@openchambery/web 1.19.11 → 1.19.13-beta.1
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.
- package/dist/assets/{AgentAvatar-CX0a1rKE.js → AgentAvatar-CiQIIM0d.js} +1 -1
- package/dist/assets/AssistantView-YmeyxehG.js +2 -0
- package/dist/assets/{DiagramView-BQO1cBLs.js → DiagramView-BpZb-G9P.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CTlNE4Hg.js → FadeInOnReveal-nf6-ZCrs.js} +1 -1
- package/dist/assets/{Icon-BYM02QyU.js → Icon-CeKHYyKZ.js} +1 -1
- package/dist/assets/MarkdownRenderer-wpeGdciL.js +2 -0
- package/dist/assets/{MarkdownRendererImpl--takeMXN.js → MarkdownRendererImpl-Peu0GVSQ.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DGSqWcPN.js → MarkstreamRendererImpl-B-odd2Gz.js} +1 -1
- package/dist/assets/MobileDetailNavigation-CtYke_1C.js +1 -0
- package/dist/assets/{MobileShareBridge-D-BUjACe.js → MobileShareBridge-DIfOl8EZ.js} +3 -3
- package/dist/assets/MobileSurface-_KoX75Ff.js +2 -0
- package/dist/assets/{MultiRunWindow-BNR9ZWmD.js → MultiRunWindow-BT5Dwgzu.js} +1 -1
- package/dist/assets/{OnboardingScreen-DS2nugLX.js → OnboardingScreen-BPusUgFG.js} +1 -1
- package/dist/assets/{OverlayScrollbar-KUpvYHdv.js → OverlayScrollbar-DUghqFGg.js} +1 -1
- package/dist/assets/{SettingsView-DGerg-C2.js → SettingsView-BwQpbIZl.js} +11 -11
- package/dist/assets/{SettingsWindow-CSpd5JbJ.js → SettingsWindow-DfEGfyr8.js} +1 -1
- package/dist/assets/{TerminalView-DS-oUxJr.js → TerminalView-8402vpcO.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Q1k9-IaY.js → ToolOutputDialog-B5RdkhsG.js} +1 -1
- package/dist/assets/{appThemeRegistry-CG7D-3-q.js → appThemeRegistry-CIZ-shMD.js} +1 -1
- package/dist/assets/{button-C0cth9tl.js → button-DFPOdZ0g.js} +1 -1
- package/dist/assets/{clipboard-DJ4nQEuY.js → clipboard-C05anBwU.js} +1 -1
- package/dist/assets/{collapsible-DFT9cE80.js → collapsible-oGbEvbe1.js} +1 -1
- package/dist/assets/{context-menu-CAp74NfV.js → context-menu-DGz4_2hs.js} +1 -1
- package/dist/assets/{desktopHosts-Dc2PS66M.js → desktopHosts-BVJXQq1S.js} +1 -1
- package/dist/assets/{desktopRelayRestore-T9y0orqa.js → desktopRelayRestore-RDfuj1M7.js} +1 -1
- package/dist/assets/{diagram-BryzMuta.js → diagram-Csk5GpDC.js} +1 -1
- package/dist/assets/{dialog-CgbV5ljg.js → dialog-rrqB-H6q.js} +1 -1
- package/dist/assets/{es-BHqnSjoZ.js → es-FE0sJ9EC.js} +1 -1
- package/dist/assets/{fileQueries-BY-9OWzp.js → fileQueries-BcdWOPlD.js} +1 -1
- package/dist/assets/{fr-BfrlJY9i.js → fr-DNDCSfGt.js} +1 -1
- package/dist/assets/{gitApi-Cr-joUEw.js → gitApi-_P0FsoXe.js} +1 -1
- package/dist/assets/{input-DFLpqjGR.js → input-BO3r20op.js} +1 -1
- package/dist/assets/{insertionBoundaries-X0xbikAA.js → insertionBoundaries-CWoioTdE.js} +1 -1
- package/dist/assets/{ja-DP-7qt-x.js → ja-BDwrk0cM.js} +1 -1
- package/dist/assets/{ko-E2B5vGQP.js → ko-BeeU2o4I.js} +1 -1
- package/dist/assets/{main-D0L7fIg3.js → main-CLj_WS1o.js} +2 -2
- package/dist/assets/{main-BI7fNQoi.js → main-CnSZ89pD.js} +4 -4
- package/dist/assets/{markdown-worker-CTsrtpPh.js → markdown-worker-CZWE1F1M.js} +1 -1
- package/dist/assets/{markdownHeightCache-CYDlisxr.js → markdownHeightCache-Cdd3hkMl.js} +1 -1
- package/dist/assets/{markdownTheme-DyJ4Gfcj.js → markdownTheme-DIB8WVmz.js} +1 -1
- package/dist/assets/miniChat-B9c3y2pD.js +2 -0
- package/dist/assets/{mobile-OcCu_0mG.js → mobile-DvbXUfNS.js} +2 -2
- package/dist/assets/{multirun-B0G_BEIN.js → multirun-CxhTsmRq.js} +1 -1
- package/dist/assets/{persistence-DdUac14I.js → persistence-CVTWFaqe.js} +2 -2
- package/dist/assets/{pl-r8X5gRM5.js → pl-BYuzpcI5.js} +1 -1
- package/dist/assets/{platform-B4KKLnZ5.js → platform-BY_Gtsqr.js} +1 -1
- package/dist/assets/{projectMeta-BNOzn1QS.js → projectMeta-Dl5iPCB6.js} +1 -1
- package/dist/assets/{pt-BR-DcpdXCf5.js → pt-BR-Bn7cwEzv.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BREc3uhX.js → renderElectronMiniChatApp-CkJ51qCh.js} +2 -2
- package/dist/assets/renderMobileApp-DcjQPhWw.js +28 -0
- package/dist/assets/{runtimeConfig-P8nVMYzE.js → runtimeConfig-Bsk2kWsW.js} +1 -1
- package/dist/assets/runtimeEndpointReset-BBLFgl85.js +147 -0
- package/dist/assets/{sessionChangeSummary-hVby3sJk.js → sessionChangeSummary-DDVT7O5J.js} +1 -1
- package/dist/assets/{sessionLookup-C_9-9ggp.js → sessionLookup-C8VZn0gJ.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-C8_9kHqu.js → sortable-tabs-strip-s7UUxsa6.js} +1 -1
- package/dist/assets/src-BpHDMgud.css +2 -0
- package/dist/assets/{store-BDFdnk6l.js → store-n94dSb3M.js} +2 -2
- package/dist/assets/{terminalApi-947l7Ra3.js → terminalApi-C54_rKEK.js} +1 -1
- package/dist/assets/{textarea-Cgo_nWUU.js → textarea-BjX-KhMN.js} +1 -1
- package/dist/assets/{tooltip-BifLJ8o0.js → tooltip-CQGqGAG_.js} +1 -1
- package/dist/assets/{uk-Di0vl9V-.js → uk-CwpbHEa3.js} +1 -1
- package/dist/assets/{url-Pk6tQ1EZ.js → url-BMjqccCo.js} +1 -1
- package/dist/assets/{useAppFontEffects-CEmOsrr6.js → useAppFontEffects-BIFw36SA.js} +5 -5
- package/dist/assets/{useAssistantUIStore-me6s63b2.js → useAssistantUIStore-Cg9bsT4b.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-CxaK-zXh.js → useDesktopWindowControlsLayout-DoygEcN4.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BIwv5r5l.js → useEffectiveDirectory-DJSYYkVp.js} +1 -1
- package/dist/assets/{useFontPreferences-BCOBlaAd.js → useFontPreferences-B5_apbBC.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-DHm5kZPx.js → useMobileNavigationStore-DuTu0Mzh.js} +5 -5
- package/dist/assets/{useSessionAutoCleanup-CPLP9KWH.js → useSessionAutoCleanup-C-L9teva.js} +1 -1
- package/dist/assets/{useUIStore-CuaA8-Hp.js → useUIStore-DwpQTjLO.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-CZ4ZTWEH.js → useWorkerHighlightedLines-DxTfgdEi.js} +1 -1
- package/dist/assets/{utils-BiK3tBGM.js → utils-81nUI_xp.js} +1 -1
- package/dist/assets/{zh-CN-coFCfeQE.js → zh-CN-BpzFZ-LU.js} +1 -1
- package/dist/assets/{zh-TW-oDRZ1-yb.js → zh-TW-Bopgc5Eo.js} +1 -1
- package/dist/index.html +9 -9
- package/dist/mini-chat.html +9 -9
- package/dist/mobile.html +9 -9
- package/package.json +1 -1
- package/server/index.js +19 -0
- package/server/lib/assistants/DOCUMENTATION.md +21 -6
- package/server/lib/assistants/assign.js +455 -30
- package/server/lib/assistants/assign.test.js +351 -0
- package/server/lib/assistants/contact-active-turn.http.test.js +134 -0
- package/server/lib/assistants/contact-store.js +64 -0
- package/server/lib/assistants/contact-store.test.js +12 -0
- package/server/lib/assistants/contact-tools.js +216 -25
- package/server/lib/assistants/contact-tools.test.js +167 -0
- package/server/lib/assistants/contracts.js +2 -2
- package/server/lib/assistants/harness.js +20 -3
- package/server/lib/assistants/harness.test.js +120 -1
- package/server/lib/assistants/pi-tools.js +50 -3
- package/server/lib/assistants/pi-tools.test.js +25 -0
- package/server/lib/assistants/service.js +320 -27
- package/server/lib/assistants/service.test.js +581 -9
- package/server/lib/llm/DOCUMENTATION.md +31 -18
- package/server/lib/llm/catalog.js +91 -16
- package/server/lib/llm/catalog.test.js +152 -11
- package/server/lib/llm/generate.js +43 -7
- package/server/lib/llm/generate.test.js +98 -1
- package/server/lib/llm/temp-directory.js +34 -13
- package/server/lib/llm/temp-directory.test.js +57 -0
- package/server/lib/notifications/APNS.md +20 -4
- package/server/lib/notifications/DOCUMENTATION.md +5 -0
- package/server/lib/notifications/apns-runtime.js +136 -18
- package/server/lib/notifications/apns-runtime.test.js +128 -0
- package/server/lib/notifications/apns-titles.js +21 -1
- package/server/lib/notifications/live-activity-refresh-runtime.js +185 -0
- package/server/lib/notifications/live-activity-refresh-runtime.test.js +242 -0
- package/server/lib/notifications/runtime.js +93 -2
- package/server/lib/notifications/runtime.test.js +167 -4
- package/server/lib/opencode/settings-helpers.js +12 -0
- package/server/lib/opencode/settings-runtime.js +16 -0
- package/server/lib/opencode/settings-runtime.test.js +21 -0
- package/server/lib/scheduled-tasks/runtime.js +21 -0
- package/server/lib/scheduled-tasks/runtime.test.js +24 -0
- package/dist/assets/AssistantView-BwrcqJzu.js +0 -2
- package/dist/assets/MarkdownRenderer-C49bfcHx.js +0 -2
- package/dist/assets/MobileDetailNavigation-LZU2vFAs.js +0 -1
- package/dist/assets/MobileSurface-OAJjAQCZ.js +0 -2
- package/dist/assets/miniChat-BJ9AclZX.js +0 -2
- package/dist/assets/renderMobileApp-C4igZ42L.js +0 -28
- package/dist/assets/runtimeEndpointReset-6lVRspis.js +0 -147
- package/dist/assets/src-B-P5qIBc.css +0 -2
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{A as n,C as r,E as i,T as a,a as o,j as s,o as c,r as l,t as u,tt as d,u as f,y as p}from"./useUIStore-CuaA8-Hp.js";import{$t as m,Bt as h,D as g,E as _,Ht as v,Kt as y,O as b,R as x,Ut as S,Vt as C,Xt as w,Yt as T,a as E,bn as D,cn as O,d as k,en as A,et as j,f as M,gn as N,hn as P,i as F,k as I,kn as L,l as R,mn as z,qt as B,r as V,u as H,un as ee,xn as U}from"./persistence-DdUac14I.js";import{a as te,g as W,h as ne,i as re,l as ie,m as ae,n as oe,p as se,r as ce,t as le,u as ue}from"./desktopHosts-Dc2PS66M.js";import{n as de}from"./desktopRelayRestore-T9y0orqa.js";import{a as fe,i as pe,r as me,t as he}from"./vendor-zustand-B4dlGEM2.js";import{nt as ge,rt as _e}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as ve,Nt as ye,n as be,t as xe}from"./platform-B4KKLnZ5.js";import{n as Se}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as Ce}from"./vendor-react-DLPElpoQ.js";import{s as we}from"./vendor-tanstack-react-query-D7pys_c9.js";import{W as Te}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{r as Ee}from"./vendor-sonner-DVzioF3d.js";import{c as De,n as Oe}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ke,r as Ae,t as je}from"./clipboard-DJ4nQEuY.js";import{a as Me,i as Ne,r as Pe}from"./MobileShareBridge-D-BUjACe.js";import{$a as Fe,Aa as Ie,Bi as Le,Co as Re,Ea as ze,Ga as Be,Gi as Ve,Gt as He,Hi as Ue,Ja as We,Ka as Ge,Ki as Ke,Oa as qe,Qa as Je,So as Ye,Vi as Xe,Wi as Ze,Xa as Qe,Xr as $e,Ya as et,Za as tt,Zi as G,Zr as nt,ao as rt,bo as it,co as at,do as ot,dr as st,ei as ct,eo as lt,fo as ut,go as dt,ho as ft,io as pt,ja as mt,ka as ht,lo as gt,mo as _t,mr as K,no as vt,oi as yt,oo as bt,po as xt,qa as St,ro as Ct,so as wt,ti as Tt,to as Et,uo as Dt,vo as Ot,xo as kt}from"./useMobileNavigationStore-DHm5kZPx.js";import{a as At,d as jt,f as Mt,g as Nt,h as Pt,m as Ft,n as It,p as Lt,r as Rt,s as zt,t as Bt,u as Vt}from"./MobileDetailNavigation-LZU2vFAs.js";import{i as Ht}from"./useAssistantUIStore-me6s63b2.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,t as Jt}from"./dialog-CgbV5ljg.js";import{i as Yt,t as q}from"./utils-BiK3tBGM.js";import{t as Xt}from"./AgentAvatar-CX0a1rKE.js";import{n as J}from"./Icon-BYM02QyU.js";import{t as Y}from"./button-C0cth9tl.js";import{T as Zt,Z as Qt,_ as $t,a as en,b as tn,h as nn,i as rn,m as an,n as on,q as sn,x as cn}from"./projectMeta-BNOzn1QS.js";import{t as ln}from"./input-DFLpqjGR.js";import{i as un,n as dn,t as fn}from"./tooltip-BifLJ8o0.js";import{$ as pn,F as mn,G as hn,H as gn,I as _n,It as vn,K as yn,Lt as bn,M as xn,Mt as Sn,Nt as Cn,Ot as wn,P as Tn,Pt as En,Q as Dn,R as On,T as kn,V as An,Z as jn,_ as Mn,_t as Nn,a as Pn,c as Fn,ct as In,dt as X,et as Ln,f as Rn,ft as zn,g as Bn,gt as Vn,h as Hn,ht as Un,i as Wn,jt as Gn,kt as Kn,lt as qn,mt as Jn,ot as Yn,p as Xn,pt as Zn,q as Qn,s as $n,st as er,t as tr,u as nr,ut as rr,vt as ir,w as ar,xt as or,y as sr,yt as cr,z as lr}from"./useSessionAutoCleanup-CPLP9KWH.js";import{n as ur}from"./useThemeSystem-DMzWVJaW.js";import{i as dr,r as fr}from"./OverlayScrollbar-KUpvYHdv.js";import{n as pr}from"./useRuntimeAPIs-DSLXJybW.js";import{A as mr,N as hr,i as gr,n as _r}from"./appThemeRegistry-CG7D-3-q.js";import{n as vr}from"./MarkdownRenderer-C49bfcHx.js";import{n as yr,t as br}from"./textarea-Cgo_nWUU.js";import{a as xr}from"./url-Pk6tQ1EZ.js";import{c as Sr}from"./markdown-worker-CTsrtpPh.js";import{t as Cr}from"./sortable-tabs-strip-C8_9kHqu.js";import{$ as wr,A as Tr,B as Er,C as Dr,D as Or,E as kr,F as Ar,G as jr,H as Mr,I as Z,J as Nr,K as Pr,L as Fr,M as Ir,N as Lr,O as Rr,P as zr,Q as Br,R as Vr,S as Hr,T as Ur,U as Wr,V as Gr,W as Kr,X as qr,Y as Jr,Z as Yr,_ as Xr,a as Zr,b as Qr,c as $r,d as ei,f as ti,h as ni,j as ri,k as ii,l as ai,m as oi,n as si,p as ci,q as li,s as ui,u as di,v as fi,w as pi,y as mi,z as hi}from"./MobileSurface-OAJjAQCZ.js";import{a as gi,n as _i,r as vi,t as yi}from"./context-menu-CAp74NfV.js";import{n as bi,r as xi,t as Si}from"./collapsible-DFT9cE80.js";import{n as Ci,t as wi}from"./vendor-yaml-DIcAK3EC.js";import{t as Ti}from"./vendor-qrcode-DAuVxiQR.js";var Ei=Ce(),Q=e(_e(),1),$=ge(),Di=`https://github.com/yee94/openchamber`,Oi=`${Di}/issues/new`,ki=`https://discord.gg/ZYRSdnwwKA`,Ai=`https://x.com/openchamber_dev`,ji=800,Mi=()=>{try{let e=Se;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.OpenChamberOTA?.channel===`stable`?`stable`:`beta`}catch{return`beta`}},Ni=({initialUpdateDialogOpen:e=!1})=>{let{t}=ke(),[n,r]=Q.useState(e),[i,a]=Q.useState(!1),[o,s]=Q.useState(!1),[c,l]=Q.useState(null),[d,f]=Q.useState(null),[p,m]=Q.useState(null),[h,g]=Q.useState(null),_=Er(he(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),{isMobile:v}=dr(),y=u(e=>e.otaChannelOverride),b=u(e=>e.setOtaChannelOverride),x=be(),S=Mi(),C=y===`beta`||y===null&&S===`beta`,[w,T]=Q.useState(!1),[E,D]=Q.useState(()=>Tt()),O=Oe(e=>{yt(e),D(e)}),k=Oe(async e=>{if(e){b(`beta`),await Er.getState().checkForUpdates();return}b(`stable`),await Er.getState().checkForUpdates();let{info:t,otaDecision:n}=Er.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&a(!0)}),A=Oe(()=>{a(!1),b(`beta`),Er.getState().checkForUpdates()}),j=Oe(()=>{a(!1),r(!0),Er.getState().downloadUpdate()}),M=Oe(e=>{e||A()}),N=c||t(`settings.openchamber.about.state.unknown`),P=Oe(async()=>{if(!w){T(!0);try{let{outcome:e,eventCount:n}=await ct();if(e===`cancelled`)return;if(e===`failed`){K.error(t(`settings.openchamber.about.diagnostics.toast.failed`));return}K.success(t(n>0?`settings.openchamber.about.diagnostics.toast.exported`:`settings.openchamber.about.diagnostics.toast.empty`))}catch{K.error(t(`settings.openchamber.about.diagnostics.toast.failed`))}finally{T(!1)}}});Q.useEffect(()=>{let e=!1;return Wr().then(t=>{e||l(t)}),Mr().then(t=>{e||f(t)}),()=>{e=!0}},[]);let F=Gr(c,d)??N;Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await L(`/api/system/info`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.openchamberVersion==`string`&&n.openchamberVersion.trim().length>0?n.openchamberVersion.trim():null;e||m(r)}catch{e||m(null)}})(),()=>{e=!0}},[]),Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await L(`/api/opencode/upgrade-status`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.currentVersion==`string`&&n.currentVersion.trim().length>0?n.currentVersion.trim():null;e||g(r)}catch{e||g(null)}})(),()=>{e=!0}},[]);let I=Q.useRef(!1);Q.useEffect(()=>{if(_.checking)s(!0),I.current=!0;else if(o){let e=setTimeout(()=>{s(!1),I.current&&_.error?(K.error(t(`settings.openchamber.about.toast.checkFailed`),{description:_.error}),I.current=!1):I.current&&!_.available&&!_.error&&(K.success(t(`settings.openchamber.about.toast.latestVersion`)),I.current=!1)},ji);return()=>clearTimeout(e)}},[t,_.checking,o,_.available,_.error]);let R=_.checking||o;return v?(0,$.jsxs)(`div`,{className:`w-full space-y-6 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Un,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`OpenChamber`})]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Fr,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:F})}),(0,$.jsx)(Fr,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:p||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Fr,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:h||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Fr,{children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,children:(0,$.jsxs)(`a`,{href:Oi,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(J,{name:`question`,className:`size-4`}),t(`settings.openchamber.about.actions.submitFeedback`)]})}),!R&&_.available?(0,$.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`size-4`}),_.info?.inAppApply?t(`settings.openchamber.about.actions.applyOtaToVersion`,{version:_.info?.version||``}):_.info?.manualUpdate?t(`settings.openchamber.about.actions.installNativeToVersion`,{version:_.info?.version||``}):t(`settings.openchamber.about.actions.updateToVersion`,{version:_.info?.version||``})]}):(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>_.checkForUpdates(),disabled:R,children:[R?(0,$.jsx)(J,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(J,{name:`refresh`,className:`size-4`}),t(R?`settings.openchamber.about.state.checking`:`settings.openchamber.about.actions.checkForUpdates`)]})]})}),_.error&&(0,$.jsx)(Fr,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:_.error})}),x&&(0,$.jsx)(Vr,{itemId:`about.beta-updates`,checked:C,onChange:k,label:t(`settings.openchamber.about.betaUpdates.label`),description:t(`settings.openchamber.about.betaUpdates.description`),ariaLabel:t(`settings.openchamber.about.betaUpdates.label`),disabled:R}),(0,$.jsx)(Vr,{itemId:`about.diagnostics`,checked:E,onChange:O,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),E&&(0,$.jsx)(Fr,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:w,onClick:()=>void P(),children:t(w?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-5`,children:[(0,$.jsxs)(`a`,{href:Di,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:ki,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`discord-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`Discord`})]})]}),(0,$.jsxs)(`a`,{href:Ai,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(hi,{open:n,onOpenChange:r,info:_.info,downloading:_.downloading,downloaded:_.downloaded,progress:_.progress,error:_.error,onDownload:_.downloadUpdate,onRestart:_.restartToUpdate,runtimeType:_.runtimeType}),(0,$.jsx)(Jt,{open:i,onOpenChange:M,children:(0,$.jsxs)(Gt,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:t(`settings.openchamber.about.betaUpdates.rollback.title`)}),(0,$.jsx)(qt,{children:t(`settings.openchamber.about.betaUpdates.rollback.description`,{version:_.info?.version||``})})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,onClick:A,children:t(`settings.openchamber.about.betaUpdates.rollback.actions.cancel`)}),(0,$.jsx)(Y,{type:`button`,size:`sm`,onClick:j,children:t(`settings.openchamber.about.betaUpdates.rollback.actions.confirm`)})]})]})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:t(`settings.openchamber.about.title`),children:[(0,$.jsx)(Fr,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:N})}),(0,$.jsx)(Fr,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:p||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Fr,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:h||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Fr,{children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-3`,children:[(0,$.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,children:(0,$.jsxs)(`a`,{href:Oi,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(J,{name:`question`,className:`size-4`}),t(`settings.openchamber.about.actions.submitFeedback`)]})}),_.checking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:t(`settings.openchamber.about.state.checking`)})]}),!_.checking&&_.available&&(0,$.jsxs)(Y,{size:`sm`,variant:`default`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`h-4 w-4 mr-1`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:_.info?.version||``})]}),!_.checking&&!_.available&&!_.error&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.about.state.upToDate`)}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>_.checkForUpdates(),disabled:_.checking,children:t(`settings.openchamber.about.actions.checkForUpdates`)})]})}),_.error&&(0,$.jsx)(Fr,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:_.error})}),(0,$.jsx)(Vr,{itemId:`about.diagnostics`,checked:E,onChange:O,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),E&&(0,$.jsx)(Fr,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:w,onClick:()=>void P(),children:t(w?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})}),(0,$.jsxs)(Fr,{controlClassName:`flex-wrap`,children:[(0,$.jsxs)(`a`,{href:Di,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Ai,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]})]}),(0,$.jsx)(hi,{open:n,onOpenChange:r,info:_.info,downloading:_.downloading,downloaded:_.downloaded,progress:_.progress,error:_.error,onDownload:_.downloadUpdate,onRestart:_.restartToUpdate,runtimeType:_.runtimeType})]})},Pi=`/assets/android-direct-share-1a0lp154.jpg`,Fi=`/assets/ios-share-sheet-B3Dlufnc.jpg`,Ii=`/assets/select-assistant-C89IRspC.jpg`,Li=`openchamber:assistant-share-welcome:v1`,Ri=[{image:Fi,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:Pi,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Ii,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],zi=e=>{let t=(0,Ei.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=ke(),[s,c]=De(Li,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=Oe(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(J,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(Kt,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(qt,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)(Ut,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=Ri.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(Wt,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(Y,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(Gt,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(Jt,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Bi=`useCommandsStore`,Vi=new Set([`init`,`review`]),Hi=e=>new Promise(t=>setTimeout(t,e)),Ui=e=>Vi.has(e.name),Wi=async(e,t)=>{await ut(H,e,t),i()===t&&kt(`commands`,{source:Bi})},Gi=fe()(me(pe(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=xt(),t=i();try{return await ut(H,e,t),!0}catch{return!1}},createCommand:async t=>Ki(`POST`,t.name,t,e),updateCommand:async(t,n)=>Ki(`PATCH`,t,n,e),deleteCommand:async t=>Ki(`DELETE`,t,void 0,e),getCommandByName:e=>ot().find(t=>t.name===e)}),{name:`commands-store`,storage:p(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Ki(e,t,n,r){Ot(`${{POST:`Creating`,PATCH:`Updating`,DELETE:`Deleting`}[e]} command configuration…`);let a=xt(),o=i(),s=!1;try{let i={};if(e===`POST`&&(i.template=n?.template||``,n?.description&&(i.description=n.description),n?.agent&&(i.agent=n.agent),n?.model&&(i.model=n.model),n?.scope&&(i.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(i[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,l=await L(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(i)}}),u=await l.json().catch(()=>null);if(!l.ok)throw Error(u?.error||`Failed to ${e.toLowerCase()} command`);return s=u?.requiresReload??!0,s?await qi(a,o,{message:u?.message,delayMs:u?.reloadDelayMs}):await Wi(a,o),e===`DELETE`&&r({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}finally{dt()}}async function qi(e,t,n){n.delayMs&&await Hi(n.delayMs),it(n.message||`Refreshing commands…`),await Wi(e,t)}typeof window<`u`&&(window.__zustand_commands_store__=Gi),Re(e=>{e.source!==Bi&&Ye(e,`commands`)&&Gi.getState().loadCommands()});var Ji=()=>{try{let e=ft.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=ye.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},Yi=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],Xi=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Zi=e=>{if(typeof e==`string`)return e.trim()||void 0},Qi=800,$i=fe()(me(pe((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=Ji();try{return!e?.force&&jr(H,t).length>0||await li(H,t,i()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{Ot(`Creating MCP server configuration…`);let n=!1,r=`directory`in(t??{})?t?.directory?.trim()||null:Ji(),a=t?.transportIdentity??i();try{let t=ea(e),i=r?`?directory=${encodeURIComponent(r)}`:``,o=await L(`/api/config/mcp/${encodeURIComponent(e.name)}${i}`,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return s?.requiresReload?(n=!0,await St({message:s.message,delayMs:s.reloadDelayMs??Qi,scopes:[`mcp`],queryDirectory:r,transportIdentity:a}),await li(H,r,a),await Nr(H,r,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):(await li(H,r,a),await Nr(H,r,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning})}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}finally{n||dt()}},updateMcp:async(e,t,n)=>{Ot(`Updating MCP server configuration…`);let r=!1,a=`directory`in(n??{})?n?.directory?.trim()||null:Ji(),o=n?.transportIdentity??i();try{let n=ea(t),i=a?`?directory=${encodeURIComponent(a)}`:``,s=await L(`/api/config/mcp/${encodeURIComponent(e)}${i}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return c?.requiresReload?(r=!0,await St({message:c.message,delayMs:c.reloadDelayMs??Qi,scopes:[`mcp`],queryDirectory:a,transportIdentity:o}),await li(H,a,o),await Nr(H,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):(await li(H,a,o),await Nr(H,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning})}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}finally{r||dt()}},deleteMcp:async(n,r)=>{Ot(`Deleting MCP server configuration…`);let a=!1,o=`directory`in(r??{})?r?.directory?.trim()||null:Ji(),s=r?.transportIdentity??i();try{let r=o?`?directory=${encodeURIComponent(o)}`:``,i=await L(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),c=await i.json().catch(()=>null);if(!i.ok)throw Error(c?.error||`Failed to delete MCP server`);return c?.requiresReload&&(a=!0,await St({message:c.message,delayMs:c.reloadDelayMs??Qi,scopes:[`mcp`],queryDirectory:o,transportIdentity:s})),t().selectedMcpName===n&&e({selectedMcpName:null}),Kr.getState().clearDiagnostic(n,o,s),await li(H,o,s),await Nr(H,o,s),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}finally{a||dt()}}}),{name:`mcp-config-store`,storage:p(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function ea(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=Xi(e.environment)??{}),e.headers!==void 0&&(t.headers=Xi(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Zi(e.oauthClientId),clientSecret:Zi(e.oauthClientSecret),scope:Zi(e.oauthScope),redirectUri:Zi(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var ta=()=>{let e=ye.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},na=`useSkillsStore`,ra=e=>new Promise(t=>setTimeout(t,e)),ia=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=ta();return typeof t==`string`&&t.trim()||null},aa=2e4,oa=300,sa=4,ca=800,la=200,ua=2e3,da=fe()(me(pe((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await tt(H,ta(),i()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=ta(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await L(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{Ot(`Creating skill...`);let n=!1;try{let r={name:e.name,description:e.description};e.instructions&&(r.instructions=e.instructions),e.scope&&(r.scope=e.scope),e.source&&(r.source=e.source),e.supportingFiles&&(r.supportingFiles=e.supportingFiles);let a=ia(t),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await L(`/api/config/skills/${encodeURIComponent(e.name)}${s}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to create skill`;throw Error(e)}return l?.requiresReload??!1?(n=!0,await pa({message:l?.message,delayMs:l?.reloadDelayMs,directory:a,transportIdentity:o}),!0):(await tt(H,a,o),await vt(H,a,o),kt(`skills`,{source:na}),!0)}catch{return!1}finally{n||dt()}},updateSkill:async(e,t,n)=>{Ot(`Updating skill...`);let r=!1;try{let a={};t.description!==void 0&&(a.description=t.description),t.instructions!==void 0&&(a.instructions=t.instructions),t.supportingFiles!==void 0&&(a.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(a.targetPath=t.targetPath);let o=ia(n),s=i(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await L(`/api/config/skills/${encodeURIComponent(e)}${c}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return u?.requiresReload??!1?(r=!0,await pa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await tt(H,o,s),await vt(H,o,s),kt(`skills`,{source:na}),!0)}catch{return!1}finally{r||dt()}},deleteSkill:async(n,r)=>{Ot(`Deleting skill...`);let a=!1;try{let o=ia(r),s=i(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await L(`/api/config/skills/${encodeURIComponent(n)}${c}`,{method:`DELETE`}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return u?.requiresReload??!1?(a=!0,await pa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await tt(H,o,s),await vt(H,o,s),kt(`skills`,{source:na}),t().selectedSkillName===n&&e({selectedSkillName:null}),!0)}catch{return!1}finally{a||dt()}},getSkillByName:e=>Qe(H,ta()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=ta(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await L(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=ta(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await L(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=ta(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await L(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:p(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=da);async function fa(e){let t=typeof e==`number`&&e>0?Math.min(e,oa):0;t>0&&await ra(t);let n=Date.now(),r=0,i=null;for(;Date.now()-n<aa;){r+=1,it(`Waiting for OpenCode… (attempt ${r})`);try{if(await ye.checkHealth())return;i=Error(`OpenCode health check reported not ready`)}catch(e){i=e}let e=Date.now()-n;await ra(r<=sa&&e<1200?oa:Math.min(ca+Math.max(0,r-sa)*la,ua))}throw i||Error(`OpenCode did not become ready in time`)}async function pa(e){let t=e&&`directory`in e?e.directory?.trim()||null:ta(),n=e?.transportIdentity??i();try{it(e?.message||`Refreshing skills…`)}catch{}try{if(await fa(e?.delayMs),i()!==n||(it(`Refreshing skills…`),await tt(H,t,n),i()!==n))return;await vt(H,t,n),kt(`skills`,{source:na})}catch(e){throw it(`OpenCode refresh failed. Please retry.`),await ra(1500),e}finally{dt()}}var ma=null;ma||=Re(e=>{if(e.source!==na&&Ye(e,`skills`)){let e=ta(),t=i();tt(H,e,t).then(()=>vt(H,e,t)).catch(()=>void 0)}});var ha=e=>{let t=(0,Ei.c)(37),{className:n}=e,{t:r}=ke(),i=ft(ga),a=ft(_a),o=ft(va),s=m(),c;t[0]===i?c=t[1]:(c=[...i].sort(ya),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let p=f,h;t[8]===n?h=t[9]:(h=q(n),t[8]=n,t[9]=h);let g;t[10]===r?g=t[11]:(g=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=g);let _;t[12]===r?_=t[13]:(_=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=_);let v,y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=q(`text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none`,`hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70`,`flex items-center gap-1.5 text-left`),y=(0,$.jsx)(J,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=v,t[15]=y):(v=t[14],y=t[15]);let b;t[16]===p?b=t[17]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(J,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=x):x=t[18];let S;t[19]!==g||t[20]!==_||t[21]!==b?(S=(0,$.jsx)(An,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":g,title:_,className:v,children:[y,b,x]})}),t[19]=g,t[20]=_,t[21]=b,t[22]=S):S=t[22];let C=d?.id??``,w;t[23]===o?w=t[24]:(w=e=>{e&&o(e)},t[23]=o,t[24]=w);let T;t[25]===l?T=t[26]:(T=l.map(ba),t[25]=l,t[26]=T);let E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,$.jsx)(mn,{align:`start`,className:`w-auto`,children:(0,$.jsx)(On,{value:C,onValueChange:w,children:T})}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==S||t[32]!==E?(D=(0,$.jsxs)(Tn,{children:[S,E]}),t[31]=S,t[32]=E,t[33]=D):D=t[33];let O;return t[34]!==D||t[35]!==h?(O=(0,$.jsx)(`div`,{className:h,children:D}),t[34]=D,t[35]=h,t[36]=O):O=t[36],O};function ga(e){return e.projects}function _a(e){return e.activeProjectId}function va(e){return e.setActiveProject}function ya(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function ba(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(lr,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function xa(e,t){return`opencode:sidebar-group:${e}:${t}`}var Sa=e=>{let t=(0,Ei.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=xa(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(Ca),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(J,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=q(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(Z,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(wa),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`flex w-full items-center gap-1 rounded-md px-2 py-1 text-left`,`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,`hover:bg-[var(--interactive-hover)] transition-colors duration-150`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(J,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function Ca(e){return!e}function wa(e){return!e}var Ta=e=>{if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.permission==`string`&&typeof e.pattern==`string`&&typeof e.action==`string`&&(e.action===`allow`||e.action===`ask`||e.action===`deny`)&&t.push({permission:e.permission,pattern:e.pattern,action:e.action})}return t},Ea=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&t.set(`${n.permission}::${n.pattern}`,n);return Array.from(t.values())},Da=e=>{let t=Ea(Ta(e));if(t.length===0)return;let n={};for(let e of t)e.permission&&((n[e.permission]||={})[e.pattern]=e.action);let r={};for(let[e,t]of Object.entries(n)){let n=Object.keys(t);if(n.length===1&&n[0]===`*`){r[e]=t[`*`];continue}r[e]=t}return Object.keys(r).length>0?r:void 0},Oa=({onItemSelect:e})=>{let{t}=ke(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=et(he(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=gt();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(Be(e)){K.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{Be(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?K.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):K.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?K.error(t(`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?K.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;let i=e,a=e.model?.providerID&&e.model?.modelID?`${e.model.providerID}/${e.model.modelID}`:null,o=e;g({name:r,scope:i.scope||`user`,description:e.description,model:a,variant:e.variant,temperature:e.temperature,top_p:e.topP,prompt:e.prompt,mode:e.mode,permission:Da(e.permission),disable:o.disable}),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){K.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){K.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,o=n,s=await _({name:e,description:n.description,model:a,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:Da(n.permission),disable:o.disable,scope:o.scope});if(s.ok){let r=await v(n.name,o.scope);r.ok?(s.requiresManualRestart||r.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):K.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):K.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else K.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(J,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(J,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(J,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>!Ge(e)),j=A.filter(Be),M=A.filter(e=>!Be(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(Y,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(ha,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(Z,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(ka,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(Sa,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(ka,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(Z,{label:F,children:P.map(t=>(0,$.jsx)(ka,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(Jt,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(Gt,{className:`max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(qt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(Jt,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(Gt,{children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(qt,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(ln,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},ka=e=>{let t=(0,Ei.c)(52),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=ke(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=fr(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[12]=n.name,t[13]=w);let T;t[14]!==n.mode||t[15]!==l?(T=l(n.mode),t[14]=n.mode,t[15]=l,t[16]=T):T=t[16];let E;t[17]!==n||t[18]!==p.scope||t[19]!==f?(E=(p.scope||Be(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Be(n)?f(`settings.agents.sidebar.badge.system`):p.scope}),t[17]=n,t[18]=p.scope,t[19]=f,t[20]=E):E=t[20];let D;t[21]!==w||t[22]!==T||t[23]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[w,T,E]}),t[21]=w,t[22]=T,t[23]=E,t[24]=D):D=t[24];let O;t[25]===n.description?O=t[26]:(O=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[25]=n.description,t[26]=O);let k;t[27]!==i||t[28]!==D||t[29]!==O?(k=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[D,O]}),t[27]=i,t[28]=D,t[29]=O,t[30]=k):k=t[30];let A;t[31]===d?A=t[32]:(A=e=>{e&&_(!1),d(e)},t[31]=d,t[32]=A);let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[33]=j):j=t[33];let M;t[34]===y?M=t[35]:(M=(0,$.jsx)(mn,{align:`end`,className:`w-fit min-w-20`,children:y(_n)}),t[34]=y,t[35]=M);let N;t[36]!==u||t[37]!==A||t[38]!==M?(N=(0,$.jsxs)(Tn,{open:u,onOpenChange:A,children:[j,M]}),t[36]=u,t[37]=A,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==k||t[41]!==N?(P=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[k,N]}),t[40]=k,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==P||t[44]!==C?(F=(0,$.jsx)(gi,{render:C,children:P}),t[43]=P,t[44]=C,t[45]=F):F=t[45];let I;t[46]===y?I=t[47]:(I=(0,$.jsx)(_i,{className:`w-fit min-w-20`,children:y(vi)}),t[46]=y,t[47]=I);let L;return t[48]!==g||t[49]!==F||t[50]!==I?(L=(0,$.jsxs)(yi,{open:g,onOpenChange:_,children:[F,I]}),t[48]=g,t[49]=F,t[50]=I,t[51]=L):L=t[51],L},Aa=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),ja=(e,t)=>{let n=Aa(e),r=Aa(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},Ma=(e,t)=>t?e.globalPermission!==t.globalPermission||!ja(e.permissionRules,t.permissionRules):!1,Na=e=>{let t=e.trim();return t===``?null:t},Pa=e=>{let t=e.trim();return t===``?null:t},Fa=e=>e.trim()||void 0,Ia=e=>e.trim()||null,La=({isNewAgent:e,agentName:t,draftScope:n,draftHasExplicitPermission:r,current:i,initial:a,permissionConfig:o})=>{if(e){let e=Ma(i,a)||r,s=i.description.trim(),c=Na(i.model),l=Pa(i.variant),u=Fa(i.prompt);return{name:t,mode:i.mode,...s?{description:s}:{},...c?{model:c}:{},...l?{variant:l}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...i.topP===void 0?{}:{top_p:i.topP},...u?{prompt:u}:{},...e?{permission:o}:{},...n?{scope:n}:{}}}let s={name:t};if(!a)return s;if(i.description!==a.description){let e=i.description.trim();e&&(s.description=e)}return i.mode!==a.mode&&(s.mode=i.mode),i.model!==a.model&&(s.model=Na(i.model)),i.variant!==a.variant&&(s.variant=Pa(i.variant)??null),i.temperature!==a.temperature&&(s.temperature=i.temperature??null),i.topP!==a.topP&&(s.top_p=i.topP??null),i.prompt!==a.prompt&&(s.prompt=Ia(i.prompt)),Ma(i,a)&&(s.permission=o),s},Ra=[`*`,`read`,`edit`,`glob`,`grep`,`list`,`bash`,`task`,`skill`,`lsp`,`todoread`,`todowrite`,`webfetch`,`websearch`,`codesearch`,`external_directory`,`doom_loop`,`question`],za=e=>e===`allow`||e===`ask`||e===`deny`,Ba=(e,t)=>`${e}::${t}`,Va=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&za(n.action)&&t.set(Ba(n.permission,n.pattern),{permission:n.permission,pattern:n.pattern,action:n.action});return Array.from(t.values())},Ha=e=>{let t=new Map;for(let n of Va(e))t.set(Ba(n.permission,n.pattern),n);return t},Ua=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Wa=(e,t)=>{let n=Ua(Va(e)),r=Ua(Va(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},Ga=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,Ka=(e,t)=>Va(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),qa=e=>{if(Array.isArray(e))return Va(e);if(za(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(za(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))za(i)&&t.push({permission:n,pattern:e,action:i})}return t},Ja=(e,t)=>{let n=Va(t),r={};for(let e of n)(r[e.permission]||={})[e.pattern]=e.action;let i={};for(let[e,t]of Object.entries(r))if(e!==`*`){if(Object.keys(t).length===1&&t[`*`]){i[e]=t[`*`];continue}i[e]=t}return Object.keys(i).length===0?e:(e!==`allow`&&(i[`*`]=e),i)},Ya=(e,t)=>{let n=mt(t);if(!n)return[];let r=e.find(e=>e.id===n.providerId)?.models?.find(e=>e.id===n.modelId);return r?.variants?Object.keys(r.variants):[]},Xa=()=>{let{t:e}=ke(),t=G(e=>e.providers),{selectedAgentName:n,getAgentByName:r,createAgent:i,updateAgent:a,agentDraft:o,setAgentDraft:s}=et(he(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:c=[]}=gt(),l=n?r(n):null,u=!!(o&&o.name===n&&!l),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(void 0),[T,E]=Q.useState(void 0),[D,O]=Q.useState(``),[k,A]=Q.useState(`allow`),[j,M]=Q.useState([]),[N,P]=Q.useState([]),[F,I]=Q.useState(``),[L,R]=Q.useState(`*`),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),ee=Q.useRef(null),U=ve(e=>e.currentDirectory??null),[te,W]=Q.useState([]),ne=Q.useMemo(()=>Ya(t,y),[y,t]),re=ne.length>0,ie=Q.useMemo(()=>!x||!ne.includes(x)?`__default`:x,[x,ne]),ae=re&&(!x||ne.includes(x)),oe=He(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await ye.listToolIds({directory:U});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));W(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[U]);let se=Q.useMemo(()=>{let e=new Set;for(let t of c){let n=Va(qa(t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(oe))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of te)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[c,oe,te]),ce=Q.useMemo(()=>Ha(j),[j]),le=Q.useMemo(()=>Ha(N),[N]),ue=Q.useCallback(e=>le.get(Ba(e,`*`))?.action,[le]),de=Q.useCallback(e=>N.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),[N]),fe=Q.useMemo(()=>{let e=new Set;for(let t of Ra)e.add(t);for(let t of se)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[se]),pe=Q.useCallback(e=>{let t=e===`*`?k:ue(e)??k,n=de(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},[de,ue,k]),me=Q.useCallback(t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),[e]),ge=Q.useCallback(t=>t===`global`?e(`settings.common.scope.global`):me(t),[me,e]),_e=Q.useMemo(()=>{let e=new Set;for(let t of Ra)e.add(t);for(let t of se)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[se]),be=Q.useCallback((e,t,n)=>{P(r=>{let i=Ha(r);return i.set(Ba(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},[]),xe=Q.useCallback((e,t)=>{P(n=>{let r=Ha(n);return r.delete(Ba(e,t)),Array.from(r.values())})},[]),Se=Q.useCallback((e,t)=>{let n=ce.get(Ba(e,t));if(n){be(e,t,n.action);return}xe(e,t)},[ce,xe,be]),Ce=Q.useCallback((e,t,n)=>{be(e,t,n)},[be]),we=Q.useCallback(e=>{A(e),P(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},[]),Te=Q.useCallback(t=>{let n=F.trim();if(!n){K.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=L.trim()||`*`;if(n===`*`&&r===`*`){we(t),I(``),R(`*`);return}r===`*`&&n!==`*`&&t===k?xe(n,`*`):be(n,r,t),I(``),R(`*`)},[k,F,L,xe,we,e,be]),Ee=Q.useCallback(t=>t===`*`?e(`settings.agents.page.permissions.defaultLabel`):t===`webfetch`?`WebFetch`:t===`websearch`?`WebSearch`:t===`codesearch`?`CodeSearch`:t===`doom_loop`?`Doom Loop`:t===`external_directory`?`External Directory`:t===`todowrite`?`TodoWrite`:t===`todoread`?`TodoRead`:t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),[e]);Q.useEffect(()=>{I(``),R(`*`);let e=e=>{let t=Va(e),n=Ga(t),r=Ka(t,n);return A(n),M(r),P(r),{global:n,rules:r}};if(u&&o){let t=o.name||``,n=o.scope||`user`,r=o.description||``,i=o.mode||`subagent`,a=o.model||``,s=o.variant||``,c=o.temperature??void 0,l=o.top_p??void 0,u=o.prompt||``;f(t),m(n),g(r),v(i),b(a),S(s),w(c),E(l),O(u);let d=e(qa(o.permission));ee.current={draftName:t,draftScope:n,description:r,mode:i,model:a,variant:s,temperature:c,topP:l,prompt:u,globalPermission:d.global,permissionRules:d.rules};return}if(l&&n===l.name){let t=l.description||``,n=l.mode||`subagent`,r=l.model?.providerID&&l.model?.modelID?`${l.model.providerID}/${l.model.modelID}`:``,i=l.variant||``,a=l.temperature,o=l.topP,s=l.prompt||``;g(t),v(n),b(r),S(i),w(a),E(o),O(s);let c=e(qa(l.permission));ee.current={draftName:``,draftScope:`user`,description:t,mode:n,model:r,variant:i,temperature:a,topP:o,prompt:s,globalPermission:c.global,permissionRules:c.rules}}},[o,u,l,n]);let De=Q.useMemo(()=>{let e=ee.current;return e?!!(u&&(d!==e.draftName||p!==e.draftScope)||h!==e.description||_!==e.mode||y!==e.model||x!==e.variant||C!==e.temperature||T!==e.topP||D!==e.prompt||k!==e.globalPermission||!Wa(N,e.permissionRules)):!1},[h,d,p,k,u,_,y,N,D,C,T,x]);return n?(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.identityRole`),children:[u&&(0,$.jsxs)(Fr,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(ln,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(an,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(tn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(cn,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(nn,{align:`end`,children:[(0,$.jsx)($t,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)($t,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Fr,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(br,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(Fr,{itemId:`agents.mode`,className:`oc-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.modelParameters`),children:[(0,$.jsx)(Fr,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(kn,{providerId:mt(y)?.providerId??``,modelId:mt(y)?.modelId??``,onChange:(e,t)=>{b(e&&t?`${e}/${t}`:``),S(``)},className:`oc-settings-inline-value`})}),(0,$.jsx)(Fr,{itemId:`agents.variant`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.variant`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.variantTooltip`)})]})]}),description:e(`settings.agents.page.field.variantHint`),children:ae?(0,$.jsxs)(an,{value:ie,onValueChange:e=>S(e===`__default`?``:e),children:[(0,$.jsx)(tn,{className:`w-fit min-w-[10rem] max-w-full`,children:(0,$.jsx)(cn,{placeholder:e(`settings.agents.page.field.variantPlaceholder`),children:t=>t===`__default`?e(`chat.modelControls.default`):t})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`__default`,children:e(`chat.modelControls.default`)}),ne.map(e=>(0,$.jsx)($t,{value:e,children:e},e))]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ln,{value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.variantPlaceholder`),disabled:!y&&!x,className:`h-7 w-40 max-w-full`}),x&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>S(``),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.common.actions.clear`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsxs)(Fr,{itemId:`agents.temperature`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.temperature`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.temperatureTooltip`)})]})]}),description:e(`settings.agents.page.field.temperatureRange`),children:[(0,$.jsx)(zr,{value:C,fallbackValue:.7,onValueChange:w,onClear:()=>w(void 0),min:0,max:2,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),C!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>w(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTemperatureAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(Fr,{itemId:`agents.top-p`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.topP`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.topPTooltip`)})]})]}),description:e(`settings.agents.page.field.topPRange`),children:[(0,$.jsx)(zr,{value:T,fallbackValue:.9,onValueChange:E,onClear:()=>E(void 0),min:0,max:1,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),T!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>E(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTopPAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),(0,$.jsx)(Ar,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(br,{embedded:!0,value:D,onChange:e=>O(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>B(e=>!e),children:e(z?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:z?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Fr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(an,{value:k,onValueChange:e=>we(e),children:[(0,$.jsx)(tn,{className:`w-[100px]`,children:(0,$.jsx)(cn,{children:me(k)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)($t,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)($t,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:fe.filter(e=>e!==`*`).map(t=>{let n=Ee(t),{defaultAction:r,patternRulesCount:i}=pe(t),a=ue(t),o=a??`global`,s=de(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==k);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>Se(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(an,{value:o,onValueChange:e=>{if(e===`global`){xe(t,`*`);return}be(t,`*`,e)},children:[(0,$.jsx)(tn,{className:`w-[90px]`,children:(0,$.jsx)(cn,{children:ge(o)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)($t,{value:e,className:`capitalize`,children:me(e)},e))]})]})]}),s.map(t=>{let n=Ba(t.permission,t.pattern),r=ce.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i?xe(t.permission,t.pattern):Se(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(an,{value:t.action,onValueChange:e=>Ce(t.permission,t.pattern,e),children:[(0,$.jsx)(tn,{className:`w-[90px]`,children:(0,$.jsx)(cn,{children:me(t.action)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)($t,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)($t,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2`,children:[(0,$.jsxs)(an,{value:F,onValueChange:I,children:[(0,$.jsx)(tn,{className:`w-full sm:w-[160px]`,children:F?(0,$.jsx)(`span`,{className:`truncate`,children:Ee(F)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(nn,{children:_e.map(e=>(0,$.jsx)($t,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:Ee(e)})})},e))})]}),(0,$.jsx)(ln,{value:L,onChange:e=>R(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 flex-1 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Te(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Te(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Te(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsx)($.Fragment,{children:fe.map(t=>{let{defaultAction:n,patternRulesCount:r,patternSummary:i,hasDefaultHint:a}=pe(t),o=Ee(t),s=a?`${n} (env blocked)`:n;return(0,$.jsx)(Fr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block`,children:t})]}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.globalSummary`,{summary:s})}):(0,$.jsx)(`span`,{className:q(`typography-micro capitalize px-1.5 py-0.5 rounded`,s===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:s===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:s}),r>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.rulesSummary`,{summary:i})})]})},t)})})})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let t=u?d.trim().replace(/\s+/g,`-`):n?.trim();if(!t){K.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&c.some(e=>e.name===t)){K.error(e(`settings.agents.sidebar.toast.agentExists`));return}H(!0);try{let n={description:h,mode:_,model:y,variant:x,temperature:C,topP:T,prompt:D,globalPermission:k,permissionRules:N},r=ee.current,c=r?{description:r.description,mode:r.mode,model:r.model,variant:r.variant,temperature:r.temperature,topP:r.topP,prompt:r.prompt,globalPermission:r.globalPermission,permissionRules:r.permissionRules}:null,l=La({isNewAgent:u,agentName:t,draftScope:u?p:void 0,draftHasExplicitPermission:u&&o?.permission!==void 0,current:n,initial:c,permissionConfig:Ja(k,N)}),d;u?(d=await i(l),d.ok&&s(null)):d=await a(t,l),d.ok?d.requiresManualRestart?K.warning(e(`settings.agents.page.toast.savedManualRestart`)):K.success(e(u?`settings.agents.page.toast.created`:`settings.agents.page.toast.updated`)):K.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);K.error(n)}finally{H(!1)}},disabled:V||!De,size:`xs`,className:`!font-normal`,children:e(V?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})},Za=e=>{let t=(0,Ei.c)(23),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c}=e,l=i!==void 0&&i,u=s&&s.length>0,d=l?`bg-interactive-selection`:`hover:bg-interactive-hover`,f;t[0]!==c||t[1]!==d?(f=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,d,c),t[0]=c,t[1]=d,t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==o||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,p]}),t[5]=o,t[6]=p,t[7]=m):m=t[7];let h;t[8]===r?h=t[9]:(h=r&&(0,$.jsx)(`div`,{className:`max-w-full truncate typography-micro leading-tight text-muted-foreground/60`,children:r}),t[8]=r,t[9]=h);let g;t[10]!==a||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`button`,{onClick:a,"data-mobile-press-feedback":`soft`,className:`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[m,h]}),t[10]=a,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==s||t[15]!==u?(_=u&&(0,$.jsxs)(Tn,{children:[(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(Y,{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:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(mn,{align:`end`,className:`w-fit min-w-20`,children:s.map(Qa)})]}),t[14]=s,t[15]=u,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==f||t[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),t[20]=f,t[21]=v,t[22]=y):y=t[22],y};function Qa(e){let t=e.icon;return(0,$.jsxs)(_n,{onClick:t=>{t.stopPropagation(),e.onClick()},className:q(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(J,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var $a=e=>{let t=(0,Ei.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=m(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=q(`oc-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},eo=`__managed_workspace__`,to=`__current_workspace__`,no=`默认助理`,ro=()=>{let e=G.getState(),t=e.settingsDefaultModel;if(t){let e=mt(t);if(e?.providerId&&e?.modelId)return{providerID:e.providerId,modelID:e.modelId}}if(e.currentProviderId&&e.currentModelId)return{providerID:e.currentProviderId,modelID:e.currentModelId};let n=e.providers;for(let e of n){let t=e.models;if(Array.isArray(t)&&t.length>0){let n=t[0];if(n?.id)return{providerID:e.id,modelID:n.id}}}return null},io=(e=``)=>{let t=ro();return{enabled:!0,name:e,defaultPrompt:``,workspacePath:null,providerID:t?.providerID??``,modelID:t?.modelID??``,agent:null,mode:`continuous`}},ao=e=>({enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,agent:e.agent,mode:e.mode}),oo=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,so=e=>{let t=Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[];return Array.from(new Set(t.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)))).sort((e,t)=>e.localeCompare(t))},co=e=>!!e&&typeof e==`object`&&!Array.isArray(e),lo=e=>{if(!co(e)||!co(e.schedule)||!co(e.execution)||!co(e.state))return!1;let t=e.schedule.times===void 0||Array.isArray(e.schedule.times)&&e.schedule.times.every(e=>typeof e==`string`),n=e.schedule.weekdays===void 0||Array.isArray(e.schedule.weekdays)&&e.schedule.weekdays.every(e=>typeof e==`number`),r=e.state.lastStatus===void 0||e.state.lastStatus===`idle`||e.state.lastStatus===`running`||e.state.lastStatus===`success`||e.state.lastStatus===`error`;return typeof e.id==`string`&&typeof e.name==`string`&&typeof e.enabled==`boolean`&&(e.schedule.kind===`daily`||e.schedule.kind===`weekly`||e.schedule.kind===`once`||e.schedule.kind===`cron`)&&t&&n&&r&&typeof e.execution.prompt==`string`&&typeof e.execution.providerID==`string`&&typeof e.execution.modelID==`string`},uo=(e,t)=>{let n=so(e).join(`, `)||`—`,r=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:n});if(e.schedule.kind===`weekly`){let i=(e.schedule.weekdays??[]).map(r).join(`, `);return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:i,time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:i,time:n})}if(e.schedule.kind===`once`){let n=e.schedule.date?.trim()||t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),r=e.schedule.time?.trim()||`—`;return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:n,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:n,time:r})}return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron??``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron??``})},fo={paused:{icon:`pause`,className:`text-muted-foreground`},idle:{icon:`pulse`,className:`text-muted-foreground`},running:{icon:`loader-4`,className:`text-[var(--status-warning)]`},success:{icon:`checkbox-circle`,className:`text-[var(--status-success)]`},error:{icon:`error-warning`,className:`text-[var(--status-error)]`}},po=e=>`${e.projectId}:${e.task.id}`,mo=e=>{let t=(0,Ei.c)(31),{assistantID:n}=e,{t:r}=ke(),i=Ft(n),a=i.isError,o=Lt(n,a),s=Nt(a),c=new Set;for(let e of o.data?.messages??[])for(let t of e.cards)t.cardType===`schedule`&&c.add(`${t.projectID}:${t.taskID}`);let l=(i.data?.tasks??[]).flatMap(vo),u;t[0]===i.data?.tasks?u=t[1]:(u=i.data?.tasks.some(yo),t[0]=i.data?.tasks,t[1]=u);let d=!!u,f=(s.data?.tasks??[]).filter(e=>c.has(po(e))),p=[...i.data?l:a?f:[]].sort(bo),m=(s.data?.failedProjectIds??[]).some(e=>Array.from(c).some(t=>t.startsWith(`${e}:`))),h=i.isPending||a&&(o.isPending||s.isPending),g=i.isError||o.isError||s.isError||m||d,_=Oe(xo),v;t[2]!==o||t[3]!==a||t[4]!==s||t[5]!==i?(v=()=>{i.refetch(),a&&(o.refetch(),s.refetch())},t[2]=o,t[3]=a,t[4]=s,t[5]=i,t[6]=v):v=t[6];let y=Oe(v),b=Z,x;t[7]===r?x=t[8]:(x=r(`assistants.settings.scheduledTasks.title`),t[7]=r,t[8]=x);let S;t[9]===r?S=t[10]:(S=r(`assistants.settings.scheduledTasks.title`),t[9]=r,t[10]=S);let C=h&&p.length===0?(0,$.jsx)(Fr,{label:r(`common.loading`),children:(0,$.jsx)(J,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`})}):null,w;t[11]!==_||t[12]!==r?(w=e=>{let t=e.task.enabled?e.task.state?.lastStatus??`idle`:`paused`,n=fo[t],i=r(t===`paused`?`sessions.scheduledTasks.dialog.taskToggle.paused`:t===`running`?`sessions.scheduledTasks.dialog.status.running`:t===`success`?`sessions.scheduledTasks.dialog.status.success`:t===`error`?`sessions.scheduledTasks.dialog.status.error`:`sessions.scheduledTasks.dialog.status.idle`);return(0,$.jsxs)(Fr,{className:`group relative cursor-pointer transition-colors hover:bg-interactive-hover`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(J,{name:`calendar`,className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium text-foreground`,children:e.task.name}),(0,$.jsx)(`span`,{className:`mt-0.5 block typography-micro truncate text-muted-foreground`,children:uo(e.task,r)})]})]}),controlClassName:`min-w-fit`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-micro ${n.className}`,children:[(0,$.jsx)(J,{name:n.icon,className:`size-3.5 ${t===`running`?`animate-spin`:``}`}),i]}),(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4`})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute inset-0 z-10 h-auto w-auto rounded-none bg-transparent p-0 hover:bg-transparent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onClick:_,"aria-label":r(`assistants.settings.scheduledTasks.open`,{name:e.task.name}),children:(0,$.jsx)(`span`,{className:`sr-only`,children:r(`assistants.settings.scheduledTasks.open`,{name:e.task.name})})})]},po(e))},t[11]=_,t[12]=r,t[13]=w):w=t[13];let T=p.map(w),E;t[14]!==g||t[15]!==y||t[16]!==r?(E=g?(0,$.jsx)(Fr,{label:r(`assistants.settings.scheduledTasks.loadError`),children:(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:y,children:r(`assistants.actions.retry`)})}):null,t[14]=g,t[15]=y,t[16]=r,t[17]=E):E=t[17];let D;t[18]!==g||t[19]!==h||t[20]!==r||t[21]!==p?(D=!h&&!g&&p.length===0?(0,$.jsx)(Fr,{label:r(`assistants.settings.scheduledTasks.empty`),children:(0,$.jsx)(J,{name:`calendar`,className:`size-4 text-muted-foreground`})}):null,t[18]=g,t[19]=h,t[20]=r,t[21]=p,t[22]=D):D=t[22];let O;return t[23]!==b||t[24]!==x||t[25]!==S||t[26]!==C||t[27]!==T||t[28]!==E||t[29]!==D?(O=(0,$.jsxs)(b,{label:x,ariaLabel:S,children:[C,T,E,D]}),t[23]=b,t[24]=x,t[25]=S,t[26]=C,t[27]=T,t[28]=E,t[29]=D,t[30]=O):O=t[30],O},ho=e=>{let t=(0,Ei.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(J,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},go=({onItemSelect:e})=>{let{t}=ke(),n=Pt(),r=Mt(),i=n.data,a=Ht(e=>e.settingsSelectedAssistantID),o=Ht(e=>e.selectSettingsAssistant),s=Ht(e=>e.requestCreate),[c,l]=Q.useState(!1);Q.useEffect(()=>{!e&&a===null&&i?.assistants[0]&&o(i.assistants[0].id)},[e,o,a,i?.assistants]),Q.useEffect(()=>{n.isSuccess&&a&&a!==`new`&&!i?.assistants.some(e=>e.id===a)&&o(e?null:i?.assistants[0]?.id??null)},[e,o,a,i?.assistants,n.isSuccess]);let u=Oe(()=>{s(),e?.()}),d=Oe(async e=>{if(i)try{if(await Vt(e,i.revision),e&&i.assistants.length===0){let e=ro();if(e){let t=await It({enabled:!0,name:no,defaultPrompt:``,workspacePath:null,providerID:e.providerID,modelID:e.modelID,agent:null,mode:`continuous`});o(t.id)}}}catch{Ee.error(t(`assistants.settings.toast.toggleFailed`))}});return r.isSuccess&&!r.data.supported?null:(0,$.jsx)($a,{variant:`background`,header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{description:(0,$.jsxs)($.Fragment,{children:[t(`assistants.settings.description`),(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:e=>{e.preventDefault(),l(!0)},children:t(`assistants.settings.descriptionLearnMore`)})]}),children:(0,$.jsx)(Vr,{itemId:`assistants.instance-enabled`,checked:i?.enabled??!1,onChange:d,label:t(`assistants.settings.instanceEnabled`),ariaLabel:t(`assistants.settings.instanceEnabled`)})}),(0,$.jsx)(zi,{open:c,onOpenChange:l})]}),children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`assistants.settings.listTitle`)}),(0,$.jsx)(Y,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:u,"aria-label":t(`assistants.settings.create`),children:(0,$.jsx)(J,{name:`add`,className:`size-4`})})]}),children:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):i?.assistants.length?i.assistants.map(t=>{let n=Me(t.name);return(0,$.jsx)(Za,{title:n.displayName,selected:a===t.id,onSelect:()=>{o(t.id),e?.()},icon:(0,$.jsx)(Xt,{name:t.id,emoji:n.avatarEmoji,size:24,label:n.displayName||t.name,shape:`circle`})},t.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row text-muted-foreground`,children:t(`assistants.settings.empty`)})})})},_o=({onItemDeleted:e})=>{let{t}=ke(),n=Pt(),r=Mt(),i=n.data,a=ft(e=>e.projects),o=Ht(e=>e.settingsSelectedAssistantID),s=Ht(e=>e.selectSettingsAssistant),c=Ht(e=>e.defaultShareAssistant),l=Ht(e=>e.setDefaultShareAssistant),u=Ht(e=>e.createRequestRevision),d=Ht(e=>e.requestCreate),[f,p]=Q.useState(io),[m,h]=Q.useState(!1),g=Q.useRef(0),_=i?.assistants.find(e=>e.id===o)??null,v=_?Me(_.name):null,y=Me(f.name),b=f.workspacePath??_?.managedWorkspacePath??null,x=Dt(b,{enabled:!0}).data??[];Q.useEffect(()=>{_&&p(ao(_))},[_]),Q.useEffect(()=>{n.isSuccess&&o&&o!==`new`&&!_&&s(null)},[s,_,o,n.isSuccess]),Q.useEffect(()=>{o!==`new`||u<=g.current||(g.current=u,p(io(i?.assistants.length?``:no)),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[u,o,i?.assistants.length]),Q.useEffect(()=>{n.isSuccess&&r.data?.serverInstanceID&&c?.serverInstanceID===r.data.serverInstanceID&&!i?.assistants.some(e=>e.id===c.assistantID)&&l(null)},[r.data,c,l,i?.assistants,n.isSuccess]),Q.useEffect(()=>{n.isSuccess&&Ne()},[i?.revision,n.isSuccess]);let S=(e,t)=>{p(n=>({...n,[e]:t}))},C=Oe(()=>d()),w=Oe(async()=>{if(!f.name.trim()||!f.providerID||!f.modelID){Ee.error(t(`assistants.settings.validation.required`));return}h(!0);try{let e=_?await jt(_,f):await It(f);s(e.id),Ee.success(t(`assistants.settings.toast.saved`))}catch{Ee.error(t(`assistants.settings.toast.saveFailed`))}finally{h(!1)}}),T=Oe(async()=>{if(!(!_||!window.confirm(t(`assistants.settings.deleteConfirm`,{name:_.name})))){h(!0);try{if(await Rt(_),c?.assistantID===_.id){let e=await At();e.serverInstanceID&&c.serverInstanceID===e.serverInstanceID&&l(null)}s(null),e?.(),Ee.success(t(`assistants.settings.toast.deleted`))}catch{Ee.error(t(`assistants.settings.toast.deleteFailed`))}finally{h(!1)}}}),E=Oe(async(e,n)=>{if(!n){l(null),Pe();return}try{let t=await At();if(!t.supported||!t.serverInstanceID)return;l({serverInstanceID:t.serverInstanceID,assistantID:e}),await Pe()}catch{Ee.error(t(`assistants.settings.toast.toggleFailed`))}}),D=f.workspacePath===null?null:a.find(e=>e.path===f.workspacePath)??null,O=f.workspacePath!==null&&!D?f.workspacePath:null,k=f.workspacePath===null?eo:D?D.id:to,A=f.workspacePath===null?(0,$.jsx)(ho,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):D?(0,$.jsx)(ho,{name:oo(D),path:D.path}):(0,$.jsx)(ho,{name:t(`assistants.settings.workspaceCurrentPath`),path:O??``,icon:`history`});return r.isSuccess&&!r.data.supported?null:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):n.isError&&!i?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(J,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:t(`assistants.state.unavailable`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void n.refetch(),children:t(`assistants.actions.retry`)})]}):(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n.isError&&i?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:t(`assistants.state.staleSnapshot`)}):null,o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,$.jsx)(Xt,{name:_?.id??`new`,emoji:y.avatarEmoji,size:38,label:y.displayName||f.name||t(`assistants.settings.create`),shape:`circle`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:_?v?.displayName:t(`assistants.settings.create`)}),f.providerID&&f.modelID?(0,$.jsx)(`p`,{className:`mt-0.5 typography-micro leading-none text-muted-foreground/70`,children:`${f.providerID}/${f.modelID}`}):null]}),_?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:T,disabled:m,className:`text-[var(--status-error)]`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`size-4`}),t(`assistants.settings.delete`)]}):null]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Fr,{itemId:`assistants.name`,label:t(`assistants.settings.name`),children:(0,$.jsx)(ln,{id:`assistant-name`,value:f.name,onChange:e=>S(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Fr,{label:t(`assistants.settings.enabled`),children:(0,$.jsx)(Qt,{checked:f.enabled,onChange:e=>S(`enabled`,e),ariaLabel:t(`assistants.settings.enabled`)})}),_?(0,$.jsx)(Fr,{itemId:`assistants.default-share`,label:t(`assistants.settings.defaultShare`),children:(0,$.jsx)(Qt,{checked:c?.assistantID===_.id&&c.serverInstanceID===r.data?.serverInstanceID,onChange:e=>void E(_.id,e),ariaLabel:t(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(Ar,{itemId:`assistants.prompt`,label:t(`assistants.settings.defaultPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(br,{embedded:!0,id:`assistant-prompt`,value:f.defaultPrompt,onChange:e=>S(`defaultPrompt`,e.target.value),placeholder:t(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsx)(Z,{label:t(`assistants.settings.runtime`),children:(0,$.jsx)(Fr,{itemId:`assistants.model`,label:t(`assistants.settings.model`),children:(0,$.jsx)(kn,{providerId:f.providerID,modelId:f.modelID,providers:x,onChange:(e,t)=>p(n=>({...n,providerID:e,modelID:t})),className:`oc-settings-inline-value`})})}),(0,$.jsx)(Ar,{itemId:`assistants.workspace`,label:t(`assistants.settings.workspace`),description:t(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(an,{value:k,onValueChange:e=>{if(e===eo){S(`workspacePath`,null);return}let t=a.find(t=>t.id===e);t&&S(`workspacePath`,t.path)},children:[(0,$.jsx)(tn,{title:f.workspacePath??t(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(cn,{children:A})}),(0,$.jsxs)(nn,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)($t,{value:eo,children:(0,$.jsx)(ho,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),a.map(e=>(0,$.jsx)($t,{value:e.id,children:(0,$.jsx)(ho,{name:oo(e),path:e.path})},e.id)),O?(0,$.jsx)($t,{value:to,disabled:!0,children:(0,$.jsx)(ho,{name:t(`assistants.settings.workspaceCurrentPath`),path:O,icon:`history`})}):null]})]})}),_?(0,$.jsx)(mo,{assistantID:_.id}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(Y,{onClick:w,disabled:m,children:[m?(0,$.jsx)(J,{name:`loader-4`,className:`size-4 animate-spin`}):null,t(`assistants.settings.save`)]})})]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)(Xt,{name:`assistants-empty`,size:44,shape:`circle`}),(0,$.jsx)(`p`,{className:`typography-ui`,children:t(`assistants.settings.empty`)}),(0,$.jsxs)(Y,{"data-settings-item":`assistants.create`,size:`sm`,onClick:C,children:[(0,$.jsx)(J,{name:`add`,className:`size-4`}),t(`assistants.settings.create`)]})]})]})})};function vo(e){return lo(e.task)?[{projectId:e.projectID,task:e.task}]:[]}function yo(e){return!lo(e.task)}function bo(e,t){return e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1}function xo(){u.getState().setActiveMainTab(`schedule`),u.getState().setScheduledTasksDialogOpen(!0)}var So=`~/.config/opencode/AGENTS.md`,Co=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},wo=e=>e.length>0&&!e.endsWith(`
|
|
2
|
-
`)?`${e}\n`:e,To={prompt:``,responseStyleEnabled:!1,responseStylePreset:`concise`,responseStyleCustomInstructions:``},Eo=(e,t)=>e===`custom`?t:qe(e),Do=e=>e===`custom`?`custom`:ht(e)?e:`concise`,Oo={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`},ko=async(e,t)=>{let n=await L(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(await Co(n,t));return n.json().catch(()=>null)},Ao=()=>{let{t:e}=ke(),t=Q.useSyncExternalStore(n,i,i),[r,a]=Q.useState(``),[o,s]=Q.useState(To.responseStyleEnabled),[c,l]=Q.useState(To.responseStylePreset),[u,d]=Q.useState(To.responseStyleCustomInstructions),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(``),b=Q.useRef(null),x=Q.useRef(null),S=Q.useRef(0),C=Q.useRef(Promise.resolve());Q.useEffect(()=>{let e=!0;return h(!1),b.current=null,x.current=null,S.current+=1,F(t).then(n=>{if(!e||t!==i())return;let r={enabled:n.responseStyleEnabled===!0,preset:Do(n.responseStylePreset),custom:typeof n.responseStyleCustomInstructions==`string`?n.responseStyleCustomInstructions:``};s(r.enabled),l(r.preset),d(r.custom),Ie({enabled:r.enabled,preset:r.preset,customInstructions:r.custom},t),b.current=r,x.current=r,h(!0)}).catch(t=>{e&&t?.name!==`AbortError`&&console.warn(`Failed to load behavior settings:`,t)}),()=>{e=!1,S.current+=1}},[t]),Q.useEffect(()=>{let e=new AbortController,n=!0;return p(!1),_(!1),(async()=>{try{let r=await L(`/api/behavior/agents-md`,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!r.ok)throw Error(`Behavior prompt request failed (${r.status})`);let o=await r.json().catch(()=>null);if(typeof o?.content!=`string`)throw Error(`Invalid behavior prompt response`);if(!n||t!==i())return;a(o.content),y(o.content),p(!0)}catch(e){n&&e?.name!==`AbortError`&&console.warn(`Failed to load behavior prompt:`,e)}})(),()=>{n=!1,e.abort()}},[t]),Q.useEffect(()=>{if(!m)return;let n={enabled:o,preset:c,custom:u},r=x.current;if(r&&r.enabled===n.enabled&&r.preset===n.preset&&r.custom===n.custom)return;x.current=n;let a=S.current+1;S.current=a;let f=setTimeout(()=>{let r=async()=>{if(t===i())try{let r=await ko({responseStyleEnabled:n.enabled,responseStylePreset:n.preset,responseStyleCustomInstructions:n.custom},e(`settings.behavior.page.toast.saveFailed`));if(t!==i())return;let o=M(r),c={enabled:o.responseStyleEnabled??n.enabled,preset:o.responseStylePreset??n.preset,custom:o.responseStyleCustomInstructions??n.custom};if(Ie({enabled:c.enabled,preset:c.preset,customInstructions:c.custom},t),E({responseStyleEnabled:c.enabled,responseStylePreset:c.preset,responseStyleCustomInstructions:c.custom},t),b.current=c,a!==S.current)return;x.current=c,s(c.enabled),l(c.preset),d(c.custom)}catch(n){if(t===i()&&a===S.current){let t=b.current;x.current=t,t&&(s(t.enabled),l(t.preset),d(t.custom));let r=n instanceof Error?n.message:e(`settings.behavior.page.toast.saveFailed`);K.error(r)}}};C.current=C.current.then(r,r)},400);return()=>clearTimeout(f)},[o,c,u,m,e,t]);let w=Eo(c,u),T=r!==v;return(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.behavior.page.title`)})}),(0,$.jsx)(Z,{itemId:`behavior.system-prompt`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.systemPrompt`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:e(`settings.behavior.page.warning.title`)}),(0,$.jsx)(`p`,{children:e(`settings.behavior.page.warning.description`,{path:So})})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(br,{embedded:!0,value:r,onChange:e=>a(e.target.value),placeholder:e(`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`}),(0,$.jsx)(Y,{onClick:async()=>{let n=t;if(n===i()){_(!0);try{let t=wo(r),o=await L(`/api/behavior/agents-md`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:t})});if(!o.ok)throw Error(await Co(o,e(`settings.behavior.page.toast.saveFailed`)));if(n!==i()||(await ko({globalBehaviorPrompt:t},e(`settings.behavior.page.toast.saveFailed`)),n!==i()))return;a(t),y(t),K.success(e(`settings.behavior.page.toast.saved`))}catch(t){if(n!==i())return;console.error(`Failed to save behavior:`,t);let r=t instanceof Error?t.message:e(`settings.behavior.page.toast.saveFailed`);K.error(r)}finally{n===i()&&_(!1)}}},disabled:g||!T||!f,size:`xs`,className:`!font-normal`,children:e(g?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})]})}),(0,$.jsxs)(Z,{itemId:`behavior.response-style`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.responseStyle`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.behavior.page.responseStyle.tooltip`)})]})]}),children:[(0,$.jsxs)(Fr,{label:e(`settings.behavior.page.responseStyle.enable`),children:[(0,$.jsx)(Qt,{checked:o,onChange:s,disabled:!m,ariaLabel:e(`settings.behavior.page.responseStyle.enableAria`)}),(0,$.jsxs)(an,{value:c,onValueChange:e=>l(e),disabled:!m||!o,children:[(0,$.jsx)(tn,{className:`w-full sm:w-56`,children:(0,$.jsx)(cn,{children:t=>t===`custom`?e(`settings.behavior.page.responseStyle.option.custom`):ht(t)?e(Oo[t]):null})}),(0,$.jsxs)(nn,{children:[ze.map(t=>(0,$.jsx)($t,{value:t,children:e(Oo[t])},t)),(0,$.jsx)($t,{value:`custom`,children:e(`settings.behavior.page.responseStyle.option.custom`)})]})]})]}),(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(br,{embedded:!0,value:w,onChange:e=>d(e.target.value),placeholder:e(`settings.behavior.page.responseStyle.customPlaceholder`),rows:5,disabled:!m||!o||c!==`custom`,outerClassName:`min-h-[120px]`,className:`w-full font-mono typography-meta bg-transparent`})})]})]})})},jo=e=>{let t=(0,Ei.c)(158),{onItemSelect:n}=e,{t:r}=ke(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),{selectedCommandName:g,setSelectedCommand:_,setCommandDraft:v,createCommand:y,deleteCommand:b}=Gi(he(No)),x=_t(),S;t[0]===x.data?S=t[1]:(S=x.data??[],t[0]=x.data,t[1]=S);let C=S,w=Fe(),T;t[2]===w.data?T=t[3]:(T=w.data??[],t[2]=w.data,t[3]=T);let E=T,{refetch:D}=w,O,k;t[4]===D?(O=t[5],k=t[6]):(O=()=>{D()},k=[D],t[4]=D,t[5]=O,t[6]=k),Q.useEffect(O,k);let A;t[7]===E?A=t[8]:(A=new Set(E.map(Po)),t[7]=E,t[8]=A);let j=A,M;if(t[9]!==C||t[10]!==j){let e;t[12]===j?e=t[13]:(e=e=>!j.has(e.name),t[12]=j,t[13]=e),M=C.filter(e),t[9]=C,t[10]=j,t[11]=M}else M=t[11];let N=M,P,F;t[14]!==g||t[15]!==_||t[16]!==j?(P=()=>{g&&j.has(g)&&_(null)},F=[g,_,j],t[14]=g,t[15]=_,t[16]=j,t[17]=P,t[18]=F):(P=t[17],F=t[18]),Q.useEffect(P,F);let I;t[19]!==C||t[20]!==n||t[21]!==v||t[22]!==_?(I=()=>{let e=`new-command`,t=1;for(;C.some(t=>t.name===e);)e=`new-command-${t}`,t++;v({name:e,scope:`user`}),_(e),n?.()},t[19]=C,t[20]=n,t[21]=v,t[22]=_,t[23]=I):I=t[23];let L=I,R;t[24]===r?R=t[25]:(R=async e=>{if(Ui(e)){K.error(r(`settings.commands.sidebar.toast.builtInCannotDelete`));return}l(e),d(`delete`)},t[24]=r,t[25]=R);let z=R,B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=async e=>{Ui(e)&&(l(e),d(`reset`))},t[26]=B):B=t[26];let V=B,H;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{l(null),d(null)},t[27]=H):H=t[27];let ee=H,U;t[28]!==c||t[29]!==u||t[30]!==b||t[31]!==r?(U=async()=>{!c||!u||(p(!0),await b(c.name)?(u===`delete`?K.success(r(`settings.commands.sidebar.toast.commandDeleted`,{name:c.name})):K.success(r(`settings.commands.sidebar.toast.commandReset`,{name:c.name})),ee()):u===`delete`?K.error(r(`settings.commands.sidebar.toast.deleteFailed`)):K.error(r(`settings.commands.sidebar.toast.resetFailed`)),p(!1))},t[28]=c,t[29]=u,t[30]=b,t[31]=r,t[32]=U):U=t[32];let te=U,W;t[33]!==C||t[34]!==v||t[35]!==_?(W=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;C.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;v({name:r,scope:e.scope||`user`,description:e.description,template:e.template,agent:e.agent,model:e.model}),_(r)},t[33]=C,t[34]=v,t[35]=_,t[36]=W):W=t[36];let ne=W,re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>{s(e.name),a(e)},t[37]=re):re=t[37];let ie=re,ae;t[38]!==C||t[39]!==y||t[40]!==b||t[41]!==i||t[42]!==o||t[43]!==_||t[44]!==r?(ae=async()=>{if(!i)return;let e=o.trim().replace(/\s+/g,`-`);if(!e){K.error(r(`settings.commands.sidebar.toast.commandNameRequired`));return}if(e===i.name){a(null);return}if(C.some(t=>t.name===e)){K.error(r(`settings.commands.sidebar.toast.commandExists`));return}await y({name:e,description:i.description,template:i.template,agent:i.agent,model:i.model})?await b(i.name)?(K.success(`Command renamed to "${e}"`),_(e)):K.error(r(`settings.commands.sidebar.toast.removeOldAfterRenameFailed`)):K.error(r(`settings.commands.sidebar.toast.renameFailed`)),a(null)},t[38]=C,t[39]=y,t[40]=b,t[41]=i,t[42]=o,t[43]=_,t[44]=r,t[45]=ae):ae=t[45];let oe=ae,se,ce,le;if(t[46]!==N||t[47]!==L||t[48]!==z||t[49]!==ne||t[50]!==n||t[51]!==m||t[52]!==g||t[53]!==_||t[54]!==r){let e=N.filter(Ui),i=N.filter(Fo),a;t[58]===r?a=t[59]:(a=r(`settings.commands.sidebar.section.custom`),t[58]=r,t[59]=a);let o;t[60]===a?o=t[61]:(o=(0,$.jsx)(`span`,{children:a}),t[60]=a,t[61]=o);let s;t[62]===r?s=t[63]:(s=r(`settings.commands.page.title.new`),t[62]=r,t[63]=s);let c;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[64]=c):c=t[64];let l;t[65]!==L||t[66]!==s?(l=(0,$.jsx)(Y,{"data-settings-item":`commands.create`,size:`icon`,variant:`ghost`,onClick:L,"aria-label":s,children:c}),t[65]=L,t[66]=s,t[67]=l):l=t[67];let u;t[68]!==o||t[69]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[o,l]}),t[68]=o,t[69]=l,t[70]=u):u=t[70];let d=u;se=`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(ha,{})})}),t[71]=ce):ce=t[71],le=(0,$.jsx)($.Fragment,{children:N.length===0?(0,$.jsx)(Z,{label:d,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`terminal-box`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.commands.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.commands.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[e.length>0&&(0,$.jsx)(Z,{label:r(`settings.commands.sidebar.section.builtIn`),children:[...e].sort(Io).map(e=>(0,$.jsx)(Mo,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onReset:()=>V(e),onDuplicate:()=>ne(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}),i.length>0?(0,$.jsx)(Z,{label:d,children:[...i].sort(Lo).map(e=>(0,$.jsx)(Mo,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onRename:()=>ie(e),onDelete:()=>z(e),onDuplicate:()=>ne(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}):(0,$.jsx)(Z,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[46]=N,t[47]=L,t[48]=z,t[49]=ne,t[50]=n,t[51]=m,t[52]=g,t[53]=_,t[54]=r,t[55]=se,t[56]=ce,t[57]=le}else se=t[55],ce=t[56],le=t[57];let ue=c!==null&&u!==null,de;t[72]===f?de=t[73]:(de=e=>{!e&&!f&&ee()},t[72]=f,t[73]=de);let fe;t[74]!==u||t[75]!==r?(fe=r(u===`delete`?`settings.commands.sidebar.dialog.deleteTitle`:`settings.commands.sidebar.dialog.resetTitle`),t[74]=u,t[75]=r,t[76]=fe):fe=t[76];let pe;t[77]===fe?pe=t[78]:(pe=(0,$.jsx)(Kt,{children:fe}),t[77]=fe,t[78]=pe);let me;t[79]!==c?.name||t[80]!==u||t[81]!==r?(me=r(u===`delete`?`settings.commands.sidebar.dialog.deleteDescription`:`settings.commands.sidebar.dialog.resetDescription`,{name:c?.name??``}),t[79]=c?.name,t[80]=u,t[81]=r,t[82]=me):me=t[82];let ge;t[83]===me?ge=t[84]:(ge=(0,$.jsx)(qt,{children:me}),t[83]=me,t[84]=ge);let _e;t[85]!==pe||t[86]!==ge?(_e=(0,$.jsxs)(Ut,{children:[pe,ge]}),t[85]=pe,t[86]=ge,t[87]=_e):_e=t[87];let ve;t[88]===r?ve=t[89]:(ve=r(`settings.common.actions.cancel`),t[88]=r,t[89]=ve);let ye;t[90]!==f||t[91]!==ve?(ye=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:ee,disabled:f,children:ve}),t[90]=f,t[91]=ve,t[92]=ye):ye=t[92];let be;t[93]!==u||t[94]!==r?(be=r(u===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`),t[93]=u,t[94]=r,t[95]=be):be=t[95];let xe;t[96]!==te||t[97]!==f||t[98]!==be?(xe=(0,$.jsx)(Y,{size:`sm`,onClick:te,disabled:f,children:be}),t[96]=te,t[97]=f,t[98]=be,t[99]=xe):xe=t[99];let Se;t[100]!==ye||t[101]!==xe?(Se=(0,$.jsxs)(Wt,{children:[ye,xe]}),t[100]=ye,t[101]=xe,t[102]=Se):Se=t[102];let Ce;t[103]!==_e||t[104]!==Se?(Ce=(0,$.jsxs)(Gt,{className:`max-w-md`,children:[_e,Se]}),t[103]=_e,t[104]=Se,t[105]=Ce):Ce=t[105];let we;t[106]!==ue||t[107]!==de||t[108]!==Ce?(we=(0,$.jsx)(Jt,{open:ue,onOpenChange:de,children:Ce}),t[106]=ue,t[107]=de,t[108]=Ce,t[109]=we):we=t[109];let Te=i!==null,Ee;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>!e&&a(null),t[110]=Ee):Ee=t[110];let De;t[111]===r?De=t[112]:(De=r(`settings.commands.sidebar.renameDialog.title`),t[111]=r,t[112]=De);let Oe;t[113]===De?Oe=t[114]:(Oe=(0,$.jsx)(Kt,{children:De}),t[113]=De,t[114]=Oe);let Ae=i?.name??``,je;t[115]!==r||t[116]!==Ae?(je=r(`settings.commands.sidebar.renameDialog.description`,{name:Ae}),t[115]=r,t[116]=Ae,t[117]=je):je=t[117];let Me;t[118]===je?Me=t[119]:(Me=(0,$.jsx)(qt,{children:je}),t[118]=je,t[119]=Me);let Ne;t[120]!==Oe||t[121]!==Me?(Ne=(0,$.jsxs)(Ut,{children:[Oe,Me]}),t[120]=Oe,t[121]=Me,t[122]=Ne):Ne=t[122];let Pe;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=e=>s(e.target.value),t[123]=Pe):Pe=t[123];let Ie;t[124]===r?Ie=t[125]:(Ie=r(`settings.commands.sidebar.renameDialog.placeholder`),t[124]=r,t[125]=Ie);let Le;t[126]===oe?Le=t[127]:(Le=e=>{e.key===`Enter`&&oe()},t[126]=oe,t[127]=Le);let Re;t[128]!==o||t[129]!==Ie||t[130]!==Le?(Re=(0,$.jsx)(ln,{value:o,onChange:Pe,placeholder:Ie,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Le}),t[128]=o,t[129]=Ie,t[130]=Le,t[131]=Re):Re=t[131];let ze;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(ze=()=>a(null),t[132]=ze):ze=t[132];let Be;t[133]===r?Be=t[134]:(Be=r(`settings.common.actions.cancel`),t[133]=r,t[134]=Be);let Ve;t[135]===Be?Ve=t[136]:(Ve=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:ze,children:Be}),t[135]=Be,t[136]=Ve);let He;t[137]===r?He=t[138]:(He=r(`settings.common.actions.rename`),t[137]=r,t[138]=He);let Ue;t[139]!==oe||t[140]!==He?(Ue=(0,$.jsx)(Y,{size:`sm`,onClick:oe,children:He}),t[139]=oe,t[140]=He,t[141]=Ue):Ue=t[141];let We;t[142]!==Ve||t[143]!==Ue?(We=(0,$.jsxs)(Wt,{children:[Ve,Ue]}),t[142]=Ve,t[143]=Ue,t[144]=We):We=t[144];let Ge;t[145]!==Ne||t[146]!==Re||t[147]!==We?(Ge=(0,$.jsxs)(Gt,{children:[Ne,Re,We]}),t[145]=Ne,t[146]=Re,t[147]=We,t[148]=Ge):Ge=t[148];let Ke;t[149]!==Te||t[150]!==Ge?(Ke=(0,$.jsx)(Jt,{open:Te,onOpenChange:Ee,children:Ge}),t[149]=Te,t[150]=Ge,t[151]=Ke):Ke=t[151];let qe;return t[152]!==se||t[153]!==ce||t[154]!==le||t[155]!==we||t[156]!==Ke?(qe=(0,$.jsxs)(`div`,{className:se,children:[ce,le,we,Ke]}),t[152]=se,t[153]=ce,t[154]=le,t[155]=we,t[156]=Ke,t[157]=qe):qe=t[157],qe},Mo=e=>{let t=(0,Ei.c)(47),{command:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,isMenuOpen:l,onMenuOpenChange:u}=e,{t:d}=ke(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=fr(),t[0]=f):f=t[0];let p=f,[m,h]=Q.useState(!1),g;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==d?(g=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=d,t[6]=g):g=t[6];let _=g,v=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,y;t[7]===v?y=t[8]:(y=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,v),t[7]=v,t[8]=y);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=p?void 0:e=>{e.preventDefault(),h(!0)},t[9]=b):b=t[9];let x;t[10]===y?x=t[11]:(x=(0,$.jsx)(`div`,{className:y,onContextMenu:b}),t[10]=y,t[11]=x);let S;t[12]===n.name?S=t[13]:(S=(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`/`,n.name]}),t[12]=n.name,t[13]=S);let C;t[14]!==n||t[15]!==d?(C=(n.scope||Ui(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Ui(n)?d(`settings.agents.sidebar.badge.system`):n.scope}),t[14]=n,t[15]=d,t[16]=C):C=t[16];let w;t[17]!==S||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.description?T=t[21]:(T=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[20]=n.description,t[21]=T);let E;t[22]!==i||t[23]!==T||t[24]!==w?(E=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[w,T]}),t[22]=i,t[23]=T,t[24]=w,t[25]=E):E=t[25];let D;t[26]===u?D=t[27]:(D=e=>{e&&h(!1),u(e)},t[26]=u,t[27]=D);let O;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[28]=O):O=t[28];let k;t[29]===_?k=t[30]:(k=(0,$.jsx)(mn,{align:`end`,className:`w-fit min-w-20`,children:_(_n)}),t[29]=_,t[30]=k);let A;t[31]!==l||t[32]!==D||t[33]!==k?(A=(0,$.jsxs)(Tn,{open:l,onOpenChange:D,children:[O,k]}),t[31]=l,t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==E||t[36]!==A?(j=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[E,A]}),t[35]=E,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==j||t[39]!==x?(M=(0,$.jsx)(gi,{render:x,children:j}),t[38]=j,t[39]=x,t[40]=M):M=t[40];let N;t[41]===_?N=t[42]:(N=(0,$.jsx)(_i,{className:`w-fit min-w-20`,children:_(vi)}),t[41]=_,t[42]=N);let P;return t[43]!==m||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(yi,{open:m,onOpenChange:h,children:[M,N]}),t[43]=m,t[44]=M,t[45]=N,t[46]=P):P=t[46],P};function No(e){return{selectedCommandName:e.selectedCommandName,setSelectedCommand:e.setSelectedCommand,setCommandDraft:e.setCommandDraft,createCommand:e.createCommand,deleteCommand:e.deleteCommand}}function Po(e){return e.name}function Fo(e){return!Ui(e)}function Io(e,t){return e.name.localeCompare(t.name)}function Lo(e,t){return e.name.localeCompare(t.name)}var Ro=()=>{let{t:e}=ke(),{selectedCommandName:t,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:a}=Gi(he(e=>({selectedCommandName:e.selectedCommandName,createCommand:e.createCommand,updateCommand:e.updateCommand,commandDraft:e.commandDraft,setCommandDraft:e.setCommandDraft}))),o=_t(),s=Q.useMemo(()=>o.data??[],[o.data]),c=t?s.find(e=>e.name===t):null,l=!!(i&&i.name===t&&!c),[u,d]=Q.useState(``),[f,p]=Q.useState(`user`),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),w=Q.useRef(null);Q.useEffect(()=>{if(l&&i){let e=i.name||``,t=i.scope||`user`,n=i.description||``,r=i.agent||``,a=i.model||``,o=i.template||``;d(e),p(t),h(n),_(r),y(a),x(o),w.current={draftName:e,draftScope:t,description:n,agent:r,model:a,template:o}}else if(c){let e=c.description||``,t=c.agent||``,n=c.model||``,r=c.template||``;h(e),_(t),y(n),x(r),w.current={draftName:``,draftScope:`user`,description:e,agent:t,model:n,template:r}}},[c,l,t,s,i]);let T=Q.useMemo(()=>{let e=w.current;return e?!!(l&&(u!==e.draftName||f!==e.draftScope)||m!==e.description||g!==e.agent||v!==e.model||b!==e.template):!1},[g,m,u,f,l,v,b]);return t?(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:l?e(`settings.commands.page.title.new`):`/${t}`}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.commands.page.subtitle.new`:`settings.commands.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.identity`),children:[l&&(0,$.jsxs)(Fr,{itemId:`commands.name`,label:e(`settings.commands.page.field.commandName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`/`}),(0,$.jsx)(ln,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.commands.page.field.commandNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(an,{value:f,onValueChange:e=>p(e),children:[(0,$.jsx)(tn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(cn,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(nn,{align:`end`,children:[(0,$.jsx)($t,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)($t,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Fr,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(br,{embedded:!0,value:m,onChange:e=>h(e.target.value),placeholder:e(`settings.commands.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})})]}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.executionContext`),children:[(0,$.jsx)(Fr,{itemId:`commands.agent`,label:e(`settings.commands.page.field.overrideAgent`),children:(0,$.jsx)(xn,{agentName:g,onChange:e=>_(e),className:`oc-settings-inline-value`})}),(0,$.jsx)(Fr,{itemId:`commands.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(kn,{providerId:mt(v)?.providerId??``,modelId:mt(v)?.modelId??``,onChange:(e,t)=>{y(e&&t?`${e}/${t}`:``)},className:`oc-settings-inline-value`})})]}),(0,$.jsx)(Ar,{itemId:`commands.template`,label:e(`settings.commands.page.section.template`),description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`text-foreground`,children:`$ARGUMENTS`}),` `,e(`settings.commands.page.templateHint.userInput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:"!`cmd`"}),` `,e(`settings.commands.page.templateHint.shellOutput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`@file`}),` `,e(`settings.commands.page.templateHint.fileContents`)]}),descriptionPlacement:`outside`,className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(br,{embedded:!0,value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.commands.page.field.templatePlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let i=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!i){K.error(e(`settings.commands.sidebar.toast.commandNameRequired`));return}if(!b.trim()){K.error(e(`settings.commands.page.toast.templateRequired`));return}if(l&&s.some(e=>e.name===i)){K.error(e(`settings.commands.sidebar.toast.commandExists`));return}C(!0);try{let t=g.trim(),o=v.trim(),s=b.trim(),c={name:i,description:m.trim()||void 0,agent:t===``?null:t,model:o===``?null:o,template:s,scope:l?f:void 0},u;l?(u=await n(c),u&&a(null)):u=await r(i,c),u?K.success(e(l?`settings.commands.page.toast.created`:`settings.commands.page.toast.updated`)):K.error(e(l?`settings.commands.page.toast.createFailed`:`settings.commands.page.toast.updateFailed`))}catch(t){console.error(`Error saving command:`,t),K.error(e(`settings.commands.page.toast.saveUnexpectedError`))}finally{C(!1)}},disabled:S||!T,size:`xs`,className:`!font-normal`,children:e(S?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`terminal-box`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.commands.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.commands.page.empty.description`)})]})})},zo=[],Bo=e=>{switch(e){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`idle`}},Vo=e=>{let t=(0,Ei.c)(5),{tone:n,enabled:r}=e;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0`}),t[0]=e):e=t[0],e}let i;t[1]===n?i=t[2]:(i=q(`inline-block h-2 w-2 rounded-full flex-shrink-0`,{success:`bg-[var(--status-success)]`,error:`bg-[var(--status-error)]`,warning:`bg-[var(--status-warning)]`,idle:`bg-muted-foreground/40`}[n]),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`span`,{className:i}),t[3]=i,t[4]=a),a},Ho=e=>{let t=(0,Ei.c)(115),{onItemSelect:n}=e,{t:r}=ke(),{selectedMcpName:a,setSelectedMcp:o,setMcpDraft:s,deleteMcp:c}=$i(he(Uo)),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Jr(),t[0]=l):l=t[0];let u=l,d=qr(u),f=Yr(u),p=d.data??zo,m;t[1]===f.data?m=t[2]:(m=f.data??{},t[1]=f.data,t[2]=m);let h=m,[g,_]=Q.useState(null),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,C]=Q.useState(null),[w,T]=Q.useState(!1),E;t[3]===p?E=t[4]:(E=p.filter(Wo),t[3]=p,t[4]=E);let D=E,O;t[5]===p?O=t[6]:(O=p.filter(Go),t[5]=p,t[6]=O);let k=O,A;t[7]===w?A=t[8]:(A=()=>{if(w)return;T(!0);let e=new Promise(Ko),t=i();Promise.all([Nr(H,u,t),e]).catch(qo).finally(()=>{T(!1)})},t[7]=w,t[8]=A);let j=A,M;t[9]!==p||t[10]!==n||t[11]!==s||t[12]!==o?(M=()=>{let e=`new-mcp-server`,t=1;for(;p.some(t=>t.name===e);)e=`new-mcp-server-${t}`,t++;s({name:e,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),o(e),n?.()},t[9]=p,t[10]=n,t[11]=s,t[12]=o,t[13]=M):M=t[13];let N=M,P;t[14]!==c||t[15]!==g||t[16]!==r?(P=async()=>{if(!g)return;y(!0);let e=await c(g.name,{directory:Jr(),transportIdentity:i()});e.ok?e.reloadFailed?K.warning(e.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:e.warning||r(`settings.mcp.sidebar.toast.refreshListIfStale`)}):K.success(e.message||r(`settings.mcp.sidebar.toast.serverDeleted`,{name:g.name})):K.error(r(`settings.mcp.sidebar.toast.deleteFailed`)),_(null),y(!1)},t[14]=c,t[15]=g,t[16]=r,t[17]=P):P=t[17];let F=P,I;t[18]===r?I=t[19]:(I=(e,t)=>(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),_(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]}),t[18]=r,t[19]=I);let L=I,R;t[20]===r?R=t[21]:(R=r(`settings.mcp.sidebar.group.userServers`),t[20]=r,t[21]=R);let z;t[22]===R?z=t[23]:(z=(0,$.jsx)(`span`,{children:R}),t[22]=R,t[23]=z);let B;t[24]===r?B=t[25]:(B=r(`settings.mcp.sidebar.actions.refreshStatusAria`),t[24]=r,t[25]=B);let V;t[26]===r?V=t[27]:(V=r(`settings.mcp.sidebar.actions.refreshStatusTitle`),t[26]=r,t[27]=V);let ee=w&&`animate-spin`,U;t[28]===ee?U=t[29]:(U=q(`h-4 w-4`,ee),t[28]=ee,t[29]=U);let te;t[30]===U?te=t[31]:(te=(0,$.jsx)(J,{name:`refresh`,className:U}),t[30]=U,t[31]=te);let W;t[32]!==j||t[33]!==w||t[34]!==B||t[35]!==V||t[36]!==te?(W=(0,$.jsx)(Y,{type:`button`,size:`icon`,variant:`ghost`,disabled:w,onClick:j,"aria-label":B,title:V,children:te}),t[32]=j,t[33]=w,t[34]=B,t[35]=V,t[36]=te,t[37]=W):W=t[37];let ne;t[38]===r?ne=t[39]:(ne=r(`settings.mcp.sidebar.actions.addServerTitle`),t[38]=r,t[39]=ne);let re;t[40]===r?re=t[41]:(re=r(`settings.mcp.sidebar.actions.addServerTitle`),t[40]=r,t[41]=re);let ie;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[42]=ie):ie=t[42];let ae;t[43]!==N||t[44]!==ne||t[45]!==re?(ae=(0,$.jsx)(Y,{"data-settings-item":`mcp.create`,size:`icon`,variant:`ghost`,onClick:N,"aria-label":ne,title:re,children:ie}),t[43]=N,t[44]=ne,t[45]=re,t[46]=ae):ae=t[46];let oe;t[47]!==W||t[48]!==ae?(oe=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[W,ae]}),t[47]=W,t[48]=ae,t[49]=oe):oe=t[49];let se;t[50]!==z||t[51]!==oe?(se=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[z,oe]}),t[50]=z,t[51]=oe,t[52]=se):se=t[52];let ce=se,le;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(ha,{})})}),t[53]=le):le=t[53];let ue;t[54]!==d.data||t[55]!==d.error||t[56]!==d.isError||t[57]!==p.length||t[58]!==h||t[59]!==n||t[60]!==b||t[61]!==D||t[62]!==L||t[63]!==S||t[64]!==a||t[65]!==s||t[66]!==o||t[67]!==f.data||t[68]!==f.error||t[69]!==f.isError||t[70]!==r||t[71]!==k||t[72]!==ce?(ue=(0,$.jsx)($.Fragment,{children:d.isError&&!d.data?(0,$.jsx)(Z,{label:ce,children:(0,$.jsx)(`div`,{className:`oc-settings-group-row py-12 text-center typography-meta text-[var(--status-error)]`,children:d.error.message})}):p.length===0?(0,$.jsx)(Z,{label:ce,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.mcp.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.mcp.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[D.length>0&&(0,$.jsx)(Z,{label:r(`settings.mcp.sidebar.group.projectServers`),children:D.map(e=>{let t=Bo((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=fr();return(0,$.jsxs)(yi,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(gi,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Vo,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(J,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(J,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(Tn,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(mn,{align:`end`,className:`w-fit min-w-20`,children:L(e,_n)})]})]}),(0,$.jsx)(_i,{className:`w-fit min-w-20`,children:L(e,vi)})]},e.name)})}),k.length>0&&(0,$.jsx)(Z,{label:ce,children:k.map(e=>{let t=Bo((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=fr();return(0,$.jsxs)(yi,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(gi,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Vo,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(J,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(J,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(Tn,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(mn,{align:`end`,className:`w-fit min-w-20`,children:L(e,_n)})]})]}),(0,$.jsx)(_i,{className:`w-fit min-w-20`,children:L(e,vi)})]},e.name)})}),k.length===0&&(0,$.jsx)(Z,{label:ce,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[54]=d.data,t[55]=d.error,t[56]=d.isError,t[57]=p.length,t[58]=h,t[59]=n,t[60]=b,t[61]=D,t[62]=L,t[63]=S,t[64]=a,t[65]=s,t[66]=o,t[67]=f.data,t[68]=f.error,t[69]=f.isError,t[70]=r,t[71]=k,t[72]=ce,t[73]=ue):ue=t[73];let de=g!==null,fe;t[74]===v?fe=t[75]:(fe=e=>{!e&&!v&&_(null)},t[74]=v,t[75]=fe);let pe;t[76]===r?pe=t[77]:(pe=r(`settings.mcp.sidebar.deleteDialog.title`),t[76]=r,t[77]=pe);let me;t[78]===pe?me=t[79]:(me=(0,$.jsx)(Kt,{children:pe}),t[78]=pe,t[79]=me);let ge=g?.name||``,_e;t[80]!==r||t[81]!==ge?(_e=r(`settings.mcp.sidebar.deleteDialog.descriptionPrefix`,{name:ge}),t[80]=r,t[81]=ge,t[82]=_e):_e=t[82];let ve;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),t[83]=ve):ve=t[83];let ye;t[84]===_e?ye=t[85]:(ye=(0,$.jsxs)(qt,{children:[_e,` `,ve,`.`]}),t[84]=_e,t[85]=ye);let be;t[86]!==me||t[87]!==ye?(be=(0,$.jsxs)(Ut,{children:[me,ye]}),t[86]=me,t[87]=ye,t[88]=be):be=t[88];let xe;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>_(null),t[89]=xe):xe=t[89];let Se;t[90]===r?Se=t[91]:(Se=r(`settings.common.actions.cancel`),t[90]=r,t[91]=Se);let Ce;t[92]!==v||t[93]!==Se?(Ce=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:xe,disabled:v,children:Se}),t[92]=v,t[93]=Se,t[94]=Ce):Ce=t[94];let we;t[95]!==v||t[96]!==r?(we=r(v?`settings.mcp.sidebar.actions.deleting`:`settings.common.actions.delete`),t[95]=v,t[96]=r,t[97]=we):we=t[97];let Te;t[98]!==F||t[99]!==v||t[100]!==we?(Te=(0,$.jsx)(Y,{size:`sm`,onClick:F,disabled:v,children:we}),t[98]=F,t[99]=v,t[100]=we,t[101]=Te):Te=t[101];let Ee;t[102]!==Ce||t[103]!==Te?(Ee=(0,$.jsxs)(Wt,{children:[Ce,Te]}),t[102]=Ce,t[103]=Te,t[104]=Ee):Ee=t[104];let De;t[105]!==be||t[106]!==Ee?(De=(0,$.jsxs)(Gt,{className:`max-w-md`,children:[be,Ee]}),t[105]=be,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]!==de||t[109]!==fe||t[110]!==De?(Oe=(0,$.jsx)(Jt,{open:de,onOpenChange:fe,children:De}),t[108]=de,t[109]=fe,t[110]=De,t[111]=Oe):Oe=t[111];let Ae;return t[112]!==ue||t[113]!==Oe?(Ae=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[le,ue,Oe]}),t[112]=ue,t[113]=Oe,t[114]=Ae):Ae=t[114],Ae};function Uo(e){return{selectedMcpName:e.selectedMcpName,setSelectedMcp:e.setSelectedMcp,setMcpDraft:e.setMcpDraft,deleteMcp:e.deleteMcp}}function Wo(e){return e.scope===`project`}function Go(e){return e.scope!==`project`}function Ko(e){return setTimeout(e,500)}function qo(e){K.error(e instanceof Error?e.message:String(e))}function Jo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Xo(e,t){return t===void 0?{ok:!1,error:e}:{ok:!1,error:e,parsed:t}}function Zo(e,t,n){return{ok:!0,name:e,type:t,command:Qo(n),url:typeof n.url==`string`?n.url.trim():``,environment:$o(n,`env`,`environment`),headers:$o(n,`headers`),oauthEnabled:es(n),oauthClientId:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientId??``).trim():``,oauthClientSecret:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientSecret??``).trim():``,oauthScope:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.scope??``).trim():``,oauthRedirectUri:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.redirectUri??``).trim():``,timeout:ts(n),enabled:ns(n)}}function Qo(e){let t=e.command,n=e.args;if(Yo(t)&&Yo(n))return[...t,...n];if(Yo(t))return t;if(typeof t==`string`&&t.trim()){let e=t.trim().split(/\s+/);return Yo(n)?[...e,...n]:e}return Yo(n)?n:[]}function $o(e,...t){for(let n of t){let t=e[n];if(!Jo(t))continue;let r=Object.entries(t).filter(([e,t])=>e&&typeof t==`string`);if(r.length>0)return r.map(([e,t])=>({key:e,value:String(t)}))}return[]}function es(e){if(e.oauth===!1||e.oauth===null||e.oauth===void 0||!Jo(e.oauth))return!1;let t=e.oauth;return!!(typeof t.clientId==`string`&&t.clientId.trim()||typeof t.clientSecret==`string`&&t.clientSecret.trim()||typeof t.scope==`string`&&t.scope.trim()||typeof t.redirectUri==`string`&&t.redirectUri.trim())}function ts(e){let t=e.timeout;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return``}function ns(e){return`disabled`in e&&e.disabled===!0?!1:`enabled`in e?!!e.enabled:!0}function rs(e){let t=e.mcpServers;if(Jo(t)){let e=Object.keys(t);if(e.length===1){let n=e[0],r=t[n];if(Jo(r))return{name:n,entry:r}}if(e.length>1)return null}let n=Object.keys(e).filter(t=>{let n=e[t];return t!==`mcpServers`&&Jo(n)});if(n.length===1){let t=n[0],r=e[t];if(is(r))return{name:t,entry:r}}return null}function is(e){return e.type===`local`||e.type===`remote`||Array.isArray(e.command)||typeof e.url==`string`||Array.isArray(e.args)}function as(e,t){let n;try{let t=e.trim();if(!t)return Xo(`No JSON content provided`);n=JSON.parse(t)}catch(e){return Xo(e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`)}if(!Jo(n))return Xo(`Expected a JSON object, not an array or primitive`);let r=n,i=r.mcpServers;if(Jo(i)){let e=Object.keys(i);if(e.length===0)return Xo(`mcpServers object is empty`,n);if(e.length>1)return Xo(`Paste one server at a time. Found `+e.length+` servers in mcpServers`,n);let t=e[0],r=i[t];return Jo(r)?Zo(t,os(r),r):Xo(`Server entry is not a valid object`,n)}let a=r.mcp;if(Jo(a)){let e=Object.keys(a);if(e.length===0)return Xo(`mcp object is empty`,n);if(e.length>1)return Xo(`Paste one server at a time. Found `+e.length+` servers in mcp`,n);let t=e[0],r=a[t];return Jo(r)?Zo(t,os(r),r):Xo(`Server entry in mcp is not a valid object`,n)}let o=rs(r);if(o)return Zo(o.name,os(o.entry),o.entry);if(is(r)){let e=os(r);return Zo(typeof r.name==`string`&&r.name.trim()?r.name.trim():t?.fallbackName,e,r)}return Xo(`No recognizable MCP server configuration found in JSON`,n)}function os(e){return e.type===`remote`?`remote`:e.type===`local`?`local`:typeof e.url==`string`&&e.url.trim()?`remote`:(Array.isArray(e.command)||typeof e.command==`string`||Array.isArray(e.args),`local`)}function ss(e,t,n){let r=n?.isNewServer??!1,i=e.name,a=r&&i?i:t.name??``;return{...t,name:a,type:e.type,command:e.type===`local`?e.command:[],url:e.type===`remote`?e.url:``,environment:e.environment,headers:e.type===`remote`?e.headers:[],oauthEnabled:e.type===`remote`&&e.oauthEnabled,oauthClientId:e.type===`remote`?e.oauthClientId:``,oauthClientSecret:e.type===`remote`?e.oauthClientSecret:``,oauthScope:e.type===`remote`?e.oauthScope:``,oauthRedirectUri:e.type===`remote`?e.oauthRedirectUri:``,timeout:e.type===`remote`?e.timeout:``,enabled:e.enabled}}function cs(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`'`&&!i){r=!r;continue}if(o===`"`&&!r){i=!i;continue}if((o===` `||o===` `)&&!r&&!i){n&&=(t.push(n),``);continue}n+=o}return n&&t.push(n),t}function ls(e){let t=e.trim();if(!t)return{code:null,context:null,stateKey:null};try{let e=new URL(t),n=e.searchParams.get(`code`);if(typeof n==`string`&&n.trim())return{code:n.trim(),context:Ir(e.searchParams),stateKey:Lr(e.searchParams)}}catch{}return{code:t,context:null,stateKey:null}}var us=({value:e,onChange:t,pasteCommandTitle:n,pasteCommandLabel:r,pasteSuccess:i,clipboardReadFailed:a,preview:o})=>{let[s,c]=Q.useState(()=>e.join(`
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{A as n,C as r,E as i,T as a,a as o,j as s,o as c,r as l,t as u,tt as d,u as f,y as p}from"./useUIStore-DwpQTjLO.js";import{$t as m,Bt as h,D as g,E as _,Ht as v,Kt as y,O as b,R as x,Ut as S,Vt as C,Xt as w,Yt as T,a as E,bn as D,cn as O,d as k,en as A,et as j,f as M,gn as N,hn as P,i as F,k as I,kn as L,l as R,mn as z,qt as B,r as V,u as H,un as ee,xn as U}from"./persistence-CVTWFaqe.js";import{a as te,g as W,h as ne,i as re,l as ie,m as ae,n as oe,p as se,r as ce,t as le,u as ue}from"./desktopHosts-BVJXQq1S.js";import{n as de}from"./desktopRelayRestore-RDfuj1M7.js";import{a as fe,i as pe,r as me,t as he}from"./vendor-zustand-B4dlGEM2.js";import{nt as ge,rt as _e}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as ve,Nt as ye,n as be,t as xe}from"./platform-BY_Gtsqr.js";import{n as Se}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as Ce}from"./vendor-react-DLPElpoQ.js";import{s as we}from"./vendor-tanstack-react-query-D7pys_c9.js";import{W as Te}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{r as Ee}from"./vendor-sonner-DVzioF3d.js";import{c as De,n as Oe}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ke,r as Ae,t as je}from"./clipboard-C05anBwU.js";import{a as Me,i as Ne,r as Pe}from"./MobileShareBridge-DIfOl8EZ.js";import{$a as Fe,Aa as Ie,Bi as Le,Co as Re,Ea as ze,Ga as Be,Gi as Ve,Gt as He,Hi as Ue,Ja as We,Ka as Ge,Ki as Ke,Oa as qe,Qa as Je,So as Ye,Vi as Xe,Wi as Ze,Xa as Qe,Xr as $e,Ya as et,Za as tt,Zi as G,Zr as nt,ao as rt,bo as it,co as at,do as ot,dr as st,ei as ct,eo as lt,fo as ut,go as dt,ho as ft,io as pt,ja as mt,ka as ht,lo as gt,mo as _t,mr as K,no as vt,oi as yt,oo as bt,po as xt,qa as St,r as Ct,ro as wt,so as Tt,ti as Et,to as Dt,uo as Ot,vo as kt,xo as At}from"./useMobileNavigationStore-DuTu0Mzh.js";import{_ as jt,c as Mt,d as Nt,f as Pt,g as Ft,h as It,i as Lt,m as Rt,o as zt,p as Bt,r as Vt,t as Ht}from"./MobileDetailNavigation-CtYke_1C.js";import{i as Ut}from"./useAssistantUIStore-Cg9bsT4b.js";import{a as Wt,i as Gt,n as Kt,o as qt,r as Jt,t as Yt}from"./dialog-rrqB-H6q.js";import{i as Xt,t as q}from"./utils-81nUI_xp.js";import{t as Zt}from"./AgentAvatar-CiQIIM0d.js";import{n as J}from"./Icon-CeKHYyKZ.js";import{t as Y}from"./button-DFPOdZ0g.js";import{T as Qt,Z as $t,_ as en,a as tn,b as nn,h as rn,i as an,m as on,n as sn,q as cn,x as ln}from"./projectMeta-Dl5iPCB6.js";import{t as un}from"./input-BO3r20op.js";import{i as dn,n as fn,t as pn}from"./tooltip-CQGqGAG_.js";import{$ as mn,F as hn,G as gn,H as _n,I as vn,It as yn,K as bn,Lt as xn,M as Sn,Mt as Cn,Nt as wn,Ot as Tn,P as En,Pt as Dn,Q as On,R as kn,T as An,V as jn,Z as Mn,_ as Nn,_t as Pn,a as Fn,c as In,ct as X,dt as Ln,et as Rn,f as zn,ft as Bn,g as Vn,gt as Hn,h as Un,ht as Wn,i as Gn,jt as Kn,kt as qn,lt as Jn,mt as Yn,ot as Xn,p as Zn,pt as Qn,q as $n,s as er,st as tr,t as nr,u as rr,ut as ir,vt as ar,w as or,xt as sr,y as cr,yt as lr,z as ur}from"./useSessionAutoCleanup-C-L9teva.js";import{n as dr}from"./useThemeSystem-DMzWVJaW.js";import{i as fr,r as pr}from"./OverlayScrollbar-DUghqFGg.js";import{n as mr}from"./useRuntimeAPIs-DSLXJybW.js";import{A as hr,N as gr,i as _r,n as vr}from"./appThemeRegistry-CIZ-shMD.js";import{n as yr}from"./MarkdownRenderer-wpeGdciL.js";import{n as br,t as xr}from"./textarea-BjX-KhMN.js";import{a as Sr}from"./url-BMjqccCo.js";import{c as Cr}from"./markdown-worker-CZWE1F1M.js";import{t as wr}from"./sortable-tabs-strip-s7UUxsa6.js";import{$ as Tr,A as Er,B as Dr,C as Or,D as kr,E as Ar,F as jr,G as Mr,H as Nr,I as Z,J as Pr,K as Fr,L as Ir,M as Lr,N as Rr,O as zr,P as Br,Q as Vr,R as Hr,S as Ur,T as Wr,U as Gr,V as Kr,W as qr,X as Jr,Y as Yr,Z as Xr,_ as Zr,a as Qr,b as $r,c as ei,d as ti,f as ni,h as ri,j as ii,k as ai,l as oi,m as si,n as ci,p as li,q as ui,s as di,u as fi,v as pi,w as mi,y as hi,z as gi}from"./MobileSurface-_KoX75Ff.js";import{a as _i,n as vi,r as yi,t as bi}from"./context-menu-DGz4_2hs.js";import{n as xi,r as Si,t as Ci}from"./collapsible-oGbEvbe1.js";import{n as wi,t as Ti}from"./vendor-yaml-DIcAK3EC.js";import{t as Ei}from"./vendor-qrcode-DAuVxiQR.js";var Di=Ce(),Q=e(_e(),1),$=ge(),Oi=`https://github.com/yee94/openchamber`,ki=`${Oi}/issues/new`,Ai=`https://discord.gg/ZYRSdnwwKA`,ji=`https://x.com/openchamber_dev`,Mi=800,Ni=()=>{try{let e=Se;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.OpenChamberOTA?.channel===`stable`?`stable`:`beta`}catch{return`beta`}},Pi=({initialUpdateDialogOpen:e=!1})=>{let{t}=ke(),[n,r]=Q.useState(e),[i,a]=Q.useState(!1),[o,s]=Q.useState(!1),[c,l]=Q.useState(null),[d,f]=Q.useState(null),[p,m]=Q.useState(null),[h,g]=Q.useState(null),_=Dr(he(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),{isMobile:v}=fr(),y=u(e=>e.otaChannelOverride),b=u(e=>e.setOtaChannelOverride),x=be(),S=Ni(),C=y===`beta`||y===null&&S===`beta`,[w,T]=Q.useState(!1),[E,D]=Q.useState(()=>Et()),O=Oe(e=>{yt(e),D(e)}),k=Oe(async e=>{if(e){b(`beta`),await Dr.getState().checkForUpdates();return}b(`stable`),await Dr.getState().checkForUpdates();let{info:t,otaDecision:n}=Dr.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&a(!0)}),A=Oe(()=>{a(!1),b(`beta`),Dr.getState().checkForUpdates()}),j=Oe(()=>{a(!1),r(!0),Dr.getState().downloadUpdate()}),M=Oe(e=>{e||A()}),N=c||t(`settings.openchamber.about.state.unknown`),P=Oe(async()=>{if(!w){T(!0);try{let{outcome:e,eventCount:n}=await ct();if(e===`cancelled`)return;if(e===`failed`){K.error(t(`settings.openchamber.about.diagnostics.toast.failed`));return}K.success(t(n>0?`settings.openchamber.about.diagnostics.toast.exported`:`settings.openchamber.about.diagnostics.toast.empty`))}catch{K.error(t(`settings.openchamber.about.diagnostics.toast.failed`))}finally{T(!1)}}});Q.useEffect(()=>{let e=!1;return Gr().then(t=>{e||l(t)}),Nr().then(t=>{e||f(t)}),()=>{e=!0}},[]);let F=Kr(c,d)??N;Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await L(`/api/system/info`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.openchamberVersion==`string`&&n.openchamberVersion.trim().length>0?n.openchamberVersion.trim():null;e||m(r)}catch{e||m(null)}})(),()=>{e=!0}},[]),Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await L(`/api/opencode/upgrade-status`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.currentVersion==`string`&&n.currentVersion.trim().length>0?n.currentVersion.trim():null;e||g(r)}catch{e||g(null)}})(),()=>{e=!0}},[]);let I=Q.useRef(!1);Q.useEffect(()=>{if(_.checking)s(!0),I.current=!0;else if(o){let e=setTimeout(()=>{s(!1),I.current&&_.error?(K.error(t(`settings.openchamber.about.toast.checkFailed`),{description:_.error}),I.current=!1):I.current&&!_.available&&!_.error&&(K.success(t(`settings.openchamber.about.toast.latestVersion`)),I.current=!1)},Mi);return()=>clearTimeout(e)}},[t,_.checking,o,_.available,_.error]);let R=_.checking||o;return v?(0,$.jsxs)(`div`,{className:`w-full space-y-6 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Wn,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`OpenChamber`})]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Ir,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:F})}),(0,$.jsx)(Ir,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:p||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ir,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:h||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ir,{children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,children:(0,$.jsxs)(`a`,{href:ki,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(J,{name:`question`,className:`size-4`}),t(`settings.openchamber.about.actions.submitFeedback`)]})}),!R&&_.available?(0,$.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`size-4`}),_.info?.inAppApply?t(`settings.openchamber.about.actions.applyOtaToVersion`,{version:_.info?.version||``}):_.info?.manualUpdate?t(`settings.openchamber.about.actions.installNativeToVersion`,{version:_.info?.version||``}):t(`settings.openchamber.about.actions.updateToVersion`,{version:_.info?.version||``})]}):(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>_.checkForUpdates(),disabled:R,children:[R?(0,$.jsx)(J,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(J,{name:`refresh`,className:`size-4`}),t(R?`settings.openchamber.about.state.checking`:`settings.openchamber.about.actions.checkForUpdates`)]})]})}),_.error&&(0,$.jsx)(Ir,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:_.error})}),x&&(0,$.jsx)(Hr,{itemId:`about.beta-updates`,checked:C,onChange:k,label:t(`settings.openchamber.about.betaUpdates.label`),description:t(`settings.openchamber.about.betaUpdates.description`),ariaLabel:t(`settings.openchamber.about.betaUpdates.label`),disabled:R}),(0,$.jsx)(Hr,{itemId:`about.diagnostics`,checked:E,onChange:O,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),E&&(0,$.jsx)(Ir,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:w,onClick:()=>void P(),children:t(w?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-5`,children:[(0,$.jsxs)(`a`,{href:Oi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Ai,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`discord-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`Discord`})]})]}),(0,$.jsxs)(`a`,{href:ji,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(gi,{open:n,onOpenChange:r,info:_.info,downloading:_.downloading,downloaded:_.downloaded,progress:_.progress,error:_.error,onDownload:_.downloadUpdate,onRestart:_.restartToUpdate,runtimeType:_.runtimeType}),(0,$.jsx)(Yt,{open:i,onOpenChange:M,children:(0,$.jsxs)(Kt,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:t(`settings.openchamber.about.betaUpdates.rollback.title`)}),(0,$.jsx)(Jt,{children:t(`settings.openchamber.about.betaUpdates.rollback.description`,{version:_.info?.version||``})})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,onClick:A,children:t(`settings.openchamber.about.betaUpdates.rollback.actions.cancel`)}),(0,$.jsx)(Y,{type:`button`,size:`sm`,onClick:j,children:t(`settings.openchamber.about.betaUpdates.rollback.actions.confirm`)})]})]})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:t(`settings.openchamber.about.title`),children:[(0,$.jsx)(Ir,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:N})}),(0,$.jsx)(Ir,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:p||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ir,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:h||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ir,{children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-3`,children:[(0,$.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,children:(0,$.jsxs)(`a`,{href:ki,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(J,{name:`question`,className:`size-4`}),t(`settings.openchamber.about.actions.submitFeedback`)]})}),_.checking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:t(`settings.openchamber.about.state.checking`)})]}),!_.checking&&_.available&&(0,$.jsxs)(Y,{size:`sm`,variant:`default`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`h-4 w-4 mr-1`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:_.info?.version||``})]}),!_.checking&&!_.available&&!_.error&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.about.state.upToDate`)}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>_.checkForUpdates(),disabled:_.checking,children:t(`settings.openchamber.about.actions.checkForUpdates`)})]})}),_.error&&(0,$.jsx)(Ir,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:_.error})}),(0,$.jsx)(Hr,{itemId:`about.diagnostics`,checked:E,onChange:O,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),E&&(0,$.jsx)(Ir,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:w,onClick:()=>void P(),children:t(w?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})}),(0,$.jsxs)(Ir,{controlClassName:`flex-wrap`,children:[(0,$.jsxs)(`a`,{href:Oi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:ji,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]})]}),(0,$.jsx)(gi,{open:n,onOpenChange:r,info:_.info,downloading:_.downloading,downloaded:_.downloaded,progress:_.progress,error:_.error,onDownload:_.downloadUpdate,onRestart:_.restartToUpdate,runtimeType:_.runtimeType})]})},Fi=`/assets/android-direct-share-1a0lp154.jpg`,Ii=`/assets/ios-share-sheet-B3Dlufnc.jpg`,Li=`/assets/select-assistant-C89IRspC.jpg`,Ri=`openchamber:assistant-share-welcome:v1`,zi=[{image:Ii,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:Fi,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Li,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],Bi=e=>{let t=(0,Di.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=ke(),[s,c]=De(Ri,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=Oe(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(J,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(qt,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(Jt,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)(Wt,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=zi.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(Gt,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(Y,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(Kt,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(Yt,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Vi=`useCommandsStore`,Hi=new Set([`init`,`review`]),Ui=e=>new Promise(t=>setTimeout(t,e)),Wi=e=>Hi.has(e.name),Gi=async(e,t)=>{await ut(H,e,t),i()===t&&At(`commands`,{source:Vi})},Ki=fe()(me(pe(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=xt(),t=i();try{return await ut(H,e,t),!0}catch{return!1}},createCommand:async t=>qi(`POST`,t.name,t,e),updateCommand:async(t,n)=>qi(`PATCH`,t,n,e),deleteCommand:async t=>qi(`DELETE`,t,void 0,e),getCommandByName:e=>ot().find(t=>t.name===e)}),{name:`commands-store`,storage:p(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function qi(e,t,n,r){kt(`${{POST:`Creating`,PATCH:`Updating`,DELETE:`Deleting`}[e]} command configuration…`);let a=xt(),o=i(),s=!1;try{let i={};if(e===`POST`&&(i.template=n?.template||``,n?.description&&(i.description=n.description),n?.agent&&(i.agent=n.agent),n?.model&&(i.model=n.model),n?.scope&&(i.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(i[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,l=await L(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(i)}}),u=await l.json().catch(()=>null);if(!l.ok)throw Error(u?.error||`Failed to ${e.toLowerCase()} command`);return s=u?.requiresReload??!0,s?await Ji(a,o,{message:u?.message,delayMs:u?.reloadDelayMs}):await Gi(a,o),e===`DELETE`&&r({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}finally{dt()}}async function Ji(e,t,n){n.delayMs&&await Ui(n.delayMs),it(n.message||`Refreshing commands…`),await Gi(e,t)}typeof window<`u`&&(window.__zustand_commands_store__=Ki),Re(e=>{e.source!==Vi&&Ye(e,`commands`)&&Ki.getState().loadCommands()});var Yi=()=>{try{let e=ft.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=ye.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},Xi=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],Zi=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Qi=e=>{if(typeof e==`string`)return e.trim()||void 0},$i=800,ea=fe()(me(pe((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=Yi();try{return!e?.force&&Mr(H,t).length>0||await ui(H,t,i()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{kt(`Creating MCP server configuration…`);let n=!1,r=`directory`in(t??{})?t?.directory?.trim()||null:Yi(),a=t?.transportIdentity??i();try{let t=ta(e),i=r?`?directory=${encodeURIComponent(r)}`:``,o=await L(`/api/config/mcp/${encodeURIComponent(e.name)}${i}`,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return s?.requiresReload?(n=!0,await St({message:s.message,delayMs:s.reloadDelayMs??$i,scopes:[`mcp`],queryDirectory:r,transportIdentity:a}),await ui(H,r,a),await Pr(H,r,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):(await ui(H,r,a),await Pr(H,r,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning})}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}finally{n||dt()}},updateMcp:async(e,t,n)=>{kt(`Updating MCP server configuration…`);let r=!1,a=`directory`in(n??{})?n?.directory?.trim()||null:Yi(),o=n?.transportIdentity??i();try{let n=ta(t),i=a?`?directory=${encodeURIComponent(a)}`:``,s=await L(`/api/config/mcp/${encodeURIComponent(e)}${i}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return c?.requiresReload?(r=!0,await St({message:c.message,delayMs:c.reloadDelayMs??$i,scopes:[`mcp`],queryDirectory:a,transportIdentity:o}),await ui(H,a,o),await Pr(H,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):(await ui(H,a,o),await Pr(H,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning})}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}finally{r||dt()}},deleteMcp:async(n,r)=>{kt(`Deleting MCP server configuration…`);let a=!1,o=`directory`in(r??{})?r?.directory?.trim()||null:Yi(),s=r?.transportIdentity??i();try{let r=o?`?directory=${encodeURIComponent(o)}`:``,i=await L(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),c=await i.json().catch(()=>null);if(!i.ok)throw Error(c?.error||`Failed to delete MCP server`);return c?.requiresReload&&(a=!0,await St({message:c.message,delayMs:c.reloadDelayMs??$i,scopes:[`mcp`],queryDirectory:o,transportIdentity:s})),t().selectedMcpName===n&&e({selectedMcpName:null}),qr.getState().clearDiagnostic(n,o,s),await ui(H,o,s),await Pr(H,o,s),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}finally{a||dt()}}}),{name:`mcp-config-store`,storage:p(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function ta(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=Zi(e.environment)??{}),e.headers!==void 0&&(t.headers=Zi(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Qi(e.oauthClientId),clientSecret:Qi(e.oauthClientSecret),scope:Qi(e.oauthScope),redirectUri:Qi(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var na=()=>{let e=ye.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},ra=`useSkillsStore`,ia=e=>new Promise(t=>setTimeout(t,e)),aa=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=na();return typeof t==`string`&&t.trim()||null},oa=2e4,sa=300,ca=4,la=800,ua=200,da=2e3,fa=fe()(me(pe((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await tt(H,na(),i()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=na(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await L(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{kt(`Creating skill...`);let n=!1;try{let r={name:e.name,description:e.description};e.instructions&&(r.instructions=e.instructions),e.scope&&(r.scope=e.scope),e.source&&(r.source=e.source),e.supportingFiles&&(r.supportingFiles=e.supportingFiles);let a=aa(t),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await L(`/api/config/skills/${encodeURIComponent(e.name)}${s}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to create skill`;throw Error(e)}return l?.requiresReload??!1?(n=!0,await ma({message:l?.message,delayMs:l?.reloadDelayMs,directory:a,transportIdentity:o}),!0):(await tt(H,a,o),await vt(H,a,o),At(`skills`,{source:ra}),!0)}catch{return!1}finally{n||dt()}},updateSkill:async(e,t,n)=>{kt(`Updating skill...`);let r=!1;try{let a={};t.description!==void 0&&(a.description=t.description),t.instructions!==void 0&&(a.instructions=t.instructions),t.supportingFiles!==void 0&&(a.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(a.targetPath=t.targetPath);let o=aa(n),s=i(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await L(`/api/config/skills/${encodeURIComponent(e)}${c}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return u?.requiresReload??!1?(r=!0,await ma({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await tt(H,o,s),await vt(H,o,s),At(`skills`,{source:ra}),!0)}catch{return!1}finally{r||dt()}},deleteSkill:async(n,r)=>{kt(`Deleting skill...`);let a=!1;try{let o=aa(r),s=i(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await L(`/api/config/skills/${encodeURIComponent(n)}${c}`,{method:`DELETE`}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return u?.requiresReload??!1?(a=!0,await ma({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await tt(H,o,s),await vt(H,o,s),At(`skills`,{source:ra}),t().selectedSkillName===n&&e({selectedSkillName:null}),!0)}catch{return!1}finally{a||dt()}},getSkillByName:e=>Qe(H,na()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=na(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await L(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=na(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await L(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=na(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await L(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:p(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=fa);async function pa(e){let t=typeof e==`number`&&e>0?Math.min(e,sa):0;t>0&&await ia(t);let n=Date.now(),r=0,i=null;for(;Date.now()-n<oa;){r+=1,it(`Waiting for OpenCode… (attempt ${r})`);try{if(await ye.checkHealth())return;i=Error(`OpenCode health check reported not ready`)}catch(e){i=e}let e=Date.now()-n;await ia(r<=ca&&e<1200?sa:Math.min(la+Math.max(0,r-ca)*ua,da))}throw i||Error(`OpenCode did not become ready in time`)}async function ma(e){let t=e&&`directory`in e?e.directory?.trim()||null:na(),n=e?.transportIdentity??i();try{it(e?.message||`Refreshing skills…`)}catch{}try{if(await pa(e?.delayMs),i()!==n||(it(`Refreshing skills…`),await tt(H,t,n),i()!==n))return;await vt(H,t,n),At(`skills`,{source:ra})}catch(e){throw it(`OpenCode refresh failed. Please retry.`),await ia(1500),e}finally{dt()}}var ha=null;ha||=Re(e=>{if(e.source!==ra&&Ye(e,`skills`)){let e=na(),t=i();tt(H,e,t).then(()=>vt(H,e,t)).catch(()=>void 0)}});var ga=e=>{let t=(0,Di.c)(37),{className:n}=e,{t:r}=ke(),i=ft(_a),a=ft(va),o=ft(ya),s=m(),c;t[0]===i?c=t[1]:(c=[...i].sort(ba),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let p=f,h;t[8]===n?h=t[9]:(h=q(n),t[8]=n,t[9]=h);let g;t[10]===r?g=t[11]:(g=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=g);let _;t[12]===r?_=t[13]:(_=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=_);let v,y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=q(`text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none`,`hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70`,`flex items-center gap-1.5 text-left`),y=(0,$.jsx)(J,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=v,t[15]=y):(v=t[14],y=t[15]);let b;t[16]===p?b=t[17]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(J,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=x):x=t[18];let S;t[19]!==g||t[20]!==_||t[21]!==b?(S=(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":g,title:_,className:v,children:[y,b,x]})}),t[19]=g,t[20]=_,t[21]=b,t[22]=S):S=t[22];let C=d?.id??``,w;t[23]===o?w=t[24]:(w=e=>{e&&o(e)},t[23]=o,t[24]=w);let T;t[25]===l?T=t[26]:(T=l.map(xa),t[25]=l,t[26]=T);let E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,$.jsx)(hn,{align:`start`,className:`w-auto`,children:(0,$.jsx)(kn,{value:C,onValueChange:w,children:T})}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==S||t[32]!==E?(D=(0,$.jsxs)(En,{children:[S,E]}),t[31]=S,t[32]=E,t[33]=D):D=t[33];let O;return t[34]!==D||t[35]!==h?(O=(0,$.jsx)(`div`,{className:h,children:D}),t[34]=D,t[35]=h,t[36]=O):O=t[36],O};function _a(e){return e.projects}function va(e){return e.activeProjectId}function ya(e){return e.setActiveProject}function ba(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function xa(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(ur,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function Sa(e,t){return`opencode:sidebar-group:${e}:${t}`}var Ca=e=>{let t=(0,Di.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=Sa(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(wa),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(J,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=q(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(Z,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(Ta),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`flex w-full items-center gap-1 rounded-md px-2 py-1 text-left`,`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,`hover:bg-[var(--interactive-hover)] transition-colors duration-150`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(J,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function wa(e){return!e}function Ta(e){return!e}var Ea=e=>{if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.permission==`string`&&typeof e.pattern==`string`&&typeof e.action==`string`&&(e.action===`allow`||e.action===`ask`||e.action===`deny`)&&t.push({permission:e.permission,pattern:e.pattern,action:e.action})}return t},Da=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&t.set(`${n.permission}::${n.pattern}`,n);return Array.from(t.values())},Oa=e=>{let t=Da(Ea(e));if(t.length===0)return;let n={};for(let e of t)e.permission&&((n[e.permission]||={})[e.pattern]=e.action);let r={};for(let[e,t]of Object.entries(n)){let n=Object.keys(t);if(n.length===1&&n[0]===`*`){r[e]=t[`*`];continue}r[e]=t}return Object.keys(r).length>0?r:void 0},ka=({onItemSelect:e})=>{let{t}=ke(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=et(he(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=gt();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(Be(e)){K.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{Be(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?K.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):K.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?K.error(t(`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?K.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;let i=e,a=e.model?.providerID&&e.model?.modelID?`${e.model.providerID}/${e.model.modelID}`:null,o=e;g({name:r,scope:i.scope||`user`,description:e.description,model:a,variant:e.variant,temperature:e.temperature,top_p:e.topP,prompt:e.prompt,mode:e.mode,permission:Oa(e.permission),disable:o.disable}),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){K.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){K.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,o=n,s=await _({name:e,description:n.description,model:a,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:Oa(n.permission),disable:o.disable,scope:o.scope});if(s.ok){let r=await v(n.name,o.scope);r.ok?(s.requiresManualRestart||r.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):K.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):K.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else K.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(J,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(J,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(J,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>!Ge(e)),j=A.filter(Be),M=A.filter(e=>!Be(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(Y,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(ga,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(Z,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(Aa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(Ca,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(Aa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(Z,{label:F,children:P.map(t=>(0,$.jsx)(Aa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(Yt,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(Kt,{className:`max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(Jt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(Yt,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(Kt,{children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(Jt,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(un,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},Aa=e=>{let t=(0,Di.c)(52),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=ke(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=pr(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[12]=n.name,t[13]=w);let T;t[14]!==n.mode||t[15]!==l?(T=l(n.mode),t[14]=n.mode,t[15]=l,t[16]=T):T=t[16];let E;t[17]!==n||t[18]!==p.scope||t[19]!==f?(E=(p.scope||Be(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Be(n)?f(`settings.agents.sidebar.badge.system`):p.scope}),t[17]=n,t[18]=p.scope,t[19]=f,t[20]=E):E=t[20];let D;t[21]!==w||t[22]!==T||t[23]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[w,T,E]}),t[21]=w,t[22]=T,t[23]=E,t[24]=D):D=t[24];let O;t[25]===n.description?O=t[26]:(O=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[25]=n.description,t[26]=O);let k;t[27]!==i||t[28]!==D||t[29]!==O?(k=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[D,O]}),t[27]=i,t[28]=D,t[29]=O,t[30]=k):k=t[30];let A;t[31]===d?A=t[32]:(A=e=>{e&&_(!1),d(e)},t[31]=d,t[32]=A);let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[33]=j):j=t[33];let M;t[34]===y?M=t[35]:(M=(0,$.jsx)(hn,{align:`end`,className:`w-fit min-w-20`,children:y(vn)}),t[34]=y,t[35]=M);let N;t[36]!==u||t[37]!==A||t[38]!==M?(N=(0,$.jsxs)(En,{open:u,onOpenChange:A,children:[j,M]}),t[36]=u,t[37]=A,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==k||t[41]!==N?(P=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[k,N]}),t[40]=k,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==P||t[44]!==C?(F=(0,$.jsx)(_i,{render:C,children:P}),t[43]=P,t[44]=C,t[45]=F):F=t[45];let I;t[46]===y?I=t[47]:(I=(0,$.jsx)(vi,{className:`w-fit min-w-20`,children:y(yi)}),t[46]=y,t[47]=I);let L;return t[48]!==g||t[49]!==F||t[50]!==I?(L=(0,$.jsxs)(bi,{open:g,onOpenChange:_,children:[F,I]}),t[48]=g,t[49]=F,t[50]=I,t[51]=L):L=t[51],L},ja=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ma=(e,t)=>{let n=ja(e),r=ja(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},Na=(e,t)=>t?e.globalPermission!==t.globalPermission||!Ma(e.permissionRules,t.permissionRules):!1,Pa=e=>{let t=e.trim();return t===``?null:t},Fa=e=>{let t=e.trim();return t===``?null:t},Ia=e=>e.trim()||void 0,La=e=>e.trim()||null,Ra=({isNewAgent:e,agentName:t,draftScope:n,draftHasExplicitPermission:r,current:i,initial:a,permissionConfig:o})=>{if(e){let e=Na(i,a)||r,s=i.description.trim(),c=Pa(i.model),l=Fa(i.variant),u=Ia(i.prompt);return{name:t,mode:i.mode,...s?{description:s}:{},...c?{model:c}:{},...l?{variant:l}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...i.topP===void 0?{}:{top_p:i.topP},...u?{prompt:u}:{},...e?{permission:o}:{},...n?{scope:n}:{}}}let s={name:t};if(!a)return s;if(i.description!==a.description){let e=i.description.trim();e&&(s.description=e)}return i.mode!==a.mode&&(s.mode=i.mode),i.model!==a.model&&(s.model=Pa(i.model)),i.variant!==a.variant&&(s.variant=Fa(i.variant)??null),i.temperature!==a.temperature&&(s.temperature=i.temperature??null),i.topP!==a.topP&&(s.top_p=i.topP??null),i.prompt!==a.prompt&&(s.prompt=La(i.prompt)),Na(i,a)&&(s.permission=o),s},za=[`*`,`read`,`edit`,`glob`,`grep`,`list`,`bash`,`task`,`skill`,`lsp`,`todoread`,`todowrite`,`webfetch`,`websearch`,`codesearch`,`external_directory`,`doom_loop`,`question`],Ba=e=>e===`allow`||e===`ask`||e===`deny`,Va=(e,t)=>`${e}::${t}`,Ha=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&Ba(n.action)&&t.set(Va(n.permission,n.pattern),{permission:n.permission,pattern:n.pattern,action:n.action});return Array.from(t.values())},Ua=e=>{let t=new Map;for(let n of Ha(e))t.set(Va(n.permission,n.pattern),n);return t},Wa=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ga=(e,t)=>{let n=Wa(Ha(e)),r=Wa(Ha(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},Ka=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,qa=(e,t)=>Ha(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),Ja=e=>{if(Array.isArray(e))return Ha(e);if(Ba(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(Ba(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))Ba(i)&&t.push({permission:n,pattern:e,action:i})}return t},Ya=(e,t)=>{let n=Ha(t),r={};for(let e of n)(r[e.permission]||={})[e.pattern]=e.action;let i={};for(let[e,t]of Object.entries(r))if(e!==`*`){if(Object.keys(t).length===1&&t[`*`]){i[e]=t[`*`];continue}i[e]=t}return Object.keys(i).length===0?e:(e!==`allow`&&(i[`*`]=e),i)},Xa=(e,t)=>{let n=mt(t);if(!n)return[];let r=e.find(e=>e.id===n.providerId)?.models?.find(e=>e.id===n.modelId);return r?.variants?Object.keys(r.variants):[]},Za=()=>{let{t:e}=ke(),t=G(e=>e.providers),{selectedAgentName:n,getAgentByName:r,createAgent:i,updateAgent:a,agentDraft:o,setAgentDraft:s}=et(he(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:c=[]}=gt(),l=n?r(n):null,u=!!(o&&o.name===n&&!l),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(void 0),[T,E]=Q.useState(void 0),[D,O]=Q.useState(``),[k,A]=Q.useState(`allow`),[j,M]=Q.useState([]),[N,P]=Q.useState([]),[F,I]=Q.useState(``),[L,R]=Q.useState(`*`),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),ee=Q.useRef(null),U=ve(e=>e.currentDirectory??null),[te,W]=Q.useState([]),ne=Q.useMemo(()=>Xa(t,y),[y,t]),re=ne.length>0,ie=Q.useMemo(()=>!x||!ne.includes(x)?`__default`:x,[x,ne]),ae=re&&(!x||ne.includes(x)),oe=He(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await ye.listToolIds({directory:U});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));W(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[U]);let se=Q.useMemo(()=>{let e=new Set;for(let t of c){let n=Ha(Ja(t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(oe))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of te)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[c,oe,te]),ce=Q.useMemo(()=>Ua(j),[j]),le=Q.useMemo(()=>Ua(N),[N]),ue=Q.useCallback(e=>le.get(Va(e,`*`))?.action,[le]),de=Q.useCallback(e=>N.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),[N]),fe=Q.useMemo(()=>{let e=new Set;for(let t of za)e.add(t);for(let t of se)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[se]),pe=Q.useCallback(e=>{let t=e===`*`?k:ue(e)??k,n=de(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},[de,ue,k]),me=Q.useCallback(t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),[e]),ge=Q.useCallback(t=>t===`global`?e(`settings.common.scope.global`):me(t),[me,e]),_e=Q.useMemo(()=>{let e=new Set;for(let t of za)e.add(t);for(let t of se)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[se]),be=Q.useCallback((e,t,n)=>{P(r=>{let i=Ua(r);return i.set(Va(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},[]),xe=Q.useCallback((e,t)=>{P(n=>{let r=Ua(n);return r.delete(Va(e,t)),Array.from(r.values())})},[]),Se=Q.useCallback((e,t)=>{let n=ce.get(Va(e,t));if(n){be(e,t,n.action);return}xe(e,t)},[ce,xe,be]),Ce=Q.useCallback((e,t,n)=>{be(e,t,n)},[be]),we=Q.useCallback(e=>{A(e),P(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},[]),Te=Q.useCallback(t=>{let n=F.trim();if(!n){K.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=L.trim()||`*`;if(n===`*`&&r===`*`){we(t),I(``),R(`*`);return}r===`*`&&n!==`*`&&t===k?xe(n,`*`):be(n,r,t),I(``),R(`*`)},[k,F,L,xe,we,e,be]),Ee=Q.useCallback(t=>t===`*`?e(`settings.agents.page.permissions.defaultLabel`):t===`webfetch`?`WebFetch`:t===`websearch`?`WebSearch`:t===`codesearch`?`CodeSearch`:t===`doom_loop`?`Doom Loop`:t===`external_directory`?`External Directory`:t===`todowrite`?`TodoWrite`:t===`todoread`?`TodoRead`:t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),[e]);Q.useEffect(()=>{I(``),R(`*`);let e=e=>{let t=Ha(e),n=Ka(t),r=qa(t,n);return A(n),M(r),P(r),{global:n,rules:r}};if(u&&o){let t=o.name||``,n=o.scope||`user`,r=o.description||``,i=o.mode||`subagent`,a=o.model||``,s=o.variant||``,c=o.temperature??void 0,l=o.top_p??void 0,u=o.prompt||``;f(t),m(n),g(r),v(i),b(a),S(s),w(c),E(l),O(u);let d=e(Ja(o.permission));ee.current={draftName:t,draftScope:n,description:r,mode:i,model:a,variant:s,temperature:c,topP:l,prompt:u,globalPermission:d.global,permissionRules:d.rules};return}if(l&&n===l.name){let t=l.description||``,n=l.mode||`subagent`,r=l.model?.providerID&&l.model?.modelID?`${l.model.providerID}/${l.model.modelID}`:``,i=l.variant||``,a=l.temperature,o=l.topP,s=l.prompt||``;g(t),v(n),b(r),S(i),w(a),E(o),O(s);let c=e(Ja(l.permission));ee.current={draftName:``,draftScope:`user`,description:t,mode:n,model:r,variant:i,temperature:a,topP:o,prompt:s,globalPermission:c.global,permissionRules:c.rules}}},[o,u,l,n]);let De=Q.useMemo(()=>{let e=ee.current;return e?!!(u&&(d!==e.draftName||p!==e.draftScope)||h!==e.description||_!==e.mode||y!==e.model||x!==e.variant||C!==e.temperature||T!==e.topP||D!==e.prompt||k!==e.globalPermission||!Ga(N,e.permissionRules)):!1},[h,d,p,k,u,_,y,N,D,C,T,x]);return n?(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.identityRole`),children:[u&&(0,$.jsxs)(Ir,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(un,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(on,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(nn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(ln,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(rn,{align:`end`,children:[(0,$.jsx)(en,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(en,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Ir,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(xr,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(Ir,{itemId:`agents.mode`,className:`oc-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.modelParameters`),children:[(0,$.jsx)(Ir,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(An,{providerId:mt(y)?.providerId??``,modelId:mt(y)?.modelId??``,onChange:(e,t)=>{b(e&&t?`${e}/${t}`:``),S(``)},className:`oc-settings-inline-value`})}),(0,$.jsx)(Ir,{itemId:`agents.variant`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.variant`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.variantTooltip`)})]})]}),description:e(`settings.agents.page.field.variantHint`),children:ae?(0,$.jsxs)(on,{value:ie,onValueChange:e=>S(e===`__default`?``:e),children:[(0,$.jsx)(nn,{className:`w-fit min-w-[10rem] max-w-full`,children:(0,$.jsx)(ln,{placeholder:e(`settings.agents.page.field.variantPlaceholder`),children:t=>t===`__default`?e(`chat.modelControls.default`):t})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`__default`,children:e(`chat.modelControls.default`)}),ne.map(e=>(0,$.jsx)(en,{value:e,children:e},e))]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(un,{value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.variantPlaceholder`),disabled:!y&&!x,className:`h-7 w-40 max-w-full`}),x&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>S(``),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.common.actions.clear`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsxs)(Ir,{itemId:`agents.temperature`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.temperature`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.temperatureTooltip`)})]})]}),description:e(`settings.agents.page.field.temperatureRange`),children:[(0,$.jsx)(Br,{value:C,fallbackValue:.7,onValueChange:w,onClear:()=>w(void 0),min:0,max:2,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),C!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>w(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTemperatureAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(Ir,{itemId:`agents.top-p`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.topP`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.topPTooltip`)})]})]}),description:e(`settings.agents.page.field.topPRange`),children:[(0,$.jsx)(Br,{value:T,fallbackValue:.9,onValueChange:E,onClear:()=>E(void 0),min:0,max:1,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),T!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>E(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTopPAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),(0,$.jsx)(jr,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(xr,{embedded:!0,value:D,onChange:e=>O(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>B(e=>!e),children:e(z?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:z?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Ir,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(on,{value:k,onValueChange:e=>we(e),children:[(0,$.jsx)(nn,{className:`w-[100px]`,children:(0,$.jsx)(ln,{children:me(k)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(en,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(en,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:fe.filter(e=>e!==`*`).map(t=>{let n=Ee(t),{defaultAction:r,patternRulesCount:i}=pe(t),a=ue(t),o=a??`global`,s=de(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==k);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>Se(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(on,{value:o,onValueChange:e=>{if(e===`global`){xe(t,`*`);return}be(t,`*`,e)},children:[(0,$.jsx)(nn,{className:`w-[90px]`,children:(0,$.jsx)(ln,{children:ge(o)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(en,{value:e,className:`capitalize`,children:me(e)},e))]})]})]}),s.map(t=>{let n=Va(t.permission,t.pattern),r=ce.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i?xe(t.permission,t.pattern):Se(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(on,{value:t.action,onValueChange:e=>Ce(t.permission,t.pattern,e),children:[(0,$.jsx)(nn,{className:`w-[90px]`,children:(0,$.jsx)(ln,{children:me(t.action)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(en,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(en,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2`,children:[(0,$.jsxs)(on,{value:F,onValueChange:I,children:[(0,$.jsx)(nn,{className:`w-full sm:w-[160px]`,children:F?(0,$.jsx)(`span`,{className:`truncate`,children:Ee(F)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(rn,{children:_e.map(e=>(0,$.jsx)(en,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:Ee(e)})})},e))})]}),(0,$.jsx)(un,{value:L,onChange:e=>R(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 flex-1 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Te(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Te(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Te(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsx)($.Fragment,{children:fe.map(t=>{let{defaultAction:n,patternRulesCount:r,patternSummary:i,hasDefaultHint:a}=pe(t),o=Ee(t),s=a?`${n} (env blocked)`:n;return(0,$.jsx)(Ir,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block`,children:t})]}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.globalSummary`,{summary:s})}):(0,$.jsx)(`span`,{className:q(`typography-micro capitalize px-1.5 py-0.5 rounded`,s===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:s===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:s}),r>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.rulesSummary`,{summary:i})})]})},t)})})})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let t=u?d.trim().replace(/\s+/g,`-`):n?.trim();if(!t){K.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&c.some(e=>e.name===t)){K.error(e(`settings.agents.sidebar.toast.agentExists`));return}H(!0);try{let n={description:h,mode:_,model:y,variant:x,temperature:C,topP:T,prompt:D,globalPermission:k,permissionRules:N},r=ee.current,c=r?{description:r.description,mode:r.mode,model:r.model,variant:r.variant,temperature:r.temperature,topP:r.topP,prompt:r.prompt,globalPermission:r.globalPermission,permissionRules:r.permissionRules}:null,l=Ra({isNewAgent:u,agentName:t,draftScope:u?p:void 0,draftHasExplicitPermission:u&&o?.permission!==void 0,current:n,initial:c,permissionConfig:Ya(k,N)}),d;u?(d=await i(l),d.ok&&s(null)):d=await a(t,l),d.ok?d.requiresManualRestart?K.warning(e(`settings.agents.page.toast.savedManualRestart`)):K.success(e(u?`settings.agents.page.toast.created`:`settings.agents.page.toast.updated`)):K.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);K.error(n)}finally{H(!1)}},disabled:V||!De,size:`xs`,className:`!font-normal`,children:e(V?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})},Qa=e=>{let t=(0,Di.c)(23),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c}=e,l=i!==void 0&&i,u=s&&s.length>0,d=l?`bg-interactive-selection`:`hover:bg-interactive-hover`,f;t[0]!==c||t[1]!==d?(f=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,d,c),t[0]=c,t[1]=d,t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==o||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,p]}),t[5]=o,t[6]=p,t[7]=m):m=t[7];let h;t[8]===r?h=t[9]:(h=r&&(0,$.jsx)(`div`,{className:`max-w-full truncate typography-micro leading-tight text-muted-foreground/60`,children:r}),t[8]=r,t[9]=h);let g;t[10]!==a||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`button`,{onClick:a,"data-mobile-press-feedback":`soft`,className:`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[m,h]}),t[10]=a,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==s||t[15]!==u?(_=u&&(0,$.jsxs)(En,{children:[(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsx)(Y,{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:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hn,{align:`end`,className:`w-fit min-w-20`,children:s.map($a)})]}),t[14]=s,t[15]=u,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==f||t[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),t[20]=f,t[21]=v,t[22]=y):y=t[22],y};function $a(e){let t=e.icon;return(0,$.jsxs)(vn,{onClick:t=>{t.stopPropagation(),e.onClick()},className:q(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(J,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var eo=e=>{let t=(0,Di.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=m(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=q(`oc-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},to=`__managed_workspace__`,no=`__current_workspace__`,ro=`默认助理`,io=()=>{let e=G.getState(),t=e.settingsDefaultModel;if(t){let e=mt(t);if(e?.providerId&&e?.modelId)return{providerID:e.providerId,modelID:e.modelId}}if(e.currentProviderId&&e.currentModelId)return{providerID:e.currentProviderId,modelID:e.currentModelId};let n=e.providers;for(let e of n){let t=e.models;if(Array.isArray(t)&&t.length>0){let n=t[0];if(n?.id)return{providerID:e.id,modelID:n.id}}}return null},ao=(e=``)=>{let t=io();return{enabled:!0,name:e,defaultPrompt:``,workspacePath:null,providerID:t?.providerID??``,modelID:t?.modelID??``,agent:null,mode:`continuous`}},oo=e=>({enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,agent:e.agent,mode:e.mode}),so=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,co=e=>{let t=Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[];return Array.from(new Set(t.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)))).sort((e,t)=>e.localeCompare(t))},lo=e=>!!e&&typeof e==`object`&&!Array.isArray(e),uo=e=>{if(!lo(e)||!lo(e.schedule)||!lo(e.execution)||!lo(e.state))return!1;let t=e.schedule.times===void 0||Array.isArray(e.schedule.times)&&e.schedule.times.every(e=>typeof e==`string`),n=e.schedule.weekdays===void 0||Array.isArray(e.schedule.weekdays)&&e.schedule.weekdays.every(e=>typeof e==`number`),r=e.state.lastStatus===void 0||e.state.lastStatus===`idle`||e.state.lastStatus===`running`||e.state.lastStatus===`success`||e.state.lastStatus===`error`;return typeof e.id==`string`&&typeof e.name==`string`&&typeof e.enabled==`boolean`&&(e.schedule.kind===`daily`||e.schedule.kind===`weekly`||e.schedule.kind===`once`||e.schedule.kind===`cron`)&&t&&n&&r&&typeof e.execution.prompt==`string`&&typeof e.execution.providerID==`string`&&typeof e.execution.modelID==`string`},fo=(e,t)=>{let n=co(e).join(`, `)||`—`,r=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:n});if(e.schedule.kind===`weekly`){let i=(e.schedule.weekdays??[]).map(r).join(`, `);return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:i,time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:i,time:n})}if(e.schedule.kind===`once`){let n=e.schedule.date?.trim()||t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),r=e.schedule.time?.trim()||`—`;return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:n,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:n,time:r})}return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron??``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron??``})},po={paused:{icon:`pause`,className:`text-muted-foreground`},idle:{icon:`pulse`,className:`text-muted-foreground`},running:{icon:`loader-4`,className:`text-[var(--status-warning)]`},success:{icon:`checkbox-circle`,className:`text-[var(--status-success)]`},error:{icon:`error-warning`,className:`text-[var(--status-error)]`}},mo=e=>`${e.projectId}:${e.task.id}`,ho=e=>{let t=(0,Di.c)(31),{assistantID:n}=e,{t:r}=ke(),i=It(n),a=i.isError,o=Rt(n,a),s=jt(a),c=new Set;for(let e of o.data?.messages??[])for(let t of e.cards)t.cardType===`schedule`&&c.add(`${t.projectID}:${t.taskID}`);let l=(i.data?.tasks??[]).flatMap(yo),u;t[0]===i.data?.tasks?u=t[1]:(u=i.data?.tasks.some(bo),t[0]=i.data?.tasks,t[1]=u);let d=!!u,f=(s.data?.tasks??[]).filter(e=>c.has(mo(e))),p=[...i.data?l:a?f:[]].sort(xo),m=(s.data?.failedProjectIds??[]).some(e=>Array.from(c).some(t=>t.startsWith(`${e}:`))),h=i.isPending||a&&(o.isPending||s.isPending),g=i.isError||o.isError||s.isError||m||d,_=Oe(So),v;t[2]!==o||t[3]!==a||t[4]!==s||t[5]!==i?(v=()=>{i.refetch(),a&&(o.refetch(),s.refetch())},t[2]=o,t[3]=a,t[4]=s,t[5]=i,t[6]=v):v=t[6];let y=Oe(v),b=Z,x;t[7]===r?x=t[8]:(x=r(`assistants.settings.scheduledTasks.title`),t[7]=r,t[8]=x);let S;t[9]===r?S=t[10]:(S=r(`assistants.settings.scheduledTasks.title`),t[9]=r,t[10]=S);let C=h&&p.length===0?(0,$.jsx)(Ir,{label:r(`common.loading`),children:(0,$.jsx)(J,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`})}):null,w;t[11]!==_||t[12]!==r?(w=e=>{let t=e.task.enabled?e.task.state?.lastStatus??`idle`:`paused`,n=po[t],i=r(t===`paused`?`sessions.scheduledTasks.dialog.taskToggle.paused`:t===`running`?`sessions.scheduledTasks.dialog.status.running`:t===`success`?`sessions.scheduledTasks.dialog.status.success`:t===`error`?`sessions.scheduledTasks.dialog.status.error`:`sessions.scheduledTasks.dialog.status.idle`);return(0,$.jsxs)(Ir,{className:`group relative cursor-pointer transition-colors hover:bg-interactive-hover`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(J,{name:`calendar`,className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium text-foreground`,children:e.task.name}),(0,$.jsx)(`span`,{className:`mt-0.5 block typography-micro truncate text-muted-foreground`,children:fo(e.task,r)})]})]}),controlClassName:`min-w-fit`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-micro ${n.className}`,children:[(0,$.jsx)(J,{name:n.icon,className:`size-3.5 ${t===`running`?`animate-spin`:``}`}),i]}),(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4`})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute inset-0 z-10 h-auto w-auto rounded-none bg-transparent p-0 hover:bg-transparent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onClick:_,"aria-label":r(`assistants.settings.scheduledTasks.open`,{name:e.task.name}),children:(0,$.jsx)(`span`,{className:`sr-only`,children:r(`assistants.settings.scheduledTasks.open`,{name:e.task.name})})})]},mo(e))},t[11]=_,t[12]=r,t[13]=w):w=t[13];let T=p.map(w),E;t[14]!==g||t[15]!==y||t[16]!==r?(E=g?(0,$.jsx)(Ir,{label:r(`assistants.settings.scheduledTasks.loadError`),children:(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:y,children:r(`assistants.actions.retry`)})}):null,t[14]=g,t[15]=y,t[16]=r,t[17]=E):E=t[17];let D;t[18]!==g||t[19]!==h||t[20]!==r||t[21]!==p?(D=!h&&!g&&p.length===0?(0,$.jsx)(Ir,{label:r(`assistants.settings.scheduledTasks.empty`),children:(0,$.jsx)(J,{name:`calendar`,className:`size-4 text-muted-foreground`})}):null,t[18]=g,t[19]=h,t[20]=r,t[21]=p,t[22]=D):D=t[22];let O;return t[23]!==b||t[24]!==x||t[25]!==S||t[26]!==C||t[27]!==T||t[28]!==E||t[29]!==D?(O=(0,$.jsxs)(b,{label:x,ariaLabel:S,children:[C,T,E,D]}),t[23]=b,t[24]=x,t[25]=S,t[26]=C,t[27]=T,t[28]=E,t[29]=D,t[30]=O):O=t[30],O},go=e=>{let t=(0,Di.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(J,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},_o=({onItemSelect:e})=>{let{t}=ke(),n=Ft(),r=Bt(),i=n.data,a=Ut(e=>e.settingsSelectedAssistantID),o=Ut(e=>e.selectSettingsAssistant),s=Ut(e=>e.requestCreate),[c,l]=Q.useState(!1);Q.useEffect(()=>{!e&&a===null&&i?.assistants[0]&&o(i.assistants[0].id)},[e,o,a,i?.assistants]),Q.useEffect(()=>{n.isSuccess&&a&&a!==`new`&&!i?.assistants.some(e=>e.id===a)&&o(e?null:i?.assistants[0]?.id??null)},[e,o,a,i?.assistants,n.isSuccess]);let u=Oe(()=>{s(),e?.()}),d=Oe(async e=>{if(i)try{if(await Nt(e,i.revision),e&&i.assistants.length===0){let e=io();if(e){let t=await Vt({enabled:!0,name:ro,defaultPrompt:``,workspacePath:null,providerID:e.providerID,modelID:e.modelID,agent:null,mode:`continuous`});o(t.id)}}}catch{Ee.error(t(`assistants.settings.toast.toggleFailed`))}});return r.isSuccess&&!r.data.supported?null:(0,$.jsx)(eo,{variant:`background`,header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{description:(0,$.jsxs)($.Fragment,{children:[t(`assistants.settings.description`),(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:e=>{e.preventDefault(),l(!0)},children:t(`assistants.settings.descriptionLearnMore`)})]}),children:(0,$.jsx)(Hr,{itemId:`assistants.instance-enabled`,checked:i?.enabled??!1,onChange:d,label:t(`assistants.settings.instanceEnabled`),ariaLabel:t(`assistants.settings.instanceEnabled`)})}),(0,$.jsx)(Bi,{open:c,onOpenChange:l})]}),children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`assistants.settings.listTitle`)}),(0,$.jsx)(Y,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:u,"aria-label":t(`assistants.settings.create`),children:(0,$.jsx)(J,{name:`add`,className:`size-4`})})]}),children:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):i?.assistants.length?i.assistants.map(t=>{let n=Me(t.name);return(0,$.jsx)(Qa,{title:n.displayName,selected:a===t.id,onSelect:()=>{o(t.id),e?.()},icon:(0,$.jsx)(Zt,{name:t.id,emoji:n.avatarEmoji,size:24,label:n.displayName||t.name,shape:`circle`})},t.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row text-muted-foreground`,children:t(`assistants.settings.empty`)})})})},vo=({onItemDeleted:e})=>{let{t}=ke(),n=Ft(),r=Bt(),i=n.data,a=ft(e=>e.projects),o=Ut(e=>e.settingsSelectedAssistantID),s=Ut(e=>e.selectSettingsAssistant),c=Ut(e=>e.defaultShareAssistant),l=Ut(e=>e.setDefaultShareAssistant),u=Ut(e=>e.createRequestRevision),d=Ut(e=>e.requestCreate),[f,p]=Q.useState(ao),[m,h]=Q.useState(!1),g=Q.useRef(0),_=i?.assistants.find(e=>e.id===o)??null,v=_?Me(_.name):null,y=Me(f.name),b=f.workspacePath??_?.managedWorkspacePath??null,x=Ot(b,{enabled:!0}).data??[];Q.useEffect(()=>{_&&p(oo(_))},[_]),Q.useEffect(()=>{n.isSuccess&&o&&o!==`new`&&!_&&s(null)},[s,_,o,n.isSuccess]),Q.useEffect(()=>{o!==`new`||u<=g.current||(g.current=u,p(ao(i?.assistants.length?``:ro)),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[u,o,i?.assistants.length]),Q.useEffect(()=>{n.isSuccess&&r.data?.serverInstanceID&&c?.serverInstanceID===r.data.serverInstanceID&&!i?.assistants.some(e=>e.id===c.assistantID)&&l(null)},[r.data,c,l,i?.assistants,n.isSuccess]),Q.useEffect(()=>{n.isSuccess&&Ne()},[i?.revision,n.isSuccess]);let S=(e,t)=>{p(n=>({...n,[e]:t}))},C=Oe(()=>d()),w=Oe(async()=>{if(!f.name.trim()||!f.providerID||!f.modelID){Ee.error(t(`assistants.settings.validation.required`));return}h(!0);try{let e=_?await Pt(_,f):await Vt(f);s(e.id),Ee.success(t(`assistants.settings.toast.saved`))}catch{Ee.error(t(`assistants.settings.toast.saveFailed`))}finally{h(!1)}}),T=Oe(async()=>{if(!(!_||!window.confirm(t(`assistants.settings.deleteConfirm`,{name:_.name})))){h(!0);try{if(await Lt(_),c?.assistantID===_.id){let e=await zt();e.serverInstanceID&&c.serverInstanceID===e.serverInstanceID&&l(null)}s(null),e?.(),Ee.success(t(`assistants.settings.toast.deleted`))}catch{Ee.error(t(`assistants.settings.toast.deleteFailed`))}finally{h(!1)}}}),E=Oe(async(e,n)=>{if(!n){l(null),Pe();return}try{let t=await zt();if(!t.supported||!t.serverInstanceID)return;l({serverInstanceID:t.serverInstanceID,assistantID:e}),await Pe()}catch{Ee.error(t(`assistants.settings.toast.toggleFailed`))}}),D=f.workspacePath===null?null:a.find(e=>e.path===f.workspacePath)??null,O=f.workspacePath!==null&&!D?f.workspacePath:null,k=f.workspacePath===null?to:D?D.id:no,A=f.workspacePath===null?(0,$.jsx)(go,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):D?(0,$.jsx)(go,{name:so(D),path:D.path}):(0,$.jsx)(go,{name:t(`assistants.settings.workspaceCurrentPath`),path:O??``,icon:`history`});return r.isSuccess&&!r.data.supported?null:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):n.isError&&!i?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(J,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:t(`assistants.state.unavailable`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void n.refetch(),children:t(`assistants.actions.retry`)})]}):(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n.isError&&i?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:t(`assistants.state.staleSnapshot`)}):null,o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,$.jsx)(Zt,{name:_?.id??`new`,emoji:y.avatarEmoji,size:38,label:y.displayName||f.name||t(`assistants.settings.create`),shape:`circle`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:_?v?.displayName:t(`assistants.settings.create`)}),f.providerID&&f.modelID?(0,$.jsx)(`p`,{className:`mt-0.5 typography-micro leading-none text-muted-foreground/70`,children:`${f.providerID}/${f.modelID}`}):null]}),_?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:T,disabled:m,className:`text-[var(--status-error)]`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`size-4`}),t(`assistants.settings.delete`)]}):null]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Ir,{itemId:`assistants.name`,label:t(`assistants.settings.name`),children:(0,$.jsx)(un,{id:`assistant-name`,value:f.name,onChange:e=>S(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Ir,{label:t(`assistants.settings.enabled`),children:(0,$.jsx)($t,{checked:f.enabled,onChange:e=>S(`enabled`,e),ariaLabel:t(`assistants.settings.enabled`)})}),_?(0,$.jsx)(Ir,{itemId:`assistants.default-share`,label:t(`assistants.settings.defaultShare`),children:(0,$.jsx)($t,{checked:c?.assistantID===_.id&&c.serverInstanceID===r.data?.serverInstanceID,onChange:e=>void E(_.id,e),ariaLabel:t(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(jr,{itemId:`assistants.prompt`,label:t(`assistants.settings.defaultPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(xr,{embedded:!0,id:`assistant-prompt`,value:f.defaultPrompt,onChange:e=>S(`defaultPrompt`,e.target.value),placeholder:t(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsx)(Z,{label:t(`assistants.settings.runtime`),children:(0,$.jsx)(Ir,{itemId:`assistants.model`,label:t(`assistants.settings.model`),children:(0,$.jsx)(An,{providerId:f.providerID,modelId:f.modelID,providers:x,onChange:(e,t)=>p(n=>({...n,providerID:e,modelID:t})),className:`oc-settings-inline-value`})})}),(0,$.jsx)(jr,{itemId:`assistants.workspace`,label:t(`assistants.settings.workspace`),description:t(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(on,{value:k,onValueChange:e=>{if(e===to){S(`workspacePath`,null);return}let t=a.find(t=>t.id===e);t&&S(`workspacePath`,t.path)},children:[(0,$.jsx)(nn,{title:f.workspacePath??t(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(ln,{children:A})}),(0,$.jsxs)(rn,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(en,{value:to,children:(0,$.jsx)(go,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),a.map(e=>(0,$.jsx)(en,{value:e.id,children:(0,$.jsx)(go,{name:so(e),path:e.path})},e.id)),O?(0,$.jsx)(en,{value:no,disabled:!0,children:(0,$.jsx)(go,{name:t(`assistants.settings.workspaceCurrentPath`),path:O,icon:`history`})}):null]})]})}),_?(0,$.jsx)(ho,{assistantID:_.id}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(Y,{onClick:w,disabled:m,children:[m?(0,$.jsx)(J,{name:`loader-4`,className:`size-4 animate-spin`}):null,t(`assistants.settings.save`)]})})]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)(Zt,{name:`assistants-empty`,size:44,shape:`circle`}),(0,$.jsx)(`p`,{className:`typography-ui`,children:t(`assistants.settings.empty`)}),(0,$.jsxs)(Y,{"data-settings-item":`assistants.create`,size:`sm`,onClick:C,children:[(0,$.jsx)(J,{name:`add`,className:`size-4`}),t(`assistants.settings.create`)]})]})]})})};function yo(e){return uo(e.task)?[{projectId:e.projectID,task:e.task}]:[]}function bo(e){return!uo(e.task)}function xo(e,t){return e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1}function So(){u.getState().setActiveMainTab(`schedule`),u.getState().setScheduledTasksDialogOpen(!0)}var Co=`~/.config/opencode/AGENTS.md`,wo=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},To=e=>e.length>0&&!e.endsWith(`
|
|
2
|
+
`)?`${e}\n`:e,Eo={prompt:``,responseStyleEnabled:!1,responseStylePreset:`concise`,responseStyleCustomInstructions:``},Do=(e,t)=>e===`custom`?t:qe(e),Oo=e=>e===`custom`?`custom`:ht(e)?e:`concise`,ko={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`},Ao=async(e,t)=>{let n=await L(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(await wo(n,t));return n.json().catch(()=>null)},jo=()=>{let{t:e}=ke(),t=Q.useSyncExternalStore(n,i,i),[r,a]=Q.useState(``),[o,s]=Q.useState(Eo.responseStyleEnabled),[c,l]=Q.useState(Eo.responseStylePreset),[u,d]=Q.useState(Eo.responseStyleCustomInstructions),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(``),b=Q.useRef(null),x=Q.useRef(null),S=Q.useRef(0),C=Q.useRef(Promise.resolve());Q.useEffect(()=>{let e=!0;return h(!1),b.current=null,x.current=null,S.current+=1,F(t).then(n=>{if(!e||t!==i())return;let r={enabled:n.responseStyleEnabled===!0,preset:Oo(n.responseStylePreset),custom:typeof n.responseStyleCustomInstructions==`string`?n.responseStyleCustomInstructions:``};s(r.enabled),l(r.preset),d(r.custom),Ie({enabled:r.enabled,preset:r.preset,customInstructions:r.custom},t),b.current=r,x.current=r,h(!0)}).catch(t=>{e&&t?.name!==`AbortError`&&console.warn(`Failed to load behavior settings:`,t)}),()=>{e=!1,S.current+=1}},[t]),Q.useEffect(()=>{let e=new AbortController,n=!0;return p(!1),_(!1),(async()=>{try{let r=await L(`/api/behavior/agents-md`,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!r.ok)throw Error(`Behavior prompt request failed (${r.status})`);let o=await r.json().catch(()=>null);if(typeof o?.content!=`string`)throw Error(`Invalid behavior prompt response`);if(!n||t!==i())return;a(o.content),y(o.content),p(!0)}catch(e){n&&e?.name!==`AbortError`&&console.warn(`Failed to load behavior prompt:`,e)}})(),()=>{n=!1,e.abort()}},[t]),Q.useEffect(()=>{if(!m)return;let n={enabled:o,preset:c,custom:u},r=x.current;if(r&&r.enabled===n.enabled&&r.preset===n.preset&&r.custom===n.custom)return;x.current=n;let a=S.current+1;S.current=a;let f=setTimeout(()=>{let r=async()=>{if(t===i())try{let r=await Ao({responseStyleEnabled:n.enabled,responseStylePreset:n.preset,responseStyleCustomInstructions:n.custom},e(`settings.behavior.page.toast.saveFailed`));if(t!==i())return;let o=M(r),c={enabled:o.responseStyleEnabled??n.enabled,preset:o.responseStylePreset??n.preset,custom:o.responseStyleCustomInstructions??n.custom};if(Ie({enabled:c.enabled,preset:c.preset,customInstructions:c.custom},t),E({responseStyleEnabled:c.enabled,responseStylePreset:c.preset,responseStyleCustomInstructions:c.custom},t),b.current=c,a!==S.current)return;x.current=c,s(c.enabled),l(c.preset),d(c.custom)}catch(n){if(t===i()&&a===S.current){let t=b.current;x.current=t,t&&(s(t.enabled),l(t.preset),d(t.custom));let r=n instanceof Error?n.message:e(`settings.behavior.page.toast.saveFailed`);K.error(r)}}};C.current=C.current.then(r,r)},400);return()=>clearTimeout(f)},[o,c,u,m,e,t]);let w=Do(c,u),T=r!==v;return(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.behavior.page.title`)})}),(0,$.jsx)(Z,{itemId:`behavior.system-prompt`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.systemPrompt`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:e(`settings.behavior.page.warning.title`)}),(0,$.jsx)(`p`,{children:e(`settings.behavior.page.warning.description`,{path:Co})})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(xr,{embedded:!0,value:r,onChange:e=>a(e.target.value),placeholder:e(`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`}),(0,$.jsx)(Y,{onClick:async()=>{let n=t;if(n===i()){_(!0);try{let t=To(r),o=await L(`/api/behavior/agents-md`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:t})});if(!o.ok)throw Error(await wo(o,e(`settings.behavior.page.toast.saveFailed`)));if(n!==i()||(await Ao({globalBehaviorPrompt:t},e(`settings.behavior.page.toast.saveFailed`)),n!==i()))return;a(t),y(t),K.success(e(`settings.behavior.page.toast.saved`))}catch(t){if(n!==i())return;console.error(`Failed to save behavior:`,t);let r=t instanceof Error?t.message:e(`settings.behavior.page.toast.saveFailed`);K.error(r)}finally{n===i()&&_(!1)}}},disabled:g||!T||!f,size:`xs`,className:`!font-normal`,children:e(g?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})]})}),(0,$.jsxs)(Z,{itemId:`behavior.response-style`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.responseStyle`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.behavior.page.responseStyle.tooltip`)})]})]}),children:[(0,$.jsxs)(Ir,{label:e(`settings.behavior.page.responseStyle.enable`),children:[(0,$.jsx)($t,{checked:o,onChange:s,disabled:!m,ariaLabel:e(`settings.behavior.page.responseStyle.enableAria`)}),(0,$.jsxs)(on,{value:c,onValueChange:e=>l(e),disabled:!m||!o,children:[(0,$.jsx)(nn,{className:`w-full sm:w-56`,children:(0,$.jsx)(ln,{children:t=>t===`custom`?e(`settings.behavior.page.responseStyle.option.custom`):ht(t)?e(ko[t]):null})}),(0,$.jsxs)(rn,{children:[ze.map(t=>(0,$.jsx)(en,{value:t,children:e(ko[t])},t)),(0,$.jsx)(en,{value:`custom`,children:e(`settings.behavior.page.responseStyle.option.custom`)})]})]})]}),(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(xr,{embedded:!0,value:w,onChange:e=>d(e.target.value),placeholder:e(`settings.behavior.page.responseStyle.customPlaceholder`),rows:5,disabled:!m||!o||c!==`custom`,outerClassName:`min-h-[120px]`,className:`w-full font-mono typography-meta bg-transparent`})})]})]})})},Mo=e=>{let t=(0,Di.c)(158),{onItemSelect:n}=e,{t:r}=ke(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),{selectedCommandName:g,setSelectedCommand:_,setCommandDraft:v,createCommand:y,deleteCommand:b}=Ki(he(Po)),x=_t(),S;t[0]===x.data?S=t[1]:(S=x.data??[],t[0]=x.data,t[1]=S);let C=S,w=Fe(),T;t[2]===w.data?T=t[3]:(T=w.data??[],t[2]=w.data,t[3]=T);let E=T,{refetch:D}=w,O,k;t[4]===D?(O=t[5],k=t[6]):(O=()=>{D()},k=[D],t[4]=D,t[5]=O,t[6]=k),Q.useEffect(O,k);let A;t[7]===E?A=t[8]:(A=new Set(E.map(Fo)),t[7]=E,t[8]=A);let j=A,M;if(t[9]!==C||t[10]!==j){let e;t[12]===j?e=t[13]:(e=e=>!j.has(e.name),t[12]=j,t[13]=e),M=C.filter(e),t[9]=C,t[10]=j,t[11]=M}else M=t[11];let N=M,P,F;t[14]!==g||t[15]!==_||t[16]!==j?(P=()=>{g&&j.has(g)&&_(null)},F=[g,_,j],t[14]=g,t[15]=_,t[16]=j,t[17]=P,t[18]=F):(P=t[17],F=t[18]),Q.useEffect(P,F);let I;t[19]!==C||t[20]!==n||t[21]!==v||t[22]!==_?(I=()=>{let e=`new-command`,t=1;for(;C.some(t=>t.name===e);)e=`new-command-${t}`,t++;v({name:e,scope:`user`}),_(e),n?.()},t[19]=C,t[20]=n,t[21]=v,t[22]=_,t[23]=I):I=t[23];let L=I,R;t[24]===r?R=t[25]:(R=async e=>{if(Wi(e)){K.error(r(`settings.commands.sidebar.toast.builtInCannotDelete`));return}l(e),d(`delete`)},t[24]=r,t[25]=R);let z=R,B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=async e=>{Wi(e)&&(l(e),d(`reset`))},t[26]=B):B=t[26];let V=B,H;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{l(null),d(null)},t[27]=H):H=t[27];let ee=H,U;t[28]!==c||t[29]!==u||t[30]!==b||t[31]!==r?(U=async()=>{!c||!u||(p(!0),await b(c.name)?(u===`delete`?K.success(r(`settings.commands.sidebar.toast.commandDeleted`,{name:c.name})):K.success(r(`settings.commands.sidebar.toast.commandReset`,{name:c.name})),ee()):u===`delete`?K.error(r(`settings.commands.sidebar.toast.deleteFailed`)):K.error(r(`settings.commands.sidebar.toast.resetFailed`)),p(!1))},t[28]=c,t[29]=u,t[30]=b,t[31]=r,t[32]=U):U=t[32];let te=U,W;t[33]!==C||t[34]!==v||t[35]!==_?(W=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;C.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;v({name:r,scope:e.scope||`user`,description:e.description,template:e.template,agent:e.agent,model:e.model}),_(r)},t[33]=C,t[34]=v,t[35]=_,t[36]=W):W=t[36];let ne=W,re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>{s(e.name),a(e)},t[37]=re):re=t[37];let ie=re,ae;t[38]!==C||t[39]!==y||t[40]!==b||t[41]!==i||t[42]!==o||t[43]!==_||t[44]!==r?(ae=async()=>{if(!i)return;let e=o.trim().replace(/\s+/g,`-`);if(!e){K.error(r(`settings.commands.sidebar.toast.commandNameRequired`));return}if(e===i.name){a(null);return}if(C.some(t=>t.name===e)){K.error(r(`settings.commands.sidebar.toast.commandExists`));return}await y({name:e,description:i.description,template:i.template,agent:i.agent,model:i.model})?await b(i.name)?(K.success(`Command renamed to "${e}"`),_(e)):K.error(r(`settings.commands.sidebar.toast.removeOldAfterRenameFailed`)):K.error(r(`settings.commands.sidebar.toast.renameFailed`)),a(null)},t[38]=C,t[39]=y,t[40]=b,t[41]=i,t[42]=o,t[43]=_,t[44]=r,t[45]=ae):ae=t[45];let oe=ae,se,ce,le;if(t[46]!==N||t[47]!==L||t[48]!==z||t[49]!==ne||t[50]!==n||t[51]!==m||t[52]!==g||t[53]!==_||t[54]!==r){let e=N.filter(Wi),i=N.filter(Io),a;t[58]===r?a=t[59]:(a=r(`settings.commands.sidebar.section.custom`),t[58]=r,t[59]=a);let o;t[60]===a?o=t[61]:(o=(0,$.jsx)(`span`,{children:a}),t[60]=a,t[61]=o);let s;t[62]===r?s=t[63]:(s=r(`settings.commands.page.title.new`),t[62]=r,t[63]=s);let c;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[64]=c):c=t[64];let l;t[65]!==L||t[66]!==s?(l=(0,$.jsx)(Y,{"data-settings-item":`commands.create`,size:`icon`,variant:`ghost`,onClick:L,"aria-label":s,children:c}),t[65]=L,t[66]=s,t[67]=l):l=t[67];let u;t[68]!==o||t[69]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[o,l]}),t[68]=o,t[69]=l,t[70]=u):u=t[70];let d=u;se=`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(ga,{})})}),t[71]=ce):ce=t[71],le=(0,$.jsx)($.Fragment,{children:N.length===0?(0,$.jsx)(Z,{label:d,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`terminal-box`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.commands.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.commands.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[e.length>0&&(0,$.jsx)(Z,{label:r(`settings.commands.sidebar.section.builtIn`),children:[...e].sort(Lo).map(e=>(0,$.jsx)(No,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onReset:()=>V(e),onDuplicate:()=>ne(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}),i.length>0?(0,$.jsx)(Z,{label:d,children:[...i].sort(Ro).map(e=>(0,$.jsx)(No,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onRename:()=>ie(e),onDelete:()=>z(e),onDuplicate:()=>ne(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}):(0,$.jsx)(Z,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[46]=N,t[47]=L,t[48]=z,t[49]=ne,t[50]=n,t[51]=m,t[52]=g,t[53]=_,t[54]=r,t[55]=se,t[56]=ce,t[57]=le}else se=t[55],ce=t[56],le=t[57];let ue=c!==null&&u!==null,de;t[72]===f?de=t[73]:(de=e=>{!e&&!f&&ee()},t[72]=f,t[73]=de);let fe;t[74]!==u||t[75]!==r?(fe=r(u===`delete`?`settings.commands.sidebar.dialog.deleteTitle`:`settings.commands.sidebar.dialog.resetTitle`),t[74]=u,t[75]=r,t[76]=fe):fe=t[76];let pe;t[77]===fe?pe=t[78]:(pe=(0,$.jsx)(qt,{children:fe}),t[77]=fe,t[78]=pe);let me;t[79]!==c?.name||t[80]!==u||t[81]!==r?(me=r(u===`delete`?`settings.commands.sidebar.dialog.deleteDescription`:`settings.commands.sidebar.dialog.resetDescription`,{name:c?.name??``}),t[79]=c?.name,t[80]=u,t[81]=r,t[82]=me):me=t[82];let ge;t[83]===me?ge=t[84]:(ge=(0,$.jsx)(Jt,{children:me}),t[83]=me,t[84]=ge);let _e;t[85]!==pe||t[86]!==ge?(_e=(0,$.jsxs)(Wt,{children:[pe,ge]}),t[85]=pe,t[86]=ge,t[87]=_e):_e=t[87];let ve;t[88]===r?ve=t[89]:(ve=r(`settings.common.actions.cancel`),t[88]=r,t[89]=ve);let ye;t[90]!==f||t[91]!==ve?(ye=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:ee,disabled:f,children:ve}),t[90]=f,t[91]=ve,t[92]=ye):ye=t[92];let be;t[93]!==u||t[94]!==r?(be=r(u===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`),t[93]=u,t[94]=r,t[95]=be):be=t[95];let xe;t[96]!==te||t[97]!==f||t[98]!==be?(xe=(0,$.jsx)(Y,{size:`sm`,onClick:te,disabled:f,children:be}),t[96]=te,t[97]=f,t[98]=be,t[99]=xe):xe=t[99];let Se;t[100]!==ye||t[101]!==xe?(Se=(0,$.jsxs)(Gt,{children:[ye,xe]}),t[100]=ye,t[101]=xe,t[102]=Se):Se=t[102];let Ce;t[103]!==_e||t[104]!==Se?(Ce=(0,$.jsxs)(Kt,{className:`max-w-md`,children:[_e,Se]}),t[103]=_e,t[104]=Se,t[105]=Ce):Ce=t[105];let we;t[106]!==ue||t[107]!==de||t[108]!==Ce?(we=(0,$.jsx)(Yt,{open:ue,onOpenChange:de,children:Ce}),t[106]=ue,t[107]=de,t[108]=Ce,t[109]=we):we=t[109];let Te=i!==null,Ee;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>!e&&a(null),t[110]=Ee):Ee=t[110];let De;t[111]===r?De=t[112]:(De=r(`settings.commands.sidebar.renameDialog.title`),t[111]=r,t[112]=De);let Oe;t[113]===De?Oe=t[114]:(Oe=(0,$.jsx)(qt,{children:De}),t[113]=De,t[114]=Oe);let Ae=i?.name??``,je;t[115]!==r||t[116]!==Ae?(je=r(`settings.commands.sidebar.renameDialog.description`,{name:Ae}),t[115]=r,t[116]=Ae,t[117]=je):je=t[117];let Me;t[118]===je?Me=t[119]:(Me=(0,$.jsx)(Jt,{children:je}),t[118]=je,t[119]=Me);let Ne;t[120]!==Oe||t[121]!==Me?(Ne=(0,$.jsxs)(Wt,{children:[Oe,Me]}),t[120]=Oe,t[121]=Me,t[122]=Ne):Ne=t[122];let Pe;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=e=>s(e.target.value),t[123]=Pe):Pe=t[123];let Ie;t[124]===r?Ie=t[125]:(Ie=r(`settings.commands.sidebar.renameDialog.placeholder`),t[124]=r,t[125]=Ie);let Le;t[126]===oe?Le=t[127]:(Le=e=>{e.key===`Enter`&&oe()},t[126]=oe,t[127]=Le);let Re;t[128]!==o||t[129]!==Ie||t[130]!==Le?(Re=(0,$.jsx)(un,{value:o,onChange:Pe,placeholder:Ie,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Le}),t[128]=o,t[129]=Ie,t[130]=Le,t[131]=Re):Re=t[131];let ze;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(ze=()=>a(null),t[132]=ze):ze=t[132];let Be;t[133]===r?Be=t[134]:(Be=r(`settings.common.actions.cancel`),t[133]=r,t[134]=Be);let Ve;t[135]===Be?Ve=t[136]:(Ve=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:ze,children:Be}),t[135]=Be,t[136]=Ve);let He;t[137]===r?He=t[138]:(He=r(`settings.common.actions.rename`),t[137]=r,t[138]=He);let Ue;t[139]!==oe||t[140]!==He?(Ue=(0,$.jsx)(Y,{size:`sm`,onClick:oe,children:He}),t[139]=oe,t[140]=He,t[141]=Ue):Ue=t[141];let We;t[142]!==Ve||t[143]!==Ue?(We=(0,$.jsxs)(Gt,{children:[Ve,Ue]}),t[142]=Ve,t[143]=Ue,t[144]=We):We=t[144];let Ge;t[145]!==Ne||t[146]!==Re||t[147]!==We?(Ge=(0,$.jsxs)(Kt,{children:[Ne,Re,We]}),t[145]=Ne,t[146]=Re,t[147]=We,t[148]=Ge):Ge=t[148];let Ke;t[149]!==Te||t[150]!==Ge?(Ke=(0,$.jsx)(Yt,{open:Te,onOpenChange:Ee,children:Ge}),t[149]=Te,t[150]=Ge,t[151]=Ke):Ke=t[151];let qe;return t[152]!==se||t[153]!==ce||t[154]!==le||t[155]!==we||t[156]!==Ke?(qe=(0,$.jsxs)(`div`,{className:se,children:[ce,le,we,Ke]}),t[152]=se,t[153]=ce,t[154]=le,t[155]=we,t[156]=Ke,t[157]=qe):qe=t[157],qe},No=e=>{let t=(0,Di.c)(47),{command:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,isMenuOpen:l,onMenuOpenChange:u}=e,{t:d}=ke(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=pr(),t[0]=f):f=t[0];let p=f,[m,h]=Q.useState(!1),g;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==d?(g=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=d,t[6]=g):g=t[6];let _=g,v=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,y;t[7]===v?y=t[8]:(y=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,v),t[7]=v,t[8]=y);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=p?void 0:e=>{e.preventDefault(),h(!0)},t[9]=b):b=t[9];let x;t[10]===y?x=t[11]:(x=(0,$.jsx)(`div`,{className:y,onContextMenu:b}),t[10]=y,t[11]=x);let S;t[12]===n.name?S=t[13]:(S=(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`/`,n.name]}),t[12]=n.name,t[13]=S);let C;t[14]!==n||t[15]!==d?(C=(n.scope||Wi(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Wi(n)?d(`settings.agents.sidebar.badge.system`):n.scope}),t[14]=n,t[15]=d,t[16]=C):C=t[16];let w;t[17]!==S||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.description?T=t[21]:(T=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[20]=n.description,t[21]=T);let E;t[22]!==i||t[23]!==T||t[24]!==w?(E=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[w,T]}),t[22]=i,t[23]=T,t[24]=w,t[25]=E):E=t[25];let D;t[26]===u?D=t[27]:(D=e=>{e&&h(!1),u(e)},t[26]=u,t[27]=D);let O;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[28]=O):O=t[28];let k;t[29]===_?k=t[30]:(k=(0,$.jsx)(hn,{align:`end`,className:`w-fit min-w-20`,children:_(vn)}),t[29]=_,t[30]=k);let A;t[31]!==l||t[32]!==D||t[33]!==k?(A=(0,$.jsxs)(En,{open:l,onOpenChange:D,children:[O,k]}),t[31]=l,t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==E||t[36]!==A?(j=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[E,A]}),t[35]=E,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==j||t[39]!==x?(M=(0,$.jsx)(_i,{render:x,children:j}),t[38]=j,t[39]=x,t[40]=M):M=t[40];let N;t[41]===_?N=t[42]:(N=(0,$.jsx)(vi,{className:`w-fit min-w-20`,children:_(yi)}),t[41]=_,t[42]=N);let P;return t[43]!==m||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(bi,{open:m,onOpenChange:h,children:[M,N]}),t[43]=m,t[44]=M,t[45]=N,t[46]=P):P=t[46],P};function Po(e){return{selectedCommandName:e.selectedCommandName,setSelectedCommand:e.setSelectedCommand,setCommandDraft:e.setCommandDraft,createCommand:e.createCommand,deleteCommand:e.deleteCommand}}function Fo(e){return e.name}function Io(e){return!Wi(e)}function Lo(e,t){return e.name.localeCompare(t.name)}function Ro(e,t){return e.name.localeCompare(t.name)}var zo=()=>{let{t:e}=ke(),{selectedCommandName:t,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:a}=Ki(he(e=>({selectedCommandName:e.selectedCommandName,createCommand:e.createCommand,updateCommand:e.updateCommand,commandDraft:e.commandDraft,setCommandDraft:e.setCommandDraft}))),o=_t(),s=Q.useMemo(()=>o.data??[],[o.data]),c=t?s.find(e=>e.name===t):null,l=!!(i&&i.name===t&&!c),[u,d]=Q.useState(``),[f,p]=Q.useState(`user`),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),w=Q.useRef(null);Q.useEffect(()=>{if(l&&i){let e=i.name||``,t=i.scope||`user`,n=i.description||``,r=i.agent||``,a=i.model||``,o=i.template||``;d(e),p(t),h(n),_(r),y(a),x(o),w.current={draftName:e,draftScope:t,description:n,agent:r,model:a,template:o}}else if(c){let e=c.description||``,t=c.agent||``,n=c.model||``,r=c.template||``;h(e),_(t),y(n),x(r),w.current={draftName:``,draftScope:`user`,description:e,agent:t,model:n,template:r}}},[c,l,t,s,i]);let T=Q.useMemo(()=>{let e=w.current;return e?!!(l&&(u!==e.draftName||f!==e.draftScope)||m!==e.description||g!==e.agent||v!==e.model||b!==e.template):!1},[g,m,u,f,l,v,b]);return t?(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:l?e(`settings.commands.page.title.new`):`/${t}`}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.commands.page.subtitle.new`:`settings.commands.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.identity`),children:[l&&(0,$.jsxs)(Ir,{itemId:`commands.name`,label:e(`settings.commands.page.field.commandName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`/`}),(0,$.jsx)(un,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.commands.page.field.commandNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(on,{value:f,onValueChange:e=>p(e),children:[(0,$.jsx)(nn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(ln,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(rn,{align:`end`,children:[(0,$.jsx)(en,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(en,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Ir,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(xr,{embedded:!0,value:m,onChange:e=>h(e.target.value),placeholder:e(`settings.commands.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})})]}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.executionContext`),children:[(0,$.jsx)(Ir,{itemId:`commands.agent`,label:e(`settings.commands.page.field.overrideAgent`),children:(0,$.jsx)(Sn,{agentName:g,onChange:e=>_(e),className:`oc-settings-inline-value`})}),(0,$.jsx)(Ir,{itemId:`commands.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(An,{providerId:mt(v)?.providerId??``,modelId:mt(v)?.modelId??``,onChange:(e,t)=>{y(e&&t?`${e}/${t}`:``)},className:`oc-settings-inline-value`})})]}),(0,$.jsx)(jr,{itemId:`commands.template`,label:e(`settings.commands.page.section.template`),description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`text-foreground`,children:`$ARGUMENTS`}),` `,e(`settings.commands.page.templateHint.userInput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:"!`cmd`"}),` `,e(`settings.commands.page.templateHint.shellOutput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`@file`}),` `,e(`settings.commands.page.templateHint.fileContents`)]}),descriptionPlacement:`outside`,className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(xr,{embedded:!0,value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.commands.page.field.templatePlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let i=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!i){K.error(e(`settings.commands.sidebar.toast.commandNameRequired`));return}if(!b.trim()){K.error(e(`settings.commands.page.toast.templateRequired`));return}if(l&&s.some(e=>e.name===i)){K.error(e(`settings.commands.sidebar.toast.commandExists`));return}C(!0);try{let t=g.trim(),o=v.trim(),s=b.trim(),c={name:i,description:m.trim()||void 0,agent:t===``?null:t,model:o===``?null:o,template:s,scope:l?f:void 0},u;l?(u=await n(c),u&&a(null)):u=await r(i,c),u?K.success(e(l?`settings.commands.page.toast.created`:`settings.commands.page.toast.updated`)):K.error(e(l?`settings.commands.page.toast.createFailed`:`settings.commands.page.toast.updateFailed`))}catch(t){console.error(`Error saving command:`,t),K.error(e(`settings.commands.page.toast.saveUnexpectedError`))}finally{C(!1)}},disabled:S||!T,size:`xs`,className:`!font-normal`,children:e(S?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`terminal-box`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.commands.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.commands.page.empty.description`)})]})})},Bo=[],Vo=e=>{switch(e){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`idle`}},Ho=e=>{let t=(0,Di.c)(5),{tone:n,enabled:r}=e;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0`}),t[0]=e):e=t[0],e}let i;t[1]===n?i=t[2]:(i=q(`inline-block h-2 w-2 rounded-full flex-shrink-0`,{success:`bg-[var(--status-success)]`,error:`bg-[var(--status-error)]`,warning:`bg-[var(--status-warning)]`,idle:`bg-muted-foreground/40`}[n]),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`span`,{className:i}),t[3]=i,t[4]=a),a},Uo=e=>{let t=(0,Di.c)(115),{onItemSelect:n}=e,{t:r}=ke(),{selectedMcpName:a,setSelectedMcp:o,setMcpDraft:s,deleteMcp:c}=ea(he(Wo)),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Yr(),t[0]=l):l=t[0];let u=l,d=Jr(u),f=Xr(u),p=d.data??Bo,m;t[1]===f.data?m=t[2]:(m=f.data??{},t[1]=f.data,t[2]=m);let h=m,[g,_]=Q.useState(null),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,C]=Q.useState(null),[w,T]=Q.useState(!1),E;t[3]===p?E=t[4]:(E=p.filter(Go),t[3]=p,t[4]=E);let D=E,O;t[5]===p?O=t[6]:(O=p.filter(Ko),t[5]=p,t[6]=O);let k=O,A;t[7]===w?A=t[8]:(A=()=>{if(w)return;T(!0);let e=new Promise(qo),t=i();Promise.all([Pr(H,u,t),e]).catch(Jo).finally(()=>{T(!1)})},t[7]=w,t[8]=A);let j=A,M;t[9]!==p||t[10]!==n||t[11]!==s||t[12]!==o?(M=()=>{let e=`new-mcp-server`,t=1;for(;p.some(t=>t.name===e);)e=`new-mcp-server-${t}`,t++;s({name:e,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),o(e),n?.()},t[9]=p,t[10]=n,t[11]=s,t[12]=o,t[13]=M):M=t[13];let N=M,P;t[14]!==c||t[15]!==g||t[16]!==r?(P=async()=>{if(!g)return;y(!0);let e=await c(g.name,{directory:Yr(),transportIdentity:i()});e.ok?e.reloadFailed?K.warning(e.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:e.warning||r(`settings.mcp.sidebar.toast.refreshListIfStale`)}):K.success(e.message||r(`settings.mcp.sidebar.toast.serverDeleted`,{name:g.name})):K.error(r(`settings.mcp.sidebar.toast.deleteFailed`)),_(null),y(!1)},t[14]=c,t[15]=g,t[16]=r,t[17]=P):P=t[17];let F=P,I;t[18]===r?I=t[19]:(I=(e,t)=>(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),_(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]}),t[18]=r,t[19]=I);let L=I,R;t[20]===r?R=t[21]:(R=r(`settings.mcp.sidebar.group.userServers`),t[20]=r,t[21]=R);let z;t[22]===R?z=t[23]:(z=(0,$.jsx)(`span`,{children:R}),t[22]=R,t[23]=z);let B;t[24]===r?B=t[25]:(B=r(`settings.mcp.sidebar.actions.refreshStatusAria`),t[24]=r,t[25]=B);let V;t[26]===r?V=t[27]:(V=r(`settings.mcp.sidebar.actions.refreshStatusTitle`),t[26]=r,t[27]=V);let ee=w&&`animate-spin`,U;t[28]===ee?U=t[29]:(U=q(`h-4 w-4`,ee),t[28]=ee,t[29]=U);let te;t[30]===U?te=t[31]:(te=(0,$.jsx)(J,{name:`refresh`,className:U}),t[30]=U,t[31]=te);let W;t[32]!==j||t[33]!==w||t[34]!==B||t[35]!==V||t[36]!==te?(W=(0,$.jsx)(Y,{type:`button`,size:`icon`,variant:`ghost`,disabled:w,onClick:j,"aria-label":B,title:V,children:te}),t[32]=j,t[33]=w,t[34]=B,t[35]=V,t[36]=te,t[37]=W):W=t[37];let ne;t[38]===r?ne=t[39]:(ne=r(`settings.mcp.sidebar.actions.addServerTitle`),t[38]=r,t[39]=ne);let re;t[40]===r?re=t[41]:(re=r(`settings.mcp.sidebar.actions.addServerTitle`),t[40]=r,t[41]=re);let ie;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[42]=ie):ie=t[42];let ae;t[43]!==N||t[44]!==ne||t[45]!==re?(ae=(0,$.jsx)(Y,{"data-settings-item":`mcp.create`,size:`icon`,variant:`ghost`,onClick:N,"aria-label":ne,title:re,children:ie}),t[43]=N,t[44]=ne,t[45]=re,t[46]=ae):ae=t[46];let oe;t[47]!==W||t[48]!==ae?(oe=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[W,ae]}),t[47]=W,t[48]=ae,t[49]=oe):oe=t[49];let se;t[50]!==z||t[51]!==oe?(se=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[z,oe]}),t[50]=z,t[51]=oe,t[52]=se):se=t[52];let ce=se,le;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(ga,{})})}),t[53]=le):le=t[53];let ue;t[54]!==d.data||t[55]!==d.error||t[56]!==d.isError||t[57]!==p.length||t[58]!==h||t[59]!==n||t[60]!==b||t[61]!==D||t[62]!==L||t[63]!==S||t[64]!==a||t[65]!==s||t[66]!==o||t[67]!==f.data||t[68]!==f.error||t[69]!==f.isError||t[70]!==r||t[71]!==k||t[72]!==ce?(ue=(0,$.jsx)($.Fragment,{children:d.isError&&!d.data?(0,$.jsx)(Z,{label:ce,children:(0,$.jsx)(`div`,{className:`oc-settings-group-row py-12 text-center typography-meta text-[var(--status-error)]`,children:d.error.message})}):p.length===0?(0,$.jsx)(Z,{label:ce,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.mcp.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.mcp.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[D.length>0&&(0,$.jsx)(Z,{label:r(`settings.mcp.sidebar.group.projectServers`),children:D.map(e=>{let t=Vo((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=pr();return(0,$.jsxs)(bi,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(_i,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ho,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(J,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(J,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(En,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hn,{align:`end`,className:`w-fit min-w-20`,children:L(e,vn)})]})]}),(0,$.jsx)(vi,{className:`w-fit min-w-20`,children:L(e,yi)})]},e.name)})}),k.length>0&&(0,$.jsx)(Z,{label:ce,children:k.map(e=>{let t=Vo((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=pr();return(0,$.jsxs)(bi,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(_i,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ho,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(J,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(J,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(En,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hn,{align:`end`,className:`w-fit min-w-20`,children:L(e,vn)})]})]}),(0,$.jsx)(vi,{className:`w-fit min-w-20`,children:L(e,yi)})]},e.name)})}),k.length===0&&(0,$.jsx)(Z,{label:ce,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[54]=d.data,t[55]=d.error,t[56]=d.isError,t[57]=p.length,t[58]=h,t[59]=n,t[60]=b,t[61]=D,t[62]=L,t[63]=S,t[64]=a,t[65]=s,t[66]=o,t[67]=f.data,t[68]=f.error,t[69]=f.isError,t[70]=r,t[71]=k,t[72]=ce,t[73]=ue):ue=t[73];let de=g!==null,fe;t[74]===v?fe=t[75]:(fe=e=>{!e&&!v&&_(null)},t[74]=v,t[75]=fe);let pe;t[76]===r?pe=t[77]:(pe=r(`settings.mcp.sidebar.deleteDialog.title`),t[76]=r,t[77]=pe);let me;t[78]===pe?me=t[79]:(me=(0,$.jsx)(qt,{children:pe}),t[78]=pe,t[79]=me);let ge=g?.name||``,_e;t[80]!==r||t[81]!==ge?(_e=r(`settings.mcp.sidebar.deleteDialog.descriptionPrefix`,{name:ge}),t[80]=r,t[81]=ge,t[82]=_e):_e=t[82];let ve;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),t[83]=ve):ve=t[83];let ye;t[84]===_e?ye=t[85]:(ye=(0,$.jsxs)(Jt,{children:[_e,` `,ve,`.`]}),t[84]=_e,t[85]=ye);let be;t[86]!==me||t[87]!==ye?(be=(0,$.jsxs)(Wt,{children:[me,ye]}),t[86]=me,t[87]=ye,t[88]=be):be=t[88];let xe;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>_(null),t[89]=xe):xe=t[89];let Se;t[90]===r?Se=t[91]:(Se=r(`settings.common.actions.cancel`),t[90]=r,t[91]=Se);let Ce;t[92]!==v||t[93]!==Se?(Ce=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:xe,disabled:v,children:Se}),t[92]=v,t[93]=Se,t[94]=Ce):Ce=t[94];let we;t[95]!==v||t[96]!==r?(we=r(v?`settings.mcp.sidebar.actions.deleting`:`settings.common.actions.delete`),t[95]=v,t[96]=r,t[97]=we):we=t[97];let Te;t[98]!==F||t[99]!==v||t[100]!==we?(Te=(0,$.jsx)(Y,{size:`sm`,onClick:F,disabled:v,children:we}),t[98]=F,t[99]=v,t[100]=we,t[101]=Te):Te=t[101];let Ee;t[102]!==Ce||t[103]!==Te?(Ee=(0,$.jsxs)(Gt,{children:[Ce,Te]}),t[102]=Ce,t[103]=Te,t[104]=Ee):Ee=t[104];let De;t[105]!==be||t[106]!==Ee?(De=(0,$.jsxs)(Kt,{className:`max-w-md`,children:[be,Ee]}),t[105]=be,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]!==de||t[109]!==fe||t[110]!==De?(Oe=(0,$.jsx)(Yt,{open:de,onOpenChange:fe,children:De}),t[108]=de,t[109]=fe,t[110]=De,t[111]=Oe):Oe=t[111];let Ae;return t[112]!==ue||t[113]!==Oe?(Ae=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[le,ue,Oe]}),t[112]=ue,t[113]=Oe,t[114]=Ae):Ae=t[114],Ae};function Wo(e){return{selectedMcpName:e.selectedMcpName,setSelectedMcp:e.setSelectedMcp,setMcpDraft:e.setMcpDraft,deleteMcp:e.deleteMcp}}function Go(e){return e.scope===`project`}function Ko(e){return e.scope!==`project`}function qo(e){return setTimeout(e,500)}function Jo(e){K.error(e instanceof Error?e.message:String(e))}function Yo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Xo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Zo(e,t){return t===void 0?{ok:!1,error:e}:{ok:!1,error:e,parsed:t}}function Qo(e,t,n){return{ok:!0,name:e,type:t,command:$o(n),url:typeof n.url==`string`?n.url.trim():``,environment:es(n,`env`,`environment`),headers:es(n,`headers`),oauthEnabled:ts(n),oauthClientId:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientId??``).trim():``,oauthClientSecret:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientSecret??``).trim():``,oauthScope:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.scope??``).trim():``,oauthRedirectUri:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.redirectUri??``).trim():``,timeout:ns(n),enabled:rs(n)}}function $o(e){let t=e.command,n=e.args;if(Xo(t)&&Xo(n))return[...t,...n];if(Xo(t))return t;if(typeof t==`string`&&t.trim()){let e=t.trim().split(/\s+/);return Xo(n)?[...e,...n]:e}return Xo(n)?n:[]}function es(e,...t){for(let n of t){let t=e[n];if(!Yo(t))continue;let r=Object.entries(t).filter(([e,t])=>e&&typeof t==`string`);if(r.length>0)return r.map(([e,t])=>({key:e,value:String(t)}))}return[]}function ts(e){if(e.oauth===!1||e.oauth===null||e.oauth===void 0||!Yo(e.oauth))return!1;let t=e.oauth;return!!(typeof t.clientId==`string`&&t.clientId.trim()||typeof t.clientSecret==`string`&&t.clientSecret.trim()||typeof t.scope==`string`&&t.scope.trim()||typeof t.redirectUri==`string`&&t.redirectUri.trim())}function ns(e){let t=e.timeout;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return``}function rs(e){return`disabled`in e&&e.disabled===!0?!1:`enabled`in e?!!e.enabled:!0}function is(e){let t=e.mcpServers;if(Yo(t)){let e=Object.keys(t);if(e.length===1){let n=e[0],r=t[n];if(Yo(r))return{name:n,entry:r}}if(e.length>1)return null}let n=Object.keys(e).filter(t=>{let n=e[t];return t!==`mcpServers`&&Yo(n)});if(n.length===1){let t=n[0],r=e[t];if(as(r))return{name:t,entry:r}}return null}function as(e){return e.type===`local`||e.type===`remote`||Array.isArray(e.command)||typeof e.url==`string`||Array.isArray(e.args)}function os(e,t){let n;try{let t=e.trim();if(!t)return Zo(`No JSON content provided`);n=JSON.parse(t)}catch(e){return Zo(e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`)}if(!Yo(n))return Zo(`Expected a JSON object, not an array or primitive`);let r=n,i=r.mcpServers;if(Yo(i)){let e=Object.keys(i);if(e.length===0)return Zo(`mcpServers object is empty`,n);if(e.length>1)return Zo(`Paste one server at a time. Found `+e.length+` servers in mcpServers`,n);let t=e[0],r=i[t];return Yo(r)?Qo(t,ss(r),r):Zo(`Server entry is not a valid object`,n)}let a=r.mcp;if(Yo(a)){let e=Object.keys(a);if(e.length===0)return Zo(`mcp object is empty`,n);if(e.length>1)return Zo(`Paste one server at a time. Found `+e.length+` servers in mcp`,n);let t=e[0],r=a[t];return Yo(r)?Qo(t,ss(r),r):Zo(`Server entry in mcp is not a valid object`,n)}let o=is(r);if(o)return Qo(o.name,ss(o.entry),o.entry);if(as(r)){let e=ss(r);return Qo(typeof r.name==`string`&&r.name.trim()?r.name.trim():t?.fallbackName,e,r)}return Zo(`No recognizable MCP server configuration found in JSON`,n)}function ss(e){return e.type===`remote`?`remote`:e.type===`local`?`local`:typeof e.url==`string`&&e.url.trim()?`remote`:(Array.isArray(e.command)||typeof e.command==`string`||Array.isArray(e.args),`local`)}function cs(e,t,n){let r=n?.isNewServer??!1,i=e.name,a=r&&i?i:t.name??``;return{...t,name:a,type:e.type,command:e.type===`local`?e.command:[],url:e.type===`remote`?e.url:``,environment:e.environment,headers:e.type===`remote`?e.headers:[],oauthEnabled:e.type===`remote`&&e.oauthEnabled,oauthClientId:e.type===`remote`?e.oauthClientId:``,oauthClientSecret:e.type===`remote`?e.oauthClientSecret:``,oauthScope:e.type===`remote`?e.oauthScope:``,oauthRedirectUri:e.type===`remote`?e.oauthRedirectUri:``,timeout:e.type===`remote`?e.timeout:``,enabled:e.enabled}}function ls(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`'`&&!i){r=!r;continue}if(o===`"`&&!r){i=!i;continue}if((o===` `||o===` `)&&!r&&!i){n&&=(t.push(n),``);continue}n+=o}return n&&t.push(n),t}function us(e){let t=e.trim();if(!t)return{code:null,context:null,stateKey:null};try{let e=new URL(t),n=e.searchParams.get(`code`);if(typeof n==`string`&&n.trim())return{code:n.trim(),context:Lr(e.searchParams),stateKey:Rr(e.searchParams)}}catch{}return{code:t,context:null,stateKey:null}}var ds=({value:e,onChange:t,pasteCommandTitle:n,pasteCommandLabel:r,pasteSuccess:i,clipboardReadFailed:a,preview:o})=>{let[s,c]=Q.useState(()=>e.join(`
|
|
3
3
|
`)),l=Q.useRef(e);Q.useEffect(()=>{JSON.stringify(l.current)!==JSON.stringify(e)&&(l.current=e,c(e.join(`
|
|
4
4
|
`)))},[e]);let u=e=>{t(e.split(`
|
|
5
5
|
`).filter(e=>e.trim().length>0))};return(0,$.jsxs)(`div`,{className:`space-y-2`,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:(0,$.jsxs)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:async()=>{try{let e=(await navigator.clipboard.readText()).trim(),n=e.includes(`
|
|
6
6
|
`)?e.split(`
|
|
7
|
-
`).filter(e=>e.trim()):
|
|
8
|
-
`)),t(n),K.success(i(n.length))}catch{K.error(a)}},type:`button`,title:n,children:[(0,$.jsx)(J,{name:`clipboard`,className:`h-3 w-3`}),r]})}),(0,$.jsx)(
|
|
7
|
+
`).filter(e=>e.trim()):ls(e);c(n.join(`
|
|
8
|
+
`)),t(n),K.success(i(n.length))}catch{K.error(a)}},type:`button`,title:n,children:[(0,$.jsx)(J,{name:`clipboard`,className:`h-3 w-3`}),r]})}),(0,$.jsx)(xr,{embedded:!0,value:s,onChange:e=>{c(e.target.value),u(e.target.value)},onBlur:()=>{let e=s.split(`
|
|
9
9
|
`).map(e=>e.trimEnd()).join(`
|
|
10
10
|
`);c(e),u(e)},placeholder:`npx
|
|
11
11
|
-y
|
|
12
12
|
@modelcontextprotocol/server-postgres
|
|
13
|
-
postgresql://user:pass@host/db`,rows:Math.max(4,e.length+1),className:`font-mono typography-meta resize-y min-h-[80px]`,spellCheck:!1}),e.length>0&&(0,$.jsxs)(`details`,{className:`group`,children:[(0,$.jsx)(`summary`,{className:`typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground`,children:o(e.length)}),(0,$.jsx)(`div`,{className:`mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto`,children:(0,$.jsx)(`code`,{className:`typography-micro text-foreground/80 whitespace-pre`,children:e.map((e,t)=>(0,$.jsxs)(`span`,{className:`block`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground select-none mr-2`,children:[`[`,t,`]`]}),e]},t))})})]})]})},
|
|
14
|
-
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.indexOf(`=`);if(n===-1)continue;let i=t.slice(0,n).trim(),a=t.slice(n+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`))&&(a=a.slice(1,-1)),i&&r.push({key:i,value:a})}if(r.length===0){K.error(s);return}let i=[...e];for(let e of r){let t=i.findIndex(t=>t.key===e.key);t===-1?i.push(e):i[t]=e}t(i),K.success(c(r.length))}catch{K.error(l)}},T=e.some(e=>e.value.length>0);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground w-32 shrink-0`,children:u}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:d})]}),(0,$.jsxs)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:w,type:`button`,title:o,children:[(0,$.jsx)(J,{name:`clipboard`,className:`h-3 w-3`}),a]})]}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ln,{value:e.key,onChange:e=>S(t,`key`,n(e.target.value)),placeholder:r,className:i,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsxs)(`div`,{className:`relative flex-1 flex items-center`,children:[(0,$.jsx)(ln,{type:v.has(t)?`text`:`password`,value:e.value,onChange:e=>S(t,`value`,e.target.value),placeholder:f,className:`font-mono typography-meta pr-8 w-full`,autoComplete:`new-password`,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`absolute right-2 text-muted-foreground/60 hover:text-muted-foreground`,title:v.has(t)?p:m,children:v.has(t)?(0,$.jsx)(J,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`eye`,className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(t),"aria-label":_,children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]},t))}),(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:b,type:`button`,children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),h]}),T&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:g})]})},ps=e=>{let t=(0,Ei.c)(14),{status:n,enabled:r,getStatusLabel:i,variant:a}=e,o=a===void 0?`compact`:a;if(!r||!n)return null;let s,c;if(t[0]!==i||t[1]!==n||t[2]!==o){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e={connected:{text:`text-[var(--status-success)]`,bg:`bg-[var(--status-success)]/10`},failed:{text:`text-[var(--status-error)]`,bg:`bg-[var(--status-error)]/10`},needs_auth:{text:`text-[var(--status-warning)]`,bg:`bg-[var(--status-warning)]/10`},needs_client_registration:{text:`text-[var(--status-warning)]`,bg:`bg-[var(--status-warning)]/10`}}[n]??{text:`text-muted-foreground`,bg:``};if(o===`pill`){let r=q(`typography-micro font-medium rounded-full px-2 py-0.5`,e.text,e.bg),a;t[5]!==i||t[6]!==n?(a=i(n),t[5]=i,t[6]=n,t[7]=a):a=t[7],c=(0,$.jsxs)(`span`,{className:r,children:[`● `,a]});break bb0}s=q(`typography-micro font-medium`,e.text)}t[0]=i,t[1]=n,t[2]=o,t[3]=s,t[4]=c}else s=t[3],c=t[4];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[8]!==i||t[9]!==n?(l=i(n),t[8]=i,t[9]=n,t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`span`,{className:s,children:[`● `,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u},ms=(e,t,n)=>{switch(e){case`connected`:return t(`settings.mcp.page.status.description.connected`);case`failed`:return n?.trim()||t(`settings.mcp.page.status.description.failedDefault`);case`needs_auth`:return t(`settings.mcp.page.status.description.needsAuth`);case`needs_client_registration`:return n?.trim()||t(`settings.mcp.page.status.description.needsClientRegistrationDefault`);case`disabled`:return t(`settings.mcp.page.status.description.disabled`);default:return t(`settings.mcp.page.status.description.default`)}},hs=e=>{switch(e){case`failed`:return`border-[var(--status-error-border)] bg-[var(--status-error-background)]`;case`needs_auth`:case`needs_client_registration`:return`border-[var(--status-warning-border)] bg-[var(--status-warning-background)]`;default:return`border-[var(--interactive-border)] bg-[var(--surface-elevated)]`}},gs=(e,t,n,r)=>!!(e===`failed`||e===`needs_auth`||e===`needs_client_registration`||t||n||r),_s=(e,t)=>{if(typeof window>`u`)return null;let n=new URL(ri,r()||window.location.origin);return typeof e==`string`&&e.trim()&&n.searchParams.set(`server`,e.trim()),typeof t==`string`&&t.trim()&&n.searchParams.set(`directory`,t.trim()),n.toString()},vs=async e=>{let t=await L(`/api/mcp/auth/pending`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({state:e.state,name:e.name,directory:typeof e.directory==`string`&&e.directory.trim()?e.directory.trim():null})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||`Failed to prepare MCP authorization callback`)}},ys=async e=>{let t=await L(`/api/mcp/auth/pending?state=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json().catch(()=>null);return n?.name?.trim()?{name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null}:null},bs=async e=>{typeof e!=`string`||!e.trim()||await L(`/api/mcp/auth/pending?state=${encodeURIComponent(e.trim())}`,{method:`DELETE`}).catch(()=>void 0)},xs=(e,t,n)=>{let r=e instanceof Error?e.message:t;return/oauth state required/i.test(r)?n(`settings.mcp.page.toast.authSessionExpired`):r},Ss=(e,t,n)=>{let r=typeof t==`string`&&t.trim()?t.trim():`__global__`;return`${n}::${e??`__none__`}::${r}`},Cs=()=>{let{t:e}=ke(),t=Q.useCallback((t,n)=>e(t,n),[e]),{selectedMcpName:n,mcpDraft:r,setMcpDraft:a,setSelectedMcp:o,createMcp:s,updateMcp:c,deleteMcp:l}=$i(he(e=>({selectedMcpName:e.selectedMcpName,mcpDraft:e.mcpDraft,setMcpDraft:e.setMcpDraft,setSelectedMcp:e.setSelectedMcp,createMcp:e.createMcp,updateMcp:e.updateMcp,deleteMcp:e.deleteMcp}))),u=Jr(),d=i(),f=qr(u),p=Yr(u),h=f.data??[],g=p.data??{},_=Q.useMemo(()=>m(),[]),v=Kr(e=>e.getDiagnosticForDirectory(u)),y=Kr(e=>e.connect),b=Kr(e=>e.disconnect),x=Kr(e=>e.startAuth),S=Kr(e=>e.completeAuth),C=Kr(e=>e.clearAuth),w=Kr(e=>e.testConnection),T=n?h.find(e=>e.name===n)??null:null,E=!!(r&&r.name===n&&!T),[D,O]=Q.useState(``),[k,A]=Q.useState(`user`),[j,M]=Q.useState(`local`),[N,P]=Q.useState([]),[F,I]=Q.useState(``),[L,R]=Q.useState([]),[z,B]=Q.useState([]),[V,ee]=Q.useState(!0),[U,te]=Q.useState(``),[W,ne]=Q.useState(``),[re,ie]=Q.useState(``),[ae,oe]=Q.useState(``),[se,ce]=Q.useState(``),[le,ue]=Q.useState(!0),[de,fe]=Q.useState(!1),[pe,me]=Q.useState(!1),[ge,_e]=Q.useState(!1),[ve,ye]=Q.useState(!1),[be,xe]=Q.useState(!1),[Se,Ce]=Q.useState(!1),[we,Te]=Q.useState(!1),[Ee,De]=Q.useState(!1),[Oe,Ae]=Q.useState(null),[Me,Ne]=Q.useState(null),[Pe,Fe]=Q.useState(``),[Ie,Le]=Q.useState(!1),Re=Q.useRef(0),ze=Q.useRef(!1),[Be,Ve]=Q.useState(!1),[He,Ue]=Q.useState(!1),[We,Ge]=Q.useState(``),[Ke,qe]=Q.useState(null),Je=Q.useMemo(()=>Ss(n,u,d),[u,n,d]),Ye=Q.useRef(Je),Xe=Q.useRef(null),Ze=Q.useCallback(()=>{Ae(null),Ne(null),Fe(``),Le(!1),Re.current=0,De(!1),xe(!1),Ce(!1),ze.current=!1},[]),Qe=Q.useCallback(()=>{Ge(``),qe(null),Ue(!0)},[]),$e=Q.useCallback(async()=>{try{let e=await navigator.clipboard.readText();Ge(e),qe(null)}catch{K.error(e(`settings.mcp.page.toast.clipboardReadFailed`))}},[e]),et=Q.useCallback(()=>{let t=as(We,{fallbackName:D});if(!t.ok){qe(t.error);return}let n=ss(t,{name:D,scope:k,type:j,command:N,url:F,environment:L,headers:z,oauthEnabled:V,oauthClientId:U,oauthClientSecret:W,oauthScope:re,oauthRedirectUri:ae,timeout:se,enabled:le},{isNewServer:E});O(n.name),M(n.type),P(n.command??[]),I(n.url??``),R(n.environment??[]),B(n.headers??[]),ee(n.oauthEnabled??!1),te(n.oauthClientId??``),ne(n.oauthClientSecret??``),ie(n.oauthScope??``),oe(n.oauthRedirectUri??``),ce(n.timeout??``),ue(n.enabled??!0),Ue(!1),Ge(``),qe(null),K.success(e(`settings.mcp.page.toast.configImported`))},[We,D,k,j,N,F,L,z,V,U,W,re,ae,se,le,E,e]);Q.useEffect(()=>{if(E&&r){O(r.name),A(r.scope||`user`),M(r.type),P(r.command),I(r.url),R(r.environment),B(r.headers),ee(r.oauthEnabled),te(r.oauthClientId),ne(r.oauthClientSecret),ie(r.oauthScope),oe(r.oauthRedirectUri),ce(r.timeout),ue(r.enabled),Ve(!1),Xe.current={mcpType:r.type,command:r.command,url:r.url,envEntries:r.environment,headerEntries:r.headers,oauthEnabled:r.oauthEnabled,oauthClientId:r.oauthClientId,oauthClientSecret:r.oauthClientSecret,oauthScope:r.oauthScope,oauthRedirectUri:r.oauthRedirectUri,timeout:r.timeout,enabled:r.enabled};return}if(T){A(T.scope===`project`?`project`:`user`);let e=Yi(T.environment),t=T.type===`remote`?T:null,n=Yi(t?.headers),r=t?.oauth,i=r&&typeof r==`object`?r:null,a=r!==!1,o=T.type,s=o===`local`?T.command??[]:[],c=o===`remote`?T.url??``:``,l=typeof t?.timeout==`number`&&Number.isFinite(t.timeout)?String(t.timeout):``;M(o),P(s),I(c),R(e),B(n),ee(a),te(a?i?.clientId??``:``),ne(a?i?.clientSecret??``:``),ie(a?i?.scope??``:``),oe(a?i?.redirectUri??``:``),ce(l),ue(T.enabled),Ve(!1),Xe.current={mcpType:o,command:s,url:c,envEntries:e,headerEntries:n,oauthEnabled:a,oauthClientId:a?i?.clientId??``:``,oauthClientSecret:a?i?.clientSecret??``:``,oauthScope:a?i?.scope??``:``,oauthRedirectUri:a?i?.redirectUri??``:``,timeout:l,enabled:T.enabled}}},[T,E,r]);let tt=Q.useMemo(()=>{let e=Xe.current;return e?j!==e.mcpType||le!==e.enabled||JSON.stringify(N)!==JSON.stringify(e.command)||F!==e.url||JSON.stringify(L)!==JSON.stringify(e.envEntries)||JSON.stringify(z)!==JSON.stringify(e.headerEntries)||V!==e.oauthEnabled||U!==e.oauthClientId||W!==e.oauthClientSecret||re!==e.oauthScope||ae!==e.oauthRedirectUri||se!==e.timeout:!1},[j,N,F,L,z,V,U,W,re,ae,se,le]),G=async()=>{let t=E?D.trim():n??``;if(!t){K.error(e(`settings.mcp.page.toast.nameRequired`));return}if(E&&h.some(e=>e.name===t)){K.error(e(`settings.mcp.page.toast.serverNameExists`));return}if(j===`local`&&N.filter(Boolean).length===0){K.error(e(`settings.mcp.page.toast.localCommandRequired`));return}if(j===`remote`&&!F.trim()){K.error(e(`settings.mcp.page.toast.remoteUrlRequired`));return}let r={name:t,scope:k,type:j,command:N,url:F,environment:L,headers:z,oauthEnabled:V,oauthClientId:U,oauthClientSecret:W,oauthScope:re,oauthRedirectUri:ae,timeout:se,enabled:le};fe(!0);try{let n={directory:Jr(),transportIdentity:i()},l=E?await s(r,n):await c(t,r,n);l.ok?(await bs(Me),Ze(),E&&(a(null),o(t)),l.reloadFailed?K.warning(l.message||e(E?`settings.mcp.page.toast.serverCreatedReloadFailed`:`settings.mcp.page.toast.savedReloadFailed`),{description:l.warning||e(`settings.mcp.page.toast.retryRefreshHint`)}):K.success(l.message||e(E?`settings.mcp.page.toast.serverCreatedReloading`:`settings.mcp.page.toast.savedReloading`))):K.error(e(`settings.mcp.page.toast.saveFailed`))}catch(t){K.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.unexpectedError`))}finally{fe(!1)}},nt=async()=>{if(!n)return;_e(!0);let t=await l(n,{directory:Jr(),transportIdentity:i()});t.ok?(await bs(Me),Ze(),t.reloadFailed?K.warning(t.message||e(`settings.mcp.page.toast.serverDeletedReloadFailed`,{name:n}),{description:t.warning||e(`settings.mcp.page.toast.refreshListIfStale`)}):K.success(t.message||e(`settings.mcp.page.toast.serverDeleted`,{name:n})),me(!1)):K.error(e(`settings.mcp.page.toast.deleteFailed`)),_e(!1)},rt=async()=>{if(n){ye(!0);try{if(g[n]?.status===`connected`)await b(n,u),K.success(e(`settings.mcp.page.toast.disconnected`));else{await y(n,u);let t=Pr(H,u)[n];t?.status===`connected`?K.success(e(`settings.mcp.page.toast.connected`)):t?.status===`needs_auth`?K.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):t?.status===`needs_client_registration`?K.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):t?.status===`failed`?K.error(t.error||e(`settings.mcp.page.toast.connectionFailed`)):K.message(e(`settings.mcp.page.toast.connectionAttemptFinished`));return}}catch(t){K.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionFailed`))}finally{ye(!1)}}},it=Q.useCallback(()=>E?(K.error(e(`settings.mcp.page.toast.createServerBeforeLiveActions`)),!1):!tt||(K.error(e(`settings.mcp.page.toast.saveBeforeLiveActions`)),!1),[tt,E,e]);Q.useEffect(()=>{Ye.current=Je,ye(!1),Te(!1),Ze()},[Ze,Je]);let at=Q.useCallback(async()=>{if(!n||j!==`remote`||!it())return;xe(!0);let r=Je,i=null;try{let t=Pr(H,u)[n]?.status;ze.current=t===`needs_auth`||t===`needs_client_registration`;let a=_s(n,u);if(!a)throw Error(e(`settings.mcp.page.toast.oauthRedirectUrlBuildFailed`));if(!ae.trim()&&!_){let t=await c(n,{oauthEnabled:V,oauthClientId:U,oauthClientSecret:W,oauthScope:re,oauthRedirectUri:a});if(!t.ok)throw Error(e(`settings.mcp.page.toast.oauthBrowserCallbackSaveFailed`));if(t.reloadFailed)throw Error(t.warning||t.message||e(`settings.mcp.page.toast.openCodeReloadFailedAfterCallbackSave`));if(Ye.current!==r)return;oe(a),Xe.current=Xe.current?{...Xe.current,oauthRedirectUri:a}:Xe.current}let o=await x(n,u),s=Lr(new URL(o).searchParams);if(s&&(i=s,await vs({state:s,name:n,directory:u})),Ye.current!==r)return;Ae(o),Ne(s??null),Le(!0),Re.current=0;let l=await xr(o);if(Ye.current!==r)return;l?K.message(e(_?`settings.mcp.page.toast.completeAuthorizationInBrowserWithPaste`:`settings.mcp.page.toast.completeAuthorizationInBrowser`)):K.error(e(`settings.mcp.page.toast.openAuthorizationUrlFailed`))}catch(n){await bs(i),Ye.current===r&&K.error(xs(n,e(`settings.mcp.page.toast.authorizationStartFailed`),t))}finally{Ye.current===r&&xe(!1)}},[_,u,j,U,W,V,ae,re,it,Je,n,x,e,t,c]),ot=Q.useCallback(async()=>{if(!n||!it())return;Ce(!0);let r=Je;try{if(await C(n,u),Ye.current!==r)return;Ae(null),Ne(null),Fe(``),Le(!1),Re.current=0,await bs(Me),K.success(e(`settings.mcp.page.toast.savedAuthorizationRemoved`))}catch(n){Ye.current===r&&K.error(xs(n,e(`settings.mcp.page.toast.clearAuthorizationFailed`),t))}finally{Ye.current===r&&Ce(!1)}},[Me,C,u,it,Je,n,e,t]),st=Q.useCallback(async()=>{if(Oe){if((await je(Oe)).ok){K.success(e(`settings.mcp.page.toast.authorizationUrlCopied`));return}K.error(e(`settings.mcp.page.toast.authorizationUrlCopyFailed`))}},[Oe,e]),ct=Q.useCallback(async()=>{let r=ls(Pe);if(!r.code){K.error(e(`settings.mcp.page.toast.pasteCallbackOrCodeFirst`));return}let i=r.stateKey?await ys(r.stateKey):null,a=r.context??i,o=a?.name??n,s=a?.directory??u;if(!o){K.error(e(`settings.mcp.page.toast.missingServerDetails`));return}if(!a&&!it())return;De(!0);let c=Je;try{if(await S(o,r.code,s),await bs(r.stateKey??Me),Ye.current!==c)return;Fe(``),Ae(null),Ne(null),Le(!1),Re.current=0,K.success(o===n?e(`settings.mcp.page.toast.authorizationCompleted`):e(`settings.mcp.page.toast.authorizationCompletedFor`,{name:o}))}catch(n){Ye.current===c&&K.error(xs(n,e(`settings.mcp.page.toast.authorizationCompleteFailed`),t))}finally{Ye.current===c&&De(!1)}},[Pe,Me,S,u,it,Je,n,e,t]),lt=Q.useCallback(async()=>{if(!(!n||!it())){if(!le){K.error(e(`settings.mcp.page.toast.enableServerBeforeTest`));return}Te(!0);try{let t=await w(n,u),r=t.status?.status;t.warning?K.warning(t.warning):r===`connected`?K.success(e(`settings.mcp.page.toast.connectionTestSucceeded`)):r===`needs_auth`?K.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):r===`needs_client_registration`?K.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):r===`failed`?K.error(t.status?.error||t.error||e(`settings.mcp.page.toast.connectionTestFailed`)):t.error?K.error(t.error):K.message(e(`settings.mcp.page.toast.connectionTestFinished`))}catch(t){K.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionTestFailed`))}finally{Te(!1)}}},[le,u,it,n,e,w]);if(Q.useEffect(()=>{if(!Ie||!n)return;let t=!1,r=null,i=()=>{Le(!1),Re.current=0,ze.current=!1},a=async()=>{try{let o=await Nr(H,u,d);if(t)return;Re.current+=1;let s=o[n];if(s?.status===`connected`){i(),Ae(null),Fe(``),K.success(e(`settings.mcp.page.toast.authorizationCompleted`));return}if(s?.status===`failed`){i(),K.error(s.error||e(`settings.mcp.page.toast.authorizationFailed`));return}if(s&&ze.current&&s.status!==`needs_auth`&&s.status!==`needs_client_registration`){i(),Ae(null),Fe(``);return}if(Re.current>=30){i(),K.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}catch{if(t)return;if(Re.current+=1,Re.current>=30){i(),K.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}};return r=window.setTimeout(()=>void a(),2e3),()=>{t=!0,r!==null&&window.clearTimeout(r)}},[Ie,u,n,e,d]),f.isError&&!f.data)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)] text-center`,children:f.error.message})});if(!n)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.mcp.page.empty.selectServer`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.mcp.page.empty.addNewOne`)})]})});let ut=g[n],dt=n?v[n]:void 0,ft=ut??dt??(p.isError&&!p.data?{status:`failed`,error:p.error.message}:void 0),pt=ut?.status===`connected`,mt=ut?.status===`needs_auth`||ut?.status===`needs_client_registration`,ht=_?null:_s(n,u),gt=ms(ft?.status,t,ft&&`error`in ft?ft.error:void 0),_t=t=>{switch(t){case`connected`:return e(`settings.mcp.page.status.label.connected`);case`failed`:return e(`settings.mcp.page.status.label.failed`);case`needs_auth`:return e(`settings.mcp.page.status.label.needsAuth`);case`needs_client_registration`:return e(`settings.mcp.page.status.label.needsRegistration`);default:return t}};return(0,$.jsxs)(yr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[E?(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.mcp.page.header.newServer`)}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:n}),(0,$.jsx)(ps,{status:ft?.status,enabled:le,getStatusLabel:_t,variant:`pill`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:E?e(`settings.mcp.page.header.configureNewServer`):e(`settings.mcp.page.header.transport`,{type:e(j===`local`?`settings.mcp.page.transport.local`:`settings.mcp.page.transport.remote`)})}),!E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:pt?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:rt,disabled:ve||!le,children:e(ve?`settings.mcp.page.actions.working`:pt?`settings.mcp.page.actions.disconnect`:`settings.mcp.page.actions.connect`)}),j===`remote`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:mt?`default`:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void at(),disabled:be||!le,children:e(be?`settings.mcp.page.actions.starting`:mt?`settings.mcp.page.actions.authorize`:`settings.mcp.page.actions.reauthorize`)}),(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void ot(),disabled:Se||!le,children:e(Se?`settings.mcp.page.actions.clearing`:`settings.mcp.page.actions.clearAuth`)})]}),pt&&(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void lt(),disabled:we||!le,children:e(we?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.test`)})]})]})]})}),!E&&gs(ft?.status,Oe,mt,Ie)&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsxs)(`div`,{className:q(`rounded-lg border p-3`,hs(ft?.status)),children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.status.runtimeStatus`)}),(0,$.jsx)(ps,{status:ft?.status,enabled:le,getStatusLabel:_t})]}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:gt}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80`,children:k===`project`?e(`settings.mcp.page.status.projectScopedTo`,{directory:u??e(`settings.mcp.page.status.activeProject`)}):e(`settings.mcp.page.status.userScoped`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:!pt&&(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void lt(),disabled:we||!le,children:e(we?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.testConnection`)})}),Oe&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.authorizationUrl`)}),(0,$.jsx)(`div`,{className:`break-all typography-micro text-foreground font-mono`,children:Oe}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void xr(Oe),children:[(0,$.jsx)(J,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.openInBrowser`)]}),(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void st(),children:[(0,$.jsx)(J,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.copyLink`)]})]})]})}),j===`remote`&&(mt||Ie||Oe)&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.auth.manualFallbackTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.manualFallbackDescription`)})]}),(0,$.jsx)(br,{embedded:!0,value:Pe,onChange:e=>Fe(e.target.value),placeholder:e(`settings.mcp.page.auth.callbackInputPlaceholder`),rows:3,className:`font-mono typography-meta resize-y`,"data-bwignore":`true`,"data-1p-ignore":`true`,spellCheck:!1}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ct(),disabled:Ee,children:e(Ee?`settings.mcp.page.actions.completing`:`settings.mcp.page.actions.completeAuthorization`)})})]})})]}),Ie&&(0,$.jsx)(`p`,{className:`mt-4 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.waitingForOpenCode`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.server`,children:(0,$.jsx)(Z,{label:e(`settings.mcp.page.server.title`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[E&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col sm:w-56 shrink-0`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.name`)})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial`,children:[(0,$.jsx)(ln,{value:D,onChange:e=>O(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,`-`)),placeholder:e(`settings.mcp.page.server.namePlaceholder`),className:`h-7 w-48 font-mono px-2`,autoFocus:!0}),(0,$.jsxs)(an,{value:k,onValueChange:e=>A(e),children:[(0,$.jsx)(tn,{className:`!h-7 !w-7 !min-w-0 !px-0 !py-0 justify-center [&>svg:last-child]:hidden`,title:e(k===`user`?`settings.common.scope.global`:`settings.common.scope.project`),children:k===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(nn,{align:`end`,children:[(0,$.jsx)($t,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)($t,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]})]}),E&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:Qe,type:`button`,title:e(`settings.mcp.page.server.importJsonTitle`),children:[(0,$.jsx)(J,{name:`file-code`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.server.importJson`)]})}),(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":le,onClick:()=>ue(!le),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ue(!le))},children:[(0,$.jsx)(Qt,{checked:le,onChange:ue,ariaLabel:e(`settings.mcp.page.server.enableAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.enable`)})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col sm:w-56 shrink-0`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.transportMode`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":j===`local`,onClick:()=>M(`local`),className:`!font-normal`,children:e(`settings.mcp.page.transport.local`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":j===`remote`,onClick:()=>M(`remote`),className:`!font-normal`,children:e(`settings.mcp.page.transport.remote`)})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.command`,children:j===`local`?(0,$.jsx)(Z,{label:e(`settings.mcp.page.connection.command`),cardClassName:`p-3`,children:(0,$.jsx)(us,{value:N,onChange:P,pasteCommandTitle:e(`settings.mcp.page.connection.pasteCommandTitle`),pasteCommandLabel:e(`settings.mcp.page.connection.pasteCommand`),pasteSuccess:t=>e(`settings.mcp.page.toast.pastedArgumentsCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),preview:t=>e(`settings.mcp.page.connection.previewArgs`,{count:t})})}):(0,$.jsx)(Z,{children:(0,$.jsx)(Fr,{label:e(`settings.mcp.page.connection.serverUrl`),children:(0,$.jsx)(ln,{value:F,onChange:e=>I(e.target.value),placeholder:e(`settings.mcp.page.connection.serverUrlPlaceholder`),className:`font-mono typography-meta`})})})}),j===`remote`&&(0,$.jsx)(`div`,{"data-settings-item":`mcp.advanced`,children:(0,$.jsx)(Z,{label:e(`settings.mcp.page.advanced.title`),cardClassName:`p-3`,children:(0,$.jsxs)(Si,{open:Be,onOpenChange:Ve,children:[(0,$.jsxs)(xi,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.mcp.page.advanced.configure`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,e(V?`settings.mcp.page.advanced.autoDetect`:`settings.mcp.page.advanced.custom`),` · `,z.length,` `,e(`settings.mcp.page.advanced.headers`),se?` · ${se}ms`:``,`)`]})]}),Be?(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(bi,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Fr,{label:e(`settings.mcp.page.advanced.timeoutMs`),description:e(`settings.mcp.page.advanced.timeoutHint`),children:(0,$.jsx)(ln,{type:`number`,min:`1`,step:`1`,value:se,onChange:e=>ce(e.target.value),placeholder:`5000`,className:`w-32 font-mono`,"data-bwignore":`true`,"data-1p-ignore":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 typography-ui-label text-foreground`,children:[e(`settings.mcp.page.advanced.requestHeaders`),z.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,z.length,`)`]})]}),(0,$.jsx)(fs,{value:z,onChange:B,keyTransform:e=>e.trimStart(),keyPlaceholder:e(`settings.mcp.page.advanced.headerNamePlaceholder`),keyInputClassName:`w-36 shrink-0 font-mono typography-meta`,pasteLabel:e(`settings.mcp.page.advanced.pasteHeaders`),pasteTitle:e(`settings.mcp.page.advanced.pasteHeadersTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-1.5`,role:`button`,tabIndex:0,"aria-pressed":V,onClick:()=>ee(!V),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ee(!V))},children:[(0,$.jsx)(Qt,{checked:V,onChange:ee,ariaLabel:e(`settings.mcp.page.advanced.oauthAutoDetectionAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.advanced.oauthAutoDetection`)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(ln,{value:U,onChange:e=>te(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientIdPlaceholder`),className:`font-mono typography-meta`,disabled:!V,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(ln,{value:W,onChange:e=>ne(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientSecretPlaceholder`),className:`font-mono typography-meta`,disabled:!V,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(ln,{value:re,onChange:e=>ie(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthScopesPlaceholder`),className:`font-mono typography-meta`,disabled:!V,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(ln,{value:ae,onChange:e=>oe(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthRedirectUriPlaceholder`),className:`font-mono typography-meta`,disabled:!V,"data-bwignore":`true`,"data-1p-ignore":`true`})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.advanced.oauthHint`)}),ht&&(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.mcp.page.advanced.oauthCallbackHint`),(0,$.jsx)(`span`,{className:`mt-1 block break-all font-mono text-foreground/80`,children:ht})]})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.environment`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`span`,{children:[e(`settings.mcp.page.env.title`),L.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,L.length,`)`]})]}),cardClassName:`p-3`,children:L.length===0?(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:()=>R([{key:``,value:``}]),children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.env.addEnvironmentVariable`)]}):(0,$.jsx)(fs,{value:L,onChange:R,keyPlaceholder:e(`settings.mcp.page.env.keyPlaceholder`),pasteLabel:e(`settings.mcp.page.env.pasteEnv`),pasteTitle:e(`settings.mcp.page.env.pasteEnvTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{onClick:G,disabled:de||!tt&&!E,size:`xs`,className:`!font-normal`,children:e(de?`settings.common.actions.saving`:E?`settings.common.actions.create`:`settings.common.actions.saveChanges`)}),!E&&(0,$.jsx)(Y,{variant:`destructive`,size:`xs`,className:`!font-normal`,onClick:()=>me(!0),children:e(`settings.common.actions.delete`)})]})]}),(0,$.jsx)(Jt,{open:He,onOpenChange:e=>{e||(Ue(!1),Ge(``),qe(null))},children:(0,$.jsxs)(Gt,{className:`max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.mcp.page.importDialog.title`)}),(0,$.jsx)(qt,{children:e(`settings.mcp.page.importDialog.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(br,{value:We,onChange:e=>{Ge(e.target.value),qe(null)},placeholder:`{
|
|
13
|
+
postgresql://user:pass@host/db`,rows:Math.max(4,e.length+1),className:`font-mono typography-meta resize-y min-h-[80px]`,spellCheck:!1}),e.length>0&&(0,$.jsxs)(`details`,{className:`group`,children:[(0,$.jsx)(`summary`,{className:`typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground`,children:o(e.length)}),(0,$.jsx)(`div`,{className:`mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto`,children:(0,$.jsx)(`code`,{className:`typography-micro text-foreground/80 whitespace-pre`,children:e.map((e,t)=>(0,$.jsxs)(`span`,{className:`block`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground select-none mr-2`,children:[`[`,t,`]`]}),e]},t))})})]})]})},fs=e=>e.toUpperCase().replace(/[^A-Z0-9_]/g,`_`),ps=({value:e,onChange:t,keyTransform:n=fs,keyPlaceholder:r=`API_KEY`,keyInputClassName:i=`w-36 shrink-0 font-mono typography-meta uppercase`,pasteLabel:a=`Paste .env`,pasteTitle:o=`Paste KEY=VALUE lines from clipboard`,noPairsFoundError:s,importSuccess:c,clipboardReadFailed:l,keyLabel:u,valueLabel:d,valuePlaceholder:f,hideValueTitle:p,showValueTitle:m,addVariable:h,plainTextWarning:g,removeVariableAria:_})=>{let[v,y]=Q.useState(new Set),b=()=>t([...e,{key:``,value:``}]),x=n=>{t(e.filter((e,t)=>t!==n)),y(e=>{let t=new Set(e);return t.delete(n),t})},S=(n,r,i)=>{let a=[...e];a[n]={...a[n],[r]:i},t(a)},C=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},w=async()=>{try{let n=await navigator.clipboard.readText(),r=[];for(let e of n.split(`
|
|
14
|
+
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.indexOf(`=`);if(n===-1)continue;let i=t.slice(0,n).trim(),a=t.slice(n+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`))&&(a=a.slice(1,-1)),i&&r.push({key:i,value:a})}if(r.length===0){K.error(s);return}let i=[...e];for(let e of r){let t=i.findIndex(t=>t.key===e.key);t===-1?i.push(e):i[t]=e}t(i),K.success(c(r.length))}catch{K.error(l)}},T=e.some(e=>e.value.length>0);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground w-32 shrink-0`,children:u}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:d})]}),(0,$.jsxs)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:w,type:`button`,title:o,children:[(0,$.jsx)(J,{name:`clipboard`,className:`h-3 w-3`}),a]})]}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(un,{value:e.key,onChange:e=>S(t,`key`,n(e.target.value)),placeholder:r,className:i,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsxs)(`div`,{className:`relative flex-1 flex items-center`,children:[(0,$.jsx)(un,{type:v.has(t)?`text`:`password`,value:e.value,onChange:e=>S(t,`value`,e.target.value),placeholder:f,className:`font-mono typography-meta pr-8 w-full`,autoComplete:`new-password`,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`absolute right-2 text-muted-foreground/60 hover:text-muted-foreground`,title:v.has(t)?p:m,children:v.has(t)?(0,$.jsx)(J,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`eye`,className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(t),"aria-label":_,children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]},t))}),(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:b,type:`button`,children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),h]}),T&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:g})]})},ms=e=>{let t=(0,Di.c)(14),{status:n,enabled:r,getStatusLabel:i,variant:a}=e,o=a===void 0?`compact`:a;if(!r||!n)return null;let s,c;if(t[0]!==i||t[1]!==n||t[2]!==o){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e={connected:{text:`text-[var(--status-success)]`,bg:`bg-[var(--status-success)]/10`},failed:{text:`text-[var(--status-error)]`,bg:`bg-[var(--status-error)]/10`},needs_auth:{text:`text-[var(--status-warning)]`,bg:`bg-[var(--status-warning)]/10`},needs_client_registration:{text:`text-[var(--status-warning)]`,bg:`bg-[var(--status-warning)]/10`}}[n]??{text:`text-muted-foreground`,bg:``};if(o===`pill`){let r=q(`typography-micro font-medium rounded-full px-2 py-0.5`,e.text,e.bg),a;t[5]!==i||t[6]!==n?(a=i(n),t[5]=i,t[6]=n,t[7]=a):a=t[7],c=(0,$.jsxs)(`span`,{className:r,children:[`● `,a]});break bb0}s=q(`typography-micro font-medium`,e.text)}t[0]=i,t[1]=n,t[2]=o,t[3]=s,t[4]=c}else s=t[3],c=t[4];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[8]!==i||t[9]!==n?(l=i(n),t[8]=i,t[9]=n,t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`span`,{className:s,children:[`● `,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u},hs=(e,t,n)=>{switch(e){case`connected`:return t(`settings.mcp.page.status.description.connected`);case`failed`:return n?.trim()||t(`settings.mcp.page.status.description.failedDefault`);case`needs_auth`:return t(`settings.mcp.page.status.description.needsAuth`);case`needs_client_registration`:return n?.trim()||t(`settings.mcp.page.status.description.needsClientRegistrationDefault`);case`disabled`:return t(`settings.mcp.page.status.description.disabled`);default:return t(`settings.mcp.page.status.description.default`)}},gs=e=>{switch(e){case`failed`:return`border-[var(--status-error-border)] bg-[var(--status-error-background)]`;case`needs_auth`:case`needs_client_registration`:return`border-[var(--status-warning-border)] bg-[var(--status-warning-background)]`;default:return`border-[var(--interactive-border)] bg-[var(--surface-elevated)]`}},_s=(e,t,n,r)=>!!(e===`failed`||e===`needs_auth`||e===`needs_client_registration`||t||n||r),vs=(e,t)=>{if(typeof window>`u`)return null;let n=new URL(ii,r()||window.location.origin);return typeof e==`string`&&e.trim()&&n.searchParams.set(`server`,e.trim()),typeof t==`string`&&t.trim()&&n.searchParams.set(`directory`,t.trim()),n.toString()},ys=async e=>{let t=await L(`/api/mcp/auth/pending`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({state:e.state,name:e.name,directory:typeof e.directory==`string`&&e.directory.trim()?e.directory.trim():null})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||`Failed to prepare MCP authorization callback`)}},bs=async e=>{let t=await L(`/api/mcp/auth/pending?state=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json().catch(()=>null);return n?.name?.trim()?{name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null}:null},xs=async e=>{typeof e!=`string`||!e.trim()||await L(`/api/mcp/auth/pending?state=${encodeURIComponent(e.trim())}`,{method:`DELETE`}).catch(()=>void 0)},Ss=(e,t,n)=>{let r=e instanceof Error?e.message:t;return/oauth state required/i.test(r)?n(`settings.mcp.page.toast.authSessionExpired`):r},Cs=(e,t,n)=>{let r=typeof t==`string`&&t.trim()?t.trim():`__global__`;return`${n}::${e??`__none__`}::${r}`},ws=()=>{let{t:e}=ke(),t=Q.useCallback((t,n)=>e(t,n),[e]),{selectedMcpName:n,mcpDraft:r,setMcpDraft:a,setSelectedMcp:o,createMcp:s,updateMcp:c,deleteMcp:l}=ea(he(e=>({selectedMcpName:e.selectedMcpName,mcpDraft:e.mcpDraft,setMcpDraft:e.setMcpDraft,setSelectedMcp:e.setSelectedMcp,createMcp:e.createMcp,updateMcp:e.updateMcp,deleteMcp:e.deleteMcp}))),u=Yr(),d=i(),f=Jr(u),p=Xr(u),h=f.data??[],g=p.data??{},_=Q.useMemo(()=>m(),[]),v=qr(e=>e.getDiagnosticForDirectory(u)),y=qr(e=>e.connect),b=qr(e=>e.disconnect),x=qr(e=>e.startAuth),S=qr(e=>e.completeAuth),C=qr(e=>e.clearAuth),w=qr(e=>e.testConnection),T=n?h.find(e=>e.name===n)??null:null,E=!!(r&&r.name===n&&!T),[D,O]=Q.useState(``),[k,A]=Q.useState(`user`),[j,M]=Q.useState(`local`),[N,P]=Q.useState([]),[F,I]=Q.useState(``),[L,R]=Q.useState([]),[z,B]=Q.useState([]),[V,ee]=Q.useState(!0),[U,te]=Q.useState(``),[W,ne]=Q.useState(``),[re,ie]=Q.useState(``),[ae,oe]=Q.useState(``),[se,ce]=Q.useState(``),[le,ue]=Q.useState(!0),[de,fe]=Q.useState(!1),[pe,me]=Q.useState(!1),[ge,_e]=Q.useState(!1),[ve,ye]=Q.useState(!1),[be,xe]=Q.useState(!1),[Se,Ce]=Q.useState(!1),[we,Te]=Q.useState(!1),[Ee,De]=Q.useState(!1),[Oe,Ae]=Q.useState(null),[Me,Ne]=Q.useState(null),[Pe,Fe]=Q.useState(``),[Ie,Le]=Q.useState(!1),Re=Q.useRef(0),ze=Q.useRef(!1),[Be,Ve]=Q.useState(!1),[He,Ue]=Q.useState(!1),[We,Ge]=Q.useState(``),[Ke,qe]=Q.useState(null),Je=Q.useMemo(()=>Cs(n,u,d),[u,n,d]),Ye=Q.useRef(Je),Xe=Q.useRef(null),Ze=Q.useCallback(()=>{Ae(null),Ne(null),Fe(``),Le(!1),Re.current=0,De(!1),xe(!1),Ce(!1),ze.current=!1},[]),Qe=Q.useCallback(()=>{Ge(``),qe(null),Ue(!0)},[]),$e=Q.useCallback(async()=>{try{let e=await navigator.clipboard.readText();Ge(e),qe(null)}catch{K.error(e(`settings.mcp.page.toast.clipboardReadFailed`))}},[e]),et=Q.useCallback(()=>{let t=os(We,{fallbackName:D});if(!t.ok){qe(t.error);return}let n=cs(t,{name:D,scope:k,type:j,command:N,url:F,environment:L,headers:z,oauthEnabled:V,oauthClientId:U,oauthClientSecret:W,oauthScope:re,oauthRedirectUri:ae,timeout:se,enabled:le},{isNewServer:E});O(n.name),M(n.type),P(n.command??[]),I(n.url??``),R(n.environment??[]),B(n.headers??[]),ee(n.oauthEnabled??!1),te(n.oauthClientId??``),ne(n.oauthClientSecret??``),ie(n.oauthScope??``),oe(n.oauthRedirectUri??``),ce(n.timeout??``),ue(n.enabled??!0),Ue(!1),Ge(``),qe(null),K.success(e(`settings.mcp.page.toast.configImported`))},[We,D,k,j,N,F,L,z,V,U,W,re,ae,se,le,E,e]);Q.useEffect(()=>{if(E&&r){O(r.name),A(r.scope||`user`),M(r.type),P(r.command),I(r.url),R(r.environment),B(r.headers),ee(r.oauthEnabled),te(r.oauthClientId),ne(r.oauthClientSecret),ie(r.oauthScope),oe(r.oauthRedirectUri),ce(r.timeout),ue(r.enabled),Ve(!1),Xe.current={mcpType:r.type,command:r.command,url:r.url,envEntries:r.environment,headerEntries:r.headers,oauthEnabled:r.oauthEnabled,oauthClientId:r.oauthClientId,oauthClientSecret:r.oauthClientSecret,oauthScope:r.oauthScope,oauthRedirectUri:r.oauthRedirectUri,timeout:r.timeout,enabled:r.enabled};return}if(T){A(T.scope===`project`?`project`:`user`);let e=Xi(T.environment),t=T.type===`remote`?T:null,n=Xi(t?.headers),r=t?.oauth,i=r&&typeof r==`object`?r:null,a=r!==!1,o=T.type,s=o===`local`?T.command??[]:[],c=o===`remote`?T.url??``:``,l=typeof t?.timeout==`number`&&Number.isFinite(t.timeout)?String(t.timeout):``;M(o),P(s),I(c),R(e),B(n),ee(a),te(a?i?.clientId??``:``),ne(a?i?.clientSecret??``:``),ie(a?i?.scope??``:``),oe(a?i?.redirectUri??``:``),ce(l),ue(T.enabled),Ve(!1),Xe.current={mcpType:o,command:s,url:c,envEntries:e,headerEntries:n,oauthEnabled:a,oauthClientId:a?i?.clientId??``:``,oauthClientSecret:a?i?.clientSecret??``:``,oauthScope:a?i?.scope??``:``,oauthRedirectUri:a?i?.redirectUri??``:``,timeout:l,enabled:T.enabled}}},[T,E,r]);let tt=Q.useMemo(()=>{let e=Xe.current;return e?j!==e.mcpType||le!==e.enabled||JSON.stringify(N)!==JSON.stringify(e.command)||F!==e.url||JSON.stringify(L)!==JSON.stringify(e.envEntries)||JSON.stringify(z)!==JSON.stringify(e.headerEntries)||V!==e.oauthEnabled||U!==e.oauthClientId||W!==e.oauthClientSecret||re!==e.oauthScope||ae!==e.oauthRedirectUri||se!==e.timeout:!1},[j,N,F,L,z,V,U,W,re,ae,se,le]),G=async()=>{let t=E?D.trim():n??``;if(!t){K.error(e(`settings.mcp.page.toast.nameRequired`));return}if(E&&h.some(e=>e.name===t)){K.error(e(`settings.mcp.page.toast.serverNameExists`));return}if(j===`local`&&N.filter(Boolean).length===0){K.error(e(`settings.mcp.page.toast.localCommandRequired`));return}if(j===`remote`&&!F.trim()){K.error(e(`settings.mcp.page.toast.remoteUrlRequired`));return}let r={name:t,scope:k,type:j,command:N,url:F,environment:L,headers:z,oauthEnabled:V,oauthClientId:U,oauthClientSecret:W,oauthScope:re,oauthRedirectUri:ae,timeout:se,enabled:le};fe(!0);try{let n={directory:Yr(),transportIdentity:i()},l=E?await s(r,n):await c(t,r,n);l.ok?(await xs(Me),Ze(),E&&(a(null),o(t)),l.reloadFailed?K.warning(l.message||e(E?`settings.mcp.page.toast.serverCreatedReloadFailed`:`settings.mcp.page.toast.savedReloadFailed`),{description:l.warning||e(`settings.mcp.page.toast.retryRefreshHint`)}):K.success(l.message||e(E?`settings.mcp.page.toast.serverCreatedReloading`:`settings.mcp.page.toast.savedReloading`))):K.error(e(`settings.mcp.page.toast.saveFailed`))}catch(t){K.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.unexpectedError`))}finally{fe(!1)}},nt=async()=>{if(!n)return;_e(!0);let t=await l(n,{directory:Yr(),transportIdentity:i()});t.ok?(await xs(Me),Ze(),t.reloadFailed?K.warning(t.message||e(`settings.mcp.page.toast.serverDeletedReloadFailed`,{name:n}),{description:t.warning||e(`settings.mcp.page.toast.refreshListIfStale`)}):K.success(t.message||e(`settings.mcp.page.toast.serverDeleted`,{name:n})),me(!1)):K.error(e(`settings.mcp.page.toast.deleteFailed`)),_e(!1)},rt=async()=>{if(n){ye(!0);try{if(g[n]?.status===`connected`)await b(n,u),K.success(e(`settings.mcp.page.toast.disconnected`));else{await y(n,u);let t=Fr(H,u)[n];t?.status===`connected`?K.success(e(`settings.mcp.page.toast.connected`)):t?.status===`needs_auth`?K.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):t?.status===`needs_client_registration`?K.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):t?.status===`failed`?K.error(t.error||e(`settings.mcp.page.toast.connectionFailed`)):K.message(e(`settings.mcp.page.toast.connectionAttemptFinished`));return}}catch(t){K.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionFailed`))}finally{ye(!1)}}},it=Q.useCallback(()=>E?(K.error(e(`settings.mcp.page.toast.createServerBeforeLiveActions`)),!1):!tt||(K.error(e(`settings.mcp.page.toast.saveBeforeLiveActions`)),!1),[tt,E,e]);Q.useEffect(()=>{Ye.current=Je,ye(!1),Te(!1),Ze()},[Ze,Je]);let at=Q.useCallback(async()=>{if(!n||j!==`remote`||!it())return;xe(!0);let r=Je,i=null;try{let t=Fr(H,u)[n]?.status;ze.current=t===`needs_auth`||t===`needs_client_registration`;let a=vs(n,u);if(!a)throw Error(e(`settings.mcp.page.toast.oauthRedirectUrlBuildFailed`));if(!ae.trim()&&!_){let t=await c(n,{oauthEnabled:V,oauthClientId:U,oauthClientSecret:W,oauthScope:re,oauthRedirectUri:a});if(!t.ok)throw Error(e(`settings.mcp.page.toast.oauthBrowserCallbackSaveFailed`));if(t.reloadFailed)throw Error(t.warning||t.message||e(`settings.mcp.page.toast.openCodeReloadFailedAfterCallbackSave`));if(Ye.current!==r)return;oe(a),Xe.current=Xe.current?{...Xe.current,oauthRedirectUri:a}:Xe.current}let o=await x(n,u),s=Rr(new URL(o).searchParams);if(s&&(i=s,await ys({state:s,name:n,directory:u})),Ye.current!==r)return;Ae(o),Ne(s??null),Le(!0),Re.current=0;let l=await Sr(o);if(Ye.current!==r)return;l?K.message(e(_?`settings.mcp.page.toast.completeAuthorizationInBrowserWithPaste`:`settings.mcp.page.toast.completeAuthorizationInBrowser`)):K.error(e(`settings.mcp.page.toast.openAuthorizationUrlFailed`))}catch(n){await xs(i),Ye.current===r&&K.error(Ss(n,e(`settings.mcp.page.toast.authorizationStartFailed`),t))}finally{Ye.current===r&&xe(!1)}},[_,u,j,U,W,V,ae,re,it,Je,n,x,e,t,c]),ot=Q.useCallback(async()=>{if(!n||!it())return;Ce(!0);let r=Je;try{if(await C(n,u),Ye.current!==r)return;Ae(null),Ne(null),Fe(``),Le(!1),Re.current=0,await xs(Me),K.success(e(`settings.mcp.page.toast.savedAuthorizationRemoved`))}catch(n){Ye.current===r&&K.error(Ss(n,e(`settings.mcp.page.toast.clearAuthorizationFailed`),t))}finally{Ye.current===r&&Ce(!1)}},[Me,C,u,it,Je,n,e,t]),st=Q.useCallback(async()=>{if(Oe){if((await je(Oe)).ok){K.success(e(`settings.mcp.page.toast.authorizationUrlCopied`));return}K.error(e(`settings.mcp.page.toast.authorizationUrlCopyFailed`))}},[Oe,e]),ct=Q.useCallback(async()=>{let r=us(Pe);if(!r.code){K.error(e(`settings.mcp.page.toast.pasteCallbackOrCodeFirst`));return}let i=r.stateKey?await bs(r.stateKey):null,a=r.context??i,o=a?.name??n,s=a?.directory??u;if(!o){K.error(e(`settings.mcp.page.toast.missingServerDetails`));return}if(!a&&!it())return;De(!0);let c=Je;try{if(await S(o,r.code,s),await xs(r.stateKey??Me),Ye.current!==c)return;Fe(``),Ae(null),Ne(null),Le(!1),Re.current=0,K.success(o===n?e(`settings.mcp.page.toast.authorizationCompleted`):e(`settings.mcp.page.toast.authorizationCompletedFor`,{name:o}))}catch(n){Ye.current===c&&K.error(Ss(n,e(`settings.mcp.page.toast.authorizationCompleteFailed`),t))}finally{Ye.current===c&&De(!1)}},[Pe,Me,S,u,it,Je,n,e,t]),lt=Q.useCallback(async()=>{if(!(!n||!it())){if(!le){K.error(e(`settings.mcp.page.toast.enableServerBeforeTest`));return}Te(!0);try{let t=await w(n,u),r=t.status?.status;t.warning?K.warning(t.warning):r===`connected`?K.success(e(`settings.mcp.page.toast.connectionTestSucceeded`)):r===`needs_auth`?K.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):r===`needs_client_registration`?K.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):r===`failed`?K.error(t.status?.error||t.error||e(`settings.mcp.page.toast.connectionTestFailed`)):t.error?K.error(t.error):K.message(e(`settings.mcp.page.toast.connectionTestFinished`))}catch(t){K.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionTestFailed`))}finally{Te(!1)}}},[le,u,it,n,e,w]);if(Q.useEffect(()=>{if(!Ie||!n)return;let t=!1,r=null,i=()=>{Le(!1),Re.current=0,ze.current=!1},a=async()=>{try{let o=await Pr(H,u,d);if(t)return;Re.current+=1;let s=o[n];if(s?.status===`connected`){i(),Ae(null),Fe(``),K.success(e(`settings.mcp.page.toast.authorizationCompleted`));return}if(s?.status===`failed`){i(),K.error(s.error||e(`settings.mcp.page.toast.authorizationFailed`));return}if(s&&ze.current&&s.status!==`needs_auth`&&s.status!==`needs_client_registration`){i(),Ae(null),Fe(``);return}if(Re.current>=30){i(),K.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}catch{if(t)return;if(Re.current+=1,Re.current>=30){i(),K.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}};return r=window.setTimeout(()=>void a(),2e3),()=>{t=!0,r!==null&&window.clearTimeout(r)}},[Ie,u,n,e,d]),f.isError&&!f.data)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)] text-center`,children:f.error.message})});if(!n)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.mcp.page.empty.selectServer`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.mcp.page.empty.addNewOne`)})]})});let ut=g[n],dt=n?v[n]:void 0,ft=ut??dt??(p.isError&&!p.data?{status:`failed`,error:p.error.message}:void 0),pt=ut?.status===`connected`,mt=ut?.status===`needs_auth`||ut?.status===`needs_client_registration`,ht=_?null:vs(n,u),gt=hs(ft?.status,t,ft&&`error`in ft?ft.error:void 0),_t=t=>{switch(t){case`connected`:return e(`settings.mcp.page.status.label.connected`);case`failed`:return e(`settings.mcp.page.status.label.failed`);case`needs_auth`:return e(`settings.mcp.page.status.label.needsAuth`);case`needs_client_registration`:return e(`settings.mcp.page.status.label.needsRegistration`);default:return t}};return(0,$.jsxs)(br,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[E?(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.mcp.page.header.newServer`)}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:n}),(0,$.jsx)(ms,{status:ft?.status,enabled:le,getStatusLabel:_t,variant:`pill`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:E?e(`settings.mcp.page.header.configureNewServer`):e(`settings.mcp.page.header.transport`,{type:e(j===`local`?`settings.mcp.page.transport.local`:`settings.mcp.page.transport.remote`)})}),!E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:pt?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:rt,disabled:ve||!le,children:e(ve?`settings.mcp.page.actions.working`:pt?`settings.mcp.page.actions.disconnect`:`settings.mcp.page.actions.connect`)}),j===`remote`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:mt?`default`:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void at(),disabled:be||!le,children:e(be?`settings.mcp.page.actions.starting`:mt?`settings.mcp.page.actions.authorize`:`settings.mcp.page.actions.reauthorize`)}),(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void ot(),disabled:Se||!le,children:e(Se?`settings.mcp.page.actions.clearing`:`settings.mcp.page.actions.clearAuth`)})]}),pt&&(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void lt(),disabled:we||!le,children:e(we?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.test`)})]})]})]})}),!E&&_s(ft?.status,Oe,mt,Ie)&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsxs)(`div`,{className:q(`rounded-lg border p-3`,gs(ft?.status)),children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.status.runtimeStatus`)}),(0,$.jsx)(ms,{status:ft?.status,enabled:le,getStatusLabel:_t})]}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:gt}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80`,children:k===`project`?e(`settings.mcp.page.status.projectScopedTo`,{directory:u??e(`settings.mcp.page.status.activeProject`)}):e(`settings.mcp.page.status.userScoped`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:!pt&&(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void lt(),disabled:we||!le,children:e(we?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.testConnection`)})}),Oe&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.authorizationUrl`)}),(0,$.jsx)(`div`,{className:`break-all typography-micro text-foreground font-mono`,children:Oe}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Sr(Oe),children:[(0,$.jsx)(J,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.openInBrowser`)]}),(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void st(),children:[(0,$.jsx)(J,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.copyLink`)]})]})]})}),j===`remote`&&(mt||Ie||Oe)&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.auth.manualFallbackTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.manualFallbackDescription`)})]}),(0,$.jsx)(xr,{embedded:!0,value:Pe,onChange:e=>Fe(e.target.value),placeholder:e(`settings.mcp.page.auth.callbackInputPlaceholder`),rows:3,className:`font-mono typography-meta resize-y`,"data-bwignore":`true`,"data-1p-ignore":`true`,spellCheck:!1}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ct(),disabled:Ee,children:e(Ee?`settings.mcp.page.actions.completing`:`settings.mcp.page.actions.completeAuthorization`)})})]})})]}),Ie&&(0,$.jsx)(`p`,{className:`mt-4 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.waitingForOpenCode`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.server`,children:(0,$.jsx)(Z,{label:e(`settings.mcp.page.server.title`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[E&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col sm:w-56 shrink-0`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.name`)})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial`,children:[(0,$.jsx)(un,{value:D,onChange:e=>O(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,`-`)),placeholder:e(`settings.mcp.page.server.namePlaceholder`),className:`h-7 w-48 font-mono px-2`,autoFocus:!0}),(0,$.jsxs)(on,{value:k,onValueChange:e=>A(e),children:[(0,$.jsx)(nn,{className:`!h-7 !w-7 !min-w-0 !px-0 !py-0 justify-center [&>svg:last-child]:hidden`,title:e(k===`user`?`settings.common.scope.global`:`settings.common.scope.project`),children:k===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(rn,{align:`end`,children:[(0,$.jsx)(en,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(en,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]})]}),E&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:Qe,type:`button`,title:e(`settings.mcp.page.server.importJsonTitle`),children:[(0,$.jsx)(J,{name:`file-code`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.server.importJson`)]})}),(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":le,onClick:()=>ue(!le),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ue(!le))},children:[(0,$.jsx)($t,{checked:le,onChange:ue,ariaLabel:e(`settings.mcp.page.server.enableAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.enable`)})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col sm:w-56 shrink-0`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.transportMode`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":j===`local`,onClick:()=>M(`local`),className:`!font-normal`,children:e(`settings.mcp.page.transport.local`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":j===`remote`,onClick:()=>M(`remote`),className:`!font-normal`,children:e(`settings.mcp.page.transport.remote`)})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.command`,children:j===`local`?(0,$.jsx)(Z,{label:e(`settings.mcp.page.connection.command`),cardClassName:`p-3`,children:(0,$.jsx)(ds,{value:N,onChange:P,pasteCommandTitle:e(`settings.mcp.page.connection.pasteCommandTitle`),pasteCommandLabel:e(`settings.mcp.page.connection.pasteCommand`),pasteSuccess:t=>e(`settings.mcp.page.toast.pastedArgumentsCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),preview:t=>e(`settings.mcp.page.connection.previewArgs`,{count:t})})}):(0,$.jsx)(Z,{children:(0,$.jsx)(Ir,{label:e(`settings.mcp.page.connection.serverUrl`),children:(0,$.jsx)(un,{value:F,onChange:e=>I(e.target.value),placeholder:e(`settings.mcp.page.connection.serverUrlPlaceholder`),className:`font-mono typography-meta`})})})}),j===`remote`&&(0,$.jsx)(`div`,{"data-settings-item":`mcp.advanced`,children:(0,$.jsx)(Z,{label:e(`settings.mcp.page.advanced.title`),cardClassName:`p-3`,children:(0,$.jsxs)(Ci,{open:Be,onOpenChange:Ve,children:[(0,$.jsxs)(Si,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.mcp.page.advanced.configure`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,e(V?`settings.mcp.page.advanced.autoDetect`:`settings.mcp.page.advanced.custom`),` · `,z.length,` `,e(`settings.mcp.page.advanced.headers`),se?` · ${se}ms`:``,`)`]})]}),Be?(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(xi,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Ir,{label:e(`settings.mcp.page.advanced.timeoutMs`),description:e(`settings.mcp.page.advanced.timeoutHint`),children:(0,$.jsx)(un,{type:`number`,min:`1`,step:`1`,value:se,onChange:e=>ce(e.target.value),placeholder:`5000`,className:`w-32 font-mono`,"data-bwignore":`true`,"data-1p-ignore":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 typography-ui-label text-foreground`,children:[e(`settings.mcp.page.advanced.requestHeaders`),z.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,z.length,`)`]})]}),(0,$.jsx)(ps,{value:z,onChange:B,keyTransform:e=>e.trimStart(),keyPlaceholder:e(`settings.mcp.page.advanced.headerNamePlaceholder`),keyInputClassName:`w-36 shrink-0 font-mono typography-meta`,pasteLabel:e(`settings.mcp.page.advanced.pasteHeaders`),pasteTitle:e(`settings.mcp.page.advanced.pasteHeadersTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-1.5`,role:`button`,tabIndex:0,"aria-pressed":V,onClick:()=>ee(!V),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ee(!V))},children:[(0,$.jsx)($t,{checked:V,onChange:ee,ariaLabel:e(`settings.mcp.page.advanced.oauthAutoDetectionAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.advanced.oauthAutoDetection`)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(un,{value:U,onChange:e=>te(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientIdPlaceholder`),className:`font-mono typography-meta`,disabled:!V,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(un,{value:W,onChange:e=>ne(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientSecretPlaceholder`),className:`font-mono typography-meta`,disabled:!V,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(un,{value:re,onChange:e=>ie(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthScopesPlaceholder`),className:`font-mono typography-meta`,disabled:!V,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(un,{value:ae,onChange:e=>oe(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthRedirectUriPlaceholder`),className:`font-mono typography-meta`,disabled:!V,"data-bwignore":`true`,"data-1p-ignore":`true`})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.advanced.oauthHint`)}),ht&&(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.mcp.page.advanced.oauthCallbackHint`),(0,$.jsx)(`span`,{className:`mt-1 block break-all font-mono text-foreground/80`,children:ht})]})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.environment`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`span`,{children:[e(`settings.mcp.page.env.title`),L.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,L.length,`)`]})]}),cardClassName:`p-3`,children:L.length===0?(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:()=>R([{key:``,value:``}]),children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.env.addEnvironmentVariable`)]}):(0,$.jsx)(ps,{value:L,onChange:R,keyPlaceholder:e(`settings.mcp.page.env.keyPlaceholder`),pasteLabel:e(`settings.mcp.page.env.pasteEnv`),pasteTitle:e(`settings.mcp.page.env.pasteEnvTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{onClick:G,disabled:de||!tt&&!E,size:`xs`,className:`!font-normal`,children:e(de?`settings.common.actions.saving`:E?`settings.common.actions.create`:`settings.common.actions.saveChanges`)}),!E&&(0,$.jsx)(Y,{variant:`destructive`,size:`xs`,className:`!font-normal`,onClick:()=>me(!0),children:e(`settings.common.actions.delete`)})]})]}),(0,$.jsx)(Yt,{open:He,onOpenChange:e=>{e||(Ue(!1),Ge(``),qe(null))},children:(0,$.jsxs)(Kt,{className:`max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.mcp.page.importDialog.title`)}),(0,$.jsx)(Jt,{children:e(`settings.mcp.page.importDialog.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(xr,{value:We,onChange:e=>{Ge(e.target.value),qe(null)},placeholder:`{
|
|
15
15
|
"mcpServers": {
|
|
16
16
|
"postgres": {
|
|
17
17
|
"command": "npx",
|
|
18
18
|
"args": ["-y", "@modelcontextprotocol/server-postgres"]
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
}`,rows:8,className:`font-mono typography-meta resize-y`,spellCheck:!1,"data-bwignore":`true`,"data-1p-ignore":`true`}),Ke&&(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-error)]`,children:Ke}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:$e,type:`button`,children:[(0,$.jsx)(J,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.importDialog.pasteFromClipboard`)]})})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{variant:`outline`,onClick:()=>{Ue(!1),Ge(``),qe(null)},className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{onClick:et,disabled:!We.trim(),size:`sm`,children:e(`settings.common.actions.import`)})]})]})}),(0,$.jsx)(Jt,{open:pe,onOpenChange:e=>{!e&&!ge&&me(!1)},children:(0,$.jsxs)(Gt,{className:`max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.mcp.page.deleteDialog.title`,{name:n??``})}),(0,$.jsxs)(qt,{children:[e(`settings.mcp.page.deleteDialog.descriptionPrefix`),` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),`.`,` `,e(`settings.mcp.page.deleteDialog.descriptionSuffix`)]})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{variant:`outline`,onClick:()=>me(!1),disabled:ge,className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,size:`sm`,onClick:nt,disabled:ge,children:e(ge?`settings.mcp.page.actions.deleting`:`settings.common.actions.delete`)})]})]})})]})},ws=()=>{try{let e=ft.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=ye.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},Ts=800,Es=5e3,Ds=`__default__`,Os=new Map,ks=new Map,As=1500,js=e=>e?.trim()||Ds,Ms=e=>{Os.delete(js(e))},Ns=fe()(me(pe((e,t)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:t=>e({selectedId:t}),setDraft:t=>e({draft:t}),loadPlugins:async n=>{let r=ws(),i=js(r),a=Date.now(),o=Os.get(i)??0,s=t().entries.length>0||t().files.length>0;if(!n?.force&&s&&a-o<Es)return!0;let c=ks.get(i);if(!n?.force&&c)return c;let l=(async()=>{e({isLoading:!0});try{let a=await L(Ps(`/api/config/plugins`,r),{headers:Rs(r)});if(!a.ok)throw Error(`Failed to load plugins`);let o=await Hs(a);return e({entries:o.entries??[],files:o.files??[],isLoading:!1}),Os.set(i,Date.now()),n?.force||t().loadRegistryInfo(),!0}catch(t){return console.error(`[PluginsStore] Failed to load plugins:`,t),e({isLoading:!1}),!1}})();ks.set(i,l);try{return await l}finally{ks.delete(i)}},loadRegistryInfo:async n=>{let r=Is(n?.specs??t().entries.map(e=>e.spec));if(r.length===0){e({isLoadingRegistry:!1});return}e({isLoadingRegistry:!0});try{let i=ws(),a={...t().registryInfo};for(let e of Ls(r)){let t=await L(Fs(e,n?.force===!0,i),{headers:Rs(i)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let r=await Hs(t);for(let e of r.results??[])a[e.spec]=e}e({registryInfo:a,isLoadingRegistry:!1})}catch(t){console.error(`[PluginsStore] Failed to load plugin registry info:`,t),e({isLoadingRegistry:!1})}},updateToLatest:async e=>{let n=t().entries.find(t=>t.id===e);if(!n)return{ok:!1};let r=t().registryInfo[n.spec];return!r||r.kind!==`npm-ok`||!r.hasUpdate||!r.latestVersion?{ok:!1}:await t().updateEntry(e,{spec:`${r.name}@${r.latestVersion}`})},createEntry:async e=>{let n=await Vs(`Creating plugin entry…`,async t=>await L(Ps(`/api/config/plugins/entry`,t),{method:`POST`,headers:zs(t),body:JSON.stringify(Bs(e))}),t);return n.ok&&t().loadRegistryInfo({specs:[e.spec],force:!0}),n},updateEntry:async(e,n)=>{let r=t().entries.find(t=>t.id===e)?.spec,i=n.spec??r,a=await Vs(`Updating plugin entry…`,async t=>await L(Ps(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`PATCH`,headers:zs(t),body:JSON.stringify(Bs(n))}),t);return a.ok&&i&&t().loadRegistryInfo({specs:[i],force:!0}),a},deleteEntry:async n=>{let r=t().entries.find(e=>e.id===n),i=await Vs(`Deleting plugin entry…`,async e=>await L(Ps(`/api/config/plugins/entry/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:Rs(e)}),t);if(i.ok&&t().selectedId===n&&e({selectedId:null}),i.ok&&r){let n={...t().registryInfo};delete n[r.spec],e({registryInfo:n})}return i},readFile:async e=>{try{let t=ws(),n=await L(Ps(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:Rs(t)});if(!n.ok)throw Error(`Failed to read plugin file`);return await Hs(n)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Vs(`Creating plugin file…`,async t=>await L(Ps(`/api/config/plugins/file`,t),{method:`POST`,headers:zs(t),body:JSON.stringify(e)}),t),updateFile:async(e,n)=>Vs(`Updating plugin file…`,async t=>await L(Ps(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{method:`PUT`,headers:zs(t),body:JSON.stringify(n)}),t),deleteFile:async n=>{let r=await Vs(`Deleting plugin file…`,async e=>await L(Ps(`/api/config/plugins/file/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:Rs(e)}),t);return r.ok&&t().selectedId===n&&e({selectedId:null}),r},getById:e=>t().entries.find(t=>t.id===e)??t().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:p(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Ps(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Fs(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Is(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function Ls(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>As?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function Rs(e){return e?{"x-opencode-directory":e}:void 0}function zs(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Bs(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Vs(e,t,n){Ot(e);let r=!1;try{let e=ws(),i=await t(e),a=await Hs(i).catch(()=>null);if(!i.ok)throw Error(a?.error||`Failed to update plugin configuration`);return Ms(e),a?.requiresReload&&(r=!0,await St({message:a.message,delayMs:a.reloadDelayMs??Ts,scopes:[`all`]})),await n().loadPlugins({force:!0}),{ok:!0,reloadFailed:a?.reloadFailed===!0,message:a?.message,warning:a?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}finally{r||dt()}}async function Hs(e){return await e.json()}var Us=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function Ws(e){let t=e.trim();if(t===``)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}var Gs=({open:e,onOpenChange:t,defaultScope:n=`user`})=>{let{t:r}=ke(),i=Ns(e=>e.createEntry),a=Ns(e=>e.createFile),[o,s]=Q.useState(`npm`),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(n),[v,y]=Q.useState(!1),b=Q.useCallback(()=>{l(``),d(``),p(``),h(``),_(n)},[n]);Q.useEffect(()=>{e&&(s(`npm`),b())},[e,b]);let x=e=>{e!==o&&(s(e),b())},S=Q.useMemo(()=>Ws(u),[u]),C=!S.ok,w=o===`file`&&f.trim()!==``&&!Us.test(f.trim()),T=(o===`npm`||o===`path`)&&c.trim()===``,E=o===`file`&&m.trim()===``,D=o===`file`&&f.trim()===``,O=v||C||o===`npm`&&T||o===`path`&&T||o===`file`&&(D||w||E),k=async()=>{if(!O){y(!0);try{let e;e=o===`file`?await a({fileName:f.trim(),content:m,scope:g}):await i({spec:c.trim(),options:S.ok?S.value:void 0,scope:g}),e.ok?(K.success(e.message||r(`settings.plugins.toast.created`)),e.reloadFailed&&K.warning(r(`settings.plugins.toast.reloadFailed`)),t(!1)):K.error(e.message||r(`settings.plugins.sidebar.toast.deleteFailed`))}finally{y(!1)}}},A=Q.useMemo(()=>[{id:`npm`,label:r(`settings.plugins.dialog.add.tab.npm`)},{id:`path`,label:r(`settings.plugins.dialog.add.tab.path`)},{id:`file`,label:r(`settings.plugins.dialog.add.tab.file`)}],[r]);return(0,$.jsx)(Jt,{open:e,onOpenChange:e=>{!e&&v||t(e)},children:(0,$.jsxs)(Gt,{className:`max-w-xl`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:r(`settings.plugins.dialog.add.title`)}),(0,$.jsx)(qt,{children:r(`settings.plugins.sidebar.empty.description`)})]}),(0,$.jsx)(Cr,{items:A,activeId:o,onSelect:e=>x(e),layoutMode:`fit`,variant:`active-pill`,activePillLowercase:!1,className:`h-10`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(o===`npm`||o===`path`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.spec`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-spec`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.spec`)}),(0,$.jsx)(ln,{id:`plugin-spec`,value:c,onChange:e=>l(e.target.value),placeholder:r(`settings.plugins.page.field.spec.placeholder`),"aria-invalid":!T&&void 0,disabled:v}),T&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`settings.plugins.validation.specRequired`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`plugins.options`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-options`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.options`)}),(0,$.jsx)(br,{id:`plugin-options`,value:u,onChange:e=>d(e.target.value),rows:5,className:`font-mono`,hasError:C,disabled:v}),C&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.page.field.options.invalidJson`)})]})]}),o===`file`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.content`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-filename`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.fileName`)}),(0,$.jsx)(ln,{id:`plugin-filename`,value:f,onChange:e=>p(e.target.value),placeholder:`my-plugin.ts`,"aria-invalid":w||void 0,disabled:v}),w&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.validation.fileName`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-content`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.content`)}),(0,$.jsx)(br,{id:`plugin-content`,value:m,onChange:e=>h(e.target.value),rows:16,className:`font-mono`,disabled:v})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.scope`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-4`,children:[`user`,`project`].map(e=>{let t=g===e,n=r(e===`user`?`settings.plugins.scope.user`:`settings.plugins.scope.project`);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(e),disabled:v,className:`flex items-center gap-2 py-1 text-left disabled:opacity-50`,children:[(0,$.jsx)(Xn,{checked:t,onChange:()=>_(e),ariaLabel:n}),(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/60`),children:n})]},e)})})]})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>t(!1),disabled:v,children:r(`settings.plugins.dialog.add.action.cancel`)}),(0,$.jsxs)(Y,{size:`sm`,onClick:()=>{k()},disabled:O,children:[v?(0,$.jsx)(J,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}):null,r(`settings.plugins.dialog.add.action.submit`)]})]})]})})},Ks=e=>{let t=(0,Ei.c)(31),{info:n}=e,{t:r}=ke();if(!n)return null;let i=qs;switch(n.kind){case`npm-ok`:{if(!n.hasUpdate||!n.latestVersion)return null;let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`arrow-up-s`,className:`h-3 w-3`}),t[0]=e):e=t[0];let a;t[1]===n.latestVersion?a=t[2]:(a=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[var(--status-success)]`,children:[e,n.latestVersion]}),t[1]=n.latestVersion,t[2]=a);let o;return t[3]!==n.currentVersion||t[4]!==n.latestVersion||t[5]!==r||t[6]!==a?(o=i(a,r(`settings.plugins.registry.badge.update.tooltip`,{current:n.currentVersion??``,latest:n.latestVersion})),t[3]=n.currentVersion,t[4]=n.latestVersion,t[5]=r,t[6]=a,t[7]=o):o=t[7],o}case`npm-missing-version`:{let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[8]=e):e=t[8];let a;return t[9]!==n.currentVersion||t[10]!==n.name||t[11]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingVersion.tooltip`,{version:n.currentVersion,name:n.name})),t[9]=n.currentVersion,t[10]=n.name,t[11]=r,t[12]=a):a=t[12],a}case`npm-missing-package`:{let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[13]=e):e=t[13];let a;return t[14]!==n.name||t[15]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingPackage.tooltip`,{name:n.name})),t[14]=n.name,t[15]=r,t[16]=a):a=t[16],a}case`npm-malformed`:{let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[17]=e):e=t[17];let n;return t[18]===r?n=t[19]:(n=i(e,r(`settings.plugins.registry.badge.malformed.tooltip`)),t[18]=r,t[19]=n),n}case`npm-network`:{let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`cloud-off`,className:`h-3 w-3 text-muted-foreground`}),t[20]=e):e=t[20];let n;return t[21]===r?n=t[22]:(n=i(e,r(`settings.plugins.registry.badge.network.tooltip`)),t[21]=r,t[22]=n),n}case`path-missing`:{let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[23]=e):e=t[23];let a;return t[24]!==n.absolutePath||t[25]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathMissing.tooltip`,{path:n.absolutePath})),t[24]=n.absolutePath,t[25]=r,t[26]=a):a=t[26],a}case`path-unreadable`:{let e;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[27]=e):e=t[27];let a;return t[28]!==n.absolutePath||t[29]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathUnreadable.tooltip`,{path:n.absolutePath})),t[28]=n.absolutePath,t[29]=r,t[30]=a):a=t[30],a}case`path-ok`:return null;default:return null}};function qs(e,t){return(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 text-xs`,children:e})}),(0,$.jsx)(dn,{children:t})]})}var Js=1500,Ys=e=>e?.trim()||null,Xs=(e,t,n=!1,r=i())=>k.plugins.registry(e,t,n,r),Zs=(e,t,n=!1,r=i())=>{let a=Ys(e),o=R(t);return{queryKey:Xs(a,o,n,r),queryFn:async({signal:e})=>{let t={};for(let r of tc(o)){let i=await L(ec(r,n,a),{headers:nc(a),signal:e});if(!i.ok)throw Error(`Failed to load plugin registry info`);let o=await i.json();for(let e of o.results??[])t[e.spec]=e}return t},staleTime:n?0:3e5,retry:2}},Qs=(e,t)=>{let n=(0,Ei.c)(6),r=t!==void 0&&t,i=ft(rc),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=Zs(Ys(i)??Ys(ye.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),we(o)},$s=async(e=H,t,n)=>{let r=Ys(t),a=i(),o=await Zs(r,n,!0,a).queryFn({signal:new AbortController().signal});return e.setQueryData(Xs(r,n,!1,a),o),o};function ec(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function tc(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>Js){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function nc(e){return e?{"x-opencode-directory":e}:void 0}function rc(e){return e.getActiveProject?.()?.path??null}var ic=e=>e.parsedKind===`npm`?`code-box`:`folder`,ac=e=>{let t=(0,Ei.c)(139),{onItemSelect:n,onAddClick:r}=e,{t:i}=ke(),{entries:a,files:o,selectedId:s,setSelected:c,deleteEntry:l,deleteFile:u,loadPlugins:d,updateEntry:f}=Ns(he(oc)),p;t[0]===a?p=t[1]:(p=a.map(sc),t[0]=a,t[1]=p);let m=p,{data:h,isFetching:g}=Qs(m,!1),_;t[2]===h?_=t[3]:(_=h??{},t[2]=h,t[3]=_);let v=_,[y,b]=Q.useState(null),[x,S]=Q.useState(!1),[C,w]=Q.useState(!1),T,E;t[4]===d?(T=t[5],E=t[6]):(T=()=>{d()},E=[d],t[4]=d,t[5]=T,t[6]=E),Q.useEffect(T,E);let D,O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{let e=()=>w(!0);return window.addEventListener(`openchamber:settings-open-plugin-add`,e),()=>window.removeEventListener(`openchamber:settings-open-plugin-add`,e)},O=[],t[7]=D,t[8]=O):(D=t[7],O=t[8]),Q.useEffect(D,O);let k;if(t[9]!==a||t[10]!==v){k={userEntries:0,projectEntries:0};for(let e of a){let t=v[e.spec];t?.kind===`npm-ok`&&t.hasUpdate&&(e.scope===`user`?k.userEntries+=1:e.scope===`project`&&(k.projectEntries+=1))}t[9]=a,t[10]=v,t[11]=k}else k=t[11];let A=k,j;t[12]===a?j=t[13]:(j=a.filter(cc),t[12]=a,t[13]=j);let M=j,N;t[14]===a?N=t[15]:(N=a.filter(lc),t[14]=a,t[15]=N);let P=N,F;t[16]===o?F=t[17]:(F=o.filter(uc),t[16]=o,t[17]=F);let I=F,L;t[18]===o?L=t[19]:(L=o.filter(dc),t[18]=o,t[19]=L);let R=L,z=a.length+o.length===0,B;t[20]===r?B=t[21]:(B=()=>{r?r():w(!0)},t[20]=r,t[21]=B);let V=B,H;t[22]!==n||t[23]!==c?(H=e=>{c(e),n?.()},t[22]=n,t[23]=c,t[24]=H):H=t[24];let ee=H,U;t[25]!==a||t[26]!==v||t[27]!==i||t[28]!==f?(U=async e=>{let t=a.find(t=>t.id===e);if(!t)return;let n=v[t.spec];if(!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion)return;let r=n.latestVersion;(await f(e,{spec:`${n.name}@${r}`})).ok?K.success(i(`settings.plugins.toast.updatedToLatest`,{version:r})):K.error(i(`settings.plugins.toast.refreshFailed`))},t[25]=a,t[26]=v,t[27]=i,t[28]=f,t[29]=U):U=t[29];let te=U,W;t[30]!==m||t[31]!==i?(W=async()=>{K.info(i(`settings.plugins.toast.refreshing`));try{await $s(void 0,xt(),m)}catch{K.error(i(`settings.plugins.toast.refreshFailed`))}},t[30]=m,t[31]=i,t[32]=W):W=t[32];let ne=W,re;t[33]!==l||t[34]!==u||t[35]!==y||t[36]!==i?(re=async()=>{if(!y)return;S(!0);let e=y.kind===`entry`?await l(y.id):await u(y.id);e.ok?K.success(e.message||i(`settings.plugins.sidebar.toast.deleted`,{name:y.label})):K.error(i(`settings.plugins.sidebar.toast.deleteFailed`)),b(null),S(!1)},t[33]=l,t[34]=u,t[35]=y,t[36]=i,t[37]=re):re=t[37];let ie=re,ae;t[38]!==ee||t[39]!==te||t[40]!==v||t[41]!==s||t[42]!==i?(ae=e=>{let t=v[e.spec],n=t?.kind===`npm-ok`&&t.hasUpdate&&!!t.latestVersion,r=[];return n&&r.push({label:i(`settings.plugins.sidebar.actions.updateToLatest`),icon:`arrow-up-s`,onClick:()=>void te(e.id)}),r.push({label:i(`settings.common.actions.delete`),icon:`delete-bin`,destructive:!0,onClick:()=>b({kind:`entry`,id:e.id,label:e.spec})}),(0,$.jsx)(Za,{title:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.spec}),(0,$.jsx)(Ks,{info:t})]}),metadata:e.parsedKind===`npm`?i(`settings.plugins.sidebar.kind.npm`):i(`settings.plugins.sidebar.kind.path`),selected:s===e.id,onSelect:()=>ee(e.id),icon:(0,$.jsx)(J,{name:ic(e),className:`h-4 w-4 flex-shrink-0 text-muted-foreground/70`}),actions:r},e.id)},t[38]=ee,t[39]=te,t[40]=v,t[41]=s,t[42]=i,t[43]=ae):ae=t[43];let oe=ae,se;t[44]!==ee||t[45]!==s||t[46]!==i?(se=e=>(0,$.jsx)(Za,{title:e.fileName,metadata:i(`settings.plugins.sidebar.kind.file`),selected:s===e.id,onSelect:()=>ee(e.id),icon:(0,$.jsx)(J,{name:`file-text`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/70`}),actions:[{label:i(`settings.common.actions.delete`),icon:`delete-bin`,destructive:!0,onClick:()=>b({kind:`file`,id:e.id,label:e.fileName})}]},e.id),t[44]=ee,t[45]=s,t[46]=i,t[47]=se):se=t[47];let ce=se,le;t[48]===i?le=t[49]:(le=(e,t,n,r,a)=>{let o=n===void 0?0:n;return(0,$.jsx)(Z,{cardClassName:a!==void 0&&a?`hidden`:void 0,label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`span`,{children:[e,o>0&&(0,$.jsx)(`span`,{className:`ml-2 text-[var(--status-success)]`,children:i(o===1?`settings.plugins.sidebar.group.updatesAvailable_one`:`settings.plugins.sidebar.group.updatesAvailable_other`,{count:o})})]}),r]}),children:t})},t[48]=i,t[49]=le);let ue=le,de;t[50]===ne?de=t[51]:(de=()=>void ne(),t[50]=ne,t[51]=de);let fe;t[52]===i?fe=t[53]:(fe=i(`settings.plugins.sidebar.actions.refresh`),t[52]=i,t[53]=fe);let pe;t[54]===i?pe=t[55]:(pe=i(`settings.plugins.sidebar.actions.refresh`),t[54]=i,t[55]=pe);let me=g?`size-4 animate-spin`:`size-4`,ge;t[56]===me?ge=t[57]:(ge=(0,$.jsx)(J,{name:`refresh`,className:me}),t[56]=me,t[57]=ge);let _e;t[58]!==g||t[59]!==de||t[60]!==fe||t[61]!==pe||t[62]!==ge?(_e=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:de,disabled:g,"aria-label":fe,title:pe,children:ge}),t[58]=g,t[59]=de,t[60]=fe,t[61]=pe,t[62]=ge,t[63]=_e):_e=t[63];let ve;t[64]===i?ve=t[65]:(ve=i(`settings.plugins.sidebar.actions.addTitle`),t[64]=i,t[65]=ve);let ye;t[66]===i?ye=t[67]:(ye=i(`settings.plugins.sidebar.actions.addTitle`),t[66]=i,t[67]=ye);let be;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(J,{name:`add`,className:`size-4`}),t[68]=be):be=t[68];let xe;t[69]!==V||t[70]!==ve||t[71]!==ye?(xe=(0,$.jsx)(Y,{"data-settings-item":`plugins.create`,type:`button`,variant:`ghost`,size:`icon`,onClick:V,"aria-label":ve,title:ye,children:be}),t[69]=V,t[70]=ve,t[71]=ye,t[72]=xe):xe=t[72];let Se;t[73]!==_e||t[74]!==xe?(Se=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_e,xe]}),t[73]=_e,t[74]=xe,t[75]=Se):Se=t[75];let Ce=Se,we;t[76]!==Ce||t[77]!==oe||t[78]!==ue||t[79]!==i||t[80]!==A||t[81]!==M?(we=M.length>0?ue(i(`settings.plugins.sidebar.group.userEntries`),M.map(oe),A.userEntries,Ce):ue(i(`settings.plugins.sidebar.group.userEntries`),(0,$.jsx)(`span`,{}),0,Ce,!0),t[76]=Ce,t[77]=oe,t[78]=ue,t[79]=i,t[80]=A,t[81]=M,t[82]=we):we=t[82];let Te;t[83]!==z||t[84]!==P||t[85]!==R||t[86]!==oe||t[87]!==ce||t[88]!==ue||t[89]!==i||t[90]!==A||t[91]!==I?(Te=z?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:i(`settings.plugins.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:i(`settings.plugins.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[I.length>0&&ue(i(`settings.plugins.sidebar.group.userFiles`),I.map(ce)),P.length>0&&ue(i(`settings.plugins.sidebar.group.projectEntries`),P.map(oe),A.projectEntries),R.length>0&&ue(i(`settings.plugins.sidebar.group.projectFiles`),R.map(ce))]}),t[83]=z,t[84]=P,t[85]=R,t[86]=oe,t[87]=ce,t[88]=ue,t[89]=i,t[90]=A,t[91]=I,t[92]=Te):Te=t[92];let Ee;t[93]!==we||t[94]!==Te?(Ee=(0,$.jsxs)($a,{variant:`background`,children:[we,Te]}),t[93]=we,t[94]=Te,t[95]=Ee):Ee=t[95];let De;t[96]===C?De=t[97]:(De=(0,$.jsx)(Gs,{open:C,onOpenChange:w}),t[96]=C,t[97]=De);let Oe=y!==null,Ae;t[98]===x?Ae=t[99]:(Ae=e=>{!e&&!x&&b(null)},t[98]=x,t[99]=Ae);let je;t[100]===i?je=t[101]:(je=i(`settings.plugins.sidebar.deleteDialog.title`),t[100]=i,t[101]=je);let Me;t[102]===je?Me=t[103]:(Me=(0,$.jsx)(Kt,{children:je}),t[102]=je,t[103]=Me);let Ne=y?.label??``,Pe;t[104]!==i||t[105]!==Ne?(Pe=i(`settings.plugins.sidebar.deleteDialog.description`,{name:Ne}),t[104]=i,t[105]=Ne,t[106]=Pe):Pe=t[106];let Fe;t[107]===Pe?Fe=t[108]:(Fe=(0,$.jsx)(qt,{children:Pe}),t[107]=Pe,t[108]=Fe);let Ie;t[109]!==Me||t[110]!==Fe?(Ie=(0,$.jsxs)(Ut,{children:[Me,Fe]}),t[109]=Me,t[110]=Fe,t[111]=Ie):Ie=t[111];let Le;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Le=()=>b(null),t[112]=Le):Le=t[112];let Re;t[113]===i?Re=t[114]:(Re=i(`settings.common.actions.cancel`),t[113]=i,t[114]=Re);let ze;t[115]!==x||t[116]!==Re?(ze=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:Le,disabled:x,children:Re}),t[115]=x,t[116]=Re,t[117]=ze):ze=t[117];let Be;t[118]!==x||t[119]!==i?(Be=i(x?`settings.plugins.sidebar.actions.deleting`:`settings.common.actions.delete`),t[118]=x,t[119]=i,t[120]=Be):Be=t[120];let Ve;t[121]!==ie||t[122]!==x||t[123]!==Be?(Ve=(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:ie,disabled:x,children:Be}),t[121]=ie,t[122]=x,t[123]=Be,t[124]=Ve):Ve=t[124];let He;t[125]!==ze||t[126]!==Ve?(He=(0,$.jsxs)(Wt,{children:[ze,Ve]}),t[125]=ze,t[126]=Ve,t[127]=He):He=t[127];let Ue;t[128]!==Ie||t[129]!==He?(Ue=(0,$.jsxs)(Gt,{className:`max-w-md`,children:[Ie,He]}),t[128]=Ie,t[129]=He,t[130]=Ue):Ue=t[130];let We;t[131]!==Oe||t[132]!==Ae||t[133]!==Ue?(We=(0,$.jsx)(Jt,{open:Oe,onOpenChange:Ae,children:Ue}),t[131]=Oe,t[132]=Ae,t[133]=Ue,t[134]=We):We=t[134];let Ge;return t[135]!==Ee||t[136]!==De||t[137]!==We?(Ge=(0,$.jsxs)($.Fragment,{children:[Ee,De,We]}),t[135]=Ee,t[136]=De,t[137]=We,t[138]=Ge):Ge=t[138],Ge};function oc(e){return{entries:e.entries,files:e.files,selectedId:e.selectedId,setSelected:e.setSelected,deleteEntry:e.deleteEntry,deleteFile:e.deleteFile,loadPlugins:e.loadPlugins,updateEntry:e.updateEntry}}function sc(e){return e.spec}function cc(e){return e.scope===`user`}function lc(e){return e.scope===`project`}function uc(e){return e.scope===`user`}function dc(e){return e.scope===`project`}var fc=e=>{let t=(0,Ei.c)(10),{children:n,className:r,outerClassName:i}=e,a;t[0]===i?a=t[1]:(a=q(`h-full`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=q(`oc-settings-page-content mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,r),t[2]=r,t[3]=o);let s;t[4]!==n||t[5]!==o?(s=(0,$.jsx)(`div`,{className:o,children:n}),t[4]=n,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,$.jsx)(yr,{outerClassName:a,className:`w-full`,children:s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},pc=({entryId:e,spec:t})=>{let{t:n}=ke(),{data:r}=Qs([t]),i=r?.[t],a=Ns(e=>e.updateEntry),[o,s]=Q.useState(!1);if(!i)return null;if(i.kind===`npm-ok`){if(!i.hasUpdate||!i.latestVersion)return null;let t=i.latestVersion,r=i.currentVersion??``,c=async()=>{s(!0);try{(await a(e,{spec:`${i.name}@latest`})).ok?K.success(n(`settings.plugins.toast.updatedToLatest`,{version:t})):K.error(n(`settings.plugins.toast.refreshFailed`))}finally{s(!1)}};return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(J,{name:`arrow-up`,className:`h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-success)]`,children:n(`settings.plugins.registry.banner.updateAvailable.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:n(`settings.plugins.registry.banner.updateAvailable.description`,{current:r,latest:t})})]}),(0,$.jsx)(Y,{variant:`default`,size:`sm`,onClick:()=>void c(),disabled:o,children:n(`settings.plugins.registry.banner.updateAvailable.action`,{latest:t})})]})}if(i.kind===`path-ok`)return null;if(i.kind===`npm-network`)return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(J,{name:`cloud-off`,className:`h-5 w-5 text-muted-foreground shrink-0 mt-0.5`}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:n(`settings.plugins.registry.badge.network.tooltip`)})})]});let c=i.kind===`path-unreadable`,l=c?`var(--status-warning)`:`var(--status-error)`,u=c?`alert`:`error-warning`,d=(()=>{switch(i.kind){case`npm-missing-version`:return n(`settings.plugins.registry.banner.invalid.missingVersion`);case`npm-missing-package`:return n(`settings.plugins.registry.banner.invalid.missingPackage`);case`npm-malformed`:return n(`settings.plugins.registry.banner.invalid.malformed`);case`path-missing`:return n(`settings.plugins.registry.banner.invalid.pathMissing`);case`path-unreadable`:return n(`settings.plugins.registry.banner.invalid.pathUnreadable`)}})();return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(J,{name:u,className:`h-5 w-5 shrink-0 mt-0.5`,style:{color:l}}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label`,style:{color:l},children:n(`settings.plugins.registry.banner.invalid.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:d})]})]})};function mc(e){let t=e.trim();if(t.length===0)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}function hc(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function gc(e){return{mode:`entry`,scope:e.scope,spec:e.spec,optionsJson:hc(e.options),fileName:``,content:``}}function _c(e,t){return{mode:`file`,scope:e.scope,spec:``,optionsJson:``,fileName:e.fileName,content:t}}var vc=e=>{let t=(0,Ei.c)(4),{scope:n,label:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`typography-micro font-medium rounded-full px-2 py-0.5`,`bg-[var(--surface-elevated)] text-muted-foreground`,`border border-[var(--interactive-border)]`),t[0]=i):i=t[0];let a;return t[1]!==r||t[2]!==n?(a=(0,$.jsx)(`span`,{className:i,"data-scope":n,children:r}),t[1]=r,t[2]=n,t[3]=a):a=t[3],a},yc=()=>{let{t:e}=ke(),t=Ns(e=>e.selectedId),n=Ns(e=>e.entries),r=Ns(e=>e.files),i=Ns(e=>e.draft),a=Ns(e=>e.setDraft),o=Ns(e=>e.updateEntry),s=Ns(e=>e.updateFile),c=Ns(e=>e.readFile),l=Q.useMemo(()=>t?n.find(e=>e.id===t)??null:null,[n,t]),u=Q.useMemo(()=>t?r.find(e=>e.id===t)??null:null,[r,t]),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),h=Q.useRef(new Map);if(Q.useEffect(()=>{let e=!1;return l?(a(gc(l)),()=>{e=!0}):u?(m(!0),(async()=>{let t=await c(u.id);if(e)return;m(!1);let n=t?.content??``;h.current.set(u.id,n),a(_c(u,n))})(),()=>{e=!0}):(a(null),()=>{e=!0})},[l,u,c,a]),!t)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.plugins.page.empty.select`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.plugins.page.empty.add`)})]})});if(l&&i&&i.mode===`entry`){let t=mc(i.optionsJson),n=t.ok,r=i.spec!==l.spec||i.optionsJson!==hc(l.options),s=()=>{a(gc(l))},c=async()=>{if(!n)return;let r=i.spec.trim();if(!r){K.error(e(`settings.plugins.validation.specRequired`));return}f(!0);try{let n=await o(l.id,{spec:r,options:t.value});n.ok?n.reloadFailed?K.warning(n.message||e(`settings.plugins.toast.reloadFailed`),{description:n.warning}):K.success(n.message||e(`settings.plugins.toast.updated`)):K.error(n.message||e(`settings.plugins.toast.reloadFailed`))}finally{f(!1)}};return(0,$.jsxs)(fc,{children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.plugins.page.header.entry`)}),(0,$.jsx)(vc,{scope:l.scope,label:l.scope===`project`?e(`settings.plugins.sidebar.group.projectEntries`):e(`settings.plugins.sidebar.group.userEntries`)})]})}),(0,$.jsx)(pc,{entryId:l.id,spec:l.spec}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.spec`,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.spec`),cardClassName:`p-3`,children:(0,$.jsx)(ln,{value:i.spec,onChange:e=>a({...i,spec:e.target.value}),placeholder:e(`settings.plugins.page.field.spec.placeholder`),className:`font-mono typography-meta`,spellCheck:!1})})}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.options`,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.options`),description:n?void 0:e(`settings.plugins.page.field.options.invalidJson`),cardClassName:`p-3`,children:(0,$.jsx)(br,{embedded:!0,value:i.optionsJson,onChange:e=>a({...i,optionsJson:e.target.value}),rows:10,className:q(`font-mono typography-meta min-h-[200px]`,!n&&`border-[var(--status-error-border)]`),spellCheck:!1,placeholder:`{ }`})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`default`,size:`sm`,onClick:()=>void c(),disabled:!r||!n||d,children:e(`settings.plugins.page.action.save`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:s,disabled:!r||d,children:e(`settings.plugins.page.action.discard`)})]})]})}if(u&&i&&i.mode===`file`){let t=h.current.get(u.id)??``,n=i.content!==t||i.fileName!==u.fileName,r=()=>{(async()=>{m(!0);let e=(await c(u.id))?.content??``;m(!1),h.current.set(u.id,e),a(_c(u,e))})()},o=async()=>{f(!0);try{let t=await s(u.id,{content:i.content});t.ok?(h.current.set(u.id,i.content),t.reloadFailed?K.warning(t.message||e(`settings.plugins.toast.reloadFailed`),{description:t.warning}):K.success(t.message||e(`settings.plugins.toast.updated`))):K.error(t.message||e(`settings.plugins.toast.reloadFailed`))}finally{f(!1)}};return(0,$.jsxs)(fc,{children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.plugins.page.header.file`)}),(0,$.jsx)(vc,{scope:u.scope,label:u.scope===`project`?e(`settings.plugins.sidebar.group.projectFiles`):e(`settings.plugins.sidebar.group.userFiles`)}),(0,$.jsx)(`span`,{className:q(`typography-micro font-mono rounded-full px-2 py-0.5`,`bg-[var(--surface-elevated)] text-foreground`,`border border-[var(--interactive-border)]`),children:u.fileName})]})}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.content`,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.content`),cardClassName:`p-3`,children:(0,$.jsx)(br,{embedded:!0,value:i.content,onChange:e=>a({...i,content:e.target.value}),rows:16,className:`font-mono typography-meta min-h-[320px]`,spellCheck:!1,disabled:p})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`default`,size:`sm`,onClick:()=>void o(),disabled:!n||d||p,children:e(`settings.plugins.page.action.save`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:r,disabled:d||p,children:e(`settings.plugins.page.action.discard`)})]})]})}return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(J,{name:`loader-4`,className:`mx-auto mb-3 h-6 w-6 animate-spin opacity-50`})})})},bc={opencode:`OpenCode`,"oh-my-opencode-slim":`oh-my-opencode-slim`,"oh-my-openagent":`oh-my-openagent`};async function xc(e,t){let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t}function Sc(){let{t:e}=ke(),{currentTheme:t}=ur(),[n,r]=Q.useState([]),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(!0),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),b=Q.useMemo(()=>{let e=u||`opencode.json`,n=e.endsWith(`.jsonc`)?`jsonc`:`json`,r=[ii(t,{syntaxColors:!1})],i=sr(e);return i&&r.push(i),r.push(Rr({language:n,themeName:t.metadata.id,theme:_r(t)})),r},[t,u]),x=Q.useCallback(async t=>{p(!0);try{let n=await L(`/api/config/global/${t}`);if(!n.ok)throw Error(await xc(n,e(`settings.globalConfig.toast.loadFailed`)));let r=await n.json(),i=typeof r.content==`string`?r.content:``;s(i),l(i),d(typeof r.fileName==`string`?r.fileName:``)}catch(t){s(``),l(``),d(``),K.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.loadFailed`))}finally{p(!1)}},[e]);Q.useEffect(()=>{let t=!1;return(async()=>{p(!0);try{let n=await L(`/api/config/global`);if(!n.ok)throw Error(await xc(n,e(`settings.globalConfig.toast.loadFailed`)));let i=await n.json(),o=Array.isArray(i.targets)?i.targets.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.target!=`string`||typeof t.fileName!=`string`||!(t.target in bc))return[];let n=t.target;return[{id:n,label:bc[n],fileName:t.fileName}]}):[];if(t)return;r(o),a(e=>o.some(t=>t.id===e)?e:o[0]?.id||null)}catch(n){t||(r([]),a(null),K.error(n instanceof Error?n.message:e(`settings.globalConfig.toast.loadFailed`)))}finally{t||p(!1)}})(),()=>{t=!0}},[e]),Q.useEffect(()=>{i&&x(i)},[x,i]);let S=async()=>{if(i){h(!0);try{let t=await L(`/api/config/global/${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:o})});if(!t.ok)throw Error(await xc(t,e(`settings.globalConfig.toast.saveFailed`)));let n=await t.json(),r=typeof n.content==`string`?n.content:o;s(r),l(r),K.success(e(`settings.globalConfig.toast.saved`)),_(!0)}catch(t){K.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.saveFailed`))}finally{h(!1)}}},C=async()=>{y(!0);try{await We({message:e(`settings.view.actions.reloadOpenCode`),mode:`projects`,scopes:[`all`]}),_(!1)}catch(t){K.error(t instanceof Error?t.message:e(`settings.view.actions.reloadOpenCode`))}finally{y(!1)}};return(0,$.jsxs)(yr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsx)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(Z,{itemId:`global-config.editor`,label:e(`settings.globalConfig.title`),description:e(`settings.globalConfig.description`),cardClassName:`p-3`,children:n.length>0?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:n.map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 px-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta truncate text-muted-foreground`,children:u}),i&&(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,onClick:()=>void x(i),disabled:f||m,children:e(`settings.globalConfig.actions.reload`)})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`h-[clamp(420px,62dvh,760px)] overflow-hidden bg-background`,children:(0,$.jsx)(Tr,{value:o,onChange:s,readOnly:f,extensions:b,className:`h-full`,enableSearch:!0})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(Y,{onClick:S,disabled:f||m||o===c,size:`sm`,children:e(m?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.globalConfig.restartHint`)})]})]})]}):(0,$.jsx)(`div`,{className:`min-h-12`,"aria-busy":f})})}),(0,$.jsx)(Jt,{open:g,onOpenChange:e=>!v&&_(e),children:(0,$.jsxs)(Gt,{className:`max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.view.actions.reloadOpenCode`)}),(0,$.jsx)(qt,{children:e(`settings.globalConfig.restartHint`)})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>_(!1),disabled:v,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>void C(),disabled:v,children:e(`settings.view.actions.reloadOpenCode`)})]})]})})]})}var Cc=`<built-in>`,wc=e=>e?.path===Cc,Tc=e=>{let t=(0,Ei.c)(172),{onItemSelect:n}=e,{t:r}=ke(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedSkillName:m,setSelectedSkill:h,setSkillDraft:g,createSkill:_,deleteSkill:v,getSkillDetail:y}=da(he(Dc)),b=Fe(),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=Je(),t[0]=x):x=t[0];let S=x,C;t[1]===b.data?C=t[2]:(C=b.data??[],t[1]=b.data,t[2]=C);let w=C,T;t[3]!==n||t[4]!==h||t[5]!==g||t[6]!==w?(T=()=>{let e=`new-skill`,t=1;for(;w.some(t=>t.name===e);)e=`new-skill-${t}`,t++;g({name:e,scope:`user`,source:`opencode`,description:``}),h(e),n?.()},t[3]=n,t[4]=h,t[5]=g,t[6]=w,t[7]=T):T=t[7];let E=T,D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=async e=>{wc(e)||l(e)},t[8]=D):D=t[8];let O=D,k;t[9]!==c||t[10]!==v||t[11]!==r?(k=async()=>{if(c){if(wc(c)){l(null);return}d(!0),await v(c.name,{directory:S})?(K.success(r(`settings.skills.sidebar.toast.skillDeleted`,{name:c.name})),l(null)):K.error(r(`settings.skills.sidebar.toast.deleteSkillFailed`)),d(!1)}},t[9]=c,t[10]=v,t[11]=r,t[12]=k):k=t[12];let A=k,j;t[13]!==y||t[14]!==h||t[15]!==g||t[16]!==w||t[17]!==r?(j=async e=>{if(wc(e))return;let t=e.name,n=1,i=`${t}-copy`;for(;w.some(e=>e.name===i);)n++,i=`${t}-copy-${n}`;let a=await y(e.name);if(!a){K.error(r(`settings.skills.sidebar.toast.duplicateLoadFailed`));return}g({name:i,scope:e.scope||`user`,source:e.source||`opencode`,description:(a.sources.md.fields.includes(`description`),``),instructions:``}),h(i)},t[13]=y,t[14]=h,t[15]=g,t[16]=w,t[17]=r,t[18]=j):j=t[18];let M=j,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{wc(e)||(s(e.name),a(e))},t[19]=N):N=t[19];let P=N,F;t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==i||t[24]!==o||t[25]!==h||t[26]!==w||t[27]!==r?(F=async()=>{if(!i)return;if(wc(i)){a(null);return}let e=o.trim().replace(/\s+/g,`-`).toLowerCase();if(!e){K.error(r(`settings.skills.page.toast.skillNameRequired`));return}if(e===i.name){a(null);return}if(w.some(t=>t.name===e)){K.error(r(`settings.skills.page.toast.skillExists`));return}if(!await y(i.name)){K.error(r(`settings.skills.sidebar.toast.renameLoadFailed`)),a(null);return}await _({name:e,description:`Renamed skill`,scope:i.scope,source:i.source},{directory:S})?await v(i.name,{directory:S})?(K.success(`Skill renamed to "${e}"`),h(e)):K.error(r(`settings.skills.sidebar.toast.removeOldAfterRenameFailed`)):K.error(r(`settings.skills.sidebar.toast.renameFailed`)),a(null)},t[20]=_,t[21]=v,t[22]=y,t[23]=i,t[24]=o,t[25]=h,t[26]=w,t[27]=r,t[28]=F):F=t[28];let I=F,L;t[29]===w?L=t[30]:(L=w.filter(Oc),t[29]=w,t[30]=L);let R=L,z;t[31]===w?z=t[32]:(z=w.filter(kc),t[31]=w,t[32]=z);let B=z,V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){let t={},n=[];for(let r of e)r.group?(t[r.group]||(t[r.group]=[]),t[r.group].push(r)):n.push(r);let r=Object.keys(t).sort(Ac).map(e=>({name:e,skills:[...t[e]].sort(jc)}));return n.sort(Mc),{sortedGroups:r,ungrouped:n}},t[33]=V):V=t[33];let H=V,ee;t[34]===R?ee=t[35]:(ee=H(R),t[34]=R,t[35]=ee);let U=ee,te;t[36]===B?te=t[37]:(te=H(B),t[36]=B,t[37]=te);let W=te,ne;t[38]===r?ne=t[39]:(ne=r(`settings.skills.sidebar.section.project`),t[38]=r,t[39]=ne);let re=ne,ie;t[40]===r?ie=t[41]:(ie=r(`settings.skills.sidebar.section.user`),t[40]=r,t[41]=ie);let ae=ie,oe;t[42]===re?oe=t[43]:(oe=(0,$.jsx)(`span`,{children:re}),t[42]=re,t[43]=oe);let se;t[44]===r?se=t[45]:(se=r(`settings.skills.page.title.newSkill`),t[44]=r,t[45]=se);let ce;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[46]=ce):ce=t[46];let le;t[47]!==E||t[48]!==se?(le=(0,$.jsx)(Y,{"data-settings-item":`skills.create`,size:`icon`,variant:`ghost`,"aria-label":se,onClick:E,children:ce}),t[47]=E,t[48]=se,t[49]=le):le=t[49];let ue;t[50]!==oe||t[51]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[oe,le]}),t[50]=oe,t[51]=le,t[52]=ue):ue=t[52];let de=ue,fe;t[53]!==M||t[54]!==n||t[55]!==f||t[56]!==m||t[57]!==h?(fe=e=>(0,$.jsx)(Ec,{skill:e,isSelected:m===e.name,onSelect:()=>{h(e.name),n?.()},onRename:()=>P(e),onDelete:()=>O(e),onDuplicate:()=>M(e),isMenuOpen:f===e.name,onMenuOpenChange:t=>p(t?e.name:null)},e.name),t[53]=M,t[54]=n,t[55]=f,t[56]=m,t[57]=h,t[58]=fe):fe=t[58];let pe=fe,me,ge;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(me=q(`oc-settings-page-content h-full overflow-y-auto p-3`,`bg-background`),ge=(0,$.jsx)(ha,{}),t[59]=me,t[60]=ge):(me=t[59],ge=t[60]);let _e;t[61]!==w.length||t[62]!==r?(_e=w.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.skills.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.sidebar.empty.description`)})]})}):null,t[61]=w.length,t[62]=r,t[63]=_e):_e=t[63];let ve;t[64]!==U.ungrouped||t[65]!==de||t[66]!==pe?(ve=U.ungrouped.length>0?(0,$.jsx)(Z,{label:de,children:U.ungrouped.map(pe)}):(0,$.jsx)(Z,{label:de,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[64]=U.ungrouped,t[65]=de,t[66]=pe,t[67]=ve):ve=t[67];let ye;if(t[68]!==U.sortedGroups||t[69]!==re||t[70]!==pe){let e;t[72]!==re||t[73]!==pe?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Sa,{label:t,labelPrefix:re,count:n.length,storageKey:`project-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[72]=re,t[73]=pe,t[74]=e):e=t[74],ye=U.sortedGroups.map(e),t[68]=U.sortedGroups,t[69]=re,t[70]=pe,t[71]=ye}else ye=t[71];let be;t[75]!==W.ungrouped||t[76]!==pe||t[77]!==ae?(be=W.ungrouped.length>0?(0,$.jsx)(Z,{label:ae,children:W.ungrouped.map(pe)}):null,t[75]=W.ungrouped,t[76]=pe,t[77]=ae,t[78]=be):be=t[78];let xe;if(t[79]!==W.sortedGroups||t[80]!==pe||t[81]!==ae){let e;t[83]!==pe||t[84]!==ae?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Sa,{label:t,labelPrefix:ae,count:n.length,storageKey:`user-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[83]=pe,t[84]=ae,t[85]=e):e=t[85],xe=W.sortedGroups.map(e),t[79]=W.sortedGroups,t[80]=pe,t[81]=ae,t[82]=xe}else xe=t[82];let Se=c!==null,Ce;t[86]===u?Ce=t[87]:(Ce=e=>{!e&&!u&&l(null)},t[86]=u,t[87]=Ce);let we;t[88]===r?we=t[89]:(we=r(`settings.skills.sidebar.deleteDialog.title`),t[88]=r,t[89]=we);let Te;t[90]===we?Te=t[91]:(Te=(0,$.jsx)(Kt,{children:we}),t[90]=we,t[91]=Te);let Ee=c?.name??``,De;t[92]!==r||t[93]!==Ee?(De=r(`settings.skills.sidebar.deleteDialog.description`,{name:Ee}),t[92]=r,t[93]=Ee,t[94]=De):De=t[94];let Oe;t[95]===De?Oe=t[96]:(Oe=(0,$.jsx)(qt,{children:De}),t[95]=De,t[96]=Oe);let Ae;t[97]!==Te||t[98]!==Oe?(Ae=(0,$.jsxs)(Ut,{children:[Te,Oe]}),t[97]=Te,t[98]=Oe,t[99]=Ae):Ae=t[99];let je;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(je=()=>l(null),t[100]=je):je=t[100];let Me;t[101]===r?Me=t[102]:(Me=r(`settings.common.actions.cancel`),t[101]=r,t[102]=Me);let Ne;t[103]!==u||t[104]!==Me?(Ne=(0,$.jsx)(Y,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:je,disabled:u,children:Me}),t[103]=u,t[104]=Me,t[105]=Ne):Ne=t[105];let Pe;t[106]===r?Pe=t[107]:(Pe=r(`settings.common.actions.delete`),t[106]=r,t[107]=Pe);let Ie;t[108]!==A||t[109]!==u||t[110]!==Pe?(Ie=(0,$.jsx)(Y,{size:`sm`,onClick:A,disabled:u,children:Pe}),t[108]=A,t[109]=u,t[110]=Pe,t[111]=Ie):Ie=t[111];let Le;t[112]!==Ne||t[113]!==Ie?(Le=(0,$.jsxs)(Wt,{children:[Ne,Ie]}),t[112]=Ne,t[113]=Ie,t[114]=Le):Le=t[114];let Re;t[115]!==Ae||t[116]!==Le?(Re=(0,$.jsxs)(Gt,{className:`max-w-md`,children:[Ae,Le]}),t[115]=Ae,t[116]=Le,t[117]=Re):Re=t[117];let ze;t[118]!==Se||t[119]!==Ce||t[120]!==Re?(ze=(0,$.jsx)(Jt,{open:Se,onOpenChange:Ce,children:Re}),t[118]=Se,t[119]=Ce,t[120]=Re,t[121]=ze):ze=t[121];let Be=i!==null,Ve;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=e=>!e&&a(null),t[122]=Ve):Ve=t[122];let He;t[123]===r?He=t[124]:(He=r(`settings.skills.sidebar.renameDialog.title`),t[123]=r,t[124]=He);let Ue;t[125]===He?Ue=t[126]:(Ue=(0,$.jsx)(Kt,{children:He}),t[125]=He,t[126]=Ue);let We=i?.name??``,Ge;t[127]!==r||t[128]!==We?(Ge=r(`settings.skills.sidebar.renameDialog.description`,{name:We}),t[127]=r,t[128]=We,t[129]=Ge):Ge=t[129];let Ke;t[130]===Ge?Ke=t[131]:(Ke=(0,$.jsx)(qt,{children:Ge}),t[130]=Ge,t[131]=Ke);let qe;t[132]!==Ue||t[133]!==Ke?(qe=(0,$.jsxs)(Ut,{children:[Ue,Ke]}),t[132]=Ue,t[133]=Ke,t[134]=qe):qe=t[134];let Ye;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=e=>s(e.target.value),t[135]=Ye):Ye=t[135];let Xe;t[136]===r?Xe=t[137]:(Xe=r(`settings.skills.sidebar.renameDialog.placeholder`),t[136]=r,t[137]=Xe);let Ze;t[138]===I?Ze=t[139]:(Ze=e=>{e.key===`Enter`&&I()},t[138]=I,t[139]=Ze);let Qe;t[140]!==o||t[141]!==Xe||t[142]!==Ze?(Qe=(0,$.jsx)(ln,{value:o,onChange:Ye,placeholder:Xe,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Ze}),t[140]=o,t[141]=Xe,t[142]=Ze,t[143]=Qe):Qe=t[143];let $e;t[144]===Symbol.for(`react.memo_cache_sentinel`)?($e=()=>a(null),t[144]=$e):$e=t[144];let et;t[145]===r?et=t[146]:(et=r(`settings.common.actions.cancel`),t[145]=r,t[146]=et);let tt;t[147]===et?tt=t[148]:(tt=(0,$.jsx)(Y,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:$e,children:et}),t[147]=et,t[148]=tt);let G;t[149]===r?G=t[150]:(G=r(`settings.common.actions.rename`),t[149]=r,t[150]=G);let nt;t[151]!==I||t[152]!==G?(nt=(0,$.jsx)(Y,{size:`sm`,onClick:I,children:G}),t[151]=I,t[152]=G,t[153]=nt):nt=t[153];let rt;t[154]!==tt||t[155]!==nt?(rt=(0,$.jsxs)(Wt,{children:[tt,nt]}),t[154]=tt,t[155]=nt,t[156]=rt):rt=t[156];let it;t[157]!==qe||t[158]!==Qe||t[159]!==rt?(it=(0,$.jsxs)(Gt,{children:[qe,Qe,rt]}),t[157]=qe,t[158]=Qe,t[159]=rt,t[160]=it):it=t[160];let at;t[161]!==Be||t[162]!==it?(at=(0,$.jsx)(Jt,{open:Be,onOpenChange:Ve,children:it}),t[161]=Be,t[162]=it,t[163]=at):at=t[163];let ot;return t[164]!==_e||t[165]!==ve||t[166]!==ye||t[167]!==be||t[168]!==xe||t[169]!==ze||t[170]!==at?(ot=(0,$.jsxs)(`div`,{className:me,children:[ge,_e,ve,ye,be,xe,ze,at]}),t[164]=_e,t[165]=ve,t[166]=ye,t[167]=be,t[168]=xe,t[169]=ze,t[170]=at,t[171]=ot):ot=t[171],ot},Ec=e=>{let t=(0,Ei.c)(49),{skill:n,isSelected:r,onSelect:i,onDelete:a,onRename:o,onDuplicate:s,isMenuOpen:c,onMenuOpenChange:l}=e,{t:u}=ke(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=fr(),t[0]=d):d=t[0];let f=d,p;t[1]!==n.source||t[2]!==u?(p=n.source===`claude`?u(`settings.skills.sidebar.badge.claude`):n.source===`agents`?u(`settings.skills.sidebar.badge.agents`):u(`settings.skills.sidebar.badge.opencode`),t[1]=n.source,t[2]=u,t[3]=p):p=t[3];let m=p,h;t[4]===n?h=t[5]:(h=wc(n),t[4]=n,t[5]=h);let g=h,[_,v]=Q.useState(!1),y;t[6]!==a||t[7]!==s||t[8]!==o||t[9]!==u?(y=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.duplicate`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.delete`)]})]}),t[6]=a,t[7]=s,t[8]=o,t[9]=u,t[10]=y):y=t[10];let b=y,x=!g&&_,S=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,C;t[11]===S?C=t[12]:(C=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,S),t[11]=S,t[12]=C);let w;t[13]===g?w=t[14]:(w=!f&&!g?e=>{e.preventDefault(),v(!0)}:void 0,t[13]=g,t[14]=w);let T;t[15]!==C||t[16]!==w?(T=(0,$.jsx)(`div`,{className:C,onContextMenu:w}),t[15]=C,t[16]=w,t[17]=T):T=t[17];let E;t[18]===n.name?E=t[19]:(E=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[18]=n.name,t[19]=E);let D;t[20]===n.scope?D=t[21]:(D=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:n.scope}),t[20]=n.scope,t[21]=D);let O;t[22]===m?O=t[23]:(O=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:m}),t[22]=m,t[23]=O);let k;t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[E,D,O]}),t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27];let A;t[28]!==i||t[29]!==k?(A=(0,$.jsx)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:k}),t[28]=i,t[29]=k,t[30]=A):A=t[30];let j;t[31]!==g||t[32]!==c||t[33]!==l||t[34]!==b?(j=g?null:(0,$.jsxs)(Tn,{open:c,onOpenChange:e=>{e&&v(!1),l(e)},children:[(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(mn,{align:`end`,className:`w-fit min-w-20`,children:b(_n)})]}),t[31]=g,t[32]=c,t[33]=l,t[34]=b,t[35]=j):j=t[35];let M;t[36]!==A||t[37]!==j?(M=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38];let N;t[39]!==M||t[40]!==T?(N=(0,$.jsx)(gi,{render:T,children:M}),t[39]=M,t[40]=T,t[41]=N):N=t[41];let P;t[42]!==g||t[43]!==b?(P=g?null:(0,$.jsx)(_i,{className:`w-fit min-w-20`,children:b(vi)}),t[42]=g,t[43]=b,t[44]=P):P=t[44];let F;return t[45]!==N||t[46]!==P||t[47]!==x?(F=(0,$.jsxs)(yi,{open:x,onOpenChange:v,children:[N,P]}),t[45]=N,t[46]=P,t[47]=x,t[48]=F):F=t[48],F};function Dc(e){return{selectedSkillName:e.selectedSkillName,setSelectedSkill:e.setSelectedSkill,setSkillDraft:e.setSkillDraft,createSkill:e.createSkill,deleteSkill:e.deleteSkill,getSkillDetail:e.getSkillDetail}}function Oc(e){return e.scope===`project`}function kc(e){return e.scope===`user`}function Ac(e,t){return e.localeCompare(t)}function jc(e,t){return e.name.localeCompare(t.name)}function Mc(e,t){return e.name.localeCompare(t.name)}var Nc=()=>{let e=ye.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},Pc=fe()(me(e=>({selectedSourceId:lt[0]?.id??null,isScanning:!1,isInstalling:!1,lastScanError:null,lastInstallError:null,scanResults:null,setSelectedSource:t=>e({selectedSourceId:t}),scanRepo:async(t,n)=>{e({isScanning:!0,lastScanError:null,scanResults:null});try{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:Nc(),i=r?`?directory=${encodeURIComponent(r)}`:``,a=await L(`/api/config/skills/scan${i}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),o=await a.json().catch(()=>null);if(!a.ok||!o){let t=o?.error||{kind:`unknown`,message:`Failed to scan repository`};return e({lastScanError:t}),{ok:!1,error:t}}return o.ok?(e({scanResults:o.items||[]}),o):(e({lastScanError:o.error||{kind:`unknown`,message:`Failed to scan repository`}}),o)}finally{e({isScanning:!1})}},installSkills:async(t,n)=>{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:Nc(),a=n?.transportIdentity??i();if(i()!==a)return{ok:!1,error:{kind:`unknown`,message:`Failed to install skills`}};Ot(`Installing skills…`),e({isInstalling:!0,lastInstallError:null});let o=!1;try{let n=r?`?directory=${encodeURIComponent(r)}`:``,s=await L(`/api/config/skills/install${n}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),c=await s.json().catch(()=>null);if(!c){let t={kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),it(`Failed to install skills. Please retry.`),{ok:!1,error:t}}if(!s.ok||!c.ok){let t=c.error||{kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),it(t.message||`Failed to install skills. Please retry.`),{ok:!1,error:t}}return i()===a&&(c.requiresReload?(o=!0,await pa({message:c.message,delayMs:c.reloadDelayMs,directory:r,transportIdentity:a})):(it(c.message||`Refreshing skills…`),await tt(H,r,a),await vt(H,r,a))),c}catch(t){let n={kind:`unknown`,message:t instanceof Error?t.message:String(t)};return e({lastInstallError:n}),it(`Failed to install skills. Please retry.`),{ok:!1,error:n}}finally{e({isInstalling:!1}),o||dt()}}}),{name:`skills-catalog-store`})),Fc=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,Ic=e=>{let t=e.trim(),n=t.startsWith(`https://`)?`https`:t.startsWith(`git@`)?`ssh`:`shorthand`;if(n===`ssh`)return`${t.split(`:`)[1].replace(/\.git$/i,``)}`;if(n===`https`)return t.split(`/`).slice(3).filter(Boolean).join(`/`).replace(/\.git$/i,``);let r=t.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return r?`${r[1]}/${r[2].replace(/\.git$/i,``)}`:t},Lc=async()=>{try{let e=U()?.settings;if(e)return(await e.load())?.settings||{};let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},Rc=e=>{let t=(0,Ei.c)(158),{open:n,onOpenChange:r}=e,{t:a}=ke(),o=Pc(zc),s=Pc(Bc),c=Pc(Vc),l=kr(Hc),u=kr(Uc),[d,f]=Q.useState(``),[p,h]=Q.useState(``),[g,_]=Q.useState(``),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[y,b]=Q.useState(v),[x,S]=Q.useState(null),[C,w]=Q.useState(!1),T;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[1]=T):T=t[1];let[E,D]=Q.useState(T),[O,k]=Q.useState(null),A=Q.useRef(0),j=Q.useRef(null),M;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{A.current+=1,w(!1),S(null),j.current=null,e?.clearIdentity&&(D([]),k(null))},t[2]=M):M=t[2];let N=M,P,F;t[3]!==u||t[4]!==n?(P=()=>{n&&(A.current+=1,f(``),h(``),_(``),S(null),w(!1),j.current=null,D([]),k(null),u(),(async()=>{let e=await Lc(),t=Array.isArray(e?.skillCatalogs)?e?.skillCatalogs:[];b(t||[])})())},F=[n,u],t[3]=u,t[4]=n,t[5]=P,t[6]=F):(P=t[5],F=t[6]),Q.useEffect(P,F);let I;t[7]===p?I=t[8]:(I=p.trim(),t[7]=p,t[8]=I);let L=I,R;t[9]===g?R=t[10]:(R=g.trim(),t[9]=g,t[10]=R);let z=R,B;if(t[11]!==y||t[12]!==L||t[13]!==z){let e;t[15]!==L||t[16]!==z?(e=e=>{let t=(e.source||``).trim(),n=(e.subpath||``).trim();return t===L&&n===z},t[15]=L,t[16]=z,t[17]=e):e=t[17],B=y.some(e),t[11]=y,t[12]=L,t[13]=z,t[14]=B}else B=t[14];let ee=B,U;t[18]!==l||t[19]!==O||t[20]!==d||t[21]!==o||t[22]!==p||t[23]!==g||t[24]!==a?(U=async()=>{let e=p.trim();if(!e){K.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}d.trim()||f(Ic(e)),w(!1),S(null);let t=A.current+1;A.current=t;let n=rt(),r=i(),s=await o({source:e,subpath:g.trim()||void 0,gitIdentityId:O||void 0},{directory:n});if(A.current!==t||i()!==r||rt()!==n)return;if(!s.ok){if(s.error?.kind===`authRequired`){if(m()){K.error(a(`settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode`));return}let e=s.error.identities||[];if(D(e),!O&&e.length>0){let t=l&&l!==`global`&&e.some(e=>e.id===l)?l:e[0].id;k(t)}K.error(a(`settings.skills.catalog.add.toast.authenticationRequiredScan`));return}K.error(s.error?.message||a(`settings.skills.catalog.add.toast.scanFailed`));return}let c=s.items?.length||0;if(S(c),c===0){K.error(a(`settings.skills.catalog.add.toast.noSkillsFound`)),w(!1);return}D([]),w(!0),j.current={directory:n,transport:r},K.success(a(`settings.skills.catalog.shared.toast.foundSkills`,{count:c}))},t[18]=l,t[19]=O,t[20]=d,t[21]=o,t[22]=p,t[23]=g,t[24]=a,t[25]=U):U=t[25];let te=U,W;t[26]!==y||t[27]!==O||t[28]!==ee||t[29]!==d||t[30]!==r||t[31]!==C||t[32]!==s||t[33]!==p||t[34]!==g||t[35]!==a?(W=async()=>{let e=d.trim(),t=p.trim(),n=g.trim();if(!e){K.error(a(`settings.skills.catalog.add.toast.catalogNameRequired`));return}if(!t){K.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}let o=rt(),c=i();if(!C||j.current?.directory!==o||j.current?.transport!==c){w(!1),j.current=null,K.error(a(`settings.skills.catalog.add.toast.scanBeforeAdd`));return}if(ee){K.error(a(`settings.skills.catalog.add.toast.catalogAlreadyExists`));return}let l={id:Fc(),label:e,source:t,...n?{subpath:n}:{},...O?{gitIdentityId:O}:{}},u=[...y,l],f=rt(),m=i();try{await V({skillCatalogs:u}),b(u),K.success(a(`settings.skills.catalog.add.toast.catalogAdded`)),await H.invalidateQueries({queryKey:[m,`skillsCatalog`,`sources`],exact:!1}),await pt(H,f,m),await Ct(H,f,l.id,m),i()===m&&(s(l.id),r(!1))}catch(e){let t=e;K.error(t instanceof Error?t.message:a(`settings.skills.catalog.add.toast.saveFailed`))}},t[26]=y,t[27]=O,t[28]=ee,t[29]=d,t[30]=r,t[31]=C,t[32]=s,t[33]=p,t[34]=g,t[35]=a,t[36]=W):W=t[36];let ne=W,re;t[37]===a?re=t[38]:(re=a(`settings.skills.catalog.add.title`),t[37]=a,t[38]=re);let ie;t[39]===re?ie=t[40]:(ie=(0,$.jsx)(Kt,{children:re}),t[39]=re,t[40]=ie);let ae;t[41]===a?ae=t[42]:(ae=a(`settings.skills.catalog.add.descriptionPrefix`),t[41]=a,t[42]=ae);let oe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),t[43]=oe):oe=t[43];let se;t[44]===a?se=t[45]:(se=a(`settings.skills.catalog.add.descriptionSuffix`),t[44]=a,t[45]=se);let ce;t[46]!==ae||t[47]!==se?(ce=(0,$.jsxs)(qt,{children:[ae,` `,oe,se]}),t[46]=ae,t[47]=se,t[48]=ce):ce=t[48];let le;t[49]!==ie||t[50]!==ce?(le=(0,$.jsxs)(Ut,{children:[ie,ce]}),t[49]=ie,t[50]=ce,t[51]=le):le=t[51];let ue;t[52]===a?ue=t[53]:(ue=a(`settings.skills.catalog.add.field.catalogName`),t[52]=a,t[53]=ue);let de;t[54]===ue?de=t[55]:(de=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:ue}),t[54]=ue,t[55]=de);let fe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>f(e.target.value),t[56]=fe):fe=t[56];let pe;t[57]===a?pe=t[58]:(pe=a(`settings.skills.catalog.add.field.catalogNamePlaceholder`),t[57]=a,t[58]=pe);let me;t[59]!==d||t[60]!==pe?(me=(0,$.jsx)(ln,{value:d,onChange:fe,placeholder:pe}),t[59]=d,t[60]=pe,t[61]=me):me=t[61];let he;t[62]!==de||t[63]!==me?(he=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[de,me]}),t[62]=de,t[63]=me,t[64]=he):he=t[64];let ge;t[65]===a?ge=t[66]:(ge=a(`settings.skills.catalog.add.field.repository`),t[65]=a,t[66]=ge);let _e;t[67]===ge?_e=t[68]:(_e=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:ge}),t[67]=ge,t[68]=_e);let ve;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>{h(e.target.value),N({clearIdentity:!0})},t[69]=ve):ve=t[69];let ye;t[70]===a?ye=t[71]:(ye=a(`settings.skills.catalog.shared.field.repositoryPlaceholder`),t[70]=a,t[71]=ye);let be;t[72]!==p||t[73]!==ye?(be=(0,$.jsx)(ln,{value:p,onChange:ve,placeholder:ye}),t[72]=p,t[73]=ye,t[74]=be):be=t[74];let xe;t[75]===a?xe=t[76]:(xe=a(`settings.skills.catalog.add.field.repositoryHint`),t[75]=a,t[76]=xe);let Se;t[77]===xe?Se=t[78]:(Se=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:xe}),t[77]=xe,t[78]=Se);let Ce;t[79]!==_e||t[80]!==be||t[81]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[_e,be,Se]}),t[79]=_e,t[80]=be,t[81]=Se,t[82]=Ce):Ce=t[82];let we;t[83]===a?we=t[84]:(we=a(`settings.skills.catalog.add.field.optionalSubpath`),t[83]=a,t[84]=we);let Te;t[85]===we?Te=t[86]:(Te=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:we}),t[85]=we,t[86]=Te);let Ee;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>{_(e.target.value),N({clearIdentity:!0})},t[87]=Ee):Ee=t[87];let De;t[88]===a?De=t[89]:(De=a(`settings.skills.catalog.shared.field.subpathPlaceholder`),t[88]=a,t[89]=De);let Oe;t[90]!==g||t[91]!==De?(Oe=(0,$.jsx)(ln,{value:g,onChange:Ee,placeholder:De}),t[90]=g,t[91]=De,t[92]=Oe):Oe=t[92];let Ae;t[93]!==Te||t[94]!==Oe?(Ae=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Te,Oe]}),t[93]=Te,t[94]=Oe,t[95]=Ae):Ae=t[95];let je;t[96]!==O||t[97]!==E||t[98]!==a?(je=E.length>0&&!m()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-[var(--status-warning)]`,children:a(`settings.skills.catalog.shared.auth.title`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:a(`settings.skills.catalog.shared.auth.description`)})]}),(0,$.jsxs)(an,{value:O||``,onValueChange:e=>{k(e),N()},children:[(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(`span`,{children:E.find(e=>e.id===O)?.name||a(`settings.skills.catalog.shared.auth.chooseIdentity`)})}),(0,$.jsx)(nn,{align:`start`,children:E.map(Wc)})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:a(`settings.skills.catalog.shared.auth.footerHint`)})]}):null,t[96]=O,t[97]=E,t[98]=a,t[99]=je):je=t[99];let Me;t[100]!==x||t[101]!==a?(Me=x===null?null:(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.scanResult`,{count:x})}),t[100]=x,t[101]=a,t[102]=Me):Me=t[102];let Ne;t[103]!==ee||t[104]!==a?(Ne=ee?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.duplicateMessage`)}):null,t[103]=ee,t[104]=a,t[105]=Ne):Ne=t[105];let Pe;t[106]!==he||t[107]!==Ce||t[108]!==Ae||t[109]!==je||t[110]!==Me||t[111]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[he,Ce,Ae,je,Me,Ne]}),t[106]=he,t[107]=Ce,t[108]=Ae,t[109]=je,t[110]=Me,t[111]=Ne,t[112]=Pe):Pe=t[112];let Fe;t[113]===r?Fe=t[114]:(Fe=()=>r(!1),t[113]=r,t[114]=Fe);let Ie;t[115]===a?Ie=t[116]:(Ie=a(`settings.common.actions.cancel`),t[115]=a,t[116]=Ie);let Le;t[117]!==Fe||t[118]!==Ie?(Le=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:Fe,children:Ie}),t[117]=Fe,t[118]=Ie,t[119]=Le):Le=t[119];let Re;t[120]===te?Re=t[121]:(Re=()=>void te(),t[120]=te,t[121]=Re);let ze;t[122]!==c||t[123]!==p?(ze=c||!p.trim(),t[122]=c,t[123]=p,t[124]=ze):ze=t[124];let Be;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,$.jsx)(J,{name:`git-repository`,className:`h-4 w-4`}),t[125]=Be):Be=t[125];let Ve;t[126]!==c||t[127]!==a?(Ve=a(c?`settings.skills.catalog.shared.actions.scanning`:`settings.skills.catalog.shared.actions.scan`),t[126]=c,t[127]=a,t[128]=Ve):Ve=t[128];let He;t[129]!==Re||t[130]!==ze||t[131]!==Ve?(He=(0,$.jsxs)(Y,{size:`sm`,className:`gap-2`,variant:`ghost`,onClick:Re,disabled:ze,children:[Be,Ve]}),t[129]=Re,t[130]=ze,t[131]=Ve,t[132]=He):He=t[132];let Ue;t[133]===ne?Ue=t[134]:(Ue=()=>void ne(),t[133]=ne,t[134]=Ue);let We;t[135]!==ee||t[136]!==d||t[137]!==C||t[138]!==p?(We=!C||ee||!d.trim()||!p.trim(),t[135]=ee,t[136]=d,t[137]=C,t[138]=p,t[139]=We):We=t[139];let Ge;t[140]===a?Ge=t[141]:(Ge=a(`settings.skills.catalog.add.actions.addCatalog`),t[140]=a,t[141]=Ge);let Ke;t[142]!==Ue||t[143]!==We||t[144]!==Ge?(Ke=(0,$.jsx)(Y,{size:`sm`,onClick:Ue,disabled:We,children:Ge}),t[142]=Ue,t[143]=We,t[144]=Ge,t[145]=Ke):Ke=t[145];let qe;t[146]!==Le||t[147]!==He||t[148]!==Ke?(qe=(0,$.jsxs)(Wt,{children:[Le,He,Ke]}),t[146]=Le,t[147]=He,t[148]=Ke,t[149]=qe):qe=t[149];let Je;t[150]!==le||t[151]!==Pe||t[152]!==qe?(Je=(0,$.jsxs)(Gt,{className:`max-w-xl`,children:[le,Pe,qe]}),t[150]=le,t[151]=Pe,t[152]=qe,t[153]=Je):Je=t[153];let Ye;return t[154]!==r||t[155]!==n||t[156]!==Je?(Ye=(0,$.jsx)(Jt,{open:n,onOpenChange:r,children:Je}),t[154]=r,t[155]=n,t[156]=Je,t[157]=Ye):Ye=t[157],Ye};function zc(e){return e.scanRepo}function Bc(e){return e.setSelectedSource}function Vc(e){return e.isScanning}function Hc(e){return e.defaultGitIdentityId}function Uc(e){return e.loadDefaultGitIdentityId}function Wc(e){return(0,$.jsx)($t,{value:e.id,children:e.name},e.id)}var Gc=e=>{let t=(0,Ei.c)(85),{open:n,onOpenChange:r,conflicts:i,onConfirm:a}=e,{t:o}=ke(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={},t[0]=s):s=t[0];let[c,l]=Q.useState(s),u,d;t[1]!==i||t[2]!==n?(u=()=>{if(!n)return;let e={};for(let t of i)e[t.skillName]=`skip`;l(e)},d=[n,i],t[1]=i,t[2]=n,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;t[5]===i?f=t[6]:(f=e=>{let t={};for(let n of i)t[n.skillName]=e;l(t)},t[5]=i,t[6]=f);let p=f,m;t[7]!==i||t[8]!==c?(m=i.length>0&&i.every(e=>c[e.skillName]),t[7]=i,t[8]=c,t[9]=m):m=t[9];let h=m,g;t[10]===o?g=t[11]:(g=o(`settings.skills.catalog.conflicts.title`),t[10]=o,t[11]=g);let _;t[12]===g?_=t[13]:(_=(0,$.jsx)(Kt,{children:g}),t[12]=g,t[13]=_);let v;t[14]===o?v=t[15]:(v=o(`settings.skills.catalog.conflicts.description`),t[14]=o,t[15]=v);let y;t[16]===v?y=t[17]:(y=(0,$.jsx)(qt,{children:v}),t[16]=v,t[17]=y);let b;t[18]!==_||t[19]!==y?(b=(0,$.jsxs)(Ut,{children:[_,y]}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==i.length||t[22]!==o?(x=o(`settings.skills.catalog.conflicts.count`,{count:i.length}),t[21]=i.length,t[22]=o,t[23]=x):x=t[23];let S;t[24]===x?S=t[25]:(S=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:x}),t[24]=x,t[25]=S);let C;t[26]===p?C=t[27]:(C=()=>p(`skip`),t[26]=p,t[27]=C);let w;t[28]===o?w=t[29]:(w=o(`settings.skills.catalog.conflicts.actions.skipAll`),t[28]=o,t[29]=w);let T;t[30]!==C||t[31]!==w?(T=(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:C,children:w}),t[30]=C,t[31]=w,t[32]=T):T=t[32];let E;t[33]===p?E=t[34]:(E=()=>p(`overwrite`),t[33]=p,t[34]=E);let D;t[35]===o?D=t[36]:(D=o(`settings.skills.catalog.conflicts.actions.overwriteAll`),t[35]=o,t[36]=D);let O;t[37]!==E||t[38]!==D?(O=(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:E,children:D}),t[37]=E,t[38]=D,t[39]=O):O=t[39];let k;t[40]!==T||t[41]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T,O]}),t[40]=T,t[41]=O,t[42]=k):k=t[42];let A;t[43]!==S||t[44]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[S,k]}),t[43]=S,t[44]=k,t[45]=A):A=t[45];let j;if(t[46]!==i||t[47]!==c||t[48]!==o){let e;t[50]!==c||t[51]!==o?(e=e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label truncate`,children:e.skillName}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:o(`settings.skills.catalog.conflicts.installedIn`,{scope:e.scope===`project`?o(`settings.skills.catalog.conflicts.scope.project`):o(`settings.skills.catalog.conflicts.scope.user`),source:e.source===`agents`?o(`settings.skills.catalog.conflicts.source.agents`):o(`settings.skills.catalog.conflicts.source.opencode`)})})]}),(0,$.jsxs)(an,{value:c[e.skillName]||`skip`,onValueChange:t=>l(n=>({...n,[e.skillName]:t})),children:[(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(`span`,{className:`capitalize`,children:(c[e.skillName]||`skip`)===`overwrite`?o(`settings.skills.catalog.conflicts.decision.overwrite`):o(`settings.skills.catalog.conflicts.decision.skip`)})}),(0,$.jsxs)(nn,{align:`end`,children:[(0,$.jsx)($t,{value:`skip`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.skip`)}),(0,$.jsx)($t,{value:`overwrite`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.overwrite`)})]})]})]},e.skillName),t[50]=c,t[51]=o,t[52]=e):e=t[52],j=i.map(e),t[46]=i,t[47]=c,t[48]=o,t[49]=j}else j=t[49];let M;t[53]===j?M=t[54]:(M=(0,$.jsx)(`div`,{className:`space-y-2`,children:j}),t[53]=j,t[54]=M);let N;t[55]!==A||t[56]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[A,M]}),t[55]=A,t[56]=M,t[57]=N):N=t[57];let P;t[58]===r?P=t[59]:(P=()=>r(!1),t[58]=r,t[59]=P);let F;t[60]===o?F=t[61]:(F=o(`settings.common.actions.cancel`),t[60]=o,t[61]=F);let I;t[62]!==P||t[63]!==F?(I=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:P,children:F}),t[62]=P,t[63]=F,t[64]=I):I=t[64];let L;t[65]!==c||t[66]!==a?(L=()=>a(c),t[65]=c,t[66]=a,t[67]=L):L=t[67];let R=!h,z;t[68]===o?z=t[69]:(z=o(`settings.skills.catalog.conflicts.actions.continue`),t[68]=o,t[69]=z);let B;t[70]!==L||t[71]!==R||t[72]!==z?(B=(0,$.jsx)(Y,{size:`sm`,onClick:L,disabled:R,children:z}),t[70]=L,t[71]=R,t[72]=z,t[73]=B):B=t[73];let V;t[74]!==I||t[75]!==B?(V=(0,$.jsxs)(Wt,{children:[I,B]}),t[74]=I,t[75]=B,t[76]=V):V=t[76];let H;t[77]!==b||t[78]!==N||t[79]!==V?(H=(0,$.jsxs)(Gt,{className:`max-w-2xl`,children:[b,N,V]}),t[77]=b,t[78]=N,t[79]=V,t[80]=H):H=t[80];let ee;return t[81]!==r||t[82]!==n||t[83]!==H?(ee=(0,$.jsx)(Jt,{open:n,onOpenChange:r,children:H}),t[81]=r,t[82]=n,t[83]=H,t[84]=ee):ee=t[84],ee},Kc=[{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 qc(e,t){return e===`project`&&t===`claude`?`project-claude`:e===`project`&&t===`agents`?`project-agents`:t===`claude`?`user-claude`:e===`project`?`project-opencode`:t===`agents`?`user-agents`:`user-opencode`}function Jc(e){if(e===`user-claude`)return{scope:`user`,source:`claude`};if(e===`project-claude`)return{scope:`project`,source:`claude`};let t=Kc.find(t=>t.value===e);return t?{scope:t.scope,source:t.source}:{scope:`user`,source:`opencode`}}var Yc=e=>{let t=(0,Ei.c)(124),{open:n,onOpenChange:r,item:a}=e,{t:o}=ke(),s=Pc(Xc),c=Pc(Zc),[l,u]=Q.useState(`user`),[d,f]=Q.useState(`opencode`),p=ft(Qc),m=ft($c),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],t[0]=y):y=t[0];let[b,x]=Q.useState(y),[S,C]=Q.useState(null),w,T;t[1]!==m||t[2]!==n?(w=()=>{n&&(u(`user`),f(`opencode`),g(m),v(!1),x([]),C(null))},T=[n,m],t[1]=m,t[2]=n,t[3]=w,t[4]=T):(w=t[3],T=t[4]),Q.useEffect(w,T);let E;t[5]===o?E=t[6]:(E=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.label`);case`user-agents`:return o(`settings.skills.location.option.userAgents.label`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.label`);default:return o(`settings.skills.location.option.userOpencode.label`)}},t[5]=o,t[6]=E);let D=E,O;t[7]===o?O=t[8]:(O=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.description`);case`user-agents`:return o(`settings.skills.location.option.userAgents.description`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.description`);default:return o(`settings.skills.location.option.userOpencode.description`)}},t[7]=o,t[8]=O);let k=O,A;bb0:{if(p.length===0){A=null;break bb0}if(h&&p.some(e=>e.id===h)){A=h;break bb0}if(m&&p.some(e=>e.id===m)){A=m;break bb0}A=p[0]?.id??null}let j=A,M;bb1:{if(l!==`project`){M=null;break bb1}let e=j;if(!e){M=null;break bb1}let n;if(t[9]!==e||t[10]!==p){let r;t[12]===e?r=t[13]:(r=t=>t.id===e,t[12]=e,t[13]=r),n=p.find(r),t[9]=e,t[10]=p,t[11]=n}else n=t[11];M=n?.path??null}let N=M,P;t[14]!==s||t[15]!==a||t[16]!==r||t[17]!==o?(P=async e=>{let t={skillDir:e.skillDir};a?.clawdhub&&(t.clawdhub={slug:a.clawdhub.slug,version:a.clawdhub.version});let n=await s({source:e.source,subpath:e.subpath,gitIdentityId:a?.gitIdentityId,scope:e.scope,targetSource:e.targetSource,selections:[t],conflictPolicy:`prompt`,conflictDecisions:e.conflictDecisions},{directory:e.effectiveDirectory,transportIdentity:e.transportIdentity});if(n.ok){K.success(o(`settings.skills.catalog.installSkill.toast.installed`)),r(!1);return}if(n.error?.kind===`conflicts`){C({source:e.source,subpath:e.subpath,scope:e.scope,targetSource:e.targetSource,skillDir:e.skillDir,directoryOverride:e.directoryOverride??null,effectiveDirectory:e.effectiveDirectory,transportIdentity:e.transportIdentity}),x(n.error.conflicts),v(!0);return}if(n.error?.kind===`authRequired`){K.error(n.error.message||o(`settings.skills.catalog.installSkill.toast.authRequired`));return}K.error(n.error?.message||o(`settings.skills.catalog.installSkill.toast.installFailed`))},t[14]=s,t[15]=a,t[16]=r,t[17]=o,t[18]=P):P=t[18];let F=P;if(!a)return null;let I;t[19]===o?I=t[20]:(I=o(`settings.skills.catalog.installSkill.title`),t[19]=o,t[20]=I);let L;t[21]===I?L=t[22]:(L=(0,$.jsx)(Kt,{children:I}),t[21]=I,t[22]=L);let R;t[23]===o?R=t[24]:(R=o(`settings.skills.catalog.installSkill.descriptionPrefix`),t[23]=o,t[24]=R);let z;t[25]===a.skillName?z=t[26]:(z=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:a.skillName}),t[25]=a.skillName,t[26]=z);let B;t[27]===o?B=t[28]:(B=o(`settings.skills.catalog.installSkill.descriptionSuffix`),t[27]=o,t[28]=B);let V;t[29]!==R||t[30]!==z||t[31]!==B?(V=(0,$.jsxs)(qt,{children:[R,` `,z,` `,B]}),t[29]=R,t[30]=z,t[31]=B,t[32]=V):V=t[32];let H;t[33]!==L||t[34]!==V?(H=(0,$.jsxs)(Ut,{children:[L,V]}),t[33]=L,t[34]=V,t[35]=H):H=t[35];let ee;t[36]===o?ee=t[37]:(ee=o(`settings.skills.catalog.installSkill.field.destination`),t[36]=o,t[37]=ee);let U;t[38]===ee?U=t[39]:(U=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:ee}),t[38]=ee,t[39]=U);let te;t[40]!==l||t[41]!==d?(te=qc(l,d),t[40]=l,t[41]=d,t[42]=te):te=t[42];let W;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{let t=Jc(e);u(t.scope),f(t.source===`agents`?`agents`:`opencode`)},t[43]=W):W=t[43];let ne;t[44]===l?ne=t[45]:(ne=l===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),t[44]=l,t[45]=ne);let re;t[46]===d?re=t[47]:(re=d===`agents`?(0,$.jsx)(J,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,t[46]=d,t[47]=re);let ie;t[48]!==D||t[49]!==l||t[50]!==d?(ie=D(qc(l,d)),t[48]=D,t[49]=l,t[50]=d,t[51]=ie):ie=t[51];let ae;t[52]===ie?ae=t[53]:(ae=(0,$.jsx)(`span`,{children:ie}),t[52]=ie,t[53]=ae);let oe;t[54]!==ne||t[55]!==re||t[56]!==ae?(oe=(0,$.jsxs)(tn,{className:`w-fit gap-1.5`,children:[ne,re,ae]}),t[54]=ne,t[55]=re,t[56]=ae,t[57]=oe):oe=t[57];let se;t[58]!==k||t[59]!==D?(se=Kc.map(e=>(0,$.jsx)($t,{value:e.value,className:`pr-2 [&>span:first-child]:hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(J,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:D(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-5`,children:k(e.value)})]})},e.value)),t[58]=k,t[59]=D,t[60]=se):se=t[60];let ce;t[61]===se?ce=t[62]:(ce=(0,$.jsx)(nn,{align:`start`,children:se}),t[61]=se,t[62]=ce);let le;t[63]!==te||t[64]!==oe||t[65]!==ce?(le=(0,$.jsxs)(an,{value:te,onValueChange:W,children:[oe,ce]}),t[63]=te,t[64]=oe,t[65]=ce,t[66]=le):le=t[66];let ue;t[67]!==U||t[68]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[U,le]}),t[67]=U,t[68]=le,t[69]=ue):ue=t[69];let de;t[70]!==p||t[71]!==j||t[72]!==l||t[73]!==o?(de=l===`project`&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.skills.catalog.installSkill.field.project`)}),p.length===0?(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.skills.catalog.installSkill.field.noProjects`)}):(0,$.jsxs)(an,{value:j??``,onValueChange:e=>g(e),disabled:p.length===1,children:[(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:o(`settings.skills.catalog.installSkill.field.chooseProjectPlaceholder`)})}),(0,$.jsx)(nn,{align:`start`,children:p.map(el)})]})]}),t[70]=p,t[71]=j,t[72]=l,t[73]=o,t[74]=de):de=t[74];let fe;t[75]===a.warnings?fe=t[76]:(fe=a.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded`,children:a.warnings.join(` · `)}):null,t[75]=a.warnings,t[76]=fe);let pe;t[77]!==ue||t[78]!==de||t[79]!==fe?(pe=(0,$.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[ue,de,fe]}),t[77]=ue,t[78]=de,t[79]=fe,t[80]=pe):pe=t[80];let me;t[81]===r?me=t[82]:(me=()=>r(!1),t[81]=r,t[82]=me);let he;t[83]===o?he=t[84]:(he=o(`settings.common.actions.cancel`),t[83]=o,t[84]=he);let ge;t[85]!==me||t[86]!==he?(ge=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:me,children:he}),t[85]=me,t[86]=he,t[87]=ge):ge=t[87];let _e=c||!a.installable||l===`project`&&!N,ve;t[88]!==N||t[89]!==F||t[90]!==a.repoSource||t[91]!==a.repoSubpath||t[92]!==a.skillDir||t[93]!==l||t[94]!==d?(ve=()=>void F({source:a.repoSource,subpath:a.repoSubpath,scope:l,targetSource:d,skillDir:a.skillDir,directoryOverride:N,effectiveDirectory:N??rt(),transportIdentity:i()}),t[88]=N,t[89]=F,t[90]=a.repoSource,t[91]=a.repoSubpath,t[92]=a.skillDir,t[93]=l,t[94]=d,t[95]=ve):ve=t[95];let ye;t[96]!==c||t[97]!==o?(ye=o(c?`settings.skills.catalog.installSkill.actions.installing`:`settings.skills.catalog.installSkill.actions.install`),t[96]=c,t[97]=o,t[98]=ye):ye=t[98];let be;t[99]!==_e||t[100]!==ve||t[101]!==ye?(be=(0,$.jsx)(Y,{size:`sm`,disabled:_e,onClick:ve,children:ye}),t[99]=_e,t[100]=ve,t[101]=ye,t[102]=be):be=t[102];let xe;t[103]!==ge||t[104]!==be?(xe=(0,$.jsxs)(Wt,{children:[ge,be]}),t[103]=ge,t[104]=be,t[105]=xe):xe=t[105];let Se;t[106]!==H||t[107]!==pe||t[108]!==xe?(Se=(0,$.jsxs)(Gt,{className:`max-w-md`,children:[H,pe,xe]}),t[106]=H,t[107]=pe,t[108]=xe,t[109]=Se):Se=t[109];let Ce;t[110]!==r||t[111]!==n||t[112]!==Se?(Ce=(0,$.jsx)(Jt,{open:n,onOpenChange:r,children:Se}),t[110]=r,t[111]=n,t[112]=Se,t[113]=Ce):Ce=t[113];let we;t[114]!==S||t[115]!==F?(we=e=>{S&&(F({source:S.source,subpath:S.subpath,scope:S.scope,targetSource:S.targetSource,skillDir:S.skillDir,conflictDecisions:e,directoryOverride:S.directoryOverride??null,effectiveDirectory:S.effectiveDirectory,transportIdentity:S.transportIdentity}),v(!1))},t[114]=S,t[115]=F,t[116]=we):we=t[116];let Te;t[117]!==b||t[118]!==_||t[119]!==we?(Te=(0,$.jsx)(Gc,{open:_,onOpenChange:v,conflicts:b,onConfirm:we}),t[117]=b,t[118]=_,t[119]=we,t[120]=Te):Te=t[120];let Ee;return t[121]!==Ce||t[122]!==Te?(Ee=(0,$.jsxs)($.Fragment,{children:[Ce,Te]}),t[121]=Ce,t[122]=Te,t[123]=Ee):Ee=t[123],Ee};function Xc(e){return e.installSkills}function Zc(e){return e.isInstalling}function Qc(e){return e.projects}function $c(e){return e.activeProjectId}function el(e){return(0,$.jsx)($t,{value:e.id,children:e.label||e.path},e.id)}var tl=async()=>{try{let e=U()?.settings;if(e)return(await e.load())?.settings||{};let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},nl=({mode:e,onModeChange:t,showModeTabs:n=!0})=>{let{t:r}=ke(),{selectedSourceId:a,setSelectedSource:o}=Pc(he(e=>({selectedSourceId:e.selectedSourceId,setSelectedSource:e.setSelectedSource}))),s=wt(),c=s.data??lt,l=c.some(e=>e.id===a)?a:null,u=bt(l??``,{enabled:!!l}),[d,f]=Q.useState(``),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(null),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(!1),[T,E]=Q.useState(null);Q.useEffect(()=>{!s.data&&s.isFetching||c.some(e=>e.id===a)||o(c[0]?.id??null)},[a,o,c,s.data,s.isFetching]);let D=rt(),O=i();Q.useEffect(()=>{E(null)},[l,D,O]);let k=Q.useMemo(()=>Et(u.data?.pages??[]),[u.data]),A=Q.useMemo(()=>{let e=d.trim().toLowerCase();return e?k.filter(t=>{let n=t.skillName.toLowerCase(),r=(t.description||``).toLowerCase(),i=(t.frontmatterName||``).toLowerCase();return n.includes(e)||r.includes(e)||i.includes(e)}):k},[k,d]),j=Q.useMemo(()=>c.find(e=>e.id===l)||null,[c,l]),M=!!(l&&l.startsWith(`custom:`)),N=j?.source===`clawdhub:registry`||j?.sourceType===`clawdhub`,P=s.isLoading&&!s.data,F=u.isLoading&&!u.data,I=u.isFetchingNextPage,L=T??s.error??u.error,R=async()=>{if(!l||!M)return;let e=rt(),t=i();b(!0),E(null);try{let n=await tl(),r=(Array.isArray(n?.skillCatalogs)?n?.skillCatalogs:[]).filter(e=>e.id!==l);await V({skillCatalogs:r}),H.setQueriesData({queryKey:[t,`skillsCatalog`,`sources`],exact:!1},e=>e?.filter(e=>e.id!==l)),H.removeQueries({queryKey:[t,`skillsCatalog`,`source`],exact:!1,predicate:e=>e.queryKey[4]===l}),i()===t&&(o(null),S(!1)),await pt(H,e,t)}catch(n){i()===t&&rt()===e&&E(n instanceof Error?n:Error(String(n)))}finally{b(!1)}},z=async()=>{let e=rt(),t=i(),n=l;w(!0),E(null);try{n?await Ct(H,e,n,t):await pt(H,e,t)}catch(r){let a=Pc.getState().selectedSourceId;i()===t&&rt()===e&&a===n&&E(r instanceof Error?r:Error(String(r)))}finally{w(!1)}};return(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n&&(0,$.jsx)(`div`,{className:`h-10`,children:(0,$.jsx)(Cr,{items:[{id:`manual`,label:r(`settings.skills.catalog.page.mode.manual`)},{id:`external`,label:r(`settings.skills.catalog.page.mode.external`)}],activeId:e,onSelect:e=>t(e),layoutMode:`fit`,variant:`animated`,animateActivePill:!1,className:`h-full`})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.catalog.source`,children:(0,$.jsx)(Z,{label:r(`settings.skills.catalog.page.section.sourceRepository`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 py-1.5`,children:[(0,$.jsxs)(an,{value:l||``,onValueChange:e=>o(e),children:[(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:r(`settings.skills.catalog.page.field.selectSourcePlaceholder`),children:j?.label})}),(0,$.jsx)(nn,{align:`start`,children:c.map(e=>(0,$.jsx)($t,{value:e.id,children:e.label},e.id))})]}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal h-6 w-6 px-0`,onClick:()=>void z(),disabled:C,title:r(`settings.skills.catalog.page.actions.refreshTitle`),children:(0,$.jsx)(J,{name:`refresh`,className:q(`h-3.5 w-3.5`,C&&`animate-spin`)})}),M&&(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>S(!0),disabled:y,title:r(`settings.skills.catalog.page.actions.removeCatalogTitle`),children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(Y,{"data-settings-item":`skills.catalog.add-catalog`,size:`xs`,className:`!font-normal gap-1`,onClick:()=>m(!0),children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),` `,r(`settings.skills.catalog.page.actions.addCatalog`)]})]}),(0,$.jsxs)(`div`,{"data-settings-item":`skills.catalog.search`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(J,{name:`search`,className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(ln,{value:d,onChange:e=>f(e.target.value),placeholder:r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),className:`h-7 pl-8 w-full sm:w-64`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground mt-1 block`,children:P?r(`settings.skills.catalog.page.loading.catalog`):r(`settings.skills.catalog.page.foundCount`,{count:A.length})})]})]})})}),L&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:r(`settings.skills.catalog.page.error.catalogTitle`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:L.message})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{children:A.length===0&&!F?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-body`,children:r(`settings.skills.catalog.page.empty.noSkillsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.catalog.page.empty.noSkillsDescription`)})]}):F?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`refresh`,className:`mx-auto mb-3 h-5 w-5 animate-spin opacity-50`}),(0,$.jsx)(`p`,{className:`typography-meta`,children:r(`settings.skills.catalog.page.loading.skills`)})]}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:A.map(e=>{let t=e.installed?.isInstalled,n=e.installed?.scope;return(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.skillName}),t&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)] bg-[var(--status-success)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.installed`,{scope:n||r(`settings.skills.catalog.page.badge.unknown`)})}),!e.installable&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.notInstallable`)})]}),e.description?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 line-clamp-2`,children:e.description}):(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground/50 mt-0.5 italic`,children:r(`settings.skills.catalog.shared.noDescription`)}),e.clawdhub&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground mt-1.5 flex items-center gap-3`,children:[e.clawdhub.owner&&(0,$.jsxs)(`span`,{children:[r(`settings.skills.catalog.page.byOwnerPrefix`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.clawdhub.owner})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(J,{name:`download`,className:`h-3 w-3`}),e.clawdhub.downloads?.toLocaleString()??0]}),(e.clawdhub.stars??0)>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(J,{name:`star`,className:`h-3 w-3`}),e.clawdhub.stars]}),(0,$.jsxs)(`span`,{className:`bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[`v`,e.clawdhub.version]})]}),e.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit`,children:e.warnings.join(` · `)}):null]}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,disabled:!e.installable,onClick:()=>{v(e),g(!0)},children:r(`settings.skills.catalog.shared.actions.install`)})]})},`${e.sourceId}:${e.skillDir}`)})})}),N&&u.hasNextPage&&!F&&A.length>0&&(0,$.jsx)(`div`,{className:`flex justify-center mt-2 px-2`,children:(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void u.fetchNextPage(),disabled:I,children:r(I?`settings.skills.catalog.page.loading.more`:`settings.skills.catalog.page.actions.loadMoreSkills`)})})]}),(0,$.jsx)(Rc,{open:p,onOpenChange:m}),(0,$.jsx)(Yc,{open:h,onOpenChange:g,item:_}),(0,$.jsx)(Jt,{open:x,onOpenChange:e=>{y||S(e)},children:(0,$.jsxs)(Gt,{className:`max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:r(`settings.skills.catalog.page.removeDialog.title`)}),(0,$.jsx)(qt,{children:r(`settings.skills.catalog.page.removeDialog.description`)})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>S(!1),disabled:y,children:r(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>void R(),disabled:y,children:r(`settings.skills.catalog.page.actions.removeCatalog`)})]})]})})]})})},rl=()=>{let e=(0,Ei.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(nl,{mode:`external`,onModeChange:fl,showModeTabs:!1}),e[0]=t):t=e[0],t},il=`SKILL.md`,al=`h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]`,ol=(e,t)=>{let n=Ci({description:e}).trimEnd(),r=t.trimStart();return`---\n${n}\n---${r?`\n\n${r}`:`
|
|
22
|
-
`}`},sl=e=>typeof e==`object`&&!!e&&!Array.isArray(e),cl=e=>{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!t)return{description:null,instructions:e};let n=null;try{let e=wi(t[1]);if(sl(e)){let t=e.description;typeof t==`string`&&(n=t)}}catch{n=null}return{description:n,instructions:t[2].replace(/^\r?\n/,``)}},ll=(e,t)=>ol(t,cl(e).instructions),ul=()=>{let{t:e}=ke(),{currentTheme:t}=ur(),{selectedSkillName:n,getSkillDetail:r,createSkill:i,updateSkill:a,skillDraft:o,setSkillDraft:s,setSelectedSkill:c}=da(he(e=>({selectedSkillName:e.selectedSkillName,getSkillDetail:e.getSkillDetail,createSkill:e.createSkill,updateSkill:e.updateSkill,skillDraft:e.skillDraft,setSkillDraft:e.setSkillDraft,setSelectedSkill:e.setSelectedSkill}))),l=Fe(),d=Je(),f=Q.useMemo(()=>l.data??[],[l.data]),p=n?f.find(e=>e.name===n)??null:null,m=!!(o&&o.name===n&&!p),h=!!(n&&!p&&!o),g=p?.path===`<built-in>`;Q.useEffect(()=>{h&&c(null)},[h,c]);let[_,v]=Q.useState(``),[y,b]=Q.useState(`user`),[x,S]=Q.useState(`opencode`),[C,w]=Q.useState(``),[T,E]=Q.useState(``),[D,O]=Q.useState(()=>ol(``,``)),[k,A]=Q.useState(`edit`),[j,M]=Q.useState([]),[N,P]=Q.useState([]),[F,I]=Q.useState(!1),[L,R]=Q.useState(!1),[z,B]=Q.useState(``),[V,H]=Q.useState(``),[ee,U]=Q.useState(!1),[te,W]=Q.useState(``),[ne,re]=Q.useState(``),[ie,ae]=Q.useState(null),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(``),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(!1),me=m?_.trim()!==``||C.trim()!==``||T.trim()!==``||N.length>0:C!==z||T!==V,ge=ie?ne!==ce:te.trim()!==``,_e=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.label`);case`user-claude`:return e(`settings.skills.location.option.userClaude.label`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.label`);case`user-agents`:return e(`settings.skills.location.option.userAgents.label`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.label`);default:return e(`settings.skills.location.option.userOpencode.label`)}},[e]),ve=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.description`);case`user-claude`:return e(`settings.skills.location.option.userClaude.description`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.description`);case`user-agents`:return e(`settings.skills.location.option.userAgents.description`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.description`);default:return e(`settings.skills.location.option.userOpencode.description`)}},[e]);Q.useEffect(()=>{(async()=>{if(m&&o){let e=o.description||``,t=o.instructions||``;v(o.name||``),b(o.scope||`user`),S(o.source===`agents`?`agents`:`opencode`),w(e),E(t),O(ol(e,t)),B(``),H(``),M([]),P(o.pendingFiles||[])}else if(n&&p){R(!0);try{let e=await r(n);if(e){let t=e.sources.md,n=t.description||``,r=t.instructions||``;w(n),E(r),O(ol(n,r)),B(n),H(r),M(t.supportingFiles||[])}}catch(e){console.error(`Failed to load skill details:`,e)}finally{R(!1)}}})()},[p,m,n,f,o,r]);let ye=u(e=>e.editorFontSize),be=Q.useMemo(()=>{let e=[ii(t,{fontSize:ye})],n=sr(il);return n&&e.push(n),e.push(Te.lineWrapping),e},[t,ye]),xe=Q.useMemo(()=>{let e=te.trim()||`supporting-file.md`,n=Sr(e),r=!!n&&n!==`markdown`,i=[ii(t,r?{syntaxColors:!1,fontSize:ye}:{fontSize:ye})],a=sr(e);return a&&i.push(a),r&&n&&i.push(Rr({language:n,themeName:t.metadata.id,theme:_r(t)})),i.push(Te.lineWrapping),i},[t,te,ye]),Se=Q.useCallback(e=>{w(e),O(t=>ll(t,e))},[]),Ce=Q.useCallback(e=>{O(e);let t=cl(e);w(t.description??``),E(t.instructions)},[]),we=async()=>{let t=m?_.trim().replace(/\s+/g,`-`).toLowerCase():n?.trim();if(!t){K.error(e(`settings.skills.page.toast.skillNameRequired`));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(t)||t.length>64){K.error(e(`settings.skills.page.toast.invalidSkillName`));return}if(!C.trim()){K.error(e(`settings.skills.page.toast.descriptionRequired`));return}if(m&&f.some(e=>e.name===t)){K.error(e(`settings.skills.page.toast.skillExists`));return}I(!0);try{let n={name:t,description:C.trim(),instructions:T.trim()||void 0,scope:m?y:void 0,source:m?x:void 0,targetPath:m?void 0:p?.path,supportingFiles:m&&N.length>0?N:void 0},r;m?(r=await i(n,{directory:d}),r&&(s(null),P([]),c(t))):(r=await a(t,n,{directory:d}),r&&(B(C.trim()),H(T.trim()))),r?K.success(e(m?`settings.skills.page.toast.skillCreated`:`settings.skills.page.toast.skillUpdated`)):K.error(e(m?`settings.skills.page.toast.createSkillFailed`:`settings.skills.page.toast.updateSkillFailed`))}catch(t){console.error(`Error saving skill:`,t),K.error(e(`settings.skills.page.toast.saveUnexpectedError`))}finally{I(!1)}},Ee=()=>{ae(null),W(``),re(``),le(``),U(!0)},De=async t=>{if(ae(t),W(t),m){let e=N.find(e=>e.path===t)?.content||``;re(e),le(e),U(!0);return}if(n){se(!0),U(!0);try{let{readSupportingFile:e}=da.getState(),r=await e(n,t);re(r||``),le(r||``)}catch{K.error(e(`settings.skills.page.toast.loadFileContentFailed`)),re(``),le(``)}finally{se(!1)}}},Oe=async()=>{if(!te.trim()){K.error(e(`settings.skills.page.toast.fileNameRequired`));return}let t=te.trim(),i=ie!==null;if(m){if(i)P(e=>e.map(e=>e.path===ie?{path:t,content:ne}:e)),K.success(e(`settings.skills.page.toast.fileUpdated`,{path:t}));else{if(N.some(e=>e.path===t)){K.error(e(`settings.skills.page.toast.fileExists`));return}P(e=>[...e,{path:t,content:ne}]),K.success(e(`settings.skills.page.toast.fileAdded`,{path:t}))}U(!1),ae(null);return}if(!n){K.error(e(`settings.skills.page.toast.noSkillSelected`));return}let{writeSupportingFile:a}=da.getState();if(await a(n,t,ne)){K.success(e(i?`settings.skills.page.toast.fileUpdated`:`settings.skills.page.toast.fileCreated`,{path:t})),U(!1),ae(null);let a=await r(n);a&&M(a.sources.md.supportingFiles||[])}else K.error(e(i?`settings.skills.page.toast.updateFileFailed`:`settings.skills.page.toast.createFileFailed`))},Ae=t=>{if(m){P(e=>e.filter(e=>e.path!==t)),K.success(e(`settings.skills.page.toast.fileRemoved`,{path:t}));return}n&&de(t)};return!n&&!o||h?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.skills.page.empty.description`)})]})}):L?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.loading.details`)})})}):(0,$.jsxs)(yr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate flex items-center gap-2`,children:m?e(`settings.skills.page.title.newSkill`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:p?e(`settings.skills.page.subtitle.skillLocation`,{location:_e(qc(p.scope,p.source))}):e(`settings.skills.page.subtitle.newSkill`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.basic-information`,children:(0,$.jsx)(Z,{label:e(`settings.skills.page.section.basicInformation`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[m&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.skills.page.field.skillNameLocation`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.skillNameHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,$.jsx)(ln,{value:_,onChange:e=>v(e.target.value.toLowerCase().replace(/\s+/g,`-`)),placeholder:e(`settings.skills.page.field.skillNamePlaceholder`),className:`h-7 w-40 px-2`}),(0,$.jsxs)(an,{value:qc(y,x),onValueChange:e=>{let t=Jc(e);b(t.scope),S(t.source===`agents`?`agents`:`opencode`)},children:[(0,$.jsxs)(tn,{className:`w-fit gap-1.5`,children:[y===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),x===`agents`?(0,$.jsx)(J,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:_e(qc(y,x))})]}),(0,$.jsx)(nn,{align:`start`,children:Kc.map(e=>(0,$.jsx)($t,{value:e.value,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(J,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:_e(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-6`,children:ve(e.value)})]})},e.value))})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[e(`settings.common.field.description`),` `,(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`*`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.descriptionHint`)}),(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(br,{embedded:!0,value:C,onChange:e=>Se(e.target.value),placeholder:e(`settings.skills.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] max-h-32 bg-transparent`,disabled:g})})]})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.instructions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.instructions`)}),(0,$.jsx)(Or,{currentMode:k===`preview`?`preview`:`edit`,onToggle:()=>A(e=>e===`preview`?`edit`:`preview`)})]}),cardClassName:`p-3`,children:(0,$.jsx)(`div`,{className:q(`overflow-hidden bg-background`,al),children:k===`preview`?(0,$.jsx)(yr,{outerClassName:`h-full`,className:`h-full`,children:(0,$.jsx)(`div`,{className:`min-h-full px-4 py-3`,children:(0,$.jsx)(vr,{content:D,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})}):(0,$.jsx)(Tr,{value:D,onChange:Ce,readOnly:g,extensions:be,className:`h-full`,enableSearch:!0})})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.supporting-files`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.supportingFiles`)}),(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Ee,disabled:g,children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),` `,e(`settings.skills.page.actions.addFile`)]})]}),cardClassName:`p-3`,children:(()=>{let t=m?N:j;return t.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-1.5`,children:e(`settings.skills.page.supportingFiles.empty`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:t.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 cursor-pointer group`,onClick:()=>De(t.path),children:[(0,$.jsx)(J,{name:`file`,className:`h-3.5 w-3.5 text-muted-foreground flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.path}),m&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:e(`settings.skills.page.badge.pending`)}),!g&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),Ae(t.path)},children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-3 w-3`})})]},t.path))})})()})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Y,{onClick:we,disabled:g||F||!me,size:`xs`,className:`!font-normal`,children:e(F?`settings.common.actions.saving`:m?`settings.skills.page.actions.createSkill`:`settings.common.actions.saveChanges`)})})]}),(0,$.jsx)(Jt,{open:ue!==null,onOpenChange:e=>{!e&&!fe&&de(null)},children:(0,$.jsxs)(Gt,{className:`max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.skills.page.deleteFileDialog.title`)}),(0,$.jsx)(qt,{children:e(`settings.skills.page.deleteFileDialog.description`,{path:ue??``})})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>de(null),disabled:fe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:async()=>{if(!ue||!n)return;pe(!0);let{deleteSupportingFile:t}=da.getState();if(await t(n,ue)){K.success(e(`settings.skills.page.toast.fileDeleted`,{path:ue}));let t=await r(n);t&&M(t.sources.md.supportingFiles||[]),de(null)}else K.error(e(`settings.skills.page.toast.deleteFileFailed`));pe(!1)},disabled:fe,children:e(`settings.common.actions.delete`)})]})]})}),(0,$.jsx)(Jt,{open:ee,onOpenChange:e=>{U(e),e||ae(null)},children:(0,$.jsxs)(Gt,{className:`max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,$.jsxs)(Ut,{className:`flex-shrink-0`,children:[(0,$.jsx)(Kt,{children:e(ie?`settings.skills.page.fileDialog.titleEdit`:`settings.skills.page.fileDialog.titleAdd`)}),(0,$.jsx)(qt,{children:e(ie?`settings.skills.page.fileDialog.descriptionEdit`:`settings.skills.page.fileDialog.descriptionAdd`)})]}),oe?(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.skills.page.loading.fileContent`)})}):(0,$.jsxs)(`div`,{className:`space-y-4 flex-1 min-h-0 flex flex-col pt-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2 flex-shrink-0`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.skills.page.fileDialog.field.filePath`)}),(0,$.jsx)(ln,{value:te,onChange:e=>W(e.target.value),placeholder:e(`settings.skills.page.fileDialog.field.filePathPlaceholder`),className:`text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]`,disabled:ie!==null}),!ie&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.skills.page.fileDialog.field.filePathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 flex-1 min-h-0 flex flex-col`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground flex-shrink-0`,children:e(`settings.skills.page.fileDialog.field.content`)}),(0,$.jsx)(`div`,{className:`h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background`,children:(0,$.jsx)(Tr,{value:ne,onChange:re,extensions:xe,className:`h-full`,enableSearch:!0})})]})]}),(0,$.jsxs)(Wt,{className:`mt-4`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{U(!1),ae(null)},children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:Oe,disabled:oe||!ge,children:e(ie?`settings.common.actions.saveChanges`:`settings.skills.page.actions.createFile`)})]})]})})]})},dl=e=>{let t=(0,Ei.c)(2),{view:n}=e,r=n===void 0?`installed`:n,i;return t[0]===r?i=t[1]:(i=r===`catalog`?(0,$.jsx)(rl,{}):(0,$.jsx)(ul,{}),t[0]=r,t[1]=i),i};function fl(){}var pl=e=>{let t=(0,Ei.c)(26),{onItemSelect:n}=e,{t:r}=ke(),i=ft(ml),a=ft(hl),o=u(gl),s=u(_l),c=Q.useRef(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[0]=l):l=t[0];let d=Q.useRef(l),f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=m(),t[1]=f):f=t[1];let p=f,h=vl,g,_;t[2]!==a||t[3]!==i||t[4]!==o||t[5]!==s?(g=()=>{let e=new Set(i.map(yl)),t=c.current;if(t)for(let n of e)t.has(n)||d.current.add(n);if(c.current=e,a&&d.current.delete(a)){s(a);return}if(i.length===0){o!==null&&s(null);return}o&&i.some(e=>e.id===o)||s(i[0].id)},_=[a,i,o,s],t[2]=a,t[3]=i,t[4]=o,t[5]=s,t[6]=g,t[7]=_):(g=t[6],_=t[7]),Q.useEffect(g,_);let v;t[8]!==i.length||t[9]!==r?(v=r(`settings.projects.sidebar.total`,{count:i.length}),t[8]=i.length,t[9]=r,t[10]=v):v=t[10];let y;t[11]===v?y=t[12]:(y=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:v}),t[11]=v,t[12]=y);let b;t[13]===r?b=t[14]:(b=!p&&(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 -my-1 text-muted-foreground`,onClick:h,"aria-label":r(`settings.projects.sidebar.actions.addProject`),children:(0,$.jsx)(J,{name:`add`,className:`size-4`})}),t[13]=r,t[14]=b);let x;t[15]!==y||t[16]!==b?(x=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-[var(--oc-settings-row-inset)]`,children:[y,b]}),t[15]=y,t[16]=b,t[17]=x):x=t[17];let S;t[18]!==n||t[19]!==i||t[20]!==o||t[21]!==s?(S=i.length>0?(0,$.jsx)(Z,{children:i.map(e=>{let t=e.id===o,r=e.icon?rn[e.icon]:null,i=e.color?on[e.color]:void 0,a=(0,$.jsx)(J,{name:r??`folder`,className:`h-4 w-4`,style:i?{color:i}:void 0}),c=(0,$.jsx)(`span`,{className:q(`flex size-5 shrink-0 items-center justify-center overflow-hidden`,t?`text-foreground`:`text-muted-foreground`),children:e.iconImage?(0,$.jsx)(en,{project:e,className:`size-full object-contain`,fallback:a}):a});return(0,$.jsx)(Za,{title:e.path.split(/[\\/]/).filter(Boolean).at(-1)||e.path,icon:c,selected:t,onSelect:()=>{s(e.id),n?.()}},e.id)})}):null,t[18]=n,t[19]=i,t[20]=o,t[21]=s,t[22]=S):S=t[22];let C;return t[23]!==x||t[24]!==S?(C=(0,$.jsx)($a,{variant:`background`,header:x,children:S}),t[23]=x,t[24]=S,t[25]=C):C=t[25],C};function ml(e){return e.projects}function hl(e){return e.activeProjectId}function gl(e){return e.settingsProjectsSelectedId}function _l(e){return e.setSettingsProjectsSelectedId}function vl(){$e.requestDirectoryDialog()}function yl(e){return e.id}var bl=()=>{let e=(0,Ei.c)(18),{t}=ke(),n=ft(xl),r=ft(Sl),i=u(Cl),a=u(wl),o;bb0:{if(!i){o=null;break bb0}let t;e[0]!==n||e[1]!==i?(t=n.find(e=>e.id===i)??null,e[0]=n,e[1]=i,e[2]=t):t=e[2],o=t}let s=o,c,l;e[3]!==n||e[4]!==i||e[5]!==a?(c=()=>{if(n.length===0){a(null);return}i&&n.some(e=>e.id===i)||a(n[0].id)},l=[n,i,a],e[3]=n,e[4]=i,e[5]=a,e[6]=c,e[7]=l):(c=e[6],l=e[7]),Q.useEffect(c,l);let d;e[8]!==s||e[9]!==r?(d=async e=>{s&&r(s.id,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},e[8]=s,e[9]=r,e[10]=d):d=e[10];let f=d;if(!s){let n;e[11]===t?n=e[12]:(n=t(`settings.projects.page.empty.noProjects`),e[11]=t,e[12]=n);let r;return e[13]===n?r=e[14]:(r=(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n})})}),e[13]=n,e[14]=r),r}let p;return e[15]!==f||e[16]!==s?(p=(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full bg-background`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(pi,{project:s,onIdentitySave:f})})}),e[15]=f,e[16]=s,e[17]=p):p=e[17],p};function xl(e){return e.projects}function Sl(e){return e.updateProjectMeta}function Cl(e){return e.settingsProjectsSelectedId}function wl(e){return e.setSettingsProjectsSelectedId}var Tl=e(Ti(),1),El=16384,Dl=globalThis,Ol=e=>{if(Dl.Buffer)return Dl.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},kl=e=>{try{if(Dl.Buffer)return Dl.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},Al=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},jl=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},Ml=e=>typeof e==`string`&&e.length>0,Nl=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!Ml(t.x)||!Ml(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},Pl=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,Fl=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=Pl(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=Al(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=jl(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Nl(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},Il=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(Fl).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},Ll=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),Rl=e=>{let t=Il(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,Ol(JSON.stringify(t))),`openchamber://connect?${n.toString()}`},zl=e=>{let t=e.trim();if(!t||t.length>El)return null;let n=t.indexOf(`?`);if(n===-1||!/^openchamber:\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>El)return null;let a=kl(i);if(!a||a.length>El)return null;try{return Il(JSON.parse(a))}catch{return null}},Bl=e=>{let t=e.trim();if(!t||t.length>El)return null;try{let e=new URL(t);if(e.protocol===`openchamber:`&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>El)return null;let n=kl(t);return!n||n.length>El?null:Il(JSON.parse(n))}}catch{}return zl(t)},Vl=`relay_identity_changed`,Hl=class extends Error{code=Vl;expectedServerId;actualServerId;constructor(e,t){super(`Relay identity changed (expected ${e}, got ${t||`unknown`})`),this.name=`RelayIdentityChangedError`,this.expectedServerId=e,this.actualServerId=t}},Ul=new Map,Wl=e=>{let t=e.trim();if(!t)throw Error(`Relay serverId is required`);return`relay:${t}`},Gl=e=>{let t={Accept:`application/json`},n=typeof e.clientToken==`string`?e.clientToken.trim():``;if(n&&(t.Authorization=`Bearer ${n}`),e.requestHeaders)for(let[n,r]of Object.entries(e.requestHeaders))!n.trim()||!r.trim()||n.trim().toLowerCase()!==`authorization`&&(t[n.trim()]=r.trim());return t},Kl=e=>({files:e?.files?.length??0,directories:e?.directories?.length??0,deletes:e?.deletes?.length??0,totalBytes:e?.totalBytes??0}),ql=async e=>{y()&&await B(`desktop_sync_runs_append`,{record:e})},Jl=async(e,t)=>{if(!t)return;let n=await t().catch(()=>null),r=typeof n?.serverId==`string`?n.serverId.trim():``;if(r&&r!==e)throw new Hl(e,r)},Yl=e=>({ok:!0,files:0,directories:0,deletes:e.deletes.length,totalBytes:0,agentsRoot:null,authFile:null,plan:e}),Xl=e=>{let t=e?.selectionShape;if(!t)throw Error(`Local sync inventory missing selectionShape (update the OpenChamber desktop app)`);return t},Zl=(e,t)=>{let n=or(e,{includeAuthFile:!1}),r=t.selections;return{fileGroups:r?.fileGroups??n.fileGroups,singleFiles:r?.singleFiles??n.singleFiles,directories:r?.directories??n.directories,agentsRoot:r?.agentsRoot!==!1,authFile:r?.authFile===!0}},Ql=(e,t,n)=>{let r=e.inventory&&typeof e.inventory==`object`?e.inventory:null;return{direction:`pull`,files:r?.files??t?.files??[],directories:r?.directories??t?.directories??[],agentsRoot:n.agentsRoot?r?.agentsRoot??null:null,authFile:n.authFile?r?.authFile??null:null,deletes:t?.deletes??[],totalBytes:t?.totalBytes??0,selections:n}},$l=(e,t)=>({...e,direction:`push`,authFile:t.authFile?e.authFile:null,agentsRoot:t.agentsRoot?e.agentsRoot:null,selections:t}),eu=e=>e.files.length>0||e.directories.length>0||!!e.agentsRoot||!!e.authFile,tu=(e,t)=>{let n=d({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),r=Gl(t),i=async(e,t,i)=>{let a=await n.fetch(t,{method:e,headers:{...r,...i===void 0?{}:{"Content-Type":`application/json`}},body:i===void 0?void 0:JSON.stringify(i)}),o=await a.json().catch(()=>({}));if(!a.ok){let n=Error(typeof o.error==`string`?o.error:`Relay sync ${e} ${t} failed (${a.status})`);throw typeof o.code==`string`&&(n.code=o.code),n}return o};return{tunnel:n,async probe(e){let t=await i(`POST`,`/api/openchamber/config-sync/probe`,{plan:e});return{remoteExisting:Array.isArray(t.remoteExisting)?t.remoteExisting:[],remoteAgentsRootExists:t.remoteAgentsRootExists===!0,remoteAuthFileExists:t.remoteAuthFileExists===!0,inventory:t.inventory}},async prepare(e,t){await i(`POST`,`/api/openchamber/config-sync/prepare`,{plan:e,syncRunId:t})},async putTar(e,t,i){let a=await n.fetch(`/api/openchamber/config-sync/put/${encodeURIComponent(e)}?syncRunId=${encodeURIComponent(i)}`,{method:`PUT`,headers:{...r,"Content-Type":`application/gzip`},body:new Blob([new Uint8Array(t)],{type:`application/gzip`})}),o=await a.json().catch(()=>({}));if(!a.ok){let t=Error(typeof o.error==`string`?o.error:`Relay sync put ${e} failed (${a.status})`);throw typeof o.code==`string`&&(t.code=o.code),t}},async download(e){let t=await n.fetch(`/api/openchamber/config-sync/download/${encodeURIComponent(e)}`,{method:`GET`,headers:r});if(!t.ok){let n=await t.json().catch(()=>({})),r=Error(typeof n.error==`string`?n.error:`Relay sync download ${e} failed (${t.status})`);throw typeof n.code==`string`&&(r.code=n.code),r}return new Uint8Array(await t.arrayBuffer())},async finalize(e){await i(`POST`,`/api/openchamber/config-sync/finalize`,{syncRunId:e})},async abort(e){await i(`POST`,`/api/openchamber/config-sync/abort`,{syncRunId:e}).catch(()=>void 0)},close(){n.close()}}},nu=async(e,t,n,r)=>{if(Ul.has(e)){let t=Error(`Config sync already in progress for ${e}`);throw t.code=`sync_in_progress`,t}let i=crypto.randomUUID(),a=new Date().toISOString();Ul.set(e,i);try{let o=await r({syncRunId:i});return await ql({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`success`,summary:Kl(o.plan)}),{...o,syncRunId:i}}catch(r){throw await ql({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`failure`,summary:Kl(null),error:r instanceof Error?r.message:String(r)}).catch(()=>void 0),r}finally{Ul.get(e)===i&&Ul.delete(e)}},ru=async(e,t)=>{let n=await Sn({direction:e,targetKind:`relay`}),r=Xl(n),i=Zl(r,t),a=e===`push`?await Sn({direction:e,selections:i,targetKind:`relay`}):n;if(e===`push`&&!a)throw Error(`Local sync inventory unavailable`);return{selectionShape:r,selections:i,localPlan:a}},iu=async(e,t={},n={})=>{let r=e.relay,i=Wl(r.serverId),a=t.direction===`pull`?`pull`:`push`;return nu(i,`preview`,a,async()=>{await Jl(r.serverId,n.refreshCandidates);let{selectionShape:i,selections:o,localPlan:s}=await ru(a,t),c=tu(r,e);try{if(a===`pull`){let e=await c.probe({});return{plan:Ql(e,s,o),remoteExisting:e.remoteExisting,remoteAgentsRootExists:e.remoteAgentsRootExists,remoteAuthFileExists:e.remoteAuthFileExists,selectionShape:i}}let e=$l(s,o),t=await c.probe(e);return{plan:e,remoteExisting:t.remoteExisting,remoteAgentsRootExists:t.remoteAgentsRootExists,remoteAuthFileExists:t.remoteAuthFileExists,selectionShape:s?.selectionShape??i}}finally{c.close()}})},au=async(e,t={},n={})=>{let r=e.relay,i=Wl(r.serverId),a=t.direction===`pull`?`pull`:`push`;return nu(i,`apply`,a,async({syncRunId:i})=>{await Jl(r.serverId,n.refreshCandidates);let{selections:o,localPlan:s}=await ru(a,t),c=tu(r,e);try{if(a===`pull`){let e=Ql(await c.probe({}),s,o);if(!eu(e))return Yl(e);let t=e.files.length>0||e.directories.length>0?await c.download(`config`):null,n=e.agentsRoot?await c.download(`agents`):null,r=e.authFile?await c.download(`auth`):null;if(!y())throw Error(`Relay pull apply requires the OpenChamber desktop app`);let a=await B(`desktop_relay_sync_apply_local`,{syncRunId:i,plan:e,configTar:t,agentsTar:n,authTar:r});if(!a?.ok)throw Error(`Relay pull local apply failed`);return{...a,plan:e}}let e=$l(s,o);if(!eu(e))return Yl(e);if(!y())throw Error(`Relay push apply requires the OpenChamber desktop app`);let t=await B(`desktop_relay_sync_pack_local`,{plan:e});if(!t)throw Error(`Relay push local pack failed`);await c.prepare(e,i);try{t.configTar&&t.configTar.byteLength>0&&await c.putTar(`config`,t.configTar,i),t.agentsTar&&t.agentsTar.byteLength>0&&await c.putTar(`agents`,t.agentsTar,i),t.authTar&&t.authTar.byteLength>0&&await c.putTar(`auth`,t.authTar,i),await c.finalize(i)}catch(e){throw await c.abort(i),e}return{ok:!0,files:e.files.length,directories:e.directories.length,deletes:e.deletes.length,totalBytes:e.totalBytes,agentsRoot:e.agentsRoot?{fileCount:e.agentsRoot.fileCount}:null,authFile:e.authFile?{bytes:e.authFile.bytes}:null,plan:e}}finally{c.close()}})},ou=`wss://relay.openchamber.dev/ws`,su=`openchamber.pairing.relayUrl.v1`,cu=e=>{if(typeof e!=`string`||!e.trim())return null;try{let t=new URL(e.trim());return t.protocol!==`ws:`&&t.protocol!==`wss:`||t.username||t.password?null:(t.username=``,t.password=``,t.hash=``,t.search=``,t.toString())}catch{return null}},lu=(e=typeof window>`u`?null:window.localStorage)=>{if(!e)return null;try{return cu(e.getItem(su))}catch{return null}},uu=(e,t=typeof window>`u`?null:window.localStorage)=>{if(!t)return;let n=cu(e);if(n)try{t.setItem(su,n)}catch{}},du=`https://github.com/yee94/openchamber/tree/main/packages/relay-server`,fu=()=>Math.floor(2e4+Math.random()*3e4),pu=e=>{if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return`${e} B`},mu={fileGroups:[],singleFiles:[],directories:[],agentsRoot:!0,authFile:!1},hu=e=>{let t=e.selectionShape;if(!t||typeof t!=`object`)return null;let n=typeof t.fileGroups==`number`?t.fileGroups:null,r=typeof t.singleFiles==`number`?t.singleFiles:null,i=typeof t.directories==`number`?t.directories:null;return n===null||r===null||i===null||n<0||r<0||i<0?null:{fileGroups:n,singleFiles:r,directories:i}},gu=(e,t)=>e.fileGroups.length===t.fileGroups&&e.singleFiles.length===t.singleFiles&&e.directories.length===t.directories,_u=[`settings.remoteInstances.page.sync.step.scanLocal`,`settings.remoteInstances.page.sync.step.compareRemote`,`settings.remoteInstances.page.sync.step.confirm`],vu=({open:e,instanceId:t,targetKind:n=`ssh`,relayHost:r=null,onOpenChange:i})=>{let{t:a}=ke(),[o,s]=Q.useState(1),[c,l]=Q.useState(`scanning-local`),[u,d]=Q.useState(`push`),[f,p]=Q.useState(mu),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(null),[S,C]=Q.useState(null),w=Q.useRef(mu),T=m!=null&&gu(f,m),E=Oe(()=>{s(1),l(`scanning-local`),d(`push`),p(mu),h(null),_(null),y(null),x(null),C(null),w.current=mu}),D=Oe(async(e=u,i=f)=>{if(t){s(2),l(`comparing-remote`),x(null),C(null),y(null);try{let o=n===`relay`?r?await iu(r,{direction:e,selections:i}):null:await Cn(t,{targetKind:n,direction:e,selections:i});if(!o){x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(2),l(`error`);return}y(o),w.current=i,s(3),l(`review`)}catch(e){console.error(`[remote-instances] config sync compare-remote failed`,e),x(e instanceof Error?e.message:String(e)),C(2),l(`error`)}}}),O=Oe(async(e=u,r=f)=>{if(t){s(1),l(`scanning-local`),x(null),C(null),_(null),y(null);try{let t=m!=null&&gu(r,m),i=await Sn(t?{targetKind:n,direction:e,selections:r}:{targetKind:n,direction:e});if(!i){h(null),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}let o=hu(i);if(!o){h(null),p(mu),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}h(o);let s=t?r:or(o,{includeAuthFile:!1});p(s),_(i),await D(e,s)}catch(e){console.error(`[remote-instances] config sync scan-local failed`,e),x(e instanceof Error?e.message:String(e)),C(1),l(`error`)}}});Q.useEffect(()=>{!e||!t||O(`push`)},[e,t]),Q.useEffect(()=>{e||E()},[e]);let k=Q.useMemo(()=>new Set(v?.remoteExisting??[]),[v]),A=v?.plan??g,j=!!(A&&(A.files.length>0||A.directories.length>0||A.agentsRoot!=null||A.authFile!=null)),M=c===`applying`,N=c===`review`||c===`applying`&&o===3,P=A?A.deletes.length+(A.agentsRoot&&v?.remoteAgentsRootExists?1:0):0,F=Oe(()=>{if(S===2){D(u,f);return}O(u,f)}),I=Oe(e=>{e===u||M||(d(e),y(null),_(null),O(e,f))}),L=Oe(async()=>{if(!(!t||!j||M||c!==`review`)){l(`applying`);try{if(!(n===`relay`?r&&await au(r,{direction:u,selections:w.current}):await Gn(t,{targetKind:n,direction:u,selections:w.current})))throw Error(`Sync bridge unavailable`);K.success(a(`settings.remoteInstances.page.sync.toast.success`)),i(!1)}catch(e){console.error(`[remote-instances] config sync apply failed`,e),K.error(a(`settings.remoteInstances.page.sync.toast.failed`),{description:e instanceof Error?e.message:String(e)}),l(`review`)}}}),R=e=>c===`error`&&S!=null?e<S?`done`:e===S?`active`:`pending`:c===`review`||c===`applying`||e<o?`done`:e===o?`active`:`pending`;return(0,$.jsx)(Jt,{open:e,onOpenChange:i,children:(0,$.jsxs)(Gt,{className:`min-h-0 sm:max-w-2xl`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:a(`settings.remoteInstances.page.sync.title`)}),(0,$.jsx)(qt,{children:a(`settings.remoteInstances.page.sync.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:u===`push`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`push`,disabled:M||c===`comparing-remote`||c===`scanning-local`,onClick:()=>I(`push`),children:a(`settings.remoteInstances.page.sync.direction.push`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:u===`pull`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`pull`,disabled:M||c===`comparing-remote`||c===`scanning-local`,onClick:()=>I(`pull`),children:a(`settings.remoteInstances.page.sync.direction.pull`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 p-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.scope.title`)}),T?null:(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:a(c===`scanning-local`||c===`comparing-remote`?`settings.remoteInstances.page.sync.step.scanLocal`:`settings.remoteInstances.page.sync.state.unavailable`)}),[{key:`config`,label:`config.json / opencode.json(c)`,index:0,kind:`fileGroups`},{key:`oh-slim`,label:`oh-my-opencode-slim.json(c)`,index:1,kind:`fileGroups`},{key:`oh-agent`,label:`oh-my-openagent.json(c)`,index:2,kind:`fileGroups`},{key:`agents-md`,label:`AGENTS.md`,index:0,kind:`singleFiles`},{key:`cursor-models`,label:`cursor-models.json`,index:1,kind:`singleFiles`},{key:`agents`,label:`agents/`,index:0,kind:`directories`},{key:`commands`,label:`commands/`,index:1,kind:`directories`},{key:`skills`,label:`skills/`,index:2,kind:`directories`},{key:`plugins`,label:`plugins/`,index:5,kind:`directories`}].filter(e=>m!=null&&e.index<m[e.kind]).map(e=>{let t=f[e.kind][e.index]!==!1;return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(Qt,{checked:t,disabled:M||!T,ariaLabel:e.label,onChange:t=>{if(!T)return;let n=[...f[e.kind]];n[e.index]=t;let r={...f,[e.kind]:n};p(r),c===`review`&&D(u,r)}}),(0,$.jsx)(`span`,{className:`font-mono`,children:e.label})]},e.key)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(Qt,{checked:f.agentsRoot,disabled:M||!T,ariaLabel:a(`settings.remoteInstances.page.sync.section.agentsRoot`),onChange:e=>{if(!T)return;let t={...f,agentsRoot:e};p(t),c===`review`&&D(u,t)}}),a(`settings.remoteInstances.page.sync.section.agentsRoot`)]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(Qt,{checked:f.authFile,disabled:M||!T,ariaLabel:a(`settings.remoteInstances.page.sync.section.authFile`),onChange:e=>{if(!T)return;let t={...f,authFile:e};p(t),c===`review`&&D(u,t)}}),a(`settings.remoteInstances.page.sync.section.authFile`)]})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:_u.map((e,t)=>{let n=t+1,r=R(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r===`done`?(0,$.jsx)(J,{name:`check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--status-success)]`}):r===`active`?(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-border/60 typography-micro text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:q(`typography-meta`,r===`pending`?`text-muted-foreground`:`text-foreground`),children:a(e)})]},e)})}),c===`error`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:a(`settings.remoteInstances.page.sync.state.error`,{message:b||``})}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:F,children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),a(`settings.remoteInstances.sidebar.actions.retry`)]})]}):null,N&&!j?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.state.empty`)}):null,N&&j&&A?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-[var(--surface-elevated)]`,children:(0,$.jsx)(yr,{fillContainer:!1,disableHorizontal:!0,outerClassName:`max-h-80`,className:`max-h-80`,children:(0,$.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[A.files.map(e=>{let t=k.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(J,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.files`),`: `]}),e.path]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:pu(e.bytes)}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`file:${e.path}`)}),A.directories.map(e=>{let t=k.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(J,{name:`folder-3-fill`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.directories`),`: `]}),e.path]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[pu(e.bytes),` · `,e.fileCount]}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`dir:${e.path}`)}),A.authFile?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(J,{name:`shield-keyhole`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.local/share/opencode/auth.json`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.authFile`),`: `]}),`~/.local/share/opencode/auth.json`]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:pu(A.authFile.bytes)}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,v?.remoteAuthFileExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAuthFileExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null,A.agentsRoot?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(J,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.agents`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.agentsRoot`),`: `]}),`~/.agents`]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[pu(A.agentsRoot.bytes),` · `,a(`settings.remoteInstances.page.sync.section.agentsRootCount`,{count:A.agentsRoot.fileCount})]}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,v?.remoteAgentsRootExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAgentsRootExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null]})})}),(0,$.jsxs)(`div`,{className:`space-y-1 typography-micro text-muted-foreground`,children:[P>0?(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.deletes`,{count:P})}):null,(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.backup`)}),(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.excluded`)})]})]}):null,(0,$.jsxs)(Wt,{className:`shrink-0`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:()=>i(!1),disabled:M,children:a(`settings.remoteInstances.page.sync.actions.cancel`)}),(0,$.jsxs)(Y,{type:`button`,size:`sm`,className:`!font-normal`,onClick:()=>void L(),disabled:!j||M||c!==`review`,children:[(0,$.jsx)(J,{name:`refresh`,className:q(`h-3.5 w-3.5`,M?`animate-spin`:``)}),a(M?`settings.remoteInstances.page.sync.applying`:`settings.remoteInstances.page.sync.actions.syncNow`)]})]})]})})},yu=e=>{let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`address already in use`)||t.includes(`eaddrinuse`)||t.includes(`port already in use`)},bu=()=>{if(typeof navigator>`u`)return;let e=(navigator.userAgent||``).toLowerCase();if(e.includes(`mac`))return`macos`;if(e.includes(`win`))return`windows`;if(e.includes(`linux`))return`linux`},xu=e=>{switch((e||``).toLowerCase()){case`ios`:return`iOS`;case`android`:return`Android`;case`macos`:case`darwin`:return`macOS`;case`windows`:case`win32`:return`Windows`;case`linux`:return`Linux`;default:return null}},Su=e=>{switch(e){case`config_resolved`:return`settings.remoteInstances.page.phase.resolvingConfiguration`;case`auth_check`:return`settings.remoteInstances.page.phase.checkingAuth`;case`master_connecting`:return`settings.remoteInstances.page.phase.establishingSsh`;case`remote_probe`:return`settings.remoteInstances.page.phase.probingRemote`;case`installing`:return`settings.remoteInstances.page.phase.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`}},Cu=new Set([`config_resolved`,`auth_check`,`master_connecting`,`remote_probe`,`installing`,`updating`,`server_detecting`,`server_starting`,`forwarding`]),wu=e=>!!(e&&Cu.has(e)),Tu=e=>e===`ready`?`bg-[var(--status-success)] animate-pulse`:e===`error`?`bg-[var(--status-error)] animate-pulse`:e===`degraded`||wu(e)?`bg-[var(--status-warning)] animate-pulse`:`bg-muted-foreground/40`,Eu=e=>e.type===`dynamic`?`${e.localHost||`127.0.0.1`}:${e.localPort||0}`:e.type===`remote`?`${e.remoteHost||`127.0.0.1`}:${e.remotePort||0} -> ${e.localHost||`127.0.0.1`}:${e.localPort||0}`:`${e.localHost||`127.0.0.1`}:${e.localPort||0} -> ${e.remoteHost||`127.0.0.1`}:${e.remotePort||0}`,Du=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:`local`,localHost:`127.0.0.1`,localPort:fu(),remoteHost:`127.0.0.1`,remotePort:80}),Ou=e=>e.trim().replace(/\*/g,`host`).replace(/\?/g,`x`)||`user@host`,ku=e=>{let t=(0,Ei.c)(10),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]!==a||t[1]!==r?(s=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:o}),t[3]=o,t[4]=c);let l;return t[5]!==i||t[6]!==n||t[7]!==s||t[8]!==c?(l=(0,$.jsx)(Z,{itemId:n,className:`oc-settings-detail-group`,label:s,description:i,children:c}),t[5]=i,t[6]=n,t[7]=s,t[8]=c,t[9]=l):l=t[9],l},Au=e=>{switch(e){case`remote`:return`settings.remoteInstances.page.forwardTypeDescription.remote`;case`dynamic`:return`settings.remoteInstances.page.forwardTypeDescription.dynamic`;default:return`settings.remoteInstances.page.forwardTypeDescription.local`}},ju=(e,t)=>{let n=(e||``).trim();return`${!n||n===`127.0.0.1`||n===`::1`?`localhost`:n}:${t||0}`},Mu=e=>{let t=(e||``).trim();return!t||t===`0.0.0.0`||t===`::`?`127.0.0.1`:t},Nu=e=>{let t=e.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!t)return e;let n=Number(t[1]);return`[${Number.isFinite(n)?new Date(n).toISOString():t[1]}] [${(t[2]||`INFO`).toUpperCase()}] ${t[3]||``}`},Pu=()=>{if(typeof window>`u`)return null;let e=r()||window.location.href;try{let t=Number(new URL(e).port||window.location.port);return Number.isFinite(t)&&t>0?t:null}catch{let e=Number(window.location.port);return Number.isFinite(e)&&e>0?e:null}},Fu=e=>{try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}},Iu=async()=>{let e=se(r())||window.location.origin;if(!w()||!T())return e;let t;try{t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}})}catch{return e}if(!t.ok||(await t.json().catch(()=>null))?.desktopLanAccessActive!==!0)return e;let n=await C(),i=Pu();return!n||!i?e:`http://${n}:${i}`},Lu=e=>{let t=e.trim();if(t)try{window.location.assign(t)}catch{window.location.href=t}},Ru=e=>{let t=e.sshCommand.trim(),n=e.nickname?.trim(),r=e.portForwards.map(e=>({...e,localHost:e.localHost?.trim()||`127.0.0.1`,localPort:typeof e.localPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localPort))):void 0,remoteHost:e.remoteHost?.trim(),remotePort:typeof e.remotePort==`number`?Math.max(1,Math.min(65535,Math.round(e.remotePort))):void 0}));return{...e,sshCommand:t,...n?{nickname:n}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(e.connectionTimeoutSec||60))),localForward:{...e.localForward,bindHost:e.localForward.bindHost===`localhost`||e.localForward.bindHost===`0.0.0.0`?e.localForward.bindHost:`127.0.0.1`,preferredLocalPort:typeof e.localForward.preferredLocalPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...e.remoteOpenchamber,preferredPort:typeof e.remoteOpenchamber.preferredPort==`number`?Math.max(1,Math.min(65535,Math.round(e.remoteOpenchamber.preferredPort))):void 0},portForwards:r}},zu=()=>{let{t:e}=ke(),{clientAuth:t}=pr(),i=w(),o=Ur(e=>e.instances),c=Ur(e=>e.statusesById),l=Ur(e=>e.importCandidates),f=Ur(e=>e.isLoading),p=Ur(e=>e.isImportsLoading),m=Ur(e=>e.isSaving),h=Ur(e=>e.error),g=Ur(e=>e.load),_=Ur(e=>e.loadImports),v=Ur(e=>e.refreshStatuses),y=Ur(e=>e.upsertInstance),b=Ur(e=>e.createFromCommand),x=Ur(e=>e.removeInstance),S=Ur(e=>e.connect),C=Ur(e=>e.disconnect),T=Ur(e=>e.retry),E=u(e=>e.settingsRemoteInstancesSelectedId),D=u(e=>e.setSettingsRemoteInstancesSelectedId),O=Q.useMemo(()=>E&&o.find(e=>e.id===E)||null,[o,E]),[k,A]=Q.useState(null),[M,N]=Q.useState([]),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(null),[B,V]=Q.useState([]),[H,ee]=Q.useState(!1),[U,fe]=Q.useState(null),[pe,me]=Q.useState(`ssh`),[he,ge]=Q.useState(null),[_e,ve]=Q.useState(null),[ye,be]=Q.useState(``),[xe,Se]=Q.useState(!1),[Ce,we]=Q.useState({}),[Te,Ee]=Q.useState(!1),[De,Ae]=Q.useState(!1),[Me,Ne]=Q.useState(()=>Date.now()),[Pe,Fe]=Q.useState([]),[Ie,Le]=Q.useState({}),[Re,ze]=Q.useState(`local`),[Be,Ve]=Q.useState(!1),[He,Ue]=Q.useState(!1),[We,Ge]=Q.useState(0),Ke=bn(),[qe,Je]=Q.useState(``),[Ye,Xe]=Q.useState(null),[Ze,Qe]=Q.useState(!1),[$e,et]=Q.useState([]),[tt,G]=Q.useState([]),[nt,rt]=Q.useState(!1),[it,at]=Q.useState(``),[ot,st]=Q.useState(null),[ct,lt]=Q.useState(null),[ut,dt]=Q.useState(null),[ft,pt]=Q.useState(null),[mt,ht]=Q.useState(!1),[gt,_t]=Q.useState(!1),[vt,yt]=Q.useState(`configure`),[bt,xt]=Q.useState(!1),[St,Ct]=Q.useState(`relay`),[wt,Tt]=Q.useState(!0),[Et,Dt]=Q.useState(ou),[Ot,kt]=Q.useState(null),[At,jt]=Q.useState(!1),Mt=Q.useRef(null),[Nt,Pt]=Q.useState(null),Ft=Q.useMemo(()=>$e.filter(e=>!!e.revokedAt).length,[$e]),[It,Lt]=Q.useState(!1),[Rt,zt]=Q.useState(`ssh user@example.com`),[Bt,Vt]=Q.useState(``);Q.useEffect(()=>{g(),_()},[g,_]);let Ht=Q.useCallback(async()=>{Ve(!0),Xe(null);try{let e=await ce();Fe(e.hosts||[]),ze(e.defaultHostId||`local`)}catch(e){Xe(e instanceof Error?e.message:String(e))}finally{Ve(!1)}},[]);Q.useEffect(()=>{Ht()},[Ht]);let Yt=Object.values(c).filter(e=>e.phase===`ready`).map(e=>`${e.id}:${e.localUrl||``}`).sort().join(`|`);Q.useEffect(()=>{Yt&&Ht()},[Ht,Yt]);let Xt=Q.useCallback(async(e,t=Re)=>{Ue(!0),Xe(null);try{await re({hosts:e,defaultHostId:t,initialHostChoiceCompleted:!0}),Fe(e),ze(t)}catch(e){Xe(e instanceof Error?e.message:String(e))}finally{Ue(!1)}},[Re]),Zt=Q.useMemo(()=>new Set(o.map(e=>e.id)),[o]),en=Q.useMemo(()=>Pe.filter(e=>ue(e,Zt)),[Pe,Zt]),rn=Oe(async()=>{let t=Bl(qe);if(!t){Xe(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let n=await te().catch(()=>``),r={method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({pairingId:t.pairingId,secret:t.secret,clientLabel:t.label||`OpenChamber Desktop`,clientKind:`desktop`,deviceName:`OpenChamber Desktop`,devicePlatform:bu(),...n?{dedupeKey:`desktop:${n}`}:{}})},i=async e=>{if(!e.ok)return null;let t=await e.json().catch(()=>null);return(typeof t?.clientToken==`string`?t.clientToken.trim():``)||null},a=[...t.candidates].sort((e,t)=>(e.type===`relay`)-+(t.type===`relay`)),o=null;for(let e of a){if(e.type===`relay`){let t=d({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...e.grant?{grant:e.grant}:{}});try{let n=await i(await t.fetch(`/api/client-auth/pairing/redeem`,r));if(n){o={kind:`relay`,relay:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk},token:n,tunnel:t},t.close();break}}catch{}t.close();continue}let t=se(e.url);if(t)try{let e=await i(await fetch(`${t}/api/client-auth/pairing/redeem`,r));if(e){o={kind:`direct`,url:t,token:e};break}}catch{}}if(!o){Xe(e(`desktopHostSwitcher.error.invalidUrl`));return}let s=()=>j(),c=t.candidates.find(e=>e.type===`relay`),l=o.kind===`relay`?o.relay:c?{relayUrl:c.relayUrl,serverId:c.serverId,hostEncPubJwk:c.hostEncPubJwk}:void 0,u=t.candidates.filter(e=>e.type!==`relay`),f=u.map(e=>se(e.url)).find(e=>!!e),p=u.filter(e=>e.type===`lan`).map(e=>se(e.url)).find(e=>!!e),m=o.kind===`direct`?o.url:p||f||null,{token:h}=o,g=m||(l?W(l.serverId):null);if(!g){Xe(e(`desktopHostSwitcher.error.invalidUrl`));return}let _={url:g,apiUrl:m||void 0,clientToken:h,source:le,...l?{relay:l}:{}},v=Pe.find(e=>l?e.relay?.serverId===l.serverId&&e.relay?.relayUrl===l.relayUrl:!e.relay&&se(e.apiUrl||e.url)===g);if(v){let e=Pe.map(e=>e.id===v.id?{...e,label:t.label||e.label,..._}:e);await Xt(e,Re)}else await Xt([{id:s(),label:t.label||ne(g),..._},...Pe],Re);Je(``),Xe(null),Qe(!1)}),on=Q.useCallback(async e=>{let t=Pe.filter(t=>t.id!==e);await Xt(t,Re===e?`local`:Re)},[Re,Pe,Xt]),sn=Q.useCallback(async()=>{let t=Rt.trim();if(!t){K.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}let n=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await b(n,t,Bt.trim()||void 0),D(n),Lt(!1),zt(`ssh user@example.com`),Vt(``),K.success(e(`settings.remoteInstances.page.toast.instanceCreated`))}catch(t){K.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)})}},[b,D,Rt,Bt,e]),pn=Q.useCallback(async e=>{await Xt(Pe,e)},[Pe,Xt]),mn=Oe(async e=>{if(de(e)||Ke)return;Xe(null);let t=await vn({host:e,cachedProbe:Ie[e.id]||null});Le(n=>({...n,[e.id]:t.status}))}),hn=Oe(async t=>{if(Ke)return;let n=t.nickname?.trim()||t.sshParsed?.destination||t.id,r=Pe;try{let e=await ce();r=e.hosts||[],Fe(r),ze(e.defaultHostId||`local`)}catch(t){K.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}),{description:t instanceof Error?t.message:String(t)});return}let i=r.find(e=>e.id===t.id)??null;if(!i||!ie(i)||!i.clientToken){K.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}));return}de(i)||await vn({host:i})});Q.useEffect(()=>{if(i)return n(()=>{Ge(e=>e+1)})},[i]),Q.useEffect(()=>{if(!i||en.length===0)return;let e=!1;return Promise.all(en.map(async e=>{let t=async()=>{let t=await ae(e.relay,{clientToken:e.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));return t.status===`ok`?{status:t.status,latencyMs:t.latencyMs,via:`relay`}:{status:t.status,latencyMs:t.latencyMs}};if(e.relay&&!e.apiUrl)return[e.id,await t()];let n=se(ie(e));if(!n)return[e.id,e.relay?await t():{status:`unreachable`,latencyMs:0}];let r=await oe(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(r.status===`unreachable`&&e.relay){let n=await t();if(n.status===`ok`)return[e.id,n]}return[e.id,r]})).then(t=>{e||Le(Object.fromEntries(t))}),()=>{e=!0}},[en,i]);let gn=Q.useCallback(async e=>{if(t){e?.silent||rt(!0),e?.silent||st(null);try{let[e,n]=await Promise.all([t.listClients(),t.listPendingPairings().catch(()=>null)]);et(e),n&&G(n)}catch(t){e?.silent||st(t instanceof Error?t.message:String(t))}finally{e?.silent||rt(!1)}}},[t]),_n=Q.useRef(!1);Q.useEffect(()=>{if(!(!gt||vt!==`result`||!ut)){if(tt.some(e=>e.id===ut)){_n.current=!0;return}_n.current&&(dt(null),_t(!1),$e.some(e=>e.pairingId===ut)&&K.success(e(`settings.remoteInstances.clientAuth.addDevice.connectedToast`)))}},[gt,vt,ut,tt,$e,e]);let yn=Q.useCallback(async e=>{if(t)try{await t.cancelPairing(e),G(t=>t.filter(t=>t.id!==e)),await gn({silent:!0})}catch(e){st(e instanceof Error?e.message:String(e))}},[t,gn]);Q.useEffect(()=>{if(!t)return;gn();let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||gn({silent:!0})},5e3);return()=>window.clearInterval(e)},[t,gn]);let xn=Q.useCallback(async()=>{let e=a()!==`local`;if(t?.getPairingTransports)try{let n=await t.getPairingTransports(),r=cu(n.relayUrl),i=Array.from(new Set([...Array.isArray(n.relayUrls)?n.relayUrls:[],...r?[r]:[]].map(e=>cu(e)).filter(e=>!!e)));return{localUrl:n.local,lanUrl:n.lan,relayAvailable:n.relayAvailable,relayUrl:r,relayUrls:n.relayAvailable?i:[],relayUrlLocked:n.relayUrlLocked===!0,remoteHost:e}}catch{}let n=Pu(),r=n?`http://127.0.0.1:${n}`:Fu(window.location.origin)?window.location.origin:null,i=null;try{let e=se(await Iu());i=e&&!Fu(e)?e:null}catch{}return{localUrl:r,lanUrl:i,relayAvailable:!1,relayUrl:null,relayUrls:[],relayUrlLocked:!1,remoteHost:e}},[t]),Sn=Oe(async()=>{st(null),lt(null),pt(null),ht(!1),dt(null),kt(null),yt(`configure`),Tt(!0),_t(!0);let e=await xn();Pt(e),jt(!1);let t=e.remoteHost?null:lu();Dt((e.relayUrlLocked||e.remoteHost?e.relayUrl:t||e.relayUrl)||`wss://relay.openchamber.dev/ws`),Ct(e.relayAvailable?`relay`:e.lanUrl?`lan`:`local`)}),Cn=Oe(async()=>{if(!(!t?.createPairingSession||!Nt)){st(null),xt(!0);try{let n=it.trim()||void 0,r,i,a=!0;St===`local`?(r=Nt.localUrl??void 0,i=!1):St===`lan`?(r=Nt.lanUrl??void 0,i=wt):wt&&Nt.lanUrl?(r=Nt.lanUrl,i=!0):(a=!1,i=!0),Nt.relayAvailable||(i=!1);let o=i?cu(Et):null;if(i&&!o){kt(e(`settings.remoteInstances.clientAuth.addDevice.relayUrlInvalid`)),Mt.current?.focus();return}kt(null);let{pairing:s,server:c}=await t.createPairingSession({label:n,allowedClientKinds:[`mobile`,`desktop`],serverUrl:r,includeRelay:i,includeDirect:a,...o?{relayUrl:o}:{}}),l=Ll({pairingId:s.id,secret:s.secret,label:n||c.label,fingerprint:s.fingerprint??void 0,expiresAt:s.expiresAt,candidates:c.candidates}),u=l.candidates.find(e=>e.type===`relay`);u&&(Dt(u.relayUrl),Nt?.remoteHost!==!0&&uu(u.relayUrl));let d=Rl(l);lt(d),pt(await Tl.toDataURL(d,{width:1024,margin:2,errorCorrectionLevel:`L`})),ht(!1),_n.current=!1,dt(s.id),yt(`result`),await gn({silent:!0})}catch(e){st(e instanceof Error?e.message:String(e))}finally{xt(!1)}}}),Tn=Q.useCallback(()=>{ct&&je(ct).then(e=>{e.ok&&(ht(!0),window.setTimeout(()=>ht(!1),2e3))})},[ct]),Dn=Q.useCallback(async e=>{if(!t)return;let n=e.clientKind===`desktop-local`;st(null);try{if(await t.revokeClient(e.id),n&&w()){let t=await ce();await re({hosts:t.hosts,defaultHostId:t.defaultHostId,initialHostChoiceCompleted:t.initialHostChoiceCompleted,localClientToken:null}),et(t=>t.map(t=>t.id===e.id?{...t,revokedAt:new Date().toISOString()}:t)),s({apiBaseUrl:r(),clientToken:null,runtimeKey:`local`});return}await gn()}catch(e){st(e instanceof Error?e.message:String(e))}},[t,gn]),On=Q.useCallback(async()=>{if(t){st(null);try{await t.purgeRevokedClients(),await gn()}catch(e){st(e instanceof Error?e.message:String(e))}}},[t,gn]);Q.useEffect(()=>{A(O)},[O]),Q.useEffect(()=>{let e=!1;return!E||O?.remoteOpenchamber?.mode!==`managed`?(N([]),()=>{e=!0}):(En(E).then(t=>{e||N(t.slice(-5).reverse())}).catch(()=>{e||N([])}),()=>{e=!0})},[E,O?.remoteOpenchamber?.mode,H]),Q.useEffect(()=>{if(!E)return;let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||v()},2e3);return()=>{window.clearInterval(e)}},[v,E]),Q.useEffect(()=>{let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=1e3&&(Ne(r),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[]);let kn=E?c[E]:null,An=kn?.phase,jn=An===`ready`,Mn=An===`degraded`,Pn=wu(An),Fn=jn||Pn||Mn,In=kn?Math.max(0,Me-kn.updatedAtMs):0,X=Mn&&In>12e3,Ln=Q.useMemo(()=>!k||!O?!1:JSON.stringify(k)!==JSON.stringify(O),[k,O]),Rn=Q.useCallback(e=>{A(t=>t&&e(t))},[]),zn=Q.useCallback(async()=>{if(!k)return;let t=Ru(k);if(!t.sshCommand.trim()){K.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}if(!(t.localForward.bindHost===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`)))){if(t.auth.sshPassword?.enabled&&t.auth.sshPassword.value?.trim()&&t.auth.sshPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeSshPasswordPlaintext`));t.auth.sshPassword.store=n?`settings`:`never`,n||(t.auth.sshPassword.value=void 0)}if(t.auth.openchamberPassword?.enabled&&t.auth.openchamberPassword.value?.trim()&&t.auth.openchamberPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeUiPasswordPlaintext`));t.auth.openchamberPassword.store=n?`settings`:`never`,n||(t.auth.openchamberPassword.value=void 0)}try{await y(t),K.success(e(`settings.remoteInstances.page.toast.instanceSaved`))}catch(t){K.error(e(`settings.remoteInstances.page.toast.saveFailed`),{description:t instanceof Error?t.message:String(t)})}}},[k,e,y]),Bn=Q.useCallback(async(t,n)=>{let r=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await b(r,`ssh ${n}`,t),D(r),K.success(e(`settings.remoteInstances.page.toast.instanceCreated`)),!0}catch(t){return K.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)}),!1}},[b,D,e]),Hn=Q.useCallback(()=>{xe||(ve(null),be(``))},[xe]),Un=Q.useCallback((e,t)=>{if(t){ve(e),be(Ou(e));return}Bn(e,e)},[Bn]),Wn=Q.useCallback(async()=>{let t=_e,n=ye.trim();if(t){if(!n){K.error(e(`settings.remoteInstances.page.toast.destinationRequired`));return}Se(!0);try{await Bn(t,n)&&(ve(null),be(``))}finally{Se(!1)}}},[Bn,ye,_e,e]),Gn=Q.useCallback(async()=>{if(O)try{await S(O.id);return}catch(t){if(!yu(t)||!window.confirm(e(`settings.remoteInstances.sidebar.confirm.localPortInUseRetry`)))throw t;let n={...O,localForward:{...O.localForward,preferredLocalPort:fu()}};await y(n),await S(n.id),K.success(e(`settings.remoteInstances.sidebar.toast.retriedWithRandomPort`))}},[S,O,e,y]),qn=Q.useCallback(async e=>(await wn(e,600)).map(e=>Nu(e)),[]),Jn=Q.useCallback(async()=>{if(k){F(!0),L(!0),z(null);try{let e=await qn(k.id);V(e)}catch(e){V([]),z(e instanceof Error?e.message:String(e))}finally{L(!1)}}},[k,qn]);Q.useEffect(()=>{if(!P||!k)return;let e=!1,t=async()=>{try{let t=await qn(k.id);e||(V(t),z(null))}catch(t){e||z(t instanceof Error?t.message:String(t))}};t();let n=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||t()},1e3);return()=>{e=!0,window.clearInterval(n)}},[k,P,qn]);let Yn=Q.useMemo(()=>B.join(`
|
|
23
|
-
`),[B]),Zn=Q.useCallback(()=>{if(!Yn.trim()){K.error(e(`settings.remoteInstances.page.toast.noLogsToCopy`));return}je(Yn).then(t=>{t.ok&&K.success(e(`settings.remoteInstances.page.toast.logsCopied`))})},[Yn,e]),Qn=Q.useCallback(async()=>{if(k)try{await Kn(k.id),V([]),K.success(e(`settings.remoteInstances.page.toast.logsCleared`))}catch(t){K.error(e(`settings.remoteInstances.page.toast.clearLogsFailed`),{description:t instanceof Error?t.message:String(t)})}},[k,e]),$n=Q.useCallback(async()=>{if(!kn?.localUrl){K.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}let t=kn.localUrl.trim();if(!t){K.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}Lu(t)},[kn?.localUrl,e]),er=Q.useCallback((e,t=`ssh`,n=null)=>{fe(e),me(t),ge(n),ee(!0)},[]),tr=Q.useCallback(()=>{if(!k)return;let t=Fn,n=k.id;Ee(!0),(t?C(n):Gn()).catch(n=>{let r=t?jn?`settings.remoteInstances.page.toast.disconnectFailed`:`settings.remoteInstances.page.toast.cancelConnectionFailed`:`settings.remoteInstances.page.toast.connectFailed`,i=kn?.detail||(n instanceof Error?n.message:String(n)),a=ir(kn?.errorCode,i);K.error(e(r),{description:t?n instanceof Error?n.message:String(n):Nn(e(cr(a)),a,i)})}).finally(()=>{Ee(!1)})},[Fn,Gn,C,k,jn,kn,e]),nr=Q.useCallback(()=>{k&&(Pn||(Ae(!0),(Mn?C(k.id).then(()=>Gn()):T(k.id)).catch(t=>{let n=kn?.detail||(t instanceof Error?t.message:String(t)),r=ir(kn?.errorCode,n);K.error(e(`settings.remoteInstances.page.toast.retryFailed`),{description:Nn(e(cr(r)),r,n)})}).finally(()=>{Ae(!1)})))},[Gn,C,k,Pn,Mn,T,kn,e]),rr=e(Pn?`settings.remoteInstances.page.actions.connecting`:Mn?X?`settings.remoteInstances.page.actions.reconnectNow`:`settings.remoteInstances.page.actions.reconnecting`:`settings.remoteInstances.sidebar.actions.retry`),ar=!Te&&!De&&(An===`error`||An===`idle`||!An||Mn&&X)&&!Pn,or=e(jn?`settings.remoteInstances.sidebar.actions.disconnect`:Fn?`settings.remoteInstances.page.actions.cancel`:`settings.remoteInstances.sidebar.actions.connect`);if(!k)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(fc,{children:[t?(0,$.jsx)(ku,{itemId:`remote-instances.client-auth`,label:e(`settings.remoteInstances.clientAuth.title`),description:e(`settings.remoteInstances.clientAuth.description`),children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void Sn(),children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.clientAuth.actions.addDevice`)]})}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Ft>0?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void On(),children:e(`settings.remoteInstances.clientAuth.actions.clearRevoked`)})}):null,nt&&$e.length===0&&tt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.loading`)}):$e.length===0&&tt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.empty`)}):(0,$.jsxs)($.Fragment,{children:[tt.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label||e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`)}),t.usesRelay?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.viaRelay`)}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:e(`settings.remoteInstances.clientAuth.state.pending`)})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void yn(t.id),children:e(`settings.common.actions.cancel`)})]},`pending-${t.id}`)),$e.map(t=>{let n=t.clientKind===`desktop-local`,r=t.lastUsedAt?Date.parse(t.lastUsedAt):NaN,i=!t.revokedAt&&(n||Number.isFinite(r)&&Date.now()-r<9e4),a=t.revokedAt?e(`settings.remoteInstances.clientAuth.state.revoked`):i?t.lastTransport===`relay`&&!n?e(`settings.remoteInstances.clientAuth.state.connectedRelay`):e(`settings.remoteInstances.clientAuth.state.connectedDirect`):t.lastUsedAt?e(`settings.remoteInstances.clientAuth.lastUsed`,{date:t.lastUsedAt}):e(`settings.remoteInstances.clientAuth.neverUsed`);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:q(`h-2 w-2 shrink-0 rounded-full`,t.revokedAt?`bg-muted-foreground/20`:i?`bg-[var(--status-success)]`:`bg-muted-foreground/30`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label}),xu(t.devicePlatform)?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:xu(t.devicePlatform)}):null,n?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.thisDevice`)}):null]}),(0,$.jsx)(`p`,{className:q(`typography-micro truncate`,i&&!t.revokedAt?`text-[var(--status-success)]`:`text-muted-foreground`),children:a})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void Dn(t),disabled:!!t.revokedAt,children:e(`settings.remoteInstances.clientAuth.actions.revoke`)})]},t.id)})]})]}),ot?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:ot}):null]})}):null,i?(0,$.jsx)(ku,{itemId:`remote-instances.instances`,label:e(`settings.remoteInstances.sidebar.title`),description:e(`settings.remoteInstances.sidebar.description`),action:(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>Qe(!0),disabled:He,children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsxs)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>Lt(!0),children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})]}),children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Be||f?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.direct.state.loading`)}):en.length===0&&o.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.sidebar.empty`)}):(0,$.jsxs)($.Fragment,{children:[en.map(t=>{let n=Ie[t.id],r=n?n.status===`ok`?`desktopHostSwitcher.status.connected`:n.status===`auth`?`desktopHostSwitcher.status.authRequired`:n.status===`update-recommended`?`desktopHostSwitcher.status.updateRecommended`:n.status===`incompatible`?`desktopHostSwitcher.status.incompatible`:n.status===`wrong-service`?`desktopHostSwitcher.status.wrongService`:`desktopHostSwitcher.status.unreachable`:`desktopHostSwitcher.status.checking`,i=n?.status===`ok`,a=de(t),o=a||Ke||He;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:q(`h-2 w-2 shrink-0 rounded-full`,n?i||a?`bg-[var(--status-success)]`:`bg-[var(--status-error)]`:`bg-muted-foreground/30 animate-pulse`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:ne(t.label)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.channel.link`)}),a?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null,Re===t.id?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.default`)}):null,(0,$.jsxs)(`span`,{className:q(`typography-micro shrink-0`,i||a?`text-[var(--status-success)]`:`text-muted-foreground`),children:[e(r),i&&typeof n?.latencyMs==`number`?e(`desktopHostSwitcher.status.ping`,{ms:Math.max(0,Math.round(n.latencyMs))}):``]})]}),(0,$.jsx)(`p`,{className:q(`typography-micro text-muted-foreground truncate`,t.apiUrl&&`font-mono`),children:t.relay&&!t.apiUrl?e(`mobile.connect.relay.badge`):ne(t.apiUrl||t.url)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void mn(t),disabled:o,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:ne(t.label)}),children:[(0,$.jsx)(J,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(a?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void pn(t.id),disabled:He||Re===t.id,"aria-label":e(`desktopHostSwitcher.actions.setAsDefaultAria`),children:Re===t.id?(0,$.jsx)(J,{name:`star-fill`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`star`,className:`h-3.5 w-3.5`})}),(()=>{let n=ie(t),r=!!n&&!n.startsWith(`relay://`)&&!t.relay;return t.relay?.serverId&&t.relay?.relayUrl&&t.relay?.hostEncPubJwk&&t.clientToken&&t.relay?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>er(t.id,`relay`,t),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):r?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>er(t.id,`direct`),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):null})(),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void on(t.id),disabled:He||Ke,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.delete`)]})]})]},`link:${t.id}`)}),o.map(t=>{let n=c[t.id],r=t.nickname?.trim()||t.sshParsed?.destination||t.id,i=n?.phase,a=i===`ready`,o=Pe.find(e=>e.id===t.id),s=de({id:t.id,label:r,url:n?.localUrl||o?.url||``}),l=(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void hn(t),disabled:s||Ke||!a,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:r}),children:[(0,$.jsx)(J,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(s?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]});return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${Tu(i)}`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:r}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.channel.ssh`)}),s?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null]}),(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:[e(Su(i)),n?.localUrl?` · ${n.localUrl}`:``]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>{(a?C(t.id):S(t.id)).catch(t=>{let r=n?.detail||(t instanceof Error?t.message:String(t)),i=ir(n?.errorCode,r);K.error(e(a?`settings.remoteInstances.sidebar.toast.disconnectFailed`:`settings.remoteInstances.sidebar.toast.connectFailed`),{description:a?t instanceof Error?t.message:String(t):Nn(e(cr(i)),i,r)})})},children:[a?(0,$.jsx)(J,{name:`stop`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`plug-2`,className:`h-3.5 w-3.5`}),e(a?`settings.remoteInstances.sidebar.actions.disconnect`:`settings.remoteInstances.sidebar.actions.connect`)]}),a?l:(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:l})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.switchInstanceDisabled`)})]}),a&&t.remoteOpenchamber?.mode!==`external`?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>er(t.id),children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]}):(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,disabled:!0,"aria-label":e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`),children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]})})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`)})]}),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>D(t.id),children:[(0,$.jsx)(J,{name:`pencil`,className:`h-3.5 w-3.5`}),e(`desktopHostSwitcher.actions.edit`)]})]})]},`ssh:${t.id}`)})]}),Ye?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:Ye}):null]})}):null,i?(0,$.jsx)(Jt,{open:Ze,onOpenChange:Qe,children:(0,$.jsxs)(Gt,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsx)(qt,{children:e(`settings.remoteInstances.direct.import.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),rn()},children:[(0,$.jsx)(ln,{className:`h-8`,value:qe,onChange:e=>Je(e.target.value),placeholder:e(`settings.remoteInstances.direct.import.placeholder`),disabled:He,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Qe(!1),disabled:He,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:He||!qe.trim(),children:e(`settings.remoteInstances.direct.import.action`)})]})]})]})}):null,(0,$.jsx)(Jt,{open:gt,onOpenChange:_t,children:(0,$.jsxs)(Gt,{className:vt===`result`?`sm:max-w-lg`:`sm:max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(vt===`result`?`settings.remoteInstances.clientAuth.qrDialogTitle`:`settings.remoteInstances.clientAuth.actions.addDevice`)}),(0,$.jsx)(qt,{children:e(vt===`result`?`settings.remoteInstances.clientAuth.qrScanHint`:`settings.remoteInstances.clientAuth.addDevice.subtitle`)})]}),vt===`configure`?(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Cn()},children:[(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(ln,{className:`h-8`,value:it,onChange:e=>at(e.target.value),placeholder:e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`),"aria-describedby":`add-device-instance-name-hint`,autoFocus:!0}),(0,$.jsx)(`span`,{id:`add-device-instance-name-hint`,className:`block typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.field.labelHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`)}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`),className:`space-y-1.5`,children:[{key:`relay`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.relay`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.relayHint`),available:!!Nt?.relayAvailable},{key:`lan`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.lan`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.lanHint`),available:!!Nt?.lanUrl},{key:`local`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.local`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.localHint`),available:!!Nt?.localUrl}].map(e=>{let t=St===e.key;return(0,$.jsxs)(`div`,{className:q(`flex items-start gap-2 py-0.5`,e.available?`cursor-pointer`:`opacity-45`),onClick:()=>{e.available&&Ct(e.key)},role:`presentation`,children:[(0,$.jsx)(Xn,{checked:t,disabled:!e.available,onChange:()=>Ct(e.key),ariaLabel:e.label,className:`mt-0.5`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/70`),children:e.label}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e.hint})]})]},e.key)})}),St===`lan`?(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 pt-1`,children:[(0,$.jsx)(Qt,{checked:wt,onChange:Tt,ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)})]}):null,St===`relay`&&Nt?.lanUrl?(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 pt-1`,children:[(0,$.jsx)(Qt,{checked:wt,onChange:Tt,ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)})]}):null,St===`relay`||St===`lan`&&wt?(()=>{let t=Array.from(new Set([...Nt?.relayUrls??[],...Nt?.relayUrl?[Nt.relayUrl]:[]])),n=t.length>1,r=Nt?.relayUrlLocked!==!0&&Nt?.remoteHost!==!0,i=n&&!At;return(0,$.jsxs)(`label`,{className:`block space-y-1.5 pt-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`)}),i?(0,$.jsxs)(an,{value:t.includes(Et)?Et:t[0],onValueChange:e=>{if(e===`__custom__`){jt(!0);return}Dt(e),kt(null)},children:[(0,$.jsx)(tn,{className:`h-8 w-full font-mono`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`),children:(0,$.jsx)(cn,{})}),(0,$.jsxs)(nn,{children:[t.map(e=>(0,$.jsx)($t,{value:e,className:`font-mono`,children:(0,$.jsx)(`span`,{className:`block max-w-[420px] truncate`,children:e})},e)),r?(0,$.jsx)($t,{value:`__custom__`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlCustomOption`)}):null]})]}):(0,$.jsx)(ln,{ref:Mt,className:`h-8 font-mono`,value:Et,onChange:e=>{Dt(e.target.value),kt(null)},placeholder:ou,readOnly:Nt?.relayUrlLocked===!0||Nt?.remoteHost===!0,"aria-readonly":Nt?.relayUrlLocked===!0||Nt?.remoteHost===!0||void 0,"aria-invalid":!!Ot||void 0,"aria-describedby":Ot?`add-device-relay-url-hint add-device-relay-url-error`:`add-device-relay-url-hint`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`}),(0,$.jsx)(`span`,{id:`add-device-relay-url-hint`,className:`block typography-meta text-muted-foreground`,children:Nt?.relayUrlLocked?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLockedHint`):Nt?.remoteHost?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlRemoteHostHint`):(0,$.jsxs)($.Fragment,{children:[e(`settings.remoteInstances.clientAuth.addDevice.relayUrlHint`),` `,(0,$.jsx)(`a`,{href:du,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,onClick:e=>{e.preventDefault(),xr(du)},children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlDeployLink`)})]})}),Ot?(0,$.jsx)(`span`,{id:`add-device-relay-url-error`,role:`alert`,"aria-live":`polite`,className:`block typography-meta text-[var(--status-error)]`,children:Ot}):null]})})():null]}),ot?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:ot}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>_t(!1),disabled:bt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:bt||!Nt,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[ft?(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(`img`,{src:ft,alt:e(`settings.remoteInstances.clientAuth.qrAlt`),className:`w-full max-w-[420px] rounded-md bg-white p-4`})}):null,ct?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate typography-code text-muted-foreground`,children:ct}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,onClick:Tn,children:[(0,$.jsx)(J,{name:mt?`check`:`file-copy`,className:q(`h-3.5 w-3.5`,mt&&`text-[var(--status-success)]`)}),e(mt?`settings.remoteInstances.clientAuth.actions.copied`:`settings.common.actions.copyAll`)]})]}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>_t(!1),children:e(`settings.remoteInstances.clientAuth.addDevice.done`)})})]})]})}),i?(0,$.jsx)(Jt,{open:It,onOpenChange:Lt,children:(0,$.jsxs)(Gt,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.remoteInstances.sidebar.actions.addSshInstance`)}),(0,$.jsx)(qt,{children:e(`settings.remoteInstances.page.section.instanceDescription`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),sn()},children:[(0,$.jsx)(ln,{className:`h-8`,value:Bt,onChange:e=>Vt(e.target.value),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`),disabled:m}),(0,$.jsx)(ln,{className:`h-8`,value:Rt,onChange:e=>zt(e.target.value),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`),disabled:m,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Lt(!1),disabled:m,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:m||!Rt.trim(),children:e(`settings.common.actions.create`)})]})]})]})}):null,i?(0,$.jsx)(ku,{label:e(`settings.remoteInstances.page.import.sectionTitle`),children:p?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.import.loading`)}):l.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.import.noneFound`)}):(0,$.jsx)(`div`,{children:l.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-3 last:border-b-0`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:[t.host,t.pattern?` ${e(`settings.remoteInstances.page.import.patternSuffix`)}`:``]}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:t.sshCommand})]}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Un(t.host,t.pattern),children:e(`settings.common.actions.import`)})]},`${t.source}:${t.host}`))})}):null,(0,$.jsx)(Jt,{open:!!_e,onOpenChange:e=>{e||Hn()},children:(0,$.jsxs)(Gt,{className:`sm:max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(qt,{children:_e?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:_e}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Wn()},children:[(0,$.jsx)(ln,{value:ye,onChange:e=>be(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Hn,disabled:xe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:xe,children:e(`settings.remoteInstances.page.actions.create`)})]})]})]})})]}),(0,$.jsx)(vu,{open:H,instanceId:U,targetKind:pe,relayHost:he,onOpenChange:e=>{ee(e),e||(fe(null),me(`ssh`),ge(null))}})]});let sr=k.remoteOpenchamber.mode===`managed`,lr=k.nickname?.trim()||k.sshParsed?.destination||k.id;return(0,$.jsx)(Jt,{open:!!k,onOpenChange:e=>{e||D(null)},children:(0,$.jsxs)(Gt,{className:`oc-settings-workspace oc-settings-workspace-desktop oc-settings-section-stack sm:max-w-4xl max-h-[90vh] overflow-auto`,children:[(0,$.jsxs)(Ut,{className:`gap-1 pr-8`,children:[(0,$.jsx)(Kt,{className:`truncate`,children:lr}),(0,$.jsxs)(qt,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full ${Tu(An)}`}),(0,$.jsx)(`span`,{children:e(Su(An))}),kn?.localUrl?(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`,children:kn.localUrl}):null,X?(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.status.reconnectStale`)}):null]})]}),An===`error`?(0,$.jsx)(Vn,{errorCode:kn?.errorCode,detail:kn?.detail}):null,(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.actions`),children:[(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Y,{type:`button`,variant:Fn?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:tr,disabled:Te||De,children:[Fn?(0,$.jsx)(J,{name:`stop`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`plug-2`,className:`h-3.5 w-3.5`}),or]}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:nr,disabled:!ar,children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5 ${Pn||Mn&&!X?`animate-spin`:``}`}),rr]}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{Jn()},children:[(0,$.jsx)(J,{name:`terminal-window`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.logs`)]}),(0,$.jsxs)(Y,{type:`button`,variant:`destructive`,size:`xs`,className:`!font-normal`,onClick:()=>{window.confirm(e(`settings.remoteInstances.page.confirm.removeInstance`))&&x(k.id).then(()=>{D(null),K.success(e(`settings.remoteInstances.page.toast.instanceRemoved`))}).catch(t=>{K.error(e(`settings.remoteInstances.page.toast.removeInstanceFailed`),{description:t instanceof Error?t.message:String(t)})})},children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.remove`)]})]}),kn?.localUrl?(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.status.currentLocalUrl`),children:(0,$.jsx)(`span`,{className:`font-mono text-foreground/90`,children:kn.localUrl})}):null]}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.instance`),children:[(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.sshCommand`),className:`oc-settings-ssh-command-row`,children:(0,$.jsx)(ln,{value:k.sshCommand,onChange:e=>Rn(t=>({...t,sshCommand:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`)})}),(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.nickname`),children:(0,$.jsx)(ln,{value:k.nickname||``,onChange:e=>Rn(t=>({...t,nickname:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`)})}),(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.connectionTimeoutSeconds`),children:(0,$.jsx)(zr,{min:5,max:240,step:1,className:`tabular-nums`,value:k.connectionTimeoutSec,onValueChange:e=>{Rn(t=>({...t,connectionTimeoutSec:Number.isFinite(e)?e:t.connectionTimeoutSec}))}})})]}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.remoteServer`),children:[(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.mode`),children:(0,$.jsxs)(an,{value:k.remoteOpenchamber.mode,onValueChange:e=>Rn(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,mode:e===`external`?`external`:`managed`}})),children:[(0,$.jsx)(tn,{children:(0,$.jsx)(cn,{placeholder:e(`settings.remoteInstances.page.field.modePlaceholder`)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`managed`,children:e(`settings.remoteInstances.page.field.modeManaged`)}),(0,$.jsx)($t,{value:`external`,children:e(`settings.remoteInstances.page.field.modeExternal`)})]})]})}),(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.preferredRemotePort`),children:(0,$.jsx)(zr,{min:1,max:65535,step:1,className:`tabular-nums`,value:k.remoteOpenchamber.preferredPort,onValueChange:e=>{Rn(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,preferredPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{Rn(e=>({...e,remoteOpenchamber:{...e.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})}),sr?(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.installMethod`),children:(0,$.jsxs)(an,{value:k.remoteOpenchamber.installMethod,onValueChange:e=>Rn(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,installMethod:e===`npm`||e===`download_release`||e===`upload_bundle`?e:`bun`}})),children:[(0,$.jsx)(tn,{children:(0,$.jsx)(cn,{placeholder:e(`settings.remoteInstances.page.field.selectInstallMethodPlaceholder`)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`bun`,children:`bun`}),(0,$.jsx)($t,{value:`npm`,children:`npm`}),(0,$.jsx)($t,{value:`download_release`,children:e(`settings.remoteInstances.page.field.installMethodDownloadRelease`)}),(0,$.jsx)($t,{value:`upload_bundle`,children:e(`settings.remoteInstances.page.field.installMethodUploadBundle`)})]})]})}):null,sr?(0,$.jsx)(Vr,{checked:k.remoteOpenchamber.keepRunning,onChange:e=>Rn(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,keepRunning:e}})),label:e(`settings.remoteInstances.page.field.keepServerRunning`),ariaLabel:e(`settings.remoteInstances.page.field.keepServerRunning`)}):null]}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.mainTunnel`),children:[(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.bindHost`),children:(0,$.jsxs)(an,{value:k.localForward.bindHost,onValueChange:t=>{t===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`))||Rn(e=>({...e,localForward:{...e.localForward,bindHost:t===`localhost`||t===`0.0.0.0`?t:`127.0.0.1`}}))},children:[(0,$.jsx)(tn,{children:(0,$.jsx)(cn,{placeholder:e(`settings.remoteInstances.page.field.selectBindHostPlaceholder`)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`127.0.0.1`,children:`127.0.0.1`}),(0,$.jsx)($t,{value:`localhost`,children:`localhost`}),(0,$.jsx)($t,{value:`0.0.0.0`,children:`0.0.0.0`})]})]})}),(0,$.jsxs)(Fr,{label:e(`settings.remoteInstances.page.field.preferredLocalPort`),children:[(0,$.jsx)(zr,{min:1,max:65535,step:1,className:`tabular-nums`,value:k.localForward.preferredLocalPort,onValueChange:e=>{Rn(t=>({...t,localForward:{...t.localForward,preferredLocalPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{Rn(e=>({...e,localForward:{...e.localForward,preferredLocalPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,"aria-label":e(`settings.remoteInstances.page.actions.pickRandomPort`),onClick:()=>Rn(e=>({...e,localForward:{...e.localForward,preferredLocalPort:fu()}})),children:(0,$.jsx)(J,{name:`shuffle`,className:`size-4`})})]})]}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.authentication`),children:[(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.sshPasswordOptional`),children:(0,$.jsx)(ln,{type:`password`,value:k.auth.sshPassword?.value||``,onChange:e=>Rn(t=>({...t,auth:{...t.auth,sshPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.sshPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.sshPasswordPlaceholder`)})}),(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.uiPasswordOptional`),children:(0,$.jsx)(ln,{type:`password`,value:k.auth.openchamberPassword?.value||``,onChange:e=>Rn(t=>({...t,auth:{...t.auth,openchamberPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.openchamberPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.uiPasswordPlaceholder`)})})]}),sr?(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.sync.runs.title`),children:M.length===0?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.sync.runs.empty`)}):M.map(t=>(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(`span`,{className:q(`shrink-0`,t.result===`success`?`text-[var(--status-success)]`:`text-[var(--status-error)]`),children:t.result===`success`?e(`settings.remoteInstances.page.sync.runs.result.success`):e(`settings.remoteInstances.page.sync.runs.result.failure`)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:[t.direction===`pull`?e(`settings.remoteInstances.page.sync.direction.pull`):e(`settings.remoteInstances.page.sync.direction.push`),t.endedAt?` · ${t.endedAt}`:``]})]},t.syncRunId))}):null,(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.portForwards`),children:[k.portForwards.length===0?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.empty.noExtraForwards`)}):null,k.portForwards.map((t,n)=>{let r=e=>{Rn(t=>({...t,portForwards:t.portForwards.map((t,r)=>r===n?e(t):t)}))},i=t.type===`remote`?e(`settings.remoteInstances.page.field.localTarget`):e(`settings.remoteInstances.page.field.localListen`),a=t.type===`remote`?e(`settings.remoteInstances.page.field.remoteListen`):e(`settings.remoteInstances.page.field.remoteTarget`),o=ju(t.localHost||`localhost`,t.localPort),s=ju(t.remoteHost||`localhost`,t.remotePort),c=t.type===`local`&&typeof t.localPort==`number`&&t.localPort>0,l=c?`http://${Mu(t.localHost)}:${t.localPort}`:``,u=!!Ce[t.id],d=t.type===`local`?e(`settings.remoteInstances.page.forwardType.local`):t.type===`remote`?e(`settings.remoteInstances.page.forwardType.remote`):e(`settings.remoteInstances.page.forwardType.dynamic`);return(0,$.jsxs)(Si,{open:u,onOpenChange:e=>{we(n=>({...n,[t.id]:e}))},className:`oc-settings-group-row`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex items-center gap-2`,children:(0,$.jsxs)(xi,{className:`flex items-center gap-2 group`,children:[(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground transition-transform ${u?`rotate-180`:``}`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:Eu(t)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 shrink-0`,children:d})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Qt,{checked:t.enabled,onChange:e=>r(t=>({...t,enabled:e})),ariaLabel:e(`settings.remoteInstances.page.actions.enableForwardAria`)}),(0,$.jsx)(Y,{type:`button`,variant:`destructive`,size:`icon`,"aria-label":e(`settings.remoteInstances.sidebar.actions.remove`),onClick:()=>Rn(e=>({...e,portForwards:e.portForwards.filter(e=>e.id!==t.id)})),children:(0,$.jsx)(J,{name:`delete-bin`,className:`size-4`})})]})]}),(0,$.jsx)(bi,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(Fr,{label:e(`settings.remoteInstances.page.field.forwardType`),description:e(Au(t.type)),children:(0,$.jsxs)(an,{value:t.type,onValueChange:e=>r(t=>({...t,type:e===`dynamic`||e===`remote`?e:`local`})),children:[(0,$.jsx)(tn,{children:(0,$.jsx)(cn,{placeholder:e(`settings.remoteInstances.page.field.typePlaceholder`)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`local`,children:e(`settings.remoteInstances.page.forwardType.local`)}),(0,$.jsx)($t,{value:`remote`,children:e(`settings.remoteInstances.page.forwardType.remote`)}),(0,$.jsx)($t,{value:`dynamic`,children:e(`settings.remoteInstances.page.forwardType.dynamic`)})]})]})}),(0,$.jsx)(Fr,{label:i,className:`oc-settings-ssh-endpoint-row`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(ln,{className:`min-w-0`,value:t.localHost||`127.0.0.1`,onChange:e=>r(t=>({...t,localHost:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.localHostPlaceholder`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`:`}),(0,$.jsx)(zr,{min:1,max:65535,step:1,className:`tabular-nums`,value:t.localPort,onValueChange:e=>{r(t=>({...t,localPort:Number.isFinite(e)&&e>0?e:void 0}))},onClear:()=>{r(e=>({...e,localPort:void 0}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})]})}),t.type===`dynamic`?null:(0,$.jsx)(Fr,{label:a,className:`oc-settings-ssh-endpoint-row`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(ln,{className:`min-w-0`,value:t.remoteHost||``,onChange:e=>r(t=>({...t,remoteHost:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.remoteHostPlaceholder`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`:`}),(0,$.jsx)(zr,{min:1,max:65535,step:1,className:`tabular-nums`,value:t.remotePort,onValueChange:e=>{r(t=>({...t,remotePort:Number.isFinite(e)&&e>0?e:void 0}))},onClear:()=>{r(e=>({...e,remotePort:void 0}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})]})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80`,children:t.type===`dynamic`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.localSocks5`)})]}):t.type===`remote`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{name:`server`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:s}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.remote`)}),(0,$.jsx)(J,{name:`arrow-right`,className:`h-3.5 w-3.5`}),(0,$.jsx)(J,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.local`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.local`)}),(0,$.jsx)(J,{name:`arrow-right`,className:`h-3.5 w-3.5`}),(0,$.jsx)(J,{name:`server`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:s}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.remote`)})]})}),c?(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{xr(l).then(t=>{t||K.error(e(`settings.remoteInstances.page.toast.openLocalEndpointFailed`))})},children:[(0,$.jsx)(J,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.openLocal`)]}):null]})]})})]},t.id)}),(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{let e=Du();Rn(t=>({...t,portForwards:[...t.portForwards,e]})),we(t=>({...t,[e.id]:!0}))},children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.addForward`)]})})]}),(0,$.jsxs)(Wt,{className:`flex-wrap`,children:[h?(0,$.jsx)(`div`,{className:`sm:mr-auto typography-meta text-[var(--status-error)]`,children:h}):null,kn?.localUrl?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{$n()},children:[(0,$.jsx)(J,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.open`)]}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{je(kn.localUrl||``).then(t=>{t.ok&&K.success(e(`settings.remoteInstances.page.toast.localUrlCopied`))})},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.copyLocalUrl`)]})]}):null,(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void zn(),disabled:!Ln||m,children:e(`settings.common.actions.saveChanges`)})]}),(0,$.jsx)(vu,{open:H,instanceId:U,targetKind:pe,relayHost:he,onOpenChange:e=>{ee(e),e||(fe(null),me(`ssh`),ge(null))}}),(0,$.jsx)(Jt,{open:P,onOpenChange:F,children:(0,$.jsxs)(Gt,{className:`sm:max-w-2xl`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.remoteInstances.page.logsDialog.title`)}),(0,$.jsx)(qt,{children:k?.nickname?.trim()||k?.sshParsed?.destination||k?.id||e(`settings.remoteInstances.page.logsDialog.selectedInstanceFallback`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Zn,disabled:I||!Yn.trim(),children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.copyAll`)]}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Qn(),disabled:I,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.clear`)]})]}),I?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.logsDialog.loading`)}):R?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:R}):(0,$.jsx)(`pre`,{className:`max-h-[55vh] overflow-auto rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3 typography-micro text-foreground whitespace-pre-wrap break-words`,children:B.length>0?B.join(`
|
|
24
|
-
`):e(`settings.remoteInstances.page.logsDialog.empty`)})]})}),(0,$.jsx)(Jt,{open:!!_e,onOpenChange:e=>{e||Hn()},children:(0,$.jsxs)(Gt,{className:`sm:max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(qt,{children:_e?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:_e}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Wn()},children:[(0,$.jsx)(ln,{value:ye,onChange:e=>be(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Hn,disabled:xe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:xe,children:e(`settings.common.actions.create`)})]})]})]})})]})})},Bu=`__add_provider__`,Vu=()=>{let e=ye.getDirectory();return typeof e==`string`&&e.trim().length>0?e.trim():null},Hu=({onItemSelect:e})=>{let{t}=ke(),n=G(e=>e.providers),r=G(e=>e.selectedProviderId),i=G(e=>e.setSelectedProvider),a=ft(e=>e.activeProjectId),[o,s]=Q.useState({}),c=Q.useMemo(()=>Vu(),[a]);Q.useEffect(()=>{if(n.length===0){s({});return}let e=!1;return(async()=>{let t=n.map(async t=>{try{let n=c?`?directory=${encodeURIComponent(c)}`:``,r=await L(`/api/provider/${encodeURIComponent(t.id)}/source${n}`,{method:`GET`,headers:{Accept:`application/json`}});if(!r.ok)return;let i=await r.json().catch(()=>null),a=i?.sources??i?.data?.sources;if(!a||e)return;s(e=>({...e,[t.id]:a}))}catch{}});await Promise.all(t)})(),()=>{e=!0}},[c,n]);let l=Q.useMemo(()=>n.filter(e=>!!o[e.id]?.project?.exists),[n,o]),u=Q.useMemo(()=>n.filter(e=>!o[e.id]?.project?.exists),[n,o]),d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.providers.sidebar.section.userProviders`)}),(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>{i(Bu),e?.()},"aria-label":t(`settings.providers.sidebar.actions.connectProviderAria`),title:t(`settings.providers.sidebar.actions.connectProviderTitle`),children:(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(ha,{}),(0,$.jsx)($.Fragment,{children:n.length===0?(0,$.jsx)(Z,{label:d,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`stack`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.providers.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.providers.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[u.length>0?(0,$.jsx)(Z,{label:d,children:u.map(t=>(0,$.jsx)(Uu,{provider:t,selectedProviderId:r,onSelect:()=>{i(t.id),e?.()}},t.id))}):(0,$.jsx)(Z,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),l.length>0&&(0,$.jsx)(Z,{label:t(`settings.providers.sidebar.section.projectProviders`),children:l.map(t=>(0,$.jsx)(Uu,{provider:t,selectedProviderId:r,onSelect:()=>{i(t.id),e?.()}},t.id))})]})})]})},Uu=e=>{let t=(0,Ei.c)(17),{provider:n,selectedProviderId:r,onSelect:i}=e,a=Array.isArray(n.models)?n.models.length:0,o=n.id===r,s=n.id,c=o?`bg-interactive-selection`:`hover:bg-interactive-hover`,l;t[0]===c?l=t[1]:(l=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 !min-h-0 py-2`,c),t[0]=c,t[1]=l);let u;t[2]===n.id?u=t[3]:(u=(0,$.jsx)(Zt,{providerId:n.id,className:`h-3.5 w-3.5 flex-shrink-0`}),t[2]=n.id,t[3]=u);let d=n.name||n.id,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:d}),t[4]=d,t[5]=f);let p;t[6]===a?p=t[7]:(p=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:a}),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==u||t[10]!==f||t[11]!==p?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[u,f,p]}),t[8]=i,t[9]=u,t[10]=f,t[11]=p,t[12]=m):m=t[12];let h;return t[13]!==n.id||t[14]!==l||t[15]!==m?(h=(0,$.jsx)(`div`,{className:l,children:m},s),t[13]=n.id,t[14]=l,t[15]=m,t[16]=h):h=t[16],h},Wu=e=>e,Gu=(e,t)=>e.flatMap((e,n)=>t(e)?[{method:e,methodIndex:n}]:[]),Ku=({providerId:e,providerName:t})=>{let{t:n}=ke(),[r,i]=Q.useState(null),[a,o]=Q.useState({}),[s,c]=Q.useState(!1),l=`/api/quota/credentials/${e}`;Q.useEffect(()=>{L(l).then(async e=>{if(!e.ok)throw Error();let t=await e.json();i(t),o(t.workspaceId?{workspaceId:t.workspaceId}:{})}).catch(()=>i({configured:!1}))},[l]);let u=async(e,r,a)=>{c(!0);try{let s=await L(e,{method:r,headers:a?{"Content-Type":`application/json`}:void 0,body:a?JSON.stringify(a):void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error);c?.configured!==void 0&&i(c),o(e=>e.workspaceId?{workspaceId:e.workspaceId}:{}),K.success(n(`settings.providers.page.quotaCredentials.saved`,{provider:t}))}catch(e){K.error(e instanceof Error&&e.message?e.message:n(`settings.providers.page.openCodeGo.saveFailed`))}finally{c(!1)}},d=(e,t,n)=>(0,$.jsxs)(`label`,{className:`oc-settings-group-row flex flex-col gap-1 typography-ui-label text-foreground`,children:[t,(0,$.jsx)(ln,{className:`font-mono text-xs`,type:e===`workspaceId`?`text`:`password`,autoComplete:`off`,value:a[e]??``,onChange:t=>o(n=>({...n,[e]:t.target.value})),placeholder:r?.secretMasked??n})]});return(0,$.jsx)(`div`,{"data-settings-item":`providers.${e}-credentials`,children:(0,$.jsxs)(Z,{label:t,className:`oc-settings-detail-group`,children:[e===`opencode-go`&&d(`workspaceId`,n(`settings.providers.page.openCodeGo.workspaceId`),`wrk_...`),e===`opencode-go`&&d(`authCookie`,n(`settings.providers.page.openCodeGo.authCookie`),`auth=...`),e===`ollama-cloud`&&d(`cookie`,n(`settings.providers.page.openCodeGo.authCookie`),`session=...`),e===`cursor`&&d(`accessToken`,n(`settings.providers.page.auth.apiKeyLabel`),n(`settings.providers.page.auth.apiKeyPlaceholder`)),e===`cursor`&&d(`refreshToken`,n(`settings.providers.page.auth.apiKeyLabel`),n(`settings.providers.page.auth.apiKeyPlaceholder`)),(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-wrap gap-2`,children:[(0,$.jsx)(Y,{size:`xs`,disabled:s,onClick:()=>u(l,`PUT`,a),children:r?.configured?n(`settings.providers.page.openCodeGo.replace`):n(`settings.providers.page.openCodeGo.save`)}),r?.configured&&(0,$.jsx)(Y,{variant:`outline`,size:`xs`,disabled:s,onClick:()=>u(`${l}/validate`,`POST`),children:n(`settings.providers.page.openCodeGo.validate`)}),e===`cursor`&&(0,$.jsx)(Y,{variant:`outline`,size:`xs`,disabled:s,onClick:()=>u(`${l}/import`,`POST`),children:n(`settings.providers.page.actions.connect`)}),r?.configured&&(0,$.jsx)(Y,{variant:`destructive`,size:`xs`,disabled:s,onClick:()=>u(l,`DELETE`),children:n(`settings.providers.page.openCodeGo.delete`)})]})]})})},qu=e=>{let t=(0,Ei.c)(12),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]!==a||t[1]!==r?(s=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:o}),t[3]=o,t[4]=c);let l;t[5]!==i||t[6]!==s||t[7]!==c?(l=(0,$.jsx)(Z,{className:`oc-settings-detail-group`,label:s,description:i,children:c}),t[5]=i,t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==l?(u=(0,$.jsx)(`div`,{"data-settings-item":n,children:l}),t[9]=n,t[10]=l,t[11]=u):u=t[11],u},Ju=e=>new Intl.NumberFormat(Ae(),{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0}).format(e),Yu=e=>{if(typeof e!=`number`||Number.isNaN(e))return null;if(e===0)return`0`;let t=Ju(e);return t.endsWith(`.0`)?t.slice(0,-2):t},Xu=`__add_provider__`,Zu=e=>typeof e==`object`&&!!e,Qu=e=>{let t=typeof e.type==`string`?e.type:``,n=`${t} ${`${e.name??``} ${e.label??``}`.toLowerCase()}`.toLowerCase();return n.includes(`oauth`)?`oauth`:n.includes(`api`)?`api`:t.toLowerCase()},$u=e=>{if(!Zu(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>Zu(e)));return t},ed=e=>{if(typeof e==`string`)return{id:e};if(!Zu(e))return null;let t=typeof e.id==`string`&&e.id||typeof e.providerID==`string`&&e.providerID||typeof e.slug==`string`&&e.slug||typeof e.name==`string`&&e.name;return t?{id:t,name:typeof e.name==`string`?e.name:void 0}:null},td=e=>{let t=[];Array.isArray(e)?t=e:Zu(e)&&(Array.isArray(e.all)?t=e.all:Array.isArray(e.providers)&&(t=e.providers));let n=t.map(e=>ed(e)).filter(e=>!!e),r=new Set;return n.filter(e=>!r.has(e.id)&&(r.add(e.id),!0))},nd=()=>{let{t:e}=ke(),t=G(e=>e.providers),n=G(e=>e.selectedProviderId),r=G(e=>e.setSelectedProvider),i=G(e=>e.getModelMetadata),a=u(e=>e.hiddenModels),o=u(e=>e.toggleHiddenModel),s=u(e=>e.hideAllModels),c=u(e=>e.showAllModels),[l,d]=Q.useState({}),[f,p]=Q.useState(!1),[m,h]=Q.useState({}),[g,_]=Q.useState(null),[v,y]=Q.useState(``),[b,x]=Q.useState(null),[S,C]=Q.useState({}),[w,T]=Q.useState({}),[E,D]=Q.useState([]),[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(``),[P,F]=Q.useState(``),[I,R]=Q.useState(!1),[z,B]=Q.useState({}),[V,H]=Q.useState(!1),ee=n===Xu;Q.useEffect(()=>{!n&&t.length>0&&r(t[0].id)},[t,n,r]),Q.useEffect(()=>{let t=!0;return(async()=>{p(!0);try{let e=await ye.getSdkClient().provider.auth();if(e.error)throw Error(`provider.auth failed: ${String(e.error)}`);if(!t)return;d($u(e.data))}catch(n){if(!t)return;console.error(`Failed to load provider auth methods:`,n),K.error(e(`settings.providers.page.toast.authMethodsLoadFailed`))}finally{t&&p(!1)}})(),()=>{t=!1}},[e]),Q.useEffect(()=>{if(!Wu(ee))return;let t=!0;return(async()=>{k(!0),j(null);try{let e=await ye.getSdkClient().provider.list();if(e.error)throw Error(`provider.list failed: ${String(e.error)}`);if(!t)return;D(td(e.data))}catch(n){if(!t)return;console.error(`Failed to load available providers:`,n),j(e(`settings.providers.page.state.unableToLoadProviderList`))}finally{t&&k(!1)}})(),()=>{t=!1}},[ee,e]);let U=Q.useMemo(()=>new Set(t.map(e=>e.id)),[t]),te=Q.useMemo(()=>E.filter(e=>!U.has(e.id)).sort((e,t)=>{let n=(e.name||e.id).toLowerCase(),r=(t.name||t.id).toLowerCase();return n.localeCompare(r)}),[E,U]);Q.useEffect(()=>{n===Xu&&M&&!te.some(e=>e.id===M)&&N(``)},[n,M,te]),Q.useEffect(()=>{if(n===Xu){H(!0);return}H(!1)},[n,e]),Q.useEffect(()=>{if(!n||n===Xu)return;let t=!1;return(async()=>{try{let r=await L(`/api/provider/${encodeURIComponent(n)}/source`,{method:`GET`,headers:{Accept:`application/json`}}),i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.error||e(`settings.providers.page.toast.providerSourcesLoadFailed`));let a=i?.sources??i?.data?.sources;!t&&a&&B(e=>({...e,[n]:a}))}catch(e){t||console.error(`Failed to load provider sources:`,e)}})(),()=>{t=!0}},[n,e]);let W=t.find(e=>e.id===n),ne=n?z[n]:void 0,re=async t=>{let n=m[t]?.trim()??``;if(!n){K.error(e(`settings.providers.page.toast.apiKeyRequired`));return}let i=`api:${t}`;_(i);try{if((await ye.getSdkClient().auth.set({providerID:t,auth:{type:`api`,key:n}})).error)throw Error(e(`settings.providers.page.toast.apiKeySaveFailed`));K.success(e(`settings.providers.page.toast.apiKeySaved`)),h(e=>({...e,[t]:``})),await We({scopes:[`providers`],mode:`active`}),r(t)}catch(t){console.error(`Failed to save API key:`,t),K.error(e(`settings.providers.page.toast.apiKeySaveFailed`))}finally{_(null)}},ie=async(t,n)=>{let r=`oauth:${t}:${n}`,i=!1;_(r);try{let r=await ye.getSdkClient().provider.oauth.authorize({providerID:t,method:n});if(r.error)throw Error(e(`settings.providers.page.toast.oauthStartFailed`));let a=Zu(r.data)?r.data:{},o=a.data,s=Zu(o)?o:a,c=typeof s.url==`string`&&s.url||typeof s.verification_uri_complete==`string`&&s.verification_uri_complete||typeof s.verification_uri==`string`&&s.verification_uri||void 0,l=typeof s.instructions==`string`&&s.instructions||typeof s.message==`string`&&s.message||void 0,u=typeof s.user_code==`string`&&s.user_code||typeof s.code==`string`&&s.code||typeof s.userCode==`string`&&s.userCode||void 0,d=s.method===`auto`?`auto`:`code`;if(!c&&!l&&!u)throw Error(e(`settings.providers.page.toast.oauthDetailsMissing`));let f=`${t}:${n}`;T(e=>({...e,[f]:{url:c,instructions:l,userCode:u,mode:d}})),c&&xr(c),x({providerId:t,methodIndex:n,mode:d}),K.message(e(`settings.providers.page.toast.completeOAuthInBrowser`)),d===`auto`&&(i=!0,ae(t,n))}catch(t){console.error(`Failed to start OAuth flow:`,t),K.error(e(`settings.providers.page.toast.oauthStartFailed`))}finally{i||_(null)}},ae=async(t,n,i)=>{let a=`${t}:${n}`,o=i??S[a]?.trim(),s=`oauth-complete:${t}:${n}`;_(s);try{let i={method:n};if(o&&(i.code=o),(await ye.getSdkClient().provider.oauth.callback({providerID:t,method:i.method,code:i.code})).error)throw Error(e(`settings.providers.page.toast.oauthCompleteFailed`));K.success(e(`settings.providers.page.toast.oauthCompleted`)),C(e=>({...e,[a]:``})),x(null),await We({scopes:[`providers`],mode:`active`}),r(t)}catch(t){console.error(`Failed to complete OAuth flow:`,t),K.error(e(`settings.providers.page.toast.oauthCompleteFailed`))}finally{_(null)}},oe=async t=>{let n=await je(t);if(n.ok){K.success(e(`settings.providers.page.toast.oauthLinkCopied`));return}console.error(`Failed to copy OAuth link:`,n.error),K.error(e(`settings.providers.page.toast.oauthLinkCopyFailed`))},se=async t=>{let n=await je(t);if(n.ok){K.success(e(`settings.providers.page.toast.deviceCodeCopied`));return}console.error(`Failed to copy device code:`,n.error),K.error(e(`settings.providers.page.toast.deviceCodeCopyFailed`))},ce=async t=>{let n=`disconnect:${t}`;_(n);try{let n=await L(`/api/provider/${encodeURIComponent(t)}/auth?scope=all`,{method:`DELETE`,headers:{Accept:`application/json`}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||e(`settings.providers.page.toast.providerDisconnectFailed`));K.success(e(`settings.providers.page.toast.providerDisconnected`)),await We({scopes:[`providers`],mode:`active`})}catch(t){console.error(`Failed to disconnect provider:`,t),K.error(e(`settings.providers.page.toast.providerDisconnectFailed`))}finally{_(null)}};if(!ee&&t.length===0)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.providers.page.empty.noProvidersDetected`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.providers.page.empty.checkOpenCodeConfiguration`)})]})});if(ee)return(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{"data-settings-item":`providers.connect`,children:(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.providers.page.connect.title`)})}),(0,$.jsx)(qu,{label:e(`settings.providers.page.connect.selectProviderTitle`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.providers.page.connect.providerField`)}),O?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.state.loading`)}):A?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:A}):te.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.connect.allProvidersConnected`)}):(0,$.jsxs)(Tn,{open:I,onOpenChange:e=>{R(e),e||F(``)},children:[(0,$.jsx)(An,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:q(`flex items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover h-6 w-fit`),children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[M?(0,$.jsx)(Zt,{providerId:M,className:`h-3.5 w-3.5 flex-shrink-0`}):null,(0,$.jsx)(`span`,{className:q(`truncate typography-ui-label font-normal`,M?`text-foreground`:`text-muted-foreground`),children:M?te.find(e=>e.id===M)?.name||M:e(`settings.providers.page.connect.selectProviderPlaceholder`)})]}),(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`})]})}),(0,$.jsxs)(mn,{align:`start`,className:`w-[280px] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2`,onKeyDown:e=>e.stopPropagation(),children:[(0,$.jsx)(J,{name:`search`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`input`,{type:`text`,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:e(`settings.providers.page.connect.searchProvidersPlaceholder`),className:`flex-1 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`,autoFocus:!0})]}),(0,$.jsx)(yr,{outerClassName:`max-h-[240px]`,className:`p-1`,children:(()=>{let t=te.filter(e=>{let t=P.toLowerCase();return(e.name||e.id).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)});return t.length===0?(0,$.jsx)(`p`,{className:`py-4 text-center typography-meta text-muted-foreground`,children:e(`settings.providers.page.connect.noProvidersFound`)}):t.map(e=>(0,$.jsxs)(_n,{onSelect:()=>{N(e.id),R(!1),F(``)},className:`flex items-center justify-between`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Zt,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name||e.id})]}),M===e.id&&(0,$.jsx)(J,{name:`check`,className:`h-4 w-4 text-[var(--primary-base)]`})]},e.id))})()})]})]})]})}),M&&(0,$.jsx)(qu,{itemId:`providers.auth`,label:e(`settings.providers.page.auth.title`),children:f?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.auth.loadingMethods`)}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsxs)(`label`,{className:`typography-ui-label text-foreground flex items-center gap-1.5`,children:[e(`settings.providers.page.auth.apiKeyLabel`),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.providers.page.auth.apiKeyTooltip`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5`,children:[(0,$.jsx)(ln,{type:`password`,value:m[M]??``,onChange:e=>h(t=>({...t,[M]:e.target.value})),placeholder:e(`settings.providers.page.auth.apiKeyPlaceholder`),className:`flex-1 font-mono text-xs`}),(0,$.jsx)(Y,{size:`xs`,className:`!font-normal shrink-0`,onClick:()=>re(M),disabled:g===`api:${M}`,children:g===`api:${M}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.saveKey`)})]})]}),(()=>{let t=Gu(l[M]??[],e=>Qu(e)===`oauth`);return t.length===0?null:(0,$.jsx)(`div`,{className:`space-y-4 border-t border-[var(--surface-subtle)] pt-2`,children:t.map(({method:t,methodIndex:n},r)=>{let i=t.label||t.name||e(`settings.providers.page.auth.oauthMethodFallback`,{index:String(r+1)}),a=`${M}:${n}`,o=b?.providerId===M&&b?.methodIndex===n;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i}),(t.description||t.help)&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:String(t.description||t.help)})]}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ie(M,n),disabled:g===`oauth:${M}:${n}`||g===`oauth-complete:${M}:${n}`,children:e(`settings.providers.page.actions.connect`)})]}),w[a]?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:w[a]?.instructions}),w[a]?.userCode&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(ln,{value:w[a]?.userCode,readOnly:!0,className:`font-mono text-center tracking-widest`}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>se(w[a]?.userCode??``),children:e(`settings.providers.page.actions.copyCode`)})]}),w[a]?.url&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(ln,{value:w[a]?.url,readOnly:!0,className:`text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>xr(w[a]?.url??``),children:e(`settings.providers.page.actions.open`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>oe(w[a]?.url??``),children:e(`settings.providers.page.actions.copy`)})]})]}),o&&b?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(ln,{value:S[a]??``,onChange:e=>C(t=>({...t,[a]:e.target.value})),placeholder:e(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`font-mono text-xs`}),(0,$.jsx)(Y,{size:`xs`,className:`!font-normal`,onClick:()=>ae(M,n),disabled:g===`oauth-complete:${M}:${n}`,children:g===`oauth-complete:${M}:${n}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.complete`)})]})]},`${M}-${i}`)})})})()]})})]})});if(!W)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.providers.page.empty.selectProviderFromSidebar`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.providers.page.empty.reviewDetailsAndConfigureAuth`)})]})});let le=Array.isArray(W.models)?W.models:[],ue=Gu(l[W.id]??[],e=>Qu(e)===`oauth`),de=le.filter(e=>{let t=typeof e?.name==`string`?e.name:``,n=typeof e?.id==`string`?e.id:``,r=v.trim().toLowerCase();return!r||t.toLowerCase().includes(r)||n.toLowerCase().includes(r)});return(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(Zt,{providerId:W.id,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:W.name||W.id}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:(0,$.jsx)(`span`,{className:`font-mono`,children:W.id})})]})]}),(0,$.jsx)(qu,{itemId:`providers.auth`,label:e(`settings.providers.page.auth.title`),action:(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>H(e=>!e),children:e(V?`settings.providers.page.actions.hide`:`settings.providers.page.actions.reconnect`)}),children:V?f?(0,$.jsx)(`div`,{className:`py-1.5 typography-meta text-muted-foreground`,children:e(`settings.providers.page.auth.loadingMethods`)}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsxs)(`label`,{className:`typography-ui-label text-foreground flex items-center gap-1.5`,children:[e(`settings.providers.page.auth.apiKeyLabel`),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.providers.page.auth.apiKeyTooltip`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5`,children:[(0,$.jsx)(ln,{type:`password`,value:m[W.id]??``,onChange:e=>h(t=>({...t,[W.id]:e.target.value})),placeholder:e(`settings.providers.page.auth.apiKeyPlaceholder`),className:`flex-1 font-mono text-xs`}),(0,$.jsx)(Y,{size:`xs`,className:`!font-normal shrink-0`,onClick:()=>re(W.id),disabled:g===`api:${W.id}`,children:g===`api:${W.id}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.saveKey`)})]})]}),ue.length>0&&(0,$.jsx)(`div`,{className:`space-y-4 border-t border-[var(--surface-subtle)] pt-2`,children:ue.map(({method:t,methodIndex:n},r)=>{let i=t.label||t.name||e(`settings.providers.page.auth.oauthMethodFallback`,{index:String(r+1)}),a=`${W.id}:${n}`,o=b?.providerId===W.id&&b?.methodIndex===n;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i}),(t.description||t.help)&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:String(t.description||t.help)})]}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ie(W.id,n),disabled:g===`oauth:${W.id}:${n}`||g===`oauth-complete:${W.id}:${n}`,children:e(`settings.providers.page.actions.connect`)})]}),w[a]?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:w[a]?.instructions}),w[a]?.userCode&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(ln,{value:w[a]?.userCode,readOnly:!0,className:`font-mono text-center tracking-widest`}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>se(w[a]?.userCode??``),children:e(`settings.providers.page.actions.copyCode`)})]}),w[a]?.url&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(ln,{value:w[a]?.url,readOnly:!0,className:`text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>xr(w[a]?.url??``),children:e(`settings.providers.page.actions.open`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>oe(w[a]?.url??``),children:e(`settings.providers.page.actions.copy`)})]})]}),o&&b?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(ln,{value:S[a]??``,onChange:e=>C(t=>({...t,[a]:e.target.value})),placeholder:e(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`font-mono text-xs`}),(0,$.jsx)(Y,{size:`xs`,className:`!font-normal`,onClick:()=>ae(W.id,n),disabled:g===`oauth-complete:${W.id}:${n}`,children:g===`oauth-complete:${W.id}:${n}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.complete`)})]})]},`${W.id}-${i}`)})})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1.5`,children:[(0,$.jsx)(J,{name:`check`,className:`w-4 h-4 text-[var(--status-success)] shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.providers.page.auth.connected`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-1`,children:e(`settings.providers.page.auth.useReconnectHint`)})]})}),(W.id===`opencode`||W.id===`opencode-go`)&&(0,$.jsx)(Ku,{providerId:`opencode-go`,providerName:`OpenCode Go`}),(W.id===`ollama`||W.id===`ollama-cloud`)&&(0,$.jsx)(Ku,{providerId:`ollama-cloud`,providerName:`Ollama Cloud`}),W.id===`cursor`&&(0,$.jsx)(Ku,{providerId:`cursor`,providerName:`Cursor`}),(0,$.jsx)(qu,{itemId:`providers.connection-details`,label:e(`settings.providers.page.connectionDetails.title`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:ne&&(ne.auth.exists||ne.user.exists||ne.project.exists||ne.custom?.exists)?(0,$.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[e(`settings.providers.page.connectionDetails.configuredIn`),` `,[ne.auth.exists?e(`settings.providers.page.connectionDetails.source.authCredentials`):null,ne.user.exists?e(`settings.providers.page.connectionDetails.source.userConfig`):null,ne.project.exists?e(`settings.providers.page.connectionDetails.source.projectConfig`):null,ne.custom?.exists?e(`settings.providers.page.connectionDetails.source.customConfig`):null].filter(Boolean).join(`, `)]}):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.connectionDetails.noActiveSource`)})}),(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>ce(W.id),disabled:g===`disconnect:${W.id}`,children:g===`disconnect:${W.id}`?e(`settings.providers.page.actions.disconnecting`):e(`settings.providers.page.actions.disconnect`)})]})}),(0,$.jsxs)(qu,{itemId:`providers.models`,label:(0,$.jsxs)($.Fragment,{children:[e(`settings.providers.page.models.title`),le.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,le.length,`)`]})]}),action:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{let e=le.map(e=>typeof e?.id==`string`?e.id:``).filter(e=>e.length>0);s(W.id,e)},children:e(`settings.providers.page.actions.hideAll`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>c(W.id),children:e(`settings.providers.page.actions.showAll`)})]}),children:[(0,$.jsxs)(`div`,{className:`relative mb-2`,children:[(0,$.jsx)(J,{name:`search`,className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(ln,{value:v,onChange:e=>y(e.target.value),placeholder:e(`settings.providers.page.models.filterPlaceholder`),className:`h-7 pl-8 w-full`})]}),de.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-4 text-center`,children:e(`settings.providers.page.models.noModelsMatchFilter`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:de.map(t=>{let n=typeof t?.id==`string`?t.id:``,r=typeof t?.name==`string`?t.name:n,s=n?i(W.id,n):void 0,c=a.some(e=>e.providerID===W.id&&e.modelID===n),l=Yu(s?.limit?.context),u=Yu(s?.limit?.output),d=[];return s?.tool_call&&d.push({key:`tools`,icon:`tools`,label:e(`settings.providers.page.models.capability.toolCalling`)}),s?.reasoning&&d.push({key:`reasoning`,icon:`brain-ai-3`,label:e(`settings.providers.page.models.capability.reasoning`)}),s?.attachment&&d.push({key:`image`,icon:`file-image`,label:e(`settings.providers.page.models.capability.imageInput`)}),(0,$.jsx)(`div`,{className:`py-1.5`,children:(0,$.jsxs)(`div`,{className:q(`flex flex-wrap items-center gap-x-3 gap-y-1.5 md:flex-nowrap md:gap-3`,c&&`opacity-50`),children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate w-full min-w-0 md:w-auto md:flex-1`,children:r}),(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 flex-shrink-0 md:w-auto md:flex-nowrap`,children:[(l||u)&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[l?`${l} ${e(`settings.providers.page.models.tokenBadge.context`)}`:``,l&&u?` · `:``,u?`${u} ${e(`settings.providers.page.models.tokenBadge.output`)}`:``]}),d.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:d.map(({key:e,icon:t,label:n})=>(0,$.jsx)(`span`,{className:`flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]`,title:n,"aria-label":n,children:(0,$.jsx)(J,{name:t,className:`h-3 w-3`})},e))}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(W.id,n),className:`ml-auto flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 md:ml-0`,title:e(c?`settings.providers.page.models.actions.showModelInSelectors`:`settings.providers.page.models.actions.hideModelFromSelectors`),"aria-label":e(c?`settings.providers.page.models.actions.showModel`:`settings.providers.page.models.actions.hideModel`),children:c?(0,$.jsx)(J,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`eye`,className:`h-3.5 w-3.5`})})]})]})},n)})})]})]})})},rd=e=>{let t=e?.windows??{},n=Object.values(t).map(e=>e.usedPercent).filter(e=>typeof e==`number`);return n.length===0?null:Math.max(...n)},id=e=>{let t=(0,Ei.c)(112),{onItemSelect:n}=e,{t:r}=ke(),i=fi(ad),a=fi(od),o=fi(sd),s=fi(cd),c=fi(ld),l=fi(ud),u=fi(dd),d=fi(fd),f=fi(pd),p=fi(md),m=fi(hd),h=fi(gd),g=fi(_d),_=fi(vd),v,y;t[0]===_?(v=t[1],y=t[2]):(v=()=>{_()},y=[_],t[0]=_,t[1]=v,t[2]=y),Q.useEffect(v,y);let b=yd,x;t[3]===f?x=t[4]:(x=e=>{f(e),b({usageAutoRefresh:e})},t[3]=f,t[4]=x);let S=x,C;t[5]===p?C=t[6]:(C=e=>{let t=Number(e);Number.isFinite(t)&&(p(t),b({usageRefreshIntervalMs:t}))},t[5]=p,t[6]=C);let w=C,T;t[7]===m?T=t[8]:(T=e=>{(e===`usage`||e===`remaining`)&&(m(e),b({usageDisplayMode:e}))},t[7]=m,t[8]=T);let E=T,D;t[9]===g?D=t[10]:(D=e=>{g(e),b({usageShowPredValues:e})},t[9]=g,t[10]=D);let O=D,k;t[11]===r?k=t[12]:(k=r(`settings.usage.sidebar.title`),t[11]=r,t[12]=k);let A;t[13]===s?A=t[14]:(A=()=>s(),t[13]=s,t[14]=A);let j;t[15]===r?j=t[16]:(j=r(`settings.usage.sidebar.actions.refreshAria`),t[15]=r,t[16]=j);let M;t[17]===r?M=t[18]:(M=r(`settings.usage.sidebar.actions.refreshTitle`),t[17]=r,t[18]=M);let N=c&&`animate-spin`,P;t[19]===N?P=t[20]:(P=q(`h-3.5 w-3.5`,N),t[19]=N,t[20]=P);let F;t[21]===P?F=t[22]:(F=(0,$.jsx)(J,{name:`refresh`,className:P}),t[21]=P,t[22]=F);let I;t[23]!==c||t[24]!==M||t[25]!==F||t[26]!==A||t[27]!==j?(I=(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`text-muted-foreground`,onClick:A,"aria-label":j,title:M,disabled:c,children:F}),t[23]=c,t[24]=M,t[25]=F,t[26]=A,t[27]=j,t[28]=I):I=t[28];let L;t[29]!==I||t[30]!==k?(L=(0,$.jsx)(Fr,{label:k,children:I}),t[29]=I,t[30]=k,t[31]=L):L=t[31];let R;t[32]===r?R=t[33]:(R=r(`settings.usage.sidebar.field.autoRefresh`),t[32]=r,t[33]=R);let z;t[34]===r?z=t[35]:(z=r(`settings.usage.sidebar.actions.toggleAutoRefreshAria`),t[34]=r,t[35]=z);let B;t[36]!==S||t[37]!==z||t[38]!==l?(B=(0,$.jsx)(Qt,{checked:l,onChange:S,ariaLabel:z}),t[36]=S,t[37]=z,t[38]=l,t[39]=B):B=t[39];let V;t[40]!==R||t[41]!==B?(V=(0,$.jsx)(Fr,{label:R,children:B}),t[40]=R,t[41]=B,t[42]=V):V=t[42];let H;t[43]===r?H=t[44]:(H=r(`settings.usage.sidebar.field.refreshInterval`),t[43]=r,t[44]=H);let ee=String(u),U=!l,te;t[45]===r?te=t[46]:(te=r(`settings.usage.sidebar.field.intervalPlaceholder`),t[45]=r,t[46]=te);let W;t[47]===te?W=t[48]:(W=(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:te,children:bd})}),t[47]=te,t[48]=W);let ne;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`30000`,children:`30s`}),(0,$.jsx)($t,{value:`60000`,children:`1m`}),(0,$.jsx)($t,{value:`300000`,children:`5m`})]}),t[49]=ne):ne=t[49];let re;t[50]!==w||t[51]!==ee||t[52]!==U||t[53]!==W?(re=(0,$.jsxs)(an,{value:ee,onValueChange:w,disabled:U,children:[W,ne]}),t[50]=w,t[51]=ee,t[52]=U,t[53]=W,t[54]=re):re=t[54];let ie;t[55]!==H||t[56]!==re?(ie=(0,$.jsx)(Fr,{label:H,children:re}),t[55]=H,t[56]=re,t[57]=ie):ie=t[57];let ae;t[58]===r?ae=t[59]:(ae=r(`settings.usage.sidebar.field.display`),t[58]=r,t[59]=ae);let oe;t[60]===r?oe=t[61]:(oe=r(`settings.usage.sidebar.field.displayModePlaceholder`),t[60]=r,t[61]=oe);let se;t[62]===r?se=t[63]:(se=e=>e===`usage`?r(`settings.usage.sidebar.field.displayModeUsage`):e===`remaining`?r(`settings.usage.sidebar.field.displayModeRemaining`):e,t[62]=r,t[63]=se);let ce;t[64]!==oe||t[65]!==se?(ce=(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:oe,children:se})}),t[64]=oe,t[65]=se,t[66]=ce):ce=t[66];let le;t[67]===r?le=t[68]:(le=r(`settings.usage.sidebar.field.displayModeUsage`),t[67]=r,t[68]=le);let ue;t[69]===le?ue=t[70]:(ue=(0,$.jsx)($t,{value:`usage`,children:le}),t[69]=le,t[70]=ue);let de;t[71]===r?de=t[72]:(de=r(`settings.usage.sidebar.field.displayModeRemaining`),t[71]=r,t[72]=de);let fe;t[73]===de?fe=t[74]:(fe=(0,$.jsx)($t,{value:`remaining`,children:de}),t[73]=de,t[74]=fe);let pe;t[75]!==ue||t[76]!==fe?(pe=(0,$.jsxs)(nn,{children:[ue,fe]}),t[75]=ue,t[76]=fe,t[77]=pe):pe=t[77];let me;t[78]!==E||t[79]!==ce||t[80]!==pe||t[81]!==d?(me=(0,$.jsxs)(an,{value:d,onValueChange:E,children:[ce,pe]}),t[78]=E,t[79]=ce,t[80]=pe,t[81]=d,t[82]=me):me=t[82];let he;t[83]!==ae||t[84]!==me?(he=(0,$.jsx)(Fr,{label:ae,children:me}),t[83]=ae,t[84]=me,t[85]=he):he=t[85];let ge;t[86]===r?ge=t[87]:(ge=r(`settings.usage.sidebar.field.showPredictions`),t[86]=r,t[87]=ge);let _e;t[88]===r?_e=t[89]:(_e=r(`settings.usage.sidebar.field.showPredictions`),t[88]=r,t[89]=_e);let ve;t[90]!==O||t[91]!==h||t[92]!==ge||t[93]!==_e?(ve=(0,$.jsx)(Vr,{checked:h,onChange:O,label:ge,ariaLabel:_e}),t[90]=O,t[91]=h,t[92]=ge,t[93]=_e,t[94]=ve):ve=t[94];let ye;t[95]!==L||t[96]!==V||t[97]!==ie||t[98]!==he||t[99]!==ve?(ye=(0,$.jsxs)(Z,{children:[L,V,ie,he,ve]}),t[95]=L,t[96]=V,t[97]=ie,t[98]=he,t[99]=ve,t[100]=ye):ye=t[100];let be;t[101]!==n||t[102]!==i||t[103]!==a||t[104]!==o||t[105]!==r?(be=wr.map(e=>{let t=i.find(t=>t.providerId===e.id),s=rd(t?.usage),c=Rn(s),l=e.id===a,u=t?.configured??!1,d=u?c===`critical`?{backgroundColor:`var(--status-error)`}:c===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`}:{backgroundColor:`var(--surface-muted-foreground)`,opacity:.4};return(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,l?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.id),n?.()},className:`flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full flex-shrink-0`,style:d}),(0,$.jsx)(Zt,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:e.name}),!u&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:r(`settings.usage.sidebar.status.notSet`)})]})},e.id)}),t[101]=n,t[102]=i,t[103]=a,t[104]=o,t[105]=r,t[106]=be):be=t[106];let xe;t[107]===be?xe=t[108]:(xe=(0,$.jsx)(Z,{children:be}),t[107]=be,t[108]=xe);let Se;return t[109]!==ye||t[110]!==xe?(Se=(0,$.jsxs)(`div`,{className:`oc-settings-page-content oc-settings-usage-sidebar h-full overflow-y-auto bg-background p-3`,children:[ye,xe]}),t[109]=ye,t[110]=xe,t[111]=Se):Se=t[111],Se};function ad(e){return e.results}function od(e){return e.selectedProviderId}function sd(e){return e.setSelectedProvider}function cd(e){return e.fetchAllQuotas}function ld(e){return e.isLoading}function ud(e){return e.autoRefresh}function dd(e){return e.refreshIntervalMs}function fd(e){return e.displayMode}function pd(e){return e.setAutoRefresh}function md(e){return e.setRefreshInterval}function hd(e){return e.setDisplayMode}function gd(e){return e.showPredValues}function _d(e){return e.setShowPredValues}function vd(e){return e.loadSettings}async function yd(e){try{await V(e)}catch(e){console.warn(`Failed to save usage settings:`,e)}}function bd(e){return e===`30000`?`30s`:e===`60000`?`1m`:e===`300000`?`5m`:e}var xd=e=>{let t=(0,Ei.c)(54),{title:n,window:r,subtitle:i,showToggle:a,toggleEnabled:o,onToggle:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,d=fi(Sd),f=fi(Cd),p=u(wd),m=d===`remaining`?r.remainingPercent:r.usedPercent,h=d===`remaining`?`remaining`:`used`,g;t[0]!==m||t[1]!==r.valueLabel?(g=Fn(r.valueLabel,m),t[0]=m,t[1]=r.valueLabel,t[2]=g):g=t[2];let _=g,v=r.resetAfterFormatted??r.resetAtFormatted,y;t[3]!==v||t[4]!==p||t[5]!==r.resetAt?(y=$n(r.resetAt,v,p),t[3]=v,t[4]=p,t[5]=r.resetAt,t[6]=y):y=t[6];let b=y,x;t[7]===n?x=t[8]:(x=nr(n),t[7]=n,t[8]=x);let S=x,C;t[9]!==n||t[10]!==r.resetAt||t[11]!==r.usedPercent||t[12]!==r.windowSeconds?(C=Pn(r.usedPercent,r.resetAt,r.windowSeconds,n),t[9]=n,t[10]=r.resetAt,t[11]=r.usedPercent,t[12]=r.windowSeconds,t[13]=C):C=t[13];let w=C,T;bb0:{if(!w||w.dailyAllocationPercent===null){T=null;break bb0}let e=Wn(w.elapsedRatio);T=d===`remaining`?100-e:e}let E=T,D;t[14]!==s||t[15]!==c||t[16]!==l?(D=c&&(0,$.jsx)(Qt,{checked:l,onChange:e=>s?.(e),ariaLabel:`Show in dropdown`}),t[14]=s,t[15]=c,t[16]=l,t[17]=D):D=t[17];let O;t[18]===S?O=t[19]:(O=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:S}),t[18]=S,t[19]=O);let k;t[20]===i?k=t[21]:(k=i&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:i}),t[20]=i,t[21]=k);let A;t[22]!==O||t[23]!==k?(A=(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[O,k]}),t[22]=O,t[23]=k,t[24]=A):A=t[24];let j;t[25]!==A||t[26]!==D?(j=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[D,A]}),t[25]=A,t[26]=D,t[27]=j):j=t[27];let M=_===`-`?``:_,N;t[28]===M?N=t[29]:(N=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground tabular-nums flex items-center justify-end`,children:M}),t[28]=M,t[29]=N);let P;t[30]!==j||t[31]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[j,N]}),t[30]=j,t[31]=N,t[32]=P):P=t[32];let F;t[33]!==m||t[34]!==E||t[35]!==r.usedPercent?(F=(0,$.jsx)(ni,{percent:m,tonePercent:r.usedPercent,expectedMarkerPercent:E,className:`h-1.5`}),t[33]=m,t[34]=E,t[35]=r.usedPercent,t[36]=F):F=t[36];let I=b?`Resets ${b}`:``,L;t[37]===I?L=t[38]:(L=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:I}),t[37]=I,t[38]=L);let R;t[39]===h?R=t[40]:(R=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:h}),t[39]=h,t[40]=R);let z;t[41]!==L||t[42]!==R?(z=(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between`,children:[L,R]}),t[41]=L,t[42]=R,t[43]=z):z=t[43];let B;t[44]!==F||t[45]!==z?(B=(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[F,z]}),t[44]=F,t[45]=z,t[46]=B):B=t[46];let V;t[47]!==w||t[48]!==f?(V=w&&f&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(oi,{paceInfo:w})}),t[47]=w,t[48]=f,t[49]=V):V=t[49];let H;return t[50]!==P||t[51]!==B||t[52]!==V?(H=(0,$.jsxs)(`div`,{className:`py-3`,children:[P,B,V]}),t[50]=P,t[51]=B,t[52]=V,t[53]=H):H=t[53],H};function Sd(e){return e.displayMode}function Cd(e){return e.showPredValues}function wd(e){return e.timeFormatPreference}var Td=(e,t)=>{if(!e)return`-`;try{return Hn(e,t,{fallback:`-`})}catch{return`-`}},Ed=()=>{let{t:e}=ke(),t=u(e=>e.timeFormatPreference),n=fi(e=>e.results),r=fi(e=>e.selectedProviderId),i=fi(e=>e.setSelectedProvider),a=fi(e=>e.loadSettings),o=fi(e=>e.fetchAllQuotas),s=fi(e=>e.isLoading),c=fi(e=>e.lastUpdated),l=fi(e=>e.error),d=fi(e=>e.dropdownProviderIds),f=fi(e=>e.setDropdownProviderIds),p=fi(e=>e.selectedModels),m=fi(e=>e.toggleModelSelected),h=fi(e=>e.applyDefaultSelections);Xr(),Q.useEffect(()=>{a(),o()},[a,o]),Q.useEffect(()=>{if(r||n.length===0)return;let e=n.find(e=>e.configured)?.providerId;i(e??wr[0]?.id??null)},[n,r,i]);let g=n.find(e=>e.providerId===r)??null,_=wr.find(e=>e.id===r)?.name??r??e(`settings.usage.sidebar.title`),v=g?.usage,y=r?d.includes(r):!1,b=Q.useCallback(e=>{if(!r)return;let t=e?Array.from(new Set([...d,r])):d.filter(e=>e!==r);f(t),V({usageDropdownProviders:t})},[d,r,f]),x=Q.useMemo(()=>v?.models?Object.entries(v.models).map(([e,t])=>({name:e,windows:t})).filter(e=>Object.keys(e.windows.windows).length>0):[],[v?.models]);Q.useEffect(()=>{r&&x.length>0&&h(r,x.map(e=>e.name))},[r,x,h]);let S=Q.useMemo(()=>!r||x.length===0?new Map:Hr(x,e=>e.name,r),[x,r]),C=Q.useMemo(()=>{if(!r)return[];let e=mi(r);return Dr(e)},[r]),[w,T]=Q.useState(()=>({})),E=Q.useCallback(e=>{T(t=>({...t,[e]:!t[e]}))},[]),D=Q.useCallback(e=>{if(!r)return;m(r,e);let t=p[r]??[],n=t.includes(e)?t.filter(t=>t!==e):[...t,e],i={...p,[r]:n};V({usageSelectedModels:i})},[r,p,m]),O=r?p[r]??[]:[];return r?(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(Zt,{providerId:r,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.usage.page.header.providerUsage`,{provider:_})}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s?(0,$.jsx)(`span`,{className:`animate-pulse`,children:e(`settings.usage.page.header.refreshing`)}):e(`settings.usage.page.header.lastUpdated`,{time:Td(c,t)})})]})]}),(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{"data-settings-item":`usage.header-menu`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>b(!y),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(!y))},children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.options.showInHeader`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.usage.page.options.showInHeaderTooltip`)})]})]})}),(0,$.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,$.jsx)(Qt,{checked:y,onChange:b,ariaLabel:e(`settings.usage.page.options.showInHeaderAria`)})})]})}),!g&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noData`)})}),l&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:l})]}),g?.configured&&!g.ok&&g.error&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:g.error})]}),g&&!g.configured&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-warning)]`,children:e(`settings.usage.page.state.providerNotConfiguredTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]/80 mt-1`,children:e(`settings.usage.page.state.providerNotConfiguredDescription`)})]}),v?.windows&&Object.keys(v.windows).length>0&&(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{"data-settings-item":`usage.model-quotas`,className:`oc-settings-group-row`,children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(v.windows).map(([e,t])=>(0,$.jsx)(xd,{title:e,window:t},e))})})}),x.length>0&&(0,$.jsxs)(Z,{label:e(`settings.usage.page.section.modelQuotas`),children:[C.map(e=>{let t=S.get(e.id)??[];if(t.length===0)return null;let n=w[e.id]??!1;return(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(Si,{open:!n,onOpenChange:()=>E(e.id),children:[(0,$.jsxs)(xi,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e.label}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(bi,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=O.includes(e.name);return(0,$.jsx)(xd,{title:n,subtitle:Qr(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})},e.id)}),(()=>{let t=S.get(null)??[];if(t.length===0)return null;let n=w.other??!1;return(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(Si,{open:!n,onOpenChange:()=>E(`other`),children:[(0,$.jsxs)(xi,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.usage.page.section.otherModels`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(bi,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=O.includes(e.name);return(0,$.jsx)(xd,{title:n,subtitle:Qr(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})})})()]}),g?.configured&&v&&Object.keys(v.windows??{}).length===0&&x.length===0&&(0,$.jsxs)(`div`,{className:`px-2`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noQuotaWindowsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground mt-1`,children:e(`settings.usage.page.state.noQuotaWindowsDescription`)})]})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.usage.page.empty.selectProvider`)})})},Dd=`git.commit.generate`,Od=fe(e=>({selectedPromptId:Dd,setSelectedPromptId:t=>{e(e=>e.selectedPromptId===t?e:{selectedPromptId:t})}})),kd=e=>{let t=(0,Ei.c)(22),{onItemSelect:n}=e,{t:r}=ke(),i=Od(Ad),a=Od(jd),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={groupKey:`settings.magicPrompts.sidebar.group.git`,items:[{id:`git.commit.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitCommitGenerate`},{id:`git.pr.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitPrGenerate`},{id:`git.conflict.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitConflictResolve`},{id:`git.integrate.cherrypick.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve`}]},t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={groupKey:`settings.magicPrompts.sidebar.group.github`,items:[{id:`github.pr.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrReview`},{id:`github.issue.review`,titleKey:`settings.magicPrompts.sidebar.item.githubIssueReview`},{id:`github.pr.checks.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrFailedChecksReview`},{id:`github.pr.comments.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrCommentsReview`},{id:`github.pr.comment.single`,titleKey:`settings.magicPrompts.sidebar.item.githubSinglePrCommentReview`}]},t[1]=s):s=t[1];let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=[o,s,{groupKey:`settings.magicPrompts.sidebar.group.session`,items:[{id:`session.explore`,titleKey:`settings.magicPrompts.sidebar.item.sessionExplore`},{id:`session.summary`,titleKey:`settings.magicPrompts.sidebar.item.sessionSummary`},{id:`session.review`,titleKey:`settings.magicPrompts.sidebar.item.sessionWorkspaceReview`},{id:`session.craftGoal`,titleKey:`settings.magicPrompts.sidebar.item.sessionCraftGoal`},{id:`session.catchup`,titleKey:`settings.magicPrompts.sidebar.item.sessionCatchUp`},{id:`session.debug`,titleKey:`settings.magicPrompts.sidebar.item.sessionDebug`},{id:`session.weigh`,titleKey:`settings.magicPrompts.sidebar.item.sessionWeigh`},{id:`session.fusion`,titleKey:`settings.magicPrompts.sidebar.item.sessionFusion`}]}],t[2]=c):c=t[2];let l=c,u;t[3]===r?u=t[4]:(u=r(`settings.magicPrompts.sidebar.title`),t[3]=r,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:u}),t[5]=u,t[6]=d);let f;t[7]===r?f=t[8]:(f=r(`settings.magicPrompts.sidebar.description`),t[7]=r,t[8]=f);let p;t[9]===f?p=t[10]:(p=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 px-2`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;t[14]!==n||t[15]!==i||t[16]!==a||t[17]!==r?(h=l.map(e=>(0,$.jsx)(Z,{label:r(e.groupKey),children:e.items.map(e=>{let t=i===e.id;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a(e.id),n?.()},className:q(`oc-settings-group-row flex w-full items-center text-left transition-colors`,t?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:(0,$.jsx)(`span`,{className:`typography-ui-label truncate font-normal`,children:r(e.titleKey)})},e.id)})},e.groupKey)),t[14]=n,t[15]=i,t[16]=a,t[17]=r,t[18]=h):h=t[18];let g;return t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[m,h]}),t[19]=m,t[20]=h,t[21]=g):g=t[21],g};function Ad(e){return e.selectedPromptId}function jd(e){return e.setSelectedPromptId}var Md={"git.commit.generate":{titleKey:`settings.magicPrompts.page.group.gitCommitGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitCommitGenerate.description`,blocks:[{id:`git.commit.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.commit.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.pr.generate":{titleKey:`settings.magicPrompts.page.group.gitPrGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitPrGenerate.description`,blocks:[{id:`git.pr.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.pr.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.review":{titleKey:`settings.magicPrompts.page.group.githubPrReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrReview.description`,blocks:[{id:`github.pr.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.issue.review":{titleKey:`settings.magicPrompts.page.group.githubIssueReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubIssueReview.description`,blocks:[{id:`github.issue.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.issue.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.checks.review":{titleKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.description`,blocks:[{id:`github.pr.checks.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.checks.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comments.review":{titleKey:`settings.magicPrompts.page.group.githubPrCommentsReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrCommentsReview.description`,blocks:[{id:`github.pr.comments.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comments.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comment.single":{titleKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.description`,blocks:[{id:`github.pr.comment.single.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comment.single.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.conflict.resolve":{titleKey:`settings.magicPrompts.page.group.gitConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitConflictResolve.description`,blocks:[{id:`git.conflict.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.conflict.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.integrate.cherrypick.resolve":{titleKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.description`,blocks:[{id:`git.integrate.cherrypick.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.integrate.cherrypick.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.summary":{titleKey:`settings.magicPrompts.page.group.sessionSummary.title`,descriptionKey:`settings.magicPrompts.page.group.sessionSummary.description`,blocks:[{id:`session.summary.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.summary.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.review":{titleKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.description`,blocks:[{id:`session.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.craftGoal":{titleKey:`settings.magicPrompts.page.group.sessionCraftGoal.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCraftGoal.description`,blocks:[{id:`session.craftGoal.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.craftGoal.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.catchup":{titleKey:`settings.magicPrompts.page.group.sessionCatchUp.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCatchUp.description`,blocks:[{id:`session.catchup.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.catchup.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.debug":{titleKey:`settings.magicPrompts.page.group.sessionDebug.title`,descriptionKey:`settings.magicPrompts.page.group.sessionDebug.description`,blocks:[{id:`session.debug.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.debug.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.weigh":{titleKey:`settings.magicPrompts.page.group.sessionWeigh.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWeigh.description`,blocks:[{id:`session.weigh.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.weigh.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.explore":{titleKey:`settings.magicPrompts.page.group.sessionExplore.title`,descriptionKey:`settings.magicPrompts.page.group.sessionExplore.description`,blocks:[{id:`session.explore.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.explore.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.fusion":{titleKey:`settings.magicPrompts.page.group.sessionFusion.title`,descriptionKey:`settings.magicPrompts.page.group.sessionFusion.description`,blocks:[{id:`session.fusion.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.fusion.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]}},Nd=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Pd=e=>e.endsWith(`.visible`),Fd=()=>{let{t:e}=ke(),t=Q.useCallback(t=>e(t),[e]),n=Od(e=>e.selectedPromptId),[r,i]=Q.useState(!0),[a,o]=Q.useState({}),[s,c]=Q.useState({}),[l,u]=Q.useState({}),[d,f]=Q.useState({}),[p,m]=Q.useState(!1);Q.useEffect(()=>{let t=!0;return(async()=>{i(!0);try{let e=await Le();if(!t)return;o(e)}catch(t){console.warn(`Failed to load magic prompts:`,t),K.error(e(`settings.magicPrompts.page.toast.loadFailed`))}finally{t&&i(!1)}})(),()=>{t=!1}},[e]);let h=Md[n]??Md[`git.commit.generate`],g=Q.useCallback(e=>Nd(a,e)?a[e]:Xe(e),[a]),_=Q.useCallback(e=>s[e]??g(e),[s,g]),v=Q.useCallback((e,t)=>{c(n=>n[e]===t?n:{...n,[e]:t})},[]),y=Q.useCallback(async t=>{let n=_(t);if(Pd(t)&&n.trim().length===0){K.error(e(`settings.magicPrompts.page.toast.visiblePromptRequired`));return}u(e=>({...e,[t]:!0}));try{let r=n===Xe(t)?await Ve(t):await Ke(t,n);o(r.overrides),K.success(e(`settings.magicPrompts.page.toast.saved`))}catch(t){let n=t instanceof Error?t.message:String(t);K.error(e(`settings.magicPrompts.page.toast.saveFailed`),{description:n})}finally{u(e=>({...e,[t]:!1}))}},[_,e]),b=Q.useCallback(async t=>{f(e=>({...e,[t]:!0}));try{let n=await Ve(t);o(n.overrides),c(e=>({...e,[t]:Xe(t)})),K.success(e(`settings.magicPrompts.page.toast.resetSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);K.error(e(`settings.magicPrompts.page.toast.resetFailed`),{description:n})}finally{f(e=>({...e,[t]:!1}))}},[e]),x=Q.useCallback(async()=>{m(!0);try{let t=await Ze();o(t.overrides),c({}),K.success(e(`settings.magicPrompts.page.toast.resetAllSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);K.error(e(`settings.magicPrompts.page.toast.resetAllFailed`),{description:n})}finally{m(!1)}},[e]);return r?(0,$.jsxs)(`div`,{className:`py-6 px-6 flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.magicPrompts.page.loading.aria`)}),(0,$.jsx)(`span`,{className:`typography-ui`,children:e(`settings.magicPrompts.page.loading.text`)})]}):(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-4xl px-6 py-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:t(h.titleKey)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:t(h.descriptionKey)})]})]})}),(0,$.jsx)(Y,{"data-settings-item":`magic-prompts.reset-overrides`,variant:`outline`,size:`sm`,onClick:()=>{x()},disabled:p||Object.keys(a).length===0,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetAllOverrides`)})]}),h.blocks.map(n=>{let r=Ue(n.id),i=g(n.id),o=_(n.id),s=Nd(a,n.id),c=o!==i,u=Pd(n.id)&&o.trim().length===0,f=l[n.id]===!0,p=d[n.id]===!0;return(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(n.titleKey)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:r.description})]})]}),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{"data-settings-item":Pd(n.id)?`magic-prompts.visible-prompt`:`magic-prompts.instructions`,className:`space-y-3`,children:[r.placeholders&&r.placeholders.length>0&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.magicPrompts.page.placeholdersLabel`),` `,r.placeholders.map(e=>`{{${e.key}}}`).join(`, `)]}),(0,$.jsx)(br,{embedded:!0,value:o,onChange:e=>v(n.id,e.target.value),className:`min-h-[220px] font-mono text-sm`}),u&&(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-error)]`,children:e(`settings.magicPrompts.page.validation.visiblePromptRequired`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(c?`settings.magicPrompts.page.status.unsavedChanges`:s?`settings.magicPrompts.page.status.usingSavedOverride`:`settings.magicPrompts.page.status.usingBuiltinDefault`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>{b(n.id)},disabled:!s||f||p,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetToDefault`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>{y(n.id)},disabled:!c||f||p||u,children:e(f?`settings.common.actions.saving`:`settings.magicPrompts.page.actions.save`)})]})]})]})},n.id)})]})})},Id=e=>{let t=(0,Ei.c)(71),{onItemSelect:n}=e,{t:r}=ke(),[i,a]=Q.useState(null),[o,s]=Q.useState(null),[c,l]=Q.useState(null),{selectedSnippetName:u,snippets:d,setSelectedSnippet:f,setSnippetDraft:p,deleteSnippet:m,loadSnippets:h}=sn(he(Ld)),g,_;t[0]===h?(g=t[1],_=t[2]):(g=()=>{h()},_=[h],t[0]=h,t[1]=g,t[2]=_),Q.useEffect(g,_);let v;t[3]!==n||t[4]!==f||t[5]!==p||t[6]!==d?(v=async()=>{let e=new Set(d.map(Rd)),t=`new-snippet`,r=1;for(;e.has(t);)t=`new-snippet-${r++}`;p({name:t,scope:`global`}),f(t),n?.()},t[3]=n,t[4]=f,t[5]=p,t[6]=d,t[7]=v):v=t[7];let y=v,b;t[8]!==i||t[9]!==m||t[10]!==r?(b=async()=>{i&&(await m(i.name)?(K.success(r(`settings.snippets.sidebar.toast.deleted`)),a(null)):K.error(r(`settings.snippets.sidebar.toast.deleteFailed`)))},t[8]=i,t[9]=m,t[10]=r,t[11]=b):b=t[11];let x=b,S;t[12]===d?S=t[13]:(S=[...d].sort(zd),t[12]=d,t[13]=S);let C=S,w;t[14]===r?w=t[15]:(w=r(`settings.snippets.sidebar.title`),t[14]=r,t[15]=w);let T;t[16]===w?T=t[17]:(T=(0,$.jsx)(`span`,{children:w}),t[16]=w,t[17]=T);let E;t[18]===r?E=t[19]:(E=r(`settings.snippets.sidebar.actions.create`),t[18]=r,t[19]=E);let D;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[20]=D):D=t[20];let O;t[21]!==y||t[22]!==E?(O=(0,$.jsx)(Y,{"data-settings-item":`snippets.create`,size:`icon`,variant:`ghost`,onClick:y,"aria-label":E,children:D}),t[21]=y,t[22]=E,t[23]=O):O=t[23];let k;t[24]!==O||t[25]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[T,O]}),t[24]=O,t[25]=T,t[26]=k):k=t[26];let A=k,j;t[27]!==n||t[28]!==o||t[29]!==c||t[30]!==u||t[31]!==f||t[32]!==A||t[33]!==C||t[34]!==r?(j=C.length>0?(0,$.jsx)(Z,{label:A,children:C.map(e=>(0,$.jsxs)(yi,{open:c===e.name,onOpenChange:t=>l(t?e.name:null),children:[(0,$.jsxs)(gi,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,u===e.name?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:t=>{t.preventDefault(),l(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{f(e.name),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`#`,e.name]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:r(`snippets.source.${e.source}`)})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:e.description||e.content.replace(/\s+/g,` `).substring(0,80)})]}),(0,$.jsxs)(Tn,{open:o===e.name,onOpenChange:t=>{t&&l(null),s(t?e.name:null)},children:[(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(Y,{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":r(`settings.snippets.sidebar.actions.more`,{name:e.name}),children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(mn,{align:`end`,className:`w-fit min-w-20`,children:(0,$.jsxs)(_n,{onClick:t=>{t.stopPropagation(),a(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]})})]})]}),(0,$.jsx)(_i,{className:`w-fit min-w-20`,children:(0,$.jsxs)(vi,{onClick:t=>{t.stopPropagation(),a(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]})})]},`${e.source}:${e.filePath}`))}):(0,$.jsx)(Z,{label:A,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[27]=n,t[28]=o,t[29]=c,t[30]=u,t[31]=f,t[32]=A,t[33]=C,t[34]=r,t[35]=j):j=t[35];let M=i!==null,N;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{e||a(null)},t[36]=N):N=t[36];let P;t[37]===r?P=t[38]:(P=r(`settings.snippets.sidebar.dialog.deleteTitle`),t[37]=r,t[38]=P);let F;t[39]===P?F=t[40]:(F=(0,$.jsx)(Kt,{children:P}),t[39]=P,t[40]=F);let I=i?.name??``,L;t[41]!==r||t[42]!==I?(L=r(`settings.snippets.sidebar.dialog.deleteDescription`,{name:I}),t[41]=r,t[42]=I,t[43]=L):L=t[43];let R;t[44]===L?R=t[45]:(R=(0,$.jsx)(qt,{children:L}),t[44]=L,t[45]=R);let z;t[46]!==F||t[47]!==R?(z=(0,$.jsxs)(Ut,{children:[F,R]}),t[46]=F,t[47]=R,t[48]=z):z=t[48];let B;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>a(null),t[49]=B):B=t[49];let V;t[50]===r?V=t[51]:(V=r(`settings.common.actions.cancel`),t[50]=r,t[51]=V);let H;t[52]===V?H=t[53]:(H=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:B,children:V}),t[52]=V,t[53]=H);let ee;t[54]===r?ee=t[55]:(ee=r(`settings.common.actions.delete`),t[54]=r,t[55]=ee);let U;t[56]!==x||t[57]!==ee?(U=(0,$.jsx)(Y,{size:`sm`,onClick:x,children:ee}),t[56]=x,t[57]=ee,t[58]=U):U=t[58];let te;t[59]!==H||t[60]!==U?(te=(0,$.jsxs)(Wt,{children:[H,U]}),t[59]=H,t[60]=U,t[61]=te):te=t[61];let W;t[62]!==z||t[63]!==te?(W=(0,$.jsxs)(Gt,{className:`max-w-md`,children:[z,te]}),t[62]=z,t[63]=te,t[64]=W):W=t[64];let ne;t[65]!==M||t[66]!==W?(ne=(0,$.jsx)(Jt,{open:M,onOpenChange:N,children:W}),t[65]=M,t[66]=W,t[67]=ne):ne=t[67];let re;return t[68]!==j||t[69]!==ne?(re=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[j,ne]}),t[68]=j,t[69]=ne,t[70]=re):re=t[70],re};function Ld(e){return{selectedSnippetName:e.selectedSnippetName,snippets:e.snippets,setSelectedSnippet:e.setSelectedSnippet,setSnippetDraft:e.setSnippetDraft,deleteSnippet:e.deleteSnippet,loadSnippets:e.loadSnippets}}function Rd(e){return e.name}function zd(e,t){return e.name.localeCompare(t.name)}var Bd=()=>{let{t:e}=ke(),{selectedSnippetName:t,snippets:n,snippetDraft:r,setSnippetDraft:i,updateSnippet:a,createSnippet:o}=sn(he(e=>({selectedSnippetName:e.selectedSnippetName,snippets:e.snippets,snippetDraft:e.snippetDraft,setSnippetDraft:e.setSnippetDraft,updateSnippet:e.updateSnippet,createSnippet:e.createSnippet}))),s=Q.useMemo(()=>t?n.find(e=>e.name===t||e.aliases.includes(t))??null:null,[t,n]),c=!!(r&&r.name===t&&!s),[l,u]=Q.useState(``),[d,f]=Q.useState(`global`),[p,m]=Q.useState(``),[h,g]=Q.useState(``),[_,v]=Q.useState(``),[y,b]=Q.useState(!1),x=Q.useRef(null);Q.useEffect(()=>{if(c&&r){let e={draftName:r.name||``,draftScope:r.scope||`global`,description:r.description||``,aliases:(r.aliases||[]).join(`, `),content:r.content||``};u(e.draftName),f(e.draftScope),m(e.description),g(e.aliases),v(e.content),x.current=e}else if(s){let e={draftName:``,draftScope:`global`,description:s.description??``,aliases:s.aliases.join(`, `),content:s.content};m(e.description),g(e.aliases),v(e.content),x.current=e}},[s,c,t,r]);let S=Q.useMemo(()=>{let e=x.current;return e?c&&l!==e.draftName||c&&d!==e.draftScope?!0:p!==e.description||h!==e.aliases||_!==e.content:!1},[h,_,p,l,d,c]);return t?(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:c?e(`settings.snippets.page.title.new`):`#${t}`}),s?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s.filePath}):null]}),(0,$.jsx)(Z,{cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[c?(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`#`}),(0,$.jsx)(ln,{value:l,onChange:e=>u(e.target.value),placeholder:e(`settings.snippets.page.field.namePlaceholder`),className:`h-7 w-44 px-2`}),(0,$.jsxs)(an,{value:d,onValueChange:e=>f(e),children:[(0,$.jsx)(tn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(cn,{})}),(0,$.jsxs)(nn,{align:`end`,children:[(0,$.jsx)($t,{value:`global`,children:e(`settings.common.scope.global`)}),(0,$.jsx)($t,{value:`project`,children:e(`settings.common.scope.project`)})]})]})]}):null,(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.common.field.description`)}),(0,$.jsx)(ln,{value:p,onChange:e=>m(e.target.value),placeholder:e(`settings.snippets.page.field.descriptionPlaceholder`),className:`mt-1.5 h-7 w-full max-w-sm px-2`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.snippets.page.field.aliases`)}),(0,$.jsx)(ln,{value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.snippets.page.field.aliasesPlaceholder`),className:`mt-1.5 h-7 w-full max-w-sm px-2`})]})]})}),(0,$.jsx)(`div`,{"data-settings-item":`snippets.content`,children:(0,$.jsx)(Z,{label:e(`settings.snippets.page.field.content`),description:e(`settings.snippets.page.hint`),cardClassName:`p-3`,children:(0,$.jsx)(br,{embedded:!0,value:_,onChange:e=>v(e.target.value),placeholder:e(`settings.snippets.page.field.contentPlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent`})})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Y,{onClick:async()=>{let n=c?l.trim().replace(/\s+/g,`-`):t?.trim();if(!n){K.error(e(`settings.snippets.page.toast.nameRequired`));return}if(!_.trim()){K.error(e(`settings.snippets.page.toast.contentRequired`));return}let r=h.split(`,`).map(e=>e.trim()).filter(Boolean);b(!0);try{if(!(c?await o(n,_,{aliases:r,description:p,scope:d}):await a(n,{content:_,aliases:r,description:p}))){K.error(e(`settings.snippets.page.toast.saveFailed`));return}K.success(e(`settings.snippets.page.toast.saved`)),c&&i(null)}finally{b(!1)}},disabled:y||!S,size:`xs`,className:`!font-normal`,children:e(y?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`file-text`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.snippets.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.snippets.page.empty.description`)})]})})},Vd=()=>{let{t:e}=ke(),t=G(e=>e.settingsGitmojiEnabled),n=G(e=>e.setSettingsGitmojiEnabled),r=g(),i=u(e=>e.gitChangesViewMode),a=u(e=>e.setGitChangesViewMode),[o,s]=Q.useState(!0),c=Q.useMemo(()=>[{id:`flat`,label:e(`settings.openchamber.git.option.flatList`)},{id:`tree`,label:e(`settings.openchamber.git.option.treeView`)}],[e]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=U()?.settings;if(t)try{let n=(await t.load())?.settings;n&&(e={gitmojiEnabled:typeof n.gitmojiEnabled==`boolean`?n.gitmojiEnabled:void 0,gitChangesViewMode:n.gitChangesViewMode===`flat`||n.gitChangesViewMode===`tree`?n.gitChangesViewMode:void 0})}catch{}}if(!e){let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}e&&(typeof e.gitmojiEnabled==`boolean`&&n(e.gitmojiEnabled),(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&a(e.gitChangesViewMode))}catch(e){console.warn(`Failed to load git settings:`,e)}finally{s(!1)}})()},[a,n]);let l=Q.useCallback(async e=>{n(e);try{await V({gitmojiEnabled:e})}catch(e){console.warn(`Failed to save gitmoji setting:`,e)}},[n]),d=Q.useCallback(e=>{e!==i&&(a(e),V({gitChangesViewMode:e}))},[i,a]);return o?null:(0,$.jsxs)(Z,{label:e(`settings.openchamber.git.title`),children:[(0,$.jsx)(Fr,{itemId:`git.changes-view`,label:e(`settings.openchamber.git.changesViewTitle`),controlClassName:`items-end`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.openchamber.git.changesViewAria`),className:`mt-0.5 space-y-0`,children:c.map(t=>{let n=i===t.id;return(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:()=>{d(t.id)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t.id))},className:`flex w-full items-center gap-2 py-0 text-left`,children:[(0,$.jsx)(Xn,{checked:n,onChange:()=>{d(t.id)},ariaLabel:e(`settings.openchamber.git.optionAria`,{option:t.label})}),(0,$.jsx)(`span`,{className:n?`typography-ui-label font-normal text-foreground`:`typography-ui-label font-normal text-foreground/50`,children:t.label})]},t.id)})})}),(0,$.jsxs)(`div`,{"data-settings-item":`git.gitmoji`,className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":t,onClick:()=>{l(!t)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(!t))},children:[(0,$.jsx)(Qt,{checked:t,onChange:e=>{l(e)},ariaLabel:e(`settings.openchamber.git.enableGitmojiAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.git.enableGitmoji`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`git.gitignored-files`,className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":r,onClick:()=>_(!r),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),_(!r))},children:[(0,$.jsx)(Qt,{checked:r,onChange:_,ariaLabel:e(`settings.openchamber.git.showGitignoredAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.git.showGitignored`)})]})]})},Hd=({itemId:e})=>{let{t}=ke(),{isMobile:n}=dr(),r=U()?.github,i=ar(),a=i.data??null,o=i.isLoading&&!i.data,s=i.isFetched,c=ci(e=>e.refreshStatus),l=ci(e=>e.setStatus),u=Q.useCallback(async e=>{await xr(e)},[]),[d,f]=Q.useState(!1),[p,m]=Q.useState(null),[h,g]=Q.useState(null),_=Q.useRef(null),v=Q.useRef(0),y=Q.useCallback(()=>{_.current!=null&&(window.clearTimeout(_.current),_.current=null),g(null)},[]);Q.useEffect(()=>((async()=>{try{s||await c(r)}catch(e){console.warn(`Failed to load GitHub auth status:`,e)}})(),()=>{y()}),[s,c,r,y]);let b=Q.useCallback(async()=>{f(!0);try{let e=r?await r.authStart():await(async()=>{let e=await L(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>null);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText);return t})();m(e),v.current=Date.now(),g(Math.max(1,e.interval)*1e3);let t=e.verificationUriComplete||e.verificationUri;u(t)}catch(e){console.error(`Failed to start GitHub connect:`,e),K.error(t(`settings.github.page.toast.startConnectFailed`))}finally{f(!1)}},[u,r,t]),x=Q.useCallback(async e=>{if(r)return r.authComplete(e);let t=await L(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n},[r]);Q.useEffect(()=>{if(!p?.deviceCode||!h||_.current!=null)return;let e=!1,n=v.current+p.expiresIn*1e3,i=async()=>{if(Date.now()>=n){K.error(t(`settings.github.page.toast.authorizationFailed`)),m(null),y();return}try{let n=await x(p.deviceCode);if(e)return;if(n.connected){K.success(t(`settings.github.page.toast.connected`)),m(null),y(),await c(r,{force:!0});return}if(n.status===`slow_down`){g(e=>e?e+5e3:5e3);return}if(n.status===`expired_token`||n.status===`access_denied`){K.error(n.error||t(`settings.github.page.toast.authorizationFailed`)),m(null),y();return}}catch(t){if(e)return;console.warn(`GitHub polling failed:`,t)}_.current=window.setTimeout(()=>void i(),h)};return _.current=window.setTimeout(()=>void i(),h),()=>{e=!0,_.current!=null&&(window.clearTimeout(_.current),_.current=null)}},[p,h,x,c,r,y,t]);let S=Q.useCallback(async e=>{f(!0);try{if(r)await r.authSetGhCliDisabled(e);else{let t=await L(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||t.statusText)}K.success(t(e?`settings.github.page.toast.ghCliDisabled`:`settings.github.page.toast.ghCliEnabled`)),await c(r,{force:!0})}catch(e){console.error(`Failed to update gh CLI setting:`,e),K.error(t(`settings.github.page.toast.ghCliUpdateFailed`))}finally{f(!1)}},[c,r,t]),C=Q.useCallback(async()=>{f(!0);try{if(y(),m(null),r)await r.authDisconnect();else{let e=await L(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText)}K.success(t(`settings.github.page.toast.disconnected`)),await c(r,{force:!0})}catch(e){console.error(`Failed to disconnect GitHub:`,e),K.error(t(`settings.github.page.toast.disconnectFailed`))}finally{f(!1)}},[c,r,y,t]),w=Q.useCallback(async e=>{if(e){f(!0);try{let n=r?await r.authActivate(e):await(async()=>{let t=await L(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();l(n),K.success(t(`settings.github.page.toast.accountSwitched`))}catch(e){console.error(`Failed to switch GitHub account:`,e),K.error(t(`settings.github.page.toast.accountSwitchFailed`))}finally{f(!1)}}},[r,l,t]);if(o)return null;if(i.isError&&!i.data)return(0,$.jsx)(`div`,{className:`oc-settings-group-description text-[var(--status-error)]`,children:i.error.message});let T=!!a?.connected,E=a?.user,D=(a?.accounts??[]).filter(e=>!e.current),O=a?.ghCli??null,k=O?.active?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(Z,{itemId:e,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(`settings.github.page.oauth.title`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:t(`settings.github.page.tooltip.connectAccount`)})]})]}),children:[(0,$.jsxs)(`div`,{className:`overflow-hidden flex flex-col`,children:[T?(0,$.jsxs)(`div`,{className:q(`px-4 py-3`,n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:q(`flex min-w-0 items-center gap-4`,n?`w-full`:void 0),children:[E?.avatarUrl?(0,$.jsx)(`img`,{src:E.avatarUrl,alt:E.login?t(`settings.github.page.avatarAlt.withLogin`,{login:E.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:E?.name?.trim()||E?.login||`GitHub`}),(0,$.jsxs)(`div`,{className:q(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:E?.login||t(`settings.github.page.label.unknownUser`)}),E?.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),E?.email&&(0,$.jsx)(`span`,{children:E.email}),(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),(0,$.jsx)(`span`,{children:k})]}),a?.scope&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.label.scopes`,{value:a.scope})}),O?.active&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.ghCli.activeDescription`)})]})]}),O?.active?(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>S(!0),disabled:d,className:q(n?`w-full`:void 0),children:t(`settings.github.page.ghCli.actions.disable`)}):(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:C,disabled:d,className:q(`text-[var(--status-error)] hover:text-[var(--status-error)]`,n?`w-full`:void 0),children:t(`settings.github.page.actions.disconnect`)})]}):(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-4 py-4`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.status.notConnected`)})}),(0,$.jsx)(Y,{size:`sm`,variant:`default`,onClick:b,disabled:d,children:t(`settings.github.page.actions.connect`)})]}),D.length>0&&(0,$.jsxs)(`div`,{className:`mt-2 border-t border-[var(--surface-subtle)] pt-2 px-2 pb-1`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-2 px-1`,children:t(`settings.github.page.label.otherAccounts`)}),(0,$.jsx)(`div`,{className:`space-y-1`,children:D.map(e=>{let n=e.user,r=e.source===`gh-cli`?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[n?.avatarUrl?(0,$.jsx)(`img`,{src:n.avatarUrl,alt:n.login?t(`settings.github.page.avatarAlt.withLogin`,{login:n.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-6 w-6 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(J,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n?.name?.trim()||n?.login||`GitHub`}),n?.login&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:n.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]})]})]}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>w(e.id),disabled:d,children:t(`settings.github.page.actions.switchTo`)})]},e.id)})})]})]}),T&&(0,$.jsx)(`div`,{className:`mt-2 px-2 pb-2`,children:(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:b,disabled:d,className:q(n?`w-full`:void 0),children:t(`settings.github.page.actions.addAccount`)})})]}),p&&(0,$.jsxs)(`div`,{className:`mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.flow.title`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.github.page.flow.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mt-4`,children:[(0,$.jsx)(`div`,{className:`font-mono text-xl tracking-widest text-foreground bg-[var(--surface-muted)] px-3 py-1.5 rounded-md border border-[var(--interactive-border)]`,children:p.userCode}),(0,$.jsx)(Y,{size:`sm`,asChild:!0,children:(0,$.jsx)(`a`,{href:p.verificationUriComplete||p.verificationUri,target:`_blank`,rel:`noopener noreferrer`,children:t(`settings.github.page.actions.openGithub`)})})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground animate-pulse`,children:t(`settings.github.page.flow.waiting`)}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:d,onClick:()=>{y(),m(null)},children:t(`settings.common.actions.cancel`)})]})]}),O?.available&&!O?.active&&(!O.user||O.disabled)&&(0,$.jsx)(Z,{label:t(`settings.github.page.ghCli.title`),children:(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:q(`px-4 py-3`,n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:q(`flex min-w-0 items-center gap-4`,n?`w-full`:void 0),children:[O.user?.avatarUrl?(0,$.jsx)(`img`,{src:O.user.avatarUrl,alt:O.user.login?t(`settings.github.page.avatarAlt.withLogin`,{login:O.user.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(J,{name:`github-fill`,className:`h-4 w-4 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[!O.disabled&&O.user&&(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground truncate`,children:O.user.name?.trim()||O.user.login||`GitHub`}),!O.disabled&&O.user?.login&&(0,$.jsxs)(`div`,{className:q(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:O.user.login}),O.user.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),O.user.email&&(0,$.jsx)(`span`,{children:O.user.email})]}),(0,$.jsx)(`div`,{className:q(`typography-meta text-muted-foreground`,O.disabled?`opacity-60`:void 0),children:O.disabled?t(`settings.github.page.ghCli.disabledDescription`):t(`settings.github.page.ghCli.fallbackDescription`)})]})]}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>S(!O.disabled),disabled:d,className:q(n?`w-full`:void 0),children:O.disabled?t(`settings.github.page.ghCli.actions.enable`):t(`settings.github.page.ghCli.actions.disable`)})]})})})]})},Ud=[{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)`}],Wd=[{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`}],Gd=({open:e,onOpenChange:t,profileId:n,importData:r})=>{let{t:i}=ke(),a=kr(e=>e.getProfileById),o=kr(e=>e.createProfile),s=kr(e=>e.updateProfile),c=kr(e=>e.deleteProfile),l=Q.useMemo(()=>n&&n!==`new`&&!r?a(n):null,[n,a,r]),u=n===`new`||r!=null,d=n===`global`,[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(`ssh`),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),[w,T]=Q.useState(``),[E,D]=Q.useState(``),[O,k]=Q.useState(`keyword`),[A,j]=Q.useState(`branch`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(e){if(r){let e=r.host.split(`/`),t=e.length>=3?e[e.length-1]:r.host;p(t),h(r.username),_(``),y(`token`),x(``),C(!1),T(``),D(r.host),k(`string`),j(`code`)}else if(u)p(``),h(``),_(``),y(`ssh`),x(``),C(!1),T(``),D(``),k(`keyword`),j(`branch`);else if(l)p(l.name),h(l.userName),_(l.userEmail),y(l.authType||`ssh`),x(l.sshKey||``),C(l.signCommits===!0),T(l.signingKey||``),D(l.host||``),k(l.color||`keyword`),j(l.icon||`branch`);else if(d){let e=a(`global`);e&&(p(e.name),h(e.userName),_(e.userEmail),y(e.authType||`ssh`),x(e.sshKey||``),C(!1),T(``),D(e.host||``),k(e.color||`keyword`),j(e.icon||`branch`))}}},[e,n,l,u,r,d,a]);let R=async()=>{if(!m.trim()||!g.trim()){K.error(i(`settings.gitIdentities.editor.toast.userNameEmailRequired`));return}if(v===`token`&&!E.trim()){K.error(i(`settings.gitIdentities.editor.toast.hostRequiredForToken`));return}if(S&&!w.trim()){K.error(i(`settings.gitIdentities.editor.toast.signingKeyRequired`));return}N(!0);try{let e={name:f.trim()||m.trim(),userName:m.trim(),userEmail:g.trim(),authType:v,sshKey:v===`ssh`&&b.trim()||null,signCommits:S,signingKey:w.trim()||null,host:v===`token`&&E.trim()||null,color:O,icon:A},r;if(u)r=await o(e);else if(n)r=await s(n,e);else return;r?(K.success(i(u?`settings.gitIdentities.editor.toast.profileCreated`:`settings.gitIdentities.editor.toast.profileUpdated`)),t(!1)):K.error(i(u?`settings.gitIdentities.editor.toast.createProfileFailed`:`settings.gitIdentities.editor.toast.updateProfileFailed`))}catch(e){console.error(`Error saving profile:`,e),K.error(i(`settings.gitIdentities.editor.toast.saveUnexpectedError`))}finally{N(!1)}},z=async()=>{if(!(!n||u)){L(!0);try{await c(n)?(K.success(i(`settings.gitIdentities.editor.toast.profileDeleted`)),F(!1),t(!1)):K.error(i(`settings.gitIdentities.editor.toast.deleteProfileFailed`))}catch(e){console.error(`Error deleting profile:`,e),K.error(i(`settings.gitIdentities.editor.toast.deleteUnexpectedError`))}finally{L(!1)}}},B=Q.useMemo(()=>Ud.find(e=>e.key===O)?.cssVar||`var(--syntax-keyword)`,[O]),V=r?i(`settings.gitIdentities.editor.title.importCredential`):u?i(`settings.gitIdentities.editor.title.newIdentity`):d?i(`settings.gitIdentities.editor.title.globalIdentity`):l?.name||i(`settings.gitIdentities.editor.title.editIdentity`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jt,{open:e,onOpenChange:t,children:(0,$.jsxs)(Gt,{className:`max-w-lg max-h-[85vh] overflow-y-auto`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:V}),(0,$.jsx)(qt,{children:i(d?`settings.gitIdentities.editor.description.globalReadOnly`:u?`settings.gitIdentities.editor.description.newProfile`:`settings.gitIdentities.editor.description.editProfile`)})]}),(0,$.jsxs)(`div`,{className:`space-y-5 py-2`,children:[!d&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground block mb-1.5`,children:i(`settings.gitIdentities.editor.field.profileName`)}),(0,$.jsx)(ln,{value:f,onChange:e=>p(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.profileNamePlaceholder`),className:`h-8`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.color`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:Ud.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>k(e.key),className:q(`w-6 h-6 rounded-md border-2 transition-all cursor-pointer`,O===e.key?`border-foreground scale-110`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar},title:e.label},e.key))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.icon`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:Wd.map(e=>{let t=e.Icon;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(e.key),className:q(`w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer`,A===e.key?`border-[var(--interactive-border)] bg-[var(--surface-muted)]`:`border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50`),title:e.label,children:(0,$.jsx)(J,{name:t,className:`w-3.5 h-3.5`,style:{color:A===e.key?B:`var(--surface-muted-foreground)`}})},e.key)})})]})]}),!d&&(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.userName`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.userNameTooltip`)})]})]}),(0,$.jsx)(ln,{value:m,onChange:e=>h(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.userNamePlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.emailAddress`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.emailAddressTooltip`)})]})]}),(0,$.jsx)(ln,{type:`email`,value:g,onChange:e=>_(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.emailAddressPlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]})]}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.authMethod`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(Y,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`ssh`,onClick:()=>y(`ssh`),children:[(0,$.jsx)(J,{name:`lock-2`,className:`w-3.5 h-3.5 mr-1`}),` SSH`]}),(0,$.jsxs)(Y,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`token`,onClick:()=>y(`token`),children:[(0,$.jsx)(J,{name:`key`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.gitIdentities.editor.field.authToken`)]})]})]}),v===`ssh`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.sshKeyPath`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.sshKeyPathTooltip`)})]})]}),(0,$.jsx)(ln,{value:b,onChange:e=>x(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.sshKeyPathPlaceholder`),className:`h-8 font-mono text-xs`})]}),(0,$.jsxs)(`div`,{className:`border-t border-border/40 pt-3 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(Qt,{checked:S,onChange:C,ariaLabel:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:i(`settings.gitIdentities.editor.section.commitSigning`)})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signingKey`)})}),(0,$.jsx)(ln,{value:w,onChange:e=>T(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.signingKeyPlaceholder`),disabled:!S,className:`h-8 font-mono text-xs`})]})]}),v===`token`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.host`)}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.hostTooltip`)})]})]}),(0,$.jsx)(ln,{value:E,onChange:e=>D(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.hostPlaceholder`),required:!0,className:`h-8 font-mono text-xs`})]})]})]})]}),(0,$.jsxs)(Wt,{className:`gap-2`,children:[!d&&!u&&(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>F(!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:[(0,$.jsx)(J,{name:`delete-bin`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.common.actions.delete`)]}),(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,children:i(d?`settings.gitIdentities.editor.actions.close`:`settings.common.actions.cancel`)}),!d&&(0,$.jsx)(Y,{size:`sm`,onClick:R,disabled:M,children:i(M?`settings.common.actions.saving`:u?`settings.gitIdentities.editor.actions.create`:`settings.gitIdentities.editor.actions.save`)})]})]})}),(0,$.jsx)(Jt,{open:P,onOpenChange:e=>{I||F(e)},children:(0,$.jsxs)(Gt,{className:`max-w-md`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:i(`settings.gitIdentities.page.deleteDialog.title`)}),(0,$.jsx)(qt,{children:i(`settings.gitIdentities.page.deleteDialog.description`,{name:l?.name||f})})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>F(!1),disabled:I,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>void z(),disabled:I,children:i(`settings.common.actions.delete`)})]})]})})]})},Kd={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`},qd={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`},Jd=()=>{let e=(0,Ei.c)(116),{t}=ke(),{profiles:n,globalIdentity:r,defaultGitIdentityId:i,deleteProfile:a,loadProfiles:o,loadGlobalIdentity:s,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:l,setDefaultGitIdentityId:u,getUnimportedCredentials:d}=kr(he(Zd)),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S,C;e[0]!==l||e[1]!==c||e[2]!==s||e[3]!==o?(S=()=>{o(),s(),c(),l()},C=[o,s,c,l],e[0]=l,e[1]=c,e[2]=s,e[3]=o,e[4]=S,e[5]=C):(S=e[4],C=e[5]),Q.useEffect(S,C);let w,T,E,D,O,k,A,j,M,N,P,F,I,L;if(e[6]!==i||e[7]!==v||e[8]!==a||e[9]!==d||e[10]!==r||e[11]!==n||e[12]!==u||e[13]!==t){let o=d(),s;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{h(e),_(t??null),p(!0)},e[28]=s):s=e[28];let c=s,l;e[29]!==i||e[30]!==u||e[31]!==t?(l=async e=>{let n=i===e?null:e;if(!await u(n)){K.error(t(`settings.gitIdentities.page.toast.updateDefaultFailed`));return}K.success(t(n?`settings.gitIdentities.page.toast.defaultUpdated`:`settings.gitIdentities.page.toast.defaultUnset`))},e[29]=i,e[30]=u,e[31]=t,e[32]=l):l=e[32];let f=l,m;e[33]!==v||e[34]!==a||e[35]!==t?(m=async()=>{v&&(x(!0),await a(v.id)?(K.success(t(`settings.gitIdentities.page.toast.profileDeleted`,{name:v.name})),y(null)):K.error(t(`settings.gitIdentities.page.toast.deleteProfileFailed`)),x(!1))},e[33]=v,e[34]=a,e[35]=t,e[36]=m):m=e[36],E=m,T=yr,O=`h-full`,k=`w-full bg-background`,L=`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,e[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(Hd,{itemId:`git.github-account`}),e[37]=D):D=e[37],w=Z,A=`git.identities`;let g;e[38]===t?g=e[39]:(g=t(`settings.gitIdentities.page.section.title`),e[38]=t,e[39]=g);let b;e[40]===g?b=e[41]:(b=(0,$.jsx)(`span`,{children:g}),e[40]=g,e[41]=b);let S,C;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>c(`new`),C=(0,$.jsx)(J,{name:`add`,className:`mr-1 size-3.5`}),e[42]=S,e[43]=C):(S=e[42],C=e[43]);let R;e[44]===t?R=e[45]:(R=t(`settings.common.badge.new`),e[44]=t,e[45]=R);let z;e[46]===R?z=e[47]:(z=(0,$.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:S,children:[C,` `,R]}),e[46]=R,e[47]=z),e[48]!==b||e[49]!==z?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[b,z]}),e[48]=b,e[49]=z,e[50]=j):j=e[50],M=`flex flex-col`,N=r&&(0,$.jsx)(Yd,{profile:r,isDefault:i===`global`,onEdit:()=>c(`global`),onToggleDefault:()=>f(`global`),isReadOnly:!0,hasBorder:n.length>0||o.length>0}),P=n.map((e,t)=>(0,$.jsx)(Yd,{profile:e,isDefault:i===e.id,onEdit:()=>c(e.id),onToggleDefault:()=>f(e.id),onDelete:()=>y(e),hasBorder:t<n.length-1||o.length>0},e.id)),F=!r&&n.length===0&&o.length===0&&(0,$.jsxs)(`div`,{className:`py-8 px-4 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`shield-keyhole`,className:`mx-auto mb-2 h-8 w-8 opacity-40`}),(0,$.jsx)(`p`,{className:`typography-ui-label`,children:t(`settings.gitIdentities.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.gitIdentities.page.empty.description`)})]}),I=o.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`px-4 py-2 border-t border-[var(--surface-subtle)]`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:t(`settings.gitIdentities.page.discoveredCredentials.title`)})}),o.map((e,t)=>(0,$.jsx)(Xd,{credential:e,onImport:()=>c(`new`,{host:e.host,username:e.username}),hasBorder:t<o.length-1},`${e.host}-${e.username}`))]}),e[6]=i,e[7]=v,e[8]=a,e[9]=d,e[10]=r,e[11]=n,e[12]=u,e[13]=t,e[14]=w,e[15]=T,e[16]=E,e[17]=D,e[18]=O,e[19]=k,e[20]=A,e[21]=j,e[22]=M,e[23]=N,e[24]=P,e[25]=F,e[26]=I,e[27]=L}else w=e[14],T=e[15],E=e[16],D=e[17],O=e[18],k=e[19],A=e[20],j=e[21],M=e[22],N=e[23],P=e[24],F=e[25],I=e[26],L=e[27];let R;e[51]!==w||e[52]!==A||e[53]!==j||e[54]!==M||e[55]!==N||e[56]!==P||e[57]!==F||e[58]!==I?(R=(0,$.jsxs)(w,{itemId:A,label:j,cardClassName:M,children:[N,P,F,I]}),e[51]=w,e[52]=A,e[53]=j,e[54]=M,e[55]=N,e[56]=P,e[57]=F,e[58]=I,e[59]=R):R=e[59];let z;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Vd,{}),e[60]=z):z=e[60];let B;e[61]!==D||e[62]!==R||e[63]!==L?(B=(0,$.jsxs)(`div`,{className:L,children:[D,R,z]}),e[61]=D,e[62]=R,e[63]=L,e[64]=B):B=e[64];let V;e[65]!==T||e[66]!==O||e[67]!==k||e[68]!==B?(V=(0,$.jsx)(T,{outerClassName:O,className:k,children:B}),e[65]=T,e[66]=O,e[67]=k,e[68]=B,e[69]=V):V=e[69];let H;e[70]!==g||e[71]!==f||e[72]!==m?(H=(0,$.jsx)(Gd,{open:f,onOpenChange:p,profileId:m,importData:g}),e[70]=g,e[71]=f,e[72]=m,e[73]=H):H=e[73];let ee=v!==null,U;e[74]===b?U=e[75]:(U=e=>{b||e||y(null)},e[74]=b,e[75]=U);let te;e[76]===t?te=e[77]:(te=t(`settings.gitIdentities.page.deleteDialog.title`),e[76]=t,e[77]=te);let W;e[78]===te?W=e[79]:(W=(0,$.jsx)(Kt,{children:te}),e[78]=te,e[79]=W);let ne=v?.name??``,re;e[80]!==t||e[81]!==ne?(re=t(`settings.gitIdentities.page.deleteDialog.description`,{name:ne}),e[80]=t,e[81]=ne,e[82]=re):re=e[82];let ie;e[83]===re?ie=e[84]:(ie=(0,$.jsx)(qt,{children:re}),e[83]=re,e[84]=ie);let ae;e[85]!==W||e[86]!==ie?(ae=(0,$.jsxs)(Ut,{children:[W,ie]}),e[85]=W,e[86]=ie,e[87]=ae):ae=e[87];let oe;e[88]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>y(null),e[88]=oe):oe=e[88];let se;e[89]===t?se=e[90]:(se=t(`settings.common.actions.cancel`),e[89]=t,e[90]=se);let ce;e[91]!==b||e[92]!==se?(ce=(0,$.jsx)(Y,{variant:`ghost`,onClick:oe,disabled:b,children:se}),e[91]=b,e[92]=se,e[93]=ce):ce=e[93];let le;e[94]===E?le=e[95]:(le=()=>void E(),e[94]=E,e[95]=le);let ue;e[96]===t?ue=e[97]:(ue=t(`settings.common.actions.delete`),e[96]=t,e[97]=ue);let de;e[98]!==b||e[99]!==le||e[100]!==ue?(de=(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:le,disabled:b,children:ue}),e[98]=b,e[99]=le,e[100]=ue,e[101]=de):de=e[101];let fe;e[102]!==ce||e[103]!==de?(fe=(0,$.jsxs)(Wt,{children:[ce,de]}),e[102]=ce,e[103]=de,e[104]=fe):fe=e[104];let pe;e[105]!==ae||e[106]!==fe?(pe=(0,$.jsxs)(Gt,{className:`max-w-md`,children:[ae,fe]}),e[105]=ae,e[106]=fe,e[107]=pe):pe=e[107];let me;e[108]!==ee||e[109]!==U||e[110]!==pe?(me=(0,$.jsx)(Jt,{open:ee,onOpenChange:U,children:pe}),e[108]=ee,e[109]=U,e[110]=pe,e[111]=me):me=e[111];let ge;return e[112]!==V||e[113]!==H||e[114]!==me?(ge=(0,$.jsxs)($.Fragment,{children:[V,H,me]}),e[112]=V,e[113]=H,e[114]=me,e[115]=ge):ge=e[115],ge},Yd=e=>{let t=(0,Ei.c)(56),{profile:n,isDefault:r,onEdit:i,onToggleDefault:a,onDelete:o,isReadOnly:s,hasBorder:c}=e,{t:l}=ke(),[u,d]=Q.useState(!1),f=Kd[n.icon||`branch`]||`git-branch`,p=qd[n.color||``],m=n.authType||`ssh`,h;t[0]===i?h=t[1]:(h=e=>{e.currentTarget===e.target&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},t[0]=i,t[1]=h);let g=h,_;t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a||t[6]!==l?(_=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:e=>{e.stopPropagation(),a()},children:l(r?`settings.gitIdentities.page.actions.unsetDefault`:`settings.gitIdentities.page.actions.setAsDefault`)}),!s&&o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),l(`settings.common.actions.delete`)]})]}),t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=_):_=t[7];let v=_,y=c&&`border-b border-[var(--surface-subtle)]`,b;t[8]===y?b=t[9]:(b=q(`group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer`,y),t[8]=y,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),d(!0)},t[10]=x):x=t[10];let S;t[11]!==g||t[12]!==i||t[13]!==b?(S=(0,$.jsx)(`div`,{className:b,onClick:i,role:`button`,tabIndex:0,onKeyDown:g,onContextMenu:x}),t[11]=g,t[12]=i,t[13]=b,t[14]=S):S=t[14];let C;t[15]===p?C=t[16]:(C={color:p},t[15]=p,t[16]=C);let w;t[17]!==f||t[18]!==C?(w=(0,$.jsx)(J,{name:f,className:`w-4 h-4 shrink-0`,style:C}),t[17]=f,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.name?T=t[21]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n.name}),t[20]=n.name,t[21]=T);let E;t[22]===m?E=t[23]:(E=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:m}),t[22]=m,t[23]=E);let D;t[24]!==r||t[25]!==l?(D=r&&(0,$.jsx)(`span`,{className:`typography-micro text-primary bg-primary/12 px-1 rounded flex-shrink-0 leading-none pb-px border border-primary/25`,children:l(`settings.gitIdentities.page.badge.default`)}),t[24]=r,t[25]=l,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==l?(O=s&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:l(`settings.agents.sidebar.badge.system`)}),t[27]=s,t[28]=l,t[29]=O):O=t[29];let k;t[30]!==E||t[31]!==D||t[32]!==O||t[33]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D,O]}),t[30]=E,t[31]=D,t[32]=O,t[33]=T,t[34]=k):k=t[34];let A=m===`token`&&n.host?n.host:n.userEmail,j;t[35]===A?j=t[36]:(j=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:A}),t[35]=A,t[36]=j);let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==M||t[41]!==w?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[w,M]}),t[40]=M,t[41]=w,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,onClick:Qd,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[43]=P):P=t[43];let F;t[44]===v?F=t[45]:(F=(0,$.jsxs)(Tn,{children:[P,(0,$.jsx)(mn,{align:`end`,className:`w-fit min-w-28`,children:v(_n)})]}),t[44]=v,t[45]=F);let I;t[46]!==N||t[47]!==F||t[48]!==S?(I=(0,$.jsxs)(gi,{render:S,children:[N,F]}),t[46]=N,t[47]=F,t[48]=S,t[49]=I):I=t[49];let L;t[50]===v?L=t[51]:(L=(0,$.jsx)(_i,{className:`w-fit min-w-28`,children:v(vi)}),t[50]=v,t[51]=L);let R;return t[52]!==u||t[53]!==I||t[54]!==L?(R=(0,$.jsxs)(yi,{open:u,onOpenChange:d,children:[I,L]}),t[52]=u,t[53]=I,t[54]=L,t[55]=R):R=t[55],R},Xd=e=>{let t=(0,Ei.c)(21),{credential:n,onImport:r,hasBorder:i}=e,{t:a}=ke(),o;t[0]===n.host?o=t[1]:(o=n.host.split(`/`),t[0]=n.host,t[1]=o);let s=o,c=s.length>=3?s[s.length-1]:n.host,l=n.host.includes(`/`),u=i&&`border-b border-[var(--surface-subtle)]`,d;t[2]===u?d=t[3]:(d=q(`flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30`,u),t[2]=u,t[3]=d);let f;t[4]===c?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate block`,children:c}),t[4]=c,t[5]=f);let p=l?n.host:n.username,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 truncate block leading-tight`,children:p}),t[6]=p,t[7]=m);let h;t[8]!==f||t[9]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(J,{name:`download`,className:`h-3 w-3`}),t[11]=g):g=t[11];let _;t[12]===a?_=t[13]:(_=a(`settings.gitIdentities.page.actions.import`),t[12]=a,t[13]=_);let v;t[14]!==r||t[15]!==_?(v=(0,$.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:r,className:`gap-1 shrink-0`,children:[g,_]}),t[14]=r,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==d||t[19]!==h?(y=(0,$.jsxs)(`div`,{className:d,children:[h,v]}),t[17]=v,t[18]=d,t[19]=h,t[20]=y):y=t[20],y};function Zd(e){return{profiles:e.profiles,globalIdentity:e.globalIdentity,defaultGitIdentityId:e.defaultGitIdentityId,deleteProfile:e.deleteProfile,loadProfiles:e.loadProfiles,loadGlobalIdentity:e.loadGlobalIdentity,loadDiscoveredCredentials:e.loadDiscoveredCredentials,loadDefaultGitIdentityId:e.loadDefaultGitIdentityId,setDefaultGitIdentityId:e.setDefaultGitIdentityId,getUnimportedCredentials:e.getUnimportedCredentials}}function Qd(e){return e.stopPropagation()}var $d=e=>{let t=(0,Ei.c)(12),{isMobile:n,itemId:r,label:i,description:a,descriptionPlacement:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&`oc-mobile-settings-detail-group`,f;t[0]===d?f=t[1]:(f=q(`oc-settings-detail-group`,d),t[0]=d,t[1]=f);let p;return t[2]!==s||t[3]!==c||t[4]!==u||t[5]!==l||t[6]!==a||t[7]!==o||t[8]!==r||t[9]!==i||t[10]!==f?(p=(0,$.jsx)(Ar,{itemId:r,label:i,description:a,descriptionPlacement:o,groupClassName:f,className:c,copyClassName:l,controlClassName:u,children:s}),t[2]=s,t[3]=c,t[4]=u,t[5]=l,t[6]=a,t[7]=o,t[8]=r,t[9]=i,t[10]=f,t[11]=p):p=t[11],p},ef=e=>{let t=(0,Ei.c)(9),{isMobile:n,label:r,children:i,description:a,className:o,cardClassName:s}=e,c=n&&`oc-mobile-settings-detail-group`,l;t[0]!==o||t[1]!==c?(l=q(`oc-settings-detail-group`,c,o),t[0]=o,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==s||t[4]!==i||t[5]!==a||t[6]!==r||t[7]!==l?(u=(0,$.jsx)(Z,{label:r,description:a,className:l,cardClassName:s,children:i}),t[3]=s,t[4]=i,t[5]=a,t[6]=r,t[7]=l,t[8]=u):u=t[8],u},tf=e=>{let t=(0,Ei.c)(8),{isMobile:n,itemId:r,label:i,mobileLabel:a,description:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&a!==void 0?a:i,f;return t[0]!==s||t[1]!==c||t[2]!==u||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==d?(f=(0,$.jsx)(Fr,{itemId:r,label:d,description:o,className:c,copyClassName:l,controlClassName:u,children:s}),t[0]=s,t[1]=c,t[2]=u,t[3]=l,t[4]=o,t[5]=r,t[6]=d,t[7]=f):f=t[7],f},nf=e=>{let t=(0,Ei.c)(17),{selected:n,onSelect:r,label:i,ariaLabel:a}=e,o;t[0]===r?o=t[1]:(o=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),r())},t[0]=r,t[1]=o);let s;t[2]!==a||t[3]!==r||t[4]!==n?(s=(0,$.jsx)(Xn,{checked:n,onChange:r,ariaLabel:a}),t[2]=a,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c=n?`text-foreground`:`text-foreground/50`,l;t[6]===c?l=t[7]:(l=q(`typography-ui-label font-normal`,c),t[6]=c,t[7]=l);let u;t[8]!==i||t[9]!==l?(u=(0,$.jsx)(`span`,{className:l,children:i}),t[8]=i,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==s||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-settings-group-row group flex cursor-pointer items-center gap-2 text-left`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:r,onKeyDown:o,children:[s,u]}),t[11]=r,t[12]=n,t[13]=o,t[14]=s,t[15]=u,t[16]=d):d=t[16],d},rf=[{value:`system`,labelKey:`settings.openchamber.visual.option.themeMode.system`},{value:`light`,labelKey:`settings.openchamber.visual.option.themeMode.light`},{value:`dark`,labelKey:`settings.openchamber.visual.option.themeMode.dark`}],af=[{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`}],of=[{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`}],sf=`OpenChamber - AI Coding Assistant`,cf=[{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`}],lf=[{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`}],uf=e=>e===`portrait`||e===`landscape`?e:`system`,df=[{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`}],ff=[{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`}],pf=[{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`}],mf=[{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`}],hf=[{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`}],gf=[{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`}],_f=[{id:`steer`,labelKey:`settings.openchamber.visual.option.followUpBehavior.steer.label`},{id:`queue`,labelKey:`settings.openchamber.visual.option.followUpBehavior.queue.label`}],vf=e=>e===`markdown`?`markdown`:`plain`,yf=({visibleSettings:e,mobile:t})=>{let{locale:n,locales:r,setLocale:i,label:a,t:s}=ke(),d=Q.useCallback(e=>s(e),[s]),{isMobile:p}=dr(),h=t??p,{browserTab:g}=ti(),_=I(),v=u(e=>e.showReasoningTraces),y=u(e=>e.sessionTitleRefreshEnabled),S=u(e=>e.setSessionTitleRefreshEnabled),C=u(e=>e.sessionGoalEnabled),T=u(e=>e.setSessionGoalEnabled),E=u(e=>e.sessionGoalDefaultBudgetEnabled),D=u(e=>e.setSessionGoalDefaultBudgetEnabled),O=u(e=>e.sessionGoalDefaultBudget),k=u(e=>e.setSessionGoalDefaultBudget),j=u(e=>e.setShowReasoningTraces),M=u(e=>e.collapsibleThinkingBlocks),N=u(e=>e.setCollapsibleThinkingBlocks),P=u(e=>e.mermaidRenderingMode),F=u(e=>e.setMermaidRenderingMode),R=u(e=>e.userMessageRenderingMode),z=u(e=>e.setUserMessageRenderingMode),H=u(e=>e.collapsibleUserMessages),ee=u(e=>e.setCollapsibleUserMessages),U=u(e=>e.stickyUserHeader),te=u(e=>e.promptNavigatorEnabled),W=u(e=>e.setStickyUserHeader),ne=u(e=>e.setPromptNavigatorEnabled),re=u(e=>e.expandedEditorToolbar),ie=u(e=>e.setExpandedEditorToolbar),ae=hr(e=>e.enabled),oe=hr(e=>e.setEnabled),se=u(e=>e.wideChatLayoutEnabled),ce=u(e=>e.setWideChatLayoutEnabled),le=u(e=>e.codeBlockLineWrap),ue=u(e=>e.setCodeBlockLineWrap),de=u(e=>e.chatRenderMode),fe=u(e=>e.setChatRenderMode),pe=u(e=>e.activityRenderMode),me=u(e=>e.setActivityRenderMode),he=u(e=>e.fontSize),ge=u(e=>e.setFontSize),_e=u(e=>e.codeFontSize),ve=u(e=>e.setCodeFontSize),ye=u(e=>e.terminalFontSize),be=u(e=>e.setTerminalFontSize),xe=u(e=>e.editorFontSize),Se=u(e=>e.setEditorFontSize),Ce=u(e=>e.uiFont),we=u(e=>e.setUiFont),Te=u(e=>e.monoFont),Ee=u(e=>e.setMonoFont),De=u(e=>e.padding),Oe=u(e=>e.setPadding),Ae=u(e=>e.inputBarOffset),je=u(e=>e.setInputBarOffset),Me=u(e=>e.mobileKeyboardMode),Ne=u(e=>e.setMobileKeyboardMode),Pe=u(e=>e.diffLayoutPreference),Fe=u(e=>e.setDiffLayoutPreference),Ie=u(e=>e.showTerminalQuickKeysOnDesktop),Le=u(e=>e.setShowTerminalQuickKeysOnDesktop),Re=u(e=>e.fileEditorKeymap),ze=u(e=>e.setFileEditorKeymap),Be=x(e=>e.followUpBehavior),Ve=x(e=>e.setFollowUpBehavior),He=u(e=>e.persistChatDraft),Ue=u(e=>e.setPersistChatDraft),We=u(e=>e.inputSpellcheckEnabled),Ge=u(e=>e.setInputSpellcheckEnabled),Ke=u(e=>e.showToolFileIcons),qe=u(e=>e.setShowToolFileIcons),Je=u(e=>e.showTurnChangedFiles),Ye=u(e=>e.setShowTurnChangedFiles),Xe=u(e=>e.showExpandedBashTools),Ze=u(e=>e.setShowExpandedBashTools),Qe=u(e=>e.showSubagentTaskDetails),$e=u(e=>e.setShowSubagentTaskDetails),et=u(e=>e.timeFormatPreference),tt=u(e=>e.setTimeFormatPreference),rt=u(e=>e.weekStartPreference),it=u(e=>e.setWeekStartPreference),at=u(e=>e.showSplitAssistantMessageActions),ot=u(e=>e.setShowSplitAssistantMessageActions),st=u(e=>e.showAssistantTps),ct=u(e=>e.setShowAssistantTps),lt=ei(e=>e.sidebarBrandName),ut=ei(e=>e.setSidebarBrandName),dt=u(e=>e.allowPromptingSubagentSessions),ft=u(e=>e.setAllowPromptingSubagentSessions),pt=G(e=>e.settingsMessageStreamTransport),mt=G(e=>e.setSettingsMessageStreamTransport),ht=pt,gt=G(e=>e.settingsDefaultFileViewerPreview),_t=G(e=>e.setSettingsDefaultFileViewerPreview),vt=u(e=>e.isSettingsDialogOpen),{themeMode:yt,setThemeMode:bt,availableThemes:xt,customThemesLoading:St,reloadCustomThemes:Ct,lightThemeId:wt,darkThemeId:Tt,setLightThemePreference:Et,setDarkThemePreference:Dt}=ur(),[Ot,kt]=Q.useState(!1),[At,jt]=Q.useState(!1),[Mt,Nt]=Q.useState(!1),Pt=Q.useMemo(()=>w()&&typeof window<`u`&&window.__OPENCHAMBER_ELECTRON__?.macVibrancySupported===!0,[]),Ft=typeof window<`u`&&window.__OPENCHAMBER_ELECTRON__?.macVibrancy===!0,[It,Lt]=Q.useState(Ft),[Rt,zt]=Q.useState(!1),Bt=Q.useMemo(()=>w()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`darwin`,[]),Vt=u(e=>e.dockBadgeEnabled),Ht=u(e=>e.setDockBadgeEnabled),[Yt,Xt]=Q.useState(0),Zt=u(e=>e.reportUsage),en=u(e=>e.setReportUsage),rn=Q.useCallback(e=>{en(e),V({reportUsage:e})},[en]),on=vt&&(!e||e.includes(`chatRenderMode`));Q.useEffect(()=>{if(!on)return;let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=420&&(Xt(e=>(e+1)%24),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[on]);let sn=Q.useCallback(e=>{z(e),V({userMessageRenderingMode:e})},[z]),pn=Q.useCallback(e=>{W(e),V({stickyUserHeader:e})},[W]),mn=Q.useCallback(e=>{ne(e),V({promptNavigatorEnabled:e})},[ne]),hn=Q.useCallback(e=>{ie(e),V({expandedEditorToolbar:e})},[ie]),gn=Q.useCallback(e=>{ee(e),V({collapsibleUserMessages:e})},[ee]),_n=Q.useCallback(e=>{ce(e),V({wideChatLayoutEnabled:e})},[ce]),vn=Q.useCallback(e=>{ot(e),V({showSplitAssistantMessageActions:e})},[ot]),yn=Q.useCallback(e=>{ct(e),V({showAssistantTps:e})},[ct]),bn=Q.useCallback(e=>{Ge(e),V({inputSpellcheckEnabled:e})},[Ge]),xn=Q.useCallback(e=>{fe(e),V({chatRenderMode:e})},[fe]),Sn=Q.useCallback(e=>{mt(e),V({messageStreamTransport:e})},[mt]),Cn=Q.useCallback(e=>{me(e),V({activityRenderMode:e})},[me]),wn=Q.useCallback(e=>{F(e),V({mermaidRenderingMode:e})},[F]),Tn=Q.useCallback(e=>{qe(e),V({showToolFileIcons:e})},[qe]),En=Q.useCallback(e=>{Ye(e),V({showTurnChangedFiles:e})},[Ye]),Dn=Q.useCallback(e=>{_t(e),V({defaultFileViewerPreview:e}),window.dispatchEvent(new CustomEvent(`openchamber:file-viewer-preview-mode-changed`,{detail:{enabled:e}}))},[_t]),On=Q.useCallback(e=>{Ze(e),V({showExpandedBashTools:e})},[Ze]),kn=Q.useCallback(e=>{$e(e),V({showSubagentTaskDetails:e})},[$e]),An=Q.useCallback(e=>{tt(e),V({timeFormatPreference:e})},[tt]),jn=Q.useCallback(e=>{it(e),V({weekStartPreference:e})},[it]),Mn=Q.useMemo(()=>xt.filter(e=>e.metadata.variant===`light`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[xt]),Nn=Q.useMemo(()=>xt.filter(e=>e.metadata.variant===`dark`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[xt]),Pn=Q.useMemo(()=>Mn.find(e=>e.metadata.id===wt)??Mn[0],[Mn,wt]),Fn=Q.useMemo(()=>Nn.find(e=>e.metadata.id===Tt)??Nn[0],[Nn,Tt]),In=Q.useCallback((e,t)=>{let n=t===`dark`?` Dark`:` Light`;return e.endsWith(n)?e.slice(0,-n.length):e},[]),X=t=>t===`splitAssistantMessageActions`||t===`showToolFileIcons`?!1:!e||e.includes(t),Ln=async()=>{if(!Mt){Nt(!0);try{await nt(),jt(!1),K.success(s(`settings.openchamber.visual.transcriptCache.toast.cleared`))}catch{K.error(s(`settings.openchamber.visual.transcriptCache.toast.failed`))}finally{Nt(!1)}}},Rn=m(),zn=mr(),Bn=X(`theme`)&&!Rn,Vn=X(`theme`)||X(`timeFormat`)||X(`weekStart`),Hn=Rn?Vn||X(`sidebarBrand`):X(`theme`)||X(`sidebarBrand`)||X(`pwaInstallName`)||X(`pwaOrientation`)||X(`mobileKeyboardMode`)||X(`timeFormat`)||X(`weekStart`)||zn,Un=X(`fontSize`)||X(`codeFontSize`)||X(`terminalFontSize`)||X(`editorFontSize`)||X(`spacing`)||X(`inputBarOffset`),Wn=X(`terminalQuickKeys`)&&!h||X(`fileEditorKeymap`)||X(`expandedEditorToolbar`),Gn=X(`mermaidRendering`)||X(`userMessageRendering`)||X(`chatRenderMode`)||X(`messageTransport`)||X(`activityRenderMode`)&&de===`sorted`||X(`collapsibleUserMessages`)||X(`stickyUserHeader`)||X(`promptNavigatorEnabled`)&&!Rn||X(`wideChatLayout`)||X(`codeBlockLineWrap`)||X(`splitAssistantMessageActions`)||X(`showAssistantTps`)||X(`subagentReadOnlyBanner`)||X(`diffLayout`)||X(`dotfiles`)||X(`fileViewerPreview`)||X(`reasoning`)||X(`followUpBehavior`)||X(`persistDraft`)||X(`showToolFileIcons`)||X(`showSubagentTaskDetails`)||X(`expandedTools`)||!h&&X(`inputSpellcheck`),Kn=X(`pwaInstallName`)&&A()&&g&&!w()&&!Rn,qn=X(`pwaOrientation`)&&A()&&!w()&&!Rn,Jn=X(`mobileKeyboardMode`)&&A()&&!w()&&!Rn&&o(),[Yn,Xn]=Q.useState(``),[Zn,Qn]=Q.useState(`system`),$n=Q.useMemo(()=>{let e=hf.find(e=>e.id===et);return d(e?.labelKey??`settings.openchamber.visual.option.timeFormat.auto.label`)},[et,d]),er=Q.useMemo(()=>{let e=gf.find(e=>e.id===rt);return d(e?.labelKey??`settings.openchamber.visual.option.weekStart.auto.label`)},[rt,d]),tr=Q.useMemo(()=>{let e=cf.find(e=>e.id===Zn);return e?d(e.labelKey):void 0},[Zn,d]),nr=Q.useMemo(()=>{let e=lf.find(e=>e.id===Me);return e?d(e.labelKey):void 0},[Me,d]),rr=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=e.trim().replace(/\s+/g,` `).slice(0,64);if(await V({pwaAppName:n}),typeof t.__OPENCHAMBER_SET_PWA_INSTALL_NAME__==`function`){let e=t.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(n);Xn(e);return}Xn(n||sf),t.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),ir=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=uf(e);if(await V({pwaOrientation:n}),typeof t.__OPENCHAMBER_SET_PWA_ORIENTATION__==`function`){let e=t.__OPENCHAMBER_SET_PWA_ORIENTATION__(n);Qn(e);return}Qn(n),t.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);return Q.useEffect(()=>{if(typeof window>`u`||!Kn&&!qn&&!Jn)return;let e=!1;return(async()=>{try{let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok){e||Xn(sf);return}let n=await t.json().catch(()=>({})),r=(typeof n?.pwaAppName==`string`?n.pwaAppName:``).trim().replace(/\s+/g,` `).slice(0,64),i=uf(n?.pwaOrientation),a=l(n?.mobileKeyboardMode);e||(Kn&&Xn(r||sf),qn&&Qn(i),Jn&&Ne(a))}catch{e||(Kn&&Xn(sf),qn&&Qn(`system`),Jn&&Ne(`native`))}})(),()=>{e=!0}},[Ne,Jn,Kn,qn]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[Hn&&(0,$.jsxs)($.Fragment,{children:[Bn&&(0,$.jsxs)(ef,{isMobile:h,label:(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:s(`settings.openchamber.visual.section.colorMode`)}),(0,$.jsxs)(`div`,{className:`inline-flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"data-settings-item":`appearance.reload-themes`,disabled:St||Ot,onClick:()=>{let e=Date.now();kt(!0),Ct().finally(()=>{let t=Date.now()-e;if(t<500){window.setTimeout(()=>{kt(!1)},500-t);return}kt(!1)})},className:`inline-flex items-center typography-micro font-normal text-muted-foreground underline decoration-[1px] underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:text-muted-foreground/60`,children:s(Ot?`settings.openchamber.visual.actions.reloadingThemes`:`settings.openchamber.visual.actions.reloadThemes`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex items-center justify-center rounded-md p-0.5 text-muted-foreground/70 hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.field.themeImportInfoAria`),children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(dn,{sideOffset:8,children:s(`settings.openchamber.visual.field.themeImportInfoTooltip`)})]})]})]}),children:[(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.color-mode`,label:s(`settings.openchamber.visual.field.themeMode`),children:(0,$.jsx)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,role:`group`,"aria-label":s(`settings.openchamber.visual.field.themeMode`),children:rf.map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":yt===e.value,className:`oc-mobile-settings-chip shrink-0 !font-normal`,onClick:()=>bt(e.value),children:d(e.labelKey)},e.value))})}),(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.light-theme`,label:s(`settings.openchamber.visual.field.lightTheme`),children:(0,$.jsxs)(an,{value:Pn?.metadata.id??``,onValueChange:Et,children:[(0,$.jsx)(tn,{"aria-label":s(`settings.openchamber.visual.field.selectLightThemeAria`),className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:s(`settings.openchamber.visual.field.selectThemePlaceholder`),children:Pn?In(Pn.metadata.name,`light`):void 0})}),(0,$.jsx)(nn,{children:Mn.map(e=>(0,$.jsx)($t,{value:e.metadata.id,children:In(e.metadata.name,`light`)},e.metadata.id))})]})}),(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.dark-theme`,label:s(`settings.openchamber.visual.field.darkTheme`),children:(0,$.jsxs)(an,{value:Fn?.metadata.id??``,onValueChange:Dt,children:[(0,$.jsx)(tn,{"aria-label":s(`settings.openchamber.visual.field.selectDarkThemeAria`),className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:s(`settings.openchamber.visual.field.selectThemePlaceholder`),children:Fn?In(Fn.metadata.name,`dark`):void 0})}),(0,$.jsx)(nn,{children:Nn.map(e=>(0,$.jsx)($t,{value:e.metadata.id,children:In(e.metadata.name,`dark`)},e.metadata.id))})]})}),Pt&&(0,$.jsxs)(`div`,{"data-settings-item":`appearance.window-transparency`,className:`oc-settings-group-row flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":It,onClick:()=>{Rt||Lt(!It)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Rt||Lt(!It))},children:[(0,$.jsx)(Qt,{checked:It,onChange:Lt,disabled:Rt,ariaLabel:s(`settings.openchamber.visual.field.macVibrancy`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.macVibrancy`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s(`settings.openchamber.visual.field.macVibrancyHint`)})]})]}),It!==Ft&&(0,$.jsx)(`div`,{className:`pl-6`,children:(0,$.jsx)(Y,{variant:`outline`,size:`sm`,disabled:Rt,onClick:()=>{zt(!0),B(`desktop_set_vibrancy`,{enabled:It})},children:s(Rt?`settings.openchamber.visual.actions.restarting`:`settings.openchamber.visual.actions.saveAndRestart`)})})]}),Bt&&(0,$.jsx)(`div`,{"data-settings-item":`appearance.dock-badge`,className:`oc-settings-group-row flex flex-col gap-1.5`,children:(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Vt,onClick:()=>Ht(!Vt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Ht(!Vt))},children:[(0,$.jsx)(Qt,{checked:Vt,onChange:Ht,ariaLabel:s(`settings.openchamber.visual.field.dockBadge`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.dockBadge`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s(`settings.openchamber.visual.field.dockBadgeHint`)})]})]})})]}),zn&&(0,$.jsx)(ef,{isMobile:h,children:(0,$.jsx)(Vr,{itemId:`appearance.ios-native-ui`,checked:ae,onChange:oe,label:s(`settings.openchamber.visual.field.iosNativeUi`),description:s(`settings.openchamber.visual.field.iosNativeUiHint`),ariaLabel:s(`settings.openchamber.visual.field.iosNativeUi`)})}),Vn&&(0,$.jsxs)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.localization`),children:[(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.language`,label:s(`settings.appearance.language.label`),description:s(`settings.appearance.language.description`),children:(0,$.jsxs)(an,{value:n,onValueChange:e=>i(e),children:[(0,$.jsx)(tn,{"aria-label":s(`settings.appearance.language.select`),className:`w-fit`,children:(0,$.jsx)(cn,{children:a(n)})}),(0,$.jsx)(nn,{children:r.map(e=>(0,$.jsx)($t,{value:e,children:a(e)},e))})]})}),(X(`timeFormat`)||X(`weekStart`))&&(0,$.jsxs)($.Fragment,{children:[X(`timeFormat`)&&(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.time-format`,label:s(`settings.openchamber.visual.field.timeFormat`),children:(0,$.jsxs)(an,{value:et,onValueChange:e=>An(e),children:[(0,$.jsx)(tn,{"aria-label":s(`settings.openchamber.visual.field.selectTimeFormatAria`),className:`w-fit`,children:(0,$.jsx)(cn,{children:$n})}),(0,$.jsx)(nn,{children:hf.map(e=>(0,$.jsx)($t,{value:e.id,children:d(e.labelKey)},e.id))})]})}),X(`weekStart`)&&(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.week-start`,label:s(`settings.openchamber.visual.field.weekStartsOn`),children:(0,$.jsxs)(an,{value:rt,onValueChange:e=>jn(e),children:[(0,$.jsx)(tn,{"aria-label":s(`settings.openchamber.visual.field.selectWeekStartAria`),className:`w-fit`,children:(0,$.jsx)(cn,{children:er})}),(0,$.jsx)(nn,{children:gf.map(e=>(0,$.jsx)($t,{value:e.id,children:d(e.labelKey)},e.id))})]})})]})]}),X(`sidebarBrand`)&&(0,$.jsx)($d,{isMobile:h,itemId:`appearance.sidebar-brand`,label:s(`settings.openchamber.visual.field.sidebarBrand`),description:s(`settings.openchamber.visual.field.sidebarBrandHint`),descriptionPlacement:`outside`,children:(0,$.jsx)(ln,{value:lt,onChange:e=>ut(e.target.value),maxLength:64,"aria-label":s(`settings.openchamber.visual.field.sidebarBrandAria`)})}),(Kn||qn||Jn)&&(0,$.jsxs)($.Fragment,{children:[Kn&&(0,$.jsxs)($d,{isMobile:h,itemId:`appearance.pwa-install-name`,label:s(`settings.openchamber.visual.field.installAppName`),description:s(`settings.openchamber.visual.field.installAppNameHint`),children:[(0,$.jsx)(ln,{value:Yn,onChange:e=>{Xn(e.target.value)},onBlur:()=>{rr(Yn)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),rr(Yn))},maxLength:64,"aria-label":s(`settings.openchamber.visual.field.pwaInstallAppNameAria`)}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Xn(sf),rr(``)},className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetInstallAppNameAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),qn&&(0,$.jsxs)($d,{isMobile:h,itemId:`appearance.pwa-orientation`,label:s(`settings.openchamber.visual.field.installOrientation`),description:s(`settings.openchamber.visual.field.installOrientationHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(an,{value:Zn,onValueChange:e=>{let t=uf(e);Qn(t),ir(t)},children:[(0,$.jsx)(tn,{"aria-label":s(`settings.openchamber.visual.field.pwaInstallOrientationAria`),className:`w-full`,children:(0,$.jsx)(cn,{placeholder:s(`settings.openchamber.visual.field.selectOrientationPlaceholder`),children:tr})}),(0,$.jsx)(nn,{children:cf.map(e=>(0,$.jsx)($t,{value:e.id,children:d(e.labelKey)},e.id))})]}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Qn(`system`),ir(`system`)},disabled:Zn===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetInstallOrientationAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Jn&&(0,$.jsxs)($d,{isMobile:h,itemId:`appearance.mobile-keyboard-mode`,label:s(`settings.openchamber.visual.field.mobileKeyboardMode`),description:s(`settings.openchamber.visual.field.mobileKeyboardModeHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(an,{value:Me,onValueChange:e=>{let t=l(e);Ne(t),V({mobileKeyboardMode:t})},children:[(0,$.jsx)(tn,{"aria-label":s(`settings.openchamber.visual.field.mobileKeyboardModeAria`),className:`w-full`,children:(0,$.jsx)(cn,{placeholder:s(`settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder`),children:nr})}),(0,$.jsx)(nn,{children:lf.map(e=>(0,$.jsx)($t,{value:e.id,children:d(e.labelKey)},e.id))})]}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Ne(`native`),V({mobileKeyboardMode:`native`})},disabled:Me===`native`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetMobileKeyboardModeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})]}),Un&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.spacingAndLayout`),children:(0,$.jsxs)($.Fragment,{children:[X(`fontSize`)&&!h&&(0,$.jsxs)(tf,{isMobile:h,label:s(`settings.openchamber.visual.field.interfaceFont`),children:[(0,$.jsxs)(an,{value:Ce,onValueChange:e=>we(e),children:[(0,$.jsx)(tn,{"aria-label":s(`settings.openchamber.visual.field.selectInterfaceFontAria`),className:`w-[13rem]`,children:(0,$.jsx)(cn,{children:f.find(e=>e.id===Ce)?.label})}),(0,$.jsx)(nn,{children:f.map(e=>(0,$.jsx)($t,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>we(`system`),disabled:Ce===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetInterfaceFontAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`terminalFontSize`)&&(0,$.jsxs)(tf,{isMobile:h,itemId:`appearance.code-font`,label:s(`settings.openchamber.visual.field.codeFont`),children:[(0,$.jsxs)(an,{value:Te,onValueChange:e=>Ee(e),children:[(0,$.jsx)(tn,{"aria-label":s(`settings.openchamber.visual.field.selectCodeFontAria`),className:`w-full max-w-[13rem]`,children:(0,$.jsx)(cn,{children:c.find(e=>e.id===Te)?.label})}),(0,$.jsx)(nn,{children:c.map(e=>(0,$.jsx)($t,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Ee(`system-mono`),disabled:Te===`system-mono`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetCodeFontAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`fontSize`)&&(0,$.jsxs)(tf,{isMobile:h,itemId:`appearance.interface-font-size`,label:s(`settings.openchamber.visual.field.interfaceFontSize`),children:[(0,$.jsx)(zr,{value:he,onValueChange:ge,min:50,max:200,step:5,"aria-label":s(`settings.openchamber.visual.field.fontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ge(100),disabled:he===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetFontSizeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`codeFontSize`)&&(0,$.jsxs)(tf,{isMobile:h,itemId:`appearance.code-font-size`,label:s(`settings.openchamber.visual.field.codeFontSize`),children:[(0,$.jsx)(zr,{value:_e,onValueChange:ve,min:50,max:200,step:5,"aria-label":s(`settings.openchamber.visual.field.codeFontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ve(100),disabled:_e===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetCodeFontSizeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`terminalFontSize`)&&(0,$.jsxs)(tf,{isMobile:h,itemId:`appearance.terminal-font-size`,label:s(`settings.openchamber.visual.field.terminalFontSize`),children:[(0,$.jsx)(zr,{value:ye,onValueChange:be,min:9,max:52,step:1,className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>be(13),disabled:ye===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetTerminalFontSizeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`editorFontSize`)&&(0,$.jsxs)(tf,{isMobile:h,itemId:`appearance.editor-font-size`,label:s(`settings.openchamber.visual.field.editorFontSize`),children:[(0,$.jsx)(zr,{value:xe,onValueChange:Se,min:9,max:32,step:1,className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Se(13),disabled:xe===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetEditorFontSizeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`spacing`)&&(0,$.jsxs)(tf,{isMobile:h,itemId:`appearance.spacing-density`,label:s(`settings.openchamber.visual.field.spacingDensity`),children:[(0,$.jsx)(zr,{value:De,onValueChange:Oe,min:50,max:200,step:5,className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Oe(100),disabled:De===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetSpacingAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`inputBarOffset`)&&(0,$.jsxs)(tf,{isMobile:h,itemId:`appearance.input-bar-offset`,label:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:s(`settings.openchamber.visual.field.inputBarOffset`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:s(`settings.openchamber.visual.field.inputBarOffsetTooltip`)})]})]}),children:[(0,$.jsx)(zr,{value:Ae,onValueChange:je,min:0,max:100,step:5,className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>je(0),disabled:Ae===0,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetInputBarOffsetAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})})}),Wn&&(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.navigation`),children:[X(`fileEditorKeymap`)&&(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.file-editor-keymap`,label:s(`settings.openchamber.visual.field.fileEditorKeymap`),children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.field.fileEditorKeymap`),className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-1`,children:[`default`,`vim`].map(e=>{let t=Re===e,n=s(`settings.openchamber.visual.option.fileEditorKeymap.${e}`);return(0,$.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-2 py-0.5 text-left`,role:`radio`,"aria-checked":t,onClick:()=>ze(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:q(`relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full transition-[background-color,box-shadow] duration-200 ease-out`,t?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)]`),children:(0,$.jsx)(`span`,{className:q(`block h-[5px] w-[5px] rounded-full bg-white`,!t&&`opacity-0`)})}),(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/50`),children:n})]},e)})})}),X(`expandedEditorToolbar`)&&(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.expanded-editor-toolbar`,label:s(`settings.openchamber.visual.field.expandedEditorToolbar`),children:(0,$.jsx)(Qt,{checked:re,onChange:hn,ariaLabel:s(`settings.openchamber.visual.field.expandedEditorToolbarAria`)})}),X(`terminalQuickKeys`)&&!h&&!w()&&(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.terminal-quick-keys`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:s(`settings.openchamber.visual.field.terminalQuickKeys`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:s(`settings.openchamber.visual.field.terminalQuickKeysTooltip`)})]})]}),children:(0,$.jsx)(Qt,{checked:Ie,onChange:Le,ariaLabel:s(`settings.openchamber.visual.field.terminalQuickKeysAria`)})})]})}),Gn&&(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(X(`userMessageRendering`)||X(`mermaidRendering`)||X(`chatRenderMode`)||X(`messageTransport`)||X(`activityRenderMode`)&&de===`sorted`||X(`diffLayout`)&&!Rn||X(`followUpBehavior`))&&(0,$.jsxs)(`div`,{className:`grid w-full grid-cols-1 gap-y-[var(--oc-settings-section-stack-gap)]`,children:[X(`chatRenderMode`)&&(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.chatRenderMode`),className:`w-full`,cardClassName:`!border-0 !bg-transparent !rounded-none overflow-visible`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.render-mode`,className:`min-w-0 w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.chatRenderModeAria`),className:`grid w-full grid-cols-1 gap-3 sm:grid-cols-2`,children:ff.map(e=>{let t=de===e.id,n=Yt%12;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>xn(e.id),"aria-pressed":t,className:q(`flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors`,t?`border-primary bg-primary/5`:`border-border hover:border-border/80 hover:bg-muted/50`),children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label`,t?`text-foreground`:`text-muted-foreground`),children:d(e.labelKey)}),(0,$.jsx)(`div`,{className:`mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2`,children:e.id===`live`?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=e*3+1,r=n-t+1,i=r<=0?0:r===1?42:r===2?68:92;return(0,$.jsxs)(`div`,{className:q(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,i>0?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none`,style:{width:`${i}%`}})]},e)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=n>=(e+1)*3;return(0,$.jsxs)(`div`,{className:q(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,t?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30`,style:{width:`92%`}})]},e)})})})]},e.id)})})})}),X(`messageTransport`)&&(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.messageStreamTransport`),className:`w-full`,children:(0,$.jsxs)(`div`,{"data-settings-item":`chat.message-transport`,className:`oc-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:pf.map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":ht===e.id,className:`!font-normal`,onClick:()=>Sn(e.id),children:d(e.labelKey)},e.id))}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:(()=>{let e=pf.find(e=>e.id===ht);return e?.descriptionKey?d(e.descriptionKey):``})()})]})}),X(`activityRenderMode`)&&de===`sorted`&&(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.activityDefault`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.activityDefaultAria`),children:mf.map(e=>{let t=pe===e.id;return(0,$.jsx)(nf,{selected:t,onSelect:()=>Cn(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.activityDefaultModeAria`,{option:d(e.labelKey)})},e.id)})})}),X(`expandedTools`)&&(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.showToolsOpenedByDefault`),className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":Xe,onClick:()=>On(!Xe),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),On(!Xe))},children:[(0,$.jsx)(Qt,{checked:Xe,onChange:On,ariaLabel:s(`settings.openchamber.visual.field.showExpandedBashToolsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.bash`)})]})}),X(`userMessageRendering`)&&(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.userMessageRendering`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.userMessageRenderingAria`),children:df.map(e=>{let t=vf(R)===e.id;return(0,$.jsx)(nf,{selected:t,onSelect:()=>sn(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.userMessageRenderingAria`,{option:d(e.labelKey)})},e.id)})})}),X(`mermaidRendering`)&&(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.mermaidRendering`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.mermaidRenderingAria`),children:of.map(e=>{let t=P===e.id;return(0,$.jsx)(nf,{selected:t,onSelect:()=>wn(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.mermaidRenderingAria`,{option:d(e.labelKey)})},e.id)})})}),X(`diffLayout`)&&!Rn&&(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.diffLayout`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.diffLayoutAria`),children:af.map(e=>{let t=Pe===e.id;return(0,$.jsx)(nf,{selected:t,onSelect:()=>Fe(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.diffLayoutAria`,{option:d(e.labelKey)})},e.id)})})}),X(`followUpBehavior`)&&(0,$.jsx)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.followUpBehavior`),className:`w-full`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.follow-up-behavior`,role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.followUpBehaviorAria`),children:_f.map(e=>{let t=Be===e.id;return(0,$.jsx)(nf,{selected:t,onSelect:()=>Ve(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.followUpBehaviorAria`,{option:d(e.labelKey)})},e.id)})})})]}),X(`sessionGoal`)&&!Rn&&(0,$.jsxs)(ef,{isMobile:h,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:s(`settings.openchamber.visual.goal.sectionTitle`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-sm`,children:s(`settings.openchamber.visual.goal.description`)})]})]}),children:[(0,$.jsx)(tf,{isMobile:h,itemId:`chat.session-goal`,label:s(`settings.openchamber.visual.field.sessionGoal`),children:(0,$.jsx)(Qt,{checked:C,onChange:T,ariaLabel:s(`settings.openchamber.visual.field.sessionGoalAria`)})}),(0,$.jsxs)(tf,{isMobile:h,itemId:`chat.session-goal-budget`,label:s(`settings.openchamber.visual.goal.budgetLabel`),children:[(0,$.jsx)(Qt,{checked:E,onChange:D,disabled:!C,ariaLabel:s(`settings.openchamber.visual.goal.budgetAria`)}),C&&E?(0,$.jsx)(zr,{value:O,onValueChange:e=>{typeof e==`number`&&Number.isFinite(e)&&e>0&&k(Math.floor(e))},min:1e3,max:1e8,step:5e4}):null]})]}),(X(`sessionAssist`)||X(`collapsibleUserMessages`)||X(`stickyUserHeader`)||X(`promptNavigatorEnabled`)&&!Rn||X(`wideChatLayout`)||X(`codeBlockLineWrap`)||X(`splitAssistantMessageActions`)||X(`showAssistantTps`)||X(`subagentReadOnlyBanner`)||X(`dotfiles`)||X(`fileViewerPreview`)||X(`persistDraft`)||X(`showToolFileIcons`)||X(`showSubagentTaskDetails`)||X(`showTurnChangedFiles`)||!h&&X(`inputSpellcheck`)||X(`reasoning`))&&(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(X(`sessionAssist`)||X(`subagentReadOnlyBanner`))&&(0,$.jsxs)(ef,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.session-assistance`,children:s(`settings.openchamber.visual.section.sessionAssistance`)}),children:[X(`sessionAssist`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.session-title-refresh`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>S(!y),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),S(!y))},children:[(0,$.jsx)(Qt,{checked:y,onChange:S,ariaLabel:s(`settings.openchamber.visual.field.sessionTitleRefreshAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.sessionTitleRefresh`)})]}),X(`subagentReadOnlyBanner`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.subagent-read-only-banner`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":dt,onClick:()=>ft(!dt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ft(!dt))},children:[(0,$.jsx)(Qt,{checked:dt,onChange:ft,ariaLabel:s(`settings.openchamber.visual.field.allowPromptingSubagentSessionsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.allowPromptingSubagentSessions`)})]})]}),X(`reasoning`)&&(0,$.jsxs)(ef,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.reasoning`,children:s(`settings.openchamber.visual.section.reasoning`)}),children:[X(`reasoning`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.reasoning-traces`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":v,onClick:()=>j(!v),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),j(!v))},children:[(0,$.jsx)(Qt,{checked:v,onChange:j,ariaLabel:s(`settings.openchamber.visual.field.showReasoningTracesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showReasoningTraces`)})]}),X(`reasoning`)&&v&&(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":M,onClick:()=>N(!M),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),N(!M))},children:[(0,$.jsx)(Qt,{checked:M,onChange:N,ariaLabel:s(`settings.openchamber.visual.field.collapsibleThinkingBlocksAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.collapsibleThinkingBlocks`)})]})]}),(X(`collapsibleUserMessages`)||X(`stickyUserHeader`)||X(`promptNavigatorEnabled`)&&!Rn||X(`wideChatLayout`)||X(`splitAssistantMessageActions`)||X(`showAssistantTps`)||X(`codeBlockLineWrap`))&&(0,$.jsxs)(ef,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.message-appearance`,children:s(`settings.openchamber.visual.section.messageAppearance`)}),children:[X(`collapsibleUserMessages`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.collapsible-user-messages`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":H,onClick:()=>gn(!H),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),gn(!H))},children:[(0,$.jsx)(Qt,{checked:H,onChange:gn,ariaLabel:s(`settings.openchamber.visual.field.collapsibleUserMessagesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.collapsibleUserMessages`)})]}),X(`stickyUserHeader`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.sticky-user-header`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":U,onClick:()=>pn(!U),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),pn(!U))},children:[(0,$.jsx)(Qt,{checked:U,onChange:pn,ariaLabel:s(`settings.openchamber.visual.field.stickyUserHeaderAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.stickyUserHeader`)})]}),X(`promptNavigatorEnabled`)&&!Rn&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.prompt-navigator`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":te,onClick:()=>mn(!te),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),mn(!te))},children:[(0,$.jsx)(Qt,{checked:te,onChange:mn,ariaLabel:s(`settings.openchamber.visual.field.promptNavigatorEnabledAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.promptNavigatorEnabled`)})]}),X(`wideChatLayout`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.wide-layout`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":se,onClick:()=>_n(!se),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),_n(!se))},children:[(0,$.jsx)(Qt,{checked:se,onChange:_n,ariaLabel:s(`settings.openchamber.visual.field.wideChatLayoutAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.wideChatLayout`)})]}),X(`splitAssistantMessageActions`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.inline-assistant-actions`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":at,onClick:()=>vn(!at),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),vn(!at))},children:[(0,$.jsx)(Qt,{checked:at,onChange:vn,ariaLabel:s(`settings.openchamber.visual.field.showSplitAssistantMessageActionsAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showSplitAssistantMessageActions`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:s(`settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip`)})]})]})]}),X(`showAssistantTps`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.assistant-tps`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":st,onClick:()=>yn(!st),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),yn(!st))},children:[(0,$.jsx)(Qt,{checked:st,onChange:yn,ariaLabel:s(`settings.openchamber.visual.field.showAssistantTpsAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showAssistantTps`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:s(`settings.openchamber.visual.field.showAssistantTpsTooltip`)})]})]})]}),X(`codeBlockLineWrap`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.code-block-line-wrap`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":le,onClick:()=>ue(!le),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ue(!le))},children:[(0,$.jsx)(Qt,{checked:le,onChange:ue,ariaLabel:s(`settings.openchamber.visual.field.codeBlockLineWrapAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.codeBlockLineWrap`)})]})]}),(X(`showToolFileIcons`)||X(`showTurnChangedFiles`)||X(`dotfiles`)||X(`fileViewerPreview`))&&(0,$.jsxs)(ef,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.tools-and-files`,children:s(`settings.openchamber.visual.section.toolsAndFiles`)}),children:[X(`showToolFileIcons`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.tool-file-icons`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Ke,onClick:()=>Tn(!Ke),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Tn(!Ke))},children:[(0,$.jsx)(Qt,{checked:Ke,onChange:Tn,ariaLabel:s(`settings.openchamber.visual.field.showToolFileIconsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showToolFileIcons`)})]}),X(`showSubagentTaskDetails`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.subagent-task-details`,className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Qe,onClick:()=>kn(!Qe),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),kn(!Qe))},children:[(0,$.jsx)(Qt,{checked:Qe,onChange:kn,ariaLabel:s(`settings.openchamber.visual.field.showSubagentTaskDetailsAria`),className:`mt-0.5`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showSubagentTaskDetails`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s(`settings.openchamber.visual.field.showSubagentTaskDetailsHint`)})]})]}),X(`showTurnChangedFiles`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.changed-files`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Je,onClick:()=>En(!Je),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),En(!Je))},children:[(0,$.jsx)(Qt,{checked:Je,onChange:En,ariaLabel:s(`settings.openchamber.visual.field.showTurnChangedFilesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showTurnChangedFiles`)})]}),X(`dotfiles`)&&!m()&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.dotfiles`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":_,onClick:()=>b(!_),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(!_))},children:[(0,$.jsx)(Qt,{checked:_,onChange:b,ariaLabel:s(`settings.openchamber.visual.field.showDotfilesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showDotfiles`)})]}),X(`fileViewerPreview`)&&(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":gt,onClick:()=>Dn(!gt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Dn(!gt))},children:[(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(Qt,{checked:gt,onChange:Dn,ariaLabel:s(`settings.openchamber.defaults.field.openFilesPreviewAria`)})}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.defaults.field.openFilesPreview`)})]})]}),(X(`persistDraft`)||!h&&X(`inputSpellcheck`))&&(0,$.jsxs)(ef,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.composer`,children:s(`settings.openchamber.visual.section.composer`)}),children:[X(`persistDraft`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.persist-drafts`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":He,onClick:()=>Ue(!He),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Ue(!He))},children:[(0,$.jsx)(Qt,{checked:He,onChange:Ue,ariaLabel:s(`settings.openchamber.visual.field.persistDraftMessagesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.persistDraftMessages`)})]}),!h&&X(`inputSpellcheck`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.spellcheck`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":We,onClick:()=>bn(!We),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),bn(!We))},children:[(0,$.jsx)(Qt,{checked:We,onChange:bn,ariaLabel:s(`settings.openchamber.visual.field.enableSpellcheckInTextInputsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.enableSpellcheckInTextInputs`)})]})]})]})]}),X(`reportUsage`)&&(0,$.jsxs)(ef,{isMobile:h,label:s(`settings.openchamber.visual.section.privacy`),children:[X(`reportUsage`)&&(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.usage-reports`,label:s(`settings.openchamber.visual.field.sendAnonymousUsageReports`),description:s(`settings.openchamber.visual.field.sendAnonymousUsageReportsHint`),children:(0,$.jsx)(Qt,{checked:Zt,onChange:rn,ariaLabel:s(`settings.openchamber.visual.field.sendAnonymousUsageReportsAria`)})}),X(`reportUsage`)&&(0,$.jsx)(tf,{isMobile:h,itemId:`appearance.transcript-cache`,label:s(`settings.openchamber.visual.transcriptCache.label`),description:s(`settings.openchamber.visual.transcriptCache.description`),children:(0,$.jsx)(Y,{type:`button`,variant:`destructive`,size:`sm`,disabled:Mt,onClick:()=>jt(!0),children:s(`settings.openchamber.visual.transcriptCache.action`)})})]})]}),(0,$.jsx)(Jt,{open:At,onOpenChange:e=>{Mt||jt(e)},children:(0,$.jsxs)(Gt,{className:`max-w-[min(480px,100vw-2rem)]`,children:[(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Kt,{children:s(`settings.openchamber.visual.transcriptCache.dialog.title`)}),(0,$.jsx)(qt,{children:s(`settings.openchamber.visual.transcriptCache.dialog.description`)})]}),(0,$.jsxs)(Wt,{children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,disabled:Mt,onClick:()=>jt(!1),children:s(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`destructive`,disabled:Mt,"aria-busy":Mt||void 0,onClick:()=>void Ln(),children:s(Mt?`settings.openchamber.visual.transcriptCache.dialog.clearing`:`settings.openchamber.visual.transcriptCache.action`)})]})]})})]})},bf=1,xf=365,Sf=30,Cf=[{value:`archive`,labelKey:`settings.openchamber.sessionRetention.action.archive`},{value:`delete`,labelKey:`settings.openchamber.sessionRetention.action.delete`}],wf=()=>{let e=(0,Ei.c)(128),{t}=ke(),n=u(Tf),r=u(Ef),i=u(Df),a=u(Of),o=u(kf),s=u(Af),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={autoRun:!1},e[0]=c):c=e[0];let{candidates:l,isRunning:d,runCleanup:f,action:p}=tr(c),m=l.length,h=st(jf),g=u(Mf),_;e[1]!==f||e[2]!==t?(_=async()=>{let e=await f({force:!0});if(e.completedIds.length===0&&e.failedIds.length===0){K.message(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.noneEligibleArchive`):t(`settings.openchamber.sessionRetention.toast.noneEligibleDelete`));return}e.completedIds.length>0&&K.success(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.archivedCount`,{count:e.completedIds.length}):t(`settings.openchamber.sessionRetention.toast.deletedCount`,{count:e.completedIds.length})),e.failedIds.length>0&&K.error(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.failedArchiveCount`,{count:e.failedIds.length}):t(`settings.openchamber.sessionRetention.toast.failedDeleteCount`,{count:e.failedIds.length}))},e[1]=f,e[2]=t,e[3]=_):_=e[3];let v=_,y;e[4]===t?y=e[5]:(y=t(`settings.openchamber.sessionRetention.title`),e[4]=t,e[5]=y);let b;e[6]===y?b=e[7]:(b=(0,$.jsx)(`span`,{children:y}),e[6]=y,e[7]=b);let x;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),e[8]=x):x=e[8];let S;e[9]===t?S=e[10]:(S=t(`settings.openchamber.sessionRetention.tooltip`),e[9]=t,e[10]=S);let C;e[11]===S?C=e[12]:(C=(0,$.jsxs)(fn,{children:[x,(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:S})]}),e[11]=S,e[12]=C);let w;e[13]!==b||e[14]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,C]}),e[13]=b,e[14]=C,e[15]=w):w=e[15];let T,E;e[16]!==n||e[17]!==a?(T=()=>a(!n),E=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),a(!n))},e[16]=n,e[17]=a,e[18]=T,e[19]=E):(T=e[18],E=e[19]);let D;e[20]===t?D=e[21]:(D=t(`settings.openchamber.sessionRetention.field.enableAutoCleanup`),e[20]=t,e[21]=D);let O;e[22]===D?O=e[23]:(O=(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:D})}),e[22]=D,e[23]=O);let k;e[24]===t?k=e[25]:(k=t(`settings.openchamber.sessionRetention.field.enableAutoCleanupAria`),e[24]=t,e[25]=k);let A;e[26]!==n||e[27]!==a||e[28]!==k?(A=(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(Qt,{checked:n,onChange:a,ariaLabel:k})}),e[26]=n,e[27]=a,e[28]=k,e[29]=A):A=e[29];let j;e[30]!==n||e[31]!==O||e[32]!==A||e[33]!==T||e[34]!==E?(j=(0,$.jsxs)(`div`,{"data-settings-item":`sessions.auto-cleanup`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:T,onKeyDown:E,children:[O,A]}),e[30]=n,e[31]=O,e[32]=A,e[33]=T,e[34]=E,e[35]=j):j=e[35];let M;e[36]===t?M=e[37]:(M=t(`settings.openchamber.sessionRetention.field.retentionPeriod`),e[36]=t,e[37]=M);let N;e[38]===t?N=e[39]:(N=t(`settings.openchamber.sessionRetention.field.retentionPeriodAria`),e[38]=t,e[39]=N);let P;e[40]!==r||e[41]!==o||e[42]!==N?(P=(0,$.jsx)(zr,{value:r,onValueChange:o,min:bf,max:xf,step:1,"aria-label":N,className:`w-20 tabular-nums`}),e[40]=r,e[41]=o,e[42]=N,e[43]=P):P=e[43];let F;e[44]===t?F=e[45]:(F=t(`settings.openchamber.sessionRetention.field.days`),e[44]=t,e[45]=F);let I;e[46]===F?I=e[47]:(I=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:F}),e[46]=F,e[47]=I);let L;e[48]===o?L=e[49]:(L=()=>o(Sf),e[48]=o,e[49]=L);let R=r===Sf,z;e[50]===t?z=e[51]:(z=t(`settings.openchamber.sessionRetention.actions.resetRetentionAria`),e[50]=t,e[51]=z);let B;e[52]===t?B=e[53]:(B=t(`settings.common.actions.reset`),e[52]=t,e[53]=B);let V;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`}),e[54]=V):V=e[54];let H;e[55]!==L||e[56]!==R||e[57]!==z||e[58]!==B?(H=(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:L,disabled:R,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":z,title:B,children:V}),e[55]=L,e[56]=R,e[57]=z,e[58]=B,e[59]=H):H=e[59];let ee;e[60]!==M||e[61]!==P||e[62]!==I||e[63]!==H?(ee=(0,$.jsxs)(Fr,{itemId:`sessions.retention-period`,label:M,children:[P,I,H]}),e[60]=M,e[61]=P,e[62]=I,e[63]=H,e[64]=ee):ee=e[64];let U;e[65]===t?U=e[66]:(U=t(`settings.openchamber.sessionRetention.field.whenSessionsExpire`),e[65]=t,e[66]=U);let te;e[67]!==i||e[68]!==s||e[69]!==t?(te=Cf.map(e=>(0,$.jsx)(Y,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":i===e.value,className:`!font-normal`,onClick:()=>s(e.value),children:t(e.labelKey)},e.value)),e[67]=i,e[68]=s,e[69]=t,e[70]=te):te=e[70];let W;e[71]===te?W=e[72]:(W=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:te}),e[71]=te,e[72]=W);let ne;e[73]!==U||e[74]!==W?(ne=(0,$.jsx)(Fr,{itemId:`sessions.retention-action`,label:U,children:W}),e[73]=U,e[74]=W,e[75]=ne):ne=e[75];let re;e[76]!==j||e[77]!==ee||e[78]!==ne||e[79]!==w?(re=(0,$.jsxs)(Z,{label:w,children:[j,ee,ne]}),e[76]=j,e[77]=ee,e[78]=ne,e[79]=w,e[80]=re):re=e[80];let ie;e[81]===t?ie=e[82]:(ie=t(`settings.openchamber.sessionRetention.manualCleanup.title`),e[81]=t,e[82]=ie);let ae;e[83]!==p||e[84]!==m||e[85]!==t?(ae=t(p===`archive`?`settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow`:`settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow`,{count:m}),e[83]=p,e[84]=m,e[85]=t,e[86]=ae):ae=e[86];let oe;e[87]!==d||e[88]!==t?(oe=t(d?`settings.openchamber.sessionRetention.actions.cleaningUp`:`settings.openchamber.sessionRetention.actions.runCleanupNow`),e[87]=d,e[88]=t,e[89]=oe):oe=e[89];let se;e[90]!==v||e[91]!==d||e[92]!==oe?(se=(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,onClick:v,disabled:d,className:`!font-normal`,children:oe}),e[90]=v,e[91]=d,e[92]=oe,e[93]=se):se=e[93];let ce;e[94]!==ie||e[95]!==ae||e[96]!==se?(ce=(0,$.jsx)(Ar,{label:ie,description:ae,descriptionPlacement:`outside`,children:se}),e[94]=ie,e[95]=ae,e[96]=se,e[97]=ce):ce=e[97];let le;e[98]===t?le=e[99]:(le=t(`settings.openchamber.archivedSessions.title`),e[98]=t,e[99]=le);let ue;e[100]!==h||e[101]!==t?(ue=t(h===1?`settings.openchamber.archivedSessions.summarySingle`:`settings.openchamber.archivedSessions.summaryPlural`,{count:h}),e[100]=h,e[101]=t,e[102]=ue):ue=e[102];let de;e[103]===ue?de=e[104]:(de=(0,$.jsx)(`span`,{className:`block`,children:ue}),e[103]=ue,e[104]=de);let fe;e[105]===t?fe=e[106]:(fe=t(`settings.openchamber.archivedSessions.description`),e[105]=t,e[106]=fe);let pe;e[107]===fe?pe=e[108]:(pe=(0,$.jsx)(`span`,{className:`block`,children:fe}),e[107]=fe,e[108]=pe);let me;e[109]!==de||e[110]!==pe?(me=(0,$.jsxs)($.Fragment,{children:[de,pe]}),e[109]=de,e[110]=pe,e[111]=me):me=e[111];let he;e[112]===g?he=e[113]:(he=()=>g(!0),e[112]=g,e[113]=he);let ge;e[114]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(J,{name:`archive`,className:`mr-1 h-3.5 w-3.5`}),e[114]=ge):ge=e[114];let _e;e[115]===t?_e=e[116]:(_e=t(`settings.openchamber.archivedSessions.actions.manage`),e[115]=t,e[116]=_e);let ve;e[117]!==he||e[118]!==_e?(ve=(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,onClick:he,className:`!font-normal`,children:[ge,_e]}),e[117]=he,e[118]=_e,e[119]=ve):ve=e[119];let ye;e[120]!==le||e[121]!==me||e[122]!==ve?(ye=(0,$.jsx)(Ar,{itemId:`sessions.archived`,label:le,description:me,descriptionPlacement:`outside`,children:ve}),e[120]=le,e[121]=me,e[122]=ve,e[123]=ye):ye=e[123];let be;return e[124]!==re||e[125]!==ce||e[126]!==ye?(be=(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[re,ce,ye]}),e[124]=re,e[125]=ce,e[126]=ye,e[127]=be):be=e[127],be};function Tf(e){return e.autoDeleteEnabled}function Ef(e){return e.autoDeleteAfterDays}function Df(e){return e.sessionRetentionAction}function Of(e){return e.setAutoDeleteEnabled}function kf(e){return e.setAutoDeleteAfterDays}function Af(e){return e.setSessionRetentionAction}function jf(e){return e.archivedSessions.length}function Mf(e){return e.setArchivedSessionsDialogOpen}var Nf=(e,t,n)=>!e||!Number.isFinite(e)?t:new Intl.DateTimeFormat(Ae(),{dateStyle:`medium`,timeStyle:`short`,hour12:n===`auto`?void 0:n===`12h`}).format(e),Pf=()=>{let{t:e}=ke(),t=u(e=>e.timeFormatPreference),[n,r]=Q.useState(!1),[i,a]=Q.useState(!0),[o,s]=Q.useState(!1),[c,l]=Q.useState(null),[d,f]=Q.useState(!1),[p,m]=Q.useState([]),[h,g]=Q.useState(er),[_,v]=Q.useState(``),y=Q.useMemo(()=>rr(),[]),b=Q.useCallback(async()=>{a(!0),v(``);try{let e=await qn();m(e)}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.loadFailed`);v(n)}finally{a(!1)}},[e]);Q.useEffect(()=>{let e=!1;return(async()=>{try{if(!y.supported){e||(r(!1),a(!1));return}e||r(!0)}catch{e||r(!1)}if(!e){let e=await In();if(g(e),!e.enabled){m([]),a(!1);return}await b()}})(),()=>{e=!0,Yn()}},[b,y.supported]);let x=Q.useCallback(async()=>{if(!h.enabled){let t=e(`settings.openchamber.passkeys.toast.enableUiPasswordFirst`);v(t),K.message(t);return}if(!n){v(y.reason),K.message(y.reason);return}if(o){Yn(),s(!1);return}v(``),s(!0);try{await zn(),g(await In()),await b(),K.success(e(`settings.openchamber.passkeys.toast.added`))}catch(t){if(X(t)){K.message(e(`settings.openchamber.passkeys.toast.setupCanceled`));return}let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.addFailed`);v(n),K.error(n)}finally{s(!1)}},[o,b,h.enabled,y.reason,n,e]),S=Q.useCallback(async t=>{l(t),v(``);try{await Jn(t),g(await In()),await b(),K.success(e(`settings.openchamber.passkeys.toast.removed`))}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.removeFailed`);v(n),K.error(n)}finally{l(null)}},[b,e]),C=Q.useCallback(async()=>{f(!0),v(``);try{await Zn(),window.location.reload()}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.clearAuthFailed`);v(n),K.error(n),f(!1)}},[e]);return(0,$.jsxs)(Z,{label:e(`settings.openchamber.passkeys.title`),children:[(0,$.jsx)(Fr,{label:e(`settings.openchamber.passkeys.field.currentDevice`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:o?`secondary`:`outline`,size:`xs`,onClick:()=>void x(),disabled:i||d,className:`!font-normal`,children:e(o?`settings.openchamber.passkeys.actions.cancelSetup`:`settings.openchamber.passkeys.actions.add`)}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void C(),disabled:i||o||d,className:`!font-normal text-muted-foreground hover:text-foreground`,children:e(d?`settings.openchamber.passkeys.actions.signingOut`:`settings.openchamber.passkeys.actions.signOutEverywhere`)})]})}),!h.enabled&&(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.uiPasswordRequired`)}),h.enabled&&!n&&(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:y.reason}),i?(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.loading`)}):p.length===0?(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.noneSaved`)}):(0,$.jsx)($.Fragment,{children:p.map(n=>(0,$.jsx)(Fr,{label:n.label,copyClassName:`truncate`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:n.lastUsedAt?e(`settings.openchamber.passkeys.item.lastUsed`,{time:Nf(n.lastUsedAt,e(`settings.openchamber.passkeys.time.neverUsed`),t)}):e(`settings.openchamber.passkeys.item.added`,{time:Nf(n.createdAt,e(`settings.openchamber.passkeys.time.neverUsed`),t)})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void S(n.id),disabled:c===n.id,className:`!font-normal text-muted-foreground hover:text-foreground`,children:c===n.id?e(`settings.openchamber.passkeys.actions.removing`):e(`settings.common.actions.delete`)})]})},n.id))}),_&&(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:_})})]})},Ff=e=>mt(e)||{providerId:``,modelId:``},If=()=>{let{t:e}=ke(),t=G(e=>e.setProvider),n=G(e=>e.setModel),r=G(e=>e.setAgent),i=G(e=>e.setCurrentVariant),a=G(e=>e.setSettingsDefaultModel),o=G(e=>e.setSettingsDefaultVariant),s=G(e=>e.setSettingsDefaultAgent),c=u(e=>e.showDeletionDialog),l=u(e=>e.setShowDeletionDialog),d=G(e=>e.providers),[f,p]=Q.useState(),[m,h]=Q.useState(),[g,_]=Q.useState(),[v,y]=Q.useState(!0),b=Q.useMemo(()=>Ff(f),[f]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=U()?.settings;if(t)try{let n=(await t.load())?.settings;if(n){let t=n;e={defaultModel:typeof n.defaultModel==`string`?n.defaultModel:void 0,defaultVariant:typeof t.defaultVariant==`string`?t.defaultVariant:void 0,defaultAgent:typeof n.defaultAgent==`string`?n.defaultAgent:void 0}}}catch{}}if(!e){let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}if(e){let t=typeof e.defaultModel==`string`&&e.defaultModel.trim().length>0?e.defaultModel.trim():void 0,n=typeof e.defaultVariant==`string`&&e.defaultVariant.trim().length>0?e.defaultVariant.trim():void 0,r=typeof e.defaultAgent==`string`&&e.defaultAgent.trim().length>0?e.defaultAgent.trim():void 0;t!==void 0&&p(t),n!==void 0&&h(n),r!==void 0&&_(r)}}catch(e){console.warn(`Failed to load defaults settings:`,e)}finally{y(!1)}})()},[]);let x=Q.useCallback(async(e,r)=>{let s=e&&r?`${e}/${r}`:void 0;p(s),h(void 0),o(void 0),i(void 0),a(s),e&&r&&d.find(t=>t.id===e)&&(t(e),n(r));try{await V({defaultModel:s??``,defaultVariant:``});let e=await L(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultModel:s})});e.ok||console.warn(`Failed to save default model to server:`,e.status,e.statusText)}catch(e){console.warn(`Failed to save default model:`,e)}},[d,i,n,t,a,o]),S=`__default__`,C=Q.useCallback(t=>t===S?e(`settings.openchamber.defaults.option.default`):t.charAt(0).toUpperCase()+t.slice(1),[e]),w=Q.useCallback(async e=>{let t=e===S?void 0:e||void 0;h(t),o(t),i(t);try{await V({defaultVariant:t??``})}catch(e){console.warn(`Failed to save default variant:`,e)}},[i,o]),T=Q.useCallback(async e=>{let t=e||void 0;_(t),s(t),e&&r(e);try{await V({defaultAgent:t??``})}catch(e){console.warn(`Failed to save default agent:`,e)}},[r,s]),E=Q.useMemo(()=>{if(!b.providerId||!b.modelId)return[];let e=d.find(e=>e.id===b.providerId)?.models.find(e=>e.id===b.modelId)?.variants;return e?Object.keys(e):[]},[b.modelId,b.providerId,d]),D=E.length>0;return Q.useEffect(()=>{!D&&m&&(h(void 0),o(void 0),i(void 0),V({defaultVariant:``}).catch(()=>{}))},[m,i,o,D]),v?null:(0,$.jsxs)(Z,{label:e(`settings.openchamber.defaults.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.openchamber.defaults.summaryPrefix`),` `,b.providerId?(0,$.jsxs)(`span`,{className:`text-foreground`,children:[b.providerId,`/`,b.modelId,D?` (${m??e(`settings.openchamber.defaults.option.defaultLowercase`)})`:``]}):(0,$.jsx)(`span`,{className:`text-foreground`,children:e(`settings.openchamber.defaults.summaryOpenCodeDefault`)}),g&&(0,$.jsxs)($.Fragment,{children:[` / `,(0,$.jsx)(`span`,{className:`text-foreground`,children:g})]})]}),children:[(0,$.jsx)(Fr,{itemId:`sessions.default-model`,label:e(`settings.openchamber.defaults.field.defaultModel`),children:(0,$.jsx)(kn,{providerId:b.providerId,modelId:b.modelId,onChange:x,className:`oc-settings-inline-value`})}),(0,$.jsx)(Fr,{itemId:`sessions.default-thinking`,label:e(`settings.openchamber.defaults.field.defaultThinking`),children:(0,$.jsxs)(an,{value:m??S,onValueChange:w,disabled:!D,children:[(0,$.jsx)(tn,{className:`w-fit min-w-[120px]`,children:(0,$.jsx)(cn,{placeholder:e(`settings.openchamber.defaults.field.thinkingPlaceholder`),children:C(m??S)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:S,children:e(`settings.openchamber.defaults.option.default`)}),E.map(e=>(0,$.jsx)($t,{value:e,children:C(e)},e))]})]})}),(0,$.jsx)(Fr,{itemId:`sessions.default-agent`,label:e(`settings.openchamber.defaults.field.defaultAgent`),children:(0,$.jsx)(xn,{agentName:g||``,onChange:T,className:`oc-settings-inline-value`})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.deletion-dialog`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":c,onClick:()=>l(!c),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(!c))},children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.defaults.field.showDeletionDialog`)})}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(Qt,{checked:c,onChange:l,ariaLabel:e(`settings.openchamber.defaults.field.showDeletionDialogAria`)})})]})]})},Lf=`You are generating a Conventional Commits subject line from the diffs of the selected files.`,Rf=[`You are a title generator. Output ONLY a thread title.`,`Name the main subject of the work.`,`Keep that subject across follow-ups, polish, commit, push, tidy, and review.`,`Switch only when the user clearly starts a different topic.`,`One line, ≤50 characters, no explanation.`,`Prefer ≤6 words or ≤6 CJK characters. No modifiers. No verbs.`,`Use the language of the user messages.`,`Keep technical terms, numbers, filenames, and HTTP codes exact.`,`Never include tool names, summarizing, or generating.`,`Always output a meaningful title.`].join(`
|
|
25
|
-
`),zf=()=>{let{t:e}=ke(),{currentTheme:t}=ur(),n=G(e=>e.providers),[r,i]=Q.useState(`provider`),[a,o]=Q.useState(``),[s,c]=Q.useState(``),[l,u]=Q.useState(``),[d,f]=Q.useState(``),[p,m]=Q.useState(!1),[h,g]=Q.useState(Lf),[_,v]=Q.useState(Rf),[y,b]=Q.useState(null),[x,S]=Q.useState(!0),[C,w]=Q.useState(!1),T=Q.useMemo(()=>[ii(t,{syntaxColors:!1})],[t]);Q.useEffect(()=>{let e=!0;return(async()=>{try{let t=null,n=U()?.settings;if(n){let e=(await n.load())?.settings;e&&(t=e)}if(!t){let e=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(t=await e.json())}if(!e||!t)return;t.summaryModelMode&&i(t.summaryModelMode),typeof t.summaryProviderID==`string`&&o(t.summaryProviderID),typeof t.summaryModelID==`string`&&c(t.summaryModelID),typeof t.summaryCustomBaseURL==`string`&&u(t.summaryCustomBaseURL),typeof t.hasSummaryCustomAPIToken==`boolean`&&m(t.hasSummaryCustomAPIToken),g(t.summaryCommitPrompt??Lf),v(t.summarySessionTitlePrompt??Rf)}catch(e){console.warn(`Failed to load summary settings:`,e)}finally{e&&S(!1)}})(),()=>{e=!1}},[]),Q.useEffect(()=>{let e=!0;return(async()=>{try{let t=await L(`/api/small-model`,{method:`GET`,headers:{Accept:`application/json`}}),n=await t.json().catch(()=>null);if(!t.ok||!n?.callableModels||typeof n.callableModels!=`object`)throw Error(`Summary provider capabilities are unavailable`);let r=Object.fromEntries(Object.entries(n.callableModels).map(([e,t])=>[e,Array.isArray(t)?t.filter(e=>typeof e==`string`):[]]).filter(([,e])=>e.length>0));e&&b(r)}catch{e&&b({})}})(),()=>{e=!1}},[]);let E=Q.useMemo(()=>n.find(e=>e.id===`openai`)??n[0],[n]);Q.useEffect(()=>{!a&&E?.id&&o(E.id)},[E?.id,a]),Q.useEffect(()=>{if(!y)return;let e=Object.keys(y);if(e.length===0)return;let t=y[a]?a:y.openai?`openai`:e[0],n=y[t]??[],r=n.includes(s)?s:n[0]??``;t!==a&&o(t),r!==s&&c(r)},[y,s,a]);let D=Q.useCallback(async()=>{w(!0);try{let e={summaryModelMode:r,summaryProviderID:a.trim(),summaryModelID:s.trim(),summaryCustomBaseURL:l,summaryCommitPrompt:h,summarySessionTitlePrompt:_};d.trim()&&(e.summaryCustomAPIToken=d),await V(e),d.trim()&&m(!0),f(``)}catch(e){console.warn(`Failed to save summary settings:`,e)}finally{w(!1)}},[h,d,l,s,r,a,_]),O=Q.useCallback(async()=>{w(!0);try{await V({summaryCustomAPIToken:``}),f(``),m(!1)}catch(e){console.warn(`Failed to clear summary API token:`,e)}finally{w(!1)}},[]);return x?null:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(Z,{label:e(`settings.openchamber.defaults.summary.title`),description:e(`settings.openchamber.defaults.summary.description`),children:[(0,$.jsx)(Fr,{itemId:`summary-ai.configuration`,label:e(`settings.openchamber.defaults.summary.modelSourceTitle`),className:`oc-settings-summary-model-source-row`,controlClassName:`items-start`,children:(0,$.jsxs)(`div`,{role:`radiogroup`,"aria-label":e(`settings.openchamber.defaults.summary.modelSourceAria`),className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,$.jsx)(Xn,{checked:r===`provider`,onChange:()=>i(`provider`),ariaLabel:e(`settings.openchamber.defaults.summary.provider`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:r===`provider`?`typography-ui-label text-foreground`:`typography-ui-label text-foreground/50`,children:e(`settings.openchamber.defaults.summary.provider`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.openchamber.defaults.summary.providerDescription`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,$.jsx)(Xn,{checked:r===`custom`,onChange:()=>i(`custom`),ariaLabel:e(`settings.openchamber.defaults.summary.custom`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:r===`custom`?`typography-ui-label text-foreground`:`typography-ui-label text-foreground/50`,children:e(`settings.openchamber.defaults.summary.custom`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.openchamber.defaults.summary.customDescription`)})]})]})]})}),r===`provider`?(0,$.jsx)(Fr,{label:e(`settings.openchamber.defaults.summary.providerModel`),children:y===null?null:Object.keys(y).length>0?(0,$.jsx)(kn,{providerId:a,modelId:s,onChange:(e,t)=>{o(e),c(t)},allowedProviderIds:Object.keys(y),allowedModelIdsByProvider:y,className:`oc-settings-inline-value`}):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.defaults.summary.providerUnavailable`)})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fr,{label:e(`settings.openchamber.defaults.summary.baseUrl`),children:(0,$.jsx)(ln,{value:l,onChange:e=>u(e.target.value),placeholder:e(`settings.openchamber.defaults.summary.baseUrlPlaceholder`)})}),(0,$.jsx)(Fr,{label:e(`settings.openchamber.defaults.summary.modelId`),children:(0,$.jsx)(ln,{value:s,onChange:e=>c(e.target.value),placeholder:e(`settings.openchamber.defaults.summary.modelIdPlaceholder`)})}),(0,$.jsx)(Fr,{label:e(`settings.openchamber.defaults.summary.apiToken`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(ln,{type:`password`,value:d,onChange:e=>f(e.target.value),placeholder:e(p?`settings.openchamber.defaults.summary.apiTokenStored`:`settings.openchamber.defaults.summary.apiTokenPlaceholder`),className:`max-w-xl`}),p?(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void O(),disabled:C,children:e(`settings.openchamber.defaults.summary.clearToken`)}):null]})})]})]}),(0,$.jsxs)(Z,{label:e(`settings.openchamber.defaults.summary.promptTitle`),children:[(0,$.jsx)(Fr,{label:e(`settings.openchamber.defaults.summary.commitPrompt`),description:e(`settings.openchamber.defaults.summary.commitPromptDescription`),className:`oc-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(`div`,{className:`h-64 w-full overflow-hidden bg-background`,children:(0,$.jsx)(Tr,{value:h,onChange:g,extensions:T,className:`h-full`,enableSearch:!0})})}),(0,$.jsx)(Fr,{label:e(`settings.openchamber.defaults.summary.sessionTitlePrompt`),description:e(`settings.openchamber.defaults.summary.sessionTitlePromptDescription`),className:`oc-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(`div`,{className:`h-64 w-full overflow-hidden bg-background`,children:(0,$.jsx)(Tr,{value:_,onChange:v,extensions:T,className:`h-full`,enableSearch:!0})})}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center justify-end`,children:(0,$.jsx)(Y,{size:`sm`,onClick:()=>void D(),disabled:C,children:e(C?`settings.common.actions.saving`:`settings.openchamber.defaults.summary.save`)})})]})]})},Bf={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`}},Vf={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`},Hf=()=>{let{t:e}=ke(),t=Q.useMemo(()=>w(),[]),n=Q.useMemo(()=>m(),[]),r=Q.useMemo(()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,[]),i=!t&&!n&&!r,a=u(e=>e.nativeNotificationsEnabled),o=u(e=>e.setNativeNotificationsEnabled),s=u(e=>e.notificationMode),c=u(e=>e.setNotificationMode),l=u(e=>e.notifyOnSubtasks),d=u(e=>e.setNotifyOnSubtasks),f=u(e=>e.notifyOnCompletion),p=u(e=>e.setNotifyOnCompletion),h=u(e=>e.notifyOnError),g=u(e=>e.setNotifyOnError),_=u(e=>e.notifyOnQuestion),v=u(e=>e.setNotifyOnQuestion),y=u(e=>e.notificationTemplates),b=u(e=>e.setNotificationTemplates),[x,S]=Q.useState(`default`),[C,T]=Q.useState(!1),[E,D]=Q.useState(!1),[O,k]=Q.useState(!1);Q.useEffect(()=>{if(!i){T(!1),D(!1);return}typeof Notification<`u`&&S(Notification.permission);let e=typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window;T(e),(async()=>{if(!e){D(!1);return}try{let e=await navigator.serviceWorker.getRegistration();if(!e){D(!1);return}let t=await e.pushManager.getSubscription();D(!!t)}catch{D(!1)}})()},[i]);let A=async n=>{if(t){o(n);return}if(!i){o(n);return}if(n&&typeof Notification<`u`&&Notification.permission==="default")try{let t=await Notification.requestPermission();S(t),t===`granted`?o(!0):K.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.description`)})}catch(t){console.error(`Failed to request notification permission:`,t),K.error(e(`settings.notifications.page.toast.requestPermissionFailed`))}else o(!!(n&&x===`granted`))},j=t||n||r||i&&typeof Notification<`u`&&Notification.permission===`granted`,M=(e,t,n)=>{b({...y,[e]:{...y[e],[t]:n}})},N=e=>{let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r},P=async(e,t,n)=>{let r=null,i=new Promise((e,i)=>{r=setTimeout(()=>{i(Error(n))},t)});try{return await Promise.race([e,i])}finally{r&&clearTimeout(r)}},F=async e=>{if(e.active)return;let t=e.installing||e.waiting;t&&t.state!==`activated`&&await P(new Promise(e=>{let n=()=>{t.state===`activated`&&(t.removeEventListener(`statechange`,n),e())};t.addEventListener(`statechange`,n),n()}),15e3,`Service worker activation timed out`)},I=async()=>{if(typeof navigator.serviceWorker.register!=`function`)throw Error(`navigator.serviceWorker.register unavailable`);let e=[{label:`no-options`,opts:null},{label:`scope-root`,opts:{scope:`/`}},{label:`type-classic`,opts:{type:`classic`}},{label:`type-classic-scope`,opts:{type:`classic`,scope:`/`}},{label:`updateViaCache-none`,opts:{type:`classic`,updateViaCache:`none`,scope:`/`}}],t=null;for(let n of e)try{let e=n.opts?navigator.serviceWorker.register(`/sw.js`,n.opts):navigator.serviceWorker.register(`/sw.js`);return await P(e,1e4,`Service worker registration timed out (${n.label})`)}catch(e){t=e}throw t instanceof Error?t:Error(`Service worker registration failed`)},L=async()=>{if(!(`serviceWorker`in navigator))throw Error(`Service worker not supported`);let e=await navigator.serviceWorker.getRegistration();if(e)return e;let t=await I();try{await t.update()}catch{}return await F(t),t},R=e=>{let t=e,n=[`type=${typeof e}`,`toString=${String(e)}`,`name=${String(t?.name??``)}`,`message=${String(t?.message??``)}`],r=``;try{r=JSON.stringify(e)}catch{}return{summary:n.filter(Boolean).join(` | `),json:r,stack:typeof t?.stack==`string`?t.stack:``}},z=async()=>{let t=U();if(!t?.notifications){K.error(e(`settings.notifications.page.toast.notificationsApiUnavailable`));return}try{await t.notifications.notifyAgentCompletion({title:e(`settings.notifications.page.testNotification.title`),body:e(`settings.notifications.page.testNotification.body`),tag:`openchamber-test`})?K.success(e(`settings.notifications.page.toast.testNotificationSent`)):K.error(e(`settings.notifications.page.toast.testNotificationFailed`))}catch(t){console.error(`Test notification failed:`,t),K.error(e(`settings.notifications.page.toast.testNotificationFailed`))}},B=async()=>{if(!C){K.error(e(`settings.notifications.page.toast.pushUnsupported`));return}let t=U();if(!t?.push){K.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}k(!0);try{if(typeof Notification<`u`&&Notification.permission==="default"){let t=await Notification.requestPermission();if(S(t),t!==`granted`){K.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}}if(typeof Notification<`u`&&Notification.permission!==`granted`){K.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}let n=await t.push.getVapidPublicKey();if(!n?.publicKey){K.error(e(`settings.notifications.page.toast.pushKeyLoadFailed`));return}let r=await L();await F(r);let i=await r.pushManager.getSubscription();if(!(`pushManager`in r)||!r.pushManager)throw Error(`PushManager unavailable (requires installed PWA + iOS 16.4+)`);let a=(i??await P(r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:N(n.publicKey)}),15e3,`Push subscription timed out`)).toJSON(),o=a.keys;if(!a.endpoint||!o?.p256dh||!o.auth)throw Error(`Push subscription missing keys`);if(!(await P(t.push.subscribe({endpoint:a.endpoint,keys:{p256dh:o.p256dh,auth:o.auth},origin:typeof window<`u`?window.location.origin:void 0,platform:xe()}),15e3,`Push subscribe request timed out`))?.ok){K.error(e(`settings.notifications.page.toast.enableBackgroundFailed`));return}D(!0),K.success(e(`settings.notifications.page.toast.backgroundEnabled`))}catch(t){console.error(`[Push] Enable failed:`,t);let n=R(t);K.error(e(`settings.notifications.page.toast.enableBackgroundFailed`),{description:n.summary})}finally{k(!1)}},V=async()=>{if(!C){D(!1);return}let t=U();if(!t?.push){K.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}k(!0);try{let n=await(await L()).pushManager.getSubscription();if(!n){D(!1);return}let r=n.endpoint;await n.unsubscribe(),await t.push.unsubscribe({endpoint:r}),D(!1),K.success(e(`settings.notifications.page.toast.backgroundDisabled`))}finally{k(!1)}},H=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`block`,children:e(`settings.notifications.page.delivery.browserPermissionHint`)}),x===`denied`?(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--status-error)]`,children:e(`settings.notifications.page.delivery.permissionDenied`)}):null,x===`granted`&&!a?(0,$.jsx)(`span`,{className:`mt-1 block`,children:e(`settings.notifications.page.delivery.permissionGrantedButDisabled`)}):null]}):n?e(`settings.notifications.page.delivery.vscodeHint`):void 0;return(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(Z,{label:e(`settings.notifications.page.delivery.title`),description:H,className:`oc-settings-detail-group`,children:[(0,$.jsx)(Vr,{itemId:`notifications.delivery`,checked:a&&j,onChange:e=>{A(e)},label:e(`settings.notifications.page.delivery.enableLabel`),ariaLabel:e(`settings.notifications.page.delivery.enableAria`)}),a&&j&&!r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vr,{checked:s===`always`,onChange:e=>c(e?`always`:`hidden-only`),label:e(`settings.notifications.page.delivery.focusedLabel`),ariaLabel:e(`settings.notifications.page.delivery.focusedAria`)}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center`,children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void z(),children:e(`settings.notifications.page.delivery.testAction`)})})]}):null]}),a&&j?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:e(`settings.notifications.page.events.title`),className:`oc-settings-detail-group`,children:[(0,$.jsx)(Vr,{itemId:`notifications.events`,checked:f,onChange:p,label:e(`settings.notifications.page.events.completionLabel`),ariaLabel:e(`settings.notifications.page.events.completionAria`)}),(0,$.jsx)(Vr,{checked:l,onChange:d,label:e(`settings.notifications.page.events.subtaskLabel`),ariaLabel:e(`settings.notifications.page.events.subtaskAria`)}),(0,$.jsx)(Vr,{checked:h,onChange:g,label:e(`settings.notifications.page.events.errorLabel`),ariaLabel:e(`settings.notifications.page.events.errorAria`)}),(0,$.jsx)(Vr,{checked:_,onChange:v,label:e(`settings.notifications.page.events.questionLabel`),ariaLabel:e(`settings.notifications.page.events.questionAria`)})]}),r?null:(0,$.jsx)(Z,{label:e(`settings.notifications.page.template.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.notifications.page.template.variablesLabel`),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{project_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{worktree}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{branch}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{session_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{agent_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{model_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{last_message}`})]}),className:`oc-settings-detail-group`,children:[`completion`,`subtask`,`error`,`question`].map(t=>(0,$.jsxs)(`div`,{className:`oc-settings-group-row`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label block font-normal text-foreground`,children:e(Vf[t])}),(0,$.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 md:grid-cols-2 md:gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.title`)}),(0,$.jsx)(ln,{value:y[t].title,onChange:e=>M(t,`title`,e.target.value),className:`w-full`,placeholder:e(Bf[t].titleKey)})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.message`)}),(0,$.jsx)(ln,{value:y[t].message,onChange:e=>M(t,`message`,e.target.value),className:`w-full`,placeholder:e(Bf[t].messageKey)})]})]})]},t))})]}):null,i?(0,$.jsx)(Z,{label:e(`settings.notifications.page.push.title`),className:`oc-settings-detail-group`,children:(0,$.jsxs)(`div`,{"data-settings-item":`notifications.push`,className:`oc-settings-group-row flex items-center gap-2`,children:[(0,$.jsx)(Qt,{checked:C?E:!1,disabled:!C||O,onChange:e=>{e?B():V()},ariaLabel:e(`settings.notifications.page.push.enableAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label`,C?`text-foreground`:`text-muted-foreground`),children:e(`settings.notifications.page.push.enableLabel`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(C?`settings.notifications.page.push.supportedHint`:`settings.notifications.page.push.unsupportedHint`)})]}),O&&(0,$.jsx)(`div`,{className:`pt-0.5 text-muted-foreground`,children:(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.notifications.page.push.loadingAria`)})})]})}):null]})},Uf=e=>{if(!e)return;e.pause();let{src:t}=e;t.startsWith(`blob:`)&&URL.revokeObjectURL(t),e.removeAttribute(`src`),e.load()},Wf=[{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`}],Gf=e=>{let t=(0,Ei.c)(8),{value:n,label:r}=e,i=`${r}: ${n}/5`,a=`${n/5*100}%`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`span`,{className:`h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]`,"aria-hidden":`true`,children:(0,$.jsx)(`span`,{className:`block h-full rounded-full bg-[var(--primary-base)]`,style:{width:a}})}),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`typography-ui-compact text-muted-foreground`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==i||t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,title:i,children:[o,s]}),t[4]=i,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},Kf=({selectedModelId:e,onSelect:t})=>{let{t:n}=ke(),r=(0,Q.useCallback)(e=>n(e),[n]),[i,a]=(0,Q.useState)(new Map),[o,s]=(0,Q.useState)(null),c=(0,Q.useCallback)(async()=>{try{let e=await L(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json();Array.isArray(t?.models)&&a(new Map(t.models.map(e=>[e.id,e])))}catch{}},[]);(0,Q.useEffect)(()=>{c()},[c]);let l=Array.from(i.values()).some(e=>e.downloading);(0,Q.useEffect)(()=>{if(!l)return;let e=setInterval(()=>{c()},2e3);return()=>clearInterval(e)},[l,c]);let u=async e=>{s(e);try{await L(`/api/dictation/models/${encodeURIComponent(e)}/download`,{method:`POST`}),await c()}catch{}finally{s(null)}},d=async e=>{s(e);try{await L(`/api/dictation/models/${encodeURIComponent(e)}`,{method:`DELETE`}),await c()}catch{}finally{s(null)}};return(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":n(`settings.voice.page.field.model`),className:`mt-1 w-full min-w-0 space-y-0`,children:Wf.map(a=>{let s=e===a.id,c=i.get(a.id)??null;return(0,$.jsxs)(`div`,{className:`flex w-full items-start gap-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`pt-0.5`,children:(0,$.jsx)(Xn,{checked:s,onChange:()=>t(a.id),ariaLabel:r(a.labelKey)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 cursor-pointer`,role:`button`,tabIndex:0,onClick:()=>t(a.id),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),t(a.id))},children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,s?`text-foreground`:`text-foreground/50`),children:r(a.labelKey)}),a.badgeKey?(0,$.jsx)(`span`,{className:`rounded px-1 text-[9px] font-medium uppercase leading-[14px] tracking-wide`,style:{backgroundColor:`var(--status-success-background)`,color:`var(--status-success)`,border:`1px solid var(--status-success-border)`},children:r(a.badgeKey)}):null]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-4 gap-y-0.5`,children:[(0,$.jsx)(Gf,{value:a.accuracy,label:n(`settings.voice.page.stt.meta.accuracy`)}),(0,$.jsx)(Gf,{value:a.speed,label:n(`settings.voice.page.stt.meta.speed`)}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:a.size})]}),c?.downloadError?(0,$.jsx)(`p`,{className:`mt-0.5 typography-meta text-[var(--status-error)]`,children:c.downloadError}):null]}),(0,$.jsx)(`div`,{className:`flex w-14 flex-shrink-0 items-center justify-end gap-1 pt-0.5`,children:c?.installed?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:o===a.id,onClick:()=>{d(a.id)},title:n(`settings.voice.page.stt.modelDelete`),"aria-label":n(`settings.voice.page.stt.modelDelete`),children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4`})}),(0,$.jsx)(J,{name:`checkbox-circle`,className:`h-4 w-4 flex-shrink-0 text-[var(--status-success)]`,"aria-label":n(`settings.voice.page.stt.modelInstalled`)})]}):c?.downloading?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof c.downloadProgress==`number`?`${c.downloadProgress}%`:``})]}):(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:o===a.id,onClick:()=>{u(a.id)},title:n(`settings.voice.page.stt.modelDownload`),"aria-label":n(`settings.voice.page.stt.modelDownload`),children:(0,$.jsx)(J,{name:`download`,className:`h-4 w-4`})})})]},a.id)})})},qf=[{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)`}],Jf=`kokoro-en-v0_19`,Yf=()=>{let{t:e}=ke(),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),a=(0,Q.useCallback)(async()=>{try{let e=await L(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json(),r=Array.isArray(t?.ttsModels)?t.ttsModels.find(e=>e.id===Jf):null;r&&n(r)}catch{}},[]);(0,Q.useEffect)(()=>{a()},[a]),(0,Q.useEffect)(()=>{if(!t?.downloading)return;let e=setInterval(()=>{a()},2e3);return()=>clearInterval(e)},[t?.downloading,a]);let o=async e=>{i(!0);try{await L(e===`POST`?`/api/dictation/models/${Jf}/download`:`/api/dictation/models/${Jf}`,{method:e}),await a()}catch{}finally{i(!1)}};return t?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`Kokoro`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:`305 MB`}),t.installed?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{name:`checkbox-circle`,className:`h-4 w-4 text-[var(--status-success)]`,"aria-label":e(`settings.voice.page.stt.modelInstalled`)}),(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:r,onClick:()=>{o(`DELETE`)},title:e(`settings.voice.page.stt.modelDelete`),"aria-label":e(`settings.voice.page.stt.modelDelete`),children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4`})})]}):t.downloading?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof t.downloadProgress==`number`?`${t.downloadProgress}%`:``})]}):(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:r,onClick:()=>{o(`POST`)},title:e(`settings.voice.page.stt.modelDownload`),"aria-label":e(`settings.voice.page.stt.modelDownload`),children:(0,$.jsx)(J,{name:`download`,className:`h-4 w-4`})}),t.downloadError?(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t.downloadError}):null]}):null},Xf=[{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`}],Zf=()=>{let{t:e}=ke(),{isMobile:t}=dr(),n=G(e=>e.voiceProvider),r=G(e=>e.setVoiceProvider),i=G(e=>e.speechRate),a=G(e=>e.setSpeechRate),o=G(e=>e.speechPitch),s=G(e=>e.setSpeechPitch),c=G(e=>e.speechVolume),l=G(e=>e.setSpeechVolume),u=G(e=>e.sayVoice),d=G(e=>e.setSayVoice),f=G(e=>e.localTtsVoiceId),p=G(e=>e.setLocalTtsVoiceId),{speak:m,stop:h,isPlaying:g,error:_}=Mn(),v=(0,Q.useCallback)(()=>{if(g){h();return}let t=qf.find(e=>e.id===f)?.label??String(f);m(e(`settings.voice.page.preview.voiceLine`,{voiceName:t}),{speakerId:f,speed:G.getState().speechRate})},[g,f,m,h,e]),y=G(e=>e.browserVoice),b=G(e=>e.setBrowserVoice),x=G(e=>e.openaiVoice),S=G(e=>e.setOpenaiVoice),C=G(e=>e.openaiApiKey),w=G(e=>e.setOpenaiApiKey),T=G(e=>e.openaiCompatibleUrl),E=G(e=>e.setOpenaiCompatibleUrl),D=G(e=>e.openaiCompatibleApiKey),O=G(e=>e.setOpenaiCompatibleApiKey),k=G(e=>e.openaiCompatibleVoice),A=G(e=>e.setOpenaiCompatibleVoice),j=G(e=>e.openaiCompatibleTtsModel),M=G(e=>e.setOpenaiCompatibleTtsModel),N=G(e=>e.showMessageTTSButtons),P=G(e=>e.ttsInputMode),F=G(e=>e.setTtsInputMode),I=G(e=>e.sttProvider),R=G(e=>e.setSttProvider),z=G(e=>e.sttServerUrl),B=G(e=>e.setSttServerUrl),V=G(e=>e.sttApiKey),H=G(e=>e.setSttApiKey),ee=G(e=>e.sttModel),U=G(e=>e.setSttModel),te=G(e=>e.sttLocalModel),W=G(e=>e.setSttLocalModel),ne=G(e=>e.sttLanguage),re=G(e=>e.setSttLanguage),ie=G(e=>e.setShowMessageTTSButtons),ae=G(e=>e.dictationEnabled),oe=G(e=>e.setDictationEnabled),[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)([]),[de,fe]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(!1),[_e,ve]=(0,Q.useState)(!1),[ye,be]=(0,Q.useState)(null),[xe,Se]=(0,Q.useState)(!1),[Ce,we]=(0,Q.useState)(null),[Te,Ee]=(0,Q.useState)([]),[De,Oe]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>((async()=>{let e=await Bn.waitForVoices();Ee(e)})(),`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=()=>{Ee(window.speechSynthesis.getVoices())}),()=>{`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);let Ae=(0,Q.useMemo)(()=>Te.filter(e=>e.lang).sort((e,t)=>{let n=e.lang.startsWith(`en`),r=t.lang.startsWith(`en`);if(n&&!r)return-1;if(!n&&r)return 1;let i=e.lang.localeCompare(t.lang);return i===0?e.name.localeCompare(t.name):i}),[Te]),je=(0,Q.useCallback)(()=>{if(De){Bn.cancelSpeech(),Oe(!1);return}let t=Te.find(e=>e.name===y),n=t?.name??e(`settings.voice.page.preview.browserVoiceFallback`),r=e(`settings.voice.page.preview.voiceLine`,{voiceName:n});Oe(!0);let a=new SpeechSynthesisUtterance(r);a.rate=i,a.pitch=o,a.volume=c,t&&(a.voice=t,a.lang=t.lang),a.onend=()=>Oe(!1),a.onerror=()=>Oe(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(a)},[y,Te,i,o,c,De,e]);(0,Q.useEffect)(()=>()=>{De&&Bn.cancelSpeech()},[De]),(0,Q.useEffect)(()=>{if(!N||n!==`openai`&&n!==`openai-compatible`){ge(C.trim().length>0);return}(async()=>{try{let e=(await(await L(`/api/tts/status`)).json()).available,t=C.trim().length>0;ge(e||t)}catch{ge(C.trim().length>0)}})()},[C,N,n]),(0,Q.useEffect)(()=>{if(!N){ce(!1),ue([]);return}L(`/api/tts/say/status`).then(e=>e.json()).then(e=>{if(ce(e.available),e.voices){let t=e.voices.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).sort((e,t)=>e.name.localeCompare(t.name));ue(t)}}).catch(()=>{ce(!1)})},[N]);let Me=(0,Q.useCallback)(async()=>{if(pe){Uf(pe),me(null),fe(!1);return}fe(!0);let t=null;try{let n=await L(`/api/tts/say/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.voiceLine`,{voiceName:u}),voice:u,rate:Math.round(100+(i-.5)*200)})});if(!n.ok)throw Error(`Preview failed`);let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{Uf(t),me(null),fe(!1)},t.onerror=()=>{Uf(t),me(null),fe(!1)},me(t),await t.play()}catch{Uf(t),me(null),fe(!1)}},[u,i,pe,e]);(0,Q.useEffect)(()=>()=>{Uf(pe)},[pe]);let Ne=(0,Q.useCallback)(async()=>{if(ye){Uf(ye),be(null),ve(!1);return}ve(!0);let t=null;try{let n=await L(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.voiceLine`,{voiceName:x}),voice:x,speed:i,apiKey:C||void 0})});if(!n.ok){let e=await n.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${n.status}`)}let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{Uf(t),be(null),ve(!1)},t.onerror=()=>{Uf(t),be(null),ve(!1)},be(t),await t.play()}catch{Uf(t),be(null),ve(!1)}},[x,i,ye,C,e]);(0,Q.useEffect)(()=>()=>{Uf(ye)},[ye]);let Pe=(0,Q.useCallback)(async()=>{if(Ce){Uf(Ce),we(null),Se(!1);return}if(!T.trim())return;Se(!0);let t=null;try{let n=await L(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.customServerLine`),voice:k,model:j||void 0,speed:i,baseURL:T,apiKey:D||void 0})});if(!n.ok){let e=await n.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${n.status}`)}let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{Uf(t),we(null),Se(!1)},t.onerror=()=>{Uf(t),we(null),Se(!1)},we(t),await t.play()}catch{Uf(t),we(null),Se(!1)}},[T,k,j,D,i,Ce,e]);(0,Q.useEffect)(()=>()=>{Uf(Ce)},[Ce]);let Fe=`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(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.page.voice.title`)})}),(0,$.jsx)(`div`,{"data-settings-item":`voice.playback`,children:(0,$.jsxs)(Z,{label:e(`settings.voice.page.section.playbackAndSummary`),children:[(0,$.jsx)(Fr,{label:e(`settings.voice.page.field.messageReadAloudButton`),children:(0,$.jsx)(Qt,{checked:N,onChange:ie,ariaLabel:e(`settings.voice.page.field.messageReadAloudButtonAria`)})}),N&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.voice.page.field.provider`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`ul`,{className:`space-y-1`,children:[(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.browser`)}),` `,e(`settings.voice.page.tooltip.browser`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.local`)}),` `,e(`settings.voice.page.tooltip.localTts`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:`OpenAI:`}),` `,e(`settings.voice.page.tooltip.openai`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.custom`)}),` `,e(`settings.voice.page.tooltip.custom`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.say`)}),` `,e(`settings.voice.page.tooltip.say`)]})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`browser`,onClick:()=>r(`browser`),className:`!font-normal`,children:e(`settings.voice.page.provider.browser`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`local`,onClick:()=>r(`local`),className:`!font-normal`,children:e(`settings.voice.page.provider.local`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`openai`,onClick:()=>r(`openai`),className:`!font-normal`,children:`OpenAI`}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`openai-compatible`,onClick:()=>r(`openai-compatible`),className:`!font-normal`,children:e(`settings.voice.page.provider.custom`)}),se&&(0,$.jsxs)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`say`,onClick:()=>r(`say`),className:`!font-normal`,children:[(0,$.jsx)(J,{name:`apple`,className:`w-3.5 h-3.5 mr-0.5`}),e(`settings.voice.page.provider.say`)]})]})}),n===`openai`&&(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!he&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.apiKey`)}),(0,$.jsx)(`span`,{className:q(`typography-meta ml-2`,he?`text-muted-foreground`:`text-[var(--status-error)]/80`),children:e(he&&!C?`settings.voice.page.field.apiKeyHintUsingConfig`:he?`settings.voice.page.field.apiKeyHintProvide`:`settings.voice.page.field.apiKeyHintRequired`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(ln,{type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),C&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>w(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),n===`openai-compatible`&&(0,$.jsxs)(`div`,{className:`py-1.5 space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!T.trim()&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.serverUrl`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.serverUrlHint`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(ln,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`http://localhost:8880/v1`,className:`w-full pr-8`}),T&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>E(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`API Key`}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:`Optional`}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(ln,{type:`password`,value:D,onChange:e=>O(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),D&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>O(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.model`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:(0,$.jsx)(ln,{type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:`speaches-ai/Kokoro-82M-v1.0-ONNX`,className:`w-full`})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.voice`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.voiceIdentifierHint`)}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2`,children:[(0,$.jsx)(`div`,{className:`relative max-w-xs flex-1`,children:(0,$.jsx)(ln,{type:`text`,value:k,onChange:e=>A(e.target.value),placeholder:`af_sky`,className:`w-full`})}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:Pe,title:e(`settings.voice.page.actions.preview`),disabled:!T.trim(),children:xe?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})})]})]})]}),n===`local`&&(0,$.jsx)(Yf,{}),(0,$.jsxs)(Fr,{label:e(`settings.voice.page.field.voice`),children:[n===`local`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(an,{value:String(f),onValueChange:e=>p(Number.parseInt(e,10)||0),children:[(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`),children:e=>qf.find(t=>String(t.id)===e)?.label??e})}),(0,$.jsx)(nn,{children:qf.map(e=>(0,$.jsx)($t,{value:String(e.id),children:e.label},e.id))})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:v,title:e(`settings.voice.page.actions.preview`),children:g?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})}),_?(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:_}):null]}),n===`openai`&&he&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(an,{value:x,onValueChange:S,children:[(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,$.jsx)(nn,{children:Xf.map(e=>(0,$.jsx)($t,{value:e.value,children:e.label},e.value))})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:Ne,title:e(`settings.voice.page.actions.preview`),children:_e?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})})]}),n===`openai-compatible`&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.voice.page.field.configuredAbove`)}),n===`say`&&se&&le.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(an,{value:u,onValueChange:d,children:[(0,$.jsx)(tn,{className:`w-fit`,children:(0,$.jsx)(cn,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,$.jsx)(nn,{children:le.map(e=>(0,$.jsx)($t,{value:e.name,children:e.name},e.name))})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:Me,title:e(`settings.voice.page.actions.preview`),children:de?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})})]}),n===`browser`&&Ae.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(an,{value:y||`$auto`,onValueChange:e=>b(e===`$auto`?``:e),children:[(0,$.jsx)(tn,{className:`w-fit max-w-[200px]`,children:(0,$.jsx)(cn,{placeholder:e(`settings.voice.page.field.auto`)})}),(0,$.jsxs)(nn,{children:[(0,$.jsx)($t,{value:`$auto`,children:e(`settings.voice.page.field.auto`)}),Ae.map(e=>(0,$.jsxs)($t,{value:e.name,children:[e.name,` (`,e.lang,`)`]},e.name))]})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:je,title:e(`settings.voice.page.actions.preview`),children:De?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(Fr,{label:e(`settings.voice.page.field.speechRate`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:i,onChange:e=>a(Number(e.target.value)),className:Fe}),(0,$.jsx)(zr,{value:i,onValueChange:a,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,$.jsxs)(Fr,{label:e(`settings.voice.page.field.speechPitch`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:o,onChange:e=>s(Number(e.target.value)),className:Fe}),(0,$.jsx)(zr,{value:o,onValueChange:s,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,$.jsxs)(Fr,{label:e(`settings.voice.page.field.speechVolume`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:.1,value:c,onChange:e=>l(Number(e.target.value)),className:Fe}),t?(0,$.jsx)(zr,{value:Math.round(c*100),onValueChange:e=>l(e/100),min:0,max:100,step:10,className:`w-16 tabular-nums`}):(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right`,children:[Math.round(c*100),`%`]})]}),(0,$.jsx)(Fr,{label:e(`settings.voice.page.field.ttsInputMode`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":P===`sanitized`,onClick:()=>F(`sanitized`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeSanitized`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":P===`raw`,onClick:()=>F(`raw`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeRaw`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":P===`summarized`,onClick:()=>F(`summarized`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeSummarized`)})]})})]})]})}),(0,$.jsx)(`div`,{"data-settings-item":`voice.speech-recognition`,children:(0,$.jsxs)(Z,{label:e(`settings.voice.page.section.speechRecognition`),children:[(0,$.jsx)(Fr,{label:e(`settings.voice.page.field.enableVoiceInput`),children:(0,$.jsx)(Qt,{checked:ae,onChange:oe,ariaLabel:e(`settings.voice.page.field.enableVoiceInputAria`)})}),ae&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.voice.page.field.provider`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`ul`,{className:`space-y-1`,children:[(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.local`)}),` `,e(`settings.voice.page.tooltip.sttLocal`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.server`)}),` `,e(`settings.voice.page.tooltip.sttServer`)]})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":I===`local`,onClick:()=>R(`local`),className:`!font-normal`,children:e(`settings.voice.page.provider.local`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":I===`openai-compatible`,onClick:()=>R(`openai-compatible`),className:`!font-normal`,children:e(`settings.voice.page.provider.server`)})]})}),I===`local`&&(0,$.jsx)(Fr,{label:e(`settings.voice.page.field.model`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(Kf,{selectedModelId:te,onSelect:W})}),I===`openai-compatible`&&(0,$.jsxs)(`div`,{className:`oc-settings-group-row space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!z.trim()&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.serverUrl`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.sttServerUrlHint`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(ln,{type:`text`,value:z,onChange:e=>B(e.target.value),placeholder:`http://localhost:8001/v1`,className:`w-full pr-8`}),z&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>B(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`API Key`}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:`Optional`}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(ln,{type:`password`,value:V,onChange:e=>H(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),V&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>H(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.model`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:(0,$.jsx)(ln,{type:`text`,value:ee,onChange:e=>U(e.target.value),placeholder:`deepdml/faster-whisper-large-v3-turbo-ct2`,className:`w-full`})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.language`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.sttLanguageHint`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-[8rem]`,children:(0,$.jsx)(ln,{type:`text`,value:ne,onChange:e=>re(e.target.value),placeholder:`auto`,className:`w-full`})})]})]})]})]})})]})},Qf=()=>{let{t:e}=ke(),[t,n]=Q.useState(``),[r,i]=Q.useState(!0),[a,o]=Q.useState(!1),s=u(e=>e.showOpenCodeUpdateNotifications),c=u(e=>e.setShowOpenCodeUpdateNotifications);Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let r=await t.json().catch(()=>null);if(e||!r)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;n(i)}catch{}finally{e||i(!1)}})(),()=>{e=!0}},[]);let l=Q.useCallback(async()=>{if(!(typeof window>`u`)&&w())try{let e=await O();e.success&&e.path&&e.path.trim().length>0&&n(e.path.trim())}catch{}},[]),d=Q.useCallback(async()=>{o(!0);try{let n=t.trim(),r=n.length>=2&&(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))?n.slice(1,-1).trim():n;await V({opencodeBinary:r}),await We({message:e(`settings.openchamber.opencodeCli.actions.restartingOpenCode`),mode:`projects`,scopes:[`all`]})}finally{o(!1)}},[e,t]),f=Q.useCallback(e=>{c(e),V({showOpenCodeUpdateNotifications:e})},[c]);return(0,$.jsxs)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.openchamber.opencodeCli.title`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsxs)(dn,{sideOffset:8,className:`max-w-xs`,children:[e(`settings.openchamber.opencodeCli.tooltipPrefix`),` `,(0,$.jsx)(`code`,{className:`font-mono text-xs`,children:`opencode`}),e(`settings.openchamber.opencodeCli.tooltipSuffix`)]})]})]}),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.openchamber.opencodeCli.tipPrefix`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`OPENCODE_BINARY`}),` `,e(`settings.openchamber.opencodeCli.tipMiddle`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`~/.config/openchamber/settings.json`}),`.`]}),children:[(0,$.jsx)(Fr,{itemId:`sessions.opencode-binary`,label:e(`settings.openchamber.opencodeCli.field.binaryPath`),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2`,children:[(0,$.jsx)(ln,{value:t,onChange:e=>n(e.target.value),placeholder:e(`settings.openchamber.opencodeCli.field.binaryPathPlaceholder`),disabled:r||a,className:`h-7 min-w-0 flex-1 font-mono text-xs`}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,onClick:l,disabled:r||a||!w(),className:`h-7 w-7 p-0`,"aria-label":e(`settings.openchamber.opencodeCli.actions.browseAria`),title:e(`settings.openchamber.opencodeCli.actions.browse`),children:(0,$.jsx)(J,{name:`folder`,className:`h-4 w-4`})})]})}),(0,$.jsxs)(`label`,{"data-settings-item":`sessions.opencode-update-notifications`,className:`oc-settings-group-row oc-settings-split-row cursor-pointer`,children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.opencodeCli.field.showUpdateNotifications`)})}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(Qt,{checked:s,onChange:f,ariaLabel:e(`settings.openchamber.opencodeCli.field.showUpdateNotificationsAria`)})})]}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex justify-end`,children:(0,$.jsx)(Y,{type:`button`,size:`xs`,onClick:d,disabled:r||a,className:`shrink-0 !font-normal`,children:e(a?`settings.common.actions.saving`:`settings.openchamber.opencodeCli.actions.saveAndReload`)})})]})},$f=[{id:`auto`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsAuto`},{id:`left`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsLeft`},{id:`right`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsRight`}],ep=()=>{let{t:e}=ke(),t=Q.useCallback(t=>e(t),[e]),n=w()&&T(),i=D(),a=u(e=>e.desktopWindowControlsPosition),o=u(e=>e.setDesktopWindowControlsPosition),[s,c]=Q.useState(!1),[l,d]=Q.useState(!1),[f,p]=Q.useState(``),[m,g]=Q.useState(``),[_,y]=Q.useState(!1),[b,x]=Q.useState(null),[E,O]=Q.useState(!0),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[F,I]=Q.useState(!1),[R,B]=Q.useState(!1),[H,U]=Q.useState(!1),[te,W]=Q.useState(!1),[ne,re]=Q.useState(!1),[ie,ae]=Q.useState(!1),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(!1),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(null);Q.useEffect(()=>{if(!n){O(!1);return}let t=!1;return(async()=>{try{let n=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!n.ok)throw Error(e(`settings.openchamber.desktopNetwork.error.loadFailed`));let r=await n.json().catch(()=>null);if(t)return;let i=r?.desktopLanAccessEnabled===!0,a=typeof r?.desktopUiPassword==`string`?r.desktopUiPassword:``;c(i),d(i),p(a),g(a),y(r?.desktopLanAccessActive===!0),x(typeof r?.desktopLanAccessBlockedReason==`string`?r.desktopLanAccessBlockedReason:null),de(null)}catch(n){t||de(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.loadFailed`))}finally{t||O(!1)}})(),()=>{t=!0}},[n,e]),Q.useEffect(()=>{if(!n){M(!1);return}let e=!1;return(async()=>{let t=await v();e||(M(t?.supported===!0),I(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){U(!1);return}let e=!1;return(async()=>{let t=await S();e||(U(t?.supported===!0),W(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){ae(!1);return}let e=!1;return(async()=>{let t=await h();e||(ae(t?.supported===!0),se(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n||!l){pe(null);return}let e=!1;return(async()=>{let t=await C();e||pe(t)})(),()=>{e=!0}},[l,n]);let me=l!==s||m!==f,he=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=r()||window.location.href,t=0;try{t=Number(new URL(e).port)}catch{t=Number(window.location.port)}return Number.isFinite(t)&&t>0?t:null},[]),ge=l&&_&&fe&&he?`http://${fe}:${he}`:null,_e=l&&!m.trim(),ve=s&&!_&&b===`missing-password`,ye=E||k||!me||_e,be=Q.useCallback(()=>{d(e=>!e)},[]),xe=Q.useCallback(e=>{g(e),e.trim()||d(!1)},[]),Se=Q.useCallback(e=>{o(e),V({desktopWindowControlsPosition:e})},[o]),Ce=Q.useCallback(async()=>{if(!j||R)return;let t=!F;I(t),B(!0),de(null);try{let n=await P(t);if(!n?.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported`));I(n.enabled)}catch(n){I(!t),de(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed`))}finally{B(!1)}},[R,F,j,e]),we=Q.useCallback(async()=>{if(!H||ne)return;let t=!te;W(t),re(!0),de(null);try{let n=await N(t);if(!n)throw Error(e(`settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed`));if(!n.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.minimizeToTrayUnsupported`));W(n.enabled)}catch(n){W(!t),de(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed`))}finally{re(!1)}},[ne,te,H,e]),Te=Q.useCallback(async()=>{if(!ie||ce)return;let t=!oe;se(t),le(!0),de(null);try{let n=await z(t);if(!n?.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.keepAwakeUnsupported`));se(n.enabled)}catch(n){se(!t),de(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed`))}finally{le(!1)}},[ce,oe,ie,e]),Ee=Q.useCallback(async()=>{if(me){A(!0),de(null);try{if(!(await L(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({desktopLanAccessEnabled:l,desktopUiPassword:m})})).ok)throw Error(e(`settings.openchamber.desktopNetwork.error.saveFailed`));if(c(l),p(m),!await ee())throw Error(e(`settings.openchamber.desktopNetwork.error.savedRestartFailed`))}catch(t){de(t instanceof Error?t.message:e(`settings.openchamber.desktopNetwork.error.saveFailed`)),A(!1)}}},[m,l,me,e]);return!n&&!i?null:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[i?(0,$.jsx)(Z,{label:e(`settings.openchamber.desktopNetwork.field.windowControlsPosition`),children:(0,$.jsx)(Fr,{itemId:`sessions.desktop-window-controls-position`,label:e(`settings.openchamber.desktopNetwork.field.windowControlsPosition`),description:e(`settings.openchamber.desktopNetwork.field.windowControlsPositionDescription`),children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,role:`group`,"aria-label":e(`settings.openchamber.desktopNetwork.field.windowControlsPositionAria`),children:$f.map(e=>(0,$.jsx)(Y,{type:`button`,variant:`chip`,size:`xs`,className:`!font-normal`,"aria-pressed":a===e.id,onClick:()=>Se(e.id),children:t(e.labelKey)},e.id))})})}):null,n?(0,$.jsxs)(Z,{label:e(`settings.openchamber.desktopNetwork.title`),children:[j?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-launch-at-login`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:Ce,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Ce())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.launchAtLogin`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.launchAtLoginDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(Qt,{checked:F,onChange:Ce,ariaLabel:e(`settings.openchamber.desktopNetwork.field.launchAtLoginAria`),disabled:R})})]}):null,H?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-minimize-to-tray`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:we,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),we())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.minimizeToTray`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.minimizeToTrayDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(Qt,{checked:te,onChange:we,ariaLabel:e(`settings.openchamber.desktopNetwork.field.minimizeToTrayAria`),disabled:ne})})]}):null,ie?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-keep-awake`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:Te,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Te())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.keepAwake`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.keepAwakeDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(Qt,{checked:oe,onChange:Te,ariaLabel:e(`settings.openchamber.desktopNetwork.field.keepAwakeAria`),disabled:ce})})]}):null,(0,$.jsx)(Fr,{itemId:`sessions.desktop-ui-password`,label:(0,$.jsx)(`label`,{htmlFor:`desktop-ui-password`,children:e(`settings.openchamber.desktopPassword.field.password`)}),description:e(`settings.openchamber.desktopPassword.field.passwordDescription`),children:(0,$.jsx)(ln,{id:`desktop-ui-password`,type:`password`,className:`max-w-sm`,value:m,onChange:e=>xe(e.target.value),placeholder:e(`settings.openchamber.desktopPassword.field.passwordPlaceholder`),disabled:E||k,required:l,"aria-invalid":_e})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-lan-access`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:be,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),be())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.allowLanAccess`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.allowLanAccessDescription`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.openchamber.desktopNetwork.field.warning`)}),_e||ve?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.openchamber.desktopNetwork.field.passwordRequiredWarning`)}):null]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(Qt,{checked:l,onChange:be,ariaLabel:e(`settings.openchamber.desktopNetwork.field.allowLanAccessAria`),disabled:E||k})})]}),ue?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-[var(--status-error)]`,children:ue}):null,ge?(0,$.jsxs)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:[e(me&&!s?`settings.openchamber.desktopNetwork.hint.openAfterRestart`:`settings.openchamber.desktopNetwork.hint.openNow`),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:ge})]}):null,(0,$.jsx)(`div`,{className:`oc-settings-group-row flex justify-end`,children:(0,$.jsx)(Y,{type:`button`,size:`xs`,onClick:Ee,disabled:ye,className:`shrink-0 !font-normal`,children:e(k?`settings.common.actions.saving`:`settings.openchamber.desktopNetwork.actions.saveAndRestart`)})})]}):null]})},tp=new Set([`shift`,`control`,`alt`,`meta`]),np=e=>{if(tp.has(e.key.toLowerCase()))return null;let t=[];(e.metaKey||e.ctrlKey)&&t.push(`mod`),e.shiftKey&&t.push(`shift`),e.altKey&&t.push(`alt`);let n=Dn(e.key);return n?(t.push(n),pn(t.join(`+`))):null},rp=()=>{let e=(0,Ei.c)(59),{t}=ke(),n;e[0]===t?n=e[1]:(n=e=>t(e),e[0]=t,e[1]=n);let r=n,i=u(ip),a=u(ap),o=u(op),s=u(sp),c;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)){bb0:{let e=yn();if(!m()){c=e;break bb0}c=e.filter(cp)}e[2]=c}else c=e[2];let l=c,d;e[3]===r?d=e[4]:(d=(e,t)=>{let n=`settings.openchamber.keyboardShortcuts.action.${e}.label`,i=r(n);return i===n?t:i},e[3]=r,e[4]=d);let f=d,[p,h]=Q.useState(null),g;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={},e[5]=g):g=e[5];let[_,v]=Q.useState(g),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(null),T=lp,E;e[6]===i?E=e[7]:(E=(e,t)=>{let n=pn(t);for(let t of l){if(t.id===e)continue;let r=Qn(t.id,i);if(pn(r)===n)return t.id}return null},e[6]=i,e[7]=E);let D=E,O;e[8]!==D||e[9]!==a||e[10]!==i||e[11]!==t?(O=(e,n)=>{let r=pn(n),o=D(e,r);if(o){w({actionId:e,combo:r,conflictActionId:o}),b(``);return}let s={...i,[e]:r};a(e,r),T(s),w(null),b(``),S(jn(r)?t(`settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut`):``),v(t=>{let n={...t};return delete n[e],n})},e[8]=D,e[9]=a,e[10]=i,e[11]=t,e[12]=O):O=e[12];let k=O,A;e[13]!==C||e[14]!==a||e[15]!==i||e[16]!==t?(A=()=>{if(!C)return;let e={...i,[C.conflictActionId]:gn,[C.actionId]:C.combo};a(C.conflictActionId,gn),a(C.actionId,C.combo),T(e),w(null),b(``),S(jn(C.combo)?t(`settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut`):``),v(e=>{let t={...e};return delete t[C.actionId],t})},e[13]=C,e[14]=a,e[15]=i,e[16]=t,e[17]=A):A=e[17];let j=A,M;e[18]!==o||e[19]!==i?(M=e=>{let t={...i};delete t[e],o(e),T(t),v(t=>{let n={...t};return delete n[e],n}),w(null),b(``),S(``)},e[18]=o,e[19]=i,e[20]=M):M=e[20];let N=M,P;e[21]===t?P=e[22]:(P=t(`settings.openchamber.keyboardShortcuts.title`),e[21]=t,e[22]=P);let F;e[23]===P?F=e[24]:(F=(0,$.jsx)(`span`,{children:P}),e[23]=P,e[24]=F);let I;e[25]===s?I=e[26]:(I=()=>{s(),T({}),v({}),w(null),b(``),S(``)},e[25]=s,e[26]=I);let L;e[27]===t?L=e[28]:(L=t(`settings.openchamber.keyboardShortcuts.actions.resetAll`),e[27]=t,e[28]=L);let R;e[29]!==I||e[30]!==L?(R=(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:I,children:L}),e[29]=I,e[30]=L,e[31]=R):R=e[31];let z;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),e[32]=z):z=e[32];let B;e[33]===t?B=e[34]:(B=t(`settings.openchamber.keyboardShortcuts.tooltip`),e[33]=t,e[34]=B);let V;e[35]===B?V=e[36]:(V=(0,$.jsxs)(fn,{children:[z,(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:B})]}),e[35]=B,e[36]=V);let H;e[37]!==R||e[38]!==V||e[39]!==F?(H=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F,R,V]}),e[37]=R,e[38]=V,e[39]=F,e[40]=H):H=e[40];let ee;e[41]!==j||e[42]!==y||e[43]!==C||e[44]!==t||e[45]!==x?(ee=(y||x||C)&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-2 px-1`,children:[C&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-foreground`,children:t(`settings.openchamber.keyboardShortcuts.overwritePrompt`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:j,children:t(`settings.openchamber.keyboardShortcuts.actions.overwrite`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>w(null),children:t(`settings.common.actions.cancel`)})]})]}),y&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground`,children:y}),x&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground`,children:x})]}),e[41]=j,e[42]=y,e[43]=C,e[44]=t,e[45]=x,e[46]=ee):ee=e[46];let U;e[47]!==f||e[48]!==p||e[49]!==_||e[50]!==N||e[51]!==k||e[52]!==i||e[53]!==t?(U=l.map(e=>{let n=Qn(e.id,i),r=_[e.id],a=r??n,o=typeof r==`string`&&pn(r)!==pn(n);return(0,$.jsxs)(Fr,{label:f(e.id,e.label),children:[(0,$.jsx)(ln,{readOnly:!0,value:p===e.id?t(`settings.openchamber.keyboardShortcuts.field.pressKeys`):hn(a),onFocus:()=>{h(e.id),b(``)},onBlur:()=>{p===e.id&&h(null)},onKeyDown:t=>{if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){h(null);return}let n=np(t);n&&(v(t=>({...t,[e.id]:n})),h(null),w(null),b(``))},className:`w-40 min-w-0 typography-ui-label text-right`}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,size:`xs`,className:`!font-normal`,onClick:()=>{let n=_[e.id];if(!n){b(t(`settings.openchamber.keyboardShortcuts.error.captureFirst`));return}k(e.id,n)},disabled:!o,children:t(`settings.common.actions.saveChanges`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>N(e.id),children:t(`settings.common.actions.reset`)})]},e.id)}),e[47]=f,e[48]=p,e[49]=_,e[50]=N,e[51]=k,e[52]=i,e[53]=t,e[54]=U):U=e[54];let te;return e[55]!==H||e[56]!==ee||e[57]!==U?(te=(0,$.jsxs)(Z,{itemId:`shortcuts.keyboard-shortcuts`,label:H,children:[ee,U]}),e[55]=H,e[56]=ee,e[57]=U,e[58]=te):te=e[58],te};function ip(e){return e.shortcutOverrides}function ap(e){return e.setShortcutOverride}function op(e){return e.clearShortcutOverride}function sp(e){return e.resetAllShortcutOverrides}function cp(e){return e.id!==`toggle_prompt_navigator`}function lp(e){V({shortcutOverrides:e})}var up=()=>{let e=(0,Ei.c)(2),[t,r]=Q.useState(0),i,a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>n(()=>r(bp)),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),t},dp=e=>{let t=(0,Ei.c)(24),{section:n,flowMobile:r}=e,i=r!==void 0&&r,{isMobile:a}=dr();up();let o;t[0]===a?o=t[1]:(o=a&&A(),t[0]=a,t[1]=o);let s=o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=m(),t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=w()&&(T()||D()),t[3]=u):u=t[3];let d=u;if(!n){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yf,{}),t[4]=e):e=t[4];let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(If,{})}),t[5]=n):n=t[5];let r,i,a;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(zf,{})}),i=d&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(ep,{})}),a=!l&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Qf,{})}),t[6]=r,t[7]=i,t[8]=a):(r=t[6],i=t[7],a=t[8]);let o;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(wf,{})}),t[9]=o):o=t[9];let c;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Pf,{})}),t[10]=c):c=t[10];let u;t[11]===s?u=t[12]:(u=s&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Ni,{})}),t[11]=s,t[12]=u);let f;return t[13]===u?f=t[14]:(f=(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content openchamber-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[e,n,r,i,a,o,c,u]})}),t[13]=u,t[14]=f),f}let f;t[15]!==i||t[16]!==n?(f=()=>{switch(n){case`visual`:return(0,$.jsx)(pp,{mobile:i});case`chat`:return(0,$.jsx)(mp,{});case`sessions`:return(0,$.jsx)(hp,{});case`summary-ai`:return(0,$.jsx)(zf,{});case`shortcuts`:return(0,$.jsx)(fp,{});case`git`:return(0,$.jsx)(gp,{});case`github`:return(0,$.jsx)(_p,{});case`notifications`:return(0,$.jsx)(vp,{});case`voice`:return(0,$.jsx)(yp,{});default:return null}},t[15]=i,t[16]=n,t[17]=f):f=t[17];let p=f,h;t[18]===p?h=t[19]:(h=p(),t[18]=p,t[19]=h);let g;t[20]===h?g=t[21]:(g=(0,$.jsx)(`div`,{className:`oc-settings-page-content openchamber-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:h}),t[20]=h,t[21]=g);let _=g;if(i)return _;let v;return t[22]===_?v=t[23]:(v=(0,$.jsx)(yr,{outerClassName:`h-full`,className:`w-full`,children:_}),t[22]=_,t[23]=v),v},fp=()=>{let e=(0,Ei.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(rp,{}),e[0]=t):t=e[0],t},pp=e=>{let t=(0,Ei.c)(5),{mobile:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=m(),t[0]=r):r=t[0];let i=r,a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=i?[]:[`weekStart`],t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=[`theme`,`sidebarBrand`,`pwaInstallName`,`pwaOrientation`,`mobileKeyboardMode`,`timeFormat`,...a,`fontSize`,`codeFontSize`,`terminalFontSize`,`editorFontSize`,`fileEditorKeymap`,`spacing`,`inputBarOffset`,`expandedEditorToolbar`,...i?[]:[`terminalQuickKeys`],`reportUsage`],t[2]=o):o=t[2];let s;return t[3]===n?s=t[4]:(s=(0,$.jsx)(yf,{mobile:n,visibleSettings:o}),t[3]=n,t[4]=s),s},mp=()=>{let e=(0,Ei.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=m(),e[0]=t):t=e[0];let n=t,r;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(yf,{visibleSettings:[`sessionGoal`,`sessionAssist`,`chatRenderMode`,`messageTransport`,`activityRenderMode`,`userMessageRendering`,`mermaidRendering`,`reasoning`,`showTurnChangedFiles`,`expandedTools`,`collapsibleUserMessages`,`stickyUserHeader`,...n?[]:[`promptNavigatorEnabled`],`wideChatLayout`,`codeBlockLineWrap`,`showAssistantTps`,`subagentReadOnlyBanner`,`diffLayout`,`dotfiles`,`fileViewerPreview`,`followUpBehavior`,`persistDraft`,`inputSpellcheck`]}),e[1]=r):r=e[1],r},hp=()=>{let e=(0,Ei.c)(7),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=m(),e[0]=t):t=e[0];let n=t;up();let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=w()&&(T()||D()),e[1]=r):r=e[1];let i=r,a,o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(If,{}),o=i&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(ep,{})}),s=!n&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Qf,{})}),e[2]=a,e[3]=o,e[4]=s):(a=e[2],o=e[3],s=e[4]);let c;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(wf,{})}),e[5]=c):c=e[5];let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[a,o,s,c,(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Pf,{})})]}),e[6]=l):l=e[6],l},gp=()=>{let e=(0,Ei.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`oc-settings-section-stack`,children:(0,$.jsx)(Vd,{})}),e[0]=t):t=e[0],t},_p=()=>{let e=(0,Ei.c)(1);if(m())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Hd,{}),e[0]=t):t=e[0],t},vp=()=>{let e=(0,Ei.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Hf,{}),e[0]=t):t=e[0],t},yp=()=>{let e=(0,Ei.c)(1);if(m())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Zf,{}),e[0]=t):t=e[0],t};function bp(e){return e+1}var xp=[{id:`instances.manage`,page:`instances`,titleKey:`mobile.settings.switchInstance`,keywords:[`instance`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{id:`global-config.editor`,page:`global-config`,titleKey:`settings.globalConfig.title`,descriptionKey:`settings.globalConfig.description`,keywords:[`opencode.json`,`opencode.jsonc`,`oh-my-opencode-slim`,`oh-my-openagent`,`json`,`jsonc`]},{id:`appearance.language`,page:`appearance`,titleKey:`settings.appearance.language.label`,descriptionKey:`settings.appearance.language.description`,keywords:[`locale`,`translation`,`ui language`]},{id:`appearance.time-format`,page:`appearance`,titleKey:`settings.openchamber.visual.field.timeFormat`,keywords:[`clock`,`12h`,`24h`]},{id:`appearance.week-start`,page:`appearance`,titleKey:`settings.openchamber.visual.field.weekStartsOn`,keywords:[`calendar`,`monday`,`sunday`],isAvailable:e=>!e.isVSCode},{id:`appearance.light-theme`,page:`appearance`,titleKey:`settings.openchamber.visual.field.lightTheme`,keywords:[`theme`,`color`,`light mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.dark-theme`,page:`appearance`,titleKey:`settings.openchamber.visual.field.darkTheme`,keywords:[`theme`,`color`,`dark mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.window-transparency`,page:`appearance`,titleKey:`settings.openchamber.visual.field.macVibrancy`,descriptionKey:`settings.openchamber.visual.field.macVibrancyHint`,keywords:[`transparent`,`transparency`,`vibrancy`,`blur`,`macos`,`opaque`],isAvailable:e=>e.isDesktopLocalOrigin},{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:e=>e.isMac},{id:`appearance.sidebar-brand`,page:`appearance`,titleKey:`settings.openchamber.visual.field.sidebarBrand`,descriptionKey:`settings.openchamber.visual.field.sidebarBrandHint`,keywords:[`logo`,`brand`,`wordmark`,`sidebar`]},{id:`appearance.pwa-install-name`,page:`appearance`,titleKey:`settings.openchamber.visual.field.installAppName`,descriptionKey:`settings.openchamber.visual.field.installAppNameHint`,keywords:[`pwa`,`installed app`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.pwa-orientation`,page:`appearance`,titleKey:`settings.openchamber.visual.field.installOrientation`,descriptionKey:`settings.openchamber.visual.field.installOrientationHint`,keywords:[`pwa`,`portrait`,`landscape`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.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:e=>e.isMobile&&e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.ios-native-ui`,page:`appearance`,titleKey:`settings.openchamber.visual.field.iosNativeUi`,descriptionKey:`settings.openchamber.visual.field.iosNativeUiHint`,keywords:[`ios`,`native`,`webview`,`composer`,`tab bar`,`live activity`],isAvailable:()=>mr()},{id:`appearance.interface-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.interfaceFontSize`,keywords:[`font`,`text size`,`ui scale`]},{id:`appearance.code-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.codeFontSize`,keywords:[`code`,`font`,`text size`,`diff`]},{id:`appearance.terminal-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.terminalFontSize`,keywords:[`terminal`,`font`,`text size`]},{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`]},{id:`appearance.expanded-editor-toolbar`,page:`appearance`,titleKey:`settings.openchamber.visual.field.expandedEditorToolbar`,keywords:[`editor`,`toolbar`,`tabs`,`docked`,`files`]},{id:`appearance.file-editor-keymap`,page:`appearance`,titleKey:`settings.openchamber.visual.field.fileEditorKeymap`,keywords:[`editor`,`vim`,`keymap`]},{id:`appearance.terminal-quick-keys`,page:`appearance`,titleKey:`settings.openchamber.visual.field.terminalQuickKeys`,descriptionKey:`settings.openchamber.visual.field.terminalQuickKeysTooltip`,keywords:[`terminal`,`keyboard`,`esc`,`ctrl`,`arrows`],isAvailable:e=>!e.isMobile&&!e.isDesktop&&!e.isVSCode},{id:`about.beta-updates`,page:`about`,titleKey:`settings.openchamber.about.betaUpdates.label`,descriptionKey:`settings.openchamber.about.betaUpdates.description`,keywords:[`beta`,`updates`,`channel`,`ota`],isAvailable:e=>e.isMobile&&be()},{id:`about.diagnostics`,page:`about`,titleKey:`settings.openchamber.about.diagnostics.label`,keywords:[`diagnostics`,`logs`,`feat`,`transcript`,`task`]},{id:`about.export-diagnostics`,page:`about`,titleKey:`settings.openchamber.about.diagnostics.export`,keywords:[`diagnostics`,`logs`,`export`,`feat`,`transcript`,`task`],isAvailable:()=>Tt()},{id:`appearance.usage-reports`,page:`appearance`,titleKey:`settings.openchamber.visual.field.sendAnonymousUsageReports`,descriptionKey:`settings.openchamber.visual.field.sendAnonymousUsageReportsHint`,keywords:[`telemetry`,`analytics`]},{id:`appearance.transcript-cache`,page:`appearance`,titleKey:`settings.openchamber.visual.transcriptCache.label`,descriptionKey:`settings.openchamber.visual.transcriptCache.description`,keywords:[`cache`,`local data`,`conversation history`,`transcript`,`privacy`]},{id:`chat.render-mode`,page:`chat`,titleKey:`settings.openchamber.visual.section.chatRenderMode`,keywords:[`messages`,`conversation`,`rendering`]},{id:`chat.message-transport`,page:`chat`,titleKey:`settings.openchamber.visual.section.messageStreamTransport`,keywords:[`streaming`,`sse`,`websocket`]},{id:`chat.session-assistance`,page:`chat`,titleKey:`settings.openchamber.visual.section.sessionAssistance`,keywords:[`title`,`assist`,`subagent`]},{id:`chat.session-title-refresh`,page:`chat`,titleKey:`settings.openchamber.visual.field.sessionTitleRefresh`,keywords:[`title`,`rename`,`refresh`,`throttle`,`small model`,`summary`]},{id:`chat.session-goal`,page:`chat`,titleKey:`settings.openchamber.visual.field.sessionGoal`,keywords:[`goal`,`objective`,`auto continue`,`small model`],isAvailable:e=>!e.isVSCode},{id:`chat.session-goal-budget`,page:`chat`,titleKey:`settings.openchamber.visual.goal.budgetLabel`,keywords:[`goal`,`budget`,`tokens`,`limit`],isAvailable:e=>!e.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.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`],isAvailable:e=>!e.isVSCode},{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`,`read aloud`],isAvailable:()=>!1},{id:`chat.assistant-tps`,page:`chat`,titleKey:`settings.openchamber.visual.field.showAssistantTps`,descriptionKey:`settings.openchamber.visual.field.showAssistantTpsTooltip`,keywords:[`tps`,`tokens`,`speed`,`rate`,`tok/s`,`throughput`]},{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`],isAvailable:()=>!1},{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:e=>!e.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.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`]},{id:`chat.spellcheck`,page:`chat`,titleKey:`settings.openchamber.visual.field.enableSpellcheckInTextInputs`,keywords:[`spelling`,`input`],isAvailable:e=>!e.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:`summary-ai.configuration`,page:`summary-ai`,titleKey:`settings.openchamber.defaults.summary.title`,descriptionKey:`settings.openchamber.defaults.summary.description`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`custom api`,`base url`,`api token`]},{id:`sessions.auto-cleanup`,page:`sessions`,titleKey:`settings.openchamber.sessionRetention.field.enableAutoCleanup`,descriptionKey:`settings.openchamber.sessionRetention.tooltip`,keywords:[`retention`,`archive`,`delete`]},{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.archived`,page:`sessions`,titleKey:`settings.openchamber.archivedSessions.title`,descriptionKey:`settings.openchamber.archivedSessions.description`,keywords:[`archive`,`archived`,`restore`,`preview`,`history`]},{id:`sessions.desktop-launch-at-login`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.launchAtLogin`,descriptionKey:`settings.openchamber.desktopNetwork.field.launchAtLoginDescription`,keywords:[`desktop`,`startup`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-window-controls-position`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.windowControlsPosition`,descriptionKey:`settings.openchamber.desktopNetwork.field.windowControlsPositionDescription`,keywords:[`desktop`,`window`,`controls`,`minimize`,`maximize`,`close`,`titlebar`,`linux`,`windows`],isAvailable:e=>e.isDesktop&&(e.isWindows||!e.isMac)},{id:`sessions.desktop-minimize-to-tray`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.minimizeToTray`,descriptionKey:`settings.openchamber.desktopNetwork.field.minimizeToTrayDescription`,keywords:[`desktop`,`tray`,`system tray`,`minimize`,`close`,`background`,`windows`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isWindows},{id:`sessions.desktop-keep-awake`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.keepAwake`,descriptionKey:`settings.openchamber.desktopNetwork.field.keepAwakeDescription`,keywords:[`desktop`,`sleep`,`awake`,`server`,`mobile`,`phone`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-ui-password`,page:`sessions`,titleKey:`settings.openchamber.desktopPassword.field.password`,descriptionKey:`settings.openchamber.desktopPassword.field.passwordDescription`,keywords:[`desktop`,`password`,`auth`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-lan-access`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.allowLanAccess`,descriptionKey:`settings.openchamber.desktopNetwork.field.allowLanAccessDescription`,keywords:[`desktop`,`lan`,`network`,`phone`,`tablet`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.opencode-binary`,page:`sessions`,titleKey:`settings.openchamber.opencodeCli.field.binaryPath`,keywords:[`opencode`,`cli`,`binary`,`path`],isAvailable:e=>!e.isVSCode},{id:`sessions.opencode-update-notifications`,page:`sessions`,titleKey:`settings.openchamber.opencodeCli.field.showUpdateNotifications`,keywords:[`opencode`,`cli`,`updates`],isAvailable:e=>!e.isVSCode},{id:`git.github-account`,page:`git`,titleKey:`settings.github.page.actions.connect`,keywords:[`github`,`account`,`oauth`,`prs`,`issues`]},{id:`git.identities`,page:`git`,titleKey:`settings.gitIdentities.page.section.title`,descriptionKey:`settings.gitIdentities.page.empty.description`,keywords:[`identity`,`profile`,`author`,`email`,`credentials`,`signing`,`commit signing`,`ssh signing`,`gpg`]},{id:`git.changes-view`,page:`git`,titleKey:`settings.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.header-menu`,page:`usage`,titleKey:`settings.usage.page.options.showInHeader`,descriptionKey:`settings.usage.page.options.showInHeaderTooltip`,keywords:[`quota`,`header`,`dropdown`]},{id:`usage.model-quotas`,page:`usage`,titleKey:`settings.usage.page.section.modelQuotas`,keywords:[`models`,`quota`,`limits`,`tokens`]},{id:`projects.name`,page:`projects`,titleKey:`settings.projects.page.field.projectName`,keywords:[`label`,`display name`,`project metadata`]},{id:`projects.accent-color`,page:`projects`,titleKey:`settings.projects.page.field.accentColor`,keywords:[`color`,`appearance`,`project metadata`]},{id:`projects.icon`,page:`projects`,titleKey:`settings.projects.page.field.projectIcon`,keywords:[`icon`,`favicon`,`upload`,`project metadata`]},{id:`projects.worktree`,page:`projects`,titleKey:`settings.projects.page.section.worktree`,keywords:[`worktree`,`branch`,`repository`]},{id:`projects.worktree.setup.wait`,page:`projects`,titleKey:`settings.openchamber.worktrees.setup.waitForCommands`,keywords:[`worktree`,`setup commands`,`bootstrap`,`wait`]},{id:`remote-instances.client-auth`,page:`remote-instances`,titleKey:`settings.remoteInstances.clientAuth.title`,descriptionKey:`settings.remoteInstances.clientAuth.description`,keywords:[`pairing link`,`client token`,`connect desktop`,`remote access`,`relay`,`devices`,`connect from anywhere`],isAvailable:e=>!e.isVSCode},{id:`remote-instances.instances`,page:`remote-instances`,titleKey:`settings.remoteInstances.sidebar.title`,descriptionKey:`settings.remoteInstances.sidebar.description`,keywords:[`import link`,`pairing link`,`connect link`,`ssh`,`remote instance`,`host switcher`],isAvailable:e=>e.isDesktop},{id:`behavior.system-prompt`,page:`behavior`,titleKey:`settings.behavior.page.section.systemPrompt`,descriptionKey:`settings.behavior.page.warning.title`,keywords:[`agents.md`,`global instructions`,`system prompt`]},{id:`behavior.response-style`,page:`behavior`,titleKey:`settings.behavior.page.section.responseStyle`,descriptionKey:`settings.behavior.page.responseStyle.tooltip`,keywords:[`tone`,`concise`,`detailed`,`custom instructions`]},{id:`agents.create`,page:`agents`,titleKey:`settings.agents.page.title.new`,keywords:[`create`,`add`,`new agent`]},{id:`assistants.instance-enabled`,page:`assistants`,titleKey:`assistants.settings.instanceEnabled`,descriptionKey:`assistants.settings.description`,keywords:[`assistant`,`enable`,`feature`]},{id:`assistants.create`,page:`assistants`,titleKey:`assistants.settings.create`,keywords:[`assistant`,`new`,`add`]},{id:`assistants.name`,page:`assistants`,titleKey:`assistants.settings.name`,keywords:[`assistant`,`name`]},{id:`assistants.default-share`,page:`assistants`,titleKey:`assistants.settings.defaultShare`,keywords:[`share`,`default`,`mobile`]},{id:`assistants.prompt`,page:`assistants`,titleKey:`assistants.settings.defaultPrompt`,keywords:[`prompt`,`instructions`]},{id:`assistants.model`,page:`assistants`,titleKey:`assistants.settings.model`,keywords:[`provider`,`model`]},{id:`assistants.workspace`,page:`assistants`,titleKey:`assistants.settings.workspace`,keywords:[`path`,`directory`,`workspace`]},{id:`agents.name`,page:`agents`,titleKey:`settings.agents.page.field.agentName`,keywords:[`agent`,`name`]},{id:`agents.mode`,page:`agents`,titleKey:`settings.agents.page.field.mode`,descriptionKey:`settings.agents.page.field.modeTooltip`,keywords:[`primary`,`subagent`,`visibility`]},{id:`agents.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.permissions`,page:`agents`,titleKey:`settings.agents.page.section.toolPermissions`,keywords:[`tools`,`permissions`,`allow`,`ask`,`deny`]},{id:`commands.create`,page:`commands`,titleKey:`settings.commands.page.title.new`,keywords:[`create`,`add`,`new command`]},{id:`commands.name`,page:`commands`,titleKey:`settings.commands.page.field.commandName`,keywords:[`slash command`,`name`]},{id:`commands.agent`,page:`commands`,titleKey:`settings.commands.page.field.overrideAgent`,keywords:[`agent`,`execution`]},{id:`commands.model`,page:`commands`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`]},{id:`commands.template`,page:`commands`,titleKey:`settings.commands.page.section.template`,keywords:[`prompt`,`template`,`arguments`,`shell`,`file`]},{id:`mcp.create`,page:`mcp`,titleKey:`settings.mcp.sidebar.actions.addServerTitle`,keywords:[`create`,`add`,`server`]},{id:`mcp.server`,page:`mcp`,titleKey:`settings.mcp.page.server.title`,keywords:[`server`,`name`,`transport`]},{id:`mcp.command`,page:`mcp`,titleKey:`settings.mcp.page.connection.command`,keywords:[`stdio`,`local`,`command`]},{id:`mcp.environment`,page:`mcp`,titleKey:`settings.mcp.page.env.title`,keywords:[`env`,`variables`,`api key`]},{id:`mcp.advanced`,page:`mcp`,titleKey:`settings.mcp.page.advanced.title`,keywords:[`oauth`,`headers`,`timeout`]},{id:`plugins.create`,page:`plugins`,titleKey:`settings.plugins.sidebar.actions.addTitle`,keywords:[`add`,`plugin`,`npm`,`path`,`file`]},{id:`plugins.spec`,page:`plugins`,titleKey:`settings.plugins.page.field.spec`,keywords:[`npm`,`package`,`path`]},{id:`plugins.options`,page:`plugins`,titleKey:`settings.plugins.page.field.options`,keywords:[`json`,`configuration`]},{id:`plugins.content`,page:`plugins`,titleKey:`settings.plugins.page.field.content`,keywords:[`file`,`code`]},{id:`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.auth`,page:`providers`,titleKey:`settings.providers.page.auth.title`,keywords:[`api key`,`oauth`,`credentials`]},{id:`providers.connection-details`,page:`providers`,titleKey:`settings.providers.page.connectionDetails.title`,keywords:[`config`,`source`,`disconnect`]},{id:`providers.models`,page:`providers`,titleKey:`settings.providers.page.models.title`,keywords:[`models`,`hide`,`show`]},{id:`skills.create`,page:`skills.installed`,titleKey:`settings.skills.page.title.newSkill`,keywords:[`create`,`add`,`new skill`]},{id:`skills.basic-information`,page:`skills.installed`,titleKey:`settings.skills.page.section.basicInformation`,keywords:[`name`,`location`,`description`]},{id:`skills.instructions`,page:`skills.installed`,titleKey:`settings.skills.page.section.instructions`,keywords:[`markdown`,`skill.md`,`content`]},{id:`skills.supporting-files`,page:`skills.installed`,titleKey:`settings.skills.page.section.supportingFiles`,keywords:[`files`,`resources`]},{id:`skills.catalog.source`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.section.sourceRepository`,keywords:[`catalog`,`repository`,`source`,`refresh`]},{id:`skills.catalog.search`,page:`skills.catalog`,titleKey:`settings.skills.catalog.shared.field.searchSkillsPlaceholder`,keywords:[`find skills`,`install skills`,`catalog search`]},{id:`skills.catalog.add-catalog`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.actions.addCatalog`,keywords:[`external repository`,`add source`,`catalog`]},{id:`magic-prompts.visible-prompt`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`,keywords:[`prompt text`,`user message`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.instructions`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.instructions`,keywords:[`hidden prompt`,`instructions`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.reset-overrides`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.actions.resetAllOverrides`,keywords:[`reset`,`default prompts`,`overrides`],isAvailable:e=>!e.isVSCode},{id:`shortcuts.keyboard-shortcuts`,page:`shortcuts`,titleKey:`settings.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:`notifications.delivery`,page:`notifications`,titleKey:`settings.notifications.page.delivery.title`,keywords:[`desktop notifications`,`system notifications`]},{id:`notifications.events`,page:`notifications`,titleKey:`settings.notifications.page.events.title`,keywords:[`completion`,`subtasks`,`errors`,`questions`]},{id:`notifications.push`,page:`notifications`,titleKey:`settings.notifications.page.push.title`,keywords:[`background`,`push`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode}];function Sp(e){return e.trim().toLocaleLowerCase()}function Cp({query:e,runtimeCtx:t,visiblePageSlugs:n,t:r,getPageTitle:i}){let a=Sp(e);if(!a)return[];let o=n?new Set(n):null,s=a.split(/\s+/).filter(Boolean);return xp.flatMap(e=>{if(o&&!o.has(e.page))return[];let n=$r(e.page);if(!n||n.isAvailable&&!n.isAvailable(t)||e.isAvailable&&!e.isAvailable(t))return[];let a=r(e.titleKey),c=e.descriptionKey?r(e.descriptionKey):null,l=Sp([a,c,i(e.page),...e.keywords??[]].filter(Boolean).join(` `));return s.every(e=>l.includes(e))?[{...e,title:a,description:c,pageTitle:i(e.page)}]:[]})}function wp(e){let t=(0,Ei.c)(10),{label:n,children:r,ariaLabel:i,className:a,borderless:o}=e,s=o!==void 0&&o,c;t[0]===a?c=t[1]:(c=q(`oc-mobile-settings-group`,a),t[0]=a,t[1]=c);let l=s&&`oc-mobile-settings-card-borderless`,u;t[2]===l?u=t[3]:(u=q(`oc-mobile-settings-card`,l),t[2]=l,t[3]=u);let d;return t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==c||t[8]!==u?(d=(0,$.jsx)(Z,{label:n,ariaLabel:i,className:c,cardClassName:u,children:r}),t[4]=i,t[5]=r,t[6]=n,t[7]=c,t[8]=u,t[9]=d):d=t[9],d}var Tp=t({SettingsView:()=>Vp,getSettingsNavIcon:()=>zp}),Ep=176,Dp=280,Op=8,kp=`__openchamberSettingsDetail`;function Ap(e){return Math.min(Dp,Math.max(Ep,e))}var jp={icon:`chat-thread`},Mp=`__add_provider__`;function Np(e,t){return{isVSCode:m(),isWeb:!e&&A(),isDesktop:e,isMobile:t}}function Pp(e,t){return!e.isAvailable||e.isAvailable(t)}function Fp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ip(e,t){let n=new Set(t),r=e,i=1;for(;n.has(r);)r=`${e}-${i}`,i+=1;return r}function Lp(e){if(!Fp(e))return null;let t=e[kp];if(!Fp(t))return null;let n=t.page,r=t.stage;return typeof n!=`string`||r!==`page-content`?null:{page:di(n),stage:r}}function Rp(){return typeof window>`u`||!Fp(window.history.state)?{}:window.history.state}function zp(e){switch(e){case`projects`:return`folders`;case`instances`:return`server`;case`remote-instances`:return`server`;case`appearance`:return`palette`;case`chat`:return`chat-ai-3`;case`magic-prompts`:return`ai-generate-2`;case`snippets`:return jp.icon;case`notifications`:return`notification-3`;case`shortcuts`:return`command`;case`sessions`:return`chat-history`;case`summary-ai`:return`ai-generate-2`;case`providers`:return`cloud`;case`agents`:return`node-tree`;case`assistants`:return`robot-2`;case`behavior`:return`brain`;case`commands`:return`slash-commands-2`;case`mcp`:return null;case`plugins`:return`code-box`;case`global-config`:return`settings-3`;case`skills.installed`:return`book-open`;case`skills.catalog`:return`book`;case`git`:return`git-branch`;case`usage`:return`bar-chart-2`;case`voice`:return`mic`;case`about`:return`information`;case`home`:return null;default:return`robot-2`}}var Bp=e=>{let t=(0,Ei.c)(95),{onOpen:n}=e,{t:r}=ke(),i;t[0]===r?i=t[1]:(i=r(`settings.view.home.title`),t[0]=r,t[1]=i);let a;t[2]===i?a=t[3]:(a=(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:i}),t[2]=i,t[3]=a);let o;t[4]===r?o=t[5]:(o=r(`settings.view.home.description`),t[4]=r,t[5]=o);let s;t[6]===o?s=t[7]:(s=(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:o}),t[6]=o,t[7]=s);let c;t[8]!==a||t[9]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,s]}),t[8]=a,t[9]=s,t[10]=c):c=t[10];let l;t[11]===n?l=t[12]:(l=()=>n(`providers`),t[11]=n,t[12]=l);let u;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[13]=u):u=t[13];let d;t[14]===r?d=t[15]:(d=r(`settings.view.home.cards.providers.title`),t[14]=r,t[15]=d);let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:d}),t[16]=d,t[17]=f);let p;t[18]===r?p=t[19]:(p=r(`settings.view.home.cards.providers.description`),t[18]=r,t[19]=p);let m;t[20]===p?m=t[21]:(m=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:p}),t[20]=p,t[21]=m);let h;t[22]!==m||t[23]!==l||t[24]!==f?(h=(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:u,children:[f,m]}),t[22]=m,t[23]=l,t[24]=f,t[25]=h):h=t[25];let g;t[26]===n?g=t[27]:(g=()=>n(`agents`),t[26]=n,t[27]=g);let _;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(_=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[28]=_):_=t[28];let v;t[29]===r?v=t[30]:(v=r(`settings.view.home.cards.agents.title`),t[29]=r,t[30]=v);let y;t[31]===v?y=t[32]:(y=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:v}),t[31]=v,t[32]=y);let b;t[33]===r?b=t[34]:(b=r(`settings.view.home.cards.agents.description`),t[33]=r,t[34]=b);let x;t[35]===b?x=t[36]:(x=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:b}),t[35]=b,t[36]=x);let S;t[37]!==g||t[38]!==y||t[39]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,onClick:g,className:_,children:[y,x]}),t[37]=g,t[38]=y,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n?C=t[42]:(C=()=>n(`skills.catalog`),t[41]=n,t[42]=C);let w;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(w=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[43]=w):w=t[43];let T;t[44]===r?T=t[45]:(T=r(`settings.view.home.cards.skillsCatalog.title`),t[44]=r,t[45]=T);let E;t[46]===T?E=t[47]:(E=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:T}),t[46]=T,t[47]=E);let D;t[48]===r?D=t[49]:(D=r(`settings.view.home.cards.skillsCatalog.description`),t[48]=r,t[49]=D);let O;t[50]===D?O=t[51]:(O=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:D}),t[50]=D,t[51]=O);let k;t[52]!==C||t[53]!==E||t[54]!==O?(k=(0,$.jsxs)(`button`,{type:`button`,onClick:C,className:w,children:[E,O]}),t[52]=C,t[53]=E,t[54]=O,t[55]=k):k=t[55];let A;t[56]===n?A=t[57]:(A=()=>n(`mcp`),t[56]=n,t[57]=A);let j;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(j=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[58]=j):j=t[58];let M;t[59]===r?M=t[60]:(M=r(`settings.view.home.cards.mcp.title`),t[59]=r,t[60]=M);let N;t[61]===M?N=t[62]:(N=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:M}),t[61]=M,t[62]=N);let P;t[63]===r?P=t[64]:(P=r(`settings.view.home.cards.mcp.description`),t[63]=r,t[64]=P);let F;t[65]===P?F=t[66]:(F=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:P}),t[65]=P,t[66]=F);let I;t[67]!==A||t[68]!==N||t[69]!==F?(I=(0,$.jsxs)(`button`,{type:`button`,onClick:A,className:j,children:[N,F]}),t[67]=A,t[68]=N,t[69]=F,t[70]=I):I=t[70];let L;t[71]===n?L=t[72]:(L=()=>n(`usage`),t[71]=n,t[72]=L);let R;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(R=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[73]=R):R=t[73];let z;t[74]===r?z=t[75]:(z=r(`settings.view.home.cards.usage.title`),t[74]=r,t[75]=z);let B;t[76]===z?B=t[77]:(B=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:z}),t[76]=z,t[77]=B);let V;t[78]===r?V=t[79]:(V=r(`settings.view.home.cards.usage.description`),t[78]=r,t[79]=V);let H;t[80]===V?H=t[81]:(H=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:V}),t[80]=V,t[81]=H);let ee;t[82]!==L||t[83]!==B||t[84]!==H?(ee=(0,$.jsxs)(`button`,{type:`button`,onClick:L,className:R,children:[B,H]}),t[82]=L,t[83]=B,t[84]=H,t[85]=ee):ee=t[85];let U;t[86]!==h||t[87]!==S||t[88]!==k||t[89]!==I||t[90]!==ee?(U=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[h,S,k,I,ee]}),t[86]=h,t[87]=S,t[88]=k,t[89]=I,t[90]=ee,t[91]=U):U=t[91];let te;return t[92]!==U||t[93]!==c?(te=(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6 space-y-6`,children:[c,U]})}),t[92]=U,t[93]=c,t[94]=te):te=t[94],te},Vp=e=>{let t=(0,Ei.c)(172),{onClose:n,mobileInstancesPage:r,forceMobile:i,isWindowed:a,visiblePageSlugs:o,hideMobileHeader:s,flowMobile:c,autoOpenMobilePage:l,initialMobileStage:d,onMobileStageChange:f}=e,p=s!==void 0&&s,m=c!==void 0&&c,h=l===void 0||l,g=d===void 0?`nav`:d,{t:_}=ke(),v=dr(),y=i??v.isMobile,b=u(Hp),x=u(Up),S=u(Wp),C;t[0]===b?C=t[1]:(C=di(b),t[0]=b,t[1]=C);let E=C,D=E===`commands`,O;t[2]===D?O=t[3]:(O={enabled:D},t[2]=D,t[3]=O);let{refetch:k}=_t(O),A,j;t[4]!==k||t[5]!==E?(A=()=>{E===`commands`&&k()},j=[k,E],t[4]=k,t[5]=E,t[6]=A,t[7]=j):(A=t[6],j=t[7]),Q.useEffect(A,j);let[M,N]=Q.useState(g),P=p&&M===`nav`,F=y&&m,I=Q.useRef(null),L=Q.useRef(0),R=Ht(Gp),z,B;t[8]!==y||t[9]!==R||t[10]!==S||t[11]!==E?(z=()=>{if(!y||R<=L.current)return;let e=Ht.getState().settingsSelectedAssistantID;if(!(!e||e===`new`)){if(E!==`assistants`){S(`assistants`);return}L.current=R,I.current=`assistants`,N(`page-content`)}},B=[y,R,S,E],t[8]=y,t[9]=R,t[10]=S,t[11]=E,t[12]=z,t[13]=B):(z=t[12],B=t[13]),Q.useEffect(z,B);let V,ee;t[14]!==M||t[15]!==f?(V=()=>{f?.(M)},ee=[M,f],t[14]=M,t[15]=f,t[16]=V,t[17]=ee):(V=t[16],ee=t[17]),Q.useEffect(V,ee);let[U,te]=Q.useState(216),[W,ne]=Q.useState(``),[re,ie]=Q.useState(null),[ae,oe]=Q.useState(0),[se,ce]=Q.useState(!1),[le,ue]=Q.useState(!1),de=Q.useRef(0),fe=Q.useRef(U),pe=Q.useRef(null),me=Q.useRef(null),he=Q.useRef(null),ge=Q.useRef(null),_e=Q.useRef(null),ve=Q.useRef(null),ye;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ye=[],t[18]=ye):ye=t[18];let xe=Q.useRef(ye),Se=Q.useRef(0),Ce=Q.useRef(!1),we;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(we=w(),t[19]=we):we=t[19];let Te=we,Ee;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=w()&&T(),t[20]=Ee):Ee=t[20];let De=Ee,Oe;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=w()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`darwin`,t[21]=Oe):Oe=t[21];let Ae=Oe,je;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(je=w()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`win32`,t[22]=je):je=t[22];let Me=je,Ne;t[23]===y?Ne=t[24]:(Ne=Np(Te,y),t[23]=y,t[24]=Ne);let Pe=Ne,Fe;if(t[25]!==y||t[26]!==r||t[27]!==Pe||t[28]!==o){let e=o?new Set(o):null,n;t[30]===Pe?n=t[31]:(n=e=>Pp(e,Pe),t[30]=Pe,t[31]=n);let i;t[32]===r?i=t[33]:(i=e=>e.slug!==`instances`||!!r,t[32]=r,t[33]=i);let a;t[34]===Pe.isVSCode?a=t[35]:(a=e=>!(Pe.isVSCode&&e.slug===`projects`),t[34]=Pe.isVSCode,t[35]=a);let s;t[36]===y?s=t[37]:(s=e=>!(y&&e.slug===`shortcuts`),t[36]=y,t[37]=s),Fe=ui.filter(Kp).filter(t=>!e||e.has(t.slug)).filter(n).filter(i).filter(a).filter(s),t[25]=y,t[26]=r,t[27]=Pe,t[28]=o,t[29]=Fe}else Fe=t[29];let Ie=Fe,Le;t[38]===Ie?Le=t[39]:(Le=ai(Ie),t[38]=Ie,t[39]=Le);let Re=Le,ze=ft(qp),Be,Ve;t[40]===se?(Be=t[41],Ve=t[42]):(Be=()=>{if(typeof window>`u`)return;let e=()=>{if(!se){let e=Ap(Math.floor(window.innerWidth*.12));te(e)}};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},Ve=[se],t[40]=se,t[41]=Be,t[42]=Ve),Q.useEffect(Be,Ve);let He,Ue;t[43]===le?(He=t[44],Ue=t[45]):(He=()=>{if(!le)return;let e=e=>{let t=e.clientX-de.current,n=Ap(fe.current+t);te(n),ce(!0)},t=()=>ue(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},Ue=[le],t[43]=le,t[44]=He,t[45]=Ue),Q.useEffect(He,Ue);let We;t[46]===U?We=t[47]:(We=e=>{ue(!0),de.current=e.clientX,fe.current=U,e.preventDefault()},t[46]=U,t[47]=We);let Ge=We,Ke;t[48]===U?Ke=t[49]:(Ke=e=>{let t=e.shiftKey?32:Op,n;bb155:switch(e.key){case`ArrowLeft`:n=U-t;break bb155;case`ArrowRight`:n=U+t;break bb155;case`Home`:n=Ep;break bb155;case`End`:n=Dp;break bb155;default:return}e.preventDefault(),te(Ap(n)),ce(!0)},t[48]=U,t[49]=Ke);let qe=Ke,Ye;t[50]!==x||t[51]!==a||t[52]!==Pe.isVSCode||t[53]!==E?(Ye=()=>{if(!(!x&&!Pe.isVSCode&&!a)){if(E===`agents`){et.getState().loadAgents();return}if(E!==`commands`&&E!==`mcp`){if(E===`plugins`){Ns.getState().loadPlugins();return}(E===`skills.installed`||E===`skills.catalog`)&&tt(H,Je()),E===`snippets`&&sn.getState().loadSnippets()}}},t[50]=x,t[51]=a,t[52]=Pe.isVSCode,t[53]=E,t[54]=Ye):Ye=t[54];let Xe;t[55]!==ze||t[56]!==x||t[57]!==a||t[58]!==Pe.isVSCode||t[59]!==E?(Xe=[ze,x,a,Pe.isVSCode,E],t[55]=ze,t[56]=x,t[57]=a,t[58]=Pe.isVSCode,t[59]=E,t[60]=Xe):Xe=t[60],Q.useEffect(Ye,Xe);let Ze;t[61]!==y||t[62]!==S?(Ze=e=>{if(S(e),I.current=e,!y)return;let t=$r(e);if(!t||t.slug===`home`){N(`nav`);return}N(t.kind===`split`?`page-sidebar`:`page-content`)},t[61]=y,t[62]=S,t[63]=Ze):Ze=t[63];let Qe=Ze,$e;t[64]===E?$e=t[65]:($e=$r(E),t[64]=E,t[65]=$e);let G=$e,nt;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(nt={appearance:`visual`,chat:`chat`,shortcuts:`shortcuts`,sessions:`sessions`,"summary-ai":`summary-ai`,notifications:`notifications`,voice:`voice`},t[66]=nt):nt=t[66];let rt=nt,it;t[67]===_?it=t[68]:(it=e=>{switch(e){case`projects`:return _(`settings.page.projects.title`);case`instances`:return _(`mobile.settings.switchInstance`);case`remote-instances`:return _(`settings.page.remoteInstances.title`);case`providers`:return _(`settings.page.providers.title`);case`usage`:return _(`settings.page.usage.title`);case`agents`:return _(`settings.page.agents.title`);case`assistants`:return _(`settings.page.assistants.title`);case`behavior`:return _(`settings.page.behavior.title`);case`commands`:return _(`settings.page.commands.title`);case`mcp`:return _(`settings.page.mcp.title`);case`plugins`:return _(`settings.page.plugins.title`);case`global-config`:return _(`settings.globalConfig.title`);case`skills.installed`:return _(`settings.page.skills.title`);case`skills.catalog`:return _(`settings.page.skillsCatalog.title`);case`git`:return _(`settings.page.git.title`);case`appearance`:return _(`settings.page.appearance.title`);case`chat`:return _(`settings.page.chat.title`);case`shortcuts`:return _(`settings.page.shortcuts.title`);case`sessions`:return _(`settings.page.sessions.title`);case`summary-ai`:return _(`settings.page.summaryAI.title`);case`magic-prompts`:return _(`settings.page.magicPrompts.title`);case`snippets`:return _(`settings.page.snippets.title`);case`notifications`:return _(`settings.page.notifications.title`);case`voice`:return _(`settings.page.voice.title`);case`about`:return _(`settings.page.about.title`);default:return _(`settings.view.home.title`)}},t[67]=_,t[68]=it);let at=it,ot;t[69]!==at||t[70]!==Pe||t[71]!==W||t[72]!==_||t[73]!==Ie?(ot=Cp({query:W,runtimeCtx:{...Pe,isDesktopLocalOrigin:De,isMac:Ae,isWindows:Me},visiblePageSlugs:Ie.map(Jp),t:_,getPageTitle:at}),t[69]=at,t[70]=Pe,t[71]=W,t[72]=_,t[73]=Ie,t[74]=ot):ot=t[74];let st=ot,ct=em,lt;if(t[75]!==st){lt=[];let e=new Map;for(let t of st){let n=e.get(t.page);n||(n={page:t.page,pageTitle:t.pageTitle,results:[]},e.set(t.page,n),lt.push(n)),n.results.push(t)}t[75]=st,t[76]=lt}else lt=t[76];let ut=lt,dt;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(dt=()=>{oe(0),Se.current=0,Ce.current=!1},t[77]=dt):dt=t[77];let pt;t[78]===W?pt=t[79]:(pt=[W],t[78]=W,t[79]=pt),Q.useEffect(dt,pt);let mt,ht;t[80]===ae?(mt=t[81],ht=t[82]):(mt=()=>{Se.current=ae},ht=[ae],t[80]=ae,t[81]=mt,t[82]=ht),Q.useEffect(mt,ht);let gt,K;t[83]===ae?(gt=t[84],K=t[85]):(gt=()=>{xe.current[ae]?.scrollIntoView({block:`nearest`})},K=[ae],t[83]=ae,t[84]=gt,t[85]=K),Q.useEffect(gt,K);let vt,yt;t[86]!==ae||t[87]!==st.length?(vt=()=>{ae>=st.length&&oe(Math.max(0,st.length-1)),xe.current.length=st.length},yt=[ae,st.length],t[86]=ae,t[87]=st.length,t[88]=vt,t[89]=yt):(vt=t[88],yt=t[89]),Q.useEffect(vt,yt);let bt;t[90]!==y||t[91]!==Qe?(bt=e=>{let t=ct(e);ie(t),Qe(e.page),y&&N(`page-content`),e.id===`plugins.create`&&typeof window<`u`&&window.setTimeout(tm,50)},t[90]=y,t[91]=Qe,t[92]=bt):bt=t[92];let xt=bt,St;t[93]!==xt||t[94]!==W||t[95]!==st?(St=e=>{if(W.trim()){if(e.key===`Escape`){e.preventDefault(),ne(``);return}if(st.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),Ce.current=!0,oe(e=>(e+1)%st.length);return}if(e.key===`ArrowUp`){e.preventDefault(),Ce.current=!0,oe(e=>(e-1+st.length)%st.length);return}if(e.key===`Enter`){e.preventDefault();let t=(Se.current%st.length+st.length)%st.length,n=st[t]??st[0];n&&xt(n)}}}},t[93]=xt,t[94]=W,t[95]=st,t[96]=St):St=t[96];let Ct=St,wt;t[97]===re?wt=t[98]:(wt=()=>{let e=re;if(!e)return;let t=!1,n=window.requestAnimationFrame(()=>{if(t)return;let n=typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`),r=pe.current?.querySelector(`[data-settings-item="${n}"]`);r&&(ie(null),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.setAttribute(`data-settings-search-highlight`,`true`),window.setTimeout(()=>{r.removeAttribute(`data-settings-search-highlight`)},1600))});return()=>{t=!0,window.cancelAnimationFrame(n)}},t[97]=re,t[98]=wt);let Tt;t[99]!==re||t[100]!==E?(Tt=[re,E],t[99]=re,t[100]=E,t[101]=Tt):Tt=t[101],Q.useEffect(wt,Tt);let Et;t[102]===_?Et=t[103]:(Et=()=>(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:_(`settings.view.unavailable.title`)}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground mt-1`,children:_(`settings.view.unavailable.description`)})]})}),t[102]=_,t[103]=Et);let Dt=Et,Ot=nm,kt;t[104]!==y||t[105]!==Pe.isVSCode||t[106]!==E?(kt=()=>{if(y){if(be()||Pe.isVSCode){N(`page-sidebar`);return}if((typeof window<`u`?Lp(window.history.state):null)?.page===E){window.history.back();return}N(`page-sidebar`)}},t[104]=y,t[105]=Pe.isVSCode,t[106]=E,t[107]=kt):kt=t[107];let At=kt,jt;t[108]!==At||t[109]!==y||t[110]!==F||t[111]!==r||t[112]!==Qe||t[113]!==Dt||t[114]!==Pe?(jt=e=>{let t=$r(e);if(t&&!Pp(t,Pe))return Dt();switch(e){case`home`:return(0,$.jsx)(Bp,{onOpen:Qe});case`projects`:return(0,$.jsx)(bl,{});case`instances`:return r??Dt();case`remote-instances`:return(0,$.jsx)(zu,{});case`agents`:return(0,$.jsx)(Xa,{});case`assistants`:return(0,$.jsx)(_o,{onItemDeleted:y?At:void 0});case`behavior`:return(0,$.jsx)(Ao,{});case`commands`:return(0,$.jsx)(Ro,{});case`mcp`:return(0,$.jsx)(Cs,{});case`plugins`:return(0,$.jsx)(yc,{});case`global-config`:return(0,$.jsx)(Sc,{});case`skills.installed`:return(0,$.jsx)(dl,{view:`installed`});case`skills.catalog`:return(0,$.jsx)(dl,{view:`catalog`});case`providers`:return(0,$.jsx)(nd,{});case`usage`:return(0,$.jsx)(Ed,{});case`about`:return(0,$.jsx)(`div`,{className:q(`h-full overflow-auto px-5 py-6`,F&&`h-auto overflow-visible p-3`),children:(0,$.jsx)(Ni,{})});case`magic-prompts`:return(0,$.jsx)(Fd,{});case`snippets`:return(0,$.jsx)(Bd,{});case`git`:return(0,$.jsx)(Jd,{});case`appearance`:case`chat`:case`shortcuts`:case`sessions`:case`summary-ai`:case`notifications`:case`voice`:{let t=rt[e]??`visual`;return(0,$.jsx)(dp,{section:t,flowMobile:F})}default:return(0,$.jsx)(Bp,{onOpen:Qe})}},t[108]=At,t[109]=y,t[110]=F,t[111]=r,t[112]=Qe,t[113]=Dt,t[114]=Pe,t[115]=jt):jt=t[115];let Mt=jt,Nt,Pt;t[116]!==h||t[117]!==y||t[118]!==M||t[119]!==E?(Nt=()=>{if(!y||!h||M!==`nav`||E===`home`||I.current===E)return;let e=$r(E);!e||e.slug===`home`||(I.current=E,N(e.kind===`split`?`page-sidebar`:`page-content`))},Pt=[h,y,M,E],t[116]=h,t[117]=y,t[118]=M,t[119]=E,t[120]=Nt,t[121]=Pt):(Nt=t[120],Pt=t[121]),Q.useEffect(Nt,Pt);let Ft=y&&M!==`nav`,It=y&&M===`page-content`&&G?.kind===`split`,Lt=M===`page-content`&&G?.kind===`split`&&!It,Rt;t[122]!==It||t[123]!==Ft||t[124]!==_?(Rt=_(It?`settings.view.actions.back`:Ft?`settings.view.actions.backToSettings`:`settings.view.actions.closeSettings`),t[122]=It,t[123]=Ft,t[124]=_,t[125]=Rt):Rt=t[125];let zt=Rt,Vt=Yt(),Ut;t[126]===Pe.isVSCode?Ut=t[127]:(Ut=e=>{if(typeof window>`u`||Pe.isVSCode||be())return;let t=Lp(window.history.state);(t?.page!==e||t.stage!==`page-content`)&&window.history.pushState({...Rp(),[kp]:{page:e,stage:`page-content`}},``,window.location.href)},t[126]=Pe.isVSCode,t[127]=Ut);let Wt=Ut,Gt;t[128]!==Wt||t[129]!==E?(Gt=()=>{N(`page-content`),Wt(E)},t[128]=Wt,t[129]=E,t[130]=Gt):Gt=t[130];let Kt=Gt,qt;t[131]!==It||t[132]!==At?(qt=()=>{if(It){At();return}N(`nav`)},t[131]=It,t[132]=At,t[133]=qt):qt=t[133];let Jt=qt,Xt;t[134]!==G?.kind||t[135]!==M?(Xt=()=>{if(M===`page-content`){_e.current=ge.current,ve.current=G?.kind===`split`?he.current:me.current;return}_e.current=he.current,ve.current=me.current},t[134]=G?.kind,t[135]=M,t[136]=Xt):Xt=t[136];let Y=G?.kind,Zt;t[137]!==M||t[138]!==Y?(Zt=[Y,M],t[137]=M,t[138]=Y,t[139]=Zt):Zt=t[139],Q.useLayoutEffect(Xt,Zt);let Qt=`mobile-settings:${E}`,$t=F&&M!==`nav`,en;t[140]!==Jt||t[141]!==Qt||t[142]!==$t?(en={id:Qt,active:$t,onBack:Jt,surfaceRef:_e,underlayRef:ve},t[140]=Jt,t[141]=Qt,t[142]=$t,t[143]=en):en=t[143],gr(en);let tn,nn;t[144]!==y||t[145]!==Pe.isVSCode||t[146]!==E?(tn=()=>{if(!y||Pe.isVSCode||be())return;let e=e=>{if($r(E)?.kind===`split`){if(Lp(e.state)?.page===E){N(`page-content`);return}N(rm)}};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},nn=[y,Pe.isVSCode,E],t[144]=y,t[145]=Pe.isVSCode,t[146]=E,t[147]=tn,t[148]=nn):(tn=t[147],nn=t[148]),Q.useEffect(tn,nn);let rn;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(rn=()=>{N(`page-sidebar`)},t[149]=rn):rn=t[149];let an=rn,on=()=>{let e=W.trim().length>0;return(0,$.jsxs)(`div`,{className:q(`flex h-full flex-col overflow-hidden`,y&&`oc-settings-navigation-content`,F&&`h-auto w-full overflow-visible`),children:[(0,$.jsx)(`div`,{className:q(`px-2 pt-3`,y&&`oc-mobile-settings-search`),children:(0,$.jsxs)(`div`,{className:q(`flex h-10 items-center gap-1.5 rounded-md border border-border bg-background/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-primary/40 sm:h-8`,y&&`oc-mobile-settings-search-field`),children:[(0,$.jsx)(J,{name:`search`,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`input`,{value:W,onChange:e=>ne(e.target.value),onKeyDown:Ct,placeholder:_(`settings.view.search.placeholder`),"aria-label":_(`settings.view.search.aria`),className:`typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70`}),e&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ne(``),"aria-label":_(`settings.view.search.clear`),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5`,children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsx)(`div`,{className:q(`flex-1 min-h-0 overflow-y-auto overflow-x-hidden`,F&&`w-full flex-none overflow-visible`),children:(0,$.jsx)(`div`,{className:q(y?`oc-mobile-settings-nav-list flex min-w-0 flex-col`:`flex flex-col gap-0.5 px-2 pb-2 pt-4`),children:e?st.length>0?(()=>{let e=0;return ut.map(t=>{let n=t.results.map(t=>{let n=e;e+=1;let r=n===ae,i=!!t.description;return(0,$.jsxs)(`button`,{type:`button`,ref:e=>{xe.current[n]=e},onMouseMove:()=>{Ce.current=!1,oe(n)},onClick:()=>xt(t),className:q(y?`oc-mobile-settings-row oc-mobile-settings-search-result`:`flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`min-h-11 py-1.5`:`py-2`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.title}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 line-clamp-2`,children:t.description})]}),y?(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]},t.id)});return y?(0,$.jsx)(wp,{label:t.pageTitle,ariaLabel:t.pageTitle,children:n},t.page):(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70`,children:t.pageTitle}),n]},t.page)})})():(0,$.jsx)(`div`,{className:`px-2 py-6 text-center typography-ui text-muted-foreground`,children:_(`settings.view.search.noResults`)}):(0,$.jsx)($.Fragment,{children:Re.map((e,t)=>{let{group:n,pages:r}=e,i=_(`settings.view.navigation.groups.${n}`),a=r.map(e=>{let t=E===e.slug,n=zp(e.slug);return!n&&e.slug!==`mcp`?null:(0,$.jsx)(fn,{children:(0,$.jsx)(un,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Qe(e.slug),"aria-current":t?`page`:void 0,className:q(y?`oc-mobile-settings-row`:`flex h-8 w-full items-center gap-2 overflow-hidden rounded-md px-2 text-left`,t&&!y?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:[e.slug===`mcp`?(0,$.jsx)(Br,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(J,{name:n,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden whitespace-nowrap transition-opacity duration-150 opacity-100`,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate`,children:at(e.slug)})}),y?(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]})})},e.slug)});return y?(0,$.jsx)(wp,{label:i,ariaLabel:i,children:a},n):(0,$.jsxs)(`div`,{className:q(`space-y-0.5`,t>0&&`pt-3`),children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 typography-micro font-medium text-muted-foreground/70`,children:i}),a]},n)})})})}),(0,$.jsx)(`div`,{className:q(`overflow-hidden transition-opacity duration-150 opacity-100`,y&&`oc-mobile-settings-footer`),children:(0,$.jsx)(`div`,{className:q(`border-t border-border bg-sidebar px-2 py-1 space-y-0.5`,y&&`oc-mobile-floating-surface oc-mobile-settings-card`),children:!Pe.isVSCode&&(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:q(y?`oc-mobile-settings-row`:`flex h-7 w-full items-center gap-2 rounded-md px-2 overflow-hidden whitespace-nowrap`,`text-sm font-semibold text-sidebar-foreground/90`,`hover:text-sidebar-foreground hover:bg-interactive-hover`),onClick:am,children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:_(`settings.view.actions.reloadOpenCode`)})]})}),(0,$.jsx)(dn,{children:_(`settings.view.actions.reloadOpenCodeTooltip`)})]})})})]})},cn=()=>(0,$.jsx)(`div`,{className:q(`flex-1 min-h-0 overflow-hidden`,F?`w-full flex-none overflow-visible bg-transparent`:Pe.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(`div`,{className:q(`flex h-full min-h-0 flex-col`,F&&`h-auto w-full overflow-visible`),children:(0,$.jsx)(Ln,{children:on()})})}),ln=e=>{let t=e===void 0?M:e;if(t===`nav`)return cn();let n=q(`flex-1 min-h-0 overflow-hidden bg-transparent`,F?`w-full flex-none overflow-visible`:`px-[var(--oc-mobile-page-inline-inset)]`);if(!G)return(0,$.jsx)(`div`,{className:n});if(t===`page-sidebar`){if(G.kind!==`split`){let e=Mt(E);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(si,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Ln,{children:e})})})}return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(si,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Ln,{children:Ot(E,{onItemSelect:Kt})})})})}let r=Mt(E);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(si,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Ln,{children:r})})})},pn;t[150]!==G||t[151]!==Qe||t[152]!==Mt||t[153]!==Pe.isVSCode||t[154]!==E?(pn=()=>!G||E===`home`?(0,$.jsx)(Bp,{onOpen:Qe}):G.kind===`split`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:q(`w-[264px] min-w-[264px] border-r`,Pe.isVSCode?`bg-background`:`bg-sidebar`),style:{borderColor:`var(--interactive-border)`},children:(0,$.jsx)(Ln,{children:Ot(E,{})})}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(Ln,{children:Mt(E)})})]}):(0,$.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(Ln,{children:Mt(E)})}),t[150]=G,t[151]=Qe,t[152]=Mt,t[153]=Pe.isVSCode,t[154]=E,t[155]=pn):pn=t[155];let mn=pn,hn=e=>(0,$.jsx)(Bt,{sticky:!0,title:(e===void 0?M:e)===`nav`?_(`settings.view.home.title`):G?at(G.slug):_(`settings.view.home.title`),backAriaLabel:zt,onBack:Ft?Jt:n,actions:[...Lt?[{icon:`list-unordered`,ariaLabel:_(`settings.view.actions.openSectionList`),onClick:an}]:[],...n?[{icon:`close`,ariaLabel:_(`settings.view.actions.closeSettings`),title:_(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:Vt}),onClick:n}]:[]]});if(F){let e=M!==`nav`,n=e&&G?.kind===`split`,r=M===`page-content`,i=M===`page-sidebar`,a=r&&G?.kind===`split`,o=e&&!a,s;t[156]===_?s=t[157]:(s=_(`mobile.settings.placeholder.title`),t[156]=_,t[157]=s);let c;return t[158]===s?c=t[159]:(c=(0,$.jsx)(Zr,{title:s}),t[158]=s,t[159]=c),(0,$.jsxs)(`div`,{ref:pe,"data-settings-view":`true`,"data-mobile-settings-detail-active":e?`true`:void 0,className:`oc-settings-workspace oc-settings-workspace-mobile h-auto w-full min-w-0 overflow-visible bg-transparent`,children:[(0,$.jsxs)(`div`,{ref:me,"data-mobile-settings-stage":`nav`,"data-mobile-navigation-underlay":o?`true`:void 0,"aria-hidden":e?`true`:void 0,inert:e?!0:void 0,className:`oc-mobile-settings-root-surface fixed inset-0 z-20 flex h-[100dvh] w-full min-w-0 max-w-full flex-col gap-[var(--oc-mobile-page-gap)] overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)] pb-[calc(var(--oc-mobile-dock-height)+2.5rem+var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px)))] pt-[calc(var(--oc-safe-area-top,env(safe-area-inset-top,0px))+1rem)] [contain:layout_paint]`,children:[c,cn()]}),n?(0,$.jsxs)(`div`,{ref:he,"data-mobile-settings-stage":`page-sidebar`,"data-mobile-navigation-underlay":a?`true`:void 0,"data-mobile-settings-push-surface":`true`,"aria-hidden":i?void 0:`true`,inert:!i||void 0,className:`fixed inset-0 z-40 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[hn(`page-sidebar`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)]`,children:ln(`page-sidebar`)})]}):null,r?(0,$.jsxs)(`div`,{ref:ge,"data-mobile-settings-stage":`page-content`,"data-mobile-settings-push-surface":`true`,className:`fixed inset-0 z-50 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[hn(`page-content`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)]`,children:ln(`page-content`)})]}):null]})}let gn=y?`oc-settings-workspace-mobile bg-transparent`:`oc-settings-workspace-desktop bg-background`,_n=F&&`h-auto w-full overflow-visible`,vn;t[160]!==gn||t[161]!==_n?(vn=q(`oc-settings-workspace relative flex h-full min-h-0 flex-col overflow-hidden`,gn,_n),t[160]=gn,t[161]=_n,t[162]=vn):vn=t[162];let yn=y&&!P?hn():y?null:(0,$.jsxs)($.Fragment,{children:[Ft&&(0,$.jsx)(`div`,{className:q(`absolute left-3 z-50`,a?`top-2`:`top-3`),children:(0,$.jsx)(`button`,{type:`button`,onClick:Jt,"aria-label":_(`settings.view.actions.back`),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(J,{name:`arrow-left-s`,className:`h-5 w-5`})})}),n&&(0,$.jsx)(`div`,{className:q(`absolute right-0.5 z-50`,a?`top-0.5`:`top-1`),children:(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":_(`settings.view.actions.closeSettings`),title:_(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:Vt}),className:`inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(J,{name:`close`,className:`h-5 w-5`})})})]}),bn=F&&`w-full flex-none overflow-visible`,xn;t[163]===bn?xn=t[164]:(xn=q(`flex flex-1 min-h-0 overflow-hidden`,bn),t[163]=bn,t[164]=xn);let Sn=y?ln():(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:q(`relative flex h-full min-h-0 flex-col overflow-hidden border-r`,Te?`bg-sidebar`:Pe.isVSCode?`bg-background`:`bg-sidebar`,le?``:`transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]`),style:{width:`${U}px`,minWidth:`${U}px`,borderColor:`var(--interactive-border)`},children:[(0,$.jsx)(`div`,{className:q(`absolute right-0 top-0 z-20 h-full w-[6px] -mr-[3px] cursor-col-resize`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,le?`bg-primary/30`:`bg-transparent hover:bg-primary/20`),tabIndex:0,onPointerDown:Ge,onKeyDown:qe,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":Ep,"aria-valuemax":Dp,"aria-valuenow":U,"aria-label":_(`settings.view.actions.resizeNavigation`)}),(0,$.jsx)(Ln,{children:on()})]}),(0,$.jsx)(`div`,{className:`oc-settings-detail-pane flex-1 overflow-hidden bg-background`,children:mn()})]}),Cn;t[165]!==xn||t[166]!==Sn?(Cn=(0,$.jsx)(`div`,{className:xn,children:Sn}),t[165]=xn,t[166]=Sn,t[167]=Cn):Cn=t[167];let wn;return t[168]!==vn||t[169]!==yn||t[170]!==Cn?(wn=(0,$.jsxs)(`div`,{ref:pe,"data-settings-view":`true`,className:vn,children:[yn,Cn]}),t[168]=vn,t[169]=yn,t[170]=Cn,t[171]=wn):wn=t[171],wn};function Hp(e){return e.settingsPage}function Up(e){return e.isSettingsDialogOpen}function Wp(e){return e.setSettingsPage}function Gp(e){return e.openSettingsRequestRevision}function Kp(e){return e.slug!==`home`}function qp(e){return e.activeProjectId}function Jp(e){return e.slug}function Yp(e){return e.name}function Xp(e){return e.name}function Zp(e){return e.name}function Qp(e){return e.name}function $p(e){return e.name}function em(e){if(e.id.startsWith(`assistants.`)){if(e.id===`assistants.instance-enabled`)return e.id;if(e.id===`assistants.default-share`){let t=Ht.getState(),n=zt()?.assistants??[],r=n.some(e=>e.id===t.settingsSelectedAssistantID);return t.selectSettingsAssistant(r?t.settingsSelectedAssistantID:n[0]?.id??null),e.id}return Ht.getState().requestCreate(),e.id===`assistants.create`?`assistants.name`:e.id}if(e.id.startsWith(`agents.`)){let t=et.getState(),n=Ip(`new-agent`,at().map(Yp));return t.setAgentDraft({name:n,scope:`user`}),t.setSelectedAgent(n),e.id===`agents.create`?`agents.name`:e.id}if(e.id.startsWith(`commands.`)){let t=Gi.getState(),n=Ip(`new-command`,ot().map(Xp));return t.setCommandDraft({name:n,scope:`user`}),t.setSelectedCommand(n),e.id===`commands.create`?`commands.name`:e.id}if(e.id.startsWith(`mcp.`)){let t=$i.getState(),n=Ip(`new-mcp-server`,jr().map(Zp));return t.setMcpDraft({name:n,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),t.setSelectedMcp(n),e.id===`mcp.create`?`mcp.server`:e.id}if(e.id.startsWith(`snippets.`)){let t=sn.getState(),n=Ip(`new-snippet`,t.snippets.map(Qp));return t.setSnippetDraft({name:n,scope:`global`}),t.setSelectedSnippet(n),e.id===`snippets.create`?`snippets.content`:e.id}if(e.id.startsWith(`skills.`)){let t=Qe(H),n=da.getState(),r=Ip(`new-skill`,t.map($p));return n.setSkillDraft({name:r,scope:`user`,source:`opencode`,description:``,instructions:``}),n.setSelectedSkill(r),e.id===`skills.create`?`skills.basic-information`:e.id}return e.id===`providers.connect`&&G.getState().setSelectedProvider(Mp),e.id===`plugins.create`?`plugins.spec`:e.id}function tm(){window.dispatchEvent(new CustomEvent(`openchamber:settings-open-plugin-add`))}function nm(e,t){switch(e){case`projects`:return(0,$.jsx)(pl,{onItemSelect:t.onItemSelect});case`agents`:return(0,$.jsx)(Oa,{onItemSelect:t.onItemSelect});case`assistants`:return(0,$.jsx)(go,{onItemSelect:t.onItemSelect});case`commands`:return(0,$.jsx)(jo,{onItemSelect:t.onItemSelect});case`mcp`:return(0,$.jsx)(Ho,{onItemSelect:t.onItemSelect});case`plugins`:return(0,$.jsx)(ac,{onItemSelect:t.onItemSelect});case`skills.installed`:return(0,$.jsx)(Tc,{onItemSelect:t.onItemSelect});case`providers`:return(0,$.jsx)(Hu,{onItemSelect:t.onItemSelect});case`usage`:return(0,$.jsx)(id,{onItemSelect:t.onItemSelect});case`magic-prompts`:return(0,$.jsx)(kd,{onItemSelect:t.onItemSelect});case`snippets`:return(0,$.jsx)(Id,{onItemSelect:t.onItemSelect});default:return null}}function rm(e){return e===`page-content`?`page-sidebar`:e}function im(){}function am(){We({message:`Restarting OpenCode…`,mode:`projects`,scopes:[`all`]}).catch(im)}export{zi as a,Pi as c,$i as i,Ni as l,Tp as n,Ii as o,Bl as r,Fi as s,Vp as t};
|
|
21
|
+
}`,rows:8,className:`font-mono typography-meta resize-y`,spellCheck:!1,"data-bwignore":`true`,"data-1p-ignore":`true`}),Ke&&(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-error)]`,children:Ke}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:$e,type:`button`,children:[(0,$.jsx)(J,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.importDialog.pasteFromClipboard`)]})})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{variant:`outline`,onClick:()=>{Ue(!1),Ge(``),qe(null)},className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{onClick:et,disabled:!We.trim(),size:`sm`,children:e(`settings.common.actions.import`)})]})]})}),(0,$.jsx)(Yt,{open:pe,onOpenChange:e=>{!e&&!ge&&me(!1)},children:(0,$.jsxs)(Kt,{className:`max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.mcp.page.deleteDialog.title`,{name:n??``})}),(0,$.jsxs)(Jt,{children:[e(`settings.mcp.page.deleteDialog.descriptionPrefix`),` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),`.`,` `,e(`settings.mcp.page.deleteDialog.descriptionSuffix`)]})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{variant:`outline`,onClick:()=>me(!1),disabled:ge,className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{variant:`destructive`,size:`sm`,onClick:nt,disabled:ge,children:e(ge?`settings.mcp.page.actions.deleting`:`settings.common.actions.delete`)})]})]})})]})},Ts=()=>{try{let e=ft.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=ye.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},Es=800,Ds=5e3,Os=`__default__`,ks=new Map,As=new Map,js=1500,Ms=e=>e?.trim()||Os,Ns=e=>{ks.delete(Ms(e))},Ps=fe()(me(pe((e,t)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:t=>e({selectedId:t}),setDraft:t=>e({draft:t}),loadPlugins:async n=>{let r=Ts(),i=Ms(r),a=Date.now(),o=ks.get(i)??0,s=t().entries.length>0||t().files.length>0;if(!n?.force&&s&&a-o<Ds)return!0;let c=As.get(i);if(!n?.force&&c)return c;let l=(async()=>{e({isLoading:!0});try{let a=await L(Fs(`/api/config/plugins`,r),{headers:zs(r)});if(!a.ok)throw Error(`Failed to load plugins`);let o=await Us(a);return e({entries:o.entries??[],files:o.files??[],isLoading:!1}),ks.set(i,Date.now()),n?.force||t().loadRegistryInfo(),!0}catch(t){return console.error(`[PluginsStore] Failed to load plugins:`,t),e({isLoading:!1}),!1}})();As.set(i,l);try{return await l}finally{As.delete(i)}},loadRegistryInfo:async n=>{let r=Ls(n?.specs??t().entries.map(e=>e.spec));if(r.length===0){e({isLoadingRegistry:!1});return}e({isLoadingRegistry:!0});try{let i=Ts(),a={...t().registryInfo};for(let e of Rs(r)){let t=await L(Is(e,n?.force===!0,i),{headers:zs(i)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let r=await Us(t);for(let e of r.results??[])a[e.spec]=e}e({registryInfo:a,isLoadingRegistry:!1})}catch(t){console.error(`[PluginsStore] Failed to load plugin registry info:`,t),e({isLoadingRegistry:!1})}},updateToLatest:async e=>{let n=t().entries.find(t=>t.id===e);if(!n)return{ok:!1};let r=t().registryInfo[n.spec];return!r||r.kind!==`npm-ok`||!r.hasUpdate||!r.latestVersion?{ok:!1}:await t().updateEntry(e,{spec:`${r.name}@${r.latestVersion}`})},createEntry:async e=>{let n=await Hs(`Creating plugin entry…`,async t=>await L(Fs(`/api/config/plugins/entry`,t),{method:`POST`,headers:Bs(t),body:JSON.stringify(Vs(e))}),t);return n.ok&&t().loadRegistryInfo({specs:[e.spec],force:!0}),n},updateEntry:async(e,n)=>{let r=t().entries.find(t=>t.id===e)?.spec,i=n.spec??r,a=await Hs(`Updating plugin entry…`,async t=>await L(Fs(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`PATCH`,headers:Bs(t),body:JSON.stringify(Vs(n))}),t);return a.ok&&i&&t().loadRegistryInfo({specs:[i],force:!0}),a},deleteEntry:async n=>{let r=t().entries.find(e=>e.id===n),i=await Hs(`Deleting plugin entry…`,async e=>await L(Fs(`/api/config/plugins/entry/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:zs(e)}),t);if(i.ok&&t().selectedId===n&&e({selectedId:null}),i.ok&&r){let n={...t().registryInfo};delete n[r.spec],e({registryInfo:n})}return i},readFile:async e=>{try{let t=Ts(),n=await L(Fs(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:zs(t)});if(!n.ok)throw Error(`Failed to read plugin file`);return await Us(n)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Hs(`Creating plugin file…`,async t=>await L(Fs(`/api/config/plugins/file`,t),{method:`POST`,headers:Bs(t),body:JSON.stringify(e)}),t),updateFile:async(e,n)=>Hs(`Updating plugin file…`,async t=>await L(Fs(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{method:`PUT`,headers:Bs(t),body:JSON.stringify(n)}),t),deleteFile:async n=>{let r=await Hs(`Deleting plugin file…`,async e=>await L(Fs(`/api/config/plugins/file/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:zs(e)}),t);return r.ok&&t().selectedId===n&&e({selectedId:null}),r},getById:e=>t().entries.find(t=>t.id===e)??t().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:p(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Fs(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Is(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Ls(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function Rs(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>js?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function zs(e){return e?{"x-opencode-directory":e}:void 0}function Bs(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Vs(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Hs(e,t,n){kt(e);let r=!1;try{let e=Ts(),i=await t(e),a=await Us(i).catch(()=>null);if(!i.ok)throw Error(a?.error||`Failed to update plugin configuration`);return Ns(e),a?.requiresReload&&(r=!0,await St({message:a.message,delayMs:a.reloadDelayMs??Es,scopes:[`all`]})),await n().loadPlugins({force:!0}),{ok:!0,reloadFailed:a?.reloadFailed===!0,message:a?.message,warning:a?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}finally{r||dt()}}async function Us(e){return await e.json()}var Ws=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function Gs(e){let t=e.trim();if(t===``)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}var Ks=({open:e,onOpenChange:t,defaultScope:n=`user`})=>{let{t:r}=ke(),i=Ps(e=>e.createEntry),a=Ps(e=>e.createFile),[o,s]=Q.useState(`npm`),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(n),[v,y]=Q.useState(!1),b=Q.useCallback(()=>{l(``),d(``),p(``),h(``),_(n)},[n]);Q.useEffect(()=>{e&&(s(`npm`),b())},[e,b]);let x=e=>{e!==o&&(s(e),b())},S=Q.useMemo(()=>Gs(u),[u]),C=!S.ok,w=o===`file`&&f.trim()!==``&&!Ws.test(f.trim()),T=(o===`npm`||o===`path`)&&c.trim()===``,E=o===`file`&&m.trim()===``,D=o===`file`&&f.trim()===``,O=v||C||o===`npm`&&T||o===`path`&&T||o===`file`&&(D||w||E),k=async()=>{if(!O){y(!0);try{let e;e=o===`file`?await a({fileName:f.trim(),content:m,scope:g}):await i({spec:c.trim(),options:S.ok?S.value:void 0,scope:g}),e.ok?(K.success(e.message||r(`settings.plugins.toast.created`)),e.reloadFailed&&K.warning(r(`settings.plugins.toast.reloadFailed`)),t(!1)):K.error(e.message||r(`settings.plugins.sidebar.toast.deleteFailed`))}finally{y(!1)}}},A=Q.useMemo(()=>[{id:`npm`,label:r(`settings.plugins.dialog.add.tab.npm`)},{id:`path`,label:r(`settings.plugins.dialog.add.tab.path`)},{id:`file`,label:r(`settings.plugins.dialog.add.tab.file`)}],[r]);return(0,$.jsx)(Yt,{open:e,onOpenChange:e=>{!e&&v||t(e)},children:(0,$.jsxs)(Kt,{className:`max-w-xl`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:r(`settings.plugins.dialog.add.title`)}),(0,$.jsx)(Jt,{children:r(`settings.plugins.sidebar.empty.description`)})]}),(0,$.jsx)(wr,{items:A,activeId:o,onSelect:e=>x(e),layoutMode:`fit`,variant:`active-pill`,activePillLowercase:!1,className:`h-10`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(o===`npm`||o===`path`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.spec`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-spec`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.spec`)}),(0,$.jsx)(un,{id:`plugin-spec`,value:c,onChange:e=>l(e.target.value),placeholder:r(`settings.plugins.page.field.spec.placeholder`),"aria-invalid":!T&&void 0,disabled:v}),T&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`settings.plugins.validation.specRequired`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`plugins.options`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-options`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.options`)}),(0,$.jsx)(xr,{id:`plugin-options`,value:u,onChange:e=>d(e.target.value),rows:5,className:`font-mono`,hasError:C,disabled:v}),C&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.page.field.options.invalidJson`)})]})]}),o===`file`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.content`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-filename`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.fileName`)}),(0,$.jsx)(un,{id:`plugin-filename`,value:f,onChange:e=>p(e.target.value),placeholder:`my-plugin.ts`,"aria-invalid":w||void 0,disabled:v}),w&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.validation.fileName`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-content`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.content`)}),(0,$.jsx)(xr,{id:`plugin-content`,value:m,onChange:e=>h(e.target.value),rows:16,className:`font-mono`,disabled:v})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.scope`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-4`,children:[`user`,`project`].map(e=>{let t=g===e,n=r(e===`user`?`settings.plugins.scope.user`:`settings.plugins.scope.project`);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(e),disabled:v,className:`flex items-center gap-2 py-1 text-left disabled:opacity-50`,children:[(0,$.jsx)(Zn,{checked:t,onChange:()=>_(e),ariaLabel:n}),(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/60`),children:n})]},e)})})]})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>t(!1),disabled:v,children:r(`settings.plugins.dialog.add.action.cancel`)}),(0,$.jsxs)(Y,{size:`sm`,onClick:()=>{k()},disabled:O,children:[v?(0,$.jsx)(J,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}):null,r(`settings.plugins.dialog.add.action.submit`)]})]})]})})},qs=e=>{let t=(0,Di.c)(31),{info:n}=e,{t:r}=ke();if(!n)return null;let i=Js;switch(n.kind){case`npm-ok`:{if(!n.hasUpdate||!n.latestVersion)return null;let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`arrow-up-s`,className:`h-3 w-3`}),t[0]=e):e=t[0];let a;t[1]===n.latestVersion?a=t[2]:(a=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[var(--status-success)]`,children:[e,n.latestVersion]}),t[1]=n.latestVersion,t[2]=a);let o;return t[3]!==n.currentVersion||t[4]!==n.latestVersion||t[5]!==r||t[6]!==a?(o=i(a,r(`settings.plugins.registry.badge.update.tooltip`,{current:n.currentVersion??``,latest:n.latestVersion})),t[3]=n.currentVersion,t[4]=n.latestVersion,t[5]=r,t[6]=a,t[7]=o):o=t[7],o}case`npm-missing-version`:{let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[8]=e):e=t[8];let a;return t[9]!==n.currentVersion||t[10]!==n.name||t[11]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingVersion.tooltip`,{version:n.currentVersion,name:n.name})),t[9]=n.currentVersion,t[10]=n.name,t[11]=r,t[12]=a):a=t[12],a}case`npm-missing-package`:{let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[13]=e):e=t[13];let a;return t[14]!==n.name||t[15]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingPackage.tooltip`,{name:n.name})),t[14]=n.name,t[15]=r,t[16]=a):a=t[16],a}case`npm-malformed`:{let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[17]=e):e=t[17];let n;return t[18]===r?n=t[19]:(n=i(e,r(`settings.plugins.registry.badge.malformed.tooltip`)),t[18]=r,t[19]=n),n}case`npm-network`:{let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`cloud-off`,className:`h-3 w-3 text-muted-foreground`}),t[20]=e):e=t[20];let n;return t[21]===r?n=t[22]:(n=i(e,r(`settings.plugins.registry.badge.network.tooltip`)),t[21]=r,t[22]=n),n}case`path-missing`:{let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[23]=e):e=t[23];let a;return t[24]!==n.absolutePath||t[25]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathMissing.tooltip`,{path:n.absolutePath})),t[24]=n.absolutePath,t[25]=r,t[26]=a):a=t[26],a}case`path-unreadable`:{let e;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(J,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[27]=e):e=t[27];let a;return t[28]!==n.absolutePath||t[29]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathUnreadable.tooltip`,{path:n.absolutePath})),t[28]=n.absolutePath,t[29]=r,t[30]=a):a=t[30],a}case`path-ok`:return null;default:return null}};function Js(e,t){return(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 text-xs`,children:e})}),(0,$.jsx)(fn,{children:t})]})}var Ys=1500,Xs=e=>e?.trim()||null,Zs=(e,t,n=!1,r=i())=>k.plugins.registry(e,t,n,r),Qs=(e,t,n=!1,r=i())=>{let a=Xs(e),o=R(t);return{queryKey:Zs(a,o,n,r),queryFn:async({signal:e})=>{let t={};for(let r of nc(o)){let i=await L(tc(r,n,a),{headers:rc(a),signal:e});if(!i.ok)throw Error(`Failed to load plugin registry info`);let o=await i.json();for(let e of o.results??[])t[e.spec]=e}return t},staleTime:n?0:3e5,retry:2}},$s=(e,t)=>{let n=(0,Di.c)(6),r=t!==void 0&&t,i=ft(ic),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=Qs(Xs(i)??Xs(ye.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),we(o)},ec=async(e=H,t,n)=>{let r=Xs(t),a=i(),o=await Qs(r,n,!0,a).queryFn({signal:new AbortController().signal});return e.setQueryData(Zs(r,n,!1,a),o),o};function tc(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function nc(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>Ys){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function rc(e){return e?{"x-opencode-directory":e}:void 0}function ic(e){return e.getActiveProject?.()?.path??null}var ac=e=>e.parsedKind===`npm`?`code-box`:`folder`,oc=e=>{let t=(0,Di.c)(139),{onItemSelect:n,onAddClick:r}=e,{t:i}=ke(),{entries:a,files:o,selectedId:s,setSelected:c,deleteEntry:l,deleteFile:u,loadPlugins:d,updateEntry:f}=Ps(he(sc)),p;t[0]===a?p=t[1]:(p=a.map(cc),t[0]=a,t[1]=p);let m=p,{data:h,isFetching:g}=$s(m,!1),_;t[2]===h?_=t[3]:(_=h??{},t[2]=h,t[3]=_);let v=_,[y,b]=Q.useState(null),[x,S]=Q.useState(!1),[C,w]=Q.useState(!1),T,E;t[4]===d?(T=t[5],E=t[6]):(T=()=>{d()},E=[d],t[4]=d,t[5]=T,t[6]=E),Q.useEffect(T,E);let D,O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{let e=()=>w(!0);return window.addEventListener(`openchamber:settings-open-plugin-add`,e),()=>window.removeEventListener(`openchamber:settings-open-plugin-add`,e)},O=[],t[7]=D,t[8]=O):(D=t[7],O=t[8]),Q.useEffect(D,O);let k;if(t[9]!==a||t[10]!==v){k={userEntries:0,projectEntries:0};for(let e of a){let t=v[e.spec];t?.kind===`npm-ok`&&t.hasUpdate&&(e.scope===`user`?k.userEntries+=1:e.scope===`project`&&(k.projectEntries+=1))}t[9]=a,t[10]=v,t[11]=k}else k=t[11];let A=k,j;t[12]===a?j=t[13]:(j=a.filter(lc),t[12]=a,t[13]=j);let M=j,N;t[14]===a?N=t[15]:(N=a.filter(uc),t[14]=a,t[15]=N);let P=N,F;t[16]===o?F=t[17]:(F=o.filter(dc),t[16]=o,t[17]=F);let I=F,L;t[18]===o?L=t[19]:(L=o.filter(fc),t[18]=o,t[19]=L);let R=L,z=a.length+o.length===0,B;t[20]===r?B=t[21]:(B=()=>{r?r():w(!0)},t[20]=r,t[21]=B);let V=B,H;t[22]!==n||t[23]!==c?(H=e=>{c(e),n?.()},t[22]=n,t[23]=c,t[24]=H):H=t[24];let ee=H,U;t[25]!==a||t[26]!==v||t[27]!==i||t[28]!==f?(U=async e=>{let t=a.find(t=>t.id===e);if(!t)return;let n=v[t.spec];if(!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion)return;let r=n.latestVersion;(await f(e,{spec:`${n.name}@${r}`})).ok?K.success(i(`settings.plugins.toast.updatedToLatest`,{version:r})):K.error(i(`settings.plugins.toast.refreshFailed`))},t[25]=a,t[26]=v,t[27]=i,t[28]=f,t[29]=U):U=t[29];let te=U,W;t[30]!==m||t[31]!==i?(W=async()=>{K.info(i(`settings.plugins.toast.refreshing`));try{await ec(void 0,xt(),m)}catch{K.error(i(`settings.plugins.toast.refreshFailed`))}},t[30]=m,t[31]=i,t[32]=W):W=t[32];let ne=W,re;t[33]!==l||t[34]!==u||t[35]!==y||t[36]!==i?(re=async()=>{if(!y)return;S(!0);let e=y.kind===`entry`?await l(y.id):await u(y.id);e.ok?K.success(e.message||i(`settings.plugins.sidebar.toast.deleted`,{name:y.label})):K.error(i(`settings.plugins.sidebar.toast.deleteFailed`)),b(null),S(!1)},t[33]=l,t[34]=u,t[35]=y,t[36]=i,t[37]=re):re=t[37];let ie=re,ae;t[38]!==ee||t[39]!==te||t[40]!==v||t[41]!==s||t[42]!==i?(ae=e=>{let t=v[e.spec],n=t?.kind===`npm-ok`&&t.hasUpdate&&!!t.latestVersion,r=[];return n&&r.push({label:i(`settings.plugins.sidebar.actions.updateToLatest`),icon:`arrow-up-s`,onClick:()=>void te(e.id)}),r.push({label:i(`settings.common.actions.delete`),icon:`delete-bin`,destructive:!0,onClick:()=>b({kind:`entry`,id:e.id,label:e.spec})}),(0,$.jsx)(Qa,{title:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.spec}),(0,$.jsx)(qs,{info:t})]}),metadata:e.parsedKind===`npm`?i(`settings.plugins.sidebar.kind.npm`):i(`settings.plugins.sidebar.kind.path`),selected:s===e.id,onSelect:()=>ee(e.id),icon:(0,$.jsx)(J,{name:ac(e),className:`h-4 w-4 flex-shrink-0 text-muted-foreground/70`}),actions:r},e.id)},t[38]=ee,t[39]=te,t[40]=v,t[41]=s,t[42]=i,t[43]=ae):ae=t[43];let oe=ae,se;t[44]!==ee||t[45]!==s||t[46]!==i?(se=e=>(0,$.jsx)(Qa,{title:e.fileName,metadata:i(`settings.plugins.sidebar.kind.file`),selected:s===e.id,onSelect:()=>ee(e.id),icon:(0,$.jsx)(J,{name:`file-text`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/70`}),actions:[{label:i(`settings.common.actions.delete`),icon:`delete-bin`,destructive:!0,onClick:()=>b({kind:`file`,id:e.id,label:e.fileName})}]},e.id),t[44]=ee,t[45]=s,t[46]=i,t[47]=se):se=t[47];let ce=se,le;t[48]===i?le=t[49]:(le=(e,t,n,r,a)=>{let o=n===void 0?0:n;return(0,$.jsx)(Z,{cardClassName:a!==void 0&&a?`hidden`:void 0,label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`span`,{children:[e,o>0&&(0,$.jsx)(`span`,{className:`ml-2 text-[var(--status-success)]`,children:i(o===1?`settings.plugins.sidebar.group.updatesAvailable_one`:`settings.plugins.sidebar.group.updatesAvailable_other`,{count:o})})]}),r]}),children:t})},t[48]=i,t[49]=le);let ue=le,de;t[50]===ne?de=t[51]:(de=()=>void ne(),t[50]=ne,t[51]=de);let fe;t[52]===i?fe=t[53]:(fe=i(`settings.plugins.sidebar.actions.refresh`),t[52]=i,t[53]=fe);let pe;t[54]===i?pe=t[55]:(pe=i(`settings.plugins.sidebar.actions.refresh`),t[54]=i,t[55]=pe);let me=g?`size-4 animate-spin`:`size-4`,ge;t[56]===me?ge=t[57]:(ge=(0,$.jsx)(J,{name:`refresh`,className:me}),t[56]=me,t[57]=ge);let _e;t[58]!==g||t[59]!==de||t[60]!==fe||t[61]!==pe||t[62]!==ge?(_e=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:de,disabled:g,"aria-label":fe,title:pe,children:ge}),t[58]=g,t[59]=de,t[60]=fe,t[61]=pe,t[62]=ge,t[63]=_e):_e=t[63];let ve;t[64]===i?ve=t[65]:(ve=i(`settings.plugins.sidebar.actions.addTitle`),t[64]=i,t[65]=ve);let ye;t[66]===i?ye=t[67]:(ye=i(`settings.plugins.sidebar.actions.addTitle`),t[66]=i,t[67]=ye);let be;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(J,{name:`add`,className:`size-4`}),t[68]=be):be=t[68];let xe;t[69]!==V||t[70]!==ve||t[71]!==ye?(xe=(0,$.jsx)(Y,{"data-settings-item":`plugins.create`,type:`button`,variant:`ghost`,size:`icon`,onClick:V,"aria-label":ve,title:ye,children:be}),t[69]=V,t[70]=ve,t[71]=ye,t[72]=xe):xe=t[72];let Se;t[73]!==_e||t[74]!==xe?(Se=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_e,xe]}),t[73]=_e,t[74]=xe,t[75]=Se):Se=t[75];let Ce=Se,we;t[76]!==Ce||t[77]!==oe||t[78]!==ue||t[79]!==i||t[80]!==A||t[81]!==M?(we=M.length>0?ue(i(`settings.plugins.sidebar.group.userEntries`),M.map(oe),A.userEntries,Ce):ue(i(`settings.plugins.sidebar.group.userEntries`),(0,$.jsx)(`span`,{}),0,Ce,!0),t[76]=Ce,t[77]=oe,t[78]=ue,t[79]=i,t[80]=A,t[81]=M,t[82]=we):we=t[82];let Te;t[83]!==z||t[84]!==P||t[85]!==R||t[86]!==oe||t[87]!==ce||t[88]!==ue||t[89]!==i||t[90]!==A||t[91]!==I?(Te=z?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:i(`settings.plugins.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:i(`settings.plugins.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[I.length>0&&ue(i(`settings.plugins.sidebar.group.userFiles`),I.map(ce)),P.length>0&&ue(i(`settings.plugins.sidebar.group.projectEntries`),P.map(oe),A.projectEntries),R.length>0&&ue(i(`settings.plugins.sidebar.group.projectFiles`),R.map(ce))]}),t[83]=z,t[84]=P,t[85]=R,t[86]=oe,t[87]=ce,t[88]=ue,t[89]=i,t[90]=A,t[91]=I,t[92]=Te):Te=t[92];let Ee;t[93]!==we||t[94]!==Te?(Ee=(0,$.jsxs)(eo,{variant:`background`,children:[we,Te]}),t[93]=we,t[94]=Te,t[95]=Ee):Ee=t[95];let De;t[96]===C?De=t[97]:(De=(0,$.jsx)(Ks,{open:C,onOpenChange:w}),t[96]=C,t[97]=De);let Oe=y!==null,Ae;t[98]===x?Ae=t[99]:(Ae=e=>{!e&&!x&&b(null)},t[98]=x,t[99]=Ae);let je;t[100]===i?je=t[101]:(je=i(`settings.plugins.sidebar.deleteDialog.title`),t[100]=i,t[101]=je);let Me;t[102]===je?Me=t[103]:(Me=(0,$.jsx)(qt,{children:je}),t[102]=je,t[103]=Me);let Ne=y?.label??``,Pe;t[104]!==i||t[105]!==Ne?(Pe=i(`settings.plugins.sidebar.deleteDialog.description`,{name:Ne}),t[104]=i,t[105]=Ne,t[106]=Pe):Pe=t[106];let Fe;t[107]===Pe?Fe=t[108]:(Fe=(0,$.jsx)(Jt,{children:Pe}),t[107]=Pe,t[108]=Fe);let Ie;t[109]!==Me||t[110]!==Fe?(Ie=(0,$.jsxs)(Wt,{children:[Me,Fe]}),t[109]=Me,t[110]=Fe,t[111]=Ie):Ie=t[111];let Le;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Le=()=>b(null),t[112]=Le):Le=t[112];let Re;t[113]===i?Re=t[114]:(Re=i(`settings.common.actions.cancel`),t[113]=i,t[114]=Re);let ze;t[115]!==x||t[116]!==Re?(ze=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:Le,disabled:x,children:Re}),t[115]=x,t[116]=Re,t[117]=ze):ze=t[117];let Be;t[118]!==x||t[119]!==i?(Be=i(x?`settings.plugins.sidebar.actions.deleting`:`settings.common.actions.delete`),t[118]=x,t[119]=i,t[120]=Be):Be=t[120];let Ve;t[121]!==ie||t[122]!==x||t[123]!==Be?(Ve=(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:ie,disabled:x,children:Be}),t[121]=ie,t[122]=x,t[123]=Be,t[124]=Ve):Ve=t[124];let He;t[125]!==ze||t[126]!==Ve?(He=(0,$.jsxs)(Gt,{children:[ze,Ve]}),t[125]=ze,t[126]=Ve,t[127]=He):He=t[127];let Ue;t[128]!==Ie||t[129]!==He?(Ue=(0,$.jsxs)(Kt,{className:`max-w-md`,children:[Ie,He]}),t[128]=Ie,t[129]=He,t[130]=Ue):Ue=t[130];let We;t[131]!==Oe||t[132]!==Ae||t[133]!==Ue?(We=(0,$.jsx)(Yt,{open:Oe,onOpenChange:Ae,children:Ue}),t[131]=Oe,t[132]=Ae,t[133]=Ue,t[134]=We):We=t[134];let Ge;return t[135]!==Ee||t[136]!==De||t[137]!==We?(Ge=(0,$.jsxs)($.Fragment,{children:[Ee,De,We]}),t[135]=Ee,t[136]=De,t[137]=We,t[138]=Ge):Ge=t[138],Ge};function sc(e){return{entries:e.entries,files:e.files,selectedId:e.selectedId,setSelected:e.setSelected,deleteEntry:e.deleteEntry,deleteFile:e.deleteFile,loadPlugins:e.loadPlugins,updateEntry:e.updateEntry}}function cc(e){return e.spec}function lc(e){return e.scope===`user`}function uc(e){return e.scope===`project`}function dc(e){return e.scope===`user`}function fc(e){return e.scope===`project`}var pc=e=>{let t=(0,Di.c)(10),{children:n,className:r,outerClassName:i}=e,a;t[0]===i?a=t[1]:(a=q(`h-full`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=q(`oc-settings-page-content mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,r),t[2]=r,t[3]=o);let s;t[4]!==n||t[5]!==o?(s=(0,$.jsx)(`div`,{className:o,children:n}),t[4]=n,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,$.jsx)(br,{outerClassName:a,className:`w-full`,children:s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},mc=({entryId:e,spec:t})=>{let{t:n}=ke(),{data:r}=$s([t]),i=r?.[t],a=Ps(e=>e.updateEntry),[o,s]=Q.useState(!1);if(!i)return null;if(i.kind===`npm-ok`){if(!i.hasUpdate||!i.latestVersion)return null;let t=i.latestVersion,r=i.currentVersion??``,c=async()=>{s(!0);try{(await a(e,{spec:`${i.name}@latest`})).ok?K.success(n(`settings.plugins.toast.updatedToLatest`,{version:t})):K.error(n(`settings.plugins.toast.refreshFailed`))}finally{s(!1)}};return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(J,{name:`arrow-up`,className:`h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-success)]`,children:n(`settings.plugins.registry.banner.updateAvailable.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:n(`settings.plugins.registry.banner.updateAvailable.description`,{current:r,latest:t})})]}),(0,$.jsx)(Y,{variant:`default`,size:`sm`,onClick:()=>void c(),disabled:o,children:n(`settings.plugins.registry.banner.updateAvailable.action`,{latest:t})})]})}if(i.kind===`path-ok`)return null;if(i.kind===`npm-network`)return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(J,{name:`cloud-off`,className:`h-5 w-5 text-muted-foreground shrink-0 mt-0.5`}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:n(`settings.plugins.registry.badge.network.tooltip`)})})]});let c=i.kind===`path-unreadable`,l=c?`var(--status-warning)`:`var(--status-error)`,u=c?`alert`:`error-warning`,d=(()=>{switch(i.kind){case`npm-missing-version`:return n(`settings.plugins.registry.banner.invalid.missingVersion`);case`npm-missing-package`:return n(`settings.plugins.registry.banner.invalid.missingPackage`);case`npm-malformed`:return n(`settings.plugins.registry.banner.invalid.malformed`);case`path-missing`:return n(`settings.plugins.registry.banner.invalid.pathMissing`);case`path-unreadable`:return n(`settings.plugins.registry.banner.invalid.pathUnreadable`)}})();return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(J,{name:u,className:`h-5 w-5 shrink-0 mt-0.5`,style:{color:l}}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label`,style:{color:l},children:n(`settings.plugins.registry.banner.invalid.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:d})]})]})};function hc(e){let t=e.trim();if(t.length===0)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}function gc(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function _c(e){return{mode:`entry`,scope:e.scope,spec:e.spec,optionsJson:gc(e.options),fileName:``,content:``}}function vc(e,t){return{mode:`file`,scope:e.scope,spec:``,optionsJson:``,fileName:e.fileName,content:t}}var yc=e=>{let t=(0,Di.c)(4),{scope:n,label:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`typography-micro font-medium rounded-full px-2 py-0.5`,`bg-[var(--surface-elevated)] text-muted-foreground`,`border border-[var(--interactive-border)]`),t[0]=i):i=t[0];let a;return t[1]!==r||t[2]!==n?(a=(0,$.jsx)(`span`,{className:i,"data-scope":n,children:r}),t[1]=r,t[2]=n,t[3]=a):a=t[3],a},bc=()=>{let{t:e}=ke(),t=Ps(e=>e.selectedId),n=Ps(e=>e.entries),r=Ps(e=>e.files),i=Ps(e=>e.draft),a=Ps(e=>e.setDraft),o=Ps(e=>e.updateEntry),s=Ps(e=>e.updateFile),c=Ps(e=>e.readFile),l=Q.useMemo(()=>t?n.find(e=>e.id===t)??null:null,[n,t]),u=Q.useMemo(()=>t?r.find(e=>e.id===t)??null:null,[r,t]),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),h=Q.useRef(new Map);if(Q.useEffect(()=>{let e=!1;return l?(a(_c(l)),()=>{e=!0}):u?(m(!0),(async()=>{let t=await c(u.id);if(e)return;m(!1);let n=t?.content??``;h.current.set(u.id,n),a(vc(u,n))})(),()=>{e=!0}):(a(null),()=>{e=!0})},[l,u,c,a]),!t)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.plugins.page.empty.select`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.plugins.page.empty.add`)})]})});if(l&&i&&i.mode===`entry`){let t=hc(i.optionsJson),n=t.ok,r=i.spec!==l.spec||i.optionsJson!==gc(l.options),s=()=>{a(_c(l))},c=async()=>{if(!n)return;let r=i.spec.trim();if(!r){K.error(e(`settings.plugins.validation.specRequired`));return}f(!0);try{let n=await o(l.id,{spec:r,options:t.value});n.ok?n.reloadFailed?K.warning(n.message||e(`settings.plugins.toast.reloadFailed`),{description:n.warning}):K.success(n.message||e(`settings.plugins.toast.updated`)):K.error(n.message||e(`settings.plugins.toast.reloadFailed`))}finally{f(!1)}};return(0,$.jsxs)(pc,{children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.plugins.page.header.entry`)}),(0,$.jsx)(yc,{scope:l.scope,label:l.scope===`project`?e(`settings.plugins.sidebar.group.projectEntries`):e(`settings.plugins.sidebar.group.userEntries`)})]})}),(0,$.jsx)(mc,{entryId:l.id,spec:l.spec}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.spec`,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.spec`),cardClassName:`p-3`,children:(0,$.jsx)(un,{value:i.spec,onChange:e=>a({...i,spec:e.target.value}),placeholder:e(`settings.plugins.page.field.spec.placeholder`),className:`font-mono typography-meta`,spellCheck:!1})})}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.options`,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.options`),description:n?void 0:e(`settings.plugins.page.field.options.invalidJson`),cardClassName:`p-3`,children:(0,$.jsx)(xr,{embedded:!0,value:i.optionsJson,onChange:e=>a({...i,optionsJson:e.target.value}),rows:10,className:q(`font-mono typography-meta min-h-[200px]`,!n&&`border-[var(--status-error-border)]`),spellCheck:!1,placeholder:`{ }`})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`default`,size:`sm`,onClick:()=>void c(),disabled:!r||!n||d,children:e(`settings.plugins.page.action.save`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:s,disabled:!r||d,children:e(`settings.plugins.page.action.discard`)})]})]})}if(u&&i&&i.mode===`file`){let t=h.current.get(u.id)??``,n=i.content!==t||i.fileName!==u.fileName,r=()=>{(async()=>{m(!0);let e=(await c(u.id))?.content??``;m(!1),h.current.set(u.id,e),a(vc(u,e))})()},o=async()=>{f(!0);try{let t=await s(u.id,{content:i.content});t.ok?(h.current.set(u.id,i.content),t.reloadFailed?K.warning(t.message||e(`settings.plugins.toast.reloadFailed`),{description:t.warning}):K.success(t.message||e(`settings.plugins.toast.updated`))):K.error(t.message||e(`settings.plugins.toast.reloadFailed`))}finally{f(!1)}};return(0,$.jsxs)(pc,{children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.plugins.page.header.file`)}),(0,$.jsx)(yc,{scope:u.scope,label:u.scope===`project`?e(`settings.plugins.sidebar.group.projectFiles`):e(`settings.plugins.sidebar.group.userFiles`)}),(0,$.jsx)(`span`,{className:q(`typography-micro font-mono rounded-full px-2 py-0.5`,`bg-[var(--surface-elevated)] text-foreground`,`border border-[var(--interactive-border)]`),children:u.fileName})]})}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.content`,children:(0,$.jsx)(Z,{label:e(`settings.plugins.page.field.content`),cardClassName:`p-3`,children:(0,$.jsx)(xr,{embedded:!0,value:i.content,onChange:e=>a({...i,content:e.target.value}),rows:16,className:`font-mono typography-meta min-h-[320px]`,spellCheck:!1,disabled:p})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`default`,size:`sm`,onClick:()=>void o(),disabled:!n||d||p,children:e(`settings.plugins.page.action.save`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:r,disabled:d||p,children:e(`settings.plugins.page.action.discard`)})]})]})}return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(J,{name:`loader-4`,className:`mx-auto mb-3 h-6 w-6 animate-spin opacity-50`})})})},xc={opencode:`OpenCode`,"oh-my-opencode-slim":`oh-my-opencode-slim`,"oh-my-openagent":`oh-my-openagent`};async function Sc(e,t){let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t}function Cc(){let{t:e}=ke(),{currentTheme:t}=dr(),[n,r]=Q.useState([]),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(!0),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),b=Q.useMemo(()=>{let e=u||`opencode.json`,n=e.endsWith(`.jsonc`)?`jsonc`:`json`,r=[ai(t,{syntaxColors:!1})],i=cr(e);return i&&r.push(i),r.push(zr({language:n,themeName:t.metadata.id,theme:vr(t)})),r},[t,u]),x=Q.useCallback(async t=>{p(!0);try{let n=await L(`/api/config/global/${t}`);if(!n.ok)throw Error(await Sc(n,e(`settings.globalConfig.toast.loadFailed`)));let r=await n.json(),i=typeof r.content==`string`?r.content:``;s(i),l(i),d(typeof r.fileName==`string`?r.fileName:``)}catch(t){s(``),l(``),d(``),K.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.loadFailed`))}finally{p(!1)}},[e]);Q.useEffect(()=>{let t=!1;return(async()=>{p(!0);try{let n=await L(`/api/config/global`);if(!n.ok)throw Error(await Sc(n,e(`settings.globalConfig.toast.loadFailed`)));let i=await n.json(),o=Array.isArray(i.targets)?i.targets.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.target!=`string`||typeof t.fileName!=`string`||!(t.target in xc))return[];let n=t.target;return[{id:n,label:xc[n],fileName:t.fileName}]}):[];if(t)return;r(o),a(e=>o.some(t=>t.id===e)?e:o[0]?.id||null)}catch(n){t||(r([]),a(null),K.error(n instanceof Error?n.message:e(`settings.globalConfig.toast.loadFailed`)))}finally{t||p(!1)}})(),()=>{t=!0}},[e]),Q.useEffect(()=>{i&&x(i)},[x,i]);let S=async()=>{if(i){h(!0);try{let t=await L(`/api/config/global/${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:o})});if(!t.ok)throw Error(await Sc(t,e(`settings.globalConfig.toast.saveFailed`)));let n=await t.json(),r=typeof n.content==`string`?n.content:o;s(r),l(r),K.success(e(`settings.globalConfig.toast.saved`)),_(!0)}catch(t){K.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.saveFailed`))}finally{h(!1)}}},C=async()=>{y(!0);try{await We({message:e(`settings.view.actions.reloadOpenCode`),mode:`projects`,scopes:[`all`]}),_(!1)}catch(t){K.error(t instanceof Error?t.message:e(`settings.view.actions.reloadOpenCode`))}finally{y(!1)}};return(0,$.jsxs)(br,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsx)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(Z,{itemId:`global-config.editor`,label:e(`settings.globalConfig.title`),description:e(`settings.globalConfig.description`),cardClassName:`p-3`,children:n.length>0?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:n.map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 px-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta truncate text-muted-foreground`,children:u}),i&&(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,onClick:()=>void x(i),disabled:f||m,children:e(`settings.globalConfig.actions.reload`)})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`h-[clamp(420px,62dvh,760px)] overflow-hidden bg-background`,children:(0,$.jsx)(Er,{value:o,onChange:s,readOnly:f,extensions:b,className:`h-full`,enableSearch:!0})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(Y,{onClick:S,disabled:f||m||o===c,size:`sm`,children:e(m?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.globalConfig.restartHint`)})]})]})]}):(0,$.jsx)(`div`,{className:`min-h-12`,"aria-busy":f})})}),(0,$.jsx)(Yt,{open:g,onOpenChange:e=>!v&&_(e),children:(0,$.jsxs)(Kt,{className:`max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.view.actions.reloadOpenCode`)}),(0,$.jsx)(Jt,{children:e(`settings.globalConfig.restartHint`)})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>_(!1),disabled:v,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>void C(),disabled:v,children:e(`settings.view.actions.reloadOpenCode`)})]})]})})]})}var wc=`<built-in>`,Tc=e=>e?.path===wc,Ec=e=>{let t=(0,Di.c)(172),{onItemSelect:n}=e,{t:r}=ke(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedSkillName:m,setSelectedSkill:h,setSkillDraft:g,createSkill:_,deleteSkill:v,getSkillDetail:y}=fa(he(Oc)),b=Fe(),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=Je(),t[0]=x):x=t[0];let S=x,C;t[1]===b.data?C=t[2]:(C=b.data??[],t[1]=b.data,t[2]=C);let w=C,T;t[3]!==n||t[4]!==h||t[5]!==g||t[6]!==w?(T=()=>{let e=`new-skill`,t=1;for(;w.some(t=>t.name===e);)e=`new-skill-${t}`,t++;g({name:e,scope:`user`,source:`opencode`,description:``}),h(e),n?.()},t[3]=n,t[4]=h,t[5]=g,t[6]=w,t[7]=T):T=t[7];let E=T,D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=async e=>{Tc(e)||l(e)},t[8]=D):D=t[8];let O=D,k;t[9]!==c||t[10]!==v||t[11]!==r?(k=async()=>{if(c){if(Tc(c)){l(null);return}d(!0),await v(c.name,{directory:S})?(K.success(r(`settings.skills.sidebar.toast.skillDeleted`,{name:c.name})),l(null)):K.error(r(`settings.skills.sidebar.toast.deleteSkillFailed`)),d(!1)}},t[9]=c,t[10]=v,t[11]=r,t[12]=k):k=t[12];let A=k,j;t[13]!==y||t[14]!==h||t[15]!==g||t[16]!==w||t[17]!==r?(j=async e=>{if(Tc(e))return;let t=e.name,n=1,i=`${t}-copy`;for(;w.some(e=>e.name===i);)n++,i=`${t}-copy-${n}`;let a=await y(e.name);if(!a){K.error(r(`settings.skills.sidebar.toast.duplicateLoadFailed`));return}g({name:i,scope:e.scope||`user`,source:e.source||`opencode`,description:(a.sources.md.fields.includes(`description`),``),instructions:``}),h(i)},t[13]=y,t[14]=h,t[15]=g,t[16]=w,t[17]=r,t[18]=j):j=t[18];let M=j,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{Tc(e)||(s(e.name),a(e))},t[19]=N):N=t[19];let P=N,F;t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==i||t[24]!==o||t[25]!==h||t[26]!==w||t[27]!==r?(F=async()=>{if(!i)return;if(Tc(i)){a(null);return}let e=o.trim().replace(/\s+/g,`-`).toLowerCase();if(!e){K.error(r(`settings.skills.page.toast.skillNameRequired`));return}if(e===i.name){a(null);return}if(w.some(t=>t.name===e)){K.error(r(`settings.skills.page.toast.skillExists`));return}if(!await y(i.name)){K.error(r(`settings.skills.sidebar.toast.renameLoadFailed`)),a(null);return}await _({name:e,description:`Renamed skill`,scope:i.scope,source:i.source},{directory:S})?await v(i.name,{directory:S})?(K.success(`Skill renamed to "${e}"`),h(e)):K.error(r(`settings.skills.sidebar.toast.removeOldAfterRenameFailed`)):K.error(r(`settings.skills.sidebar.toast.renameFailed`)),a(null)},t[20]=_,t[21]=v,t[22]=y,t[23]=i,t[24]=o,t[25]=h,t[26]=w,t[27]=r,t[28]=F):F=t[28];let I=F,L;t[29]===w?L=t[30]:(L=w.filter(kc),t[29]=w,t[30]=L);let R=L,z;t[31]===w?z=t[32]:(z=w.filter(Ac),t[31]=w,t[32]=z);let B=z,V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){let t={},n=[];for(let r of e)r.group?(t[r.group]||(t[r.group]=[]),t[r.group].push(r)):n.push(r);let r=Object.keys(t).sort(jc).map(e=>({name:e,skills:[...t[e]].sort(Mc)}));return n.sort(Nc),{sortedGroups:r,ungrouped:n}},t[33]=V):V=t[33];let H=V,ee;t[34]===R?ee=t[35]:(ee=H(R),t[34]=R,t[35]=ee);let U=ee,te;t[36]===B?te=t[37]:(te=H(B),t[36]=B,t[37]=te);let W=te,ne;t[38]===r?ne=t[39]:(ne=r(`settings.skills.sidebar.section.project`),t[38]=r,t[39]=ne);let re=ne,ie;t[40]===r?ie=t[41]:(ie=r(`settings.skills.sidebar.section.user`),t[40]=r,t[41]=ie);let ae=ie,oe;t[42]===re?oe=t[43]:(oe=(0,$.jsx)(`span`,{children:re}),t[42]=re,t[43]=oe);let se;t[44]===r?se=t[45]:(se=r(`settings.skills.page.title.newSkill`),t[44]=r,t[45]=se);let ce;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[46]=ce):ce=t[46];let le;t[47]!==E||t[48]!==se?(le=(0,$.jsx)(Y,{"data-settings-item":`skills.create`,size:`icon`,variant:`ghost`,"aria-label":se,onClick:E,children:ce}),t[47]=E,t[48]=se,t[49]=le):le=t[49];let ue;t[50]!==oe||t[51]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[oe,le]}),t[50]=oe,t[51]=le,t[52]=ue):ue=t[52];let de=ue,fe;t[53]!==M||t[54]!==n||t[55]!==f||t[56]!==m||t[57]!==h?(fe=e=>(0,$.jsx)(Dc,{skill:e,isSelected:m===e.name,onSelect:()=>{h(e.name),n?.()},onRename:()=>P(e),onDelete:()=>O(e),onDuplicate:()=>M(e),isMenuOpen:f===e.name,onMenuOpenChange:t=>p(t?e.name:null)},e.name),t[53]=M,t[54]=n,t[55]=f,t[56]=m,t[57]=h,t[58]=fe):fe=t[58];let pe=fe,me,ge;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(me=q(`oc-settings-page-content h-full overflow-y-auto p-3`,`bg-background`),ge=(0,$.jsx)(ga,{}),t[59]=me,t[60]=ge):(me=t[59],ge=t[60]);let _e;t[61]!==w.length||t[62]!==r?(_e=w.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.skills.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.sidebar.empty.description`)})]})}):null,t[61]=w.length,t[62]=r,t[63]=_e):_e=t[63];let ve;t[64]!==U.ungrouped||t[65]!==de||t[66]!==pe?(ve=U.ungrouped.length>0?(0,$.jsx)(Z,{label:de,children:U.ungrouped.map(pe)}):(0,$.jsx)(Z,{label:de,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[64]=U.ungrouped,t[65]=de,t[66]=pe,t[67]=ve):ve=t[67];let ye;if(t[68]!==U.sortedGroups||t[69]!==re||t[70]!==pe){let e;t[72]!==re||t[73]!==pe?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Ca,{label:t,labelPrefix:re,count:n.length,storageKey:`project-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[72]=re,t[73]=pe,t[74]=e):e=t[74],ye=U.sortedGroups.map(e),t[68]=U.sortedGroups,t[69]=re,t[70]=pe,t[71]=ye}else ye=t[71];let be;t[75]!==W.ungrouped||t[76]!==pe||t[77]!==ae?(be=W.ungrouped.length>0?(0,$.jsx)(Z,{label:ae,children:W.ungrouped.map(pe)}):null,t[75]=W.ungrouped,t[76]=pe,t[77]=ae,t[78]=be):be=t[78];let xe;if(t[79]!==W.sortedGroups||t[80]!==pe||t[81]!==ae){let e;t[83]!==pe||t[84]!==ae?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Ca,{label:t,labelPrefix:ae,count:n.length,storageKey:`user-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[83]=pe,t[84]=ae,t[85]=e):e=t[85],xe=W.sortedGroups.map(e),t[79]=W.sortedGroups,t[80]=pe,t[81]=ae,t[82]=xe}else xe=t[82];let Se=c!==null,Ce;t[86]===u?Ce=t[87]:(Ce=e=>{!e&&!u&&l(null)},t[86]=u,t[87]=Ce);let we;t[88]===r?we=t[89]:(we=r(`settings.skills.sidebar.deleteDialog.title`),t[88]=r,t[89]=we);let Te;t[90]===we?Te=t[91]:(Te=(0,$.jsx)(qt,{children:we}),t[90]=we,t[91]=Te);let Ee=c?.name??``,De;t[92]!==r||t[93]!==Ee?(De=r(`settings.skills.sidebar.deleteDialog.description`,{name:Ee}),t[92]=r,t[93]=Ee,t[94]=De):De=t[94];let Oe;t[95]===De?Oe=t[96]:(Oe=(0,$.jsx)(Jt,{children:De}),t[95]=De,t[96]=Oe);let Ae;t[97]!==Te||t[98]!==Oe?(Ae=(0,$.jsxs)(Wt,{children:[Te,Oe]}),t[97]=Te,t[98]=Oe,t[99]=Ae):Ae=t[99];let je;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(je=()=>l(null),t[100]=je):je=t[100];let Me;t[101]===r?Me=t[102]:(Me=r(`settings.common.actions.cancel`),t[101]=r,t[102]=Me);let Ne;t[103]!==u||t[104]!==Me?(Ne=(0,$.jsx)(Y,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:je,disabled:u,children:Me}),t[103]=u,t[104]=Me,t[105]=Ne):Ne=t[105];let Pe;t[106]===r?Pe=t[107]:(Pe=r(`settings.common.actions.delete`),t[106]=r,t[107]=Pe);let Ie;t[108]!==A||t[109]!==u||t[110]!==Pe?(Ie=(0,$.jsx)(Y,{size:`sm`,onClick:A,disabled:u,children:Pe}),t[108]=A,t[109]=u,t[110]=Pe,t[111]=Ie):Ie=t[111];let Le;t[112]!==Ne||t[113]!==Ie?(Le=(0,$.jsxs)(Gt,{children:[Ne,Ie]}),t[112]=Ne,t[113]=Ie,t[114]=Le):Le=t[114];let Re;t[115]!==Ae||t[116]!==Le?(Re=(0,$.jsxs)(Kt,{className:`max-w-md`,children:[Ae,Le]}),t[115]=Ae,t[116]=Le,t[117]=Re):Re=t[117];let ze;t[118]!==Se||t[119]!==Ce||t[120]!==Re?(ze=(0,$.jsx)(Yt,{open:Se,onOpenChange:Ce,children:Re}),t[118]=Se,t[119]=Ce,t[120]=Re,t[121]=ze):ze=t[121];let Be=i!==null,Ve;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=e=>!e&&a(null),t[122]=Ve):Ve=t[122];let He;t[123]===r?He=t[124]:(He=r(`settings.skills.sidebar.renameDialog.title`),t[123]=r,t[124]=He);let Ue;t[125]===He?Ue=t[126]:(Ue=(0,$.jsx)(qt,{children:He}),t[125]=He,t[126]=Ue);let We=i?.name??``,Ge;t[127]!==r||t[128]!==We?(Ge=r(`settings.skills.sidebar.renameDialog.description`,{name:We}),t[127]=r,t[128]=We,t[129]=Ge):Ge=t[129];let Ke;t[130]===Ge?Ke=t[131]:(Ke=(0,$.jsx)(Jt,{children:Ge}),t[130]=Ge,t[131]=Ke);let qe;t[132]!==Ue||t[133]!==Ke?(qe=(0,$.jsxs)(Wt,{children:[Ue,Ke]}),t[132]=Ue,t[133]=Ke,t[134]=qe):qe=t[134];let Ye;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=e=>s(e.target.value),t[135]=Ye):Ye=t[135];let Xe;t[136]===r?Xe=t[137]:(Xe=r(`settings.skills.sidebar.renameDialog.placeholder`),t[136]=r,t[137]=Xe);let Ze;t[138]===I?Ze=t[139]:(Ze=e=>{e.key===`Enter`&&I()},t[138]=I,t[139]=Ze);let Qe;t[140]!==o||t[141]!==Xe||t[142]!==Ze?(Qe=(0,$.jsx)(un,{value:o,onChange:Ye,placeholder:Xe,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Ze}),t[140]=o,t[141]=Xe,t[142]=Ze,t[143]=Qe):Qe=t[143];let $e;t[144]===Symbol.for(`react.memo_cache_sentinel`)?($e=()=>a(null),t[144]=$e):$e=t[144];let et;t[145]===r?et=t[146]:(et=r(`settings.common.actions.cancel`),t[145]=r,t[146]=et);let tt;t[147]===et?tt=t[148]:(tt=(0,$.jsx)(Y,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:$e,children:et}),t[147]=et,t[148]=tt);let G;t[149]===r?G=t[150]:(G=r(`settings.common.actions.rename`),t[149]=r,t[150]=G);let nt;t[151]!==I||t[152]!==G?(nt=(0,$.jsx)(Y,{size:`sm`,onClick:I,children:G}),t[151]=I,t[152]=G,t[153]=nt):nt=t[153];let rt;t[154]!==tt||t[155]!==nt?(rt=(0,$.jsxs)(Gt,{children:[tt,nt]}),t[154]=tt,t[155]=nt,t[156]=rt):rt=t[156];let it;t[157]!==qe||t[158]!==Qe||t[159]!==rt?(it=(0,$.jsxs)(Kt,{children:[qe,Qe,rt]}),t[157]=qe,t[158]=Qe,t[159]=rt,t[160]=it):it=t[160];let at;t[161]!==Be||t[162]!==it?(at=(0,$.jsx)(Yt,{open:Be,onOpenChange:Ve,children:it}),t[161]=Be,t[162]=it,t[163]=at):at=t[163];let ot;return t[164]!==_e||t[165]!==ve||t[166]!==ye||t[167]!==be||t[168]!==xe||t[169]!==ze||t[170]!==at?(ot=(0,$.jsxs)(`div`,{className:me,children:[ge,_e,ve,ye,be,xe,ze,at]}),t[164]=_e,t[165]=ve,t[166]=ye,t[167]=be,t[168]=xe,t[169]=ze,t[170]=at,t[171]=ot):ot=t[171],ot},Dc=e=>{let t=(0,Di.c)(49),{skill:n,isSelected:r,onSelect:i,onDelete:a,onRename:o,onDuplicate:s,isMenuOpen:c,onMenuOpenChange:l}=e,{t:u}=ke(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=pr(),t[0]=d):d=t[0];let f=d,p;t[1]!==n.source||t[2]!==u?(p=n.source===`claude`?u(`settings.skills.sidebar.badge.claude`):n.source===`agents`?u(`settings.skills.sidebar.badge.agents`):u(`settings.skills.sidebar.badge.opencode`),t[1]=n.source,t[2]=u,t[3]=p):p=t[3];let m=p,h;t[4]===n?h=t[5]:(h=Tc(n),t[4]=n,t[5]=h);let g=h,[_,v]=Q.useState(!1),y;t[6]!==a||t[7]!==s||t[8]!==o||t[9]!==u?(y=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.duplicate`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.delete`)]})]}),t[6]=a,t[7]=s,t[8]=o,t[9]=u,t[10]=y):y=t[10];let b=y,x=!g&&_,S=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,C;t[11]===S?C=t[12]:(C=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,S),t[11]=S,t[12]=C);let w;t[13]===g?w=t[14]:(w=!f&&!g?e=>{e.preventDefault(),v(!0)}:void 0,t[13]=g,t[14]=w);let T;t[15]!==C||t[16]!==w?(T=(0,$.jsx)(`div`,{className:C,onContextMenu:w}),t[15]=C,t[16]=w,t[17]=T):T=t[17];let E;t[18]===n.name?E=t[19]:(E=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[18]=n.name,t[19]=E);let D;t[20]===n.scope?D=t[21]:(D=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:n.scope}),t[20]=n.scope,t[21]=D);let O;t[22]===m?O=t[23]:(O=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:m}),t[22]=m,t[23]=O);let k;t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[E,D,O]}),t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27];let A;t[28]!==i||t[29]!==k?(A=(0,$.jsx)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:k}),t[28]=i,t[29]=k,t[30]=A):A=t[30];let j;t[31]!==g||t[32]!==c||t[33]!==l||t[34]!==b?(j=g?null:(0,$.jsxs)(En,{open:c,onOpenChange:e=>{e&&v(!1),l(e)},children:[(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hn,{align:`end`,className:`w-fit min-w-20`,children:b(vn)})]}),t[31]=g,t[32]=c,t[33]=l,t[34]=b,t[35]=j):j=t[35];let M;t[36]!==A||t[37]!==j?(M=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38];let N;t[39]!==M||t[40]!==T?(N=(0,$.jsx)(_i,{render:T,children:M}),t[39]=M,t[40]=T,t[41]=N):N=t[41];let P;t[42]!==g||t[43]!==b?(P=g?null:(0,$.jsx)(vi,{className:`w-fit min-w-20`,children:b(yi)}),t[42]=g,t[43]=b,t[44]=P):P=t[44];let F;return t[45]!==N||t[46]!==P||t[47]!==x?(F=(0,$.jsxs)(bi,{open:x,onOpenChange:v,children:[N,P]}),t[45]=N,t[46]=P,t[47]=x,t[48]=F):F=t[48],F};function Oc(e){return{selectedSkillName:e.selectedSkillName,setSelectedSkill:e.setSelectedSkill,setSkillDraft:e.setSkillDraft,createSkill:e.createSkill,deleteSkill:e.deleteSkill,getSkillDetail:e.getSkillDetail}}function kc(e){return e.scope===`project`}function Ac(e){return e.scope===`user`}function jc(e,t){return e.localeCompare(t)}function Mc(e,t){return e.name.localeCompare(t.name)}function Nc(e,t){return e.name.localeCompare(t.name)}var Pc=()=>{let e=ye.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},Fc=fe()(me(e=>({selectedSourceId:lt[0]?.id??null,isScanning:!1,isInstalling:!1,lastScanError:null,lastInstallError:null,scanResults:null,setSelectedSource:t=>e({selectedSourceId:t}),scanRepo:async(t,n)=>{e({isScanning:!0,lastScanError:null,scanResults:null});try{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:Pc(),i=r?`?directory=${encodeURIComponent(r)}`:``,a=await L(`/api/config/skills/scan${i}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),o=await a.json().catch(()=>null);if(!a.ok||!o){let t=o?.error||{kind:`unknown`,message:`Failed to scan repository`};return e({lastScanError:t}),{ok:!1,error:t}}return o.ok?(e({scanResults:o.items||[]}),o):(e({lastScanError:o.error||{kind:`unknown`,message:`Failed to scan repository`}}),o)}finally{e({isScanning:!1})}},installSkills:async(t,n)=>{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:Pc(),a=n?.transportIdentity??i();if(i()!==a)return{ok:!1,error:{kind:`unknown`,message:`Failed to install skills`}};kt(`Installing skills…`),e({isInstalling:!0,lastInstallError:null});let o=!1;try{let n=r?`?directory=${encodeURIComponent(r)}`:``,s=await L(`/api/config/skills/install${n}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),c=await s.json().catch(()=>null);if(!c){let t={kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),it(`Failed to install skills. Please retry.`),{ok:!1,error:t}}if(!s.ok||!c.ok){let t=c.error||{kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),it(t.message||`Failed to install skills. Please retry.`),{ok:!1,error:t}}return i()===a&&(c.requiresReload?(o=!0,await ma({message:c.message,delayMs:c.reloadDelayMs,directory:r,transportIdentity:a})):(it(c.message||`Refreshing skills…`),await tt(H,r,a),await vt(H,r,a))),c}catch(t){let n={kind:`unknown`,message:t instanceof Error?t.message:String(t)};return e({lastInstallError:n}),it(`Failed to install skills. Please retry.`),{ok:!1,error:n}}finally{e({isInstalling:!1}),o||dt()}}}),{name:`skills-catalog-store`})),Ic=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,Lc=e=>{let t=e.trim(),n=t.startsWith(`https://`)?`https`:t.startsWith(`git@`)?`ssh`:`shorthand`;if(n===`ssh`)return`${t.split(`:`)[1].replace(/\.git$/i,``)}`;if(n===`https`)return t.split(`/`).slice(3).filter(Boolean).join(`/`).replace(/\.git$/i,``);let r=t.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return r?`${r[1]}/${r[2].replace(/\.git$/i,``)}`:t},Rc=async()=>{try{let e=U()?.settings;if(e)return(await e.load())?.settings||{};let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},zc=e=>{let t=(0,Di.c)(158),{open:n,onOpenChange:r}=e,{t:a}=ke(),o=Fc(Bc),s=Fc(Vc),c=Fc(Hc),l=Ar(Uc),u=Ar(Wc),[d,f]=Q.useState(``),[p,h]=Q.useState(``),[g,_]=Q.useState(``),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[y,b]=Q.useState(v),[x,S]=Q.useState(null),[C,w]=Q.useState(!1),T;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[1]=T):T=t[1];let[E,D]=Q.useState(T),[O,k]=Q.useState(null),A=Q.useRef(0),j=Q.useRef(null),M;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{A.current+=1,w(!1),S(null),j.current=null,e?.clearIdentity&&(D([]),k(null))},t[2]=M):M=t[2];let N=M,P,F;t[3]!==u||t[4]!==n?(P=()=>{n&&(A.current+=1,f(``),h(``),_(``),S(null),w(!1),j.current=null,D([]),k(null),u(),(async()=>{let e=await Rc(),t=Array.isArray(e?.skillCatalogs)?e?.skillCatalogs:[];b(t||[])})())},F=[n,u],t[3]=u,t[4]=n,t[5]=P,t[6]=F):(P=t[5],F=t[6]),Q.useEffect(P,F);let I;t[7]===p?I=t[8]:(I=p.trim(),t[7]=p,t[8]=I);let L=I,R;t[9]===g?R=t[10]:(R=g.trim(),t[9]=g,t[10]=R);let z=R,B;if(t[11]!==y||t[12]!==L||t[13]!==z){let e;t[15]!==L||t[16]!==z?(e=e=>{let t=(e.source||``).trim(),n=(e.subpath||``).trim();return t===L&&n===z},t[15]=L,t[16]=z,t[17]=e):e=t[17],B=y.some(e),t[11]=y,t[12]=L,t[13]=z,t[14]=B}else B=t[14];let ee=B,U;t[18]!==l||t[19]!==O||t[20]!==d||t[21]!==o||t[22]!==p||t[23]!==g||t[24]!==a?(U=async()=>{let e=p.trim();if(!e){K.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}d.trim()||f(Lc(e)),w(!1),S(null);let t=A.current+1;A.current=t;let n=rt(),r=i(),s=await o({source:e,subpath:g.trim()||void 0,gitIdentityId:O||void 0},{directory:n});if(A.current!==t||i()!==r||rt()!==n)return;if(!s.ok){if(s.error?.kind===`authRequired`){if(m()){K.error(a(`settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode`));return}let e=s.error.identities||[];if(D(e),!O&&e.length>0){let t=l&&l!==`global`&&e.some(e=>e.id===l)?l:e[0].id;k(t)}K.error(a(`settings.skills.catalog.add.toast.authenticationRequiredScan`));return}K.error(s.error?.message||a(`settings.skills.catalog.add.toast.scanFailed`));return}let c=s.items?.length||0;if(S(c),c===0){K.error(a(`settings.skills.catalog.add.toast.noSkillsFound`)),w(!1);return}D([]),w(!0),j.current={directory:n,transport:r},K.success(a(`settings.skills.catalog.shared.toast.foundSkills`,{count:c}))},t[18]=l,t[19]=O,t[20]=d,t[21]=o,t[22]=p,t[23]=g,t[24]=a,t[25]=U):U=t[25];let te=U,W;t[26]!==y||t[27]!==O||t[28]!==ee||t[29]!==d||t[30]!==r||t[31]!==C||t[32]!==s||t[33]!==p||t[34]!==g||t[35]!==a?(W=async()=>{let e=d.trim(),t=p.trim(),n=g.trim();if(!e){K.error(a(`settings.skills.catalog.add.toast.catalogNameRequired`));return}if(!t){K.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}let o=rt(),c=i();if(!C||j.current?.directory!==o||j.current?.transport!==c){w(!1),j.current=null,K.error(a(`settings.skills.catalog.add.toast.scanBeforeAdd`));return}if(ee){K.error(a(`settings.skills.catalog.add.toast.catalogAlreadyExists`));return}let l={id:Ic(),label:e,source:t,...n?{subpath:n}:{},...O?{gitIdentityId:O}:{}},u=[...y,l],f=rt(),m=i();try{await V({skillCatalogs:u}),b(u),K.success(a(`settings.skills.catalog.add.toast.catalogAdded`)),await H.invalidateQueries({queryKey:[m,`skillsCatalog`,`sources`],exact:!1}),await pt(H,f,m),await wt(H,f,l.id,m),i()===m&&(s(l.id),r(!1))}catch(e){let t=e;K.error(t instanceof Error?t.message:a(`settings.skills.catalog.add.toast.saveFailed`))}},t[26]=y,t[27]=O,t[28]=ee,t[29]=d,t[30]=r,t[31]=C,t[32]=s,t[33]=p,t[34]=g,t[35]=a,t[36]=W):W=t[36];let ne=W,re;t[37]===a?re=t[38]:(re=a(`settings.skills.catalog.add.title`),t[37]=a,t[38]=re);let ie;t[39]===re?ie=t[40]:(ie=(0,$.jsx)(qt,{children:re}),t[39]=re,t[40]=ie);let ae;t[41]===a?ae=t[42]:(ae=a(`settings.skills.catalog.add.descriptionPrefix`),t[41]=a,t[42]=ae);let oe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),t[43]=oe):oe=t[43];let se;t[44]===a?se=t[45]:(se=a(`settings.skills.catalog.add.descriptionSuffix`),t[44]=a,t[45]=se);let ce;t[46]!==ae||t[47]!==se?(ce=(0,$.jsxs)(Jt,{children:[ae,` `,oe,se]}),t[46]=ae,t[47]=se,t[48]=ce):ce=t[48];let le;t[49]!==ie||t[50]!==ce?(le=(0,$.jsxs)(Wt,{children:[ie,ce]}),t[49]=ie,t[50]=ce,t[51]=le):le=t[51];let ue;t[52]===a?ue=t[53]:(ue=a(`settings.skills.catalog.add.field.catalogName`),t[52]=a,t[53]=ue);let de;t[54]===ue?de=t[55]:(de=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:ue}),t[54]=ue,t[55]=de);let fe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>f(e.target.value),t[56]=fe):fe=t[56];let pe;t[57]===a?pe=t[58]:(pe=a(`settings.skills.catalog.add.field.catalogNamePlaceholder`),t[57]=a,t[58]=pe);let me;t[59]!==d||t[60]!==pe?(me=(0,$.jsx)(un,{value:d,onChange:fe,placeholder:pe}),t[59]=d,t[60]=pe,t[61]=me):me=t[61];let he;t[62]!==de||t[63]!==me?(he=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[de,me]}),t[62]=de,t[63]=me,t[64]=he):he=t[64];let ge;t[65]===a?ge=t[66]:(ge=a(`settings.skills.catalog.add.field.repository`),t[65]=a,t[66]=ge);let _e;t[67]===ge?_e=t[68]:(_e=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:ge}),t[67]=ge,t[68]=_e);let ve;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>{h(e.target.value),N({clearIdentity:!0})},t[69]=ve):ve=t[69];let ye;t[70]===a?ye=t[71]:(ye=a(`settings.skills.catalog.shared.field.repositoryPlaceholder`),t[70]=a,t[71]=ye);let be;t[72]!==p||t[73]!==ye?(be=(0,$.jsx)(un,{value:p,onChange:ve,placeholder:ye}),t[72]=p,t[73]=ye,t[74]=be):be=t[74];let xe;t[75]===a?xe=t[76]:(xe=a(`settings.skills.catalog.add.field.repositoryHint`),t[75]=a,t[76]=xe);let Se;t[77]===xe?Se=t[78]:(Se=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:xe}),t[77]=xe,t[78]=Se);let Ce;t[79]!==_e||t[80]!==be||t[81]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[_e,be,Se]}),t[79]=_e,t[80]=be,t[81]=Se,t[82]=Ce):Ce=t[82];let we;t[83]===a?we=t[84]:(we=a(`settings.skills.catalog.add.field.optionalSubpath`),t[83]=a,t[84]=we);let Te;t[85]===we?Te=t[86]:(Te=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:we}),t[85]=we,t[86]=Te);let Ee;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>{_(e.target.value),N({clearIdentity:!0})},t[87]=Ee):Ee=t[87];let De;t[88]===a?De=t[89]:(De=a(`settings.skills.catalog.shared.field.subpathPlaceholder`),t[88]=a,t[89]=De);let Oe;t[90]!==g||t[91]!==De?(Oe=(0,$.jsx)(un,{value:g,onChange:Ee,placeholder:De}),t[90]=g,t[91]=De,t[92]=Oe):Oe=t[92];let Ae;t[93]!==Te||t[94]!==Oe?(Ae=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Te,Oe]}),t[93]=Te,t[94]=Oe,t[95]=Ae):Ae=t[95];let je;t[96]!==O||t[97]!==E||t[98]!==a?(je=E.length>0&&!m()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-[var(--status-warning)]`,children:a(`settings.skills.catalog.shared.auth.title`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:a(`settings.skills.catalog.shared.auth.description`)})]}),(0,$.jsxs)(on,{value:O||``,onValueChange:e=>{k(e),N()},children:[(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(`span`,{children:E.find(e=>e.id===O)?.name||a(`settings.skills.catalog.shared.auth.chooseIdentity`)})}),(0,$.jsx)(rn,{align:`start`,children:E.map(Gc)})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:a(`settings.skills.catalog.shared.auth.footerHint`)})]}):null,t[96]=O,t[97]=E,t[98]=a,t[99]=je):je=t[99];let Me;t[100]!==x||t[101]!==a?(Me=x===null?null:(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.scanResult`,{count:x})}),t[100]=x,t[101]=a,t[102]=Me):Me=t[102];let Ne;t[103]!==ee||t[104]!==a?(Ne=ee?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.duplicateMessage`)}):null,t[103]=ee,t[104]=a,t[105]=Ne):Ne=t[105];let Pe;t[106]!==he||t[107]!==Ce||t[108]!==Ae||t[109]!==je||t[110]!==Me||t[111]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[he,Ce,Ae,je,Me,Ne]}),t[106]=he,t[107]=Ce,t[108]=Ae,t[109]=je,t[110]=Me,t[111]=Ne,t[112]=Pe):Pe=t[112];let Fe;t[113]===r?Fe=t[114]:(Fe=()=>r(!1),t[113]=r,t[114]=Fe);let Ie;t[115]===a?Ie=t[116]:(Ie=a(`settings.common.actions.cancel`),t[115]=a,t[116]=Ie);let Le;t[117]!==Fe||t[118]!==Ie?(Le=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:Fe,children:Ie}),t[117]=Fe,t[118]=Ie,t[119]=Le):Le=t[119];let Re;t[120]===te?Re=t[121]:(Re=()=>void te(),t[120]=te,t[121]=Re);let ze;t[122]!==c||t[123]!==p?(ze=c||!p.trim(),t[122]=c,t[123]=p,t[124]=ze):ze=t[124];let Be;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,$.jsx)(J,{name:`git-repository`,className:`h-4 w-4`}),t[125]=Be):Be=t[125];let Ve;t[126]!==c||t[127]!==a?(Ve=a(c?`settings.skills.catalog.shared.actions.scanning`:`settings.skills.catalog.shared.actions.scan`),t[126]=c,t[127]=a,t[128]=Ve):Ve=t[128];let He;t[129]!==Re||t[130]!==ze||t[131]!==Ve?(He=(0,$.jsxs)(Y,{size:`sm`,className:`gap-2`,variant:`ghost`,onClick:Re,disabled:ze,children:[Be,Ve]}),t[129]=Re,t[130]=ze,t[131]=Ve,t[132]=He):He=t[132];let Ue;t[133]===ne?Ue=t[134]:(Ue=()=>void ne(),t[133]=ne,t[134]=Ue);let We;t[135]!==ee||t[136]!==d||t[137]!==C||t[138]!==p?(We=!C||ee||!d.trim()||!p.trim(),t[135]=ee,t[136]=d,t[137]=C,t[138]=p,t[139]=We):We=t[139];let Ge;t[140]===a?Ge=t[141]:(Ge=a(`settings.skills.catalog.add.actions.addCatalog`),t[140]=a,t[141]=Ge);let Ke;t[142]!==Ue||t[143]!==We||t[144]!==Ge?(Ke=(0,$.jsx)(Y,{size:`sm`,onClick:Ue,disabled:We,children:Ge}),t[142]=Ue,t[143]=We,t[144]=Ge,t[145]=Ke):Ke=t[145];let qe;t[146]!==Le||t[147]!==He||t[148]!==Ke?(qe=(0,$.jsxs)(Gt,{children:[Le,He,Ke]}),t[146]=Le,t[147]=He,t[148]=Ke,t[149]=qe):qe=t[149];let Je;t[150]!==le||t[151]!==Pe||t[152]!==qe?(Je=(0,$.jsxs)(Kt,{className:`max-w-xl`,children:[le,Pe,qe]}),t[150]=le,t[151]=Pe,t[152]=qe,t[153]=Je):Je=t[153];let Ye;return t[154]!==r||t[155]!==n||t[156]!==Je?(Ye=(0,$.jsx)(Yt,{open:n,onOpenChange:r,children:Je}),t[154]=r,t[155]=n,t[156]=Je,t[157]=Ye):Ye=t[157],Ye};function Bc(e){return e.scanRepo}function Vc(e){return e.setSelectedSource}function Hc(e){return e.isScanning}function Uc(e){return e.defaultGitIdentityId}function Wc(e){return e.loadDefaultGitIdentityId}function Gc(e){return(0,$.jsx)(en,{value:e.id,children:e.name},e.id)}var Kc=e=>{let t=(0,Di.c)(85),{open:n,onOpenChange:r,conflicts:i,onConfirm:a}=e,{t:o}=ke(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={},t[0]=s):s=t[0];let[c,l]=Q.useState(s),u,d;t[1]!==i||t[2]!==n?(u=()=>{if(!n)return;let e={};for(let t of i)e[t.skillName]=`skip`;l(e)},d=[n,i],t[1]=i,t[2]=n,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;t[5]===i?f=t[6]:(f=e=>{let t={};for(let n of i)t[n.skillName]=e;l(t)},t[5]=i,t[6]=f);let p=f,m;t[7]!==i||t[8]!==c?(m=i.length>0&&i.every(e=>c[e.skillName]),t[7]=i,t[8]=c,t[9]=m):m=t[9];let h=m,g;t[10]===o?g=t[11]:(g=o(`settings.skills.catalog.conflicts.title`),t[10]=o,t[11]=g);let _;t[12]===g?_=t[13]:(_=(0,$.jsx)(qt,{children:g}),t[12]=g,t[13]=_);let v;t[14]===o?v=t[15]:(v=o(`settings.skills.catalog.conflicts.description`),t[14]=o,t[15]=v);let y;t[16]===v?y=t[17]:(y=(0,$.jsx)(Jt,{children:v}),t[16]=v,t[17]=y);let b;t[18]!==_||t[19]!==y?(b=(0,$.jsxs)(Wt,{children:[_,y]}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==i.length||t[22]!==o?(x=o(`settings.skills.catalog.conflicts.count`,{count:i.length}),t[21]=i.length,t[22]=o,t[23]=x):x=t[23];let S;t[24]===x?S=t[25]:(S=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:x}),t[24]=x,t[25]=S);let C;t[26]===p?C=t[27]:(C=()=>p(`skip`),t[26]=p,t[27]=C);let w;t[28]===o?w=t[29]:(w=o(`settings.skills.catalog.conflicts.actions.skipAll`),t[28]=o,t[29]=w);let T;t[30]!==C||t[31]!==w?(T=(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:C,children:w}),t[30]=C,t[31]=w,t[32]=T):T=t[32];let E;t[33]===p?E=t[34]:(E=()=>p(`overwrite`),t[33]=p,t[34]=E);let D;t[35]===o?D=t[36]:(D=o(`settings.skills.catalog.conflicts.actions.overwriteAll`),t[35]=o,t[36]=D);let O;t[37]!==E||t[38]!==D?(O=(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:E,children:D}),t[37]=E,t[38]=D,t[39]=O):O=t[39];let k;t[40]!==T||t[41]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T,O]}),t[40]=T,t[41]=O,t[42]=k):k=t[42];let A;t[43]!==S||t[44]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[S,k]}),t[43]=S,t[44]=k,t[45]=A):A=t[45];let j;if(t[46]!==i||t[47]!==c||t[48]!==o){let e;t[50]!==c||t[51]!==o?(e=e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label truncate`,children:e.skillName}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:o(`settings.skills.catalog.conflicts.installedIn`,{scope:e.scope===`project`?o(`settings.skills.catalog.conflicts.scope.project`):o(`settings.skills.catalog.conflicts.scope.user`),source:e.source===`agents`?o(`settings.skills.catalog.conflicts.source.agents`):o(`settings.skills.catalog.conflicts.source.opencode`)})})]}),(0,$.jsxs)(on,{value:c[e.skillName]||`skip`,onValueChange:t=>l(n=>({...n,[e.skillName]:t})),children:[(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(`span`,{className:`capitalize`,children:(c[e.skillName]||`skip`)===`overwrite`?o(`settings.skills.catalog.conflicts.decision.overwrite`):o(`settings.skills.catalog.conflicts.decision.skip`)})}),(0,$.jsxs)(rn,{align:`end`,children:[(0,$.jsx)(en,{value:`skip`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.skip`)}),(0,$.jsx)(en,{value:`overwrite`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.overwrite`)})]})]})]},e.skillName),t[50]=c,t[51]=o,t[52]=e):e=t[52],j=i.map(e),t[46]=i,t[47]=c,t[48]=o,t[49]=j}else j=t[49];let M;t[53]===j?M=t[54]:(M=(0,$.jsx)(`div`,{className:`space-y-2`,children:j}),t[53]=j,t[54]=M);let N;t[55]!==A||t[56]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[A,M]}),t[55]=A,t[56]=M,t[57]=N):N=t[57];let P;t[58]===r?P=t[59]:(P=()=>r(!1),t[58]=r,t[59]=P);let F;t[60]===o?F=t[61]:(F=o(`settings.common.actions.cancel`),t[60]=o,t[61]=F);let I;t[62]!==P||t[63]!==F?(I=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:P,children:F}),t[62]=P,t[63]=F,t[64]=I):I=t[64];let L;t[65]!==c||t[66]!==a?(L=()=>a(c),t[65]=c,t[66]=a,t[67]=L):L=t[67];let R=!h,z;t[68]===o?z=t[69]:(z=o(`settings.skills.catalog.conflicts.actions.continue`),t[68]=o,t[69]=z);let B;t[70]!==L||t[71]!==R||t[72]!==z?(B=(0,$.jsx)(Y,{size:`sm`,onClick:L,disabled:R,children:z}),t[70]=L,t[71]=R,t[72]=z,t[73]=B):B=t[73];let V;t[74]!==I||t[75]!==B?(V=(0,$.jsxs)(Gt,{children:[I,B]}),t[74]=I,t[75]=B,t[76]=V):V=t[76];let H;t[77]!==b||t[78]!==N||t[79]!==V?(H=(0,$.jsxs)(Kt,{className:`max-w-2xl`,children:[b,N,V]}),t[77]=b,t[78]=N,t[79]=V,t[80]=H):H=t[80];let ee;return t[81]!==r||t[82]!==n||t[83]!==H?(ee=(0,$.jsx)(Yt,{open:n,onOpenChange:r,children:H}),t[81]=r,t[82]=n,t[83]=H,t[84]=ee):ee=t[84],ee},qc=[{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 Jc(e,t){return e===`project`&&t===`claude`?`project-claude`:e===`project`&&t===`agents`?`project-agents`:t===`claude`?`user-claude`:e===`project`?`project-opencode`:t===`agents`?`user-agents`:`user-opencode`}function Yc(e){if(e===`user-claude`)return{scope:`user`,source:`claude`};if(e===`project-claude`)return{scope:`project`,source:`claude`};let t=qc.find(t=>t.value===e);return t?{scope:t.scope,source:t.source}:{scope:`user`,source:`opencode`}}var Xc=e=>{let t=(0,Di.c)(124),{open:n,onOpenChange:r,item:a}=e,{t:o}=ke(),s=Fc(Zc),c=Fc(Qc),[l,u]=Q.useState(`user`),[d,f]=Q.useState(`opencode`),p=ft($c),m=ft(el),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],t[0]=y):y=t[0];let[b,x]=Q.useState(y),[S,C]=Q.useState(null),w,T;t[1]!==m||t[2]!==n?(w=()=>{n&&(u(`user`),f(`opencode`),g(m),v(!1),x([]),C(null))},T=[n,m],t[1]=m,t[2]=n,t[3]=w,t[4]=T):(w=t[3],T=t[4]),Q.useEffect(w,T);let E;t[5]===o?E=t[6]:(E=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.label`);case`user-agents`:return o(`settings.skills.location.option.userAgents.label`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.label`);default:return o(`settings.skills.location.option.userOpencode.label`)}},t[5]=o,t[6]=E);let D=E,O;t[7]===o?O=t[8]:(O=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.description`);case`user-agents`:return o(`settings.skills.location.option.userAgents.description`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.description`);default:return o(`settings.skills.location.option.userOpencode.description`)}},t[7]=o,t[8]=O);let k=O,A;bb0:{if(p.length===0){A=null;break bb0}if(h&&p.some(e=>e.id===h)){A=h;break bb0}if(m&&p.some(e=>e.id===m)){A=m;break bb0}A=p[0]?.id??null}let j=A,M;bb1:{if(l!==`project`){M=null;break bb1}let e=j;if(!e){M=null;break bb1}let n;if(t[9]!==e||t[10]!==p){let r;t[12]===e?r=t[13]:(r=t=>t.id===e,t[12]=e,t[13]=r),n=p.find(r),t[9]=e,t[10]=p,t[11]=n}else n=t[11];M=n?.path??null}let N=M,P;t[14]!==s||t[15]!==a||t[16]!==r||t[17]!==o?(P=async e=>{let t={skillDir:e.skillDir};a?.clawdhub&&(t.clawdhub={slug:a.clawdhub.slug,version:a.clawdhub.version});let n=await s({source:e.source,subpath:e.subpath,gitIdentityId:a?.gitIdentityId,scope:e.scope,targetSource:e.targetSource,selections:[t],conflictPolicy:`prompt`,conflictDecisions:e.conflictDecisions},{directory:e.effectiveDirectory,transportIdentity:e.transportIdentity});if(n.ok){K.success(o(`settings.skills.catalog.installSkill.toast.installed`)),r(!1);return}if(n.error?.kind===`conflicts`){C({source:e.source,subpath:e.subpath,scope:e.scope,targetSource:e.targetSource,skillDir:e.skillDir,directoryOverride:e.directoryOverride??null,effectiveDirectory:e.effectiveDirectory,transportIdentity:e.transportIdentity}),x(n.error.conflicts),v(!0);return}if(n.error?.kind===`authRequired`){K.error(n.error.message||o(`settings.skills.catalog.installSkill.toast.authRequired`));return}K.error(n.error?.message||o(`settings.skills.catalog.installSkill.toast.installFailed`))},t[14]=s,t[15]=a,t[16]=r,t[17]=o,t[18]=P):P=t[18];let F=P;if(!a)return null;let I;t[19]===o?I=t[20]:(I=o(`settings.skills.catalog.installSkill.title`),t[19]=o,t[20]=I);let L;t[21]===I?L=t[22]:(L=(0,$.jsx)(qt,{children:I}),t[21]=I,t[22]=L);let R;t[23]===o?R=t[24]:(R=o(`settings.skills.catalog.installSkill.descriptionPrefix`),t[23]=o,t[24]=R);let z;t[25]===a.skillName?z=t[26]:(z=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:a.skillName}),t[25]=a.skillName,t[26]=z);let B;t[27]===o?B=t[28]:(B=o(`settings.skills.catalog.installSkill.descriptionSuffix`),t[27]=o,t[28]=B);let V;t[29]!==R||t[30]!==z||t[31]!==B?(V=(0,$.jsxs)(Jt,{children:[R,` `,z,` `,B]}),t[29]=R,t[30]=z,t[31]=B,t[32]=V):V=t[32];let H;t[33]!==L||t[34]!==V?(H=(0,$.jsxs)(Wt,{children:[L,V]}),t[33]=L,t[34]=V,t[35]=H):H=t[35];let ee;t[36]===o?ee=t[37]:(ee=o(`settings.skills.catalog.installSkill.field.destination`),t[36]=o,t[37]=ee);let U;t[38]===ee?U=t[39]:(U=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:ee}),t[38]=ee,t[39]=U);let te;t[40]!==l||t[41]!==d?(te=Jc(l,d),t[40]=l,t[41]=d,t[42]=te):te=t[42];let W;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{let t=Yc(e);u(t.scope),f(t.source===`agents`?`agents`:`opencode`)},t[43]=W):W=t[43];let ne;t[44]===l?ne=t[45]:(ne=l===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),t[44]=l,t[45]=ne);let re;t[46]===d?re=t[47]:(re=d===`agents`?(0,$.jsx)(J,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,t[46]=d,t[47]=re);let ie;t[48]!==D||t[49]!==l||t[50]!==d?(ie=D(Jc(l,d)),t[48]=D,t[49]=l,t[50]=d,t[51]=ie):ie=t[51];let ae;t[52]===ie?ae=t[53]:(ae=(0,$.jsx)(`span`,{children:ie}),t[52]=ie,t[53]=ae);let oe;t[54]!==ne||t[55]!==re||t[56]!==ae?(oe=(0,$.jsxs)(nn,{className:`w-fit gap-1.5`,children:[ne,re,ae]}),t[54]=ne,t[55]=re,t[56]=ae,t[57]=oe):oe=t[57];let se;t[58]!==k||t[59]!==D?(se=qc.map(e=>(0,$.jsx)(en,{value:e.value,className:`pr-2 [&>span:first-child]:hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(J,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:D(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-5`,children:k(e.value)})]})},e.value)),t[58]=k,t[59]=D,t[60]=se):se=t[60];let ce;t[61]===se?ce=t[62]:(ce=(0,$.jsx)(rn,{align:`start`,children:se}),t[61]=se,t[62]=ce);let le;t[63]!==te||t[64]!==oe||t[65]!==ce?(le=(0,$.jsxs)(on,{value:te,onValueChange:W,children:[oe,ce]}),t[63]=te,t[64]=oe,t[65]=ce,t[66]=le):le=t[66];let ue;t[67]!==U||t[68]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[U,le]}),t[67]=U,t[68]=le,t[69]=ue):ue=t[69];let de;t[70]!==p||t[71]!==j||t[72]!==l||t[73]!==o?(de=l===`project`&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.skills.catalog.installSkill.field.project`)}),p.length===0?(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.skills.catalog.installSkill.field.noProjects`)}):(0,$.jsxs)(on,{value:j??``,onValueChange:e=>g(e),disabled:p.length===1,children:[(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:o(`settings.skills.catalog.installSkill.field.chooseProjectPlaceholder`)})}),(0,$.jsx)(rn,{align:`start`,children:p.map(tl)})]})]}),t[70]=p,t[71]=j,t[72]=l,t[73]=o,t[74]=de):de=t[74];let fe;t[75]===a.warnings?fe=t[76]:(fe=a.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded`,children:a.warnings.join(` · `)}):null,t[75]=a.warnings,t[76]=fe);let pe;t[77]!==ue||t[78]!==de||t[79]!==fe?(pe=(0,$.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[ue,de,fe]}),t[77]=ue,t[78]=de,t[79]=fe,t[80]=pe):pe=t[80];let me;t[81]===r?me=t[82]:(me=()=>r(!1),t[81]=r,t[82]=me);let he;t[83]===o?he=t[84]:(he=o(`settings.common.actions.cancel`),t[83]=o,t[84]=he);let ge;t[85]!==me||t[86]!==he?(ge=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:me,children:he}),t[85]=me,t[86]=he,t[87]=ge):ge=t[87];let _e=c||!a.installable||l===`project`&&!N,ve;t[88]!==N||t[89]!==F||t[90]!==a.repoSource||t[91]!==a.repoSubpath||t[92]!==a.skillDir||t[93]!==l||t[94]!==d?(ve=()=>void F({source:a.repoSource,subpath:a.repoSubpath,scope:l,targetSource:d,skillDir:a.skillDir,directoryOverride:N,effectiveDirectory:N??rt(),transportIdentity:i()}),t[88]=N,t[89]=F,t[90]=a.repoSource,t[91]=a.repoSubpath,t[92]=a.skillDir,t[93]=l,t[94]=d,t[95]=ve):ve=t[95];let ye;t[96]!==c||t[97]!==o?(ye=o(c?`settings.skills.catalog.installSkill.actions.installing`:`settings.skills.catalog.installSkill.actions.install`),t[96]=c,t[97]=o,t[98]=ye):ye=t[98];let be;t[99]!==_e||t[100]!==ve||t[101]!==ye?(be=(0,$.jsx)(Y,{size:`sm`,disabled:_e,onClick:ve,children:ye}),t[99]=_e,t[100]=ve,t[101]=ye,t[102]=be):be=t[102];let xe;t[103]!==ge||t[104]!==be?(xe=(0,$.jsxs)(Gt,{children:[ge,be]}),t[103]=ge,t[104]=be,t[105]=xe):xe=t[105];let Se;t[106]!==H||t[107]!==pe||t[108]!==xe?(Se=(0,$.jsxs)(Kt,{className:`max-w-md`,children:[H,pe,xe]}),t[106]=H,t[107]=pe,t[108]=xe,t[109]=Se):Se=t[109];let Ce;t[110]!==r||t[111]!==n||t[112]!==Se?(Ce=(0,$.jsx)(Yt,{open:n,onOpenChange:r,children:Se}),t[110]=r,t[111]=n,t[112]=Se,t[113]=Ce):Ce=t[113];let we;t[114]!==S||t[115]!==F?(we=e=>{S&&(F({source:S.source,subpath:S.subpath,scope:S.scope,targetSource:S.targetSource,skillDir:S.skillDir,conflictDecisions:e,directoryOverride:S.directoryOverride??null,effectiveDirectory:S.effectiveDirectory,transportIdentity:S.transportIdentity}),v(!1))},t[114]=S,t[115]=F,t[116]=we):we=t[116];let Te;t[117]!==b||t[118]!==_||t[119]!==we?(Te=(0,$.jsx)(Kc,{open:_,onOpenChange:v,conflicts:b,onConfirm:we}),t[117]=b,t[118]=_,t[119]=we,t[120]=Te):Te=t[120];let Ee;return t[121]!==Ce||t[122]!==Te?(Ee=(0,$.jsxs)($.Fragment,{children:[Ce,Te]}),t[121]=Ce,t[122]=Te,t[123]=Ee):Ee=t[123],Ee};function Zc(e){return e.installSkills}function Qc(e){return e.isInstalling}function $c(e){return e.projects}function el(e){return e.activeProjectId}function tl(e){return(0,$.jsx)(en,{value:e.id,children:e.label||e.path},e.id)}var nl=async()=>{try{let e=U()?.settings;if(e)return(await e.load())?.settings||{};let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},rl=({mode:e,onModeChange:t,showModeTabs:n=!0})=>{let{t:r}=ke(),{selectedSourceId:a,setSelectedSource:o}=Fc(he(e=>({selectedSourceId:e.selectedSourceId,setSelectedSource:e.setSelectedSource}))),s=Tt(),c=s.data??lt,l=c.some(e=>e.id===a)?a:null,u=bt(l??``,{enabled:!!l}),[d,f]=Q.useState(``),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(null),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(!1),[T,E]=Q.useState(null);Q.useEffect(()=>{!s.data&&s.isFetching||c.some(e=>e.id===a)||o(c[0]?.id??null)},[a,o,c,s.data,s.isFetching]);let D=rt(),O=i();Q.useEffect(()=>{E(null)},[l,D,O]);let k=Q.useMemo(()=>Dt(u.data?.pages??[]),[u.data]),A=Q.useMemo(()=>{let e=d.trim().toLowerCase();return e?k.filter(t=>{let n=t.skillName.toLowerCase(),r=(t.description||``).toLowerCase(),i=(t.frontmatterName||``).toLowerCase();return n.includes(e)||r.includes(e)||i.includes(e)}):k},[k,d]),j=Q.useMemo(()=>c.find(e=>e.id===l)||null,[c,l]),M=!!(l&&l.startsWith(`custom:`)),N=j?.source===`clawdhub:registry`||j?.sourceType===`clawdhub`,P=s.isLoading&&!s.data,F=u.isLoading&&!u.data,I=u.isFetchingNextPage,L=T??s.error??u.error,R=async()=>{if(!l||!M)return;let e=rt(),t=i();b(!0),E(null);try{let n=await nl(),r=(Array.isArray(n?.skillCatalogs)?n?.skillCatalogs:[]).filter(e=>e.id!==l);await V({skillCatalogs:r}),H.setQueriesData({queryKey:[t,`skillsCatalog`,`sources`],exact:!1},e=>e?.filter(e=>e.id!==l)),H.removeQueries({queryKey:[t,`skillsCatalog`,`source`],exact:!1,predicate:e=>e.queryKey[4]===l}),i()===t&&(o(null),S(!1)),await pt(H,e,t)}catch(n){i()===t&&rt()===e&&E(n instanceof Error?n:Error(String(n)))}finally{b(!1)}},z=async()=>{let e=rt(),t=i(),n=l;w(!0),E(null);try{n?await wt(H,e,n,t):await pt(H,e,t)}catch(r){let a=Fc.getState().selectedSourceId;i()===t&&rt()===e&&a===n&&E(r instanceof Error?r:Error(String(r)))}finally{w(!1)}};return(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n&&(0,$.jsx)(`div`,{className:`h-10`,children:(0,$.jsx)(wr,{items:[{id:`manual`,label:r(`settings.skills.catalog.page.mode.manual`)},{id:`external`,label:r(`settings.skills.catalog.page.mode.external`)}],activeId:e,onSelect:e=>t(e),layoutMode:`fit`,variant:`animated`,animateActivePill:!1,className:`h-full`})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.catalog.source`,children:(0,$.jsx)(Z,{label:r(`settings.skills.catalog.page.section.sourceRepository`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 py-1.5`,children:[(0,$.jsxs)(on,{value:l||``,onValueChange:e=>o(e),children:[(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:r(`settings.skills.catalog.page.field.selectSourcePlaceholder`),children:j?.label})}),(0,$.jsx)(rn,{align:`start`,children:c.map(e=>(0,$.jsx)(en,{value:e.id,children:e.label},e.id))})]}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal h-6 w-6 px-0`,onClick:()=>void z(),disabled:C,title:r(`settings.skills.catalog.page.actions.refreshTitle`),children:(0,$.jsx)(J,{name:`refresh`,className:q(`h-3.5 w-3.5`,C&&`animate-spin`)})}),M&&(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>S(!0),disabled:y,title:r(`settings.skills.catalog.page.actions.removeCatalogTitle`),children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(Y,{"data-settings-item":`skills.catalog.add-catalog`,size:`xs`,className:`!font-normal gap-1`,onClick:()=>m(!0),children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),` `,r(`settings.skills.catalog.page.actions.addCatalog`)]})]}),(0,$.jsxs)(`div`,{"data-settings-item":`skills.catalog.search`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(J,{name:`search`,className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(un,{value:d,onChange:e=>f(e.target.value),placeholder:r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),className:`h-7 pl-8 w-full sm:w-64`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground mt-1 block`,children:P?r(`settings.skills.catalog.page.loading.catalog`):r(`settings.skills.catalog.page.foundCount`,{count:A.length})})]})]})})}),L&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:r(`settings.skills.catalog.page.error.catalogTitle`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:L.message})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{children:A.length===0&&!F?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-body`,children:r(`settings.skills.catalog.page.empty.noSkillsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.catalog.page.empty.noSkillsDescription`)})]}):F?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`refresh`,className:`mx-auto mb-3 h-5 w-5 animate-spin opacity-50`}),(0,$.jsx)(`p`,{className:`typography-meta`,children:r(`settings.skills.catalog.page.loading.skills`)})]}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:A.map(e=>{let t=e.installed?.isInstalled,n=e.installed?.scope;return(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.skillName}),t&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)] bg-[var(--status-success)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.installed`,{scope:n||r(`settings.skills.catalog.page.badge.unknown`)})}),!e.installable&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.notInstallable`)})]}),e.description?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 line-clamp-2`,children:e.description}):(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground/50 mt-0.5 italic`,children:r(`settings.skills.catalog.shared.noDescription`)}),e.clawdhub&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground mt-1.5 flex items-center gap-3`,children:[e.clawdhub.owner&&(0,$.jsxs)(`span`,{children:[r(`settings.skills.catalog.page.byOwnerPrefix`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.clawdhub.owner})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(J,{name:`download`,className:`h-3 w-3`}),e.clawdhub.downloads?.toLocaleString()??0]}),(e.clawdhub.stars??0)>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(J,{name:`star`,className:`h-3 w-3`}),e.clawdhub.stars]}),(0,$.jsxs)(`span`,{className:`bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[`v`,e.clawdhub.version]})]}),e.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit`,children:e.warnings.join(` · `)}):null]}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,disabled:!e.installable,onClick:()=>{v(e),g(!0)},children:r(`settings.skills.catalog.shared.actions.install`)})]})},`${e.sourceId}:${e.skillDir}`)})})}),N&&u.hasNextPage&&!F&&A.length>0&&(0,$.jsx)(`div`,{className:`flex justify-center mt-2 px-2`,children:(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void u.fetchNextPage(),disabled:I,children:r(I?`settings.skills.catalog.page.loading.more`:`settings.skills.catalog.page.actions.loadMoreSkills`)})})]}),(0,$.jsx)(zc,{open:p,onOpenChange:m}),(0,$.jsx)(Xc,{open:h,onOpenChange:g,item:_}),(0,$.jsx)(Yt,{open:x,onOpenChange:e=>{y||S(e)},children:(0,$.jsxs)(Kt,{className:`max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:r(`settings.skills.catalog.page.removeDialog.title`)}),(0,$.jsx)(Jt,{children:r(`settings.skills.catalog.page.removeDialog.description`)})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>S(!1),disabled:y,children:r(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>void R(),disabled:y,children:r(`settings.skills.catalog.page.actions.removeCatalog`)})]})]})})]})})},il=()=>{let e=(0,Di.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(rl,{mode:`external`,onModeChange:pl,showModeTabs:!1}),e[0]=t):t=e[0],t},al=`SKILL.md`,ol=`h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]`,sl=(e,t)=>{let n=wi({description:e}).trimEnd(),r=t.trimStart();return`---\n${n}\n---${r?`\n\n${r}`:`
|
|
22
|
+
`}`},cl=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ll=e=>{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!t)return{description:null,instructions:e};let n=null;try{let e=Ti(t[1]);if(cl(e)){let t=e.description;typeof t==`string`&&(n=t)}}catch{n=null}return{description:n,instructions:t[2].replace(/^\r?\n/,``)}},ul=(e,t)=>sl(t,ll(e).instructions),dl=()=>{let{t:e}=ke(),{currentTheme:t}=dr(),{selectedSkillName:n,getSkillDetail:r,createSkill:i,updateSkill:a,skillDraft:o,setSkillDraft:s,setSelectedSkill:c}=fa(he(e=>({selectedSkillName:e.selectedSkillName,getSkillDetail:e.getSkillDetail,createSkill:e.createSkill,updateSkill:e.updateSkill,skillDraft:e.skillDraft,setSkillDraft:e.setSkillDraft,setSelectedSkill:e.setSelectedSkill}))),l=Fe(),d=Je(),f=Q.useMemo(()=>l.data??[],[l.data]),p=n?f.find(e=>e.name===n)??null:null,m=!!(o&&o.name===n&&!p),h=!!(n&&!p&&!o),g=p?.path===`<built-in>`;Q.useEffect(()=>{h&&c(null)},[h,c]);let[_,v]=Q.useState(``),[y,b]=Q.useState(`user`),[x,S]=Q.useState(`opencode`),[C,w]=Q.useState(``),[T,E]=Q.useState(``),[D,O]=Q.useState(()=>sl(``,``)),[k,A]=Q.useState(`edit`),[j,M]=Q.useState([]),[N,P]=Q.useState([]),[F,I]=Q.useState(!1),[L,R]=Q.useState(!1),[z,B]=Q.useState(``),[V,H]=Q.useState(``),[ee,U]=Q.useState(!1),[te,W]=Q.useState(``),[ne,re]=Q.useState(``),[ie,ae]=Q.useState(null),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(``),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(!1),me=m?_.trim()!==``||C.trim()!==``||T.trim()!==``||N.length>0:C!==z||T!==V,ge=ie?ne!==ce:te.trim()!==``,_e=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.label`);case`user-claude`:return e(`settings.skills.location.option.userClaude.label`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.label`);case`user-agents`:return e(`settings.skills.location.option.userAgents.label`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.label`);default:return e(`settings.skills.location.option.userOpencode.label`)}},[e]),ve=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.description`);case`user-claude`:return e(`settings.skills.location.option.userClaude.description`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.description`);case`user-agents`:return e(`settings.skills.location.option.userAgents.description`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.description`);default:return e(`settings.skills.location.option.userOpencode.description`)}},[e]);Q.useEffect(()=>{(async()=>{if(m&&o){let e=o.description||``,t=o.instructions||``;v(o.name||``),b(o.scope||`user`),S(o.source===`agents`?`agents`:`opencode`),w(e),E(t),O(sl(e,t)),B(``),H(``),M([]),P(o.pendingFiles||[])}else if(n&&p){R(!0);try{let e=await r(n);if(e){let t=e.sources.md,n=t.description||``,r=t.instructions||``;w(n),E(r),O(sl(n,r)),B(n),H(r),M(t.supportingFiles||[])}}catch(e){console.error(`Failed to load skill details:`,e)}finally{R(!1)}}})()},[p,m,n,f,o,r]);let ye=u(e=>e.editorFontSize),be=Q.useMemo(()=>{let e=[ai(t,{fontSize:ye})],n=cr(al);return n&&e.push(n),e.push(Te.lineWrapping),e},[t,ye]),xe=Q.useMemo(()=>{let e=te.trim()||`supporting-file.md`,n=Cr(e),r=!!n&&n!==`markdown`,i=[ai(t,r?{syntaxColors:!1,fontSize:ye}:{fontSize:ye})],a=cr(e);return a&&i.push(a),r&&n&&i.push(zr({language:n,themeName:t.metadata.id,theme:vr(t)})),i.push(Te.lineWrapping),i},[t,te,ye]),Se=Q.useCallback(e=>{w(e),O(t=>ul(t,e))},[]),Ce=Q.useCallback(e=>{O(e);let t=ll(e);w(t.description??``),E(t.instructions)},[]),we=async()=>{let t=m?_.trim().replace(/\s+/g,`-`).toLowerCase():n?.trim();if(!t){K.error(e(`settings.skills.page.toast.skillNameRequired`));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(t)||t.length>64){K.error(e(`settings.skills.page.toast.invalidSkillName`));return}if(!C.trim()){K.error(e(`settings.skills.page.toast.descriptionRequired`));return}if(m&&f.some(e=>e.name===t)){K.error(e(`settings.skills.page.toast.skillExists`));return}I(!0);try{let n={name:t,description:C.trim(),instructions:T.trim()||void 0,scope:m?y:void 0,source:m?x:void 0,targetPath:m?void 0:p?.path,supportingFiles:m&&N.length>0?N:void 0},r;m?(r=await i(n,{directory:d}),r&&(s(null),P([]),c(t))):(r=await a(t,n,{directory:d}),r&&(B(C.trim()),H(T.trim()))),r?K.success(e(m?`settings.skills.page.toast.skillCreated`:`settings.skills.page.toast.skillUpdated`)):K.error(e(m?`settings.skills.page.toast.createSkillFailed`:`settings.skills.page.toast.updateSkillFailed`))}catch(t){console.error(`Error saving skill:`,t),K.error(e(`settings.skills.page.toast.saveUnexpectedError`))}finally{I(!1)}},Ee=()=>{ae(null),W(``),re(``),le(``),U(!0)},De=async t=>{if(ae(t),W(t),m){let e=N.find(e=>e.path===t)?.content||``;re(e),le(e),U(!0);return}if(n){se(!0),U(!0);try{let{readSupportingFile:e}=fa.getState(),r=await e(n,t);re(r||``),le(r||``)}catch{K.error(e(`settings.skills.page.toast.loadFileContentFailed`)),re(``),le(``)}finally{se(!1)}}},Oe=async()=>{if(!te.trim()){K.error(e(`settings.skills.page.toast.fileNameRequired`));return}let t=te.trim(),i=ie!==null;if(m){if(i)P(e=>e.map(e=>e.path===ie?{path:t,content:ne}:e)),K.success(e(`settings.skills.page.toast.fileUpdated`,{path:t}));else{if(N.some(e=>e.path===t)){K.error(e(`settings.skills.page.toast.fileExists`));return}P(e=>[...e,{path:t,content:ne}]),K.success(e(`settings.skills.page.toast.fileAdded`,{path:t}))}U(!1),ae(null);return}if(!n){K.error(e(`settings.skills.page.toast.noSkillSelected`));return}let{writeSupportingFile:a}=fa.getState();if(await a(n,t,ne)){K.success(e(i?`settings.skills.page.toast.fileUpdated`:`settings.skills.page.toast.fileCreated`,{path:t})),U(!1),ae(null);let a=await r(n);a&&M(a.sources.md.supportingFiles||[])}else K.error(e(i?`settings.skills.page.toast.updateFileFailed`:`settings.skills.page.toast.createFileFailed`))},Ae=t=>{if(m){P(e=>e.filter(e=>e.path!==t)),K.success(e(`settings.skills.page.toast.fileRemoved`,{path:t}));return}n&&de(t)};return!n&&!o||h?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.skills.page.empty.description`)})]})}):L?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.loading.details`)})})}):(0,$.jsxs)(br,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate flex items-center gap-2`,children:m?e(`settings.skills.page.title.newSkill`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:p?e(`settings.skills.page.subtitle.skillLocation`,{location:_e(Jc(p.scope,p.source))}):e(`settings.skills.page.subtitle.newSkill`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.basic-information`,children:(0,$.jsx)(Z,{label:e(`settings.skills.page.section.basicInformation`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[m&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.skills.page.field.skillNameLocation`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.skillNameHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,$.jsx)(un,{value:_,onChange:e=>v(e.target.value.toLowerCase().replace(/\s+/g,`-`)),placeholder:e(`settings.skills.page.field.skillNamePlaceholder`),className:`h-7 w-40 px-2`}),(0,$.jsxs)(on,{value:Jc(y,x),onValueChange:e=>{let t=Yc(e);b(t.scope),S(t.source===`agents`?`agents`:`opencode`)},children:[(0,$.jsxs)(nn,{className:`w-fit gap-1.5`,children:[y===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),x===`agents`?(0,$.jsx)(J,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:_e(Jc(y,x))})]}),(0,$.jsx)(rn,{align:`start`,children:qc.map(e=>(0,$.jsx)(en,{value:e.value,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(J,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:_e(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-6`,children:ve(e.value)})]})},e.value))})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[e(`settings.common.field.description`),` `,(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`*`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.descriptionHint`)}),(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(xr,{embedded:!0,value:C,onChange:e=>Se(e.target.value),placeholder:e(`settings.skills.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] max-h-32 bg-transparent`,disabled:g})})]})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.instructions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.instructions`)}),(0,$.jsx)(kr,{currentMode:k===`preview`?`preview`:`edit`,onToggle:()=>A(e=>e===`preview`?`edit`:`preview`)})]}),cardClassName:`p-3`,children:(0,$.jsx)(`div`,{className:q(`overflow-hidden bg-background`,ol),children:k===`preview`?(0,$.jsx)(br,{outerClassName:`h-full`,className:`h-full`,children:(0,$.jsx)(`div`,{className:`min-h-full px-4 py-3`,children:(0,$.jsx)(yr,{content:D,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})}):(0,$.jsx)(Er,{value:D,onChange:Ce,readOnly:g,extensions:be,className:`h-full`,enableSearch:!0})})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.supporting-files`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.supportingFiles`)}),(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Ee,disabled:g,children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),` `,e(`settings.skills.page.actions.addFile`)]})]}),cardClassName:`p-3`,children:(()=>{let t=m?N:j;return t.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-1.5`,children:e(`settings.skills.page.supportingFiles.empty`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:t.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 cursor-pointer group`,onClick:()=>De(t.path),children:[(0,$.jsx)(J,{name:`file`,className:`h-3.5 w-3.5 text-muted-foreground flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.path}),m&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:e(`settings.skills.page.badge.pending`)}),!g&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),Ae(t.path)},children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-3 w-3`})})]},t.path))})})()})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Y,{onClick:we,disabled:g||F||!me,size:`xs`,className:`!font-normal`,children:e(F?`settings.common.actions.saving`:m?`settings.skills.page.actions.createSkill`:`settings.common.actions.saveChanges`)})})]}),(0,$.jsx)(Yt,{open:ue!==null,onOpenChange:e=>{!e&&!fe&&de(null)},children:(0,$.jsxs)(Kt,{className:`max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.skills.page.deleteFileDialog.title`)}),(0,$.jsx)(Jt,{children:e(`settings.skills.page.deleteFileDialog.description`,{path:ue??``})})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>de(null),disabled:fe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:async()=>{if(!ue||!n)return;pe(!0);let{deleteSupportingFile:t}=fa.getState();if(await t(n,ue)){K.success(e(`settings.skills.page.toast.fileDeleted`,{path:ue}));let t=await r(n);t&&M(t.sources.md.supportingFiles||[]),de(null)}else K.error(e(`settings.skills.page.toast.deleteFileFailed`));pe(!1)},disabled:fe,children:e(`settings.common.actions.delete`)})]})]})}),(0,$.jsx)(Yt,{open:ee,onOpenChange:e=>{U(e),e||ae(null)},children:(0,$.jsxs)(Kt,{className:`max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,$.jsxs)(Wt,{className:`flex-shrink-0`,children:[(0,$.jsx)(qt,{children:e(ie?`settings.skills.page.fileDialog.titleEdit`:`settings.skills.page.fileDialog.titleAdd`)}),(0,$.jsx)(Jt,{children:e(ie?`settings.skills.page.fileDialog.descriptionEdit`:`settings.skills.page.fileDialog.descriptionAdd`)})]}),oe?(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.skills.page.loading.fileContent`)})}):(0,$.jsxs)(`div`,{className:`space-y-4 flex-1 min-h-0 flex flex-col pt-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2 flex-shrink-0`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.skills.page.fileDialog.field.filePath`)}),(0,$.jsx)(un,{value:te,onChange:e=>W(e.target.value),placeholder:e(`settings.skills.page.fileDialog.field.filePathPlaceholder`),className:`text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]`,disabled:ie!==null}),!ie&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.skills.page.fileDialog.field.filePathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 flex-1 min-h-0 flex flex-col`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground flex-shrink-0`,children:e(`settings.skills.page.fileDialog.field.content`)}),(0,$.jsx)(`div`,{className:`h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background`,children:(0,$.jsx)(Er,{value:ne,onChange:re,extensions:xe,className:`h-full`,enableSearch:!0})})]})]}),(0,$.jsxs)(Gt,{className:`mt-4`,children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{U(!1),ae(null)},children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:Oe,disabled:oe||!ge,children:e(ie?`settings.common.actions.saveChanges`:`settings.skills.page.actions.createFile`)})]})]})})]})},fl=e=>{let t=(0,Di.c)(2),{view:n}=e,r=n===void 0?`installed`:n,i;return t[0]===r?i=t[1]:(i=r===`catalog`?(0,$.jsx)(il,{}):(0,$.jsx)(dl,{}),t[0]=r,t[1]=i),i};function pl(){}var ml=e=>{let t=(0,Di.c)(26),{onItemSelect:n}=e,{t:r}=ke(),i=ft(hl),a=ft(gl),o=u(_l),s=u(vl),c=Q.useRef(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[0]=l):l=t[0];let d=Q.useRef(l),f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=m(),t[1]=f):f=t[1];let p=f,h=yl,g,_;t[2]!==a||t[3]!==i||t[4]!==o||t[5]!==s?(g=()=>{let e=new Set(i.map(bl)),t=c.current;if(t)for(let n of e)t.has(n)||d.current.add(n);if(c.current=e,a&&d.current.delete(a)){s(a);return}if(i.length===0){o!==null&&s(null);return}o&&i.some(e=>e.id===o)||s(i[0].id)},_=[a,i,o,s],t[2]=a,t[3]=i,t[4]=o,t[5]=s,t[6]=g,t[7]=_):(g=t[6],_=t[7]),Q.useEffect(g,_);let v;t[8]!==i.length||t[9]!==r?(v=r(`settings.projects.sidebar.total`,{count:i.length}),t[8]=i.length,t[9]=r,t[10]=v):v=t[10];let y;t[11]===v?y=t[12]:(y=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:v}),t[11]=v,t[12]=y);let b;t[13]===r?b=t[14]:(b=!p&&(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 -my-1 text-muted-foreground`,onClick:h,"aria-label":r(`settings.projects.sidebar.actions.addProject`),children:(0,$.jsx)(J,{name:`add`,className:`size-4`})}),t[13]=r,t[14]=b);let x;t[15]!==y||t[16]!==b?(x=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-[var(--oc-settings-row-inset)]`,children:[y,b]}),t[15]=y,t[16]=b,t[17]=x):x=t[17];let S;t[18]!==n||t[19]!==i||t[20]!==o||t[21]!==s?(S=i.length>0?(0,$.jsx)(Z,{children:i.map(e=>{let t=e.id===o,r=e.icon?an[e.icon]:null,i=e.color?sn[e.color]:void 0,a=(0,$.jsx)(J,{name:r??`folder`,className:`h-4 w-4`,style:i?{color:i}:void 0}),c=(0,$.jsx)(`span`,{className:q(`flex size-5 shrink-0 items-center justify-center overflow-hidden`,t?`text-foreground`:`text-muted-foreground`),children:e.iconImage?(0,$.jsx)(tn,{project:e,className:`size-full object-contain`,fallback:a}):a});return(0,$.jsx)(Qa,{title:e.path.split(/[\\/]/).filter(Boolean).at(-1)||e.path,icon:c,selected:t,onSelect:()=>{s(e.id),n?.()}},e.id)})}):null,t[18]=n,t[19]=i,t[20]=o,t[21]=s,t[22]=S):S=t[22];let C;return t[23]!==x||t[24]!==S?(C=(0,$.jsx)(eo,{variant:`background`,header:x,children:S}),t[23]=x,t[24]=S,t[25]=C):C=t[25],C};function hl(e){return e.projects}function gl(e){return e.activeProjectId}function _l(e){return e.settingsProjectsSelectedId}function vl(e){return e.setSettingsProjectsSelectedId}function yl(){$e.requestDirectoryDialog()}function bl(e){return e.id}var xl=()=>{let e=(0,Di.c)(18),{t}=ke(),n=ft(Sl),r=ft(Cl),i=u(wl),a=u(Tl),o;bb0:{if(!i){o=null;break bb0}let t;e[0]!==n||e[1]!==i?(t=n.find(e=>e.id===i)??null,e[0]=n,e[1]=i,e[2]=t):t=e[2],o=t}let s=o,c,l;e[3]!==n||e[4]!==i||e[5]!==a?(c=()=>{if(n.length===0){a(null);return}i&&n.some(e=>e.id===i)||a(n[0].id)},l=[n,i,a],e[3]=n,e[4]=i,e[5]=a,e[6]=c,e[7]=l):(c=e[6],l=e[7]),Q.useEffect(c,l);let d;e[8]!==s||e[9]!==r?(d=async e=>{s&&r(s.id,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},e[8]=s,e[9]=r,e[10]=d):d=e[10];let f=d;if(!s){let n;e[11]===t?n=e[12]:(n=t(`settings.projects.page.empty.noProjects`),e[11]=t,e[12]=n);let r;return e[13]===n?r=e[14]:(r=(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n})})}),e[13]=n,e[14]=r),r}let p;return e[15]!==f||e[16]!==s?(p=(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full bg-background`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(mi,{project:s,onIdentitySave:f})})}),e[15]=f,e[16]=s,e[17]=p):p=e[17],p};function Sl(e){return e.projects}function Cl(e){return e.updateProjectMeta}function wl(e){return e.settingsProjectsSelectedId}function Tl(e){return e.setSettingsProjectsSelectedId}var El=e(Ei(),1),Dl=16384,Ol=globalThis,kl=e=>{if(Ol.Buffer)return Ol.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},Al=e=>{try{if(Ol.Buffer)return Ol.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},jl=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},Ml=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},Nl=e=>typeof e==`string`&&e.length>0,Pl=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!Nl(t.x)||!Nl(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},Fl=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,Il=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=Fl(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=jl(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=Ml(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Pl(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},Ll=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(Il).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},Rl=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),zl=e=>{let t=Ll(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,kl(JSON.stringify(t))),`openchamber://connect?${n.toString()}`},Bl=e=>{let t=e.trim();if(!t||t.length>Dl)return null;let n=t.indexOf(`?`);if(n===-1||!/^openchamber:\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>Dl)return null;let a=Al(i);if(!a||a.length>Dl)return null;try{return Ll(JSON.parse(a))}catch{return null}},Vl=e=>{let t=e.trim();if(!t||t.length>Dl)return null;try{let e=new URL(t);if(e.protocol===`openchamber:`&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>Dl)return null;let n=Al(t);return!n||n.length>Dl?null:Ll(JSON.parse(n))}}catch{}return Bl(t)},Hl=`relay_identity_changed`,Ul=class extends Error{code=Hl;expectedServerId;actualServerId;constructor(e,t){super(`Relay identity changed (expected ${e}, got ${t||`unknown`})`),this.name=`RelayIdentityChangedError`,this.expectedServerId=e,this.actualServerId=t}},Wl=new Map,Gl=e=>{let t=e.trim();if(!t)throw Error(`Relay serverId is required`);return`relay:${t}`},Kl=e=>{let t={Accept:`application/json`},n=typeof e.clientToken==`string`?e.clientToken.trim():``;if(n&&(t.Authorization=`Bearer ${n}`),e.requestHeaders)for(let[n,r]of Object.entries(e.requestHeaders))!n.trim()||!r.trim()||n.trim().toLowerCase()!==`authorization`&&(t[n.trim()]=r.trim());return t},ql=e=>({files:e?.files?.length??0,directories:e?.directories?.length??0,deletes:e?.deletes?.length??0,totalBytes:e?.totalBytes??0}),Jl=async e=>{y()&&await B(`desktop_sync_runs_append`,{record:e})},Yl=async(e,t)=>{if(!t)return;let n=await t().catch(()=>null),r=typeof n?.serverId==`string`?n.serverId.trim():``;if(r&&r!==e)throw new Ul(e,r)},Xl=e=>({ok:!0,files:0,directories:0,deletes:e.deletes.length,totalBytes:0,agentsRoot:null,authFile:null,plan:e}),Zl=e=>{let t=e?.selectionShape;if(!t)throw Error(`Local sync inventory missing selectionShape (update the OpenChamber desktop app)`);return t},Ql=(e,t)=>{let n=sr(e,{includeAuthFile:!1}),r=t.selections;return{fileGroups:r?.fileGroups??n.fileGroups,singleFiles:r?.singleFiles??n.singleFiles,directories:r?.directories??n.directories,agentsRoot:r?.agentsRoot!==!1,authFile:r?.authFile===!0}},$l=(e,t,n)=>{let r=e.inventory&&typeof e.inventory==`object`?e.inventory:null;return{direction:`pull`,files:r?.files??t?.files??[],directories:r?.directories??t?.directories??[],agentsRoot:n.agentsRoot?r?.agentsRoot??null:null,authFile:n.authFile?r?.authFile??null:null,deletes:t?.deletes??[],totalBytes:t?.totalBytes??0,selections:n}},eu=(e,t)=>({...e,direction:`push`,authFile:t.authFile?e.authFile:null,agentsRoot:t.agentsRoot?e.agentsRoot:null,selections:t}),tu=e=>e.files.length>0||e.directories.length>0||!!e.agentsRoot||!!e.authFile,nu=(e,t)=>{let n=d({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),r=Kl(t),i=async(e,t,i)=>{let a=await n.fetch(t,{method:e,headers:{...r,...i===void 0?{}:{"Content-Type":`application/json`}},body:i===void 0?void 0:JSON.stringify(i)}),o=await a.json().catch(()=>({}));if(!a.ok){let n=Error(typeof o.error==`string`?o.error:`Relay sync ${e} ${t} failed (${a.status})`);throw typeof o.code==`string`&&(n.code=o.code),n}return o};return{tunnel:n,async probe(e){let t=await i(`POST`,`/api/openchamber/config-sync/probe`,{plan:e});return{remoteExisting:Array.isArray(t.remoteExisting)?t.remoteExisting:[],remoteAgentsRootExists:t.remoteAgentsRootExists===!0,remoteAuthFileExists:t.remoteAuthFileExists===!0,inventory:t.inventory}},async prepare(e,t){await i(`POST`,`/api/openchamber/config-sync/prepare`,{plan:e,syncRunId:t})},async putTar(e,t,i){let a=await n.fetch(`/api/openchamber/config-sync/put/${encodeURIComponent(e)}?syncRunId=${encodeURIComponent(i)}`,{method:`PUT`,headers:{...r,"Content-Type":`application/gzip`},body:new Blob([new Uint8Array(t)],{type:`application/gzip`})}),o=await a.json().catch(()=>({}));if(!a.ok){let t=Error(typeof o.error==`string`?o.error:`Relay sync put ${e} failed (${a.status})`);throw typeof o.code==`string`&&(t.code=o.code),t}},async download(e){let t=await n.fetch(`/api/openchamber/config-sync/download/${encodeURIComponent(e)}`,{method:`GET`,headers:r});if(!t.ok){let n=await t.json().catch(()=>({})),r=Error(typeof n.error==`string`?n.error:`Relay sync download ${e} failed (${t.status})`);throw typeof n.code==`string`&&(r.code=n.code),r}return new Uint8Array(await t.arrayBuffer())},async finalize(e){await i(`POST`,`/api/openchamber/config-sync/finalize`,{syncRunId:e})},async abort(e){await i(`POST`,`/api/openchamber/config-sync/abort`,{syncRunId:e}).catch(()=>void 0)},close(){n.close()}}},ru=async(e,t,n,r)=>{if(Wl.has(e)){let t=Error(`Config sync already in progress for ${e}`);throw t.code=`sync_in_progress`,t}let i=crypto.randomUUID(),a=new Date().toISOString();Wl.set(e,i);try{let o=await r({syncRunId:i});return await Jl({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`success`,summary:ql(o.plan)}),{...o,syncRunId:i}}catch(r){throw await Jl({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`failure`,summary:ql(null),error:r instanceof Error?r.message:String(r)}).catch(()=>void 0),r}finally{Wl.get(e)===i&&Wl.delete(e)}},iu=async(e,t)=>{let n=await Cn({direction:e,targetKind:`relay`}),r=Zl(n),i=Ql(r,t),a=e===`push`?await Cn({direction:e,selections:i,targetKind:`relay`}):n;if(e===`push`&&!a)throw Error(`Local sync inventory unavailable`);return{selectionShape:r,selections:i,localPlan:a}},au=async(e,t={},n={})=>{let r=e.relay,i=Gl(r.serverId),a=t.direction===`pull`?`pull`:`push`;return ru(i,`preview`,a,async()=>{await Yl(r.serverId,n.refreshCandidates);let{selectionShape:i,selections:o,localPlan:s}=await iu(a,t),c=nu(r,e);try{if(a===`pull`){let e=await c.probe({});return{plan:$l(e,s,o),remoteExisting:e.remoteExisting,remoteAgentsRootExists:e.remoteAgentsRootExists,remoteAuthFileExists:e.remoteAuthFileExists,selectionShape:i}}let e=eu(s,o),t=await c.probe(e);return{plan:e,remoteExisting:t.remoteExisting,remoteAgentsRootExists:t.remoteAgentsRootExists,remoteAuthFileExists:t.remoteAuthFileExists,selectionShape:s?.selectionShape??i}}finally{c.close()}})},ou=async(e,t={},n={})=>{let r=e.relay,i=Gl(r.serverId),a=t.direction===`pull`?`pull`:`push`;return ru(i,`apply`,a,async({syncRunId:i})=>{await Yl(r.serverId,n.refreshCandidates);let{selections:o,localPlan:s}=await iu(a,t),c=nu(r,e);try{if(a===`pull`){let e=$l(await c.probe({}),s,o);if(!tu(e))return Xl(e);let t=e.files.length>0||e.directories.length>0?await c.download(`config`):null,n=e.agentsRoot?await c.download(`agents`):null,r=e.authFile?await c.download(`auth`):null;if(!y())throw Error(`Relay pull apply requires the OpenChamber desktop app`);let a=await B(`desktop_relay_sync_apply_local`,{syncRunId:i,plan:e,configTar:t,agentsTar:n,authTar:r});if(!a?.ok)throw Error(`Relay pull local apply failed`);return{...a,plan:e}}let e=eu(s,o);if(!tu(e))return Xl(e);if(!y())throw Error(`Relay push apply requires the OpenChamber desktop app`);let t=await B(`desktop_relay_sync_pack_local`,{plan:e});if(!t)throw Error(`Relay push local pack failed`);await c.prepare(e,i);try{t.configTar&&t.configTar.byteLength>0&&await c.putTar(`config`,t.configTar,i),t.agentsTar&&t.agentsTar.byteLength>0&&await c.putTar(`agents`,t.agentsTar,i),t.authTar&&t.authTar.byteLength>0&&await c.putTar(`auth`,t.authTar,i),await c.finalize(i)}catch(e){throw await c.abort(i),e}return{ok:!0,files:e.files.length,directories:e.directories.length,deletes:e.deletes.length,totalBytes:e.totalBytes,agentsRoot:e.agentsRoot?{fileCount:e.agentsRoot.fileCount}:null,authFile:e.authFile?{bytes:e.authFile.bytes}:null,plan:e}}finally{c.close()}})},su=`wss://relay.openchamber.dev/ws`,cu=`openchamber.pairing.relayUrl.v1`,lu=e=>{if(typeof e!=`string`||!e.trim())return null;try{let t=new URL(e.trim());return t.protocol!==`ws:`&&t.protocol!==`wss:`||t.username||t.password?null:(t.username=``,t.password=``,t.hash=``,t.search=``,t.toString())}catch{return null}},uu=(e=typeof window>`u`?null:window.localStorage)=>{if(!e)return null;try{return lu(e.getItem(cu))}catch{return null}},du=(e,t=typeof window>`u`?null:window.localStorage)=>{if(!t)return;let n=lu(e);if(n)try{t.setItem(cu,n)}catch{}},fu=`https://github.com/yee94/openchamber/tree/main/packages/relay-server`,pu=()=>Math.floor(2e4+Math.random()*3e4),mu=e=>{if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return`${e} B`},hu={fileGroups:[],singleFiles:[],directories:[],agentsRoot:!0,authFile:!1},gu=e=>{let t=e.selectionShape;if(!t||typeof t!=`object`)return null;let n=typeof t.fileGroups==`number`?t.fileGroups:null,r=typeof t.singleFiles==`number`?t.singleFiles:null,i=typeof t.directories==`number`?t.directories:null;return n===null||r===null||i===null||n<0||r<0||i<0?null:{fileGroups:n,singleFiles:r,directories:i}},_u=(e,t)=>e.fileGroups.length===t.fileGroups&&e.singleFiles.length===t.singleFiles&&e.directories.length===t.directories,vu=[`settings.remoteInstances.page.sync.step.scanLocal`,`settings.remoteInstances.page.sync.step.compareRemote`,`settings.remoteInstances.page.sync.step.confirm`],yu=({open:e,instanceId:t,targetKind:n=`ssh`,relayHost:r=null,onOpenChange:i})=>{let{t:a}=ke(),[o,s]=Q.useState(1),[c,l]=Q.useState(`scanning-local`),[u,d]=Q.useState(`push`),[f,p]=Q.useState(hu),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(null),[S,C]=Q.useState(null),w=Q.useRef(hu),T=m!=null&&_u(f,m),E=Oe(()=>{s(1),l(`scanning-local`),d(`push`),p(hu),h(null),_(null),y(null),x(null),C(null),w.current=hu}),D=Oe(async(e=u,i=f)=>{if(t){s(2),l(`comparing-remote`),x(null),C(null),y(null);try{let o=n===`relay`?r?await au(r,{direction:e,selections:i}):null:await wn(t,{targetKind:n,direction:e,selections:i});if(!o){x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(2),l(`error`);return}y(o),w.current=i,s(3),l(`review`)}catch(e){console.error(`[remote-instances] config sync compare-remote failed`,e),x(e instanceof Error?e.message:String(e)),C(2),l(`error`)}}}),O=Oe(async(e=u,r=f)=>{if(t){s(1),l(`scanning-local`),x(null),C(null),_(null),y(null);try{let t=m!=null&&_u(r,m),i=await Cn(t?{targetKind:n,direction:e,selections:r}:{targetKind:n,direction:e});if(!i){h(null),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}let o=gu(i);if(!o){h(null),p(hu),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}h(o);let s=t?r:sr(o,{includeAuthFile:!1});p(s),_(i),await D(e,s)}catch(e){console.error(`[remote-instances] config sync scan-local failed`,e),x(e instanceof Error?e.message:String(e)),C(1),l(`error`)}}});Q.useEffect(()=>{!e||!t||O(`push`)},[e,t]),Q.useEffect(()=>{e||E()},[e]);let k=Q.useMemo(()=>new Set(v?.remoteExisting??[]),[v]),A=v?.plan??g,j=!!(A&&(A.files.length>0||A.directories.length>0||A.agentsRoot!=null||A.authFile!=null)),M=c===`applying`,N=c===`review`||c===`applying`&&o===3,P=A?A.deletes.length+(A.agentsRoot&&v?.remoteAgentsRootExists?1:0):0,F=Oe(()=>{if(S===2){D(u,f);return}O(u,f)}),I=Oe(e=>{e===u||M||(d(e),y(null),_(null),O(e,f))}),L=Oe(async()=>{if(!(!t||!j||M||c!==`review`)){l(`applying`);try{if(!(n===`relay`?r&&await ou(r,{direction:u,selections:w.current}):await Kn(t,{targetKind:n,direction:u,selections:w.current})))throw Error(`Sync bridge unavailable`);K.success(a(`settings.remoteInstances.page.sync.toast.success`)),i(!1)}catch(e){console.error(`[remote-instances] config sync apply failed`,e),K.error(a(`settings.remoteInstances.page.sync.toast.failed`),{description:e instanceof Error?e.message:String(e)}),l(`review`)}}}),R=e=>c===`error`&&S!=null?e<S?`done`:e===S?`active`:`pending`:c===`review`||c===`applying`||e<o?`done`:e===o?`active`:`pending`;return(0,$.jsx)(Yt,{open:e,onOpenChange:i,children:(0,$.jsxs)(Kt,{className:`min-h-0 sm:max-w-2xl`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:a(`settings.remoteInstances.page.sync.title`)}),(0,$.jsx)(Jt,{children:a(`settings.remoteInstances.page.sync.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:u===`push`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`push`,disabled:M||c===`comparing-remote`||c===`scanning-local`,onClick:()=>I(`push`),children:a(`settings.remoteInstances.page.sync.direction.push`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,variant:u===`pull`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`pull`,disabled:M||c===`comparing-remote`||c===`scanning-local`,onClick:()=>I(`pull`),children:a(`settings.remoteInstances.page.sync.direction.pull`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 p-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.scope.title`)}),T?null:(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:a(c===`scanning-local`||c===`comparing-remote`?`settings.remoteInstances.page.sync.step.scanLocal`:`settings.remoteInstances.page.sync.state.unavailable`)}),[{key:`config`,label:`config.json / opencode.json(c)`,index:0,kind:`fileGroups`},{key:`oh-slim`,label:`oh-my-opencode-slim.json(c)`,index:1,kind:`fileGroups`},{key:`oh-agent`,label:`oh-my-openagent.json(c)`,index:2,kind:`fileGroups`},{key:`agents-md`,label:`AGENTS.md`,index:0,kind:`singleFiles`},{key:`cursor-models`,label:`cursor-models.json`,index:1,kind:`singleFiles`},{key:`agents`,label:`agents/`,index:0,kind:`directories`},{key:`commands`,label:`commands/`,index:1,kind:`directories`},{key:`skills`,label:`skills/`,index:2,kind:`directories`},{key:`plugins`,label:`plugins/`,index:5,kind:`directories`}].filter(e=>m!=null&&e.index<m[e.kind]).map(e=>{let t=f[e.kind][e.index]!==!1;return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)($t,{checked:t,disabled:M||!T,ariaLabel:e.label,onChange:t=>{if(!T)return;let n=[...f[e.kind]];n[e.index]=t;let r={...f,[e.kind]:n};p(r),c===`review`&&D(u,r)}}),(0,$.jsx)(`span`,{className:`font-mono`,children:e.label})]},e.key)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)($t,{checked:f.agentsRoot,disabled:M||!T,ariaLabel:a(`settings.remoteInstances.page.sync.section.agentsRoot`),onChange:e=>{if(!T)return;let t={...f,agentsRoot:e};p(t),c===`review`&&D(u,t)}}),a(`settings.remoteInstances.page.sync.section.agentsRoot`)]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)($t,{checked:f.authFile,disabled:M||!T,ariaLabel:a(`settings.remoteInstances.page.sync.section.authFile`),onChange:e=>{if(!T)return;let t={...f,authFile:e};p(t),c===`review`&&D(u,t)}}),a(`settings.remoteInstances.page.sync.section.authFile`)]})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:vu.map((e,t)=>{let n=t+1,r=R(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r===`done`?(0,$.jsx)(J,{name:`check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--status-success)]`}):r===`active`?(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-border/60 typography-micro text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:q(`typography-meta`,r===`pending`?`text-muted-foreground`:`text-foreground`),children:a(e)})]},e)})}),c===`error`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:a(`settings.remoteInstances.page.sync.state.error`,{message:b||``})}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:F,children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),a(`settings.remoteInstances.sidebar.actions.retry`)]})]}):null,N&&!j?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.state.empty`)}):null,N&&j&&A?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-[var(--surface-elevated)]`,children:(0,$.jsx)(br,{fillContainer:!1,disableHorizontal:!0,outerClassName:`max-h-80`,className:`max-h-80`,children:(0,$.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[A.files.map(e=>{let t=k.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(J,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.files`),`: `]}),e.path]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:mu(e.bytes)}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`file:${e.path}`)}),A.directories.map(e=>{let t=k.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(J,{name:`folder-3-fill`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.directories`),`: `]}),e.path]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[mu(e.bytes),` · `,e.fileCount]}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`dir:${e.path}`)}),A.authFile?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(J,{name:`shield-keyhole`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.local/share/opencode/auth.json`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.authFile`),`: `]}),`~/.local/share/opencode/auth.json`]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:mu(A.authFile.bytes)}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,v?.remoteAuthFileExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAuthFileExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null,A.agentsRoot?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(J,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.agents`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.agentsRoot`),`: `]}),`~/.agents`]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[mu(A.agentsRoot.bytes),` · `,a(`settings.remoteInstances.page.sync.section.agentsRootCount`,{count:A.agentsRoot.fileCount})]}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,v?.remoteAgentsRootExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAgentsRootExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null]})})}),(0,$.jsxs)(`div`,{className:`space-y-1 typography-micro text-muted-foreground`,children:[P>0?(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.deletes`,{count:P})}):null,(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.backup`)}),(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.excluded`)})]})]}):null,(0,$.jsxs)(Gt,{className:`shrink-0`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:()=>i(!1),disabled:M,children:a(`settings.remoteInstances.page.sync.actions.cancel`)}),(0,$.jsxs)(Y,{type:`button`,size:`sm`,className:`!font-normal`,onClick:()=>void L(),disabled:!j||M||c!==`review`,children:[(0,$.jsx)(J,{name:`refresh`,className:q(`h-3.5 w-3.5`,M?`animate-spin`:``)}),a(M?`settings.remoteInstances.page.sync.applying`:`settings.remoteInstances.page.sync.actions.syncNow`)]})]})]})})},bu=e=>{let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`address already in use`)||t.includes(`eaddrinuse`)||t.includes(`port already in use`)},xu=()=>{if(typeof navigator>`u`)return;let e=(navigator.userAgent||``).toLowerCase();if(e.includes(`mac`))return`macos`;if(e.includes(`win`))return`windows`;if(e.includes(`linux`))return`linux`},Su=e=>{switch((e||``).toLowerCase()){case`ios`:return`iOS`;case`android`:return`Android`;case`macos`:case`darwin`:return`macOS`;case`windows`:case`win32`:return`Windows`;case`linux`:return`Linux`;default:return null}},Cu=e=>{switch(e){case`config_resolved`:return`settings.remoteInstances.page.phase.resolvingConfiguration`;case`auth_check`:return`settings.remoteInstances.page.phase.checkingAuth`;case`master_connecting`:return`settings.remoteInstances.page.phase.establishingSsh`;case`remote_probe`:return`settings.remoteInstances.page.phase.probingRemote`;case`installing`:return`settings.remoteInstances.page.phase.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`}},wu=new Set([`config_resolved`,`auth_check`,`master_connecting`,`remote_probe`,`installing`,`updating`,`server_detecting`,`server_starting`,`forwarding`]),Tu=e=>!!(e&&wu.has(e)),Eu=e=>e===`ready`?`bg-[var(--status-success)] animate-pulse`:e===`error`?`bg-[var(--status-error)] animate-pulse`:e===`degraded`||Tu(e)?`bg-[var(--status-warning)] animate-pulse`:`bg-muted-foreground/40`,Du=e=>e.type===`dynamic`?`${e.localHost||`127.0.0.1`}:${e.localPort||0}`:e.type===`remote`?`${e.remoteHost||`127.0.0.1`}:${e.remotePort||0} -> ${e.localHost||`127.0.0.1`}:${e.localPort||0}`:`${e.localHost||`127.0.0.1`}:${e.localPort||0} -> ${e.remoteHost||`127.0.0.1`}:${e.remotePort||0}`,Ou=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:`local`,localHost:`127.0.0.1`,localPort:pu(),remoteHost:`127.0.0.1`,remotePort:80}),ku=e=>e.trim().replace(/\*/g,`host`).replace(/\?/g,`x`)||`user@host`,Au=e=>{let t=(0,Di.c)(10),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]!==a||t[1]!==r?(s=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:o}),t[3]=o,t[4]=c);let l;return t[5]!==i||t[6]!==n||t[7]!==s||t[8]!==c?(l=(0,$.jsx)(Z,{itemId:n,className:`oc-settings-detail-group`,label:s,description:i,children:c}),t[5]=i,t[6]=n,t[7]=s,t[8]=c,t[9]=l):l=t[9],l},ju=e=>{switch(e){case`remote`:return`settings.remoteInstances.page.forwardTypeDescription.remote`;case`dynamic`:return`settings.remoteInstances.page.forwardTypeDescription.dynamic`;default:return`settings.remoteInstances.page.forwardTypeDescription.local`}},Mu=(e,t)=>{let n=(e||``).trim();return`${!n||n===`127.0.0.1`||n===`::1`?`localhost`:n}:${t||0}`},Nu=e=>{let t=(e||``).trim();return!t||t===`0.0.0.0`||t===`::`?`127.0.0.1`:t},Pu=e=>{let t=e.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!t)return e;let n=Number(t[1]);return`[${Number.isFinite(n)?new Date(n).toISOString():t[1]}] [${(t[2]||`INFO`).toUpperCase()}] ${t[3]||``}`},Fu=()=>{if(typeof window>`u`)return null;let e=r()||window.location.href;try{let t=Number(new URL(e).port||window.location.port);return Number.isFinite(t)&&t>0?t:null}catch{let e=Number(window.location.port);return Number.isFinite(e)&&e>0?e:null}},Iu=e=>{try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}},Lu=async()=>{let e=se(r())||window.location.origin;if(!w()||!T())return e;let t;try{t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}})}catch{return e}if(!t.ok||(await t.json().catch(()=>null))?.desktopLanAccessActive!==!0)return e;let n=await C(),i=Fu();return!n||!i?e:`http://${n}:${i}`},Ru=e=>{let t=e.trim();if(t)try{window.location.assign(t)}catch{window.location.href=t}},zu=e=>{let t=e.sshCommand.trim(),n=e.nickname?.trim(),r=e.portForwards.map(e=>({...e,localHost:e.localHost?.trim()||`127.0.0.1`,localPort:typeof e.localPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localPort))):void 0,remoteHost:e.remoteHost?.trim(),remotePort:typeof e.remotePort==`number`?Math.max(1,Math.min(65535,Math.round(e.remotePort))):void 0}));return{...e,sshCommand:t,...n?{nickname:n}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(e.connectionTimeoutSec||60))),localForward:{...e.localForward,bindHost:e.localForward.bindHost===`localhost`||e.localForward.bindHost===`0.0.0.0`?e.localForward.bindHost:`127.0.0.1`,preferredLocalPort:typeof e.localForward.preferredLocalPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...e.remoteOpenchamber,preferredPort:typeof e.remoteOpenchamber.preferredPort==`number`?Math.max(1,Math.min(65535,Math.round(e.remoteOpenchamber.preferredPort))):void 0},portForwards:r}},Bu=()=>{let{t:e}=ke(),{clientAuth:t}=mr(),i=w(),o=Wr(e=>e.instances),c=Wr(e=>e.statusesById),l=Wr(e=>e.importCandidates),f=Wr(e=>e.isLoading),p=Wr(e=>e.isImportsLoading),m=Wr(e=>e.isSaving),h=Wr(e=>e.error),g=Wr(e=>e.load),_=Wr(e=>e.loadImports),v=Wr(e=>e.refreshStatuses),y=Wr(e=>e.upsertInstance),b=Wr(e=>e.createFromCommand),x=Wr(e=>e.removeInstance),S=Wr(e=>e.connect),C=Wr(e=>e.disconnect),T=Wr(e=>e.retry),E=u(e=>e.settingsRemoteInstancesSelectedId),D=u(e=>e.setSettingsRemoteInstancesSelectedId),O=Q.useMemo(()=>E&&o.find(e=>e.id===E)||null,[o,E]),[k,A]=Q.useState(null),[M,N]=Q.useState([]),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(null),[B,V]=Q.useState([]),[H,ee]=Q.useState(!1),[U,fe]=Q.useState(null),[pe,me]=Q.useState(`ssh`),[he,ge]=Q.useState(null),[_e,ve]=Q.useState(null),[ye,be]=Q.useState(``),[xe,Se]=Q.useState(!1),[Ce,we]=Q.useState({}),[Te,Ee]=Q.useState(!1),[De,Ae]=Q.useState(!1),[Me,Ne]=Q.useState(()=>Date.now()),[Pe,Fe]=Q.useState([]),[Ie,Le]=Q.useState({}),[Re,ze]=Q.useState(`local`),[Be,Ve]=Q.useState(!1),[He,Ue]=Q.useState(!1),[We,Ge]=Q.useState(0),Ke=xn(),[qe,Je]=Q.useState(``),[Ye,Xe]=Q.useState(null),[Ze,Qe]=Q.useState(!1),[$e,et]=Q.useState([]),[tt,G]=Q.useState([]),[nt,rt]=Q.useState(!1),[it,at]=Q.useState(``),[ot,st]=Q.useState(null),[ct,lt]=Q.useState(null),[ut,dt]=Q.useState(null),[ft,pt]=Q.useState(null),[mt,ht]=Q.useState(!1),[gt,_t]=Q.useState(!1),[vt,yt]=Q.useState(`configure`),[bt,xt]=Q.useState(!1),[St,Ct]=Q.useState(`relay`),[wt,Tt]=Q.useState(!0),[Et,Dt]=Q.useState(su),[Ot,kt]=Q.useState(null),[At,jt]=Q.useState(!1),Mt=Q.useRef(null),[Nt,Pt]=Q.useState(null),Ft=Q.useMemo(()=>$e.filter(e=>!!e.revokedAt).length,[$e]),[It,Lt]=Q.useState(!1),[Rt,zt]=Q.useState(`ssh user@example.com`),[Bt,Vt]=Q.useState(``);Q.useEffect(()=>{g(),_()},[g,_]);let Ht=Q.useCallback(async()=>{Ve(!0),Xe(null);try{let e=await ce();Fe(e.hosts||[]),ze(e.defaultHostId||`local`)}catch(e){Xe(e instanceof Error?e.message:String(e))}finally{Ve(!1)}},[]);Q.useEffect(()=>{Ht()},[Ht]);let Ut=Object.values(c).filter(e=>e.phase===`ready`).map(e=>`${e.id}:${e.localUrl||``}`).sort().join(`|`);Q.useEffect(()=>{Ut&&Ht()},[Ht,Ut]);let Xt=Q.useCallback(async(e,t=Re)=>{Ue(!0),Xe(null);try{await re({hosts:e,defaultHostId:t,initialHostChoiceCompleted:!0}),Fe(e),ze(t)}catch(e){Xe(e instanceof Error?e.message:String(e))}finally{Ue(!1)}},[Re]),Zt=Q.useMemo(()=>new Set(o.map(e=>e.id)),[o]),Qt=Q.useMemo(()=>Pe.filter(e=>ue(e,Zt)),[Pe,Zt]),tn=Oe(async()=>{let t=Vl(qe);if(!t){Xe(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let n=await te().catch(()=>``),r={method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({pairingId:t.pairingId,secret:t.secret,clientLabel:t.label||`OpenChamber Desktop`,clientKind:`desktop`,deviceName:`OpenChamber Desktop`,devicePlatform:xu(),...n?{dedupeKey:`desktop:${n}`}:{}})},i=async e=>{if(!e.ok)return null;let t=await e.json().catch(()=>null);return(typeof t?.clientToken==`string`?t.clientToken.trim():``)||null},a=[...t.candidates].sort((e,t)=>(e.type===`relay`)-+(t.type===`relay`)),o=null;for(let e of a){if(e.type===`relay`){let t=d({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...e.grant?{grant:e.grant}:{}});try{let n=await i(await t.fetch(`/api/client-auth/pairing/redeem`,r));if(n){o={kind:`relay`,relay:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk},token:n,tunnel:t},t.close();break}}catch{}t.close();continue}let t=se(e.url);if(t)try{let e=await i(await fetch(`${t}/api/client-auth/pairing/redeem`,r));if(e){o={kind:`direct`,url:t,token:e};break}}catch{}}if(!o){Xe(e(`desktopHostSwitcher.error.invalidUrl`));return}let s=()=>j(),c=t.candidates.find(e=>e.type===`relay`),l=o.kind===`relay`?o.relay:c?{relayUrl:c.relayUrl,serverId:c.serverId,hostEncPubJwk:c.hostEncPubJwk}:void 0,u=t.candidates.filter(e=>e.type!==`relay`),f=u.map(e=>se(e.url)).find(e=>!!e),p=u.filter(e=>e.type===`lan`).map(e=>se(e.url)).find(e=>!!e),m=o.kind===`direct`?o.url:p||f||null,{token:h}=o,g=m||(l?W(l.serverId):null);if(!g){Xe(e(`desktopHostSwitcher.error.invalidUrl`));return}let _={url:g,apiUrl:m||void 0,clientToken:h,source:le,...l?{relay:l}:{}},v=Pe.find(e=>l?e.relay?.serverId===l.serverId&&e.relay?.relayUrl===l.relayUrl:!e.relay&&se(e.apiUrl||e.url)===g);if(v){let e=Pe.map(e=>e.id===v.id?{...e,label:t.label||e.label,..._}:e);await Xt(e,Re)}else await Xt([{id:s(),label:t.label||ne(g),..._},...Pe],Re);Je(``),Xe(null),Qe(!1)}),an=Q.useCallback(async e=>{let t=Pe.filter(t=>t.id!==e);await Xt(t,Re===e?`local`:Re)},[Re,Pe,Xt]),sn=Q.useCallback(async()=>{let t=Rt.trim();if(!t){K.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}let n=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await b(n,t,Bt.trim()||void 0),D(n),Lt(!1),zt(`ssh user@example.com`),Vt(``),K.success(e(`settings.remoteInstances.page.toast.instanceCreated`))}catch(t){K.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)})}},[b,D,Rt,Bt,e]),cn=Q.useCallback(async e=>{await Xt(Pe,e)},[Pe,Xt]),mn=Oe(async e=>{if(de(e)||Ke)return;Xe(null);let t=await yn({host:e,cachedProbe:Ie[e.id]||null});Le(n=>({...n,[e.id]:t.status}))}),hn=Oe(async t=>{if(Ke)return;let n=t.nickname?.trim()||t.sshParsed?.destination||t.id,r=Pe;try{let e=await ce();r=e.hosts||[],Fe(r),ze(e.defaultHostId||`local`)}catch(t){K.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}),{description:t instanceof Error?t.message:String(t)});return}let i=r.find(e=>e.id===t.id)??null;if(!i||!ie(i)||!i.clientToken){K.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}));return}de(i)||await yn({host:i})});Q.useEffect(()=>{if(i)return n(()=>{Ge(e=>e+1)})},[i]),Q.useEffect(()=>{if(!i||Qt.length===0)return;let e=!1;return Promise.all(Qt.map(async e=>{let t=async()=>{let t=await ae(e.relay,{clientToken:e.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));return t.status===`ok`?{status:t.status,latencyMs:t.latencyMs,via:`relay`}:{status:t.status,latencyMs:t.latencyMs}};if(e.relay&&!e.apiUrl)return[e.id,await t()];let n=se(ie(e));if(!n)return[e.id,e.relay?await t():{status:`unreachable`,latencyMs:0}];let r=await oe(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(r.status===`unreachable`&&e.relay){let n=await t();if(n.status===`ok`)return[e.id,n]}return[e.id,r]})).then(t=>{e||Le(Object.fromEntries(t))}),()=>{e=!0}},[Qt,i]);let gn=Q.useCallback(async e=>{if(t){e?.silent||rt(!0),e?.silent||st(null);try{let[e,n]=await Promise.all([t.listClients(),t.listPendingPairings().catch(()=>null)]);et(e),n&&G(n)}catch(t){e?.silent||st(t instanceof Error?t.message:String(t))}finally{e?.silent||rt(!1)}}},[t]),_n=Q.useRef(!1);Q.useEffect(()=>{if(!(!gt||vt!==`result`||!ut)){if(tt.some(e=>e.id===ut)){_n.current=!0;return}_n.current&&(dt(null),_t(!1),$e.some(e=>e.pairingId===ut)&&K.success(e(`settings.remoteInstances.clientAuth.addDevice.connectedToast`)))}},[gt,vt,ut,tt,$e,e]);let vn=Q.useCallback(async e=>{if(t)try{await t.cancelPairing(e),G(t=>t.filter(t=>t.id!==e)),await gn({silent:!0})}catch(e){st(e instanceof Error?e.message:String(e))}},[t,gn]);Q.useEffect(()=>{if(!t)return;gn();let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||gn({silent:!0})},5e3);return()=>window.clearInterval(e)},[t,gn]);let bn=Q.useCallback(async()=>{let e=a()!==`local`;if(t?.getPairingTransports)try{let n=await t.getPairingTransports(),r=lu(n.relayUrl),i=Array.from(new Set([...Array.isArray(n.relayUrls)?n.relayUrls:[],...r?[r]:[]].map(e=>lu(e)).filter(e=>!!e)));return{localUrl:n.local,lanUrl:n.lan,relayAvailable:n.relayAvailable,relayUrl:r,relayUrls:n.relayAvailable?i:[],relayUrlLocked:n.relayUrlLocked===!0,remoteHost:e}}catch{}let n=Fu(),r=n?`http://127.0.0.1:${n}`:Iu(window.location.origin)?window.location.origin:null,i=null;try{let e=se(await Lu());i=e&&!Iu(e)?e:null}catch{}return{localUrl:r,lanUrl:i,relayAvailable:!1,relayUrl:null,relayUrls:[],relayUrlLocked:!1,remoteHost:e}},[t]),Sn=Oe(async()=>{st(null),lt(null),pt(null),ht(!1),dt(null),kt(null),yt(`configure`),Tt(!0),_t(!0);let e=await bn();Pt(e),jt(!1);let t=e.remoteHost?null:uu();Dt((e.relayUrlLocked||e.remoteHost?e.relayUrl:t||e.relayUrl)||`wss://relay.openchamber.dev/ws`),Ct(e.relayAvailable?`relay`:e.lanUrl?`lan`:`local`)}),Cn=Oe(async()=>{if(!(!t?.createPairingSession||!Nt)){st(null),xt(!0);try{let n=it.trim()||void 0,r,i,a=!0;St===`local`?(r=Nt.localUrl??void 0,i=!1):St===`lan`?(r=Nt.lanUrl??void 0,i=wt):wt&&Nt.lanUrl?(r=Nt.lanUrl,i=!0):(a=!1,i=!0),Nt.relayAvailable||(i=!1);let o=i?lu(Et):null;if(i&&!o){kt(e(`settings.remoteInstances.clientAuth.addDevice.relayUrlInvalid`)),Mt.current?.focus();return}kt(null);let{pairing:s,server:c}=await t.createPairingSession({label:n,allowedClientKinds:[`mobile`,`desktop`],serverUrl:r,includeRelay:i,includeDirect:a,...o?{relayUrl:o}:{}}),l=Rl({pairingId:s.id,secret:s.secret,label:n||c.label,fingerprint:s.fingerprint??void 0,expiresAt:s.expiresAt,candidates:c.candidates}),u=l.candidates.find(e=>e.type===`relay`);u&&(Dt(u.relayUrl),Nt?.remoteHost!==!0&&du(u.relayUrl));let d=zl(l);lt(d),pt(await El.toDataURL(d,{width:1024,margin:2,errorCorrectionLevel:`L`})),ht(!1),_n.current=!1,dt(s.id),yt(`result`),await gn({silent:!0})}catch(e){st(e instanceof Error?e.message:String(e))}finally{xt(!1)}}}),wn=Q.useCallback(()=>{ct&&je(ct).then(e=>{e.ok&&(ht(!0),window.setTimeout(()=>ht(!1),2e3))})},[ct]),En=Q.useCallback(async e=>{if(!t)return;let n=e.clientKind===`desktop-local`;st(null);try{if(await t.revokeClient(e.id),n&&w()){let t=await ce();await re({hosts:t.hosts,defaultHostId:t.defaultHostId,initialHostChoiceCompleted:t.initialHostChoiceCompleted,localClientToken:null}),et(t=>t.map(t=>t.id===e.id?{...t,revokedAt:new Date().toISOString()}:t)),s({apiBaseUrl:r(),clientToken:null,runtimeKey:`local`});return}await gn()}catch(e){st(e instanceof Error?e.message:String(e))}},[t,gn]),On=Q.useCallback(async()=>{if(t){st(null);try{await t.purgeRevokedClients(),await gn()}catch(e){st(e instanceof Error?e.message:String(e))}}},[t,gn]);Q.useEffect(()=>{A(O)},[O]),Q.useEffect(()=>{let e=!1;return!E||O?.remoteOpenchamber?.mode!==`managed`?(N([]),()=>{e=!0}):(Dn(E).then(t=>{e||N(t.slice(-5).reverse())}).catch(()=>{e||N([])}),()=>{e=!0})},[E,O?.remoteOpenchamber?.mode,H]),Q.useEffect(()=>{if(!E)return;let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||v()},2e3);return()=>{window.clearInterval(e)}},[v,E]),Q.useEffect(()=>{let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=1e3&&(Ne(r),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[]);let kn=E?c[E]:null,An=kn?.phase,jn=An===`ready`,Mn=An===`degraded`,Nn=Tu(An),Fn=jn||Nn||Mn,In=kn?Math.max(0,Me-kn.updatedAtMs):0,X=Mn&&In>12e3,Ln=Q.useMemo(()=>!k||!O?!1:JSON.stringify(k)!==JSON.stringify(O),[k,O]),Rn=Q.useCallback(e=>{A(t=>t&&e(t))},[]),zn=Q.useCallback(async()=>{if(!k)return;let t=zu(k);if(!t.sshCommand.trim()){K.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}if(!(t.localForward.bindHost===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`)))){if(t.auth.sshPassword?.enabled&&t.auth.sshPassword.value?.trim()&&t.auth.sshPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeSshPasswordPlaintext`));t.auth.sshPassword.store=n?`settings`:`never`,n||(t.auth.sshPassword.value=void 0)}if(t.auth.openchamberPassword?.enabled&&t.auth.openchamberPassword.value?.trim()&&t.auth.openchamberPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeUiPasswordPlaintext`));t.auth.openchamberPassword.store=n?`settings`:`never`,n||(t.auth.openchamberPassword.value=void 0)}try{await y(t),K.success(e(`settings.remoteInstances.page.toast.instanceSaved`))}catch(t){K.error(e(`settings.remoteInstances.page.toast.saveFailed`),{description:t instanceof Error?t.message:String(t)})}}},[k,e,y]),Bn=Q.useCallback(async(t,n)=>{let r=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await b(r,`ssh ${n}`,t),D(r),K.success(e(`settings.remoteInstances.page.toast.instanceCreated`)),!0}catch(t){return K.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)}),!1}},[b,D,e]),Vn=Q.useCallback(()=>{xe||(ve(null),be(``))},[xe]),Un=Q.useCallback((e,t)=>{if(t){ve(e),be(ku(e));return}Bn(e,e)},[Bn]),Wn=Q.useCallback(async()=>{let t=_e,n=ye.trim();if(t){if(!n){K.error(e(`settings.remoteInstances.page.toast.destinationRequired`));return}Se(!0);try{await Bn(t,n)&&(ve(null),be(``))}finally{Se(!1)}}},[Bn,ye,_e,e]),Gn=Q.useCallback(async()=>{if(O)try{await S(O.id);return}catch(t){if(!bu(t)||!window.confirm(e(`settings.remoteInstances.sidebar.confirm.localPortInUseRetry`)))throw t;let n={...O,localForward:{...O.localForward,preferredLocalPort:pu()}};await y(n),await S(n.id),K.success(e(`settings.remoteInstances.sidebar.toast.retriedWithRandomPort`))}},[S,O,e,y]),Kn=Q.useCallback(async e=>(await Tn(e,600)).map(e=>Pu(e)),[]),Jn=Q.useCallback(async()=>{if(k){F(!0),L(!0),z(null);try{let e=await Kn(k.id);V(e)}catch(e){V([]),z(e instanceof Error?e.message:String(e))}finally{L(!1)}}},[k,Kn]);Q.useEffect(()=>{if(!P||!k)return;let e=!1,t=async()=>{try{let t=await Kn(k.id);e||(V(t),z(null))}catch(t){e||z(t instanceof Error?t.message:String(t))}};t();let n=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||t()},1e3);return()=>{e=!0,window.clearInterval(n)}},[k,P,Kn]);let Yn=Q.useMemo(()=>B.join(`
|
|
23
|
+
`),[B]),Xn=Q.useCallback(()=>{if(!Yn.trim()){K.error(e(`settings.remoteInstances.page.toast.noLogsToCopy`));return}je(Yn).then(t=>{t.ok&&K.success(e(`settings.remoteInstances.page.toast.logsCopied`))})},[Yn,e]),Qn=Q.useCallback(async()=>{if(k)try{await qn(k.id),V([]),K.success(e(`settings.remoteInstances.page.toast.logsCleared`))}catch(t){K.error(e(`settings.remoteInstances.page.toast.clearLogsFailed`),{description:t instanceof Error?t.message:String(t)})}},[k,e]),$n=Q.useCallback(async()=>{if(!kn?.localUrl){K.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}let t=kn.localUrl.trim();if(!t){K.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}Ru(t)},[kn?.localUrl,e]),er=Q.useCallback((e,t=`ssh`,n=null)=>{fe(e),me(t),ge(n),ee(!0)},[]),tr=Q.useCallback(()=>{if(!k)return;let t=Fn,n=k.id;Ee(!0),(t?C(n):Gn()).catch(n=>{let r=t?jn?`settings.remoteInstances.page.toast.disconnectFailed`:`settings.remoteInstances.page.toast.cancelConnectionFailed`:`settings.remoteInstances.page.toast.connectFailed`,i=kn?.detail||(n instanceof Error?n.message:String(n)),a=ar(kn?.errorCode,i);K.error(e(r),{description:t?n instanceof Error?n.message:String(n):Pn(e(lr(a)),a,i)})}).finally(()=>{Ee(!1)})},[Fn,Gn,C,k,jn,kn,e]),nr=Q.useCallback(()=>{k&&(Nn||(Ae(!0),(Mn?C(k.id).then(()=>Gn()):T(k.id)).catch(t=>{let n=kn?.detail||(t instanceof Error?t.message:String(t)),r=ar(kn?.errorCode,n);K.error(e(`settings.remoteInstances.page.toast.retryFailed`),{description:Pn(e(lr(r)),r,n)})}).finally(()=>{Ae(!1)})))},[Gn,C,k,Nn,Mn,T,kn,e]),rr=e(Nn?`settings.remoteInstances.page.actions.connecting`:Mn?X?`settings.remoteInstances.page.actions.reconnectNow`:`settings.remoteInstances.page.actions.reconnecting`:`settings.remoteInstances.sidebar.actions.retry`),ir=!Te&&!De&&(An===`error`||An===`idle`||!An||Mn&&X)&&!Nn,or=e(jn?`settings.remoteInstances.sidebar.actions.disconnect`:Fn?`settings.remoteInstances.page.actions.cancel`:`settings.remoteInstances.sidebar.actions.connect`);if(!k)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(pc,{children:[t?(0,$.jsx)(Au,{itemId:`remote-instances.client-auth`,label:e(`settings.remoteInstances.clientAuth.title`),description:e(`settings.remoteInstances.clientAuth.description`),children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void Sn(),children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.clientAuth.actions.addDevice`)]})}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Ft>0?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void On(),children:e(`settings.remoteInstances.clientAuth.actions.clearRevoked`)})}):null,nt&&$e.length===0&&tt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.loading`)}):$e.length===0&&tt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.empty`)}):(0,$.jsxs)($.Fragment,{children:[tt.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label||e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`)}),t.usesRelay?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.viaRelay`)}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:e(`settings.remoteInstances.clientAuth.state.pending`)})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void vn(t.id),children:e(`settings.common.actions.cancel`)})]},`pending-${t.id}`)),$e.map(t=>{let n=t.clientKind===`desktop-local`,r=t.lastUsedAt?Date.parse(t.lastUsedAt):NaN,i=!t.revokedAt&&(n||Number.isFinite(r)&&Date.now()-r<9e4),a=t.revokedAt?e(`settings.remoteInstances.clientAuth.state.revoked`):i?t.lastTransport===`relay`&&!n?e(`settings.remoteInstances.clientAuth.state.connectedRelay`):e(`settings.remoteInstances.clientAuth.state.connectedDirect`):t.lastUsedAt?e(`settings.remoteInstances.clientAuth.lastUsed`,{date:t.lastUsedAt}):e(`settings.remoteInstances.clientAuth.neverUsed`);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:q(`h-2 w-2 shrink-0 rounded-full`,t.revokedAt?`bg-muted-foreground/20`:i?`bg-[var(--status-success)]`:`bg-muted-foreground/30`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label}),Su(t.devicePlatform)?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:Su(t.devicePlatform)}):null,n?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.thisDevice`)}):null]}),(0,$.jsx)(`p`,{className:q(`typography-micro truncate`,i&&!t.revokedAt?`text-[var(--status-success)]`:`text-muted-foreground`),children:a})]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void En(t),disabled:!!t.revokedAt,children:e(`settings.remoteInstances.clientAuth.actions.revoke`)})]},t.id)})]})]}),ot?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:ot}):null]})}):null,i?(0,$.jsx)(Au,{itemId:`remote-instances.instances`,label:e(`settings.remoteInstances.sidebar.title`),description:e(`settings.remoteInstances.sidebar.description`),action:(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>Qe(!0),disabled:He,children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsxs)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>Lt(!0),children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})]}),children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Be||f?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.direct.state.loading`)}):Qt.length===0&&o.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.sidebar.empty`)}):(0,$.jsxs)($.Fragment,{children:[Qt.map(t=>{let n=Ie[t.id],r=n?n.status===`ok`?`desktopHostSwitcher.status.connected`:n.status===`auth`?`desktopHostSwitcher.status.authRequired`:n.status===`update-recommended`?`desktopHostSwitcher.status.updateRecommended`:n.status===`incompatible`?`desktopHostSwitcher.status.incompatible`:n.status===`wrong-service`?`desktopHostSwitcher.status.wrongService`:`desktopHostSwitcher.status.unreachable`:`desktopHostSwitcher.status.checking`,i=n?.status===`ok`,a=de(t),o=a||Ke||He;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:q(`h-2 w-2 shrink-0 rounded-full`,n?i||a?`bg-[var(--status-success)]`:`bg-[var(--status-error)]`:`bg-muted-foreground/30 animate-pulse`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:ne(t.label)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.channel.link`)}),a?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null,Re===t.id?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.default`)}):null,(0,$.jsxs)(`span`,{className:q(`typography-micro shrink-0`,i||a?`text-[var(--status-success)]`:`text-muted-foreground`),children:[e(r),i&&typeof n?.latencyMs==`number`?e(`desktopHostSwitcher.status.ping`,{ms:Math.max(0,Math.round(n.latencyMs))}):``]})]}),(0,$.jsx)(`p`,{className:q(`typography-micro text-muted-foreground truncate`,t.apiUrl&&`font-mono`),children:t.relay&&!t.apiUrl?e(`mobile.connect.relay.badge`):ne(t.apiUrl||t.url)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void mn(t),disabled:o,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:ne(t.label)}),children:[(0,$.jsx)(J,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(a?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void cn(t.id),disabled:He||Re===t.id,"aria-label":e(`desktopHostSwitcher.actions.setAsDefaultAria`),children:Re===t.id?(0,$.jsx)(J,{name:`star-fill`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`star`,className:`h-3.5 w-3.5`})}),(()=>{let n=ie(t),r=!!n&&!n.startsWith(`relay://`)&&!t.relay;return t.relay?.serverId&&t.relay?.relayUrl&&t.relay?.hostEncPubJwk&&t.clientToken&&t.relay?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>er(t.id,`relay`,t),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):r?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>er(t.id,`direct`),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):null})(),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void an(t.id),disabled:He||Ke,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.delete`)]})]})]},`link:${t.id}`)}),o.map(t=>{let n=c[t.id],r=t.nickname?.trim()||t.sshParsed?.destination||t.id,i=n?.phase,a=i===`ready`,o=Pe.find(e=>e.id===t.id),s=de({id:t.id,label:r,url:n?.localUrl||o?.url||``}),l=(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void hn(t),disabled:s||Ke||!a,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:r}),children:[(0,$.jsx)(J,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(s?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]});return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${Eu(i)}`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:r}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.channel.ssh`)}),s?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null]}),(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:[e(Cu(i)),n?.localUrl?` · ${n.localUrl}`:``]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>{(a?C(t.id):S(t.id)).catch(t=>{let r=n?.detail||(t instanceof Error?t.message:String(t)),i=ar(n?.errorCode,r);K.error(e(a?`settings.remoteInstances.sidebar.toast.disconnectFailed`:`settings.remoteInstances.sidebar.toast.connectFailed`),{description:a?t instanceof Error?t.message:String(t):Pn(e(lr(i)),i,r)})})},children:[a?(0,$.jsx)(J,{name:`stop`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`plug-2`,className:`h-3.5 w-3.5`}),e(a?`settings.remoteInstances.sidebar.actions.disconnect`:`settings.remoteInstances.sidebar.actions.connect`)]}),a?l:(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:l})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.switchInstanceDisabled`)})]}),a&&t.remoteOpenchamber?.mode!==`external`?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>er(t.id),children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]}):(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,disabled:!0,"aria-label":e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`),children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]})})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`)})]}),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>D(t.id),children:[(0,$.jsx)(J,{name:`pencil`,className:`h-3.5 w-3.5`}),e(`desktopHostSwitcher.actions.edit`)]})]})]},`ssh:${t.id}`)})]}),Ye?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:Ye}):null]})}):null,i?(0,$.jsx)(Yt,{open:Ze,onOpenChange:Qe,children:(0,$.jsxs)(Kt,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsx)(Jt,{children:e(`settings.remoteInstances.direct.import.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),tn()},children:[(0,$.jsx)(un,{className:`h-8`,value:qe,onChange:e=>Je(e.target.value),placeholder:e(`settings.remoteInstances.direct.import.placeholder`),disabled:He,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Qe(!1),disabled:He,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:He||!qe.trim(),children:e(`settings.remoteInstances.direct.import.action`)})]})]})]})}):null,(0,$.jsx)(Yt,{open:gt,onOpenChange:_t,children:(0,$.jsxs)(Kt,{className:vt===`result`?`sm:max-w-lg`:`sm:max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(vt===`result`?`settings.remoteInstances.clientAuth.qrDialogTitle`:`settings.remoteInstances.clientAuth.actions.addDevice`)}),(0,$.jsx)(Jt,{children:e(vt===`result`?`settings.remoteInstances.clientAuth.qrScanHint`:`settings.remoteInstances.clientAuth.addDevice.subtitle`)})]}),vt===`configure`?(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Cn()},children:[(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(un,{className:`h-8`,value:it,onChange:e=>at(e.target.value),placeholder:e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`),"aria-describedby":`add-device-instance-name-hint`,autoFocus:!0}),(0,$.jsx)(`span`,{id:`add-device-instance-name-hint`,className:`block typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.field.labelHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`)}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`),className:`space-y-1.5`,children:[{key:`relay`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.relay`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.relayHint`),available:!!Nt?.relayAvailable},{key:`lan`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.lan`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.lanHint`),available:!!Nt?.lanUrl},{key:`local`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.local`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.localHint`),available:!!Nt?.localUrl}].map(e=>{let t=St===e.key;return(0,$.jsxs)(`div`,{className:q(`flex items-start gap-2 py-0.5`,e.available?`cursor-pointer`:`opacity-45`),onClick:()=>{e.available&&Ct(e.key)},role:`presentation`,children:[(0,$.jsx)(Zn,{checked:t,disabled:!e.available,onChange:()=>Ct(e.key),ariaLabel:e.label,className:`mt-0.5`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/70`),children:e.label}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e.hint})]})]},e.key)})}),St===`lan`?(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 pt-1`,children:[(0,$.jsx)($t,{checked:wt,onChange:Tt,ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)})]}):null,St===`relay`&&Nt?.lanUrl?(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 pt-1`,children:[(0,$.jsx)($t,{checked:wt,onChange:Tt,ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)})]}):null,St===`relay`||St===`lan`&&wt?(()=>{let t=Array.from(new Set([...Nt?.relayUrls??[],...Nt?.relayUrl?[Nt.relayUrl]:[]])),n=t.length>1,r=Nt?.relayUrlLocked!==!0&&Nt?.remoteHost!==!0,i=n&&!At;return(0,$.jsxs)(`label`,{className:`block space-y-1.5 pt-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`)}),i?(0,$.jsxs)(on,{value:t.includes(Et)?Et:t[0],onValueChange:e=>{if(e===`__custom__`){jt(!0);return}Dt(e),kt(null)},children:[(0,$.jsx)(nn,{className:`h-8 w-full font-mono`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`),children:(0,$.jsx)(ln,{})}),(0,$.jsxs)(rn,{children:[t.map(e=>(0,$.jsx)(en,{value:e,className:`font-mono`,children:(0,$.jsx)(`span`,{className:`block max-w-[420px] truncate`,children:e})},e)),r?(0,$.jsx)(en,{value:`__custom__`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlCustomOption`)}):null]})]}):(0,$.jsx)(un,{ref:Mt,className:`h-8 font-mono`,value:Et,onChange:e=>{Dt(e.target.value),kt(null)},placeholder:su,readOnly:Nt?.relayUrlLocked===!0||Nt?.remoteHost===!0,"aria-readonly":Nt?.relayUrlLocked===!0||Nt?.remoteHost===!0||void 0,"aria-invalid":!!Ot||void 0,"aria-describedby":Ot?`add-device-relay-url-hint add-device-relay-url-error`:`add-device-relay-url-hint`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`}),(0,$.jsx)(`span`,{id:`add-device-relay-url-hint`,className:`block typography-meta text-muted-foreground`,children:Nt?.relayUrlLocked?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLockedHint`):Nt?.remoteHost?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlRemoteHostHint`):(0,$.jsxs)($.Fragment,{children:[e(`settings.remoteInstances.clientAuth.addDevice.relayUrlHint`),` `,(0,$.jsx)(`a`,{href:fu,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,onClick:e=>{e.preventDefault(),Sr(fu)},children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlDeployLink`)})]})}),Ot?(0,$.jsx)(`span`,{id:`add-device-relay-url-error`,role:`alert`,"aria-live":`polite`,className:`block typography-meta text-[var(--status-error)]`,children:Ot}):null]})})():null]}),ot?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:ot}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>_t(!1),disabled:bt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:bt||!Nt,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[ft?(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(`img`,{src:ft,alt:e(`settings.remoteInstances.clientAuth.qrAlt`),className:`w-full max-w-[420px] rounded-md bg-white p-4`})}):null,ct?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate typography-code text-muted-foreground`,children:ct}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,onClick:wn,children:[(0,$.jsx)(J,{name:mt?`check`:`file-copy`,className:q(`h-3.5 w-3.5`,mt&&`text-[var(--status-success)]`)}),e(mt?`settings.remoteInstances.clientAuth.actions.copied`:`settings.common.actions.copyAll`)]})]}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>_t(!1),children:e(`settings.remoteInstances.clientAuth.addDevice.done`)})})]})]})}),i?(0,$.jsx)(Yt,{open:It,onOpenChange:Lt,children:(0,$.jsxs)(Kt,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.remoteInstances.sidebar.actions.addSshInstance`)}),(0,$.jsx)(Jt,{children:e(`settings.remoteInstances.page.section.instanceDescription`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),sn()},children:[(0,$.jsx)(un,{className:`h-8`,value:Bt,onChange:e=>Vt(e.target.value),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`),disabled:m}),(0,$.jsx)(un,{className:`h-8`,value:Rt,onChange:e=>zt(e.target.value),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`),disabled:m,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Lt(!1),disabled:m,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:m||!Rt.trim(),children:e(`settings.common.actions.create`)})]})]})]})}):null,i?(0,$.jsx)(Au,{label:e(`settings.remoteInstances.page.import.sectionTitle`),children:p?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.import.loading`)}):l.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.import.noneFound`)}):(0,$.jsx)(`div`,{children:l.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-3 last:border-b-0`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:[t.host,t.pattern?` ${e(`settings.remoteInstances.page.import.patternSuffix`)}`:``]}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:t.sshCommand})]}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Un(t.host,t.pattern),children:e(`settings.common.actions.import`)})]},`${t.source}:${t.host}`))})}):null,(0,$.jsx)(Yt,{open:!!_e,onOpenChange:e=>{e||Vn()},children:(0,$.jsxs)(Kt,{className:`sm:max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(Jt,{children:_e?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:_e}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Wn()},children:[(0,$.jsx)(un,{value:ye,onChange:e=>be(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Vn,disabled:xe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:xe,children:e(`settings.remoteInstances.page.actions.create`)})]})]})]})})]}),(0,$.jsx)(yu,{open:H,instanceId:U,targetKind:pe,relayHost:he,onOpenChange:e=>{ee(e),e||(fe(null),me(`ssh`),ge(null))}})]});let sr=k.remoteOpenchamber.mode===`managed`,cr=k.nickname?.trim()||k.sshParsed?.destination||k.id;return(0,$.jsx)(Yt,{open:!!k,onOpenChange:e=>{e||D(null)},children:(0,$.jsxs)(Kt,{className:`oc-settings-workspace oc-settings-workspace-desktop oc-settings-section-stack sm:max-w-4xl max-h-[90vh] overflow-auto`,children:[(0,$.jsxs)(Wt,{className:`gap-1 pr-8`,children:[(0,$.jsx)(qt,{className:`truncate`,children:cr}),(0,$.jsxs)(Jt,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full ${Eu(An)}`}),(0,$.jsx)(`span`,{children:e(Cu(An))}),kn?.localUrl?(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`,children:kn.localUrl}):null,X?(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.status.reconnectStale`)}):null]})]}),An===`error`?(0,$.jsx)(Hn,{errorCode:kn?.errorCode,detail:kn?.detail}):null,(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.actions`),children:[(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Y,{type:`button`,variant:Fn?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:tr,disabled:Te||De,children:[Fn?(0,$.jsx)(J,{name:`stop`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`plug-2`,className:`h-3.5 w-3.5`}),or]}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:nr,disabled:!ir,children:[(0,$.jsx)(J,{name:`refresh`,className:`h-3.5 w-3.5 ${Nn||Mn&&!X?`animate-spin`:``}`}),rr]}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{Jn()},children:[(0,$.jsx)(J,{name:`terminal-window`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.logs`)]}),(0,$.jsxs)(Y,{type:`button`,variant:`destructive`,size:`xs`,className:`!font-normal`,onClick:()=>{window.confirm(e(`settings.remoteInstances.page.confirm.removeInstance`))&&x(k.id).then(()=>{D(null),K.success(e(`settings.remoteInstances.page.toast.instanceRemoved`))}).catch(t=>{K.error(e(`settings.remoteInstances.page.toast.removeInstanceFailed`),{description:t instanceof Error?t.message:String(t)})})},children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.remove`)]})]}),kn?.localUrl?(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.status.currentLocalUrl`),children:(0,$.jsx)(`span`,{className:`font-mono text-foreground/90`,children:kn.localUrl})}):null]}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.instance`),children:[(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.sshCommand`),className:`oc-settings-ssh-command-row`,children:(0,$.jsx)(un,{value:k.sshCommand,onChange:e=>Rn(t=>({...t,sshCommand:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`)})}),(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.nickname`),children:(0,$.jsx)(un,{value:k.nickname||``,onChange:e=>Rn(t=>({...t,nickname:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`)})}),(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.connectionTimeoutSeconds`),children:(0,$.jsx)(Br,{min:5,max:240,step:1,className:`tabular-nums`,value:k.connectionTimeoutSec,onValueChange:e=>{Rn(t=>({...t,connectionTimeoutSec:Number.isFinite(e)?e:t.connectionTimeoutSec}))}})})]}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.remoteServer`),children:[(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.mode`),children:(0,$.jsxs)(on,{value:k.remoteOpenchamber.mode,onValueChange:e=>Rn(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,mode:e===`external`?`external`:`managed`}})),children:[(0,$.jsx)(nn,{children:(0,$.jsx)(ln,{placeholder:e(`settings.remoteInstances.page.field.modePlaceholder`)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`managed`,children:e(`settings.remoteInstances.page.field.modeManaged`)}),(0,$.jsx)(en,{value:`external`,children:e(`settings.remoteInstances.page.field.modeExternal`)})]})]})}),(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.preferredRemotePort`),children:(0,$.jsx)(Br,{min:1,max:65535,step:1,className:`tabular-nums`,value:k.remoteOpenchamber.preferredPort,onValueChange:e=>{Rn(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,preferredPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{Rn(e=>({...e,remoteOpenchamber:{...e.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})}),sr?(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.installMethod`),children:(0,$.jsxs)(on,{value:k.remoteOpenchamber.installMethod,onValueChange:e=>Rn(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,installMethod:e===`npm`||e===`download_release`||e===`upload_bundle`?e:`bun`}})),children:[(0,$.jsx)(nn,{children:(0,$.jsx)(ln,{placeholder:e(`settings.remoteInstances.page.field.selectInstallMethodPlaceholder`)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`bun`,children:`bun`}),(0,$.jsx)(en,{value:`npm`,children:`npm`}),(0,$.jsx)(en,{value:`download_release`,children:e(`settings.remoteInstances.page.field.installMethodDownloadRelease`)}),(0,$.jsx)(en,{value:`upload_bundle`,children:e(`settings.remoteInstances.page.field.installMethodUploadBundle`)})]})]})}):null,sr?(0,$.jsx)(Hr,{checked:k.remoteOpenchamber.keepRunning,onChange:e=>Rn(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,keepRunning:e}})),label:e(`settings.remoteInstances.page.field.keepServerRunning`),ariaLabel:e(`settings.remoteInstances.page.field.keepServerRunning`)}):null]}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.mainTunnel`),children:[(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.bindHost`),children:(0,$.jsxs)(on,{value:k.localForward.bindHost,onValueChange:t=>{t===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`))||Rn(e=>({...e,localForward:{...e.localForward,bindHost:t===`localhost`||t===`0.0.0.0`?t:`127.0.0.1`}}))},children:[(0,$.jsx)(nn,{children:(0,$.jsx)(ln,{placeholder:e(`settings.remoteInstances.page.field.selectBindHostPlaceholder`)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`127.0.0.1`,children:`127.0.0.1`}),(0,$.jsx)(en,{value:`localhost`,children:`localhost`}),(0,$.jsx)(en,{value:`0.0.0.0`,children:`0.0.0.0`})]})]})}),(0,$.jsxs)(Ir,{label:e(`settings.remoteInstances.page.field.preferredLocalPort`),children:[(0,$.jsx)(Br,{min:1,max:65535,step:1,className:`tabular-nums`,value:k.localForward.preferredLocalPort,onValueChange:e=>{Rn(t=>({...t,localForward:{...t.localForward,preferredLocalPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{Rn(e=>({...e,localForward:{...e.localForward,preferredLocalPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,"aria-label":e(`settings.remoteInstances.page.actions.pickRandomPort`),onClick:()=>Rn(e=>({...e,localForward:{...e.localForward,preferredLocalPort:pu()}})),children:(0,$.jsx)(J,{name:`shuffle`,className:`size-4`})})]})]}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.authentication`),children:[(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.sshPasswordOptional`),children:(0,$.jsx)(un,{type:`password`,value:k.auth.sshPassword?.value||``,onChange:e=>Rn(t=>({...t,auth:{...t.auth,sshPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.sshPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.sshPasswordPlaceholder`)})}),(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.uiPasswordOptional`),children:(0,$.jsx)(un,{type:`password`,value:k.auth.openchamberPassword?.value||``,onChange:e=>Rn(t=>({...t,auth:{...t.auth,openchamberPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.openchamberPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.uiPasswordPlaceholder`)})})]}),sr?(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.sync.runs.title`),children:M.length===0?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.sync.runs.empty`)}):M.map(t=>(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(`span`,{className:q(`shrink-0`,t.result===`success`?`text-[var(--status-success)]`:`text-[var(--status-error)]`),children:t.result===`success`?e(`settings.remoteInstances.page.sync.runs.result.success`):e(`settings.remoteInstances.page.sync.runs.result.failure`)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:[t.direction===`pull`?e(`settings.remoteInstances.page.sync.direction.pull`):e(`settings.remoteInstances.page.sync.direction.push`),t.endedAt?` · ${t.endedAt}`:``]})]},t.syncRunId))}):null,(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.section.portForwards`),children:[k.portForwards.length===0?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.empty.noExtraForwards`)}):null,k.portForwards.map((t,n)=>{let r=e=>{Rn(t=>({...t,portForwards:t.portForwards.map((t,r)=>r===n?e(t):t)}))},i=t.type===`remote`?e(`settings.remoteInstances.page.field.localTarget`):e(`settings.remoteInstances.page.field.localListen`),a=t.type===`remote`?e(`settings.remoteInstances.page.field.remoteListen`):e(`settings.remoteInstances.page.field.remoteTarget`),o=Mu(t.localHost||`localhost`,t.localPort),s=Mu(t.remoteHost||`localhost`,t.remotePort),c=t.type===`local`&&typeof t.localPort==`number`&&t.localPort>0,l=c?`http://${Nu(t.localHost)}:${t.localPort}`:``,u=!!Ce[t.id],d=t.type===`local`?e(`settings.remoteInstances.page.forwardType.local`):t.type===`remote`?e(`settings.remoteInstances.page.forwardType.remote`):e(`settings.remoteInstances.page.forwardType.dynamic`);return(0,$.jsxs)(Ci,{open:u,onOpenChange:e=>{we(n=>({...n,[t.id]:e}))},className:`oc-settings-group-row`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex items-center gap-2`,children:(0,$.jsxs)(Si,{className:`flex items-center gap-2 group`,children:[(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground transition-transform ${u?`rotate-180`:``}`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:Du(t)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 shrink-0`,children:d})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)($t,{checked:t.enabled,onChange:e=>r(t=>({...t,enabled:e})),ariaLabel:e(`settings.remoteInstances.page.actions.enableForwardAria`)}),(0,$.jsx)(Y,{type:`button`,variant:`destructive`,size:`icon`,"aria-label":e(`settings.remoteInstances.sidebar.actions.remove`),onClick:()=>Rn(e=>({...e,portForwards:e.portForwards.filter(e=>e.id!==t.id)})),children:(0,$.jsx)(J,{name:`delete-bin`,className:`size-4`})})]})]}),(0,$.jsx)(xi,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(Ir,{label:e(`settings.remoteInstances.page.field.forwardType`),description:e(ju(t.type)),children:(0,$.jsxs)(on,{value:t.type,onValueChange:e=>r(t=>({...t,type:e===`dynamic`||e===`remote`?e:`local`})),children:[(0,$.jsx)(nn,{children:(0,$.jsx)(ln,{placeholder:e(`settings.remoteInstances.page.field.typePlaceholder`)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`local`,children:e(`settings.remoteInstances.page.forwardType.local`)}),(0,$.jsx)(en,{value:`remote`,children:e(`settings.remoteInstances.page.forwardType.remote`)}),(0,$.jsx)(en,{value:`dynamic`,children:e(`settings.remoteInstances.page.forwardType.dynamic`)})]})]})}),(0,$.jsx)(Ir,{label:i,className:`oc-settings-ssh-endpoint-row`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(un,{className:`min-w-0`,value:t.localHost||`127.0.0.1`,onChange:e=>r(t=>({...t,localHost:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.localHostPlaceholder`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`:`}),(0,$.jsx)(Br,{min:1,max:65535,step:1,className:`tabular-nums`,value:t.localPort,onValueChange:e=>{r(t=>({...t,localPort:Number.isFinite(e)&&e>0?e:void 0}))},onClear:()=>{r(e=>({...e,localPort:void 0}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})]})}),t.type===`dynamic`?null:(0,$.jsx)(Ir,{label:a,className:`oc-settings-ssh-endpoint-row`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(un,{className:`min-w-0`,value:t.remoteHost||``,onChange:e=>r(t=>({...t,remoteHost:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.remoteHostPlaceholder`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`:`}),(0,$.jsx)(Br,{min:1,max:65535,step:1,className:`tabular-nums`,value:t.remotePort,onValueChange:e=>{r(t=>({...t,remotePort:Number.isFinite(e)&&e>0?e:void 0}))},onClear:()=>{r(e=>({...e,remotePort:void 0}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})]})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80`,children:t.type===`dynamic`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.localSocks5`)})]}):t.type===`remote`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{name:`server`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:s}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.remote`)}),(0,$.jsx)(J,{name:`arrow-right`,className:`h-3.5 w-3.5`}),(0,$.jsx)(J,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.local`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.local`)}),(0,$.jsx)(J,{name:`arrow-right`,className:`h-3.5 w-3.5`}),(0,$.jsx)(J,{name:`server`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:s}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.remote`)})]})}),c?(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{Sr(l).then(t=>{t||K.error(e(`settings.remoteInstances.page.toast.openLocalEndpointFailed`))})},children:[(0,$.jsx)(J,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.openLocal`)]}):null]})]})})]},t.id)}),(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{let e=Ou();Rn(t=>({...t,portForwards:[...t.portForwards,e]})),we(t=>({...t,[e.id]:!0}))},children:[(0,$.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.addForward`)]})})]}),(0,$.jsxs)(Gt,{className:`flex-wrap`,children:[h?(0,$.jsx)(`div`,{className:`sm:mr-auto typography-meta text-[var(--status-error)]`,children:h}):null,kn?.localUrl?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{$n()},children:[(0,$.jsx)(J,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.open`)]}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{je(kn.localUrl||``).then(t=>{t.ok&&K.success(e(`settings.remoteInstances.page.toast.localUrlCopied`))})},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.copyLocalUrl`)]})]}):null,(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void zn(),disabled:!Ln||m,children:e(`settings.common.actions.saveChanges`)})]}),(0,$.jsx)(yu,{open:H,instanceId:U,targetKind:pe,relayHost:he,onOpenChange:e=>{ee(e),e||(fe(null),me(`ssh`),ge(null))}}),(0,$.jsx)(Yt,{open:P,onOpenChange:F,children:(0,$.jsxs)(Kt,{className:`sm:max-w-2xl`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.remoteInstances.page.logsDialog.title`)}),(0,$.jsx)(Jt,{children:k?.nickname?.trim()||k?.sshParsed?.destination||k?.id||e(`settings.remoteInstances.page.logsDialog.selectedInstanceFallback`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Xn,disabled:I||!Yn.trim(),children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.copyAll`)]}),(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Qn(),disabled:I,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.clear`)]})]}),I?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.logsDialog.loading`)}):R?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:R}):(0,$.jsx)(`pre`,{className:`max-h-[55vh] overflow-auto rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3 typography-micro text-foreground whitespace-pre-wrap break-words`,children:B.length>0?B.join(`
|
|
24
|
+
`):e(`settings.remoteInstances.page.logsDialog.empty`)})]})}),(0,$.jsx)(Yt,{open:!!_e,onOpenChange:e=>{e||Vn()},children:(0,$.jsxs)(Kt,{className:`sm:max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(Jt,{children:_e?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:_e}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Wn()},children:[(0,$.jsx)(un,{value:ye,onChange:e=>be(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Vn,disabled:xe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:xe,children:e(`settings.common.actions.create`)})]})]})]})})]})})},Vu=`__add_provider__`,Hu=()=>{let e=ye.getDirectory();return typeof e==`string`&&e.trim().length>0?e.trim():null},Uu=({onItemSelect:e})=>{let{t}=ke(),n=G(e=>e.providers),r=G(e=>e.selectedProviderId),i=G(e=>e.setSelectedProvider),a=ft(e=>e.activeProjectId),[o,s]=Q.useState({}),c=Q.useMemo(()=>Hu(),[a]);Q.useEffect(()=>{if(n.length===0){s({});return}let e=!1;return(async()=>{let t=n.map(async t=>{try{let n=c?`?directory=${encodeURIComponent(c)}`:``,r=await L(`/api/provider/${encodeURIComponent(t.id)}/source${n}`,{method:`GET`,headers:{Accept:`application/json`}});if(!r.ok)return;let i=await r.json().catch(()=>null),a=i?.sources??i?.data?.sources;if(!a||e)return;s(e=>({...e,[t.id]:a}))}catch{}});await Promise.all(t)})(),()=>{e=!0}},[c,n]);let l=Q.useMemo(()=>n.filter(e=>!!o[e.id]?.project?.exists),[n,o]),u=Q.useMemo(()=>n.filter(e=>!o[e.id]?.project?.exists),[n,o]),d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.providers.sidebar.section.userProviders`)}),(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>{i(Vu),e?.()},"aria-label":t(`settings.providers.sidebar.actions.connectProviderAria`),title:t(`settings.providers.sidebar.actions.connectProviderTitle`),children:(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(ga,{}),(0,$.jsx)($.Fragment,{children:n.length===0?(0,$.jsx)(Z,{label:d,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`stack`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.providers.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.providers.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[u.length>0?(0,$.jsx)(Z,{label:d,children:u.map(t=>(0,$.jsx)(Wu,{provider:t,selectedProviderId:r,onSelect:()=>{i(t.id),e?.()}},t.id))}):(0,$.jsx)(Z,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),l.length>0&&(0,$.jsx)(Z,{label:t(`settings.providers.sidebar.section.projectProviders`),children:l.map(t=>(0,$.jsx)(Wu,{provider:t,selectedProviderId:r,onSelect:()=>{i(t.id),e?.()}},t.id))})]})})]})},Wu=e=>{let t=(0,Di.c)(17),{provider:n,selectedProviderId:r,onSelect:i}=e,a=Array.isArray(n.models)?n.models.length:0,o=n.id===r,s=n.id,c=o?`bg-interactive-selection`:`hover:bg-interactive-hover`,l;t[0]===c?l=t[1]:(l=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 !min-h-0 py-2`,c),t[0]=c,t[1]=l);let u;t[2]===n.id?u=t[3]:(u=(0,$.jsx)(Qt,{providerId:n.id,className:`h-3.5 w-3.5 flex-shrink-0`}),t[2]=n.id,t[3]=u);let d=n.name||n.id,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:d}),t[4]=d,t[5]=f);let p;t[6]===a?p=t[7]:(p=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:a}),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==u||t[10]!==f||t[11]!==p?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[u,f,p]}),t[8]=i,t[9]=u,t[10]=f,t[11]=p,t[12]=m):m=t[12];let h;return t[13]!==n.id||t[14]!==l||t[15]!==m?(h=(0,$.jsx)(`div`,{className:l,children:m},s),t[13]=n.id,t[14]=l,t[15]=m,t[16]=h):h=t[16],h},Gu=e=>e,Ku=(e,t)=>e.flatMap((e,n)=>t(e)?[{method:e,methodIndex:n}]:[]),qu=({providerId:e,providerName:t})=>{let{t:n}=ke(),[r,i]=Q.useState(null),[a,o]=Q.useState({}),[s,c]=Q.useState(!1),l=`/api/quota/credentials/${e}`;Q.useEffect(()=>{L(l).then(async e=>{if(!e.ok)throw Error();let t=await e.json();i(t),o(t.workspaceId?{workspaceId:t.workspaceId}:{})}).catch(()=>i({configured:!1}))},[l]);let u=async(e,r,a)=>{c(!0);try{let s=await L(e,{method:r,headers:a?{"Content-Type":`application/json`}:void 0,body:a?JSON.stringify(a):void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error);c?.configured!==void 0&&i(c),o(e=>e.workspaceId?{workspaceId:e.workspaceId}:{}),K.success(n(`settings.providers.page.quotaCredentials.saved`,{provider:t}))}catch(e){K.error(e instanceof Error&&e.message?e.message:n(`settings.providers.page.openCodeGo.saveFailed`))}finally{c(!1)}},d=(e,t,n)=>(0,$.jsxs)(`label`,{className:`oc-settings-group-row flex flex-col gap-1 typography-ui-label text-foreground`,children:[t,(0,$.jsx)(un,{className:`font-mono text-xs`,type:e===`workspaceId`?`text`:`password`,autoComplete:`off`,value:a[e]??``,onChange:t=>o(n=>({...n,[e]:t.target.value})),placeholder:r?.secretMasked??n})]});return(0,$.jsx)(`div`,{"data-settings-item":`providers.${e}-credentials`,children:(0,$.jsxs)(Z,{label:t,className:`oc-settings-detail-group`,children:[e===`opencode-go`&&d(`workspaceId`,n(`settings.providers.page.openCodeGo.workspaceId`),`wrk_...`),e===`opencode-go`&&d(`authCookie`,n(`settings.providers.page.openCodeGo.authCookie`),`auth=...`),e===`ollama-cloud`&&d(`cookie`,n(`settings.providers.page.openCodeGo.authCookie`),`session=...`),e===`cursor`&&d(`accessToken`,n(`settings.providers.page.auth.apiKeyLabel`),n(`settings.providers.page.auth.apiKeyPlaceholder`)),e===`cursor`&&d(`refreshToken`,n(`settings.providers.page.auth.apiKeyLabel`),n(`settings.providers.page.auth.apiKeyPlaceholder`)),(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-wrap gap-2`,children:[(0,$.jsx)(Y,{size:`xs`,disabled:s,onClick:()=>u(l,`PUT`,a),children:r?.configured?n(`settings.providers.page.openCodeGo.replace`):n(`settings.providers.page.openCodeGo.save`)}),r?.configured&&(0,$.jsx)(Y,{variant:`outline`,size:`xs`,disabled:s,onClick:()=>u(`${l}/validate`,`POST`),children:n(`settings.providers.page.openCodeGo.validate`)}),e===`cursor`&&(0,$.jsx)(Y,{variant:`outline`,size:`xs`,disabled:s,onClick:()=>u(`${l}/import`,`POST`),children:n(`settings.providers.page.actions.connect`)}),r?.configured&&(0,$.jsx)(Y,{variant:`destructive`,size:`xs`,disabled:s,onClick:()=>u(l,`DELETE`),children:n(`settings.providers.page.openCodeGo.delete`)})]})]})})},Ju=e=>{let t=(0,Di.c)(12),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]!==a||t[1]!==r?(s=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:o}),t[3]=o,t[4]=c);let l;t[5]!==i||t[6]!==s||t[7]!==c?(l=(0,$.jsx)(Z,{className:`oc-settings-detail-group`,label:s,description:i,children:c}),t[5]=i,t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==l?(u=(0,$.jsx)(`div`,{"data-settings-item":n,children:l}),t[9]=n,t[10]=l,t[11]=u):u=t[11],u},Yu=e=>new Intl.NumberFormat(Ae(),{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0}).format(e),Xu=e=>{if(typeof e!=`number`||Number.isNaN(e))return null;if(e===0)return`0`;let t=Yu(e);return t.endsWith(`.0`)?t.slice(0,-2):t},Zu=`__add_provider__`,Qu=e=>typeof e==`object`&&!!e,$u=e=>{let t=typeof e.type==`string`?e.type:``,n=`${t} ${`${e.name??``} ${e.label??``}`.toLowerCase()}`.toLowerCase();return n.includes(`oauth`)?`oauth`:n.includes(`api`)?`api`:t.toLowerCase()},ed=e=>{if(!Qu(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>Qu(e)));return t},td=e=>{if(typeof e==`string`)return{id:e};if(!Qu(e))return null;let t=typeof e.id==`string`&&e.id||typeof e.providerID==`string`&&e.providerID||typeof e.slug==`string`&&e.slug||typeof e.name==`string`&&e.name;return t?{id:t,name:typeof e.name==`string`?e.name:void 0}:null},nd=e=>{let t=[];Array.isArray(e)?t=e:Qu(e)&&(Array.isArray(e.all)?t=e.all:Array.isArray(e.providers)&&(t=e.providers));let n=t.map(e=>td(e)).filter(e=>!!e),r=new Set;return n.filter(e=>!r.has(e.id)&&(r.add(e.id),!0))},rd=()=>{let{t:e}=ke(),t=G(e=>e.providers),n=G(e=>e.selectedProviderId),r=G(e=>e.setSelectedProvider),i=G(e=>e.getModelMetadata),a=u(e=>e.hiddenModels),o=u(e=>e.toggleHiddenModel),s=u(e=>e.hideAllModels),c=u(e=>e.showAllModels),[l,d]=Q.useState({}),[f,p]=Q.useState(!1),[m,h]=Q.useState({}),[g,_]=Q.useState(null),[v,y]=Q.useState(``),[b,x]=Q.useState(null),[S,C]=Q.useState({}),[w,T]=Q.useState({}),[E,D]=Q.useState([]),[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(``),[P,F]=Q.useState(``),[I,R]=Q.useState(!1),[z,B]=Q.useState({}),[V,H]=Q.useState(!1),ee=n===Zu;Q.useEffect(()=>{!n&&t.length>0&&r(t[0].id)},[t,n,r]),Q.useEffect(()=>{let t=!0;return(async()=>{p(!0);try{let e=await ye.getSdkClient().provider.auth();if(e.error)throw Error(`provider.auth failed: ${String(e.error)}`);if(!t)return;d(ed(e.data))}catch(n){if(!t)return;console.error(`Failed to load provider auth methods:`,n),K.error(e(`settings.providers.page.toast.authMethodsLoadFailed`))}finally{t&&p(!1)}})(),()=>{t=!1}},[e]),Q.useEffect(()=>{if(!Gu(ee))return;let t=!0;return(async()=>{k(!0),j(null);try{let e=await ye.getSdkClient().provider.list();if(e.error)throw Error(`provider.list failed: ${String(e.error)}`);if(!t)return;D(nd(e.data))}catch(n){if(!t)return;console.error(`Failed to load available providers:`,n),j(e(`settings.providers.page.state.unableToLoadProviderList`))}finally{t&&k(!1)}})(),()=>{t=!1}},[ee,e]);let U=Q.useMemo(()=>new Set(t.map(e=>e.id)),[t]),te=Q.useMemo(()=>E.filter(e=>!U.has(e.id)).sort((e,t)=>{let n=(e.name||e.id).toLowerCase(),r=(t.name||t.id).toLowerCase();return n.localeCompare(r)}),[E,U]);Q.useEffect(()=>{n===Zu&&M&&!te.some(e=>e.id===M)&&N(``)},[n,M,te]),Q.useEffect(()=>{if(n===Zu){H(!0);return}H(!1)},[n,e]),Q.useEffect(()=>{if(!n||n===Zu)return;let t=!1;return(async()=>{try{let r=await L(`/api/provider/${encodeURIComponent(n)}/source`,{method:`GET`,headers:{Accept:`application/json`}}),i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.error||e(`settings.providers.page.toast.providerSourcesLoadFailed`));let a=i?.sources??i?.data?.sources;!t&&a&&B(e=>({...e,[n]:a}))}catch(e){t||console.error(`Failed to load provider sources:`,e)}})(),()=>{t=!0}},[n,e]);let W=t.find(e=>e.id===n),ne=n?z[n]:void 0,re=async t=>{let n=m[t]?.trim()??``;if(!n){K.error(e(`settings.providers.page.toast.apiKeyRequired`));return}let i=`api:${t}`;_(i);try{if((await ye.getSdkClient().auth.set({providerID:t,auth:{type:`api`,key:n}})).error)throw Error(e(`settings.providers.page.toast.apiKeySaveFailed`));K.success(e(`settings.providers.page.toast.apiKeySaved`)),h(e=>({...e,[t]:``})),await We({scopes:[`providers`],mode:`active`}),r(t)}catch(t){console.error(`Failed to save API key:`,t),K.error(e(`settings.providers.page.toast.apiKeySaveFailed`))}finally{_(null)}},ie=async(t,n)=>{let r=`oauth:${t}:${n}`,i=!1;_(r);try{let r=await ye.getSdkClient().provider.oauth.authorize({providerID:t,method:n});if(r.error)throw Error(e(`settings.providers.page.toast.oauthStartFailed`));let a=Qu(r.data)?r.data:{},o=a.data,s=Qu(o)?o:a,c=typeof s.url==`string`&&s.url||typeof s.verification_uri_complete==`string`&&s.verification_uri_complete||typeof s.verification_uri==`string`&&s.verification_uri||void 0,l=typeof s.instructions==`string`&&s.instructions||typeof s.message==`string`&&s.message||void 0,u=typeof s.user_code==`string`&&s.user_code||typeof s.code==`string`&&s.code||typeof s.userCode==`string`&&s.userCode||void 0,d=s.method===`auto`?`auto`:`code`;if(!c&&!l&&!u)throw Error(e(`settings.providers.page.toast.oauthDetailsMissing`));let f=`${t}:${n}`;T(e=>({...e,[f]:{url:c,instructions:l,userCode:u,mode:d}})),c&&Sr(c),x({providerId:t,methodIndex:n,mode:d}),K.message(e(`settings.providers.page.toast.completeOAuthInBrowser`)),d===`auto`&&(i=!0,ae(t,n))}catch(t){console.error(`Failed to start OAuth flow:`,t),K.error(e(`settings.providers.page.toast.oauthStartFailed`))}finally{i||_(null)}},ae=async(t,n,i)=>{let a=`${t}:${n}`,o=i??S[a]?.trim(),s=`oauth-complete:${t}:${n}`;_(s);try{let i={method:n};if(o&&(i.code=o),(await ye.getSdkClient().provider.oauth.callback({providerID:t,method:i.method,code:i.code})).error)throw Error(e(`settings.providers.page.toast.oauthCompleteFailed`));K.success(e(`settings.providers.page.toast.oauthCompleted`)),C(e=>({...e,[a]:``})),x(null),await We({scopes:[`providers`],mode:`active`}),r(t)}catch(t){console.error(`Failed to complete OAuth flow:`,t),K.error(e(`settings.providers.page.toast.oauthCompleteFailed`))}finally{_(null)}},oe=async t=>{let n=await je(t);if(n.ok){K.success(e(`settings.providers.page.toast.oauthLinkCopied`));return}console.error(`Failed to copy OAuth link:`,n.error),K.error(e(`settings.providers.page.toast.oauthLinkCopyFailed`))},se=async t=>{let n=await je(t);if(n.ok){K.success(e(`settings.providers.page.toast.deviceCodeCopied`));return}console.error(`Failed to copy device code:`,n.error),K.error(e(`settings.providers.page.toast.deviceCodeCopyFailed`))},ce=async t=>{let n=`disconnect:${t}`;_(n);try{let n=await L(`/api/provider/${encodeURIComponent(t)}/auth?scope=all`,{method:`DELETE`,headers:{Accept:`application/json`}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||e(`settings.providers.page.toast.providerDisconnectFailed`));K.success(e(`settings.providers.page.toast.providerDisconnected`)),await We({scopes:[`providers`],mode:`active`})}catch(t){console.error(`Failed to disconnect provider:`,t),K.error(e(`settings.providers.page.toast.providerDisconnectFailed`))}finally{_(null)}};if(!ee&&t.length===0)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.providers.page.empty.noProvidersDetected`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.providers.page.empty.checkOpenCodeConfiguration`)})]})});if(ee)return(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{"data-settings-item":`providers.connect`,children:(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.providers.page.connect.title`)})}),(0,$.jsx)(Ju,{label:e(`settings.providers.page.connect.selectProviderTitle`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.providers.page.connect.providerField`)}),O?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.state.loading`)}):A?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:A}):te.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.connect.allProvidersConnected`)}):(0,$.jsxs)(En,{open:I,onOpenChange:e=>{R(e),e||F(``)},children:[(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:q(`flex items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover h-6 w-fit`),children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[M?(0,$.jsx)(Qt,{providerId:M,className:`h-3.5 w-3.5 flex-shrink-0`}):null,(0,$.jsx)(`span`,{className:q(`truncate typography-ui-label font-normal`,M?`text-foreground`:`text-muted-foreground`),children:M?te.find(e=>e.id===M)?.name||M:e(`settings.providers.page.connect.selectProviderPlaceholder`)})]}),(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`})]})}),(0,$.jsxs)(hn,{align:`start`,className:`w-[280px] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2`,onKeyDown:e=>e.stopPropagation(),children:[(0,$.jsx)(J,{name:`search`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`input`,{type:`text`,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:e(`settings.providers.page.connect.searchProvidersPlaceholder`),className:`flex-1 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`,autoFocus:!0})]}),(0,$.jsx)(br,{outerClassName:`max-h-[240px]`,className:`p-1`,children:(()=>{let t=te.filter(e=>{let t=P.toLowerCase();return(e.name||e.id).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)});return t.length===0?(0,$.jsx)(`p`,{className:`py-4 text-center typography-meta text-muted-foreground`,children:e(`settings.providers.page.connect.noProvidersFound`)}):t.map(e=>(0,$.jsxs)(vn,{onSelect:()=>{N(e.id),R(!1),F(``)},className:`flex items-center justify-between`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Qt,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name||e.id})]}),M===e.id&&(0,$.jsx)(J,{name:`check`,className:`h-4 w-4 text-[var(--primary-base)]`})]},e.id))})()})]})]})]})}),M&&(0,$.jsx)(Ju,{itemId:`providers.auth`,label:e(`settings.providers.page.auth.title`),children:f?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.auth.loadingMethods`)}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsxs)(`label`,{className:`typography-ui-label text-foreground flex items-center gap-1.5`,children:[e(`settings.providers.page.auth.apiKeyLabel`),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.providers.page.auth.apiKeyTooltip`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5`,children:[(0,$.jsx)(un,{type:`password`,value:m[M]??``,onChange:e=>h(t=>({...t,[M]:e.target.value})),placeholder:e(`settings.providers.page.auth.apiKeyPlaceholder`),className:`flex-1 font-mono text-xs`}),(0,$.jsx)(Y,{size:`xs`,className:`!font-normal shrink-0`,onClick:()=>re(M),disabled:g===`api:${M}`,children:g===`api:${M}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.saveKey`)})]})]}),(()=>{let t=Ku(l[M]??[],e=>$u(e)===`oauth`);return t.length===0?null:(0,$.jsx)(`div`,{className:`space-y-4 border-t border-[var(--surface-subtle)] pt-2`,children:t.map(({method:t,methodIndex:n},r)=>{let i=t.label||t.name||e(`settings.providers.page.auth.oauthMethodFallback`,{index:String(r+1)}),a=`${M}:${n}`,o=b?.providerId===M&&b?.methodIndex===n;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i}),(t.description||t.help)&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:String(t.description||t.help)})]}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ie(M,n),disabled:g===`oauth:${M}:${n}`||g===`oauth-complete:${M}:${n}`,children:e(`settings.providers.page.actions.connect`)})]}),w[a]?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:w[a]?.instructions}),w[a]?.userCode&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(un,{value:w[a]?.userCode,readOnly:!0,className:`font-mono text-center tracking-widest`}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>se(w[a]?.userCode??``),children:e(`settings.providers.page.actions.copyCode`)})]}),w[a]?.url&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(un,{value:w[a]?.url,readOnly:!0,className:`text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Sr(w[a]?.url??``),children:e(`settings.providers.page.actions.open`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>oe(w[a]?.url??``),children:e(`settings.providers.page.actions.copy`)})]})]}),o&&b?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(un,{value:S[a]??``,onChange:e=>C(t=>({...t,[a]:e.target.value})),placeholder:e(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`font-mono text-xs`}),(0,$.jsx)(Y,{size:`xs`,className:`!font-normal`,onClick:()=>ae(M,n),disabled:g===`oauth-complete:${M}:${n}`,children:g===`oauth-complete:${M}:${n}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.complete`)})]})]},`${M}-${i}`)})})})()]})})]})});if(!W)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.providers.page.empty.selectProviderFromSidebar`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.providers.page.empty.reviewDetailsAndConfigureAuth`)})]})});let le=Array.isArray(W.models)?W.models:[],ue=Ku(l[W.id]??[],e=>$u(e)===`oauth`),de=le.filter(e=>{let t=typeof e?.name==`string`?e.name:``,n=typeof e?.id==`string`?e.id:``,r=v.trim().toLowerCase();return!r||t.toLowerCase().includes(r)||n.toLowerCase().includes(r)});return(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(Qt,{providerId:W.id,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:W.name||W.id}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:(0,$.jsx)(`span`,{className:`font-mono`,children:W.id})})]})]}),(0,$.jsx)(Ju,{itemId:`providers.auth`,label:e(`settings.providers.page.auth.title`),action:(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>H(e=>!e),children:e(V?`settings.providers.page.actions.hide`:`settings.providers.page.actions.reconnect`)}),children:V?f?(0,$.jsx)(`div`,{className:`py-1.5 typography-meta text-muted-foreground`,children:e(`settings.providers.page.auth.loadingMethods`)}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsxs)(`label`,{className:`typography-ui-label text-foreground flex items-center gap-1.5`,children:[e(`settings.providers.page.auth.apiKeyLabel`),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.providers.page.auth.apiKeyTooltip`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5`,children:[(0,$.jsx)(un,{type:`password`,value:m[W.id]??``,onChange:e=>h(t=>({...t,[W.id]:e.target.value})),placeholder:e(`settings.providers.page.auth.apiKeyPlaceholder`),className:`flex-1 font-mono text-xs`}),(0,$.jsx)(Y,{size:`xs`,className:`!font-normal shrink-0`,onClick:()=>re(W.id),disabled:g===`api:${W.id}`,children:g===`api:${W.id}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.saveKey`)})]})]}),ue.length>0&&(0,$.jsx)(`div`,{className:`space-y-4 border-t border-[var(--surface-subtle)] pt-2`,children:ue.map(({method:t,methodIndex:n},r)=>{let i=t.label||t.name||e(`settings.providers.page.auth.oauthMethodFallback`,{index:String(r+1)}),a=`${W.id}:${n}`,o=b?.providerId===W.id&&b?.methodIndex===n;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i}),(t.description||t.help)&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:String(t.description||t.help)})]}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ie(W.id,n),disabled:g===`oauth:${W.id}:${n}`||g===`oauth-complete:${W.id}:${n}`,children:e(`settings.providers.page.actions.connect`)})]}),w[a]?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:w[a]?.instructions}),w[a]?.userCode&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(un,{value:w[a]?.userCode,readOnly:!0,className:`font-mono text-center tracking-widest`}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>se(w[a]?.userCode??``),children:e(`settings.providers.page.actions.copyCode`)})]}),w[a]?.url&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(un,{value:w[a]?.url,readOnly:!0,className:`text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Sr(w[a]?.url??``),children:e(`settings.providers.page.actions.open`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>oe(w[a]?.url??``),children:e(`settings.providers.page.actions.copy`)})]})]}),o&&b?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(un,{value:S[a]??``,onChange:e=>C(t=>({...t,[a]:e.target.value})),placeholder:e(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`font-mono text-xs`}),(0,$.jsx)(Y,{size:`xs`,className:`!font-normal`,onClick:()=>ae(W.id,n),disabled:g===`oauth-complete:${W.id}:${n}`,children:g===`oauth-complete:${W.id}:${n}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.complete`)})]})]},`${W.id}-${i}`)})})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1.5`,children:[(0,$.jsx)(J,{name:`check`,className:`w-4 h-4 text-[var(--status-success)] shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.providers.page.auth.connected`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-1`,children:e(`settings.providers.page.auth.useReconnectHint`)})]})}),(W.id===`opencode`||W.id===`opencode-go`)&&(0,$.jsx)(qu,{providerId:`opencode-go`,providerName:`OpenCode Go`}),(W.id===`ollama`||W.id===`ollama-cloud`)&&(0,$.jsx)(qu,{providerId:`ollama-cloud`,providerName:`Ollama Cloud`}),W.id===`cursor`&&(0,$.jsx)(qu,{providerId:`cursor`,providerName:`Cursor`}),(0,$.jsx)(Ju,{itemId:`providers.connection-details`,label:e(`settings.providers.page.connectionDetails.title`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:ne&&(ne.auth.exists||ne.user.exists||ne.project.exists||ne.custom?.exists)?(0,$.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[e(`settings.providers.page.connectionDetails.configuredIn`),` `,[ne.auth.exists?e(`settings.providers.page.connectionDetails.source.authCredentials`):null,ne.user.exists?e(`settings.providers.page.connectionDetails.source.userConfig`):null,ne.project.exists?e(`settings.providers.page.connectionDetails.source.projectConfig`):null,ne.custom?.exists?e(`settings.providers.page.connectionDetails.source.customConfig`):null].filter(Boolean).join(`, `)]}):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.connectionDetails.noActiveSource`)})}),(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>ce(W.id),disabled:g===`disconnect:${W.id}`,children:g===`disconnect:${W.id}`?e(`settings.providers.page.actions.disconnecting`):e(`settings.providers.page.actions.disconnect`)})]})}),(0,$.jsxs)(Ju,{itemId:`providers.models`,label:(0,$.jsxs)($.Fragment,{children:[e(`settings.providers.page.models.title`),le.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,le.length,`)`]})]}),action:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{let e=le.map(e=>typeof e?.id==`string`?e.id:``).filter(e=>e.length>0);s(W.id,e)},children:e(`settings.providers.page.actions.hideAll`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>c(W.id),children:e(`settings.providers.page.actions.showAll`)})]}),children:[(0,$.jsxs)(`div`,{className:`relative mb-2`,children:[(0,$.jsx)(J,{name:`search`,className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(un,{value:v,onChange:e=>y(e.target.value),placeholder:e(`settings.providers.page.models.filterPlaceholder`),className:`h-7 pl-8 w-full`})]}),de.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-4 text-center`,children:e(`settings.providers.page.models.noModelsMatchFilter`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:de.map(t=>{let n=typeof t?.id==`string`?t.id:``,r=typeof t?.name==`string`?t.name:n,s=n?i(W.id,n):void 0,c=a.some(e=>e.providerID===W.id&&e.modelID===n),l=Xu(s?.limit?.context),u=Xu(s?.limit?.output),d=[];return s?.tool_call&&d.push({key:`tools`,icon:`tools`,label:e(`settings.providers.page.models.capability.toolCalling`)}),s?.reasoning&&d.push({key:`reasoning`,icon:`brain-ai-3`,label:e(`settings.providers.page.models.capability.reasoning`)}),s?.attachment&&d.push({key:`image`,icon:`file-image`,label:e(`settings.providers.page.models.capability.imageInput`)}),(0,$.jsx)(`div`,{className:`py-1.5`,children:(0,$.jsxs)(`div`,{className:q(`flex flex-wrap items-center gap-x-3 gap-y-1.5 md:flex-nowrap md:gap-3`,c&&`opacity-50`),children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate w-full min-w-0 md:w-auto md:flex-1`,children:r}),(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 flex-shrink-0 md:w-auto md:flex-nowrap`,children:[(l||u)&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[l?`${l} ${e(`settings.providers.page.models.tokenBadge.context`)}`:``,l&&u?` · `:``,u?`${u} ${e(`settings.providers.page.models.tokenBadge.output`)}`:``]}),d.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:d.map(({key:e,icon:t,label:n})=>(0,$.jsx)(`span`,{className:`flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]`,title:n,"aria-label":n,children:(0,$.jsx)(J,{name:t,className:`h-3 w-3`})},e))}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(W.id,n),className:`ml-auto flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 md:ml-0`,title:e(c?`settings.providers.page.models.actions.showModelInSelectors`:`settings.providers.page.models.actions.hideModelFromSelectors`),"aria-label":e(c?`settings.providers.page.models.actions.showModel`:`settings.providers.page.models.actions.hideModel`),children:c?(0,$.jsx)(J,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(J,{name:`eye`,className:`h-3.5 w-3.5`})})]})]})},n)})})]})]})})},id=e=>{let t=e?.windows??{},n=Object.values(t).map(e=>e.usedPercent).filter(e=>typeof e==`number`);return n.length===0?null:Math.max(...n)},ad=e=>{let t=(0,Di.c)(112),{onItemSelect:n}=e,{t:r}=ke(),i=pi(od),a=pi(sd),o=pi(cd),s=pi(ld),c=pi(ud),l=pi(dd),u=pi(fd),d=pi(pd),f=pi(md),p=pi(hd),m=pi(gd),h=pi(_d),g=pi(vd),_=pi(yd),v,y;t[0]===_?(v=t[1],y=t[2]):(v=()=>{_()},y=[_],t[0]=_,t[1]=v,t[2]=y),Q.useEffect(v,y);let b=bd,x;t[3]===f?x=t[4]:(x=e=>{f(e),b({usageAutoRefresh:e})},t[3]=f,t[4]=x);let S=x,C;t[5]===p?C=t[6]:(C=e=>{let t=Number(e);Number.isFinite(t)&&(p(t),b({usageRefreshIntervalMs:t}))},t[5]=p,t[6]=C);let w=C,T;t[7]===m?T=t[8]:(T=e=>{(e===`usage`||e===`remaining`)&&(m(e),b({usageDisplayMode:e}))},t[7]=m,t[8]=T);let E=T,D;t[9]===g?D=t[10]:(D=e=>{g(e),b({usageShowPredValues:e})},t[9]=g,t[10]=D);let O=D,k;t[11]===r?k=t[12]:(k=r(`settings.usage.sidebar.title`),t[11]=r,t[12]=k);let A;t[13]===s?A=t[14]:(A=()=>s(),t[13]=s,t[14]=A);let j;t[15]===r?j=t[16]:(j=r(`settings.usage.sidebar.actions.refreshAria`),t[15]=r,t[16]=j);let M;t[17]===r?M=t[18]:(M=r(`settings.usage.sidebar.actions.refreshTitle`),t[17]=r,t[18]=M);let N=c&&`animate-spin`,P;t[19]===N?P=t[20]:(P=q(`h-3.5 w-3.5`,N),t[19]=N,t[20]=P);let F;t[21]===P?F=t[22]:(F=(0,$.jsx)(J,{name:`refresh`,className:P}),t[21]=P,t[22]=F);let I;t[23]!==c||t[24]!==M||t[25]!==F||t[26]!==A||t[27]!==j?(I=(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`text-muted-foreground`,onClick:A,"aria-label":j,title:M,disabled:c,children:F}),t[23]=c,t[24]=M,t[25]=F,t[26]=A,t[27]=j,t[28]=I):I=t[28];let L;t[29]!==I||t[30]!==k?(L=(0,$.jsx)(Ir,{label:k,children:I}),t[29]=I,t[30]=k,t[31]=L):L=t[31];let R;t[32]===r?R=t[33]:(R=r(`settings.usage.sidebar.field.autoRefresh`),t[32]=r,t[33]=R);let z;t[34]===r?z=t[35]:(z=r(`settings.usage.sidebar.actions.toggleAutoRefreshAria`),t[34]=r,t[35]=z);let B;t[36]!==S||t[37]!==z||t[38]!==l?(B=(0,$.jsx)($t,{checked:l,onChange:S,ariaLabel:z}),t[36]=S,t[37]=z,t[38]=l,t[39]=B):B=t[39];let V;t[40]!==R||t[41]!==B?(V=(0,$.jsx)(Ir,{label:R,children:B}),t[40]=R,t[41]=B,t[42]=V):V=t[42];let H;t[43]===r?H=t[44]:(H=r(`settings.usage.sidebar.field.refreshInterval`),t[43]=r,t[44]=H);let ee=String(u),U=!l,te;t[45]===r?te=t[46]:(te=r(`settings.usage.sidebar.field.intervalPlaceholder`),t[45]=r,t[46]=te);let W;t[47]===te?W=t[48]:(W=(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:te,children:xd})}),t[47]=te,t[48]=W);let ne;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`30000`,children:`30s`}),(0,$.jsx)(en,{value:`60000`,children:`1m`}),(0,$.jsx)(en,{value:`300000`,children:`5m`})]}),t[49]=ne):ne=t[49];let re;t[50]!==w||t[51]!==ee||t[52]!==U||t[53]!==W?(re=(0,$.jsxs)(on,{value:ee,onValueChange:w,disabled:U,children:[W,ne]}),t[50]=w,t[51]=ee,t[52]=U,t[53]=W,t[54]=re):re=t[54];let ie;t[55]!==H||t[56]!==re?(ie=(0,$.jsx)(Ir,{label:H,children:re}),t[55]=H,t[56]=re,t[57]=ie):ie=t[57];let ae;t[58]===r?ae=t[59]:(ae=r(`settings.usage.sidebar.field.display`),t[58]=r,t[59]=ae);let oe;t[60]===r?oe=t[61]:(oe=r(`settings.usage.sidebar.field.displayModePlaceholder`),t[60]=r,t[61]=oe);let se;t[62]===r?se=t[63]:(se=e=>e===`usage`?r(`settings.usage.sidebar.field.displayModeUsage`):e===`remaining`?r(`settings.usage.sidebar.field.displayModeRemaining`):e,t[62]=r,t[63]=se);let ce;t[64]!==oe||t[65]!==se?(ce=(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:oe,children:se})}),t[64]=oe,t[65]=se,t[66]=ce):ce=t[66];let le;t[67]===r?le=t[68]:(le=r(`settings.usage.sidebar.field.displayModeUsage`),t[67]=r,t[68]=le);let ue;t[69]===le?ue=t[70]:(ue=(0,$.jsx)(en,{value:`usage`,children:le}),t[69]=le,t[70]=ue);let de;t[71]===r?de=t[72]:(de=r(`settings.usage.sidebar.field.displayModeRemaining`),t[71]=r,t[72]=de);let fe;t[73]===de?fe=t[74]:(fe=(0,$.jsx)(en,{value:`remaining`,children:de}),t[73]=de,t[74]=fe);let pe;t[75]!==ue||t[76]!==fe?(pe=(0,$.jsxs)(rn,{children:[ue,fe]}),t[75]=ue,t[76]=fe,t[77]=pe):pe=t[77];let me;t[78]!==E||t[79]!==ce||t[80]!==pe||t[81]!==d?(me=(0,$.jsxs)(on,{value:d,onValueChange:E,children:[ce,pe]}),t[78]=E,t[79]=ce,t[80]=pe,t[81]=d,t[82]=me):me=t[82];let he;t[83]!==ae||t[84]!==me?(he=(0,$.jsx)(Ir,{label:ae,children:me}),t[83]=ae,t[84]=me,t[85]=he):he=t[85];let ge;t[86]===r?ge=t[87]:(ge=r(`settings.usage.sidebar.field.showPredictions`),t[86]=r,t[87]=ge);let _e;t[88]===r?_e=t[89]:(_e=r(`settings.usage.sidebar.field.showPredictions`),t[88]=r,t[89]=_e);let ve;t[90]!==O||t[91]!==h||t[92]!==ge||t[93]!==_e?(ve=(0,$.jsx)(Hr,{checked:h,onChange:O,label:ge,ariaLabel:_e}),t[90]=O,t[91]=h,t[92]=ge,t[93]=_e,t[94]=ve):ve=t[94];let ye;t[95]!==L||t[96]!==V||t[97]!==ie||t[98]!==he||t[99]!==ve?(ye=(0,$.jsxs)(Z,{children:[L,V,ie,he,ve]}),t[95]=L,t[96]=V,t[97]=ie,t[98]=he,t[99]=ve,t[100]=ye):ye=t[100];let be;t[101]!==n||t[102]!==i||t[103]!==a||t[104]!==o||t[105]!==r?(be=Tr.map(e=>{let t=i.find(t=>t.providerId===e.id),s=id(t?.usage),c=zn(s),l=e.id===a,u=t?.configured??!1,d=u?c===`critical`?{backgroundColor:`var(--status-error)`}:c===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`}:{backgroundColor:`var(--surface-muted-foreground)`,opacity:.4};return(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,l?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.id),n?.()},className:`flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full flex-shrink-0`,style:d}),(0,$.jsx)(Qt,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:e.name}),!u&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:r(`settings.usage.sidebar.status.notSet`)})]})},e.id)}),t[101]=n,t[102]=i,t[103]=a,t[104]=o,t[105]=r,t[106]=be):be=t[106];let xe;t[107]===be?xe=t[108]:(xe=(0,$.jsx)(Z,{children:be}),t[107]=be,t[108]=xe);let Se;return t[109]!==ye||t[110]!==xe?(Se=(0,$.jsxs)(`div`,{className:`oc-settings-page-content oc-settings-usage-sidebar h-full overflow-y-auto bg-background p-3`,children:[ye,xe]}),t[109]=ye,t[110]=xe,t[111]=Se):Se=t[111],Se};function od(e){return e.results}function sd(e){return e.selectedProviderId}function cd(e){return e.setSelectedProvider}function ld(e){return e.fetchAllQuotas}function ud(e){return e.isLoading}function dd(e){return e.autoRefresh}function fd(e){return e.refreshIntervalMs}function pd(e){return e.displayMode}function md(e){return e.setAutoRefresh}function hd(e){return e.setRefreshInterval}function gd(e){return e.setDisplayMode}function _d(e){return e.showPredValues}function vd(e){return e.setShowPredValues}function yd(e){return e.loadSettings}async function bd(e){try{await V(e)}catch(e){console.warn(`Failed to save usage settings:`,e)}}function xd(e){return e===`30000`?`30s`:e===`60000`?`1m`:e===`300000`?`5m`:e}var Sd=e=>{let t=(0,Di.c)(54),{title:n,window:r,subtitle:i,showToggle:a,toggleEnabled:o,onToggle:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,d=pi(Cd),f=pi(wd),p=u(Td),m=d===`remaining`?r.remainingPercent:r.usedPercent,h=d===`remaining`?`remaining`:`used`,g;t[0]!==m||t[1]!==r.valueLabel?(g=In(r.valueLabel,m),t[0]=m,t[1]=r.valueLabel,t[2]=g):g=t[2];let _=g,v=r.resetAfterFormatted??r.resetAtFormatted,y;t[3]!==v||t[4]!==p||t[5]!==r.resetAt?(y=er(r.resetAt,v,p),t[3]=v,t[4]=p,t[5]=r.resetAt,t[6]=y):y=t[6];let b=y,x;t[7]===n?x=t[8]:(x=rr(n),t[7]=n,t[8]=x);let S=x,C;t[9]!==n||t[10]!==r.resetAt||t[11]!==r.usedPercent||t[12]!==r.windowSeconds?(C=Fn(r.usedPercent,r.resetAt,r.windowSeconds,n),t[9]=n,t[10]=r.resetAt,t[11]=r.usedPercent,t[12]=r.windowSeconds,t[13]=C):C=t[13];let w=C,T;bb0:{if(!w||w.dailyAllocationPercent===null){T=null;break bb0}let e=Gn(w.elapsedRatio);T=d===`remaining`?100-e:e}let E=T,D;t[14]!==s||t[15]!==c||t[16]!==l?(D=c&&(0,$.jsx)($t,{checked:l,onChange:e=>s?.(e),ariaLabel:`Show in dropdown`}),t[14]=s,t[15]=c,t[16]=l,t[17]=D):D=t[17];let O;t[18]===S?O=t[19]:(O=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:S}),t[18]=S,t[19]=O);let k;t[20]===i?k=t[21]:(k=i&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:i}),t[20]=i,t[21]=k);let A;t[22]!==O||t[23]!==k?(A=(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[O,k]}),t[22]=O,t[23]=k,t[24]=A):A=t[24];let j;t[25]!==A||t[26]!==D?(j=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[D,A]}),t[25]=A,t[26]=D,t[27]=j):j=t[27];let M=_===`-`?``:_,N;t[28]===M?N=t[29]:(N=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground tabular-nums flex items-center justify-end`,children:M}),t[28]=M,t[29]=N);let P;t[30]!==j||t[31]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[j,N]}),t[30]=j,t[31]=N,t[32]=P):P=t[32];let F;t[33]!==m||t[34]!==E||t[35]!==r.usedPercent?(F=(0,$.jsx)(ri,{percent:m,tonePercent:r.usedPercent,expectedMarkerPercent:E,className:`h-1.5`}),t[33]=m,t[34]=E,t[35]=r.usedPercent,t[36]=F):F=t[36];let I=b?`Resets ${b}`:``,L;t[37]===I?L=t[38]:(L=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:I}),t[37]=I,t[38]=L);let R;t[39]===h?R=t[40]:(R=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:h}),t[39]=h,t[40]=R);let z;t[41]!==L||t[42]!==R?(z=(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between`,children:[L,R]}),t[41]=L,t[42]=R,t[43]=z):z=t[43];let B;t[44]!==F||t[45]!==z?(B=(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[F,z]}),t[44]=F,t[45]=z,t[46]=B):B=t[46];let V;t[47]!==w||t[48]!==f?(V=w&&f&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(si,{paceInfo:w})}),t[47]=w,t[48]=f,t[49]=V):V=t[49];let H;return t[50]!==P||t[51]!==B||t[52]!==V?(H=(0,$.jsxs)(`div`,{className:`py-3`,children:[P,B,V]}),t[50]=P,t[51]=B,t[52]=V,t[53]=H):H=t[53],H};function Cd(e){return e.displayMode}function wd(e){return e.showPredValues}function Td(e){return e.timeFormatPreference}var Ed=(e,t)=>{if(!e)return`-`;try{return Un(e,t,{fallback:`-`})}catch{return`-`}},Dd=()=>{let{t:e}=ke(),t=u(e=>e.timeFormatPreference),n=pi(e=>e.results),r=pi(e=>e.selectedProviderId),i=pi(e=>e.setSelectedProvider),a=pi(e=>e.loadSettings),o=pi(e=>e.fetchAllQuotas),s=pi(e=>e.isLoading),c=pi(e=>e.lastUpdated),l=pi(e=>e.error),d=pi(e=>e.dropdownProviderIds),f=pi(e=>e.setDropdownProviderIds),p=pi(e=>e.selectedModels),m=pi(e=>e.toggleModelSelected),h=pi(e=>e.applyDefaultSelections);Zr(),Q.useEffect(()=>{a(),o()},[a,o]),Q.useEffect(()=>{if(r||n.length===0)return;let e=n.find(e=>e.configured)?.providerId;i(e??Tr[0]?.id??null)},[n,r,i]);let g=n.find(e=>e.providerId===r)??null,_=Tr.find(e=>e.id===r)?.name??r??e(`settings.usage.sidebar.title`),v=g?.usage,y=r?d.includes(r):!1,b=Q.useCallback(e=>{if(!r)return;let t=e?Array.from(new Set([...d,r])):d.filter(e=>e!==r);f(t),V({usageDropdownProviders:t})},[d,r,f]),x=Q.useMemo(()=>v?.models?Object.entries(v.models).map(([e,t])=>({name:e,windows:t})).filter(e=>Object.keys(e.windows.windows).length>0):[],[v?.models]);Q.useEffect(()=>{r&&x.length>0&&h(r,x.map(e=>e.name))},[r,x,h]);let S=Q.useMemo(()=>!r||x.length===0?new Map:Ur(x,e=>e.name,r),[x,r]),C=Q.useMemo(()=>{if(!r)return[];let e=hi(r);return Or(e)},[r]),[w,T]=Q.useState(()=>({})),E=Q.useCallback(e=>{T(t=>({...t,[e]:!t[e]}))},[]),D=Q.useCallback(e=>{if(!r)return;m(r,e);let t=p[r]??[],n=t.includes(e)?t.filter(t=>t!==e):[...t,e],i={...p,[r]:n};V({usageSelectedModels:i})},[r,p,m]),O=r?p[r]??[]:[];return r?(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(Qt,{providerId:r,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.usage.page.header.providerUsage`,{provider:_})}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s?(0,$.jsx)(`span`,{className:`animate-pulse`,children:e(`settings.usage.page.header.refreshing`)}):e(`settings.usage.page.header.lastUpdated`,{time:Ed(c,t)})})]})]}),(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{"data-settings-item":`usage.header-menu`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>b(!y),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(!y))},children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.options.showInHeader`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.usage.page.options.showInHeaderTooltip`)})]})]})}),(0,$.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,$.jsx)($t,{checked:y,onChange:b,ariaLabel:e(`settings.usage.page.options.showInHeaderAria`)})})]})}),!g&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noData`)})}),l&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:l})]}),g?.configured&&!g.ok&&g.error&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:g.error})]}),g&&!g.configured&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-warning)]`,children:e(`settings.usage.page.state.providerNotConfiguredTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]/80 mt-1`,children:e(`settings.usage.page.state.providerNotConfiguredDescription`)})]}),v?.windows&&Object.keys(v.windows).length>0&&(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{"data-settings-item":`usage.model-quotas`,className:`oc-settings-group-row`,children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(v.windows).map(([e,t])=>(0,$.jsx)(Sd,{title:e,window:t},e))})})}),x.length>0&&(0,$.jsxs)(Z,{label:e(`settings.usage.page.section.modelQuotas`),children:[C.map(e=>{let t=S.get(e.id)??[];if(t.length===0)return null;let n=w[e.id]??!1;return(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(Ci,{open:!n,onOpenChange:()=>E(e.id),children:[(0,$.jsxs)(Si,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e.label}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(xi,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=O.includes(e.name);return(0,$.jsx)(Sd,{title:n,subtitle:$r(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})},e.id)}),(()=>{let t=S.get(null)??[];if(t.length===0)return null;let n=w.other??!1;return(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(Ci,{open:!n,onOpenChange:()=>E(`other`),children:[(0,$.jsxs)(Si,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.usage.page.section.otherModels`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(xi,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=O.includes(e.name);return(0,$.jsx)(Sd,{title:n,subtitle:$r(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})})})()]}),g?.configured&&v&&Object.keys(v.windows??{}).length===0&&x.length===0&&(0,$.jsxs)(`div`,{className:`px-2`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noQuotaWindowsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground mt-1`,children:e(`settings.usage.page.state.noQuotaWindowsDescription`)})]})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.usage.page.empty.selectProvider`)})})},Od=`git.commit.generate`,kd=fe(e=>({selectedPromptId:Od,setSelectedPromptId:t=>{e(e=>e.selectedPromptId===t?e:{selectedPromptId:t})}})),Ad=e=>{let t=(0,Di.c)(22),{onItemSelect:n}=e,{t:r}=ke(),i=kd(jd),a=kd(Md),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={groupKey:`settings.magicPrompts.sidebar.group.git`,items:[{id:`git.commit.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitCommitGenerate`},{id:`git.pr.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitPrGenerate`},{id:`git.conflict.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitConflictResolve`},{id:`git.integrate.cherrypick.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve`}]},t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={groupKey:`settings.magicPrompts.sidebar.group.github`,items:[{id:`github.pr.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrReview`},{id:`github.issue.review`,titleKey:`settings.magicPrompts.sidebar.item.githubIssueReview`},{id:`github.pr.checks.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrFailedChecksReview`},{id:`github.pr.comments.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrCommentsReview`},{id:`github.pr.comment.single`,titleKey:`settings.magicPrompts.sidebar.item.githubSinglePrCommentReview`}]},t[1]=s):s=t[1];let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=[o,s,{groupKey:`settings.magicPrompts.sidebar.group.session`,items:[{id:`session.explore`,titleKey:`settings.magicPrompts.sidebar.item.sessionExplore`},{id:`session.summary`,titleKey:`settings.magicPrompts.sidebar.item.sessionSummary`},{id:`session.review`,titleKey:`settings.magicPrompts.sidebar.item.sessionWorkspaceReview`},{id:`session.craftGoal`,titleKey:`settings.magicPrompts.sidebar.item.sessionCraftGoal`},{id:`session.catchup`,titleKey:`settings.magicPrompts.sidebar.item.sessionCatchUp`},{id:`session.debug`,titleKey:`settings.magicPrompts.sidebar.item.sessionDebug`},{id:`session.weigh`,titleKey:`settings.magicPrompts.sidebar.item.sessionWeigh`},{id:`session.fusion`,titleKey:`settings.magicPrompts.sidebar.item.sessionFusion`}]}],t[2]=c):c=t[2];let l=c,u;t[3]===r?u=t[4]:(u=r(`settings.magicPrompts.sidebar.title`),t[3]=r,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:u}),t[5]=u,t[6]=d);let f;t[7]===r?f=t[8]:(f=r(`settings.magicPrompts.sidebar.description`),t[7]=r,t[8]=f);let p;t[9]===f?p=t[10]:(p=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 px-2`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;t[14]!==n||t[15]!==i||t[16]!==a||t[17]!==r?(h=l.map(e=>(0,$.jsx)(Z,{label:r(e.groupKey),children:e.items.map(e=>{let t=i===e.id;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a(e.id),n?.()},className:q(`oc-settings-group-row flex w-full items-center text-left transition-colors`,t?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:(0,$.jsx)(`span`,{className:`typography-ui-label truncate font-normal`,children:r(e.titleKey)})},e.id)})},e.groupKey)),t[14]=n,t[15]=i,t[16]=a,t[17]=r,t[18]=h):h=t[18];let g;return t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[m,h]}),t[19]=m,t[20]=h,t[21]=g):g=t[21],g};function jd(e){return e.selectedPromptId}function Md(e){return e.setSelectedPromptId}var Nd={"git.commit.generate":{titleKey:`settings.magicPrompts.page.group.gitCommitGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitCommitGenerate.description`,blocks:[{id:`git.commit.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.commit.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.pr.generate":{titleKey:`settings.magicPrompts.page.group.gitPrGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitPrGenerate.description`,blocks:[{id:`git.pr.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.pr.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.review":{titleKey:`settings.magicPrompts.page.group.githubPrReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrReview.description`,blocks:[{id:`github.pr.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.issue.review":{titleKey:`settings.magicPrompts.page.group.githubIssueReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubIssueReview.description`,blocks:[{id:`github.issue.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.issue.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.checks.review":{titleKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.description`,blocks:[{id:`github.pr.checks.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.checks.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comments.review":{titleKey:`settings.magicPrompts.page.group.githubPrCommentsReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrCommentsReview.description`,blocks:[{id:`github.pr.comments.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comments.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comment.single":{titleKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.description`,blocks:[{id:`github.pr.comment.single.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comment.single.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.conflict.resolve":{titleKey:`settings.magicPrompts.page.group.gitConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitConflictResolve.description`,blocks:[{id:`git.conflict.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.conflict.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.integrate.cherrypick.resolve":{titleKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.description`,blocks:[{id:`git.integrate.cherrypick.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.integrate.cherrypick.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.summary":{titleKey:`settings.magicPrompts.page.group.sessionSummary.title`,descriptionKey:`settings.magicPrompts.page.group.sessionSummary.description`,blocks:[{id:`session.summary.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.summary.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.review":{titleKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.description`,blocks:[{id:`session.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.craftGoal":{titleKey:`settings.magicPrompts.page.group.sessionCraftGoal.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCraftGoal.description`,blocks:[{id:`session.craftGoal.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.craftGoal.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.catchup":{titleKey:`settings.magicPrompts.page.group.sessionCatchUp.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCatchUp.description`,blocks:[{id:`session.catchup.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.catchup.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.debug":{titleKey:`settings.magicPrompts.page.group.sessionDebug.title`,descriptionKey:`settings.magicPrompts.page.group.sessionDebug.description`,blocks:[{id:`session.debug.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.debug.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.weigh":{titleKey:`settings.magicPrompts.page.group.sessionWeigh.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWeigh.description`,blocks:[{id:`session.weigh.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.weigh.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.explore":{titleKey:`settings.magicPrompts.page.group.sessionExplore.title`,descriptionKey:`settings.magicPrompts.page.group.sessionExplore.description`,blocks:[{id:`session.explore.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.explore.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.fusion":{titleKey:`settings.magicPrompts.page.group.sessionFusion.title`,descriptionKey:`settings.magicPrompts.page.group.sessionFusion.description`,blocks:[{id:`session.fusion.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.fusion.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]}},Pd=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Fd=e=>e.endsWith(`.visible`),Id=()=>{let{t:e}=ke(),t=Q.useCallback(t=>e(t),[e]),n=kd(e=>e.selectedPromptId),[r,i]=Q.useState(!0),[a,o]=Q.useState({}),[s,c]=Q.useState({}),[l,u]=Q.useState({}),[d,f]=Q.useState({}),[p,m]=Q.useState(!1);Q.useEffect(()=>{let t=!0;return(async()=>{i(!0);try{let e=await Le();if(!t)return;o(e)}catch(t){console.warn(`Failed to load magic prompts:`,t),K.error(e(`settings.magicPrompts.page.toast.loadFailed`))}finally{t&&i(!1)}})(),()=>{t=!1}},[e]);let h=Nd[n]??Nd[`git.commit.generate`],g=Q.useCallback(e=>Pd(a,e)?a[e]:Xe(e),[a]),_=Q.useCallback(e=>s[e]??g(e),[s,g]),v=Q.useCallback((e,t)=>{c(n=>n[e]===t?n:{...n,[e]:t})},[]),y=Q.useCallback(async t=>{let n=_(t);if(Fd(t)&&n.trim().length===0){K.error(e(`settings.magicPrompts.page.toast.visiblePromptRequired`));return}u(e=>({...e,[t]:!0}));try{let r=n===Xe(t)?await Ve(t):await Ke(t,n);o(r.overrides),K.success(e(`settings.magicPrompts.page.toast.saved`))}catch(t){let n=t instanceof Error?t.message:String(t);K.error(e(`settings.magicPrompts.page.toast.saveFailed`),{description:n})}finally{u(e=>({...e,[t]:!1}))}},[_,e]),b=Q.useCallback(async t=>{f(e=>({...e,[t]:!0}));try{let n=await Ve(t);o(n.overrides),c(e=>({...e,[t]:Xe(t)})),K.success(e(`settings.magicPrompts.page.toast.resetSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);K.error(e(`settings.magicPrompts.page.toast.resetFailed`),{description:n})}finally{f(e=>({...e,[t]:!1}))}},[e]),x=Q.useCallback(async()=>{m(!0);try{let t=await Ze();o(t.overrides),c({}),K.success(e(`settings.magicPrompts.page.toast.resetAllSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);K.error(e(`settings.magicPrompts.page.toast.resetAllFailed`),{description:n})}finally{m(!1)}},[e]);return r?(0,$.jsxs)(`div`,{className:`py-6 px-6 flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.magicPrompts.page.loading.aria`)}),(0,$.jsx)(`span`,{className:`typography-ui`,children:e(`settings.magicPrompts.page.loading.text`)})]}):(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-4xl px-6 py-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:t(h.titleKey)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:t(h.descriptionKey)})]})]})}),(0,$.jsx)(Y,{"data-settings-item":`magic-prompts.reset-overrides`,variant:`outline`,size:`sm`,onClick:()=>{x()},disabled:p||Object.keys(a).length===0,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetAllOverrides`)})]}),h.blocks.map(n=>{let r=Ue(n.id),i=g(n.id),o=_(n.id),s=Pd(a,n.id),c=o!==i,u=Fd(n.id)&&o.trim().length===0,f=l[n.id]===!0,p=d[n.id]===!0;return(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(n.titleKey)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:r.description})]})]}),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{"data-settings-item":Fd(n.id)?`magic-prompts.visible-prompt`:`magic-prompts.instructions`,className:`space-y-3`,children:[r.placeholders&&r.placeholders.length>0&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.magicPrompts.page.placeholdersLabel`),` `,r.placeholders.map(e=>`{{${e.key}}}`).join(`, `)]}),(0,$.jsx)(xr,{embedded:!0,value:o,onChange:e=>v(n.id,e.target.value),className:`min-h-[220px] font-mono text-sm`}),u&&(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-error)]`,children:e(`settings.magicPrompts.page.validation.visiblePromptRequired`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(c?`settings.magicPrompts.page.status.unsavedChanges`:s?`settings.magicPrompts.page.status.usingSavedOverride`:`settings.magicPrompts.page.status.usingBuiltinDefault`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>{b(n.id)},disabled:!s||f||p,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetToDefault`)}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>{y(n.id)},disabled:!c||f||p||u,children:e(f?`settings.common.actions.saving`:`settings.magicPrompts.page.actions.save`)})]})]})]})},n.id)})]})})},Ld=e=>{let t=(0,Di.c)(71),{onItemSelect:n}=e,{t:r}=ke(),[i,a]=Q.useState(null),[o,s]=Q.useState(null),[c,l]=Q.useState(null),{selectedSnippetName:u,snippets:d,setSelectedSnippet:f,setSnippetDraft:p,deleteSnippet:m,loadSnippets:h}=cn(he(Rd)),g,_;t[0]===h?(g=t[1],_=t[2]):(g=()=>{h()},_=[h],t[0]=h,t[1]=g,t[2]=_),Q.useEffect(g,_);let v;t[3]!==n||t[4]!==f||t[5]!==p||t[6]!==d?(v=async()=>{let e=new Set(d.map(zd)),t=`new-snippet`,r=1;for(;e.has(t);)t=`new-snippet-${r++}`;p({name:t,scope:`global`}),f(t),n?.()},t[3]=n,t[4]=f,t[5]=p,t[6]=d,t[7]=v):v=t[7];let y=v,b;t[8]!==i||t[9]!==m||t[10]!==r?(b=async()=>{i&&(await m(i.name)?(K.success(r(`settings.snippets.sidebar.toast.deleted`)),a(null)):K.error(r(`settings.snippets.sidebar.toast.deleteFailed`)))},t[8]=i,t[9]=m,t[10]=r,t[11]=b):b=t[11];let x=b,S;t[12]===d?S=t[13]:(S=[...d].sort(Bd),t[12]=d,t[13]=S);let C=S,w;t[14]===r?w=t[15]:(w=r(`settings.snippets.sidebar.title`),t[14]=r,t[15]=w);let T;t[16]===w?T=t[17]:(T=(0,$.jsx)(`span`,{children:w}),t[16]=w,t[17]=T);let E;t[18]===r?E=t[19]:(E=r(`settings.snippets.sidebar.actions.create`),t[18]=r,t[19]=E);let D;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[20]=D):D=t[20];let O;t[21]!==y||t[22]!==E?(O=(0,$.jsx)(Y,{"data-settings-item":`snippets.create`,size:`icon`,variant:`ghost`,onClick:y,"aria-label":E,children:D}),t[21]=y,t[22]=E,t[23]=O):O=t[23];let k;t[24]!==O||t[25]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[T,O]}),t[24]=O,t[25]=T,t[26]=k):k=t[26];let A=k,j;t[27]!==n||t[28]!==o||t[29]!==c||t[30]!==u||t[31]!==f||t[32]!==A||t[33]!==C||t[34]!==r?(j=C.length>0?(0,$.jsx)(Z,{label:A,children:C.map(e=>(0,$.jsxs)(bi,{open:c===e.name,onOpenChange:t=>l(t?e.name:null),children:[(0,$.jsxs)(_i,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,u===e.name?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:t=>{t.preventDefault(),l(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{f(e.name),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`#`,e.name]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:r(`snippets.source.${e.source}`)})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:e.description||e.content.replace(/\s+/g,` `).substring(0,80)})]}),(0,$.jsxs)(En,{open:o===e.name,onOpenChange:t=>{t&&l(null),s(t?e.name:null)},children:[(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsx)(Y,{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":r(`settings.snippets.sidebar.actions.more`,{name:e.name}),children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hn,{align:`end`,className:`w-fit min-w-20`,children:(0,$.jsxs)(vn,{onClick:t=>{t.stopPropagation(),a(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]})})]})]}),(0,$.jsx)(vi,{className:`w-fit min-w-20`,children:(0,$.jsxs)(yi,{onClick:t=>{t.stopPropagation(),a(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]})})]},`${e.source}:${e.filePath}`))}):(0,$.jsx)(Z,{label:A,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[27]=n,t[28]=o,t[29]=c,t[30]=u,t[31]=f,t[32]=A,t[33]=C,t[34]=r,t[35]=j):j=t[35];let M=i!==null,N;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{e||a(null)},t[36]=N):N=t[36];let P;t[37]===r?P=t[38]:(P=r(`settings.snippets.sidebar.dialog.deleteTitle`),t[37]=r,t[38]=P);let F;t[39]===P?F=t[40]:(F=(0,$.jsx)(qt,{children:P}),t[39]=P,t[40]=F);let I=i?.name??``,L;t[41]!==r||t[42]!==I?(L=r(`settings.snippets.sidebar.dialog.deleteDescription`,{name:I}),t[41]=r,t[42]=I,t[43]=L):L=t[43];let R;t[44]===L?R=t[45]:(R=(0,$.jsx)(Jt,{children:L}),t[44]=L,t[45]=R);let z;t[46]!==F||t[47]!==R?(z=(0,$.jsxs)(Wt,{children:[F,R]}),t[46]=F,t[47]=R,t[48]=z):z=t[48];let B;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>a(null),t[49]=B):B=t[49];let V;t[50]===r?V=t[51]:(V=r(`settings.common.actions.cancel`),t[50]=r,t[51]=V);let H;t[52]===V?H=t[53]:(H=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:B,children:V}),t[52]=V,t[53]=H);let ee;t[54]===r?ee=t[55]:(ee=r(`settings.common.actions.delete`),t[54]=r,t[55]=ee);let U;t[56]!==x||t[57]!==ee?(U=(0,$.jsx)(Y,{size:`sm`,onClick:x,children:ee}),t[56]=x,t[57]=ee,t[58]=U):U=t[58];let te;t[59]!==H||t[60]!==U?(te=(0,$.jsxs)(Gt,{children:[H,U]}),t[59]=H,t[60]=U,t[61]=te):te=t[61];let W;t[62]!==z||t[63]!==te?(W=(0,$.jsxs)(Kt,{className:`max-w-md`,children:[z,te]}),t[62]=z,t[63]=te,t[64]=W):W=t[64];let ne;t[65]!==M||t[66]!==W?(ne=(0,$.jsx)(Yt,{open:M,onOpenChange:N,children:W}),t[65]=M,t[66]=W,t[67]=ne):ne=t[67];let re;return t[68]!==j||t[69]!==ne?(re=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[j,ne]}),t[68]=j,t[69]=ne,t[70]=re):re=t[70],re};function Rd(e){return{selectedSnippetName:e.selectedSnippetName,snippets:e.snippets,setSelectedSnippet:e.setSelectedSnippet,setSnippetDraft:e.setSnippetDraft,deleteSnippet:e.deleteSnippet,loadSnippets:e.loadSnippets}}function zd(e){return e.name}function Bd(e,t){return e.name.localeCompare(t.name)}var Vd=()=>{let{t:e}=ke(),{selectedSnippetName:t,snippets:n,snippetDraft:r,setSnippetDraft:i,updateSnippet:a,createSnippet:o}=cn(he(e=>({selectedSnippetName:e.selectedSnippetName,snippets:e.snippets,snippetDraft:e.snippetDraft,setSnippetDraft:e.setSnippetDraft,updateSnippet:e.updateSnippet,createSnippet:e.createSnippet}))),s=Q.useMemo(()=>t?n.find(e=>e.name===t||e.aliases.includes(t))??null:null,[t,n]),c=!!(r&&r.name===t&&!s),[l,u]=Q.useState(``),[d,f]=Q.useState(`global`),[p,m]=Q.useState(``),[h,g]=Q.useState(``),[_,v]=Q.useState(``),[y,b]=Q.useState(!1),x=Q.useRef(null);Q.useEffect(()=>{if(c&&r){let e={draftName:r.name||``,draftScope:r.scope||`global`,description:r.description||``,aliases:(r.aliases||[]).join(`, `),content:r.content||``};u(e.draftName),f(e.draftScope),m(e.description),g(e.aliases),v(e.content),x.current=e}else if(s){let e={draftName:``,draftScope:`global`,description:s.description??``,aliases:s.aliases.join(`, `),content:s.content};m(e.description),g(e.aliases),v(e.content),x.current=e}},[s,c,t,r]);let S=Q.useMemo(()=>{let e=x.current;return e?c&&l!==e.draftName||c&&d!==e.draftScope?!0:p!==e.description||h!==e.aliases||_!==e.content:!1},[h,_,p,l,d,c]);return t?(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:c?e(`settings.snippets.page.title.new`):`#${t}`}),s?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s.filePath}):null]}),(0,$.jsx)(Z,{cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[c?(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`#`}),(0,$.jsx)(un,{value:l,onChange:e=>u(e.target.value),placeholder:e(`settings.snippets.page.field.namePlaceholder`),className:`h-7 w-44 px-2`}),(0,$.jsxs)(on,{value:d,onValueChange:e=>f(e),children:[(0,$.jsx)(nn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(ln,{})}),(0,$.jsxs)(rn,{align:`end`,children:[(0,$.jsx)(en,{value:`global`,children:e(`settings.common.scope.global`)}),(0,$.jsx)(en,{value:`project`,children:e(`settings.common.scope.project`)})]})]})]}):null,(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.common.field.description`)}),(0,$.jsx)(un,{value:p,onChange:e=>m(e.target.value),placeholder:e(`settings.snippets.page.field.descriptionPlaceholder`),className:`mt-1.5 h-7 w-full max-w-sm px-2`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.snippets.page.field.aliases`)}),(0,$.jsx)(un,{value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.snippets.page.field.aliasesPlaceholder`),className:`mt-1.5 h-7 w-full max-w-sm px-2`})]})]})}),(0,$.jsx)(`div`,{"data-settings-item":`snippets.content`,children:(0,$.jsx)(Z,{label:e(`settings.snippets.page.field.content`),description:e(`settings.snippets.page.hint`),cardClassName:`p-3`,children:(0,$.jsx)(xr,{embedded:!0,value:_,onChange:e=>v(e.target.value),placeholder:e(`settings.snippets.page.field.contentPlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent`})})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Y,{onClick:async()=>{let n=c?l.trim().replace(/\s+/g,`-`):t?.trim();if(!n){K.error(e(`settings.snippets.page.toast.nameRequired`));return}if(!_.trim()){K.error(e(`settings.snippets.page.toast.contentRequired`));return}let r=h.split(`,`).map(e=>e.trim()).filter(Boolean);b(!0);try{if(!(c?await o(n,_,{aliases:r,description:p,scope:d}):await a(n,{content:_,aliases:r,description:p}))){K.error(e(`settings.snippets.page.toast.saveFailed`));return}K.success(e(`settings.snippets.page.toast.saved`)),c&&i(null)}finally{b(!1)}},disabled:y||!S,size:`xs`,className:`!font-normal`,children:e(y?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`file-text`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.snippets.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.snippets.page.empty.description`)})]})})},Hd=()=>{let{t:e}=ke(),t=G(e=>e.settingsGitmojiEnabled),n=G(e=>e.setSettingsGitmojiEnabled),r=g(),i=u(e=>e.gitChangesViewMode),a=u(e=>e.setGitChangesViewMode),[o,s]=Q.useState(!0),c=Q.useMemo(()=>[{id:`flat`,label:e(`settings.openchamber.git.option.flatList`)},{id:`tree`,label:e(`settings.openchamber.git.option.treeView`)}],[e]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=U()?.settings;if(t)try{let n=(await t.load())?.settings;n&&(e={gitmojiEnabled:typeof n.gitmojiEnabled==`boolean`?n.gitmojiEnabled:void 0,gitChangesViewMode:n.gitChangesViewMode===`flat`||n.gitChangesViewMode===`tree`?n.gitChangesViewMode:void 0})}catch{}}if(!e){let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}e&&(typeof e.gitmojiEnabled==`boolean`&&n(e.gitmojiEnabled),(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&a(e.gitChangesViewMode))}catch(e){console.warn(`Failed to load git settings:`,e)}finally{s(!1)}})()},[a,n]);let l=Q.useCallback(async e=>{n(e);try{await V({gitmojiEnabled:e})}catch(e){console.warn(`Failed to save gitmoji setting:`,e)}},[n]),d=Q.useCallback(e=>{e!==i&&(a(e),V({gitChangesViewMode:e}))},[i,a]);return o?null:(0,$.jsxs)(Z,{label:e(`settings.openchamber.git.title`),children:[(0,$.jsx)(Ir,{itemId:`git.changes-view`,label:e(`settings.openchamber.git.changesViewTitle`),controlClassName:`items-end`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.openchamber.git.changesViewAria`),className:`mt-0.5 space-y-0`,children:c.map(t=>{let n=i===t.id;return(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:()=>{d(t.id)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t.id))},className:`flex w-full items-center gap-2 py-0 text-left`,children:[(0,$.jsx)(Zn,{checked:n,onChange:()=>{d(t.id)},ariaLabel:e(`settings.openchamber.git.optionAria`,{option:t.label})}),(0,$.jsx)(`span`,{className:n?`typography-ui-label font-normal text-foreground`:`typography-ui-label font-normal text-foreground/50`,children:t.label})]},t.id)})})}),(0,$.jsxs)(`div`,{"data-settings-item":`git.gitmoji`,className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":t,onClick:()=>{l(!t)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(!t))},children:[(0,$.jsx)($t,{checked:t,onChange:e=>{l(e)},ariaLabel:e(`settings.openchamber.git.enableGitmojiAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.git.enableGitmoji`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`git.gitignored-files`,className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":r,onClick:()=>_(!r),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),_(!r))},children:[(0,$.jsx)($t,{checked:r,onChange:_,ariaLabel:e(`settings.openchamber.git.showGitignoredAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.git.showGitignored`)})]})]})},Ud=({itemId:e})=>{let{t}=ke(),{isMobile:n}=fr(),r=U()?.github,i=or(),a=i.data??null,o=i.isLoading&&!i.data,s=i.isFetched,c=li(e=>e.refreshStatus),l=li(e=>e.setStatus),u=Q.useCallback(async e=>{await Sr(e)},[]),[d,f]=Q.useState(!1),[p,m]=Q.useState(null),[h,g]=Q.useState(null),_=Q.useRef(null),v=Q.useRef(0),y=Q.useCallback(()=>{_.current!=null&&(window.clearTimeout(_.current),_.current=null),g(null)},[]);Q.useEffect(()=>((async()=>{try{s||await c(r)}catch(e){console.warn(`Failed to load GitHub auth status:`,e)}})(),()=>{y()}),[s,c,r,y]);let b=Q.useCallback(async()=>{f(!0);try{let e=r?await r.authStart():await(async()=>{let e=await L(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>null);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText);return t})();m(e),v.current=Date.now(),g(Math.max(1,e.interval)*1e3);let t=e.verificationUriComplete||e.verificationUri;u(t)}catch(e){console.error(`Failed to start GitHub connect:`,e),K.error(t(`settings.github.page.toast.startConnectFailed`))}finally{f(!1)}},[u,r,t]),x=Q.useCallback(async e=>{if(r)return r.authComplete(e);let t=await L(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n},[r]);Q.useEffect(()=>{if(!p?.deviceCode||!h||_.current!=null)return;let e=!1,n=v.current+p.expiresIn*1e3,i=async()=>{if(Date.now()>=n){K.error(t(`settings.github.page.toast.authorizationFailed`)),m(null),y();return}try{let n=await x(p.deviceCode);if(e)return;if(n.connected){K.success(t(`settings.github.page.toast.connected`)),m(null),y(),await c(r,{force:!0});return}if(n.status===`slow_down`){g(e=>e?e+5e3:5e3);return}if(n.status===`expired_token`||n.status===`access_denied`){K.error(n.error||t(`settings.github.page.toast.authorizationFailed`)),m(null),y();return}}catch(t){if(e)return;console.warn(`GitHub polling failed:`,t)}_.current=window.setTimeout(()=>void i(),h)};return _.current=window.setTimeout(()=>void i(),h),()=>{e=!0,_.current!=null&&(window.clearTimeout(_.current),_.current=null)}},[p,h,x,c,r,y,t]);let S=Q.useCallback(async e=>{f(!0);try{if(r)await r.authSetGhCliDisabled(e);else{let t=await L(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||t.statusText)}K.success(t(e?`settings.github.page.toast.ghCliDisabled`:`settings.github.page.toast.ghCliEnabled`)),await c(r,{force:!0})}catch(e){console.error(`Failed to update gh CLI setting:`,e),K.error(t(`settings.github.page.toast.ghCliUpdateFailed`))}finally{f(!1)}},[c,r,t]),C=Q.useCallback(async()=>{f(!0);try{if(y(),m(null),r)await r.authDisconnect();else{let e=await L(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText)}K.success(t(`settings.github.page.toast.disconnected`)),await c(r,{force:!0})}catch(e){console.error(`Failed to disconnect GitHub:`,e),K.error(t(`settings.github.page.toast.disconnectFailed`))}finally{f(!1)}},[c,r,y,t]),w=Q.useCallback(async e=>{if(e){f(!0);try{let n=r?await r.authActivate(e):await(async()=>{let t=await L(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();l(n),K.success(t(`settings.github.page.toast.accountSwitched`))}catch(e){console.error(`Failed to switch GitHub account:`,e),K.error(t(`settings.github.page.toast.accountSwitchFailed`))}finally{f(!1)}}},[r,l,t]);if(o)return null;if(i.isError&&!i.data)return(0,$.jsx)(`div`,{className:`oc-settings-group-description text-[var(--status-error)]`,children:i.error.message});let T=!!a?.connected,E=a?.user,D=(a?.accounts??[]).filter(e=>!e.current),O=a?.ghCli??null,k=O?.active?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(Z,{itemId:e,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(`settings.github.page.oauth.title`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:t(`settings.github.page.tooltip.connectAccount`)})]})]}),children:[(0,$.jsxs)(`div`,{className:`overflow-hidden flex flex-col`,children:[T?(0,$.jsxs)(`div`,{className:q(`px-4 py-3`,n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:q(`flex min-w-0 items-center gap-4`,n?`w-full`:void 0),children:[E?.avatarUrl?(0,$.jsx)(`img`,{src:E.avatarUrl,alt:E.login?t(`settings.github.page.avatarAlt.withLogin`,{login:E.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:E?.name?.trim()||E?.login||`GitHub`}),(0,$.jsxs)(`div`,{className:q(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:E?.login||t(`settings.github.page.label.unknownUser`)}),E?.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),E?.email&&(0,$.jsx)(`span`,{children:E.email}),(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),(0,$.jsx)(`span`,{children:k})]}),a?.scope&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.label.scopes`,{value:a.scope})}),O?.active&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.ghCli.activeDescription`)})]})]}),O?.active?(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>S(!0),disabled:d,className:q(n?`w-full`:void 0),children:t(`settings.github.page.ghCli.actions.disable`)}):(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:C,disabled:d,className:q(`text-[var(--status-error)] hover:text-[var(--status-error)]`,n?`w-full`:void 0),children:t(`settings.github.page.actions.disconnect`)})]}):(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-4 py-4`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.status.notConnected`)})}),(0,$.jsx)(Y,{size:`sm`,variant:`default`,onClick:b,disabled:d,children:t(`settings.github.page.actions.connect`)})]}),D.length>0&&(0,$.jsxs)(`div`,{className:`mt-2 border-t border-[var(--surface-subtle)] pt-2 px-2 pb-1`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-2 px-1`,children:t(`settings.github.page.label.otherAccounts`)}),(0,$.jsx)(`div`,{className:`space-y-1`,children:D.map(e=>{let n=e.user,r=e.source===`gh-cli`?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[n?.avatarUrl?(0,$.jsx)(`img`,{src:n.avatarUrl,alt:n.login?t(`settings.github.page.avatarAlt.withLogin`,{login:n.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-6 w-6 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(J,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n?.name?.trim()||n?.login||`GitHub`}),n?.login&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:n.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]})]})]}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>w(e.id),disabled:d,children:t(`settings.github.page.actions.switchTo`)})]},e.id)})})]})]}),T&&(0,$.jsx)(`div`,{className:`mt-2 px-2 pb-2`,children:(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:b,disabled:d,className:q(n?`w-full`:void 0),children:t(`settings.github.page.actions.addAccount`)})})]}),p&&(0,$.jsxs)(`div`,{className:`mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.flow.title`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.github.page.flow.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mt-4`,children:[(0,$.jsx)(`div`,{className:`font-mono text-xl tracking-widest text-foreground bg-[var(--surface-muted)] px-3 py-1.5 rounded-md border border-[var(--interactive-border)]`,children:p.userCode}),(0,$.jsx)(Y,{size:`sm`,asChild:!0,children:(0,$.jsx)(`a`,{href:p.verificationUriComplete||p.verificationUri,target:`_blank`,rel:`noopener noreferrer`,children:t(`settings.github.page.actions.openGithub`)})})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground animate-pulse`,children:t(`settings.github.page.flow.waiting`)}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:d,onClick:()=>{y(),m(null)},children:t(`settings.common.actions.cancel`)})]})]}),O?.available&&!O?.active&&(!O.user||O.disabled)&&(0,$.jsx)(Z,{label:t(`settings.github.page.ghCli.title`),children:(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:q(`px-4 py-3`,n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:q(`flex min-w-0 items-center gap-4`,n?`w-full`:void 0),children:[O.user?.avatarUrl?(0,$.jsx)(`img`,{src:O.user.avatarUrl,alt:O.user.login?t(`settings.github.page.avatarAlt.withLogin`,{login:O.user.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(J,{name:`github-fill`,className:`h-4 w-4 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[!O.disabled&&O.user&&(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground truncate`,children:O.user.name?.trim()||O.user.login||`GitHub`}),!O.disabled&&O.user?.login&&(0,$.jsxs)(`div`,{className:q(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:O.user.login}),O.user.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),O.user.email&&(0,$.jsx)(`span`,{children:O.user.email})]}),(0,$.jsx)(`div`,{className:q(`typography-meta text-muted-foreground`,O.disabled?`opacity-60`:void 0),children:O.disabled?t(`settings.github.page.ghCli.disabledDescription`):t(`settings.github.page.ghCli.fallbackDescription`)})]})]}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>S(!O.disabled),disabled:d,className:q(n?`w-full`:void 0),children:O.disabled?t(`settings.github.page.ghCli.actions.enable`):t(`settings.github.page.ghCli.actions.disable`)})]})})})]})},Wd=[{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)`}],Gd=[{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`}],Kd=({open:e,onOpenChange:t,profileId:n,importData:r})=>{let{t:i}=ke(),a=Ar(e=>e.getProfileById),o=Ar(e=>e.createProfile),s=Ar(e=>e.updateProfile),c=Ar(e=>e.deleteProfile),l=Q.useMemo(()=>n&&n!==`new`&&!r?a(n):null,[n,a,r]),u=n===`new`||r!=null,d=n===`global`,[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(`ssh`),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),[w,T]=Q.useState(``),[E,D]=Q.useState(``),[O,k]=Q.useState(`keyword`),[A,j]=Q.useState(`branch`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(e){if(r){let e=r.host.split(`/`),t=e.length>=3?e[e.length-1]:r.host;p(t),h(r.username),_(``),y(`token`),x(``),C(!1),T(``),D(r.host),k(`string`),j(`code`)}else if(u)p(``),h(``),_(``),y(`ssh`),x(``),C(!1),T(``),D(``),k(`keyword`),j(`branch`);else if(l)p(l.name),h(l.userName),_(l.userEmail),y(l.authType||`ssh`),x(l.sshKey||``),C(l.signCommits===!0),T(l.signingKey||``),D(l.host||``),k(l.color||`keyword`),j(l.icon||`branch`);else if(d){let e=a(`global`);e&&(p(e.name),h(e.userName),_(e.userEmail),y(e.authType||`ssh`),x(e.sshKey||``),C(!1),T(``),D(e.host||``),k(e.color||`keyword`),j(e.icon||`branch`))}}},[e,n,l,u,r,d,a]);let R=async()=>{if(!m.trim()||!g.trim()){K.error(i(`settings.gitIdentities.editor.toast.userNameEmailRequired`));return}if(v===`token`&&!E.trim()){K.error(i(`settings.gitIdentities.editor.toast.hostRequiredForToken`));return}if(S&&!w.trim()){K.error(i(`settings.gitIdentities.editor.toast.signingKeyRequired`));return}N(!0);try{let e={name:f.trim()||m.trim(),userName:m.trim(),userEmail:g.trim(),authType:v,sshKey:v===`ssh`&&b.trim()||null,signCommits:S,signingKey:w.trim()||null,host:v===`token`&&E.trim()||null,color:O,icon:A},r;if(u)r=await o(e);else if(n)r=await s(n,e);else return;r?(K.success(i(u?`settings.gitIdentities.editor.toast.profileCreated`:`settings.gitIdentities.editor.toast.profileUpdated`)),t(!1)):K.error(i(u?`settings.gitIdentities.editor.toast.createProfileFailed`:`settings.gitIdentities.editor.toast.updateProfileFailed`))}catch(e){console.error(`Error saving profile:`,e),K.error(i(`settings.gitIdentities.editor.toast.saveUnexpectedError`))}finally{N(!1)}},z=async()=>{if(!(!n||u)){L(!0);try{await c(n)?(K.success(i(`settings.gitIdentities.editor.toast.profileDeleted`)),F(!1),t(!1)):K.error(i(`settings.gitIdentities.editor.toast.deleteProfileFailed`))}catch(e){console.error(`Error deleting profile:`,e),K.error(i(`settings.gitIdentities.editor.toast.deleteUnexpectedError`))}finally{L(!1)}}},B=Q.useMemo(()=>Wd.find(e=>e.key===O)?.cssVar||`var(--syntax-keyword)`,[O]),V=r?i(`settings.gitIdentities.editor.title.importCredential`):u?i(`settings.gitIdentities.editor.title.newIdentity`):d?i(`settings.gitIdentities.editor.title.globalIdentity`):l?.name||i(`settings.gitIdentities.editor.title.editIdentity`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yt,{open:e,onOpenChange:t,children:(0,$.jsxs)(Kt,{className:`max-w-lg max-h-[85vh] overflow-y-auto`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:V}),(0,$.jsx)(Jt,{children:i(d?`settings.gitIdentities.editor.description.globalReadOnly`:u?`settings.gitIdentities.editor.description.newProfile`:`settings.gitIdentities.editor.description.editProfile`)})]}),(0,$.jsxs)(`div`,{className:`space-y-5 py-2`,children:[!d&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground block mb-1.5`,children:i(`settings.gitIdentities.editor.field.profileName`)}),(0,$.jsx)(un,{value:f,onChange:e=>p(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.profileNamePlaceholder`),className:`h-8`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.color`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:Wd.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>k(e.key),className:q(`w-6 h-6 rounded-md border-2 transition-all cursor-pointer`,O===e.key?`border-foreground scale-110`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar},title:e.label},e.key))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.icon`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:Gd.map(e=>{let t=e.Icon;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(e.key),className:q(`w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer`,A===e.key?`border-[var(--interactive-border)] bg-[var(--surface-muted)]`:`border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50`),title:e.label,children:(0,$.jsx)(J,{name:t,className:`w-3.5 h-3.5`,style:{color:A===e.key?B:`var(--surface-muted-foreground)`}})},e.key)})})]})]}),!d&&(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.userName`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.userNameTooltip`)})]})]}),(0,$.jsx)(un,{value:m,onChange:e=>h(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.userNamePlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.emailAddress`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.emailAddressTooltip`)})]})]}),(0,$.jsx)(un,{type:`email`,value:g,onChange:e=>_(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.emailAddressPlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]})]}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.authMethod`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(Y,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`ssh`,onClick:()=>y(`ssh`),children:[(0,$.jsx)(J,{name:`lock-2`,className:`w-3.5 h-3.5 mr-1`}),` SSH`]}),(0,$.jsxs)(Y,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`token`,onClick:()=>y(`token`),children:[(0,$.jsx)(J,{name:`key`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.gitIdentities.editor.field.authToken`)]})]})]}),v===`ssh`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.sshKeyPath`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.sshKeyPathTooltip`)})]})]}),(0,$.jsx)(un,{value:b,onChange:e=>x(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.sshKeyPathPlaceholder`),className:`h-8 font-mono text-xs`})]}),(0,$.jsxs)(`div`,{className:`border-t border-border/40 pt-3 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)($t,{checked:S,onChange:C,ariaLabel:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:i(`settings.gitIdentities.editor.section.commitSigning`)})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signingKey`)})}),(0,$.jsx)(un,{value:w,onChange:e=>T(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.signingKeyPlaceholder`),disabled:!S,className:`h-8 font-mono text-xs`})]})]}),v===`token`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.host`)}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.hostTooltip`)})]})]}),(0,$.jsx)(un,{value:E,onChange:e=>D(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.hostPlaceholder`),required:!0,className:`h-8 font-mono text-xs`})]})]})]})]}),(0,$.jsxs)(Gt,{className:`gap-2`,children:[!d&&!u&&(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>F(!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:[(0,$.jsx)(J,{name:`delete-bin`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.common.actions.delete`)]}),(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,children:i(d?`settings.gitIdentities.editor.actions.close`:`settings.common.actions.cancel`)}),!d&&(0,$.jsx)(Y,{size:`sm`,onClick:R,disabled:M,children:i(M?`settings.common.actions.saving`:u?`settings.gitIdentities.editor.actions.create`:`settings.gitIdentities.editor.actions.save`)})]})]})}),(0,$.jsx)(Yt,{open:P,onOpenChange:e=>{I||F(e)},children:(0,$.jsxs)(Kt,{className:`max-w-md`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:i(`settings.gitIdentities.page.deleteDialog.title`)}),(0,$.jsx)(Jt,{children:i(`settings.gitIdentities.page.deleteDialog.description`,{name:l?.name||f})})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>F(!1),disabled:I,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:()=>void z(),disabled:I,children:i(`settings.common.actions.delete`)})]})]})})]})},qd={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`},Jd={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`},Yd=()=>{let e=(0,Di.c)(116),{t}=ke(),{profiles:n,globalIdentity:r,defaultGitIdentityId:i,deleteProfile:a,loadProfiles:o,loadGlobalIdentity:s,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:l,setDefaultGitIdentityId:u,getUnimportedCredentials:d}=Ar(he(Qd)),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S,C;e[0]!==l||e[1]!==c||e[2]!==s||e[3]!==o?(S=()=>{o(),s(),c(),l()},C=[o,s,c,l],e[0]=l,e[1]=c,e[2]=s,e[3]=o,e[4]=S,e[5]=C):(S=e[4],C=e[5]),Q.useEffect(S,C);let w,T,E,D,O,k,A,j,M,N,P,F,I,L;if(e[6]!==i||e[7]!==v||e[8]!==a||e[9]!==d||e[10]!==r||e[11]!==n||e[12]!==u||e[13]!==t){let o=d(),s;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{h(e),_(t??null),p(!0)},e[28]=s):s=e[28];let c=s,l;e[29]!==i||e[30]!==u||e[31]!==t?(l=async e=>{let n=i===e?null:e;if(!await u(n)){K.error(t(`settings.gitIdentities.page.toast.updateDefaultFailed`));return}K.success(t(n?`settings.gitIdentities.page.toast.defaultUpdated`:`settings.gitIdentities.page.toast.defaultUnset`))},e[29]=i,e[30]=u,e[31]=t,e[32]=l):l=e[32];let f=l,m;e[33]!==v||e[34]!==a||e[35]!==t?(m=async()=>{v&&(x(!0),await a(v.id)?(K.success(t(`settings.gitIdentities.page.toast.profileDeleted`,{name:v.name})),y(null)):K.error(t(`settings.gitIdentities.page.toast.deleteProfileFailed`)),x(!1))},e[33]=v,e[34]=a,e[35]=t,e[36]=m):m=e[36],E=m,T=br,O=`h-full`,k=`w-full bg-background`,L=`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,e[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(Ud,{itemId:`git.github-account`}),e[37]=D):D=e[37],w=Z,A=`git.identities`;let g;e[38]===t?g=e[39]:(g=t(`settings.gitIdentities.page.section.title`),e[38]=t,e[39]=g);let b;e[40]===g?b=e[41]:(b=(0,$.jsx)(`span`,{children:g}),e[40]=g,e[41]=b);let S,C;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>c(`new`),C=(0,$.jsx)(J,{name:`add`,className:`mr-1 size-3.5`}),e[42]=S,e[43]=C):(S=e[42],C=e[43]);let R;e[44]===t?R=e[45]:(R=t(`settings.common.badge.new`),e[44]=t,e[45]=R);let z;e[46]===R?z=e[47]:(z=(0,$.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:S,children:[C,` `,R]}),e[46]=R,e[47]=z),e[48]!==b||e[49]!==z?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[b,z]}),e[48]=b,e[49]=z,e[50]=j):j=e[50],M=`flex flex-col`,N=r&&(0,$.jsx)(Xd,{profile:r,isDefault:i===`global`,onEdit:()=>c(`global`),onToggleDefault:()=>f(`global`),isReadOnly:!0,hasBorder:n.length>0||o.length>0}),P=n.map((e,t)=>(0,$.jsx)(Xd,{profile:e,isDefault:i===e.id,onEdit:()=>c(e.id),onToggleDefault:()=>f(e.id),onDelete:()=>y(e),hasBorder:t<n.length-1||o.length>0},e.id)),F=!r&&n.length===0&&o.length===0&&(0,$.jsxs)(`div`,{className:`py-8 px-4 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`shield-keyhole`,className:`mx-auto mb-2 h-8 w-8 opacity-40`}),(0,$.jsx)(`p`,{className:`typography-ui-label`,children:t(`settings.gitIdentities.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.gitIdentities.page.empty.description`)})]}),I=o.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`px-4 py-2 border-t border-[var(--surface-subtle)]`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:t(`settings.gitIdentities.page.discoveredCredentials.title`)})}),o.map((e,t)=>(0,$.jsx)(Zd,{credential:e,onImport:()=>c(`new`,{host:e.host,username:e.username}),hasBorder:t<o.length-1},`${e.host}-${e.username}`))]}),e[6]=i,e[7]=v,e[8]=a,e[9]=d,e[10]=r,e[11]=n,e[12]=u,e[13]=t,e[14]=w,e[15]=T,e[16]=E,e[17]=D,e[18]=O,e[19]=k,e[20]=A,e[21]=j,e[22]=M,e[23]=N,e[24]=P,e[25]=F,e[26]=I,e[27]=L}else w=e[14],T=e[15],E=e[16],D=e[17],O=e[18],k=e[19],A=e[20],j=e[21],M=e[22],N=e[23],P=e[24],F=e[25],I=e[26],L=e[27];let R;e[51]!==w||e[52]!==A||e[53]!==j||e[54]!==M||e[55]!==N||e[56]!==P||e[57]!==F||e[58]!==I?(R=(0,$.jsxs)(w,{itemId:A,label:j,cardClassName:M,children:[N,P,F,I]}),e[51]=w,e[52]=A,e[53]=j,e[54]=M,e[55]=N,e[56]=P,e[57]=F,e[58]=I,e[59]=R):R=e[59];let z;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Hd,{}),e[60]=z):z=e[60];let B;e[61]!==D||e[62]!==R||e[63]!==L?(B=(0,$.jsxs)(`div`,{className:L,children:[D,R,z]}),e[61]=D,e[62]=R,e[63]=L,e[64]=B):B=e[64];let V;e[65]!==T||e[66]!==O||e[67]!==k||e[68]!==B?(V=(0,$.jsx)(T,{outerClassName:O,className:k,children:B}),e[65]=T,e[66]=O,e[67]=k,e[68]=B,e[69]=V):V=e[69];let H;e[70]!==g||e[71]!==f||e[72]!==m?(H=(0,$.jsx)(Kd,{open:f,onOpenChange:p,profileId:m,importData:g}),e[70]=g,e[71]=f,e[72]=m,e[73]=H):H=e[73];let ee=v!==null,U;e[74]===b?U=e[75]:(U=e=>{b||e||y(null)},e[74]=b,e[75]=U);let te;e[76]===t?te=e[77]:(te=t(`settings.gitIdentities.page.deleteDialog.title`),e[76]=t,e[77]=te);let W;e[78]===te?W=e[79]:(W=(0,$.jsx)(qt,{children:te}),e[78]=te,e[79]=W);let ne=v?.name??``,re;e[80]!==t||e[81]!==ne?(re=t(`settings.gitIdentities.page.deleteDialog.description`,{name:ne}),e[80]=t,e[81]=ne,e[82]=re):re=e[82];let ie;e[83]===re?ie=e[84]:(ie=(0,$.jsx)(Jt,{children:re}),e[83]=re,e[84]=ie);let ae;e[85]!==W||e[86]!==ie?(ae=(0,$.jsxs)(Wt,{children:[W,ie]}),e[85]=W,e[86]=ie,e[87]=ae):ae=e[87];let oe;e[88]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>y(null),e[88]=oe):oe=e[88];let se;e[89]===t?se=e[90]:(se=t(`settings.common.actions.cancel`),e[89]=t,e[90]=se);let ce;e[91]!==b||e[92]!==se?(ce=(0,$.jsx)(Y,{variant:`ghost`,onClick:oe,disabled:b,children:se}),e[91]=b,e[92]=se,e[93]=ce):ce=e[93];let le;e[94]===E?le=e[95]:(le=()=>void E(),e[94]=E,e[95]=le);let ue;e[96]===t?ue=e[97]:(ue=t(`settings.common.actions.delete`),e[96]=t,e[97]=ue);let de;e[98]!==b||e[99]!==le||e[100]!==ue?(de=(0,$.jsx)(Y,{size:`sm`,variant:`destructive`,onClick:le,disabled:b,children:ue}),e[98]=b,e[99]=le,e[100]=ue,e[101]=de):de=e[101];let fe;e[102]!==ce||e[103]!==de?(fe=(0,$.jsxs)(Gt,{children:[ce,de]}),e[102]=ce,e[103]=de,e[104]=fe):fe=e[104];let pe;e[105]!==ae||e[106]!==fe?(pe=(0,$.jsxs)(Kt,{className:`max-w-md`,children:[ae,fe]}),e[105]=ae,e[106]=fe,e[107]=pe):pe=e[107];let me;e[108]!==ee||e[109]!==U||e[110]!==pe?(me=(0,$.jsx)(Yt,{open:ee,onOpenChange:U,children:pe}),e[108]=ee,e[109]=U,e[110]=pe,e[111]=me):me=e[111];let ge;return e[112]!==V||e[113]!==H||e[114]!==me?(ge=(0,$.jsxs)($.Fragment,{children:[V,H,me]}),e[112]=V,e[113]=H,e[114]=me,e[115]=ge):ge=e[115],ge},Xd=e=>{let t=(0,Di.c)(56),{profile:n,isDefault:r,onEdit:i,onToggleDefault:a,onDelete:o,isReadOnly:s,hasBorder:c}=e,{t:l}=ke(),[u,d]=Q.useState(!1),f=qd[n.icon||`branch`]||`git-branch`,p=Jd[n.color||``],m=n.authType||`ssh`,h;t[0]===i?h=t[1]:(h=e=>{e.currentTarget===e.target&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},t[0]=i,t[1]=h);let g=h,_;t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a||t[6]!==l?(_=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:e=>{e.stopPropagation(),a()},children:l(r?`settings.gitIdentities.page.actions.unsetDefault`:`settings.gitIdentities.page.actions.setAsDefault`)}),!s&&o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),l(`settings.common.actions.delete`)]})]}),t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=_):_=t[7];let v=_,y=c&&`border-b border-[var(--surface-subtle)]`,b;t[8]===y?b=t[9]:(b=q(`group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer`,y),t[8]=y,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),d(!0)},t[10]=x):x=t[10];let S;t[11]!==g||t[12]!==i||t[13]!==b?(S=(0,$.jsx)(`div`,{className:b,onClick:i,role:`button`,tabIndex:0,onKeyDown:g,onContextMenu:x}),t[11]=g,t[12]=i,t[13]=b,t[14]=S):S=t[14];let C;t[15]===p?C=t[16]:(C={color:p},t[15]=p,t[16]=C);let w;t[17]!==f||t[18]!==C?(w=(0,$.jsx)(J,{name:f,className:`w-4 h-4 shrink-0`,style:C}),t[17]=f,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.name?T=t[21]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n.name}),t[20]=n.name,t[21]=T);let E;t[22]===m?E=t[23]:(E=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:m}),t[22]=m,t[23]=E);let D;t[24]!==r||t[25]!==l?(D=r&&(0,$.jsx)(`span`,{className:`typography-micro text-primary bg-primary/12 px-1 rounded flex-shrink-0 leading-none pb-px border border-primary/25`,children:l(`settings.gitIdentities.page.badge.default`)}),t[24]=r,t[25]=l,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==l?(O=s&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:l(`settings.agents.sidebar.badge.system`)}),t[27]=s,t[28]=l,t[29]=O):O=t[29];let k;t[30]!==E||t[31]!==D||t[32]!==O||t[33]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D,O]}),t[30]=E,t[31]=D,t[32]=O,t[33]=T,t[34]=k):k=t[34];let A=m===`token`&&n.host?n.host:n.userEmail,j;t[35]===A?j=t[36]:(j=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:A}),t[35]=A,t[36]=j);let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==M||t[41]!==w?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[w,M]}),t[40]=M,t[41]=w,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(jn,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,onClick:$d,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[43]=P):P=t[43];let F;t[44]===v?F=t[45]:(F=(0,$.jsxs)(En,{children:[P,(0,$.jsx)(hn,{align:`end`,className:`w-fit min-w-28`,children:v(vn)})]}),t[44]=v,t[45]=F);let I;t[46]!==N||t[47]!==F||t[48]!==S?(I=(0,$.jsxs)(_i,{render:S,children:[N,F]}),t[46]=N,t[47]=F,t[48]=S,t[49]=I):I=t[49];let L;t[50]===v?L=t[51]:(L=(0,$.jsx)(vi,{className:`w-fit min-w-28`,children:v(yi)}),t[50]=v,t[51]=L);let R;return t[52]!==u||t[53]!==I||t[54]!==L?(R=(0,$.jsxs)(bi,{open:u,onOpenChange:d,children:[I,L]}),t[52]=u,t[53]=I,t[54]=L,t[55]=R):R=t[55],R},Zd=e=>{let t=(0,Di.c)(21),{credential:n,onImport:r,hasBorder:i}=e,{t:a}=ke(),o;t[0]===n.host?o=t[1]:(o=n.host.split(`/`),t[0]=n.host,t[1]=o);let s=o,c=s.length>=3?s[s.length-1]:n.host,l=n.host.includes(`/`),u=i&&`border-b border-[var(--surface-subtle)]`,d;t[2]===u?d=t[3]:(d=q(`flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30`,u),t[2]=u,t[3]=d);let f;t[4]===c?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate block`,children:c}),t[4]=c,t[5]=f);let p=l?n.host:n.username,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 truncate block leading-tight`,children:p}),t[6]=p,t[7]=m);let h;t[8]!==f||t[9]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(J,{name:`download`,className:`h-3 w-3`}),t[11]=g):g=t[11];let _;t[12]===a?_=t[13]:(_=a(`settings.gitIdentities.page.actions.import`),t[12]=a,t[13]=_);let v;t[14]!==r||t[15]!==_?(v=(0,$.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:r,className:`gap-1 shrink-0`,children:[g,_]}),t[14]=r,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==d||t[19]!==h?(y=(0,$.jsxs)(`div`,{className:d,children:[h,v]}),t[17]=v,t[18]=d,t[19]=h,t[20]=y):y=t[20],y};function Qd(e){return{profiles:e.profiles,globalIdentity:e.globalIdentity,defaultGitIdentityId:e.defaultGitIdentityId,deleteProfile:e.deleteProfile,loadProfiles:e.loadProfiles,loadGlobalIdentity:e.loadGlobalIdentity,loadDiscoveredCredentials:e.loadDiscoveredCredentials,loadDefaultGitIdentityId:e.loadDefaultGitIdentityId,setDefaultGitIdentityId:e.setDefaultGitIdentityId,getUnimportedCredentials:e.getUnimportedCredentials}}function $d(e){return e.stopPropagation()}var ef=e=>{let t=(0,Di.c)(12),{isMobile:n,itemId:r,label:i,description:a,descriptionPlacement:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&`oc-mobile-settings-detail-group`,f;t[0]===d?f=t[1]:(f=q(`oc-settings-detail-group`,d),t[0]=d,t[1]=f);let p;return t[2]!==s||t[3]!==c||t[4]!==u||t[5]!==l||t[6]!==a||t[7]!==o||t[8]!==r||t[9]!==i||t[10]!==f?(p=(0,$.jsx)(jr,{itemId:r,label:i,description:a,descriptionPlacement:o,groupClassName:f,className:c,copyClassName:l,controlClassName:u,children:s}),t[2]=s,t[3]=c,t[4]=u,t[5]=l,t[6]=a,t[7]=o,t[8]=r,t[9]=i,t[10]=f,t[11]=p):p=t[11],p},tf=e=>{let t=(0,Di.c)(9),{isMobile:n,label:r,children:i,description:a,className:o,cardClassName:s}=e,c=n&&`oc-mobile-settings-detail-group`,l;t[0]!==o||t[1]!==c?(l=q(`oc-settings-detail-group`,c,o),t[0]=o,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==s||t[4]!==i||t[5]!==a||t[6]!==r||t[7]!==l?(u=(0,$.jsx)(Z,{label:r,description:a,className:l,cardClassName:s,children:i}),t[3]=s,t[4]=i,t[5]=a,t[6]=r,t[7]=l,t[8]=u):u=t[8],u},nf=e=>{let t=(0,Di.c)(8),{isMobile:n,itemId:r,label:i,mobileLabel:a,description:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&a!==void 0?a:i,f;return t[0]!==s||t[1]!==c||t[2]!==u||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==d?(f=(0,$.jsx)(Ir,{itemId:r,label:d,description:o,className:c,copyClassName:l,controlClassName:u,children:s}),t[0]=s,t[1]=c,t[2]=u,t[3]=l,t[4]=o,t[5]=r,t[6]=d,t[7]=f):f=t[7],f},rf=e=>{let t=(0,Di.c)(17),{selected:n,onSelect:r,label:i,ariaLabel:a}=e,o;t[0]===r?o=t[1]:(o=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),r())},t[0]=r,t[1]=o);let s;t[2]!==a||t[3]!==r||t[4]!==n?(s=(0,$.jsx)(Zn,{checked:n,onChange:r,ariaLabel:a}),t[2]=a,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c=n?`text-foreground`:`text-foreground/50`,l;t[6]===c?l=t[7]:(l=q(`typography-ui-label font-normal`,c),t[6]=c,t[7]=l);let u;t[8]!==i||t[9]!==l?(u=(0,$.jsx)(`span`,{className:l,children:i}),t[8]=i,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==s||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-settings-group-row group flex cursor-pointer items-center gap-2 text-left`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:r,onKeyDown:o,children:[s,u]}),t[11]=r,t[12]=n,t[13]=o,t[14]=s,t[15]=u,t[16]=d):d=t[16],d},af=[{value:`system`,labelKey:`settings.openchamber.visual.option.themeMode.system`},{value:`light`,labelKey:`settings.openchamber.visual.option.themeMode.light`},{value:`dark`,labelKey:`settings.openchamber.visual.option.themeMode.dark`}],of=[{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`}],sf=[{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`}],cf=`OpenChamber - AI Coding Assistant`,lf=[{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`}],uf=[{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`}],df=e=>e===`portrait`||e===`landscape`?e:`system`,ff=[{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`}],pf=[{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`}],mf=[{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`}],hf=[{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`}],gf=[{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`}],_f=[{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`}],vf=[{id:`steer`,labelKey:`settings.openchamber.visual.option.followUpBehavior.steer.label`},{id:`queue`,labelKey:`settings.openchamber.visual.option.followUpBehavior.queue.label`}],yf=e=>e===`markdown`?`markdown`:`plain`,bf=({visibleSettings:e,mobile:t})=>{let{locale:n,locales:r,setLocale:i,label:a,t:s}=ke(),d=Q.useCallback(e=>s(e),[s]),{isMobile:p}=fr(),h=t??p,{browserTab:g}=ni(),_=I(),v=u(e=>e.showReasoningTraces),y=u(e=>e.sessionTitleRefreshEnabled),S=u(e=>e.setSessionTitleRefreshEnabled),C=u(e=>e.sessionGoalEnabled),T=u(e=>e.setSessionGoalEnabled),E=u(e=>e.sessionGoalDefaultBudgetEnabled),D=u(e=>e.setSessionGoalDefaultBudgetEnabled),O=u(e=>e.sessionGoalDefaultBudget),k=u(e=>e.setSessionGoalDefaultBudget),j=u(e=>e.setShowReasoningTraces),M=u(e=>e.collapsibleThinkingBlocks),N=u(e=>e.setCollapsibleThinkingBlocks),P=u(e=>e.mermaidRenderingMode),F=u(e=>e.setMermaidRenderingMode),R=u(e=>e.userMessageRenderingMode),z=u(e=>e.setUserMessageRenderingMode),H=u(e=>e.collapsibleUserMessages),ee=u(e=>e.setCollapsibleUserMessages),U=u(e=>e.stickyUserHeader),te=u(e=>e.promptNavigatorEnabled),W=u(e=>e.setStickyUserHeader),ne=u(e=>e.setPromptNavigatorEnabled),re=u(e=>e.expandedEditorToolbar),ie=u(e=>e.setExpandedEditorToolbar),ae=gr(e=>e.enabled),oe=gr(e=>e.setEnabled),se=u(e=>e.wideChatLayoutEnabled),ce=u(e=>e.setWideChatLayoutEnabled),le=u(e=>e.codeBlockLineWrap),ue=u(e=>e.setCodeBlockLineWrap),de=u(e=>e.chatRenderMode),fe=u(e=>e.setChatRenderMode),pe=u(e=>e.activityRenderMode),me=u(e=>e.setActivityRenderMode),he=u(e=>e.fontSize),ge=u(e=>e.setFontSize),_e=u(e=>e.codeFontSize),ve=u(e=>e.setCodeFontSize),ye=u(e=>e.terminalFontSize),be=u(e=>e.setTerminalFontSize),xe=u(e=>e.editorFontSize),Se=u(e=>e.setEditorFontSize),Ce=u(e=>e.uiFont),we=u(e=>e.setUiFont),Te=u(e=>e.monoFont),Ee=u(e=>e.setMonoFont),De=u(e=>e.padding),Oe=u(e=>e.setPadding),Ae=u(e=>e.inputBarOffset),je=u(e=>e.setInputBarOffset),Me=u(e=>e.mobileKeyboardMode),Ne=u(e=>e.setMobileKeyboardMode),Pe=u(e=>e.diffLayoutPreference),Fe=u(e=>e.setDiffLayoutPreference),Ie=u(e=>e.showTerminalQuickKeysOnDesktop),Le=u(e=>e.setShowTerminalQuickKeysOnDesktop),Re=u(e=>e.fileEditorKeymap),ze=u(e=>e.setFileEditorKeymap),Be=x(e=>e.followUpBehavior),Ve=x(e=>e.setFollowUpBehavior),He=u(e=>e.persistChatDraft),Ue=u(e=>e.setPersistChatDraft),We=u(e=>e.inputSpellcheckEnabled),Ge=u(e=>e.setInputSpellcheckEnabled),Ke=u(e=>e.showToolFileIcons),qe=u(e=>e.setShowToolFileIcons),Je=u(e=>e.showTurnChangedFiles),Ye=u(e=>e.setShowTurnChangedFiles),Xe=u(e=>e.showExpandedBashTools),Ze=u(e=>e.setShowExpandedBashTools),Qe=u(e=>e.showSubagentTaskDetails),$e=u(e=>e.setShowSubagentTaskDetails),et=u(e=>e.timeFormatPreference),tt=u(e=>e.setTimeFormatPreference),rt=u(e=>e.weekStartPreference),it=u(e=>e.setWeekStartPreference),at=u(e=>e.showSplitAssistantMessageActions),ot=u(e=>e.setShowSplitAssistantMessageActions),st=u(e=>e.showAssistantTps),ct=u(e=>e.setShowAssistantTps),lt=ti(e=>e.sidebarBrandName),ut=ti(e=>e.setSidebarBrandName),dt=u(e=>e.allowPromptingSubagentSessions),ft=u(e=>e.setAllowPromptingSubagentSessions),pt=G(e=>e.settingsMessageStreamTransport),mt=G(e=>e.setSettingsMessageStreamTransport),ht=pt,gt=G(e=>e.settingsDefaultFileViewerPreview),_t=G(e=>e.setSettingsDefaultFileViewerPreview),vt=u(e=>e.isSettingsDialogOpen),{themeMode:yt,setThemeMode:bt,availableThemes:xt,customThemesLoading:St,reloadCustomThemes:Ct,lightThemeId:wt,darkThemeId:Tt,setLightThemePreference:Et,setDarkThemePreference:Dt}=dr(),[Ot,kt]=Q.useState(!1),[At,jt]=Q.useState(!1),[Mt,Nt]=Q.useState(!1),Pt=Q.useMemo(()=>w()&&typeof window<`u`&&window.__OPENCHAMBER_ELECTRON__?.macVibrancySupported===!0,[]),Ft=typeof window<`u`&&window.__OPENCHAMBER_ELECTRON__?.macVibrancy===!0,[It,Lt]=Q.useState(Ft),[Rt,zt]=Q.useState(!1),Bt=Q.useMemo(()=>w()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`darwin`,[]),Vt=u(e=>e.dockBadgeEnabled),Ht=u(e=>e.setDockBadgeEnabled),[Ut,Xt]=Q.useState(0),Zt=u(e=>e.reportUsage),Qt=u(e=>e.setReportUsage),tn=Q.useCallback(e=>{Qt(e),V({reportUsage:e})},[Qt]),an=vt&&(!e||e.includes(`chatRenderMode`));Q.useEffect(()=>{if(!an)return;let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=420&&(Xt(e=>(e+1)%24),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[an]);let sn=Q.useCallback(e=>{z(e),V({userMessageRenderingMode:e})},[z]),cn=Q.useCallback(e=>{W(e),V({stickyUserHeader:e})},[W]),mn=Q.useCallback(e=>{ne(e),V({promptNavigatorEnabled:e})},[ne]),hn=Q.useCallback(e=>{ie(e),V({expandedEditorToolbar:e})},[ie]),gn=Q.useCallback(e=>{ee(e),V({collapsibleUserMessages:e})},[ee]),_n=Q.useCallback(e=>{ce(e),V({wideChatLayoutEnabled:e})},[ce]),vn=Q.useCallback(e=>{ot(e),V({showSplitAssistantMessageActions:e})},[ot]),yn=Q.useCallback(e=>{ct(e),V({showAssistantTps:e})},[ct]),bn=Q.useCallback(e=>{Ge(e),V({inputSpellcheckEnabled:e})},[Ge]),xn=Q.useCallback(e=>{fe(e),V({chatRenderMode:e})},[fe]),Sn=Q.useCallback(e=>{mt(e),V({messageStreamTransport:e})},[mt]),Cn=Q.useCallback(e=>{me(e),V({activityRenderMode:e})},[me]),wn=Q.useCallback(e=>{F(e),V({mermaidRenderingMode:e})},[F]),Tn=Q.useCallback(e=>{qe(e),V({showToolFileIcons:e})},[qe]),En=Q.useCallback(e=>{Ye(e),V({showTurnChangedFiles:e})},[Ye]),Dn=Q.useCallback(e=>{_t(e),V({defaultFileViewerPreview:e}),window.dispatchEvent(new CustomEvent(`openchamber:file-viewer-preview-mode-changed`,{detail:{enabled:e}}))},[_t]),On=Q.useCallback(e=>{Ze(e),V({showExpandedBashTools:e})},[Ze]),kn=Q.useCallback(e=>{$e(e),V({showSubagentTaskDetails:e})},[$e]),An=Q.useCallback(e=>{tt(e),V({timeFormatPreference:e})},[tt]),jn=Q.useCallback(e=>{it(e),V({weekStartPreference:e})},[it]),Mn=Q.useMemo(()=>xt.filter(e=>e.metadata.variant===`light`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[xt]),Nn=Q.useMemo(()=>xt.filter(e=>e.metadata.variant===`dark`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[xt]),Pn=Q.useMemo(()=>Mn.find(e=>e.metadata.id===wt)??Mn[0],[Mn,wt]),Fn=Q.useMemo(()=>Nn.find(e=>e.metadata.id===Tt)??Nn[0],[Nn,Tt]),In=Q.useCallback((e,t)=>{let n=t===`dark`?` Dark`:` Light`;return e.endsWith(n)?e.slice(0,-n.length):e},[]),X=t=>t===`splitAssistantMessageActions`||t===`showToolFileIcons`?!1:!e||e.includes(t),Ln=async()=>{if(!Mt){Nt(!0);try{await nt(),jt(!1),K.success(s(`settings.openchamber.visual.transcriptCache.toast.cleared`))}catch{K.error(s(`settings.openchamber.visual.transcriptCache.toast.failed`))}finally{Nt(!1)}}},Rn=m(),zn=hr(),Bn=X(`theme`)&&!Rn,Vn=X(`theme`)||X(`timeFormat`)||X(`weekStart`),Hn=Rn?Vn||X(`sidebarBrand`):X(`theme`)||X(`sidebarBrand`)||X(`pwaInstallName`)||X(`pwaOrientation`)||X(`mobileKeyboardMode`)||X(`timeFormat`)||X(`weekStart`)||zn,Un=X(`fontSize`)||X(`codeFontSize`)||X(`terminalFontSize`)||X(`editorFontSize`)||X(`spacing`)||X(`inputBarOffset`),Wn=X(`terminalQuickKeys`)&&!h||X(`fileEditorKeymap`)||X(`expandedEditorToolbar`),Gn=X(`mermaidRendering`)||X(`userMessageRendering`)||X(`chatRenderMode`)||X(`messageTransport`)||X(`activityRenderMode`)&&de===`sorted`||X(`collapsibleUserMessages`)||X(`stickyUserHeader`)||X(`promptNavigatorEnabled`)&&!Rn||X(`wideChatLayout`)||X(`codeBlockLineWrap`)||X(`splitAssistantMessageActions`)||X(`showAssistantTps`)||X(`subagentReadOnlyBanner`)||X(`diffLayout`)||X(`dotfiles`)||X(`fileViewerPreview`)||X(`reasoning`)||X(`followUpBehavior`)||X(`persistDraft`)||X(`showToolFileIcons`)||X(`showSubagentTaskDetails`)||X(`expandedTools`)||!h&&X(`inputSpellcheck`),Kn=X(`pwaInstallName`)&&A()&&g&&!w()&&!Rn,qn=X(`pwaOrientation`)&&A()&&!w()&&!Rn,Jn=X(`mobileKeyboardMode`)&&A()&&!w()&&!Rn&&o(),[Yn,Xn]=Q.useState(``),[Zn,Qn]=Q.useState(`system`),$n=Q.useMemo(()=>{let e=gf.find(e=>e.id===et);return d(e?.labelKey??`settings.openchamber.visual.option.timeFormat.auto.label`)},[et,d]),er=Q.useMemo(()=>{let e=_f.find(e=>e.id===rt);return d(e?.labelKey??`settings.openchamber.visual.option.weekStart.auto.label`)},[rt,d]),tr=Q.useMemo(()=>{let e=lf.find(e=>e.id===Zn);return e?d(e.labelKey):void 0},[Zn,d]),nr=Q.useMemo(()=>{let e=uf.find(e=>e.id===Me);return e?d(e.labelKey):void 0},[Me,d]),rr=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=e.trim().replace(/\s+/g,` `).slice(0,64);if(await V({pwaAppName:n}),typeof t.__OPENCHAMBER_SET_PWA_INSTALL_NAME__==`function`){let e=t.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(n);Xn(e);return}Xn(n||cf),t.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),ir=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=df(e);if(await V({pwaOrientation:n}),typeof t.__OPENCHAMBER_SET_PWA_ORIENTATION__==`function`){let e=t.__OPENCHAMBER_SET_PWA_ORIENTATION__(n);Qn(e);return}Qn(n),t.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);return Q.useEffect(()=>{if(typeof window>`u`||!Kn&&!qn&&!Jn)return;let e=!1;return(async()=>{try{let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok){e||Xn(cf);return}let n=await t.json().catch(()=>({})),r=(typeof n?.pwaAppName==`string`?n.pwaAppName:``).trim().replace(/\s+/g,` `).slice(0,64),i=df(n?.pwaOrientation),a=l(n?.mobileKeyboardMode);e||(Kn&&Xn(r||cf),qn&&Qn(i),Jn&&Ne(a))}catch{e||(Kn&&Xn(cf),qn&&Qn(`system`),Jn&&Ne(`native`))}})(),()=>{e=!0}},[Ne,Jn,Kn,qn]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[Hn&&(0,$.jsxs)($.Fragment,{children:[Bn&&(0,$.jsxs)(tf,{isMobile:h,label:(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:s(`settings.openchamber.visual.section.colorMode`)}),(0,$.jsxs)(`div`,{className:`inline-flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"data-settings-item":`appearance.reload-themes`,disabled:St||Ot,onClick:()=>{let e=Date.now();kt(!0),Ct().finally(()=>{let t=Date.now()-e;if(t<500){window.setTimeout(()=>{kt(!1)},500-t);return}kt(!1)})},className:`inline-flex items-center typography-micro font-normal text-muted-foreground underline decoration-[1px] underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:text-muted-foreground/60`,children:s(Ot?`settings.openchamber.visual.actions.reloadingThemes`:`settings.openchamber.visual.actions.reloadThemes`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex items-center justify-center rounded-md p-0.5 text-muted-foreground/70 hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.field.themeImportInfoAria`),children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(fn,{sideOffset:8,children:s(`settings.openchamber.visual.field.themeImportInfoTooltip`)})]})]})]}),children:[(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.color-mode`,label:s(`settings.openchamber.visual.field.themeMode`),children:(0,$.jsx)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,role:`group`,"aria-label":s(`settings.openchamber.visual.field.themeMode`),children:af.map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":yt===e.value,className:`oc-mobile-settings-chip shrink-0 !font-normal`,onClick:()=>bt(e.value),children:d(e.labelKey)},e.value))})}),(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.light-theme`,label:s(`settings.openchamber.visual.field.lightTheme`),children:(0,$.jsxs)(on,{value:Pn?.metadata.id??``,onValueChange:Et,children:[(0,$.jsx)(nn,{"aria-label":s(`settings.openchamber.visual.field.selectLightThemeAria`),className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:s(`settings.openchamber.visual.field.selectThemePlaceholder`),children:Pn?In(Pn.metadata.name,`light`):void 0})}),(0,$.jsx)(rn,{children:Mn.map(e=>(0,$.jsx)(en,{value:e.metadata.id,children:In(e.metadata.name,`light`)},e.metadata.id))})]})}),(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.dark-theme`,label:s(`settings.openchamber.visual.field.darkTheme`),children:(0,$.jsxs)(on,{value:Fn?.metadata.id??``,onValueChange:Dt,children:[(0,$.jsx)(nn,{"aria-label":s(`settings.openchamber.visual.field.selectDarkThemeAria`),className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:s(`settings.openchamber.visual.field.selectThemePlaceholder`),children:Fn?In(Fn.metadata.name,`dark`):void 0})}),(0,$.jsx)(rn,{children:Nn.map(e=>(0,$.jsx)(en,{value:e.metadata.id,children:In(e.metadata.name,`dark`)},e.metadata.id))})]})}),Pt&&(0,$.jsxs)(`div`,{"data-settings-item":`appearance.window-transparency`,className:`oc-settings-group-row flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":It,onClick:()=>{Rt||Lt(!It)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Rt||Lt(!It))},children:[(0,$.jsx)($t,{checked:It,onChange:Lt,disabled:Rt,ariaLabel:s(`settings.openchamber.visual.field.macVibrancy`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.macVibrancy`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s(`settings.openchamber.visual.field.macVibrancyHint`)})]})]}),It!==Ft&&(0,$.jsx)(`div`,{className:`pl-6`,children:(0,$.jsx)(Y,{variant:`outline`,size:`sm`,disabled:Rt,onClick:()=>{zt(!0),B(`desktop_set_vibrancy`,{enabled:It})},children:s(Rt?`settings.openchamber.visual.actions.restarting`:`settings.openchamber.visual.actions.saveAndRestart`)})})]}),Bt&&(0,$.jsx)(`div`,{"data-settings-item":`appearance.dock-badge`,className:`oc-settings-group-row flex flex-col gap-1.5`,children:(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Vt,onClick:()=>Ht(!Vt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Ht(!Vt))},children:[(0,$.jsx)($t,{checked:Vt,onChange:Ht,ariaLabel:s(`settings.openchamber.visual.field.dockBadge`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.dockBadge`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s(`settings.openchamber.visual.field.dockBadgeHint`)})]})]})})]}),zn&&(0,$.jsx)(tf,{isMobile:h,children:(0,$.jsx)(Hr,{itemId:`appearance.ios-native-ui`,checked:ae,onChange:oe,label:s(`settings.openchamber.visual.field.iosNativeUi`),description:s(`settings.openchamber.visual.field.iosNativeUiHint`),ariaLabel:s(`settings.openchamber.visual.field.iosNativeUi`)})}),Vn&&(0,$.jsxs)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.localization`),children:[(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.language`,label:s(`settings.appearance.language.label`),description:s(`settings.appearance.language.description`),children:(0,$.jsxs)(on,{value:n,onValueChange:e=>i(e),children:[(0,$.jsx)(nn,{"aria-label":s(`settings.appearance.language.select`),className:`w-fit`,children:(0,$.jsx)(ln,{children:a(n)})}),(0,$.jsx)(rn,{children:r.map(e=>(0,$.jsx)(en,{value:e,children:a(e)},e))})]})}),(X(`timeFormat`)||X(`weekStart`))&&(0,$.jsxs)($.Fragment,{children:[X(`timeFormat`)&&(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.time-format`,label:s(`settings.openchamber.visual.field.timeFormat`),children:(0,$.jsxs)(on,{value:et,onValueChange:e=>An(e),children:[(0,$.jsx)(nn,{"aria-label":s(`settings.openchamber.visual.field.selectTimeFormatAria`),className:`w-fit`,children:(0,$.jsx)(ln,{children:$n})}),(0,$.jsx)(rn,{children:gf.map(e=>(0,$.jsx)(en,{value:e.id,children:d(e.labelKey)},e.id))})]})}),X(`weekStart`)&&(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.week-start`,label:s(`settings.openchamber.visual.field.weekStartsOn`),children:(0,$.jsxs)(on,{value:rt,onValueChange:e=>jn(e),children:[(0,$.jsx)(nn,{"aria-label":s(`settings.openchamber.visual.field.selectWeekStartAria`),className:`w-fit`,children:(0,$.jsx)(ln,{children:er})}),(0,$.jsx)(rn,{children:_f.map(e=>(0,$.jsx)(en,{value:e.id,children:d(e.labelKey)},e.id))})]})})]})]}),X(`sidebarBrand`)&&(0,$.jsx)(ef,{isMobile:h,itemId:`appearance.sidebar-brand`,label:s(`settings.openchamber.visual.field.sidebarBrand`),description:s(`settings.openchamber.visual.field.sidebarBrandHint`),descriptionPlacement:`outside`,children:(0,$.jsx)(un,{value:lt,onChange:e=>ut(e.target.value),maxLength:64,"aria-label":s(`settings.openchamber.visual.field.sidebarBrandAria`)})}),(Kn||qn||Jn)&&(0,$.jsxs)($.Fragment,{children:[Kn&&(0,$.jsxs)(ef,{isMobile:h,itemId:`appearance.pwa-install-name`,label:s(`settings.openchamber.visual.field.installAppName`),description:s(`settings.openchamber.visual.field.installAppNameHint`),children:[(0,$.jsx)(un,{value:Yn,onChange:e=>{Xn(e.target.value)},onBlur:()=>{rr(Yn)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),rr(Yn))},maxLength:64,"aria-label":s(`settings.openchamber.visual.field.pwaInstallAppNameAria`)}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Xn(cf),rr(``)},className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetInstallAppNameAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),qn&&(0,$.jsxs)(ef,{isMobile:h,itemId:`appearance.pwa-orientation`,label:s(`settings.openchamber.visual.field.installOrientation`),description:s(`settings.openchamber.visual.field.installOrientationHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(on,{value:Zn,onValueChange:e=>{let t=df(e);Qn(t),ir(t)},children:[(0,$.jsx)(nn,{"aria-label":s(`settings.openchamber.visual.field.pwaInstallOrientationAria`),className:`w-full`,children:(0,$.jsx)(ln,{placeholder:s(`settings.openchamber.visual.field.selectOrientationPlaceholder`),children:tr})}),(0,$.jsx)(rn,{children:lf.map(e=>(0,$.jsx)(en,{value:e.id,children:d(e.labelKey)},e.id))})]}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Qn(`system`),ir(`system`)},disabled:Zn===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetInstallOrientationAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Jn&&(0,$.jsxs)(ef,{isMobile:h,itemId:`appearance.mobile-keyboard-mode`,label:s(`settings.openchamber.visual.field.mobileKeyboardMode`),description:s(`settings.openchamber.visual.field.mobileKeyboardModeHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(on,{value:Me,onValueChange:e=>{let t=l(e);Ne(t),V({mobileKeyboardMode:t})},children:[(0,$.jsx)(nn,{"aria-label":s(`settings.openchamber.visual.field.mobileKeyboardModeAria`),className:`w-full`,children:(0,$.jsx)(ln,{placeholder:s(`settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder`),children:nr})}),(0,$.jsx)(rn,{children:uf.map(e=>(0,$.jsx)(en,{value:e.id,children:d(e.labelKey)},e.id))})]}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Ne(`native`),V({mobileKeyboardMode:`native`})},disabled:Me===`native`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetMobileKeyboardModeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})]}),Un&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.spacingAndLayout`),children:(0,$.jsxs)($.Fragment,{children:[X(`fontSize`)&&!h&&(0,$.jsxs)(nf,{isMobile:h,label:s(`settings.openchamber.visual.field.interfaceFont`),children:[(0,$.jsxs)(on,{value:Ce,onValueChange:e=>we(e),children:[(0,$.jsx)(nn,{"aria-label":s(`settings.openchamber.visual.field.selectInterfaceFontAria`),className:`w-[13rem]`,children:(0,$.jsx)(ln,{children:f.find(e=>e.id===Ce)?.label})}),(0,$.jsx)(rn,{children:f.map(e=>(0,$.jsx)(en,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>we(`system`),disabled:Ce===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetInterfaceFontAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`terminalFontSize`)&&(0,$.jsxs)(nf,{isMobile:h,itemId:`appearance.code-font`,label:s(`settings.openchamber.visual.field.codeFont`),children:[(0,$.jsxs)(on,{value:Te,onValueChange:e=>Ee(e),children:[(0,$.jsx)(nn,{"aria-label":s(`settings.openchamber.visual.field.selectCodeFontAria`),className:`w-full max-w-[13rem]`,children:(0,$.jsx)(ln,{children:c.find(e=>e.id===Te)?.label})}),(0,$.jsx)(rn,{children:c.map(e=>(0,$.jsx)(en,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Ee(`system-mono`),disabled:Te===`system-mono`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetCodeFontAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`fontSize`)&&(0,$.jsxs)(nf,{isMobile:h,itemId:`appearance.interface-font-size`,label:s(`settings.openchamber.visual.field.interfaceFontSize`),children:[(0,$.jsx)(Br,{value:he,onValueChange:ge,min:50,max:200,step:5,"aria-label":s(`settings.openchamber.visual.field.fontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ge(100),disabled:he===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetFontSizeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`codeFontSize`)&&(0,$.jsxs)(nf,{isMobile:h,itemId:`appearance.code-font-size`,label:s(`settings.openchamber.visual.field.codeFontSize`),children:[(0,$.jsx)(Br,{value:_e,onValueChange:ve,min:50,max:200,step:5,"aria-label":s(`settings.openchamber.visual.field.codeFontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ve(100),disabled:_e===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetCodeFontSizeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`terminalFontSize`)&&(0,$.jsxs)(nf,{isMobile:h,itemId:`appearance.terminal-font-size`,label:s(`settings.openchamber.visual.field.terminalFontSize`),children:[(0,$.jsx)(Br,{value:ye,onValueChange:be,min:9,max:52,step:1,className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>be(13),disabled:ye===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetTerminalFontSizeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`editorFontSize`)&&(0,$.jsxs)(nf,{isMobile:h,itemId:`appearance.editor-font-size`,label:s(`settings.openchamber.visual.field.editorFontSize`),children:[(0,$.jsx)(Br,{value:xe,onValueChange:Se,min:9,max:32,step:1,className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Se(13),disabled:xe===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetEditorFontSizeAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`spacing`)&&(0,$.jsxs)(nf,{isMobile:h,itemId:`appearance.spacing-density`,label:s(`settings.openchamber.visual.field.spacingDensity`),children:[(0,$.jsx)(Br,{value:De,onValueChange:Oe,min:50,max:200,step:5,className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Oe(100),disabled:De===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetSpacingAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]}),X(`inputBarOffset`)&&(0,$.jsxs)(nf,{isMobile:h,itemId:`appearance.input-bar-offset`,label:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:s(`settings.openchamber.visual.field.inputBarOffset`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:s(`settings.openchamber.visual.field.inputBarOffsetTooltip`)})]})]}),children:[(0,$.jsx)(Br,{value:Ae,onValueChange:je,min:0,max:100,step:5,className:`w-16`}),(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>je(0),disabled:Ae===0,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":s(`settings.openchamber.visual.actions.resetInputBarOffsetAria`),title:s(`settings.common.actions.reset`),children:(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})})}),Wn&&(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.navigation`),children:[X(`fileEditorKeymap`)&&(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.file-editor-keymap`,label:s(`settings.openchamber.visual.field.fileEditorKeymap`),children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.field.fileEditorKeymap`),className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-1`,children:[`default`,`vim`].map(e=>{let t=Re===e,n=s(`settings.openchamber.visual.option.fileEditorKeymap.${e}`);return(0,$.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-2 py-0.5 text-left`,role:`radio`,"aria-checked":t,onClick:()=>ze(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:q(`relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full transition-[background-color,box-shadow] duration-200 ease-out`,t?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)]`),children:(0,$.jsx)(`span`,{className:q(`block h-[5px] w-[5px] rounded-full bg-white`,!t&&`opacity-0`)})}),(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/50`),children:n})]},e)})})}),X(`expandedEditorToolbar`)&&(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.expanded-editor-toolbar`,label:s(`settings.openchamber.visual.field.expandedEditorToolbar`),children:(0,$.jsx)($t,{checked:re,onChange:hn,ariaLabel:s(`settings.openchamber.visual.field.expandedEditorToolbarAria`)})}),X(`terminalQuickKeys`)&&!h&&!w()&&(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.terminal-quick-keys`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:s(`settings.openchamber.visual.field.terminalQuickKeys`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:s(`settings.openchamber.visual.field.terminalQuickKeysTooltip`)})]})]}),children:(0,$.jsx)($t,{checked:Ie,onChange:Le,ariaLabel:s(`settings.openchamber.visual.field.terminalQuickKeysAria`)})})]})}),Gn&&(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(X(`userMessageRendering`)||X(`mermaidRendering`)||X(`chatRenderMode`)||X(`messageTransport`)||X(`activityRenderMode`)&&de===`sorted`||X(`diffLayout`)&&!Rn||X(`followUpBehavior`))&&(0,$.jsxs)(`div`,{className:`grid w-full grid-cols-1 gap-y-[var(--oc-settings-section-stack-gap)]`,children:[X(`chatRenderMode`)&&(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.chatRenderMode`),className:`w-full`,cardClassName:`!border-0 !bg-transparent !rounded-none overflow-visible`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.render-mode`,className:`min-w-0 w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.chatRenderModeAria`),className:`grid w-full grid-cols-1 gap-3 sm:grid-cols-2`,children:pf.map(e=>{let t=de===e.id,n=Ut%12;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>xn(e.id),"aria-pressed":t,className:q(`flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors`,t?`border-primary bg-primary/5`:`border-border hover:border-border/80 hover:bg-muted/50`),children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label`,t?`text-foreground`:`text-muted-foreground`),children:d(e.labelKey)}),(0,$.jsx)(`div`,{className:`mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2`,children:e.id===`live`?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=e*3+1,r=n-t+1,i=r<=0?0:r===1?42:r===2?68:92;return(0,$.jsxs)(`div`,{className:q(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,i>0?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none`,style:{width:`${i}%`}})]},e)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=n>=(e+1)*3;return(0,$.jsxs)(`div`,{className:q(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,t?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30`,style:{width:`92%`}})]},e)})})})]},e.id)})})})}),X(`messageTransport`)&&(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.messageStreamTransport`),className:`w-full`,children:(0,$.jsxs)(`div`,{"data-settings-item":`chat.message-transport`,className:`oc-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:mf.map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":ht===e.id,className:`!font-normal`,onClick:()=>Sn(e.id),children:d(e.labelKey)},e.id))}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:(()=>{let e=mf.find(e=>e.id===ht);return e?.descriptionKey?d(e.descriptionKey):``})()})]})}),X(`activityRenderMode`)&&de===`sorted`&&(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.activityDefault`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.activityDefaultAria`),children:hf.map(e=>{let t=pe===e.id;return(0,$.jsx)(rf,{selected:t,onSelect:()=>Cn(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.activityDefaultModeAria`,{option:d(e.labelKey)})},e.id)})})}),X(`expandedTools`)&&(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.showToolsOpenedByDefault`),className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":Xe,onClick:()=>On(!Xe),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),On(!Xe))},children:[(0,$.jsx)($t,{checked:Xe,onChange:On,ariaLabel:s(`settings.openchamber.visual.field.showExpandedBashToolsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.bash`)})]})}),X(`userMessageRendering`)&&(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.userMessageRendering`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.userMessageRenderingAria`),children:ff.map(e=>{let t=yf(R)===e.id;return(0,$.jsx)(rf,{selected:t,onSelect:()=>sn(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.userMessageRenderingAria`,{option:d(e.labelKey)})},e.id)})})}),X(`mermaidRendering`)&&(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.mermaidRendering`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.mermaidRenderingAria`),children:sf.map(e=>{let t=P===e.id;return(0,$.jsx)(rf,{selected:t,onSelect:()=>wn(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.mermaidRenderingAria`,{option:d(e.labelKey)})},e.id)})})}),X(`diffLayout`)&&!Rn&&(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.diffLayout`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.diffLayoutAria`),children:of.map(e=>{let t=Pe===e.id;return(0,$.jsx)(rf,{selected:t,onSelect:()=>Fe(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.diffLayoutAria`,{option:d(e.labelKey)})},e.id)})})}),X(`followUpBehavior`)&&(0,$.jsx)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.followUpBehavior`),className:`w-full`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.follow-up-behavior`,role:`radiogroup`,"aria-label":s(`settings.openchamber.visual.section.followUpBehaviorAria`),children:vf.map(e=>{let t=Be===e.id;return(0,$.jsx)(rf,{selected:t,onSelect:()=>Ve(e.id),label:d(e.labelKey),ariaLabel:s(`settings.openchamber.visual.field.followUpBehaviorAria`,{option:d(e.labelKey)})},e.id)})})})]}),X(`sessionGoal`)&&!Rn&&(0,$.jsxs)(tf,{isMobile:h,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:s(`settings.openchamber.visual.goal.sectionTitle`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-sm`,children:s(`settings.openchamber.visual.goal.description`)})]})]}),children:[(0,$.jsx)(nf,{isMobile:h,itemId:`chat.session-goal`,label:s(`settings.openchamber.visual.field.sessionGoal`),children:(0,$.jsx)($t,{checked:C,onChange:T,ariaLabel:s(`settings.openchamber.visual.field.sessionGoalAria`)})}),(0,$.jsxs)(nf,{isMobile:h,itemId:`chat.session-goal-budget`,label:s(`settings.openchamber.visual.goal.budgetLabel`),children:[(0,$.jsx)($t,{checked:E,onChange:D,disabled:!C,ariaLabel:s(`settings.openchamber.visual.goal.budgetAria`)}),C&&E?(0,$.jsx)(Br,{value:O,onValueChange:e=>{typeof e==`number`&&Number.isFinite(e)&&e>0&&k(Math.floor(e))},min:1e3,max:1e8,step:5e4}):null]})]}),(X(`sessionAssist`)||X(`collapsibleUserMessages`)||X(`stickyUserHeader`)||X(`promptNavigatorEnabled`)&&!Rn||X(`wideChatLayout`)||X(`codeBlockLineWrap`)||X(`splitAssistantMessageActions`)||X(`showAssistantTps`)||X(`subagentReadOnlyBanner`)||X(`dotfiles`)||X(`fileViewerPreview`)||X(`persistDraft`)||X(`showToolFileIcons`)||X(`showSubagentTaskDetails`)||X(`showTurnChangedFiles`)||!h&&X(`inputSpellcheck`)||X(`reasoning`))&&(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(X(`sessionAssist`)||X(`subagentReadOnlyBanner`))&&(0,$.jsxs)(tf,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.session-assistance`,children:s(`settings.openchamber.visual.section.sessionAssistance`)}),children:[X(`sessionAssist`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.session-title-refresh`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>S(!y),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),S(!y))},children:[(0,$.jsx)($t,{checked:y,onChange:S,ariaLabel:s(`settings.openchamber.visual.field.sessionTitleRefreshAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.sessionTitleRefresh`)})]}),X(`subagentReadOnlyBanner`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.subagent-read-only-banner`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":dt,onClick:()=>ft(!dt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ft(!dt))},children:[(0,$.jsx)($t,{checked:dt,onChange:ft,ariaLabel:s(`settings.openchamber.visual.field.allowPromptingSubagentSessionsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.allowPromptingSubagentSessions`)})]})]}),X(`reasoning`)&&(0,$.jsxs)(tf,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.reasoning`,children:s(`settings.openchamber.visual.section.reasoning`)}),children:[X(`reasoning`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.reasoning-traces`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":v,onClick:()=>j(!v),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),j(!v))},children:[(0,$.jsx)($t,{checked:v,onChange:j,ariaLabel:s(`settings.openchamber.visual.field.showReasoningTracesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showReasoningTraces`)})]}),X(`reasoning`)&&v&&(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":M,onClick:()=>N(!M),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),N(!M))},children:[(0,$.jsx)($t,{checked:M,onChange:N,ariaLabel:s(`settings.openchamber.visual.field.collapsibleThinkingBlocksAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.collapsibleThinkingBlocks`)})]})]}),(X(`collapsibleUserMessages`)||X(`stickyUserHeader`)||X(`promptNavigatorEnabled`)&&!Rn||X(`wideChatLayout`)||X(`splitAssistantMessageActions`)||X(`showAssistantTps`)||X(`codeBlockLineWrap`))&&(0,$.jsxs)(tf,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.message-appearance`,children:s(`settings.openchamber.visual.section.messageAppearance`)}),children:[X(`collapsibleUserMessages`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.collapsible-user-messages`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":H,onClick:()=>gn(!H),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),gn(!H))},children:[(0,$.jsx)($t,{checked:H,onChange:gn,ariaLabel:s(`settings.openchamber.visual.field.collapsibleUserMessagesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.collapsibleUserMessages`)})]}),X(`stickyUserHeader`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.sticky-user-header`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":U,onClick:()=>cn(!U),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),cn(!U))},children:[(0,$.jsx)($t,{checked:U,onChange:cn,ariaLabel:s(`settings.openchamber.visual.field.stickyUserHeaderAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.stickyUserHeader`)})]}),X(`promptNavigatorEnabled`)&&!Rn&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.prompt-navigator`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":te,onClick:()=>mn(!te),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),mn(!te))},children:[(0,$.jsx)($t,{checked:te,onChange:mn,ariaLabel:s(`settings.openchamber.visual.field.promptNavigatorEnabledAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.promptNavigatorEnabled`)})]}),X(`wideChatLayout`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.wide-layout`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":se,onClick:()=>_n(!se),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),_n(!se))},children:[(0,$.jsx)($t,{checked:se,onChange:_n,ariaLabel:s(`settings.openchamber.visual.field.wideChatLayoutAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.wideChatLayout`)})]}),X(`splitAssistantMessageActions`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.inline-assistant-actions`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":at,onClick:()=>vn(!at),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),vn(!at))},children:[(0,$.jsx)($t,{checked:at,onChange:vn,ariaLabel:s(`settings.openchamber.visual.field.showSplitAssistantMessageActionsAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showSplitAssistantMessageActions`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:s(`settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip`)})]})]})]}),X(`showAssistantTps`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.assistant-tps`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":st,onClick:()=>yn(!st),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),yn(!st))},children:[(0,$.jsx)($t,{checked:st,onChange:yn,ariaLabel:s(`settings.openchamber.visual.field.showAssistantTpsAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showAssistantTps`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:s(`settings.openchamber.visual.field.showAssistantTpsTooltip`)})]})]})]}),X(`codeBlockLineWrap`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.code-block-line-wrap`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":le,onClick:()=>ue(!le),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ue(!le))},children:[(0,$.jsx)($t,{checked:le,onChange:ue,ariaLabel:s(`settings.openchamber.visual.field.codeBlockLineWrapAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.codeBlockLineWrap`)})]})]}),(X(`showToolFileIcons`)||X(`showTurnChangedFiles`)||X(`dotfiles`)||X(`fileViewerPreview`))&&(0,$.jsxs)(tf,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.tools-and-files`,children:s(`settings.openchamber.visual.section.toolsAndFiles`)}),children:[X(`showToolFileIcons`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.tool-file-icons`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Ke,onClick:()=>Tn(!Ke),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Tn(!Ke))},children:[(0,$.jsx)($t,{checked:Ke,onChange:Tn,ariaLabel:s(`settings.openchamber.visual.field.showToolFileIconsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showToolFileIcons`)})]}),X(`showSubagentTaskDetails`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.subagent-task-details`,className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Qe,onClick:()=>kn(!Qe),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),kn(!Qe))},children:[(0,$.jsx)($t,{checked:Qe,onChange:kn,ariaLabel:s(`settings.openchamber.visual.field.showSubagentTaskDetailsAria`),className:`mt-0.5`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showSubagentTaskDetails`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s(`settings.openchamber.visual.field.showSubagentTaskDetailsHint`)})]})]}),X(`showTurnChangedFiles`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.changed-files`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Je,onClick:()=>En(!Je),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),En(!Je))},children:[(0,$.jsx)($t,{checked:Je,onChange:En,ariaLabel:s(`settings.openchamber.visual.field.showTurnChangedFilesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showTurnChangedFiles`)})]}),X(`dotfiles`)&&!m()&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.dotfiles`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":_,onClick:()=>b(!_),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(!_))},children:[(0,$.jsx)($t,{checked:_,onChange:b,ariaLabel:s(`settings.openchamber.visual.field.showDotfilesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.showDotfiles`)})]}),X(`fileViewerPreview`)&&(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":gt,onClick:()=>Dn(!gt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Dn(!gt))},children:[(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)($t,{checked:gt,onChange:Dn,ariaLabel:s(`settings.openchamber.defaults.field.openFilesPreviewAria`)})}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.defaults.field.openFilesPreview`)})]})]}),(X(`persistDraft`)||!h&&X(`inputSpellcheck`))&&(0,$.jsxs)(tf,{isMobile:h,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.composer`,children:s(`settings.openchamber.visual.section.composer`)}),children:[X(`persistDraft`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.persist-drafts`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":He,onClick:()=>Ue(!He),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Ue(!He))},children:[(0,$.jsx)($t,{checked:He,onChange:Ue,ariaLabel:s(`settings.openchamber.visual.field.persistDraftMessagesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.persistDraftMessages`)})]}),!h&&X(`inputSpellcheck`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.spellcheck`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":We,onClick:()=>bn(!We),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),bn(!We))},children:[(0,$.jsx)($t,{checked:We,onChange:bn,ariaLabel:s(`settings.openchamber.visual.field.enableSpellcheckInTextInputsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:s(`settings.openchamber.visual.field.enableSpellcheckInTextInputs`)})]})]})]})]}),X(`reportUsage`)&&(0,$.jsxs)(tf,{isMobile:h,label:s(`settings.openchamber.visual.section.privacy`),children:[X(`reportUsage`)&&(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.usage-reports`,label:s(`settings.openchamber.visual.field.sendAnonymousUsageReports`),description:s(`settings.openchamber.visual.field.sendAnonymousUsageReportsHint`),children:(0,$.jsx)($t,{checked:Zt,onChange:tn,ariaLabel:s(`settings.openchamber.visual.field.sendAnonymousUsageReportsAria`)})}),X(`reportUsage`)&&(0,$.jsx)(nf,{isMobile:h,itemId:`appearance.transcript-cache`,label:s(`settings.openchamber.visual.transcriptCache.label`),description:s(`settings.openchamber.visual.transcriptCache.description`),children:(0,$.jsx)(Y,{type:`button`,variant:`destructive`,size:`sm`,disabled:Mt,onClick:()=>jt(!0),children:s(`settings.openchamber.visual.transcriptCache.action`)})})]})]}),(0,$.jsx)(Yt,{open:At,onOpenChange:e=>{Mt||jt(e)},children:(0,$.jsxs)(Kt,{className:`max-w-[min(480px,100vw-2rem)]`,children:[(0,$.jsxs)(Wt,{children:[(0,$.jsx)(qt,{children:s(`settings.openchamber.visual.transcriptCache.dialog.title`)}),(0,$.jsx)(Jt,{children:s(`settings.openchamber.visual.transcriptCache.dialog.description`)})]}),(0,$.jsxs)(Gt,{children:[(0,$.jsx)(Y,{type:`button`,variant:`ghost`,disabled:Mt,onClick:()=>jt(!1),children:s(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{type:`button`,variant:`destructive`,disabled:Mt,"aria-busy":Mt||void 0,onClick:()=>void Ln(),children:s(Mt?`settings.openchamber.visual.transcriptCache.dialog.clearing`:`settings.openchamber.visual.transcriptCache.action`)})]})]})})]})},xf=1,Sf=365,Cf=30,wf=[{value:`archive`,labelKey:`settings.openchamber.sessionRetention.action.archive`},{value:`delete`,labelKey:`settings.openchamber.sessionRetention.action.delete`}],Tf=()=>{let e=(0,Di.c)(128),{t}=ke(),n=u(Ef),r=u(Df),i=u(Of),a=u(kf),o=u(Af),s=u(jf),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={autoRun:!1},e[0]=c):c=e[0];let{candidates:l,isRunning:d,runCleanup:f,action:p}=nr(c),m=l.length,h=st(Mf),g=u(Nf),_;e[1]!==f||e[2]!==t?(_=async()=>{let e=await f({force:!0});if(e.completedIds.length===0&&e.failedIds.length===0){K.message(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.noneEligibleArchive`):t(`settings.openchamber.sessionRetention.toast.noneEligibleDelete`));return}e.completedIds.length>0&&K.success(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.archivedCount`,{count:e.completedIds.length}):t(`settings.openchamber.sessionRetention.toast.deletedCount`,{count:e.completedIds.length})),e.failedIds.length>0&&K.error(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.failedArchiveCount`,{count:e.failedIds.length}):t(`settings.openchamber.sessionRetention.toast.failedDeleteCount`,{count:e.failedIds.length}))},e[1]=f,e[2]=t,e[3]=_):_=e[3];let v=_,y;e[4]===t?y=e[5]:(y=t(`settings.openchamber.sessionRetention.title`),e[4]=t,e[5]=y);let b;e[6]===y?b=e[7]:(b=(0,$.jsx)(`span`,{children:y}),e[6]=y,e[7]=b);let x;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),e[8]=x):x=e[8];let S;e[9]===t?S=e[10]:(S=t(`settings.openchamber.sessionRetention.tooltip`),e[9]=t,e[10]=S);let C;e[11]===S?C=e[12]:(C=(0,$.jsxs)(pn,{children:[x,(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:S})]}),e[11]=S,e[12]=C);let w;e[13]!==b||e[14]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,C]}),e[13]=b,e[14]=C,e[15]=w):w=e[15];let T,E;e[16]!==n||e[17]!==a?(T=()=>a(!n),E=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),a(!n))},e[16]=n,e[17]=a,e[18]=T,e[19]=E):(T=e[18],E=e[19]);let D;e[20]===t?D=e[21]:(D=t(`settings.openchamber.sessionRetention.field.enableAutoCleanup`),e[20]=t,e[21]=D);let O;e[22]===D?O=e[23]:(O=(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:D})}),e[22]=D,e[23]=O);let k;e[24]===t?k=e[25]:(k=t(`settings.openchamber.sessionRetention.field.enableAutoCleanupAria`),e[24]=t,e[25]=k);let A;e[26]!==n||e[27]!==a||e[28]!==k?(A=(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)($t,{checked:n,onChange:a,ariaLabel:k})}),e[26]=n,e[27]=a,e[28]=k,e[29]=A):A=e[29];let j;e[30]!==n||e[31]!==O||e[32]!==A||e[33]!==T||e[34]!==E?(j=(0,$.jsxs)(`div`,{"data-settings-item":`sessions.auto-cleanup`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:T,onKeyDown:E,children:[O,A]}),e[30]=n,e[31]=O,e[32]=A,e[33]=T,e[34]=E,e[35]=j):j=e[35];let M;e[36]===t?M=e[37]:(M=t(`settings.openchamber.sessionRetention.field.retentionPeriod`),e[36]=t,e[37]=M);let N;e[38]===t?N=e[39]:(N=t(`settings.openchamber.sessionRetention.field.retentionPeriodAria`),e[38]=t,e[39]=N);let P;e[40]!==r||e[41]!==o||e[42]!==N?(P=(0,$.jsx)(Br,{value:r,onValueChange:o,min:xf,max:Sf,step:1,"aria-label":N,className:`w-20 tabular-nums`}),e[40]=r,e[41]=o,e[42]=N,e[43]=P):P=e[43];let F;e[44]===t?F=e[45]:(F=t(`settings.openchamber.sessionRetention.field.days`),e[44]=t,e[45]=F);let I;e[46]===F?I=e[47]:(I=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:F}),e[46]=F,e[47]=I);let L;e[48]===o?L=e[49]:(L=()=>o(Cf),e[48]=o,e[49]=L);let R=r===Cf,z;e[50]===t?z=e[51]:(z=t(`settings.openchamber.sessionRetention.actions.resetRetentionAria`),e[50]=t,e[51]=z);let B;e[52]===t?B=e[53]:(B=t(`settings.common.actions.reset`),e[52]=t,e[53]=B);let V;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(J,{name:`restart`,className:`h-3.5 w-3.5`}),e[54]=V):V=e[54];let H;e[55]!==L||e[56]!==R||e[57]!==z||e[58]!==B?(H=(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:L,disabled:R,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":z,title:B,children:V}),e[55]=L,e[56]=R,e[57]=z,e[58]=B,e[59]=H):H=e[59];let ee;e[60]!==M||e[61]!==P||e[62]!==I||e[63]!==H?(ee=(0,$.jsxs)(Ir,{itemId:`sessions.retention-period`,label:M,children:[P,I,H]}),e[60]=M,e[61]=P,e[62]=I,e[63]=H,e[64]=ee):ee=e[64];let U;e[65]===t?U=e[66]:(U=t(`settings.openchamber.sessionRetention.field.whenSessionsExpire`),e[65]=t,e[66]=U);let te;e[67]!==i||e[68]!==s||e[69]!==t?(te=wf.map(e=>(0,$.jsx)(Y,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":i===e.value,className:`!font-normal`,onClick:()=>s(e.value),children:t(e.labelKey)},e.value)),e[67]=i,e[68]=s,e[69]=t,e[70]=te):te=e[70];let W;e[71]===te?W=e[72]:(W=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:te}),e[71]=te,e[72]=W);let ne;e[73]!==U||e[74]!==W?(ne=(0,$.jsx)(Ir,{itemId:`sessions.retention-action`,label:U,children:W}),e[73]=U,e[74]=W,e[75]=ne):ne=e[75];let re;e[76]!==j||e[77]!==ee||e[78]!==ne||e[79]!==w?(re=(0,$.jsxs)(Z,{label:w,children:[j,ee,ne]}),e[76]=j,e[77]=ee,e[78]=ne,e[79]=w,e[80]=re):re=e[80];let ie;e[81]===t?ie=e[82]:(ie=t(`settings.openchamber.sessionRetention.manualCleanup.title`),e[81]=t,e[82]=ie);let ae;e[83]!==p||e[84]!==m||e[85]!==t?(ae=t(p===`archive`?`settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow`:`settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow`,{count:m}),e[83]=p,e[84]=m,e[85]=t,e[86]=ae):ae=e[86];let oe;e[87]!==d||e[88]!==t?(oe=t(d?`settings.openchamber.sessionRetention.actions.cleaningUp`:`settings.openchamber.sessionRetention.actions.runCleanupNow`),e[87]=d,e[88]=t,e[89]=oe):oe=e[89];let se;e[90]!==v||e[91]!==d||e[92]!==oe?(se=(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,onClick:v,disabled:d,className:`!font-normal`,children:oe}),e[90]=v,e[91]=d,e[92]=oe,e[93]=se):se=e[93];let ce;e[94]!==ie||e[95]!==ae||e[96]!==se?(ce=(0,$.jsx)(jr,{label:ie,description:ae,descriptionPlacement:`outside`,children:se}),e[94]=ie,e[95]=ae,e[96]=se,e[97]=ce):ce=e[97];let le;e[98]===t?le=e[99]:(le=t(`settings.openchamber.archivedSessions.title`),e[98]=t,e[99]=le);let ue;e[100]!==h||e[101]!==t?(ue=t(h===1?`settings.openchamber.archivedSessions.summarySingle`:`settings.openchamber.archivedSessions.summaryPlural`,{count:h}),e[100]=h,e[101]=t,e[102]=ue):ue=e[102];let de;e[103]===ue?de=e[104]:(de=(0,$.jsx)(`span`,{className:`block`,children:ue}),e[103]=ue,e[104]=de);let fe;e[105]===t?fe=e[106]:(fe=t(`settings.openchamber.archivedSessions.description`),e[105]=t,e[106]=fe);let pe;e[107]===fe?pe=e[108]:(pe=(0,$.jsx)(`span`,{className:`block`,children:fe}),e[107]=fe,e[108]=pe);let me;e[109]!==de||e[110]!==pe?(me=(0,$.jsxs)($.Fragment,{children:[de,pe]}),e[109]=de,e[110]=pe,e[111]=me):me=e[111];let he;e[112]===g?he=e[113]:(he=()=>g(!0),e[112]=g,e[113]=he);let ge;e[114]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(J,{name:`archive`,className:`mr-1 h-3.5 w-3.5`}),e[114]=ge):ge=e[114];let _e;e[115]===t?_e=e[116]:(_e=t(`settings.openchamber.archivedSessions.actions.manage`),e[115]=t,e[116]=_e);let ve;e[117]!==he||e[118]!==_e?(ve=(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,onClick:he,className:`!font-normal`,children:[ge,_e]}),e[117]=he,e[118]=_e,e[119]=ve):ve=e[119];let ye;e[120]!==le||e[121]!==me||e[122]!==ve?(ye=(0,$.jsx)(jr,{itemId:`sessions.archived`,label:le,description:me,descriptionPlacement:`outside`,children:ve}),e[120]=le,e[121]=me,e[122]=ve,e[123]=ye):ye=e[123];let be;return e[124]!==re||e[125]!==ce||e[126]!==ye?(be=(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[re,ce,ye]}),e[124]=re,e[125]=ce,e[126]=ye,e[127]=be):be=e[127],be};function Ef(e){return e.autoDeleteEnabled}function Df(e){return e.autoDeleteAfterDays}function Of(e){return e.sessionRetentionAction}function kf(e){return e.setAutoDeleteEnabled}function Af(e){return e.setAutoDeleteAfterDays}function jf(e){return e.setSessionRetentionAction}function Mf(e){return e.archivedSessions.length}function Nf(e){return e.setArchivedSessionsDialogOpen}var Pf=(e,t,n)=>!e||!Number.isFinite(e)?t:new Intl.DateTimeFormat(Ae(),{dateStyle:`medium`,timeStyle:`short`,hour12:n===`auto`?void 0:n===`12h`}).format(e),Ff=()=>{let{t:e}=ke(),t=u(e=>e.timeFormatPreference),[n,r]=Q.useState(!1),[i,a]=Q.useState(!0),[o,s]=Q.useState(!1),[c,l]=Q.useState(null),[d,f]=Q.useState(!1),[p,m]=Q.useState([]),[h,g]=Q.useState(tr),[_,v]=Q.useState(``),y=Q.useMemo(()=>ir(),[]),b=Q.useCallback(async()=>{a(!0),v(``);try{let e=await Jn();m(e)}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.loadFailed`);v(n)}finally{a(!1)}},[e]);Q.useEffect(()=>{let e=!1;return(async()=>{try{if(!y.supported){e||(r(!1),a(!1));return}e||r(!0)}catch{e||r(!1)}if(!e){let e=await X();if(g(e),!e.enabled){m([]),a(!1);return}await b()}})(),()=>{e=!0,Xn()}},[b,y.supported]);let x=Q.useCallback(async()=>{if(!h.enabled){let t=e(`settings.openchamber.passkeys.toast.enableUiPasswordFirst`);v(t),K.message(t);return}if(!n){v(y.reason),K.message(y.reason);return}if(o){Xn(),s(!1);return}v(``),s(!0);try{await Bn(),g(await X()),await b(),K.success(e(`settings.openchamber.passkeys.toast.added`))}catch(t){if(Ln(t)){K.message(e(`settings.openchamber.passkeys.toast.setupCanceled`));return}let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.addFailed`);v(n),K.error(n)}finally{s(!1)}},[o,b,h.enabled,y.reason,n,e]),S=Q.useCallback(async t=>{l(t),v(``);try{await Yn(t),g(await X()),await b(),K.success(e(`settings.openchamber.passkeys.toast.removed`))}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.removeFailed`);v(n),K.error(n)}finally{l(null)}},[b,e]),C=Q.useCallback(async()=>{f(!0),v(``);try{await Qn(),window.location.reload()}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.clearAuthFailed`);v(n),K.error(n),f(!1)}},[e]);return(0,$.jsxs)(Z,{label:e(`settings.openchamber.passkeys.title`),children:[(0,$.jsx)(Ir,{label:e(`settings.openchamber.passkeys.field.currentDevice`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:o?`secondary`:`outline`,size:`xs`,onClick:()=>void x(),disabled:i||d,className:`!font-normal`,children:e(o?`settings.openchamber.passkeys.actions.cancelSetup`:`settings.openchamber.passkeys.actions.add`)}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void C(),disabled:i||o||d,className:`!font-normal text-muted-foreground hover:text-foreground`,children:e(d?`settings.openchamber.passkeys.actions.signingOut`:`settings.openchamber.passkeys.actions.signOutEverywhere`)})]})}),!h.enabled&&(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.uiPasswordRequired`)}),h.enabled&&!n&&(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:y.reason}),i?(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.loading`)}):p.length===0?(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.noneSaved`)}):(0,$.jsx)($.Fragment,{children:p.map(n=>(0,$.jsx)(Ir,{label:n.label,copyClassName:`truncate`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:n.lastUsedAt?e(`settings.openchamber.passkeys.item.lastUsed`,{time:Pf(n.lastUsedAt,e(`settings.openchamber.passkeys.time.neverUsed`),t)}):e(`settings.openchamber.passkeys.item.added`,{time:Pf(n.createdAt,e(`settings.openchamber.passkeys.time.neverUsed`),t)})}),(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void S(n.id),disabled:c===n.id,className:`!font-normal text-muted-foreground hover:text-foreground`,children:c===n.id?e(`settings.openchamber.passkeys.actions.removing`):e(`settings.common.actions.delete`)})]})},n.id))}),_&&(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:_})})]})},If=e=>mt(e)||{providerId:``,modelId:``},Lf=()=>{let{t:e}=ke(),t=G(e=>e.setProvider),n=G(e=>e.setModel),r=G(e=>e.setAgent),i=G(e=>e.setCurrentVariant),a=G(e=>e.setSettingsDefaultModel),o=G(e=>e.setSettingsDefaultVariant),s=G(e=>e.setSettingsDefaultAgent),c=u(e=>e.showDeletionDialog),l=u(e=>e.setShowDeletionDialog),d=G(e=>e.providers),[f,p]=Q.useState(),[m,h]=Q.useState(),[g,_]=Q.useState(),[v,y]=Q.useState(!0),b=Q.useMemo(()=>If(f),[f]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=U()?.settings;if(t)try{let n=(await t.load())?.settings;if(n){let t=n;e={defaultModel:typeof n.defaultModel==`string`?n.defaultModel:void 0,defaultVariant:typeof t.defaultVariant==`string`?t.defaultVariant:void 0,defaultAgent:typeof n.defaultAgent==`string`?n.defaultAgent:void 0}}}catch{}}if(!e){let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}if(e){let t=typeof e.defaultModel==`string`&&e.defaultModel.trim().length>0?e.defaultModel.trim():void 0,n=typeof e.defaultVariant==`string`&&e.defaultVariant.trim().length>0?e.defaultVariant.trim():void 0,r=typeof e.defaultAgent==`string`&&e.defaultAgent.trim().length>0?e.defaultAgent.trim():void 0;t!==void 0&&p(t),n!==void 0&&h(n),r!==void 0&&_(r)}}catch(e){console.warn(`Failed to load defaults settings:`,e)}finally{y(!1)}})()},[]);let x=Q.useCallback(async(e,r)=>{let s=e&&r?`${e}/${r}`:void 0;p(s),h(void 0),o(void 0),i(void 0),a(s),e&&r&&d.find(t=>t.id===e)&&(t(e),n(r));try{await V({defaultModel:s??``,defaultVariant:``});let e=await L(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultModel:s})});e.ok||console.warn(`Failed to save default model to server:`,e.status,e.statusText)}catch(e){console.warn(`Failed to save default model:`,e)}},[d,i,n,t,a,o]),S=`__default__`,C=Q.useCallback(t=>t===S?e(`settings.openchamber.defaults.option.default`):t.charAt(0).toUpperCase()+t.slice(1),[e]),w=Q.useCallback(async e=>{let t=e===S?void 0:e||void 0;h(t),o(t),i(t);try{await V({defaultVariant:t??``})}catch(e){console.warn(`Failed to save default variant:`,e)}},[i,o]),T=Q.useCallback(async e=>{let t=e||void 0;_(t),s(t),e&&r(e);try{await V({defaultAgent:t??``})}catch(e){console.warn(`Failed to save default agent:`,e)}},[r,s]),E=Q.useMemo(()=>{if(!b.providerId||!b.modelId)return[];let e=d.find(e=>e.id===b.providerId)?.models.find(e=>e.id===b.modelId)?.variants;return e?Object.keys(e):[]},[b.modelId,b.providerId,d]),D=E.length>0;return Q.useEffect(()=>{!D&&m&&(h(void 0),o(void 0),i(void 0),V({defaultVariant:``}).catch(()=>{}))},[m,i,o,D]),v?null:(0,$.jsxs)(Z,{label:e(`settings.openchamber.defaults.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.openchamber.defaults.summaryPrefix`),` `,b.providerId?(0,$.jsxs)(`span`,{className:`text-foreground`,children:[b.providerId,`/`,b.modelId,D?` (${m??e(`settings.openchamber.defaults.option.defaultLowercase`)})`:``]}):(0,$.jsx)(`span`,{className:`text-foreground`,children:e(`settings.openchamber.defaults.summaryOpenCodeDefault`)}),g&&(0,$.jsxs)($.Fragment,{children:[` / `,(0,$.jsx)(`span`,{className:`text-foreground`,children:g})]})]}),children:[(0,$.jsx)(Ir,{itemId:`sessions.default-model`,label:e(`settings.openchamber.defaults.field.defaultModel`),children:(0,$.jsx)(An,{providerId:b.providerId,modelId:b.modelId,onChange:x,className:`oc-settings-inline-value`})}),(0,$.jsx)(Ir,{itemId:`sessions.default-thinking`,label:e(`settings.openchamber.defaults.field.defaultThinking`),children:(0,$.jsxs)(on,{value:m??S,onValueChange:w,disabled:!D,children:[(0,$.jsx)(nn,{className:`w-fit min-w-[120px]`,children:(0,$.jsx)(ln,{placeholder:e(`settings.openchamber.defaults.field.thinkingPlaceholder`),children:C(m??S)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:S,children:e(`settings.openchamber.defaults.option.default`)}),E.map(e=>(0,$.jsx)(en,{value:e,children:C(e)},e))]})]})}),(0,$.jsx)(Ir,{itemId:`sessions.default-agent`,label:e(`settings.openchamber.defaults.field.defaultAgent`),children:(0,$.jsx)(Sn,{agentName:g||``,onChange:T,className:`oc-settings-inline-value`})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.deletion-dialog`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":c,onClick:()=>l(!c),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(!c))},children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.defaults.field.showDeletionDialog`)})}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)($t,{checked:c,onChange:l,ariaLabel:e(`settings.openchamber.defaults.field.showDeletionDialogAria`)})})]})]})},Rf=`You are generating a Conventional Commits subject line from the diffs of the selected files.`,zf=[`You are a title generator. Output ONLY a thread title.`,`Name the main subject of the work.`,`Keep that subject across follow-ups, polish, commit, push, tidy, and review.`,`Switch only when the user clearly starts a different topic.`,`One line, ≤50 characters, no explanation.`,`Prefer ≤6 words or ≤6 CJK characters. No modifiers. No verbs.`,`Use the language of the user messages.`,`Keep technical terms, numbers, filenames, and HTTP codes exact.`,`Never include tool names, summarizing, or generating.`,`Always output a meaningful title.`].join(`
|
|
25
|
+
`),Bf=()=>{let{t:e}=ke(),{currentTheme:t}=dr(),n=G(e=>e.providers),[r,i]=Q.useState(`provider`),[a,o]=Q.useState(``),[s,c]=Q.useState(``),[l,u]=Q.useState(``),[d,f]=Q.useState(``),[p,m]=Q.useState(!1),[h,g]=Q.useState(Rf),[_,v]=Q.useState(zf),[y,b]=Q.useState(null),[x,S]=Q.useState(!0),[C,w]=Q.useState(!1),T=Q.useMemo(()=>[ai(t,{syntaxColors:!1})],[t]);Q.useEffect(()=>{let e=!0;return(async()=>{try{let t=null,n=U()?.settings;if(n){let e=(await n.load())?.settings;e&&(t=e)}if(!t){let e=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(t=await e.json())}if(!e||!t)return;t.summaryModelMode&&i(t.summaryModelMode),typeof t.summaryProviderID==`string`&&o(t.summaryProviderID),typeof t.summaryModelID==`string`&&c(t.summaryModelID),typeof t.summaryCustomBaseURL==`string`&&u(t.summaryCustomBaseURL),typeof t.hasSummaryCustomAPIToken==`boolean`&&m(t.hasSummaryCustomAPIToken),g(t.summaryCommitPrompt??Rf),v(t.summarySessionTitlePrompt??zf)}catch(e){console.warn(`Failed to load summary settings:`,e)}finally{e&&S(!1)}})(),()=>{e=!1}},[]),Q.useEffect(()=>{let e=!0;return(async()=>{try{let t=await L(`/api/small-model`,{method:`GET`,headers:{Accept:`application/json`}}),n=await t.json().catch(()=>null);if(!t.ok||!n?.callableModels||typeof n.callableModels!=`object`)throw Error(`Summary provider capabilities are unavailable`);let r=Object.fromEntries(Object.entries(n.callableModels).map(([e,t])=>[e,Array.isArray(t)?t.filter(e=>typeof e==`string`):[]]).filter(([,e])=>e.length>0));e&&b(r)}catch{e&&b({})}})(),()=>{e=!1}},[]);let E=Q.useMemo(()=>n.find(e=>e.id===`openai`)??n[0],[n]);Q.useEffect(()=>{!a&&E?.id&&o(E.id)},[E?.id,a]),Q.useEffect(()=>{if(!y)return;let e=Object.keys(y);if(e.length===0)return;let t=y[a]?a:y.openai?`openai`:e[0],n=y[t]??[],r=n.includes(s)?s:n[0]??``;t!==a&&o(t),r!==s&&c(r)},[y,s,a]);let D=Q.useCallback(async()=>{w(!0);try{let e={summaryModelMode:r,summaryProviderID:a.trim(),summaryModelID:s.trim(),summaryCustomBaseURL:l,summaryCommitPrompt:h,summarySessionTitlePrompt:_};d.trim()&&(e.summaryCustomAPIToken=d),await V(e),d.trim()&&m(!0),f(``)}catch(e){console.warn(`Failed to save summary settings:`,e)}finally{w(!1)}},[h,d,l,s,r,a,_]),O=Q.useCallback(async()=>{w(!0);try{await V({summaryCustomAPIToken:``}),f(``),m(!1)}catch(e){console.warn(`Failed to clear summary API token:`,e)}finally{w(!1)}},[]);return x?null:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(Z,{label:e(`settings.openchamber.defaults.summary.title`),description:e(`settings.openchamber.defaults.summary.description`),children:[(0,$.jsx)(Ir,{itemId:`summary-ai.configuration`,label:e(`settings.openchamber.defaults.summary.modelSourceTitle`),className:`oc-settings-summary-model-source-row`,controlClassName:`items-start`,children:(0,$.jsxs)(`div`,{role:`radiogroup`,"aria-label":e(`settings.openchamber.defaults.summary.modelSourceAria`),className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,$.jsx)(Zn,{checked:r===`provider`,onChange:()=>i(`provider`),ariaLabel:e(`settings.openchamber.defaults.summary.provider`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:r===`provider`?`typography-ui-label text-foreground`:`typography-ui-label text-foreground/50`,children:e(`settings.openchamber.defaults.summary.provider`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.openchamber.defaults.summary.providerDescription`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,$.jsx)(Zn,{checked:r===`custom`,onChange:()=>i(`custom`),ariaLabel:e(`settings.openchamber.defaults.summary.custom`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:r===`custom`?`typography-ui-label text-foreground`:`typography-ui-label text-foreground/50`,children:e(`settings.openchamber.defaults.summary.custom`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.openchamber.defaults.summary.customDescription`)})]})]})]})}),r===`provider`?(0,$.jsx)(Ir,{label:e(`settings.openchamber.defaults.summary.providerModel`),children:y===null?null:Object.keys(y).length>0?(0,$.jsx)(An,{providerId:a,modelId:s,onChange:(e,t)=>{o(e),c(t)},allowedProviderIds:Object.keys(y),allowedModelIdsByProvider:y,className:`oc-settings-inline-value`}):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.defaults.summary.providerUnavailable`)})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ir,{label:e(`settings.openchamber.defaults.summary.baseUrl`),children:(0,$.jsx)(un,{value:l,onChange:e=>u(e.target.value),placeholder:e(`settings.openchamber.defaults.summary.baseUrlPlaceholder`)})}),(0,$.jsx)(Ir,{label:e(`settings.openchamber.defaults.summary.modelId`),children:(0,$.jsx)(un,{value:s,onChange:e=>c(e.target.value),placeholder:e(`settings.openchamber.defaults.summary.modelIdPlaceholder`)})}),(0,$.jsx)(Ir,{label:e(`settings.openchamber.defaults.summary.apiToken`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(un,{type:`password`,value:d,onChange:e=>f(e.target.value),placeholder:e(p?`settings.openchamber.defaults.summary.apiTokenStored`:`settings.openchamber.defaults.summary.apiTokenPlaceholder`),className:`max-w-xl`}),p?(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void O(),disabled:C,children:e(`settings.openchamber.defaults.summary.clearToken`)}):null]})})]})]}),(0,$.jsxs)(Z,{label:e(`settings.openchamber.defaults.summary.promptTitle`),children:[(0,$.jsx)(Ir,{label:e(`settings.openchamber.defaults.summary.commitPrompt`),description:e(`settings.openchamber.defaults.summary.commitPromptDescription`),className:`oc-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(`div`,{className:`h-64 w-full overflow-hidden bg-background`,children:(0,$.jsx)(Er,{value:h,onChange:g,extensions:T,className:`h-full`,enableSearch:!0})})}),(0,$.jsx)(Ir,{label:e(`settings.openchamber.defaults.summary.sessionTitlePrompt`),description:e(`settings.openchamber.defaults.summary.sessionTitlePromptDescription`),className:`oc-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(`div`,{className:`h-64 w-full overflow-hidden bg-background`,children:(0,$.jsx)(Er,{value:_,onChange:v,extensions:T,className:`h-full`,enableSearch:!0})})}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center justify-end`,children:(0,$.jsx)(Y,{size:`sm`,onClick:()=>void D(),disabled:C,children:e(C?`settings.common.actions.saving`:`settings.openchamber.defaults.summary.save`)})})]})]})},Vf={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`}},Hf={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`},Uf=()=>{let{t:e}=ke(),t=Q.useMemo(()=>w(),[]),n=Q.useMemo(()=>m(),[]),r=Q.useMemo(()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,[]),i=!t&&!n&&!r,a=u(e=>e.nativeNotificationsEnabled),o=u(e=>e.setNativeNotificationsEnabled),s=u(e=>e.notificationMode),c=u(e=>e.setNotificationMode),l=u(e=>e.notifyOnSubtasks),d=u(e=>e.setNotifyOnSubtasks),f=u(e=>e.notifyOnCompletion),p=u(e=>e.setNotifyOnCompletion),h=u(e=>e.notifyOnError),g=u(e=>e.setNotifyOnError),_=u(e=>e.notifyOnQuestion),v=u(e=>e.setNotifyOnQuestion),y=u(e=>e.notifyOnPermission),b=u(e=>e.setNotifyOnPermission),x=u(e=>e.notifyOnScheduledTasks),S=u(e=>e.setNotifyOnScheduledTasks),C=u(e=>e.notifyOnAssistants),T=u(e=>e.setNotifyOnAssistants),E=u(e=>e.notifyOnGoals),D=u(e=>e.setNotifyOnGoals),O=u(e=>e.notificationTemplates),k=u(e=>e.setNotificationTemplates),[A,j]=Q.useState(`default`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(!i){N(!1),F(!1);return}typeof Notification<`u`&&j(Notification.permission);let e=typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window;N(e),(async()=>{if(!e){F(!1);return}try{let e=await navigator.serviceWorker.getRegistration();if(!e){F(!1);return}let t=await e.pushManager.getSubscription();F(!!t)}catch{F(!1)}})()},[i]);let R=async n=>{if(t){o(n);return}if(!i){o(n);return}if(n&&typeof Notification<`u`&&Notification.permission==="default")try{let t=await Notification.requestPermission();j(t),t===`granted`?o(!0):K.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.description`)})}catch(t){console.error(`Failed to request notification permission:`,t),K.error(e(`settings.notifications.page.toast.requestPermissionFailed`))}else o(!!(n&&A===`granted`))},z=t||n||r||i&&typeof Notification<`u`&&Notification.permission===`granted`,B=(e,t,n)=>{k({...O,[e]:{...O[e],[t]:n}})},V=e=>{let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r},H=async(e,t,n)=>{let r=null,i=new Promise((e,i)=>{r=setTimeout(()=>{i(Error(n))},t)});try{return await Promise.race([e,i])}finally{r&&clearTimeout(r)}},ee=async e=>{if(e.active)return;let t=e.installing||e.waiting;t&&t.state!==`activated`&&await H(new Promise(e=>{let n=()=>{t.state===`activated`&&(t.removeEventListener(`statechange`,n),e())};t.addEventListener(`statechange`,n),n()}),15e3,`Service worker activation timed out`)},te=async()=>{if(typeof navigator.serviceWorker.register!=`function`)throw Error(`navigator.serviceWorker.register unavailable`);let e=[{label:`no-options`,opts:null},{label:`scope-root`,opts:{scope:`/`}},{label:`type-classic`,opts:{type:`classic`}},{label:`type-classic-scope`,opts:{type:`classic`,scope:`/`}},{label:`updateViaCache-none`,opts:{type:`classic`,updateViaCache:`none`,scope:`/`}}],t=null;for(let n of e)try{let e=n.opts?navigator.serviceWorker.register(`/sw.js`,n.opts):navigator.serviceWorker.register(`/sw.js`);return await H(e,1e4,`Service worker registration timed out (${n.label})`)}catch(e){t=e}throw t instanceof Error?t:Error(`Service worker registration failed`)},W=async()=>{if(!(`serviceWorker`in navigator))throw Error(`Service worker not supported`);let e=await navigator.serviceWorker.getRegistration();if(e)return e;let t=await te();try{await t.update()}catch{}return await ee(t),t},ne=e=>{let t=e,n=[`type=${typeof e}`,`toString=${String(e)}`,`name=${String(t?.name??``)}`,`message=${String(t?.message??``)}`],r=``;try{r=JSON.stringify(e)}catch{}return{summary:n.filter(Boolean).join(` | `),json:r,stack:typeof t?.stack==`string`?t.stack:``}},re=async()=>{let t=U();if(!t?.notifications){K.error(e(`settings.notifications.page.toast.notificationsApiUnavailable`));return}try{await t.notifications.notifyAgentCompletion({title:e(`settings.notifications.page.testNotification.title`),body:e(`settings.notifications.page.testNotification.body`),tag:`openchamber-test`})?K.success(e(`settings.notifications.page.toast.testNotificationSent`)):K.error(e(`settings.notifications.page.toast.testNotificationFailed`))}catch(t){console.error(`Test notification failed:`,t),K.error(e(`settings.notifications.page.toast.testNotificationFailed`))}},ie=async()=>{if(!M){K.error(e(`settings.notifications.page.toast.pushUnsupported`));return}let t=U();if(!t?.push){K.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}L(!0);try{if(typeof Notification<`u`&&Notification.permission==="default"){let t=await Notification.requestPermission();if(j(t),t!==`granted`){K.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}}if(typeof Notification<`u`&&Notification.permission!==`granted`){K.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}let n=await t.push.getVapidPublicKey();if(!n?.publicKey){K.error(e(`settings.notifications.page.toast.pushKeyLoadFailed`));return}let r=await W();await ee(r);let i=await r.pushManager.getSubscription();if(!(`pushManager`in r)||!r.pushManager)throw Error(`PushManager unavailable (requires installed PWA + iOS 16.4+)`);let a=(i??await H(r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:V(n.publicKey)}),15e3,`Push subscription timed out`)).toJSON(),o=a.keys;if(!a.endpoint||!o?.p256dh||!o.auth)throw Error(`Push subscription missing keys`);if(!(await H(t.push.subscribe({endpoint:a.endpoint,keys:{p256dh:o.p256dh,auth:o.auth},origin:typeof window<`u`?window.location.origin:void 0,platform:xe()}),15e3,`Push subscribe request timed out`))?.ok){K.error(e(`settings.notifications.page.toast.enableBackgroundFailed`));return}F(!0),K.success(e(`settings.notifications.page.toast.backgroundEnabled`))}catch(t){console.error(`[Push] Enable failed:`,t);let n=ne(t);K.error(e(`settings.notifications.page.toast.enableBackgroundFailed`),{description:n.summary})}finally{L(!1)}},ae=async()=>{if(!M){F(!1);return}let t=U();if(!t?.push){K.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}L(!0);try{let n=await(await W()).pushManager.getSubscription();if(!n){F(!1);return}let r=n.endpoint;await n.unsubscribe(),await t.push.unsubscribe({endpoint:r}),F(!1),K.success(e(`settings.notifications.page.toast.backgroundDisabled`))}finally{L(!1)}},oe=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`block`,children:e(`settings.notifications.page.delivery.browserPermissionHint`)}),A===`denied`?(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--status-error)]`,children:e(`settings.notifications.page.delivery.permissionDenied`)}):null,A===`granted`&&!a?(0,$.jsx)(`span`,{className:`mt-1 block`,children:e(`settings.notifications.page.delivery.permissionGrantedButDisabled`)}):null]}):n?e(`settings.notifications.page.delivery.vscodeHint`):void 0;return(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(Z,{label:e(`settings.notifications.page.delivery.title`),description:oe,className:`oc-settings-detail-group`,children:[(0,$.jsx)(Hr,{itemId:`notifications.delivery`,checked:a&&z,onChange:e=>{R(e)},label:e(`settings.notifications.page.delivery.enableLabel`),ariaLabel:e(`settings.notifications.page.delivery.enableAria`)}),a&&z&&!r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hr,{checked:s===`always`,onChange:e=>c(e?`always`:`hidden-only`),label:e(`settings.notifications.page.delivery.focusedLabel`),ariaLabel:e(`settings.notifications.page.delivery.focusedAria`)}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center`,children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void re(),children:e(`settings.notifications.page.delivery.testAction`)})})]}):null]}),a&&z?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:e(`settings.notifications.page.events.title`),className:`oc-settings-detail-group`,children:[(0,$.jsx)(Hr,{itemId:`notifications.events`,checked:f,onChange:p,label:e(`settings.notifications.page.events.completionLabel`),ariaLabel:e(`settings.notifications.page.events.completionAria`)}),(0,$.jsx)(Hr,{checked:l,onChange:d,label:e(`settings.notifications.page.events.subtaskLabel`),ariaLabel:e(`settings.notifications.page.events.subtaskAria`)}),(0,$.jsx)(Hr,{checked:h,onChange:g,label:e(`settings.notifications.page.events.errorLabel`),ariaLabel:e(`settings.notifications.page.events.errorAria`)}),(0,$.jsx)(Hr,{checked:_,onChange:v,label:e(`settings.notifications.page.events.questionLabel`),ariaLabel:e(`settings.notifications.page.events.questionAria`)}),(0,$.jsx)(Hr,{checked:y,onChange:b,label:e(`settings.notifications.page.events.permissionLabel`),ariaLabel:e(`settings.notifications.page.events.permissionAria`)}),(0,$.jsx)(Hr,{checked:x,onChange:S,label:e(`settings.notifications.page.events.scheduledTasksLabel`),ariaLabel:e(`settings.notifications.page.events.scheduledTasksAria`)}),(0,$.jsx)(Hr,{checked:C,onChange:T,label:e(`settings.notifications.page.events.assistantsLabel`),ariaLabel:e(`settings.notifications.page.events.assistantsAria`)}),(0,$.jsx)(Hr,{checked:E,onChange:D,label:e(`settings.notifications.page.events.goalsLabel`),ariaLabel:e(`settings.notifications.page.events.goalsAria`)})]}),r?null:(0,$.jsx)(Z,{label:e(`settings.notifications.page.template.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.notifications.page.template.variablesLabel`),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{project_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{worktree}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{branch}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{session_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{agent_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{model_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{last_message}`})]}),className:`oc-settings-detail-group`,children:[`completion`,`subtask`,`error`,`question`].map(t=>(0,$.jsxs)(`div`,{className:`oc-settings-group-row`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label block font-normal text-foreground`,children:e(Hf[t])}),(0,$.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 md:grid-cols-2 md:gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.title`)}),(0,$.jsx)(un,{value:O[t].title,onChange:e=>B(t,`title`,e.target.value),className:`w-full`,placeholder:e(Vf[t].titleKey)})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.message`)}),(0,$.jsx)(un,{value:O[t].message,onChange:e=>B(t,`message`,e.target.value),className:`w-full`,placeholder:e(Vf[t].messageKey)})]})]})]},t))})]}):null,i?(0,$.jsx)(Z,{label:e(`settings.notifications.page.push.title`),className:`oc-settings-detail-group`,children:(0,$.jsxs)(`div`,{"data-settings-item":`notifications.push`,className:`oc-settings-group-row flex items-center gap-2`,children:[(0,$.jsx)($t,{checked:M?P:!1,disabled:!M||I,onChange:e=>{e?ie():ae()},ariaLabel:e(`settings.notifications.page.push.enableAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label`,M?`text-foreground`:`text-muted-foreground`),children:e(`settings.notifications.page.push.enableLabel`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(M?`settings.notifications.page.push.supportedHint`:`settings.notifications.page.push.unsupportedHint`)})]}),I&&(0,$.jsx)(`div`,{className:`pt-0.5 text-muted-foreground`,children:(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.notifications.page.push.loadingAria`)})})]})}):null]})},Wf=e=>{if(!e)return;e.pause();let{src:t}=e;t.startsWith(`blob:`)&&URL.revokeObjectURL(t),e.removeAttribute(`src`),e.load()},Gf=[{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`}],Kf=e=>{let t=(0,Di.c)(8),{value:n,label:r}=e,i=`${r}: ${n}/5`,a=`${n/5*100}%`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`span`,{className:`h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]`,"aria-hidden":`true`,children:(0,$.jsx)(`span`,{className:`block h-full rounded-full bg-[var(--primary-base)]`,style:{width:a}})}),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`typography-ui-compact text-muted-foreground`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==i||t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,title:i,children:[o,s]}),t[4]=i,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},qf=({selectedModelId:e,onSelect:t})=>{let{t:n}=ke(),r=(0,Q.useCallback)(e=>n(e),[n]),[i,a]=(0,Q.useState)(new Map),[o,s]=(0,Q.useState)(null),c=(0,Q.useCallback)(async()=>{try{let e=await L(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json();Array.isArray(t?.models)&&a(new Map(t.models.map(e=>[e.id,e])))}catch{}},[]);(0,Q.useEffect)(()=>{c()},[c]);let l=Array.from(i.values()).some(e=>e.downloading);(0,Q.useEffect)(()=>{if(!l)return;let e=setInterval(()=>{c()},2e3);return()=>clearInterval(e)},[l,c]);let u=async e=>{s(e);try{await L(`/api/dictation/models/${encodeURIComponent(e)}/download`,{method:`POST`}),await c()}catch{}finally{s(null)}},d=async e=>{s(e);try{await L(`/api/dictation/models/${encodeURIComponent(e)}`,{method:`DELETE`}),await c()}catch{}finally{s(null)}};return(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":n(`settings.voice.page.field.model`),className:`mt-1 w-full min-w-0 space-y-0`,children:Gf.map(a=>{let s=e===a.id,c=i.get(a.id)??null;return(0,$.jsxs)(`div`,{className:`flex w-full items-start gap-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`pt-0.5`,children:(0,$.jsx)(Zn,{checked:s,onChange:()=>t(a.id),ariaLabel:r(a.labelKey)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 cursor-pointer`,role:`button`,tabIndex:0,onClick:()=>t(a.id),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),t(a.id))},children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,s?`text-foreground`:`text-foreground/50`),children:r(a.labelKey)}),a.badgeKey?(0,$.jsx)(`span`,{className:`rounded px-1 text-[9px] font-medium uppercase leading-[14px] tracking-wide`,style:{backgroundColor:`var(--status-success-background)`,color:`var(--status-success)`,border:`1px solid var(--status-success-border)`},children:r(a.badgeKey)}):null]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-4 gap-y-0.5`,children:[(0,$.jsx)(Kf,{value:a.accuracy,label:n(`settings.voice.page.stt.meta.accuracy`)}),(0,$.jsx)(Kf,{value:a.speed,label:n(`settings.voice.page.stt.meta.speed`)}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:a.size})]}),c?.downloadError?(0,$.jsx)(`p`,{className:`mt-0.5 typography-meta text-[var(--status-error)]`,children:c.downloadError}):null]}),(0,$.jsx)(`div`,{className:`flex w-14 flex-shrink-0 items-center justify-end gap-1 pt-0.5`,children:c?.installed?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:o===a.id,onClick:()=>{d(a.id)},title:n(`settings.voice.page.stt.modelDelete`),"aria-label":n(`settings.voice.page.stt.modelDelete`),children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4`})}),(0,$.jsx)(J,{name:`checkbox-circle`,className:`h-4 w-4 flex-shrink-0 text-[var(--status-success)]`,"aria-label":n(`settings.voice.page.stt.modelInstalled`)})]}):c?.downloading?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof c.downloadProgress==`number`?`${c.downloadProgress}%`:``})]}):(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:o===a.id,onClick:()=>{u(a.id)},title:n(`settings.voice.page.stt.modelDownload`),"aria-label":n(`settings.voice.page.stt.modelDownload`),children:(0,$.jsx)(J,{name:`download`,className:`h-4 w-4`})})})]},a.id)})})},Jf=[{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)`}],Yf=`kokoro-en-v0_19`,Xf=()=>{let{t:e}=ke(),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),a=(0,Q.useCallback)(async()=>{try{let e=await L(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json(),r=Array.isArray(t?.ttsModels)?t.ttsModels.find(e=>e.id===Yf):null;r&&n(r)}catch{}},[]);(0,Q.useEffect)(()=>{a()},[a]),(0,Q.useEffect)(()=>{if(!t?.downloading)return;let e=setInterval(()=>{a()},2e3);return()=>clearInterval(e)},[t?.downloading,a]);let o=async e=>{i(!0);try{await L(e===`POST`?`/api/dictation/models/${Yf}/download`:`/api/dictation/models/${Yf}`,{method:e}),await a()}catch{}finally{i(!1)}};return t?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`Kokoro`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:`305 MB`}),t.installed?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{name:`checkbox-circle`,className:`h-4 w-4 text-[var(--status-success)]`,"aria-label":e(`settings.voice.page.stt.modelInstalled`)}),(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:r,onClick:()=>{o(`DELETE`)},title:e(`settings.voice.page.stt.modelDelete`),"aria-label":e(`settings.voice.page.stt.modelDelete`),children:(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4`})})]}):t.downloading?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof t.downloadProgress==`number`?`${t.downloadProgress}%`:``})]}):(0,$.jsx)(Y,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:r,onClick:()=>{o(`POST`)},title:e(`settings.voice.page.stt.modelDownload`),"aria-label":e(`settings.voice.page.stt.modelDownload`),children:(0,$.jsx)(J,{name:`download`,className:`h-4 w-4`})}),t.downloadError?(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t.downloadError}):null]}):null},Zf=[{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`}],Qf=()=>{let{t:e}=ke(),{isMobile:t}=fr(),n=G(e=>e.voiceProvider),r=G(e=>e.setVoiceProvider),i=G(e=>e.speechRate),a=G(e=>e.setSpeechRate),o=G(e=>e.speechPitch),s=G(e=>e.setSpeechPitch),c=G(e=>e.speechVolume),l=G(e=>e.setSpeechVolume),u=G(e=>e.sayVoice),d=G(e=>e.setSayVoice),f=G(e=>e.localTtsVoiceId),p=G(e=>e.setLocalTtsVoiceId),{speak:m,stop:h,isPlaying:g,error:_}=Nn(),v=(0,Q.useCallback)(()=>{if(g){h();return}let t=Jf.find(e=>e.id===f)?.label??String(f);m(e(`settings.voice.page.preview.voiceLine`,{voiceName:t}),{speakerId:f,speed:G.getState().speechRate})},[g,f,m,h,e]),y=G(e=>e.browserVoice),b=G(e=>e.setBrowserVoice),x=G(e=>e.openaiVoice),S=G(e=>e.setOpenaiVoice),C=G(e=>e.openaiApiKey),w=G(e=>e.setOpenaiApiKey),T=G(e=>e.openaiCompatibleUrl),E=G(e=>e.setOpenaiCompatibleUrl),D=G(e=>e.openaiCompatibleApiKey),O=G(e=>e.setOpenaiCompatibleApiKey),k=G(e=>e.openaiCompatibleVoice),A=G(e=>e.setOpenaiCompatibleVoice),j=G(e=>e.openaiCompatibleTtsModel),M=G(e=>e.setOpenaiCompatibleTtsModel),N=G(e=>e.showMessageTTSButtons),P=G(e=>e.ttsInputMode),F=G(e=>e.setTtsInputMode),I=G(e=>e.sttProvider),R=G(e=>e.setSttProvider),z=G(e=>e.sttServerUrl),B=G(e=>e.setSttServerUrl),V=G(e=>e.sttApiKey),H=G(e=>e.setSttApiKey),ee=G(e=>e.sttModel),U=G(e=>e.setSttModel),te=G(e=>e.sttLocalModel),W=G(e=>e.setSttLocalModel),ne=G(e=>e.sttLanguage),re=G(e=>e.setSttLanguage),ie=G(e=>e.setShowMessageTTSButtons),ae=G(e=>e.dictationEnabled),oe=G(e=>e.setDictationEnabled),[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)([]),[de,fe]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(!1),[_e,ve]=(0,Q.useState)(!1),[ye,be]=(0,Q.useState)(null),[xe,Se]=(0,Q.useState)(!1),[Ce,we]=(0,Q.useState)(null),[Te,Ee]=(0,Q.useState)([]),[De,Oe]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>((async()=>{let e=await Vn.waitForVoices();Ee(e)})(),`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=()=>{Ee(window.speechSynthesis.getVoices())}),()=>{`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);let Ae=(0,Q.useMemo)(()=>Te.filter(e=>e.lang).sort((e,t)=>{let n=e.lang.startsWith(`en`),r=t.lang.startsWith(`en`);if(n&&!r)return-1;if(!n&&r)return 1;let i=e.lang.localeCompare(t.lang);return i===0?e.name.localeCompare(t.name):i}),[Te]),je=(0,Q.useCallback)(()=>{if(De){Vn.cancelSpeech(),Oe(!1);return}let t=Te.find(e=>e.name===y),n=t?.name??e(`settings.voice.page.preview.browserVoiceFallback`),r=e(`settings.voice.page.preview.voiceLine`,{voiceName:n});Oe(!0);let a=new SpeechSynthesisUtterance(r);a.rate=i,a.pitch=o,a.volume=c,t&&(a.voice=t,a.lang=t.lang),a.onend=()=>Oe(!1),a.onerror=()=>Oe(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(a)},[y,Te,i,o,c,De,e]);(0,Q.useEffect)(()=>()=>{De&&Vn.cancelSpeech()},[De]),(0,Q.useEffect)(()=>{if(!N||n!==`openai`&&n!==`openai-compatible`){ge(C.trim().length>0);return}(async()=>{try{let e=(await(await L(`/api/tts/status`)).json()).available,t=C.trim().length>0;ge(e||t)}catch{ge(C.trim().length>0)}})()},[C,N,n]),(0,Q.useEffect)(()=>{if(!N){ce(!1),ue([]);return}L(`/api/tts/say/status`).then(e=>e.json()).then(e=>{if(ce(e.available),e.voices){let t=e.voices.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).sort((e,t)=>e.name.localeCompare(t.name));ue(t)}}).catch(()=>{ce(!1)})},[N]);let Me=(0,Q.useCallback)(async()=>{if(pe){Wf(pe),me(null),fe(!1);return}fe(!0);let t=null;try{let n=await L(`/api/tts/say/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.voiceLine`,{voiceName:u}),voice:u,rate:Math.round(100+(i-.5)*200)})});if(!n.ok)throw Error(`Preview failed`);let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{Wf(t),me(null),fe(!1)},t.onerror=()=>{Wf(t),me(null),fe(!1)},me(t),await t.play()}catch{Wf(t),me(null),fe(!1)}},[u,i,pe,e]);(0,Q.useEffect)(()=>()=>{Wf(pe)},[pe]);let Ne=(0,Q.useCallback)(async()=>{if(ye){Wf(ye),be(null),ve(!1);return}ve(!0);let t=null;try{let n=await L(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.voiceLine`,{voiceName:x}),voice:x,speed:i,apiKey:C||void 0})});if(!n.ok){let e=await n.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${n.status}`)}let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{Wf(t),be(null),ve(!1)},t.onerror=()=>{Wf(t),be(null),ve(!1)},be(t),await t.play()}catch{Wf(t),be(null),ve(!1)}},[x,i,ye,C,e]);(0,Q.useEffect)(()=>()=>{Wf(ye)},[ye]);let Pe=(0,Q.useCallback)(async()=>{if(Ce){Wf(Ce),we(null),Se(!1);return}if(!T.trim())return;Se(!0);let t=null;try{let n=await L(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.customServerLine`),voice:k,model:j||void 0,speed:i,baseURL:T,apiKey:D||void 0})});if(!n.ok){let e=await n.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${n.status}`)}let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{Wf(t),we(null),Se(!1)},t.onerror=()=>{Wf(t),we(null),Se(!1)},we(t),await t.play()}catch{Wf(t),we(null),Se(!1)}},[T,k,j,D,i,Ce,e]);(0,Q.useEffect)(()=>()=>{Wf(Ce)},[Ce]);let Fe=`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(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.page.voice.title`)})}),(0,$.jsx)(`div`,{"data-settings-item":`voice.playback`,children:(0,$.jsxs)(Z,{label:e(`settings.voice.page.section.playbackAndSummary`),children:[(0,$.jsx)(Ir,{label:e(`settings.voice.page.field.messageReadAloudButton`),children:(0,$.jsx)($t,{checked:N,onChange:ie,ariaLabel:e(`settings.voice.page.field.messageReadAloudButtonAria`)})}),N&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ir,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.voice.page.field.provider`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`ul`,{className:`space-y-1`,children:[(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.browser`)}),` `,e(`settings.voice.page.tooltip.browser`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.local`)}),` `,e(`settings.voice.page.tooltip.localTts`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:`OpenAI:`}),` `,e(`settings.voice.page.tooltip.openai`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.custom`)}),` `,e(`settings.voice.page.tooltip.custom`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.say`)}),` `,e(`settings.voice.page.tooltip.say`)]})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`browser`,onClick:()=>r(`browser`),className:`!font-normal`,children:e(`settings.voice.page.provider.browser`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`local`,onClick:()=>r(`local`),className:`!font-normal`,children:e(`settings.voice.page.provider.local`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`openai`,onClick:()=>r(`openai`),className:`!font-normal`,children:`OpenAI`}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`openai-compatible`,onClick:()=>r(`openai-compatible`),className:`!font-normal`,children:e(`settings.voice.page.provider.custom`)}),se&&(0,$.jsxs)(Y,{variant:`chip`,size:`xs`,"aria-pressed":n===`say`,onClick:()=>r(`say`),className:`!font-normal`,children:[(0,$.jsx)(J,{name:`apple`,className:`w-3.5 h-3.5 mr-0.5`}),e(`settings.voice.page.provider.say`)]})]})}),n===`openai`&&(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!he&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.apiKey`)}),(0,$.jsx)(`span`,{className:q(`typography-meta ml-2`,he?`text-muted-foreground`:`text-[var(--status-error)]/80`),children:e(he&&!C?`settings.voice.page.field.apiKeyHintUsingConfig`:he?`settings.voice.page.field.apiKeyHintProvide`:`settings.voice.page.field.apiKeyHintRequired`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(un,{type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),C&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>w(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),n===`openai-compatible`&&(0,$.jsxs)(`div`,{className:`py-1.5 space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!T.trim()&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.serverUrl`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.serverUrlHint`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(un,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`http://localhost:8880/v1`,className:`w-full pr-8`}),T&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>E(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`API Key`}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:`Optional`}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(un,{type:`password`,value:D,onChange:e=>O(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),D&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>O(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.model`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:(0,$.jsx)(un,{type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:`speaches-ai/Kokoro-82M-v1.0-ONNX`,className:`w-full`})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.voice`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.voiceIdentifierHint`)}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2`,children:[(0,$.jsx)(`div`,{className:`relative max-w-xs flex-1`,children:(0,$.jsx)(un,{type:`text`,value:k,onChange:e=>A(e.target.value),placeholder:`af_sky`,className:`w-full`})}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:Pe,title:e(`settings.voice.page.actions.preview`),disabled:!T.trim(),children:xe?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})})]})]})]}),n===`local`&&(0,$.jsx)(Xf,{}),(0,$.jsxs)(Ir,{label:e(`settings.voice.page.field.voice`),children:[n===`local`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(on,{value:String(f),onValueChange:e=>p(Number.parseInt(e,10)||0),children:[(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`),children:e=>Jf.find(t=>String(t.id)===e)?.label??e})}),(0,$.jsx)(rn,{children:Jf.map(e=>(0,$.jsx)(en,{value:String(e.id),children:e.label},e.id))})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:v,title:e(`settings.voice.page.actions.preview`),children:g?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})}),_?(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:_}):null]}),n===`openai`&&he&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(on,{value:x,onValueChange:S,children:[(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,$.jsx)(rn,{children:Zf.map(e=>(0,$.jsx)(en,{value:e.value,children:e.label},e.value))})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:Ne,title:e(`settings.voice.page.actions.preview`),children:_e?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})})]}),n===`openai-compatible`&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.voice.page.field.configuredAbove`)}),n===`say`&&se&&le.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(on,{value:u,onValueChange:d,children:[(0,$.jsx)(nn,{className:`w-fit`,children:(0,$.jsx)(ln,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,$.jsx)(rn,{children:le.map(e=>(0,$.jsx)(en,{value:e.name,children:e.name},e.name))})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:Me,title:e(`settings.voice.page.actions.preview`),children:de?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})})]}),n===`browser`&&Ae.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(on,{value:y||`$auto`,onValueChange:e=>b(e===`$auto`?``:e),children:[(0,$.jsx)(nn,{className:`w-fit max-w-[200px]`,children:(0,$.jsx)(ln,{placeholder:e(`settings.voice.page.field.auto`)})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(en,{value:`$auto`,children:e(`settings.voice.page.field.auto`)}),Ae.map(e=>(0,$.jsxs)(en,{value:e.name,children:[e.name,` (`,e.lang,`)`]},e.name))]})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:je,title:e(`settings.voice.page.actions.preview`),children:De?(0,$.jsx)(J,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(J,{name:`play`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(Ir,{label:e(`settings.voice.page.field.speechRate`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:i,onChange:e=>a(Number(e.target.value)),className:Fe}),(0,$.jsx)(Br,{value:i,onValueChange:a,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,$.jsxs)(Ir,{label:e(`settings.voice.page.field.speechPitch`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:o,onChange:e=>s(Number(e.target.value)),className:Fe}),(0,$.jsx)(Br,{value:o,onValueChange:s,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,$.jsxs)(Ir,{label:e(`settings.voice.page.field.speechVolume`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:.1,value:c,onChange:e=>l(Number(e.target.value)),className:Fe}),t?(0,$.jsx)(Br,{value:Math.round(c*100),onValueChange:e=>l(e/100),min:0,max:100,step:10,className:`w-16 tabular-nums`}):(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right`,children:[Math.round(c*100),`%`]})]}),(0,$.jsx)(Ir,{label:e(`settings.voice.page.field.ttsInputMode`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":P===`sanitized`,onClick:()=>F(`sanitized`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeSanitized`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":P===`raw`,onClick:()=>F(`raw`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeRaw`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":P===`summarized`,onClick:()=>F(`summarized`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeSummarized`)})]})})]})]})}),(0,$.jsx)(`div`,{"data-settings-item":`voice.speech-recognition`,children:(0,$.jsxs)(Z,{label:e(`settings.voice.page.section.speechRecognition`),children:[(0,$.jsx)(Ir,{label:e(`settings.voice.page.field.enableVoiceInput`),children:(0,$.jsx)($t,{checked:ae,onChange:oe,ariaLabel:e(`settings.voice.page.field.enableVoiceInputAria`)})}),ae&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ir,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.voice.page.field.provider`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`ul`,{className:`space-y-1`,children:[(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.local`)}),` `,e(`settings.voice.page.tooltip.sttLocal`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.server`)}),` `,e(`settings.voice.page.tooltip.sttServer`)]})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":I===`local`,onClick:()=>R(`local`),className:`!font-normal`,children:e(`settings.voice.page.provider.local`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":I===`openai-compatible`,onClick:()=>R(`openai-compatible`),className:`!font-normal`,children:e(`settings.voice.page.provider.server`)})]})}),I===`local`&&(0,$.jsx)(Ir,{label:e(`settings.voice.page.field.model`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(qf,{selectedModelId:te,onSelect:W})}),I===`openai-compatible`&&(0,$.jsxs)(`div`,{className:`oc-settings-group-row space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!z.trim()&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.serverUrl`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.sttServerUrlHint`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(un,{type:`text`,value:z,onChange:e=>B(e.target.value),placeholder:`http://localhost:8001/v1`,className:`w-full pr-8`}),z&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>B(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`API Key`}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:`Optional`}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(un,{type:`password`,value:V,onChange:e=>H(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),V&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>H(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(J,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.model`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:(0,$.jsx)(un,{type:`text`,value:ee,onChange:e=>U(e.target.value),placeholder:`deepdml/faster-whisper-large-v3-turbo-ct2`,className:`w-full`})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.language`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.sttLanguageHint`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-[8rem]`,children:(0,$.jsx)(un,{type:`text`,value:ne,onChange:e=>re(e.target.value),placeholder:`auto`,className:`w-full`})})]})]})]})]})})]})},$f=()=>{let{t:e}=ke(),[t,n]=Q.useState(``),[r,i]=Q.useState(!0),[a,o]=Q.useState(!1),s=u(e=>e.showOpenCodeUpdateNotifications),c=u(e=>e.setShowOpenCodeUpdateNotifications);Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let r=await t.json().catch(()=>null);if(e||!r)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;n(i)}catch{}finally{e||i(!1)}})(),()=>{e=!0}},[]);let l=Q.useCallback(async()=>{if(!(typeof window>`u`)&&w())try{let e=await O();e.success&&e.path&&e.path.trim().length>0&&n(e.path.trim())}catch{}},[]),d=Q.useCallback(async()=>{o(!0);try{let n=t.trim(),r=n.length>=2&&(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))?n.slice(1,-1).trim():n;await V({opencodeBinary:r}),await We({message:e(`settings.openchamber.opencodeCli.actions.restartingOpenCode`),mode:`projects`,scopes:[`all`]})}finally{o(!1)}},[e,t]),f=Q.useCallback(e=>{c(e),V({showOpenCodeUpdateNotifications:e})},[c]);return(0,$.jsxs)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.openchamber.opencodeCli.title`)}),(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsxs)(fn,{sideOffset:8,className:`max-w-xs`,children:[e(`settings.openchamber.opencodeCli.tooltipPrefix`),` `,(0,$.jsx)(`code`,{className:`font-mono text-xs`,children:`opencode`}),e(`settings.openchamber.opencodeCli.tooltipSuffix`)]})]})]}),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.openchamber.opencodeCli.tipPrefix`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`OPENCODE_BINARY`}),` `,e(`settings.openchamber.opencodeCli.tipMiddle`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`~/.config/openchamber/settings.json`}),`.`]}),children:[(0,$.jsx)(Ir,{itemId:`sessions.opencode-binary`,label:e(`settings.openchamber.opencodeCli.field.binaryPath`),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2`,children:[(0,$.jsx)(un,{value:t,onChange:e=>n(e.target.value),placeholder:e(`settings.openchamber.opencodeCli.field.binaryPathPlaceholder`),disabled:r||a,className:`h-7 min-w-0 flex-1 font-mono text-xs`}),(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,onClick:l,disabled:r||a||!w(),className:`h-7 w-7 p-0`,"aria-label":e(`settings.openchamber.opencodeCli.actions.browseAria`),title:e(`settings.openchamber.opencodeCli.actions.browse`),children:(0,$.jsx)(J,{name:`folder`,className:`h-4 w-4`})})]})}),(0,$.jsxs)(`label`,{"data-settings-item":`sessions.opencode-update-notifications`,className:`oc-settings-group-row oc-settings-split-row cursor-pointer`,children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.opencodeCli.field.showUpdateNotifications`)})}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)($t,{checked:s,onChange:f,ariaLabel:e(`settings.openchamber.opencodeCli.field.showUpdateNotificationsAria`)})})]}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex justify-end`,children:(0,$.jsx)(Y,{type:`button`,size:`xs`,onClick:d,disabled:r||a,className:`shrink-0 !font-normal`,children:e(a?`settings.common.actions.saving`:`settings.openchamber.opencodeCli.actions.saveAndReload`)})})]})},ep=[{id:`auto`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsAuto`},{id:`left`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsLeft`},{id:`right`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsRight`}],tp=()=>{let{t:e}=ke(),t=Q.useCallback(t=>e(t),[e]),n=w()&&T(),i=D(),a=u(e=>e.desktopWindowControlsPosition),o=u(e=>e.setDesktopWindowControlsPosition),[s,c]=Q.useState(!1),[l,d]=Q.useState(!1),[f,p]=Q.useState(``),[m,g]=Q.useState(``),[_,y]=Q.useState(!1),[b,x]=Q.useState(null),[E,O]=Q.useState(!0),[k,A]=Q.useState(!1),[j,M]=Q.useState(!1),[F,I]=Q.useState(!1),[R,B]=Q.useState(!1),[H,U]=Q.useState(!1),[te,W]=Q.useState(!1),[ne,re]=Q.useState(!1),[ie,ae]=Q.useState(!1),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(!1),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(null);Q.useEffect(()=>{if(!n){O(!1);return}let t=!1;return(async()=>{try{let n=await L(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!n.ok)throw Error(e(`settings.openchamber.desktopNetwork.error.loadFailed`));let r=await n.json().catch(()=>null);if(t)return;let i=r?.desktopLanAccessEnabled===!0,a=typeof r?.desktopUiPassword==`string`?r.desktopUiPassword:``;c(i),d(i),p(a),g(a),y(r?.desktopLanAccessActive===!0),x(typeof r?.desktopLanAccessBlockedReason==`string`?r.desktopLanAccessBlockedReason:null),de(null)}catch(n){t||de(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.loadFailed`))}finally{t||O(!1)}})(),()=>{t=!0}},[n,e]),Q.useEffect(()=>{if(!n){M(!1);return}let e=!1;return(async()=>{let t=await v();e||(M(t?.supported===!0),I(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){U(!1);return}let e=!1;return(async()=>{let t=await S();e||(U(t?.supported===!0),W(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){ae(!1);return}let e=!1;return(async()=>{let t=await h();e||(ae(t?.supported===!0),se(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n||!l){pe(null);return}let e=!1;return(async()=>{let t=await C();e||pe(t)})(),()=>{e=!0}},[l,n]);let me=l!==s||m!==f,he=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=r()||window.location.href,t=0;try{t=Number(new URL(e).port)}catch{t=Number(window.location.port)}return Number.isFinite(t)&&t>0?t:null},[]),ge=l&&_&&fe&&he?`http://${fe}:${he}`:null,_e=l&&!m.trim(),ve=s&&!_&&b===`missing-password`,ye=E||k||!me||_e,be=Q.useCallback(()=>{d(e=>!e)},[]),xe=Q.useCallback(e=>{g(e),e.trim()||d(!1)},[]),Se=Q.useCallback(e=>{o(e),V({desktopWindowControlsPosition:e})},[o]),Ce=Q.useCallback(async()=>{if(!j||R)return;let t=!F;I(t),B(!0),de(null);try{let n=await P(t);if(!n?.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported`));I(n.enabled)}catch(n){I(!t),de(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed`))}finally{B(!1)}},[R,F,j,e]),we=Q.useCallback(async()=>{if(!H||ne)return;let t=!te;W(t),re(!0),de(null);try{let n=await N(t);if(!n)throw Error(e(`settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed`));if(!n.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.minimizeToTrayUnsupported`));W(n.enabled)}catch(n){W(!t),de(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed`))}finally{re(!1)}},[ne,te,H,e]),Te=Q.useCallback(async()=>{if(!ie||ce)return;let t=!oe;se(t),le(!0),de(null);try{let n=await z(t);if(!n?.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.keepAwakeUnsupported`));se(n.enabled)}catch(n){se(!t),de(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed`))}finally{le(!1)}},[ce,oe,ie,e]),Ee=Q.useCallback(async()=>{if(me){A(!0),de(null);try{if(!(await L(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({desktopLanAccessEnabled:l,desktopUiPassword:m})})).ok)throw Error(e(`settings.openchamber.desktopNetwork.error.saveFailed`));if(c(l),p(m),!await ee())throw Error(e(`settings.openchamber.desktopNetwork.error.savedRestartFailed`))}catch(t){de(t instanceof Error?t.message:e(`settings.openchamber.desktopNetwork.error.saveFailed`)),A(!1)}}},[m,l,me,e]);return!n&&!i?null:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[i?(0,$.jsx)(Z,{label:e(`settings.openchamber.desktopNetwork.field.windowControlsPosition`),children:(0,$.jsx)(Ir,{itemId:`sessions.desktop-window-controls-position`,label:e(`settings.openchamber.desktopNetwork.field.windowControlsPosition`),description:e(`settings.openchamber.desktopNetwork.field.windowControlsPositionDescription`),children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,role:`group`,"aria-label":e(`settings.openchamber.desktopNetwork.field.windowControlsPositionAria`),children:ep.map(e=>(0,$.jsx)(Y,{type:`button`,variant:`chip`,size:`xs`,className:`!font-normal`,"aria-pressed":a===e.id,onClick:()=>Se(e.id),children:t(e.labelKey)},e.id))})})}):null,n?(0,$.jsxs)(Z,{label:e(`settings.openchamber.desktopNetwork.title`),children:[j?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-launch-at-login`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:Ce,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Ce())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.launchAtLogin`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.launchAtLoginDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)($t,{checked:F,onChange:Ce,ariaLabel:e(`settings.openchamber.desktopNetwork.field.launchAtLoginAria`),disabled:R})})]}):null,H?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-minimize-to-tray`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:we,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),we())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.minimizeToTray`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.minimizeToTrayDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)($t,{checked:te,onChange:we,ariaLabel:e(`settings.openchamber.desktopNetwork.field.minimizeToTrayAria`),disabled:ne})})]}):null,ie?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-keep-awake`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:Te,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Te())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.keepAwake`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.keepAwakeDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)($t,{checked:oe,onChange:Te,ariaLabel:e(`settings.openchamber.desktopNetwork.field.keepAwakeAria`),disabled:ce})})]}):null,(0,$.jsx)(Ir,{itemId:`sessions.desktop-ui-password`,label:(0,$.jsx)(`label`,{htmlFor:`desktop-ui-password`,children:e(`settings.openchamber.desktopPassword.field.password`)}),description:e(`settings.openchamber.desktopPassword.field.passwordDescription`),children:(0,$.jsx)(un,{id:`desktop-ui-password`,type:`password`,className:`max-w-sm`,value:m,onChange:e=>xe(e.target.value),placeholder:e(`settings.openchamber.desktopPassword.field.passwordPlaceholder`),disabled:E||k,required:l,"aria-invalid":_e})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-lan-access`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:be,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),be())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.allowLanAccess`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.allowLanAccessDescription`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.openchamber.desktopNetwork.field.warning`)}),_e||ve?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.openchamber.desktopNetwork.field.passwordRequiredWarning`)}):null]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)($t,{checked:l,onChange:be,ariaLabel:e(`settings.openchamber.desktopNetwork.field.allowLanAccessAria`),disabled:E||k})})]}),ue?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-[var(--status-error)]`,children:ue}):null,ge?(0,$.jsxs)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:[e(me&&!s?`settings.openchamber.desktopNetwork.hint.openAfterRestart`:`settings.openchamber.desktopNetwork.hint.openNow`),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:ge})]}):null,(0,$.jsx)(`div`,{className:`oc-settings-group-row flex justify-end`,children:(0,$.jsx)(Y,{type:`button`,size:`xs`,onClick:Ee,disabled:ye,className:`shrink-0 !font-normal`,children:e(k?`settings.common.actions.saving`:`settings.openchamber.desktopNetwork.actions.saveAndRestart`)})})]}):null]})},np=new Set([`shift`,`control`,`alt`,`meta`]),rp=e=>{if(np.has(e.key.toLowerCase()))return null;let t=[];(e.metaKey||e.ctrlKey)&&t.push(`mod`),e.shiftKey&&t.push(`shift`),e.altKey&&t.push(`alt`);let n=On(e.key);return n?(t.push(n),mn(t.join(`+`))):null},ip=()=>{let e=(0,Di.c)(59),{t}=ke(),n;e[0]===t?n=e[1]:(n=e=>t(e),e[0]=t,e[1]=n);let r=n,i=u(ap),a=u(op),o=u(sp),s=u(cp),c;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)){bb0:{let e=bn();if(!m()){c=e;break bb0}c=e.filter(lp)}e[2]=c}else c=e[2];let l=c,d;e[3]===r?d=e[4]:(d=(e,t)=>{let n=`settings.openchamber.keyboardShortcuts.action.${e}.label`,i=r(n);return i===n?t:i},e[3]=r,e[4]=d);let f=d,[p,h]=Q.useState(null),g;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={},e[5]=g):g=e[5];let[_,v]=Q.useState(g),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(null),T=up,E;e[6]===i?E=e[7]:(E=(e,t)=>{let n=mn(t);for(let t of l){if(t.id===e)continue;let r=$n(t.id,i);if(mn(r)===n)return t.id}return null},e[6]=i,e[7]=E);let D=E,O;e[8]!==D||e[9]!==a||e[10]!==i||e[11]!==t?(O=(e,n)=>{let r=mn(n),o=D(e,r);if(o){w({actionId:e,combo:r,conflictActionId:o}),b(``);return}let s={...i,[e]:r};a(e,r),T(s),w(null),b(``),S(Mn(r)?t(`settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut`):``),v(t=>{let n={...t};return delete n[e],n})},e[8]=D,e[9]=a,e[10]=i,e[11]=t,e[12]=O):O=e[12];let k=O,A;e[13]!==C||e[14]!==a||e[15]!==i||e[16]!==t?(A=()=>{if(!C)return;let e={...i,[C.conflictActionId]:_n,[C.actionId]:C.combo};a(C.conflictActionId,_n),a(C.actionId,C.combo),T(e),w(null),b(``),S(Mn(C.combo)?t(`settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut`):``),v(e=>{let t={...e};return delete t[C.actionId],t})},e[13]=C,e[14]=a,e[15]=i,e[16]=t,e[17]=A):A=e[17];let j=A,M;e[18]!==o||e[19]!==i?(M=e=>{let t={...i};delete t[e],o(e),T(t),v(t=>{let n={...t};return delete n[e],n}),w(null),b(``),S(``)},e[18]=o,e[19]=i,e[20]=M):M=e[20];let N=M,P;e[21]===t?P=e[22]:(P=t(`settings.openchamber.keyboardShortcuts.title`),e[21]=t,e[22]=P);let F;e[23]===P?F=e[24]:(F=(0,$.jsx)(`span`,{children:P}),e[23]=P,e[24]=F);let I;e[25]===s?I=e[26]:(I=()=>{s(),T({}),v({}),w(null),b(``),S(``)},e[25]=s,e[26]=I);let L;e[27]===t?L=e[28]:(L=t(`settings.openchamber.keyboardShortcuts.actions.resetAll`),e[27]=t,e[28]=L);let R;e[29]!==I||e[30]!==L?(R=(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:I,children:L}),e[29]=I,e[30]=L,e[31]=R):R=e[31];let z;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),e[32]=z):z=e[32];let B;e[33]===t?B=e[34]:(B=t(`settings.openchamber.keyboardShortcuts.tooltip`),e[33]=t,e[34]=B);let V;e[35]===B?V=e[36]:(V=(0,$.jsxs)(pn,{children:[z,(0,$.jsx)(fn,{sideOffset:8,className:`max-w-xs`,children:B})]}),e[35]=B,e[36]=V);let H;e[37]!==R||e[38]!==V||e[39]!==F?(H=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F,R,V]}),e[37]=R,e[38]=V,e[39]=F,e[40]=H):H=e[40];let ee;e[41]!==j||e[42]!==y||e[43]!==C||e[44]!==t||e[45]!==x?(ee=(y||x||C)&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-2 px-1`,children:[C&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-foreground`,children:t(`settings.openchamber.keyboardShortcuts.overwritePrompt`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,onClick:j,children:t(`settings.openchamber.keyboardShortcuts.actions.overwrite`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>w(null),children:t(`settings.common.actions.cancel`)})]})]}),y&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground`,children:y}),x&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground`,children:x})]}),e[41]=j,e[42]=y,e[43]=C,e[44]=t,e[45]=x,e[46]=ee):ee=e[46];let U;e[47]!==f||e[48]!==p||e[49]!==_||e[50]!==N||e[51]!==k||e[52]!==i||e[53]!==t?(U=l.map(e=>{let n=$n(e.id,i),r=_[e.id],a=r??n,o=typeof r==`string`&&mn(r)!==mn(n);return(0,$.jsxs)(Ir,{label:f(e.id,e.label),children:[(0,$.jsx)(un,{readOnly:!0,value:p===e.id?t(`settings.openchamber.keyboardShortcuts.field.pressKeys`):gn(a),onFocus:()=>{h(e.id),b(``)},onBlur:()=>{p===e.id&&h(null)},onKeyDown:t=>{if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){h(null);return}let n=rp(t);n&&(v(t=>({...t,[e.id]:n})),h(null),w(null),b(``))},className:`w-40 min-w-0 typography-ui-label text-right`}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,size:`xs`,className:`!font-normal`,onClick:()=>{let n=_[e.id];if(!n){b(t(`settings.openchamber.keyboardShortcuts.error.captureFirst`));return}k(e.id,n)},disabled:!o,children:t(`settings.common.actions.saveChanges`)}),(0,$.jsx)(Y,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>N(e.id),children:t(`settings.common.actions.reset`)})]},e.id)}),e[47]=f,e[48]=p,e[49]=_,e[50]=N,e[51]=k,e[52]=i,e[53]=t,e[54]=U):U=e[54];let te;return e[55]!==H||e[56]!==ee||e[57]!==U?(te=(0,$.jsxs)(Z,{itemId:`shortcuts.keyboard-shortcuts`,label:H,children:[ee,U]}),e[55]=H,e[56]=ee,e[57]=U,e[58]=te):te=e[58],te};function ap(e){return e.shortcutOverrides}function op(e){return e.setShortcutOverride}function sp(e){return e.clearShortcutOverride}function cp(e){return e.resetAllShortcutOverrides}function lp(e){return e.id!==`toggle_prompt_navigator`}function up(e){V({shortcutOverrides:e})}var dp=()=>{let e=(0,Di.c)(2),[t,r]=Q.useState(0),i,a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>n(()=>r(xp)),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),t},fp=e=>{let t=(0,Di.c)(24),{section:n,flowMobile:r}=e,i=r!==void 0&&r,{isMobile:a}=fr();dp();let o;t[0]===a?o=t[1]:(o=a&&A(),t[0]=a,t[1]=o);let s=o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=m(),t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=w()&&(T()||D()),t[3]=u):u=t[3];let d=u;if(!n){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(bf,{}),t[4]=e):e=t[4];let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Lf,{})}),t[5]=n):n=t[5];let r,i,a;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Bf,{})}),i=d&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(tp,{})}),a=!l&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)($f,{})}),t[6]=r,t[7]=i,t[8]=a):(r=t[6],i=t[7],a=t[8]);let o;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Tf,{})}),t[9]=o):o=t[9];let c;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Ff,{})}),t[10]=c):c=t[10];let u;t[11]===s?u=t[12]:(u=s&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Pi,{})}),t[11]=s,t[12]=u);let f;return t[13]===u?f=t[14]:(f=(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content openchamber-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[e,n,r,i,a,o,c,u]})}),t[13]=u,t[14]=f),f}let f;t[15]!==i||t[16]!==n?(f=()=>{switch(n){case`visual`:return(0,$.jsx)(mp,{mobile:i});case`chat`:return(0,$.jsx)(hp,{});case`sessions`:return(0,$.jsx)(gp,{});case`summary-ai`:return(0,$.jsx)(Bf,{});case`shortcuts`:return(0,$.jsx)(pp,{});case`git`:return(0,$.jsx)(_p,{});case`github`:return(0,$.jsx)(vp,{});case`notifications`:return(0,$.jsx)(yp,{});case`voice`:return(0,$.jsx)(bp,{});default:return null}},t[15]=i,t[16]=n,t[17]=f):f=t[17];let p=f,h;t[18]===p?h=t[19]:(h=p(),t[18]=p,t[19]=h);let g;t[20]===h?g=t[21]:(g=(0,$.jsx)(`div`,{className:`oc-settings-page-content openchamber-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:h}),t[20]=h,t[21]=g);let _=g;if(i)return _;let v;return t[22]===_?v=t[23]:(v=(0,$.jsx)(br,{outerClassName:`h-full`,className:`w-full`,children:_}),t[22]=_,t[23]=v),v},pp=()=>{let e=(0,Di.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(ip,{}),e[0]=t):t=e[0],t},mp=e=>{let t=(0,Di.c)(5),{mobile:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=m(),t[0]=r):r=t[0];let i=r,a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=i?[]:[`weekStart`],t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=[`theme`,`sidebarBrand`,`pwaInstallName`,`pwaOrientation`,`mobileKeyboardMode`,`timeFormat`,...a,`fontSize`,`codeFontSize`,`terminalFontSize`,`editorFontSize`,`fileEditorKeymap`,`spacing`,`inputBarOffset`,`expandedEditorToolbar`,...i?[]:[`terminalQuickKeys`],`reportUsage`],t[2]=o):o=t[2];let s;return t[3]===n?s=t[4]:(s=(0,$.jsx)(bf,{mobile:n,visibleSettings:o}),t[3]=n,t[4]=s),s},hp=()=>{let e=(0,Di.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=m(),e[0]=t):t=e[0];let n=t,r;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(bf,{visibleSettings:[`sessionGoal`,`sessionAssist`,`chatRenderMode`,`messageTransport`,`activityRenderMode`,`userMessageRendering`,`mermaidRendering`,`reasoning`,`showTurnChangedFiles`,`expandedTools`,`collapsibleUserMessages`,`stickyUserHeader`,...n?[]:[`promptNavigatorEnabled`],`wideChatLayout`,`codeBlockLineWrap`,`showAssistantTps`,`subagentReadOnlyBanner`,`diffLayout`,`dotfiles`,`fileViewerPreview`,`followUpBehavior`,`persistDraft`,`inputSpellcheck`]}),e[1]=r):r=e[1],r},gp=()=>{let e=(0,Di.c)(7),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=m(),e[0]=t):t=e[0];let n=t;dp();let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=w()&&(T()||D()),e[1]=r):r=e[1];let i=r,a,o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Lf,{}),o=i&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(tp,{})}),s=!n&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)($f,{})}),e[2]=a,e[3]=o,e[4]=s):(a=e[2],o=e[3],s=e[4]);let c;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Tf,{})}),e[5]=c):c=e[5];let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[a,o,s,c,(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Ff,{})})]}),e[6]=l):l=e[6],l},_p=()=>{let e=(0,Di.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`oc-settings-section-stack`,children:(0,$.jsx)(Hd,{})}),e[0]=t):t=e[0],t},vp=()=>{let e=(0,Di.c)(1);if(m())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ud,{}),e[0]=t):t=e[0],t},yp=()=>{let e=(0,Di.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Uf,{}),e[0]=t):t=e[0],t},bp=()=>{let e=(0,Di.c)(1);if(m())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Qf,{}),e[0]=t):t=e[0],t};function xp(e){return e+1}var Sp=[{id:`instances.manage`,page:`instances`,titleKey:`mobile.settings.switchInstance`,keywords:[`instance`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{id:`global-config.editor`,page:`global-config`,titleKey:`settings.globalConfig.title`,descriptionKey:`settings.globalConfig.description`,keywords:[`opencode.json`,`opencode.jsonc`,`oh-my-opencode-slim`,`oh-my-openagent`,`json`,`jsonc`]},{id:`appearance.language`,page:`appearance`,titleKey:`settings.appearance.language.label`,descriptionKey:`settings.appearance.language.description`,keywords:[`locale`,`translation`,`ui language`]},{id:`appearance.time-format`,page:`appearance`,titleKey:`settings.openchamber.visual.field.timeFormat`,keywords:[`clock`,`12h`,`24h`]},{id:`appearance.week-start`,page:`appearance`,titleKey:`settings.openchamber.visual.field.weekStartsOn`,keywords:[`calendar`,`monday`,`sunday`],isAvailable:e=>!e.isVSCode},{id:`appearance.light-theme`,page:`appearance`,titleKey:`settings.openchamber.visual.field.lightTheme`,keywords:[`theme`,`color`,`light mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.dark-theme`,page:`appearance`,titleKey:`settings.openchamber.visual.field.darkTheme`,keywords:[`theme`,`color`,`dark mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.window-transparency`,page:`appearance`,titleKey:`settings.openchamber.visual.field.macVibrancy`,descriptionKey:`settings.openchamber.visual.field.macVibrancyHint`,keywords:[`transparent`,`transparency`,`vibrancy`,`blur`,`macos`,`opaque`],isAvailable:e=>e.isDesktopLocalOrigin},{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:e=>e.isMac},{id:`appearance.sidebar-brand`,page:`appearance`,titleKey:`settings.openchamber.visual.field.sidebarBrand`,descriptionKey:`settings.openchamber.visual.field.sidebarBrandHint`,keywords:[`logo`,`brand`,`wordmark`,`sidebar`]},{id:`appearance.pwa-install-name`,page:`appearance`,titleKey:`settings.openchamber.visual.field.installAppName`,descriptionKey:`settings.openchamber.visual.field.installAppNameHint`,keywords:[`pwa`,`installed app`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.pwa-orientation`,page:`appearance`,titleKey:`settings.openchamber.visual.field.installOrientation`,descriptionKey:`settings.openchamber.visual.field.installOrientationHint`,keywords:[`pwa`,`portrait`,`landscape`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.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:e=>e.isMobile&&e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.ios-native-ui`,page:`appearance`,titleKey:`settings.openchamber.visual.field.iosNativeUi`,descriptionKey:`settings.openchamber.visual.field.iosNativeUiHint`,keywords:[`ios`,`native`,`webview`,`composer`,`tab bar`,`live activity`],isAvailable:()=>hr()},{id:`appearance.interface-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.interfaceFontSize`,keywords:[`font`,`text size`,`ui scale`]},{id:`appearance.code-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.codeFontSize`,keywords:[`code`,`font`,`text size`,`diff`]},{id:`appearance.terminal-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.terminalFontSize`,keywords:[`terminal`,`font`,`text size`]},{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`]},{id:`appearance.expanded-editor-toolbar`,page:`appearance`,titleKey:`settings.openchamber.visual.field.expandedEditorToolbar`,keywords:[`editor`,`toolbar`,`tabs`,`docked`,`files`]},{id:`appearance.file-editor-keymap`,page:`appearance`,titleKey:`settings.openchamber.visual.field.fileEditorKeymap`,keywords:[`editor`,`vim`,`keymap`]},{id:`appearance.terminal-quick-keys`,page:`appearance`,titleKey:`settings.openchamber.visual.field.terminalQuickKeys`,descriptionKey:`settings.openchamber.visual.field.terminalQuickKeysTooltip`,keywords:[`terminal`,`keyboard`,`esc`,`ctrl`,`arrows`],isAvailable:e=>!e.isMobile&&!e.isDesktop&&!e.isVSCode},{id:`about.beta-updates`,page:`about`,titleKey:`settings.openchamber.about.betaUpdates.label`,descriptionKey:`settings.openchamber.about.betaUpdates.description`,keywords:[`beta`,`updates`,`channel`,`ota`],isAvailable:e=>e.isMobile&&be()},{id:`about.diagnostics`,page:`about`,titleKey:`settings.openchamber.about.diagnostics.label`,keywords:[`diagnostics`,`logs`,`feat`,`transcript`,`task`]},{id:`about.export-diagnostics`,page:`about`,titleKey:`settings.openchamber.about.diagnostics.export`,keywords:[`diagnostics`,`logs`,`export`,`feat`,`transcript`,`task`],isAvailable:()=>Et()},{id:`appearance.usage-reports`,page:`appearance`,titleKey:`settings.openchamber.visual.field.sendAnonymousUsageReports`,descriptionKey:`settings.openchamber.visual.field.sendAnonymousUsageReportsHint`,keywords:[`telemetry`,`analytics`]},{id:`appearance.transcript-cache`,page:`appearance`,titleKey:`settings.openchamber.visual.transcriptCache.label`,descriptionKey:`settings.openchamber.visual.transcriptCache.description`,keywords:[`cache`,`local data`,`conversation history`,`transcript`,`privacy`]},{id:`chat.render-mode`,page:`chat`,titleKey:`settings.openchamber.visual.section.chatRenderMode`,keywords:[`messages`,`conversation`,`rendering`]},{id:`chat.message-transport`,page:`chat`,titleKey:`settings.openchamber.visual.section.messageStreamTransport`,keywords:[`streaming`,`sse`,`websocket`]},{id:`chat.session-assistance`,page:`chat`,titleKey:`settings.openchamber.visual.section.sessionAssistance`,keywords:[`title`,`assist`,`subagent`]},{id:`chat.session-title-refresh`,page:`chat`,titleKey:`settings.openchamber.visual.field.sessionTitleRefresh`,keywords:[`title`,`rename`,`refresh`,`throttle`,`small model`,`summary`]},{id:`chat.session-goal`,page:`chat`,titleKey:`settings.openchamber.visual.field.sessionGoal`,keywords:[`goal`,`objective`,`auto continue`,`small model`],isAvailable:e=>!e.isVSCode},{id:`chat.session-goal-budget`,page:`chat`,titleKey:`settings.openchamber.visual.goal.budgetLabel`,keywords:[`goal`,`budget`,`tokens`,`limit`],isAvailable:e=>!e.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.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`],isAvailable:e=>!e.isVSCode},{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`,`read aloud`],isAvailable:()=>!1},{id:`chat.assistant-tps`,page:`chat`,titleKey:`settings.openchamber.visual.field.showAssistantTps`,descriptionKey:`settings.openchamber.visual.field.showAssistantTpsTooltip`,keywords:[`tps`,`tokens`,`speed`,`rate`,`tok/s`,`throughput`]},{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`],isAvailable:()=>!1},{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:e=>!e.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.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`]},{id:`chat.spellcheck`,page:`chat`,titleKey:`settings.openchamber.visual.field.enableSpellcheckInTextInputs`,keywords:[`spelling`,`input`],isAvailable:e=>!e.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:`summary-ai.configuration`,page:`summary-ai`,titleKey:`settings.openchamber.defaults.summary.title`,descriptionKey:`settings.openchamber.defaults.summary.description`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`custom api`,`base url`,`api token`]},{id:`sessions.auto-cleanup`,page:`sessions`,titleKey:`settings.openchamber.sessionRetention.field.enableAutoCleanup`,descriptionKey:`settings.openchamber.sessionRetention.tooltip`,keywords:[`retention`,`archive`,`delete`]},{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.archived`,page:`sessions`,titleKey:`settings.openchamber.archivedSessions.title`,descriptionKey:`settings.openchamber.archivedSessions.description`,keywords:[`archive`,`archived`,`restore`,`preview`,`history`]},{id:`sessions.desktop-launch-at-login`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.launchAtLogin`,descriptionKey:`settings.openchamber.desktopNetwork.field.launchAtLoginDescription`,keywords:[`desktop`,`startup`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-window-controls-position`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.windowControlsPosition`,descriptionKey:`settings.openchamber.desktopNetwork.field.windowControlsPositionDescription`,keywords:[`desktop`,`window`,`controls`,`minimize`,`maximize`,`close`,`titlebar`,`linux`,`windows`],isAvailable:e=>e.isDesktop&&(e.isWindows||!e.isMac)},{id:`sessions.desktop-minimize-to-tray`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.minimizeToTray`,descriptionKey:`settings.openchamber.desktopNetwork.field.minimizeToTrayDescription`,keywords:[`desktop`,`tray`,`system tray`,`minimize`,`close`,`background`,`windows`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isWindows},{id:`sessions.desktop-keep-awake`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.keepAwake`,descriptionKey:`settings.openchamber.desktopNetwork.field.keepAwakeDescription`,keywords:[`desktop`,`sleep`,`awake`,`server`,`mobile`,`phone`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-ui-password`,page:`sessions`,titleKey:`settings.openchamber.desktopPassword.field.password`,descriptionKey:`settings.openchamber.desktopPassword.field.passwordDescription`,keywords:[`desktop`,`password`,`auth`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-lan-access`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.allowLanAccess`,descriptionKey:`settings.openchamber.desktopNetwork.field.allowLanAccessDescription`,keywords:[`desktop`,`lan`,`network`,`phone`,`tablet`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.opencode-binary`,page:`sessions`,titleKey:`settings.openchamber.opencodeCli.field.binaryPath`,keywords:[`opencode`,`cli`,`binary`,`path`],isAvailable:e=>!e.isVSCode},{id:`sessions.opencode-update-notifications`,page:`sessions`,titleKey:`settings.openchamber.opencodeCli.field.showUpdateNotifications`,keywords:[`opencode`,`cli`,`updates`],isAvailable:e=>!e.isVSCode},{id:`git.github-account`,page:`git`,titleKey:`settings.github.page.actions.connect`,keywords:[`github`,`account`,`oauth`,`prs`,`issues`]},{id:`git.identities`,page:`git`,titleKey:`settings.gitIdentities.page.section.title`,descriptionKey:`settings.gitIdentities.page.empty.description`,keywords:[`identity`,`profile`,`author`,`email`,`credentials`,`signing`,`commit signing`,`ssh signing`,`gpg`]},{id:`git.changes-view`,page:`git`,titleKey:`settings.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.header-menu`,page:`usage`,titleKey:`settings.usage.page.options.showInHeader`,descriptionKey:`settings.usage.page.options.showInHeaderTooltip`,keywords:[`quota`,`header`,`dropdown`]},{id:`usage.model-quotas`,page:`usage`,titleKey:`settings.usage.page.section.modelQuotas`,keywords:[`models`,`quota`,`limits`,`tokens`]},{id:`projects.name`,page:`projects`,titleKey:`settings.projects.page.field.projectName`,keywords:[`label`,`display name`,`project metadata`]},{id:`projects.accent-color`,page:`projects`,titleKey:`settings.projects.page.field.accentColor`,keywords:[`color`,`appearance`,`project metadata`]},{id:`projects.icon`,page:`projects`,titleKey:`settings.projects.page.field.projectIcon`,keywords:[`icon`,`favicon`,`upload`,`project metadata`]},{id:`projects.worktree`,page:`projects`,titleKey:`settings.projects.page.section.worktree`,keywords:[`worktree`,`branch`,`repository`]},{id:`projects.worktree.setup.wait`,page:`projects`,titleKey:`settings.openchamber.worktrees.setup.waitForCommands`,keywords:[`worktree`,`setup commands`,`bootstrap`,`wait`]},{id:`remote-instances.client-auth`,page:`remote-instances`,titleKey:`settings.remoteInstances.clientAuth.title`,descriptionKey:`settings.remoteInstances.clientAuth.description`,keywords:[`pairing link`,`client token`,`connect desktop`,`remote access`,`relay`,`devices`,`connect from anywhere`],isAvailable:e=>!e.isVSCode},{id:`remote-instances.instances`,page:`remote-instances`,titleKey:`settings.remoteInstances.sidebar.title`,descriptionKey:`settings.remoteInstances.sidebar.description`,keywords:[`import link`,`pairing link`,`connect link`,`ssh`,`remote instance`,`host switcher`],isAvailable:e=>e.isDesktop},{id:`behavior.system-prompt`,page:`behavior`,titleKey:`settings.behavior.page.section.systemPrompt`,descriptionKey:`settings.behavior.page.warning.title`,keywords:[`agents.md`,`global instructions`,`system prompt`]},{id:`behavior.response-style`,page:`behavior`,titleKey:`settings.behavior.page.section.responseStyle`,descriptionKey:`settings.behavior.page.responseStyle.tooltip`,keywords:[`tone`,`concise`,`detailed`,`custom instructions`]},{id:`agents.create`,page:`agents`,titleKey:`settings.agents.page.title.new`,keywords:[`create`,`add`,`new agent`]},{id:`assistants.instance-enabled`,page:`assistants`,titleKey:`assistants.settings.instanceEnabled`,descriptionKey:`assistants.settings.description`,keywords:[`assistant`,`enable`,`feature`]},{id:`assistants.create`,page:`assistants`,titleKey:`assistants.settings.create`,keywords:[`assistant`,`new`,`add`]},{id:`assistants.name`,page:`assistants`,titleKey:`assistants.settings.name`,keywords:[`assistant`,`name`]},{id:`assistants.default-share`,page:`assistants`,titleKey:`assistants.settings.defaultShare`,keywords:[`share`,`default`,`mobile`]},{id:`assistants.prompt`,page:`assistants`,titleKey:`assistants.settings.defaultPrompt`,keywords:[`prompt`,`instructions`]},{id:`assistants.model`,page:`assistants`,titleKey:`assistants.settings.model`,keywords:[`provider`,`model`]},{id:`assistants.workspace`,page:`assistants`,titleKey:`assistants.settings.workspace`,keywords:[`path`,`directory`,`workspace`]},{id:`agents.name`,page:`agents`,titleKey:`settings.agents.page.field.agentName`,keywords:[`agent`,`name`]},{id:`agents.mode`,page:`agents`,titleKey:`settings.agents.page.field.mode`,descriptionKey:`settings.agents.page.field.modeTooltip`,keywords:[`primary`,`subagent`,`visibility`]},{id:`agents.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.permissions`,page:`agents`,titleKey:`settings.agents.page.section.toolPermissions`,keywords:[`tools`,`permissions`,`allow`,`ask`,`deny`]},{id:`commands.create`,page:`commands`,titleKey:`settings.commands.page.title.new`,keywords:[`create`,`add`,`new command`]},{id:`commands.name`,page:`commands`,titleKey:`settings.commands.page.field.commandName`,keywords:[`slash command`,`name`]},{id:`commands.agent`,page:`commands`,titleKey:`settings.commands.page.field.overrideAgent`,keywords:[`agent`,`execution`]},{id:`commands.model`,page:`commands`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`]},{id:`commands.template`,page:`commands`,titleKey:`settings.commands.page.section.template`,keywords:[`prompt`,`template`,`arguments`,`shell`,`file`]},{id:`mcp.create`,page:`mcp`,titleKey:`settings.mcp.sidebar.actions.addServerTitle`,keywords:[`create`,`add`,`server`]},{id:`mcp.server`,page:`mcp`,titleKey:`settings.mcp.page.server.title`,keywords:[`server`,`name`,`transport`]},{id:`mcp.command`,page:`mcp`,titleKey:`settings.mcp.page.connection.command`,keywords:[`stdio`,`local`,`command`]},{id:`mcp.environment`,page:`mcp`,titleKey:`settings.mcp.page.env.title`,keywords:[`env`,`variables`,`api key`]},{id:`mcp.advanced`,page:`mcp`,titleKey:`settings.mcp.page.advanced.title`,keywords:[`oauth`,`headers`,`timeout`]},{id:`plugins.create`,page:`plugins`,titleKey:`settings.plugins.sidebar.actions.addTitle`,keywords:[`add`,`plugin`,`npm`,`path`,`file`]},{id:`plugins.spec`,page:`plugins`,titleKey:`settings.plugins.page.field.spec`,keywords:[`npm`,`package`,`path`]},{id:`plugins.options`,page:`plugins`,titleKey:`settings.plugins.page.field.options`,keywords:[`json`,`configuration`]},{id:`plugins.content`,page:`plugins`,titleKey:`settings.plugins.page.field.content`,keywords:[`file`,`code`]},{id:`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.auth`,page:`providers`,titleKey:`settings.providers.page.auth.title`,keywords:[`api key`,`oauth`,`credentials`]},{id:`providers.connection-details`,page:`providers`,titleKey:`settings.providers.page.connectionDetails.title`,keywords:[`config`,`source`,`disconnect`]},{id:`providers.models`,page:`providers`,titleKey:`settings.providers.page.models.title`,keywords:[`models`,`hide`,`show`]},{id:`skills.create`,page:`skills.installed`,titleKey:`settings.skills.page.title.newSkill`,keywords:[`create`,`add`,`new skill`]},{id:`skills.basic-information`,page:`skills.installed`,titleKey:`settings.skills.page.section.basicInformation`,keywords:[`name`,`location`,`description`]},{id:`skills.instructions`,page:`skills.installed`,titleKey:`settings.skills.page.section.instructions`,keywords:[`markdown`,`skill.md`,`content`]},{id:`skills.supporting-files`,page:`skills.installed`,titleKey:`settings.skills.page.section.supportingFiles`,keywords:[`files`,`resources`]},{id:`skills.catalog.source`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.section.sourceRepository`,keywords:[`catalog`,`repository`,`source`,`refresh`]},{id:`skills.catalog.search`,page:`skills.catalog`,titleKey:`settings.skills.catalog.shared.field.searchSkillsPlaceholder`,keywords:[`find skills`,`install skills`,`catalog search`]},{id:`skills.catalog.add-catalog`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.actions.addCatalog`,keywords:[`external repository`,`add source`,`catalog`]},{id:`magic-prompts.visible-prompt`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`,keywords:[`prompt text`,`user message`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.instructions`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.instructions`,keywords:[`hidden prompt`,`instructions`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.reset-overrides`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.actions.resetAllOverrides`,keywords:[`reset`,`default prompts`,`overrides`],isAvailable:e=>!e.isVSCode},{id:`shortcuts.keyboard-shortcuts`,page:`shortcuts`,titleKey:`settings.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:`notifications.delivery`,page:`notifications`,titleKey:`settings.notifications.page.delivery.title`,keywords:[`desktop notifications`,`system notifications`]},{id:`notifications.events`,page:`notifications`,titleKey:`settings.notifications.page.events.title`,keywords:[`completion`,`subtasks`,`errors`,`questions`]},{id:`notifications.push`,page:`notifications`,titleKey:`settings.notifications.page.push.title`,keywords:[`background`,`push`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode}];function Cp(e){return e.trim().toLocaleLowerCase()}function wp({query:e,runtimeCtx:t,visiblePageSlugs:n,t:r,getPageTitle:i}){let a=Cp(e);if(!a)return[];let o=n?new Set(n):null,s=a.split(/\s+/).filter(Boolean);return Sp.flatMap(e=>{if(o&&!o.has(e.page))return[];let n=ei(e.page);if(!n||n.isAvailable&&!n.isAvailable(t)||e.isAvailable&&!e.isAvailable(t))return[];let a=r(e.titleKey),c=e.descriptionKey?r(e.descriptionKey):null,l=Cp([a,c,i(e.page),...e.keywords??[]].filter(Boolean).join(` `));return s.every(e=>l.includes(e))?[{...e,title:a,description:c,pageTitle:i(e.page)}]:[]})}function Tp(e){let t=(0,Di.c)(10),{label:n,children:r,ariaLabel:i,className:a,borderless:o}=e,s=o!==void 0&&o,c;t[0]===a?c=t[1]:(c=q(`oc-mobile-settings-group`,a),t[0]=a,t[1]=c);let l=s&&`oc-mobile-settings-card-borderless`,u;t[2]===l?u=t[3]:(u=q(`oc-mobile-settings-card`,l),t[2]=l,t[3]=u);let d;return t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==c||t[8]!==u?(d=(0,$.jsx)(Z,{label:n,ariaLabel:i,className:c,cardClassName:u,children:r}),t[4]=i,t[5]=r,t[6]=n,t[7]=c,t[8]=u,t[9]=d):d=t[9],d}var Ep=t({SettingsView:()=>Hp,getSettingsNavIcon:()=>Bp}),Dp=176,Op=280,kp=8,Ap=`__openchamberSettingsDetail`;function jp(e){return Math.min(Op,Math.max(Dp,e))}var Mp={icon:`chat-thread`},Np=`__add_provider__`;function Pp(e,t){return{isVSCode:m(),isWeb:!e&&A(),isDesktop:e,isMobile:t}}function Fp(e,t){return!e.isAvailable||e.isAvailable(t)}function Ip(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lp(e,t){let n=new Set(t),r=e,i=1;for(;n.has(r);)r=`${e}-${i}`,i+=1;return r}function Rp(e){if(!Ip(e))return null;let t=e[Ap];if(!Ip(t))return null;let n=t.page,r=t.stage;return typeof n!=`string`||r!==`page-content`?null:{page:fi(n),stage:r}}function zp(){return typeof window>`u`||!Ip(window.history.state)?{}:window.history.state}function Bp(e){switch(e){case`projects`:return`folders`;case`instances`:return`server`;case`remote-instances`:return`server`;case`appearance`:return`palette`;case`chat`:return`chat-ai-3`;case`magic-prompts`:return`ai-generate-2`;case`snippets`:return Mp.icon;case`notifications`:return`notification-3`;case`shortcuts`:return`command`;case`sessions`:return`chat-history`;case`summary-ai`:return`ai-generate-2`;case`providers`:return`cloud`;case`agents`:return`node-tree`;case`assistants`:return`robot-2`;case`behavior`:return`brain`;case`commands`:return`slash-commands-2`;case`mcp`:return null;case`plugins`:return`code-box`;case`global-config`:return`settings-3`;case`skills.installed`:return`book-open`;case`skills.catalog`:return`book`;case`git`:return`git-branch`;case`usage`:return`bar-chart-2`;case`voice`:return`mic`;case`about`:return`information`;case`home`:return null;default:return`robot-2`}}var Vp=e=>{let t=(0,Di.c)(95),{onOpen:n}=e,{t:r}=ke(),i;t[0]===r?i=t[1]:(i=r(`settings.view.home.title`),t[0]=r,t[1]=i);let a;t[2]===i?a=t[3]:(a=(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:i}),t[2]=i,t[3]=a);let o;t[4]===r?o=t[5]:(o=r(`settings.view.home.description`),t[4]=r,t[5]=o);let s;t[6]===o?s=t[7]:(s=(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:o}),t[6]=o,t[7]=s);let c;t[8]!==a||t[9]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,s]}),t[8]=a,t[9]=s,t[10]=c):c=t[10];let l;t[11]===n?l=t[12]:(l=()=>n(`providers`),t[11]=n,t[12]=l);let u;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[13]=u):u=t[13];let d;t[14]===r?d=t[15]:(d=r(`settings.view.home.cards.providers.title`),t[14]=r,t[15]=d);let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:d}),t[16]=d,t[17]=f);let p;t[18]===r?p=t[19]:(p=r(`settings.view.home.cards.providers.description`),t[18]=r,t[19]=p);let m;t[20]===p?m=t[21]:(m=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:p}),t[20]=p,t[21]=m);let h;t[22]!==m||t[23]!==l||t[24]!==f?(h=(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:u,children:[f,m]}),t[22]=m,t[23]=l,t[24]=f,t[25]=h):h=t[25];let g;t[26]===n?g=t[27]:(g=()=>n(`agents`),t[26]=n,t[27]=g);let _;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(_=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[28]=_):_=t[28];let v;t[29]===r?v=t[30]:(v=r(`settings.view.home.cards.agents.title`),t[29]=r,t[30]=v);let y;t[31]===v?y=t[32]:(y=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:v}),t[31]=v,t[32]=y);let b;t[33]===r?b=t[34]:(b=r(`settings.view.home.cards.agents.description`),t[33]=r,t[34]=b);let x;t[35]===b?x=t[36]:(x=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:b}),t[35]=b,t[36]=x);let S;t[37]!==g||t[38]!==y||t[39]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,onClick:g,className:_,children:[y,x]}),t[37]=g,t[38]=y,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n?C=t[42]:(C=()=>n(`skills.catalog`),t[41]=n,t[42]=C);let w;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(w=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[43]=w):w=t[43];let T;t[44]===r?T=t[45]:(T=r(`settings.view.home.cards.skillsCatalog.title`),t[44]=r,t[45]=T);let E;t[46]===T?E=t[47]:(E=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:T}),t[46]=T,t[47]=E);let D;t[48]===r?D=t[49]:(D=r(`settings.view.home.cards.skillsCatalog.description`),t[48]=r,t[49]=D);let O;t[50]===D?O=t[51]:(O=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:D}),t[50]=D,t[51]=O);let k;t[52]!==C||t[53]!==E||t[54]!==O?(k=(0,$.jsxs)(`button`,{type:`button`,onClick:C,className:w,children:[E,O]}),t[52]=C,t[53]=E,t[54]=O,t[55]=k):k=t[55];let A;t[56]===n?A=t[57]:(A=()=>n(`mcp`),t[56]=n,t[57]=A);let j;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(j=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[58]=j):j=t[58];let M;t[59]===r?M=t[60]:(M=r(`settings.view.home.cards.mcp.title`),t[59]=r,t[60]=M);let N;t[61]===M?N=t[62]:(N=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:M}),t[61]=M,t[62]=N);let P;t[63]===r?P=t[64]:(P=r(`settings.view.home.cards.mcp.description`),t[63]=r,t[64]=P);let F;t[65]===P?F=t[66]:(F=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:P}),t[65]=P,t[66]=F);let I;t[67]!==A||t[68]!==N||t[69]!==F?(I=(0,$.jsxs)(`button`,{type:`button`,onClick:A,className:j,children:[N,F]}),t[67]=A,t[68]=N,t[69]=F,t[70]=I):I=t[70];let L;t[71]===n?L=t[72]:(L=()=>n(`usage`),t[71]=n,t[72]=L);let R;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(R=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[73]=R):R=t[73];let z;t[74]===r?z=t[75]:(z=r(`settings.view.home.cards.usage.title`),t[74]=r,t[75]=z);let B;t[76]===z?B=t[77]:(B=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:z}),t[76]=z,t[77]=B);let V;t[78]===r?V=t[79]:(V=r(`settings.view.home.cards.usage.description`),t[78]=r,t[79]=V);let H;t[80]===V?H=t[81]:(H=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:V}),t[80]=V,t[81]=H);let ee;t[82]!==L||t[83]!==B||t[84]!==H?(ee=(0,$.jsxs)(`button`,{type:`button`,onClick:L,className:R,children:[B,H]}),t[82]=L,t[83]=B,t[84]=H,t[85]=ee):ee=t[85];let U;t[86]!==h||t[87]!==S||t[88]!==k||t[89]!==I||t[90]!==ee?(U=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[h,S,k,I,ee]}),t[86]=h,t[87]=S,t[88]=k,t[89]=I,t[90]=ee,t[91]=U):U=t[91];let te;return t[92]!==U||t[93]!==c?(te=(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6 space-y-6`,children:[c,U]})}),t[92]=U,t[93]=c,t[94]=te):te=t[94],te},Hp=e=>{let t=(0,Di.c)(178),{onClose:n,mobileInstancesPage:r,forceMobile:i,isWindowed:a,visiblePageSlugs:o,hideMobileHeader:s,flowMobile:c,autoOpenMobilePage:l,initialMobileStage:d,onMobileStageChange:f}=e,p=s!==void 0&&s,m=c!==void 0&&c,h=l===void 0||l,g=d===void 0?`nav`:d,{t:_}=ke(),v=fr(),y=i??v.isMobile,b=u(Up),x=u(Wp),S=u(Gp),C;t[0]===b?C=t[1]:(C=fi(b),t[0]=b,t[1]=C);let E=C,D=E===`commands`,O;t[2]===D?O=t[3]:(O={enabled:D},t[2]=D,t[3]=O);let{refetch:k}=_t(O),A,j;t[4]!==k||t[5]!==E?(A=()=>{E===`commands`&&k()},j=[k,E],t[4]=k,t[5]=E,t[6]=A,t[7]=j):(A=t[6],j=t[7]),Q.useEffect(A,j);let[M,N]=Q.useState(g),P=p&&M===`nav`,F=y&&m,I=Q.useRef(null),L=Q.useRef(0),R=Ut(Kp),z,B;t[8]!==y||t[9]!==R||t[10]!==S||t[11]!==E?(z=()=>{if(!y||R<=L.current)return;let e=Ut.getState().settingsSelectedAssistantID;if(!(!e||e===`new`)){if(E!==`assistants`){S(`assistants`);return}L.current=R,I.current=`assistants`,N(`page-content`)}},B=[y,R,S,E],t[8]=y,t[9]=R,t[10]=S,t[11]=E,t[12]=z,t[13]=B):(z=t[12],B=t[13]),Q.useEffect(z,B);let V,ee;t[14]!==M||t[15]!==f?(V=()=>{f?.(M)},ee=[M,f],t[14]=M,t[15]=f,t[16]=V,t[17]=ee):(V=t[16],ee=t[17]),Q.useEffect(V,ee);let[U,te]=Q.useState(216),[W,ne]=Q.useState(``),[re,ie]=Q.useState(null),[ae,oe]=Q.useState(0),[se,ce]=Q.useState(!1),[le,ue]=Q.useState(!1),de=Q.useRef(0),fe=Q.useRef(U),pe=Q.useRef(null),me=Q.useRef(null),he=Q.useRef(null),ge=Q.useRef(null),_e=Q.useRef(null),ve=Q.useRef(null),ye;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ye=[],t[18]=ye):ye=t[18];let xe=Q.useRef(ye),Se=Q.useRef(0),Ce=Q.useRef(!1),we;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(we=w(),t[19]=we):we=t[19];let Te=we,Ee;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=w()&&T(),t[20]=Ee):Ee=t[20];let De=Ee,Oe;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=w()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`darwin`,t[21]=Oe):Oe=t[21];let Ae=Oe,je;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(je=w()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`win32`,t[22]=je):je=t[22];let Me=je,Ne;t[23]===y?Ne=t[24]:(Ne=Pp(Te,y),t[23]=y,t[24]=Ne);let Pe=Ne,Fe;if(t[25]!==y||t[26]!==r||t[27]!==Pe||t[28]!==o){let e=o?new Set(o):null,n;t[30]===Pe?n=t[31]:(n=e=>Fp(e,Pe),t[30]=Pe,t[31]=n);let i;t[32]===r?i=t[33]:(i=e=>e.slug!==`instances`||!!r,t[32]=r,t[33]=i);let a;t[34]===Pe.isVSCode?a=t[35]:(a=e=>!(Pe.isVSCode&&e.slug===`projects`),t[34]=Pe.isVSCode,t[35]=a);let s;t[36]===y?s=t[37]:(s=e=>!(y&&e.slug===`shortcuts`),t[36]=y,t[37]=s),Fe=di.filter(qp).filter(t=>!e||e.has(t.slug)).filter(n).filter(i).filter(a).filter(s),t[25]=y,t[26]=r,t[27]=Pe,t[28]=o,t[29]=Fe}else Fe=t[29];let Ie=Fe,Le;t[38]===Ie?Le=t[39]:(Le=oi(Ie),t[38]=Ie,t[39]=Le);let Re=Le,ze=ft(Jp),Be,Ve;t[40]===se?(Be=t[41],Ve=t[42]):(Be=()=>{if(typeof window>`u`)return;let e=()=>{if(!se){let e=jp(Math.floor(window.innerWidth*.12));te(e)}};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},Ve=[se],t[40]=se,t[41]=Be,t[42]=Ve),Q.useEffect(Be,Ve);let He,Ue;t[43]===le?(He=t[44],Ue=t[45]):(He=()=>{if(!le)return;let e=e=>{let t=e.clientX-de.current,n=jp(fe.current+t);te(n),ce(!0)},t=()=>ue(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},Ue=[le],t[43]=le,t[44]=He,t[45]=Ue),Q.useEffect(He,Ue);let We;t[46]===U?We=t[47]:(We=e=>{ue(!0),de.current=e.clientX,fe.current=U,e.preventDefault()},t[46]=U,t[47]=We);let Ge=We,Ke;t[48]===U?Ke=t[49]:(Ke=e=>{let t=e.shiftKey?32:kp,n;bb155:switch(e.key){case`ArrowLeft`:n=U-t;break bb155;case`ArrowRight`:n=U+t;break bb155;case`Home`:n=Dp;break bb155;case`End`:n=Op;break bb155;default:return}e.preventDefault(),te(jp(n)),ce(!0)},t[48]=U,t[49]=Ke);let qe=Ke,Ye;t[50]!==x||t[51]!==a||t[52]!==Pe.isVSCode||t[53]!==E?(Ye=()=>{if(!(!x&&!Pe.isVSCode&&!a)){if(E===`agents`){et.getState().loadAgents();return}if(E!==`commands`&&E!==`mcp`){if(E===`plugins`){Ps.getState().loadPlugins();return}(E===`skills.installed`||E===`skills.catalog`)&&tt(H,Je()),E===`snippets`&&cn.getState().loadSnippets()}}},t[50]=x,t[51]=a,t[52]=Pe.isVSCode,t[53]=E,t[54]=Ye):Ye=t[54];let Xe;t[55]!==ze||t[56]!==x||t[57]!==a||t[58]!==Pe.isVSCode||t[59]!==E?(Xe=[ze,x,a,Pe.isVSCode,E],t[55]=ze,t[56]=x,t[57]=a,t[58]=Pe.isVSCode,t[59]=E,t[60]=Xe):Xe=t[60],Q.useEffect(Ye,Xe);let Ze;t[61]!==y||t[62]!==S?(Ze=e=>{if(S(e),I.current=e,!y)return;let t=ei(e);if(!t||t.slug===`home`){N(`nav`);return}N(t.kind===`split`?`page-sidebar`:`page-content`)},t[61]=y,t[62]=S,t[63]=Ze):Ze=t[63];let Qe=Ze,$e;t[64]===E?$e=t[65]:($e=ei(E),t[64]=E,t[65]=$e);let G=$e,nt;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(nt={appearance:`visual`,chat:`chat`,shortcuts:`shortcuts`,sessions:`sessions`,"summary-ai":`summary-ai`,notifications:`notifications`,voice:`voice`},t[66]=nt):nt=t[66];let rt=nt,it;t[67]===_?it=t[68]:(it=e=>{switch(e){case`projects`:return _(`settings.page.projects.title`);case`instances`:return _(`mobile.settings.switchInstance`);case`remote-instances`:return _(`settings.page.remoteInstances.title`);case`providers`:return _(`settings.page.providers.title`);case`usage`:return _(`settings.page.usage.title`);case`agents`:return _(`settings.page.agents.title`);case`assistants`:return _(`settings.page.assistants.title`);case`behavior`:return _(`settings.page.behavior.title`);case`commands`:return _(`settings.page.commands.title`);case`mcp`:return _(`settings.page.mcp.title`);case`plugins`:return _(`settings.page.plugins.title`);case`global-config`:return _(`settings.globalConfig.title`);case`skills.installed`:return _(`settings.page.skills.title`);case`skills.catalog`:return _(`settings.page.skillsCatalog.title`);case`git`:return _(`settings.page.git.title`);case`appearance`:return _(`settings.page.appearance.title`);case`chat`:return _(`settings.page.chat.title`);case`shortcuts`:return _(`settings.page.shortcuts.title`);case`sessions`:return _(`settings.page.sessions.title`);case`summary-ai`:return _(`settings.page.summaryAI.title`);case`magic-prompts`:return _(`settings.page.magicPrompts.title`);case`snippets`:return _(`settings.page.snippets.title`);case`notifications`:return _(`settings.page.notifications.title`);case`voice`:return _(`settings.page.voice.title`);case`about`:return _(`settings.page.about.title`);default:return _(`settings.view.home.title`)}},t[67]=_,t[68]=it);let at=it,ot;t[69]!==at||t[70]!==Pe||t[71]!==W||t[72]!==_||t[73]!==Ie?(ot=wp({query:W,runtimeCtx:{...Pe,isDesktopLocalOrigin:De,isMac:Ae,isWindows:Me},visiblePageSlugs:Ie.map(Yp),t:_,getPageTitle:at}),t[69]=at,t[70]=Pe,t[71]=W,t[72]=_,t[73]=Ie,t[74]=ot):ot=t[74];let st=ot,ct=tm,lt;if(t[75]!==st){lt=[];let e=new Map;for(let t of st){let n=e.get(t.page);n||(n={page:t.page,pageTitle:t.pageTitle,results:[]},e.set(t.page,n),lt.push(n)),n.results.push(t)}t[75]=st,t[76]=lt}else lt=t[76];let ut=lt,dt;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(dt=()=>{oe(0),Se.current=0,Ce.current=!1},t[77]=dt):dt=t[77];let pt;t[78]===W?pt=t[79]:(pt=[W],t[78]=W,t[79]=pt),Q.useEffect(dt,pt);let mt,ht;t[80]===ae?(mt=t[81],ht=t[82]):(mt=()=>{Se.current=ae},ht=[ae],t[80]=ae,t[81]=mt,t[82]=ht),Q.useEffect(mt,ht);let gt,K;t[83]===ae?(gt=t[84],K=t[85]):(gt=()=>{xe.current[ae]?.scrollIntoView({block:`nearest`})},K=[ae],t[83]=ae,t[84]=gt,t[85]=K),Q.useEffect(gt,K);let vt,yt;t[86]!==ae||t[87]!==st.length?(vt=()=>{ae>=st.length&&oe(Math.max(0,st.length-1)),xe.current.length=st.length},yt=[ae,st.length],t[86]=ae,t[87]=st.length,t[88]=vt,t[89]=yt):(vt=t[88],yt=t[89]),Q.useEffect(vt,yt);let bt;t[90]!==y||t[91]!==Qe?(bt=e=>{let t=ct(e);ie(t),Qe(e.page),y&&N(`page-content`),e.id===`plugins.create`&&typeof window<`u`&&window.setTimeout(nm,50)},t[90]=y,t[91]=Qe,t[92]=bt):bt=t[92];let xt=bt,St;t[93]!==xt||t[94]!==W||t[95]!==st?(St=e=>{if(W.trim()){if(e.key===`Escape`){e.preventDefault(),ne(``);return}if(st.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),Ce.current=!0,oe(e=>(e+1)%st.length);return}if(e.key===`ArrowUp`){e.preventDefault(),Ce.current=!0,oe(e=>(e-1+st.length)%st.length);return}if(e.key===`Enter`){e.preventDefault();let t=(Se.current%st.length+st.length)%st.length,n=st[t]??st[0];n&&xt(n)}}}},t[93]=xt,t[94]=W,t[95]=st,t[96]=St):St=t[96];let wt=St,Tt;t[97]===re?Tt=t[98]:(Tt=()=>{let e=re;if(!e)return;let t=!1,n=window.requestAnimationFrame(()=>{if(t)return;let n=typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`),r=pe.current?.querySelector(`[data-settings-item="${n}"]`);r&&(ie(null),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.setAttribute(`data-settings-search-highlight`,`true`),window.setTimeout(()=>{r.removeAttribute(`data-settings-search-highlight`)},1600))});return()=>{t=!0,window.cancelAnimationFrame(n)}},t[97]=re,t[98]=Tt);let Et;t[99]!==re||t[100]!==E?(Et=[re,E],t[99]=re,t[100]=E,t[101]=Et):Et=t[101],Q.useEffect(Tt,Et);let Dt;t[102]===_?Dt=t[103]:(Dt=()=>(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:_(`settings.view.unavailable.title`)}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground mt-1`,children:_(`settings.view.unavailable.description`)})]})}),t[102]=_,t[103]=Dt);let Ot=Dt,kt=rm,At;t[104]!==y||t[105]!==Pe.isVSCode||t[106]!==E?(At=()=>{if(y){if(be()||Pe.isVSCode){N(`page-sidebar`);return}if((typeof window<`u`?Rp(window.history.state):null)?.page===E){window.history.back();return}N(`page-sidebar`)}},t[104]=y,t[105]=Pe.isVSCode,t[106]=E,t[107]=At):At=t[107];let jt=At,Mt;t[108]!==jt||t[109]!==y||t[110]!==F||t[111]!==r||t[112]!==Qe||t[113]!==Ot||t[114]!==Pe?(Mt=e=>{let t=ei(e);if(t&&!Fp(t,Pe))return Ot();switch(e){case`home`:return(0,$.jsx)(Vp,{onOpen:Qe});case`projects`:return(0,$.jsx)(xl,{});case`instances`:return r??Ot();case`remote-instances`:return(0,$.jsx)(Bu,{});case`agents`:return(0,$.jsx)(Za,{});case`assistants`:return(0,$.jsx)(vo,{onItemDeleted:y?jt:void 0});case`behavior`:return(0,$.jsx)(jo,{});case`commands`:return(0,$.jsx)(zo,{});case`mcp`:return(0,$.jsx)(ws,{});case`plugins`:return(0,$.jsx)(bc,{});case`global-config`:return(0,$.jsx)(Cc,{});case`skills.installed`:return(0,$.jsx)(fl,{view:`installed`});case`skills.catalog`:return(0,$.jsx)(fl,{view:`catalog`});case`providers`:return(0,$.jsx)(rd,{});case`usage`:return(0,$.jsx)(Dd,{});case`about`:return(0,$.jsx)(`div`,{className:q(`h-full overflow-auto px-5 py-6`,F&&`h-auto overflow-visible p-3`),children:(0,$.jsx)(Pi,{})});case`magic-prompts`:return(0,$.jsx)(Id,{});case`snippets`:return(0,$.jsx)(Vd,{});case`git`:return(0,$.jsx)(Yd,{});case`appearance`:case`chat`:case`shortcuts`:case`sessions`:case`summary-ai`:case`notifications`:case`voice`:{let t=rt[e]??`visual`;return(0,$.jsx)(fp,{section:t,flowMobile:F})}default:return(0,$.jsx)(Vp,{onOpen:Qe})}},t[108]=jt,t[109]=y,t[110]=F,t[111]=r,t[112]=Qe,t[113]=Ot,t[114]=Pe,t[115]=Mt):Mt=t[115];let Nt=Mt,Pt,Ft;t[116]!==h||t[117]!==y||t[118]!==M||t[119]!==E?(Pt=()=>{if(!y||!h||M!==`nav`||E===`home`||I.current===E)return;let e=ei(E);!e||e.slug===`home`||(I.current=E,N(e.kind===`split`?`page-sidebar`:`page-content`))},Ft=[h,y,M,E],t[116]=h,t[117]=y,t[118]=M,t[119]=E,t[120]=Pt,t[121]=Ft):(Pt=t[120],Ft=t[121]),Q.useEffect(Pt,Ft);let It,Lt;t[122]!==m||t[123]!==E?(It=()=>{!m||E!==`home`||(I.current=null,N(`nav`))},Lt=[m,E],t[122]=m,t[123]=E,t[124]=It,t[125]=Lt):(It=t[124],Lt=t[125]),Q.useEffect(It,Lt);let Rt=y&&M!==`nav`,zt=y&&M===`page-content`&&G?.kind===`split`,Bt=M===`page-content`&&G?.kind===`split`&&!zt,Vt;t[126]!==zt||t[127]!==Rt||t[128]!==_?(Vt=_(zt?`settings.view.actions.back`:Rt?`settings.view.actions.backToSettings`:`settings.view.actions.closeSettings`),t[126]=zt,t[127]=Rt,t[128]=_,t[129]=Vt):Vt=t[129];let Wt=Vt,Gt=Xt(),Kt;t[130]===Pe.isVSCode?Kt=t[131]:(Kt=e=>{if(typeof window>`u`||Pe.isVSCode||be())return;let t=Rp(window.history.state);(t?.page!==e||t.stage!==`page-content`)&&window.history.pushState({...zp(),[Ap]:{page:e,stage:`page-content`}},``,window.location.href)},t[130]=Pe.isVSCode,t[131]=Kt);let qt=Kt,Jt;t[132]!==qt||t[133]!==E?(Jt=()=>{N(`page-content`),qt(E)},t[132]=qt,t[133]=E,t[134]=Jt):Jt=t[134];let Yt=Jt,Zt;t[135]!==zt||t[136]!==m||t[137]!==jt||t[138]!==S?(Zt=()=>{if(m&&Ct.getState().settingsReturnTo){I.current=null,N(`nav`),S(`home`),Ct.getState().restoreSettingsReturnTo();return}if(zt){jt();return}N(`nav`)},t[135]=zt,t[136]=m,t[137]=jt,t[138]=S,t[139]=Zt):Zt=t[139];let Y=Zt,Qt;t[140]!==G?.kind||t[141]!==M?(Qt=()=>{if(M===`page-content`){_e.current=ge.current,ve.current=G?.kind===`split`?he.current:me.current;return}_e.current=he.current,ve.current=me.current},t[140]=G?.kind,t[141]=M,t[142]=Qt):Qt=t[142];let $t=G?.kind,en;t[143]!==M||t[144]!==$t?(en=[$t,M],t[143]=M,t[144]=$t,t[145]=en):en=t[145],Q.useLayoutEffect(Qt,en);let tn=`mobile-settings:${E}`,nn=F&&M!==`nav`,rn;t[146]!==Y||t[147]!==tn||t[148]!==nn?(rn={id:tn,active:nn,onBack:Y,surfaceRef:_e,underlayRef:ve},t[146]=Y,t[147]=tn,t[148]=nn,t[149]=rn):rn=t[149],_r(rn);let an,on;t[150]!==y||t[151]!==Pe.isVSCode||t[152]!==E?(an=()=>{if(!y||Pe.isVSCode||be())return;let e=e=>{if(ei(E)?.kind===`split`){if(Rp(e.state)?.page===E){N(`page-content`);return}N(im)}};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},on=[y,Pe.isVSCode,E],t[150]=y,t[151]=Pe.isVSCode,t[152]=E,t[153]=an,t[154]=on):(an=t[153],on=t[154]),Q.useEffect(an,on);let sn;t[155]===Symbol.for(`react.memo_cache_sentinel`)?(sn=()=>{N(`page-sidebar`)},t[155]=sn):sn=t[155];let ln=sn,un=()=>{let e=W.trim().length>0;return(0,$.jsxs)(`div`,{className:q(`flex h-full flex-col overflow-hidden`,y&&`oc-settings-navigation-content`,F&&`h-auto w-full overflow-visible`),children:[(0,$.jsx)(`div`,{className:q(`px-2 pt-3`,y&&`oc-mobile-settings-search`),children:(0,$.jsxs)(`div`,{className:q(`flex h-10 items-center gap-1.5 rounded-md border border-border bg-background/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-primary/40 sm:h-8`,y&&`oc-mobile-settings-search-field`),children:[(0,$.jsx)(J,{name:`search`,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`input`,{value:W,onChange:e=>ne(e.target.value),onKeyDown:wt,placeholder:_(`settings.view.search.placeholder`),"aria-label":_(`settings.view.search.aria`),className:`typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70`}),e&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ne(``),"aria-label":_(`settings.view.search.clear`),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5`,children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsx)(`div`,{className:q(`flex-1 min-h-0 overflow-y-auto overflow-x-hidden`,F&&`w-full flex-none overflow-visible`),children:(0,$.jsx)(`div`,{className:q(y?`oc-mobile-settings-nav-list flex min-w-0 flex-col`:`flex flex-col gap-0.5 px-2 pb-2 pt-4`),children:e?st.length>0?(()=>{let e=0;return ut.map(t=>{let n=t.results.map(t=>{let n=e;e+=1;let r=n===ae,i=!!t.description;return(0,$.jsxs)(`button`,{type:`button`,ref:e=>{xe.current[n]=e},onMouseMove:()=>{Ce.current=!1,oe(n)},onClick:()=>xt(t),className:q(y?`oc-mobile-settings-row oc-mobile-settings-search-result`:`flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`min-h-11 py-1.5`:`py-2`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.title}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 line-clamp-2`,children:t.description})]}),y?(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]},t.id)});return y?(0,$.jsx)(Tp,{label:t.pageTitle,ariaLabel:t.pageTitle,children:n},t.page):(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70`,children:t.pageTitle}),n]},t.page)})})():(0,$.jsx)(`div`,{className:`px-2 py-6 text-center typography-ui text-muted-foreground`,children:_(`settings.view.search.noResults`)}):(0,$.jsx)($.Fragment,{children:Re.map((e,t)=>{let{group:n,pages:r}=e,i=_(`settings.view.navigation.groups.${n}`),a=r.map(e=>{let t=E===e.slug,n=Bp(e.slug);return!n&&e.slug!==`mcp`?null:(0,$.jsx)(pn,{children:(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Qe(e.slug),"aria-current":t?`page`:void 0,className:q(y?`oc-mobile-settings-row`:`flex h-8 w-full items-center gap-2 overflow-hidden rounded-md px-2 text-left`,t&&!y?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:[e.slug===`mcp`?(0,$.jsx)(Vr,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(J,{name:n,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden whitespace-nowrap transition-opacity duration-150 opacity-100`,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate`,children:at(e.slug)})}),y?(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]})})},e.slug)});return y?(0,$.jsx)(Tp,{label:i,ariaLabel:i,children:a},n):(0,$.jsxs)(`div`,{className:q(`space-y-0.5`,t>0&&`pt-3`),children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 typography-micro font-medium text-muted-foreground/70`,children:i}),a]},n)})})})}),(0,$.jsx)(`div`,{className:q(`overflow-hidden transition-opacity duration-150 opacity-100`,y&&`oc-mobile-settings-footer`),children:(0,$.jsx)(`div`,{className:q(`border-t border-border bg-sidebar px-2 py-1 space-y-0.5`,y&&`oc-mobile-floating-surface oc-mobile-settings-card`),children:!Pe.isVSCode&&(0,$.jsxs)(pn,{children:[(0,$.jsx)(dn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:q(y?`oc-mobile-settings-row`:`flex h-7 w-full items-center gap-2 rounded-md px-2 overflow-hidden whitespace-nowrap`,`text-sm font-semibold text-sidebar-foreground/90`,`hover:text-sidebar-foreground hover:bg-interactive-hover`),onClick:om,children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:_(`settings.view.actions.reloadOpenCode`)})]})}),(0,$.jsx)(fn,{children:_(`settings.view.actions.reloadOpenCodeTooltip`)})]})})})]})},mn=()=>(0,$.jsx)(`div`,{className:q(`flex-1 min-h-0 overflow-hidden`,F?`w-full flex-none overflow-visible bg-transparent`:Pe.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(`div`,{className:q(`flex h-full min-h-0 flex-col`,F&&`h-auto w-full overflow-visible`),children:(0,$.jsx)(Rn,{children:un()})})}),hn=e=>{let t=e===void 0?M:e;if(t===`nav`)return mn();let n=q(`flex-1 min-h-0 overflow-hidden bg-transparent`,F?`w-full flex-none overflow-visible`:`px-[var(--oc-mobile-page-inline-inset)]`);if(!G)return(0,$.jsx)(`div`,{className:n});if(t===`page-sidebar`){if(G.kind!==`split`){let e=Nt(E);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(ci,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Rn,{children:e})})})}return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(ci,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Rn,{children:kt(E,{onItemSelect:Yt})})})})}let r=Nt(E);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(ci,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(Rn,{children:r})})})},gn;t[156]!==G||t[157]!==Qe||t[158]!==Nt||t[159]!==Pe.isVSCode||t[160]!==E?(gn=()=>!G||E===`home`?(0,$.jsx)(Vp,{onOpen:Qe}):G.kind===`split`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:q(`w-[264px] min-w-[264px] border-r`,Pe.isVSCode?`bg-background`:`bg-sidebar`),style:{borderColor:`var(--interactive-border)`},children:(0,$.jsx)(Rn,{children:kt(E,{})})}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(Rn,{children:Nt(E)})})]}):(0,$.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(Rn,{children:Nt(E)})}),t[156]=G,t[157]=Qe,t[158]=Nt,t[159]=Pe.isVSCode,t[160]=E,t[161]=gn):gn=t[161];let _n=gn,vn=e=>(0,$.jsx)(Ht,{sticky:!0,title:(e===void 0?M:e)===`nav`?_(`settings.view.home.title`):G?at(G.slug):_(`settings.view.home.title`),backAriaLabel:Wt,onBack:Rt?Y:n,actions:[...Bt?[{icon:`list-unordered`,ariaLabel:_(`settings.view.actions.openSectionList`),onClick:ln}]:[],...n?[{icon:`close`,ariaLabel:_(`settings.view.actions.closeSettings`),title:_(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:Gt}),onClick:n}]:[]]});if(F){let e=M!==`nav`,n=e&&G?.kind===`split`,r=M===`page-content`,i=M===`page-sidebar`,a=r&&G?.kind===`split`,o=e&&!a,s;t[162]===_?s=t[163]:(s=_(`mobile.settings.placeholder.title`),t[162]=_,t[163]=s);let c;return t[164]===s?c=t[165]:(c=(0,$.jsx)(Qr,{title:s}),t[164]=s,t[165]=c),(0,$.jsxs)(`div`,{ref:pe,"data-settings-view":`true`,"data-mobile-settings-detail-active":e?`true`:void 0,className:`oc-settings-workspace oc-settings-workspace-mobile h-auto w-full min-w-0 overflow-visible bg-transparent`,children:[(0,$.jsxs)(`div`,{ref:me,"data-mobile-settings-stage":`nav`,"data-mobile-navigation-underlay":o?`true`:void 0,"aria-hidden":e?`true`:void 0,inert:e?!0:void 0,className:`oc-mobile-settings-root-surface fixed inset-0 z-20 flex h-[100dvh] w-full min-w-0 max-w-full flex-col gap-[var(--oc-mobile-page-gap)] overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)] pb-[calc(var(--oc-mobile-dock-height)+2.5rem+var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px)))] pt-[calc(var(--oc-safe-area-top,env(safe-area-inset-top,0px))+1rem)] [contain:layout_paint]`,children:[c,mn()]}),n?(0,$.jsxs)(`div`,{ref:he,"data-mobile-settings-stage":`page-sidebar`,"data-mobile-navigation-underlay":a?`true`:void 0,"data-mobile-settings-push-surface":`true`,"aria-hidden":i?void 0:`true`,inert:!i||void 0,className:`fixed inset-0 z-40 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[vn(`page-sidebar`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)]`,children:hn(`page-sidebar`)})]}):null,r?(0,$.jsxs)(`div`,{ref:ge,"data-mobile-settings-stage":`page-content`,"data-mobile-settings-push-surface":`true`,className:`fixed inset-0 z-50 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[vn(`page-content`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)]`,children:hn(`page-content`)})]}):null]})}let yn=y?`oc-settings-workspace-mobile bg-transparent`:`oc-settings-workspace-desktop bg-background`,bn=F&&`h-auto w-full overflow-visible`,xn;t[166]!==yn||t[167]!==bn?(xn=q(`oc-settings-workspace relative flex h-full min-h-0 flex-col overflow-hidden`,yn,bn),t[166]=yn,t[167]=bn,t[168]=xn):xn=t[168];let Sn=y&&!P?vn():y?null:(0,$.jsxs)($.Fragment,{children:[Rt&&(0,$.jsx)(`div`,{className:q(`absolute left-3 z-50`,a?`top-2`:`top-3`),children:(0,$.jsx)(`button`,{type:`button`,onClick:Y,"aria-label":_(`settings.view.actions.back`),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(J,{name:`arrow-left-s`,className:`h-5 w-5`})})}),n&&(0,$.jsx)(`div`,{className:q(`absolute right-0.5 z-50`,a?`top-0.5`:`top-1`),children:(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":_(`settings.view.actions.closeSettings`),title:_(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:Gt}),className:`inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(J,{name:`close`,className:`h-5 w-5`})})})]}),Cn=F&&`w-full flex-none overflow-visible`,wn;t[169]===Cn?wn=t[170]:(wn=q(`flex flex-1 min-h-0 overflow-hidden`,Cn),t[169]=Cn,t[170]=wn);let Tn=y?hn():(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:q(`relative flex h-full min-h-0 flex-col overflow-hidden border-r`,Te?`bg-sidebar`:Pe.isVSCode?`bg-background`:`bg-sidebar`,le?``:`transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]`),style:{width:`${U}px`,minWidth:`${U}px`,borderColor:`var(--interactive-border)`},children:[(0,$.jsx)(`div`,{className:q(`absolute right-0 top-0 z-20 h-full w-[6px] -mr-[3px] cursor-col-resize`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,le?`bg-primary/30`:`bg-transparent hover:bg-primary/20`),tabIndex:0,onPointerDown:Ge,onKeyDown:qe,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":Dp,"aria-valuemax":Op,"aria-valuenow":U,"aria-label":_(`settings.view.actions.resizeNavigation`)}),(0,$.jsx)(Rn,{children:un()})]}),(0,$.jsx)(`div`,{className:`oc-settings-detail-pane flex-1 overflow-hidden bg-background`,children:_n()})]}),En;t[171]!==wn||t[172]!==Tn?(En=(0,$.jsx)(`div`,{className:wn,children:Tn}),t[171]=wn,t[172]=Tn,t[173]=En):En=t[173];let Dn;return t[174]!==xn||t[175]!==Sn||t[176]!==En?(Dn=(0,$.jsxs)(`div`,{ref:pe,"data-settings-view":`true`,className:xn,children:[Sn,En]}),t[174]=xn,t[175]=Sn,t[176]=En,t[177]=Dn):Dn=t[177],Dn};function Up(e){return e.settingsPage}function Wp(e){return e.isSettingsDialogOpen}function Gp(e){return e.setSettingsPage}function Kp(e){return e.openSettingsRequestRevision}function qp(e){return e.slug!==`home`}function Jp(e){return e.activeProjectId}function Yp(e){return e.slug}function Xp(e){return e.name}function Zp(e){return e.name}function Qp(e){return e.name}function $p(e){return e.name}function em(e){return e.name}function tm(e){if(e.id.startsWith(`assistants.`)){if(e.id===`assistants.instance-enabled`)return e.id;if(e.id===`assistants.default-share`){let t=Ut.getState(),n=Mt()?.assistants??[],r=n.some(e=>e.id===t.settingsSelectedAssistantID);return t.selectSettingsAssistant(r?t.settingsSelectedAssistantID:n[0]?.id??null),e.id}return Ut.getState().requestCreate(),e.id===`assistants.create`?`assistants.name`:e.id}if(e.id.startsWith(`agents.`)){let t=et.getState(),n=Lp(`new-agent`,at().map(Xp));return t.setAgentDraft({name:n,scope:`user`}),t.setSelectedAgent(n),e.id===`agents.create`?`agents.name`:e.id}if(e.id.startsWith(`commands.`)){let t=Ki.getState(),n=Lp(`new-command`,ot().map(Zp));return t.setCommandDraft({name:n,scope:`user`}),t.setSelectedCommand(n),e.id===`commands.create`?`commands.name`:e.id}if(e.id.startsWith(`mcp.`)){let t=ea.getState(),n=Lp(`new-mcp-server`,Mr().map(Qp));return t.setMcpDraft({name:n,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),t.setSelectedMcp(n),e.id===`mcp.create`?`mcp.server`:e.id}if(e.id.startsWith(`snippets.`)){let t=cn.getState(),n=Lp(`new-snippet`,t.snippets.map($p));return t.setSnippetDraft({name:n,scope:`global`}),t.setSelectedSnippet(n),e.id===`snippets.create`?`snippets.content`:e.id}if(e.id.startsWith(`skills.`)){let t=Qe(H),n=fa.getState(),r=Lp(`new-skill`,t.map(em));return n.setSkillDraft({name:r,scope:`user`,source:`opencode`,description:``,instructions:``}),n.setSelectedSkill(r),e.id===`skills.create`?`skills.basic-information`:e.id}return e.id===`providers.connect`&&G.getState().setSelectedProvider(Np),e.id===`plugins.create`?`plugins.spec`:e.id}function nm(){window.dispatchEvent(new CustomEvent(`openchamber:settings-open-plugin-add`))}function rm(e,t){switch(e){case`projects`:return(0,$.jsx)(ml,{onItemSelect:t.onItemSelect});case`agents`:return(0,$.jsx)(ka,{onItemSelect:t.onItemSelect});case`assistants`:return(0,$.jsx)(_o,{onItemSelect:t.onItemSelect});case`commands`:return(0,$.jsx)(Mo,{onItemSelect:t.onItemSelect});case`mcp`:return(0,$.jsx)(Uo,{onItemSelect:t.onItemSelect});case`plugins`:return(0,$.jsx)(oc,{onItemSelect:t.onItemSelect});case`skills.installed`:return(0,$.jsx)(Ec,{onItemSelect:t.onItemSelect});case`providers`:return(0,$.jsx)(Uu,{onItemSelect:t.onItemSelect});case`usage`:return(0,$.jsx)(ad,{onItemSelect:t.onItemSelect});case`magic-prompts`:return(0,$.jsx)(Ad,{onItemSelect:t.onItemSelect});case`snippets`:return(0,$.jsx)(Ld,{onItemSelect:t.onItemSelect});default:return null}}function im(e){return e===`page-content`?`page-sidebar`:e}function am(){}function om(){We({message:`Restarting OpenCode…`,mode:`projects`,scopes:[`all`]}).catch(am)}export{Bi as a,Fi as c,ea as i,Pi as l,Ep as n,Li as o,Vl as r,Ii as s,Hp as t};
|