@vantran-se/openchamber-web 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DZF8ntaq.js → CodeMirrorCommentWidgets-BlzB2e0C.js} +1 -1
  2. package/dist/assets/DiffView-D7JQzQVZ.js +4 -0
  3. package/dist/assets/FilesView-DC2gadXM.js +17 -0
  4. package/dist/assets/{GitView-DwQwqDvu.js → GitView-Gzl0wbdd.js} +4 -4
  5. package/dist/assets/{GuestAttachDialog-CoXM0gh_.js → GuestAttachDialog-CQdDIeco.js} +1 -1
  6. package/dist/assets/GuestSurfacePane-CrOhlIdt.js +1 -0
  7. package/dist/assets/{JsonTreeView-Cq_27v0y.js → JsonTreeView-C3QZifYe.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-CsSSRMhn.js → LinearIssuesView-X27TCI3v.js} +1 -1
  9. package/dist/assets/MarkdownImageGallery-BlTWU9oH.js +1 -0
  10. package/dist/assets/MarkdownRendererImpl-Cno7QsJO.js +12 -0
  11. package/dist/assets/{OnboardingScreen-ClatMQAX.js → OnboardingScreen-Wr_UzNtt.js} +1 -1
  12. package/dist/assets/{PatchDiff-DOwlrIK9.js → PatchDiff-D6pWS7cD.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-CrcGqqD_.js → PierreDiffViewer-DDljFbJJ.js} +3 -3
  14. package/dist/assets/{PlanView-BGLsMgQk.js → PlanView-LcfEbBPi.js} +4 -4
  15. package/dist/assets/PluginPane-DPWPLc2f.js +3 -0
  16. package/dist/assets/SettingsView-CFe9O3EM.js +30 -0
  17. package/dist/assets/{SettingsWindow-B0BAy-f9.js → SettingsWindow-DT1xhvgi.js} +1 -1
  18. package/dist/assets/{SubmoduleDiffSummary-fcdDzCSW.js → SubmoduleDiffSummary-CBHXaIkB.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-B7xaUz2H.js → ToolOutputDialog-B_ZX8ZbZ.js} +6 -6
  20. package/dist/assets/{ToolPartDiffPreview-CkWCaUmZ.js → ToolPartDiffPreview-D_HQzkXU.js} +2 -2
  21. package/dist/assets/{VirtualizedFileDiff-DONC4eI2.js → VirtualizedFileDiff-BUK1ujXg.js} +1 -1
  22. package/dist/assets/{WalkthroughView-CXDImOXW.js → WalkthroughView-H-tYOvhO.js} +2 -2
  23. package/dist/assets/{appThemeRegistry-Br2TLSlb.js → appThemeRegistry-BoJGAwCP.js} +1 -1
  24. package/dist/assets/changesTree-CePHbFcj.js +1 -0
  25. package/dist/assets/commitAndPush-BzZrF8bK.js +1 -0
  26. package/dist/assets/{computeVirtualFileMetrics-_-20umCs.js → computeVirtualFileMetrics-kYyVjXLu.js} +2 -2
  27. package/dist/assets/de-ByfQDcPj.js +10 -0
  28. package/dist/assets/es-DzNbjsQS.js +16 -0
  29. package/dist/assets/fr-B8AVLrnX.js +14 -0
  30. package/dist/assets/{index-OKDYjcMF.js → index-0-ON1L7L.js} +1 -1
  31. package/dist/assets/index-DUke1nme.css +1 -0
  32. package/dist/assets/index-Di6zUe5h.js +41 -0
  33. package/dist/assets/{isDiffPlainText-D77M6q1f.js → isDiffPlainText-Bgm_aLpu.js} +1 -1
  34. package/dist/assets/{isFilePlainText-C54B4Mns.js → isFilePlainText-D5GMgURH.js} +1 -1
  35. package/dist/assets/ja-1g6S0G19.js +16 -0
  36. package/dist/assets/ko-CxplvYkJ.js +16 -0
  37. package/dist/assets/{main-CGEvLMd2.js → main--Y98ZLsD.js} +2 -2
  38. package/dist/assets/main-GjXmVNpD.js +896 -0
  39. package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
  40. package/dist/assets/markdownCore-CVdUcVCi.js +7 -0
  41. package/dist/assets/{miniChat-BSxkRQLj.js → miniChat-tTx5mpbd.js} +2 -2
  42. package/dist/assets/{mobile-C5KRTNOB.js → mobile-BmbiDWGb.js} +2 -2
  43. package/dist/assets/patchFileDiff-CV4iVQ8L.js +13 -0
  44. package/dist/assets/pl-f3QyqvIB.js +16 -0
  45. package/dist/assets/pt-BR-BsaoaiCK.js +16 -0
  46. package/dist/assets/{renderElectronMiniChatApp-CnkAQV6o.js → renderElectronMiniChatApp-BnCdnDhv.js} +2 -2
  47. package/dist/assets/renderMobileApp-CKn8nbSW.js +25 -0
  48. package/dist/assets/runtimeEndpointReset-sCi88eed.js +27 -0
  49. package/dist/assets/scheduledTasksApi-Dahv3ws0.js +1 -0
  50. package/dist/assets/{shikiHighlight-4O0ZM14D.js → shikiHighlight-O5_xLmWt.js} +1 -1
  51. package/dist/assets/{textMateThemeFromAppTheme-yNq7b0DZ.js → textMateThemeFromAppTheme-XM4VefqN.js} +1 -1
  52. package/dist/assets/tr-BNFsa6nz.js +7 -0
  53. package/dist/assets/uk-CJ9y5ULA.js +16 -0
  54. package/dist/assets/{useAppFontEffects-Bzyszv2N.js → useAppFontEffects-BN06mgHB.js} +160 -156
  55. package/dist/assets/{useInlineCommentController-zOf6ORAq.js → useInlineCommentController-Bb9Gjz1Q.js} +2 -2
  56. package/dist/assets/{useRootScrollLock-DCaZ4BWi.js → useRootScrollLock-Chk1cFUw.js} +2 -2
  57. package/dist/assets/{vendor-codemirror-language-data-6cEFPNUR.js → vendor-codemirror-language-data-C2qMZiA7.js} +2 -2
  58. package/dist/assets/vendor-opencode-client-DSZl7jSi.js +12 -0
  59. package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
  60. package/dist/assets/{web-components-BEo4-ISu.js → web-components-BQWjCn_U.js} +1 -1
  61. package/dist/assets/zh-CN-U0QjVlAA.js +16 -0
  62. package/dist/assets/zh-TW-J9PTJQJi.js +16 -0
  63. package/dist/index.html +5 -5
  64. package/dist/mini-chat.html +5 -5
  65. package/dist/mobile.html +5 -5
  66. package/package.json +4 -4
  67. package/server/index.js +82 -0
  68. package/server/lib/agent-tool/DOCUMENTATION.md +132 -47
  69. package/server/lib/agent-tool/runtime.js +34 -15
  70. package/server/lib/agent-tool/runtime.test.js +15 -0
  71. package/server/lib/browser-control/DOCUMENTATION.md +14 -2
  72. package/server/lib/event-stream/global-hub.js +23 -1
  73. package/server/lib/event-stream/global-hub.test.js +35 -0
  74. package/server/lib/event-stream/global-ws-bridge.js +3 -1
  75. package/server/lib/event-stream/upstream-reader.js +3 -2
  76. package/server/lib/git/DOCUMENTATION.md +1 -1
  77. package/server/lib/git/service.js +22 -0
  78. package/server/lib/git/service.test.js +8 -0
  79. package/server/lib/guests/DOCUMENTATION.md +4 -3
  80. package/server/lib/guests/catalog.js +19 -1
  81. package/server/lib/guests/catalog.test.js +22 -0
  82. package/server/lib/guests/html-styles.js +5 -3
  83. package/server/lib/guests/html-styles.test.js +3 -1
  84. package/server/lib/guests/routes.js +11 -3
  85. package/server/lib/guests/service.js +5 -0
  86. package/server/lib/guests/surface.js +55 -9
  87. package/server/lib/guests/surface.test.js +56 -6
  88. package/server/lib/notifications/DOCUMENTATION.md +10 -0
  89. package/server/lib/notifications/emit-route.js +118 -0
  90. package/server/lib/notifications/emit-route.test.js +112 -0
  91. package/server/lib/openchamber-control/actions.js +16 -2
  92. package/server/lib/openchamber-control/service.js +23 -0
  93. package/server/lib/openchamber-control/service.test.js +31 -0
  94. package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
  95. package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
  96. package/server/lib/openchamber-sessions/routes.js +11 -0
  97. package/server/lib/openchamber-sessions/routes.test.js +18 -0
  98. package/server/lib/opencode/bootstrap-runtime.js +14 -1
  99. package/server/lib/opencode/compatibility.js +6 -3
  100. package/server/lib/opencode/compatibility.test.js +8 -0
  101. package/server/lib/opencode/config-entity-v2.test.js +27 -0
  102. package/server/lib/opencode/config-paths.test.js +12 -0
  103. package/server/lib/opencode/config-v2.d.ts +2 -0
  104. package/server/lib/opencode/config-v2.js +42 -0
  105. package/server/lib/opencode/config-v2.test.js +17 -0
  106. package/server/lib/opencode/core-routes.js +20 -4
  107. package/server/lib/opencode/core-routes.test.js +41 -0
  108. package/server/lib/opencode/env-runtime.js +1 -8
  109. package/server/lib/opencode/feature-routes-runtime.js +2 -1
  110. package/server/lib/opencode/lifecycle.js +30 -2
  111. package/server/lib/opencode/lifecycle.test.js +27 -0
  112. package/server/lib/opencode/managed-config-file.js +18 -6
  113. package/server/lib/opencode/managed-config-file.test.js +23 -7
  114. package/server/lib/opencode/mcp.js +7 -2
  115. package/server/lib/opencode/npm-registry-config.d.ts +1 -0
  116. package/server/lib/opencode/npm-registry-config.js +123 -0
  117. package/server/lib/opencode/npm-registry-config.test.js +167 -0
  118. package/server/lib/opencode/npm-registry.js +5 -6
  119. package/server/lib/opencode/npm-registry.test.js +30 -0
  120. package/server/lib/opencode/openchamber-routes.js +29 -11
  121. package/server/lib/opencode/openchamber-routes.test.js +18 -0
  122. package/server/lib/opencode/project-directory-runtime.js +8 -0
  123. package/server/lib/opencode/project-directory-runtime.test.js +13 -0
  124. package/server/lib/opencode/provider-source-route.test.js +59 -0
  125. package/server/lib/opencode/providers.js +3 -0
  126. package/server/lib/opencode/providers.test.js +62 -0
  127. package/server/lib/opencode/proxy.js +38 -2
  128. package/server/lib/opencode/routes-upgrade.test.js +1 -1
  129. package/server/lib/opencode/routes.js +36 -1
  130. package/server/lib/opencode/server-utils-runtime.js +5 -0
  131. package/server/lib/opencode/settings-helpers.js +10 -0
  132. package/server/lib/opencode/settings-helpers.test.js +2 -2
  133. package/server/lib/opencode/settings-registry.json +17 -0
  134. package/server/lib/opencode/settings-runtime.js +1 -0
  135. package/server/lib/opencode/shared.js +49 -4
  136. package/server/lib/opencode/shared.test.js +78 -1
  137. package/server/lib/opencode/shutdown-runtime.js +3 -0
  138. package/server/lib/opencode/skill-routes.js +28 -12
  139. package/server/lib/opencode/skill-routes.test.js +121 -1
  140. package/server/lib/opencode/upgrade-capability.js +0 -14
  141. package/server/lib/opencode/v1-migration-topup.js +21 -15
  142. package/server/lib/opencode/v1-migration-topup.test.js +14 -6
  143. package/server/lib/opencode/v2-install.d.ts +1 -0
  144. package/server/lib/opencode/v2-install.js +8 -7
  145. package/server/lib/opencode/v2-install.test.js +13 -4
  146. package/server/lib/opencode/watcher.js +3 -1
  147. package/server/lib/opencode/websearch-config.js +13 -1
  148. package/server/lib/quota/providers/kimi.js +1 -1
  149. package/server/lib/realtime-proxy.js +5 -1
  150. package/server/lib/realtime-proxy.test.js +29 -0
  151. package/server/lib/relay/tunnel-host.js +4 -1
  152. package/server/lib/relay/tunnel-host.test.js +11 -0
  153. package/server/lib/session-assist/DOCUMENTATION.md +17 -5
  154. package/server/lib/session-assist/runtime.js +19 -2
  155. package/server/lib/session-assist/runtime.test.js +8 -0
  156. package/server/lib/session-goal/DOCUMENTATION.md +11 -0
  157. package/server/lib/small-model/DOCUMENTATION.md +11 -10
  158. package/server/lib/small-model/index.js +27 -32
  159. package/server/lib/small-model/index.test.js +28 -16
  160. package/server/lib/spaces/DOCUMENTATION.md +404 -32
  161. package/server/lib/spaces/code-in-bait.js +145 -6
  162. package/server/lib/spaces/code-in.js +10 -150
  163. package/server/lib/spaces/code-in.test.js +7 -83
  164. package/server/lib/spaces/code-out.js +1819 -0
  165. package/server/lib/spaces/code-out.test.js +3945 -0
  166. package/server/lib/spaces/code-transfer.js +173 -0
  167. package/server/lib/spaces/command-stream.test.js +181 -0
  168. package/server/lib/spaces/dispatcher.js +670 -0
  169. package/server/lib/spaces/dispatcher.test.js +582 -0
  170. package/server/lib/spaces/gatekeeper-channel.js +61 -7
  171. package/server/lib/spaces/gatekeeper-channel.test.js +43 -7
  172. package/server/lib/spaces/gatekeeper-program.cjs +68 -14
  173. package/server/lib/spaces/gatekeeper-program.test.js +118 -3
  174. package/server/lib/spaces/hardening.js +20 -4
  175. package/server/lib/spaces/hardening.test.js +18 -3
  176. package/server/lib/spaces/host-git.js +7 -4
  177. package/server/lib/spaces/host-git.test.js +6 -2
  178. package/server/lib/spaces/host.js +310 -0
  179. package/server/lib/spaces/host.test.js +273 -0
  180. package/server/lib/spaces/journey.js +552 -0
  181. package/server/lib/spaces/journey.test.js +589 -0
  182. package/server/lib/spaces/layout.js +42 -8
  183. package/server/lib/spaces/manager.js +4 -3
  184. package/server/lib/spaces/manager.test.js +6 -0
  185. package/server/lib/spaces/places/code-out.docker.live.test.js +412 -0
  186. package/server/lib/spaces/places/contract-suite.js +36 -0
  187. package/server/lib/spaces/places/dispatcher.docker.live.test.js +296 -0
  188. package/server/lib/spaces/places/docker-live-support.js +27 -4
  189. package/server/lib/spaces/places/docker.js +33 -5
  190. package/server/lib/spaces/places/docker.test.js +42 -3
  191. package/server/lib/spaces/places/escape-suite.js +118 -14
  192. package/server/lib/spaces/places/fake-docker.js +3 -1
  193. package/server/lib/spaces/places/grants.docker.live.test.js +197 -0
  194. package/server/lib/spaces/places/memory-place.js +24 -1
  195. package/server/lib/spaces/places/registry.js +1 -1
  196. package/server/lib/spaces/places/server.docker.live.test.js +69 -33
  197. package/server/lib/spaces/places/sessions.docker.live.test.js +222 -0
  198. package/server/lib/spaces/routes.js +216 -0
  199. package/server/lib/spaces/routes.test.js +213 -0
  200. package/server/lib/spaces/run-command.js +261 -8
  201. package/server/lib/spaces/run-command.test.js +193 -3
  202. package/server/lib/spaces/space-events.js +153 -0
  203. package/server/lib/spaces/space-events.test.js +160 -0
  204. package/server/lib/spaces/space-opencode.js +52 -0
  205. package/server/lib/spaces/space-opencode.test.js +41 -0
  206. package/server/lib/spaces/space-records.js +150 -0
  207. package/server/lib/spaces/space-records.test.js +113 -0
  208. package/server/lib/spaces/space-sessions.js +210 -0
  209. package/server/lib/spaces/space-sessions.test.js +161 -0
  210. package/server/lib/spaces/websocket.js +329 -0
  211. package/server/lib/spaces/websocket.test.js +345 -0
  212. package/server/lib/ui-auth/ui-auth.js +8 -2
  213. package/server/lib/ui-auth/ui-auth.test.js +29 -0
  214. package/server/opencode-proxy.test.js +113 -0
  215. package/dist/assets/DiffView-D2p4Ar0H.js +0 -4
  216. package/dist/assets/FilesView-BeTtbsip.js +0 -17
  217. package/dist/assets/GuestSurfacePane-DIJvkkM-.js +0 -1
  218. package/dist/assets/MarkdownImageGallery-CY0dWTaE.js +0 -1
  219. package/dist/assets/MarkdownRendererImpl-ILdXzLrt.js +0 -12
  220. package/dist/assets/PluginPane-B39JEUL8.js +0 -3
  221. package/dist/assets/SettingsView-13B2_G-A.js +0 -29
  222. package/dist/assets/commitAndPush-CcI4ol7c.js +0 -1
  223. package/dist/assets/de-BtYnUgII.js +0 -10
  224. package/dist/assets/es-crP5qPye.js +0 -16
  225. package/dist/assets/fr-CLSRuALk.js +0 -14
  226. package/dist/assets/index-CLcM8HKx.css +0 -1
  227. package/dist/assets/index-CvLgnuNI.js +0 -41
  228. package/dist/assets/ja-SZ1-ucLV.js +0 -16
  229. package/dist/assets/ko-HthbT_Ve.js +0 -16
  230. package/dist/assets/main-BJklC7Cl.js +0 -896
  231. package/dist/assets/markdownCore-BzQuETm0.js +0 -5
  232. package/dist/assets/patchFileDiff-DGw2KryM.js +0 -13
  233. package/dist/assets/pl-C8eYfjL1.js +0 -16
  234. package/dist/assets/pt-BR-cYOrZdxS.js +0 -16
  235. package/dist/assets/renderMobileApp-CMxjwisj.js +0 -25
  236. package/dist/assets/runtimeEndpointReset-C45jrFq4.js +0 -27
  237. package/dist/assets/scheduledTasksApi-CkK1F9s2.js +0 -1
  238. package/dist/assets/tr-B4IQ5t-T.js +0 -7
  239. package/dist/assets/uk-DCoXG6ve.js +0 -16
  240. package/dist/assets/vendor-opencode-client-_BAHQo4R.js +0 -12
  241. package/dist/assets/vendor-zod-Gea9uBlY.js +0 -39
  242. package/dist/assets/zh-CN-BXBoxsFk.js +0 -16
  243. package/dist/assets/zh-TW-C6oelpnL.js +0 -16
@@ -0,0 +1,30 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
2
+ import{R as o,j as s,f as tt,r as et}from"./vendor-react-BUCujlKS.js";import{f as Qe,B as G,I as _,o as jn,bj as Zn,t as $,O as Kd,h0 as zd,e$ as qe,h1 as Ct,g as _a,eK as Cc,b as pn,T as fa,h as Pe,au as Ud,h2 as Pr,h3 as _d,cl as $t,ck as At,cn as ut,cm as Tt,cj as Et,eR as Qn,h4 as Ic,h5 as $d,h6 as Ua,h7 as _n,c8 as Ns,c2 as Ut,c3 as _t,c4 as Vt,c5 as Ht,c6 as qt,c7 as as,X as He,h8 as pi,av as kn,bh as an,at as Nn,as as Sn,h9 as Xr,ha as Vi,ad as Yn,ac as un,f5 as Gt,hb as mn,hc as fo,hd as vs,l as rt,he as di,fm as zn,hf as Pc,fj as It,fg as Bt,hg as Ft,co as As,ea as ca,fi as Ws,fk as nn,hh as us,ef as hs,hi as bs,cW as gt,hj as Ac,hk as Bd,hl as Vd,hm as gi,hn as Hd,ho as ws,e_ as Ps,hp as tn,gj as Wa,gp as sn,hq as $a,hr as Tc,hs as xo,eb as bo,ah as Ba,ht as eo,hu as Bo,hv as qd,cg as Cn,cr as In,ch as Pn,hw as Vo,hx as An,hy as Jt,hz as vo,ae as ar,af as ir,ag as yo,hA as jo,hB as na,hC as Ec,hD as Ln,a7 as Ja,cw as wo,hE as Ho,ay as Gd,cp as Wd,da as Jd,U as Qd,V as Yd,W as Zd,_ as ko,hF as Xd,hG as eu,ce as tu,cq as to,hH as Dc,P as Va,hI as Fs,fl as su,a6 as nu,hJ as au,n as rs,ex as Qi,y as Mc,x as iu,i as ru,j as ou,ey as lu,p as cu,hK as du,hL as uu,hM as qo,eg as Rc,hN as mu,hO as Ar,hP as Go,hQ as pu,hR as gu,hS as hu,hT as fu,gd as Yi,hU as cs,hV as js,dh as Fc,bZ as Oc,di as Lc,b_ as qs,hW as Kn,hX as No,aH as Jn,aI as Ma,hY as Xs,hZ as On,dv as Kc,h_ as zc,h$ as Uc,i0 as xu,eZ as bu,eY as vu,i1 as so,eI as yu,i2 as aa,i3 as Rs,i4 as Hs,g6 as ia,i5 as ks,i6 as ju,i7 as Wo,i8 as _c,i9 as ra,ia as wu,ib as ku,R as $c,db as Nu,d5 as Su,d6 as Cu,cJ as Iu,eT as Pu,d7 as Au,d1 as Tu,bp as Eu,ic as Qa,ff as Ra,id as Jo,ie as Fa,ig as Oa,b$ as ua,ih as Du,ii as Mu,ij as Ru,ik as Fu,il as Tr,im as Qo,io as Ou,ip as Lu,iq as Ku,ir as zu,is as Yo,z as Uu,m as Zo,dz as _u,it as $u,iu as Er,iv as Xo,eC as Bu,iw as rr,ix as Vu,iy as Hu,iz as qu,iA as Gu,iB as Wu,iC as Dr,cX as Ju,c0 as Bc,aB as Hn,aC as Qu}from"./useAppFontEffects-BN06mgHB.js";import{h as St,i as So,u as he,P as fs,dG as Yu,dH as el,v as xt,aF as En,C as Ms,a as wn,F as ls,Q as tl,cN as sl,cU as nl,V as ei,p as Zu,dI as Xu,k as em,cM as Ka,dJ as tm,an as sm,cR as nm,dK as am,dL as im,s as rm,e as hi,cS as om,H as fi,dM as Vc,$ as lm,dN as cm,a4 as Hc,aE as os,dO as qc,bb as Gc,y as Ha,b4 as Wc,ag as dm,ah as um,aO as Co,dP as mm,z as or,_ as pm,q as al,aT as il,bf as Di,aU as gm,dQ as hm,ac as da,dR as fm,dS as rl,dF as ol,dT as ll,aR as cl,dU as xm,dV as bm,dW as vm,dX as ym,dY as dl,b as jm,dZ as wm,d_ as km,d$ as Nm,e0 as Sm,e1 as Cm,e2 as Im,ay as Pm}from"./index-Di6zUe5h.js";import{u as Am,X as ul,aq as Tm,ar as Em,as as Dm,Z as ma,$ as pa,a0 as ga,a1 as ha,m as Io,at as oa,a5 as Mm,z as Is,au as Rm,ao as Fm,a3 as Om,av as za,aw as Jc,a2 as Lm,a4 as Km}from"./runtimeEndpointReset-sCi88eed.js";import{u as Bs,c as zm}from"./vendor-zustand-BAGL70zf.js";import{o as Ts,s as Mt,b as Po,l as Um,r as Un,c as no,a as xa,_ as Ao,u as ao}from"./vendor-zod-BSoePkpP.js";import{s as _m,p as $m}from"./vendor-yaml-3778uTud.js";import{c as ml,s as Bm,C as pl,P as Vm}from"./shikiHighlight-O5_xLmWt.js";import{getResolvedShikiTheme as Hm}from"./appThemeRegistry-BoJGAwCP.js";import{E as gl}from"./vendor-codemirror-view-CiLROUVV.js";import{Q as Qc}from"./vendor-qrcode-DTJ12-WC.js";import{u as Mr,s as qm,d as Gm,b as Wm,A as Jm,c as Qm,e as Ym,f as Zm,h as Xm,i as Rr,j as ep}from"./PluginPane-DPWPLc2f.js";import{toast as qa}from"./vendor-sonner-DFyL3AvE.js";import{s as tp}from"./vendor-strip-json-comments-5dJlOkP1.js";import{Y as sp,U as np,X as ap,W as ip,V as rp}from"./vendor-base-ui-CsXYnR5c.js";import{_ as op}from"./vendor-vite-runtime-DD1OZmLC.js";const hl=()=>{const{t}=Qe(),[e,a]=o.useState(null);o.useEffect(()=>{let r=!1;const i=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const d=await St("/api/system/info",{signal:i?.signal,headers:{Accept:"application/json"}});if(!d.ok)return;const c=await d.json().catch(()=>null);if(!c||r)return;const h=typeof c.port=="number"&&Number.isFinite(c.port)&&c.port>0?c.port:null,g=typeof c.tunnelUrl=="string"&&c.tunnelUrl.trim().length>0?c.tunnelUrl.trim():null;a({port:h,tunnelUrl:g})}catch{}})(),()=>{r=!0,i?.abort()}},[]);const n=[];return e?.port!==null&&e?.port!==void 0&&n.push({key:"application",label:t("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${e.port}/`}),e?.tunnelUrl&&n.push({key:"tunnel",label:t("settings.openchamber.about.field.tunnelUrl"),url:e.tunnelUrl}),n.length===0?null:s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(r=>s.jsxs(G,{type:"button",variant:"outline",size:"sm",title:r.label,className:"max-w-full gap-1.5 px-2.5",onClick:()=>{jn(r.url)},children:[s.jsx(_,{name:"external-link",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"max-w-64 truncate font-mono typography-micro",children:r.url})]},r.key))})},fl="https://github.com/openchamber/openchamber",lp="https://discord.gg/ZYRSdnwwKA",xl="https://x.com/openchamber_dev",cp=800,dp={info:null,checking:!1,available:!1,error:null};function up(t){const e=tt.c(5),[a,n]=o.useState(dp);let r;e[0]!==t?(r=async()=>{if(t){n(mp);try{const d=await Tm();n({info:d,checking:!1,available:d.available,error:null})}catch(d){const c=d;n({info:null,checking:!1,available:!1,error:c instanceof Error?c.message:String(c)})}}},e[0]=t,e[1]=r):r=e[1];const i=r;let l;return e[2]!==i||e[3]!==a?(l={...a,check:i},e[2]=i,e[3]=a,e[4]=l):l=e[4],l}function mp(t){return{...t,checking:!0,error:null}}function pp(t){const e=tt.c(11),[a,n]=o.useState(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={kind:"idle"},e[0]=r):r=e[0];const[i,l]=o.useState(r);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{try{const b=await Em();return n(b),b}catch{return null}},e[1]=d):d=e[1];const c=d;let h,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{c()},g=[c],e[2]=h,e[3]=g):(h=e[2],g=e[3]),o.useEffect(h,g);let f;e[4]!==t?(f=async()=>{l({kind:"upgrading"});try{const b=await Dm(t);l({kind:"installed",version:b})}catch(b){const k=b;l({kind:"failed",error:k instanceof Error?k.message:t})}},e[4]=t,e[5]=f):f=e[5];const m=f;let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=async b=>{await b().catch(gp);const k=await c();k?.currentVersion&&l(p=>p.kind!=="installed"||p.version&&p.version.replace(/^v/,"")!==k.currentVersion?p:{kind:"idle"})},e[6]=u):u=e[6];const v=u;let w;return e[7]!==i||e[8]!==a||e[9]!==m?(w={status:a,phase:i,refresh:c,upgrade:m,reloadAfterUpgrade:v},e[7]=i,e[8]=a,e[9]=m,e[10]=w):w=e[10],w}function gp(){}function hp(t){const[e,a]=o.useState(null);return o.useEffect(()=>{if(!t)return;let n=!1;return op(async()=>{const{App:r}=await import("./vendor-capacitor-app-BrDJj9I_.js");return{App:r}},__vite__mapDeps([0,1,2])).then(({App:r})=>r.getInfo()).then(r=>{n||a(r.version.trim()||null)}).catch(()=>{}),()=>{n=!0}},[t]),e}const Yc=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=Qe(),[a,n]=o.useState(t),[r,i]=o.useState(!1),[l,d]=o.useState(null),c=Am(Bs(O=>({info:O.info,checking:O.checking,available:O.available,error:O.error,downloading:O.downloading,downloaded:O.downloaded,progress:O.progress,runtimeType:O.runtimeType,checkForUpdates:O.checkForUpdates,downloadUpdate:O.downloadUpdate,restartToUpdate:O.restartToUpdate}))),{isMobile:h}=Zn(),g=o.useMemo(()=>So(),[]),f=up(g),m=hp(g),u=g?{info:f.info,checking:f.checking,available:f.available,error:f.error,checkForUpdates:f.check,runtimeType:"web"}:{info:c.info,checking:c.checking,available:c.available,error:c.error,checkForUpdates:c.checkForUpdates,runtimeType:c.runtimeType},v=l||u.info?.currentVersion||"unknown",w=pp(e("opencodeUpdate.toast.failed.description")),b=w.status?.currentVersion??null,k=w.phase.kind==="installed"?null:w.status?.availableVersion??null,[p,S]=o.useState(!1),N=(()=>{const O=u.info?.version||"";return g?u.info?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:O}):e("settings.openchamber.about.actions.updateServerToVersion",{version:O}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:O})})(),I=u.available&&u.info?.installBlocked==="service-manager",y=u.info?.updateCommand||"openchamber update",T=()=>{u.checkForUpdates(),w.refresh()},x=async()=>{(await _a(y)).ok&&(S(!0),setTimeout(()=>S(!1),2e3))},A=()=>{w.reloadAfterUpgrade(async()=>{await Cc({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})})},R=I?s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.serviceManagerUpdate",{version:u.info?.version||""})}),s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-elevated/50 p-1 pl-3",children:[s.jsx("code",{className:"flex-1 overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground",children:y}),s.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{x()},"aria-label":e(p?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(_,{name:p?"check":"clipboard",className:"size-4"})})]})]}):null,P=(()=>{const{phase:O}=w;if(O.kind==="installed")return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:O.version?e("settings.openchamber.about.openCode.installedVersion",{version:O.version}):e("settings.openchamber.about.openCode.installed")}),s.jsx(G,{type:"button",size:"sm",variant:"outline",onClick:A,children:e("opencodeUpdate.toast.actions.reload")})]});if(!k)return null;if(!w.status?.supported)return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:k})});const C=O.kind==="upgrading";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>{w.upgrade()},disabled:C,children:[s.jsx(_,{name:C?"loader":"download",className:C?"size-4 animate-spin":"size-4"}),C?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:k})]}),O.kind==="failed"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:O.error})]})})();o.useEffect(()=>{let O=!1;return(async()=>{try{const M=await St("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!M.ok)return;const U=await M.json().catch(()=>null),L=typeof U?.openchamberVersion=="string"&&U.openchamberVersion.trim().length>0?U.openchamberVersion.trim():null;O||d(L)}catch{O||d(null)}})(),()=>{O=!0}},[]);const D=o.useRef(!1);o.useEffect(()=>{if(u.checking)i(!0),D.current=!0;else if(r){const O=setTimeout(()=>{i(!1),D.current&&!u.available&&!u.error&&($.success(e(g?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),D.current=!1)},cp);return()=>clearTimeout(O)}},[e,g,u.checking,r,u.available,u.error]);const F=u.checking||r;return h?s.jsxs("div",{className:"w-full space-y-6 pb-2",children:[s.jsxs("div",{className:"flex flex-col items-center text-center",children:[s.jsx(Kd,{width:72,height:72}),s.jsx("h2",{className:`mt-4 ${zd}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:g?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:v})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:b||e("settings.openchamber.about.state.unknown")})}),m&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:m})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:v})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:b||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(hl,{})]}),s.jsxs("div",{className:"flex justify-center",children:[!u.available&&!u.error&&s.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:F,className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[F?s.jsx(_,{name:"loader",className:"size-4 animate-spin"}):s.jsx(_,{name:"refresh",className:"size-4"}),e(F?"settings.openchamber.about.state.checking":g?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!F&&u.available&&!I&&s.jsxs(G,{type:"button",variant:"default",size:"sm",onClick:()=>n(!0),className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[s.jsx(_,{name:"download",className:"size-4"}),N]})]}),R,P&&s.jsx("div",{className:"flex justify-center text-center",children:P}),u.error&&s.jsx("p",{className:"rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:u.error}),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:fl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:lp,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:xl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(_,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),s.jsx(ul,{open:a,onOpenChange:n,info:u.info,downloading:c.downloading,downloaded:c.downloaded,progress:c.progress,error:u.error,onDownload:c.downloadUpdate,onRestart:c.restartToUpdate,runtimeType:u.runtimeType})]}):s.jsxs(qe,{divider:!1,children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center justify-between gap-4 px-4 py-3 border-b border-border/40",children:[s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Ct,children:e("settings.openchamber.about.field.version")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:v})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Ct,children:e("settings.openchamber.about.field.openCodeVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:b||e("settings.openchamber.about.state.unknown")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[u.checking&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(_,{name:"loader",className:"h-4 w-4 animate-spin"}),s.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!u.checking&&u.available&&!I&&s.jsxs(G,{size:"sm",variant:"default",onClick:()=>n(!0),children:[s.jsx(_,{name:"download",className:"h-4 w-4 mr-1"}),N]}),!u.checking&&!u.available&&!u.error&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),s.jsx(G,{size:"sm",variant:"outline",onClick:T,disabled:u.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),R&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:R}),P&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:P}),u.error&&s.jsx("div",{className:"px-3 py-2 border-b border-border/40",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:u.error})}),s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-4 py-3 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsx("span",{className:Ct,children:e("settings.openchamber.about.field.instanceUrls")}),s.jsx(hl,{})]}),s.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[s.jsxs("a",{href:fl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(_,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:xl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(_,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]})]}),s.jsx(ul,{open:a,onOpenChange:n,info:u.info,downloading:c.downloading,downloaded:c.downloaded,progress:c.progress,error:u.error,onDownload:c.downloadUpdate,onRestart:c.restartToUpdate,runtimeType:u.runtimeType})]})},fp=(t,e,a)=>t&&e.some(r=>r.path===t)?t:(e.find(r=>r.id===a)??e[0])?.path??null,rn=()=>{const t=tt.c(4),e=he(xp),a=pn(bp),n=pn(vp);let r;return t[0]!==n||t[1]!==a||t[2]!==e?(r=fp(e,a,n),t[0]=n,t[1]=a,t[2]=e,t[3]=r):r=t[3],r};function xp(t){return t.settingsProjectPath}function bp(t){return t.projects}function vp(t){return t.activeProjectId}const yp=t=>[...t].sort((e,a)=>(e.label||e.path).localeCompare(a.label||a.path)),xi=t=>{const e=tt.c(75),{className:a}=t,{t:n}=Qe(),{currentTheme:r}=fa(),i=he(jp),[l,d]=o.useState(!1),c=pn(wp),h=rn(),g=he(kp),f=fs();let m;e[0]!==c?(m=yp(c),e[0]=c,e[1]=m):m=e[1];const u=m;let v;e[2]!==h||e[3]!==u?(v=u.find(F=>F.path===h)??u[0]??null,e[2]=h,e[3]=u,e[4]=v):v=e[4];const w=v;if(f||!w)return null;let b;e[5]!==g||e[6]!==u?(b=F=>{const O=u.find(C=>C.id===F);O&&g(O.path)},e[5]=g,e[6]=u,e[7]=b):b=e[7];const k=b;if(i){let F;e[8]!==a?(F=Pe(a),e[8]=a,e[9]=F):F=e[9];let O;e[10]!==n?(O=n("settings.shared.projectSelector.switchProjectAria"),e[10]=n,e[11]=O):O=e[11];let C;e[12]!==n?(C=n("settings.shared.projectSelector.switchProjectTitle"),e[12]=n,e[13]=C):C=e[13];let M,U;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=()=>d(!0),U=Pe(Ud({size:"touch"}),"w-full min-w-0"),e[14]=M,e[15]=U):(M=e[14],U=e[15]);let L;e[16]!==w||e[17]!==r?(L=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(Pr,{project:w,theme:r})}),e[16]=w,e[17]=r,e[18]=L):L=e[18];let W;e[19]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(_,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[19]=W):W=e[19];let X;e[20]!==l||e[21]!==O||e[22]!==C||e[23]!==U||e[24]!==L?(X=s.jsxs("button",{type:"button","aria-label":O,title:C,"aria-haspopup":"dialog","aria-expanded":l,onClick:M,className:U,children:[L,W]}),e[20]=l,e[21]=O,e[22]=C,e[23]=U,e[24]=L,e[25]=X):X=e[25];let J;e[26]!==X||e[27]!==F?(J=s.jsx("div",{className:F,children:X}),e[26]=X,e[27]=F,e[28]=J):J=e[28];let q;e[29]===Symbol.for("react.memo_cache_sentinel")?(q=()=>d(!1),e[29]=q):q=e[29];const z=w.id;let H;e[30]!==n?(H=n("settings.shared.projectSelector.sheetTitle"),e[30]=n,e[31]=H):H=e[31];let se;e[32]!==n?(se=n("settings.shared.projectSelector.searchPlaceholder"),e[32]=n,e[33]=se):se=e[33];let B;e[34]!==w.id||e[35]!==r||e[36]!==k||e[37]!==l||e[38]!==u||e[39]!==H||e[40]!==se?(B=s.jsx(_d,{open:l,onClose:q,projects:u,selectedProjectId:z,onSelectProject:k,theme:r,title:H,searchPlaceholder:se}),e[34]=w.id,e[35]=r,e[36]=k,e[37]=l,e[38]=u,e[39]=H,e[40]=se,e[41]=B):B=e[41];let ne;return e[42]!==J||e[43]!==B?(ne=s.jsxs(s.Fragment,{children:[J,B]}),e[42]=J,e[43]=B,e[44]=ne):ne=e[44],ne}let p;e[45]!==a?(p=Pe(a),e[45]=a,e[46]=p):p=e[46];const S=w.id;let N;e[47]!==k?(N=F=>{F&&k(F)},e[47]=k,e[48]=N):N=e[48];let I;e[49]!==n?(I=n("settings.shared.projectSelector.switchProjectAria"),e[49]=n,e[50]=I):I=e[50];let y;e[51]!==n?(y=n("settings.shared.projectSelector.switchProjectTitle"),e[51]=n,e[52]=y):y=e[52];let T;e[53]!==w||e[54]!==r?(T=s.jsx($t,{children:s.jsx(Pr,{project:w,theme:r})}),e[53]=w,e[54]=r,e[55]=T):T=e[55];let x;e[56]!==I||e[57]!==y||e[58]!==T?(x=s.jsx(At,{size:"settings",className:"w-full","aria-label":I,title:y,children:T}),e[56]=I,e[57]=y,e[58]=T,e[59]=x):x=e[59];let A;if(e[60]!==r||e[61]!==u){let F;e[63]!==r?(F=O=>s.jsx(ut,{value:O.id,className:"max-w-[24rem] truncate",children:s.jsx(Pr,{project:O,theme:r})},O.id),e[63]=r,e[64]=F):F=e[64],A=u.map(F),e[60]=r,e[61]=u,e[62]=A}else A=e[62];let R;e[65]!==A?(R=s.jsx(Tt,{fitContent:!0,children:A}),e[65]=A,e[66]=R):R=e[66];let P;e[67]!==w.id||e[68]!==x||e[69]!==R||e[70]!==N?(P=s.jsxs(Et,{value:S,onValueChange:N,children:[x,R]}),e[67]=w.id,e[68]=x,e[69]=R,e[70]=N,e[71]=P):P=e[71];let D;return e[72]!==P||e[73]!==p?(D=s.jsx("div",{className:p,children:P}),e[72]=P,e[73]=p,e[74]=D):D=e[74],D};function jp(t){return t.isMobile}function wp(t){return t.projects}function kp(t){return t.setSettingsProjectPath}function Np(t,e){return`opencode:sidebar-group:${t}:${e}`}const io=t=>{const e=tt.c(33),{label:a,count:n,storageKey:r,defaultExpanded:i,children:l}=t,d=i===void 0?!0:i;let c;e[0]!==a||e[1]!==r?(c=Np(r,a),e[0]=a,e[1]=r,e[2]=c):c=e[2];const h=c,g=o.useId();let f;e[3]!==d||e[4]!==h?(f=()=>{try{const P=localStorage.getItem(h);if(P!==null)return P==="true"}catch{}return d},e[3]=d,e[4]=h,e[5]=f):f=e[5];const[m,u]=et.useState(f);let v,w;e[6]!==m||e[7]!==h?(v=()=>{try{localStorage.setItem(h,String(m))}catch{}},w=[h,m],e[6]=m,e[7]=h,e[8]=v,e[9]=w):(v=e[8],w=e[9]),et.useEffect(v,w);let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=()=>u(Sp),e[10]=b):b=e[10];let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=Pe("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-ring"),e[11]=k):k=e[11];const p=!m&&"-rotate-90";let S;e[12]!==p?(S=Pe("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",p),e[12]=p,e[13]=S):S=e[13];let N;e[14]!==S?(N=s.jsx(_,{name:"arrow-down-s",className:S}),e[14]=S,e[15]=N):N=e[15];let I;e[16]!==a?(I=s.jsx("span",{className:"flex-1 truncate",children:a}),e[16]=a,e[17]=I):I=e[17];let y;e[18]!==n?(y=s.jsx("span",{className:"ml-1 tabular-nums opacity-60",children:n}),e[18]=n,e[19]=y):y=e[19];let T;e[20]!==g||e[21]!==m||e[22]!==N||e[23]!==I||e[24]!==y?(T=s.jsxs("button",{type:"button",onClick:b,"aria-expanded":m,"aria-controls":g,className:k,children:[N,I,y]}),e[20]=g,e[21]=m,e[22]=N,e[23]=I,e[24]=y,e[25]=T):T=e[25];const x=!m;let A;e[26]!==l||e[27]!==g||e[28]!==x?(A=s.jsx("div",{id:g,hidden:x,className:"mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]",children:l}),e[26]=l,e[27]=g,e[28]=x,e[29]=A):A=e[29];let R;return e[30]!==T||e[31]!==A?(R=s.jsxs("div",{children:[T,A]}),e[30]=T,e[31]=A,e[32]=R):R=e[32],R};function Sp(t){return!t}const Cp=({onItemSelect:t})=>{const{t:e}=Qe(),[a,n]=o.useState(null),[r,i]=o.useState(""),[l,d]=o.useState(null),[c,h]=o.useState(null),[g,f]=o.useState(!1),[m,u]=o.useState(null),{selectedAgentName:v,setSelectedAgent:w,setAgentDraft:b,createAgent:k,deleteAgent:p,loadAgents:S,fetchAgentEntity:N}=Qn(Bs(q=>({selectedAgentName:q.selectedAgentName,setSelectedAgent:q.setSelectedAgent,setAgentDraft:q.setAgentDraft,createAgent:q.createAgent,deleteAgent:q.deleteAgent,loadAgents:q.loadAgents,fetchAgentEntity:q.fetchAgentEntity}))),I=rn(),y=Qn(q=>Ic(q,I));o.useEffect(()=>{S(I)},[S,I]);const T="bg-background",x=()=>{const q="new-agent";let z=q,H=1;for(;y.some(se=>se.name===z);)z=`${q}-${H}`,H++;b({name:z,scope:"user"}),w(z),t?.()},A=async q=>{if(Ua(q)){$.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(q),h("delete")},R=async q=>{Ua(q)&&(d(q),h("reset"))},P=()=>{d(null),h(null)},D=async()=>{if(!(!l||!c)){f(!0);try{(await p(l.name,l.scope,I)).ok?(c==="delete"?$.success(e("settings.agents.sidebar.toast.agentDeleted",{name:l.name})):$.success(e("settings.agents.sidebar.toast.agentReset",{name:l.name})),P()):c==="delete"?$.error(e("settings.agents.sidebar.toast.deleteFailed")):$.error(e("settings.agents.sidebar.toast.resetFailed"))}catch(q){const z=q instanceof Error?q.message:"",H=/built-in|not deletable|not found/i.test(z);c==="delete"?$.error(e(H?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed")):$.error(e("settings.agents.sidebar.toast.resetFailed"))}f(!1)}},F=async q=>{const z=q.name;let H=1,se=`${z}-copy`;for(;y.some(Z=>Z.name===se);)H++,se=`${z}-copy-${H}`;const B=q,ne=await N(q.name,I);if(!ne){$.error(e("settings.agents.sidebar.toast.renameFailed"));return}const K=ne.config.request?.body;b({name:se,scope:ne.scope??B.scope??"user",description:ne.config.description??void 0,model:ne.config.model??null,system:ne.config.system??void 0,steps:ne.config.steps??void 0,temperature:K?.temperature,top_p:K?.top_p,mode:ne.config.mode??B.mode,permissions:ne.config.permissions??void 0}),w(se),t?.()},O=q=>{i(q.name),n(q)},C=async()=>{if(!a)return;const q=r.trim().replace(/\s+/g,"-");if(!q){$.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(q===a.name){n(null);return}if(y.some(B=>B.name===q)){$.error(e("settings.agents.sidebar.toast.agentExists"));return}const z=a,H=await N(a.name,I);if(!H){$.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await k({...H.config,name:q,scope:H.scope??z.scope},I)).ok?(await p(a.name,z.scope,I)).ok?($.success(e("settings.agents.sidebar.toast.agentRenamed",{name:q})),w(q)):$.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):$.error(e("settings.agents.sidebar.toast.renameFailed")),n(null)},M=q=>{switch(q){case"primary":return s.jsx(_,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(_,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(_,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},U=y.filter(q=>!$d(q)),L=U.filter(Ua),W=U.filter(q=>!Ua(q)),{groupedCustomAgents:X,ungroupedCustomAgents:J}=et.useMemo(()=>{const q={},z=[];for(const se of W){const B=se;B.group?(q[B.group]||(q[B.group]=[]),q[B.group].push(se)):z.push(se)}return{groupedCustomAgents:Object.keys(q).sort((se,B)=>se.localeCompare(B)).map(se=>({name:se,agents:q[se]})),ungroupedCustomAgents:z}},[W]);return s.jsxs("div",{className:Pe("flex h-full flex-col",T),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${_n} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(xi,{className:"mb-3"}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:U.length})}),s.jsx(G,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:x,children:s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:U.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[L.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),L.map(q=>s.jsx(Fr,{agent:q,isSelected:v===q.name,onSelect:()=>{w(q.name),t?.()},onReset:()=>R(q),onDuplicate:()=>{F(q)},getAgentModeIcon:M,isMenuOpen:m===q.name,onMenuOpenChange:z=>u(z?q.name:null)},q.name))]}),W.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),X.map(({name:q,agents:z})=>s.jsx(io,{label:q,count:z.length,storageKey:"agents",children:z.map(H=>s.jsx(Fr,{agent:H,isSelected:v===H.name,onSelect:()=>{w(H.name),t?.()},onRename:()=>O(H),onDelete:()=>A(H),onDuplicate:()=>{F(H)},getAgentModeIcon:M,isMenuOpen:m===H.name,onMenuOpenChange:se=>u(se?H.name:null)},H.name))},q)),J.map(q=>s.jsx(Fr,{agent:q,isSelected:v===q.name,onSelect:()=>{w(q.name),t?.()},onRename:()=>O(q),onDelete:()=>A(q),onDuplicate:()=>{F(q)},getAgentModeIcon:M,isMenuOpen:m===q.name,onMenuOpenChange:z=>u(z?q.name:null)},q.name))]})]})}),s.jsx(Ut,{open:l!==null&&c!==null,onOpenChange:q=>{!q&&!g&&P()},children:s.jsxs(_t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:e(c==="delete"?"settings.agents.sidebar.dialog.deleteTitle":"settings.agents.sidebar.dialog.resetTitle")}),s.jsx(qt,{children:c==="delete"?e("settings.agents.sidebar.dialog.deleteDescription",{name:l?.name??""}):e("settings.agents.sidebar.dialog.resetDescription",{name:l?.name??""})})]}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:P,disabled:g,children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:D,disabled:g,children:e(c==="delete"?"settings.common.actions.delete":"settings.common.actions.reset")})]})]})}),s.jsx(Ut,{open:a!==null,onOpenChange:q=>!q&&n(null),children:s.jsxs(_t,{children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(qt,{children:e("settings.agents.sidebar.renameDialog.description",{name:a?.name??""})})]}),s.jsx(He,{value:r,onChange:q=>i(q.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:q=>{q.key==="Enter"&&C()}}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>n(null),children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:C,children:e("settings.common.actions.rename")})]})]})})]})},Fr=t=>{const e=tt.c(52),{agent:a,isSelected:n,onSelect:r,onDelete:i,onReset:l,onRename:d,onDuplicate:c,getAgentModeIcon:h,isMenuOpen:g,onMenuOpenChange:f}=t,{t:m}=Qe(),u=a;let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=pi(),e[0]=v):v=e[0];const w=v,[b,k]=o.useState(!1);let p;e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==l||e[5]!==m?(p=q=>s.jsxs(s.Fragment,{children:[d&&s.jsxs(q,{onClick:z=>{z.stopPropagation(),d()},children:[s.jsx(_,{name:"edit",className:"h-4 w-4 mr-px"}),m("settings.common.actions.rename")]}),s.jsxs(q,{onClick:z=>{z.stopPropagation(),c()},children:[s.jsx(_,{name:"file-copy",className:"h-4 w-4 mr-px"}),m("settings.common.actions.duplicate")]}),l&&s.jsxs(q,{onClick:z=>{z.stopPropagation(),l()},children:[s.jsx(_,{name:"restart",className:"h-4 w-4 mr-px"}),m("settings.common.actions.reset")]}),i&&s.jsxs(q,{onClick:z=>{z.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),m("settings.common.actions.delete")]})]}),e[1]=i,e[2]=c,e[3]=d,e[4]=l,e[5]=m,e[6]=p):p=e[6];const S=p,N=n?"bg-interactive-selection":"hover:bg-interactive-hover";let I;e[7]!==N?(I=Pe("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",N),e[7]=N,e[8]=I):I=e[8];let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=w?void 0:q=>{q.preventDefault(),k(!0)},e[9]=y):y=e[9];let T;e[10]!==I?(T=s.jsx("div",{className:I,onContextMenu:y}),e[10]=I,e[11]=T):T=e[11];let x;e[12]!==a.name?(x=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name}),e[12]=a.name,e[13]=x):x=e[13];let A;e[14]!==a.mode||e[15]!==h?(A=h(a.mode),e[14]=a.mode,e[15]=h,e[16]=A):A=e[16];let R;e[17]!==a||e[18]!==u.scope||e[19]!==m?(R=(u.scope||Ua(a))&&s.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:Ua(a)?m("settings.agents.sidebar.badge.system"):u.scope}),e[17]=a,e[18]=u.scope,e[19]=m,e[20]=R):R=e[20];let P;e[21]!==x||e[22]!==A||e[23]!==R?(P=s.jsxs("div",{className:"flex items-center gap-1.5",children:[x,A,R]}),e[21]=x,e[22]=A,e[23]=R,e[24]=P):P=e[24];let D;e[25]!==a.description?(D=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[25]=a.description,e[26]=D):D=e[26];let F;e[27]!==r||e[28]!==P||e[29]!==D?(F=s.jsxs("button",{onClick:r,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-ring",tabIndex:0,children:[P,D]}),e[27]=r,e[28]=P,e[29]=D,e[30]=F):F=e[30];let O;e[31]!==f?(O=q=>{q&&k(!1),f(q)},e[31]=f,e[32]=O):O=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(Nn,{asChild:!0,children:s.jsx(G,{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:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=C):C=e[33];let M;e[34]!==S?(M=s.jsx(kn,{align:"end",className:"w-fit min-w-20",children:S(an)}),e[34]=S,e[35]=M):M=e[35];let U;e[36]!==g||e[37]!==O||e[38]!==M?(U=s.jsxs(Sn,{open:g,onOpenChange:O,children:[C,M]}),e[36]=g,e[37]=O,e[38]=M,e[39]=U):U=e[39];let L;e[40]!==F||e[41]!==U?(L=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[F,U]}),e[40]=F,e[41]=U,e[42]=L):L=e[42];let W;e[43]!==L||e[44]!==T?(W=s.jsx(ga,{render:T,children:L}),e[43]=L,e[44]=T,e[45]=W):W=e[45];let X;e[46]!==S?(X=s.jsx(ma,{className:"w-fit min-w-20",children:S(pa)}),e[46]=S,e[47]=X):X=e[47];let J;return e[48]!==b||e[49]!==W||e[50]!==X?(J=s.jsxs(ha,{open:b,onOpenChange:k,children:[W,X]}),e[48]=b,e[49]=W,e[50]=X,e[51]=J):J=e[51],J},ts=t=>{const e=tt.c(22),{children:a,className:n,outerClassName:r,title:i,titleLeading:l,titleAccessory:d,description:c,headerEnd:h,showSaveStatus:g,onBlurCapture:f}=t,m=g===void 0?!1:g,u=i!=null||c!=null||h!=null||m,v=typeof i=="string"||typeof i=="number",w=l!=null||d!=null;let b;e[0]!==r?(b=Pe("h-full overlay-scrollbar-wrapper--stable-gutter",r),e[0]=r,e[1]=b):b=e[1];let k;e[2]!==n?(k=Pe("mx-auto max-w-[840px] space-y-0 px-6 py-6 @3xl:px-12 @3xl:py-8","[&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",n),e[2]=n,e[3]=k):k=e[3];let p;e[4]!==c||e[5]!==u||e[6]!==w||e[7]!==h||e[8]!==v||e[9]!==m||e[10]!==i||e[11]!==d||e[12]!==l?(p=u&&s.jsxs("div",{className:"mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[s.jsxs("div",{className:"min-w-0 flex-1 basis-64 space-y-1",children:[i!=null?v?w?s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[l,s.jsx("h1",{"data-settings-page-heading":!0,tabIndex:-1,className:Pe(Xr,"min-w-0 truncate"),children:i}),s.jsx("span",{className:"shrink-0",children:d})]}):s.jsx("h1",{"data-settings-page-heading":!0,tabIndex:-1,className:Xr,children:i}):i:null,c!=null?typeof c=="string"||typeof c=="number"?s.jsx("p",{className:Vi,children:c}):c:null]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-3",children:[h,m&&s.jsx(Pp,{})]})]}),e[4]=c,e[5]=u,e[6]=w,e[7]=h,e[8]=v,e[9]=m,e[10]=i,e[11]=d,e[12]=l,e[13]=p):p=e[13];let S;e[14]!==a||e[15]!==f||e[16]!==k||e[17]!==p?(S=s.jsxs("div",{className:k,onBlurCapture:f,children:[p,a]}),e[14]=a,e[15]=f,e[16]=k,e[17]=p,e[18]=S):S=e[18];let N;return e[19]!==b||e[20]!==S?(N=s.jsx(Ns,{outerClassName:b,className:"w-full @container",children:S}),e[19]=b,e[20]=S,e[21]=N):N=e[21],N},Ip=500,Pp=()=>{const t=tt.c(13),{t:e}=Qe(),a=o.useSyncExternalStore(Yu,el,el),[n,r]=o.useState(!1);let i,l;if(t[0]!==a?(i=()=>{if(a!=="saving"){r(!1);return}const g=setTimeout(()=>r(!0),Ip);return()=>clearTimeout(g)},l=[a],t[0]=a,t[1]=i,t[2]=l):(i=t[1],l=t[2]),o.useEffect(i,l),a==="error"){let g;t[3]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(_,{name:"error-warning",className:"size-3.5"}),t[3]=g):g=t[3];let f;t[4]!==e?(f=e("settings.common.status.saveFailed"),t[4]=e,t[5]=f):f=t[5];let m;return t[6]!==f?(m=s.jsxs("div",{"aria-live":"assertive",className:"flex shrink-0 items-center gap-1.5 typography-meta text-[var(--status-error)]",children:[g,s.jsx("span",{children:f})]}),t[6]=f,t[7]=m):m=t[7],m}if(a!=="saving"||!n)return null;let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}),t[8]=d):d=t[8];let c;t[9]!==e?(c=e("settings.common.actions.saving"),t[9]=e,t[10]=c):c=t[10];let h;return t[11]!==c?(h=s.jsxs("div",{"aria-live":"polite",className:"flex shrink-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[d,s.jsx("span",{children:c})]}),t[11]=c,t[12]=h):h=t[12],h},Os={ok:!0,changed:!1},Tn={ok:!0,changed:!0},ms=t=>({ok:!1,reason:t}),Ap=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,Ya=t=>{const{t:e}=Qe(),[a,n]=o.useState(0),r=o.useRef(t);r.current=t;const i=o.useRef(e);i.current=e;const l=o.useRef(!1),d=o.useRef(!1),c=o.useRef(!1),h=o.useCallback(()=>{n(m=>m+1)},[]),g=o.useCallback(m=>{Ap(m.target)&&h()},[h]),f=o.useCallback(async()=>{l.current=!0;try{for(;;){d.current=!1;let m;try{m=await r.current()}catch(u){m={ok:!1,reason:u instanceof Error?u.message:String(u)}}if(!c.current)return;if(!d.current){m.ok||$.error(i.current("settings.common.status.saveFailedReason",{reason:m.reason}));return}}}finally{l.current=!1}},[]);return o.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]),o.useEffect(()=>{if(a!==0){if(l.current){d.current=!0;return}f()}},[a,f]),{requestSave:h,onBlurCapture:g}},Tp=["allow","ask","deny"],Ep=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],Dp=["openchamber","openchamber_web","openchamber_memory","openchamber_notify"],Mp=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),Zc=t=>Mp.has(t),Rp=[{action:"*",resource:"*",effect:"allow"},{action:"external_directory",resource:"*",effect:"ask"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],bl=()=>({global:null,keys:{},source:[]}),ta=t=>({global:t.global,source:t.source,keys:Object.fromEntries(Object.entries(t.keys).map(([e,a])=>[e,{effect:a.effect,patterns:a.patterns.map(n=>({...n}))}]))}),Fp=t=>{const e={global:null,keys:{},source:t.map(a=>({...a}))};for(const a of t){if(Zc(a.action))continue;if(a.action==="*"){a.resource==="*"&&(e.global=a.effect);continue}const n=e.keys[a.action]??{effect:null,patterns:[]};if(a.resource==="*")n.effect=a.effect;else{const r=n.patterns.findIndex(i=>i.pattern===a.resource);r>=0?n.patterns[r]={pattern:a.resource,effect:a.effect}:n.patterns.push({pattern:a.resource,effect:a.effect})}e.keys[a.action]=n}return e},Op=t=>t.action!=="*"||t.resource==="*",la=(t,e)=>`${t}\0${e}`,Lp=t=>{const e=new Map;t.global!==null&&e.set(la("*","*"),t.global);for(const[a,n]of Object.entries(t.keys)){n.effect!==null&&e.set(la(a,"*"),n.effect);for(const r of n.patterns){const i=r.pattern.trim();i.length!==0&&e.set(la(a,i),r.effect)}}return e},ro=t=>{const e=Lp(t),a=new Set,n=[];for(const i of t.source){if(Zc(i.action))continue;if(!Op(i)){n.push({...i});continue}const l=la(i.action,i.resource),d=e.get(l);d!==void 0&&(n.push({action:i.action,resource:i.resource,effect:d}),a.add(l))}const r=la("*","*");t.global!==null&&!a.has(r)&&n.unshift({action:"*",resource:"*",effect:t.global});for(const[i,l]of Object.entries(t.keys)){const d=la(i,"*");if(l.effect!==null&&!a.has(d)){const c=n.findIndex(g=>g.action===i),h={action:i,resource:"*",effect:l.effect};c>=0?n.splice(c,0,h):n.push(h)}for(const c of l.patterns){const h=c.pattern.trim();if(h.length===0)continue;const g=la(i,h),f=e.get(g);f===void 0||a.has(g)||(a.add(g),n.push({action:i,resource:h,effect:f}))}}return n},Kp=(t,e)=>JSON.stringify(ro(t))===JSON.stringify(ro(e)),zp=(t,e)=>{const a=[...Rp,...e.global,...e.agentGlobal?[{action:"*",resource:"*",effect:e.agentGlobal}]:[]];let n="ask";for(const r of a)r.resource==="*"&&(r.action==="*"||r.action===t)&&(n=r.effect);return n},Up=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),_p=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),$p={effect:null,patterns:[]},Bp=t=>{const e=tt.c(163),{agent:a,registerSave:n,requestSave:r}=t,{t:i}=Qe(),l=Qn(Vp),d=Qn(Hp);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[h,g]=o.useState(c),[f,m]=o.useState(bl),[u,v]=o.useState(bl),[w,b]=o.useState(!0),[k,p]=o.useState(!1);let S;e[1]===Symbol.for("react.memo_cache_sentinel")?(S={},e[1]=S):S=e[1];const[N,I]=o.useState(S),[y,T]=o.useState(""),[x,A]=o.useState(0),R=a.name,P=rn(),D=Yn(qp);let F;e[2]!==P?(F=ze=>fo(ze,P),e[2]=P,e[3]=F):F=e[3];const O=Yn(F);let C;e[4]!==P?(C=ze=>ze.getStatusForDirectory(P),e[4]=P,e[5]=C):C=e[5];const M=un(C);let U,L;e[6]!==D||e[7]!==P?(U=()=>{D({directory:P})},L=[D,P],e[6]=D,e[7]=P,e[8]=U,e[9]=L):(U=e[8],L=e[9]),o.useEffect(U,L);let W;e[10]!==R||e[11]!==d||e[12]!==P?(W=()=>{let ze=!1;return b(!0),p(!1),(async()=>{const Ge=await d(R,P);if(ze)return;if(!Ge){p(!0),b(!1);return}const Q=Fp(Ge.agent);g(Ge.global),m(ta(Q)),v(Q),I({}),b(!1)})(),()=>{ze=!0}},e[10]=R,e[11]=d,e[12]=P,e[13]=W):W=e[13];let X;e[14]!==R||e[15]!==d||e[16]!==x||e[17]!==P?(X=[R,d,x,P],e[14]=R,e[15]=d,e[16]=x,e[17]=P,e[18]=X):X=e[18],o.useEffect(W,X);let J;e[19]!==R||e[20]!==f||e[21]!==u||e[22]!==P||e[23]!==i||e[24]!==l?(J=async()=>Kp(u,f)?Os:(await l(R,{permissions:ro(u)},P)).ok?(m(ta(u)),Tn):ms(i("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=R,e[20]=f,e[21]=u,e[22]=P,e[23]=i,e[24]=l,e[25]=J):J=e[25];const q=J;let z,H;e[26]!==n||e[27]!==q?(z=()=>(n(q),()=>n(null)),H=[n,q],e[26]=n,e[27]=q,e[28]=z,e[29]=H):(z=e[28],H=e[29]),o.useEffect(z,H);let se;e[30]!==O?(se=O.map(Gp),e[30]=O,e[31]=se):se=e[31];const B=se;let ne;if(e[32]!==B||e[33]!==u.keys){ne=[...Ep,...Dp];const ze=new Set(B.map(Wp));let Ge;e[35]!==u.keys?(Ge=Object.keys(u.keys),e[35]=u.keys,e[36]=Ge):Ge=e[36];for(const Q of Ge)!ne.includes(Q)&&!ze.has(Q)&&ne.push(Q);e[32]=B,e[33]=u.keys,e[34]=ne}else ne=e[34];const K=ne;let Z;e[37]!==M||e[38]!==i?(Z=ze=>{switch(M?.[ze]?.status.status){case"connected":return i("settings.mcp.page.status.label.connected");case"failed":return i("settings.mcp.page.status.label.failed");case"needs_auth":return i("settings.mcp.page.status.label.needsAuth");case"disabled":return i("settings.agents.page.permissionsEditor.mcpStatus.disabled");case"pending":return i("settings.agents.page.permissionsEditor.mcpStatus.pending");default:return null}},e[37]=M,e[38]=i,e[39]=Z):Z=e[39];const oe=Z;let ue;e[40]!==h||e[41]!==u.global?(ue=ze=>zp(ze,{global:h,agentGlobal:u.global}),e[40]=h,e[41]=u.global,e[42]=ue):ue=e[42];const de=ue;let ce;e[43]!==r?(ce=ze=>{v(Ge=>({...Ge,global:ze})),r()},e[43]=r,e[44]=ce):ce=e[44];const Se=ce;let re;e[45]!==r?(re=(ze,Ge)=>{v(Q=>{const Ue=ta(Q),st=Ue.keys[ze]??{effect:null,patterns:[]};return st.effect=Ge,st.effect===null&&st.patterns.length===0?delete Ue.keys[ze]:Ue.keys[ze]=st,Ue}),r()},e[45]=r,e[46]=re):re=e[46];const ve=re;let ie;e[47]!==r?(ie=(ze,Ge,Q,Ue,st)=>{v(dt=>{const ct=ta(dt),ft=ct.keys[ze]??{effect:null,patterns:[]};return ft.patterns[Ge]={pattern:Q,effect:Ue},ct.keys[ze]=ft,ct}),st&&r()},e[47]=r,e[48]=ie):ie=e[48];const me=ie;let ke;e[49]===Symbol.for("react.memo_cache_sentinel")?(ke=ze=>{v(Ge=>{const Q=ta(Ge),Ue=Q.keys[ze]??{effect:null,patterns:[]};return Ue.patterns.push({pattern:"",effect:"allow"}),Q.keys[ze]=Ue,Q}),I(Ge=>({...Ge,[ze]:!0}))},e[49]=ke):ke=e[49];const Ae=ke;let pe;e[50]!==r?(pe=(ze,Ge)=>{v(Q=>{const Ue=ta(Q),st=Ue.keys[ze];return st?(st.patterns.splice(Ge,1),st.effect===null&&st.patterns.length===0&&delete Ue.keys[ze],Ue):Q}),r()},e[50]=r,e[51]=pe):pe=e[51];const Le=pe;let Ve;e[52]!==y||e[53]!==r?(Ve=()=>{const ze=y.trim();!ze||ze==="*"||(v(Ge=>{if(Ge.keys[ze])return Ge;const Q=ta(Ge);return Q.keys[ze]={effect:"ask",patterns:[]},Q}),T(""),r())},e[52]=y,e[53]=r,e[54]=Ve):Ve=e[54];const ye=Ve;let Te;e[55]!==i?(Te=ze=>i(ze==="allow"?"settings.agents.page.permissionsEditor.action.allow":ze==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=i,e[56]=Te):Te=e[56];const ee=Te;let ae,fe,je,Re,Ce,_e,Ke,Fe,Me;if(e[57]!==ee||e[58]!==de||e[59]!==N||e[60]!==w||e[61]!==k||e[62]!==B||e[63]!==oe||e[64]!==u.global||e[65]!==u.keys||e[66]!==Le||e[67]!==Se||e[68]!==ve||e[69]!==me||e[70]!==i||e[71]!==K){Me=Symbol.for("react.early_return_sentinel");e:{const ze=i("settings.agents.page.permissionsEditor.action.inherit"),Ge=i("settings.agents.page.permissionsEditor.action.default");let Q;e[81]!==ee?(Q=$e=>[...$e?[{value:"inherit",label:$e}]:[],...Tp.map(Y=>({value:Y,label:ee(Y)}))],e[81]=ee,e[82]=Q):Q=e[82];const Ue=Q,st=($e,Y,V,be)=>{const ge=be===void 0?ze:be;return s.jsx(mn,{value:$e??"inherit",options:Ue(ge),onChange:Ee=>Y(Ee==="inherit"?null:Ee),"aria-label":V})};if(w){let $e;e[83]!==i?($e=i("settings.agents.page.section.toolPermissions"),e[83]=i,e[84]=$e):$e=e[84];let Y;e[85]!==i?(Y=i("common.loading"),e[85]=i,e[86]=Y):Y=e[86];let V;e[87]!==Y?(V=s.jsx("p",{className:vs,children:Y}),e[87]=Y,e[88]=V):V=e[88];let be;e[89]!==$e||e[90]!==V?(be=s.jsx(qe,{title:$e,children:V}),e[89]=$e,e[90]=V,e[91]=be):be=e[91],Me=be;break e}if(k){let $e;e[92]!==i?($e=i("settings.agents.page.section.toolPermissions"),e[92]=i,e[93]=$e):$e=e[93];let Y;e[94]!==i?(Y=i("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=i,e[95]=Y):Y=e[95];let V;e[96]!==Y?(V=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Y}),e[96]=Y,e[97]=V):V=e[97];let be;e[98]===Symbol.for("react.memo_cache_sentinel")?(be=()=>A(Jp),e[98]=be):be=e[98];let ge;e[99]!==i?(ge=i("settings.agents.page.permissionsEditor.actions.retry"),e[99]=i,e[100]=ge):ge=e[100];let Ee;e[101]!==ge?(Ee=s.jsx(G,{variant:"outline",size:"xs",onClick:be,children:ge}),e[101]=ge,e[102]=Ee):Ee=e[102];let te;e[103]!==V||e[104]!==Ee?(te=s.jsxs("div",{className:"flex items-center gap-3",children:[V,Ee]}),e[103]=V,e[104]=Ee,e[105]=te):te=e[105];let xe;e[106]!==$e||e[107]!==te?(xe=s.jsx(qe,{title:$e,children:te}),e[106]=$e,e[107]=te,e[108]=xe):xe=e[108],Me=xe;break e}const dt=($e,Y,V)=>{const be=u.keys[$e]??$p,ge=_p.has($e)||be.patterns.length>0,Ee=N[$e]===!0;return s.jsxs("div",{className:"border-t border-border/40 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("button",{type:"button",onClick:ge?()=>I(te=>({...te,[$e]:!Ee})):void 0,className:Pe("flex min-w-0 items-center gap-1.5 text-left",!ge&&"cursor-default"),"aria-expanded":ge?Ee:void 0,children:[s.jsx(_,{name:Ee&&ge?"arrow-down-s":"arrow-right-s",className:Pe("h-3.5 w-3.5 shrink-0 text-muted-foreground",!ge&&"opacity-0")}),s.jsx("span",{className:Ct,children:Y}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground/70",children:$e}),V&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:V}),be.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:i("settings.agents.page.permissionsEditor.effectiveHint",{action:ee(de($e))})}),be.patterns.length>0&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:i("settings.agents.page.permissionsEditor.ruleCount",{count:String(be.patterns.length)})})]}),st(be.effect,te=>ve($e,te),i("settings.agents.page.permissionsEditor.keyAria",{key:$e}))]}),Ee&&ge&&s.jsxs("div",{className:"mt-2 space-y-2 pl-5",children:[be.patterns.map((te,xe)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(He,{value:te.pattern,onChange:Ze=>me($e,xe,Ze.target.value,te.effect,!1),placeholder:i("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":i("settings.agents.page.permissionsEditor.patternActionAria",{key:$e}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(mn,{value:te.effect,options:Ue(),onChange:Ze=>me($e,xe,te.pattern,Ze,!0),"aria-label":i("settings.agents.page.permissionsEditor.patternActionAria",{key:$e})}),s.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>Le($e,xe),"aria-label":i("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]},xe)),s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ae($e),children:[s.jsx(_,{name:"add",className:"mr-1 h-3.5 w-3.5"}),i("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},$e)};ae=qe,e[109]!==i?(fe=i("settings.agents.page.section.toolPermissions"),e[109]=i,e[110]=fe):fe=e[110],je="agents.permissions",e[111]!==i?(Re=i("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=i,e[112]=Re):Re=e[112],Ce="space-y-4";let ct;e[113]!==i?(ct=i("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=i,e[114]=ct):ct=e[114];let ft;e[115]!==ct?(ft=s.jsx("span",{className:Ct,children:ct}),e[115]=ct,e[116]=ft):ft=e[116];let kt;e[117]!==i?(kt=i("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=i,e[118]=kt):kt=e[118];let bt;e[119]!==kt?(bt=s.jsx(Gt,{children:kt}),e[119]=kt,e[120]=bt):bt=e[120];let vt;e[121]!==ee||e[122]!==de||e[123]!==u.global||e[124]!==i?(vt=u.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:i("settings.agents.page.permissionsEditor.effectiveHint",{action:ee(de("*"))})}),e[121]=ee,e[122]=de,e[123]=u.global,e[124]=i,e[125]=vt):vt=e[125];let Xe;e[126]!==ft||e[127]!==bt||e[128]!==vt?(Xe=s.jsxs("div",{className:"flex items-center gap-1.5",children:[ft,bt,vt]}),e[126]=ft,e[127]=bt,e[128]=vt,e[129]=Xe):Xe=e[129];const jt=u.global;let De;e[130]!==i?(De=i("settings.agents.page.permissionsEditor.defaultAria"),e[130]=i,e[131]=De):De=e[131],_e=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[Xe,st(jt,Se,De,Ge)]}),Ke=s.jsx("div",{children:K.map($e=>dt($e,Up($e),null))}),Fe=B.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/40 pt-3 pb-1",children:[s.jsx("span",{className:Ct,children:i("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(Gt,{children:i("settings.agents.page.permissionsEditor.mcpInfo")})]}),B.map($e=>dt($e.key,$e.server,oe($e.server)))]})}e[57]=ee,e[58]=de,e[59]=N,e[60]=w,e[61]=k,e[62]=B,e[63]=oe,e[64]=u.global,e[65]=u.keys,e[66]=Le,e[67]=Se,e[68]=ve,e[69]=me,e[70]=i,e[71]=K,e[72]=ae,e[73]=fe,e[74]=je,e[75]=Re,e[76]=Ce,e[77]=_e,e[78]=Ke,e[79]=Fe,e[80]=Me}else ae=e[72],fe=e[73],je=e[74],Re=e[75],Ce=e[76],_e=e[77],Ke=e[78],Fe=e[79],Me=e[80];if(Me!==Symbol.for("react.early_return_sentinel"))return Me;let at;e[132]===Symbol.for("react.memo_cache_sentinel")?(at=ze=>T(ze.target.value),e[132]=at):at=e[132];let pt;e[133]!==ye?(pt=ze=>{ze.key==="Enter"&&(ze.preventDefault(),ye())},e[133]=ye,e[134]=pt):pt=e[134];let ot;e[135]!==i?(ot=i("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=i,e[136]=ot):ot=e[136];let mt;e[137]!==y||e[138]!==pt||e[139]!==ot?(mt=s.jsx(He,{value:y,onChange:at,onKeyDown:pt,placeholder:ot,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=y,e[138]=pt,e[139]=ot,e[140]=mt):mt=e[140];let ht;e[141]!==y?(ht=y.trim(),e[141]=y,e[142]=ht):ht=e[142];const Oe=!ht;let nt;e[143]===Symbol.for("react.memo_cache_sentinel")?(nt=s.jsx(_,{name:"add",className:"mr-1 h-3.5 w-3.5"}),e[143]=nt):nt=e[143];let lt;e[144]!==i?(lt=i("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=i,e[145]=lt):lt=e[145];let we;e[146]!==ye||e[147]!==Oe||e[148]!==lt?(we=s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:ye,disabled:Oe,children:[nt,lt]}),e[146]=ye,e[147]=Oe,e[148]=lt,e[149]=we):we=e[149];let Je;e[150]!==mt||e[151]!==we?(Je=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/40 pt-3",children:[mt,we]}),e[150]=mt,e[151]=we,e[152]=Je):Je=e[152];let Ye;return e[153]!==ae||e[154]!==fe||e[155]!==je||e[156]!==Re||e[157]!==Ce||e[158]!==_e||e[159]!==Ke||e[160]!==Fe||e[161]!==Je?(Ye=s.jsxs(ae,{title:fe,settingsItem:je,info:Re,contentClassName:Ce,children:[_e,Ke,Fe,Je]}),e[153]=ae,e[154]=fe,e[155]=je,e[156]=Re,e[157]=Ce,e[158]=_e,e[159]=Ke,e[160]=Fe,e[161]=Je,e[162]=Ye):Ye=e[162],Ye};function Vp(t){return t.updateAgent}function Hp(t){return t.fetchAgentPermissions}function qp(t){return t.loadMcpConfigs}function Gp(t){return{key:`${t.name}_*`,server:t.name}}function Wp(t){return t.key}function Jp(t){return t+1}const To=t=>{const e=tt.c(11),{legacy:a,path:n,className:r}=t,{t:i}=Qe();if(!a)return null;let l;e[0]!==r?(l=Pe("mb-4 flex items-start gap-1.5",vs,r),e[0]=r,e[1]=l):l=e[1];const d=n??void 0;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(_,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),e[2]=c):c=e[2];let h;e[3]!==i?(h=i("settings.common.legacyFormat.note"),e[3]=i,e[4]=h):h=e[4];let g;e[5]!==h?(g=s.jsx("span",{children:h}),e[5]=h,e[6]=g):g=e[6];let f;return e[7]!==l||e[8]!==d||e[9]!==g?(f=s.jsxs("p",{className:l,title:d,children:[c,g]}),e[7]=l,e[8]=d,e[9]=g,e[10]=f):f=e[10],f},Qp=(t,e)=>{const a=zn(e);return a?t.find(i=>i.id===a.providerId)?.models.find(i=>i.modelID===a.modelId)?.variants.map(i=>i.id)??[]:[]},Yp=()=>{const{t}=Qe(),e=rt(ye=>ye.providers),{selectedAgentName:a,getAgentByName:n,createAgent:r,updateAgent:i,fetchAgentEntity:l,agentDraft:d,setAgentDraft:c,setSelectedAgent:h}=Qn(Bs(ye=>({selectedAgentName:ye.selectedAgentName,getAgentByName:ye.getAgentByName,createAgent:ye.createAgent,updateAgent:ye.updateAgent,fetchAgentEntity:ye.fetchAgentEntity,agentDraft:ye.agentDraft,setAgentDraft:ye.setAgentDraft,setSelectedAgent:ye.setSelectedAgent}))),g=rn(),f=Qn(ye=>Ic(ye,g)),m=a?n(a,g):null,u=!!(d&&d.name===a&&!m),v=u?"":m?.description?.trim()??"",w=u?"":m?.system?.trim()??"",[b,k]=o.useState(""),[p,S]=o.useState("user"),[N,I]=o.useState(""),[y,T]=o.useState("subagent"),[x,A]=o.useState(""),[R,P]=o.useState(""),[D,F]=o.useState(void 0),[O,C]=o.useState(void 0),[M,U]=o.useState(void 0),[L,W]=o.useState(""),[X,J]=o.useState(!1),[q,z]=o.useState(null),H=o.useRef({}),se=o.useRef(null),B=o.useCallback(ye=>{se.current=ye},[]),ne=o.useRef(null),K=JSON.stringify([a,g,u]),Z=o.useRef(K);Z.current=K;const oe=o.useRef(null),ue={description:N,mode:y,model:x,variant:R,steps:D,temperature:O,topP:M,system:L},de=o.useRef(ue);de.current=ue;const ce=o.useMemo(()=>Qp(e,x),[x,e]),Se=ce.length>0,re=R||"__default",ve=Se,ie=o.useMemo(()=>R&&!ce.includes(R)?[R,...ce]:ce,[R,ce]);o.useEffect(()=>{if(!u||!d)return;oe.current=null;const ye=di(d.model),Te=d.name||"",ee=d.scope||"user",ae=d.description||"",fe=d.mode||"subagent",je=ye?`${ye.providerID}/${ye.modelID}`:"",Re=ye?.variant||"",Ce=d.steps??void 0,_e=d.temperature??void 0,Ke=d.top_p??void 0,Fe=d.system||"";H.current={},z(null),k(Te),S(ee),I(ae),T(fe),A(je),P(Re),F(Ce),C(_e),U(Ke),W(Fe),ne.current={draftName:Te,draftScope:ee,description:ae,mode:fe,model:je,variant:Re,steps:Ce,temperature:_e,topP:Ke,system:Fe}},[d,u]),o.useEffect(()=>{if(u||!a)return;let ye=!1;return(async()=>{const Te=await l(a,g);if(ye||Z.current!==K||!Te)return;const ee=Te.config;H.current=ee;const ae=di(ee.model),fe=ee.request?.body,je={draftName:"",draftScope:"user",description:ee.description||"",mode:ee.mode||m?.mode||"subagent",model:ae?`${ae.providerID}/${ae.modelID}`:"",variant:ae?.variant||"",steps:ee.steps??void 0,temperature:fe?.temperature,topP:fe?.top_p,system:ee.system||""},Re=ne.current,Ce=de.current,_e=Re!==null&&(Ce.description!==Re.description||Ce.mode!==Re.mode||Ce.model!==Re.model||Ce.variant!==Re.variant||Ce.steps!==Re.steps||Ce.temperature!==Re.temperature||Ce.topP!==Re.topP||Ce.system!==Re.system);z({legacy:Te.legacy===!0,path:Te.path,source:Te.source}),!(oe.current===K&&_e)&&(oe.current=K,I(je.description),T(je.mode),A(je.model),P(je.variant),F(je.steps),C(je.temperature),U(je.topP),W(je.system),ne.current=je)})(),()=>{ye=!0}},[l,u,m,a,g,K]);const me=o.useCallback(ye=>{const Te=zn(x.trim()),ee=Te?Pc({providerID:Te.providerId,modelID:Te.modelId,variant:R.trim()||void 0}):null,ae=H.current.request,fe={...ae?.body};O===void 0?delete fe.temperature:fe.temperature=O,M===void 0?delete fe.top_p:fe.top_p=M;const je=ae?.headers,Re={};je&&Object.keys(je).length>0&&(Re.headers=je),Object.keys(fe).length>0&&(Re.body=fe);const Ce=N.trim(),_e=L.trim(),Ke={name:ye,mode:y,model:ee,steps:D??null,system:_e||(u?void 0:null),request:Object.keys(Re).length>0?Re:null};return Ce&&(Ke.description=Ce),u&&p&&(Ke.scope=p),u&&d?.permissions?.length&&(Ke.permissions=d.permissions),Ke},[d,N,p,u,y,x,D,L,O,M,R]),ke=o.useCallback(async()=>{const ye=ne.current,Te=a?.trim();if(u||!ye||!Te)return Os;const ee=se.current?await se.current():Os;if(N===ye.description&&y===ye.mode&&x===ye.model&&R===ye.variant&&D===ye.steps&&O===ye.temperature&&M===ye.topP&&L===ye.system||!ee.ok)return ee;const fe=me(Te);return(await i(Te,fe,g)).ok?(Z.current!==K||(H.current={...H.current,model:fe.model,system:fe.system??void 0,steps:fe.steps,request:fe.request??void 0},ne.current={...ye,description:N,mode:y,model:x,variant:R,steps:D,temperature:O,topP:M,system:L}),Tn):ms(t("settings.agents.page.toast.updateFailed"))},[me,N,u,y,x,a,K,g,D,L,t,O,M,i,R]),Ae=Ya(ke),{requestSave:pe}=Ae,Le=async()=>{const ye=b.trim().replace(/\s+/g,"-");if(!ye){$.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(f.some(Te=>Te.name===ye)){$.error(t("settings.agents.sidebar.toast.agentExists"));return}J(!0);try{(await r(me(ye),g)).ok?(c(null),$.success(t("settings.agents.page.toast.created"))):$.error(t("settings.agents.page.toast.createFailed"))}catch(Te){console.error("Error creating agent:",Te);const ee=Te instanceof Error&&Te.message?Te.message:t("settings.agents.page.toast.saveUnexpectedError");$.error(ee)}finally{J(!1)}},Ve=()=>{c(null),h(null)};return a?s.jsxs(ts,{title:u?t("settings.agents.page.title.new"):a,description:t(u?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:Ae.onBlurCapture,children:[!u&&q&&s.jsx(To,{legacy:q.legacy,path:q.path}),!u&&q?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${vs}`,children:[s.jsx(_,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),s.jsx("span",{children:t("settings.agents.page.runtimeProvided.note")})]}),s.jsxs(qe,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-0",children:[u&&s.jsxs(It,{settingsItem:"agents.name",label:t("settings.agents.page.field.agentName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"@"}),s.jsx(He,{value:b,onChange:ye=>k(ye.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Et,{value:p,onValueChange:ye=>S(ye),children:[s.jsx(At,{size:Bt,className:"w-fit min-w-[100px]",children:s.jsx($t,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(Tt,{align:"end",children:[s.jsx(ut,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(ut,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(Ft,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(As,{value:N,onChange:ye=>I(ye.target.value),placeholder:v||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(Ft,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(mn,{"aria-label":t("settings.agents.page.field.mode"),value:y,onChange:ye=>{T(ye),pe()},options:[{value:"primary",label:t("settings.agents.page.mode.primary")},{value:"subagent",label:t("settings.agents.page.mode.subagent")},{value:"all",label:t("settings.agents.page.mode.all")}]})})]}),s.jsxs(qe,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(It,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ca,{providerId:zn(x)?.providerId??"",modelId:zn(x)?.modelId??"",onChange:(ye,Te)=>{A(ye&&Te?`${ye}/${Te}`:""),P(""),pe()},className:Ws})}),s.jsx(It,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:ve?s.jsxs(Et,{value:re,onValueChange:ye=>{P(ye==="__default"?"":ye),pe()},children:[s.jsx(At,{size:Bt,className:nn,children:s.jsx($t,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:ye=>ye==="__default"?t("chat.modelControls.default"):ye})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:"__default",children:t("chat.modelControls.default")}),ie.map(ye=>s.jsx(ut,{value:ye,children:ye},ye))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(He,{value:R,onChange:ye=>P(ye.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!x&&!R,className:"h-8 w-40 rounded-md px-3"}),R&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{P(""),pe()},className:us,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(It,{settingsItem:"agents.temperature",label:t("settings.agents.page.field.temperature"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.temperatureTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.temperatureRange")})]}),children:[s.jsx(hs,{value:O,fallbackValue:.7,onValueChange:C,onClear:()=>{C(void 0),pe()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:bs}),O!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{C(void 0),pe()},className:us,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(It,{settingsItem:"agents.top-p",label:t("settings.agents.page.field.topP"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.topPTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.topPRange")})]}),children:[s.jsx(hs,{value:M,fallbackValue:.9,onValueChange:U,onClear:()=>{U(void 0),pe()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:bs}),M!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{U(void 0),pe()},className:us,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(It,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(hs,{value:D,fallbackValue:20,onValueChange:F,onClear:()=>{F(void 0),pe()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:bs}),D!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{F(void 0),pe()},className:us,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(qe,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(As,{value:L,onChange:ye=>W(ye.target.value),placeholder:w||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!u&&m&&s.jsx(Bp,{agent:m,registerSave:B,requestSave:pe}),u&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(G,{onClick:()=>{Le()},disabled:X||!b.trim(),size:"xs",className:"!font-normal",children:t(X?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(G,{variant:"ghost",onClick:Ve,disabled:X,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(_,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.agents.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.agents.page.empty.description")})]})})};function Zp(t,e){return t.kind==="file"?t.content:e??""}const vl=Ts({content:Mt(),exists:Po(),path:Mt().min(1).optional()}),Xp=async(t,e)=>{const a=await t.json().catch(()=>null);return typeof a?.error=="string"&&a.error.trim()?a.error:e},eg=t=>t.length>0&&!t.endsWith(`
3
+ `)?`${t}
4
+ `:t,Mi={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},tg=(t,e)=>t==="custom"?e:Vd(t),sg=t=>t==="custom"?"custom":Ac(t)?t:"concise",yl={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"},ng=()=>{const{t}=Qe(),[e,a]=o.useState(""),[n,r]=o.useState("AGENTS.md"),[i,l]=o.useState(Mi.responseStyleEnabled),[d,c]=o.useState(Mi.responseStylePreset),[h,g]=o.useState(Mi.responseStyleCustomInstructions),[f,m]=o.useState(!0),u=o.useRef(null),v=o.useRef(null);o.useEffect(()=>{const N=new AbortController;return(async()=>{try{const[y,T]=await Promise.all([En(),St("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:N.signal})]);let x=Mi,A;y&&(x={...x,responseStyleEnabled:y.responseStyleEnabled===!0,responseStylePreset:sg(y.responseStylePreset),responseStyleCustomInstructions:y.responseStyleCustomInstructions??""},y.globalBehaviorPrompt!==void 0&&(A=y.globalBehaviorPrompt));let R={kind:"missing"};if(T.ok){const P=vl.parse(await T.json());if(N.signal.aborted)return;r(P.path??"AGENTS.md"),v.current=P.exists?P.content:null,P.exists&&(R={kind:"file",content:P.content})}x={...x,prompt:Zp(R,A)},a(x.prompt),l(x.responseStyleEnabled),c(x.responseStylePreset),g(x.responseStyleCustomInstructions),u.current=x}catch(y){y.name!=="AbortError"&&console.warn("Failed to load behavior settings:",y)}finally{m(!1)}})(),()=>N.abort()},[]);const w=o.useRef(e);w.current=e,o.useEffect(()=>{let N=null;const I=async()=>{if(document.visibilityState!=="visible"||!u.current)return;N?.abort();const T=new AbortController;N=T;try{const x=await St("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:T.signal});if(!x.ok)return;const A=vl.parse(await x.json()),R=u.current;if(T.signal.aborted||!R||!A.exists||A.content===v.current||w.current!==R.prompt)return;v.current=A.content,u.current={...R,prompt:A.content},a(A.content)}catch(x){x instanceof DOMException&&x.name==="AbortError"||console.warn("Failed to refresh AGENTS.md:",x)}},y=()=>{I()};return window.addEventListener("focus",y),document.addEventListener("visibilitychange",y),()=>{N?.abort(),window.removeEventListener("focus",y),document.removeEventListener("visibilitychange",y)}},[]);const b=o.useCallback(async()=>{const N=u.current;if(!N||f)return Os;const I=e!==N.prompt,y=i!==N.responseStyleEnabled||d!==N.responseStylePreset||h!==N.responseStyleCustomInstructions;if(!I&&!y)return Os;const T=I?eg(e):N.prompt;if(I){const A=await St("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:T,expectedContent:v.current})});if(A.status===409)return ms(t("settings.behavior.page.toast.agentsMdChangedOnDisk"));if(!A.ok)return ms(await Xp(A,t("settings.behavior.page.toast.saveFailed")));v.current=T,a(R=>R===e?T:R)}return(await xt({...I?{globalBehaviorPrompt:T}:{},responseStyleEnabled:i,responseStylePreset:d,responseStyleCustomInstructions:h})).ok?(u.current={prompt:T,responseStyleEnabled:i,responseStylePreset:d,responseStyleCustomInstructions:h},Tn):ms(t("settings.behavior.page.toast.saveFailed"))},[f,e,h,i,d,t]),k=Ya(b),{requestSave:p}=k,S=tg(d,h);return s.jsxs(ts,{title:t("settings.behavior.page.title"),description:t("settings.page.behavior.description"),onBlurCapture:k.onBlurCapture,children:[s.jsx(qe,{title:t("settings.behavior.page.section.systemPrompt"),divider:!1,info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"font-medium text-foreground",children:t("settings.behavior.page.warning.title")}),s.jsx("p",{children:t("settings.behavior.page.warning.description",{path:n})})]}),settingsItem:"behavior.system-prompt",contentClassName:"space-y-3",children:s.jsx(As,{value:e,onChange:N=>a(N.target.value),placeholder:t("settings.behavior.page.field.systemPromptPlaceholder"),rows:12,disabled:f,outerClassName:"min-h-[160px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"})}),s.jsxs(qe,{title:t("settings.behavior.page.section.responseStyle"),info:t("settings.behavior.page.responseStyle.tooltip"),settingsItem:"behavior.response-style",contentClassName:"space-y-3",children:[s.jsx(gt,{checked:i,onChange:N=>{l(N),p()},disabled:f,label:t("settings.behavior.page.responseStyle.enable"),ariaLabel:t("settings.behavior.page.responseStyle.enableAria")}),s.jsx(It,{label:t("settings.behavior.page.responseStyle.preset"),alignEnd:!1,children:s.jsxs(Et,{value:d,onValueChange:N=>{c(N),p()},disabled:f||!i,children:[s.jsx(At,{size:Bt,className:nn,children:s.jsx($t,{children:N=>N==="custom"?t("settings.behavior.page.responseStyle.option.custom"):Ac(N)?t(yl[N]):null})}),s.jsxs(Tt,{children:[Bd.map(N=>s.jsx(ut,{value:N,children:t(yl[N])},N)),s.jsx(ut,{value:"custom",children:t("settings.behavior.page.responseStyle.option.custom")})]})]})}),s.jsx(As,{value:S,onChange:N=>g(N.target.value),placeholder:t("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:f||!i||d!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})},ag=(t,e)=>t.kind===e.kind&&(t.kind!=="provider"||e.kind==="provider"&&t.id===e.id),ig=t=>{const e=tt.c(73),{snapshot:a}=t,{t:n}=Qe(),r=gi(cg),i=a.selection,l=a.projectOverride!==null;let d;e[0]!==l||e[1]!==i||e[2]!==r||e[3]!==n?(d=O=>{l||ag(O,i)||r(O).then(C=>{C||$.error(n("settings.webSearch.toast.saveFailed"))})},e[0]=l,e[1]=i,e[2]=r,e[3]=n,e[4]=d):d=e[4];const c=d,h=i.kind==="provider"&&!a.providers.some(O=>O.id===i.id)?i.id:null;let g;e[5]!==n?(g=n("settings.webSearch.section.provider"),e[5]=n,e[6]=g):g=e[6];let f;e[7]!==n?(f=n("settings.webSearch.section.providerInfo"),e[7]=n,e[8]=f):f=e[8];let m;e[9]!==n?(m=n("settings.webSearch.section.provider"),e[9]=n,e[10]=m):m=e[10];const u=i.kind==="default";let v;e[11]!==c?(v=()=>c({kind:"default"}),e[11]=c,e[12]=v):v=e[12];let w;e[13]!==n?(w=n("settings.webSearch.option.default"),e[13]=n,e[14]=w):w=e[14];let b;e[15]!==n?(b=n("settings.webSearch.option.defaultDescription"),e[15]=n,e[16]=b):b=e[16];let k;e[17]!==l||e[18]!==u||e[19]!==v||e[20]!==w||e[21]!==b?(k=s.jsx(ws,{selected:u,onSelect:v,disabled:l,label:w,description:b}),e[17]=l,e[18]=u,e[19]=v,e[20]=w,e[21]=b,e[22]=k):k=e[22];let p;e[23]!==c||e[24]!==l||e[25]!==i.kind||e[26]!==a.providers.length||e[27]!==n?(p=a.providers.length>0?s.jsx(ws,{selected:i.kind==="random",onSelect:()=>c({kind:"random"}),disabled:l,label:n("settings.webSearch.option.random"),description:n("settings.webSearch.option.randomDescription")}):null,e[23]=c,e[24]=l,e[25]=i.kind,e[26]=a.providers.length,e[27]=n,e[28]=p):p=e[28];let S;if(e[29]!==c||e[30]!==l||e[31]!==i.id||e[32]!==i.kind||e[33]!==a.providers){let O;e[35]!==c||e[36]!==l||e[37]!==i.id||e[38]!==i.kind?(O=C=>s.jsx(ws,{selected:i.kind==="provider"&&i.id===C.id,onSelect:()=>c({kind:"provider",id:C.id}),disabled:l,label:C.name},C.id),e[35]=c,e[36]=l,e[37]=i.id,e[38]=i.kind,e[39]=O):O=e[39],S=a.providers.map(O),e[29]=c,e[30]=l,e[31]=i.id,e[32]=i.kind,e[33]=a.providers,e[34]=S}else S=e[34];let N;e[40]!==h||e[41]!==n?(N=h?s.jsx(ws,{selected:!0,onSelect:dg,label:h,description:n("settings.webSearch.option.missing")}):null,e[40]=h,e[41]=n,e[42]=N):N=e[42];const I=i.kind==="off";let y;e[43]!==c?(y=()=>c({kind:"off"}),e[43]=c,e[44]=y):y=e[44];let T;e[45]!==n?(T=n("settings.webSearch.option.off"),e[45]=n,e[46]=T):T=e[46];let x;e[47]!==l||e[48]!==I||e[49]!==y||e[50]!==T?(x=s.jsx(ws,{selected:I,onSelect:y,disabled:l,label:T}),e[47]=l,e[48]=I,e[49]=y,e[50]=T,e[51]=x):x=e[51];let A;e[52]!==p||e[53]!==S||e[54]!==N||e[55]!==x||e[56]!==m||e[57]!==k?(A=s.jsxs(tn,{"aria-label":m,children:[k,p,S,N,x]}),e[52]=p,e[53]=S,e[54]=N,e[55]=x,e[56]=m,e[57]=k,e[58]=A):A=e[58];let R;e[59]!==a.projectOverride||e[60]!==n?(R=a.projectOverride?s.jsx("p",{className:`${vs} mt-2 break-all`,children:n("settings.webSearch.state.projectOverride",{path:a.projectOverride})}):null,e[59]=a.projectOverride,e[60]=n,e[61]=R):R=e[61];let P;e[62]!==a.providers.length||e[63]!==n?(P=a.providers.length===0?s.jsx("p",{className:`${vs} mt-2`,children:n("settings.webSearch.state.noProviders")}):null,e[62]=a.providers.length,e[63]=n,e[64]=P):P=e[64];let D;e[65]!==A||e[66]!==R||e[67]!==P?(D=s.jsxs("div",{children:[A,R,P]}),e[65]=A,e[66]=R,e[67]=P,e[68]=D):D=e[68];let F;return e[69]!==g||e[70]!==D||e[71]!==f?(F=s.jsx(qe,{title:g,info:f,divider:!1,settingsItem:"web-search.provider",children:D}),e[69]=g,e[70]=D,e[71]=f,e[72]=F):F=e[72],F},rg=t=>{const e=tt.c(26),{provider:a,access:n}=t,{t:r}=Qe(),i=gi(ug),l=gi(mg),[d,c]=o.useState(""),[h,g]=o.useState(!1);let f;e[0]!==n.envNames||e[1]!==r?(f=n.envNames.length>0?r("settings.webSearch.keys.envHint",{names:n.envNames.join(", ")}):void 0,e[0]=n.envNames,e[1]=r,e[2]=f):f=e[2];const m=f;let u;e[3]!==d||e[4]!==a.id||e[5]!==a.name||e[6]!==i||e[7]!==r?(u=async()=>{const N=d.trim();if(!N)return;g(!0);const I=await i(a.id,N);g(!1),I?(c(""),$.success(r("settings.webSearch.toast.keySaved",{provider:a.name}))):$.error(r("settings.webSearch.toast.keySaveFailed"))},e[3]=d,e[4]=a.id,e[5]=a.name,e[6]=i,e[7]=r,e[8]=u):u=e[8];const v=u;let w;e[9]!==a.id||e[10]!==l||e[11]!==r?(w=async()=>{g(!0);const N=await l(a.id);g(!1),N||$.error(r("settings.webSearch.toast.keyRemoveFailed"))},e[9]=a.id,e[10]=l,e[11]=r,e[12]=w):w=e[12];const b=w,k=n.key;let p;e[13]!==h||e[14]!==d||e[15]!==b||e[16]!==v||e[17]!==a.name||e[18]!==k.kind||e[19]!==k.name||e[20]!==r?(p=k.kind==="stored"?s.jsxs("div",{className:`${Ps} flex items-center justify-end gap-2`,children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.webSearch.keys.saved")}),s.jsx(G,{variant:"outline",size:"xs",disabled:h,onClick:()=>{b()},children:r("settings.webSearch.keys.remove")})]}):k.kind==="env"?s.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.webSearch.keys.fromEnv",{name:k.name})}):s.jsxs("div",{className:`${Ps} flex items-center gap-2`,children:[s.jsx(He,{type:"password",value:d,onChange:N=>c(N.target.value),onKeyDown:N=>{N.key==="Enter"&&v()},placeholder:r("settings.webSearch.keys.placeholder"),"aria-label":r("settings.webSearch.keys.inputAria",{provider:a.name}),className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"}),s.jsx(G,{size:"xs",disabled:h||d.trim().length===0,onClick:()=>{v()},children:r("settings.webSearch.keys.save")})]}),e[13]=h,e[14]=d,e[15]=b,e[16]=v,e[17]=a.name,e[18]=k.kind,e[19]=k.name,e[20]=r,e[21]=p):p=e[21];let S;return e[22]!==m||e[23]!==a.name||e[24]!==p?(S=s.jsx(It,{label:a.name,info:m,children:p}),e[22]=m,e[23]=a.name,e[24]=p,e[25]=S):S=e[25],S},og=t=>{const e=tt.c(23),{snapshot:a}=t,{t:n}=Qe(),r=a.access;let i,l,d,c,h,g,f;if(e[0]!==r||e[1]!==a.providers||e[2]!==n){f=Symbol.for("react.early_return_sentinel");e:{const v=r?a.providers.flatMap(w=>{const b=r[w.id];return b&&b.key.kind!=="unsupported"?[{provider:w,access:b}]:[]}):[];if(r&&v.length===0){f=null;break e}i=qe,e[10]!==n?(c=n("settings.webSearch.section.keys"),e[10]=n,e[11]=c):c=e[11],e[12]!==n?(h=n("settings.webSearch.section.keysInfo"),e[12]=n,e[13]=h):h=e[13],g="web-search.keys",l="space-y-4",d=r===null?s.jsx("p",{className:vs,children:n("settings.webSearch.state.keysUnavailable")}):v.map(pg)}e[0]=r,e[1]=a.providers,e[2]=n,e[3]=i,e[4]=l,e[5]=d,e[6]=c,e[7]=h,e[8]=g,e[9]=f}else i=e[3],l=e[4],d=e[5],c=e[6],h=e[7],g=e[8],f=e[9];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;e[14]!==l||e[15]!==d?(m=s.jsx("div",{className:l,children:d}),e[14]=l,e[15]=d,e[16]=m):m=e[16];let u;return e[17]!==i||e[18]!==c||e[19]!==h||e[20]!==g||e[21]!==m?(u=s.jsx(i,{title:c,info:h,settingsItem:g,children:m}),e[17]=i,e[18]=c,e[19]=h,e[20]=g,e[21]=m,e[22]=u):u=e[22],u},lg=()=>{const t=tt.c(17),{t:e}=Qe(),a=gi(gg),n=gi(hg);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=Hd(),t[0]=r):r=t[0];const i=r;let l,d;t[1]!==n?(l=()=>{n()},d=[n,i],t[1]=n,t[2]=l,t[3]=d):(l=t[2],d=t[3]),o.useEffect(l,d);const c=a.kind==="ready"&&a.snapshot.scope===i?a.snapshot:null;let h;t[4]!==e?(h=e("settings.page.webSearch.title"),t[4]=e,t[5]=h):h=t[5];let g;t[6]!==e?(g=e("settings.page.webSearch.description"),t[6]=e,t[7]=g):g=t[7];let f;t[8]!==n||t[9]!==c||t[10]!==a.kind||t[11]!==e?(f=c?s.jsxs(s.Fragment,{children:[s.jsx(ig,{snapshot:c}),s.jsx(og,{snapshot:c})]}):a.kind==="failed"?s.jsx(qe,{divider:!1,children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("settings.webSearch.state.loadFailed")}),s.jsx(G,{variant:"outline",size:"xs",onClick:()=>{n()},children:e("settings.webSearch.actions.retry")})]})}):s.jsx(qe,{divider:!1,children:s.jsx("p",{className:vs,children:e("settings.webSearch.state.loading")})}),t[8]=n,t[9]=c,t[10]=a.kind,t[11]=e,t[12]=f):f=t[12];let m;return t[13]!==h||t[14]!==g||t[15]!==f?(m=s.jsx(ts,{title:h,description:g,showSaveStatus:!0,children:f}),t[13]=h,t[14]=g,t[15]=f,t[16]=m):m=t[16],m};function cg(t){return t.setSelection}function dg(){}function ug(t){return t.saveKey}function mg(t){return t.removeKey}function pg(t){const{provider:e,access:a}=t;return s.jsx(rg,{provider:e,access:a},e.id)}function gg(t){return t.state}function hg(t){return t.load}const fg=t=>{const e=tt.c(176),{onItemSelect:a}=t,{t:n}=Qe(),[r,i]=o.useState(null),[l,d]=o.useState(""),[c,h]=o.useState(null),[g,f]=o.useState(null),[m,u]=o.useState(!1),[v,w]=o.useState(null),{selectedCommandName:b,setSelectedCommand:k,setCommandDraft:p,createCommand:S,deleteCommand:N,loadCommands:I}=Wa(Bs(xg)),y=rn();let T;e[0]!==y?(T=Xe=>Tc(Xe,y),e[0]=y,e[1]=T):T=e[1];const x=Wa(T);let A;e[2]!==y?(A=Xe=>xo(Xe,y),e[2]=y,e[3]=A):A=e[3];const R=sn(A),P=sn(bg);let D,F;e[4]!==I||e[5]!==P||e[6]!==y?(D=()=>{I(y),P(y)},F=[I,P,y],e[4]=I,e[5]=P,e[6]=y,e[7]=D,e[8]=F):(D=e[7],F=e[8]),o.useEffect(D,F);let O;e[9]!==R?(O=new Set(R.map(vg)),e[9]=R,e[10]=O):O=e[10];const C=O;let M;if(e[11]!==x||e[12]!==C){let Xe;e[14]!==C?(Xe=jt=>!C.has(jt.name),e[14]=C,e[15]=Xe):Xe=e[15],M=x.filter(Xe),e[11]=x,e[12]=C,e[13]=M}else M=e[13];const U=M;let L,W;e[16]!==b||e[17]!==k||e[18]!==C?(L=()=>{b&&C.has(b)&&k(null)},W=[b,k,C],e[16]=b,e[17]=k,e[18]=C,e[19]=L,e[20]=W):(L=e[19],W=e[20]),o.useEffect(L,W);let X;e[21]!==x||e[22]!==a||e[23]!==p||e[24]!==k?(X=()=>{let Xe="new-command",jt=1;for(;x.some(De=>De.name===Xe);)Xe=`new-command-${jt}`,jt++;p({name:Xe,scope:"user"}),k(Xe),a?.()},e[21]=x,e[22]=a,e[23]=p,e[24]=k,e[25]=X):X=e[25];const J=X;let q;e[26]!==n?(q=async Xe=>{if($a(Xe)){$.error(n("settings.commands.sidebar.toast.builtInCannotDelete"));return}h(Xe),f("delete")},e[26]=n,e[27]=q):q=e[27];const z=q;let H;e[28]===Symbol.for("react.memo_cache_sentinel")?(H=async Xe=>{$a(Xe)&&(h(Xe),f("reset"))},e[28]=H):H=e[28];const se=H;let B;e[29]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{h(null),f(null)},e[29]=B):B=e[29];const ne=B;let K;e[30]!==c||e[31]!==g||e[32]!==N||e[33]!==y||e[34]!==n?(K=async()=>{if(!c||!g)return;u(!0),await N(c.name,y)?(g==="delete"?$.success(n("settings.commands.sidebar.toast.commandDeleted",{name:c.name})):$.success(n("settings.commands.sidebar.toast.commandReset",{name:c.name})),ne()):g==="delete"?$.error(n("settings.commands.sidebar.toast.deleteFailed")):$.error(n("settings.commands.sidebar.toast.resetFailed")),u(!1)},e[30]=c,e[31]=g,e[32]=N,e[33]=y,e[34]=n,e[35]=K):K=e[35];const Z=K;let oe;e[36]!==x||e[37]!==p||e[38]!==k?(oe=Xe=>{const jt=Xe.name;let De=1,$e=`${jt}-copy`;for(;x.some(Y=>Y.name===$e);)De++,$e=`${jt}-copy-${De}`;p({name:$e,scope:Xe.scope||"user",description:Xe.description,template:Xe.template,agent:Xe.agent,model:Xe.model,subagent:Xe.subagent}),k($e)},e[36]=x,e[37]=p,e[38]=k,e[39]=oe):oe=e[39];const ue=oe;let de;e[40]===Symbol.for("react.memo_cache_sentinel")?(de=Xe=>{d(Xe.name),i(Xe)},e[40]=de):de=e[40];const ce=de;let Se;e[41]!==x||e[42]!==S||e[43]!==N||e[44]!==r||e[45]!==l||e[46]!==k||e[47]!==y||e[48]!==n?(Se=async()=>{if(!r)return;const Xe=l.trim().replace(/\s+/g,"-");if(!Xe){$.error(n("settings.commands.sidebar.toast.commandNameRequired"));return}if(Xe===r.name){i(null);return}if(x.some(De=>De.name===Xe)){$.error(n("settings.commands.sidebar.toast.commandExists"));return}await S({name:Xe,description:r.description,template:r.template,agent:r.agent,model:r.model,subagent:r.subagent,scope:r.scope},y)?await N(r.name,y)?($.success(`Command renamed to "${Xe}"`),k(Xe)):$.error(n("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):$.error(n("settings.commands.sidebar.toast.renameFailed")),i(null)},e[41]=x,e[42]=S,e[43]=N,e[44]=r,e[45]=l,e[46]=k,e[47]=y,e[48]=n,e[49]=Se):Se=e[49];const re=Se;let ve,ie,me,ke,Ae,pe;if(e[50]!==U||e[51]!==J||e[52]!==z||e[53]!==ue||e[54]!==a||e[55]!==v||e[56]!==b||e[57]!==k||e[58]!==n){const Xe=U.filter($a),jt=U.filter(yg);e[65]===Symbol.for("react.memo_cache_sentinel")?(Ae=Pe("flex h-full flex-col","bg-background"),e[65]=Ae):Ae=e[65];let De;e[66]!==n?(De=n("settings.commands.sidebar.title"),e[66]=n,e[67]=De):De=e[67];let $e;e[68]!==De?($e=s.jsx("h2",{className:`${_n} mb-3`,children:De}),e[68]=De,e[69]=$e):$e=e[69];let Y;e[70]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(xi,{className:"mb-3"}),e[70]=Y):Y=e[70];let V;e[71]!==U.length||e[72]!==n?(V=n("settings.commands.sidebar.total",{count:U.length}),e[71]=U.length,e[72]=n,e[73]=V):V=e[73];let be;e[74]!==V?(be=s.jsx("span",{className:"typography-meta text-muted-foreground",children:V}),e[74]=V,e[75]=be):be=e[75];let ge;e[76]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),e[76]=ge):ge=e[76];let Ee;e[77]!==J?(Ee=s.jsx(G,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:J,children:ge}),e[77]=J,e[78]=Ee):Ee=e[78];let te;e[79]!==be||e[80]!==Ee?(te=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[be,Ee]}),e[79]=be,e[80]=Ee,e[81]=te):te=e[81],e[82]!==$e||e[83]!==te?(pe=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[$e,Y,te]}),e[82]=$e,e[83]=te,e[84]=pe):pe=e[84],ve=Ns,ie="flex-1 min-h-0",me="space-y-1 px-3 py-2",ke=U.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"terminal-box",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.commands.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.commands.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[Xe.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.commands.sidebar.section.builtIn")}),[...Xe].sort(jg).map(xe=>s.jsx(jl,{command:xe,isSelected:b===xe.name,onSelect:()=>{k(xe.name),a?.()},onReset:()=>se(xe),onDuplicate:()=>ue(xe),isMenuOpen:v===xe.name,onMenuOpenChange:Ze=>w(Ze?xe.name:null)},xe.name))]}),jt.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.commands.sidebar.section.custom")}),[...jt].sort(wg).map(xe=>s.jsx(jl,{command:xe,isSelected:b===xe.name,onSelect:()=>{k(xe.name),a?.()},onRename:()=>ce(xe),onDelete:()=>z(xe),onDuplicate:()=>ue(xe),isMenuOpen:v===xe.name,onMenuOpenChange:Ze=>w(Ze?xe.name:null)},xe.name))]})]}),e[50]=U,e[51]=J,e[52]=z,e[53]=ue,e[54]=a,e[55]=v,e[56]=b,e[57]=k,e[58]=n,e[59]=ve,e[60]=ie,e[61]=me,e[62]=ke,e[63]=Ae,e[64]=pe}else ve=e[59],ie=e[60],me=e[61],ke=e[62],Ae=e[63],pe=e[64];let Le;e[85]!==ve||e[86]!==ie||e[87]!==me||e[88]!==ke?(Le=s.jsx(ve,{outerClassName:ie,className:me,children:ke}),e[85]=ve,e[86]=ie,e[87]=me,e[88]=ke,e[89]=Le):Le=e[89];const Ve=c!==null&&g!==null;let ye;e[90]!==m?(ye=Xe=>{!Xe&&!m&&ne()},e[90]=m,e[91]=ye):ye=e[91];let Te;e[92]!==g||e[93]!==n?(Te=n(g==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[92]=g,e[93]=n,e[94]=Te):Te=e[94];let ee;e[95]!==Te?(ee=s.jsx(Ht,{children:Te}),e[95]=Te,e[96]=ee):ee=e[96];let ae;e[97]!==c?.name||e[98]!==g||e[99]!==n?(ae=g==="delete"?n("settings.commands.sidebar.dialog.deleteDescription",{name:c?.name??""}):n("settings.commands.sidebar.dialog.resetDescription",{name:c?.name??""}),e[97]=c?.name,e[98]=g,e[99]=n,e[100]=ae):ae=e[100];let fe;e[101]!==ae?(fe=s.jsx(qt,{children:ae}),e[101]=ae,e[102]=fe):fe=e[102];let je;e[103]!==ee||e[104]!==fe?(je=s.jsxs(Vt,{children:[ee,fe]}),e[103]=ee,e[104]=fe,e[105]=je):je=e[105];let Re;e[106]!==n?(Re=n("settings.common.actions.cancel"),e[106]=n,e[107]=Re):Re=e[107];let Ce;e[108]!==m||e[109]!==Re?(Ce=s.jsx(G,{size:"sm",variant:"ghost",onClick:ne,disabled:m,children:Re}),e[108]=m,e[109]=Re,e[110]=Ce):Ce=e[110];let _e;e[111]!==g||e[112]!==n?(_e=n(g==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[111]=g,e[112]=n,e[113]=_e):_e=e[113];let Ke;e[114]!==Z||e[115]!==m||e[116]!==_e?(Ke=s.jsx(G,{size:"sm",onClick:Z,disabled:m,children:_e}),e[114]=Z,e[115]=m,e[116]=_e,e[117]=Ke):Ke=e[117];let Fe;e[118]!==Ce||e[119]!==Ke?(Fe=s.jsxs(as,{children:[Ce,Ke]}),e[118]=Ce,e[119]=Ke,e[120]=Fe):Fe=e[120];let Me;e[121]!==je||e[122]!==Fe?(Me=s.jsxs(_t,{className:"max-w-md",children:[je,Fe]}),e[121]=je,e[122]=Fe,e[123]=Me):Me=e[123];let at;e[124]!==Ve||e[125]!==ye||e[126]!==Me?(at=s.jsx(Ut,{open:Ve,onOpenChange:ye,children:Me}),e[124]=Ve,e[125]=ye,e[126]=Me,e[127]=at):at=e[127];const pt=r!==null;let ot;e[128]===Symbol.for("react.memo_cache_sentinel")?(ot=Xe=>!Xe&&i(null),e[128]=ot):ot=e[128];let mt;e[129]!==n?(mt=n("settings.commands.sidebar.renameDialog.title"),e[129]=n,e[130]=mt):mt=e[130];let ht;e[131]!==mt?(ht=s.jsx(Ht,{children:mt}),e[131]=mt,e[132]=ht):ht=e[132];const Oe=r?.name??"";let nt;e[133]!==n||e[134]!==Oe?(nt=n("settings.commands.sidebar.renameDialog.description",{name:Oe}),e[133]=n,e[134]=Oe,e[135]=nt):nt=e[135];let lt;e[136]!==nt?(lt=s.jsx(qt,{children:nt}),e[136]=nt,e[137]=lt):lt=e[137];let we;e[138]!==ht||e[139]!==lt?(we=s.jsxs(Vt,{children:[ht,lt]}),e[138]=ht,e[139]=lt,e[140]=we):we=e[140];let Je;e[141]===Symbol.for("react.memo_cache_sentinel")?(Je=Xe=>d(Xe.target.value),e[141]=Je):Je=e[141];let Ye;e[142]!==n?(Ye=n("settings.commands.sidebar.renameDialog.placeholder"),e[142]=n,e[143]=Ye):Ye=e[143];let ze;e[144]!==re?(ze=Xe=>{Xe.key==="Enter"&&re()},e[144]=re,e[145]=ze):ze=e[145];let Ge;e[146]!==l||e[147]!==Ye||e[148]!==ze?(Ge=s.jsx(He,{value:l,onChange:Je,placeholder:Ye,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:ze}),e[146]=l,e[147]=Ye,e[148]=ze,e[149]=Ge):Ge=e[149];let Q;e[150]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>i(null),e[150]=Q):Q=e[150];let Ue;e[151]!==n?(Ue=n("settings.common.actions.cancel"),e[151]=n,e[152]=Ue):Ue=e[152];let st;e[153]!==Ue?(st=s.jsx(G,{size:"sm",variant:"ghost",onClick:Q,children:Ue}),e[153]=Ue,e[154]=st):st=e[154];let dt;e[155]!==n?(dt=n("settings.common.actions.rename"),e[155]=n,e[156]=dt):dt=e[156];let ct;e[157]!==re||e[158]!==dt?(ct=s.jsx(G,{size:"sm",onClick:re,children:dt}),e[157]=re,e[158]=dt,e[159]=ct):ct=e[159];let ft;e[160]!==st||e[161]!==ct?(ft=s.jsxs(as,{children:[st,ct]}),e[160]=st,e[161]=ct,e[162]=ft):ft=e[162];let kt;e[163]!==we||e[164]!==Ge||e[165]!==ft?(kt=s.jsxs(_t,{children:[we,Ge,ft]}),e[163]=we,e[164]=Ge,e[165]=ft,e[166]=kt):kt=e[166];let bt;e[167]!==pt||e[168]!==kt?(bt=s.jsx(Ut,{open:pt,onOpenChange:ot,children:kt}),e[167]=pt,e[168]=kt,e[169]=bt):bt=e[169];let vt;return e[170]!==Ae||e[171]!==pe||e[172]!==Le||e[173]!==at||e[174]!==bt?(vt=s.jsxs("div",{className:Ae,children:[pe,Le,at,bt]}),e[170]=Ae,e[171]=pe,e[172]=Le,e[173]=at,e[174]=bt,e[175]=vt):vt=e[175],vt},jl=t=>{const e=tt.c(47),{command:a,isSelected:n,onSelect:r,onDelete:i,onReset:l,onRename:d,onDuplicate:c,isMenuOpen:h,onMenuOpenChange:g}=t,{t:f}=Qe();let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=pi(),e[0]=m):m=e[0];const u=m,[v,w]=o.useState(!1);let b;e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==l||e[5]!==f?(b=W=>s.jsxs(s.Fragment,{children:[d&&s.jsxs(W,{onClick:X=>{X.stopPropagation(),d()},children:[s.jsx(_,{name:"edit",className:"h-4 w-4 mr-px"}),f("settings.common.actions.rename")]}),s.jsxs(W,{onClick:X=>{X.stopPropagation(),c()},children:[s.jsx(_,{name:"file-copy",className:"h-4 w-4 mr-px"}),f("settings.common.actions.duplicate")]}),l&&s.jsxs(W,{onClick:X=>{X.stopPropagation(),l()},children:[s.jsx(_,{name:"restart",className:"h-4 w-4 mr-px"}),f("settings.common.actions.reset")]}),i&&s.jsxs(W,{onClick:X=>{X.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),f("settings.common.actions.delete")]})]}),e[1]=i,e[2]=c,e[3]=d,e[4]=l,e[5]=f,e[6]=b):b=e[6];const k=b,p=n?"bg-interactive-selection":"hover:bg-interactive-hover";let S;e[7]!==p?(S=Pe("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",p),e[7]=p,e[8]=S):S=e[8];let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=u?void 0:W=>{W.preventDefault(),w(!0)},e[9]=N):N=e[9];let I;e[10]!==S?(I=s.jsx("div",{className:S,onContextMenu:N}),e[10]=S,e[11]=I):I=e[11];let y;e[12]!==a.name?(y=s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",a.name]}),e[12]=a.name,e[13]=y):y=e[13];let T;e[14]!==a||e[15]!==f?(T=(a.scope||$a(a))&&s.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:$a(a)?f("settings.agents.sidebar.badge.system"):a.scope}),e[14]=a,e[15]=f,e[16]=T):T=e[16];let x;e[17]!==y||e[18]!==T?(x=s.jsxs("div",{className:"flex items-center gap-2",children:[y,T]}),e[17]=y,e[18]=T,e[19]=x):x=e[19];let A;e[20]!==a.description?(A=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[20]=a.description,e[21]=A):A=e[21];let R;e[22]!==r||e[23]!==A||e[24]!==x?(R=s.jsxs("button",{onClick:r,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-ring",tabIndex:0,children:[x,A]}),e[22]=r,e[23]=A,e[24]=x,e[25]=R):R=e[25];let P;e[26]!==g?(P=W=>{W&&w(!1),g(W)},e[26]=g,e[27]=P):P=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(Nn,{asChild:!0,children:s.jsx(G,{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:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=D):D=e[28];let F;e[29]!==k?(F=s.jsx(kn,{align:"end",className:"w-fit min-w-20",children:k(an)}),e[29]=k,e[30]=F):F=e[30];let O;e[31]!==h||e[32]!==P||e[33]!==F?(O=s.jsxs(Sn,{open:h,onOpenChange:P,children:[D,F]}),e[31]=h,e[32]=P,e[33]=F,e[34]=O):O=e[34];let C;e[35]!==R||e[36]!==O?(C=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[R,O]}),e[35]=R,e[36]=O,e[37]=C):C=e[37];let M;e[38]!==C||e[39]!==I?(M=s.jsx(ga,{render:I,children:C}),e[38]=C,e[39]=I,e[40]=M):M=e[40];let U;e[41]!==k?(U=s.jsx(ma,{className:"w-fit min-w-20",children:k(pa)}),e[41]=k,e[42]=U):U=e[42];let L;return e[43]!==v||e[44]!==M||e[45]!==U?(L=s.jsxs(ha,{open:v,onOpenChange:w,children:[M,U]}),e[43]=v,e[44]=M,e[45]=U,e[46]=L):L=e[46],L};function xg(t){return{selectedCommandName:t.selectedCommandName,setSelectedCommand:t.setSelectedCommand,setCommandDraft:t.setCommandDraft,createCommand:t.createCommand,deleteCommand:t.deleteCommand,loadCommands:t.loadCommands}}function bg(t){return t.loadSkills}function vg(t){return t.name}function yg(t){return!$a(t)}function jg(t,e){return t.name.localeCompare(e.name)}function wg(t,e){return t.name.localeCompare(e.name)}const kg=()=>{const{t}=Qe(),{selectedCommandName:e,getCommandByName:a,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:l,setSelectedCommand:d}=Wa(Bs(H=>({selectedCommandName:H.selectedCommandName,getCommandByName:H.getCommandByName,createCommand:H.createCommand,updateCommand:H.updateCommand,commandDraft:H.commandDraft,setCommandDraft:H.setCommandDraft,setSelectedCommand:H.setSelectedCommand}))),c=rn(),h=Wa(H=>Tc(H,c)),g=e?a(e,c):null,f=!!(i&&i.name===e&&!g),[m,u]=o.useState(""),[v,w]=o.useState("user"),[b,k]=o.useState(""),[p,S]=o.useState(""),[N,I]=o.useState(""),[y,T]=o.useState(""),[x,A]=o.useState(!1),[R,P]=o.useState(""),[D,F]=o.useState(!1),O=o.useRef(null),C=JSON.stringify([c,e]),M=o.useRef(null),U=o.useRef(null);o.useEffect(()=>{const H=M.current===C;if(M.current=C,f&&i){const se=i.name||"",B=i.scope||"user",ne=i.description||"",K=i.agent||"",Z=di(i.model),oe=Z?`${Z.providerID}/${Z.modelID}`:"",ue=Z?.variant||"",de=i.subagent===!0,ce=i.template||"";u(se),w(B),k(ne),S(K),I(oe),T(ue),A(de),P(ce),O.current={draftName:se,draftScope:B,description:ne,agent:K,model:oe,variant:ue,subagent:de,template:ce}}else if(g){const se=g.description||"",B=g.agent||"",ne=di(g.model),K=ne?`${ne.providerID}/${ne.modelID}`:"",Z=ne?.variant||"",oe=g.subagent===!0,ue=g.template||"",de=U.current,ce=[O.current,de?.identity===C?de.form:null];if(H&&ce.some(Se=>Se&&Se.description===se&&Se.agent===B&&Se.model===K&&Se.variant===Z&&Se.subagent===oe&&Se.template===ue))return;k(se),S(B),I(K),T(Z),A(oe),P(ue),O.current={draftName:"",draftScope:"user",description:se,agent:B,model:K,variant:Z,subagent:oe,template:ue}}},[g,f,e,h,i,C]);const L=o.useCallback(H=>{const se=p.trim(),B=zn(N.trim()),ne=B?Pc({providerID:B.providerId,modelID:B.modelId,variant:y.trim()||void 0}):null;return{name:H,description:b.trim()||void 0,agent:se===""?null:se,model:ne,subagent:x,template:R.trim(),scope:f?v:void 0}},[p,b,v,f,N,x,R,y]),W=o.useCallback(async()=>{const H=O.current,se=e?.trim();if(f||!H||!se||b.trim()===H.description.trim()&&p.trim()===H.agent.trim()&&N.trim()===H.model.trim()&&y.trim()===H.variant.trim()&&x===H.subagent&&R.trim()===H.template.trim())return Os;if(!R.trim())return ms(t("settings.commands.page.toast.templateRequired"));const ne=L(se),K=di(ne.model),Z={identity:C,form:{...H,description:ne.description||"",agent:ne.agent||"",model:K?`${K.providerID}/${K.modelID}`:"",variant:K?.variant||"",subagent:ne.subagent===!0,template:ne.template||""}};U.current=Z;try{return await r(se,ne,c)?(M.current===C&&(O.current=Z.form),Tn):ms(t("settings.commands.page.toast.updateFailed"))}finally{U.current===Z&&(U.current=null)}},[p,L,b,C,f,N,e,c,x,t,R,r,y]),X=Ya(W),{requestSave:J}=X,q=async()=>{const H=m.trim().replace(/\s+/g,"-");if(!H){$.error(t("settings.commands.sidebar.toast.commandNameRequired"));return}if(!R.trim()){$.error(t("settings.commands.page.toast.templateRequired"));return}if(h.some(se=>se.name===H)){$.error(t("settings.commands.sidebar.toast.commandExists"));return}F(!0);try{await n(L(H),c)?(l(null),$.success(t("settings.commands.page.toast.created"))):$.error(t("settings.commands.page.toast.createFailed"))}catch(se){console.error("Error creating command:",se),$.error(t("settings.commands.page.toast.saveUnexpectedError"))}finally{F(!1)}},z=()=>{l(null),d(null)};return e?s.jsxs(ts,{title:f?t("settings.commands.page.title.new"):`/${e}`,description:t(f?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit"),onBlurCapture:X.onBlurCapture,children:[!f&&g&&s.jsx(To,{legacy:g.legacy===!0,path:g.path}),s.jsxs(qe,{title:t("settings.commands.page.section.identity"),divider:!1,contentClassName:"space-y-0",children:[f&&s.jsxs(It,{settingsItem:"commands.name",label:t("settings.commands.page.field.commandName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"/"}),s.jsx(He,{value:m,onChange:H=>u(H.target.value),placeholder:t("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Et,{value:v,onValueChange:H=>w(H),children:[s.jsx(At,{size:Bt,className:"w-fit min-w-[100px]",children:s.jsx($t,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(Tt,{align:"end",children:[s.jsx(ut,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(ut,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsxs("div",{className:"py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.common.field.description")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(As,{value:b,onChange:H=>k(H.target.value),placeholder:t("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]}),s.jsxs(qe,{title:t("settings.commands.page.section.executionContext"),contentClassName:"space-y-0",children:[s.jsx(It,{settingsItem:"commands.agent",label:t("settings.commands.page.field.overrideAgent"),children:s.jsx(bo,{agentName:p,onChange:H=>{S(H),J()},className:Ws})}),s.jsx(It,{settingsItem:"commands.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ca,{providerId:zn(N)?.providerId??"",modelId:zn(N)?.modelId??"",onChange:(H,se)=>{I(H&&se?`${H}/${se}`:""),J()},className:Ws})}),s.jsx(It,{settingsItem:"commands.variant",label:t("settings.agents.page.field.variant"),info:t("settings.agents.page.field.variantTooltip"),children:s.jsx(He,{value:y,onChange:H=>T(H.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!N&&!y,className:"h-8 w-40 rounded-md px-3"})}),s.jsx(It,{settingsItem:"commands.subagent",label:t("settings.commands.page.field.subagent"),info:t("settings.commands.page.field.subagentTooltip"),children:s.jsx(Ba,{checked:x,onCheckedChange:H=>{A(H),J()},"aria-label":t("settings.commands.page.field.subagent")})})]}),s.jsxs(qe,{title:t("settings.commands.page.section.template"),settingsItem:"commands.template",children:[s.jsx(As,{value:R,onChange:H=>P(H.target.value),placeholder:t("settings.commands.page.field.templatePlaceholder"),rows:12,className:"w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),s.jsxs("p",{className:"mt-2 typography-meta text-muted-foreground",children:[s.jsx("code",{className:"text-foreground",children:"$ARGUMENTS"})," ",t("settings.commands.page.templateHint.userInput")," ·"," ",s.jsx("code",{className:"text-foreground",children:"!`cmd`"})," ",t("settings.commands.page.templateHint.shellOutput")," ·"," ",s.jsx("code",{className:"text-foreground",children:"@file"})," ",t("settings.commands.page.templateHint.fileContents")]}),f&&s.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[s.jsx(G,{onClick:()=>{q()},disabled:D||!m.trim()||!R.trim(),size:"xs",className:"!font-normal",children:t(D?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(G,{variant:"ghost",onClick:z,disabled:D,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(_,{name:"terminal-box",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.commands.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.commands.page.empty.description")})]})})},Zi={oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:""},Ng=t=>t===!1?{...Zi,oauthEnabled:!1}:t?{oauthEnabled:!0,oauthClientId:t.client_id??"",oauthClientSecret:t.client_secret??"",oauthScope:t.scope??"",oauthRedirectUri:t.redirect_uri??"",oauthCallbackPort:t.callback_port===void 0?"":String(t.callback_port)}:Zi,wl=t=>{switch(t){case"connected":return"success";case"failed":return"error";case"needs_auth":return"warning";default:return"idle"}},kl=t=>{const e=tt.c(5),{tone:a,enabled:n}=t;if(!n){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0"}),e[0]=l):l=e[0],l}let r;e[1]!==a?(r=Pe("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"}[a]),e[1]=a,e[2]=r):r=e[2];let i;return e[3]!==r?(i=s.jsx("span",{className:r}),e[3]=r,e[4]=i):i=e[4],i},Sg=t=>{const e=tt.c(124),{onItemSelect:a}=t,{t:n}=Qe(),{selectedMcpName:r,setSelectedMcp:i,setMcpDraft:l,loadMcpConfigs:d,deleteMcp:c}=Yn(Bs(Cg)),h=rn();let g;e[0]!==h?(g=Oe=>fo(Oe,h),e[0]=h,e[1]=g):g=e[1];const f=Yn(g);let m;e[2]!==h?(m=Oe=>Oe.getStatusForDirectory(h),e[2]=h,e[3]=m):m=e[3];const u=un(m),v=un(Ig),w=un(Pg),[b,k]=o.useState(null),[p,S]=o.useState(!1),[N,I]=o.useState(null),[y,T]=o.useState(null),[x,A]=o.useState(!1);let R;e[4]!==f?(R=f.filter(Ag),e[4]=f,e[5]=R):R=e[5];const P=R;let D;e[6]!==f?(D=f.filter(Tg),e[6]=f,e[7]=D):D=e[7];const F=D;let O,C;e[8]!==d||e[9]!==h?(O=()=>{d({directory:h})},C=[d,h],e[8]=d,e[9]=h,e[10]=O,e[11]=C):(O=e[10],C=e[11]),o.useEffect(O,C);let M;e[12]!==w||e[13]!==x||e[14]!==v||e[15]!==h?(M=()=>{if(x)return;A(!0);const Oe=new Promise(Eg);Promise.all([v({directory:h,silent:!0}),Oe]).then(()=>{const nt=w(h);nt&&$.error(nt)}).finally(()=>{A(!1)})},e[12]=w,e[13]=x,e[14]=v,e[15]=h,e[16]=M):M=e[16];const U=M;let L;e[17]!==f||e[18]!==a||e[19]!==l||e[20]!==i?(L=()=>{let Oe="new-mcp-server",nt=1;for(;f.some(we=>we.name===Oe);)Oe=`new-mcp-server-${nt}`,nt++;const lt={name:Oe,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],...Zi,oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1};l(lt),i(Oe),a?.()},e[17]=f,e[18]=a,e[19]=l,e[20]=i,e[21]=L):L=e[21];const W=L;let X;e[22]!==c||e[23]!==b||e[24]!==h||e[25]!==n?(X=async()=>{if(!b)return;S(!0);const Oe=await c(b.name,h);Oe.ok?Oe.reloadFailed?$.warning(Oe.message||`MCP server "${b.name}" deleted, but OpenCode reload failed`,{description:Oe.warning||n("settings.mcp.sidebar.toast.refreshListIfStale")}):$.success(Oe.message||n("settings.mcp.sidebar.toast.serverDeleted",{name:b.name})):$.error(n("settings.mcp.sidebar.toast.deleteFailed")),k(null),S(!1)},e[22]=c,e[23]=b,e[24]=h,e[25]=n,e[26]=X):X=e[26];const J=X;let q;e[27]!==n?(q=(Oe,nt)=>s.jsxs(nt,{onClick:lt=>{lt.stopPropagation(),k(Oe)},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),n("settings.common.actions.delete")]}),e[27]=n,e[28]=q):q=e[28];const z=q;let H;e[29]===Symbol.for("react.memo_cache_sentinel")?(H=Pe("flex h-full flex-col","bg-background"),e[29]=H):H=e[29];let se;e[30]!==n?(se=n("settings.mcp.sidebar.title"),e[30]=n,e[31]=se):se=e[31];let B;e[32]!==se?(B=s.jsx("h2",{className:_n,children:se}),e[32]=se,e[33]=B):B=e[33];let ne;e[34]!==n?(ne=n("settings.mcp.sidebar.actions.refreshStatusAria"),e[34]=n,e[35]=ne):ne=e[35];let K;e[36]!==n?(K=n("settings.mcp.sidebar.actions.refreshStatusTitle"),e[36]=n,e[37]=K):K=e[37];const Z=x&&"animate-spin";let oe;e[38]!==Z?(oe=Pe("h-4 w-4",Z),e[38]=Z,e[39]=oe):oe=e[39];let ue;e[40]!==oe?(ue=s.jsx(_,{name:"refresh",className:oe}),e[40]=oe,e[41]=ue):ue=e[41];let de;e[42]!==U||e[43]!==x||e[44]!==ne||e[45]!==K||e[46]!==ue?(de=s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",disabled:x,onClick:U,"aria-label":ne,title:K,children:ue}),e[42]=U,e[43]=x,e[44]=ne,e[45]=K,e[46]=ue,e[47]=de):de=e[47];let ce;e[48]!==B||e[49]!==de?(ce=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[B,de]}),e[48]=B,e[49]=de,e[50]=ce):ce=e[50];let Se;e[51]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx(xi,{className:"mb-3"}),e[51]=Se):Se=e[51];let re;e[52]!==f.length||e[53]!==n?(re=n("settings.mcp.sidebar.total",{count:f.length}),e[52]=f.length,e[53]=n,e[54]=re):re=e[54];let ve;e[55]!==re?(ve=s.jsx("span",{className:"typography-meta text-muted-foreground",children:re}),e[55]=re,e[56]=ve):ve=e[56];let ie;e[57]!==n?(ie=n("settings.mcp.sidebar.actions.addServerTitle"),e[57]=n,e[58]=ie):ie=e[58];let me;e[59]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),e[59]=me):me=e[59];let ke;e[60]!==W||e[61]!==ie?(ke=s.jsx(G,{size:"sm","data-settings-item":"mcp.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:W,title:ie,children:me}),e[60]=W,e[61]=ie,e[62]=ke):ke=e[62];let Ae;e[63]!==ve||e[64]!==ke?(Ae=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ve,ke]}),e[63]=ve,e[64]=ke,e[65]=Ae):Ae=e[65];let pe;e[66]!==ce||e[67]!==Ae?(pe=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[ce,Se,Ae]}),e[66]=ce,e[67]=Ae,e[68]=pe):pe=e[68];let Le;e[69]!==f.length||e[70]!==u||e[71]!==a||e[72]!==N||e[73]!==P||e[74]!==z||e[75]!==y||e[76]!==r||e[77]!==l||e[78]!==i||e[79]!==n||e[80]!==F?(Le=s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:f.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"plug",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.mcp.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.mcp.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[P.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.mcp.sidebar.group.projectServers")}),P.map(Oe=>{const nt=u[Oe.name],lt=wl(nt?.status.status),we=r===Oe.name,Je=pi();return s.jsxs(ha,{open:y===Oe.name,onOpenChange:Ye=>T(Ye?Oe.name:null),children:[s.jsxs(ga,{render:s.jsx("div",{className:Pe("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",we?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:Je?void 0:Ye=>{Ye.preventDefault(),T(Oe.name)}}),children:[s.jsxs("button",{onClick:()=>{i(Oe.name),l(null),a?.()},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-ring",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kl,{tone:lt,enabled:Oe.disabled!==!0}),s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:Oe.name}),s.jsx("span",{title:Oe.type==="local"?n("settings.mcp.sidebar.serverType.localTitle"):n("settings.mcp.sidebar.serverType.remoteTitle"),children:Oe.type==="local"?s.jsx(_,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):s.jsx(_,{name:"global",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"})})]}),s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight pl-4",children:Oe.type==="local"?Oe.command?.join(" ")??"":Oe.url??""})]}),s.jsxs(Sn,{open:N===Oe.name,onOpenChange:Ye=>{Ye&&T(null),I(Ye?Oe.name:null)},children:[s.jsx(Nn,{asChild:!0,children:s.jsx(G,{size:"xs",variant:"ghost",className:"flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(kn,{align:"end",className:"w-fit min-w-20",children:z(Oe,an)})]})]}),s.jsx(ma,{className:"w-fit min-w-20",children:z(Oe,pa)})]},Oe.name)})]}),F.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.mcp.sidebar.group.userServers")}),F.map(Oe=>{const nt=u[Oe.name],lt=wl(nt?.status.status),we=r===Oe.name,Je=pi();return s.jsxs(ha,{open:y===Oe.name,onOpenChange:Ye=>T(Ye?Oe.name:null),children:[s.jsxs(ga,{render:s.jsx("div",{className:Pe("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",we?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:Je?void 0:Ye=>{Ye.preventDefault(),T(Oe.name)}}),children:[s.jsxs("button",{onClick:()=>{i(Oe.name),l(null),a?.()},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-ring",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kl,{tone:lt,enabled:Oe.disabled!==!0}),s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:Oe.name}),s.jsx("span",{title:Oe.type==="local"?n("settings.mcp.sidebar.serverType.localTitle"):n("settings.mcp.sidebar.serverType.remoteTitle"),children:Oe.type==="local"?s.jsx(_,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):s.jsx(_,{name:"global",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"})})]}),s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight pl-4",children:Oe.type==="local"?Oe.command?.join(" ")??"":Oe.url??""})]}),s.jsxs(Sn,{open:N===Oe.name,onOpenChange:Ye=>{Ye&&T(null),I(Ye?Oe.name:null)},children:[s.jsx(Nn,{asChild:!0,children:s.jsx(G,{size:"xs",variant:"ghost",className:"flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(kn,{align:"end",className:"w-fit min-w-20",children:z(Oe,an)})]})]}),s.jsx(ma,{className:"w-fit min-w-20",children:z(Oe,pa)})]},Oe.name)})]})]})}),e[69]=f.length,e[70]=u,e[71]=a,e[72]=N,e[73]=P,e[74]=z,e[75]=y,e[76]=r,e[77]=l,e[78]=i,e[79]=n,e[80]=F,e[81]=Le):Le=e[81];const Ve=b!==null;let ye;e[82]!==p?(ye=Oe=>{!Oe&&!p&&k(null)},e[82]=p,e[83]=ye):ye=e[83];let Te;e[84]!==n?(Te=n("settings.mcp.sidebar.deleteDialog.title"),e[84]=n,e[85]=Te):Te=e[85];let ee;e[86]!==Te?(ee=s.jsx(Ht,{children:Te}),e[86]=Te,e[87]=ee):ee=e[87];const ae=b?.name||"";let fe;e[88]!==n||e[89]!==ae?(fe=n("settings.mcp.sidebar.deleteDialog.descriptionPrefix",{name:ae}),e[88]=n,e[89]=ae,e[90]=fe):fe=e[90];let je;e[91]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx("code",{className:"text-foreground",children:"opencode.json"}),e[91]=je):je=e[91];let Re;e[92]!==fe?(Re=s.jsxs(qt,{children:[fe," ",je,"."]}),e[92]=fe,e[93]=Re):Re=e[93];let Ce;e[94]!==ee||e[95]!==Re?(Ce=s.jsxs(Vt,{children:[ee,Re]}),e[94]=ee,e[95]=Re,e[96]=Ce):Ce=e[96];let _e;e[97]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>k(null),e[97]=_e):_e=e[97];let Ke;e[98]!==n?(Ke=n("settings.common.actions.cancel"),e[98]=n,e[99]=Ke):Ke=e[99];let Fe;e[100]!==p||e[101]!==Ke?(Fe=s.jsx(G,{size:"sm",variant:"ghost",onClick:_e,disabled:p,children:Ke}),e[100]=p,e[101]=Ke,e[102]=Fe):Fe=e[102];let Me;e[103]!==p||e[104]!==n?(Me=n(p?"settings.mcp.sidebar.actions.deleting":"settings.common.actions.delete"),e[103]=p,e[104]=n,e[105]=Me):Me=e[105];let at;e[106]!==J||e[107]!==p||e[108]!==Me?(at=s.jsx(G,{size:"sm",onClick:J,disabled:p,children:Me}),e[106]=J,e[107]=p,e[108]=Me,e[109]=at):at=e[109];let pt;e[110]!==Fe||e[111]!==at?(pt=s.jsxs(as,{children:[Fe,at]}),e[110]=Fe,e[111]=at,e[112]=pt):pt=e[112];let ot;e[113]!==Ce||e[114]!==pt?(ot=s.jsxs(_t,{className:"max-w-md",children:[Ce,pt]}),e[113]=Ce,e[114]=pt,e[115]=ot):ot=e[115];let mt;e[116]!==Ve||e[117]!==ye||e[118]!==ot?(mt=s.jsx(Ut,{open:Ve,onOpenChange:ye,children:ot}),e[116]=Ve,e[117]=ye,e[118]=ot,e[119]=mt):mt=e[119];let ht;return e[120]!==pe||e[121]!==Le||e[122]!==mt?(ht=s.jsxs("div",{className:H,children:[pe,Le,mt]}),e[120]=pe,e[121]=Le,e[122]=mt,e[123]=ht):ht=e[123],ht};function Cg(t){return{selectedMcpName:t.selectedMcpName,setSelectedMcp:t.setSelectedMcp,setMcpDraft:t.setMcpDraft,loadMcpConfigs:t.loadMcpConfigs,deleteMcp:t.deleteMcp}}function Ig(t){return t.refresh}function Pg(t){return t.getErrorForDirectory}function Ag(t){return t.scope==="project"}function Tg(t){return t.scope!=="project"}function Eg(t){return setTimeout(t,500)}function Gs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ti(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function yn(t,e){return e!==void 0?{ok:!1,error:t,parsed:e}:{ok:!1,error:t}}function Ri(t,e,a){const n=Mg(a),r=typeof a.url=="string"?a.url.trim():"",i=Nl(a,"env","environment"),l=Nl(a,"headers"),d=Gs(a.oauth)?a.oauth:null,c=si(d,"client_id","clientId"),h=si(d,"client_secret","clientSecret"),g=si(d,"scope"),f=si(d,"redirect_uri","redirectUri"),m=Dg(d,"callback_port","callbackPort"),u=si(d,"auth_server_metadata_url","authServerMetadataUrl"),v=a.oauth===!1||a.oauth===null||a.oauth===void 0?!1:!!d&&!!(c||h||g||f||m||u),w=Rg(a);return{ok:!0,name:t,type:e,command:n,url:r,environment:i,headers:l,oauthEnabled:v,oauthClientId:c,oauthClientSecret:h,oauthScope:g,oauthRedirectUri:f,oauthCallbackPort:m,oauthAuthServerMetadataUrl:u,timeoutStartup:w.startup,timeoutCatalog:w.catalog,timeoutExecution:w.execution,codemode:a.codemode===!0?"on":a.codemode===!1?"off":"default",disabled:Fg(a),protocol:eo.find(b=>b===a.protocol)??"legacy"}}function si(t,...e){if(!t)return"";for(const a of e){const n=t[a];if(typeof n=="string"&&n.trim())return n.trim()}return""}function Dg(t,...e){if(!t)return"";for(const a of e){const n=li(t[a]);if(n)return n}return""}function li(t){if(typeof t=="number"&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t=="string"&&t.trim()){const e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return""}function Mg(t){const e=t.command,a=t.args;if(ti(e)&&ti(a))return[...e,...a];if(ti(e))return e;if(typeof e=="string"&&e.trim()){const n=e.trim().split(/\s+/);return ti(a)?[...n,...a]:n}return ti(a)?a:[]}function Nl(t,...e){for(const a of e){const n=t[a];if(!Gs(n))continue;const r=Object.entries(n).filter(([i,l])=>i&&typeof l=="string");if(r.length>0)return r.map(([i,l])=>({key:i,value:String(l)}))}return[]}function Rg(t){return Gs(t.timeout)?{startup:li(t.timeout.startup),catalog:li(t.timeout.catalog),execution:li(t.timeout.execution)}:{startup:"",catalog:"",execution:li(t.timeout)}}function Fg(t){return t.disabled===!0?!0:t.disabled===!1?!1:"enabled"in t?!t.enabled:!1}function Og(t){const e=t.mcpServers;if(Gs(e)){const n=Object.keys(e);if(n.length===1){const r=n[0],i=e[r];if(Gs(i))return{name:r,entry:i}}if(n.length>1)return null}const a=Object.keys(t).filter(n=>{const r=t[n];return n!=="mcpServers"&&Gs(r)});if(a.length===1){const n=a[0],r=t[n];if(Xc(r))return{name:n,entry:r}}return null}function Xc(t){return t.type==="local"||t.type==="remote"||Array.isArray(t.command)||typeof t.url=="string"||Array.isArray(t.args)}function Lg(t,e){let a;try{const c=t.trim();if(!c)return yn("No JSON content provided");a=JSON.parse(c)}catch(c){return yn(c instanceof Error?`Invalid JSON: ${c.message}`:"Invalid JSON")}if(!Gs(a))return yn("Expected a JSON object, not an array or primitive");const n=a,r=n.mcpServers;if(Gs(r)){const c=Object.keys(r);if(c.length===0)return yn("mcpServers object is empty",a);if(c.length>1)return yn("Paste one server at a time. Found "+c.length+" servers in mcpServers",a);const h=c[0],g=r[h];return Gs(g)?Ri(h,Fi(g),g):yn("Server entry is not a valid object",a)}const i=n.mcp,l=Gs(i)&&Gs(i.servers)?i.servers:i;if(Gs(l)){const c=Object.keys(l);if(c.length===0)return yn("mcp object is empty",a);if(c.length>1)return yn("Paste one server at a time. Found "+c.length+" servers in mcp",a);const h=c[0],g=l[h];return Gs(g)?Ri(h,Fi(g),g):yn("Server entry in mcp is not a valid object",a)}const d=Og(n);if(d)return Ri(d.name,Fi(d.entry),d.entry);if(Xc(n)){const c=Fi(n),h=typeof n.name=="string"&&n.name.trim()?n.name.trim():e?.fallbackName;return Ri(h,c,n)}return yn("No recognizable MCP server configuration found in JSON",a)}function Fi(t){return t.type==="remote"?"remote":t.type==="local"?"local":typeof t.url=="string"&&t.url.trim()?"remote":(Array.isArray(t.command)||typeof t.command=="string"||Array.isArray(t.args),"local")}function Kg(t,e,a){const n=a?.isNewServer??!1,r=t.name,i=n&&r?r:e.name??"";return{...e,name:i,type:t.type,command:t.type==="local"?t.command:[],url:t.type==="remote"?t.url:"",environment:t.environment,headers:t.type==="remote"?t.headers:[],oauthEnabled:t.type==="remote"?t.oauthEnabled:!1,oauthClientId:t.type==="remote"?t.oauthClientId:"",oauthClientSecret:t.type==="remote"?t.oauthClientSecret:"",oauthScope:t.type==="remote"?t.oauthScope:"",oauthRedirectUri:t.type==="remote"?t.oauthRedirectUri:"",oauthCallbackPort:t.type==="remote"?t.oauthCallbackPort:"",oauthAuthServerMetadataUrl:t.type==="remote"?t.oauthAuthServerMetadataUrl:"",timeoutStartup:t.type==="local"?t.timeoutStartup:"",timeoutCatalog:t.timeoutCatalog,timeoutExecution:t.timeoutExecution,codemode:t.codemode,disabled:t.disabled,protocol:t.protocol}}const zg=(t,e)=>!!e&&t!=="claude-code",Ug=/[A-Z0-9]{4}-[A-Z0-9]{4,5}/,_g=t=>Ug.exec(t)?.[0]??void 0,bi=t=>t.type!=="external",Oi=t=>t.title??t.key,$g=(t,e)=>{if(e===void 0)return!1;const a=String(e),n=String(t.value);return t.op==="eq"?a===n:a!==n},Bg=(t,e)=>bi(t)?(t.when??[]).every(a=>$g(a,e[a.key])):!0,Eo=(t,e)=>{const a={},n=[];for(const r of t){if(!Bg(r,a))continue;n.push(r);const i=e[r.key];bi(r)&&i!==void 0&&(a[r.key]=i)}return n},Vg=t=>{const e={};for(const a of t)switch(a.type){case"external":break;case"boolean":e[a.key]=a.default??!1;break;case"number":case"integer":typeof a.default=="number"&&(e[a.key]=a.default);break;case"multiselect":e[a.key]=a.default??[];break;case"string":e[a.key]=a.default??a.options?.[0]?.value??"";break}return e},ed=t=>t===void 0?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:!1,Hg=(t,e)=>Eo(t,e).find(a=>bi(a)&&a.required===!0&&ed(e[a.key]))??null,qg=(t,e)=>{const a={};for(const n of Eo(t,e)){if(!bi(n))continue;const r=e[n.key];ed(r)||r===void 0||(a[n.key]=typeof r=="string"?r.trim():r)}return a},Sl=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Cl=t=>typeof t=="string"&&t.length>0?t:void 0,Gg=(t,e,a)=>{const n=Sl(t)?t:{},r=Sl(n.data)?n.data:{};switch(n.name){case"IntegrationOauthAttemptMissing":return e("settings.providers.page.auth.oauth.error.sessionExpired");case"IntegrationOauthCodeMissing":return e("settings.providers.page.auth.oauth.error.codeRequired");case"IntegrationOauthFailed":return e("settings.providers.page.auth.oauth.error.declined");case"IntegrationValidationFailed":return Cl(r.message)??e("settings.providers.page.auth.oauth.error.invalidInput");default:return Cl(n.message)??e(a)}},Or={phase:"idle"},Wg=1500,oo=({integrationId:t,methods:e,onConnected:a,directory:n,className:r})=>{const{t:i}=Qe(),l=o.useCallback(()=>n?Ms.getScopedSdkClient(n):Ms.getSdkClient(),[n]),[d,c]=o.useState(Or),[h,g]=o.useState({}),[f,m]=o.useState(""),u=o.useRef(null),v=o.useCallback(D=>{u.current=null,l().integration.oauth.cancel({integrationID:t,attemptID:D}).catch(()=>{})},[t,l]);o.useEffect(()=>()=>{const D=u.current;D&&v(D)},[v]);const w=d.phase==="idle"?null:d.methodID,b=d.phase==="connecting"||d.phase==="waiting"||d.phase==="awaitingCode"&&d.submitting,k=async(D,F,O)=>{const C=await _a(D);if(C.ok){$.success(i(F));return}console.error("Failed to copy OAuth value:",C.error),$.error(i(O))},p=async()=>{u.current=null,c(Or),$.success(i("settings.providers.page.toast.oauthCompleted")),await a()},S=(D,F,O)=>{u.current=null,console.error("OAuth flow failed:",F),c({phase:"failed",methodID:D,message:Gg(F,i,O)})},N=async(D,F)=>{const O=l();for(;u.current===F;){if(await new Promise(C=>setTimeout(C,Wg)),u.current!==F)return;try{const{data:C}=await O.integration.oauth.status({integrationID:t,attemptID:F});if(u.current!==F)return;if(C.status==="complete"){await p();return}if(C.status==="failed"){c({phase:"failed",methodID:D,message:C.message}),u.current=null;return}}catch(C){if(u.current!==F)return;S(D,C,"settings.providers.page.toast.oauthCompleteFailed");return}}},I=async(D,F)=>{c({phase:"connecting",methodID:D.id});let O;try{const{data:C}=await l().integration.oauth.connect({integrationID:t,methodID:D.id,...Object.keys(F).length>0?{answer:F}:{}});O={attemptID:C.attemptID,mode:C.mode,url:C.url,instructions:C.instructions}}catch(C){S(D.id,C,"settings.providers.page.toast.oauthStartFailed");return}if(u.current=O.attemptID,zg(t,O.url)&&jn(O.url),O.mode==="code"){m(""),c({phase:"awaitingCode",methodID:D.id,attempt:O,submitting:!1});return}c({phase:"waiting",methodID:D.id,attempt:O}),await N(D.id,O.attemptID)},y=D=>{const F=(D.form??[]).filter(bi);if(F.length===0){I(D,{});return}g(Vg(F)),c({phase:"prompting",methodID:D.id,fields:F,error:null})},T=D=>{if(d.phase!=="prompting")return;const F=Hg(d.fields,h);if(F){c({...d,error:i("settings.providers.page.auth.oauth.promptRequired",{field:Oi(F)})});return}I(D,qg(d.fields,h))},x=async()=>{if(d.phase!=="awaitingCode")return;const D=f.trim();if(!D)return;const{methodID:F,attempt:O}=d;c({...d,submitting:!0});try{await l().integration.oauth.complete({integrationID:t,attemptID:O.attemptID,code:D}),await p()}catch(C){S(F,C,"settings.providers.page.toast.oauthCompleteFailed")}},A=()=>{(d.phase==="waiting"||d.phase==="awaitingCode")&&v(d.attempt.attemptID),c(Or)},R=D=>{if(D.type==="external")return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:Oi(D)}),s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{jn(D.url)},children:i("settings.providers.page.actions.open")})]},D.key);const F=h[D.key],O=typeof F=="string"?F:"",C=U=>g(L=>({...L,[D.key]:U})),M=D.type==="string"||D.type==="multiselect"?D.options??[]:[];return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:Oi(D)}),D.description&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:D.description}),M.length>0?s.jsxs(Et,{value:O,onValueChange:C,children:[s.jsx(At,{size:Bt,className:nn,children:s.jsx($t,{children:U=>M.find(L=>L.value===U)?.label??null})}),s.jsx(Tt,{children:M.map(U=>s.jsx(ut,{value:U.value,children:U.description?`${U.label} · ${U.description}`:U.label},U.value))})]}):D.type==="boolean"?s.jsx("input",{type:"checkbox",checked:F===!0,onChange:U=>C(U.target.checked),"aria-label":Oi(D)}):s.jsx(He,{value:O,onChange:U=>C(U.target.value),placeholder:D.type==="string"?D.placeholder:void 0,className:"max-w-[24rem] text-xs"})]},D.key)},P=D=>{const F=_g(D.instructions);return s.jsxs(s.Fragment,{children:[D.instructions&&s.jsx("p",{className:"typography-meta text-[var(--status-info-text)] bg-[var(--status-info-background)] px-2 py-1.5 rounded",children:D.instructions}),F&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(He,{value:F,readOnly:!0,"aria-label":i("settings.providers.page.auth.oauth.deviceCodeLabel"),className:"font-mono text-center tracking-widest"}),s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>{k(F,"settings.providers.page.toast.deviceCodeCopied","settings.providers.page.toast.deviceCodeCopyFailed")},children:i("settings.providers.page.actions.copyCode")})]}),D.url&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(He,{value:D.url,readOnly:!0,"aria-label":i("settings.providers.page.auth.oauth.linkLabel"),className:"text-xs text-muted-foreground"}),s.jsxs("div",{className:"flex gap-1 shrink-0",children:[s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{jn(D.url)},children:i("settings.providers.page.actions.open")}),s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{k(D.url,"settings.providers.page.toast.oauthLinkCopied","settings.providers.page.toast.oauthLinkCopyFailed")},children:i("settings.providers.page.actions.copy")})]})]})]})};return s.jsx("div",{className:Pe("space-y-4",r),children:e.map(D=>{const F=w===D.id;return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:D.label}),s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>y(D),disabled:b,children:i("settings.providers.page.actions.connect")})]}),F&&d.phase==="prompting"&&s.jsxs("div",{className:"space-y-3",children:[Eo(d.fields,h).map(R),d.error&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:d.error}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G,{size:"xs",className:"!font-normal",onClick:()=>T(D),children:i("settings.providers.page.actions.continue")}),s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:A,children:i("settings.providers.page.actions.cancel")})]})]}),F&&d.phase==="connecting"&&s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx(_,{name:"loader",className:"h-3.5 w-3.5 animate-spin"}),i("settings.providers.page.auth.oauth.starting")]}),F&&d.phase==="waiting"&&s.jsxs("div",{className:"space-y-3",children:[P(d.attempt),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx(_,{name:"loader",className:"h-3.5 w-3.5 animate-spin"}),i("settings.providers.page.auth.oauth.waiting")]}),s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:A,children:i("settings.providers.page.actions.cancel")})]}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("settings.providers.page.auth.oauth.waitingHint")})]}),F&&d.phase==="awaitingCode"&&s.jsxs("div",{className:"space-y-3",children:[P(d.attempt),s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("settings.providers.page.auth.oauth.codeHint")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(He,{value:f,onChange:O=>m(O.target.value),placeholder:i("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs",disabled:d.submitting}),s.jsx(G,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{x()},disabled:d.submitting||f.trim().length===0,children:d.submitting?i("settings.providers.page.actions.saving"):i("settings.providers.page.actions.complete")}),s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:A,disabled:d.submitting,children:i("settings.providers.page.actions.cancel")})]})]}),F&&d.phase==="failed"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:d.message}),s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>y(D),children:i("settings.providers.page.actions.tryAgain")})]})]},D.id)})})},Jg=(t,e)=>t.find(a=>a.id.startsWith("mcp_")&&a.metadata?.source==="mcp"&&a.name===e),Qg=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),Yg=({serverName:t,directory:e,onConnected:a})=>{const[n,r]=o.useState(null);o.useEffect(()=>{let l=!1;r(null);const d=e?Ms.getScopedSdkClient(e):Ms.getSdkClient();return(async()=>{try{const{data:h}=await d.integration.list();l||r(Jg(h,t)??null)}catch(h){console.error("Failed to load MCP integrations:",h)}})(),()=>{l=!0}},[e,t]);const i=Qg(n??void 0);return!n||i.length===0?null:s.jsx(oo,{integrationId:n.id,methods:i,directory:e,onConnected:a},n.id)},Lr=t=>t===void 0?"":String(t),Kr=t=>{const e=t.trim();if(!e)return null;const a=Number(e);return!Number.isFinite(a)||a<=0?null:a%1e3===0?`${a/1e3}s`:`${a}ms`},zr={legacy:"settings.mcp.page.advanced.protocolOption.legacy",auto:"settings.mcp.page.advanced.protocolOption.auto","2026-07-28":"settings.mcp.page.advanced.protocolOption.revision20260728"},Il={default:"settings.mcp.page.advanced.codemodeOption.default",on:"settings.mcp.page.advanced.codemodeOption.on",off:"settings.mcp.page.advanced.codemodeOption.off"},Zg=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},ni=t=>t?.status.status,Ur=t=>t?.status.status==="failed"||t?.status.status==="needs_auth"?t.status.error:void 0;function td(t){const e=[];let a="",n=!1,r=!1;for(let i=0;i<t.length;i++){const l=t[i];if(l==="'"&&!r){n=!n;continue}if(l==='"'&&!n){r=!r;continue}if((l===" "||l===" ")&&!n&&!r){a&&(e.push(a),a="");continue}a+=l}return a&&e.push(a),e}const Xg=t=>{const e=tt.c(27),{value:a,onChange:n,preview:r,onDetectUrl:i}=t;let l;e[0]!==a?(l=()=>a.join(`
5
+ `),e[0]=a,e[1]=l):l=e[1];const[d,c]=o.useState(l),h=o.useRef(a);let g,f;e[2]!==a?(g=()=>{JSON.stringify(h.current)!==JSON.stringify(a)&&(h.current=a,c(a.join(`
6
+ `)))},f=[a],e[2]=a,e[3]=g,e[4]=f):(g=e[3],f=e[4]),o.useEffect(g,f);let m;e[5]!==n||e[6]!==i?(m=y=>{const T=y.split(`
7
+ `).filter(rh);if(i&&T.length===1&&/^https?:\/\/\S+$/i.test(T[0].trim())){i(T[0].trim());return}n(T)},e[5]=n,e[6]=i,e[7]=m):m=e[7];const u=m;let v;e[8]!==n?(v=y=>{const x=y.clipboardData.getData("text").trim();if(!x||x.includes(`
8
+ `)||!/\s/.test(x))return;const A=y.currentTarget;if(A.selectionStart!==0||A.selectionEnd!==A.value.length)return;y.preventDefault();const R=td(x);c(R.join(`
9
+ `)),n(R)},e[8]=n,e[9]=v):v=e[9];const w=v;let b;e[10]!==u?(b=y=>{c(y.target.value),u(y.target.value)},e[10]=u,e[11]=b):b=e[11];let k;e[12]!==u||e[13]!==d?(k=()=>{const y=d.split(`
10
+ `).map(oh).join(`
11
+ `);c(y),u(y)},e[12]=u,e[13]=d,e[14]=k):k=e[14];const p=Math.max(4,a.length+1);let S;e[15]!==w||e[16]!==b||e[17]!==k||e[18]!==p||e[19]!==d?(S=s.jsx(As,{onPaste:w,value:d,onChange:b,onBlur:k,placeholder:`npx
12
+ -y
13
+ @modelcontextprotocol/server-postgres
14
+ postgresql://user:pass@host/db`,rows:p,className:"font-mono typography-meta min-h-[80px]",spellCheck:!1}),e[15]=w,e[16]=b,e[17]=k,e[18]=p,e[19]=d,e[20]=S):S=e[20];let N;e[21]!==r||e[22]!==a?(N=a.length>0&&s.jsxs("details",{className:"group",children:[s.jsx("summary",{className:"typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground",children:r(a.length)}),s.jsx("div",{className:"mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto",children:s.jsx("code",{className:"typography-micro text-foreground/80 whitespace-pre",children:a.map(lh)})})]}),e[21]=r,e[22]=a,e[23]=N):N=e[23];let I;return e[24]!==N||e[25]!==S?(I=s.jsxs("div",{className:"space-y-2","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",children:[S,N]}),e[24]=N,e[25]=S,e[26]=I):I=e[26],I},eh=t=>t.toUpperCase().replace(/[^A-Z0-9_]/g,"_"),Pl=({value:t,onChange:e,onCommit:a,keyTransform:n=eh,keyPlaceholder:r="API_KEY",keyInputClassName:i="w-36 shrink-0 font-mono typography-meta uppercase",pasteLabel:l="Paste .env",pasteTitle:d="Paste KEY=VALUE lines from clipboard",noPairsFoundError:c,importSuccess:h,clipboardReadFailed:g,keyLabel:f,valueLabel:m,valuePlaceholder:u,hideValueTitle:v,showValueTitle:w,addVariable:b,plainTextWarning:k,removeVariableAria:p})=>{const[S,N]=o.useState(new Set),I=()=>e([...t,{key:"",value:""}]),y=P=>{e(t.filter((D,F)=>F!==P)),a?.(),N(D=>{const F=new Set(D);return F.delete(P),F})},T=(P,D,F)=>{const O=[...t];O[P]={...O[P],[D]:F},e(O)},x=P=>{N(D=>{const F=new Set(D);return F.has(P)?F.delete(P):F.add(P),F})},A=async()=>{try{const P=await navigator.clipboard.readText(),D=[];for(const O of P.split(`
15
+ `)){const C=O.trim();if(!C||C.startsWith("#"))continue;const M=C.indexOf("=");if(M===-1)continue;const U=C.slice(0,M).trim();let L=C.slice(M+1).trim();(L.startsWith('"')&&L.endsWith('"')||L.startsWith("'")&&L.endsWith("'"))&&(L=L.slice(1,-1)),U&&D.push({key:U,value:L})}if(D.length===0){$.error(c);return}const F=[...t];for(const O of D){const C=F.findIndex(M=>M.key===O.key);C!==-1?F[C]=O:F.push(O)}e(F),a?.(),$.success(h(D.length))}catch{$.error(g)}},R=t.some(P=>P.value.length>0);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"typography-micro text-muted-foreground w-32 shrink-0",children:f}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:m})]}),s.jsxs(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:A,type:"button",title:d,children:[s.jsx(_,{name:"clipboard",className:"h-3 w-3"}),l]})]}),s.jsx("div",{className:"space-y-1.5",children:t.map((P,D)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(He,{value:P.key,onChange:F=>T(D,"key",n(F.target.value)),placeholder:r,className:i,"data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),s.jsxs("div",{className:"relative flex-1 flex items-center",children:[s.jsx(He,{type:S.has(D)?"text":"password",value:P.value,onChange:F=>T(D,"value",F.target.value),placeholder:u,className:"font-mono typography-meta pr-8 w-full",autoComplete:"new-password","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),s.jsx("button",{type:"button",onClick:()=>x(D),className:"absolute right-2 text-muted-foreground/60 hover:text-muted-foreground",title:S.has(D)?v:w,children:S.has(D)?s.jsx(_,{name:"eye-off",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"eye",className:"h-3.5 w-3.5"})})]}),s.jsx(G,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>y(D),"aria-label":p,children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},D))}),s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:I,type:"button",children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),b]}),R&&s.jsx("p",{className:"typography-micro text-muted-foreground/60",children:k})]})},Al=t=>{const e=tt.c(14),{status:a,enabled:n,getStatusLabel:r,variant:i}=t,l=i===void 0?"compact":i;if(!n||!a)return null;let d,c;if(e[0]!==r||e[1]!==a||e[2]!==l){c=Symbol.for("react.early_return_sentinel");e:{const m={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"}}[a]??{text:"text-muted-foreground",bg:""};if(l==="pill"){const u=Pe("typography-micro font-medium rounded-full px-2 py-0.5",m.text,m.bg);let v;e[5]!==r||e[6]!==a?(v=r(a),e[5]=r,e[6]=a,e[7]=v):v=e[7],c=s.jsxs("span",{className:u,children:["● ",v]});break e}d=Pe("typography-micro font-medium",m.text)}e[0]=r,e[1]=a,e[2]=l,e[3]=d,e[4]=c}else d=e[3],c=e[4];if(c!==Symbol.for("react.early_return_sentinel"))return c;let h;e[8]!==r||e[9]!==a?(h=r(a),e[8]=r,e[9]=a,e[10]=h):h=e[10];let g;return e[11]!==d||e[12]!==h?(g=s.jsxs("span",{className:d,children:["● ",h]}),e[11]=d,e[12]=h,e[13]=g):g=e[13],g},th=(t,e,a)=>{switch(t){case"connected":return e("settings.mcp.page.status.description.connected");case"failed":return a?.trim()||e("settings.mcp.page.status.description.failedDefault");case"needs_auth":return a?.trim()||e("settings.mcp.page.status.description.needsAuth");case"disabled":return e("settings.mcp.page.status.description.disabled");default:return e("settings.mcp.page.status.description.default")}},sh=t=>{switch(t){case"failed":return"border-[var(--status-error-border)] bg-[var(--status-error-background)]";case"needs_auth":return"border-[var(--status-warning-border)] bg-[var(--status-warning-background)]";default:return"border-[var(--interactive-border)] bg-[var(--surface-elevated)]"}},nh=t=>t==="failed"||t==="needs_auth",ah=(t,e)=>{const a=typeof e=="string"&&e.trim()?e.trim():"__global__";return`${t??"__none__"}::${a}`},ih=()=>{const{t}=Qe(),e=o.useCallback((te,xe)=>t(te,xe),[t]),{selectedMcpName:a,mcpDraft:n,setMcpDraft:r,setSelectedMcp:i,getMcpByName:l,createMcp:d,updateMcp:c,deleteMcp:h}=Yn(Bs(te=>({selectedMcpName:te.selectedMcpName,mcpDraft:te.mcpDraft,setMcpDraft:te.setMcpDraft,setSelectedMcp:te.setSelectedMcp,getMcpByName:te.getMcpByName,createMcp:te.createMcp,updateMcp:te.updateMcp,deleteMcp:te.deleteMcp}))),g=rn(),f=un(te=>te.getStatusForDirectory(g)),m=un(te=>te.getDiagnosticForDirectory(g)),u=un(te=>te.refresh),v=un(te=>te.connect),w=un(te=>te.disconnect),b=un(te=>te.testConnection),k=Yn(te=>fo(te,g)),p=a?l(a,g):null,S=!!(n&&n.name===a&&!p),[N,I]=o.useState(""),[y,T]=o.useState("user"),[x,A]=o.useState("local"),[R,P]=o.useState([]),[D,F]=o.useState(""),[O,C]=o.useState([]),[M,U]=o.useState([]),[L,W]=o.useState(""),[X,J]=o.useState(""),[q,z]=o.useState(""),[H,se]=o.useState("default"),[B,ne]=o.useState("legacy"),[K,Z]=o.useState(""),[oe,ue]=o.useState(Zi),[de,ce]=o.useState(!0),[Se,re]=o.useState(!1),[ve,ie]=o.useState(!1),[me,ke]=o.useState(!1),[Ae,pe]=o.useState(!1),[Le,Ve]=o.useState(!1),[ye,Te]=o.useState(!1),[ee,ae]=o.useState(!1),[fe,je]=o.useState(""),[Re,Ce]=o.useState(null),_e=o.useMemo(()=>ah(a,g),[g,a]),Ke=o.useRef(_e),Fe=o.useRef(null),Me=JSON.stringify([a,g,S]),at=o.useRef(Me);at.current=Me;const pt=o.useRef(null),ot={mcpType:x,command:R,url:D,envEntries:O,headerEntries:M,timeoutStartup:L,timeoutCatalog:X,timeoutExecution:q,codemode:H,protocol:B,oauthAuthServerMetadataUrl:x==="remote"?K:"",enabled:de},mt=o.useRef(ot);mt.current=ot;const ht=o.useCallback(()=>{je(""),Ce(null),ae(!0)},[]),Oe=o.useCallback(async()=>{try{const te=await navigator.clipboard.readText();je(te),Ce(null)}catch{$.error(t("settings.mcp.page.toast.clipboardReadFailed"))}},[t]),nt=o.useCallback(()=>{const te=Lg(fe,{fallbackName:N});if(!te.ok){Ce(te.error);return}const Ze=Kg(te,{name:N,scope:y,type:x,command:R,url:D,environment:O,headers:M,timeoutStartup:L,timeoutCatalog:X,timeoutExecution:q,codemode:H,disabled:!de,protocol:B,oauthAuthServerMetadataUrl:K},{isNewServer:S});I(Ze.name),A(Ze.type),P(Ze.command??[]),F(Ze.url??""),C(Ze.environment??[]),U(Ze.headers??[]),W(Ze.timeoutStartup??""),J(Ze.timeoutCatalog??""),z(Ze.timeoutExecution??""),se(Ze.codemode??"default"),ce(Ze.disabled!==!0),ne(Ze.protocol??"legacy"),Z(Ze.oauthAuthServerMetadataUrl??""),ae(!1),je(""),Ce(null),$.success(t("settings.mcp.page.toast.configImported"))},[fe,N,y,x,R,D,O,M,B,K,L,X,q,H,de,S,t]);o.useEffect(()=>{if(S&&n){pt.current=null,I(n.name),T(n.scope||"user"),A(n.type),P(n.command),F(n.url),C(n.environment),U(n.headers),W(n.timeoutStartup),J(n.timeoutCatalog),z(n.timeoutExecution),se(n.codemode),ne(n.protocol),Z(n.oauthAuthServerMetadataUrl),ue({oauthEnabled:n.oauthEnabled,oauthClientId:n.oauthClientId,oauthClientSecret:n.oauthClientSecret,oauthScope:n.oauthScope,oauthRedirectUri:n.oauthRedirectUri,oauthCallbackPort:n.oauthCallbackPort}),ce(!n.disabled),Te(!1),Fe.current={mcpType:n.type,command:n.command,url:n.url,envEntries:n.environment,headerEntries:n.headers,timeoutStartup:n.timeoutStartup,timeoutCatalog:n.timeoutCatalog,timeoutExecution:n.timeoutExecution,codemode:n.codemode,protocol:n.protocol,oauthAuthServerMetadataUrl:n.oauthAuthServerMetadataUrl,enabled:!n.disabled};return}if(p){T(p.scope==="project"?"project":"user");const te=Bo(p.environment),xe=p.type==="remote"?p:null,Ze=Bo(xe?.headers),Nt=p.type,Lt=Nt==="local"?p.command??[]:[],Ie=xe?.url??"",Be=Lr(p.timeout?.startup),wt=Lr(p.timeout?.catalog),Pt=Lr(p.timeout?.execution),Qt=qd(p.codemode),Xt=p.protocol??"legacy",ss=Ng(xe?.oauth),es=xe&&xe.oauth?xe.oauth.auth_server_metadata_url??"":"",Ls=p.disabled!==!0;ue(ss);const Js=Fe.current!==null&&JSON.stringify(Fe.current)!==JSON.stringify(mt.current);if(pt.current===Me&&Js)return;pt.current=Me,A(Nt),P(Lt),F(Ie),C(te),U(Ze),W(Be),J(wt),z(Pt),se(Qt),ne(Xt),Z(es),ce(Ls),Te(!1),Fe.current={mcpType:Nt,command:Lt,url:Ie,envEntries:te,headerEntries:Ze,timeoutStartup:Be,timeoutCatalog:wt,timeoutExecution:Pt,codemode:Qt,protocol:Xt,oauthAuthServerMetadataUrl:es,enabled:Ls}}},[p,a,g,S,n,Me]);const lt=o.useMemo(()=>{const te=K.trim();return!te||Zg(te)?null:t("settings.mcp.page.advanced.oauthMetadataUrlInvalid")},[K,t]),we=o.useMemo(()=>{const te=[];x==="remote"&&M.length>0&&te.push(`${M.length} ${t("settings.mcp.page.advanced.headers")}`);const xe=x==="local"?Kr(L):null;xe&&te.push(t("settings.mcp.page.advanced.summary.startup",{value:xe}));const Ze=Kr(X);Ze&&te.push(t("settings.mcp.page.advanced.summary.catalog",{value:Ze}));const Nt=Kr(q);return Nt&&te.push(t("settings.mcp.page.advanced.summary.execution",{value:Nt})),H==="on"&&te.push(t("settings.mcp.page.advanced.summary.codemodeOn")),H==="off"&&te.push(t("settings.mcp.page.advanced.summary.codemodeOff")),B!=="legacy"&&te.push(t(zr[B])),te.join(" · ")},[H,M.length,x,B,t,X,q,L]),Je=o.useMemo(()=>[{id:"local",label:t("settings.mcp.page.connection.kindCommand"),icon:s.jsx(_,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"remote",label:t("settings.mcp.page.connection.kindLink"),icon:s.jsx(_,{name:"global",className:"h-3.5 w-3.5"})}],[t]),Ye=o.useCallback(te=>{A("remote"),F(te),P([])},[]),ze=o.useCallback(te=>{F(te);const xe=te.trim();xe&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(xe)&&/\s/.test(xe)&&(A("local"),P(td(xe)),F(""))},[]),Ge=te=>({name:te,scope:y,type:x,command:R,url:D,environment:O,headers:M,...oe,oauthAuthServerMetadataUrl:x==="remote"?K:"",protocol:B,timeoutStartup:L,timeoutCatalog:X,timeoutExecution:q,codemode:H,disabled:!de}),Ue=Ya(async()=>{const te=Fe.current;if(S||!te||!a||JSON.stringify(te)===JSON.stringify({mcpType:x,command:R,url:D,envEntries:O,headerEntries:M,timeoutStartup:L,timeoutCatalog:X,timeoutExecution:q,codemode:H,protocol:B,oauthAuthServerMetadataUrl:x==="remote"?K:"",enabled:de}))return Os;if(x==="local"&&R.filter(Boolean).length===0)return ms(t("settings.mcp.page.toast.localCommandRequired"));if(x==="remote"&&!D.trim())return ms(t("settings.mcp.page.toast.remoteUrlRequired"));if(x==="remote"&&lt)return ms(lt);const xe=await c(a,Ge(a),g);return xe.ok?at.current!==Me?Tn:(Fe.current={mcpType:x,command:R,url:D,envEntries:O,headerEntries:M,timeoutStartup:L,timeoutCatalog:X,timeoutExecution:q,codemode:H,protocol:B,oauthAuthServerMetadataUrl:x==="remote"?K:"",enabled:de},await u({directory:g,silent:!0}),xe.reloadFailed?ms(xe.warning||xe.message||t("settings.mcp.page.toast.savedReloadFailed")):Tn):ms(t("settings.mcp.page.toast.saveFailed"))}),{requestSave:st}=Ue,dt=async()=>{const te=N.trim();if(!te){$.error(t("settings.mcp.page.toast.nameRequired"));return}if(k.some(xe=>xe.name===te)){$.error(t("settings.mcp.page.toast.serverNameExists"));return}if(x==="local"&&R.filter(Boolean).length===0){$.error(t("settings.mcp.page.toast.localCommandRequired"));return}if(x==="remote"&&!D.trim()){$.error(t("settings.mcp.page.toast.remoteUrlRequired"));return}if(x==="remote"&&lt){$.error(lt);return}re(!0);try{const xe=await d(Ge(te),g);xe.ok?(r(null),i(te),await u({directory:g,silent:!0}),xe.reloadFailed?$.warning(xe.message||t("settings.mcp.page.toast.serverCreatedReloadFailed"),{description:xe.warning||t("settings.mcp.page.toast.retryRefreshHint")}):$.success(xe.message||t("settings.mcp.page.toast.serverCreatedReloading"))):$.error(t("settings.mcp.page.toast.saveFailed"))}catch(xe){$.error(xe instanceof Error?xe.message:t("settings.mcp.page.toast.unexpectedError"))}finally{re(!1)}},ct=()=>{r(null),i(null)},ft=async()=>{if(!a)return;ke(!0);const te=await h(a,g);te.ok?(te.reloadFailed?$.warning(te.message||t("settings.mcp.page.toast.serverDeletedReloadFailed",{name:a}),{description:te.warning||t("settings.mcp.page.toast.refreshListIfStale")}):$.success(te.message||t("settings.mcp.page.toast.serverDeleted",{name:a})),ie(!1)):$.error(t("settings.mcp.page.toast.deleteFailed")),ke(!1)},kt=async()=>{if(a)try{await v(a,g),$.success(t("settings.mcp.page.toast.connected"))}catch(te){$.error(te instanceof Error?te.message:t("settings.mcp.page.toast.connectionTestFailed"))}},bt=async()=>{if(a){pe(!0);try{if(ni(f[a])==="connected")await w(a,g),$.success(t("settings.mcp.page.toast.disconnected"));else{await v(a,g),await u({directory:g,silent:!0});const xe=un.getState().getStatusForDirectory(g)[a],Ze=ni(xe);Ze==="connected"?$.success(t("settings.mcp.page.toast.connected")):Ze==="needs_auth"?$.message(t("settings.mcp.page.toast.connectionNeedsAuthorization")):Ze==="failed"?$.error(Ur(xe)||t("settings.mcp.page.toast.connectionFailed")):$.message(t("settings.mcp.page.toast.connectionAttemptFinished"));return}await u({directory:g,silent:!0})}catch(te){$.error(te instanceof Error?te.message:t("settings.mcp.page.toast.connectionFailed"))}finally{pe(!1)}}},vt=o.useCallback(()=>S?($.error(t("settings.mcp.page.toast.createServerBeforeLiveActions")),!1):!0,[S,t]),Xe=o.useCallback(async(te=!1)=>{try{await u({directory:g,silent:te})}catch(xe){te||$.error(xe instanceof Error?xe.message:t("settings.mcp.page.toast.refreshStatusFailed"))}},[g,u,t]);o.useEffect(()=>{Xe(!0)},[Xe]),o.useEffect(()=>{Ke.current=_e,pe(!1),Ve(!1)},[_e]);const jt=o.useCallback(async()=>{if(!(!a||!vt())){if(!de){$.error(t("settings.mcp.page.toast.enableServerBeforeTest"));return}Ve(!0);try{const te=await b(a,g),xe=ni(te.status);te.warning?$.warning(te.warning):xe==="connected"?$.success(t("settings.mcp.page.toast.connectionTestSucceeded")):xe==="needs_auth"?$.message(t("settings.mcp.page.toast.connectionNeedsAuthorization")):xe==="failed"?$.error(Ur(te.status)||te.error||t("settings.mcp.page.toast.connectionTestFailed")):te.error?$.error(te.error):$.message(t("settings.mcp.page.toast.connectionTestFinished"))}catch(te){$.error(te instanceof Error?te.message:t("settings.mcp.page.toast.connectionTestFailed"))}finally{Ve(!1)}}},[g,de,vt,a,t,b]);if(!a)return s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(_,{name:"plug",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.mcp.page.empty.selectServer")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.mcp.page.empty.addNewOne")})]})});const De=f[a],$e=a?m[a]:void 0,Y=De?ni(De):$e?.status,V=De?Ur(De):$e?.error,be=ni(De)==="connected",ge=th(Y,e,V),Ee=te=>{switch(te){case"connected":return t("settings.mcp.page.status.label.connected");case"failed":return t("settings.mcp.page.status.label.failed");case"needs_auth":return t("settings.mcp.page.status.label.needsAuth");default:return te}};return s.jsxs(s.Fragment,{children:[s.jsxs(ts,{title:S?t("settings.mcp.page.header.newServer"):a,titleAccessory:S?void 0:s.jsx(Al,{status:Y,enabled:de,getStatusLabel:Ee,variant:"pill"}),description:S?t("settings.mcp.page.header.configureNewServer"):t("settings.mcp.page.header.transport",{type:t(x==="local"?"settings.mcp.page.transport.local":"settings.mcp.page.transport.remote")}),headerEnd:S?void 0:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(G,{variant:be?"outline":"default",size:"xs",className:"!font-normal",onClick:bt,disabled:Ae||!de,children:t(Ae?"settings.mcp.page.actions.working":be?"settings.mcp.page.actions.disconnect":"settings.mcp.page.actions.connect")}),be&&s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{jt()},disabled:Le||!de,children:t(Le?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.test")})]}),onBlurCapture:Ue.onBlurCapture,children:[!S&&p&&s.jsx(To,{legacy:p.legacy===!0,path:p.path}),!S&&nh(Y)&&s.jsx(qe,{divider:!1,children:s.jsx("div",{className:Pe("rounded-lg border p-3",sh(Y)),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.status.runtimeStatus")}),s.jsx(Al,{status:Y,enabled:de,getStatusLabel:Ee})]}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:ge}),s.jsx("p",{className:"typography-micro text-muted-foreground/80",children:y==="project"?t("settings.mcp.page.status.projectScopedTo",{directory:g??t("settings.mcp.page.status.activeProject")}):t("settings.mcp.page.status.userScoped")})]}),Y==="needs_auth"&&a&&s.jsx(Yg,{serverName:a,directory:g,onConnected:kt}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:!be&&s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{jt()},disabled:Le||!de,children:t(Le?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.testConnection")})})]})})}),s.jsxs(qe,{title:t("settings.mcp.page.server.title"),divider:!1,settingsItem:"mcp.server",contentClassName:"space-y-0",titleAccessory:S?s.jsxs(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1.5 text-muted-foreground",onClick:ht,type:"button",title:t("settings.mcp.page.server.importJsonTitle"),children:[s.jsx(_,{name:"file-code",className:"h-3.5 w-3.5"}),t("settings.mcp.page.server.importJson")]}):null,children:[S&&s.jsxs(It,{label:t("settings.mcp.page.server.name"),controlClassName:"flex-wrap @xl:w-auto @xl:flex-1",children:[s.jsx(He,{value:N,onChange:te=>I(te.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"-")),placeholder:t("settings.mcp.page.server.namePlaceholder"),className:"h-7 w-48 min-w-0 max-w-full shrink font-mono px-2",autoFocus:!0}),s.jsxs(Et,{value:y,onValueChange:te=>T(te),children:[s.jsxs(At,{size:Bt,className:"!h-7 min-w-0 max-w-full gap-1.5 px-2",children:[s.jsx(_,{name:y==="user"?"user-3":"folder",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:t(y==="user"?"settings.mcp.page.scope.everywhere":"settings.mcp.page.scope.thisProject")})]}),s.jsxs(Tt,{align:"end",children:[s.jsx(ut,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.mcp.page.scope.everywhere")})]})}),s.jsx(ut,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.mcp.page.scope.thisProject")})]})})]})]})]}),s.jsx(gt,{checked:de,onChange:te=>{ce(te),st()},label:t("settings.mcp.page.server.enable"),ariaLabel:t("settings.mcp.page.server.enableAria")})]}),s.jsxs(qe,{title:t("settings.mcp.page.connection.title"),description:t("settings.mcp.page.connection.description"),settingsItem:"mcp.command",contentClassName:"space-y-2",children:[s.jsx(Io,{items:Je,activeId:x,onSelect:te=>{A(te),st()},layoutMode:"fit",variant:"active-pill",activePillLowercase:!1,className:"h-10"}),x==="local"?s.jsx(Xg,{value:R,onChange:P,preview:te=>t("settings.mcp.page.connection.previewArgs",{count:te}),onDetectUrl:Ye}):s.jsx(He,{value:D,onChange:te=>ze(te.target.value),placeholder:t("settings.mcp.page.connection.serverUrlPlaceholder"),className:"font-mono typography-meta"}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t(x==="local"?"settings.mcp.page.connection.hintCommand":"settings.mcp.page.connection.hintLink")})]}),s.jsx(qe,{title:t("settings.mcp.page.advanced.title"),settingsItem:"mcp.advanced",children:s.jsxs(Cn,{open:ye,onOpenChange:Te,children:[s.jsxs(In,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:t("settings.mcp.page.advanced.configure")}),we&&s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",we,")"]})]}),ye?s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx(_,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(Pn,{className:"pt-2",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.protocol")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.protocolHint")})]}),s.jsxs(Et,{value:B,onValueChange:te=>{const xe=eo.find(Ze=>Ze===te);xe&&(ne(xe),st())},children:[s.jsx(At,{size:Bt,className:"!h-7 w-full max-w-[16rem] px-2","aria-label":t("settings.mcp.page.advanced.protocol"),children:s.jsx("span",{className:"truncate",children:t(zr[B])})}),s.jsx(Tt,{children:eo.map(te=>s.jsx(ut,{value:te,children:t(zr[te])},te))})]})]}),s.jsxs("div",{className:"space-y-2",children:[x==="local"&&s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.timeoutStartupMs")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.timeoutStartupHint")})]}),s.jsx(He,{type:"number",min:"1",step:"1",value:L,onChange:te=>W(te.target.value),placeholder:"5000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.timeoutCatalogMs")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.timeoutCatalogHint")})]}),s.jsx(He,{type:"number",min:"1",step:"1",value:X,onChange:te=>J(te.target.value),placeholder:"30000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.timeoutExecutionMs")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.timeoutExecutionHint")})]}),s.jsx(He,{type:"number",min:"1",step:"1",value:q,onChange:te=>z(te.target.value),placeholder:"30000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.codemode")}),s.jsxs(Gt,{children:[t("settings.mcp.page.advanced.codemodeHint")," ",t("settings.mcp.page.advanced.codemodeDefaultHint")]})]}),s.jsxs(Et,{value:H,onValueChange:te=>{const xe=Vo.find(Ze=>Ze===te);xe&&(se(xe),st())},children:[s.jsx(At,{size:Bt,className:"!h-7 w-full max-w-[16rem] px-2","aria-label":t("settings.mcp.page.advanced.codemode"),children:s.jsx("span",{className:"truncate",children:t(Il[H])})}),s.jsx(Tt,{children:Vo.map(te=>s.jsx(ut,{value:te,children:t(Il[te])},te))})]})]}),x==="remote"&&s.jsxs("div",{children:[s.jsxs(An,{as:"div",className:"mb-2",children:[t("settings.mcp.page.advanced.requestHeaders"),M.length>0&&s.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",M.length,")"]})]}),s.jsx(Pl,{value:M,onChange:U,onCommit:st,keyTransform:te=>te.trimStart(),keyPlaceholder:t("settings.mcp.page.advanced.headerNamePlaceholder"),keyInputClassName:"w-36 shrink-0 font-mono typography-meta",pasteLabel:t("settings.mcp.page.advanced.pasteHeaders"),pasteTitle:t("settings.mcp.page.advanced.pasteHeadersTitle"),noPairsFoundError:t("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:te=>t("settings.mcp.page.toast.importedVariablesCount",{count:te}),clipboardReadFailed:t("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:t("settings.mcp.page.env.key"),valueLabel:t("settings.mcp.page.env.value"),valuePlaceholder:t("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:t("settings.mcp.page.env.hide"),showValueTitle:t("settings.mcp.page.env.show"),addVariable:t("settings.mcp.page.env.addVariable"),plainTextWarning:t("settings.mcp.page.env.plainTextWarning"),removeVariableAria:t("settings.mcp.page.env.removeVariableAria")})]}),x==="remote"&&s.jsxs("div",{children:[s.jsx(An,{as:"div",className:"mb-2",children:t("settings.mcp.page.advanced.oauth")}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.oauthMetadataUrl")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.oauthMetadataUrlHint")})]}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx(He,{type:"url",value:K,onChange:te=>Z(te.target.value),placeholder:t("settings.mcp.page.advanced.oauthMetadataUrlPlaceholder"),"aria-label":t("settings.mcp.page.advanced.oauthMetadataUrl"),"aria-invalid":lt?!0:void 0,className:"h-7 w-full max-w-[24rem] font-mono typography-meta px-2","data-bwignore":"true","data-1p-ignore":"true"}),lt&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:lt})]})]})]})]})})]})}),s.jsx(qe,{title:t("settings.mcp.page.env.title"),description:t("settings.mcp.page.env.description"),titleAccessory:O.length>0?s.jsxs("span",{className:"typography-micro text-muted-foreground font-normal",children:["(",O.length,")"]}):null,settingsItem:"mcp.environment",children:O.length===0?s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:()=>C([{key:"",value:""}]),children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),t("settings.mcp.page.env.addEnvironmentVariable")]}):s.jsx(Pl,{value:O,onChange:C,onCommit:st,keyPlaceholder:t("settings.mcp.page.env.keyPlaceholder"),pasteLabel:t("settings.mcp.page.env.pasteEnv"),pasteTitle:t("settings.mcp.page.env.pasteEnvTitle"),noPairsFoundError:t("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:te=>t("settings.mcp.page.toast.importedVariablesCount",{count:te}),clipboardReadFailed:t("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:t("settings.mcp.page.env.key"),valueLabel:t("settings.mcp.page.env.value"),valuePlaceholder:t("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:t("settings.mcp.page.env.hide"),showValueTitle:t("settings.mcp.page.env.show"),addVariable:t("settings.mcp.page.env.addVariable"),plainTextWarning:t("settings.mcp.page.env.plainTextWarning"),removeVariableAria:t("settings.mcp.page.env.removeVariableAria")})}),s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[S&&s.jsxs(s.Fragment,{children:[s.jsx(G,{onClick:()=>{dt()},disabled:Se||!N.trim(),size:"xs",className:"!font-normal",children:t(Se?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(G,{variant:"ghost",onClick:ct,disabled:Se,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]}),!S&&s.jsx(G,{variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>ie(!0),children:t("settings.common.actions.delete")})]})," "]}),s.jsx(Ut,{open:ee,onOpenChange:te=>{te||(ae(!1),je(""),Ce(null))},children:s.jsxs(_t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.mcp.page.importDialog.title")}),s.jsx(qt,{children:t("settings.mcp.page.importDialog.description")})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx(As,{value:fe,onChange:te=>{je(te.target.value),Ce(null)},placeholder:`{
16
+ "mcpServers": {
17
+ "postgres": {
18
+ "command": "npx",
19
+ "args": ["-y", "@modelcontextprotocol/server-postgres"]
20
+ }
21
+ }
22
+ }`,rows:8,className:"font-mono typography-meta",spellCheck:!1,"data-bwignore":"true","data-1p-ignore":"true"}),Re&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:Re}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:Oe,type:"button",children:[s.jsx(_,{name:"clipboard",className:"h-3.5 w-3.5"}),t("settings.mcp.page.importDialog.pasteFromClipboard")]})})]}),s.jsxs(as,{children:[s.jsx(G,{variant:"outline",onClick:()=>{ae(!1),je(""),Ce(null)},className:"text-foreground",children:t("settings.common.actions.cancel")}),s.jsx(G,{onClick:nt,disabled:!fe.trim(),size:"sm",children:t("settings.common.actions.import")})]})]})}),s.jsx(Ut,{open:ve,onOpenChange:te=>{!te&&!me&&ie(!1)},children:s.jsxs(_t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.mcp.page.deleteDialog.title",{name:a??""})}),s.jsxs(qt,{children:[t("settings.mcp.page.deleteDialog.descriptionPrefix")," ",s.jsx("code",{className:"text-foreground",children:"opencode.json"}),"."," ",t("settings.mcp.page.deleteDialog.descriptionSuffix")]})]}),s.jsxs(as,{children:[s.jsx(G,{variant:"outline",onClick:()=>ie(!1),disabled:me,className:"text-foreground",children:t("settings.common.actions.cancel")}),s.jsx(G,{variant:"destructive",size:"sm",onClick:ft,disabled:me,children:t(me?"settings.mcp.page.actions.deleting":"settings.common.actions.delete")})]})]})})]})};function rh(t){return t.trim().length>0}function oh(t){return t.trimEnd()}function lh(t,e){return s.jsxs("span",{className:"block",children:[s.jsxs("span",{className:"text-muted-foreground select-none mr-2",children:["[",e,"]"]}),t]},e)}const ch=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function dh(t){const e=t.trim();if(e==="")return{ok:!0,value:void 0};try{const a=JSON.parse(e);return a===null||typeof a!="object"||Array.isArray(a)?{ok:!1}:{ok:!0,value:a}}catch{return{ok:!1}}}const uh=({open:t,onOpenChange:e,defaultScope:a="user"})=>{const{t:n}=Qe(),r=Jt(C=>C.createEntry),i=Jt(C=>C.createFile),[l,d]=o.useState("npm"),[c,h]=o.useState(""),[g,f]=o.useState(""),[m,u]=o.useState(""),[v,w]=o.useState(""),[b,k]=o.useState(a),[p,S]=o.useState(!1),N=o.useCallback(()=>{h(""),f(""),u(""),w(""),k(a)},[a]);o.useEffect(()=>{t&&(d("npm"),N())},[t,N]);const I=C=>{C!==l&&(d(C),N())},y=o.useMemo(()=>dh(g),[g]),T=!y.ok,x=l==="file"&&m.trim()!==""&&!ch.test(m.trim()),A=(l==="npm"||l==="path")&&c.trim()==="",R=l==="file"&&v.trim()==="",P=l==="file"&&m.trim()==="",D=p||T||l==="npm"&&A||l==="path"&&A||l==="file"&&(P||x||R),F=async()=>{if(!D){S(!0);try{let C;l==="file"?C=await i({fileName:m.trim(),content:v,scope:b}):C=await r({spec:c.trim(),options:y.ok?y.value:void 0,scope:b}),C.ok?($.success(C.message||n("settings.plugins.toast.created")),C.reloadFailed&&$.warning(n("settings.plugins.toast.reloadFailed")),e(!1)):$.error(C.message||n("settings.plugins.sidebar.toast.deleteFailed"))}finally{S(!1)}}},O=o.useMemo(()=>[{id:"npm",label:n("settings.plugins.dialog.add.tab.npm")},{id:"path",label:n("settings.plugins.dialog.add.tab.path")},{id:"file",label:n("settings.plugins.dialog.add.tab.file")}],[n]);return s.jsx(Ut,{open:t,onOpenChange:C=>{!C&&p||e(C)},children:s.jsxs(_t,{className:"max-w-xl",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:n("settings.plugins.dialog.add.title")}),s.jsx(qt,{children:n("settings.plugins.sidebar.empty.description")})]}),s.jsx(Io,{items:O,activeId:l,onSelect:C=>I(C),layoutMode:"fit",variant:"active-pill",activePillLowercase:!1,className:"h-10"}),s.jsxs("div",{className:"flex flex-col gap-4",children:[(l==="npm"||l==="path")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-settings-item":"plugins.spec",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-spec",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.spec")}),s.jsx(He,{id:"plugin-spec",value:c,onChange:C=>h(C.target.value),placeholder:n("settings.plugins.page.field.spec.placeholder"),"aria-invalid":A?!1:void 0,disabled:p}),A&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.plugins.validation.specRequired")})]}),s.jsxs("div",{"data-settings-item":"plugins.options",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-options",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.options")}),s.jsx(As,{id:"plugin-options",value:g,onChange:C=>f(C.target.value),rows:5,className:"font-mono",hasError:T,disabled:p}),T&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:n("settings.plugins.page.field.options.invalidJson")})]})]}),l==="file"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-settings-item":"plugins.content",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-filename",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.fileName")}),s.jsx(He,{id:"plugin-filename",value:m,onChange:C=>u(C.target.value),placeholder:"my-plugin.ts","aria-invalid":x||void 0,disabled:p}),x&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:n("settings.plugins.validation.fileName")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-content",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.content")}),s.jsx(As,{id:"plugin-content",value:v,onChange:C=>w(C.target.value),rows:16,className:"font-mono",disabled:p})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.scope")}),s.jsx("div",{className:"flex items-center gap-4",children:["user","project"].map(C=>{const M=b===C,U=n(C==="user"?"settings.plugins.scope.user":"settings.plugins.scope.project");return s.jsxs("button",{type:"button",onClick:()=>k(C),disabled:p,className:"flex items-center gap-2 py-1 text-left disabled:opacity-50",children:[s.jsx(vo,{checked:M,onChange:()=>k(C),ariaLabel:U}),s.jsx("span",{className:Pe("typography-ui-label font-normal",M?"text-foreground":"text-foreground/60"),children:U})]},C)})})]})]}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>e(!1),disabled:p,children:n("settings.plugins.dialog.add.action.cancel")}),s.jsxs(G,{size:"sm",onClick:()=>{F()},disabled:D,children:[p?s.jsx(_,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}):null,n("settings.plugins.dialog.add.action.submit")]})]})]})})},mh=t=>{const e=tt.c(33),{spec:a}=t;let n;e[0]!==a?(n=d=>d.registryInfo[a],e[0]=a,e[1]=n):n=e[1];const r=Jt(n),{t:i}=Qe();if(!r)return null;const l=ph;switch(r.kind){case"npm-ok":{if(!r.hasUpdate||!r.latestVersion)return null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"arrow-up-s",className:"h-3 w-3"}),e[2]=d):d=e[2];let c;e[3]!==r.latestVersion?(c=s.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[var(--status-success)]",children:[d,r.latestVersion]}),e[3]=r.latestVersion,e[4]=c):c=e[4];let h;return e[5]!==r.currentVersion||e[6]!==r.latestVersion||e[7]!==i||e[8]!==c?(h=l(c,i("settings.plugins.registry.badge.update.tooltip",{current:r.currentVersion??"",latest:r.latestVersion})),e[5]=r.currentVersion,e[6]=r.latestVersion,e[7]=i,e[8]=c,e[9]=h):h=e[9],h}case"npm-missing-version":{let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"error-warning",className:"h-3 w-3 text-[var(--status-warning)]"}),e[10]=d):d=e[10];let c;return e[11]!==r.currentVersion||e[12]!==r.name||e[13]!==i?(c=l(d,i("settings.plugins.registry.badge.missingVersion.tooltip",{version:r.currentVersion,name:r.name})),e[11]=r.currentVersion,e[12]=r.name,e[13]=i,e[14]=c):c=e[14],c}case"npm-missing-package":{let d;e[15]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[15]=d):d=e[15];let c;return e[16]!==r.name||e[17]!==i?(c=l(d,i("settings.plugins.registry.badge.missingPackage.tooltip",{name:r.name})),e[16]=r.name,e[17]=i,e[18]=c):c=e[18],c}case"npm-malformed":{let d;e[19]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[19]=d):d=e[19];let c;return e[20]!==i?(c=l(d,i("settings.plugins.registry.badge.malformed.tooltip")),e[20]=i,e[21]=c):c=e[21],c}case"npm-network":{let d;e[22]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"cloud-off",className:"h-3 w-3 text-muted-foreground"}),e[22]=d):d=e[22];let c;return e[23]!==i?(c=l(d,i("settings.plugins.registry.badge.network.tooltip")),e[23]=i,e[24]=c):c=e[24],c}case"path-missing":{let d;e[25]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[25]=d):d=e[25];let c;return e[26]!==r.absolutePath||e[27]!==i?(c=l(d,i("settings.plugins.registry.badge.pathMissing.tooltip",{path:r.absolutePath})),e[26]=r.absolutePath,e[27]=i,e[28]=c):c=e[28],c}case"path-unreadable":{let d;e[29]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"error-warning",className:"h-3 w-3 text-[var(--status-warning)]"}),e[29]=d):d=e[29];let c;return e[30]!==r.absolutePath||e[31]!==i?(c=l(d,i("settings.plugins.registry.badge.pathUnreadable.tooltip",{path:r.absolutePath})),e[30]=r.absolutePath,e[31]=i,e[32]=c):c=e[32],c}case"path-ok":return null;default:return null}};function ph(t,e){return s.jsxs(ar,{children:[s.jsx(ir,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-xs",children:t})}),s.jsx(yo,{children:e})]})}const gh=t=>t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t),Ga=t=>{const e=t.replace(/\\/g,"/"),a=[],[n,...r]=e.split("/");for(const l of r)if(!(l===""||l===".")){if(l===".."){a.pop();continue}a.push(l)}return`${/^[A-Za-z]:$/.test(n)?`${n.toUpperCase()}/`:"/"}${a.join("/")}`},hh=t=>Ga(`${t.replace(/\\/g,"/")}/..`),fh=t=>{try{const e=decodeURIComponent(new URL(t).pathname);return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}catch{return null}};function sd(t,e){if(t.startsWith("file://")){const a=fh(t);return a?{kind:"local",path:Ga(a)}:null}return t.startsWith("./")||t.startsWith("../")?e?{kind:"local",path:Ga(`${hh(e)}/${t}`)}:null:gh(t)?{kind:"local",path:Ga(t)}:{kind:"package",target:t}}function nd(t){return t?{kind:"local",path:Ga(t)}:null}const xh=(t,e)=>{if(t.kind==="package")return e.source.kind==="package"&&e.source.target===t.target;if(e.source.kind!=="local")return!1;const a=Ga(e.source.path);return a===t.path||a.startsWith(`${t.path}/`)};function ad(t,e){return e.filter(a=>xh(t,a))}function bh(t){const e=t.find(n=>n.state.kind==="failed");if(e&&e.state.kind==="failed")return{kind:"failed",error:e.state.error,ref:e.state.ref};const a=t[0];return a?{kind:"active",version:a.source.kind==="package"?a.source.version:null}:{kind:"notReported"}}function id(t){const e=t.flatMap(a=>a.source.kind==="package"?[a.source]:[]);return e.some(a=>a.updating)?"updating":e.some(a=>a.outdated)?"available":"none"}function rd(t){const e=tt.c(12),a=Jt(vh),n=jo(na());let r;e:{if(a.kind==="idle"||a.scope!==n){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={kind:"loading"},e[0]=h):h=e[0],r=h;break e}if(a.kind==="failed"||!t){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h={kind:"unknown"},e[1]=h):h=e[1],r=h;break e}let i,l,d;if(e[2]!==a.plugins||e[3]!==t){const h=ad(t,a.plugins);i="known",l=bh(h),d=id(h),e[2]=a.plugins,e[3]=t,e[4]=i,e[5]=l,e[6]=d}else i=e[4],l=e[5],d=e[6];let c;e[7]!==i||e[8]!==l||e[9]!==d||e[10]!==t?(c={kind:i,load:l,update:d,target:t},e[7]=i,e[8]=l,e[9]=d,e[10]=t,e[11]=c):c=e[11],r=c}return r}function vh(t){return t.runtime}function od(t){const e=tt.c(4);let a;if(e[0]!==t){const i=jo(na());a=t?.kind==="package"?Ec(i,t.target):null,e[0]=t,e[1]=a}else a=e[1];const n=a;let r;return e[2]!==n?(r=i=>n?i.packageUpdates[n]??null:null,e[2]=n,e[3]=r):r=e[3],Jt(r)}const _r=t=>{const e=tt.c(28),{target:a}=t,{t:n}=Qe(),r=rd(a),i=od(a);if(r.kind!=="known")return null;let l;e:{if(r.update==="updating"||i?.kind==="running"){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_,{name:"loader-4",className:"h-3 w-3 animate-spin text-muted-foreground"}),e[0]=f):f=e[0];let m;e[1]!==n?(m=n("settings.plugins.update.running"),e[1]=n,e[2]=m):m=e[2];let u;e[3]!==m?(u={icon:f,label:m},e[3]=m,e[4]=u):u=e[4],l=u;break e}if(r.load.kind==="failed"){let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[5]=f):f=e[5];let m;e[6]!==n?(m=n("settings.plugins.status.failed.title"),e[6]=n,e[7]=m):m=e[7];let u;e[8]!==m?(u={icon:f,label:m},e[8]=m,e[9]=u):u=e[9],l=u;break e}if(r.load.kind==="notReported"){let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_,{name:"time",className:"h-3 w-3 text-muted-foreground"}),e[10]=f):f=e[10];let m;e[11]!==n?(m=n("settings.plugins.status.notReported.title"),e[11]=n,e[12]=m):m=e[12];let u;e[13]!==m?(u={icon:f,label:m},e[13]=m,e[14]=u):u=e[14],l=u;break e}if(r.update==="available"){let f;e[15]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_,{name:"arrow-up-s",className:"h-3 w-3 text-[var(--status-success)]"}),e[15]=f):f=e[15];let m;e[16]!==n?(m=n("settings.plugins.update.available.title"),e[16]=n,e[17]=m):m=e[17];let u;e[18]!==m?(u={icon:f,label:m},e[18]=m,e[19]=u):u=e[19],l=u;break e}l=null}const d=l;if(!d)return null;let c;e[20]!==d.icon||e[21]!==d.label?(c=s.jsx(ir,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0 items-center","aria-label":d.label,children:d.icon})}),e[20]=d.icon,e[21]=d.label,e[22]=c):c=e[22];let h;e[23]!==d.label?(h=s.jsx(yo,{children:d.label}),e[23]=d.label,e[24]=h):h=e[24];let g;return e[25]!==c||e[26]!==h?(g=s.jsxs(ar,{children:[c,h]}),e[25]=c,e[26]=h,e[27]=g):g=e[27],g},ld=t=>{const e=tt.c(26),{header:a,footer:n,children:r,className:i,variant:l}=t,d=l===void 0?"sidebar":l,c=fs(),h=o.useRef(null),[g,f]=o.useState(!1),[m,u]=o.useState(!1),v=d==="background"||c?"bg-background":"bg-sidebar",w=v==="bg-background"?"var(--surface-background)":"var(--surface-muted)";let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const D=h.current;if(!D){f(!1),u(!1);return}if(!(D.scrollHeight>D.clientHeight+1)){f(!1),u(!1);return}f(D.scrollTop>1),u(D.scrollTop+D.clientHeight<D.scrollHeight-1)},e[0]=b):b=e[0];const k=b;let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{k()},e[1]=p):p=e[1];let S;e[2]!==r?(S=[r,k],e[2]=r,e[3]=S):S=e[3],o.useEffect(p,S);let N,I;e[4]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{const D=h.current;if(!D)return;const F=()=>k();return D.addEventListener("scroll",F,{passive:!0}),()=>D.removeEventListener("scroll",F)},I=[k],e[4]=N,e[5]=I):(N=e[4],I=e[5]),o.useEffect(N,I);let y;e[6]!==v||e[7]!==i?(y=Pe("flex h-full flex-col",v,i),e[6]=v,e[7]=i,e[8]=y):y=e[8];let T;e[9]!==r?(T=s.jsx(Ns,{ref:h,outerClassName:"flex-1 min-h-0",className:"space-y-0.5 px-3 py-2 overflow-x-hidden",children:r}),e[9]=r,e[10]=T):T=e[10];let x;e[11]!==w||e[12]!==g?(x=g&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-4",style:{background:`linear-gradient(to bottom, ${w} 0%, transparent 100%)`}}),e[11]=w,e[12]=g,e[13]=x):x=e[13];let A;e[14]!==w||e[15]!==m?(A=m&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6",style:{background:`linear-gradient(to top, ${w} 0%, transparent 100%)`}}),e[14]=w,e[15]=m,e[16]=A):A=e[16];let R;e[17]!==A||e[18]!==T||e[19]!==x?(R=s.jsxs("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[T,x,A]}),e[17]=A,e[18]=T,e[19]=x,e[20]=R):R=e[20];let P;return e[21]!==n||e[22]!==a||e[23]!==R||e[24]!==y?(P=s.jsxs("div",{className:y,children:[a,R,n]}),e[21]=n,e[22]=a,e[23]=R,e[24]=y,e[25]=P):P=e[25],P},Hi=t=>{const e=tt.c(23),{title:a,metadata:n,selected:r,onSelect:i,icon:l,actions:d,className:c}=t,h=r===void 0?!1:r,g=d&&d.length>0,f=h?"bg-interactive-selection":"hover:bg-interactive-hover";let m;e[0]!==c||e[1]!==f?(m=Pe("group relative flex items-center rounded-md px-1.5 py-0.5 transition-all duration-200",f,c),e[0]=c,e[1]=f,e[2]=m):m=e[2];let u;e[3]!==a?(u=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a}),e[3]=a,e[4]=u):u=e[4];let v;e[5]!==l||e[6]!==u?(v=s.jsxs("div",{className:"flex items-center gap-1.5",children:[l,u]}),e[5]=l,e[6]=u,e[7]=v):v=e[7];let w;e[8]!==n?(w=n&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n}),e[8]=n,e[9]=w):w=e[9];let b;e[10]!==i||e[11]!==v||e[12]!==w?(b=s.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-ring",tabIndex:0,children:[v,w]}),e[10]=i,e[11]=v,e[12]=w,e[13]=b):b=e[13];let k;e[14]!==d||e[15]!==g?(k=g&&s.jsxs(Sn,{children:[s.jsx(Nn,{asChild:!0,children:s.jsx(G,{size:"icon",variant:"ghost",className:"h-6 w-6 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(kn,{align:"end",className:"w-fit min-w-20",children:d.map(yh)})]}),e[14]=d,e[15]=g,e[16]=k):k=e[16];let p;e[17]!==b||e[18]!==k?(p=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[b,k]}),e[17]=b,e[18]=k,e[19]=p):p=e[19];let S;return e[20]!==m||e[21]!==p?(S=s.jsx("div",{className:m,children:p}),e[20]=m,e[21]=p,e[22]=S):S=e[22],S};function yh(t){const e=t.icon;return s.jsxs(an,{onClick:a=>{a.stopPropagation(),t.onClick()},className:Pe(t.destructive&&"text-destructive focus:text-destructive"),children:[e&&s.jsx(_,{name:e,className:"h-4 w-4 mr-px"}),t.label]},t.label)}const jh=t=>t.parsedKind==="npm"?"code-box":"folder",wh=t=>{const e=tt.c(165),{onItemSelect:a,onAddClick:n}=t,{t:r}=Qe(),{entries:i,files:l,selectedId:d,setSelected:c,deleteEntry:h,deleteFile:g,loadPlugins:f}=Jt(Bs(kh)),m=Jt(Nh),u=Jt(Sh),v=Jt(Ch),w=Jt(Ih),b=Jt(Ph),k=Jt(Ah),p=Jt(Th),S=Jt(Eh),N=Jt(Dh);let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I=jo(na()),e[0]=I):I=e[0];const y=I,T=b.kind==="failed"&&b.scope===y,x=b.kind==="ready"&&b.scope===y?b.plugins:null;let A;if(e[1]!==i||e[2]!==l){A=new Map;for(const Ie of i)A.set(Ie.id,sd(Ie.spec,Ie.sourcePath));for(const Ie of l)A.set(Ie.id,nd(Ie.absolutePath));e[1]=i,e[2]=l,e[3]=A}else A=e[3];const R=A;let P;e[4]!==N||e[5]!==x||e[6]!==R?(P=Ie=>{const Be=R.get(Ie);return!x||Be?.kind!=="package"||N[Ec(y,Be.target)]?.kind==="running"?null:id(ad(Be,x))==="available"?Be.target:null},e[4]=N,e[5]=x,e[6]=R,e[7]=P):P=e[7];const D=P,[F,O]=o.useState(null),[C,M]=o.useState(!1),[U,L]=o.useState(!1);let W,X;e[8]!==f?(W=()=>{f()},X=[f],e[8]=f,e[9]=W,e[10]=X):(W=e[9],X=e[10]),o.useEffect(W,X);let J,q;e[11]===Symbol.for("react.memo_cache_sentinel")?(J=()=>{const Ie=()=>L(!0);return window.addEventListener("openchamber:settings-open-plugin-add",Ie),()=>window.removeEventListener("openchamber:settings-open-plugin-add",Ie)},q=[],e[11]=J,e[12]=q):(J=e[11],q=e[12]),o.useEffect(J,q);let z;if(e[13]!==i||e[14]!==D||e[15]!==m){z={userEntries:0,projectEntries:0};for(const Ie of i){const Be=m[Ie.spec];(Be?.kind==="npm-ok"&&Be.hasUpdate||D(Ie.id)!==null)&&(Ie.scope==="user"?z.userEntries=z.userEntries+1:Ie.scope==="project"&&(z.projectEntries=z.projectEntries+1))}e[13]=i,e[14]=D,e[15]=m,e[16]=z}else z=e[16];const H=z;let se;e[17]!==i?(se=i.filter(Mh),e[17]=i,e[18]=se):se=e[18];const B=se;let ne;e[19]!==i?(ne=i.filter(Rh),e[19]=i,e[20]=ne):ne=e[20];const K=ne;let Z;e[21]!==l?(Z=l.filter(Fh),e[21]=l,e[22]=Z):Z=e[22];const oe=Z;let ue;e[23]!==l?(ue=l.filter(Oh),e[23]=l,e[24]=ue):ue=e[24];const de=ue,ce=i.length+l.length,Se=ce===0;let re;e[25]!==n?(re=()=>{n?n():L(!0)},e[25]=n,e[26]=re):re=e[26];const ve=re;let ie;e[27]!==a||e[28]!==c?(ie=Ie=>{c(Ie),a?.()},e[27]=a,e[28]=c,e[29]=ie):ie=e[29];const me=ie;let ke;e[30]!==i||e[31]!==m||e[32]!==r||e[33]!==w?(ke=async Ie=>{const Be=i.find(Xt=>Xt.id===Ie);if(!Be)return;const wt=m[Be.spec];if(!wt||wt.kind!=="npm-ok"||!wt.hasUpdate||!wt.latestVersion)return;const Pt=wt.latestVersion;(await w(Ie)).ok?$.success(r("settings.plugins.toast.updatedToLatest",{version:Pt})):$.error(r("settings.plugins.toast.refreshFailed"))},e[30]=i,e[31]=m,e[32]=r,e[33]=w,e[34]=ke):ke=e[34];const Ae=ke;let pe;e[35]!==r||e[36]!==S?(pe=async(Ie,Be)=>{await S(Ie)?$.success(r("settings.plugins.update.toast.done",{name:Be})):$.error(r("settings.plugins.update.toast.failed",{name:Be}))},e[35]=r,e[36]=S,e[37]=pe):pe=e[37];const Le=pe;let Ve;e[38]!==p||e[39]!==v||e[40]!==r?(Ve=async()=>{$.info(r("settings.plugins.toast.refreshing"));const[Ie,Be]=await Promise.all([v({force:!0}),p()]);Ie||$.error(r("settings.plugins.toast.refreshFailed")),Be||$.error(r("settings.plugins.toast.checkFailed"))},e[38]=p,e[39]=v,e[40]=r,e[41]=Ve):Ve=e[41];const ye=Ve;let Te;e[42]!==h||e[43]!==g||e[44]!==F||e[45]!==r?(Te=async()=>{if(!F)return;M(!0);const Ie=F.kind==="entry"?await h(F.id):await g(F.id);Ie.ok?$.success(Ie.message||r("settings.plugins.sidebar.toast.deleted",{name:F.label})):$.error(r("settings.plugins.sidebar.toast.deleteFailed")),O(null),M(!1)},e[42]=h,e[43]=g,e[44]=F,e[45]=r,e[46]=Te):Te=e[46];const ee=Te;let ae;e[47]!==Le||e[48]!==me||e[49]!==Ae||e[50]!==D||e[51]!==m||e[52]!==R||e[53]!==d||e[54]!==r?(ae=Ie=>{const Be=m[Ie.spec],wt=Be?.kind==="npm-ok"&&Be.hasUpdate&&!!Be.latestVersion,Pt=D(Ie.id),Qt=[];return wt?Qt.push({label:r("settings.plugins.sidebar.actions.updateToLatest"),icon:"arrow-up-s",onClick:()=>{Ae(Ie.id)}}):Pt&&Qt.push({label:r("settings.plugins.update.action"),icon:"arrow-up-s",onClick:()=>{Le(Pt,Ie.spec)}}),Qt.push({label:r("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onClick:()=>O({kind:"entry",id:Ie.id,label:Ie.spec})}),s.jsx(Hi,{title:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Ie.spec}),s.jsx(_r,{target:R.get(Ie.id)??null}),s.jsx(mh,{spec:Ie.spec})]}),metadata:Ie.parsedKind==="npm"?r("settings.plugins.sidebar.kind.npm"):r("settings.plugins.sidebar.kind.path"),selected:d===Ie.id,onSelect:()=>me(Ie.id),icon:s.jsx(_,{name:jh(Ie),className:"h-4 w-4 flex-shrink-0 text-muted-foreground/70"}),actions:Qt},Ie.id)},e[47]=Le,e[48]=me,e[49]=Ae,e[50]=D,e[51]=m,e[52]=R,e[53]=d,e[54]=r,e[55]=ae):ae=e[55];const fe=ae;let je;e[56]!==me||e[57]!==R||e[58]!==d||e[59]!==r?(je=Ie=>Ie.kind==="package"?s.jsx(Hi,{title:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Ie.fileName}),s.jsx(_r,{target:R.get(Ie.id)??null})]}),metadata:r("settings.plugins.sidebar.kind.package"),selected:!1,onSelect:Lh,icon:s.jsx(_,{name:"folder",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/70"})},Ie.id):s.jsx(Hi,{title:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Ie.fileName}),s.jsx(_r,{target:R.get(Ie.id)??null})]}),metadata:r("settings.plugins.sidebar.kind.file"),selected:d===Ie.id,onSelect:()=>me(Ie.id),icon:s.jsx(_,{name:"file-text",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/70"}),actions:[{label:r("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onClick:()=>O({kind:"file",id:Ie.id,label:Ie.fileName})}]},Ie.id),e[56]=me,e[57]=R,e[58]=d,e[59]=r,e[60]=je):je=e[60];const Re=je;let Ce;e[61]!==r?(Ce=(Ie,Be,wt)=>{const Pt=wt===void 0?0:wt;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[Ie,Pt>0&&s.jsx("span",{className:"ml-2 normal-case font-normal text-[var(--status-success)]",children:r(Pt===1?"settings.plugins.sidebar.group.updatesAvailable_one":"settings.plugins.sidebar.group.updatesAvailable_other",{count:Pt})})]}),Be]})},e[61]=r,e[62]=Ce):Ce=e[62];const _e=Ce;let Ke;e[63]!==r?(Ke=r("settings.plugins.sidebar.title"),e[63]=r,e[64]=Ke):Ke=e[64];let Fe;e[65]!==Ke?(Fe=s.jsx("div",{className:"mb-3 flex items-center justify-between gap-3",children:s.jsx("h2",{className:_n,children:Ke})}),e[65]=Ke,e[66]=Fe):Fe=e[66];let Me;e[67]!==r||e[68]!==ce?(Me=r("settings.plugins.sidebar.total",{count:ce}),e[67]=r,e[68]=ce,e[69]=Me):Me=e[69];let at;e[70]!==T||e[71]!==r?(at=T?s.jsxs("span",{className:"ml-2 inline-flex items-center gap-1",children:[s.jsx(_,{name:"question",className:"size-3"}),r("settings.plugins.status.sidebar.unavailable")]}):null,e[70]=T,e[71]=r,e[72]=at):at=e[72];let pt;e[73]!==Me||e[74]!==at?(pt=s.jsxs("span",{className:"typography-meta text-muted-foreground",children:[Me,at]}),e[73]=Me,e[74]=at,e[75]=pt):pt=e[75];let ot;e[76]!==ye?(ot=()=>{ye()},e[76]=ye,e[77]=ot):ot=e[77];const mt=u||k;let ht;e[78]!==r?(ht=r("settings.plugins.sidebar.actions.refresh"),e[78]=r,e[79]=ht):ht=e[79];let Oe;e[80]!==r?(Oe=r("settings.plugins.sidebar.actions.refresh"),e[80]=r,e[81]=Oe):Oe=e[81];const nt=u||k?"size-4 animate-spin":"size-4";let lt;e[82]!==nt?(lt=s.jsx(_,{name:"refresh",className:nt}),e[82]=nt,e[83]=lt):lt=e[83];let we;e[84]!==ot||e[85]!==mt||e[86]!==ht||e[87]!==Oe||e[88]!==lt?(we=s.jsx(G,{type:"button","data-settings-item":"plugins.create",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:ot,disabled:mt,"aria-label":ht,title:Oe,children:lt}),e[84]=ot,e[85]=mt,e[86]=ht,e[87]=Oe,e[88]=lt,e[89]=we):we=e[89];let Je;e[90]!==r?(Je=r("settings.plugins.sidebar.actions.addTitle"),e[90]=r,e[91]=Je):Je=e[91];let Ye;e[92]!==r?(Ye=r("settings.plugins.sidebar.actions.addTitle"),e[92]=r,e[93]=Ye):Ye=e[93];let ze;e[94]===Symbol.for("react.memo_cache_sentinel")?(ze=s.jsx(_,{name:"add",className:"size-4"}),e[94]=ze):ze=e[94];let Ge;e[95]!==ve||e[96]!==Je||e[97]!==Ye?(Ge=s.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:ve,"aria-label":Je,title:Ye,children:ze}),e[95]=ve,e[96]=Je,e[97]=Ye,e[98]=Ge):Ge=e[98];let Q;e[99]!==we||e[100]!==Ge?(Q=s.jsxs("div",{className:"flex items-center gap-1",children:[we,Ge]}),e[99]=we,e[100]=Ge,e[101]=Q):Q=e[101];let Ue;e[102]!==pt||e[103]!==Q?(Ue=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[pt,Q]}),e[102]=pt,e[103]=Q,e[104]=Ue):Ue=e[104];let st;e[105]!==Fe||e[106]!==Ue?(st=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[Fe,Ue]}),e[105]=Fe,e[106]=Ue,e[107]=st):st=e[107];let dt;e[108]!==Se||e[109]!==K||e[110]!==de||e[111]!==fe||e[112]!==Re||e[113]!==_e||e[114]!==r||e[115]!==H||e[116]!==B||e[117]!==oe?(dt=Se?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"plug",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:r("settings.plugins.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:r("settings.plugins.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[B.length>0&&_e(r("settings.plugins.sidebar.group.userEntries"),B.map(fe),H.userEntries),oe.length>0&&_e(r("settings.plugins.sidebar.group.userFiles"),oe.map(Re)),K.length>0&&_e(r("settings.plugins.sidebar.group.projectEntries"),K.map(fe),H.projectEntries),de.length>0&&_e(r("settings.plugins.sidebar.group.projectFiles"),de.map(Re))]}),e[108]=Se,e[109]=K,e[110]=de,e[111]=fe,e[112]=Re,e[113]=_e,e[114]=r,e[115]=H,e[116]=B,e[117]=oe,e[118]=dt):dt=e[118];let ct;e[119]!==st||e[120]!==dt?(ct=s.jsx(ld,{variant:"background",header:st,children:dt}),e[119]=st,e[120]=dt,e[121]=ct):ct=e[121];let ft;e[122]!==U?(ft=s.jsx(uh,{open:U,onOpenChange:L}),e[122]=U,e[123]=ft):ft=e[123];const kt=F!==null;let bt;e[124]!==C?(bt=Ie=>{!Ie&&!C&&O(null)},e[124]=C,e[125]=bt):bt=e[125];let vt;e[126]!==r?(vt=r("settings.plugins.sidebar.deleteDialog.title"),e[126]=r,e[127]=vt):vt=e[127];let Xe;e[128]!==vt?(Xe=s.jsx(Ht,{children:vt}),e[128]=vt,e[129]=Xe):Xe=e[129];const jt=F?.label??"";let De;e[130]!==r||e[131]!==jt?(De=r("settings.plugins.sidebar.deleteDialog.description",{name:jt}),e[130]=r,e[131]=jt,e[132]=De):De=e[132];let $e;e[133]!==De?($e=s.jsx(qt,{children:De}),e[133]=De,e[134]=$e):$e=e[134];let Y;e[135]!==Xe||e[136]!==$e?(Y=s.jsxs(Vt,{children:[Xe,$e]}),e[135]=Xe,e[136]=$e,e[137]=Y):Y=e[137];let V;e[138]===Symbol.for("react.memo_cache_sentinel")?(V=()=>O(null),e[138]=V):V=e[138];let be;e[139]!==r?(be=r("settings.common.actions.cancel"),e[139]=r,e[140]=be):be=e[140];let ge;e[141]!==C||e[142]!==be?(ge=s.jsx(G,{size:"sm",variant:"ghost",onClick:V,disabled:C,children:be}),e[141]=C,e[142]=be,e[143]=ge):ge=e[143];let Ee;e[144]!==C||e[145]!==r?(Ee=r(C?"settings.plugins.sidebar.actions.deleting":"settings.common.actions.delete"),e[144]=C,e[145]=r,e[146]=Ee):Ee=e[146];let te;e[147]!==ee||e[148]!==C||e[149]!==Ee?(te=s.jsx(G,{size:"sm",variant:"destructive",onClick:ee,disabled:C,children:Ee}),e[147]=ee,e[148]=C,e[149]=Ee,e[150]=te):te=e[150];let xe;e[151]!==ge||e[152]!==te?(xe=s.jsxs(as,{children:[ge,te]}),e[151]=ge,e[152]=te,e[153]=xe):xe=e[153];let Ze;e[154]!==Y||e[155]!==xe?(Ze=s.jsxs(_t,{className:"max-w-md",children:[Y,xe]}),e[154]=Y,e[155]=xe,e[156]=Ze):Ze=e[156];let Nt;e[157]!==kt||e[158]!==bt||e[159]!==Ze?(Nt=s.jsx(Ut,{open:kt,onOpenChange:bt,children:Ze}),e[157]=kt,e[158]=bt,e[159]=Ze,e[160]=Nt):Nt=e[160];let Lt;return e[161]!==ct||e[162]!==ft||e[163]!==Nt?(Lt=s.jsxs(s.Fragment,{children:[ct,ft,Nt]}),e[161]=ct,e[162]=ft,e[163]=Nt,e[164]=Lt):Lt=e[164],Lt};function kh(t){return{entries:t.entries,files:t.files,selectedId:t.selectedId,setSelected:t.setSelected,deleteEntry:t.deleteEntry,deleteFile:t.deleteFile,loadPlugins:t.loadPlugins}}function Nh(t){return t.registryInfo}function Sh(t){return t.isLoadingRegistry}function Ch(t){return t.loadRegistryInfo}function Ih(t){return t.updateToLatest}function Ph(t){return t.runtime}function Ah(t){return t.isCheckingUpdates}function Th(t){return t.checkUpdates}function Eh(t){return t.updatePackage}function Dh(t){return t.packageUpdates}function Mh(t){return t.scope==="user"}function Rh(t){return t.scope==="project"}function Fh(t){return t.scope==="user"}function Oh(t){return t.scope==="project"}function Lh(){}const Kh=({entryId:t,spec:e})=>{const{t:a}=Qe(),n=Jt(f=>f.registryInfo[e]),r=Jt(f=>f.updateToLatest),[i,l]=o.useState(!1);if(!n)return null;if(n.kind==="npm-ok"){if(!n.hasUpdate||!n.latestVersion)return null;const f=n.latestVersion,m=n.currentVersion??"",u=async()=>{l(!0);try{(await r(t)).ok?$.success(a("settings.plugins.toast.updatedToLatest",{version:f})):$.error(a("settings.plugins.toast.refreshFailed"))}finally{l(!1)}};return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx(_,{name:"arrow-up",className:"h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label text-[var(--status-success)]",children:a("settings.plugins.registry.banner.updateAvailable.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:a("settings.plugins.registry.banner.updateAvailable.description",{current:m,latest:f})})]}),s.jsx(G,{variant:"default",size:"sm",onClick:()=>{u()},disabled:i,children:a("settings.plugins.registry.banner.updateAvailable.action",{latest:f})})]})}if(n.kind==="path-ok")return null;if(n.kind==="npm-network")return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx(_,{name:"cloud-off",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("settings.plugins.registry.badge.network.tooltip")})})]});const d=n.kind==="path-unreadable",c=d?"var(--status-warning)":"var(--status-error)",h=d?"alert":"error-warning",g=(()=>{switch(n.kind){case"npm-missing-version":return a("settings.plugins.registry.banner.invalid.missingVersion");case"npm-missing-package":return a("settings.plugins.registry.banner.invalid.missingPackage");case"npm-malformed":return a("settings.plugins.registry.banner.invalid.malformed");case"path-missing":return a("settings.plugins.registry.banner.invalid.pathMissing");case"path-unreadable":return a("settings.plugins.registry.banner.invalid.pathUnreadable")}})();return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx(_,{name:h,className:"h-5 w-5 shrink-0 mt-0.5",style:{color:c}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label",style:{color:c},children:a("settings.plugins.registry.banner.invalid.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:g})]})]})},Tl=t=>{const e=tt.c(68),{target:a,name:n}=t,{t:r}=Qe(),i=rd(a),l=od(a),d=Jt(zh),c=Jt(Uh);if(i.kind==="loading")return null;if(i.kind==="unknown"){let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(_,{name:"question",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),e[0]=N):N=e[0];let I;e[1]!==r?(I=r("settings.plugins.status.unknown.title"),e[1]=r,e[2]=I):I=e[2];let y;e[3]!==I?(y=s.jsx("p",{className:"typography-label text-foreground",children:I}),e[3]=I,e[4]=y):y=e[4];let T;e[5]!==r?(T=r("settings.plugins.status.unknown.description"),e[5]=r,e[6]=T):T=e[6];let x;e[7]!==T?(x=s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:T}),e[7]=T,e[8]=x):x=e[8];let A;e[9]!==y||e[10]!==x?(A=s.jsxs("div",{className:"flex-1 min-w-0",children:[y,x]}),e[9]=y,e[10]=x,e[11]=A):A=e[11];let R;e[12]!==d?(R=()=>{d()},e[12]=d,e[13]=R):R=e[13];let P;e[14]!==r?(P=r("settings.plugins.status.retry"),e[14]=r,e[15]=P):P=e[15];let D;e[16]!==R||e[17]!==P?(D=s.jsx(G,{variant:"outline",size:"sm",onClick:R,children:P}),e[16]=R,e[17]=P,e[18]=D):D=e[18];let F;return e[19]!==A||e[20]!==D?(F=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[N,A,D]}),e[19]=A,e[20]=D,e[21]=F):F=e[21],F}const{load:h,update:g}=i,f=i.target.kind==="package"?i.target.target:null,m=g==="updating"||l?.kind==="running";let u;e[22]!==n||e[23]!==f||e[24]!==r||e[25]!==c?(u=async()=>{if(!f)return;await c(f)?$.success(r("settings.plugins.update.toast.done",{name:n})):$.error(r("settings.plugins.update.toast.failed",{name:n}))},e[22]=n,e[23]=f,e[24]=r,e[25]=c,e[26]=u):u=e[26];const v=u;let w;e:{switch(h.kind){case"active":{let N;e[27]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(_,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]"}),e[27]=N):N=e[27];let I;e[28]!==h.version||e[29]!==r?(I=h.version?r("settings.plugins.status.loadedVersion",{version:h.version}):r("settings.plugins.status.loaded"),e[28]=h.version,e[29]=r,e[30]=I):I=e[30];let y;e[31]!==I?(y=s.jsxs("p",{className:"typography-meta flex items-center gap-1.5 text-muted-foreground",children:[N,I]}),e[31]=I,e[32]=y):y=e[32],w=y;break e}case"notReported":{let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(_,{name:"time",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),e[33]=N):N=e[33];let I;e[34]!==r?(I=r("settings.plugins.status.notReported.title"),e[34]=r,e[35]=I):I=e[35];let y;e[36]!==I?(y=s.jsx("p",{className:"typography-label text-foreground",children:I}),e[36]=I,e[37]=y):y=e[37];let T;e[38]!==r?(T=r("settings.plugins.status.notReported.description"),e[38]=r,e[39]=T):T=e[39];let x;e[40]!==T?(x=s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:T}),e[40]=T,e[41]=x):x=e[41];let A;e[42]!==y||e[43]!==x?(A=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[N,s.jsxs("div",{className:"flex-1 min-w-0",children:[y,x]})]}),e[42]=y,e[43]=x,e[44]=A):A=e[44],w=A;break e}case"failed":{let N;e[45]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(_,{name:"error-warning",className:"h-5 w-5 text-[var(--status-error)] shrink-0 mt-0.5"}),e[45]=N):N=e[45];let I;e[46]!==r?(I=r("settings.plugins.status.failed.title"),e[46]=r,e[47]=I):I=e[47];let y;e[48]!==I?(y=s.jsx("p",{className:"typography-label text-[var(--status-error)]",children:I}),e[48]=I,e[49]=y):y=e[49];let T;e[50]!==h.error?(T=s.jsx("p",{className:"typography-micro font-mono text-foreground mt-1 whitespace-pre-wrap break-words",children:h.error}),e[50]=h.error,e[51]=T):T=e[51];let x;e[52]!==h.ref||e[53]!==r?(x=h.ref?s.jsx("p",{className:"typography-micro text-muted-foreground mt-1",children:r("settings.plugins.status.failed.ref",{ref:h.ref})}):null,e[52]=h.ref,e[53]=r,e[54]=x):x=e[54];let A;e[55]!==y||e[56]!==T||e[57]!==x?(A=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[N,s.jsxs("div",{className:"flex-1 min-w-0",children:[y,T,x]})]}),e[55]=y,e[56]=T,e[57]=x,e[58]=A):A=e[58],w=A;break e}}w=void 0}const b=w,k=f!==null&&(g!=="none"||l!==null);let p;e[59]!==v||e[60]!==m||e[61]!==l||e[62]!==k||e[63]!==r?(p=k?s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx(_,{name:"arrow-up",className:"h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label text-[var(--status-success)]",children:r("settings.plugins.update.available.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:r("settings.plugins.update.available.description")}),l?.kind==="failed"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-micro text-[var(--status-error)] mt-2",children:r("settings.plugins.update.failed.title")}),s.jsx("p",{className:"typography-micro font-mono text-foreground mt-0.5 whitespace-pre-wrap break-words",children:l.error})]}):null]}),s.jsx(G,{variant:"default",size:"sm",onClick:()=>{v()},disabled:m,children:m?s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),r("settings.plugins.update.running")]}):r("settings.plugins.update.action")})]}):null,e[59]=v,e[60]=m,e[61]=l,e[62]=k,e[63]=r,e[64]=p):p=e[64];let S;return e[65]!==b||e[66]!==p?(S=s.jsxs("div",{className:"flex flex-col gap-3",children:[b,p]}),e[65]=b,e[66]=p,e[67]=S):S=e[67],S};function zh(t){return t.loadRuntime}function Uh(t){return t.updatePackage}function Xi(t){const e=t.trim();if(e.length===0)return{ok:!0,value:void 0};try{const a=JSON.parse(e);return a===null||typeof a!="object"||Array.isArray(a)?{ok:!1}:{ok:!0,value:a}}catch{return{ok:!1}}}function er(t){return!t||Object.keys(t).length===0?"":JSON.stringify(t,null,2)}function El(t,e){if(t.trim()===e.trim())return!0;const a=Xi(t),n=Xi(e);return a.ok&&n.ok&&er(a.value)===er(n.value)}function _h(t){return{mode:"entry",scope:t.scope,spec:t.spec,optionsJson:er(t.options),fileName:"",content:""}}function $h(t,e){return{mode:"file",scope:t.scope,spec:"",optionsJson:"",fileName:t.fileName,content:e}}const Dl=t=>{const e=tt.c(4),{scope:a,label:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=Pe("typography-micro font-medium rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-muted-foreground","border border-[var(--interactive-border)]"),e[0]=r):r=e[0];let i;return e[1]!==n||e[2]!==a?(i=s.jsx("span",{className:r,"data-scope":a,children:n}),e[1]=n,e[2]=a,e[3]=i):i=e[3],i},Bh=()=>{const t=tt.c(147),{t:e}=Qe(),n=pn(Vh)?.trim()||na(),r=Jt(Hh),i=Jt(qh),l=r===n&&i===wn(),d=Jt(Gh),c=Jt(Wh),h=Jt(Jh),g=Jt(Qh),f=Jt(Yh),m=Jt(Zh),u=Jt(Xh),v=Jt(ef);let w;t[0]!==c||t[1]!==d?(w=d?c.find(W=>W.id===d)??null:null,t[0]=c,t[1]=d,t[2]=w):w=t[2];const b=w;let k;t[3]!==h||t[4]!==d?(k=d?h.find(W=>W.id===d)??null:null,t[3]=h,t[4]=d,t[5]=k):k=t[5];const p=k;let S;t[6]!==b?(S=b?sd(b.spec,b.sourcePath):null,t[6]=b,t[7]=S):S=t[7];const N=S;let I;t[8]!==p?(I=p?nd(p.absolutePath):null,t[8]=p,t[9]=I):I=t[9];const y=I,[T,x]=o.useState(!1);let A;t[10]===Symbol.for("react.memo_cache_sentinel")?(A=new Map,t[10]=A):A=t[10];const R=o.useRef(A),P=o.useRef(null),D=JSON.stringify([n,d]);let F;t[11]!==l||t[12]!==n||t[13]!==D||t[14]!==v||t[15]!==b||t[16]!==p||t[17]!==f||t[18]!==x?(F=()=>{let W=!1;if(!l){P.current=null,f(null);return}const X=(J,q)=>{if(Jt.getState().selectedId!==J||na()!==n)return;const z=P.current,H=Jt.getState().draft,se=z?.id===J&&z.directory===n&&H!==null&&(H.spec!==z.value.spec||!El(H.optionsJson,z.value.optionsJson)||H.content!==z.value.content);P.current={id:J,directory:n,value:q},se||f(q)};return b?(X(b.id,_h(b)),()=>{W=!0}):p?(x(P.current?.id!==p.id||P.current.directory!==n),(async()=>{const J=await v(p.id);if(W||na()!==n)return;x(!1);const q=J?.content??"";R.current.set(D,q),X(p.id,$h(p,q))})(),()=>{W=!0}):(P.current=null,f(null),()=>{W=!0})},t[11]=l,t[12]=n,t[13]=D,t[14]=v,t[15]=b,t[16]=p,t[17]=f,t[18]=x,t[19]=F):F=t[19];let O;t[20]!==l||t[21]!==n||t[22]!==D||t[23]!==v||t[24]!==b||t[25]!==p||t[26]!==f?(O=[b,p,v,f,l,n,D],t[20]=l,t[21]=n,t[22]=D,t[23]=v,t[24]=b,t[25]=p,t[26]=f,t[27]=O):O=t[27],o.useEffect(F,O);let C;t[28]!==l||t[29]!==n||t[30]!==g||t[31]!==D||t[32]!==b||t[33]!==p||t[34]!==e||t[35]!==m||t[36]!==u?(C=async()=>{if(!g||!l||na()!==n)return Os;if(b&&g.mode==="entry"){const W=g.spec.trim();if(W===b.spec&&El(g.optionsJson,er(b.options)))return Os;if(!W)return ms(e("settings.plugins.validation.specRequired"));const J=Xi(g.optionsJson);if(!J.ok)return ms(e("settings.plugins.page.field.options.invalidJson"));const q=await m(b.id,{spec:W,options:J.value});return q.ok?q.reloadFailed?ms(q.warning||q.message||e("settings.plugins.toast.reloadFailed")):Tn:ms(q.message||e("settings.plugins.toast.reloadFailed"))}if(p&&g.mode==="file"){const W=R.current.get(D)??"";if(g.content===W)return Os;const X=await u(p.id,{content:g.content});return X.ok?(R.current.set(D,g.content),X.reloadFailed?ms(X.warning||X.message||e("settings.plugins.toast.reloadFailed")):Tn):ms(X.message||e("settings.plugins.toast.reloadFailed"))}return Os},t[28]=l,t[29]=n,t[30]=g,t[31]=D,t[32]=b,t[33]=p,t[34]=e,t[35]=m,t[36]=u,t[37]=C):C=t[37];const U=Ya(C);if(!d){let W;t[38]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(_,{name:"plug",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t[38]=W):W=t[38];let X;t[39]!==e?(X=e("settings.plugins.page.empty.select"),t[39]=e,t[40]=X):X=t[40];let J;t[41]!==X?(J=s.jsx("p",{className:"typography-body",children:X}),t[41]=X,t[42]=J):J=t[42];let q;t[43]!==e?(q=e("settings.plugins.page.empty.add"),t[43]=e,t[44]=q):q=t[44];let z;t[45]!==q?(z=s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:q}),t[45]=q,t[46]=z):z=t[46];let H;return t[47]!==J||t[48]!==z?(H=s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[W,J,z]})}),t[47]=J,t[48]=z,t[49]=H):H=t[49],H}if(b&&g&&g.mode==="entry"){let W;t[50]!==g.optionsJson?(W=Xi(g.optionsJson),t[50]=g.optionsJson,t[51]=W):W=t[51];const J=W.ok;let q;t[52]!==e?(q=e("settings.plugins.page.header.entry"),t[52]=e,t[53]=q):q=t[53];let z;t[54]!==b.scope||t[55]!==e?(z=b.scope==="project"?e("settings.plugins.sidebar.group.projectEntries"):e("settings.plugins.sidebar.group.userEntries"),t[54]=b.scope,t[55]=e,t[56]=z):z=t[56];let H;t[57]!==b.scope||t[58]!==z?(H=s.jsx(Dl,{scope:b.scope,label:z}),t[57]=b.scope,t[58]=z,t[59]=H):H=t[59];const se=U.onBlurCapture;let B;t[60]!==b.spec||t[61]!==N?(B=s.jsx(Tl,{target:N,name:b.spec}),t[60]=b.spec,t[61]=N,t[62]=B):B=t[62];let ne;t[63]!==b.id||t[64]!==b.spec?(ne=s.jsx(Kh,{entryId:b.id,spec:b.spec}),t[63]=b.id,t[64]=b.spec,t[65]=ne):ne=t[65];let K;t[66]!==B||t[67]!==ne?(K=s.jsx(qe,{divider:!1,children:s.jsxs("div",{className:"flex flex-col gap-3",children:[B,ne]})}),t[66]=B,t[67]=ne,t[68]=K):K=t[68];let Z;t[69]!==e?(Z=e("settings.plugins.page.field.spec"),t[69]=e,t[70]=Z):Z=t[70];const oe=g.spec;let ue;t[71]!==g||t[72]!==f?(ue=ye=>f({...g,spec:ye.target.value}),t[71]=g,t[72]=f,t[73]=ue):ue=t[73];let de;t[74]!==e?(de=e("settings.plugins.page.field.spec.placeholder"),t[74]=e,t[75]=de):de=t[75];let ce;t[76]!==g.spec||t[77]!==ue||t[78]!==de?(ce=s.jsx(He,{value:oe,onChange:ue,placeholder:de,className:"font-mono typography-meta",spellCheck:!1}),t[76]=g.spec,t[77]=ue,t[78]=de,t[79]=ce):ce=t[79];let Se;t[80]!==Z||t[81]!==ce?(Se=s.jsx(qe,{title:Z,settingsItem:"plugins.spec",children:ce}),t[80]=Z,t[81]=ce,t[82]=Se):Se=t[82];let re;t[83]!==e?(re=e("settings.plugins.page.field.options"),t[83]=e,t[84]=re):re=t[84];const ve=g.optionsJson;let ie;t[85]!==g||t[86]!==f?(ie=ye=>f({...g,optionsJson:ye.target.value}),t[85]=g,t[86]=f,t[87]=ie):ie=t[87];const me=!J&&"border-[var(--status-error-border)]";let ke;t[88]!==me?(ke=Pe("font-mono typography-meta min-h-[200px]",me),t[88]=me,t[89]=ke):ke=t[89];let Ae;t[90]!==g.optionsJson||t[91]!==ie||t[92]!==ke?(Ae=s.jsx(As,{value:ve,onChange:ie,rows:10,className:ke,spellCheck:!1,placeholder:"{ }"}),t[90]=g.optionsJson,t[91]=ie,t[92]=ke,t[93]=Ae):Ae=t[93];let pe;t[94]!==J||t[95]!==e?(pe=!J&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:e("settings.plugins.page.field.options.invalidJson")}),t[94]=J,t[95]=e,t[96]=pe):pe=t[96];let Le;t[97]!==re||t[98]!==Ae||t[99]!==pe?(Le=s.jsxs(qe,{title:re,settingsItem:"plugins.options",children:[Ae,pe]}),t[97]=re,t[98]=Ae,t[99]=pe,t[100]=Le):Le=t[100];let Ve;return t[101]!==U.onBlurCapture||t[102]!==H||t[103]!==K||t[104]!==Se||t[105]!==Le||t[106]!==q?(Ve=s.jsxs(ts,{title:q,titleAccessory:H,onBlurCapture:se,children:[K,Se,Le]}),t[101]=U.onBlurCapture,t[102]=H,t[103]=K,t[104]=Se,t[105]=Le,t[106]=q,t[107]=Ve):Ve=t[107],Ve}if(p&&g&&g.mode==="file"){let W;t[108]!==e?(W=e("settings.plugins.page.header.file"),t[108]=e,t[109]=W):W=t[109];let X;t[110]!==p.scope||t[111]!==e?(X=p.scope==="project"?e("settings.plugins.sidebar.group.projectFiles"):e("settings.plugins.sidebar.group.userFiles"),t[110]=p.scope,t[111]=e,t[112]=X):X=t[112];let J;t[113]!==p.scope||t[114]!==X?(J=s.jsx(Dl,{scope:p.scope,label:X}),t[113]=p.scope,t[114]=X,t[115]=J):J=t[115];let q;t[116]===Symbol.for("react.memo_cache_sentinel")?(q=Pe("typography-micro font-mono rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-foreground","border border-[var(--interactive-border)]"),t[116]=q):q=t[116];let z;t[117]!==p.fileName?(z=s.jsx("span",{className:q,children:p.fileName}),t[117]=p.fileName,t[118]=z):z=t[118];let H;t[119]!==J||t[120]!==z?(H=s.jsxs(s.Fragment,{children:[J,z]}),t[119]=J,t[120]=z,t[121]=H):H=t[121];const se=U.onBlurCapture;let B;t[122]!==p.fileName||t[123]!==y?(B=s.jsx(qe,{divider:!1,children:s.jsx(Tl,{target:y,name:p.fileName})}),t[122]=p.fileName,t[123]=y,t[124]=B):B=t[124];let ne;t[125]!==e?(ne=e("settings.plugins.page.field.content"),t[125]=e,t[126]=ne):ne=t[126];let K;t[127]!==g||t[128]!==f?(K=ce=>f({...g,content:ce.target.value}),t[127]=g,t[128]=f,t[129]=K):K=t[129];let Z;t[130]!==U?(Z=ce=>{ce.key==="Enter"&&(ce.metaKey||ce.ctrlKey)&&(ce.preventDefault(),U.requestSave())},t[130]=U,t[131]=Z):Z=t[131];let oe;t[132]!==g.content||t[133]!==T||t[134]!==K||t[135]!==Z?(oe=s.jsx(As,{value:g.content,onChange:K,onKeyDown:Z,rows:16,className:"font-mono typography-meta min-h-[320px]",spellCheck:!1,disabled:T}),t[132]=g.content,t[133]=T,t[134]=K,t[135]=Z,t[136]=oe):oe=t[136];let ue;t[137]!==ne||t[138]!==oe?(ue=s.jsx(qe,{title:ne,settingsItem:"plugins.content",children:oe}),t[137]=ne,t[138]=oe,t[139]=ue):ue=t[139];let de;return t[140]!==U.onBlurCapture||t[141]!==H||t[142]!==B||t[143]!==ue||t[144]!==W?(de=s.jsxs(ts,{title:W,titleAccessory:H,onBlurCapture:se,children:[B,ue]}),t[140]=U.onBlurCapture,t[141]=H,t[142]=B,t[143]=ue,t[144]=W,t[145]=de):de=t[145],de}let L;return t[146]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx("div",{className:"text-center text-muted-foreground",children:s.jsx(_,{name:"loader-4",className:"mx-auto mb-3 h-6 w-6 animate-spin opacity-50"})})}),t[146]=L):L=t[146],L};function Vh(t){return t.getActiveProject()?.path}function Hh(t){return t.loadedDirectory}function qh(t){return t.loadedRuntimeKey}function Gh(t){return t.selectedId}function Wh(t){return t.entries}function Jh(t){return t.files}function Qh(t){return t.draft}function Yh(t){return t.setDraft}function Zh(t){return t.updateEntry}function Xh(t){return t.updateFile}function ef(t){return t.readFile}const tf="<built-in>",ui=t=>t?.path===tf,lo=t=>!!t&&!ui(t)&&t.renamable===!0,sf=t=>{const e=tt.c(157),{onItemSelect:a}=t,{t:n}=Qe(),[r,i]=o.useState(null),[l,d]=o.useState(""),[c,h]=o.useState(null),[g,f]=o.useState(!1),[m,u]=o.useState(null),{selectedSkillName:v,setSelectedSkill:w,setSkillDraft:b,deleteSkill:k,renameSkill:p,getSkillDetail:S}=sn(Bs(nf)),N=rn();let I;e[0]!==N?(I=De=>xo(De,N),e[0]=N,e[1]=I):I=e[1];const y=sn(I),T=sn(af);let x,A;e[2]!==T||e[3]!==N?(x=()=>{T(N)},A=[T,N],e[2]=T,e[3]=N,e[4]=x,e[5]=A):(x=e[4],A=e[5]),o.useEffect(x,A);let R;e[6]!==a||e[7]!==w||e[8]!==b||e[9]!==y?(R=()=>{let De="new-skill",$e=1;for(;y.some(Y=>Y.name===De);)De=`new-skill-${$e}`,$e++;b({name:De,scope:"user",source:"opencode",description:""}),w(De),a?.()},e[6]=a,e[7]=w,e[8]=b,e[9]=y,e[10]=R):R=e[10];const P=R;let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D=async De=>{ui(De)||h(De)},e[11]=D):D=e[11];const F=D;let O;e[12]!==c||e[13]!==k||e[14]!==N||e[15]!==n?(O=async()=>{if(!c)return;if(ui(c)){h(null);return}f(!0),await k(c.name,N)?($.success(n("settings.skills.sidebar.toast.skillDeleted",{name:c.name})),h(null)):$.error(n("settings.skills.sidebar.toast.deleteSkillFailed")),f(!1)},e[12]=c,e[13]=k,e[14]=N,e[15]=n,e[16]=O):O=e[16];const C=O;let M;e[17]!==S||e[18]!==w||e[19]!==b||e[20]!==N||e[21]!==y||e[22]!==n?(M=async De=>{if(ui(De))return;const $e=De.name;let Y=1,V=`${$e}-copy`;for(;y.some(ge=>ge.name===V);)Y++,V=`${$e}-copy-${Y}`;const be=await S(De.name,N);if(!be){$.error(n("settings.skills.sidebar.toast.duplicateLoadFailed"));return}b({name:V,scope:De.scope||"user",source:De.source||"opencode",description:(be.sources.md.fields.includes("description"),""),instructions:""}),w(V)},e[17]=S,e[18]=w,e[19]=b,e[20]=N,e[21]=y,e[22]=n,e[23]=M):M=e[23];const U=M;let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=De=>{lo(De)&&(d(De.name),i(De))},e[24]=L):L=e[24];const W=L;let X;e[25]!==r||e[26]!==l||e[27]!==p||e[28]!==w||e[29]!==N||e[30]!==y||e[31]!==n?(X=async()=>{if(!r)return;if(!lo(r)){i(null);return}const De=l.trim().replace(/\s+/g,"-").toLowerCase();if(!De){$.error(n("settings.skills.page.toast.skillNameRequired"));return}if(De===r.name){i(null);return}if(y.some(Y=>Y.name===De)){$.error(n("settings.skills.page.toast.skillExists"));return}await p(r.name,De,N)?($.success(n("settings.skills.sidebar.toast.skillRenamed",{name:De})),w(De)):$.error(n("settings.skills.sidebar.toast.renameFailed")),i(null)},e[25]=r,e[26]=l,e[27]=p,e[28]=w,e[29]=N,e[30]=y,e[31]=n,e[32]=X):X=e[32];const J=X;let q;e[33]!==y?(q=y.filter(rf),e[33]=y,e[34]=q):q=e[34];const z=q;let H;e[35]!==y?(H=y.filter(of),e[35]=y,e[36]=H):H=e[36];const se=H;let B;e[37]===Symbol.for("react.memo_cache_sentinel")?(B=function($e){const Y={},V=[];for(const ge of $e)ge.group?(Y[ge.group]||(Y[ge.group]=[]),Y[ge.group].push(ge)):V.push(ge);const be=Object.keys(Y).sort(lf).map(ge=>({name:ge,skills:[...Y[ge]].sort(cf)}));return V.sort(df),{sortedGroups:be,ungrouped:V}},e[37]=B):B=e[37];const ne=B;let K;e[38]!==z?(K=ne(z),e[38]=z,e[39]=K):K=e[39];const Z=K;let oe;e[40]!==se?(oe=ne(se),e[40]=se,e[41]=oe):oe=e[41];const ue=oe;let de;e[42]===Symbol.for("react.memo_cache_sentinel")?(de=Pe("flex h-full flex-col","bg-background"),e[42]=de):de=e[42];let ce;e[43]!==n?(ce=n("settings.skills.sidebar.title"),e[43]=n,e[44]=ce):ce=e[44];let Se;e[45]!==ce?(Se=s.jsx("h2",{className:`${_n} mb-3`,children:ce}),e[45]=ce,e[46]=Se):Se=e[46];let re;e[47]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(xi,{className:"mb-3"}),e[47]=re):re=e[47];let ve;e[48]!==y.length||e[49]!==n?(ve=n("settings.skills.sidebar.total",{count:y.length}),e[48]=y.length,e[49]=n,e[50]=ve):ve=e[50];let ie;e[51]!==ve?(ie=s.jsx("span",{className:"typography-meta text-muted-foreground",children:ve}),e[51]=ve,e[52]=ie):ie=e[52];let me;e[53]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),e[53]=me):me=e[53];let ke;e[54]!==P?(ke=s.jsx(G,{size:"sm","data-settings-item":"skills.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:P,children:me}),e[54]=P,e[55]=ke):ke=e[55];let Ae;e[56]!==ie||e[57]!==ke?(Ae=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ie,ke]}),e[56]=ie,e[57]=ke,e[58]=Ae):Ae=e[58];let pe;e[59]!==Se||e[60]!==Ae?(pe=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[Se,re,Ae]}),e[59]=Se,e[60]=Ae,e[61]=pe):pe=e[61];let Le;e[62]!==Z||e[63]!==ue||e[64]!==U||e[65]!==a||e[66]!==m||e[67]!==z||e[68]!==v||e[69]!==w||e[70]!==y.length||e[71]!==n||e[72]!==se?(Le=s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:y.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.skills.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.skills.sidebar.empty.description")})]}):s.jsxs(s.Fragment,{children:[z.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.skills.sidebar.section.project")}),Z.sortedGroups.map(De=>{const{name:$e,skills:Y}=De;return s.jsx(io,{label:$e,count:Y.length,storageKey:"project-skills",children:Y.map(V=>s.jsx(Li,{skill:V,isSelected:v===V.name,onSelect:()=>{w(V.name),a?.()},onRename:()=>W(V),onDelete:()=>F(V),onDuplicate:()=>U(V),isMenuOpen:m===V.name,onMenuOpenChange:be=>u(be?V.name:null)},V.name))},$e)}),Z.ungrouped.map(De=>s.jsx(Li,{skill:De,isSelected:v===De.name,onSelect:()=>{w(De.name),a?.()},onRename:()=>W(De),onDelete:()=>F(De),onDuplicate:()=>U(De),isMenuOpen:m===De.name,onMenuOpenChange:$e=>u($e?De.name:null)},De.name))]}),se.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.skills.sidebar.section.user")}),ue.sortedGroups.map(De=>{const{name:$e,skills:Y}=De;return s.jsx(io,{label:$e,count:Y.length,storageKey:"user-skills",children:Y.map(V=>s.jsx(Li,{skill:V,isSelected:v===V.name,onSelect:()=>{w(V.name),a?.()},onRename:()=>W(V),onDelete:()=>F(V),onDuplicate:()=>U(V),isMenuOpen:m===V.name,onMenuOpenChange:be=>u(be?V.name:null)},V.name))},$e)}),ue.ungrouped.map(De=>s.jsx(Li,{skill:De,isSelected:v===De.name,onSelect:()=>{w(De.name),a?.()},onRename:()=>W(De),onDelete:()=>F(De),onDuplicate:()=>U(De),isMenuOpen:m===De.name,onMenuOpenChange:$e=>u($e?De.name:null)},De.name))]})]})}),e[62]=Z,e[63]=ue,e[64]=U,e[65]=a,e[66]=m,e[67]=z,e[68]=v,e[69]=w,e[70]=y.length,e[71]=n,e[72]=se,e[73]=Le):Le=e[73];const Ve=c!==null;let ye;e[74]!==g?(ye=De=>{!De&&!g&&h(null)},e[74]=g,e[75]=ye):ye=e[75];let Te;e[76]!==n?(Te=n("settings.skills.sidebar.deleteDialog.title"),e[76]=n,e[77]=Te):Te=e[77];let ee;e[78]!==Te?(ee=s.jsx(Ht,{children:Te}),e[78]=Te,e[79]=ee):ee=e[79];const ae=c?.name??"";let fe;e[80]!==n||e[81]!==ae?(fe=n("settings.skills.sidebar.deleteDialog.description",{name:ae}),e[80]=n,e[81]=ae,e[82]=fe):fe=e[82];let je;e[83]!==fe?(je=s.jsx(qt,{children:fe}),e[83]=fe,e[84]=je):je=e[84];let Re;e[85]!==ee||e[86]!==je?(Re=s.jsxs(Vt,{children:[ee,je]}),e[85]=ee,e[86]=je,e[87]=Re):Re=e[87];let Ce;e[88]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>h(null),e[88]=Ce):Ce=e[88];let _e;e[89]!==n?(_e=n("settings.common.actions.cancel"),e[89]=n,e[90]=_e):_e=e[90];let Ke;e[91]!==g||e[92]!==_e?(Ke=s.jsx(G,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:Ce,disabled:g,children:_e}),e[91]=g,e[92]=_e,e[93]=Ke):Ke=e[93];let Fe;e[94]!==n?(Fe=n("settings.common.actions.delete"),e[94]=n,e[95]=Fe):Fe=e[95];let Me;e[96]!==C||e[97]!==g||e[98]!==Fe?(Me=s.jsx(G,{size:"sm",onClick:C,disabled:g,children:Fe}),e[96]=C,e[97]=g,e[98]=Fe,e[99]=Me):Me=e[99];let at;e[100]!==Ke||e[101]!==Me?(at=s.jsxs(as,{children:[Ke,Me]}),e[100]=Ke,e[101]=Me,e[102]=at):at=e[102];let pt;e[103]!==Re||e[104]!==at?(pt=s.jsxs(_t,{className:"max-w-md",children:[Re,at]}),e[103]=Re,e[104]=at,e[105]=pt):pt=e[105];let ot;e[106]!==Ve||e[107]!==ye||e[108]!==pt?(ot=s.jsx(Ut,{open:Ve,onOpenChange:ye,children:pt}),e[106]=Ve,e[107]=ye,e[108]=pt,e[109]=ot):ot=e[109];const mt=r!==null;let ht;e[110]===Symbol.for("react.memo_cache_sentinel")?(ht=De=>!De&&i(null),e[110]=ht):ht=e[110];let Oe;e[111]!==n?(Oe=n("settings.skills.sidebar.renameDialog.title"),e[111]=n,e[112]=Oe):Oe=e[112];let nt;e[113]!==Oe?(nt=s.jsx(Ht,{children:Oe}),e[113]=Oe,e[114]=nt):nt=e[114];const lt=r?.name??"";let we;e[115]!==n||e[116]!==lt?(we=n("settings.skills.sidebar.renameDialog.description",{name:lt}),e[115]=n,e[116]=lt,e[117]=we):we=e[117];let Je;e[118]!==we?(Je=s.jsx(qt,{children:we}),e[118]=we,e[119]=Je):Je=e[119];let Ye;e[120]!==nt||e[121]!==Je?(Ye=s.jsxs(Vt,{children:[nt,Je]}),e[120]=nt,e[121]=Je,e[122]=Ye):Ye=e[122];let ze;e[123]===Symbol.for("react.memo_cache_sentinel")?(ze=De=>d(De.target.value),e[123]=ze):ze=e[123];let Ge;e[124]!==n?(Ge=n("settings.skills.sidebar.renameDialog.placeholder"),e[124]=n,e[125]=Ge):Ge=e[125];let Q;e[126]!==J?(Q=De=>{De.key==="Enter"&&J()},e[126]=J,e[127]=Q):Q=e[127];let Ue;e[128]!==l||e[129]!==Ge||e[130]!==Q?(Ue=s.jsx(He,{value:l,onChange:ze,placeholder:Ge,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:Q}),e[128]=l,e[129]=Ge,e[130]=Q,e[131]=Ue):Ue=e[131];let st;e[132]===Symbol.for("react.memo_cache_sentinel")?(st=()=>i(null),e[132]=st):st=e[132];let dt;e[133]!==n?(dt=n("settings.common.actions.cancel"),e[133]=n,e[134]=dt):dt=e[134];let ct;e[135]!==dt?(ct=s.jsx(G,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:st,children:dt}),e[135]=dt,e[136]=ct):ct=e[136];let ft;e[137]!==n?(ft=n("settings.common.actions.rename"),e[137]=n,e[138]=ft):ft=e[138];let kt;e[139]!==J||e[140]!==ft?(kt=s.jsx(G,{size:"sm",onClick:J,children:ft}),e[139]=J,e[140]=ft,e[141]=kt):kt=e[141];let bt;e[142]!==ct||e[143]!==kt?(bt=s.jsxs(as,{children:[ct,kt]}),e[142]=ct,e[143]=kt,e[144]=bt):bt=e[144];let vt;e[145]!==Ye||e[146]!==Ue||e[147]!==bt?(vt=s.jsxs(_t,{children:[Ye,Ue,bt]}),e[145]=Ye,e[146]=Ue,e[147]=bt,e[148]=vt):vt=e[148];let Xe;e[149]!==mt||e[150]!==vt?(Xe=s.jsx(Ut,{open:mt,onOpenChange:ht,children:vt}),e[149]=mt,e[150]=vt,e[151]=Xe):Xe=e[151];let jt;return e[152]!==pe||e[153]!==Le||e[154]!==ot||e[155]!==Xe?(jt=s.jsxs("div",{className:de,children:[pe,Le,ot,Xe]}),e[152]=pe,e[153]=Le,e[154]=ot,e[155]=Xe,e[156]=jt):jt=e[156],jt},Li=t=>{const e=tt.c(41),{skill:a,isSelected:n,onSelect:r,onDelete:i,onRename:l,onDuplicate:d,isMenuOpen:c,onMenuOpenChange:h}=t,{t:g}=Qe();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=pi(),e[0]=f):f=e[0];const m=f;let u;e[1]!==a?(u=ui(a),e[1]=a,e[2]=u):u=e[2];const v=u;let w;e[3]!==a?(w=lo(a),e[3]=a,e[4]=w):w=e[4];const b=w,[k,p]=o.useState(!1);let S;e[5]!==b||e[6]!==i||e[7]!==d||e[8]!==l||e[9]!==g?(S=U=>s.jsxs(s.Fragment,{children:[b?s.jsxs(U,{onClick:L=>{L.stopPropagation(),l()},children:[s.jsx(_,{name:"edit",className:"h-4 w-4 mr-px"}),g("settings.common.actions.rename")]}):null,s.jsxs(U,{onClick:L=>{L.stopPropagation(),d()},children:[s.jsx(_,{name:"file-copy",className:"h-4 w-4 mr-px"}),g("settings.common.actions.duplicate")]}),s.jsxs(U,{onClick:L=>{L.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),g("settings.common.actions.delete")]})]}),e[5]=b,e[6]=i,e[7]=d,e[8]=l,e[9]=g,e[10]=S):S=e[10];const N=S,I=!v&&k,y=n?"bg-interactive-selection":"hover:bg-interactive-hover";let T;e[11]!==y?(T=Pe("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",y),e[11]=y,e[12]=T):T=e[12];let x;e[13]!==v?(x=!m&&!v?U=>{U.preventDefault(),p(!0)}:void 0,e[13]=v,e[14]=x):x=e[14];let A;e[15]!==T||e[16]!==x?(A=s.jsx("div",{className:T,onContextMenu:x}),e[15]=T,e[16]=x,e[17]=A):A=e[17];let R;e[18]!==a.name?(R=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name})}),e[18]=a.name,e[19]=R):R=e[19];let P;e[20]!==r||e[21]!==R?(P=s.jsx("button",{onClick:r,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-ring",tabIndex:0,children:R}),e[20]=r,e[21]=R,e[22]=P):P=e[22];let D;e[23]!==v||e[24]!==c||e[25]!==h||e[26]!==N?(D=v?null:s.jsxs(Sn,{open:c,onOpenChange:U=>{U&&p(!1),h(U)},children:[s.jsx(Nn,{asChild:!0,children:s.jsx(G,{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:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(kn,{align:"end",className:"w-fit min-w-20",children:N(an)})]}),e[23]=v,e[24]=c,e[25]=h,e[26]=N,e[27]=D):D=e[27];let F;e[28]!==P||e[29]!==D?(F=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[P,D]}),e[28]=P,e[29]=D,e[30]=F):F=e[30];let O;e[31]!==F||e[32]!==A?(O=s.jsx(ga,{render:A,children:F}),e[31]=F,e[32]=A,e[33]=O):O=e[33];let C;e[34]!==v||e[35]!==N?(C=v?null:s.jsx(ma,{className:"w-fit min-w-20",children:N(pa)}),e[34]=v,e[35]=N,e[36]=C):C=e[36];let M;return e[37]!==O||e[38]!==C||e[39]!==I?(M=s.jsxs(ha,{open:I,onOpenChange:p,children:[O,C]}),e[37]=O,e[38]=C,e[39]=I,e[40]=M):M=e[40],M};function nf(t){return{selectedSkillName:t.selectedSkillName,setSelectedSkill:t.setSelectedSkill,setSkillDraft:t.setSkillDraft,deleteSkill:t.deleteSkill,renameSkill:t.renameSkill,getSkillDetail:t.getSkillDetail}}function af(t){return t.loadSkills}function rf(t){return t.scope==="project"}function of(t){return t.scope==="user"}function lf(t,e){return t.localeCompare(e)}function cf(t,e){return t.name.localeCompare(e.name)}function df(t,e){return t.name.localeCompare(e.name)}const uf=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,mf=t=>{const e=t.trim(),a=e.startsWith("https://")?"https":e.startsWith("git@")?"ssh":"shorthand";if(a==="ssh")return`${e.split(":")[1].replace(/\.git$/i,"")}`;if(a==="https")return e.split("/").slice(3).filter(Boolean).join("/").replace(/\.git$/i,"");const n=e.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return n?`${n[1]}/${n[2].replace(/\.git$/i,"")}`:e},pf=({open:t,onOpenChange:e})=>{const{t:a}=Qe(),n=Ln(C=>C.scanRepo),r=Ln(C=>C.loadCatalog),i=Ln(C=>C.loadSource),l=Ln(C=>C.setSelectedSource),d=Ln(C=>C.isScanning),c=oa(C=>C.defaultGitIdentityId),h=oa(C=>C.loadDefaultGitIdentityId),[g,f]=o.useState(""),[m,u]=o.useState(""),[v,w]=o.useState(""),[b,k]=o.useState(null),[p,S]=o.useState(null),[N,I]=o.useState(!1),[y,T]=o.useState([]),[x,A]=o.useState(null),R=o.useRef(0),P=o.useCallback(C=>{R.current+=1,I(!1),S(null),C?.clearIdentity&&(T([]),A(null))},[]);o.useEffect(()=>{t&&(R.current+=1,f(""),u(""),w(""),S(null),I(!1),T([]),A(null),h(),k(null),(async()=>{const C=await En();k(C?C.skillCatalogs??[]:null)})())},[t,h]);const D=o.useMemo(()=>{const C=m.trim(),M=v.trim();return(b??[]).some(U=>{const L=(U.source||"").trim(),W=(U.subpath||"").trim();return L===C&&W===M})},[b,m,v]),F=async()=>{const C=m.trim();if(!C){$.error(a("settings.skills.catalog.add.toast.repositoryRequired"));return}g.trim()||f(mf(C)),I(!1),S(null);const M=R.current+1;R.current=M;const U=await n({source:C,subpath:v.trim()||void 0,gitIdentityId:x||void 0});if(R.current!==M)return;if(!U.ok){if(U.error?.kind==="authRequired"){if(fs()){$.error(a("settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode"));return}const W=U.error.identities||[];if(T(W),!x&&W.length>0){const X=c&&c!=="global"&&W.some(J=>J.id===c)?c:W[0].id;A(X)}$.error(a("settings.skills.catalog.add.toast.authenticationRequiredScan"));return}$.error(U.error?.message||a("settings.skills.catalog.add.toast.scanFailed"));return}const L=U.items?.length||0;if(S(L),L===0){$.error(a("settings.skills.catalog.add.toast.noSkillsFound")),I(!1);return}T([]),I(!0),$.success(a("settings.skills.catalog.shared.toast.foundSkills",{count:L}))},O=async()=>{const C=g.trim(),M=m.trim(),U=v.trim();if(!C){$.error(a("settings.skills.catalog.add.toast.catalogNameRequired"));return}if(!M){$.error(a("settings.skills.catalog.add.toast.repositoryRequired"));return}if(!N){$.error(a("settings.skills.catalog.add.toast.scanBeforeAdd"));return}if(D){$.error(a("settings.skills.catalog.add.toast.catalogAlreadyExists"));return}const L={id:uf(),label:C,source:M,...U?{subpath:U}:{},...x?{gitIdentityId:x}:{}};if(b===null){$.error(a("settings.skills.catalog.add.toast.saveFailed"));return}const W=[...b,L];try{if(!(await xt({skillCatalogs:W})).ok)throw new Error(a("settings.skills.catalog.add.toast.saveFailed"));k(W),$.success(a("settings.skills.catalog.add.toast.catalogAdded")),await r({refresh:!0}),await i(L.id,{refresh:!0}),l(L.id),e(!1)}catch(X){$.error(X instanceof Error?X.message:a("settings.skills.catalog.add.toast.saveFailed"))}};return s.jsx(Ut,{open:t,onOpenChange:e,children:s.jsxs(_t,{className:"max-w-xl",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:a("settings.skills.catalog.add.title")}),s.jsxs(qt,{children:[a("settings.skills.catalog.add.descriptionPrefix")," ",s.jsx("code",{className:"font-mono",children:"SKILL.md"}),a("settings.skills.catalog.add.descriptionSuffix")]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:a("settings.skills.catalog.add.field.catalogName")}),s.jsx(He,{value:g,onChange:C=>f(C.target.value),placeholder:a("settings.skills.catalog.add.field.catalogNamePlaceholder")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:a("settings.skills.catalog.add.field.repository")}),s.jsx(Gt,{children:a("settings.skills.catalog.add.field.repositoryHint")})]}),s.jsx(He,{value:m,onChange:C=>{u(C.target.value),P({clearIdentity:!0})},placeholder:a("settings.skills.catalog.shared.field.repositoryPlaceholder")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:a("settings.skills.catalog.add.field.optionalSubpath")}),s.jsx(He,{value:v,onChange:C=>{w(C.target.value),P({clearIdentity:!0})},placeholder:a("settings.skills.catalog.shared.field.subpathPlaceholder")})]}),y.length>0&&!fs()?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-[var(--status-warning)]",children:a("settings.skills.catalog.shared.auth.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground ml-2",children:a("settings.skills.catalog.shared.auth.description")}),s.jsx(Gt,{className:"ml-1",children:a("settings.skills.catalog.shared.auth.footerHint")})]}),s.jsxs(Et,{value:x||"",onValueChange:C=>{A(C),P()},children:[s.jsx(At,{className:"w-fit",children:s.jsx("span",{children:y.find(C=>C.id===x)?.name||a("settings.skills.catalog.shared.auth.chooseIdentity")})}),s.jsx(Tt,{align:"start",children:y.map(C=>s.jsx(ut,{value:C.id,children:C.name},C.id))})]})]}):null,p!==null?s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("settings.skills.catalog.add.scanResult",{count:p})}):null,D?s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("settings.skills.catalog.add.duplicateMessage")}):null]}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:a("settings.common.actions.cancel")}),s.jsxs(G,{size:"sm",className:"gap-2",variant:"ghost",onClick:()=>{F()},disabled:d||!m.trim(),children:[s.jsx(_,{name:"git-repository",className:"h-4 w-4"}),a(d?"settings.skills.catalog.shared.actions.scanning":"settings.skills.catalog.shared.actions.scan")]}),s.jsx(G,{size:"sm",onClick:()=>{O()},disabled:!N||D||b===null||!g.trim()||!m.trim(),children:a("settings.skills.catalog.add.actions.addCatalog")})]})]})})},gf=t=>{const e=tt.c(85),{open:a,onOpenChange:n,conflicts:r,onConfirm:i}=t,{t:l}=Qe();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const[c,h]=o.useState(d);let g,f;e[1]!==r||e[2]!==a?(g=()=>{if(!a)return;const K={};for(const Z of r)K[Z.skillName]="skip";h(K)},f=[a,r],e[1]=r,e[2]=a,e[3]=g,e[4]=f):(g=e[3],f=e[4]),o.useEffect(g,f);let m;e[5]!==r?(m=K=>{const Z={};for(const oe of r)Z[oe.skillName]=K;h(Z)},e[5]=r,e[6]=m):m=e[6];const u=m;let v;e[7]!==r||e[8]!==c?(v=r.length>0&&r.every(K=>c[K.skillName]),e[7]=r,e[8]=c,e[9]=v):v=e[9];const w=v;let b;e[10]!==l?(b=l("settings.skills.catalog.conflicts.title"),e[10]=l,e[11]=b):b=e[11];let k;e[12]!==b?(k=s.jsx(Ht,{children:b}),e[12]=b,e[13]=k):k=e[13];let p;e[14]!==l?(p=l("settings.skills.catalog.conflicts.description"),e[14]=l,e[15]=p):p=e[15];let S;e[16]!==p?(S=s.jsx(qt,{children:p}),e[16]=p,e[17]=S):S=e[17];let N;e[18]!==k||e[19]!==S?(N=s.jsxs(Vt,{children:[k,S]}),e[18]=k,e[19]=S,e[20]=N):N=e[20];let I;e[21]!==r.length||e[22]!==l?(I=l("settings.skills.catalog.conflicts.count",{count:r.length}),e[21]=r.length,e[22]=l,e[23]=I):I=e[23];let y;e[24]!==I?(y=s.jsx("span",{className:"typography-meta text-muted-foreground",children:I}),e[24]=I,e[25]=y):y=e[25];let T;e[26]!==u?(T=()=>u("skip"),e[26]=u,e[27]=T):T=e[27];let x;e[28]!==l?(x=l("settings.skills.catalog.conflicts.actions.skipAll"),e[28]=l,e[29]=x):x=e[29];let A;e[30]!==T||e[31]!==x?(A=s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:T,children:x}),e[30]=T,e[31]=x,e[32]=A):A=e[32];let R;e[33]!==u?(R=()=>u("overwrite"),e[33]=u,e[34]=R):R=e[34];let P;e[35]!==l?(P=l("settings.skills.catalog.conflicts.actions.overwriteAll"),e[35]=l,e[36]=P):P=e[36];let D;e[37]!==R||e[38]!==P?(D=s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:R,children:P}),e[37]=R,e[38]=P,e[39]=D):D=e[39];let F;e[40]!==A||e[41]!==D?(F=s.jsxs("div",{className:"flex items-center gap-2",children:[A,D]}),e[40]=A,e[41]=D,e[42]=F):F=e[42];let O;e[43]!==y||e[44]!==F?(O=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y,F]}),e[43]=y,e[44]=F,e[45]=O):O=e[45];let C;if(e[46]!==r||e[47]!==c||e[48]!==l){let K;e[50]!==c||e[51]!==l?(K=Z=>s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label truncate",children:Z.skillName}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:l("settings.skills.catalog.conflicts.installedIn",{scope:Z.scope==="project"?l("settings.skills.catalog.conflicts.scope.project"):l("settings.skills.catalog.conflicts.scope.user"),source:Z.source==="agents"?l("settings.skills.catalog.conflicts.source.agents"):l("settings.skills.catalog.conflicts.source.opencode")})})]}),s.jsxs(Et,{value:c[Z.skillName]||"skip",onValueChange:oe=>h(ue=>({...ue,[Z.skillName]:oe})),children:[s.jsx(At,{className:"w-fit",children:s.jsx("span",{className:"capitalize",children:(c[Z.skillName]||"skip")==="overwrite"?l("settings.skills.catalog.conflicts.decision.overwrite"):l("settings.skills.catalog.conflicts.decision.skip")})}),s.jsxs(Tt,{align:"end",children:[s.jsx(ut,{value:"skip",className:"pr-2 [&>span:first-child]:hidden",children:l("settings.skills.catalog.conflicts.decision.skip")}),s.jsx(ut,{value:"overwrite",className:"pr-2 [&>span:first-child]:hidden",children:l("settings.skills.catalog.conflicts.decision.overwrite")})]})]})]},Z.skillName),e[50]=c,e[51]=l,e[52]=K):K=e[52],C=r.map(K),e[46]=r,e[47]=c,e[48]=l,e[49]=C}else C=e[49];let M;e[53]!==C?(M=s.jsx("div",{className:"space-y-2",children:C}),e[53]=C,e[54]=M):M=e[54];let U;e[55]!==O||e[56]!==M?(U=s.jsxs("div",{className:"space-y-3",children:[O,M]}),e[55]=O,e[56]=M,e[57]=U):U=e[57];let L;e[58]!==n?(L=()=>n(!1),e[58]=n,e[59]=L):L=e[59];let W;e[60]!==l?(W=l("settings.common.actions.cancel"),e[60]=l,e[61]=W):W=e[61];let X;e[62]!==L||e[63]!==W?(X=s.jsx(G,{size:"sm",variant:"ghost",onClick:L,children:W}),e[62]=L,e[63]=W,e[64]=X):X=e[64];let J;e[65]!==c||e[66]!==i?(J=()=>i(c),e[65]=c,e[66]=i,e[67]=J):J=e[67];const q=!w;let z;e[68]!==l?(z=l("settings.skills.catalog.conflicts.actions.continue"),e[68]=l,e[69]=z):z=e[69];let H;e[70]!==J||e[71]!==q||e[72]!==z?(H=s.jsx(G,{size:"sm",onClick:J,disabled:q,children:z}),e[70]=J,e[71]=q,e[72]=z,e[73]=H):H=e[73];let se;e[74]!==X||e[75]!==H?(se=s.jsxs(as,{children:[X,H]}),e[74]=X,e[75]=H,e[76]=se):se=e[76];let B;e[77]!==N||e[78]!==U||e[79]!==se?(B=s.jsxs(_t,{className:"max-w-2xl",children:[N,U,se]}),e[77]=N,e[78]=U,e[79]=se,e[80]=B):B=e[80];let ne;return e[81]!==n||e[82]!==a||e[83]!==B?(ne=s.jsx(Ut,{open:a,onOpenChange:n,children:B}),e[81]=n,e[82]=a,e[83]=B,e[84]=ne):ne=e[84],ne},Do=[{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 mi(t,e){return t==="project"&&e==="claude"?"project-claude":t==="project"&&e==="agents"?"project-agents":e==="claude"?"user-claude":t==="project"?"project-opencode":e==="agents"?"user-agents":"user-opencode"}function cd(t){if(t==="user-claude")return{scope:"user",source:"claude"};if(t==="project-claude")return{scope:"project",source:"claude"};const e=Do.find(a=>a.value===t);return e?{scope:e.scope,source:e.source}:{scope:"user",source:"opencode"}}const hf=t=>{const e=tt.c(124),{open:a,onOpenChange:n,item:r}=t,{t:i}=Qe(),l=Ln(ff),d=Ln(xf),[c,h]=o.useState("user"),[g,f]=o.useState("opencode"),m=pn(bf),u=pn(vf),[v,w]=o.useState(null),[b,k]=o.useState(!1);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[0]=p):p=e[0];const[S,N]=o.useState(p),[I,y]=o.useState(null);let T,x;e[1]!==u||e[2]!==a?(T=()=>{a&&(h("user"),f("opencode"),w(u),k(!1),N([]),y(null))},x=[a,u],e[1]=u,e[2]=a,e[3]=T,e[4]=x):(T=e[3],x=e[4]),o.useEffect(T,x);let A;e[5]!==i?(A=Me=>{switch(Me){case"project-opencode":return i("settings.skills.location.option.projectOpencode.label");case"user-agents":return i("settings.skills.location.option.userAgents.label");case"project-agents":return i("settings.skills.location.option.projectAgents.label");default:return i("settings.skills.location.option.userOpencode.label")}},e[5]=i,e[6]=A):A=e[6];const R=A;let P;e[7]!==i?(P=Me=>{switch(Me){case"project-opencode":return i("settings.skills.location.option.projectOpencode.description");case"user-agents":return i("settings.skills.location.option.userAgents.description");case"project-agents":return i("settings.skills.location.option.projectAgents.description");default:return i("settings.skills.location.option.userOpencode.description")}},e[7]=i,e[8]=P):P=e[8];const D=P;let F;e:{if(m.length===0){F=null;break e}if(v&&m.some(Me=>Me.id===v)){F=v;break e}if(u&&m.some(Me=>Me.id===u)){F=u;break e}F=m[0]?.id??null}const O=F;let C;e:{if(c!=="project"){C=null;break e}const Me=O;if(!Me){C=null;break e}let at;if(e[9]!==Me||e[10]!==m){let ot;e[12]!==Me?(ot=mt=>mt.id===Me,e[12]=Me,e[13]=ot):ot=e[13],at=m.find(ot),e[9]=Me,e[10]=m,e[11]=at}else at=e[11];C=at?.path??null}const M=C;let U;e[14]!==l||e[15]!==r?.gitIdentityId||e[16]!==n||e[17]!==i?(U=async Me=>{const at=await l({source:Me.source,subpath:Me.subpath,gitIdentityId:r?.gitIdentityId,scope:Me.scope,targetSource:Me.targetSource,selections:[{skillDir:Me.skillDir}],conflictPolicy:"prompt",conflictDecisions:Me.conflictDecisions},{directory:Me.directoryOverride??null});if(at.ok){$.success(i("settings.skills.catalog.installSkill.toast.installed")),n(!1);return}if(at.error?.kind==="conflicts"){y({source:Me.source,subpath:Me.subpath,scope:Me.scope,targetSource:Me.targetSource,skillDir:Me.skillDir,directoryOverride:Me.directoryOverride??null}),N(at.error.conflicts),k(!0);return}if(at.error?.kind==="authRequired"){$.error(at.error.message||i("settings.skills.catalog.installSkill.toast.authRequired"));return}$.error(at.error?.message||i("settings.skills.catalog.installSkill.toast.installFailed"))},e[14]=l,e[15]=r?.gitIdentityId,e[16]=n,e[17]=i,e[18]=U):U=e[18];const L=U;if(!r)return null;let W;e[19]!==i?(W=i("settings.skills.catalog.installSkill.title"),e[19]=i,e[20]=W):W=e[20];let X;e[21]!==W?(X=s.jsx(Ht,{children:W}),e[21]=W,e[22]=X):X=e[22];let J;e[23]!==i?(J=i("settings.skills.catalog.installSkill.descriptionPrefix"),e[23]=i,e[24]=J):J=e[24];let q;e[25]!==r.skillName?(q=s.jsx("span",{className:"font-semibold text-foreground",children:r.skillName}),e[25]=r.skillName,e[26]=q):q=e[26];let z;e[27]!==i?(z=i("settings.skills.catalog.installSkill.descriptionSuffix"),e[27]=i,e[28]=z):z=e[28];let H;e[29]!==J||e[30]!==q||e[31]!==z?(H=s.jsxs(qt,{children:[J," ",q," ",z]}),e[29]=J,e[30]=q,e[31]=z,e[32]=H):H=e[32];let se;e[33]!==X||e[34]!==H?(se=s.jsxs(Vt,{children:[X,H]}),e[33]=X,e[34]=H,e[35]=se):se=e[35];let B;e[36]!==i?(B=i("settings.skills.catalog.installSkill.field.destination"),e[36]=i,e[37]=B):B=e[37];let ne;e[38]!==B?(ne=s.jsx("span",{className:"typography-ui-label text-foreground",children:B}),e[38]=B,e[39]=ne):ne=e[39];let K;e[40]!==c||e[41]!==g?(K=mi(c,g),e[40]=c,e[41]=g,e[42]=K):K=e[42];let Z;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=Me=>{const at=cd(Me);h(at.scope),f(at.source==="agents"?"agents":"opencode")},e[43]=Z):Z=e[43];let oe;e[44]!==c?(oe=c==="user"?s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),e[44]=c,e[45]=oe):oe=e[45];let ue;e[46]!==g?(ue=g==="agents"?s.jsx(_,{name:"robot-2",className:"h-3.5 w-3.5"}):null,e[46]=g,e[47]=ue):ue=e[47];let de;e[48]!==R||e[49]!==c||e[50]!==g?(de=R(mi(c,g)),e[48]=R,e[49]=c,e[50]=g,e[51]=de):de=e[51];let ce;e[52]!==de?(ce=s.jsx("span",{children:de}),e[52]=de,e[53]=ce):ce=e[53];let Se;e[54]!==oe||e[55]!==ue||e[56]!==ce?(Se=s.jsxs(At,{className:"w-fit gap-1.5",children:[oe,ue,ce]}),e[54]=oe,e[55]=ue,e[56]=ce,e[57]=Se):Se=e[57];let re;e[58]!==D||e[59]!==R?(re=Do.map(Me=>s.jsx(ut,{value:Me.value,className:"pr-2 [&>span:first-child]:hidden",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Me.scope==="user"?s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),Me.source==="agents"?s.jsx(_,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:R(Me.value)})]}),s.jsx("span",{className:"typography-micro text-muted-foreground ml-5",children:D(Me.value)})]})},Me.value)),e[58]=D,e[59]=R,e[60]=re):re=e[60];let ve;e[61]!==re?(ve=s.jsx(Tt,{align:"start",children:re}),e[61]=re,e[62]=ve):ve=e[62];let ie;e[63]!==K||e[64]!==Se||e[65]!==ve?(ie=s.jsxs(Et,{value:K,onValueChange:Z,children:[Se,ve]}),e[63]=K,e[64]=Se,e[65]=ve,e[66]=ie):ie=e[66];let me;e[67]!==ne||e[68]!==ie?(me=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ne,ie]}),e[67]=ne,e[68]=ie,e[69]=me):me=e[69];let ke;e[70]!==m||e[71]!==O||e[72]!==c||e[73]!==i?(ke=c==="project"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.skills.catalog.installSkill.field.project")}),m.length===0?s.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.skills.catalog.installSkill.field.noProjects")}):s.jsxs(Et,{value:O??"",onValueChange:Me=>w(Me),disabled:m.length===1,children:[s.jsx(At,{className:"w-fit",children:s.jsx($t,{placeholder:i("settings.skills.catalog.installSkill.field.chooseProjectPlaceholder")})}),s.jsx(Tt,{align:"start",children:m.map(yf)})]})]}),e[70]=m,e[71]=O,e[72]=c,e[73]=i,e[74]=ke):ke=e[74];let Ae;e[75]!==r.warnings?(Ae=r.warnings?.length?s.jsx("div",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded",children:r.warnings.join(" · ")}):null,e[75]=r.warnings,e[76]=Ae):Ae=e[76];let pe;e[77]!==me||e[78]!==ke||e[79]!==Ae?(pe=s.jsxs("div",{className:"mt-2 space-y-3",children:[me,ke,Ae]}),e[77]=me,e[78]=ke,e[79]=Ae,e[80]=pe):pe=e[80];let Le;e[81]!==n?(Le=()=>n(!1),e[81]=n,e[82]=Le):Le=e[82];let Ve;e[83]!==i?(Ve=i("settings.common.actions.cancel"),e[83]=i,e[84]=Ve):Ve=e[84];let ye;e[85]!==Le||e[86]!==Ve?(ye=s.jsx(G,{size:"sm",variant:"ghost",onClick:Le,children:Ve}),e[85]=Le,e[86]=Ve,e[87]=ye):ye=e[87];const Te=d||!r.installable||c==="project"&&!M;let ee;e[88]!==M||e[89]!==L||e[90]!==r.repoSource||e[91]!==r.repoSubpath||e[92]!==r.skillDir||e[93]!==c||e[94]!==g?(ee=()=>{L({source:r.repoSource,subpath:r.repoSubpath,scope:c,targetSource:g,skillDir:r.skillDir,directoryOverride:M})},e[88]=M,e[89]=L,e[90]=r.repoSource,e[91]=r.repoSubpath,e[92]=r.skillDir,e[93]=c,e[94]=g,e[95]=ee):ee=e[95];let ae;e[96]!==d||e[97]!==i?(ae=i(d?"settings.skills.catalog.installSkill.actions.installing":"settings.skills.catalog.installSkill.actions.install"),e[96]=d,e[97]=i,e[98]=ae):ae=e[98];let fe;e[99]!==Te||e[100]!==ee||e[101]!==ae?(fe=s.jsx(G,{size:"sm",disabled:Te,onClick:ee,children:ae}),e[99]=Te,e[100]=ee,e[101]=ae,e[102]=fe):fe=e[102];let je;e[103]!==ye||e[104]!==fe?(je=s.jsxs(as,{children:[ye,fe]}),e[103]=ye,e[104]=fe,e[105]=je):je=e[105];let Re;e[106]!==se||e[107]!==pe||e[108]!==je?(Re=s.jsxs(_t,{className:"max-w-md",children:[se,pe,je]}),e[106]=se,e[107]=pe,e[108]=je,e[109]=Re):Re=e[109];let Ce;e[110]!==n||e[111]!==a||e[112]!==Re?(Ce=s.jsx(Ut,{open:a,onOpenChange:n,children:Re}),e[110]=n,e[111]=a,e[112]=Re,e[113]=Ce):Ce=e[113];let _e;e[114]!==I||e[115]!==L?(_e=Me=>{I&&(L({source:I.source,subpath:I.subpath,scope:I.scope,targetSource:I.targetSource,skillDir:I.skillDir,conflictDecisions:Me,directoryOverride:I.directoryOverride??null}),k(!1))},e[114]=I,e[115]=L,e[116]=_e):_e=e[116];let Ke;e[117]!==S||e[118]!==b||e[119]!==_e?(Ke=s.jsx(gf,{open:b,onOpenChange:k,conflicts:S,onConfirm:_e}),e[117]=S,e[118]=b,e[119]=_e,e[120]=Ke):Ke=e[120];let Fe;return e[121]!==Ce||e[122]!==Ke?(Fe=s.jsxs(s.Fragment,{children:[Ce,Ke]}),e[121]=Ce,e[122]=Ke,e[123]=Fe):Fe=e[123],Fe};function ff(t){return t.installSkills}function xf(t){return t.isInstalling}function bf(t){return t.projects}function vf(t){return t.activeProjectId}function yf(t){return s.jsx(ut,{value:t.id,children:t.label||t.path},t.id)}const jf=/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,wf=t=>{const e=t.trim();return jf.test(e)?`https://github.com/${e}`:null},kf=t=>{const e=wf(t.repoSource);if(!e)return null;const a=[t.repoSubpath,t.skillDir].filter(Boolean).join("/");return a?`${e}/tree/HEAD/${a}`:e};let Ki=null;const Nf=t=>{const e=wo();return(!Ki||Ki.locale!==e)&&(Ki={locale:e,formatter:new Intl.NumberFormat(e,{notation:"compact"})}),Ki.formatter.format(t)},Sf=t=>{const e=Date.parse(t);if(Number.isNaN(e))return null;const a=Date.now()-e;if(a<6e4)return{key:"common.relative.justNow",count:0};const n=Math.floor(a/6e4);if(n<60)return{key:"common.relative.minutesAgoShort",count:n};const r=Math.floor(n/60);if(r<24)return{key:"common.relative.hoursAgoShort",count:r};const i=Math.floor(r/24);if(i<7)return{key:"common.relative.daysAgoShort",count:i};const l=Math.floor(i/7);return l<52?{key:"common.relative.weeksAgoShort",count:l}:{key:"common.relative.yearsAgoShort",count:Math.floor(i/365)}},Cf=t=>{const e=tt.c(50),{source:a,isActive:n,isLoading:r,skillsCount:i,onSelect:l,t:d}=t,c=a.stars??null;let h,g,f,m,u,v,w,b,k,p;if(e[0]!==n||e[1]!==r||e[2]!==l||e[3]!==i||e[4]!==a.label||e[5]!==a.repoUpdatedAt||e[6]!==a.source||e[7]!==c||e[8]!==d){const y=a.repoUpdatedAt?Sf(a.repoUpdatedAt):null;b="button",k=l,p=n;const T=n?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-interactive-border-hover";e[19]!==T?(g=Pe("oc-surface-elevated w-full min-h-24 text-left rounded-lg border bg-surface-elevated p-3.5 flex gap-3 items-start transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",T),e[19]=T,e[20]=g):g=e[20],u="min-w-0 flex-1 block";let x;e[21]!==a.label?(x=s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:a.label}),e[21]=a.label,e[22]=x):x=e[22];let A;e[23]!==r||e[24]!==i||e[25]!==d?(A=r?s.jsx(_,{name:"refresh",className:"h-3 w-3 animate-spin text-muted-foreground shrink-0"}):i!==null&&s.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:d("settings.skills.catalog.page.source.skillsCount",{count:i})}),e[23]=r,e[24]=i,e[25]=d,e[26]=A):A=e[26],e[27]!==x||e[28]!==A?(v=s.jsxs("span",{className:"flex items-center gap-2",children:[x,A]}),e[27]=x,e[28]=A,e[29]=v):v=e[29],e[30]!==a.source?(w=s.jsx("span",{className:"typography-micro font-mono text-muted-foreground block mt-0.5 truncate",children:a.source}),e[30]=a.source,e[31]=w):w=e[31],h="flex items-center gap-3 mt-1",e[32]!==c||e[33]!==d?(f=c!==null&&s.jsxs("span",{className:"typography-micro text-muted-foreground flex items-center gap-1",title:d("settings.skills.catalog.page.source.stars",{count:c}),children:[s.jsx(_,{name:"star",className:"h-3 w-3"}),Nf(c)]}),e[32]=c,e[33]=d,e[34]=f):f=e[34],m=y&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:y.key==="common.relative.justNow"?d(y.key):d("settings.skills.catalog.page.source.updated",{time:d(y.key,{count:y.count})})}),e[0]=n,e[1]=r,e[2]=l,e[3]=i,e[4]=a.label,e[5]=a.repoUpdatedAt,e[6]=a.source,e[7]=c,e[8]=d,e[9]=h,e[10]=g,e[11]=f,e[12]=m,e[13]=u,e[14]=v,e[15]=w,e[16]=b,e[17]=k,e[18]=p}else h=e[9],g=e[10],f=e[11],m=e[12],u=e[13],v=e[14],w=e[15],b=e[16],k=e[17],p=e[18];let S;e[35]!==h||e[36]!==f||e[37]!==m?(S=s.jsxs("span",{className:h,children:[f,m]}),e[35]=h,e[36]=f,e[37]=m,e[38]=S):S=e[38];let N;e[39]!==S||e[40]!==u||e[41]!==v||e[42]!==w?(N=s.jsxs("span",{className:u,children:[v,w,S]}),e[39]=S,e[40]=u,e[41]=v,e[42]=w,e[43]=N):N=e[43];let I;return e[44]!==g||e[45]!==N||e[46]!==b||e[47]!==k||e[48]!==p?(I=s.jsx("button",{type:b,onClick:k,"aria-pressed":p,className:g,children:N}),e[44]=g,e[45]=N,e[46]=b,e[47]=k,e[48]=p,e[49]=I):I=e[49],I},If=({mode:t,onModeChange:e,showModeTabs:a=!0})=>{const{t:n}=Qe(),{sources:r,itemsBySource:i,selectedSourceId:l,setSelectedSource:d,loadCatalog:c,loadSource:h,isLoadingCatalog:g,isLoadingSource:f,loadedSourceIds:m,lastCatalogError:u}=Ln(Bs(L=>({sources:L.sources,itemsBySource:L.itemsBySource,selectedSourceId:L.selectedSourceId,setSelectedSource:L.setSelectedSource,loadCatalog:L.loadCatalog,loadSource:L.loadSource,isLoadingCatalog:L.isLoadingCatalog,isLoadingSource:L.isLoadingSource,loadedSourceIds:L.loadedSourceIds,lastCatalogError:L.lastCatalogError}))),[v,w]=o.useState(""),[b,k]=o.useState(!1),[p,S]=o.useState(!1),[N,I]=o.useState(null),[y,T]=o.useState(!1),[x,A]=o.useState(!1),R=o.useRef(null);o.useEffect(()=>{c()},[c]),o.useEffect(()=>{const L=r.filter(J=>!m[J.id]);if(L.length===0)return;let W=!1;return(async()=>{for(const J of L){if(W)return;await h(J.id)}})(),()=>{W=!0}},[r,m,h]),o.useEffect(()=>{!l||m[l]||h(l)},[l,m,h]),o.useEffect(()=>{const L=W=>{(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="k"&&(W.preventDefault(),R.current?.focus())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const P=v.trim().length>0,D=o.useMemo(()=>P?Ja(r.flatMap(L=>i[L.id]||[]),v,L=>[L.skillName,L.frontmatterName,L.description]):l?i[l]||[]:[],[r,i,l,v,P]),F=o.useMemo(()=>r.find(L=>L.id===l)||null,[r,l]),O=!!(l&&l.startsWith("custom:")),C=async()=>{if(!(!l||!O)){T(!0);try{const L=await En();if(!L)return;const X=(L.skillCatalogs??[]).filter(J=>J.id!==l);await xt({skillCatalogs:X}),await c({refresh:!0}),A(!1)}finally{T(!1)}}},M=P?n("settings.skills.catalog.page.list.searchTitle"):F?.label??"",U=!P&&l!==null&&!m[l]&&(f||g);return s.jsxs(s.Fragment,{children:[s.jsxs(ts,{title:n("settings.skills.catalog.page.title"),showSaveStatus:!1,children:[a&&s.jsx("div",{className:"mb-4",children:s.jsx("div",{className:"h-10",children:s.jsx(Io,{items:[{id:"manual",label:n("settings.skills.catalog.page.mode.manual")},{id:"external",label:n("settings.skills.catalog.page.mode.external")}],activeId:t,onSelect:L=>e(L),layoutMode:"fit",variant:"animated",animateActivePill:!1,className:"h-full"})})}),s.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:n("settings.skills.catalog.page.subtitle")}),s.jsx("div",{"data-settings-item":"skills.catalog.search",className:"mb-5",children:s.jsxs("div",{className:"relative max-w-md",children:[s.jsx(_,{name:"search",className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),s.jsx(He,{ref:R,value:v,onChange:L=>w(L.target.value),placeholder:n("settings.skills.catalog.page.searchAllPlaceholder"),className:Pe("h-8 pl-8 w-full",v&&"pr-8")}),v&&s.jsx("button",{type:"button",onClick:()=>{w(""),R.current?.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center justify-center h-4 w-4 rounded text-muted-foreground hover:text-foreground transition-colors",title:n("settings.skills.catalog.page.search.clear"),children:s.jsx(_,{name:"close",className:"h-3 w-3"})})]})}),s.jsx(qe,{title:n("settings.skills.catalog.page.section.sources"),divider:!1,settingsItem:"skills.catalog.source",contentClassName:"space-y-0",children:s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 py-1.5",children:[r.map(L=>s.jsx(Cf,{source:L,isActive:L.id===l,isLoading:f&&!m[L.id],skillsCount:m[L.id]?(i[L.id]||[]).length:null,onSelect:()=>d(L.id),t:n},L.id)),s.jsxs("button",{type:"button","data-settings-item":"skills.catalog.add-catalog",onClick:()=>k(!0),className:"min-h-24 text-left rounded-lg border border-dashed border-[var(--interactive-border)] hover:border-[var(--interactive-border-hover)] hover:bg-[var(--surface-muted)] p-3.5 flex gap-3 items-start transition-colors",children:[s.jsx("span",{className:"flex items-center justify-center rounded-md bg-transparent text-muted-foreground w-8 h-8 shrink-0",children:s.jsx(_,{name:"add",className:"h-4 w-4"})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground block",children:n("settings.skills.catalog.page.source.addOwnTitle")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 block mt-0.5",children:n("settings.skills.catalog.page.source.addOwnDescription")})]})]})]})}),u&&s.jsx(qe,{children:s.jsxs("div",{className:"rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[s.jsx("div",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:n("settings.skills.catalog.page.error.catalogTitle")}),s.jsx("div",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:u.message})]})}),s.jsxs(qe,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 pb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"typography-micro font-medium uppercase tracking-wide text-muted-foreground truncate",children:M}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:n("settings.skills.catalog.page.foundCount",{count:D.length})})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>{l&&!P?h(l,{refresh:!0}):c({refresh:!0})},disabled:g||f,title:n("settings.skills.catalog.page.actions.refreshTitle"),children:s.jsx(_,{name:"refresh",className:Pe("h-3.5 w-3.5",(g||f)&&"animate-spin")})}),O&&!P&&s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>A(!0),disabled:y,title:n("settings.skills.catalog.page.actions.removeCatalogTitle"),children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),U||f&&D.length===0?s.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[s.jsx(_,{name:"refresh",className:"mx-auto mb-3 h-5 w-5 animate-spin opacity-50"}),s.jsx("p",{className:"typography-meta",children:n("settings.skills.catalog.page.loading.skills")})]}):D.length===0?s.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-body",children:n("settings.skills.catalog.page.empty.noSkillsTitle")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.skills.catalog.page.empty.noSkillsDescription")})]}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:D.map(L=>{const W=L.installed?.isInstalled,X=L.installed?.scope,J=kf(L);return s.jsx("div",{className:"py-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:L.skillName}),W&&s.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:n("settings.skills.catalog.page.badge.installed",{scope:X||n("settings.skills.catalog.page.badge.unknown")})}),!L.installable&&s.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:n("settings.skills.catalog.page.badge.notInstallable")})]}),L.description?s.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 line-clamp-2",children:L.description}):s.jsx("div",{className:"typography-meta text-muted-foreground/50 mt-0.5 italic",children:n("settings.skills.catalog.shared.noDescription")}),s.jsxs("div",{className:"typography-micro text-muted-foreground/80 mt-1 flex items-center gap-2 min-w-0",children:[J?s.jsxs("a",{href:J,target:"_blank",rel:"noreferrer",className:"font-mono hover:underline truncate inline-flex items-center gap-1",title:n("settings.skills.catalog.page.skill.viewOnGithub"),children:[s.jsx(_,{name:"github",className:"h-3 w-3 shrink-0"}),L.repoSource]}):s.jsx("span",{className:"font-mono truncate",children:L.repoSource}),L.skillDir&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"opacity-40",children:"·"}),s.jsx("span",{className:"truncate",children:L.skillDir})]})]}),L.warnings?.length?s.jsx("div",{className:"typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit",children:L.warnings.join(" · ")}):null]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[J&&s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>window.open(J,"_blank","noreferrer"),title:n("settings.skills.catalog.page.skill.viewOnGithub"),children:s.jsx(_,{name:"external-link",className:"h-3.5 w-3.5"})}),W?s.jsx("span",{className:"text-[var(--status-success)] flex items-center justify-center w-7 h-7",title:n("settings.skills.catalog.page.badge.installed",{scope:X||""}),children:s.jsx(_,{name:"check",className:"h-4 w-4"})}):s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",disabled:!L.installable,onClick:()=>{I(L),S(!0)},children:n("settings.skills.catalog.shared.actions.install")})]})]})},`${L.sourceId}:${L.skillDir}`)})})]})]}),s.jsx(pf,{open:b,onOpenChange:k}),s.jsx(hf,{open:p,onOpenChange:S,item:N}),s.jsx(Ut,{open:x,onOpenChange:L=>{y||A(L)},children:s.jsxs(_t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:n("settings.skills.catalog.page.removeDialog.title")}),s.jsx(qt,{children:n("settings.skills.catalog.page.removeDialog.description")})]}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>A(!1),disabled:y,children:n("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",variant:"destructive",onClick:()=>{C()},disabled:y,children:n("settings.skills.catalog.page.actions.removeCatalog")})]})]})})]})},Pf=()=>{const t=tt.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(If,{mode:"external",onModeChange:Rf,showModeTabs:!1}),t[0]=e):e=t[0],e},Af="SKILL.md",Tf="h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]",qi=(t,e)=>{const a=_m({description:t}).trimEnd(),n=e.trimStart();return`---
23
+ ${a}
24
+ ---${n?`
25
+
26
+ ${n}`:`
27
+ `}`},Ef=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),dd=t=>{const e=t.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!e)return{description:null,instructions:t};let a=null;try{const n=$m(e[1]);if(Ef(n)){const r=n.description;typeof r=="string"&&(a=r)}}catch{a=null}return{description:a,instructions:e[2].replace(/^\r?\n/,"")}},Df=(t,e)=>{const a=dd(t);return qi(e,a.instructions)},Mf=()=>{const{t}=Qe(),{currentTheme:e}=fa(),{selectedSkillName:a,getSkillByName:n,getSkillDetail:r,createSkill:i,updateSkill:l,skillDraft:d,setSkillDraft:c,setSelectedSkill:h}=sn(Bs(we=>({selectedSkillName:we.selectedSkillName,getSkillByName:we.getSkillByName,getSkillDetail:we.getSkillDetail,createSkill:we.createSkill,updateSkill:we.updateSkill,skillDraft:we.skillDraft,setSkillDraft:we.setSkillDraft,setSelectedSkill:we.setSelectedSkill}))),g=rn(),f=sn(we=>xo(we,g)),m=a?n(a,g):null,u=!!(d&&d.name===a&&!m),v=!!(a&&!m&&!d),w=m?.path==="<built-in>";o.useEffect(()=>{v&&h(null)},[v,h]);const[b,k]=o.useState(""),[p,S]=o.useState("user"),[N,I]=o.useState("opencode"),[y,T]=o.useState(""),[x,A]=o.useState(""),[R,P]=o.useState(()=>qi("","")),[D,F]=o.useState("edit"),[O,C]=o.useState([]),[M,U]=o.useState([]),[L,W]=o.useState(!1),[X,J]=o.useState(!1),[q,z]=o.useState(""),[H,se]=o.useState(""),[B,ne]=o.useState(!1),[K,Z]=o.useState(""),[oe,ue]=o.useState(""),[de,ce]=o.useState(null),[Se,re]=o.useState(!1),[ve,ie]=o.useState(""),[me,ke]=o.useState(null),[Ae,pe]=o.useState(!1),Le=de?oe!==ve:K.trim()!=="",Ve=o.useCallback(we=>{switch(we){case"project-opencode":return t("settings.skills.location.option.projectOpencode.label");case"user-claude":return t("settings.skills.location.option.userClaude.label");case"project-claude":return t("settings.skills.location.option.projectClaude.label");case"user-agents":return t("settings.skills.location.option.userAgents.label");case"project-agents":return t("settings.skills.location.option.projectAgents.label");default:return t("settings.skills.location.option.userOpencode.label")}},[t]),ye=o.useCallback(we=>{switch(we){case"project-opencode":return t("settings.skills.location.option.projectOpencode.description");case"user-claude":return t("settings.skills.location.option.userClaude.description");case"project-claude":return t("settings.skills.location.option.projectClaude.description");case"user-agents":return t("settings.skills.location.option.userAgents.description");case"project-agents":return t("settings.skills.location.option.projectAgents.description");default:return t("settings.skills.location.option.userOpencode.description")}},[t]),Te=JSON.stringify([g,a,m?.path,u]),ee=o.useRef(null),ae=o.useRef({key:Te,markdown:R});ae.current={key:Te,markdown:R};const fe=o.useRef("");o.useEffect(()=>{let we=!1;const Je=(ze,Ge)=>{if(ae.current.key!==Te)return;const Q=qi(ze,Ge),Ue=ee.current===Te&&ae.current.markdown!==fe.current;ee.current=Te,fe.current=Q,Ue||(T(ze),A(Ge),P(Q))};return(async()=>{if(u&&d){J(!1);const ze=d.description||"",Ge=d.instructions||"";k(d.name||""),S(d.scope||"user"),I(d.source==="agents"?"agents":"opencode"),Je(ze,Ge),z(""),se(""),C([]),U(d.pendingFiles||[])}else if(a&&m){J(ee.current!==Te);try{const ze=await r(a,g);if(!we&&ae.current.key===Te&&ze){const Ge=ze.sources.md,Q=Ge.description||"",Ue=Ge.instructions||"";Je(Q,Ue),z(Q),se(Ue),C(Ge.supportingFiles||[])}}catch(ze){console.error("Failed to load skill details:",ze)}finally{we||J(!1)}}})(),()=>{we=!0}},[m,u,a,g,f,d,r,Te]);const je=he(we=>we.editorFontSize),Re=o.useMemo(()=>{const we=[ml(e,{fontSize:je})],Je=Ho(Af);return Je&&we.push(Je),we.push(gl.lineWrapping),we},[e,je]),Ce=o.useMemo(()=>{const we=K.trim()||"supporting-file.md",Je=Gd(we),Ye=!!Je&&Je!=="markdown",ze=[ml(e,Ye?{syntaxColors:!1,fontSize:je}:{fontSize:je})],Ge=Ho(we);return Ge&&ze.push(Ge),Ye&&Je&&ze.push(Bm({language:Je,themeName:e.metadata.id,theme:Hm(e)})),ze.push(gl.lineWrapping),ze},[e,K,je]),_e=o.useCallback(we=>{T(we),P(Je=>Df(Je,we))},[]),Ke=o.useCallback(we=>{P(we);const Je=dd(we);T(Je.description??""),A(Je.instructions)},[]),Fe=we=>we?!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(we)||we.length>64?t("settings.skills.page.toast.invalidSkillName"):null:t("settings.skills.page.toast.skillNameRequired"),Me=o.useCallback(async()=>{const we=a?.trim();return u||w||!we||y===q&&x===H?Os:y.trim()?await l(we,{name:we,description:y.trim(),instructions:x.trim()||void 0,targetPath:m?.path},g)?(ae.current.key===Te&&(fe.current=qi(y,x),z(y),se(x)),Tn):ms(t("settings.skills.page.toast.updateSkillFailed")):ms(t("settings.skills.page.toast.descriptionRequired"))},[y,x,u,w,q,H,m?.path,a,g,Te,t,l]),at=Ya(Me),pt=async()=>{const we=b.trim().replace(/\s+/g,"-").toLowerCase(),Je=Fe(we);if(Je){$.error(Je);return}if(!y.trim()){$.error(t("settings.skills.page.toast.descriptionRequired"));return}if(f.some(Ye=>Ye.name===we)){$.error(t("settings.skills.page.toast.skillExists"));return}W(!0);try{const Ye={name:we,description:y.trim(),instructions:x.trim()||void 0,scope:p,source:N,supportingFiles:M.length>0?M:void 0};await i(Ye,g)?(c(null),U([]),h(we),$.success(t("settings.skills.page.toast.skillCreated"))):$.error(t("settings.skills.page.toast.createSkillFailed"))}catch(Ye){console.error("Error creating skill:",Ye),$.error(t("settings.skills.page.toast.saveUnexpectedError"))}finally{W(!1)}},ot=()=>{c(null),h(null)},mt=()=>{ce(null),Z(""),ue(""),ie(""),ne(!0)},ht=async we=>{if(ce(we),Z(we),u){const Ye=M.find(ze=>ze.path===we)?.content||"";ue(Ye),ie(Ye),ne(!0);return}if(a){re(!0),ne(!0);try{const{readSupportingFile:Je}=sn.getState(),Ye=await Je(a,we,g);ue(Ye||""),ie(Ye||"")}catch{$.error(t("settings.skills.page.toast.loadFileContentFailed")),ue(""),ie("")}finally{re(!1)}}},Oe=async()=>{if(!K.trim()){$.error(t("settings.skills.page.toast.fileNameRequired"));return}const we=K.trim(),Je=de!==null;if(u){if(Je)U(Ge=>Ge.map(Q=>Q.path===de?{path:we,content:oe}:Q)),$.success(t("settings.skills.page.toast.fileUpdated",{path:we}));else{if(M.some(Ge=>Ge.path===we)){$.error(t("settings.skills.page.toast.fileExists"));return}U(Ge=>[...Ge,{path:we,content:oe}]),$.success(t("settings.skills.page.toast.fileAdded",{path:we}))}ne(!1),ce(null);return}if(!a){$.error(t("settings.skills.page.toast.noSkillSelected"));return}const{writeSupportingFile:Ye}=sn.getState();if(await Ye(a,we,oe,g)){$.success(Je?t("settings.skills.page.toast.fileUpdated",{path:we}):t("settings.skills.page.toast.fileCreated",{path:we})),ne(!1),ce(null);const Ge=await r(a,g);Ge&&C(Ge.sources.md.supportingFiles||[])}else $.error(t(Je?"settings.skills.page.toast.updateFileFailed":"settings.skills.page.toast.createFileFailed"))},nt=we=>{if(u){U(Je=>Je.filter(Ye=>Ye.path!==we)),$.success(t("settings.skills.page.toast.fileRemoved",{path:we}));return}a&&ke(we)},lt=async()=>{if(!me||!a)return;pe(!0);const{deleteSupportingFile:we}=sn.getState();if(await we(a,me,g)){$.success(t("settings.skills.page.toast.fileDeleted",{path:me}));const Ye=await r(a,g);Ye&&C(Ye.sources.md.supportingFiles||[]),ke(null)}else $.error(t("settings.skills.page.toast.deleteFileFailed"));pe(!1)};return!a&&!d||v?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(_,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.skills.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.skills.page.empty.description")})]})}):X?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsx("div",{className:"text-center text-muted-foreground",children:s.jsx("p",{className:"typography-body",children:t("settings.skills.page.loading.details")})})}):s.jsxs(s.Fragment,{children:[s.jsxs(ts,{title:u?t("settings.skills.page.title.newSkill"):a,description:m?t("settings.skills.page.subtitle.skillLocation",{location:Ve(mi(m.scope,m.source))}):t("settings.skills.page.subtitle.newSkill"),onBlurCapture:at.onBlurCapture,children:[s.jsxs(qe,{title:t("settings.skills.page.section.basicInformation"),divider:!1,settingsItem:"skills.basic-information",contentClassName:"space-y-0",children:[u&&s.jsxs(It,{label:t("settings.skills.page.field.skillNameLocation"),info:t("settings.skills.page.field.skillNameHint"),children:[s.jsx(He,{value:b,onChange:we=>k(we.target.value.toLowerCase().replace(/\s+/g,"-")),placeholder:t("settings.skills.page.field.skillNamePlaceholder"),className:"h-7 w-40 px-2"}),s.jsxs(Et,{value:mi(p,N),onValueChange:we=>{const Je=cd(we);S(Je.scope),I(Je.source==="agents"?"agents":"opencode")},children:[s.jsxs(At,{size:Bt,className:"w-fit gap-1.5",children:[p==="user"?s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),N==="agents"?s.jsx(_,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:Ve(mi(p,N))})]}),s.jsx(Tt,{align:"start",children:Do.map(we=>s.jsx(ut,{value:we.value,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[we.scope==="user"?s.jsx(_,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5"}),we.source==="agents"?s.jsx(_,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:Ve(we.value)})]}),s.jsx("span",{className:"typography-micro text-muted-foreground ml-6",children:ye(we.value)})]})},we.value))})]})]}),s.jsx(Ft,{label:s.jsxs(s.Fragment,{children:[t("settings.common.field.description")," ",s.jsx("span",{className:"text-[var(--status-error)]",children:"*"})]}),info:t("settings.skills.page.field.descriptionHint"),controlClassName:"w-full max-w-none",children:s.jsx(As,{value:y,onChange:we=>_e(we.target.value),placeholder:t("settings.skills.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] max-h-32 bg-transparent",disabled:w})})]}),s.jsx(qe,{title:t("settings.skills.page.section.instructions"),headerAction:s.jsx(Vm,{currentMode:D==="preview"?"preview":"edit",onToggle:()=>F(we=>we==="preview"?"edit":"preview")}),settingsItem:"skills.instructions",children:s.jsx("div",{className:Pe("overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",Tf),onKeyDown:we=>{we.key==="Enter"&&(we.metaKey||we.ctrlKey)&&(we.preventDefault(),at.requestSave())},children:D==="preview"?s.jsx(Ns,{outerClassName:"h-full",className:"h-full",children:s.jsx("div",{className:"min-h-full px-4 py-3",children:s.jsx(Wd,{content:R,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})}):s.jsx(pl,{value:R,onChange:Ke,readOnly:w,extensions:Re,className:"h-full",enableSearch:!0})})}),s.jsx(qe,{title:t("settings.skills.page.section.supportingFiles"),headerAction:s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:mt,disabled:w,children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})," ",t("settings.skills.page.actions.addFile")]}),settingsItem:"skills.supporting-files",children:(()=>{const we=u?M:O;return we.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground py-1.5",children:t("settings.skills.page.supportingFiles.empty")}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:we.map(Je=>s.jsxs("div",{className:"flex items-center gap-2 py-1.5 cursor-pointer group",onClick:()=>ht(Je.path),children:[s.jsx(_,{name:"file",className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Je.path}),u&&s.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:t("settings.skills.page.badge.pending")}),!w&&s.jsx(G,{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:Ye=>{Ye.stopPropagation(),nt(Je.path)},children:s.jsx(_,{name:"delete-bin",className:"h-3 w-3"})})]},Je.path))})})()}),u&&s.jsx(qe,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G,{onClick:()=>{pt()},disabled:L||!b.trim()||!y.trim(),size:"xs",className:"!font-normal",children:t(L?"settings.common.actions.saving":"settings.skills.page.actions.createSkill")}),s.jsx(G,{variant:"ghost",onClick:ot,disabled:L,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})})]}),s.jsx(Ut,{open:me!==null,onOpenChange:we=>{!we&&!Ae&&ke(null)},children:s.jsxs(_t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.skills.page.deleteFileDialog.title")}),s.jsx(qt,{children:t("settings.skills.page.deleteFileDialog.description",{path:me??""})})]}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>ke(null),disabled:Ae,children:t("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",variant:"destructive",onClick:lt,disabled:Ae,children:t("settings.common.actions.delete")})]})]})}),s.jsx(Ut,{open:B,onOpenChange:we=>{if(we){ne(!0);return}if(de!==null&&oe!==ve){Oe();return}ne(!1),ce(null)},children:s.jsxs(_t,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[s.jsxs(Vt,{className:"flex-shrink-0",children:[s.jsx(Ht,{children:t(de?"settings.skills.page.fileDialog.titleEdit":"settings.skills.page.fileDialog.titleAdd")}),s.jsx(qt,{children:t(de?"settings.skills.page.fileDialog.descriptionEdit":"settings.skills.page.fileDialog.descriptionAdd")})]}),Se?s.jsx("div",{className:"flex-1 flex items-center justify-center py-8",children:s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.skills.page.loading.fileContent")})}):s.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col pt-2",children:[s.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:Ct,children:t("settings.skills.page.fileDialog.field.filePath")}),!de&&s.jsx(Gt,{children:t("settings.skills.page.fileDialog.field.filePathHint")})]}),s.jsx(He,{value:K,onChange:we=>Z(we.target.value),placeholder:t("settings.skills.page.fileDialog.field.filePathPlaceholder"),className:"text-foreground placeholder:text-muted-foreground focus-visible:ring-ring",disabled:de!==null})]}),s.jsxs("div",{className:"space-y-2 flex-1 min-h-0 flex flex-col",children:[s.jsx("label",{className:`${Ct} flex-shrink-0`,children:t("settings.skills.page.fileDialog.field.content")}),s.jsx("div",{className:"h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",children:s.jsx(pl,{value:oe,onChange:ue,extensions:Ce,className:"h-full",enableSearch:!0})})]})]}),s.jsx(as,{className:"mt-4",children:de?s.jsx(G,{size:"sm",onClick:()=>{Oe()},disabled:Se,children:t("settings.common.actions.close")}):s.jsxs(s.Fragment,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>{ne(!1),ce(null)},children:t("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:()=>{Oe()},disabled:Se||!Le,children:t("settings.skills.page.actions.createFile")})]})})]})})]})},Ml=t=>{const e=tt.c(2),{view:a}=t,n=a===void 0?"installed":a;let r;return e[0]!==n?(r=n==="catalog"?s.jsx(Pf,{}):s.jsx(Mf,{}),e[0]=n,e[1]=r):r=e[1],r};function Rf(){}const Ff=t=>{const e=tt.c(38),{onItemSelect:a}=t,{t:n}=Qe(),r=pn(Of),i=he(Lf),l=he(Kf),{currentTheme:d}=fa();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=fs(),e[0]=c):c=e[0];const h=c,g=zf;let f,m;e[1]!==r||e[2]!==i||e[3]!==l?(f=()=>{if(r.length===0){i!==null&&l(null);return}i&&r.some(T=>T.id===i)||l(r[0].id)},m=[r,i,l],e[1]=r,e[2]=i,e[3]=l,e[4]=f,e[5]=m):(f=e[4],m=e[5]),o.useEffect(f,m);let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=Pe("border-b px-3","pt-4 pb-3"),e[6]=u):u=e[6];let v;e[7]!==n?(v=n("settings.page.projects.title"),e[7]=n,e[8]=v):v=e[8];let w;e[9]!==v?(w=s.jsx("h2",{className:`${_n} mb-3`,children:v}),e[9]=v,e[10]=w):w=e[10];let b;e[11]!==r.length||e[12]!==n?(b=n("settings.projects.sidebar.total",{count:r.length}),e[11]=r.length,e[12]=n,e[13]=b):b=e[13];let k;e[14]!==b?(k=s.jsx("span",{className:"typography-meta text-muted-foreground",children:b}),e[14]=b,e[15]=k):k=e[15];let p;e[16]!==n?(p=!h&&s.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:g,"aria-label":n("settings.projects.sidebar.actions.addProject"),children:s.jsx(_,{name:"add",className:"size-4"})}),e[16]=n,e[17]=p):p=e[17];let S;e[18]!==k||e[19]!==p?(S=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k,p]}),e[18]=k,e[19]=p,e[20]=S):S=e[20];let N;e[21]!==S||e[22]!==w?(N=s.jsxs("div",{className:u,children:[w,S]}),e[21]=S,e[22]=w,e[23]=N):N=e[23];let I;if(e[24]!==d||e[25]!==a||e[26]!==r||e[27]!==i||e[28]!==l){let T;e[30]!==d||e[31]!==a||e[32]!==i||e[33]!==l?(T=x=>{const A=x.id===i,R=x.icon?Qd[x.icon]:null,P=x.color?Yd[x.color]??null:null,D=R?s.jsx(_,{name:R,className:Pe("h-4 w-4",A?"text-foreground":"text-muted-foreground/70"),style:P?{color:P}:void 0}):s.jsx(_,{name:"folder",className:Pe("h-4 w-4",A?"text-foreground":"text-muted-foreground/70"),style:P?{color:P}:void 0}),F=x.iconImage?s.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:x.iconBackground?{backgroundColor:x.iconBackground}:void 0,children:s.jsx(Zd,{project:x,options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:D})}):D;return s.jsx(Hi,{title:x.label||x.path,icon:F,selected:A,onSelect:()=>{l(x.id),a?.()}},x.id)},e[30]=d,e[31]=a,e[32]=i,e[33]=l,e[34]=T):T=e[34],I=r.map(T),e[24]=d,e[25]=a,e[26]=r,e[27]=i,e[28]=l,e[29]=I}else I=e[29];let y;return e[35]!==N||e[36]!==I?(y=s.jsx(ld,{variant:"background",header:N,children:I}),e[35]=N,e[36]=I,e[37]=y):y=e[37],y};function Of(t){return t.projects}function Lf(t){return t.settingsProjectsSelectedId}function Kf(t){return t.setSettingsProjectsSelectedId}function zf(){Jd.requestDirectoryDialog()}const Uf=()=>{const t=tt.c(30),{t:e}=Qe(),a=pn(_f),n=pn($f),r=he(Bf),i=he(Vf);let l;e:{if(!r){l=null;break e}let b;t[0]!==a||t[1]!==r?(b=a.find(k=>k.id===r)??null,t[0]=a,t[1]=r,t[2]=b):b=t[2],l=b}const d=l;let c,h;t[3]!==a||t[4]!==r||t[5]!==i?(c=()=>{if(a.length===0){i(null);return}r&&a.some(b=>b.id===r)||i(a[0].id)},h=[a,r,i],t[3]=a,t[4]=r,t[5]=i,t[6]=c,t[7]=h):(c=t[6],h=t[7]),o.useEffect(c,h);let g;t[8]!==d||t[9]!==n?(g=async b=>{d&&n(d.id,{label:b.label,icon:b.icon,color:b.color,iconBackground:b.iconBackground,defaultAgent:b.defaultAgent??null,defaultModel:b.defaultModel??null,defaultVariant:b.defaultVariant??null})},t[8]=d,t[9]=n,t[10]=g):g=t[10];const f=g;if(!d){let b;t[11]!==e?(b=e("settings.page.projects.title"),t[11]=e,t[12]=b):b=t[12];let k;t[13]!==e?(k=e("settings.projects.page.empty.noProjects"),t[13]=e,t[14]=k):k=t[14];let p;t[15]!==k?(p=s.jsx("p",{className:"typography-meta text-muted-foreground",children:k}),t[15]=k,t[16]=p):p=t[16];let S;return t[17]!==b||t[18]!==p?(S=s.jsx(ts,{title:b,showSaveStatus:!0,children:p}),t[17]=b,t[18]=p,t[19]=S):S=t[19],S}let m;t[20]!==d.label||t[21]!==e?(m=d.label??e("settings.projects.page.title.default"),t[20]=d.label,t[21]=e,t[22]=m):m=t[22];const u=m;let v;t[23]!==f||t[24]!==d?(v=s.jsx(Mm,{project:d,onIdentitySave:f}),t[23]=f,t[24]=d,t[25]=v):v=t[25];let w;return t[26]!==u||t[27]!==d.path||t[28]!==v?(w=s.jsx(ts,{title:u,description:d.path,showSaveStatus:!0,outerClassName:"bg-background",children:v}),t[26]=u,t[27]=d.path,t[28]=v,t[29]=w):w=t[29],w};function _f(t){return t.projects}function $f(t){return t.updateProjectMeta}function Bf(t){return t.settingsProjectsSelectedId}function Vf(t){return t.setSettingsProjectsSelectedId}const Hf=Ts({clientToken:Mt().trim().min(1)}),qf=Ts({error:Um("Invalid or expired pairing session")}),Gf=async t=>{const e=await t.json().catch(()=>null);if(!t.ok)return t.status===400&&qf.safeParse(e).success?{kind:"rejected"}:{kind:"http-error",status:t.status};const a=Hf.safeParse(e);return a.success?{kind:"success",token:a.data.clientToken}:{kind:"invalid-response"}};function Wf(t){const e=tt.c(42),{t:a}=Qe(),[n,r]=et.useState(null),i=et.useRef(null),l=et.useRef(null);let d,c;e[0]!==t?(d=()=>(l.current=t,r(null),()=>{l.current=null;const C=i.current;i.current=null,C?.(null)}),c=[t],e[0]=t,e[1]=d,e[2]=c):(d=e[1],c=e[2]),et.useEffect(d,c);let h;e[3]!==t?(h=(C,M)=>{const U=M===void 0?"settings.common.actions.saveChanges":M;return!t||l.current!==t||i.current?Promise.resolve(null):new Promise(L=>{i.current=L,r({messageKey:C,actionKey:U})})},e[3]=t,e[4]=h):h=e[4];const g=h;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=C=>{const M=i.current;i.current=null,r(null),M?.(C)},e[5]=f):f=e[5];const m=f,u=n!==null;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=C=>{C||m(!1)},e[6]=v):v=e[6];let w;e[7]!==a?(w=a("settings.remoteInstances.page.title"),e[7]=a,e[8]=w):w=e[8];let b;e[9]!==w?(b=s.jsx(Ht,{children:w}),e[9]=w,e[10]=b):b=e[10];let k;e[11]!==n||e[12]!==a?(k=n?a(n.messageKey):null,e[11]=n,e[12]=a,e[13]=k):k=e[13];let p;e[14]!==k?(p=s.jsx(qt,{children:k}),e[14]=k,e[15]=p):p=e[15];let S;e[16]!==b||e[17]!==p?(S=s.jsxs(Vt,{children:[b,p]}),e[16]=b,e[17]=p,e[18]=S):S=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=()=>m(!1),e[19]=N):N=e[19];let I;e[20]!==a?(I=a("settings.common.actions.cancel"),e[20]=a,e[21]=I):I=e[21];let y;e[22]!==I?(y=s.jsx(G,{variant:"outline",autoFocus:!0,onClick:N,children:I}),e[22]=I,e[23]=y):y=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=()=>m(!0),e[24]=T):T=e[24];let x;e[25]!==n||e[26]!==a?(x=n?a(n.actionKey):null,e[25]=n,e[26]=a,e[27]=x):x=e[27];let A;e[28]!==x?(A=s.jsx(G,{onClick:T,children:x}),e[28]=x,e[29]=A):A=e[29];let R;e[30]!==y||e[31]!==A?(R=s.jsxs(as,{children:[y,A]}),e[30]=y,e[31]=A,e[32]=R):R=e[32];let P;e[33]!==S||e[34]!==R?(P=s.jsxs(_t,{children:[S,R]}),e[33]=S,e[34]=R,e[35]=P):P=e[35];let D;e[36]!==P||e[37]!==u?(D=s.jsx(Ut,{open:u,onOpenChange:v,children:P}),e[36]=P,e[37]=u,e[38]=D):D=e[38];const F=D;let O;return e[39]!==g||e[40]!==F?(O={confirm:g,dialog:F},e[39]=g,e[40]=F,e[41]=O):O=e[41],O}const Gi=()=>Math.floor(2e4+Math.random()*3e4),Jf=t=>{const e=(t instanceof Error?t.message:String(t)).toLowerCase();return e.includes("address already in use")||e.includes("eaddrinuse")||e.includes("port already in use")},Qf=()=>{if(typeof navigator>"u")return;const t=(navigator.userAgent||"").toLowerCase();if(t.includes("mac"))return"macos";if(t.includes("win"))return"windows";if(t.includes("linux"))return"linux"},Rl=t=>{switch((t||"").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}},Fl=t=>{switch(t){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.installingOpenChamber";case"updating":return"settings.remoteInstances.page.phase.updatingOpenChamber";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"}},Yf=new Set(["config_resolved","auth_check","master_connecting","remote_probe","installing","updating","server_detecting","server_starting","forwarding"]),Mo=t=>!!(t&&Yf.has(t)),Ol=t=>t==="ready"?"ready":t==="error"?"error":t==="degraded"||Mo(t)?"connecting":"idle",Ll=t=>{switch(t){case"ready":return"settings.remoteInstances.page.state.ready";case"connecting":return"settings.remoteInstances.page.state.connecting";case"error":return"settings.remoteInstances.page.state.problem";default:return"settings.remoteInstances.page.state.notConnected"}},Zf=t=>{const e=(t||"").toLowerCase();return e?e.includes("ui authentication")||e.includes("ui password")?"uiPassword":e.includes("already in use")||e.includes("eaddrinuse")?"localPort":e.includes("neither bun nor npm")?"noRuntime":e.includes("opencode cli is not installed")?"noOpencode":e.includes("requires a ui password")?"uiPassword":e.includes("preferred remote openchamber port")?"externalPort":null:null},Kl={noRuntime:"settings.remoteInstances.page.error.hint.noRuntime",noOpencode:"settings.remoteInstances.page.error.hint.noOpencode"},Xf=t=>t==="noRuntime"?Kl.noRuntime:t==="noOpencode"?Kl.noOpencode:null,zl=t=>t==="ready"?"bg-[var(--status-success)] animate-pulse":t==="error"?"bg-[var(--status-error)] animate-pulse":t==="degraded"||Mo(t)?"bg-[var(--status-warning)] animate-pulse":"bg-muted-foreground/40",ex=t=>t.type==="dynamic"?`${t.localHost||"127.0.0.1"}:${t.localPort||0}`:t.type==="remote"?`${t.remoteHost||"127.0.0.1"}:${t.remotePort||0} -> ${t.localHost||"127.0.0.1"}:${t.localPort||0}`:`${t.localHost||"127.0.0.1"}:${t.localPort||0} -> ${t.remoteHost||"127.0.0.1"}:${t.remotePort||0}`,tx=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:"local",localHost:"127.0.0.1",localPort:Gi(),remoteHost:"127.0.0.1",remotePort:80}),sx=t=>t.trim().replace(/\*/g,"host").replace(/\?/g,"x")||"user@host",en=t=>{const e=tt.c(7),{label:a,hint:n}=t;let r;e[0]!==a?(r=s.jsx("span",{children:a}),e[0]=a,e[1]=r):r=e[1];let i;e[2]!==n?(i=s.jsx(Gt,{contentClassName:"max-w-xs",children:n}),e[2]=n,e[3]=i):i=e[3];let l;return e[4]!==r||e[5]!==i?(l=s.jsxs("span",{className:`inline-flex items-center gap-1 ${Ct}`,children:[r,i]}),e[4]=r,e[5]=i,e[6]=l):l=e[6],l},nx=t=>{switch(t){case"remote":return"settings.remoteInstances.page.forwardTypeDescription.remote";case"dynamic":return"settings.remoteInstances.page.forwardTypeDescription.dynamic";default:return"settings.remoteInstances.page.forwardTypeDescription.local"}},Ul=(t,e)=>{const a=(t||"").trim();return`${!a||a==="127.0.0.1"||a==="::1"?"localhost":a}:${e||0}`},ax=t=>{const e=(t||"").trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},ix=t=>{const e=t.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!e)return t;const a=Number(e[1]),n=Number.isFinite(a)?new Date(a).toISOString():e[1],r=(e[2]||"INFO").toUpperCase(),i=e[3]||"";return`[${n}] [${r}] ${i}`},co=(t="",e="")=>({id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`header-${Date.now()}-${Math.random().toString(16).slice(2)}`,name:t,value:e}),rx=t=>t.trim().toLowerCase()==="authorization",$r=t=>{const e={};for(const a of t){const n=a.name.trim(),r=a.value.trim();n&&r&&!rx(n)&&(e[n]=r)}return Object.keys(e).length>0?e:void 0},ox=t=>Object.entries(t||{}).map(([e,a])=>co(e,a)),ud=()=>{if(typeof window>"u")return null;const e=hi()||window.location.href;try{const a=Number(new URL(e).port||window.location.port);return Number.isFinite(a)&&a>0?a:null}catch{const a=Number(window.location.port);return Number.isFinite(a)&&a>0?a:null}},_l=t=>{try{const e=new URL(t).hostname.toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}catch{return!1}},lx=async()=>{const t=Ka(hi())||window.location.origin;if(!ls()||!fi()||(await En())?.desktopLanAccessActive!==!0)return t;const a=await Vc(),n=ud();return!a||!n?t:`http://${a}:${n}`},zi=t=>{const e=t.trim();if(e)try{window.location.assign(e)}catch{window.location.href=e}},cx=t=>{const e=t.sshCommand.trim(),a=t.nickname?.trim(),n=t.portForwards.map(r=>({...r,localHost:r.localHost?.trim()||"127.0.0.1",localPort:typeof r.localPort=="number"?Math.max(1,Math.min(65535,Math.round(r.localPort))):void 0,remoteHost:r.remoteHost?.trim(),remotePort:typeof r.remotePort=="number"?Math.max(1,Math.min(65535,Math.round(r.remotePort))):void 0}));return{...t,sshCommand:e,...a?{nickname:a}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(t.connectionTimeoutSec||60))),localForward:{...t.localForward,bindHost:t.localForward.bindHost==="localhost"||t.localForward.bindHost==="0.0.0.0"?t.localForward.bindHost:"127.0.0.1",preferredLocalPort:typeof t.localForward.preferredLocalPort=="number"?Math.max(1,Math.min(65535,Math.round(t.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...t.remoteOpenchamber,preferredPort:typeof t.remoteOpenchamber.preferredPort=="number"?Math.max(1,Math.min(65535,Math.round(t.remoteOpenchamber.preferredPort))):void 0},portForwards:n}},dx=()=>{const{t}=Qe(),e=he(E=>E.timeFormatPreference),{clientAuth:a}=ko(),n=ls(),r=Is(E=>E.instances),i=Is(E=>E.statusesById),l=Is(E=>E.importCandidates),d=Is(E=>E.isLoading),c=Is(E=>E.isImportsLoading),h=Is(E=>E.isSaving),g=Is(E=>E.error),f=Is(E=>E.load),m=Is(E=>E.loadImports),u=Is(E=>E.refreshStatuses),v=Is(E=>E.upsertInstance),w=Is(E=>E.createFromCommand),b=Is(E=>E.removeInstance),k=Is(E=>E.connect),p=Is(E=>E.disconnect),S=Is(E=>E.retry),N=he(E=>E.settingsRemoteInstancesSelectedId),I=he(E=>E.setSettingsRemoteInstancesSelectedId),{confirm:y,dialog:T}=Wf(N),x=o.useMemo(()=>N&&r.find(E=>E.id===N)||null,[r,N]),[A,R]=o.useState(null),[P,D]=o.useState(!1),[F,O]=o.useState(!1),[C,M]=o.useState(null),[U,L]=o.useState([]),[W,X]=o.useState(null),[J,q]=o.useState(""),[z,H]=o.useState(!1),[se,B]=o.useState({}),[ne,K]=o.useState(!1),[Z,oe]=o.useState(!1),[ue,de]=o.useState(()=>Date.now()),[ce,Se]=o.useState([]),[re,ve]=o.useState({}),[ie,me]=o.useState("local"),[ke,Ae]=o.useState(!1),[pe,Le]=o.useState(!1),[Ve,ye]=o.useState(""),[Te,ee]=o.useState(""),[ae,fe]=o.useState(""),[je,Re]=o.useState([]),[Ce,_e]=o.useState(""),[Ke,Fe]=o.useState(null),[Me,at]=o.useState(!1),[pt,ot]=o.useState(!1),[mt,ht]=o.useState(!1),[Oe,nt]=o.useState(null),[lt,we]=o.useState(""),[Je,Ye]=o.useState(""),[ze,Ge]=o.useState(""),[Q,Ue]=o.useState([]),[st,dt]=o.useState([]),[ct,ft]=o.useState([]),[kt,bt]=o.useState(!1),[vt,Xe]=o.useState(""),[jt,De]=o.useState(null),[$e,Y]=o.useState(null),[V,be]=o.useState(null),[ge,Ee]=o.useState(null),[te,xe]=o.useState(!1),[Ze,Nt]=o.useState(!1),[Lt,Ie]=o.useState("configure"),[Be,wt]=o.useState(!1),[Pt,Qt]=o.useState("relay"),[Xt,ss]=o.useState(!0),[es,Ls]=o.useState(null),Js=o.useMemo(()=>st.filter(E=>!!E.revokedAt).length,[st]),[gn,Ks]=o.useState(!1),[zs,on]=o.useState("saved"),[Qs,Ys]=o.useState(""),[Us,Dn]=o.useState(""),[Rt,Wt]=o.useState(""),[zt,Dt]=o.useState(!1);o.useEffect(()=>{f(),m()},[f,m]);const is=o.useCallback(async()=>{Ae(!0),Fe(null);try{const E=await tl();Se(E.hosts||[]),me(E.defaultHostId||"local")}catch(E){Fe(E instanceof Error?E.message:String(E))}finally{Ae(!1)}},[]);o.useEffect(()=>{is()},[is]);const ns=o.useCallback(async(E,le=ie)=>{Le(!0),Fe(null);try{return await sl({hosts:E,defaultHostId:le,initialHostChoiceCompleted:!0}),Se(E),me(le),!0}catch(We){return Fe(We instanceof Error?We.message:String(We)),!1}finally{Le(!1)}},[ie]),cr=o.useCallback(async()=>{const E=nl(Te);if(!E){Fe(t("desktopHostSwitcher.error.invalidUrl"));return}const le=E.persistedUrl,it={id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,label:Ve.trim()||ei(le),url:le,apiUrl:le,...ae.trim()?{clientToken:ae.trim()}:{},...$r(je)?{requestHeaders:$r(je)}:{}};await ns([it,...ce],ie)&&(ye(""),ee(""),fe(""),Re([]),at(!1),E.redeemUrl&&zi(E.redeemUrl))},[ie,je,ce,Ve,ae,Te,ns,t]),dr=o.useCallback(async()=>{Fe(null);const E=Zu(Ce);if(!E){Fe(t("settings.remoteInstances.direct.error.invalidConnectLink"));return}const le=await Xu().catch(()=>""),We=JSON.stringify({pairingId:E.pairingId,secret:E.secret,clientLabel:E.label||"OpenChamber Desktop",clientKind:"desktop",deviceName:"OpenChamber Desktop",devicePlatform:Qf(),...le?{dedupeKey:`desktop:${le}`}:{}}),it={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:We};let Ot=null;const xs=async Zt=>{const Cs=await Gf(Zt);switch(Cs.kind){case"success":return Cs.token;case"rejected":Ot=t("desktopHostSwitcher.error.pairingRejected");break;case"http-error":Ot??=t("desktopHostSwitcher.error.pairingFailed",{status:Cs.status});break;case"invalid-response":Ot??=t("desktopHostSwitcher.error.pairingInvalidResponse");break}return null},Zs=[...E.candidates].sort((Zt,Cs)=>(Zt.type==="relay"?1:0)-(Cs.type==="relay"?1:0));let ps=null;for(const Zt of Zs){if(Zt.type==="relay"){const Ta=em({relayUrl:Zt.relayUrl,serverId:Zt.serverId,hostEncPubJwk:Zt.hostEncPubJwk,...Zt.grant?{grant:Zt.grant}:{}});try{const Ea=await Ta.fetch("/api/client-auth/pairing/redeem",{...it,signal:AbortSignal.timeout(15e3)}),Da=await xs(Ea);if(Da){ps={kind:"relay",relay:{relayUrl:Zt.relayUrl,serverId:Zt.serverId,hostEncPubJwk:Zt.hostEncPubJwk},token:Da};break}}catch{}finally{Ta.close()}continue}const Cs=Ka(Zt.url);if(Cs)try{const Ta=await fetch(`${Cs}/api/client-auth/pairing/redeem`,{...it,signal:AbortSignal.timeout(15e3)}),Ea=await xs(Ta);if(Ea){ps={kind:"direct",url:Cs,token:Ea};break}}catch{}}if(!ps){Fe(Ot||t("mobile.connect.error.unreachable"));return}const _s=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,Rn=E.candidates.find(Zt=>Zt.type==="relay"),xn=ps.kind==="relay"?ps.relay:Rn?{relayUrl:Rn.relayUrl,serverId:Rn.serverId,hostEncPubJwk:Rn.hostEncPubJwk}:void 0,Pa=E.candidates.filter(Zt=>Zt.type!=="relay").map(Zt=>Ka(Zt.url)).find(Zt=>!!Zt),Aa=ps.kind==="direct"?ps.url:Pa,{token:Kt}=ps,Yt=Aa||(xn?tm(xn.serverId):null);if(!Yt){Fe(t("settings.remoteInstances.direct.error.invalidConnectLink"));return}const bn={url:Yt,apiUrl:Aa||void 0,clientToken:Kt,...xn?{relay:xn}:{}},dn=ce.find(Zt=>xn?Zt.relay?.serverId===xn.serverId:!Zt.relay&&Ka(Zt.apiUrl||Zt.url)===Yt);if(dn){const Zt=ce.map(Cs=>Cs.id===dn.id?{...Cs,label:E.label||Cs.label,...bn}:Cs);if(!await ns(Zt,ie))return}else if(!await ns([{id:_s(),label:E.label||ei(Yt),...bn},...ce],ie))return;_e(""),Fe(null),ot(!1)},[Ce,ie,ce,ns,t]),ur=o.useCallback(async E=>{const le=ce.filter(it=>it.id!==E);await ns(le,ie===E?"local":ie)&&Oe===E&&nt(null)},[ie,Oe,ce,ns]),mr=o.useCallback(E=>{nt(E.id),we(E.label),Ye(E.apiUrl||E.url),Ge(E.clientToken||""),Ue(ox(E.requestHeaders)),Fe(null)},[]),vi=o.useCallback(async()=>{if(!Oe)return;const E=nl(Je);if(!E){Fe(t("desktopHostSwitcher.error.invalidUrl"));return}const le=E.persistedUrl,We=ce.map(it=>it.id===Oe?{...it,label:lt.trim()||ei(le),url:le,apiUrl:le,clientToken:ze.trim()||void 0,requestHeaders:$r(Q)}:it);await ns(We,ie)&&(nt(null),E.redeemUrl&&zi(E.redeemUrl))},[ie,Q,lt,ze,Je,Oe,ce,ns,t]),pr=o.useCallback(async()=>{const E=Us.trim();if(!E){$.error(t("settings.remoteInstances.page.toast.sshCommandRequired"));return}const le=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await w(le,E,Rt.trim()||t("settings.remoteInstances.sidebar.newSshInstanceName")),I(le),Ks(!1),Dn(""),Wt(""),$.success(t("settings.remoteInstances.page.toast.instanceCreated"))}catch(We){$.error(t("settings.remoteInstances.sidebar.toast.createFailed"),{description:We instanceof Error?We.message:String(We)})}},[w,I,Us,Rt,t]),yi=o.useCallback(()=>{Ys(""),on(l.length>0?"saved":"manual"),Ks(!0)},[l.length]),gr=o.useCallback(async E=>{await ns(ce,E)},[ce,ns]);o.useEffect(()=>{if(!n||ce.length===0)return;let E=!1;return Promise.all(ce.map(async le=>{const We=()=>om(le.relay,{clientToken:le.clientToken||null,requestHeaders:le.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(le.relay&&!le.apiUrl)return[le.id,await We()];const it=Ka(sm(le));if(!it)return[le.id,le.relay?await We():{status:"unreachable",latencyMs:0}];const Ot=await nm(it,{clientToken:le.clientToken||null,requestHeaders:le.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(Ot.status==="unreachable"&&le.relay){const xs=await We();if(xs.status==="ok")return[le.id,xs]}return[le.id,Ot]})).then(le=>{E||ve(Object.fromEntries(le))}),()=>{E=!0}},[ce,n]);const Vs=o.useCallback(async E=>{if(a){E?.silent||bt(!0),E?.silent||De(null);try{const[le,We]=await Promise.all([a.listClients(),a.listPendingPairings().catch(()=>null)]);dt(le),We&&ft(We)}catch(le){E?.silent||De(le instanceof Error?le.message:String(le))}finally{E?.silent||bt(!1)}}},[a]),Za=o.useRef(!1);o.useEffect(()=>{if(!(!Ze||Lt!=="result"||!V)){if(ct.some(E=>E.id===V)){Za.current=!0;return}Za.current&&(be(null),Nt(!1),st.some(E=>E.pairingId===V)&&$.success(t("settings.remoteInstances.clientAuth.addDevice.connectedToast")))}},[Ze,Lt,V,ct,st,t]);const ji=o.useCallback(async E=>{if(a)try{await a.cancelPairing(E),ft(le=>le.filter(We=>We.id!==E)),await Vs({silent:!0})}catch(le){De(le instanceof Error?le.message:String(le))}},[a,Vs]);o.useEffect(()=>{if(!a)return;Vs();const E=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Vs({silent:!0})},5e3);return()=>window.clearInterval(E)},[a,Vs]);const wi=o.useCallback(async()=>{if(a?.getPairingTransports)try{const it=await a.getPairingTransports();return{localUrl:it.local,lanUrl:it.lan,relayAvailable:it.relayAvailable}}catch{}const E=ud(),le=E?`http://127.0.0.1:${E}`:_l(window.location.origin)?window.location.origin:null;let We=null;try{const it=Ka(await lx());We=it&&!_l(it)?it:null}catch{}return{localUrl:le,lanUrl:We,relayAvailable:!0}},[a]),hr=o.useCallback(async()=>{De(null),Y(null),Ee(null),xe(!1),be(null),Ie("configure"),ss(!0),Nt(!0);const E=await wi();Ls(E),Qt(E.relayAvailable?"relay":E.lanUrl?"lan":"local")},[wi]),fr=o.useCallback(async()=>{if(!(!a?.createPairingSession||!es)){De(null),wt(!0);try{const E=vt.trim()||void 0;let le,We,it=!0;Pt==="local"?(le=es.localUrl??void 0,We=!1):Pt==="lan"?(le=es.lanUrl??void 0,We=Xt):Xt&&es.lanUrl?(le=es.lanUrl,We=!0):(it=!1,We=!0);const{pairing:Ot,server:xs}=await a.createPairingSession({label:E,allowedClientKinds:["mobile","desktop"],serverUrl:le,includeRelay:We,includeDirect:it}),Zs=am({pairingId:Ot.id,secret:Ot.secret,label:xs.label,fingerprint:Ot.fingerprint??void 0,expiresAt:Ot.expiresAt,candidates:xs.candidates}),ps=im(Zs);Y(ps),Ee(await Qc.toDataURL(ps,{width:1024,margin:2,errorCorrectionLevel:"L"})),xe(!1),Za.current=!1,be(Ot.id),Ie("result"),await Vs({silent:!0})}catch(E){De(E instanceof Error?E.message:String(E))}finally{wt(!1)}}},[a,es,Pt,Xt,vt,Vs]),ki=o.useCallback(()=>{$e&&_a($e).then(E=>{E.ok&&(xe(!0),window.setTimeout(()=>xe(!1),2e3))})},[$e]),xr=o.useCallback(async E=>{if(!a)return;const le=E.clientKind==="desktop-local";De(null);try{if(await a.revokeClient(E.id),le&&ls()){const We=await tl();await sl({hosts:We.hosts,defaultHostId:We.defaultHostId,initialHostChoiceCompleted:We.initialHostChoiceCompleted,localClientToken:null}),dt(it=>it.map(Ot=>Ot.id===E.id?{...Ot,revokedAt:new Date().toISOString()}:Ot)),rm({apiBaseUrl:hi(),clientToken:null,runtimeKey:"local"});return}await Vs()}catch(We){De(We instanceof Error?We.message:String(We))}},[a,Vs]),br=o.useCallback(async()=>{if(a){De(null);try{await a.purgeRevokedClients(),await Vs()}catch(E){De(E instanceof Error?E.message:String(E))}}},[a,Vs]);o.useEffect(()=>{R(x)},[x]),o.useEffect(()=>{Dt(!1)},[N]),o.useEffect(()=>{if(!N)return;const E=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||u()},2e3);return()=>{window.clearInterval(E)}},[u,N]),o.useEffect(()=>{let E=null,le=Date.now();const We=()=>{const Ot=Date.now();Ot-le>=1e3&&(de(Ot),le=Ot),E=requestAnimationFrame(We)};(typeof document>"u"||document.visibilityState==="visible")&&(E=requestAnimationFrame(We));const it=()=>{document.visibilityState==="visible"&&E===null?E=requestAnimationFrame(We):document.visibilityState!=="visible"&&E!==null&&(cancelAnimationFrame(E),E=null)};return document.addEventListener("visibilitychange",it),()=>{document.removeEventListener("visibilitychange",it),E!==null&&cancelAnimationFrame(E)}},[]);const ys=N?i[N]:null,ln=ys?.phase,ba=ln==="ready",Mn=ln==="degraded",$n=Mo(ln),cn=ba||($n||Mn),vr=ys?Math.max(0,ue-ys.updatedAtMs):0,va=Mn&&vr>12e3,ya=Ol(ln),Xn=ya==="error"?Zf(ys?.detail):null,Xa=Xf(Xn),yr=o.useMemo(()=>!A||!x?!1:JSON.stringify(A)!==JSON.stringify(x),[A,x]),ds=o.useCallback(E=>{R(le=>le&&E(le))},[]),jr=o.useCallback(async()=>{if(!A)return;const E=cx(A);if(!E.sshCommand.trim()){$.error(t("settings.remoteInstances.page.toast.sshCommandRequired"));return}if(E.remoteOpenchamber.mode==="external"&&!E.remoteOpenchamber.preferredPort){$.error(t("settings.remoteInstances.page.validation.externalPortRequired")),Dt(!0);return}if(E.remoteOpenchamber.mode==="managed"&&E.remoteOpenchamber.bindHost==="0.0.0.0"&&!E.auth.openchamberPassword?.value?.trim()){$.error(t("settings.remoteInstances.page.validation.remoteLanNeedsPassword")),Dt(!0),window.setTimeout(()=>ka.current?.focus(),0);return}if(!(E.localForward.bindHost==="0.0.0.0"&&!await y("settings.remoteInstances.page.confirm.bindAllInterfaces"))){if(E.auth.sshPassword?.enabled&&E.auth.sshPassword.value?.trim()&&E.auth.sshPassword.store!=="settings"){const le=await y("settings.remoteInstances.page.confirm.storeSshPasswordPlaintext");if(le===null)return;E.auth.sshPassword.store=le?"settings":"never",le||(E.auth.sshPassword.value=void 0)}if(E.auth.openchamberPassword?.enabled&&E.auth.openchamberPassword.value?.trim()&&E.auth.openchamberPassword.store!=="settings"){const le=await y("settings.remoteInstances.page.confirm.storeUiPasswordPlaintext");if(le===null)return;E.auth.openchamberPassword.store=le?"settings":"never",le||(E.auth.openchamberPassword.value=void 0)}try{await v(E),$.success(t("settings.remoteInstances.page.toast.instanceSaved"))}catch(le){$.error(t("settings.remoteInstances.page.toast.saveFailed"),{description:le instanceof Error?le.message:String(le)})}}},[y,A,t,v]),ja=o.useCallback(async(E,le)=>{const We=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await w(We,`ssh ${le}`,E),I(We),$.success(t("settings.remoteInstances.page.toast.instanceCreated")),!0}catch(it){return $.error(t("settings.remoteInstances.sidebar.toast.createFailed"),{description:it instanceof Error?it.message:String(it)}),!1}},[w,I,t]),wa=o.useCallback(()=>{z||(X(null),q(""))},[z]),wr=o.useCallback((E,le)=>{if(Ks(!1),le){X(E),q(sx(E));return}ja(E,E)},[ja]),Ni=o.useMemo(()=>Ja(l,Qs,E=>[E.host,E.sshCommand]),[l,Qs]),kr=o.useCallback(E=>{const le=(E||"").trim();if(!le){$.error(t("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}zi(le)},[t]),Bn=o.useCallback(async()=>{const E=W,le=J.trim();if(E){if(!le){$.error(t("settings.remoteInstances.page.toast.destinationRequired"));return}H(!0);try{await ja(E,le)&&(X(null),q(""))}finally{H(!1)}}},[ja,J,W,t]),hn=o.useCallback(async()=>{if(x)try{await k(x.id);return}catch(E){if(!Jf(E)||!await y("settings.remoteInstances.sidebar.confirm.localPortInUseRetry","settings.remoteInstances.sidebar.actions.retry"))throw E;const We={...x,localForward:{...x.localForward,preferredLocalPort:Gi()}};await v(We),await k(We.id),$.success(t("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}},[y,k,x,t,v]),ka=o.useRef(null),Si=o.useRef(null),Na=o.useCallback(async E=>{if(x){if(E==="localPort"){const le={...x,localForward:{...x.localForward,preferredLocalPort:Gi()}};try{await v(le),await k(le.id),$.success(t("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}catch(We){$.error(t("settings.remoteInstances.page.toast.connectFailed"),{description:We instanceof Error?We.message:String(We)})}return}Dt(!0),window.setTimeout(()=>{if(E==="uiPassword"){ka.current?.focus();return}Si.current?.scrollIntoView({block:"center"})},0)}},[k,x,t,v]),Sa=o.useCallback(async E=>(await Xd(E,600)).map(We=>ix(We)),[]),Nr=o.useCallback(async()=>{if(A){D(!0),O(!0),M(null);try{const E=await Sa(A.id);L(E)}catch(E){L([]),M(E instanceof Error?E.message:String(E))}finally{O(!1)}}},[A,Sa]);o.useEffect(()=>{if(!P||!A)return;let E=!1;const le=async()=>{try{const it=await Sa(A.id);E||(L(it),M(null))}catch(it){E||M(it instanceof Error?it.message:String(it))}};le();const We=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||le()},1e3);return()=>{E=!0,window.clearInterval(We)}},[A,P,Sa]);const Ne=o.useMemo(()=>U.join(`
28
+ `),[U]),Ss=o.useCallback(()=>{if(!Ne.trim()){$.error(t("settings.remoteInstances.page.toast.noLogsToCopy"));return}_a(Ne).then(E=>{E.ok&&$.success(t("settings.remoteInstances.page.toast.logsCopied"))})},[Ne,t]),Ca=o.useCallback(async()=>{if(A)try{await eu(A.id),L([]),$.success(t("settings.remoteInstances.page.toast.logsCleared"))}catch(E){$.error(t("settings.remoteInstances.page.toast.clearLogsFailed"),{description:E instanceof Error?E.message:String(E)})}},[A,t]),Ci=o.useCallback(async()=>{if(!ys?.localUrl){$.error(t("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}const E=ys.localUrl.trim();if(!E){$.error(t("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}zi(E)},[ys?.localUrl,t]),Ii=o.useCallback(()=>{if(!A)return;if(!cn&&A.remoteOpenchamber.mode==="external"&&!A.remoteOpenchamber.preferredPort){$.error(t("settings.remoteInstances.page.validation.externalPortRequired")),Dt(!0);return}if(!cn&&A.remoteOpenchamber.mode==="managed"&&A.remoteOpenchamber.bindHost==="0.0.0.0"&&!A.auth.openchamberPassword?.value?.trim()){$.error(t("settings.remoteInstances.page.validation.remoteLanNeedsPassword")),Dt(!0),window.setTimeout(()=>ka.current?.focus(),0);return}K(!0),(cn?p(A.id):hn()).catch(le=>{const We=cn?ba?"settings.remoteInstances.page.toast.disconnectFailed":"settings.remoteInstances.page.toast.cancelConnectionFailed":"settings.remoteInstances.page.toast.connectFailed";$.error(t(We),{description:le instanceof Error?le.message:String(le)})}).finally(()=>{K(!1)})},[cn,hn,p,A,ba,t]),Pi=o.useCallback(()=>{if(!A||$n)return;oe(!0),(Mn?p(A.id).then(()=>hn()):S(A.id)).catch(le=>{$.error(t("settings.remoteInstances.page.toast.retryFailed"),{description:le instanceof Error?le.message:String(le)})}).finally(()=>{oe(!1)})},[hn,p,A,$n,Mn,S,t]),Ai=t($n?"settings.remoteInstances.page.actions.connecting":Mn?va?"settings.remoteInstances.page.actions.reconnectNow":"settings.remoteInstances.page.actions.reconnecting":"settings.remoteInstances.sidebar.actions.retry"),Ti=!ne&&!Z&&(ln==="error"||ln==="idle"||!ln||Mn&&va)&&!$n,Sr=t(ba?"settings.remoteInstances.sidebar.actions.disconnect":cn?"settings.remoteInstances.page.actions.cancel":"settings.remoteInstances.sidebar.actions.connect");if(!A)return s.jsxs(ts,{title:t("settings.page.remoteInstances.title"),children:[a?s.jsxs(qe,{title:t("settings.remoteInstances.clientAuth.title"),info:t("settings.remoteInstances.clientAuth.description"),divider:!1,settingsItem:"remote-instances.client-auth",contentClassName:"space-y-3",children:[s.jsx("div",{children:s.jsxs(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{hr()},children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.clientAuth.actions.addDevice")]})}),s.jsxs("div",{className:"space-y-2.5",children:[Js>0?s.jsx("div",{className:"flex justify-end",children:s.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{br()},children:t("settings.remoteInstances.clientAuth.actions.clearRevoked")})}):null,kt&&st.length===0&&ct.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.state.loading")}):st.length===0&&ct.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.state.empty")}):s.jsxs(s.Fragment,{children:[ct.map(E=>s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse"}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:E.label||t("settings.remoteInstances.clientAuth.field.labelPlaceholder")}),E.usesRelay?s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50",children:t("settings.remoteInstances.clientAuth.state.viaRelay")}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground truncate",children:t("settings.remoteInstances.clientAuth.state.pending")})]}),s.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ji(E.id)},children:t("settings.common.actions.cancel")})]},`pending-${E.id}`)),st.map(E=>{const le=E.clientKind==="desktop-local",We=E.lastUsedAt?Date.parse(E.lastUsedAt):Number.NaN,it=!E.revokedAt&&(le||Number.isFinite(We)&&Date.now()-We<9e4),Ot=E.revokedAt?t("settings.remoteInstances.clientAuth.state.revoked"):it?E.lastTransport==="relay"&&!le?t("settings.remoteInstances.clientAuth.state.connectedRelay"):t("settings.remoteInstances.clientAuth.state.connectedDirect"):Number.isFinite(We)?t("settings.remoteInstances.clientAuth.lastUsed",{date:tu(We,e,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}):t("settings.remoteInstances.clientAuth.neverUsed");return s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsx("div",{className:"min-w-0",children:s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[s.jsx("span",{className:Pe("h-2 w-2 shrink-0 rounded-full",E.revokedAt?"bg-muted-foreground/20":it?"bg-[var(--status-success)]":"bg-muted-foreground/30")}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:E.label}),Rl(E.devicePlatform)?s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50",children:Rl(E.devicePlatform)}):null,le?s.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:t("settings.remoteInstances.clientAuth.state.thisDevice")}):null,s.jsx("span",{className:Pe("typography-micro truncate",it&&!E.revokedAt?"text-[var(--status-success)]":"text-muted-foreground"),children:Ot})]})}),s.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{xr(E)},disabled:!!E.revokedAt,children:t("settings.remoteInstances.clientAuth.actions.revoke")})]},E.id)})]})]}),jt?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:jt}):null]}):null,n?s.jsxs(qe,{title:t("settings.remoteInstances.direct.title"),info:t("settings.remoteInstances.direct.description"),settingsItem:"remote-instances.direct-hosts",contentClassName:"space-y-4",headerAction:s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Fe(null),ot(!0)},disabled:pe,children:t("settings.remoteInstances.direct.import.action")}),s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Fe(null),at(!0)},disabled:pe,children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.actions.add")]})]}),children:[s.jsx("div",{className:"space-y-2.5",children:ke?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.direct.state.loading")}):ce.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.direct.state.empty")}):ce.map(E=>{const le=re[E.id],We=le?le.status==="ok"?"desktopHostSwitcher.status.connected":le.status==="auth"?"desktopHostSwitcher.status.authRequired":le.status==="update-recommended"?"desktopHostSwitcher.status.updateRecommended":le.status==="incompatible"?"desktopHostSwitcher.status.incompatible":le.status==="wrong-service"?"desktopHostSwitcher.status.wrongService":"desktopHostSwitcher.status.unreachable":"desktopHostSwitcher.status.checking",it=le?.status==="ok";return s.jsx("div",{className:"py-1.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Pe("h-2 w-2 shrink-0 rounded-full",le?it?"bg-[var(--status-success)]":"bg-[var(--status-error)]":"bg-muted-foreground/30 animate-pulse")}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:ei(E.label)}),ie===E.id?s.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:t("desktopHostSwitcher.header.default")}):null,s.jsxs("span",{className:Pe("typography-micro shrink-0",it?"text-[var(--status-success)]":"text-muted-foreground"),children:[t(We),it&&typeof le?.latencyMs=="number"?t("desktopHostSwitcher.status.ping",{ms:Math.max(0,Math.round(le.latencyMs))}):""]})]}),s.jsx("p",{className:Pe("typography-micro text-muted-foreground truncate",E.apiUrl&&"font-mono"),children:E.relay&&!E.apiUrl?t("mobile.connect.relay.badge"):ei(E.apiUrl||E.url)})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{gr(E.id)},disabled:pe||ie===E.id,"aria-label":t("desktopHostSwitcher.actions.setAsDefaultAria"),children:ie===E.id?s.jsx(_,{name:"star-fill",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"star",className:"h-3.5 w-3.5"})}),E.relay&&!E.apiUrl?null:s.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>mr(E),disabled:pe,children:[s.jsx(_,{name:"pencil",className:"h-3.5 w-3.5"}),t("desktopHostSwitcher.actions.edit")]}),s.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ur(E.id)},disabled:pe,children:[s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.delete")]})]})]})},E.id)})}),Ke&&!pt&&!Me&&!Oe?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Ke}):null]}):null,n?s.jsx(Ut,{open:Me,onOpenChange:at,children:s.jsxs(_t,{className:"sm:max-w-lg",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.direct.actions.add")}),s.jsx(qt,{children:t("settings.remoteInstances.direct.addDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:E=>{E.preventDefault(),cr()},children:[s.jsx(He,{className:"h-8",value:Ve,onChange:E=>ye(E.target.value),placeholder:t("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:pe}),s.jsx(He,{className:"h-8",value:Te,onChange:E=>ee(E.target.value),placeholder:t("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:pe,autoFocus:!0}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(He,{className:"h-8",value:ae,onChange:E=>fe(E.target.value),placeholder:t("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:pe}),s.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:t("settings.remoteInstances.direct.note")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{children:t("settings.remoteInstances.direct.headers.title")}),s.jsx(Gt,{children:t("settings.remoteInstances.direct.headers.description")})]}),je.map(E=>s.jsxs("div",{className:"flex w-full gap-2",children:[s.jsx(He,{className:"h-8 font-mono text-xs",value:E.name,onChange:le=>Re(We=>We.map(it=>it.id===E.id?{...it,name:le.target.value}:it)),placeholder:t("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:pe}),s.jsx(He,{className:"h-8 font-mono text-xs",value:E.value,onChange:le=>Re(We=>We.map(it=>it.id===E.id?{...it,value:le.target.value}:it)),placeholder:t("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:pe}),s.jsx("button",{type:"button",onClick:()=>Re(le=>le.filter(We=>We.id!==E.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t("settings.remoteInstances.direct.headers.removeAria"),disabled:pe,children:s.jsx(_,{name:"close",className:"h-4 w-4"})})]},E.id)),s.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Re(E=>[...E,co()]),disabled:pe,children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.headers.actions.add")]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>at(!1),disabled:pe,children:t("settings.common.actions.cancel")}),s.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:pe||!Te.trim(),children:t("settings.remoteInstances.direct.actions.add")})]}),Ke?s.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ke}):null]})]})}):null,n?s.jsx(Ut,{open:!!Oe,onOpenChange:E=>{E||nt(null)},children:s.jsxs(_t,{className:"sm:max-w-lg",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("desktopHostSwitcher.actions.edit")}),s.jsx(qt,{children:t("settings.remoteInstances.direct.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:E=>{E.preventDefault(),vi()},children:[s.jsx(He,{className:"h-8",value:lt,onChange:E=>we(E.target.value),placeholder:t("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:pe}),s.jsx(He,{className:"h-8",value:Je,onChange:E=>Ye(E.target.value),placeholder:t("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:pe,autoFocus:!0}),s.jsx(He,{className:"h-8",value:ze,onChange:E=>Ge(E.target.value),placeholder:t("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:pe}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{children:t("settings.remoteInstances.direct.headers.title")}),s.jsx(Gt,{children:t("settings.remoteInstances.direct.headers.description")})]}),Q.map(E=>s.jsxs("div",{className:"flex w-full gap-2",children:[s.jsx(He,{className:"h-8 font-mono text-xs",value:E.name,onChange:le=>Ue(We=>We.map(it=>it.id===E.id?{...it,name:le.target.value}:it)),placeholder:t("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:pe}),s.jsx(He,{className:"h-8 font-mono text-xs",value:E.value,onChange:le=>Ue(We=>We.map(it=>it.id===E.id?{...it,value:le.target.value}:it)),placeholder:t("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:pe}),s.jsx("button",{type:"button",onClick:()=>Ue(le=>le.filter(We=>We.id!==E.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t("settings.remoteInstances.direct.headers.removeAria"),disabled:pe,children:s.jsx(_,{name:"close",className:"h-4 w-4"})})]},E.id)),s.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Ue(E=>[...E,co()]),disabled:pe,children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.headers.actions.add")]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>nt(null),disabled:pe,children:t("settings.common.actions.cancel")}),s.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:pe,children:t("settings.common.actions.saveChanges")})]}),Ke?s.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ke}):null]})]})}):null,n?s.jsx(Ut,{open:pt,onOpenChange:E=>{mt||ot(E)},children:s.jsxs(_t,{className:"sm:max-w-lg",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.direct.import.action")}),s.jsx(qt,{children:t("settings.remoteInstances.direct.import.description")})]}),s.jsxs("form",{className:"space-y-3","aria-busy":mt,onSubmit:async E=>{if(E.preventDefault(),!(mt||pe)){ht(!0);try{await dr()}catch{Fe(t("mobile.connect.error.unreachable"))}finally{ht(!1)}}},children:[s.jsx(He,{className:"h-8",value:Ce,onChange:E=>{_e(E.target.value),Fe(null)},placeholder:t("settings.remoteInstances.direct.import.placeholder"),disabled:pe||mt,"aria-describedby":Ke?"direct-import-error":void 0,autoFocus:!0}),Ke?s.jsx("p",{id:"direct-import-error",role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ke}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ot(!1),disabled:pe||mt,children:t("settings.common.actions.cancel")}),s.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:pe||mt||!Ce.trim(),children:t("settings.remoteInstances.direct.import.action")})]})]})]})}):null,s.jsx(Ut,{open:Ze,onOpenChange:Nt,children:s.jsxs(_t,{className:Lt==="result"?"sm:max-w-lg":"sm:max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t(Lt==="result"?"settings.remoteInstances.clientAuth.qrDialogTitle":"settings.remoteInstances.clientAuth.actions.addDevice")}),s.jsx(qt,{children:t(Lt==="result"?"settings.remoteInstances.clientAuth.qrScanHint":"settings.remoteInstances.clientAuth.addDevice.subtitle")})]}),Lt==="configure"?s.jsxs("form",{className:"space-y-4",onSubmit:E=>{E.preventDefault(),fr()},children:[s.jsx(He,{className:"h-8",value:vt,onChange:E=>Xe(E.target.value),placeholder:t("settings.remoteInstances.clientAuth.field.labelPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.transportLabel")}),s.jsx("div",{role:"radiogroup","aria-label":t("settings.remoteInstances.clientAuth.addDevice.transportLabel"),className:"space-y-1.5",children:[{key:"relay",label:t("settings.remoteInstances.clientAuth.addDevice.transport.relay"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.relayHint"),available:!!es?.relayAvailable},{key:"lan",label:t("settings.remoteInstances.clientAuth.addDevice.transport.lan"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.lanHint"),available:!!es?.lanUrl},{key:"local",label:t("settings.remoteInstances.clientAuth.addDevice.transport.local"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.localHint"),available:!!es?.localUrl}].map(E=>{const le=Pt===E.key;return s.jsxs("div",{className:Pe("flex items-start gap-2 py-0.5",E.available?"cursor-pointer":"opacity-45"),onClick:()=>{E.available&&Qt(E.key)},role:"presentation",children:[s.jsx(vo,{checked:le,disabled:!E.available,onChange:()=>Qt(E.key),ariaLabel:E.label,className:"mt-0.5"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:Pe("typography-ui-label font-normal",le?"text-foreground":"text-foreground/70"),children:E.label}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:E.hint})]})]},E.key)})}),Pt==="lan"?s.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[s.jsx(to,{checked:Xt,onChange:ss,ariaLabel:t("settings.remoteInstances.clientAuth.addDevice.fallback.relay")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.fallback.relay")})]}):null,Pt==="relay"&&es?.lanUrl?s.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[s.jsx(to,{checked:Xt,onChange:ss,ariaLabel:t("settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal")})]}):null]}),jt?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:jt}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Nt(!1),disabled:Be,children:t("settings.common.actions.cancel")}),s.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:Be||!es,children:t("settings.remoteInstances.clientAuth.addDevice.create")})]})]}):s.jsxs("div",{className:"space-y-3",children:[ge?s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:ge,alt:t("settings.remoteInstances.clientAuth.qrAlt"),className:"w-full max-w-[420px] rounded-md bg-white p-4"})}):null,$e?s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate typography-code text-muted-foreground",children:$e}),s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:ki,children:[s.jsx(_,{name:te?"check":"file-copy",className:Pe("h-3.5 w-3.5",te&&"text-[var(--status-success)]")}),t(te?"settings.remoteInstances.clientAuth.actions.copied":"settings.common.actions.copyAll")]})]}):null,s.jsx("div",{className:"flex justify-end",children:s.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>Nt(!1),children:t("settings.remoteInstances.clientAuth.addDevice.done")})})]})]})}),n?s.jsx(qe,{title:t("settings.remoteInstances.sidebar.title"),description:t("settings.remoteInstances.sidebar.total",{count:r.length}),headerAction:s.jsxs(G,{type:"button",size:"xs",className:"!font-normal",onClick:yi,children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.sidebar.actions.addSshInstance")]}),contentClassName:"space-y-2.5",children:d?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.state.loadingInstances")}):r.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:l.length===1?t("settings.remoteInstances.page.empty.noInstancesWithOneImport"):l.length>1?t("settings.remoteInstances.page.empty.noInstancesWithImports",{count:l.length}):t("settings.remoteInstances.page.empty.noInstances")}):r.map(E=>{const le=i[E.id],We=E.nickname?.trim()||E.sshParsed?.destination||E.id,it=le?.phase,Ot=it==="ready",xs=Ol(it),Zs=xs==="error"?le?.detail:void 0;return s.jsxs("div",{className:"space-y-1.5 py-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${zl(it)}`}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:We})]}),s.jsxs("p",{className:"typography-micro text-muted-foreground truncate",children:[t(Ll(xs)),xs==="connecting"?` · ${t(Fl(it))}`:"",Ot&&le?.localUrl?` · ${le.localUrl}`:""]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Ot?s.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>kr(le?.localUrl),children:[s.jsx(_,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.open")]}):null,s.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{(Ot?p(E.id):k(E.id)).catch(_s=>$.error(t(Ot?"settings.remoteInstances.sidebar.toast.disconnectFailed":"settings.remoteInstances.sidebar.toast.connectFailed"),{description:_s instanceof Error?_s.message:String(_s)}))},children:[Ot?s.jsx(_,{name:"stop",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"plug-2",className:"h-3.5 w-3.5"}),t(Ot?"settings.remoteInstances.sidebar.actions.disconnect":"settings.remoteInstances.sidebar.actions.connect")]}),s.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>I(E.id),children:[s.jsx(_,{name:"pencil",className:"h-3.5 w-3.5"}),t("desktopHostSwitcher.actions.edit")]}),s.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{window.confirm(t("settings.remoteInstances.page.confirm.removeInstance"))&&b(E.id).catch(_s=>$.error(t("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:_s instanceof Error?_s.message:String(_s)}))},children:[s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.delete")]})]})]}),Zs?s.jsx("p",{className:"typography-micro text-[var(--status-error)] break-words",children:Zs}):null]},E.id)})}):null,n?s.jsx(Ut,{open:gn,onOpenChange:Ks,children:s.jsxs(_t,{className:"sm:max-w-lg",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.sidebar.actions.addSshInstance")}),s.jsx(qt,{children:t("settings.remoteInstances.page.addDialog.description")})]}),s.jsx(mn,{value:zs,onChange:on,"aria-label":t("settings.remoteInstances.page.addDialog.sourceLabel"),options:[{value:"saved",label:t("settings.remoteInstances.page.addDialog.tab.saved")},{value:"manual",label:t("settings.remoteInstances.page.addDialog.tab.manual")}]}),zs==="saved"?s.jsxs("div",{className:"space-y-2",children:[s.jsx(He,{className:"h-8",value:Qs,onChange:E=>Ys(E.target.value),placeholder:t("settings.remoteInstances.page.addDialog.searchPlaceholder"),autoFocus:!0}),c?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.import.loading")}):l.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.addDialog.emptySaved")}):Ni.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.addDialog.searchEmpty")}):s.jsx("div",{className:"max-h-[45vh] overflow-auto",children:Ni.map(E=>s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-2.5 last:border-b-0",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"typography-ui-label font-medium text-foreground truncate",children:[E.host,E.pattern?` ${t("settings.remoteInstances.page.import.patternSuffix")}`:""]}),s.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:E.sshCommand})]}),s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{wr(E.host,E.pattern)},children:t("settings.remoteInstances.page.addDialog.use")})]},`${E.source}:${E.host}`))})]}):s.jsxs("form",{className:"space-y-3",onSubmit:E=>{E.preventDefault(),pr()},children:[s.jsx(He,{className:"h-8",value:Rt,onChange:E=>Wt(E.target.value),placeholder:t("settings.remoteInstances.page.field.nicknamePlaceholder"),disabled:h}),s.jsx(He,{className:"h-8",value:Us,onChange:E=>Dn(E.target.value),placeholder:t("settings.remoteInstances.page.field.sshCommandPlaceholder"),disabled:h,autoFocus:!0}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ks(!1),disabled:h,children:t("settings.common.actions.cancel")}),s.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:h||!Us.trim(),children:t("settings.common.actions.create")})]})]})]})}):null,s.jsx(Ut,{open:!!W,onOpenChange:E=>{E||wa()},children:s.jsxs(_t,{className:"sm:max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.page.patternDialog.title")}),s.jsx(qt,{children:W?t("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:W}):t("settings.remoteInstances.page.patternDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:E=>{E.preventDefault(),Bn()},children:[s.jsx(He,{value:J,onChange:E=>q(E.target.value),placeholder:t("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:wa,disabled:z,children:t("settings.common.actions.cancel")}),s.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:z,children:t("settings.remoteInstances.page.actions.create")})]})]})]})})]});const fn=A.remoteOpenchamber.mode==="managed",Vn=fn&&A.remoteOpenchamber.bindHost==="0.0.0.0",Ia=Vn&&!A.auth.openchamberPassword?.value?.trim(),Cr=A.nickname?.trim()||A.sshParsed?.destination||A.id;return s.jsx(Ut,{open:!!A,onOpenChange:E=>{E||I(null)},children:s.jsxs(_t,{className:"sm:max-w-4xl max-h-[90vh] overflow-auto",children:[s.jsxs("div",{className:"mb-6 px-1",children:[s.jsx("h1",{className:`${Xr} truncate`,children:Cr}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${zl(ln)}`}),s.jsx("span",{className:"text-foreground",children:t(Ll(ya))}),ya==="connecting"?s.jsx("span",{children:t(Fl(ln))}):null,ys?.localUrl?s.jsx("span",{className:"font-mono text-foreground/80",children:ys.localUrl}):null,va?s.jsx("span",{children:t("settings.remoteInstances.page.status.reconnectStale")}):null]})]}),s.jsxs(qe,{title:t("settings.remoteInstances.page.section.actions"),info:t("settings.remoteInstances.page.section.actionsDescription"),divider:!1,contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(G,{type:"button",variant:cn?"outline":"default",size:"xs",className:"!font-normal",onClick:Ii,disabled:ne||Z,children:[cn?s.jsx(_,{name:"stop",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"plug-2",className:"h-3.5 w-3.5"}),Sr]}),s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Pi,disabled:!Ti,children:[s.jsx(_,{name:"refresh",className:`h-3.5 w-3.5 ${$n||Mn&&!va?"animate-spin":""}`}),Ai]}),s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Nr()},children:[s.jsx(_,{name:"terminal-window",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.logs")]}),s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal text-[var(--status-error)] border-[var(--status-error)]/30 hover:text-[var(--status-error)]",onClick:()=>{window.confirm(t("settings.remoteInstances.page.confirm.removeInstance"))&&b(A.id).then(()=>{I(null),$.success(t("settings.remoteInstances.page.toast.instanceRemoved"))}).catch(le=>{$.error(t("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:le instanceof Error?le.message:String(le)})})},children:[s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.sidebar.actions.remove")]})]}),ya==="error"&&ys?.detail?s.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--status-error)]/30 bg-[var(--status-error-background)] p-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)] break-words",children:ys.detail}),Xa?s.jsx("p",{className:"typography-micro text-muted-foreground",children:t(Xa)}):null,Xn&&!Xa?s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Na(Xn)},children:t(Xn==="uiPassword"?"settings.remoteInstances.page.error.action.setUiPassword":Xn==="localPort"?"settings.remoteInstances.page.error.action.pickRandomPort":"settings.remoteInstances.page.error.action.setRemotePort")}):null]}):null,ys?.localUrl?s.jsxs("div",{className:"flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx("span",{children:t("settings.remoteInstances.page.status.currentLocalUrl")}),s.jsx("span",{className:"font-mono text-foreground/90",children:ys.localUrl})]}):null]}),s.jsxs(qe,{title:t("settings.remoteInstances.page.section.instance"),info:t("settings.remoteInstances.page.section.instanceDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.sshCommand")}),s.jsx(He,{className:"h-7 md:max-w-xl",value:A.sshCommand,onChange:E=>ds(le=>({...le,sshCommand:E.target.value})),placeholder:t("settings.remoteInstances.page.field.sshCommandPlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.nickname")}),s.jsx(He,{className:"h-7 md:max-w-sm",value:A.nickname||"",onChange:E=>ds(le=>({...le,nickname:E.target.value})),placeholder:t("settings.remoteInstances.page.field.nicknamePlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t("settings.remoteInstances.page.field.mode"),hint:t("settings.remoteInstances.page.field.modeHint")})}),s.jsxs(Et,{value:A.remoteOpenchamber.mode,onValueChange:E=>ds(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,mode:E==="external"?"external":"managed"}})),children:[s.jsx(At,{size:Bt,className:"w-fit min-w-[140px]",children:s.jsx($t,{placeholder:t("settings.remoteInstances.page.field.modePlaceholder")})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:"managed",children:t("settings.remoteInstances.page.field.modeManaged")}),s.jsx(ut,{value:"external",children:t("settings.remoteInstances.page.field.modeExternal")})]})]})]})]}),s.jsxs(Cn,{open:zt,onOpenChange:Dt,children:[s.jsxs(In,{className:"mt-6 w-auto justify-start gap-1.5",children:[s.jsx("span",{className:Dc,children:t("settings.remoteInstances.page.section.advanced")}),s.jsx(_,{name:zt?"arrow-up-s":"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsxs(Pn,{children:[s.jsx("p",{className:"px-2 pb-2 typography-micro text-muted-foreground",children:t("settings.remoteInstances.page.section.advancedHint")}),s.jsxs("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.connectionTimeoutSeconds")}),s.jsx(hs,{containerClassName:"w-fit",min:5,max:240,step:1,className:Pe(bs,"tabular-nums"),value:A.connectionTimeoutSec,onValueChange:E=>{ds(le=>({...le,connectionTimeoutSec:Number.isFinite(E)?E:le.connectionTimeoutSec}))}})]}),s.jsxs(qe,{title:t("settings.remoteInstances.page.section.remoteServer"),info:t("settings.remoteInstances.page.section.remoteServerDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",ref:Si,children:s.jsx(en,{label:t("settings.remoteInstances.page.field.preferredRemotePort"),hint:t("settings.remoteInstances.page.field.preferredRemotePortHint")})}),s.jsx(hs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Pe(bs,"tabular-nums"),value:A.remoteOpenchamber.preferredPort,onValueChange:E=>{ds(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,preferredPort:Number.isFinite(E)&&E>0?E:void 0}}))},onClear:()=>{ds(E=>({...E,remoteOpenchamber:{...E.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]}),fn?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t("settings.remoteInstances.page.field.installMethod"),hint:t("settings.remoteInstances.page.field.installMethodHint")})}),s.jsxs(Et,{value:A.remoteOpenchamber.installMethod,onValueChange:E=>ds(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,installMethod:E==="npm"||E==="bun"?E:"auto"}})),children:[s.jsx(At,{size:Bt,className:"w-fit min-w-[140px]",children:s.jsx($t,{placeholder:t("settings.remoteInstances.page.field.selectInstallMethodPlaceholder")})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:"auto",children:t("settings.remoteInstances.page.field.installMethodAuto")}),s.jsx(ut,{value:"bun",children:"bun"}),s.jsx(ut,{value:"npm",children:"npm"})]})]})]}):null,fn?s.jsxs("div",{className:"py-1.5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t("settings.remoteInstances.page.field.remoteLanAccess"),hint:t("settings.remoteInstances.page.field.remoteLanAccessHint")})}),s.jsx(Ba,{checked:Vn,onCheckedChange:E=>ds(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,bindHost:E?"0.0.0.0":"127.0.0.1"}})),"aria-label":t("settings.remoteInstances.page.field.remoteLanAccess")})]}),Vn?s.jsx("p",{className:"mt-2 typography-micro text-[var(--status-warning)] md:pl-[16rem]",children:t("settings.remoteInstances.page.field.remoteLanAccessWarning")}):null]}):null,fn?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t("settings.remoteInstances.page.field.keepServerRunning"),hint:t("settings.remoteInstances.page.field.keepServerRunningHint")})}),s.jsx("div",{className:"flex w-full items-center gap-2 md:max-w-xs",children:s.jsx(Ba,{checked:A.remoteOpenchamber.keepRunning,onCheckedChange:E=>ds(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,keepRunning:E}}))})})]}):null]}),s.jsxs(qe,{title:t("settings.remoteInstances.page.section.mainTunnel"),info:t("settings.remoteInstances.page.section.mainTunnelDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t("settings.remoteInstances.page.field.bindHost"),hint:t("settings.remoteInstances.page.field.bindHostHint")})}),s.jsxs(Et,{value:A.localForward.bindHost,onValueChange:E=>{E==="0.0.0.0"&&!window.confirm(t("settings.remoteInstances.page.confirm.bindAllInterfaces"))||ds(le=>({...le,localForward:{...le.localForward,bindHost:E==="localhost"||E==="0.0.0.0"?E:"127.0.0.1"}}))},children:[s.jsx(At,{size:Bt,className:"w-fit min-w-[240px]",children:s.jsx($t,{placeholder:t("settings.remoteInstances.page.field.selectBindHostPlaceholder")})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:"127.0.0.1",children:t("settings.remoteInstances.page.field.bindHostOption.loopback")}),s.jsx(ut,{value:"localhost",children:t("settings.remoteInstances.page.field.bindHostOption.localhost")}),s.jsx(ut,{value:"0.0.0.0",children:t("settings.remoteInstances.page.field.bindHostOption.lan")})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t("settings.remoteInstances.page.field.preferredLocalPort"),hint:t("settings.remoteInstances.page.field.preferredLocalPortHint")})}),s.jsxs("div",{className:"flex w-full items-center gap-2 md:max-w-sm",children:[s.jsx(hs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Pe(bs,"tabular-nums"),value:A.localForward.preferredLocalPort,onValueChange:E=>{ds(le=>({...le,localForward:{...le.localForward,preferredLocalPort:Number.isFinite(E)&&E>0?E:void 0}}))},onClear:()=>{ds(E=>({...E,localForward:{...E.localForward,preferredLocalPort:void 0}}))},emptyLabel:t("settings.remoteInstances.page.field.auto")}),s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal h-7 w-7 px-0",title:t("settings.remoteInstances.page.actions.pickRandomPort"),onClick:()=>ds(E=>({...E,localForward:{...E.localForward,preferredLocalPort:Gi()}})),children:s.jsx(_,{name:"shuffle",className:"h-3.5 w-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1 pt-1",children:[s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.remoteInstances.page.tunnelPreview.caption")}),s.jsx("p",{className:"typography-micro font-mono text-foreground/80 break-all",children:`${A.localForward.bindHost}:${A.localForward.preferredLocalPort||"auto"} → ${A.sshParsed?.destination||A.nickname||"remote"}:${A.remoteOpenchamber.preferredPort||"auto"}`})]})]}),s.jsxs(qe,{title:t("settings.remoteInstances.page.section.authentication"),info:t("settings.remoteInstances.page.section.authenticationDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t("settings.remoteInstances.page.field.sshPasswordOptional"),hint:t("settings.remoteInstances.page.field.sshPasswordHint")})}),s.jsx(He,{className:"h-7 md:max-w-sm",type:"password",value:A.auth.sshPassword?.value||"",onChange:E=>ds(le=>({...le,auth:{...le.auth,sshPassword:{enabled:E.target.value.trim().length>0,value:E.target.value,store:le.auth.sshPassword?.store||"never"}}})),placeholder:t("settings.remoteInstances.page.field.sshPasswordPlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t(Vn?"settings.remoteInstances.page.field.uiPasswordRequired":"settings.remoteInstances.page.field.uiPasswordOptional"),hint:t(fn?"settings.remoteInstances.page.field.uiPasswordHintManaged":"settings.remoteInstances.page.field.uiPasswordHintExternal")})}),s.jsx(He,{className:Pe("h-7 md:max-w-sm",Ia&&"border-[var(--status-error)]"),type:"password",ref:ka,"aria-invalid":Ia,value:A.auth.openchamberPassword?.value||"",onChange:E=>ds(le=>({...le,auth:{...le.auth,openchamberPassword:{enabled:E.target.value.trim().length>0,value:E.target.value,store:le.auth.openchamberPassword?.store||"never"}}})),placeholder:t("settings.remoteInstances.page.field.uiPasswordPlaceholder")})]}),Ia?s.jsx("p",{className:"typography-micro text-[var(--status-error)] md:pl-[16rem]",children:t("settings.remoteInstances.page.field.uiPasswordMissingForLan")}):null]}),s.jsxs(qe,{title:t("settings.remoteInstances.page.section.portForwards"),info:t("settings.remoteInstances.page.section.portForwardsDescription"),contentClassName:"space-y-2",children:[A.portForwards.length===0?s.jsx("p",{className:"typography-micro text-muted-foreground/80",children:t("settings.remoteInstances.page.empty.noExtraForwards")}):null,A.portForwards.map((E,le)=>{const We=Kt=>{ds(Yt=>({...Yt,portForwards:Yt.portForwards.map((bn,dn)=>dn===le?Kt(bn):bn)}))},it=E.type==="remote"?"Local target":"Local listen",Ot=E.type==="remote"?"Local host and port on your machine that receives traffic from remote -R listener.":"Local host and port where this forward listens on your machine.",xs=E.type==="remote"?"Remote listen":"Remote target",Zs=E.type==="remote"?"Remote host and port where SSH creates the -R listener.":"Remote host and port that receives traffic from local -L listener.",ps=Ul(E.localHost||"localhost",E.localPort),_s=Ul(E.remoteHost||"localhost",E.remotePort),Rn=E.type==="local"&&typeof E.localPort=="number"&&E.localPort>0,xn=Rn?`http://${ax(E.localHost)}:${E.localPort}`:"",Pa=!!se[E.id],Aa=E.type==="local"?t("settings.remoteInstances.page.forwardType.local"):E.type==="remote"?t("settings.remoteInstances.page.forwardType.remote"):t("settings.remoteInstances.page.forwardType.dynamic");return s.jsxs(Cn,{open:Pa,onOpenChange:Kt=>{B(Yt=>({...Yt,[E.id]:Kt}))},className:`${le>0?"border-t border-[var(--surface-subtle)]":""} py-2`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:s.jsxs(In,{className:"flex items-center gap-2 group",children:[s.jsx(_,{name:"arrow-down-s",className:`h-4 w-4 text-muted-foreground transition-transform ${Pa?"rotate-180":""}`}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ex(E)}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:Aa})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ba,{checked:E.enabled,onCheckedChange:Kt=>We(Yt=>({...Yt,enabled:Kt})),"aria-label":t("settings.remoteInstances.page.actions.enableForwardAria")}),s.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>ds(Kt=>({...Kt,portForwards:Kt.portForwards.filter(Yt=>Yt.id!==E.id)})),children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Pn,{className:"pt-2",children:s.jsxs("div",{className:"space-y-0 pb-2",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:t("settings.remoteInstances.page.field.forwardType"),hint:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.remoteInstances.page.field.forwardTypeHint")}),s.jsx("p",{children:t(nx(E.type))})]})})}),s.jsxs(Et,{value:E.type,onValueChange:Kt=>We(Yt=>({...Yt,type:Kt==="dynamic"||Kt==="remote"?Kt:"local"})),children:[s.jsx(At,{size:Bt,className:"w-fit min-w-[140px]",children:s.jsx($t,{placeholder:t("settings.remoteInstances.page.field.typePlaceholder")})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:"local",children:t("settings.remoteInstances.page.forwardType.local")}),s.jsx(ut,{value:"remote",children:t("settings.remoteInstances.page.forwardType.remote")}),s.jsx(ut,{value:"dynamic",children:t("settings.remoteInstances.page.forwardType.dynamic")})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:it,hint:Ot})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(He,{className:"h-7 w-32",value:E.localHost||"127.0.0.1",onChange:Kt=>We(Yt=>({...Yt,localHost:Kt.target.value})),placeholder:t("settings.remoteInstances.page.field.localHostPlaceholder")}),s.jsx("span",{className:"text-muted-foreground",children:":"}),s.jsx(hs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Pe(bs,"tabular-nums"),value:E.localPort,onValueChange:Kt=>{We(Yt=>({...Yt,localPort:Number.isFinite(Kt)&&Kt>0?Kt:void 0}))},onClear:()=>{We(Kt=>({...Kt,localPort:void 0}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]})]}),E.type!=="dynamic"?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(en,{label:xs,hint:Zs})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(He,{className:"h-7 w-32",value:E.remoteHost||"",onChange:Kt=>We(Yt=>({...Yt,remoteHost:Kt.target.value})),placeholder:t("settings.remoteInstances.page.field.remoteHostPlaceholder")}),s.jsx("span",{className:"text-muted-foreground",children:":"}),s.jsx(hs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Pe(bs,"tabular-nums"),value:E.remotePort,onValueChange:Kt=>{We(Yt=>({...Yt,remotePort:Number.isFinite(Kt)&&Kt>0?Kt:void 0}))},onClear:()=>{We(Kt=>({...Kt,remotePort:void 0}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]})]}):null,s.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md bg-[var(--surface-subtle)] p-2",children:[s.jsx("div",{className:"flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80",children:E.type==="dynamic"?s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:ps}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.localSocks5")})]}):E.type==="remote"?s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"server",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:_s}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.remote")}),s.jsx(_,{name:"arrow-right",className:"h-3.5 w-3.5"}),s.jsx(_,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:ps}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.local")})]}):s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:ps}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.local")}),s.jsx(_,{name:"arrow-right",className:"h-3.5 w-3.5"}),s.jsx(_,{name:"server",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:_s}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.remote")})]})}),Rn?s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{jn(xn).then(Kt=>{Kt||$.error(t("settings.remoteInstances.page.toast.openLocalEndpointFailed"))})},children:[s.jsx(_,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.openLocal")]}):null]})]})})]},E.id)}),s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal mt-1",onClick:()=>{const E=tx();ds(le=>({...le,portForwards:[...le.portForwards,E]})),B(le=>({...le,[E.id]:!0}))},children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.addForward")]})]})]})]}),s.jsx("div",{className:"mt-8 border-t border-[var(--interactive-border)] pt-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{jr()},disabled:!yr||h,children:t("settings.common.actions.saveChanges")}),ys?.localUrl?s.jsxs(s.Fragment,{children:[s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{_a(ys.localUrl||"").then(E=>{E.ok&&$.success(t("settings.remoteInstances.page.toast.localUrlCopied"))})},children:[s.jsx(_,{name:"file-copy",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.copyLocalUrl")]}),s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ci()},children:[s.jsx(_,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.open")]})]}):null,g?s.jsx("div",{className:"ml-auto typography-meta text-[var(--status-error)]",children:g}):null]})}),T,s.jsx(Ut,{open:P,onOpenChange:D,children:s.jsxs(_t,{className:"sm:max-w-2xl",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.page.logsDialog.title")}),s.jsx(qt,{children:A?.nickname?.trim()||A?.sshParsed?.destination||A?.id||t("settings.remoteInstances.page.logsDialog.selectedInstanceFallback")})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Ss,disabled:F||!Ne.trim(),children:[s.jsx(_,{name:"file-copy",className:"h-3.5 w-3.5"}),t("settings.common.actions.copyAll")]}),s.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ca()},disabled:F,children:[s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.clear")]})]}),F?s.jsx("div",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.logsDialog.loading")}):C?s.jsx("div",{className:"typography-meta text-[var(--status-error)]",children:C}):s.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:U.length>0?U.join(`
29
+ `):t("settings.remoteInstances.page.logsDialog.empty")})]})}),s.jsx(Ut,{open:!!W,onOpenChange:E=>{E||wa()},children:s.jsxs(_t,{className:"sm:max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.page.patternDialog.title")}),s.jsx(qt,{children:W?t("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:W}):t("settings.remoteInstances.page.patternDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:E=>{E.preventDefault(),Bn()},children:[s.jsx(He,{value:J,onChange:E=>q(E.target.value),placeholder:t("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:wa,disabled:z,children:t("settings.common.actions.cancel")}),s.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:z,children:t("settings.common.actions.create")})]})]})]})})]})})},ux=t=>t,mx=(t,e,a)=>t&&!e&&!a,px=Mt(),uo=t=>px.safeParse(t?.settings?.apiKey).data??null,Wn=(t,e)=>t.find(a=>a.id===e),ci=t=>t==="opencode-go"?"opencode":t,Wi=(t,e)=>{const a=Wn(t,e)?.connections,n=ci(e);if(n===e)return a;const r=Wn(t,n)?.connections;if(!(!a&&!r))return[...a??[],...r??[]]},$l=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),gx=t=>(t?.methods??[]).find(e=>e.type==="key"),Bl=t=>t===void 0||gx(t)!==void 0,Vl=t=>(t?.connections??[]).filter(e=>e.type==="credential"),Hl=t=>(t.connections?.length??0)>0?!0:typeof t.optionsApiKey=="string"&&t.optionsApiKey.trim().length>0,hx=t=>{if(t.integrations===null)return null;const e=Wi(t.integrations,t.providerId),a=(e??[]).filter(n=>n.type==="credential").length;return a>1?{kind:"accounts",count:a}:a===1||(t.optionsApiKey?.trim().length??0)>0?{kind:"connected"}:(e??[]).some(n=>n.type==="env")?{kind:"environment"}:e===void 0?null:{kind:"signInNeeded"}},fx=t=>t.modelCount>0&&(!t.integrationsLoaded||t.hasCredentials||!!t.isEditableCustomProvider),xx=t=>!t.hasCredentials&&!t.userDismissed&&!t.isEditableCustomProvider,md=Pe("group flex min-h-[132px] flex-col rounded-xl border p-4 text-left transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]"),bx=(t,e)=>{const[a,n]=o.useState(()=>new Set);return o.useEffect(()=>{let r=!1;const i=e?`?directory=${encodeURIComponent(e)}`:"";return Promise.all(t.map(async l=>{try{const d=await St(`/api/provider/${encodeURIComponent(l.id)}/source${i}`,{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return null;const c=await d.json().catch(()=>null);return(c?.sources??c?.data?.sources)?.project?.exists===!0?l.id:null}catch{return null}})).then(l=>{r||n(new Set(l.filter(d=>d!==null)))}),()=>{r=!0}},[e,t]),a},vx=t=>{const e=tt.c(9),{status:a}=t,{t:n}=Qe();let r;e[0]!==a.count||e[1]!==a.kind||e[2]!==n?(r=a.kind==="accounts"?n("settings.providers.card.status.accounts",{count:a.count}):a.kind==="connected"?n("settings.providers.card.status.connected"):a.kind==="environment"?n("settings.providers.card.status.environment"):n("settings.providers.card.status.signInNeeded"),e[0]=a.count,e[1]=a.kind,e[2]=n,e[3]=r):r=e[3];const i=r,l=a.kind==="signInNeeded"?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":a.kind==="environment"?"bg-[var(--surface-muted)] text-muted-foreground":"bg-[var(--status-success)]/15 text-[var(--status-success)]";let d;e[4]!==l?(d=Pe("max-w-40 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",l),e[4]=l,e[5]=d):d=e[5];let c;return e[6]!==i||e[7]!==d?(c=s.jsx("span",{className:d,children:i}),e[6]=i,e[7]=d,e[8]=c):c=e[8],c},yx=t=>{const e=tt.c(39),{provider:a,status:n,fromProject:r,onSelect:i}=t,{t:l}=Qe(),d=a.models.length;let c;e[0]!==i||e[1]!==a.id?(c=()=>i(a.id),e[0]=i,e[1]=a.id,e[2]=c):c=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=Pe(md,"border-[var(--interactive-border)] bg-[var(--surface-elevated)] hover:border-[var(--interactive-border-hover)] hover:bg-[var(--interactive-hover)]/50"),e[3]=h):h=e[3];let g;e[4]!==a.id?(g=s.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(Va,{providerId:a.id,className:"size-5"})}),e[4]=a.id,e[5]=g):g=e[5];let f;e[6]!==n?(f=n?s.jsx(vx,{status:n}):null,e[6]=n,e[7]=f):f=e[7];let m;e[8]!==g||e[9]!==f?(m=s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[g,f]}),e[8]=g,e[9]=f,e[10]=m):m=e[10];const u=a.name||a.id;let v;e[11]!==u?(v=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:u}),e[11]=u,e[12]=v):v=e[12];let w;e[13]!==a.id?(w=s.jsx("div",{className:"mt-0.5 truncate font-mono typography-micro text-muted-foreground",children:a.id}),e[13]=a.id,e[14]=w):w=e[14];let b;e[15]!==v||e[16]!==w?(b=s.jsxs("div",{className:"mt-3 min-w-0",children:[v,w]}),e[15]=v,e[16]=w,e[17]=b):b=e[17];let k;e[18]!==d||e[19]!==l?(k=l("settings.providers.card.models",{count:d}),e[18]=d,e[19]=l,e[20]=k):k=e[20];let p;e[21]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(_,{name:"stack",className:"size-3.5 opacity-70","aria-hidden":!0}),e[21]=p):p=e[21];let S;e[22]!==d?(S=s.jsx("span",{className:"tabular-nums",children:d}),e[22]=d,e[23]=S):S=e[23];let N;e[24]!==k||e[25]!==S?(N=s.jsxs("span",{className:"inline-flex items-center gap-1","aria-label":k,children:[p,S]}),e[24]=k,e[25]=S,e[26]=N):N=e[26];let I;e[27]!==r||e[28]!==l?(I=r?s.jsx("span",{className:"rounded-full border border-[var(--interactive-border)] px-2 py-px text-[10px] font-medium",children:l("settings.providers.card.source.project")}):null,e[27]=r,e[28]=l,e[29]=I):I=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(_,{name:"arrow-right-s",className:"ml-auto size-4 opacity-0 transition-opacity duration-150 group-hover:opacity-70 group-focus-visible:opacity-70","aria-hidden":!0}),e[30]=y):y=e[30];let T;e[31]!==N||e[32]!==I?(T=s.jsxs("div",{className:"mt-auto flex items-center gap-2 pt-3 typography-micro text-muted-foreground",children:[N,I,y]}),e[31]=N,e[32]=I,e[33]=T):T=e[33];let x;return e[34]!==c||e[35]!==T||e[36]!==m||e[37]!==b?(x=s.jsxs("button",{type:"button",onClick:c,className:h,children:[m,b,T]}),e[34]=c,e[35]=T,e[36]=m,e[37]=b,e[38]=x):x=e[38],x},jx=t=>{const e=tt.c(47),{providers:a,integrations:n,directory:r,onSelect:i,onConnect:l}=t,{t:d}=Qe(),[c,h]=o.useState(""),g=bx(a,r);let f,m,u,v,w,b,k,p,S;if(e[0]!==n||e[1]!==l||e[2]!==i||e[3]!==g||e[4]!==a||e[5]!==c||e[6]!==d){const y=Ja([...a],c,wx);let T;e[16]!==c?(T=c.trim(),e[16]=c,e[17]=T):T=e[17];const x=T.length>0;f=ts,e[18]!==d?(w=d("settings.page.providers.title"),e[18]=d,e[19]=w):w=e[19],e[20]!==d?(b=d("settings.providers.grid.description"),e[20]=d,e[21]=b):b=e[21],e[22]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(xi,{className:"w-full min-w-0 @xl:w-56"}),e[22]=k):k=e[22],e[23]!==a.length||e[24]!==c||e[25]!==d?(p=a.length>0?s.jsxs("div",{className:"relative mb-4 max-w-[24rem]",children:[s.jsx(_,{name:"search",className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),s.jsx(He,{value:c,onChange:R=>h(R.target.value),placeholder:d("settings.providers.grid.searchPlaceholder"),"aria-label":d("settings.providers.grid.searchPlaceholder"),className:"h-9 pl-8"})]}):null,e[23]=a.length,e[24]=c,e[25]=d,e[26]=p):p=e[26],S=a.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:d("settings.providers.grid.empty")}):y.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:d("settings.providers.grid.noMatches",{query:c.trim()})}):null,m="grid grid-cols-1 gap-3 @xl:grid-cols-2 @3xl:grid-cols-3",e[27]!==x||e[28]!==l||e[29]!==d?(u=x?null:s.jsxs("button",{type:"button",onClick:l,className:Pe(md,"items-center justify-center gap-2 border-dashed border-[var(--interactive-border)] text-muted-foreground hover:bg-[var(--interactive-hover)]/50 hover:text-foreground"),children:[s.jsx("span",{className:"flex size-10 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(_,{name:"add",className:"size-5"})}),s.jsx("span",{className:"typography-ui-label font-medium",children:d("settings.providers.grid.connect")}),s.jsx("span",{className:"typography-micro",children:d("settings.providers.grid.connectHint")})]}),e[27]=x,e[28]=l,e[29]=d,e[30]=u):u=e[30];let A;e[31]!==n||e[32]!==i||e[33]!==g?(A=R=>s.jsx(yx,{provider:R,status:hx({integrations:n,providerId:R.id,optionsApiKey:uo(R)}),fromProject:g.has(R.id),onSelect:i},R.id),e[31]=n,e[32]=i,e[33]=g,e[34]=A):A=e[34],v=y.map(A),e[0]=n,e[1]=l,e[2]=i,e[3]=g,e[4]=a,e[5]=c,e[6]=d,e[7]=f,e[8]=m,e[9]=u,e[10]=v,e[11]=w,e[12]=b,e[13]=k,e[14]=p,e[15]=S}else f=e[7],m=e[8],u=e[9],v=e[10],w=e[11],b=e[12],k=e[13],p=e[14],S=e[15];let N;e[35]!==m||e[36]!==u||e[37]!==v?(N=s.jsxs("div",{className:m,children:[u,v]}),e[35]=m,e[36]=u,e[37]=v,e[38]=N):N=e[38];let I;return e[39]!==f||e[40]!==w||e[41]!==b||e[42]!==k||e[43]!==p||e[44]!==S||e[45]!==N?(I=s.jsxs(f,{title:w,description:b,headerEnd:k,children:[p,S,N]}),e[39]=f,e[40]=w,e[41]=b,e[42]=k,e[43]=p,e[44]=S,e[45]=N,e[46]=I):I=e[46],I};function wx(t){return[t.name||t.id,t.id]}const ql=t=>{const e=tt.c(2),{icon:a}=t;let n;return e[0]!==a?(n=s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:s.jsx(_,{name:a,className:"size-4"})}),e[0]=a,e[1]=n):n=e[1],n},kx=t=>{const e=tt.c(32),{initial:a,onSave:n,onCancel:r}=t,{t:i}=Qe(),[l,d]=o.useState(a);let c;e[0]!==l?(c=l.trim(),e[0]=l,e[1]=c):c=e[1];const h=c;let g;e[2]!==a||e[3]!==r||e[4]!==n||e[5]!==h?(g=()=>{if(h.length===0||h===a){r();return}n(h)},e[2]=a,e[3]=r,e[4]=n,e[5]=h,e[6]=g):g=e[6];const f=g;let m;e[7]!==f?(m=y=>{y.preventDefault(),f()},e[7]=f,e[8]=m):m=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=y=>d(y.target.value),e[9]=u):u=e[9];let v;e[10]!==r?(v=y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),r())},e[10]=r,e[11]=v):v=e[11];let w;e[12]!==i?(w=i("settings.providers.accounts.nameAria"),e[12]=i,e[13]=w):w=e[13];let b;e[14]!==v||e[15]!==w||e[16]!==l?(b=s.jsx(He,{autoFocus:!0,value:l,onChange:u,onKeyDown:v,"aria-label":w,className:"h-8 max-w-[18rem]"}),e[14]=v,e[15]=w,e[16]=l,e[17]=b):b=e[17];let k;e[18]!==i?(k=i("settings.providers.accounts.save"),e[18]=i,e[19]=k):k=e[19];let p;e[20]!==k?(p=s.jsx(G,{type:"submit",size:"xs",children:k}),e[20]=k,e[21]=p):p=e[21];let S;e[22]!==i?(S=i("settings.providers.page.actions.cancel"),e[22]=i,e[23]=S):S=e[23];let N;e[24]!==r||e[25]!==S?(N=s.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:r,children:S}),e[24]=r,e[25]=S,e[26]=N):N=e[26];let I;return e[27]!==N||e[28]!==m||e[29]!==b||e[30]!==p?(I=s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-2",onSubmit:m,children:[b,p,N]}),e[27]=N,e[28]=m,e[29]=b,e[30]=p,e[31]=I):I=e[31],I},Nx=t=>{const e=tt.c(32),{connections:a,activeId:n,unusedIds:r,busyId:i,onActivate:l,onRename:d,onRemove:c}=t,{t:h}=Qe(),[g,f]=o.useState(null);let m;if(e[0]!==a||e[1]!==r){let S;e[3]!==r?(S=N=>N.type==="credential"&&!r.has(N.id),e[3]=r,e[4]=S):S=e[4],m=a.filter(S),e[0]=a,e[1]=r,e[2]=m}else m=e[2];const v=m.length>1;let w;e[5]!==a?(w=a.filter(Sx),e[5]=a,e[6]=w):w=e[6];const b=w.length>1;let k;if(e[7]!==n||e[8]!==i||e[9]!==v||e[10]!==a||e[11]!==l||e[12]!==c||e[13]!==d||e[14]!==g||e[15]!==b||e[16]!==h||e[17]!==r){let S;e[19]!==n||e[20]!==i||e[21]!==v||e[22]!==l||e[23]!==c||e[24]!==d||e[25]!==g||e[26]!==b||e[27]!==h||e[28]!==r?(S=N=>{if(N.type==="env")return s.jsxs("div",{className:"flex min-w-0 items-center gap-3 py-2.5",children:[s.jsx(ql,{icon:"terminal-box"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate font-mono typography-ui-label text-foreground",children:N.name}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h("settings.providers.accounts.environment")})]})]},`env:${N.name}`);const I=N.id===n,y=r.has(N.id),T=i!==null,x=N.method==="oauth"?h(y?"settings.providers.accounts.method.oauthUnused":"settings.providers.accounts.method.oauth"):h(y?"settings.providers.accounts.method.keyUnused":"settings.providers.accounts.method.key");return s.jsxs("div",{className:Pe("flex min-w-0 items-center gap-3 py-2.5",y&&"opacity-60"),children:[s.jsx(ql,{icon:N.method==="oauth"?"user-3":"key"}),g===N.id?s.jsx(kx,{initial:N.label,onCancel:()=>f(null),onSave:A=>{f(null),d(N,A)}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:N.label}),b&&I?s.jsx("span",{className:"shrink-0 rounded-full bg-[var(--interactive-selection)] px-2 py-px text-[10px] font-medium text-[var(--interactive-selection-foreground)]",children:h("settings.providers.accounts.active")}):null]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:x})]}),v&&!I&&!y?s.jsxs(G,{variant:"outline",size:"xs",disabled:T,onClick:()=>l(N),"aria-label":h("settings.providers.accounts.useAria",{account:N.label}),children:[i===N.id?s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):null,h("settings.providers.accounts.use")]}):null,s.jsxs(Sn,{children:[s.jsx(Nn,{asChild:!0,children:s.jsx(G,{variant:"ghost",size:"icon",disabled:T,className:Pe(us,"shrink-0"),"aria-label":h("settings.providers.accounts.menuAria",{account:N.label}),children:s.jsx(_,{name:"more-2",className:"size-4"})})}),s.jsxs(kn,{align:"end",children:[s.jsxs(an,{onSelect:()=>f(N.id),children:[s.jsx(_,{name:"pencil",className:"size-4"}),h("settings.providers.accounts.rename")]}),s.jsxs(an,{variant:"destructive",onSelect:()=>c(N),children:[s.jsx(_,{name:"delete-bin",className:"size-4"}),h("settings.providers.accounts.remove")]})]})]})]})]},N.id)},e[19]=n,e[20]=i,e[21]=v,e[22]=l,e[23]=c,e[24]=d,e[25]=g,e[26]=b,e[27]=h,e[28]=r,e[29]=S):S=e[29],k=a.map(S),e[7]=n,e[8]=i,e[9]=v,e[10]=a,e[11]=l,e[12]=c,e[13]=d,e[14]=g,e[15]=b,e[16]=h,e[17]=r,e[18]=k}else k=e[18];let p;return e[30]!==k?(p=s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:k}),e[30]=k,e[31]=p):p=e[31],p};function Sx(t){return t.type==="credential"}const Ro={"openai-chat":"aisdk:@ai-sdk/openai-compatible","openai-responses":"aisdk:@ai-sdk/openai","anthropic-messages":"aisdk:@ai-sdk/anthropic"},sa="__custom_provider__",Cx=/^[a-z0-9][a-z0-9-_]*$/,pd=/^https?:\/\//,Ix=/^\{env:([^}]+)\}$/,tr=t=>{if(!t)return;if(typeof t.package=="string"&&t.package)return t.package;const e=t.api?.npm;return typeof e=="string"&&e?`aisdk:${e}`:void 0},gd=t=>t.settings&&typeof t.settings=="object"?t.settings:t.options&&typeof t.options=="object"?t.options:{};let Px=0;const sr=()=>`row-${Px++}`,Fo=()=>({row:sr(),id:"",name:"",variants:""});function Ax(t,e){switch(t){case"openai-chat":return{settings:{reasoningEffort:e}};case"openai-responses":return{settings:{reasoningEffort:e,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}};case"anthropic-messages":return{settings:{thinking:{type:"adaptive",display:"summarized"},effort:e}}}}function Tx(t){const e=t.split(/[,\s]+/).map(a=>a.trim()).filter(Boolean);return e.filter((a,n)=>e.indexOf(a)===n)}function Ex(t){return Object.fromEntries((t??[]).map(({id:e,...a})=>[e,a]))}const Oo=()=>({row:sr(),key:"",value:""}),Dx=()=>({providerID:"",name:"",protocol:"openai-chat",baseURL:"",apiKey:"",models:[Fo()],headers:[Oo()]}),hd={"@opencode/ai/providers/openai-compatible":"openai-chat","@opencode/ai/providers/openai":"openai-responses","@opencode/ai/providers/anthropic":"anthropic-messages"};function Mx(t){const e=t?hd[t]:void 0;if(e)return e;switch(t){case"aisdk:@ai-sdk/openai":case"@ai-sdk/openai":return"openai-responses";case"aisdk:@ai-sdk/anthropic":case"@ai-sdk/anthropic":return"anthropic-messages";default:return"openai-chat"}}function Rx(t){const e=t.trim();if(!e)return{};const n=e.match(Ix)?.[1]?.trim();return n?{env:n}:{key:e}}function Fx(t){const e=gd(t),a=typeof e.baseURL=="string"?e.baseURL.trim():"";if(a&&pd.test(a))return!0;const n=new Set([...Object.values(Ro),...Object.keys(hd)]);return n.has(tr(t)??"")?!0:(Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.values(t.models):[]).some(i=>!i||typeof i!="object"?!1:n.has(tr(i)??""))}function Gl(t,e){return e?!!(e.user?.exists||e.project?.exists||e.custom?.exists)&&Fx(t):!1}function Wl(t){return t?.custom?.exists?"custom":t?.project?.exists?"project":"user"}function Jl(t){const e=gd(t),a=typeof e.baseURL=="string"?e.baseURL:"",n=t.headers&&typeof t.headers=="object"?t.headers:e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers)?e.headers:{},r=Object.entries(n).filter(h=>typeof h[0]=="string"&&typeof h[1]=="string").map(([h,g])=>({row:sr(),key:h,value:g})),i=Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.entries(t.models).map(([h,g])=>{const f=g&&typeof g=="object"?g:{};return{id:h,modelID:typeof f.modelID=="string"?f.modelID:h,name:typeof f.name=="string"?f.name:h,package:typeof f.package=="string"?f.package:void 0,variants:fd.safeParse(f.variants).data}}):[],l=i.length>0?i.map(h=>{const g=typeof h?.modelID=="string"&&h.modelID?h.modelID:typeof h?.id=="string"?h.id:"",f=Ex(h?.variants);return{row:sr(),id:g,name:typeof h?.name=="string"?h.name:g,variants:Object.keys(f).join(", "),savedVariants:f}}):[Fo()],d=Array.isArray(t.env)?t.env.find(h=>typeof h=="string"&&h.trim().length>0)?.trim():void 0,c=i.map(h=>tr(h)).find(h=>!!h);return{providerID:t.id,name:typeof t.name=="string"&&t.name.trim()?t.name:t.id,protocol:Mx(tr(t)??c),baseURL:a,apiKey:d?`{env:${d}}`:"",models:l,headers:r.length>0?r:[Oo()]}}const fd=xa(Ts({id:Mt(),settings:Un(Mt(),no()).optional(),headers:Un(Mt(),Mt()).optional(),body:Un(Mt(),no()).optional()})),Ox=Ts({name:Mt().optional(),package:Mt().optional(),env:xa(Mt()).optional(),settings:Un(Mt(),no()).optional(),headers:Un(Mt(),Mt()).optional(),models:Un(Mt(),Ts({modelID:Mt().optional(),name:Mt().optional(),package:Mt().optional(),variants:fd.optional()})).optional()});function Lx(t,e){const a=Array.isArray(t.models)?t.models.map(i=>({...i,variants:void 0})):t.models,n=Jl({...t,models:a});if(!e)return{...n,models:n.models.map(i=>({...i,savedVariants:void 0}))};const r=Jl({...e,id:t.id});return{providerID:t.id,name:e.name?.trim()?r.name:n.name,protocol:e.package?r.protocol:n.protocol,baseURL:r.baseURL||n.baseURL,apiKey:r.apiKey,models:e.models&&Object.keys(e.models).length>0?r.models:n.models.map(i=>({...i,savedVariants:void 0})),headers:r.headers}}function Kx(t){const e=t.form.providerID.trim(),a=t.form.name.trim(),n=t.form.baseURL.trim(),{env:r,key:i}=Rx(t.form.apiKey),l=t.disabledProviders??[],d=t.editingProviderID?.trim(),c=e?Cx.test(e)?void 0:t.t("settings.providers.page.custom.error.providerID.format"):t.t("settings.providers.page.custom.error.providerID.required"),h=a?void 0:t.t("settings.providers.page.custom.error.name.required"),g=n?pd.test(n)?void 0:t.t("settings.providers.page.custom.error.baseURL.format"):t.t("settings.providers.page.custom.error.baseURL.required"),m=!!(r||i||d&&t.allowExistingAuth&&d===e)?void 0:t.t("settings.providers.page.custom.error.apiKey.required"),u=l.includes(e),w=c||!!(d&&d===e)?void 0:t.existingProviderIDs.has(e)&&!u?t.t("settings.providers.page.custom.error.providerID.exists"):void 0,b=new Set,k=t.form.models.map(R=>{const P=R.id.trim(),D=P?b.has(P)?t.t("settings.providers.page.custom.error.duplicate"):void b.add(P):t.t("settings.providers.page.custom.error.required"),F=R.name.trim()?void 0:t.t("settings.providers.page.custom.error.required");return{id:D,name:F}}),p=k.every(R=>!R.id&&!R.name),S=Object.fromEntries(t.form.models.map(R=>{const P=R.id.trim(),D={modelID:P,name:R.name.trim()},F=Tx(R.variants);return(F.length>0||R.savedVariants!==void 0)&&(D.variants=F.map(O=>({id:O,...R.savedVariants?.[O]??Ax(t.form.protocol,O)}))),[P,D]})),N=new Set,I=t.form.headers.map(R=>{const P=R.key.trim(),D=R.value.trim();if(!P&&!D)return{};const F=P?N.has(P.toLowerCase())?t.t("settings.providers.page.custom.error.duplicate"):void N.add(P.toLowerCase()):t.t("settings.providers.page.custom.error.required"),O=D?void 0:t.t("settings.providers.page.custom.error.required");return{key:F,value:O}}),y=I.every(R=>!R.key&&!R.value),T=Object.fromEntries(t.form.headers.map(R=>({key:R.key.trim(),value:R.value.trim()})).filter(R=>R.key&&R.value).map(R=>[R.key,R.value])),x={providerID:c??w,name:h,baseURL:g,apiKey:m};return!c&&!w&&!h&&!g&&!m&&p&&y?{err:x,models:k,headers:I,result:{providerID:e,name:a,apiKey:i,config:zx({protocol:t.form.protocol,name:a,env:r,baseURL:n,headers:T,models:S})}}:{err:x,models:k,headers:I}}function zx(t){const e={package:Ro[t.protocol],name:t.name,settings:{baseURL:t.baseURL},models:t.models};return t.env&&(e.env=[t.env]),Object.keys(t.headers).length>0&&(e.headers=t.headers),e}function Ux(t){return t.apiKey?{integrationID:t.providerID,key:t.apiKey}:null}function _x(t,e){return{providerID:t.providerID,config:t.config,scope:e?.scope??"user"}}const Ql=t=>{const e=tt.c(234),{existingProviderIDs:a,disabledProviders:n,busy:r,mode:i,initialValues:l,allowExistingAuth:d,authFailureHint:c,onSubmit:h,onCancel:g,onDisconnect:f}=t;let m;e[0]!==n?(m=n===void 0?[]:n,e[0]=n,e[1]=m):m=e[1];const u=m,v=r===void 0?!1:r,w=i===void 0?"create":i,b=d===void 0?!1:d,k=c===void 0?null:c,{t:p}=Qe(),S=w==="edit";let N;e[2]!==l?(N=()=>l??Dx(),e[2]=l,e[3]=N):N=e[3];const[I,y]=o.useState(N);let T;e[4]===Symbol.for("react.memo_cache_sentinel")?(T={},e[4]=T):T=e[4];const[x,A]=o.useState(T);let R;e[5]===Symbol.for("react.memo_cache_sentinel")?(R=[],e[5]=R):R=e[5];const[P,D]=o.useState(R);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=[],e[6]=F):F=e[6];const[O,C]=o.useState(F),M=o.useRef(null);let U,L;e[7]!==l||e[8]!==S?(U=()=>{l&&(S&&M.current===l.providerID||(M.current=S?l.providerID:null,y(l),A({}),D([]),C([])))},L=[l,S],e[7]=l,e[8]=S,e[9]=U,e[10]=L):(U=e[9],L=e[10]),o.useEffect(U,L);let W;e[11]===Symbol.for("react.memo_cache_sentinel")?(W=(Rt,Wt)=>{y(zt=>({...zt,[Rt]:Wt})),A(zt=>({...zt,[Rt]:void 0}))},e[11]=W):W=e[11];const X=W;let J;e[12]===Symbol.for("react.memo_cache_sentinel")?(J=(Rt,Wt,zt)=>{y(Dt=>({...Dt,models:Dt.models.map((is,ns)=>ns===Rt?{...is,[Wt]:zt}:is)})),D(Dt=>{const is=[...Dt];return is[Rt]={...is[Rt]??{},[Wt]:void 0},is})},e[12]=J):J=e[12];const q=J;let z;e[13]===Symbol.for("react.memo_cache_sentinel")?(z=(Rt,Wt,zt)=>{y(Dt=>({...Dt,headers:Dt.headers.map((is,ns)=>ns===Rt?{...is,[Wt]:zt}:is)})),C(Dt=>{const is=[...Dt];return is[Rt]={...is[Rt]??{},[Wt]:void 0},is})},e[13]=z):z=e[13];const H=z;let se;e[14]!==b||e[15]!==v||e[16]!==u||e[17]!==a||e[18]!==I||e[19]!==S||e[20]!==h||e[21]!==p?(se=async Rt=>{if(Rt.preventDefault(),v)return;const Wt=Kx({form:I,t:((zt,Dt)=>p(zt,Dt)),existingProviderIDs:a,disabledProviders:u,editingProviderID:S?I.providerID:void 0,allowExistingAuth:S&&b});A(Wt.err),D(Wt.models),C(Wt.headers),Wt.result&&await h(Wt.result)},e[14]=b,e[15]=v,e[16]=u,e[17]=a,e[18]=I,e[19]=S,e[20]=h,e[21]=p,e[22]=se):se=e[22];const B=se;let ne;e[23]!==S||e[24]!==p?(ne=p(S?"settings.providers.page.custom.editTitle":"settings.providers.page.custom.title"),e[23]=S,e[24]=p,e[25]=ne):ne=e[25];let K;e[26]!==p?(K=p("settings.providers.page.custom.description"),e[26]=p,e[27]=K):K=e[27];let Z;e[28]!==K?(Z=s.jsx("p",{className:vs,children:K}),e[28]=K,e[29]=Z):Z=e[29];let oe;e[30]!==k?(oe=k?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",role:"status",children:k}):null,e[30]=k,e[31]=oe):oe=e[31];let ue;e[32]!==p?(ue=p("settings.providers.page.custom.field.providerID.label"),e[32]=p,e[33]=ue):ue=e[33];let de;e[34]!==p?(de=p("settings.providers.page.custom.field.providerID.info"),e[34]=p,e[35]=de):de=e[35];const ce=I.providerID;let Se;e[36]===Symbol.for("react.memo_cache_sentinel")?(Se=Rt=>X("providerID",Rt.target.value),e[36]=Se):Se=e[36];let re;e[37]!==p?(re=p("settings.providers.page.custom.field.providerID.placeholder"),e[37]=p,e[38]=re):re=e[38];const ve=!S,ie=S||v,me=!!x.providerID;let ke;e[39]!==p?(ke=p("settings.providers.page.custom.field.providerID.label"),e[39]=p,e[40]=ke):ke=e[40];let Ae;e[41]!==I.providerID||e[42]!==re||e[43]!==ve||e[44]!==ie||e[45]!==me||e[46]!==ke?(Ae=s.jsx(He,{value:ce,onChange:Se,placeholder:re,className:"h-8 rounded-md px-3 font-mono text-xs",autoFocus:ve,disabled:ie,"aria-invalid":me,"aria-label":ke}),e[41]=I.providerID,e[42]=re,e[43]=ve,e[44]=ie,e[45]=me,e[46]=ke,e[47]=Ae):Ae=e[47];let pe;e[48]!==x.providerID?(pe=x.providerID?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:x.providerID}):null,e[48]=x.providerID,e[49]=pe):pe=e[49];let Le;e[50]!==ue||e[51]!==de||e[52]!==Ae||e[53]!==pe?(Le=s.jsxs(Ft,{label:ue,info:de,children:[Ae,pe]}),e[50]=ue,e[51]=de,e[52]=Ae,e[53]=pe,e[54]=Le):Le=e[54];let Ve;e[55]!==p?(Ve=p("settings.providers.page.custom.field.protocol.label"),e[55]=p,e[56]=Ve):Ve=e[56];let ye;e[57]!==p?(ye=p("settings.providers.page.custom.field.protocol.info"),e[57]=p,e[58]=ye):ye=e[58];const Te=I.protocol;let ee;e[59]===Symbol.for("react.memo_cache_sentinel")?(ee=Rt=>{Rt in Ro&&y(Wt=>({...Wt,protocol:Rt,models:Wt.models.map($x)}))},e[59]=ee):ee=e[59];let ae;e[60]!==p?(ae=p("settings.providers.page.custom.field.protocol.label"),e[60]=p,e[61]=ae):ae=e[61];let fe;e[62]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx($t,{}),e[62]=fe):fe=e[62];let je;e[63]!==ae?(je=s.jsx(At,{"aria-label":ae,className:"w-full",children:fe}),e[63]=ae,e[64]=je):je=e[64];let Re;e[65]!==p?(Re=p("settings.providers.page.custom.field.protocol.openaiChat"),e[65]=p,e[66]=Re):Re=e[66];let Ce;e[67]!==Re?(Ce=s.jsx(ut,{value:"openai-chat",children:Re}),e[67]=Re,e[68]=Ce):Ce=e[68];let _e;e[69]!==p?(_e=p("settings.providers.page.custom.field.protocol.openaiResponses"),e[69]=p,e[70]=_e):_e=e[70];let Ke;e[71]!==_e?(Ke=s.jsx(ut,{value:"openai-responses",children:_e}),e[71]=_e,e[72]=Ke):Ke=e[72];let Fe;e[73]!==p?(Fe=p("settings.providers.page.custom.field.protocol.anthropicMessages"),e[73]=p,e[74]=Fe):Fe=e[74];let Me;e[75]!==Fe?(Me=s.jsx(ut,{value:"anthropic-messages",children:Fe}),e[75]=Fe,e[76]=Me):Me=e[76];let at;e[77]!==Ce||e[78]!==Ke||e[79]!==Me?(at=s.jsxs(Tt,{children:[Ce,Ke,Me]}),e[77]=Ce,e[78]=Ke,e[79]=Me,e[80]=at):at=e[80];let pt;e[81]!==v||e[82]!==I.protocol||e[83]!==je||e[84]!==at?(pt=s.jsxs(Et,{value:Te,onValueChange:ee,disabled:v,children:[je,at]}),e[81]=v,e[82]=I.protocol,e[83]=je,e[84]=at,e[85]=pt):pt=e[85];let ot;e[86]!==Ve||e[87]!==ye||e[88]!==pt?(ot=s.jsx(Ft,{label:Ve,info:ye,children:pt}),e[86]=Ve,e[87]=ye,e[88]=pt,e[89]=ot):ot=e[89];let mt;e[90]!==p?(mt=p("settings.providers.page.custom.field.name.label"),e[90]=p,e[91]=mt):mt=e[91];let ht;e[92]!==p?(ht=p("settings.providers.page.custom.field.name.info"),e[92]=p,e[93]=ht):ht=e[93];const Oe=I.name;let nt;e[94]===Symbol.for("react.memo_cache_sentinel")?(nt=Rt=>X("name",Rt.target.value),e[94]=nt):nt=e[94];let lt;e[95]!==p?(lt=p("settings.providers.page.custom.field.name.placeholder"),e[95]=p,e[96]=lt):lt=e[96];const we=!!x.name;let Je;e[97]!==p?(Je=p("settings.providers.page.custom.field.name.label"),e[97]=p,e[98]=Je):Je=e[98];let Ye;e[99]!==I.name||e[100]!==lt||e[101]!==we||e[102]!==Je?(Ye=s.jsx(He,{value:Oe,onChange:nt,placeholder:lt,className:"h-8 rounded-md px-3","aria-invalid":we,"aria-label":Je}),e[99]=I.name,e[100]=lt,e[101]=we,e[102]=Je,e[103]=Ye):Ye=e[103];let ze;e[104]!==x.name?(ze=x.name?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:x.name}):null,e[104]=x.name,e[105]=ze):ze=e[105];let Ge;e[106]!==mt||e[107]!==ht||e[108]!==Ye||e[109]!==ze?(Ge=s.jsxs(Ft,{label:mt,info:ht,children:[Ye,ze]}),e[106]=mt,e[107]=ht,e[108]=Ye,e[109]=ze,e[110]=Ge):Ge=e[110];let Q;e[111]!==p?(Q=p("settings.providers.page.custom.field.baseURL.label"),e[111]=p,e[112]=Q):Q=e[112];let Ue;e[113]!==p?(Ue=p("settings.providers.page.custom.field.baseURL.info"),e[113]=p,e[114]=Ue):Ue=e[114];const st=I.baseURL;let dt;e[115]===Symbol.for("react.memo_cache_sentinel")?(dt=Rt=>X("baseURL",Rt.target.value),e[115]=dt):dt=e[115];let ct;e[116]!==p?(ct=p("settings.providers.page.custom.field.baseURL.placeholder"),e[116]=p,e[117]=ct):ct=e[117];const ft=!!x.baseURL;let kt;e[118]!==p?(kt=p("settings.providers.page.custom.field.baseURL.label"),e[118]=p,e[119]=kt):kt=e[119];let bt;e[120]!==I.baseURL||e[121]!==ct||e[122]!==ft||e[123]!==kt?(bt=s.jsx(He,{value:st,onChange:dt,placeholder:ct,className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":ft,"aria-label":kt}),e[120]=I.baseURL,e[121]=ct,e[122]=ft,e[123]=kt,e[124]=bt):bt=e[124];let vt;e[125]!==x.baseURL?(vt=x.baseURL?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:x.baseURL}):null,e[125]=x.baseURL,e[126]=vt):vt=e[126];let Xe;e[127]!==Q||e[128]!==Ue||e[129]!==bt||e[130]!==vt?(Xe=s.jsxs(Ft,{label:Q,info:Ue,children:[bt,vt]}),e[127]=Q,e[128]=Ue,e[129]=bt,e[130]=vt,e[131]=Xe):Xe=e[131];let jt;e[132]!==p?(jt=p("settings.providers.page.custom.field.apiKey.label"),e[132]=p,e[133]=jt):jt=e[133];let De;e[134]!==b||e[135]!==S||e[136]!==p?(De=p(S&&b?"settings.providers.page.custom.field.apiKey.editInfo":"settings.providers.page.custom.field.apiKey.info"),e[134]=b,e[135]=S,e[136]=p,e[137]=De):De=e[137];const $e=I.apiKey;let Y;e[138]===Symbol.for("react.memo_cache_sentinel")?(Y=Rt=>X("apiKey",Rt.target.value),e[138]=Y):Y=e[138];let V;e[139]!==b||e[140]!==S||e[141]!==p?(V=p(S&&b?"settings.providers.page.custom.field.apiKey.editPlaceholder":"settings.providers.page.custom.field.apiKey.placeholder"),e[139]=b,e[140]=S,e[141]=p,e[142]=V):V=e[142];const be=!!x.apiKey;let ge;e[143]!==p?(ge=p("settings.providers.page.custom.field.apiKey.label"),e[143]=p,e[144]=ge):ge=e[144];let Ee;e[145]!==I.apiKey||e[146]!==V||e[147]!==be||e[148]!==ge?(Ee=s.jsx(He,{type:"password",value:$e,onChange:Y,placeholder:V,className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":be,"aria-label":ge}),e[145]=I.apiKey,e[146]=V,e[147]=be,e[148]=ge,e[149]=Ee):Ee=e[149];let te;e[150]!==x.apiKey?(te=x.apiKey?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:x.apiKey}):null,e[150]=x.apiKey,e[151]=te):te=e[151];let xe;e[152]!==jt||e[153]!==De||e[154]!==Ee||e[155]!==te?(xe=s.jsxs(Ft,{label:jt,info:De,children:[Ee,te]}),e[152]=jt,e[153]=De,e[154]=Ee,e[155]=te,e[156]=xe):xe=e[156];let Ze;e[157]!==ne||e[158]!==Z||e[159]!==oe||e[160]!==Le||e[161]!==ot||e[162]!==Ge||e[163]!==Xe||e[164]!==xe?(Ze=s.jsxs(qe,{title:ne,divider:!1,settingsItem:"providers.custom",contentClassName:Fs,children:[Z,oe,Le,ot,Ge,Xe,xe]}),e[157]=ne,e[158]=Z,e[159]=oe,e[160]=Le,e[161]=ot,e[162]=Ge,e[163]=Xe,e[164]=xe,e[165]=Ze):Ze=e[165];let Nt;e[166]!==p?(Nt=p("settings.providers.page.custom.models.title"),e[166]=p,e[167]=Nt):Nt=e[167];let Lt;if(e[168]!==I.models||e[169]!==P||e[170]!==p){let Rt;e[172]!==I.models.length||e[173]!==P||e[174]!==p?(Rt=(Wt,zt)=>s.jsx("div",{className:`${Ps} space-y-2`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:p("settings.providers.page.custom.models.idLabel")}),s.jsx(He,{value:Wt.id,onChange:Dt=>q(zt,"id",Dt.target.value),placeholder:p("settings.providers.page.custom.models.idPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":p("settings.providers.page.custom.models.idLabel")}),P[zt]?.id?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:P[zt]?.id}):null]}),s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:p("settings.providers.page.custom.models.nameLabel")}),s.jsx(He,{value:Wt.name,onChange:Dt=>q(zt,"name",Dt.target.value),placeholder:p("settings.providers.page.custom.models.namePlaceholder"),className:"mt-1 h-8 rounded-md px-3","aria-label":p("settings.providers.page.custom.models.nameLabel")}),P[zt]?.name?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:P[zt]?.name}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:Ct,children:p("settings.providers.page.custom.models.variantsLabel")}),s.jsx(Gt,{children:p("settings.providers.page.custom.models.variantsInfo")})]}),s.jsx(He,{value:Wt.variants,onChange:Dt=>q(zt,"variants",Dt.target.value),placeholder:p("settings.providers.page.custom.models.variantsPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":p("settings.providers.page.custom.models.variantsLabel")})]})]}),s.jsx(G,{type:"button",variant:"ghost",size:"icon",className:us,disabled:I.models.length<=1,onClick:()=>{I.models.length<=1||(y(Dt=>({...Dt,models:Dt.models.filter((is,ns)=>ns!==zt)})),D(Dt=>Dt.filter((is,ns)=>ns!==zt)))},"aria-label":p("settings.providers.page.custom.models.remove"),children:s.jsx(_,{name:"delete-bin",className:"size-4"})})]})},Wt.row),e[172]=I.models.length,e[173]=P,e[174]=p,e[175]=Rt):Rt=e[175],Lt=I.models.map(Rt),e[168]=I.models,e[169]=P,e[170]=p,e[171]=Lt}else Lt=e[171];let Ie;e[176]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>{y(Bx),D(Vx)},e[176]=Ie):Ie=e[176];let Be;e[177]!==p?(Be=p("settings.providers.page.custom.models.add"),e[177]=p,e[178]=Be):Be=e[178];let wt;e[179]!==Be?(wt=s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Ie,children:Be}),e[179]=Be,e[180]=wt):wt=e[180];let Pt;e[181]!==Nt||e[182]!==Lt||e[183]!==wt?(Pt=s.jsxs(qe,{title:Nt,contentClassName:Fs,children:[Lt,wt]}),e[181]=Nt,e[182]=Lt,e[183]=wt,e[184]=Pt):Pt=e[184];let Qt;e[185]!==p?(Qt=p("settings.providers.page.custom.headers.title"),e[185]=p,e[186]=Qt):Qt=e[186];let Xt;e[187]!==p?(Xt=p("settings.providers.page.custom.headers.description"),e[187]=p,e[188]=Xt):Xt=e[188];let ss;e[189]!==Xt?(ss=s.jsx("p",{className:vs,children:Xt}),e[189]=Xt,e[190]=ss):ss=e[190];let es;if(e[191]!==I.headers||e[192]!==O||e[193]!==p){let Rt;e[195]!==I.headers.length||e[196]!==O||e[197]!==p?(Rt=(Wt,zt)=>s.jsx("div",{className:`${Ps} space-y-2`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:p("settings.providers.page.custom.headers.keyLabel")}),s.jsx(He,{value:Wt.key,onChange:Dt=>H(zt,"key",Dt.target.value),placeholder:p("settings.providers.page.custom.headers.keyPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":p("settings.providers.page.custom.headers.keyLabel")}),O[zt]?.key?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:O[zt]?.key}):null]}),s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:p("settings.providers.page.custom.headers.valueLabel")}),s.jsx(He,{value:Wt.value,onChange:Dt=>H(zt,"value",Dt.target.value),placeholder:p("settings.providers.page.custom.headers.valuePlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":p("settings.providers.page.custom.headers.valueLabel")}),O[zt]?.value?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:O[zt]?.value}):null]})]}),s.jsx(G,{type:"button",variant:"ghost",size:"icon",className:us,disabled:I.headers.length<=1,onClick:()=>{I.headers.length<=1||(y(Dt=>({...Dt,headers:Dt.headers.filter((is,ns)=>ns!==zt)})),C(Dt=>Dt.filter((is,ns)=>ns!==zt)))},"aria-label":p("settings.providers.page.custom.headers.remove"),children:s.jsx(_,{name:"delete-bin",className:"size-4"})})]})},Wt.row),e[195]=I.headers.length,e[196]=O,e[197]=p,e[198]=Rt):Rt=e[198],es=I.headers.map(Rt),e[191]=I.headers,e[192]=O,e[193]=p,e[194]=es}else es=e[194];let Ls;e[199]===Symbol.for("react.memo_cache_sentinel")?(Ls=()=>{y(Hx),C(qx)},e[199]=Ls):Ls=e[199];let Js;e[200]!==p?(Js=p("settings.providers.page.custom.headers.add"),e[200]=p,e[201]=Js):Js=e[201];let gn;e[202]!==Js?(gn=s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Ls,children:Js}),e[202]=Js,e[203]=gn):gn=e[203];let Ks;e[204]!==Qt||e[205]!==ss||e[206]!==es||e[207]!==gn?(Ks=s.jsxs(qe,{title:Qt,contentClassName:Fs,children:[ss,es,gn]}),e[204]=Qt,e[205]=ss,e[206]=es,e[207]=gn,e[208]=Ks):Ks=e[208];let zs;e[209]!==v||e[210]!==g||e[211]!==p?(zs=g?s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:g,disabled:v,children:p("settings.providers.page.custom.actions.back")}):null,e[209]=v,e[210]=g,e[211]=p,e[212]=zs):zs=e[212];let on;e[213]!==v||e[214]!==f||e[215]!==p?(on=f?s.jsx(G,{type:"button",variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>{f()},disabled:v,children:p("settings.providers.page.actions.disconnect")}):null,e[213]=v,e[214]=f,e[215]=p,e[216]=on):on=e[216];let Qs;e[217]!==v||e[218]!==S||e[219]!==p?(Qs=p(v?"settings.providers.page.actions.saving":S?"settings.providers.page.custom.actions.update":"settings.providers.page.custom.actions.save"),e[217]=v,e[218]=S,e[219]=p,e[220]=Qs):Qs=e[220];let Ys;e[221]!==v||e[222]!==Qs?(Ys=s.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:v,children:Qs}),e[221]=v,e[222]=Qs,e[223]=Ys):Ys=e[223];let Us;e[224]!==zs||e[225]!==on||e[226]!==Ys?(Us=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-4",children:[zs,on,Ys]}),e[224]=zs,e[225]=on,e[226]=Ys,e[227]=Us):Us=e[227];let Dn;return e[228]!==B||e[229]!==Ze||e[230]!==Pt||e[231]!==Ks||e[232]!==Us?(Dn=s.jsxs("form",{onSubmit:B,className:"space-y-0",children:[Ze,Pt,Ks,Us]}),e[228]=B,e[229]=Ze,e[230]=Pt,e[231]=Ks,e[232]=Us,e[233]=Dn):Dn=e[233],Dn};function $x(t){return t.savedVariants?{...t,savedVariants:{}}:t}function Bx(t){return{...t,models:[...t.models,Fo()]}}function Vx(t){return[...t,{}]}function Hx(t){return{...t,headers:[...t.headers,Oo()]}}function qx(t){return[...t,{}]}const Gx=t=>new Intl.NumberFormat(wo(),{notation:"compact",compactDisplay:"short",maximumFractionDigits:1,minimumFractionDigits:0}).format(t),Yl=t=>{if(typeof t!="number"||Number.isNaN(t))return null;if(t===0)return"0";const e=Gx(t);return e.endsWith(".0")?e.slice(0,-2):e},qn="__add_provider__",xd=t=>typeof t=="object"&&t!==null,Wx=t=>{if(typeof t=="string")return{id:t};if(!xd(t))return null;const e=typeof t.id=="string"&&t.id||typeof t.providerID=="string"&&t.providerID||typeof t.slug=="string"&&t.slug||typeof t.name=="string"&&t.name;if(!e)return null;const a=typeof t.name=="string"?t.name:void 0;return{id:e,name:a}},Jx=t=>{let e=[];Array.isArray(t)?e=t:xd(t)&&(Array.isArray(t.all)?e=t.all:Array.isArray(t.providers)&&(e=t.providers));const a=e.map(r=>Wx(r)).filter(r=>!!r),n=new Set;return a.filter(r=>n.has(r.id)?!1:(n.add(r.id),!0))},Qx=()=>{const{t}=Qe(),e=rn(),a=rt(V=>su(V,e)),n=he(V=>V.settingsProvidersConnectRequested),r=he(V=>V.setSettingsProvidersConnectRequested),[i,l]=o.useState(()=>n?qn:"");o.useEffect(()=>{n&&(l(qn),r(!1))},[n,r]);const d=rt(V=>V.getModelMetadata),c=he(V=>V.hiddenModels),h=he(V=>V.toggleHiddenModel),g=he(V=>V.hideAllModels),f=he(V=>V.showAllModels),m=rt(V=>V.loadProviders);o.useEffect(()=>{e&&m({directory:e,source:"settings:providers"})},[m,e]);const[u,v]=o.useState(null),[w,b]=o.useState(!1),[k,p]=o.useState({}),[S,N]=o.useState(null),[I,y]=o.useState(null),[T,x]=o.useState(""),[A,R]=o.useState([]),[P,D]=o.useState(!1),[F,O]=o.useState(null),[C,M]=o.useState(""),[U,L]=o.useState(""),[W,X]=o.useState(!1),[J,q]=o.useState({}),[z,H]=o.useState({}),[se,B]=o.useState(0),[ne,K]=o.useState(0),[Z,oe]=o.useState(!1),[ue,de]=o.useState(null),[ce,Se]=o.useState(null),[re,ve]=o.useState(null),[ie,me]=o.useState(null),[ke,Ae]=o.useState(null),[pe,Le]=o.useState(null),Ve=i===qn,ye=Ve&&C===sa,Te=!!(ce&&i&&ce===i&&!Ve);o.useEffect(()=>{let V=!0;return(async()=>{b(!0);try{const{data:ge}=await Ms.getSdkClient().integration.list();if(!V)return;v(ge)}catch(ge){if(!V)return;console.error("Failed to load provider integrations:",ge),$.error(t("settings.providers.page.toast.authMethodsLoadFailed"))}finally{V&&b(!1)}})(),()=>{V=!1}},[ne,t]),o.useEffect(()=>{if(!ux(Ve))return;let V=!0;return(async()=>{D(!0),O(null);try{const[{data:ge},Ee]=await Promise.all([Ms.getSdkClient().integration.list(),au(Ms.getDirectory()??null).catch(()=>null)]);if(!V)return;const te=new Set((Ee??[]).map(xe=>xe.id));R(Jx(ge.filter(xe=>!xe.id.startsWith("mcp_")&&!te.has(xe.id)&&xe.connections.length===0)))}catch(ge){if(!V)return;console.error("Failed to load available providers:",ge),O(t("settings.providers.page.state.unableToLoadProviderList"))}finally{V&&D(!1)}})(),()=>{V=!1}},[Ve,t]);const ee=o.useMemo(()=>new Set(a.map(V=>V.id)),[a]),ae=o.useMemo(()=>A.filter(V=>!ee.has(V.id)).sort((V,be)=>{const ge=(V.name||V.id).toLowerCase(),Ee=(be.name||be.id).toLowerCase();return ge.localeCompare(Ee)}),[A,ee]);o.useEffect(()=>{i===qn&&C&&C!==sa&&!ae.some(V=>V.id===C)&&M("")},[i,C,ae]),o.useEffect(()=>{if(i===qn){oe(!0),de(null),Se(null),ve(null),me(null),Ae(null);return}oe(!1),de(null),ce&&ce!==i&&(Se(null),ve(null),me(null),Ae(null))},[i,ce]),o.useEffect(()=>{if(!i||i===qn)return;const V=J[i];if(!V||u===null)return;const be=a.find(te=>te.id===i),ge=Hl({connections:Wi(u,i),optionsApiKey:uo(be)}),Ee=!!(be&&Gl(be,V));xx({hasCredentials:ge,userDismissed:ue===i,isEditableCustomProvider:Ee})&&oe(!0)},[i,J,a,u,ue]),o.useEffect(()=>{if(!i||i===qn)return;let V=!1;return(async()=>{try{const ge=e?`?directory=${encodeURIComponent(e)}`:"",Ee=await St(`/api/provider/${encodeURIComponent(i)}/source${ge}`,{method:"GET",headers:{Accept:"application/json"}}),te=await Ee.json().catch(()=>null);if(!Ee.ok)throw new Error(te?.error||t("settings.providers.page.toast.providerSourcesLoadFailed"));const xe=te?.sources??te?.data?.sources;!V&&xe&&(q(Ze=>({...Ze,[i]:xe})),H(Ze=>({...Ze,[i]:Ox.safeParse(te?.config??te?.data?.config).data??null})))}catch(ge){V||console.error("Failed to load provider sources:",ge)}})(),()=>{V=!0}},[i,se,e,t]);const fe=o.useCallback(()=>{B(V=>V+1)},[]),je=o.useCallback(()=>{K(V=>V+1)},[]),Re=o.useCallback(V=>{v(be=>(be??[]).map(ge=>ge.id===V&&ge.connections.length===0?{...ge,connections:[{type:"credential",id:`pending:${V}`,label:V,method:"key"}]}:ge)),de(null),oe(!1),l(V),fe(),je()},[je,fe,l]),Ce=a.find(V=>V.id===i),_e=i?J[i]:void 0,Ke=async V=>{const be=k[V]?.trim()??"";if(!be){$.error(t("settings.providers.page.toast.apiKeyRequired"));return}const ge=`api:${V}`;N(ge);try{await Ms.getSdkClient().integration.connect.key({integrationID:V,key:be}),$.success(t("settings.providers.page.toast.apiKeySaved")),p(Ee=>({...Ee,[V]:""})),Re(V)}catch(Ee){console.error("Failed to save API key:",Ee),$.error(t("settings.providers.page.toast.apiKeySaveFailed"))}finally{N(null)}},Fe=async V=>{const be=`custom:${V.providerID}`;N(be),Le(V.providerID),Ae(null);try{const ge=Ux(V);ge&&await Ms.getSdkClient().integration.connect.key(ge);const Ee=_x(V,{scope:ce?ie??Wl(J[ce]):"user"}),te=await St(`/api/provider${e?`?directory=${encodeURIComponent(e)}`:""}`,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(Ee)}),xe=await te.json().catch(()=>null);if(!te.ok)throw ge&&Ae(t("settings.providers.page.custom.authFailure.configAfterAuth")),new Error(xe?.error||t("settings.providers.page.toast.customProviderSaveFailed"));$.success(t("settings.providers.page.toast.customProviderSaved",{provider:V.name})),M(""),Se(null),ve(null),me(null),Ae(null),Le(null),Re(V.providerID)}catch(ge){console.error("Failed to save custom provider:",ge),$.error(ge instanceof Error&&ge.message?ge.message:t("settings.providers.page.toast.customProviderSaveFailed"))}finally{N(null)}},Me=V=>{oe(!1),Re(V)},at=async V=>{const be=`disconnect:${V}`;N(be);try{const ge=Vl(Wn(u??[],V)),Ee=Ms.getSdkClient();for(const te of ge)await Ee.credential.remove({credentialID:te.id});$.success(t("settings.providers.page.toast.providerDisconnected")),de(null),fe(),je()}catch(ge){console.error("Failed to disconnect provider:",ge),$.error(t("settings.providers.page.toast.providerDisconnectFailed"))}finally{N(null)}},pt=async V=>{V&&(await at(V),Se(null),ve(null),me(null),Ae(null),Le(null),M(""))},ot=async(V,be,ge)=>{y(V.id);try{await be(),ge.success&&$.success(ge.success)}catch(Ee){console.error("Provider account action failed:",Ee),$.error(ge.failure)}finally{y(null),je()}},mt=V=>ot(V,async()=>{await Ms.getSdkClient().credential.activate({credentialID:V.id})},{success:t("settings.providers.accounts.toast.switched",{account:V.label}),failure:t("settings.providers.accounts.toast.switchFailed")}),ht=(V,be)=>ot(V,async()=>{await Ms.getSdkClient().credential.update({credentialID:V.id,label:be})},{failure:t("settings.providers.accounts.toast.renameFailed")}),Oe=V=>ot(V,async()=>{await Ms.getSdkClient().credential.remove({credentialID:V.id}),fe()},{success:t("settings.providers.accounts.toast.removed"),failure:t("settings.providers.accounts.toast.removeFailed")}),nt=()=>l(""),lt=s.jsx(G,{variant:"ghost",size:"icon",className:"-ml-2 h-7 w-7 shrink-0",onClick:nt,"aria-label":t("settings.providers.page.back"),title:t("settings.providers.page.back"),children:s.jsx(_,{name:"arrow-left-s",className:"size-4"})});if(Ve)return s.jsxs(ts,{title:t("settings.providers.page.connect.title"),titleLeading:lt,showSaveStatus:!1,children:[s.jsx(qe,{title:t("settings.providers.page.connect.selectProviderTitle"),divider:!1,settingsItem:"providers.connect",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.providers.page.connect.providerField")}),P?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.page.state.loading")}):F?s.jsx("p",{className:"typography-meta text-muted-foreground",children:F}):s.jsxs(Sn,{open:W,onOpenChange:V=>{X(V),V||L("")},children:[s.jsx(Nn,{asChild:!0,children:s.jsxs("button",{type:"button",className:Ws,children:[s.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[C&&C!==sa?s.jsx(Va,{providerId:C,className:"h-3.5 w-3.5 flex-shrink-0"}):null,s.jsx("span",{className:Pe("truncate typography-ui-label font-normal",C?"text-foreground":"text-muted-foreground"),children:C===sa?t("settings.providers.page.custom.optionLabel"):C?ae.find(V=>V.id===C)?.name||C:t("settings.providers.page.connect.selectProviderPlaceholder")})]}),s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/50"})]})}),s.jsxs(kn,{align:"start",className:"w-[280px] p-0",onCloseAutoFocus:V=>V.preventDefault(),children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2",onKeyDown:V=>V.stopPropagation(),children:[s.jsx(_,{name:"search",className:"h-4 w-4 text-muted-foreground"}),s.jsx("input",{type:"text",value:U,onChange:V=>L(V.target.value),onKeyDown:V=>V.stopPropagation(),placeholder:t("settings.providers.page.connect.searchProvidersPlaceholder"),className:"flex-1 bg-transparent typography-meta outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),s.jsx(Ns,{outerClassName:"max-h-[240px]",className:"p-1",children:(()=>{const V=t("settings.providers.page.custom.optionLabel"),be=nu([V,"other","custom"],U),ge=Ja(ae,U,Ee=>[Ee.name||Ee.id,Ee.id]);return ge.length===0&&!be?s.jsx("p",{className:"py-4 text-center typography-meta text-muted-foreground",children:t("settings.providers.page.connect.noProvidersFound")}):s.jsxs(s.Fragment,{children:[ge.map(Ee=>s.jsxs(an,{onSelect:()=>{M(Ee.id),X(!1),L("")},className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Va,{providerId:Ee.id,className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Ee.name||Ee.id})]}),C===Ee.id&&s.jsx(_,{name:"check",className:"h-4 w-4 text-[var(--primary-base)]"})]},Ee.id)),be?s.jsxs(an,{onSelect:()=>{M(sa),X(!1),L("")},className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(_,{name:"add",className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:V})]}),C===sa&&s.jsx(_,{name:"check",className:"h-4 w-4 text-[var(--primary-base)]"})]},sa):null]})})()})]})]})]})}),ye?s.jsx(Ql,{mode:"create",existingProviderIDs:ee,busy:S?.startsWith("custom:")??!1,authFailureHint:ke,onCancel:()=>{M(""),Ae(null),Le(null)},onDisconnect:ke&&pe?()=>{pt(pe)}:void 0,onSubmit:Fe}):C?s.jsx(qe,{title:t("settings.providers.page.auth.title"),settingsItem:"providers.auth",contentClassName:"space-y-4",children:w?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.page.auth.loadingMethods")}):s.jsx(s.Fragment,{children:(()=>{const V=Wn(u??[],C),be=$l(Wn(u??[],ci(C))),ge=Bl(V);return s.jsxs(s.Fragment,{children:[ge?s.jsxs("div",{className:"py-1.5",children:[s.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[t("settings.providers.page.auth.apiKeyLabel"),s.jsx(Gt,{children:t("settings.providers.page.auth.apiKeyTooltip")})]}),s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center gap-2 mt-1.5",children:[s.jsx(He,{type:"password",value:k[C]??"",onChange:Ee=>p(te=>({...te,[C]:Ee.target.value})),placeholder:t("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),s.jsx(G,{size:"xs",className:"!font-normal shrink-0",onClick:()=>Ke(C),disabled:S===`api:${C}`,children:S===`api:${C}`?t("settings.providers.page.actions.saving"):t("settings.providers.page.actions.saveKey")})]})]}):null,be.length>0?s.jsx(oo,{integrationId:ci(C),methods:be,onConnected:()=>Me(C),className:Pe(ge&&"border-t border-[var(--surface-subtle)] pt-2")},C):null]})})()})}):null]});if(!Ce)return s.jsx(jx,{providers:a,integrations:u,directory:e,onSelect:l,onConnect:()=>l(qn)});const we=Array.isArray(Ce.models)?Ce.models:[],Je=Wn(u??[],Ce.id),Ye=$l(Wn(u??[],ci(Ce.id))),ze=Bl(Je),Ge=u!==null,Q=!!_e,Ue=Q&&Gl(Ce,_e),st=Hl({connections:Wi(u??[],Ce.id),optionsApiKey:uo(Ce)}),dt=mx(Ge,st,Ue),ct=fx({modelCount:we.length,integrationsLoaded:Ge,hasCredentials:st,isEditableCustomProvider:Ue}),ft=Wi(u??[],Ce.id)??[],kt=Ce.integrationID??Ce.id,bt=Vl(Wn(u??[],kt)),vt=bt[0]?.id??null,Xe=new Set(ft.flatMap(V=>V.type==="credential"&&!bt.some(be=>be.id===V.id)?[V.id]:[])),jt=[_e?.user.exists?t("settings.providers.page.connectionDetails.source.userConfig"):null,_e?.project.exists?t("settings.providers.page.connectionDetails.source.projectConfig"):null,_e?.custom?.exists?t("settings.providers.page.connectionDetails.source.customConfig"):null].filter(V=>V!==null),De=s.jsxs("span",{className:"flex items-center gap-2",children:[lt,s.jsx(Va,{providerId:Ce.id,className:"h-5 w-5 shrink-0"})]}),$e=s.jsxs("span",{className:"typography-settings-description text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:Ce.id}),jt.length>0?s.jsxs(s.Fragment,{children:[" · ",t("settings.providers.page.configuredIn",{sources:jt.join(", ")})]}):null]}),Y=Ja(we,T,V=>[typeof V?.name=="string"?V.name:"",typeof V?.id=="string"?V.id:""]);return Te&&Ue&&re?s.jsx(ts,{title:Ce.name||Ce.id,titleLeading:De,description:$e,showSaveStatus:!1,children:s.jsx(Ql,{mode:"edit",existingProviderIDs:ee,initialValues:re,allowExistingAuth:st||!Q,busy:S?.startsWith("custom:")??!1,authFailureHint:ke,onCancel:()=>{Se(null),ve(null),me(null),Ae(null),Le(null)},onDisconnect:()=>{pt(Ce.id)},onSubmit:Fe})}):s.jsxs(ts,{title:Ce.name||Ce.id,titleLeading:De,description:$e,showSaveStatus:!1,children:[s.jsxs(qe,{title:t("settings.providers.accounts.title"),info:t("settings.providers.accounts.info"),divider:!1,headerAction:s.jsxs("div",{className:"flex items-center gap-1",children:[Ue?s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ae(null),ve(Lx(Ce,z[Ce.id]??null)),me(Wl(_e)),Se(Ce.id)},children:t("settings.providers.page.actions.edit")}):null,s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const V=!Z;oe(V),de(V?null:Ce.id)},children:Z?t("settings.providers.page.actions.cancel"):s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"add",className:"size-3.5"}),ft.length>0?t("settings.providers.accounts.add"):t("settings.providers.page.actions.connect")]})})]}),settingsItem:"providers.auth",contentClassName:"space-y-4",children:[ft.length>0?s.jsx(Nx,{connections:ft,activeId:vt,unusedIds:Xe,busyId:I,onActivate:V=>{mt(V)},onRename:(V,be)=>{ht(V,be)},onRemove:V=>{Oe(V)}}):!Z&&dt?s.jsxs("div",{className:"flex items-center gap-1.5 py-1.5",children:[s.jsx(_,{name:"alert",className:"w-4 h-4 text-[var(--status-warning)] shrink-0"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.providers.page.auth.incomplete")}),ze?s.jsx(Gt,{children:t("settings.providers.page.auth.incompleteHint")}):null]}):null,Z?w?s.jsx("div",{className:"py-1.5 typography-meta text-muted-foreground",children:t("settings.providers.page.auth.loadingMethods")}):s.jsxs("div",{className:Pe("space-y-4",ft.length>0&&"rounded-xl border border-[var(--interactive-border)] p-4"),children:[ze?s.jsxs("div",{className:"py-1.5",children:[s.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[t("settings.providers.page.auth.apiKeyLabel"),s.jsx(Gt,{children:t("settings.providers.page.auth.apiKeyTooltip")})]}),s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center gap-2 mt-1.5",children:[s.jsx(He,{type:"password",value:k[Ce.id]??"",onChange:V=>p(be=>({...be,[Ce.id]:V.target.value})),placeholder:t("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),s.jsx(G,{size:"xs",className:"!font-normal shrink-0",onClick:()=>Ke(Ce.id),disabled:S===`api:${Ce.id}`,children:S===`api:${Ce.id}`?t("settings.providers.page.actions.saving"):t("settings.providers.page.actions.saveKey")})]})]}):null,Ye.length>0&&s.jsx(oo,{integrationId:ci(Ce.id),methods:Ye,onConnected:()=>Me(Ce.id),className:Pe(ze&&"border-t border-[var(--surface-subtle)] pt-2")},Ce.id)]}):null]}),ct?s.jsxs(qe,{title:t("settings.providers.page.models.title"),titleAccessory:s.jsxs("span",{className:"typography-micro text-muted-foreground font-normal",children:["(",we.length,")"]}),headerAction:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const V=we.map(be=>typeof be?.id=="string"?be.id:"").filter(be=>be.length>0);g(Ce.id,V)},children:t("settings.providers.page.actions.hideAll")}),s.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>f(Ce.id),children:t("settings.providers.page.actions.showAll")})]}),settingsItem:"providers.models",children:[s.jsxs("div",{className:"relative mb-2",children:[s.jsx(_,{name:"search",className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),s.jsx(He,{value:T,onChange:V=>x(V.target.value),placeholder:t("settings.providers.page.models.filterPlaceholder"),className:"h-7 pl-8 w-full"})]}),Y.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground py-4 text-center",children:t("settings.providers.page.models.noModelsMatchFilter")}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Y.map(V=>{const be=typeof V?.id=="string"?V.id:"",ge=typeof V?.name=="string"?V.name:be,Ee=be?d(Ce.id,be):void 0,te=c.some(Lt=>Lt.providerID===Ce.id&&Lt.modelID===be),xe=Yl(Ee?.limit?.context),Ze=Yl(Ee?.limit?.output),Nt=[];return Ee?.tool_call&&Nt.push({key:"tools",icon:"tools",label:t("settings.providers.page.models.capability.toolCalling")}),Ee?.reasoning&&Nt.push({key:"reasoning",icon:"brain-ai-3",label:t("settings.providers.page.models.capability.reasoning")}),Ee?.attachment&&Nt.push({key:"image",icon:"file-image",label:t("settings.providers.page.models.capability.imageInput")}),s.jsx("div",{className:"py-1.5",children:s.jsxs("div",{className:Pe("flex items-center gap-3",te&&"opacity-50"),children:[s.jsx("span",{className:"typography-meta font-medium text-foreground truncate flex-1 min-w-0",children:ge}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(xe||Ze)&&s.jsxs("span",{className:"typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:[xe?`${xe} ${t("settings.providers.page.models.tokenBadge.context")}`:"",xe&&Ze?" · ":"",Ze?`${Ze} ${t("settings.providers.page.models.tokenBadge.output")}`:""]}),Nt.length>0&&s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:Nt.map(({key:Lt,icon:Ie,label:Be})=>s.jsx("span",{className:"flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]",title:Be,"aria-label":Be,children:s.jsx(_,{name:Ie,className:"h-3 w-3"})},Lt))}),s.jsx("button",{type:"button",onClick:()=>h(Ce.id,be),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50",title:t(te?"settings.providers.page.models.actions.showModelInSelectors":"settings.providers.page.models.actions.hideModelFromSelectors"),"aria-label":t(te?"settings.providers.page.models.actions.showModel":"settings.providers.page.models.actions.hideModel"),children:te?s.jsx(_,{name:"eye-off",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"eye",className:"h-3.5 w-3.5"})})]})]})},be)})})]}):null]})},Yx=t=>{const e=t?.windows??{},a=Object.values(e).map(n=>n.usedPercent).filter(n=>typeof n=="number");return a.length===0?null:Math.max(...a)},Zx=t=>{const e=tt.c(75),{onItemSelect:a}=t,{t:n}=Qe(),r=rs(Xx),i=rs(eb),l=rs(tb),d=rs(sb),c=rs(nb),h=rs(ab),g=rs(ib),f=rs(rb);let m,u;e[0]!==f?(m=()=>{f()},u=[f],e[0]=f,e[1]=m,e[2]=u):(m=e[1],u=e[2]),o.useEffect(m,u);const v=ob;let w;e[3]!==g?(w=Z=>{Z!=="usage"&&Z!=="remaining"||(g(Z),v({usageDisplayMode:Z}))},e[3]=g,e[4]=w):w=e[4];const b=w;let k;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=Pe("flex h-full flex-col","bg-background"),e[5]=k):k=e[5];let p;e[6]!==n?(p=n("settings.usage.sidebar.title"),e[6]=n,e[7]=p):p=e[7];let S;e[8]!==p?(S=s.jsx("h2",{className:`${_n} mb-3`,children:p}),e[8]=p,e[9]=S):S=e[9];let N;e[10]!==n?(N=n("settings.usage.sidebar.total",{count:Qi.length}),e[10]=n,e[11]=N):N=e[11];let I;e[12]!==N?(I=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[12]=N,e[13]=I):I=e[13];let y;e[14]!==d?(y=()=>d(),e[14]=d,e[15]=y):y=e[15];let T;e[16]!==n?(T=n("settings.usage.sidebar.actions.refreshAria"),e[16]=n,e[17]=T):T=e[17];let x;e[18]!==n?(x=n("settings.usage.sidebar.actions.refreshTitle"),e[18]=n,e[19]=x):x=e[19];const A=c&&"animate-spin";let R;e[20]!==A?(R=Pe("h-3.5 w-3.5",A),e[20]=A,e[21]=R):R=e[21];let P;e[22]!==R?(P=s.jsx(_,{name:"refresh",className:R}),e[22]=R,e[23]=P):P=e[23];let D;e[24]!==c||e[25]!==T||e[26]!==x||e[27]!==P||e[28]!==y?(D=s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(G,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 text-muted-foreground",onClick:y,"aria-label":T,title:x,disabled:c,children:P})}),e[24]=c,e[25]=T,e[26]=x,e[27]=P,e[28]=y,e[29]=D):D=e[29];let F;e[30]!==D||e[31]!==I?(F=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[I,D]}),e[30]=D,e[31]=I,e[32]=F):F=e[32];let O;e[33]!==n?(O=n("settings.usage.sidebar.field.display"),e[33]=n,e[34]=O):O=e[34];let C;e[35]!==O?(C=s.jsx("span",{className:"typography-micro text-muted-foreground",children:O}),e[35]=O,e[36]=C):C=e[36];let M;e[37]!==n?(M=n("settings.usage.sidebar.field.displayModePlaceholder"),e[37]=n,e[38]=M):M=e[38];let U;e[39]!==M?(U=s.jsx(At,{className:"w-fit",children:s.jsx($t,{placeholder:M})}),e[39]=M,e[40]=U):U=e[40];let L;e[41]!==n?(L=n("settings.usage.sidebar.field.displayModeUsage"),e[41]=n,e[42]=L):L=e[42];let W;e[43]!==L?(W=s.jsx(ut,{value:"usage",children:L}),e[43]=L,e[44]=W):W=e[44];let X;e[45]!==n?(X=n("settings.usage.sidebar.field.displayModeRemaining"),e[45]=n,e[46]=X):X=e[46];let J;e[47]!==X?(J=s.jsx(ut,{value:"remaining",children:X}),e[47]=X,e[48]=J):J=e[48];let q;e[49]!==W||e[50]!==J?(q=s.jsxs(Tt,{children:[W,J]}),e[49]=W,e[50]=J,e[51]=q):q=e[51];let z;e[52]!==b||e[53]!==U||e[54]!==q||e[55]!==h?(z=s.jsxs(Et,{value:h,onValueChange:b,children:[U,q]}),e[52]=b,e[53]=U,e[54]=q,e[55]=h,e[56]=z):z=e[56];let H;e[57]!==C||e[58]!==z?(H=s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[C,z]}),e[57]=C,e[58]=z,e[59]=H):H=e[59];let se;e[60]!==F||e[61]!==H||e[62]!==S?(se=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[S,F,H]}),e[60]=F,e[61]=H,e[62]=S,e[63]=se):se=e[63];let B;e[64]!==a||e[65]!==r||e[66]!==i||e[67]!==l||e[68]!==n?(B=Qi.map(Z=>{const oe=r.find(ve=>ve.providerId===Z.id),ue=Yx(oe?.usage),de=Mc(ue),ce=Z.id===i,Se=oe?.configured,re=Se?de==="critical"?{backgroundColor:"var(--status-error)"}:de==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"}:{backgroundColor:"var(--surface-muted-foreground)",opacity:.4};return s.jsx("div",{className:Pe("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",ce?"bg-interactive-selection":"hover:bg-interactive-hover"),children:s.jsxs("button",{type:"button",onClick:()=>{l(Z.id),a?.()},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-ring",children:[s.jsx("span",{className:"h-2.5 w-2.5 rounded-full flex-shrink-0",style:re}),s.jsx(Va,{providerId:Z.id,className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:Z.name}),Se===!1&&s.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:n("settings.usage.sidebar.status.notSet")})]})},Z.id)}),e[64]=a,e[65]=r,e[66]=i,e[67]=l,e[68]=n,e[69]=B):B=e[69];let ne;e[70]!==B?(ne=s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:B}),e[70]=B,e[71]=ne):ne=e[71];let K;return e[72]!==se||e[73]!==ne?(K=s.jsxs("div",{className:k,children:[se,ne]}),e[72]=se,e[73]=ne,e[74]=K):K=e[74],K};function Xx(t){return t.results}function eb(t){return t.selectedProviderId}function tb(t){return t.setSelectedProvider}function sb(t){return t.fetchAllQuotas}function nb(t){return t.isLoading}function ab(t){return t.displayMode}function ib(t){return t.setDisplayMode}function rb(t){return t.loadSettings}async function ob(t){try{await xt(t)}catch(e){console.warn("Failed to save usage settings:",e)}}const lb=t=>{const e=tt.c(17),{percent:a,tonePercent:n,className:r}=t;let i;e[0]!==a?(i=iu(a)??0,e[0]=a,e[1]=i):i=e[1];const l=i,d=n??a;let c;e[2]!==d?(c=Mc(d),e[2]=d,e[3]=c):c=e[3];const h=c;let g;e[4]!==h?(g=h==="critical"?{backgroundColor:"var(--status-error)"}:h==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=h,e[5]=g):g=e[5];const f=g;let m;e[6]!==r?(m=Pe("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",r),e[6]=r,e[7]=m):m=e[7];const u=`${l}%`;let v;e[8]!==f||e[9]!==u?(v={...f,width:u},e[8]=f,e[9]=u,e[10]=v):v=e[10];let w;e[11]!==l||e[12]!==v?(w=s.jsx("div",{className:"h-full transition-all duration-300",style:v,role:"progressbar","aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100}),e[11]=l,e[12]=v,e[13]=w):w=e[13];let b;return e[14]!==m||e[15]!==w?(b=s.jsx("div",{className:m,children:w}),e[14]=m,e[15]=w,e[16]=b):b=e[16],b},Br=t=>{const e=tt.c(37),{title:a,window:n,subtitle:r,showToggle:i,toggleEnabled:l,onToggle:d}=t,c=i===void 0?!1:i,h=l===void 0?!1:l,g=rs(cb),f=he(db),m=g==="remaining"?n.remainingPercent:n.usedPercent,u=m!==null,v=g==="remaining"?"remaining":"used";let w;e[0]!==m||e[1]!==n.valueLabel?(w=ru(n.valueLabel,m),e[0]=m,e[1]=n.valueLabel,e[2]=w):w=e[2];const b=w,k=n.resetAfterFormatted??n.resetAtFormatted;let p;e[3]!==k||e[4]!==f||e[5]!==n.resetAt?(p=ou(n.resetAt,k,f),e[3]=k,e[4]=f,e[5]=n.resetAt,e[6]=p):p=e[6];const S=p,N=S?`Resets ${S}`:"";let I;e[7]!==a?(I=lu(a),e[7]=a,e[8]=I):I=e[8];const y=I;let T;e[9]!==d||e[10]!==c||e[11]!==h?(T=c&&s.jsx(to,{checked:h,onChange:U=>d?.(U),ariaLabel:"Show in dropdown"}),e[9]=d,e[10]=c,e[11]=h,e[12]=T):T=e[12];let x;e[13]!==y?(x=s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:y}),e[13]=y,e[14]=x):x=e[14];let A;e[15]!==r?(A=r&&s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:r}),e[15]=r,e[16]=A):A=e[16];let R;e[17]!==x||e[18]!==A?(R=s.jsxs("div",{className:"min-w-0 flex flex-col",children:[x,A]}),e[17]=x,e[18]=A,e[19]=R):R=e[19];let P;e[20]!==R||e[21]!==T?(P=s.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[T,R]}),e[20]=R,e[21]=T,e[22]=P):P=e[22];const D=b==="-"?"":b;let F;e[23]!==D?(F=s.jsx("div",{className:"typography-ui-label text-foreground tabular-nums flex items-center justify-end",children:D}),e[23]=D,e[24]=F):F=e[24];let O;e[25]!==P||e[26]!==F?(O=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[P,F]}),e[25]=P,e[26]=F,e[27]=O):O=e[27];let C;e[28]!==v||e[29]!==m||e[30]!==u||e[31]!==N||e[32]!==n.usedPercent?(C=u?s.jsxs("div",{className:"mt-2.5",children:[s.jsx(lb,{percent:m,tonePercent:n.usedPercent,className:"h-1.5"}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:N}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:v})]})]}):N?s.jsx("div",{className:"mt-1 typography-micro text-muted-foreground",children:N}):null,e[28]=v,e[29]=m,e[30]=u,e[31]=N,e[32]=n.usedPercent,e[33]=C):C=e[33];let M;return e[34]!==O||e[35]!==C?(M=s.jsxs("div",{className:"py-3",children:[O,C]}),e[34]=O,e[35]=C,e[36]=M):M=e[36],M};function cb(t){return t.displayMode}function db(t){return t.timeFormatPreference}const ub=`ssh exe.dev "ssh-key generate-api-key --label=openchamber --exp=30d --cmds='billing credits usage'"`,mb=({providerId:t,providerName:e})=>{const{t:a}=Qe(),[n,r]=o.useState(null),[i,l]=o.useState({}),[d,c]=o.useState(!1),h=`/api/quota/credentials/${t}`;o.useEffect(()=>{St(h).then(async m=>{if(!m.ok)throw new Error;const u=await m.json();r(u),l({})}).catch(()=>r({configured:!1}))},[h]);const g=async(m,u,v)=>{c(!0);try{const w=await St(m,{method:u,headers:v?{"Content-Type":"application/json"}:void 0,body:v?JSON.stringify(v):void 0}),b=await w.json().catch(()=>null);if(!w.ok)throw new Error(b?.error);b?.configured!==void 0&&r(b),l({}),$.success(a("settings.providers.page.quotaCredentials.saved",{provider:e}))}catch(w){$.error(w instanceof Error&&w.message?w.message:a("settings.providers.page.openCodeGo.saveFailed"))}finally{c(!1)}},f=(m,u,v)=>s.jsxs("label",{className:"block typography-ui-label text-foreground",children:[u,s.jsx(He,{className:"mt-1 h-7 font-mono text-xs",type:"password",autoComplete:"off",value:i[m]??"",onChange:w=>l(b=>({...b,[m]:w.target.value})),placeholder:n?.secretMasked??v})]});return s.jsxs("div",{"data-settings-item":`usage.${t}-credentials`,className:"mb-8",children:[s.jsx("div",{className:"mb-1 px-1",children:s.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:e})}),s.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[t==="exe-dev"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:a("settings.providers.page.quotaCredentials.exeDevTokenInstructions")}),s.jsx("code",{className:"typography-code block whitespace-pre-wrap break-all rounded bg-muted/50 px-2 py-1.5 text-xs text-foreground",children:ub})]}),t==="ollama-cloud"&&f("cookie",a("settings.providers.page.openCodeGo.authCookie"),"aid=...; __Secure-session=..."),t==="exe-dev"&&f("usageToken",a("settings.providers.page.quotaCredentials.usageToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="cursor"&&f("accessToken",a("settings.providers.page.quotaCredentials.accessToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="cursor"&&f("refreshToken",a("settings.providers.page.quotaCredentials.refreshToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(G,{size:"xs",disabled:d,onClick:()=>g(h,"PUT",i),children:n?.configured?a("settings.providers.page.openCodeGo.replace"):a("settings.providers.page.openCodeGo.save")}),n?.configured&&s.jsx(G,{variant:"outline",size:"xs",disabled:d,onClick:()=>g(`${h}/validate`,"POST"),children:a("settings.providers.page.openCodeGo.validate")}),t==="cursor"&&s.jsx(G,{variant:"outline",size:"xs",disabled:d,onClick:()=>g(`${h}/import`,"POST"),children:a("settings.providers.page.actions.connect")}),n?.configured&&s.jsx(G,{variant:"destructive",size:"xs",disabled:d,onClick:()=>g(h,"DELETE"),children:a("settings.providers.page.openCodeGo.delete")})]})]})]})},Zl=(t,e)=>{if(!t)return"-";try{return Rc(t,e,{fallback:"-"})}catch{return"-"}},pb=()=>{const{t}=Qe(),e=he(M=>M.timeFormatPreference),a=rs(M=>M.results),n=rs(M=>M.selectedProviderId),r=rs(M=>M.setSelectedProvider),i=rs(M=>M.loadSettings),l=rs(M=>M.fetchAllQuotas),d=rs(M=>M.isLoading),c=rs(M=>M.lastUpdated),h=rs(M=>M.refreshErrors),g=rs(M=>M.dropdownProviderIds),f=rs(M=>M.setDropdownProviderIds),m=rs(M=>M.selectedModels),u=rs(M=>M.toggleModelSelected),v=rs(M=>M.applyDefaultSelections);cu(),o.useEffect(()=>{i(),l()},[i,l]),o.useEffect(()=>{if(n||a.length===0)return;const M=a.find(U=>U.configured)?.providerId;r(M??Qi[0]?.id??null)},[a,n,r]);const w=a.find(M=>M.providerId===n)??null,k=Qi.find(M=>M.id===n)?.name??n??t("settings.usage.sidebar.title"),p=w?.usage,S=n?h[n]:void 0,N=S?p?t("header.services.usageRefreshFailedStale",{error:S}):S:w?.configured&&!w.ok?w.error:null,I=n?g.includes(n):!1,y=n==="exe-dev"||n==="ollama-cloud"||n==="cursor",T=o.useCallback(M=>{if(!n)return;const U=M?Array.from(new Set([...g,n])):g.filter(L=>L!==n);f(U),xt({usageDropdownProviders:U})},[g,n,f]),x=o.useMemo(()=>p?.models?Object.entries(p.models).map(([M,U])=>({name:M,windows:U})).filter(M=>Object.keys(M.windows.windows).length>0):[],[p?.models]);o.useEffect(()=>{n&&x.length>0&&v(n,x.map(M=>M.name))},[n,x,v]);const A=o.useMemo(()=>!n||x.length===0?new Map:du(x,M=>M.name,n),[x,n]),R=o.useMemo(()=>{if(!n)return[];const M=mu(n);return uu(M)},[n]),[P,D]=o.useState(()=>({})),F=o.useCallback(M=>{D(U=>({...U,[M]:!U[M]}))},[]),O=o.useCallback(M=>{if(!n)return;u(n,M);const U=m[n]??[],W=U.includes(M)?U.filter(J=>J!==M):[...U,M],X={...m,[n]:W};xt({usageSelectedModels:X})},[n,m,u]),C=n?m[n]??[]:[];return n?s.jsxs(ts,{title:t("settings.usage.page.header.providerUsage",{provider:k}),titleLeading:s.jsx(Va,{providerId:n,className:"h-5 w-5 shrink-0"}),description:d?s.jsx("span",{className:"animate-pulse typography-settings-description text-muted-foreground",children:t("settings.usage.page.header.refreshing")}):w?.planLabel?t("settings.usage.page.header.lastUpdatedWithPlan",{plan:w.planLabel,time:Zl(c,e)}):t("settings.usage.page.header.lastUpdated",{time:Zl(c,e)}),showSaveStatus:!0,children:[s.jsx(qe,{divider:!1,settingsItem:"usage.work-status-panel",children:s.jsx(gt,{checked:I,onChange:T,label:t("settings.usage.page.options.showInWorkStatus"),ariaLabel:t("settings.usage.page.options.showInWorkStatusAria"),info:t("settings.usage.page.options.showInWorkStatusTooltip")})}),!w&&s.jsx("p",{className:"typography-ui-label text-foreground pb-8",children:t("settings.usage.page.state.noData")}),N&&s.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:t("settings.usage.page.state.refreshFailedTitle")}),s.jsx("p",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:N})]}),w&&!w.configured&&!y&&s.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3",children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-warning)]",children:t("settings.usage.page.state.providerNotConfiguredTitle")}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]/80 mt-1",children:t("settings.usage.page.state.providerNotConfiguredDescription")})]}),(n==="exe-dev"||n==="ollama-cloud"||n==="cursor")&&s.jsx(mb,{providerId:n,providerName:k}),p?.windows&&Object.keys(p.windows).length>0&&s.jsx(qe,{settingsItem:"usage.model-quotas",children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Object.entries(p.windows).map(([M,U])=>s.jsx(Br,{title:M,window:U},M))})}),x.length>0&&s.jsxs(qe,{title:t("settings.usage.page.section.modelQuotas"),contentClassName:"space-y-3",children:[R.map(M=>{const U=A.get(M.id)??[];if(U.length===0)return null;const L=P[M.id]??!1;return s.jsx("section",{className:"p-2",children:s.jsxs(Cn,{open:!L,onOpenChange:()=>F(M.id),children:[s.jsxs(In,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:M.label}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",U.length,")"]})]}),L?s.jsx(_,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(Pn,{children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:U.map(W=>{const X=Object.entries(W.windows.windows);if(X.length===0)return null;const[J,q]=X[0],z=C.includes(W.name);return s.jsx(Br,{title:J,subtitle:qo(W.name),window:q,showToggle:!0,toggleEnabled:z,onToggle:()=>O(W.name)},W.name)})})})]})},M.id)}),(()=>{const M=A.get(null)??[];if(M.length===0)return null;const U=P.other??!1;return s.jsx("section",{className:"p-2",children:s.jsxs(Cn,{open:!U,onOpenChange:()=>F("other"),children:[s.jsxs(In,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:t("settings.usage.page.section.otherModels")}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",M.length,")"]})]}),U?s.jsx(_,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(Pn,{children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:M.map(L=>{const W=Object.entries(L.windows.windows);if(W.length===0)return null;const[X,J]=W[0],q=C.includes(L.name);return s.jsx(Br,{title:X,subtitle:qo(L.name),window:J,showToggle:!0,toggleEnabled:q,onToggle:()=>O(L.name)},L.name)})})})]})})})()]}),w?.configured&&p&&Object.keys(p.windows??{}).length===0&&x.length===0&&s.jsxs("div",{className:"pb-8",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:t("settings.usage.page.state.noQuotaWindowsTitle")}),s.jsx("p",{className:"typography-meta text-muted-foreground mt-1",children:t("settings.usage.page.state.noQuotaWindowsDescription")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:s.jsx("p",{className:"typography-body",children:t("settings.usage.page.empty.selectProvider")})})},gb="git.commit.generate",mo=zm(t=>({selectedPromptId:gb,setSelectedPromptId:e=>{t(a=>a.selectedPromptId===e?a:{selectedPromptId:e})}})),hb=t=>{const e=tt.c(24),{onItemSelect:a}=t,{t:n}=Qe(),r=mo(fb),i=mo(xb);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={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"}]},e[0]=l):l=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={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"}]},e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={groupKey:"settings.magicPrompts.sidebar.group.linear",items:[{id:"linear.issue.review",titleKey:"settings.magicPrompts.sidebar.item.linearIssueReview"}]},e[2]=c):c=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={groupKey:"settings.magicPrompts.sidebar.group.planning",items:[{id:"plan.todo",titleKey:"settings.magicPrompts.sidebar.item.planTodo"},{id:"plan.improve",titleKey:"settings.magicPrompts.sidebar.item.planImprove"},{id:"plan.implement",titleKey:"settings.magicPrompts.sidebar.item.planImplement"}]},e[3]=h):h=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=[l,d,c,h,{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.plan",titleKey:"settings.magicPrompts.sidebar.item.sessionFeaturePlan"},{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"}]}],e[4]=g):g=e[4];const f=g;let m;e[5]!==n?(m=n("settings.magicPrompts.sidebar.title"),e[5]=n,e[6]=m):m=e[6];let u;e[7]!==m?(u=s.jsx("h2",{className:_n,children:m}),e[7]=m,e[8]=u):u=e[8];let v;e[9]!==n?(v=n("settings.magicPrompts.sidebar.description"),e[9]=n,e[10]=v):v=e[10];let w;e[11]!==v?(w=s.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:v}),e[11]=v,e[12]=w):w=e[12];let b;e[13]!==u||e[14]!==w?(b=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[u,w]}),e[13]=u,e[14]=w,e[15]=b):b=e[15];let k;e[16]!==a||e[17]!==r||e[18]!==i||e[19]!==n?(k=s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"space-y-3 px-3 py-2 overflow-x-hidden",children:f.map(S=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro px-1 text-muted-foreground",children:n(S.groupKey)}),S.items.map(N=>{const I=r===N.id;return s.jsx("button",{type:"button",onClick:()=>{i(N.id),a?.()},className:Pe("flex w-full items-center rounded-md px-2 py-1.5 text-left transition-colors",I?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:s.jsx("span",{className:"typography-ui-label truncate font-normal",children:n(N.titleKey)})},N.id)})]},S.groupKey))}),e[16]=a,e[17]=r,e[18]=i,e[19]=n,e[20]=k):k=e[20];let p;return e[21]!==b||e[22]!==k?(p=s.jsxs("div",{className:"flex h-full flex-col bg-background",children:[b,k]}),e[21]=b,e[22]=k,e[23]=p):p=e[23],p};function fb(t){return t.selectedPromptId}function xb(t){return t.setSelectedPromptId}const Xl={"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"}]},"linear.issue.review":{titleKey:"settings.magicPrompts.page.group.linearIssueReview.title",descriptionKey:"settings.magicPrompts.page.group.linearIssueReview.description",blocks:[{id:"linear.issue.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"linear.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"}]},"plan.improve":{titleKey:"settings.magicPrompts.page.group.planImprove.title",descriptionKey:"settings.magicPrompts.page.group.planImprove.description",blocks:[{id:"plan.improve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.improve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.todo":{titleKey:"settings.magicPrompts.page.group.planTodo.title",descriptionKey:"settings.magicPrompts.page.group.planTodo.description",blocks:[{id:"plan.todo.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.todo.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.implement":{titleKey:"settings.magicPrompts.page.group.planImplement.title",descriptionKey:"settings.magicPrompts.page.group.planImplement.description",blocks:[{id:"plan.implement.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.implement.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.plan":{titleKey:"settings.magicPrompts.page.group.sessionFeaturePlan.title",descriptionKey:"settings.magicPrompts.page.group.sessionFeaturePlan.description",blocks:[{id:"session.plan.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.plan.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"}]}},ec=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Vr=t=>t.endsWith(".visible"),bb=()=>{const{t}=Qe(),e=o.useCallback(y=>t(y),[t]),a=mo(y=>y.selectedPromptId),[n,r]=o.useState(!0),[i,l]=o.useState({}),[d,c]=o.useState({}),[h,g]=o.useState({}),[f,m]=o.useState({}),[u,v]=o.useState(!1);o.useEffect(()=>{let y=!0;return(async()=>{r(!0);try{const x=await fu();if(!y)return;l(x)}catch(x){console.warn("Failed to load magic prompts:",x),$.error(t("settings.magicPrompts.page.toast.loadFailed"))}finally{y&&r(!1)}})(),()=>{y=!1}},[t]);const w=Xl[a]??Xl["git.commit.generate"],b=o.useCallback(y=>ec(i,y)?i[y]:Ar(y),[i]),k=o.useCallback(y=>d[y]??b(y),[d,b]),p=o.useCallback((y,T)=>{c(x=>x[y]===T?x:{...x,[y]:T})},[]),S=o.useCallback(async y=>{const T=k(y);if(Vr(y)&&T.trim().length===0){$.error(t("settings.magicPrompts.page.toast.visiblePromptRequired"));return}g(x=>({...x,[y]:!0}));try{const x=T===Ar(y)?await Go(y):await pu(y,T);l(x.overrides),$.success(t("settings.magicPrompts.page.toast.saved"))}catch(x){const A=x instanceof Error?x.message:String(x);$.error(t("settings.magicPrompts.page.toast.saveFailed"),{description:A})}finally{g(x=>({...x,[y]:!1}))}},[k,t]),N=o.useCallback(async y=>{m(T=>({...T,[y]:!0}));try{const T=await Go(y);l(T.overrides),c(x=>({...x,[y]:Ar(y)})),$.success(t("settings.magicPrompts.page.toast.resetSuccess"))}catch(T){const x=T instanceof Error?T.message:String(T);$.error(t("settings.magicPrompts.page.toast.resetFailed"),{description:x})}finally{m(T=>({...T,[y]:!1}))}},[t]),I=o.useCallback(async()=>{v(!0);try{const y=await gu();l(y.overrides),c({}),$.success(t("settings.magicPrompts.page.toast.resetAllSuccess"))}catch(y){const T=y instanceof Error?y.message:String(y);$.error(t("settings.magicPrompts.page.toast.resetAllFailed"),{description:T})}finally{v(!1)}},[t]);return n?s.jsxs("div",{className:"py-6 px-6 flex items-center gap-2 text-muted-foreground",children:[s.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":t("settings.magicPrompts.page.loading.aria")}),s.jsx("span",{className:"typography-ui",children:t("settings.magicPrompts.page.loading.text")})]}):s.jsx(ts,{title:e(w.titleKey),titleAccessory:s.jsx(Gt,{contentClassName:"max-w-xs",children:e(w.descriptionKey)}),headerEnd:s.jsx(G,{"data-settings-item":"magic-prompts.reset-overrides",variant:"outline",size:"sm",onClick:()=>{I()},disabled:u||Object.keys(i).length===0,children:t(u?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetAllOverrides")}),showSaveStatus:!1,children:w.blocks.map((y,T)=>{const x=hu(y.id),A=b(y.id),R=k(y.id),P=ec(i,y.id),D=R!==A,F=Vr(y.id)&&R.trim().length===0,O=h[y.id]===!0,C=f[y.id]===!0;return s.jsxs(qe,{title:e(y.titleKey),info:x.description,description:x.placeholders&&x.placeholders.length>0?`${t("settings.magicPrompts.page.placeholdersLabel")} ${x.placeholders.map(M=>`{{${M.key}}}`).join(", ")}`:void 0,divider:T>0,settingsItem:Vr(y.id)?"magic-prompts.visible-prompt":"magic-prompts.instructions",contentClassName:"space-y-3",children:[s.jsx(As,{value:R,onChange:M=>p(y.id,M.target.value),className:"min-h-[220px] font-mono text-sm"}),F&&s.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:t("settings.magicPrompts.page.validation.visiblePromptRequired")}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:t(D?"settings.magicPrompts.page.status.unsavedChanges":P?"settings.magicPrompts.page.status.usingSavedOverride":"settings.magicPrompts.page.status.usingBuiltinDefault")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G,{variant:"outline",size:"sm",onClick:()=>{N(y.id)},disabled:!P||O||C,children:t(C?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetToDefault")}),s.jsx(G,{size:"sm",onClick:()=>{S(y.id)},disabled:!D||O||C||F,children:t(O?"settings.common.actions.saving":"settings.magicPrompts.page.actions.save")})]})]})]},y.id)})})},vb=t=>{const e=tt.c(89),{onItemSelect:a}=t,{t:n}=Qe(),[r,i]=o.useState(null),[l,d]=o.useState(null),[c,h]=o.useState(null),{selectedSnippetName:g,snippets:f,setSelectedSnippet:m,setSnippetDraft:u,deleteSnippet:v,loadSnippets:w}=Yi(Bs(yb));let b,k;e[0]!==w?(b=()=>{w()},k=[w],e[0]=w,e[1]=b,e[2]=k):(b=e[1],k=e[2]),o.useEffect(b,k);let p;e[3]!==a||e[4]!==m||e[5]!==u||e[6]!==f?(p=async()=>{const ie=new Set(f.map(jb));let me="new-snippet",ke=1;for(;ie.has(me);)me=`new-snippet-${ke++}`;u({name:me,scope:"global"}),m(me),a?.()},e[3]=a,e[4]=m,e[5]=u,e[6]=f,e[7]=p):p=e[7];const S=p;let N;e[8]!==r||e[9]!==v||e[10]!==n?(N=async()=>{if(!r)return;await v(r.name)?($.success(n("settings.snippets.sidebar.toast.deleted")),i(null)):$.error(n("settings.snippets.sidebar.toast.deleteFailed"))},e[8]=r,e[9]=v,e[10]=n,e[11]=N):N=e[11];const I=N;let y;e[12]!==f?(y=[...f].sort(wb),e[12]=f,e[13]=y):y=e[13];const T=y;let x;e[14]===Symbol.for("react.memo_cache_sentinel")?(x=Pe("flex h-full flex-col","bg-background"),e[14]=x):x=e[14];let A;e[15]!==n?(A=n("settings.snippets.sidebar.title"),e[15]=n,e[16]=A):A=e[16];let R;e[17]!==A?(R=s.jsx("h2",{className:`${_n} mb-3`,children:A}),e[17]=A,e[18]=R):R=e[18];let P;e[19]!==f.length||e[20]!==n?(P=n("settings.snippets.sidebar.total",{count:f.length}),e[19]=f.length,e[20]=n,e[21]=P):P=e[21];let D;e[22]!==P?(D=s.jsx("span",{className:"typography-meta text-muted-foreground",children:P}),e[22]=P,e[23]=D):D=e[23];let F;e[24]!==n?(F=n("settings.snippets.sidebar.actions.create"),e[24]=n,e[25]=F):F=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),e[26]=O):O=e[26];let C;e[27]!==S||e[28]!==F?(C=s.jsx(G,{size:"sm","data-settings-item":"snippets.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:S,"aria-label":F,children:O}),e[27]=S,e[28]=F,e[29]=C):C=e[29];let M;e[30]!==D||e[31]!==C?(M=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[D,C]}),e[30]=D,e[31]=C,e[32]=M):M=e[32];let U;e[33]!==M||e[34]!==R?(U=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[R,M]}),e[33]=M,e[34]=R,e[35]=U):U=e[35];let L;if(e[36]!==a||e[37]!==l||e[38]!==c||e[39]!==g||e[40]!==m||e[41]!==T||e[42]!==n){let ie;e[44]!==a||e[45]!==l||e[46]!==c||e[47]!==g||e[48]!==m||e[49]!==n?(ie=me=>s.jsxs(ha,{open:c===me.name,onOpenChange:ke=>h(ke?me.name:null),children:[s.jsxs(ga,{render:s.jsx("div",{className:Pe("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",g===me.name?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:ke=>{ke.preventDefault(),h(me.name)}}),children:[s.jsxs("button",{onClick:()=>{m(me.name),a?.()},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-ring",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["#",me.name]}),s.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:n(`snippets.source.${me.source}`)})]}),s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:me.description||me.content.replace(/\s+/g," ").substring(0,80)})]}),s.jsxs(Sn,{open:l===me.name,onOpenChange:ke=>{ke&&h(null),d(ke?me.name:null)},children:[s.jsx(Nn,{asChild:!0,children:s.jsx(G,{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","aria-label":n("settings.snippets.sidebar.actions.more",{name:me.name}),children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(kn,{align:"end",className:"w-fit min-w-20",children:s.jsxs(an,{onClick:ke=>{ke.stopPropagation(),i(me)},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),n("settings.common.actions.delete")]})})]})]}),s.jsx(ma,{className:"w-fit min-w-20",children:s.jsxs(pa,{onClick:ke=>{ke.stopPropagation(),i(me)},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),n("settings.common.actions.delete")]})})]},`${me.source}:${me.filePath}`),e[44]=a,e[45]=l,e[46]=c,e[47]=g,e[48]=m,e[49]=n,e[50]=ie):ie=e[50],L=T.map(ie),e[36]=a,e[37]=l,e[38]=c,e[39]=g,e[40]=m,e[41]=T,e[42]=n,e[43]=L}else L=e[43];let W;e[51]!==L?(W=s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2",children:L}),e[51]=L,e[52]=W):W=e[52];const X=r!==null;let J;e[53]===Symbol.for("react.memo_cache_sentinel")?(J=ie=>{ie||i(null)},e[53]=J):J=e[53];let q;e[54]!==n?(q=n("settings.snippets.sidebar.dialog.deleteTitle"),e[54]=n,e[55]=q):q=e[55];let z;e[56]!==q?(z=s.jsx(Ht,{children:q}),e[56]=q,e[57]=z):z=e[57];const H=r?.name??"";let se;e[58]!==n||e[59]!==H?(se=n("settings.snippets.sidebar.dialog.deleteDescription",{name:H}),e[58]=n,e[59]=H,e[60]=se):se=e[60];let B;e[61]!==se?(B=s.jsx(qt,{children:se}),e[61]=se,e[62]=B):B=e[62];let ne;e[63]!==z||e[64]!==B?(ne=s.jsxs(Vt,{children:[z,B]}),e[63]=z,e[64]=B,e[65]=ne):ne=e[65];let K;e[66]===Symbol.for("react.memo_cache_sentinel")?(K=()=>i(null),e[66]=K):K=e[66];let Z;e[67]!==n?(Z=n("settings.common.actions.cancel"),e[67]=n,e[68]=Z):Z=e[68];let oe;e[69]!==Z?(oe=s.jsx(G,{size:"sm",variant:"ghost",onClick:K,children:Z}),e[69]=Z,e[70]=oe):oe=e[70];let ue;e[71]!==n?(ue=n("settings.common.actions.delete"),e[71]=n,e[72]=ue):ue=e[72];let de;e[73]!==I||e[74]!==ue?(de=s.jsx(G,{size:"sm",onClick:I,children:ue}),e[73]=I,e[74]=ue,e[75]=de):de=e[75];let ce;e[76]!==oe||e[77]!==de?(ce=s.jsxs(as,{children:[oe,de]}),e[76]=oe,e[77]=de,e[78]=ce):ce=e[78];let Se;e[79]!==ne||e[80]!==ce?(Se=s.jsxs(_t,{className:"max-w-md",children:[ne,ce]}),e[79]=ne,e[80]=ce,e[81]=Se):Se=e[81];let re;e[82]!==X||e[83]!==Se?(re=s.jsx(Ut,{open:X,onOpenChange:J,children:Se}),e[82]=X,e[83]=Se,e[84]=re):re=e[84];let ve;return e[85]!==U||e[86]!==W||e[87]!==re?(ve=s.jsxs("div",{className:x,children:[U,W,re]}),e[85]=U,e[86]=W,e[87]=re,e[88]=ve):ve=e[88],ve};function yb(t){return{selectedSnippetName:t.selectedSnippetName,snippets:t.snippets,setSelectedSnippet:t.setSelectedSnippet,setSnippetDraft:t.setSnippetDraft,deleteSnippet:t.deleteSnippet,loadSnippets:t.loadSnippets}}function jb(t){return t.name}function wb(t,e){return t.name.localeCompare(e.name)}const kb=()=>{const{t}=Qe(),{selectedSnippetName:e,snippets:a,snippetDraft:n,setSnippetDraft:r,updateSnippet:i,createSnippet:l}=Yi(Bs(x=>({selectedSnippetName:x.selectedSnippetName,snippets:x.snippets,snippetDraft:x.snippetDraft,setSnippetDraft:x.setSnippetDraft,updateSnippet:x.updateSnippet,createSnippet:x.createSnippet}))),d=o.useMemo(()=>e?a.find(x=>x.name===e||x.aliases.includes(e))??null:null,[e,a]),c=!!(n&&n.name===e&&!d),[h,g]=o.useState(""),[f,m]=o.useState("global"),[u,v]=o.useState(""),[w,b]=o.useState(""),[k,p]=o.useState(""),[S,N]=o.useState(!1),I=o.useRef(null);o.useEffect(()=>{if(c&&n){const x={draftName:n.name||"",draftScope:n.scope||"global",description:n.description||"",aliases:(n.aliases||[]).join(", "),content:n.content||""};g(x.draftName),m(x.draftScope),v(x.description),b(x.aliases),p(x.content),I.current=x}else if(d){const x={draftName:"",draftScope:"global",description:d.description??"",aliases:d.aliases.join(", "),content:d.content};v(x.description),b(x.aliases),p(x.content),I.current=x}},[d,c,e,n]);const y=o.useMemo(()=>{const x=I.current;return x?c&&h!==x.draftName||c&&f!==x.draftScope?!0:u!==x.description||w!==x.aliases||k!==x.content:!1},[w,k,u,h,f,c]),T=async()=>{const x=c?h.trim().replace(/\s+/g,"-"):e?.trim();if(!x){$.error(t("settings.snippets.page.toast.nameRequired"));return}if(!k.trim()){$.error(t("settings.snippets.page.toast.contentRequired"));return}const A=w.split(",").map(R=>R.trim()).filter(Boolean);N(!0);try{if(!(c?await l(x,k,{aliases:A,description:u,scope:f}):await i(x,{content:k,aliases:A,description:u}))){$.error(t("settings.snippets.page.toast.saveFailed"));return}$.success(t("settings.snippets.page.toast.saved")),c&&r(null)}finally{N(!1)}};return e?s.jsxs(ts,{title:c?t("settings.snippets.page.title.new"):`#${e}`,description:d?d.filePath:void 0,showSaveStatus:!1,children:[s.jsxs(qe,{divider:!1,contentClassName:"space-y-0",children:[c?s.jsxs(It,{label:"#",children:[s.jsx(He,{value:h,onChange:x=>g(x.target.value),placeholder:t("settings.snippets.page.field.namePlaceholder"),className:"h-7 w-44 px-2"}),s.jsxs(Et,{value:f,onValueChange:x=>m(x),children:[s.jsx(At,{size:Bt,className:"w-fit min-w-[100px]",children:s.jsx($t,{})}),s.jsxs(Tt,{align:"end",children:[s.jsx(ut,{value:"global",children:t("settings.common.scope.global")}),s.jsx(ut,{value:"project",children:t("settings.common.scope.project")})]})]})]}):null,s.jsx(Ft,{label:t("settings.common.field.description"),children:s.jsx(He,{value:u,onChange:x=>v(x.target.value),placeholder:t("settings.snippets.page.field.descriptionPlaceholder"),className:"h-7 w-full max-w-sm px-2"})}),s.jsx(Ft,{label:t("settings.snippets.page.field.aliases"),children:s.jsx(He,{value:w,onChange:x=>b(x.target.value),placeholder:t("settings.snippets.page.field.aliasesPlaceholder"),className:"h-7 w-full max-w-sm px-2"})})]}),s.jsxs(qe,{settingsItem:"snippets.content",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.snippets.page.field.content")}),s.jsx(Gt,{children:t("settings.snippets.page.hint")})]}),s.jsx(As,{value:k,onChange:x=>p(x.target.value),placeholder:t("settings.snippets.page.field.contentPlaceholder"),rows:12,className:"mt-1.5 w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),s.jsx("div",{className:"pt-3",children:s.jsx(G,{onClick:T,disabled:S||!y,size:"xs",className:"!font-normal",children:t(S?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(_,{name:"file-text",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.snippets.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.snippets.page.empty.description")})]})})},bd=()=>{const{t}=Qe(),e=rt(f=>f.settingsGitmojiEnabled),a=rt(f=>f.setSettingsGitmojiEnabled),n=lm(),r=he(f=>f.gitChangesViewMode),i=he(f=>f.setGitChangesViewMode),[l,d]=o.useState(!0),c=o.useMemo(()=>[{id:"flat",label:t("settings.openchamber.git.option.flatList")},{id:"tree",label:t("settings.openchamber.git.option.treeView")}],[t]);o.useEffect(()=>{(async()=>{try{const m=await En();m&&(m.gitmojiEnabled!==void 0&&a(m.gitmojiEnabled),m.gitChangesViewMode!==void 0&&i(m.gitChangesViewMode))}catch(m){console.warn("Failed to load git settings:",m)}finally{d(!1)}})()},[i,a]);const h=o.useCallback(async f=>{a(f);try{await xt({gitmojiEnabled:f})}catch(m){console.warn("Failed to save gitmoji setting:",m)}},[a]),g=o.useCallback(f=>{f!==r&&(i(f),xt({gitChangesViewMode:f}))},[r,i]);return l?null:s.jsx(qe,{title:t("settings.openchamber.git.title"),children:s.jsxs("div",{className:cs,children:[s.jsx(js,{settingsItem:"git.changes-view",title:t("settings.openchamber.git.changesViewTitle"),children:s.jsx(tn,{"aria-label":t("settings.openchamber.git.changesViewAria"),children:c.map(f=>s.jsx(ws,{selected:r===f.id,onSelect:()=>{g(f.id)},label:f.label,ariaLabel:t("settings.openchamber.git.optionAria",{option:f.label})},f.id))})}),s.jsx(gt,{settingsItem:"git.gitmoji",checked:e,onChange:f=>{h(f)},label:t("settings.openchamber.git.enableGitmoji"),ariaLabel:t("settings.openchamber.git.enableGitmojiAria")}),s.jsx(gt,{settingsItem:"git.gitignored-files",checked:n,onChange:cm,label:t("settings.openchamber.git.showGitignored"),ariaLabel:t("settings.openchamber.git.showGitignoredAria")})]})})},tc=[{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)"}],Nb=[{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"}],Sb=({open:t,onOpenChange:e,profileId:a,importData:n})=>{const{t:r}=Qe(),i=oa(B=>B.getProfileById),l=oa(B=>B.createProfile),d=oa(B=>B.updateProfile),c=oa(B=>B.deleteProfile),h=o.useMemo(()=>a&&a!=="new"&&!n?i(a):null,[a,i,n]),g=a==="new"||n!=null,f=a==="global",[m,u]=o.useState(""),[v,w]=o.useState(""),[b,k]=o.useState(""),[p,S]=o.useState("ssh"),[N,I]=o.useState(""),[y,T]=o.useState(!1),[x,A]=o.useState(""),[R,P]=o.useState(""),[D,F]=o.useState("keyword"),[O,C]=o.useState("branch"),[M,U]=o.useState(!1),[L,W]=o.useState(!1),[X,J]=o.useState(!1);o.useEffect(()=>{if(t){if(n){const B=n.host.split("/"),ne=B.length>=3?B[B.length-1]:n.host;u(ne),w(n.username),k(""),S("token"),I(""),T(!1),A(""),P(n.host),F("string"),C("code")}else if(g)u(""),w(""),k(""),S("ssh"),I(""),T(!1),A(""),P(""),F("keyword"),C("branch");else if(h)u(h.name),w(h.userName),k(h.userEmail),S(h.authType||"ssh"),I(h.sshKey||""),T(h.signCommits===!0),A(h.signingKey||""),P(h.host||""),F(h.color||"keyword"),C(h.icon||"branch");else if(f){const B=i("global");B&&(u(B.name),w(B.userName),k(B.userEmail),S(B.authType||"ssh"),I(B.sshKey||""),T(!1),A(""),P(B.host||""),F(B.color||"keyword"),C(B.icon||"branch"))}}},[t,a,h,g,n,f,i]);const q=async()=>{if(!v.trim()||!b.trim()){$.error(r("settings.gitIdentities.editor.toast.userNameEmailRequired"));return}if(p==="token"&&!R.trim()){$.error(r("settings.gitIdentities.editor.toast.hostRequiredForToken"));return}if(y&&!x.trim()){$.error(r("settings.gitIdentities.editor.toast.signingKeyRequired"));return}U(!0);try{const B={name:m.trim()||v.trim(),userName:v.trim(),userEmail:b.trim(),authType:p,sshKey:p==="ssh"&&N.trim()||null,signCommits:y,signingKey:x.trim()||null,host:p==="token"&&R.trim()||null,color:D,icon:O};let ne;if(g)ne=await l(B);else if(a)ne=await d(a,B);else return;ne?($.success(r(g?"settings.gitIdentities.editor.toast.profileCreated":"settings.gitIdentities.editor.toast.profileUpdated")),e(!1)):$.error(r(g?"settings.gitIdentities.editor.toast.createProfileFailed":"settings.gitIdentities.editor.toast.updateProfileFailed"))}catch(B){console.error("Error saving profile:",B),$.error(r("settings.gitIdentities.editor.toast.saveUnexpectedError"))}finally{U(!1)}},z=async()=>{if(!(!a||g)){J(!0);try{await c(a)?($.success(r("settings.gitIdentities.editor.toast.profileDeleted")),W(!1),e(!1)):$.error(r("settings.gitIdentities.editor.toast.deleteProfileFailed"))}catch(B){console.error("Error deleting profile:",B),$.error(r("settings.gitIdentities.editor.toast.deleteUnexpectedError"))}finally{J(!1)}}},H=o.useMemo(()=>tc.find(ne=>ne.key===D)?.cssVar||"var(--syntax-keyword)",[D]),se=n?r("settings.gitIdentities.editor.title.importCredential"):g?r("settings.gitIdentities.editor.title.newIdentity"):f?r("settings.gitIdentities.editor.title.globalIdentity"):h?.name||r("settings.gitIdentities.editor.title.editIdentity");return s.jsxs(s.Fragment,{children:[s.jsx(Ut,{open:t,onOpenChange:e,children:s.jsxs(_t,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:se}),s.jsx(qt,{children:r(f?"settings.gitIdentities.editor.description.globalReadOnly":g?"settings.gitIdentities.editor.description.newProfile":"settings.gitIdentities.editor.description.editProfile")})]}),s.jsxs("div",{className:"space-y-5 py-2",children:[!f&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:`${Ct} block mb-1.5`,children:r("settings.gitIdentities.editor.field.profileName")}),s.jsx(He,{value:m,onChange:B=>u(B.target.value),placeholder:r("settings.gitIdentities.editor.field.profileNamePlaceholder"),className:"h-8"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.color")}),s.jsx("div",{className:"flex gap-1.5",children:tc.map(B=>s.jsx("button",{type:"button",onClick:()=>F(B.key),className:Pe("w-6 h-6 rounded-md border-2 transition-all cursor-pointer",D===B.key?"border-foreground scale-110":"border-transparent hover:border-border"),style:{backgroundColor:B.cssVar},title:B.label},B.key))})]}),s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.icon")}),s.jsx("div",{className:"flex gap-1.5",children:Nb.map(B=>{const ne=B.Icon;return s.jsx("button",{type:"button",onClick:()=>C(B.key),className:Pe("w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer",O===B.key?"border-[var(--interactive-border)] bg-[var(--surface-muted)]":"border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50"),title:B.label,children:s.jsx(_,{name:ne,className:"w-3.5 h-3.5",style:{color:O===B.key?H:"var(--surface-muted-foreground)"}})},B.key)})})]})]}),!f&&s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Ct,children:r("settings.gitIdentities.editor.field.userName")}),!f&&s.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),s.jsx(Gt,{contentClassName:"max-w-xs",children:r("settings.gitIdentities.editor.field.userNameTooltip")})]}),s.jsx(He,{value:v,onChange:B=>w(B.target.value),placeholder:r("settings.gitIdentities.editor.field.userNamePlaceholder"),required:!f,readOnly:f,disabled:f,className:"h-8"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Ct,children:r("settings.gitIdentities.editor.field.emailAddress")}),!f&&s.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),s.jsx(Gt,{contentClassName:"max-w-xs",children:r("settings.gitIdentities.editor.field.emailAddressTooltip")})]}),s.jsx(He,{type:"email",value:b,onChange:B=>k(B.target.value),placeholder:r("settings.gitIdentities.editor.field.emailAddressPlaceholder"),required:!f,readOnly:f,disabled:f,className:"h-8"})]})]}),!f&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.authMethod")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs(G,{size:"sm",type:"button",variant:"chip","aria-pressed":p==="ssh",onClick:()=>S("ssh"),children:[s.jsx(_,{name:"lock-2",className:"w-3.5 h-3.5 mr-1"})," SSH"]}),s.jsxs(G,{size:"sm",type:"button",variant:"chip","aria-pressed":p==="token",onClick:()=>S("token"),children:[s.jsx(_,{name:"key",className:"w-3.5 h-3.5 mr-1"})," ",r("settings.gitIdentities.editor.field.authToken")]})]})]}),p==="ssh"&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Ct,children:r("settings.gitIdentities.editor.field.sshKeyPath")}),s.jsx(Gt,{contentClassName:"max-w-xs",children:r("settings.gitIdentities.editor.field.sshKeyPathTooltip")})]}),s.jsx(He,{value:N,onChange:B=>I(B.target.value),placeholder:r("settings.gitIdentities.editor.field.sshKeyPathPlaceholder"),className:"h-8 font-mono text-xs"})]}),s.jsxs("div",{className:"border-t border-border/40 pt-3 space-y-3",children:[s.jsx(gt,{checked:y,onChange:T,label:r("settings.gitIdentities.editor.field.signCommits"),info:r("settings.gitIdentities.editor.section.commitSigning"),ariaLabel:r("settings.gitIdentities.editor.field.signCommits")}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:s.jsx("label",{className:Ct,children:r("settings.gitIdentities.editor.field.signingKey")})}),s.jsx(He,{value:x,onChange:B=>A(B.target.value),placeholder:r("settings.gitIdentities.editor.field.signingKeyPlaceholder"),disabled:!y,className:"h-8 font-mono text-xs"})]})]}),p==="token"&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Ct,children:r("settings.gitIdentities.editor.field.host")}),s.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),s.jsx(Gt,{contentClassName:"max-w-xs",children:r("settings.gitIdentities.editor.field.hostTooltip")})]}),s.jsx(He,{value:R,onChange:B=>P(B.target.value),placeholder:r("settings.gitIdentities.editor.field.hostPlaceholder"),required:!0,className:"h-8 font-mono text-xs"})]})]})]})]}),s.jsxs(as,{className:"gap-2",children:[!f&&!g&&s.jsxs(G,{variant:"outline",size:"sm",onClick:()=>W(!0),className:"text-[var(--status-error)] hover:text-[var(--status-error)] border-[var(--status-error)]/30 hover:bg-[var(--status-error)]/10 mr-auto",children:[s.jsx(_,{name:"delete-bin",className:"w-3.5 h-3.5 mr-1"})," ",r("settings.common.actions.delete")]}),s.jsx(G,{variant:"ghost",size:"sm",onClick:()=>e(!1),className:"text-foreground hover:bg-interactive-hover hover:text-foreground",children:r(f?"settings.gitIdentities.editor.actions.close":"settings.common.actions.cancel")}),!f&&s.jsx(G,{size:"sm",onClick:q,disabled:M,children:r(M?"settings.common.actions.saving":g?"settings.gitIdentities.editor.actions.create":"settings.gitIdentities.editor.actions.save")})]})]})}),s.jsx(Ut,{open:L,onOpenChange:B=>{X||W(B)},children:s.jsxs(_t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:r("settings.gitIdentities.page.deleteDialog.title")}),s.jsx(qt,{children:r("settings.gitIdentities.page.deleteDialog.description",{name:h?.name||m})})]}),s.jsxs(as,{children:[s.jsx(G,{variant:"ghost",onClick:()=>W(!1),disabled:X,children:r("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",variant:"destructive",onClick:()=>{z()},disabled:X,children:r("settings.common.actions.delete")})]})]})})]})},Cb={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart"},Ib={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)"},Pb=()=>{const t=tt.c(112),{t:e}=Qe(),{profiles:a,globalIdentity:n,defaultGitIdentityId:r,deleteProfile:i,loadProfiles:l,loadGlobalIdentity:d,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:h,setDefaultGitIdentityId:g,getUnimportedCredentials:f}=oa(Bs(Tb)),[m,u]=o.useState(!1),[v,w]=o.useState(null),[b,k]=o.useState(null),[p,S]=o.useState(null),[N,I]=o.useState(!1);let y,T;t[0]!==h||t[1]!==c||t[2]!==d||t[3]!==l?(y=()=>{l(),d(),c(),h()},T=[l,d,c,h],t[0]=h,t[1]=c,t[2]=d,t[3]=l,t[4]=y,t[5]=T):(y=t[4],T=t[5]),o.useEffect(y,T);let x,A,R,P,D,F,O,C,M,U,L,W,X,J;if(t[6]!==r||t[7]!==p||t[8]!==i||t[9]!==f||t[10]!==n||t[11]!==a||t[12]!==g||t[13]!==e){const Te=f();let ee;t[28]===Symbol.for("react.memo_cache_sentinel")?(ee=(Fe,Me)=>{w(Fe),k(Me??null),u(!0)},t[28]=ee):ee=t[28];const ae=ee;let fe;t[29]!==r||t[30]!==g||t[31]!==e?(fe=async Fe=>{const Me=r===Fe?null:Fe;if(!await g(Me)){$.error(e("settings.gitIdentities.page.toast.updateDefaultFailed"));return}$.success(e(Me?"settings.gitIdentities.page.toast.defaultUpdated":"settings.gitIdentities.page.toast.defaultUnset"))},t[29]=r,t[30]=g,t[31]=e,t[32]=fe):fe=t[32];const je=fe;let Re;t[33]!==p||t[34]!==i||t[35]!==e?(Re=async()=>{if(!p)return;I(!0),await i(p.id)?($.success(e("settings.gitIdentities.page.toast.profileDeleted",{name:p.name})),S(null)):$.error(e("settings.gitIdentities.page.toast.deleteProfileFailed")),I(!1)},t[33]=p,t[34]=i,t[35]=e,t[36]=Re):Re=t[36],R=Re,A=ts,t[37]!==e?(D=e("settings.page.git.title"),t[37]=e,t[38]=D):D=t[38],F=!0,x=qe,t[39]!==e?(W=e("settings.gitIdentities.page.section.title"),t[39]=e,t[40]=W):W=t[40],X=!1;let Ce,_e;t[41]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>ae("new"),_e=s.jsx(_,{name:"add",className:"w-3.5 h-3.5 mr-1"}),t[41]=Ce,t[42]=_e):(Ce=t[41],_e=t[42]);let Ke;t[43]!==e?(Ke=e("settings.common.badge.new"),t[43]=e,t[44]=Ke):Ke=t[44],t[45]!==Ke?(J=s.jsxs(G,{size:"sm",variant:"outline",onClick:Ce,children:[_e," ",Ke]}),t[45]=Ke,t[46]=J):J=t[46],P="git.identities",O="rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",C=n&&s.jsx(sc,{profile:n,isDefault:r==="global",onEdit:()=>ae("global"),onToggleDefault:()=>je("global"),isReadOnly:!0,hasBorder:a.length>0||Te.length>0}),M=a.map((Fe,Me)=>s.jsx(sc,{profile:Fe,isDefault:r===Fe.id,onEdit:()=>ae(Fe.id),onToggleDefault:()=>je(Fe.id),onDelete:()=>S(Fe),hasBorder:Me<a.length-1||Te.length>0},Fe.id)),U=!n&&a.length===0&&Te.length===0&&s.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground",children:[s.jsx(_,{name:"shield-keyhole",className:"mx-auto mb-2 h-8 w-8 opacity-40"}),s.jsx("p",{className:"typography-ui-label",children:e("settings.gitIdentities.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.gitIdentities.page.empty.description")})]}),L=Te.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-4 py-2 border-t border-[var(--surface-subtle)]",children:s.jsx("span",{className:"typography-micro text-muted-foreground",children:e("settings.gitIdentities.page.discoveredCredentials.title")})}),Te.map((Fe,Me)=>s.jsx(Ab,{credential:Fe,onImport:()=>ae("new",{host:Fe.host,username:Fe.username}),hasBorder:Me<Te.length-1},`${Fe.host}-${Fe.username}`))]}),t[6]=r,t[7]=p,t[8]=i,t[9]=f,t[10]=n,t[11]=a,t[12]=g,t[13]=e,t[14]=x,t[15]=A,t[16]=R,t[17]=P,t[18]=D,t[19]=F,t[20]=O,t[21]=C,t[22]=M,t[23]=U,t[24]=L,t[25]=W,t[26]=X,t[27]=J}else x=t[14],A=t[15],R=t[16],P=t[17],D=t[18],F=t[19],O=t[20],C=t[21],M=t[22],U=t[23],L=t[24],W=t[25],X=t[26],J=t[27];let q;t[47]!==O||t[48]!==C||t[49]!==M||t[50]!==U||t[51]!==L?(q=s.jsxs("div",{className:O,children:[C,M,U,L]}),t[47]=O,t[48]=C,t[49]=M,t[50]=U,t[51]=L,t[52]=q):q=t[52];let z;t[53]!==x||t[54]!==P||t[55]!==q||t[56]!==W||t[57]!==X||t[58]!==J?(z=s.jsx(x,{title:W,divider:X,headerAction:J,settingsItem:P,children:q}),t[53]=x,t[54]=P,t[55]=q,t[56]=W,t[57]=X,t[58]=J,t[59]=z):z=t[59];let H;t[60]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(bd,{}),t[60]=H):H=t[60];let se;t[61]!==A||t[62]!==D||t[63]!==F||t[64]!==z?(se=s.jsxs(A,{title:D,showSaveStatus:F,children:[z,H]}),t[61]=A,t[62]=D,t[63]=F,t[64]=z,t[65]=se):se=t[65];let B;t[66]!==b||t[67]!==m||t[68]!==v?(B=s.jsx(Sb,{open:m,onOpenChange:u,profileId:v,importData:b}),t[66]=b,t[67]=m,t[68]=v,t[69]=B):B=t[69];const ne=p!==null;let K;t[70]!==N?(K=Te=>{N||Te||S(null)},t[70]=N,t[71]=K):K=t[71];let Z;t[72]!==e?(Z=e("settings.gitIdentities.page.deleteDialog.title"),t[72]=e,t[73]=Z):Z=t[73];let oe;t[74]!==Z?(oe=s.jsx(Ht,{children:Z}),t[74]=Z,t[75]=oe):oe=t[75];const ue=p?.name??"";let de;t[76]!==e||t[77]!==ue?(de=e("settings.gitIdentities.page.deleteDialog.description",{name:ue}),t[76]=e,t[77]=ue,t[78]=de):de=t[78];let ce;t[79]!==de?(ce=s.jsx(qt,{children:de}),t[79]=de,t[80]=ce):ce=t[80];let Se;t[81]!==oe||t[82]!==ce?(Se=s.jsxs(Vt,{children:[oe,ce]}),t[81]=oe,t[82]=ce,t[83]=Se):Se=t[83];let re;t[84]===Symbol.for("react.memo_cache_sentinel")?(re=()=>S(null),t[84]=re):re=t[84];let ve;t[85]!==e?(ve=e("settings.common.actions.cancel"),t[85]=e,t[86]=ve):ve=t[86];let ie;t[87]!==N||t[88]!==ve?(ie=s.jsx(G,{variant:"ghost",onClick:re,disabled:N,children:ve}),t[87]=N,t[88]=ve,t[89]=ie):ie=t[89];let me;t[90]!==R?(me=()=>{R()},t[90]=R,t[91]=me):me=t[91];let ke;t[92]!==e?(ke=e("settings.common.actions.delete"),t[92]=e,t[93]=ke):ke=t[93];let Ae;t[94]!==N||t[95]!==me||t[96]!==ke?(Ae=s.jsx(G,{size:"sm",variant:"destructive",onClick:me,disabled:N,children:ke}),t[94]=N,t[95]=me,t[96]=ke,t[97]=Ae):Ae=t[97];let pe;t[98]!==ie||t[99]!==Ae?(pe=s.jsxs(as,{children:[ie,Ae]}),t[98]=ie,t[99]=Ae,t[100]=pe):pe=t[100];let Le;t[101]!==Se||t[102]!==pe?(Le=s.jsxs(_t,{className:"max-w-md",children:[Se,pe]}),t[101]=Se,t[102]=pe,t[103]=Le):Le=t[103];let Ve;t[104]!==ne||t[105]!==K||t[106]!==Le?(Ve=s.jsx(Ut,{open:ne,onOpenChange:K,children:Le}),t[104]=ne,t[105]=K,t[106]=Le,t[107]=Ve):Ve=t[107];let ye;return t[108]!==se||t[109]!==B||t[110]!==Ve?(ye=s.jsxs(s.Fragment,{children:[se,B,Ve]}),t[108]=se,t[109]=B,t[110]=Ve,t[111]=ye):ye=t[111],ye},sc=t=>{const e=tt.c(56),{profile:a,isDefault:n,onEdit:r,onToggleDefault:i,onDelete:l,isReadOnly:d,hasBorder:c}=t,{t:h}=Qe(),[g,f]=o.useState(!1),m=Cb[a.icon||"branch"]||"git-branch",u=Ib[a.color||""],v=a.authType||"ssh";let w;e[0]!==r?(w=z=>{z.currentTarget===z.target&&(z.key!=="Enter"&&z.key!==" "||(z.preventDefault(),r()))},e[0]=r,e[1]=w):w=e[1];const b=w;let k;e[2]!==n||e[3]!==d||e[4]!==l||e[5]!==i||e[6]!==h?(k=z=>s.jsxs(s.Fragment,{children:[s.jsx(z,{onClick:H=>{H.stopPropagation(),i()},children:h(n?"settings.gitIdentities.page.actions.unsetDefault":"settings.gitIdentities.page.actions.setAsDefault")}),!d&&l&&s.jsxs(z,{onClick:H=>{H.stopPropagation(),l()},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"h-4 w-4 mr-px"}),h("settings.common.actions.delete")]})]}),e[2]=n,e[3]=d,e[4]=l,e[5]=i,e[6]=h,e[7]=k):k=e[7];const p=k,S=c&&"border-b border-[var(--surface-subtle)]";let N;e[8]!==S?(N=Pe("group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer",S),e[8]=S,e[9]=N):N=e[9];let I;e[10]===Symbol.for("react.memo_cache_sentinel")?(I=z=>{z.preventDefault(),f(!0)},e[10]=I):I=e[10];let y;e[11]!==b||e[12]!==r||e[13]!==N?(y=s.jsx("div",{className:N,onClick:r,role:"button",tabIndex:0,onKeyDown:b,onContextMenu:I}),e[11]=b,e[12]=r,e[13]=N,e[14]=y):y=e[14];let T;e[15]!==u?(T={color:u},e[15]=u,e[16]=T):T=e[16];let x;e[17]!==m||e[18]!==T?(x=s.jsx(_,{name:m,className:"w-4 h-4 shrink-0",style:T}),e[17]=m,e[18]=T,e[19]=x):x=e[19];let A;e[20]!==a.name?(A=s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:a.name}),e[20]=a.name,e[21]=A):A=e[21];let R;e[22]!==v?(R=s.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:v}),e[22]=v,e[23]=R):R=e[23];let P;e[24]!==n||e[25]!==h?(P=n&&s.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:h("settings.gitIdentities.page.badge.default")}),e[24]=n,e[25]=h,e[26]=P):P=e[26];let D;e[27]!==d||e[28]!==h?(D=d&&s.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:h("settings.agents.sidebar.badge.system")}),e[27]=d,e[28]=h,e[29]=D):D=e[29];let F;e[30]!==R||e[31]!==P||e[32]!==D||e[33]!==A?(F=s.jsxs("div",{className:"flex items-center gap-1.5",children:[A,R,P,D]}),e[30]=R,e[31]=P,e[32]=D,e[33]=A,e[34]=F):F=e[34];const O=v==="token"&&a.host?a.host:a.userEmail;let C;e[35]!==O?(C=s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:O}),e[35]=O,e[36]=C):C=e[36];let M;e[37]!==F||e[38]!==C?(M=s.jsxs("div",{className:"min-w-0",children:[F,C]}),e[37]=F,e[38]=C,e[39]=M):M=e[39];let U;e[40]!==M||e[41]!==x?(U=s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[x,M]}),e[40]=M,e[41]=x,e[42]=U):U=e[42];let L;e[43]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(Nn,{asChild:!0,children:s.jsx(G,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:Eb,children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[43]=L):L=e[43];let W;e[44]!==p?(W=s.jsxs(Sn,{children:[L,s.jsx(kn,{align:"end",className:"w-fit min-w-28",children:p(an)})]}),e[44]=p,e[45]=W):W=e[45];let X;e[46]!==U||e[47]!==W||e[48]!==y?(X=s.jsxs(ga,{render:y,children:[U,W]}),e[46]=U,e[47]=W,e[48]=y,e[49]=X):X=e[49];let J;e[50]!==p?(J=s.jsx(ma,{className:"w-fit min-w-28",children:p(pa)}),e[50]=p,e[51]=J):J=e[51];let q;return e[52]!==g||e[53]!==X||e[54]!==J?(q=s.jsxs(ha,{open:g,onOpenChange:f,children:[X,J]}),e[52]=g,e[53]=X,e[54]=J,e[55]=q):q=e[55],q},Ab=t=>{const e=tt.c(21),{credential:a,onImport:n,hasBorder:r}=t,{t:i}=Qe();let l;e[0]!==a.host?(l=a.host.split("/"),e[0]=a.host,e[1]=l):l=e[1];const d=l,c=d.length>=3?d[d.length-1]:a.host,h=a.host.includes("/"),g=r&&"border-b border-[var(--surface-subtle)]";let f;e[2]!==g?(f=Pe("flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30",g),e[2]=g,e[3]=f):f=e[3];let m;e[4]!==c?(m=s.jsx("span",{className:"typography-ui-label text-foreground truncate block",children:c}),e[4]=c,e[5]=m):m=e[5];const u=h?a.host:a.username;let v;e[6]!==u?(v=s.jsx("span",{className:"typography-micro text-muted-foreground/60 truncate block leading-tight",children:u}),e[6]=u,e[7]=v):v=e[7];let w;e[8]!==m||e[9]!==v?(w=s.jsxs("div",{className:"min-w-0",children:[m,v]}),e[8]=m,e[9]=v,e[10]=w):w=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(_,{name:"download",className:"h-3 w-3"}),e[11]=b):b=e[11];let k;e[12]!==i?(k=i("settings.gitIdentities.page.actions.import"),e[12]=i,e[13]=k):k=e[13];let p;e[14]!==n||e[15]!==k?(p=s.jsxs(G,{size:"sm",variant:"ghost",onClick:n,className:"gap-1 shrink-0",children:[b,k]}),e[14]=n,e[15]=k,e[16]=p):p=e[16];let S;return e[17]!==p||e[18]!==f||e[19]!==w?(S=s.jsxs("div",{className:f,children:[w,p]}),e[17]=p,e[18]=f,e[19]=w,e[20]=S):S=e[20],S};function Tb(t){return{profiles:t.profiles,globalIdentity:t.globalIdentity,defaultGitIdentityId:t.defaultGitIdentityId,deleteProfile:t.deleteProfile,loadProfiles:t.loadProfiles,loadGlobalIdentity:t.loadGlobalIdentity,loadDiscoveredCredentials:t.loadDiscoveredCredentials,loadDefaultGitIdentityId:t.loadDefaultGitIdentityId,setDefaultGitIdentityId:t.setDefaultGitIdentityId,getUnimportedCredentials:t.getUnimportedCredentials}}function Eb(t){return t.stopPropagation()}const vd=({guest:t})=>{const{t:e}=Qe(),a=t.integration,n=Mr(K=>K.byId[t.id]),r=Mr(K=>K.setStatus),i=o.useMemo(()=>Fc(t.id,t.icon,Hc().authenticatedAsset),[t.id,t.icon]),l=Mr(K=>K.refresh),[d,c]=o.useState(!1),[h,g]=o.useState(!1),[f,m]=o.useState(!1),[u,v]=o.useState(""),[w,b]=o.useState(""),[k,p]=o.useState(""),[S,N]=o.useState(""),[I,y]=o.useState({}),[T,x]=o.useState(!1),A=o.useRef(null),[R]=o.useState(wn),P=o.useRef(!0),D=()=>P.current&&wn()===R,F=o.useCallback(()=>{A.current!=null&&(window.clearInterval(A.current),A.current=null),m(!1)},[]);if(o.useEffect(()=>(P.current=!0,l(t.id),()=>{P.current=!1,F()}),[t.id,l,F]),o.useEffect(()=>{n&&y(n.settings)},[n]),!a)return null;const O=a.auth,C=O==="token"&&a.token?.scheme==="basic",M=!!n?.connection.connected,U=n?.connection.account.trim()||"",L=f?e("settings.integrations.guests.status.waiting"):M?U||e("settings.integrations.guests.status.connected"):e("settings.integrations.guests.status.notConnected"),W=f?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":M?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground",X=f||d,J=a.name,q=async()=>{if(!D())return!1;const K=u.trim();if(!K)return n?.hasClient?!0:($.error(e("settings.integrations.guests.toast.clientRequired")),!1);os("saving");const Z=await Xm(t.id,K,w.trim()||void 0);return D()?Z?(r(t.id,Z),b(""),os("saved"),!0):(os("error"),$.error(e("settings.integrations.guests.toast.saveFailed",{name:J})),!1):!1},z=async(K=I)=>{if(!D())return!1;const Z=n?.settings??{};if((a.settings??[]).every(ce=>(K[ce.id]??"").trim()===(Z[ce.id]??"")))return!0;os("saving");const de=await qm(t.id,K);return D()?de?(r(t.id,de),os("saved"),!0):(os("error"),$.error(e("settings.integrations.guests.toast.saveFailed",{name:J})),!1):!1},H=async()=>{if(!D())return!1;const K=k.trim();if(!K)return M?!0:($.error(e("settings.integrations.guests.toast.tokenRequired")),!1);const Z=S.trim();if(C&&!Z)return $.error(e("settings.integrations.guests.toast.usernameRequired")),!1;os("saving");const oe=await Zm(t.id,K,C?Z:void 0);return D()?oe?(r(t.id,oe),p(""),N(""),os("saved"),!0):(os("error"),$.error(e("settings.integrations.guests.toast.tokenInvalid")),!1):!1},se=async()=>{if(!D())return;F(),g(!0);const K=n?.connection??{connected:!1,account:""};try{if(O==="token"){if(await H()){if((a.settings??[]).length>0&&!await z()||!D())return;$.success(e("settings.integrations.guests.toast.connected",{name:J}))}return}if(O==="oauth"&&!n?.hasClient&&!await q())return;const Z=await Wm(t.id);if(!D())return;if(!Z){$.error(e("settings.integrations.guests.toast.startFailed",{name:J}));return}m(!0),c(!0),jn(Z);const oe=Date.now()+Jm;A.current=window.setInterval(()=>{(async()=>{if(!D()){F();return}if(Date.now()>oe){F(),$.error(e("settings.integrations.guests.toast.authorizationFailed",{name:J}));return}const ue=await l(t.id);D()&&ue&&Qm(K,ue.connection)&&(F(),$.success(e("settings.integrations.guests.toast.connected",{name:J})),ls()&&qc())})()},Ym)}catch(Z){if(!D())return;console.error("Failed to start guest connect:",Z),$.error(e("settings.integrations.guests.toast.startFailed",{name:J})),F()}finally{D()&&g(!1)}},B=async()=>{if(D()){g(!0);try{F();const K=await Gm(t.id);if(!D())return;if(!K){$.error(e("settings.integrations.guests.toast.disconnectFailed",{name:J}));return}r(t.id,K),$.success(e("settings.integrations.guests.toast.disconnected",{name:J}))}catch(K){if(!D())return;console.error("Failed to disconnect guest:",K),$.error(e("settings.integrations.guests.toast.disconnectFailed",{name:J}))}finally{D()&&g(!1)}}},ne=async()=>{const K=n?.redirectUri??"";!K||!(await _a(K)).ok||(x(!0),window.setTimeout(()=>x(!1),1500))};return s.jsx(Cn,{open:X,onOpenChange:K=>{if(f){c(!0);return}c(K)},children:s.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[s.jsxs(In,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(Oc,{icon:Lc(t.icon),iconSrc:i,className:"size-5 text-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:J}),s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:a.description})]}),s.jsx("span",{"aria-live":"polite",className:Pe("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",W),children:L}),s.jsx(_,{name:"arrow-down-s",className:Pe("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",X&&"rotate-180")})]}),s.jsx(Pn,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsxs("div",{className:"space-y-3",children:[O==="oauth"?s.jsxs(s.Fragment,{children:[s.jsx(Ft,{label:e("settings.integrations.guests.field.clientId"),controlClassName:"w-full max-w-none",children:s.jsx(He,{value:u,onChange:K=>v(K.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:h})}),s.jsx(Ft,{label:e("settings.integrations.guests.field.clientSecret"),controlClassName:"w-full max-w-none",children:s.jsx(He,{type:"password",value:w,onChange:K=>b(K.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:h})})]}):null,C?s.jsx(Ft,{label:a.token?.usernameLabel??e("settings.integrations.guests.field.username"),controlClassName:"w-full max-w-none",children:s.jsx(He,{value:S,onChange:K=>N(K.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:h})}):null,O==="token"?s.jsx(Ft,{label:e("settings.integrations.guests.field.token"),info:e("settings.integrations.guests.field.token.info"),controlClassName:"w-full max-w-none",children:s.jsx(He,{type:"password",value:k,onChange:K=>p(K.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:h})}):null,(a.settings??[]).map(K=>s.jsx(Ft,{label:K.label,controlClassName:"w-full max-w-none",children:s.jsx(He,{value:I[K.id]??"",onChange:Z=>{y(oe=>({...oe,[K.id]:Z.target.value}))},onBlur:()=>{z()},autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:h})},K.id)),O==="oauth"?s.jsxs(Ft,{label:e("settings.integrations.guests.field.redirectUri"),info:e("settings.integrations.guests.field.redirectUri.info"),controlClassName:"w-full max-w-none",children:[s.jsx(He,{value:n?.redirectUri??"",readOnly:!0,className:"h-8 min-w-0 flex-1 rounded-md px-3"}),s.jsx(G,{type:"button",size:"sm",variant:"outline",disabled:!n?.redirectUri,onClick:()=>{ne()},children:e(T?"settings.integrations.guests.actions.copied":"settings.integrations.guests.actions.copyRedirect")})]}):null,s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:M?s.jsx(G,{type:"button",size:"sm",variant:"destructive",disabled:h,onClick:()=>{B()},children:e("settings.integrations.guests.actions.disconnect")}):s.jsxs(G,{type:"button",size:"sm",disabled:h||f,onClick:()=>{se()},children:[h?s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):null,e("settings.integrations.guests.actions.connect")]})})]})})]})})},Db=t=>{const e=tt.c(27),{divider:a}=t,n=a===void 0?!0:a,{t:r}=Qe(),i=qs(Mb),l=qs(Rb);let d;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0],o.useEffect(Fb,d),fs()||Gc())return null;let c,h,g,f,m,u,v,w;if(e[1]!==n||e[2]!==i||e[3]!==l||e[4]!==r){w=Symbol.for("react.early_return_sentinel");e:{const k=i.filter(Ob);if(k.length===0){w=null;break e}c=qe,e[13]!==r?(h=r("settings.integrations.guests.title"),e[13]=r,e[14]=h):h=e[14],e[15]!==r?(g=r("settings.integrations.guests.info"),e[15]=r,e[16]=g):g=e[16],f=n,m="integrations.guests",u="space-y-3";let p;e[17]!==l?(p=S=>s.jsx(vd,{guest:S},`${l}:${S.id}`),e[17]=l,e[18]=p):p=e[18],v=k.map(p)}e[1]=n,e[2]=i,e[3]=l,e[4]=r,e[5]=c,e[6]=h,e[7]=g,e[8]=f,e[9]=m,e[10]=u,e[11]=v,e[12]=w}else c=e[5],h=e[6],g=e[7],f=e[8],m=e[9],u=e[10],v=e[11],w=e[12];if(w!==Symbol.for("react.early_return_sentinel"))return w;let b;return e[19]!==c||e[20]!==h||e[21]!==g||e[22]!==f||e[23]!==m||e[24]!==u||e[25]!==v?(b=s.jsx(c,{title:h,info:g,divider:f,settingsItem:m,contentClassName:u,children:v}),e[19]=c,e[20]=h,e[21]=g,e[22]=f,e[23]=m,e[24]=u,e[25]=v,e[26]=b):b=e[26],b};function Mb(t){return t.guests}function Rb(t){return t.runtimeKey}function Fb(){Kn()}function Ob(t){return t.source!=="bundled"&&t.integration&&No(t)}const Lb=({embedded:t=!1})=>{const{t:e}=Qe(),{isMobile:a}=Zn(),n=Ha()?.github,r=Jn(C=>C.status),i=Jn(C=>C.isLoading),l=Jn(C=>C.hasChecked),d=Jn(C=>C.refreshStatus),c=Jn(C=>C.setStatus),h=o.useCallback(async C=>{await jn(C)},[]),[g,f]=o.useState(!1),[m,u]=o.useState(null),[v,w]=o.useState(null),b=o.useRef(null),k=o.useCallback(()=>{b.current!=null&&(window.clearInterval(b.current),b.current=null),w(null)},[]);o.useEffect(()=>((async()=>{try{l||await d(n)}catch(C){console.warn("Failed to load GitHub auth status:",C)}})(),()=>{k()}),[l,d,n,k]);const p=o.useCallback(async()=>{f(!0);try{const C=n?await n.authStart():await(async()=>{const U=await St("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),L=await U.json().catch(()=>null);if(!U.ok||!L||!("deviceCode"in L))throw new Error(L?.error||U.statusText);return L})();u(C),w(Math.max(1,C.interval)*1e3);const M=C.verificationUriComplete||C.verificationUri;h(M)}catch(C){console.error("Failed to start GitHub connect:",C),$.error(e("settings.github.page.toast.startConnectFailed"))}finally{f(!1)}},[h,n,e]),S=o.useCallback(async C=>{if(n)return n.authComplete(C);const M=await St("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:C})}),U=await M.json().catch(()=>null);if(!M.ok||!U)throw new Error(U?.error||M.statusText);return U},[n]);o.useEffect(()=>{if(!(!m?.deviceCode||!v)&&b.current==null)return b.current=window.setInterval(()=>{(async()=>{try{const C=await S(m.deviceCode);if(C.connected){$.success(e("settings.github.page.toast.connected")),u(null),k(),await d(n,{force:!0});return}C.status==="slow_down"&&w(M=>M?M+5e3:5e3),(C.status==="expired_token"||C.status==="access_denied")&&($.error(C.error||e("settings.github.page.toast.authorizationFailed")),u(null),k())}catch(C){console.warn("GitHub polling failed:",C)}})()},v),()=>{b.current!=null&&(window.clearInterval(b.current),b.current=null)}},[m,v,S,d,n,k,e]);const N=o.useCallback(async C=>{f(!0);try{if(n)await n.authSetGhCliDisabled(C);else{const M=await St("/api/github/auth/gh-cli",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({disabled:C})}),U=await M.json().catch(()=>null);if(!M.ok)throw new Error(U?.error||M.statusText)}$.success(e(C?"settings.github.page.toast.ghCliDisabled":"settings.github.page.toast.ghCliEnabled")),await d(n,{force:!0})}catch(M){console.error("Failed to update gh CLI setting:",M),$.error(e("settings.github.page.toast.ghCliUpdateFailed"))}finally{f(!1)}},[d,n,e]),I=o.useCallback(async()=>{f(!0);try{if(k(),u(null),n)await n.authDisconnect();else{const C=await St("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}});if(!C.ok)throw new Error(C.statusText)}$.success(e("settings.github.page.toast.disconnected")),await d(n,{force:!0})}catch(C){console.error("Failed to disconnect GitHub:",C),$.error(e("settings.github.page.toast.disconnectFailed"))}finally{f(!1)}},[d,n,k,e]),y=o.useCallback(async C=>{if(C){f(!0);try{const M=n?await n.authActivate(C):await(async()=>{const U=await St("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:C})}),L=await U.json().catch(()=>null);if(!U.ok||!L)throw new Error(L?.error||U.statusText);return L})();c(M),$.success(e("settings.github.page.toast.accountSwitched"))}catch(M){console.error("Failed to switch GitHub account:",M),$.error(e("settings.github.page.toast.accountSwitchFailed"))}finally{f(!1)}}},[n,c,e]);if(i&&!l)return null;const T=!!r?.connected,x=r?.user,R=(r?.accounts??[]).filter(C=>!C.current),P=r?.ghCli??null,D=P?.active?e("settings.github.page.accountSource.cli"):e("settings.github.page.accountSource.oauth"),F=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[T?s.jsxs("div",{className:Pe("px-4 py-3",a?"flex flex-col gap-3":"flex items-center justify-between gap-4"),children:[s.jsxs("div",{className:Pe("flex min-w-0 items-center gap-4",a?"w-full":void 0),children:[x?.avatarUrl?s.jsx("img",{src:x.avatarUrl,alt:x.login?e("settings.github.page.avatarAlt.withLogin",{login:x.login}):e("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"}):s.jsx("div",{className:"h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:x?.name?.trim()||x?.login||"GitHub"}),s.jsxs("div",{className:Pe("flex items-center gap-2 typography-meta text-muted-foreground mt-0.5",a?"flex-wrap":"truncate"),children:[s.jsx(_,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"font-mono",children:x?.login||e("settings.github.page.label.unknownUser")}),x?.email&&s.jsx("span",{className:"opacity-50",children:"•"}),x?.email&&s.jsx("span",{children:x.email}),s.jsx("span",{className:"opacity-50",children:"•"}),s.jsx("span",{children:D})]}),r?.scope&&s.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:e("settings.github.page.label.scopes",{value:r.scope})}),P?.active&&s.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:e("settings.github.page.ghCli.activeDescription")})]})]}),P?.active?s.jsx(G,{size:"sm",variant:"outline",onClick:()=>N(!0),disabled:g,className:Pe(a?"w-full":void 0),children:e("settings.github.page.ghCli.actions.disable")}):s.jsx(G,{size:"sm",variant:"outline",onClick:I,disabled:g,className:Pe("text-[var(--status-error)] hover:text-[var(--status-error)]",a?"w-full":void 0),children:e("settings.github.page.actions.disconnect")})]}):s.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-4",children:[s.jsx("div",{className:"flex min-w-0 flex-col",children:s.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.github.page.status.notConnected")})}),s.jsx(G,{size:"sm",variant:"default",onClick:p,disabled:g,children:e("settings.github.page.actions.connect")})]}),R.length>0&&s.jsxs("div",{className:"mt-2 border-t border-[var(--surface-subtle)] pt-2 px-2 pb-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground mb-2 px-1",children:e("settings.github.page.label.otherAccounts")}),s.jsx("div",{className:"space-y-1",children:R.map(C=>{const M=C.user,U=C.source==="gh-cli"?e("settings.github.page.accountSource.cli"):e("settings.github.page.accountSource.oauth");return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[M?.avatarUrl?s.jsx("img",{src:M.avatarUrl,alt:M.login?e("settings.github.page.avatarAlt.withLogin",{login:M.login}):e("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"}):s.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:s.jsx(_,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0 flex flex-col",children:[s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:M?.name?.trim()||M?.login||"GitHub"}),M?.login&&s.jsxs("span",{className:"typography-micro text-muted-foreground truncate",children:[s.jsx("span",{className:"font-mono",children:M.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:U})]})]})]}),s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>y(C.id),disabled:g,children:e("settings.github.page.actions.switchTo")})]},C.id)})})]})]}),T&&s.jsx("div",{className:"mt-2 px-2 pb-2",children:s.jsx(G,{size:"sm",variant:"outline",onClick:p,disabled:g,className:Pe(a?"w-full":void 0),children:e("settings.github.page.actions.addAccount")})}),m&&s.jsxs("div",{className:"mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(An,{children:e("settings.github.page.flow.title")}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.github.page.flow.description")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3 mt-4",children:[s.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}),s.jsx(G,{size:"sm",asChild:!0,children:s.jsx("a",{href:m.verificationUriComplete||m.verificationUri,target:"_blank",rel:"noopener noreferrer",children:e("settings.github.page.actions.openGithub")})})]}),s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsx("span",{className:"typography-micro text-muted-foreground animate-pulse",children:e("settings.github.page.flow.waiting")}),s.jsx(G,{size:"sm",variant:"ghost",disabled:g,onClick:()=>{k(),u(null)},children:e("settings.common.actions.cancel")})]})]})]}),O=P?.available&&!P?.active&&(!P.user||P.disabled)?s.jsx(s.Fragment,{children:s.jsx("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden",children:s.jsxs("div",{className:Pe("px-4 py-3",a?"flex flex-col gap-3":"flex items-center justify-between gap-4"),children:[s.jsxs("div",{className:Pe("flex min-w-0 items-center gap-4",a?"w-full":void 0),children:[P.user?.avatarUrl?s.jsx("img",{src:P.user.avatarUrl,alt:P.user.login?e("settings.github.page.avatarAlt.withLogin",{login:P.user.login}):e("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"}):s.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:s.jsx(_,{name:"github-fill",className:"h-4 w-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[!P.disabled&&P.user&&s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:P.user.name?.trim()||P.user.login||"GitHub"}),!P.disabled&&P.user?.login&&s.jsxs("div",{className:Pe("flex items-center gap-2 typography-meta text-muted-foreground mt-0.5",a?"flex-wrap":"truncate"),children:[s.jsx(_,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"font-mono",children:P.user.login}),P.user.email&&s.jsx("span",{className:"opacity-50",children:"•"}),P.user.email&&s.jsx("span",{children:P.user.email})]}),s.jsx("div",{className:Pe("typography-meta text-muted-foreground",P.disabled?"opacity-60":void 0),children:P.disabled?e("settings.github.page.ghCli.disabledDescription"):e("settings.github.page.ghCli.fallbackDescription")})]})]}),s.jsx(G,{size:"sm",variant:"outline",onClick:()=>N(!P.disabled),disabled:g,className:Pe(a?"w-full":void 0),children:P.disabled?e("settings.github.page.ghCli.actions.enable"):e("settings.github.page.ghCli.actions.disable")})]})})}):null;return t?s.jsxs("div",{className:"space-y-4",children:[F,O?s.jsxs("div",{className:"space-y-2",children:[s.jsx(An,{children:e("settings.github.page.ghCli.title")}),O]}):null]}):s.jsxs(s.Fragment,{children:[s.jsx(qe,{title:e("settings.github.page.oauth.title"),divider:!1,settingsItem:"git.github-account",info:e("settings.github.page.tooltip.connectAccount"),children:F}),O?s.jsx(qe,{title:e("settings.github.page.ghCli.title"),children:O}):null]})},Kb=()=>{const t=tt.c(37),{t:e}=Qe(),a=Jn(zb),n=Jn(Ub),r=Jn(_b),[i,l]=o.useState(!1),d=a?.connected===!0;let c;t[0]!==d||t[1]!==r||t[2]!==n||t[3]!==a?.user?.login||t[4]!==e?(c=n&&!r?e("common.loading"):d?a?.user?.login?.trim()||e("settings.github.page.status.active"):e("settings.integrations.github.status.notConnected"),t[0]=d,t[1]=r,t[2]=n,t[3]=a?.user?.login,t[4]=e,t[5]=c):c=t[5];const h=c,g=d?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground";let f;t[6]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(_,{name:"github-fill",className:"size-5 text-foreground"})}),t[6]=f):f=t[6];let m;t[7]!==e?(m=e("settings.integrations.github.title"),t[7]=e,t[8]=m):m=t[8];let u;t[9]!==m?(u=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:m}),t[9]=m,t[10]=u):u=t[10];let v;t[11]!==e?(v=e("settings.integrations.github.description"),t[11]=e,t[12]=v):v=t[12];let w;t[13]!==v?(w=s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:v}),t[13]=v,t[14]=w):w=t[14];let b;t[15]!==u||t[16]!==w?(b=s.jsxs("div",{className:"min-w-0 flex-1",children:[u,w]}),t[15]=u,t[16]=w,t[17]=b):b=t[17];let k;t[18]!==g?(k=Pe("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",g),t[18]=g,t[19]=k):k=t[19];let p;t[20]!==h||t[21]!==k?(p=s.jsx("span",{"aria-live":"polite",className:k,children:h}),t[20]=h,t[21]=k,t[22]=p):p=t[22];const S=i&&"rotate-180";let N;t[23]!==S?(N=Pe("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",S),t[23]=S,t[24]=N):N=t[24];let I;t[25]!==N?(I=s.jsx(_,{name:"arrow-down-s",className:N}),t[25]=N,t[26]=I):I=t[26];let y;t[27]!==I||t[28]!==b||t[29]!==p?(y=s.jsxs(In,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[f,b,p,I]}),t[27]=I,t[28]=b,t[29]=p,t[30]=y):y=t[30];let T;t[31]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(Pn,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsx(Lb,{embedded:!0})}),t[31]=T):T=t[31];let x;t[32]!==y?(x=s.jsxs("div",{"data-settings-item":"integrations.github",className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[y,T]}),t[32]=y,t[33]=x):x=t[33];let A;return t[34]!==i||t[35]!==x?(A=s.jsx(Cn,{open:i,onOpenChange:l,children:x}),t[34]=i,t[35]=x,t[36]=A):A=t[36],A};function zb(t){return t.status}function Ub(t){return t.isLoading}function _b(t){return t.hasChecked}const Ui="__none__",_i="__inherit__";function $b({linear:t,connected:e,organizationId:a}){const{t:n}=Qe(),r=pn(b=>b.projects),[i,l]=o.useState(null),[d,c]=o.useState(!1),[h,g]=o.useState(!1),f=o.useCallback(async()=>{if(!e){l(null),c(!1);return}try{const b=await t.mappingGet();if(b.connected===!1){l(null),c(!1);return}l(b),c(!1)}catch(b){console.error("Failed to load Linear mapping:",b),c(!0)}},[e,t]);o.useEffect(()=>{f()},[f,a]);const m=o.useCallback(async b=>{const k={};for(const p of b.teams??[])p.projectPath&&(k[p.id]=p.projectPath);g(!0),os("saving");try{const p=await t.mappingSet({defaultProjectPath:b.defaultProjectPath??null,teamProjectPaths:k});if(p.connected===!1){l(null),os("error");return}l(p),c(!1),os("saved")}catch(p){console.error("Failed to save Linear mapping:",p),os("error")}finally{g(!1)}},[t]);if(!e)return null;if(d&&!i)return s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.loadFailed")});if(!i)return null;const u=b=>r.find(p=>p.path===b)?.label?.trim()||b,v=b=>!b||b===Ui?n("settings.integrations.linear.mapping.defaultProject.placeholder"):u(b),w=b=>!b||b===_i?n("settings.integrations.linear.mapping.teams.useDefault"):u(b);return s.jsxs("div",{className:Fs,children:[r.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.emptyProjects")}):null,s.jsx(It,{label:n("settings.integrations.linear.mapping.defaultProject"),info:n("settings.integrations.linear.mapping.defaultProject.info"),settingsItem:"integrations.linear.mapping",children:s.jsxs(Et,{value:i.defaultProjectPath||Ui,disabled:h||r.length===0,onValueChange:b=>{m({...i,defaultProjectPath:b===Ui?null:b})},children:[s.jsx(At,{size:Bt,className:nn,"aria-label":n("settings.integrations.linear.mapping.defaultProject.aria"),children:s.jsx($t,{placeholder:n("settings.integrations.linear.mapping.defaultProject.placeholder"),children:v})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:Ui,children:n("settings.integrations.linear.mapping.defaultProject.placeholder")}),i.defaultProjectPath&&!r.some(b=>b.path===i.defaultProjectPath)?s.jsx(ut,{value:i.defaultProjectPath,children:i.defaultProjectPath}):null,r.map(b=>s.jsx(ut,{value:b.path,children:u(b.path)},b.id))]})]})}),s.jsx(js,{title:n("settings.integrations.linear.mapping.teams"),info:n("settings.integrations.linear.mapping.teams.info"),children:(i.teams??[]).length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.emptyTeams")}):s.jsx("div",{className:Fs,children:(i.teams??[]).map(b=>s.jsx(It,{label:`${b.key} · ${b.name}`,children:s.jsxs(Et,{value:b.projectPath||_i,disabled:h||r.length===0,onValueChange:k=>{m({...i,teams:(i.teams??[]).map(p=>p.id===b.id?{...p,projectPath:k===_i?null:k}:p)})},children:[s.jsx(At,{size:Bt,className:nn,"aria-label":n("settings.integrations.linear.mapping.teams.aria",{team:b.key}),children:s.jsx($t,{placeholder:n("settings.integrations.linear.mapping.teams.useDefault"),children:w})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:_i,children:n("settings.integrations.linear.mapping.teams.useDefault")}),b.projectPath&&!r.some(k=>k.path===b.projectPath)?s.jsx(ut,{value:b.projectPath,children:b.projectPath}):null,r.map(k=>s.jsx(ut,{value:k.path,children:u(k.path)},k.id))]})]})},b.id))})})]})}function Bb({linear:t,connected:e}){const{t:a}=Qe(),[n,r]=o.useState(null),[i,l]=o.useState(!1),[d,c]=o.useState(!1);o.useEffect(()=>{if(!e){r(null),l(!1);return}let g=!1;return t.preferencesGet().then(f=>{g||(r(f.sessionComments),l(!1))}).catch(()=>{g||l(!0)}),()=>{g=!0}},[e,t]);const h=o.useCallback(async g=>{const f=n;r(g),c(!0);try{const m=await t.preferencesSet({sessionComments:g});r(m.sessionComments),os("saved")}catch{r(f),os("error")}finally{c(!1)}},[n,t]);return e?i?s.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.integrations.linear.sessionComments.loadFailed")}):s.jsx("div",{className:Fs,children:s.jsx(It,{label:a("settings.integrations.linear.sessionComments.label"),info:a("settings.integrations.linear.sessionComments.info"),settingsItem:"integrations.linear.session-comments",children:s.jsx(Ba,{checked:n===!0,disabled:n===null||d,onCheckedChange:g=>{h(g)},"aria-label":a("settings.integrations.linear.sessionComments.aria")})})}):null}const Vb=3*6e4,Hb=1500;function nc(t){const e=t?.workspaces??[],a=e.find(n=>n.current);return{connected:!!t?.connected,ids:e.map(n=>n.id).slice().sort().join(","),currentId:a?.id||t?.organization?.id||"",currentAuthorizedAt:a?.authorizedAt??0}}function qb(t,e){return e.connected?t.connected?e.ids!==t.ids||e.currentId!==t.currentId||e.currentAuthorizedAt!==t.currentAuthorizedAt:!0:!1}const Gb=()=>{const{t}=Qe(),e=Ha()?.linear,a=Ma(P=>P.status),n=Ma(P=>P.isLoading),r=Ma(P=>P.hasChecked),i=Ma(P=>P.refreshStatus),l=Ma(P=>P.setStatus),[d,c]=o.useState(!1),[h,g]=o.useState(!1),[f,m]=o.useState(!1),u=o.useRef(null),v=o.useCallback(()=>{u.current!=null&&(window.clearInterval(u.current),u.current=null),g(!1)},[]);o.useEffect(()=>{if(e)return r||i(e),()=>{v()}},[r,i,e,v]);const w=o.useCallback(async()=>{if(!e)return;v(),c(!0);const P=nc(Ma.getState().status);try{const D=await e.authStart(ls()?"desktop":"web");g(!0),m(!0),jn(D.authorizationUrl);const F=Date.now()+Vb;u.current=window.setInterval(()=>{(async()=>{if(Date.now()>F){v(),$.error(t("settings.integrations.linear.toast.authorizationFailed"));return}const O=await i(e,{force:!0});qb(P,nc(O))&&(v(),$.success(t("settings.integrations.linear.toast.connected")),qc())})()},Hb)}catch(D){console.error("Failed to start Linear connect:",D),$.error(t("settings.integrations.linear.toast.startConnectFailed")),v()}finally{c(!1)}},[i,e,v,t]),b=o.useCallback(async P=>{if(!(!e||!P)){c(!0);try{const D=await e.authActivate(P);l(D),$.success(t("settings.integrations.linear.toast.workspaceSwitched"))}catch(D){console.error("Failed to switch Linear workspace:",D),$.error(t("settings.integrations.linear.toast.workspaceSwitchFailed"))}finally{c(!1)}}},[e,l,t]),k=o.useCallback(async()=>{if(e){c(!0);try{v(),await e.authDisconnect(),$.success(t("settings.integrations.linear.toast.disconnected")),await i(e,{force:!0})}catch(P){console.error("Failed to disconnect Linear:",P),$.error(t("settings.integrations.linear.toast.disconnectFailed"))}finally{c(!1)}}},[i,e,v,t]);if(!e)return null;const p=!!a?.connected,S=a?.user,N=a?.organization,y=(a?.workspaces??[]).filter(P=>!P.current),T=S?.displayName?.trim()||S?.name?.trim()||t("settings.integrations.linear.label.unknownUser"),x=h?t("settings.integrations.linear.status.waiting"):n&&!r?t("common.loading"):p?N?.name?.trim()||t("settings.integrations.linear.status.connected"):t("settings.integrations.linear.status.notConnected"),A=h?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":p?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground",R=h||f;return s.jsx(Cn,{open:R,onOpenChange:P=>{if(h){m(!0);return}m(P)},children:s.jsxs("div",{"data-settings-item":"integrations.linear",className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[s.jsxs(In,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(_,{name:"linear",className:"size-5 text-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:t("settings.integrations.linear.title")}),s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:t("settings.integrations.linear.description")})]}),s.jsx("span",{"aria-live":"polite",className:Pe("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",A),children:x}),s.jsx(_,{name:"arrow-down-s",className:Pe("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",R&&"rotate-180")})]}),s.jsx(Pn,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsxs("div",{className:"space-y-3",children:[p?s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[S?.avatarUrl?s.jsx("img",{src:S.avatarUrl,alt:t("settings.integrations.linear.avatarAlt.withName",{name:T}),className:"size-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]",children:s.jsx(_,{name:"linear",className:"size-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:T}),s.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[N?.name,S?.email].filter(Boolean).join(" · ")})]})]}):h?s.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.integrations.linear.flow.description")}):null,p?s.jsxs(s.Fragment,{children:[s.jsx($b,{linear:e,connected:p,organizationId:N?.id??null}),s.jsx(Bb,{linear:e,connected:p}),y.length>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.integrations.linear.label.otherWorkspaces")}),s.jsx("div",{className:"space-y-1",children:y.map(P=>{const D=P.user,F=P.name?.trim()||t("settings.integrations.linear.status.connected");return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:F}),D?.email?s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:D.email}):null]}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",onClick:()=>{b(P.id)},disabled:d,children:t("settings.integrations.linear.actions.switchTo")})]},P.id)})})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(G,{type:"button",size:"sm",variant:"outline",onClick:()=>{w()},disabled:d||h,"data-settings-item":"integrations.linear.add-workspace",children:t("settings.integrations.linear.actions.addWorkspace")}),s.jsx(G,{type:"button",size:"sm",variant:"destructive",onClick:()=>{k()},disabled:d,children:t("settings.integrations.linear.actions.disconnect")})]})]}):h?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground animate-pulse",children:t("settings.integrations.linear.flow.waiting")}),s.jsx(G,{type:"button",size:"sm",variant:"ghost",disabled:d,onClick:v,children:t("settings.common.actions.cancel")})]}):s.jsxs(G,{type:"button",size:"sm",variant:"default",onClick:()=>{w()},disabled:d||n&&!r,children:[d?s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):null,t("settings.integrations.linear.actions.connect")]})]})})]})})},Wb=()=>{const t=tt.c(23),{t:e}=Qe();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=fs(),t[0]=a):a=t[0];const n=!a,r=!!Ha()?.linear,i=qs(Jb),l=qs(Qb);let d,c,h,g,f,m;if(t[1]!==i||t[2]!==l||t[3]!==e){const w=!fs()&&!Gc()?i.filter(Yb):[];c=n||r||w.length>0,d=ts,t[10]!==e?(h=e("settings.page.integrations.title"),t[10]=e,t[11]=h):h=t[11],t[12]!==e?(g=e("settings.page.integrations.description"),t[12]=e,t[13]=g):g=t[13],f=!0,m=c?s.jsxs(qe,{title:e("settings.integrations.firstParty.title"),info:e("settings.integrations.firstParty.info"),divider:!1,settingsItem:"integrations.first-party",contentClassName:"space-y-3",children:[n?s.jsx(Kb,{}):null,r?s.jsx(Gb,{}):null,w.map(b=>s.jsx(vd,{guest:b},`${l}:${b.id}`))]}):null,t[1]=i,t[2]=l,t[3]=e,t[4]=d,t[5]=c,t[6]=h,t[7]=g,t[8]=f,t[9]=m}else d=t[4],c=t[5],h=t[6],g=t[7],f=t[8],m=t[9];let u;t[14]!==c?(u=s.jsx(Db,{divider:c}),t[14]=c,t[15]=u):u=t[15];let v;return t[16]!==d||t[17]!==h||t[18]!==g||t[19]!==f||t[20]!==m||t[21]!==u?(v=s.jsxs(d,{title:h,description:g,showSaveStatus:f,children:[m,u]}),t[16]=d,t[17]=h,t[18]=g,t[19]=f,t[20]=m,t[21]=u,t[22]=v):v=t[22],v};function Jb(t){return t.guests}function Qb(t){return t.runtimeKey}function Yb(t){return t.source==="bundled"&&t.integration&&No(t)}const La="__default__",Zb=500,Xb=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,64),ev=(t,e)=>{const a=tt.c(9),n=rt(nv);let r;e:{if(!t||!e){let c;a[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],a[0]=c):c=a[0],r=c;break e}let i;if(a[1]!==e||a[2]!==t||a[3]!==n){let c;a[5]!==t?(c=g=>g.id===t,a[5]=t,a[6]=c):c=a[6],i=n.find(c)?.models.find(g=>g.id===e),a[1]=e,a[2]=t,a[3]=n,a[4]=i}else i=a[4];const l=i;let d;a[7]!==l?(d=l?.variants?Object.keys(l.variants):[],a[7]=l,a[8]=d):d=a[8],r=d}return r},yd=t=>{const e=tt.c(33),{providerID:a,modelID:n,value:r,onChange:i,ariaLabel:l,className:d}=t,{t:c}=Qe(),h=ev(a,n);let g;e[0]!==c?(g=A=>A===La?c("settings.routing.thinking.default"):A.charAt(0).toUpperCase()+A.slice(1),e[0]=c,e[1]=g):g=e[1];const f=g,m=r??La;let u;e[2]!==i?(u=A=>i(A===La?null:A),e[2]=i,e[3]=u):u=e[3];const v=h.length===0;let w;e[4]!==d?(w=Pe(nn,d),e[4]=d,e[5]=w):w=e[5];const b=r??La;let k;e[6]!==f||e[7]!==b?(k=f(b),e[6]=f,e[7]=b,e[8]=k):k=e[8];let p;e[9]!==k?(p=s.jsx($t,{children:k}),e[9]=k,e[10]=p):p=e[10];let S;e[11]!==l||e[12]!==w||e[13]!==p?(S=s.jsx(At,{size:Bt,className:w,"aria-label":l,children:p}),e[11]=l,e[12]=w,e[13]=p,e[14]=S):S=e[14];let N;e[15]!==f?(N=f(La),e[15]=f,e[16]=N):N=e[16];let I;e[17]!==N?(I=s.jsx(ut,{value:La,children:N}),e[17]=N,e[18]=I):I=e[18];let y;if(e[19]!==f||e[20]!==h){let A;e[22]!==f?(A=R=>s.jsx(ut,{value:R,children:f(R)},R),e[22]=f,e[23]=A):A=e[23],y=h.map(A),e[19]=f,e[20]=h,e[21]=y}else y=e[21];let T;e[24]!==I||e[25]!==y?(T=s.jsxs(Tt,{children:[I,y]}),e[24]=I,e[25]=y,e[26]=T):T=e[26];let x;return e[27]!==T||e[28]!==m||e[29]!==u||e[30]!==v||e[31]!==S?(x=s.jsxs(Et,{value:m,onValueChange:u,disabled:v,children:[S,T]}),e[27]=T,e[28]=m,e[29]=u,e[30]=v,e[31]=S,e[32]=x):x=e[32],x},tv=t=>{const e=tt.c(49),{category:a,expanded:n,onToggle:r,onChange:i,onReset:l,onRemove:d}=t,{t:c}=Qe();let h;e[0]!==a.model||e[1]!==a.variant||e[2]!==c?(h=a.model?`${a.model.modelID}${a.variant?` / ${a.variant}`:""}`:c("settings.routing.model.useFallback"),e[0]=a.model,e[1]=a.variant,e[2]=c,e[3]=h):h=e[3];const g=h;let f;e[4]!==a.agent||e[5]!==g?(f=[g,a.agent].filter(Boolean),e[4]=a.agent,e[5]=g,e[6]=f):f=e[6];const m=f.join(" · "),u=!a.enabled&&"opacity-60";let v;e[7]!==u?(v=Pe("py-1",u),e[7]=u,e[8]=v):v=e[8];const w=n?"arrow-down-s":"arrow-right-s";let b;e[9]!==w?(b=s.jsx(_,{name:w,className:"size-4 flex-shrink-0 text-muted-foreground"}),e[9]=w,e[10]=b):b=e[10];const k=a.name||a.id;let p;e[11]!==k?(p=s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:k}),e[11]=k,e[12]=p):p=e[12];let S;e[13]!==m?(S=s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:m}),e[13]=m,e[14]=S):S=e[14];let N;e[15]!==n||e[16]!==r||e[17]!==b||e[18]!==p||e[19]!==S?(N=s.jsxs("button",{type:"button",onClick:r,"aria-expanded":n,className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-1.5 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[b,p,S]}),e[15]=n,e[16]=r,e[17]=b,e[18]=p,e[19]=S,e[20]=N):N=e[20];const I=a.enabled;let y;e[21]!==i?(y=D=>i({enabled:D}),e[21]=i,e[22]=y):y=e[22];let T;e[23]!==a.name||e[24]!==c?(T=c("settings.routing.category.enabledAria",{name:a.name}),e[23]=a.name,e[24]=c,e[25]=T):T=e[25];let x;e[26]!==a.enabled||e[27]!==y||e[28]!==T?(x=s.jsx(Ba,{checked:I,onCheckedChange:y,"aria-label":T}),e[26]=a.enabled,e[27]=y,e[28]=T,e[29]=x):x=e[29];let A;e[30]!==N||e[31]!==x?(A=s.jsxs("div",{className:"flex items-center gap-2",children:[N,x]}),e[30]=N,e[31]=x,e[32]=A):A=e[32];let R;e[33]!==a.agent||e[34]!==a.description||e[35]!==a.model?.modelID||e[36]!==a.model?.providerID||e[37]!==a.name||e[38]!==a.variant||e[39]!==n||e[40]!==i||e[41]!==d||e[42]!==l||e[43]!==c?(R=n?s.jsxs("div",{className:"space-y-4 px-1 pb-4 pt-2",children:[s.jsxs(On,{children:[s.jsx(Ft,{label:c("settings.routing.category.name"),controlClassName:"max-w-none",children:s.jsx(He,{value:a.name,onChange:D=>i({name:D.target.value}),"aria-label":c("settings.routing.category.name"),className:"h-8 w-full rounded-md px-3",maxLength:60})}),s.jsx(Ft,{label:c("settings.routing.category.agent"),info:c("settings.routing.category.agentInfo"),controlClassName:"max-w-none",children:s.jsx(bo,{agentName:a.agent??"",onChange:D=>i({agent:D||null}),filter:av,className:Pe(Ws,"w-full")})}),s.jsx(Ft,{label:c("settings.routing.category.model"),info:c("settings.routing.category.modelInfo"),controlClassName:"max-w-none",children:s.jsx(ca,{providerId:a.model?.providerID??"",modelId:a.model?.modelID??"",onChange:(D,F)=>i({model:{providerID:D,modelID:F},variant:null}),className:Pe(Ws,"w-full"),placeholder:c("settings.routing.model.useFallback")})}),s.jsx(Ft,{label:c("settings.routing.category.thinking"),controlClassName:"max-w-none",children:s.jsx(yd,{providerID:a.model?.providerID,modelID:a.model?.modelID,value:a.variant,onChange:D=>i({variant:D}),ariaLabel:c("settings.routing.category.thinking"),className:"w-full"})})]}),s.jsx(Ft,{label:c("settings.routing.category.description"),info:c("settings.routing.category.descriptionInfo"),controlClassName:"max-w-none",children:s.jsx(As,{value:a.description,onChange:D=>i({description:D.target.value}),"aria-label":c("settings.routing.category.description"),rows:5,maxLength:2e3,className:"w-full"})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l?s.jsx(G,{size:"sm",variant:"outline",onClick:l,children:c("settings.routing.category.reset")}):null,s.jsx(G,{size:"sm",variant:"ghost",onClick:d,children:c("settings.routing.category.remove")})]})]}):null,e[33]=a.agent,e[34]=a.description,e[35]=a.model?.modelID,e[36]=a.model?.providerID,e[37]=a.name,e[38]=a.variant,e[39]=n,e[40]=i,e[41]=d,e[42]=l,e[43]=c,e[44]=R):R=e[44];let P;return e[45]!==A||e[46]!==R||e[47]!==v?(P=s.jsxs("div",{className:v,children:[A,R]}),e[45]=A,e[46]=R,e[47]=v,e[48]=P):P=e[48],P},sv=()=>{const{t}=Qe(),e=Xs(K=>K.available),a=Xs(K=>K.autoReady),n=Xs(K=>K.tokenPresent),r=Xs(K=>K.jevSource),i=Xs(K=>K.config),l=Xs(K=>K.builtins),d=Xs(K=>K.loaded),c=Xs(K=>K.loadError),h=Xs(K=>K.load),g=Xs(K=>K.saveConfig),f=Xs(K=>K.setToken),m=Xs(K=>K.clearToken),[u,v]=o.useState(i),[w,b]=o.useState(""),[k,p]=o.useState(!1),[S,N]=o.useState(null),[I,y]=o.useState(""),[T,x]=o.useState(null),A=o.useRef(null),R=o.useRef(null),P=o.useRef(Promise.resolve()),D=o.useRef(0);o.useEffect(()=>{h()},[h]),o.useEffect(()=>{!A.current&&D.current===0&&v(i)},[i]);const F=o.useCallback(()=>{const K=A.current;if(!K||(A.current=null,K.runtimeKey!==wn()))return P.current;D.current+=1,os("saving");const Z=P.current.then(async()=>{try{if(K.runtimeKey!==wn()){os("saved");return}await g(K.config),os("saved")}catch{os("error")}finally{D.current-=1}});return P.current=Z,Z},[g]);o.useEffect(()=>()=>{R.current&&clearTimeout(R.current),F()},[F]);const O=rt(K=>K.settingsDefaultModel),C=rt(K=>K.settingsDefaultVariant),M=o.useRef(!1);o.useEffect(()=>{if(M.current||!d||!i||i.fallback)return;const K=zn(O);!K||Wc(K.providerId,K.modelId)||(M.current=!0,U(Z=>Z.fallback?Z:{...Z,fallback:{model:{providerID:K.providerId,modelID:K.modelId},variant:C??null}}))},[d,i,O,C]);const U=o.useCallback(K=>{v(Z=>{if(!Z)return Z;const oe=K(Z);return A.current={config:oe,runtimeKey:wn()},R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{R.current=null,F()},Zb),oe})},[F]),L=o.useCallback((K,Z)=>{U(oe=>({...oe,categories:oe.categories.map(ue=>ue.id===K?{...ue,...Z}:ue)}))},[U]),W=async()=>{const K=w.trim();if(K){p(!0),N(null);try{await f(K),b("")}catch(Z){N(Z instanceof Error?Z.message:String(Z))}finally{p(!1)}}},X=async()=>{p(!0),N(null);try{await m()}catch(K){N(K instanceof Error?K.message:String(K))}finally{p(!1)}},J=()=>{const K=I.trim();if(!K||!u)return;const Z=Xb(K)||`category-${Date.now()}`;let oe=Z,ue=2;for(;u.categories.some(de=>de.id===oe);)oe=`${Z}-${ue++}`;U(de=>({...de,categories:[...de.categories,{id:oe,builtin:!1,enabled:!0,name:K,description:"",model:null,variant:null,agent:null}]})),y(""),x(oe)},q=K=>{const Z=l.find(oe=>oe.id===K);Z&&L(K,{name:Z.name,description:Z.description,model:null,variant:null,agent:null,enabled:!0})},z=K=>{const Z=l.find(oe=>oe.id===K);Z&&U(oe=>({...oe,categories:[...oe.categories,{id:K,builtin:!0,enabled:!0,name:Z.name,description:Z.description,model:null,variant:null,agent:null}]}))},H=K=>{U(Z=>({...Z,categories:Z.categories.filter(oe=>oe.id!==K)}))},se=u?.categories.filter(K=>K.enabled).length??0,B=l.filter(K=>!u?.categories.some(Z=>Z.id===K.id)),ne=u?.enabled?u.fallback?se<2?t("settings.routing.status.tooFewCategories"):t(a?"settings.routing.status.ready":"settings.routing.status.notReady"):t("settings.routing.status.noFallback"):t("settings.routing.status.disabled");return s.jsxs(ts,{title:t("settings.page.routing.title"),description:t("settings.page.routing.description"),showSaveStatus:!0,children:[c?s.jsx("p",{className:Vi,children:t("settings.routing.loadError",{error:c})}):null,!d||!u?null:e?s.jsxs(s.Fragment,{children:[s.jsx(qe,{title:t("settings.routing.access.title"),divider:!1,children:s.jsxs("div",{className:Fs,children:[s.jsx("p",{className:vs,children:t("settings.routing.access.intro")}),s.jsx("p",{className:vs,children:r==="typesafe"?t("settings.routing.access.usingKey"):s.jsxs(s.Fragment,{children:[s.jsx("strong",{className:"font-semibold",children:t("settings.routing.access.usingFree")})," ",t("settings.routing.access.usingFreeDetails")]})}),s.jsx(It,{settingsItem:"routing.token",label:t("settings.routing.token.label"),info:t("settings.routing.token.info"),children:s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(He,{type:"password",autoComplete:"off",value:w,onChange:K=>b(K.target.value),onKeyDown:K=>{K.key==="Enter"&&W()},placeholder:t(n?"settings.routing.token.replacePlaceholder":"settings.routing.token.placeholder"),"aria-label":t("settings.routing.token.label"),className:"h-8 rounded-md px-3 min-w-0 flex-1",disabled:k}),s.jsx(G,{size:"sm",variant:"outline",onClick:()=>{W()},disabled:k||w.trim().length===0,children:t("settings.routing.token.save")}),n?s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>{X()},disabled:k,children:t("settings.routing.token.remove")}):null]})}),S?s.jsx("p",{className:Vi,children:S}):null]})}),s.jsx(qe,{title:t("settings.routing.auto.title"),children:s.jsxs("div",{className:Fs,children:[s.jsx("div",{className:cs,children:s.jsx(gt,{settingsItem:"routing.enabled",checked:u.enabled,onChange:K=>U(Z=>({...Z,enabled:K})),label:t("settings.routing.auto.enable"),ariaLabel:t("settings.routing.auto.enable"),info:t("settings.routing.auto.enableInfo")})}),s.jsx("p",{className:vs,children:ne}),s.jsx(It,{settingsItem:"routing.fallback-model",label:t("settings.routing.auto.fallbackModel"),info:t("settings.routing.auto.fallbackModelInfo"),children:s.jsx(ca,{providerId:u.fallback?.model.providerID??"",modelId:u.fallback?.model.modelID??"",onChange:(K,Z)=>U(oe=>({...oe,fallback:{model:{providerID:K,modelID:Z},variant:null}})),className:Ws,placeholder:t("settings.routing.model.placeholder")})}),s.jsx(It,{settingsItem:"routing.fallback-thinking",label:t("settings.routing.auto.fallbackThinking"),info:t("settings.routing.auto.fallbackThinkingInfo"),children:s.jsx(yd,{providerID:u.fallback?.model.providerID,modelID:u.fallback?.model.modelID,value:u.fallback?.variant??null,onChange:K=>U(Z=>Z.fallback?{...Z,fallback:{...Z.fallback,variant:K}}:Z),ariaLabel:t("settings.routing.auto.fallbackThinking")})})]})}),s.jsx(qe,{title:t("settings.routing.categories.title"),children:s.jsxs("div",{className:Fs,children:[s.jsx("p",{className:vs,children:t("settings.routing.categories.description")}),s.jsx("div",{className:"divide-y divide-border/40 border-y border-border/40",children:u.categories.map(K=>s.jsx(tv,{category:K,expanded:T===K.id,onToggle:()=>x(Z=>Z===K.id?null:K.id),onChange:Z=>L(K.id,Z),onReset:K.builtin?()=>q(K.id):null,onRemove:()=>H(K.id)},K.id))}),B.length>0?s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:B.map(K=>s.jsx(G,{size:"sm",variant:"outline",onClick:()=>z(K.id),children:t("settings.routing.category.restore",{name:K.name})},K.id))}):null,s.jsx(It,{label:t("settings.routing.categories.addLabel"),settingsItem:"routing.add-category",children:s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(He,{value:I,onChange:K=>y(K.target.value),onKeyDown:K=>{K.key==="Enter"&&J()},placeholder:t("settings.routing.categories.addPlaceholder"),"aria-label":t("settings.routing.categories.addLabel"),className:"h-8 rounded-md px-3 min-w-0 flex-1",maxLength:60}),s.jsx(G,{size:"sm",variant:"outline",onClick:J,disabled:I.trim().length===0,children:t("settings.routing.categories.add")})]})})]})}),s.jsx(qe,{title:t("settings.routing.safety.title"),children:s.jsxs("div",{className:Fs,children:[s.jsx("p",{className:vs,children:t("settings.routing.safety.description")}),s.jsx("div",{className:cs,children:s.jsx(gt,{settingsItem:"routing.safety-enabled",checked:u.safetyNet.enabled,onChange:K=>U(Z=>({...Z,safetyNet:{...Z.safetyNet,enabled:K}})),label:t("settings.routing.safety.enable"),ariaLabel:t("settings.routing.safety.enable"),info:t("settings.routing.safety.enableInfo")})})]})})]}):s.jsx("p",{className:Vi,children:t("settings.routing.unavailable")})]})};function nv(t){return t.providers}function av(t){return Kc(t.mode)}const iv={prompt:{icon:"chat-1",titleKey:"settings.extensions.capability.prompt",detailKey:"settings.extensions.capability.prompt.detail"},sessions:{icon:"git-branch",titleKey:"settings.extensions.capability.sessions",detailKey:"settings.extensions.capability.sessions.detail"},files:{icon:"file-text",titleKey:"settings.extensions.capability.files",detailKey:"settings.extensions.capability.files.detail"},model:{icon:"sparkling",titleKey:"settings.extensions.capability.model",detailKey:"settings.extensions.capability.model.detail"},conversation:{icon:"chat-history",titleKey:"settings.extensions.capability.conversation",detailKey:"settings.extensions.capability.conversation.detail"},filesystem:{icon:"hard-drive-2",titleKey:"settings.extensions.capability.filesystem",detailKey:"settings.extensions.capability.filesystem.detail"},service:{icon:"terminal",titleKey:"settings.extensions.capability.service",detailKey:"settings.extensions.capability.service.detail"},network:{icon:"plug",titleKey:"settings.extensions.capability.network",detailKey:"settings.extensions.capability.network.detail"}},rv=t=>{const e=tt.c(73),{guest:a,busy:n,onApprove:r,onDecline:i,onDismiss:l}=t,{t:d}=Qe();let c;e[0]!==a?.capabilities.requested?(c=a?.capabilities.requested??[],e[0]=a?.capabilities.requested,e[1]=c):c=e[1];const h=c;let g;e[2]!==a?.filesystem?(g=a?.filesystem??[],e[2]=a?.filesystem,e[3]=g):g=e[3];const f=g;let m;e[4]!==a?.service?.permissions?.exec?(m=a?.service?.permissions?.exec??[],e[4]=a?.service?.permissions?.exec,e[5]=m):m=e[5];const u=m;let v;e[6]!==a?.service?.permissions?.sockets?(v=a?.service?.permissions?.sockets??[],e[6]=a?.service?.permissions?.sockets,e[7]=v):v=e[7];const w=v,b=a?.service;let k;e[8]!==b?(k=zc(b,"browser"),e[8]=b,e[9]=k):k=e[9];const p=k,S=a?.integration?.apiOrigin??null,N=a!==null;let I;e[10]!==n||e[11]!==l?(I=se=>{!se&&!n&&l()},e[10]=n,e[11]=l,e[12]=I):I=e[12];const y=a?.name??"";let T;e[13]!==d||e[14]!==y?(T=d("settings.extensions.dialog.approveTitle",{name:y}),e[13]=d,e[14]=y,e[15]=T):T=e[15];let x;e[16]!==T?(x=s.jsx(Ht,{children:T}),e[16]=T,e[17]=x):x=e[17];const A=a?.name??"",R=a?.version?`v${a.version}`:"";let P;e[18]!==d||e[19]!==A||e[20]!==R?(P=d("settings.extensions.dialog.approveDescription",{name:A,version:R}),e[18]=d,e[19]=A,e[20]=R,e[21]=P):P=e[21];let D;e[22]!==P?(D=s.jsx(qt,{children:P}),e[22]=P,e[23]=D):D=e[23];let F;e[24]!==x||e[25]!==D?(F=s.jsxs(Vt,{children:[x,D]}),e[24]=x,e[25]=D,e[26]=F):F=e[26];let O;if(e[27]!==S||e[28]!==f||e[29]!==p||e[30]!==h||e[31]!==u||e[32]!==w||e[33]!==d){let se;e[35]!==S||e[36]!==f||e[37]!==p||e[38]!==u||e[39]!==w||e[40]!==d?(se=B=>{const ne=iv[B];return s.jsxs("li",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-muted)]",children:s.jsx(_,{name:ne.icon,className:"size-4 text-foreground"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground",children:d(ne.titleKey)}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:d(ne.detailKey)}),B==="filesystem"&&f.length>0?s.jsx("ul",{className:"mt-1 space-y-0.5",children:f.map(ov)}):null,B==="network"&&S?s.jsxs("p",{className:"typography-meta mt-1 text-foreground",children:[d("settings.extensions.capability.service.sockets")," ",s.jsx("span",{className:"break-all font-mono",children:S})]}):null,B==="service"&&u.length>0?s.jsxs("p",{className:"typography-meta mt-1 text-foreground",children:[d("settings.extensions.capability.service.runs")," ",s.jsx("span",{className:"break-all font-mono",children:u.join(", ")})]}):null,B==="service"&&w.length>0?s.jsxs("p",{className:"typography-meta mt-0.5 text-foreground",children:[d("settings.extensions.capability.service.sockets")," ",s.jsx("span",{className:"break-all font-mono",children:w.join(", ")})]}):null,B==="service"&&p?s.jsx("p",{className:"typography-meta mt-0.5 text-foreground",children:d("settings.extensions.capability.service.providesBrowser")}):null]})]},B)},e[35]=S,e[36]=f,e[37]=p,e[38]=u,e[39]=w,e[40]=d,e[41]=se):se=e[41],O=h.map(se),e[27]=S,e[28]=f,e[29]=p,e[30]=h,e[31]=u,e[32]=w,e[33]=d,e[34]=O}else O=e[34];let C;e[42]!==O?(C=s.jsx("ul",{className:"space-y-3",children:O}),e[42]=O,e[43]=C):C=e[43];let M;e[44]!==a||e[45]!==i?(M=()=>a&&i(a),e[44]=a,e[45]=i,e[46]=M):M=e[46];let U;e[47]!==d?(U=d("settings.extensions.dialog.decline"),e[47]=d,e[48]=U):U=e[48];let L;e[49]!==n||e[50]!==M||e[51]!==U?(L=s.jsx(G,{size:"sm",variant:"ghost",disabled:n,onClick:M,children:U}),e[49]=n,e[50]=M,e[51]=U,e[52]=L):L=e[52];let W;e[53]!==a||e[54]!==r?(W=()=>a&&r(a),e[53]=a,e[54]=r,e[55]=W):W=e[55];let X;e[56]!==d?(X=d("settings.extensions.dialog.approve"),e[56]=d,e[57]=X):X=e[57];let J;e[58]!==n||e[59]!==W||e[60]!==X?(J=s.jsx(G,{size:"sm",disabled:n,onClick:W,children:X}),e[58]=n,e[59]=W,e[60]=X,e[61]=J):J=e[61];let q;e[62]!==L||e[63]!==J?(q=s.jsxs(as,{children:[L,J]}),e[62]=L,e[63]=J,e[64]=q):q=e[64];let z;e[65]!==F||e[66]!==C||e[67]!==q?(z=s.jsxs(_t,{className:"max-w-md",children:[F,C,q]}),e[65]=F,e[66]=C,e[67]=q,e[68]=z):z=e[68];let H;return e[69]!==z||e[70]!==N||e[71]!==I?(H=s.jsx(Ut,{open:N,onOpenChange:I,children:z}),e[69]=z,e[70]=N,e[71]=I,e[72]=H):H=e[72],H};function ov(t){return s.jsx("li",{className:"typography-meta break-all font-mono text-foreground",children:t},t)}const lv=t=>{if(t.source!=="git"||!t.origin?.url)return null;const e=t.origin.url.trim(),a=/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?([A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+):([^\s]+)$/.exec(e);try{const n=new URL(a?`ssh://${a[1]}/${a[2]}`:e);if(n.protocol!=="https:"&&n.protocol!=="ssh:")return null;const r=n.protocol==="ssh:"?new URL(`https://${n.hostname}${n.pathname}`):n;return r.username="",r.password="",r.search="",r.hash="",r.pathname=r.pathname.replace(/\/+$/,"").replace(/\.git$/i,""),r.pathname==="/"?null:r.href}catch{return null}},cv=Ts({error:Ao(["invalid-path","invalid-url","not-found","invalid-manifest","id-taken","already-installed","missing-build","host-too-old","bundled","reserved-id","clone-failed","extract-failed","too-large"]),required:Mt().trim().min(1).max(64).optional(),id:Mt().trim().min(1).max(128).optional()}),dv=t=>{const e=t.trim();if(!e)return{ok:!1,code:"invalid-path"};if(e.slice(0,8).toLowerCase()==="https://")return{ok:!0,request:{url:e}};if(e.slice(0,6).toLowerCase()==="ssh://"||/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+:[^\s]+$/.test(e))return{ok:!0,request:{url:e}};const a=/^[a-zA-Z]:[\\/]/.test(e);return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!a?{ok:!1,code:"invalid-url"}:e.startsWith("/")||a||e.startsWith("\\\\")?{ok:!0,request:{path:e}}:{ok:!1,code:"invalid-path"}},jd=async t=>{try{const e=cv.safeParse(JSON.parse(await t.text()));return e.success?e.data.error==="host-too-old"&&e.data.required&&e.data.id?{code:"host-too-old",required:e.data.required,id:e.data.id}:e.data.error==="host-too-old"&&e.data.required?{code:"host-too-old",required:e.data.required}:e.data.id?{code:e.data.error,id:e.data.id}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},wd=async(t,e)=>{if(!t.ok)return{ok:!1,...await jd(t),diagnostic:{method:"POST",path:e,kind:"http",status:t.status}};const a=await t.text().catch(()=>null),n=a===null?null:Uc(a);return n?{ok:!0,guest:n,replaced:t.status===200}:{ok:!1,code:"failed",diagnostic:{method:"POST",path:e,kind:"invalid-response",status:t.status}}},uv=async(t,e={})=>{const a=dv(t);if(!a.ok)return a;const n={...a.request};e.replace&&(n.replace=!0),"url"in n&&e.gitIdentityId&&(n.gitIdentityId=e.gitIdentityId);try{const r=await St("/api/guests",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return await wd(r,"/api/guests")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests",kind:"network"}}}},mv=async(t,e={})=>{try{const a=await St("/api/guests/upload",{method:"POST",query:{replace:e.replace?"true":void 0,name:t.name||void 0},headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},body:t});return await wd(a,"/api/guests/upload")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests/upload",kind:"network"}}}},pv=async t=>{try{const e=await St(`/api/guests/${t}`,{method:"DELETE"});return e.status===204?{ok:!0}:{ok:!1,code:(await jd(e)).code}}catch{return{ok:!1,code:"failed"}}},gv=async(t,e)=>{try{return(await St(`/api/guests/${t}/enabled`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok}catch{return!1}},hv=async(t,e)=>{try{return(await St(`/api/guests/${t}/capabilities`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({granted:e})})).ok}catch{return!1}},Hr=(t,e)=>{const a=`${t.method} ${t.path}`;return t.kind==="network"?`${a}: ${e("settings.extensions.request.noResponse")}`:t.kind==="invalid-response"?`${a}: ${e("settings.extensions.request.invalidResponse",{status:t.status})}`:`${a}: HTTP ${t.status}`},fv=Ts({updates:Un(Mt().min(1),xu)}),xv=Ts({error:Ao(["not-git","clone-failed","invalid-manifest","missing-build","host-too-old","swap-failed","not-found"]),required:Mt().trim().min(1).max(64).optional()}),ac=async t=>{try{const e=await St("/api/guests/updates/check",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({force:t})});if(!e.ok)return{ok:!1};const a=fv.safeParse(JSON.parse(await e.text()));return a.success?{ok:!0,updates:a.data.updates}:{ok:!1}}catch{return{ok:!1}}},bv=async t=>{try{const e=xv.safeParse(JSON.parse(await t.text()));return e.success?e.data.required?{code:e.data.error,required:e.data.required}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},vv=async t=>{try{const e=await St(`/api/guests/${t}/update`,{method:"POST",headers:{Accept:"application/json"}});if(!e.ok){const n=await bv(e);return n.required?{ok:!1,code:n.code,required:n.required}:{ok:!1,code:n.code}}const a=Uc(await e.text());return a?{ok:!0,guest:a}:{ok:!1,code:"failed"}}catch{return{ok:!1,code:"failed"}}},yv=t=>t==="invalid-path"?"settings.extensions.toast.invalidPath":t==="invalid-url"?"settings.extensions.toast.invalidUrl":t==="not-found"?"settings.extensions.toast.notFound":t==="invalid-manifest"?"settings.extensions.toast.invalidManifest":t==="reserved-id"?"settings.extensions.toast.reservedId":t==="id-taken"?"settings.extensions.toast.idTaken":t==="already-installed"?"settings.extensions.toast.alreadyInstalled":t==="missing-build"?"settings.extensions.toast.missingBuild":t==="host-too-old"?"settings.extensions.toast.hostTooOld":t==="clone-failed"?"settings.extensions.toast.cloneFailed":t==="extract-failed"?"settings.extensions.toast.extractFailed":t==="too-large"?"settings.extensions.toast.zipTooLarge":"settings.extensions.toast.failed",ic=t=>t.name.toLowerCase().endsWith(".zip"),jv=t=>t==="not-git"?"settings.extensions.toast.notGit":t==="clone-failed"?"settings.extensions.toast.cloneFailed":t==="invalid-manifest"?"settings.extensions.toast.invalidManifest":t==="missing-build"?"settings.extensions.toast.missingBuild":t==="swap-failed"?"settings.extensions.toast.swapFailed":t==="not-found"?"settings.extensions.toast.notFound":"settings.extensions.toast.updateFailed",wv=t=>t==="path"?"settings.extensions.source.path":t==="zip"?"settings.extensions.source.zip":t==="git"?"settings.extensions.source.git":"settings.extensions.source.bundled",kv=t=>{const e=(t.service?.socketBindings??[]).map(r=>r.resolved?`${r.id}=${r.resolved}`:`${r.id}?`),a=(t.service?.permissions?.sockets??[]).filter(r=>!(t.service?.socketBindings??[]).some(i=>i.id===r));return[...e,...a,...t.service?.permissions?.exec??[]].join(", ")},Nv=t=>{const e=tt.c(27),{guest:a,binding:n,busy:r,onSaved:i}=t,{t:l}=Qe(),[d,c]=o.useState(n.override??n.resolved??""),[h,g]=o.useState(!1),[f,m]=o.useState(!n.resolved);let u;e[0]!==n.override||e[1]!==n.resolved?(u=()=>{c(n.override??n.resolved??""),n.resolved||m(!0)},e[0]=n.override,e[1]=n.resolved,e[2]=u):u=e[2];let v;e[3]!==n.id||e[4]!==n.override||e[5]!==n.resolved?(v=[n.id,n.override,n.resolved],e[3]=n.id,e[4]=n.override,e[5]=n.resolved,e[6]=v):v=e[6],o.useEffect(u,v);let w;e[7]!==n.id||e[8]!==a.id||e[9]!==a.name||e[10]!==i||e[11]!==l?(w=async N=>{g(!0);const I=await ep(a.id,n.id,N);if(g(!1),!I){$.error(l("settings.extensions.toast.socketSaveFailed"));return}$.success(l("settings.extensions.toast.socketSaved",{name:a.name})),m(!1),await i()},e[7]=n.id,e[8]=a.id,e[9]=a.name,e[10]=i,e[11]=l,e[12]=w):w=e[12];const b=w;let k;e[13]!==n.override||e[14]!==n.resolved?(k=()=>{c(n.override??n.resolved??""),n.resolved&&m(!1)},e[13]=n.override,e[14]=n.resolved,e[15]=k):k=e[15];const p=k;let S;return e[16]!==n.id||e[17]!==n.override||e[18]!==n.resolved||e[19]!==r||e[20]!==p||e[21]!==f||e[22]!==b||e[23]!==h||e[24]!==l||e[25]!==d?(S=s.jsx("div",{className:"space-y-1",children:f?s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(He,{value:d,onChange:N=>c(N.target.value),placeholder:l("settings.extensions.service.socket.path",{id:n.id}),"aria-label":l("settings.extensions.service.socket.path.aria",{id:n.id}),className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:r||h,autoFocus:!0}),s.jsx(G,{type:"button",variant:"ghost",size:"xs",disabled:r||h,"aria-label":l("settings.extensions.service.socket.save.aria",{id:n.id}),onClick:()=>{b(d.trim()||null)},children:l("settings.extensions.service.socket.save")}),n.override?s.jsx(G,{type:"button",variant:"ghost",size:"xs",disabled:r||h,"aria-label":l("settings.extensions.service.socket.clear.aria",{id:n.id}),onClick:()=>{b(null)},children:l("settings.extensions.service.socket.clear")}):null,n.resolved?s.jsx(G,{type:"button",variant:"ghost",size:"xs",disabled:r||h,"aria-label":l("settings.extensions.service.socket.cancel.aria",{id:n.id}),onClick:p,children:l("settings.extensions.service.socket.cancel")}):null]}):s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx("div",{className:"typography-meta min-w-0 flex-1 truncate text-muted-foreground",children:n.resolved?l("settings.extensions.service.socket.resolved",{path:n.resolved}):l("settings.extensions.service.socket.unresolved")}),s.jsx(G,{type:"button",variant:"ghost",size:"icon",className:us,disabled:r||h,"aria-label":l("settings.extensions.service.socket.edit.aria",{id:n.id}),onClick:()=>m(!0),children:s.jsx(_,{name:"pencil",className:"h-3.5 w-3.5"})})]})}),e[16]=n.id,e[17]=n.override,e[18]=n.resolved,e[19]=r,e[20]=p,e[21]=f,e[22]=b,e[23]=h,e[24]=l,e[25]=d,e[26]=S):S=e[26],S},Sv=t=>{const e=tt.c(143),{guest:a,busy:n,onReview:r,onRemove:i,onSetEnabled:l,onUpdate:d}=t,{t:c}=Qe(),[h,g]=o.useState(!1),f=a.enabled!==!1;let m;e[0]!==a?(m=so(a),e[0]=a,e[1]=m):m=e[1];const u=m;let v,w,b,k,p,S,N,I,y,T,x,A,R,P;if(e[2]!==f||e[3]!==a||e[4]!==u||e[5]!==h||e[6]!==c){const H=kv(a);b=!!(a.source&&a.source!=="bundled");const se=a.source==="bundled";let B;e[21]!==a?(B=lv(a),e[21]=a,e[22]=B):B=e[22],k=B,P=a.source==="git"?a.update:void 0;let ne;e[23]!==a.icon||e[24]!==a.id?(ne=Fc(a.id,a.icon,Hc().authenticatedAsset),e[23]=a.icon,e[24]=a.id,e[25]=ne):ne=e[25];const K=ne;let Z;e[26]!==se||e[27]!==a.source||e[28]!==c?(Z=se?null:c(wv(a.source)),e[26]=se,e[27]=a.source,e[28]=c,e[29]=Z):Z=e[29];const oe=a.version?`v${a.version}`:null;let ue;e[30]!==a.entry||e[31]!==c?(ue=a.entry?null:c("settings.extensions.source.noPanel"),e[30]=a.entry,e[31]=c,e[32]=ue):ue=e[32];let de;e[33]!==Z||e[34]!==oe||e[35]!==ue?(de=[Z,oe,ue].filter(Boolean),e[33]=Z,e[34]=oe,e[35]=ue,e[36]=de):de=e[36];const ce=de.join(" · "),Se=a.path||a.id;let re;e[37]!==f||e[38]!==u||e[39]!==c?(re=c(u?"settings.extensions.status.needsApproval":f?"settings.extensions.status.enabled":"settings.extensions.status.disabled"),e[37]=f,e[38]=u,e[39]=c,e[40]=re):re=e[40];const ve=re,ie=u?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":f?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground";w=Cn,R=h,p=g,x="overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]";let me;e[41]!==a.icon?(me=Lc(a.icon),e[41]=a.icon,e[42]=me):me=e[42];let ke;e[43]!==K||e[44]!==me?(ke=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(Oc,{icon:me,iconSrc:K,className:"size-5 text-foreground"})}),e[43]=K,e[44]=me,e[45]=ke):ke=e[45];let Ae;e[46]!==a.name?(Ae=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e[46]=a.name,e[47]=Ae):Ae=e[47];let pe;e[48]!==ce?(pe=s.jsx("p",{className:"mt-0.5 truncate text-xs leading-snug text-muted-foreground",children:ce}),e[48]=ce,e[49]=pe):pe=e[49];let Le;e[50]!==Ae||e[51]!==pe?(Le=s.jsxs("div",{className:"min-w-0 flex-1",children:[Ae,pe]}),e[50]=Ae,e[51]=pe,e[52]=Le):Le=e[52];let Ve;e[53]!==se||e[54]!==c?(Ve=se?s.jsx("span",{className:"shrink-0 rounded-full border border-[var(--interactive-border)] px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:c("settings.extensions.source.bundled")}):null,e[53]=se,e[54]=c,e[55]=Ve):Ve=e[55];let ye;e[56]!==c||e[57]!==P?(ye=P?s.jsx("span",{className:"max-w-40 shrink-0 truncate rounded-full bg-[var(--status-info)]/15 px-2 py-0.5 text-[10px] font-medium text-[var(--status-info)]",children:c("settings.extensions.update.badge",{version:P.version})}):null,e[56]=c,e[57]=P,e[58]=ye):ye=e[58];let Te;e[59]!==ie?(Te=Pe("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",ie),e[59]=ie,e[60]=Te):Te=e[60];let ee;e[61]!==ve||e[62]!==Te?(ee=s.jsx("span",{"aria-live":"polite",className:Te,children:ve}),e[61]=ve,e[62]=Te,e[63]=ee):ee=e[63];const ae=h&&"rotate-180";let fe;e[64]!==ae?(fe=Pe("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",ae),e[64]=ae,e[65]=fe):fe=e[65];let je;e[66]!==fe?(je=s.jsx(_,{name:"arrow-down-s",className:fe}),e[66]=fe,e[67]=je):je=e[67],e[68]!==ke||e[69]!==Le||e[70]!==Ve||e[71]!==ye||e[72]!==ee||e[73]!==je?(A=s.jsxs(In,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[ke,Le,Ve,ye,ee,je]}),e[68]=ke,e[69]=Le,e[70]=Ve,e[71]=ye,e[72]=ee,e[73]=je,e[74]=A):A=e[74],v=Pn,T="border-t border-[var(--interactive-border)] px-4 py-4",S="space-y-3",e[75]!==Se?(N=s.jsx("p",{className:"typography-meta truncate font-mono text-muted-foreground",title:Se,children:Se}),e[75]=Se,e[76]=N):N=e[76],e[77]!==se||e[78]!==c?(I=se?s.jsx("p",{className:"typography-meta text-muted-foreground",children:c("settings.extensions.builtIn.info")}):null,e[77]=se,e[78]=c,e[79]=I):I=e[79],y=H?s.jsx("p",{className:"typography-meta truncate text-muted-foreground",children:c("settings.extensions.service.permissions",{list:H})}):null,e[2]=f,e[3]=a,e[4]=u,e[5]=h,e[6]=c,e[7]=v,e[8]=w,e[9]=b,e[10]=k,e[11]=p,e[12]=S,e[13]=N,e[14]=I,e[15]=y,e[16]=T,e[17]=x,e[18]=A,e[19]=R,e[20]=P}else v=e[7],w=e[8],b=e[9],k=e[10],p=e[11],S=e[12],N=e[13],I=e[14],y=e[15],T=e[16],x=e[17],A=e[18],R=e[19],P=e[20];let D;e[80]!==a.service||e[81]!==c?(D=a.service?s.jsx("p",{className:"typography-meta text-muted-foreground",children:c("settings.extensions.service.warning")}):null,e[80]=a.service,e[81]=c,e[82]=D):D=e[82];let F;e[83]!==n||e[84]!==f||e[85]!==a?(F=f?(a.service?.socketBindings??[]).map(H=>s.jsx(Nv,{guest:a,binding:H,busy:n,onSaved:Kn},H.id)):null,e[83]=n,e[84]=f,e[85]=a,e[86]=F):F=e[86];let O;e[87]!==n||e[88]!==a||e[89]!==d||e[90]!==c||e[91]!==P?(O=P?s.jsx(G,{type:"button",size:"sm",disabled:n,"aria-label":c("settings.extensions.update.action.aria",{name:a.name,version:P.version}),onClick:()=>{d(a)},children:c("settings.extensions.update.action")}):null,e[87]=n,e[88]=a,e[89]=d,e[90]=c,e[91]=P,e[92]=O):O=e[92];let C;e[93]!==n||e[94]!==a||e[95]!==u||e[96]!==r||e[97]!==c?(C=u?s.jsx(G,{type:"button",size:"sm",disabled:n,"aria-label":c("settings.extensions.review.aria",{name:a.name}),onClick:()=>r(a),children:c("settings.extensions.review")}):null,e[93]=n,e[94]=a,e[95]=u,e[96]=r,e[97]=c,e[98]=C):C=e[98];let M;e[99]!==n||e[100]!==f||e[101]!==a.id||e[102]!==a.name||e[103]!==l||e[104]!==c?(M=f?s.jsx(G,{type:"button",size:"sm",variant:"outline",disabled:n,"aria-label":c("settings.extensions.actions.disable.aria",{name:a.name}),onClick:()=>{l(a.id,a.name,!1)},children:c("settings.extensions.actions.disable")}):s.jsx(G,{type:"button",size:"sm",disabled:n,"aria-label":c("settings.extensions.actions.enable.aria",{name:a.name}),onClick:()=>{l(a.id,a.name,!0)},children:c("settings.extensions.actions.enable")}),e[99]=n,e[100]=f,e[101]=a.id,e[102]=a.name,e[103]=l,e[104]=c,e[105]=M):M=e[105];let U;e[106]!==n||e[107]!==b||e[108]!==a.id||e[109]!==a.name||e[110]!==i||e[111]!==c?(U=b?s.jsx(G,{type:"button",size:"sm",variant:"destructive",disabled:n,"aria-label":c("settings.extensions.remove.aria",{name:a.name}),onClick:()=>{i(a.id,a.name)},children:c("settings.extensions.remove")}):null,e[106]=n,e[107]=b,e[108]=a.id,e[109]=a.name,e[110]=i,e[111]=c,e[112]=U):U=e[112];let L;e[113]!==k||e[114]!==c?(L=k?s.jsxs(G,{type:"button",size:"sm",variant:"outline",className:"ml-auto",onClick:()=>{jn(k)},children:[s.jsx(_,{name:"external-link",className:"size-4"}),c("settings.extensions.actions.openSource")]}):null,e[113]=k,e[114]=c,e[115]=L):L=e[115];let W;e[116]!==O||e[117]!==C||e[118]!==M||e[119]!==U||e[120]!==L?(W=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[O,C,M,U,L]}),e[116]=O,e[117]=C,e[118]=M,e[119]=U,e[120]=L,e[121]=W):W=e[121];let X;e[122]!==D||e[123]!==F||e[124]!==W||e[125]!==S||e[126]!==N||e[127]!==I||e[128]!==y?(X=s.jsxs("div",{className:S,children:[N,I,y,D,F,W]}),e[122]=D,e[123]=F,e[124]=W,e[125]=S,e[126]=N,e[127]=I,e[128]=y,e[129]=X):X=e[129];let J;e[130]!==v||e[131]!==X||e[132]!==T?(J=s.jsx(v,{className:T,children:X}),e[130]=v,e[131]=X,e[132]=T,e[133]=J):J=e[133];let q;e[134]!==J||e[135]!==x||e[136]!==A?(q=s.jsxs("div",{className:x,children:[A,J]}),e[134]=J,e[135]=x,e[136]=A,e[137]=q):q=e[137];let z;return e[138]!==w||e[139]!==p||e[140]!==q||e[141]!==R?(z=s.jsx(w,{open:R,onOpenChange:p,children:q}),e[138]=w,e[139]=p,e[140]=q,e[141]=R,e[142]=z):z=e[142],z},Cv=()=>{const t=tt.c(174),{t:e}=Qe(),a=qs(Iv),n=qs(Pv),r=qs(Av),i=qs(Tv),[l,d]=o.useState(null),[c,h]=o.useState(!1),[g,f]=o.useState("global"),m=n==="unsupported",[u,v]=o.useState(""),[w,b]=o.useState(!1),[k,p]=o.useState(!1),S=o.useRef(!1),[N,I]=o.useState(null),[y,T]=o.useState(null),[x,A]=o.useState(!1),R=o.useRef(0),P=o.useRef(null);let D;t[0]===Symbol.for("react.memo_cache_sentinel")?(D=dm(),t[0]=D):D=t[0];const F=D;let O;t[1]===Symbol.for("react.memo_cache_sentinel")?(O=[],t[1]=O):O=t[1],o.useEffect(Ev,O);let C,M;t[2]!==i||t[3]!==m?(C=()=>{let Ie=!1;if(d(null),h(!1),f("global"),I(null),T(null),S.current=!1,!m)return Promise.all([bu(),vu()]).then(Be=>{const[wt,Pt]=Be;Ie||d({runtimeKey:i,profiles:wt,global:Pt})}).catch(()=>{Ie||h(!0)}),()=>{Ie=!0}},M=[i,m],t[2]=i,t[3]=m,t[4]=C,t[5]=M):(C=t[4],M=t[5]),o.useEffect(C,M);const U=l?.runtimeKey===i?l:null;let L;t[6]!==e?(L=e("settings.gitIdentities.editor.title.globalIdentity"),t[6]=e,t[7]=L):L=t[7];const W=U?.global?.userName??"",X=U?.global?.userEmail??"";let J;t[8]!==L||t[9]!==W||t[10]!==X?(J={id:"global",name:L,userName:W,userEmail:X,icon:"fingerprint",color:"info"},t[8]=L,t[9]=W,t[10]=X,t[11]=J):J=t[11];let q;t[12]!==U?.profiles||t[13]!==J?(q=[J,...U?.profiles.filter(Dv)??[]],t[12]=U?.profiles,t[13]=J,t[14]=q):q=t[14];const z=q;let H;t[15]!==z||t[16]!==g?(H=z.find(Ie=>Ie.id===g)??z[0],t[15]=z,t[16]=g,t[17]=H):H=t[17];const se=H;let B,ne;t[18]!==n?(B=()=>{if(n!=="ready"||S.current)return;S.current=!0;const Ie=qs.getState().runtimeKey;ac(!1).then(Be=>{Be.ok&&qs.getState().applyUpdates(Be.updates,Ie)})},ne=[n],t[18]=n,t[19]=B,t[20]=ne):(B=t[19],ne=t[20]),o.useEffect(B,ne);let K;t[21]!==e?(K=async()=>{p(!0);const Ie=qs.getState().runtimeKey,Be=await ac(!0);if(p(!1),!Be.ok){$.error(e("settings.extensions.toast.checkFailed"));return}qs.getState().applyUpdates(Be.updates,Ie),Object.keys(Be.updates).length===0&&$.success(e("settings.extensions.toast.upToDate"))},t[21]=e,t[22]=K):K=t[22];const Z=K;let oe;t[23]!==e?(oe=async Ie=>{b(!0);const Be=await vv(Ie.id);if(b(!1),!Be.ok){$.error(Be.code==="host-too-old"&&Be.required?e("settings.extensions.toast.hostTooOld",{version:Be.required}):e(jv(Be.code)));return}Rr(Ie.id),$.success(e("settings.extensions.toast.updated",{name:Be.guest.name,version:Be.guest.version??""})),await Kn(),so(Be.guest)&&T(Be.guest)},t[23]=e,t[24]=oe):oe=t[24];const ue=oe;let de;if(t[25]!==a||t[26]!==e){const Ie=async(Be,wt,Pt)=>{const Qt=Pt===void 0?{}:Pt;if(!Be.ok){if(Qt.allowConflictDialog!==!1&&(Be.code==="id-taken"||Be.code==="already-installed")){const Xt=Be.id?a.find(ss=>ss.id===Be.id):void 0;return I({source:wt,name:Xt?.name??Be.id??(wt.kind==="file"?wt.file.name:wt.input)}),!1}return Be.code==="host-too-old"?$.error(Be.required?e("settings.extensions.toast.hostTooOld",{version:Be.required}):e("settings.extensions.toast.failed"),{description:Be.diagnostic?Hr(Be.diagnostic,e):void 0}):$.error(e(yv(Be.code)),{description:Be.diagnostic?Hr(Be.diagnostic,e):void 0}),!1}return v(""),I(null),$.success(Be.replaced?e("settings.extensions.toast.reinstalled",{name:Be.guest.name}):e("settings.extensions.toast.added",{name:Be.guest.name})),await Kn(),so(Be.guest)&&T(Be.guest),!0};de=async(Be,wt)=>{const Pt=wt===void 0?{}:wt,Qt=wn();Be.kind==="input"&&v(Be.input),b(!0);const Xt=Be.kind==="file"?await mv(Be.file,Pt):await uv(Be.input,{...Pt,gitIdentityId:Be.gitIdentityId});b(!1),wn()===Qt&&await Ie(Xt,Be,{allowConflictDialog:!Pt.replace})},t[25]=a,t[26]=e,t[27]=de}else de=t[27];const ce=de;let Se;t[28]!==u||t[29]!==ce||t[30]!==se||t[31]!==e?(Se=async()=>{const Ie=u.trim();if(!Ie){$.error(e("settings.extensions.toast.invalidPath"));return}await ce({kind:"input",input:Ie,gitIdentityId:se.id})},t[28]=u,t[29]=ce,t[30]=se,t[31]=e,t[32]=Se):Se=t[32];const re=Se;let ve;t[33]!==ce?(ve=async()=>{if(!F)return;const Ie=await um("");Ie.success&&Ie.path&&await ce({kind:"input",input:Ie.path})},t[33]=ce,t[34]=ve):ve=t[34];const ie=ve;let me;t[35]!==ce?(me=async()=>{if(!F){P.current?.click();return}const Ie=await Co({filters:[{name:"ZIP Archive",extensions:["zip"]}]});Ie.success&&Ie.path&&await ce({kind:"input",input:Ie.path})},t[35]=ce,t[36]=me):me=t[36];const ke=me;let Ae;t[37]!==ce||t[38]!==e?(Ae=async Ie=>{const Be=Ie.target.files?.[0]??null;if(Ie.target.value="",!!Be){if(!ic(Be)){$.error(e("settings.extensions.toast.invalidPath"));return}await ce({kind:"file",file:Be})}},t[37]=ce,t[38]=e,t[39]=Ae):Ae=t[39];const pe=Ae;let Le;t[40]!==w?(Le=Ie=>{w||(Ie.preventDefault(),R.current=R.current+1,A(!0))},t[40]=w,t[41]=Le):Le=t[41];const Ve=Le;let ye;t[42]!==w?(ye=Ie=>{w||(Ie.preventDefault(),Ie.dataTransfer.dropEffect="copy")},t[42]=w,t[43]=ye):ye=t[43];const Te=ye;let ee;t[44]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>{R.current=Math.max(0,R.current-1),R.current===0&&A(!1)},t[44]=ee):ee=t[44];const ae=ee;let fe;t[45]!==w||t[46]!==ce||t[47]!==e?(fe=async Ie=>{if(Ie.preventDefault(),R.current=0,A(!1),w)return;const Be=Ie.dataTransfer.items[0],wt=Be?.getAsFile()??null,Qt=(Be?.webkitGetAsEntry()??null)?.isDirectory===!0,Xt=wt!==null&&!Qt&&ic(wt),ss=wt&&F?mm(wt):null;if(ss&&(Qt||Xt)){await ce({kind:"input",input:ss});return}if(Qt){$.error(e(F?"settings.extensions.toast.invalidPath":"settings.extensions.toast.folderNeedsZip"));return}if(!wt||!Xt){$.error(e("settings.extensions.toast.invalidPath"));return}await ce({kind:"file",file:wt})},t[45]=w,t[46]=ce,t[47]=e,t[48]=fe):fe=t[48];const je=fe;let Re;t[49]!==N||t[50]!==ce?(Re=async()=>{N&&await ce(N.source,{replace:!0})},t[49]=N,t[50]=ce,t[51]=Re):Re=t[51];const Ce=Re;let _e;t[52]!==e?(_e=async(Ie,Be)=>{b(!0);const wt=await pv(Ie);if(b(!1),!wt.ok){$.error(e("settings.extensions.toast.removeFailed"));return}Rr(Ie),$.success(e("settings.extensions.toast.removed",{name:Be})),await Kn()},t[52]=e,t[53]=_e):_e=t[53];const Ke=_e;let Fe;t[54]!==e?(Fe=async Ie=>{b(!0);const Be=await hv(Ie.id,Ie.capabilities.requested);if(b(!1),!Be){$.error(e("settings.extensions.toast.approveFailed"));return}T(null),$.success(e("settings.extensions.toast.approved",{name:Ie.name})),await Kn()},t[54]=e,t[55]=Fe):Fe=t[55];const Me=Fe;let at;t[56]!==Ke?(at=async Ie=>{T(null),await Ke(Ie.id,Ie.name)},t[56]=Ke,t[57]=at):at=t[57];const pt=at;let ot;t[58]!==e?(ot=async(Ie,Be,wt)=>{b(!0);const Pt=await gv(Ie,wt);if(b(!1),!Pt){$.error(e("settings.extensions.toast.enabledFailed"));return}wt||Rr(Ie),$.success(wt?e("settings.extensions.toast.enabled",{name:Be}):e("settings.extensions.toast.disabled",{name:Be})),await Kn()},t[58]=e,t[59]=ot):ot=t[59];const mt=ot;let ht;t[60]!==e?(ht=e("settings.page.extensions.title"),t[60]=e,t[61]=ht):ht=t[61];let Oe;t[62]!==e?(Oe=e("settings.page.extensions.description"),t[62]=e,t[63]=Oe):Oe=t[63];let nt;t[64]!==re||t[65]!==ie||t[66]!==ke||t[67]!==w||t[68]!==x||t[69]!==z||t[70]!==l||t[71]!==c||t[72]!==u||t[73]!==Ve||t[74]!==Te||t[75]!==je||t[76]!==pe||t[77]!==se||t[78]!==e||t[79]!==m?(nt=m?null:s.jsxs(qe,{title:e("settings.extensions.add.action"),info:e("settings.extensions.add.info"),children:[s.jsx(Ft,{label:e("settings.extensions.add.label"),info:e(F?"settings.extensions.add.drop":"settings.extensions.add.drop.zipOnly"),settingsItem:"extensions.add",controlClassName:"w-full max-w-none",children:s.jsxs("div",{className:Pe("relative -m-1 flex min-w-0 flex-1 items-center gap-2 rounded-md border border-dashed border-transparent p-1 transition-colors",x&&"border-primary bg-primary/5"),onDragEnter:Ve,onDragOver:Te,onDragLeave:ae,onDrop:Ie=>{je(Ie)},children:[x?s.jsx("span",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-md bg-background/80 typography-ui-label text-primary",children:e("settings.extensions.add.drop.active")}):null,s.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center",children:[s.jsx(He,{value:u,onChange:Ie=>v(Ie.target.value),onKeyDown:Ie=>{Ie.key==="Enter"&&(Ie.preventDefault(),re())},placeholder:e("settings.extensions.add.placeholder"),"aria-label":e("settings.extensions.add.label"),className:Pe("h-8 min-w-0 flex-1 rounded-md pl-3",F?"pr-14":"pr-8"),disabled:w}),s.jsx("input",{ref:P,type:"file",accept:".zip,application/zip",className:"sr-only",tabIndex:-1,"aria-hidden":"true",onChange:Ie=>{pe(Ie)}}),s.jsxs("div",{className:"absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[F?s.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:e("settings.extensions.add.browseFolder"),"aria-label":e("settings.extensions.add.browseFolder.aria"),disabled:w,onClick:()=>{ie()},children:s.jsx(_,{name:"folder",className:"h-4 w-4"})}):null,s.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:e("settings.extensions.add.browseZip"),"aria-label":e("settings.extensions.add.browseZip.aria"),disabled:w,onClick:()=>{ke()},children:s.jsx(_,{name:"archive",className:"h-4 w-4"})})]})]}),s.jsx("div",{className:"shrink-0","data-settings-item":"extensions.gitIdentity",children:s.jsx(Rm,{activeProfile:se,identities:z,onSelect:Ie=>f(Ie.id),isApplying:w||!l&&!c,iconOnly:!0})}),s.jsxs(G,{type:"button",size:"sm",disabled:w,"aria-label":e("settings.extensions.add.aria"),onClick:()=>{re()},children:[s.jsx(_,{name:"add",className:"h-4 w-4"}),e("settings.extensions.add.action")]})]})}),c?s.jsx("p",{className:"typography-meta text-destructive",children:e("settings.extensions.identity.loadFailed")}):null]}),t[64]=re,t[65]=ie,t[66]=ke,t[67]=w,t[68]=x,t[69]=z,t[70]=l,t[71]=c,t[72]=u,t[73]=Ve,t[74]=Te,t[75]=je,t[76]=pe,t[77]=se,t[78]=e,t[79]=m,t[80]=nt):nt=t[80];let lt;t[81]!==e?(lt=e("settings.extensions.section.installed"),t[81]=e,t[82]=lt):lt=t[82];let we;t[83]!==w||t[84]!==Z||t[85]!==k||t[86]!==n||t[87]!==e||t[88]!==m?(we=m?null:s.jsxs(G,{type:"button",variant:"ghost",size:"sm","data-settings-item":"extensions.updates.check",disabled:w||k||n!=="ready","aria-label":e("settings.extensions.updates.check.aria"),onClick:()=>{Z()},children:[s.jsx(_,{name:"refresh",className:Pe("h-4 w-4",k&&"animate-spin")}),e("settings.extensions.updates.check")]}),t[83]=w,t[84]=Z,t[85]=k,t[86]=n,t[87]=e,t[88]=m,t[89]=we):we=t[89];let Je;t[90]!==r||t[91]!==n||t[92]!==e?(Je=n==="error"||r?s.jsxs("p",{className:"typography-meta whitespace-pre-line text-destructive",children:[e("settings.extensions.toast.loadFailed"),r?`
30
+ ${Hr(r,e)}`:""]}):null,t[90]=r,t[91]=n,t[92]=e,t[93]=Je):Je=t[93];let Ye;t[94]!==e||t[95]!==m?(Ye=m?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.extensions.unsupported")}):null,t[94]=e,t[95]=m,t[96]=Ye):Ye=t[96];let ze;t[97]!==a.length||t[98]!==n||t[99]!==e?(ze=n==="ready"&&a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.extensions.empty")}):null,t[97]=a.length,t[98]=n,t[99]=e,t[100]=ze):ze=t[100];let Ge;if(t[101]!==w||t[102]!==a||t[103]!==Ke||t[104]!==mt||t[105]!==ue){let Ie;t[107]!==w||t[108]!==Ke||t[109]!==mt||t[110]!==ue?(Ie=Be=>s.jsx(Sv,{guest:Be,busy:w,onReview:T,onRemove:Ke,onSetEnabled:mt,onUpdate:ue},Be.id),t[107]=w,t[108]=Ke,t[109]=mt,t[110]=ue,t[111]=Ie):Ie=t[111],Ge=a.map(Ie),t[101]=w,t[102]=a,t[103]=Ke,t[104]=mt,t[105]=ue,t[106]=Ge}else Ge=t[106];let Q;t[112]!==lt||t[113]!==we||t[114]!==Je||t[115]!==Ye||t[116]!==ze||t[117]!==Ge?(Q=s.jsxs(qe,{title:lt,contentClassName:"space-y-3",headerAction:we,children:[Je,Ye,ze,Ge]}),t[112]=lt,t[113]=we,t[114]=Je,t[115]=Ye,t[116]=ze,t[117]=Ge,t[118]=Q):Q=t[118];let Ue;t[119]!==Me?(Ue=Ie=>{Me(Ie)},t[119]=Me,t[120]=Ue):Ue=t[120];let st;t[121]!==pt?(st=Ie=>{pt(Ie)},t[121]=pt,t[122]=st):st=t[122];let dt;t[123]===Symbol.for("react.memo_cache_sentinel")?(dt=()=>T(null),t[123]=dt):dt=t[123];let ct;t[124]!==y||t[125]!==w||t[126]!==Ue||t[127]!==st?(ct=s.jsx(rv,{guest:y,busy:w,onApprove:Ue,onDecline:st,onDismiss:dt}),t[124]=y,t[125]=w,t[126]=Ue,t[127]=st,t[128]=ct):ct=t[128];const ft=N!==null;let kt;t[129]!==w?(kt=Ie=>{!Ie&&!w&&I(null)},t[129]=w,t[130]=kt):kt=t[130];let bt;t[131]!==e?(bt=e("settings.extensions.dialog.reinstallTitle"),t[131]=e,t[132]=bt):bt=t[132];let vt;t[133]!==bt?(vt=s.jsx(Ht,{children:bt}),t[133]=bt,t[134]=vt):vt=t[134];const Xe=N?.name??"";let jt;t[135]!==e||t[136]!==Xe?(jt=e("settings.extensions.dialog.reinstallDescription",{name:Xe}),t[135]=e,t[136]=Xe,t[137]=jt):jt=t[137];let De;t[138]!==jt?(De=s.jsx(qt,{children:jt}),t[138]=jt,t[139]=De):De=t[139];let $e;t[140]!==vt||t[141]!==De?($e=s.jsxs(Vt,{children:[vt,De]}),t[140]=vt,t[141]=De,t[142]=$e):$e=t[142];let Y;t[143]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>I(null),t[143]=Y):Y=t[143];let V;t[144]!==e?(V=e("settings.common.actions.cancel"),t[144]=e,t[145]=V):V=t[145];let be;t[146]!==w||t[147]!==V?(be=s.jsx(G,{size:"sm",variant:"ghost",disabled:w,onClick:Y,children:V}),t[146]=w,t[147]=V,t[148]=be):be=t[148];let ge;t[149]!==Ce?(ge=()=>{Ce()},t[149]=Ce,t[150]=ge):ge=t[150];let Ee;t[151]!==e?(Ee=e("settings.extensions.dialog.reinstall"),t[151]=e,t[152]=Ee):Ee=t[152];let te;t[153]!==w||t[154]!==ge||t[155]!==Ee?(te=s.jsx(G,{size:"sm",disabled:w,onClick:ge,children:Ee}),t[153]=w,t[154]=ge,t[155]=Ee,t[156]=te):te=t[156];let xe;t[157]!==be||t[158]!==te?(xe=s.jsxs(as,{children:[be,te]}),t[157]=be,t[158]=te,t[159]=xe):xe=t[159];let Ze;t[160]!==$e||t[161]!==xe?(Ze=s.jsxs(_t,{className:"max-w-md",children:[$e,xe]}),t[160]=$e,t[161]=xe,t[162]=Ze):Ze=t[162];let Nt;t[163]!==ft||t[164]!==kt||t[165]!==Ze?(Nt=s.jsx(Ut,{open:ft,onOpenChange:kt,children:Ze}),t[163]=ft,t[164]=kt,t[165]=Ze,t[166]=Nt):Nt=t[166];let Lt;return t[167]!==ht||t[168]!==Oe||t[169]!==nt||t[170]!==Q||t[171]!==ct||t[172]!==Nt?(Lt=s.jsxs(ts,{title:ht,description:Oe,children:[nt,Q,ct,Nt]}),t[167]=ht,t[168]=Oe,t[169]=nt,t[170]=Q,t[171]=ct,t[172]=Nt,t[173]=Lt):Lt=t[173],Lt};function Iv(t){return t.guests}function Pv(t){return t.status}function Av(t){return t.failure}function Tv(t){return t.runtimeKey}function Ev(){Kn()}function Dv(t){return t.id!=="global"}const $s=ia,Mv=t=>{const e=t.kind==="dark"||t.kind==="high-contrast",a=yu(e),n=(ke,Ae)=>t.colors[ke]??Ae,r=ke=>ke!=="transparent"&&(Hs(ke,"#000000")!==1||Hs(ke,"#ffffff")!==1),i=(ke,Ae)=>{const pe=n(ke,Ae);return r(pe)?pe:Ae},l=n("chat.list.background",n("editor.background",a.colors.surface.background)),d=n("interactive-session.foreground",n("foreground",n("editor.foreground",a.colors.surface.foreground))),h=[["editorWidget.background","editorWidget.foreground"],["dropdown.background","dropdown.foreground"],["input.background","input.foreground"]].find(([ke])=>t.colors[ke]),g=h?n(h[0],a.colors.surface.elevated):a.colors.surface.elevated,f=aa(d,g,l),m=h?n(h[1],f):f,u=n("sideBar.background",n("panel.background",a.colors.surface.muted)),v=n("descriptionForeground",n("input.placeholderForeground",a.colors.surface.mutedForeground)),w=n("textBlockQuote.background",u),b=a.colors.surface.overlay,k=n("button.background",n("textLink.foreground",a.colors.primary.base)),p=n("button.hoverBackground",k),S=t.colors["button.background"]?n("button.foreground",Rs(k,l)):Rs(k,l),N=$s(k,.5),y=[t.kind==="high-contrast"?n("contrastBorder",""):"",n("widget.border",""),n("input.border",""),n("panel.border",""),n("sideBar.border",""),n("editorWidget.border",""),n("contrastBorder","")].find(ke=>ke&&r(ke))||$s(d,e?.25:.2),T=n("toolbar.hoverBackground",n("list.hoverBackground",a.colors.interactive.hover)),x=n("toolbar.activeBackground",T),R=[["list.activeSelectionBackground","list.activeSelectionForeground"],["menu.selectionBackground","menu.selectionForeground"],["editor.selectionBackground","editor.selectionForeground"]].filter(([ke])=>t.colors[ke]),P=R.find(([ke])=>[l,u,g].every(Ae=>{const pe=Hs(n(ke,""),Ae,l);return pe===null||pe>1.01}))??R[0],D=P?n(P[0],a.colors.interactive.selection):a.colors.interactive.selection,F=P?n(P[1],d):d,O=n("focusBorder",n("inputOption.activeBorder",k)),C=O,M=n("editorCursor.foreground",a.colors.interactive.cursor),U=n("editorError.foreground",n("testing.iconFailed",a.colors.status.error)),L=i("editorError.background",$s(U,e?.16:.12)),W=n("problemsWarningIcon.foreground",n("notificationsWarningIcon.foreground",n("editorWarning.foreground",a.colors.status.warning))),X=i("editorWarning.background",$s(W,e?.16:.12)),J=n("testing.iconPassed",n("gitDecoration.addedResourceForeground",a.colors.status.success)),q=$s(J,e?.16:.12),z=n("problemsInfoIcon.foreground",n("editorInfo.foreground",a.colors.status.info)),H=i("editorInfo.background",$s(z,e?.16:.12)),se=n("editorLineNumber.foreground",v),B=n("textPreformat.foreground",n("terminal.ansiGreen",a.colors.syntax.base.string)),ne=n("terminal.ansiBlue",k),K=n("terminal.ansiYellow",a.colors.syntax.base.number),Z=n("terminal.ansiCyan",a.colors.syntax.base.function),oe=n("terminal.ansiMagenta",d),ue=n("terminal.ansiYellow",a.colors.syntax.base.type),de=n("chat.requestBorder",y),ce=n("diffEditor.insertedLineBackground",n("diffEditor.insertedTextBackground",q)),Se=n("diffEditor.removedLineBackground",n("diffEditor.removedTextBackground",L)),re=n("chat.linesAddedForeground",n("gitDecoration.addedResourceForeground",J)),ve=n("chat.linesRemovedForeground",n("gitDecoration.deletedResourceForeground",U)),ie=n("gitDecoration.modifiedResourceForeground",z),me=n("chat.requestBubbleBackground",n("chat.requestBackground",g));return{...a,metadata:{...a.metadata,id:"vscode-auto",name:"VS Code Theme",description:"Mirrors your current VS Code color theme",author:"VS Code",version:"1.0.0",variant:e?"dark":"light",tags:["vscode","auto"]},colors:{...a.colors,primary:{base:k,hover:p,active:p,foreground:S,muted:N},surface:{background:l,foreground:d,muted:u,mutedForeground:v,elevated:g,elevatedForeground:m,overlay:b,subtle:w},interactive:{border:y,borderHover:n("toolbar.hoverOutline",y),borderFocus:O,selection:D,selectionForeground:F,focus:O,focusRing:C,cursor:M,hover:T,active:x},status:{error:U,errorForeground:Rs(U,l),errorBackground:L,errorBorder:$s(U,e?.45:.35),warning:W,warningForeground:Rs(W,l),warningBackground:X,warningBorder:$s(W,e?.45:.35),success:J,successForeground:Rs(J,l),successBackground:q,successBorder:$s(J,e?.45:.35),info:z,infoForeground:Rs(z,l),infoBackground:H,infoBorder:$s(z,e?.45:.35)},syntax:{tokens:{},highlights:{diffAdded:re,diffAddedBackground:ce,diffRemoved:ve,diffRemovedBackground:Se,diffModified:ie,diffModifiedBackground:$s(ie,e?.16:.12),lineNumber:n("editorLineNumber.foreground",v),lineNumberActive:n("editorLineNumber.activeForeground",d)},base:{background:n("editor.background",l),foreground:n("editor.foreground",d),comment:se,keyword:ne,string:B,number:K,function:Z,variable:oe,type:ue,operator:k}},tools:{border:de,icon:n("icon.foreground",v),title:d,description:$s(v,.8),edit:{added:re,addedBackground:ce,removed:ve,removedBackground:Se,modified:ie,modifiedBackground:$s(ie,e?.16:.12),lineNumber:se}},chat:{background:l,userMessage:d,userMessageBackground:me,assistantMessage:d,assistantMessageBackground:l,timestamp:v,divider:y,typing:n("chat.thinkingShimmer",v),avatarBackground:n("chat.avatarBackground",l),avatarForeground:n("chat.avatarForeground",d),slashCommandBackground:n("chat.slashCommandBackground",k),slashCommandForeground:n("chat.slashCommandForeground",S),inputWorkingBorderColor1:n("chat.inputWorkingBorderColor1",k),inputWorkingBorderColor2:n("chat.inputWorkingBorderColor2",p),inputWorkingBorderColor3:n("chat.inputWorkingBorderColor3",N)},markdown:{link:n("textLink.foreground",k),linkHover:n("textLink.activeForeground",p),inlineCode:n("textPreformat.foreground",B),inlineCodeBackground:n("textPreformat.background",n("editor.background",l)),blockquote:d,blockquoteBackground:n("textBlockQuote.background","transparent"),blockquoteBorder:n("textBlockQuote.border",y),listMarker:$s(k,.6)}}}},qr=.075;function Rv(t,e,a){const{surface:n,primary:r,status:i,interactive:l}=t.colors,d=n.background,c=t.metadata.variant==="dark",h=Rs(n.muted,d),g=[d,n.muted,n.elevated,ks(l.selection,n.muted,1,d)].filter(k=>Rs(k,d)===h),f=k=>g.reduce((p,S)=>aa(p,S,d),k),m=k=>[d,n.muted].every(p=>(Hs(k,p,d)??0)>=3),u=[e["button.background"],e["textLink.foreground"],e["activityBarBadge.background"],e["list.highlightForeground"],e.focusBorder,e["inputOption.activeBorder"],a.function,a.keyword].filter(k=>k!==void 0),v=f(u.find(m)??r.base);v!==r.base&&(r.base=v,r.foreground=Rs(v,d),r.hover=ks(n.foreground,v,.08,d),r.active=ks(n.foreground,v,.16,d),r.muted=ia(v,.5),!e.focusBorder&&!e["inputOption.activeBorder"]&&(l.focus=v,l.focusRing=v,l.borderFocus=v),t.colors.markdown&&(e["textLink.foreground"]||(t.colors.markdown.link=v),e["textLink.activeForeground"]||(t.colors.markdown.linkHover=r.hover),t.colors.markdown.listMarker=ia(v,.6))),g.some(k=>(Hs(l.focusRing,k,d)??0)<1.1)&&(l.focus=r.base,l.focusRing=r.base,l.borderFocus=r.base);const w=(k,p,S)=>g.every(N=>(Wo(k,p,N,d)??0)>=S);let b=f(i.info);if(!w(b,r.base,qr)){const k=N=>w(N,r.base,qr)&&[i.error,i.warning,i.success].every(I=>w(N,I,.1));let S=[e["notificationsInfoIcon.foreground"],e["editorInfo.foreground"],e["terminal.ansiCyan"],e["terminal.ansiBlue"],e["terminal.ansiMagenta"],e["textLink.foreground"],a.function,a.type].filter(N=>N!==void 0).map(f).find(k);if(!S){const N=ks(b,d,1,d),y=[N,f(ks(N,d,.5,d))].flatMap(T=>[.12,.18].flatMap(x=>[0,60,-60,90,-90,120,-120,180].map(A=>f(ju(T,A,x)))));if(S=y.find(k),!S){const T=x=>Math.min(...[i.error,i.warning,i.success].map(A=>Wo(x,A,n.muted,d)??0));S=y.filter(x=>w(x,r.base,qr)).sort((x,A)=>T(A)-T(x))[0]}}S&&(b=S)}if(b!==i.info&&(i.info=b,i.infoForeground=Rs(b,d),i.infoBackground=ia(b,c?.16:.12),i.infoBorder=ia(b,c?.45:.35)),t.colors.chat){const k=t.colors.chat.userMessageBackground??n.elevated;if((Hs(k,d,d)??1)<1.1){const p=ks(k,d,1,d);let N=(Hs(p,"#000000")??1)<(Hs(d,"#000000")??1)?"#000000":"#ffffff",I=p;((Hs(N,d,d)??1)<1.1||(Hs(p,d,d)??1)<1.01)&&(I=d,N=n.foreground);let y=0,T=1;for(let A=0;A<16;A++){const R=(y+T)/2,P=ks(N,I,R,d);(Hs(P,d,d)??1)>=1.1?T=R:y=R}const x=ks(N,I,T,d);(Hs(n.foreground,x,d)??0)>=4.5&&(t.colors.chat.userMessageBackground=x)}}}const nr=Mt().regex(/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i),Lo=Ts({foreground:nr.optional()}),kd=Ts({scope:ao([Mt(),xa(Mt())]).optional(),settings:Lo}),Fv=Ts({name:Mt().trim().min(1).max(160).optional(),author:Mt().max(160).optional(),description:Mt().max(1024).optional(),type:Ao(["light","dark","hc","hc-black","hc-light"]).optional(),include:Mt().optional(),colors:Un(Mt(),nr.nullable()).default({}),tokenColors:ao([xa(kd),Mt()]).optional(),semanticHighlighting:Po().optional(),semanticTokenColors:Un(Mt(),ao([nr,Lo])).optional()});function Ov(t){return t.flatMap(e=>(Array.isArray(e.scope)?e.scope:[e.scope??""]).flatMap(n=>n.split(",").map(r=>({scope:r.trim(),color:e.settings.foreground}))))}function Lv(t,e){for(const a of e){let n,r=-1;for(const i of t)!i.color||!i.scope||(a===i.scope||a.startsWith(`${i.scope}.`))&&i.scope.length>=r&&(n=i.color,r=i.scope.length);if(n)return n}}function Kv(t,e){for(const a of e.length?[...e,"*"]:e){const n=t[a];if(n===void 0)continue;const r=nr.safeParse(n);if(r.success)return r.data;const i=Lo.safeParse(n);if(i.success&&i.data.foreground)return i.data.foreground}}function zv(t){return/^[a-z0-9]+(?:[-_][a-z0-9]+)+$/.test(t)?t.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):t}function Uv(t,e,a,n){const r=Rs(a,a);if(e.some(c=>Rs(c,a)!==r))return t;let i=t;for(const c of e)i=aa(i,c,a);let l=0,d=1;for(let c=0;c<16;c++){const h=(l+d)/2,g=ia(i,h);e.every(f=>(Hs(g,f,a)??0)>=n)?d=h:l=h}return ia(i,d)}function Nd(t,e){if(new TextEncoder().encode(t).byteLength>_c)throw new ra("size");let a;try{a=Fv.parse(JSON.parse(tp(t.replace(/^\uFEFF/,""),{trailingCommas:!0})))}catch{throw new ra("invalid")}const n=xa(kd).safeParse(a.tokenColors??[]);if(a.include||!n.success)throw new ra("include");const r={};for(const[A,R]of Object.entries(a.colors))R!==null&&(r[A]=R);const i={...r},l=r["editor.background"];if(!l)throw new ra("background");const d=a.type?["dark","hc","hc-black"].includes(a.type):Rs(l,"#ffffff")==="#ffffff",c=d?"dark":"light",h=ks(l,d?"#000000":"#ffffff",1),g=Ov(n.data),f=n.data.filter(A=>!A.scope&&A.settings.foreground).at(-1)?.settings.foreground,m=r["editor.foreground"]??f??r.foreground??Rs(h,h),u=r["chat.list.background"]??h,v=r["interactive-session.foreground"]??r.foreground??m;r["editor.background"]=h,r["editor.foreground"]=m,r.foreground??=v,r["sideBar.background"]??=r["panel.background"]??ks(v,u,.03,u),!r["editorWidget.background"]&&!r["dropdown.background"]&&!r["input.background"]&&(r["editorWidget.background"]=ks(v,u,.04,u),r["editorWidget.foreground"]=aa(v,r["editorWidget.background"],u)),r.descriptionForeground??=aa(ks(v,u,.6,u),u),r["widget.border"]??=r["input.border"]??r["panel.border"]??ks(v,u,.15,u),r["toolbar.hoverBackground"]??=r["list.hoverBackground"]??ks(v,u,.08,u),r["toolbar.activeBackground"]??=ks(v,u,.12,u),!r["list.activeSelectionBackground"]&&!r["editor.selectionBackground"]&&(r["list.activeSelectionBackground"]=ks(v,u,.16,u),r["list.activeSelectionForeground"]=aa(v,r["list.activeSelectionBackground"],u)),r["button.background"]||(r["button.background"]=r["textLink.foreground"]??r.focusBorder??v,r["button.foreground"]=Rs(r["button.background"],u)),r.focusBorder??=r["button.background"],r["editorCursor.foreground"]??=m;const w=a.type?.startsWith("hc")??!1;w&&r.contrastBorder&&(r["widget.border"]=r.contrastBorder);const k=Mv({kind:d&&w?"high-contrast":c,colors:r});if(w)k.colors.interactive.focusRing=r.focusBorder;else{const{surface:A,interactive:R}=k.colors,P=Uv(R.border,[A.background,A.muted,A.elevated],A.background,d?1.15:1.2);R.border=P,r["toolbar.hoverOutline"]||(R.borderHover=P),k.colors.tools&&!r["chat.requestBorder"]&&(k.colors.tools.border=P),k.colors.chat&&(k.colors.chat.divider=P),k.colors.markdown&&!r["textBlockQuote.border"]&&(k.colors.markdown.blockquoteBorder=P)}const p=a.semanticHighlighting===!1?{}:a.semanticTokenColors??{},S=(A,R,P)=>Kv(p,A)??Lv(g,R)??P,N={background:h,foreground:m,comment:S(["comment"],["comment","comment.line","comment.block"],aa(ks(m,h,.6,h),h)),keyword:S(["keyword"],["keyword","storage","keyword.control","storage.type"],m),string:S(["string"],["string","string.quoted","string.template"],m),number:S(["number"],["constant.numeric"],m),function:S(["function"],["entity.name.function","support.function"],m),variable:S(["variable"],["variable.other.readwrite","variable"],m),type:S(["type"],["entity.name.type","support.type","support.class"],m),operator:S(["operator"],["keyword.operator"],m)},I=S(["class"],["entity.name.type.class","entity.name.class"],N.type),y=S(["property"],["variable.other.property","support.type.property-name"],N.variable),T={base:N,tokens:{className:I,interface:S(["interface"],["entity.name.type.interface"],N.type),enum:S(["enum"],["entity.name.type.enum"],I),method:S(["method"],["entity.name.function.method"],N.function),variableProperty:y,parameter:S(["parameter"],["variable.parameter"],N.variable),constant:S(["variable.readonly","*.readonly","enumMember"],["variable.other.constant","constant.other"],N.number),boolean:S([],["constant.language.boolean","constant.language"],N.number),punctuation:S([],["punctuation","punctuation.separator"],N.operator),stringEscape:S([],["constant.character.escape"],N.string),commentDoc:S([],["comment.block.documentation","comment.documentation"],N.comment),keywordImport:S([],["keyword.control.import","keyword.import"],N.keyword),tag:S([],["entity.name.tag"],N.keyword),tagAttribute:S([],["entity.other.attribute-name"],y)},highlights:k.colors.syntax.highlights},x=zv(a.name??(e.replace(/\.(jsonc?|code-theme)$/i,"").replace(/[-_]color[-_]theme$/i,"").trim().slice(0,160)||"VS Code"));return Rv(k,i,N),wu({metadata:{id:`vscode-import-${c}`,name:x,variant:c,author:a.author,description:a.description??"",version:"1.0.0",tags:["imported","vscode"]},colors:{...k.colors,syntax:T,pr:{open:k.colors.status.success,draft:k.colors.surface.mutedForeground,blocked:k.colors.status.warning,merged:I,closed:k.colors.status.error}}})}const _v=Ts({namespace:Mt(),name:Mt(),version:Mt(),label:Mt(),icon:Mt().url().refine(t=>{const e=new URL(t);return e.protocol==="https:"&&["open-vsx.org","openvsx.eclipsecontent.org"].includes(e.hostname)}).nullable()});async function $v(t,e){const a=await St("/api/config/themes/catalog/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t}),signal:e});if(!a.ok)throw new Error("catalog");return Ts({items:xa(_v).max(24)}).parse(await a.json()).items}async function Bv(t,e){const a=await St("/api/config/themes/catalog/package",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:e});if(!a.ok)throw new Error("catalog");const{items:n}=Ts({items:xa(Ts({path:Mt(),name:Mt(),text:Mt(),error:Po()})).max(40)}).parse(await a.json());return n.map((r,i)=>{const l=`${i}:${r.path}`;try{if(r.error)throw new Error("invalid");const d=Nd(r.text,r.path);return d.metadata.name=r.name,d.metadata.author=t.namespace,{status:"ready",key:l,name:r.name,definition:d,theme:ku(d)}}catch{return{status:"invalid",key:l,name:r.name}}})}function Vv(t){const e=tt.c(3),{extension:a}=t,[n,r]=o.useState(!1);let i;return e[0]!==a.icon||e[1]!==n?(i=a.icon&&!n?s.jsx("img",{src:a.icon,alt:"",referrerPolicy:"no-referrer",loading:"lazy",className:"size-9 shrink-0 rounded object-contain",onError:()=>r(!0)}):s.jsx(_,{name:"palette",className:"size-9 shrink-0 text-muted-foreground"}),e[0]=a.icon,e[1]=n,e[2]=i):i=e[2],i}function Hv(t){const e=tt.c(93),{pickFile:a,fileBusy:n,onClose:r}=t,{t:i}=Qe(),l=he(Wv),{isMobile:d}=Zn(),c=l||d,{importTheme:h}=fa(),[g,f]=o.useState("");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={step:"search",status:"idle",results:[]},e[0]=m):m=e[0];const[u,v]=o.useState(m);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=new Set,e[1]=w):w=e[1];const[b,k]=o.useState(w);let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=new Set,e[2]=p):p=e[2];const[S,N]=o.useState(p),[I,y]=o.useState(!1),[T,x]=o.useState(null),A=o.useRef(null);let R,P;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const B=new AbortController;A.current=B;const ne=or(()=>B.abort());return()=>{ne(),B.abort()}},P=[],e[3]=R,e[4]=P):(R=e[3],P=e[4]),o.useEffect(R,P);let D,F;e[5]!==g||e[6]!==u.step?(D=()=>{if(u.step!=="search")return;const B=new AbortController,ne=g.trim(),K=setTimeout(async()=>{if(!ne){v({step:"search",status:"idle",results:[]});return}v({step:"search",status:"loading",results:[]});try{const Z=await $v(ne,B.signal);B.signal.aborted||v({step:"search",status:"ready",results:Z})}catch{B.signal.aborted||v({step:"search",status:"error",results:[]})}},350);return()=>{clearTimeout(K),B.abort()}},F=[g,u.step],e[5]=g,e[6]=u.step,e[7]=D,e[8]=F):(D=e[7],F=e[8]),o.useEffect(D,F);let O,C;if(e[9]!==n||e[10]!==h||e[11]!==c||e[12]!==a||e[13]!==g||e[14]!==T||e[15]!==S||e[16]!==I||e[17]!==b||e[18]!==u.extension||e[19]!==u.results||e[20]!==u.status||e[21]!==u.step||e[22]!==u.variants||e[23]!==i){const B=async ie=>{const me=A.current?.signal;if(me){v({step:"package",status:"loading",extension:ie}),N(new Set),x(null),k(new Set);try{const ke=await Bv(ie,me);me.aborted||v({step:"variants",extension:ie,variants:ke})}catch{me.aborted||v({step:"package",status:"error",extension:ie})}}};let ne;e[26]!==h||e[27]!==S||e[28]!==I||e[29]!==b||e[30]!==u.step||e[31]!==u.variants||e[32]!==i?(ne=async()=>{if(u.step!=="variants"||I)return;const ie=A.current?.signal;if(!ie)return;y(!0),x(null);let me=!1;for(const ke of u.variants){if(ie.aborted)break;if(!(ke.status!=="ready"||!b.has(ke.key)||S.has(ke.key)))try{if(await h(ke.definition,{activate:!1}),ie.aborted)break;N(Ae=>new Set(Ae).add(ke.key)),k(Ae=>{const pe=new Set(Ae);return pe.delete(ke.key),pe})}catch{me=!0}}ie.aborted||(y(!1),x(me?"partial":null),me?qa.error(i("settings.themeImport.partialError")):qa.success(i("settings.themeImport.complete")))},e[26]=h,e[27]=S,e[28]=I,e[29]=b,e[30]=u.step,e[31]=u.variants,e[32]=i,e[33]=ne):ne=e[33];const K=ne;let Z,oe;e[34]!==S||e[35]!==b||e[36]!==u.step||e[37]!==u.variants?(Z=u.step==="variants"?u.variants.filter(ie=>ie.status==="ready"&&!S.has(ie.key)):[],oe=Z.length>0&&Z.every(ie=>b.has(ie.key)),e[34]=S,e[35]=b,e[36]=u.step,e[37]=u.variants,e[38]=Z,e[39]=oe):(Z=e[38],oe=e[39]);const ue=oe;let de;e[40]!==n||e[41]!==K||e[42]!==I||e[43]!==b||e[44]!==u.step||e[45]!==i?(de=u.step==="variants"&&s.jsx(G,{disabled:!b.size||I||n,onClick:()=>{K()},children:i(I?"settings.themeImport.busy":"settings.themeImport.importSelected")}),e[40]=n,e[41]=K,e[42]=I,e[43]=b,e[44]=u.step,e[45]=i,e[46]=de):de=e[46];const ce=I||n;let Se;e[47]!==i?(Se=i("settings.themeImport.chooseFile"),e[47]=i,e[48]=Se):Se=e[48];let re;e[49]!==a||e[50]!==ce||e[51]!==Se?(re=s.jsx(G,{variant:"outline",className:"self-start",disabled:ce,onClick:a,children:Se}),e[49]=a,e[50]=ce,e[51]=Se,e[52]=re):re=e[52];let ve;e[53]!==de||e[54]!==re?(ve=s.jsxs(s.Fragment,{children:[de,re]}),e[53]=de,e[54]=re,e[55]=ve):ve=e[55],O=ve,C=s.jsx(s.Fragment,{children:u.step==="search"?s.jsxs(s.Fragment,{children:[s.jsx(He,{autoFocus:!0,"aria-label":i("settings.themeImport.search"),placeholder:i("settings.themeImport.search"),value:g,maxLength:160,onChange:ie=>f(ie.target.value)}),s.jsxs("div",{className:c?"space-y-1":"max-h-[45dvh] overflow-y-auto space-y-1","aria-live":"polite",children:[u.status==="loading"&&s.jsx("p",{className:"text-muted-foreground",children:i("common.loading")}),u.status==="error"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:i("settings.themeImport.catalogError")}),u.status==="ready"&&!u.results.length&&s.jsx("p",{className:"text-muted-foreground",children:i("settings.themeImport.empty")}),u.results.map(ie=>s.jsxs(G,{variant:"ghost",className:"h-auto w-full justify-start py-2 text-left",onClick:()=>{B(ie)},children:[s.jsx(Vv,{extension:ie}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate",children:ie.label}),s.jsx("span",{className:"block truncate typography-meta text-muted-foreground",children:ie.namespace})]})]},`${ie.namespace}.${ie.name}`))]})]}):s.jsxs(s.Fragment,{children:[s.jsxs(G,{variant:"ghost",size:"sm",className:"justify-start",disabled:I||u.step==="package"&&u.status==="loading",onClick:()=>v({step:"search",status:"idle",results:[]}),children:[s.jsx(_,{name:"arrow-left",className:"size-4"}),i("settings.themeImport.back")]}),s.jsx("p",{className:"typography-ui-label",children:u.extension.label}),T==="partial"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:i("settings.themeImport.partialError")}),u.step==="package"?u.status==="loading"?s.jsx("p",{role:"status",children:i("common.loading")}):s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:i("settings.themeImport.catalogError")}):s.jsxs(s.Fragment,{children:[u.variants.length>1&&s.jsx(G,{variant:"ghost",size:"sm",className:"self-start",disabled:I||n||!Z.length,onClick:()=>k(ue?new Set:new Set(Z.map(Gv))),children:i(ue?"settings.themeImport.deselectAll":"settings.themeImport.selectAll")}),s.jsx("div",{className:c?"space-y-2":"max-h-[45dvh] overflow-y-auto space-y-2",children:u.variants.map(ie=>s.jsxs("div",{className:"flex items-center gap-3",children:[ie.status==="ready"&&s.jsxs("div",{"aria-hidden":"true",className:"flex w-20 shrink-0 items-center gap-2 rounded px-2 py-3",style:{backgroundColor:ie.theme.colors.surface.background,color:ie.theme.colors.surface.foreground},children:[s.jsx("span",{children:"Aa"}),s.jsx("span",{className:"space-y-1",children:[ie.theme.colors.syntax.base.keyword,ie.theme.colors.syntax.base.string,ie.theme.colors.syntax.base.function].map(qv)})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[S.has(ie.key)?s.jsxs("div",{className:"flex items-center gap-2 py-1",children:[s.jsx(_,{name:"check",className:"size-4 shrink-0 text-[var(--status-success-text)]"}),s.jsx("span",{className:"typography-ui-label",children:ie.name})]}):s.jsx(gt,{checked:b.has(ie.key),disabled:ie.status!=="ready"||I||n,label:ie.name,onChange:me=>k(ke=>{const Ae=new Set(ke);return me?Ae.add(ie.key):Ae.delete(ie.key),Ae})}),s.jsx("p",{className:S.has(ie.key)?"typography-meta font-medium text-[var(--status-success-text)]":"typography-meta text-muted-foreground",children:ie.status!=="ready"?i("settings.themeImport.error.invalid"):S.has(ie.key)?i("settings.themeImport.installed"):i(ie.theme.metadata.variant==="dark"?"settings.openchamber.visual.option.themeMode.dark":"settings.openchamber.visual.option.themeMode.light")})]})]},ie.key))})]})]})}),e[9]=n,e[10]=h,e[11]=c,e[12]=a,e[13]=g,e[14]=T,e[15]=S,e[16]=I,e[17]=b,e[18]=u.extension,e[19]=u.results,e[20]=u.status,e[21]=u.step,e[22]=u.variants,e[23]=i,e[24]=O,e[25]=C}else O=e[24],C=e[25];const M=C;if(c){let B;e[56]!==i?(B=i("settings.themeImport.catalogTitle"),e[56]=i,e[57]=B):B=e[57];let ne;e[58]!==O?(ne=s.jsx("div",{className:"flex flex-col gap-2",children:O}),e[58]=O,e[59]=ne):ne=e[59];let K;e[60]!==i?(K=i("settings.themeImport.catalogHint"),e[60]=i,e[61]=K):K=e[61];let Z;e[62]!==K?(Z=s.jsx("p",{className:"typography-meta text-muted-foreground",children:K}),e[62]=K,e[63]=Z):Z=e[63];let oe;e[64]!==M||e[65]!==Z?(oe=s.jsxs("div",{className:"flex flex-col gap-4 px-1",children:[Z,M]}),e[64]=M,e[65]=Z,e[66]=oe):oe=e[66];let ue;return e[67]!==r||e[68]!==ne||e[69]!==oe||e[70]!==B?(ue=s.jsx($c,{open:!0,title:B,onClose:r,footer:ne,children:oe}),e[67]=r,e[68]=ne,e[69]=oe,e[70]=B,e[71]=ue):ue=e[71],ue}let U;e[72]!==r?(U=B=>{B||r()},e[72]=r,e[73]=U):U=e[73];let L;e[74]===Symbol.for("react.memo_cache_sentinel")?(L={forceRender:!0},e[74]=L):L=e[74];let W;e[75]!==i?(W=i("settings.themeImport.catalogTitle"),e[75]=i,e[76]=W):W=e[76];let X;e[77]!==W?(X=s.jsx(Ht,{children:W}),e[77]=W,e[78]=X):X=e[78];let J;e[79]!==i?(J=i("settings.themeImport.catalogHint"),e[79]=i,e[80]=J):J=e[80];let q;e[81]!==J?(q=s.jsx(qt,{children:J}),e[81]=J,e[82]=q):q=e[82];let z;e[83]!==X||e[84]!==q?(z=s.jsxs(Vt,{children:[X,q]}),e[83]=X,e[84]=q,e[85]=z):z=e[85];let H;e[86]!==O||e[87]!==M||e[88]!==z?(H=s.jsxs(_t,{className:"max-w-lg",backdropProps:L,children:[z,M,O]}),e[86]=O,e[87]=M,e[88]=z,e[89]=H):H=e[89];let se;return e[90]!==H||e[91]!==U?(se=s.jsx(Ut,{open:!0,onOpenChange:U,children:H}),e[90]=H,e[91]=U,e[92]=se):se=e[92],se}function qv(t,e){return s.jsx("span",{className:"block h-1 w-5 rounded",style:{backgroundColor:t}},e)}function Gv(t){return t.key}function Wv(t){return t.isMobile}function Jv(){const{t}=Qe(),{importTheme:e,customThemesLoading:a}=fa(),n=ko(),[r,i]=o.useState(!1),l=o.useCallback(()=>i(!1),[]),d=o.useRef(null),c=o.useRef(0),h=o.useRef(null),[g,f]=o.useState(!1);o.useEffect(()=>or(()=>{c.current+=1,i(!1)}),[]);const m=async(w,b)=>{f(!0);try{if(w.size>_c)throw new ra("size");const k=await w.text();if(b.key!==wn()||b.generation!==c.current)throw new ra("connection");const p=await e(Nd(k,w.name));qa.success(t("settings.themeImport.success",{name:p.metadata.name})),i(!1)}catch(k){const p=k instanceof ra?k.code:"invalid";qa.error(t(`settings.themeImport.error.${p}`))}finally{f(!1)}},u=async()=>{if(g)return;const w={key:wn(),generation:c.current};if(h.current=w,!n.themeFiles){d.current?.click();return}f(!0);try{const b=await n.themeFiles.pick();if(b?.status==="picked"){if(b.file){const k=b.file;await m({name:k.name,size:k.size,text:async()=>k.text},w)}return}d.current?.click()}catch{qa.error(t("settings.themeImport.error.invalid"))}finally{f(!1)}},v=async w=>{const b=w.target.files?.[0];w.target.value="",b&&!g&&h.current&&await m(b,h.current)};return s.jsxs("div",{className:"flex items-center gap-2","data-settings-item":"appearance.import-theme",children:[s.jsxs(G,{variant:"outline",size:"sm",disabled:g||a,onClick:()=>i(!0),children:[s.jsx(_,{name:g?"loader":"add",className:g?"size-3.5 animate-spin":"size-3.5"}),t(g?"settings.themeImport.busy":"settings.themeImport.action")]}),s.jsx(Gt,{children:t("settings.themeImport.catalogHint")}),s.jsx("input",{ref:d,type:"file",accept:".json,.jsonc",className:"hidden","aria-label":t("settings.themeImport.action"),onChange:v}),r&&s.jsx(Hv,{pickFile:()=>{u()},fileBusy:g,onClose:l})]})}const rc=(t,e,a)=>{const n=t?.querySelector("[cmdk-list]"),r=t?.querySelector(`[cmdk-item][data-value="${CSS.escape(e)}"]`);if(!n||!r)return;const i=n.getBoundingClientRect(),l=n.offsetHeight>0?i.height/n.offsetHeight:1;if(l<=0)return;const d=r.getBoundingClientRect(),c=(d.top-i.top)/l+n.scrollTop,h=d.height/l;a?.onlyIfHidden&&c>=n.scrollTop&&c+h<=n.scrollTop+n.clientHeight||(n.scrollTop=Math.max(0,c-(n.clientHeight-h)/2))};function oc({options:t,value:e,onValueChange:a,placeholder:n,ariaLabel:r}){const{t:i}=Qe(),{deleteImportedTheme:l,customThemeIds:d}=fa(),{isMobile:c}=Zn(),[h,g]=o.useState(!1),[f,m]=o.useState(""),[u,v]=o.useState(void 0),[w,b]=o.useState(null),k=o.useRef(null),p=o.useRef(null),[S,N]=o.useState(null),[I,y]=o.useState(null),T=o.useCallback(M=>{const U=M instanceof HTMLElement?M:null,L=U?.closest('[data-slot="dialog-content"], [role="dialog"]');N(L instanceof HTMLElement?L:null),y(U?.closest("main")??null)},[]);o.useEffect(()=>{if(h)return Nu.suspend()},[h]);const x=o.useRef(e);x.current=e;const A=o.useCallback(M=>{M&&rc(M,x.current)},[]),R=t.find(M=>M.id===e),P=o.useMemo(()=>h?Ja(t,f,M=>[M.label]):t,[h,t,f]),D=M=>{a(M),g(!1)},F=async M=>{if(!w){b(M.id);try{await l(M.id),k.current?.focus()}catch{qa.error(i("settings.themeImport.deleteError"))}finally{b(null)}}},O=M=>{if(!d.includes(M.id))return null;const U=w===M.id;return s.jsx(G,{variant:"ghost",size:"icon",className:"size-6 shrink-0",disabled:U,"aria-label":i("settings.themeImport.delete",{name:M.label}),onPointerDown:L=>L.stopPropagation(),onClick:L=>{L.stopPropagation(),F(M)},children:s.jsx(_,{name:U?"loader":"delete-bin",className:U?"size-4 animate-spin":"size-4"})})},C=s.jsx("div",{role:"status",className:"px-3 py-6 text-center typography-ui-label text-muted-foreground",children:i("settings.openchamber.visual.field.noThemesFound")});return c?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","aria-label":r,"aria-haspopup":"dialog",className:Pe(Ws,!R&&"text-muted-foreground"),onClick:()=>{m(""),g(!0)},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:R?.label??n}),s.jsx(_,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx($c,{open:h,title:r,onClose:()=>g(!1),children:s.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[s.jsx(He,{value:f,onChange:M=>m(M.target.value),placeholder:i("settings.openchamber.visual.field.searchThemes"),"aria-label":i("settings.openchamber.visual.field.searchThemes"),className:"h-9"}),s.jsx("div",{className:"flex flex-col",role:"listbox","aria-label":r,children:P.length===0?C:P.map(M=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",role:"option","aria-selected":M.id===e,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg px-2 py-2.5 text-left typography-ui-label hover:bg-[var(--interactive-hover)]",onClick:()=>D(M.id),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M.label}),M.id===e?s.jsx(_,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null]}),O(M)]},M.id))})]})})]}):s.jsxs(sp,{open:h,onOpenChange:M=>{m(""),v(M?e:void 0),g(M)},onOpenChangeComplete:M=>{if(!M){p.current?.focus();return}k.current?.focus(),rc(k.current?.closest('[data-slot="command"]'),e,{onlyIfHidden:!0})},children:[s.jsxs(np,{ref:p,"aria-label":r,"aria-haspopup":"dialog",className:Pe(Ws,!R&&"text-muted-foreground"),onPointerDownCapture:M=>T(M.currentTarget),onFocusCapture:M=>T(M.currentTarget),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:R?.label??n}),s.jsx(_,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(ap,{container:S??void 0,children:s.jsx(ip,{side:"bottom",align:"start",sideOffset:4,collisionAvoidance:{side:"none"},collisionBoundary:I??void 0,className:"z-[120]",children:s.jsx(rp,{role:"dialog","aria-label":r,className:Pe(Eu,"flex w-[var(--anchor-width)] min-w-[16rem] max-w-[calc(100vw-2rem)] flex-col p-0"),initialFocus:!1,finalFocus:!1,children:s.jsxs(Su,{ref:A,className:"min-h-0 flex-1",shouldFilter:!1,value:u,onValueChange:v,children:[s.jsx(Cu,{ref:k,"aria-label":i("settings.openchamber.visual.field.searchThemes"),placeholder:i("settings.openchamber.visual.field.searchThemes"),value:f,onValueChange:m,onKeyDown:M=>{if(Iu(M)){M.stopPropagation();return}Pu(M,U=>{M.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:U,bubbles:!0,cancelable:!0}))})}}),s.jsx(Au,{label:r,className:"max-h-[20rem] p-1",children:P.length===0?C:P.map(M=>s.jsxs(Tu,{value:M.id,onSelect:D,"aria-current":M.id===e?!0:void 0,className:"max-w-full typography-ui-label",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M.label}),M.id===e?s.jsx(_,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null,O(M)]},M.id))})]})})})})]})}const Qv=[{value:"system",labelKey:"settings.openchamber.visual.option.themeMode.system",descriptionKey:"settings.openchamber.visual.option.themeMode.system.description"},{value:"light",labelKey:"settings.openchamber.visual.option.themeMode.light",descriptionKey:"settings.openchamber.visual.option.themeMode.light.description"},{value:"dark",labelKey:"settings.openchamber.visual.option.themeMode.dark",descriptionKey:"settings.openchamber.visual.option.themeMode.dark.description"}],Yv=[{id:"dynamic",labelKey:"settings.openchamber.visual.option.diffLayout.dynamic.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.dynamic.description"},{id:"inline",labelKey:"settings.openchamber.visual.option.diffLayout.inline.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.inline.description"},{id:"side-by-side",labelKey:"settings.openchamber.visual.option.diffLayout.sideBySide.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.sideBySide.description"}],Zv=[{id:"svg",labelKey:"settings.openchamber.visual.option.mermaidRendering.svg.label",descriptionKey:"settings.openchamber.visual.option.mermaidRendering.svg.description"},{id:"ascii",labelKey:"settings.openchamber.visual.option.mermaidRendering.ascii.label",descriptionKey:"settings.openchamber.visual.option.mermaidRendering.ascii.description"}],ai="OpenChamber - AI Coding Assistant",lc=[{id:"system",labelKey:"settings.openchamber.visual.option.pwaOrientation.system.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.system.description"},{id:"portrait",labelKey:"settings.openchamber.visual.option.pwaOrientation.portrait.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.portrait.description"},{id:"landscape",labelKey:"settings.openchamber.visual.option.pwaOrientation.landscape.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.landscape.description"}],cc=[{id:"native",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.description"},{id:"resize-content",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.description"}],Gr=t=>t==="portrait"||t==="landscape"?t:"system",Xv=[{id:"markdown",labelKey:"settings.openchamber.visual.option.userMessageRendering.markdown.label",descriptionKey:"settings.openchamber.visual.option.userMessageRendering.markdown.description"},{id:"plain",labelKey:"settings.openchamber.visual.option.userMessageRendering.plain.label",descriptionKey:"settings.openchamber.visual.option.userMessageRendering.plain.description"}],ey=[{id:"sorted",labelKey:"settings.openchamber.visual.option.chatRenderMode.sorted.label",descriptionKey:"settings.openchamber.visual.option.chatRenderMode.sorted.description"},{id:"live",labelKey:"settings.openchamber.visual.option.chatRenderMode.live.label",descriptionKey:"settings.openchamber.visual.option.chatRenderMode.live.description"}],dc=[{id:"auto",labelKey:"settings.openchamber.visual.option.messageTransport.auto.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.auto.description"},{id:"ws",labelKey:"settings.openchamber.visual.option.messageTransport.ws.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.ws.description"},{id:"sse",labelKey:"settings.openchamber.visual.option.messageTransport.sse.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.sse.description"}],ty=[{id:"collapsed",labelKey:"settings.openchamber.visual.option.activityRenderMode.collapsed.label",descriptionKey:"settings.openchamber.visual.option.activityRenderMode.collapsed.description"},{id:"summary",labelKey:"settings.openchamber.visual.option.activityRenderMode.summary.label",descriptionKey:"settings.openchamber.visual.option.activityRenderMode.summary.description"}],uc=[{id:"auto",labelKey:"settings.openchamber.visual.option.timeFormat.auto.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.auto.description"},{id:"24h",labelKey:"settings.openchamber.visual.option.timeFormat.24h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.24h.description"},{id:"12h",labelKey:"settings.openchamber.visual.option.timeFormat.12h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.12h.description"}],mc=[{id:"auto",labelKey:"settings.openchamber.visual.option.weekStart.auto.label",descriptionKey:"settings.openchamber.visual.option.weekStart.auto.description"},{id:"monday",labelKey:"settings.openchamber.visual.option.weekStart.monday.label"},{id:"sunday",labelKey:"settings.openchamber.visual.option.weekStart.sunday.label"}],sy=[{id:"steer",labelKey:"settings.openchamber.visual.option.followUpBehavior.steer.label"},{id:"queue",labelKey:"settings.openchamber.visual.option.followUpBehavior.queue.label"}],ny=[{id:"ask",labelKey:"settings.openchamber.visual.option.largeTextPaste.ask.label"},{id:"attach",labelKey:"settings.openchamber.visual.option.largeTextPaste.attach.label"},{id:"inline",labelKey:"settings.openchamber.visual.option.largeTextPaste.inline.label"}],ay=[{id:"global",labelKey:"settings.openchamber.visual.option.inputHistoryScope.global.label"},{id:"session",labelKey:"settings.openchamber.visual.option.inputHistoryScope.session.label"}],iy=t=>t==="markdown"?"markdown":"plain",ry=[{id:"left",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsLeft"},{id:"right",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsRight"}],oy=[{id:"classic",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsClassic"},{id:"traffic-lights",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsTrafficLights"}],lr=({visibleSettings:t})=>{const{locale:e,locales:a,setLocale:n,label:r,t:i}=Qe(),l=o.useCallback(j=>i(j),[i]),{isMobile:d}=Zn(),{terminal:c}=ko(),{browserTab:h}=Fm(),g=pm(),f=he(j=>j.showReasoningTraces),m=he(j=>j.sessionRecapEnabled),u=he(j=>j.sessionSuggestionEnabled),v=he(j=>j.setSessionRecapEnabled),w=he(j=>j.setSessionSuggestionEnabled),b=he(j=>j.sessionGoalEnabled),k=he(j=>j.setSessionGoalEnabled),p=he(j=>j.sessionGoalDefaultBudgetEnabled),S=he(j=>j.setSessionGoalDefaultBudgetEnabled),N=he(j=>j.sessionGoalDefaultBudget),I=he(j=>j.setSessionGoalDefaultBudget),y=he(j=>j.setShowReasoningTraces),T=he(j=>j.streamingAutoFollowEnabled),x=he(j=>j.setStreamingAutoFollowEnabled),A=he(j=>j.collapsibleThinkingBlocks),R=he(j=>j.setCollapsibleThinkingBlocks),P=al(j=>j.animatedActivityIndicators),D=al(j=>j.setAnimatedActivityIndicators),F=he(j=>j.mermaidRenderingMode),O=he(j=>j.setMermaidRenderingMode),C=he(j=>j.userMessageRenderingMode),M=he(j=>j.setUserMessageRenderingMode),U=he(j=>j.collapsibleUserMessages),L=he(j=>j.setCollapsibleUserMessages),W=he(j=>j.stickyUserHeader),X=he(j=>j.promptNavigatorEnabled),J=he(j=>j.setStickyUserHeader),q=he(j=>j.setPromptNavigatorEnabled),z=he(j=>j.autoSaveEnabled),H=he(j=>j.setAutoSaveEnabled),se=he(j=>j.wideChatLayoutEnabled),B=he(j=>j.setWideChatLayoutEnabled),ne=he(j=>j.codeBlockLineWrap),K=he(j=>j.setCodeBlockLineWrap),Z=he(j=>j.chatRenderMode),oe=he(j=>j.setChatRenderMode),ue=he(j=>j.activityRenderMode),de=he(j=>j.setActivityRenderMode),ce=he(j=>j.fontSize),Se=he(j=>j.setFontSize),re=he(j=>j.terminalFontSize),ve=he(j=>j.setTerminalFontSize),ie=he(j=>j.terminalShell),me=he(j=>j.setTerminalShell),ke=he(j=>j.terminalLoginShells),Ae=he(j=>j.setTerminalLoginShells),pe=he(j=>j.editorFontSize),Le=he(j=>j.setEditorFontSize),Ve=he(j=>j.uiFont),ye=he(j=>j.setUiFont),Te=he(j=>j.monoFont),ee=he(j=>j.setMonoFont),ae=he(j=>j.padding),fe=he(j=>j.setPadding),je=he(j=>j.inputBarOffset),Re=he(j=>j.setInputBarOffset),Ce=he(j=>j.mobileKeyboardMode),_e=he(j=>j.setMobileKeyboardMode),Ke=he(j=>j.diffLayoutPreference),Fe=he(j=>j.setDiffLayoutPreference),Me=he(j=>j.showTerminalQuickKeysOnDesktop),at=he(j=>j.sessionTabsEnabled),pt=he(j=>j.setSessionTabsEnabled),ot=he(j=>j.setShowTerminalQuickKeysOnDesktop),mt=he(j=>j.fileEditorKeymap),ht=he(j=>j.setFileEditorKeymap),Oe=il(j=>j.followUpBehavior),nt=il(j=>j.setFollowUpBehavior),lt=Di(j=>j.scope),we=Di(j=>j.entryLimit),Je=Di(j=>j.applyScope),Ye=Di(j=>j.applyEntryLimit),ze=he(j=>j.persistChatDraft),Ge=he(j=>j.setPersistChatDraft),Q=he(j=>j.inputSpellcheckEnabled),Ue=he(j=>j.setInputSpellcheckEnabled),st=he(j=>j.largeTextPasteBehavior),dt=he(j=>j.setLargeTextPasteBehavior),ct=he(j=>j.enterToSend),ft=he(j=>j.setEnterToSend),kt=he(j=>j.enterToSendConfigured),bt=he(j=>j.setEnterToSendConfigured),vt=kt?ct:!d,Xe=he(j=>j.showToolFileIcons),jt=he(j=>j.setShowToolFileIcons),De=he(j=>j.showTurnChangedFiles),$e=he(j=>j.setShowTurnChangedFiles),Y=he(j=>j.showExpandedBashTools),V=he(j=>j.setShowExpandedBashTools),be=he(j=>j.showExpandedEditTools),ge=he(j=>j.setShowExpandedEditTools),Ee=he(j=>j.timeFormatPreference),te=he(j=>j.setTimeFormatPreference),xe=he(j=>j.weekStartPreference),Ze=he(j=>j.setWeekStartPreference),Nt=he(j=>j.showSplitAssistantMessageActions),Lt=he(j=>j.setShowSplitAssistantMessageActions),Ie=he(j=>j.allowPromptingSubagentSessions),Be=he(j=>j.setAllowPromptingSubagentSessions),wt=he(j=>j.draftStartersVisible),Pt=he(j=>j.setDraftStartersVisible),Qt=rt(j=>j.settingsMessageStreamTransport),Xt=rt(j=>j.setSettingsMessageStreamTransport),ss=Qt,es=rt(j=>j.settingsDefaultFileViewerPreview),Ls=rt(j=>j.setSettingsDefaultFileViewerPreview),Js=he(j=>j.isSettingsDialogOpen),{themeMode:gn,setThemeMode:Ks,availableThemes:zs,customThemesLoading:on,reloadCustomThemes:Qs,lightThemeId:Ys,darkThemeId:Us,setLightThemePreference:Dn,setDarkThemePreference:Rt}=fa(),[Wt,zt]=o.useState(!1),Dt=o.useMemo(()=>ls()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),is=he(j=>j.dockBadgeEnabled),ns=he(j=>j.setDockBadgeEnabled),cr=he(j=>j.alwaysShowScrollbars===!0),dr=he(j=>j.setAlwaysShowScrollbars),ur=gm(),mr=he(j=>j.desktopWindowControlsPosition),vi=he(j=>j.setDesktopWindowControlsPosition),pr=he(j=>j.desktopWindowControlsStyle),yi=he(j=>j.setDesktopWindowControlsStyle),[gr,Vs]=o.useState(0),Za=he(j=>j.reportUsage),ji=he(j=>j.setReportUsage),wi=o.useCallback(j=>{ji(j),xt({reportUsage:j})},[ji]),hr=o.useCallback(j=>{vi(j),xt({desktopWindowControlsPosition:j})},[vi]),fr=o.useCallback(j=>{yi(j),xt({desktopWindowControlsStyle:j})},[yi]),ki=(Js||d||fs())&&(t?t.includes("chatRenderMode"):!0);o.useEffect(()=>{if(!ki)return;let j=null,yt=Date.now();const gs=()=>{const vn=Date.now();vn-yt>=420&&(Vs(ea=>(ea+1)%24),yt=vn),j=requestAnimationFrame(gs)};(typeof document>"u"||document.visibilityState==="visible")&&(j=requestAnimationFrame(gs));const Es=()=>{document.visibilityState==="visible"&&j===null?j=requestAnimationFrame(gs):document.visibilityState!=="visible"&&j!==null&&(cancelAnimationFrame(j),j=null)};return document.addEventListener("visibilitychange",Es),()=>{document.removeEventListener("visibilitychange",Es),j!==null&&cancelAnimationFrame(j)}},[ki]);const xr=o.useCallback(j=>{M(j),xt({userMessageRenderingMode:j})},[M]),br=o.useCallback(j=>{J(j),xt({stickyUserHeader:j})},[J]),ys=o.useCallback(j=>{q(j),xt({promptNavigatorEnabled:j})},[q]),ln=o.useCallback(j=>{Pt(j),xt({draftStartersVisible:j})},[Pt]),ba=o.useCallback(j=>{L(j),xt({collapsibleUserMessages:j})},[L]),Mn=o.useCallback(j=>{B(j),xt({wideChatLayoutEnabled:j})},[B]),$n=o.useCallback(j=>{Lt(j),xt({showSplitAssistantMessageActions:j})},[Lt]),_o=o.useCallback(j=>{Ue(j),xt({inputSpellcheckEnabled:j})},[Ue]),cn=o.useCallback(j=>{ft(j),bt(!0),xt({enterToSend:j,enterToSendConfigured:!0})},[ft,bt]),vr=o.useCallback(j=>{oe(j),xt({chatRenderMode:j})},[oe]),va=o.useCallback(j=>{Xt(j),xt({messageStreamTransport:j})},[Xt]),ya=o.useCallback(j=>{Je(j),xt({inputHistoryScope:j})},[Je]),Xn=o.useCallback(j=>{const yt=Math.round(j);hm(yt)&&(Ye(yt),xt({inputHistoryLimit:yt}))},[Ye]),Xa=o.useCallback(j=>{de(j),xt({activityRenderMode:j})},[de]),yr=o.useCallback(j=>{O(j),xt({mermaidRenderingMode:j})},[O]),ds=o.useCallback(j=>{jt(j),xt({showToolFileIcons:j})},[jt]),jr=o.useCallback(j=>{$e(j),xt({showTurnChangedFiles:j})},[$e]),ja=o.useCallback(j=>{Ls(j),xt({defaultFileViewerPreview:j}),window.dispatchEvent(new CustomEvent("openchamber:file-viewer-preview-mode-changed",{detail:{enabled:j}}))},[Ls]),wa=o.useCallback(j=>{V(j),xt({showExpandedBashTools:j})},[V]),wr=o.useCallback(j=>{ge(j),xt({showExpandedEditTools:j})},[ge]),Ni=o.useCallback(j=>{te(j),xt({timeFormatPreference:j})},[te]),kr=o.useCallback(j=>{Ze(j),xt({weekStartPreference:j})},[Ze]),Bn=o.useMemo(()=>zs.filter(j=>j.metadata.variant==="light").sort((j,yt)=>j.metadata.name.localeCompare(yt.metadata.name)),[zs]),hn=o.useMemo(()=>zs.filter(j=>j.metadata.variant==="dark").sort((j,yt)=>j.metadata.name.localeCompare(yt.metadata.name)),[zs]),ka=o.useMemo(()=>Bn.find(j=>j.metadata.id===Ys)??Bn[0],[Bn,Ys]),Si=o.useMemo(()=>hn.find(j=>j.metadata.id===Us)??hn[0],[hn,Us]),Na=o.useCallback((j,yt)=>{const gs=yt==="dark"?" Dark":" Light";return j.endsWith(gs)?j.slice(0,-gs.length):j},[]),Sa=o.useMemo(()=>Bn.map(j=>({id:j.metadata.id,label:Na(j.metadata.name,"light")})),[Bn,Na]),Nr=o.useMemo(()=>hn.map(j=>({id:j.metadata.id,label:Na(j.metadata.name,"dark")})),[hn,Na]),Ne=j=>j==="enterToSend"&&d?!1:t?t.includes(j):!0,Ss=fs(),Ca=Ne("theme")&&!Ss,Ci=Ne("windowControlsPosition")&&ur,Ii=Ne("theme")||Ne("timeFormat")||Ne("weekStart"),Pi=Ss?Ii:Ne("theme")||Ci||Ne("pwaInstallName")||Ne("pwaOrientation")||Ne("timeFormat")||Ne("weekStart"),Ai=Ne("fontSize")||Ne("terminalFontSize")||Ne("editorFontSize")||Ne("spacing")||Ne("scrollbars")&&!Ca||Ne("inputBarOffset")&&d,Ti=Ne("terminalQuickKeys")&&!d||(Ne("terminalShell")||Ne("terminalLoginShell"))&&!Ss||Ne("fileEditorKeymap")||Ne("autoSaveEnabled")||Ne("sessionTabs")&&!Ss&&!d,Sr=Ne("mermaidRendering")||Ne("sessionGoal")&&!Ss||Ne("userMessageRendering")||Ne("chatRenderMode")||Ne("messageTransport")||Ne("activityRenderMode")||Ne("collapsibleUserMessages")||Ne("stickyUserHeader")||Ne("promptNavigatorEnabled")||Ne("wideChatLayout")||Ne("codeBlockLineWrap")||Ne("splitAssistantMessageActions")||Ne("subagentReadOnlyBanner")||Ne("diffLayout")||Ne("dotfiles")||Ne("fileViewerPreview")||Ne("reasoning")||Ne("followUpBehavior")||Ne("inputHistoryScope")||Ne("inputHistoryLimit")||Ne("persistDraft")||Ne("largeTextPaste")||Ne("showToolFileIcons")||Ne("expandedTools")||!d&&Ne("inputSpellcheck")||Ne("enterToSend"),fn=Ne("chatRenderMode")||Ne("activityRenderMode"),Vn=Ne("messageTransport"),Ia=Ne("userMessageRendering")||Ne("mermaidRendering")||Ne("diffLayout")&&!Ss||Ne("followUpBehavior")||Ne("inputHistoryScope")||Ne("inputHistoryLimit"),Cr=Ne("sessionAssist")||Ne("sessionGoal")&&!Ss||Ne("subagentReadOnlyBanner")||Ne("collapsibleUserMessages")||Ne("stickyUserHeader")||Ne("promptNavigatorEnabled")||Ne("wideChatLayout")||Ne("codeBlockLineWrap")||Ne("splitAssistantMessageActions")||Ne("dotfiles")||Ne("fileViewerPreview")||Ne("persistDraft")||Ne("largeTextPaste")||Ne("showToolFileIcons")||Ne("showTurnChangedFiles")||!d&&Ne("inputSpellcheck")||Ne("enterToSend")||Ne("reasoning")||Ne("expandedTools"),E=Pi||Ai||Ti,le=Ne("pwaInstallName")&&da()&&h&&!ls()&&!Ss,We=Ne("pwaOrientation")&&da()&&!ls()&&!Ss,it=Ne("mobileKeyboardMode")&&da()&&!ls()&&!Ss&&fm(),Ot=(Ne("terminalShell")||Ne("terminalLoginShell"))&&!Ss,[xs,Zs]=o.useState([]),[ps,_s]=o.useState(0);o.useEffect(()=>or(()=>{Zs([]),_s(j=>j+1)}),[]),o.useEffect(()=>{let j=!1;if(!(!Ot||!c.listShells))return c.listShells().then(yt=>{j||Zs(yt)}).catch(()=>{j||Zs([])}),()=>{j=!0}},[Ot,c,ps]);const Rn=o.useMemo(()=>{const j=xs.filter(yt=>yt.id!=="auto");return ie==="auto"||j.some(yt=>yt.id===ie)?j:[{id:ie,name:ie,supportsLogin:!1},...j]},[xs,ie]),xn=xs.find(j=>j.id===ie)?.supportsLogin===!0,Pa=ke.includes(ie),Aa=j=>{Ae(j?[...ke.filter(yt=>yt!==ie),ie]:ke.filter(yt=>yt!==ie))},[Kt,Yt]=o.useState(""),[bn,dn]=o.useState("system"),Zt=o.useMemo(()=>{const j=uc.find(yt=>yt.id===Ee);return l(j?.labelKey??"settings.openchamber.visual.option.timeFormat.auto.label")},[Ee,l]),Cs=o.useMemo(()=>{const j=mc.find(yt=>yt.id===xe);return l(j?.labelKey??"settings.openchamber.visual.option.weekStart.auto.label")},[xe,l]),Ta=o.useMemo(()=>{const j=lc.find(yt=>yt.id===bn);return j?l(j.labelKey):void 0},[bn,l]),Ea=o.useMemo(()=>{const j=cc.find(yt=>yt.id===Ce);return j?l(j.labelKey):void 0},[Ce,l]),Da=o.useCallback(async j=>{if(typeof window>"u")return;const yt=window,Es=j.trim().replace(/\s+/g," ").slice(0,64);if(await xt({pwaAppName:Es}),typeof yt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__=="function"){const vn=yt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(Es);Yt(vn);return}Yt(Es||ai),yt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),$o=o.useCallback(async j=>{if(typeof window>"u")return;const yt=window,gs=Gr(j);if(await xt({pwaOrientation:gs}),typeof yt.__OPENCHAMBER_SET_PWA_ORIENTATION__=="function"){const Es=yt.__OPENCHAMBER_SET_PWA_ORIENTATION__(gs);dn(Es);return}dn(gs),yt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);o.useEffect(()=>{if(typeof window>"u"||!le&&!We&&!it)return;let j=!1;return(async()=>{try{const gs=await En();if(!gs){j||Yt(ai);return}const vn=(gs.pwaAppName??"").trim().replace(/\s+/g," ").slice(0,64),ea=Gr(gs.pwaOrientation),Ei=dl(gs.mobileKeyboardMode);j||(le&&Yt(vn||ai),We&&dn(ea),it&&_e(Ei))}catch{j||(le&&Yt(ai),We&&dn("system"),it&&_e("native"))}})(),()=>{j=!0}},[_e,it,le,We]);const Ir=Ne("scrollbars")?s.jsx(gt,{checked:cr,onChange:dr,label:i("settings.openchamber.visual.field.alwaysShowScrollbars"),info:i("settings.openchamber.visual.field.alwaysShowScrollbarsHint"),settingsItem:"appearance.scrollbars"}):null;return s.jsxs("div",{className:"space-y-0",children:[Pi&&s.jsxs("div",{className:"space-y-0",children:[Ca&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.colorModeAndTheme"),divider:!1,children:[s.jsxs(On,{children:[s.jsx("div",{className:Fs,children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.section.colorMode"),children:Qv.map(j=>s.jsx(ws,{selected:gn===j.value,onSelect:()=>Ks(j.value),label:l(j.labelKey),ariaLabel:l(j.labelKey)},j.value))})}),s.jsxs("div",{className:Fs,children:[s.jsx(Ft,{label:i("settings.openchamber.visual.field.lightTheme"),settingsItem:"appearance.light-theme",children:s.jsx(oc,{options:Sa,value:ka?.metadata.id??"",onValueChange:Dn,placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:i("settings.openchamber.visual.field.selectLightThemeAria")})}),s.jsx(Ft,{label:i("settings.openchamber.visual.field.darkTheme"),settingsItem:"appearance.dark-theme",children:s.jsx(oc,{options:Nr,value:Si?.metadata.id??"",onValueChange:Rt,placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:i("settings.openchamber.visual.field.selectDarkThemeAria")})}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",disabled:on||Wt,onClick:()=>{const j=Date.now();zt(!0),Qs().finally(()=>{const yt=Date.now()-j;if(yt<500){window.setTimeout(()=>{zt(!1)},500-yt);return}zt(!1)})},className:"typography-settings-link inline-flex items-center gap-1.5 disabled:cursor-not-allowed disabled:opacity-50 disabled:no-underline",children:[s.jsx(_,{name:"restart",className:Pe("h-3.5 w-3.5",Wt&&"animate-spin")}),i(Wt?"settings.openchamber.visual.actions.reloadingThemes":"settings.openchamber.visual.actions.reloadThemes")]}),s.jsx(Gt,{children:i("settings.openchamber.visual.field.themeImportInfoTooltip")})]}),s.jsx(Jv,{})]})]}),Dt&&s.jsx(Qa,{settingsItem:"appearance.dock-badge",children:s.jsx(gt,{checked:is,onChange:ns,label:i("settings.openchamber.visual.field.dockBadge"),info:i("settings.openchamber.visual.field.dockBadgeHint"),ariaLabel:i("settings.openchamber.visual.field.dockBadge")})}),Ir&&s.jsx(Qa,{children:Ir})]}),Ci&&s.jsx(qe,{title:i("settings.openchamber.desktopNetwork.field.windowControls"),info:i("settings.openchamber.desktopNetwork.field.windowControlsPositionDescription"),divider:Ca,children:s.jsxs(On,{children:[s.jsx(Ft,{label:i("settings.openchamber.desktopNetwork.field.windowControlsPosition"),settingsItem:"sessions.desktop-window-controls-position",children:s.jsx(mn,{value:mr,options:ry.map(j=>({value:j.id,label:l(j.labelKey)})),onChange:hr,"aria-label":i("settings.openchamber.desktopNetwork.field.windowControlsPositionAria")})}),s.jsx(Ft,{label:i("settings.openchamber.desktopNetwork.field.windowControlsStyle"),settingsItem:"sessions.desktop-window-controls-style",children:s.jsx(mn,{value:pr,options:oy.map(j=>({value:j.id,label:l(j.labelKey)})),onChange:fr,"aria-label":i("settings.openchamber.desktopNetwork.field.windowControlsStyleAria")})})]})}),Ii&&s.jsx(qe,{title:i("settings.openchamber.visual.section.localization"),children:s.jsxs(On,{children:[s.jsx(Ft,{label:i("settings.appearance.language.label"),info:i("settings.appearance.language.description"),settingsItem:"appearance.language",children:s.jsxs(Et,{value:e,onValueChange:j=>n(j),children:[s.jsx(At,{"aria-label":i("settings.appearance.language.select"),size:Bt,className:Ra,children:s.jsx($t,{children:r(e)})}),s.jsx(Tt,{children:a.map(j=>s.jsx(ut,{value:j,children:r(j)},j))})]})}),(Ne("timeFormat")||Ne("weekStart"))&&s.jsxs("div",{className:Fs,children:[Ne("timeFormat")&&s.jsx(Ft,{label:i("settings.openchamber.visual.field.timeFormat"),settingsItem:"appearance.time-format",children:s.jsxs(Et,{value:Ee,onValueChange:j=>Ni(j),children:[s.jsx(At,{"aria-label":i("settings.openchamber.visual.field.selectTimeFormatAria"),size:Bt,className:Ra,children:s.jsx($t,{children:Zt})}),s.jsx(Tt,{children:uc.map(j=>s.jsx(ut,{value:j.id,children:l(j.labelKey)},j.id))})]})}),Ne("weekStart")&&s.jsx(Ft,{label:i("settings.openchamber.visual.field.weekStartsOn"),settingsItem:"appearance.week-start",children:s.jsxs(Et,{value:xe,onValueChange:j=>kr(j),children:[s.jsx(At,{"aria-label":i("settings.openchamber.visual.field.selectWeekStartAria"),size:Bt,className:Ra,children:s.jsx($t,{children:Cs})}),s.jsx(Tt,{children:mc.map(j=>s.jsx(ut,{value:j.id,children:l(j.labelKey)},j.id))})]})})]})]})}),(le||We||it)&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.appInstall"),contentClassName:Fs,children:[le&&s.jsxs(It,{label:i("settings.openchamber.visual.field.installAppName"),info:i("settings.openchamber.visual.field.installAppNameHint"),settingsItem:"appearance.pwa-install-name",alignEnd:!1,controlClassName:Ps,children:[s.jsx(He,{value:Kt,onChange:j=>{Yt(j.target.value)},onBlur:()=>{Da(Kt)},onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),Da(Kt))},className:"min-w-0 flex-1",maxLength:64,"aria-label":i("settings.openchamber.visual.field.pwaInstallAppNameAria")}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Yt(ai),Da("")},className:us,"aria-label":i("settings.openchamber.visual.actions.resetInstallAppNameAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]}),We&&s.jsxs(It,{label:i("settings.openchamber.visual.field.installOrientation"),description:i("settings.openchamber.visual.field.installOrientationHint"),settingsItem:"appearance.pwa-orientation",alignEnd:!1,controlClassName:Ps,children:[s.jsxs(Et,{value:bn,onValueChange:j=>{const yt=Gr(j);dn(yt),$o(yt)},children:[s.jsx(At,{"aria-label":i("settings.openchamber.visual.field.pwaInstallOrientationAria"),size:Bt,className:Jo,children:s.jsx($t,{placeholder:i("settings.openchamber.visual.field.selectOrientationPlaceholder"),children:Ta})}),s.jsx(Tt,{children:lc.map(j=>s.jsx(ut,{value:j.id,children:l(j.labelKey)},j.id))})]}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{dn("system"),$o("system")},disabled:bn==="system",className:us,"aria-label":i("settings.openchamber.visual.actions.resetInstallOrientationAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]}),it&&s.jsxs(It,{label:i("settings.openchamber.visual.field.mobileKeyboardMode"),info:i("settings.openchamber.visual.field.mobileKeyboardModeHint"),settingsItem:"appearance.mobile-keyboard-mode",alignEnd:!1,controlClassName:Ps,children:[s.jsxs(Et,{value:Ce,onValueChange:j=>{const yt=dl(j);_e(yt),xt({mobileKeyboardMode:yt})},children:[s.jsx(At,{"aria-label":i("settings.openchamber.visual.field.mobileKeyboardModeAria"),size:Bt,className:Jo,children:s.jsx($t,{placeholder:i("settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder"),children:Ea})}),s.jsx(Tt,{children:cc.map(j=>s.jsx(ut,{value:j.id,children:l(j.labelKey)},j.id))})]}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{_e("native"),xt({mobileKeyboardMode:"native"})},disabled:Ce==="native",className:us,"aria-label":i("settings.openchamber.visual.actions.resetMobileKeyboardModeAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]}),Ai&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.densityAndType"),contentClassName:Fs,children:[Ne("fontSize")&&!d||Ne("terminalFontSize")?s.jsxs(On,{children:[Ne("fontSize")&&!d&&s.jsxs(Ft,{label:i("settings.openchamber.visual.field.interfaceFont"),settingsItem:"appearance.interface-font-size",controlClassName:"w-full",children:[s.jsxs(Et,{value:Ve,onValueChange:j=>ye(j),children:[s.jsx(At,{"aria-label":i("settings.openchamber.visual.field.selectInterfaceFontAria"),size:Bt,className:Ra,children:s.jsx($t,{children:rl.find(j=>j.id===Ve)?.label})}),s.jsx(Tt,{children:rl.map(j=>s.jsx(ut,{value:j.id,children:s.jsx("span",{style:{fontFamily:j.stack},children:j.label})},j.id))})]}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>ye(ol),disabled:Ve===ol,className:us,"aria-label":i("settings.openchamber.visual.actions.resetInterfaceFontAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]}),Ne("terminalFontSize")&&s.jsxs(Ft,{label:i("settings.openchamber.visual.field.codeFont"),controlClassName:"w-full",children:[s.jsxs(Et,{value:Te,onValueChange:j=>ee(j),children:[s.jsx(At,{"aria-label":i("settings.openchamber.visual.field.selectCodeFontAria"),size:Bt,className:Ra,children:s.jsx($t,{children:ll.find(j=>j.id===Te)?.label})}),s.jsx(Tt,{children:ll.map(j=>s.jsx(ut,{value:j.id,children:s.jsx("span",{style:{fontFamily:j.stack},children:j.label})},j.id))})]}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>ee(cl),disabled:Te===cl,className:us,"aria-label":i("settings.openchamber.visual.actions.resetCodeFontAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]})]}):null,Ne("fontSize")&&!d||Ne("terminalFontSize")||Ne("editorFontSize")?s.jsxs(On,{children:[Ne("fontSize")&&!d&&s.jsx(Ft,{label:i("settings.openchamber.visual.field.interfaceFontSize"),controlClassName:"w-full",children:s.jsxs("div",{className:Fa,children:[s.jsx(hs,{value:ce,onValueChange:Se,min:50,max:200,step:5,className:bs,"aria-label":i("settings.openchamber.visual.field.fontSizePercentageAria")}),s.jsx("span",{className:Oa,children:"%"}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>Se(100),disabled:ce===100,className:us,"aria-label":i("settings.openchamber.visual.actions.resetFontSizeAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]})}),Ne("terminalFontSize")&&s.jsx(Ft,{label:i("settings.openchamber.visual.field.terminalFontSize"),settingsItem:"appearance.terminal-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:Fa,children:[s.jsx(hs,{value:re,onValueChange:ve,min:9,max:52,step:1,className:bs}),s.jsx("span",{className:Oa,children:"px"}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>ve(13),disabled:re===13,className:us,"aria-label":i("settings.openchamber.visual.actions.resetTerminalFontSizeAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]})}),Ne("editorFontSize")&&s.jsx(Ft,{label:i("settings.openchamber.visual.field.editorFontSize"),settingsItem:"appearance.editor-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:Fa,children:[s.jsx(hs,{value:pe,onValueChange:Le,min:9,max:32,step:1,className:bs}),s.jsx("span",{className:Oa,children:"px"}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>Le(13),disabled:pe===13,className:us,"aria-label":i("settings.openchamber.visual.actions.resetEditorFontSizeAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,Ne("spacing")||Ne("inputBarOffset")&&d?s.jsxs(On,{children:[Ne("spacing")&&s.jsx(Ft,{label:i("settings.openchamber.visual.field.spacingDensity"),settingsItem:"appearance.spacing-density",controlClassName:"w-full",children:s.jsxs("div",{className:Fa,children:[s.jsx(hs,{value:ae,onValueChange:fe,min:50,max:200,step:5,className:bs}),s.jsx("span",{className:Oa,children:"%"}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>fe(100),disabled:ae===100,className:us,"aria-label":i("settings.openchamber.visual.actions.resetSpacingAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]})}),Ne("inputBarOffset")&&d&&s.jsx(Ft,{label:i("settings.openchamber.visual.field.inputBarOffset"),info:i("settings.openchamber.visual.field.inputBarOffsetTooltip"),settingsItem:"appearance.input-bar-offset",controlClassName:"w-full",children:s.jsxs("div",{className:Fa,children:[s.jsx(hs,{value:je,onValueChange:Re,min:0,max:100,step:5,className:bs}),s.jsx("span",{className:Oa,children:"px"}),s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>Re(0),disabled:je===0,className:us,"aria-label":i("settings.openchamber.visual.actions.resetInputBarOffsetAria"),title:i("settings.common.actions.reset"),children:s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,!Ca&&Ir]}),Ne("animatedActivityIndicators")&&s.jsx(qe,{title:i("settings.openchamber.visual.section.sessionActivity"),settingsItem:"appearance.session-activity",contentClassName:cs,children:s.jsx(gt,{checked:P,onChange:D,label:i("settings.openchamber.visual.field.animatedActivityIndicators"),ariaLabel:i("settings.openchamber.visual.field.animatedActivityIndicatorsAria"),info:i("settings.openchamber.visual.field.animatedActivityIndicatorsInfo"),settingsItem:"appearance.animated-activity-indicators"})}),Ti&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.navigation"),contentClassName:"space-y-4",children:[Ne("fileEditorKeymap")&&s.jsx(js,{title:i("settings.openchamber.visual.field.fileEditorKeymap"),settingsItem:"appearance.file-editor-keymap",children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.field.fileEditorKeymap"),children:["default","vim"].map(j=>s.jsx(ws,{selected:mt===j,onSelect:()=>ht(j),label:i(`settings.openchamber.visual.option.fileEditorKeymap.${j}`),ariaLabel:i(`settings.openchamber.visual.option.fileEditorKeymap.${j}`)},j))})}),s.jsxs("div",{className:cs,children:[Ne("autoSaveEnabled")&&s.jsx(gt,{checked:z,onChange:H,label:i("settings.openchamber.visual.field.autoSaveEnabled"),ariaLabel:i("settings.openchamber.visual.field.autoSaveEnabledAria"),info:i("settings.openchamber.visual.field.autoSaveEnabledInfo"),settingsItem:"appearance.auto-save-enabled"}),Ot&&s.jsx(Ft,{label:i("settings.openchamber.visual.field.terminalShell"),info:i("settings.openchamber.visual.field.terminalShellHint"),settingsItem:"appearance.terminal-shell",className:"pt-2",children:s.jsxs(Et,{value:ie,onValueChange:j=>{xm(j)&&me(j)},children:[s.jsx(At,{"aria-label":i("settings.openchamber.visual.field.terminalShellAria"),size:Bt,className:Ra,children:s.jsx($t,{})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:"auto",children:i("settings.openchamber.visual.option.terminalShell.auto")}),Rn.map(j=>s.jsx(ut,{value:j.id,children:j.name},j.id))]})]})}),Ot&&xn&&s.jsx(gt,{checked:Pa,onChange:Aa,label:i("settings.openchamber.visual.field.terminalLoginShell"),ariaLabel:i("settings.openchamber.visual.field.terminalLoginShell"),settingsItem:"appearance.terminal-login-shell"}),Ne("terminalQuickKeys")&&!d&&s.jsx(gt,{checked:Me,onChange:ot,label:i("settings.openchamber.visual.field.terminalQuickKeys"),ariaLabel:i("settings.openchamber.visual.field.terminalQuickKeysAria"),settingsItem:"appearance.terminal-quick-keys",info:i("settings.openchamber.visual.field.terminalQuickKeysTooltip",{control:ua("ctrl"),alt:ua("alt")})})]}),Ne("sessionTabs")&&!Ss&&!d&&s.jsx(js,{title:i("settings.openchamber.visual.field.sessionTabsGroup"),settingsItem:"appearance.session-tabs",children:s.jsx(gt,{checked:at,onChange:pt,label:i("settings.openchamber.visual.field.sessionTabs"),ariaLabel:i("settings.openchamber.visual.field.sessionTabsAria"),info:i("settings.openchamber.visual.field.sessionTabsInfo")})})]}),Sr&&s.jsxs(s.Fragment,{children:[fn&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.chatDisplay"),divider:E,contentClassName:"space-y-6",children:[Ne("chatRenderMode")&&s.jsx(js,{title:i("settings.openchamber.visual.section.chatRenderMode"),settingsItem:"chat.render-mode",children:s.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.chatRenderModeAria"),className:"grid w-full max-w-[26rem] grid-cols-1 gap-3 @xl:grid-cols-2",children:ey.map(j=>{const yt=Z===j.id,gs=gr%12;return s.jsxs("button",{type:"button",onClick:()=>vr(j.id),"aria-pressed":yt,className:Pe("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",yt?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[s.jsx("span",{className:Pe("typography-ui-label",yt?"text-inherit":"text-muted-foreground"),children:l(j.labelKey)}),s.jsx("div",{className:"mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2",children:j.id==="live"?s.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(Es=>{const vn=Es*3+1,ea=gs-vn+1,Ei=ea<=0?0:ea===1?42:ea===2?68:92,Ld=Ei>0;return s.jsxs("div",{className:Pe("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",Ld?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:[s.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55"}),s.jsx("span",{className:"h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none",style:{width:`${Ei}%`}})]},Es)})}):s.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(Es=>{const vn=gs>=(Es+1)*3;return s.jsxs("div",{className:Pe("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",vn?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:[s.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55"}),s.jsx("span",{className:"h-1.5 rounded bg-muted-foreground/30",style:{width:"92%"}})]},Es)})})})]},j.id)})})}),Ne("activityRenderMode")&&s.jsx(js,{title:i("settings.openchamber.visual.section.activityDefault"),settingsItem:"chat.activity-default",children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.section.activityDefaultAria"),children:ty.map(j=>s.jsx(ws,{selected:ue===j.id,onSelect:()=>Xa(j.id),label:l(j.labelKey),ariaLabel:i("settings.openchamber.visual.field.activityDefaultModeAria",{option:l(j.labelKey)})},j.id))})})]}),Vn&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.messageStreamTransport"),divider:fn||E,settingsItem:"chat.message-transport",contentClassName:"space-y-2",children:[s.jsx(mn,{value:ss,options:dc.map(j=>({value:j.id,label:l(j.labelKey)})),onChange:va,"aria-label":i("settings.openchamber.visual.section.messageStreamTransport")}),(()=>{const j=dc.find(yt=>yt.id===ss);return j?.descriptionKey?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l(j.descriptionKey)}):null})()]}),Ia&&s.jsx(qe,{title:i("settings.openchamber.visual.section.chatMessageOptions"),divider:fn||Vn||E,children:s.jsxs(On,{className:"lg:gap-y-6",children:[Ne("userMessageRendering")&&s.jsx(js,{title:i("settings.openchamber.visual.section.userMessageRendering"),children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.section.userMessageRenderingAria"),children:Xv.map(j=>s.jsx(ws,{selected:iy(C)===j.id,onSelect:()=>xr(j.id),label:l(j.labelKey),ariaLabel:i("settings.openchamber.visual.field.userMessageRenderingAria",{option:l(j.labelKey)})},j.id))})}),Ne("mermaidRendering")&&s.jsx(js,{title:i("settings.openchamber.visual.section.mermaidRendering"),children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.section.mermaidRenderingAria"),children:Zv.map(j=>s.jsx(ws,{selected:F===j.id,onSelect:()=>yr(j.id),label:l(j.labelKey),ariaLabel:i("settings.openchamber.visual.field.mermaidRenderingAria",{option:l(j.labelKey)})},j.id))})}),Ne("diffLayout")&&!Ss&&s.jsx(js,{title:i("settings.openchamber.visual.section.diffLayout"),children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.section.diffLayoutAria"),children:Yv.map(j=>s.jsx(ws,{selected:Ke===j.id,onSelect:()=>Fe(j.id),label:l(j.labelKey),ariaLabel:i("settings.openchamber.visual.field.diffLayoutAria",{option:l(j.labelKey)})},j.id))})}),Ne("followUpBehavior")&&s.jsx(js,{title:i("settings.openchamber.visual.section.followUpBehavior"),settingsItem:"chat.follow-up-behavior",children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.section.followUpBehaviorAria"),children:sy.map(j=>s.jsx(ws,{selected:Oe===j.id,onSelect:()=>nt(j.id),label:l(j.labelKey),ariaLabel:i("settings.openchamber.visual.field.followUpBehaviorAria",{option:l(j.labelKey)})},j.id))})}),Ne("inputHistoryScope")&&s.jsx(js,{title:i("settings.openchamber.visual.field.inputHistoryScope"),info:i("settings.openchamber.visual.field.inputHistoryScopeDescription"),settingsItem:"chat.input-history-scope",children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.section.inputHistoryScopeAria"),children:ay.map(j=>s.jsx(ws,{selected:lt===j.id,onSelect:()=>ya(j.id),label:l(j.labelKey),ariaLabel:l(j.labelKey)},j.id))})}),Ne("inputHistoryLimit")&&s.jsx(js,{title:i("settings.openchamber.visual.field.inputHistoryLimit"),description:i("settings.openchamber.visual.field.inputHistoryLimitDescription"),contentClassName:Ps,settingsItem:"chat.input-history-limit",children:s.jsxs("div",{className:Fa,children:[s.jsx(hs,{value:we,onValueChange:Xn,min:vm,max:bm,step:1,className:bs,deferExternalValueWhileFocused:!0,"aria-label":i("settings.openchamber.visual.field.inputHistoryLimitAria")}),s.jsx("span",{className:Oa,children:i("settings.openchamber.visual.field.inputHistoryLimitUnit")})]})})]})}),Cr&&s.jsxs(s.Fragment,{children:[Ne("expandedTools")&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.showToolsOpenedByDefault"),divider:fn||Vn||Ia||E,contentClassName:cs,children:[s.jsx(gt,{checked:Y,onChange:wa,label:i("settings.openchamber.visual.field.bash"),ariaLabel:i("settings.openchamber.visual.field.showExpandedBashToolsAria")}),s.jsx(gt,{checked:be,onChange:wr,label:i("settings.openchamber.visual.field.editTools"),ariaLabel:i("settings.openchamber.visual.field.showExpandedEditToolsAria")})]}),s.jsxs(qe,{title:i("settings.openchamber.visual.section.sessionAssistance"),settingsItem:"chat.session-assistance",contentClassName:cs,children:[s.jsx(gt,{checked:wt,onChange:ln,label:i("settings.openchamber.visual.field.draftStartersVisible"),ariaLabel:i("settings.openchamber.visual.field.draftStartersVisibleAria"),settingsItem:"chat.draft-starters-visible"}),Ne("sessionAssist")&&s.jsxs(s.Fragment,{children:[s.jsx(gt,{checked:m,onChange:v,label:i("settings.openchamber.visual.field.sessionRecap"),ariaLabel:i("settings.openchamber.visual.field.sessionRecapAria"),settingsItem:"chat.session-recap"}),s.jsx(gt,{checked:u,onChange:w,label:i("settings.openchamber.visual.field.sessionSuggestion"),ariaLabel:i("settings.openchamber.visual.field.sessionSuggestionAria"),settingsItem:"chat.session-suggestion"})]}),Ne("subagentReadOnlyBanner")&&s.jsx(gt,{checked:Ie,onChange:Be,label:i("settings.openchamber.visual.field.allowPromptingSubagentSessions"),ariaLabel:i("settings.openchamber.visual.field.allowPromptingSubagentSessionsAria"),settingsItem:"chat.subagent-read-only-banner"})]}),Ne("sessionGoal")&&!Ss&&s.jsxs(qe,{title:i("settings.openchamber.visual.goal.sectionTitle"),info:i("settings.openchamber.visual.goal.description"),contentClassName:cs,children:[s.jsx(gt,{checked:b,onChange:k,label:i("settings.openchamber.visual.field.sessionGoal"),ariaLabel:i("settings.openchamber.visual.field.sessionGoalAria"),settingsItem:"chat.session-goal"}),s.jsxs("div",{"data-settings-item":"chat.session-goal-budget",className:"flex items-center gap-2",children:[s.jsx(gt,{checked:p,onChange:S,disabled:!b,label:i("settings.openchamber.visual.goal.budgetLabel"),ariaLabel:i("settings.openchamber.visual.goal.budgetAria")}),b&&p?s.jsx(hs,{value:N,onValueChange:j=>{typeof j=="number"&&Number.isFinite(j)&&j>0&&I(Math.floor(j))},min:1e3,max:1e8,step:5e4}):null]})]}),Ne("reasoning")&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.reasoning"),settingsItem:"chat.reasoning",contentClassName:cs,children:[s.jsx(gt,{checked:f,onChange:y,label:i("settings.openchamber.visual.field.showReasoningTraces"),ariaLabel:i("settings.openchamber.visual.field.showReasoningTracesAria"),settingsItem:"chat.reasoning-traces"}),f&&s.jsx(gt,{checked:A,onChange:R,label:i("settings.openchamber.visual.field.collapsibleThinkingBlocks"),ariaLabel:i("settings.openchamber.visual.field.collapsibleThinkingBlocksAria")})]}),s.jsx(qe,{title:i("settings.openchamber.visual.section.streaming"),settingsItem:"chat.streaming",contentClassName:cs,children:s.jsx(gt,{checked:T,onChange:x,label:i("settings.openchamber.visual.field.streamingAutoFollow"),ariaLabel:i("settings.openchamber.visual.field.streamingAutoFollowAria"),info:i("settings.openchamber.visual.field.streamingAutoFollowInfo"),settingsItem:"chat.streaming-auto-follow"})}),(Ne("collapsibleUserMessages")||Ne("stickyUserHeader")||Ne("promptNavigatorEnabled")||Ne("wideChatLayout")||Ne("splitAssistantMessageActions")||Ne("codeBlockLineWrap"))&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.messageAppearance"),settingsItem:"chat.message-appearance",contentClassName:cs,children:[Ne("collapsibleUserMessages")&&s.jsx(gt,{checked:U,onChange:ba,label:i("settings.openchamber.visual.field.collapsibleUserMessages"),ariaLabel:i("settings.openchamber.visual.field.collapsibleUserMessagesAria"),settingsItem:"chat.collapsible-user-messages"}),Ne("stickyUserHeader")&&s.jsx(gt,{checked:W,onChange:br,label:i("settings.openchamber.visual.field.stickyUserHeader"),ariaLabel:i("settings.openchamber.visual.field.stickyUserHeaderAria"),settingsItem:"chat.sticky-user-header"}),Ne("promptNavigatorEnabled")&&s.jsx(gt,{checked:X,onChange:ys,label:i("settings.openchamber.visual.field.promptNavigatorEnabled"),ariaLabel:i("settings.openchamber.visual.field.promptNavigatorEnabledAria"),settingsItem:"chat.prompt-navigator"}),Ne("wideChatLayout")&&s.jsx(gt,{checked:se,onChange:Mn,label:i("settings.openchamber.visual.field.wideChatLayout"),ariaLabel:i("settings.openchamber.visual.field.wideChatLayoutAria"),settingsItem:"chat.wide-layout"}),Ne("splitAssistantMessageActions")&&s.jsx(gt,{checked:Nt,onChange:$n,label:i("settings.openchamber.visual.field.showSplitAssistantMessageActions"),ariaLabel:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsAria"),settingsItem:"chat.inline-assistant-actions",info:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip")}),Ne("codeBlockLineWrap")&&s.jsx(gt,{checked:ne,onChange:K,label:i("settings.openchamber.visual.field.codeBlockLineWrap"),ariaLabel:i("settings.openchamber.visual.field.codeBlockLineWrapAria"),settingsItem:"chat.code-block-line-wrap"})]}),(Ne("showToolFileIcons")||Ne("showTurnChangedFiles")||Ne("dotfiles")&&!fs()||Ne("fileViewerPreview"))&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.toolsAndFiles"),settingsItem:"chat.tools-and-files",contentClassName:cs,children:[Ne("showToolFileIcons")&&s.jsx(gt,{checked:Xe,onChange:ds,label:i("settings.openchamber.visual.field.showToolFileIcons"),ariaLabel:i("settings.openchamber.visual.field.showToolFileIconsAria"),settingsItem:"chat.tool-file-icons"}),Ne("showTurnChangedFiles")&&s.jsx(gt,{checked:De,onChange:jr,label:i("settings.openchamber.visual.field.showTurnChangedFiles"),ariaLabel:i("settings.openchamber.visual.field.showTurnChangedFilesAria"),settingsItem:"chat.changed-files"}),Ne("dotfiles")&&!fs()&&s.jsx(gt,{checked:g,onChange:ym,label:i("settings.openchamber.visual.field.showDotfiles"),ariaLabel:i("settings.openchamber.visual.field.showDotfilesAria"),settingsItem:"chat.dotfiles"}),Ne("fileViewerPreview")&&s.jsx(gt,{checked:es,onChange:ja,label:i("settings.openchamber.defaults.field.openFilesPreview"),ariaLabel:i("settings.openchamber.defaults.field.openFilesPreviewAria")})]}),(Ne("persistDraft")||Ne("largeTextPaste")||!d&&Ne("inputSpellcheck")||Ne("enterToSend"))&&s.jsxs(qe,{title:i("settings.openchamber.visual.section.composer"),settingsItem:"chat.composer",contentClassName:"space-y-6",children:[(Ne("persistDraft")||!d&&Ne("inputSpellcheck"))&&s.jsxs("div",{className:cs,children:[Ne("persistDraft")&&s.jsx(gt,{checked:ze,onChange:Ge,label:i("settings.openchamber.visual.field.persistDraftMessages"),ariaLabel:i("settings.openchamber.visual.field.persistDraftMessagesAria"),settingsItem:"chat.persist-drafts"}),!d&&Ne("inputSpellcheck")&&s.jsx(gt,{checked:Q,onChange:_o,label:i("settings.openchamber.visual.field.enableSpellcheckInTextInputs"),ariaLabel:i("settings.openchamber.visual.field.enableSpellcheckInTextInputsAria"),settingsItem:"chat.spellcheck"})]}),Ne("largeTextPaste")&&s.jsx(js,{title:i("settings.openchamber.visual.field.largeTextPaste"),info:i("settings.openchamber.visual.field.largeTextPasteHint"),settingsItem:"chat.large-text-paste",children:s.jsx(tn,{"aria-label":i("settings.openchamber.visual.field.largeTextPasteAria"),children:ny.map(j=>s.jsx(ws,{selected:st===j.id,onSelect:()=>dt(j.id),label:l(j.labelKey),ariaLabel:i("settings.openchamber.visual.field.largeTextPasteOptionAria",{option:l(j.labelKey)})},j.id))})}),Ne("enterToSend")&&s.jsx(js,{title:i("settings.openchamber.visual.field.enterToSend"),info:i("settings.openchamber.visual.field.enterToSendHint"),settingsItem:"chat.enter-to-send",children:s.jsxs(tn,{"aria-label":i("settings.openchamber.visual.field.enterToSend"),children:[s.jsx(ws,{selected:vt,onSelect:()=>cn(!0),label:i("settings.openchamber.visual.option.enterToSend.enter.label"),ariaLabel:i("settings.openchamber.visual.option.enterToSend.enter.label")}),s.jsx(ws,{selected:!vt,onSelect:()=>cn(!1),label:i("settings.openchamber.visual.option.enterToSend.modifier.label"),ariaLabel:i("settings.openchamber.visual.option.enterToSend.modifier.label")})]})})]})]})]}),Ne("reportUsage")&&s.jsx(qe,{title:i("settings.openchamber.visual.section.privacy"),children:s.jsx(gt,{checked:Za,onChange:wi,label:i("settings.openchamber.visual.field.sendAnonymousUsageReports"),info:i("settings.openchamber.visual.field.sendAnonymousUsageReportsHint"),ariaLabel:i("settings.openchamber.visual.field.sendAnonymousUsageReportsAria"),settingsItem:"appearance.usage-reports"})})]})},ly=1,cy=365,pc=30,dy=[{value:"archive",labelKey:"settings.openchamber.sessionRetention.action.archive"},{value:"delete",labelKey:"settings.openchamber.sessionRetention.action.delete"}],Sd=()=>{const t=tt.c(105),{t:e}=Qe(),a=he(uy),n=he(my),r=he(py),i=he(gy),l=he(hy),d=he(fy),c=he(xy);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h={autoRun:!1},t[0]=h):h=t[0];const{candidates:g,isRunning:f,runCleanup:m,action:u,status:v}=Du(h),w=g.length;let b;t[1]!==m||t[2]!==e?(b=async()=>{const me=await m({force:!0}).catch(()=>($.error(e("sessions.sidebar.group.empty.loadFailed")),null));if(!(!me||me.skippedReason&&me.skippedReason!=="no-candidates")){if(me.completedIds.length===0&&me.failedIds.length===0){$.message(me.action==="archive"?e("settings.openchamber.sessionRetention.toast.noneEligibleArchive"):e("settings.openchamber.sessionRetention.toast.noneEligibleDelete"));return}me.completedIds.length>0&&$.success(me.action==="archive"?e("settings.openchamber.sessionRetention.toast.archivedCount",{count:me.completedIds.length}):e("settings.openchamber.sessionRetention.toast.deletedCount",{count:me.completedIds.length})),me.failedIds.length>0&&$.error(me.action==="archive"?e("settings.openchamber.sessionRetention.toast.failedArchiveCount",{count:me.failedIds.length}):e("settings.openchamber.sessionRetention.toast.failedDeleteCount",{count:me.failedIds.length}))}},t[1]=m,t[2]=e,t[3]=b):b=t[3];const k=b;let p;t[4]!==e?(p=e("settings.openchamber.sessionRetention.title"),t[4]=e,t[5]=p):p=t[5];const S=r?"settings.openchamber.sessionRetention.archivedTooltip":"settings.openchamber.sessionRetention.tooltip";let N;t[6]!==e||t[7]!==S?(N=e(S),t[6]=e,t[7]=S,t[8]=N):N=t[8];let I;t[9]!==e?(I=e("settings.openchamber.sessionRetention.field.enableAutoCleanup"),t[9]=e,t[10]=I):I=t[10];let y;t[11]!==e?(y=e("settings.openchamber.sessionRetention.field.enableAutoCleanupAria"),t[11]=e,t[12]=y):y=t[12];let T;t[13]!==a||t[14]!==i||t[15]!==I||t[16]!==y?(T=s.jsx(gt,{settingsItem:"sessions.auto-cleanup",checked:a,onChange:i,label:I,ariaLabel:y}),t[13]=a,t[14]=i,t[15]=I,t[16]=y,t[17]=T):T=t[17];let x;t[18]!==e?(x=e("settings.openchamber.sessionRetention.field.onlyArchived"),t[18]=e,t[19]=x):x=t[19];let A;t[20]!==e?(A=e("settings.openchamber.sessionRetention.field.onlyArchived"),t[20]=e,t[21]=A):A=t[21];let R;t[22]!==e?(R=e("settings.openchamber.sessionRetention.field.onlyArchivedDescription"),t[22]=e,t[23]=R):R=t[23];let P;t[24]!==f||t[25]!==r||t[26]!==c||t[27]!==R||t[28]!==x||t[29]!==A?(P=s.jsx(gt,{settingsItem:"sessions.retention-only-archived",checked:r,onChange:c,disabled:f,label:x,ariaLabel:A,info:R}),t[24]=f,t[25]=r,t[26]=c,t[27]=R,t[28]=x,t[29]=A,t[30]=P):P=t[30];let D;t[31]!==e?(D=e("settings.openchamber.sessionRetention.field.retentionPeriod"),t[31]=e,t[32]=D):D=t[32];let F;t[33]!==e?(F=e("settings.openchamber.sessionRetention.field.retentionPeriodAria"),t[33]=e,t[34]=F):F=t[34];let O;t[35]===Symbol.for("react.memo_cache_sentinel")?(O=Pe(bs,"tabular-nums"),t[35]=O):O=t[35];let C;t[36]!==n||t[37]!==l||t[38]!==F?(C=s.jsx(hs,{value:n,onValueChange:l,min:ly,max:cy,step:1,"aria-label":F,className:O}),t[36]=n,t[37]=l,t[38]=F,t[39]=C):C=t[39];let M;t[40]!==e?(M=e("settings.openchamber.sessionRetention.field.days"),t[40]=e,t[41]=M):M=t[41];let U;t[42]!==M?(U=s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:M}),t[42]=M,t[43]=U):U=t[43];let L;t[44]!==l?(L=()=>l(pc),t[44]=l,t[45]=L):L=t[45];const W=n===pc;let X;t[46]!==e?(X=e("settings.openchamber.sessionRetention.actions.resetRetentionAria"),t[46]=e,t[47]=X):X=t[47];let J;t[48]!==e?(J=e("settings.common.actions.reset"),t[48]=e,t[49]=J):J=t[49];let q;t[50]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(_,{name:"restart",className:"h-3.5 w-3.5"}),t[50]=q):q=t[50];let z;t[51]!==L||t[52]!==W||t[53]!==X||t[54]!==J?(z=s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:L,disabled:W,className:us,"aria-label":X,title:J,children:q}),t[51]=L,t[52]=W,t[53]=X,t[54]=J,t[55]=z):z=t[55];let H;t[56]!==D||t[57]!==C||t[58]!==U||t[59]!==z?(H=s.jsxs(It,{settingsItem:"sessions.retention-period",label:D,children:[C,U,z]}),t[56]=D,t[57]=C,t[58]=U,t[59]=z,t[60]=H):H=t[60];let se;t[61]!==e?(se=e("settings.openchamber.sessionRetention.field.whenSessionsExpire"),t[61]=e,t[62]=se):se=t[62];let B;t[63]!==r||t[64]!==e?(B=dy.map(me=>({value:me.value,label:e(me.labelKey),disabled:r&&me.value==="archive"})),t[63]=r,t[64]=e,t[65]=B):B=t[65];let ne;t[66]!==u||t[67]!==d||t[68]!==B?(ne=s.jsx(mn,{value:u,onChange:d,options:B}),t[66]=u,t[67]=d,t[68]=B,t[69]=ne):ne=t[69];let K;t[70]!==se||t[71]!==ne?(K=s.jsx(It,{settingsItem:"sessions.retention-action",label:se,children:ne}),t[70]=se,t[71]=ne,t[72]=K):K=t[72];let Z;t[73]!==P||t[74]!==H||t[75]!==K?(Z=s.jsxs(Qa,{className:"space-y-0",children:[P,H,K]}),t[73]=P,t[74]=H,t[75]=K,t[76]=Z):Z=t[76];let oe;t[77]!==e?(oe=e("settings.openchamber.sessionRetention.manualCleanup.title"),t[77]=e,t[78]=oe):oe=t[78];let ue;t[79]!==f||t[80]!==e?(ue=e(f?"settings.openchamber.sessionRetention.actions.cleaningUp":"settings.openchamber.sessionRetention.actions.runCleanupNow"),t[79]=f,t[80]=e,t[81]=ue):ue=t[81];let de;t[82]!==k||t[83]!==f||t[84]!==ue?(de=s.jsx(G,{type:"button",variant:"outline",size:"xs",onClick:k,disabled:f,className:"!font-normal",children:ue}),t[82]=k,t[83]=f,t[84]=ue,t[85]=de):de=t[85];let ce;t[86]!==oe||t[87]!==de?(ce=s.jsx(It,{label:oe,children:de}),t[86]=oe,t[87]=de,t[88]=ce):ce=t[88];let Se;t[89]!==u||t[90]!==w||t[91]!==v||t[92]!==e?(Se=v==="error"?e("sessions.sidebar.group.empty.loadFailed"):v!=="ready"?e("sessions.sidebar.group.empty.loadingSessions"):u==="archive"?e("settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow",{count:w}):e("settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow",{count:w}),t[89]=u,t[90]=w,t[91]=v,t[92]=e,t[93]=Se):Se=t[93];let re;t[94]!==Se?(re=s.jsx("p",{className:"typography-meta text-muted-foreground",children:Se}),t[94]=Se,t[95]=re):re=t[95];let ve;t[96]!==ce||t[97]!==re?(ve=s.jsxs("div",{className:"mt-1 py-1.5 space-y-1",children:[ce,re]}),t[96]=ce,t[97]=re,t[98]=ve):ve=t[98];let ie;return t[99]!==p||t[100]!==Z||t[101]!==ve||t[102]!==N||t[103]!==T?(ie=s.jsxs(qe,{title:p,info:N,children:[T,Z,ve]}),t[99]=p,t[100]=Z,t[101]=ve,t[102]=N,t[103]=T,t[104]=ie):ie=t[104],ie};function uy(t){return t.autoDeleteEnabled}function my(t){return t.autoDeleteAfterDays}function py(t){return t.sessionRetentionOnlyArchived}function gy(t){return t.setAutoDeleteEnabled}function hy(t){return t.setAutoDeleteAfterDays}function fy(t){return t.setSessionRetentionAction}function xy(t){return t.setSessionRetentionOnlyArchived}const gc=(t,e,a)=>!t||!Number.isFinite(t)?e:new Intl.DateTimeFormat(wo(),{dateStyle:"medium",timeStyle:"short",hour12:a==="auto"?void 0:a==="12h"}).format(t),Cd=()=>{const{t}=Qe(),e=he(T=>T.timeFormatPreference),[a,n]=o.useState(!1),[r,i]=o.useState(!0),[l,d]=o.useState(!1),[c,h]=o.useState(null),[g,f]=o.useState(!1),[m,u]=o.useState([]),[v,w]=o.useState(Mu),[b,k]=o.useState(""),p=o.useMemo(()=>Ru(),[]),S=o.useCallback(async()=>{i(!0),k("");try{const T=await Fu();u(T)}catch(T){const x=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.loadFailed");k(x)}finally{i(!1)}},[t]);o.useEffect(()=>{let T=!1;return(async()=>{try{if(!p.supported){T||(n(!1),i(!1));return}T||n(!0)}catch{T||n(!1)}if(!T){const x=await Tr();if(w(x),!x.enabled){u([]),i(!1);return}await S()}})(),()=>{T=!0,Qo()}},[S,p.supported]);const N=o.useCallback(async()=>{if(!v.enabled){const T=t("settings.openchamber.passkeys.toast.enableUiPasswordFirst");k(T),$.message(T);return}if(!a){k(p.reason),$.message(p.reason);return}if(l){Qo(),d(!1);return}k(""),d(!0);try{await Ou(),w(await Tr()),await S(),$.success(t("settings.openchamber.passkeys.toast.added"))}catch(T){if(Lu(T)){$.message(t("settings.openchamber.passkeys.toast.setupCanceled"));return}const x=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.addFailed");k(x),$.error(x)}finally{d(!1)}},[l,S,v.enabled,p.reason,a,t]),I=o.useCallback(async T=>{h(T),k("");try{await Ku(T),w(await Tr()),await S(),$.success(t("settings.openchamber.passkeys.toast.removed"))}catch(x){const A=x instanceof Error?x.message:t("settings.openchamber.passkeys.toast.removeFailed");k(A),$.error(A)}finally{h(null)}},[S,t]),y=o.useCallback(async()=>{f(!0),k("");try{await zu(),window.location.reload()}catch(T){const x=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.clearAuthFailed");k(x),$.error(x),f(!1)}},[t]);return s.jsxs(qe,{title:t("settings.openchamber.passkeys.title"),children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(It,{label:t("settings.openchamber.passkeys.field.currentDevice"),children:[s.jsx(G,{type:"button",variant:l?"secondary":"outline",size:"xs",onClick:()=>{N()},disabled:r||g,className:"!font-normal",children:t(l?"settings.openchamber.passkeys.actions.cancelSetup":"settings.openchamber.passkeys.actions.add")}),s.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:()=>{y()},disabled:r||l||g,className:"!font-normal text-muted-foreground hover:text-foreground",children:t(g?"settings.openchamber.passkeys.actions.signingOut":"settings.openchamber.passkeys.actions.signOutEverywhere")})]}),!v.enabled&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.uiPasswordRequired")}),v.enabled&&!a&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:p.reason}),r?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.loading")}):m.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.noneSaved")}):s.jsx("div",{className:"space-y-1 pt-1",children:m.map(T=>s.jsxs(It,{label:s.jsx("span",{title:T.label,children:T.label}),alignEnd:!1,controlClassName:"justify-between sm:flex-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:T.lastUsedAt?t("settings.openchamber.passkeys.item.lastUsed",{time:gc(T.lastUsedAt,t("settings.openchamber.passkeys.time.neverUsed"),e)}):t("settings.openchamber.passkeys.item.added",{time:gc(T.createdAt,t("settings.openchamber.passkeys.time.neverUsed"),e)})}),s.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:()=>{I(T.id)},disabled:c===T.id,className:"!font-normal text-muted-foreground hover:text-foreground",children:c===T.id?t("settings.openchamber.passkeys.actions.removing"):t("settings.common.actions.delete")})]},T.id))})]}),b&&s.jsx("div",{className:"mt-1 py-1.5",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:b})})]})},Id=()=>{const t=tt.c(14),{t:e}=Qe(),a=Yo(by),n=Yo(vy);let r;t[0]!==e?(r=e("settings.openchamber.appLinks.title"),t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e?(i=e("settings.openchamber.appLinks.info"),t[2]=e,t[3]=i):i=t[3];let l;t[4]!==n||t[5]!==e||t[6]!==a?(l=a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.appLinks.empty")}):a.map(h=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-[13px]",children:`${h}://`}),s.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:()=>n(h),className:"!font-normal text-muted-foreground hover:text-foreground","aria-label":e("settings.openchamber.appLinks.removeAria",{scheme:`${h}://`}),children:e("settings.common.actions.delete")})]},h)),t[4]=n,t[5]=e,t[6]=a,t[7]=l):l=t[7];let d;t[8]!==l?(d=s.jsx("div",{className:"space-y-1","data-settings-item":"general.app-links",children:l}),t[8]=l,t[9]=d):d=t[9];let c;return t[10]!==r||t[11]!==i||t[12]!==d?(c=s.jsx(qe,{title:r,description:i,children:d}),t[10]=r,t[11]=i,t[12]=d,t[13]=c):c=t[13],c};function by(t){return t.trustedSchemes}function vy(t){return t.removeTrustedScheme}const yy=()=>{const{t}=Qe(),[e,a]=o.useState(null),n=o.useRef(0);o.useEffect(()=>{let i=!1;return Ms.getConfig(null).then(l=>{!i&&n.current===0&&a(!!l.warming)},l=>console.warn("[session-warming] failed to read config",l)),()=>{i=!0}},[]);const r=o.useCallback(async i=>{const l=e,d=++n.current;a(i),os("saving");try{const c=await St("/api/config/warming",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({enabled:i})});if(!c.ok)throw new Error(`HTTP ${c.status}`);os("saved"),Ms.clearConfigCache()}catch(c){console.warn("[session-warming] failed to save",c),os("error"),d===n.current&&a(l)}},[e]);return s.jsx(gt,{settingsItem:"sessions.warming",checked:e??!1,disabled:e===null,onChange:i=>{r(i)},label:t("settings.openchamber.defaults.field.sessionWarming"),info:t("settings.openchamber.defaults.field.sessionWarmingInfo")})},Wr=t=>{const e=zn(t);return e||{providerId:"",modelId:""}},Pd=()=>{const{t}=Qe(),e=rt(re=>re.setProvider),a=rt(re=>re.setModel),n=rt(re=>re.setAgent),r=rt(re=>re.setCurrentVariant),i=rt(re=>re.setCurrentVariantOverride),l=rt(re=>re.setSettingsDefaultModel),d=rt(re=>re.setSettingsDefaultVariant),c=rt(re=>re.setSettingsDefaultAgent),h=rt(re=>re.selectionSource==="manual"),g=Uu(re=>re.currentSessionId),f=Zo(re=>re.getSessionModelSelection),m=Zo(re=>re.getSessionAgentSelection),u=rt(re=>re.agentSelectionSource==="manual"),w=!!(rt(re=>{if(re.agentSelectionSource!=="manual")return!1;const ve=re.agents.find(ie=>ie.name===re.currentAgentName);return!!(ve?.model?.providerID&&ve.model.id)})||h&&g&&f(g)),b=!!(u&&g&&m(g)),k=he(re=>re.showDeletionDialog),p=he(re=>re.setShowDeletionDialog),S=rt(re=>re.providers),N=rt(re=>re.modelsMetadata),[I,y]=o.useState(),[T,x]=o.useState(),[A,R]=o.useState(),[P,D]=o.useState(!0),[F,O]=o.useState(),[C,M]=o.useState([]),[U,L]=o.useState(),[W,X]=o.useState(!0),J=o.useMemo(()=>Wr(I),[I]);o.useEffect(()=>{(async()=>{try{const ve=await En();if(ve){const ie=ve.defaultModel?.trim()||void 0,me=ve.defaultVariant?.trim()||void 0,ke=ve.defaultAgent?.trim()||void 0;ie!==void 0&&y(ie),me!==void 0&&x(me),ke!==void 0&&R(ke),ve.smallModelUseDefault!==void 0&&D(ve.smallModelUseDefault);const Ae=ve.smallModelOverride?.trim();Ae&&O(Ae);const pe=ve.walkthroughModelOverride?.trim();pe&&L(pe)}}catch(ve){console.warn("Failed to load defaults settings:",ve)}finally{X(!1)}})()},[]);const q=o.useCallback(async(re,ve)=>{const ie=re&&ve?`${re}/${ve}`:void 0;y(ie),x(void 0),d(void 0),l(ie),w||(r(void 0),re&&ve&&(S.find(ke=>ke.id===re)||Wc(re,ve))&&(e(re),a(ve)));try{await xt({defaultModel:ie??"",defaultVariant:""})}catch(me){console.warn("Failed to save default model:",me)}},[w,S,r,a,e,l,d]),z="__default__",H=o.useCallback(re=>re===z?t("settings.openchamber.defaults.option.default"):re.charAt(0).toUpperCase()+re.slice(1),[t]),se=o.useCallback(async re=>{const ve=re===z?void 0:re||void 0;x(ve),d(ve),w||i(ve??null,ve);try{await xt({defaultVariant:ve??""})}catch(ie){console.warn("Failed to save default variant:",ie)}},[w,i,d]),B=o.useCallback(async re=>{const ve=re||void 0;R(ve),c(ve),re&&!b&&n(re);try{await xt({defaultAgent:ve??""})}catch(ie){console.warn("Failed to save default agent:",ie)}},[b,n,c]),ne=o.useCallback(async re=>{D(re);try{await xt({smallModelUseDefault:re})}catch(ve){console.warn("Failed to save small model preference:",ve)}},[]),K=o.useCallback(async(re,ve)=>{const ie=re&&ve?`${re}/${ve}`:void 0;O(ie);try{await xt({smallModelOverride:ie??""})}catch(me){console.warn("Failed to save small model override:",me)}},[]),Z=o.useCallback(async(re,ve)=>{const ie=re&&ve?`${re}/${ve}`:void 0;L(ie);try{await xt({walkthroughModelOverride:ie??""})}catch(me){console.warn("Failed to save walkthrough model override:",me)}},[]),oe=o.useCallback((re,ve)=>N.get(`${re}/${ve}`)?.structured_output!==!1,[N]),ue=o.useMemo(()=>Wr(F),[F]),de=o.useMemo(()=>Wr(U),[U]);o.useEffect(()=>{let re=!1;return(async()=>{try{const ve=await St("/api/small-model",{method:"GET",headers:{Accept:"application/json"}});if(!ve.ok)return;const ie=await ve.json().catch(()=>null);!re&&Array.isArray(ie?.authenticatedProviders)&&M(ie.authenticatedProviders.filter(me=>typeof me=="string"))}catch{}})(),()=>{re=!0}},[]);const ce=o.useMemo(()=>{if(!J.providerId||!J.modelId)return[];const ve=S.find(ie=>ie.id===J.providerId)?.models.find(ie=>ie.id===J.modelId);return _u(ve?.variants)},[J.modelId,J.providerId,S]),Se=ce.length>0;return W?null:s.jsx(s.Fragment,{children:s.jsx(qe,{title:t("settings.openchamber.defaults.title"),divider:!1,children:s.jsxs("div",{className:"space-y-0",children:[s.jsxs("div",{className:"mt-0 mb-1 typography-meta text-muted-foreground",children:[t("settings.openchamber.defaults.summaryPrefix")," ",J.providerId?s.jsxs("span",{className:"text-foreground",children:[J.providerId,"/",J.modelId,Se?` (${T??t("settings.openchamber.defaults.option.defaultLowercase")})`:""]}):s.jsx("span",{className:"text-foreground",children:t("settings.openchamber.defaults.summaryOpenCodeDefault")}),A&&s.jsxs(s.Fragment,{children:[" / ",s.jsx("span",{className:"text-foreground",children:A})]})]}),s.jsxs("div",{children:[s.jsx(It,{settingsItem:"sessions.default-model",label:t("settings.openchamber.defaults.field.defaultModel"),children:s.jsx(ca,{providerId:J.providerId,modelId:J.modelId,onChange:q,className:Ws,offerAuto:!0})}),s.jsx(It,{settingsItem:"sessions.default-thinking",label:t("settings.openchamber.defaults.field.defaultThinking"),children:s.jsxs(Et,{value:T??z,onValueChange:se,disabled:!Se,children:[s.jsx(At,{size:Bt,className:nn,children:s.jsx($t,{placeholder:t("settings.openchamber.defaults.field.thinkingPlaceholder"),children:H(T??z)})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:z,children:t("settings.openchamber.defaults.option.default")}),ce.map(re=>s.jsx(ut,{value:re,children:H(re)},re))]})]})}),s.jsx(It,{settingsItem:"sessions.default-agent",label:t("settings.openchamber.defaults.field.defaultAgent"),children:s.jsx(bo,{agentName:A||"",onChange:B,filter:re=>Kc(re.mode),className:Ws})})]}),s.jsxs(Qa,{className:cs,children:[s.jsx(gt,{settingsItem:"sessions.deletion-dialog",checked:k,onChange:p,label:t("settings.openchamber.defaults.field.showDeletionDialog"),ariaLabel:t("settings.openchamber.defaults.field.showDeletionDialogAria")}),s.jsx(yy,{})]}),s.jsxs("div",{className:"space-y-3 pt-6",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{children:t("settings.openchamber.defaults.smallModel.title")}),s.jsx(Gt,{children:t("settings.openchamber.defaults.smallModel.description")})]}),s.jsx(gt,{settingsItem:"sessions.small-model",checked:P,onChange:re=>{ne(re)},label:t("settings.openchamber.defaults.smallModel.useDefault"),ariaLabel:t("settings.openchamber.defaults.smallModel.useDefaultAria")}),P?null:s.jsx(It,{label:t("settings.openchamber.defaults.smallModel.overrideModel"),children:s.jsx(ca,{providerId:ue.providerId,modelId:ue.modelId,onChange:K,allowedProviderIds:C,className:Ws})}),s.jsxs(Qa,{className:cs,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{children:t("settings.openchamber.defaults.walkthroughModel.title")}),s.jsx(Gt,{children:t("settings.openchamber.defaults.walkthroughModel.description")})]}),s.jsx(It,{settingsItem:"sessions.walkthrough-model",label:t("settings.openchamber.defaults.walkthroughModel.overrideModel"),children:s.jsx(ca,{providerId:de.providerId,modelId:de.modelId,onChange:Z,allowedProviderIds:C,isModelAllowed:oe,placeholder:t("settings.openchamber.defaults.walkthroughModel.usesSmallModel"),className:Ws})})]})]})]})})})},hc={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"}},jy={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"},wy=()=>{const{t}=Qe(),e=o.useMemo(()=>ls(),[]),a=o.useMemo(()=>fs(),[]),n=o.useMemo(()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",[]),r=!e&&!a&&!n,i=he(z=>z.nativeNotificationsEnabled),l=he(z=>z.setNativeNotificationsEnabled),d=he(z=>z.notificationMode),c=he(z=>z.setNotificationMode),h=he(z=>z.notifyOnSubtasks),g=he(z=>z.setNotifyOnSubtasks),f=he(z=>z.notifyOnCompletion),m=he(z=>z.setNotifyOnCompletion),u=he(z=>z.notifyOnError),v=he(z=>z.setNotifyOnError),w=he(z=>z.notifyOnQuestion),b=he(z=>z.setNotifyOnQuestion),k=he(z=>z.notificationTemplates),p=he(z=>z.setNotificationTemplates),[S,N]=o.useState("default"),[I,y]=o.useState(!1),[T,x]=o.useState(!1),[A,R]=o.useState(!1);o.useEffect(()=>{if(!r){y(!1),x(!1);return}typeof Notification<"u"&&N(Notification.permission);const z=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;y(z),(async()=>{if(!z){x(!1);return}try{const se=await navigator.serviceWorker.getRegistration();if(!se){x(!1);return}const B=await se.pushManager.getSubscription();x(!!B)}catch{x(!1)}})()},[r]);const P=async z=>{if(e){l(z);return}if(!r){l(z);return}if(z&&typeof Notification<"u"&&Notification.permission==="default")try{const H=await Notification.requestPermission();N(H),H==="granted"?l(!0):$.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.description")})}catch(H){console.error("Failed to request notification permission:",H),$.error(t("settings.notifications.page.toast.requestPermissionFailed"))}else l(!!(z&&S==="granted"))},D=e||a||n||r&&typeof Notification<"u"&&Notification.permission==="granted",F=(z,H,se)=>{p(B=>({...B,[z]:{...B[z],[H]:se}}))},O=z=>{const H="=".repeat((4-z.length%4)%4),se=(z+H).replace(/-/g,"+").replace(/_/g,"/"),B=atob(se),ne=new Uint8Array(B.length);for(let K=0;K<B.length;K+=1)ne[K]=B.charCodeAt(K);return ne},C=async(z,H,se)=>{let B=null;const ne=new Promise((K,Z)=>{B=setTimeout(()=>{Z(new Error(se))},H)});try{return await Promise.race([z,ne])}finally{B&&clearTimeout(B)}},M=async z=>{if(z.active)return;const H=z.installing||z.waiting;H&&H.state!=="activated"&&await C(new Promise(se=>{const B=()=>{H.state==="activated"&&(H.removeEventListener("statechange",B),se())};H.addEventListener("statechange",B),B()}),15e3,"Service worker activation timed out")},U=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const z=[{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:"/"}}];let H=null;for(const se of z)try{const B=se.opts?navigator.serviceWorker.register("/sw.js",se.opts):navigator.serviceWorker.register("/sw.js");return await C(B,1e4,`Service worker registration timed out (${se.label})`)}catch(B){H=B}throw H instanceof Error?H:new Error("Service worker registration failed")},L=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const z=await navigator.serviceWorker.getRegistration();if(z)return z;const H=await U();try{await H.update()}catch{}return await M(H),H},W=z=>{const H=z,se=[`type=${typeof z}`,`toString=${String(z)}`,`name=${String(H?.name??"")}`,`message=${String(H?.message??"")}`];let B="";try{B=JSON.stringify(z)}catch{}return{summary:se.filter(Boolean).join(" | "),json:B,stack:typeof H?.stack=="string"?H.stack:""}},X=async()=>{const z=Ha();if(!z?.notifications){$.error(t("settings.notifications.page.toast.notificationsApiUnavailable"));return}try{await z.notifications.notifyAgentCompletion({title:t("settings.notifications.page.testNotification.title"),body:t("settings.notifications.page.testNotification.body"),tag:"openchamber-test"})?$.success(t("settings.notifications.page.toast.testNotificationSent")):$.error(t("settings.notifications.page.toast.testNotificationFailed"))}catch(H){console.error("Test notification failed:",H),$.error(t("settings.notifications.page.toast.testNotificationFailed"))}},J=async()=>{if(!I){$.error(t("settings.notifications.page.toast.pushUnsupported"));return}const z=Ha();if(!z?.push){$.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}R(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const ue=await Notification.requestPermission();if(N(ue),ue!=="granted"){$.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){$.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}const H=await z.push.getVapidPublicKey();if(!H?.publicKey){$.error(t("settings.notifications.page.toast.pushKeyLoadFailed"));return}const se=await L();await M(se);const B=await se.pushManager.getSubscription();if(!("pushManager"in se)||!se.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const K=(B??await C(se.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:O(H.publicKey)}),15e3,"Push subscription timed out")).toJSON(),Z=K.keys;if(!K.endpoint||!Z?.p256dh||!Z.auth)throw new Error("Push subscription missing keys");if(!(await C(z.push.subscribe({endpoint:K.endpoint,keys:{p256dh:Z.p256dh,auth:Z.auth},origin:typeof window<"u"?window.location.origin:void 0,platform:jm()}),15e3,"Push subscribe request timed out"))?.ok){$.error(t("settings.notifications.page.toast.enableBackgroundFailed"));return}x(!0),$.success(t("settings.notifications.page.toast.backgroundEnabled"))}catch(H){console.error("[Push] Enable failed:",H);const se=W(H);$.error(t("settings.notifications.page.toast.enableBackgroundFailed"),{description:se.summary})}finally{R(!1)}},q=async()=>{if(!I){x(!1);return}const z=Ha();if(!z?.push){$.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}R(!0);try{const se=await(await L()).pushManager.getSubscription();if(!se){x(!1);return}const B=se.endpoint;await se.unsubscribe(),await z.push.unsubscribe({endpoint:B}),x(!1),$.success(t("settings.notifications.page.toast.backgroundDisabled"))}finally{R(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs(qe,{settingsItem:"notifications.delivery",title:t("settings.notifications.page.delivery.title"),divider:!1,children:[s.jsxs("div",{className:cs,children:[s.jsx(gt,{checked:i&&D,onChange:z=>{P(z)},label:t("settings.notifications.page.delivery.enableLabel"),info:r?t("settings.notifications.page.delivery.browserPermissionHint"):a?t("settings.notifications.page.delivery.vscodeHint"):void 0,ariaLabel:t("settings.notifications.page.delivery.enableAria")}),i&&D&&!n&&s.jsxs(s.Fragment,{children:[s.jsx(gt,{checked:d==="always",onChange:z=>c(z?"always":"hidden-only"),label:t("settings.notifications.page.delivery.focusedLabel"),ariaLabel:t("settings.notifications.page.delivery.focusedAria")}),s.jsx("div",{className:"py-2",children:s.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{X()},children:t("settings.notifications.page.delivery.testAction")})})]})]}),r&&s.jsxs("div",{className:"mt-1",children:[S==="denied"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:t("settings.notifications.page.delivery.permissionDenied")}),S==="granted"&&!i&&s.jsx("p",{className:"typography-meta text-muted-foreground/70 mt-1",children:t("settings.notifications.page.delivery.permissionGrantedButDisabled")})]})]}),i&&D&&s.jsxs(s.Fragment,{children:[s.jsx(qe,{settingsItem:"notifications.events",title:t("settings.notifications.page.events.title"),children:s.jsxs("div",{className:cs,children:[s.jsx(gt,{checked:f,onChange:m,label:t("settings.notifications.page.events.completionLabel"),ariaLabel:t("settings.notifications.page.events.completionAria")}),s.jsx(gt,{checked:h,onChange:g,label:t("settings.notifications.page.events.subtaskLabel"),ariaLabel:t("settings.notifications.page.events.subtaskAria")}),s.jsx(gt,{checked:u,onChange:v,label:t("settings.notifications.page.events.errorLabel"),ariaLabel:t("settings.notifications.page.events.errorAria")}),s.jsx(gt,{checked:w,onChange:b,label:t("settings.notifications.page.events.questionLabel"),ariaLabel:t("settings.notifications.page.events.questionAria")})]})}),!n&&s.jsx(qe,{title:t("settings.notifications.page.template.title"),description:s.jsxs(s.Fragment,{children:[t("settings.notifications.page.template.variablesLabel")," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{project_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{worktree}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{branch}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{session_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{agent_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{model_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{last_message}"})]}),children:s.jsx(On,{className:"gap-2 md:grid-cols-2 md:gap-3 lg:gap-3",children:["completion","subtask","error","question"].map(z=>s.jsxs("section",{className:"p-2",children:[s.jsx(An,{className:"capitalize",children:t(jy[z])}),s.jsxs("div",{className:"mt-1.5 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.title")}),s.jsx(He,{value:k[z].title,onChange:H=>F(z,"title",H.target.value),className:"h-7",placeholder:t(hc[z].titleKey)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.message")}),s.jsx(He,{value:k[z].message,onChange:H=>F(z,"message",H.target.value),className:"h-7",placeholder:t(hc[z].messageKey)})]})]})]},z))})})]}),r&&s.jsx(qe,{settingsItem:"notifications.push",title:t("settings.notifications.page.push.title"),children:s.jsx(gt,{checked:I?T:!1,disabled:!I||A,onChange:z=>{z?J():q()},label:t("settings.notifications.page.push.enableLabel"),description:I?void 0:t("settings.notifications.page.push.unsupportedHint"),info:I?t("settings.notifications.page.push.supportedHint"):void 0,ariaLabel:t("settings.notifications.page.push.enableAria"),labelAccessory:A?s.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground animate-busy-pulse","aria-label":t("settings.notifications.page.push.loadingAria")}):null})})]})},Ds=t=>{if(!t)return;t.pause();const{src:e}=t;e.startsWith("blob:")&&URL.revokeObjectURL(e),t.removeAttribute("src"),t.load()},Fn="oc-surface-elevated w-full h-7 rounded-lg border border-input bg-surface-elevated px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring focus:border-interactive-border-focus",ky=[{id:"parakeet-tdt-0.6b-v2-int8",labelKey:"settings.voice.page.stt.model.parakeetV2",badgeKey:"settings.voice.page.stt.badge.bestForEnglish",accuracy:5,speed:5,size:"460 MB"},{id:"parakeet-tdt-0.6b-v3-int8",labelKey:"settings.voice.page.stt.model.parakeetV3",badgeKey:"settings.voice.page.stt.badge.bestForMultilingual",accuracy:5,speed:4,size:"465 MB"},{id:"whisper-base-int8",labelKey:"settings.voice.page.stt.model.whisperBase",badgeKey:null,accuracy:3,speed:3,size:"200 MB"},{id:"whisper-tiny-int8",labelKey:"settings.voice.page.stt.model.whisperTiny",badgeKey:null,accuracy:2,speed:4,size:"115 MB"}],fc=t=>{const e=tt.c(8),{value:a,label:n}=t,r=`${n}: ${a}/5`,i=`${a/5*100}%`;let l;e[0]!==i?(l=s.jsx("span",{className:"h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]","aria-hidden":"true",children:s.jsx("span",{className:"block h-full rounded-full bg-[var(--primary-base)]",style:{width:i}})}),e[0]=i,e[1]=l):l=e[1];let d;e[2]!==n?(d=s.jsx("span",{className:"typography-ui-compact text-muted-foreground",children:n}),e[2]=n,e[3]=d):d=e[3];let c;return e[4]!==r||e[5]!==l||e[6]!==d?(c=s.jsxs("span",{className:"flex items-center gap-1.5",title:r,children:[l,d]}),e[4]=r,e[5]=l,e[6]=d,e[7]=c):c=e[7],c},Ny=({selectedModelId:t,onSelect:e})=>{const{t:a}=Qe(),n=et.useCallback(m=>a(m),[a]),[r,i]=et.useState(new Map),[l,d]=et.useState(null),c=et.useCallback(async()=>{try{const m=await St("/api/dictation/status",{query:{provider:"local"}});if(!m.ok)return;const u=await m.json();Array.isArray(u?.models)&&i(new Map(u.models.map(v=>[v.id,v])))}catch{}},[]);et.useEffect(()=>{c()},[c]);const h=Array.from(r.values()).some(m=>m.downloading);et.useEffect(()=>{if(!h)return;const m=setInterval(()=>{c()},2e3);return()=>clearInterval(m)},[h,c]);const g=async m=>{d(m);try{await St(`/api/dictation/models/${encodeURIComponent(m)}/download`,{method:"POST"}),await c()}catch{}finally{d(null)}},f=async m=>{d(m);try{await St(`/api/dictation/models/${encodeURIComponent(m)}`,{method:"DELETE"}),await c()}catch{}finally{d(null)}};return s.jsx("div",{role:"radiogroup","aria-label":a("settings.voice.page.field.model"),className:"mt-1.5 grid w-full grid-cols-1 gap-3 @xl:grid-cols-2",children:ky.map(m=>{const u=t===m.id,v=r.get(m.id)??null;return s.jsx("div",{className:Pe("rounded-lg border border-[var(--interactive-border)] p-3",u&&"border-border bg-interactive-selection text-interactive-selection-foreground"),children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 cursor-pointer items-start gap-2",role:"button",tabIndex:0,onClick:()=>e(m.id),onKeyDown:w=>{(w.key===" "||w.key==="Enter")&&(w.preventDefault(),e(m.id))},children:[s.jsx("div",{className:"pt-0.5",children:s.jsx(vo,{checked:u,onChange:()=>e(m.id),ariaLabel:n(m.labelKey)})}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:Pe("typography-ui-label font-normal",u?"text-foreground":"text-foreground/50"),children:n(m.labelKey)}),m.badgeKey?s.jsx("span",{className:"rounded border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-1 text-[9px] font-medium uppercase leading-[14px] tracking-wide text-[var(--status-success)]",children:n(m.badgeKey)}):null]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(fc,{value:m.accuracy,label:a("settings.voice.page.stt.meta.accuracy")}),s.jsx(fc,{value:m.speed,label:a("settings.voice.page.stt.meta.speed")}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:m.size})]}),v?.downloadError?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:v.downloadError}):null]})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:v?.installed?s.jsxs(s.Fragment,{children:[s.jsx(G,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:l===m.id,onClick:()=>{f(m.id)},title:a("settings.voice.page.stt.modelDelete"),"aria-label":a("settings.voice.page.stt.modelDelete"),children:s.jsx(_,{name:"delete-bin",className:"h-4 w-4"})}),s.jsx(_,{name:"checkbox-circle",className:"h-4 w-4 flex-shrink-0 text-[var(--status-success)]","aria-label":a("settings.voice.page.stt.modelInstalled")})]}):v?.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(_,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof v.downloadProgress=="number"?`${v.downloadProgress}%`:""})]}):s.jsx(G,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:l===m.id,onClick:()=>{g(m.id)},title:a("settings.voice.page.stt.modelDownload"),"aria-label":a("settings.voice.page.stt.modelDownload"),children:s.jsx(_,{name:"download",className:"h-4 w-4"})})})]})},m.id)})})},Sy=[{id:0,label:"Alloy (af)"},{id:1,label:"Bella (af)"},{id:2,label:"Nicole (af)"},{id:3,label:"Sarah (af)"},{id:4,label:"Sky (af)"},{id:5,label:"Adam (am)"},{id:6,label:"Michael (am)"},{id:7,label:"Emma (bf)"},{id:8,label:"Isabella (bf)"},{id:9,label:"George (bm)"},{id:10,label:"Lewis (bm)"}],po="kokoro-en-v0_19",Cy="kokoro-multi-lang-v1_1",Iy=[{id:0,label:"Maple (af)"},{id:1,label:"Sol (af)"},{id:2,label:"Vale (bf)"},{id:3,label:"Xiaoxiao (zf)"},{id:58,label:"Yunxi (zm)"}],ii=(t,e)=>`${t}:${e}`,Py=()=>{const[t,e]=et.useState([]),[a,n]=et.useState(null),r=et.useCallback(async()=>{try{const d=await St("/api/dictation/status",{query:{provider:"local"}});if(!d.ok)return;const c=await d.json();Array.isArray(c?.ttsModels)&&e(c.ttsModels)}catch{}},[]);et.useEffect(()=>{r()},[r]);const i=t.some(d=>d.downloading);et.useEffect(()=>{if(!i)return;const d=setInterval(()=>{r()},2e3);return()=>clearInterval(d)},[i,r]);const l=et.useCallback(async(d,c)=>{n(d);try{const h=c==="POST"?`/api/dictation/models/${d}/download`:`/api/dictation/models/${d}`;await St(h,{method:c}),await r()}catch{}finally{n(null)}},[r]);return{models:t,requestingId:a,request:l,refresh:r}},Ay=t=>{const e=Sy.map(a=>({modelId:po,speakerId:a.id,label:a.label}));for(const a of t)if(!(a.id===po||!a.installed)){if(a.id===Cy){for(const n of Iy)e.push({modelId:a.id,speakerId:n.id,label:`${n.label} · Kokoro zh/en`});continue}e.push({modelId:a.id,speakerId:0,label:a.description??a.id})}return e},Ty=t=>{const e=tt.c(14),{models:a,requestingId:n,request:r}=t,{t:i}=Qe();let l,d,c;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==i){c=Symbol.for("react.early_return_sentinel");e:{const g=a.filter(My);if(g.length===0){c=null;break e}l="flex flex-col";let f;e[7]!==r||e[8]!==n||e[9]!==i?(f=m=>s.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:m.description??m.id}),m.installed?s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]","aria-label":i("settings.voice.page.stt.modelInstalled")}),s.jsx(G,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:n!==null,onClick:()=>{r(m.id,"DELETE")},title:i("settings.voice.page.stt.modelDelete"),"aria-label":i("settings.voice.page.stt.modelDelete"),children:s.jsx(_,{name:"delete-bin",className:"h-4 w-4"})})]}):m.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(_,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof m.downloadProgress=="number"?`${m.downloadProgress}%`:""})]}):s.jsx(G,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:n!==null,onClick:()=>{r(m.id,"POST")},title:i("settings.voice.page.stt.modelDownload"),"aria-label":i("settings.voice.page.stt.modelDownload"),children:s.jsx(_,{name:"download",className:"h-4 w-4"})}),m.downloadError?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:m.downloadError}):null]},m.id),e[7]=r,e[8]=n,e[9]=i,e[10]=f):f=e[10],d=g.map(f)}e[0]=a,e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=d,e[6]=c}else l=e[4],d=e[5],c=e[6];if(c!==Symbol.for("react.early_return_sentinel"))return c;let h;return e[11]!==l||e[12]!==d?(h=s.jsx("div",{className:l,children:d}),e[11]=l,e[12]=d,e[13]=h):h=e[13],h},Ey=[{value:"alloy",label:"Alloy"},{value:"ash",label:"Ash"},{value:"ballad",label:"Ballad"},{value:"coral",label:"Coral"},{value:"echo",label:"Echo"},{value:"fable",label:"Fable"},{value:"nova",label:"Nova"},{value:"onyx",label:"Onyx"},{value:"sage",label:"Sage"},{value:"shimmer",label:"Shimmer"},{value:"verse",label:"Verse"},{value:"marin",label:"Marin"},{value:"cedar",label:"Cedar"}],Dy=()=>{const{t}=Qe(),{isMobile:e}=Zn(),a=rt(Q=>Q.voiceProvider),n=rt(Q=>Q.setVoiceProvider),r=rt(Q=>Q.speechRate),i=rt(Q=>Q.setSpeechRate),l=rt(Q=>Q.speechPitch),d=rt(Q=>Q.setSpeechPitch),c=rt(Q=>Q.speechVolume),h=rt(Q=>Q.setSpeechVolume),g=rt(Q=>Q.sayVoice),f=rt(Q=>Q.setSayVoice),m=rt(Q=>Q.localTtsVoiceId),u=rt(Q=>Q.localTtsModelId),v=rt(Q=>Q.setLocalTtsModelId),w=Py(),b=et.useMemo(()=>Ay(w.models),[w.models]),k=rt(Q=>Q.ttsFollowTextLanguage),p=rt(Q=>Q.setTtsFollowTextLanguage),S=rt(Q=>Q.setLocalTtsVoiceId),{speak:N,stop:I,isPlaying:y,error:T}=$u(),x=et.useCallback(()=>{if(y){I();return}const Q=b.find(Ue=>Ue.modelId===u&&Ue.speakerId===m)?.label??String(m);N(t("settings.voice.page.preview.voiceLine",{voiceName:Q}),{model:u,speakerId:m,speed:rt.getState().speechRate})},[y,u,m,b,N,I,t]),A=rt(Q=>Q.browserVoice),R=rt(Q=>Q.setBrowserVoice),P=rt(Q=>Q.openaiVoice),D=rt(Q=>Q.setOpenaiVoice),F=rt(Q=>Q.openaiApiKey),O=rt(Q=>Q.setOpenaiApiKey),C=rt(Q=>Q.openaiCompatibleUrl),M=rt(Q=>Q.setOpenaiCompatibleUrl),U=rt(Q=>Q.openaiCompatibleApiKey),L=rt(Q=>Q.setOpenaiCompatibleApiKey),W=rt(Q=>Q.openaiCompatibleVoice),X=rt(Q=>Q.setOpenaiCompatibleVoice),J=rt(Q=>Q.openaiCompatibleTtsModel),q=rt(Q=>Q.setOpenaiCompatibleTtsModel),z=rt(Q=>Q.showMessageTTSButtons),H=rt(Q=>Q.ttsInputMode),se=rt(Q=>Q.setTtsInputMode),B=rt(Q=>Q.sttProvider),ne=rt(Q=>Q.setSttProvider),K=rt(Q=>Q.sttServerUrl),Z=rt(Q=>Q.setSttServerUrl),oe=rt(Q=>Q.sttApiKey),ue=rt(Q=>Q.setSttApiKey),de=rt(Q=>Q.sttModel),ce=rt(Q=>Q.setSttModel),Se=rt(Q=>Q.sttLocalModel),re=rt(Q=>Q.setSttLocalModel),ve=rt(Q=>Q.sttLanguage),ie=rt(Q=>Q.setSttLanguage),me=rt(Q=>Q.setShowMessageTTSButtons),ke=rt(Q=>Q.dictationEnabled),Ae=rt(Q=>Q.setDictationEnabled),[pe,Le]=et.useState(!1),[Ve,ye]=et.useState([]),[Te,ee]=et.useState(!1),[ae,fe]=et.useState(null),[je,Re]=et.useState(!1),[Ce,_e]=et.useState(!1),[Ke,Fe]=et.useState(null),[Me,at]=et.useState(!1),[pt,ot]=et.useState(null),[mt,ht]=et.useState([]),[Oe,nt]=et.useState(!1);et.useEffect(()=>((async()=>{const Ue=await Er.waitForVoices();ht(Ue)})(),"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=()=>{ht(window.speechSynthesis.getVoices())}),()=>{"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);const lt=et.useMemo(()=>mt.filter(Q=>Q.lang).sort((Q,Ue)=>{const st=Q.lang.startsWith("en"),dt=Ue.lang.startsWith("en");if(st&&!dt)return-1;if(!st&&dt)return 1;const ct=Q.lang.localeCompare(Ue.lang);return ct!==0?ct:Q.name.localeCompare(Ue.name)}),[mt]),we=et.useCallback(()=>{if(Oe){Er.cancelSpeech(),nt(!1);return}const Q=mt.find(ct=>ct.name===A),Ue=Q?.name??t("settings.voice.page.preview.browserVoiceFallback"),st=t("settings.voice.page.preview.voiceLine",{voiceName:Ue});nt(!0);const dt=new SpeechSynthesisUtterance(st);dt.rate=r,dt.pitch=l,dt.volume=c,Q&&(dt.voice=Q,dt.lang=Q.lang),dt.onend=()=>nt(!1),dt.onerror=()=>nt(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(dt)},[A,mt,r,l,c,Oe,t]);et.useEffect(()=>()=>{Oe&&Er.cancelSpeech()},[Oe]),et.useEffect(()=>{if(!z||a!=="openai"&&a!=="openai-compatible"){Re(F.trim().length>0);return}(async()=>{try{const dt=(await(await St("/api/tts/status")).json()).available,ct=F.trim().length>0;Re(dt||ct)}catch{Re(F.trim().length>0)}})()},[F,z,a]),et.useEffect(()=>{if(!z){Le(!1),ye([]);return}St("/api/tts/say/status").then(Q=>Q.json()).then(Q=>{if(Le(Q.available),Q.voices){const Ue=Q.voices.filter((st,dt,ct)=>ct.findIndex(ft=>ft.name===st.name)===dt).sort((st,dt)=>st.name.localeCompare(dt.name));ye(Ue)}}).catch(()=>{Le(!1)})},[z]);const Je=et.useCallback(async()=>{if(ae){Ds(ae),fe(null),ee(!1);return}ee(!0);let Q=null;try{const Ue=await St("/api/tts/say/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:g}),voice:g,rate:Math.round(100+(r-.5)*200)})});if(!Ue.ok)throw new Error("Preview failed");const st=await Ue.blob(),dt=URL.createObjectURL(st);Q=new Audio(dt),Q.onended=()=>{Ds(Q),fe(null),ee(!1)},Q.onerror=()=>{Ds(Q),fe(null),ee(!1)},fe(Q),await Q.play()}catch{Ds(Q),fe(null),ee(!1)}},[g,r,ae,t]);et.useEffect(()=>()=>{Ds(ae)},[ae]);const Ye=et.useCallback(async()=>{if(Ke){Ds(Ke),Fe(null),_e(!1);return}_e(!0);let Q=null;try{const Ue=await St("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:P}),voice:P,speed:r,apiKey:F||void 0})});if(!Ue.ok){const ct=await Ue.json().catch(()=>({error:"Unknown error"}));throw new Error(ct.error||`HTTP ${Ue.status}`)}const st=await Ue.blob(),dt=URL.createObjectURL(st);Q=new Audio(dt),Q.onended=()=>{Ds(Q),Fe(null),_e(!1)},Q.onerror=()=>{Ds(Q),Fe(null),_e(!1)},Fe(Q),await Q.play()}catch{Ds(Q),Fe(null),_e(!1)}},[P,r,Ke,F,t]);et.useEffect(()=>()=>{Ds(Ke)},[Ke]);const ze=et.useCallback(async()=>{if(pt){Ds(pt),ot(null),at(!1);return}if(!C.trim())return;at(!0);let Q=null;try{const Ue=await St("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.customServerLine"),voice:W,model:J||void 0,speed:r,baseURL:C,apiKey:U||void 0})});if(!Ue.ok){const ct=await Ue.json().catch(()=>({error:"Unknown error"}));throw new Error(ct.error||`HTTP ${Ue.status}`)}const st=await Ue.blob(),dt=URL.createObjectURL(st);Q=new Audio(dt),Q.onended=()=>{Ds(Q),ot(null),at(!1)},Q.onerror=()=>{Ds(Q),ot(null),at(!1)},ot(Q),await Q.play()}catch{Ds(Q),ot(null),at(!1)}},[C,W,J,U,r,pt,t]);et.useEffect(()=>()=>{Ds(pt)},[pt]);const Ge="flex-1 min-w-0 h-1.5 bg-[var(--interactive-border)] rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:border-0 disabled:opacity-50";return s.jsxs(s.Fragment,{children:[s.jsxs(qe,{settingsItem:"voice.playback",title:t("settings.voice.page.section.playbackAndSummary"),divider:!1,contentClassName:"space-y-4",children:[s.jsx(gt,{checked:z,onChange:me,label:t("settings.voice.page.field.messageReadAloudButton"),ariaLabel:t("settings.voice.page.field.messageReadAloudButtonAria")}),z&&s.jsxs(s.Fragment,{children:[s.jsx(js,{title:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.browser")})," ",t("settings.voice.page.tooltip.browser")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.localTts")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.openai")})," ",t("settings.voice.page.tooltip.openai")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.custom")})," ",t("settings.voice.page.tooltip.custom")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.say")})," ",t("settings.voice.page.tooltip.say")]})]}),children:s.jsx(mn,{value:a,onChange:n,"aria-label":t("settings.voice.page.field.provider"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"browser",label:t("settings.voice.page.provider.browser")},{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai",label:t("settings.voice.page.provider.openai")},{value:"openai-compatible",label:t("settings.voice.page.provider.custom")},...pe?[{value:"say",label:s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"apple",className:"mr-0.5 h-3.5 w-3.5"}),t("settings.voice.page.provider.say")]})}]:[]]})}),a==="openai"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Pe(Ct,!je&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.apiKey")}),s.jsx("span",{className:Pe(vs,!je&&"text-[var(--status-error)]/80"),children:t(je&&!F?"settings.voice.page.field.apiKeyHintUsingConfig":je?"settings.voice.page.field.apiKeyHintProvide":"settings.voice.page.field.apiKeyHintRequired")}),s.jsxs("div",{className:Pe("relative",Ps),children:[s.jsx("input",{type:"password",value:F,onChange:Q=>O(Q.target.value),placeholder:"sk-...",className:Fn}),F&&s.jsx("button",{type:"button",onClick:()=>O(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"w-3.5 h-3.5"})})]})]}),a==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Pe(Ct,!C.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),s.jsx(Gt,{children:t("settings.voice.page.field.serverUrlHint")})]}),s.jsxs("div",{className:Pe("relative",Ps),children:[s.jsx("input",{type:"text",value:C,onChange:Q=>M(Q.target.value),placeholder:"http://localhost:8880/v1",className:Fn}),C&&s.jsx("button",{type:"button",onClick:()=>M(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:"API Key"}),s.jsx("span",{className:vs,children:"Optional"}),s.jsxs("div",{className:Pe("relative",Ps),children:[s.jsx("input",{type:"password",value:U,onChange:Q=>L(Q.target.value),placeholder:"sk-...",className:Fn}),U&&s.jsx("button",{type:"button",onClick:()=>L(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.model")}),s.jsx("div",{className:Pe("relative",Ps),children:s.jsx("input",{type:"text",value:J,onChange:Q=>q(Q.target.value),placeholder:"speaches-ai/Kokoro-82M-v1.0-ONNX",className:Fn})})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.voice")}),s.jsx(Gt,{children:t("settings.voice.page.field.voiceIdentifierHint")})]}),s.jsxs("div",{className:Pe("flex items-center gap-2",Ps),children:[s.jsx("div",{className:"relative min-w-0 flex-1",children:s.jsx("input",{type:"text",value:W,onChange:Q=>X(Q.target.value),placeholder:"af_sky",className:Fn})}),s.jsx(G,{size:"xs",variant:"ghost",onClick:ze,title:t("settings.voice.page.actions.preview"),disabled:!C.trim(),children:Me?s.jsx(_,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(_,{name:"play",className:"w-3.5 h-3.5"})})]})]})]}),a==="local"&&s.jsx(Ty,{...w}),(a==="local"||a==="say")&&s.jsx(gt,{checked:k,onChange:p,label:t("settings.voice.page.field.followTextLanguage"),ariaLabel:t("settings.voice.page.field.followTextLanguageAria"),info:t("settings.voice.page.field.followTextLanguageInfo")}),s.jsxs(It,{label:t("settings.voice.page.field.voice"),children:[a==="local"&&s.jsxs(s.Fragment,{children:[s.jsxs(Et,{value:ii(u,m),onValueChange:Q=>{const Ue=b.find(st=>ii(st.modelId,st.speakerId)===Q);Ue&&(v(Ue.modelId),S(Ue.speakerId))},children:[s.jsx(At,{size:Bt,className:nn,children:s.jsx($t,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder"),children:Q=>b.find(Ue=>ii(Ue.modelId,Ue.speakerId)===Q)?.label??Q})}),s.jsx(Tt,{children:b.map(Q=>s.jsx(ut,{value:ii(Q.modelId,Q.speakerId),children:Q.label},ii(Q.modelId,Q.speakerId)))})]}),s.jsx(G,{size:"xs",variant:"ghost",onClick:x,title:t("settings.voice.page.actions.preview"),children:y?s.jsx(_,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(_,{name:"play",className:"w-3.5 h-3.5"})}),T?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:T}):null]}),a==="openai"&&je&&s.jsxs(s.Fragment,{children:[s.jsxs(Et,{value:P,onValueChange:D,children:[s.jsx(At,{size:Bt,className:nn,children:s.jsx($t,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder")})}),s.jsx(Tt,{children:Ey.map(Q=>s.jsx(ut,{value:Q.value,children:Q.label},Q.value))})]}),s.jsx(G,{size:"xs",variant:"ghost",onClick:Ye,title:t("settings.voice.page.actions.preview"),children:Ce?s.jsx(_,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(_,{name:"play",className:"w-3.5 h-3.5"})})]}),a==="openai-compatible"&&s.jsx("span",{className:vs,children:t("settings.voice.page.field.configuredAbove")}),a==="say"&&pe&&Ve.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Et,{value:g,onValueChange:f,children:[s.jsx(At,{size:Bt,className:nn,children:s.jsx($t,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder")})}),s.jsx(Tt,{children:Ve.map(Q=>s.jsx(ut,{value:Q.name,children:Q.name},Q.name))})]}),s.jsx(G,{size:"xs",variant:"ghost",onClick:Je,title:t("settings.voice.page.actions.preview"),children:Te?s.jsx(_,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(_,{name:"play",className:"w-3.5 h-3.5"})})]}),a==="browser"&&lt.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Et,{value:A||"$auto",onValueChange:Q=>R(Q==="$auto"?"":Q),children:[s.jsx(At,{size:Bt,className:nn,children:s.jsx($t,{placeholder:t("settings.voice.page.field.auto")})}),s.jsxs(Tt,{children:[s.jsx(ut,{value:"$auto",children:t("settings.voice.page.field.auto")}),lt.map(Q=>s.jsxs(ut,{value:Q.name,children:[Q.name," (",Q.lang,")"]},Q.name))]})]}),s.jsx(G,{size:"xs",variant:"ghost",onClick:we,title:t("settings.voice.page.actions.preview"),children:Oe?s.jsx(_,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(_,{name:"play",className:"w-3.5 h-3.5"})})]})]}),s.jsxs(It,{label:t("settings.voice.page.field.speechRate"),children:[!e&&s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:r,onChange:Q=>i(Number(Q.target.value)),className:Ge}),s.jsx(hs,{value:r,onValueChange:i,min:.5,max:2,step:.1,className:Pe(bs,"tabular-nums")})]}),s.jsxs(It,{label:t("settings.voice.page.field.speechPitch"),children:[!e&&s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:l,onChange:Q=>d(Number(Q.target.value)),className:Ge}),s.jsx(hs,{value:l,onValueChange:d,min:.5,max:2,step:.1,className:Pe(bs,"tabular-nums")})]}),s.jsxs(It,{label:t("settings.voice.page.field.speechVolume"),children:[!e&&s.jsx("input",{type:"range",min:0,max:1,step:.1,value:c,onChange:Q=>h(Number(Q.target.value)),className:Ge}),e?s.jsx(hs,{value:Math.round(c*100),onValueChange:Q=>h(Q/100),min:0,max:100,step:10,className:Pe(bs,"tabular-nums")}):s.jsxs("span",{className:"typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right",children:[Math.round(c*100),"%"]})]}),s.jsx(js,{title:t("settings.voice.page.field.ttsInputMode"),children:s.jsx(mn,{value:H,onChange:se,"aria-label":t("settings.voice.page.field.ttsInputMode"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"sanitized",label:t("settings.voice.page.field.ttsInputModeSanitized")},{value:"raw",label:t("settings.voice.page.field.ttsInputModeRaw")},{value:"summarized",label:t("settings.voice.page.field.ttsInputModeSummarized")}]})})]})]}),s.jsxs(qe,{settingsItem:"voice.speech-recognition",title:t("settings.voice.page.section.speechRecognition"),contentClassName:"space-y-4",children:[s.jsx(gt,{checked:ke,onChange:Ae,label:t("settings.voice.page.field.enableVoiceInput"),ariaLabel:t("settings.voice.page.field.enableVoiceInputAria")}),ke&&s.jsxs(s.Fragment,{children:[s.jsx(js,{title:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.sttLocal")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.server")})," ",t("settings.voice.page.tooltip.sttServer")]})]}),children:s.jsx(mn,{value:B,onChange:ne,"aria-label":t("settings.voice.page.field.provider"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai-compatible",label:t("settings.voice.page.provider.server")}]})}),B==="local"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.model")}),s.jsx(Ny,{selectedModelId:Se,onSelect:re})]}),B==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Pe(Ct,!K.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),s.jsx(Gt,{children:t("settings.voice.page.field.sttServerUrlHint")})]}),s.jsxs("div",{className:Pe("relative",Ps),children:[s.jsx("input",{type:"text",value:K,onChange:Q=>Z(Q.target.value),placeholder:"http://localhost:8001/v1",className:Fn}),K&&s.jsx("button",{type:"button",onClick:()=>Z(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:"API Key"}),s.jsx("span",{className:vs,children:"Optional"}),s.jsxs("div",{className:Pe("relative",Ps),children:[s.jsx("input",{type:"password",value:oe,onChange:Q=>ue(Q.target.value),placeholder:"sk-...",className:Fn}),oe&&s.jsx("button",{type:"button",onClick:()=>ue(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.model")}),s.jsx("div",{className:Pe("relative",Ps),children:s.jsx("input",{type:"text",value:de,onChange:Q=>ce(Q.target.value),placeholder:"deepdml/faster-whisper-large-v3-turbo-ct2",className:Fn})})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.language")}),s.jsx(Gt,{children:t("settings.voice.page.field.sttLanguageHint")})]}),s.jsx("div",{className:"relative max-w-[8rem]",children:s.jsx("input",{type:"text",value:ve,onChange:Q=>ie(Q.target.value),placeholder:"auto",className:Fn})})]})]})]})]})]})};function My(t){return t.id===po||t.installed||t.downloading}const $i=[{value:"1800000",label:"30m",ms:1800*1e3},{value:"180000",label:"3m",ms:180*1e3},{value:"7200000",label:"2h",ms:7200*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3}],Bi=[{value:"3600000",label:"1h",ms:3600*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"43200000",label:"12h",ms:720*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3},{value:"604800000",label:"1w",ms:10080*60*1e3},{value:"2592000000",label:"30d",ms:720*60*60*1e3}],Ry="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",Fy="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",Jr=[{value:"quick",labelKey:"settings.openchamber.tunnel.option.mode.quick.label",tooltipKey:"settings.openchamber.tunnel.option.mode.quick.tooltip"},{value:"managed-remote",labelKey:"settings.openchamber.tunnel.option.mode.managedRemote.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedRemote.tooltip"},{value:"managed-local",labelKey:"settings.openchamber.tunnel.option.mode.managedLocal.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedLocal.tooltip"}],Oy=[".yml",".yaml",".json"],Ly="settings.openchamber.tunnel.error.invalidConfigExtension",ri=t=>{const e=t.trim().toLowerCase();return Oy.some(a=>e.endsWith(a))},Ky=t=>t==="ngrok"?"ngrok":"cloudflared",Ad=()=>{if(typeof window<"u"&&typeof window.__OPENCHAMBER_PLATFORM__=="string"){const e=window.__OPENCHAMBER_PLATFORM__;if(e==="win32"||e==="darwin"||e==="linux")return e}const t=typeof navigator<"u"?`${navigator.platform||""} ${navigator.userAgent||""}`.toLowerCase():"";return t.includes("win")?"win32":t.includes("mac")?"darwin":"linux"},zy=(t,e=Ad())=>t==="ngrok"?e==="win32"?"winget install ngrok -s msstore":e==="darwin"?"brew install ngrok":"https://ngrok.com/download":e==="win32"?"winget install --id Cloudflare.cloudflared":e==="darwin"?"brew install cloudflared":"https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/",Qr=(t,e)=>{const a=typeof e?.provider=="string"&&e.provider.trim().length>0?e.provider.trim().toLowerCase():t,n=typeof e?.dependency=="string"&&e.dependency.trim().length>0?e.dependency.trim():Ky(a),r=typeof e?.platform=="string"&&e.platform.trim().length>0?e.platform.trim():Ad(),i=typeof e?.installCommand=="string"&&e.installCommand.trim().length>0?e.installCommand.trim():zy(a,r);return{provider:a,dependency:n,installCommand:i}},Td=t=>t==="cloudflare"?"Cloudflare":t==="ngrok"?"Ngrok":t,xc=t=>{const e=tt.c(11),{provider:a}=t;let n;e[0]!==a?(n=Td(a),e[0]=a,e[1]=n):n=e[1];const r=n,d=a==="cloudflare"||a==="ngrok"?"text-[var(--status-warning)]":"text-muted-foreground";let c;e[2]!==d?(c=Pe("size-4 shrink-0",d),e[2]=d,e[3]=c):c=e[3];let h;e[4]!==c?(h=s.jsx(_,{name:"cloud",className:c}),e[4]=c,e[5]=h):h=e[5];let g;e[6]!==r?(g=s.jsx("span",{children:r}),e[6]=r,e[7]=g):g=e[7];let f;return e[8]!==h||e[9]!==g?(f=s.jsxs("span",{className:"flex items-center gap-2",children:[h,g]}),e[8]=h,e[9]=g,e[10]=f):f=e[10],f},Gn=t=>t==="quick"?"quick":t==="managed-remote"?"managed-remote":t==="managed-local"?"managed-local":"quick",go=(t,e,a)=>t.find(r=>r.ms===e)?.value||a,bc=(t,e,a)=>{const n=go(t,e,a);return t.find(r=>r.value===n)?.label||n},vc=t=>{const e=Math.max(0,t),a=Math.floor(e/1e3),n=Math.floor(a/3600),r=Math.floor(a%3600/60),i=a%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`},Uy=(t,e)=>Rc(t,e,{hour:"2-digit",precision:"second"}),Ji=t=>{const e=t.trim();if(!e)return"";try{return(e.includes("://")?new URL(e):new URL(`https://${e}`)).hostname.trim().toLowerCase()}catch{return e.toLowerCase()}},_y=t=>{if(!Array.isArray(t))return[];const e=new Set,a=new Set,n=[];for(const r of t){if(!r||typeof r!="object")continue;const i=r,l=typeof i.id=="string"?i.id.trim():"",d=typeof i.name=="string"?i.name.trim():"",c=Ji(typeof i.hostname=="string"?i.hostname:"");!l||!d||!c||e.has(l)||a.has(c)||(e.add(l),a.add(c),n.push({id:l,name:d,hostname:c}))}return n},$y=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,By=()=>{const{t}=Qe(),e=he(Y=>Y.timeFormatPreference),a=o.useCallback(Y=>t(Y),[t]),[n,r]=o.useState("checking"),[i,l]=o.useState(null),[d,c]=o.useState(null),[h,g]=o.useState(null),[f,m]=o.useState(null),[u,v]=o.useState(null),[w,b]=o.useState(!1),[k,p]=o.useState(!1),[S,N]=o.useState(!1),[I,y]=o.useState("cloudflare"),[T,x]=o.useState(()=>Qr("cloudflare")),[A,R]=o.useState([]),[P,D]=o.useState("quick"),[F,O]=o.useState(null),[C,M]=o.useState([]),[U,L]=o.useState({}),[W,X]=o.useState(""),[J,q]=o.useState({}),[z,H]=o.useState(new Set),[se,B]=o.useState(!1),[ne,K]=o.useState(""),[Z,oe]=o.useState(""),[ue,de]=o.useState(""),[ce,Se]=o.useState(1800*1e3),[re,ve]=o.useState(480*60*1e3),[ie,me]=o.useState(""),[ke,Ae]=o.useState([]),[pe,Le]=o.useState(()=>Date.now()),[Ve,ye]=o.useState(null),Te=t(Ly),ee=o.useRef(null),ae=o.useMemo(()=>F?!ri(F):!1,[F]),fe=o.useMemo(()=>C.find(Y=>Y.id===W)||C[0]||null,[C,W]),je=o.useMemo(()=>ke.map(Y=>{const V=Y.expiresAt<=pe,be=Y.status==="active"&&!V,ge=be?vc(Y.expiresAt-pe):Y.inactiveReason==="expired"||V?"expired":"inactive",Ee=ge==="expired"?t("settings.openchamber.tunnel.state.expired"):Y.inactiveReason==="tunnel-revoked"?t("settings.openchamber.tunnel.state.revoked"):t("settings.openchamber.tunnel.state.inactive"),te=Gn(Y.mode);return{...Y,isActive:be,mode:te,remainingTextForSession:ge,inactiveLabel:Ee}}),[pe,ke,t]),Re=o.useMemo(()=>i?.connectUrl?i.bootstrapExpiresAt===null?!0:i.bootstrapExpiresAt>pe:!1,[pe,i?.bootstrapExpiresAt,i?.connectUrl]),Ce=o.useMemo(()=>!i||n!=="active"&&n!=="stopping"?!1:d===P,[d,n,i,P]),_e=o.useMemo(()=>!i||n!=="active"||!d?!1:d!==P,[d,n,i,P]),Ke=o.useMemo(()=>{if(typeof Ve=="number"&&Number.isFinite(Ve)&&Ve>0)return Ve;if(typeof window>"u")return null;const V=hi()||window.location.href;let be=0;try{be=Number(new URL(V).port)}catch{be=Number(window.location.port)}return Number.isFinite(be)&&be>0?be:null},[Ve]),Fe=o.useMemo(()=>A.find(Y=>Y.provider===I)??null,[A,I]),Me=o.useMemo(()=>{const Y=new Set(Fe?.modes?.map(V=>V.key).filter(V=>V==="quick"||V==="managed-remote"||V==="managed-local"));return Y.size===0?Jr:Jr.filter(V=>Y.has(V.value))},[Fe]),at=o.useMemo(()=>Me.some(Y=>Y.value==="managed-remote"||Y.value==="managed-local"),[Me]),pt=o.useMemo(()=>T.provider===I?T:Qr(I),[T,I]),ot=o.useCallback(async Y=>{await jn(Y)},[]),mt=o.useCallback((Y,V)=>(x(Qr(V,Y)),Y.available===!0),[]),ht=o.useCallback(async(Y,V)=>{try{const be=await St("/api/openchamber/tunnel/check",{query:{provider:Y},...V?{signal:V}:{}});if(!be.ok)return null;const ge=await be.json();if(V?.aborted)return null;const Ee=mt(ge,Y);return r(te=>te==="checking"||te==="starting"||te==="active"||te==="stopping"?te:Ee?"idle":"not-available"),Ee}catch{return null}},[mt]),Oe=o.useCallback(async Y=>{try{const[V,be,ge,Ee]=await Promise.all([St("/api/openchamber/tunnel/check",{signal:Y}),St("/api/openchamber/tunnel/status",{signal:Y}),En(),St("/api/openchamber/tunnel/providers",{signal:Y})]),te=await V.json(),xe=await be.json(),Ze=ge??{},Nt=Ee.ok?await Ee.json():{},Lt=xe.ttlConfig?.bootstrapTtlMs??(Ze.tunnelBootstrapTtlMs===void 0?1800*1e3:Ze.tunnelBootstrapTtlMs),Ie=typeof xe.ttlConfig?.sessionTtlMs=="number"?xe.ttlConfig.sessionTtlMs:Ze.tunnelSessionTtlMs??480*60*1e3,Be=Gn(xe.mode??Ze.tunnelMode),wt=Ze.tunnelProvider??"cloudflare",Pt=Ze.managedLocalTunnelConfigPath??null,Qt=mt(te,wt),Xt=_y(xe?.managedRemoteTunnelPresets),ss=typeof xe.managedRemoteTunnelHostname=="string"?xe.managedRemoteTunnelHostname:"",es=Xt.length>0?Xt:ss?[{id:`legacy-${Ji(ss)}`,name:ss,hostname:Ji(ss)}]:[],Ls=es[0]?.id||"";if(Se(Lt),ve(Ie),y(wt),R(Array.isArray(Nt?.providers)?Nt.providers:[]),D(Be),O(Pt),M(es),X(Ls),Ae(Array.isArray(xe.activeSessions)?xe.activeSessions:[]),c(xe.activeTunnelMode?Gn(xe.activeTunnelMode):xe.active&&xe.mode?Gn(xe.mode):null),H(new Set(Array.isArray(xe.managedRemoteTunnelTokenPresetIds)?xe.managedRemoteTunnelTokenPresetIds:[])),ye(typeof xe.localPort=="number"?xe.localPort:null),xe.active&&xe.url){l({url:xe.url,connectUrl:null,bootstrapExpiresAt:typeof xe.bootstrapExpiresAt=="number"?xe.bootstrapExpiresAt:null}),r("active");return}r(Qt?"idle":"not-available")}catch{Y.aborted||(r("error"),m(t("settings.openchamber.tunnel.toast.checkAvailabilityFailed")))}},[mt,t]);o.useEffect(()=>{const Y=new AbortController;return Oe(Y.signal),()=>Y.abort()},[Oe]),o.useEffect(()=>{if(!i?.connectUrl){g(null);return}let Y=!1;return Qc.toDataURL(i.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(V=>{Y||g(V)}).catch(()=>{Y||g(null)}),()=>{Y=!0}},[i?.connectUrl]),o.useEffect(()=>{if(!i?.bootstrapExpiresAt){me(t("settings.openchamber.tunnel.state.noExpiry"));return}let Y=null,V=Date.now();const be=()=>{const te=i.bootstrapExpiresAt?i.bootstrapExpiresAt-Date.now():0;te<=0?me(t("settings.openchamber.tunnel.state.expired")):me(vc(te))},ge=()=>{const te=Date.now();te-V>=1e3&&(be(),V=te),Y=requestAnimationFrame(ge)};be(),(typeof document>"u"||document.visibilityState==="visible")&&(Y=requestAnimationFrame(ge));const Ee=()=>{document.visibilityState==="visible"&&Y===null?Y=requestAnimationFrame(ge):document.visibilityState!=="visible"&&Y!==null&&(cancelAnimationFrame(Y),Y=null)};return document.addEventListener("visibilitychange",Ee),()=>{document.removeEventListener("visibilitychange",Ee),Y!==null&&cancelAnimationFrame(Y)}},[t,i?.bootstrapExpiresAt]),o.useEffect(()=>{let Y=null,V=Date.now();const be=()=>{const Ee=Date.now();Ee-V>=1e3&&(Le(Ee),V=Ee),Y=requestAnimationFrame(be)};(typeof document>"u"||document.visibilityState==="visible")&&(Y=requestAnimationFrame(be));const ge=()=>{document.visibilityState==="visible"&&Y===null?Y=requestAnimationFrame(be):document.visibilityState!=="visible"&&Y!==null&&(cancelAnimationFrame(Y),Y=null)};return document.addEventListener("visibilitychange",ge),()=>{document.removeEventListener("visibilitychange",ge),Y!==null&&cancelAnimationFrame(Y)}},[]),o.useEffect(()=>{if(n==="starting"||n==="stopping"||n==="checking")return;let Y=!1;const V=async()=>{try{const ge=await St("/api/openchamber/tunnel/status");if(!ge.ok||Y)return;const Ee=await ge.json();if(Y)return;Ae(Array.isArray(Ee.activeSessions)?Ee.activeSessions:[]),H(new Set(Array.isArray(Ee.managedRemoteTunnelTokenPresetIds)?Ee.managedRemoteTunnelTokenPresetIds:[])),ye(typeof Ee.localPort=="number"?Ee.localPort:null)}catch{}},be=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||V()},5e3);return()=>{Y=!0,window.clearInterval(be)}},[n]);const nt=o.useCallback(async Y=>{N(!0);try{await xt(Y),Object.prototype.hasOwnProperty.call(Y,"tunnelMode")&&Y.tunnelMode&&D(Y.tunnelMode),Object.prototype.hasOwnProperty.call(Y,"tunnelProvider")&&typeof Y.tunnelProvider=="string"&&y(Y.tunnelProvider),Object.prototype.hasOwnProperty.call(Y,"managedLocalTunnelConfigPath")&&O(Y.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(Y,"managedRemoteTunnelPresets")&&Y.managedRemoteTunnelPresets&&M(Y.managedRemoteTunnelPresets)}catch{$.error(t("settings.openchamber.tunnel.toast.saveSettingsFailed"))}finally{N(!1)}},[t]),lt=o.useCallback(async(Y,V)=>{p(!0);try{await xt({tunnelBootstrapTtlMs:Y,tunnelSessionTtlMs:V})}catch{$.error(t("settings.openchamber.tunnel.toast.saveTtlFailed"))}finally{p(!1)}},[t]),we=o.useCallback(async Y=>{const V=Y.token.trim();if(V)try{const be={...J,[Y.presetId]:V};await xt({managedRemoteTunnelPresetTokens:be}),H(ge=>{const Ee=new Set(ge);return Ee.add(Y.presetId),Ee})}catch{$.error(t("settings.openchamber.tunnel.toast.saveTokenFailed"))}},[J,t]),Je=o.useCallback(async Y=>{v(null),m(null);const V=A.find(ge=>ge.provider===Y),be=V?.modes?.some(ge=>ge.key===P)?P:Gn(V?.modes?.[0]?.key);await nt({tunnelProvider:Y,tunnelMode:be}),ht(Y)},[A,ht,nt,P]),Ye=o.useCallback(async()=>{const Y=await Co({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(Y.success&&typeof Y.path=="string"&&Y.path.trim().length>0){const V=Y.path.trim();if(!ri(V)){$.error(Te);return}O(V),await nt({managedLocalTunnelConfigPath:V});return}ee.current?.click()},[Te,nt]),ze=o.useCallback(Y=>{const V=Y.trim();O(V.length>0?V:null)},[]),Ge=o.useCallback(async()=>{if(F&&!ri(F)){$.error(Te);return}await nt({managedLocalTunnelConfigPath:F})},[Te,F,nt]),Q=o.useCallback(async()=>{O(null),await nt({managedLocalTunnelConfigPath:null})},[nt]),Ue=o.useCallback(async Y=>{const V=Y.target.files?.[0];if(!V)return;const be=V.name.trim();if(be.length!==0){if(!ri(be)){$.error(Te);return}O(be),await nt({managedLocalTunnelConfigPath:be}),Y.target.value=""}},[Te,nt]),st=o.useCallback(async()=>{if(m(null),v(null),P==="managed-local"&&F&&!ri(F)){m(Te),$.error(Te);return}r("starting");try{let Y="",V="";if(P==="managed-remote"){if(!fe){r("idle"),v(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst")),$.error(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst"));return}Y=fe.hostname,V=(J[fe.id]||"").trim(),await nt({tunnelMode:"managed-remote",managedRemoteTunnelPresets:C})}const be=await St("/api/openchamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:I,mode:P,...P==="managed-remote"&&fe?{managedRemoteTunnelPresetId:fe.id,managedRemoteTunnelPresetName:fe.name}:{},...P==="managed-remote"&&Y?{managedRemoteTunnelHostname:Y}:{},...P==="managed-remote"&&V?{managedRemoteTunnelToken:V}:{},...P==="managed-local"&&F?{configPath:F}:{}})}),ge=await be.json();if(!be.ok||!ge.ok){if(P==="managed-remote"&&typeof ge.error=="string"&&ge.error.includes("Managed remote tunnel token is required")){r("idle"),v(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequiredBeforeStarting")),$.error(t("settings.openchamber.tunnel.toast.addManagedRemoteTokenBeforeStarting"));return}r("error"),m(ge.error||t("settings.openchamber.tunnel.toast.startFailed")),$.error(ge.error||t("settings.openchamber.tunnel.toast.startFailed"));return}const Ee=typeof ge.url=="string"?ge.url:"";if(!Ee){r("error"),m(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl")),$.error(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl"));return}if(l({url:Ee,connectUrl:typeof ge.connectUrl=="string"?ge.connectUrl:null,bootstrapExpiresAt:typeof ge.bootstrapExpiresAt=="number"?ge.bootstrapExpiresAt:null}),c(ge.activeTunnelMode?Gn(ge.activeTunnelMode):ge.mode?Gn(ge.mode):P),Ae(Array.isArray(ge.activeSessions)?ge.activeSessions:[]),Array.isArray(ge.managedRemoteTunnelTokenPresetIds)&&H(new Set(ge.managedRemoteTunnelTokenPresetIds)),typeof ge.localPort=="number"&&ye(ge.localPort),typeof ge.mode=="string"&&D(Gn(ge.mode)),r("active"),ge.replacedTunnel){const te=typeof ge.revokedBootstrapCount=="number"?ge.revokedBootstrapCount:0,xe=typeof ge.invalidatedSessionCount=="number"?ge.invalidatedSessionCount:0;te===1&&xe===1?$.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleSingle")):te===1?$.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleManySessions",{invalidatedSessionCount:xe})):xe===1?$.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyLinksSingleSession",{revokedBootstrapCount:te})):$.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyMany",{revokedBootstrapCount:te,invalidatedSessionCount:xe}))}else $.success(t("settings.openchamber.tunnel.toast.linkReady"))}catch{r("error"),m(t("settings.openchamber.tunnel.toast.startFailed")),$.error(t("settings.openchamber.tunnel.toast.startFailed"))}},[Te,C,nt,fe,J,t,I,P,F]),dt=o.useCallback(async()=>{r("stopping");try{await St("/api/openchamber/tunnel/stop",{method:"POST"});const Y=await St("/api/openchamber/tunnel/status");if(Y.ok){const V=await Y.json();Ae(Array.isArray(V.activeSessions)?V.activeSessions:[]),H(new Set(Array.isArray(V.managedRemoteTunnelTokenPresetIds)?V.managedRemoteTunnelTokenPresetIds:[])),ye(typeof V.localPort=="number"?V.localPort:null)}l(null),c(null),g(null),r("idle"),$.success(t("settings.openchamber.tunnel.toast.stopped"))}catch{r("error"),m(t("settings.openchamber.tunnel.toast.stopFailed")),$.error(t("settings.openchamber.tunnel.toast.stopFailed"))}},[t]),ct=o.useCallback(async()=>{if(i?.connectUrl)try{await navigator.clipboard.writeText(i.connectUrl),b(!0),$.success(t("settings.openchamber.tunnel.toast.connectLinkCopied")),setTimeout(()=>b(!1),2e3)}catch{$.error(t("settings.openchamber.tunnel.toast.copyUrlFailed"))}},[t,i?.connectUrl]),ft=o.useCallback(async Y=>{const V=$i.find(be=>be.value===Y);V&&(Se(V.ms),await lt(V.ms,re))},[lt,re]),kt=o.useCallback(async Y=>{const V=Bi.find(be=>be.value===Y);!V||V.ms===null||(ve(V.ms),await lt(ce,V.ms))},[ce,lt]),bt=o.useCallback(async Y=>{v(null),m(null),n!=="active"&&n!=="stopping"&&n!=="starting"&&r("idle"),await nt({tunnelMode:Y,managedRemoteTunnelPresets:C})},[C,nt,n]),vt=o.useCallback(async(Y,V)=>{try{await xt({managedRemoteTunnelPresets:V})}catch{$.error(t("settings.openchamber.tunnel.toast.saveSelectedManagedRemoteFailed"))}},[t]),Xe=o.useCallback(Y=>{const V=C.find(be=>be.id===Y);V&&(X(V.id),v(null),vt(V,C))},[C,vt]),jt=o.useCallback(async()=>{const Y=ne.trim(),V=Ji(Z),be=ue.trim();if(!Y){$.error(t("settings.openchamber.tunnel.toast.tunnelNameRequired"));return}if(!V){$.error(t("settings.openchamber.tunnel.toast.managedRemoteHostnameRequired"));return}if(!be){$.error(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequired"));return}if(C.some(te=>te.hostname===V)){$.error(t("settings.openchamber.tunnel.toast.hostnameAlreadyExists"));return}const ge={id:$y(),name:Y,hostname:V},Ee=[...C,ge];M(Ee),X(ge.id),L(te=>({...te,[ge.id]:!0})),q(te=>({...te,[ge.id]:be})),v(null),B(!1),K(""),oe(""),de(""),await nt({tunnelMode:"managed-remote",managedRemoteTunnelPresets:Ee,managedRemoteTunnelPresetTokens:{...J,[ge.id]:be}}),await we({presetId:ge.id,presetName:ge.name,hostname:ge.hostname,token:be}),$.success(t("settings.openchamber.tunnel.toast.managedRemoteSaved"))},[C,Z,ne,ue,we,nt,J,t]),De=o.useCallback(async Y=>{const V=C.find(xe=>xe.id===Y);if(!V)return;const be=C.filter(xe=>xe.id!==V.id),ge=be[0]?.id||"",Ee=W===V.id?ge:W,te=Object.fromEntries(Object.entries(J).filter(([xe,Ze])=>xe!==V.id&&Ze.trim().length>0));M(be),X(Ee),L(xe=>{const Ze={...xe};return delete Ze[V.id],Ze}),q(xe=>{const Ze={...xe};return delete Ze[V.id],Ze}),H(xe=>{const Ze=new Set(xe);return Ze.delete(V.id),Ze}),v(null),await nt({managedRemoteTunnelPresets:be,managedRemoteTunnelPresetTokens:te}),$.success(t("settings.openchamber.tunnel.toast.managedRemoteRemoved"))},[C,nt,W,J,t]),$e="gap-2 border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:bg-[var(--primary-hover)] hover:text-[var(--primary-foreground)]";return n==="checking"?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":t("settings.openchamber.tunnel.state.loading")})}):s.jsx(qe,{title:t("settings.openchamber.tunnel.title"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.openchamber.tunnel.description")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.serverSideEnforced")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.connectLinksOneTime")})]}),divider:!1,children:s.jsxs("div",{className:"space-y-6",children:[je.length>0&&s.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:s.jsxs("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)]/30 p-3",children:[s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[s.jsx(_,{name:"information",className:"size-4 text-[var(--status-info)]"}),s.jsx("p",{className:Xo,children:t("settings.openchamber.tunnel.section.redeemedAccessLinks")})]}),s.jsx("div",{className:"space-y-1",children:je.map(Y=>{const V=Y.mode==="quick",be=Y.mode==="managed-remote",ge=V?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":be?"border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)]":"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",Ee=Y.isActive?V?"text-[var(--status-warning)]":be?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",te=t(V?"settings.openchamber.tunnel.badge.quick":be?"settings.openchamber.tunnel.badge.remote":"settings.openchamber.tunnel.badge.local");return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 rounded border border-[var(--surface-subtle)] bg-[var(--surface-elevated)] px-2 py-1.5",children:[s.jsx(_,{name:"checkbox-blank-circle-fill",className:Pe("size-2.5 shrink-0",Ee)}),s.jsx("span",{className:Pe("typography-micro rounded border px-1.5 py-0.5 uppercase",ge),children:te}),s.jsx("span",{className:"typography-meta text-muted-foreground/80",children:t("settings.openchamber.tunnel.session.redeemedAt",{time:Uy(Y.createdAt,e)})}),s.jsx("span",{className:"typography-meta text-foreground",children:Y.isActive?t("settings.openchamber.tunnel.session.expiresIn",{remaining:Y.remainingTextForSession}):Y.inactiveLabel===t("settings.openchamber.tunnel.state.inactive")?t("settings.openchamber.tunnel.state.inactive"):t("settings.openchamber.tunnel.session.inactiveWithReason",{reason:Y.inactiveLabel})})]},Y.sessionId)})})]})}),n==="not-available"&&s.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:s.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-[var(--status-warning)]/30 bg-[var(--status-warning)]/5 p-3",children:[s.jsx(_,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:Xo,children:t("settings.openchamber.tunnel.notAvailable.dependencyNotFound",{dependency:pt.dependency})}),s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t("settings.openchamber.tunnel.notAvailable.installHint")}),s.jsx("code",{className:"typography-code block rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:pt.installCommand})]})]})}),s.jsxs("section",{className:"space-y-4 px-2 pb-2 pt-0",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{"data-settings-item":"tunnel.provider",className:"space-y-1.5",children:[s.jsx("p",{className:Ct,children:t("settings.openchamber.tunnel.field.provider")}),s.jsxs(Et,{value:I,onValueChange:Y=>{Je(Y)},disabled:S||n==="starting"||n==="stopping",children:[s.jsx(At,{size:Bt,className:"max-w-[16rem]",children:s.jsx($t,{placeholder:t("settings.openchamber.tunnel.field.providerPlaceholder"),children:Td(I)})}),s.jsxs(Tt,{children:[A.length>0?A.map(Y=>s.jsx(ut,{value:Y.provider,children:s.jsx(xc,{provider:Y.provider})},Y.provider)):s.jsx(ut,{value:"cloudflare",children:s.jsx(xc,{provider:"cloudflare"})}),s.jsx(ut,{value:"__more-soon",disabled:!0,children:t("settings.openchamber.tunnel.option.moreProvidersSoon")})]})]})]}),s.jsxs("div",{"data-settings-item":"tunnel.type",className:"space-y-1.5",children:[s.jsx("p",{className:Ct,children:t("settings.openchamber.tunnel.field.tunnelType")}),s.jsx("div",{className:"flex flex-wrap items-center gap-1",children:Me.map(Y=>s.jsxs(ar,{children:[s.jsx(ir,{asChild:!0,children:s.jsx(G,{variant:"chip",size:"xs","aria-pressed":P===Y.value,className:"!font-normal",onClick:()=>{bt(Y.value)},disabled:S||n==="starting"||n==="stopping",children:a(Y.labelKey)})}),s.jsx(yo,{sideOffset:8,className:"max-w-xs",children:a(Y.tooltipKey)})]},Y.value))})]})]}),s.jsxs("div",{"data-settings-item":"tunnel.ttl",className:"mt-2 grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Pe(Ct,"shrink-0"),children:t("settings.openchamber.tunnel.field.connectLinkTtl")}),s.jsxs(Et,{value:go($i,ce,"1800000"),onValueChange:Y=>{ft(Y)},disabled:k||S||n==="starting"||n==="stopping",children:[s.jsx(At,{size:Bt,className:"max-w-[11rem] min-w-0",children:s.jsx($t,{className:"truncate",children:bc($i,ce,"1800000")})}),s.jsx(Tt,{children:$i.map(Y=>s.jsx(ut,{value:Y.value,children:Y.label},Y.value))})]})]}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Pe(Ct,"shrink-0"),children:t("settings.openchamber.tunnel.field.tunnelSessionTtl")}),s.jsxs(Et,{value:go(Bi,re,"28800000"),onValueChange:Y=>{kt(Y)},disabled:k||S||n==="starting"||n==="stopping",children:[s.jsx(At,{size:Bt,className:"max-w-[11rem] min-w-0",children:s.jsx($t,{className:"truncate",children:bc(Bi,re,"28800000")})}),s.jsx(Tt,{children:Bi.map(Y=>s.jsx(ut,{value:Y.value,children:Y.label},Y.value))})]})]})]}),P==="quick"&&s.jsx("div",{className:"rounded-lg border border-[var(--status-warning)]/35 bg-[var(--status-warning)]/10 p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(_,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.option.mode.quick.tooltip")}),at&&s.jsx("p",{className:"typography-meta mt-1 text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.quickModeReliability")})]})]})}),P==="managed-remote"&&s.jsxs("div",{"data-settings-item":"tunnel.managed-remote",className:"space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[typeof Ke=="number"&&s.jsx("div",{className:"rounded-md border border-[var(--status-info-border)] bg-[var(--status-info-background)]/35 px-2 py-1.5",children:s.jsxs("p",{className:"typography-meta text-[var(--status-info)]",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTarget")," ",s.jsxs("code",{children:["http://localhost:",Ke]})]})}),s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[s.jsx(An,{children:t("settings.openchamber.tunnel.section.savedManagedRemoteTunnels")}),s.jsxs(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>B(Y=>!Y),disabled:n==="starting"||n==="stopping"||S,children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),t("settings.common.actions.create")]})]}),C.length>0?s.jsx("div",{className:"overflow-hidden rounded-md border border-[var(--surface-subtle)]",children:C.map((Y,V)=>{const be=J[Y.id]||"",ge=z.has(Y.id),Ee=U[Y.id]??!1;return s.jsx("div",{className:Pe(V<C.length-1&&"border-b border-[var(--surface-subtle)]"),children:s.jsxs(Cn,{open:Ee,onOpenChange:te=>{L(xe=>({...xe,[Y.id]:te})),te&&Xe(Y.id)},className:"py-1.5",children:[s.jsxs("div",{className:"flex items-start gap-2 px-3",children:[s.jsxs(In,{type:"button",className:"group flex-1 justify-start gap-2 rounded-md px-0 py-1 pr-1 text-left hover:bg-[var(--interactive-hover)]",disabled:n==="starting"||n==="stopping"||S,children:[Ee?s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(_,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label min-w-0 flex-1 truncate text-foreground",children:Y.name})]}),s.jsx(G,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-[var(--status-error)]","aria-label":t("settings.openchamber.tunnel.actions.removePresetAria",{name:Y.name}),onClick:()=>{De(Y.id)},disabled:n==="starting"||n==="stopping"||S,children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),s.jsx(Pn,{className:"pt-1.5",children:s.jsxs("div",{className:"space-y-1 px-3 pb-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.field.hostnameLabel")," ",s.jsx("code",{children:Y.hostname})]}),s.jsx(He,{type:"password",value:be,onChange:te=>{const xe=te.target.value;v(null),q(Ze=>({...Ze,[Y.id]:xe}))},onBlur:te=>{const xe=te.currentTarget.value.trim();xe&&we({presetId:Y.id,presetName:Y.name,hostname:Y.hostname,token:xe})},placeholder:t(ge?"settings.openchamber.tunnel.field.savedTokenAvailablePlaceholder":"settings.openchamber.tunnel.field.pasteTokenPlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",disabled:n==="starting"||n==="stopping"||be.trim().length===0,onClick:()=>{we({presetId:Y.id,presetName:Y.name,hostname:Y.hostname,token:be})},children:t("settings.openchamber.tunnel.actions.saveToken")})})]})})]})},Y.id)})}):s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t("settings.openchamber.tunnel.empty.noManagedRemoteTunnels")}),se&&s.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--surface-subtle)] p-2",children:[s.jsx(He,{value:ne,onChange:Y=>K(Y.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetNamePlaceholder"),className:"h-7",disabled:S||n==="starting"||n==="stopping"}),s.jsx(He,{value:Z,onChange:Y=>oe(Y.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetHostnamePlaceholder"),className:"h-7",disabled:S||n==="starting"||n==="stopping"}),s.jsx(He,{type:"password",value:ue,onChange:Y=>de(Y.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetTokenPlaceholder"),className:"h-7",disabled:S||n==="starting"||n==="stopping"}),typeof Ke=="number"&&s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTargetUse")," ",s.jsxs("code",{children:["http://localhost:",Ke]}),"."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{jt()},disabled:S||n==="starting"||n==="stopping",children:t("settings.common.actions.saveChanges")}),s.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{B(!1),K(""),oe(""),de("")},disabled:S||n==="starting"||n==="stopping",children:t("settings.common.actions.cancel")})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("settings.openchamber.tunnel.note.tokensSavedPerTunnel")}),s.jsx(Gt,{children:t("settings.openchamber.tunnel.tooltip.tokensSavedPath")})]}),!fe&&u&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:u})]}),P==="managed-local"&&s.jsx("div",{"data-settings-item":"tunnel.managed-local-config",className:"space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:Ct,children:t("settings.openchamber.tunnel.field.configurationFile")}),s.jsx("input",{ref:ee,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:Y=>{Ue(Y)}}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(He,{value:F||"",onChange:Y=>{ze(Y.target.value)},onBlur:()=>{Ge()},placeholder:t("settings.openchamber.tunnel.field.configurationFilePlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"||S}),s.jsx(G,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.browseConfigFileAria"),onClick:()=>{Ye()},disabled:n==="starting"||n==="stopping"||S,children:s.jsx(_,{name:"folder",className:"size-3.5"})}),F&&s.jsx(G,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.clearConfigFileAria"),onClick:()=>{Q()},disabled:n==="starting"||n==="stopping"||S,children:s.jsx(_,{name:"close",className:"size-3.5"})})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t(F?"settings.openchamber.tunnel.note.customConfigUsed":"settings.openchamber.tunnel.note.defaultConfigUsed")}),ae&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Te})]})}),!Ce&&s.jsxs("div",{"data-settings-item":"tunnel.start",className:"space-y-6",children:[s.jsx("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)] p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(_,{name:"information",className:"mt-0.5 size-4 shrink-0 text-[var(--status-info)]"}),s.jsxs("div",{className:"space-y-1",children:[P==="managed-remote"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.managedRemoteRequiresDomain")}),s.jsxs("button",{type:"button",className:"typography-meta inline-flex items-center gap-1 text-[var(--status-info)] underline underline-offset-2 hover:opacity-90",onClick:()=>{ot(Ry)},children:[t("settings.openchamber.tunnel.actions.openManagedRemoteDocs"),s.jsx(_,{name:"external-link",className:"size-3.5"})]})]}),P==="managed-local"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.managedLocalUsesConfig")}),s.jsxs("button",{type:"button",className:"typography-meta inline-flex items-center gap-1 text-[var(--status-info)] underline underline-offset-2 hover:opacity-90",onClick:()=>{ot(Fy)},children:[t("settings.openchamber.tunnel.actions.openManagedLocalDocs"),s.jsx(_,{name:"external-link",className:"size-3.5"})]})]}),s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.startModeAndGenerateLink",{mode:a(Jr.find(Y=>Y.value===P)?.labelKey??"settings.openchamber.tunnel.option.mode.quick.label")})})]})]})}),P==="managed-remote"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:Ct,children:t("settings.openchamber.tunnel.field.managedRemoteTunnelToConnect")}),s.jsxs(Et,{value:W||(C[0]?.id??""),onValueChange:Y=>{Xe(Y)},disabled:S||n==="starting"||n==="stopping"||C.length<=1,children:[s.jsx(At,{size:Bt,children:s.jsx($t,{placeholder:t("settings.openchamber.tunnel.field.selectSavedTunnelPlaceholder"),children:fe?.name})}),s.jsx(Tt,{fitContent:!0,children:C.map(Y=>s.jsx(ut,{value:Y.id,children:Y.name},Y.id))})]})]}),_e&&s.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(_,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.replacesActiveTunnel")})]})}),s.jsx(G,{size:"sm",variant:"outline",onClick:st,disabled:n==="starting"||S||P==="managed-remote"&&!fe||P==="managed-local"&&ae,className:Pe($e,n==="starting"&&"opacity-70"),children:n==="starting"?s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.startingTunnel")]}):t("settings.openchamber.tunnel.actions.startTunnel")})]})]}),Ce&&i&&s.jsxs("section",{"data-settings-item":"tunnel.start",className:"space-y-4 px-2 pb-2 pt-0",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--status-success)]"}),s.jsx("p",{className:"typography-meta font-medium text-foreground",children:t("settings.openchamber.tunnel.state.tunnelReady")})]}),s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:t("settings.openchamber.tunnel.field.publicUrlHint")}),s.jsx("code",{className:"typography-code block truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:i.url})]}),Re&&i.connectUrl&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:t("settings.openchamber.tunnel.field.connectLink")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"typography-code flex-1 truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:i.connectUrl}),s.jsxs(G,{size:"sm",variant:"ghost",onClick:ct,className:"shrink-0 gap-1.5",children:[w?s.jsx(_,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):s.jsx(_,{name:"file-copy",className:"size-3.5"}),t(w?"settings.openchamber.tunnel.actions.copied":"settings.common.actions.copyAll")]})]}),s.jsxs("p",{className:"typography-meta mt-1 text-muted-foreground/70",children:[t("settings.openchamber.tunnel.field.expires"),": ",i.bootstrapExpiresAt?ie:t("settings.openchamber.tunnel.state.never")]})]}),s.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border/50 bg-[var(--surface-elevated)] p-4",children:[h?s.jsx("img",{src:h,alt:t("settings.openchamber.tunnel.field.connectQrAlt"),className:"size-48"}):s.jsx("div",{className:"size-48 rounded bg-muted/30"}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.tunnel.note.scanQrToConnect")})]})]})]}),s.jsx("div",{className:"pt-1",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(G,{size:"sm",variant:"outline",onClick:st,disabled:n==="stopping"||S||P==="managed-local"&&ae,className:$e,children:[s.jsx(_,{name:"restart",className:"size-3.5"}),t("settings.openchamber.tunnel.actions.newConnectLink")]}),s.jsx(G,{size:"sm",variant:"ghost",onClick:dt,disabled:n==="stopping"||S,className:"gap-2 text-[var(--status-error)]",children:n==="stopping"?s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.stopping")]}):t("settings.openchamber.tunnel.actions.stopTunnel")})]})})]}),n==="error"&&f&&s.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:f}),s.jsx(G,{size:"sm",variant:"ghost",onClick:st,children:t("settings.openchamber.tunnel.actions.retry")})]})]})})},Ed=()=>{const{t}=Qe(),[e,a]=et.useState(""),[n,r]=et.useState(!0),[i,l]=et.useState(!1),d=he(u=>u.showOpenCodeUpdateNotifications),c=he(u=>u.setShowOpenCodeUpdateNotifications);et.useEffect(()=>{let u=!1;return(async()=>{try{const v=await En();if(u||!v)return;a(v.opencodeBinary??"")}catch{}finally{u||r(!1)}})(),()=>{u=!0}},[]);const h=et.useCallback(async()=>{if(!(typeof window>"u")&&ls())try{const u=await Co();u.success&&u.path&&u.path.trim().length>0&&a(u.path.trim())}catch{}},[]),g=et.useCallback(async()=>{l(!0);try{const u=e.trim(),v=u.length>=2&&(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))?u.slice(1,-1).trim():u;await xt({opencodeBinary:v}),await Cc({message:t("settings.openchamber.opencodeCli.actions.restartingOpenCode"),mode:"projects",scopes:["all"]})}catch(u){if(u?.requiresManualRestart){$.warning(t("settings.openchamber.opencodeCli.restart.manualRequired"));return}$.error(t("settings.openchamber.opencodeCli.restart.failed"))}finally{l(!1)}},[t,e]),f=et.useCallback(async()=>{l(!0);try{await Om(t)}finally{l(!1)}},[t]),m=et.useCallback(u=>{c(u),xt({showOpenCodeUpdateNotifications:u})},[c]);return s.jsx(qe,{title:t("settings.openchamber.opencodeCli.title"),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs(It,{settingsItem:"sessions.opencode-binary",label:t("settings.openchamber.opencodeCli.field.binaryPath"),info:s.jsxs(s.Fragment,{children:[t("settings.openchamber.opencodeCli.tipPrefix")," ",s.jsx("span",{className:"font-mono",children:"OPENCODE_BINARY"})," ",t("settings.openchamber.opencodeCli.tipMiddle")," ",s.jsx("span",{className:"font-mono",children:"~/.config/openchamber/settings.json"}),"."]}),alignEnd:!1,controlClassName:"@xl:w-[20rem]",children:[s.jsx(He,{value:e,onChange:u=>a(u.target.value),placeholder:t("settings.openchamber.opencodeCli.field.binaryPathPlaceholder"),disabled:n||i,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),s.jsx(G,{type:"button",variant:"outline",size:"xs",onClick:h,disabled:n||i||!ls(),className:us,"aria-label":t("settings.openchamber.opencodeCli.actions.browseAria"),title:t("settings.openchamber.opencodeCli.actions.browse"),children:s.jsx(_,{name:"folder",className:"h-4 w-4"})})]}),s.jsxs(Qa,{className:cs,children:[s.jsx(gt,{settingsItem:"sessions.opencode-update-notifications",checked:d,onChange:m,label:t("settings.openchamber.opencodeCli.field.showUpdateNotifications"),ariaLabel:t("settings.openchamber.opencodeCli.field.showUpdateNotificationsAria")}),s.jsxs("div",{className:"flex flex-wrap justify-start gap-2 py-1.5","data-settings-item":"sessions.opencode-restart",children:[s.jsx(G,{type:"button",size:"xs",onClick:g,disabled:n||i,className:"shrink-0 !font-normal",children:t(i?"settings.openchamber.opencodeCli.actions.restartingOpenCode":"settings.openchamber.opencodeCli.actions.saveAndReload")}),s.jsx(G,{type:"button",variant:"outline",size:"xs",onClick:f,disabled:n||i,className:"shrink-0 !font-normal",children:t("settings.openchamber.opencodeCli.actions.restart")})]})]})]})})},Ko=!1,Yr="builtin",Vy=t=>t.filter(e=>No(e)&&zc(e.service,"browser")),Dd=()=>{const t=tt.c(99),{t:e}=Qe(),a=he(Hy),n=he(qy),r=he(Gy),i=he(Wy),l=he(Jy),d=he(Qy),c=qs(Yy),h=he(Zy),g=he(Xy),f=he(e1),m=he(t1),u=he(s1);let v;t[0]!==n?(v=pe=>{n(pe),xt({agentControlToolEnabled:pe})},t[0]=n,t[1]=v):v=t[1];const w=v;let b;t[2]!==i?(b=pe=>{i(pe),xt({agentWebToolEnabled:pe})},t[2]=i,t[3]=b):b=t[3];const k=b;let p;t[4]!==u?(p=pe=>{u(pe),xt({agentNotifyToolEnabled:pe})},t[4]=u,t[5]=p):p=t[5];const S=p;let N;t[6]===Symbol.for("react.memo_cache_sentinel")?(N=[],t[6]=N):N=t[6],et.useEffect(n1,N);let I;t[7]!==c?(I=Vy(c),t[7]=c,t[8]=I):I=t[8];const y=I;let T;t[9]!==l||t[10]!==y?(T=y.some(pe=>pe.id===l)?l:Yr,t[9]=l,t[10]=y,t[11]=T):T=t[11];const x=T;let A;t[12]!==d?(A=pe=>{d(pe),xt({browserProvider:pe})},t[12]=d,t[13]=A):A=t[13];const R=A;let P;t[14]!==f?(P=pe=>{f(pe),xt({agentMemoryToolEnabled:pe}).finally(()=>{pe&&Bu.getState().refresh()})},t[14]=f,t[15]=P):P=t[15];const D=P;let F;t[16]!==e?(F=e("settings.openchamber.tools.title"),t[16]=e,t[17]=F):F=t[17];let O;t[18]!==e?(O=e("settings.openchamber.tools.field.agentControlTool"),t[18]=e,t[19]=O):O=t[19];let C;t[20]!==e?(C=e("settings.openchamber.tools.field.agentControlToolAria"),t[20]=e,t[21]=C):C=t[21];let M;t[22]!==e?(M=e("settings.openchamber.tools.field.agentControlToolInfo"),t[22]=e,t[23]=M):M=t[23];let U;t[24]!==a||t[25]!==w||t[26]!==C||t[27]!==M||t[28]!==O?(U=s.jsx(gt,{settingsItem:"sessions.agent-control-tool",checked:a,onChange:w,label:O,ariaLabel:C,info:M}),t[24]=a,t[25]=w,t[26]=C,t[27]=M,t[28]=O,t[29]=U):U=t[29];let L;t[30]!==e?(L=e("settings.openchamber.tools.field.agentWebTool"),t[30]=e,t[31]=L):L=t[31];let W;t[32]!==e?(W=e("settings.openchamber.tools.field.agentWebToolAria"),t[32]=e,t[33]=W):W=t[33];let X;t[34]!==e?(X=e("settings.openchamber.tools.field.agentWebToolInfo"),t[34]=e,t[35]=X):X=t[35];let J;t[36]!==r||t[37]!==k||t[38]!==L||t[39]!==W||t[40]!==X?(J=s.jsx(gt,{settingsItem:"sessions.agent-web-tool",checked:r,onChange:k,label:L,ariaLabel:W,info:X}),t[36]=r,t[37]=k,t[38]=L,t[39]=W,t[40]=X,t[41]=J):J=t[41];let q;t[42]!==e?(q=e("settings.openchamber.tools.browserProvider.label"),t[42]=e,t[43]=q):q=t[43];let z;t[44]!==e?(z=e("settings.openchamber.tools.browserProvider.info"),t[44]=e,t[45]=z):z=t[45];const H=!r||y.length===0;let se;t[46]!==e?(se=e("settings.openchamber.tools.browserProvider.aria"),t[46]=e,t[47]=se):se=t[47];let B;t[48]!==y||t[49]!==e?(B=s.jsx($t,{children:pe=>pe===Yr?e("settings.openchamber.tools.browserProvider.option.builtin"):y.find(Le=>Le.id===pe)?.name??null}),t[48]=y,t[49]=e,t[50]=B):B=t[50];let ne;t[51]!==se||t[52]!==B?(ne=s.jsx(At,{size:Bt,className:nn,"aria-label":se,children:B}),t[51]=se,t[52]=B,t[53]=ne):ne=t[53];let K;t[54]!==e?(K=e("settings.openchamber.tools.browserProvider.option.builtin"),t[54]=e,t[55]=K):K=t[55];let Z;t[56]!==K?(Z=s.jsx(ut,{value:Yr,children:K}),t[56]=K,t[57]=Z):Z=t[57];let oe;t[58]!==y?(oe=y.map(a1),t[58]=y,t[59]=oe):oe=t[59];let ue;t[60]!==Z||t[61]!==oe?(ue=s.jsxs(Tt,{children:[Z,oe]}),t[60]=Z,t[61]=oe,t[62]=ue):ue=t[62];let de;t[63]!==R||t[64]!==x||t[65]!==H||t[66]!==ne||t[67]!==ue?(de=s.jsxs(Et,{value:x,onValueChange:R,disabled:H,children:[ne,ue]}),t[63]=R,t[64]=x,t[65]=H,t[66]=ne,t[67]=ue,t[68]=de):de=t[68];let ce;t[69]!==q||t[70]!==z||t[71]!==de?(ce=s.jsx(It,{settingsItem:"sessions.browser-provider",label:q,info:z,children:de}),t[69]=q,t[70]=z,t[71]=de,t[72]=ce):ce=t[72];let Se;t[73]!==e?(Se=e("settings.openchamber.tools.field.agentNotifyTool"),t[73]=e,t[74]=Se):Se=t[74];let re;t[75]!==e?(re=e("settings.openchamber.tools.field.agentNotifyToolAria"),t[75]=e,t[76]=re):re=t[76];let ve;t[77]!==e?(ve=e("settings.openchamber.tools.field.agentNotifyToolInfo"),t[77]=e,t[78]=ve):ve=t[78];let ie;t[79]!==m||t[80]!==S||t[81]!==Se||t[82]!==re||t[83]!==ve?(ie=s.jsx(gt,{settingsItem:"sessions.agent-notify-tool",checked:m,onChange:S,label:Se,ariaLabel:re,info:ve}),t[79]=m,t[80]=S,t[81]=Se,t[82]=re,t[83]=ve,t[84]=ie):ie=t[84];let me;t[85]!==g||t[86]!==h||t[87]!==D||t[88]!==e?(me=g?s.jsx(gt,{settingsItem:"sessions.agent-memory-tool",checked:h,onChange:D,label:e("settings.openchamber.tools.field.agentMemoryTool"),ariaLabel:e("settings.openchamber.tools.field.agentMemoryToolAria"),info:e("settings.openchamber.tools.field.agentMemoryToolInfo")}):null,t[85]=g,t[86]=h,t[87]=D,t[88]=e,t[89]=me):me=t[89];let ke;t[90]!==U||t[91]!==J||t[92]!==ce||t[93]!==ie||t[94]!==me?(ke=s.jsxs("div",{className:cs,children:[U,J,ce,ie,me]}),t[90]=U,t[91]=J,t[92]=ce,t[93]=ie,t[94]=me,t[95]=ke):ke=t[95];let Ae;return t[96]!==ke||t[97]!==F?(Ae=s.jsx(qe,{title:F,children:ke}),t[96]=ke,t[97]=F,t[98]=Ae):Ae=t[98],Ae};function Hy(t){return t.agentControlToolEnabled}function qy(t){return t.setAgentControlToolEnabled}function Gy(t){return t.agentWebToolEnabled}function Wy(t){return t.setAgentWebToolEnabled}function Jy(t){return t.browserProvider}function Qy(t){return t.setBrowserProvider}function Yy(t){return t.guests}function Zy(t){return t.agentMemoryToolEnabled}function Xy(t){return t.agentMemoryFeatureAvailable}function e1(t){return t.setAgentMemoryToolEnabled}function t1(t){return t.agentNotifyToolEnabled}function s1(t){return t.setAgentNotifyToolEnabled}function n1(){Kn()}function a1(t){return s.jsx(ut,{value:t.id,children:t.name},t.id)}const Md=()=>{const{t}=Qe(),e=ls()&&fi(),a=e&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[n,r]=et.useState(!1),[i,l]=et.useState(!1),[d,c]=et.useState(!1),[h,g]=et.useState(""),[f,m]=et.useState(!1),[u,v]=et.useState(!1),[w,b]=et.useState(null),[k,p]=et.useState(!0),[S,N]=et.useState(!1),[I,y]=et.useState(!1),[T,x]=et.useState(!1),[A,R]=et.useState(!1),[P,D]=et.useState(!1),[F,O]=et.useState(!1),[C,M]=et.useState(!1),[U,L]=et.useState(!0),[W,X]=et.useState(!0),[J,q]=et.useState(!1),[z,H]=et.useState(!1),[se,B]=et.useState(!1),[ne,K]=et.useState(null),[Z,oe]=et.useState(null);et.useEffect(()=>{if(!e){p(!1);return}let ee=!1;return(async()=>{try{const ae=await En();if(!ae)throw new Error(t("settings.openchamber.desktopNetwork.error.loadFailed"));if(ee)return;const fe=ae.desktopLanAccessEnabled===!0;r(fe),l(fe),c(ae.hasDesktopUiPassword===!0),g(""),m(!1),v(ae.desktopLanAccessActive===!0),b(ae.desktopLanAccessBlockedReason??null);const je=ae.desktopMacMenuBarEnabled!==!1;L(je),X(je),K(null)}catch(ae){ee||K(ae instanceof Error?ae.message:t("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{ee||p(!1)}})(),()=>{ee=!0}},[e,t]),et.useEffect(()=>{if(!e){y(!1);return}let ee=!1;return(async()=>{const ae=await wm();ee||(y(ae?.supported===!0),x(ae?.enabled===!0))})(),()=>{ee=!0}},[e]),et.useEffect(()=>{if(!e){D(!1);return}let ee=!1;return(async()=>{const ae=await km();ee||(D(ae?.supported===!0),O(ae?.enabled===!0))})(),()=>{ee=!0}},[e]),et.useEffect(()=>{if(!e){q(!1);return}let ee=!1;return(async()=>{const ae=await Nm();ee||(q(ae?.supported===!0),H(ae?.enabled===!0))})(),()=>{ee=!0}},[e]),et.useEffect(()=>{if(!e||!i){oe(null);return}let ee=!1;return(async()=>{const ae=await Vc();ee||oe(ae)})(),()=>{ee=!0}},[i,e]);const ue=h.trim(),de=ue.length>0||f,ce=i!==n||de||W!==U,Se=et.useMemo(()=>{if(typeof window>"u")return null;const ae=hi()||window.location.href;let fe=0;try{fe=Number(new URL(ae).port)}catch{fe=Number(window.location.port)}return Number.isFinite(fe)&&fe>0?fe:null},[]),re=i&&u&&Z&&Se?`http://${Z}:${Se}`:null,ve=ue.length>0||d&&!f,ie=i&&!ve,me=n&&!u&&w==="missing-password",ke=k||S||!ce||ie,Ae=et.useCallback(ee=>{g(ee),ee.trim()&&m(!1)},[]),pe=et.useCallback(()=>{g(""),m(!0),l(!1)},[]),Le=et.useCallback(async()=>{if(!I||A)return;const ee=!T;x(ee),R(!0),K(null);try{const ae=await Sm(ee);if(!ae?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported"));x(ae.enabled)}catch(ae){x(!ee),K(ae instanceof Error?ae.message:t("settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed"))}finally{R(!1)}},[A,T,I,t]),Ve=et.useCallback(async()=>{if(!P||C)return;const ee=!F;O(ee),M(!0),K(null);try{const ae=await Cm(ee);if(!ae)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"));if(!ae.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTrayUnsupported"));O(ae.enabled)}catch(ae){O(!ee),K(ae instanceof Error?ae.message:t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"))}finally{M(!1)}},[C,F,P,t]),ye=et.useCallback(async()=>{if(!J||se)return;const ee=!z;H(ee),B(!0),K(null);try{const ae=await Im(ee);if(!ae?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.keepAwakeUnsupported"));H(ae.enabled)}catch(ae){H(!ee),K(ae instanceof Error?ae.message:t("settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed"))}finally{B(!1)}},[se,z,J,t]),Te=et.useCallback(async()=>{if(ce){N(!0),K(null);try{if(!(await xt({desktopLanAccessEnabled:i,...ue?{desktopUiPassword:ue}:f?{desktopUiPassword:""}:{},desktopMacMenuBarEnabled:W})).ok)throw new Error(t("settings.openchamber.desktopNetwork.error.saveFailed"));if(r(i),ue?c(!0):f&&c(!1),g(""),m(!1),L(W),!await Pm())throw new Error(t("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(ee){K(ee instanceof Error?ee.message:t("settings.openchamber.desktopNetwork.error.saveFailed")),N(!1)}}},[W,i,ce,ue,f,t]);return e?s.jsx(qe,{title:t("settings.openchamber.desktopNetwork.title"),children:s.jsxs("div",{className:"space-y-3",children:[I||a||P||J?s.jsxs("div",{className:cs,children:[I?s.jsx(gt,{settingsItem:"sessions.desktop-launch-at-login",checked:T,onChange:ee=>{ee!==T&&Le()},disabled:A,label:t("settings.openchamber.desktopNetwork.field.launchAtLogin"),info:t("settings.openchamber.desktopNetwork.field.launchAtLoginDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.launchAtLoginAria")}):null,a?s.jsx(gt,{settingsItem:"sessions.desktop-mac-menu-bar",checked:W,onChange:X,disabled:k||S,label:t("settings.openchamber.desktopNetwork.field.macMenuBar"),info:t("settings.openchamber.desktopNetwork.field.macMenuBarDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.macMenuBarAria")}):null,P?s.jsx(gt,{settingsItem:"sessions.desktop-minimize-to-tray",checked:F,onChange:ee=>{ee!==F&&Ve()},disabled:C,label:t("settings.openchamber.desktopNetwork.field.minimizeToTray"),info:t("settings.openchamber.desktopNetwork.field.minimizeToTrayDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.minimizeToTrayAria")}):null,J?s.jsx(gt,{settingsItem:"sessions.desktop-keep-awake",checked:z,onChange:ee=>{ee!==z&&ye()},disabled:se,label:t("settings.openchamber.desktopNetwork.field.keepAwake"),info:t("settings.openchamber.desktopNetwork.field.keepAwakeDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.keepAwakeAria")}):null]}):null,s.jsxs(Ft,{settingsItem:"sessions.desktop-ui-password",label:s.jsx("label",{htmlFor:"desktop-ui-password",children:t("settings.openchamber.desktopPassword.field.password")}),info:t("settings.openchamber.desktopPassword.field.passwordDescription"),children:[s.jsx(He,{id:"desktop-ui-password",type:"password",className:"h-8 min-w-0 flex-1",value:h,onChange:ee=>Ae(ee.target.value),placeholder:t(d&&!f?"settings.openchamber.desktopPassword.field.passwordSetPlaceholder":"settings.openchamber.desktopPassword.field.passwordPlaceholder"),disabled:k||S,required:i&&!ve,"aria-invalid":ie}),d&&!f?s.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:pe,disabled:k||S,className:"shrink-0 !font-normal",children:t("settings.openchamber.desktopPassword.actions.removePassword")}):null]}),s.jsx("div",{className:cs,children:s.jsx(gt,{settingsItem:"sessions.desktop-lan-access",checked:i,onChange:l,disabled:k||S,label:t("settings.openchamber.desktopNetwork.field.allowLanAccess"),info:t("settings.openchamber.desktopNetwork.field.allowLanAccessDescription"),description:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.warning")}),ie||me?s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.passwordRequiredWarning")}):null]}),ariaLabel:t("settings.openchamber.desktopNetwork.field.allowLanAccessAria")})}),ne?s.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:ne}):null,re?s.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[t(ce&&!n?"settings.openchamber.desktopNetwork.hint.openAfterRestart":"settings.openchamber.desktopNetwork.hint.openNow"),s.jsx("span",{className:"font-mono text-foreground",children:re})]}):null,s.jsx("div",{className:"flex justify-start py-1.5",children:s.jsx(G,{type:"button",size:"xs",onClick:Te,disabled:ke,className:"shrink-0 !font-normal",children:t(S?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")})})]})}):null},Rd=new Set(["shift","control","alt","meta"]),zo=3,i1=3e3;function Uo(t,e=!1){const a=new Set;return t.altKey&&a.add("alt"),t.ctrlKey&&a.add("control"),t.metaKey&&a.add("meta"),t.shiftKey&&a.add("shift"),e&&a.add(t.key.toLowerCase()),a.size}function r1(t){return t.action.customizable}function yc(t){if(Uo(t)>zo)return null;const e=[];return(t.metaKey||t.ctrlKey)&&e.push("mod"),t.shiftKey&&e.push("shift"),t.altKey&&e.push("alt"),e.length>0?rr(e.join("+")):null}function o1(t){if(Rd.has(t.key.toLowerCase())||Uo(t,!0)>zo)return null;const e=qu(Gu(t));if(!e)return null;const a=[];return(t.metaKey||t.ctrlKey)&&a.push("mod"),t.shiftKey&&a.push("shift"),t.altKey&&a.push("alt"),a.push(e),rr(a.join("+"))}function l1(t){const e=t.key.toLowerCase();if(!Rd.has(e)||Uo(t,!0)>zo)return null;const a=[];return(t.metaKey||t.ctrlKey||e==="meta"||e==="control")&&a.push("mod"),(t.shiftKey||e==="shift")&&a.push("shift"),(t.altKey||e==="alt")&&a.push("alt"),a.length>0?rr(a.join("+")):null}function jc(t){return t.chords.length>0?{...t,livePreview:null,settled:!0}:t}function c1(t,e,a){if(e.repeat||e.isComposing)return t;if(a==="keyup")return{...t,livePreview:yc(e)};if(e.key==="Backspace")return{chords:t.chords.slice(0,-1),livePreview:null,settled:!1};const n=o1(e);if(n){if(t.settled)return{chords:[n],livePreview:null,settled:!1};const r=t.chords.length<2?[...t.chords,n]:t.chords;return{chords:r,livePreview:null,settled:r.length===2}}return{...t,livePreview:yc(e)}}const d1=t=>{const e=tt.c(117),{action:a,overrides:n,onSave:r,onOpenChange:i}=t,{t:l}=Qe();let d;e[0]!==l?(d=Se=>l(Se.settingsLabelKey),e[0]=l,e[1]=d):d=e[1];const c=d;let h;e[2]!==c?(h=Se=>Se.action.customizable?c(Se.action):ua(Se.action.defaultBinding),e[2]=c,e[3]=h):h=e[3];const g=h;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f={chords:[],livePreview:null,settled:!1},e[4]=f):f=e[4];const[m,u]=o.useState(f),v=o.useRef(null);let w,b;e[5]!==a?(w=()=>{a&&(u({chords:[],livePreview:null,settled:!1}),v.current?.focus())},b=[a],e[5]=a,e[6]=w,e[7]=b):(w=e[6],b=e[7]),o.useEffect(w,b);const k=m.chords.length===1&&!m.settled;let p,S;e[8]!==k?(p=()=>{if(!k)return;const Se=window.setTimeout(()=>u(jc),i1);return()=>window.clearTimeout(Se)},S=[k],e[8]=k,e[9]=p,e[10]=S):(p=e[9],S=e[10]),o.useEffect(p,S);let N;e[11]!==m.chords?(N=rr(m.chords.join(" ")),e[11]=m.chords,e[12]=N):N=e[12];const I=N;let y;e[13]!==a||e[14]!==I||e[15]!==n?(y=a&&I?Vu(a.id,I,n):[],e[13]=a,e[14]=I,e[15]=n,e[16]=y):y=e[16];const T=y;let x;e[17]!==T?(x=T.find(u1),e[17]=T,e[18]=x):x=e[18];const A=x;let R,P,D,F,O,C,M,U,L,W,X,J,q,z,H;if(e[19]!==a||e[20]!==c||e[21]!==I||e[22]!==g||e[23]!==T||e[24]!==i||e[25]!==r||e[26]!==A||e[27]!==m||e[28]!==l){const Se=T.filter(r1);O=Se.find(m1);const re=Se.find(p1),ve=T.find(g1);let ie;e[44]!==i?(ie=()=>i(!1),e[44]=i,e[45]=ie):ie=e[45],D=ie,F=()=>{m.settled||u(jc),!(!a||!I||A||O)&&(r(a.id,I,re?.action.id),D())};let me;e[46]!==a||e[47]!==m?(me=(Ce,_e)=>{Ce.preventDefault(),Ce.stopPropagation();const Ke=!!(a&&"prefixStyle"in a&&a.prefixStyle);if(_e==="keyup"&&Ke&&m.chords.length===0){const Me=l1(Ce);if(Me){u({chords:[Me],livePreview:null,settled:!0});return}}const Fe=c1(m,{altKey:Ce.altKey,code:Ce.nativeEvent.code,ctrlKey:Ce.ctrlKey,isComposing:Ce.nativeEvent.isComposing,key:Ce.key,metaKey:Ce.metaKey,repeat:Ce.repeat,shiftKey:Ce.shiftKey},_e);u(Ke&&Fe.chords.length>1?m:Fe)},e[46]=a,e[47]=m,e[48]=me):me=e[48];const ke=me;P=Ut,z=a!==null,H=h1,R=_t,C="max-w-md",M=v,U=!1;let Ae;e[49]!==a||e[50]!==c||e[51]!==l?(Ae=a?l("settings.openchamber.keyboardShortcuts.dialog.title",{action:c(a)}):"",e[49]=a,e[50]=c,e[51]=l,e[52]=Ae):Ae=e[52];let pe;e[53]!==Ae?(pe=s.jsx(Ht,{children:Ae}),e[53]=Ae,e[54]=pe):pe=e[54];let Le;e[55]!==l?(Le=l("settings.openchamber.keyboardShortcuts.dialog.instructions"),e[55]=l,e[56]=Le):Le=e[56];let Ve;e[57]!==Le?(Ve=s.jsx(qt,{children:Le}),e[57]=Le,e[58]=Ve):Ve=e[58],e[59]!==pe||e[60]!==Ve?(L=s.jsxs(Vt,{children:[pe,Ve]}),e[59]=pe,e[60]=Ve,e[61]=L):L=e[61];let ye,Te;e[62]!==ke?(ye=Ce=>ke(Ce,"keydown"),Te=Ce=>ke(Ce,"keyup"),e[62]=ke,e[63]=ye,e[64]=Te):(ye=e[63],Te=e[64]);let ee;e[65]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>u(f1),e[65]=ee):ee=e[65];let ae;e[66]!==m.chords?(ae=m.chords.map(x1),e[66]=m.chords,e[67]=ae):ae=e[67];let fe;e[68]!==m.livePreview?(fe=m.livePreview?s.jsx("kbd",{className:"rounded-md border border-dashed border-border bg-muted px-3 py-2 typography-ui-label font-mono text-muted-foreground",children:ua(m.livePreview)}):null,e[68]=m.livePreview,e[69]=fe):fe=e[69];let je;e[70]!==m.chords.length||e[71]!==m.livePreview||e[72]!==l?(je=m.chords.length===0&&!m.livePreview?s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:l("settings.openchamber.keyboardShortcuts.dialog.recording")}):null,e[70]=m.chords.length,e[71]=m.livePreview,e[72]=l,e[73]=je):je=e[73];let Re;e[74]!==ae||e[75]!==fe||e[76]!==je?(Re=s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[ae,fe,je]}),e[74]=ae,e[75]=fe,e[76]=je,e[77]=Re):Re=e[77],e[78]!==ye||e[79]!==Te||e[80]!==Re?(W=s.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-lg border border-border bg-[var(--surface-elevated)] px-4 py-5 text-center outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,ref:v,onKeyDown:ye,onKeyUp:Te,onBlur:ee,children:Re}),e[78]=ye,e[79]=Te,e[80]=Re,e[81]=W):W=e[81],X=m.settled&&A?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l("settings.openchamber.keyboardShortcuts.error.internalConflict")}):m.settled&&O?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l("settings.openchamber.keyboardShortcuts.error.prefixConflict",{action:c(O.action)})}):null,J=m.settled&&re&&!A&&!O?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.error.exactConflict",{action:c(re.action)})}):null,q=m.settled&&ve&&!A&&!O?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.warning.contextualPrefix",{action:g(ve)})}):null,e[19]=a,e[20]=c,e[21]=I,e[22]=g,e[23]=T,e[24]=i,e[25]=r,e[26]=A,e[27]=m,e[28]=l,e[29]=R,e[30]=P,e[31]=D,e[32]=F,e[33]=O,e[34]=C,e[35]=M,e[36]=U,e[37]=L,e[38]=W,e[39]=X,e[40]=J,e[41]=q,e[42]=z,e[43]=H}else R=e[29],P=e[30],D=e[31],F=e[32],O=e[33],C=e[34],M=e[35],U=e[36],L=e[37],W=e[38],X=e[39],J=e[40],q=e[41],z=e[42],H=e[43];let se;e[82]!==I||e[83]!==m.settled||e[84]!==l?(se=m.settled&&I&&Hu(I)?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut")}):null,e[82]=I,e[83]=m.settled,e[84]=l,e[85]=se):se=e[85];let B;e[86]!==l?(B=l("settings.common.actions.cancel"),e[86]=l,e[87]=B):B=e[87];let ne;e[88]!==D||e[89]!==B?(ne=s.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:D,children:B}),e[88]=D,e[89]=B,e[90]=ne):ne=e[90];const K=!I||m.settled&&(!!A||!!O);let Z;e[91]!==l?(Z=l("settings.openchamber.keyboardShortcuts.actions.confirm"),e[91]=l,e[92]=Z):Z=e[92];let oe;e[93]!==F||e[94]!==K||e[95]!==Z?(oe=s.jsx(G,{type:"button",size:"sm",disabled:K,onClick:F,children:Z}),e[93]=F,e[94]=K,e[95]=Z,e[96]=oe):oe=e[96];let ue;e[97]!==ne||e[98]!==oe?(ue=s.jsxs(as,{children:[ne,oe]}),e[97]=ne,e[98]=oe,e[99]=ue):ue=e[99];let de;e[100]!==R||e[101]!==C||e[102]!==M||e[103]!==U||e[104]!==L||e[105]!==W||e[106]!==X||e[107]!==J||e[108]!==q||e[109]!==se||e[110]!==ue?(de=s.jsxs(R,{className:C,initialFocus:M,showCloseButton:U,children:[L,W,X,J,q,se,ue]}),e[100]=R,e[101]=C,e[102]=M,e[103]=U,e[104]=L,e[105]=W,e[106]=X,e[107]=J,e[108]=q,e[109]=se,e[110]=ue,e[111]=de):de=e[111];let ce;return e[112]!==P||e[113]!==z||e[114]!==H||e[115]!==de?(ce=s.jsx(P,{open:z,onOpenChange:H,children:de}),e[112]=P,e[113]=z,e[114]=H,e[115]=de,e[116]=ce):ce=e[116],ce};function u1(t){return!t.action.customizable&&t.kind!=="contextual-prefix"}function m1(t){return t.kind==="prefix"}function p1(t){return t.kind==="exact"}function g1(t){return t.kind==="contextual-prefix"}function h1(t,e){t||e.cancel()}function f1(t){return{...t,livePreview:null}}function x1(t,e){return s.jsx("kbd",{className:"rounded-md border border-border bg-muted px-3 py-2 typography-ui-label font-mono text-foreground",children:ua(t)},`${t}-${e}`)}const b1=["session","models","panels","navigation","application"],v1=()=>{const t=tt.c(24),{t:e}=Qe(),a=he(y1),n=he(j1),r=he(w1),i=he(k1),[l,d]=o.useState(null);let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=Wu(),t[0]=c):c=t[0];const h=c,g=N1;let f;t[1]!==n||t[2]!==a?(f=(I,y,T)=>{const x={...a,[I]:y};T&&(x[T]=Dr),n(I,y),T&&n(T,Dr),g(x)},t[1]=n,t[2]=a,t[3]=f):f=t[3];const m=f;let u;t[4]!==r||t[5]!==a?(u=I=>{const y={...a};delete y[I],r(I),g(y)},t[4]=r,t[5]=a,t[6]=u):u=t[6];const v=u;let w;t[7]!==a||t[8]!==e?(w=I=>{const y="prefixStyle"in I&&I.prefixStyle,T=y?Ju(I.id,a):Bc(I.id,a),x=ua(T,e("settings.openchamber.keyboardShortcuts.unassigned"));if(!y||!T||T===Dr)return x;const A=I.id==="switch_session_tab"?e("settings.openchamber.keyboardShortcuts.action.switch_session_tab.suffix"):e("settings.openchamber.keyboardShortcuts.action.switch_context_surface.suffix");return`${x}${A}`},t[7]=a,t[8]=e,t[9]=w):w=t[9];const b=w;let k;t[10]!==i||t[11]!==v||t[12]!==b||t[13]!==a||t[14]!==e?(k=b1.map((I,y)=>{const T=h.filter(x=>x.category===I);return T.length===0?null:s.jsx(qe,{settingsItem:y===0?"shortcuts.keyboard-shortcuts":void 0,title:e(`settings.openchamber.keyboardShortcuts.category.${I}`),divider:y!==0,info:y===0?e("settings.openchamber.keyboardShortcuts.tooltip"):void 0,headerAction:y===0?s.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{i(),g({})},children:e("settings.openchamber.keyboardShortcuts.actions.resetAll")}):void 0,children:s.jsx("div",{className:"space-y-2",children:T.map(x=>s.jsxs(It,{label:e(x.settingsLabelKey),children:[s.jsx("kbd",{className:"min-w-32 rounded-md border border-border bg-muted px-2 py-1 text-center typography-meta font-mono text-foreground",children:b(x)}),s.jsx(G,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>d(x),children:e("settings.openchamber.keyboardShortcuts.actions.edit")}),x.id in a?s.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>v(x.id),children:e("settings.common.actions.reset")}):null]},x.id))})},I)}),t[10]=i,t[11]=v,t[12]=b,t[13]=a,t[14]=e,t[15]=k):k=t[15];let p;t[16]===Symbol.for("react.memo_cache_sentinel")?(p=I=>{I||d(null)},t[16]=p):p=t[16];let S;t[17]!==l||t[18]!==m||t[19]!==a?(S=s.jsx(d1,{action:l,overrides:a,onSave:m,onOpenChange:p}),t[17]=l,t[18]=m,t[19]=a,t[20]=S):S=t[20];let N;return t[21]!==k||t[22]!==S?(N=s.jsxs(s.Fragment,{children:[k,S]}),t[21]=k,t[22]=S,t[23]=N):N=t[23],N};function y1(t){return t.shortcutOverrides}function j1(t){return t.setShortcutOverride}function w1(t){return t.clearShortcutOverride}function k1(t){return t.resetAllShortcutOverrides}function N1(t){xt({shortcutOverrides:t})}const Fd=()=>{const t=tt.c(2),[e,a]=o.useState(0);let n,r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>or(()=>a(F1)),r=[],t[0]=n,t[1]=r):(n=t[0],r=t[1]),o.useEffect(n,r),e},S1=t=>{const e=tt.c(84),{section:a}=t,{t:n}=Qe(),{isMobile:r}=Zn(),i=Fd();let l;e[0]!==r?(l=r&&da(),e[0]=r,e[1]=l):l=e[1];const d=l;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=fs(),e[2]=c):c=e[2];const h=c;let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=ls()&&fi(),e[3]=g):g=e[3];const f=g;if(!a){let q;e[4]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(lr,{}),e[4]=q):q=e[4];let z;e[5]!==i?(z=s.jsx(Pd,{},i),e[5]=i,e[6]=z):z=e[6];let H,se,B,ne,K,Z,oe;e[7]===Symbol.for("react.memo_cache_sentinel")?(ne=f&&s.jsx(Md,{}),K=!h&&s.jsx(Ed,{}),Z=!h&&s.jsx(Dd,{}),oe=!h&&Ko,H=s.jsx(Sd,{}),se=s.jsx(Id,{}),B=da()&&!ls()&&!h&&!So()&&s.jsx(Cd,{}),e[7]=H,e[8]=se,e[9]=B,e[10]=ne,e[11]=K,e[12]=Z,e[13]=oe):(H=e[7],se=e[8],B=e[9],ne=e[10],K=e[11],Z=e[12],oe=e[13]);let ue;e[14]!==d?(ue=d&&s.jsx(Yc,{}),e[14]=d,e[15]=ue):ue=e[15];let de;return e[16]!==ue||e[17]!==z?(de=s.jsxs(ts,{showSaveStatus:!0,className:"openchamber-page-body space-y-3 sm:space-y-6",children:[q,z,ne,K,Z,oe,H,se,B,ue]}),e[16]=ue,e[17]=z,e[18]=de):de=e[18],de}let m;e[19]!==i||e[20]!==a?(m=()=>{switch(a){case"general":return s.jsx(I1,{});case"visual":return s.jsx(P1,{});case"chat":return s.jsx(A1,{});case"sessions":return s.jsx(T1,{runtimeEndpointEpoch:i});case"shortcuts":return s.jsx(C1,{});case"git":return s.jsx(E1,{});case"notifications":return s.jsx(D1,{});case"voice":return s.jsx(M1,{});case"tunnel":return s.jsx(R1,{});default:return null}},e[19]=i,e[20]=a,e[21]=m):m=e[21];const u=m;let v;e[22]!==n?(v=n("settings.page.general.title"),e[22]=n,e[23]=v):v=e[23];let w;e[24]!==n?(w=n("settings.page.appearance.title"),e[24]=n,e[25]=w):w=e[25];let b;e[26]!==n?(b=n("settings.page.chat.title"),e[26]=n,e[27]=b):b=e[27];let k;e[28]!==n?(k=n("settings.page.sessions.title"),e[28]=n,e[29]=k):k=e[29];let p;e[30]!==n?(p=n("settings.page.shortcuts.title"),e[30]=n,e[31]=p):p=e[31];let S;e[32]!==n?(S=n("settings.page.git.title"),e[32]=n,e[33]=S):S=e[33];let N;e[34]!==n?(N=n("settings.page.git.title"),e[34]=n,e[35]=N):N=e[35];let I;e[36]!==n?(I=n("settings.page.notifications.title"),e[36]=n,e[37]=I):I=e[37];let y;e[38]!==n?(y=n("settings.page.voice.title"),e[38]=n,e[39]=y):y=e[39];let T;e[40]!==n?(T=n("settings.page.tunnel.title"),e[40]=n,e[41]=T):T=e[41];let x;e[42]!==S||e[43]!==N||e[44]!==I||e[45]!==y||e[46]!==T||e[47]!==v||e[48]!==w||e[49]!==b||e[50]!==k||e[51]!==p?(x={general:v,visual:w,chat:b,sessions:k,shortcuts:p,git:S,github:N,notifications:I,voice:y,tunnel:T},e[42]=S,e[43]=N,e[44]=I,e[45]=y,e[46]=T,e[47]=v,e[48]=w,e[49]=b,e[50]=k,e[51]=p,e[52]=x):x=e[52];const A=x[a];let R;e[53]!==n?(R=n("settings.page.general.description"),e[53]=n,e[54]=R):R=e[54];let P;e[55]!==n?(P=n("settings.page.appearance.description"),e[55]=n,e[56]=P):P=e[56];let D;e[57]!==n?(D=n("settings.page.chat.description"),e[57]=n,e[58]=D):D=e[58];let F;e[59]!==n?(F=n("settings.page.sessions.description"),e[59]=n,e[60]=F):F=e[60];let O;e[61]!==n?(O=n("settings.page.shortcuts.description"),e[61]=n,e[62]=O):O=e[62];let C;e[63]!==n?(C=n("settings.page.notifications.description"),e[63]=n,e[64]=C):C=e[64];let M;e[65]!==n?(M=n("settings.page.voice.description"),e[65]=n,e[66]=M):M=e[66];let U;e[67]!==n?(U=n("settings.page.tunnel.description"),e[67]=n,e[68]=U):U=e[68];let L;e[69]!==R||e[70]!==P||e[71]!==D||e[72]!==F||e[73]!==O||e[74]!==C||e[75]!==M||e[76]!==U?(L={general:R,visual:P,chat:D,sessions:F,shortcuts:O,git:void 0,github:void 0,notifications:C,voice:M,tunnel:U},e[69]=R,e[70]=P,e[71]=D,e[72]=F,e[73]=O,e[74]=C,e[75]=M,e[76]=U,e[77]=L):L=e[77];const W=L[a];let X;e[78]!==u?(X=u(),e[78]=u,e[79]=X):X=e[79];let J;return e[80]!==W||e[81]!==A||e[82]!==X?(J=s.jsx(ts,{title:A,description:W,showSaveStatus:!0,className:"openchamber-page-body",children:X}),e[80]=W,e[81]=A,e[82]=X,e[83]=J):J=e[83],J},C1=()=>{const t=tt.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(v1,{}),t[0]=e):e=t[0],e},I1=()=>{const t=tt.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=fs(),t[0]=e):e=t[0];const a=e;Fd();let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=ls()&&fi(),t[1]=n):n=t[1];const r=n;let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=da()&&!ls()&&!a&&!So(),t[2]=i):i=t[2];const l=i;let d,c,h,g,f,m;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=r&&s.jsx(Md,{}),c=l&&s.jsx(Cd,{}),h=s.jsx(Id,{}),g=!a&&s.jsx(Ed,{}),f=!a&&s.jsx(Dd,{}),m=!a&&Ko,t[3]=d,t[4]=c,t[5]=h,t[6]=g,t[7]=f,t[8]=m):(d=t[3],c=t[4],h=t[5],g=t[6],f=t[7],m=t[8]);let u;t[9]===Symbol.for("react.memo_cache_sentinel")?(u=a?[]:["sessionTabs"],t[9]=u):u=t[9];let v;return t[10]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsxs(s.Fragment,{children:[d,c,h,g,f,m,s.jsx(lr,{visibleSettings:["fileEditorKeymap",...u,"autoSaveEnabled",...a?[]:["terminalQuickKeys"],...a?[]:["terminalShell"],...a?[]:["terminalLoginShell"],"messageTransport","reportUsage"]})]}),t[10]=v):v=t[10],v},P1=()=>{const t=tt.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=fs(),t[0]=e):e=t[0];const a=e;let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(lr,{visibleSettings:["theme","windowControlsPosition","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat",...a?[]:["weekStart"],"fontSize","terminalFontSize","editorFontSize","spacing","scrollbars","inputBarOffset","animatedActivityIndicators"]}),t[1]=n):n=t[1],n},A1=()=>{const t=tt.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(lr,{visibleSettings:["sessionGoal","sessionAssist","chatRenderMode","activityRenderMode","userMessageRendering","mermaidRendering","reasoning","showToolFileIcons","showTurnChangedFiles","expandedTools","collapsibleUserMessages","stickyUserHeader","promptNavigatorEnabled","wideChatLayout","codeBlockLineWrap","splitAssistantMessageActions","subagentReadOnlyBanner","diffLayout","inputHistoryScope","inputHistoryLimit","dotfiles","fileViewerPreview","followUpBehavior","persistDraft","inputSpellcheck","largeTextPaste","enterToSend"]}),t[0]=e):e=t[0],e},T1=t=>{const e=tt.c(5),{runtimeEndpointEpoch:a}=t;let n;e[0]!==a?(n=s.jsx(Pd,{},a),e[0]=a,e[1]=n):n=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Sd,{}),e[2]=r):r=e[2];let i;return e[3]!==n?(i=s.jsxs(s.Fragment,{children:[n,r]}),e[3]=n,e[4]=i):i=e[4],i},E1=()=>{const t=tt.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(bd,{}),t[0]=e):e=t[0],e},D1=()=>{const t=tt.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(wy,{}),t[0]=e):e=t[0],e},M1=()=>{const t=tt.c(1);if(fs())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Dy,{}),t[0]=e):e=t[0],e},R1=()=>{const t=tt.c(1);if(fs())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(By,{}),t[0]=e):e=t[0],e};function F1(t){return t+1}const O1=[{id:"chat.activity-default",page:"chat",titleKey:"settings.openchamber.visual.section.activityDefault",keywords:["activity","collapsed","expanded","live","tools","history"]},{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.openchamber.visual.field.timeFormat",keywords:["clock","12h","24h"]},{id:"appearance.week-start",page:"appearance",titleKey:"settings.openchamber.visual.field.weekStartsOn",keywords:["calendar","monday","sunday"]},{id:"appearance.light-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.lightTheme",keywords:["theme","color","light mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.dark-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.darkTheme",keywords:["theme","color","dark mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.import-theme",page:"appearance",titleKey:"settings.themeImport.action",descriptionKey:"settings.themeImport.catalogHint",keywords:["theme","import","vscode","open vsx","openvsx","json","jsonc","syntax","palette"],isAvailable:t=>!t.isVSCode},{id:"appearance.dock-badge",page:"appearance",titleKey:"settings.openchamber.visual.field.dockBadge",descriptionKey:"settings.openchamber.visual.field.dockBadgeHint",keywords:["dock","badge","unread","unseen","counter","count","notification","macos"],isAvailable:t=>t.isMac},{id:"appearance.scrollbars",page:"appearance",titleKey:"settings.openchamber.visual.field.alwaysShowScrollbars",descriptionKey:"settings.openchamber.visual.field.alwaysShowScrollbarsHint",keywords:["scrollbar","scrollbars","scroll","mouse","wheel","accessibility","always visible"]},{id:"appearance.pwa-install-name",page:"appearance",titleKey:"settings.openchamber.visual.field.installAppName",descriptionKey:"settings.openchamber.visual.field.installAppNameHint",keywords:["pwa","installed app"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.pwa-orientation",page:"appearance",titleKey:"settings.openchamber.visual.field.installOrientation",descriptionKey:"settings.openchamber.visual.field.installOrientationHint",keywords:["pwa","portrait","landscape"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.mobile-keyboard-mode",page:"appearance",titleKey:"settings.openchamber.visual.field.mobileKeyboardMode",descriptionKey:"settings.openchamber.visual.field.mobileKeyboardModeHint",keywords:["mobile","keyboard","resize"],isAvailable:t=>t.isMobile&&t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.animated-activity-indicators",page:"appearance",titleKey:"settings.openchamber.visual.field.animatedActivityIndicators",descriptionKey:"settings.openchamber.visual.field.animatedActivityIndicatorsInfo",keywords:["spinner","animation","session","activity","motion","running","indicator"]},{id:"appearance.interface-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.interfaceFontSize",keywords:["font","text size","ui scale"],isAvailable:t=>!t.isMobile},{id:"appearance.terminal-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalFontSize",keywords:["terminal","font","text size"]},{id:"appearance.terminal-shell",page:"general",titleKey:"settings.openchamber.visual.field.terminalShell",descriptionKey:"settings.openchamber.visual.field.terminalShellHint",keywords:["terminal","shell","bash","zsh","fish","pwsh","powershell"],isAvailable:t=>!t.isVSCode},{id:"appearance.editor-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.editorFontSize",keywords:["editor","font","text size","code"]},{id:"appearance.spacing-density",page:"appearance",titleKey:"settings.openchamber.visual.field.spacingDensity",keywords:["density","compact","comfortable","spacing"]},{id:"appearance.input-bar-offset",page:"appearance",titleKey:"settings.openchamber.visual.field.inputBarOffset",descriptionKey:"settings.openchamber.visual.field.inputBarOffsetTooltip",keywords:["input","home bar","offset"],isAvailable:t=>t.isMobile},{id:"appearance.auto-save-enabled",page:"general",titleKey:"settings.openchamber.visual.field.autoSaveEnabled",descriptionKey:"settings.openchamber.visual.field.autoSaveEnabledInfo",keywords:["editor","autosave","auto-save","files","save"]},{id:"appearance.file-editor-keymap",page:"general",titleKey:"settings.openchamber.visual.field.fileEditorKeymap",keywords:["editor","vim","keymap"]},{id:"appearance.session-tabs",page:"general",titleKey:"settings.openchamber.visual.field.sessionTabsGroup",descriptionKey:"settings.openchamber.visual.field.sessionTabsInfo",keywords:["session","tabs","header","working set"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.terminal-quick-keys",page:"general",titleKey:"settings.openchamber.visual.field.terminalQuickKeys",descriptionKey:"settings.openchamber.visual.field.terminalQuickKeysTooltip",keywords:["terminal","keyboard","esc","ctrl","arrows"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.usage-reports",page:"general",titleKey:"settings.openchamber.visual.field.sendAnonymousUsageReports",descriptionKey:"settings.openchamber.visual.field.sendAnonymousUsageReportsHint",keywords:["telemetry","analytics"]},{id:"general.app-links",page:"general",titleKey:"settings.openchamber.appLinks.title",descriptionKey:"settings.openchamber.appLinks.info",keywords:["security","app link","deep link","scheme","protocol","obsidian","notion"]},{id:"chat.render-mode",page:"chat",titleKey:"settings.openchamber.visual.section.chatRenderMode",keywords:["messages","conversation","rendering"]},{id:"chat.message-transport",page:"general",titleKey:"settings.openchamber.visual.section.messageStreamTransport",keywords:["streaming","sse","websocket"]},{id:"chat.session-recap",page:"chat",titleKey:"settings.openchamber.visual.field.sessionRecap",keywords:["recap","assist","small model","summary"]},{id:"chat.session-assistance",page:"chat",titleKey:"settings.openchamber.visual.section.sessionAssistance",keywords:["recap","suggestion","subagent"]},{id:"chat.session-suggestion",page:"chat",titleKey:"settings.openchamber.visual.field.sessionSuggestion",keywords:["suggestion","assist","small model","follow up"]},{id:"chat.session-goal",page:"chat",titleKey:"settings.openchamber.visual.field.sessionGoal",keywords:["goal","objective","auto continue","small model"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-budget",page:"chat",titleKey:"settings.openchamber.visual.goal.budgetLabel",keywords:["goal","budget","tokens","limit"],isAvailable:t=>!t.isVSCode},{id:"chat.reasoning-traces",page:"chat",titleKey:"settings.openchamber.visual.field.showReasoningTraces",keywords:["thinking","reasoning"]},{id:"chat.reasoning",page:"chat",titleKey:"settings.openchamber.visual.section.reasoning",keywords:["thinking","traces"]},{id:"chat.streaming",page:"chat",titleKey:"settings.openchamber.visual.section.streaming",keywords:["stream","scroll"]},{id:"chat.streaming-auto-follow",page:"chat",titleKey:"settings.openchamber.visual.field.streamingAutoFollow",descriptionKey:"settings.openchamber.visual.field.streamingAutoFollowInfo",keywords:["autoscroll","auto-scroll","follow","stick to bottom","streaming"]},{id:"chat.sticky-user-header",page:"chat",titleKey:"settings.openchamber.visual.field.stickyUserHeader",keywords:["messages","header"]},{id:"chat.prompt-navigator",page:"chat",titleKey:"settings.openchamber.visual.field.promptNavigatorEnabled",keywords:["prompt","navigator","navigation","timeline","scroll"]},{id:"chat.collapsible-user-messages",page:"chat",titleKey:"settings.openchamber.visual.field.collapsibleUserMessages",keywords:["collapse","expand","clamp","long messages","user messages"]},{id:"chat.wide-layout",page:"chat",titleKey:"settings.openchamber.visual.field.wideChatLayout",keywords:["layout","wide","messages"]},{id:"chat.message-appearance",page:"chat",titleKey:"settings.openchamber.visual.section.messageAppearance",keywords:["layout","messages","appearance"]},{id:"chat.code-block-line-wrap",page:"chat",titleKey:"settings.openchamber.visual.field.codeBlockLineWrap",keywords:["code","wrap","line wrap","markdown"]},{id:"chat.inline-assistant-actions",page:"chat",titleKey:"settings.openchamber.visual.field.showSplitAssistantMessageActions",descriptionKey:"settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip",keywords:["copy","save image","read aloud"]},{id:"chat.draft-starters-visible",page:"chat",titleKey:"settings.openchamber.visual.field.draftStartersVisible",keywords:["starter","starters","new session","welcome","suggestions"]},{id:"chat.subagent-read-only-banner",page:"chat",titleKey:"settings.openchamber.visual.field.allowPromptingSubagentSessions",keywords:["subagent","read only","prompt","banner"]},{id:"chat.tool-file-icons",page:"chat",titleKey:"settings.openchamber.visual.field.showToolFileIcons",keywords:["tools","files","icons"]},{id:"chat.tools-and-files",page:"chat",titleKey:"settings.openchamber.visual.section.toolsAndFiles",keywords:["tools","files","dotfiles"]},{id:"chat.changed-files",page:"chat",titleKey:"settings.openchamber.visual.field.showTurnChangedFiles",keywords:["changed files","turns"]},{id:"chat.dotfiles",page:"chat",titleKey:"settings.openchamber.visual.field.showDotfiles",keywords:["hidden files"],isAvailable:t=>!t.isVSCode},{id:"chat.follow-up-behavior",page:"chat",titleKey:"settings.openchamber.visual.section.followUpBehavior",descriptionKey:"settings.openchamber.visual.field.followUpBehaviorDescription",keywords:["follow up","queue","steer","send immediately"]},{id:"chat.input-history-scope",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryScope",descriptionKey:"settings.openchamber.visual.field.inputHistoryScopeDescription",keywords:["input history","composer history","global","session","reuse"]},{id:"chat.input-history-limit",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryLimit",descriptionKey:"settings.openchamber.visual.field.inputHistoryLimitDescription",keywords:["history limit","prompt recall","remember prompts","composer history","submitted prompts","trim history"]},{id:"chat.persist-drafts",page:"chat",titleKey:"settings.openchamber.visual.field.persistDraftMessages",keywords:["draft","message"]},{id:"chat.composer",page:"chat",titleKey:"settings.openchamber.visual.section.composer",keywords:["input","draft","spellcheck","paste"]},{id:"chat.spellcheck",page:"chat",titleKey:"settings.openchamber.visual.field.enableSpellcheckInTextInputs",keywords:["spelling","input"],isAvailable:t=>!t.isMobile},{id:"chat.large-text-paste",page:"chat",titleKey:"settings.openchamber.visual.field.largeTextPaste",descriptionKey:"settings.openchamber.visual.field.largeTextPasteHint",keywords:["paste","clipboard","attachment","large","text","file"]},{id:"chat.enter-to-send",page:"chat",titleKey:"settings.openchamber.visual.field.enterToSend",descriptionKey:"settings.openchamber.visual.field.enterToSendHint",keywords:["enter","shift enter","ctrl enter","cmd enter","mod enter","send","newline"],isAvailable:t=>!t.isMobile},{id:"sessions.default-model",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultModel",keywords:["model","provider","new sessions"]},{id:"sessions.default-thinking",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultThinking",keywords:["thinking","reasoning","variant"]},{id:"sessions.default-agent",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultAgent",keywords:["agent","new sessions"]},{id:"sessions.deletion-dialog",page:"sessions",titleKey:"settings.openchamber.defaults.field.showDeletionDialog",keywords:["delete","confirmation"]},{id:"sessions.warming",page:"sessions",titleKey:"settings.openchamber.defaults.field.sessionWarming",descriptionKey:"settings.openchamber.defaults.field.sessionWarmingInfo",keywords:["warming","warm","cache","prompt cache","keep-alive","idle"]},{id:"sessions.small-model",page:"sessions",titleKey:"settings.openchamber.defaults.smallModel.title",descriptionKey:"settings.openchamber.defaults.smallModel.description",keywords:["small model","utility","summary","recap","cheap","override"]},{id:"sessions.walkthrough-model",page:"sessions",titleKey:"settings.openchamber.defaults.walkthroughModel.title",descriptionKey:"settings.openchamber.defaults.walkthroughModel.description",keywords:["walkthrough","diff","review","changes","structured output","model","override"]},{id:"sessions.auto-cleanup",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.enableAutoCleanup",descriptionKey:"settings.openchamber.sessionRetention.tooltip",keywords:["retention","archive","delete"]},{id:"sessions.retention-only-archived",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.onlyArchived",descriptionKey:"settings.openchamber.sessionRetention.field.onlyArchivedDescription",keywords:["archive","archived","only","delete","cleanup","retention"]},{id:"sessions.retention-period",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.retentionPeriod",keywords:["days","cleanup","retention"]},{id:"sessions.retention-action",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.whenSessionsExpire",keywords:["archive","delete","expire"]},{id:"sessions.desktop-launch-at-login",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.launchAtLogin",descriptionKey:"settings.openchamber.desktopNetwork.field.launchAtLoginDescription",keywords:["desktop","startup","login","launch","background","autostart"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-window-controls-position",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsPosition",descriptionKey:"settings.openchamber.desktopNetwork.field.windowControlsPositionDescription",keywords:["desktop","window","controls","minimize","maximize","close","titlebar","linux","windows"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-window-controls-style",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsStyle",keywords:["desktop","window","controls","style","traffic","lights","classic","macos","titlebar"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-mac-menu-bar",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.macMenuBar",descriptionKey:"settings.openchamber.desktopNetwork.field.macMenuBarDescription",keywords:["desktop","menu bar","tray","status item","macos","background"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isMac},{id:"sessions.desktop-minimize-to-tray",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.minimizeToTray",descriptionKey:"settings.openchamber.desktopNetwork.field.minimizeToTrayDescription",keywords:["desktop","tray","system tray","minimize","close","background","windows","linux"],isAvailable:t=>t.isDesktopLocalOrigin&&(t.isWindows||t.isLinux)},{id:"sessions.desktop-keep-awake",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.keepAwake",descriptionKey:"settings.openchamber.desktopNetwork.field.keepAwakeDescription",keywords:["desktop","sleep","awake","server","mobile","phone"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-ui-password",page:"general",titleKey:"settings.openchamber.desktopPassword.field.password",descriptionKey:"settings.openchamber.desktopPassword.field.passwordDescription",keywords:["desktop","password","auth","login"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-lan-access",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.allowLanAccess",descriptionKey:"settings.openchamber.desktopNetwork.field.allowLanAccessDescription",keywords:["desktop","lan","network","phone","tablet"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.opencode-binary",page:"general",titleKey:"settings.openchamber.opencodeCli.field.binaryPath",keywords:["opencode","cli","binary","path"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-restart",page:"general",titleKey:"settings.openchamber.opencodeCli.actions.restart",keywords:["opencode","restart","reload","plugin"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-update-notifications",page:"general",titleKey:"settings.openchamber.opencodeCli.field.showUpdateNotifications",keywords:["opencode","cli","updates"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-control-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentControlTool",descriptionKey:"settings.openchamber.tools.field.agentControlToolInfo",keywords:["agent","tool","orchestration","openchamber","sessions","schedule","control"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-web-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentWebTool",descriptionKey:"settings.openchamber.tools.field.agentWebToolInfo",keywords:["agent","tool","web","browser","page","preview","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.browser-provider",page:"general",titleKey:"settings.openchamber.tools.browserProvider.label",descriptionKey:"settings.openchamber.tools.browserProvider.info",keywords:["agent","browser","provider","extension","chrome","server","headless"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-notify-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentNotifyTool",descriptionKey:"settings.openchamber.tools.field.agentNotifyToolInfo",keywords:["agent","tool","notify","notification","alert","ping","openchamber"],isAvailable:t=>!t.isVSCode},{id:"general.isolated-spaces",page:"general",titleKey:"settings.openchamber.spaces.field.enabled",descriptionKey:"settings.openchamber.spaces.field.enabledInfo",keywords:["isolated","space","spaces","container","docker","sandbox","agent"],isAvailable:t=>!t.isVSCode&&Ko},{id:"sessions.agent-memory-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentMemoryTool",descriptionKey:"settings.openchamber.tools.field.agentMemoryToolInfo",keywords:["agent","tool","memory","remember","recall","preferences","openchamber"],isAvailable:t=>!t.isVSCode&&he.getState().agentMemoryFeatureAvailable},{id:"routing.token",page:"routing",titleKey:"settings.routing.token.label",descriptionKey:"settings.routing.token.info",keywords:["jev","typesafe","api key","token","routing","zen","free"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"routing.enabled",page:"routing",titleKey:"settings.routing.auto.enable",descriptionKey:"settings.routing.auto.enableInfo",keywords:["auto","routing","model","jev","automatic"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"routing.fallback-model",page:"routing",titleKey:"settings.routing.auto.fallbackModel",descriptionKey:"settings.routing.auto.fallbackModelInfo",keywords:["fallback","default","model","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"routing.safety-enabled",page:"routing",titleKey:"settings.routing.safety.enable",descriptionKey:"settings.routing.safety.enableInfo",keywords:["safety net","auto-accept","permissions","destructive","hold"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"routing.add-category",page:"routing",titleKey:"settings.routing.categories.title",descriptionKey:"settings.routing.categories.description",keywords:["category","categories","task type","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{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.openchamber.git.changesViewTitle",keywords:["changes","flat list","tree view"]},{id:"git.gitmoji",page:"git",titleKey:"settings.openchamber.git.enableGitmoji",keywords:["commit","emoji"]},{id:"git.gitignored-files",page:"git",titleKey:"settings.openchamber.git.showGitignored",keywords:["ignored","files","gitignore"]},{id:"usage.work-status-panel",page:"usage",titleKey:"settings.usage.page.options.showInWorkStatus",descriptionKey:"settings.usage.page.options.showInWorkStatusTooltip",keywords:["quota","work","status","panel"]},{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.default-agent",page:"projects",titleKey:"settings.projects.page.field.projectAgent",keywords:["agent","default","new chat","project metadata"]},{id:"projects.default-model",page:"projects",titleKey:"settings.projects.page.field.projectModel",keywords:["model","default","new chat","project metadata"]},{id:"projects.default-thinking",page:"projects",titleKey:"settings.projects.page.field.projectThinking",keywords:["thinking","variant","reasoning","effort","model","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.openchamber.worktrees.setup.waitForCommands",keywords:["worktree","setup commands","bootstrap","wait"]},{id:"projects.worktree.setup.replace",page:"projects",titleKey:"settings.projects.shared.replaceMode",keywords:["worktree","setup commands","shared","team","only mine"]},{id:"projects.shared",page:"projects",titleKey:"settings.projects.shared.title",descriptionKey:"settings.projects.shared.description",keywords:["shared","team","repository",".openchamber","project.json","trust"]},{id:"projects.shared.plansDir",page:"projects",titleKey:"settings.projects.shared.plansDir",descriptionKey:"settings.projects.shared.plansDirInfo",keywords:["plans","folder","shared","team","docs"]},{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:t=>!t.isVSCode},{id:"remote-instances.direct-hosts",page:"remote-instances",titleKey:"settings.remoteInstances.direct.title",descriptionKey:"settings.remoteInstances.direct.description",keywords:["server url","connection token","import link","host switcher","additional headers","request headers","cloudflare access","service token"],isAvailable:t=>t.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:"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.model",page:"agents",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"agents.variant",page:"agents",titleKey:"settings.agents.page.field.variant",descriptionKey:"settings.agents.page.field.variantTooltip",keywords:["thinking","reasoning","variant","depth"]},{id:"agents.temperature",page:"agents",titleKey:"settings.agents.page.field.temperature",descriptionKey:"settings.agents.page.field.temperatureTooltip",keywords:["randomness","creative"]},{id:"agents.top-p",page:"agents",titleKey:"settings.agents.page.field.topP",descriptionKey:"settings.agents.page.field.topPTooltip",keywords:["sampling","nucleus"]},{id:"agents.system-prompt",page:"agents",titleKey:"settings.agents.page.section.systemPrompt",keywords:["prompt","instructions"]},{id:"agents.steps",page:"agents",titleKey:"settings.agents.page.field.steps",descriptionKey:"settings.agents.page.field.stepsTooltip",keywords:["steps","loop","tool calls"]},{id:"agents.permissions",page:"agents",titleKey:"settings.agents.page.section.toolPermissions",keywords:["tools","permissions","rules","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.variant",page:"commands",titleKey:"settings.agents.page.field.variant",keywords:["variant","reasoning","thinking"]},{id:"commands.subagent",page:"commands",titleKey:"settings.commands.page.field.subagent",descriptionKey:"settings.commands.page.field.subagentTooltip",keywords:["subagent","background","child session"]},{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","code mode","codemode"]},{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:"snippets.create",page:"snippets",titleKey:"settings.snippets.sidebar.actions.create",keywords:["add","new snippet"]},{id:"snippets.content",page:"snippets",titleKey:"settings.snippets.page.field.content",keywords:["markdown","prompt","template"]},{id:"providers.connect",page:"providers",titleKey:"settings.providers.page.connect.title",keywords:["add provider","connect provider","credentials"]},{id:"providers.custom",page:"providers",titleKey:"settings.providers.page.custom.title",descriptionKey:"settings.providers.page.custom.description",keywords:["other","custom","openai-compatible","base url","api key"]},{id:"providers.auth",page:"providers",titleKey:"settings.providers.accounts.title",keywords:["api key","oauth","credentials","accounts","switch account","disconnect"]},{id:"providers.models",page:"providers",titleKey:"settings.providers.page.models.title",keywords:["models","hide","show"]},{id:"web-search.provider",page:"web-search",titleKey:"settings.webSearch.section.provider",descriptionKey:"settings.webSearch.section.providerInfo",keywords:["web search","websearch","internet","default provider","disable","off","random"]},{id:"web-search.keys",page:"web-search",titleKey:"settings.webSearch.section.keys",keywords:["api key","exa","tavily","firecrawl","parallel","tinyfish","credentials"]},{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:t=>!t.isVSCode},{id:"magic-prompts.instructions",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.instructions",keywords:["hidden prompt","instructions","template"],isAvailable:t=>!t.isVSCode},{id:"magic-prompts.reset-overrides",page:"magic-prompts",titleKey:"settings.magicPrompts.page.actions.resetAllOverrides",keywords:["reset","default prompts","overrides"],isAvailable:t=>!t.isVSCode},{id:"shortcuts.keyboard-shortcuts",page:"shortcuts",titleKey:"settings.openchamber.keyboardShortcuts.title",descriptionKey:"settings.openchamber.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"]},{id:"voice.speech-recognition",page:"voice",titleKey:"settings.voice.page.section.speechRecognition",keywords:["stt","dictation","voice input","transcribe","whisper","parakeet","microphone"]},{id:"tunnel.provider",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.provider",descriptionKey:"settings.openchamber.tunnel.description",keywords:["remote access","cloudflare","ngrok"],isAvailable:t=>!t.isVSCode},{id:"tunnel.type",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.tunnelType",keywords:["quick","managed remote","managed local"],isAvailable:t=>!t.isVSCode},{id:"tunnel.ttl",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.connectLinkTtl",descriptionKey:"settings.openchamber.tunnel.field.tunnelSessionTtl",keywords:["expiry","expiration","session ttl","connect link ttl"],isAvailable:t=>!t.isVSCode},{id:"tunnel.managed-remote",page:"tunnel",titleKey:"settings.openchamber.tunnel.section.savedManagedRemoteTunnels",keywords:["cloudflare","hostname","token","managed remote"],isAvailable:t=>!t.isVSCode},{id:"tunnel.managed-local-config",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.configurationFile",descriptionKey:"settings.openchamber.tunnel.note.managedLocalUsesConfig",keywords:["cloudflared","config","yaml","json","managed local"],isAvailable:t=>!t.isVSCode},{id:"tunnel.start",page:"tunnel",titleKey:"settings.openchamber.tunnel.actions.startTunnel",descriptionKey:"settings.openchamber.tunnel.note.connectLinksOneTime",keywords:["connect link","qr code","public url","remote access"],isAvailable:t=>!t.isVSCode},{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:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"integrations.first-party",page:"integrations",titleKey:"settings.integrations.firstParty.title",descriptionKey:"settings.integrations.firstParty.info",keywords:["built-in","first-party","native","github","linear"],isAvailable:t=>!t.isVSCode},{id:"integrations.github",page:"integrations",titleKey:"settings.integrations.github.title",descriptionKey:"settings.integrations.github.description",keywords:["github","account","oauth","gh","cli","prs","pull request","issues","connect"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear",page:"integrations",titleKey:"settings.integrations.linear.title",descriptionKey:"settings.integrations.linear.description",keywords:["linear","issues","oauth","connect","workspace"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.add-workspace",page:"integrations",titleKey:"settings.integrations.linear.actions.addWorkspace",descriptionKey:"settings.integrations.linear.description",keywords:["linear","workspace","add","connect","oauth"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.mapping",page:"integrations",titleKey:"settings.integrations.linear.mapping.defaultProject",descriptionKey:"settings.integrations.linear.mapping.defaultProject.info",keywords:["linear","project","team","map","workspace","directory"],isAvailable:t=>!t.isVSCode},{id:"integrations.guests",page:"integrations",titleKey:"settings.integrations.guests.title",descriptionKey:"settings.integrations.guests.info",keywords:["guest","extension","oauth","clickup","gitlab","panel","connect"],isAvailable:t=>!t.isVSCode},{id:"extensions.add",page:"extensions",titleKey:"settings.extensions.add.label",descriptionKey:"settings.extensions.add.info",keywords:["folder","path","zip","git","url","install","guest","panel"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.gitIdentity",page:"extensions",titleKey:"settings.extensions.identity.title",descriptionKey:"settings.extensions.add.info",keywords:["ssh","key","identity","git","private","clone","extension"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.updates.check",page:"extensions",titleKey:"settings.extensions.updates.check",keywords:["update","upgrade","version","git","extension","guest","refresh"],isAvailable:t=>!t.isVSCode&&!t.isMobile}];function wc(t){return t.trim().toLocaleLowerCase()}function L1({query:t,runtimeCtx:e,visiblePageSlugs:a,t:n,getPageTitle:r}){const i=wc(t);if(!i)return[];const l=a?new Set(a):null,d=i.split(/\s+/).filter(Boolean);return O1.flatMap(c=>{if(l&&!l.has(c.page))return[];const h=za(c.page);if(!h||h.isAvailable&&!h.isAvailable(e)||c.isAvailable&&!c.isAvailable(e))return[];const g=n(c.titleKey),f=c.descriptionKey?n(c.descriptionKey):null,m=wc([g,f,r(c.page),...c.keywords??[]].filter(Boolean).join(" "));return d.every(u=>m.includes(u))?[{...c,title:g,description:f,pageTitle:r(c.page)}]:[]})}const kc=256,Nc=280,Od="__openchamberSettingsDetail",K1=["general","appearance","chat","notifications","sessions","routing","shortcuts","voice","integrations","extensions","usage","about","projects","remote-instances","tunnel","git","providers","web-search","agents","behavior","commands","mcp","plugins","magic-prompts","snippets","skills.installed","skills.catalog"],z1=["general","projects","opencode","content"];function U1(t,e,a){const n=fs(),r=!t&&da();return{isVSCode:n,isWeb:r,isDesktop:t,isMobile:e,routingAvailable:a}}function Sc(t,e){return t.isAvailable?t.isAvailable(e):!0}function ho(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function oi(t,e){const a=new Set(e);let n=t,r=1;for(;a.has(n);)n=`${t}-${r}`,r+=1;return n}function Zr(t){if(!ho(t))return null;const e=t[Od];if(!ho(e))return null;const a=e.page,n=e.stage;return typeof a!="string"||n!=="page-content"?null:{page:Jc(a),stage:n}}function _1(){return typeof window>"u"||!ho(window.history.state)?{}:window.history.state}const aj=({onClose:t,forceMobile:e,isWindowed:a,visiblePageSlugs:n,initialMobileStage:r="nav",registerBackHandler:i})=>{const{t:l}=Qe(),d=Zn(),c=e??d.isMobile,h=he(ee=>ee.settingsPage),g=he(ee=>ee.isSettingsDialogOpen),f=he(ee=>ee.setSettingsPage),m=he(ee=>ee.shortcutOverrides.open_settings),u=Jc(h),[v,w]=o.useState(r),b=o.useRef(r==="nav"?u:null);o.useEffect(()=>{!c&&u==="home"&&f("general")},[c,f,u]);const[k,p]=o.useState(""),[S,N]=o.useState(null),[I,y]=o.useState(0),T=o.useRef(null),x=o.useRef(!1),A=o.useRef([]),R=o.useRef(0),P=o.useRef(!1),D=o.useMemo(()=>ls(),[]),F=o.useMemo(()=>ls()&&fi(),[]),O=o.useMemo(()=>ls()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),C=o.useMemo(()=>ls()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="win32",[]),M=o.useMemo(()=>ls()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="linux",[]),U=he(ee=>ee.routingFeatureAvailable),L=o.useMemo(()=>U1(D,c,U),[D,c,U]),W=o.useMemo(()=>{const ee=n?new Set(n):null;return Lm.filter(ae=>ae.slug!=="home").filter(ae=>!ee||ee.has(ae.slug)).filter(ae=>Sc(ae,L)).filter(ae=>!(L.isVSCode&&ae.slug==="projects")).filter(ae=>!(c&&ae.slug==="shortcuts"))},[L,c,n]),X=o.useMemo(()=>{const ee=new Map(K1.map((ae,fe)=>[ae,fe]));return W.slice().sort((ae,fe)=>(ee.get(ae.slug)??999)-(ee.get(fe.slug)??999))},[W]),J=pn(ee=>ee.activeProjectId),q=rn();o.useEffect(()=>{if(!(!g&&!L.isVSCode&&!a)){if(u==="agents"){Qn.getState().loadAgents(q);return}if(u==="commands"){Wa.getState().loadCommands(q);return}if(u==="mcp"){Yn.getState().loadMcpConfigs({directory:q});return}if(u==="plugins"){Jt.getState().loadPlugins();return}(u==="skills.installed"||u==="skills.catalog")&&(sn.getState().loadSkills(q),Ln.getState().loadCatalog()),u==="snippets"&&Yi.getState().loadSnippets()}},[J,g,a,L.isVSCode,q,u]);const z=o.useCallback(ee=>{if(f(ee),b.current=ee,!c)return;const ae=za(ee);if(!ae||ae.slug==="home"){w("nav");return}w(ae.kind==="split"?"page-sidebar":"page-content")},[c,f]),H=o.useMemo(()=>za(u),[u]),se=o.useMemo(()=>({general:"general",appearance:"visual",chat:"chat",shortcuts:"shortcuts",sessions:"sessions",notifications:"notifications",voice:"voice",tunnel:"tunnel"}),[]),B=o.useCallback(ee=>{switch(ee){case"general":return l("settings.page.general.title");case"projects":return l("settings.page.projects.title");case"remote-instances":return l("settings.page.remoteInstances.title");case"providers":return l("settings.page.providers.title");case"web-search":return l("settings.page.webSearch.title");case"usage":return l("settings.page.usage.title");case"agents":return l("settings.page.agents.title");case"behavior":return l("settings.page.behavior.title");case"commands":return l("settings.page.commands.title");case"mcp":return l("settings.page.mcp.title");case"plugins":return l("settings.page.plugins.title");case"skills.installed":return l("settings.page.skills.title");case"skills.catalog":return l("settings.page.skillsCatalog.title");case"git":return l("settings.page.git.title");case"integrations":return l("settings.page.integrations.title");case"extensions":return l("settings.page.extensions.title");case"appearance":return l("settings.page.appearance.title");case"chat":return l("settings.page.chat.title");case"shortcuts":return l("settings.page.shortcuts.title");case"sessions":return l("settings.page.sessions.title");case"routing":return l("settings.page.routing.title");case"magic-prompts":return l("settings.page.magicPrompts.title");case"snippets":return l("settings.page.snippets.title");case"notifications":return l("settings.page.notifications.title");case"voice":return l("settings.page.voice.title");case"tunnel":return l("settings.page.tunnel.title");case"about":return l("settings.page.about.title");default:return l("settings.view.home.title")}},[l]),ne=o.useMemo(()=>L1({query:k,runtimeCtx:{...L,isDesktopLocalOrigin:F,isMac:O,isWindows:C,isLinux:M},visiblePageSlugs:n,t:l,getPageTitle:B}),[B,F,O,C,M,L,k,l,n]),K=o.useCallback(ee=>{if(ee.id.startsWith("agents.")){const ae=Qn.getState(),fe=oi("new-agent",ae.agents.map(je=>je.name));return ae.setAgentDraft({name:fe,scope:"user"}),ae.setSelectedAgent(fe),ee.id==="agents.create"?"agents.name":ee.id}if(ee.id.startsWith("commands.")){const ae=Wa.getState(),fe=oi("new-command",ae.commands.map(je=>je.name));return ae.setCommandDraft({name:fe,scope:"user"}),ae.setSelectedCommand(fe),ee.id==="commands.create"?"commands.name":ee.id}if(ee.id.startsWith("mcp.")){const ae=Yn.getState(),fe=oi("new-mcp-server",ae.mcpServers.map(je=>je.name));return ae.setMcpDraft({name:fe,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),ae.setSelectedMcp(fe),ee.id==="mcp.create"?"mcp.server":ee.id}if(ee.id.startsWith("snippets.")){const ae=Yi.getState(),fe=oi("new-snippet",ae.snippets.map(je=>je.name));return ae.setSnippetDraft({name:fe,scope:"global"}),ae.setSelectedSnippet(fe),ee.id==="snippets.create"?"snippets.content":ee.id}if(ee.id.startsWith("skills.")){const ae=sn.getState(),fe=oi("new-skill",ae.skills.map(je=>je.name));return ae.setSkillDraft({name:fe,scope:"user",source:"opencode",description:"",instructions:""}),ae.setSelectedSkill(fe),ee.id==="skills.create"?"skills.basic-information":ee.id}return ee.id==="providers.connect"&&he.getState().setSettingsProvidersConnectRequested(!0),ee.id==="plugins.create"?"plugins.spec":ee.id},[]),Z=o.useMemo(()=>{const ee=[],ae=new Map;for(const fe of ne){let je=ae.get(fe.page);je||(je={page:fe.page,pageTitle:fe.pageTitle,results:[]},ae.set(fe.page,je),ee.push(je)),je.results.push(fe)}return ee},[ne]);o.useEffect(()=>{y(0),R.current=0,P.current=!1},[k]),o.useEffect(()=>{R.current=I},[I]),o.useEffect(()=>{A.current[I]?.scrollIntoView({block:"nearest"})},[I]),o.useEffect(()=>{I>=ne.length&&y(Math.max(0,ne.length-1)),A.current.length=ne.length},[I,ne.length]);const oe=o.useCallback(ee=>{const ae=K(ee);N(ae),z(ee.page),c&&w("page-content"),ee.id==="plugins.create"&&typeof window<"u"&&window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("openchamber:settings-open-plugin-add"))},50)},[c,z,K]),ue=o.useCallback(ee=>{if(k.trim()){if(ee.key==="Escape"){ee.preventDefault(),p("");return}if(ne.length!==0){if(ee.key==="ArrowDown"){ee.preventDefault(),P.current=!0,y(ae=>(ae+1)%ne.length);return}if(ee.key==="ArrowUp"){ee.preventDefault(),P.current=!0,y(ae=>(ae-1+ne.length)%ne.length);return}if(ee.key==="Enter"){ee.preventDefault();const ae=(R.current%ne.length+ne.length)%ne.length,fe=ne[ae]??ne[0];fe&&oe(fe)}}}},[oe,k,ne]);o.useEffect(()=>{const ee=S;if(!ee)return;let ae=!1;const fe=window.requestAnimationFrame(()=>{if(ae)return;const je=typeof CSS<"u"&&CSS.escape?CSS.escape(ee):ee.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Re=T.current?.querySelector(`[data-settings-item="${je}"]`);Re&&(N(null),Re.scrollIntoView({block:"center",behavior:"smooth"}),Re.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{Re.removeAttribute("data-settings-search-highlight")},1600))});return()=>{ae=!0,window.cancelAnimationFrame(fe)}},[S,u]);const de=o.useCallback(()=>s.jsx("div",{className:"flex h-full items-center justify-center px-6",children:s.jsxs("div",{className:"max-w-md text-center",children:[s.jsx("div",{className:Dc,children:l("settings.view.unavailable.title")}),s.jsx("p",{className:"typography-ui text-muted-foreground mt-1",children:l("settings.view.unavailable.description")})]})}),[l]),ce=o.useCallback((ee,ae)=>{switch(ee){case"projects":return s.jsx(Ff,{onItemSelect:ae.onItemSelect});case"agents":return s.jsx(Cp,{onItemSelect:ae.onItemSelect});case"commands":return s.jsx(fg,{onItemSelect:ae.onItemSelect});case"mcp":return s.jsx(Sg,{onItemSelect:ae.onItemSelect});case"plugins":return s.jsx(wh,{onItemSelect:ae.onItemSelect});case"skills.installed":return s.jsx(sf,{onItemSelect:ae.onItemSelect});case"usage":return s.jsx(Zx,{onItemSelect:ae.onItemSelect});case"magic-prompts":return s.jsx(hb,{onItemSelect:ae.onItemSelect});case"snippets":return s.jsx(vb,{onItemSelect:ae.onItemSelect});default:return null}},[]),Se=o.useCallback(ee=>{const ae=za(ee);if(ae&&!Sc(ae,L))return de();switch(ee){case"projects":return s.jsx(Uf,{});case"remote-instances":return s.jsx(dx,{});case"agents":return s.jsx(Yp,{});case"behavior":return s.jsx(ng,{});case"commands":return s.jsx(kg,{});case"mcp":return s.jsx(ih,{});case"plugins":return s.jsx(Bh,{});case"skills.installed":return s.jsx(Ml,{view:"installed"});case"skills.catalog":return s.jsx(Ml,{view:"catalog"});case"providers":return s.jsx(Qx,{});case"web-search":return s.jsx(lg,{});case"usage":return s.jsx(pb,{});case"about":return s.jsx(ts,{title:l("settings.page.about.title"),showSaveStatus:!1,children:s.jsx(Yc,{})});case"magic-prompts":return s.jsx(bb,{});case"snippets":return s.jsx(kb,{});case"git":return s.jsx(Pb,{});case"integrations":return s.jsx(Wb,{});case"routing":return s.jsx(sv,{});case"extensions":return s.jsx(Cv,{});case"general":case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"voice":case"tunnel":{const fe=se[ee]??"visual";return s.jsx(S1,{section:fe})}default:return null}},[se,de,L,l]);o.useEffect(()=>{if(!c||v!=="nav"||u==="home"||b.current===u)return;const ee=za(u);!ee||ee.slug==="home"||(b.current=u,w(ee.kind==="split"?"page-sidebar":"page-content"))},[c,v,u]);const re=c&&v!=="nav",ve=c&&v==="page-content"&&H?.kind==="split",ie=l(ve?"settings.view.actions.back":re?"settings.view.actions.backToSettings":"settings.view.actions.closeSettings"),me=Bc("open_settings",m===void 0?void 0:{open_settings:m}),ke=me?l("settings.view.actions.closeSettingsWithShortcut",{shortcut:ua(me)}):l("settings.view.actions.closeSettings"),Ae=o.useCallback(ee=>{if(typeof window>"u"||L.isVSCode)return;const ae=Zr(window.history.state);ae?.page===ee&&ae.stage==="page-content"||window.history.pushState({..._1(),[Od]:{page:ee,stage:"page-content"}},"",window.location.href)},[L.isVSCode]),pe=o.useCallback(()=>{x.current=!0,w("page-content"),Ae(u)},[Ae,u]);o.useEffect(()=>{if(!c||v!=="page-content"||!x.current)return;x.current=!1;const ee=window.requestAnimationFrame(()=>{T.current?.querySelector("[data-settings-page-heading]")?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(ee)}},[c,v,u]);const Le=o.useCallback(()=>{if(ve){if((typeof window<"u"?Zr(window.history.state):null)?.page===u&&!L.isVSCode){window.history.back();return}w("page-sidebar");return}w("nav")},[ve,L.isVSCode,u]);o.useEffect(()=>{if(i)return i(()=>!c||v==="nav"?!1:(Le(),!0)),()=>i(null)},[Le,c,v,i]),o.useEffect(()=>{if(!c||L.isVSCode)return;const ee=ae=>{if(za(u)?.kind!=="split")return;if(Zr(ae.state)?.page===u){w("page-content");return}w(je=>je==="page-content"?"page-sidebar":je)};return window.addEventListener("popstate",ee),()=>{window.removeEventListener("popstate",ee)}},[c,L.isVSCode,u]);const Ve=()=>{const ee=k.trim().length>0;return s.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"px-4 pt-3",children:s.jsxs("div",{className:"oc-surface-elevated flex h-10 items-center gap-1.5 rounded-md border border-border bg-surface-elevated/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-ring sm:h-8",children:[s.jsx(_,{name:"search",className:"h-4 w-4 shrink-0"}),s.jsx("input",{value:k,onChange:ae=>p(ae.target.value),onKeyDown:ue,placeholder:l("settings.view.search.placeholder"),"aria-label":l("settings.view.search.aria"),className:"typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70"}),ee&&s.jsx("button",{type:"button",onClick:()=>p(""),"aria-label":l("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:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsx(Ns,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx("div",{className:"flex flex-col gap-0.5 px-4 pt-4 pb-2",children:ee?ne.length>0?(()=>{let ae=0;return Z.map(fe=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70",children:fe.pageTitle}),fe.results.map(je=>{const Re=ae;ae+=1;const Ce=Re===I,_e=!!je.description;return s.jsxs("button",{type:"button",ref:Ke=>{A.current[Re]=Ke},onMouseMove:()=>{P.current=!1,y(Re)},onClick:()=>oe(je),className:Pe("flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",_e?"min-h-11 py-1.5":"py-2",Ce?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:je.title}),_e&&s.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:je.description})]},je.id)})]},fe.page))})():s.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:l("settings.view.search.noResults")}):(()=>{const ae=new Map;for(const je of X){const Re=je.group,Ce=ae.get(Re);Ce?Ce.push(je):ae.set(Re,[je])}return z1.map(je=>({group:je,pages:ae.get(je)??[]})).filter(je=>je.pages.length>0).map(({group:je,pages:Re},Ce)=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:Pe("px-3 pb-1 typography-micro font-semibold uppercase tracking-wide text-muted-foreground sm:px-2 sm:pb-0.5",Ce===0?"pt-1":"pt-4 sm:pt-3"),children:l(`settings.view.nav.group.${je}`)}),Re.map(_e=>{const Ke=u===_e.slug&&!(c&&v==="nav"),Fe=Km(_e.slug);return!Fe&&_e.slug!=="mcp"?null:s.jsx(ar,{children:s.jsx(ir,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>z(_e.slug),"aria-current":Ke?"page":void 0,className:Pe("flex h-11 w-full items-center gap-2.5 rounded-md px-3 overflow-hidden sm:h-8 sm:gap-2 sm:px-2",Ke?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[_e.slug==="mcp"?s.jsx(Qu,{className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}):s.jsx(_,{name:Fe,className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}),s.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap overflow-hidden transition-opacity duration-150 opacity-100",children:[s.jsx("span",{className:"typography-ui-label font-normal truncate",children:B(_e.slug)}),_e.slug==="tunnel"&&s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:l("settings.view.badge.beta")})]})]})})},_e.slug)})]},je))})()})})]})},ye=()=>{if(v==="nav")return s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx(Hn,{children:Ve()})})});if(!H)return s.jsx("div",{className:"flex-1 bg-background"});if(v==="page-sidebar"){if(H.kind!=="split"){const ae=Se(u);return s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Hn,{children:ae})})}return s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Hn,{children:ce(u,{onItemSelect:pe})})})}const ee=Se(u);return s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Hn,{children:ee})})},Te=()=>!H||u==="home"?null:H.kind==="split"?s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[s.jsx("div",{className:Pe("border-r",L.isVSCode?"bg-background":"bg-sidebar"),style:{width:Nc,minWidth:Nc,borderColor:"var(--interactive-border)"},children:s.jsx(Hn,{children:ce(u,{})})}),s.jsx(Ns,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Hn,{children:Se(u)})})]}):s.jsx(Ns,{outerClassName:"h-full min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Hn,{children:Se(u)})});return s.jsxs("div",{ref:T,"data-settings-view":"true",className:Pe("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),children:[c?s.jsxs("div",{className:Pe("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",v!=="nav"&&"border-b","bg-background"),style:v!=="nav"?{borderColor:"var(--interactive-border)"}:void 0,children:[re?s.jsx("button",{type:"button",onClick:Le,"aria-label":ie,className:"inline-flex h-9 w-9 flex-shrink-0 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-ring",children:s.jsx(_,{name:"arrow-left-s",className:"h-5 w-5"})}):null,s.jsx("div",{className:"min-w-0 flex-1 px-2 typography-ui-label font-medium text-foreground truncate",children:v==="nav"?l("settings.view.home.title"):H?B(H.slug):l("settings.view.home.title")}),t&&s.jsx("button",{type:"button",onClick:t,"aria-label":l("settings.view.actions.closeSettings"),title:ke,className:"inline-flex h-9 w-9 flex-shrink-0 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-ring",children:s.jsx(_,{name:"close",className:"h-5 w-5"})})]}):s.jsxs(s.Fragment,{children:[re&&s.jsx("div",{className:Pe("absolute left-3 z-50",a?"top-2":"top-3"),children:s.jsx("button",{type:"button",onClick:Le,"aria-label":l("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-ring",children:s.jsx(_,{name:"arrow-left-s",className:"h-5 w-5"})})}),t&&s.jsx("div",{className:Pe("absolute right-0.5 z-50",a?"top-0.5":"top-1"),children:s.jsx("button",{type:"button",onClick:t,"aria-label":l("settings.view.actions.closeSettings"),title:ke,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-ring",children:s.jsx(_,{name:"close",className:"h-5 w-5"})})})]}),s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:c?ye():s.jsxs(s.Fragment,{children:[s.jsx("div",{className:Pe("relative flex h-full min-h-0 flex-col overflow-hidden border-r",D?"bg-sidebar":L.isVSCode?"bg-background":"bg-sidebar"),style:{width:`${kc}px`,minWidth:`${kc}px`,borderColor:"var(--interactive-border)"},children:s.jsx(Hn,{children:Ve()})}),s.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:Te()})]})})]})};export{Yc as A,aj as S};