@openchamber/web 2.3.2 → 2.3.3
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/{AboutDialog-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
- package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
- package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
- package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
- package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
- package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
- package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
- package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
- package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
- package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
- package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
- package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
- package/dist/assets/PlanView-BxRCMuGe.js +5 -0
- package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
- package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
- package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
- package/dist/assets/SettingsView-CVpfbdob.js +30 -0
- package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
- package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
- package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
- package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
- package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
- package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
- package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
- package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
- package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
- package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
- package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
- package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
- package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
- package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
- package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
- package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
- package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
- package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
- package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
- package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
- package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
- package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
- package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
- package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
- package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
- package/dist/assets/katex-BZNCT55U.css +1 -0
- package/dist/assets/katex.min-EZjpSwGK.js +65 -0
- package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
- package/dist/assets/main-BUetg9hg.js +1048 -0
- package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
- package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
- package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
- package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
- package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
- package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
- package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
- package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
- package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
- package/dist/assets/pl-4LdEMgWI.js +20 -0
- package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
- package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
- package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
- package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
- package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
- package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
- package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
- package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
- package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
- package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
- package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
- package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
- package/dist/assets/tr-Bg0Qt-mG.js +11 -0
- package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
- package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
- package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
- package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
- package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
- package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
- package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
- package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
- package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
- package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +5 -5
- package/server/index.js +13 -1
- package/server/lib/agent-memory/actions.js +22 -9
- package/server/lib/agent-memory/actions.test.js +57 -0
- package/server/lib/agent-memory/runtime.js +8 -5
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
- package/server/lib/agent-tool/runtime.js +41 -7
- package/server/lib/agent-tool/runtime.test.js +11 -0
- package/server/lib/git/DOCUMENTATION.md +17 -5
- package/server/lib/git/lfs-discovery.js +7 -4
- package/server/lib/git/lfs-discovery.test.js +60 -0
- package/server/lib/git/network-operations.js +9 -3
- package/server/lib/git/network-operations.test.js +31 -2
- package/server/lib/git/service.js +72 -12
- package/server/lib/git/service.test.js +65 -0
- package/server/lib/github/DOCUMENTATION.md +1 -0
- package/server/lib/github/reference-search.js +49 -18
- package/server/lib/github/reference-search.test.js +28 -6
- package/server/lib/github/routes.js +87 -1
- package/server/lib/github/routes.mutations.test.js +38 -0
- package/server/lib/github/routes.test.js +1 -0
- package/server/lib/gitlab/DOCUMENTATION.md +4 -0
- package/server/lib/gitlab/client.js +23 -0
- package/server/lib/gitlab/client.test.js +28 -1
- package/server/lib/gitlab/mappers.js +9 -0
- package/server/lib/gitlab/resources.js +153 -4
- package/server/lib/gitlab/resources.test.js +107 -0
- package/server/lib/gitlab/routes.js +120 -1
- package/server/lib/gitlab/routes.test.js +59 -0
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +14 -2
- package/server/lib/markdown-image-grants/routes.test.js +23 -0
- package/server/lib/notifications/APNS.md +24 -23
- package/server/lib/notifications/DOCUMENTATION.md +2 -2
- package/server/lib/notifications/apns-runtime.js +8 -5
- package/server/lib/notifications/apns-runtime.test.js +26 -0
- package/server/lib/notifications/message.js +5 -3
- package/server/lib/notifications/message.test.js +9 -0
- package/server/lib/notifications/runtime.js +44 -9
- package/server/lib/notifications/trigger-runtime.test.js +84 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +18 -2
- package/server/lib/openchamber-control/project-knowledge.js +17 -3
- package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
- package/server/lib/openchamber-control/render-page.js +58 -0
- package/server/lib/openchamber-control/service.js +9 -0
- package/server/lib/openchamber-control/service.test.js +43 -0
- package/server/lib/openchamber-sessions/routes.js +1 -0
- package/server/lib/openchamber-sessions/worktree-move.js +26 -10
- package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -1
- package/server/lib/opencode/managed-config-file.js +3 -2
- package/server/lib/opencode/managed-config-file.test.js +20 -6
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/server/lib/opencode/settings-runtime.js +1 -0
- package/server/lib/project-context/DOCUMENTATION.md +25 -1
- package/server/lib/project-context/plan-progress.js +69 -0
- package/server/lib/project-context/plan-progress.test.js +58 -0
- package/server/lib/project-context/routes.http.test.js +22 -0
- package/server/lib/project-context/routes.js +20 -0
- package/server/lib/project-context/runtime.js +132 -18
- package/server/lib/project-context/runtime.test.js +58 -0
- package/server/lib/provider-read-cache/index.js +7 -1
- package/server/lib/provider-read-cache/index.test.js +12 -0
- package/server/lib/relay/DOCUMENTATION.md +17 -1
- package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
- package/server/lib/session-knowledge/runtime.js +29 -6
- package/server/lib/session-knowledge/runtime.test.js +26 -1
- package/server/lib/source-control/audit-storage.js +1 -0
- package/server/lib/source-control/mutation-storage.js +3 -0
- package/server/lib/spaces/DOCUMENTATION.md +14 -9
- package/server/lib/spaces/code-out.js +13 -4
- package/server/lib/spaces/code-out.test.js +5 -3
- package/server/lib/spaces/dispatcher.js +12 -5
- package/server/lib/spaces/dispatcher.test.js +19 -1
- package/server/lib/spaces/gatekeeper-channel.js +8 -7
- package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
- package/server/lib/spaces/gatekeeper-program.cjs +38 -3
- package/server/lib/spaces/gatekeeper-program.test.js +20 -0
- package/server/lib/spaces/hardening.js +14 -1
- package/server/lib/spaces/hardening.test.js +5 -0
- package/server/lib/spaces/host-providers.js +165 -0
- package/server/lib/spaces/host-providers.test.js +100 -0
- package/server/lib/spaces/host.js +16 -4
- package/server/lib/spaces/journey.js +87 -17
- package/server/lib/spaces/journey.test.js +90 -2
- package/server/lib/spaces/layout.js +15 -5
- package/server/lib/spaces/places/docker-live-support.js +2 -0
- package/server/lib/spaces/places/docker.test.js +2 -0
- package/server/lib/spaces/places/fake-docker.js +3 -0
- package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
- package/server/lib/spaces/routes.js +9 -0
- package/server/lib/spaces/routes.test.js +4 -2
- package/server/lib/spaces/space-opencode.js +31 -14
- package/server/lib/spaces/space-opencode.test.js +15 -2
- package/server/lib/spaces/space-records.js +8 -0
- package/server/lib/spaces/space-records.test.js +7 -3
- package/server/lib/spaces/websocket.test.js +13 -1
- package/server/lib/ui-auth/ui-auth.js +28 -3
- package/server/lib/ui-auth/ui-auth.test.js +31 -0
- package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
- package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
- package/dist/assets/SettingsView-BolP_tuu.js +0 -30
- package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
- package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
- package/dist/assets/katex-rNcbfUj4.css +0 -1
- package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
- package/dist/assets/main-CVHM3_8W.js +0 -1048
- package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
- package/dist/assets/pl-Bj-Hy0X5.js +0 -20
- package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
- package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
- package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
- package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
- package/dist/assets/tr-qMRMBQ8r.js +0 -11
- package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
- package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
- package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{R as c,j as s,f as $e,r as Be}from"./vendor-react-BUCujlKS.js";import{u as ze,B as q,I as J,cY as ks,aA as Fn,a9 as Dm,z as W,a8 as Rm,hf as Fm,ax as He,hg as Ct,a0 as Ld,av as $a,a3 as un,aB as ua,L as Me,bW as Om,cD as ur,cH as Lm,bO as Ut,bP as Pt,bJ as ot,bQ as At,bR as Tt,y as Ve,hh as hn,hi as Kd,hj as Km,bZ as ho,hk as Bl,gO as Ci,hl as zm,hm as ki,hn as On,n as Ts,t as Kt,q as zt,D as Bt,l as _t,E as Vt,o as ts,ho as ul,aO as ma,aP as Bn,gd as Ti,gf as Ei,aN as pa,aM as ga,gh as Mi,gi as Di,gT as An,gS as dn,bH as qt,hp as Gs,hq as ml,eY as Dt,$ as rt,hr as kt,bV as Mt,b_ as ws,bX as oa,hs as sn,ht as nn,hu as os,c2 as ps,hv as fs,hw as zd,hx as Um,hy as it,hz as Ud,hA as $m,hB as Bm,hC as Ii,hD as _m,hE as ns,co as Ln,hF as ys,hG as Os,hH as qa,hI as Ws,hJ as Ba,hK as $d,hL as pl,bY as gl,gU as ra,hM as _r,K as _n,hN as _l,hO as Vm,d2 as fl,hP as Vl,f0 as Dn,hQ as Lt,R as hl,hR as bl,hS as sa,hT as Bd,hU as fn,hV as Hm,C as Pi,x as xl,aF as Hl,bz as qm,aR as Wm,O as Gm,c4 as Jm,c5 as Qm,c6 as Ym,ci as Ja,eh as Ai,hW as Zm,hX as Xm,bL as ep,hY as tp,bN as an,hZ as Wt,h_ as Vr,h$ as sp,i0 as Cn,f2 as js,i1 as bo,i2 as np,i3 as _d,i4 as ap,gq as rs,i5 as xo,d4 as Vd,d3 as ip,go as op,gp as rp,i6 as lp,i7 as cp,gr as dp,i8 as up,i9 as mp,ia as ql,bK as Hd,ib as pp,ic as mr,id as Wl,ie as gp,ig as fp,ih as hp,ii as bp,ij as vo,ik as bs,f1 as hs,eD as zs,eE as vl,il as xp,im as qd,eU as vp,e_ as yp,fK as jp,io as pr,ip as Wd,iq as Gd,ir as Jd,is as kp,it as wp,iu as Sp,iv as Np,iw as Cp,ix as Ip,iy as Pp,iz as Ap,a$ as vs,iA as en,b0 as yl,iB as Hs,iC as Qd,cE as Da,iD as Tp,iE as Ep,iF as Mp,iG as Dp,iH as Wa,cx as Rp,iI as wi,iJ as Nn,iK as Yd,iL as Fp,iM as Op,iN as Lp,iO as Ls,iP as Is,iQ as Zn,iR as In,iS as Gl,iT as co,iU as Kp,a6 as zp,iV as Zd,iW as na,iX as Up,iY as $p,k as Xd,cl as Bp,au as _p,at as Vp,b5 as Hp,cI as qp,an as Wp,aq as Gp,aX as Jp,iZ as Qp,i_ as da,i$ as Yp,j0 as jl,j1 as Xn,g_ as Zp,j2 as Ra,j3 as Jl,j4 as Fa,ah as Rn,j5 as Xp,j6 as eg,j7 as tg,j8 as sg,j9 as gr,ja as Ql,jb as ng,jc as ag,jd as ig,je as og,jf as Yl,jg as rg,F as lg,aJ as Zl,bU as cg,jh as dg,ji as fr,T as eu,U as tu,V as ug,jj as mg,jk as Do,jl as pg,jm as gg,jn as fg,jo as hg,jp as bg,jq as kl,jr as Pn,ai as xg,ak as su,cp as vg,aQ as Qn,cq as yg}from"./useAppFontEffects-Cs6k0JKv.js";import{l as Rt,bf as wl,u as oe,m as cs,bw as Si,bx as Tn,by as nu,bz as jg,aH as yt,aE as xn,v as Ks,bA as kg,$ as Qt,aV as wg,ao as as,a$ as Qa,ay as hr,aB as Xl,az as ec,aI as ui,bo as Sg,bB as Ng,bl as Cg,aJ as ea,bC as Ig,bD as tc,aA as Pg,bE as Ag,bF as Tg,bg as sc,a_ as Ri,bG as Eg,bH as Mg,bI as au,bJ as es,bK as Dg,ag as Rg,ah as Fg,bL as Sl,aU as Og,a5 as iu,bM as ou,aZ as ru,bs as la,bN as lu,bO as Lg,bP as Kg,aG as Nl,bQ as zg,a1 as Ro,bR as nc,bS as Ug,b3 as $g,bq as yo,bT as ac,bU as Gi,aM as Bg,bV as _g,ap as ca,bW as Vg,bX as Oa,bY as ic,bZ as oc,b_ as rc,b$ as lc,c0 as Hg,c1 as qg,c2 as Wg,c3 as Gg,c4 as cc,bd as Jg,c5 as cu,c6 as Qg,c7 as Hr,c8 as Yg,c9 as Zg,ca as Xg,cb as ef,cc as du,cd as tf,ce as sf,cf as nf,cg as qr,aC as af}from"./katex.min-EZjpSwGK.js";import{u as Ms,c as uu}from"./vendor-zustand-BAGL70zf.js";import{a3 as of,aL as rf,aM as br,aN as lf,aO as cf,aP as df,aQ as Yt,aR as uf,aS as Fo,aT as Oo,aU as Lo,aV as Ga,aW as jo,aX as Wr,aY as tn,e as Js,c as Qs,d as Ys,aZ as ko,J as aa,a_ as mf,a$ as Cs,b0 as pf,b1 as mu,b2 as gf,b3 as pu,K as ff,b4 as hf,b5 as bf,b6 as xf,b7 as vf,b8 as uo,b9 as za,ba as Gr,f as yf,g as jf,bb as kf}from"./runtimeEndpointReset-6CNNzem4.js";import{o as ss,s as St,b as Fi,l as wf,a as Zs,r as En,u as Jr,n as wo,_ as Cl,c as Qr}from"./vendor-zod-CVhJ1Zpv.js";import{s as Sf,c as Nf}from"./vendor-yaml-CE-D_49-.js";import{c as dc,C as uc,P as Cf,p as If}from"./flexokiTheme-DKNCYSqL.js";import{s as Pf}from"./shikiHighlight-CweIj1cL.js";import{getResolvedShikiTheme as Af}from"./appThemeRegistry-xm_W0svA.js";import{E as mc}from"./vendor-codemirror-view-B66jUSmE.js";import{Q as gu}from"./vendor-qrcode-DTJ12-WC.js";import{toast as _a}from"./vendor-sonner-DFyL3AvE.js";import{s as Tf}from"./vendor-strip-json-comments-5dJlOkP1.js";import{h as Ef,P as Mf,e as Df,f as Rf,g as Ff}from"./vendor-base-ui-CXFyogip.js";import{_ as Of}from"./vendor-vite-runtime-DD1OZmLC.js";import{u as Lf}from"./useCallableModelProviders-BsGEzsl2.js";import{r as fu}from"./restartOpenCode-FYqjpaWc.js";const pc=()=>{const{t}=ze(),[e,a]=c.useState(null);c.useEffect(()=>{let o=!1;const i=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const l=await Rt("/api/system/info",{signal:i?.signal,headers:{Accept:"application/json"}});if(!l.ok)return;const u=await l.json().catch(()=>null);if(!u||o)return;const m=typeof u.port=="number"&&Number.isFinite(u.port)&&u.port>0?u.port:null,d=typeof u.tunnelUrl=="string"&&u.tunnelUrl.trim().length>0?u.tunnelUrl.trim():null;a({port:m,tunnelUrl:d})}catch{}})(),()=>{o=!0,i?.abort()}},[]);const n=[];return e?.port!==null&&e?.port!==void 0&&n.push({key:"application",label:t("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${e.port}/`}),e?.tunnelUrl&&n.push({key:"tunnel",label:t("settings.openchamber.about.field.tunnelUrl"),url:e.tunnelUrl}),n.length===0?null:s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(o=>s.jsxs(q,{type:"button",variant:"outline",size:"sm",title:o.label,className:"max-w-full gap-1.5 px-2.5",onClick:()=>{ks(o.url)},children:[s.jsx(J,{name:"external-link",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"max-w-64 truncate font-mono typography-micro",children:o.url})]},o.key))})},gc="https://github.com/openchamber/openchamber",Kf="https://discord.gg/ZYRSdnwwKA",fc="https://x.com/openchamber_dev",zf=800,Uf={info:null,checking:!1,available:!1,error:null};function $f(t){const e=$e.c(5),[a,n]=c.useState(Uf);let o;e[0]!==t?(o=async()=>{if(t){n(Bf);try{const l=await lf();n({info:l,checking:!1,available:l.available,error:null})}catch(l){const u=l;n({info:null,checking:!1,available:!1,error:u instanceof Error?u.message:String(u)})}}},e[0]=t,e[1]=o):o=e[1];const i=o;let r;return e[2]!==i||e[3]!==a?(r={...a,check:i},e[2]=i,e[3]=a,e[4]=r):r=e[4],r}function Bf(t){return{...t,checking:!0,error:null}}function _f(t){const e=$e.c(11),[a,n]=c.useState(null);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={kind:"idle"},e[0]=o):o=e[0];const[i,r]=c.useState(o);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=async()=>{try{const b=await cf();return n(b),b}catch{return null}},e[1]=l):l=e[1];const u=l;let m,d;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{u()},d=[u],e[2]=m,e[3]=d):(m=e[2],d=e[3]),c.useEffect(m,d);let f;e[4]!==t?(f=async()=>{r({kind:"upgrading"});try{const b=await df(t);r({kind:"installed",version:b})}catch(b){const k=b;r({kind:"failed",error:k instanceof Error?k.message:t})}},e[4]=t,e[5]=f):f=e[5];const g=f;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=async b=>{await b().catch(Vf);const k=await u();k?.currentVersion&&r(v=>v.kind!=="installed"||v.version&&v.version.replace(/^v/,"")!==k.currentVersion?v:{kind:"idle"})},e[6]=p):p=e[6];const h=p;let w;return e[7]!==i||e[8]!==a||e[9]!==g?(w={status:a,phase:i,refresh:u,upgrade:g,reloadAfterUpgrade:h},e[7]=i,e[8]=a,e[9]=g,e[10]=w):w=e[10],w}function Vf(){}function Hf(t){const[e,a]=c.useState(null);return c.useEffect(()=>{if(!t)return;let n=!1;return Of(async()=>{const{App:o}=await import("./vendor-capacitor-app-BrDJj9I_.js");return{App:o}},__vite__mapDeps([0,1,2])).then(({App:o})=>o.getInfo()).then(o=>{n||a(o.version.trim()||null)}).catch(()=>{}),()=>{n=!0}},[t]),e}const hu=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=ze(),[a,n]=c.useState(t),[o,i]=c.useState(!1),[r,l]=c.useState(null),u=of(Ms(Q=>({info:Q.info,checking:Q.checking,available:Q.available,error:Q.error,downloading:Q.downloading,downloaded:Q.downloaded,installing:Q.installing,progress:Q.progress,runtimeType:Q.runtimeType,checkForUpdates:Q.checkForUpdates,downloadUpdate:Q.downloadUpdate,restartToUpdate:Q.restartToUpdate}))),{isMobile:m}=Fn(),d=c.useMemo(()=>wl(),[]),f=rf(),g=$f(d||f),p=f?g:null,h=g.check;c.useEffect(()=>{f&&h()},[f,h]);const[w,b]=c.useState(!1),[k,v]=c.useState(null);c.useEffect(()=>{if(!f)return;let Q=!1;return Dm().then(le=>{Q||v(le)}),()=>{Q=!0}},[f]);const S=Hf(d),y=d?{info:g.info,checking:g.checking,available:g.available,error:g.error,checkForUpdates:g.check,runtimeType:"web"}:{info:u.info,checking:u.checking,available:u.available,error:u.error,checkForUpdates:u.checkForUpdates,runtimeType:u.runtimeType},N=r||y.info?.currentVersion||"unknown",x=k||u.info?.currentVersion||"unknown",I=r||p?.info?.currentVersion||"unknown",j=_f(e("opencodeUpdate.toast.failed.description")),D=j.status?.currentVersion??null,C=j.phase.kind==="installed"?null:j.status?.availableVersion??null,[P,A]=c.useState(!1),R=Q=>{const le=Q?.version||"";return Q?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:le}):e("settings.openchamber.about.actions.updateServerToVersion",{version:le})},K=(()=>{const Q=y.info?.version||"";return d?R(y.info):f?e("settings.openchamber.about.actions.updateAppToVersion",{version:Q}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:Q})})(),F=Q=>!!Q?.installBlocked,T=y.available&&F(y.info),O=!!(p?.available&&F(p.info)),E=()=>{y.checkForUpdates(),p&&p.check(),j.refresh()},B=async Q=>{(await $a(Q)).ok&&(A(!0),setTimeout(()=>A(!1),2e3))},_=()=>{j.reloadAfterUpgrade(async()=>{await Ld({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})})},H=Q=>{if(Q?.installBlocked==="desktop-host")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:Q.version||""})});if(Q?.installBlocked==="manual-install")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.manualInstallUpdate",{version:Q.version||""})});const le=Q?.updateCommand||"openchamber update";return s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.serviceManagerUpdate",{version:Q?.version||""})}),s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-elevated/50 p-1 ps-3",children:[s.jsx("code",{className:"flex-1 overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground",children:le}),s.jsx(q,{type:"button",variant:"ghost",size:"icon",onClick:()=>{B(le)},"aria-label":e(P?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(J,{name:P?"check":"clipboard",className:"size-4"})})]})]})},ne=T?H(y.info):null,z=!p?.available||p.checking?null:O?H(p.info):s.jsxs(q,{type:"button",size:"sm",variant:"outline",onClick:()=>b(!0),children:[s.jsx(J,{name:"download",className:"size-4"}),R(p.info)]}),$=p?s.jsx(br,{open:w,onOpenChange:b,info:p.info,downloading:!1,downloaded:!1,progress:null,error:p.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,V=(()=>{const{phase:Q}=j;if(Q.kind==="installed")return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:Q.version?e("settings.openchamber.about.openCode.installedVersion",{version:Q.version}):e("settings.openchamber.about.openCode.installed")}),s.jsx(q,{type:"button",size:"sm",variant:"outline",onClick:_,children:e("opencodeUpdate.toast.actions.reload")})]});if(!C)return null;if(!j.status?.supported)return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:C})});const le=Q.kind==="upgrading";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs(q,{type:"button",size:"sm",variant:"outline",onClick:()=>{j.upgrade()},disabled:le,children:[s.jsx(J,{name:le?"loader":"download",className:le?"size-4 animate-spin":"size-4"}),le?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:C})]}),Q.kind==="failed"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Q.error})]})})();c.useEffect(()=>{let Q=!1;return(async()=>{try{const Z=await Rt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!Z.ok)return;const fe=await Z.json().catch(()=>null),Y=typeof fe?.openchamberVersion=="string"&&fe.openchamberVersion.trim().length>0?fe.openchamberVersion.trim():null;Q||l(Y)}catch{Q||l(null)}})(),()=>{Q=!0}},[]);const G=p?.checking??!1,ee=p?.available??!1,ae=c.useRef(!1);c.useEffect(()=>{if(y.checking)i(!0),ae.current=!0;else if(o){const Q=setTimeout(()=>{i(!1);const le=G||ee;ae.current&&!y.available&&!y.error&&!le&&(W.success(e(d?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),ae.current=!1)},zf);return()=>clearTimeout(Q)}},[e,d,y.checking,o,y.available,y.error,G,ee]);const X=y.checking||o;return m?s.jsxs("div",{className:"w-full space-y-6 pb-2",children:[s.jsxs("div",{className:"flex flex-col items-center text-center",children:[s.jsx(Rm,{width:72,height:72}),s.jsx("h2",{className:`mt-4 ${Fm}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:d?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:N})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:D||e("settings.openchamber.about.state.unknown")})}),S&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:S})})]}):f?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.appVersionLabel",{version:x})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:I})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:D||e("settings.openchamber.about.state.unknown")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:N})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:D||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(pc,{})]}),s.jsxs("div",{className:"flex justify-center",children:[!y.available&&!y.error&&s.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:E,disabled:X,className:"w-auto justify-center gap-2",children:[X?s.jsx(J,{name:"loader",className:"size-4 animate-spin"}):s.jsx(J,{name:"refresh",className:"size-4"}),e(X?"settings.openchamber.about.state.checking":d?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!X&&y.available&&!T&&s.jsxs(q,{type:"button",variant:"default",size:"sm",onClick:()=>n(!0),className:"w-auto justify-center gap-2",children:[s.jsx(J,{name:"download",className:"size-4"}),K]})]}),ne,z&&s.jsx("div",{className:"flex justify-center text-center",children:z}),V&&s.jsx("div",{className:"flex justify-center text-center",children:V}),[y.error,p?.error].filter(Boolean).map(Q=>s.jsx("p",{className:"rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:Q},Q)),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:gc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(J,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Kf,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(J,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:fc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(J,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),s.jsx(br,{open:a,onOpenChange:n,info:y.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:y.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:y.runtimeType}),$]}):s.jsxs(He,{divider:!1,children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center justify-between gap-4 px-4 py-3 border-b border-border/40",children:[f?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Ct,children:e("settings.openchamber.about.field.appVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:x})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Ct,children:e("settings.openchamber.about.field.serverVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:I})]})]}):s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Ct,children:e("settings.openchamber.about.field.version")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:N})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Ct,children:e("settings.openchamber.about.field.openCodeVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:D||e("settings.openchamber.about.state.unknown")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[y.checking&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(J,{name:"loader",className:"h-4 w-4 animate-spin"}),s.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!y.checking&&y.available&&!T&&s.jsxs(q,{size:"sm",variant:"default",onClick:()=>n(!0),children:[s.jsx(J,{name:"download",className:"h-4 w-4 me-1"}),K]}),!y.checking&&!y.available&&!y.error&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),s.jsx(q,{size:"sm",variant:"outline",onClick:E,disabled:y.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),ne&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:ne}),z&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:z}),V&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:V}),[y.error,p?.error].filter(Boolean).map(Q=>s.jsx("div",{className:"px-3 py-2 border-b border-border/40",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Q})},Q)),s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-4 py-3 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsx("span",{className:Ct,children:e("settings.openchamber.about.field.instanceUrls")}),s.jsx(pc,{})]}),s.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[s.jsxs("a",{href:gc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(J,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:fc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(J,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]})]}),s.jsx(br,{open:a,onOpenChange:n,info:y.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:y.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:y.runtimeType}),$]})},qf=(t,e,a)=>t&&e.some(o=>o.path===t)?t:(e.find(o=>o.id===a)??e[0])?.path??null,Us=()=>{const t=$e.c(4),e=oe(Wf),a=un(Gf),n=un(Jf);let o;return t[0]!==n||t[1]!==a||t[2]!==e?(o=qf(e,a,n),t[0]=n,t[1]=a,t[2]=e,t[3]=o):o=t[3],o};function Wf(t){return t.settingsProjectPath}function Gf(t){return t.projects}function Jf(t){return t.activeProjectId}const Yr=uu(t=>({tab:"general",setTab:e=>t({tab:e})})),Qf=new Map([["projects.default-agent","general"],["projects.default-model","general"],["projects.default-thinking","general"],["projects.shared","general"],["projects.shared.plansDir","general"],["projects.actions","actions"],["projects.worktree","worktrees"],["projects.worktree.setup.wait","worktrees"],["projects.worktree.setup.replace","worktrees"],["projects.environment","environment"]]),Yf=t=>Qf.get(t)??null,Zf=t=>[...t].sort((e,a)=>(e.label||e.path).localeCompare(a.label||a.path)),Oi=t=>{const e=$e.c(75),{className:a}=t,{t:n}=ze(),{currentTheme:o}=ua(),i=oe(Xf),[r,l]=c.useState(!1),u=un(eh),m=Us(),d=oe(th),f=cs();let g;e[0]!==u?(g=Zf(u),e[0]=u,e[1]=g):g=e[1];const p=g;let h;e[2]!==m||e[3]!==p?(h=p.find(R=>R.path===m)??p[0]??null,e[2]=m,e[3]=p,e[4]=h):h=e[4];const w=h;if(f||!w)return null;let b;e[5]!==d||e[6]!==p?(b=R=>{const K=p.find(F=>F.id===R);K&&d(K.path)},e[5]=d,e[6]=p,e[7]=b):b=e[7];const k=b;if(i){let R;e[8]!==a?(R=Me(a),e[8]=a,e[9]=R):R=e[9];let K;e[10]!==n?(K=n("settings.shared.projectSelector.switchProjectAria"),e[10]=n,e[11]=K):K=e[11];let F;e[12]!==n?(F=n("settings.shared.projectSelector.switchProjectTitle"),e[12]=n,e[13]=F):F=e[13];let T,O;e[14]===Symbol.for("react.memo_cache_sentinel")?(T=()=>l(!0),O=Me(Om({size:"touch"}),"w-full min-w-0"),e[14]=T,e[15]=O):(T=e[14],O=e[15]);let E;e[16]!==w||e[17]!==o?(E=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(ur,{project:w,theme:o})}),e[16]=w,e[17]=o,e[18]=E):E=e[18];let B;e[19]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(J,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[19]=B):B=e[19];let _;e[20]!==r||e[21]!==K||e[22]!==F||e[23]!==O||e[24]!==E?(_=s.jsxs("button",{type:"button","aria-label":K,title:F,"aria-haspopup":"dialog","aria-expanded":r,onClick:T,className:O,children:[E,B]}),e[20]=r,e[21]=K,e[22]=F,e[23]=O,e[24]=E,e[25]=_):_=e[25];let H;e[26]!==_||e[27]!==R?(H=s.jsx("div",{className:R,children:_}),e[26]=_,e[27]=R,e[28]=H):H=e[28];let ne;e[29]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>l(!1),e[29]=ne):ne=e[29];const z=w.id;let $;e[30]!==n?($=n("settings.shared.projectSelector.sheetTitle"),e[30]=n,e[31]=$):$=e[31];let V;e[32]!==n?(V=n("settings.shared.projectSelector.searchPlaceholder"),e[32]=n,e[33]=V):V=e[33];let G;e[34]!==w.id||e[35]!==o||e[36]!==k||e[37]!==r||e[38]!==p||e[39]!==$||e[40]!==V?(G=s.jsx(Lm,{open:r,onClose:ne,projects:p,selectedProjectId:z,onSelectProject:k,theme:o,title:$,searchPlaceholder:V}),e[34]=w.id,e[35]=o,e[36]=k,e[37]=r,e[38]=p,e[39]=$,e[40]=V,e[41]=G):G=e[41];let ee;return e[42]!==H||e[43]!==G?(ee=s.jsxs(s.Fragment,{children:[H,G]}),e[42]=H,e[43]=G,e[44]=ee):ee=e[44],ee}let v;e[45]!==a?(v=Me(a),e[45]=a,e[46]=v):v=e[46];const S=w.id;let y;e[47]!==k?(y=R=>{R&&k(R)},e[47]=k,e[48]=y):y=e[48];let N;e[49]!==n?(N=n("settings.shared.projectSelector.switchProjectAria"),e[49]=n,e[50]=N):N=e[50];let x;e[51]!==n?(x=n("settings.shared.projectSelector.switchProjectTitle"),e[51]=n,e[52]=x):x=e[52];let I;e[53]!==w||e[54]!==o?(I=s.jsx(Ut,{children:s.jsx(ur,{project:w,theme:o})}),e[53]=w,e[54]=o,e[55]=I):I=e[55];let j;e[56]!==N||e[57]!==x||e[58]!==I?(j=s.jsx(Pt,{className:"w-full","aria-label":N,title:x,children:I}),e[56]=N,e[57]=x,e[58]=I,e[59]=j):j=e[59];let D;if(e[60]!==o||e[61]!==p){let R;e[63]!==o?(R=K=>s.jsx(ot,{value:K.id,className:"max-w-[24rem] truncate",children:s.jsx(ur,{project:K,theme:o})},K.id),e[63]=o,e[64]=R):R=e[64],D=p.map(R),e[60]=o,e[61]=p,e[62]=D}else D=e[62];let C;e[65]!==D?(C=s.jsx(At,{fitContent:!0,children:D}),e[65]=D,e[66]=C):C=e[66];let P;e[67]!==w.id||e[68]!==j||e[69]!==C||e[70]!==y?(P=s.jsxs(Tt,{value:S,onValueChange:y,children:[j,C]}),e[67]=w.id,e[68]=j,e[69]=C,e[70]=y,e[71]=P):P=e[71];let A;return e[72]!==P||e[73]!==v?(A=s.jsx("div",{className:v,children:P}),e[72]=P,e[73]=v,e[74]=A):A=e[74],A};function Xf(t){return t.isMobile}function eh(t){return t.projects}function th(t){return t.setSettingsProjectPath}const Il=t=>{const e=$e.c(16),{value:a,onChange:n}=t,{t:o}=ze();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(J,{name:"search",className:"pointer-events-none absolute inset-s-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),e[0]=i):i=e[0];let r;e[1]!==n?(r=f=>n(f.target.value),e[1]=n,e[2]=r):r=e[2];let l;e[3]!==n||e[4]!==a?(l=f=>{f.key==="Escape"&&a&&(f.preventDefault(),f.stopPropagation(),n(""))},e[3]=n,e[4]=a,e[5]=l):l=e[5];let u;e[6]!==o?(u=o("settings.common.sidebar.searchPlaceholder"),e[6]=o,e[7]=u):u=e[7];let m;e[8]!==o?(m=o("settings.common.sidebar.searchPlaceholder"),e[8]=o,e[9]=m):m=e[9];let d;return e[10]!==r||e[11]!==l||e[12]!==u||e[13]!==m||e[14]!==a?(d=s.jsxs("div",{className:"relative mt-3",children:[i,s.jsx(Ve,{value:a,onChange:r,onKeyDown:l,placeholder:u,"aria-label":m,className:"h-8 ps-7 typography-meta"})]}),e[10]=r,e[11]=l,e[12]=u,e[13]=m,e[14]=a,e[15]=d):d=e[15],d},Pl=t=>{const e=$e.c(5),{query:a}=t,{t:n}=ze();let o;e[0]!==a||e[1]!==n?(o=n("settings.common.sidebar.noMatches",{query:a.trim()}),e[0]=a,e[1]=n,e[2]=o):o=e[2];let i;return e[3]!==o?(i=s.jsx("p",{className:"px-2 py-6 text-center typography-meta text-muted-foreground",children:o}),e[3]=o,e[4]=i):i=e[4],i};function sh(t,e){return`opencode:sidebar-group:${t}:${e}`}const Zr=t=>{const e=$e.c(33),{label:a,count:n,storageKey:o,defaultExpanded:i,children:r}=t,l=i===void 0?!0:i;let u;e[0]!==a||e[1]!==o?(u=sh(o,a),e[0]=a,e[1]=o,e[2]=u):u=e[2];const m=u,d=c.useId();let f;e[3]!==l||e[4]!==m?(f=()=>{try{const P=localStorage.getItem(m);if(P!==null)return P==="true"}catch{}return l},e[3]=l,e[4]=m,e[5]=f):f=e[5];const[g,p]=Be.useState(f);let h,w;e[6]!==g||e[7]!==m?(h=()=>{try{localStorage.setItem(m,String(g))}catch{}},w=[m,g],e[6]=g,e[7]=m,e[8]=h,e[9]=w):(h=e[8],w=e[9]),Be.useEffect(h,w);let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=()=>p(nh),e[10]=b):b=e[10];let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=Me("flex w-full items-center gap-1 rounded-md px-2 py-1 text-start","text-xs font-semibold uppercase tracking-wide text-muted-foreground","hover:bg-[var(--interactive-hover)] transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),e[11]=k):k=e[11];const v=!g&&"-rotate-90 rtl:rotate-90";let S;e[12]!==v?(S=Me("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",v),e[12]=v,e[13]=S):S=e[13];let y;e[14]!==S?(y=s.jsx(J,{name:"arrow-down-s",className:S}),e[14]=S,e[15]=y):y=e[15];let N;e[16]!==a?(N=s.jsx("span",{className:"flex-1 truncate",children:a}),e[16]=a,e[17]=N):N=e[17];let x;e[18]!==n?(x=s.jsx("span",{className:"ms-1 tabular-nums opacity-60",children:n}),e[18]=n,e[19]=x):x=e[19];let I;e[20]!==d||e[21]!==g||e[22]!==y||e[23]!==N||e[24]!==x?(I=s.jsxs("button",{type:"button",onClick:b,"aria-expanded":g,"aria-controls":d,className:k,children:[y,N,x]}),e[20]=d,e[21]=g,e[22]=y,e[23]=N,e[24]=x,e[25]=I):I=e[25];const j=!g;let D;e[26]!==r||e[27]!==d||e[28]!==j?(D=s.jsx("div",{id:d,hidden:j,className:"mt-0.5 space-y-0.5 ms-2 ps-3 border-s-2 border-[var(--interactive-border)]",children:r}),e[26]=r,e[27]=d,e[28]=j,e[29]=D):D=e[29];let C;return e[30]!==I||e[31]!==D?(C=s.jsxs("div",{children:[I,D]}),e[30]=I,e[31]=D,e[32]=C):C=e[32],C};function nh(t){return!t}const ah=({onItemSelect:t})=>{const{t:e}=ze(),[a,n]=c.useState(""),[o,i]=c.useState(null),[r,l]=c.useState(""),[u,m]=c.useState(null),[d,f]=c.useState(!1),[g,p]=c.useState(null),{selectedAgentName:h,setSelectedAgent:w,setAgentDraft:b,createAgent:k,deleteAgent:v,loadAgents:S,loadDisabledAgents:y,updateAgent:N,fetchAgentEntity:x}=hn(Ms(Z=>({selectedAgentName:Z.selectedAgentName,setSelectedAgent:Z.setSelectedAgent,setAgentDraft:Z.setAgentDraft,createAgent:Z.createAgent,deleteAgent:Z.deleteAgent,loadAgents:Z.loadAgents,loadDisabledAgents:Z.loadDisabledAgents,updateAgent:Z.updateAgent,fetchAgentEntity:Z.fetchAgentEntity}))),I=Us(),j=hn(Z=>Kd(Z,I)),D=hn(Z=>Km(Z,I)),[C,P]=c.useState(null);c.useEffect(()=>{S(I),y(I)},[S,y,I]);const A=j.filter(Z=>ho(Z.mode)&&!Bl(Z)).length,R=Z=>!(ho(Z.mode)&&!Bl(Z)&&A<=1),K=async(Z,fe)=>{P(Z);try{await N(Z,{disabled:fe},I),fe&&h===Z&&w(null),W.success(fe?e("settings.agents.sidebar.toast.agentDisabled",{name:Z}):e("settings.agents.sidebar.toast.agentEnabled",{name:Z}))}catch{W.error(e(fe?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{P(null)}},F=D.filter(Z=>Ci([Z.name,Z.description],a)),T="bg-background",O=()=>{const Z="new-agent";let fe=Z,Y=1;for(;j.some(be=>be.name===fe);)fe=`${Z}-${Y}`,Y++;b({name:fe,scope:"user"}),w(fe),t?.()},E=async Z=>{if(ki(Z)){W.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}m(Z)},B=()=>{m(null)},_=async()=>{if(u){f(!0);try{(await v(u.name,u.scope,I)).ok?(W.success(e("settings.agents.sidebar.toast.agentDeleted",{name:u.name})),B()):W.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(Z){const fe=Z instanceof Error?Z.message:"",Y=/built-in|not deletable|not found/i.test(fe);W.error(e(Y?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}f(!1)}},H=async Z=>{const fe=Z.name;let Y=1,be=`${fe}-copy`;for(;j.some(je=>je.name===be);)Y++,be=`${fe}-copy-${Y}`;const Ee=Z,se=await x(Z.name,I);if(!se){W.error(e("settings.agents.sidebar.toast.renameFailed"));return}const re=se.config.request?.body;b({name:be,scope:se.scope??Ee.scope??"user",description:se.config.description??void 0,model:se.config.model??null,system:se.config.system??void 0,steps:se.config.steps??void 0,temperature:re?.temperature,top_p:re?.top_p,mode:se.config.mode??Ee.mode,permissions:se.config.permissions??void 0,hidden:se.config.hidden}),w(be),t?.()},ne=Z=>{l(Z.name),i(Z)},z=async()=>{if(!o)return;const Z=r.trim().replace(/\s+/g,"-");if(!Z){W.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(Z===o.name){i(null);return}if(j.some(Ee=>Ee.name===Z)){W.error(e("settings.agents.sidebar.toast.agentExists"));return}const fe=o,Y=await x(o.name,I);if(!Y){W.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await k({...Y.config,name:Z,scope:Y.scope??fe.scope},I)).ok?(await v(o.name,fe.scope,I)).ok?(W.success(e("settings.agents.sidebar.toast.agentRenamed",{name:Z})),w(Z)):W.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):W.error(e("settings.agents.sidebar.toast.renameFailed")),i(null)},$=Z=>{switch(Z){case"primary":return s.jsx(J,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(J,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(J,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},V=new Set(D.map(Z=>Z.name)),G=j.filter(Z=>zm(Z)&&!V.has(Z.name)),ee=G.filter(Z=>Ci([Z.name,Z.description],a)),ae=ee.filter(ki),X=ee.filter(Z=>!ki(Z)),{groupedCustomAgents:Q,ungroupedCustomAgents:le}=Be.useMemo(()=>{const Z={},fe=[];for(const be of X){const Ee=be;Ee.group?(Z[Ee.group]||(Z[Ee.group]=[]),Z[Ee.group].push(be)):fe.push(be)}return{groupedCustomAgents:Object.keys(Z).sort((be,Ee)=>be.localeCompare(Ee)).map(be=>({name:be,agents:Z[be]})),ungroupedCustomAgents:fe}},[X]);return s.jsxs("div",{className:Me("flex h-full flex-col",T),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${On} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(Oi,{className:"mb-3"}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:G.length})}),s.jsx(q,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:O,children:s.jsx(J,{name:"add",className:"h-3.5 w-3.5"})})]}),G.length>0?s.jsx(Il,{value:a,onChange:n}):null]}),s.jsxs(Ts,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[G.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(J,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):ee.length===0?s.jsx(Pl,{query:a}):s.jsxs(s.Fragment,{children:[ae.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),ae.map(Z=>s.jsx(xr,{agent:Z,isSelected:h===Z.name,onSelect:()=>{w(Z.name),t?.()},onDuplicate:()=>{H(Z)},onDisable:R(Z)?()=>{K(Z.name,!0)}:void 0,getAgentModeIcon:$,isMenuOpen:g===Z.name,onMenuOpenChange:fe=>p(fe?Z.name:null)},Z.name))]}),X.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),Q.map(({name:Z,agents:fe})=>s.jsx(Zr,{label:Z,count:fe.length,storageKey:"agents",children:fe.map(Y=>s.jsx(xr,{agent:Y,isSelected:h===Y.name,onSelect:()=>{w(Y.name),t?.()},onRename:()=>ne(Y),onDelete:()=>E(Y),onDuplicate:()=>{H(Y)},onDisable:R(Y)?()=>{K(Y.name,!0)}:void 0,getAgentModeIcon:$,isMenuOpen:g===Y.name,onMenuOpenChange:be=>p(be?Y.name:null)},Y.name))},Z)),le.map(Z=>s.jsx(xr,{agent:Z,isSelected:h===Z.name,onSelect:()=>{w(Z.name),t?.()},onRename:()=>ne(Z),onDelete:()=>E(Z),onDuplicate:()=>{H(Z)},onDisable:R(Z)?()=>{K(Z.name,!0)}:void 0,getAgentModeIcon:$,isMenuOpen:g===Z.name,onMenuOpenChange:fe=>p(fe?Z.name:null)},Z.name))]})]}),F.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.disabled")}),F.map(Z=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-1.5 py-1",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"typography-ui-label truncate text-muted-foreground",children:Z.name}),Z.description?s.jsx("div",{className:"typography-micro truncate leading-tight text-muted-foreground/60",children:Z.description}):null]}),s.jsx(q,{size:"xs",variant:"outline",disabled:C===Z.name,onClick:()=>{K(Z.name,!1)},"aria-label":e("settings.agents.sidebar.actions.enableAria",{name:Z.name}),children:e("settings.agents.sidebar.actions.enable")})]},Z.name))]})]}),s.jsx(Kt,{open:u!==null,onOpenChange:Z=>{!Z&&!d&&B()},children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Vt,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:u?.name??""})})]}),s.jsxs(ts,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:B,disabled:d,children:e("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",onClick:_,disabled:d,children:e("settings.common.actions.delete")})]})]})}),s.jsx(Kt,{open:o!==null,onOpenChange:Z=>!Z&&i(null),children:s.jsxs(zt,{children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(Vt,{children:e("settings.agents.sidebar.renameDialog.description",{name:o?.name??""})})]}),s.jsx(Ve,{value:r,onChange:Z=>l(Z.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:Z=>{Z.key==="Enter"&&z()}}),s.jsxs(ts,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>i(null),children:e("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",onClick:z,children:e("settings.common.actions.rename")})]})]})})]})},xr=t=>{const e=$e.c(52),{agent:a,isSelected:n,onSelect:o,onDelete:i,onRename:r,onDuplicate:l,onDisable:u,getAgentModeIcon:m,isMenuOpen:d,onMenuOpenChange:f}=t,{t:g}=ze(),p=a;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=ul(),e[0]=h):h=e[0];const w=h,[b,k]=c.useState(!1);let v;e[1]!==i||e[2]!==u||e[3]!==l||e[4]!==r||e[5]!==g?(v=ne=>s.jsxs(s.Fragment,{children:[r&&s.jsxs(ne,{onClick:z=>{z.stopPropagation(),r()},children:[s.jsx(J,{name:"edit",className:"h-4 w-4 me-px"}),g("settings.common.actions.rename")]}),s.jsxs(ne,{onClick:z=>{z.stopPropagation(),l()},children:[s.jsx(J,{name:"file-copy",className:"h-4 w-4 me-px"}),g("settings.common.actions.duplicate")]}),u&&s.jsxs(ne,{onClick:z=>{z.stopPropagation(),u()},children:[s.jsx(J,{name:"eye-off",className:"h-4 w-4 me-px"}),g("settings.agents.sidebar.actions.disable")]}),i&&s.jsxs(ne,{onClick:z=>{z.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[s.jsx(J,{name:"delete-bin",className:"h-4 w-4 me-px"}),g("settings.common.actions.delete")]})]}),e[1]=i,e[2]=u,e[3]=l,e[4]=r,e[5]=g,e[6]=v):v=e[6];const S=v,y=n?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==y?(N=Me("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",y),e[7]=y,e[8]=N):N=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=w?void 0:ne=>{ne.preventDefault(),k(!0)},e[9]=x):x=e[9];let I;e[10]!==N?(I=s.jsx("div",{className:N,onContextMenu:x}),e[10]=N,e[11]=I):I=e[11];let j;e[12]!==a.name?(j=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name}),e[12]=a.name,e[13]=j):j=e[13];let D;e[14]!==a.mode||e[15]!==m?(D=m(a.mode),e[14]=a.mode,e[15]=m,e[16]=D):D=e[16];let C;e[17]!==a||e[18]!==p.scope||e[19]!==g?(C=(p.scope||ki(a))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:ki(a)?g("settings.agents.sidebar.badge.system"):p.scope}),e[17]=a,e[18]=p.scope,e[19]=g,e[20]=C):C=e[20];let P;e[21]!==j||e[22]!==D||e[23]!==C?(P=s.jsxs("div",{className:"flex items-center gap-1.5",children:[j,D,C]}),e[21]=j,e[22]=D,e[23]=C,e[24]=P):P=e[24];let A;e[25]!==a.description?(A=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[25]=a.description,e[26]=A):A=e[26];let R;e[27]!==o||e[28]!==P||e[29]!==A?(R=s.jsxs("button",{onClick:o,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:[P,A]}),e[27]=o,e[28]=P,e[29]=A,e[30]=R):R=e[30];let K;e[31]!==f?(K=ne=>{ne&&k(!1),f(ne)},e[31]=f,e[32]=K):K=e[32];let F;e[33]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(pa,{asChild:!0,children:s.jsx(q,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(J,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=F):F=e[33];let T;e[34]!==S?(T=s.jsx(ma,{align:"end",className:"w-fit min-w-20",children:S(Bn)}),e[34]=S,e[35]=T):T=e[35];let O;e[36]!==d||e[37]!==K||e[38]!==T?(O=s.jsxs(ga,{open:d,onOpenChange:K,children:[F,T]}),e[36]=d,e[37]=K,e[38]=T,e[39]=O):O=e[39];let E;e[40]!==R||e[41]!==O?(E=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[R,O]}),e[40]=R,e[41]=O,e[42]=E):E=e[42];let B;e[43]!==E||e[44]!==I?(B=s.jsx(Mi,{render:I,children:E}),e[43]=E,e[44]=I,e[45]=B):B=e[45];let _;e[46]!==S?(_=s.jsx(Ti,{className:"w-fit min-w-20",children:S(Ei)}),e[46]=S,e[47]=_):_=e[47];let H;return e[48]!==b||e[49]!==B||e[50]!==_?(H=s.jsxs(Di,{open:b,onOpenChange:k,children:[B,_]}),e[48]=b,e[49]=B,e[50]=_,e[51]=H):H=e[51],H},Es={ok:!0,changed:!1},bn={ok:!0,changed:!0},gs=t=>({ok:!1,reason:t}),ih=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,Ya=t=>{const{t:e}=ze(),[a,n]=c.useState(0),o=c.useRef(t);o.current=t;const i=c.useRef(e);i.current=e;const r=c.useRef(!1),l=c.useRef(!1),u=c.useRef(!1),m=c.useCallback(()=>{n(g=>g+1)},[]),d=c.useCallback(g=>{ih(g.target)&&m()},[m]),f=c.useCallback(async()=>{r.current=!0;try{for(;;){l.current=!1;let g;try{g=await o.current()}catch(p){g={ok:!1,reason:p instanceof Error?p.message:String(p)}}if(!u.current)return;if(!l.current){g.ok||W.error(i.current("settings.common.status.saveFailedReason",{reason:g.reason}));return}}}finally{r.current=!1}},[]);return c.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]),c.useEffect(()=>{if(a!==0){if(r.current){l.current=!0;return}f()}},[a,f]),{requestSave:m,onBlurCapture:d}},oh=["allow","ask","deny"],rh=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],lh=["openchamber","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_render"],ch=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),bu=t=>ch.has(t),dh=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],hc=()=>({global:null,keys:{},source:[]}),Yn=t=>({global:t.global,source:t.source,keys:Object.fromEntries(Object.entries(t.keys).map(([e,a])=>[e,{effect:a.effect,patterns:a.patterns.map(n=>({...n}))}]))}),uh=t=>{const e={global:null,keys:{},source:t.map(a=>({...a}))};for(const a of t){if(bu(a.action))continue;if(a.action==="*"){a.resource==="*"&&(e.global=a.effect);continue}const n=e.keys[a.action]??{effect:null,patterns:[]};if(a.resource==="*")n.effect=a.effect;else{const o=n.patterns.findIndex(i=>i.pattern===a.resource);o>=0?n.patterns[o]={pattern:a.resource,effect:a.effect}:n.patterns.push({pattern:a.resource,effect:a.effect})}e.keys[a.action]=n}return e},mh=t=>t.action!=="*"||t.resource==="*",ia=(t,e)=>`${t}\0${e}`,ph=t=>{const e=new Map;t.global!==null&&e.set(ia("*","*"),t.global);for(const[a,n]of Object.entries(t.keys)){n.effect!==null&&e.set(ia(a,"*"),n.effect);for(const o of n.patterns){const i=o.pattern.trim();i.length!==0&&e.set(ia(a,i),o.effect)}}return e},Xr=t=>{const e=ph(t),a=new Set,n=[];for(const i of t.source){if(bu(i.action))continue;if(!mh(i)){n.push({...i});continue}const r=ia(i.action,i.resource),l=e.get(r);l!==void 0&&(n.push({action:i.action,resource:i.resource,effect:l}),a.add(r))}const o=ia("*","*");t.global!==null&&!a.has(o)&&n.unshift({action:"*",resource:"*",effect:t.global});for(const[i,r]of Object.entries(t.keys)){const l=ia(i,"*");if(r.effect!==null&&!a.has(l)){const u=n.findIndex(d=>d.action===i),m={action:i,resource:"*",effect:r.effect};u>=0?n.splice(u,0,m):n.push(m)}for(const u of r.patterns){const m=u.pattern.trim();if(m.length===0)continue;const d=ia(i,m),f=e.get(d);f===void 0||a.has(d)||(a.add(d),n.push({action:i,resource:m,effect:f}))}}return n},gh=(t,e)=>JSON.stringify(Xr(t))===JSON.stringify(Xr(e)),fh=(t,e)=>{const a=[...dh,...e.global,...e.agentGlobal?[{action:"*",resource:"*",effect:e.agentGlobal}]:[]];let n="ask";for(const o of a)o.resource==="*"&&(o.action==="*"||o.action===t)&&(n=o.effect);return n},hh=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),bh=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),xh={effect:null,patterns:[]},vh=t=>{const e=$e.c(163),{agent:a,registerSave:n,requestSave:o}=t,{t:i}=ze(),r=hn(yh),l=hn(jh);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];const[m,d]=c.useState(u),[f,g]=c.useState(hc),[p,h]=c.useState(hc),[w,b]=c.useState(!0),[k,v]=c.useState(!1);let S;e[1]===Symbol.for("react.memo_cache_sentinel")?(S={},e[1]=S):S=e[1];const[y,N]=c.useState(S),[x,I]=c.useState(""),[j,D]=c.useState(0),C=a.name,P=Us(),A=An(kh);let R;e[2]!==P?(R=_e=>ml(_e,P),e[2]=P,e[3]=R):R=e[3];const K=An(R);let F;e[4]!==P?(F=_e=>_e.getStatusForDirectory(P),e[4]=P,e[5]=F):F=e[5];const T=dn(F);let O,E;e[6]!==A||e[7]!==P?(O=()=>{A({directory:P})},E=[A,P],e[6]=A,e[7]=P,e[8]=O,e[9]=E):(O=e[8],E=e[9]),c.useEffect(O,E);let B;e[10]!==C||e[11]!==l||e[12]!==P?(B=()=>{let _e=!1;return b(!0),v(!1),(async()=>{const nt=await l(C,P);if(_e)return;if(!nt){v(!0),b(!1);return}const te=uh(nt.agent);d(nt.global),g(Yn(te)),h(te),N({}),b(!1)})(),()=>{_e=!0}},e[10]=C,e[11]=l,e[12]=P,e[13]=B):B=e[13];let _;e[14]!==C||e[15]!==l||e[16]!==j||e[17]!==P?(_=[C,l,j,P],e[14]=C,e[15]=l,e[16]=j,e[17]=P,e[18]=_):_=e[18],c.useEffect(B,_);let H;e[19]!==C||e[20]!==f||e[21]!==p||e[22]!==P||e[23]!==i||e[24]!==r?(H=async()=>gh(p,f)?Es:(await r(C,{permissions:Xr(p)},P)).ok?(g(Yn(p)),bn):gs(i("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=C,e[20]=f,e[21]=p,e[22]=P,e[23]=i,e[24]=r,e[25]=H):H=e[25];const ne=H;let z,$;e[26]!==n||e[27]!==ne?(z=()=>(n(ne),()=>n(null)),$=[n,ne],e[26]=n,e[27]=ne,e[28]=z,e[29]=$):(z=e[28],$=e[29]),c.useEffect(z,$);let V;e[30]!==K?(V=K.map(wh),e[30]=K,e[31]=V):V=e[31];const G=V;let ee;if(e[32]!==G||e[33]!==p.keys){ee=[...rh,...lh];const _e=new Set(G.map(Sh));let nt;e[35]!==p.keys?(nt=Object.keys(p.keys),e[35]=p.keys,e[36]=nt):nt=e[36];for(const te of nt)!ee.includes(te)&&!_e.has(te)&&ee.push(te);e[32]=G,e[33]=p.keys,e[34]=ee}else ee=e[34];const ae=ee;let X;e[37]!==T||e[38]!==i?(X=_e=>{switch(T?.[_e]?.status.status){case"connected":return i("settings.mcp.page.status.label.connected");case"failed":return i("settings.mcp.page.status.label.failed");case"needs_auth":return i("settings.mcp.page.status.label.needsAuth");case"disabled":return i("settings.agents.page.permissionsEditor.mcpStatus.disabled");case"pending":return i("settings.agents.page.permissionsEditor.mcpStatus.pending");default:return null}},e[37]=T,e[38]=i,e[39]=X):X=e[39];const Q=X;let le;e[40]!==m||e[41]!==p.global?(le=_e=>fh(_e,{global:m,agentGlobal:p.global}),e[40]=m,e[41]=p.global,e[42]=le):le=e[42];const Z=le;let fe;e[43]!==o?(fe=_e=>{h(nt=>({...nt,global:_e})),o()},e[43]=o,e[44]=fe):fe=e[44];const Y=fe;let be;e[45]!==o?(be=(_e,nt)=>{h(te=>{const ue=Yn(te),he=ue.keys[_e]??{effect:null,patterns:[]};return he.effect=nt,he.effect===null&&he.patterns.length===0?delete ue.keys[_e]:ue.keys[_e]=he,ue}),o()},e[45]=o,e[46]=be):be=e[46];const Ee=be;let se;e[47]!==o?(se=(_e,nt,te,ue,he)=>{h(ye=>{const qe=Yn(ye),Ze=qe.keys[_e]??{effect:null,patterns:[]};return Ze.patterns[nt]={pattern:te,effect:ue},qe.keys[_e]=Ze,qe}),he&&o()},e[47]=o,e[48]=se):se=e[48];const re=se;let je;e[49]===Symbol.for("react.memo_cache_sentinel")?(je=_e=>{h(nt=>{const te=Yn(nt),ue=te.keys[_e]??{effect:null,patterns:[]};return ue.patterns.push({pattern:"",effect:"allow"}),te.keys[_e]=ue,te}),N(nt=>({...nt,[_e]:!0}))},e[49]=je):je=e[49];const ie=je;let Pe;e[50]!==o?(Pe=(_e,nt)=>{h(te=>{const ue=Yn(te),he=ue.keys[_e];return he?(he.patterns.splice(nt,1),he.effect===null&&he.patterns.length===0&&delete ue.keys[_e],ue):te}),o()},e[50]=o,e[51]=Pe):Pe=e[51];const ke=Pe;let Ae;e[52]!==x||e[53]!==o?(Ae=()=>{const _e=x.trim();!_e||_e==="*"||(h(nt=>{if(nt.keys[_e])return nt;const te=Yn(nt);return te.keys[_e]={effect:"ask",patterns:[]},te}),I(""),o())},e[52]=x,e[53]=o,e[54]=Ae):Ae=e[54];const Te=Ae;let Ke;e[55]!==i?(Ke=_e=>i(_e==="allow"?"settings.agents.page.permissionsEditor.action.allow":_e==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=i,e[56]=Ke):Ke=e[56];const ge=Ke;let Re,Oe,pe,xe,Ne,de,Ue,Ie,De;if(e[57]!==ge||e[58]!==Z||e[59]!==y||e[60]!==w||e[61]!==k||e[62]!==G||e[63]!==Q||e[64]!==p.global||e[65]!==p.keys||e[66]!==ke||e[67]!==Y||e[68]!==Ee||e[69]!==re||e[70]!==i||e[71]!==ae){De=Symbol.for("react.early_return_sentinel");e:{const _e=i("settings.agents.page.permissionsEditor.action.inherit"),nt=i("settings.agents.page.permissionsEditor.action.default");let te;e[81]!==ge?(te=Xe=>[...Xe?[{value:"inherit",label:Xe}]:[],...oh.map(gt=>({value:gt,label:ge(gt)}))],e[81]=ge,e[82]=te):te=e[82];const ue=te,he=(Xe,gt,jt,L)=>{const me=L===void 0?_e:L;return s.jsx(Gs,{value:Xe??"inherit",options:ue(me),onChange:Se=>gt(Se==="inherit"?null:Se),"aria-label":jt})};if(w){let Xe;e[83]!==i?(Xe=i("settings.agents.page.section.toolPermissions"),e[83]=i,e[84]=Xe):Xe=e[84];let gt;e[85]!==i?(gt=i("common.loading"),e[85]=i,e[86]=gt):gt=e[86];let jt;e[87]!==gt?(jt=s.jsx("p",{className:Dt,children:gt}),e[87]=gt,e[88]=jt):jt=e[88];let L;e[89]!==Xe||e[90]!==jt?(L=s.jsx(He,{title:Xe,children:jt}),e[89]=Xe,e[90]=jt,e[91]=L):L=e[91],De=L;break e}if(k){let Xe;e[92]!==i?(Xe=i("settings.agents.page.section.toolPermissions"),e[92]=i,e[93]=Xe):Xe=e[93];let gt;e[94]!==i?(gt=i("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=i,e[95]=gt):gt=e[95];let jt;e[96]!==gt?(jt=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:gt}),e[96]=gt,e[97]=jt):jt=e[97];let L;e[98]===Symbol.for("react.memo_cache_sentinel")?(L=()=>D(Nh),e[98]=L):L=e[98];let me;e[99]!==i?(me=i("settings.agents.page.permissionsEditor.actions.retry"),e[99]=i,e[100]=me):me=e[100];let Se;e[101]!==me?(Se=s.jsx(q,{variant:"outline",size:"xs",onClick:L,children:me}),e[101]=me,e[102]=Se):Se=e[102];let Ce;e[103]!==jt||e[104]!==Se?(Ce=s.jsxs("div",{className:"flex items-center gap-3",children:[jt,Se]}),e[103]=jt,e[104]=Se,e[105]=Ce):Ce=e[105];let We;e[106]!==Xe||e[107]!==Ce?(We=s.jsx(He,{title:Xe,children:Ce}),e[106]=Xe,e[107]=Ce,e[108]=We):We=e[108],De=We;break e}const ye=(Xe,gt,jt)=>{const L=p.keys[Xe]??xh,me=bh.has(Xe)||L.patterns.length>0,Se=y[Xe]===!0;return s.jsxs("div",{className:"border-t border-border/40 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("button",{type:"button",onClick:me?()=>N(Ce=>({...Ce,[Xe]:!Se})):void 0,className:Me("flex min-w-0 items-center gap-1.5 text-start",!me&&"cursor-default"),"aria-expanded":me?Se:void 0,children:[s.jsx(J,{name:Se&&me?"arrow-down-s":"arrow-right-s",className:Me("h-3.5 w-3.5 shrink-0 text-muted-foreground",!me&&"opacity-0")}),s.jsx("span",{className:Ct,children:gt}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground/70",children:Xe}),jt&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:jt}),L.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:i("settings.agents.page.permissionsEditor.effectiveHint",{action:ge(Z(Xe))})}),L.patterns.length>0&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:i("settings.agents.page.permissionsEditor.ruleCount",{count:String(L.patterns.length)})})]}),he(L.effect,Ce=>Ee(Xe,Ce),i("settings.agents.page.permissionsEditor.keyAria",{key:Xe}))]}),Se&&me&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[L.patterns.map((Ce,We)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ve,{value:Ce.pattern,onChange:ce=>re(Xe,We,ce.target.value,Ce.effect,!1),placeholder:i("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":i("settings.agents.page.permissionsEditor.patternActionAria",{key:Xe}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Gs,{value:Ce.effect,options:ue(),onChange:ce=>re(Xe,We,Ce.pattern,ce,!0),"aria-label":i("settings.agents.page.permissionsEditor.patternActionAria",{key:Xe})}),s.jsx(q,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>ke(Xe,We),"aria-label":i("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(J,{name:"close",className:"h-3.5 w-3.5"})})]},We)),s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ie(Xe),children:[s.jsx(J,{name:"add",className:"me-1 h-3.5 w-3.5"}),i("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},Xe)};Re=He,e[109]!==i?(Oe=i("settings.agents.page.section.toolPermissions"),e[109]=i,e[110]=Oe):Oe=e[110],pe="agents.permissions",e[111]!==i?(xe=i("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=i,e[112]=xe):xe=e[112],Ne="space-y-4";let qe;e[113]!==i?(qe=i("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=i,e[114]=qe):qe=e[114];let Ze;e[115]!==qe?(Ze=s.jsx("span",{className:Ct,children:qe}),e[115]=qe,e[116]=Ze):Ze=e[116];let pt;e[117]!==i?(pt=i("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=i,e[118]=pt):pt=e[118];let vt;e[119]!==pt?(vt=s.jsx(qt,{children:pt}),e[119]=pt,e[120]=vt):vt=e[120];let bt;e[121]!==ge||e[122]!==Z||e[123]!==p.global||e[124]!==i?(bt=p.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:i("settings.agents.page.permissionsEditor.effectiveHint",{action:ge(Z("*"))})}),e[121]=ge,e[122]=Z,e[123]=p.global,e[124]=i,e[125]=bt):bt=e[125];let wt;e[126]!==Ze||e[127]!==vt||e[128]!==bt?(wt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Ze,vt,bt]}),e[126]=Ze,e[127]=vt,e[128]=bt,e[129]=wt):wt=e[129];const Et=p.global;let Le;e[130]!==i?(Le=i("settings.agents.page.permissionsEditor.defaultAria"),e[130]=i,e[131]=Le):Le=e[131],de=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[wt,he(Et,Y,Le,nt)]}),Ue=s.jsx("div",{children:ae.map(Xe=>ye(Xe,hh(Xe),null))}),Ie=G.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/40 pt-3 pb-1",children:[s.jsx("span",{className:Ct,children:i("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(qt,{children:i("settings.agents.page.permissionsEditor.mcpInfo")})]}),G.map(Xe=>ye(Xe.key,Xe.server,Q(Xe.server)))]})}e[57]=ge,e[58]=Z,e[59]=y,e[60]=w,e[61]=k,e[62]=G,e[63]=Q,e[64]=p.global,e[65]=p.keys,e[66]=ke,e[67]=Y,e[68]=Ee,e[69]=re,e[70]=i,e[71]=ae,e[72]=Re,e[73]=Oe,e[74]=pe,e[75]=xe,e[76]=Ne,e[77]=de,e[78]=Ue,e[79]=Ie,e[80]=De}else Re=e[72],Oe=e[73],pe=e[74],xe=e[75],Ne=e[76],de=e[77],Ue=e[78],Ie=e[79],De=e[80];if(De!==Symbol.for("react.early_return_sentinel"))return De;let Je;e[132]===Symbol.for("react.memo_cache_sentinel")?(Je=_e=>I(_e.target.value),e[132]=Je):Je=e[132];let tt;e[133]!==Te?(tt=_e=>{_e.key==="Enter"&&(_e.preventDefault(),Te())},e[133]=Te,e[134]=tt):tt=e[134];let mt;e[135]!==i?(mt=i("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=i,e[136]=mt):mt=e[136];let ht;e[137]!==x||e[138]!==tt||e[139]!==mt?(ht=s.jsx(Ve,{value:x,onChange:Je,onKeyDown:tt,placeholder:mt,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=x,e[138]=tt,e[139]=mt,e[140]=ht):ht=e[140];let ft;e[141]!==x?(ft=x.trim(),e[141]=x,e[142]=ft):ft=e[142];const xt=!ft;let Qe;e[143]===Symbol.for("react.memo_cache_sentinel")?(Qe=s.jsx(J,{name:"add",className:"me-1 h-3.5 w-3.5"}),e[143]=Qe):Qe=e[143];let lt;e[144]!==i?(lt=i("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=i,e[145]=lt):lt=e[145];let Ye;e[146]!==Te||e[147]!==xt||e[148]!==lt?(Ye=s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:Te,disabled:xt,children:[Qe,lt]}),e[146]=Te,e[147]=xt,e[148]=lt,e[149]=Ye):Ye=e[149];let at;e[150]!==ht||e[151]!==Ye?(at=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/40 pt-3",children:[ht,Ye]}),e[150]=ht,e[151]=Ye,e[152]=at):at=e[152];let dt;return e[153]!==Re||e[154]!==Oe||e[155]!==pe||e[156]!==xe||e[157]!==Ne||e[158]!==de||e[159]!==Ue||e[160]!==Ie||e[161]!==at?(dt=s.jsxs(Re,{title:Oe,settingsItem:pe,info:xe,contentClassName:Ne,children:[de,Ue,Ie,at]}),e[153]=Re,e[154]=Oe,e[155]=pe,e[156]=xe,e[157]=Ne,e[158]=de,e[159]=Ue,e[160]=Ie,e[161]=at,e[162]=dt):dt=e[162],dt};function yh(t){return t.updateAgent}function jh(t){return t.fetchAgentPermissions}function kh(t){return t.loadMcpConfigs}function wh(t){return{key:`${t.name}_*`,server:t.name}}function Sh(t){return t.key}function Nh(t){return t+1}const Al=t=>{const e=$e.c(11),{legacy:a,path:n,className:o}=t,{t:i}=ze();if(!a)return null;let r;e[0]!==o?(r=Me("mb-4 flex items-start gap-1.5",Dt,o),e[0]=o,e[1]=r):r=e[1];const l=n??void 0;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(J,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),e[2]=u):u=e[2];let m;e[3]!==i?(m=i("settings.common.legacyFormat.note"),e[3]=i,e[4]=m):m=e[4];let d;e[5]!==m?(d=s.jsx("span",{children:m}),e[5]=m,e[6]=d):d=e[6];let f;return e[7]!==r||e[8]!==l||e[9]!==d?(f=s.jsxs("p",{className:r,title:l,children:[u,d]}),e[7]=r,e[8]=l,e[9]=d,e[10]=f):f=e[10],f},Ch=(t,e)=>{const a=Tn(e);if(!a)return[];const n=t.find(i=>i.id===a.providerId),o=jg(n?.models,a.modelId);return zd(o)},Ih=t=>Um(t)?.toLowerCase()??"",Ph=()=>{const{t}=ze(),e=rt(ge=>ge.providers),{selectedAgentName:a,getAgentByName:n,createAgent:o,updateAgent:i,fetchAgentEntity:r,agentDraft:l,setAgentDraft:u,setSelectedAgent:m}=hn(Ms(ge=>({selectedAgentName:ge.selectedAgentName,getAgentByName:ge.getAgentByName,createAgent:ge.createAgent,updateAgent:ge.updateAgent,fetchAgentEntity:ge.fetchAgentEntity,agentDraft:ge.agentDraft,setAgentDraft:ge.setAgentDraft,setSelectedAgent:ge.setSelectedAgent}))),d=Us(),f=hn(ge=>Kd(ge,d)),g=a?n(a,d):null,p=!!(l&&l.name===a&&!g),h=p?"":g?.description?.trim()??"",w=p?"":g?.system?.trim()??"",[b,k]=c.useState(""),[v,S]=c.useState("user"),[y,N]=c.useState(""),[x,I]=c.useState("subagent"),[j,D]=c.useState(""),[C,P]=c.useState(""),[A,R]=c.useState(void 0),[K,F]=c.useState(void 0),[T,O]=c.useState(void 0),[E,B]=c.useState(""),[_,H]=c.useState(""),[ne,z]=c.useState(!1),[$,V]=c.useState(null),G=c.useRef({}),ee=c.useRef(null),ae=c.useCallback(ge=>{ee.current=ge},[]),X=c.useRef(null),Q=JSON.stringify([a,d,p]),le=c.useRef(Q);le.current=Q;const Z=c.useRef(null),fe={description:y,mode:x,model:j,variant:C,steps:A,temperature:K,topP:T,system:E,color:_},Y=c.useRef(fe);Y.current=fe;const be=c.useMemo(()=>Ch(e,j),[j,e]),Ee=be.length>0,se=C||"__default",re=Ee,je=c.useMemo(()=>C&&!be.includes(C)?[C,...be]:be,[C,be]);c.useEffect(()=>{if(!p||!l)return;Z.current=null;const ge=Si(l.model),Re=l.name||"",Oe=l.scope||"user",pe=l.description||"",xe=l.mode||"subagent",Ne=ge?`${ge.providerID}/${ge.modelID}`:"",de=ge?.variant||"",Ue=l.steps??void 0,Ie=l.temperature??void 0,De=l.top_p??void 0,Je=l.system||"",tt="";G.current={},V(null),k(Re),S(Oe),N(pe),I(xe),D(Ne),P(de),R(Ue),F(Ie),O(De),B(Je),H(tt),X.current={draftName:Re,draftScope:Oe,description:pe,mode:xe,model:Ne,variant:de,steps:Ue,temperature:Ie,topP:De,system:Je,color:tt}},[l,p]),c.useEffect(()=>{if(p||!a)return;let ge=!1;return(async()=>{const Re=await r(a,d);if(ge||le.current!==Q||!Re)return;const Oe=Re.config;G.current=Oe;const pe=Si(Oe.model),xe=Oe.request?.body,Ne={draftName:"",draftScope:"user",description:Oe.description||"",mode:Oe.mode||g?.mode||"subagent",model:pe?`${pe.providerID}/${pe.modelID}`:"",variant:pe?.variant||"",steps:Oe.steps??void 0,temperature:xe?.temperature,topP:xe?.top_p,system:Oe.system||"",color:Ih(Oe.color)},de=X.current,Ue=Y.current,Ie=de!==null&&(Ue.description!==de.description||Ue.mode!==de.mode||Ue.model!==de.model||Ue.variant!==de.variant||Ue.steps!==de.steps||Ue.temperature!==de.temperature||Ue.topP!==de.topP||Ue.system!==de.system||Ue.color!==de.color);V({legacy:Re.legacy===!0,path:Re.path,source:Re.source}),!(Z.current===Q&&Ie)&&(Z.current=Q,N(Ne.description),I(Ne.mode),D(Ne.model),P(Ne.variant),R(Ne.steps),F(Ne.temperature),O(Ne.topP),B(Ne.system),H(Ne.color),X.current=Ne)})(),()=>{ge=!0}},[r,p,g,a,d,Q]);const ie=c.useCallback(ge=>{const Re=Tn(j.trim()),Oe=Re?nu({providerID:Re.providerId,modelID:Re.modelId,variant:C.trim()||void 0}):null,pe=G.current.request,xe={...pe?.body};K===void 0?delete xe.temperature:xe.temperature=K,T===void 0?delete xe.top_p:xe.top_p=T;const Ne=pe?.headers,de={};Ne&&Object.keys(Ne).length>0&&(de.headers=Ne),Object.keys(xe).length>0&&(de.body=xe);const Ue=y.trim(),Ie=E.trim(),De={name:ge,mode:x,model:Oe,steps:A??null,system:Ie||(p?void 0:null),request:Object.keys(de).length>0?de:null};return Ue&&(De.description=Ue),_!==(X.current?.color??"")&&(De.color=_||null),p&&v&&(De.scope=v),p&&l?.hidden!==void 0&&(De.hidden=l.hidden),p&&l?.permissions?.length&&(De.permissions=l.permissions),De},[l,_,y,v,p,x,j,A,E,K,T,C]),Pe=c.useCallback(async()=>{const ge=X.current,Re=a?.trim();if(p||!ge||!Re)return Es;const Oe=ee.current?await ee.current():Es;if(y===ge.description&&x===ge.mode&&j===ge.model&&C===ge.variant&&A===ge.steps&&K===ge.temperature&&T===ge.topP&&E===ge.system&&_===ge.color||!Oe.ok)return Oe;const xe=ie(Re);return(await i(Re,xe,d)).ok?(le.current!==Q||(G.current={...G.current,model:xe.model,system:xe.system??void 0,steps:xe.steps,request:xe.request??void 0},X.current={...ge,description:y,mode:x,model:j,variant:C,steps:A,temperature:K,topP:T,system:E,color:_}),bn):gs(t("settings.agents.page.toast.updateFailed"))},[ie,_,y,p,x,j,a,Q,d,A,E,t,K,T,i,C]),ke=Ya(Pe),{requestSave:Ae}=ke,Te=async()=>{const ge=b.trim().replace(/\s+/g,"-");if(!ge){W.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(f.some(Re=>Re.name===ge)){W.error(t("settings.agents.sidebar.toast.agentExists"));return}z(!0);try{(await o(ie(ge),d)).ok?(u(null),W.success(t("settings.agents.page.toast.created"))):W.error(t("settings.agents.page.toast.createFailed"))}catch(Re){console.error("Error creating agent:",Re);const Oe=Re instanceof Error&&Re.message?Re.message:t("settings.agents.page.toast.saveUnexpectedError");W.error(Oe)}finally{z(!1)}},Ke=()=>{u(null),m(null)};return a?s.jsxs(Yt,{title:p?t("settings.agents.page.title.new"):a,description:t(p?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:ke.onBlurCapture,children:[!p&&$&&s.jsx(Al,{legacy:$.legacy,path:$.path}),!p&&$?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${Dt}`,children:[s.jsx(J,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),s.jsx("span",{children:t("settings.agents.page.runtimeProvided.note")})]}),s.jsxs(He,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-3",children:[p&&s.jsxs(kt,{settingsItem:"agents.name",label:t("settings.agents.page.field.agentName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground me-1",children:"@"}),s.jsx(Ve,{value:b,onChange:ge=>k(ge.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Tt,{value:v,onValueChange:ge=>S(ge),children:[s.jsx(Pt,{className:"w-fit min-w-[100px]",children:s.jsx(Ut,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(At,{align:"end",children:[s.jsx(ot,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(ot,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(Mt,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(ws,{value:y,onChange:ge=>N(ge.target.value),placeholder:h||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(Mt,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Gs,{"aria-label":t("settings.agents.page.field.mode"),value:x,onChange:ge=>{I(ge),Ae()},options:[{value:"primary",label:t("settings.agents.page.mode.primary")},{value:"subagent",label:t("settings.agents.page.mode.subagent")},{value:"all",label:t("settings.agents.page.mode.all")}]})}),s.jsx(Mt,{settingsItem:"agents.color",label:t("settings.agents.page.field.color"),info:t("settings.agents.page.field.colorTooltip"),children:s.jsx(uf,{value:_,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:ge=>t("settings.agents.page.field.colorSwatchAria",{color:ge}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:ge=>{H(ge),Ae()}})})]}),s.jsxs(He,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(kt,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(oa,{providerId:Tn(j)?.providerId??"",modelId:Tn(j)?.modelId??"",onChange:(ge,Re)=>{D(ge&&Re?`${ge}/${Re}`:""),P(""),Ae()},className:sn})}),s.jsx(kt,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:re?s.jsxs(Tt,{value:se,onValueChange:ge=>{P(ge==="__default"?"":ge),Ae()},children:[s.jsx(Pt,{className:nn,children:s.jsx(Ut,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:ge=>ge==="__default"?t("chat.modelControls.default"):ge})}),s.jsxs(At,{children:[s.jsx(ot,{value:"__default",children:t("chat.modelControls.default")}),je.map(ge=>s.jsx(ot,{value:ge,children:ge},ge))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ve,{value:C,onChange:ge=>P(ge.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!j&&!C,className:"h-8 w-40 rounded-md px-3"}),C&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{P(""),Ae()},className:os,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(J,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(kt,{settingsItem:"agents.temperature",label:t("settings.agents.page.field.temperature"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.temperatureTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.temperatureRange")})]}),children:[s.jsx(ps,{value:K,fallbackValue:.7,onValueChange:F,onClear:()=>{F(void 0),Ae()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:fs}),K!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{F(void 0),Ae()},className:os,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(J,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(kt,{settingsItem:"agents.top-p",label:t("settings.agents.page.field.topP"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.topPTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.topPRange")})]}),children:[s.jsx(ps,{value:T,fallbackValue:.9,onValueChange:O,onClear:()=>{O(void 0),Ae()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:fs}),T!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{O(void 0),Ae()},className:os,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(J,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(kt,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(ps,{value:A,fallbackValue:20,onValueChange:R,onClear:()=>{R(void 0),Ae()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:fs}),A!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{R(void 0),Ae()},className:os,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx(J,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(He,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(ws,{value:E,onChange:ge=>B(ge.target.value),placeholder:w||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!p&&g&&s.jsx(vh,{agent:g,registerSave:ae,requestSave:Ae}),p&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(q,{onClick:()=>{Te()},disabled:ne||!b.trim(),size:"xs",className:"!font-normal",children:t(ne?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(q,{variant:"ghost",onClick:Ke,disabled:ne,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(J,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.agents.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.agents.page.empty.description")})]})})};function Ah(t,e){return t.kind==="file"?t.content:e??""}const bc=ss({content:St(),exists:Fi(),path:St().min(1).optional()}),Th=async(t,e)=>{const a=await t.json().catch(()=>null);return typeof a?.error=="string"&&a.error.trim()?a.error:e},Eh=t=>t.length>0&&!t.endsWith(`
|
|
3
|
+
`)?`${t}
|
|
4
|
+
`:t,Ji={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},Mh=(t,e)=>t==="custom"?e:Bm(t),Dh=t=>t==="custom"?"custom":Ud(t)?t:"concise",xc={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"},Rh=()=>{const{t}=ze(),[e,a]=c.useState(""),[n,o]=c.useState("AGENTS.md"),[i,r]=c.useState(Ji.responseStyleEnabled),[l,u]=c.useState(Ji.responseStylePreset),[m,d]=c.useState(Ji.responseStyleCustomInstructions),[f,g]=c.useState(!0),p=c.useRef(null),h=c.useRef(null);c.useEffect(()=>{const y=new AbortController;return(async()=>{try{const[x,I]=await Promise.all([xn(),Rt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:y.signal})]);let j=Ji,D;x&&(j={...j,responseStyleEnabled:x.responseStyleEnabled===!0,responseStylePreset:Dh(x.responseStylePreset),responseStyleCustomInstructions:x.responseStyleCustomInstructions??""},x.globalBehaviorPrompt!==void 0&&(D=x.globalBehaviorPrompt));let C={kind:"missing"};if(I.ok){const P=bc.parse(await I.json());if(y.signal.aborted)return;o(P.path??"AGENTS.md"),h.current=P.exists?P.content:null,P.exists&&(C={kind:"file",content:P.content})}j={...j,prompt:Ah(C,D)},a(j.prompt),r(j.responseStyleEnabled),u(j.responseStylePreset),d(j.responseStyleCustomInstructions),p.current=j}catch(x){x.name!=="AbortError"&&console.warn("Failed to load behavior settings:",x)}finally{g(!1)}})(),()=>y.abort()},[]);const w=c.useRef(e);w.current=e,c.useEffect(()=>{let y=null;const N=async()=>{if(document.visibilityState!=="visible"||!p.current)return;y?.abort();const I=new AbortController;y=I;try{const j=await Rt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:I.signal});if(!j.ok)return;const D=bc.parse(await j.json()),C=p.current;if(I.signal.aborted||!C||!D.exists||D.content===h.current||w.current!==C.prompt)return;h.current=D.content,p.current={...C,prompt:D.content},a(D.content)}catch(j){j instanceof DOMException&&j.name==="AbortError"||console.warn("Failed to refresh AGENTS.md:",j)}},x=()=>{N()};return window.addEventListener("focus",x),document.addEventListener("visibilitychange",x),()=>{y?.abort(),window.removeEventListener("focus",x),document.removeEventListener("visibilitychange",x)}},[]);const b=c.useCallback(async()=>{const y=p.current;if(!y||f)return Es;const N=e!==y.prompt,x=i!==y.responseStyleEnabled||l!==y.responseStylePreset||m!==y.responseStyleCustomInstructions;if(!N&&!x)return Es;const I=N?Eh(e):y.prompt;if(N){const D=await Rt("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:I,expectedContent:h.current})});if(D.status===409)return gs(t("settings.behavior.page.toast.agentsMdChangedOnDisk"));if(!D.ok)return gs(await Th(D,t("settings.behavior.page.toast.saveFailed")));h.current=I,a(C=>C===e?I:C)}return(await yt({...N?{globalBehaviorPrompt:I}:{},responseStyleEnabled:i,responseStylePreset:l,responseStyleCustomInstructions:m})).ok?(p.current={prompt:I,responseStyleEnabled:i,responseStylePreset:l,responseStyleCustomInstructions:m},bn):gs(t("settings.behavior.page.toast.saveFailed"))},[f,e,m,i,l,t]),k=Ya(b),{requestSave:v}=k,S=Mh(l,m);return s.jsxs(Yt,{title:t("settings.behavior.page.title"),description:t("settings.page.behavior.description"),onBlurCapture:k.onBlurCapture,children:[s.jsx(He,{title:t("settings.behavior.page.section.systemPrompt"),divider:!1,info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"font-medium text-foreground",children:t("settings.behavior.page.warning.title")}),s.jsx("p",{children:t("settings.behavior.page.warning.description",{path:n})})]}),settingsItem:"behavior.system-prompt",contentClassName:"space-y-3",children:s.jsx(ws,{value:e,onChange:y=>a(y.target.value),placeholder:t("settings.behavior.page.field.systemPromptPlaceholder"),rows:12,disabled:f,outerClassName:"min-h-[160px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"})}),s.jsxs(He,{title:t("settings.behavior.page.section.responseStyle"),info:t("settings.behavior.page.responseStyle.tooltip"),settingsItem:"behavior.response-style",contentClassName:"space-y-3",children:[s.jsx(it,{checked:i,onChange:y=>{r(y),v()},disabled:f,label:t("settings.behavior.page.responseStyle.enable"),ariaLabel:t("settings.behavior.page.responseStyle.enableAria")}),s.jsx(kt,{label:t("settings.behavior.page.responseStyle.preset"),alignEnd:!1,children:s.jsxs(Tt,{value:l,onValueChange:y=>{u(y),v()},disabled:f||!i,children:[s.jsx(Pt,{className:nn,children:s.jsx(Ut,{children:y=>y==="custom"?t("settings.behavior.page.responseStyle.option.custom"):Ud(y)?t(xc[y]):null})}),s.jsxs(At,{children:[$m.map(y=>s.jsx(ot,{value:y,children:t(xc[y])},y)),s.jsx(ot,{value:"custom",children:t("settings.behavior.page.responseStyle.option.custom")})]})]})}),s.jsx(ws,{value:S,onChange:y=>d(y.target.value),placeholder:t("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:f||!i||l!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})},Fh=(t,e)=>t.kind===e.kind&&(t.kind!=="provider"||e.kind==="provider"&&t.id===e.id),Oh=t=>{const e=$e.c(73),{snapshot:a}=t,{t:n}=ze(),o=Ii(Uh),i=a.selection,r=a.projectOverride!==null;let l;e[0]!==r||e[1]!==i||e[2]!==o||e[3]!==n?(l=K=>{r||Fh(K,i)||o(K).then(F=>{F||W.error(n("settings.webSearch.toast.saveFailed"))})},e[0]=r,e[1]=i,e[2]=o,e[3]=n,e[4]=l):l=e[4];const u=l,m=i.kind==="provider"&&!a.providers.some(K=>K.id===i.id)?i.id:null;let d;e[5]!==n?(d=n("settings.webSearch.section.provider"),e[5]=n,e[6]=d):d=e[6];let f;e[7]!==n?(f=n("settings.webSearch.section.providerInfo"),e[7]=n,e[8]=f):f=e[8];let g;e[9]!==n?(g=n("settings.webSearch.section.provider"),e[9]=n,e[10]=g):g=e[10];const p=i.kind==="default";let h;e[11]!==u?(h=()=>u({kind:"default"}),e[11]=u,e[12]=h):h=e[12];let w;e[13]!==n?(w=n("settings.webSearch.option.default"),e[13]=n,e[14]=w):w=e[14];let b;e[15]!==n?(b=n("settings.webSearch.option.defaultDescription"),e[15]=n,e[16]=b):b=e[16];let k;e[17]!==r||e[18]!==p||e[19]!==h||e[20]!==w||e[21]!==b?(k=s.jsx(ns,{selected:p,onSelect:h,disabled:r,label:w,description:b}),e[17]=r,e[18]=p,e[19]=h,e[20]=w,e[21]=b,e[22]=k):k=e[22];let v;e[23]!==u||e[24]!==r||e[25]!==i.kind||e[26]!==a.providers.length||e[27]!==n?(v=a.providers.length>0?s.jsx(ns,{selected:i.kind==="random",onSelect:()=>u({kind:"random"}),disabled:r,label:n("settings.webSearch.option.random"),description:n("settings.webSearch.option.randomDescription")}):null,e[23]=u,e[24]=r,e[25]=i.kind,e[26]=a.providers.length,e[27]=n,e[28]=v):v=e[28];let S;if(e[29]!==u||e[30]!==r||e[31]!==i.id||e[32]!==i.kind||e[33]!==a.providers){let K;e[35]!==u||e[36]!==r||e[37]!==i.id||e[38]!==i.kind?(K=F=>s.jsx(ns,{selected:i.kind==="provider"&&i.id===F.id,onSelect:()=>u({kind:"provider",id:F.id}),disabled:r,label:F.name},F.id),e[35]=u,e[36]=r,e[37]=i.id,e[38]=i.kind,e[39]=K):K=e[39],S=a.providers.map(K),e[29]=u,e[30]=r,e[31]=i.id,e[32]=i.kind,e[33]=a.providers,e[34]=S}else S=e[34];let y;e[40]!==m||e[41]!==n?(y=m?s.jsx(ns,{selected:!0,onSelect:$h,label:m,description:n("settings.webSearch.option.missing")}):null,e[40]=m,e[41]=n,e[42]=y):y=e[42];const N=i.kind==="off";let x;e[43]!==u?(x=()=>u({kind:"off"}),e[43]=u,e[44]=x):x=e[44];let I;e[45]!==n?(I=n("settings.webSearch.option.off"),e[45]=n,e[46]=I):I=e[46];let j;e[47]!==r||e[48]!==N||e[49]!==x||e[50]!==I?(j=s.jsx(ns,{selected:N,onSelect:x,disabled:r,label:I}),e[47]=r,e[48]=N,e[49]=x,e[50]=I,e[51]=j):j=e[51];let D;e[52]!==v||e[53]!==S||e[54]!==y||e[55]!==j||e[56]!==g||e[57]!==k?(D=s.jsxs(Os,{"aria-label":g,children:[k,v,S,y,j]}),e[52]=v,e[53]=S,e[54]=y,e[55]=j,e[56]=g,e[57]=k,e[58]=D):D=e[58];let C;e[59]!==a.projectOverride||e[60]!==n?(C=a.projectOverride?s.jsx("p",{className:`${Dt} mt-2 break-all`,children:n("settings.webSearch.state.projectOverride",{path:a.projectOverride})}):null,e[59]=a.projectOverride,e[60]=n,e[61]=C):C=e[61];let P;e[62]!==a.providers.length||e[63]!==n?(P=a.providers.length===0?s.jsx("p",{className:`${Dt} mt-2`,children:n("settings.webSearch.state.noProviders")}):null,e[62]=a.providers.length,e[63]=n,e[64]=P):P=e[64];let A;e[65]!==D||e[66]!==C||e[67]!==P?(A=s.jsxs("div",{children:[D,C,P]}),e[65]=D,e[66]=C,e[67]=P,e[68]=A):A=e[68];let R;return e[69]!==d||e[70]!==A||e[71]!==f?(R=s.jsx(He,{title:d,info:f,divider:!1,settingsItem:"web-search.provider",children:A}),e[69]=d,e[70]=A,e[71]=f,e[72]=R):R=e[72],R},Lh=t=>{const e=$e.c(27),{provider:a,access:n,locked:o}=t,{t:i}=ze(),r=Ii(Bh),l=Ii(_h),[u,m]=c.useState(""),[d,f]=c.useState(!1);let g;e[0]!==n.envNames||e[1]!==i?(g=n.envNames.length>0?i("settings.webSearch.keys.envHint",{names:n.envNames.join(", ")}):void 0,e[0]=n.envNames,e[1]=i,e[2]=g):g=e[2];const p=g;let h;e[3]!==u||e[4]!==a.id||e[5]!==a.name||e[6]!==r||e[7]!==i?(h=async()=>{const N=u.trim();if(!N)return;f(!0);const x=await r(a.id,N);f(!1),x?(m(""),W.success(i("settings.webSearch.toast.keySaved",{provider:a.name}))):W.error(i("settings.webSearch.toast.keySaveFailed"))},e[3]=u,e[4]=a.id,e[5]=a.name,e[6]=r,e[7]=i,e[8]=h):h=e[8];const w=h;let b;e[9]!==a.id||e[10]!==l||e[11]!==i?(b=async()=>{f(!0);const N=await l(a.id);f(!1),N||W.error(i("settings.webSearch.toast.keyRemoveFailed"))},e[9]=a.id,e[10]=l,e[11]=i,e[12]=b):b=e[12];const k=b,v=n.key;let S;e[13]!==d||e[14]!==u||e[15]!==k||e[16]!==w||e[17]!==o||e[18]!==a.name||e[19]!==v.kind||e[20]!==v.name||e[21]!==i?(S=v.kind==="stored"?s.jsxs("div",{className:`${ys} flex items-center justify-end gap-2`,children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.webSearch.keys.saved")}),s.jsx(q,{variant:"outline",size:"xs",disabled:d,onClick:()=>{k()},children:i("settings.webSearch.keys.remove")})]}):v.kind==="env"?s.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.webSearch.keys.fromEnv",{name:v.name})}):o?null:s.jsxs("div",{className:`${ys} flex items-center gap-2`,children:[s.jsx(Ve,{type:"password",value:u,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&w()},placeholder:i("settings.webSearch.keys.placeholder"),"aria-label":i("settings.webSearch.keys.inputAria",{provider:a.name}),className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"}),s.jsx(q,{size:"xs",disabled:d||u.trim().length===0,onClick:()=>{w()},children:i("settings.webSearch.keys.save")})]}),e[13]=d,e[14]=u,e[15]=k,e[16]=w,e[17]=o,e[18]=a.name,e[19]=v.kind,e[20]=v.name,e[21]=i,e[22]=S):S=e[22];let y;return e[23]!==p||e[24]!==a.name||e[25]!==S?(y=s.jsx(kt,{label:a.name,info:p,children:S}),e[23]=p,e[24]=a.name,e[25]=S,e[26]=y):y=e[26],y},Kh=t=>{const e=$e.c(29),{snapshot:a}=t,{t:n}=ze(),o=Ln(),i=a.access;let r,l,u,m,d,f,g,p;if(e[0]!==i||e[1]!==o||e[2]!==a.providers||e[3]!==n){p=Symbol.for("react.early_return_sentinel");e:{const b=i?a.providers.flatMap(k=>{const v=i[k.id];return v&&v.key.kind!=="unsupported"?[{provider:k,access:v}]:[]}):[];if(i&&b.length===0){p=null;break e}r=He,e[12]!==n?(d=n("settings.webSearch.section.keys"),e[12]=n,e[13]=d):d=e[13],e[14]!==n?(f=n("settings.webSearch.section.keysInfo"),e[14]=n,e[15]=f):f=e[15],g="web-search.keys",l="space-y-4",e[16]!==o||e[17]!==n?(u=o?s.jsx("p",{className:Dt,children:n("settings.webSearch.keys.enterpriseMode")}):null,e[16]=o,e[17]=n,e[18]=u):u=e[18],m=i===null?s.jsx("p",{className:Dt,children:n("settings.webSearch.state.keysUnavailable")}):b.map(k=>{const{provider:v,access:S}=k;return s.jsx(Lh,{provider:v,access:S,locked:o},v.id)})}e[0]=i,e[1]=o,e[2]=a.providers,e[3]=n,e[4]=r,e[5]=l,e[6]=u,e[7]=m,e[8]=d,e[9]=f,e[10]=g,e[11]=p}else r=e[4],l=e[5],u=e[6],m=e[7],d=e[8],f=e[9],g=e[10],p=e[11];if(p!==Symbol.for("react.early_return_sentinel"))return p;let h;e[19]!==l||e[20]!==u||e[21]!==m?(h=s.jsxs("div",{className:l,children:[u,m]}),e[19]=l,e[20]=u,e[21]=m,e[22]=h):h=e[22];let w;return e[23]!==r||e[24]!==d||e[25]!==f||e[26]!==g||e[27]!==h?(w=s.jsx(r,{title:d,info:f,settingsItem:g,children:h}),e[23]=r,e[24]=d,e[25]=f,e[26]=g,e[27]=h,e[28]=w):w=e[28],w},zh=()=>{const t=$e.c(17),{t:e}=ze(),a=Ii(Vh),n=Ii(Hh);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=_m(),t[0]=o):o=t[0];const i=o;let r,l;t[1]!==n?(r=()=>{n()},l=[n,i],t[1]=n,t[2]=r,t[3]=l):(r=t[2],l=t[3]),c.useEffect(r,l);const u=a.kind==="ready"&&a.snapshot.scope===i?a.snapshot:null;let m;t[4]!==e?(m=e("settings.page.webSearch.title"),t[4]=e,t[5]=m):m=t[5];let d;t[6]!==e?(d=e("settings.page.webSearch.description"),t[6]=e,t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==u||t[10]!==a.kind||t[11]!==e?(f=u?s.jsxs(s.Fragment,{children:[s.jsx(Oh,{snapshot:u}),s.jsx(Kh,{snapshot:u})]}):a.kind==="failed"?s.jsx(He,{divider:!1,children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("settings.webSearch.state.loadFailed")}),s.jsx(q,{variant:"outline",size:"xs",onClick:()=>{n()},children:e("settings.webSearch.actions.retry")})]})}):s.jsx(He,{divider:!1,children:s.jsx("p",{className:Dt,children:e("settings.webSearch.state.loading")})}),t[8]=n,t[9]=u,t[10]=a.kind,t[11]=e,t[12]=f):f=t[12];let g;return t[13]!==m||t[14]!==d||t[15]!==f?(g=s.jsx(Yt,{title:m,description:d,showSaveStatus:!0,children:f}),t[13]=m,t[14]=d,t[15]=f,t[16]=g):g=t[16],g};function Uh(t){return t.setSelection}function $h(){}function Bh(t){return t.saveKey}function _h(t){return t.removeKey}function Vh(t){return t.state}function Hh(t){return t.load}const qh=t=>{const e=$e.c(183),{onItemSelect:a}=t,{t:n}=ze(),[o,i]=c.useState(""),[r,l]=c.useState(null),[u,m]=c.useState(""),[d,f]=c.useState(null),[g,p]=c.useState(null),[h,w]=c.useState(!1),[b,k]=c.useState(null),{selectedCommandName:v,setSelectedCommand:S,setCommandDraft:y,createCommand:N,deleteCommand:x,loadCommands:I}=qa(Ms(Wh)),j=Us();let D;e[0]!==j?(D=Le=>$d(Le,j),e[0]=j,e[1]=D):D=e[1];const C=qa(D);let P;e[2]!==j?(P=Le=>pl(Le,j),e[2]=j,e[3]=P):P=e[3];const A=Ws(P),R=Ws(Gh);let K,F;e[4]!==I||e[5]!==R||e[6]!==j?(K=()=>{I(j),R(j)},F=[I,R,j],e[4]=I,e[5]=R,e[6]=j,e[7]=K,e[8]=F):(K=e[7],F=e[8]),c.useEffect(K,F);let T;e[9]!==A?(T=new Set(A.map(Jh)),e[9]=A,e[10]=T):T=e[10];const O=T;let E;if(e[11]!==C||e[12]!==O){let Le;e[14]!==O?(Le=Xe=>!O.has(Xe.name),e[14]=O,e[15]=Le):Le=e[15],E=C.filter(Le),e[11]=C,e[12]=O,e[13]=E}else E=e[13];const B=E;let _,H;e[16]!==v||e[17]!==S||e[18]!==O?(_=()=>{v&&O.has(v)&&S(null)},H=[v,S,O],e[16]=v,e[17]=S,e[18]=O,e[19]=_,e[20]=H):(_=e[19],H=e[20]),c.useEffect(_,H);let ne;e[21]!==C||e[22]!==a||e[23]!==y||e[24]!==S?(ne=()=>{let Le="new-command",Xe=1;for(;C.some(gt=>gt.name===Le);)Le=`new-command-${Xe}`,Xe++;y({name:Le,scope:"user"}),S(Le),a?.()},e[21]=C,e[22]=a,e[23]=y,e[24]=S,e[25]=ne):ne=e[25];const z=ne;let $;e[26]!==n?($=async Le=>{if(Ba(Le)){W.error(n("settings.commands.sidebar.toast.builtInCannotDelete"));return}f(Le),p("delete")},e[26]=n,e[27]=$):$=e[27];const V=$;let G;e[28]===Symbol.for("react.memo_cache_sentinel")?(G=async Le=>{Ba(Le)&&(f(Le),p("reset"))},e[28]=G):G=e[28];const ee=G;let ae;e[29]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>{f(null),p(null)},e[29]=ae):ae=e[29];const X=ae;let Q;e[30]!==d||e[31]!==g||e[32]!==x||e[33]!==j||e[34]!==n?(Q=async()=>{if(!d||!g)return;w(!0),await x(d.name,j)?(g==="delete"?W.success(n("settings.commands.sidebar.toast.commandDeleted",{name:d.name})):W.success(n("settings.commands.sidebar.toast.commandReset",{name:d.name})),X()):g==="delete"?W.error(n("settings.commands.sidebar.toast.deleteFailed")):W.error(n("settings.commands.sidebar.toast.resetFailed")),w(!1)},e[30]=d,e[31]=g,e[32]=x,e[33]=j,e[34]=n,e[35]=Q):Q=e[35];const le=Q;let Z;e[36]!==C||e[37]!==y||e[38]!==S?(Z=Le=>{const Xe=Le.name;let gt=1,jt=`${Xe}-copy`;for(;C.some(L=>L.name===jt);)gt++,jt=`${Xe}-copy-${gt}`;y({name:jt,scope:Le.scope||"user",description:Le.description,template:Le.template,agent:Le.agent,model:Le.model,subagent:Le.subagent}),S(jt)},e[36]=C,e[37]=y,e[38]=S,e[39]=Z):Z=e[39];const fe=Z;let Y;e[40]===Symbol.for("react.memo_cache_sentinel")?(Y=Le=>{m(Le.name),l(Le)},e[40]=Y):Y=e[40];const be=Y;let Ee;e[41]!==C||e[42]!==N||e[43]!==x||e[44]!==r||e[45]!==u||e[46]!==S||e[47]!==j||e[48]!==n?(Ee=async()=>{if(!r)return;const Le=u.trim().replace(/\s+/g,"-");if(!Le){W.error(n("settings.commands.sidebar.toast.commandNameRequired"));return}if(Le===r.name){l(null);return}if(C.some(gt=>gt.name===Le)){W.error(n("settings.commands.sidebar.toast.commandExists"));return}await N({name:Le,description:r.description,template:r.template,agent:r.agent,model:r.model,subagent:r.subagent,scope:r.scope},j)?await x(r.name,j)?(W.success(`Command renamed to "${Le}"`),S(Le)):W.error(n("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):W.error(n("settings.commands.sidebar.toast.renameFailed")),l(null)},e[41]=C,e[42]=N,e[43]=x,e[44]=r,e[45]=u,e[46]=S,e[47]=j,e[48]=n,e[49]=Ee):Ee=e[49];const se=Ee;let re,je,ie,Pe,ke,Ae;if(e[50]!==B||e[51]!==z||e[52]!==V||e[53]!==fe||e[54]!==a||e[55]!==b||e[56]!==o||e[57]!==v||e[58]!==S||e[59]!==n){let Le;e[66]!==o?(Le=It=>Ci([It.name,It.description],o),e[66]=o,e[67]=Le):Le=e[67];const Xe=B.filter(Le),gt=Xe.filter(Ba),jt=Xe.filter(Qh);e[68]===Symbol.for("react.memo_cache_sentinel")?(ke=Me("flex h-full flex-col","bg-background"),e[68]=ke):ke=e[68];let L;e[69]!==n?(L=n("settings.commands.sidebar.title"),e[69]=n,e[70]=L):L=e[70];let me;e[71]!==L?(me=s.jsx("h2",{className:`${On} mb-3`,children:L}),e[71]=L,e[72]=me):me=e[72];let Se;e[73]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx(Oi,{className:"mb-3"}),e[73]=Se):Se=e[73];let Ce;e[74]!==B.length||e[75]!==n?(Ce=n("settings.commands.sidebar.total",{count:B.length}),e[74]=B.length,e[75]=n,e[76]=Ce):Ce=e[76];let We;e[77]!==Ce?(We=s.jsx("span",{className:"typography-meta text-muted-foreground",children:Ce}),e[77]=Ce,e[78]=We):We=e[78];let ce;e[79]===Symbol.for("react.memo_cache_sentinel")?(ce=s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),e[79]=ce):ce=e[79];let Fe;e[80]!==z?(Fe=s.jsx(q,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:z,children:ce}),e[80]=z,e[81]=Fe):Fe=e[81];let ct;e[82]!==We||e[83]!==Fe?(ct=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[We,Fe]}),e[82]=We,e[83]=Fe,e[84]=ct):ct=e[84];let Ft;e[85]!==B.length||e[86]!==o?(Ft=B.length>0?s.jsx(Il,{value:o,onChange:i}):null,e[85]=B.length,e[86]=o,e[87]=Ft):Ft=e[87],e[88]!==me||e[89]!==ct||e[90]!==Ft?(Ae=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[me,Se,ct,Ft]}),e[88]=me,e[89]=ct,e[90]=Ft,e[91]=Ae):Ae=e[91],re=Ts,je="flex-1 min-h-0",ie="space-y-1 px-3 py-2",Pe=B.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(J,{name:"terminal-box",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.commands.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.commands.sidebar.empty.description")})]}):Xe.length===0?s.jsx(Pl,{query:o}):s.jsxs(s.Fragment,{children:[gt.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.commands.sidebar.section.builtIn")}),[...gt].sort(Yh).map(It=>s.jsx(vc,{command:It,isSelected:v===It.name,onSelect:()=>{S(It.name),a?.()},onReset:()=>ee(It),onDuplicate:()=>fe(It),isMenuOpen:b===It.name,onMenuOpenChange:ls=>k(ls?It.name:null)},It.name))]}),jt.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.commands.sidebar.section.custom")}),[...jt].sort(Zh).map(It=>s.jsx(vc,{command:It,isSelected:v===It.name,onSelect:()=>{S(It.name),a?.()},onRename:()=>be(It),onDelete:()=>V(It),onDuplicate:()=>fe(It),isMenuOpen:b===It.name,onMenuOpenChange:ls=>k(ls?It.name:null)},It.name))]})]}),e[50]=B,e[51]=z,e[52]=V,e[53]=fe,e[54]=a,e[55]=b,e[56]=o,e[57]=v,e[58]=S,e[59]=n,e[60]=re,e[61]=je,e[62]=ie,e[63]=Pe,e[64]=ke,e[65]=Ae}else re=e[60],je=e[61],ie=e[62],Pe=e[63],ke=e[64],Ae=e[65];let Te;e[92]!==re||e[93]!==je||e[94]!==ie||e[95]!==Pe?(Te=s.jsx(re,{outerClassName:je,className:ie,children:Pe}),e[92]=re,e[93]=je,e[94]=ie,e[95]=Pe,e[96]=Te):Te=e[96];const Ke=d!==null&&g!==null;let ge;e[97]!==h?(ge=Le=>{!Le&&!h&&X()},e[97]=h,e[98]=ge):ge=e[98];let Re;e[99]!==g||e[100]!==n?(Re=n(g==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[99]=g,e[100]=n,e[101]=Re):Re=e[101];let Oe;e[102]!==Re?(Oe=s.jsx(_t,{children:Re}),e[102]=Re,e[103]=Oe):Oe=e[103];let pe;e[104]!==d?.name||e[105]!==g||e[106]!==n?(pe=g==="delete"?n("settings.commands.sidebar.dialog.deleteDescription",{name:d?.name??""}):n("settings.commands.sidebar.dialog.resetDescription",{name:d?.name??""}),e[104]=d?.name,e[105]=g,e[106]=n,e[107]=pe):pe=e[107];let xe;e[108]!==pe?(xe=s.jsx(Vt,{children:pe}),e[108]=pe,e[109]=xe):xe=e[109];let Ne;e[110]!==Oe||e[111]!==xe?(Ne=s.jsxs(Bt,{children:[Oe,xe]}),e[110]=Oe,e[111]=xe,e[112]=Ne):Ne=e[112];let de;e[113]!==n?(de=n("settings.common.actions.cancel"),e[113]=n,e[114]=de):de=e[114];let Ue;e[115]!==h||e[116]!==de?(Ue=s.jsx(q,{size:"sm",variant:"ghost",onClick:X,disabled:h,children:de}),e[115]=h,e[116]=de,e[117]=Ue):Ue=e[117];let Ie;e[118]!==g||e[119]!==n?(Ie=n(g==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[118]=g,e[119]=n,e[120]=Ie):Ie=e[120];let De;e[121]!==le||e[122]!==h||e[123]!==Ie?(De=s.jsx(q,{size:"sm",onClick:le,disabled:h,children:Ie}),e[121]=le,e[122]=h,e[123]=Ie,e[124]=De):De=e[124];let Je;e[125]!==Ue||e[126]!==De?(Je=s.jsxs(ts,{children:[Ue,De]}),e[125]=Ue,e[126]=De,e[127]=Je):Je=e[127];let tt;e[128]!==Ne||e[129]!==Je?(tt=s.jsxs(zt,{className:"max-w-md",children:[Ne,Je]}),e[128]=Ne,e[129]=Je,e[130]=tt):tt=e[130];let mt;e[131]!==Ke||e[132]!==ge||e[133]!==tt?(mt=s.jsx(Kt,{open:Ke,onOpenChange:ge,children:tt}),e[131]=Ke,e[132]=ge,e[133]=tt,e[134]=mt):mt=e[134];const ht=r!==null;let ft;e[135]===Symbol.for("react.memo_cache_sentinel")?(ft=Le=>!Le&&l(null),e[135]=ft):ft=e[135];let xt;e[136]!==n?(xt=n("settings.commands.sidebar.renameDialog.title"),e[136]=n,e[137]=xt):xt=e[137];let Qe;e[138]!==xt?(Qe=s.jsx(_t,{children:xt}),e[138]=xt,e[139]=Qe):Qe=e[139];const lt=r?.name??"";let Ye;e[140]!==n||e[141]!==lt?(Ye=n("settings.commands.sidebar.renameDialog.description",{name:lt}),e[140]=n,e[141]=lt,e[142]=Ye):Ye=e[142];let at;e[143]!==Ye?(at=s.jsx(Vt,{children:Ye}),e[143]=Ye,e[144]=at):at=e[144];let dt;e[145]!==Qe||e[146]!==at?(dt=s.jsxs(Bt,{children:[Qe,at]}),e[145]=Qe,e[146]=at,e[147]=dt):dt=e[147];let _e;e[148]===Symbol.for("react.memo_cache_sentinel")?(_e=Le=>m(Le.target.value),e[148]=_e):_e=e[148];let nt;e[149]!==n?(nt=n("settings.commands.sidebar.renameDialog.placeholder"),e[149]=n,e[150]=nt):nt=e[150];let te;e[151]!==se?(te=Le=>{Le.key==="Enter"&&se()},e[151]=se,e[152]=te):te=e[152];let ue;e[153]!==u||e[154]!==nt||e[155]!==te?(ue=s.jsx(Ve,{value:u,onChange:_e,placeholder:nt,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:te}),e[153]=u,e[154]=nt,e[155]=te,e[156]=ue):ue=e[156];let he;e[157]===Symbol.for("react.memo_cache_sentinel")?(he=()=>l(null),e[157]=he):he=e[157];let ye;e[158]!==n?(ye=n("settings.common.actions.cancel"),e[158]=n,e[159]=ye):ye=e[159];let qe;e[160]!==ye?(qe=s.jsx(q,{size:"sm",variant:"ghost",onClick:he,children:ye}),e[160]=ye,e[161]=qe):qe=e[161];let Ze;e[162]!==n?(Ze=n("settings.common.actions.rename"),e[162]=n,e[163]=Ze):Ze=e[163];let pt;e[164]!==se||e[165]!==Ze?(pt=s.jsx(q,{size:"sm",onClick:se,children:Ze}),e[164]=se,e[165]=Ze,e[166]=pt):pt=e[166];let vt;e[167]!==qe||e[168]!==pt?(vt=s.jsxs(ts,{children:[qe,pt]}),e[167]=qe,e[168]=pt,e[169]=vt):vt=e[169];let bt;e[170]!==dt||e[171]!==ue||e[172]!==vt?(bt=s.jsxs(zt,{children:[dt,ue,vt]}),e[170]=dt,e[171]=ue,e[172]=vt,e[173]=bt):bt=e[173];let wt;e[174]!==ht||e[175]!==bt?(wt=s.jsx(Kt,{open:ht,onOpenChange:ft,children:bt}),e[174]=ht,e[175]=bt,e[176]=wt):wt=e[176];let Et;return e[177]!==ke||e[178]!==Ae||e[179]!==Te||e[180]!==mt||e[181]!==wt?(Et=s.jsxs("div",{className:ke,children:[Ae,Te,mt,wt]}),e[177]=ke,e[178]=Ae,e[179]=Te,e[180]=mt,e[181]=wt,e[182]=Et):Et=e[182],Et},vc=t=>{const e=$e.c(47),{command:a,isSelected:n,onSelect:o,onDelete:i,onReset:r,onRename:l,onDuplicate:u,isMenuOpen:m,onMenuOpenChange:d}=t,{t:f}=ze();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=ul(),e[0]=g):g=e[0];const p=g,[h,w]=c.useState(!1);let b;e[1]!==i||e[2]!==u||e[3]!==l||e[4]!==r||e[5]!==f?(b=B=>s.jsxs(s.Fragment,{children:[l&&s.jsxs(B,{onClick:_=>{_.stopPropagation(),l()},children:[s.jsx(J,{name:"edit",className:"h-4 w-4 me-px"}),f("settings.common.actions.rename")]}),s.jsxs(B,{onClick:_=>{_.stopPropagation(),u()},children:[s.jsx(J,{name:"file-copy",className:"h-4 w-4 me-px"}),f("settings.common.actions.duplicate")]}),r&&s.jsxs(B,{onClick:_=>{_.stopPropagation(),r()},children:[s.jsx(J,{name:"restart",className:"h-4 w-4 me-px"}),f("settings.common.actions.reset")]}),i&&s.jsxs(B,{onClick:_=>{_.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[s.jsx(J,{name:"delete-bin",className:"h-4 w-4 me-px"}),f("settings.common.actions.delete")]})]}),e[1]=i,e[2]=u,e[3]=l,e[4]=r,e[5]=f,e[6]=b):b=e[6];const k=b,v=n?"bg-interactive-selection":"hover:bg-interactive-hover";let S;e[7]!==v?(S=Me("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",v),e[7]=v,e[8]=S):S=e[8];let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=p?void 0:B=>{B.preventDefault(),w(!0)},e[9]=y):y=e[9];let N;e[10]!==S?(N=s.jsx("div",{className:S,onContextMenu:y}),e[10]=S,e[11]=N):N=e[11];let x;e[12]!==a.name?(x=s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",a.name]}),e[12]=a.name,e[13]=x):x=e[13];let I;e[14]!==a||e[15]!==f?(I=(a.scope||Ba(a))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:Ba(a)?f("settings.agents.sidebar.badge.system"):a.scope}),e[14]=a,e[15]=f,e[16]=I):I=e[16];let j;e[17]!==x||e[18]!==I?(j=s.jsxs("div",{className:"flex items-center gap-2",children:[x,I]}),e[17]=x,e[18]=I,e[19]=j):j=e[19];let D;e[20]!==a.description?(D=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[20]=a.description,e[21]=D):D=e[21];let C;e[22]!==o||e[23]!==D||e[24]!==j?(C=s.jsxs("button",{onClick:o,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:[j,D]}),e[22]=o,e[23]=D,e[24]=j,e[25]=C):C=e[25];let P;e[26]!==d?(P=B=>{B&&w(!1),d(B)},e[26]=d,e[27]=P):P=e[27];let A;e[28]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(pa,{asChild:!0,children:s.jsx(q,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(J,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=A):A=e[28];let R;e[29]!==k?(R=s.jsx(ma,{align:"end",className:"w-fit min-w-20",children:k(Bn)}),e[29]=k,e[30]=R):R=e[30];let K;e[31]!==m||e[32]!==P||e[33]!==R?(K=s.jsxs(ga,{open:m,onOpenChange:P,children:[A,R]}),e[31]=m,e[32]=P,e[33]=R,e[34]=K):K=e[34];let F;e[35]!==C||e[36]!==K?(F=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[C,K]}),e[35]=C,e[36]=K,e[37]=F):F=e[37];let T;e[38]!==F||e[39]!==N?(T=s.jsx(Mi,{render:N,children:F}),e[38]=F,e[39]=N,e[40]=T):T=e[40];let O;e[41]!==k?(O=s.jsx(Ti,{className:"w-fit min-w-20",children:k(Ei)}),e[41]=k,e[42]=O):O=e[42];let E;return e[43]!==h||e[44]!==T||e[45]!==O?(E=s.jsxs(Di,{open:h,onOpenChange:w,children:[T,O]}),e[43]=h,e[44]=T,e[45]=O,e[46]=E):E=e[46],E};function Wh(t){return{selectedCommandName:t.selectedCommandName,setSelectedCommand:t.setSelectedCommand,setCommandDraft:t.setCommandDraft,createCommand:t.createCommand,deleteCommand:t.deleteCommand,loadCommands:t.loadCommands}}function Gh(t){return t.loadSkills}function Jh(t){return t.name}function Qh(t){return!Ba(t)}function Yh(t,e){return t.name.localeCompare(e.name)}function Zh(t,e){return t.name.localeCompare(e.name)}const Xh=()=>{const{t}=ze(),{selectedCommandName:e,getCommandByName:a,createCommand:n,updateCommand:o,commandDraft:i,setCommandDraft:r,setSelectedCommand:l}=qa(Ms($=>({selectedCommandName:$.selectedCommandName,getCommandByName:$.getCommandByName,createCommand:$.createCommand,updateCommand:$.updateCommand,commandDraft:$.commandDraft,setCommandDraft:$.setCommandDraft,setSelectedCommand:$.setSelectedCommand}))),u=Us(),m=qa($=>$d($,u)),d=e?a(e,u):null,f=!!(i&&i.name===e&&!d),[g,p]=c.useState(""),[h,w]=c.useState("user"),[b,k]=c.useState(""),[v,S]=c.useState(""),[y,N]=c.useState(""),[x,I]=c.useState(""),[j,D]=c.useState(!1),[C,P]=c.useState(""),[A,R]=c.useState(!1),K=c.useRef(null),F=JSON.stringify([u,e]),T=c.useRef(null),O=c.useRef(null);c.useEffect(()=>{const $=T.current===F;if(T.current=F,f&&i){const V=i.name||"",G=i.scope||"user",ee=i.description||"",ae=i.agent||"",X=Si(i.model),Q=X?`${X.providerID}/${X.modelID}`:"",le=X?.variant||"",Z=i.subagent===!0,fe=i.template||"";p(V),w(G),k(ee),S(ae),N(Q),I(le),D(Z),P(fe),K.current={draftName:V,draftScope:G,description:ee,agent:ae,model:Q,variant:le,subagent:Z,template:fe}}else if(d){const V=d.description||"",G=d.agent||"",ee=Si(d.model),ae=ee?`${ee.providerID}/${ee.modelID}`:"",X=ee?.variant||"",Q=d.subagent===!0,le=d.template||"",Z=O.current,fe=[K.current,Z?.identity===F?Z.form:null];if($&&fe.some(Y=>Y&&Y.description===V&&Y.agent===G&&Y.model===ae&&Y.variant===X&&Y.subagent===Q&&Y.template===le))return;k(V),S(G),N(ae),I(X),D(Q),P(le),K.current={draftName:"",draftScope:"user",description:V,agent:G,model:ae,variant:X,subagent:Q,template:le}}},[d,f,e,m,i,F]);const E=c.useCallback($=>{const V=v.trim(),G=Tn(y.trim()),ee=G?nu({providerID:G.providerId,modelID:G.modelId,variant:x.trim()||void 0}):null;return{name:$,description:b.trim()||void 0,agent:V===""?null:V,model:ee,subagent:j,template:C.trim(),scope:f?h:void 0}},[v,b,h,f,y,j,C,x]),B=c.useCallback(async()=>{const $=K.current,V=e?.trim();if(f||!$||!V||b.trim()===$.description.trim()&&v.trim()===$.agent.trim()&&y.trim()===$.model.trim()&&x.trim()===$.variant.trim()&&j===$.subagent&&C.trim()===$.template.trim())return Es;if(!C.trim())return gs(t("settings.commands.page.toast.templateRequired"));const ee=E(V),ae=Si(ee.model),X={identity:F,form:{...$,description:ee.description||"",agent:ee.agent||"",model:ae?`${ae.providerID}/${ae.modelID}`:"",variant:ae?.variant||"",subagent:ee.subagent===!0,template:ee.template||""}};O.current=X;try{return await o(V,ee,u)?(T.current===F&&(K.current=X.form),bn):gs(t("settings.commands.page.toast.updateFailed"))}finally{O.current===X&&(O.current=null)}},[v,E,b,F,f,y,e,u,j,t,C,o,x]),_=Ya(B),{requestSave:H}=_,ne=async()=>{const $=g.trim().replace(/\s+/g,"-");if(!$){W.error(t("settings.commands.sidebar.toast.commandNameRequired"));return}if(!C.trim()){W.error(t("settings.commands.page.toast.templateRequired"));return}if(m.some(V=>V.name===$)){W.error(t("settings.commands.sidebar.toast.commandExists"));return}R(!0);try{await n(E($),u)?(r(null),W.success(t("settings.commands.page.toast.created"))):W.error(t("settings.commands.page.toast.createFailed"))}catch(V){console.error("Error creating command:",V),W.error(t("settings.commands.page.toast.saveUnexpectedError"))}finally{R(!1)}},z=()=>{r(null),l(null)};return e?s.jsxs(Yt,{title:f?t("settings.commands.page.title.new"):`/${e}`,description:t(f?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit"),onBlurCapture:_.onBlurCapture,children:[!f&&d&&s.jsx(Al,{legacy:d.legacy===!0,path:d.path}),s.jsxs(He,{title:t("settings.commands.page.section.identity"),divider:!1,contentClassName:"space-y-0",children:[f&&s.jsxs(kt,{settingsItem:"commands.name",label:t("settings.commands.page.field.commandName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground me-1",children:"/"}),s.jsx(Ve,{value:g,onChange:$=>p($.target.value),placeholder:t("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Tt,{value:h,onValueChange:$=>w($),children:[s.jsx(Pt,{className:"w-fit min-w-[100px]",children:s.jsx(Ut,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(At,{align:"end",children:[s.jsx(ot,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(ot,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsxs("div",{className:"py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.common.field.description")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(ws,{value:b,onChange:$=>k($.target.value),placeholder:t("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]}),s.jsxs(He,{title:t("settings.commands.page.section.executionContext"),contentClassName:"space-y-0",children:[s.jsx(kt,{settingsItem:"commands.agent",label:t("settings.commands.page.field.overrideAgent"),children:s.jsx(gl,{agentName:v,onChange:$=>{S($),H()},className:sn})}),s.jsx(kt,{settingsItem:"commands.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(oa,{providerId:Tn(y)?.providerId??"",modelId:Tn(y)?.modelId??"",onChange:($,V)=>{N($&&V?`${$}/${V}`:""),H()},className:sn})}),s.jsx(kt,{settingsItem:"commands.variant",label:t("settings.agents.page.field.variant"),info:t("settings.agents.page.field.variantTooltip"),children:s.jsx(Ve,{value:x,onChange:$=>I($.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!y&&!x,className:"h-8 w-40 rounded-md px-3"})}),s.jsx(kt,{settingsItem:"commands.subagent",label:t("settings.commands.page.field.subagent"),info:t("settings.commands.page.field.subagentTooltip"),children:s.jsx(ra,{checked:j,onCheckedChange:$=>{D($),H()},"aria-label":t("settings.commands.page.field.subagent")})})]}),s.jsxs(He,{title:t("settings.commands.page.section.template"),settingsItem:"commands.template",children:[s.jsx(ws,{value:C,onChange:$=>P($.target.value),placeholder:t("settings.commands.page.field.templatePlaceholder"),rows:12,className:"w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),s.jsxs("p",{className:"mt-2 typography-meta text-muted-foreground",children:[s.jsx("code",{className:"text-foreground",children:"$ARGUMENTS"})," ",t("settings.commands.page.templateHint.userInput")," ·"," ",s.jsx("code",{className:"text-foreground",children:"!`cmd`"})," ",t("settings.commands.page.templateHint.shellOutput")," ·"," ",s.jsx("code",{className:"text-foreground",children:"@file"})," ",t("settings.commands.page.templateHint.fileContents")]}),f&&s.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[s.jsx(q,{onClick:()=>{ne()},disabled:A||!g.trim()||!C.trim(),size:"xs",className:"!font-normal",children:t(A?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(q,{variant:"ghost",onClick:z,disabled:A,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(J,{name:"terminal-box",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.commands.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.commands.page.empty.description")})]})})},xu=t=>t.toLowerCase().replace(/[^a-z0-9_-]/g,"-"),eb=t=>xu(t.trim()).replace(/^[-_]+|[-_]+$/g,""),So={oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:""},tb=t=>t===!1?{...So,oauthEnabled:!1}:t?{oauthEnabled:!0,oauthClientId:t.client_id??"",oauthClientSecret:t.client_secret??"",oauthScope:t.scope??"",oauthRedirectUri:t.redirect_uri??"",oauthCallbackPort:t.callback_port===void 0?"":String(t.callback_port)}:So;function qs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function mi(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function pn(t,e){return e!==void 0?{ok:!1,error:t,parsed:e}:{ok:!1,error:t}}function Qi(t,e,a){const n=nb(a),o=typeof a.url=="string"?a.url.trim():"",i=yc(a,"env","environment"),r=yc(a,"headers"),l=qs(a.oauth)?a.oauth:null,u=pi(l,"client_id","clientId"),m=pi(l,"client_secret","clientSecret"),d=pi(l,"scope"),f=pi(l,"redirect_uri","redirectUri"),g=sb(l,"callback_port","callbackPort"),p=pi(l,"auth_server_metadata_url","authServerMetadataUrl"),h=a.oauth===!1||a.oauth===null||a.oauth===void 0?!1:!!l&&!!(u||m||d||f||g||p),w=ab(a);return{ok:!0,name:t,type:e,command:n,url:o,environment:i,headers:r,oauthEnabled:h,oauthClientId:u,oauthClientSecret:m,oauthScope:d,oauthRedirectUri:f,oauthCallbackPort:g,oauthAuthServerMetadataUrl:p,timeoutStartup:w.startup,timeoutCatalog:w.catalog,timeoutExecution:w.execution,codemode:a.codemode===!0?"on":a.codemode===!1?"off":"default",disabled:ib(a),protocol:_r.find(b=>b===a.protocol)??"legacy"}}function pi(t,...e){if(!t)return"";for(const a of e){const n=t[a];if(typeof n=="string"&&n.trim())return n.trim()}return""}function sb(t,...e){if(!t)return"";for(const a of e){const n=yi(t[a]);if(n)return n}return""}function yi(t){if(typeof t=="number"&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t=="string"&&t.trim()){const e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return""}function nb(t){const e=t.command,a=t.args;if(mi(e)&&mi(a))return[...e,...a];if(mi(e))return e;if(typeof e=="string"&&e.trim()){const n=e.trim().split(/\s+/);return mi(a)?[...n,...a]:n}return mi(a)?a:[]}function yc(t,...e){for(const a of e){const n=t[a];if(!qs(n))continue;const o=Object.entries(n).filter(([i,r])=>i&&typeof r=="string");if(o.length>0)return o.map(([i,r])=>({key:i,value:String(r)}))}return[]}function ab(t){return qs(t.timeout)?{startup:yi(t.timeout.startup),catalog:yi(t.timeout.catalog),execution:yi(t.timeout.execution)}:{startup:"",catalog:"",execution:yi(t.timeout)}}function ib(t){return t.disabled===!0?!0:t.disabled===!1?!1:"enabled"in t?!t.enabled:!1}function ob(t){const e=t.mcpServers;if(qs(e)){const n=Object.keys(e);if(n.length===1){const o=n[0],i=e[o];if(qs(i))return{name:o,entry:i}}if(n.length>1)return null}const a=Object.keys(t).filter(n=>{const o=t[n];return n!=="mcpServers"&&qs(o)});if(a.length===1){const n=a[0],o=t[n];if(vu(o))return{name:n,entry:o}}return null}function vu(t){return t.type==="local"||t.type==="remote"||Array.isArray(t.command)||typeof t.url=="string"||Array.isArray(t.args)}function rb(t,e){let a;try{const u=t.trim();if(!u)return pn("No JSON content provided");a=JSON.parse(u)}catch(u){return pn(u instanceof Error?`Invalid JSON: ${u.message}`:"Invalid JSON")}if(!qs(a))return pn("Expected a JSON object, not an array or primitive");const n=a,o=n.mcpServers;if(qs(o)){const u=Object.keys(o);if(u.length===0)return pn("mcpServers object is empty",a);if(u.length>1)return pn("Paste one server at a time. Found "+u.length+" servers in mcpServers",a);const m=u[0],d=o[m];return qs(d)?Qi(m,Yi(d),d):pn("Server entry is not a valid object",a)}const i=n.mcp,r=qs(i)&&qs(i.servers)?i.servers:i;if(qs(r)){const u=Object.keys(r);if(u.length===0)return pn("mcp object is empty",a);if(u.length>1)return pn("Paste one server at a time. Found "+u.length+" servers in mcp",a);const m=u[0],d=r[m];return qs(d)?Qi(m,Yi(d),d):pn("Server entry in mcp is not a valid object",a)}const l=ob(n);if(l)return Qi(l.name,Yi(l.entry),l.entry);if(vu(n)){const u=Yi(n),m=typeof n.name=="string"&&n.name.trim()?n.name.trim():e?.fallbackName;return Qi(m,u,n)}return pn("No recognizable MCP server configuration found in JSON",a)}function Yi(t){return t.type==="remote"?"remote":t.type==="local"?"local":typeof t.url=="string"&&t.url.trim()?"remote":(Array.isArray(t.command)||typeof t.command=="string"||Array.isArray(t.args),"local")}function lb(t,e,a){const n=a?.isNewServer??!1,o=t.name?eb(t.name):void 0,i=n&&o?o:e.name??"";return{...e,name:i,type:t.type,command:t.type==="local"?t.command:[],url:t.type==="remote"?t.url:"",environment:t.environment,headers:t.type==="remote"?t.headers:[],oauthEnabled:t.type==="remote"?t.oauthEnabled:!1,oauthClientId:t.type==="remote"?t.oauthClientId:"",oauthClientSecret:t.type==="remote"?t.oauthClientSecret:"",oauthScope:t.type==="remote"?t.oauthScope:"",oauthRedirectUri:t.type==="remote"?t.oauthRedirectUri:"",oauthCallbackPort:t.type==="remote"?t.oauthCallbackPort:"",oauthAuthServerMetadataUrl:t.type==="remote"?t.oauthAuthServerMetadataUrl:"",timeoutStartup:t.type==="local"?t.timeoutStartup:"",timeoutCatalog:t.timeoutCatalog,timeoutExecution:t.timeoutExecution,codemode:t.codemode,disabled:t.disabled,protocol:t.protocol}}const cb=(t,e)=>!!e&&t!=="claude-code",db=/[A-Z0-9]{4}-[A-Z0-9]{4,5}/,ub=t=>db.exec(t)?.[0]??void 0,Za=t=>t.type!=="external",ta=t=>t.title??t.key,mb=(t,e)=>{if(e===void 0)return!1;const a=String(e),n=String(t.value);return t.op==="eq"?a===n:a!==n},pb=(t,e)=>Za(t)?(t.when??[]).every(a=>mb(a,e[a.key])):!0,Tl=(t,e)=>{const a={},n=[];for(const o of t){if(!pb(o,a))continue;n.push(o);const i=e[o.key];Za(o)&&i!==void 0&&(a[o.key]=i)}return n},yu=t=>{const e={};for(const a of t)switch(a.type){case"external":break;case"boolean":e[a.key]=a.default??!1;break;case"number":case"integer":typeof a.default=="number"&&(e[a.key]=a.default);break;case"multiselect":e[a.key]=a.default??[];break;case"string":e[a.key]=a.default??a.options?.[0]?.value??"";break}return e},ju=t=>t===void 0?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:!1,ku=(t,e)=>Tl(t,e).find(a=>Za(a)&&a.required===!0&&ju(e[a.key]))??null,wu=(t,e)=>{const a={};for(const n of Tl(t,e)){if(!Za(n))continue;const o=e[n.key];ju(o)||o===void 0||(a[n.key]=typeof o=="string"?o.trim():o)}return a},jc=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),kc=t=>typeof t=="string"&&t.length>0?t:void 0,gb=(t,e,a)=>{const n=jc(t)?t:{},o=jc(n.data)?n.data:{};switch(n.name){case"IntegrationOauthAttemptMissing":return e("settings.providers.page.auth.oauth.error.sessionExpired");case"IntegrationOauthCodeMissing":return e("settings.providers.page.auth.oauth.error.codeRequired");case"IntegrationOauthFailed":return e("settings.providers.page.auth.oauth.error.declined");case"IntegrationValidationFailed":return kc(o.message)??e("settings.providers.page.auth.oauth.error.invalidInput");default:return kc(n.message)??e(a)}},Zi="\0typed",Su=t=>{const e=$e.c(12),{fields:a,values:n,onChange:o}=t,{t:i}=ze();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,e[0]=r):r=e[0];const[l,u]=c.useState(r);let m;e[1]!==o||e[2]!==i||e[3]!==l||e[4]!==n?(m=p=>{if(p.type==="external")return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:ta(p)}),s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{ks(p.url)},children:i("settings.providers.page.actions.open")})]},p.key);const h=n[p.key],w=typeof h=="string"?h:"",b=N=>o(p.key,N),k=p.type==="string"||p.type==="multiselect"?p.options??[]:[],v=p.type==="string"&&p.custom===!0,S=v&&l.has(p.key),y=N=>u(x=>{const I=new Set(x);return N?I.add(p.key):I.delete(p.key),I});return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:ta(p)}),p.description&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:p.description}),k.length>0?s.jsxs(s.Fragment,{children:[s.jsxs(Tt,{value:S?Zi:w,onValueChange:N=>{if(N===Zi){y(!0),b("");return}y(!1),b(N)},children:[s.jsx(Pt,{className:nn,children:s.jsx(Ut,{children:N=>N===Zi?i("settings.providers.page.auth.field.other"):k.find(x=>x.value===N)?.label??null})}),s.jsxs(At,{children:[k.map(fb),v?s.jsx(ot,{value:Zi,children:i("settings.providers.page.auth.field.other")}):null]})]}),S?s.jsx(Ve,{value:w,onChange:N=>b(N.target.value),placeholder:p.placeholder??i("settings.providers.page.auth.field.otherPlaceholder"),"aria-label":ta(p),className:"max-w-[24rem] text-xs",autoFocus:!0}):null]}):p.type==="boolean"?s.jsx("input",{type:"checkbox",checked:h===!0,onChange:N=>b(N.target.checked),"aria-label":ta(p)}):s.jsx(Ve,{value:w,onChange:N=>b(N.target.value),placeholder:p.type==="string"?p.placeholder:void 0,"aria-label":ta(p),className:"max-w-[24rem] text-xs"})]},p.key)},e[1]=o,e[2]=i,e[3]=l,e[4]=n,e[5]=m):m=e[5];const d=m;let f;e[6]!==a||e[7]!==d||e[8]!==n?(f=Tl(a,n).map(d),e[6]=a,e[7]=d,e[8]=n,e[9]=f):f=e[9];let g;return e[10]!==f?(g=s.jsx(s.Fragment,{children:f}),e[10]=f,e[11]=g):g=e[11],g};function fb(t){return s.jsx(ot,{value:t.value,children:t.description?`${t.label} · ${t.description}`:t.label},t.value)}const vr={phase:"idle"},hb=1500,No=({integrationId:t,methods:e,onConnected:a,directory:n,className:o})=>{const{t:i}=ze(),r=c.useCallback(()=>n?Ks.getScopedSdkClient(n):Ks.getSdkClient(),[n]),[l,u]=c.useState(vr),[m,d]=c.useState({}),[f,g]=c.useState(""),p=c.useRef(null),h=c.useCallback(A=>{p.current=null,r().integration.oauth.cancel({integrationID:t,attemptID:A}).catch(()=>{})},[t,r]);c.useEffect(()=>()=>{const A=p.current;A&&h(A)},[h]);const w=l.phase==="idle"?null:l.methodID,b=l.phase==="connecting"||l.phase==="waiting"||l.phase==="awaitingCode"&&l.submitting,k=async(A,R,K)=>{const F=await $a(A);if(F.ok){W.success(i(R));return}console.error("Failed to copy OAuth value:",F.error),W.error(i(K))},v=async(A="settings.providers.page.toast.oauthCompleted")=>{p.current=null,u(vr),W.success(i(A)),await a()},S=(A,R,K)=>{p.current=null,console.error("OAuth flow failed:",R),u({phase:"failed",methodID:A,message:gb(R,i,K)})},y=async(A,R)=>{const K=r();for(;p.current===R;){if(await new Promise(F=>setTimeout(F,hb)),p.current!==R)return;try{const{data:F}=await K.integration.oauth.status({integrationID:t,attemptID:R});if(p.current!==R)return;if(F.status==="complete"){await v();return}if(F.status==="failed"){u({phase:"failed",methodID:A,message:F.message}),p.current=null;return}}catch(F){if(p.current!==R)return;S(A,F,"settings.providers.page.toast.oauthCompleteFailed");return}}},N=async(A,R)=>{u({phase:"connecting",methodID:A});try{await r().integration.connect.external({integrationID:t,methodID:A,answer:Object.keys(R).length>0?R:void 0})}catch(K){S(A,K,"settings.providers.page.toast.externalConnectFailed");return}await v("settings.providers.page.toast.externalConnected")},x=async(A,R)=>{if(A.type==="external"){await N(A.id,R);return}u({phase:"connecting",methodID:A.id});let K;try{const{data:F}=await r().integration.oauth.connect({integrationID:t,methodID:A.id,...Object.keys(R).length>0?{answer:R}:{}});K={attemptID:F.attemptID,mode:F.mode,url:F.url,instructions:F.instructions}}catch(F){S(A.id,F,"settings.providers.page.toast.oauthStartFailed");return}if(p.current=K.attemptID,cb(t,K.url)&&ks(K.url),K.mode==="code"){g(""),u({phase:"awaitingCode",methodID:A.id,attempt:K,submitting:!1});return}u({phase:"waiting",methodID:A.id,attempt:K}),await y(A.id,K.attemptID)},I=A=>{const R=(A.form??[]).filter(Za);if(R.length===0){x(A,{});return}d(yu(R)),u({phase:"prompting",methodID:A.id,fields:R,error:null})},j=A=>{if(l.phase!=="prompting")return;const R=ku(l.fields,m);if(R){u({...l,error:i("settings.providers.page.auth.oauth.promptRequired",{field:ta(R)})});return}x(A,wu(l.fields,m))},D=async()=>{if(l.phase!=="awaitingCode")return;const A=f.trim();if(!A)return;const{methodID:R,attempt:K}=l;u({...l,submitting:!0});try{await r().integration.oauth.complete({integrationID:t,attemptID:K.attemptID,code:A}),await v()}catch(F){S(R,F,"settings.providers.page.toast.oauthCompleteFailed")}},C=()=>{(l.phase==="waiting"||l.phase==="awaitingCode")&&h(l.attempt.attemptID),u(vr)},P=A=>{const R=ub(A.instructions);return s.jsxs(s.Fragment,{children:[A.instructions&&s.jsx("p",{className:"typography-meta text-[var(--status-info-text)] bg-[var(--status-info-background)] px-2 py-1.5 rounded",children:A.instructions}),R&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{value:R,readOnly:!0,"aria-label":i("settings.providers.page.auth.oauth.deviceCodeLabel"),className:"font-mono text-center tracking-widest"}),s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>{k(R,"settings.providers.page.toast.deviceCodeCopied","settings.providers.page.toast.deviceCodeCopyFailed")},children:i("settings.providers.page.actions.copyCode")})]}),A.url&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{value:A.url,readOnly:!0,"aria-label":i("settings.providers.page.auth.oauth.linkLabel"),className:"text-xs text-muted-foreground"}),s.jsxs("div",{className:"flex gap-1 shrink-0",children:[s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{ks(A.url)},children:i("settings.providers.page.actions.open")}),s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{k(A.url,"settings.providers.page.toast.oauthLinkCopied","settings.providers.page.toast.oauthLinkCopyFailed")},children:i("settings.providers.page.actions.copy")})]})]})]})};return s.jsx("div",{className:Me("space-y-4",o),children:e.map(A=>{const R=w===A.id;return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:A.label}),s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>I(A),disabled:b,children:i("settings.providers.page.actions.connect")})]}),R&&l.phase==="prompting"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(Su,{fields:l.fields,values:m,onChange:(K,F)=>d(T=>({...T,[K]:F}))}),l.error&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l.error}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{size:"xs",className:"!font-normal",onClick:()=>j(A),children:i("settings.providers.page.actions.continue")}),s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal",onClick:C,children:i("settings.providers.page.actions.cancel")})]})]}),R&&l.phase==="connecting"&&s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx(J,{name:"loader",className:"h-3.5 w-3.5 animate-spin"}),A.type==="external"?i("settings.providers.page.auth.external.connecting"):i("settings.providers.page.auth.oauth.starting")]}),R&&l.phase==="waiting"&&s.jsxs("div",{className:"space-y-3",children:[P(l.attempt),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx(J,{name:"loader",className:"h-3.5 w-3.5 animate-spin"}),i("settings.providers.page.auth.oauth.waiting")]}),s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:C,children:i("settings.providers.page.actions.cancel")})]}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("settings.providers.page.auth.oauth.waitingHint")})]}),R&&l.phase==="awaitingCode"&&s.jsxs("div",{className:"space-y-3",children:[P(l.attempt),s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("settings.providers.page.auth.oauth.codeHint")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{value:f,onChange:K=>g(K.target.value),placeholder:i("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs",disabled:l.submitting}),s.jsx(q,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{D()},disabled:l.submitting||f.trim().length===0,children:l.submitting?i("settings.providers.page.actions.saving"):i("settings.providers.page.actions.complete")}),s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:C,disabled:l.submitting,children:i("settings.providers.page.actions.cancel")})]})]}),R&&l.phase==="failed"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l.message}),s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>I(A),children:i("settings.providers.page.actions.tryAgain")})]})]},A.id)})})},bb=(t,e)=>t.find(a=>a.id.startsWith("mcp_")&&a.metadata?.source==="mcp"&&a.name===e),xb=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),vb=({serverName:t,directory:e,onConnected:a})=>{const[n,o]=c.useState(null);c.useEffect(()=>{let r=!1;o(null);const l=e?Ks.getScopedSdkClient(e):Ks.getSdkClient();return(async()=>{try{const{data:m}=await l.integration.list();r||o(bb(m,t)??null)}catch(m){console.error("Failed to load MCP integrations:",m)}})(),()=>{r=!0}},[e,t]);const i=xb(n??void 0);return!n||i.length===0?null:s.jsx(No,{integrationId:n.id,methods:i,directory:e,onConnected:a},n.id)},wc=[],El=t=>{const e=$e.c(5),[a,n]=c.useState(wc);let o,i;e[0]!==t?(o=()=>{let l=!1;return n(wc),Ks.getIntegrationPolicies(t).then(u=>{l||n(u)}).catch(yb),()=>{l=!0}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),c.useEffect(o,i);let r;return e[3]!==a?(r=l=>kg(a,l),e[3]=a,e[4]=r):r=e[4],r};function yb(t){console.warn("[settings] could not read OpenCode integration policies:",t instanceof Error?t.message:String(t))}const jb=t=>{const e="new-mcp-server";let a=e,n=1;for(;t.some(o=>o.name===a);)a=`${e}-${n}`,n+=1;return a},kb=t=>{const e=$e.c(13),{status:a,enabled:n,blocked:o}=t,{t:i}=ze();if(o){let m;e[0]!==i?(m=i("settings.mcp.grid.status.blockedByPolicy"),e[0]=i,e[1]=m):m=e[1];let d;return e[2]!==m?(d=s.jsx(tn,{tone:"warning",children:m}),e[2]=m,e[3]=d):d=e[3],d}if(!n){let m;e[4]!==i?(m=i("settings.mcp.grid.status.disabled"),e[4]=i,e[5]=m):m=e[5];let d;return e[6]!==m?(d=s.jsx(tn,{tone:"neutral",children:m}),e[6]=m,e[7]=d):d=e[7],d}let r;e[8]!==a||e[9]!==i?(r=a==="connected"?{tone:"success",label:i("settings.mcp.page.status.label.connected")}:a==="failed"?{tone:"error",label:i("settings.mcp.page.status.label.failed")}:a==="needs_auth"?{tone:"warning",label:i("settings.mcp.page.status.label.needsAuth")}:a==="pending"?{tone:"neutral",label:i("settings.mcp.grid.status.pending")}:null,e[8]=a,e[9]=i,e[10]=r):r=e[10];const l=r;let u;return e[11]!==l?(u=l?s.jsx(tn,{tone:l.tone,children:l.label}):null,e[11]=l,e[12]=u):u=e[12],u},wb=()=>{const t=$e.c(132),{t:e}=ze(),a=Us(),{setSelectedMcp:n,setMcpDraft:o,loadMcpConfigs:i,deleteMcp:r}=An(Ms(Sb)),[l,u]=c.useState(null),[m,d]=c.useState(!1);let f;t[0]!==a?(f=Te=>ml(Te,a),t[0]=a,t[1]=f):f=t[1];const g=An(f);let p;t[2]!==a?(p=Te=>Te.getStatusForDirectory(a),t[2]=a,t[3]=p):p=t[3];const h=dn(p),w=El(a),b=dn(Nb),k=dn(Cb),[v,S]=c.useState(!1),[y,N]=c.useState("");let x,I;t[4]!==i||t[5]!==a?(x=()=>{i({directory:a})},I=[i,a],t[4]=i,t[5]=a,t[6]=x,t[7]=I):(x=t[6],I=t[7]),c.useEffect(x,I);let j;t[8]!==k||t[9]!==v||t[10]!==b||t[11]!==a?(j=()=>{if(v)return;S(!0);const Te=new Promise(Ib);Promise.all([b({directory:a,silent:!0}),Te]).then(()=>{const Ke=k(a);Ke&&W.error(Ke)}).finally(()=>S(!1))},t[8]=k,t[9]=v,t[10]=b,t[11]=a,t[12]=j):j=t[12];const D=j;let C;t[13]!==g||t[14]!==o||t[15]!==n?(C=()=>{const Te=jb(g),Ke={name:Te,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],...So,oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1};o(Ke),n(Te)},t[13]=g,t[14]=o,t[15]=n,t[16]=C):C=t[16];const P=C;let A;t[17]!==r||t[18]!==l||t[19]!==a||t[20]!==e?(A=async()=>{if(!l)return;const Te=l;d(!0);const Ke=await r(Te,a);Ke.ok?(Ke.reloadFailed?W.warning(Ke.message||e("settings.mcp.page.toast.serverDeletedReloadFailed",{name:Te}),{description:Ke.warning||e("settings.mcp.page.toast.refreshListIfStale")}):W.success(Ke.message||e("settings.mcp.page.toast.serverDeleted",{name:Te})),u(null)):W.error(e("settings.mcp.page.toast.deleteFailed")),d(!1)},t[17]=r,t[18]=l,t[19]=a,t[20]=e,t[21]=A):A=t[21];const R=A;let K,F,T,O,E,B,_,H,ne;if(t[22]!==P||t[23]!==D||t[24]!==w||t[25]!==v||t[26]!==h||t[27]!==y||t[28]!==g||t[29]!==o||t[30]!==n||t[31]!==e){const Te=_n([...g],y,Pb);let Ke;t[41]!==y?(Ke=y.trim(),t[41]=y,t[42]=Ke):Ke=t[42];const ge=Ke.length>0;K=Yt,t[43]!==e?(F=e("settings.page.mcp.title"),t[43]=e,t[44]=F):F=t[44],t[45]!==e?(T=e("settings.mcp.grid.description"),t[45]=e,t[46]=T):T=t[46];let Re;t[47]===Symbol.for("react.memo_cache_sentinel")?(Re=s.jsx(Oi,{className:"min-w-0 flex-1 @xl:w-56 @xl:flex-none"}),t[47]=Re):Re=t[47];let Oe;t[48]!==e?(Oe=e("settings.mcp.sidebar.actions.refreshStatusAria"),t[48]=e,t[49]=Oe):Oe=t[49];let pe;t[50]!==e?(pe=e("settings.mcp.sidebar.actions.refreshStatusTitle"),t[50]=e,t[51]=pe):pe=t[51];const xe=v&&"animate-spin";let Ne;t[52]!==xe?(Ne=Me("size-4",xe),t[52]=xe,t[53]=Ne):Ne=t[53];let de;t[54]!==Ne?(de=s.jsx(J,{name:"refresh",className:Ne}),t[54]=Ne,t[55]=de):de=t[55],t[56]!==D||t[57]!==v||t[58]!==Oe||t[59]!==pe||t[60]!==de?(O=s.jsxs("div",{className:"flex w-full items-center gap-2 @xl:w-auto",children:[Re,s.jsx(q,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 text-muted-foreground",disabled:v,onClick:D,"aria-label":Oe,title:pe,children:de})]}),t[56]=D,t[57]=v,t[58]=Oe,t[59]=pe,t[60]=de,t[61]=O):O=t[61],t[62]!==y||t[63]!==g.length||t[64]!==e?(E=g.length>0?s.jsx(Fo,{value:y,onChange:N,placeholder:e("settings.mcp.grid.searchPlaceholder")}):null,t[62]=y,t[63]=g.length,t[64]=e,t[65]=E):E=t[65],B=g.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.empty")}):Te.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.noMatches",{query:y.trim()})}):null,_=Lo,t[66]!==P||t[67]!==ge||t[68]!==e?(H=ge?null:s.jsx(Oo,{label:e("settings.mcp.sidebar.actions.addServerTitle"),hint:e("settings.mcp.grid.addHint"),onClick:P,settingsItem:"mcp.create"}),t[66]=P,t[67]=ge,t[68]=e,t[69]=H):H=t[69];let Ue;t[70]!==w||t[71]!==h||t[72]!==o||t[73]!==n||t[74]!==e?(Ue=Ie=>{const De=Ie.disabled!==!0,Je=w(`mcp:${Ie.name}`),tt=Ie.type==="local"?Ie.command?.join(" "):Ie.url;return s.jsx(Ga,{icon:s.jsx(Wr,{name:Ie.type==="local"?"server":"global"}),title:Ie.name,subtitle:tt||void 0,badges:s.jsx(kb,{status:h[Ie.name]?.status.status,enabled:De,blocked:Je}),muted:!De||Je,footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ie.type==="local"?e("settings.mcp.sidebar.serverType.localTitle"):e("settings.mcp.sidebar.serverType.remoteTitle")}),Ie.scope==="project"?s.jsx(jo,{children:e("settings.mcp.grid.scope.project")}):null]}),onOpen:()=>{o(null),n(Ie.name)},actionsLabel:e("settings.mcp.grid.actionsAria",{name:Ie.name}),actions:[{label:e("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>u(Ie.name)}]},Ie.name)},t[70]=w,t[71]=h,t[72]=o,t[73]=n,t[74]=e,t[75]=Ue):Ue=t[75],ne=Te.map(Ue),t[22]=P,t[23]=D,t[24]=w,t[25]=v,t[26]=h,t[27]=y,t[28]=g,t[29]=o,t[30]=n,t[31]=e,t[32]=K,t[33]=F,t[34]=T,t[35]=O,t[36]=E,t[37]=B,t[38]=_,t[39]=H,t[40]=ne}else K=t[32],F=t[33],T=t[34],O=t[35],E=t[36],B=t[37],_=t[38],H=t[39],ne=t[40];let z;t[76]!==_||t[77]!==H||t[78]!==ne?(z=s.jsxs("div",{className:_,children:[H,ne]}),t[76]=_,t[77]=H,t[78]=ne,t[79]=z):z=t[79];const $=l!==null;let V;t[80]!==m?(V=Te=>{!Te&&!m&&u(null)},t[80]=m,t[81]=V):V=t[81];const G=l??"";let ee;t[82]!==e||t[83]!==G?(ee=e("settings.mcp.page.deleteDialog.title",{name:G}),t[82]=e,t[83]=G,t[84]=ee):ee=t[84];let ae;t[85]!==ee?(ae=s.jsx(_t,{children:ee}),t[85]=ee,t[86]=ae):ae=t[86];let X;t[87]!==e?(X=e("settings.mcp.page.deleteDialog.descriptionPrefix"),t[87]=e,t[88]=X):X=t[88];let Q;t[89]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx("code",{className:"text-foreground",children:"opencode.json"}),t[89]=Q):Q=t[89];let le;t[90]!==e?(le=e("settings.mcp.page.deleteDialog.descriptionSuffix"),t[90]=e,t[91]=le):le=t[91];let Z;t[92]!==X||t[93]!==le?(Z=s.jsxs(Vt,{children:[X," ",Q,"."," ",le]}),t[92]=X,t[93]=le,t[94]=Z):Z=t[94];let fe;t[95]!==ae||t[96]!==Z?(fe=s.jsxs(Bt,{children:[ae,Z]}),t[95]=ae,t[96]=Z,t[97]=fe):fe=t[97];let Y;t[98]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>u(null),t[98]=Y):Y=t[98];let be;t[99]!==e?(be=e("settings.common.actions.cancel"),t[99]=e,t[100]=be):be=t[100];let Ee;t[101]!==m||t[102]!==be?(Ee=s.jsx(q,{variant:"outline",size:"sm",onClick:Y,disabled:m,children:be}),t[101]=m,t[102]=be,t[103]=Ee):Ee=t[103];let se;t[104]!==R?(se=()=>{R()},t[104]=R,t[105]=se):se=t[105];let re;t[106]!==m||t[107]!==e?(re=e(m?"settings.mcp.page.actions.deleting":"settings.common.actions.delete"),t[106]=m,t[107]=e,t[108]=re):re=t[108];let je;t[109]!==m||t[110]!==se||t[111]!==re?(je=s.jsx(q,{variant:"destructive",size:"sm",onClick:se,disabled:m,children:re}),t[109]=m,t[110]=se,t[111]=re,t[112]=je):je=t[112];let ie;t[113]!==Ee||t[114]!==je?(ie=s.jsxs(ts,{children:[Ee,je]}),t[113]=Ee,t[114]=je,t[115]=ie):ie=t[115];let Pe;t[116]!==fe||t[117]!==ie?(Pe=s.jsxs(zt,{className:"max-w-md",children:[fe,ie]}),t[116]=fe,t[117]=ie,t[118]=Pe):Pe=t[118];let ke;t[119]!==$||t[120]!==V||t[121]!==Pe?(ke=s.jsx(Kt,{open:$,onOpenChange:V,children:Pe}),t[119]=$,t[120]=V,t[121]=Pe,t[122]=ke):ke=t[122];let Ae;return t[123]!==K||t[124]!==F||t[125]!==T||t[126]!==O||t[127]!==E||t[128]!==B||t[129]!==z||t[130]!==ke?(Ae=s.jsxs(K,{title:F,description:T,headerEnd:O,children:[E,B,z,ke]}),t[123]=K,t[124]=F,t[125]=T,t[126]=O,t[127]=E,t[128]=B,t[129]=z,t[130]=ke,t[131]=Ae):Ae=t[131],Ae};function Sb(t){return{setSelectedMcp:t.setSelectedMcp,setMcpDraft:t.setMcpDraft,loadMcpConfigs:t.loadMcpConfigs,deleteMcp:t.deleteMcp}}function Nb(t){return t.refresh}function Cb(t){return t.getErrorForDirectory}function Ib(t){return setTimeout(t,500)}function Pb(t){return[t.name,t.type==="local"?t.command?.join(" ")??"":t.url??""]}const yr=t=>t===void 0?"":String(t),jr=t=>{const e=t.trim();if(!e)return null;const a=Number(e);return!Number.isFinite(a)||a<=0?null:a%1e3===0?`${a/1e3}s`:`${a}ms`},kr={legacy:"settings.mcp.page.advanced.protocolOption.legacy",auto:"settings.mcp.page.advanced.protocolOption.auto","2026-07-28":"settings.mcp.page.advanced.protocolOption.revision20260728"},Sc={default:"settings.mcp.page.advanced.codemodeOption.default",on:"settings.mcp.page.advanced.codemodeOption.on",off:"settings.mcp.page.advanced.codemodeOption.off"},Ab=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},gi=t=>t?.status.status,wr=t=>t?.status.status==="failed"||t?.status.status==="needs_auth"?t.status.error:void 0;function Nu(t){const e=[];let a="",n=!1,o=!1;for(let i=0;i<t.length;i++){const r=t[i];if(r==="'"&&!o){n=!n;continue}if(r==='"'&&!n){o=!o;continue}if((r===" "||r===" ")&&!n&&!o){a&&(e.push(a),a="");continue}a+=r}return a&&e.push(a),e}const Tb=t=>{const e=$e.c(27),{value:a,onChange:n,preview:o,onDetectUrl:i}=t;let r;e[0]!==a?(r=()=>a.join(`
|
|
5
|
+
`),e[0]=a,e[1]=r):r=e[1];const[l,u]=c.useState(r),m=c.useRef(a);let d,f;e[2]!==a?(d=()=>{JSON.stringify(m.current)!==JSON.stringify(a)&&(m.current=a,u(a.join(`
|
|
6
|
+
`)))},f=[a],e[2]=a,e[3]=d,e[4]=f):(d=e[3],f=e[4]),c.useEffect(d,f);let g;e[5]!==n||e[6]!==i?(g=x=>{const I=x.split(`
|
|
7
|
+
`).filter(Lb);if(i&&I.length===1&&/^https?:\/\/\S+$/i.test(I[0].trim())){i(I[0].trim());return}n(I)},e[5]=n,e[6]=i,e[7]=g):g=e[7];const p=g;let h;e[8]!==n?(h=x=>{const j=x.clipboardData.getData("text").trim();if(!j||j.includes(`
|
|
8
|
+
`)||!/\s/.test(j))return;const D=x.currentTarget;if(D.selectionStart!==0||D.selectionEnd!==D.value.length)return;x.preventDefault();const C=Nu(j);u(C.join(`
|
|
9
|
+
`)),n(C)},e[8]=n,e[9]=h):h=e[9];const w=h;let b;e[10]!==p?(b=x=>{u(x.target.value),p(x.target.value)},e[10]=p,e[11]=b):b=e[11];let k;e[12]!==p||e[13]!==l?(k=()=>{const x=l.split(`
|
|
10
|
+
`).map(Kb).join(`
|
|
11
|
+
`);u(x),p(x)},e[12]=p,e[13]=l,e[14]=k):k=e[14];const v=Math.max(4,a.length+1);let S;e[15]!==w||e[16]!==b||e[17]!==k||e[18]!==v||e[19]!==l?(S=s.jsx(ws,{onPaste:w,value:l,onChange:b,onBlur:k,placeholder:`npx
|
|
12
|
+
-y
|
|
13
|
+
@modelcontextprotocol/server-postgres
|
|
14
|
+
postgresql://user:pass@host/db`,rows:v,className:"font-mono typography-meta min-h-[80px]",spellCheck:!1}),e[15]=w,e[16]=b,e[17]=k,e[18]=v,e[19]=l,e[20]=S):S=e[20];let y;e[21]!==o||e[22]!==a?(y=a.length>0&&s.jsxs("details",{className:"group",children:[s.jsx("summary",{className:"typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground",children:o(a.length)}),s.jsx("div",{className:"mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto",children:s.jsx("code",{className:"typography-micro text-foreground/80 whitespace-pre",children:a.map(zb)})})]}),e[21]=o,e[22]=a,e[23]=y):y=e[23];let N;return e[24]!==y||e[25]!==S?(N=s.jsxs("div",{className:"space-y-2","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",children:[S,y]}),e[24]=y,e[25]=S,e[26]=N):N=e[26],N},Eb=t=>t.toUpperCase().replace(/[^A-Z0-9_]/g,"_"),Nc=({value:t,onChange:e,onCommit:a,keyTransform:n=Eb,keyPlaceholder:o="API_KEY",keyInputClassName:i="w-36 shrink-0 font-mono typography-meta uppercase",pasteLabel:r="Paste .env",pasteTitle:l="Paste KEY=VALUE lines from clipboard",noPairsFoundError:u,importSuccess:m,clipboardReadFailed:d,keyLabel:f,valueLabel:g,valuePlaceholder:p,hideValueTitle:h,showValueTitle:w,addVariable:b,plainTextWarning:k,removeVariableAria:v})=>{const[S,y]=c.useState(new Set),N=()=>e([...t,{key:"",value:""}]),x=P=>{e(t.filter((A,R)=>R!==P)),a?.(),y(A=>{const R=new Set(A);return R.delete(P),R})},I=(P,A,R)=>{const K=[...t];K[P]={...K[P],[A]:R},e(K)},j=P=>{y(A=>{const R=new Set(A);return R.has(P)?R.delete(P):R.add(P),R})},D=async()=>{try{const P=await navigator.clipboard.readText(),A=[];for(const K of P.split(`
|
|
15
|
+
`)){const F=K.trim();if(!F||F.startsWith("#"))continue;const T=F.indexOf("=");if(T===-1)continue;const O=F.slice(0,T).trim();let E=F.slice(T+1).trim();(E.startsWith('"')&&E.endsWith('"')||E.startsWith("'")&&E.endsWith("'"))&&(E=E.slice(1,-1)),O&&A.push({key:O,value:E})}if(A.length===0){W.error(u);return}const R=[...t];for(const K of A){const F=R.findIndex(T=>T.key===K.key);F!==-1?R[F]=K:R.push(K)}e(R),a?.(),W.success(m(A.length))}catch{W.error(d)}},C=t.some(P=>P.value.length>0);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"typography-micro text-muted-foreground w-32 shrink-0",children:f}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:g})]}),s.jsxs(q,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:D,type:"button",title:l,children:[s.jsx(J,{name:"clipboard",className:"h-3 w-3"}),r]})]}),s.jsx("div",{className:"space-y-1.5",children:t.map((P,A)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{value:P.key,onChange:R=>I(A,"key",n(R.target.value)),placeholder:o,className:i,"data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),s.jsxs("div",{className:"relative flex-1 flex items-center",children:[s.jsx(Ve,{type:S.has(A)?"text":"password",value:P.value,onChange:R=>I(A,"value",R.target.value),placeholder:p,className:"font-mono typography-meta pe-8 w-full",autoComplete:"new-password","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),s.jsx("button",{type:"button",onClick:()=>j(A),className:"absolute inset-e-2 text-muted-foreground/60 hover:text-muted-foreground",title:S.has(A)?h:w,children:S.has(A)?s.jsx(J,{name:"eye-off",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"eye",className:"h-3.5 w-3.5"})})]}),s.jsx(q,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>x(A),"aria-label":v,children:s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},A))}),s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:N,type:"button",children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),b]}),C&&s.jsx("p",{className:"typography-micro text-muted-foreground/60",children:k})]})},Cc=t=>{const e=$e.c(14),{status:a,enabled:n,getStatusLabel:o,variant:i}=t,r=i===void 0?"compact":i;if(!n||!a)return null;let l,u;if(e[0]!==o||e[1]!==a||e[2]!==r){u=Symbol.for("react.early_return_sentinel");e:{const g={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"},blocked:{text:"text-[var(--status-warning)]",bg:"bg-[var(--status-warning)]/10"}}[a]??{text:"text-muted-foreground",bg:""};if(r==="pill"){const p=Me("typography-micro font-medium rounded-full px-2 py-0.5",g.text,g.bg);let h;e[5]!==o||e[6]!==a?(h=o(a),e[5]=o,e[6]=a,e[7]=h):h=e[7],u=s.jsxs("span",{className:p,children:["● ",h]});break e}l=Me("typography-micro font-medium",g.text)}e[0]=o,e[1]=a,e[2]=r,e[3]=l,e[4]=u}else l=e[3],u=e[4];if(u!==Symbol.for("react.early_return_sentinel"))return u;let m;e[8]!==o||e[9]!==a?(m=o(a),e[8]=o,e[9]=a,e[10]=m):m=e[10];let d;return e[11]!==l||e[12]!==m?(d=s.jsxs("span",{className:l,children:["● ",m]}),e[11]=l,e[12]=m,e[13]=d):d=e[13],d},Mb=(t,e,a)=>{switch(t){case"connected":return e("settings.mcp.page.status.description.connected");case"failed":return a?.trim()||e("settings.mcp.page.status.description.failedDefault");case"needs_auth":return a?.trim()||e("settings.mcp.page.status.description.needsAuth");case"disabled":return e("settings.mcp.page.status.description.disabled");case"blocked":return e("settings.mcp.page.status.description.blockedByPolicy");default:return e("settings.mcp.page.status.description.default")}},Db=t=>{switch(t){case"failed":return"border-[var(--status-error-border)] bg-[var(--status-error-background)]";case"needs_auth":case"blocked":return"border-[var(--status-warning-border)] bg-[var(--status-warning-background)]";default:return"border-[var(--interactive-border)] bg-[var(--surface-elevated)]"}},Rb=t=>t==="failed"||t==="needs_auth"||t==="blocked",Fb=(t,e)=>{const a=typeof e=="string"&&e.trim()?e.trim():"__global__";return`${t??"__none__"}::${a}`},Ob=()=>{const{t}=ze(),e=c.useCallback((ce,Fe)=>t(ce,Fe),[t]),{selectedMcpName:a,mcpDraft:n,setMcpDraft:o,setSelectedMcp:i,getMcpByName:r,createMcp:l,updateMcp:u,deleteMcp:m}=An(Ms(ce=>({selectedMcpName:ce.selectedMcpName,mcpDraft:ce.mcpDraft,setMcpDraft:ce.setMcpDraft,setSelectedMcp:ce.setSelectedMcp,getMcpByName:ce.getMcpByName,createMcp:ce.createMcp,updateMcp:ce.updateMcp,deleteMcp:ce.deleteMcp}))),d=Us(),f=El(d);c.useEffect(()=>()=>{const ce=An.getState();ce.setSelectedMcp(null),ce.setMcpDraft(null)},[]);const g=dn(ce=>ce.getStatusForDirectory(d)),p=dn(ce=>ce.getDiagnosticForDirectory(d)),h=dn(ce=>ce.refresh),w=dn(ce=>ce.connect),b=dn(ce=>ce.disconnect),k=dn(ce=>ce.testConnection),v=An(ce=>ml(ce,d)),S=a?r(a,d):null,y=!!(n&&n.name===a&&!S),[N,x]=c.useState(""),[I,j]=c.useState("user"),[D,C]=c.useState("local"),[P,A]=c.useState([]),[R,K]=c.useState(""),[F,T]=c.useState([]),[O,E]=c.useState([]),[B,_]=c.useState(""),[H,ne]=c.useState(""),[z,$]=c.useState(""),[V,G]=c.useState("default"),[ee,ae]=c.useState("legacy"),[X,Q]=c.useState(""),[le,Z]=c.useState(So),[fe,Y]=c.useState(!0),[be,Ee]=c.useState(!1),[se,re]=c.useState(!1),[je,ie]=c.useState(!1),[Pe,ke]=c.useState(!1),[Ae,Te]=c.useState(!1),[Ke,ge]=c.useState(!1),[Re,Oe]=c.useState(!1),[pe,xe]=c.useState(""),[Ne,de]=c.useState(null),Ue=c.useMemo(()=>Fb(a,d),[d,a]),Ie=c.useRef(Ue),De=c.useRef(null),Je=JSON.stringify([a,d,y]),tt=c.useRef(Je);tt.current=Je;const mt=c.useRef(null),ht={mcpType:D,command:P,url:R,envEntries:F,headerEntries:O,timeoutStartup:B,timeoutCatalog:H,timeoutExecution:z,codemode:V,protocol:ee,oauthAuthServerMetadataUrl:D==="remote"?X:"",enabled:fe},ft=c.useRef(ht);ft.current=ht;const xt=c.useCallback(()=>{xe(""),de(null),Oe(!0)},[]),Qe=c.useCallback(async()=>{try{const ce=await navigator.clipboard.readText();xe(ce),de(null)}catch{W.error(t("settings.mcp.page.toast.clipboardReadFailed"))}},[t]),lt=c.useCallback(()=>{const ce=rb(pe,{fallbackName:N});if(!ce.ok){de(ce.error);return}const ct=lb(ce,{name:N,scope:I,type:D,command:P,url:R,environment:F,headers:O,timeoutStartup:B,timeoutCatalog:H,timeoutExecution:z,codemode:V,disabled:!fe,protocol:ee,oauthAuthServerMetadataUrl:X},{isNewServer:y});x(ct.name),C(ct.type),A(ct.command??[]),K(ct.url??""),T(ct.environment??[]),E(ct.headers??[]),_(ct.timeoutStartup??""),ne(ct.timeoutCatalog??""),$(ct.timeoutExecution??""),G(ct.codemode??"default"),Y(ct.disabled!==!0),ae(ct.protocol??"legacy"),Q(ct.oauthAuthServerMetadataUrl??""),Oe(!1),xe(""),de(null),W.success(t("settings.mcp.page.toast.configImported"))},[pe,N,I,D,P,R,F,O,ee,X,B,H,z,V,fe,y,t]);c.useEffect(()=>{if(y&&n){mt.current=null,x(n.name),j(n.scope||"user"),C(n.type),A(n.command),K(n.url),T(n.environment),E(n.headers),_(n.timeoutStartup),ne(n.timeoutCatalog),$(n.timeoutExecution),G(n.codemode),ae(n.protocol),Q(n.oauthAuthServerMetadataUrl),Z({oauthEnabled:n.oauthEnabled,oauthClientId:n.oauthClientId,oauthClientSecret:n.oauthClientSecret,oauthScope:n.oauthScope,oauthRedirectUri:n.oauthRedirectUri,oauthCallbackPort:n.oauthCallbackPort}),Y(!n.disabled),ge(!1),De.current={mcpType:n.type,command:n.command,url:n.url,envEntries:n.environment,headerEntries:n.headers,timeoutStartup:n.timeoutStartup,timeoutCatalog:n.timeoutCatalog,timeoutExecution:n.timeoutExecution,codemode:n.codemode,protocol:n.protocol,oauthAuthServerMetadataUrl:n.oauthAuthServerMetadataUrl,enabled:!n.disabled};return}if(S){j(S.scope==="project"?"project":"user");const ce=_l(S.environment),Fe=S.type==="remote"?S:null,ct=_l(Fe?.headers),Ft=S.type,It=Ft==="local"?S.command??[]:[],ls=Fe?.url??"",et=yr(S.timeout?.startup),st=yr(S.timeout?.catalog),Ht=yr(S.timeout?.execution),is=Vm(S.codemode),us=S.protocol??"legacy",Jt=tb(Fe?.oauth),Ss=Fe&&Fe.oauth?Fe.oauth.auth_server_metadata_url??"":"",vn=S.disabled!==!0;Z(Jt);const Xa=De.current!==null&&JSON.stringify(De.current)!==JSON.stringify(ft.current);if(mt.current===Je&&Xa)return;mt.current=Je,C(Ft),A(It),K(ls),T(ce),E(ct),_(et),ne(st),$(Ht),G(is),ae(us),Q(Ss),Y(vn),ge(!1),De.current={mcpType:Ft,command:It,url:ls,envEntries:ce,headerEntries:ct,timeoutStartup:et,timeoutCatalog:st,timeoutExecution:Ht,codemode:is,protocol:us,oauthAuthServerMetadataUrl:Ss,enabled:vn}}},[S,a,d,y,n,Je]);const Ye=c.useMemo(()=>{const ce=X.trim();return!ce||Ab(ce)?null:t("settings.mcp.page.advanced.oauthMetadataUrlInvalid")},[X,t]),at=c.useMemo(()=>{const ce=[];D==="remote"&&O.length>0&&ce.push(`${O.length} ${t("settings.mcp.page.advanced.headers")}`);const Fe=D==="local"?jr(B):null;Fe&&ce.push(t("settings.mcp.page.advanced.summary.startup",{value:Fe}));const ct=jr(H);ct&&ce.push(t("settings.mcp.page.advanced.summary.catalog",{value:ct}));const Ft=jr(z);return Ft&&ce.push(t("settings.mcp.page.advanced.summary.execution",{value:Ft})),V==="on"&&ce.push(t("settings.mcp.page.advanced.summary.codemodeOn")),V==="off"&&ce.push(t("settings.mcp.page.advanced.summary.codemodeOff")),ee!=="legacy"&&ce.push(t(kr[ee])),ce.join(" · ")},[V,O.length,D,ee,t,H,z,B]),dt=c.useMemo(()=>[{id:"local",label:t("settings.mcp.page.connection.kindCommand"),icon:s.jsx(J,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"remote",label:t("settings.mcp.page.connection.kindLink"),icon:s.jsx(J,{name:"global",className:"h-3.5 w-3.5"})}],[t]),_e=c.useCallback(ce=>{C("remote"),K(ce),A([])},[]),nt=c.useCallback(ce=>{K(ce);const Fe=ce.trim();Fe&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(Fe)&&/\s/.test(Fe)&&(C("local"),A(Nu(Fe)),K(""))},[]),te=ce=>({name:ce,scope:I,type:D,command:P,url:R,environment:F,headers:O,...le,oauthAuthServerMetadataUrl:D==="remote"?X:"",protocol:ee,timeoutStartup:B,timeoutCatalog:H,timeoutExecution:z,codemode:V,disabled:!fe}),he=Ya(async()=>{const ce=De.current;if(y||!ce||!a||JSON.stringify(ce)===JSON.stringify({mcpType:D,command:P,url:R,envEntries:F,headerEntries:O,timeoutStartup:B,timeoutCatalog:H,timeoutExecution:z,codemode:V,protocol:ee,oauthAuthServerMetadataUrl:D==="remote"?X:"",enabled:fe}))return Es;if(D==="local"&&P.filter(Boolean).length===0)return gs(t("settings.mcp.page.toast.localCommandRequired"));if(D==="remote"&&!R.trim())return gs(t("settings.mcp.page.toast.remoteUrlRequired"));if(D==="remote"&&Ye)return gs(Ye);const Fe=await u(a,te(a),d);return Fe.ok?tt.current!==Je?bn:(De.current={mcpType:D,command:P,url:R,envEntries:F,headerEntries:O,timeoutStartup:B,timeoutCatalog:H,timeoutExecution:z,codemode:V,protocol:ee,oauthAuthServerMetadataUrl:D==="remote"?X:"",enabled:fe},await h({directory:d,silent:!0}),Fe.reloadFailed?gs(Fe.warning||Fe.message||t("settings.mcp.page.toast.savedReloadFailed")):bn):gs(t("settings.mcp.page.toast.saveFailed"))}),{requestSave:ye}=he,qe=async()=>{const ce=N.trim();if(!ce){W.error(t("settings.mcp.page.toast.nameRequired"));return}if(v.some(Fe=>Fe.name===ce)){W.error(t("settings.mcp.page.toast.serverNameExists"));return}if(D==="local"&&P.filter(Boolean).length===0){W.error(t("settings.mcp.page.toast.localCommandRequired"));return}if(D==="remote"&&!R.trim()){W.error(t("settings.mcp.page.toast.remoteUrlRequired"));return}if(D==="remote"&&Ye){W.error(Ye);return}Ee(!0);try{const Fe=await l(te(ce),d);o(null),i(ce),await h({directory:d,silent:!0}),Fe.reloadFailed?W.warning(Fe.message||t("settings.mcp.page.toast.serverCreatedReloadFailed"),{description:Fe.warning||t("settings.mcp.page.toast.retryRefreshHint")}):W.success(Fe.message||t("settings.mcp.page.toast.serverCreatedReloading"))}catch(Fe){W.error(Fe instanceof Error?Fe.message:t("settings.mcp.page.toast.unexpectedError"))}finally{Ee(!1)}},Ze=()=>{o(null),i(null)},pt=async()=>{if(!a)return;ie(!0);const ce=await m(a,d);ce.ok?(ce.reloadFailed?W.warning(ce.message||t("settings.mcp.page.toast.serverDeletedReloadFailed",{name:a}),{description:ce.warning||t("settings.mcp.page.toast.refreshListIfStale")}):W.success(ce.message||t("settings.mcp.page.toast.serverDeleted",{name:a})),re(!1)):W.error(t("settings.mcp.page.toast.deleteFailed")),ie(!1)},vt=async()=>{if(a)try{await w(a,d),W.success(t("settings.mcp.page.toast.connected"))}catch(ce){W.error(ce instanceof Error?ce.message:t("settings.mcp.page.toast.connectionTestFailed"))}},bt=async()=>{if(a){ke(!0);try{if(gi(g[a])==="connected")await b(a,d),W.success(t("settings.mcp.page.toast.disconnected"));else{await w(a,d),await h({directory:d,silent:!0});const Fe=dn.getState().getStatusForDirectory(d)[a],ct=gi(Fe);ct==="connected"?W.success(t("settings.mcp.page.toast.connected")):ct==="needs_auth"?W.message(t("settings.mcp.page.toast.connectionNeedsAuthorization")):ct==="failed"?W.error(wr(Fe)||t("settings.mcp.page.toast.connectionFailed")):W.message(t("settings.mcp.page.toast.connectionAttemptFinished"));return}await h({directory:d,silent:!0})}catch(ce){W.error(ce instanceof Error?ce.message:t("settings.mcp.page.toast.connectionFailed"))}finally{ke(!1)}}},wt=c.useCallback(()=>y?(W.error(t("settings.mcp.page.toast.createServerBeforeLiveActions")),!1):!0,[y,t]),Et=c.useCallback(async(ce=!1)=>{try{await h({directory:d,silent:ce})}catch(Fe){ce||W.error(Fe instanceof Error?Fe.message:t("settings.mcp.page.toast.refreshStatusFailed"))}},[d,h,t]);c.useEffect(()=>{Et(!0)},[Et]),c.useEffect(()=>{Ie.current=Ue,ke(!1),Te(!1)},[Ue]);const Le=c.useCallback(async()=>{if(!(!a||!wt())){if(!fe){W.error(t("settings.mcp.page.toast.enableServerBeforeTest"));return}Te(!0);try{const ce=await k(a,d),Fe=gi(ce.status);ce.warning?W.warning(ce.warning):Fe==="connected"?W.success(t("settings.mcp.page.toast.connectionTestSucceeded")):Fe==="needs_auth"?W.message(t("settings.mcp.page.toast.connectionNeedsAuthorization")):Fe==="failed"?W.error(wr(ce.status)||ce.error||t("settings.mcp.page.toast.connectionTestFailed")):ce.error?W.error(ce.error):W.message(t("settings.mcp.page.toast.connectionTestFinished"))}catch(ce){W.error(ce instanceof Error?ce.message:t("settings.mcp.page.toast.connectionTestFailed"))}finally{Te(!1)}}},[d,fe,wt,a,t,k]);if(!a)return s.jsx(wb,{});const Xe=g[a],gt=a?p[a]:void 0,jt=a?f(`mcp:${a}`):!1,L=jt?"blocked":Xe?gi(Xe):gt?.status,me=Xe?wr(Xe):gt?.error,Se=gi(Xe)==="connected",Ce=Mb(L,e,me),We=ce=>{switch(ce){case"connected":return t("settings.mcp.page.status.label.connected");case"failed":return t("settings.mcp.page.status.label.failed");case"needs_auth":return t("settings.mcp.page.status.label.needsAuth");case"blocked":return t("settings.mcp.grid.status.blockedByPolicy");default:return ce}};return s.jsxs(s.Fragment,{children:[s.jsxs(Yt,{title:y?t("settings.mcp.page.header.newServer"):a,titleLeading:s.jsx(ko,{label:t("settings.mcp.page.back"),onClick:()=>{o(null),i(null)}}),titleAccessory:y?void 0:s.jsx(Cc,{status:L,enabled:fe,getStatusLabel:We,variant:"pill"}),description:y?t("settings.mcp.page.header.configureNewServer"):t("settings.mcp.page.header.transport",{type:t(D==="local"?"settings.mcp.page.transport.local":"settings.mcp.page.transport.remote")}),headerEnd:y?void 0:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(q,{variant:Se?"outline":"default",size:"xs",className:"!font-normal",onClick:bt,disabled:Pe||!fe||jt,children:t(Pe?"settings.mcp.page.actions.working":Se?"settings.mcp.page.actions.disconnect":"settings.mcp.page.actions.connect")}),Se&&s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{Le()},disabled:Ae||!fe,children:t(Ae?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.test")})]}),onBlurCapture:he.onBlurCapture,children:[!y&&S&&s.jsx(Al,{legacy:S.legacy===!0,path:S.path}),!y&&Rb(L)&&s.jsx(He,{divider:!1,children:s.jsx("div",{className:Me("rounded-lg border p-3",Db(L)),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.status.runtimeStatus")}),s.jsx(Cc,{status:L,enabled:fe,getStatusLabel:We})]}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:Ce}),s.jsx("p",{className:"typography-micro text-muted-foreground/80",children:I==="project"?t("settings.mcp.page.status.projectScopedTo",{directory:d??t("settings.mcp.page.status.activeProject")}):t("settings.mcp.page.status.userScoped")})]}),L==="needs_auth"&&a&&s.jsx(vb,{serverName:a,directory:d,onConnected:vt}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:!Se&&s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Le()},disabled:Ae||!fe||jt,children:t(Ae?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.testConnection")})})]})})}),s.jsxs(He,{title:t("settings.mcp.page.server.title"),divider:!1,settingsItem:"mcp.server",contentClassName:"space-y-0",titleAccessory:y?s.jsxs(q,{variant:"ghost",size:"xs",className:"!font-normal gap-1.5 text-muted-foreground",onClick:xt,type:"button",title:t("settings.mcp.page.server.importJsonTitle"),children:[s.jsx(J,{name:"file-code",className:"h-3.5 w-3.5"}),t("settings.mcp.page.server.importJson")]}):null,children:[y&&s.jsxs(kt,{label:t("settings.mcp.page.server.name"),controlClassName:"flex-wrap @xl:w-auto @xl:flex-1",children:[s.jsx(Ve,{value:N,onChange:ce=>x(xu(ce.target.value)),placeholder:t("settings.mcp.page.server.namePlaceholder"),className:"h-7 w-48 min-w-0 max-w-full shrink font-mono px-2",autoFocus:!0}),s.jsxs(Tt,{value:I,onValueChange:ce=>j(ce),children:[s.jsxs(Pt,{className:"!h-7 min-w-0 max-w-full gap-1.5 px-2",children:[s.jsx(J,{name:I==="user"?"user-3":"folder",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:t(I==="user"?"settings.mcp.page.scope.everywhere":"settings.mcp.page.scope.thisProject")})]}),s.jsxs(At,{align:"end",children:[s.jsx(ot,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.mcp.page.scope.everywhere")})]})}),s.jsx(ot,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(J,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.mcp.page.scope.thisProject")})]})})]})]})]}),s.jsx(it,{checked:fe,onChange:ce=>{Y(ce),ye()},label:t("settings.mcp.page.server.enable"),ariaLabel:t("settings.mcp.page.server.enableAria")})]}),s.jsxs(He,{title:t("settings.mcp.page.connection.title"),description:t("settings.mcp.page.connection.description"),settingsItem:"mcp.command",contentClassName:"space-y-2",children:[s.jsx(fl,{items:dt,activeId:D,onSelect:ce=>{C(ce),ye()},layoutMode:"fit",variant:"active-pill",className:"h-7"}),D==="local"?s.jsx(Tb,{value:P,onChange:A,preview:ce=>t("settings.mcp.page.connection.previewArgs",{count:ce}),onDetectUrl:_e}):s.jsx(Ve,{value:R,onChange:ce=>nt(ce.target.value),placeholder:t("settings.mcp.page.connection.serverUrlPlaceholder"),className:"font-mono typography-meta"}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t(D==="local"?"settings.mcp.page.connection.hintCommand":"settings.mcp.page.connection.hintLink")})]}),s.jsx(He,{title:t("settings.mcp.page.advanced.title"),settingsItem:"mcp.advanced",children:s.jsxs(Js,{open:Ke,onOpenChange:ge,children:[s.jsxs(Qs,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-start",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:t("settings.mcp.page.advanced.configure")}),at&&s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",at,")"]})]}),Ke?s.jsx(J,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx(J,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(Ys,{className:"pt-2",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.protocol")}),s.jsx(qt,{children:t("settings.mcp.page.advanced.protocolHint")})]}),s.jsxs(Tt,{value:ee,onValueChange:ce=>{const Fe=_r.find(ct=>ct===ce);Fe&&(ae(Fe),ye())},children:[s.jsx(Pt,{className:"!h-7 w-full max-w-[16rem] px-2","aria-label":t("settings.mcp.page.advanced.protocol"),children:s.jsx("span",{className:"truncate",children:t(kr[ee])})}),s.jsx(At,{children:_r.map(ce=>s.jsx(ot,{value:ce,children:t(kr[ce])},ce))})]})]}),s.jsxs("div",{className:"space-y-2",children:[D==="local"&&s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.timeoutStartupMs")}),s.jsx(qt,{children:t("settings.mcp.page.advanced.timeoutStartupHint")})]}),s.jsx(Ve,{type:"number",min:"1",step:"1",value:B,onChange:ce=>_(ce.target.value),placeholder:"5000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.timeoutCatalogMs")}),s.jsx(qt,{children:t("settings.mcp.page.advanced.timeoutCatalogHint")})]}),s.jsx(Ve,{type:"number",min:"1",step:"1",value:H,onChange:ce=>ne(ce.target.value),placeholder:"30000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.timeoutExecutionMs")}),s.jsx(qt,{children:t("settings.mcp.page.advanced.timeoutExecutionHint")})]}),s.jsx(Ve,{type:"number",min:"1",step:"1",value:z,onChange:ce=>$(ce.target.value),placeholder:"30000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.codemode")}),s.jsxs(qt,{children:[t("settings.mcp.page.advanced.codemodeHint")," ",t("settings.mcp.page.advanced.codemodeDefaultHint")]})]}),s.jsxs(Tt,{value:V,onValueChange:ce=>{const Fe=Vl.find(ct=>ct===ce);Fe&&(G(Fe),ye())},children:[s.jsx(Pt,{className:"!h-7 w-full max-w-[16rem] px-2","aria-label":t("settings.mcp.page.advanced.codemode"),children:s.jsx("span",{className:"truncate",children:t(Sc[V])})}),s.jsx(At,{children:Vl.map(ce=>s.jsx(ot,{value:ce,children:t(Sc[ce])},ce))})]})]}),D==="remote"&&s.jsxs("div",{children:[s.jsxs(Dn,{as:"div",className:"mb-2",children:[t("settings.mcp.page.advanced.requestHeaders"),O.length>0&&s.jsxs("span",{className:"ms-1.5 typography-micro text-muted-foreground font-normal",children:["(",O.length,")"]})]}),s.jsx(Nc,{value:O,onChange:E,onCommit:ye,keyTransform:ce=>ce.trimStart(),keyPlaceholder:t("settings.mcp.page.advanced.headerNamePlaceholder"),keyInputClassName:"w-36 shrink-0 font-mono typography-meta",pasteLabel:t("settings.mcp.page.advanced.pasteHeaders"),pasteTitle:t("settings.mcp.page.advanced.pasteHeadersTitle"),noPairsFoundError:t("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:ce=>t("settings.mcp.page.toast.importedVariablesCount",{count:ce}),clipboardReadFailed:t("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:t("settings.mcp.page.env.key"),valueLabel:t("settings.mcp.page.env.value"),valuePlaceholder:t("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:t("settings.mcp.page.env.hide"),showValueTitle:t("settings.mcp.page.env.show"),addVariable:t("settings.mcp.page.env.addVariable"),plainTextWarning:t("settings.mcp.page.env.plainTextWarning"),removeVariableAria:t("settings.mcp.page.env.removeVariableAria")})]}),D==="remote"&&s.jsxs("div",{children:[s.jsx(Dn,{as:"div",className:"mb-2",children:t("settings.mcp.page.advanced.oauth")}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Ct,children:t("settings.mcp.page.advanced.oauthMetadataUrl")}),s.jsx(qt,{children:t("settings.mcp.page.advanced.oauthMetadataUrlHint")})]}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx(Ve,{type:"url",value:X,onChange:ce=>Q(ce.target.value),placeholder:t("settings.mcp.page.advanced.oauthMetadataUrlPlaceholder"),"aria-label":t("settings.mcp.page.advanced.oauthMetadataUrl"),"aria-invalid":Ye?!0:void 0,className:"h-7 w-full max-w-[24rem] font-mono typography-meta px-2","data-bwignore":"true","data-1p-ignore":"true"}),Ye&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:Ye})]})]})]})]})})]})}),s.jsx(He,{title:t("settings.mcp.page.env.title"),description:t("settings.mcp.page.env.description"),titleAccessory:F.length>0?s.jsxs("span",{className:"typography-micro text-muted-foreground font-normal",children:["(",F.length,")"]}):null,settingsItem:"mcp.environment",children:F.length===0?s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:()=>T([{key:"",value:""}]),children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),t("settings.mcp.page.env.addEnvironmentVariable")]}):s.jsx(Nc,{value:F,onChange:T,onCommit:ye,keyPlaceholder:t("settings.mcp.page.env.keyPlaceholder"),pasteLabel:t("settings.mcp.page.env.pasteEnv"),pasteTitle:t("settings.mcp.page.env.pasteEnvTitle"),noPairsFoundError:t("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:ce=>t("settings.mcp.page.toast.importedVariablesCount",{count:ce}),clipboardReadFailed:t("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:t("settings.mcp.page.env.key"),valueLabel:t("settings.mcp.page.env.value"),valuePlaceholder:t("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:t("settings.mcp.page.env.hide"),showValueTitle:t("settings.mcp.page.env.show"),addVariable:t("settings.mcp.page.env.addVariable"),plainTextWarning:t("settings.mcp.page.env.plainTextWarning"),removeVariableAria:t("settings.mcp.page.env.removeVariableAria")})}),s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[y&&s.jsxs(s.Fragment,{children:[s.jsx(q,{onClick:()=>{qe()},disabled:be||!N.trim(),size:"xs",className:"!font-normal",children:t(be?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(q,{variant:"ghost",onClick:Ze,disabled:be,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]}),!y&&s.jsx(q,{variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>re(!0),children:t("settings.common.actions.delete")})]})," "]}),s.jsx(Kt,{open:Re,onOpenChange:ce=>{ce||(Oe(!1),xe(""),de(null))},children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.mcp.page.importDialog.title")}),s.jsx(Vt,{children:t("settings.mcp.page.importDialog.description")})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx(ws,{value:pe,onChange:ce=>{xe(ce.target.value),de(null)},placeholder:`{
|
|
16
|
+
"mcpServers": {
|
|
17
|
+
"postgres": {
|
|
18
|
+
"command": "npx",
|
|
19
|
+
"args": ["-y", "@modelcontextprotocol/server-postgres"]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}`,rows:8,className:"font-mono typography-meta",spellCheck:!1,"data-bwignore":"true","data-1p-ignore":"true"}),Ne&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:Ne}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:Qe,type:"button",children:[s.jsx(J,{name:"clipboard",className:"h-3.5 w-3.5"}),t("settings.mcp.page.importDialog.pasteFromClipboard")]})})]}),s.jsxs(ts,{children:[s.jsx(q,{variant:"outline",onClick:()=>{Oe(!1),xe(""),de(null)},className:"text-foreground",children:t("settings.common.actions.cancel")}),s.jsx(q,{onClick:lt,disabled:!pe.trim(),size:"sm",children:t("settings.common.actions.import")})]})]})}),s.jsx(Kt,{open:se,onOpenChange:ce=>{!ce&&!je&&re(!1)},children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.mcp.page.deleteDialog.title",{name:a??""})}),s.jsxs(Vt,{children:[t("settings.mcp.page.deleteDialog.descriptionPrefix")," ",s.jsx("code",{className:"text-foreground",children:"opencode.json"}),"."," ",t("settings.mcp.page.deleteDialog.descriptionSuffix")]})]}),s.jsxs(ts,{children:[s.jsx(q,{variant:"outline",onClick:()=>re(!1),disabled:je,className:"text-foreground",children:t("settings.common.actions.cancel")}),s.jsx(q,{variant:"destructive",size:"sm",onClick:pt,disabled:je,children:t(je?"settings.mcp.page.actions.deleting":"settings.common.actions.delete")})]})]})})]})};function Lb(t){return t.trim().length>0}function Kb(t){return t.trimEnd()}function zb(t,e){return s.jsxs("span",{className:"block",children:[s.jsxs("span",{className:"text-muted-foreground select-none me-2",children:["[",e,"]"]}),t]},e)}const Ub=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function $b(t){const e=t.trim();if(e==="")return{ok:!0,value:void 0};try{const a=JSON.parse(e);return a===null||typeof a!="object"||Array.isArray(a)?{ok:!1}:{ok:!0,value:a}}catch{return{ok:!1}}}const Bb=({open:t,onOpenChange:e,defaultScope:a="user"})=>{const{t:n}=ze(),o=Lt(F=>F.createEntry),i=Lt(F=>F.createFile),[r,l]=c.useState("npm"),[u,m]=c.useState(""),[d,f]=c.useState(""),[g,p]=c.useState(""),[h,w]=c.useState(""),[b,k]=c.useState(a),[v,S]=c.useState(!1),y=c.useCallback(()=>{m(""),f(""),p(""),w(""),k(a)},[a]);c.useEffect(()=>{t&&(l("npm"),y())},[t,y]);const N=F=>{F!==r&&(l(F),y())},x=c.useMemo(()=>$b(d),[d]),I=!x.ok,j=r==="file"&&g.trim()!==""&&!Ub.test(g.trim()),D=(r==="npm"||r==="path")&&u.trim()==="",C=r==="file"&&h.trim()==="",P=r==="file"&&g.trim()==="",A=v||I||r==="npm"&&D||r==="path"&&D||r==="file"&&(P||j||C),R=async()=>{if(!A){S(!0);try{let F;r==="file"?F=await i({fileName:g.trim(),content:h,scope:b}):F=await o({spec:u.trim(),options:x.ok?x.value:void 0,scope:b}),F.ok?(W.success(F.message||n("settings.plugins.toast.created")),F.reloadFailed&&W.warning(n("settings.plugins.toast.reloadFailed")),e(!1)):W.error(F.message||n("settings.plugins.sidebar.toast.deleteFailed"))}finally{S(!1)}}},K=c.useMemo(()=>[{id:"npm",label:n("settings.plugins.dialog.add.tab.npm")},{id:"path",label:n("settings.plugins.dialog.add.tab.path")},{id:"file",label:n("settings.plugins.dialog.add.tab.file")}],[n]);return s.jsx(Kt,{open:t,onOpenChange:F=>{!F&&v||e(F)},children:s.jsxs(zt,{className:"max-w-xl",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:n("settings.plugins.dialog.add.title")}),s.jsx(Vt,{children:n("settings.plugins.sidebar.empty.description")})]}),s.jsx(fl,{items:K,activeId:r,onSelect:F=>N(F),layoutMode:"fit",variant:"active-pill",className:"h-7"}),s.jsxs("div",{className:"flex flex-col gap-4",children:[(r==="npm"||r==="path")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-settings-item":"plugins.spec",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-spec",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.spec")}),s.jsx(Ve,{id:"plugin-spec",value:u,onChange:F=>m(F.target.value),placeholder:n("settings.plugins.page.field.spec.placeholder"),"aria-invalid":D?!1:void 0,disabled:v}),D&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.plugins.validation.specRequired")})]}),s.jsxs("div",{"data-settings-item":"plugins.options",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-options",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.options")}),s.jsx(ws,{id:"plugin-options",value:d,onChange:F=>f(F.target.value),rows:5,className:"font-mono",hasError:I,disabled:v}),I&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:n("settings.plugins.page.field.options.invalidJson")})]})]}),r==="file"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-settings-item":"plugins.content",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-filename",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.fileName")}),s.jsx(Ve,{id:"plugin-filename",value:g,onChange:F=>p(F.target.value),placeholder:"my-plugin.ts","aria-invalid":j||void 0,disabled:v}),j&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:n("settings.plugins.validation.fileName")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-content",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.content")}),s.jsx(ws,{id:"plugin-content",value:h,onChange:F=>w(F.target.value),rows:16,className:"font-mono",disabled:v})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.scope")}),s.jsx("div",{className:"flex items-center gap-4",children:["user","project"].map(F=>{const T=b===F,O=n(F==="user"?"settings.plugins.scope.user":"settings.plugins.scope.project");return s.jsxs("button",{type:"button",onClick:()=>k(F),disabled:v,className:"flex items-center gap-2 py-1 text-start disabled:opacity-50",children:[s.jsx(hl,{checked:T,onChange:()=>k(F),ariaLabel:O}),s.jsx("span",{className:Me("typography-ui-label font-normal",T?"text-foreground":"text-foreground/60"),children:O})]},F)})})]})]}),s.jsxs(ts,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>e(!1),disabled:v,children:n("settings.plugins.dialog.add.action.cancel")}),s.jsxs(q,{size:"sm",onClick:()=>{R()},disabled:A,children:[v?s.jsx(J,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}):null,n("settings.plugins.dialog.add.action.submit")]})]})]})})},_b=t=>t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t),Va=t=>{const e=t.replace(/\\/g,"/"),a=[],[n,...o]=e.split("/");for(const r of o)if(!(r===""||r===".")){if(r===".."){a.pop();continue}a.push(r)}return`${/^[A-Za-z]:$/.test(n)?`${n.toUpperCase()}/`:"/"}${a.join("/")}`},Vb=t=>Va(`${t.replace(/\\/g,"/")}/..`),Hb=t=>{try{const e=decodeURIComponent(new URL(t).pathname);return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}catch{return null}};function Cu(t,e){if(t.startsWith("file://")){const a=Hb(t);return a?{kind:"local",path:Va(a)}:null}return t.startsWith("./")||t.startsWith("../")?e?{kind:"local",path:Va(`${Vb(e)}/${t}`)}:null:_b(t)?{kind:"local",path:Va(t)}:{kind:"package",target:t}}function Iu(t){return t?{kind:"local",path:Va(t)}:null}const qb=(t,e)=>{if(t.kind==="package")return e.source.kind==="package"&&e.source.target===t.target;if(e.source.kind!=="local")return!1;const a=Va(e.source.path);return a===t.path||a.startsWith(`${t.path}/`)};function Pu(t,e){return e.filter(a=>qb(t,a))}function Wb(t){const e=t.find(n=>n.state.kind==="failed");if(e&&e.state.kind==="failed")return{kind:"failed",error:e.state.error,ref:e.state.ref};const a=t[0];return a?{kind:"active",version:a.source.kind==="package"?a.source.version:null}:{kind:"notReported"}}function Au(t){const e=t.flatMap(a=>a.source.kind==="package"?[a.source]:[]);return e.some(a=>a.updating)?"updating":e.some(a=>a.outdated)?"available":"none"}function Tu(t){const e=$e.c(12),a=Lt(Gb),n=bl(sa());let o;e:{if(a.kind==="idle"||a.scope!==n){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={kind:"loading"},e[0]=m):m=e[0],o=m;break e}if(a.kind==="failed"||!t){let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={kind:"unknown"},e[1]=m):m=e[1],o=m;break e}let i,r,l;if(e[2]!==a.plugins||e[3]!==t){const m=Pu(t,a.plugins);i="known",r=Wb(m),l=Au(m),e[2]=a.plugins,e[3]=t,e[4]=i,e[5]=r,e[6]=l}else i=e[4],r=e[5],l=e[6];let u;e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==t?(u={kind:i,load:r,update:l,target:t},e[7]=i,e[8]=r,e[9]=l,e[10]=t,e[11]=u):u=e[11],o=u}return o}function Gb(t){return t.runtime}function Eu(t){const e=$e.c(4);let a;if(e[0]!==t){const i=bl(sa());a=t?.kind==="package"?Bd(i,t.target):null,e[0]=t,e[1]=a}else a=e[1];const n=a;let o;return e[2]!==n?(o=i=>n?i.packageUpdates[n]??null:null,e[2]=n,e[3]=o):o=e[3],Lt(o)}const Ic=t=>{const e=$e.c(18),{target:a,spec:n}=t,{t:o}=ze(),i=Tu(a),r=Eu(a);let l;e[0]!==n?(l=b=>n?b.registryInfo[n]:void 0,e[0]=n,e[1]=l):l=e[1];const u=Lt(l),m=u?.kind==="npm-missing-package"||u?.kind==="npm-missing-version"||u?.kind==="npm-malformed"||u?.kind==="path-missing"||u?.kind==="path-unreadable",d=i.kind==="known"&&(i.update==="updating"||r?.kind==="running"),f=!d&&(u?.kind==="npm-ok"&&u.hasUpdate||i.kind==="known"&&i.update==="available");let g;e[2]!==m||e[3]!==o?(g=m?s.jsx(tn,{tone:"error",children:o("settings.plugins.registry.banner.invalid.title")}):null,e[2]=m,e[3]=o,e[4]=g):g=e[4];let p;e[5]!==m||e[6]!==i.kind||e[7]!==i.load||e[8]!==o||e[9]!==d?(p=i.kind==="known"&&!m?d?s.jsx(tn,{tone:"neutral",children:o("settings.plugins.update.running")}):i.load.kind==="failed"?s.jsx(tn,{tone:"error",children:o("settings.plugins.status.failed.title")}):i.load.kind==="notReported"?s.jsx(tn,{tone:"neutral",children:o("settings.plugins.status.notReported.title")}):s.jsx(tn,{tone:"success",children:o("settings.plugins.status.loaded")}):null,e[5]=m,e[6]=i.kind,e[7]=i.load,e[8]=o,e[9]=d,e[10]=p):p=e[10];let h;e[11]!==o||e[12]!==f?(h=f?s.jsx(tn,{tone:"info",children:o("settings.plugins.update.available.title")}):null,e[11]=o,e[12]=f,e[13]=h):h=e[13];let w;return e[14]!==g||e[15]!==p||e[16]!==h?(w=s.jsxs(s.Fragment,{children:[g,p,h]}),e[14]=g,e[15]=p,e[16]=h,e[17]=w):w=e[17],w},Jb=t=>{const e=$e.c(54),{onAdd:a,onDelete:n}=t,{t:o}=ze(),{entries:i,files:r,setSelected:l,loadPlugins:u}=Lt(Ms(Qb)),m=Lt(Yb),d=Lt(Zb),f=Lt(Xb),g=Lt(ex),p=Lt(tx),h=Lt(sx),w=Lt(nx),b=Lt(ax),k=Lt(ix),v=bl(sa()),S=p.kind==="failed"&&p.scope===v,y=p.kind==="ready"&&p.scope===v?p.plugins:null,[N,x]=c.useState("");let I,j;e[0]!==u?(I=()=>{u()},j=[u],e[0]=u,e[1]=I,e[2]=j):(I=e[1],j=e[2]),c.useEffect(I,j);let D;e[3]!==g||e[4]!==d||e[5]!==o?(D=async()=>{W.info(o("settings.plugins.toast.refreshing"));const[je,ie]=await Promise.all([d({force:!0}),g()]);je||W.error(o("settings.plugins.toast.refreshFailed")),ie||W.error(o("settings.plugins.toast.checkFailed"))},e[3]=g,e[4]=d,e[5]=o,e[6]=D):D=e[6];const C=D;let P;if(e[7]!==i||e[8]!==r){P=new Map;for(const je of i)P.set(je.id,Cu(je.spec,je.sourcePath));for(const je of r)P.set(je.id,Iu(je.absolutePath));e[7]=i,e[8]=r,e[9]=P}else P=e[9];const A=P,R=je=>{const ie=A.get(je);return!y||ie?.kind!=="package"||w[Bd(v,ie.target)]?.kind==="running"?null:Au(Pu(ie,y))==="available"?ie.target:null},K=je=>{const ie=[],Pe=h[je.spec],ke=R(je.id);if(Pe?.kind==="npm-ok"&&Pe.hasUpdate&&Pe.latestVersion){const Ae=Pe.latestVersion;ie.push({label:o("settings.plugins.registry.banner.updateAvailable.action",{latest:Ae}),icon:"arrow-up-s",onSelect:()=>{b(je.id).then(Te=>{Te.ok?W.success(o("settings.plugins.toast.updatedToLatest",{version:Ae})):W.error(o("settings.plugins.toast.refreshFailed"))})}})}else ke&&ie.push({label:o("settings.plugins.update.action"),icon:"arrow-up-s",onSelect:()=>{k(ke).then(Ae=>{Ae?W.success(o("settings.plugins.update.toast.done",{name:je.spec})):W.error(o("settings.plugins.update.toast.failed",{name:je.spec}))})}});return ie.push({label:o("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>n({kind:"entry",id:je.id,label:je.spec})}),ie},F=[...i.map(ox),...r.map(rx)],T=_n(F,N,lx);let O;e[10]!==N?(O=N.trim(),e[10]=N,e[11]=O):O=e[11];const E=O.length>0,B=m||f,_=Yt;let H;e[12]!==o?(H=o("settings.page.plugins.title"),e[12]=o,e[13]=H):H=e[13];let ne;e[14]!==o?(ne=o("settings.plugins.grid.description"),e[14]=o,e[15]=ne):ne=e[15];let z;e[16]!==S||e[17]!==o?(z=S?s.jsxs("span",{className:"inline-flex items-center gap-1 typography-meta text-muted-foreground",children:[s.jsx(J,{name:"question",className:"size-3.5"}),o("settings.plugins.status.sidebar.unavailable")]}):null,e[16]=S,e[17]=o,e[18]=z):z=e[18];let $;e[19]!==C?($=()=>{C()},e[19]=C,e[20]=$):$=e[20];let V;e[21]!==o?(V=o("settings.plugins.sidebar.actions.refresh"),e[21]=o,e[22]=V):V=e[22];let G;e[23]!==o?(G=o("settings.plugins.sidebar.actions.refresh"),e[23]=o,e[24]=G):G=e[24];const ee=B&&"animate-spin";let ae;e[25]!==ee?(ae=Me("size-4",ee),e[25]=ee,e[26]=ae):ae=e[26];let X;e[27]!==ae?(X=s.jsx(J,{name:"refresh",className:ae}),e[27]=ae,e[28]=X):X=e[28];let Q;e[29]!==B||e[30]!==G||e[31]!==X||e[32]!==$||e[33]!==V?(Q=s.jsx(q,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 text-muted-foreground",onClick:$,disabled:B,"aria-label":V,title:G,children:X}),e[29]=B,e[30]=G,e[31]=X,e[32]=$,e[33]=V,e[34]=Q):Q=e[34];let le;e[35]!==Q||e[36]!==z?(le=s.jsxs("div",{className:"flex items-center gap-2",children:[z,Q]}),e[35]=Q,e[36]=z,e[37]=le):le=e[37];const Z=F.length>0?s.jsx(Fo,{value:N,onChange:x,placeholder:o("settings.plugins.grid.searchPlaceholder")}):null,fe=F.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:o("settings.plugins.grid.empty")}):T.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:o("settings.plugins.grid.noMatches",{query:N.trim()})}):null,Y=Lo;let be;e[38]!==E||e[39]!==a||e[40]!==o?(be=E?null:s.jsx(Oo,{label:o("settings.plugins.sidebar.actions.addTitle"),hint:o("settings.plugins.grid.addHint"),onClick:a,settingsItem:"plugins.create"}),e[38]=E,e[39]=a,e[40]=o,e[41]=be):be=e[41];const Ee=T.map(je=>{if(je.kind==="entry"){const{entry:ke}=je;return s.jsx(Ga,{icon:s.jsx(Wr,{name:ke.parsedKind==="npm"?"code-box":"folder"}),title:ke.spec,badges:s.jsx(Ic,{target:A.get(ke.id)??null,spec:ke.spec}),footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:ke.parsedKind==="npm"?o("settings.plugins.sidebar.kind.npm"):o("settings.plugins.sidebar.kind.path")}),ke.scope==="project"?s.jsx(jo,{children:o("settings.plugins.grid.scope.project")}):null]}),onOpen:()=>l(ke.id),actionsLabel:o("settings.plugins.grid.actionsAria",{name:ke.spec}),actions:K(ke)},ke.id)}const{file:ie}=je,Pe=ie.kind==="package";return s.jsx(Ga,{icon:s.jsx(Wr,{name:Pe?"folder":"file-text"}),title:ie.fileName,badges:s.jsx(Ic,{target:A.get(ie.id)??null}),footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:o(Pe?"settings.plugins.sidebar.kind.package":"settings.plugins.sidebar.kind.file")}),ie.scope==="project"?s.jsx(jo,{children:o("settings.plugins.grid.scope.project")}):null]}),onOpen:Pe?void 0:()=>l(ie.id),actionsLabel:o("settings.plugins.grid.actionsAria",{name:ie.fileName}),actions:Pe?void 0:[{label:o("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>n({kind:"file",id:ie.id,label:ie.fileName})}]},ie.id)});let se;e[42]!==Y||e[43]!==be||e[44]!==Ee?(se=s.jsxs("div",{className:Y,children:[be,Ee]}),e[42]=Y,e[43]=be,e[44]=Ee,e[45]=se):se=e[45];let re;return e[46]!==_||e[47]!==le||e[48]!==Z||e[49]!==fe||e[50]!==se||e[51]!==H||e[52]!==ne?(re=s.jsxs(_,{title:H,description:ne,headerEnd:le,children:[Z,fe,se]}),e[46]=_,e[47]=le,e[48]=Z,e[49]=fe,e[50]=se,e[51]=H,e[52]=ne,e[53]=re):re=e[53],re};function Qb(t){return{entries:t.entries,files:t.files,setSelected:t.setSelected,loadPlugins:t.loadPlugins}}function Yb(t){return t.isLoadingRegistry}function Zb(t){return t.loadRegistryInfo}function Xb(t){return t.isCheckingUpdates}function ex(t){return t.checkUpdates}function tx(t){return t.runtime}function sx(t){return t.registryInfo}function nx(t){return t.packageUpdates}function ax(t){return t.updateToLatest}function ix(t){return t.updatePackage}function ox(t){return{kind:"entry",entry:t}}function rx(t){return{kind:"file",file:t}}function lx(t){return t.kind==="entry"?[t.entry.spec]:[t.file.fileName,t.file.absolutePath??""]}const cx=({entryId:t,spec:e})=>{const{t:a}=ze(),n=Lt(f=>f.registryInfo[e]),o=Lt(f=>f.updateToLatest),[i,r]=c.useState(!1);if(!n)return null;if(n.kind==="npm-ok"){if(!n.hasUpdate||!n.latestVersion)return null;const f=n.latestVersion,g=n.currentVersion??"",p=async()=>{r(!0);try{(await o(t)).ok?W.success(a("settings.plugins.toast.updatedToLatest",{version:f})):W.error(a("settings.plugins.toast.refreshFailed"))}finally{r(!1)}};return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx(J,{name:"arrow-up",className:"h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label text-[var(--status-success)]",children:a("settings.plugins.registry.banner.updateAvailable.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:a("settings.plugins.registry.banner.updateAvailable.description",{current:g,latest:f})})]}),s.jsx(q,{variant:"default",size:"sm",onClick:()=>{p()},disabled:i,children:a("settings.plugins.registry.banner.updateAvailable.action",{latest:f})})]})}if(n.kind==="path-ok")return null;if(n.kind==="npm-network")return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx(J,{name:"cloud-off",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("settings.plugins.registry.badge.network.tooltip")})})]});const l=n.kind==="path-unreadable",u=l?"var(--status-warning)":"var(--status-error)",m=l?"alert":"error-warning",d=(()=>{switch(n.kind){case"npm-missing-version":return a("settings.plugins.registry.banner.invalid.missingVersion");case"npm-missing-package":return a("settings.plugins.registry.banner.invalid.missingPackage");case"npm-malformed":return a("settings.plugins.registry.banner.invalid.malformed");case"path-missing":return a("settings.plugins.registry.banner.invalid.pathMissing");case"path-unreadable":return a("settings.plugins.registry.banner.invalid.pathUnreadable")}})();return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx(J,{name:m,className:"h-5 w-5 shrink-0 mt-0.5",style:{color:u}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label",style:{color:u},children:a("settings.plugins.registry.banner.invalid.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:d})]})]})},Pc=t=>{const e=$e.c(68),{target:a,name:n}=t,{t:o}=ze(),i=Tu(a),r=Eu(a),l=Lt(dx),u=Lt(ux);if(i.kind==="loading")return null;if(i.kind==="unknown"){let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(J,{name:"question",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),e[0]=y):y=e[0];let N;e[1]!==o?(N=o("settings.plugins.status.unknown.title"),e[1]=o,e[2]=N):N=e[2];let x;e[3]!==N?(x=s.jsx("p",{className:"typography-label text-foreground",children:N}),e[3]=N,e[4]=x):x=e[4];let I;e[5]!==o?(I=o("settings.plugins.status.unknown.description"),e[5]=o,e[6]=I):I=e[6];let j;e[7]!==I?(j=s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:I}),e[7]=I,e[8]=j):j=e[8];let D;e[9]!==x||e[10]!==j?(D=s.jsxs("div",{className:"flex-1 min-w-0",children:[x,j]}),e[9]=x,e[10]=j,e[11]=D):D=e[11];let C;e[12]!==l?(C=()=>{l()},e[12]=l,e[13]=C):C=e[13];let P;e[14]!==o?(P=o("settings.plugins.status.retry"),e[14]=o,e[15]=P):P=e[15];let A;e[16]!==C||e[17]!==P?(A=s.jsx(q,{variant:"outline",size:"sm",onClick:C,children:P}),e[16]=C,e[17]=P,e[18]=A):A=e[18];let R;return e[19]!==D||e[20]!==A?(R=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[y,D,A]}),e[19]=D,e[20]=A,e[21]=R):R=e[21],R}const{load:m,update:d}=i,f=i.target.kind==="package"?i.target.target:null,g=d==="updating"||r?.kind==="running";let p;e[22]!==n||e[23]!==f||e[24]!==o||e[25]!==u?(p=async()=>{if(!f)return;await u(f)?W.success(o("settings.plugins.update.toast.done",{name:n})):W.error(o("settings.plugins.update.toast.failed",{name:n}))},e[22]=n,e[23]=f,e[24]=o,e[25]=u,e[26]=p):p=e[26];const h=p;let w;e:{switch(m.kind){case"active":{let y;e[27]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(J,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]"}),e[27]=y):y=e[27];let N;e[28]!==m.version||e[29]!==o?(N=m.version?o("settings.plugins.status.loadedVersion",{version:m.version}):o("settings.plugins.status.loaded"),e[28]=m.version,e[29]=o,e[30]=N):N=e[30];let x;e[31]!==N?(x=s.jsxs("p",{className:"typography-meta flex items-center gap-1.5 text-muted-foreground",children:[y,N]}),e[31]=N,e[32]=x):x=e[32],w=x;break e}case"notReported":{let y;e[33]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(J,{name:"time",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),e[33]=y):y=e[33];let N;e[34]!==o?(N=o("settings.plugins.status.notReported.title"),e[34]=o,e[35]=N):N=e[35];let x;e[36]!==N?(x=s.jsx("p",{className:"typography-label text-foreground",children:N}),e[36]=N,e[37]=x):x=e[37];let I;e[38]!==o?(I=o("settings.plugins.status.notReported.description"),e[38]=o,e[39]=I):I=e[39];let j;e[40]!==I?(j=s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:I}),e[40]=I,e[41]=j):j=e[41];let D;e[42]!==x||e[43]!==j?(D=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[y,s.jsxs("div",{className:"flex-1 min-w-0",children:[x,j]})]}),e[42]=x,e[43]=j,e[44]=D):D=e[44],w=D;break e}case"failed":{let y;e[45]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(J,{name:"error-warning",className:"h-5 w-5 text-[var(--status-error)] shrink-0 mt-0.5"}),e[45]=y):y=e[45];let N;e[46]!==o?(N=o("settings.plugins.status.failed.title"),e[46]=o,e[47]=N):N=e[47];let x;e[48]!==N?(x=s.jsx("p",{className:"typography-label text-[var(--status-error)]",children:N}),e[48]=N,e[49]=x):x=e[49];let I;e[50]!==m.error?(I=s.jsx("p",{className:"typography-micro font-mono text-foreground mt-1 whitespace-pre-wrap break-words",children:m.error}),e[50]=m.error,e[51]=I):I=e[51];let j;e[52]!==m.ref||e[53]!==o?(j=m.ref?s.jsx("p",{className:"typography-micro text-muted-foreground mt-1",children:o("settings.plugins.status.failed.ref",{ref:m.ref})}):null,e[52]=m.ref,e[53]=o,e[54]=j):j=e[54];let D;e[55]!==x||e[56]!==I||e[57]!==j?(D=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[y,s.jsxs("div",{className:"flex-1 min-w-0",children:[x,I,j]})]}),e[55]=x,e[56]=I,e[57]=j,e[58]=D):D=e[58],w=D;break e}}w=void 0}const b=w,k=f!==null&&(d!=="none"||r!==null);let v;e[59]!==h||e[60]!==g||e[61]!==r||e[62]!==k||e[63]!==o?(v=k?s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx(J,{name:"arrow-up",className:"h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label text-[var(--status-success)]",children:o("settings.plugins.update.available.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:o("settings.plugins.update.available.description")}),r?.kind==="failed"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-micro text-[var(--status-error)] mt-2",children:o("settings.plugins.update.failed.title")}),s.jsx("p",{className:"typography-micro font-mono text-foreground mt-0.5 whitespace-pre-wrap break-words",children:r.error})]}):null]}),s.jsx(q,{variant:"default",size:"sm",onClick:()=>{h()},disabled:g,children:g?s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"loader-4",className:"size-4 animate-spin"}),o("settings.plugins.update.running")]}):o("settings.plugins.update.action")})]}):null,e[59]=h,e[60]=g,e[61]=r,e[62]=k,e[63]=o,e[64]=v):v=e[64];let S;return e[65]!==b||e[66]!==v?(S=s.jsxs("div",{className:"flex flex-col gap-3",children:[b,v]}),e[65]=b,e[66]=v,e[67]=S):S=e[67],S};function dx(t){return t.loadRuntime}function ux(t){return t.updatePackage}function Co(t){const e=t.trim();if(e.length===0)return{ok:!0,value:void 0};try{const a=JSON.parse(e);return a===null||typeof a!="object"||Array.isArray(a)?{ok:!1}:{ok:!0,value:a}}catch{return{ok:!1}}}function Io(t){return!t||Object.keys(t).length===0?"":JSON.stringify(t,null,2)}function Ac(t,e){if(t.trim()===e.trim())return!0;const a=Co(t),n=Co(e);return a.ok&&n.ok&&Io(a.value)===Io(n.value)}function mx(t){return{mode:"entry",scope:t.scope,spec:t.spec,optionsJson:Io(t.options),fileName:"",content:""}}function px(t,e){return{mode:"file",scope:t.scope,spec:"",optionsJson:"",fileName:t.fileName,content:e}}const Tc=t=>{const e=$e.c(4),{scope:a,label:n}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Me("typography-micro font-medium rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-muted-foreground","border border-[var(--interactive-border)]"),e[0]=o):o=e[0];let i;return e[1]!==n||e[2]!==a?(i=s.jsx("span",{className:o,"data-scope":a,children:n}),e[1]=n,e[2]=a,e[3]=i):i=e[3],i},gx=()=>{const t=$e.c(229),{t:e}=ze(),n=un(fx)?.trim()||sa(),o=Lt(hx),i=Lt(bx),r=o===n&&i===Qt(),l=Lt(xx),u=Lt(vx),m=Lt(yx),d=Lt(jx),f=Lt(kx),g=Lt(wx),p=Lt(Sx),h=Lt(Nx),w=Lt(Cx),b=Lt(Ix),k=Lt(Px),[v,S]=c.useState(!1),[y,N]=c.useState(null),[x,I]=c.useState(!1);let j;t[0]!==S?(j=()=>{const Qe=()=>S(!0);return window.addEventListener("openchamber:settings-open-plugin-add",Qe),()=>window.removeEventListener("openchamber:settings-open-plugin-add",Qe)},t[0]=S,t[1]=j):j=t[1];let D;t[2]===Symbol.for("react.memo_cache_sentinel")?(D=[],t[2]=D):D=t[2],c.useEffect(j,D);let C;t[3]===Symbol.for("react.memo_cache_sentinel")?(C=[],t[3]=C):C=t[3],c.useEffect(Tx,C);let P;t[4]!==u||t[5]!==l?(P=l?u.find(Qe=>Qe.id===l)??null:null,t[4]=u,t[5]=l,t[6]=P):P=t[6];const A=P;let R;t[7]!==m||t[8]!==l?(R=l?m.find(Qe=>Qe.id===l)??null:null,t[7]=m,t[8]=l,t[9]=R):R=t[9];const K=R;let F;t[10]!==A?(F=A?Cu(A.spec,A.sourcePath):null,t[10]=A,t[11]=F):F=t[11];const T=F;let O;t[12]!==K?(O=K?Iu(K.absolutePath):null,t[12]=K,t[13]=O):O=t[13];const E=O,[B,_]=c.useState(!1);let H;t[14]===Symbol.for("react.memo_cache_sentinel")?(H=new Map,t[14]=H):H=t[14];const ne=c.useRef(H),z=c.useRef(null),$=JSON.stringify([n,l]);let V;t[15]!==r||t[16]!==n||t[17]!==$||t[18]!==h||t[19]!==A||t[20]!==K||t[21]!==f||t[22]!==_?(V=()=>{let Qe=!1;if(!r){z.current=null,f(null);return}const lt=(Ye,at)=>{if(Lt.getState().selectedId!==Ye||sa()!==n)return;const dt=z.current,_e=Lt.getState().draft,nt=dt?.id===Ye&&dt.directory===n&&_e!==null&&(_e.spec!==dt.value.spec||!Ac(_e.optionsJson,dt.value.optionsJson)||_e.content!==dt.value.content);z.current={id:Ye,directory:n,value:at},nt||f(at)};return A?(lt(A.id,mx(A)),()=>{Qe=!0}):K?(_(z.current?.id!==K.id||z.current.directory!==n),(async()=>{const Ye=await h(K.id);if(Qe||sa()!==n)return;_(!1);const at=Ye?.content??"";ne.current.set($,at),lt(K.id,px(K,at))})(),()=>{Qe=!0}):(z.current=null,f(null),()=>{Qe=!0})},t[15]=r,t[16]=n,t[17]=$,t[18]=h,t[19]=A,t[20]=K,t[21]=f,t[22]=_,t[23]=V):V=t[23];let G;t[24]!==r||t[25]!==n||t[26]!==$||t[27]!==h||t[28]!==A||t[29]!==K||t[30]!==f?(G=[A,K,h,f,r,n,$],t[24]=r,t[25]=n,t[26]=$,t[27]=h,t[28]=A,t[29]=K,t[30]=f,t[31]=G):G=t[31],c.useEffect(V,G);let ee;t[32]!==r||t[33]!==n||t[34]!==d||t[35]!==$||t[36]!==A||t[37]!==K||t[38]!==e||t[39]!==g||t[40]!==p?(ee=async()=>{if(!d||!r||sa()!==n)return Es;if(A&&d.mode==="entry"){const Qe=d.spec.trim();if(Qe===A.spec&&Ac(d.optionsJson,Io(A.options)))return Es;if(!Qe)return gs(e("settings.plugins.validation.specRequired"));const Ye=Co(d.optionsJson);if(!Ye.ok)return gs(e("settings.plugins.page.field.options.invalidJson"));const at=await g(A.id,{spec:Qe,options:Ye.value});return at.ok?at.reloadFailed?gs(at.warning||at.message||e("settings.plugins.toast.reloadFailed")):bn:gs(at.message||e("settings.plugins.toast.reloadFailed"))}if(K&&d.mode==="file"){const Qe=ne.current.get($)??"";if(d.content===Qe)return Es;const lt=await p(K.id,{content:d.content});return lt.ok?(ne.current.set($,d.content),lt.reloadFailed?gs(lt.warning||lt.message||e("settings.plugins.toast.reloadFailed")):bn):gs(lt.message||e("settings.plugins.toast.reloadFailed"))}return Es},t[32]=r,t[33]=n,t[34]=d,t[35]=$,t[36]=A,t[37]=K,t[38]=e,t[39]=g,t[40]=p,t[41]=ee):ee=t[41];const X=Ya(ee);let Q;t[42]!==b||t[43]!==k||t[44]!==y||t[45]!==N||t[46]!==I||t[47]!==e?(Q=async()=>{if(!y)return;I(!0);const Qe=y.kind==="entry"?await b(y.id):await k(y.id);Qe.ok?W.success(Qe.message||e("settings.plugins.sidebar.toast.deleted",{name:y.label})):W.error(e("settings.plugins.sidebar.toast.deleteFailed")),N(null),I(!1)},t[42]=b,t[43]=k,t[44]=y,t[45]=N,t[46]=I,t[47]=e,t[48]=Q):Q=t[48];const le=Q;let Z;t[49]!==v||t[50]!==S?(Z=s.jsx(Bb,{open:v,onOpenChange:S}),t[49]=v,t[50]=S,t[51]=Z):Z=t[51];const fe=y!==null;let Y;t[52]!==x||t[53]!==N?(Y=Qe=>{!Qe&&!x&&N(null)},t[52]=x,t[53]=N,t[54]=Y):Y=t[54];let be;t[55]!==e?(be=e("settings.plugins.sidebar.deleteDialog.title"),t[55]=e,t[56]=be):be=t[56];let Ee;t[57]!==be?(Ee=s.jsx(_t,{children:be}),t[57]=be,t[58]=Ee):Ee=t[58];const se=y?.label??"";let re;t[59]!==e||t[60]!==se?(re=e("settings.plugins.sidebar.deleteDialog.description",{name:se}),t[59]=e,t[60]=se,t[61]=re):re=t[61];let je;t[62]!==re?(je=s.jsx(Vt,{children:re}),t[62]=re,t[63]=je):je=t[63];let ie;t[64]!==Ee||t[65]!==je?(ie=s.jsxs(Bt,{children:[Ee,je]}),t[64]=Ee,t[65]=je,t[66]=ie):ie=t[66];let Pe;t[67]!==N?(Pe=()=>N(null),t[67]=N,t[68]=Pe):Pe=t[68];let ke;t[69]!==e?(ke=e("settings.common.actions.cancel"),t[69]=e,t[70]=ke):ke=t[70];let Ae;t[71]!==x||t[72]!==Pe||t[73]!==ke?(Ae=s.jsx(q,{size:"sm",variant:"ghost",onClick:Pe,disabled:x,children:ke}),t[71]=x,t[72]=Pe,t[73]=ke,t[74]=Ae):Ae=t[74];let Te;t[75]!==le?(Te=()=>{le()},t[75]=le,t[76]=Te):Te=t[76];let Ke;t[77]!==x||t[78]!==e?(Ke=e(x?"settings.plugins.sidebar.actions.deleting":"settings.common.actions.delete"),t[77]=x,t[78]=e,t[79]=Ke):Ke=t[79];let ge;t[80]!==x||t[81]!==Te||t[82]!==Ke?(ge=s.jsx(q,{size:"sm",variant:"destructive",onClick:Te,disabled:x,children:Ke}),t[80]=x,t[81]=Te,t[82]=Ke,t[83]=ge):ge=t[83];let Re;t[84]!==Ae||t[85]!==ge?(Re=s.jsxs(ts,{children:[Ae,ge]}),t[84]=Ae,t[85]=ge,t[86]=Re):Re=t[86];let Oe;t[87]!==ie||t[88]!==Re?(Oe=s.jsxs(zt,{className:"max-w-md",children:[ie,Re]}),t[87]=ie,t[88]=Re,t[89]=Oe):Oe=t[89];let pe;t[90]!==fe||t[91]!==Y||t[92]!==Oe?(pe=s.jsx(Kt,{open:fe,onOpenChange:Y,children:Oe}),t[90]=fe,t[91]=Y,t[92]=Oe,t[93]=pe):pe=t[93];let xe;t[94]!==Z||t[95]!==pe?(xe=s.jsxs(s.Fragment,{children:[Z,pe]}),t[94]=Z,t[95]=pe,t[96]=xe):xe=t[96];const Ne=xe;if(!l){let Qe;t[97]!==S?(Qe=()=>S(!0),t[97]=S,t[98]=Qe):Qe=t[98];let lt;t[99]!==N||t[100]!==Qe?(lt=s.jsx(Jb,{onAdd:Qe,onDelete:N}),t[99]=N,t[100]=Qe,t[101]=lt):lt=t[101];let Ye;return t[102]!==Ne||t[103]!==lt?(Ye=s.jsxs(s.Fragment,{children:[lt,Ne]}),t[102]=Ne,t[103]=lt,t[104]=Ye):Ye=t[104],Ye}let de;t[105]!==e?(de=e("settings.plugins.page.back"),t[105]=e,t[106]=de):de=t[106];let Ue;t[107]!==w?(Ue=()=>w(null),t[107]=w,t[108]=Ue):Ue=t[108];let Ie;t[109]!==de||t[110]!==Ue?(Ie=s.jsx(ko,{label:de,onClick:Ue}),t[109]=de,t[110]=Ue,t[111]=Ie):Ie=t[111];const De=Ie;let Je;t[112]!==A||t[113]!==K||t[114]!==N?(Je=()=>{A?N({kind:"entry",id:A.id,label:A.spec}):K&&N({kind:"file",id:K.id,label:K.fileName})},t[112]=A,t[113]=K,t[114]=N,t[115]=Je):Je=t[115];let tt;t[116]===Symbol.for("react.memo_cache_sentinel")?(tt=s.jsx(J,{name:"delete-bin",className:"size-3.5"}),t[116]=tt):tt=t[116];let mt;t[117]!==e?(mt=e("settings.common.actions.delete"),t[117]=e,t[118]=mt):mt=t[118];let ht;t[119]!==Je||t[120]!==mt?(ht=s.jsxs(q,{variant:"ghost",size:"xs",className:"!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:Je,children:[tt,mt]}),t[119]=Je,t[120]=mt,t[121]=ht):ht=t[121];const ft=ht;if(A&&d&&d.mode==="entry"){let Qe;t[122]!==d.optionsJson?(Qe=Co(d.optionsJson),t[122]=d.optionsJson,t[123]=Qe):Qe=t[123];const Ye=Qe.ok;let at;t[124]!==e?(at=e("settings.plugins.page.header.entry"),t[124]=e,t[125]=at):at=t[125];let dt;t[126]!==A.scope||t[127]!==e?(dt=A.scope==="project"?e("settings.plugins.sidebar.group.projectEntries"):e("settings.plugins.sidebar.group.userEntries"),t[126]=A.scope,t[127]=e,t[128]=dt):dt=t[128];let _e;t[129]!==A.scope||t[130]!==dt?(_e=s.jsx(Tc,{scope:A.scope,label:dt}),t[129]=A.scope,t[130]=dt,t[131]=_e):_e=t[131];const nt=X.onBlurCapture;let te;t[132]!==A.spec||t[133]!==T?(te=s.jsx(Pc,{target:T,name:A.spec}),t[132]=A.spec,t[133]=T,t[134]=te):te=t[134];let ue;t[135]!==A.id||t[136]!==A.spec?(ue=s.jsx(cx,{entryId:A.id,spec:A.spec}),t[135]=A.id,t[136]=A.spec,t[137]=ue):ue=t[137];let he;t[138]!==te||t[139]!==ue?(he=s.jsx(He,{divider:!1,children:s.jsxs("div",{className:"flex flex-col gap-3",children:[te,ue]})}),t[138]=te,t[139]=ue,t[140]=he):he=t[140];let ye;t[141]!==e?(ye=e("settings.plugins.page.field.spec"),t[141]=e,t[142]=ye):ye=t[142];const qe=d.spec;let Ze;t[143]!==d||t[144]!==f?(Ze=We=>f({...d,spec:We.target.value}),t[143]=d,t[144]=f,t[145]=Ze):Ze=t[145];let pt;t[146]!==e?(pt=e("settings.plugins.page.field.spec.placeholder"),t[146]=e,t[147]=pt):pt=t[147];let vt;t[148]!==d.spec||t[149]!==Ze||t[150]!==pt?(vt=s.jsx(Ve,{value:qe,onChange:Ze,placeholder:pt,className:"font-mono typography-meta",spellCheck:!1}),t[148]=d.spec,t[149]=Ze,t[150]=pt,t[151]=vt):vt=t[151];let bt;t[152]!==ye||t[153]!==vt?(bt=s.jsx(He,{title:ye,settingsItem:"plugins.spec",children:vt}),t[152]=ye,t[153]=vt,t[154]=bt):bt=t[154];let wt;t[155]!==e?(wt=e("settings.plugins.page.field.options"),t[155]=e,t[156]=wt):wt=t[156];const Et=d.optionsJson;let Le;t[157]!==d||t[158]!==f?(Le=We=>f({...d,optionsJson:We.target.value}),t[157]=d,t[158]=f,t[159]=Le):Le=t[159];const Xe=!Ye&&"border-[var(--status-error-border)]";let gt;t[160]!==Xe?(gt=Me("font-mono typography-meta min-h-[200px]",Xe),t[160]=Xe,t[161]=gt):gt=t[161];let jt;t[162]!==d.optionsJson||t[163]!==Le||t[164]!==gt?(jt=s.jsx(ws,{value:Et,onChange:Le,rows:10,className:gt,spellCheck:!1,placeholder:"{ }"}),t[162]=d.optionsJson,t[163]=Le,t[164]=gt,t[165]=jt):jt=t[165];let L;t[166]!==Ye||t[167]!==e?(L=!Ye&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:e("settings.plugins.page.field.options.invalidJson")}),t[166]=Ye,t[167]=e,t[168]=L):L=t[168];let me;t[169]!==wt||t[170]!==jt||t[171]!==L?(me=s.jsxs(He,{title:wt,settingsItem:"plugins.options",children:[jt,L]}),t[169]=wt,t[170]=jt,t[171]=L,t[172]=me):me=t[172];let Se;t[173]!==X.onBlurCapture||t[174]!==De||t[175]!==ft||t[176]!==at||t[177]!==_e||t[178]!==he||t[179]!==bt||t[180]!==me?(Se=s.jsxs(Yt,{title:at,titleLeading:De,headerEnd:ft,titleAccessory:_e,onBlurCapture:nt,children:[he,bt,me]}),t[173]=X.onBlurCapture,t[174]=De,t[175]=ft,t[176]=at,t[177]=_e,t[178]=he,t[179]=bt,t[180]=me,t[181]=Se):Se=t[181];let Ce;return t[182]!==Ne||t[183]!==Se?(Ce=s.jsxs(s.Fragment,{children:[Se,Ne]}),t[182]=Ne,t[183]=Se,t[184]=Ce):Ce=t[184],Ce}if(K&&d&&d.mode==="file"){let Qe;t[185]!==e?(Qe=e("settings.plugins.page.header.file"),t[185]=e,t[186]=Qe):Qe=t[186];let lt;t[187]!==K.scope||t[188]!==e?(lt=K.scope==="project"?e("settings.plugins.sidebar.group.projectFiles"):e("settings.plugins.sidebar.group.userFiles"),t[187]=K.scope,t[188]=e,t[189]=lt):lt=t[189];let Ye;t[190]!==K.scope||t[191]!==lt?(Ye=s.jsx(Tc,{scope:K.scope,label:lt}),t[190]=K.scope,t[191]=lt,t[192]=Ye):Ye=t[192];let at;t[193]===Symbol.for("react.memo_cache_sentinel")?(at=Me("typography-micro font-mono rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-foreground","border border-[var(--interactive-border)]"),t[193]=at):at=t[193];let dt;t[194]!==K.fileName?(dt=s.jsx("span",{className:at,children:K.fileName}),t[194]=K.fileName,t[195]=dt):dt=t[195];let _e;t[196]!==Ye||t[197]!==dt?(_e=s.jsxs(s.Fragment,{children:[Ye,dt]}),t[196]=Ye,t[197]=dt,t[198]=_e):_e=t[198];const nt=X.onBlurCapture;let te;t[199]!==K.fileName||t[200]!==E?(te=s.jsx(He,{divider:!1,children:s.jsx(Pc,{target:E,name:K.fileName})}),t[199]=K.fileName,t[200]=E,t[201]=te):te=t[201];let ue;t[202]!==e?(ue=e("settings.plugins.page.field.content"),t[202]=e,t[203]=ue):ue=t[203];let he;t[204]!==d||t[205]!==f?(he=bt=>f({...d,content:bt.target.value}),t[204]=d,t[205]=f,t[206]=he):he=t[206];let ye;t[207]!==X?(ye=bt=>{bt.key==="Enter"&&(bt.metaKey||bt.ctrlKey)&&(bt.preventDefault(),X.requestSave())},t[207]=X,t[208]=ye):ye=t[208];let qe;t[209]!==d.content||t[210]!==B||t[211]!==he||t[212]!==ye?(qe=s.jsx(ws,{value:d.content,onChange:he,onKeyDown:ye,rows:16,className:"font-mono typography-meta min-h-[320px]",spellCheck:!1,disabled:B}),t[209]=d.content,t[210]=B,t[211]=he,t[212]=ye,t[213]=qe):qe=t[213];let Ze;t[214]!==ue||t[215]!==qe?(Ze=s.jsx(He,{title:ue,settingsItem:"plugins.content",children:qe}),t[214]=ue,t[215]=qe,t[216]=Ze):Ze=t[216];let pt;t[217]!==X.onBlurCapture||t[218]!==De||t[219]!==ft||t[220]!==Qe||t[221]!==_e||t[222]!==te||t[223]!==Ze?(pt=s.jsxs(Yt,{title:Qe,titleLeading:De,headerEnd:ft,titleAccessory:_e,onBlurCapture:nt,children:[te,Ze]}),t[217]=X.onBlurCapture,t[218]=De,t[219]=ft,t[220]=Qe,t[221]=_e,t[222]=te,t[223]=Ze,t[224]=pt):pt=t[224];let vt;return t[225]!==Ne||t[226]!==pt?(vt=s.jsxs(s.Fragment,{children:[pt,Ne]}),t[225]=Ne,t[226]=pt,t[227]=vt):vt=t[227],vt}let xt;return t[228]===Symbol.for("react.memo_cache_sentinel")?(xt=s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx("div",{className:"text-center text-muted-foreground",children:s.jsx(J,{name:"loader-4",className:"mx-auto mb-3 h-6 w-6 animate-spin opacity-50"})})}),t[228]=xt):xt=t[228],xt};function fx(t){return t.getActiveProject()?.path}function hx(t){return t.loadedDirectory}function bx(t){return t.loadedRuntimeKey}function xx(t){return t.selectedId}function vx(t){return t.entries}function yx(t){return t.files}function jx(t){return t.draft}function kx(t){return t.setDraft}function wx(t){return t.updateEntry}function Sx(t){return t.updateFile}function Nx(t){return t.readFile}function Cx(t){return t.setSelected}function Ix(t){return t.deleteEntry}function Px(t){return t.deleteFile}function Ax(){Lt.getState().setSelected(null)}function Tx(){return Ax}const Ex="<built-in>",Ha=t=>t?.path===Ex,el=t=>!!t&&!Ha(t)&&t.renamable===!0,Xi=t=>{if(Ha(t))return t.name;const e=t.path.split(/[\\/]/).filter(Boolean),a=e.at(-1)??"";return a==="SKILL.md"?e.at(-2)??t.name:a.endsWith(".md")?a.slice(0,-3):t.name},Mx=t=>{const e=$e.c(167),{onItemSelect:a}=t,{t:n}=ze(),[o,i]=c.useState(""),[r,l]=c.useState(null),[u,m]=c.useState(""),[d,f]=c.useState(null),[g,p]=c.useState(!1),[h,w]=c.useState(null),{selectedSkillName:b,setSelectedSkill:k,setSkillDraft:v,deleteSkill:S,renameSkill:y,getSkillDetail:N}=Ws(Ms(Dx)),x=Us();let I;e[0]!==x?(I=L=>pl(L,x),e[0]=x,e[1]=I):I=e[1];const j=Ws(I),D=El(x),C=Ws(Rx);let P,A;e[2]!==C||e[3]!==x?(P=()=>{C(x)},A=[C,x],e[2]=C,e[3]=x,e[4]=P,e[5]=A):(P=e[4],A=e[5]),c.useEffect(P,A);let R;e[6]!==a||e[7]!==k||e[8]!==v||e[9]!==j?(R=()=>{let L="new-skill",me=1;for(;j.some(Se=>Se.name===L);)L=`new-skill-${me}`,me++;v({name:L,scope:"user",source:"opencode",description:""}),k(L),a?.()},e[6]=a,e[7]=k,e[8]=v,e[9]=j,e[10]=R):R=e[10];const K=R;let F;e[11]===Symbol.for("react.memo_cache_sentinel")?(F=async L=>{Ha(L)||f(L)},e[11]=F):F=e[11];const T=F;let O;e[12]!==d||e[13]!==S||e[14]!==x||e[15]!==n?(O=async()=>{if(!d)return;if(Ha(d)){f(null);return}p(!0),await S(d.name,x)?(W.success(n("settings.skills.sidebar.toast.skillDeleted",{name:d.name})),f(null)):W.error(n("settings.skills.sidebar.toast.deleteSkillFailed")),p(!1)},e[12]=d,e[13]=S,e[14]=x,e[15]=n,e[16]=O):O=e[16];const E=O;let B;e[17]!==N||e[18]!==k||e[19]!==v||e[20]!==x||e[21]!==j||e[22]!==n?(B=async L=>{if(Ha(L))return;const me=L.name;let Se=1,Ce=`${me}-copy`;for(;j.some(ce=>ce.name===Ce);)Se++,Ce=`${me}-copy-${Se}`;const We=await N(L.name,x);if(!We){W.error(n("settings.skills.sidebar.toast.duplicateLoadFailed"));return}v({name:Ce,scope:L.scope||"user",source:L.source||"opencode",description:(We.sources.md.fields.includes("description"),""),instructions:""}),k(Ce)},e[17]=N,e[18]=k,e[19]=v,e[20]=x,e[21]=j,e[22]=n,e[23]=B):B=e[23];const _=B;let H;e[24]===Symbol.for("react.memo_cache_sentinel")?(H=L=>{el(L)&&(m(L.name),l(L))},e[24]=H):H=e[24];const ne=H;let z;e[25]!==r||e[26]!==u||e[27]!==y||e[28]!==k||e[29]!==x||e[30]!==j||e[31]!==n?(z=async()=>{if(!r)return;if(!el(r)){l(null);return}const L=u.trim().replace(/\s+/g,"-").toLowerCase();if(!L){W.error(n("settings.skills.page.toast.skillNameRequired"));return}if(L===r.name){l(null);return}if(j.some(Se=>Se.name===L)){W.error(n("settings.skills.page.toast.skillExists"));return}await y(r.name,L,x)?(W.success(n("settings.skills.sidebar.toast.skillRenamed",{name:L})),k(L)):W.error(n("settings.skills.sidebar.toast.renameFailed")),l(null)},e[25]=r,e[26]=u,e[27]=y,e[28]=k,e[29]=x,e[30]=j,e[31]=n,e[32]=z):z=e[32];const $=z;let V,G,ee;if(e[33]!==o||e[34]!==j){let L;e[38]!==o?(L=me=>Ci([me.name,me.description],o),e[38]=o,e[39]=L):L=e[39],G=j.filter(L),V=G.filter(Fx),ee=G.filter(Ox),e[33]=o,e[34]=j,e[35]=V,e[36]=G,e[37]=ee}else V=e[35],G=e[36],ee=e[37];const ae=ee;let X;e[40]===Symbol.for("react.memo_cache_sentinel")?(X=function(me){const Se={},Ce=[];for(const ce of me)ce.group?(Se[ce.group]||(Se[ce.group]=[]),Se[ce.group].push(ce)):Ce.push(ce);const We=Object.keys(Se).sort(Lx).map(ce=>({name:ce,skills:[...Se[ce]].sort(Kx)}));return Ce.sort(zx),{sortedGroups:We,ungrouped:Ce}},e[40]=X):X=e[40];const Q=X;let le;e[41]!==V?(le=Q(V),e[41]=V,e[42]=le):le=e[42];const Z=le;let fe;e[43]!==ae?(fe=Q(ae),e[43]=ae,e[44]=fe):fe=e[44];const Y=fe;let be;e[45]===Symbol.for("react.memo_cache_sentinel")?(be=Me("flex h-full flex-col","bg-background"),e[45]=be):be=e[45];let Ee;e[46]!==n?(Ee=n("settings.skills.sidebar.title"),e[46]=n,e[47]=Ee):Ee=e[47];let se;e[48]!==Ee?(se=s.jsx("h2",{className:`${On} mb-3`,children:Ee}),e[48]=Ee,e[49]=se):se=e[49];let re;e[50]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(Oi,{className:"mb-3"}),e[50]=re):re=e[50];let je;e[51]!==j.length||e[52]!==n?(je=n("settings.skills.sidebar.total",{count:j.length}),e[51]=j.length,e[52]=n,e[53]=je):je=e[53];let ie;e[54]!==je?(ie=s.jsx("span",{className:"typography-meta text-muted-foreground",children:je}),e[54]=je,e[55]=ie):ie=e[55];let Pe;e[56]===Symbol.for("react.memo_cache_sentinel")?(Pe=s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),e[56]=Pe):Pe=e[56];let ke;e[57]!==K?(ke=s.jsx(q,{size:"sm","data-settings-item":"skills.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:K,children:Pe}),e[57]=K,e[58]=ke):ke=e[58];let Ae;e[59]!==ie||e[60]!==ke?(Ae=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ie,ke]}),e[59]=ie,e[60]=ke,e[61]=Ae):Ae=e[61];let Te;e[62]!==o||e[63]!==j.length?(Te=j.length>0?s.jsx(Il,{value:o,onChange:i}):null,e[62]=o,e[63]=j.length,e[64]=Te):Te=e[64];let Ke;e[65]!==se||e[66]!==Ae||e[67]!==Te?(Ke=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[se,re,Ae,Te]}),e[65]=se,e[66]=Ae,e[67]=Te,e[68]=Ke):Ke=e[68];let ge;e[69]!==Z||e[70]!==Y||e[71]!==_||e[72]!==D||e[73]!==a||e[74]!==h||e[75]!==V||e[76]!==o||e[77]!==b||e[78]!==k||e[79]!==G||e[80]!==j.length||e[81]!==n||e[82]!==ae?(ge=s.jsx(Ts,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:j.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(J,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.skills.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.skills.sidebar.empty.description")})]}):G.length===0?s.jsx(Pl,{query:o}):s.jsxs(s.Fragment,{children:[V.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.skills.sidebar.section.project")}),Z.sortedGroups.map(L=>{const{name:me,skills:Se}=L;return s.jsx(Zr,{label:me,count:Se.length,storageKey:"project-skills",children:Se.map(Ce=>s.jsx(eo,{skill:Ce,blocked:D(`skill:${Xi(Ce)}`),isSelected:b===Ce.name,onSelect:()=>{k(Ce.name),a?.()},onRename:()=>ne(Ce),onDelete:()=>T(Ce),onDuplicate:()=>_(Ce),isMenuOpen:h===Ce.name,onMenuOpenChange:We=>w(We?Ce.name:null)},Ce.name))},me)}),Z.ungrouped.map(L=>s.jsx(eo,{skill:L,blocked:D(`skill:${Xi(L)}`),isSelected:b===L.name,onSelect:()=>{k(L.name),a?.()},onRename:()=>ne(L),onDelete:()=>T(L),onDuplicate:()=>_(L),isMenuOpen:h===L.name,onMenuOpenChange:me=>w(me?L.name:null)},L.name))]}),ae.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.skills.sidebar.section.user")}),Y.sortedGroups.map(L=>{const{name:me,skills:Se}=L;return s.jsx(Zr,{label:me,count:Se.length,storageKey:"user-skills",children:Se.map(Ce=>s.jsx(eo,{skill:Ce,blocked:D(`skill:${Xi(Ce)}`),isSelected:b===Ce.name,onSelect:()=>{k(Ce.name),a?.()},onRename:()=>ne(Ce),onDelete:()=>T(Ce),onDuplicate:()=>_(Ce),isMenuOpen:h===Ce.name,onMenuOpenChange:We=>w(We?Ce.name:null)},Ce.name))},me)}),Y.ungrouped.map(L=>s.jsx(eo,{skill:L,blocked:D(`skill:${Xi(L)}`),isSelected:b===L.name,onSelect:()=>{k(L.name),a?.()},onRename:()=>ne(L),onDelete:()=>T(L),onDuplicate:()=>_(L),isMenuOpen:h===L.name,onMenuOpenChange:me=>w(me?L.name:null)},L.name))]})]})}),e[69]=Z,e[70]=Y,e[71]=_,e[72]=D,e[73]=a,e[74]=h,e[75]=V,e[76]=o,e[77]=b,e[78]=k,e[79]=G,e[80]=j.length,e[81]=n,e[82]=ae,e[83]=ge):ge=e[83];const Re=d!==null;let Oe;e[84]!==g?(Oe=L=>{!L&&!g&&f(null)},e[84]=g,e[85]=Oe):Oe=e[85];let pe;e[86]!==n?(pe=n("settings.skills.sidebar.deleteDialog.title"),e[86]=n,e[87]=pe):pe=e[87];let xe;e[88]!==pe?(xe=s.jsx(_t,{children:pe}),e[88]=pe,e[89]=xe):xe=e[89];const Ne=d?.name??"";let de;e[90]!==n||e[91]!==Ne?(de=n("settings.skills.sidebar.deleteDialog.description",{name:Ne}),e[90]=n,e[91]=Ne,e[92]=de):de=e[92];let Ue;e[93]!==de?(Ue=s.jsx(Vt,{children:de}),e[93]=de,e[94]=Ue):Ue=e[94];let Ie;e[95]!==xe||e[96]!==Ue?(Ie=s.jsxs(Bt,{children:[xe,Ue]}),e[95]=xe,e[96]=Ue,e[97]=Ie):Ie=e[97];let De;e[98]===Symbol.for("react.memo_cache_sentinel")?(De=()=>f(null),e[98]=De):De=e[98];let Je;e[99]!==n?(Je=n("settings.common.actions.cancel"),e[99]=n,e[100]=Je):Je=e[100];let tt;e[101]!==g||e[102]!==Je?(tt=s.jsx(q,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:De,disabled:g,children:Je}),e[101]=g,e[102]=Je,e[103]=tt):tt=e[103];let mt;e[104]!==n?(mt=n("settings.common.actions.delete"),e[104]=n,e[105]=mt):mt=e[105];let ht;e[106]!==E||e[107]!==g||e[108]!==mt?(ht=s.jsx(q,{size:"sm",onClick:E,disabled:g,children:mt}),e[106]=E,e[107]=g,e[108]=mt,e[109]=ht):ht=e[109];let ft;e[110]!==tt||e[111]!==ht?(ft=s.jsxs(ts,{children:[tt,ht]}),e[110]=tt,e[111]=ht,e[112]=ft):ft=e[112];let xt;e[113]!==Ie||e[114]!==ft?(xt=s.jsxs(zt,{className:"max-w-md",children:[Ie,ft]}),e[113]=Ie,e[114]=ft,e[115]=xt):xt=e[115];let Qe;e[116]!==Re||e[117]!==Oe||e[118]!==xt?(Qe=s.jsx(Kt,{open:Re,onOpenChange:Oe,children:xt}),e[116]=Re,e[117]=Oe,e[118]=xt,e[119]=Qe):Qe=e[119];const lt=r!==null;let Ye;e[120]===Symbol.for("react.memo_cache_sentinel")?(Ye=L=>!L&&l(null),e[120]=Ye):Ye=e[120];let at;e[121]!==n?(at=n("settings.skills.sidebar.renameDialog.title"),e[121]=n,e[122]=at):at=e[122];let dt;e[123]!==at?(dt=s.jsx(_t,{children:at}),e[123]=at,e[124]=dt):dt=e[124];const _e=r?.name??"";let nt;e[125]!==n||e[126]!==_e?(nt=n("settings.skills.sidebar.renameDialog.description",{name:_e}),e[125]=n,e[126]=_e,e[127]=nt):nt=e[127];let te;e[128]!==nt?(te=s.jsx(Vt,{children:nt}),e[128]=nt,e[129]=te):te=e[129];let ue;e[130]!==dt||e[131]!==te?(ue=s.jsxs(Bt,{children:[dt,te]}),e[130]=dt,e[131]=te,e[132]=ue):ue=e[132];let he;e[133]===Symbol.for("react.memo_cache_sentinel")?(he=L=>m(L.target.value),e[133]=he):he=e[133];let ye;e[134]!==n?(ye=n("settings.skills.sidebar.renameDialog.placeholder"),e[134]=n,e[135]=ye):ye=e[135];let qe;e[136]!==$?(qe=L=>{L.key==="Enter"&&$()},e[136]=$,e[137]=qe):qe=e[137];let Ze;e[138]!==u||e[139]!==ye||e[140]!==qe?(Ze=s.jsx(Ve,{value:u,onChange:he,placeholder:ye,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:qe}),e[138]=u,e[139]=ye,e[140]=qe,e[141]=Ze):Ze=e[141];let pt;e[142]===Symbol.for("react.memo_cache_sentinel")?(pt=()=>l(null),e[142]=pt):pt=e[142];let vt;e[143]!==n?(vt=n("settings.common.actions.cancel"),e[143]=n,e[144]=vt):vt=e[144];let bt;e[145]!==vt?(bt=s.jsx(q,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:pt,children:vt}),e[145]=vt,e[146]=bt):bt=e[146];let wt;e[147]!==n?(wt=n("settings.common.actions.rename"),e[147]=n,e[148]=wt):wt=e[148];let Et;e[149]!==$||e[150]!==wt?(Et=s.jsx(q,{size:"sm",onClick:$,children:wt}),e[149]=$,e[150]=wt,e[151]=Et):Et=e[151];let Le;e[152]!==bt||e[153]!==Et?(Le=s.jsxs(ts,{children:[bt,Et]}),e[152]=bt,e[153]=Et,e[154]=Le):Le=e[154];let Xe;e[155]!==ue||e[156]!==Ze||e[157]!==Le?(Xe=s.jsxs(zt,{children:[ue,Ze,Le]}),e[155]=ue,e[156]=Ze,e[157]=Le,e[158]=Xe):Xe=e[158];let gt;e[159]!==lt||e[160]!==Xe?(gt=s.jsx(Kt,{open:lt,onOpenChange:Ye,children:Xe}),e[159]=lt,e[160]=Xe,e[161]=gt):gt=e[161];let jt;return e[162]!==Ke||e[163]!==ge||e[164]!==Qe||e[165]!==gt?(jt=s.jsxs("div",{className:be,children:[Ke,ge,Qe,gt]}),e[162]=Ke,e[163]=ge,e[164]=Qe,e[165]=gt,e[166]=jt):jt=e[166],jt},eo=t=>{const e=$e.c(50),{skill:a,blocked:n,isSelected:o,onSelect:i,onDelete:r,onRename:l,onDuplicate:u,isMenuOpen:m,onMenuOpenChange:d}=t,{t:f}=ze();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=ul(),e[0]=g):g=e[0];const p=g;let h;e[1]!==a?(h=Ha(a),e[1]=a,e[2]=h):h=e[2];const w=h;let b;e[3]!==a?(b=el(a),e[3]=a,e[4]=b):b=e[4];const k=b,[v,S]=c.useState(!1);let y;e[5]!==k||e[6]!==r||e[7]!==u||e[8]!==l||e[9]!==f?(y=ne=>s.jsxs(s.Fragment,{children:[k?s.jsxs(ne,{onClick:z=>{z.stopPropagation(),l()},children:[s.jsx(J,{name:"edit",className:"h-4 w-4 me-px"}),f("settings.common.actions.rename")]}):null,s.jsxs(ne,{onClick:z=>{z.stopPropagation(),u()},children:[s.jsx(J,{name:"file-copy",className:"h-4 w-4 me-px"}),f("settings.common.actions.duplicate")]}),s.jsxs(ne,{onClick:z=>{z.stopPropagation(),r()},className:"text-destructive focus:text-destructive",children:[s.jsx(J,{name:"delete-bin",className:"h-4 w-4 me-px"}),f("settings.common.actions.delete")]})]}),e[5]=k,e[6]=r,e[7]=u,e[8]=l,e[9]=f,e[10]=y):y=e[10];const N=y,x=!w&&v,I=o?"bg-interactive-selection":"hover:bg-interactive-hover";let j;e[11]!==I?(j=Me("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",I),e[11]=I,e[12]=j):j=e[12];let D;e[13]!==w?(D=!p&&!w?ne=>{ne.preventDefault(),S(!0)}:void 0,e[13]=w,e[14]=D):D=e[14];let C;e[15]!==j||e[16]!==D?(C=s.jsx("div",{className:j,onContextMenu:D}),e[15]=j,e[16]=D,e[17]=C):C=e[17];const P=n?"text-muted-foreground":"text-foreground";let A;e[18]!==P?(A=Me("typography-ui-label font-normal truncate",P),e[18]=P,e[19]=A):A=e[19];let R;e[20]!==a.name||e[21]!==A?(R=s.jsx("span",{className:A,children:a.name}),e[20]=a.name,e[21]=A,e[22]=R):R=e[22];let K;e[23]!==n||e[24]!==f?(K=n?s.jsx("span",{className:"typography-micro shrink-0 text-[var(--status-warning)]",title:f("settings.skills.sidebar.blockedByPolicyHint"),children:f("settings.skills.sidebar.blockedByPolicy")}):null,e[23]=n,e[24]=f,e[25]=K):K=e[25];let F;e[26]!==R||e[27]!==K?(F=s.jsxs("div",{className:"flex items-center gap-1.5",children:[R,K]}),e[26]=R,e[27]=K,e[28]=F):F=e[28];let T;e[29]!==i||e[30]!==F?(T=s.jsx("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:F}),e[29]=i,e[30]=F,e[31]=T):T=e[31];let O;e[32]!==w||e[33]!==m||e[34]!==d||e[35]!==N?(O=w?null:s.jsxs(ga,{open:m,onOpenChange:ne=>{ne&&S(!1),d(ne)},children:[s.jsx(pa,{asChild:!0,children:s.jsx(q,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(J,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(ma,{align:"end",className:"w-fit min-w-20",children:N(Bn)})]}),e[32]=w,e[33]=m,e[34]=d,e[35]=N,e[36]=O):O=e[36];let E;e[37]!==T||e[38]!==O?(E=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[T,O]}),e[37]=T,e[38]=O,e[39]=E):E=e[39];let B;e[40]!==E||e[41]!==C?(B=s.jsx(Mi,{render:C,children:E}),e[40]=E,e[41]=C,e[42]=B):B=e[42];let _;e[43]!==w||e[44]!==N?(_=w?null:s.jsx(Ti,{className:"w-fit min-w-20",children:N(Ei)}),e[43]=w,e[44]=N,e[45]=_):_=e[45];let H;return e[46]!==B||e[47]!==_||e[48]!==x?(H=s.jsxs(Di,{open:x,onOpenChange:S,children:[B,_]}),e[46]=B,e[47]=_,e[48]=x,e[49]=H):H=e[49],H};function Dx(t){return{selectedSkillName:t.selectedSkillName,setSelectedSkill:t.setSelectedSkill,setSkillDraft:t.setSkillDraft,deleteSkill:t.deleteSkill,renameSkill:t.renameSkill,getSkillDetail:t.getSkillDetail}}function Rx(t){return t.loadSkills}function Fx(t){return t.scope==="project"}function Ox(t){return t.scope==="user"}function Lx(t,e){return t.localeCompare(e)}function Kx(t,e){return t.name.localeCompare(e.name)}function zx(t,e){return t.name.localeCompare(e.name)}const Ux=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,$x=t=>{const e=t.trim(),a=e.startsWith("https://")?"https":e.startsWith("git@")?"ssh":"shorthand";if(a==="ssh")return`${e.split(":")[1].replace(/\.git$/i,"")}`;if(a==="https")return e.split("/").slice(3).filter(Boolean).join("/").replace(/\.git$/i,"");const n=e.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return n?`${n[1]}/${n[2].replace(/\.git$/i,"")}`:e},Bx=t=>t.transport==="account"&&!!t.account||t.transport==="ssh"&&!!t.sshCredentialId,_x=({open:t,onOpenChange:e,catalogId:a=null})=>{const{t:n}=ze(),o=fn(E=>E.scanRepo),i=fn(E=>E.loadCatalog),r=fn(E=>E.loadSource),l=fn(E=>E.setSelectedSource),u=fn(E=>E.isScanning),m=aa(E=>E.profiles),d=aa(E=>E.loadProfiles),[f,g]=c.useState(""),[p,h]=c.useState(""),[w,b]=c.useState(""),[k,v]=c.useState(null),[S,y]=c.useState(null),[N,x]=c.useState(!1),[I,j]=c.useState(null),D=c.useRef(0),C=c.useRef(0),P=c.useCallback(()=>{D.current+=1,x(!1),y(null)},[]);c.useEffect(()=>{if(!t)return;const E=++C.current;return D.current+=1,g(""),h(""),b(""),y(null),x(!1),j(null),d(),v(null),(async()=>{const B=await xn();if(C.current!==E)return;const _=B?B.skillCatalogs??[]:null;if(v(_),!_||!a)return;const H=_.find(ne=>ne.id===a);H&&(g(H.label),h(H.source),b(H.subpath??""),j(H.gitIdentityId??null),x(!1))})(),()=>{C.current+=1,D.current+=1}},[t,a,d]);const A=c.useMemo(()=>m.filter(Bx),[m]),R=!I||I===Hm||m.some(E=>E.id===I&&wg(E)==="system")?"none":I,K=m.find(E=>E.id===R),F=c.useMemo(()=>{const E=p.trim(),B=w.trim();return(k??[]).some(_=>{if(_.id===a)return!1;const H=(_.source||"").trim(),ne=(_.subpath||"").trim();return H===E&&ne===B})},[a,k,p,w]),T=async()=>{const E=p.trim();if(!E){W.error(n("settings.skills.catalog.add.toast.repositoryRequired"));return}f.trim()||g($x(E)),x(!1),y(null);const B=D.current+1;D.current=B;const _=await o({source:E,subpath:w.trim()||void 0,gitIdentityId:I||void 0});if(D.current!==B)return;if(!_.ok){if(_.error?.kind==="authRequired"){if(cs()){W.error(n("settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode"));return}W.error(n("settings.skills.catalog.add.toast.authenticationRequiredScan"));return}W.error(_.error?.message||n("settings.skills.catalog.add.toast.scanFailed"));return}const H=_.items?.length||0;if(y(H),H===0){W.error(n("settings.skills.catalog.add.toast.noSkillsFound")),x(!1);return}x(!0),W.success(n("settings.skills.catalog.shared.toast.foundSkills",{count:H}))},O=async()=>{const E=f.trim(),B=p.trim(),_=w.trim();if(!E){W.error(n("settings.skills.catalog.add.toast.catalogNameRequired"));return}if(!B){W.error(n("settings.skills.catalog.add.toast.repositoryRequired"));return}const H=k?.find(V=>V.id===a);if((!a||!H||H.source!==B||(H.subpath??"")!==_||(H.gitIdentityId??null)!==I)&&!N){W.error(n("settings.skills.catalog.add.toast.scanBeforeAdd"));return}if(F){W.error(n("settings.skills.catalog.add.toast.catalogAlreadyExists"));return}const z={id:a??Ux(),label:E,source:B};if(_&&(z.subpath=_),I&&(z.gitIdentityId=I),k===null){W.error(n("settings.skills.catalog.add.toast.saveFailed"));return}if(a&&!H){W.error(n("settings.skills.catalog.add.toast.saveFailed"));return}const $=a?k.map(V=>V.id===a?z:V):[...k,z];try{if(!(await yt({skillCatalogs:$})).ok)throw new Error(n("settings.skills.catalog.add.toast.saveFailed"));v($),await i({refresh:!0})&&await r(z.id,{refresh:!0}),l(z.id),e(!1)}catch(V){W.error(V instanceof Error?V.message:n("settings.skills.catalog.add.toast.saveFailed"))}};return s.jsx(Kt,{open:t,onOpenChange:e,children:s.jsxs(zt,{className:"max-w-xl",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:n(a?"settings.skills.catalog.edit.title":"settings.skills.catalog.add.title")}),s.jsxs(Vt,{children:[n("settings.skills.catalog.add.descriptionPrefix")," ",s.jsx("code",{className:"font-mono",children:"SKILL.md"}),n("settings.skills.catalog.add.descriptionSuffix")]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:n("settings.skills.catalog.add.field.catalogName")}),s.jsx(Ve,{value:f,onChange:E=>g(E.target.value),placeholder:n("settings.skills.catalog.add.field.catalogNamePlaceholder")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:n("settings.skills.catalog.add.field.repository")}),s.jsx(qt,{children:n("settings.skills.catalog.add.field.repositoryHint")})]}),s.jsx(Ve,{value:p,onChange:E=>{h(E.target.value),P()},placeholder:n("settings.skills.catalog.shared.field.repositoryPlaceholder")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:n("settings.skills.catalog.add.field.optionalSubpath")}),s.jsx(Ve,{value:w,onChange:E=>{b(E.target.value),P()},placeholder:n("settings.skills.catalog.shared.field.subpathPlaceholder")})]}),(A.length>0||R!=="none")&&!cs()?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:n("settings.skills.catalog.shared.auth.description")}),s.jsx(qt,{children:n("settings.skills.catalog.shared.auth.footerHint")})]}),s.jsxs(Tt,{value:R,onValueChange:E=>{j(E==="none"?null:E),P()},children:[s.jsx(Pt,{className:"w-fit","aria-label":n("settings.skills.catalog.shared.auth.description"),children:s.jsx("span",{children:R==="none"?n("settings.skills.catalog.shared.auth.default"):K?.name??R})}),s.jsxs(At,{align:"start",className:"max-w-80",portalToBody:!0,children:[s.jsxs(ot,{value:"none",children:[s.jsx(J,{name:"terminal-box",className:"size-4"}),s.jsxs("span",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:n("settings.skills.catalog.shared.auth.default")}),s.jsx("span",{className:"typography-meta text-muted-foreground whitespace-normal",children:n("settings.skills.catalog.shared.auth.defaultHint")})]})]}),R!=="none"&&!A.some(E=>E.id===R)&&s.jsx(ot,{value:R,disabled:!0,children:K?.name??R}),A.map(E=>s.jsxs(ot,{value:E.id,children:[s.jsx(J,{name:E.transport==="ssh"?"key":E.account?.provider==="gitlab"?"gitlab":"github",className:"size-4"}),s.jsxs("span",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:E.name}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:E.transport==="ssh"?n("settings.skills.catalog.shared.auth.sshHint"):n("settings.skills.catalog.shared.auth.accountHint")})]})]},E.id))]})]})]}):null,S!==null?s.jsx("div",{className:"typography-meta text-muted-foreground",children:n("settings.skills.catalog.add.scanResult",{count:S})}):null,F?s.jsx("div",{className:"typography-meta text-muted-foreground",children:n("settings.skills.catalog.add.duplicateMessage")}):null]}),s.jsxs(ts,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:n("settings.common.actions.cancel")}),s.jsxs(q,{size:"sm",className:"gap-2",variant:"ghost",onClick:()=>{T()},disabled:u||!p.trim(),children:[s.jsx(J,{name:"git-repository",className:"h-4 w-4"}),n(u?"settings.skills.catalog.shared.actions.scanning":"settings.skills.catalog.shared.actions.scan")]}),s.jsx(q,{size:"sm",onClick:()=>{O()},disabled:F||k===null||!f.trim()||!p.trim()||(!a||!k.some(E=>E.id===a&&E.source===p.trim()&&(E.subpath??"")===w.trim()&&(E.gitIdentityId??null)===I))&&!N,children:n(a?"settings.skills.catalog.edit.actions.save":"settings.skills.catalog.add.actions.addCatalog")})]})]})})},Vx=t=>{const e=$e.c(85),{open:a,onOpenChange:n,conflicts:o,onConfirm:i}=t,{t:r}=ze();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[u,m]=c.useState(l);let d,f;e[1]!==o||e[2]!==a?(d=()=>{if(!a)return;const ae={};for(const X of o)ae[X.skillName]="skip";m(ae)},f=[a,o],e[1]=o,e[2]=a,e[3]=d,e[4]=f):(d=e[3],f=e[4]),c.useEffect(d,f);let g;e[5]!==o?(g=ae=>{const X={};for(const Q of o)X[Q.skillName]=ae;m(X)},e[5]=o,e[6]=g):g=e[6];const p=g;let h;e[7]!==o||e[8]!==u?(h=o.length>0&&o.every(ae=>u[ae.skillName]),e[7]=o,e[8]=u,e[9]=h):h=e[9];const w=h;let b;e[10]!==r?(b=r("settings.skills.catalog.conflicts.title"),e[10]=r,e[11]=b):b=e[11];let k;e[12]!==b?(k=s.jsx(_t,{children:b}),e[12]=b,e[13]=k):k=e[13];let v;e[14]!==r?(v=r("settings.skills.catalog.conflicts.description"),e[14]=r,e[15]=v):v=e[15];let S;e[16]!==v?(S=s.jsx(Vt,{children:v}),e[16]=v,e[17]=S):S=e[17];let y;e[18]!==k||e[19]!==S?(y=s.jsxs(Bt,{children:[k,S]}),e[18]=k,e[19]=S,e[20]=y):y=e[20];let N;e[21]!==o.length||e[22]!==r?(N=r("settings.skills.catalog.conflicts.count",{count:o.length}),e[21]=o.length,e[22]=r,e[23]=N):N=e[23];let x;e[24]!==N?(x=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[24]=N,e[25]=x):x=e[25];let I;e[26]!==p?(I=()=>p("skip"),e[26]=p,e[27]=I):I=e[27];let j;e[28]!==r?(j=r("settings.skills.catalog.conflicts.actions.skipAll"),e[28]=r,e[29]=j):j=e[29];let D;e[30]!==I||e[31]!==j?(D=s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:I,children:j}),e[30]=I,e[31]=j,e[32]=D):D=e[32];let C;e[33]!==p?(C=()=>p("overwrite"),e[33]=p,e[34]=C):C=e[34];let P;e[35]!==r?(P=r("settings.skills.catalog.conflicts.actions.overwriteAll"),e[35]=r,e[36]=P):P=e[36];let A;e[37]!==C||e[38]!==P?(A=s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:C,children:P}),e[37]=C,e[38]=P,e[39]=A):A=e[39];let R;e[40]!==D||e[41]!==A?(R=s.jsxs("div",{className:"flex items-center gap-2",children:[D,A]}),e[40]=D,e[41]=A,e[42]=R):R=e[42];let K;e[43]!==x||e[44]!==R?(K=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[x,R]}),e[43]=x,e[44]=R,e[45]=K):K=e[45];let F;if(e[46]!==o||e[47]!==u||e[48]!==r){let ae;e[50]!==u||e[51]!==r?(ae=X=>s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label truncate",children:X.skillName}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:r("settings.skills.catalog.conflicts.installedIn",{scope:X.scope==="project"?r("settings.skills.catalog.conflicts.scope.project"):r("settings.skills.catalog.conflicts.scope.user"),source:X.source==="agents"?r("settings.skills.catalog.conflicts.source.agents"):r("settings.skills.catalog.conflicts.source.opencode")})})]}),s.jsxs(Tt,{value:u[X.skillName]||"skip",onValueChange:Q=>m(le=>({...le,[X.skillName]:Q})),children:[s.jsx(Pt,{className:"w-fit",children:s.jsx("span",{className:"capitalize",children:(u[X.skillName]||"skip")==="overwrite"?r("settings.skills.catalog.conflicts.decision.overwrite"):r("settings.skills.catalog.conflicts.decision.skip")})}),s.jsxs(At,{align:"end",children:[s.jsx(ot,{value:"skip",className:"pe-2 [&>span:first-child]:hidden",children:r("settings.skills.catalog.conflicts.decision.skip")}),s.jsx(ot,{value:"overwrite",className:"pe-2 [&>span:first-child]:hidden",children:r("settings.skills.catalog.conflicts.decision.overwrite")})]})]})]},X.skillName),e[50]=u,e[51]=r,e[52]=ae):ae=e[52],F=o.map(ae),e[46]=o,e[47]=u,e[48]=r,e[49]=F}else F=e[49];let T;e[53]!==F?(T=s.jsx("div",{className:"space-y-2",children:F}),e[53]=F,e[54]=T):T=e[54];let O;e[55]!==K||e[56]!==T?(O=s.jsxs("div",{className:"space-y-3",children:[K,T]}),e[55]=K,e[56]=T,e[57]=O):O=e[57];let E;e[58]!==n?(E=()=>n(!1),e[58]=n,e[59]=E):E=e[59];let B;e[60]!==r?(B=r("settings.common.actions.cancel"),e[60]=r,e[61]=B):B=e[61];let _;e[62]!==E||e[63]!==B?(_=s.jsx(q,{size:"sm",variant:"ghost",onClick:E,children:B}),e[62]=E,e[63]=B,e[64]=_):_=e[64];let H;e[65]!==u||e[66]!==i?(H=()=>i(u),e[65]=u,e[66]=i,e[67]=H):H=e[67];const ne=!w;let z;e[68]!==r?(z=r("settings.skills.catalog.conflicts.actions.continue"),e[68]=r,e[69]=z):z=e[69];let $;e[70]!==H||e[71]!==ne||e[72]!==z?($=s.jsx(q,{size:"sm",onClick:H,disabled:ne,children:z}),e[70]=H,e[71]=ne,e[72]=z,e[73]=$):$=e[73];let V;e[74]!==_||e[75]!==$?(V=s.jsxs(ts,{children:[_,$]}),e[74]=_,e[75]=$,e[76]=V):V=e[76];let G;e[77]!==y||e[78]!==O||e[79]!==V?(G=s.jsxs(zt,{className:"max-w-2xl",children:[y,O,V]}),e[77]=y,e[78]=O,e[79]=V,e[80]=G):G=e[80];let ee;return e[81]!==n||e[82]!==a||e[83]!==G?(ee=s.jsx(Kt,{open:a,onOpenChange:n,children:G}),e[81]=n,e[82]=a,e[83]=G,e[84]=ee):ee=e[84],ee},Po=[{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 Ni(t,e){return t==="project"&&e==="claude"?"project-claude":t==="project"&&e==="agents"?"project-agents":e==="claude"?"user-claude":t==="project"?"project-opencode":e==="agents"?"user-agents":"user-opencode"}function Mu(t){if(t==="user-claude")return{scope:"user",source:"claude"};if(t==="project-claude")return{scope:"project",source:"claude"};const e=Po.find(a=>a.value===t);return e?{scope:e.scope,source:e.source}:{scope:"user",source:"opencode"}}const Hx=t=>{const e=$e.c(125),{open:a,onOpenChange:n,items:o}=t,{t:i}=ze(),r=fn(qx),l=fn(Wx),u=fn(Gx),[m,d]=c.useState("user"),[f,g]=c.useState("opencode"),p=un(Jx),h=un(Qx),[w,b]=c.useState(null),[k,v]=c.useState(!1);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[0]=S):S=e[0];const[y,N]=c.useState(S),[x,I]=c.useState(null);let j,D;e[1]!==h||e[2]!==a?(j=()=>{a&&(d("user"),g("opencode"),b(h),v(!1),N([]),I(null))},D=[a,h],e[1]=h,e[2]=a,e[3]=j,e[4]=D):(j=e[3],D=e[4]),c.useEffect(j,D);let C;e[5]!==i?(C=Ie=>{switch(Ie){case"project-opencode":return i("settings.skills.location.option.projectOpencode.label");case"user-agents":return i("settings.skills.location.option.userAgents.label");case"project-agents":return i("settings.skills.location.option.projectAgents.label");default:return i("settings.skills.location.option.userOpencode.label")}},e[5]=i,e[6]=C):C=e[6];const P=C;let A;e[7]!==i?(A=Ie=>{switch(Ie){case"project-opencode":return i("settings.skills.location.option.projectOpencode.description");case"user-agents":return i("settings.skills.location.option.userAgents.description");case"project-agents":return i("settings.skills.location.option.projectAgents.description");default:return i("settings.skills.location.option.userOpencode.description")}},e[7]=i,e[8]=A):A=e[8];const R=A;let K;e:{if(p.length===0){K=null;break e}if(w&&p.some(Ie=>Ie.id===w)){K=w;break e}if(h&&p.some(Ie=>Ie.id===h)){K=h;break e}K=p[0]?.id??null}const F=K;let T;e:{if(m!=="project"){T=null;break e}const Ie=F;if(!Ie){T=null;break e}let De;if(e[9]!==Ie||e[10]!==p){let tt;e[12]!==Ie?(tt=mt=>mt.id===Ie,e[12]=Ie,e[13]=tt):tt=e[13],De=p.find(tt),e[9]=Ie,e[10]=p,e[11]=De}else De=e[11];T=De?.path??null}const O=T;let E;e[14]!==r||e[15]!==o||e[16]!==l||e[17]!==n||e[18]!==i?(E=async Ie=>{const De=await r({source:Ie.source,subpath:Ie.subpath,sourceId:o[0]?.sourceId,gitIdentityId:o[0]?.gitIdentityId,scope:Ie.scope,targetSource:Ie.targetSource,selections:Ie.skillDirs.map(Yx),conflictPolicy:"prompt",conflictDecisions:Ie.conflictDecisions},{directory:Ie.directoryOverride??null});if(De.ok){const Je=De.skipped??[];Je.length>0?W.warning(i("settings.skills.catalog.installSkill.toast.skipped",{skills:Je.map(Zx).join(", ")})):W.success(i("settings.skills.catalog.installSkill.toast.installed")),n(!1),await Promise.all([...new Set(o.map(Xx))].map(tt=>l(tt,{refresh:!0})));return}if(De.error?.kind==="conflicts"){I({source:Ie.source,subpath:Ie.subpath,scope:Ie.scope,targetSource:Ie.targetSource,skillDirs:Ie.skillDirs,directoryOverride:Ie.directoryOverride??null}),N(De.error.conflicts),v(!0);return}if(De.error?.kind==="authRequired"){W.error(De.error.message||i("settings.skills.catalog.installSkill.toast.authRequired"));return}W.error(De.error?.message||i("settings.skills.catalog.installSkill.toast.installFailed"))},e[14]=r,e[15]=o,e[16]=l,e[17]=n,e[18]=i,e[19]=E):E=e[19];const B=E;if(o.length===0)return null;let _;e[20]!==o.length||e[21]!==i?(_=o.length===1?i("settings.skills.catalog.installSkill.title"):i("settings.skills.catalog.installFromRepo.title"),e[20]=o.length,e[21]=i,e[22]=_):_=e[22];let H;e[23]!==_?(H=s.jsx(_t,{children:_}),e[23]=_,e[24]=H):H=e[24];let ne;e[25]!==o[0].skillName||e[26]!==o.length||e[27]!==i?(ne=o.length===1?s.jsxs(s.Fragment,{children:[i("settings.skills.catalog.installSkill.descriptionPrefix")," ",s.jsx("span",{className:"font-semibold text-foreground",children:o[0].skillName})," ",i("settings.skills.catalog.installSkill.descriptionSuffix")]}):i("settings.skills.catalog.installFromRepo.selectedCount",{selected:o.length,total:o.length}),e[25]=o[0].skillName,e[26]=o.length,e[27]=i,e[28]=ne):ne=e[28];let z;e[29]!==ne?(z=s.jsx(Vt,{children:ne}),e[29]=ne,e[30]=z):z=e[30];let $;e[31]!==H||e[32]!==z?($=s.jsxs(Bt,{children:[H,z]}),e[31]=H,e[32]=z,e[33]=$):$=e[33];let V;e[34]!==i?(V=i("settings.skills.catalog.installSkill.field.destination"),e[34]=i,e[35]=V):V=e[35];let G;e[36]!==V?(G=s.jsx("span",{className:"typography-ui-label text-foreground",children:V}),e[36]=V,e[37]=G):G=e[37];let ee;e[38]!==m||e[39]!==f?(ee=Ni(m,f),e[38]=m,e[39]=f,e[40]=ee):ee=e[40];let ae;e[41]===Symbol.for("react.memo_cache_sentinel")?(ae=Ie=>{const De=Po.find(tt=>tt.value===Ie);if(!De)return;const Je=Mu(De.value);d(Je.scope),g(Je.source==="agents"?"agents":"opencode")},e[41]=ae):ae=e[41];let X;e[42]!==m?(X=m==="user"?s.jsx(J,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"folder",className:"h-3.5 w-3.5"}),e[42]=m,e[43]=X):X=e[43];let Q;e[44]!==f?(Q=f==="agents"?s.jsx(J,{name:"robot-2",className:"h-3.5 w-3.5"}):null,e[44]=f,e[45]=Q):Q=e[45];let le;e[46]!==P||e[47]!==m||e[48]!==f?(le=P(Ni(m,f)),e[46]=P,e[47]=m,e[48]=f,e[49]=le):le=e[49];let Z;e[50]!==le?(Z=s.jsx("span",{children:le}),e[50]=le,e[51]=Z):Z=e[51];let fe;e[52]!==X||e[53]!==Q||e[54]!==Z?(fe=s.jsxs(Pt,{className:"w-fit gap-1.5",children:[X,Q,Z]}),e[52]=X,e[53]=Q,e[54]=Z,e[55]=fe):fe=e[55];let Y;e[56]!==R||e[57]!==P?(Y=Po.map(Ie=>s.jsx(ot,{value:Ie.value,className:"pe-2 [&>span:first-child]:hidden",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ie.scope==="user"?s.jsx(J,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"folder",className:"h-3.5 w-3.5"}),Ie.source==="agents"?s.jsx(J,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:P(Ie.value)})]}),s.jsx("span",{className:"typography-micro text-muted-foreground ms-5",children:R(Ie.value)})]})},Ie.value)),e[56]=R,e[57]=P,e[58]=Y):Y=e[58];let be;e[59]!==Y?(be=s.jsx(At,{align:"start",portalToBody:!0,children:Y}),e[59]=Y,e[60]=be):be=e[60];let Ee;e[61]!==ee||e[62]!==fe||e[63]!==be?(Ee=s.jsxs(Tt,{value:ee,onValueChange:ae,children:[fe,be]}),e[61]=ee,e[62]=fe,e[63]=be,e[64]=Ee):Ee=e[64];let se;e[65]!==G||e[66]!==Ee?(se=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[G,Ee]}),e[65]=G,e[66]=Ee,e[67]=se):se=e[67];let re;e[68]!==p||e[69]!==F||e[70]!==m||e[71]!==i?(re=m==="project"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.skills.catalog.installSkill.field.project")}),p.length===0?s.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.skills.catalog.installSkill.field.noProjects")}):s.jsxs(Tt,{value:F??"",onValueChange:Ie=>b(Ie),disabled:p.length===1,children:[s.jsx(Pt,{className:"w-fit",children:s.jsx(Ut,{placeholder:i("settings.skills.catalog.installSkill.field.chooseProjectPlaceholder")})}),s.jsx(At,{align:"start",portalToBody:!0,children:p.map(ev)})]})]}),e[68]=p,e[69]=F,e[70]=m,e[71]=i,e[72]=re):re=e[72];let je;e[73]!==o?(je=o.flatMap(tv).length?s.jsx("div",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded",children:o.flatMap(sv).join(" · ")}):null,e[73]=o,e[74]=je):je=e[74];let ie;e[75]!==se||e[76]!==re||e[77]!==je?(ie=s.jsxs("div",{className:"mt-2 space-y-3",children:[se,re,je]}),e[75]=se,e[76]=re,e[77]=je,e[78]=ie):ie=e[78];let Pe;e[79]!==n?(Pe=()=>n(!1),e[79]=n,e[80]=Pe):Pe=e[80];let ke;e[81]!==i?(ke=i("settings.common.actions.cancel"),e[81]=i,e[82]=ke):ke=e[82];let Ae;e[83]!==Pe||e[84]!==ke?(Ae=s.jsx(q,{size:"sm",variant:"ghost",onClick:Pe,children:ke}),e[83]=Pe,e[84]=ke,e[85]=Ae):Ae=e[85];let Te;e[86]!==O||e[87]!==u||e[88]!==o||e[89]!==m?(Te=u||o.some(nv)||m==="project"&&!O,e[86]=O,e[87]=u,e[88]=o,e[89]=m,e[90]=Te):Te=e[90];let Ke;e[91]!==O||e[92]!==B||e[93]!==o||e[94]!==m||e[95]!==f?(Ke=()=>{B({source:o[0].repoSource,subpath:o[0].repoSubpath,scope:m,targetSource:f,skillDirs:o.map(av),directoryOverride:O})},e[91]=O,e[92]=B,e[93]=o,e[94]=m,e[95]=f,e[96]=Ke):Ke=e[96];let ge;e[97]!==u||e[98]!==i?(ge=i(u?"settings.skills.catalog.installSkill.actions.installing":"settings.skills.catalog.installSkill.actions.install"),e[97]=u,e[98]=i,e[99]=ge):ge=e[99];let Re;e[100]!==Te||e[101]!==Ke||e[102]!==ge?(Re=s.jsx(q,{size:"sm",disabled:Te,onClick:Ke,children:ge}),e[100]=Te,e[101]=Ke,e[102]=ge,e[103]=Re):Re=e[103];let Oe;e[104]!==Ae||e[105]!==Re?(Oe=s.jsxs(ts,{children:[Ae,Re]}),e[104]=Ae,e[105]=Re,e[106]=Oe):Oe=e[106];let pe;e[107]!==$||e[108]!==ie||e[109]!==Oe?(pe=s.jsxs(zt,{className:"max-w-md",children:[$,ie,Oe]}),e[107]=$,e[108]=ie,e[109]=Oe,e[110]=pe):pe=e[110];let xe;e[111]!==n||e[112]!==a||e[113]!==pe?(xe=s.jsx(Kt,{open:a,onOpenChange:n,children:pe}),e[111]=n,e[112]=a,e[113]=pe,e[114]=xe):xe=e[114];let Ne;e[115]!==x||e[116]!==B?(Ne=Ie=>{x&&(B({source:x.source,subpath:x.subpath,scope:x.scope,targetSource:x.targetSource,skillDirs:x.skillDirs,conflictDecisions:Ie,directoryOverride:x.directoryOverride??null}),v(!1))},e[115]=x,e[116]=B,e[117]=Ne):Ne=e[117];let de;e[118]!==y||e[119]!==k||e[120]!==Ne?(de=s.jsx(Vx,{open:k,onOpenChange:v,conflicts:y,onConfirm:Ne}),e[118]=y,e[119]=k,e[120]=Ne,e[121]=de):de=e[121];let Ue;return e[122]!==xe||e[123]!==de?(Ue=s.jsxs(s.Fragment,{children:[xe,de]}),e[122]=xe,e[123]=de,e[124]=Ue):Ue=e[124],Ue};function qx(t){return t.installSkills}function Wx(t){return t.loadSource}function Gx(t){return t.isInstalling}function Jx(t){return t.projects}function Qx(t){return t.activeProjectId}function Yx(t){return{skillDir:t}}function Zx(t){return`${t.skillName} (${t.reason})`}function Xx(t){return t.sourceId}function ev(t){return s.jsx(ot,{value:t.id,children:t.label||t.path},t.id)}function tv(t){return t.warnings??[]}function sv(t){return t.warnings??[]}function nv(t){return!t.installable}function av(t){return t.skillDir}const iv=/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,ov=t=>{const e=t.trim();return iv.test(e)?`https://github.com/${e}`:null},rv=t=>{const e=ov(t.repoSource);if(!e)return null;const a=[t.repoSubpath,t.skillDir].filter(Boolean).join("/");return a?`${e}/tree/HEAD/${a}`:e};let to=null;const lv=t=>{const e=xl();return(!to||to.locale!==e)&&(to={locale:e,formatter:new Intl.NumberFormat(e,{notation:"compact"})}),to.formatter.format(t)},cv=t=>{const e=Date.parse(t);if(Number.isNaN(e))return null;const a=Date.now()-e;if(a<6e4)return{key:"common.relative.justNow",count:0};const n=Math.floor(a/6e4);if(n<60)return{key:"common.relative.minutesAgoShort",count:n};const o=Math.floor(n/60);if(o<24)return{key:"common.relative.hoursAgoShort",count:o};const i=Math.floor(o/24);if(i<7)return{key:"common.relative.daysAgoShort",count:i};const r=Math.floor(i/7);return r<52?{key:"common.relative.weeksAgoShort",count:r}:{key:"common.relative.yearsAgoShort",count:Math.floor(i/365)}},dv=t=>{const e=$e.c(50),{source:a,isActive:n,isLoading:o,skillsCount:i,onSelect:r,t:l}=t,u=a.stars??null;let m,d,f,g,p,h,w,b,k,v;if(e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==i||e[4]!==a.label||e[5]!==a.repoUpdatedAt||e[6]!==a.source||e[7]!==u||e[8]!==l){const x=a.repoUpdatedAt?cv(a.repoUpdatedAt):null;b="button",k=r,v=n;const I=n?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-interactive-border-hover";e[19]!==I?(d=Me("oc-surface-elevated w-full min-h-24 text-start rounded-lg border bg-surface-elevated p-3.5 flex gap-3 items-start transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",I),e[19]=I,e[20]=d):d=e[20],p="min-w-0 flex-1 block";let j;e[21]!==a.label?(j=s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:a.label}),e[21]=a.label,e[22]=j):j=e[22];let D;e[23]!==o||e[24]!==i||e[25]!==l?(D=o?s.jsx(J,{name:"refresh",className:"h-3 w-3 animate-spin text-muted-foreground shrink-0"}):i!==null&&s.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:l("settings.skills.catalog.page.source.skillsCount",{count:i})}),e[23]=o,e[24]=i,e[25]=l,e[26]=D):D=e[26],e[27]!==j||e[28]!==D?(h=s.jsxs("span",{className:"flex items-center gap-2",children:[j,D]}),e[27]=j,e[28]=D,e[29]=h):h=e[29],e[30]!==a.source?(w=s.jsx("span",{className:"typography-micro font-mono text-muted-foreground block mt-0.5 truncate",children:a.source}),e[30]=a.source,e[31]=w):w=e[31],m="flex items-center gap-3 mt-1",e[32]!==u||e[33]!==l?(f=u!==null&&s.jsxs("span",{className:"typography-micro text-muted-foreground flex items-center gap-1",title:l("settings.skills.catalog.page.source.stars",{count:u}),children:[s.jsx(J,{name:"star",className:"h-3 w-3"}),lv(u)]}),e[32]=u,e[33]=l,e[34]=f):f=e[34],g=x&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:x.key==="common.relative.justNow"?l(x.key):l("settings.skills.catalog.page.source.updated",{time:l(x.key,{count:x.count})})}),e[0]=n,e[1]=o,e[2]=r,e[3]=i,e[4]=a.label,e[5]=a.repoUpdatedAt,e[6]=a.source,e[7]=u,e[8]=l,e[9]=m,e[10]=d,e[11]=f,e[12]=g,e[13]=p,e[14]=h,e[15]=w,e[16]=b,e[17]=k,e[18]=v}else m=e[9],d=e[10],f=e[11],g=e[12],p=e[13],h=e[14],w=e[15],b=e[16],k=e[17],v=e[18];let S;e[35]!==m||e[36]!==f||e[37]!==g?(S=s.jsxs("span",{className:m,children:[f,g]}),e[35]=m,e[36]=f,e[37]=g,e[38]=S):S=e[38];let y;e[39]!==S||e[40]!==p||e[41]!==h||e[42]!==w?(y=s.jsxs("span",{className:p,children:[h,w,S]}),e[39]=S,e[40]=p,e[41]=h,e[42]=w,e[43]=y):y=e[43];let N;return e[44]!==d||e[45]!==y||e[46]!==b||e[47]!==k||e[48]!==v?(N=s.jsx("button",{type:b,onClick:k,"aria-pressed":v,className:d,children:y}),e[44]=d,e[45]=y,e[46]=b,e[47]=k,e[48]=v,e[49]=N):N=e[49],N},uv=({mode:t,onModeChange:e,showModeTabs:a=!0})=>{const{t:n}=ze(),{sources:o,itemsBySource:i,selectedSourceId:r,setSelectedSource:l,loadCatalog:u,loadSource:m,isLoadingCatalog:d,isLoadingSource:f,loadedSourceIds:g,lastCatalogError:p}=fn(Ms(ie=>({sources:ie.sources,itemsBySource:ie.itemsBySource,selectedSourceId:ie.selectedSourceId,setSelectedSource:ie.setSelectedSource,loadCatalog:ie.loadCatalog,loadSource:ie.loadSource,isLoadingCatalog:ie.isLoadingCatalog,isLoadingSource:ie.isLoadingSource,loadedSourceIds:ie.loadedSourceIds,lastCatalogError:ie.lastCatalogError}))),[h,w]=c.useState(""),[b,k]=c.useState(!1),[v,S]=c.useState(null),[y,N]=c.useState(!1),[x,I]=c.useState([]),[j,D]=c.useState(new Set),[C,P]=c.useState([]),[A,R]=c.useState(!1),[K,F]=c.useState(!1),[T,O]=c.useState(!1),E=c.useRef(null),B=Ws(ie=>ie.deleteSkill),_=Us();c.useEffect(()=>{u()},[u]),c.useEffect(()=>{const ie=o.filter(Ae=>!g[Ae.id]);if(ie.length===0)return;let Pe=!1;return(async()=>{for(const Ae of ie){if(Pe)return;await m(Ae.id)}})(),()=>{Pe=!0}},[o,g,m]),c.useEffect(()=>{!r||g[r]||m(r)},[r,g,m]),c.useEffect(()=>{const ie=Pe=>{(Pe.metaKey||Pe.ctrlKey)&&Pe.key.toLowerCase()==="k"&&(Pe.preventDefault(),E.current?.focus())};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[]);const H=h.trim().length>0,ne=c.useMemo(()=>H?_n(o.flatMap(ie=>i[ie.id]||[]),h,ie=>[ie.skillName,ie.frontmatterName,ie.description]):r?i[r]||[]:[],[o,i,r,h,H]),z=c.useMemo(()=>o.find(ie=>ie.id===r)||null,[o,r]),$=!!(r&&r.startsWith("custom:")),V=c.useCallback(ie=>`${ie.sourceId}:${ie.skillDir}`,[]),G=c.useMemo(()=>ne.filter(ie=>j.has(V(ie))),[ne,V,j]),ee=G[0]?.sourceId??(H?ne.find(ie=>ie.installable||ie.installed?.isInstalled)?.sourceId:r),ae=G.filter(ie=>!ie.installed?.isInstalled),X=G.filter(ie=>ie.installed?.isInstalled),Q=ne.filter(ie=>(ie.installable||ie.installed?.isInstalled)&&ie.sourceId===ee),le=o.find(ie=>ie.id===ee)?.label,Z=Q.length>0&&Q.every(ie=>j.has(V(ie)));c.useEffect(()=>{const ie=new Set(ne.filter(Pe=>Pe.installable||Pe.installed?.isInstalled).map(V));D(Pe=>new Set([...Pe].filter(ke=>ie.has(ke))))},[ne,V]);const fe=(ie,Pe)=>{const ke=V(ie);D(Ae=>{const Te=ne.find(ge=>Ae.has(V(ge)));if(Pe&&Te&&Te.sourceId!==ie.sourceId)return Ae;const Ke=new Set(Ae);return Pe?Ke.add(ke):Ke.delete(ke),Ke})},Y=ie=>{D(Pe=>{const ke=new Set(Pe);for(const Ae of Q)ie?ke.add(V(Ae)):ke.delete(V(Ae));return ke})},be=ie=>{ie.length!==0&&(I(ie),N(!0))},Ee=async()=>{if(C.length===0)return;R(!0);const ie=[],Pe=new Set;for(const ke of C){const Ae=ke.installed?.scope==="project"?_:null;(ke.installed?.scope!=="project"||!!Ae)&&await B(ke.skillName,Ae)?(Pe.add(ke.sourceId),D(Ke=>{const ge=new Set(Ke);return ge.delete(V(ke)),ge})):ie.push(ke)}P(ie),await Promise.all([...Pe].map(ke=>m(ke,{refresh:!0}))),ie.length>0?W.error(n("settings.skills.sidebar.toast.deleteSkillFailed")):C.length===1?W.success(n("settings.skills.sidebar.toast.skillDeleted",{name:C[0].skillName})):W.success(n("settings.skills.catalog.page.toast.deleted",{count:C.length})),R(!1)},se=async()=>{if(!(!r||!$)){F(!0);try{const ie=await xn();if(!ie){W.error(n("settings.skills.catalog.add.toast.saveFailed"));return}const ke=(ie.skillCatalogs??[]).filter(Te=>Te.id!==r);if(!(await yt({skillCatalogs:ke})).ok){W.error(n("settings.skills.catalog.add.toast.saveFailed"));return}if(!await u({refresh:!0})){W.error(n("settings.skills.catalog.add.toast.saveFailed"));return}O(!1)}catch{W.error(n("settings.skills.catalog.add.toast.saveFailed"))}finally{F(!1)}}},re=H?n("settings.skills.catalog.page.list.searchTitle"):z?.label??"",je=!H&&r!==null&&!g[r]&&(f||d);return s.jsxs(s.Fragment,{children:[s.jsxs(Yt,{title:n("settings.skills.catalog.page.title"),showSaveStatus:!1,children:[a&&s.jsx("div",{className:"mb-4",children:s.jsx("div",{className:"h-7",children:s.jsx(fl,{items:[{id:"manual",label:n("settings.skills.catalog.page.mode.manual")},{id:"external",label:n("settings.skills.catalog.page.mode.external")}],activeId:t,onSelect:ie=>{(ie==="manual"||ie==="external")&&e(ie)},layoutMode:"fit",variant:"animated",animateActivePill:!1,className:"h-full"})})}),s.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:n("settings.skills.catalog.page.subtitle")}),s.jsx("div",{"data-settings-item":"skills.catalog.search",className:"mb-5",children:s.jsxs("div",{className:"relative max-w-md",children:[s.jsx(J,{name:"search",className:"absolute inset-s-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Ve,{ref:E,value:h,onChange:ie=>w(ie.target.value),placeholder:n("settings.skills.catalog.page.searchAllPlaceholder"),className:Me("h-8 ps-8 w-full",h&&"pe-8")}),h&&s.jsx("button",{type:"button",onClick:()=>{w(""),E.current?.focus()},className:"absolute inset-e-2 top-1/2 -translate-y-1/2 flex items-center justify-center h-4 w-4 rounded text-muted-foreground hover:text-foreground transition-colors",title:n("settings.skills.catalog.page.search.clear"),children:s.jsx(J,{name:"close",className:"h-3 w-3"})})]})}),s.jsx(He,{title:n("settings.skills.catalog.page.section.sources"),divider:!1,settingsItem:"skills.catalog.source",contentClassName:"space-y-0",children:s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 py-1.5",children:[o.map(ie=>s.jsx(dv,{source:ie,isActive:ie.id===r,isLoading:f&&!g[ie.id],skillsCount:g[ie.id]?(i[ie.id]||[]).length:null,onSelect:()=>l(ie.id),t:n},ie.id)),s.jsxs("button",{type:"button","data-settings-item":"skills.catalog.add-catalog",onClick:()=>{S(null),k(!0)},className:"min-h-24 text-start rounded-lg border border-dashed border-[var(--interactive-border)] hover:border-[var(--interactive-border-hover)] hover:bg-[var(--surface-muted)] p-3.5 flex gap-3 items-start transition-colors",children:[s.jsx("span",{className:"flex items-center justify-center rounded-md bg-transparent text-muted-foreground w-8 h-8 shrink-0",children:s.jsx(J,{name:"add",className:"h-4 w-4"})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground block",children:n("settings.skills.catalog.page.source.addOwnTitle")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 block mt-0.5",children:n("settings.skills.catalog.page.source.addOwnDescription")})]})]})]})}),p&&s.jsx(He,{children:s.jsxs("div",{className:"rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[s.jsx("div",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:n("settings.skills.catalog.page.error.catalogTitle")}),s.jsx("div",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:p.message}),p.kind==="authRequired"&&$&&s.jsx(q,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{S(r),k(!0)},children:n("settings.skills.catalog.page.actions.editCatalog")})]})}),s.jsxs(He,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 pb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"typography-micro font-medium uppercase tracking-wide text-muted-foreground truncate",children:re}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:n("settings.skills.catalog.page.foundCount",{count:ne.length})})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>{r&&!H?m(r,{refresh:!0}):u({refresh:!0})},disabled:d||f,title:n("settings.skills.catalog.page.actions.refreshTitle"),children:s.jsx(J,{name:"refresh",className:Me("h-3.5 w-3.5",(d||f)&&"animate-spin")})}),$&&!H&&s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>{S(r),k(!0)},title:n("settings.skills.catalog.page.actions.editCatalog"),children:s.jsx(J,{name:"edit",className:"h-3.5 w-3.5"})}),$&&!H&&s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>O(!0),disabled:K,title:n("settings.skills.catalog.page.actions.removeCatalogTitle"),children:s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),Q.length>0&&s.jsxs("div",{className:"flex items-center justify-between gap-3 pb-2 min-h-8",children:[s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(Pi,{checked:Z,indeterminate:G.length>0&&!Z,onChange:ie=>Y(ie),ariaLabel:n(Z?"settings.skills.catalog.page.actions.deselectAll":"settings.skills.catalog.installFromRepo.actions.selectAll")}),s.jsxs("span",{children:[n(Z?"settings.skills.catalog.page.actions.deselectAll":"settings.skills.catalog.installFromRepo.actions.selectAll"),H&&le?` · ${le}`:""]})]}),G.length>0&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:n("settings.skills.catalog.installFromRepo.selectedCount",{selected:G.length,total:Q.length})}),ae.length>0&&s.jsx(q,{size:"xs",onClick:()=>be(ae),children:n("settings.skills.catalog.installFromRepo.actions.installSelected")}),X.length>0&&s.jsx(q,{size:"xs",variant:"destructive",onClick:()=>P(X),children:n("settings.skills.catalog.page.actions.delete")})]})]}),je||f&&ne.length===0||d&&o.length===0?s.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[s.jsx(J,{name:"refresh",className:"mx-auto mb-3 h-5 w-5 animate-spin opacity-50"}),s.jsx("p",{className:"typography-meta",children:n("settings.skills.catalog.page.loading.skills")})]}):ne.length===0?s.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-body",children:n("settings.skills.catalog.page.empty.noSkillsTitle")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.skills.catalog.page.empty.noSkillsDescription")})]}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:ne.map(ie=>{const Pe=ie.installed?.isInstalled,ke=ie.installed?.scope,Ae=rv(ie);return s.jsx("div",{className:"py-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pi,{checked:j.has(V(ie)),onChange:Te=>fe(ie,Te),disabled:!Pe&&!ie.installable||G.length>0&&ee!==ie.sourceId,ariaLabel:`${n(Pe?"settings.skills.catalog.page.actions.delete":"settings.skills.catalog.shared.actions.install")} ${ie.skillName}`}),s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:ie.skillName}),Pe&&s.jsx("span",{className:"typography-micro text-[var(--status-success)] bg-[var(--status-success)]/10 px-1.5 py-0.5 rounded flex-shrink-0",children:n("settings.skills.catalog.page.badge.installed",{scope:ke||n("settings.skills.catalog.page.badge.unknown")})}),!ie.installable&&s.jsx("span",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0",children:n("settings.skills.catalog.page.badge.notInstallable")})]}),ie.description?s.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 line-clamp-2",children:ie.description}):s.jsx("div",{className:"typography-meta text-muted-foreground/50 mt-0.5 italic",children:n("settings.skills.catalog.shared.noDescription")}),s.jsxs("div",{className:"typography-micro text-muted-foreground/80 mt-1 flex items-center gap-2 min-w-0",children:[Ae?s.jsxs("a",{href:Ae,target:"_blank",rel:"noreferrer",className:"font-mono hover:underline truncate inline-flex items-center gap-1",title:n("settings.skills.catalog.page.skill.viewOnGithub"),children:[s.jsx(J,{name:"github",className:"h-3 w-3 shrink-0"}),ie.repoSource]}):s.jsx("span",{className:"font-mono truncate",children:ie.repoSource}),ie.skillDir&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"opacity-40",children:"·"}),s.jsx("span",{className:"truncate",children:ie.skillDir})]})]}),ie.warnings?.length?s.jsx("div",{className:"typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit",children:ie.warnings.join(" · ")}):null]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Ae&&s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>window.open(Ae,"_blank","noreferrer"),title:n("settings.skills.catalog.page.skill.viewOnGithub"),children:s.jsx(J,{name:"external-link",className:"h-3.5 w-3.5"})}),Pe?s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-[var(--status-success)] hover:text-[var(--status-error)]",onClick:()=>P([ie]),title:n("settings.skills.sidebar.deleteDialog.title"),children:s.jsx(J,{name:"check",className:"h-4 w-4"})}):s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",disabled:!ie.installable,onClick:()=>{be([ie])},children:n("settings.skills.catalog.shared.actions.install")})]})]})},`${ie.sourceId}:${ie.skillDir}`)})})]})]}),s.jsx(_x,{open:b,onOpenChange:k,catalogId:v}),s.jsx(Hx,{open:y,onOpenChange:N,items:x}),s.jsx(Kt,{open:C.length>0,onOpenChange:ie=>!ie&&!A&&P([]),children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:n("settings.skills.sidebar.deleteDialog.title")}),s.jsx(Vt,{children:C.length===1?n("settings.skills.sidebar.deleteDialog.description",{name:C[0].skillName}):C.map(ie=>ie.skillName).join(", ")})]}),s.jsxs(ts,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>P([]),disabled:A,children:n("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",variant:"destructive",onClick:()=>{Ee()},disabled:A,children:n("settings.common.actions.delete")})]})]})}),s.jsx(Kt,{open:T,onOpenChange:ie=>{K||O(ie)},children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:n("settings.skills.catalog.page.removeDialog.title")}),s.jsx(Vt,{children:n("settings.skills.catalog.page.removeDialog.description")})]}),s.jsxs(ts,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>O(!1),disabled:K,children:n("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",variant:"destructive",onClick:()=>{se()},disabled:K,children:n("settings.skills.catalog.page.actions.removeCatalog")})]})]})})]})},mv=()=>{const t=$e.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(uv,{mode:"external",onModeChange:xv,showModeTabs:!1}),t[0]=e):e=t[0],e},pv="SKILL.md",gv="h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]",mo=(t,e)=>{const a=Sf({description:t}).trimEnd(),n=e.trimStart();return`---
|
|
23
|
+
${a}
|
|
24
|
+
---${n?`
|
|
25
|
+
|
|
26
|
+
${n}`:`
|
|
27
|
+
`}`},fv=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Du=t=>{const e=t.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!e)return{description:null,instructions:t};let a=null;try{const n=Nf(e[1]);if(fv(n)){const o=n.description;typeof o=="string"&&(a=o)}}catch{a=null}return{description:a,instructions:e[2].replace(/^\r?\n/,"")}},hv=(t,e)=>{const a=Du(t);return mo(e,a.instructions)},bv=()=>{const{t}=ze(),{currentTheme:e}=ua(),{selectedSkillName:a,getSkillByName:n,getSkillDetail:o,createSkill:i,updateSkill:r,skillDraft:l,setSkillDraft:u,setSelectedSkill:m}=Ws(Ms(ue=>({selectedSkillName:ue.selectedSkillName,getSkillByName:ue.getSkillByName,getSkillDetail:ue.getSkillDetail,createSkill:ue.createSkill,updateSkill:ue.updateSkill,skillDraft:ue.skillDraft,setSkillDraft:ue.setSkillDraft,setSelectedSkill:ue.setSelectedSkill}))),d=Us(),f=Ws(ue=>pl(ue,d)),g=a?n(a,d):null,p=!!(l&&l.name===a&&!g),h=!!(a&&!g&&!l),w=g?.path==="<built-in>";c.useEffect(()=>{h&&m(null)},[h,m]);const[b,k]=c.useState(""),[v,S]=c.useState("user"),[y,N]=c.useState("opencode"),[x,I]=c.useState(""),[j,D]=c.useState(""),[C,P]=c.useState(!1),[A,R]=c.useState(()=>mo("","")),[K,F]=c.useState("edit"),[T,O]=c.useState([]),[E,B]=c.useState([]),[_,H]=c.useState(!1),[ne,z]=c.useState(!1),[$,V]=c.useState(""),[G,ee]=c.useState(""),[ae,X]=c.useState(!1),[Q,le]=c.useState(!1),[Z,fe]=c.useState(""),[Y,be]=c.useState(""),[Ee,se]=c.useState(null),[re,je]=c.useState(!1),[ie,Pe]=c.useState(""),[ke,Ae]=c.useState(null),[Te,Ke]=c.useState(!1),ge=Ee?Y!==ie:Z.trim()!=="",Re=c.useCallback(ue=>{switch(ue){case"project-opencode":return t("settings.skills.location.option.projectOpencode.label");case"user-claude":return t("settings.skills.location.option.userClaude.label");case"project-claude":return t("settings.skills.location.option.projectClaude.label");case"user-agents":return t("settings.skills.location.option.userAgents.label");case"project-agents":return t("settings.skills.location.option.projectAgents.label");default:return t("settings.skills.location.option.userOpencode.label")}},[t]),Oe=c.useCallback(ue=>{switch(ue){case"project-opencode":return t("settings.skills.location.option.projectOpencode.description");case"user-claude":return t("settings.skills.location.option.userClaude.description");case"project-claude":return t("settings.skills.location.option.projectClaude.description");case"user-agents":return t("settings.skills.location.option.userAgents.description");case"project-agents":return t("settings.skills.location.option.projectAgents.description");default:return t("settings.skills.location.option.userOpencode.description")}},[t]),pe=JSON.stringify([d,a,g?.path,p]),xe=c.useRef(null),Ne=c.useRef({key:pe,markdown:A,disableModelInvocation:C});Ne.current={key:pe,markdown:A,disableModelInvocation:C};const de=c.useRef(""),Ue=c.useRef(!1);c.useEffect(()=>{let ue=!1;const he=(qe,Ze,pt)=>{if(Ne.current.key!==pe)return;const vt=mo(qe,Ze),bt=xe.current===pe,wt=bt&&Ne.current.markdown!==de.current,Et=bt&&Ne.current.disableModelInvocation!==Ue.current;xe.current=pe,de.current=vt,Ue.current=pt,wt||(I(qe),D(Ze),R(vt)),Et||P(pt)};return(async()=>{if(p&&l){z(!1);const qe=l.description||"",Ze=l.instructions||"";k(l.name||""),S(l.scope||"user"),N(l.source==="agents"?"agents":"opencode"),he(qe,Ze,!1),V(""),ee(""),X(!1),O([]),B(l.pendingFiles||[])}else if(a&&g){z(xe.current!==pe);try{const qe=await o(a,d);if(!ue&&Ne.current.key===pe&&qe){const Ze=qe.sources.md,pt=Ze.description||"",vt=Ze.instructions||"",bt=Ze.disableModelInvocation===!0;he(pt,vt,bt),V(pt),ee(vt),X(bt),O(Ze.supportingFiles||[])}}catch(qe){console.error("Failed to load skill details:",qe)}finally{ue||z(!1)}}})(),()=>{ue=!0}},[g,p,a,d,f,l,o,pe]);const Ie=oe(ue=>ue.editorFontSize),De=c.useMemo(()=>{const ue=[dc(e,{fontSize:Ie})],he=Hl(pv);return he&&ue.push(he),ue.push(mc.lineWrapping),ue},[e,Ie]),Je=c.useMemo(()=>{const ue=Z.trim()||"supporting-file.md",he=qm(ue),ye=!!he&&he!=="markdown",qe=[dc(e,ye?{syntaxColors:!1,fontSize:Ie}:{fontSize:Ie})],Ze=Hl(ue);return Ze&&qe.push(Ze),ye&&he&&qe.push(Pf({language:he,themeName:e.metadata.id,theme:Af(e)})),qe.push(mc.lineWrapping),qe},[e,Z,Ie]),tt=c.useCallback(ue=>{I(ue),R(he=>hv(he,ue))},[]),mt=c.useCallback(ue=>{R(ue);const he=Du(ue);I(he.description??""),D(he.instructions)},[]),ht=ue=>ue?!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(ue)||ue.length>64?t("settings.skills.page.toast.invalidSkillName"):null:t("settings.skills.page.toast.skillNameRequired"),ft=c.useCallback(async()=>{const ue=a?.trim();return p||w||!ue||x===$&&j===G&&C===ae?Es:x.trim()?await r(ue,{name:ue,description:x.trim(),instructions:j.trim()||void 0,targetPath:g?.path,disableModelInvocation:C},d)?(Ne.current.key===pe&&(de.current=mo(x,j),Ue.current=C,V(x),ee(j),X(C)),bn):gs(t("settings.skills.page.toast.updateSkillFailed")):gs(t("settings.skills.page.toast.descriptionRequired"))},[x,j,C,p,w,$,G,ae,g?.path,a,d,pe,t,r]),xt=Ya(ft),Qe=ue=>{P(ue),p||xt.requestSave()},lt=async()=>{const ue=b.trim().replace(/\s+/g,"-").toLowerCase(),he=ht(ue);if(he){W.error(he);return}if(!x.trim()){W.error(t("settings.skills.page.toast.descriptionRequired"));return}if(f.some(ye=>ye.name===ue)){W.error(t("settings.skills.page.toast.skillExists"));return}H(!0);try{const ye={name:ue,description:x.trim(),instructions:j.trim()||void 0,scope:v,source:y,supportingFiles:E.length>0?E:void 0,disableModelInvocation:C};await i(ye,d)?(u(null),B([]),m(ue),W.success(t("settings.skills.page.toast.skillCreated"))):W.error(t("settings.skills.page.toast.createSkillFailed"))}catch(ye){console.error("Error creating skill:",ye),W.error(t("settings.skills.page.toast.saveUnexpectedError"))}finally{H(!1)}},Ye=()=>{u(null),m(null)},at=()=>{se(null),fe(""),be(""),Pe(""),le(!0)},dt=async ue=>{if(se(ue),fe(ue),p){const ye=E.find(qe=>qe.path===ue)?.content||"";be(ye),Pe(ye),le(!0);return}if(a){je(!0),le(!0);try{const{readSupportingFile:he}=Ws.getState(),ye=await he(a,ue,d);be(ye||""),Pe(ye||"")}catch{W.error(t("settings.skills.page.toast.loadFileContentFailed")),be(""),Pe("")}finally{je(!1)}}},_e=async()=>{if(!Z.trim()){W.error(t("settings.skills.page.toast.fileNameRequired"));return}const ue=Z.trim(),he=Ee!==null;if(p){if(he)B(Ze=>Ze.map(pt=>pt.path===Ee?{path:ue,content:Y}:pt)),W.success(t("settings.skills.page.toast.fileUpdated",{path:ue}));else{if(E.some(Ze=>Ze.path===ue)){W.error(t("settings.skills.page.toast.fileExists"));return}B(Ze=>[...Ze,{path:ue,content:Y}]),W.success(t("settings.skills.page.toast.fileAdded",{path:ue}))}le(!1),se(null);return}if(!a){W.error(t("settings.skills.page.toast.noSkillSelected"));return}const{writeSupportingFile:ye}=Ws.getState();if(await ye(a,ue,Y,d)){W.success(he?t("settings.skills.page.toast.fileUpdated",{path:ue}):t("settings.skills.page.toast.fileCreated",{path:ue})),le(!1),se(null);const Ze=await o(a,d);Ze&&O(Ze.sources.md.supportingFiles||[])}else W.error(t(he?"settings.skills.page.toast.updateFileFailed":"settings.skills.page.toast.createFileFailed"))},nt=ue=>{if(p){B(he=>he.filter(ye=>ye.path!==ue)),W.success(t("settings.skills.page.toast.fileRemoved",{path:ue}));return}a&&Ae(ue)},te=async()=>{if(!ke||!a)return;Ke(!0);const{deleteSupportingFile:ue}=Ws.getState();if(await ue(a,ke,d)){W.success(t("settings.skills.page.toast.fileDeleted",{path:ke}));const ye=await o(a,d);ye&&O(ye.sources.md.supportingFiles||[]),Ae(null)}else W.error(t("settings.skills.page.toast.deleteFileFailed"));Ke(!1)};return!a&&!l||h?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(J,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.skills.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.skills.page.empty.description")})]})}):ne?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsx("div",{className:"text-center text-muted-foreground",children:s.jsx("p",{className:"typography-body",children:t("settings.skills.page.loading.details")})})}):s.jsxs(s.Fragment,{children:[s.jsxs(Yt,{title:p?t("settings.skills.page.title.newSkill"):a,description:g?t("settings.skills.page.subtitle.skillLocation",{location:Re(Ni(g.scope,g.source))}):t("settings.skills.page.subtitle.newSkill"),onBlurCapture:xt.onBlurCapture,children:[s.jsxs(He,{title:t("settings.skills.page.section.basicInformation"),divider:!1,settingsItem:"skills.basic-information",contentClassName:"space-y-0",children:[p&&s.jsxs(kt,{label:t("settings.skills.page.field.skillNameLocation"),info:t("settings.skills.page.field.skillNameHint"),children:[s.jsx(Ve,{value:b,onChange:ue=>k(ue.target.value.toLowerCase().replace(/\s+/g,"-")),placeholder:t("settings.skills.page.field.skillNamePlaceholder"),className:"h-7 w-40 px-2"}),s.jsxs(Tt,{value:Ni(v,y),onValueChange:ue=>{const he=Mu(ue);S(he.scope),N(he.source==="agents"?"agents":"opencode")},children:[s.jsxs(Pt,{className:"w-fit gap-1.5",children:[v==="user"?s.jsx(J,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"folder",className:"h-3.5 w-3.5"}),y==="agents"?s.jsx(J,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:Re(Ni(v,y))})]}),s.jsx(At,{align:"start",children:Po.map(ue=>s.jsx(ot,{value:ue.value,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[ue.scope==="user"?s.jsx(J,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"folder",className:"h-3.5 w-3.5"}),ue.source==="agents"?s.jsx(J,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:Re(ue.value)})]}),s.jsx("span",{className:"typography-micro text-muted-foreground ms-6",children:Oe(ue.value)})]})},ue.value))})]})]}),s.jsx(Mt,{label:s.jsxs(s.Fragment,{children:[t("settings.common.field.description")," ",s.jsx("span",{className:"text-[var(--status-error)]",children:"*"})]}),info:t("settings.skills.page.field.descriptionHint"),controlClassName:"w-full max-w-none",children:s.jsx(ws,{value:x,onChange:ue=>tt(ue.target.value),placeholder:t("settings.skills.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] max-h-32 bg-transparent",disabled:w})}),s.jsx(it,{checked:C,onChange:Qe,label:t("settings.skills.page.field.disableModelInvocation"),info:t("settings.skills.page.field.disableModelInvocationHint"),disabled:w,className:"pt-2"})]}),s.jsx(He,{title:t("settings.skills.page.section.instructions"),headerAction:s.jsx(Cf,{currentMode:K==="preview"?"preview":"edit",onToggle:()=>F(ue=>ue==="preview"?"edit":"preview")}),settingsItem:"skills.instructions",children:s.jsx("div",{className:Me("overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",gv),onKeyDown:ue=>{ue.key==="Enter"&&(ue.metaKey||ue.ctrlKey)&&(ue.preventDefault(),xt.requestSave())},children:K==="preview"?s.jsx(Ts,{outerClassName:"h-full",className:"h-full",children:s.jsx("div",{className:"min-h-full px-4 py-3",children:s.jsx(Wm,{content:A,className:"typography-markdown-body",frontmatter:"hide",enableFileReferences:!1})})}):s.jsx(uc,{value:A,onChange:mt,readOnly:w,extensions:De,className:"h-full",enableSearch:!0})})}),s.jsx(He,{title:t("settings.skills.page.section.supportingFiles"),headerAction:s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:at,disabled:w,children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"})," ",t("settings.skills.page.actions.addFile")]}),settingsItem:"skills.supporting-files",children:(()=>{const ue=p?E:T;return ue.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground py-1.5",children:t("settings.skills.page.supportingFiles.empty")}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:ue.map(he=>s.jsxs("div",{className:"flex items-center gap-2 py-1.5 cursor-pointer group",onClick:()=>dt(he.path),children:[s.jsx(J,{name:"file",className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:he.path}),p&&s.jsx("span",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0",children:t("settings.skills.page.badge.pending")}),!w&&s.jsx(q,{size:"sm",variant:"ghost",className:"h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity",onClick:ye=>{ye.stopPropagation(),nt(he.path)},children:s.jsx(J,{name:"delete-bin",className:"h-3 w-3"})})]},he.path))})})()}),p&&s.jsx(He,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{onClick:()=>{lt()},disabled:_||!b.trim()||!x.trim(),size:"xs",className:"!font-normal",children:t(_?"settings.common.actions.saving":"settings.skills.page.actions.createSkill")}),s.jsx(q,{variant:"ghost",onClick:Ye,disabled:_,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})})]}),s.jsx(Kt,{open:ke!==null,onOpenChange:ue=>{!ue&&!Te&&Ae(null)},children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.skills.page.deleteFileDialog.title")}),s.jsx(Vt,{children:t("settings.skills.page.deleteFileDialog.description",{path:ke??""})})]}),s.jsxs(ts,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>Ae(null),disabled:Te,children:t("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",variant:"destructive",onClick:te,disabled:Te,children:t("settings.common.actions.delete")})]})]})}),s.jsx(Kt,{open:Q,onOpenChange:ue=>{if(ue){le(!0);return}if(Ee!==null&&Y!==ie){_e();return}le(!1),se(null)},children:s.jsxs(zt,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[s.jsxs(Bt,{className:"flex-shrink-0",children:[s.jsx(_t,{children:t(Ee?"settings.skills.page.fileDialog.titleEdit":"settings.skills.page.fileDialog.titleAdd")}),s.jsx(Vt,{children:t(Ee?"settings.skills.page.fileDialog.descriptionEdit":"settings.skills.page.fileDialog.descriptionAdd")})]}),re?s.jsx("div",{className:"flex-1 flex items-center justify-center py-8",children:s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.skills.page.loading.fileContent")})}):s.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col pt-2",children:[s.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:Ct,children:t("settings.skills.page.fileDialog.field.filePath")}),!Ee&&s.jsx(qt,{children:t("settings.skills.page.fileDialog.field.filePathHint")})]}),s.jsx(Ve,{value:Z,onChange:ue=>fe(ue.target.value),placeholder:t("settings.skills.page.fileDialog.field.filePathPlaceholder"),className:"text-foreground placeholder:text-muted-foreground focus-visible:ring-ring",disabled:Ee!==null})]}),s.jsxs("div",{className:"space-y-2 flex-1 min-h-0 flex flex-col",children:[s.jsx("label",{className:`${Ct} flex-shrink-0`,children:t("settings.skills.page.fileDialog.field.content")}),s.jsx("div",{className:"h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",children:s.jsx(uc,{value:Y,onChange:be,extensions:Je,className:"h-full",enableSearch:!0})})]})]}),s.jsx(ts,{className:"mt-4",children:Ee?s.jsx(q,{size:"sm",onClick:()=>{_e()},disabled:re,children:t("settings.common.actions.close")}):s.jsxs(s.Fragment,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>{le(!1),se(null)},children:t("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",onClick:()=>{_e()},disabled:re||!ge,children:t("settings.skills.page.actions.createFile")})]})})]})})]})},Ec=t=>{const e=$e.c(2),{view:a}=t,n=a===void 0?"installed":a;let o;return e[0]!==n?(o=n==="catalog"?s.jsx(mv,{}):s.jsx(bv,{}),e[0]=n,e[1]=o):o=e[1],o};function xv(){}const vv=t=>{const e=$e.c(26),{header:a,footer:n,children:o,className:i,variant:r}=t,l=r===void 0?"sidebar":r,u=cs(),m=c.useRef(null),[d,f]=c.useState(!1),[g,p]=c.useState(!1),h=l==="background"||u?"bg-background":"bg-sidebar",w=h==="bg-background"?"var(--surface-background)":"var(--surface-muted)";let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const A=m.current;if(!A){f(!1),p(!1);return}if(!(A.scrollHeight>A.clientHeight+1)){f(!1),p(!1);return}f(A.scrollTop>1),p(A.scrollTop+A.clientHeight<A.scrollHeight-1)},e[0]=b):b=e[0];const k=b;let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{k()},e[1]=v):v=e[1];let S;e[2]!==o?(S=[o,k],e[2]=o,e[3]=S):S=e[3],c.useEffect(v,S);let y,N;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{const A=m.current;if(!A)return;const R=()=>k();return A.addEventListener("scroll",R,{passive:!0}),()=>A.removeEventListener("scroll",R)},N=[k],e[4]=y,e[5]=N):(y=e[4],N=e[5]),c.useEffect(y,N);let x;e[6]!==h||e[7]!==i?(x=Me("flex h-full flex-col",h,i),e[6]=h,e[7]=i,e[8]=x):x=e[8];let I;e[9]!==o?(I=s.jsx(Ts,{ref:m,outerClassName:"flex-1 min-h-0",className:"space-y-0.5 px-3 py-2 overflow-x-hidden",children:o}),e[9]=o,e[10]=I):I=e[10];let j;e[11]!==w||e[12]!==d?(j=d&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-4",style:{background:`linear-gradient(to bottom, ${w} 0%, transparent 100%)`}}),e[11]=w,e[12]=d,e[13]=j):j=e[13];let D;e[14]!==w||e[15]!==g?(D=g&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6",style:{background:`linear-gradient(to top, ${w} 0%, transparent 100%)`}}),e[14]=w,e[15]=g,e[16]=D):D=e[16];let C;e[17]!==D||e[18]!==I||e[19]!==j?(C=s.jsxs("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[I,j,D]}),e[17]=D,e[18]=I,e[19]=j,e[20]=C):C=e[20];let P;return e[21]!==n||e[22]!==a||e[23]!==C||e[24]!==x?(P=s.jsxs("div",{className:x,children:[a,C,n]}),e[21]=n,e[22]=a,e[23]=C,e[24]=x,e[25]=P):P=e[25],P},yv=t=>{const e=$e.c(23),{title:a,metadata:n,selected:o,onSelect:i,icon:r,actions:l,className:u}=t,m=o===void 0?!1:o,d=l&&l.length>0,f=m?"bg-interactive-selection":"hover:bg-interactive-hover";let g;e[0]!==u||e[1]!==f?(g=Me("group relative flex items-center rounded-md px-1.5 py-0.5 transition-all duration-200",f,u),e[0]=u,e[1]=f,e[2]=g):g=e[2];let p;e[3]!==a?(p=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a}),e[3]=a,e[4]=p):p=e[4];let h;e[5]!==r||e[6]!==p?(h=s.jsxs("div",{className:"flex items-center gap-1.5",children:[r,p]}),e[5]=r,e[6]=p,e[7]=h):h=e[7];let w;e[8]!==n?(w=n&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n}),e[8]=n,e[9]=w):w=e[9];let b;e[10]!==i||e[11]!==h||e[12]!==w?(b=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:[h,w]}),e[10]=i,e[11]=h,e[12]=w,e[13]=b):b=e[13];let k;e[14]!==l||e[15]!==d?(k=d&&s.jsxs(ga,{children:[s.jsx(pa,{asChild:!0,children:s.jsx(q,{size:"icon",variant:"ghost",className:"h-6 w-6 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(J,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(ma,{align:"end",className:"w-fit min-w-20",children:l.map(jv)})]}),e[14]=l,e[15]=d,e[16]=k):k=e[16];let v;e[17]!==b||e[18]!==k?(v=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[b,k]}),e[17]=b,e[18]=k,e[19]=v):v=e[19];let S;return e[20]!==g||e[21]!==v?(S=s.jsx("div",{className:g,children:v}),e[20]=g,e[21]=v,e[22]=S):S=e[22],S};function jv(t){const e=t.icon;return s.jsxs(Bn,{onClick:a=>{a.stopPropagation(),t.onClick()},className:Me(t.destructive&&"text-destructive focus:text-destructive"),children:[e&&s.jsx(J,{name:e,className:"h-4 w-4 me-px"}),t.label]},t.label)}const kv=t=>{const e=$e.c(38),{onItemSelect:a}=t,{t:n}=ze(),o=un(wv),i=oe(Sv),r=oe(Nv),{currentTheme:l}=ua();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=cs(),e[0]=u):u=e[0];const m=u,d=Cv;let f,g;e[1]!==o||e[2]!==i||e[3]!==r?(f=()=>{if(o.length===0){i!==null&&r(null);return}i&&o.some(I=>I.id===i)||r(o[0].id)},g=[o,i,r],e[1]=o,e[2]=i,e[3]=r,e[4]=f,e[5]=g):(f=e[4],g=e[5]),c.useEffect(f,g);let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=Me("border-b px-3","pt-4 pb-3"),e[6]=p):p=e[6];let h;e[7]!==n?(h=n("settings.page.projects.title"),e[7]=n,e[8]=h):h=e[8];let w;e[9]!==h?(w=s.jsx("h2",{className:`${On} mb-3`,children:h}),e[9]=h,e[10]=w):w=e[10];let b;e[11]!==o.length||e[12]!==n?(b=n("settings.projects.sidebar.total",{count:o.length}),e[11]=o.length,e[12]=n,e[13]=b):b=e[13];let k;e[14]!==b?(k=s.jsx("span",{className:"typography-meta text-muted-foreground",children:b}),e[14]=b,e[15]=k):k=e[15];let v;e[16]!==n?(v=!m&&s.jsx(q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:d,"aria-label":n("settings.projects.sidebar.actions.addProject"),children:s.jsx(J,{name:"add",className:"size-4"})}),e[16]=n,e[17]=v):v=e[17];let S;e[18]!==k||e[19]!==v?(S=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k,v]}),e[18]=k,e[19]=v,e[20]=S):S=e[20];let y;e[21]!==S||e[22]!==w?(y=s.jsxs("div",{className:p,children:[w,S]}),e[21]=S,e[22]=w,e[23]=y):y=e[23];let N;if(e[24]!==l||e[25]!==a||e[26]!==o||e[27]!==i||e[28]!==r){let I;e[30]!==l||e[31]!==a||e[32]!==i||e[33]!==r?(I=j=>{const D=j.id===i,C=j.icon?Jm[j.icon]:null,P=Qm(j.color),A=C?s.jsx(J,{name:C,className:Me("h-4 w-4",D?"text-foreground":"text-muted-foreground/70"),style:P?{color:P}:void 0}):s.jsx(J,{name:"folder",className:Me("h-4 w-4",D?"text-foreground":"text-muted-foreground/70"),style:P?{color:P}:void 0}),R=j.iconImage?s.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:j.iconBackground?{backgroundColor:j.iconBackground}:void 0,children:s.jsx(Ym,{project:j,options:{themeVariant:l.metadata.variant,iconColor:l.colors.surface.foreground},className:"h-full w-full object-contain",fallback:A})}):A;return s.jsx(yv,{title:j.label||j.path,icon:R,selected:D,onSelect:()=>{r(j.id),a?.()}},j.id)},e[30]=l,e[31]=a,e[32]=i,e[33]=r,e[34]=I):I=e[34],N=o.map(I),e[24]=l,e[25]=a,e[26]=o,e[27]=i,e[28]=r,e[29]=N}else N=e[29];let x;return e[35]!==y||e[36]!==N?(x=s.jsx(vv,{variant:"background",header:y,children:N}),e[35]=y,e[36]=N,e[37]=x):x=e[37],x};function wv(t){return t.projects}function Sv(t){return t.settingsProjectsSelectedId}function Nv(t){return t.setSettingsProjectsSelectedId}function Cv(){Gm.requestDirectoryDialog()}const Iv=()=>{const t=$e.c(30),{t:e}=ze(),{isMobile:a}=Fn(),n=un(Pv),o=un(Av),i=oe(Tv),r=oe(Ev),l=oe(Mv),u=oe(Dv),m=Yr(Rv),d=Yr(Fv);let f;e:{if(!i){f=null;break e}let N;t[0]!==n||t[1]!==i?(N=n.find(x=>x.id===i)??null,t[0]=n,t[1]=i,t[2]=N):N=t[2],f=N}const g=f;let p,h;t[3]!==n||t[4]!==i||t[5]!==r?(p=()=>{if(n.length===0){r(null);return}i&&n.some(N=>N.id===i)||r(n[0].id)},h=[n,i,r],t[3]=n,t[4]=i,t[5]=r,t[6]=p,t[7]=h):(p=t[6],h=t[7]),c.useEffect(p,h);let w;t[8]!==g||t[9]!==o?(w=async N=>{g&&o(g.id,{label:N.label,icon:N.icon,color:N.color,iconBackground:N.iconBackground,defaultAgent:N.defaultAgent??null,defaultModel:N.defaultModel??null,defaultVariant:N.defaultVariant??null})},t[8]=g,t[9]=o,t[10]=w):w=t[10];const b=w,k=g?.id??null;let v;e:{if(a||!k){v=void 0;break e}let N;t[11]!==k||t[12]!==l||t[13]!==u?(N=()=>{l(!1),u(k)},t[11]=k,t[12]=l,t[13]=u,t[14]=N):N=t[14],v=N}const S=v;if(!g){let N;t[15]!==e?(N=e("settings.page.projects.title"),t[15]=e,t[16]=N):N=t[16];let x;t[17]!==e?(x=e("settings.projects.page.empty.noProjects"),t[17]=e,t[18]=x):x=t[18];let I;t[19]!==x?(I=s.jsx("p",{className:"typography-meta text-muted-foreground",children:x}),t[19]=x,t[20]=I):I=t[20];let j;return t[21]!==N||t[22]!==I?(j=s.jsx(Yt,{title:N,showSaveStatus:!0,children:I}),t[21]=N,t[22]=I,t[23]=j):j=t[23],j}let y;return t[24]!==b||t[25]!==S||t[26]!==g||t[27]!==d||t[28]!==m?(y=s.jsx(mf,{frame:"page",project:g,onIdentitySave:b,tab:m,onTabChange:d,onOpenWorktrees:S}),t[24]=b,t[25]=S,t[26]=g,t[27]=d,t[28]=m,t[29]=y):y=t[29],y};function Pv(t){return t.projects}function Av(t){return t.updateProjectMeta}function Tv(t){return t.settingsProjectsSelectedId}function Ev(t){return t.setSettingsProjectsSelectedId}function Mv(t){return t.setSettingsDialogOpen}function Dv(t){return t.setWorktreesPageProjectId}function Rv(t){return t.tab}function Fv(t){return t.setTab}const Ov=ss({clientToken:St().trim().min(1)}),Lv=ss({error:wf("Invalid or expired pairing session")}),Kv=async t=>{const e=await t.json().catch(()=>null);if(!t.ok)return t.status===400&&Lv.safeParse(e).success?{kind:"rejected"}:{kind:"http-error",status:t.status};const a=Ov.safeParse(e);return a.success?{kind:"success",token:a.data.clientToken}:{kind:"invalid-response"}};function zv(t){const e=$e.c(42),{t:a}=ze(),[n,o]=Be.useState(null),i=Be.useRef(null),r=Be.useRef(null);let l,u;e[0]!==t?(l=()=>(r.current=t,o(null),()=>{r.current=null;const F=i.current;i.current=null,F?.(null)}),u=[t],e[0]=t,e[1]=l,e[2]=u):(l=e[1],u=e[2]),Be.useEffect(l,u);let m;e[3]!==t?(m=(F,T)=>{const O=T===void 0?"settings.common.actions.saveChanges":T;return!t||r.current!==t||i.current?Promise.resolve(null):new Promise(E=>{i.current=E,o({messageKey:F,actionKey:O})})},e[3]=t,e[4]=m):m=e[4];const d=m;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=F=>{const T=i.current;i.current=null,o(null),T?.(F)},e[5]=f):f=e[5];const g=f,p=n!==null;let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=F=>{F||g(!1)},e[6]=h):h=e[6];let w;e[7]!==a?(w=a("settings.remoteInstances.page.title"),e[7]=a,e[8]=w):w=e[8];let b;e[9]!==w?(b=s.jsx(_t,{children:w}),e[9]=w,e[10]=b):b=e[10];let k;e[11]!==n||e[12]!==a?(k=n?a(n.messageKey):null,e[11]=n,e[12]=a,e[13]=k):k=e[13];let v;e[14]!==k?(v=s.jsx(Vt,{children:k}),e[14]=k,e[15]=v):v=e[15];let S;e[16]!==b||e[17]!==v?(S=s.jsxs(Bt,{children:[b,v]}),e[16]=b,e[17]=v,e[18]=S):S=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=()=>g(!1),e[19]=y):y=e[19];let N;e[20]!==a?(N=a("settings.common.actions.cancel"),e[20]=a,e[21]=N):N=e[21];let x;e[22]!==N?(x=s.jsx(q,{variant:"outline",autoFocus:!0,onClick:y,children:N}),e[22]=N,e[23]=x):x=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=()=>g(!0),e[24]=I):I=e[24];let j;e[25]!==n||e[26]!==a?(j=n?a(n.actionKey):null,e[25]=n,e[26]=a,e[27]=j):j=e[27];let D;e[28]!==j?(D=s.jsx(q,{onClick:I,children:j}),e[28]=j,e[29]=D):D=e[29];let C;e[30]!==x||e[31]!==D?(C=s.jsxs(ts,{children:[x,D]}),e[30]=x,e[31]=D,e[32]=C):C=e[32];let P;e[33]!==S||e[34]!==C?(P=s.jsxs(zt,{children:[S,C]}),e[33]=S,e[34]=C,e[35]=P):P=e[35];let A;e[36]!==P||e[37]!==p?(A=s.jsx(Kt,{open:p,onOpenChange:h,children:P}),e[36]=P,e[37]=p,e[38]=A):A=e[38];const R=A;let K;return e[39]!==d||e[40]!==R?(K={confirm:d,dialog:R},e[39]=d,e[40]=R,e[41]=K):K=e[41],K}const po=()=>Math.floor(2e4+Math.random()*3e4),Uv=t=>{const e=(t instanceof Error?t.message:String(t)).toLowerCase();return e.includes("address already in use")||e.includes("eaddrinuse")||e.includes("port already in use")},$v=()=>{if(typeof navigator>"u")return;const t=(navigator.userAgent||"").toLowerCase();if(t.includes("mac"))return"macos";if(t.includes("win"))return"windows";if(t.includes("linux"))return"linux"},Mc=t=>{switch((t||"").toLowerCase()){case"ios":return"iOS";case"android":return"Android";case"macos":case"darwin":return"macOS";case"windows":case"win32":return"Windows";case"linux":return"Linux";default:return null}},Dc=t=>{switch(t){case"config_resolved":return"settings.remoteInstances.page.phase.resolvingConfiguration";case"auth_check":return"settings.remoteInstances.page.phase.checkingAuth";case"master_connecting":return"settings.remoteInstances.page.phase.establishingSsh";case"remote_probe":return"settings.remoteInstances.page.phase.probingRemote";case"installing":return"settings.remoteInstances.page.phase.installingOpenChamber";case"updating":return"settings.remoteInstances.page.phase.updatingOpenChamber";case"server_detecting":return"settings.remoteInstances.page.phase.detectingServer";case"server_starting":return"settings.remoteInstances.page.phase.startingServer";case"forwarding":return"settings.remoteInstances.page.phase.forwardingPorts";case"ready":return"settings.remoteInstances.sidebar.phase.ready";case"degraded":return"settings.remoteInstances.page.phase.reconnecting";case"error":return"settings.remoteInstances.sidebar.phase.error";default:return"settings.remoteInstances.sidebar.phase.idle"}},Bv=new Set(["config_resolved","auth_check","master_connecting","remote_probe","installing","updating","server_detecting","server_starting","forwarding"]),Ml=t=>!!(t&&Bv.has(t)),Rc=t=>t==="ready"?"ready":t==="error"?"error":t==="degraded"||Ml(t)?"connecting":"idle",Fc=t=>{switch(t){case"ready":return"settings.remoteInstances.page.state.ready";case"connecting":return"settings.remoteInstances.page.state.connecting";case"error":return"settings.remoteInstances.page.state.problem";default:return"settings.remoteInstances.page.state.notConnected"}},_v=t=>{const e=(t||"").toLowerCase();return e?e.includes("ui authentication")||e.includes("ui password")?"uiPassword":e.includes("already in use")||e.includes("eaddrinuse")?"localPort":e.includes("neither bun nor npm")?"noRuntime":e.includes("opencode cli is not installed")?"noOpencode":e.includes("requires a ui password")?"uiPassword":e.includes("preferred remote openchamber port")?"externalPort":null:null},Oc={noRuntime:"settings.remoteInstances.page.error.hint.noRuntime",noOpencode:"settings.remoteInstances.page.error.hint.noOpencode"},Vv=t=>t==="noRuntime"?Oc.noRuntime:t==="noOpencode"?Oc.noOpencode:null,Lc=t=>t==="ready"?"bg-[var(--status-success)] animate-pulse":t==="error"?"bg-[var(--status-error)] animate-pulse":t==="degraded"||Ml(t)?"bg-[var(--status-warning)] animate-pulse":"bg-muted-foreground/40",Hv=t=>t.type==="dynamic"?`${t.localHost||"127.0.0.1"}:${t.localPort||0}`:t.type==="remote"?`${t.remoteHost||"127.0.0.1"}:${t.remotePort||0} -> ${t.localHost||"127.0.0.1"}:${t.localPort||0}`:`${t.localHost||"127.0.0.1"}:${t.localPort||0} -> ${t.remoteHost||"127.0.0.1"}:${t.remotePort||0}`,qv=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:"local",localHost:"127.0.0.1",localPort:po(),remoteHost:"127.0.0.1",remotePort:80}),Wv=t=>t.trim().replace(/\*/g,"host").replace(/\?/g,"x")||"user@host",Xs=t=>{const e=$e.c(7),{label:a,hint:n}=t;let o;e[0]!==a?(o=s.jsx("span",{children:a}),e[0]=a,e[1]=o):o=e[1];let i;e[2]!==n?(i=s.jsx(qt,{contentClassName:"max-w-xs",children:n}),e[2]=n,e[3]=i):i=e[3];let r;return e[4]!==o||e[5]!==i?(r=s.jsxs("span",{className:`inline-flex items-center gap-1 ${Ct}`,children:[o,i]}),e[4]=o,e[5]=i,e[6]=r):r=e[6],r},Gv=t=>{switch(t){case"remote":return"settings.remoteInstances.page.forwardTypeDescription.remote";case"dynamic":return"settings.remoteInstances.page.forwardTypeDescription.dynamic";default:return"settings.remoteInstances.page.forwardTypeDescription.local"}},Kc=(t,e)=>{const a=(t||"").trim();return`${!a||a==="127.0.0.1"||a==="::1"?"localhost":a}:${e||0}`},Jv=t=>{const e=(t||"").trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},Qv=t=>{const e=t.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!e)return t;const a=Number(e[1]),n=Number.isFinite(a)?new Date(a).toISOString():e[1],o=(e[2]||"INFO").toUpperCase(),i=e[3]||"";return`[${n}] [${o}] ${i}`},tl=(t="",e="")=>({id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`header-${Date.now()}-${Math.random().toString(16).slice(2)}`,name:t,value:e}),Yv=t=>t.trim().toLowerCase()==="authorization",Sr=t=>{const e={};for(const a of t){const n=a.name.trim(),o=a.value.trim();n&&o&&!Yv(n)&&(e[n]=o)}return Object.keys(e).length>0?e:void 0},Zv=t=>Object.entries(t||{}).map(([e,a])=>tl(e,a)),Ru=()=>{if(typeof window>"u")return null;const e=Ri()||window.location.href;try{const a=Number(new URL(e).port||window.location.port);return Number.isFinite(a)&&a>0?a:null}catch{const a=Number(window.location.port);return Number.isFinite(a)&&a>0?a:null}},zc=t=>{try{const e=new URL(t).hostname.toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}catch{return!1}},Xv=async()=>{const t=ea(Ri())||window.location.origin;if(!as()||!Qa()||(await xn())?.desktopLanAccessActive!==!0)return t;const a=await au(),n=Ru();return!a||!n?t:`http://${a}:${n}`},Uc=t=>{const e=t.trim();if(e)try{window.location.assign(e)}catch{window.location.href=e}},ey=t=>{const e=t.sshCommand.trim(),a=t.nickname?.trim(),n=t.portForwards.map(o=>({...o,localHost:o.localHost?.trim()||"127.0.0.1",localPort:typeof o.localPort=="number"?Math.max(1,Math.min(65535,Math.round(o.localPort))):void 0,remoteHost:o.remoteHost?.trim(),remotePort:typeof o.remotePort=="number"?Math.max(1,Math.min(65535,Math.round(o.remotePort))):void 0}));return{...t,sshCommand:e,...a?{nickname:a}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(t.connectionTimeoutSec||60))),localForward:{...t.localForward,bindHost:t.localForward.bindHost==="localhost"||t.localForward.bindHost==="0.0.0.0"?t.localForward.bindHost:"127.0.0.1",preferredLocalPort:typeof t.localForward.preferredLocalPort=="number"?Math.max(1,Math.min(65535,Math.round(t.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...t.remoteOpenchamber,preferredPort:typeof t.remoteOpenchamber.preferredPort=="number"?Math.max(1,Math.min(65535,Math.round(t.remoteOpenchamber.preferredPort))):void 0},portForwards:n}},ty=()=>{const{t}=ze(),e=oe(U=>U.timeFormatPreference),{clientAuth:a}=Ja(),n=as(),o=Cs(U=>U.instances),i=Cs(U=>U.statusesById),r=Cs(U=>U.importCandidates),l=Cs(U=>U.isLoading),u=Cs(U=>U.isImportsLoading),m=Cs(U=>U.isSaving),d=Cs(U=>U.error),f=Cs(U=>U.load),g=Cs(U=>U.loadImports),p=Cs(U=>U.refreshStatuses),h=Cs(U=>U.upsertInstance),w=Cs(U=>U.createFromCommand),b=Cs(U=>U.removeInstance),k=Cs(U=>U.connect),v=Cs(U=>U.disconnect),S=Cs(U=>U.retry),y=oe(U=>U.settingsRemoteInstancesSelectedId),N=oe(U=>U.setSettingsRemoteInstancesSelectedId),x=oe(U=>U.setSettingsDialogOpen),{confirm:I,dialog:j}=zv(y),D=c.useMemo(()=>y&&o.find(U=>U.id===y)||null,[o,y]),[C,P]=c.useState(null),[A,R]=c.useState(!1),[K,F]=c.useState(!1),[T,O]=c.useState(null),[E,B]=c.useState([]),[_,H]=c.useState(null),[ne,z]=c.useState(""),[$,V]=c.useState(!1),[G,ee]=c.useState({}),[ae,X]=c.useState(!1),[Q,le]=c.useState(!1),[Z,fe]=c.useState(()=>Date.now()),[Y,be]=c.useState([]),[Ee,se]=c.useState({}),[re,je]=c.useState("local"),[ie,Pe]=c.useState(!1),[ke,Ae]=c.useState(!1),[Te,Ke]=c.useState(""),[ge,Re]=c.useState(""),[Oe,pe]=c.useState(""),[xe,Ne]=c.useState([]),[de,Ue]=c.useState(""),[Ie,De]=c.useState(null),[Je,tt]=c.useState(!1),[mt,ht]=c.useState(!1),[ft,xt]=c.useState(!1),[Qe,lt]=c.useState(null),[Ye,at]=c.useState(""),[dt,_e]=c.useState(""),[nt,te]=c.useState(""),[ue,he]=c.useState([]),[ye,qe]=c.useState([]),[Ze,pt]=c.useState([]),[vt,bt]=c.useState(!1),[wt,Et]=c.useState(""),[Le,Xe]=c.useState(null),[gt,jt]=c.useState(null),[L,me]=c.useState(null),[Se,Ce]=c.useState(null),[We,ce]=c.useState(!1),[Fe,ct]=c.useState(!1),[Ft,It]=c.useState("configure"),[ls,et]=c.useState(!1),[st,Ht]=c.useState("relay"),[is,us]=c.useState(!0),[Jt,Ss]=c.useState(null),vn=Ai(U=>U.networkAccessBlocked),Xa=!Jt||Jt.lanUrl?t("settings.remoteInstances.clientAuth.addDevice.transport.lanHint"):as()?Qa()?t(vn?"settings.openchamber.desktopNetwork.field.enterpriseBlocked":"settings.remoteInstances.clientAuth.addDevice.transport.lanUnavailableDesktopHint"):t("settings.remoteInstances.clientAuth.addDevice.transport.lanHint"):t("settings.remoteInstances.clientAuth.addDevice.transport.lanUnavailableServerHint"),Li=c.useMemo(()=>ye.filter(U=>!!U.revokedAt).length,[ye]),[ei,Kn]=c.useState(!1),[fa,ti]=c.useState("saved"),[si,ni]=c.useState(""),[ha,Ki]=c.useState(""),[ai,ii]=c.useState(""),[zi,mn]=c.useState(!1);c.useEffect(()=>{f(),g()},[f,g]);const oi=c.useCallback(async()=>{Pe(!0),De(null);try{const U=await hr();be(U.hosts||[]),je(U.defaultHostId||"local")}catch(U){De(U instanceof Error?U.message:String(U))}finally{Pe(!1)}},[]);c.useEffect(()=>{oi()},[oi]);const $s=c.useCallback(async(U,ve=re)=>{Ae(!0),De(null);try{return await Xl({hosts:U,defaultHostId:ve,initialHostChoiceCompleted:!0}),be(U),je(ve),!0}catch(Ge){return De(Ge instanceof Error?Ge.message:String(Ge)),!1}finally{Ae(!1)}},[re]),Ui=c.useCallback(async()=>{const U=ec(ge);if(!U){De(t("desktopHostSwitcher.error.invalidUrl"));return}const ve=U.persistedUrl,ut={id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,label:Te.trim()||ui(ve),url:ve,apiUrl:ve,...Oe.trim()?{clientToken:Oe.trim()}:{},...Sr(xe)?{requestHeaders:Sr(xe)}:{}};await $s([ut,...Y],re)&&(Ke(""),Re(""),pe(""),Ne([]),tt(!1),U.redeemUrl&&Uc(U.redeemUrl))},[re,xe,Y,Te,Oe,ge,$s,t]),Bo=c.useCallback(async()=>{De(null);const U=Sg(de);if(!U){De(t("settings.remoteInstances.direct.error.invalidConnectLink"));return}const ve=await Ng().catch(()=>""),Ge=JSON.stringify({pairingId:U.pairingId,secret:U.secret,clientLabel:U.label||"OpenChamber Desktop",clientKind:"desktop",deviceName:"OpenChamber Desktop",devicePlatform:$v(),...ve?{dedupeKey:`desktop:${ve}`}:{}}),ut={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:Ge};let $t=null;const xs=async Gt=>{const Ns=await Kv(Gt);switch(Ns.kind){case"success":return Ns.token;case"rejected":$t=t("desktopHostSwitcher.error.pairingRejected");break;case"http-error":$t??=t("desktopHostSwitcher.error.pairingFailed",{status:Ns.status});break;case"invalid-response":$t??=t("desktopHostSwitcher.error.pairingInvalidResponse");break}return null},_s=[...U.candidates].sort((Gt,Ns)=>(Gt.type==="relay"?1:0)-(Ns.type==="relay"?1:0));let ds=null;for(const Gt of _s){if(Gt.type==="relay"){const Aa=Cg({relayUrl:Gt.relayUrl,serverId:Gt.serverId,hostEncPubJwk:Gt.hostEncPubJwk,...Gt.grant?{grant:Gt.grant}:{}});try{const Ta=await Aa.fetch("/api/client-auth/pairing/redeem",{...ut,signal:AbortSignal.timeout(15e3)}),qi=await xs(Ta);if(qi){ds={kind:"relay",relay:{relayUrl:Gt.relayUrl,serverId:Gt.serverId,hostEncPubJwk:Gt.hostEncPubJwk},token:qi};break}}catch{}finally{Aa.close()}continue}const Ns=ea(Gt.url);if(Ns)try{const Aa=await fetch(`${Ns}/api/client-auth/pairing/redeem`,{...ut,signal:AbortSignal.timeout(15e3)}),Ta=await xs(Aa);if(Ta){ds={kind:"direct",url:Ns,token:Ta};break}}catch{}}if(!ds){De($t||t("mobile.connect.error.unreachable"));return}const Ps=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,kn=U.candidates.find(Gt=>Gt.type==="relay"),Vs=ds.kind==="relay"?ds.relay:kn?{relayUrl:kn.relayUrl,serverId:kn.serverId,hostEncPubJwk:kn.hostEncPubJwk}:void 0,ln=U.candidates.filter(Gt=>Gt.type!=="relay").map(Gt=>ea(Gt.url)).find(Gt=>!!Gt),cn=ds.kind==="direct"?ds.url:ln,{token:Ot}=ds,Xt=cn||(Vs?Ig(Vs.serverId):null);if(!Xt){De(t("settings.remoteInstances.direct.error.invalidConnectLink"));return}const wn={url:Xt,apiUrl:cn||void 0,clientToken:Ot,...Vs?{relay:Vs}:{}},zn=Y.find(Gt=>Vs?Gt.relay?.serverId===Vs.serverId:!Gt.relay&&ea(Gt.apiUrl||Gt.url)===Xt);if(zn){const Gt=Y.map(Ns=>Ns.id===zn.id?{...Ns,label:U.label||Ns.label,...wn}:Ns);if(!await $s(Gt,re))return}else if(!await $s([{id:Ps(),label:U.label||ui(Xt),...wn},...Y],re))return;Ue(""),De(null),ht(!1)},[de,re,Y,$s,t]),_o=c.useCallback(async U=>{const ve=Y.filter(ut=>ut.id!==U);await $s(ve,re===U?"local":re)&&Qe===U&<(null)},[re,Qe,Y,$s]),ba=c.useCallback(U=>{lt(U.id),at(U.label),_e(U.apiUrl||U.url),te(U.clientToken||""),he(Zv(U.requestHeaders)),De(null)},[]),Vo=c.useCallback(async()=>{if(!Qe)return;const U=ec(dt);if(!U){De(t("desktopHostSwitcher.error.invalidUrl"));return}const ve=U.persistedUrl,Ge=Y.map(ut=>ut.id===Qe?{...ut,label:Ye.trim()||ui(ve),url:ve,apiUrl:ve,clientToken:nt.trim()||void 0,requestHeaders:Sr(ue)}:ut);await $s(Ge,re)&&(lt(null),U.redeemUrl&&Uc(U.redeemUrl))},[re,ue,Ye,nt,dt,Qe,Y,$s,t]),Ho=c.useCallback(async()=>{const U=ha.trim();if(!U){W.error(t("settings.remoteInstances.page.toast.sshCommandRequired"));return}const ve=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await w(ve,U,ai.trim()||t("settings.remoteInstances.sidebar.newSshInstanceName")),N(ve),Kn(!1),Ki(""),ii(""),W.success(t("settings.remoteInstances.page.toast.instanceCreated"))}catch(Ge){W.error(t("settings.remoteInstances.sidebar.toast.createFailed"),{description:Ge instanceof Error?Ge.message:String(Ge)})}},[w,N,ha,ai,t]),$i=c.useCallback(()=>{ni(""),ti(r.length>0?"saved":"manual"),Kn(!0)},[r.length]),Bi=c.useCallback(async U=>{await $s(Y,U)},[Y,$s]);c.useEffect(()=>{if(!n||Y.length===0)return;let U=!1;return Promise.all(Y.map(async ve=>{const Ge=()=>Mg(ve.relay,{clientToken:ve.clientToken||null,requestHeaders:ve.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(ve.relay&&!ve.apiUrl)return[ve.id,await Ge()];const ut=ea(tc(ve));if(!ut)return[ve.id,ve.relay?await Ge():{status:"unreachable",latencyMs:0}];const $t=await Pg(ut,{clientToken:ve.clientToken||null,requestHeaders:ve.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if($t.status==="unreachable"&&ve.relay){const xs=await Ge();if(xs.status==="ok"||xs.status==="relay-limit")return[ve.id,xs]}return[ve.id,$t]})).then(ve=>{U||se(Object.fromEntries(ve))}),()=>{U=!0}},[Y,n]);const Bs=c.useCallback(async U=>{if(a){U?.silent||bt(!0),U?.silent||Xe(null);try{const[ve,Ge]=await Promise.all([a.listClients(),a.listPendingPairings().catch(()=>null)]);qe(ve),Ge&&pt(Ge)}catch(ve){U?.silent||Xe(ve instanceof Error?ve.message:String(ve))}finally{U?.silent||bt(!1)}}},[a]),ri=c.useRef(!1);c.useEffect(()=>{if(!(!Fe||Ft!=="result"||!L)){if(Ze.some(U=>U.id===L)){ri.current=!0;return}ri.current&&(me(null),ct(!1),ye.some(U=>U.pairingId===L)&&W.success(t("settings.remoteInstances.clientAuth.addDevice.connectedToast")))}},[Fe,Ft,L,Ze,ye,t]);const li=c.useCallback(async U=>{if(a)try{await a.cancelPairing(U),pt(ve=>ve.filter(Ge=>Ge.id!==U)),await Bs({silent:!0})}catch(ve){Xe(ve instanceof Error?ve.message:String(ve))}},[a,Bs]);c.useEffect(()=>{if(!a)return;Bs();const U=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Bs({silent:!0})},5e3);return()=>window.clearInterval(U)},[a,Bs]);const xa=c.useCallback(async()=>{if(a?.getPairingTransports)try{const ut=await a.getPairingTransports();return{localUrl:ut.local,lanUrl:ut.lan,relayAvailable:ut.relayAvailable}}catch{}const U=Ru(),ve=U?`http://127.0.0.1:${U}`:zc(window.location.origin)?window.location.origin:null;let Ge=null;try{const ut=ea(await Xv());Ge=ut&&!zc(ut)?ut:null}catch{}return{localUrl:ve,lanUrl:Ge,relayAvailable:!0}},[a]),qo=c.useCallback(async()=>{Xe(null),jt(null),Ce(null),ce(!1),me(null),It("configure"),us(!0),ct(!0);const U=await xa();Ss(U),Ht(U.relayAvailable?"relay":U.lanUrl?"lan":"local")},[xa]),Wo=c.useCallback(async()=>{if(!(!a?.createPairingSession||!Jt)){Xe(null),et(!0);try{const U=wt.trim()||void 0;let ve,Ge,ut=!0;st==="local"?(ve=Jt.localUrl??void 0,Ge=!1):st==="lan"?(ve=Jt.lanUrl??void 0,Ge=is):is&&Jt.lanUrl?(ve=Jt.lanUrl,Ge=!0):(ut=!1,Ge=!0);const{pairing:$t,server:xs}=await a.createPairingSession({label:U,allowedClientKinds:["mobile","desktop"],serverUrl:ve,includeRelay:Ge,includeDirect:ut}),_s=Ag({pairingId:$t.id,secret:$t.secret,label:xs.label,fingerprint:$t.fingerprint??void 0,expiresAt:$t.expiresAt,candidates:xs.candidates}),ds=Tg(_s);jt(ds),Ce(await gu.toDataURL(ds,{width:1024,margin:2,errorCorrectionLevel:"L"})),ce(!1),ri.current=!1,me($t.id),It("result"),await Bs({silent:!0})}catch(U){Xe(U instanceof Error?U.message:String(U))}finally{et(!1)}}},[a,Jt,st,is,wt,Bs]),Go=c.useCallback(()=>{gt&&$a(gt).then(U=>{U.ok&&(ce(!0),window.setTimeout(()=>ce(!1),2e3))})},[gt]),Jo=c.useCallback(async U=>{if(!a)return;const ve=U.clientKind==="desktop-local";Xe(null);try{if(await a.revokeClient(U.id),ve&&as()){const Ge=await hr();await Xl({hosts:Ge.hosts,defaultHostId:Ge.defaultHostId,initialHostChoiceCompleted:Ge.initialHostChoiceCompleted,localClientToken:null}),qe(ut=>ut.map($t=>$t.id===U.id?{...$t,revokedAt:new Date().toISOString()}:$t)),sc({apiBaseUrl:Ri(),clientToken:null,runtimeKey:"local"});return}await Bs()}catch(Ge){Xe(Ge instanceof Error?Ge.message:String(Ge))}},[a,Bs]),Qo=c.useCallback(async()=>{if(a){Xe(null);try{await a.purgeRevokedClients(),await Bs()}catch(U){Xe(U instanceof Error?U.message:String(U))}}},[a,Bs]);c.useEffect(()=>{P(D)},[D]),c.useEffect(()=>{mn(!1)},[y]),c.useEffect(()=>{if(!y)return;const U=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||p()},2e3);return()=>{window.clearInterval(U)}},[p,y]),c.useEffect(()=>{let U=null,ve=Date.now();const Ge=()=>{const $t=Date.now();$t-ve>=1e3&&(fe($t),ve=$t),U=requestAnimationFrame(Ge)};(typeof document>"u"||document.visibilityState==="visible")&&(U=requestAnimationFrame(Ge));const ut=()=>{document.visibilityState==="visible"&&U===null?U=requestAnimationFrame(Ge):document.visibilityState!=="visible"&&U!==null&&(cancelAnimationFrame(U),U=null)};return document.addEventListener("visibilitychange",ut),()=>{document.removeEventListener("visibilitychange",ut),U!==null&&cancelAnimationFrame(U)}},[]);const Ds=y?i[y]:null,on=Ds?.phase,Vn=on==="ready",yn=on==="degraded",jn=Ml(on),rn=Vn||(jn||yn),Yo=Ds?Math.max(0,Z-Ds.updatedAtMs):0,va=yn&&Yo>12e3,ya=Rc(on),Hn=ya==="error"?_v(Ds?.detail):null,ci=Vv(Hn),Zo=c.useMemo(()=>!C||!D?!1:JSON.stringify(C)!==JSON.stringify(D),[C,D]),ms=c.useCallback(U=>{P(ve=>ve&&U(ve))},[]),Xo=c.useCallback(async()=>{if(!C)return;const U=ey(C);if(!U.sshCommand.trim()){W.error(t("settings.remoteInstances.page.toast.sshCommandRequired"));return}if(U.remoteOpenchamber.mode==="external"&&!U.remoteOpenchamber.preferredPort){W.error(t("settings.remoteInstances.page.validation.externalPortRequired")),mn(!0);return}if(U.remoteOpenchamber.mode==="managed"&&U.remoteOpenchamber.bindHost==="0.0.0.0"&&!U.auth.openchamberPassword?.value?.trim()){W.error(t("settings.remoteInstances.page.validation.remoteLanNeedsPassword")),mn(!0),window.setTimeout(()=>Sa.current?.focus(),0);return}if(!(U.localForward.bindHost==="0.0.0.0"&&!await I("settings.remoteInstances.page.confirm.bindAllInterfaces"))){if(U.auth.sshPassword?.enabled&&U.auth.sshPassword.value?.trim()&&U.auth.sshPassword.store!=="settings"){const ve=await I("settings.remoteInstances.page.confirm.storeSshPasswordPlaintext");if(ve===null)return;U.auth.sshPassword.store=ve?"settings":"never",ve||(U.auth.sshPassword.value=void 0)}if(U.auth.openchamberPassword?.enabled&&U.auth.openchamberPassword.value?.trim()&&U.auth.openchamberPassword.store!=="settings"){const ve=await I("settings.remoteInstances.page.confirm.storeUiPasswordPlaintext");if(ve===null)return;U.auth.openchamberPassword.store=ve?"settings":"never",ve||(U.auth.openchamberPassword.value=void 0)}try{await h(U),W.success(t("settings.remoteInstances.page.toast.instanceSaved"))}catch(ve){W.error(t("settings.remoteInstances.page.toast.saveFailed"),{description:ve instanceof Error?ve.message:String(ve)})}}},[I,C,t,h]),ja=c.useCallback(async(U,ve)=>{const Ge=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await w(Ge,`ssh ${ve}`,U),N(Ge),W.success(t("settings.remoteInstances.page.toast.instanceCreated")),!0}catch(ut){return W.error(t("settings.remoteInstances.sidebar.toast.createFailed"),{description:ut instanceof Error?ut.message:String(ut)}),!1}},[w,N,t]),ka=c.useCallback(()=>{$||(H(null),z(""))},[$]),er=c.useCallback((U,ve)=>{if(Kn(!1),ve){H(U),z(Wv(U));return}ja(U,U)},[ja]),di=c.useMemo(()=>_n(r,si,U=>[U.host,U.sshCommand]),[r,si]),_i=c.useCallback(async U=>{const Ge=(await hr().catch(()=>null))?.hosts.find($t=>$t.id===U),ut=Ge?ea(tc(Ge)):null;if(!Ge||!ut){W.error(t("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}sc({apiBaseUrl:ut,clientToken:Ge.clientToken||null,requestHeaders:Ge.requestHeaders||null,runtimeKey:Eg(Ge),sshForwarded:Ge.sshForwarded===!0}),x(!1)},[x,t]),Vi=c.useCallback(async()=>{const U=_,ve=ne.trim();if(U){if(!ve){W.error(t("settings.remoteInstances.page.toast.destinationRequired"));return}V(!0);try{await ja(U,ve)&&(H(null),z(""))}finally{V(!1)}}},[ja,ne,_,t]),wa=c.useCallback(async()=>{if(D)try{await k(D.id);return}catch(U){if(!Uv(U)||!await I("settings.remoteInstances.sidebar.confirm.localPortInUseRetry","settings.remoteInstances.sidebar.actions.retry"))throw U;const Ge={...D,localForward:{...D.localForward,preferredLocalPort:po()}};await h(Ge),await k(Ge.id),W.success(t("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}},[I,k,D,t,h]),Sa=c.useRef(null),Hi=c.useRef(null),tr=c.useCallback(async U=>{if(D){if(U==="localPort"){const ve={...D,localForward:{...D.localForward,preferredLocalPort:po()}};try{await h(ve),await k(ve.id),W.success(t("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}catch(Ge){W.error(t("settings.remoteInstances.page.toast.connectFailed"),{description:Ge instanceof Error?Ge.message:String(Ge)})}return}mn(!0),window.setTimeout(()=>{if(U==="uiPassword"){Sa.current?.focus();return}Hi.current?.scrollIntoView({block:"center"})},0)}},[k,D,t,h]),Na=c.useCallback(async U=>(await Zm(U,600)).map(Ge=>Qv(Ge)),[]),sr=c.useCallback(async()=>{if(C){R(!0),F(!0),O(null);try{const U=await Na(C.id);B(U)}catch(U){B([]),O(U instanceof Error?U.message:String(U))}finally{F(!1)}}},[C,Na]);c.useEffect(()=>{if(!A||!C)return;let U=!1;const ve=async()=>{try{const ut=await Na(C.id);U||(B(ut),O(null))}catch(ut){U||O(ut instanceof Error?ut.message:String(ut))}};ve();const Ge=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||ve()},1e3);return()=>{U=!0,window.clearInterval(Ge)}},[C,A,Na]);const Ca=c.useMemo(()=>E.join(`
|
|
28
|
+
`),[E]),nr=c.useCallback(()=>{if(!Ca.trim()){W.error(t("settings.remoteInstances.page.toast.noLogsToCopy"));return}$a(Ca).then(U=>{U.ok&&W.success(t("settings.remoteInstances.page.toast.logsCopied"))})},[Ca,t]),qn=c.useCallback(async()=>{if(C)try{await Xm(C.id),B([]),W.success(t("settings.remoteInstances.page.toast.logsCleared"))}catch(U){W.error(t("settings.remoteInstances.page.toast.clearLogsFailed"),{description:U instanceof Error?U.message:String(U)})}},[C,t]),Wn=c.useCallback(()=>{if(!C)return;if(!rn&&C.remoteOpenchamber.mode==="external"&&!C.remoteOpenchamber.preferredPort){W.error(t("settings.remoteInstances.page.validation.externalPortRequired")),mn(!0);return}if(!rn&&C.remoteOpenchamber.mode==="managed"&&C.remoteOpenchamber.bindHost==="0.0.0.0"&&!C.auth.openchamberPassword?.value?.trim()){W.error(t("settings.remoteInstances.page.validation.remoteLanNeedsPassword")),mn(!0),window.setTimeout(()=>Sa.current?.focus(),0);return}X(!0),(rn?v(C.id):wa()).catch(ve=>{const Ge=rn?Vn?"settings.remoteInstances.page.toast.disconnectFailed":"settings.remoteInstances.page.toast.cancelConnectionFailed":"settings.remoteInstances.page.toast.connectFailed";W.error(t(Ge),{description:ve instanceof Error?ve.message:String(ve)})}).finally(()=>{X(!1)})},[rn,wa,v,C,Vn,t]),ar=c.useCallback(()=>{if(!C||jn)return;le(!0),(yn?v(C.id).then(()=>wa()):S(C.id)).catch(ve=>{W.error(t("settings.remoteInstances.page.toast.retryFailed"),{description:ve instanceof Error?ve.message:String(ve)})}).finally(()=>{le(!1)})},[wa,v,C,jn,yn,S,t]),ir=t(jn?"settings.remoteInstances.page.actions.connecting":yn?va?"settings.remoteInstances.page.actions.reconnectNow":"settings.remoteInstances.page.actions.reconnecting":"settings.remoteInstances.sidebar.actions.retry"),Ia=!ae&&!Q&&(on==="error"||on==="idle"||!on||yn&&va)&&!jn,or=t(Vn?"settings.remoteInstances.sidebar.actions.disconnect":rn?"settings.remoteInstances.page.actions.cancel":"settings.remoteInstances.sidebar.actions.connect");if(!C)return s.jsxs(Yt,{title:t("settings.page.remoteInstances.title"),children:[a?s.jsxs(He,{title:t("settings.remoteInstances.clientAuth.title"),info:t("settings.remoteInstances.clientAuth.description"),divider:!1,settingsItem:"remote-instances.client-auth",contentClassName:"space-y-3",children:[s.jsx("div",{children:s.jsxs(q,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{qo()},children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.clientAuth.actions.addDevice")]})}),s.jsxs("div",{className:"space-y-2.5",children:[Li>0?s.jsx("div",{className:"flex justify-end",children:s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Qo()},children:t("settings.remoteInstances.clientAuth.actions.clearRevoked")})}):null,vt&&ye.length===0&&Ze.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.state.loading")}):ye.length===0&&Ze.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.state.empty")}):s.jsxs(s.Fragment,{children:[Ze.map(U=>s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse"}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:U.label||t("settings.remoteInstances.clientAuth.field.labelPlaceholder")}),U.usesRelay?s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50",children:t("settings.remoteInstances.clientAuth.state.viaRelay")}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground truncate",children:t("settings.remoteInstances.clientAuth.state.pending")})]}),s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{li(U.id)},children:t("settings.common.actions.cancel")})]},`pending-${U.id}`)),ye.map(U=>{const ve=U.clientKind==="desktop-local",Ge=U.lastUsedAt?Date.parse(U.lastUsedAt):Number.NaN,ut=!U.revokedAt&&(ve||Number.isFinite(Ge)&&Date.now()-Ge<9e4),$t=U.revokedAt?t("settings.remoteInstances.clientAuth.state.revoked"):ut?U.lastTransport==="relay"&&!ve?t("settings.remoteInstances.clientAuth.state.connectedRelay"):t("settings.remoteInstances.clientAuth.state.connectedDirect"):Number.isFinite(Ge)?t("settings.remoteInstances.clientAuth.lastUsed",{date:ep(Ge,e,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}):t("settings.remoteInstances.clientAuth.neverUsed");return s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsx("div",{className:"min-w-0",children:s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[s.jsx("span",{className:Me("h-2 w-2 shrink-0 rounded-full",U.revokedAt?"bg-muted-foreground/20":ut?"bg-[var(--status-success)]":"bg-muted-foreground/30")}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:U.label}),Mc(U.devicePlatform)?s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50",children:Mc(U.devicePlatform)}):null,ve?s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:t("settings.remoteInstances.clientAuth.state.thisDevice")}):null,s.jsx("span",{className:Me("typography-micro truncate",ut&&!U.revokedAt?"text-[var(--status-success)]":"text-muted-foreground"),children:$t})]})}),s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Jo(U)},disabled:!!U.revokedAt,children:t("settings.remoteInstances.clientAuth.actions.revoke")})]},U.id)})]})]}),Le?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Le}):null]}):null,n?s.jsxs(He,{title:t("settings.remoteInstances.direct.title"),info:t("settings.remoteInstances.direct.description"),settingsItem:"remote-instances.direct-hosts",contentClassName:"space-y-4",headerAction:s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(q,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{De(null),ht(!0)},disabled:ke,children:t("settings.remoteInstances.direct.import.action")}),s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{De(null),tt(!0)},disabled:ke,children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.actions.add")]})]}),children:[s.jsx("div",{className:"space-y-2.5",children:ie?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.direct.state.loading")}):Y.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.direct.state.empty")}):Y.map(U=>{const ve=Ee[U.id],Ge=ve?ve.status==="ok"?"desktopHostSwitcher.status.connected":ve.status==="auth"?"desktopHostSwitcher.status.authRequired":ve.status==="update-recommended"?"desktopHostSwitcher.status.updateRecommended":ve.status==="incompatible"?"desktopHostSwitcher.status.incompatible":ve.status==="wrong-service"?"desktopHostSwitcher.status.wrongService":ve.status==="relay-limit"?"desktopHostSwitcher.status.relayLimit":"desktopHostSwitcher.status.unreachable":"desktopHostSwitcher.status.checking",ut=ve?.status==="ok";return s.jsx("div",{className:"py-1.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Me("h-2 w-2 shrink-0 rounded-full",ve?ut?"bg-[var(--status-success)]":"bg-[var(--status-error)]":"bg-muted-foreground/30 animate-pulse")}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:ui(U.label)}),re===U.id?s.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:t("desktopHostSwitcher.header.default")}):null,s.jsxs("span",{className:Me("typography-micro shrink-0",ut?"text-[var(--status-success)]":"text-muted-foreground"),children:[t(Ge),ut&&typeof ve?.latencyMs=="number"?t("desktopHostSwitcher.status.ping",{ms:Math.max(0,Math.round(ve.latencyMs))}):""]})]}),s.jsx("p",{className:Me("typography-micro text-muted-foreground truncate",U.apiUrl&&"font-mono"),children:U.relay&&!U.apiUrl?t("mobile.connect.relay.badge"):ui(U.apiUrl||U.url)})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Bi(U.id)},disabled:ke||re===U.id,"aria-label":t("desktopHostSwitcher.actions.setAsDefaultAria"),children:re===U.id?s.jsx(J,{name:"star-fill",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"star",className:"h-3.5 w-3.5"})}),U.relay&&!U.apiUrl?null:s.jsxs(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ba(U),disabled:ke,children:[s.jsx(J,{name:"pencil",className:"h-3.5 w-3.5"}),t("desktopHostSwitcher.actions.edit")]}),s.jsxs(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{_o(U.id)},disabled:ke,children:[s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.delete")]})]})]})},U.id)})}),Ie&&!mt&&!Je&&!Qe?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Ie}):null]}):null,n?s.jsx(Kt,{open:Je,onOpenChange:tt,children:s.jsxs(zt,{className:"sm:max-w-lg",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.remoteInstances.direct.actions.add")}),s.jsx(Vt,{children:t("settings.remoteInstances.direct.addDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Ui()},children:[s.jsx(Ve,{className:"h-8",value:Te,onChange:U=>Ke(U.target.value),placeholder:t("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:ke}),s.jsx(Ve,{className:"h-8",value:ge,onChange:U=>Re(U.target.value),placeholder:t("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:ke,autoFocus:!0}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ve,{className:"h-8",value:Oe,onChange:U=>pe(U.target.value),placeholder:t("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:ke}),s.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:t("settings.remoteInstances.direct.note")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Dn,{children:t("settings.remoteInstances.direct.headers.title")}),s.jsx(qt,{children:t("settings.remoteInstances.direct.headers.description")})]}),xe.map(U=>s.jsxs("div",{className:"flex w-full gap-2",children:[s.jsx(Ve,{className:"h-8 font-mono text-xs",value:U.name,onChange:ve=>Ne(Ge=>Ge.map(ut=>ut.id===U.id?{...ut,name:ve.target.value}:ut)),placeholder:t("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:ke}),s.jsx(Ve,{className:"h-8 font-mono text-xs",value:U.value,onChange:ve=>Ne(Ge=>Ge.map(ut=>ut.id===U.id?{...ut,value:ve.target.value}:ut)),placeholder:t("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:ke}),s.jsx("button",{type:"button",onClick:()=>Ne(ve=>ve.filter(Ge=>Ge.id!==U.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t("settings.remoteInstances.direct.headers.removeAria"),disabled:ke,children:s.jsx(J,{name:"close",className:"h-4 w-4"})})]},U.id)),s.jsxs(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Ne(U=>[...U,tl()]),disabled:ke,children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.headers.actions.add")]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>tt(!1),disabled:ke,children:t("settings.common.actions.cancel")}),s.jsx(q,{type:"submit",size:"xs",className:"!font-normal",disabled:ke||!ge.trim(),children:t("settings.remoteInstances.direct.actions.add")})]}),Ie?s.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ie}):null]})]})}):null,n?s.jsx(Kt,{open:!!Qe,onOpenChange:U=>{U||lt(null)},children:s.jsxs(zt,{className:"sm:max-w-lg",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("desktopHostSwitcher.actions.edit")}),s.jsx(Vt,{children:t("settings.remoteInstances.direct.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Vo()},children:[s.jsx(Ve,{className:"h-8",value:Ye,onChange:U=>at(U.target.value),placeholder:t("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:ke}),s.jsx(Ve,{className:"h-8",value:dt,onChange:U=>_e(U.target.value),placeholder:t("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:ke,autoFocus:!0}),s.jsx(Ve,{className:"h-8",value:nt,onChange:U=>te(U.target.value),placeholder:t("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:ke}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Dn,{children:t("settings.remoteInstances.direct.headers.title")}),s.jsx(qt,{children:t("settings.remoteInstances.direct.headers.description")})]}),ue.map(U=>s.jsxs("div",{className:"flex w-full gap-2",children:[s.jsx(Ve,{className:"h-8 font-mono text-xs",value:U.name,onChange:ve=>he(Ge=>Ge.map(ut=>ut.id===U.id?{...ut,name:ve.target.value}:ut)),placeholder:t("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:ke}),s.jsx(Ve,{className:"h-8 font-mono text-xs",value:U.value,onChange:ve=>he(Ge=>Ge.map(ut=>ut.id===U.id?{...ut,value:ve.target.value}:ut)),placeholder:t("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:ke}),s.jsx("button",{type:"button",onClick:()=>he(ve=>ve.filter(Ge=>Ge.id!==U.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t("settings.remoteInstances.direct.headers.removeAria"),disabled:ke,children:s.jsx(J,{name:"close",className:"h-4 w-4"})})]},U.id)),s.jsxs(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>he(U=>[...U,tl()]),disabled:ke,children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.headers.actions.add")]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>lt(null),disabled:ke,children:t("settings.common.actions.cancel")}),s.jsx(q,{type:"submit",size:"xs",className:"!font-normal",disabled:ke,children:t("settings.common.actions.saveChanges")})]}),Ie?s.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ie}):null]})]})}):null,n?s.jsx(Kt,{open:mt,onOpenChange:U=>{ft||ht(U)},children:s.jsxs(zt,{className:"sm:max-w-lg",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.remoteInstances.direct.import.action")}),s.jsx(Vt,{children:t("settings.remoteInstances.direct.import.description")})]}),s.jsxs("form",{className:"space-y-3","aria-busy":ft,onSubmit:async U=>{if(U.preventDefault(),!(ft||ke)){xt(!0);try{await Bo()}catch{De(t("mobile.connect.error.unreachable"))}finally{xt(!1)}}},children:[s.jsx(Ve,{className:"h-8",value:de,onChange:U=>{Ue(U.target.value),De(null)},placeholder:t("settings.remoteInstances.direct.import.placeholder"),disabled:ke||ft,"aria-describedby":Ie?"direct-import-error":void 0,autoFocus:!0}),Ie?s.jsx("p",{id:"direct-import-error",role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ie}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ht(!1),disabled:ke||ft,children:t("settings.common.actions.cancel")}),s.jsx(q,{type:"submit",size:"xs",className:"!font-normal",disabled:ke||ft||!de.trim(),children:t("settings.remoteInstances.direct.import.action")})]})]})]})}):null,s.jsx(Kt,{open:Fe,onOpenChange:ct,children:s.jsxs(zt,{className:Ft==="result"?"sm:max-w-lg":"sm:max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t(Ft==="result"?"settings.remoteInstances.clientAuth.qrDialogTitle":"settings.remoteInstances.clientAuth.actions.addDevice")}),s.jsx(Vt,{children:t(Ft==="result"?"settings.remoteInstances.clientAuth.qrScanHint":"settings.remoteInstances.clientAuth.addDevice.subtitle")})]}),Ft==="configure"?s.jsxs("form",{className:"space-y-4",onSubmit:U=>{U.preventDefault(),Wo()},children:[s.jsx(Ve,{className:"h-8",value:wt,onChange:U=>Et(U.target.value),placeholder:t("settings.remoteInstances.clientAuth.field.labelPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.transportLabel")}),s.jsx("div",{role:"radiogroup","aria-label":t("settings.remoteInstances.clientAuth.addDevice.transportLabel"),className:"space-y-1.5",children:[{key:"relay",label:t("settings.remoteInstances.clientAuth.addDevice.transport.relay"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.relayHint"),available:!!Jt?.relayAvailable},{key:"lan",label:t("settings.remoteInstances.clientAuth.addDevice.transport.lan"),hint:Xa,available:!!Jt?.lanUrl},{key:"local",label:t("settings.remoteInstances.clientAuth.addDevice.transport.local"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.localHint"),available:!!Jt?.localUrl}].map(U=>{const ve=st===U.key;return s.jsxs("div",{className:Me("flex items-start gap-2 py-0.5",U.available?"cursor-pointer":"opacity-45"),onClick:()=>{U.available&&Ht(U.key)},role:"presentation",children:[s.jsx(hl,{checked:ve,disabled:!U.available,onChange:()=>Ht(U.key),ariaLabel:U.label,className:"mt-0.5"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:Me("typography-ui-label font-normal",ve?"text-foreground":"text-foreground/70"),children:U.label}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:U.hint})]})]},U.key)})}),st==="lan"?s.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[s.jsx(Pi,{checked:is,onChange:us,ariaLabel:t("settings.remoteInstances.clientAuth.addDevice.fallback.relay")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.fallback.relay")})]}):null,st==="relay"&&Jt?.lanUrl?s.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[s.jsx(Pi,{checked:is,onChange:us,ariaLabel:t("settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal")})]}):null]}),Le?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Le}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ct(!1),disabled:ls,children:t("settings.common.actions.cancel")}),s.jsx(q,{type:"submit",size:"xs",className:"!font-normal",disabled:ls||!Jt,children:t("settings.remoteInstances.clientAuth.addDevice.create")})]})]}):s.jsxs("div",{className:"space-y-3",children:[Se?s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:Se,alt:t("settings.remoteInstances.clientAuth.qrAlt"),className:"w-full max-w-[420px] rounded-md bg-white p-4"})}):null,gt?s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate typography-code text-muted-foreground",children:gt}),s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:Go,children:[s.jsx(J,{name:We?"check":"file-copy",className:Me("h-3.5 w-3.5",We&&"text-[var(--status-success)]")}),t(We?"settings.remoteInstances.clientAuth.actions.copied":"settings.common.actions.copyAll")]})]}):null,s.jsx("div",{className:"flex justify-end",children:s.jsx(q,{type:"button",size:"xs",className:"!font-normal",onClick:()=>ct(!1),children:t("settings.remoteInstances.clientAuth.addDevice.done")})})]})]})}),n?s.jsx(He,{title:t("settings.remoteInstances.sidebar.title"),description:t("settings.remoteInstances.sidebar.total",{count:o.length}),headerAction:s.jsxs(q,{type:"button",size:"xs",className:"!font-normal",onClick:$i,children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.sidebar.actions.addSshInstance")]}),contentClassName:"space-y-2.5",children:l?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.state.loadingInstances")}):o.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:r.length===1?t("settings.remoteInstances.page.empty.noInstancesWithOneImport"):r.length>1?t("settings.remoteInstances.page.empty.noInstancesWithImports",{count:r.length}):t("settings.remoteInstances.page.empty.noInstances")}):o.map(U=>{const ve=i[U.id],Ge=U.nickname?.trim()||U.sshParsed?.destination||U.id,ut=ve?.phase,$t=ut==="ready",xs=Rc(ut),_s=xs==="error"?ve?.detail:void 0;return s.jsxs("div",{className:"space-y-1.5 py-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${Lc(ut)}`}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:Ge})]}),s.jsxs("p",{className:"typography-micro text-muted-foreground truncate",children:[t(Fc(xs)),xs==="connecting"?` · ${t(Dc(ut))}`:"",$t&&ve?.localUrl?` · ${ve.localUrl}`:""]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$t?s.jsxs(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{_i(U.id)},children:[s.jsx(J,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.open")]}):null,s.jsxs(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{($t?v(U.id):k(U.id)).catch(Ps=>W.error(t($t?"settings.remoteInstances.sidebar.toast.disconnectFailed":"settings.remoteInstances.sidebar.toast.connectFailed"),{description:Ps instanceof Error?Ps.message:String(Ps)}))},children:[$t?s.jsx(J,{name:"stop",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"plug-2",className:"h-3.5 w-3.5"}),t($t?"settings.remoteInstances.sidebar.actions.disconnect":"settings.remoteInstances.sidebar.actions.connect")]}),s.jsxs(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>N(U.id),children:[s.jsx(J,{name:"pencil",className:"h-3.5 w-3.5"}),t("desktopHostSwitcher.actions.edit")]}),s.jsxs(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{window.confirm(t("settings.remoteInstances.page.confirm.removeInstance"))&&b(U.id).catch(Ps=>W.error(t("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:Ps instanceof Error?Ps.message:String(Ps)}))},children:[s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.delete")]})]})]}),_s?s.jsx("p",{className:"typography-micro text-[var(--status-error)] break-words",children:_s}):null]},U.id)})}):null,n?s.jsx(Kt,{open:ei,onOpenChange:Kn,children:s.jsxs(zt,{className:"sm:max-w-lg",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.remoteInstances.sidebar.actions.addSshInstance")}),s.jsx(Vt,{children:t("settings.remoteInstances.page.addDialog.description")})]}),s.jsx(Gs,{value:fa,onChange:ti,"aria-label":t("settings.remoteInstances.page.addDialog.sourceLabel"),options:[{value:"saved",label:t("settings.remoteInstances.page.addDialog.tab.saved")},{value:"manual",label:t("settings.remoteInstances.page.addDialog.tab.manual")}]}),fa==="saved"?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ve,{className:"h-8",value:si,onChange:U=>ni(U.target.value),placeholder:t("settings.remoteInstances.page.addDialog.searchPlaceholder"),autoFocus:!0}),u?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.import.loading")}):r.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.addDialog.emptySaved")}):di.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.addDialog.searchEmpty")}):s.jsx("div",{className:"max-h-[45vh] overflow-auto",children:di.map(U=>s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-2.5 last:border-b-0",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"typography-ui-label font-medium text-foreground truncate",children:[U.host,U.pattern?` ${t("settings.remoteInstances.page.import.patternSuffix")}`:""]}),s.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:U.sshCommand})]}),s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{er(U.host,U.pattern)},children:t("settings.remoteInstances.page.addDialog.use")})]},`${U.source}:${U.host}`))})]}):s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Ho()},children:[s.jsx(Ve,{className:"h-8",value:ai,onChange:U=>ii(U.target.value),placeholder:t("settings.remoteInstances.page.field.nicknamePlaceholder"),disabled:m}),s.jsx(Ve,{className:"h-8",value:ha,onChange:U=>Ki(U.target.value),placeholder:t("settings.remoteInstances.page.field.sshCommandPlaceholder"),disabled:m,autoFocus:!0}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Kn(!1),disabled:m,children:t("settings.common.actions.cancel")}),s.jsx(q,{type:"submit",size:"xs",className:"!font-normal",disabled:m||!ha.trim(),children:t("settings.common.actions.create")})]})]})]})}):null,s.jsx(Kt,{open:!!_,onOpenChange:U=>{U||ka()},children:s.jsxs(zt,{className:"sm:max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.remoteInstances.page.patternDialog.title")}),s.jsx(Vt,{children:_?t("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:_}):t("settings.remoteInstances.page.patternDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Vi()},children:[s.jsx(Ve,{value:ne,onChange:U=>z(U.target.value),placeholder:t("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:ka,disabled:$,children:t("settings.common.actions.cancel")}),s.jsx(q,{type:"submit",size:"xs",className:"!font-normal",disabled:$,children:t("settings.remoteInstances.page.actions.create")})]})]})]})})]});const Gn=C.remoteOpenchamber.mode==="managed",we=Gn&&C.remoteOpenchamber.bindHost==="0.0.0.0",Zt=we&&!C.auth.openchamberPassword?.value?.trim(),Pa=C.nickname?.trim()||C.sshParsed?.destination||C.id;return s.jsx(Kt,{open:!!C,onOpenChange:U=>{U||N(null)},children:s.jsxs(zt,{className:"sm:max-w-4xl max-h-[90vh] overflow-auto",children:[s.jsxs("div",{className:"mb-6 px-1",children:[s.jsx("h1",{className:`${tp} truncate`,children:Pa}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${Lc(on)}`}),s.jsx("span",{className:"text-foreground",children:t(Fc(ya))}),ya==="connecting"?s.jsx("span",{children:t(Dc(on))}):null,Ds?.localUrl?s.jsx("span",{className:"font-mono text-foreground/80",children:Ds.localUrl}):null,va?s.jsx("span",{children:t("settings.remoteInstances.page.status.reconnectStale")}):null]})]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.actions"),info:t("settings.remoteInstances.page.section.actionsDescription"),divider:!1,contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(q,{type:"button",variant:rn?"outline":"default",size:"xs",className:"!font-normal",onClick:Wn,disabled:ae||Q,children:[rn?s.jsx(J,{name:"stop",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"plug-2",className:"h-3.5 w-3.5"}),or]}),s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:ar,disabled:!Ia,children:[s.jsx(J,{name:"refresh",className:`h-3.5 w-3.5 ${jn||yn&&!va?"animate-spin":""}`}),ir]}),s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{sr()},children:[s.jsx(J,{name:"terminal-window",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.logs")]}),s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal text-[var(--status-error)] border-[var(--status-error)]/30 hover:text-[var(--status-error)]",onClick:()=>{window.confirm(t("settings.remoteInstances.page.confirm.removeInstance"))&&b(C.id).then(()=>{N(null),W.success(t("settings.remoteInstances.page.toast.instanceRemoved"))}).catch(ve=>{W.error(t("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:ve instanceof Error?ve.message:String(ve)})})},children:[s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.sidebar.actions.remove")]})]}),ya==="error"&&Ds?.detail?s.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--status-error)]/30 bg-[var(--status-error-background)] p-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)] break-words",children:Ds.detail}),ci?s.jsx("p",{className:"typography-micro text-muted-foreground",children:t(ci)}):null,Hn&&!ci?s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{tr(Hn)},children:t(Hn==="uiPassword"?"settings.remoteInstances.page.error.action.setUiPassword":Hn==="localPort"?"settings.remoteInstances.page.error.action.pickRandomPort":"settings.remoteInstances.page.error.action.setRemotePort")}):null]}):null,Ds?.localUrl?s.jsxs("div",{className:"flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx("span",{children:t("settings.remoteInstances.page.status.currentLocalUrl")}),s.jsx("span",{className:"font-mono text-foreground/90",children:Ds.localUrl})]}):null]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.instance"),info:t("settings.remoteInstances.page.section.instanceDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.sshCommand")}),s.jsx(Ve,{className:"h-7 md:max-w-xl",value:C.sshCommand,onChange:U=>ms(ve=>({...ve,sshCommand:U.target.value})),placeholder:t("settings.remoteInstances.page.field.sshCommandPlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.nickname")}),s.jsx(Ve,{className:"h-7 md:max-w-sm",value:C.nickname||"",onChange:U=>ms(ve=>({...ve,nickname:U.target.value})),placeholder:t("settings.remoteInstances.page.field.nicknamePlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.mode"),hint:t("settings.remoteInstances.page.field.modeHint")})}),s.jsxs(Tt,{value:C.remoteOpenchamber.mode,onValueChange:U=>ms(ve=>({...ve,remoteOpenchamber:{...ve.remoteOpenchamber,mode:U==="external"?"external":"managed"}})),children:[s.jsx(Pt,{className:"w-fit min-w-[140px]",children:s.jsx(Ut,{placeholder:t("settings.remoteInstances.page.field.modePlaceholder")})}),s.jsxs(At,{children:[s.jsx(ot,{value:"managed",children:t("settings.remoteInstances.page.field.modeManaged")}),s.jsx(ot,{value:"external",children:t("settings.remoteInstances.page.field.modeExternal")})]})]})]})]}),s.jsxs(Js,{open:zi,onOpenChange:mn,children:[s.jsxs(Qs,{className:"mt-6 w-auto justify-start gap-1.5",children:[s.jsx("span",{className:On,children:t("settings.remoteInstances.page.section.advanced")}),s.jsx(J,{name:zi?"arrow-up-s":"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsxs(Ys,{children:[s.jsx("p",{className:"px-2 pb-2 typography-micro text-muted-foreground",children:t("settings.remoteInstances.page.section.advancedHint")}),s.jsxs("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.connectionTimeoutSeconds")}),s.jsx(ps,{containerClassName:"w-fit",min:5,max:240,step:1,className:Me(fs,"tabular-nums"),value:C.connectionTimeoutSec,onValueChange:U=>{ms(ve=>({...ve,connectionTimeoutSec:Number.isFinite(U)?U:ve.connectionTimeoutSec}))}})]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.remoteServer"),info:t("settings.remoteInstances.page.section.remoteServerDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",ref:Hi,children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.preferredRemotePort"),hint:t("settings.remoteInstances.page.field.preferredRemotePortHint")})}),s.jsx(ps,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Me(fs,"tabular-nums"),value:C.remoteOpenchamber.preferredPort,onValueChange:U=>{ms(ve=>({...ve,remoteOpenchamber:{...ve.remoteOpenchamber,preferredPort:Number.isFinite(U)&&U>0?U:void 0}}))},onClear:()=>{ms(U=>({...U,remoteOpenchamber:{...U.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]}),Gn?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.installMethod"),hint:t("settings.remoteInstances.page.field.installMethodHint")})}),s.jsxs(Tt,{value:C.remoteOpenchamber.installMethod,onValueChange:U=>ms(ve=>({...ve,remoteOpenchamber:{...ve.remoteOpenchamber,installMethod:U==="npm"||U==="bun"?U:"auto"}})),children:[s.jsx(Pt,{className:"w-fit min-w-[140px]",children:s.jsx(Ut,{placeholder:t("settings.remoteInstances.page.field.selectInstallMethodPlaceholder")})}),s.jsxs(At,{children:[s.jsx(ot,{value:"auto",children:t("settings.remoteInstances.page.field.installMethodAuto")}),s.jsx(ot,{value:"bun",children:"bun"}),s.jsx(ot,{value:"npm",children:"npm"})]})]})]}):null,Gn?s.jsxs("div",{className:"py-1.5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.remoteLanAccess"),hint:t("settings.remoteInstances.page.field.remoteLanAccessHint")})}),s.jsx(ra,{checked:we,onCheckedChange:U=>ms(ve=>({...ve,remoteOpenchamber:{...ve.remoteOpenchamber,bindHost:U?"0.0.0.0":"127.0.0.1"}})),"aria-label":t("settings.remoteInstances.page.field.remoteLanAccess")})]}),we?s.jsx("p",{className:"mt-2 typography-micro text-[var(--status-warning)] md:ps-[16rem]",children:t("settings.remoteInstances.page.field.remoteLanAccessWarning")}):null]}):null,Gn?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.keepServerRunning"),hint:t("settings.remoteInstances.page.field.keepServerRunningHint")})}),s.jsx("div",{className:"flex w-full items-center gap-2 md:max-w-xs",children:s.jsx(ra,{checked:C.remoteOpenchamber.keepRunning,onCheckedChange:U=>ms(ve=>({...ve,remoteOpenchamber:{...ve.remoteOpenchamber,keepRunning:U}}))})})]}):null]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.mainTunnel"),info:t("settings.remoteInstances.page.section.mainTunnelDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.bindHost"),hint:t("settings.remoteInstances.page.field.bindHostHint")})}),s.jsxs(Tt,{value:C.localForward.bindHost,onValueChange:U=>{U==="0.0.0.0"&&!window.confirm(t("settings.remoteInstances.page.confirm.bindAllInterfaces"))||ms(ve=>({...ve,localForward:{...ve.localForward,bindHost:U==="localhost"||U==="0.0.0.0"?U:"127.0.0.1"}}))},children:[s.jsx(Pt,{className:"w-fit min-w-[240px]",children:s.jsx(Ut,{placeholder:t("settings.remoteInstances.page.field.selectBindHostPlaceholder")})}),s.jsxs(At,{children:[s.jsx(ot,{value:"127.0.0.1",children:t("settings.remoteInstances.page.field.bindHostOption.loopback")}),s.jsx(ot,{value:"localhost",children:t("settings.remoteInstances.page.field.bindHostOption.localhost")}),s.jsx(ot,{value:"0.0.0.0",children:t("settings.remoteInstances.page.field.bindHostOption.lan")})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.preferredLocalPort"),hint:t("settings.remoteInstances.page.field.preferredLocalPortHint")})}),s.jsxs("div",{className:"flex w-full items-center gap-2 md:max-w-sm",children:[s.jsx(ps,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Me(fs,"tabular-nums"),value:C.localForward.preferredLocalPort,onValueChange:U=>{ms(ve=>({...ve,localForward:{...ve.localForward,preferredLocalPort:Number.isFinite(U)&&U>0?U:void 0}}))},onClear:()=>{ms(U=>({...U,localForward:{...U.localForward,preferredLocalPort:void 0}}))},emptyLabel:t("settings.remoteInstances.page.field.auto")}),s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal h-7 w-7 px-0",title:t("settings.remoteInstances.page.actions.pickRandomPort"),onClick:()=>ms(U=>({...U,localForward:{...U.localForward,preferredLocalPort:po()}})),children:s.jsx(J,{name:"shuffle",className:"h-3.5 w-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1 pt-1",children:[s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.remoteInstances.page.tunnelPreview.caption")}),s.jsx("p",{className:"typography-micro font-mono text-foreground/80 break-all",children:`${C.localForward.bindHost}:${C.localForward.preferredLocalPort||"auto"} → ${C.sshParsed?.destination||C.nickname||"remote"}:${C.remoteOpenchamber.preferredPort||"auto"}`})]})]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.authentication"),info:t("settings.remoteInstances.page.section.authenticationDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.sshPasswordOptional"),hint:t("settings.remoteInstances.page.field.sshPasswordHint")})}),s.jsx(Ve,{className:"h-7 md:max-w-sm",type:"password",value:C.auth.sshPassword?.value||"",onChange:U=>ms(ve=>({...ve,auth:{...ve.auth,sshPassword:{enabled:U.target.value.trim().length>0,value:U.target.value,store:ve.auth.sshPassword?.store||"never"}}})),placeholder:t("settings.remoteInstances.page.field.sshPasswordPlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t(we?"settings.remoteInstances.page.field.uiPasswordRequired":"settings.remoteInstances.page.field.uiPasswordOptional"),hint:t(Gn?"settings.remoteInstances.page.field.uiPasswordHintManaged":"settings.remoteInstances.page.field.uiPasswordHintExternal")})}),s.jsx(Ve,{className:Me("h-7 md:max-w-sm",Zt&&"border-[var(--status-error)]"),type:"password",ref:Sa,"aria-invalid":Zt,value:C.auth.openchamberPassword?.value||"",onChange:U=>ms(ve=>({...ve,auth:{...ve.auth,openchamberPassword:{enabled:U.target.value.trim().length>0,value:U.target.value,store:ve.auth.openchamberPassword?.store||"never"}}})),placeholder:t("settings.remoteInstances.page.field.uiPasswordPlaceholder")})]}),Zt?s.jsx("p",{className:"typography-micro text-[var(--status-error)] md:ps-[16rem]",children:t("settings.remoteInstances.page.field.uiPasswordMissingForLan")}):null]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.portForwards"),info:t("settings.remoteInstances.page.section.portForwardsDescription"),contentClassName:"space-y-2",children:[C.portForwards.length===0?s.jsx("p",{className:"typography-micro text-muted-foreground/80",children:t("settings.remoteInstances.page.empty.noExtraForwards")}):null,C.portForwards.map((U,ve)=>{const Ge=Ot=>{ms(Xt=>({...Xt,portForwards:Xt.portForwards.map((wn,zn)=>zn===ve?Ot(wn):wn)}))},ut=U.type==="remote"?"Local target":"Local listen",$t=U.type==="remote"?"Local host and port on your machine that receives traffic from remote -R listener.":"Local host and port where this forward listens on your machine.",xs=U.type==="remote"?"Remote listen":"Remote target",_s=U.type==="remote"?"Remote host and port where SSH creates the -R listener.":"Remote host and port that receives traffic from local -L listener.",ds=Kc(U.localHost||"localhost",U.localPort),Ps=Kc(U.remoteHost||"localhost",U.remotePort),kn=U.type==="local"&&typeof U.localPort=="number"&&U.localPort>0,Vs=kn?`http://${Jv(U.localHost)}:${U.localPort}`:"",ln=!!G[U.id],cn=U.type==="local"?t("settings.remoteInstances.page.forwardType.local"):U.type==="remote"?t("settings.remoteInstances.page.forwardType.remote"):t("settings.remoteInstances.page.forwardType.dynamic");return s.jsxs(Js,{open:ln,onOpenChange:Ot=>{ee(Xt=>({...Xt,[U.id]:Ot}))},className:`${ve>0?"border-t border-[var(--surface-subtle)]":""} py-2`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:s.jsxs(Qs,{className:"flex items-center gap-2 group",children:[s.jsx(J,{name:"arrow-down-s",className:`h-4 w-4 text-muted-foreground transition-transform ${ln?"rotate-180":""}`}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Hv(U)}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:cn})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ra,{checked:U.enabled,onCheckedChange:Ot=>Ge(Xt=>({...Xt,enabled:Ot})),"aria-label":t("settings.remoteInstances.page.actions.enableForwardAria")}),s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>ms(Ot=>({...Ot,portForwards:Ot.portForwards.filter(Xt=>Xt.id!==U.id)})),children:s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Ys,{className:"pt-2",children:s.jsxs("div",{className:"space-y-0 pb-2",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:t("settings.remoteInstances.page.field.forwardType"),hint:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.remoteInstances.page.field.forwardTypeHint")}),s.jsx("p",{children:t(Gv(U.type))})]})})}),s.jsxs(Tt,{value:U.type,onValueChange:Ot=>Ge(Xt=>({...Xt,type:Ot==="dynamic"||Ot==="remote"?Ot:"local"})),children:[s.jsx(Pt,{className:"w-fit min-w-[140px]",children:s.jsx(Ut,{placeholder:t("settings.remoteInstances.page.field.typePlaceholder")})}),s.jsxs(At,{children:[s.jsx(ot,{value:"local",children:t("settings.remoteInstances.page.forwardType.local")}),s.jsx(ot,{value:"remote",children:t("settings.remoteInstances.page.forwardType.remote")}),s.jsx(ot,{value:"dynamic",children:t("settings.remoteInstances.page.forwardType.dynamic")})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:ut,hint:$t})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ve,{className:"h-7 w-32",value:U.localHost||"127.0.0.1",onChange:Ot=>Ge(Xt=>({...Xt,localHost:Ot.target.value})),placeholder:t("settings.remoteInstances.page.field.localHostPlaceholder")}),s.jsx("span",{className:"text-muted-foreground",children:":"}),s.jsx(ps,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Me(fs,"tabular-nums"),value:U.localPort,onValueChange:Ot=>{Ge(Xt=>({...Xt,localPort:Number.isFinite(Ot)&&Ot>0?Ot:void 0}))},onClear:()=>{Ge(Ot=>({...Ot,localPort:void 0}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]})]}),U.type!=="dynamic"?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(Xs,{label:xs,hint:_s})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ve,{className:"h-7 w-32",value:U.remoteHost||"",onChange:Ot=>Ge(Xt=>({...Xt,remoteHost:Ot.target.value})),placeholder:t("settings.remoteInstances.page.field.remoteHostPlaceholder")}),s.jsx("span",{className:"text-muted-foreground",children:":"}),s.jsx(ps,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Me(fs,"tabular-nums"),value:U.remotePort,onValueChange:Ot=>{Ge(Xt=>({...Xt,remotePort:Number.isFinite(Ot)&&Ot>0?Ot:void 0}))},onClear:()=>{Ge(Ot=>({...Ot,remotePort:void 0}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]})]}):null,s.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md bg-[var(--surface-subtle)] p-2",children:[s.jsx("div",{className:"flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80",children:U.type==="dynamic"?s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:ds}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.localSocks5")})]}):U.type==="remote"?s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"server",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:Ps}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.remote")}),s.jsx(J,{name:"arrow-right",className:"h-3.5 w-3.5"}),s.jsx(J,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:ds}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.local")})]}):s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:ds}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.local")}),s.jsx(J,{name:"arrow-right",className:"h-3.5 w-3.5"}),s.jsx(J,{name:"server",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:Ps}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.remote")})]})}),kn?s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{ks(Vs).then(Ot=>{Ot||W.error(t("settings.remoteInstances.page.toast.openLocalEndpointFailed"))})},children:[s.jsx(J,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.openLocal")]}):null]})]})})]},U.id)}),s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal mt-1",onClick:()=>{const U=qv();ms(ve=>({...ve,portForwards:[...ve.portForwards,U]})),ee(ve=>({...ve,[U.id]:!0}))},children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.addForward")]})]})]})]}),s.jsx("div",{className:"mt-8 border-t border-[var(--interactive-border)] pt-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Xo()},disabled:!Zo||m,children:t("settings.common.actions.saveChanges")}),Ds?.localUrl?s.jsxs(s.Fragment,{children:[s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{$a(Ds.localUrl||"").then(U=>{U.ok&&W.success(t("settings.remoteInstances.page.toast.localUrlCopied"))})},children:[s.jsx(J,{name:"file-copy",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.copyLocalUrl")]}),s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{C&&_i(C.id)},children:[s.jsx(J,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.open")]})]}):null,d?s.jsx("div",{className:"ms-auto typography-meta text-[var(--status-error)]",children:d}):null]})}),j,s.jsx(Kt,{open:A,onOpenChange:R,children:s.jsxs(zt,{className:"sm:max-w-2xl",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.remoteInstances.page.logsDialog.title")}),s.jsx(Vt,{children:C?.nickname?.trim()||C?.sshParsed?.destination||C?.id||t("settings.remoteInstances.page.logsDialog.selectedInstanceFallback")})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:nr,disabled:K||!Ca.trim(),children:[s.jsx(J,{name:"file-copy",className:"h-3.5 w-3.5"}),t("settings.common.actions.copyAll")]}),s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{qn()},disabled:K,children:[s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.clear")]})]}),K?s.jsx("div",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.logsDialog.loading")}):T?s.jsx("div",{className:"typography-meta text-[var(--status-error)]",children:T}):s.jsx("pre",{className:"max-h-[55vh] overflow-auto rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3 typography-micro text-foreground whitespace-pre-wrap break-words",children:E.length>0?E.join(`
|
|
29
|
+
`):t("settings.remoteInstances.page.logsDialog.empty")})]})}),s.jsx(Kt,{open:!!_,onOpenChange:U=>{U||ka()},children:s.jsxs(zt,{className:"sm:max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:t("settings.remoteInstances.page.patternDialog.title")}),s.jsx(Vt,{children:_?t("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:_}):t("settings.remoteInstances.page.patternDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Vi()},children:[s.jsx(Ve,{value:ne,onChange:U=>z(U.target.value),placeholder:t("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:ka,disabled:$,children:t("settings.common.actions.cancel")}),s.jsx(q,{type:"submit",size:"xs",className:"!font-normal",disabled:$,children:t("settings.common.actions.create")})]})]})]})})]})})},Fu=ss({providers:Zs(St())}),sy=ss({error:St().min(1)}),ny=async()=>{const t=await Rt("/api/provider/disabled");if(t.status===404)return null;if(!t.ok)throw new Error(`Could not read disabled providers (${t.status})`);return Fu.parse(await t.json()).providers},ay=async(t,e)=>{const a=await Rt(`/api/provider/${encodeURIComponent(t)}/disabled`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:e})}),n=await a.json().catch(()=>null);if(!a.ok){const o=sy.safeParse(n);throw new Error(o.success?o.data.error:`Could not update the provider (${a.status})`)}return Fu.parse(n).providers},iy=(t,e,a)=>t&&!e&&!a,$c="grid grid-cols-1 gap-0.5 @xl:grid-cols-2 @3xl:grid-cols-3",Ou="flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-start typography-ui-label text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",Bc=t=>{const e=$e.c(11),{provider:a,onSelect:n}=t;let o;e[0]!==n||e[1]!==a.id?(o=()=>n(a.id),e[0]=n,e[1]=a.id,e[2]=o):o=e[2];let i;e[3]!==a.id?(i=s.jsx(an,{providerId:a.id,className:"size-4 shrink-0"}),e[3]=a.id,e[4]=i):i=e[4];let r;e[5]!==a.name?(r=s.jsx("span",{className:"truncate",children:a.name}),e[5]=a.name,e[6]=r):r=e[6];let l;return e[7]!==o||e[8]!==i||e[9]!==r?(l=s.jsxs("button",{type:"button",className:Ou,onClick:o,children:[i,r]}),e[7]=o,e[8]=i,e[9]=r,e[10]=l):l=e[10],l},oy=t=>{const e=$e.c(56),{providers:a,loadFailed:n,onSelect:o,onSelectCustom:i}=t,{t:r}=ze(),[l,u]=c.useState(""),[m,d]=c.useState(!1);let f;e[0]!==a?(f=a??[],e[0]=a,e[1]=f):f=e[1];let g;e[2]!==f?(g=pf(f),e[2]=f,e[3]=g):g=e[3];const{popular:p,others:h}=g;let w,b,k;if(e[4]!==n||e[5]!==o||e[6]!==i||e[7]!==a||e[8]!==l||e[9]!==r){k=Symbol.for("react.early_return_sentinel");e:{if(w=r("settings.providers.page.custom.title"),a===null){let A;e[13]!==n||e[14]!==r?(A=r(n?"settings.providers.page.state.unableToLoadProviderList":"settings.providers.page.state.loading"),e[13]=n,e[14]=r,e[15]=A):A=e[15];let R;e[16]!==A?(R=s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:A}),e[16]=A,e[17]=R):R=e[17],k=R;break e}let C;e[18]!==r?(C=r("settings.providers.connect.searchPlaceholder"),e[18]=r,e[19]=C):C=e[19];let P;if(e[20]!==l||e[21]!==C?(P=s.jsx(Fo,{value:l,onChange:u,placeholder:C}),e[20]=l,e[21]=C,e[22]=P):P=e[22],b=P,l.trim().length>0){const A=_n(a,l,ry),R=Ci([w,"other","custom","openai-compatible"],l),K=A.length===0&&!R?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:r("settings.providers.page.connect.noProvidersFound")}):s.jsxs("div",{className:$c,children:[A.map(T=>s.jsx(Bc,{provider:T,onSelect:o},T.id)),R?s.jsxs("button",{type:"button",className:Ou,onClick:i,children:[s.jsx(J,{name:"add",className:"size-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"truncate",children:w})]}):null]});let F;e[23]!==b||e[24]!==K?(F=s.jsxs(s.Fragment,{children:[b,K]}),e[23]=b,e[24]=K,e[25]=F):F=e[25],k=F;break e}}e[4]=n,e[5]=o,e[6]=i,e[7]=a,e[8]=l,e[9]=r,e[10]=w,e[11]=b,e[12]=k}else w=e[10],b=e[11],k=e[12];if(k!==Symbol.for("react.early_return_sentinel"))return k;let v;e[26]!==r?(v=r("settings.providers.connect.popular"),e[26]=r,e[27]=v):v=e[27];let S;if(e[28]!==o||e[29]!==p||e[30]!==r){let C;e[32]!==o||e[33]!==r?(C=P=>s.jsx(Ga,{icon:s.jsx(an,{providerId:P.id,className:"size-5"}),title:P.name,badges:P.recommended?s.jsx(tn,{tone:"neutral",children:r("settings.providers.connect.recommended")}):null,description:r(P.noteKey),onOpen:()=>o(P.id)},P.id),e[32]=o,e[33]=r,e[34]=C):C=e[34],S=p.map(C),e[28]=o,e[29]=p,e[30]=r,e[31]=S}else S=e[31];let y;e[35]!==r?(y=r("settings.providers.connect.customHint"),e[35]=r,e[36]=y):y=e[36];let N;e[37]!==w||e[38]!==i||e[39]!==y?(N=s.jsx(Oo,{label:w,hint:y,onClick:i}),e[37]=w,e[38]=i,e[39]=y,e[40]=N):N=e[40];let x;e[41]!==S||e[42]!==N?(x=s.jsxs("div",{className:Lo,children:[S,N]}),e[41]=S,e[42]=N,e[43]=x):x=e[43];let I;e[44]!==v||e[45]!==x?(I=s.jsx(He,{title:v,divider:!1,settingsItem:"providers.connect",children:x}),e[44]=v,e[45]=x,e[46]=I):I=e[46];let j;e[47]!==o||e[48]!==h||e[49]!==m||e[50]!==r?(j=h.length>0?s.jsx(He,{title:r("settings.providers.connect.all"),children:m?s.jsx("div",{className:$c,children:h.map(C=>s.jsx(Bc,{provider:C,onSelect:o},C.id))}):s.jsx(q,{variant:"outline",size:"sm",className:"!font-normal",onClick:()=>d(!0),children:r("settings.providers.connect.showAll",{count:h.length})})}):null,e[47]=o,e[48]=h,e[49]=m,e[50]=r,e[51]=j):j=e[51];let D;return e[52]!==b||e[53]!==j||e[54]!==I?(D=s.jsxs(s.Fragment,{children:[b,I,j]}),e[52]=b,e[53]=j,e[54]=I,e[55]=D):D=e[55],D};function ry(t){return[t.name,t.id]}const ly=St(),sl=t=>ly.safeParse(t?.settings?.apiKey).data??null,cy=St().min(1),nl=t=>t!==void 0&&(t.id==="google-vertex"||t.package.startsWith("@opencode/ai/providers/google-vertex"))&&cy.safeParse(t.settings?.project).success,gn=(t,e)=>t.find(a=>a.id===e),ji=t=>t==="opencode-go"?"opencode":t,go=(t,e)=>{const a=gn(t,e)?.connections,n=ji(e);if(n===e)return a;const o=gn(t,n)?.connections;if(!(!a&&!o))return[...a??[],...o??[]]},al=t=>(t?.methods??[]).filter(e=>e.type==="oauth"||e.type==="external"),il=t=>(t?.methods??[]).find(e=>e.type==="key"),_c=t=>t===void 0||il(t)!==void 0,Vc=t=>(t?.connections??[]).filter(e=>e.type==="credential"),Hc=t=>(t.connections?.length??0)>0||t.machineCredentials?!0:typeof t.optionsApiKey=="string"&&t.optionsApiKey.trim().length>0,Dl=t=>t.status?.status==="needs_auth",dy=t=>{if(t.integrations===null)return null;const e=go(t.integrations,t.providerId);if((e??[]).some(Dl))return{kind:"reauthNeeded"};const a=(e??[]).filter(n=>n.type==="credential").length;return a>1?{kind:"accounts",count:a}:a===1||(t.optionsApiKey?.trim().length??0)>0?{kind:"connected"}:t.machineCredentials||(e??[]).some(n=>n.type==="env")?{kind:"environment"}:e===void 0?null:{kind:"signInNeeded"}},uy=t=>t.modelCount>0&&(!t.integrationsLoaded||t.hasCredentials||!!t.isEditableCustomProvider),my=t=>!t.hasCredentials&&!t.userDismissed&&!t.isEditableCustomProvider,Ko=t=>{const e=$e.c(12),{t:a}=ze();if(t==="zen-promo"){let n;return e[0]!==a?(n=a("settings.classification.source.zenPromo.name"),e[0]=a,e[1]=n):n=e[1],n}if(t==="zen-key"){let n;return e[2]!==a?(n=a("settings.classification.source.zenKey.name"),e[2]=a,e[3]=n):n=e[3],n}if(t==="openrouter"){let n;return e[4]!==a?(n=a("settings.classification.source.openrouter.name"),e[4]=a,e[5]=n):n=e[5],n}if(t==="vercel"){let n;return e[6]!==a?(n=a("settings.classification.source.vercel.name"),e[6]=a,e[7]=n):n=e[7],n}if(t==="typesafe"){let n;return e[8]!==a?(n=a("settings.classification.source.typesafe.name"),e[8]=a,e[9]=n):n=e[9],n}if(t==="custom"){let n;return e[10]!==a?(n=a("settings.classification.source.custom.name"),e[10]=a,e[11]=n):n=e[11],n}return null},Ao=()=>{const t=oe.getState();t.setSettingsProvidersClassificationRequested(!0),t.requestSettingsJump("providers","providers.classification")},Mn=t=>{const e=$e.c(3),{onClick:a,children:n}=t;let o;return e[0]!==n||e[1]!==a?(o=s.jsx("button",{type:"button",onClick:a,className:"cursor-pointer text-[var(--primary-text)] underline-offset-4 hover:underline focus-visible:underline focus-visible:outline-none",children:n}),e[0]=n,e[1]=a,e[2]=o):o=e[2],o},zo=()=>{const t=$e.c(16),{t:e}=ze(),a=Wt(py),n=Wt(gy),o=Wt(fy),i=Ko(o),r=Ln();if(!a)return null;if(r&&!n){let f;t[0]!==e?(f=e("settings.jevAccess.enterprise"),t[0]=e,t[1]=f):f=t[1];let g;return t[2]!==f?(g=s.jsx("p",{className:Dt,children:f}),t[2]=f,t[3]=g):g=t[3],g}let l;t[4]!==n||t[5]!==i||t[6]!==e?(l=n&&i?e("settings.jevAccess.via",{provider:i}):e("settings.jevAccess.missing"),t[4]=n,t[5]=i,t[6]=e,t[7]=l):l=t[7];let u;t[8]!==n||t[9]!==e?(u=e(n?"settings.jevAccess.manage":"settings.jevAccess.setUp"),t[8]=n,t[9]=e,t[10]=u):u=t[10];let m;t[11]!==u?(m=s.jsx(Mn,{onClick:Ao,children:u}),t[11]=u,t[12]=m):m=t[12];let d;return t[13]!==l||t[14]!==m?(d=s.jsxs("p",{className:Dt,children:[l," ",m]}),t[13]=l,t[14]=m,t[15]=d):d=t[15],d};function py(t){return t.available}function gy(t){return t.jevAvailable}function fy(t){return t.classifier?.effective??null}const hy="https://opencode.ai/v2/docs/policies/",by=t=>{const e=$e.c(3),[a,n]=c.useState(null);let o,i;return e[0]!==t?(o=()=>{let r=!1;return n(null),Ks.configDeniesAnyProvider(t).then(l=>{r||n(l)}).catch(l=>{console.warn("[providers] could not read OpenCode provider policies:",l instanceof Error?l.message:String(l)),r||n(null)}),()=>{r=!0}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),c.useEffect(o,i),a},xy=t=>{const e=$e.c(44),{directory:a,integrations:n}=t,{t:o}=ze(),i=by(a),r=Ai(wy),l=Ai(Sy),u=n===null?null:(gn(n,"opencode")?.connections?.length??0)>0,m=i!==!1||u===null?null:u?"console":"open",d=m==="open";let f;e[0]!==o?(f=o("settings.providers.enterprisePolicyLink"),e[0]=o,e[1]=f):f=e[1];let g;e[2]!==f?(g=s.jsx(Mn,{onClick:Ny,children:f}),e[2]=f,e[3]=g):g=e[3];const p=g,h=d?"border-[var(--status-warning)]/30 bg-[var(--status-warning)]/5":"border-[var(--status-info-border)] bg-[var(--status-info-background)]/30";let w;e[4]!==h?(w=Me("mb-4 flex items-start gap-2 rounded-lg border p-3",h),e[4]=h,e[5]=w):w=e[5];const b=d?"error-warning":"information",k=d?"text-[var(--status-warning)]":"text-[var(--status-info)]";let v;e[6]!==k?(v=Me("mt-0.5 size-4 shrink-0",k),e[6]=k,e[7]=v):v=e[7];let S;e[8]!==b||e[9]!==v?(S=s.jsx(J,{name:b,className:v}),e[8]=b,e[9]=v,e[10]=S):S=e[10];let y;e[11]!==o?(y=o("settings.providers.enterpriseTitle"),e[11]=o,e[12]=y):y=e[12];let N;e[13]!==y?(N=s.jsx("p",{className:Vr,children:y}),e[13]=y,e[14]=N):N=e[14];let x;e[15]!==r||e[16]!==o?(x=r?s.jsx("p",{className:"typography-meta text-foreground",children:o("settings.providers.enterpriseManagedBy",{organization:r})}):null,e[15]=r,e[16]=o,e[17]=x):x=e[17];let I;e[18]!==l||e[19]!==o?(I=l?s.jsx("p",{className:"typography-meta text-foreground",children:o("settings.providers.enterprisePolicyUnreadable")}):null,e[18]=l,e[19]=o,e[20]=I):I=e[20];let j;e[21]!==o?(j=o("settings.providers.enterpriseMode"),e[21]=o,e[22]=j):j=e[22];let D;e[23]!==j?(D=s.jsx("p",{className:"typography-meta text-muted-foreground",children:j}),e[23]=j,e[24]=D):D=e[24];let C;e[25]!==m||e[26]!==p||e[27]!==o?(C=m==="open"?s.jsxs("p",{className:"typography-meta text-foreground",children:[o("settings.providers.enterprisePolicyMissing")," ",p]}):null,e[25]=m,e[26]=p,e[27]=o,e[28]=C):C=e[28];let P;e[29]!==m||e[30]!==p||e[31]!==o?(P=m==="console"?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[o("settings.providers.enterprisePolicyConsole")," ",p]}):null,e[29]=m,e[30]=p,e[31]=o,e[32]=P):P=e[32];let A;e[33]!==N||e[34]!==x||e[35]!==I||e[36]!==D||e[37]!==C||e[38]!==P?(A=s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[N,x,I,D,C,P]}),e[33]=N,e[34]=x,e[35]=I,e[36]=D,e[37]=C,e[38]=P,e[39]=A):A=e[39];let R;return e[40]!==A||e[41]!==w||e[42]!==S?(R=s.jsxs("div",{className:w,children:[S,A]}),e[40]=A,e[41]=w,e[42]=S,e[43]=R):R=e[43],R},vy=t=>{const e=$e.c(19),{onOpen:a}=t,{t:n}=ze(),o=Wt(Cy),i=Wt(Iy),r=Wt(Py);if(!o)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx(an,{providerId:"typesafe",className:"size-5"}),e[0]=l):l=e[0];let u;e[1]!==n?(u=n("settings.classification.page.title"),e[1]=n,e[2]=u):u=e[2];const m=i?"success":r?"neutral":"warning";let d;e[3]!==i||e[4]!==r||e[5]!==n?(d=n(i?"settings.classification.card.ready":r?"settings.classification.card.off":"settings.classification.card.notSetUp"),e[3]=i,e[4]=r,e[5]=n,e[6]=d):d=e[6];let f;e[7]!==m||e[8]!==d?(f=s.jsx(tn,{tone:m,children:d}),e[7]=m,e[8]=d,e[9]=f):f=e[9];let g;e[10]!==n?(g=n("settings.classification.card.usedFor"),e[10]=n,e[11]=g):g=e[11];let p;e[12]!==g?(p=s.jsx("span",{className:"min-w-0 truncate",children:g}),e[12]=g,e[13]=p):p=e[13];let h;return e[14]!==a||e[15]!==u||e[16]!==f||e[17]!==p?(h=s.jsx(Ga,{icon:l,title:u,subtitle:"jev",badges:f,footer:p,onOpen:a}),e[14]=a,e[15]=u,e[16]=f,e[17]=p,e[18]=h):h=e[18],h},yy=(t,e)=>{const[a,n]=c.useState(()=>new Set);return c.useEffect(()=>{let o=!1;const i=e?`?directory=${encodeURIComponent(e)}`:"";return Promise.all(t.map(async r=>{try{const l=await Rt(`/api/provider/${encodeURIComponent(r.id)}/source${i}`,{method:"GET",headers:{Accept:"application/json"}});if(!l.ok)return null;const u=await l.json().catch(()=>null);return(u?.sources??u?.data?.sources)?.project?.exists===!0?r.id:null}catch{return null}})).then(r=>{o||n(new Set(r.filter(l=>l!==null)))}),()=>{o=!0}},[e,t]),a},jy=t=>{const e=$e.c(14),{status:a}=t,{t:n}=ze();let o;e:switch(a.kind){case"reauthNeeded":{let l;e[0]!==n?(l=n("settings.providers.card.status.reauthNeeded"),e[0]=n,e[1]=l):l=e[1],o=l;break e}case"accounts":{let l;e[2]!==a.count||e[3]!==n?(l=n("settings.providers.card.status.accounts",{count:a.count}),e[2]=a.count,e[3]=n,e[4]=l):l=e[4],o=l;break e}case"connected":{let l;e[5]!==n?(l=n("settings.providers.card.status.connected"),e[5]=n,e[6]=l):l=e[6],o=l;break e}case"environment":{let l;e[7]!==n?(l=n("settings.providers.card.status.environment"),e[7]=n,e[8]=l):l=e[8],o=l;break e}case"signInNeeded":{let l;e[9]!==n?(l=n("settings.providers.card.status.signInNeeded"),e[9]=n,e[10]=l):l=e[10],o=l}}const i=a.kind==="signInNeeded"||a.kind==="reauthNeeded"?"warning":a.kind==="environment"?"neutral":"success";let r;return e[11]!==o||e[12]!==i?(r=s.jsx(tn,{tone:i,children:o}),e[11]=o,e[12]=i,e[13]=r):r=e[13],r},ky=t=>{const e=$e.c(49),{providers:a,integrations:n,directory:o,onSelect:i,onConnect:r,onOpenClassification:l,disabledProviders:u,onEnableProvider:m}=t,{t:d}=ze(),[f,g]=c.useState(""),p=yy(a,o);let h;e[0]!==a?(h=[...a].sort(Ay),e[0]=a,e[1]=h):h=e[1];const b=_n(h,f,Ty);let k;e[2]!==f?(k=f.trim(),e[2]=f,e[3]=k):k=e[3];const v=k.length>0,S=Ln(),y=Yt;let N;e[4]!==d?(N=d("settings.page.providers.title"),e[4]=d,e[5]=N):N=e[5];let x;e[6]!==d?(x=d("settings.providers.grid.description"),e[6]=d,e[7]=x):x=e[7];let I;e[8]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(Oi,{className:"w-full min-w-0 @xl:w-56"}),e[8]=I):I=e[8];const j="[&>section:first-of-type]:pt-8";let D;e[9]!==o||e[10]!==n||e[11]!==S?(D=S?s.jsx(xy,{directory:o,integrations:n}):null,e[9]=o,e[10]=n,e[11]=S,e[12]=D):D=e[12];let C;e[13]!==a.length||e[14]!==f||e[15]!==d?(C=a.length>0?s.jsx(Fo,{value:f,onChange:g,placeholder:d("settings.providers.grid.searchPlaceholder")}):null,e[13]=a.length,e[14]=f,e[15]=d,e[16]=C):C=e[16];const P=a.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:d("settings.providers.grid.empty")}):b.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:d("settings.providers.grid.noMatches",{query:f.trim()})}):null,A=Lo;let R;e[17]!==v||e[18]!==S||e[19]!==r||e[20]!==d?(R=v||S?null:s.jsx(Oo,{label:d("settings.providers.grid.connect"),hint:d("settings.providers.grid.connectHint"),onClick:r}),e[17]=v,e[18]=S,e[19]=r,e[20]=d,e[21]=R):R=e[21];let K;e[22]!==v||e[23]!==l?(K=v?null:s.jsx(vy,{onOpen:l}),e[22]=v,e[23]=l,e[24]=K):K=e[24];let F;e[25]!==n||e[26]!==i||e[27]!==p||e[28]!==d?(F=_=>{const H=dy({integrations:n,providerId:_.id,optionsApiKey:sl(_),machineCredentials:nl(_)});return s.jsx(Ga,{icon:s.jsx(an,{providerId:_.id,className:"size-5"}),title:_.name||_.id,badges:H?s.jsx(jy,{status:H}):null,footer:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"inline-flex items-center gap-1","aria-label":d("settings.providers.card.models",{count:_.models.length}),children:[s.jsx(J,{name:"stack",className:"size-3.5 opacity-70","aria-hidden":!0}),s.jsx("span",{className:"tabular-nums",children:_.models.length})]}),p.has(_.id)?s.jsx(jo,{children:d("settings.providers.card.source.project")}):null]}),onOpen:()=>i(_.id)},_.id)},e[25]=n,e[26]=i,e[27]=p,e[28]=d,e[29]=F):F=e[29];const T=b.map(F);let O;e[30]!==A||e[31]!==R||e[32]!==K||e[33]!==T?(O=s.jsxs("div",{className:A,children:[R,K,T]}),e[30]=A,e[31]=R,e[32]=K,e[33]=T,e[34]=O):O=e[34];let E;e[35]!==u||e[36]!==m||e[37]!==d?(E=u&&u.length>0&&m?s.jsx(He,{title:d("settings.providers.disabled.title"),info:d("settings.providers.disabled.info"),children:s.jsx("div",{className:"space-y-1",children:u.map(_=>s.jsxs("div",{className:"flex items-center gap-2 py-1",children:[s.jsx(an,{providerId:_,className:"size-4 shrink-0 opacity-60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:_}),s.jsx(q,{size:"xs",variant:"outline",className:"!font-normal",onClick:()=>m(_),children:d("settings.providers.disabled.enable")})]},_))})}):null,e[35]=u,e[36]=m,e[37]=d,e[38]=E):E=e[38];let B;return e[39]!==y||e[40]!==O||e[41]!==E||e[42]!==N||e[43]!==x||e[44]!==I||e[45]!==D||e[46]!==C||e[47]!==P?(B=s.jsxs(y,{title:N,description:x,headerEnd:I,className:j,children:[D,C,P,O,E]}),e[39]=y,e[40]=O,e[41]=E,e[42]=N,e[43]=x,e[44]=I,e[45]=D,e[46]=C,e[47]=P,e[48]=B):B=e[48],B};function wy(t){return t.organization}function Sy(t){return t.policyError!==null}function Ny(){ks(hy)}function Cy(t){return t.available}function Iy(t){return t.jevAvailable}function Py(t){return t.classifier?.selected==="off"}function Ay(t,e){return(t.name||t.id).localeCompare(e.name||e.id,void 0,{sensitivity:"base"})}function Ty(t){return[t.name||t.id,t.id]}const Lu=t=>{const e=$e.c(38),{disabled:a,draft:n}=t,o=a===void 0?!1:a,{t:i}=ze();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={kind:"idle"},e[0]=r):r=e[0];const[l,u]=c.useState(r),m=l.kind==="done"?l.result:null,d=Ko(m?.source??null)??"";let f;e[1]!==n?(f=async()=>{const j=n?n():void 0;if(j!==null){u({kind:"running"});try{u({kind:"done",result:await sp(j)})}catch(D){const C=D;u({kind:"failed",error:C instanceof Error?C.message:String(C)})}}},e[1]=n,e[2]=f):f=e[2];const g=f;let p;e[3]!==d||e[4]!==m||e[5]!==l.error||e[6]!==l.kind||e[7]!==i?(p=()=>{if(l.kind==="failed")return{text:i("settings.classification.test.failed",{error:l.error}),ok:!1};if(!m)return null;if(m.ok)return{text:i("settings.classification.test.ok",{provider:d,model:m.model,ms:m.ms}),ok:!0};if(m.reason==="unavailable")return{text:i("settings.classification.test.unavailable"),ok:!1};if(m.reason==="timeout")return{text:i("settings.classification.test.timeout",{provider:d}),ok:!1};if(m.reason==="unparsable")return{text:i("settings.classification.test.unparsable",{provider:d}),ok:!1};if(m.reason==="network")return{text:i("settings.classification.test.network",{provider:d,error:m.message??""}),ok:!1};const j=m.status??0;return j===401||j===403?{text:i("settings.classification.test.keyRejected",{provider:d,status:j}),ok:!1}:j===404?{text:i("settings.classification.test.notFound",{provider:d}),ok:!1}:{text:i("settings.classification.test.http",{provider:d,status:j}),ok:!1}},e[3]=d,e[4]=m,e[5]=l.error,e[6]=l.kind,e[7]=i,e[8]=p):p=e[8];const h=p;let w,b,k,v,S,y;if(e[9]!==h||e[10]!==o||e[11]!==g||e[12]!==l.kind||e[13]!==i){w=h(),S="flex min-w-0 flex-col gap-1.5";let j;e[20]!==g?(j=()=>{g()},e[20]=g,e[21]=j):j=e[21];const D=o||l.kind==="running";let C;e[22]!==l.kind||e[23]!==i?(C=l.kind==="running"?i("settings.classification.test.running"):i("settings.classification.test.button"),e[22]=l.kind,e[23]=i,e[24]=C):C=e[24],e[25]!==j||e[26]!==D||e[27]!==C?(y=s.jsx(q,{size:"sm",variant:"outline",className:"self-start",onClick:j,disabled:D,children:C}),e[25]=j,e[26]=D,e[27]=C,e[28]=y):y=e[28],b="status",k="polite",v=Me(Dt,w&&!w.ok&&"text-[var(--status-error)]"),e[9]=h,e[10]=o,e[11]=g,e[12]=l.kind,e[13]=i,e[14]=w,e[15]=b,e[16]=k,e[17]=v,e[18]=S,e[19]=y}else w=e[14],b=e[15],k=e[16],v=e[17],S=e[18],y=e[19];const N=w?.text??"";let x;e[29]!==N||e[30]!==b||e[31]!==k||e[32]!==v?(x=s.jsx("p",{role:b,"aria-live":k,className:v,children:N}),e[29]=N,e[30]=b,e[31]=k,e[32]=v,e[33]=x):x=e[33];let I;return e[34]!==x||e[35]!==S||e[36]!==y?(I=s.jsxs("div",{className:S,children:[y,x]}),e[34]=x,e[35]=S,e[36]=y,e[37]=I):I=e[37],I},Nr="flex w-full min-w-0 items-center gap-2",Cr="h-8 rounded-md px-3 min-w-0 flex-1",Ey=()=>{const{t}=ze(),e=Wt(S=>S.customEndpoint),a=Wt(S=>S.setCustomEndpoint),n=Wt(S=>S.clearCustomEndpoint),[o,i]=c.useState(e?.url??""),[r,l]=c.useState(e?.model??""),[u,m]=c.useState(""),[d,f]=c.useState(!1),[g,p]=c.useState(null);c.useEffect(()=>{i(e?.url??""),l(e?.model??"")},[e?.url,e?.model]);const h=async S=>{f(!0),p(null);try{await S(),m("")}catch(y){p(y instanceof Error?y.message:String(y))}finally{f(!1)}},w=o.trim().length>0&&r.trim().length>0,b=()=>{if(!w)return;const S={url:o.trim(),model:r.trim()},y=u.trim();y&&(S.key=y),h(()=>a(S))},k=()=>{if(!w)return null;const S=u.trim();return S?{url:o.trim(),model:r.trim(),key:S}:{url:o.trim(),model:r.trim()}},v=S=>{S.key==="Enter"&&b()};return e?.pinned?s.jsx(He,{title:t("settings.classification.custom.title"),info:t("settings.classification.custom.info"),children:s.jsx("p",{className:Cn,children:t("settings.classification.custom.pinned",{url:e.url,model:e.model})})}):s.jsx(He,{title:t("settings.classification.custom.title"),info:t("settings.classification.custom.info"),children:s.jsxs("div",{className:js,children:[s.jsx(kt,{label:t("settings.classification.custom.url.label"),info:t("settings.classification.custom.url.info"),children:s.jsx("div",{className:Nr,children:s.jsx(Ve,{type:"url",autoComplete:"off",spellCheck:!1,value:o,onChange:S=>i(S.target.value),onKeyDown:v,placeholder:"https://example.com/v1/systemone","aria-label":t("settings.classification.custom.url.label"),className:Cr,disabled:d})})}),s.jsx(kt,{label:t("settings.classification.custom.model.label"),children:s.jsx("div",{className:Nr,children:s.jsx(Ve,{autoComplete:"off",spellCheck:!1,value:r,onChange:S=>l(S.target.value),onKeyDown:v,placeholder:"jev-latest","aria-label":t("settings.classification.custom.model.label"),className:Cr,disabled:d})})}),s.jsx(kt,{label:t("settings.classification.custom.key.label"),info:t("settings.classification.custom.key.info"),children:s.jsx("div",{className:Nr,children:s.jsx(Ve,{type:"password",autoComplete:"off",value:u,onChange:S=>m(S.target.value),onKeyDown:v,placeholder:e?.keyPresent?t("settings.classification.custom.key.replacePlaceholder"):t("settings.classification.custom.key.placeholder"),"aria-label":t("settings.classification.custom.key.label"),className:Cr,disabled:d})})}),s.jsxs(kt,{label:null,children:[s.jsx(q,{size:"sm",variant:"outline",onClick:b,disabled:d||!w,children:t("settings.classification.custom.save")}),e?s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>{h(n)},disabled:d,children:t("settings.classification.custom.remove")}):null]}),g?s.jsx("p",{className:Cn,children:g}):null,s.jsx(kt,{label:null,children:s.jsx(Lu,{disabled:d||!w,draft:k})})]})})},My="https://docs.openchamber.dev/classification-providers/",Ir=t=>{const e=$e.c(6),{text:a,linkLabel:n,onOpen:o}=t;let i;e[0]!==n||e[1]!==o?(i=s.jsx("span",{onClick:Ry,onKeyDown:Fy,children:s.jsx(Mn,{onClick:o,children:n})}),e[0]=n,e[1]=o,e[2]=i):i=e[2];let r;return e[3]!==i||e[4]!==a?(r=s.jsxs(s.Fragment,{children:[a," ",i]}),e[3]=i,e[4]=a,e[5]=r):r=e[5],r},Dy=({titleLeading:t,onOpenProvider:e})=>{const{t:a}=ze(),n=Wt(F=>F.available),o=Wt(F=>F.loaded),i=Wt(F=>F.loadError),r=Wt(F=>F.classifier),l=Wt(F=>F.tokenPresent),u=Wt(F=>F.customEndpoint),m=Wt(F=>F.enterpriseMode),d=Wt(F=>F.load),f=Wt(F=>F.setClassifierSource),g=Wt(F=>F.setToken),p=Wt(F=>F.clearToken),h=Ko(r?.effective??null),[w,b]=c.useState(""),[k,v]=c.useState(!1),[S,y]=c.useState(null);c.useEffect(()=>{d()},[d]);const N=F=>r?.sources.find(T=>T.id===F)?.usable===!0,x=async F=>{es("saving");try{await f(F),es("saved")}catch{es("error")}},I=async()=>{const F=w.trim();if(F){v(!0),y(null);try{await g(F),b("")}catch(T){y(T instanceof Error?T.message:String(T))}finally{v(!1)}}},j=async()=>{v(!0),y(null);try{await p()}catch(F){y(F instanceof Error?F.message:String(F))}finally{v(!1)}},D=m?u?.pinned?a("settings.classification.status.enterprisePinned"):a("settings.classification.status.enterprise"):!r||r.selected==="off"?null:r.effective===null?a("settings.classification.status.none"):r.effective!==r.selected&&h?a("settings.classification.status.fallback",{provider:h}):null,C=N("zen-promo"),P=N("zen-key"),A=N("openrouter"),R=N("vercel"),K=N("custom");return s.jsxs(Yt,{title:a("settings.classification.page.title"),titleLeading:t,description:s.jsxs("p",{className:Cn,children:[a("settings.classification.page.description")," ",s.jsx(Mn,{onClick:()=>{ks(My)},children:a("settings.classification.page.docsLink")})]}),showSaveStatus:!0,children:[i?s.jsx("p",{className:Cn,children:a("settings.routing.loadError",{error:i})}):null,o?!n||!r?s.jsx("p",{className:Cn,children:a("settings.classification.unavailable")}):s.jsxs(s.Fragment,{children:[s.jsx(He,{title:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(an,{providerId:"typesafe",className:"size-4 shrink-0"}),a("settings.classification.jev.title")]}),info:a("settings.classification.jev.info"),divider:!1,settingsItem:"providers.classification",children:s.jsxs("div",{className:js,children:[D?s.jsx("p",{className:Dt,children:D}):null,s.jsxs(Os,{"aria-label":a("settings.classification.jev.title"),children:[s.jsx(ns,{selected:r.selected==="off",onSelect:()=>{x("off")},label:a("settings.classification.source.off.name"),description:a("settings.classification.source.off.description")}),m?null:s.jsxs(s.Fragment,{children:[C||r.selected==="zen-promo"?s.jsx(ns,{selected:r.selected==="zen-promo",onSelect:()=>{x("zen-promo")},disabled:!C,label:a("settings.classification.source.zenPromo.name"),description:a(C?"settings.classification.source.zenPromo.description":"settings.classification.source.zenPromo.ended")}):null,s.jsx(ns,{selected:r.selected==="zen-key",onSelect:()=>{x("zen-key")},disabled:!P,label:a("settings.classification.source.zenKey.name"),description:P?a("settings.classification.source.zenKey.description"):s.jsx(Ir,{text:a("settings.classification.source.zenKey.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"OpenCode Zen"}),onOpen:()=>e("opencode")})}),s.jsx(ns,{selected:r.selected==="openrouter",onSelect:()=>{x("openrouter")},disabled:!A,label:a("settings.classification.source.openrouter.name"),description:A?a("settings.classification.source.openrouter.description"):s.jsx(Ir,{text:a("settings.classification.source.openrouter.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"OpenRouter"}),onOpen:()=>e("openrouter")})}),s.jsx(ns,{selected:r.selected==="vercel",onSelect:()=>{x("vercel")},disabled:!R,label:a("settings.classification.source.vercel.name"),description:R?a("settings.classification.source.vercel.description"):s.jsx(Ir,{text:a("settings.classification.source.vercel.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"Vercel AI Gateway"}),onOpen:()=>e("vercel")})}),s.jsx(ns,{selected:r.selected==="typesafe",onSelect:()=>{x("typesafe")},disabled:!l,label:a("settings.classification.source.typesafe.name"),description:a(l?"settings.classification.source.typesafe.description":"settings.classification.source.typesafe.missing")})]}),!m||u?.pinned?s.jsx(ns,{selected:r.selected==="custom",onSelect:()=>{x("custom")},disabled:!K,label:a("settings.classification.source.custom.name"),description:u&&K?a("settings.classification.source.custom.description",{url:u.url}):a("settings.classification.source.custom.missing")}):null]}),m?null:s.jsx(kt,{label:a("settings.routing.token.label"),info:a("settings.routing.token.info"),children:s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(Ve,{type:"password",autoComplete:"off",value:w,onChange:F=>b(F.target.value),onKeyDown:F=>{F.key==="Enter"&&I()},placeholder:a(l?"settings.routing.token.replacePlaceholder":"settings.routing.token.placeholder"),"aria-label":a("settings.routing.token.label"),className:"h-8 rounded-md px-3 min-w-0 flex-1",disabled:k}),s.jsx(q,{size:"sm",variant:"outline",onClick:()=>{I()},disabled:k||w.trim().length===0,children:a("settings.routing.token.save")}),l?s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>{j()},disabled:k,children:a("settings.routing.token.remove")}):null]})}),S?s.jsx("p",{className:Cn,children:S}):null,s.jsx(kt,{label:null,children:s.jsx(Lu,{disabled:r.effective===null})})]})}),!m||u?.pinned?s.jsx(Ey,{}):null]}):null]})};function Ry(t){return t.stopPropagation()}function Fy(t){return t.stopPropagation()}const qc=t=>{const e=$e.c(2),{icon:a}=t;let n;return e[0]!==a?(n=s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:s.jsx(J,{name:a,className:"size-4"})}),e[0]=a,e[1]=n):n=e[1],n},Wc=t=>{const e=$e.c(3),{connection:a,fallback:n}=t;let o;return e[0]!==a||e[1]!==n?(o=Dl(a)&&a.status?s.jsx("div",{className:"typography-micro text-[var(--status-warning)] break-words",children:a.status.message}):s.jsx("div",{className:"typography-micro text-muted-foreground",children:n}),e[0]=a,e[1]=n,e[2]=o):o=e[2],o},Gc=t=>{const e=$e.c(11),{connection:a,account:n}=t,{t:o}=ze(),i=Dl(a)?a.status?.url:void 0;if(!i)return null;let r;e[0]!==i?(r=()=>{ks(i)},e[0]=i,e[1]=r):r=e[1];let l;e[2]!==n||e[3]!==o?(l=o("settings.providers.accounts.signInAria",{account:n}),e[2]=n,e[3]=o,e[4]=l):l=e[4];let u;e[5]!==o?(u=o("settings.providers.accounts.signIn"),e[5]=o,e[6]=u):u=e[6];let m;return e[7]!==r||e[8]!==l||e[9]!==u?(m=s.jsx(q,{variant:"outline",size:"xs",onClick:r,"aria-label":l,children:u}),e[7]=r,e[8]=l,e[9]=u,e[10]=m):m=e[10],m},Oy=t=>{const e=$e.c(32),{initial:a,onSave:n,onCancel:o}=t,{t:i}=ze(),[r,l]=c.useState(a);let u;e[0]!==r?(u=r.trim(),e[0]=r,e[1]=u):u=e[1];const m=u;let d;e[2]!==a||e[3]!==o||e[4]!==n||e[5]!==m?(d=()=>{if(m.length===0||m===a){o();return}n(m)},e[2]=a,e[3]=o,e[4]=n,e[5]=m,e[6]=d):d=e[6];const f=d;let g;e[7]!==f?(g=x=>{x.preventDefault(),f()},e[7]=f,e[8]=g):g=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=x=>l(x.target.value),e[9]=p):p=e[9];let h;e[10]!==o?(h=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),o())},e[10]=o,e[11]=h):h=e[11];let w;e[12]!==i?(w=i("settings.providers.accounts.nameAria"),e[12]=i,e[13]=w):w=e[13];let b;e[14]!==h||e[15]!==w||e[16]!==r?(b=s.jsx(Ve,{autoFocus:!0,value:r,onChange:p,onKeyDown:h,"aria-label":w,className:"h-8 max-w-[18rem]"}),e[14]=h,e[15]=w,e[16]=r,e[17]=b):b=e[17];let k;e[18]!==i?(k=i("settings.providers.accounts.save"),e[18]=i,e[19]=k):k=e[19];let v;e[20]!==k?(v=s.jsx(q,{type:"submit",size:"xs",children:k}),e[20]=k,e[21]=v):v=e[21];let S;e[22]!==i?(S=i("settings.providers.page.actions.cancel"),e[22]=i,e[23]=S):S=e[23];let y;e[24]!==o||e[25]!==S?(y=s.jsx(q,{type:"button",variant:"ghost",size:"xs",onClick:o,children:S}),e[24]=o,e[25]=S,e[26]=y):y=e[26];let N;return e[27]!==y||e[28]!==g||e[29]!==b||e[30]!==v?(N=s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-2",onSubmit:g,children:[b,v,y]}),e[27]=y,e[28]=g,e[29]=b,e[30]=v,e[31]=N):N=e[31],N},Ly=t=>{const e=$e.c(32),{connections:a,activeId:n,unusedIds:o,busyId:i,onActivate:r,onRename:l,onRemove:u}=t,{t:m}=ze(),[d,f]=c.useState(null);let g;if(e[0]!==a||e[1]!==o){let S;e[3]!==o?(S=y=>y.type==="credential"&&!o.has(y.id),e[3]=o,e[4]=S):S=e[4],g=a.filter(S),e[0]=a,e[1]=o,e[2]=g}else g=e[2];const h=g.length>1;let w;e[5]!==a?(w=a.filter(Ky),e[5]=a,e[6]=w):w=e[6];const b=w.length>1;let k;if(e[7]!==n||e[8]!==i||e[9]!==h||e[10]!==a||e[11]!==r||e[12]!==u||e[13]!==l||e[14]!==d||e[15]!==b||e[16]!==m||e[17]!==o){let S;e[19]!==n||e[20]!==i||e[21]!==h||e[22]!==r||e[23]!==u||e[24]!==l||e[25]!==d||e[26]!==b||e[27]!==m||e[28]!==o?(S=y=>{if(y.type==="env")return s.jsxs("div",{className:"flex min-w-0 items-center gap-3 py-2.5",children:[s.jsx(qc,{icon:"terminal-box"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate font-mono typography-ui-label text-foreground",children:y.name}),s.jsx(Wc,{connection:y,fallback:m("settings.providers.accounts.environment")})]}),s.jsx(Gc,{connection:y,account:y.name})]},`env:${y.name}`);const N=y.id===n,x=o.has(y.id),I=i!==null,j=y.method==="oauth"?m(x?"settings.providers.accounts.method.oauthUnused":"settings.providers.accounts.method.oauth"):y.method==="external"?m(x?"settings.providers.accounts.method.externalUnused":"settings.providers.accounts.method.external"):m(x?"settings.providers.accounts.method.keyUnused":"settings.providers.accounts.method.key"),D=y.method==="oauth"?"user-3":y.method==="external"?"terminal-box":"key";return s.jsxs("div",{className:Me("flex min-w-0 items-center gap-3 py-2.5",x&&"opacity-60"),children:[s.jsx(qc,{icon:D}),d===y.id?s.jsx(Oy,{initial:y.label,onCancel:()=>f(null),onSave:C=>{f(null),l(y,C)}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:y.label}),b&&N?s.jsx("span",{className:"shrink-0 rounded-full bg-[var(--interactive-selection)] px-2 py-px text-[10px] font-medium text-[var(--interactive-selection-foreground)]",children:m("settings.providers.accounts.active")}):null]}),s.jsx(Wc,{connection:y,fallback:j})]}),s.jsx(Gc,{connection:y,account:y.label}),h&&!N&&!x?s.jsxs(q,{variant:"outline",size:"xs",disabled:I,onClick:()=>r(y),"aria-label":m("settings.providers.accounts.useAria",{account:y.label}),children:[i===y.id?s.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}):null,m("settings.providers.accounts.use")]}):null,s.jsxs(ga,{children:[s.jsx(pa,{asChild:!0,children:s.jsx(q,{variant:"ghost",size:"icon",disabled:I,className:Me(os,"shrink-0"),"aria-label":m("settings.providers.accounts.menuAria",{account:y.label}),children:s.jsx(J,{name:"more-2",className:"size-4"})})}),s.jsxs(ma,{align:"end",children:[s.jsxs(Bn,{onSelect:()=>f(y.id),children:[s.jsx(J,{name:"pencil",className:"size-4"}),m("settings.providers.accounts.rename")]}),s.jsxs(Bn,{variant:"destructive",onSelect:()=>u(y),children:[s.jsx(J,{name:"delete-bin",className:"size-4"}),m("settings.providers.accounts.remove")]})]})]})]})]},y.id)},e[19]=n,e[20]=i,e[21]=h,e[22]=r,e[23]=u,e[24]=l,e[25]=d,e[26]=b,e[27]=m,e[28]=o,e[29]=S):S=e[29],k=a.map(S),e[7]=n,e[8]=i,e[9]=h,e[10]=a,e[11]=r,e[12]=u,e[13]=l,e[14]=d,e[15]=b,e[16]=m,e[17]=o,e[18]=k}else k=e[18];let v;return e[30]!==k?(v=s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:k}),e[30]=k,e[31]=v):v=e[31],v};function Ky(t){return t.type==="credential"}const Rl={"openai-chat":"aisdk:@ai-sdk/openai-compatible","openai-responses":"aisdk:@ai-sdk/openai","anthropic-messages":"aisdk:@ai-sdk/anthropic"},Pr="__custom_provider__",zy=/^[a-z0-9][a-z0-9-_]*$/,Ku=/^https?:\/\//,Uy=/^\{env:([^}]+)\}$/,To=t=>{if(!t)return;if(typeof t.package=="string"&&t.package)return t.package;const e=t.api?.npm;return typeof e=="string"&&e?`aisdk:${e}`:void 0},zu=t=>t.settings&&typeof t.settings=="object"?t.settings:t.options&&typeof t.options=="object"?t.options:{};let $y=0;const Eo=()=>`row-${$y++}`,Uo=()=>({row:Eo(),id:"",name:"",contextWindow:"",maxOutputTokens:"",inputCapabilities:["text"],outputCapabilities:["text"],tools:!0,capabilitiesKnown:!1,variants:""}),Jc=ss({context:wo().optional(),output:wo().optional()}),Qc=ss({tools:Fi(),input:Zs(St()),output:Zs(St())}),By=ss({id:St(),name:St(),limit:Jc.optional(),capabilities:Qc.optional(),metadata:ss({providerID:St(),modelID:St(),name:St().optional(),limit:Jc.optional(),capabilities:Qc.optional()}).optional()}),_y=ss({models:Zs(By)}),Vy=ss({error:St()}),Hy=t=>{const e=t.metadata,a=t.limit?.context??e?.limit?.context,n=t.limit?.output??e?.limit?.output,o=t.capabilities??e?.capabilities,i=!!(t.limit||t.capabilities);return{...Uo(),id:t.id,name:t.name!==t.id?t.name:e?.name??t.id,contextWindow:a?String(a):"",maxOutputTokens:n?String(n):"",inputCapabilities:o?.input??["text"],outputCapabilities:o?.output??["text"],tools:o?.tools??!0,capabilitiesKnown:!!o,...i?{metadataSource:"provider-api"}:e?{metadataSource:"models.dev"}:{}}};function qy(t,e){switch(t){case"openai-chat":return{settings:{reasoningEffort:e}};case"openai-responses":return{settings:{reasoningEffort:e,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}};case"anthropic-messages":return{settings:{thinking:{type:"adaptive",display:"summarized"},effort:e}}}}function Wy(t){const e=t.split(/[,\s]+/).map(a=>a.trim()).filter(Boolean);return e.filter((a,n)=>e.indexOf(a)===n)}function Gy(t){return Object.fromEntries((t??[]).map(({id:e,...a})=>[e,a]))}const Fl=()=>({row:Eo(),key:"",value:""}),Jy=()=>({providerID:"",name:"",icon:null,protocol:"openai-chat",baseURL:"",apiKey:"",models:[Uo()],headers:[Fl()]}),Uu={"@opencode/ai/providers/openai-compatible":"openai-chat","@opencode/ai/providers/openai":"openai-responses","@opencode/ai/providers/anthropic":"anthropic-messages"};function Qy(t){const e=t?Uu[t]:void 0;if(e)return e;switch(t){case"aisdk:@ai-sdk/openai":case"@ai-sdk/openai":return"openai-responses";case"aisdk:@ai-sdk/anthropic":case"@ai-sdk/anthropic":return"anthropic-messages";default:return"openai-chat"}}function Yy(t){const e=t.trim();if(!e)return{};const n=e.match(Uy)?.[1]?.trim();return n?{env:n}:{key:e}}function Zy(t){const e=zu(t),a=typeof e.baseURL=="string"?e.baseURL.trim():"";if(a&&Ku.test(a))return!0;const n=new Set([...Object.values(Rl),...Object.keys(Uu)]);return n.has(To(t)??"")?!0:(Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.values(t.models):[]).some(i=>!i||typeof i!="object"?!1:n.has(To(i)??""))}function Yc(t,e){return e?!!(e.user?.exists||e.project?.exists||e.custom?.exists)&&Zy(t):!1}function Zc(t){return t?.custom?.exists?"custom":t?.project?.exists?"project":"user"}function Xc(t){const e=zu(t),a=typeof e.baseURL=="string"?e.baseURL:"",n=t.headers&&typeof t.headers=="object"?t.headers:e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers)?e.headers:{},o=Object.entries(n).filter(m=>typeof m[0]=="string"&&typeof m[1]=="string").map(([m,d])=>({row:Eo(),key:m,value:d})),i=Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.entries(t.models).map(([m,d])=>{const f=d&&typeof d=="object"?d:{};return{id:m,modelID:typeof f.modelID=="string"?f.modelID:m,name:typeof f.name=="string"?f.name:m,package:typeof f.package=="string"?f.package:void 0,variants:$u.safeParse(f.variants).data,limit:Bu.safeParse(f.limit).data,capabilities:_u.safeParse(f.capabilities).data}}):[],r=i.length>0?i.map(m=>{const d=typeof m?.modelID=="string"&&m.modelID?m.modelID:typeof m?.id=="string"?m.id:"",f=Gy(m?.variants);return{row:Eo(),id:d,name:typeof m?.name=="string"?m.name:d,contextWindow:m.limit?.context?String(m.limit.context):"",maxOutputTokens:m.limit?.output?String(m.limit.output):"",inputCapabilities:m.capabilities?.input??["text"],outputCapabilities:m.capabilities?.output??["text"],tools:m.capabilities?.tools??!0,capabilitiesKnown:!!m.capabilities,variants:Object.keys(f).join(", "),savedVariants:f}}):[Uo()],l=Array.isArray(t.env)?t.env.find(m=>typeof m=="string"&&m.trim().length>0)?.trim():void 0,u=i.map(m=>To(m)).find(m=>!!m);return{providerID:t.id,name:typeof t.name=="string"&&t.name.trim()?t.name:t.id,icon:null,protocol:Qy(To(t)??u),baseURL:a,apiKey:l?`{env:${l}}`:"",models:r,headers:o.length>0?o:[Fl()]}}const $u=Zs(ss({id:St(),settings:En(St(),Jr()).optional(),headers:En(St(),St()).optional(),body:En(St(),Jr()).optional()})),Bu=ss({context:wo().optional(),output:wo().optional()}),_u=ss({tools:Fi().optional(),input:Zs(St()).optional(),output:Zs(St()).optional()}),Xy=ss({name:St().optional(),package:St().optional(),env:Zs(St()).optional(),settings:En(St(),Jr()).optional(),headers:En(St(),St()).optional(),models:En(St(),ss({modelID:St().optional(),name:St().optional(),package:St().optional(),variants:$u.optional(),limit:Bu.optional(),capabilities:_u.optional()})).optional()});function e1(t,e,a=null){const n=Array.isArray(t.models)?t.models.map(r=>({...r,variants:void 0})):t.models,o=Xc({...t,models:n});if(!e)return{...o,icon:a,models:o.models.map(r=>({...r,savedVariants:void 0}))};const i=Xc({...e,id:t.id});return{providerID:t.id,name:e.name?.trim()?i.name:o.name,icon:a,protocol:e.package?i.protocol:o.protocol,baseURL:i.baseURL||o.baseURL,apiKey:i.apiKey,models:e.models&&Object.keys(e.models).length>0?i.models:o.models.map(r=>({...r,savedVariants:void 0})),headers:i.headers}}function t1(t){const e=t.form.providerID.trim(),a=t.form.name.trim(),n=t.form.baseURL.trim(),{env:o,key:i}=Yy(t.form.apiKey),r=t.disabledProviders??[],l=t.editingProviderID?.trim(),u=e?zy.test(e)?void 0:t.t("settings.providers.page.custom.error.providerID.format"):t.t("settings.providers.page.custom.error.providerID.required"),m=a?void 0:t.t("settings.providers.page.custom.error.name.required"),d=n?Ku.test(n)?void 0:t.t("settings.providers.page.custom.error.baseURL.format"):t.t("settings.providers.page.custom.error.baseURL.required"),g=!!(o||i||l&&t.allowExistingAuth&&l===e)?void 0:t.t("settings.providers.page.custom.error.apiKey.required"),p=r.includes(e),w=u||!!(l&&l===e)?void 0:t.existingProviderIDs.has(e)&&!p?t.t("settings.providers.page.custom.error.providerID.exists"):void 0,b=new Set,k=t.form.models.map(C=>{const P=C.id.trim(),A=P?b.has(P)?t.t("settings.providers.page.custom.error.duplicate"):void b.add(P):t.t("settings.providers.page.custom.error.required"),R=C.name.trim()?void 0:t.t("settings.providers.page.custom.error.required"),K=C.contextWindow.trim()&&!so(C.contextWindow)?t.t("settings.providers.page.custom.error.positiveInteger"):void 0,F=C.maxOutputTokens.trim()&&!so(C.maxOutputTokens)?t.t("settings.providers.page.custom.error.positiveInteger"):void 0;return{id:A,name:R,contextWindow:K,maxOutputTokens:F}}),v=k.every(C=>!C.id&&!C.name&&!C.contextWindow&&!C.maxOutputTokens),S=Object.fromEntries(t.form.models.map(C=>{const P=C.id.trim(),A={modelID:P,name:C.name.trim()},R=so(C.contextWindow),K=so(C.maxOutputTokens);(R||K)&&(A.limit={...R?{context:R}:{},...K?{output:K}:{}}),C.capabilitiesKnown&&(A.capabilities={tools:C.tools,input:C.inputCapabilities,output:C.outputCapabilities});const F=Wy(C.variants);return(F.length>0||C.savedVariants!==void 0)&&(A.variants=F.map(T=>({id:T,...C.savedVariants?.[T]??qy(t.form.protocol,T)}))),[P,A]})),y=new Set,N=t.form.headers.map(C=>{const P=C.key.trim(),A=C.value.trim();if(!P&&!A)return{};const R=P?y.has(P.toLowerCase())?t.t("settings.providers.page.custom.error.duplicate"):void y.add(P.toLowerCase()):t.t("settings.providers.page.custom.error.required"),K=A?void 0:t.t("settings.providers.page.custom.error.required");return{key:R,value:K}}),x=N.every(C=>!C.key&&!C.value),I=Object.fromEntries(t.form.headers.map(C=>({key:C.key.trim(),value:C.value.trim()})).filter(C=>C.key&&C.value).map(C=>[C.key,C.value])),j={providerID:u??w,name:m,baseURL:d,apiKey:g};return!u&&!w&&!m&&!d&&!g&&v&&x?{err:j,models:k,headers:N,result:{providerID:e,name:a,icon:t.form.icon,apiKey:i,...!o&&!i?{keepsStoredCredential:!0}:{},config:s1({protocol:t.form.protocol,name:a,env:o,baseURL:n,headers:I,models:S})}}:{err:j,models:k,headers:N}}function so(t){const e=t.trim();if(!/^\d+$/.test(e))return;const a=Number(e);return Number.isSafeInteger(a)&&a>0?a:void 0}function s1(t){const e={package:Rl[t.protocol],name:t.name,settings:{baseURL:t.baseURL},models:t.models};return t.env&&(e.env=[t.env]),Object.keys(t.headers).length>0&&(e.headers=t.headers),e}function n1(t){return t.apiKey?{integrationID:t.providerID,key:t.apiKey}:null}function a1(t,e){return{providerID:t.providerID,config:t.config,scope:e?.scope??"user",hasCredential:!!(t.apiKey||t.keepsStoredCredential)}}const i1=[250,500,1e3,2e3];async function o1(t,e=a=>new Promise(n=>setTimeout(n,a))){for(let a=0;;a+=1)try{await t();return}catch(n){const o=i1[a];if(!(n instanceof Error&&/not found/i.test(n.message))||o===void 0)throw n;await e(o)}}const r1=8,l1=t=>{const e=$e.c(78),{models:a,existingIds:n,onAdd:o,onCancel:i}=t,{t:r}=ze(),[l,u]=c.useState("");let m;e[0]!==n||e[1]!==a?(m=()=>new Set(a.filter(z=>!n.has(z.id)).map(c1)),e[0]=n,e[1]=a,e[2]=m):m=e[2];const[d,f]=c.useState(m);let g,p,h,w,b,k,v,S,y,N;if(e[3]!==n||e[4]!==a||e[5]!==l||e[6]!==d||e[7]!==r){const z=l.trim().toLocaleLowerCase();N=z?a.filter(G=>[G.id,G.name,G.metadata?.name].some(ee=>ee?.toLocaleLowerCase().includes(z))):a;let $;e[18]!==n?($=G=>!n.has(G.id),e[18]=n,e[19]=$):$=e[19],p=N.filter($),g=p.length>0&&p.every(G=>d.has(G.id)),y=()=>f(G=>{const ee=new Set(G);for(const ae of p)g?ee.delete(ae.id):ee.add(ae.id);return ee}),S="space-y-2",v="flex items-end justify-between gap-2",b="min-w-0";let V;e[20]!==r?(V=r("settings.providers.page.custom.discovery.review"),e[20]=r,e[21]=V):V=e[21],e[22]!==V?(k=s.jsx("p",{className:Ct,children:V}),e[22]=V,e[23]=k):k=e[23],h=Dt,w=r("settings.providers.page.custom.discovery.counts",{matching:N.length,total:a.length,selected:d.size}),e[3]=n,e[4]=a,e[5]=l,e[6]=d,e[7]=r,e[8]=g,e[9]=p,e[10]=h,e[11]=w,e[12]=b,e[13]=k,e[14]=v,e[15]=S,e[16]=y,e[17]=N}else g=e[8],p=e[9],h=e[10],w=e[11],b=e[12],k=e[13],v=e[14],S=e[15],y=e[16],N=e[17];let x;e[24]!==h||e[25]!==w?(x=s.jsx("p",{className:h,children:w}),e[24]=h,e[25]=w,e[26]=x):x=e[26];let I;e[27]!==b||e[28]!==k||e[29]!==x?(I=s.jsxs("div",{className:b,children:[k,x]}),e[27]=b,e[28]=k,e[29]=x,e[30]=I):I=e[30];const j=p.length===0;let D;e[31]!==g||e[32]!==r?(D=r(g?"settings.providers.page.custom.discovery.deselectAll":"settings.providers.page.custom.discovery.selectAll"),e[31]=g,e[32]=r,e[33]=D):D=e[33];let C;e[34]!==j||e[35]!==D||e[36]!==y?(C=s.jsx(q,{type:"button",variant:"ghost",size:"xs",disabled:j,onClick:y,children:D}),e[34]=j,e[35]=D,e[36]=y,e[37]=C):C=e[37];let P;e[38]!==C||e[39]!==v||e[40]!==I?(P=s.jsxs("div",{className:v,children:[I,C]}),e[38]=C,e[39]=v,e[40]=I,e[41]=P):P=e[41];let A;e[42]!==a.length||e[43]!==l||e[44]!==r?(A=a.length>r1?s.jsxs("div",{className:"relative",children:[s.jsx(J,{name:"search",className:"pointer-events-none absolute inset-s-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),s.jsx(Ve,{value:l,onChange:z=>u(z.target.value),onKeyDown:z=>{z.key==="Escape"&&l&&(z.preventDefault(),z.stopPropagation(),u(""))},placeholder:r("settings.agents.modelSelector.searchPlaceholder"),"aria-label":r("settings.agents.modelSelector.searchPlaceholder"),className:"h-8 rounded-md ps-8"})]}):null,e[42]=a.length,e[43]=l,e[44]=r,e[45]=A):A=e[45];let R;e[46]!==n||e[47]!==d||e[48]!==r||e[49]!==N?(R=N.length>0?N.map(z=>{const $=n.has(z.id),V=z.limit?.context??z.metadata?.limit?.context,G=z.limit?.output??z.metadata?.limit?.output,ee=[V?r("settings.providers.page.custom.discovery.contextValue",{value:bo(V)}):null,G?r("settings.providers.page.custom.discovery.outputValue",{value:bo(G)}):null].filter(Boolean).join(" · ");return s.jsx(it,{checked:$||d.has(z.id),disabled:$,onChange:ae=>f(X=>{const Q=new Set(X);return ae?Q.add(z.id):Q.delete(z.id),Q}),label:s.jsx("span",{className:"block truncate font-mono text-xs",children:z.id}),description:$?r("settings.providers.page.custom.discovery.alreadyAdded"):ee||void 0,ariaLabel:z.id,className:"py-1.5"},z.id)}):s.jsx("p",{className:"px-2 py-6 text-center typography-meta text-muted-foreground",children:r("settings.agents.modelSelector.state.noModelsFound")}),e[46]=n,e[47]=d,e[48]=r,e[49]=N,e[50]=R):R=e[50];let K;e[51]!==R?(K=s.jsx(Ts,{outerClassName:"max-h-[min(18rem,45dvh)] rounded-md border border-border/60",className:"px-2 py-1",disableHorizontal:!0,preventOverscroll:!0,useScrollShadow:!0,children:R}),e[51]=R,e[52]=K):K=e[52];const F=d.size===0;let T;e[53]!==a||e[54]!==o||e[55]!==d?(T=()=>o(a.filter(z=>d.has(z.id))),e[53]=a,e[54]=o,e[55]=d,e[56]=T):T=e[56];let O;e[57]!==d.size||e[58]!==r?(O=r("settings.providers.page.custom.discovery.importSelected",{count:d.size}),e[57]=d.size,e[58]=r,e[59]=O):O=e[59];let E;e[60]!==F||e[61]!==T||e[62]!==O?(E=s.jsx(q,{type:"button",size:"xs",className:"!font-normal",disabled:F,onClick:T,children:O}),e[60]=F,e[61]=T,e[62]=O,e[63]=E):E=e[63];let B;e[64]!==r?(B=r("settings.providers.page.custom.discovery.cancel"),e[64]=r,e[65]=B):B=e[65];let _;e[66]!==i||e[67]!==B?(_=s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:i,children:B}),e[66]=i,e[67]=B,e[68]=_):_=e[68];let H;e[69]!==E||e[70]!==_?(H=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[E,_]}),e[69]=E,e[70]=_,e[71]=H):H=e[71];let ne;return e[72]!==P||e[73]!==A||e[74]!==K||e[75]!==H||e[76]!==S?(ne=s.jsxs("div",{className:S,children:[P,A,K,H]}),e[72]=P,e[73]=A,e[74]=K,e[75]=H,e[76]=S,e[77]=ne):ne=e[77],ne};function c1(t){return t.id}const d1=["text","image","audio","video","pdf"],ed=t=>{const e=Number(t.trim());return Number.isSafeInteger(e)&&e>0?e:null},u1=t=>{const e=$e.c(70),{model:a,errors:n,expanded:o,onToggle:i,onChange:r,onToggleCapability:l,onToolsChange:u,onRemove:m}=t,{t:d}=ze(),f=c.useId();let g;e[0]!==a.id?(g=a.id.trim(),e[0]=a.id,e[1]=g):g=e[1];const p=g;let h;e[2]!==a.name?(h=a.name.trim(),e[2]=a.name,e[3]=h):h=e[3];const w=h;let b;e[4]!==p||e[5]!==w||e[6]!==d?(b=w||p||d("settings.providers.page.custom.models.untitled"),e[4]=p,e[5]=w,e[6]=d,e[7]=b):b=e[7];const k=b;let v,S,y;if(e[8]!==a.contextWindow||e[9]!==a.inputCapabilities||e[10]!==a.maxOutputTokens||e[11]!==d){const $=ed(a.contextWindow),V=ed(a.maxOutputTokens),G=a.inputCapabilities.filter(m1);v=$?d("settings.providers.page.custom.discovery.contextValue",{value:bo($)}):null,S=V?d("settings.providers.page.custom.discovery.outputValue",{value:bo(V)}):null,y=G.length>0?G.join(", "):null,e[8]=a.contextWindow,e[9]=a.inputCapabilities,e[10]=a.maxOutputTokens,e[11]=d,e[12]=v,e[13]=S,e[14]=y}else v=e[12],S=e[13],y=e[14];let N;e[15]!==a.tools||e[16]!==d?(N=a.tools?null:d("settings.providers.page.custom.models.toolsOff"),e[15]=a.tools,e[16]=d,e[17]=N):N=e[17];let x;e[18]!==v||e[19]!==S||e[20]!==y||e[21]!==N?(x=[v,S,y,N].filter(Boolean),e[18]=v,e[19]=S,e[20]=y,e[21]=N,e[22]=x):x=e[22];const I=x.join(" · "),j=p1,D=o&&"rotate-90 rtl:-rotate-90";let C;e[23]!==D?(C=Me("size-4 shrink-0 text-muted-foreground transition-transform",D),e[23]=D,e[24]=C):C=e[24];let P;e[25]!==C?(P=s.jsx(J,{name:"arrow-right-s",className:C,"aria-hidden":!0}),e[25]=C,e[26]=P):P=e[26];const A=!w&&!p&&"text-muted-foreground";let R;e[27]!==A?(R=Me("truncate",Ct,A),e[27]=A,e[28]=R):R=e[28];let K;e[29]!==R||e[30]!==k?(K=s.jsx("span",{className:R,children:k}),e[29]=R,e[30]=k,e[31]=K):K=e[31];let F;e[32]!==p||e[33]!==w?(F=w&&p&&w!==p?s.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:p}):null,e[32]=p,e[33]=w,e[34]=F):F=e[34];let T;e[35]!==K||e[36]!==F?(T=s.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[K,F]}),e[35]=K,e[36]=F,e[37]=T):T=e[37];let O;e[38]!==I?(O=I?s.jsx("span",{className:Me("truncate",Dt),children:I}):null,e[38]=I,e[39]=O):O=e[39];let E;e[40]!==T||e[41]!==O?(E=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[T,O]}),e[40]=T,e[41]=O,e[42]=E):E=e[42];let B;e[43]!==f||e[44]!==o||e[45]!==i||e[46]!==P||e[47]!==E?(B=s.jsxs("button",{type:"button",onClick:i,"aria-expanded":o,"aria-controls":f,className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-1.5 text-start hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--interactive-focus-ring)]",children:[P,E]}),e[43]=f,e[44]=o,e[45]=i,e[46]=P,e[47]=E,e[48]=B):B=e[48];let _;e[49]!==m||e[50]!==d?(_=m?s.jsx(q,{type:"button",variant:"ghost",size:"icon",className:os,onClick:m,"aria-label":d("settings.providers.page.custom.models.remove"),children:s.jsx(J,{name:"delete-bin",className:"size-4"})}):null,e[49]=m,e[50]=d,e[51]=_):_=e[51];let H;e[52]!==B||e[53]!==_?(H=s.jsxs("div",{className:"flex items-center gap-1 py-1",children:[B,_]}),e[52]=B,e[53]=_,e[54]=H):H=e[54];let ne;e[55]!==f||e[56]!==n?.contextWindow||e[57]!==n?.id||e[58]!==n?.maxOutputTokens||e[59]!==n?.name||e[60]!==o||e[61]!==a||e[62]!==r||e[63]!==l||e[64]!==u||e[65]!==d?(ne=o?s.jsxs("div",{id:f,className:"space-y-3 pb-4 ps-7 pe-1 pt-1",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-2 @xl:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:d("settings.providers.page.custom.models.idLabel")}),s.jsx(Ve,{value:a.id,onChange:$=>r("id",$.target.value),placeholder:d("settings.providers.page.custom.models.idPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!n?.id,"aria-label":d("settings.providers.page.custom.models.idLabel")}),j(n?.id)]}),s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:d("settings.providers.page.custom.models.nameLabel")}),s.jsx(Ve,{value:a.name,onChange:$=>r("name",$.target.value),placeholder:d("settings.providers.page.custom.models.namePlaceholder"),className:"mt-1 h-8 rounded-md px-3","aria-invalid":!!n?.name,"aria-label":d("settings.providers.page.custom.models.nameLabel")}),j(n?.name)]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-2 @xl:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:d("settings.providers.page.custom.models.contextWindow")}),s.jsx(Ve,{inputMode:"numeric",value:a.contextWindow,onChange:$=>r("contextWindow",$.target.value),placeholder:"128000",className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!n?.contextWindow,"aria-label":d("settings.providers.page.custom.models.contextWindow")}),j(n?.contextWindow)]}),s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:d("settings.providers.page.custom.models.maxOutputTokens")}),s.jsx(Ve,{inputMode:"numeric",value:a.maxOutputTokens,onChange:$=>r("maxOutputTokens",$.target.value),placeholder:"16384",className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!n?.maxOutputTokens,"aria-label":d("settings.providers.page.custom.models.maxOutputTokens")}),j(n?.maxOutputTokens)]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:Ct,children:d("settings.providers.page.custom.models.variantsLabel")}),s.jsx(qt,{children:d("settings.providers.page.custom.models.variantsInfo")})]}),s.jsx(Ve,{value:a.variants,onChange:$=>r("variants",$.target.value),placeholder:d("settings.providers.page.custom.models.variantsPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":d("settings.providers.page.custom.models.variantsLabel")})]}),["inputCapabilities","outputCapabilities"].map($=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("span",{className:Ct,children:d($==="inputCapabilities"?"settings.providers.page.custom.models.inputCapabilities":"settings.providers.page.custom.models.outputCapabilities")}),s.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:d1.map(V=>s.jsx(it,{checked:a[$].includes(V),onChange:()=>l($,V),label:V,ariaLabel:V},V))})]},$)),s.jsx(it,{checked:a.tools,onChange:u,label:d("settings.providers.page.custom.models.tools"),ariaLabel:d("settings.providers.page.custom.models.tools")}),a.metadataSource==="models.dev"||a.metadataSource==="provider-api"?s.jsx("p",{className:Dt,children:a.metadataSource==="models.dev"?d("settings.providers.page.custom.discovery.source.models.dev"):d("settings.providers.page.custom.discovery.source.provider-api")}):null]}):null,e[55]=f,e[56]=n?.contextWindow,e[57]=n?.id,e[58]=n?.maxOutputTokens,e[59]=n?.name,e[60]=o,e[61]=a,e[62]=r,e[63]=l,e[64]=u,e[65]=d,e[66]=ne):ne=e[66];let z;return e[67]!==H||e[68]!==ne?(z=s.jsxs("div",{className:"border-b border-border/50 last:border-b-0",children:[H,ne]}),e[67]=H,e[68]=ne,e[69]=z):z=e[69],z};function m1(t){return t!=="text"}function p1(t){return t?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:t}):null}const td=({existingProviderIDs:t,disabledProviders:e=[],busy:a=!1,mode:n="create",initialValues:o,allowExistingAuth:i=!1,authFailureHint:r=null,onSubmit:l,onCancel:u,onDisconnect:m})=>{const{t:d}=ze(),f=n==="edit",[g,p]=c.useState(()=>o??Jy()),[h,w]=c.useState({}),[b,k]=c.useState([]),[v,S]=c.useState([]),[y,N]=c.useState(!1),[x,I]=c.useState(null),[j,D]=c.useState(null),[C,P]=c.useState(()=>new Set(o?[]:g.models.map(z=>z.row))),A=c.useRef(null),R=g.providerID.trim()||"custom",{hasLogo:K}=np(R);c.useEffect(()=>{o&&(f&&A.current===o.providerID||(A.current=f?o.providerID:null,p(o),w({}),k([]),S([]),P(new Set),D(null)))},[o,f]);const F=(z,$)=>{p(V=>({...V,[z]:$})),w(V=>({...V,[z]:void 0}))},T=(z,$,V)=>{p(G=>({...G,models:G.models.map((ee,ae)=>ae===z?{...ee,[$]:V,metadataSource:"manual"}:ee)})),k(G=>{const ee=[...G];return ee[z]={...ee[z]??{},[$]:void 0},ee})},O=(z,$,V)=>{p(G=>({...G,headers:G.headers.map((ee,ae)=>ae===z?{...ee,[$]:V}:ee)})),S(G=>{const ee=[...G];return ee[z]={...ee[z]??{},[$]:void 0},ee})},E=async()=>{N(!0),I(null);try{const z=Object.fromEntries(g.headers.map(ee=>[ee.key.trim(),ee.value.trim()]).filter(([ee,ae])=>ee&&ae)),$=await Rt("/api/provider/discover-models",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({providerID:f?g.providerID:void 0,baseURL:g.baseURL,apiKey:g.apiKey,headers:z,enrich:!0,metadataProviderID:g.providerID})}),V=await $.json().catch(()=>null),G=_y.safeParse(V);if(!$.ok||!G.success)throw new Error(Vy.safeParse(V).data?.error||d("settings.providers.page.custom.discovery.failed"));D(G.data.models)}catch(z){I(z instanceof Error?z.message:d("settings.providers.page.custom.discovery.failed"))}finally{N(!1)}},B=z=>{p($=>{const V=new Set($.models.map(ae=>ae.id.trim()).filter(Boolean)),G=z.filter(ae=>!V.has(ae.id)).map(Hy),ee=$.models.filter(ae=>ae.id.trim()||ae.name.trim());return{...$,models:[...ee,...G]}}),k([]),D(null)},_=z=>P($=>{const V=new Set($);return V.has(z)?V.delete(z):V.add(z),V}),H=(z,$,V)=>{p(G=>({...G,models:G.models.map((ee,ae)=>{if(ae!==z)return ee;const X=ee[$],Q=X.includes(V)?X.filter(le=>le!==V):[...X,V];return{...ee,[$]:Q,capabilitiesKnown:!0,metadataSource:"manual"}})}))},ne=async z=>{if(z.preventDefault(),a)return;const $=t1({form:g,t:((G,ee)=>d(G,ee)),existingProviderIDs:t,disabledProviders:e,editingProviderID:f?g.providerID:void 0,allowExistingAuth:f&&i});w($.err),k($.models),S($.headers);const V=g.models.filter((G,ee)=>Object.values($.models[ee]??{}).some(Boolean)).map(G=>G.row);V.length>0&&P(G=>new Set([...G,...V])),$.result&&await l($.result)};return s.jsxs("form",{onSubmit:ne,className:"space-y-0",children:[s.jsxs(He,{title:d(f?"settings.providers.page.custom.editTitle":"settings.providers.page.custom.title"),divider:!1,settingsItem:"providers.custom",contentClassName:js,children:[s.jsx("p",{className:Dt,children:d("settings.providers.page.custom.description")}),r?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",role:"status",children:r}):null,s.jsxs(Mt,{label:d("settings.providers.page.custom.field.providerID.label"),info:d("settings.providers.page.custom.field.providerID.info"),children:[s.jsx(Ve,{value:g.providerID,onChange:z=>F("providerID",z.target.value),placeholder:d("settings.providers.page.custom.field.providerID.placeholder"),className:"h-8 rounded-md px-3 font-mono text-xs",autoFocus:!f,disabled:f||a,"aria-invalid":!!h.providerID,"aria-label":d("settings.providers.page.custom.field.providerID.label")}),h.providerID?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:h.providerID}):null]}),s.jsx(Mt,{label:d("settings.providers.page.custom.field.protocol.label"),info:d("settings.providers.page.custom.field.protocol.info"),children:s.jsxs(Tt,{value:g.protocol,onValueChange:z=>{z in Rl&&p($=>({...$,protocol:z,models:$.models.map(V=>V.savedVariants?{...V,savedVariants:{}}:V)}))},disabled:a,children:[s.jsx(Pt,{"aria-label":d("settings.providers.page.custom.field.protocol.label"),className:"w-full",children:s.jsx(Ut,{})}),s.jsxs(At,{children:[s.jsx(ot,{value:"openai-chat",children:d("settings.providers.page.custom.field.protocol.openaiChat")}),s.jsx(ot,{value:"openai-responses",children:d("settings.providers.page.custom.field.protocol.openaiResponses")}),s.jsx(ot,{value:"anthropic-messages",children:d("settings.providers.page.custom.field.protocol.anthropicMessages")})]})]})}),s.jsxs(Mt,{label:d("settings.providers.page.custom.field.name.label"),info:d("settings.providers.page.custom.field.name.info"),children:[s.jsx(Ve,{value:g.name,onChange:z=>F("name",z.target.value),placeholder:d("settings.providers.page.custom.field.name.placeholder"),className:"h-8 rounded-md px-3","aria-invalid":!!h.name,"aria-label":d("settings.providers.page.custom.field.name.label")}),h.name?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:h.name}):null]}),s.jsx(Mt,{label:d("settings.providers.page.custom.field.icon.label"),info:d("settings.providers.page.custom.field.icon.info"),children:s.jsxs("div",{className:"flex flex-wrap gap-1.5",role:"group","aria-label":d("settings.providers.page.custom.field.icon.label"),children:[s.jsx(q,{type:"button",variant:g.icon===null?"chip":"ghost",size:"icon",className:Me(os,g.icon===null&&"text-foreground"),"aria-label":d("settings.providers.page.custom.field.icon.option.default"),title:d("settings.providers.page.custom.field.icon.option.default"),"aria-pressed":g.icon===null,onClick:()=>p(z=>({...z,icon:null})),children:K?s.jsx(an,{providerId:R,className:"size-4",ignoreCustomIcon:!0}):s.jsx(J,{name:"checkbox-blank-circle",className:"size-4 text-muted-foreground"})}),Dg.map(z=>s.jsx(q,{type:"button",variant:g.icon===z.id?"chip":"ghost",size:"icon",className:Me(os,g.icon===z.id&&"text-foreground"),"aria-label":d(`settings.providers.page.custom.field.icon.option.${z.id}`),title:d(`settings.providers.page.custom.field.icon.option.${z.id}`),"aria-pressed":g.icon===z.id,onClick:()=>p($=>({...$,icon:z.id})),children:s.jsx(J,{name:z.icon,className:"size-4"})},z.id))]})}),s.jsxs(Mt,{label:d("settings.providers.page.custom.field.baseURL.label"),info:d("settings.providers.page.custom.field.baseURL.info"),children:[s.jsx(Ve,{value:g.baseURL,onChange:z=>F("baseURL",z.target.value),placeholder:d("settings.providers.page.custom.field.baseURL.placeholder"),className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!h.baseURL,"aria-label":d("settings.providers.page.custom.field.baseURL.label")}),h.baseURL?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:h.baseURL}):null]}),s.jsxs(Mt,{label:d("settings.providers.page.custom.field.apiKey.label"),info:d(f&&i?"settings.providers.page.custom.field.apiKey.editInfo":"settings.providers.page.custom.field.apiKey.info"),children:[s.jsx(Ve,{type:"password",value:g.apiKey,onChange:z=>F("apiKey",z.target.value),placeholder:d(f&&i?"settings.providers.page.custom.field.apiKey.editPlaceholder":"settings.providers.page.custom.field.apiKey.placeholder"),className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!h.apiKey,"aria-label":d("settings.providers.page.custom.field.apiKey.label")}),h.apiKey?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:h.apiKey}):null]})]}),s.jsxs(He,{title:d("settings.providers.page.custom.models.title"),contentClassName:js,children:[s.jsxs("div",{className:`${ys} space-y-2`,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{E()},disabled:a||y||!g.baseURL.trim(),children:[s.jsx(J,{name:"search",className:"size-3.5"}),d(y?"settings.providers.page.custom.discovery.fetching":"settings.providers.page.custom.discovery.fetch")]}),s.jsx(qt,{children:d("settings.providers.page.custom.discovery.info")})]}),x?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",role:"alert",children:x}):null,j?s.jsx(l1,{models:j,existingIds:new Set(g.models.map(z=>z.id.trim()).filter(Boolean)),onAdd:B,onCancel:()=>D(null)}):null]}),s.jsx("div",{className:ys,children:g.models.map((z,$)=>s.jsx(u1,{model:z,errors:b[$],expanded:C.has(z.row),onToggle:()=>_(z.row),onChange:(V,G)=>T($,V,G),onToggleCapability:(V,G)=>H($,V,G),onToolsChange:V=>p(G=>({...G,models:G.models.map((ee,ae)=>ae===$?{...ee,tools:V,capabilitiesKnown:!0,metadataSource:"manual"}:ee)})),onRemove:g.models.length>1?()=>{p(V=>({...V,models:V.models.filter((G,ee)=>ee!==$)})),k(V=>V.filter((G,ee)=>ee!==$))}:void 0},z.row))}),s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const z=Uo();p($=>({...$,models:[...$.models,z]})),k($=>[...$,{}]),P($=>new Set([...$,z.row]))},children:d("settings.providers.page.custom.models.add")})]}),s.jsxs(He,{title:d("settings.providers.page.custom.headers.title"),contentClassName:js,children:[s.jsx("p",{className:Dt,children:d("settings.providers.page.custom.headers.description")}),g.headers.map((z,$)=>s.jsx("div",{className:`${ys} space-y-2`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:d("settings.providers.page.custom.headers.keyLabel")}),s.jsx(Ve,{value:z.key,onChange:V=>O($,"key",V.target.value),placeholder:d("settings.providers.page.custom.headers.keyPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":d("settings.providers.page.custom.headers.keyLabel")}),v[$]?.key?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:v[$]?.key}):null]}),s.jsxs("div",{children:[s.jsx("label",{className:Ct,children:d("settings.providers.page.custom.headers.valueLabel")}),s.jsx(Ve,{value:z.value,onChange:V=>O($,"value",V.target.value),placeholder:d("settings.providers.page.custom.headers.valuePlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":d("settings.providers.page.custom.headers.valueLabel")}),v[$]?.value?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:v[$]?.value}):null]})]}),s.jsx(q,{type:"button",variant:"ghost",size:"icon",className:os,disabled:g.headers.length<=1,onClick:()=>{g.headers.length<=1||(p(V=>({...V,headers:V.headers.filter((G,ee)=>ee!==$)})),S(V=>V.filter((G,ee)=>ee!==$)))},"aria-label":d("settings.providers.page.custom.headers.remove"),children:s.jsx(J,{name:"delete-bin",className:"size-4"})})]})},z.row)),s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{p(z=>({...z,headers:[...z.headers,Fl()]})),S(z=>[...z,{}])},children:d("settings.providers.page.custom.headers.add")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-4",children:[u?s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:u,disabled:a,children:d("settings.providers.page.custom.actions.back")}):null,m?s.jsx(q,{type:"button",variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>{m()},disabled:a,children:d("settings.providers.page.actions.disconnect")}):null,s.jsx(q,{type:"submit",size:"xs",className:"!font-normal",disabled:a,children:d(a?"settings.providers.page.actions.saving":f?"settings.providers.page.custom.actions.update":"settings.providers.page.custom.actions.save")})]})]})},sd=({integrationId:t,keyMethod:e,connectKey:a,onSaved:n})=>{const{t:o}=ze(),i=c.useMemo(()=>(e?.form??[]).filter(Za),[e]),[r,l]=c.useState(""),[u,m]=c.useState({}),d=c.useMemo(()=>({...yu(i),...u}),[i,u]),[f,g]=c.useState(null),[p,h]=c.useState(!1),w=async()=>{const b=r.trim();if(!b){W.error(o("settings.providers.page.toast.apiKeyRequired"));return}const k=ku(i,d);if(k){g(o("settings.providers.page.auth.oauth.promptRequired",{field:ta(k)}));return}g(null);const v={integrationID:t,key:b},S=wu(i,d);Object.keys(S).length>0&&(v.answer=S),h(!0);try{await a(v),W.success(o("settings.providers.page.toast.apiKeySaved")),l(""),n()}catch(y){console.error("Failed to save API key:",y),W.error(o("settings.providers.page.toast.apiKeySaveFailed"))}finally{h(!1)}};return s.jsxs("div",{className:"py-1.5 space-y-3",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[o("settings.providers.page.auth.apiKeyLabel"),s.jsx(qt,{children:o("settings.providers.page.auth.apiKeyTooltip")})]}),s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center gap-2 mt-1.5",children:[s.jsx(Ve,{type:"password",value:r,onChange:b=>l(b.target.value),placeholder:o("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),s.jsx(q,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{w()},disabled:p,children:o(p?"settings.providers.page.actions.saving":"settings.providers.page.actions.saveKey")})]})]}),i.length>0?s.jsx(Su,{fields:i,values:d,onChange:(b,k)=>m(v=>({...v,[b]:k}))}):null,f?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:f}):null]})},nd=t=>{if(typeof t!="number"||Number.isNaN(t))return null;if(t===0)return"0";const e=ap(t);return e.endsWith(".0")?e.slice(0,-2):e},ad=async t=>{await Ks.getSdkClient().integration.connect.key(t)},Sn="__add_provider__",La="__classification__",g1=()=>{const{t}=ze(),{isMobile:e}=Fn(),a=Us(),n=rt(L=>_d(L,a)),o=oe(L=>L.settingsProvidersConnectRequested),i=oe(L=>L.setSettingsProvidersConnectRequested),r=oe(L=>L.settingsProvidersClassificationRequested),l=oe(L=>L.setSettingsProvidersClassificationRequested),u=oe(L=>L.settingsProvidersOpenRequested),m=oe(L=>L.setSettingsProvidersOpenRequested),[d,f]=c.useState(()=>o?Sn:r?La:u??"");c.useEffect(()=>{o&&(f(Sn),i(!1))},[o,i]),c.useEffect(()=>{r&&(f(La),l(!1))},[r,l]),c.useEffect(()=>{u&&(f(u),m(null))},[u,m]);const g=rt(L=>L.getModelMetadata),p=oe(L=>L.hiddenModels),h=oe(L=>L.customProviderIcons),w=oe(L=>L.setCustomProviderIcon),b=oe(L=>L.toggleHiddenModel),k=oe(L=>L.hideAllModels),v=oe(L=>L.showAllModels),S=rt(L=>L.loadProviders);c.useEffect(()=>{S({directory:a,source:"settings:providers"})},[S,a]);const[y,N]=c.useState(()=>mu()),[x,I]=c.useState(!1),j=y?.integrations??null,[D,C]=c.useState(null);c.useEffect(()=>{let L=!0;return ny().then(me=>{L&&C(me)}).catch(me=>{console.warn("[providers] could not read disabled providers:",me)}),()=>{L=!1}},[]);const P=c.useCallback(async(L,me)=>{try{C(await ay(L,me)),me&&f(""),W.success(me?t("settings.providers.disabled.toast.disabled",{provider:L}):t("settings.providers.disabled.toast.enabled",{provider:L})),S({directory:a,source:"settings:providers",fresh:!0})}catch(Se){W.error(Se instanceof Error?Se.message:String(Se))}},[S,f,a,t]),A=y===null&&!x,[R,K]=c.useState(null),[F,T]=c.useState(null),[O,E]=c.useState(""),[B,_]=c.useState(""),[H,ne]=c.useState({}),[z,$]=c.useState({}),[V,G]=c.useState(0),[ee,ae]=c.useState(0),[X,Q]=c.useState(!1),le=Ln(),[Z,fe]=c.useState(null),[Y,be]=c.useState(null),[Ee,se]=c.useState(null),[re,je]=c.useState(null),[ie,Pe]=c.useState(null),[ke,Ae]=c.useState(null),Te=d===Sn,Ke=Te&&B===Pr,ge=!!(Y&&d&&Y===d&&!Te);c.useEffect(()=>{let L=!0;return(async()=>{try{const Se=await pu();if(!L)return;N(Se),I(!1)}catch(Se){if(!L)return;console.error("Failed to load provider integrations:",Se),I(!0),W.error(t("settings.providers.page.toast.authMethodsLoadFailed"))}})(),()=>{L=!1}},[ee,t]);const Re=c.useMemo(()=>new Set(n.map(L=>L.id)),[n]),Oe=c.useMemo(()=>y?gf(y,Re):null,[y,Re]);c.useEffect(()=>{d!==Sn||!Oe||Oe.length===0||B&&B!==Pr&&!Oe.some(L=>L.id===B)&&_("")},[d,B,Oe]),c.useEffect(()=>{if(d===Sn){Q(!0),fe(null),be(null),se(null),je(null),Pe(null);return}Q(!1),fe(null),Y&&Y!==d&&(be(null),se(null),je(null),Pe(null))},[d,Y]),c.useEffect(()=>{if(!d||d===Sn||d===La)return;const L=H[d];if(!L||j===null)return;const me=n.find(We=>We.id===d),Se=Hc({connections:go(j,d),optionsApiKey:sl(me),machineCredentials:nl(me)}),Ce=!!(me&&Yc(me,L));my({hasCredentials:Se,userDismissed:Z===d,isEditableCustomProvider:Ce})&&Q(!0)},[d,H,n,j,Z]),c.useEffect(()=>{if(!d||d===Sn||d===La)return;let L=!1;return(async()=>{try{const Se=a?`?directory=${encodeURIComponent(a)}`:"",Ce=await Rt(`/api/provider/${encodeURIComponent(d)}/source${Se}`,{method:"GET",headers:{Accept:"application/json"}}),We=await Ce.json().catch(()=>null);if(!Ce.ok)throw new Error(We?.error||t("settings.providers.page.toast.providerSourcesLoadFailed"));const ce=We?.sources??We?.data?.sources;!L&&ce&&(ne(Fe=>({...Fe,[d]:ce})),$(Fe=>({...Fe,[d]:Xy.safeParse(We?.config??We?.data?.config).data??null})))}catch(Se){L||console.error("Failed to load provider sources:",Se)}})(),()=>{L=!0}},[d,V,a,t]);const pe=c.useCallback(()=>{G(L=>L+1)},[]),xe=c.useCallback(()=>{ae(L=>L+1)},[]),Ne=c.useCallback(L=>{N(me=>me&&{...me,integrations:me.integrations.map(Se=>Se.id===L&&Se.connections.length===0?{...Se,connections:[{type:"credential",id:`pending:${L}`,label:L,method:"key"}]}:Se)}),fe(null),Q(!1),_(""),f(L),pe(),xe()},[xe,pe,f]),de=n.find(L=>L.id===d),Ue=d?H[d]:void 0,Ie=async L=>{const me=`custom:${L.providerID}`;K(me),Ae(L.providerID),Pe(null);try{const Se=n1(L),Ce=a1(L,{scope:Y?re??Zc(H[Y]):"user"}),We=await Rt(`/api/provider${a?`?directory=${encodeURIComponent(a)}`:""}`,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(Ce)}),ce=await We.json().catch(()=>null);if(!We.ok)throw new Error(ce?.error||t("settings.providers.page.toast.customProviderSaveFailed"));if(Se)try{await o1(()=>Ks.getSdkClient().integration.connect.key(Se))}catch(ct){throw Pe(t("settings.providers.page.custom.authFailure.keyAfterConfig")),ct}const Fe={...oe.getState().customProviderIcons};L.icon?Fe[L.providerID]=L.icon:delete Fe[L.providerID],await yt({customProviderIcons:Fe}),w(L.providerID,L.icon),W.success(t("settings.providers.page.toast.customProviderSaved",{provider:L.name})),_(""),be(null),se(null),je(null),Pe(null),Ae(null),Ne(L.providerID)}catch(Se){console.error("Failed to save custom provider:",Se),W.error(Se instanceof Error&&Se.message?Se.message:t("settings.providers.page.toast.customProviderSaveFailed"))}finally{K(null)}},De=L=>{Q(!1),Ne(L)},Je=async L=>{const me=`disconnect:${L}`;K(me);try{const Se=Vc(gn(j??[],L)),Ce=Ks.getSdkClient();for(const We of Se)await Ce.credential.remove({credentialID:We.id});W.success(t("settings.providers.page.toast.providerDisconnected")),fe(null),pe(),xe()}catch(Se){console.error("Failed to disconnect provider:",Se),W.error(t("settings.providers.page.toast.providerDisconnectFailed"))}finally{K(null)}},tt=async L=>{L&&(await Je(L),be(null),se(null),je(null),Pe(null),Ae(null),_(""))},mt=async(L,me,Se)=>{T(L.id);try{await me(),Se.success&&W.success(Se.success)}catch(Ce){console.error("Provider account action failed:",Ce),W.error(Se.failure)}finally{T(null),xe()}},ht=L=>mt(L,async()=>{await Ks.getSdkClient().credential.activate({credentialID:L.id})},{success:t("settings.providers.accounts.toast.switched",{account:L.label}),failure:t("settings.providers.accounts.toast.switchFailed")}),ft=(L,me)=>mt(L,async()=>{await Ks.getSdkClient().credential.update({credentialID:L.id,label:me})},{failure:t("settings.providers.accounts.toast.renameFailed")}),xt=L=>mt(L,async()=>{await Ks.getSdkClient().credential.remove({credentialID:L.id}),pe()},{success:t("settings.providers.accounts.toast.removed"),failure:t("settings.providers.accounts.toast.removeFailed")}),Qe=()=>{_(""),f("")},lt=s.jsx(ko,{label:t("settings.providers.page.back"),onClick:Qe}),Ye=L=>{if(n.some(me=>me.id===L)){f(L);return}_(L),f(Sn)};if(d===La)return s.jsx(Dy,{titleLeading:lt,onOpenProvider:Ye});if(Te&&!le&&!B)return s.jsx(Yt,{title:t("settings.providers.page.connect.title"),titleLeading:lt,showSaveStatus:!1,children:s.jsx(oy,{providers:Oe,loadFailed:x,onSelect:_,onSelectCustom:()=>_(Pr)})});if(Te&&!le){const L=s.jsx(ko,{label:t("settings.providers.page.back"),onClick:()=>_("")}),me=Oe?.find(Se=>Se.id===B)?.name??B;return s.jsx(Yt,{title:Ke?t("settings.providers.page.connect.title"):me,titleLeading:Ke?L:s.jsxs("span",{className:"flex items-center gap-2",children:[L,s.jsx(an,{providerId:B,className:"h-5 w-5 shrink-0"})]}),showSaveStatus:!1,children:Ke?s.jsx(td,{mode:"create",existingProviderIDs:Re,busy:R?.startsWith("custom:")??!1,authFailureHint:ie,onCancel:()=>{_(""),Pe(null),Ae(null)},onDisconnect:ie&&ke?()=>{tt(ke)}:void 0,onSubmit:Ie}):s.jsx(He,{title:t("settings.providers.page.auth.title"),divider:!1,settingsItem:"providers.auth",contentClassName:"space-y-4",children:A?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.page.auth.loadingMethods")}):s.jsx(s.Fragment,{children:(()=>{const Se=gn(j??[],B),Ce=al(gn(j??[],ji(B))),We=_c(Se);return s.jsxs(s.Fragment,{children:[We?s.jsx(sd,{integrationId:B,keyMethod:il(Se),connectKey:ad,onSaved:()=>Ne(B)},B):null,Ce.length>0?s.jsx(No,{integrationId:ji(B),methods:Ce,onConnected:()=>De(B),className:Me(We&&"border-t border-[var(--surface-subtle)] pt-2")},B):null]})})()})})})}if(!de)return s.jsx(ky,{providers:n,integrations:j,directory:a,onSelect:f,onConnect:()=>f(Sn),onOpenClassification:()=>f(La),disabledProviders:D,onEnableProvider:L=>{P(L,!1)}});const at=Array.isArray(de.models)?de.models:[],dt=gn(j??[],de.id),_e=al(gn(j??[],ji(de.id))),nt=_c(dt),te=j!==null,ue=!!Ue,he=ue&&Yc(de,Ue),ye=Hc({connections:go(j??[],de.id),optionsApiKey:sl(de),machineCredentials:nl(de)}),qe=iy(te,ye,he),Ze=uy({modelCount:at.length,integrationsLoaded:te,hasCredentials:ye,isEditableCustomProvider:he}),pt=go(j??[],de.id)??[],vt=de.integrationID??de.id,bt=Vc(gn(j??[],vt)),wt=bt[0]?.id??null,Et=new Set(pt.flatMap(L=>L.type==="credential"&&!bt.some(me=>me.id===L.id)?[L.id]:[])),Le=[Ue?.user.exists?t("settings.providers.page.connectionDetails.source.userConfig"):null,Ue?.project.exists?t("settings.providers.page.connectionDetails.source.projectConfig"):null,Ue?.custom?.exists?t("settings.providers.page.connectionDetails.source.customConfig"):null].filter(L=>L!==null),Xe=s.jsxs("span",{className:"flex items-center gap-2",children:[lt,s.jsx(an,{providerId:de.id,className:"h-5 w-5 shrink-0"})]}),gt=s.jsxs("span",{className:"typography-settings-description text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:de.id}),Le.length>0?s.jsxs(s.Fragment,{children:[" · ",t("settings.providers.page.configuredIn",{sources:Le.join(", ")})]}):null]}),jt=_n(at,O,L=>[typeof L?.name=="string"?L.name:"",typeof L?.id=="string"?L.id:""]);return ge&&he&&Ee?s.jsx(Yt,{title:de.name||de.id,titleLeading:Xe,description:gt,showSaveStatus:!1,children:s.jsx(td,{mode:"edit",existingProviderIDs:Re,initialValues:Ee,allowExistingAuth:ye||!ue,busy:R?.startsWith("custom:")??!1,authFailureHint:ie,onCancel:()=>{be(null),se(null),je(null),Pe(null),Ae(null)},onDisconnect:()=>{tt(de.id)},onSubmit:Ie})}):s.jsxs(Yt,{title:de.name||de.id,titleLeading:Xe,description:gt,showSaveStatus:!1,children:[s.jsxs(He,{title:t("settings.providers.accounts.title"),info:t("settings.providers.accounts.info"),divider:!1,headerAction:s.jsxs("div",{className:"flex items-center gap-1",children:[he&&!le?s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Pe(null),se(e1(de,z[de.id]??null,h[de.id])),je(Zc(Ue)),be(de.id)},children:t("settings.providers.page.actions.edit")}):null,D!==null?s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",title:t("settings.providers.disabled.disableHint"),onClick:()=>{P(de.id,!0)},children:t("settings.providers.disabled.disable")}):null,le?null:s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const L=!X;Q(L),fe(L?null:de.id)},children:X?t("settings.providers.page.actions.cancel"):s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"add",className:"size-3.5"}),pt.length>0?t("settings.providers.accounts.add"):t("settings.providers.page.actions.connect")]})})]}),settingsItem:"providers.auth",contentClassName:"space-y-4",children:[pt.length>0?s.jsx(Ly,{connections:pt,activeId:wt,unusedIds:Et,busyId:F,onActivate:L=>{ht(L)},onRename:(L,me)=>{ft(L,me)},onRemove:L=>{xt(L)}}):!X&&qe?s.jsxs("div",{className:"flex items-center gap-1.5 py-1.5",children:[s.jsx(J,{name:"alert",className:"w-4 h-4 text-[var(--status-warning)] shrink-0"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.providers.page.auth.incomplete")}),nt?s.jsx(qt,{children:t("settings.providers.page.auth.incompleteHint")}):null]}):null,le?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.enterpriseMode")}):null,!X||le?null:A?s.jsx("div",{className:"py-1.5 typography-meta text-muted-foreground",children:t("settings.providers.page.auth.loadingMethods")}):s.jsxs("div",{className:Me("space-y-4",pt.length>0&&"rounded-xl border border-[var(--interactive-border)] p-4"),children:[nt?s.jsx(sd,{integrationId:de.id,keyMethod:il(dt),connectKey:ad,onSaved:()=>Ne(de.id)},de.id):null,_e.length>0&&s.jsx(No,{integrationId:ji(de.id),methods:_e,onConnected:()=>De(de.id),className:Me(nt&&"border-t border-[var(--surface-subtle)] pt-2")},de.id)]})]}),Ze?s.jsxs(He,{title:t("settings.providers.page.models.title"),titleAccessory:s.jsxs("span",{className:"typography-micro text-muted-foreground font-normal",children:["(",at.length,")"]}),headerAction:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const L=at.map(me=>typeof me?.id=="string"?me.id:"").filter(me=>me.length>0);k(de.id,L)},children:t("settings.providers.page.actions.hideAll")}),s.jsx(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>v(de.id),children:t("settings.providers.page.actions.showAll")})]}),settingsItem:"providers.models",children:[s.jsxs("div",{className:"relative mb-2",children:[s.jsx(J,{name:"search",className:"absolute inset-s-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Ve,{value:O,onChange:L=>E(L.target.value),placeholder:t("settings.providers.page.models.filterPlaceholder"),className:"h-7 ps-8 w-full"})]}),jt.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground py-4 text-center",children:t("settings.providers.page.models.noModelsMatchFilter")}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:jt.map(L=>{const me=typeof L?.id=="string"?L.id:"",Se=typeof L?.name=="string"?L.name:me,Ce=me?g(de.id,me):void 0,We=p.some(It=>It.providerID===de.id&&It.modelID===me),ce=nd(Ce?.limit?.context),Fe=nd(Ce?.limit?.output),ct=[ce?`${ce} ${t("settings.providers.page.models.tokenBadge.context")}`:null,Fe?`${Fe} ${t("settings.providers.page.models.tokenBadge.output")}`:null].filter(Boolean).join(" · "),Ft=[];return Ce?.tool_call&&Ft.push({key:"tools",icon:"tools",label:t("settings.providers.page.models.capability.toolCalling")}),Ce?.reasoning&&Ft.push({key:"reasoning",icon:"brain-ai-3",label:t("settings.providers.page.models.capability.reasoning")}),Ce?.attachment&&Ft.push({key:"image",icon:"file-image",label:t("settings.providers.page.models.capability.imageInput")}),s.jsx("div",{className:"py-1.5",children:s.jsxs("div",{className:Me("flex items-center gap-3",We&&"opacity-50"),children:[s.jsx("span",{className:"typography-meta font-medium text-foreground truncate flex-1 min-w-0",children:Se}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e?ct||Ft.length>0?s.jsx(qt,{className:"h-6 w-6",children:s.jsxs("div",{className:"space-y-1.5",children:[ct?s.jsx("div",{className:"font-medium",children:ct}):null,Ft.map(({key:It,icon:ls,label:et})=>s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(J,{name:ls,className:"h-3.5 w-3.5"}),et]},It))]})}):null:s.jsxs(s.Fragment,{children:[ct?s.jsx("span",{className:"typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:ct}):null,Ft.length>0&&s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:Ft.map(({key:It,icon:ls,label:et})=>s.jsx("span",{className:"flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]",title:et,"aria-label":et,children:s.jsx(J,{name:ls,className:"h-3 w-3"})},It))})]}),s.jsx("button",{type:"button",onClick:()=>b(de.id,me),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50",title:t(We?"settings.providers.page.models.actions.showModelInSelectors":"settings.providers.page.models.actions.hideModelFromSelectors"),"aria-label":t(We?"settings.providers.page.models.actions.showModel":"settings.providers.page.models.actions.hideModel"),children:We?s.jsx(J,{name:"eye-off",className:"h-3.5 w-3.5"}):s.jsx(J,{name:"eye",className:"h-3.5 w-3.5"})})]})]})},me)})})]}):null]})},f1=t=>{const e=t?.windows??{},a=Object.values(e).map(n=>n.usedPercent).filter(n=>typeof n=="number");return a.length===0?null:Math.max(...a)},h1=t=>{const e=$e.c(75),{onItemSelect:a}=t,{t:n}=ze(),o=rs(b1),i=rs(x1),r=rs(v1),l=rs(y1),u=rs(j1),m=rs(k1),d=rs(w1),f=rs(S1);let g,p;e[0]!==f?(g=()=>{f()},p=[f],e[0]=f,e[1]=g,e[2]=p):(g=e[1],p=e[2]),c.useEffect(g,p);const h=N1;let w;e[3]!==d?(w=X=>{X!=="usage"&&X!=="remaining"||(d(X),h({usageDisplayMode:X}))},e[3]=d,e[4]=w):w=e[4];const b=w;let k;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=Me("flex h-full flex-col","bg-background"),e[5]=k):k=e[5];let v;e[6]!==n?(v=n("settings.usage.sidebar.title"),e[6]=n,e[7]=v):v=e[7];let S;e[8]!==v?(S=s.jsx("h2",{className:`${On} mb-3`,children:v}),e[8]=v,e[9]=S):S=e[9];let y;e[10]!==n?(y=n("settings.usage.sidebar.total",{count:xo.length}),e[10]=n,e[11]=y):y=e[11];let N;e[12]!==y?(N=s.jsx("span",{className:"typography-meta text-muted-foreground",children:y}),e[12]=y,e[13]=N):N=e[13];let x;e[14]!==l?(x=()=>l(),e[14]=l,e[15]=x):x=e[15];let I;e[16]!==n?(I=n("settings.usage.sidebar.actions.refreshAria"),e[16]=n,e[17]=I):I=e[17];let j;e[18]!==n?(j=n("settings.usage.sidebar.actions.refreshTitle"),e[18]=n,e[19]=j):j=e[19];const D=u&&"animate-spin";let C;e[20]!==D?(C=Me("h-3.5 w-3.5",D),e[20]=D,e[21]=C):C=e[21];let P;e[22]!==C?(P=s.jsx(J,{name:"refresh",className:C}),e[22]=C,e[23]=P):P=e[23];let A;e[24]!==u||e[25]!==I||e[26]!==j||e[27]!==P||e[28]!==x?(A=s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(q,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 text-muted-foreground",onClick:x,"aria-label":I,title:j,disabled:u,children:P})}),e[24]=u,e[25]=I,e[26]=j,e[27]=P,e[28]=x,e[29]=A):A=e[29];let R;e[30]!==A||e[31]!==N?(R=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[N,A]}),e[30]=A,e[31]=N,e[32]=R):R=e[32];let K;e[33]!==n?(K=n("settings.usage.sidebar.field.display"),e[33]=n,e[34]=K):K=e[34];let F;e[35]!==K?(F=s.jsx("span",{className:"typography-micro text-muted-foreground",children:K}),e[35]=K,e[36]=F):F=e[36];let T;e[37]!==n?(T=n("settings.usage.sidebar.field.displayModePlaceholder"),e[37]=n,e[38]=T):T=e[38];let O;e[39]!==T?(O=s.jsx(Pt,{className:"w-fit",children:s.jsx(Ut,{placeholder:T})}),e[39]=T,e[40]=O):O=e[40];let E;e[41]!==n?(E=n("settings.usage.sidebar.field.displayModeUsage"),e[41]=n,e[42]=E):E=e[42];let B;e[43]!==E?(B=s.jsx(ot,{value:"usage",children:E}),e[43]=E,e[44]=B):B=e[44];let _;e[45]!==n?(_=n("settings.usage.sidebar.field.displayModeRemaining"),e[45]=n,e[46]=_):_=e[46];let H;e[47]!==_?(H=s.jsx(ot,{value:"remaining",children:_}),e[47]=_,e[48]=H):H=e[48];let ne;e[49]!==B||e[50]!==H?(ne=s.jsxs(At,{children:[B,H]}),e[49]=B,e[50]=H,e[51]=ne):ne=e[51];let z;e[52]!==b||e[53]!==O||e[54]!==ne||e[55]!==m?(z=s.jsxs(Tt,{value:m,onValueChange:b,children:[O,ne]}),e[52]=b,e[53]=O,e[54]=ne,e[55]=m,e[56]=z):z=e[56];let $;e[57]!==F||e[58]!==z?($=s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[F,z]}),e[57]=F,e[58]=z,e[59]=$):$=e[59];let V;e[60]!==R||e[61]!==$||e[62]!==S?(V=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[S,R,$]}),e[60]=R,e[61]=$,e[62]=S,e[63]=V):V=e[63];let G;e[64]!==a||e[65]!==o||e[66]!==i||e[67]!==r||e[68]!==n?(G=xo.map(X=>{const Q=o.find(Ee=>Ee.providerId===X.id),le=f1(Q?.usage),Z=Vd(le),fe=X.id===i,Y=Q?.configured,be=Y?Z==="critical"?{backgroundColor:"var(--status-error)"}:Z==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"}:{backgroundColor:"var(--surface-muted-foreground)",opacity:.4};return s.jsx("div",{className:Me("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",fe?"bg-interactive-selection":"hover:bg-interactive-hover"),children:s.jsxs("button",{type:"button",onClick:()=>{r(X.id),a?.()},className:"flex min-w-0 flex-1 items-center gap-2 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[s.jsx("span",{className:"h-2.5 w-2.5 rounded-full flex-shrink-0",style:be}),s.jsx(an,{providerId:X.id,className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:X.name}),Y===!1&&s.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:n("settings.usage.sidebar.status.notSet")})]})},X.id)}),e[64]=a,e[65]=o,e[66]=i,e[67]=r,e[68]=n,e[69]=G):G=e[69];let ee;e[70]!==G?(ee=s.jsx(Ts,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:G}),e[70]=G,e[71]=ee):ee=e[71];let ae;return e[72]!==V||e[73]!==ee?(ae=s.jsxs("div",{className:k,children:[V,ee]}),e[72]=V,e[73]=ee,e[74]=ae):ae=e[74],ae};function b1(t){return t.results}function x1(t){return t.selectedProviderId}function v1(t){return t.setSelectedProvider}function y1(t){return t.fetchAllQuotas}function j1(t){return t.isLoading}function k1(t){return t.displayMode}function w1(t){return t.setDisplayMode}function S1(t){return t.loadSettings}async function N1(t){try{await yt(t)}catch(e){console.warn("Failed to save usage settings:",e)}}const C1=t=>{const e=$e.c(17),{percent:a,tonePercent:n,className:o}=t;let i;e[0]!==a?(i=ip(a)??0,e[0]=a,e[1]=i):i=e[1];const r=i,l=n??a;let u;e[2]!==l?(u=Vd(l),e[2]=l,e[3]=u):u=e[3];const m=u;let d;e[4]!==m?(d=m==="critical"?{backgroundColor:"var(--status-error)"}:m==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=m,e[5]=d):d=e[5];const f=d;let g;e[6]!==o?(g=Me("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",o),e[6]=o,e[7]=g):g=e[7];const p=`${r}%`;let h;e[8]!==f||e[9]!==p?(h={...f,width:p},e[8]=f,e[9]=p,e[10]=h):h=e[10];let w;e[11]!==r||e[12]!==h?(w=s.jsx("div",{className:"h-full transition-all duration-300",style:h,role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100}),e[11]=r,e[12]=h,e[13]=w):w=e[13];let b;return e[14]!==g||e[15]!==w?(b=s.jsx("div",{className:g,children:w}),e[14]=g,e[15]=w,e[16]=b):b=e[16],b},Ar=t=>{const e=$e.c(49),{title:a,window:n,subtitle:o,showToggle:i,toggleEnabled:r,onToggle:l,providerId:u}=t,m=i===void 0?!1:i,d=r===void 0?!1:r,{t:f}=ze(),g=rs(I1),p=oe(P1),h=g==="remaining"?n.remainingPercent:n.usedPercent,w=h!==null;let b;e[0]!==g||e[1]!==f?(b=f(g==="remaining"?"settings.usage.card.bar.remaining":"settings.usage.card.bar.used"),e[0]=g,e[1]=f,e[2]=b):b=e[2];const k=b;let v;e[3]!==h||e[4]!==n.valueLabel?(v=op(n.valueLabel,h),e[3]=h,e[4]=n.valueLabel,e[5]=v):v=e[5];const S=v;let y;if(e[6]!==f||e[7]!==p||e[8]!==n.resetAfterFormatted||e[9]!==n.resetAt||e[10]!==n.resetAtFormatted){const _=rp(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,p);y=_?f("settings.usage.card.resetsAt",{time:_}):"",e[6]=f,e[7]=p,e[8]=n.resetAfterFormatted,e[9]=n.resetAt,e[10]=n.resetAtFormatted,e[11]=y}else y=e[11];const N=y;let x;e[12]!==a?(x=lp(a),e[12]=a,e[13]=x):x=e[13];const I=x;let j;e[14]!==l||e[15]!==m||e[16]!==f||e[17]!==d?(j=m&&s.jsx(Pi,{checked:d,onChange:_=>l?.(_),ariaLabel:f("settings.usage.card.showInHeaderAria")}),e[14]=l,e[15]=m,e[16]=f,e[17]=d,e[18]=j):j=e[18];let D;e[19]!==I?(D=s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:I}),e[19]=I,e[20]=D):D=e[20];let C;e[21]!==o?(C=o&&s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:o}),e[21]=o,e[22]=C):C=e[22];let P;e[23]!==D||e[24]!==C?(P=s.jsxs("div",{className:"min-w-0 flex flex-col",children:[D,C]}),e[23]=D,e[24]=C,e[25]=P):P=e[25];let A;e[26]!==P||e[27]!==j?(A=s.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[j,P]}),e[26]=P,e[27]=j,e[28]=A):A=e[28];let R;e[29]!==u||e[30]!==n?(R=u&&s.jsx(cp,{window:n,providerId:u}),e[29]=u,e[30]=n,e[31]=R):R=e[31];const K=S==="-"?"":S;let F;e[32]!==K?(F=s.jsx("div",{className:"typography-ui-label text-foreground tabular-nums",children:K}),e[32]=K,e[33]=F):F=e[33];let T;e[34]!==R||e[35]!==F?(T=s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[R,F]}),e[34]=R,e[35]=F,e[36]=T):T=e[36];let O;e[37]!==A||e[38]!==T?(O=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[A,T]}),e[37]=A,e[38]=T,e[39]=O):O=e[39];let E;e[40]!==k||e[41]!==h||e[42]!==w||e[43]!==N||e[44]!==n.usedPercent?(E=w?s.jsxs("div",{className:"mt-2.5",children:[s.jsx(C1,{percent:h,tonePercent:n.usedPercent,className:"h-1.5"}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:N}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:k})]})]}):N?s.jsx("div",{className:"mt-1 typography-micro text-muted-foreground",children:N}):null,e[40]=k,e[41]=h,e[42]=w,e[43]=N,e[44]=n.usedPercent,e[45]=E):E=e[45];let B;return e[46]!==O||e[47]!==E?(B=s.jsxs("div",{className:"py-3",children:[O,E]}),e[46]=O,e[47]=E,e[48]=B):B=e[48],B};function I1(t){return t.displayMode}function P1(t){return t.timeFormatPreference}const A1=`ssh exe.dev "ssh-key generate-api-key --label=openchamber --exp=30d --cmds='billing credits usage'"`,T1=({providerId:t,providerName:e})=>{const{t:a}=ze(),[n,o]=c.useState(null),[i,r]=c.useState({}),[l,u]=c.useState(!1),m=`/api/quota/credentials/${t}`;c.useEffect(()=>{Rt(m).then(async g=>{if(!g.ok)throw new Error;const p=await g.json();o(p),r({})}).catch(()=>o({configured:!1}))},[m]);const d=async(g,p,h)=>{u(!0);try{const w=await Rt(g,{method:p,headers:h?{"Content-Type":"application/json"}:void 0,body:h?JSON.stringify(h):void 0}),b=await w.json().catch(()=>null);if(!w.ok)throw new Error(b?.error);b?.configured!==void 0&&o(b),r({}),W.success(a("settings.providers.page.quotaCredentials.saved",{provider:e}))}catch(w){W.error(w instanceof Error&&w.message?w.message:a("settings.providers.page.openCodeGo.saveFailed"))}finally{u(!1)}},f=(g,p,h)=>s.jsxs("label",{className:"block typography-ui-label text-foreground",children:[p,s.jsx(Ve,{className:"mt-1 h-7 font-mono text-xs",type:"password",autoComplete:"off",value:i[g]??"",onChange:w=>r(b=>({...b,[g]:w.target.value})),placeholder:n?.secretMasked??h})]});return s.jsxs("div",{"data-settings-item":`usage.${t}-credentials`,className:"mb-8",children:[s.jsx("div",{className:"mb-1 px-1",children:s.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:e})}),s.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[t==="exe-dev"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:a("settings.providers.page.quotaCredentials.exeDevTokenInstructions")}),s.jsx("code",{className:"typography-code block whitespace-pre-wrap break-all rounded bg-muted/50 px-2 py-1.5 text-xs text-foreground",children:A1})]}),t==="zenmux"&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:a("settings.providers.page.quotaCredentials.zenmuxInstructions")}),t==="exe-dev"&&f("usageToken",a("settings.providers.page.quotaCredentials.usageToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="zenmux"&&f("platformApiKey",a("settings.providers.page.quotaCredentials.platformApiKey"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="cursor"&&f("accessToken",a("settings.providers.page.quotaCredentials.accessToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="cursor"&&f("refreshToken",a("settings.providers.page.quotaCredentials.refreshToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(q,{size:"xs",disabled:l,onClick:()=>d(m,"PUT",i),children:n?.configured?a("settings.providers.page.openCodeGo.replace"):a("settings.providers.page.openCodeGo.save")}),n?.configured&&s.jsx(q,{variant:"outline",size:"xs",disabled:l,onClick:()=>d(`${m}/validate`,"POST"),children:a("settings.providers.page.openCodeGo.validate")}),t==="cursor"&&s.jsx(q,{variant:"outline",size:"xs",disabled:l,onClick:()=>d(`${m}/import`,"POST"),children:a("settings.providers.page.actions.connect")}),n?.configured&&s.jsx(q,{variant:"destructive",size:"xs",disabled:l,onClick:()=>d(m,"DELETE"),children:a("settings.providers.page.openCodeGo.delete")})]})]})]})},E1="claude-code",M1="claude auth login",Vu=t=>({state:"ready",integration:gn(t,E1)}),D1=t=>{const e=$e.c(15),{onSignedIn:a}=t,{t:n}=ze(),[o,i]=c.useState(R1);let r,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{let f=!1;return(async()=>{try{const g=await pu();f||i(Vu(g.integrations))}catch(g){console.error("Failed to load the Claude Code sign-in:",g),f||i(F1)}})(),()=>{f=!0}},l=[],e[0]=r,e[1]=l):(r=e[0],l=e[1]),c.useEffect(r,l),o.state==="loading")return null;let u;e[2]!==o.integration?(u=al(o.integration),e[2]=o.integration,e[3]=u):u=e[3];const m=u;if(!o.integration||m.length===0){let f;e[4]!==n?(f=n("settings.usage.page.state.claudeSignInCommand"),e[4]=n,e[5]=f):f=e[5];let g;e[6]!==f?(g=s.jsx("p",{className:"typography-meta text-[var(--status-warning)]/80",children:f}),e[6]=f,e[7]=g):g=e[7];let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx("code",{className:"typography-code block whitespace-pre-wrap break-all rounded bg-muted/50 px-2 py-1.5 text-xs text-foreground",children:M1}),e[8]=p):p=e[8];let h;return e[9]!==g?(h=s.jsxs("div",{className:"mt-1 space-y-1.5",children:[g,p]}),e[9]=g,e[10]=h):h=e[10],h}let d;return e[11]!==o.integration.id||e[12]!==m||e[13]!==a?(d=s.jsx(No,{integrationId:o.integration.id,methods:m,onConnected:a,className:"mt-3"},o.integration.id),e[11]=o.integration.id,e[12]=m,e[13]=a,e[14]=d):d=e[14],d};function R1(){const t=mu();return t?Vu(t.integrations):{state:"loading"}}function F1(t){return t.state==="loading"?{state:"ready",integration:void 0}:t}const id=(t,e)=>{if(!t)return"-";try{return Hd(t,e,{fallback:"-"})}catch{return"-"}},O1=()=>{const{t}=ze(),e=oe(E=>E.timeFormatPreference),a=rs(E=>E.results),n=rs(E=>E.selectedProviderId),o=rs(E=>E.setSelectedProvider),i=rs(E=>E.loadSettings),r=rs(E=>E.fetchAllQuotas),l=rs(E=>E.fetchProviderQuota),u=rs(E=>E.isLoading),m=rs(E=>E.lastUpdated),d=rs(E=>E.refreshErrors),f=rs(E=>E.dropdownProviderIds),g=rs(E=>E.setDropdownProviderIds),p=rs(E=>E.selectedModels),h=rs(E=>E.toggleModelSelected),w=rs(E=>E.applyDefaultSelections);dp(),c.useEffect(()=>{i(),r()},[i,r]),c.useEffect(()=>{if(n||a.length===0)return;const E=a.find(B=>B.configured)?.providerId;o(E??xo[0]?.id??null)},[a,n,o]);const b=a.find(E=>E.providerId===n)??null,v=xo.find(E=>E.id===n)?.name??n??t("settings.usage.sidebar.title"),S=b?.usage,y=n?d[n]:void 0,N=y?S?t("header.services.usageRefreshFailedStale",{error:y}):y:b?.configured&&!b.ok?b.error:null,x=n?f.includes(n):!1,I=n==="exe-dev"||n==="cursor"||n==="zenmux"?n:null,j=I!==null,D=c.useCallback(E=>{if(!n)return;const B=E?Array.from(new Set([...f,n])):f.filter(_=>_!==n);g(B),yt({usageDropdownProviders:B})},[f,n,g]),C=c.useMemo(()=>S?.models?Object.entries(S.models).map(([E,B])=>({name:E,windows:B})).filter(E=>Object.keys(E.windows.windows).length>0):[],[S?.models]);c.useEffect(()=>{n&&C.length>0&&w(n,C.map(E=>E.name))},[n,C,w]);const P=c.useMemo(()=>!n||C.length===0?new Map:up(C,E=>E.name,n),[C,n]),A=c.useMemo(()=>{if(!n)return[];const E=pp(n);return mp(E)},[n]),[R,K]=c.useState(()=>({})),F=c.useCallback(E=>{K(B=>({...B,[E]:!B[E]}))},[]),T=c.useCallback(E=>{if(!n)return;h(n,E);const B=p[n]??[],H=B.includes(E)?B.filter(z=>z!==E):[...B,E],ne={...p,[n]:H};yt({usageSelectedModels:ne})},[n,p,h]),O=n?p[n]??[]:[];return n?s.jsxs(Yt,{title:t("settings.usage.page.header.providerUsage",{provider:v}),titleLeading:s.jsx(an,{providerId:n,className:"h-5 w-5 shrink-0"}),description:u?s.jsx("span",{className:"animate-pulse typography-settings-description text-muted-foreground",children:t("settings.usage.page.header.refreshing")}):b?.planLabel?t("settings.usage.page.header.lastUpdatedWithPlan",{plan:b.planLabel,time:id(m,e)}):t("settings.usage.page.header.lastUpdated",{time:id(m,e)}),showSaveStatus:!0,children:[s.jsx(He,{divider:!1,settingsItem:"usage.work-status-panel",children:s.jsx(it,{checked:x,onChange:D,label:t("settings.usage.page.options.showInWorkStatus"),ariaLabel:t("settings.usage.page.options.showInWorkStatusAria"),info:t("settings.usage.page.options.showInWorkStatusTooltip")})}),!b&&s.jsx("p",{className:"typography-ui-label text-foreground pb-8",children:t("settings.usage.page.state.noData")}),N&&s.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:t("settings.usage.page.state.refreshFailedTitle")}),s.jsx("p",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:N})]}),b&&!b.configured&&!j&&s.jsx("div",{className:"mb-8 rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3",children:n==="claude"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-warning)]",children:t("settings.usage.page.state.claudeSignedOutTitle")}),s.jsx(D1,{onSignedIn:()=>{l("claude")}})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-warning)]",children:t("settings.usage.page.state.providerNotConfiguredTitle")}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]/80 mt-1",children:t("settings.usage.page.state.providerNotConfiguredDescription")})]})}),I&&s.jsx(T1,{providerId:I,providerName:v}),S?.windows&&Object.keys(S.windows).length>0&&s.jsx(He,{settingsItem:"usage.model-quotas",children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Object.entries(S.windows).map(([E,B])=>s.jsx(Ar,{title:E,window:B,providerId:n},E))})}),C.length>0&&s.jsxs(He,{title:t("settings.usage.page.section.modelQuotas"),contentClassName:"space-y-3",children:[A.map(E=>{const B=P.get(E.id)??[];if(B.length===0)return null;const _=R[E.id]??!1;return s.jsx("section",{className:"p-2",children:s.jsxs(Js,{open:!_,onOpenChange:()=>F(E.id),children:[s.jsxs(Qs,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-start",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:E.label}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",B.length,")"]})]}),_?s.jsx(J,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx(J,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(Ys,{children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:B.map(H=>{const ne=Object.entries(H.windows.windows);if(ne.length===0)return null;const[z,$]=ne[0],V=O.includes(H.name);return s.jsx(Ar,{title:z,subtitle:ql(H.name),window:$,showToggle:!0,toggleEnabled:V,onToggle:()=>T(H.name)},H.name)})})})]})},E.id)}),(()=>{const E=P.get(null)??[];if(E.length===0)return null;const B=R.other??!1;return s.jsx("section",{className:"p-2",children:s.jsxs(Js,{open:!B,onOpenChange:()=>F("other"),children:[s.jsxs(Qs,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-start",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:t("settings.usage.page.section.otherModels")}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",E.length,")"]})]}),B?s.jsx(J,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx(J,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(Ys,{children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:E.map(_=>{const H=Object.entries(_.windows.windows);if(H.length===0)return null;const[ne,z]=H[0],$=O.includes(_.name);return s.jsx(Ar,{title:ne,subtitle:ql(_.name),window:z,showToggle:!0,toggleEnabled:$,onToggle:()=>T(_.name)},_.name)})})})]})})})()]}),b?.configured&&S&&Object.keys(S.windows??{}).length===0&&C.length===0&&s.jsxs("div",{className:"pb-8",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:t("settings.usage.page.state.noQuotaWindowsTitle")}),s.jsx("p",{className:"typography-meta text-muted-foreground mt-1",children:t("settings.usage.page.state.noQuotaWindowsDescription")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:s.jsx("p",{className:"typography-body",children:t("settings.usage.page.empty.selectProvider")})})},L1="git.commit.generate",ol=uu(t=>({selectedPromptId:L1,setSelectedPromptId:e=>{t(a=>a.selectedPromptId===e?a:{selectedPromptId:e})}})),K1=t=>{const e=$e.c(23),{onItemSelect:a}=t,{t:n}=ze(),o=ol(z1),i=ol(U1);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={groupKey:"settings.magicPrompts.sidebar.group.git",items:[{id:"git.commit.generate",titleKey:"settings.magicPrompts.sidebar.item.gitCommitGenerate"},{id:"git.pr.generate",titleKey:"settings.magicPrompts.sidebar.item.gitPrGenerate"},{id:"git.conflict.resolve",titleKey:"settings.magicPrompts.sidebar.item.gitConflictResolve"},{id:"git.integrate.cherrypick.resolve",titleKey:"settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve"}]},e[0]=r):r=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l={groupKey:"settings.magicPrompts.sidebar.group.planning",items:[{id:"plan.todo",titleKey:"settings.magicPrompts.sidebar.item.planTodo"},{id:"plan.improve",titleKey:"settings.magicPrompts.sidebar.item.planImprove"},{id:"plan.implement",titleKey:"settings.magicPrompts.sidebar.item.planImplement"}]},e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u={groupKey:"settings.magicPrompts.sidebar.group.session",items:[{id:"session.explore",titleKey:"settings.magicPrompts.sidebar.item.sessionExplore"},{id:"session.summary",titleKey:"settings.magicPrompts.sidebar.item.sessionSummary"},{id:"session.review",titleKey:"settings.magicPrompts.sidebar.item.sessionWorkspaceReview"},{id:"session.plan",titleKey:"settings.magicPrompts.sidebar.item.sessionFeaturePlan"},{id:"session.craftGoal",titleKey:"settings.magicPrompts.sidebar.item.sessionCraftGoal"},{id:"session.catchup",titleKey:"settings.magicPrompts.sidebar.item.sessionCatchUp"},{id:"session.debug",titleKey:"settings.magicPrompts.sidebar.item.sessionDebug"},{id:"session.weigh",titleKey:"settings.magicPrompts.sidebar.item.sessionWeigh"},{id:"session.fusion",titleKey:"settings.magicPrompts.sidebar.item.sessionFusion"}]},e[2]=u):u=e[2];let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=[r,l,u,{groupKey:"settings.magicPrompts.sidebar.group.memory",items:[{id:"memory.tidy",titleKey:"settings.magicPrompts.sidebar.item.memoryTidy"}]}],e[3]=m):m=e[3];const d=m;let f;e[4]!==n?(f=n("settings.magicPrompts.sidebar.title"),e[4]=n,e[5]=f):f=e[5];let g;e[6]!==f?(g=s.jsx("h2",{className:On,children:f}),e[6]=f,e[7]=g):g=e[7];let p;e[8]!==n?(p=n("settings.magicPrompts.sidebar.description"),e[8]=n,e[9]=p):p=e[9];let h;e[10]!==p?(h=s.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:p}),e[10]=p,e[11]=h):h=e[11];let w;e[12]!==g||e[13]!==h?(w=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[g,h]}),e[12]=g,e[13]=h,e[14]=w):w=e[14];let b;e[15]!==a||e[16]!==o||e[17]!==i||e[18]!==n?(b=s.jsx(Ts,{outerClassName:"flex-1 min-h-0",className:"space-y-3 px-3 py-2 overflow-x-hidden",children:d.map(v=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro px-1 text-muted-foreground",children:n(v.groupKey)}),v.items.map(S=>{const y=o===S.id;return s.jsx("button",{type:"button",onClick:()=>{i(S.id),a?.()},className:Me("flex w-full items-center rounded-md px-2 py-1.5 text-start transition-colors",y?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:s.jsx("span",{className:"typography-ui-label truncate font-normal",children:n(S.titleKey)})},S.id)})]},v.groupKey))}),e[15]=a,e[16]=o,e[17]=i,e[18]=n,e[19]=b):b=e[19];let k;return e[20]!==b||e[21]!==w?(k=s.jsxs("div",{className:"flex h-full flex-col bg-background",children:[w,b]}),e[20]=b,e[21]=w,e[22]=k):k=e[22],k};function z1(t){return t.selectedPromptId}function U1(t){return t.setSelectedPromptId}const od={"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"}]},"git.conflict.resolve":{titleKey:"settings.magicPrompts.page.group.gitConflictResolve.title",descriptionKey:"settings.magicPrompts.page.group.gitConflictResolve.description",blocks:[{id:"git.conflict.resolve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.conflict.resolve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.integrate.cherrypick.resolve":{titleKey:"settings.magicPrompts.page.group.gitCherrypickConflictResolve.title",descriptionKey:"settings.magicPrompts.page.group.gitCherrypickConflictResolve.description",blocks:[{id:"git.integrate.cherrypick.resolve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.integrate.cherrypick.resolve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.improve":{titleKey:"settings.magicPrompts.page.group.planImprove.title",descriptionKey:"settings.magicPrompts.page.group.planImprove.description",blocks:[{id:"plan.improve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.improve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.todo":{titleKey:"settings.magicPrompts.page.group.planTodo.title",descriptionKey:"settings.magicPrompts.page.group.planTodo.description",blocks:[{id:"plan.todo.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.todo.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.implement":{titleKey:"settings.magicPrompts.page.group.planImplement.title",descriptionKey:"settings.magicPrompts.page.group.planImplement.description",blocks:[{id:"plan.implement.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.implement.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.summary":{titleKey:"settings.magicPrompts.page.group.sessionSummary.title",descriptionKey:"settings.magicPrompts.page.group.sessionSummary.description",blocks:[{id:"session.summary.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.summary.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.review":{titleKey:"settings.magicPrompts.page.group.sessionWorkspaceReview.title",descriptionKey:"settings.magicPrompts.page.group.sessionWorkspaceReview.description",blocks:[{id:"session.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.plan":{titleKey:"settings.magicPrompts.page.group.sessionFeaturePlan.title",descriptionKey:"settings.magicPrompts.page.group.sessionFeaturePlan.description",blocks:[{id:"session.plan.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.plan.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.craftGoal":{titleKey:"settings.magicPrompts.page.group.sessionCraftGoal.title",descriptionKey:"settings.magicPrompts.page.group.sessionCraftGoal.description",blocks:[{id:"session.craftGoal.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.craftGoal.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.catchup":{titleKey:"settings.magicPrompts.page.group.sessionCatchUp.title",descriptionKey:"settings.magicPrompts.page.group.sessionCatchUp.description",blocks:[{id:"session.catchup.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.catchup.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.debug":{titleKey:"settings.magicPrompts.page.group.sessionDebug.title",descriptionKey:"settings.magicPrompts.page.group.sessionDebug.description",blocks:[{id:"session.debug.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.debug.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.weigh":{titleKey:"settings.magicPrompts.page.group.sessionWeigh.title",descriptionKey:"settings.magicPrompts.page.group.sessionWeigh.description",blocks:[{id:"session.weigh.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.weigh.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.explore":{titleKey:"settings.magicPrompts.page.group.sessionExplore.title",descriptionKey:"settings.magicPrompts.page.group.sessionExplore.description",blocks:[{id:"session.explore.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.explore.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.fusion":{titleKey:"settings.magicPrompts.page.group.sessionFusion.title",descriptionKey:"settings.magicPrompts.page.group.sessionFusion.description",blocks:[{id:"session.fusion.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.fusion.instructions",titleKey:"settings.magicPrompts.page.block.instructions"},{id:"session.fusion.codeInstructions",titleKey:"settings.magicPrompts.page.block.codeFusionInstructions"}]},"memory.tidy":{titleKey:"settings.magicPrompts.page.group.memoryTidy.title",descriptionKey:"settings.magicPrompts.page.group.memoryTidy.description",blocks:[{id:"memory.tidy.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"memory.tidy.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]}},rd=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Tr=t=>t.endsWith(".visible"),$1=()=>{const{t}=ze(),e=c.useCallback(x=>t(x),[t]),a=ol(x=>x.selectedPromptId),[n,o]=c.useState(!0),[i,r]=c.useState({}),[l,u]=c.useState({}),[m,d]=c.useState({}),[f,g]=c.useState({}),[p,h]=c.useState(!1);c.useEffect(()=>{let x=!0;return(async()=>{o(!0);try{const j=await bp();if(!x)return;r(j)}catch(j){console.warn("Failed to load magic prompts:",j),W.error(t("settings.magicPrompts.page.toast.loadFailed"))}finally{x&&o(!1)}})(),()=>{x=!1}},[t]);const w=od[a]??od["git.commit.generate"],b=c.useCallback(x=>rd(i,x)?i[x]:mr(x),[i]),k=c.useCallback(x=>l[x]??b(x),[l,b]),v=c.useCallback((x,I)=>{u(j=>j[x]===I?j:{...j,[x]:I})},[]),S=c.useCallback(async x=>{const I=k(x);if(Tr(x)&&I.trim().length===0){W.error(t("settings.magicPrompts.page.toast.visiblePromptRequired"));return}d(j=>({...j,[x]:!0}));try{const j=I===mr(x)?await Wl(x):await gp(x,I);r(j.overrides),W.success(t("settings.magicPrompts.page.toast.saved"))}catch(j){const D=j instanceof Error?j.message:String(j);W.error(t("settings.magicPrompts.page.toast.saveFailed"),{description:D})}finally{d(j=>({...j,[x]:!1}))}},[k,t]),y=c.useCallback(async x=>{g(I=>({...I,[x]:!0}));try{const I=await Wl(x);r(I.overrides),u(j=>({...j,[x]:mr(x)})),W.success(t("settings.magicPrompts.page.toast.resetSuccess"))}catch(I){const j=I instanceof Error?I.message:String(I);W.error(t("settings.magicPrompts.page.toast.resetFailed"),{description:j})}finally{g(I=>({...I,[x]:!1}))}},[t]),N=c.useCallback(async()=>{h(!0);try{const x=await fp();r(x.overrides),u({}),W.success(t("settings.magicPrompts.page.toast.resetAllSuccess"))}catch(x){const I=x instanceof Error?x.message:String(x);W.error(t("settings.magicPrompts.page.toast.resetAllFailed"),{description:I})}finally{h(!1)}},[t]);return n?s.jsxs("div",{className:"py-6 px-6 flex items-center gap-2 text-muted-foreground",children:[s.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":t("settings.magicPrompts.page.loading.aria")}),s.jsx("span",{className:"typography-ui",children:t("settings.magicPrompts.page.loading.text")})]}):s.jsx(Yt,{title:e(w.titleKey),titleAccessory:s.jsx(qt,{contentClassName:"max-w-xs",children:e(w.descriptionKey)}),headerEnd:s.jsx(q,{"data-settings-item":"magic-prompts.reset-overrides",variant:"outline",size:"sm",onClick:()=>{N()},disabled:p||Object.keys(i).length===0,children:t(p?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetAllOverrides")}),showSaveStatus:!1,children:w.blocks.map((x,I)=>{const j=hp(x.id),D=b(x.id),C=k(x.id),P=rd(i,x.id),A=C!==D,R=Tr(x.id)&&C.trim().length===0,K=m[x.id]===!0,F=f[x.id]===!0;return s.jsxs(He,{title:e(x.titleKey),info:j.description,description:j.placeholders&&j.placeholders.length>0?`${t("settings.magicPrompts.page.placeholdersLabel")} ${j.placeholders.map(T=>`{{${T.key}}}`).join(", ")}`:void 0,divider:I>0,settingsItem:Tr(x.id)?"magic-prompts.visible-prompt":"magic-prompts.instructions",contentClassName:"space-y-3",children:[s.jsx(ws,{value:C,onChange:T=>v(x.id,T.target.value),className:"min-h-[220px] font-mono text-sm"}),R&&s.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:t("settings.magicPrompts.page.validation.visiblePromptRequired")}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:t(A?"settings.magicPrompts.page.status.unsavedChanges":P?"settings.magicPrompts.page.status.usingSavedOverride":"settings.magicPrompts.page.status.usingBuiltinDefault")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{variant:"outline",size:"sm",onClick:()=>{y(x.id)},disabled:!P||K||F,children:t(F?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetToDefault")}),s.jsx(q,{size:"sm",onClick:()=>{S(x.id)},disabled:!A||K||F||R,children:t(K?"settings.common.actions.saving":"settings.magicPrompts.page.actions.save")})]})]})]},x.id)})})},B1=t=>{const e=$e.c(89),{onItemSelect:a}=t,{t:n}=ze(),[o,i]=c.useState(null),[r,l]=c.useState(null),[u,m]=c.useState(null),{selectedSnippetName:d,snippets:f,setSelectedSnippet:g,setSnippetDraft:p,deleteSnippet:h,loadSnippets:w}=vo(Ms(_1));let b,k;e[0]!==w?(b=()=>{w()},k=[w],e[0]=w,e[1]=b,e[2]=k):(b=e[1],k=e[2]),c.useEffect(b,k);let v;e[3]!==a||e[4]!==g||e[5]!==p||e[6]!==f?(v=async()=>{const se=new Set(f.map(V1));let re="new-snippet",je=1;for(;se.has(re);)re=`new-snippet-${je++}`;p({name:re,scope:"global"}),g(re),a?.()},e[3]=a,e[4]=g,e[5]=p,e[6]=f,e[7]=v):v=e[7];const S=v;let y;e[8]!==o||e[9]!==h||e[10]!==n?(y=async()=>{if(!o)return;await h(o.name)?(W.success(n("settings.snippets.sidebar.toast.deleted")),i(null)):W.error(n("settings.snippets.sidebar.toast.deleteFailed"))},e[8]=o,e[9]=h,e[10]=n,e[11]=y):y=e[11];const N=y;let x;e[12]!==f?(x=[...f].sort(H1),e[12]=f,e[13]=x):x=e[13];const I=x;let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=Me("flex h-full flex-col","bg-background"),e[14]=j):j=e[14];let D;e[15]!==n?(D=n("settings.snippets.sidebar.title"),e[15]=n,e[16]=D):D=e[16];let C;e[17]!==D?(C=s.jsx("h2",{className:`${On} mb-3`,children:D}),e[17]=D,e[18]=C):C=e[18];let P;e[19]!==f.length||e[20]!==n?(P=n("settings.snippets.sidebar.total",{count:f.length}),e[19]=f.length,e[20]=n,e[21]=P):P=e[21];let A;e[22]!==P?(A=s.jsx("span",{className:"typography-meta text-muted-foreground",children:P}),e[22]=P,e[23]=A):A=e[23];let R;e[24]!==n?(R=n("settings.snippets.sidebar.actions.create"),e[24]=n,e[25]=R):R=e[25];let K;e[26]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),e[26]=K):K=e[26];let F;e[27]!==S||e[28]!==R?(F=s.jsx(q,{size:"sm","data-settings-item":"snippets.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:S,"aria-label":R,children:K}),e[27]=S,e[28]=R,e[29]=F):F=e[29];let T;e[30]!==A||e[31]!==F?(T=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A,F]}),e[30]=A,e[31]=F,e[32]=T):T=e[32];let O;e[33]!==T||e[34]!==C?(O=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[C,T]}),e[33]=T,e[34]=C,e[35]=O):O=e[35];let E;if(e[36]!==a||e[37]!==r||e[38]!==u||e[39]!==d||e[40]!==g||e[41]!==I||e[42]!==n){let se;e[44]!==a||e[45]!==r||e[46]!==u||e[47]!==d||e[48]!==g||e[49]!==n?(se=re=>s.jsxs(Di,{open:u===re.name,onOpenChange:je=>m(je?re.name:null),children:[s.jsxs(Mi,{render:s.jsx("div",{className:Me("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",d===re.name?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:je=>{je.preventDefault(),m(re.name)}}),children:[s.jsxs("button",{onClick:()=>{g(re.name),a?.()},className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["#",re.name]}),s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:n(`snippets.source.${re.source}`)})]}),s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:re.description||re.content.replace(/\s+/g," ").substring(0,80)})]}),s.jsxs(ga,{open:r===re.name,onOpenChange:je=>{je&&m(null),l(je?re.name:null)},children:[s.jsx(pa,{asChild:!0,children:s.jsx(q,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100","aria-label":n("settings.snippets.sidebar.actions.more",{name:re.name}),children:s.jsx(J,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(ma,{align:"end",className:"w-fit min-w-20",children:s.jsxs(Bn,{onClick:je=>{je.stopPropagation(),i(re)},className:"text-destructive focus:text-destructive",children:[s.jsx(J,{name:"delete-bin",className:"h-4 w-4 me-px"}),n("settings.common.actions.delete")]})})]})]}),s.jsx(Ti,{className:"w-fit min-w-20",children:s.jsxs(Ei,{onClick:je=>{je.stopPropagation(),i(re)},className:"text-destructive focus:text-destructive",children:[s.jsx(J,{name:"delete-bin",className:"h-4 w-4 me-px"}),n("settings.common.actions.delete")]})})]},`${re.source}:${re.filePath}`),e[44]=a,e[45]=r,e[46]=u,e[47]=d,e[48]=g,e[49]=n,e[50]=se):se=e[50],E=I.map(se),e[36]=a,e[37]=r,e[38]=u,e[39]=d,e[40]=g,e[41]=I,e[42]=n,e[43]=E}else E=e[43];let B;e[51]!==E?(B=s.jsx(Ts,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2",children:E}),e[51]=E,e[52]=B):B=e[52];const _=o!==null;let H;e[53]===Symbol.for("react.memo_cache_sentinel")?(H=se=>{se||i(null)},e[53]=H):H=e[53];let ne;e[54]!==n?(ne=n("settings.snippets.sidebar.dialog.deleteTitle"),e[54]=n,e[55]=ne):ne=e[55];let z;e[56]!==ne?(z=s.jsx(_t,{children:ne}),e[56]=ne,e[57]=z):z=e[57];const $=o?.name??"";let V;e[58]!==n||e[59]!==$?(V=n("settings.snippets.sidebar.dialog.deleteDescription",{name:$}),e[58]=n,e[59]=$,e[60]=V):V=e[60];let G;e[61]!==V?(G=s.jsx(Vt,{children:V}),e[61]=V,e[62]=G):G=e[62];let ee;e[63]!==z||e[64]!==G?(ee=s.jsxs(Bt,{children:[z,G]}),e[63]=z,e[64]=G,e[65]=ee):ee=e[65];let ae;e[66]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>i(null),e[66]=ae):ae=e[66];let X;e[67]!==n?(X=n("settings.common.actions.cancel"),e[67]=n,e[68]=X):X=e[68];let Q;e[69]!==X?(Q=s.jsx(q,{size:"sm",variant:"ghost",onClick:ae,children:X}),e[69]=X,e[70]=Q):Q=e[70];let le;e[71]!==n?(le=n("settings.common.actions.delete"),e[71]=n,e[72]=le):le=e[72];let Z;e[73]!==N||e[74]!==le?(Z=s.jsx(q,{size:"sm",onClick:N,children:le}),e[73]=N,e[74]=le,e[75]=Z):Z=e[75];let fe;e[76]!==Q||e[77]!==Z?(fe=s.jsxs(ts,{children:[Q,Z]}),e[76]=Q,e[77]=Z,e[78]=fe):fe=e[78];let Y;e[79]!==ee||e[80]!==fe?(Y=s.jsxs(zt,{className:"max-w-md",children:[ee,fe]}),e[79]=ee,e[80]=fe,e[81]=Y):Y=e[81];let be;e[82]!==_||e[83]!==Y?(be=s.jsx(Kt,{open:_,onOpenChange:H,children:Y}),e[82]=_,e[83]=Y,e[84]=be):be=e[84];let Ee;return e[85]!==O||e[86]!==B||e[87]!==be?(Ee=s.jsxs("div",{className:j,children:[O,B,be]}),e[85]=O,e[86]=B,e[87]=be,e[88]=Ee):Ee=e[88],Ee};function _1(t){return{selectedSnippetName:t.selectedSnippetName,snippets:t.snippets,setSelectedSnippet:t.setSelectedSnippet,setSnippetDraft:t.setSnippetDraft,deleteSnippet:t.deleteSnippet,loadSnippets:t.loadSnippets}}function V1(t){return t.name}function H1(t,e){return t.name.localeCompare(e.name)}const q1=()=>{const{t}=ze(),{selectedSnippetName:e,snippets:a,snippetDraft:n,setSnippetDraft:o,updateSnippet:i,createSnippet:r}=vo(Ms(j=>({selectedSnippetName:j.selectedSnippetName,snippets:j.snippets,snippetDraft:j.snippetDraft,setSnippetDraft:j.setSnippetDraft,updateSnippet:j.updateSnippet,createSnippet:j.createSnippet}))),l=c.useMemo(()=>e?a.find(j=>j.name===e||j.aliases.includes(e))??null:null,[e,a]),u=!!(n&&n.name===e&&!l),[m,d]=c.useState(""),[f,g]=c.useState("global"),[p,h]=c.useState(""),[w,b]=c.useState(""),[k,v]=c.useState(""),[S,y]=c.useState(!1),N=c.useRef(null);c.useEffect(()=>{if(u&&n){const j={draftName:n.name||"",draftScope:n.scope||"global",description:n.description||"",aliases:(n.aliases||[]).join(", "),content:n.content||""};d(j.draftName),g(j.draftScope),h(j.description),b(j.aliases),v(j.content),N.current=j}else if(l){const j={draftName:"",draftScope:"global",description:l.description??"",aliases:l.aliases.join(", "),content:l.content};h(j.description),b(j.aliases),v(j.content),N.current=j}},[l,u,e,n]);const x=c.useMemo(()=>{const j=N.current;return j?u&&m!==j.draftName||u&&f!==j.draftScope?!0:p!==j.description||w!==j.aliases||k!==j.content:!1},[w,k,p,m,f,u]),I=async()=>{const j=u?m.trim().replace(/\s+/g,"-"):e?.trim();if(!j){W.error(t("settings.snippets.page.toast.nameRequired"));return}if(!k.trim()){W.error(t("settings.snippets.page.toast.contentRequired"));return}const D=w.split(",").map(C=>C.trim()).filter(Boolean);y(!0);try{if(!(u?await r(j,k,{aliases:D,description:p,scope:f}):await i(j,{content:k,aliases:D,description:p}))){W.error(t("settings.snippets.page.toast.saveFailed"));return}W.success(t("settings.snippets.page.toast.saved")),u&&o(null)}finally{y(!1)}};return e?s.jsxs(Yt,{title:u?t("settings.snippets.page.title.new"):`#${e}`,description:l?l.filePath:void 0,showSaveStatus:!1,children:[s.jsxs(He,{divider:!1,contentClassName:"space-y-0",children:[u?s.jsxs(kt,{label:"#",children:[s.jsx(Ve,{value:m,onChange:j=>d(j.target.value),placeholder:t("settings.snippets.page.field.namePlaceholder"),className:"h-7 w-44 px-2"}),s.jsxs(Tt,{value:f,onValueChange:j=>g(j),children:[s.jsx(Pt,{className:"w-fit min-w-[100px]",children:s.jsx(Ut,{})}),s.jsxs(At,{align:"end",children:[s.jsx(ot,{value:"global",children:t("settings.common.scope.global")}),s.jsx(ot,{value:"project",children:t("settings.common.scope.project")})]})]})]}):null,s.jsx(Mt,{label:t("settings.common.field.description"),children:s.jsx(Ve,{value:p,onChange:j=>h(j.target.value),placeholder:t("settings.snippets.page.field.descriptionPlaceholder"),className:"h-7 w-full max-w-sm px-2"})}),s.jsx(Mt,{label:t("settings.snippets.page.field.aliases"),children:s.jsx(Ve,{value:w,onChange:j=>b(j.target.value),placeholder:t("settings.snippets.page.field.aliasesPlaceholder"),className:"h-7 w-full max-w-sm px-2"})})]}),s.jsxs(He,{settingsItem:"snippets.content",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.snippets.page.field.content")}),s.jsx(qt,{children:t("settings.snippets.page.hint")})]}),s.jsx(ws,{value:k,onChange:j=>v(j.target.value),placeholder:t("settings.snippets.page.field.contentPlaceholder"),rows:12,className:"mt-1.5 w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),s.jsx("div",{className:"pt-3",children:s.jsx(q,{onClick:I,disabled:S||!x,size:"xs",className:"!font-normal",children:t(S?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(J,{name:"file-text",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.snippets.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.snippets.page.empty.description")})]})})},Hu=()=>{const{t}=ze(),e=rt(f=>f.settingsGitmojiEnabled),a=rt(f=>f.setSettingsGitmojiEnabled),n=Rg(),o=oe(f=>f.gitChangesViewMode),i=oe(f=>f.setGitChangesViewMode),[r,l]=c.useState(!0),u=c.useMemo(()=>[{id:"flat",label:t("settings.openchamber.git.option.flatList")},{id:"tree",label:t("settings.openchamber.git.option.treeView")}],[t]);c.useEffect(()=>{(async()=>{try{const g=await xn();g&&(g.gitmojiEnabled!==void 0&&a(g.gitmojiEnabled),g.gitChangesViewMode!==void 0&&i(g.gitChangesViewMode))}catch(g){console.warn("Failed to load git settings:",g)}finally{l(!1)}})()},[i,a]);const m=c.useCallback(async f=>{a(f);try{await yt({gitmojiEnabled:f})}catch(g){console.warn("Failed to save gitmoji setting:",g)}},[a]),d=c.useCallback(f=>{f!==o&&(i(f),yt({gitChangesViewMode:f}))},[o,i]);return r?null:s.jsx(He,{title:t("settings.openchamber.git.title"),children:s.jsxs("div",{className:bs,children:[s.jsx(hs,{settingsItem:"git.changes-view",title:t("settings.openchamber.git.changesViewTitle"),children:s.jsx(Os,{"aria-label":t("settings.openchamber.git.changesViewAria"),children:u.map(f=>s.jsx(ns,{selected:o===f.id,onSelect:()=>{d(f.id)},label:f.label,ariaLabel:t("settings.openchamber.git.optionAria",{option:f.label})},f.id))})}),s.jsx(it,{settingsItem:"git.gitmoji",checked:e,onChange:f=>{m(f)},label:t("settings.openchamber.git.enableGitmoji"),ariaLabel:t("settings.openchamber.git.enableGitmojiAria")}),s.jsx(it,{settingsItem:"git.gitignored-files",checked:n,onChange:Fg,label:t("settings.openchamber.git.showGitignored"),ariaLabel:t("settings.openchamber.git.showGitignoredAria")})]})})},Er=()=>({status:"idle",credentials:[],candidates:[],truncated:!1,discoveryAttempted:!1});function W1({selection:t,disabled:e=!1}){const{t:a}=ze(),{git:n}=Ja(),[o,i]=c.useState(Er),[r,l]=c.useState(!1),[u,m]=c.useState(""),d=c.useRef(0),f=t?.onChange;c.useLayoutEffect(()=>{const x=()=>{d.current+=1,i(Er()),l(!1),m("")};x();const I=Sl(()=>{x(),f?.("")});return()=>{d.current+=1,I()}},[n,f]);const g=async x=>{if(!n.managedSshCredentials||e||o.status==="loading")return;const I=++d.current,j=Qt();i(D=>({...D,status:"loading",rejection:void 0,imported:!1}));try{const D=await n.managedSshCredentials(x);if(I!==d.current||j!==Qt())return;if(D.status==="unsupported"){l(!0),i(Er());return}if(l(!1),D.status==="available"){t?.value&&!D.credentials.some(P=>P.credentialId===t.value&&P.capability.status==="ready")&&t.onChange(""),m(""),i({status:"ready",credentials:D.credentials,candidates:[],truncated:!1,discoveryAttempted:!1});return}if(D.status==="discovered"){m(""),i(P=>({...P,status:"ready",candidates:D.candidates,truncated:D.truncated,discoveryAttempted:!0}));return}if(D.status==="rejected"){m(""),i(P=>({...P,status:"ready",rejection:D.reason}));return}m(""),t?.onChange(D.selectedCredential.credentialId);const C=x.operation==="import"?x.candidateId:"";i(P=>({...P,status:"ready",credentials:D.credentials,candidates:P.candidates.filter(A=>!("candidateId"in A)||A.candidateId!==C),truncated:!1,discoveryAttempted:!1,imported:!0}))}catch{I===d.current&&j===Qt()&&i(D=>({...D,status:"error",imported:!1}))}},p=c.useRef(g);p.current=g,c.useEffect(()=>{p.current({operation:"inventory"})},[n]);const h=x=>x.capability.status==="ready"?"":x.capability.reason==="unreadable"?a("settings.sourceControl.ssh.unreadable"):x.capability.reason==="fingerprint-mismatch"?a("settings.sourceControl.ssh.changed"):a("settings.sourceControl.ssh.unverifiable"),w=x=>x.capability.status==="ready"?"":x.capability.reason==="unreadable"?a("settings.sourceControl.ssh.unreadable"):x.capability.reason==="insecure-permissions"?a("settings.sourceControl.ssh.insecurePermissions"):a("settings.sourceControl.ssh.unverifiable"),b=()=>o.rejection?o.rejection==="candidate-expired"?a("settings.sourceControl.ssh.candidateExpired"):o.rejection==="candidate-changed"?a("settings.sourceControl.ssh.candidateChanged"):o.rejection==="fingerprint-mismatch"?a("settings.sourceControl.ssh.confirmationMismatch"):o.rejection==="inventory-full"?a("settings.sourceControl.ssh.inventoryFull"):a("settings.sourceControl.ssh.candidateUnavailable"):"",k=x=>[x.label,x.fingerprint,h(x)].filter(Boolean).join(" · "),v=o.credentials.find(x=>x.credentialId===t.value)??null,S=b(),y=e||o.status==="loading"||!n.managedSshCredentials,N=s.jsxs(s.Fragment,{children:[s.jsxs(Tt,{value:t.value,onValueChange:t.onChange,disabled:e||o.status!=="ready",children:[s.jsx(Pt,{className:"w-full","aria-label":a("settings.sourceControl.ssh.title"),children:s.jsx(Ut,{placeholder:a("settings.sourceControl.ssh.title"),children:v?k(v):void 0})}),s.jsx(At,{children:o.credentials.map(x=>s.jsx(ot,{value:x.credentialId,disabled:x.capability.status!=="ready",children:k(x)},x.credentialId))})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.status==="idle"||o.status==="error"?s.jsx(q,{size:"sm",variant:"outline",disabled:y,onClick:()=>{g({operation:"inventory"})},children:a("settings.sourceControl.ssh.load")}):null,s.jsx(q,{size:"sm",variant:"outline",disabled:y,onClick:()=>{g({operation:"discover"})},children:a("settings.sourceControl.ssh.discover")})]}),o.candidates.length?s.jsx("div",{className:"space-y-4",children:o.candidates.map((x,I)=>"candidateId"in x?s.jsxs("div",{className:"space-y-2 border-t border-border/60 pt-3",children:[s.jsx("p",{className:"typography-settings-field-label text-foreground",children:x.label}),s.jsx("p",{className:Me(Dt,"break-all"),children:x.fingerprint}),s.jsx(it,{checked:u===x.candidateId,onChange:j=>m(j?x.candidateId:""),disabled:e||o.status==="loading",className:"min-w-0 break-all",label:a("settings.sourceControl.ssh.confirmFingerprint",{fingerprint:x.fingerprint}),ariaLabel:a("settings.sourceControl.ssh.confirmFingerprint",{fingerprint:x.fingerprint})}),s.jsx(q,{size:"sm",variant:"default",disabled:e||o.status==="loading"||u!==x.candidateId,onClick:()=>{g({operation:"import",candidateId:x.candidateId,expectedFingerprint:x.fingerprint,confirmed:!0})},children:a("settings.sourceControl.ssh.import")})]},x.candidateId):s.jsx("p",{className:Dt,children:[x.label,w(x)].filter(Boolean).join(" · ")},`${x.label}-${I}`))}):null,o.status==="loading"?s.jsx("p",{role:"status",className:Dt,children:a("settings.sourceControl.transport.loading")}):null,o.status==="error"?s.jsx("p",{role:"alert",className:Me(Dt,"text-[var(--status-error)]"),children:a("settings.sourceControl.ssh.operationFailed")}):null,S?s.jsx("p",{role:"alert",className:Me(Dt,"text-[var(--status-error)]"),children:S}):null,o.imported?s.jsx("p",{role:"status",className:Me(Dt,"text-[var(--status-success)]"),children:a("settings.sourceControl.ssh.imported")}):null,o.status==="ready"&&!o.credentials.length?s.jsx("p",{className:Dt,children:a("settings.sourceControl.ssh.empty")}):null,o.status==="ready"&&o.discoveryAttempted&&!o.candidates.length?s.jsx("p",{className:Dt,children:a("settings.sourceControl.ssh.discoveredEmpty")}):null,o.truncated?s.jsx("p",{role:"status",className:Me(Dt,"text-[var(--status-warning)]"),children:a("settings.sourceControl.ssh.discoveryTruncated")}):null,r||!n.managedSshCredentials?s.jsx("p",{role:"status",className:Dt,children:a("settings.sourceControl.ssh.hostSetup")}):null]});return s.jsx(Mt,{className:"min-w-0 w-full",controlClassName:"max-w-none flex-col items-stretch gap-3",label:a("settings.sourceControl.ssh.title"),info:a("settings.sourceControl.ssh.hostSetup"),children:N})}const no="__none__",ld=t=>JSON.stringify([t.provider,t.instance,t.accountId]),cd=[{method:"system",icon:"computer",labelKey:"settings.gitIdentities.editor.auth.system",hintKey:"settings.gitIdentities.editor.auth.systemHint"},{method:"account",icon:"user-3",labelKey:"settings.gitIdentities.editor.auth.account",hintKey:"settings.gitIdentities.editor.auth.accountHint"},{method:"ssh",icon:"lock",labelKey:"settings.gitIdentities.editor.auth.ssh",hintKey:null},{method:"anonymous",icon:"global",labelKey:"settings.gitIdentities.editor.auth.anonymous",hintKey:"settings.gitIdentities.editor.auth.anonymousHint"}],dd=[{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)"}],G1=[{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"},{key:"github",Icon:"github",label:"GitHub"},{key:"gitlab",Icon:"gitlab",label:"GitLab"}],J1=({open:t,onOpenChange:e,profileId:a})=>{const{t:n}=ze(),o=aa(Y=>Y.getProfileById),i=aa(Y=>Y.createProfile),r=aa(Y=>Y.updateProfile),l=aa(Y=>Y.deleteProfile),u=c.useMemo(()=>a&&a!=="new"?o(a):null,[a,o]),m=a==="new",d=a==="global",[f,g]=c.useState(""),[p,h]=c.useState(""),[w,b]=c.useState(""),[k,v]=c.useState(!1),[S,y]=c.useState(""),[N,x]=c.useState("keyword"),[I,j]=c.useState("branch"),[D,C]=c.useState(no),[P,A]=c.useState("system"),[R,K]=c.useState(""),[F,T]=c.useState(!1),[O,E]=c.useState(!1),[B,_]=c.useState(!1),{sourceControl:H}=Ja(),ne=zs(Y=>Y.identities),z=zs(Y=>Y.entries),$=zs(Y=>Y.refreshAll);c.useEffect(()=>{t&&!d&&$(H)},[t,d,$,H]);const V=c.useMemo(()=>ne.flatMap(Y=>{const be=z[vl(Y)];return!be?.hasChecked||be.status?.status!=="connected"?[]:xp(Y,be.status.accounts,Ee=>n(qd(Ee.source)))}),[z,ne,n]),G=V.find(Y=>Y.key===D)??null,ee=u?.account&&D===ld(u.account)?u.account:null,ae=G?.reference??ee,X=P;c.useEffect(()=>{if(t){if(m)g(""),h(""),b(""),v(!1),y(""),x("keyword"),j("branch"),C(no),A("system"),K("");else if(u)g(u.name),h(u.userName),b(u.userEmail),v(u.signCommits===!0),y(u.signingKey||""),x(u.color||"keyword"),j(u.icon||"branch"),C(u.account?ld(u.account):no),A(u.transport??"system"),K(u.sshCredentialId??"");else if(d){const Y=o("global");Y&&(g(Y.name),h(Y.userName),b(Y.userEmail),v(!1),y(""),x(Y.color||"keyword"),j(Y.icon||"branch"))}}},[t,a,u,m,d,o]);const Q=async()=>{if(!p.trim()||!w.trim()){W.error(n("settings.gitIdentities.editor.toast.userNameEmailRequired"));return}if(k&&!S.trim()){W.error(n("settings.gitIdentities.editor.toast.signingKeyRequired"));return}if(X==="account"&&!ae){W.error(n("settings.gitIdentities.editor.toast.accountRequired"));return}if(X==="ssh"&&!R.trim()){W.error(n("settings.gitIdentities.editor.toast.sshKeyRequired"));return}T(!0);try{const Y={name:f.trim()||p.trim(),userName:p.trim(),userEmail:w.trim(),account:ae,transport:X,signCommits:k,signingKey:S.trim()||null,color:N,icon:I};X==="ssh"&&(Y.sshCredentialId=R.trim());let be;if(m)be=await i(Y);else if(a)be=await r(a,Y);else return;be?(W.success(n(m?"settings.gitIdentities.editor.toast.profileCreated":"settings.gitIdentities.editor.toast.profileUpdated")),e(!1)):W.error(n(m?"settings.gitIdentities.editor.toast.createProfileFailed":"settings.gitIdentities.editor.toast.updateProfileFailed"))}catch(Y){console.error("Error saving profile:",Y),W.error(n("settings.gitIdentities.editor.toast.saveUnexpectedError"))}finally{T(!1)}},le=async()=>{if(!(!a||m)){_(!0);try{await l(a)?(W.success(n("settings.gitIdentities.editor.toast.profileDeleted")),E(!1),e(!1)):W.error(n("settings.gitIdentities.editor.toast.deleteProfileFailed"))}catch(Y){console.error("Error deleting profile:",Y),W.error(n("settings.gitIdentities.editor.toast.deleteUnexpectedError"))}finally{_(!1)}}},Z=c.useMemo(()=>dd.find(be=>be.key===N)?.cssVar||"var(--syntax-keyword)",[N]),fe=m?n("settings.gitIdentities.editor.title.newIdentity"):d?n("settings.gitIdentities.editor.title.globalIdentity"):u?.name||n("settings.gitIdentities.editor.title.editIdentity");return s.jsxs(s.Fragment,{children:[s.jsx(Kt,{open:t,onOpenChange:e,children:s.jsxs(zt,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:fe}),s.jsx(Vt,{children:n(d?"settings.gitIdentities.editor.description.globalReadOnly":m?"settings.gitIdentities.editor.description.newProfile":"settings.gitIdentities.editor.description.editProfile")})]}),s.jsxs("div",{className:"space-y-5 py-2",children:[!d&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:`${Ct} block mb-1.5`,children:n("settings.gitIdentities.editor.field.profileName")}),s.jsx(Ve,{value:f,onChange:Y=>g(Y.target.value),placeholder:n("settings.gitIdentities.editor.field.profileNamePlaceholder"),className:"h-8"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:n("settings.gitIdentities.editor.field.color")}),s.jsx("div",{className:"flex gap-1.5",children:dd.map(Y=>s.jsx("button",{type:"button",onClick:()=>x(Y.key),className:Me("w-6 h-6 rounded-md border-2 transition-all cursor-pointer",N===Y.key?"border-foreground scale-110":"border-transparent hover:border-border"),style:{backgroundColor:Y.cssVar},title:Y.label},Y.key))})]}),s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:n("settings.gitIdentities.editor.field.icon")}),s.jsx("div",{className:"flex gap-1.5",children:G1.map(Y=>{const be=Y.Icon;return s.jsx("button",{type:"button",onClick:()=>j(Y.key),className:Me("w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer",I===Y.key?"border-[var(--interactive-border)] bg-[var(--surface-muted)]":"border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50"),title:Y.label,children:s.jsx(J,{name:be,className:"w-3.5 h-3.5",style:{color:I===Y.key?Z:"var(--surface-muted-foreground)"}})},Y.key)})})]})]}),!d&&s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Ct,children:n("settings.gitIdentities.editor.field.userName")}),!d&&s.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),s.jsx(qt,{contentClassName:"max-w-xs",children:n("settings.gitIdentities.editor.field.userNameTooltip")})]}),s.jsx(Ve,{value:p,onChange:Y=>h(Y.target.value),placeholder:n("settings.gitIdentities.editor.field.userNamePlaceholder"),required:!d,readOnly:d,disabled:d,className:"h-8"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Ct,children:n("settings.gitIdentities.editor.field.emailAddress")}),!d&&s.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),s.jsx(qt,{contentClassName:"max-w-xs",children:n("settings.gitIdentities.editor.field.emailAddressTooltip")})]}),s.jsx(Ve,{type:"email",value:w,onChange:Y=>b(Y.target.value),placeholder:n("settings.gitIdentities.editor.field.emailAddressPlaceholder"),required:!d,readOnly:d,disabled:d,className:"h-8"})]})]}),!d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:`${Ct} block mb-1.5`,children:n("settings.gitIdentities.editor.field.account")}),s.jsxs(Tt,{value:D,onValueChange:C,children:[s.jsx(Pt,{className:"w-full","aria-label":n("settings.gitIdentities.editor.field.account"),children:s.jsx(Ut,{children:G?.label??ee?.instance??n("settings.gitIdentities.editor.field.accountNone")})}),s.jsxs(At,{children:[V.map(Y=>s.jsx(ot,{value:Y.key,children:Y.label},Y.key)),s.jsx(ot,{value:no,children:n("settings.gitIdentities.editor.field.accountNone")})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:`${Ct} block mb-1.5`,children:n("settings.gitIdentities.editor.auth.label")}),s.jsx("div",{className:"flex flex-wrap items-center gap-1",children:cd.map(Y=>s.jsxs(q,{size:"sm",type:"button",variant:"chip","aria-pressed":P===Y.method,onClick:()=>{A(Y.method),Y.method!=="ssh"&&K("")},children:[s.jsx(J,{name:Y.icon,className:"w-3.5 h-3.5 me-1"})," ",n(Y.labelKey)]},Y.method))})]}),X==="ssh"?s.jsx(W1,{selection:{value:R,onChange:K}}):s.jsx("p",{className:Dt,children:n(cd.find(Y=>Y.method===P)?.hintKey??"settings.gitIdentities.editor.auth.systemHint")})]})]}),!d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"space-y-3",children:[s.jsx(it,{checked:k,onChange:v,label:n("settings.gitIdentities.editor.field.signCommits"),info:n("settings.gitIdentities.editor.section.commitSigning"),ariaLabel:n("settings.gitIdentities.editor.field.signCommits")}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:s.jsx("label",{className:Ct,children:n("settings.gitIdentities.editor.field.signingKey")})}),s.jsx(Ve,{value:S,onChange:Y=>y(Y.target.value),placeholder:n("settings.gitIdentities.editor.field.signingKeyPlaceholder"),disabled:!k,className:"h-8 font-mono text-xs"})]})]})]})]}),s.jsxs(ts,{className:"gap-2",children:[!d&&!m&&s.jsxs(q,{variant:"outline",size:"sm",onClick:()=>E(!0),className:"text-[var(--status-error)] hover:text-[var(--status-error)] border-[var(--status-error)]/30 hover:bg-[var(--status-error)]/10 me-auto",children:[s.jsx(J,{name:"delete-bin",className:"w-3.5 h-3.5 me-1"})," ",n("settings.common.actions.delete")]}),s.jsx(q,{variant:"ghost",size:"sm",onClick:()=>e(!1),className:"text-foreground hover:bg-interactive-hover hover:text-foreground",children:n(d?"settings.gitIdentities.editor.actions.close":"settings.common.actions.cancel")}),!d&&s.jsx(q,{size:"sm",onClick:Q,disabled:F,children:n(F?"settings.common.actions.saving":m?"settings.gitIdentities.editor.actions.create":"settings.gitIdentities.editor.actions.save")})]})]})}),s.jsx(Kt,{open:O,onOpenChange:Y=>{B||E(Y)},children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:n("settings.gitIdentities.page.deleteDialog.title")}),s.jsx(Vt,{children:n("settings.gitIdentities.page.deleteDialog.description",{name:u?.name||f})})]}),s.jsxs(ts,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>E(!1),disabled:B,children:n("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",variant:"destructive",onClick:()=>{le()},disabled:B,children:n("settings.common.actions.delete")})]})]})})]})},Q1={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",github:"github",gitlab:"gitlab"},Y1={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)"},Z1=()=>{const t=$e.c(103),{t:e}=ze(),{sourceControl:a}=Ja(),n=zs(X1),{profiles:o,globalIdentity:i,defaultGitIdentityId:r,deleteProfile:l,loadProfiles:u,loadGlobalIdentity:m,loadDefaultGitIdentityId:d,setDefaultGitIdentityId:f}=aa(Ms(ej));let g,p;t[0]!==o||t[1]!==n||t[2]!==a?(g=()=>{n(a,o.map(tj))},p=[n,a,o],t[0]=o,t[1]=n,t[2]=a,t[3]=g,t[4]=p):(g=t[3],p=t[4]),c.useEffect(g,p);const[h,w]=c.useState(!1),[b,k]=c.useState(null),[v,S]=c.useState(null),[y,N]=c.useState(!1);let x,I;t[5]!==d||t[6]!==m||t[7]!==u?(x=()=>{u(),m(),d()},I=[u,m,d],t[5]=d,t[6]=m,t[7]=u,t[8]=x,t[9]=I):(x=t[8],I=t[9]),c.useEffect(x,I);let j;t[10]===Symbol.for("react.memo_cache_sentinel")?(j=ge=>{k(ge),w(!0)},t[10]=j):j=t[10];const D=j;let C;t[11]!==r||t[12]!==f||t[13]!==e?(C=async ge=>{const Re=r===ge?null:ge;if(!await f(Re)){W.error(e("settings.gitIdentities.page.toast.updateDefaultFailed"));return}W.success(e(Re?"settings.gitIdentities.page.toast.defaultUpdated":"settings.gitIdentities.page.toast.defaultUnset"))},t[11]=r,t[12]=f,t[13]=e,t[14]=C):C=t[14];const P=C;let A;t[15]!==v||t[16]!==l||t[17]!==e?(A=async()=>{if(!v)return;N(!0),await l(v.id)?(W.success(e("settings.gitIdentities.page.toast.profileDeleted",{name:v.name})),S(null)):W.error(e("settings.gitIdentities.page.toast.deleteProfileFailed")),N(!1)},t[15]=v,t[16]=l,t[17]=e,t[18]=A):A=t[18];const R=A;let K;t[19]!==e?(K=e("settings.page.git.title"),t[19]=e,t[20]=K):K=t[20];let F;t[21]!==e?(F=e("settings.gitIdentities.page.section.title"),t[21]=e,t[22]=F):F=t[22];let T,O;t[23]===Symbol.for("react.memo_cache_sentinel")?(O=()=>D("new"),T=s.jsx(J,{name:"add",className:"w-3.5 h-3.5 me-1"}),t[23]=T,t[24]=O):(T=t[23],O=t[24]);let E;t[25]!==e?(E=e("settings.common.badge.new"),t[25]=e,t[26]=E):E=t[26];let B;t[27]!==E?(B=s.jsxs(q,{size:"sm",variant:"outline",onClick:O,children:[T," ",E]}),t[27]=E,t[28]=B):B=t[28];let _;t[29]!==r||t[30]!==i||t[31]!==P||t[32]!==o.length?(_=i&&s.jsx(ud,{profile:i,isDefault:r==="global",onEdit:()=>D("global"),onToggleDefault:()=>P("global"),isReadOnly:!0,hasBorder:o.length>0}),t[29]=r,t[30]=i,t[31]=P,t[32]=o.length,t[33]=_):_=t[33];let H;if(t[34]!==r||t[35]!==P||t[36]!==o){let ge;t[38]!==r||t[39]!==P||t[40]!==o.length?(ge=(Re,Oe)=>s.jsx(ud,{profile:Re,isDefault:r===Re.id,onEdit:()=>D(Re.id),onToggleDefault:()=>P(Re.id),onDelete:()=>S(Re),hasBorder:Oe<o.length-1},Re.id),t[38]=r,t[39]=P,t[40]=o.length,t[41]=ge):ge=t[41],H=o.map(ge),t[34]=r,t[35]=P,t[36]=o,t[37]=H}else H=t[37];let ne;t[42]!==i||t[43]!==o.length||t[44]!==e?(ne=!i&&o.length===0&&s.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground",children:[s.jsx(J,{name:"shield-keyhole",className:"mx-auto mb-2 h-8 w-8 opacity-40"}),s.jsx("p",{className:"typography-ui-label",children:e("settings.gitIdentities.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.gitIdentities.page.empty.description")})]}),t[42]=i,t[43]=o.length,t[44]=e,t[45]=ne):ne=t[45];let z;t[46]!==_||t[47]!==H||t[48]!==ne?(z=s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[_,H,ne]}),t[46]=_,t[47]=H,t[48]=ne,t[49]=z):z=t[49];let $;t[50]!==B||t[51]!==z||t[52]!==F?($=s.jsx(He,{title:F,headerAction:B,settingsItem:"git.identities",children:z}),t[50]=B,t[51]=z,t[52]=F,t[53]=$):$=t[53];let V;t[54]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Hu,{}),t[54]=V):V=t[54];let G;t[55]!==$||t[56]!==K?(G=s.jsxs(Yt,{title:K,showSaveStatus:!0,className:"px-4 @xl:px-6 @3xl:px-12",children:[$,V]}),t[55]=$,t[56]=K,t[57]=G):G=t[57];let ee;t[58]!==h||t[59]!==b?(ee=s.jsx(J1,{open:h,onOpenChange:w,profileId:b}),t[58]=h,t[59]=b,t[60]=ee):ee=t[60];const ae=v!==null;let X;t[61]!==y?(X=ge=>{!ge&&!y&&S(null)},t[61]=y,t[62]=X):X=t[62];let Q;t[63]!==e?(Q=e("settings.gitIdentities.page.deleteDialog.title"),t[63]=e,t[64]=Q):Q=t[64];let le;t[65]!==Q?(le=s.jsx(_t,{children:Q}),t[65]=Q,t[66]=le):le=t[66];const Z=v?.name??"";let fe;t[67]!==e||t[68]!==Z?(fe=e("settings.gitIdentities.page.deleteDialog.description",{name:Z}),t[67]=e,t[68]=Z,t[69]=fe):fe=t[69];let Y;t[70]!==fe?(Y=s.jsx(Vt,{children:fe}),t[70]=fe,t[71]=Y):Y=t[71];let be;t[72]!==le||t[73]!==Y?(be=s.jsxs(Bt,{children:[le,Y]}),t[72]=le,t[73]=Y,t[74]=be):be=t[74];let Ee;t[75]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>S(null),t[75]=Ee):Ee=t[75];let se;t[76]!==e?(se=e("settings.common.actions.cancel"),t[76]=e,t[77]=se):se=t[77];let re;t[78]!==y||t[79]!==se?(re=s.jsx(q,{size:"sm",variant:"ghost",onClick:Ee,disabled:y,children:se}),t[78]=y,t[79]=se,t[80]=re):re=t[80];let je;t[81]!==R?(je=()=>{R()},t[81]=R,t[82]=je):je=t[82];let ie;t[83]!==e?(ie=e("settings.common.actions.delete"),t[83]=e,t[84]=ie):ie=t[84];let Pe;t[85]!==y||t[86]!==je||t[87]!==ie?(Pe=s.jsx(q,{size:"sm",variant:"destructive",onClick:je,disabled:y,children:ie}),t[85]=y,t[86]=je,t[87]=ie,t[88]=Pe):Pe=t[88];let ke;t[89]!==re||t[90]!==Pe?(ke=s.jsxs(ts,{children:[re,Pe]}),t[89]=re,t[90]=Pe,t[91]=ke):ke=t[91];let Ae;t[92]!==be||t[93]!==ke?(Ae=s.jsxs(zt,{className:"max-w-md",children:[be,ke]}),t[92]=be,t[93]=ke,t[94]=Ae):Ae=t[94];let Te;t[95]!==ae||t[96]!==X||t[97]!==Ae?(Te=s.jsx(Kt,{open:ae,onOpenChange:X,children:Ae}),t[95]=ae,t[96]=X,t[97]=Ae,t[98]=Te):Te=t[98];let Ke;return t[99]!==G||t[100]!==ee||t[101]!==Te?(Ke=s.jsxs(s.Fragment,{children:[G,ee,Te]}),t[99]=G,t[100]=ee,t[101]=Te,t[102]=Ke):Ke=t[102],Ke},ud=t=>{const e=$e.c(58),{profile:a,isDefault:n,onEdit:o,onToggleDefault:i,onDelete:r,isReadOnly:l,hasBorder:u}=t,{t:m}=ze(),d=vp(),[f,g]=c.useState(!1),p=Q1[a.icon||"branch"]||"git-branch",h=Og(a)?yp(a,d)?null:"settings.gitIdentities.page.accountGone":"settings.gitIdentities.page.incomplete",w=h!==null,b=Y1[a.color||""];let k;e[0]!==o?(k=$=>{$.currentTarget===$.target&&($.key!=="Enter"&&$.key!==" "||($.preventDefault(),o()))},e[0]=o,e[1]=k):k=e[1];const v=k;let S;e[2]!==n||e[3]!==l||e[4]!==r||e[5]!==i||e[6]!==m?(S=$=>s.jsxs(s.Fragment,{children:[s.jsx($,{onClick:V=>{V.stopPropagation(),i()},children:m(n?"settings.gitIdentities.page.actions.unsetDefault":"settings.gitIdentities.page.actions.setAsDefault")}),!l&&r&&s.jsxs($,{onClick:V=>{V.stopPropagation(),r()},className:"text-destructive focus:text-destructive",children:[s.jsx(J,{name:"delete-bin",className:"h-4 w-4 me-px"}),m("settings.common.actions.delete")]})]}),e[2]=n,e[3]=l,e[4]=r,e[5]=i,e[6]=m,e[7]=S):S=e[7];const y=S,N=u&&"border-b border-[var(--surface-subtle)]";let x;e[8]!==N?(x=Me("group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer",N),e[8]=N,e[9]=x):x=e[9];let I;e[10]===Symbol.for("react.memo_cache_sentinel")?(I=$=>{$.preventDefault(),g(!0)},e[10]=I):I=e[10];let j;e[11]!==v||e[12]!==o||e[13]!==x?(j=s.jsx("div",{className:x,onClick:o,role:"button",tabIndex:0,onKeyDown:v,onContextMenu:I}),e[11]=v,e[12]=o,e[13]=x,e[14]=j):j=e[14];let D;e[15]!==b?(D={color:b},e[15]=b,e[16]=D):D=e[16];let C;e[17]!==p||e[18]!==D?(C=s.jsx(J,{name:p,className:"w-4 h-4 shrink-0",style:D}),e[17]=p,e[18]=D,e[19]=C):C=e[19];let P;e[20]!==a||e[21]!==m?(P=jp(a,m),e[20]=a,e[21]=m,e[22]=P):P=e[22];let A;e[23]!==P?(A=s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:P}),e[23]=P,e[24]=A):A=e[24];let R;e[25]!==n||e[26]!==m?(R=n&&s.jsx("span",{className:"typography-micro text-primary bg-primary/12 px-1 rounded flex-shrink-0 leading-none pb-px border border-primary/25",children:m("settings.gitIdentities.page.badge.default")}),e[25]=n,e[26]=m,e[27]=R):R=e[27];let K;e[28]!==A||e[29]!==R?(K=s.jsxs("div",{className:"flex items-center gap-1.5",children:[A,R]}),e[28]=A,e[29]=R,e[30]=K):K=e[30];let F;e[31]!==l||e[32]!==w||e[33]!==h||e[34]!==a.userEmail||e[35]!==m?(F=!l&&h?s.jsx("span",{className:w?"text-[var(--status-warning)]":void 0,children:m(h)}):a.userEmail,e[31]=l,e[32]=w,e[33]=h,e[34]=a.userEmail,e[35]=m,e[36]=F):F=e[36];let T;e[37]!==F?(T=s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:F}),e[37]=F,e[38]=T):T=e[38];let O;e[39]!==K||e[40]!==T?(O=s.jsxs("div",{className:"min-w-0",children:[K,T]}),e[39]=K,e[40]=T,e[41]=O):O=e[41];let E;e[42]!==O||e[43]!==C?(E=s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[C,O]}),e[42]=O,e[43]=C,e[44]=E):E=e[44];let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(pa,{asChild:!0,children:s.jsx(q,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:sj,children:s.jsx(J,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[45]=B):B=e[45];let _;e[46]!==y?(_=s.jsxs(ga,{children:[B,s.jsx(ma,{align:"end",className:"w-fit min-w-28",children:y(Bn)})]}),e[46]=y,e[47]=_):_=e[47];let H;e[48]!==E||e[49]!==_||e[50]!==j?(H=s.jsxs(Mi,{render:j,children:[E,_]}),e[48]=E,e[49]=_,e[50]=j,e[51]=H):H=e[51];let ne;e[52]!==y?(ne=s.jsx(Ti,{className:"w-fit min-w-28",children:y(Ei)}),e[52]=y,e[53]=ne):ne=e[53];let z;return e[54]!==f||e[55]!==H||e[56]!==ne?(z=s.jsxs(Di,{open:f,onOpenChange:g,children:[H,ne]}),e[54]=f,e[55]=H,e[56]=ne,e[57]=z):z=e[57],z};function X1(t){return t.refreshIdentityAccounts}function ej(t){return{profiles:t.profiles,globalIdentity:t.globalIdentity,defaultGitIdentityId:t.defaultGitIdentityId,deleteProfile:t.deleteProfile,loadProfiles:t.loadProfiles,loadGlobalIdentity:t.loadGlobalIdentity,loadDefaultGitIdentityId:t.loadDefaultGitIdentityId,setDefaultGitIdentityId:t.setDefaultGitIdentityId}}function tj(t){return t.account}function sj(t){return t.stopPropagation()}const qu=({guest:t})=>{const{t:e}=ze(),a=t.integration,n=pr(ae=>ae.byId[t.id]),o=pr(ae=>ae.setStatus),i=c.useMemo(()=>Wd(t.id,t.icon,iu().authenticatedAsset),[t.id,t.icon]),r=pr(ae=>ae.refresh),[l,u]=c.useState(!1),[m,d]=c.useState(!1),[f,g]=c.useState(!1),[p,h]=c.useState(""),[w,b]=c.useState(""),[k,v]=c.useState(""),[S,y]=c.useState(""),[N,x]=c.useState({}),[I,j]=c.useState(!1),D=c.useRef(null),[C]=c.useState(Qt),P=c.useRef(!0),A=()=>P.current&&Qt()===C,R=c.useCallback(()=>{D.current!=null&&(window.clearInterval(D.current),D.current=null),g(!1)},[]);if(c.useEffect(()=>(P.current=!0,r(t.id),()=>{P.current=!1,R()}),[t.id,r,R]),c.useEffect(()=>{n&&x(n.settings)},[n]),!a)return null;const K=a.auth,F=K==="token"&&a.token?.scheme==="basic",T=!!n?.connection.connected,O=n?.connection.account.trim()||"",E=f?e("settings.integrations.guests.status.waiting"):T?O||e("settings.integrations.guests.status.connected"):e("settings.integrations.guests.status.notConnected"),B=f?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":T?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground",_=f||l,H=a.name,ne=async()=>{if(!A())return!1;const ae=p.trim();if(!ae)return n?.hasClient?!0:(W.error(e("settings.integrations.guests.toast.clientRequired")),!1);es("saving");const X=await Ap(t.id,ae,w.trim()||void 0);return A()?X?(o(t.id,X),b(""),es("saved"),!0):(es("error"),W.error(e("settings.integrations.guests.toast.saveFailed",{name:H})),!1):!1},z=async(ae=N)=>{if(!A())return!1;const X=n?.settings??{};if((a.settings??[]).every(fe=>(ae[fe.id]??"").trim()===(X[fe.id]??"")))return!0;es("saving");const Z=await kp(t.id,ae);return A()?Z?(o(t.id,Z),es("saved"),!0):(es("error"),W.error(e("settings.integrations.guests.toast.saveFailed",{name:H})),!1):!1},$=async()=>{if(!A())return!1;const ae=k.trim();if(!ae)return T?!0:(W.error(e("settings.integrations.guests.toast.tokenRequired")),!1);const X=S.trim();if(F&&!X)return W.error(e("settings.integrations.guests.toast.usernameRequired")),!1;es("saving");const Q=await Pp(t.id,ae,F?X:void 0);return A()?Q?(o(t.id,Q),v(""),y(""),es("saved"),!0):(es("error"),W.error(e("settings.integrations.guests.toast.tokenInvalid")),!1):!1},V=async()=>{if(!A())return;R(),d(!0);const ae=n?.connection??{connected:!1,account:""};try{if(K==="token"){if(await $()){if((a.settings??[]).length>0&&!await z()||!A())return;W.success(e("settings.integrations.guests.toast.connected",{name:H}))}return}if(K==="oauth"&&!n?.hasClient&&!await ne())return;const X=await Sp(t.id);if(!A())return;if(!X){W.error(e("settings.integrations.guests.toast.startFailed",{name:H}));return}g(!0),u(!0),ks(X);const Q=Date.now()+Np;D.current=window.setInterval(()=>{(async()=>{if(!A()){R();return}if(Date.now()>Q){R(),W.error(e("settings.integrations.guests.toast.authorizationFailed",{name:H}));return}const le=await r(t.id);A()&&le&&Cp(ae,le.connection)&&(R(),W.success(e("settings.integrations.guests.toast.connected",{name:H})),as()&&ou())})()},Ip)}catch(X){if(!A())return;console.error("Failed to start guest connect:",X),W.error(e("settings.integrations.guests.toast.startFailed",{name:H})),R()}finally{A()&&d(!1)}},G=async()=>{if(A()){d(!0);try{R();const ae=await wp(t.id);if(!A())return;if(!ae){W.error(e("settings.integrations.guests.toast.disconnectFailed",{name:H}));return}o(t.id,ae),W.success(e("settings.integrations.guests.toast.disconnected",{name:H}))}catch(ae){if(!A())return;console.error("Failed to disconnect guest:",ae),W.error(e("settings.integrations.guests.toast.disconnectFailed",{name:H}))}finally{A()&&d(!1)}}},ee=async()=>{const ae=n?.redirectUri??"";!ae||!(await $a(ae)).ok||(j(!0),window.setTimeout(()=>j(!1),1500))};return s.jsx(Js,{open:_,onOpenChange:ae=>{if(f){u(!0);return}u(ae)},children:s.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[s.jsxs(Qs,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-start hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(Gd,{icon:Jd(t.icon),iconSrc:i,className:"size-5 text-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:H}),s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:a.description})]}),s.jsx("span",{"aria-live":"polite",className:Me("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",B),children:E}),s.jsx(J,{name:"arrow-down-s",className:Me("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",_&&"rotate-180")})]}),s.jsx(Ys,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsxs("div",{className:"space-y-3",children:[K==="oauth"?s.jsxs(s.Fragment,{children:[s.jsx(Mt,{label:e("settings.integrations.guests.field.clientId"),controlClassName:"w-full max-w-none",children:s.jsx(Ve,{value:p,onChange:ae=>h(ae.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:m})}),s.jsx(Mt,{label:e("settings.integrations.guests.field.clientSecret"),controlClassName:"w-full max-w-none",children:s.jsx(Ve,{type:"password",value:w,onChange:ae=>b(ae.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:m})})]}):null,F?s.jsx(Mt,{label:a.token?.usernameLabel??e("settings.integrations.guests.field.username"),controlClassName:"w-full max-w-none",children:s.jsx(Ve,{value:S,onChange:ae=>y(ae.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:m})}):null,K==="token"?s.jsx(Mt,{label:e("settings.integrations.guests.field.token"),info:e("settings.integrations.guests.field.token.info"),controlClassName:"w-full max-w-none",children:s.jsx(Ve,{type:"password",value:k,onChange:ae=>v(ae.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:m})}):null,(a.settings??[]).map(ae=>s.jsx(Mt,{label:ae.label,controlClassName:"w-full max-w-none",children:s.jsx(Ve,{value:N[ae.id]??"",onChange:X=>{x(Q=>({...Q,[ae.id]:X.target.value}))},onBlur:()=>{z()},autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:m})},ae.id)),K==="oauth"?s.jsxs(Mt,{label:e("settings.integrations.guests.field.redirectUri"),info:e("settings.integrations.guests.field.redirectUri.info"),controlClassName:"w-full max-w-none",children:[s.jsx(Ve,{value:n?.redirectUri??"",readOnly:!0,className:"h-8 min-w-0 flex-1 rounded-md px-3"}),s.jsx(q,{type:"button",size:"sm",variant:"outline",disabled:!n?.redirectUri,onClick:()=>{ee()},children:e(I?"settings.integrations.guests.actions.copied":"settings.integrations.guests.actions.copyRedirect")})]}):null,s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:T?s.jsx(q,{type:"button",size:"sm",variant:"destructive",disabled:m,onClick:()=>{G()},children:e("settings.integrations.guests.actions.disconnect")}):s.jsxs(q,{type:"button",size:"sm",disabled:m||f,onClick:()=>{V()},children:[m?s.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}):null,e("settings.integrations.guests.actions.connect")]})})]})})]})})},nj=t=>{const e=$e.c(27),{divider:a}=t,n=a===void 0?!0:a,{t:o}=ze(),i=vs(aj),r=vs(ij);let l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[0]=l):l=e[0],c.useEffect(oj,l),cs()||ru())return null;let u,m,d,f,g,p,h,w;if(e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==o){w=Symbol.for("react.early_return_sentinel");e:{const k=i.filter(rj);if(k.length===0){w=null;break e}u=He,e[13]!==o?(m=o("settings.integrations.guests.title"),e[13]=o,e[14]=m):m=e[14],e[15]!==o?(d=o("settings.integrations.guests.info"),e[15]=o,e[16]=d):d=e[16],f=n,g="integrations.guests",p="space-y-3";let v;e[17]!==r?(v=S=>s.jsx(qu,{guest:S},`${r}:${S.id}`),e[17]=r,e[18]=v):v=e[18],h=k.map(v)}e[1]=n,e[2]=i,e[3]=r,e[4]=o,e[5]=u,e[6]=m,e[7]=d,e[8]=f,e[9]=g,e[10]=p,e[11]=h,e[12]=w}else u=e[5],m=e[6],d=e[7],f=e[8],g=e[9],p=e[10],h=e[11],w=e[12];if(w!==Symbol.for("react.early_return_sentinel"))return w;let b;return e[19]!==u||e[20]!==m||e[21]!==d||e[22]!==f||e[23]!==g||e[24]!==p||e[25]!==h?(b=s.jsx(u,{title:m,info:d,divider:f,settingsItem:g,contentClassName:p,children:h}),e[19]=u,e[20]=m,e[21]=d,e[22]=f,e[23]=g,e[24]=p,e[25]=h,e[26]=b):b=e[26],b};function aj(t){return t.guests}function ij(t){return t.runtimeKey}function oj(){en()}function rj(t){return t.source!=="bundled"&&t.integration&&yl(t)}const lj=t=>{const e=new Map;for(const a of t){const n=JSON.stringify([a.user.provider,a.user.instance,a.user.id]),o=e.get(n);o?o.accounts.push(a):e.set(n,{key:n,accounts:[a]})}return Array.from(e.values())},cj=t=>/[0-9a-f]{8}(?=-[0-9a-f]{4}-)/i.exec(t)?.[0]??null,Wu=t=>{const e=$e.c(15),{accounts:a,avatarAlt:n,sourceLabel:o,statusLabel:i,currentLabel:r,renderActions:l}=t;let u;if(e[0]!==a||e[1]!==n||e[2]!==r||e[3]!==l||e[4]!==o||e[5]!==i){let d;e[7]!==n||e[8]!==r||e[9]!==l||e[10]!==o||e[11]!==i?(d=f=>{const g=f.accounts[0].user;return s.jsxs("div",{className:"py-3 first:pt-0 last:pb-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[g.avatarUrl?s.jsx("img",{src:g.avatarUrl,alt:n(g.username),className:"size-9 shrink-0 rounded-full border border-border bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-full border border-border bg-muted",children:s.jsx(J,{name:g.provider==="github"?"github-fill":g.provider==="gitlab"?"gitlab":"git-branch",className:"size-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate typography-ui-label text-foreground",children:g.name?.trim()||g.username}),s.jsx("div",{className:"truncate font-mono typography-micro text-muted-foreground",children:g.username})]})]}),s.jsx("div",{className:"ms-12 mt-2 divide-y divide-[var(--surface-subtle)]",children:f.accounts.map(p=>{const h=o(p),w=i(p),b=f.accounts.some(k=>k!==p&&o(k)===h)?cj(p.id):null;return s.jsxs("div",{className:"flex flex-col gap-2 py-2 first:pt-0 last:pb-0 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx("span",{children:h}),w?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{className:"text-[var(--status-warning)]",children:w})]}):null,b?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{className:"font-mono",children:b})]}):null,f.accounts.length>1&&p.current?s.jsx("span",{className:"rounded-full border border-border px-1.5",children:r}):null]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:l(p)})]},p.id)})})]},f.key)},e[7]=n,e[8]=r,e[9]=l,e[10]=o,e[11]=i,e[12]=d):d=e[12],u=lj(a).map(d),e[0]=a,e[1]=n,e[2]=r,e[3]=l,e[4]=o,e[5]=i,e[6]=u}else u=e[6];let m;return e[13]!==u?(m=s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:u}),e[13]=u,e[14]=m):m=e[14],m},Gu=t=>{const e=$e.c(34),{code:a,description:n,openLabel:o,onOpen:i,onCancel:r,disabled:l}=t,u=l===void 0?!1:l,{t:m}=ze();let d;e[0]!==m?(d=m("settings.github.page.flow.title"),e[0]=m,e[1]=d):d=e[1];let f;e[2]!==d?(f=s.jsx(Dn,{children:d}),e[2]=d,e[3]=f):f=e[3];let g;e[4]!==n?(g=s.jsx("p",{className:"typography-meta text-muted-foreground",children:n}),e[4]=n,e[5]=g):g=e[5];let p;e[6]!==f||e[7]!==g?(p=s.jsxs("div",{className:"space-y-1",children:[f,g]}),e[6]=f,e[7]=g,e[8]=p):p=e[8];let h;e[9]!==a?(h=s.jsx("code",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-1.5 font-mono text-xl tracking-widest text-foreground",children:a}),e[9]=a,e[10]=h):h=e[10];let w;e[11]!==i||e[12]!==o?(w=s.jsx(q,{size:"sm",onClick:i,children:o}),e[11]=i,e[12]=o,e[13]=w):w=e[13];let b;e[14]!==h||e[15]!==w?(b=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[h,w]}),e[14]=h,e[15]=w,e[16]=b):b=e[16];let k;e[17]!==m?(k=m("settings.github.page.flow.waiting"),e[17]=m,e[18]=k):k=e[18];let v;e[19]!==k?(v=s.jsx("span",{className:"typography-micro text-muted-foreground animate-pulse",children:k}),e[19]=k,e[20]=v):v=e[20];let S;e[21]!==m?(S=m("settings.common.actions.cancel"),e[21]=m,e[22]=S):S=e[22];let y;e[23]!==u||e[24]!==r||e[25]!==S?(y=s.jsx(q,{size:"sm",variant:"ghost",disabled:u,onClick:r,children:S}),e[23]=u,e[24]=r,e[25]=S,e[26]=y):y=e[26];let N;e[27]!==v||e[28]!==y?(N=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[v,y]}),e[27]=v,e[28]=y,e[29]=N):N=e[29];let x;return e[30]!==N||e[31]!==p||e[32]!==b?(x=s.jsxs("div",{className:"space-y-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] p-3",children:[p,b,N]}),e[30]=N,e[31]=p,e[32]=b,e[33]=x):x=e[33],x},dj=()=>{const{t}=ze(),e=la()?.sourceControl,a=vl(Hs),n=zs(O=>O.entries[a]),o=n?.status??null,i=n?.isLoading??!1,r=n?.hasChecked??!1,l=zs(O=>O.refreshStatus),u=zs(O=>O.refreshInstances),m=zs(O=>O.setStatus),d=c.useCallback(async O=>{await ks(O)},[]),[f,g]=c.useState(!1),[p,h]=c.useState(null),[w,b]=c.useState(null),[k,v]=c.useState(0),S=c.useRef(null),y=c.useRef(""),N=c.useRef(0),x=c.useCallback(()=>{const O=Qt(),E=N.current;return()=>E===N.current&&O===Qt()},[]),I=c.useCallback(()=>{S.current!=null&&(window.clearTimeout(S.current),S.current=null),b(null)},[]),j=c.useCallback(()=>{y.current="",h(null),I()},[I]);c.useEffect(()=>{const O=Sl(()=>{N.current+=1,g(!1),j()});return()=>{N.current+=1,O()}},[j]),c.useEffect(()=>((async()=>{try{!r&&e&&await l(e,Hs)}catch(O){console.warn("Failed to load GitHub auth status:",O)}})(),()=>{I()}),[r,l,e,I]);const D=c.useCallback(async()=>{const O=x();g(!0);try{if(!e)return;const E=await e.authStart(Hs);if(!O())return;y.current=Qt(),h(E),v(0),b(Math.max(1,E.interval)*1e3);const B=E.verificationUriComplete||E.verificationUri;d(B)}catch(E){O()&&(console.error("Failed to start GitHub connect:",E),W.error(t("settings.github.page.toast.startConnectFailed")))}finally{O()&&g(!1)}},[x,d,e,t]);c.useEffect(()=>{if(!p?.flowId||!w||S.current!=null)return;const O=async()=>{const E=x();if(y.current!==Qt()){j();return}try{if(!e)throw new Error("Source control runtime API unavailable");const B=await e.authComplete(Hs,p.flowId);if(!E()||y.current!==Qt())return;if(B.status==="connected"){if(j(),await l(e,Hs,{force:!0}),!E()||(await u(e,{force:!0}),!E()))return;W.success(t("settings.github.page.toast.connected"));return}B.status==="pending"&&B.slowDown&&b(_=>_?_+5e3:5e3),B.status==="pending"&&v(_=>_+1),B.status==="error"&&(W.error(B.message||t("settings.github.page.toast.authorizationFailed")),j())}catch(B){E()&&y.current===Qt()&&(console.warn("GitHub polling failed:",B),v(_=>_+1))}};return S.current=window.setTimeout(()=>{O()},w),()=>{S.current!=null&&(window.clearTimeout(S.current),S.current=null)}},[x,p,k,w,u,l,e,j,t]);const C=c.useCallback(async O=>{const E=x();g(!0);try{if(!e||(await e.authSetCliDisabled(Hs,O),!E())||(await l(e,Hs,{force:!0}),!E()))return;W.success(t(O?"settings.github.page.toast.ghCliDisabled":"settings.github.page.toast.ghCliEnabled"))}catch(B){E()&&(console.error("Failed to update gh CLI setting:",B),W.error(t("settings.github.page.toast.ghCliUpdateFailed")))}finally{E()&&g(!1)}},[x,l,e,t]),P=c.useCallback(async O=>{const E=x();g(!0);try{if(!e)return;const B=await e.authActivate(Hs,O);E()&&m(Hs,B)}catch(B){E()&&(console.error("Failed to switch GitHub account:",B),W.error(t("settings.github.page.toast.switchFailed")))}finally{E()&&g(!1)}},[x,m,e,t]),A=c.useCallback(async O=>{const E=x();g(!0);try{if(j(),!e||(await e.authDisconnect(Hs,O),!E())||(await l(e,Hs,{force:!0}),!E())||(await u(e,{force:!0}),!E()))return;W.success(t("settings.github.page.toast.disconnected"))}catch(B){E()&&(console.error("Failed to remove GitHub account:",B),W.error(t("settings.github.page.toast.disconnectFailed")))}finally{E()&&g(!1)}},[x,u,l,e,j,t]);if(i&&!r)return s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.sourceControl.status.checking")});const R=o?.accounts??[],K=o?.cli??null,F=o?.status==="unreachable"||o?.status==="temporarily-unavailable"?o.message||t("sessionAuth.error.networkRetry"):null,T=!!(K?.available&&!K.active&&(!K.user||K.disabled));return s.jsxs("div",{className:"space-y-3","data-settings-item":"git.github-account",children:[F&&s.jsx(kt,{label:t("sessionAuth.error.networkTitle"),description:F,children:s.jsx(q,{size:"sm",variant:"outline",disabled:f||i||!e,onClick:()=>{e&&l(e,Hs,{force:!0})},children:t("sessionAuth.error.retry")})}),R.length===0?!F&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.github.page.status.notConnected")}):s.jsx(Wu,{accounts:R,avatarAlt:O=>t("settings.github.page.avatarAlt.withLogin",{login:O}),currentLabel:t("settings.sourceControl.accounts.inUse"),sourceLabel:O=>O.source==="cli"?t("settings.github.page.accountSource.cli"):t("settings.github.page.accountSource.oauth"),statusLabel:O=>O.status==="valid"?null:t("settings.sourceControl.accounts.needsAuthentication"),renderActions:O=>s.jsxs(s.Fragment,{children:[O.status==="invalid"?s.jsx(q,{size:"sm",variant:"outline",onClick:D,disabled:f,children:t("settings.sourceControl.actions.reauthenticate")}):null,O.source==="cli"&&!O.current?s.jsx(q,{size:"sm",variant:"outline",onClick:()=>{P(O.id)},disabled:f,children:t("settings.sourceControl.actions.use")}):null,s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>O.source==="cli"?C(!0):A(O.id),disabled:f,children:O.source==="cli"?t("settings.github.page.ghCli.actions.disable"):t("settings.sourceControl.actions.remove")})]})}),p?s.jsx(Gu,{code:p.userCode,description:t("settings.github.page.flow.description"),openLabel:t("settings.github.page.actions.openGithub"),onOpen:()=>{d(p.verificationUriComplete||p.verificationUri)},onCancel:j,disabled:f}):s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsx(q,{"data-settings-item":"git.github-connect",size:"sm",variant:R.length>0?"outline":"default",onClick:D,disabled:f,children:R.length>0?t("settings.github.page.actions.addAccount"):t("settings.github.page.actions.connect")})}),T&&K?s.jsx(kt,{label:t("settings.github.page.ghCli.title"),description:K.disabled?t("settings.github.page.ghCli.disabledDescription"):t("settings.github.page.ghCli.availableDescription"),className:"border-t border-[var(--surface-subtle)] pt-3",children:s.jsx(q,{size:"sm",variant:"outline",onClick:()=>C(!K.disabled),disabled:f,children:K.disabled?t("settings.github.page.ghCli.actions.enable"):t("settings.github.page.ghCli.actions.disable")})}):null]})},uj=()=>{const t=$e.c(37),{t:e}=ze(),a=Qd(Hs),n=a?.status??null,o=a?.isLoading??!1,i=a?.hasChecked??!1,[r,l]=c.useState(!1),u=n?.connected===!0;let m;if(t[0]!==u||t[1]!==i||t[2]!==o||t[3]!==n||t[4]!==e){const P=n?.accounts??[],A=(P.find(mj)??P[0])?.user.username.trim()??(n?.status==="connected"?n.user.username.trim():"");m=o&&!i?e("common.loading"):u?P.length>1?e("settings.sourceControl.accounts.connectedCount",{count:P.length}):A||e("settings.github.page.status.active"):e("settings.integrations.github.status.notConnected"),t[0]=u,t[1]=i,t[2]=o,t[3]=n,t[4]=e,t[5]=m}else m=t[5];const d=m,f=u?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground";let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(J,{name:"github-fill",className:"size-5 text-foreground"})}),t[6]=g):g=t[6];let p;t[7]!==e?(p=e("settings.integrations.github.title"),t[7]=e,t[8]=p):p=t[8];let h;t[9]!==p?(h=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:p}),t[9]=p,t[10]=h):h=t[10];let w;t[11]!==e?(w=e("settings.integrations.github.description"),t[11]=e,t[12]=w):w=t[12];let b;t[13]!==w?(b=s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:w}),t[13]=w,t[14]=b):b=t[14];let k;t[15]!==h||t[16]!==b?(k=s.jsxs("div",{className:"min-w-0 flex-1",children:[h,b]}),t[15]=h,t[16]=b,t[17]=k):k=t[17];let v;t[18]!==f?(v=Me("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",f),t[18]=f,t[19]=v):v=t[19];let S;t[20]!==d||t[21]!==v?(S=s.jsx("span",{"aria-live":"polite",className:v,children:d}),t[20]=d,t[21]=v,t[22]=S):S=t[22];const y=r&&"rotate-180";let N;t[23]!==y?(N=Me("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",y),t[23]=y,t[24]=N):N=t[24];let x;t[25]!==N?(x=s.jsx(J,{name:"arrow-down-s",className:N}),t[25]=N,t[26]=x):x=t[26];let I;t[27]!==x||t[28]!==k||t[29]!==S?(I=s.jsxs(Qs,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-start hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[g,k,S,x]}),t[27]=x,t[28]=k,t[29]=S,t[30]=I):I=t[30];let j;t[31]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Ys,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsx(dj,{embedded:!0})}),t[31]=j):j=t[31];let D;t[32]!==I?(D=s.jsxs("div",{"data-settings-item":"integrations.github",className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[I,j]}),t[32]=I,t[33]=D):D=t[33];let C;return t[34]!==r||t[35]!==D?(C=s.jsx(Js,{open:r,onOpenChange:l,children:D}),t[34]=r,t[35]=D,t[36]=C):C=t[36],C};function mj(t){return t.current}const pj={provider:"gitlab",instance:"https://gitlab.com"},Ju="overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)]",Ua="px-3 py-3",ao="border-t border-[var(--surface-subtle)]",gj=t=>{try{const e=new URL(t.includes("://")?t:`https://${t}`),a=["localhost","127.0.0.1","::1","[::1]"].includes(e.hostname.toLowerCase()),n=!!(e.username||e.password||e.search||e.hash||e.pathname&&e.pathname!=="/"),o=e.protocol==="https:"||e.protocol==="http:"&&a;return n||!o?null:{provider:"gitlab",instance:e.origin}}catch{return null}},fj=({identity:t,sourceControl:e,onSaved:a})=>{const{t:n}=ze(),o=zs(Q=>Q.refreshInstances),i=zs(Q=>Q.refreshStatus),r=zs(Q=>Q.setStatus),l=Qd(t),[u,m]=c.useState(null),[d,f]=c.useState(!1),[g,p]=c.useState(0),[h,w]=c.useState(null),[b,k]=c.useState(0),[v,S]=c.useState(0),[y,N]=c.useState(""),[x,I]=c.useState(!1),[j,D]=c.useState(!1),[C,P]=c.useState(!1),[A,R]=c.useState(!1),K=c.useRef(""),F=c.useRef(0),T=c.useCallback(()=>{const Q=Qt(),le=F.current;return()=>le===F.current&&Q===Qt()},[]),O=l?.status??null,E=O?.accounts??[],B=O&&"cli"in O?O.cli:void 0,_=c.useCallback(()=>{K.current="",w(null),k(0)},[]);c.useEffect(()=>{const Q=Sl(()=>{F.current+=1,_()});return()=>{F.current+=1,Q()}},[_]),c.useEffect(()=>_(),[t.instance,t.provider,_]),c.useEffect(()=>{let Q=!1;const le=T();return f(!1),Promise.all([e.capabilities(t),i(e,t)]).then(([Z])=>{!Q&&le()&&m(Z)}).catch(()=>{!Q&&le()&&f(!0)}),()=>{Q=!0}},[g,T,t,i,e]),c.useEffect(()=>{if(!h||b<=0)return;const Q=async()=>{const Z=T();if(K.current!==Qt()){_();return}try{const fe=await e.authComplete(t,h.flowId);if(!Z()||K.current!==Qt())return;if(fe.status==="connected"){if(_(),I(!1),await i(e,t,{force:!0}),!Z()||(await o(e,{force:!0}),!Z()))return;a?.(),P(!1);return}if(fe.status==="pending"){k((fe.slowDown?b+5e3:b)||5e3),S(Y=>Y+1);return}_(),P(!0)}catch{Z()&&K.current===Qt()&&S(fe=>fe+1)}},le=window.setTimeout(()=>{Q()},b);return()=>window.clearTimeout(le)},[T,h,t,a,v,b,o,i,e,_]);const H=async()=>{const Q=T();D(!0),P(!1),R(!1);try{const le=await e.authStart(t);if(!Q())return;K.current=Qt(),w(le),S(0),k(Math.max(1,le.interval)*1e3),await ks(le.verificationUriComplete||le.verificationUri)}catch{Q()&&P(!0)}finally{Q()&&D(!1)}},ne=async()=>{if(!y.trim())return;const Q=T();D(!0),P(!1),R(!1);try{const le=await e.authSetToken(t,y.trim());if(!Q()||(r(t,le),N(""),I(!1),await i(e,t,{force:!0}),!Q())||(await o(e,{force:!0}),!Q()))return;a?.()}catch(le){if(!Q())return;le instanceof Error&&"code"in le&&le.code==="INVALID_TOKEN"?R(!0):P(!0)}finally{Q()&&D(!1)}},z=async Q=>{const le=T();D(!0),P(!1),R(!1);try{if(await e.authDisconnect(t,Q),!le()||(await i(e,t,{force:!0}),!le()))return;await o(e,{force:!0})}catch{le()&&P(!0)}finally{le()&&D(!1)}},$=async Q=>{const le=T();D(!0),P(!1),R(!1);try{const Z=await e.authActivate(t,Q);le()&&r(t,Z)}catch{le()&&P(!0)}finally{le()&&D(!1)}},V=async()=>{if(!B)return;const Q=T();D(!0),P(!1),R(!1);try{if(await e.authSetCliDisabled(t,!B.disabled),!Q())return;await i(e,t,{force:!0})}catch{Q()&&P(!0)}finally{Q()&&D(!1)}},G=()=>{I(!1),w(null),k(0),S(0),N(""),P(!1),R(!1)},ee=E.length>0,ae=!ee||x;let X;return l?.isLoading?X=n("settings.sourceControl.status.checking"):A?X=n("settings.gitlab.status.tokenRejected"):C||d||O?.status==="unreachable"?X=n("settings.gitlab.status.operationFailed"):E.length>0?X=null:X=n("settings.gitlab.status.notConnected"),s.jsxs("div",{className:Ju,children:[s.jsxs("div",{className:Me(Ua,"flex items-start justify-between gap-4"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label truncate text-foreground",children:t.instance}),X?s.jsx("div",{className:"typography-meta mt-0.5 text-muted-foreground",children:X}):null]}),d||O?.status==="unreachable"?s.jsx(q,{size:"sm",variant:"outline",disabled:j||l?.isLoading,onClick:()=>p(Q=>Q+1),children:n("sessionAuth.error.retry")}):null]}),E.length>0?s.jsx("div",{className:Me(Ua,ao),children:s.jsx(Wu,{accounts:E,avatarAlt:Q=>Q,currentLabel:n("settings.sourceControl.accounts.inUse"),sourceLabel:Q=>n(Q.source==="cli"?"settings.gitlab.cli.label":qd(Q.source)),statusLabel:Q=>Q.status==="valid"?null:n("settings.sourceControl.accounts.needsAuthentication"),renderActions:Q=>s.jsxs(s.Fragment,{children:[Q.status==="invalid"&&Q.source!=="cli"?s.jsx(q,{size:"sm",variant:"outline",onClick:()=>I(!0),disabled:j,children:n("settings.sourceControl.actions.reauthenticate")}):null,Q.source==="cli"&&!Q.current?s.jsx(q,{size:"sm",variant:"outline",onClick:()=>{$(Q.id)},disabled:j,children:n("settings.sourceControl.actions.use")}):null,s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>Q.source==="cli"?V():z(Q.id),disabled:j,children:Q.source==="cli"?n("settings.gitlab.actions.disableCli"):n("settings.sourceControl.actions.remove")})]})})}):null,ee&&!x&&s.jsx("div",{className:Me(Ua,ao),children:s.jsx(q,{size:"sm",variant:"outline",onClick:()=>I(!0),disabled:j,children:n("settings.github.page.actions.addAccount")})}),ae&&s.jsxs("div",{className:Me(js,Ua,ao),children:[u?.authenticationMethods.device.available&&!h&&s.jsx(kt,{label:n("settings.gitlab.device.label"),children:s.jsx(q,{size:"sm",onClick:H,disabled:j,children:n("settings.gitlab.actions.connect")})}),h&&s.jsx(Gu,{code:h.userCode,description:n("settings.gitlab.device.waiting"),openLabel:n("settings.gitlab.actions.openGitLab"),onOpen:()=>{ks(h.verificationUriComplete||h.verificationUri)},onCancel:G}),u?.authenticationMethods.pat.available&&s.jsx(kt,{label:n("settings.gitlab.token.label"),info:n("settings.gitlab.token.info"),children:s.jsxs("div",{className:`${ys} flex flex-col gap-2 @xl:flex-row @xl:items-center`,children:[s.jsx(Ve,{className:"h-8 w-full min-w-0 rounded-md",type:"password",value:y,onChange:Q=>N(Q.target.value),"aria-label":n("settings.gitlab.token.label")}),s.jsx(q,{className:"w-full @xl:w-auto",size:"sm",onClick:ne,disabled:j||!y.trim(),children:n("settings.common.actions.saveChanges")})]})}),x&&!h&&s.jsx("div",{className:"flex justify-end",children:s.jsx(q,{size:"sm",variant:"ghost",onClick:G,disabled:j,children:n("settings.common.actions.cancel")})})]}),(ee||B?.disabled)&&B&&(B.available||B.disabled)&&s.jsx("div",{className:Me(Ua,ao),children:s.jsx(kt,{label:n("settings.gitlab.cli.label"),info:n("settings.gitlab.cli.info"),children:s.jsx(q,{size:"sm",variant:"outline",onClick:V,disabled:j,children:B.disabled?n("settings.gitlab.actions.enableCli"):n("settings.gitlab.actions.disableCli")})})})]})},hj=()=>{const t=$e.c(51),{t:e}=ze(),a=la()?.sourceControl,n=zs(bj),o=zs(xj),i=zs(vj),[r,l]=c.useState(!1),[u,m]=c.useState(null),[d,f]=c.useState(""),[g,p]=c.useState(!1),[h,w]=c.useState(!1);let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>m(null),t[0]=b):b=t[0];const k=b,v=n.filter(yj),S=[...v];u&&!v.some(Y=>Y.instance===u.instance)&&S.push(u),S.length===0&&S.push(pj);let y,N;t[1]!==i?(y=()=>{a&&i(a)},N=[i,a],t[1]=i,t[2]=y,t[3]=N):(y=t[2],N=t[3]),c.useEffect(y,N);let x;t[4]!==d?(x=()=>{const Y=gj(d);if(!Y){w(!0);return}m(Y),f(""),p(!1),w(!1)},t[4]=d,t[5]=x):x=t[5];const I=x;if(!a)return null;let j;t[6]!==o?(j=Y=>o[vl(Y)],t[6]=o,t[7]=j):j=t[7];const D=v.map(j),C=D.flatMap(jj).filter(kj),P=C.find(wj)??C[0]??null,A=P!==null,K=D.some(Sj)&&!A?e("common.loading"):A?C.length>1?e("settings.sourceControl.accounts.connectedCount",{count:C.length}):P.user.username.trim()||e("settings.gitlab.status.connected"):e("settings.gitlab.status.notConnected"),F=A?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground";let T;t[8]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(J,{name:"gitlab",className:"size-5 text-foreground"})}),t[8]=T):T=t[8];let O;t[9]!==e?(O=e("settings.gitlab.title"),t[9]=e,t[10]=O):O=t[10];let E;t[11]!==O?(E=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:O}),t[11]=O,t[12]=E):E=t[12];let B;t[13]!==e?(B=e("settings.gitlab.info"),t[13]=e,t[14]=B):B=t[14];let _;t[15]!==B?(_=s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:B}),t[15]=B,t[16]=_):_=t[16];let H;t[17]!==E||t[18]!==_?(H=s.jsxs("div",{className:"min-w-0 flex-1",children:[E,_]}),t[17]=E,t[18]=_,t[19]=H):H=t[19];let ne;t[20]!==F?(ne=Me("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",F),t[20]=F,t[21]=ne):ne=t[21];let z;t[22]!==K||t[23]!==ne?(z=s.jsx("span",{"aria-live":"polite",className:ne,children:K}),t[22]=K,t[23]=ne,t[24]=z):z=t[24];const $=r&&"rotate-180";let V;t[25]!==$?(V=Me("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",$),t[25]=$,t[26]=V):V=t[26];let G;t[27]!==V?(G=s.jsx(J,{name:"arrow-down-s",className:V}),t[27]=V,t[28]=G):G=t[28];let ee;t[29]!==H||t[30]!==z||t[31]!==G?(ee=s.jsxs(Qs,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-start hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[T,H,z,G]}),t[29]=H,t[30]=z,t[31]=G,t[32]=ee):ee=t[32];let ae;t[33]!==e?(ae=e("settings.gitlab.instances.title"),t[33]=e,t[34]=ae):ae=t[34];const X=S.map(Y=>s.jsx(fj,{identity:Y,sourceControl:a,onSaved:u?.instance===Y.instance?k:void 0},`${Qt()}:${Y.instance}`));let Q;t[35]!==I||t[36]!==h||t[37]!==d||t[38]!==g||t[39]!==e?(Q=g?s.jsx("div",{className:Me(Ju,Ua),children:s.jsx(kt,{label:e("settings.gitlab.instance.customLabel"),info:e("settings.gitlab.instance.customInfo"),description:h?e("settings.gitlab.status.operationFailed"):void 0,children:s.jsxs("div",{className:`${ys} flex flex-col gap-2 @xl:flex-row @xl:items-center`,children:[s.jsx(Ve,{className:"h-8 w-full min-w-0 rounded-md",value:d,onChange:Y=>f(Y.target.value),placeholder:"https://gitlab.example.com","aria-label":e("settings.gitlab.instance.customLabel")}),s.jsx(q,{className:"w-full @xl:w-auto",size:"sm",onClick:I,children:e("settings.gitlab.actions.useInstance")}),s.jsx(q,{className:"w-full @xl:w-auto",size:"sm",variant:"ghost",onClick:()=>{f(""),p(!1),w(!1)},children:e("settings.common.actions.cancel")})]})})}):s.jsx(q,{size:"sm",variant:"outline",onClick:()=>p(!0),children:e("settings.gitlab.actions.addInstance")}),t[35]=I,t[36]=h,t[37]=d,t[38]=g,t[39]=e,t[40]=Q):Q=t[40];let le;t[41]!==ae||t[42]!==X||t[43]!==Q?(le=s.jsx(Ys,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsxs(hs,{title:ae,contentClassName:"space-y-3",settingsItem:"git.gitlab-connect",children:[X,Q]})}),t[41]=ae,t[42]=X,t[43]=Q,t[44]=le):le=t[44];let Z;t[45]!==ee||t[46]!==le?(Z=s.jsxs("div",{"data-settings-item":"git.gitlab-account",className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[ee,le]}),t[45]=ee,t[46]=le,t[47]=Z):Z=t[47];let fe;return t[48]!==r||t[49]!==Z?(fe=s.jsx(Js,{open:r,onOpenChange:l,children:Z}),t[48]=r,t[49]=Z,t[50]=fe):fe=t[50],fe};function bj(t){return t.identities}function xj(t){return t.entries}function vj(t){return t.refreshInstances}function yj(t){return t.provider==="gitlab"}function jj(t){return t?.status?.status==="connected"?t.status.accounts:[]}function kj(t){return t.status==="valid"}function wj(t){return t.current}function Sj(t){return t?.isLoading&&!t.hasChecked}const io="__none__",oo="__inherit__";function Nj({linear:t,connected:e,organizationId:a}){const{t:n}=ze(),o=un(b=>b.projects),[i,r]=c.useState(null),[l,u]=c.useState(!1),[m,d]=c.useState(!1),f=c.useCallback(async()=>{if(!e){r(null),u(!1);return}try{const b=await t.mappingGet();if(b.connected===!1){r(null),u(!1);return}r(b),u(!1)}catch(b){console.error("Failed to load Linear mapping:",b),u(!0)}},[e,t]);c.useEffect(()=>{f()},[f,a]);const g=c.useCallback(async b=>{const k={};for(const v of b.teams??[])v.projectPath&&(k[v.id]=v.projectPath);d(!0),es("saving");try{const v=await t.mappingSet({defaultProjectPath:b.defaultProjectPath??null,teamProjectPaths:k});if(v.connected===!1){r(null),es("error");return}r(v),u(!1),es("saved")}catch(v){console.error("Failed to save Linear mapping:",v),es("error")}finally{d(!1)}},[t]);if(!e)return null;if(l&&!i)return s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.loadFailed")});if(!i)return null;const p=b=>o.find(v=>v.path===b)?.label?.trim()||b,h=b=>!b||b===io?n("settings.integrations.linear.mapping.defaultProject.placeholder"):p(b),w=b=>!b||b===oo?n("settings.integrations.linear.mapping.teams.useDefault"):p(b);return s.jsxs("div",{className:js,children:[o.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.emptyProjects")}):null,s.jsx(kt,{label:n("settings.integrations.linear.mapping.defaultProject"),info:n("settings.integrations.linear.mapping.defaultProject.info"),settingsItem:"integrations.linear.mapping",children:s.jsxs(Tt,{value:i.defaultProjectPath||io,disabled:m||o.length===0,onValueChange:b=>{g({...i,defaultProjectPath:b===io?null:b})},children:[s.jsx(Pt,{className:nn,"aria-label":n("settings.integrations.linear.mapping.defaultProject.aria"),children:s.jsx(Ut,{placeholder:n("settings.integrations.linear.mapping.defaultProject.placeholder"),children:h})}),s.jsxs(At,{children:[s.jsx(ot,{value:io,children:n("settings.integrations.linear.mapping.defaultProject.placeholder")}),i.defaultProjectPath&&!o.some(b=>b.path===i.defaultProjectPath)?s.jsx(ot,{value:i.defaultProjectPath,children:i.defaultProjectPath}):null,o.map(b=>s.jsx(ot,{value:b.path,children:p(b.path)},b.id))]})]})}),s.jsx(hs,{title:n("settings.integrations.linear.mapping.teams"),info:n("settings.integrations.linear.mapping.teams.info"),children:(i.teams??[]).length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.emptyTeams")}):s.jsx("div",{className:js,children:(i.teams??[]).map(b=>s.jsx(kt,{label:`${b.key} · ${b.name}`,children:s.jsxs(Tt,{value:b.projectPath||oo,disabled:m||o.length===0,onValueChange:k=>{g({...i,teams:(i.teams??[]).map(v=>v.id===b.id?{...v,projectPath:k===oo?null:k}:v)})},children:[s.jsx(Pt,{className:nn,"aria-label":n("settings.integrations.linear.mapping.teams.aria",{team:b.key}),children:s.jsx(Ut,{placeholder:n("settings.integrations.linear.mapping.teams.useDefault"),children:w})}),s.jsxs(At,{children:[s.jsx(ot,{value:oo,children:n("settings.integrations.linear.mapping.teams.useDefault")}),b.projectPath&&!o.some(k=>k.path===b.projectPath)?s.jsx(ot,{value:b.projectPath,children:b.projectPath}):null,o.map(k=>s.jsx(ot,{value:k.path,children:p(k.path)},k.id))]})]})},b.id))})})]})}function Cj({linear:t,connected:e}){const{t:a}=ze(),[n,o]=c.useState(null),[i,r]=c.useState(!1),[l,u]=c.useState(!1);c.useEffect(()=>{if(!e){o(null),r(!1);return}let d=!1;return t.preferencesGet().then(f=>{d||(o(f.sessionComments),r(!1))}).catch(()=>{d||r(!0)}),()=>{d=!0}},[e,t]);const m=c.useCallback(async d=>{const f=n;o(d),u(!0);try{const g=await t.preferencesSet({sessionComments:d});o(g.sessionComments),es("saved")}catch{o(f),es("error")}finally{u(!1)}},[n,t]);return e?i?s.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.integrations.linear.sessionComments.loadFailed")}):s.jsx("div",{className:js,children:s.jsx(kt,{label:a("settings.integrations.linear.sessionComments.label"),info:a("settings.integrations.linear.sessionComments.info"),settingsItem:"integrations.linear.session-comments",children:s.jsx(ra,{checked:n===!0,disabled:n===null||l,onCheckedChange:d=>{m(d)},"aria-label":a("settings.integrations.linear.sessionComments.aria")})})}):null}const Ij=3*6e4,Pj=1500;function md(t){const e=t?.workspaces??[],a=e.find(n=>n.current);return{connected:!!t?.connected,ids:e.map(n=>n.id).slice().sort().join(","),currentId:a?.id||t?.organization?.id||"",currentAuthorizedAt:a?.authorizedAt??0}}function Aj(t,e){return e.connected?t.connected?e.ids!==t.ids||e.currentId!==t.currentId||e.currentAuthorizedAt!==t.currentAuthorizedAt:!0:!1}const Tj=()=>{const{t}=ze(),e=la()?.linear,a=Da(P=>P.status),n=Da(P=>P.isLoading),o=Da(P=>P.hasChecked),i=Da(P=>P.refreshStatus),r=Da(P=>P.setStatus),[l,u]=c.useState(!1),[m,d]=c.useState(!1),[f,g]=c.useState(!1),p=c.useRef(null),h=c.useCallback(()=>{p.current!=null&&(window.clearInterval(p.current),p.current=null),d(!1)},[]);c.useEffect(()=>{if(e)return o||i(e),()=>{h()}},[o,i,e,h]);const w=c.useCallback(async()=>{if(!e)return;h(),u(!0);const P=md(Da.getState().status);try{const A=await e.authStart(as()?"desktop":"web");d(!0),g(!0),ks(A.authorizationUrl);const R=Date.now()+Ij;p.current=window.setInterval(()=>{(async()=>{if(Date.now()>R){h(),W.error(t("settings.integrations.linear.toast.authorizationFailed"));return}const K=await i(e,{force:!0});Aj(P,md(K))&&(h(),W.success(t("settings.integrations.linear.toast.connected")),ou())})()},Pj)}catch(A){console.error("Failed to start Linear connect:",A),W.error(t("settings.integrations.linear.toast.startConnectFailed")),h()}finally{u(!1)}},[i,e,h,t]),b=c.useCallback(async P=>{if(!(!e||!P)){u(!0);try{const A=await e.authActivate(P);r(A),W.success(t("settings.integrations.linear.toast.workspaceSwitched"))}catch(A){console.error("Failed to switch Linear workspace:",A),W.error(t("settings.integrations.linear.toast.workspaceSwitchFailed"))}finally{u(!1)}}},[e,r,t]),k=c.useCallback(async()=>{if(e){u(!0);try{h(),await e.authDisconnect(),W.success(t("settings.integrations.linear.toast.disconnected")),await i(e,{force:!0})}catch(P){console.error("Failed to disconnect Linear:",P),W.error(t("settings.integrations.linear.toast.disconnectFailed"))}finally{u(!1)}}},[i,e,h,t]);if(!e)return null;const v=!!a?.connected,S=a?.user,y=a?.organization,x=(a?.workspaces??[]).filter(P=>!P.current),I=S?.displayName?.trim()||S?.name?.trim()||t("settings.integrations.linear.label.unknownUser"),j=m?t("settings.integrations.linear.status.waiting"):n&&!o?t("common.loading"):v?y?.name?.trim()||t("settings.integrations.linear.status.connected"):t("settings.integrations.linear.status.notConnected"),D=m?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":v?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground",C=m||f;return s.jsx(Js,{open:C,onOpenChange:P=>{if(m){g(!0);return}g(P)},children:s.jsxs("div",{"data-settings-item":"integrations.linear",className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[s.jsxs(Qs,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-start hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(J,{name:"linear",className:"size-5 text-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:t("settings.integrations.linear.title")}),s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:t("settings.integrations.linear.description")})]}),s.jsx("span",{"aria-live":"polite",className:Me("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",D),children:j}),s.jsx(J,{name:"arrow-down-s",className:Me("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",C&&"rotate-180")})]}),s.jsx(Ys,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsxs("div",{className:"space-y-3",children:[v?s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[S?.avatarUrl?s.jsx("img",{src:S.avatarUrl,alt:t("settings.integrations.linear.avatarAlt.withName",{name:I}),className:"size-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]",children:s.jsx(J,{name:"linear",className:"size-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:I}),s.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[y?.name,S?.email].filter(Boolean).join(" · ")})]})]}):m?s.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.integrations.linear.flow.description")}):null,v?s.jsxs(s.Fragment,{children:[s.jsx(Nj,{linear:e,connected:v,organizationId:y?.id??null}),s.jsx(Cj,{linear:e,connected:v}),x.length>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.integrations.linear.label.otherWorkspaces")}),s.jsx("div",{className:"space-y-1",children:x.map(P=>{const A=P.user,R=P.name?.trim()||t("settings.integrations.linear.status.connected");return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:R}),A?.email?s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:A.email}):null]}),s.jsx(q,{type:"button",size:"sm",variant:"ghost",onClick:()=>{b(P.id)},disabled:l,children:t("settings.integrations.linear.actions.switchTo")})]},P.id)})})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(q,{type:"button",size:"sm",variant:"outline",onClick:()=>{w()},disabled:l||m,"data-settings-item":"integrations.linear.add-workspace",children:t("settings.integrations.linear.actions.addWorkspace")}),s.jsx(q,{type:"button",size:"sm",variant:"destructive",onClick:()=>{k()},disabled:l,children:t("settings.integrations.linear.actions.disconnect")})]})]}):m?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground animate-pulse",children:t("settings.integrations.linear.flow.waiting")}),s.jsx(q,{type:"button",size:"sm",variant:"ghost",disabled:l,onClick:h,children:t("settings.common.actions.cancel")})]}):s.jsxs(q,{type:"button",size:"sm",variant:"default",onClick:()=>{w()},disabled:l||n&&!o,children:[l?s.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}):null,t("settings.integrations.linear.actions.connect")]})]})})]})})},Mr=[{id:"opencode-claude",packageName:"@openchamber/opencode-claude",providerId:"claude-code",nameKey:"settings.integrations.thirdParty.opencodeClaude.name",descriptionKey:"settings.integrations.thirdParty.opencodeClaude.description",homepage:"https://github.com/openchamber/opencode-claude"}],Ej=(t,e)=>t===e||t.startsWith(`${e}@`);function Dr(t,e,a){const n=t.filter(u=>Ej(u.spec,e)),o=n.filter(u=>u.scope==="user"),i=n.filter(u=>u.scope==="project"),r=o.length===1?o[0]:null,l=a[r?.spec??e]??a[e]??null;return{userEntry:r,userEntryIsAmbiguous:o.length>1,projectEntries:i,registry:l}}function rl(t,e){return e?.kind!=="npm-ok"||e.name!==t||!e.latestVersion?null:`${t}@${e.latestVersion}`}function pd(t,e){if(t.userEntryIsAmbiguous)return"manage";if(!t.userEntry)return"install";const a=rl(e,t.registry);return a&&a!==t.userEntry.spec?"update":"setup"}function Mj(t,e={}){const a=t.registry?.kind==="npm-ok"?t.registry.latestVersion:null;return t.userEntryIsAmbiguous?{status:"ambiguous",latestVersion:a}:e.restartRequired?{status:"restart-required",latestVersion:a}:e.providerUnavailable?{status:"provider-unavailable",latestVersion:a}:e.registryUnavailable?{status:"registry-unavailable",latestVersion:a}:t.userEntry?t.registry?.kind==="npm-ok"&&t.registry.currentVersion===t.registry.latestVersion?{status:"installed-version",latestVersion:a}:t.registry?.kind==="npm-ok"&&t.registry.currentVersion===null?{status:"unpinned",latestVersion:a}:t.registry?.kind==="npm-ok"&&a?{status:"update-available",latestVersion:a}:{status:"installed",latestVersion:a}:{status:"not-installed",latestVersion:a}}const Dj={success:"bg-[var(--status-success)]/15 text-[var(--status-success)]",warning:"bg-[var(--status-warning)]/15 text-[var(--status-warning)]",neutral:"bg-[var(--surface-muted)] text-muted-foreground"},Qu=t=>{const e=$e.c(33),{settingsItem:a,logo:n,name:o,description:i,status:r,statusTone:l,open:u,onOpenChange:m,children:d}=t;let f;e[0]!==n?(f=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:n}),e[0]=n,e[1]=f):f=e[1];let g;e[2]!==o?(g=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:o}),e[2]=o,e[3]=g):g=e[3];let p;e[4]!==i?(p=s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:i}),e[4]=i,e[5]=p):p=e[5];let h;e[6]!==g||e[7]!==p?(h=s.jsxs("div",{className:"min-w-0 flex-1",children:[g,p]}),e[6]=g,e[7]=p,e[8]=h):h=e[8];const w=Dj[l];let b;e[9]!==w?(b=Me("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",w),e[9]=w,e[10]=b):b=e[10];let k;e[11]!==r||e[12]!==b?(k=s.jsx("span",{"aria-live":"polite",className:b,children:r}),e[11]=r,e[12]=b,e[13]=k):k=e[13];const v=u&&"rotate-180";let S;e[14]!==v?(S=Me("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",v),e[14]=v,e[15]=S):S=e[15];let y;e[16]!==S?(y=s.jsx(J,{name:"arrow-down-s",className:S}),e[16]=S,e[17]=y):y=e[17];let N;e[18]!==f||e[19]!==y||e[20]!==h||e[21]!==k?(N=s.jsxs(Qs,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-start hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[f,h,k,y]}),e[18]=f,e[19]=y,e[20]=h,e[21]=k,e[22]=N):N=e[22];let x;e[23]!==d?(x=s.jsx(Ys,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:d}),e[23]=d,e[24]=x):x=e[24];let I;e[25]!==a||e[26]!==N||e[27]!==x?(I=s.jsxs("div",{"data-settings-item":a,className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[N,x]}),e[25]=a,e[26]=N,e[27]=x,e[28]=I):I=e[28];let j;return e[29]!==m||e[30]!==u||e[31]!==I?(j=s.jsx(Js,{open:u,onOpenChange:m,children:I}),e[29]=m,e[30]=u,e[31]=I,e[32]=j):j=e[32],j},Rj=t=>t.requiresManualRestart===!0||t.reloadFailed===!0,Fj=({divider:t=!0})=>{const{t:e}=ze(),a=Us(),n=c.useCallback(()=>{oe.getState().requestSettingsJump("plugins")},[]),o=c.useCallback(async T=>{if(await rt.getState().loadProviders({directory:a,source:"settings:third-party-provider-setup"}),!_d(rt.getState(),a).some(B=>B.id===T))return!1;const E=oe.getState();return E.setSettingsProvidersOpenRequested(T),E.requestSettingsJump("providers"),!0},[a]),{entries:i,registryInfo:r,loadPlugins:l,loadRegistryInfo:u,createEntry:m,updateEntry:d,deleteEntry:f}=Lt(Ms(T=>({entries:T.entries,registryInfo:T.registryInfo,loadPlugins:T.loadPlugins,loadRegistryInfo:T.loadRegistryInfo,createEntry:T.createEntry,updateEntry:T.updateEntry,deleteEntry:T.deleteEntry}))),[g,p]=c.useState(!1),[h,w]=c.useState(null),[b,k]=c.useState(()=>new Set),[v,S]=c.useState(()=>new Set),[y,N]=c.useState(null),[x,I]=c.useState(()=>new Set),j=c.useCallback(async()=>{if(!await l({force:!0})){p(!0);return}const O=Lt.getState().entries,E=new Set(Mr.map(_=>_.packageName));for(const _ of O)Mr.some(H=>_.spec===H.packageName||_.spec.startsWith(`${H.packageName}@`))&&E.add(_.spec);const B=await u({specs:[...E],force:!0});p(!B)},[l,u]);c.useEffect(()=>{j()},[j]);const D=c.useCallback((T,O)=>{k(E=>{const B=new Set(E);return O?B.add(T):B.delete(T),B})},[]),C=c.useCallback((T,O)=>{S(E=>{const B=new Set(E);return O?B.add(T):B.delete(T),B})},[]),P=c.useCallback(async(T,O,E)=>{w({pluginId:T.id,action:O});try{const B=await E();if(!B.ok){W.error(e("settings.integrations.thirdParty.toast.actionFailed"));return}C(T.id,!1);const _=Rj(B);D(T.id,_);const H=_?{description:e("settings.integrations.thirdParty.toast.restartRequired")}:void 0;O==="install"?W.success(e("settings.integrations.thirdParty.toast.installed",{name:e(T.nameKey)}),H):O==="update"?W.success(e("settings.integrations.thirdParty.toast.updated",{name:e(T.nameKey)}),H):W.success(e("settings.integrations.thirdParty.toast.removed",{name:e(T.nameKey)}),H),await j()}finally{w(null)}},[j,C,D,e]),A=c.useCallback(async T=>{const O=Dr(i,T.packageName,r),E=pd(O,T.packageName);if(E==="manage"){n();return}if(E==="setup"){w({pluginId:T.id,action:E});try{const _=await o(T.providerId);C(T.id,!_),_?D(T.id,!1):W.error(e("settings.integrations.thirdParty.toast.providerUnavailable"))}finally{w(null)}return}const B=rl(T.packageName,O.registry);if(!B){p(!0);return}if(E==="install"){await P(T,"install",()=>m({spec:B,scope:"user"}));return}O.userEntry&&await P(T,"update",()=>d(O.userEntry.id,{spec:B}))},[m,i,n,o,r,P,C,D,e,d]),R=c.useCallback(async()=>{const T=y;if(!T)return;const O=Dr(i,T.packageName,r);if(!O.userEntry||O.userEntryIsAmbiguous){N(null),n();return}N(null),await P(T,"remove",()=>f(O.userEntry.id))},[f,i,n,r,y,P]),K=c.useCallback((T,O)=>{I(E=>{const B=new Set(E);return O?B.add(T):B.delete(T),B})},[]),F=T=>{const O=Dr(i,T.packageName,r),E=pd(O,T.packageName),B=rl(T.packageName,O.registry),_=h?.pluginId===T.id,H=b.has(T.id),ne=v.has(T.id),z=g||O.registry?.kind==="npm-network",$=_||H&&E!=="setup"||(E==="install"||E==="update")&&(z||!B),V=Mj(O,{registryUnavailable:z,restartRequired:H,providerUnavailable:ne});let G;switch(V.status){case"installed-version":G=V.latestVersion?e("settings.integrations.thirdParty.status.installedVersion",{version:V.latestVersion}):e("settings.integrations.thirdParty.status.installed");break;case"update-available":G=V.latestVersion?e("settings.integrations.thirdParty.status.updateAvailable",{version:V.latestVersion}):e("settings.integrations.thirdParty.status.unpinned");break;case"not-installed":G=e("settings.integrations.thirdParty.status.notInstalled");break;case"installed":G=e("settings.integrations.thirdParty.status.installed");break;case"unpinned":G=e("settings.integrations.thirdParty.status.unpinned");break;case"ambiguous":G=e("settings.integrations.thirdParty.status.ambiguous");break;case"restart-required":G=e("settings.integrations.thirdParty.status.restartRequired");break;case"registry-unavailable":G=e("settings.integrations.thirdParty.status.registryUnavailable");break;case"provider-unavailable":G=e("settings.integrations.thirdParty.status.providerUnavailable");break}const ee=V.status==="installed-version"?"success":V.status==="update-available"||V.status==="ambiguous"||V.status==="restart-required"||V.status==="registry-unavailable"||V.status==="provider-unavailable"?"warning":"neutral",ae={install:e("settings.integrations.thirdParty.actions.install"),update:e("settings.integrations.thirdParty.actions.update"),setup:e("settings.integrations.thirdParty.actions.setup"),manage:e("settings.integrations.thirdParty.actions.managePlugins")}[E],X=x.has(T.id);return s.jsx(Qu,{settingsItem:`integrations.third-party.${T.id}`,logo:s.jsx(an,{providerId:T.providerId,alt:"",className:"size-5"}),name:e(T.nameKey),description:e(T.descriptionKey),status:G,statusTone:ee,open:X,onOpenChange:Q=>K(T.id,Q),children:s.jsxs("div",{className:"space-y-3",children:[O.projectEntries.length>0?s.jsx("p",{className:"text-xs text-muted-foreground",children:e("settings.integrations.thirdParty.status.projectInstalled")}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(q,{type:"button",size:"sm",variant:E==="manage"?"outline":"default",onClick:()=>{A(T)},disabled:$,children:[_?s.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}):E==="setup"?s.jsx(J,{name:"plug-2",className:"size-3.5"}):null,ae]}),s.jsxs(q,{type:"button",size:"sm",variant:"secondary",onClick:()=>{ks(T.homepage)},children:[s.jsx(J,{name:"external-link",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.docs")]}),O.userEntry&&!O.userEntryIsAmbiguous?s.jsxs(q,{type:"button",size:"sm",variant:"destructive",onClick:()=>N(T),disabled:_,children:[s.jsx(J,{name:"delete-bin",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.remove")]}):null]})]})},T.id)};return s.jsxs(s.Fragment,{children:[s.jsx(He,{title:e("settings.integrations.thirdParty.title"),info:e("settings.integrations.thirdParty.info"),divider:t,settingsItem:"integrations.third-party",contentClassName:"space-y-3",children:Mr.map(F)}),s.jsx(Kt,{open:y!==null,onOpenChange:T=>!T&&N(null),children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:e("settings.integrations.thirdParty.dialog.remove.title")}),s.jsx(Vt,{children:e("settings.integrations.thirdParty.dialog.remove.description",{name:y?e(y.nameKey):""})})]}),s.jsxs(ts,{children:[s.jsx(q,{type:"button",size:"sm",variant:"ghost",onClick:()=>N(null),children:e("settings.common.actions.cancel")}),s.jsx(q,{type:"button",size:"sm",variant:"destructive",onClick:()=>{R()},children:e("settings.integrations.thirdParty.actions.remove")})]})]})})]})},ll=t=>t==="invalid-path"?"settings.extensions.toast.invalidPath":t==="invalid-url"?"settings.extensions.toast.invalidUrl":t==="not-found"?"settings.extensions.toast.notFound":t==="invalid-manifest"?"settings.extensions.toast.invalidManifest":t==="reserved-id"?"settings.extensions.toast.reservedId":t==="id-taken"?"settings.extensions.toast.idTaken":t==="already-installed"?"settings.extensions.toast.alreadyInstalled":t==="missing-build"?"settings.extensions.toast.missingBuild":t==="host-too-old"?"settings.extensions.toast.hostTooOld":t==="clone-failed"?"settings.extensions.toast.cloneFailed":t==="clone-auth-failed"?"settings.extensions.toast.cloneNeedsSignIn":t==="extract-failed"?"settings.extensions.toast.extractFailed":t==="too-large"?"settings.extensions.toast.zipTooLarge":t==="enterprise-mode"?"settings.extensions.toast.enterpriseMode":t==="unreadable"?"settings.extensions.toast.installedUnreadable":"settings.extensions.toast.failed",Yu=t=>t==="not-git"?"settings.extensions.toast.notGit":t==="enterprise-mode"?"settings.extensions.toast.enterpriseUpdate":t==="clone-failed"?"settings.extensions.toast.cloneFailed":t==="clone-auth-failed"?"settings.extensions.toast.cloneNeedsSignIn":t==="invalid-manifest"?"settings.extensions.toast.invalidManifest":t==="missing-build"?"settings.extensions.toast.missingBuild":t==="swap-failed"?"settings.extensions.toast.swapFailed":t==="not-found"?"settings.extensions.toast.notFound":"settings.extensions.toast.updateFailed",Oj=ss({error:Cl(["invalid-path","invalid-url","not-found","invalid-manifest","id-taken","already-installed","missing-build","host-too-old","bundled","reserved-id","clone-failed","clone-auth-failed","extract-failed","too-large","enterprise-mode"]),required:St().trim().min(1).max(64).optional(),id:St().trim().min(1).max(128).optional()}),Lj=t=>{const e=t.trim();if(!e)return{ok:!1,code:"invalid-path"};if(e.slice(0,8).toLowerCase()==="https://")return{ok:!0,request:{url:e}};if(e.slice(0,6).toLowerCase()==="ssh://"||/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+:[^\s]+$/.test(e))return{ok:!0,request:{url:e}};const a=/^[a-zA-Z]:[\\/]/.test(e);return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!a?{ok:!1,code:"invalid-url"}:e.startsWith("/")||a||e.startsWith("\\\\")?{ok:!0,request:{path:e}}:{ok:!1,code:"invalid-path"}},Zu=async t=>{try{const e=Oj.safeParse(JSON.parse(await t.text()));return e.success?e.data.error==="host-too-old"&&e.data.required&&e.data.id?{code:"host-too-old",required:e.data.required,id:e.data.id}:e.data.error==="host-too-old"&&e.data.required?{code:"host-too-old",required:e.data.required}:e.data.id?{code:e.data.error,id:e.data.id}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},Xu=async(t,e)=>{if(!t.ok)return{ok:!1,...await Zu(t),diagnostic:{method:"POST",path:e,kind:"http",status:t.status}};const a=await t.text().catch(()=>null),n=a===null?null:Ep(a);return n==="unreadable"?{ok:!1,code:"unreadable"}:n?{ok:!0,guest:n,replaced:t.status===200}:{ok:!1,code:"failed",diagnostic:{method:"POST",path:e,kind:"invalid-response",status:t.status}}},em=async(t,e={})=>{const a=Lj(t);if(!a.ok)return a;const n={...a.request};e.replace&&(n.replace=!0),"url"in n&&e.gitIdentityId&&(n.gitIdentityId=e.gitIdentityId);try{const o=await Rt("/api/guests",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return await Xu(o,"/api/guests")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests",kind:"network"}}}},Kj=async(t,e={})=>{try{const a=await Rt("/api/guests/upload",{method:"POST",query:{replace:e.replace?"true":void 0,name:t.name||void 0},headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},body:t});return await Xu(a,"/api/guests/upload")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests/upload",kind:"network"}}}},tm=async t=>{const e=vs.getState(),a=Qt(),n=e.runtimeKey===a?e.guests.find(o=>o.id===t)?.storageId:void 0;try{const o=await Rt(`/api/guests/${t}`,{method:"DELETE"});return o.status===204?(n&&globalThis.indexedDB&&await Tp({runtimeKey:a,guestId:t,storageId:n}).catch(()=>{console.warn("Could not clear local extension preferences.")}),{ok:!0}):{ok:!1,code:(await Zu(o)).code}}catch{return{ok:!1,code:"failed"}}},sm=async(t,e)=>{try{return(await Rt(`/api/guests/${t}/enabled`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok}catch{return!1}},zj=async(t,e)=>{try{return(await Rt(`/api/guests/${t}/capabilities`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({granted:e})})).ok}catch{return!1}},Uj=ss({updates:En(St().min(1),Mp)}),$j=ss({error:Cl(["not-git","clone-failed","clone-auth-failed","invalid-manifest","missing-build","host-too-old","swap-failed","not-found","enterprise-mode"]),required:St().trim().min(1).max(64).optional()}),gd=async t=>{try{const e=await Rt("/api/guests/updates/check",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({force:t})});if(!e.ok)return{ok:!1};const a=Uj.safeParse(JSON.parse(await e.text()));return a.success?{ok:!0,updates:a.data.updates}:{ok:!1}}catch{return{ok:!1}}},Bj=async t=>{try{const e=$j.safeParse(JSON.parse(await t.text()));return e.success?e.data.required?{code:e.data.error,required:e.data.required}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},nm=async t=>{try{const e=await Rt(`/api/guests/${t}/update`,{method:"POST",headers:{Accept:"application/json"}});if(!e.ok){const n=await Bj(e);return n.required?{ok:!1,code:n.code,required:n.required}:{ok:!1,code:n.code}}const a=Dp(await e.text());return a?{ok:!0,guest:a}:{ok:!1,code:"failed"}}catch{return{ok:!1,code:"failed"}}},_j={guestId:"excalidraw",gitUrl:"https://github.com/openchamber/openchamber-excalidraw",homepage:"https://github.com/openchamber/openchamber-excalidraw",nameKey:"settings.integrations.extensionCatalog.excalidraw.name",descriptionKey:"settings.integrations.extensionCatalog.excalidraw.description",logoFileName:"drawing.excalidraw"},Vj=[_j],Hj=(t,e)=>{const a=t.find(n=>n.id===e.guestId);return a?a.enterpriseBlocked?.length?{kind:"blocked",guest:a}:Wa(a)?{kind:"needs-approval",guest:a}:a.enabled===!1?{kind:"paused",guest:a}:a.update?{kind:"update-available",guest:a,version:a.update.version}:{kind:"installed",guest:a}:{kind:"not-installed"}},qj=({divider:t=!0})=>{const{t:e}=ze(),a=vs(v=>v.guests),n=vs(v=>v.status),[o,i]=c.useState(null),[r,l]=c.useState(()=>new Set),[u,m]=c.useState(null);c.useEffect(()=>{en()},[]);const d=c.useCallback(()=>{oe.getState().requestSettingsJump("extensions")},[]),f=c.useCallback(async(v,S,y)=>{const N=Qt();i({guestId:v.guestId,action:S});try{await y(),Qt()===N&&await en()}finally{i(null)}},[]),g=v=>f(v,"install",async()=>{const S=await em(v.gitUrl);if(!S.ok){W.error(S.code==="host-too-old"&&S.required?e("settings.extensions.toast.hostTooOld",{version:S.required}):e(ll(S.code)));return}W.success(e("settings.integrations.thirdParty.toast.installed",{name:e(v.nameKey)})),Wa(S.guest)&&d()}),p=v=>f(v,"update",async()=>{const S=await nm(v.guestId);if(!S.ok){W.error(S.code==="host-too-old"&&S.required?e("settings.extensions.toast.hostTooOld",{version:S.required}):e(Yu(S.code)));return}wi(v.guestId),W.success(e("settings.integrations.thirdParty.toast.updated",{name:e(v.nameKey)})),Wa(S.guest)&&d()}),h=v=>f(v,"enable",async()=>{if(!await sm(v.guestId,!0)){W.error(e("settings.integrations.extensionCatalog.toast.enableFailed",{name:e(v.nameKey)}));return}W.success(e("settings.integrations.extensionCatalog.toast.enabled",{name:e(v.nameKey)}))}),w=async()=>{const v=u;v&&(m(null),await f(v,"remove",async()=>{if(!(await tm(v.guestId)).ok){W.error(e("settings.integrations.thirdParty.toast.actionFailed"));return}wi(v.guestId),W.success(e("settings.integrations.thirdParty.toast.removed",{name:e(v.nameKey)}))}))},b=v=>{switch(v.kind){case"not-installed":return{status:e("settings.integrations.thirdParty.status.notInstalled"),tone:"neutral"};case"blocked":return{status:e("settings.extensions.status.enterpriseBlocked"),tone:"warning"};case"needs-approval":return{status:e("settings.integrations.extensionCatalog.status.needsApproval"),tone:"warning"};case"paused":return{status:e("settings.integrations.extensionCatalog.status.paused"),tone:"neutral"};case"update-available":return{status:e("settings.integrations.thirdParty.status.updateAvailable",{version:v.version}),tone:"warning"};case"installed":return{status:v.guest.version?e("settings.integrations.thirdParty.status.installedVersion",{version:v.guest.version}):e("settings.integrations.thirdParty.status.installed"),tone:"success"}}},k=v=>{const S=Hj(a,v),y=n==="idle"||n==="loading",{status:N,tone:x}=y?{status:e("common.loading"),tone:"neutral"}:b(S),I=o?.guestId===v.guestId||y,j=r.has(v.guestId),D=s.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}),C=S.kind==="not-installed"?{label:e("settings.integrations.thirdParty.actions.install"),onClick:()=>{g(v)},variant:"default"}:S.kind==="update-available"?{label:e("settings.integrations.thirdParty.actions.update"),onClick:()=>{p(v)},variant:"default"}:S.kind==="paused"?{label:e("settings.integrations.extensionCatalog.actions.enable"),onClick:()=>{h(v)},variant:"default"}:S.kind==="needs-approval"||S.kind==="blocked"?{label:e("settings.integrations.extensionCatalog.actions.manage"),onClick:d,variant:"outline"}:null;return s.jsx(Qu,{settingsItem:`integrations.extensions.${v.guestId}`,logo:s.jsx(Rp,{filePath:v.logoFileName,className:"size-5"}),name:e(v.nameKey),description:e(v.descriptionKey),status:N,statusTone:x,open:j,onOpenChange:P=>l(A=>{const R=new Set(A);return P?R.add(v.guestId):R.delete(v.guestId),R}),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[C?s.jsxs(q,{type:"button",size:"sm",variant:C.variant,onClick:C.onClick,disabled:I,children:[I?D:null,C.label]}):null,s.jsxs(q,{type:"button",size:"sm",variant:"secondary",onClick:()=>{ks(v.homepage)},children:[s.jsx(J,{name:"external-link",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.docs")]}),S.kind!=="not-installed"?s.jsxs(q,{type:"button",size:"sm",variant:"destructive",onClick:()=>m(v),disabled:I,children:[s.jsx(J,{name:"delete-bin",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.remove")]}):null]})},v.guestId)};return n==="unsupported"?null:s.jsxs(s.Fragment,{children:[s.jsx(He,{title:e("settings.integrations.extensionCatalog.title"),info:e("settings.integrations.extensionCatalog.info"),divider:t,settingsItem:"integrations.extensions",contentClassName:"space-y-3",children:Vj.map(k)}),s.jsx(Kt,{open:u!==null,onOpenChange:v=>!v&&m(null),children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(_t,{children:e("settings.integrations.extensionCatalog.dialog.remove.title")}),s.jsx(Vt,{children:e("settings.integrations.extensionCatalog.dialog.remove.description",{name:u?e(u.nameKey):""})})]}),s.jsxs(ts,{children:[s.jsx(q,{type:"button",size:"sm",variant:"ghost",onClick:()=>m(null),children:e("settings.common.actions.cancel")}),s.jsx(q,{type:"button",size:"sm",variant:"destructive",onClick:()=>{w()},children:e("settings.integrations.thirdParty.actions.remove")})]})]})})]})},Wj=()=>{const t=$e.c(26),{t:e}=ze();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=cs(),t[0]=a):a=t[0];const n=!a;let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o=cs(),t[1]=o):o=t[1];const i=!o,r=!!la()?.linear,l=vs(Gj),u=vs(Jj);let m,d,f,g,p,h;if(t[2]!==l||t[3]!==u||t[4]!==e){const S=!cs()&&!ru()?l.filter(Qj):[];d=n||i||r||S.length>0,m=Yt,t[11]!==e?(f=e("settings.page.integrations.title"),t[11]=e,t[12]=f):f=t[12],t[13]!==e?(g=e("settings.page.integrations.description"),t[13]=e,t[14]=g):g=t[14],p=!0,h=d?s.jsxs(He,{title:e("settings.integrations.firstParty.title"),info:e("settings.integrations.firstParty.info"),divider:!1,settingsItem:"integrations.first-party",contentClassName:"space-y-3",children:[n?s.jsx(uj,{}):null,i?s.jsx(hj,{}):null,r?s.jsx(Tj,{}):null,S.map(y=>s.jsx(qu,{guest:y},`${u}:${y.id}`))]}):null,t[2]=l,t[3]=u,t[4]=e,t[5]=m,t[6]=d,t[7]=f,t[8]=g,t[9]=p,t[10]=h}else m=t[5],d=t[6],f=t[7],g=t[8],p=t[9],h=t[10];let w;t[15]!==d?(w=s.jsx(Fj,{divider:d}),t[15]=d,t[16]=w):w=t[16];let b,k;t[17]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(qj,{}),k=s.jsx(nj,{}),t[17]=b,t[18]=k):(b=t[17],k=t[18]);let v;return t[19]!==m||t[20]!==f||t[21]!==g||t[22]!==p||t[23]!==h||t[24]!==w?(v=s.jsxs(m,{title:f,description:g,showSaveStatus:p,children:[h,w,b,k]}),t[19]=m,t[20]=f,t[21]=g,t[22]=p,t[23]=h,t[24]=w,t[25]=v):v=t[25],v};function Gj(t){return t.guests}function Jj(t){return t.runtimeKey}function Qj(t){return t.source==="bundled"&&t.integration&&yl(t)}const fi="__default__",Yj=500,Zj=(t,e)=>{const a=n=>JSON.stringify({...n,categories:n.categories.map(o=>({...o,name:o.name.trim(),description:o.description.trim()}))});return a(t)===a(e)},Xj=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,64),am=(t,e)=>{const a=$e.c(7),n=rt(sk);let o;e:{if(!t||!e){let r;a[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],a[0]=r):r=a[0],o=r;break e}let i;if(a[1]!==e||a[2]!==t||a[3]!==n){let r;a[5]!==t?(r=m=>m.id===t,a[5]=t,a[6]=r):r=a[6];const u=n.find(r)?.models.find(m=>m.id===e);i=zd(u),a[1]=e,a[2]=t,a[3]=n,a[4]=i}else i=a[4];o=i}return o},im=(t,e)=>t&&(e.length===0||e.includes(t))?t:null,om=t=>{const e=$e.c(49),{providerID:a,modelID:n,value:o,onChange:i,ariaLabel:r,className:l}=t,{t:u}=ze(),m=am(a,n);let d,f,g,p,h,w,b,k,v,S;if(e[0]!==r||e[1]!==l||e[2]!==i||e[3]!==u||e[4]!==o||e[5]!==m){const P=im(o,m)??fi;let A;e[16]!==u?(A=R=>R===fi?u("settings.routing.thinking.default"):R.charAt(0).toUpperCase()+R.slice(1),e[16]=u,e[17]=A):A=e[17],p=A,g=Tt,k=P,e[18]!==i?(v=R=>i(R===fi?null:R),e[18]=i,e[19]=v):v=e[19],S=m.length===0,f=Pt,e[20]!==l?(w=Me(nn,l),e[20]=l,e[21]=w):w=e[21],b=r,d=Ut,h=p(P),e[0]=r,e[1]=l,e[2]=i,e[3]=u,e[4]=o,e[5]=m,e[6]=d,e[7]=f,e[8]=g,e[9]=p,e[10]=h,e[11]=w,e[12]=b,e[13]=k,e[14]=v,e[15]=S}else d=e[6],f=e[7],g=e[8],p=e[9],h=e[10],w=e[11],b=e[12],k=e[13],v=e[14],S=e[15];let y;e[22]!==d||e[23]!==h?(y=s.jsx(d,{children:h}),e[22]=d,e[23]=h,e[24]=y):y=e[24];let N;e[25]!==f||e[26]!==w||e[27]!==b||e[28]!==y?(N=s.jsx(f,{className:w,"aria-label":b,children:y}),e[25]=f,e[26]=w,e[27]=b,e[28]=y,e[29]=N):N=e[29];let x;e[30]!==p?(x=p(fi),e[30]=p,e[31]=x):x=e[31];let I;e[32]!==x?(I=s.jsx(ot,{value:fi,children:x}),e[32]=x,e[33]=I):I=e[33];let j;if(e[34]!==p||e[35]!==m){let P;e[37]!==p?(P=A=>s.jsx(ot,{value:A,children:p(A)},A),e[37]=p,e[38]=P):P=e[38],j=m.map(P),e[34]=p,e[35]=m,e[36]=j}else j=e[36];let D;e[39]!==I||e[40]!==j?(D=s.jsxs(At,{children:[I,j]}),e[39]=I,e[40]=j,e[41]=D):D=e[41];let C;return e[42]!==g||e[43]!==D||e[44]!==k||e[45]!==v||e[46]!==S||e[47]!==N?(C=s.jsxs(g,{value:k,onValueChange:v,disabled:S,children:[N,D]}),e[42]=g,e[43]=D,e[44]=k,e[45]=v,e[46]=S,e[47]=N,e[48]=C):C=e[48],C},ek=t=>{const e=$e.c(52),{category:a,expanded:n,onToggle:o,onChange:i,onReset:r,onRemove:l}=t,{t:u}=ze(),m=am(a.model?.providerID,a.model?.modelID);let d;e[0]!==a.variant||e[1]!==m?(d=im(a.variant,m),e[0]=a.variant,e[1]=m,e[2]=d):d=e[2];const f=d;let g;e[3]!==a.model||e[4]!==f||e[5]!==u?(g=a.model?`${a.model.modelID}${f?` / ${f}`:""}`:u("settings.routing.model.useFallback"),e[3]=a.model,e[4]=f,e[5]=u,e[6]=g):g=e[6];const p=g;let h;e[7]!==a.agent||e[8]!==p?(h=[p,a.agent].filter(Boolean),e[7]=a.agent,e[8]=p,e[9]=h):h=e[9];const w=h.join(" · "),b=!a.enabled&&"opacity-60";let k;e[10]!==b?(k=Me("py-1",b),e[10]=b,e[11]=k):k=e[11];const v=n?"arrow-down-s":"arrow-right-s";let S;e[12]!==v?(S=s.jsx(J,{name:v,className:"size-4 flex-shrink-0 text-muted-foreground"}),e[12]=v,e[13]=S):S=e[13];const y=a.name||a.id;let N;e[14]!==y?(N=s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:y}),e[14]=y,e[15]=N):N=e[15];let x;e[16]!==w?(x=s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:w}),e[16]=w,e[17]=x):x=e[17];let I;e[18]!==n||e[19]!==o||e[20]!==x||e[21]!==S||e[22]!==N?(I=s.jsxs("button",{type:"button",onClick:o,"aria-expanded":n,className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-1.5 text-start hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[S,N,x]}),e[18]=n,e[19]=o,e[20]=x,e[21]=S,e[22]=N,e[23]=I):I=e[23];const j=a.enabled;let D;e[24]!==i?(D=F=>i({enabled:F}),e[24]=i,e[25]=D):D=e[25];let C;e[26]!==a.name||e[27]!==u?(C=u("settings.routing.category.enabledAria",{name:a.name}),e[26]=a.name,e[27]=u,e[28]=C):C=e[28];let P;e[29]!==a.enabled||e[30]!==D||e[31]!==C?(P=s.jsx(ra,{checked:j,onCheckedChange:D,"aria-label":C}),e[29]=a.enabled,e[30]=D,e[31]=C,e[32]=P):P=e[32];let A;e[33]!==I||e[34]!==P?(A=s.jsxs("div",{className:"flex items-center gap-2",children:[I,P]}),e[33]=I,e[34]=P,e[35]=A):A=e[35];let R;e[36]!==a.agent||e[37]!==a.description||e[38]!==a.model?.modelID||e[39]!==a.model?.providerID||e[40]!==a.name||e[41]!==a.variant||e[42]!==n||e[43]!==i||e[44]!==l||e[45]!==r||e[46]!==u?(R=n?s.jsxs("div",{className:"space-y-4 px-1 pb-4 pt-2",children:[s.jsxs(Nn,{children:[s.jsx(Mt,{label:u("settings.routing.category.name"),controlClassName:"max-w-none",children:s.jsx(Ve,{value:a.name,onChange:F=>i({name:F.target.value}),"aria-label":u("settings.routing.category.name"),className:"h-8 w-full rounded-md px-3",maxLength:60})}),s.jsx(Mt,{label:u("settings.routing.category.agent"),info:u("settings.routing.category.agentInfo"),controlClassName:"max-w-none",children:s.jsx(gl,{agentName:a.agent??"",onChange:F=>i({agent:F||null}),filter:nk,className:Me(sn,"w-full")})}),s.jsx(Mt,{label:u("settings.routing.category.model"),info:u("settings.routing.category.modelInfo"),controlClassName:"max-w-none",children:s.jsx(oa,{providerId:a.model?.providerID??"",modelId:a.model?.modelID??"",onChange:(F,T)=>i({model:{providerID:F,modelID:T},variant:null}),className:Me(sn,"w-full"),placeholder:u("settings.routing.model.useFallback")})}),s.jsx(Mt,{label:u("settings.routing.category.thinking"),controlClassName:"max-w-none",children:s.jsx(om,{providerID:a.model?.providerID,modelID:a.model?.modelID,value:a.variant,onChange:F=>i({variant:F}),ariaLabel:u("settings.routing.category.thinking"),className:"w-full"})})]}),s.jsx(Mt,{label:u("settings.routing.category.description"),info:u("settings.routing.category.descriptionInfo"),controlClassName:"max-w-none",children:s.jsx(ws,{value:a.description,onChange:F=>i({description:F.target.value}),"aria-label":u("settings.routing.category.description"),rows:5,maxLength:2e3,className:"w-full"})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r?s.jsx(q,{size:"sm",variant:"outline",onClick:r,children:u("settings.routing.category.reset")}):null,s.jsx(q,{size:"sm",variant:"ghost",onClick:l,children:u("settings.routing.category.remove")})]})]}):null,e[36]=a.agent,e[37]=a.description,e[38]=a.model?.modelID,e[39]=a.model?.providerID,e[40]=a.name,e[41]=a.variant,e[42]=n,e[43]=i,e[44]=l,e[45]=r,e[46]=u,e[47]=R):R=e[47];let K;return e[48]!==A||e[49]!==R||e[50]!==k?(K=s.jsxs("div",{className:k,children:[A,R]}),e[48]=A,e[49]=R,e[50]=k,e[51]=K):K=e[51],K},tk=()=>{const{t}=ze(),e=Wt(T=>T.available),a=Wt(T=>T.autoReady),n=Wt(T=>T.config),o=Wt(T=>T.builtins),i=Wt(T=>T.loaded),r=Wt(T=>T.loadError),l=Wt(T=>T.load),u=Wt(T=>T.saveConfig),[m,d]=c.useState(n),[f,g]=c.useState(""),[p,h]=c.useState(null),w=c.useRef(null),b=c.useRef(null),k=c.useRef(Promise.resolve()),v=c.useRef(0);c.useEffect(()=>{l()},[l]),c.useEffect(()=>{w.current||v.current>0||d(T=>T&&n&&Zj(n,T)?T:n)},[n]);const S=c.useCallback(()=>{const T=w.current;if(!T||(w.current=null,T.runtimeKey!==Qt()))return k.current;v.current+=1,es("saving");const O=k.current.then(async()=>{try{if(T.runtimeKey!==Qt()){es("saved");return}await u(T.config),es("saved")}catch{es("error")}finally{v.current-=1}});return k.current=O,O},[u]);c.useEffect(()=>()=>{b.current&&clearTimeout(b.current),S()},[S]);const y=rt(T=>T.settingsDefaultModel),N=rt(T=>T.settingsDefaultVariant),x=c.useRef(!1);c.useEffect(()=>{if(x.current||!i||!n||n.fallback)return;const T=Tn(y);!T||lu(T.providerId,T.modelId)||(x.current=!0,I(O=>O.fallback?O:{...O,fallback:{model:{providerID:T.providerId,modelID:T.modelId},variant:N??null}}))},[i,n,y,N]);const I=c.useCallback(T=>{d(O=>{if(!O)return O;const E=T(O);return w.current={config:E,runtimeKey:Qt()},b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{b.current=null,S()},Yj),E})},[S]),j=c.useCallback((T,O)=>{I(E=>({...E,categories:E.categories.map(B=>B.id===T?{...B,...O}:B)}))},[I]),D=()=>{const T=f.trim();if(!T||!m)return;const O=Xj(T)||`category-${Date.now()}`;let E=O,B=2;for(;m.categories.some(_=>_.id===E);)E=`${O}-${B++}`;I(_=>({..._,categories:[..._.categories,{id:E,builtin:!1,enabled:!0,name:T,description:"",model:null,variant:null,agent:null}]})),g(""),h(E)},C=T=>{const O=o.find(E=>E.id===T);O&&j(T,{name:O.name,description:O.description,model:null,variant:null,agent:null,enabled:!0})},P=T=>{const O=o.find(E=>E.id===T);O&&I(E=>({...E,categories:[...E.categories,{id:T,builtin:!0,enabled:!0,name:O.name,description:O.description,model:null,variant:null,agent:null}]}))},A=T=>{I(O=>({...O,categories:O.categories.filter(E=>E.id!==T)}))},R=m?.categories.filter(T=>T.enabled).length??0,K=o.filter(T=>!m?.categories.some(O=>O.id===T.id)),F=m?.enabled?m.fallback?R<2?t("settings.routing.status.tooFewCategories"):t(a?"settings.routing.status.ready":"settings.routing.status.notReady"):t("settings.routing.status.noFallback"):t("settings.routing.status.disabled");return s.jsxs(Yt,{title:t("settings.page.routing.title"),description:t("settings.page.routing.description"),showSaveStatus:!0,children:[r?s.jsx("p",{className:Cn,children:t("settings.routing.loadError",{error:r})}):null,!i||!m?null:e?s.jsxs(s.Fragment,{children:[s.jsx(He,{title:t("settings.routing.auto.title"),divider:!1,children:s.jsxs("div",{className:js,children:[s.jsx(zo,{}),s.jsxs("div",{className:bs,children:[s.jsx(it,{settingsItem:"routing.enabled",checked:m.enabled,onChange:T=>I(O=>({...O,enabled:T})),label:t("settings.routing.auto.enable"),ariaLabel:t("settings.routing.auto.enable"),info:t("settings.routing.auto.enableInfo")}),m.preserveCache===void 0?null:s.jsx(it,{settingsItem:"routing.preserve-cache",checked:m.preserveCache,onChange:T=>I(O=>({...O,preserveCache:T})),label:t("settings.routing.auto.preserveCache"),ariaLabel:t("settings.routing.auto.preserveCache"),info:t("settings.routing.auto.preserveCacheInfo")})]}),s.jsx("p",{className:Dt,children:F}),s.jsx(kt,{settingsItem:"routing.fallback-model",label:t("settings.routing.auto.fallbackModel"),info:t("settings.routing.auto.fallbackModelInfo"),children:s.jsx(oa,{providerId:m.fallback?.model.providerID??"",modelId:m.fallback?.model.modelID??"",onChange:(T,O)=>I(E=>({...E,fallback:{model:{providerID:T,modelID:O},variant:null}})),className:sn,placeholder:t("settings.routing.model.placeholder")})}),s.jsx(kt,{settingsItem:"routing.fallback-thinking",label:t("settings.routing.auto.fallbackThinking"),info:t("settings.routing.auto.fallbackThinkingInfo"),children:s.jsx(om,{providerID:m.fallback?.model.providerID,modelID:m.fallback?.model.modelID,value:m.fallback?.variant??null,onChange:T=>I(O=>O.fallback?{...O,fallback:{...O.fallback,variant:T}}:O),ariaLabel:t("settings.routing.auto.fallbackThinking")})})]})}),s.jsx(He,{title:t("settings.routing.categories.title"),children:s.jsxs("div",{className:js,children:[s.jsx("p",{className:Dt,children:t("settings.routing.categories.description")}),s.jsx("div",{className:"divide-y divide-border/40 border-y border-border/40",children:m.categories.map(T=>s.jsx(ek,{category:T,expanded:p===T.id,onToggle:()=>h(O=>O===T.id?null:T.id),onChange:O=>j(T.id,O),onReset:T.builtin?()=>C(T.id):null,onRemove:()=>A(T.id)},T.id))}),K.length>0?s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:K.map(T=>s.jsx(q,{size:"sm",variant:"outline",onClick:()=>P(T.id),children:t("settings.routing.category.restore",{name:T.name})},T.id))}):null,s.jsx(kt,{label:t("settings.routing.categories.addLabel"),settingsItem:"routing.add-category",children:s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(Ve,{value:f,onChange:T=>g(T.target.value),onKeyDown:T=>{T.key==="Enter"&&D()},placeholder:t("settings.routing.categories.addPlaceholder"),"aria-label":t("settings.routing.categories.addLabel"),className:"h-8 rounded-md px-3 min-w-0 flex-1",maxLength:60}),s.jsx(q,{size:"sm",variant:"outline",onClick:D,disabled:f.trim().length===0,children:t("settings.routing.categories.add")})]})})]})})]}):s.jsx("p",{className:Cn,children:t("settings.routing.unavailable")})]})};function sk(t){return t.providers}function nk(t){return ho(t.mode)}const ak={prompt:{icon:"chat-1",titleKey:"settings.extensions.capability.prompt",detailKey:"settings.extensions.capability.prompt.detail"},sessions:{icon:"git-branch",titleKey:"settings.extensions.capability.sessions",detailKey:"settings.extensions.capability.sessions.detail"},files:{icon:"file-text",titleKey:"settings.extensions.capability.files",detailKey:"settings.extensions.capability.files.detail"},model:{icon:"sparkling",titleKey:"settings.extensions.capability.model",detailKey:"settings.extensions.capability.model.detail"},shells:{icon:"terminal-box",titleKey:"settings.extensions.capability.shells",detailKey:"settings.extensions.capability.shells.detail"},conversation:{icon:"chat-history",titleKey:"settings.extensions.capability.conversation",detailKey:"settings.extensions.capability.conversation.detail"},filesystem:{icon:"hard-drive-2",titleKey:"settings.extensions.capability.filesystem",detailKey:"settings.extensions.capability.filesystem.detail"},service:{icon:"terminal",titleKey:"settings.extensions.capability.service",detailKey:"settings.extensions.capability.service.detail"},network:{icon:"plug",titleKey:"settings.extensions.capability.network",detailKey:"settings.extensions.capability.network.detail"},origins:{icon:"global",titleKey:"settings.extensions.capability.origins",detailKey:"settings.extensions.capability.origins.detail"}},ik=t=>{const e=$e.c(77),{guest:a,busy:n,onApprove:o,onDecline:i,onDismiss:r}=t,{t:l}=ze();let u;e[0]!==a?.capabilities.requested?(u=a?.capabilities.requested??[],e[0]=a?.capabilities.requested,e[1]=u):u=e[1];const m=u;let d;e[2]!==a?.filesystem?(d=a?.filesystem??[],e[2]=a?.filesystem,e[3]=d):d=e[3];const f=d;let g;e[4]!==a?.origins?(g=a?.origins??[],e[4]=a?.origins,e[5]=g):g=e[5];const p=g;let h;e[6]!==a?.service?.permissions?.exec?(h=a?.service?.permissions?.exec??[],e[6]=a?.service?.permissions?.exec,e[7]=h):h=e[7];const w=h;let b;e[8]!==a?.service?.permissions?.sockets?(b=a?.service?.permissions?.sockets??[],e[8]=a?.service?.permissions?.sockets,e[9]=b):b=e[9];const k=b,v=a?.service;let S;e[10]!==v?(S=Yd(v,"browser"),e[10]=v,e[11]=S):S=e[11];const y=S,N=a?.integration?.apiOrigin??null,x=a!==null;let I;e[12]!==n||e[13]!==r?(I=ee=>{!ee&&!n&&r()},e[12]=n,e[13]=r,e[14]=I):I=e[14];const j=a?.name??"";let D;e[15]!==l||e[16]!==j?(D=l("settings.extensions.dialog.approveTitle",{name:j}),e[15]=l,e[16]=j,e[17]=D):D=e[17];let C;e[18]!==D?(C=s.jsx(_t,{children:D}),e[18]=D,e[19]=C):C=e[19];const P=a?.name??"",A=a?.version?`v${a.version}`:"";let R;e[20]!==l||e[21]!==P||e[22]!==A?(R=l("settings.extensions.dialog.approveDescription",{name:P,version:A}),e[20]=l,e[21]=P,e[22]=A,e[23]=R):R=e[23];let K;e[24]!==R?(K=s.jsx(Vt,{children:R}),e[24]=R,e[25]=K):K=e[25];let F;e[26]!==C||e[27]!==K?(F=s.jsxs(Bt,{children:[C,K]}),e[26]=C,e[27]=K,e[28]=F):F=e[28];let T;if(e[29]!==N||e[30]!==f||e[31]!==p||e[32]!==y||e[33]!==m||e[34]!==w||e[35]!==k||e[36]!==l){let ee;e[38]!==N||e[39]!==f||e[40]!==p||e[41]!==y||e[42]!==w||e[43]!==k||e[44]!==l?(ee=ae=>{const X=ak[ae];return s.jsxs("li",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-muted)]",children:s.jsx(J,{name:X.icon,className:"size-4 text-foreground"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground",children:l(X.titleKey)}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:l(X.detailKey)}),ae==="filesystem"&&f.length>0?s.jsx("ul",{className:"mt-1 space-y-0.5",children:f.map(ok)}):null,ae==="origins"&&p.length>0?s.jsx("ul",{className:"mt-1 space-y-0.5",children:p.map(rk)}):null,ae==="network"&&N?s.jsxs("p",{className:"typography-meta mt-1 text-foreground",children:[l("settings.extensions.capability.service.sockets")," ",s.jsx("span",{className:"break-all font-mono",children:N})]}):null,ae==="service"&&w.length>0?s.jsxs("p",{className:"typography-meta mt-1 text-foreground",children:[l("settings.extensions.capability.service.runs")," ",s.jsx("span",{className:"break-all font-mono",children:w.join(", ")})]}):null,ae==="service"&&k.length>0?s.jsxs("p",{className:"typography-meta mt-0.5 text-foreground",children:[l("settings.extensions.capability.service.sockets")," ",s.jsx("span",{className:"break-all font-mono",children:k.join(", ")})]}):null,ae==="service"&&y?s.jsx("p",{className:"typography-meta mt-0.5 text-foreground",children:l("settings.extensions.capability.service.providesBrowser")}):null]})]},ae)},e[38]=N,e[39]=f,e[40]=p,e[41]=y,e[42]=w,e[43]=k,e[44]=l,e[45]=ee):ee=e[45],T=m.map(ee),e[29]=N,e[30]=f,e[31]=p,e[32]=y,e[33]=m,e[34]=w,e[35]=k,e[36]=l,e[37]=T}else T=e[37];let O;e[46]!==T?(O=s.jsx("ul",{className:"space-y-3",children:T}),e[46]=T,e[47]=O):O=e[47];let E;e[48]!==a||e[49]!==i?(E=()=>a&&i(a),e[48]=a,e[49]=i,e[50]=E):E=e[50];let B;e[51]!==l?(B=l("settings.extensions.dialog.decline"),e[51]=l,e[52]=B):B=e[52];let _;e[53]!==n||e[54]!==E||e[55]!==B?(_=s.jsx(q,{size:"sm",variant:"ghost",disabled:n,onClick:E,children:B}),e[53]=n,e[54]=E,e[55]=B,e[56]=_):_=e[56];let H;e[57]!==a||e[58]!==o?(H=()=>a&&o(a),e[57]=a,e[58]=o,e[59]=H):H=e[59];let ne;e[60]!==l?(ne=l("settings.extensions.dialog.approve"),e[60]=l,e[61]=ne):ne=e[61];let z;e[62]!==n||e[63]!==H||e[64]!==ne?(z=s.jsx(q,{size:"sm",disabled:n,onClick:H,children:ne}),e[62]=n,e[63]=H,e[64]=ne,e[65]=z):z=e[65];let $;e[66]!==_||e[67]!==z?($=s.jsxs(ts,{children:[_,z]}),e[66]=_,e[67]=z,e[68]=$):$=e[68];let V;e[69]!==F||e[70]!==O||e[71]!==$?(V=s.jsxs(zt,{className:"max-w-md",children:[F,O,$]}),e[69]=F,e[70]=O,e[71]=$,e[72]=V):V=e[72];let G;return e[73]!==V||e[74]!==x||e[75]!==I?(G=s.jsx(Kt,{open:x,onOpenChange:I,children:V}),e[73]=V,e[74]=x,e[75]=I,e[76]=G):G=e[76],G};function ok(t){return s.jsx("li",{className:"typography-meta break-all font-mono text-foreground",children:t},t)}function rk(t){return s.jsx("li",{className:"typography-meta break-all font-mono text-foreground",children:t},t)}const lk=t=>{if(t.source!=="git"||!t.origin?.url)return null;const e=t.origin.url.trim(),a=/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?([A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+):([^\s]+)$/.exec(e);try{const n=new URL(a?`ssh://${a[1]}/${a[2]}`:e);if(n.protocol!=="https:"&&n.protocol!=="ssh:")return null;const o=n.protocol==="ssh:"?new URL(`https://${n.hostname}${n.pathname}`):n;return o.username="",o.password="",o.search="",o.hash="",o.pathname=o.pathname.replace(/\/+$/,"").replace(/\.git$/i,""),o.pathname==="/"?null:o.href}catch{return null}},Rr=(t,e)=>{const a=`${t.method} ${t.path}`;return t.kind==="network"?`${a}: ${e("settings.extensions.request.noResponse")}`:t.kind==="invalid-response"?`${a}: ${e("settings.extensions.request.invalidResponse",{status:t.status})}`:`${a}: HTTP ${t.status}`},fd=t=>t.name.toLowerCase().endsWith(".zip"),ck=t=>t==="path"?"settings.extensions.source.path":t==="zip"?"settings.extensions.source.zip":t==="git"?"settings.extensions.source.git":"settings.extensions.source.bundled",dk=t=>{const e=(t.service?.socketBindings??[]).map(o=>o.resolved?`${o.id}=${o.resolved}`:`${o.id}?`),a=(t.service?.permissions?.sockets??[]).filter(o=>!(t.service?.socketBindings??[]).some(i=>i.id===o));return[...e,...a,...t.service?.permissions?.exec??[]].join(", ")},uk=t=>{const e=$e.c(27),{guest:a,binding:n,busy:o,onSaved:i}=t,{t:r}=ze(),[l,u]=c.useState(n.override??n.resolved??""),[m,d]=c.useState(!1),[f,g]=c.useState(!n.resolved);let p;e[0]!==n.override||e[1]!==n.resolved?(p=()=>{u(n.override??n.resolved??""),n.resolved||g(!0)},e[0]=n.override,e[1]=n.resolved,e[2]=p):p=e[2];let h;e[3]!==n.id||e[4]!==n.override||e[5]!==n.resolved?(h=[n.id,n.override,n.resolved],e[3]=n.id,e[4]=n.override,e[5]=n.resolved,e[6]=h):h=e[6],c.useEffect(p,h);let w;e[7]!==n.id||e[8]!==a.id||e[9]!==a.name||e[10]!==i||e[11]!==r?(w=async y=>{d(!0);const N=await Lp(a.id,n.id,y);if(d(!1),!N){W.error(r("settings.extensions.toast.socketSaveFailed"));return}W.success(r("settings.extensions.toast.socketSaved",{name:a.name})),g(!1),await i()},e[7]=n.id,e[8]=a.id,e[9]=a.name,e[10]=i,e[11]=r,e[12]=w):w=e[12];const b=w;let k;e[13]!==n.override||e[14]!==n.resolved?(k=()=>{u(n.override??n.resolved??""),n.resolved&&g(!1)},e[13]=n.override,e[14]=n.resolved,e[15]=k):k=e[15];const v=k;let S;return e[16]!==n.id||e[17]!==n.override||e[18]!==n.resolved||e[19]!==o||e[20]!==v||e[21]!==f||e[22]!==b||e[23]!==m||e[24]!==r||e[25]!==l?(S=s.jsx("div",{className:"space-y-1",children:f?s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(Ve,{value:l,onChange:y=>u(y.target.value),placeholder:r("settings.extensions.service.socket.path",{id:n.id}),"aria-label":r("settings.extensions.service.socket.path.aria",{id:n.id}),className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:o||m,autoFocus:!0}),s.jsx(q,{type:"button",variant:"ghost",size:"xs",disabled:o||m,"aria-label":r("settings.extensions.service.socket.save.aria",{id:n.id}),onClick:()=>{b(l.trim()||null)},children:r("settings.extensions.service.socket.save")}),n.override?s.jsx(q,{type:"button",variant:"ghost",size:"xs",disabled:o||m,"aria-label":r("settings.extensions.service.socket.clear.aria",{id:n.id}),onClick:()=>{b(null)},children:r("settings.extensions.service.socket.clear")}):null,n.resolved?s.jsx(q,{type:"button",variant:"ghost",size:"xs",disabled:o||m,"aria-label":r("settings.extensions.service.socket.cancel.aria",{id:n.id}),onClick:v,children:r("settings.extensions.service.socket.cancel")}):null]}):s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx("div",{className:"typography-meta min-w-0 flex-1 truncate text-muted-foreground",children:n.resolved?r("settings.extensions.service.socket.resolved",{path:n.resolved}):r("settings.extensions.service.socket.unresolved")}),s.jsx(q,{type:"button",variant:"ghost",size:"icon",className:os,disabled:o||m,"aria-label":r("settings.extensions.service.socket.edit.aria",{id:n.id}),onClick:()=>g(!0),children:s.jsx(J,{name:"pencil",className:"h-3.5 w-3.5"})})]})}),e[16]=n.id,e[17]=n.override,e[18]=n.resolved,e[19]=o,e[20]=v,e[21]=f,e[22]=b,e[23]=m,e[24]=r,e[25]=l,e[26]=S):S=e[26],S},mk=t=>{const e=$e.c(151),{guest:a,busy:n,onReview:o,onRemove:i,onSetEnabled:r,onUpdate:l}=t,{t:u}=ze(),[m,d]=c.useState(!1),f=a.enabled!==!1,g=(a.enterpriseBlocked?.length??0)>0;let p;e[0]!==g||e[1]!==a?(p=!g&&Wa(a),e[0]=g,e[1]=a,e[2]=p):p=e[2];const h=p;let w,b,k,v,S,y,N,x,I,j,D,C,P,A,R;if(e[3]!==f||e[4]!==g||e[5]!==a||e[6]!==h||e[7]!==m||e[8]!==u){const G=dk(a);k=!!(a.source&&a.source!=="bundled");const ee=a.source==="bundled";let ae;e[24]!==a?(ae=lk(a),e[24]=a,e[25]=ae):ae=e[25],v=ae,R=a.source==="git"?a.update:void 0;let X;e[26]!==a.icon||e[27]!==a.id?(X=Wd(a.id,a.icon,iu().authenticatedAsset),e[26]=a.icon,e[27]=a.id,e[28]=X):X=e[28];const Q=X;let le;e[29]!==ee||e[30]!==a.source||e[31]!==u?(le=ee?null:u(ck(a.source)),e[29]=ee,e[30]=a.source,e[31]=u,e[32]=le):le=e[32];const Z=a.version?`v${a.version}`:null;let fe;e[33]!==a.entry||e[34]!==u?(fe=a.entry?null:u("settings.extensions.source.noPanel"),e[33]=a.entry,e[34]=u,e[35]=fe):fe=e[35];let Y;e[36]!==le||e[37]!==Z||e[38]!==fe?(Y=[le,Z,fe].filter(Boolean),e[36]=le,e[37]=Z,e[38]=fe,e[39]=Y):Y=e[39];const be=Y.join(" · "),Ee=a.path||a.id;let se;e[40]!==f||e[41]!==g||e[42]!==h||e[43]!==u?(se=u(g?"settings.extensions.status.enterpriseBlocked":h?"settings.extensions.status.needsApproval":f?"settings.extensions.status.enabled":"settings.extensions.status.disabled"),e[40]=f,e[41]=g,e[42]=h,e[43]=u,e[44]=se):se=e[44];const re=se,je=g||h?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":f?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground";b=Js,S=m,y=d,P="overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]";let ie;e[45]!==a.icon?(ie=Jd(a.icon),e[45]=a.icon,e[46]=ie):ie=e[46];let Pe;e[47]!==Q||e[48]!==ie?(Pe=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(Gd,{icon:ie,iconSrc:Q,className:"size-5 text-foreground"})}),e[47]=Q,e[48]=ie,e[49]=Pe):Pe=e[49];let ke;e[50]!==a.name?(ke=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e[50]=a.name,e[51]=ke):ke=e[51];let Ae;e[52]!==be?(Ae=s.jsx("p",{className:"mt-0.5 truncate text-xs leading-snug text-muted-foreground",children:be}),e[52]=be,e[53]=Ae):Ae=e[53];let Te;e[54]!==ke||e[55]!==Ae?(Te=s.jsxs("div",{className:"min-w-0 flex-1",children:[ke,Ae]}),e[54]=ke,e[55]=Ae,e[56]=Te):Te=e[56];let Ke;e[57]!==ee||e[58]!==u?(Ke=ee?s.jsx("span",{className:"shrink-0 rounded-full border border-[var(--interactive-border)] px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:u("settings.extensions.source.bundled")}):null,e[57]=ee,e[58]=u,e[59]=Ke):Ke=e[59];let ge;e[60]!==u||e[61]!==R?(ge=R?s.jsx("span",{className:"max-w-40 shrink-0 truncate rounded-full bg-[var(--status-info)]/15 px-2 py-0.5 text-[10px] font-medium text-[var(--status-info)]",children:u("settings.extensions.update.badge",{version:R.version})}):null,e[60]=u,e[61]=R,e[62]=ge):ge=e[62];let Re;e[63]!==je?(Re=Me("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",je),e[63]=je,e[64]=Re):Re=e[64];let Oe;e[65]!==re||e[66]!==Re?(Oe=s.jsx("span",{"aria-live":"polite",className:Re,children:re}),e[65]=re,e[66]=Re,e[67]=Oe):Oe=e[67];const pe=m&&"rotate-180";let xe;e[68]!==pe?(xe=Me("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",pe),e[68]=pe,e[69]=xe):xe=e[69];let Ne;e[70]!==xe?(Ne=s.jsx(J,{name:"arrow-down-s",className:xe}),e[70]=xe,e[71]=Ne):Ne=e[71],e[72]!==Pe||e[73]!==Te||e[74]!==Ke||e[75]!==ge||e[76]!==Oe||e[77]!==Ne?(A=s.jsxs(Qs,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-start hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[Pe,Te,Ke,ge,Oe,Ne]}),e[72]=Pe,e[73]=Te,e[74]=Ke,e[75]=ge,e[76]=Oe,e[77]=Ne,e[78]=A):A=e[78],w=Ys,C="border-t border-[var(--interactive-border)] px-4 py-4",N="space-y-3",e[79]!==Ee?(x=s.jsx("p",{className:"typography-meta truncate font-mono text-muted-foreground",title:Ee,children:Ee}),e[79]=Ee,e[80]=x):x=e[80],e[81]!==g||e[82]!==u?(I=g?s.jsx("p",{className:"typography-meta text-foreground",children:u("settings.extensions.enterpriseBlocked")}):null,e[81]=g,e[82]=u,e[83]=I):I=e[83],e[84]!==ee||e[85]!==u?(j=ee?s.jsx("p",{className:"typography-meta text-muted-foreground",children:u("settings.extensions.builtIn.info")}):null,e[84]=ee,e[85]=u,e[86]=j):j=e[86],D=G?s.jsx("p",{className:"typography-meta truncate text-muted-foreground",children:u("settings.extensions.service.permissions",{list:G})}):null,e[3]=f,e[4]=g,e[5]=a,e[6]=h,e[7]=m,e[8]=u,e[9]=w,e[10]=b,e[11]=k,e[12]=v,e[13]=S,e[14]=y,e[15]=N,e[16]=x,e[17]=I,e[18]=j,e[19]=D,e[20]=C,e[21]=P,e[22]=A,e[23]=R}else w=e[9],b=e[10],k=e[11],v=e[12],S=e[13],y=e[14],N=e[15],x=e[16],I=e[17],j=e[18],D=e[19],C=e[20],P=e[21],A=e[22],R=e[23];let K;e[87]!==a.service||e[88]!==u?(K=a.service?s.jsx("p",{className:"typography-meta text-muted-foreground",children:u("settings.extensions.service.warning")}):null,e[87]=a.service,e[88]=u,e[89]=K):K=e[89];let F;e[90]!==n||e[91]!==f||e[92]!==a?(F=f?(a.service?.socketBindings??[]).map(G=>s.jsx(uk,{guest:a,binding:G,busy:n,onSaved:en},G.id)):null,e[90]=n,e[91]=f,e[92]=a,e[93]=F):F=e[93];let T;e[94]!==n||e[95]!==a||e[96]!==l||e[97]!==u||e[98]!==R?(T=R?s.jsx(q,{type:"button",size:"sm",disabled:n,"aria-label":u("settings.extensions.update.action.aria",{name:a.name,version:R.version}),onClick:()=>{l(a)},children:u("settings.extensions.update.action")}):null,e[94]=n,e[95]=a,e[96]=l,e[97]=u,e[98]=R,e[99]=T):T=e[99];let O;e[100]!==n||e[101]!==a||e[102]!==h||e[103]!==o||e[104]!==u?(O=h?s.jsx(q,{type:"button",size:"sm",disabled:n,"aria-label":u("settings.extensions.review.aria",{name:a.name}),onClick:()=>o(a),children:u("settings.extensions.review")}):null,e[100]=n,e[101]=a,e[102]=h,e[103]=o,e[104]=u,e[105]=O):O=e[105];let E;e[106]!==n||e[107]!==f||e[108]!==a.id||e[109]!==a.name||e[110]!==r||e[111]!==u?(E=f?s.jsx(q,{type:"button",size:"sm",variant:"outline",disabled:n,"aria-label":u("settings.extensions.actions.disable.aria",{name:a.name}),onClick:()=>{r(a.id,a.name,!1)},children:u("settings.extensions.actions.disable")}):s.jsx(q,{type:"button",size:"sm",disabled:n,"aria-label":u("settings.extensions.actions.enable.aria",{name:a.name}),onClick:()=>{r(a.id,a.name,!0)},children:u("settings.extensions.actions.enable")}),e[106]=n,e[107]=f,e[108]=a.id,e[109]=a.name,e[110]=r,e[111]=u,e[112]=E):E=e[112];let B;e[113]!==n||e[114]!==k||e[115]!==a.id||e[116]!==a.name||e[117]!==i||e[118]!==u?(B=k?s.jsx(q,{type:"button",size:"sm",variant:"destructive",disabled:n,"aria-label":u("settings.extensions.remove.aria",{name:a.name}),onClick:()=>{i(a.id,a.name)},children:u("settings.extensions.remove")}):null,e[113]=n,e[114]=k,e[115]=a.id,e[116]=a.name,e[117]=i,e[118]=u,e[119]=B):B=e[119];let _;e[120]!==v||e[121]!==u?(_=v?s.jsxs(q,{type:"button",size:"sm",variant:"outline",className:"ms-auto",onClick:()=>{ks(v)},children:[s.jsx(J,{name:"external-link",className:"size-4"}),u("settings.extensions.actions.openSource")]}):null,e[120]=v,e[121]=u,e[122]=_):_=e[122];let H;e[123]!==T||e[124]!==O||e[125]!==E||e[126]!==B||e[127]!==_?(H=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[T,O,E,B,_]}),e[123]=T,e[124]=O,e[125]=E,e[126]=B,e[127]=_,e[128]=H):H=e[128];let ne;e[129]!==K||e[130]!==F||e[131]!==H||e[132]!==N||e[133]!==x||e[134]!==I||e[135]!==j||e[136]!==D?(ne=s.jsxs("div",{className:N,children:[x,I,j,D,K,F,H]}),e[129]=K,e[130]=F,e[131]=H,e[132]=N,e[133]=x,e[134]=I,e[135]=j,e[136]=D,e[137]=ne):ne=e[137];let z;e[138]!==w||e[139]!==ne||e[140]!==C?(z=s.jsx(w,{className:C,children:ne}),e[138]=w,e[139]=ne,e[140]=C,e[141]=z):z=e[141];let $;e[142]!==z||e[143]!==P||e[144]!==A?($=s.jsxs("div",{className:P,children:[A,z]}),e[142]=z,e[143]=P,e[144]=A,e[145]=$):$=e[145];let V;return e[146]!==b||e[147]!==S||e[148]!==y||e[149]!==$?(V=s.jsx(b,{open:S,onOpenChange:y,children:$}),e[146]=b,e[147]=S,e[148]=y,e[149]=$,e[150]=V):V=e[150],V},pk=t=>{const e=$e.c(24),{guest:a,busy:n,onRemove:o}=t,{t:i}=ze();let r;e[0]!==a.id||e[1]!==a.name||e[2]!==i?(r=a.name??a.id??i("settings.extensions.unreadable.unnamed"),e[0]=a.id,e[1]=a.name,e[2]=i,e[3]=r):r=e[3];const l=r,u=a.builtIn?null:a.id;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(J,{name:"error-warning",className:"size-5 text-[var(--status-error)]"})}),e[4]=m):m=e[4];let d;e[5]!==l?(d=s.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-foreground",children:l}),e[5]=l,e[6]=d):d=e[6];let f;e[7]!==i?(f=i("settings.extensions.unreadable.hint"),e[7]=i,e[8]=f):f=e[8];let g;e[9]!==i?(g=i("settings.extensions.status.unreadable"),e[9]=i,e[10]=g):g=e[10];let p;e[11]!==f||e[12]!==g?(p=s.jsx("span",{title:f,className:"max-w-36 shrink-0 truncate rounded-full bg-[var(--status-error)]/15 px-2 py-0.5 text-[10px] font-medium text-[var(--status-error)]",children:g}),e[11]=f,e[12]=g,e[13]=p):p=e[13];let h;e[14]!==n||e[15]!==l||e[16]!==o||e[17]!==u||e[18]!==i?(h=u?s.jsx(q,{type:"button",variant:"ghost",size:"icon",className:os,disabled:n,title:i("settings.extensions.remove"),"aria-label":i("settings.extensions.remove.aria",{name:l}),onClick:()=>{o(u,l)},children:s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"})}):null,e[14]=n,e[15]=l,e[16]=o,e[17]=u,e[18]=i,e[19]=h):h=e[19];let w;return e[20]!==d||e[21]!==p||e[22]!==h?(w=s.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[m,d,p,h]}),e[20]=d,e[21]=p,e[22]=h,e[23]=w):w=e[23],w},gk=()=>{const t=$e.c(185),{t:e}=ze(),a=vs(fk),n=vs(hk),o=vs(bk),i=vs(xk),r=vs(vk),[l,u]=c.useState(null),[m,d]=c.useState(!1),[f,g]=c.useState("global"),p=o==="unsupported",[h,w]=c.useState(""),b=Ln(),[k,v]=c.useState(!1),[S,y]=c.useState(!1),N=c.useRef(!1),[x,I]=c.useState(null),[j,D]=c.useState(null),[C,P]=c.useState(!1),A=c.useRef(0),R=c.useRef(null);let K;t[0]===Symbol.for("react.memo_cache_sentinel")?(K=Lg(),t[0]=K):K=t[0];const F=K;let T;t[1]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[1]=T):T=t[1],c.useEffect(yk,T);let O,E;t[2]!==r||t[3]!==p?(O=()=>{let et=!1;if(u(null),d(!1),g("global"),I(null),D(null),N.current=!1,!p)return Promise.all([Fp(),Op()]).then(st=>{const[Ht,is]=st;et||u({runtimeKey:r,profiles:Ht,global:is})}).catch(()=>{et||d(!0)}),()=>{et=!0}},E=[r,p],t[2]=r,t[3]=p,t[4]=O,t[5]=E):(O=t[4],E=t[5]),c.useEffect(O,E);const B=l?.runtimeKey===r?l:null;let _;t[6]!==e?(_=e("settings.gitIdentities.editor.title.globalIdentity"),t[6]=e,t[7]=_):_=t[7];const H=B?.global?.userName??"",ne=B?.global?.userEmail??"";let z;t[8]!==_||t[9]!==H||t[10]!==ne?(z={id:"global",name:_,userName:H,userEmail:ne,icon:"fingerprint",color:"info"},t[8]=_,t[9]=H,t[10]=ne,t[11]=z):z=t[11];let $;t[12]!==B?.profiles||t[13]!==z?($=[z,...B?.profiles.filter(jk)??[]],t[12]=B?.profiles,t[13]=z,t[14]=$):$=t[14];const V=$;let G;t[15]!==V||t[16]!==f?(G=V.find(et=>et.id===f)??V[0],t[15]=V,t[16]=f,t[17]=G):G=t[17];const ee=G;let ae,X;t[18]!==o?(ae=()=>{if(o!=="ready"||N.current)return;N.current=!0;const et=vs.getState().runtimeKey;gd(!1).then(st=>{st.ok&&vs.getState().applyUpdates(st.updates,et)})},X=[o],t[18]=o,t[19]=ae,t[20]=X):(ae=t[19],X=t[20]),c.useEffect(ae,X);let Q;t[21]!==e?(Q=async()=>{y(!0);const et=vs.getState().runtimeKey,st=await gd(!0);if(y(!1),!st.ok){W.error(e("settings.extensions.toast.checkFailed"));return}vs.getState().applyUpdates(st.updates,et),Object.keys(st.updates).length===0&&W.success(e("settings.extensions.toast.upToDate"))},t[21]=e,t[22]=Q):Q=t[22];const le=Q;let Z;t[23]!==e?(Z=async et=>{v(!0);const st=await nm(et.id);if(v(!1),!st.ok){W.error(st.code==="host-too-old"&&st.required?e("settings.extensions.toast.hostTooOld",{version:st.required}):e(Yu(st.code)));return}wi(et.id),W.success(e("settings.extensions.toast.updated",{name:st.guest.name,version:st.guest.version??""})),await en(),Wa(st.guest)&&D(st.guest)},t[23]=e,t[24]=Z):Z=t[24];const fe=Z;let Y;if(t[25]!==a||t[26]!==e||t[27]!==n){const et=async(st,Ht,is)=>{const us=is===void 0?{}:is;if(!st.ok&&st.code==="unreadable")return w(""),I(null),W.error(e(ll(st.code))),await en(),!1;if(!st.ok){if(us.allowConflictDialog!==!1&&(st.code==="id-taken"||st.code==="already-installed")){const Jt=st.id?a.find(Ss=>Ss.id===st.id)??n.find(Ss=>Ss.id===st.id):void 0;return I({source:Ht,name:Jt?.name??st.id??(Ht.kind==="file"?Ht.file.name:Ht.input)}),!1}return st.code==="host-too-old"?W.error(st.required?e("settings.extensions.toast.hostTooOld",{version:st.required}):e("settings.extensions.toast.failed"),{description:st.diagnostic?Rr(st.diagnostic,e):void 0}):W.error(e(ll(st.code)),{description:st.diagnostic?Rr(st.diagnostic,e):void 0}),!1}return w(""),I(null),W.success(st.replaced?e("settings.extensions.toast.reinstalled",{name:st.guest.name}):e("settings.extensions.toast.added",{name:st.guest.name})),await en(),Wa(st.guest)&&D(st.guest),!0};Y=async(st,Ht)=>{const is=Ht===void 0?{}:Ht,us=Qt();st.kind==="input"&&w(st.input),v(!0);const Jt=st.kind==="file"?await Kj(st.file,is):await em(st.input,{...is,gitIdentityId:st.gitIdentityId});v(!1),Qt()===us&&await et(Jt,st,{allowConflictDialog:!is.replace})},t[25]=a,t[26]=e,t[27]=n,t[28]=Y}else Y=t[28];const be=Y;let Ee;t[29]!==h||t[30]!==be||t[31]!==ee||t[32]!==e?(Ee=async()=>{const et=h.trim();if(!et){W.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"input",input:et,gitIdentityId:ee.id})},t[29]=h,t[30]=be,t[31]=ee,t[32]=e,t[33]=Ee):Ee=t[33];const se=Ee;let re;t[34]!==be?(re=async()=>{if(!F)return;const et=await Kg("");et.success&&et.path&&await be({kind:"input",input:et.path})},t[34]=be,t[35]=re):re=t[35];const je=re;let ie;t[36]!==be?(ie=async()=>{if(!F){R.current?.click();return}const et=await Nl({filters:[{name:"ZIP Archive",extensions:["zip"]}]});et.success&&et.path&&await be({kind:"input",input:et.path})},t[36]=be,t[37]=ie):ie=t[37];const Pe=ie;let ke;t[38]!==be||t[39]!==e?(ke=async et=>{const st=et.target.files?.[0]??null;if(et.target.value="",!!st){if(!fd(st)){W.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"file",file:st})}},t[38]=be,t[39]=e,t[40]=ke):ke=t[40];const Ae=ke;let Te;t[41]!==k?(Te=et=>{k||(et.preventDefault(),A.current=A.current+1,P(!0))},t[41]=k,t[42]=Te):Te=t[42];const Ke=Te;let ge;t[43]!==k?(ge=et=>{k||(et.preventDefault(),et.dataTransfer.dropEffect="copy")},t[43]=k,t[44]=ge):ge=t[44];const Re=ge;let Oe;t[45]===Symbol.for("react.memo_cache_sentinel")?(Oe=()=>{A.current=Math.max(0,A.current-1),A.current===0&&P(!1)},t[45]=Oe):Oe=t[45];const pe=Oe;let xe;t[46]!==k||t[47]!==be||t[48]!==e?(xe=async et=>{if(et.preventDefault(),A.current=0,P(!1),k)return;const st=et.dataTransfer.items[0],Ht=st?.getAsFile()??null,us=(st?.webkitGetAsEntry()??null)?.isDirectory===!0,Jt=Ht!==null&&!us&&fd(Ht),Ss=Ht&&F?zg(Ht):null;if(Ss&&(us||Jt)){await be({kind:"input",input:Ss});return}if(us){W.error(e(F?"settings.extensions.toast.invalidPath":"settings.extensions.toast.folderNeedsZip"));return}if(!Ht||!Jt){W.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"file",file:Ht})},t[46]=k,t[47]=be,t[48]=e,t[49]=xe):xe=t[49];const Ne=xe;let de;t[50]!==x||t[51]!==be?(de=async()=>{x&&await be(x.source,{replace:!0})},t[50]=x,t[51]=be,t[52]=de):de=t[52];const Ue=de;let Ie;t[53]!==e?(Ie=async(et,st)=>{v(!0);const Ht=await tm(et);if(v(!1),!Ht.ok){W.error(e("settings.extensions.toast.removeFailed"));return}wi(et),W.success(e("settings.extensions.toast.removed",{name:st})),await en()},t[53]=e,t[54]=Ie):Ie=t[54];const De=Ie;let Je;t[55]!==e?(Je=async et=>{v(!0);const st=await zj(et.id,et.capabilities.requested);if(v(!1),!st){W.error(e("settings.extensions.toast.approveFailed"));return}D(null),W.success(e("settings.extensions.toast.approved",{name:et.name})),await en()},t[55]=e,t[56]=Je):Je=t[56];const tt=Je;let mt;t[57]!==De?(mt=async et=>{D(null),await De(et.id,et.name)},t[57]=De,t[58]=mt):mt=t[58];const ht=mt;let ft;t[59]!==e?(ft=async(et,st,Ht)=>{v(!0);const is=await sm(et,Ht);if(v(!1),!is){W.error(e("settings.extensions.toast.enabledFailed"));return}Ht||wi(et),W.success(Ht?e("settings.extensions.toast.enabled",{name:st}):e("settings.extensions.toast.disabled",{name:st})),await en()},t[59]=e,t[60]=ft):ft=t[60];const xt=ft;let Qe;t[61]!==e?(Qe=e("settings.page.extensions.title"),t[61]=e,t[62]=Qe):Qe=t[62];let lt;t[63]!==e?(lt=e("settings.page.extensions.description"),t[63]=e,t[64]=lt):lt=t[64];let Ye;t[65]!==se||t[66]!==je||t[67]!==Pe||t[68]!==k||t[69]!==C||t[70]!==b||t[71]!==V||t[72]!==l||t[73]!==m||t[74]!==h||t[75]!==Ke||t[76]!==Re||t[77]!==Ne||t[78]!==Ae||t[79]!==ee||t[80]!==e||t[81]!==p?(Ye=p?null:s.jsxs(He,{title:e("settings.extensions.add.action"),info:b?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block",children:e("settings.extensions.add.enterpriseRule")}),s.jsx("span",{className:"mt-2 block",children:e("settings.extensions.add.info")})]}):e("settings.extensions.add.info"),children:[s.jsx(Mt,{label:e("settings.extensions.add.label"),info:e(F?"settings.extensions.add.drop":"settings.extensions.add.drop.zipOnly"),settingsItem:"extensions.add",controlClassName:"w-full max-w-none",children:s.jsxs("div",{className:Me("relative -m-1 flex min-w-0 flex-1 items-center gap-2 rounded-md border border-dashed border-transparent p-1 transition-colors",C&&"border-primary bg-primary/5"),onDragEnter:Ke,onDragOver:Re,onDragLeave:pe,onDrop:et=>{Ne(et)},children:[C?s.jsx("span",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-md bg-background/80 typography-ui-label text-primary",children:e("settings.extensions.add.drop.active")}):null,s.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center",children:[s.jsx(Ve,{value:h,onChange:et=>w(et.target.value),onKeyDown:et=>{et.key==="Enter"&&(et.preventDefault(),se())},placeholder:e("settings.extensions.add.placeholder"),"aria-label":e("settings.extensions.add.label"),className:Me("h-8 min-w-0 flex-1 rounded-md ps-3",F?"pe-14":"pe-8"),disabled:k}),s.jsx("input",{ref:R,type:"file",accept:".zip,application/zip",className:"sr-only",tabIndex:-1,"aria-hidden":"true",onChange:et=>{Ae(et)}}),s.jsxs("div",{className:"absolute inset-e-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[F?s.jsx(q,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:e("settings.extensions.add.browseFolder"),"aria-label":e("settings.extensions.add.browseFolder.aria"),disabled:k,onClick:()=>{je()},children:s.jsx(J,{name:"folder",className:"h-4 w-4"})}):null,s.jsx(q,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:e("settings.extensions.add.browseZip"),"aria-label":e("settings.extensions.add.browseZip.aria"),disabled:k,onClick:()=>{Pe()},children:s.jsx(J,{name:"archive",className:"h-4 w-4"})})]})]}),s.jsx("div",{className:"shrink-0","data-settings-item":"extensions.gitIdentity",children:s.jsx(ff,{activeProfile:ee,identities:V,onSelect:et=>g(et.id),isApplying:k||!l&&!m,iconOnly:!0})}),s.jsxs(q,{type:"button",size:"sm",disabled:k,"aria-label":e("settings.extensions.add.aria"),onClick:()=>{se()},children:[s.jsx(J,{name:"add",className:"h-4 w-4"}),e("settings.extensions.add.action")]})]})}),m?s.jsx("p",{className:"typography-meta text-destructive",children:e("settings.extensions.identity.loadFailed")}):null]}),t[65]=se,t[66]=je,t[67]=Pe,t[68]=k,t[69]=C,t[70]=b,t[71]=V,t[72]=l,t[73]=m,t[74]=h,t[75]=Ke,t[76]=Re,t[77]=Ne,t[78]=Ae,t[79]=ee,t[80]=e,t[81]=p,t[82]=Ye):Ye=t[82];let at;t[83]!==e?(at=e("settings.extensions.section.installed"),t[83]=e,t[84]=at):at=t[84];let dt;t[85]!==k||t[86]!==le||t[87]!==S||t[88]!==o||t[89]!==e||t[90]!==p?(dt=p?null:s.jsxs(q,{type:"button",variant:"ghost",size:"sm","data-settings-item":"extensions.updates.check",disabled:k||S||o!=="ready","aria-label":e("settings.extensions.updates.check.aria"),onClick:()=>{le()},children:[s.jsx(J,{name:"refresh",className:Me("h-4 w-4",S&&"animate-spin")}),e("settings.extensions.updates.check")]}),t[85]=k,t[86]=le,t[87]=S,t[88]=o,t[89]=e,t[90]=p,t[91]=dt):dt=t[91];let _e;t[92]!==i||t[93]!==o||t[94]!==e?(_e=o==="error"||i?s.jsxs("p",{className:"typography-meta whitespace-pre-line text-destructive",children:[e("settings.extensions.toast.loadFailed"),i?`
|
|
30
|
+
${Rr(i,e)}`:""]}):null,t[92]=i,t[93]=o,t[94]=e,t[95]=_e):_e=t[95];let nt;t[96]!==e||t[97]!==p?(nt=p?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.extensions.unsupported")}):null,t[96]=e,t[97]=p,t[98]=nt):nt=t[98];let te;t[99]!==a.length||t[100]!==o||t[101]!==e||t[102]!==n.length?(te=o==="ready"&&a.length===0&&n.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.extensions.empty")}):null,t[99]=a.length,t[100]=o,t[101]=e,t[102]=n.length,t[103]=te):te=t[103];let ue;if(t[104]!==k||t[105]!==a||t[106]!==De||t[107]!==xt||t[108]!==fe){let et;t[110]!==k||t[111]!==De||t[112]!==xt||t[113]!==fe?(et=st=>s.jsx(mk,{guest:st,busy:k,onReview:D,onRemove:De,onSetEnabled:xt,onUpdate:fe},st.id),t[110]=k,t[111]=De,t[112]=xt,t[113]=fe,t[114]=et):et=t[114],ue=a.map(et),t[104]=k,t[105]=a,t[106]=De,t[107]=xt,t[108]=fe,t[109]=ue}else ue=t[109];let he;if(t[115]!==k||t[116]!==De||t[117]!==n){let et;t[119]!==k||t[120]!==De?(et=(st,Ht)=>s.jsx(pk,{guest:st,busy:k,onRemove:De},st.id??`unreadable-${Ht}`),t[119]=k,t[120]=De,t[121]=et):et=t[121],he=n.map(et),t[115]=k,t[116]=De,t[117]=n,t[118]=he}else he=t[118];let ye;t[122]!==at||t[123]!==dt||t[124]!==_e||t[125]!==nt||t[126]!==te||t[127]!==ue||t[128]!==he?(ye=s.jsxs(He,{title:at,contentClassName:"space-y-3",headerAction:dt,children:[_e,nt,te,ue,he]}),t[122]=at,t[123]=dt,t[124]=_e,t[125]=nt,t[126]=te,t[127]=ue,t[128]=he,t[129]=ye):ye=t[129];let qe;t[130]!==tt?(qe=et=>{tt(et)},t[130]=tt,t[131]=qe):qe=t[131];let Ze;t[132]!==ht?(Ze=et=>{ht(et)},t[132]=ht,t[133]=Ze):Ze=t[133];let pt;t[134]===Symbol.for("react.memo_cache_sentinel")?(pt=()=>D(null),t[134]=pt):pt=t[134];let vt;t[135]!==j||t[136]!==k||t[137]!==qe||t[138]!==Ze?(vt=s.jsx(ik,{guest:j,busy:k,onApprove:qe,onDecline:Ze,onDismiss:pt}),t[135]=j,t[136]=k,t[137]=qe,t[138]=Ze,t[139]=vt):vt=t[139];const bt=x!==null;let wt;t[140]!==k?(wt=et=>{!et&&!k&&I(null)},t[140]=k,t[141]=wt):wt=t[141];let Et;t[142]!==e?(Et=e("settings.extensions.dialog.reinstallTitle"),t[142]=e,t[143]=Et):Et=t[143];let Le;t[144]!==Et?(Le=s.jsx(_t,{children:Et}),t[144]=Et,t[145]=Le):Le=t[145];const Xe=x?.name??"";let gt;t[146]!==e||t[147]!==Xe?(gt=e("settings.extensions.dialog.reinstallDescription",{name:Xe}),t[146]=e,t[147]=Xe,t[148]=gt):gt=t[148];let jt;t[149]!==gt?(jt=s.jsx(Vt,{children:gt}),t[149]=gt,t[150]=jt):jt=t[150];let L;t[151]!==Le||t[152]!==jt?(L=s.jsxs(Bt,{children:[Le,jt]}),t[151]=Le,t[152]=jt,t[153]=L):L=t[153];let me;t[154]===Symbol.for("react.memo_cache_sentinel")?(me=()=>I(null),t[154]=me):me=t[154];let Se;t[155]!==e?(Se=e("settings.common.actions.cancel"),t[155]=e,t[156]=Se):Se=t[156];let Ce;t[157]!==k||t[158]!==Se?(Ce=s.jsx(q,{size:"sm",variant:"ghost",disabled:k,onClick:me,children:Se}),t[157]=k,t[158]=Se,t[159]=Ce):Ce=t[159];let We;t[160]!==Ue?(We=()=>{Ue()},t[160]=Ue,t[161]=We):We=t[161];let ce;t[162]!==e?(ce=e("settings.extensions.dialog.reinstall"),t[162]=e,t[163]=ce):ce=t[163];let Fe;t[164]!==k||t[165]!==We||t[166]!==ce?(Fe=s.jsx(q,{size:"sm",disabled:k,onClick:We,children:ce}),t[164]=k,t[165]=We,t[166]=ce,t[167]=Fe):Fe=t[167];let ct;t[168]!==Ce||t[169]!==Fe?(ct=s.jsxs(ts,{children:[Ce,Fe]}),t[168]=Ce,t[169]=Fe,t[170]=ct):ct=t[170];let Ft;t[171]!==L||t[172]!==ct?(Ft=s.jsxs(zt,{className:"max-w-md",children:[L,ct]}),t[171]=L,t[172]=ct,t[173]=Ft):Ft=t[173];let It;t[174]!==bt||t[175]!==wt||t[176]!==Ft?(It=s.jsx(Kt,{open:bt,onOpenChange:wt,children:Ft}),t[174]=bt,t[175]=wt,t[176]=Ft,t[177]=It):It=t[177];let ls;return t[178]!==Qe||t[179]!==lt||t[180]!==Ye||t[181]!==ye||t[182]!==vt||t[183]!==It?(ls=s.jsxs(Yt,{title:Qe,description:lt,children:[Ye,ye,vt,It]}),t[178]=Qe,t[179]=lt,t[180]=Ye,t[181]=ye,t[182]=vt,t[183]=It,t[184]=ls):ls=t[184],ls};function fk(t){return t.guests}function hk(t){return t.unreadable}function bk(t){return t.status}function xk(t){return t.failure}function vk(t){return t.runtimeKey}function yk(){en()}function jk(t){return t.id!=="global"}const kk={dark:.16,light:.06};function wk(t,e,a=!1){if(a)return;const{surface:n,primary:o,status:i,interactive:r,markdown:l,chat:u,tools:m,syntax:d}=t.colors,f=t.metadata.variant==="dark",g=n.background,p=Ls(g,g),h=(P,A)=>co(P,A,g)??1,w=(P,A,R)=>{if(R(P))return P;let K=0,F=1,T=A;for(let O=0;O<16;O++){const E=(K+F)/2,B=Is(A,P,E,g);R(B)?(F=E,T=B):K=E}return T},b=P=>h(P,"#000000"),k=Math.min(4.6,h(p,g)),v=(P,A)=>{const R=A?"#ffffff":"#000000",F=(A?b(P)>b(g):b(P)<b(g))?Is(P,g,1,g):g,T=w(F,g,E=>h(E,g)<=1.1),O=h(R,g)<1.04?R:w(T,R,E=>h(E,g)>=1.04);return w(O,g,E=>h(p,E)>=k)};n.muted=v(n.muted,!1),n.elevated=v(n.elevated,f),n.subtle=Is(p,g,.025,g);const S=[g,n.muted,n.elevated],y=P=>Math.min(...S.map(A=>h(P,A))),N=P=>w(P,p,A=>y(A)>=4.6),x=(P,A,R=4.6)=>w(w(P,g,K=>h(K,g)<=A),p,K=>y(K)>=R);n.foreground=x(n.foreground,f?13.6:9,7),n.mutedForeground=x(n.mutedForeground,Math.min(6,h(n.foreground,g)*.7)),n.elevatedForeground=x(n.elevatedForeground,f?13.6:9,7);const I=[e["button.background"],e["textLink.foreground"],e["activityBarBadge.background"],e["list.highlightForeground"],e.focusBorder];o.base=N(I.find(P=>P!==void 0&&y(P)>=3)??o.base),o.foreground=Ls(o.base,g),o.hover=Is(p,o.base,.08,g),o.active=Is(p,o.base,.16,g),o.muted=Zn(o.base,.5),y(r.focusRing)<1.1&&(r.focus=o.base,r.focusRing=o.base,r.borderFocus=o.base),r.selection=w(r.selection,Is(o.base,g,.18,g),P=>y(P)>=1.1);const j=f?{border:[1.217,1.245,1.117],hover:[2.304,2.356,2.115],tools:[1.199,1.207,1.156],divider:[1.41,1.442,1.294]}:{border:[1.268,1.203,1.162],hover:[1.64,1.557,1.503],tools:[1.231,1.195,1.171],divider:[1.427,1.355,1.308]},D=(P,[A,R,K])=>{const F=Math.max(A,R,K),T=H=>H+(F-H)*.2,O=H=>h(H,g)<=T(A)&&h(H,n.muted)<=T(R)&&h(H,n.elevated)<=T(K);if(O(P))return P;let E=0,B=1,_=Zn(P,0);for(let H=0;H<16;H++){const ne=(E+B)/2,z=Zn(P,ne);O(z)?(E=ne,_=z):B=ne}return _};r.border=D(r.border,j.border),r.borderHover=D(r.borderHover,j.hover),r.hover=D(r.hover,[1.18,1.18,1.18]),r.active=D(r.active,[1.25,1.25,1.25]),r.selection=D(r.selection,[1.6,1.7,1.45]),r.selectionForeground=In(n.foreground,r.selection,g);const C=(P,A,R,K)=>{const F=Kp(P,g);return N(F!==null&&F>=R&&F<=K?P:A)};i.error=C(i.error,f?"#e07777":"#b43b45",0,35),i.warning=C(i.warning,f?"#d6b467":"#916b17",35,100),i.success=C(i.success,f?"#80b888":"#357b47",105,170),i.info=C(i.info,f?"#83afe0":"#366eaa",185,275);for(const P of["error","warning","success","info"])i[`${P}Foreground`]=Ls(i[P],g),i[`${P}Background`]=Zn(i[P],f?.16:.12),i[`${P}Border`]=Zn(i[P],f?.45:.35);if(t.colors.pr={open:i.success,closed:i.error,draft:n.mutedForeground,blocked:C(e["terminal.ansiYellow"]??"",f?"#d99464":"#a65b25",40,65),merged:C(e["terminal.ansiMagenta"]??"",f?"#b79bd9":"#8255b0",285,325)},u){let P=w(g,p,A=>h(A,g)>=1.12);h(p,P)<k&&(P=w(g,p==="#ffffff"?"#000000":"#ffffff",A=>h(A,g)>=1.12)),u.userMessageBackground=w(Gl(o.base,P,kk[f?"dark":"light"],g),P,A=>h(A,g)>=1.1&&h(p,A)>=k),S.push(u.userMessageBackground),n.foreground=w(n.foreground,p,A=>y(A)>=7),n.mutedForeground=N(n.mutedForeground),u.userMessage=In(n.foreground,u.userMessageBackground,g),u.assistantMessage=n.foreground,u.timestamp=n.mutedForeground,u.typing=n.mutedForeground,u.avatarForeground=e["chat.avatarForeground"]??n.foreground,u.slashCommandBackground=e["chat.slashCommandBackground"]??o.base,u.slashCommandForeground=e["chat.slashCommandForeground"]??Ls(u.slashCommandBackground,g),u.inputWorkingBorderColor1=e["chat.inputWorkingBorderColor1"]??o.base,u.inputWorkingBorderColor2=e["chat.inputWorkingBorderColor2"]??o.hover,u.inputWorkingBorderColor3=e["chat.inputWorkingBorderColor3"]??o.muted,u.divider=D(u.divider??r.border,j.divider)}t.colors.pr&&(t.colors.pr.draft=n.mutedForeground),m&&(m.border=D(m.border??r.border,j.tools),m.title=n.foreground,m.description=n.mutedForeground,m.icon=n.mutedForeground),l&&(l.bold=Is(p,n.foreground,.12,g),l.italic=n.foreground,l.blockquote=n.mutedForeground,l.blockquoteBorder=D(l.blockquoteBorder??r.border,j.divider),l.hr=D(l.hr??r.border,j.divider),l.link=N(e["textLink.foreground"]??o.base),l.linkHover=N(e["textLink.activeForeground"]??o.hover),l.listMarker=Zn(o.base,.6),l.inlineCodeBackground=n.subtle,l.inlineCode=In(N(e["textPreformat.foreground"]??o.base),n.subtle,g)),d.base.background=w(Gl(g,d.base.background,1,g),g,P=>h(P,g)<=1.1),d.base.foreground=In(n.foreground,d.base.background,g)}const Fs=Zn,Sk=t=>{const e={...t,colors:{...t.colors}},a=e.kind==="dark"||e.kind==="high-contrast",n=zp(a),o=e.colors,i=o["chat.list.background"]??o["editor.background"]??n.colors.surface.background,r=o["interactive-session.foreground"]??o.foreground??o["editor.foreground"]??Ls(i,i);o.foreground??=r,o["sideBar.background"]??=o["panel.background"]??Is(r,i,.03,i),!o["editorWidget.background"]&&!o["dropdown.background"]&&!o["input.background"]&&(o["editorWidget.background"]=Is(r,i,.04,i),o["editorWidget.foreground"]=In(r,o["editorWidget.background"],i)),o.descriptionForeground??=In(Is(r,i,.6,i),i),o["widget.border"]??=o["input.border"]??o["panel.border"]??Is(r,i,.15,i),o["toolbar.hoverBackground"]??=o["list.hoverBackground"]??Is(r,i,.08,i),o["toolbar.activeBackground"]??=Is(r,i,.12,i),!o["list.activeSelectionBackground"]&&!o["menu.selectionBackground"]&&!o["editor.selectionBackground"]&&(o["list.activeSelectionBackground"]=Is(r,i,.16,i),o["list.activeSelectionForeground"]=In(r,o["list.activeSelectionBackground"],i)),o["button.background"]||(o["button.background"]=o["textLink.foreground"]??o.focusBorder??r,o["button.foreground"]=Ls(o["button.background"],i)),o.focusBorder??=o["button.background"],o["editorCursor.foreground"]??=o["editor.foreground"]??r;const l=(Te,Ke)=>e.colors[Te]??Ke,u=Te=>Te!=="transparent"&&(co(Te,"#000000")!==1||co(Te,"#ffffff")!==1),m=(Te,Ke)=>{const ge=l(Te,Ke);return u(ge)?ge:Ke},d=l("chat.list.background",l("editor.background",n.colors.surface.background)),f=l("interactive-session.foreground",l("foreground",l("editor.foreground",n.colors.surface.foreground))),p=[["editorWidget.background","editorWidget.foreground"],["dropdown.background","dropdown.foreground"],["input.background","input.foreground"]].find(([Te])=>e.colors[Te]),h=p?l(p[0],n.colors.surface.elevated):n.colors.surface.elevated,w=In(f,h,d),b=p?l(p[1],w):w,k=l("sideBar.background",l("panel.background",n.colors.surface.muted)),v=l("descriptionForeground",l("input.placeholderForeground",n.colors.surface.mutedForeground)),S=l("textBlockQuote.background",k),y=n.colors.surface.overlay,N=l("button.background",l("textLink.foreground",n.colors.primary.base)),x=l("button.hoverBackground",N),I=e.colors["button.background"]?l("button.foreground",Ls(N,d)):Ls(N,d),j=Fs(N,.5),C=[e.kind==="high-contrast"||e.highContrast?l("contrastBorder",""):"",l("widget.border",""),l("input.border",""),l("panel.border",""),l("sideBar.border",""),l("editorWidget.border",""),l("contrastBorder","")].find(Te=>Te&&u(Te))||Fs(f,a?.25:.2),P=l("toolbar.hoverBackground",l("list.hoverBackground",n.colors.interactive.hover)),A=l("toolbar.activeBackground",P),K=[["list.activeSelectionBackground","list.activeSelectionForeground"],["menu.selectionBackground","menu.selectionForeground"],["editor.selectionBackground","editor.selectionForeground"]].filter(([Te])=>e.colors[Te]),F=K.find(([Te])=>[d,k,h].every(Ke=>{const ge=co(l(Te,""),Ke,d);return ge===null||ge>1.01}))??K[0],T=F?l(F[0],n.colors.interactive.selection):n.colors.interactive.selection,O=F?l(F[1],f):f,E=l("focusBorder",l("inputOption.activeBorder",N)),B=E,_=l("editorCursor.foreground",n.colors.interactive.cursor),H=l("editorError.foreground",l("testing.iconFailed",n.colors.status.error)),ne=m("editorError.background",Fs(H,a?.16:.12)),z=l("problemsWarningIcon.foreground",l("notificationsWarningIcon.foreground",l("editorWarning.foreground",n.colors.status.warning))),$=m("editorWarning.background",Fs(z,a?.16:.12)),V=l("testing.iconPassed",l("gitDecoration.addedResourceForeground",n.colors.status.success)),G=Fs(V,a?.16:.12),ee=l("problemsInfoIcon.foreground",l("editorInfo.foreground",n.colors.status.info)),ae=m("editorInfo.background",Fs(ee,a?.16:.12)),X=l("editorLineNumber.foreground",v),Q=l("textPreformat.foreground",l("terminal.ansiGreen",n.colors.syntax.base.string)),le=l("terminal.ansiBlue",N),Z=l("terminal.ansiYellow",n.colors.syntax.base.number),fe=l("terminal.ansiCyan",n.colors.syntax.base.function),Y=l("terminal.ansiMagenta",f),be=l("terminal.ansiYellow",n.colors.syntax.base.type),Ee=l("chat.requestBorder",C),se=l("diffEditor.insertedLineBackground",l("diffEditor.insertedTextBackground",G)),re=l("diffEditor.removedLineBackground",l("diffEditor.removedTextBackground",ne)),je=l("chat.linesAddedForeground",l("gitDecoration.addedResourceForeground",V)),ie=l("chat.linesRemovedForeground",l("gitDecoration.deletedResourceForeground",H)),Pe=l("gitDecoration.modifiedResourceForeground",ee),ke=l("chat.requestBubbleBackground",l("chat.requestBackground",h)),Ae={...n,metadata:{...n.metadata,id:"vscode-auto",name:"VS Code Theme",description:"Mirrors your current VS Code color theme",author:"VS Code",version:"1.0.0",variant:a?"dark":"light",tags:["vscode","auto"]},colors:{...n.colors,primary:{base:N,hover:x,active:x,foreground:I,muted:j},surface:{background:d,foreground:f,muted:k,mutedForeground:v,elevated:h,elevatedForeground:b,overlay:y,subtle:S},interactive:{border:C,borderHover:l("toolbar.hoverOutline",C),borderFocus:E,selection:T,selectionForeground:O,focus:E,focusRing:B,cursor:_,hover:P,active:A},status:{error:H,errorForeground:Ls(H,d),errorBackground:ne,errorBorder:Fs(H,a?.45:.35),warning:z,warningForeground:Ls(z,d),warningBackground:$,warningBorder:Fs(z,a?.45:.35),success:V,successForeground:Ls(V,d),successBackground:G,successBorder:Fs(V,a?.45:.35),info:ee,infoForeground:Ls(ee,d),infoBackground:ae,infoBorder:Fs(ee,a?.45:.35)},pr:n.colors.pr?{...n.colors.pr,open:V,closed:H,draft:v}:void 0,syntax:{tokens:{},highlights:{diffAdded:je,diffAddedBackground:se,diffRemoved:ie,diffRemovedBackground:re,diffModified:Pe,diffModifiedBackground:Fs(Pe,a?.16:.12),lineNumber:l("editorLineNumber.foreground",v),lineNumberActive:l("editorLineNumber.activeForeground",f)},base:{background:l("editor.background",d),foreground:l("editor.foreground",f),comment:X,keyword:le,string:Q,number:Z,function:fe,variable:Y,type:be,operator:N}},tools:{border:Ee,icon:l("icon.foreground",v),title:f,description:Fs(v,.8),edit:{added:je,addedBackground:se,removed:ie,removedBackground:re,modified:Pe,modifiedBackground:Fs(Pe,a?.16:.12),lineNumber:X}},chat:{background:d,userMessage:f,userMessageBackground:ke,assistantMessage:f,assistantMessageBackground:d,timestamp:v,divider:C,typing:l("chat.thinkingShimmer",v),avatarBackground:l("chat.avatarBackground",d),avatarForeground:l("chat.avatarForeground",f),slashCommandBackground:l("chat.slashCommandBackground",N),slashCommandForeground:l("chat.slashCommandForeground",I),inputWorkingBorderColor1:l("chat.inputWorkingBorderColor1",N),inputWorkingBorderColor2:l("chat.inputWorkingBorderColor2",x),inputWorkingBorderColor3:l("chat.inputWorkingBorderColor3",j)},markdown:{link:l("textLink.foreground",N),linkHover:l("textLink.activeForeground",x),inlineCode:l("textPreformat.foreground",Q),inlineCodeBackground:l("textPreformat.background",l("editor.background",d)),blockquote:f,blockquoteBackground:l("textBlockQuote.background","transparent"),blockquoteBorder:l("textBlockQuote.border",C),listMarker:Fs(N,.6)}}};return wk(Ae,t.colors,e.kind==="high-contrast"||e.highContrast===!0),Ae},Mo=St().regex(/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i),Ol=ss({foreground:Mo.optional()}),rm=ss({scope:Qr([St(),Zs(St())]).optional(),settings:Ol}),Nk=ss({name:St().trim().min(1).max(160).optional(),author:St().max(160).optional(),description:St().max(1024).optional(),type:Cl(["light","dark","hc","hc-black","hc-light"]).optional(),include:St().optional(),colors:En(St(),Mo.nullable()).default({}),tokenColors:Qr([Zs(rm),St()]).optional(),semanticHighlighting:Fi().optional(),semanticTokenColors:En(St(),Qr([Mo,Ol])).optional()});function Ck(t){return t.flatMap(e=>(Array.isArray(e.scope)?e.scope:[e.scope??""]).flatMap(n=>n.split(",").map(o=>({scope:o.trim(),color:e.settings.foreground}))))}function Ik(t,e){for(const a of e){let n,o=-1;for(const i of t)!i.color||!i.scope||(a===i.scope||a.startsWith(`${i.scope}.`))&&i.scope.length>=o&&(n=i.color,o=i.scope.length);if(n)return n}}function Pk(t,e){for(const a of e.length?[...e,"*"]:e){const n=t[a];if(n===void 0)continue;const o=Mo.safeParse(n);if(o.success)return o.data;const i=Ol.safeParse(n);if(i.success&&i.data.foreground)return i.data.foreground}}function Ak(t){return/^[a-z0-9]+(?:[-_][a-z0-9]+)+$/.test(t)?t.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):t}function lm(t,e){if(new TextEncoder().encode(t).byteLength>Zd)throw new na("size");let a;try{a=Nk.parse(JSON.parse(Tf(t.replace(/^\uFEFF/,""),{trailingCommas:!0})))}catch{throw new na("invalid")}const n=Zs(rm).safeParse(a.tokenColors??[]);if(a.include||!n.success)throw new na("include");const o={};for(const[I,j]of Object.entries(a.colors))j!==null&&(o[I]=j);const i=o["editor.background"];if(!i)throw new na("background");const r=a.type?["dark","hc","hc-black"].includes(a.type):Ls(i,"#ffffff")==="#ffffff",l=r?"dark":"light",u=Is(i,r?"#000000":"#ffffff",1),m=Ck(n.data),d=n.data.filter(I=>!I.scope&&I.settings.foreground).at(-1)?.settings.foreground,f=o["editor.foreground"]??d??o.foreground??Ls(u,u);o["editor.background"]=u,o["editor.foreground"]=f;const g=a.type?.startsWith("hc")??!1;g&&o.contrastBorder&&(o["widget.border"]=o.contrastBorder);const h=Sk({kind:r&&g?"high-contrast":l,colors:o,highContrast:g}),w=a.semanticHighlighting===!1?{}:a.semanticTokenColors??{},b=(I,j,D)=>Pk(w,I)??Ik(m,j)??D,k=h.colors.syntax.base.foreground,v={background:h.colors.syntax.base.background,foreground:h.colors.syntax.base.foreground,comment:b(["comment"],["comment","comment.line","comment.block"],In(Is(f,u,.6,u),u)),keyword:b(["keyword"],["keyword","storage","keyword.control","storage.type"],k),string:b(["string"],["string","string.quoted","string.template"],k),number:b(["number"],["constant.numeric"],k),function:b(["function"],["entity.name.function","support.function"],k),variable:b(["variable"],["variable.other.readwrite","variable"],k),type:b(["type"],["entity.name.type","support.type","support.class"],k),operator:b(["operator"],["keyword.operator"],k)},S=b(["class"],["entity.name.type.class","entity.name.class"],v.type),y=b(["property"],["variable.other.property","support.type.property-name"],v.variable),N={base:v,tokens:{className:S,interface:b(["interface"],["entity.name.type.interface"],v.type),enum:b(["enum"],["entity.name.type.enum"],S),method:b(["method"],["entity.name.function.method"],v.function),variableProperty:y,parameter:b(["parameter"],["variable.parameter"],v.variable),constant:b(["variable.readonly","*.readonly","enumMember"],["variable.other.constant","constant.other"],v.number),boolean:b([],["constant.language.boolean","constant.language"],v.number),punctuation:b([],["punctuation","punctuation.separator"],v.operator),stringEscape:b([],["constant.character.escape"],v.string),commentDoc:b([],["comment.block.documentation","comment.documentation"],v.comment),keywordImport:b([],["keyword.control.import","keyword.import"],v.keyword),tag:b([],["entity.name.tag"],v.keyword),tagAttribute:b([],["entity.other.attribute-name"],y)},highlights:h.colors.syntax.highlights},x=Ak(a.name??(e.replace(/\.(jsonc?|code-theme)$/i,"").replace(/[-_]color[-_]theme$/i,"").trim().slice(0,160)||"VS Code"));return Up({metadata:{id:`vscode-import-${l}`,name:x,variant:l,author:a.author,description:a.description??"",version:"1.0.0",tags:["imported","vscode"]},colors:{...h.colors,syntax:N}})}const Tk=ss({namespace:St(),name:St(),version:St(),label:St(),icon:St().url().refine(t=>{const e=new URL(t);return e.protocol==="https:"&&["open-vsx.org","openvsx.eclipsecontent.org"].includes(e.hostname)}).nullable()});async function Ek(t,e){const a=await Rt("/api/config/themes/catalog/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t}),signal:e});if(!a.ok)throw new Error("catalog");return ss({items:Zs(Tk).max(24)}).parse(await a.json()).items}async function Mk(t,e){const a=await Rt("/api/config/themes/catalog/package",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:e});if(!a.ok)throw new Error("catalog");const{items:n}=ss({items:Zs(ss({path:St(),name:St(),text:St(),error:Fi()})).max(40)}).parse(await a.json());return n.map((o,i)=>{const r=`${i}:${o.path}`;try{if(o.error)throw new Error("invalid");const l=lm(o.text,o.path);return l.metadata.name=o.name,l.metadata.author=t.namespace,{status:"ready",key:r,name:o.name,definition:l,theme:$p(l)}}catch{return{status:"invalid",key:r,name:o.name}}})}function Dk(t){const e=$e.c(3),{extension:a}=t,[n,o]=c.useState(!1);let i;return e[0]!==a.icon||e[1]!==n?(i=a.icon&&!n?s.jsx("img",{src:a.icon,alt:"",referrerPolicy:"no-referrer",loading:"lazy",className:"size-9 shrink-0 rounded object-contain",onError:()=>o(!0)}):s.jsx(J,{name:"palette",className:"size-9 shrink-0 text-muted-foreground"}),e[0]=a.icon,e[1]=n,e[2]=i):i=e[2],i}function Rk(t){const e=$e.c(93),{pickFile:a,fileBusy:n,onClose:o}=t,{t:i}=ze(),r=oe(Lk),{isMobile:l}=Fn(),u=r||l,{importTheme:m}=ua(),[d,f]=c.useState("");let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={step:"search",status:"idle",results:[]},e[0]=g):g=e[0];const[p,h]=c.useState(g);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=new Set,e[1]=w):w=e[1];const[b,k]=c.useState(w);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=new Set,e[2]=v):v=e[2];const[S,y]=c.useState(v),[N,x]=c.useState(!1),[I,j]=c.useState(null),D=c.useRef(null);let C,P;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{const G=new AbortController;D.current=G;const ee=Ro(()=>G.abort());return()=>{ee(),G.abort()}},P=[],e[3]=C,e[4]=P):(C=e[3],P=e[4]),c.useEffect(C,P);let A,R;e[5]!==d||e[6]!==p.step?(A=()=>{if(p.step!=="search")return;const G=new AbortController,ee=d.trim(),ae=setTimeout(async()=>{if(!ee){h({step:"search",status:"idle",results:[]});return}h({step:"search",status:"loading",results:[]});try{const X=await Ek(ee,G.signal);G.signal.aborted||h({step:"search",status:"ready",results:X})}catch{G.signal.aborted||h({step:"search",status:"error",results:[]})}},350);return()=>{clearTimeout(ae),G.abort()}},R=[d,p.step],e[5]=d,e[6]=p.step,e[7]=A,e[8]=R):(A=e[7],R=e[8]),c.useEffect(A,R);let K,F;if(e[9]!==n||e[10]!==m||e[11]!==u||e[12]!==a||e[13]!==d||e[14]!==I||e[15]!==S||e[16]!==N||e[17]!==b||e[18]!==p.extension||e[19]!==p.results||e[20]!==p.status||e[21]!==p.step||e[22]!==p.variants||e[23]!==i){const G=async se=>{const re=D.current?.signal;if(re){h({step:"package",status:"loading",extension:se}),y(new Set),j(null),k(new Set);try{const je=await Mk(se,re);re.aborted||h({step:"variants",extension:se,variants:je})}catch{re.aborted||h({step:"package",status:"error",extension:se})}}};let ee;e[26]!==m||e[27]!==S||e[28]!==N||e[29]!==b||e[30]!==p.step||e[31]!==p.variants||e[32]!==i?(ee=async()=>{if(p.step!=="variants"||N)return;const se=D.current?.signal;if(!se)return;x(!0),j(null);let re=!1;for(const je of p.variants){if(se.aborted)break;if(!(je.status!=="ready"||!b.has(je.key)||S.has(je.key)))try{if(await m(je.definition,{activate:!1}),se.aborted)break;y(ie=>new Set(ie).add(je.key)),k(ie=>{const Pe=new Set(ie);return Pe.delete(je.key),Pe})}catch{re=!0}}se.aborted||(x(!1),j(re?"partial":null),re?_a.error(i("settings.themeImport.partialError")):_a.success(i("settings.themeImport.complete")))},e[26]=m,e[27]=S,e[28]=N,e[29]=b,e[30]=p.step,e[31]=p.variants,e[32]=i,e[33]=ee):ee=e[33];const ae=ee;let X,Q;e[34]!==S||e[35]!==b||e[36]!==p.step||e[37]!==p.variants?(X=p.step==="variants"?p.variants.filter(se=>se.status==="ready"&&!S.has(se.key)):[],Q=X.length>0&&X.every(se=>b.has(se.key)),e[34]=S,e[35]=b,e[36]=p.step,e[37]=p.variants,e[38]=X,e[39]=Q):(X=e[38],Q=e[39]);const le=Q;let Z;e[40]!==n||e[41]!==ae||e[42]!==N||e[43]!==b||e[44]!==p.step||e[45]!==i?(Z=p.step==="variants"&&s.jsx(q,{disabled:!b.size||N||n,onClick:()=>{ae()},children:i(N?"settings.themeImport.busy":"settings.themeImport.importSelected")}),e[40]=n,e[41]=ae,e[42]=N,e[43]=b,e[44]=p.step,e[45]=i,e[46]=Z):Z=e[46];const fe=N||n;let Y;e[47]!==i?(Y=i("settings.themeImport.chooseFile"),e[47]=i,e[48]=Y):Y=e[48];let be;e[49]!==a||e[50]!==fe||e[51]!==Y?(be=s.jsx(q,{variant:"outline",className:"self-start",disabled:fe,onClick:a,children:Y}),e[49]=a,e[50]=fe,e[51]=Y,e[52]=be):be=e[52];let Ee;e[53]!==Z||e[54]!==be?(Ee=s.jsxs(s.Fragment,{children:[Z,be]}),e[53]=Z,e[54]=be,e[55]=Ee):Ee=e[55],K=Ee,F=s.jsx(s.Fragment,{children:p.step==="search"?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{autoFocus:!0,"aria-label":i("settings.themeImport.search"),placeholder:i("settings.themeImport.search"),value:d,maxLength:160,onChange:se=>f(se.target.value)}),s.jsxs("div",{className:u?"space-y-1":"max-h-[45dvh] overflow-y-auto space-y-1","aria-live":"polite",children:[p.status==="loading"&&s.jsx("p",{className:"text-muted-foreground",children:i("common.loading")}),p.status==="error"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:i("settings.themeImport.catalogError")}),p.status==="ready"&&!p.results.length&&s.jsx("p",{className:"text-muted-foreground",children:i("settings.themeImport.empty")}),p.results.map(se=>s.jsxs(q,{variant:"ghost",className:"h-auto w-full justify-start py-2 text-start",onClick:()=>{G(se)},children:[s.jsx(Dk,{extension:se}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate",children:se.label}),s.jsx("span",{className:"block truncate typography-meta text-muted-foreground",children:se.namespace})]})]},`${se.namespace}.${se.name}`))]})]}):s.jsxs(s.Fragment,{children:[s.jsxs(q,{variant:"ghost",size:"sm",className:"justify-start",disabled:N||p.step==="package"&&p.status==="loading",onClick:()=>h({step:"search",status:"idle",results:[]}),children:[s.jsx(J,{name:"arrow-left",className:"size-4"}),i("settings.themeImport.back")]}),s.jsx("p",{className:"typography-ui-label",children:p.extension.label}),I==="partial"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:i("settings.themeImport.partialError")}),p.step==="package"?p.status==="loading"?s.jsx("p",{role:"status",children:i("common.loading")}):s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:i("settings.themeImport.catalogError")}):s.jsxs(s.Fragment,{children:[p.variants.length>1&&s.jsx(q,{variant:"ghost",size:"sm",className:"self-start",disabled:N||n||!X.length,onClick:()=>k(le?new Set:new Set(X.map(Ok))),children:i(le?"settings.themeImport.deselectAll":"settings.themeImport.selectAll")}),s.jsx("div",{className:u?"space-y-2":"max-h-[45dvh] overflow-y-auto space-y-2",children:p.variants.map(se=>s.jsxs("div",{className:"flex items-center gap-3",children:[se.status==="ready"&&s.jsxs("div",{"aria-hidden":"true",className:"flex w-20 shrink-0 items-center gap-2 rounded px-2 py-3",style:{backgroundColor:se.theme.colors.surface.background,color:se.theme.colors.surface.foreground},children:[s.jsx("span",{children:"Aa"}),s.jsx("span",{className:"space-y-1",children:[se.theme.colors.syntax.base.keyword,se.theme.colors.syntax.base.string,se.theme.colors.syntax.base.function].map(Fk)})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[S.has(se.key)?s.jsxs("div",{className:"flex items-center gap-2 py-1",children:[s.jsx(J,{name:"check",className:"size-4 shrink-0 text-[var(--status-success-text)]"}),s.jsx("span",{className:"typography-ui-label",children:se.name})]}):s.jsx(it,{checked:b.has(se.key),disabled:se.status!=="ready"||N||n,label:se.name,onChange:re=>k(je=>{const ie=new Set(je);return re?ie.add(se.key):ie.delete(se.key),ie})}),s.jsx("p",{className:S.has(se.key)?"typography-meta font-medium text-[var(--status-success-text)]":"typography-meta text-muted-foreground",children:se.status!=="ready"?i("settings.themeImport.error.invalid"):S.has(se.key)?i("settings.themeImport.installed"):i(se.theme.metadata.variant==="dark"?"settings.openchamber.visual.option.themeMode.dark":"settings.openchamber.visual.option.themeMode.light")})]})]},se.key))})]})]})}),e[9]=n,e[10]=m,e[11]=u,e[12]=a,e[13]=d,e[14]=I,e[15]=S,e[16]=N,e[17]=b,e[18]=p.extension,e[19]=p.results,e[20]=p.status,e[21]=p.step,e[22]=p.variants,e[23]=i,e[24]=K,e[25]=F}else K=e[24],F=e[25];const T=F;if(u){let G;e[56]!==i?(G=i("settings.themeImport.catalogTitle"),e[56]=i,e[57]=G):G=e[57];let ee;e[58]!==K?(ee=s.jsx("div",{className:"flex flex-col gap-2",children:K}),e[58]=K,e[59]=ee):ee=e[59];let ae;e[60]!==i?(ae=i("settings.themeImport.catalogHint"),e[60]=i,e[61]=ae):ae=e[61];let X;e[62]!==ae?(X=s.jsx("p",{className:"typography-meta text-muted-foreground",children:ae}),e[62]=ae,e[63]=X):X=e[63];let Q;e[64]!==T||e[65]!==X?(Q=s.jsxs("div",{className:"flex flex-col gap-4 px-1",children:[X,T]}),e[64]=T,e[65]=X,e[66]=Q):Q=e[66];let le;return e[67]!==o||e[68]!==ee||e[69]!==Q||e[70]!==G?(le=s.jsx(Xd,{open:!0,title:G,onClose:o,footer:ee,children:Q}),e[67]=o,e[68]=ee,e[69]=Q,e[70]=G,e[71]=le):le=e[71],le}let O;e[72]!==o?(O=G=>{G||o()},e[72]=o,e[73]=O):O=e[73];let E;e[74]===Symbol.for("react.memo_cache_sentinel")?(E={forceRender:!0},e[74]=E):E=e[74];let B;e[75]!==i?(B=i("settings.themeImport.catalogTitle"),e[75]=i,e[76]=B):B=e[76];let _;e[77]!==B?(_=s.jsx(_t,{children:B}),e[77]=B,e[78]=_):_=e[78];let H;e[79]!==i?(H=i("settings.themeImport.catalogHint"),e[79]=i,e[80]=H):H=e[80];let ne;e[81]!==H?(ne=s.jsx(Vt,{children:H}),e[81]=H,e[82]=ne):ne=e[82];let z;e[83]!==_||e[84]!==ne?(z=s.jsxs(Bt,{children:[_,ne]}),e[83]=_,e[84]=ne,e[85]=z):z=e[85];let $;e[86]!==K||e[87]!==T||e[88]!==z?($=s.jsxs(zt,{className:"max-w-lg",backdropProps:E,children:[z,T,K]}),e[86]=K,e[87]=T,e[88]=z,e[89]=$):$=e[89];let V;return e[90]!==$||e[91]!==O?(V=s.jsx(Kt,{open:!0,onOpenChange:O,children:$}),e[90]=$,e[91]=O,e[92]=V):V=e[92],V}function Fk(t,e){return s.jsx("span",{className:"block h-1 w-5 rounded",style:{backgroundColor:t}},e)}function Ok(t){return t.key}function Lk(t){return t.isMobile}function Kk(){const{t}=ze(),{importTheme:e,customThemesLoading:a}=ua(),n=Ja(),[o,i]=c.useState(!1),r=c.useCallback(()=>i(!1),[]),l=c.useRef(null),u=c.useRef(0),m=c.useRef(null),[d,f]=c.useState(!1);c.useEffect(()=>Ro(()=>{u.current+=1,i(!1)}),[]);const g=async(w,b)=>{f(!0);try{if(w.size>Zd)throw new na("size");const k=await w.text();if(b.key!==Qt()||b.generation!==u.current)throw new na("connection");const v=await e(lm(k,w.name));_a.success(t("settings.themeImport.success",{name:v.metadata.name})),i(!1)}catch(k){const v=k instanceof na?k.code:"invalid";_a.error(t(`settings.themeImport.error.${v}`))}finally{f(!1)}},p=async()=>{if(d)return;const w={key:Qt(),generation:u.current};if(m.current=w,!n.themeFiles){l.current?.click();return}f(!0);try{const b=await n.themeFiles.pick();if(b?.status==="picked"){if(b.file){const k=b.file;await g({name:k.name,size:k.size,text:async()=>k.text},w)}return}l.current?.click()}catch{_a.error(t("settings.themeImport.error.invalid"))}finally{f(!1)}},h=async w=>{const b=w.target.files?.[0];w.target.value="",b&&!d&&m.current&&await g(b,m.current)};return s.jsxs("div",{className:"flex items-center gap-2","data-settings-item":"appearance.import-theme",children:[s.jsxs(q,{variant:"outline",size:"sm",disabled:d||a,onClick:()=>i(!0),children:[s.jsx(J,{name:d?"loader":"add",className:d?"size-3.5 animate-spin":"size-3.5"}),t(d?"settings.themeImport.busy":"settings.themeImport.action")]}),s.jsx(qt,{children:t("settings.themeImport.catalogHint")}),s.jsx("input",{ref:l,type:"file",accept:".json,.jsonc",className:"hidden","aria-label":t("settings.themeImport.action"),onChange:h}),o&&s.jsx(Rk,{pickFile:()=>{p()},fileBusy:d,onClose:r})]})}const hd=(t,e,a)=>{const n=t?.querySelector("[cmdk-list]"),o=t?.querySelector(`[cmdk-item][data-value="${CSS.escape(e)}"]`);if(!n||!o)return;const i=n.getBoundingClientRect(),r=n.offsetHeight>0?i.height/n.offsetHeight:1;if(r<=0)return;const l=o.getBoundingClientRect(),u=(l.top-i.top)/r+n.scrollTop,m=l.height/r;a?.onlyIfHidden&&u>=n.scrollTop&&u+m<=n.scrollTop+n.clientHeight||(n.scrollTop=Math.max(0,u-(n.clientHeight-m)/2))};function bd({options:t,value:e,onValueChange:a,placeholder:n,ariaLabel:o}){const{t:i}=ze(),{deleteImportedTheme:r,customThemeIds:l}=ua(),{isMobile:u}=Fn(),[m,d]=c.useState(!1),[f,g]=c.useState(""),[p,h]=c.useState(void 0),[w,b]=c.useState(null),k=c.useRef(null),v=c.useRef(null),[S,y]=c.useState(null),[N,x]=c.useState(null),I=c.useCallback(T=>{const O=T instanceof HTMLElement?T:null,E=O?.closest('[data-slot="dialog-content"], [role="dialog"]');y(E instanceof HTMLElement?E:null),x(O?.closest("main")??null)},[]);c.useEffect(()=>{if(m)return Bp.suspend()},[m]);const j=c.useRef(e);j.current=e;const D=c.useCallback(T=>{T&&hd(T,j.current)},[]),C=t.find(T=>T.id===e),P=c.useMemo(()=>m?_n(t,f,T=>[T.label]):t,[m,t,f]),A=T=>{a(T),d(!1)},R=async T=>{if(!w){b(T.id);try{await r(T.id),k.current?.focus()}catch{_a.error(i("settings.themeImport.deleteError"))}finally{b(null)}}},K=T=>{if(!l.includes(T.id))return null;const O=w===T.id;return s.jsx(q,{variant:"ghost",size:"icon",className:"size-6 shrink-0",disabled:O,"aria-label":i("settings.themeImport.delete",{name:T.label}),onPointerDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),R(T)},children:s.jsx(J,{name:O?"loader":"delete-bin",className:O?"size-4 animate-spin":"size-4"})})},F=s.jsx("div",{role:"status",className:"px-3 py-6 text-center typography-ui-label text-muted-foreground",children:i("settings.openchamber.visual.field.noThemesFound")});return u?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","aria-label":o,"aria-haspopup":"dialog",className:Me(sn,!C&&"text-muted-foreground"),onClick:()=>{g(""),d(!0)},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:C?.label??n}),s.jsx(J,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(Xd,{open:m,title:o,onClose:()=>d(!1),children:s.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[s.jsx(Ve,{value:f,onChange:T=>g(T.target.value),placeholder:i("settings.openchamber.visual.field.searchThemes"),"aria-label":i("settings.openchamber.visual.field.searchThemes"),className:"h-9"}),s.jsx("div",{className:"flex flex-col",role:"listbox","aria-label":o,children:P.length===0?F:P.map(T=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",role:"option","aria-selected":T.id===e,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg px-2 py-2.5 text-start typography-ui-label hover:bg-[var(--interactive-hover)]",onClick:()=>A(T.id),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.label}),T.id===e?s.jsx(J,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null]}),K(T)]},T.id))})]})})]}):s.jsxs(Ef,{open:m,onOpenChange:T=>{g(""),h(T?e:void 0),d(T)},onOpenChangeComplete:T=>{if(!T){v.current?.focus();return}k.current?.focus(),hd(k.current?.closest('[data-slot="command"]'),e,{onlyIfHidden:!0})},children:[s.jsxs(Mf,{ref:v,"aria-label":o,"aria-haspopup":"dialog",className:Me(sn,!C&&"text-muted-foreground"),onPointerDownCapture:T=>I(T.currentTarget),onFocusCapture:T=>I(T.currentTarget),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:C?.label??n}),s.jsx(J,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(Df,{container:S??void 0,children:s.jsx(Rf,{side:"bottom",align:"start",sideOffset:4,collisionAvoidance:{side:"none"},collisionBoundary:N??void 0,className:"z-[120]",children:s.jsx(Ff,{role:"dialog","aria-label":o,className:Me(Jp,"flex w-[var(--anchor-width)] min-w-[16rem] max-w-[calc(100vw-2rem)] flex-col p-0"),initialFocus:!1,finalFocus:!1,children:s.jsxs(_p,{ref:D,className:"min-h-0 flex-1",shouldFilter:!1,value:p,onValueChange:h,children:[s.jsx(Vp,{ref:k,"aria-label":i("settings.openchamber.visual.field.searchThemes"),placeholder:i("settings.openchamber.visual.field.searchThemes"),value:f,onValueChange:g,onKeyDown:T=>{if(Hp(T)){T.stopPropagation();return}qp(T,O=>{T.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:O,bubbles:!0,cancelable:!0}))})}}),s.jsx(Wp,{label:o,className:"max-h-[20rem] p-1",children:P.length===0?F:P.map(T=>s.jsxs(Gp,{value:T.id,onSelect:A,"aria-current":T.id===e?!0:void 0,className:"max-w-full typography-ui-label",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.label}),T.id===e?s.jsx(J,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null,K(T)]},T.id))})]})})})})]})}const zk=2e3,Uk=3,$k=(t,e)=>t.state==="unsupported"||t.state==="failed"?!0:e?t.state==="on"&&t.index?.backfill.state!=="running":t.state==="off",Bk=t=>{const e=t/1e6;return new Intl.NumberFormat(xl(),{style:"unit",unit:"megabyte",maximumFractionDigits:e<10?1:0}).format(e)},_k=()=>{const t=$e.c(70),{t:e}=ze(),a=oe(Vk),n=oe(Hk),o=oe(qk),i=oe(Wk);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={kind:"loading"},t[0]=r):r=t[0];const[l,u]=c.useState(r),[m,d]=c.useState(!1),f=c.useRef(o);let g,p;t[1]!==a||t[2]!==o?(g=()=>{const _=a&&o&&!f.current;f.current=o;const H=new AbortController;let ne,z=_?Uk:0;const $=()=>{Yp(H.signal).then(V=>{if(H.signal.aborted)return;u({kind:"ready",status:V}),V.index?.backfill.state==="running"&&(z=0);const G=z>0;z=z-1,(!$k(V,a)||G)&&(ne=setTimeout($,zk))}).catch(()=>{H.signal.aborted||u({kind:"error"})})};return $(),()=>{H.abort(),clearTimeout(ne)}},p=[a,o],t[1]=a,t[2]=o,t[3]=g,t[4]=p):(g=t[3],p=t[4]),c.useEffect(g,p);let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{d(!0),Qp().then(_=>u({kind:"ready",status:_})).catch(()=>u({kind:"error"})).finally(()=>d(!1))},t[5]=h):h=t[5];const w=h,b=l.kind==="ready"?l.status:null,k=b?.state==="unsupported";let v;if(t[6]!==a||t[7]!==b?.sizeBytes||t[8]!==e||t[9]!==l.kind||t[10]!==l.status){const _=Bk(b?.sizeBytes??0);if(l.kind==="loading"){let H;t[12]!==e?(H=e("settings.openchamber.messageSearch.status.loading"),t[12]=e,t[13]=H):H=t[13],v=H}else if(l.kind==="error"){let H;t[14]!==e?(H=e("settings.openchamber.messageSearch.status.error"),t[14]=e,t[15]=H):H=t[15],v=H}else if(l.status.state==="unsupported"){let H;t[16]!==e?(H=e("settings.openchamber.messageSearch.status.unsupported"),t[16]=e,t[17]=H):H=t[17],v=H}else if(!a)v=l.status.sizeBytes>0?e("settings.openchamber.messageSearch.status.offWithFile",{size:_}):e("settings.openchamber.messageSearch.status.off");else if(l.status.state==="failed"){let H;t[18]!==e?(H=e("settings.openchamber.messageSearch.status.failed"),t[18]=e,t[19]=H):H=t[19],v=H}else if(l.status.state==="on"&&l.status.index?.backfill.state==="running")v=e("settings.openchamber.messageSearch.status.indexing",{done:l.status.index.backfill.done,total:l.status.index.backfill.total,size:_});else if(l.status.state==="on"&&l.status.index)v=e("settings.openchamber.messageSearch.status.ready",{sessions:l.status.index.sessions,messages:l.status.index.messages,size:_});else{let H;t[20]!==e?(H=e("settings.openchamber.messageSearch.status.loading"),t[20]=e,t[21]=H):H=t[21],v=H}t[6]=a,t[7]=b?.sizeBytes,t[8]=e,t[9]=l.kind,t[10]=l.status,t[11]=v}else v=t[11];let S;t[22]!==e?(S=e("settings.openchamber.messageSearch.title"),t[22]=e,t[23]=S):S=t[23];let y;t[24]!==e?(y=e("settings.openchamber.messageSearch.field.enabled"),t[24]=e,t[25]=y):y=t[25];let N;t[26]!==e?(N=e("settings.openchamber.messageSearch.field.enabled"),t[26]=e,t[27]=N):N=t[27];let x;t[28]!==e?(x=e("settings.openchamber.messageSearch.field.enabledInfo"),t[28]=e,t[29]=x):x=t[29];let I;t[30]!==a||t[31]!==n||t[32]!==y||t[33]!==N||t[34]!==x||t[35]!==k?(I=s.jsx(it,{settingsItem:"chat.message-search-enabled",checked:a,onChange:n,disabled:k,label:y,ariaLabel:N,info:x}),t[30]=a,t[31]=n,t[32]=y,t[33]=N,t[34]=x,t[35]=k,t[36]=I):I=t[36];const j=a&&o,D=!a||k;let C;t[37]!==e?(C=e("settings.openchamber.messageSearch.field.reasoning"),t[37]=e,t[38]=C):C=t[38];let P;t[39]!==e?(P=e("settings.openchamber.messageSearch.field.reasoning"),t[39]=e,t[40]=P):P=t[40];let A;t[41]!==e?(A=e("settings.openchamber.messageSearch.field.reasoningInfo"),t[41]=e,t[42]=A):A=t[42];let R;t[43]!==i||t[44]!==D||t[45]!==C||t[46]!==P||t[47]!==A||t[48]!==j?(R=s.jsx(it,{settingsItem:"chat.message-search-reasoning",checked:j,onChange:i,disabled:D,label:C,ariaLabel:P,info:A}),t[43]=i,t[44]=D,t[45]=C,t[46]=P,t[47]=A,t[48]=j,t[49]=R):R=t[49];let K;t[50]!==e?(K=e("settings.openchamber.messageSearch.field.index"),t[50]=e,t[51]=K):K=t[51];let F;t[52]!==a||t[53]!==b||t[54]!==e||t[55]!==m?(F=a?s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:w,disabled:m||b?.state!=="on"&&b?.state!=="failed",children:e(m?"settings.openchamber.messageSearch.actions.working":"settings.openchamber.messageSearch.actions.rebuild")}):s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:w,disabled:m||!b||b.state==="on"||b.sizeBytes===0,children:e(m?"settings.openchamber.messageSearch.actions.working":"settings.openchamber.messageSearch.actions.delete")}),t[52]=a,t[53]=b,t[54]=e,t[55]=m,t[56]=F):F=t[56];let T;t[57]!==K||t[58]!==F?(T=s.jsx(kt,{label:K,children:F}),t[57]=K,t[58]=F,t[59]=T):T=t[59];let O;t[60]!==v?(O=s.jsx("p",{className:Dt,"aria-live":"polite",children:v}),t[60]=v,t[61]=O):O=t[61];let E;t[62]!==R||t[63]!==T||t[64]!==O?(E=s.jsxs(da,{children:[R,T,O]}),t[62]=R,t[63]=T,t[64]=O,t[65]=E):E=t[65];let B;return t[66]!==E||t[67]!==S||t[68]!==I?(B=s.jsxs(He,{title:S,settingsItem:"chat.message-search",children:[I,E]}),t[66]=E,t[67]=S,t[68]=I,t[69]=B):B=t[69],B};function Vk(t){return t.messageSearchEnabled}function Hk(t){return t.setMessageSearchEnabled}function qk(t){return t.messageSearchReasoningEnabled}function Wk(t){return t.setMessageSearchReasoningEnabled}const Gk=()=>{oe.getState().requestSettingsJump("sessions","sessions.small-model")},Jk=t=>{const e=$e.c(33),{disabled:a}=t,n=a===void 0?!1:a,{t:o}=ze(),i=oe(Yk),r=oe(Zk),l=Wt(jl),u=!Ln(),m=l?i:"small-model";let d;e[0]!==o?(d=o("settings.openchamber.visual.goal.checkerLabel"),e[0]=o,e[1]=d):d=e[1];let f;e[2]!==o?(f=o("settings.openchamber.visual.goal.checkerInfo"),e[2]=o,e[3]=f):f=e[3];let g;e[4]!==o?(g=o("settings.openchamber.visual.goal.checkerLabel"),e[4]=o,e[5]=g):g=e[5];const p=n||!l;let h;e[6]!==p?(h={value:"classifier",label:"Jev",disabled:p},e[6]=p,e[7]=h):h=e[7];let w;e[8]!==o?(w=o("settings.openchamber.visual.goal.checker.smallModel"),e[8]=o,e[9]=w):w=e[9];let b;e[10]!==n||e[11]!==w?(b={value:"small-model",label:w,disabled:n},e[10]=n,e[11]=w,e[12]=b):b=e[12];let k;e[13]!==h||e[14]!==b?(k=[h,b],e[13]=h,e[14]=b,e[15]=k):k=e[15];let v;e[16]!==r||e[17]!==m||e[18]!==g||e[19]!==k?(v=s.jsx(Gs,{"aria-label":g,value:m,onChange:r,options:k}),e[16]=r,e[17]=m,e[18]=g,e[19]=k,e[20]=v):v=e[20];let S;e[21]!==v||e[22]!==d||e[23]!==f?(S=s.jsx(kt,{settingsItem:"chat.session-goal-checker",label:d,info:f,children:v}),e[21]=v,e[22]=d,e[23]=f,e[24]=S):S=e[24];let y;e[25]!==u||e[26]!==l||e[27]!==m||e[28]!==o?(y=m==="classifier"?s.jsx(zo,{}):s.jsxs("p",{className:Dt,children:[o(l?"settings.openchamber.visual.goal.checker.viaSmallModel":"settings.openchamber.visual.goal.checker.jevMissing")," ",s.jsx(Mn,{onClick:Gk,children:o("settings.openchamber.visual.goal.checker.smallModelLink")}),l||!u?null:s.jsxs(s.Fragment,{children:[" · ",s.jsx(Mn,{onClick:Ao,children:o("settings.jevAccess.setUp")})]})]}),e[25]=u,e[26]=l,e[27]=m,e[28]=o,e[29]=y):y=e[29];let N;return e[30]!==S||e[31]!==y?(N=s.jsxs("div",{className:"space-y-1",children:[S,y]}),e[30]=S,e[31]=y,e[32]=N):N=e[32],N},Qk=t=>{const e=$e.c(32),{disabled:a}=t,n=a===void 0?!1:a,{t:o}=ze(),i=oe(Xk),r=oe(ew);let l;e[0]!==o?(l=o("settings.openchamber.visual.goal.maxTurnsLabel"),e[0]=o,e[1]=l):l=e[1];let u;e[2]!==o?(u=o("settings.openchamber.visual.goal.maxTurnsInfo"),e[2]=o,e[3]=u):u=e[3];let m;e[4]!==r?(m=y=>r(Math.floor(y)),e[4]=r,e[5]=m):m=e[5];let d;e[6]!==o?(d=o("settings.openchamber.visual.goal.maxTurnsLabel"),e[6]=o,e[7]=d):d=e[7];let f;e[8]!==n||e[9]!==i||e[10]!==m||e[11]!==d?(f=s.jsx(ps,{value:i,onValueChange:m,min:1,max:Ug,step:1,disabled:n,className:fs,"aria-label":d}),e[8]=n,e[9]=i,e[10]=m,e[11]=d,e[12]=f):f=e[12];let g;e[13]!==r?(g=()=>r(nc),e[13]=r,e[14]=g):g=e[14];const p=n||i===nc;let h;e[15]!==o?(h=o("settings.openchamber.visual.goal.maxTurnsResetAria"),e[15]=o,e[16]=h):h=e[16];let w;e[17]!==o?(w=o("settings.common.actions.reset"),e[17]=o,e[18]=w):w=e[18];let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"}),e[19]=b):b=e[19];let k;e[20]!==w||e[21]!==g||e[22]!==p||e[23]!==h?(k=s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:g,disabled:p,className:os,"aria-label":h,title:w,children:b}),e[20]=w,e[21]=g,e[22]=p,e[23]=h,e[24]=k):k=e[24];let v;e[25]!==k||e[26]!==f?(v=s.jsxs("div",{className:Xn,children:[f,k]}),e[25]=k,e[26]=f,e[27]=v):v=e[27];let S;return e[28]!==v||e[29]!==l||e[30]!==u?(S=s.jsx(kt,{settingsItem:"chat.session-goal-max-turns",label:l,info:u,children:v}),e[28]=v,e[29]=l,e[30]=u,e[31]=S):S=e[31],S};function Yk(t){return t.sessionGoalChecker}function Zk(t){return t.setSessionGoalChecker}function Xk(t){return t.sessionGoalMaxAutoTurns}function ew(t){return t.setSessionGoalMaxAutoTurns}const tw=[{value:"system",labelKey:"settings.openchamber.visual.option.themeMode.system",descriptionKey:"settings.openchamber.visual.option.themeMode.system.description"},{value:"light",labelKey:"settings.openchamber.visual.option.themeMode.light",descriptionKey:"settings.openchamber.visual.option.themeMode.light.description"},{value:"dark",labelKey:"settings.openchamber.visual.option.themeMode.dark",descriptionKey:"settings.openchamber.visual.option.themeMode.dark.description"}],sw=[{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"}],nw=[{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"}],hi="OpenChamber - AI Coding Assistant",xd=[{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"}],vd=[{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"}],Fr=t=>t==="portrait"||t==="landscape"?t:"system",aw=[{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"}],yd=[{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"}],iw=[{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"}],jd=[{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"}],kd=[{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"}],ow=[{id:"steer",labelKey:"settings.openchamber.visual.option.followUpBehavior.steer.label"},{id:"queue",labelKey:"settings.openchamber.visual.option.followUpBehavior.queue.label"}],rw=[{id:"ask",labelKey:"settings.openchamber.visual.option.largeTextPaste.ask.label"},{id:"attach",labelKey:"settings.openchamber.visual.option.largeTextPaste.attach.label"},{id:"inline",labelKey:"settings.openchamber.visual.option.largeTextPaste.inline.label"},{id:"inline-double-paste",labelKey:"settings.openchamber.visual.option.largeTextPaste.inlineDoublePaste.label"}],lw=[{id:"global",labelKey:"settings.openchamber.visual.option.inputHistoryScope.global.label"},{id:"session",labelKey:"settings.openchamber.visual.option.inputHistoryScope.session.label"}],cw=t=>t==="markdown"?"markdown":"plain",dw=[{id:"left",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsLeft"},{id:"right",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsRight"}],uw=[{id:"classic",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsClassic"},{id:"traffic-lights",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsTrafficLights"}],$o=({visibleSettings:t})=>{const{locale:e,locales:a,setLocale:n,label:o,t:i}=ze(),r=c.useCallback(M=>i(M),[i]),{isMobile:l}=Fn(),{terminal:u}=Ja(),{browserTab:m}=hf(),d=$g(),f=oe(M=>M.showReasoningTraces),g=oe(M=>M.sessionRecapEnabled),p=oe(M=>M.sessionSuggestionEnabled),h=oe(M=>M.setSessionRecapEnabled),w=oe(M=>M.setSessionSuggestionEnabled),b=oe(M=>M.sessionReviewOfferEnabled),k=oe(M=>M.setSessionReviewOfferEnabled),v=Wt(jl),S=oe(M=>M.sessionGoalEnabled),y=oe(M=>M.setSessionGoalEnabled),N=oe(M=>M.sessionGoalDefaultBudgetEnabled),x=oe(M=>M.setSessionGoalDefaultBudgetEnabled),I=oe(M=>M.sessionGoalDefaultBudget),j=oe(M=>M.setSessionGoalDefaultBudget),D=oe(M=>M.setShowReasoningTraces),C=oe(M=>M.streamingAutoFollowEnabled),P=oe(M=>M.setStreamingAutoFollowEnabled),A=oe(M=>M.collapsibleThinkingBlocks),R=oe(M=>M.setCollapsibleThinkingBlocks),K=oe(M=>M.expandReasoningWhileStreaming),F=oe(M=>M.setExpandReasoningWhileStreaming),T=yo(M=>M.animatedActivityIndicators),O=yo(M=>M.setAnimatedActivityIndicators),E=oe(M=>M.mermaidRenderingMode),B=oe(M=>M.setMermaidRenderingMode),_=oe(M=>M.userMessageRenderingMode),H=oe(M=>M.setUserMessageRenderingMode),ne=oe(M=>M.collapsibleUserMessages),z=oe(M=>M.setCollapsibleUserMessages),$=oe(M=>M.promptNavigatorEnabled),V=oe(M=>M.setPromptNavigatorEnabled),G=oe(M=>M.autoSaveEnabled),ee=oe(M=>M.setAutoSaveEnabled),ae=oe(M=>M.confirmFileTreeMove),X=oe(M=>M.setConfirmFileTreeMove),Q=oe(M=>M.layoutAnimations),le=oe(M=>M.fileTreeSide),Z=oe(M=>M.setFileTreeSide),fe=oe(M=>M.setLayoutAnimations),Y=oe(M=>M.openLinksInBrowserPanel),be=oe(M=>M.setOpenLinksInBrowserPanel),Ee=oe(M=>M.openTrackerLinksOnBoard),se=oe(M=>M.setOpenTrackerLinksOnBoard),re=oe(M=>M.wideChatLayoutEnabled),je=oe(M=>M.setWideChatLayoutEnabled),ie=oe(M=>M.codeBlockLineWrap),Pe=oe(M=>M.setCodeBlockLineWrap),ke=oe(M=>M.tableCellWrap),Ae=oe(M=>M.setTableCellWrap),Te=oe(M=>M.copyMessagesAsPlainText),Ke=oe(M=>M.setCopyMessagesAsPlainText),ge=oe(M=>M.activityRenderMode),Re=oe(M=>M.setActivityRenderMode),Oe=oe(M=>M.fontSize),pe=oe(M=>M.setFontSize),xe=oe(M=>M.terminalFontSize),Ne=oe(M=>M.setTerminalFontSize),de=oe(M=>M.terminalShell),Ue=oe(M=>M.setTerminalShell),Ie=oe(M=>M.terminalLoginShells),De=oe(M=>M.setTerminalLoginShells),Je=oe(M=>M.editorFontSize),tt=oe(M=>M.setEditorFontSize),{uiFont:mt,monoFont:ht}=Zp(),ft=oe(M=>M.setUiFont),xt=oe(M=>M.setMonoFont),Qe=oe(M=>M.customUiFont),lt=oe(M=>M.customMonoFont),Ye=oe(M=>M.setCustomUiFont),at=oe(M=>M.setCustomMonoFont),dt=Ln(),_e=oe(M=>M.padding),nt=oe(M=>M.setPadding),te=oe(M=>M.inputBarOffset),ue=oe(M=>M.setInputBarOffset),he=oe(M=>M.mobileKeyboardMode),ye=oe(M=>M.setMobileKeyboardMode),qe=oe(M=>M.diffLayoutPreference),Ze=oe(M=>M.setDiffLayoutPreference),pt=oe(M=>M.showTerminalQuickKeysOnDesktop),vt=oe(M=>M.sessionTabsEnabled),bt=oe(M=>M.setSessionTabsEnabled),wt=oe(M=>M.setShowTerminalQuickKeysOnDesktop),Et=oe(M=>M.fileEditorKeymap),Le=oe(M=>M.setFileEditorKeymap),Xe=oe(M=>M.fileEditorVimMappings),gt=oe(M=>M.setFileEditorVimMappings),jt=c.useMemo(()=>If(Xe).invalidLines,[Xe]),L=ac(M=>M.followUpBehavior),me=ac(M=>M.setFollowUpBehavior),Se=Gi(M=>M.scope),Ce=Gi(M=>M.entryLimit),We=Gi(M=>M.applyScope),ce=Gi(M=>M.applyEntryLimit),Fe=oe(M=>M.persistChatDraft),ct=oe(M=>M.setPersistChatDraft),Ft=oe(M=>M.inputSpellcheckEnabled),It=oe(M=>M.setInputSpellcheckEnabled),ls=oe(M=>M.largeTextPasteBehavior),et=oe(M=>M.setLargeTextPasteBehavior),st=oe(M=>M.enterToSend),Ht=oe(M=>M.setEnterToSend),is=oe(M=>M.enterToSendConfigured),us=oe(M=>M.setEnterToSendConfigured),Jt=is?st:!l,Ss=oe(M=>M.showToolFileIcons),vn=oe(M=>M.setShowToolFileIcons),Xa=oe(M=>M.showTurnChangedFiles),Li=oe(M=>M.setShowTurnChangedFiles),ei=oe(M=>M.timeFormatPreference),Kn=oe(M=>M.setTimeFormatPreference),fa=oe(M=>M.weekStartPreference),ti=oe(M=>M.setWeekStartPreference),si=oe(M=>M.showSplitAssistantMessageActions),ni=oe(M=>M.setShowSplitAssistantMessageActions),ha=oe(M=>M.allowPromptingSubagentSessions),Ki=oe(M=>M.setAllowPromptingSubagentSessions),ai=oe(M=>M.draftStartersVisible),ii=oe(M=>M.setDraftStartersVisible),zi=rt(M=>M.settingsMessageStreamTransport),mn=rt(M=>M.setSettingsMessageStreamTransport),oi=zi,$s=rt(M=>M.settingsDefaultFileViewerPreview),Ui=rt(M=>M.setSettingsDefaultFileViewerPreview),{themeMode:Bo,setThemeMode:_o,availableThemes:ba,customThemesLoading:Vo,reloadCustomThemes:Ho,lightThemeId:$i,darkThemeId:Bi,setLightThemePreference:Bs,setDarkThemePreference:ri}=ua(),[li,xa]=c.useState(!1),qo=c.useMemo(()=>as()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),Wo=oe(M=>M.dockBadgeEnabled),Go=oe(M=>M.setDockBadgeEnabled),Jo=oe(M=>M.alwaysShowScrollbars===!0),Qo=oe(M=>M.setAlwaysShowScrollbars),Ds=Bg(),on=oe(M=>M.desktopWindowControlsPosition),Vn=oe(M=>M.setDesktopWindowControlsPosition),yn=oe(M=>M.desktopWindowControlsStyle),jn=oe(M=>M.setDesktopWindowControlsStyle),Ul=oe(M=>M.reportUsage),rn=oe(M=>M.setReportUsage),Yo=c.useCallback(M=>{rn(M),yt({reportUsage:M})},[rn]),va=c.useCallback(M=>{const Nt=a.find(Rs=>Rs===M);Nt&&(n(Nt),yt({locale:Nt}))},[a,n]),ya=c.useCallback(M=>{Vn(M),yt({desktopWindowControlsPosition:M})},[Vn]),Hn=c.useCallback(M=>{jn(M),yt({desktopWindowControlsStyle:M})},[jn]),ci=c.useCallback(M=>{H(M),yt({userMessageRenderingMode:M})},[H]),Zo=c.useCallback(M=>{V(M),yt({promptNavigatorEnabled:M})},[V]),ms=c.useCallback(M=>{ii(M),yt({draftStartersVisible:M})},[ii]),Xo=c.useCallback(M=>{z(M),yt({collapsibleUserMessages:M})},[z]),ja=c.useCallback(M=>{je(M),yt({wideChatLayoutEnabled:M})},[je]),ka=c.useCallback(M=>{ni(M),yt({showSplitAssistantMessageActions:M})},[ni]),er=c.useCallback(M=>{It(M),yt({inputSpellcheckEnabled:M})},[It]),di=c.useCallback(M=>{Ht(M),us(!0),yt({enterToSend:M,enterToSendConfigured:!0})},[Ht,us]),_i=c.useCallback(M=>{mn(M),yt({messageStreamTransport:M})},[mn]),Vi=c.useCallback(M=>{We(M),yt({inputHistoryScope:M})},[We]),wa=c.useCallback(M=>{const Nt=Math.round(M);_g(Nt)&&(ce(Nt),yt({inputHistoryLimit:Nt}))},[ce]),Sa=c.useCallback(M=>{Re(M),yt({activityRenderMode:M,chatRenderMode:"live"})},[Re]),Hi=c.useCallback(M=>{B(M),yt({mermaidRenderingMode:M})},[B]),tr=c.useCallback(M=>{vn(M),yt({showToolFileIcons:M})},[vn]),Na=c.useCallback(M=>{Li(M),yt({showTurnChangedFiles:M})},[Li]),sr=c.useCallback(M=>{Ui(M),yt({defaultFileViewerPreview:M}),window.dispatchEvent(new CustomEvent("openchamber:file-viewer-preview-mode-changed",{detail:{enabled:M}}))},[Ui]),Ca=c.useCallback(M=>{Kn(M),yt({timeFormatPreference:M})},[Kn]),nr=c.useCallback(M=>{ti(M),yt({weekStartPreference:M})},[ti]),qn=c.useMemo(()=>ba.filter(M=>M.metadata.variant==="light").sort((M,Nt)=>M.metadata.name.localeCompare(Nt.metadata.name)),[ba]),Wn=c.useMemo(()=>ba.filter(M=>M.metadata.variant==="dark").sort((M,Nt)=>M.metadata.name.localeCompare(Nt.metadata.name)),[ba]),ar=c.useMemo(()=>qn.find(M=>M.metadata.id===$i)??qn[0],[qn,$i]),ir=c.useMemo(()=>Wn.find(M=>M.metadata.id===Bi)??Wn[0],[Wn,Bi]),Ia=c.useCallback((M,Nt)=>{const Rs=Nt==="dark"?" Dark":" Light";return M.endsWith(Rs)?M.slice(0,-Rs.length):M},[]),or=c.useMemo(()=>qn.map(M=>({id:M.metadata.id,label:Ia(M.metadata.name,"light")})),[qn,Ia]),Gn=c.useMemo(()=>Wn.map(M=>({id:M.metadata.id,label:Ia(M.metadata.name,"dark")})),[Wn,Ia]),we=M=>M==="enterToSend"&&l?!1:t?t.includes(M):!0,Zt=cs(),Pa=we("theme")&&!Zt,U=we("windowControlsPosition")&&Ds,ve=we("theme")||we("timeFormat")||we("weekStart"),Ge=Zt?ve:we("theme")||U||we("pwaInstallName")||we("pwaOrientation")||we("timeFormat")||we("weekStart"),ut=we("fontSize")||we("terminalFontSize")||we("editorFontSize")||we("spacing")||we("scrollbars")&&!Pa||we("inputBarOffset")&&l,$t=we("terminalQuickKeys")&&!l||(we("terminalShell")||we("terminalLoginShell"))&&!Zt||we("fileEditorKeymap")||we("autoSaveEnabled")||we("confirmFileTreeMove")&&!Zt&&!l||we("layoutAnimations")&&!Zt&&!l||we("openLinksInBrowserPanel")&&as()&&!l||we("openTrackerLinksOnBoard")&&!Zt||we("fileTreeSide")&&!Zt&&!l||we("sessionTabs")&&!Zt&&!l,xs=we("mermaidRendering")||we("sessionGoal")&&!Zt||we("userMessageRendering")||we("messageTransport")||we("activityRenderMode")||we("collapsibleUserMessages")||we("promptNavigatorEnabled")||we("wideChatLayout")||we("codeBlockLineWrap")||we("tableCellWrap")||we("copyMessagesAsPlainText")||we("splitAssistantMessageActions")||we("subagentReadOnlyBanner")||we("diffLayout")||we("dotfiles")||we("fileViewerPreview")||we("reasoning")||we("followUpBehavior")||we("inputHistoryScope")||we("inputHistoryLimit")||we("persistDraft")||we("largeTextPaste")||we("showToolFileIcons")||!l&&we("inputSpellcheck")||we("enterToSend"),_s=we("activityRenderMode"),ds=we("messageTransport"),Ps=we("userMessageRendering")||we("mermaidRendering")||we("diffLayout")&&!Zt||we("followUpBehavior")||we("inputHistoryScope")||we("inputHistoryLimit"),kn=we("sessionAssist")||we("sessionGoal")&&!Zt||we("subagentReadOnlyBanner")||we("collapsibleUserMessages")||we("promptNavigatorEnabled")||we("wideChatLayout")||we("codeBlockLineWrap")||we("tableCellWrap")||we("copyMessagesAsPlainText")||we("splitAssistantMessageActions")||we("dotfiles")||we("fileViewerPreview")||we("persistDraft")||we("largeTextPaste")||we("showToolFileIcons")||we("showTurnChangedFiles")||!l&&we("inputSpellcheck")||we("enterToSend")||we("reasoning"),Vs=Ge||ut||$t,ln=we("pwaInstallName")&&ca()&&m&&!as()&&!Zt,cn=we("pwaOrientation")&&ca()&&!as()&&!Zt,Ot=we("mobileKeyboardMode")&&ca()&&!as()&&!Zt&&Vg(),Xt=(we("terminalShell")||we("terminalLoginShell"))&&!Zt,[wn,zn]=c.useState([]),[Gt,Ns]=c.useState(0);c.useEffect(()=>Ro(()=>{zn([]),Ns(M=>M+1)}),[]),c.useEffect(()=>{let M=!1;if(!(!Xt||!u.listShells))return u.listShells().then(Nt=>{M||zn(Nt)}).catch(()=>{M||zn([])}),()=>{M=!0}},[Xt,u,Gt]);const Aa=c.useMemo(()=>{const M=wn.filter(Nt=>Nt.id!=="auto");return de==="auto"||M.some(Nt=>Nt.id===de)?M:[{id:de,name:de,supportsLogin:!1},...M]},[wn,de]),Ta=wn.find(M=>M.id===de)?.supportsLogin===!0,qi=Ie.includes(de),Cm=M=>{De(M?[...Ie.filter(Nt=>Nt!==de),de]:Ie.filter(Nt=>Nt!==de))},[rr,Jn]=c.useState(""),[Wi,Ea]=c.useState("system"),Im=c.useMemo(()=>{const M=jd.find(Nt=>Nt.id===ei);return r(M?.labelKey??"settings.openchamber.visual.option.timeFormat.auto.label")},[ei,r]),Pm=c.useMemo(()=>{const M=kd.find(Nt=>Nt.id===fa);return r(M?.labelKey??"settings.openchamber.visual.option.weekStart.auto.label")},[fa,r]),Am=c.useMemo(()=>{const M=xd.find(Nt=>Nt.id===Wi);return M?r(M.labelKey):void 0},[Wi,r]),Tm=c.useMemo(()=>{const M=vd.find(Nt=>Nt.id===he);return M?r(M.labelKey):void 0},[he,r]),lr=c.useCallback(async M=>{if(typeof window>"u")return;const Nt=window,Ma=M.trim().replace(/\s+/g," ").slice(0,64);if(await yt({pwaAppName:Ma}),typeof Nt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__=="function"){const dr=Nt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(Ma);Jn(dr);return}Jn(Ma||hi),Nt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),$l=c.useCallback(async M=>{if(typeof window>"u")return;const Nt=window,Rs=Fr(M);if(await yt({pwaOrientation:Rs}),typeof Nt.__OPENCHAMBER_SET_PWA_ORIENTATION__=="function"){const Ma=Nt.__OPENCHAMBER_SET_PWA_ORIENTATION__(Rs);Ea(Ma);return}Ea(Rs),Nt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);c.useEffect(()=>{if(typeof window>"u"||!ln&&!cn&&!Ot)return;let M=!1;return(async()=>{try{const Rs=await xn();if(!Rs){M||Jn(hi);return}const dr=(Rs.pwaAppName??"").trim().replace(/\s+/g," ").slice(0,64),Em=Fr(Rs.pwaOrientation),Mm=cc(Rs.mobileKeyboardMode);M||(ln&&Jn(dr||hi),cn&&Ea(Em),Ot&&ye(Mm))}catch{M||(ln&&Jn(hi),cn&&Ea("system"),Ot&&ye("native"))}})(),()=>{M=!0}},[ye,Ot,ln,cn]);const cr=we("scrollbars")?s.jsx(it,{checked:Jo,onChange:Qo,label:i("settings.openchamber.visual.field.alwaysShowScrollbars"),info:i("settings.openchamber.visual.field.alwaysShowScrollbarsHint"),settingsItem:"appearance.scrollbars"}):null;return s.jsxs("div",{className:"space-y-0",children:[Ge&&s.jsxs("div",{className:"space-y-0",children:[Pa&&s.jsxs(He,{title:i("settings.openchamber.visual.section.colorModeAndTheme"),divider:!1,children:[s.jsxs(Nn,{children:[s.jsx("div",{className:js,children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.section.colorMode"),children:tw.map(M=>s.jsx(ns,{selected:Bo===M.value,onSelect:()=>_o(M.value),label:r(M.labelKey),ariaLabel:r(M.labelKey)},M.value))})}),s.jsxs("div",{className:js,children:[s.jsx(Mt,{label:i("settings.openchamber.visual.field.lightTheme"),settingsItem:"appearance.light-theme",children:s.jsx(bd,{options:or,value:ar?.metadata.id??"",onValueChange:Bs,placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:i("settings.openchamber.visual.field.selectLightThemeAria")})}),s.jsx(Mt,{label:i("settings.openchamber.visual.field.darkTheme"),settingsItem:"appearance.dark-theme",children:s.jsx(bd,{options:Gn,value:ir?.metadata.id??"",onValueChange:ri,placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:i("settings.openchamber.visual.field.selectDarkThemeAria")})}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",disabled:Vo||li,onClick:()=>{const M=Date.now();xa(!0),Ho().finally(()=>{const Nt=Date.now()-M;if(Nt<500){window.setTimeout(()=>{xa(!1)},500-Nt);return}xa(!1)})},className:"typography-settings-link inline-flex items-center gap-1.5 disabled:cursor-not-allowed disabled:opacity-50 disabled:no-underline",children:[s.jsx(J,{name:"restart",className:Me("h-3.5 w-3.5",li&&"animate-spin")}),i(li?"settings.openchamber.visual.actions.reloadingThemes":"settings.openchamber.visual.actions.reloadThemes")]}),s.jsx(qt,{children:i("settings.openchamber.visual.field.themeImportInfoTooltip")})]}),s.jsx(Kk,{})]})]}),qo&&s.jsx(da,{settingsItem:"appearance.dock-badge",children:s.jsx(it,{checked:Wo,onChange:Go,label:i("settings.openchamber.visual.field.dockBadge"),info:i("settings.openchamber.visual.field.dockBadgeHint"),ariaLabel:i("settings.openchamber.visual.field.dockBadge")})}),cr&&s.jsx(da,{children:cr})]}),U&&s.jsx(He,{title:i("settings.openchamber.desktopNetwork.field.windowControls"),info:i("settings.openchamber.desktopNetwork.field.windowControlsPositionDescription"),divider:Pa,children:s.jsxs(Nn,{children:[s.jsx(Mt,{label:i("settings.openchamber.desktopNetwork.field.windowControlsPosition"),settingsItem:"sessions.desktop-window-controls-position",children:s.jsx(Gs,{value:on,options:dw.map(M=>({value:M.id,label:r(M.labelKey)})),onChange:ya,"aria-label":i("settings.openchamber.desktopNetwork.field.windowControlsPositionAria")})}),s.jsx(Mt,{label:i("settings.openchamber.desktopNetwork.field.windowControlsStyle"),settingsItem:"sessions.desktop-window-controls-style",children:s.jsx(Gs,{value:yn,options:uw.map(M=>({value:M.id,label:r(M.labelKey)})),onChange:Hn,"aria-label":i("settings.openchamber.desktopNetwork.field.windowControlsStyleAria")})})]})}),ve&&s.jsx(He,{title:i("settings.openchamber.visual.section.localization"),children:s.jsxs(Nn,{children:[s.jsx(Mt,{label:i("settings.appearance.language.label"),info:i("settings.appearance.language.description"),settingsItem:"appearance.language",children:s.jsxs(Tt,{value:e,onValueChange:va,children:[s.jsx(Pt,{"aria-label":i("settings.appearance.language.select"),className:Ra,children:s.jsx(Ut,{children:o(e)})}),s.jsx(At,{children:a.map(M=>s.jsx(ot,{value:M,children:o(M)},M))})]})}),(we("timeFormat")||we("weekStart"))&&s.jsxs("div",{className:js,children:[we("timeFormat")&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.timeFormat"),settingsItem:"appearance.time-format",children:s.jsxs(Tt,{value:ei,onValueChange:M=>Ca(M),children:[s.jsx(Pt,{"aria-label":i("settings.openchamber.visual.field.selectTimeFormatAria"),className:Ra,children:s.jsx(Ut,{children:Im})}),s.jsx(At,{children:jd.map(M=>s.jsx(ot,{value:M.id,children:r(M.labelKey)},M.id))})]})}),we("weekStart")&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.weekStartsOn"),settingsItem:"appearance.week-start",children:s.jsxs(Tt,{value:fa,onValueChange:M=>nr(M),children:[s.jsx(Pt,{"aria-label":i("settings.openchamber.visual.field.selectWeekStartAria"),className:Ra,children:s.jsx(Ut,{children:Pm})}),s.jsx(At,{children:kd.map(M=>s.jsx(ot,{value:M.id,children:r(M.labelKey)},M.id))})]})})]})]})}),(ln||cn||Ot)&&s.jsxs(He,{title:i("settings.openchamber.visual.section.appInstall"),contentClassName:js,children:[ln&&s.jsxs(kt,{label:i("settings.openchamber.visual.field.installAppName"),info:i("settings.openchamber.visual.field.installAppNameHint"),settingsItem:"appearance.pwa-install-name",alignEnd:!1,controlClassName:ys,children:[s.jsx(Ve,{value:rr,onChange:M=>{Jn(M.target.value)},onBlur:()=>{lr(rr)},onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),lr(rr))},className:"min-w-0 flex-1",maxLength:64,"aria-label":i("settings.openchamber.visual.field.pwaInstallAppNameAria")}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Jn(hi),lr("")},className:os,"aria-label":i("settings.openchamber.visual.actions.resetInstallAppNameAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})})]}),cn&&s.jsxs(kt,{label:i("settings.openchamber.visual.field.installOrientation"),description:i("settings.openchamber.visual.field.installOrientationHint"),settingsItem:"appearance.pwa-orientation",alignEnd:!1,controlClassName:ys,children:[s.jsxs(Tt,{value:Wi,onValueChange:M=>{const Nt=Fr(M);Ea(Nt),$l(Nt)},children:[s.jsx(Pt,{"aria-label":i("settings.openchamber.visual.field.pwaInstallOrientationAria"),className:Jl,children:s.jsx(Ut,{placeholder:i("settings.openchamber.visual.field.selectOrientationPlaceholder"),children:Am})}),s.jsx(At,{children:xd.map(M=>s.jsx(ot,{value:M.id,children:r(M.labelKey)},M.id))})]}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Ea("system"),$l("system")},disabled:Wi==="system",className:os,"aria-label":i("settings.openchamber.visual.actions.resetInstallOrientationAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})})]}),Ot&&s.jsxs(kt,{label:i("settings.openchamber.visual.field.mobileKeyboardMode"),info:i("settings.openchamber.visual.field.mobileKeyboardModeHint"),settingsItem:"appearance.mobile-keyboard-mode",alignEnd:!1,controlClassName:ys,children:[s.jsxs(Tt,{value:he,onValueChange:M=>{const Nt=cc(M);ye(Nt),yt({mobileKeyboardMode:Nt})},children:[s.jsx(Pt,{"aria-label":i("settings.openchamber.visual.field.mobileKeyboardModeAria"),className:Jl,children:s.jsx(Ut,{placeholder:i("settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder"),children:Tm})}),s.jsx(At,{children:vd.map(M=>s.jsx(ot,{value:M.id,children:r(M.labelKey)},M.id))})]}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{ye("native"),yt({mobileKeyboardMode:"native"})},disabled:he==="native",className:os,"aria-label":i("settings.openchamber.visual.actions.resetMobileKeyboardModeAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]}),ut&&s.jsxs(He,{title:i("settings.openchamber.visual.section.densityAndType"),contentClassName:js,children:[we("fontSize")&&!l||we("terminalFontSize")?s.jsxs(Nn,{children:[we("fontSize")&&!l&&s.jsxs(Mt,{label:i("settings.openchamber.visual.field.interfaceFont"),settingsItem:"appearance.interface-font-size",controlClassName:"w-full flex-wrap",children:[s.jsxs(Tt,{value:mt,onValueChange:M=>ft(M),children:[s.jsx(Pt,{"aria-label":i("settings.openchamber.visual.field.selectInterfaceFontAria"),className:Ra,children:s.jsx(Ut,{children:mt===Oa?i("settings.openchamber.visual.field.customFont"):ic.find(M=>M.id===mt)?.label})}),s.jsxs(At,{children:[ic.map(M=>s.jsx(ot,{value:M.id,disabled:dt&&!!M.source,children:s.jsx("span",{style:{fontFamily:M.stack},children:M.label})},M.id)),s.jsx(ot,{value:Oa,children:i("settings.openchamber.visual.field.customFont")})]})]}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>ft(oc),disabled:mt===oc,className:os,"aria-label":i("settings.openchamber.visual.actions.resetInterfaceFontAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})}),mt===Oa?s.jsx(Ve,{value:Qe,onChange:M=>Ye(M.target.value),placeholder:i("settings.openchamber.visual.field.customFontPlaceholder"),"aria-label":i("settings.openchamber.visual.field.customFontAria"),spellCheck:!1,autoComplete:"off",className:"h-8 basis-full rounded-md px-3"}):null]}),we("terminalFontSize")&&s.jsxs(Mt,{label:i("settings.openchamber.visual.field.codeFont"),controlClassName:"w-full flex-wrap",children:[s.jsxs(Tt,{value:ht,onValueChange:M=>xt(M),children:[s.jsx(Pt,{"aria-label":i("settings.openchamber.visual.field.selectCodeFontAria"),className:Ra,children:s.jsx(Ut,{children:ht===Oa?i("settings.openchamber.visual.field.customFont"):rc.find(M=>M.id===ht)?.label})}),s.jsxs(At,{children:[rc.map(M=>s.jsx(ot,{value:M.id,disabled:dt&&!!M.source,children:s.jsx("span",{style:{fontFamily:M.stack},children:M.label})},M.id)),s.jsx(ot,{value:Oa,children:i("settings.openchamber.visual.field.customFont")})]})]}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>xt(lc),disabled:ht===lc,className:os,"aria-label":i("settings.openchamber.visual.actions.resetCodeFontAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})}),ht===Oa?s.jsx(Ve,{value:lt,onChange:M=>at(M.target.value),placeholder:i("settings.openchamber.visual.field.customFontPlaceholder"),"aria-label":i("settings.openchamber.visual.field.customFontAria"),spellCheck:!1,autoComplete:"off",className:"h-8 basis-full rounded-md px-3"}):null]})]}):null,dt&&(we("fontSize")&&!l||we("terminalFontSize"))?s.jsx("p",{className:Dt,children:i("settings.openchamber.visual.field.webFontsEnterprise")}):null,we("fontSize")&&!l||we("terminalFontSize")||we("editorFontSize")?s.jsxs(Nn,{children:[we("fontSize")&&!l&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.interfaceFontSize"),controlClassName:"w-full",children:s.jsxs("div",{className:Xn,children:[s.jsx(ps,{value:Oe,onValueChange:pe,min:50,max:200,step:5,className:fs,"aria-label":i("settings.openchamber.visual.field.fontSizePercentageAria")}),s.jsx("span",{className:Fa,children:"%"}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>pe(100),disabled:Oe===100,className:os,"aria-label":i("settings.openchamber.visual.actions.resetFontSizeAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})})]})}),we("terminalFontSize")&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.terminalFontSize"),settingsItem:"appearance.terminal-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:Xn,children:[s.jsx(ps,{value:xe,onValueChange:Ne,min:9,max:52,step:1,className:fs}),s.jsx("span",{className:Fa,children:"px"}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>Ne(13),disabled:xe===13,className:os,"aria-label":i("settings.openchamber.visual.actions.resetTerminalFontSizeAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})})]})}),we("editorFontSize")&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.editorFontSize"),settingsItem:"appearance.editor-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:Xn,children:[s.jsx(ps,{value:Je,onValueChange:tt,min:9,max:32,step:1,className:fs}),s.jsx("span",{className:Fa,children:"px"}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>tt(13),disabled:Je===13,className:os,"aria-label":i("settings.openchamber.visual.actions.resetEditorFontSizeAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,we("spacing")||we("inputBarOffset")&&l?s.jsxs(Nn,{children:[we("spacing")&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.spacingDensity"),settingsItem:"appearance.spacing-density",controlClassName:"w-full",children:s.jsxs("div",{className:Xn,children:[s.jsx(ps,{value:_e,onValueChange:nt,min:50,max:200,step:5,className:fs}),s.jsx("span",{className:Fa,children:"%"}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>nt(100),disabled:_e===100,className:os,"aria-label":i("settings.openchamber.visual.actions.resetSpacingAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})})]})}),we("inputBarOffset")&&l&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.inputBarOffset"),info:i("settings.openchamber.visual.field.inputBarOffsetTooltip"),settingsItem:"appearance.input-bar-offset",controlClassName:"w-full",children:s.jsxs("div",{className:Xn,children:[s.jsx(ps,{value:te,onValueChange:ue,min:0,max:100,step:5,className:fs}),s.jsx("span",{className:Fa,children:"px"}),s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>ue(0),disabled:te===0,className:os,"aria-label":i("settings.openchamber.visual.actions.resetInputBarOffsetAria"),title:i("settings.common.actions.reset"),children:s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,!Pa&&cr]}),we("animatedActivityIndicators")&&s.jsx(He,{title:i("settings.openchamber.visual.section.sessionActivity"),settingsItem:"appearance.session-activity",contentClassName:bs,children:s.jsx(it,{checked:T,onChange:O,label:i("settings.openchamber.visual.field.animatedActivityIndicators"),ariaLabel:i("settings.openchamber.visual.field.animatedActivityIndicatorsAria"),info:i("settings.openchamber.visual.field.animatedActivityIndicatorsInfo"),settingsItem:"appearance.animated-activity-indicators"})}),$t&&s.jsxs(He,{title:i("settings.openchamber.visual.section.navigation"),contentClassName:"space-y-4",children:[we("fileEditorKeymap")&&s.jsx(hs,{title:i("settings.openchamber.visual.field.fileEditorKeymap"),settingsItem:"appearance.file-editor-keymap",children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.field.fileEditorKeymap"),children:["default","vim"].map(M=>s.jsx(ns,{selected:Et===M,onSelect:()=>Le(M),label:i(`settings.openchamber.visual.option.fileEditorKeymap.${M}`),ariaLabel:i(`settings.openchamber.visual.option.fileEditorKeymap.${M}`)},M))})}),we("fileTreeSide")&&!Zt&&!l&&s.jsx(hs,{title:i("settings.openchamber.visual.field.fileTreeSide"),settingsItem:"appearance.file-tree-side",children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.field.fileTreeSide"),children:["left","right"].map(M=>s.jsx(ns,{selected:le===M,onSelect:()=>Z(M),label:i(`settings.openchamber.visual.option.fileTreeSide.${M}`),ariaLabel:i(`settings.openchamber.visual.option.fileTreeSide.${M}`)},M))})}),we("fileEditorKeymap")&&Et==="vim"&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.fileEditorVimMappings"),info:i("settings.openchamber.visual.field.fileEditorVimMappingsInfo"),description:jt.length>0?i("settings.openchamber.visual.field.fileEditorVimMappingsInvalid",{lines:jt.join(", ")}):void 0,descriptionPlacement:"after",settingsItem:"appearance.file-editor-vim-mappings",children:s.jsx(ws,{value:Xe,onChange:M=>gt(M.target.value),placeholder:"inoremap jk <Esc>","aria-label":i("settings.openchamber.visual.field.fileEditorVimMappings"),rows:4,spellCheck:!1,className:"w-full font-mono typography-meta"})}),s.jsxs("div",{className:bs,children:[we("autoSaveEnabled")&&s.jsx(it,{checked:G,onChange:ee,label:i("settings.openchamber.visual.field.autoSaveEnabled"),ariaLabel:i("settings.openchamber.visual.field.autoSaveEnabledAria"),info:i("settings.openchamber.visual.field.autoSaveEnabledInfo"),settingsItem:"appearance.auto-save-enabled"}),we("confirmFileTreeMove")&&!Zt&&!l&&s.jsx(it,{checked:ae,onChange:X,label:i("settings.openchamber.visual.field.confirmFileTreeMove"),ariaLabel:i("settings.openchamber.visual.field.confirmFileTreeMove"),settingsItem:"appearance.confirm-file-tree-move"}),we("layoutAnimations")&&!Zt&&!l&&s.jsx(it,{checked:Q,onChange:fe,label:i("settings.openchamber.visual.field.layoutAnimations"),ariaLabel:i("settings.openchamber.visual.field.layoutAnimationsAria"),info:i("settings.openchamber.visual.field.layoutAnimationsInfo"),settingsItem:"appearance.layout-animations"}),we("openLinksInBrowserPanel")&&as()&&!l&&s.jsx(it,{checked:Y,onChange:be,label:i("settings.openchamber.visual.field.openLinksInBrowserPanel"),ariaLabel:i("settings.openchamber.visual.field.openLinksInBrowserPanel"),info:i("settings.openchamber.visual.field.openLinksInBrowserPanelInfo"),settingsItem:"appearance.open-links-in-browser-panel"}),we("openTrackerLinksOnBoard")&&!Zt&&s.jsx(it,{checked:Ee,onChange:se,label:i("settings.openchamber.visual.field.openTrackerLinksOnBoard"),ariaLabel:i("settings.openchamber.visual.field.openTrackerLinksOnBoard"),info:i("settings.openchamber.visual.field.openTrackerLinksOnBoardInfo"),settingsItem:"appearance.open-tracker-links-on-board"}),Xt&&s.jsx(Mt,{label:i("settings.openchamber.visual.field.terminalShell"),info:i("settings.openchamber.visual.field.terminalShellHint"),settingsItem:"appearance.terminal-shell",className:"pt-2",children:s.jsxs(Tt,{value:de,onValueChange:M=>{Hg(M)&&Ue(M)},children:[s.jsx(Pt,{"aria-label":i("settings.openchamber.visual.field.terminalShellAria"),className:Ra,children:s.jsx(Ut,{})}),s.jsxs(At,{children:[s.jsx(ot,{value:"auto",children:i("settings.openchamber.visual.option.terminalShell.auto")}),Aa.map(M=>s.jsx(ot,{value:M.id,children:M.name},M.id))]})]})}),Xt&&Ta&&s.jsx(it,{checked:qi,onChange:Cm,label:i("settings.openchamber.visual.field.terminalLoginShell"),ariaLabel:i("settings.openchamber.visual.field.terminalLoginShell"),settingsItem:"appearance.terminal-login-shell"}),we("terminalQuickKeys")&&!l&&s.jsx(it,{checked:pt,onChange:wt,label:i("settings.openchamber.visual.field.terminalQuickKeys"),ariaLabel:i("settings.openchamber.visual.field.terminalQuickKeysAria"),settingsItem:"appearance.terminal-quick-keys",info:i("settings.openchamber.visual.field.terminalQuickKeysTooltip",{control:Rn("ctrl"),alt:Rn("alt")})})]}),we("sessionTabs")&&!Zt&&!l&&s.jsx(hs,{title:i("settings.openchamber.visual.field.sessionTabsGroup"),settingsItem:"appearance.session-tabs",children:s.jsx(it,{checked:vt,onChange:bt,label:i("settings.openchamber.visual.field.sessionTabs"),ariaLabel:i("settings.openchamber.visual.field.sessionTabsAria"),info:i("settings.openchamber.visual.field.sessionTabsInfo")})})]}),xs&&s.jsxs(s.Fragment,{children:[_s&&s.jsx(He,{title:i("settings.openchamber.visual.section.chatDisplay"),divider:Vs,contentClassName:"space-y-6",children:we("activityRenderMode")&&s.jsx(hs,{title:i("settings.openchamber.visual.section.activityDefault"),settingsItem:"chat.activity-default",children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.section.activityDefaultAria"),children:iw.map(M=>s.jsx(ns,{selected:ge===M.id,onSelect:()=>Sa(M.id),label:r(M.labelKey),ariaLabel:i("settings.openchamber.visual.field.activityDefaultModeAria",{option:r(M.labelKey)})},M.id))})})}),ds&&s.jsxs(He,{title:i("settings.openchamber.visual.section.messageStreamTransport"),divider:_s||Vs,settingsItem:"chat.message-transport",contentClassName:"space-y-2",children:[s.jsx(Gs,{value:oi,options:yd.map(M=>({value:M.id,label:r(M.labelKey)})),onChange:_i,"aria-label":i("settings.openchamber.visual.section.messageStreamTransport")}),(()=>{const M=yd.find(Nt=>Nt.id===oi);return M?.descriptionKey?s.jsx("span",{className:"typography-meta text-muted-foreground",children:r(M.descriptionKey)}):null})()]}),Ps&&s.jsx(He,{title:i("settings.openchamber.visual.section.chatMessageOptions"),divider:_s||ds||Vs,children:s.jsxs(Nn,{className:"lg:gap-y-6",children:[we("userMessageRendering")&&s.jsx(hs,{title:i("settings.openchamber.visual.section.userMessageRendering"),children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.section.userMessageRenderingAria"),children:aw.map(M=>s.jsx(ns,{selected:cw(_)===M.id,onSelect:()=>ci(M.id),label:r(M.labelKey),ariaLabel:i("settings.openchamber.visual.field.userMessageRenderingAria",{option:r(M.labelKey)})},M.id))})}),we("mermaidRendering")&&s.jsx(hs,{title:i("settings.openchamber.visual.section.mermaidRendering"),children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.section.mermaidRenderingAria"),children:nw.map(M=>s.jsx(ns,{selected:E===M.id,onSelect:()=>Hi(M.id),label:r(M.labelKey),ariaLabel:i("settings.openchamber.visual.field.mermaidRenderingAria",{option:r(M.labelKey)})},M.id))})}),we("diffLayout")&&!Zt&&s.jsx(hs,{title:i("settings.openchamber.visual.section.diffLayout"),children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.section.diffLayoutAria"),children:sw.map(M=>s.jsx(ns,{selected:qe===M.id,onSelect:()=>Ze(M.id),label:r(M.labelKey),ariaLabel:i("settings.openchamber.visual.field.diffLayoutAria",{option:r(M.labelKey)})},M.id))})}),we("followUpBehavior")&&s.jsx(hs,{title:i("settings.openchamber.visual.section.followUpBehavior"),settingsItem:"chat.follow-up-behavior",children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.section.followUpBehaviorAria"),children:ow.map(M=>s.jsx(ns,{selected:L===M.id,onSelect:()=>me(M.id),label:r(M.labelKey),ariaLabel:i("settings.openchamber.visual.field.followUpBehaviorAria",{option:r(M.labelKey)})},M.id))})}),we("inputHistoryScope")&&s.jsx(hs,{title:i("settings.openchamber.visual.field.inputHistoryScope"),info:i("settings.openchamber.visual.field.inputHistoryScopeDescription"),settingsItem:"chat.input-history-scope",children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.section.inputHistoryScopeAria"),children:lw.map(M=>s.jsx(ns,{selected:Se===M.id,onSelect:()=>Vi(M.id),label:r(M.labelKey),ariaLabel:r(M.labelKey)},M.id))})}),we("inputHistoryLimit")&&s.jsx(hs,{title:i("settings.openchamber.visual.field.inputHistoryLimit"),description:i("settings.openchamber.visual.field.inputHistoryLimitDescription"),contentClassName:ys,settingsItem:"chat.input-history-limit",children:s.jsxs("div",{className:Xn,children:[s.jsx(ps,{value:Ce,onValueChange:wa,min:Wg,max:qg,step:1,className:fs,deferExternalValueWhileFocused:!0,"aria-label":i("settings.openchamber.visual.field.inputHistoryLimitAria")}),s.jsx("span",{className:Fa,children:i("settings.openchamber.visual.field.inputHistoryLimitUnit")})]})})]})}),we("messageSearch")&&!Zt&&s.jsx(_k,{}),kn&&s.jsxs(s.Fragment,{children:[s.jsxs(He,{title:i("settings.openchamber.visual.section.sessionAssistance"),settingsItem:"chat.session-assistance",divider:_s||ds||Ps||Vs,contentClassName:bs,children:[s.jsx(it,{checked:ai,onChange:ms,label:i("settings.openchamber.visual.field.draftStartersVisible"),ariaLabel:i("settings.openchamber.visual.field.draftStartersVisibleAria"),settingsItem:"chat.draft-starters-visible"}),we("sessionAssist")&&s.jsxs(s.Fragment,{children:[s.jsx(it,{checked:g,onChange:h,label:i("settings.openchamber.visual.field.sessionRecap"),ariaLabel:i("settings.openchamber.visual.field.sessionRecapAria"),settingsItem:"chat.session-recap"}),s.jsx(it,{checked:p,onChange:w,label:i("settings.openchamber.visual.field.sessionSuggestion"),ariaLabel:i("settings.openchamber.visual.field.sessionSuggestionAria"),settingsItem:"chat.session-suggestion"})]}),we("sessionAssist")&&!Zt&&s.jsxs("div",{children:[s.jsx(it,{checked:v&&b,onChange:k,disabled:!v,label:i("settings.openchamber.visual.field.sessionReviewOffer"),ariaLabel:i("settings.openchamber.visual.field.sessionReviewOffer"),info:i("settings.openchamber.visual.field.sessionReviewOfferInfo"),settingsItem:"chat.session-review-offer"}),s.jsx(zo,{})]}),we("subagentReadOnlyBanner")&&s.jsx(it,{checked:ha,onChange:Ki,label:i("settings.openchamber.visual.field.allowPromptingSubagentSessions"),ariaLabel:i("settings.openchamber.visual.field.allowPromptingSubagentSessionsAria"),settingsItem:"chat.subagent-read-only-banner"})]}),we("sessionGoal")&&!Zt&&s.jsxs(He,{title:i("settings.openchamber.visual.goal.sectionTitle"),info:i("settings.openchamber.visual.goal.description"),contentClassName:bs,children:[s.jsx(it,{checked:S,onChange:y,label:i("settings.openchamber.visual.field.sessionGoal"),ariaLabel:i("settings.openchamber.visual.field.sessionGoalAria"),settingsItem:"chat.session-goal"}),s.jsx(Jk,{disabled:!S}),s.jsx(Qk,{disabled:!S}),s.jsxs("div",{"data-settings-item":"chat.session-goal-budget",className:"flex items-center gap-2",children:[s.jsx(it,{checked:N,onChange:x,disabled:!S,label:i("settings.openchamber.visual.goal.budgetLabel"),ariaLabel:i("settings.openchamber.visual.goal.budgetAria")}),S&&N?s.jsx(ps,{value:I,onValueChange:M=>{typeof M=="number"&&Number.isFinite(M)&&M>0&&j(Math.floor(M))},min:1e3,max:1e8,step:5e4}):null]})]}),we("reasoning")&&s.jsxs(He,{title:i("settings.openchamber.visual.section.reasoning"),settingsItem:"chat.reasoning",contentClassName:bs,children:[s.jsx(it,{checked:f,onChange:D,label:i("settings.openchamber.visual.field.showReasoningTraces"),ariaLabel:i("settings.openchamber.visual.field.showReasoningTracesAria"),settingsItem:"chat.reasoning-traces"}),f&&s.jsx(it,{checked:A,onChange:R,label:i("settings.openchamber.visual.field.collapsibleThinkingBlocks"),ariaLabel:i("settings.openchamber.visual.field.collapsibleThinkingBlocksAria")}),f&&A&&s.jsx(it,{checked:K,onChange:F,label:i("settings.openchamber.visual.field.expandReasoningWhileStreaming"),ariaLabel:i("settings.openchamber.visual.field.expandReasoningWhileStreamingAria"),info:i("settings.openchamber.visual.field.expandReasoningWhileStreamingInfo")})]}),s.jsx(He,{title:i("settings.openchamber.visual.section.streaming"),settingsItem:"chat.streaming",contentClassName:bs,children:s.jsx(it,{checked:C,onChange:P,label:i("settings.openchamber.visual.field.streamingAutoFollow"),ariaLabel:i("settings.openchamber.visual.field.streamingAutoFollowAria"),info:i("settings.openchamber.visual.field.streamingAutoFollowInfo"),settingsItem:"chat.streaming-auto-follow"})}),(we("collapsibleUserMessages")||we("promptNavigatorEnabled")||we("wideChatLayout")||we("splitAssistantMessageActions")||we("codeBlockLineWrap")||we("tableCellWrap")||we("copyMessagesAsPlainText"))&&s.jsxs(He,{title:i("settings.openchamber.visual.section.messageAppearance"),settingsItem:"chat.message-appearance",contentClassName:bs,children:[we("collapsibleUserMessages")&&s.jsx(it,{checked:ne,onChange:Xo,label:i("settings.openchamber.visual.field.collapsibleUserMessages"),ariaLabel:i("settings.openchamber.visual.field.collapsibleUserMessagesAria"),settingsItem:"chat.collapsible-user-messages"}),we("promptNavigatorEnabled")&&s.jsx(it,{checked:$,onChange:Zo,label:i("settings.openchamber.visual.field.promptNavigatorEnabled"),ariaLabel:i("settings.openchamber.visual.field.promptNavigatorEnabledAria"),settingsItem:"chat.prompt-navigator"}),we("wideChatLayout")&&s.jsx(it,{checked:re,onChange:ja,label:i("settings.openchamber.visual.field.wideChatLayout"),ariaLabel:i("settings.openchamber.visual.field.wideChatLayoutAria"),settingsItem:"chat.wide-layout"}),we("splitAssistantMessageActions")&&s.jsx(it,{checked:si,onChange:ka,label:i("settings.openchamber.visual.field.showSplitAssistantMessageActions"),ariaLabel:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsAria"),settingsItem:"chat.inline-assistant-actions",info:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip")}),we("codeBlockLineWrap")&&s.jsx(it,{checked:ie,onChange:Pe,label:i("settings.openchamber.visual.field.codeBlockLineWrap"),ariaLabel:i("settings.openchamber.visual.field.codeBlockLineWrapAria"),settingsItem:"chat.code-block-line-wrap"}),we("tableCellWrap")&&s.jsx(it,{checked:ke,onChange:Ae,label:i("settings.openchamber.visual.field.tableCellWrap"),ariaLabel:i("settings.openchamber.visual.field.tableCellWrapAria"),info:i("settings.openchamber.visual.field.tableCellWrapInfo"),settingsItem:"chat.table-cell-wrap"}),we("copyMessagesAsPlainText")&&s.jsx(it,{checked:Te,onChange:Ke,label:i("settings.openchamber.visual.field.copyMessagesAsPlainText"),ariaLabel:i("settings.openchamber.visual.field.copyMessagesAsPlainTextAria"),info:i("settings.openchamber.visual.field.copyMessagesAsPlainTextInfo"),settingsItem:"chat.copy-plain-text"})]}),(we("showToolFileIcons")||we("showTurnChangedFiles")||we("dotfiles")&&!cs()||we("fileViewerPreview"))&&s.jsxs(He,{title:i("settings.openchamber.visual.section.toolsAndFiles"),settingsItem:"chat.tools-and-files",contentClassName:bs,children:[we("showToolFileIcons")&&s.jsx(it,{checked:Ss,onChange:tr,label:i("settings.openchamber.visual.field.showToolFileIcons"),ariaLabel:i("settings.openchamber.visual.field.showToolFileIconsAria"),settingsItem:"chat.tool-file-icons"}),we("showTurnChangedFiles")&&s.jsx(it,{checked:Xa,onChange:Na,label:i("settings.openchamber.visual.field.showTurnChangedFiles"),ariaLabel:i("settings.openchamber.visual.field.showTurnChangedFilesAria"),settingsItem:"chat.changed-files"}),we("dotfiles")&&!cs()&&s.jsx(it,{checked:d,onChange:Gg,label:i("settings.openchamber.visual.field.showDotfiles"),ariaLabel:i("settings.openchamber.visual.field.showDotfilesAria"),settingsItem:"chat.dotfiles"}),we("fileViewerPreview")&&s.jsx(it,{checked:$s,onChange:sr,label:i("settings.openchamber.defaults.field.openFilesPreview"),ariaLabel:i("settings.openchamber.defaults.field.openFilesPreviewAria")})]}),(we("persistDraft")||we("largeTextPaste")||!l&&we("inputSpellcheck")||we("enterToSend"))&&s.jsxs(He,{title:i("settings.openchamber.visual.section.composer"),settingsItem:"chat.composer",contentClassName:"space-y-6",children:[(we("persistDraft")||!l&&we("inputSpellcheck"))&&s.jsxs("div",{className:bs,children:[we("persistDraft")&&s.jsx(it,{checked:Fe,onChange:ct,label:i("settings.openchamber.visual.field.persistDraftMessages"),ariaLabel:i("settings.openchamber.visual.field.persistDraftMessagesAria"),settingsItem:"chat.persist-drafts"}),!l&&we("inputSpellcheck")&&s.jsx(it,{checked:Ft,onChange:er,label:i("settings.openchamber.visual.field.enableSpellcheckInTextInputs"),ariaLabel:i("settings.openchamber.visual.field.enableSpellcheckInTextInputsAria"),settingsItem:"chat.spellcheck"})]}),we("largeTextPaste")&&s.jsx(hs,{title:i("settings.openchamber.visual.field.largeTextPaste"),info:i("settings.openchamber.visual.field.largeTextPasteHint"),settingsItem:"chat.large-text-paste",children:s.jsx(Os,{"aria-label":i("settings.openchamber.visual.field.largeTextPasteAria"),children:rw.map(M=>s.jsx(ns,{selected:ls===M.id,onSelect:()=>et(M.id),label:r(M.labelKey),ariaLabel:i("settings.openchamber.visual.field.largeTextPasteOptionAria",{option:r(M.labelKey)})},M.id))})}),we("enterToSend")&&s.jsx(hs,{title:i("settings.openchamber.visual.field.enterToSend"),info:i("settings.openchamber.visual.field.enterToSendHint"),settingsItem:"chat.enter-to-send",children:s.jsxs(Os,{"aria-label":i("settings.openchamber.visual.field.enterToSend"),children:[s.jsx(ns,{selected:Jt,onSelect:()=>di(!0),label:i("settings.openchamber.visual.option.enterToSend.enter.label"),ariaLabel:i("settings.openchamber.visual.option.enterToSend.enter.label")}),s.jsx(ns,{selected:!Jt,onSelect:()=>di(!1),label:i("settings.openchamber.visual.option.enterToSend.modifier.label"),ariaLabel:i("settings.openchamber.visual.option.enterToSend.modifier.label")})]})})]})]})]}),we("reportUsage")&&s.jsx(He,{title:i("settings.openchamber.visual.section.privacy"),children:s.jsx(it,{checked:Ul,onChange:Yo,label:i("settings.openchamber.visual.field.sendAnonymousUsageReports"),info:i("settings.openchamber.visual.field.sendAnonymousUsageReportsHint"),ariaLabel:i("settings.openchamber.visual.field.sendAnonymousUsageReportsAria"),settingsItem:"appearance.usage-reports"})})]})},mw=1,pw=365,wd=30,gw=[{value:"archive",labelKey:"settings.openchamber.sessionRetention.action.archive"},{value:"delete",labelKey:"settings.openchamber.sessionRetention.action.delete"}],cm=()=>{const t=$e.c(105),{t:e}=ze(),a=oe(fw),n=oe(hw),o=oe(bw),i=oe(xw),r=oe(vw),l=oe(yw),u=oe(jw);let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m={autoRun:!1},t[0]=m):m=t[0];const{candidates:d,isRunning:f,runCleanup:g,action:p,status:h}=Xp(m),w=d.length;let b;t[1]!==g||t[2]!==e?(b=async()=>{const re=await g({force:!0}).catch(()=>(W.error(e("sessions.sidebar.group.empty.loadFailed")),null));if(!(!re||re.skippedReason&&re.skippedReason!=="no-candidates")){if(re.completedIds.length===0&&re.failedIds.length===0){W.message(re.action==="archive"?e("settings.openchamber.sessionRetention.toast.noneEligibleArchive"):e("settings.openchamber.sessionRetention.toast.noneEligibleDelete"));return}re.completedIds.length>0&&W.success(re.action==="archive"?e("settings.openchamber.sessionRetention.toast.archivedCount",{count:re.completedIds.length}):e("settings.openchamber.sessionRetention.toast.deletedCount",{count:re.completedIds.length})),re.failedIds.length>0&&W.error(re.action==="archive"?e("settings.openchamber.sessionRetention.toast.failedArchiveCount",{count:re.failedIds.length}):e("settings.openchamber.sessionRetention.toast.failedDeleteCount",{count:re.failedIds.length}))}},t[1]=g,t[2]=e,t[3]=b):b=t[3];const k=b;let v;t[4]!==e?(v=e("settings.openchamber.sessionRetention.title"),t[4]=e,t[5]=v):v=t[5];const S=o?"settings.openchamber.sessionRetention.archivedTooltip":"settings.openchamber.sessionRetention.tooltip";let y;t[6]!==e||t[7]!==S?(y=e(S),t[6]=e,t[7]=S,t[8]=y):y=t[8];let N;t[9]!==e?(N=e("settings.openchamber.sessionRetention.field.enableAutoCleanup"),t[9]=e,t[10]=N):N=t[10];let x;t[11]!==e?(x=e("settings.openchamber.sessionRetention.field.enableAutoCleanupAria"),t[11]=e,t[12]=x):x=t[12];let I;t[13]!==a||t[14]!==i||t[15]!==N||t[16]!==x?(I=s.jsx(it,{settingsItem:"sessions.auto-cleanup",checked:a,onChange:i,label:N,ariaLabel:x}),t[13]=a,t[14]=i,t[15]=N,t[16]=x,t[17]=I):I=t[17];let j;t[18]!==e?(j=e("settings.openchamber.sessionRetention.field.onlyArchived"),t[18]=e,t[19]=j):j=t[19];let D;t[20]!==e?(D=e("settings.openchamber.sessionRetention.field.onlyArchived"),t[20]=e,t[21]=D):D=t[21];let C;t[22]!==e?(C=e("settings.openchamber.sessionRetention.field.onlyArchivedDescription"),t[22]=e,t[23]=C):C=t[23];let P;t[24]!==f||t[25]!==o||t[26]!==u||t[27]!==C||t[28]!==j||t[29]!==D?(P=s.jsx(it,{settingsItem:"sessions.retention-only-archived",checked:o,onChange:u,disabled:f,label:j,ariaLabel:D,info:C}),t[24]=f,t[25]=o,t[26]=u,t[27]=C,t[28]=j,t[29]=D,t[30]=P):P=t[30];let A;t[31]!==e?(A=e("settings.openchamber.sessionRetention.field.retentionPeriod"),t[31]=e,t[32]=A):A=t[32];let R;t[33]!==e?(R=e("settings.openchamber.sessionRetention.field.retentionPeriodAria"),t[33]=e,t[34]=R):R=t[34];let K;t[35]===Symbol.for("react.memo_cache_sentinel")?(K=Me(fs,"tabular-nums"),t[35]=K):K=t[35];let F;t[36]!==n||t[37]!==r||t[38]!==R?(F=s.jsx(ps,{value:n,onValueChange:r,min:mw,max:pw,step:1,"aria-label":R,className:K}),t[36]=n,t[37]=r,t[38]=R,t[39]=F):F=t[39];let T;t[40]!==e?(T=e("settings.openchamber.sessionRetention.field.days"),t[40]=e,t[41]=T):T=t[41];let O;t[42]!==T?(O=s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:T}),t[42]=T,t[43]=O):O=t[43];let E;t[44]!==r?(E=()=>r(wd),t[44]=r,t[45]=E):E=t[45];const B=n===wd;let _;t[46]!==e?(_=e("settings.openchamber.sessionRetention.actions.resetRetentionAria"),t[46]=e,t[47]=_):_=t[47];let H;t[48]!==e?(H=e("settings.common.actions.reset"),t[48]=e,t[49]=H):H=t[49];let ne;t[50]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(J,{name:"restart",className:"h-3.5 w-3.5"}),t[50]=ne):ne=t[50];let z;t[51]!==E||t[52]!==B||t[53]!==_||t[54]!==H?(z=s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:E,disabled:B,className:os,"aria-label":_,title:H,children:ne}),t[51]=E,t[52]=B,t[53]=_,t[54]=H,t[55]=z):z=t[55];let $;t[56]!==A||t[57]!==F||t[58]!==O||t[59]!==z?($=s.jsxs(kt,{settingsItem:"sessions.retention-period",label:A,children:[F,O,z]}),t[56]=A,t[57]=F,t[58]=O,t[59]=z,t[60]=$):$=t[60];let V;t[61]!==e?(V=e("settings.openchamber.sessionRetention.field.whenSessionsExpire"),t[61]=e,t[62]=V):V=t[62];let G;t[63]!==o||t[64]!==e?(G=gw.map(re=>({value:re.value,label:e(re.labelKey),disabled:o&&re.value==="archive"})),t[63]=o,t[64]=e,t[65]=G):G=t[65];let ee;t[66]!==p||t[67]!==l||t[68]!==G?(ee=s.jsx(Gs,{value:p,onChange:l,options:G}),t[66]=p,t[67]=l,t[68]=G,t[69]=ee):ee=t[69];let ae;t[70]!==V||t[71]!==ee?(ae=s.jsx(kt,{settingsItem:"sessions.retention-action",label:V,children:ee}),t[70]=V,t[71]=ee,t[72]=ae):ae=t[72];let X;t[73]!==P||t[74]!==$||t[75]!==ae?(X=s.jsxs(da,{className:"space-y-0",children:[P,$,ae]}),t[73]=P,t[74]=$,t[75]=ae,t[76]=X):X=t[76];let Q;t[77]!==e?(Q=e("settings.openchamber.sessionRetention.manualCleanup.title"),t[77]=e,t[78]=Q):Q=t[78];let le;t[79]!==f||t[80]!==e?(le=e(f?"settings.openchamber.sessionRetention.actions.cleaningUp":"settings.openchamber.sessionRetention.actions.runCleanupNow"),t[79]=f,t[80]=e,t[81]=le):le=t[81];let Z;t[82]!==k||t[83]!==f||t[84]!==le?(Z=s.jsx(q,{type:"button",variant:"outline",size:"xs",onClick:k,disabled:f,className:"!font-normal",children:le}),t[82]=k,t[83]=f,t[84]=le,t[85]=Z):Z=t[85];let fe;t[86]!==Q||t[87]!==Z?(fe=s.jsx(kt,{label:Q,children:Z}),t[86]=Q,t[87]=Z,t[88]=fe):fe=t[88];let Y;t[89]!==p||t[90]!==w||t[91]!==h||t[92]!==e?(Y=h==="error"?e("sessions.sidebar.group.empty.loadFailed"):h!=="ready"?e("sessions.sidebar.group.empty.loadingSessions"):p==="archive"?e("settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow",{count:w}):e("settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow",{count:w}),t[89]=p,t[90]=w,t[91]=h,t[92]=e,t[93]=Y):Y=t[93];let be;t[94]!==Y?(be=s.jsx("p",{className:"typography-meta text-muted-foreground",children:Y}),t[94]=Y,t[95]=be):be=t[95];let Ee;t[96]!==fe||t[97]!==be?(Ee=s.jsxs("div",{className:"mt-1 py-1.5 space-y-1",children:[fe,be]}),t[96]=fe,t[97]=be,t[98]=Ee):Ee=t[98];let se;return t[99]!==v||t[100]!==X||t[101]!==Ee||t[102]!==y||t[103]!==I?(se=s.jsxs(He,{title:v,info:y,children:[I,X,Ee]}),t[99]=v,t[100]=X,t[101]=Ee,t[102]=y,t[103]=I,t[104]=se):se=t[104],se};function fw(t){return t.autoDeleteEnabled}function hw(t){return t.autoDeleteAfterDays}function bw(t){return t.sessionRetentionOnlyArchived}function xw(t){return t.setAutoDeleteEnabled}function vw(t){return t.setAutoDeleteAfterDays}function yw(t){return t.setSessionRetentionAction}function jw(t){return t.setSessionRetentionOnlyArchived}const dm=()=>{const t=$e.c(17),{t:e}=ze(),a=oe(kw),n=oe(ww);let o;t[0]!==e?(o=e("settings.openchamber.mergedWorktreeCleanup.title"),t[0]=e,t[1]=o):o=t[1];let i;t[2]!==e?(i=e("settings.openchamber.mergedWorktreeCleanup.info"),t[2]=e,t[3]=i):i=t[3];let r;t[4]!==e?(r=e("settings.openchamber.mergedWorktreeCleanup.field.enable"),t[4]=e,t[5]=r):r=t[5];let l;t[6]!==e?(l=e("settings.openchamber.mergedWorktreeCleanup.field.enableDescription"),t[6]=e,t[7]=l):l=t[7];let u;t[8]!==a||t[9]!==n||t[10]!==r||t[11]!==l?(u=s.jsx(it,{settingsItem:"sessions.merged-worktree-cleanup",checked:a,onChange:n,label:r,description:l}),t[8]=a,t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12];let m;return t[13]!==o||t[14]!==i||t[15]!==u?(m=s.jsx(He,{settingsItem:"sessions.merged-worktree-cleanup-section",title:o,info:i,children:u}),t[13]=o,t[14]=i,t[15]=u,t[16]=m):m=t[16],m};function kw(t){return t.mergedWorktreeCleanupEnabled}function ww(t){return t.setMergedWorktreeCleanupEnabled}const um=()=>{const t=$e.c(17),{t:e}=ze(),a=oe(Sw),n=oe(Nw);let o;t[0]!==e?(o=e("settings.openchamber.sessionWork.title"),t[0]=e,t[1]=o):o=t[1];let i;t[2]!==e?(i=e("settings.openchamber.sessionWork.info"),t[2]=e,t[3]=i):i=t[3];let r;t[4]!==e?(r=e("settings.openchamber.sessionWork.field.enabled"),t[4]=e,t[5]=r):r=t[5];let l;t[6]!==e?(l=e("settings.openchamber.sessionWork.field.enabled"),t[6]=e,t[7]=l):l=t[7];let u;t[8]!==a||t[9]!==n||t[10]!==r||t[11]!==l?(u=s.jsx(it,{settingsItem:"sessions.work-enabled",checked:a,onChange:n,label:r,ariaLabel:l}),t[8]=a,t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12];let m;return t[13]!==o||t[14]!==i||t[15]!==u?(m=s.jsx(He,{title:o,info:i,settingsItem:"sessions.work",children:u}),t[13]=o,t[14]=i,t[15]=u,t[16]=m):m=t[16],m};function Sw(t){return t.sessionWorkEnabled}function Nw(t){return t.setSessionWorkEnabled}const Sd=(t,e,a)=>!t||!Number.isFinite(t)?e:new Intl.DateTimeFormat(xl(),{dateStyle:"medium",timeStyle:"short",hour12:a==="auto"?void 0:a==="12h"}).format(t),mm=()=>{const{t}=ze(),e=oe(I=>I.timeFormatPreference),[a,n]=c.useState(!1),[o,i]=c.useState(!0),[r,l]=c.useState(!1),[u,m]=c.useState(null),[d,f]=c.useState(!1),[g,p]=c.useState([]),[h,w]=c.useState(eg),[b,k]=c.useState(""),v=c.useMemo(()=>tg(),[]),S=c.useCallback(async()=>{i(!0),k("");try{const I=await sg();p(I)}catch(I){const j=I instanceof Error?I.message:t("settings.openchamber.passkeys.toast.loadFailed");k(j)}finally{i(!1)}},[t]);c.useEffect(()=>{let I=!1;return(async()=>{try{if(!v.supported){I||(n(!1),i(!1));return}I||n(!0)}catch{I||n(!1)}if(!I){const j=await gr();if(w(j),!j.enabled){p([]),i(!1);return}await S()}})(),()=>{I=!0,Ql()}},[S,v.supported]);const y=c.useCallback(async()=>{if(!h.enabled){const I=t("settings.openchamber.passkeys.toast.enableUiPasswordFirst");k(I),W.message(I);return}if(!a){k(v.reason),W.message(v.reason);return}if(r){Ql(),l(!1);return}k(""),l(!0);try{await ng(),w(await gr()),await S(),W.success(t("settings.openchamber.passkeys.toast.added"))}catch(I){if(ag(I)){W.message(t("settings.openchamber.passkeys.toast.setupCanceled"));return}const j=I instanceof Error?I.message:t("settings.openchamber.passkeys.toast.addFailed");k(j),W.error(j)}finally{l(!1)}},[r,S,h.enabled,v.reason,a,t]),N=c.useCallback(async I=>{m(I),k("");try{await ig(I),w(await gr()),await S(),W.success(t("settings.openchamber.passkeys.toast.removed"))}catch(j){const D=j instanceof Error?j.message:t("settings.openchamber.passkeys.toast.removeFailed");k(D),W.error(D)}finally{m(null)}},[S,t]),x=c.useCallback(async()=>{f(!0),k("");try{await og(),window.location.reload()}catch(I){const j=I instanceof Error?I.message:t("settings.openchamber.passkeys.toast.clearAuthFailed");k(j),W.error(j),f(!1)}},[t]);return s.jsxs(He,{title:t("settings.openchamber.passkeys.title"),children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(kt,{label:t("settings.openchamber.passkeys.field.currentDevice"),children:[s.jsx(q,{type:"button",variant:r?"secondary":"outline",size:"xs",onClick:()=>{y()},disabled:o||d,className:"!font-normal",children:t(r?"settings.openchamber.passkeys.actions.cancelSetup":"settings.openchamber.passkeys.actions.add")}),s.jsx(q,{type:"button",variant:"ghost",size:"xs",onClick:()=>{x()},disabled:o||r||d,className:"!font-normal text-muted-foreground hover:text-foreground",children:t(d?"settings.openchamber.passkeys.actions.signingOut":"settings.openchamber.passkeys.actions.signOutEverywhere")})]}),!h.enabled&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.uiPasswordRequired")}),h.enabled&&!a&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:v.reason}),o?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.loading")}):g.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.noneSaved")}):s.jsx("div",{className:"space-y-1 pt-1",children:g.map(I=>s.jsxs(kt,{label:s.jsx("span",{title:I.label,children:I.label}),alignEnd:!1,controlClassName:"justify-between sm:flex-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:I.lastUsedAt?t("settings.openchamber.passkeys.item.lastUsed",{time:Sd(I.lastUsedAt,t("settings.openchamber.passkeys.time.neverUsed"),e)}):t("settings.openchamber.passkeys.item.added",{time:Sd(I.createdAt,t("settings.openchamber.passkeys.time.neverUsed"),e)})}),s.jsx(q,{type:"button",variant:"ghost",size:"xs",onClick:()=>{N(I.id)},disabled:u===I.id,className:"!font-normal text-muted-foreground hover:text-foreground",children:u===I.id?t("settings.openchamber.passkeys.actions.removing"):t("settings.common.actions.delete")})]},I.id))})]}),b&&s.jsx("div",{className:"mt-1 py-1.5",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:b})})]})},pm=()=>{const t=$e.c(14),{t:e}=ze(),a=Yl(Cw),n=Yl(Iw);let o;t[0]!==e?(o=e("settings.openchamber.appLinks.title"),t[0]=e,t[1]=o):o=t[1];let i;t[2]!==e?(i=e("settings.openchamber.appLinks.info"),t[2]=e,t[3]=i):i=t[3];let r;t[4]!==n||t[5]!==e||t[6]!==a?(r=a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.appLinks.empty")}):a.map(m=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-[13px]",children:`${m}://`}),s.jsx(q,{type:"button",variant:"ghost",size:"xs",onClick:()=>n(m),className:"!font-normal text-muted-foreground hover:text-foreground","aria-label":e("settings.openchamber.appLinks.removeAria",{scheme:`${m}://`}),children:e("settings.common.actions.delete")})]},m)),t[4]=n,t[5]=e,t[6]=a,t[7]=r):r=t[7];let l;t[8]!==r?(l=s.jsx("div",{className:"space-y-1","data-settings-item":"general.app-links",children:r}),t[8]=r,t[9]=l):l=t[9];let u;return t[10]!==o||t[11]!==i||t[12]!==l?(u=s.jsx(He,{title:o,description:i,children:l}),t[10]=o,t[11]=i,t[12]=l,t[13]=u):u=t[13],u};function Cw(t){return t.trustedSchemes}function Iw(t){return t.removeTrustedScheme}const Pw=()=>{const{t}=ze(),[e,a]=c.useState(null),n=c.useRef(0);c.useEffect(()=>{let i=!1;return Ks.getConfig(null).then(r=>{!i&&n.current===0&&a(!!r.warming)},r=>console.warn("[session-warming] failed to read config",r)),()=>{i=!0}},[]);const o=c.useCallback(async i=>{const r=e,l=++n.current;a(i),es("saving");try{const u=await Rt("/api/config/warming",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({enabled:i})});if(!u.ok)throw new Error(`HTTP ${u.status}`);es("saved"),Ks.clearConfigCache()}catch(u){console.warn("[session-warming] failed to save",u),es("error"),l===n.current&&a(r)}},[e]);return s.jsx(it,{settingsItem:"sessions.warming",checked:e??!1,disabled:e===null,onChange:i=>{o(i)},label:t("settings.openchamber.defaults.field.sessionWarming"),info:t("settings.openchamber.defaults.field.sessionWarmingInfo")})},Aw={ask:{icon:"shield-user",color:void 0},safety:{icon:"shield-star",color:"var(--status-success)"},auto:{icon:"shield-check",color:"var(--status-info)"}},Tw=t=>{const e=$e.c(42),{agentName:a}=t,{t:n}=ze(),o=oe(Ew),i=oe(Mw),r=Wt(jl),l=Ko(Wt(Dw));let u;e[0]!==o||e[1]!==r?(u=rg(o,r),e[0]=o,e[1]=r,e[2]=u):u=e[2];const m=u;let d;e[3]!==i?(d=P=>{i(P),yt({permissionDefaultMode:P})},e[3]=i,e[4]=d):d=e[4];const f=d;let g;e[5]!==a?(g=()=>{const P=a??rt.getState().currentAgentName;P&&hn.getState().setSelectedAgent(P),oe.getState().requestSettingsJump("agents","agents.permissions")},e[5]=a,e[6]=g):g=e[6];const p=g;let h;e[7]!==p||e[8]!==l||e[9]!==r||e[10]!==n?(h=P=>P==="safety"&&!r?s.jsxs(s.Fragment,{children:[n("settings.sessions.permissions.explain.safetyUnavailable")," ",s.jsx(Mn,{onClick:Ao,children:n("settings.jevAccess.setUp")})]}):P==="safety"?s.jsxs(s.Fragment,{children:[l?n("settings.sessions.permissions.explain.safetyVia",{provider:l}):n("settings.sessions.permissions.explain.safety")," ",s.jsx(Mn,{onClick:Ao,children:n("settings.jevAccess.manage")})]}):s.jsxs(s.Fragment,{children:[n(P==="auto"?"settings.sessions.permissions.explain.auto":"settings.sessions.permissions.explain.ask")," ",s.jsx(Mn,{onClick:p,children:n("settings.sessions.permissions.agentPermissionsLink")})]}),e[7]=p,e[8]=l,e[9]=r,e[10]=n,e[11]=h):h=e[11];const w=h;let b;e[12]!==w||e[13]!==r?(b=(P,A)=>{const{icon:R,color:K}=Aw[P];return{value:P,label:s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(J,{name:R,className:"size-3.5",style:K?{color:K}:void 0}),A]}),tooltip:w(P),disabled:P==="safety"&&!r}},e[12]=w,e[13]=r,e[14]=b):b=e[14];const k=b;let v;e[15]!==n?(v=n("settings.sessions.permissions.defaultMode"),e[15]=n,e[16]=v):v=e[16];let S;e[17]!==n?(S=n("settings.sessions.permissions.defaultModeInfo"),e[17]=n,e[18]=S):S=e[18];let y;e[19]!==n?(y=n("settings.sessions.permissions.defaultMode"),e[19]=n,e[20]=y):y=e[20];let N;e[21]!==k||e[22]!==n?(N=[k("ask",n("settings.sessions.permissions.mode.ask")),k("safety",n("settings.sessions.permissions.mode.safety")),k("auto",n("settings.sessions.permissions.mode.auto"))],e[21]=k,e[22]=n,e[23]=N):N=e[23];let x;e[24]!==f||e[25]!==m||e[26]!==y||e[27]!==N?(x=s.jsx(Gs,{"aria-label":y,value:m,onChange:f,options:N}),e[24]=f,e[25]=m,e[26]=y,e[27]=N,e[28]=x):x=e[28];let I;e[29]!==x||e[30]!==v||e[31]!==S?(I=s.jsx(kt,{settingsItem:"sessions.permission-default",label:v,info:S,children:x}),e[29]=x,e[30]=v,e[31]=S,e[32]=I):I=e[32];let j;e[33]!==w||e[34]!==m?(j=s.jsx("p",{className:Dt,children:w(m)}),e[33]=w,e[34]=m,e[35]=j):j=e[35];let D;e[36]!==r?(D=r?null:s.jsx(zo,{}),e[36]=r,e[37]=D):D=e[37];let C;return e[38]!==I||e[39]!==j||e[40]!==D?(C=s.jsxs("div",{className:"space-y-1",children:[I,j,D]}),e[38]=I,e[39]=j,e[40]=D,e[41]=C):C=e[41],C};function Ew(t){return t.permissionDefaultMode}function Mw(t){return t.setPermissionDefaultMode}function Dw(t){return t.classifier?.effective??null}const Or=t=>{const e=Tn(t);return e||{providerId:"",modelId:""}},gm=()=>{const{t}=ze(),e=rt(se=>se.setProvider),a=rt(se=>se.setModel),n=rt(se=>se.setAgent),o=rt(se=>se.setCurrentVariant),i=rt(se=>se.setCurrentVariantOverride),r=rt(se=>se.setSettingsDefaultModel),l=rt(se=>se.setSettingsDefaultVariant),u=rt(se=>se.setSettingsDefaultAgent),m=rt(se=>se.selectionSource==="manual"),d=lg(se=>se.currentSessionId),f=Zl(se=>se.getSessionModelSelection),g=Zl(se=>se.getSessionAgentSelection),p=rt(se=>se.agentSelectionSource==="manual"),w=!!(rt(se=>{if(se.agentSelectionSource!=="manual")return!1;const re=se.agents.find(je=>je.name===se.currentAgentName);return!!(re?.model?.providerID&&re.model.id)})||m&&d&&f(d)),b=!!(p&&d&&g(d)),k=c.useMemo(()=>cs(),[]),v=yo(se=>se.showChatsSection),S=yo(se=>se.setShowChatsSection),y=oe(se=>se.showDeletionDialog),N=oe(se=>se.setShowDeletionDialog),x=rt(se=>se.providers),I=rt(se=>se.modelsMetadata),[j,D]=c.useState(),[C,P]=c.useState(),[A,R]=c.useState(),[K,F]=c.useState(!0),[T,O]=c.useState(),E=Lf()??[],[B,_]=c.useState(),[H,ne]=c.useState(!0),z=c.useMemo(()=>Or(j),[j]);c.useEffect(()=>{(async()=>{try{const re=await xn();if(re){const je=re.defaultModel?.trim()||void 0,ie=re.defaultVariant?.trim()||void 0,Pe=re.defaultAgent?.trim()||void 0;je!==void 0&&D(je),ie!==void 0&&P(ie),Pe!==void 0&&R(Pe),re.smallModelUseDefault!==void 0&&F(re.smallModelUseDefault);const ke=re.smallModelOverride?.trim();ke&&O(ke);const Ae=re.walkthroughModelOverride?.trim();Ae&&_(Ae)}}catch(re){console.warn("Failed to load defaults settings:",re)}finally{ne(!1)}})()},[]);const $=c.useCallback(async(se,re)=>{const je=se&&re?`${se}/${re}`:void 0;D(je),P(void 0),l(void 0),r(je),w||(o(void 0),se&&re&&(x.find(Pe=>Pe.id===se)||lu(se,re))&&(e(se),a(re)));try{await yt({defaultModel:je??"",defaultVariant:""})}catch(ie){console.warn("Failed to save default model:",ie)}},[w,x,o,a,e,r,l]),V="__default__",G=c.useCallback(se=>se===V?t("settings.openchamber.defaults.option.default"):se.charAt(0).toUpperCase()+se.slice(1),[t]),ee=c.useCallback(async se=>{const re=se===V?void 0:se||void 0;P(re),l(re),w||i(re??null,re);try{await yt({defaultVariant:re??""})}catch(je){console.warn("Failed to save default variant:",je)}},[w,i,l]),ae=c.useCallback(async se=>{const re=se||void 0;R(re),u(re),se&&!b&&n(se);try{await yt({defaultAgent:re??""})}catch(je){console.warn("Failed to save default agent:",je)}},[b,n,u]),X=c.useCallback(async se=>{F(se);try{await yt({smallModelUseDefault:se})}catch(re){console.warn("Failed to save small model preference:",re)}},[]),Q=c.useCallback(async(se,re)=>{const je=se&&re?`${se}/${re}`:void 0;O(je);try{await yt({smallModelOverride:je??""})}catch(ie){console.warn("Failed to save small model override:",ie)}},[]),le=c.useCallback(async(se,re)=>{const je=se&&re?`${se}/${re}`:void 0;_(je);try{await yt({walkthroughModelOverride:je??""})}catch(ie){console.warn("Failed to save walkthrough model override:",ie)}},[]),Z=c.useCallback((se,re)=>I.get(`${se}/${re}`)?.structured_output!==!1,[I]),fe=c.useMemo(()=>Or(T),[T]),Y=c.useMemo(()=>Or(B),[B]),be=c.useMemo(()=>{if(!z.providerId||!z.modelId)return[];const re=x.find(je=>je.id===z.providerId)?.models.find(je=>je.id===z.modelId);return cg(re?.variants)},[z.modelId,z.providerId,x]),Ee=be.length>0;return H?null:s.jsx(s.Fragment,{children:s.jsx(He,{title:t("settings.openchamber.defaults.title"),divider:!1,children:s.jsxs("div",{className:"space-y-0",children:[s.jsxs("div",{className:"mt-0 mb-4 typography-meta text-muted-foreground",children:[t("settings.openchamber.defaults.summaryPrefix")," ",z.providerId?s.jsxs("span",{className:"text-foreground",children:[z.providerId,"/",z.modelId,Ee?` (${C??t("settings.openchamber.defaults.option.defaultLowercase")})`:""]}):s.jsx("span",{className:"text-foreground",children:t("settings.openchamber.defaults.summaryOpenCodeDefault")}),A&&s.jsxs(s.Fragment,{children:[" / ",s.jsx("span",{className:"text-foreground",children:A})]})]}),s.jsxs("div",{className:js,children:[s.jsx(kt,{settingsItem:"sessions.default-model",label:t("settings.openchamber.defaults.field.defaultModel"),children:s.jsx(oa,{providerId:z.providerId,modelId:z.modelId,onChange:$,className:sn,offerAuto:!0})}),s.jsx(kt,{settingsItem:"sessions.default-thinking",label:t("settings.openchamber.defaults.field.defaultThinking"),children:s.jsxs(Tt,{value:C??V,onValueChange:ee,disabled:!Ee,children:[s.jsx(Pt,{className:nn,children:s.jsx(Ut,{placeholder:t("settings.openchamber.defaults.field.thinkingPlaceholder"),children:G(C??V)})}),s.jsxs(At,{children:[s.jsx(ot,{value:V,children:t("settings.openchamber.defaults.option.default")}),be.map(se=>s.jsx(ot,{value:se,children:G(se)},se))]})]})}),s.jsx(kt,{settingsItem:"sessions.default-agent",label:t("settings.openchamber.defaults.field.defaultAgent"),children:s.jsx(gl,{agentName:A||"",onChange:ae,filter:se=>ho(se.mode),className:sn})}),k?null:s.jsx(Tw,{agentName:A})]}),s.jsxs(da,{className:bs,children:[s.jsx(it,{settingsItem:"sessions.deletion-dialog",checked:y,onChange:N,label:t("settings.openchamber.defaults.field.showDeletionDialog"),ariaLabel:t("settings.openchamber.defaults.field.showDeletionDialogAria")}),s.jsx(Pw,{}),k?null:s.jsx(it,{settingsItem:"sessions.show-chats",checked:v,onChange:se=>{S(se),yt({sidebarShowChatsSection:se})},label:t("settings.openchamber.defaults.field.showChats"),ariaLabel:t("settings.openchamber.defaults.field.showChats")})]}),s.jsxs("div",{className:"space-y-3 pt-6",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Dn,{children:t("settings.openchamber.defaults.smallModel.title")}),s.jsx(qt,{children:t("settings.openchamber.defaults.smallModel.description")})]}),s.jsx(it,{settingsItem:"sessions.small-model",checked:K,onChange:se=>{X(se)},label:t("settings.openchamber.defaults.smallModel.useDefault"),ariaLabel:t("settings.openchamber.defaults.smallModel.useDefaultAria")}),K?null:s.jsx(kt,{label:t("settings.openchamber.defaults.smallModel.overrideModel"),children:s.jsx(oa,{providerId:fe.providerId,modelId:fe.modelId,onChange:Q,allowedProviderIds:E,className:sn})}),s.jsxs(da,{className:bs,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Dn,{children:t("settings.openchamber.defaults.walkthroughModel.title")}),s.jsx(qt,{children:t("settings.openchamber.defaults.walkthroughModel.description")})]}),s.jsx(kt,{settingsItem:"sessions.walkthrough-model",label:t("settings.openchamber.defaults.walkthroughModel.overrideModel"),children:s.jsx(oa,{providerId:Y.providerId,modelId:Y.modelId,onChange:le,allowedProviderIds:E,isModelAllowed:Z,placeholder:t("settings.openchamber.defaults.walkthroughModel.usesSmallModel"),className:sn})})]})]})]})})})},Nd={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"}},Rw={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"},Fw=()=>{const{t}=ze(),e=c.useMemo(()=>as(),[]),a=c.useMemo(()=>cs(),[]),n=c.useMemo(()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",[]),o=!e&&!a&&!n,i=oe(z=>z.nativeNotificationsEnabled),r=oe(z=>z.setNativeNotificationsEnabled),l=oe(z=>z.notificationMode),u=oe(z=>z.setNotificationMode),m=oe(z=>z.notifyOnSubtasks),d=oe(z=>z.setNotifyOnSubtasks),f=oe(z=>z.notifyOnCompletion),g=oe(z=>z.setNotifyOnCompletion),p=oe(z=>z.notifyOnError),h=oe(z=>z.setNotifyOnError),w=oe(z=>z.notifyOnQuestion),b=oe(z=>z.setNotifyOnQuestion),k=oe(z=>z.notificationTemplates),v=oe(z=>z.setNotificationTemplates),[S,y]=c.useState("default"),[N,x]=c.useState(!1),[I,j]=c.useState(!1),[D,C]=c.useState(!1);c.useEffect(()=>{if(!o){x(!1),j(!1);return}typeof Notification<"u"&&y(Notification.permission);const z=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;x(z),(async()=>{if(!z){j(!1);return}try{const V=await navigator.serviceWorker.getRegistration();if(!V){j(!1);return}const G=await V.pushManager.getSubscription();j(!!G)}catch{j(!1)}})()},[o]);const P=async z=>{if(e){r(z);return}if(!o){r(z);return}if(z&&typeof Notification<"u"&&Notification.permission==="default")try{const $=await Notification.requestPermission();y($),$==="granted"?r(!0):W.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.description")})}catch($){console.error("Failed to request notification permission:",$),W.error(t("settings.notifications.page.toast.requestPermissionFailed"))}else r(!!(z&&S==="granted"))},A=e||a||n||o&&typeof Notification<"u"&&Notification.permission==="granted",R=(z,$,V)=>{v(G=>({...G,[z]:{...G[z],[$]:V}}))},K=z=>{const $="=".repeat((4-z.length%4)%4),V=(z+$).replace(/-/g,"+").replace(/_/g,"/"),G=atob(V),ee=new Uint8Array(G.length);for(let ae=0;ae<G.length;ae+=1)ee[ae]=G.charCodeAt(ae);return ee},F=async(z,$,V)=>{let G=null;const ee=new Promise((ae,X)=>{G=setTimeout(()=>{X(new Error(V))},$)});try{return await Promise.race([z,ee])}finally{G&&clearTimeout(G)}},T=async z=>{if(z.active)return;const $=z.installing||z.waiting;$&&$.state!=="activated"&&await F(new Promise(V=>{const G=()=>{$.state==="activated"&&($.removeEventListener("statechange",G),V())};$.addEventListener("statechange",G),G()}),15e3,"Service worker activation timed out")},O=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const z=[{label:"no-options",opts:null},{label:"scope-root",opts:{scope:"/"}},{label:"type-classic",opts:{type:"classic"}},{label:"type-classic-scope",opts:{type:"classic",scope:"/"}},{label:"updateViaCache-none",opts:{type:"classic",updateViaCache:"none",scope:"/"}}];let $=null;for(const V of z)try{const G=V.opts?navigator.serviceWorker.register("/sw.js",V.opts):navigator.serviceWorker.register("/sw.js");return await F(G,1e4,`Service worker registration timed out (${V.label})`)}catch(G){$=G}throw $ instanceof Error?$:new Error("Service worker registration failed")},E=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const z=await navigator.serviceWorker.getRegistration();if(z)return z;const $=await O();try{await $.update()}catch{}return await T($),$},B=z=>{const $=z,V=[`type=${typeof z}`,`toString=${String(z)}`,`name=${String($?.name??"")}`,`message=${String($?.message??"")}`];let G="";try{G=JSON.stringify(z)}catch{}return{summary:V.filter(Boolean).join(" | "),json:G,stack:typeof $?.stack=="string"?$.stack:""}},_=async()=>{const z=la();if(!z?.notifications){W.error(t("settings.notifications.page.toast.notificationsApiUnavailable"));return}try{await z.notifications.notifyAgentCompletion({title:t("settings.notifications.page.testNotification.title"),body:t("settings.notifications.page.testNotification.body"),tag:"openchamber-test"})?W.success(t("settings.notifications.page.toast.testNotificationSent")):W.error(t("settings.notifications.page.toast.testNotificationFailed"))}catch($){console.error("Test notification failed:",$),W.error(t("settings.notifications.page.toast.testNotificationFailed"))}},H=async()=>{if(!N){W.error(t("settings.notifications.page.toast.pushUnsupported"));return}const z=la();if(!z?.push){W.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}C(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const le=await Notification.requestPermission();if(y(le),le!=="granted"){W.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){W.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}const $=await z.push.getVapidPublicKey();if(!$?.publicKey){W.error(t("settings.notifications.page.toast.pushKeyLoadFailed"));return}const V=await E();await T(V);const G=await V.pushManager.getSubscription();if(!("pushManager"in V)||!V.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const ae=(G??await F(V.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:K($.publicKey)}),15e3,"Push subscription timed out")).toJSON(),X=ae.keys;if(!ae.endpoint||!X?.p256dh||!X.auth)throw new Error("Push subscription missing keys");if(!(await F(z.push.subscribe({endpoint:ae.endpoint,keys:{p256dh:X.p256dh,auth:X.auth},origin:typeof window<"u"?window.location.origin:void 0,platform:Jg()}),15e3,"Push subscribe request timed out"))?.ok){W.error(t("settings.notifications.page.toast.enableBackgroundFailed"));return}j(!0),W.success(t("settings.notifications.page.toast.backgroundEnabled"))}catch($){console.error("[Push] Enable failed:",$);const V=B($);W.error(t("settings.notifications.page.toast.enableBackgroundFailed"),{description:V.summary})}finally{C(!1)}},ne=async()=>{if(!N){j(!1);return}const z=la();if(!z?.push){W.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}C(!0);try{const V=await(await E()).pushManager.getSubscription();if(!V){j(!1);return}const G=V.endpoint;await V.unsubscribe(),await z.push.unsubscribe({endpoint:G}),j(!1),W.success(t("settings.notifications.page.toast.backgroundDisabled"))}finally{C(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs(He,{settingsItem:"notifications.delivery",title:t("settings.notifications.page.delivery.title"),divider:!1,children:[s.jsxs("div",{className:bs,children:[s.jsx(it,{checked:i&&A,onChange:z=>{P(z)},label:t("settings.notifications.page.delivery.enableLabel"),info:o?t("settings.notifications.page.delivery.browserPermissionHint"):a?t("settings.notifications.page.delivery.vscodeHint"):void 0,ariaLabel:t("settings.notifications.page.delivery.enableAria")}),i&&A&&!n&&s.jsxs(s.Fragment,{children:[s.jsx(it,{checked:l==="always",onChange:z=>u(z?"always":"hidden-only"),label:t("settings.notifications.page.delivery.focusedLabel"),ariaLabel:t("settings.notifications.page.delivery.focusedAria")}),s.jsx("div",{className:"py-2",children:s.jsx(q,{type:"button",variant:"outline",size:"sm",onClick:()=>{_()},children:t("settings.notifications.page.delivery.testAction")})})]})]}),o&&s.jsxs("div",{className:"mt-1",children:[S==="denied"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:t("settings.notifications.page.delivery.permissionDenied")}),S==="granted"&&!i&&s.jsx("p",{className:"typography-meta text-muted-foreground/70 mt-1",children:t("settings.notifications.page.delivery.permissionGrantedButDisabled")})]})]}),i&&A&&s.jsxs(s.Fragment,{children:[s.jsx(He,{settingsItem:"notifications.events",title:t("settings.notifications.page.events.title"),children:s.jsxs("div",{className:bs,children:[s.jsx(it,{checked:f,onChange:g,label:t("settings.notifications.page.events.completionLabel"),ariaLabel:t("settings.notifications.page.events.completionAria")}),s.jsx(it,{checked:m,onChange:d,label:t("settings.notifications.page.events.subtaskLabel"),ariaLabel:t("settings.notifications.page.events.subtaskAria")}),s.jsx(it,{checked:p,onChange:h,label:t("settings.notifications.page.events.errorLabel"),ariaLabel:t("settings.notifications.page.events.errorAria")}),s.jsx(it,{checked:w,onChange:b,label:t("settings.notifications.page.events.questionLabel"),ariaLabel:t("settings.notifications.page.events.questionAria")})]})}),!n&&s.jsx(He,{title:t("settings.notifications.page.template.title"),description:s.jsxs(s.Fragment,{children:[t("settings.notifications.page.template.variablesLabel")," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{project_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{worktree}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{branch}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{session_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{agent_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{model_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{last_message}"})]}),children:s.jsx(Nn,{className:"gap-2 md:grid-cols-2 md:gap-3 lg:gap-3",children:["completion","subtask","error","question"].map(z=>s.jsxs("section",{className:"p-2",children:[s.jsx(Dn,{className:"capitalize",children:t(Rw[z])}),s.jsxs("div",{className:"mt-1.5 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.title")}),s.jsx(Ve,{value:k[z].title,onChange:$=>R(z,"title",$.target.value),className:"h-7",placeholder:t(Nd[z].titleKey)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.message")}),s.jsx(Ve,{value:k[z].message,onChange:$=>R(z,"message",$.target.value),className:"h-7",placeholder:t(Nd[z].messageKey)})]})]})]},z))})})]}),o&&s.jsx(He,{settingsItem:"notifications.push",title:t("settings.notifications.page.push.title"),children:s.jsx(it,{checked:N?I:!1,disabled:!N||D,onChange:z=>{z?H():ne()},label:t("settings.notifications.page.push.enableLabel"),description:N?void 0:t("settings.notifications.page.push.unsupportedHint"),info:N?t("settings.notifications.page.push.supportedHint"):void 0,ariaLabel:t("settings.notifications.page.push.enableAria"),labelAccessory:D?s.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground animate-busy-pulse","aria-label":t("settings.notifications.page.push.loadingAria")}):null})})]})},As=t=>{if(!t)return;t.pause();const{src:e}=t;e.startsWith("blob:")&&URL.revokeObjectURL(e),t.removeAttribute("src"),t.load()},$n="oc-surface-elevated w-full h-7 rounded-lg border border-input bg-surface-elevated px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring focus:border-interactive-border-focus",Ow=[{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"}],Cd=t=>{const e=$e.c(8),{value:a,label:n}=t,o=`${n}: ${a}/5`,i=`${a/5*100}%`;let r;e[0]!==i?(r=s.jsx("span",{className:"h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]","aria-hidden":"true",children:s.jsx("span",{className:"block h-full rounded-full bg-[var(--primary-base)]",style:{width:i}})}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==n?(l=s.jsx("span",{className:"typography-ui-compact text-muted-foreground",children:n}),e[2]=n,e[3]=l):l=e[3];let u;return e[4]!==o||e[5]!==r||e[6]!==l?(u=s.jsxs("span",{className:"flex items-center gap-1.5",title:o,children:[r,l]}),e[4]=o,e[5]=r,e[6]=l,e[7]=u):u=e[7],u},Lw=({selectedModelId:t,onSelect:e})=>{const{t:a}=ze(),n=Be.useCallback(g=>a(g),[a]),[o,i]=Be.useState(new Map),[r,l]=Be.useState(null),u=Be.useCallback(async()=>{try{const g=await Rt("/api/dictation/status",{query:{provider:"local"}});if(!g.ok)return;const p=await g.json();Array.isArray(p?.models)&&i(new Map(p.models.map(h=>[h.id,h])))}catch{}},[]);Be.useEffect(()=>{u()},[u]);const m=Array.from(o.values()).some(g=>g.downloading);Be.useEffect(()=>{if(!m)return;const g=setInterval(()=>{u()},2e3);return()=>clearInterval(g)},[m,u]);const d=async g=>{l(g);try{await Rt(`/api/dictation/models/${encodeURIComponent(g)}/download`,{method:"POST"}),await u()}catch{}finally{l(null)}},f=async g=>{l(g);try{await Rt(`/api/dictation/models/${encodeURIComponent(g)}`,{method:"DELETE"}),await u()}catch{}finally{l(null)}};return s.jsx("div",{role:"radiogroup","aria-label":a("settings.voice.page.field.model"),className:"mt-1.5 grid w-full grid-cols-1 gap-3 @xl:grid-cols-2",children:Ow.map(g=>{const p=t===g.id,h=o.get(g.id)??null;return s.jsx("div",{className:Me("rounded-lg border border-[var(--interactive-border)] p-3",p&&"border-border bg-interactive-selection text-interactive-selection-foreground"),children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 cursor-pointer items-start gap-2",role:"button",tabIndex:0,onClick:()=>e(g.id),onKeyDown:w=>{(w.key===" "||w.key==="Enter")&&(w.preventDefault(),e(g.id))},children:[s.jsx("div",{className:"pt-0.5",children:s.jsx(hl,{checked:p,onChange:()=>e(g.id),ariaLabel:n(g.labelKey)})}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:Me("typography-ui-label font-normal",p?"text-foreground":"text-foreground/50"),children:n(g.labelKey)}),g.badgeKey?s.jsx("span",{className:"rounded border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-1 text-[9px] font-medium uppercase leading-[14px] tracking-wide text-[var(--status-success)]",children:n(g.badgeKey)}):null]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Cd,{value:g.accuracy,label:a("settings.voice.page.stt.meta.accuracy")}),s.jsx(Cd,{value:g.speed,label:a("settings.voice.page.stt.meta.speed")}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:g.size})]}),h?.downloadError?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:h.downloadError}):null]})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:h?.installed?s.jsxs(s.Fragment,{children:[s.jsx(q,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:r===g.id,onClick:()=>{f(g.id)},title:a("settings.voice.page.stt.modelDelete"),"aria-label":a("settings.voice.page.stt.modelDelete"),children:s.jsx(J,{name:"delete-bin",className:"h-4 w-4"})}),s.jsx(J,{name:"checkbox-circle",className:"h-4 w-4 flex-shrink-0 text-[var(--status-success)]","aria-label":a("settings.voice.page.stt.modelInstalled")})]}):h?.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(J,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof h.downloadProgress=="number"?`${h.downloadProgress}%`:""})]}):s.jsx(q,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:r===g.id,onClick:()=>{d(g.id)},title:a("settings.voice.page.stt.modelDownload"),"aria-label":a("settings.voice.page.stt.modelDownload"),children:s.jsx(J,{name:"download",className:"h-4 w-4"})})})]})},g.id)})})},Kw=[{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)"}],cl="kokoro-en-v0_19",zw="kokoro-multi-lang-v1_1",Uw=[{id:0,label:"Maple (af)"},{id:1,label:"Sol (af)"},{id:2,label:"Vale (bf)"},{id:3,label:"Xiaoxiao (zf)"},{id:58,label:"Yunxi (zm)"}],bi=(t,e)=>`${t}:${e}`,$w=()=>{const[t,e]=Be.useState([]),[a,n]=Be.useState(null),o=Be.useCallback(async()=>{try{const l=await Rt("/api/dictation/status",{query:{provider:"local"}});if(!l.ok)return;const u=await l.json();Array.isArray(u?.ttsModels)&&e(u.ttsModels)}catch{}},[]);Be.useEffect(()=>{o()},[o]);const i=t.some(l=>l.downloading);Be.useEffect(()=>{if(!i)return;const l=setInterval(()=>{o()},2e3);return()=>clearInterval(l)},[i,o]);const r=Be.useCallback(async(l,u)=>{n(l);try{const m=u==="POST"?`/api/dictation/models/${l}/download`:`/api/dictation/models/${l}`;await Rt(m,{method:u}),await o()}catch{}finally{n(null)}},[o]);return{models:t,requestingId:a,request:r,refresh:o}},Bw=t=>{const e=Kw.map(a=>({modelId:cl,speakerId:a.id,label:a.label}));for(const a of t)if(!(a.id===cl||!a.installed)){if(a.id===zw){for(const n of Uw)e.push({modelId:a.id,speakerId:n.id,label:`${n.label} · Kokoro zh/en`});continue}e.push({modelId:a.id,speakerId:0,label:a.description??a.id})}return e},Id=t=>{const e=$e.c(16),{model:a,requestingId:n,request:o,t:i}=t,r=a.description??a.id;let l;e[0]!==r?(l=s.jsx("span",{className:"typography-ui-label text-foreground",children:r}),e[0]=r,e[1]=l):l=e[1];let u;e[2]!==a.downloadProgress||e[3]!==a.downloading||e[4]!==a.id||e[5]!==a.installed||e[6]!==o||e[7]!==n||e[8]!==i?(u=a.installed?s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]","aria-label":i("settings.voice.page.stt.modelInstalled")}),s.jsx(q,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:n!==null,onClick:()=>{o(a.id,"DELETE")},title:i("settings.voice.page.stt.modelDelete"),"aria-label":i("settings.voice.page.stt.modelDelete"),children:s.jsx(J,{name:"delete-bin",className:"h-4 w-4"})})]}):a.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(J,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof a.downloadProgress=="number"?`${a.downloadProgress}%`:""})]}):s.jsx(q,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:n!==null,onClick:()=>{o(a.id,"POST")},title:i("settings.voice.page.stt.modelDownload"),"aria-label":i("settings.voice.page.stt.modelDownload"),children:s.jsx(J,{name:"download",className:"h-4 w-4"})}),e[2]=a.downloadProgress,e[3]=a.downloading,e[4]=a.id,e[5]=a.installed,e[6]=o,e[7]=n,e[8]=i,e[9]=u):u=e[9];let m;e[10]!==a.downloadError?(m=a.downloadError?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:a.downloadError}):null,e[10]=a.downloadError,e[11]=m):m=e[11];let d;return e[12]!==l||e[13]!==u||e[14]!==m?(d=s.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[l,u,m]}),e[12]=l,e[13]=u,e[14]=m,e[15]=d):d=e[15],d},_w=t=>{const e=$e.c(21),{models:a,requestingId:n,request:o}=t,{t:i}=ze(),[r,l]=Be.useState(!1),[u,m]=Be.useState("");if(a.length===0)return null;let d,f,g;if(e[0]!==u||e[1]!==a){f=[],d=[];for(const v of a)v.id===cl||v.installed||v.downloading||v.downloadError?f.push(v):d.push(v);const k=u.trim().toLowerCase();g=k?d.filter(v=>(v.description??"").toLowerCase().includes(k)||v.id.toLowerCase().includes(k)):d,e[0]=u,e[1]=a,e[2]=d,e[3]=f,e[4]=g}else d=e[2],f=e[3],g=e[4];const p=g;let h;e[5]!==f||e[6]!==o||e[7]!==n||e[8]!==i?(h=f.map(k=>s.jsx(Id,{model:k,requestingId:n,request:o,t:i},k.id)),e[5]=f,e[6]=o,e[7]=n,e[8]=i,e[9]=h):h=e[9];let w;e[10]!==d.length||e[11]!==r||e[12]!==u||e[13]!==p||e[14]!==o||e[15]!==n||e[16]!==i?(w=d.length>0?s.jsxs(Js,{open:r,onOpenChange:l,children:[s.jsxs(Qs,{className:"group flex w-full items-center justify-between py-1 hover:bg-transparent",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-start",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:i("settings.voice.page.localTts.availableToDownload")}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",d.length,")"]})]}),s.jsx(J,{name:r?"arrow-down-s":"arrow-right-s",className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]}),s.jsxs(Ys,{className:"pt-1",children:[s.jsx("input",{type:"text",value:u,onChange:k=>m(k.target.value),placeholder:i("settings.voice.page.localTts.filterPlaceholder"),"aria-label":i("settings.voice.page.localTts.filterPlaceholder"),className:Me($n,"mb-1")}),p.length===0?s.jsx("div",{className:"typography-meta py-1.5 text-muted-foreground",children:i("settings.voice.page.localTts.filterNoMatch")}):p.map(k=>s.jsx(Id,{model:k,requestingId:n,request:o,t:i},k.id))]})]}):null,e[10]=d.length,e[11]=r,e[12]=u,e[13]=p,e[14]=o,e[15]=n,e[16]=i,e[17]=w):w=e[17];let b;return e[18]!==h||e[19]!==w?(b=s.jsxs("div",{className:"flex flex-col",children:[h,w]}),e[18]=h,e[19]=w,e[20]=b):b=e[20],b},Vw=[{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"}],Lr=t=>{const e=$e.c(34),{kind:a}=t,{t:n}=ze();let o;e[0]!==a?(o=I=>I.voiceApiKeys[a],e[0]=a,e[1]=o):o=e[1];const i=rt(o),r=rt(qw),[l,u]=Be.useState(""),[m,d]=Be.useState(!1);let f;e[2]!==a||e[3]!==r||e[4]!==n?(f=async I=>{d(!0);const j=await r(a,I);d(!1),j?u(""):W.error(n("settings.voice.page.toast.apiKeySaveFailed"))},e[2]=a,e[3]=r,e[4]=n,e[5]=f):f=e[5];const g=f;let p;e[6]!==l||e[7]!==g?(p=()=>{const I=l.trim();I&&g(I)},e[6]=l,e[7]=g,e[8]=p):p=e[8];const h=p;let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=Me("relative",ys),e[9]=w):w=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=I=>u(I.target.value),e[10]=b):b=e[10];let k;e[11]!==h?(k=I=>{I.key==="Enter"&&h()},e[11]=h,e[12]=k):k=e[12];let v;e[13]!==i||e[14]!==n?(v=i?n("settings.voice.page.field.apiKeySavedPlaceholder"):"sk-...",e[13]=i,e[14]=n,e[15]=v):v=e[15];let S;e[16]!==n?(S=n("settings.voice.page.field.apiKey"),e[16]=n,e[17]=S):S=e[17];let y;e[18]!==h||e[19]!==l||e[20]!==m||e[21]!==k||e[22]!==v||e[23]!==S?(y=s.jsx("input",{type:"password",value:l,disabled:m,onChange:b,onBlur:h,onKeyDown:k,placeholder:v,className:$n,"aria-label":S}),e[18]=h,e[19]=l,e[20]=m,e[21]=k,e[22]=v,e[23]=S,e[24]=y):y=e[24];let N;e[25]!==l||e[26]!==m||e[27]!==g||e[28]!==i||e[29]!==n?(N=i&&!l&&s.jsx("button",{type:"button",onClick:()=>{g(null)},disabled:m,"aria-label":n("settings.voice.page.field.apiKeyRemove"),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(J,{name:"close",className:"w-3.5 h-3.5"})}),e[25]=l,e[26]=m,e[27]=g,e[28]=i,e[29]=n,e[30]=N):N=e[30];let x;return e[31]!==N||e[32]!==y?(x=s.jsxs("div",{className:w,children:[y,N]}),e[31]=N,e[32]=y,e[33]=x):x=e[33],x},Hw=()=>{const{t}=ze(),{isMobile:e}=Fn(),a=rt(te=>te.voiceProvider),n=rt(te=>te.setVoiceProvider),o=rt(te=>te.speechRate),i=rt(te=>te.setSpeechRate),r=rt(te=>te.speechPitch),l=rt(te=>te.setSpeechPitch),u=rt(te=>te.speechVolume),m=rt(te=>te.setSpeechVolume),d=rt(te=>te.sayVoice),f=rt(te=>te.setSayVoice),g=rt(te=>te.localTtsVoiceId),p=rt(te=>te.localTtsModelId),h=rt(te=>te.setLocalTtsModelId),w=$w(),b=Be.useMemo(()=>Bw(w.models),[w.models]),k=rt(te=>te.ttsFollowTextLanguage),v=rt(te=>te.setTtsFollowTextLanguage),S=rt(te=>te.setLocalTtsVoiceId),{speak:y,stop:N,isPlaying:x,error:I}=dg(),j=Be.useCallback(()=>{if(x){N();return}const te=b.find(ue=>ue.modelId===p&&ue.speakerId===g)?.label??String(g);y(t("settings.voice.page.preview.voiceLine",{voiceName:te}),{model:p,speakerId:g,speed:rt.getState().speechRate})},[x,p,g,b,y,N,t]),D=rt(te=>te.browserVoice),C=rt(te=>te.setBrowserVoice),P=rt(te=>te.openaiVoice),A=rt(te=>te.setOpenaiVoice),R=rt(te=>te.voiceApiKeys.openai),K=rt(te=>te.refreshVoiceApiKeys),F=rt(te=>te.openaiCompatibleUrl),T=rt(te=>te.setOpenaiCompatibleUrl),O=rt(te=>te.openaiCompatibleVoice),E=rt(te=>te.setOpenaiCompatibleVoice),B=rt(te=>te.openaiCompatibleTtsModel),_=rt(te=>te.setOpenaiCompatibleTtsModel),H=rt(te=>te.showMessageTTSButtons),ne=rt(te=>te.ttsInputMode),z=rt(te=>te.setTtsInputMode),$=rt(te=>te.ttsChunkedMode),V=rt(te=>te.setTtsChunkedMode),G=rt(te=>te.sttProvider),ee=rt(te=>te.setSttProvider),ae=rt(te=>te.sttServerUrl),X=rt(te=>te.setSttServerUrl),Q=rt(te=>te.sttModel),le=rt(te=>te.setSttModel),Z=rt(te=>te.sttLocalModel),fe=rt(te=>te.setSttLocalModel),Y=rt(te=>te.sttLanguage),be=rt(te=>te.setSttLanguage),Ee=rt(te=>te.setShowMessageTTSButtons),se=rt(te=>te.dictationEnabled),re=rt(te=>te.setDictationEnabled),[je,ie]=Be.useState(!1),[Pe,ke]=Be.useState([]),[Ae,Te]=Be.useState(!1),[Ke,ge]=Be.useState(null),[Re,Oe]=Be.useState(!1),[pe,xe]=Be.useState(!1),[Ne,de]=Be.useState(!1),[Ue,Ie]=Be.useState(null),[De,Je]=Be.useState(!1),[tt,mt]=Be.useState(null),[ht,ft]=Be.useState([]),[xt,Qe]=Be.useState(!1);Be.useEffect(()=>((async()=>{const ue=await fr.waitForVoices();ft(ue)})(),"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=()=>{ft(window.speechSynthesis.getVoices())}),()=>{"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);const lt=Be.useMemo(()=>ht.filter(te=>te.lang).sort((te,ue)=>{const he=te.lang.startsWith("en"),ye=ue.lang.startsWith("en");if(he&&!ye)return-1;if(!he&&ye)return 1;const qe=te.lang.localeCompare(ue.lang);return qe!==0?qe:te.name.localeCompare(ue.name)}),[ht]),Ye=Be.useCallback(()=>{if(xt){fr.cancelSpeech(),Qe(!1);return}const te=ht.find(qe=>qe.name===D),ue=te?.name??t("settings.voice.page.preview.browserVoiceFallback"),he=t("settings.voice.page.preview.voiceLine",{voiceName:ue});Qe(!0);const ye=new SpeechSynthesisUtterance(he);ye.rate=o,ye.pitch=r,ye.volume=u,te&&(ye.voice=te,ye.lang=te.lang),ye.onend=()=>Qe(!1),ye.onerror=()=>Qe(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(ye)},[D,ht,o,r,u,xt,t]);Be.useEffect(()=>()=>{xt&&fr.cancelSpeech()},[xt]),Be.useEffect(()=>{K({force:!0})},[K]),Be.useEffect(()=>{if(!H||a!=="openai"&&a!=="openai-compatible"){Oe(R);return}(async()=>{try{const he=await(await Rt("/api/tts/status")).json(),ye=he.available,qe=R,Ze=he.enterpriseMode===!0;xe(Ze),Oe(!Ze&&(ye||qe))}catch{Oe(R)}})()},[R,H,a]),Be.useEffect(()=>{if(!H){ie(!1),ke([]);return}Rt("/api/tts/say/status").then(te=>te.json()).then(te=>{if(ie(te.available),te.voices){const ue=te.voices.filter((he,ye,qe)=>qe.findIndex(Ze=>Ze.name===he.name)===ye).sort((he,ye)=>he.name.localeCompare(ye.name));ke(ue)}}).catch(()=>{ie(!1)})},[H]);const at=Be.useCallback(async()=>{if(Ke){As(Ke),ge(null),Te(!1);return}Te(!0);let te=null;try{const ue=await Rt("/api/tts/say/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:d}),voice:d,rate:Math.round(100+(o-.5)*200)})});if(!ue.ok)throw new Error("Preview failed");const he=await ue.blob(),ye=URL.createObjectURL(he);te=new Audio(ye),te.onended=()=>{As(te),ge(null),Te(!1)},te.onerror=()=>{As(te),ge(null),Te(!1)},ge(te),await te.play()}catch{As(te),ge(null),Te(!1)}},[d,o,Ke,t]);Be.useEffect(()=>()=>{As(Ke)},[Ke]);const dt=Be.useCallback(async()=>{if(Ue){As(Ue),Ie(null),de(!1);return}de(!0);let te=null;try{const ue=await Rt("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:P}),voice:P,speed:o})});if(!ue.ok){const qe=await ue.json().catch(()=>({error:"Unknown error"}));throw new Error(qe.error||`HTTP ${ue.status}`)}const he=await ue.blob(),ye=URL.createObjectURL(he);te=new Audio(ye),te.onended=()=>{As(te),Ie(null),de(!1)},te.onerror=()=>{As(te),Ie(null),de(!1)},Ie(te),await te.play()}catch{As(te),Ie(null),de(!1)}},[P,o,Ue,t]);Be.useEffect(()=>()=>{As(Ue)},[Ue]);const _e=Be.useCallback(async()=>{if(tt){As(tt),mt(null),Je(!1);return}if(!F.trim())return;Je(!0);let te=null;try{const ue=await Rt("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.customServerLine"),voice:O,model:B||void 0,speed:o,baseURL:F})});if(!ue.ok){const qe=await ue.json().catch(()=>({error:"Unknown error"}));throw new Error(qe.error||`HTTP ${ue.status}`)}const he=await ue.blob(),ye=URL.createObjectURL(he);te=new Audio(ye),te.onended=()=>{As(te),mt(null),Je(!1)},te.onerror=()=>{As(te),mt(null),Je(!1)},mt(te),await te.play()}catch{As(te),mt(null),Je(!1)}},[F,O,B,o,tt,t]);Be.useEffect(()=>()=>{As(tt)},[tt]);const nt="flex-1 min-w-0 h-1.5 bg-[var(--interactive-border)] rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:border-0 disabled:opacity-50";return s.jsxs(s.Fragment,{children:[s.jsxs(He,{settingsItem:"voice.playback",title:t("settings.voice.page.section.playbackAndSummary"),divider:!1,contentClassName:"space-y-4",children:[s.jsx(it,{checked:H,onChange:Ee,label:t("settings.voice.page.field.messageReadAloudButton"),ariaLabel:t("settings.voice.page.field.messageReadAloudButtonAria")}),H&&s.jsxs(s.Fragment,{children:[s.jsx(hs,{title:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.browser")})," ",t("settings.voice.page.tooltip.browser")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.localTts")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.openai")})," ",t("settings.voice.page.tooltip.openai")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.custom")})," ",t("settings.voice.page.tooltip.custom")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.say")})," ",t("settings.voice.page.tooltip.say")]})]}),children:s.jsx(Gs,{value:a,onChange:n,"aria-label":t("settings.voice.page.field.provider"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"browser",label:t("settings.voice.page.provider.browser")},{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai",label:t("settings.voice.page.provider.openai")},{value:"openai-compatible",label:t("settings.voice.page.provider.custom")},...je?[{value:"say",label:s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"apple",className:"me-0.5 h-3.5 w-3.5"}),t("settings.voice.page.provider.say")]})}]:[]]})}),pe&&(a==="openai"||a==="openai-compatible")&&s.jsx("p",{className:Dt,children:t("settings.voice.page.enterpriseMode")}),a==="openai"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Me(Ct,!Re&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.apiKey")}),s.jsx("span",{className:Me(Dt,!Re&&"text-[var(--status-error)]/80"),children:t(Re&&!R?"settings.voice.page.field.apiKeyHintUsingConfig":Re?"settings.voice.page.field.apiKeyHintProvide":"settings.voice.page.field.apiKeyHintRequired")}),s.jsx(Lr,{kind:"openai"})]}),a==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Me(Ct,!F.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),s.jsx(qt,{children:t("settings.voice.page.field.serverUrlHint")})]}),s.jsxs("div",{className:Me("relative",ys),children:[s.jsx("input",{type:"text",value:F,onChange:te=>T(te.target.value),placeholder:"http://localhost:8880/v1",className:$n}),F&&s.jsx("button",{type:"button",onClick:()=>T(""),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(J,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.apiKey")}),s.jsx("span",{className:Dt,children:t("settings.voice.page.field.apiKeyOptional")}),s.jsx(Lr,{kind:"openaiCompatible"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.model")}),s.jsx("div",{className:Me("relative",ys),children:s.jsx("input",{type:"text",value:B,onChange:te=>_(te.target.value),placeholder:"speaches-ai/Kokoro-82M-v1.0-ONNX",className:$n})})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.voice")}),s.jsx(qt,{children:t("settings.voice.page.field.voiceIdentifierHint")})]}),s.jsxs("div",{className:Me("flex items-center gap-2",ys),children:[s.jsx("div",{className:"relative min-w-0 flex-1",children:s.jsx("input",{type:"text",value:O,onChange:te=>E(te.target.value),placeholder:"af_sky",className:$n})}),s.jsx(q,{size:"xs",variant:"ghost",onClick:_e,title:t("settings.voice.page.actions.preview"),disabled:!F.trim(),children:De?s.jsx(J,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(J,{name:"play",className:"w-3.5 h-3.5"})})]})]})]}),a==="local"&&s.jsx(_w,{...w}),(a==="local"||a==="say")&&s.jsx(it,{checked:k,onChange:v,label:t("settings.voice.page.field.followTextLanguage"),ariaLabel:t("settings.voice.page.field.followTextLanguageAria"),info:t("settings.voice.page.field.followTextLanguageInfo")}),s.jsxs(kt,{label:t("settings.voice.page.field.voice"),children:[a==="local"&&s.jsxs(s.Fragment,{children:[s.jsxs(Tt,{value:bi(p,g),onValueChange:te=>{const ue=b.find(he=>bi(he.modelId,he.speakerId)===te);ue&&(h(ue.modelId),S(ue.speakerId))},children:[s.jsx(Pt,{className:nn,children:s.jsx(Ut,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder"),children:te=>b.find(ue=>bi(ue.modelId,ue.speakerId)===te)?.label??te})}),s.jsx(At,{children:b.map(te=>s.jsx(ot,{value:bi(te.modelId,te.speakerId),children:te.label},bi(te.modelId,te.speakerId)))})]}),s.jsx(q,{size:"xs",variant:"ghost",onClick:j,title:t("settings.voice.page.actions.preview"),children:x?s.jsx(J,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(J,{name:"play",className:"w-3.5 h-3.5"})}),I?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:I}):null]}),a==="openai"&&Re&&s.jsxs(s.Fragment,{children:[s.jsxs(Tt,{value:P,onValueChange:A,children:[s.jsx(Pt,{className:nn,children:s.jsx(Ut,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder")})}),s.jsx(At,{children:Vw.map(te=>s.jsx(ot,{value:te.value,children:te.label},te.value))})]}),s.jsx(q,{size:"xs",variant:"ghost",onClick:dt,title:t("settings.voice.page.actions.preview"),children:Ne?s.jsx(J,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(J,{name:"play",className:"w-3.5 h-3.5"})})]}),a==="openai-compatible"&&s.jsx("span",{className:Dt,children:t("settings.voice.page.field.configuredAbove")}),a==="say"&&je&&Pe.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Tt,{value:d,onValueChange:f,children:[s.jsx(Pt,{className:nn,children:s.jsx(Ut,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder")})}),s.jsx(At,{children:Pe.map(te=>s.jsx(ot,{value:te.name,children:te.name},te.name))})]}),s.jsx(q,{size:"xs",variant:"ghost",onClick:at,title:t("settings.voice.page.actions.preview"),children:Ae?s.jsx(J,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(J,{name:"play",className:"w-3.5 h-3.5"})})]}),a==="browser"&<.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Tt,{value:D||"$auto",onValueChange:te=>C(te==="$auto"?"":te),children:[s.jsx(Pt,{className:nn,children:s.jsx(Ut,{placeholder:t("settings.voice.page.field.auto")})}),s.jsxs(At,{children:[s.jsx(ot,{value:"$auto",children:t("settings.voice.page.field.auto")}),lt.map(te=>s.jsxs(ot,{value:te.name,children:[te.name," (",te.lang,")"]},te.name))]})]}),s.jsx(q,{size:"xs",variant:"ghost",onClick:Ye,title:t("settings.voice.page.actions.preview"),children:xt?s.jsx(J,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(J,{name:"play",className:"w-3.5 h-3.5"})})]})]}),s.jsxs(kt,{label:t("settings.voice.page.field.speechRate"),children:[!e&&s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:o,onChange:te=>i(Number(te.target.value)),className:nt}),s.jsx(ps,{value:o,onValueChange:i,min:.5,max:2,step:.1,className:Me(fs,"tabular-nums")})]}),s.jsxs(kt,{label:t("settings.voice.page.field.speechPitch"),children:[!e&&s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:r,onChange:te=>l(Number(te.target.value)),className:nt}),s.jsx(ps,{value:r,onValueChange:l,min:.5,max:2,step:.1,className:Me(fs,"tabular-nums")})]}),s.jsxs(kt,{label:t("settings.voice.page.field.speechVolume"),children:[!e&&s.jsx("input",{type:"range",min:0,max:1,step:.1,value:u,onChange:te=>m(Number(te.target.value)),className:nt}),e?s.jsx(ps,{value:Math.round(u*100),onValueChange:te=>m(te/100),min:0,max:100,step:10,className:Me(fs,"tabular-nums")}):s.jsxs("span",{className:"typography-ui-label text-foreground tabular-nums min-w-[3rem] text-end",children:[Math.round(u*100),"%"]})]}),s.jsx(hs,{title:t("settings.voice.page.field.ttsInputMode"),children:s.jsx(Gs,{value:ne,onChange:z,"aria-label":t("settings.voice.page.field.ttsInputMode"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"sanitized",label:t("settings.voice.page.field.ttsInputModeSanitized")},{value:"raw",label:t("settings.voice.page.field.ttsInputModeRaw")},{value:"summarized",label:t("settings.voice.page.field.ttsInputModeSummarized")}]})}),(a==="openai"||a==="openai-compatible")&&s.jsx(it,{checked:$,onChange:V,label:t("settings.voice.page.field.ttsChunkedMode"),ariaLabel:t("settings.voice.page.field.ttsChunkedModeAria"),info:t("settings.voice.page.tooltip.ttsChunked")})]})]}),s.jsxs(He,{settingsItem:"voice.speech-recognition",title:t("settings.voice.page.section.speechRecognition"),contentClassName:"space-y-4",children:[s.jsx(it,{checked:se,onChange:re,label:t("settings.voice.page.field.enableVoiceInput"),ariaLabel:t("settings.voice.page.field.enableVoiceInputAria")}),se&&s.jsxs(s.Fragment,{children:[s.jsx(hs,{title:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.sttLocal")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.server")})," ",t("settings.voice.page.tooltip.sttServer")]})]}),children:s.jsx(Gs,{value:G,onChange:ee,"aria-label":t("settings.voice.page.field.provider"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai-compatible",label:t("settings.voice.page.provider.server")}]})}),G==="local"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.model")}),s.jsx(Lw,{selectedModelId:Z,onSelect:fe})]}),G==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Me(Ct,!ae.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),s.jsx(qt,{children:t("settings.voice.page.field.sttServerUrlHint")})]}),s.jsxs("div",{className:Me("relative",ys),children:[s.jsx("input",{type:"text",value:ae,onChange:te=>X(te.target.value),placeholder:"http://localhost:8001/v1",className:$n}),ae&&s.jsx("button",{type:"button",onClick:()=>X(""),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(J,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.apiKey")}),s.jsx("span",{className:Dt,children:t("settings.voice.page.field.apiKeyOptional")}),s.jsx(Lr,{kind:"stt"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.model")}),s.jsx("div",{className:Me("relative",ys),children:s.jsx("input",{type:"text",value:Q,onChange:te=>le(te.target.value),placeholder:"deepdml/faster-whisper-large-v3-turbo-ct2",className:$n})})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ct,children:t("settings.voice.page.field.language")}),s.jsx(qt,{children:t("settings.voice.page.field.sttLanguageHint")})]}),s.jsx("div",{className:"relative max-w-[8rem]",children:s.jsx("input",{type:"text",value:Y,onChange:te=>be(te.target.value),placeholder:"auto",className:$n})})]})]})]})]})]})};function qw(t){return t.setVoiceApiKey}const ro=[{value:"1800000",label:"30m",ms:1800*1e3},{value:"180000",label:"3m",ms:180*1e3},{value:"7200000",label:"2h",ms:7200*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3}],lo=[{value:"3600000",label:"1h",ms:3600*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"43200000",label:"12h",ms:720*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3},{value:"604800000",label:"1w",ms:10080*60*1e3},{value:"2592000000",label:"30d",ms:720*60*60*1e3}],Ww="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",Gw="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",Kr=[{value:"quick",labelKey:"settings.openchamber.tunnel.option.mode.quick.label",tooltipKey:"settings.openchamber.tunnel.option.mode.quick.tooltip"},{value:"managed-remote",labelKey:"settings.openchamber.tunnel.option.mode.managedRemote.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedRemote.tooltip"},{value:"managed-local",labelKey:"settings.openchamber.tunnel.option.mode.managedLocal.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedLocal.tooltip"}],Jw=[".yml",".yaml",".json"],Qw="settings.openchamber.tunnel.error.invalidConfigExtension",xi=t=>{const e=t.trim().toLowerCase();return Jw.some(a=>e.endsWith(a))},Yw=t=>t==="ngrok"?"ngrok":"cloudflared",fm=()=>{if(typeof window<"u"&&typeof window.__OPENCHAMBER_PLATFORM__=="string"){const e=window.__OPENCHAMBER_PLATFORM__;if(e==="win32"||e==="darwin"||e==="linux")return e}const t=typeof navigator<"u"?`${navigator.platform||""} ${navigator.userAgent||""}`.toLowerCase():"";return t.includes("win")?"win32":t.includes("mac")?"darwin":"linux"},Zw=(t,e=fm())=>t==="ngrok"?e==="win32"?"winget install ngrok -s msstore":e==="darwin"?"brew install ngrok":"https://ngrok.com/download":e==="win32"?"winget install --id Cloudflare.cloudflared":e==="darwin"?"brew install cloudflared":"https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/",zr=(t,e)=>{const a=typeof e?.provider=="string"&&e.provider.trim().length>0?e.provider.trim().toLowerCase():t,n=typeof e?.dependency=="string"&&e.dependency.trim().length>0?e.dependency.trim():Yw(a),o=typeof e?.platform=="string"&&e.platform.trim().length>0?e.platform.trim():fm(),i=typeof e?.installCommand=="string"&&e.installCommand.trim().length>0?e.installCommand.trim():Zw(a,o);return{provider:a,dependency:n,installCommand:i}},hm=t=>t==="cloudflare"?"Cloudflare":t==="ngrok"?"Ngrok":t,Pd=t=>{const e=$e.c(11),{provider:a}=t;let n;e[0]!==a?(n=hm(a),e[0]=a,e[1]=n):n=e[1];const o=n,l=a==="cloudflare"||a==="ngrok"?"text-[var(--status-warning)]":"text-muted-foreground";let u;e[2]!==l?(u=Me("size-4 shrink-0",l),e[2]=l,e[3]=u):u=e[3];let m;e[4]!==u?(m=s.jsx(J,{name:"cloud",className:u}),e[4]=u,e[5]=m):m=e[5];let d;e[6]!==o?(d=s.jsx("span",{children:o}),e[6]=o,e[7]=d):d=e[7];let f;return e[8]!==m||e[9]!==d?(f=s.jsxs("span",{className:"flex items-center gap-2",children:[m,d]}),e[8]=m,e[9]=d,e[10]=f):f=e[10],f},Un=t=>t==="quick"?"quick":t==="managed-remote"?"managed-remote":t==="managed-local"?"managed-local":"quick",dl=(t,e,a)=>t.find(o=>o.ms===e)?.value||a,Ad=(t,e,a)=>{const n=dl(t,e,a);return t.find(o=>o.value===n)?.label||n},Td=t=>{const e=Math.max(0,t),a=Math.floor(e/1e3),n=Math.floor(a/3600),o=Math.floor(a%3600/60),i=a%60;return n>0?`${n}h ${o}m`:o>0?`${o}m ${i}s`:`${i}s`},Xw=(t,e)=>Hd(t,e,{hour:"2-digit",precision:"second"}),fo=t=>{const e=t.trim();if(!e)return"";try{return(e.includes("://")?new URL(e):new URL(`https://${e}`)).hostname.trim().toLowerCase()}catch{return e.toLowerCase()}},e2=t=>{if(!Array.isArray(t))return[];const e=new Set,a=new Set,n=[];for(const o of t){if(!o||typeof o!="object")continue;const i=o,r=typeof i.id=="string"?i.id.trim():"",l=typeof i.name=="string"?i.name.trim():"",u=fo(typeof i.hostname=="string"?i.hostname:"");!r||!l||!u||e.has(r)||a.has(u)||(e.add(r),a.add(u),n.push({id:r,name:l,hostname:u}))}return n},t2=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,s2=()=>{const{t}=ze(),e=oe(L=>L.timeFormatPreference),a=c.useCallback(L=>t(L),[t]),[n,o]=c.useState("checking"),[i,r]=c.useState(!1),[l,u]=c.useState(null),[m,d]=c.useState(null),[f,g]=c.useState(null),[p,h]=c.useState(null),[w,b]=c.useState(null),[k,v]=c.useState(!1),[S,y]=c.useState(!1),[N,x]=c.useState(!1),[I,j]=c.useState("cloudflare"),[D,C]=c.useState(()=>zr("cloudflare")),[P,A]=c.useState([]),[R,K]=c.useState("quick"),[F,T]=c.useState(null),[O,E]=c.useState([]),[B,_]=c.useState({}),[H,ne]=c.useState(""),[z,$]=c.useState({}),[V,G]=c.useState(new Set),[ee,ae]=c.useState(!1),[X,Q]=c.useState(""),[le,Z]=c.useState(""),[fe,Y]=c.useState(""),[be,Ee]=c.useState(1800*1e3),[se,re]=c.useState(480*60*1e3),[je,ie]=c.useState(""),[Pe,ke]=c.useState([]),[Ae,Te]=c.useState(()=>Date.now()),[Ke,ge]=c.useState(null),Re=t(Qw),Oe=c.useRef(null),pe=c.useMemo(()=>F?!xi(F):!1,[F]),xe=c.useMemo(()=>O.find(L=>L.id===H)||O[0]||null,[O,H]),Ne=c.useMemo(()=>Pe.map(L=>{const me=L.expiresAt<=Ae,Se=L.status==="active"&&!me,Ce=Se?Td(L.expiresAt-Ae):L.inactiveReason==="expired"||me?"expired":"inactive",We=Ce==="expired"?t("settings.openchamber.tunnel.state.expired"):L.inactiveReason==="tunnel-revoked"?t("settings.openchamber.tunnel.state.revoked"):t("settings.openchamber.tunnel.state.inactive"),ce=Un(L.mode);return{...L,isActive:Se,mode:ce,remainingTextForSession:Ce,inactiveLabel:We}}),[Ae,Pe,t]),de=c.useMemo(()=>l?.connectUrl?l.bootstrapExpiresAt===null?!0:l.bootstrapExpiresAt>Ae:!1,[Ae,l?.bootstrapExpiresAt,l?.connectUrl]),Ue=c.useMemo(()=>!l||n!=="active"&&n!=="stopping"?!1:m===R,[m,n,l,R]),Ie=c.useMemo(()=>!l||n!=="active"||!m?!1:m!==R,[m,n,l,R]),De=c.useMemo(()=>{if(typeof Ke=="number"&&Number.isFinite(Ke)&&Ke>0)return Ke;if(typeof window>"u")return null;const me=Ri()||window.location.href;let Se=0;try{Se=Number(new URL(me).port)}catch{Se=Number(window.location.port)}return Number.isFinite(Se)&&Se>0?Se:null},[Ke]),Je=c.useMemo(()=>P.find(L=>L.provider===I)??null,[P,I]),tt=c.useMemo(()=>{const L=new Set(Je?.modes?.map(me=>me.key).filter(me=>me==="quick"||me==="managed-remote"||me==="managed-local"));return L.size===0?Kr:Kr.filter(me=>L.has(me.value))},[Je]),mt=c.useMemo(()=>tt.some(L=>L.value==="managed-remote"||L.value==="managed-local"),[tt]),ht=c.useMemo(()=>D.provider===I?D:zr(I),[D,I]),ft=c.useCallback(async L=>{await ks(L)},[]),xt=c.useCallback((L,me)=>(C(zr(me,L)),L.available===!0),[]),Qe=c.useCallback(async(L,me)=>{try{const Se=await Rt("/api/openchamber/tunnel/check",{query:{provider:L},...me?{signal:me}:{}});if(!Se.ok)return null;const Ce=await Se.json();if(me?.aborted)return null;const We=xt(Ce,L);return o(ce=>ce==="checking"||ce==="starting"||ce==="active"||ce==="stopping"?ce:We?"idle":"not-available"),We}catch{return null}},[xt]),lt=c.useCallback(async L=>{try{const[me,Se,Ce,We]=await Promise.all([Rt("/api/openchamber/tunnel/check",{signal:L}),Rt("/api/openchamber/tunnel/status",{signal:L}),xn(),Rt("/api/openchamber/tunnel/providers",{signal:L})]),ce=await me.json(),Fe=await Se.json(),ct=Ce??{},Ft=We.ok?await We.json():{},It=Fe.ttlConfig?.bootstrapTtlMs??(ct.tunnelBootstrapTtlMs===void 0?1800*1e3:ct.tunnelBootstrapTtlMs),ls=typeof Fe.ttlConfig?.sessionTtlMs=="number"?Fe.ttlConfig.sessionTtlMs:ct.tunnelSessionTtlMs??480*60*1e3,et=Un(Fe.mode??ct.tunnelMode),st=ct.tunnelProvider??"cloudflare",Ht=ct.managedLocalTunnelConfigPath??null,is=xt(ce,st),us=e2(Fe?.managedRemoteTunnelPresets),Jt=typeof Fe.managedRemoteTunnelHostname=="string"?Fe.managedRemoteTunnelHostname:"",Ss=us.length>0?us:Jt?[{id:`legacy-${fo(Jt)}`,name:Jt,hostname:fo(Jt)}]:[],vn=Ss[0]?.id||"";if(r(Fe.enterpriseMode===!0),Ee(It),re(ls),j(st),A(Array.isArray(Ft?.providers)?Ft.providers:[]),K(et),T(Ht),E(Ss),ne(vn),ke(Array.isArray(Fe.activeSessions)?Fe.activeSessions:[]),d(Fe.activeTunnelMode?Un(Fe.activeTunnelMode):Fe.active&&Fe.mode?Un(Fe.mode):null),G(new Set(Array.isArray(Fe.managedRemoteTunnelTokenPresetIds)?Fe.managedRemoteTunnelTokenPresetIds:[])),ge(typeof Fe.localPort=="number"?Fe.localPort:null),Fe.active&&Fe.url){u({url:Fe.url,connectUrl:null,bootstrapExpiresAt:typeof Fe.bootstrapExpiresAt=="number"?Fe.bootstrapExpiresAt:null}),o("active");return}o(is?"idle":"not-available")}catch{L.aborted||(o("error"),h(t("settings.openchamber.tunnel.toast.checkAvailabilityFailed")))}},[xt,t]);c.useEffect(()=>{const L=new AbortController;return lt(L.signal),()=>L.abort()},[lt]),c.useEffect(()=>{if(!l?.connectUrl){g(null);return}let L=!1;return gu.toDataURL(l.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(me=>{L||g(me)}).catch(()=>{L||g(null)}),()=>{L=!0}},[l?.connectUrl]),c.useEffect(()=>{if(!l?.bootstrapExpiresAt){ie(t("settings.openchamber.tunnel.state.noExpiry"));return}let L=null,me=Date.now();const Se=()=>{const ce=l.bootstrapExpiresAt?l.bootstrapExpiresAt-Date.now():0;ce<=0?ie(t("settings.openchamber.tunnel.state.expired")):ie(Td(ce))},Ce=()=>{const ce=Date.now();ce-me>=1e3&&(Se(),me=ce),L=requestAnimationFrame(Ce)};Se(),(typeof document>"u"||document.visibilityState==="visible")&&(L=requestAnimationFrame(Ce));const We=()=>{document.visibilityState==="visible"&&L===null?L=requestAnimationFrame(Ce):document.visibilityState!=="visible"&&L!==null&&(cancelAnimationFrame(L),L=null)};return document.addEventListener("visibilitychange",We),()=>{document.removeEventListener("visibilitychange",We),L!==null&&cancelAnimationFrame(L)}},[t,l?.bootstrapExpiresAt]),c.useEffect(()=>{let L=null,me=Date.now();const Se=()=>{const We=Date.now();We-me>=1e3&&(Te(We),me=We),L=requestAnimationFrame(Se)};(typeof document>"u"||document.visibilityState==="visible")&&(L=requestAnimationFrame(Se));const Ce=()=>{document.visibilityState==="visible"&&L===null?L=requestAnimationFrame(Se):document.visibilityState!=="visible"&&L!==null&&(cancelAnimationFrame(L),L=null)};return document.addEventListener("visibilitychange",Ce),()=>{document.removeEventListener("visibilitychange",Ce),L!==null&&cancelAnimationFrame(L)}},[]),c.useEffect(()=>{if(n==="starting"||n==="stopping"||n==="checking")return;let L=!1;const me=async()=>{try{const Ce=await Rt("/api/openchamber/tunnel/status");if(!Ce.ok||L)return;const We=await Ce.json();if(L)return;ke(Array.isArray(We.activeSessions)?We.activeSessions:[]),G(new Set(Array.isArray(We.managedRemoteTunnelTokenPresetIds)?We.managedRemoteTunnelTokenPresetIds:[])),ge(typeof We.localPort=="number"?We.localPort:null)}catch{}},Se=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||me()},5e3);return()=>{L=!0,window.clearInterval(Se)}},[n]);const Ye=c.useCallback(async L=>{x(!0);try{await yt(L),Object.prototype.hasOwnProperty.call(L,"tunnelMode")&&L.tunnelMode&&K(L.tunnelMode),Object.prototype.hasOwnProperty.call(L,"tunnelProvider")&&typeof L.tunnelProvider=="string"&&j(L.tunnelProvider),Object.prototype.hasOwnProperty.call(L,"managedLocalTunnelConfigPath")&&T(L.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(L,"managedRemoteTunnelPresets")&&L.managedRemoteTunnelPresets&&E(L.managedRemoteTunnelPresets)}catch{W.error(t("settings.openchamber.tunnel.toast.saveSettingsFailed"))}finally{x(!1)}},[t]),at=c.useCallback(async(L,me)=>{y(!0);try{await yt({tunnelBootstrapTtlMs:L,tunnelSessionTtlMs:me})}catch{W.error(t("settings.openchamber.tunnel.toast.saveTtlFailed"))}finally{y(!1)}},[t]),dt=c.useCallback(async L=>{const me=L.token.trim();if(me)try{const Se={...z,[L.presetId]:me};await yt({managedRemoteTunnelPresetTokens:Se}),G(Ce=>{const We=new Set(Ce);return We.add(L.presetId),We})}catch{W.error(t("settings.openchamber.tunnel.toast.saveTokenFailed"))}},[z,t]),_e=c.useCallback(async L=>{b(null),h(null);const me=P.find(Ce=>Ce.provider===L),Se=me?.modes?.some(Ce=>Ce.key===R)?R:Un(me?.modes?.[0]?.key);await Ye({tunnelProvider:L,tunnelMode:Se}),Qe(L)},[P,Qe,Ye,R]),nt=c.useCallback(async()=>{const L=await Nl({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(L.success&&typeof L.path=="string"&&L.path.trim().length>0){const me=L.path.trim();if(!xi(me)){W.error(Re);return}T(me),await Ye({managedLocalTunnelConfigPath:me});return}Oe.current?.click()},[Re,Ye]),te=c.useCallback(L=>{const me=L.trim();T(me.length>0?me:null)},[]),ue=c.useCallback(async()=>{if(F&&!xi(F)){W.error(Re);return}await Ye({managedLocalTunnelConfigPath:F})},[Re,F,Ye]),he=c.useCallback(async()=>{T(null),await Ye({managedLocalTunnelConfigPath:null})},[Ye]),ye=c.useCallback(async L=>{const me=L.target.files?.[0];if(!me)return;const Se=me.name.trim();if(Se.length!==0){if(!xi(Se)){W.error(Re);return}T(Se),await Ye({managedLocalTunnelConfigPath:Se}),L.target.value=""}},[Re,Ye]),qe=c.useCallback(async()=>{if(h(null),b(null),R==="managed-local"&&F&&!xi(F)){h(Re),W.error(Re);return}o("starting");try{let L="",me="";if(R==="managed-remote"){if(!xe){o("idle"),b(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst")),W.error(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst"));return}L=xe.hostname,me=(z[xe.id]||"").trim(),await Ye({tunnelMode:"managed-remote",managedRemoteTunnelPresets:O})}const Se=await Rt("/api/openchamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:I,mode:R,...R==="managed-remote"&&xe?{managedRemoteTunnelPresetId:xe.id,managedRemoteTunnelPresetName:xe.name}:{},...R==="managed-remote"&&L?{managedRemoteTunnelHostname:L}:{},...R==="managed-remote"&&me?{managedRemoteTunnelToken:me}:{},...R==="managed-local"&&F?{configPath:F}:{}})}),Ce=await Se.json();if(!Se.ok||!Ce.ok){if(R==="managed-remote"&&typeof Ce.error=="string"&&Ce.error.includes("Managed remote tunnel token is required")){o("idle"),b(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequiredBeforeStarting")),W.error(t("settings.openchamber.tunnel.toast.addManagedRemoteTokenBeforeStarting"));return}o("error"),h(Ce.error||t("settings.openchamber.tunnel.toast.startFailed")),W.error(Ce.error||t("settings.openchamber.tunnel.toast.startFailed"));return}const We=typeof Ce.url=="string"?Ce.url:"";if(!We){o("error"),h(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl")),W.error(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl"));return}if(u({url:We,connectUrl:typeof Ce.connectUrl=="string"?Ce.connectUrl:null,bootstrapExpiresAt:typeof Ce.bootstrapExpiresAt=="number"?Ce.bootstrapExpiresAt:null}),d(Ce.activeTunnelMode?Un(Ce.activeTunnelMode):Ce.mode?Un(Ce.mode):R),ke(Array.isArray(Ce.activeSessions)?Ce.activeSessions:[]),Array.isArray(Ce.managedRemoteTunnelTokenPresetIds)&&G(new Set(Ce.managedRemoteTunnelTokenPresetIds)),typeof Ce.localPort=="number"&&ge(Ce.localPort),typeof Ce.mode=="string"&&K(Un(Ce.mode)),o("active"),Ce.replacedTunnel){const ce=typeof Ce.revokedBootstrapCount=="number"?Ce.revokedBootstrapCount:0,Fe=typeof Ce.invalidatedSessionCount=="number"?Ce.invalidatedSessionCount:0;ce===1&&Fe===1?W.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleSingle")):ce===1?W.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleManySessions",{invalidatedSessionCount:Fe})):Fe===1?W.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyLinksSingleSession",{revokedBootstrapCount:ce})):W.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyMany",{revokedBootstrapCount:ce,invalidatedSessionCount:Fe}))}else W.success(t("settings.openchamber.tunnel.toast.linkReady"))}catch{o("error"),h(t("settings.openchamber.tunnel.toast.startFailed")),W.error(t("settings.openchamber.tunnel.toast.startFailed"))}},[Re,O,Ye,xe,z,t,I,R,F]),Ze=c.useCallback(async()=>{o("stopping");try{await Rt("/api/openchamber/tunnel/stop",{method:"POST"});const L=await Rt("/api/openchamber/tunnel/status");if(L.ok){const me=await L.json();ke(Array.isArray(me.activeSessions)?me.activeSessions:[]),G(new Set(Array.isArray(me.managedRemoteTunnelTokenPresetIds)?me.managedRemoteTunnelTokenPresetIds:[])),ge(typeof me.localPort=="number"?me.localPort:null)}u(null),d(null),g(null),o("idle"),W.success(t("settings.openchamber.tunnel.toast.stopped"))}catch{o("error"),h(t("settings.openchamber.tunnel.toast.stopFailed")),W.error(t("settings.openchamber.tunnel.toast.stopFailed"))}},[t]),pt=c.useCallback(async()=>{if(l?.connectUrl)try{await navigator.clipboard.writeText(l.connectUrl),v(!0),W.success(t("settings.openchamber.tunnel.toast.connectLinkCopied")),setTimeout(()=>v(!1),2e3)}catch{W.error(t("settings.openchamber.tunnel.toast.copyUrlFailed"))}},[t,l?.connectUrl]),vt=c.useCallback(async L=>{const me=ro.find(Se=>Se.value===L);me&&(Ee(me.ms),await at(me.ms,se))},[at,se]),bt=c.useCallback(async L=>{const me=lo.find(Se=>Se.value===L);!me||me.ms===null||(re(me.ms),await at(be,me.ms))},[be,at]),wt=c.useCallback(async L=>{b(null),h(null),n!=="active"&&n!=="stopping"&&n!=="starting"&&o("idle"),await Ye({tunnelMode:L,managedRemoteTunnelPresets:O})},[O,Ye,n]),Et=c.useCallback(async(L,me)=>{try{await yt({managedRemoteTunnelPresets:me})}catch{W.error(t("settings.openchamber.tunnel.toast.saveSelectedManagedRemoteFailed"))}},[t]),Le=c.useCallback(L=>{const me=O.find(Se=>Se.id===L);me&&(ne(me.id),b(null),Et(me,O))},[O,Et]),Xe=c.useCallback(async()=>{const L=X.trim(),me=fo(le),Se=fe.trim();if(!L){W.error(t("settings.openchamber.tunnel.toast.tunnelNameRequired"));return}if(!me){W.error(t("settings.openchamber.tunnel.toast.managedRemoteHostnameRequired"));return}if(!Se){W.error(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequired"));return}if(O.some(ce=>ce.hostname===me)){W.error(t("settings.openchamber.tunnel.toast.hostnameAlreadyExists"));return}const Ce={id:t2(),name:L,hostname:me},We=[...O,Ce];E(We),ne(Ce.id),_(ce=>({...ce,[Ce.id]:!0})),$(ce=>({...ce,[Ce.id]:Se})),b(null),ae(!1),Q(""),Z(""),Y(""),await Ye({tunnelMode:"managed-remote",managedRemoteTunnelPresets:We,managedRemoteTunnelPresetTokens:{...z,[Ce.id]:Se}}),await dt({presetId:Ce.id,presetName:Ce.name,hostname:Ce.hostname,token:Se}),W.success(t("settings.openchamber.tunnel.toast.managedRemoteSaved"))},[O,le,X,fe,dt,Ye,z,t]),gt=c.useCallback(async L=>{const me=O.find(Fe=>Fe.id===L);if(!me)return;const Se=O.filter(Fe=>Fe.id!==me.id),Ce=Se[0]?.id||"",We=H===me.id?Ce:H,ce=Object.fromEntries(Object.entries(z).filter(([Fe,ct])=>Fe!==me.id&&ct.trim().length>0));E(Se),ne(We),_(Fe=>{const ct={...Fe};return delete ct[me.id],ct}),$(Fe=>{const ct={...Fe};return delete ct[me.id],ct}),G(Fe=>{const ct=new Set(Fe);return ct.delete(me.id),ct}),b(null),await Ye({managedRemoteTunnelPresets:Se,managedRemoteTunnelPresetTokens:ce}),W.success(t("settings.openchamber.tunnel.toast.managedRemoteRemoved"))},[O,Ye,H,z,t]),jt="gap-2 border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:bg-[var(--primary-hover)] hover:text-[var(--primary-foreground)]";return n==="checking"?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":t("settings.openchamber.tunnel.state.loading")})}):i?s.jsx(He,{title:t("settings.openchamber.tunnel.title"),divider:!1,children:s.jsx("p",{className:Cn,children:t("settings.openchamber.tunnel.enterpriseMode")})}):s.jsx(He,{title:t("settings.openchamber.tunnel.title"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.openchamber.tunnel.description")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.serverSideEnforced")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.connectLinksOneTime")})]}),divider:!1,children:s.jsxs("div",{className:"space-y-6",children:[Ne.length>0&&s.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:s.jsxs("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)]/30 p-3",children:[s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[s.jsx(J,{name:"information",className:"size-4 text-[var(--status-info)]"}),s.jsx("p",{className:Vr,children:t("settings.openchamber.tunnel.section.redeemedAccessLinks")})]}),s.jsx("div",{className:"space-y-1",children:Ne.map(L=>{const me=L.mode==="quick",Se=L.mode==="managed-remote",Ce=me?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":Se?"border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)]":"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",We=L.isActive?me?"text-[var(--status-warning)]":Se?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",ce=t(me?"settings.openchamber.tunnel.badge.quick":Se?"settings.openchamber.tunnel.badge.remote":"settings.openchamber.tunnel.badge.local");return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 rounded border border-[var(--surface-subtle)] bg-[var(--surface-elevated)] px-2 py-1.5",children:[s.jsx(J,{name:"checkbox-blank-circle-fill",className:Me("size-2.5 shrink-0",We)}),s.jsx("span",{className:Me("typography-micro rounded border px-1.5 py-0.5 uppercase",Ce),children:ce}),s.jsx("span",{className:"typography-meta text-muted-foreground/80",children:t("settings.openchamber.tunnel.session.redeemedAt",{time:Xw(L.createdAt,e)})}),s.jsx("span",{className:"typography-meta text-foreground",children:L.isActive?t("settings.openchamber.tunnel.session.expiresIn",{remaining:L.remainingTextForSession}):L.inactiveLabel===t("settings.openchamber.tunnel.state.inactive")?t("settings.openchamber.tunnel.state.inactive"):t("settings.openchamber.tunnel.session.inactiveWithReason",{reason:L.inactiveLabel})})]},L.sessionId)})})]})}),n==="not-available"&&s.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:s.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-[var(--status-warning)]/30 bg-[var(--status-warning)]/5 p-3",children:[s.jsx(J,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:Vr,children:t("settings.openchamber.tunnel.notAvailable.dependencyNotFound",{dependency:ht.dependency})}),s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t("settings.openchamber.tunnel.notAvailable.installHint")}),s.jsx("code",{className:"typography-code block rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:ht.installCommand})]})]})}),s.jsxs("section",{className:"space-y-4 px-2 pb-2 pt-0",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{"data-settings-item":"tunnel.provider",className:"space-y-1.5",children:[s.jsx("p",{className:Ct,children:t("settings.openchamber.tunnel.field.provider")}),s.jsxs(Tt,{value:I,onValueChange:L=>{_e(L)},disabled:N||n==="starting"||n==="stopping",children:[s.jsx(Pt,{className:"max-w-[16rem]",children:s.jsx(Ut,{placeholder:t("settings.openchamber.tunnel.field.providerPlaceholder"),children:hm(I)})}),s.jsxs(At,{children:[P.length>0?P.map(L=>s.jsx(ot,{value:L.provider,children:s.jsx(Pd,{provider:L.provider})},L.provider)):s.jsx(ot,{value:"cloudflare",children:s.jsx(Pd,{provider:"cloudflare"})}),s.jsx(ot,{value:"__more-soon",disabled:!0,children:t("settings.openchamber.tunnel.option.moreProvidersSoon")})]})]})]}),s.jsxs("div",{"data-settings-item":"tunnel.type",className:"space-y-1.5",children:[s.jsx("p",{className:Ct,children:t("settings.openchamber.tunnel.field.tunnelType")}),s.jsx("div",{className:"flex flex-wrap items-center gap-1",children:tt.map(L=>s.jsxs(eu,{children:[s.jsx(tu,{asChild:!0,children:s.jsx(q,{variant:"chip",size:"xs","aria-pressed":R===L.value,className:"!font-normal",onClick:()=>{wt(L.value)},disabled:N||n==="starting"||n==="stopping",children:a(L.labelKey)})}),s.jsx(ug,{sideOffset:8,className:"max-w-xs",children:a(L.tooltipKey)})]},L.value))})]})]}),s.jsxs("div",{"data-settings-item":"tunnel.ttl",className:"mt-2 grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Me(Ct,"shrink-0"),children:t("settings.openchamber.tunnel.field.connectLinkTtl")}),s.jsxs(Tt,{value:dl(ro,be,"1800000"),onValueChange:L=>{vt(L)},disabled:S||N||n==="starting"||n==="stopping",children:[s.jsx(Pt,{className:"max-w-[11rem] min-w-0",children:s.jsx(Ut,{className:"truncate",children:Ad(ro,be,"1800000")})}),s.jsx(At,{children:ro.map(L=>s.jsx(ot,{value:L.value,children:L.label},L.value))})]})]}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Me(Ct,"shrink-0"),children:t("settings.openchamber.tunnel.field.tunnelSessionTtl")}),s.jsxs(Tt,{value:dl(lo,se,"28800000"),onValueChange:L=>{bt(L)},disabled:S||N||n==="starting"||n==="stopping",children:[s.jsx(Pt,{className:"max-w-[11rem] min-w-0",children:s.jsx(Ut,{className:"truncate",children:Ad(lo,se,"28800000")})}),s.jsx(At,{children:lo.map(L=>s.jsx(ot,{value:L.value,children:L.label},L.value))})]})]})]}),R==="quick"&&s.jsx("div",{className:"rounded-lg border border-[var(--status-warning)]/35 bg-[var(--status-warning)]/10 p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(J,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.option.mode.quick.tooltip")}),mt&&s.jsx("p",{className:"typography-meta mt-1 text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.quickModeReliability")})]})]})}),R==="managed-remote"&&s.jsxs("div",{"data-settings-item":"tunnel.managed-remote",className:"space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[typeof De=="number"&&s.jsx("div",{className:"rounded-md border border-[var(--status-info-border)] bg-[var(--status-info-background)]/35 px-2 py-1.5",children:s.jsxs("p",{className:"typography-meta text-[var(--status-info)]",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTarget")," ",s.jsxs("code",{children:["http://localhost:",De]})]})}),s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[s.jsx(Dn,{children:t("settings.openchamber.tunnel.section.savedManagedRemoteTunnels")}),s.jsxs(q,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ae(L=>!L),disabled:n==="starting"||n==="stopping"||N,children:[s.jsx(J,{name:"add",className:"h-3.5 w-3.5"}),t("settings.common.actions.create")]})]}),O.length>0?s.jsx("div",{className:"overflow-hidden rounded-md border border-[var(--surface-subtle)]",children:O.map((L,me)=>{const Se=z[L.id]||"",Ce=V.has(L.id),We=B[L.id]??!1;return s.jsx("div",{className:Me(me<O.length-1&&"border-b border-[var(--surface-subtle)]"),children:s.jsxs(Js,{open:We,onOpenChange:ce=>{_(Fe=>({...Fe,[L.id]:ce})),ce&&Le(L.id)},className:"py-1.5",children:[s.jsxs("div",{className:"flex items-start gap-2 px-3",children:[s.jsxs(Qs,{type:"button",className:"group flex-1 justify-start gap-2 rounded-md px-0 py-1 pe-1 text-start hover:bg-[var(--interactive-hover)]",disabled:n==="starting"||n==="stopping"||N,children:[We?s.jsx(J,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(J,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label min-w-0 flex-1 truncate text-foreground",children:L.name})]}),s.jsx(q,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-[var(--status-error)]","aria-label":t("settings.openchamber.tunnel.actions.removePresetAria",{name:L.name}),onClick:()=>{gt(L.id)},disabled:n==="starting"||n==="stopping"||N,children:s.jsx(J,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),s.jsx(Ys,{className:"pt-1.5",children:s.jsxs("div",{className:"space-y-1 px-3 pb-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.field.hostnameLabel")," ",s.jsx("code",{children:L.hostname})]}),s.jsx(Ve,{type:"password",value:Se,onChange:ce=>{const Fe=ce.target.value;b(null),$(ct=>({...ct,[L.id]:Fe}))},onBlur:ce=>{const Fe=ce.currentTarget.value.trim();Fe&&dt({presetId:L.id,presetName:L.name,hostname:L.hostname,token:Fe})},placeholder:t(Ce?"settings.openchamber.tunnel.field.savedTokenAvailablePlaceholder":"settings.openchamber.tunnel.field.pasteTokenPlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal",disabled:n==="starting"||n==="stopping"||Se.trim().length===0,onClick:()=>{dt({presetId:L.id,presetName:L.name,hostname:L.hostname,token:Se})},children:t("settings.openchamber.tunnel.actions.saveToken")})})]})})]})},L.id)})}):s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t("settings.openchamber.tunnel.empty.noManagedRemoteTunnels")}),ee&&s.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--surface-subtle)] p-2",children:[s.jsx(Ve,{value:X,onChange:L=>Q(L.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetNamePlaceholder"),className:"h-7",disabled:N||n==="starting"||n==="stopping"}),s.jsx(Ve,{value:le,onChange:L=>Z(L.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetHostnamePlaceholder"),className:"h-7",disabled:N||n==="starting"||n==="stopping"}),s.jsx(Ve,{type:"password",value:fe,onChange:L=>Y(L.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetTokenPlaceholder"),className:"h-7",disabled:N||n==="starting"||n==="stopping"}),typeof De=="number"&&s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTargetUse")," ",s.jsxs("code",{children:["http://localhost:",De]}),"."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Xe()},disabled:N||n==="starting"||n==="stopping",children:t("settings.common.actions.saveChanges")}),s.jsx(q,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ae(!1),Q(""),Z(""),Y("")},disabled:N||n==="starting"||n==="stopping",children:t("settings.common.actions.cancel")})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("settings.openchamber.tunnel.note.tokensSavedPerTunnel")}),s.jsx(qt,{children:t("settings.openchamber.tunnel.tooltip.tokensSavedPath")})]}),!xe&&w&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:w})]}),R==="managed-local"&&s.jsx("div",{"data-settings-item":"tunnel.managed-local-config",className:"space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:Ct,children:t("settings.openchamber.tunnel.field.configurationFile")}),s.jsx("input",{ref:Oe,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:L=>{ye(L)}}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ve,{value:F||"",onChange:L=>{te(L.target.value)},onBlur:()=>{ue()},placeholder:t("settings.openchamber.tunnel.field.configurationFilePlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"||N}),s.jsx(q,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.browseConfigFileAria"),onClick:()=>{nt()},disabled:n==="starting"||n==="stopping"||N,children:s.jsx(J,{name:"folder",className:"size-3.5"})}),F&&s.jsx(q,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.clearConfigFileAria"),onClick:()=>{he()},disabled:n==="starting"||n==="stopping"||N,children:s.jsx(J,{name:"close",className:"size-3.5"})})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t(F?"settings.openchamber.tunnel.note.customConfigUsed":"settings.openchamber.tunnel.note.defaultConfigUsed")}),pe&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Re})]})}),!Ue&&s.jsxs("div",{"data-settings-item":"tunnel.start",className:"space-y-6",children:[s.jsx("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)] p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(J,{name:"information",className:"mt-0.5 size-4 shrink-0 text-[var(--status-info)]"}),s.jsxs("div",{className:"space-y-1",children:[R==="managed-remote"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.managedRemoteRequiresDomain")}),s.jsxs("button",{type:"button",className:"typography-meta inline-flex items-center gap-1 text-[var(--status-info)] underline underline-offset-2 hover:opacity-90",onClick:()=>{ft(Ww)},children:[t("settings.openchamber.tunnel.actions.openManagedRemoteDocs"),s.jsx(J,{name:"external-link",className:"size-3.5"})]})]}),R==="managed-local"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.managedLocalUsesConfig")}),s.jsxs("button",{type:"button",className:"typography-meta inline-flex items-center gap-1 text-[var(--status-info)] underline underline-offset-2 hover:opacity-90",onClick:()=>{ft(Gw)},children:[t("settings.openchamber.tunnel.actions.openManagedLocalDocs"),s.jsx(J,{name:"external-link",className:"size-3.5"})]})]}),s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.startModeAndGenerateLink",{mode:a(Kr.find(L=>L.value===R)?.labelKey??"settings.openchamber.tunnel.option.mode.quick.label")})})]})]})}),R==="managed-remote"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:Ct,children:t("settings.openchamber.tunnel.field.managedRemoteTunnelToConnect")}),s.jsxs(Tt,{value:H||(O[0]?.id??""),onValueChange:L=>{Le(L)},disabled:N||n==="starting"||n==="stopping"||O.length<=1,children:[s.jsx(Pt,{children:s.jsx(Ut,{placeholder:t("settings.openchamber.tunnel.field.selectSavedTunnelPlaceholder"),children:xe?.name})}),s.jsx(At,{fitContent:!0,children:O.map(L=>s.jsx(ot,{value:L.id,children:L.name},L.id))})]})]}),Ie&&s.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(J,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.replacesActiveTunnel")})]})}),s.jsx(q,{size:"sm",variant:"outline",onClick:qe,disabled:n==="starting"||N||R==="managed-remote"&&!xe||R==="managed-local"&&pe,className:Me(jt,n==="starting"&&"opacity-70"),children:n==="starting"?s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.startingTunnel")]}):t("settings.openchamber.tunnel.actions.startTunnel")})]})]}),Ue&&l&&s.jsxs("section",{"data-settings-item":"tunnel.start",className:"space-y-4 px-2 pb-2 pt-0",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--status-success)]"}),s.jsx("p",{className:"typography-meta font-medium text-foreground",children:t("settings.openchamber.tunnel.state.tunnelReady")})]}),s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:t("settings.openchamber.tunnel.field.publicUrlHint")}),s.jsx("code",{className:"typography-code block truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:l.url})]}),de&&l.connectUrl&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:t("settings.openchamber.tunnel.field.connectLink")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"typography-code flex-1 truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:l.connectUrl}),s.jsxs(q,{size:"sm",variant:"ghost",onClick:pt,className:"shrink-0 gap-1.5",children:[k?s.jsx(J,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):s.jsx(J,{name:"file-copy",className:"size-3.5"}),t(k?"settings.openchamber.tunnel.actions.copied":"settings.common.actions.copyAll")]})]}),s.jsxs("p",{className:"typography-meta mt-1 text-muted-foreground/70",children:[t("settings.openchamber.tunnel.field.expires"),": ",l.bootstrapExpiresAt?je:t("settings.openchamber.tunnel.state.never")]})]}),s.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border/50 bg-[var(--surface-elevated)] p-4",children:[f?s.jsx("img",{src:f,alt:t("settings.openchamber.tunnel.field.connectQrAlt"),className:"size-48"}):s.jsx("div",{className:"size-48 rounded bg-muted/30"}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.tunnel.note.scanQrToConnect")})]})]})]}),s.jsx("div",{className:"pt-1",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(q,{size:"sm",variant:"outline",onClick:qe,disabled:n==="stopping"||N||R==="managed-local"&&pe,className:jt,children:[s.jsx(J,{name:"restart",className:"size-3.5"}),t("settings.openchamber.tunnel.actions.newConnectLink")]}),s.jsx(q,{size:"sm",variant:"ghost",onClick:Ze,disabled:n==="stopping"||N,className:"gap-2 text-[var(--status-error)]",children:n==="stopping"?s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.stopping")]}):t("settings.openchamber.tunnel.actions.stopTunnel")})]})})]}),n==="error"&&p&&s.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:p}),s.jsx(q,{size:"sm",variant:"ghost",onClick:qe,children:t("settings.openchamber.tunnel.actions.retry")})]})]})})},bm=()=>{const{t}=ze(),e=Ai(h=>h.opencodeBinary),[a,n]=Be.useState(""),[o,i]=Be.useState(!0),[r,l]=Be.useState(!1),u=oe(h=>h.showOpenCodeUpdateNotifications),m=oe(h=>h.setShowOpenCodeUpdateNotifications);Be.useEffect(()=>{let h=!1;return(async()=>{try{const w=await xn();if(h||!w)return;n(w.opencodeBinary??"")}catch{}finally{h||i(!1)}})(),()=>{h=!0}},[]);const d=Be.useCallback(async()=>{if(!(typeof window>"u")&&as())try{const h=await Nl();h.success&&h.path&&h.path.trim().length>0&&n(h.path.trim())}catch{}},[]),f=Be.useCallback(async()=>{l(!0);try{const h=a.trim(),w=h.length>=2&&(h.startsWith('"')&&h.endsWith('"')||h.startsWith("'")&&h.endsWith("'"))?h.slice(1,-1).trim():h;await yt({opencodeBinary:w}),await Ld({message:t("settings.openchamber.opencodeCli.actions.restartingOpenCode"),mode:"projects",scopes:["all"]})}catch(h){if(h?.requiresManualRestart){W.warning(t("settings.openchamber.opencodeCli.restart.manualRequired"));return}W.error(t("settings.openchamber.opencodeCli.restart.failed"))}finally{l(!1)}},[t,a]),g=Be.useCallback(async()=>{l(!0);try{await fu(t)}finally{l(!1)}},[t]),p=Be.useCallback(h=>{m(h),yt({showOpenCodeUpdateNotifications:h})},[m]);return s.jsx(He,{title:t("settings.openchamber.opencodeCli.title"),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs(kt,{settingsItem:"sessions.opencode-binary",label:t("settings.openchamber.opencodeCli.field.binaryPath"),info:s.jsxs(s.Fragment,{children:[t("settings.openchamber.opencodeCli.tipPrefix")," ",s.jsx("span",{className:"font-mono",children:"OPENCODE_BINARY"})," ",t("settings.openchamber.opencodeCli.tipMiddle")," ",s.jsx("span",{className:"font-mono",children:"~/.config/openchamber/settings.json"}),"."]}),description:e?t("settings.openchamber.opencodeCli.field.pinnedByAdministrator"):void 0,alignEnd:!1,controlClassName:"@xl:w-[20rem]",children:[s.jsx(Ve,{value:e??a,onChange:h=>n(h.target.value),placeholder:t("settings.openchamber.opencodeCli.field.binaryPathPlaceholder"),disabled:o||r||e!==null,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),s.jsx(q,{type:"button",variant:"outline",size:"xs",onClick:d,disabled:o||r||!as()||e!==null,className:os,"aria-label":t("settings.openchamber.opencodeCli.actions.browseAria"),title:t("settings.openchamber.opencodeCli.actions.browse"),children:s.jsx(J,{name:"folder",className:"h-4 w-4"})})]}),s.jsxs(da,{className:bs,children:[s.jsx(it,{settingsItem:"sessions.opencode-update-notifications",checked:u,onChange:p,label:t("settings.openchamber.opencodeCli.field.showUpdateNotifications"),ariaLabel:t("settings.openchamber.opencodeCli.field.showUpdateNotificationsAria")}),s.jsxs("div",{className:"flex flex-wrap justify-start gap-2 py-1.5","data-settings-item":"sessions.opencode-restart",children:[s.jsx(q,{type:"button",size:"xs",onClick:f,disabled:o||r||e!==null,className:"shrink-0 !font-normal",children:t(r?"settings.openchamber.opencodeCli.actions.restartingOpenCode":"settings.openchamber.opencodeCli.actions.saveAndReload")}),s.jsx(q,{type:"button",variant:"outline",size:"xs",onClick:g,disabled:o||r,className:"shrink-0 !font-normal",children:t("settings.openchamber.opencodeCli.actions.restart")})]})]})]})})},xm=()=>{const{t}=ze(),e=Ln(),[a,n]=c.useState({state:"loading"}),[o,i]=c.useState(!1),[r,l]=c.useState(!1);c.useEffect(()=>{let d=!1;return bf().then(f=>{d||n({state:"ready",names:f.names})}).catch(()=>{d||n({state:"failed"})}),()=>{d=!0}},[]);const u=c.useCallback(async d=>{es("saving");try{const f=await xf(d);return n({state:"ready",names:f.names}),i(!0),es("saved"),!0}catch{return es("error"),W.error(t("settings.environment.editor.saveFailed")),!1}},[t]),m=c.useCallback(async()=>{l(!0);try{await fu(t),i(!1)}finally{l(!1)}},[t]);return s.jsx(He,{title:t("settings.environment.user.title"),info:t("settings.environment.user.info"),settingsItem:"general.environment-variables",children:s.jsxs("div",{className:"space-y-3",children:[e?s.jsx("p",{className:Dt,children:t("settings.environment.user.enterpriseNote")}):null,a.state==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:t("settings.environment.editor.loadFailed")}):s.jsx(vf,{names:a.state==="ready"?a.names:[],disabled:a.state!=="ready",onSet:(d,f)=>u({[d]:f}),onRemove:d=>u({[d]:null})}),o&&!e?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:Dt,children:t("settings.environment.user.restartNote")}),s.jsx(q,{type:"button",variant:"outline",size:"xs",onClick:()=>{m()},disabled:r,className:"shrink-0 !font-normal",children:t(r?"settings.openchamber.opencodeCli.actions.restartingOpenCode":"settings.openchamber.opencodeCli.actions.restart")})]}):null]})})},Ur="builtin",n2=t=>t.filter(e=>yl(e)&&Yd(e.service,"browser")),Ed="ps-[3.75rem]",Ka=t=>{const e=$e.c(23),{icon:a,title:n,summary:o,info:i,ariaLabel:r,checked:l,onChange:u,settingsItem:m}=t;let d;e[0]!==a?(d=s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-foreground",children:s.jsx(J,{name:a,className:"size-4"})}),e[0]=a,e[1]=d):d=e[1];let f;e[2]!==n?(f=s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:n}),e[2]=n,e[3]=f):f=e[3];let g;e[4]!==i?(g=s.jsx(qt,{children:i}),e[4]=i,e[5]=g):g=e[5];let p;e[6]!==f||e[7]!==g?(p=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[f,g]}),e[6]=f,e[7]=g,e[8]=p):p=e[8];let h;e[9]!==o?(h=s.jsx("p",{className:"typography-meta text-muted-foreground",children:o}),e[9]=o,e[10]=h):h=e[10];let w;e[11]!==p||e[12]!==h?(w=s.jsxs("div",{className:"min-w-0 flex-1",children:[p,h]}),e[11]=p,e[12]=h,e[13]=w):w=e[13];let b;e[14]!==r||e[15]!==l||e[16]!==u?(b=s.jsx(ra,{checked:l,onCheckedChange:u,"aria-label":r}),e[14]=r,e[15]=l,e[16]=u,e[17]=b):b=e[17];let k;return e[18]!==m||e[19]!==d||e[20]!==w||e[21]!==b?(k=s.jsxs("div",{"data-settings-item":m,className:"flex items-center gap-3 px-4 py-3",children:[d,w,b]}),e[18]=m,e[19]=d,e[20]=w,e[21]=b,e[22]=k):k=e[22],k},vm=()=>{const t=$e.c(176),{t:e}=ze(),a=oe(a2),n=oe(i2),o=oe(o2),i=oe(r2),r=oe(l2),l=oe(c2),u=vs(d2),m=oe(u2),d=oe(m2),f=oe(p2),g=oe(g2),p=oe(f2),h=oe(h2),w=oe(b2),b=oe(x2),k=oe(v2),v=oe(y2),S=oe(j2),y=oe(k2),N=oe(w2);let x;t[0]!==n?(x=Le=>{n(Le),yt({agentControlToolEnabled:Le})},t[0]=n,t[1]=x):x=t[1];const I=x;let j;t[2]!==N?(j=Le=>{N(Le),yt({agentWorktreeMoveWithoutAsking:Le})},t[2]=N,t[3]=j):j=t[3];const D=j;let C;t[4]!==i?(C=Le=>{i(Le),yt({agentWebToolEnabled:Le})},t[4]=i,t[5]=C):C=t[5];const P=C;let A;t[6]!==w?(A=Le=>{w(Le),yt({agentNotifyToolEnabled:Le})},t[6]=w,t[7]=A):A=t[7];const R=A;let K;t[8]!==k?(K=Le=>{k(Le),yt({agentRenderToolEnabled:Le})},t[8]=k,t[9]=K):K=t[9];const F=K;let T;t[10]!==p?(T=Le=>{p(Le),yt({agentKnowledgeToolEnabled:Le})},t[10]=p,t[11]=T):T=t[11];const O=T;let E;t[12]!==S?(E=Le=>{S(Le),yt({agentToolsCodeMode:Le})},t[12]=S,t[13]=E):E=t[13];const B=E;let _;t[14]===Symbol.for("react.memo_cache_sentinel")?(_=[],t[14]=_):_=t[14],Be.useEffect(S2,_);let H;t[15]!==u?(H=n2(u),t[15]=u,t[16]=H):H=t[16];const ne=H;let z;t[17]!==r||t[18]!==ne?(z=ne.some(Le=>Le.id===r)?r:Ur,t[17]=r,t[18]=ne,t[19]=z):z=t[19];const $=z;let V;t[20]!==l?(V=Le=>{l(Le),yt({browserProvider:Le})},t[20]=l,t[21]=V):V=t[21];const G=V;let ee;t[22]!==f?(ee=Le=>{f(Le),yt({agentMemoryToolEnabled:Le}).finally(()=>{Le&&mg.getState().refresh()})},t[22]=f,t[23]=ee):ee=t[23];const ae=ee;let X;t[24]!==e?(X=e("settings.openchamber.tools.title"),t[24]=e,t[25]=X):X=t[25];let Q;t[26]!==e?(Q=e("settings.openchamber.tools.field.agentControlTool"),t[26]=e,t[27]=Q):Q=t[27];let le;t[28]!==e?(le=e("settings.openchamber.tools.field.agentControlToolSummary"),t[28]=e,t[29]=le):le=t[29];let Z;t[30]!==e?(Z=e("settings.openchamber.tools.field.agentControlToolInfo"),t[30]=e,t[31]=Z):Z=t[31];let fe;t[32]!==e?(fe=e("settings.openchamber.tools.field.agentControlToolAria"),t[32]=e,t[33]=fe):fe=t[33];let Y;t[34]!==a||t[35]!==I||t[36]!==Q||t[37]!==le||t[38]!==Z||t[39]!==fe?(Y=s.jsx(Ka,{icon:"node-tree",settingsItem:"sessions.agent-control-tool",checked:a,onChange:I,title:Q,summary:le,info:Z,ariaLabel:fe}),t[34]=a,t[35]=I,t[36]=Q,t[37]=le,t[38]=Z,t[39]=fe,t[40]=Y):Y=t[40];let be;t[41]!==a||t[42]!==y||t[43]!==D||t[44]!==e?(be=a?s.jsx("div",{className:Me("pb-3 pe-4",Ed),children:s.jsx(it,{settingsItem:"sessions.agent-worktree-move",checked:y,onChange:D,label:e("settings.openchamber.tools.field.agentWorktreeMove"),ariaLabel:e("settings.openchamber.tools.field.agentWorktreeMoveAria"),info:e("settings.openchamber.tools.field.agentWorktreeMoveInfo")})}):null,t[41]=a,t[42]=y,t[43]=D,t[44]=e,t[45]=be):be=t[45];let Ee;t[46]!==Y||t[47]!==be?(Ee=s.jsxs("div",{children:[Y,be]}),t[46]=Y,t[47]=be,t[48]=Ee):Ee=t[48];let se;t[49]!==e?(se=e("settings.openchamber.tools.field.agentWebTool"),t[49]=e,t[50]=se):se=t[50];let re;t[51]!==e?(re=e("settings.openchamber.tools.field.agentWebToolSummary"),t[51]=e,t[52]=re):re=t[52];let je;t[53]!==e?(je=e("settings.openchamber.tools.field.agentWebToolInfo"),t[53]=e,t[54]=je):je=t[54];let ie;t[55]!==e?(ie=e("settings.openchamber.tools.field.agentWebToolAria"),t[55]=e,t[56]=ie):ie=t[56];let Pe;t[57]!==o||t[58]!==P||t[59]!==se||t[60]!==re||t[61]!==je||t[62]!==ie?(Pe=s.jsx(Ka,{icon:"global",settingsItem:"sessions.agent-web-tool",checked:o,onChange:P,title:se,summary:re,info:je,ariaLabel:ie}),t[57]=o,t[58]=P,t[59]=se,t[60]=re,t[61]=je,t[62]=ie,t[63]=Pe):Pe=t[63];let ke;t[64]===Symbol.for("react.memo_cache_sentinel")?(ke=Me("flex min-w-0 items-center gap-2 pb-3 pe-4",Ed),t[64]=ke):ke=t[64];let Ae;t[65]!==e?(Ae=e("settings.openchamber.tools.browserProvider.label"),t[65]=e,t[66]=Ae):Ae=t[66];let Te;t[67]!==Ae?(Te=s.jsx("span",{className:"truncate typography-meta text-muted-foreground",children:Ae}),t[67]=Ae,t[68]=Te):Te=t[68];let Ke;t[69]!==e?(Ke=e("settings.openchamber.tools.browserProvider.info"),t[69]=e,t[70]=Ke):Ke=t[70];let ge;t[71]!==Ke?(ge=s.jsx(qt,{children:Ke}),t[71]=Ke,t[72]=ge):ge=t[72];const Re=!o||ne.length===0;let Oe;t[73]!==e?(Oe=e("settings.openchamber.tools.browserProvider.aria"),t[73]=e,t[74]=Oe):Oe=t[74];let pe;t[75]!==ne||t[76]!==e?(pe=s.jsx(Ut,{children:Le=>Le===Ur?e("settings.openchamber.tools.browserProvider.option.builtin"):ne.find(Xe=>Xe.id===Le)?.name??null}),t[75]=ne,t[76]=e,t[77]=pe):pe=t[77];let xe;t[78]!==Oe||t[79]!==pe?(xe=s.jsx(Pt,{className:"ms-auto w-auto min-w-0 max-w-[14rem]","aria-label":Oe,children:pe}),t[78]=Oe,t[79]=pe,t[80]=xe):xe=t[80];let Ne;t[81]!==e?(Ne=e("settings.openchamber.tools.browserProvider.option.builtin"),t[81]=e,t[82]=Ne):Ne=t[82];let de;t[83]!==Ne?(de=s.jsx(ot,{value:Ur,children:Ne}),t[83]=Ne,t[84]=de):de=t[84];let Ue;t[85]!==ne?(Ue=ne.map(N2),t[85]=ne,t[86]=Ue):Ue=t[86];let Ie;t[87]!==de||t[88]!==Ue?(Ie=s.jsxs(At,{children:[de,Ue]}),t[87]=de,t[88]=Ue,t[89]=Ie):Ie=t[89];let De;t[90]!==G||t[91]!==$||t[92]!==Re||t[93]!==xe||t[94]!==Ie?(De=s.jsxs(Tt,{value:$,onValueChange:G,disabled:Re,children:[xe,Ie]}),t[90]=G,t[91]=$,t[92]=Re,t[93]=xe,t[94]=Ie,t[95]=De):De=t[95];let Je;t[96]!==Te||t[97]!==ge||t[98]!==De?(Je=s.jsxs("div",{"data-settings-item":"sessions.browser-provider",className:ke,children:[Te,ge,De]}),t[96]=Te,t[97]=ge,t[98]=De,t[99]=Je):Je=t[99];let tt;t[100]!==Pe||t[101]!==Je?(tt=s.jsxs("div",{children:[Pe,Je]}),t[100]=Pe,t[101]=Je,t[102]=tt):tt=t[102];let mt;t[103]!==e?(mt=e("settings.openchamber.tools.field.agentNotifyTool"),t[103]=e,t[104]=mt):mt=t[104];let ht;t[105]!==e?(ht=e("settings.openchamber.tools.field.agentNotifyToolSummary"),t[105]=e,t[106]=ht):ht=t[106];let ft;t[107]!==e?(ft=e("settings.openchamber.tools.field.agentNotifyToolInfo"),t[107]=e,t[108]=ft):ft=t[108];let xt;t[109]!==e?(xt=e("settings.openchamber.tools.field.agentNotifyToolAria"),t[109]=e,t[110]=xt):xt=t[110];let Qe;t[111]!==h||t[112]!==R||t[113]!==mt||t[114]!==ht||t[115]!==ft||t[116]!==xt?(Qe=s.jsx(Ka,{icon:"notification-3",settingsItem:"sessions.agent-notify-tool",checked:h,onChange:R,title:mt,summary:ht,info:ft,ariaLabel:xt}),t[111]=h,t[112]=R,t[113]=mt,t[114]=ht,t[115]=ft,t[116]=xt,t[117]=Qe):Qe=t[117];let lt;t[118]!==e?(lt=e("settings.openchamber.tools.field.agentRenderTool"),t[118]=e,t[119]=lt):lt=t[119];let Ye;t[120]!==e?(Ye=e("settings.openchamber.tools.field.agentRenderToolSummary"),t[120]=e,t[121]=Ye):Ye=t[121];let at;t[122]!==e?(at=e("settings.openchamber.tools.field.agentRenderToolInfo"),t[122]=e,t[123]=at):at=t[123];let dt;t[124]!==e?(dt=e("settings.openchamber.tools.field.agentRenderToolAria"),t[124]=e,t[125]=dt):dt=t[125];let _e;t[126]!==b||t[127]!==F||t[128]!==lt||t[129]!==Ye||t[130]!==at||t[131]!==dt?(_e=s.jsx(Ka,{icon:"bar-chart-box",settingsItem:"sessions.agent-render-tool",checked:b,onChange:F,title:lt,summary:Ye,info:at,ariaLabel:dt}),t[126]=b,t[127]=F,t[128]=lt,t[129]=Ye,t[130]=at,t[131]=dt,t[132]=_e):_e=t[132];let nt;t[133]!==e?(nt=e("settings.openchamber.tools.field.agentKnowledgeTool"),t[133]=e,t[134]=nt):nt=t[134];let te;t[135]!==e?(te=e("settings.openchamber.tools.field.agentKnowledgeToolSummary"),t[135]=e,t[136]=te):te=t[136];let ue;t[137]!==e?(ue=e("settings.openchamber.tools.field.agentKnowledgeToolInfo"),t[137]=e,t[138]=ue):ue=t[138];let he;t[139]!==e?(he=e("settings.openchamber.tools.field.agentKnowledgeToolAria"),t[139]=e,t[140]=he):he=t[140];let ye;t[141]!==g||t[142]!==O||t[143]!==nt||t[144]!==te||t[145]!==ue||t[146]!==he?(ye=s.jsx(Ka,{icon:"sticky-note",settingsItem:"sessions.agent-knowledge-tool",checked:g,onChange:O,title:nt,summary:te,info:ue,ariaLabel:he}),t[141]=g,t[142]=O,t[143]=nt,t[144]=te,t[145]=ue,t[146]=he,t[147]=ye):ye=t[147];let qe;t[148]!==d||t[149]!==m||t[150]!==ae||t[151]!==e?(qe=d?s.jsx(Ka,{icon:"brain",settingsItem:"sessions.agent-memory-tool",checked:m,onChange:ae,title:e("settings.openchamber.tools.field.agentMemoryTool"),summary:e("settings.openchamber.tools.field.agentMemoryToolSummary"),info:e("settings.openchamber.tools.field.agentMemoryToolInfo"),ariaLabel:e("settings.openchamber.tools.field.agentMemoryToolAria")}):null,t[148]=d,t[149]=m,t[150]=ae,t[151]=e,t[152]=qe):qe=t[152];let Ze;t[153]!==Ee||t[154]!==tt||t[155]!==Qe||t[156]!==_e||t[157]!==ye||t[158]!==qe?(Ze=s.jsxs("div",{className:"max-w-[44rem] divide-y divide-[var(--interactive-border)] rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[Ee,tt,Qe,_e,ye,qe]}),t[153]=Ee,t[154]=tt,t[155]=Qe,t[156]=_e,t[157]=ye,t[158]=qe,t[159]=Ze):Ze=t[159];let pt;t[160]!==e?(pt=e("settings.openchamber.tools.field.agentToolsCodeMode"),t[160]=e,t[161]=pt):pt=t[161];let vt;t[162]!==e?(vt=e("settings.openchamber.tools.field.agentToolsCodeModeAria"),t[162]=e,t[163]=vt):vt=t[163];let bt;t[164]!==e?(bt=e("settings.openchamber.tools.field.agentToolsCodeModeInfo"),t[164]=e,t[165]=bt):bt=t[165];let wt;t[166]!==v||t[167]!==B||t[168]!==pt||t[169]!==vt||t[170]!==bt?(wt=s.jsx(it,{className:"mt-4",settingsItem:"sessions.agent-tools-code-mode",checked:v,onChange:B,label:pt,ariaLabel:vt,info:bt}),t[166]=v,t[167]=B,t[168]=pt,t[169]=vt,t[170]=bt,t[171]=wt):wt=t[171];let Et;return t[172]!==X||t[173]!==Ze||t[174]!==wt?(Et=s.jsxs(He,{title:X,children:[Ze,wt]}),t[172]=X,t[173]=Ze,t[174]=wt,t[175]=Et):Et=t[175],Et};function a2(t){return t.agentControlToolEnabled}function i2(t){return t.setAgentControlToolEnabled}function o2(t){return t.agentWebToolEnabled}function r2(t){return t.setAgentWebToolEnabled}function l2(t){return t.browserProvider}function c2(t){return t.setBrowserProvider}function d2(t){return t.guests}function u2(t){return t.agentMemoryToolEnabled}function m2(t){return t.agentMemoryFeatureAvailable}function p2(t){return t.setAgentMemoryToolEnabled}function g2(t){return t.agentKnowledgeToolEnabled}function f2(t){return t.setAgentKnowledgeToolEnabled}function h2(t){return t.agentNotifyToolEnabled}function b2(t){return t.setAgentNotifyToolEnabled}function x2(t){return t.agentRenderToolEnabled}function v2(t){return t.setAgentRenderToolEnabled}function y2(t){return t.agentToolsCodeMode}function j2(t){return t.setAgentToolsCodeMode}function k2(t){return t.agentWorktreeMoveWithoutAsking}function w2(t){return t.setAgentWorktreeMoveWithoutAsking}function S2(){en()}function N2(t){return s.jsx(ot,{value:t.id,children:t.name},t.id)}const ym=new Set(["shift","control","alt","meta"]),jm=3,C2=3e3,km={maxKeys:jm,macModifiers:bg()};function Ll(t,{macModifiers:e}){const a=[];return e?(t.metaKey&&a.push("mod"),t.ctrlKey&&a.push("ctrl")):(t.ctrlKey&&a.push("mod"),t.metaKey&&a.push("super")),t.shiftKey&&a.push("shift"),t.altKey&&a.push("alt"),a}function Kl(t,e=!1){const a=new Set;return t.altKey&&a.add("alt"),t.ctrlKey&&a.add("control"),t.metaKey&&a.add("meta"),t.shiftKey&&a.add("shift"),e&&a.add(t.key.toLowerCase()),a.size}function I2(t){return t.action.customizable}function Md(t,e){if(Kl(t)>e.maxKeys)return null;const a=Ll(t,e);return a.length>0?Do(a.join("+")):null}function P2(t,e){if(ym.has(t.key.toLowerCase())||Kl(t,!0)>e.maxKeys)return null;const a=fg(hg(t));return a?Do([...Ll(t,e),a].join("+")):null}function A2(t,e){const a=t.key.toLowerCase();if(!ym.has(a)||Kl(t,!0)>e.maxKeys)return null;const n=Ll({metaKey:t.metaKey||a==="meta",ctrlKey:t.ctrlKey||a==="control",shiftKey:t.shiftKey||a==="shift",altKey:t.altKey||a==="alt"},e);return n.length>0?Do(n.join("+")):null}function Dd(t){return t.chords.length>0?{...t,livePreview:null,settled:!0}:t}function T2(t,e,a,n=2,o={}){const i={...km,...o};if(e.repeat||e.isComposing)return t;if(a==="keyup")return{...t,livePreview:Md(e,i)};if(e.key==="Backspace")return{chords:t.chords.slice(0,-1),livePreview:null,settled:!1};const r=P2(e,i);if(r){if(t.settled){const u=[r];return{chords:u,livePreview:null,settled:u.length>=n}}const l=t.chords.length<n?[...t.chords,r]:t.chords;return{chords:l,livePreview:null,settled:l.length>=n}}return{...t,livePreview:Md(e,i)}}const zl=t=>{const e=$e.c(122),{action:a,overrides:n,onSave:o,onOpenChange:i,maxChords:r,maxKeys:l}=t,u=r===void 0?2:r,m=l===void 0?jm:l,{t:d}=ze();let f;e[0]!==d?(f=re=>d(re.settingsLabelKey),e[0]=d,e[1]=f):f=e[1];const g=f;let p;e[2]!==g?(p=re=>re.action.customizable?g(re.action):Rn(re.action.defaultBinding),e[2]=g,e[3]=p):p=e[3];const h=p;let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w={chords:[],livePreview:null,settled:!1},e[4]=w):w=e[4];const[b,k]=c.useState(w),v=c.useRef(null);let S,y;e[5]!==a?(S=()=>{a&&(k({chords:[],livePreview:null,settled:!1}),v.current?.focus())},y=[a],e[5]=a,e[6]=S,e[7]=y):(S=e[6],y=e[7]),c.useEffect(S,y);const N=b.chords.length===1&&!b.settled;let x,I;e[8]!==N?(x=()=>{if(!N)return;const re=window.setTimeout(()=>k(Dd),C2);return()=>window.clearTimeout(re)},I=[N],e[8]=N,e[9]=x,e[10]=I):(x=e[9],I=e[10]),c.useEffect(x,I);let j;e[11]!==b.chords?(j=Do(b.chords.join(" ")),e[11]=b.chords,e[12]=j):j=e[12];const D=j;let C;e[13]!==a||e[14]!==D||e[15]!==n?(C=a&&D?pg(a.id,D,n):[],e[13]=a,e[14]=D,e[15]=n,e[16]=C):C=e[16];const P=C;let A;e[17]!==P?(A=P.find(E2),e[17]=P,e[18]=A):A=e[18];const R=A;let K,F,T,O,E,B,_,H,ne,z,$,V,G,ee,ae;if(e[19]!==a||e[20]!==g||e[21]!==D||e[22]!==h||e[23]!==P||e[24]!==u||e[25]!==m||e[26]!==i||e[27]!==o||e[28]!==R||e[29]!==b||e[30]!==d){const re=P.filter(I2);E=re.find(M2);const je=re.find(D2),ie=P.find(R2);let Pe;e[46]!==i?(Pe=()=>i(!1),e[46]=i,e[47]=Pe):Pe=e[47],T=Pe,O=()=>{b.settled||k(Dd),!(!a||!D||R||E)&&(o(a.id,D,je?.action.id),T())};let ke;e[48]!==a||e[49]!==u||e[50]!==m||e[51]!==b?(ke=(Je,tt)=>{Je.preventDefault(),Je.stopPropagation();const mt=!!(a&&"prefixStyle"in a&&a.prefixStyle);if(tt==="keyup"&&mt&&b.chords.length===0){const ft=A2(Je,{...km,maxKeys:m});if(ft){k({chords:[ft],livePreview:null,settled:!0});return}}const ht=T2(b,{altKey:Je.altKey,code:Je.nativeEvent.code,ctrlKey:Je.ctrlKey,isComposing:Je.nativeEvent.isComposing,key:Je.key,metaKey:Je.metaKey,repeat:Je.repeat,shiftKey:Je.shiftKey},tt,u,{maxKeys:m});k(mt&&ht.chords.length>1?b:ht)},e[48]=a,e[49]=u,e[50]=m,e[51]=b,e[52]=ke):ke=e[52];const Ae=ke;F=Kt,ee=a!==null,ae=F2,K=zt,B="max-w-md",_=v,H=!1;let Te;e[53]!==a||e[54]!==g||e[55]!==d?(Te=a?d("settings.openchamber.keyboardShortcuts.dialog.title",{action:g(a)}):"",e[53]=a,e[54]=g,e[55]=d,e[56]=Te):Te=e[56];let Ke;e[57]!==Te?(Ke=s.jsx(_t,{children:Te}),e[57]=Te,e[58]=Ke):Ke=e[58];const ge=u===1?"settings.openchamber.keyboardShortcuts.dialog.instructionsSingle":"settings.openchamber.keyboardShortcuts.dialog.instructions";let Re;e[59]!==d||e[60]!==ge?(Re=d(ge),e[59]=d,e[60]=ge,e[61]=Re):Re=e[61];let Oe;e[62]!==Re?(Oe=s.jsx(Vt,{children:Re}),e[62]=Re,e[63]=Oe):Oe=e[63],e[64]!==Ke||e[65]!==Oe?(ne=s.jsxs(Bt,{children:[Ke,Oe]}),e[64]=Ke,e[65]=Oe,e[66]=ne):ne=e[66];let pe,xe;e[67]!==Ae?(pe=Je=>Ae(Je,"keydown"),xe=Je=>Ae(Je,"keyup"),e[67]=Ae,e[68]=pe,e[69]=xe):(pe=e[68],xe=e[69]);let Ne;e[70]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>k(O2),e[70]=Ne):Ne=e[70];let de;e[71]!==b.chords?(de=b.chords.map(L2),e[71]=b.chords,e[72]=de):de=e[72];let Ue;e[73]!==b.livePreview?(Ue=b.livePreview?s.jsx("kbd",{className:"rounded-md border border-dashed border-border bg-muted px-3 py-2 typography-ui-label text-muted-foreground",children:Rn(b.livePreview)}):null,e[73]=b.livePreview,e[74]=Ue):Ue=e[74];let Ie;e[75]!==b.chords.length||e[76]!==b.livePreview||e[77]!==d?(Ie=b.chords.length===0&&!b.livePreview?s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:d("settings.openchamber.keyboardShortcuts.dialog.recording")}):null,e[75]=b.chords.length,e[76]=b.livePreview,e[77]=d,e[78]=Ie):Ie=e[78];let De;e[79]!==de||e[80]!==Ue||e[81]!==Ie?(De=s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[de,Ue,Ie]}),e[79]=de,e[80]=Ue,e[81]=Ie,e[82]=De):De=e[82],e[83]!==pe||e[84]!==xe||e[85]!==De?(z=s.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-lg border border-border bg-[var(--surface-elevated)] px-4 py-5 text-center outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,ref:v,onKeyDown:pe,onKeyUp:xe,onBlur:Ne,children:De}),e[83]=pe,e[84]=xe,e[85]=De,e[86]=z):z=e[86],$=b.settled&&R?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:d("settings.openchamber.keyboardShortcuts.error.internalConflict")}):b.settled&&E?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:d("settings.openchamber.keyboardShortcuts.error.prefixConflict",{action:g(E.action)})}):null,V=b.settled&&je&&!R&&!E?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:d("settings.openchamber.keyboardShortcuts.error.exactConflict",{action:g(je.action)})}):null,G=b.settled&&ie&&!R&&!E?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:d("settings.openchamber.keyboardShortcuts.warning.contextualPrefix",{action:h(ie)})}):null,e[19]=a,e[20]=g,e[21]=D,e[22]=h,e[23]=P,e[24]=u,e[25]=m,e[26]=i,e[27]=o,e[28]=R,e[29]=b,e[30]=d,e[31]=K,e[32]=F,e[33]=T,e[34]=O,e[35]=E,e[36]=B,e[37]=_,e[38]=H,e[39]=ne,e[40]=z,e[41]=$,e[42]=V,e[43]=G,e[44]=ee,e[45]=ae}else K=e[31],F=e[32],T=e[33],O=e[34],E=e[35],B=e[36],_=e[37],H=e[38],ne=e[39],z=e[40],$=e[41],V=e[42],G=e[43],ee=e[44],ae=e[45];let X;e[87]!==D||e[88]!==b.settled||e[89]!==d?(X=b.settled&&D&&gg(D)?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:d("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut")}):null,e[87]=D,e[88]=b.settled,e[89]=d,e[90]=X):X=e[90];let Q;e[91]!==d?(Q=d("settings.common.actions.cancel"),e[91]=d,e[92]=Q):Q=e[92];let le;e[93]!==T||e[94]!==Q?(le=s.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:T,children:Q}),e[93]=T,e[94]=Q,e[95]=le):le=e[95];const Z=!D||b.settled&&(!!R||!!E);let fe;e[96]!==d?(fe=d("settings.openchamber.keyboardShortcuts.actions.confirm"),e[96]=d,e[97]=fe):fe=e[97];let Y;e[98]!==O||e[99]!==Z||e[100]!==fe?(Y=s.jsx(q,{type:"button",size:"sm",disabled:Z,onClick:O,children:fe}),e[98]=O,e[99]=Z,e[100]=fe,e[101]=Y):Y=e[101];let be;e[102]!==le||e[103]!==Y?(be=s.jsxs(ts,{children:[le,Y]}),e[102]=le,e[103]=Y,e[104]=be):be=e[104];let Ee;e[105]!==K||e[106]!==B||e[107]!==_||e[108]!==H||e[109]!==ne||e[110]!==z||e[111]!==$||e[112]!==V||e[113]!==G||e[114]!==X||e[115]!==be?(Ee=s.jsxs(K,{className:B,initialFocus:_,showCloseButton:H,children:[ne,z,$,V,G,X,be]}),e[105]=K,e[106]=B,e[107]=_,e[108]=H,e[109]=ne,e[110]=z,e[111]=$,e[112]=V,e[113]=G,e[114]=X,e[115]=be,e[116]=Ee):Ee=e[116];let se;return e[117]!==F||e[118]!==ee||e[119]!==ae||e[120]!==Ee?(se=s.jsx(F,{open:ee,onOpenChange:ae,children:Ee}),e[117]=F,e[118]=ee,e[119]=ae,e[120]=Ee,e[121]=se):se=e[121],se};function E2(t){return!t.action.customizable&&t.kind!=="contextual-prefix"}function M2(t){return t.kind==="prefix"}function D2(t){return t.kind==="exact"}function R2(t){return t.kind==="contextual-prefix"}function F2(t,e){t||e.cancel()}function O2(t){return{...t,livePreview:null}}function L2(t,e){return s.jsx("kbd",{className:"rounded-md border border-border bg-muted px-3 py-2 typography-ui-label text-foreground",children:Rn(t)},`${t}-${e}`)}const $r=[.3,.35,.4,.45,.5,.6,1],K2=t=>{const e=$e.c(41),{quake:a,miniChatCombo:n,onReleaseMiniChatShortcut:o}=t,{t:i}=ze(),[r,l]=Be.useState(!1),u=oe(z2),m=oe(U2);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=kl().find($2)??null,e[0]=d):d=e[0];const f=d;let g;e[1]!==n||e[2]!==u?(g=n?{...u,mini_chat_global:n}:u,e[1]=n,e[2]=u,e[3]=g):g=e[3];const p=g;let h=$r[0];for(const T of $r)Math.abs(T-a.heightFraction)<Math.abs(h-a.heightFraction)&&(h=T);const w=String(h),{saveShortcut:b}=a;let k;e[4]!==o||e[5]!==b||e[6]!==m||e[7]!==u?(k=(T,O,E)=>{b(O).then(B=>{if(!(!B||!E)){if(E==="mini_chat_global"){o();return}m(E,Pn),yt({shortcutOverrides:{...u,[E]:Pn}})}})},e[4]=o,e[5]=b,e[6]=m,e[7]=u,e[8]=k):k=e[8];const v=k;if(!a.supported)return null;const S=a.enabled;let y;e[9]!==a?(y=T=>{T!==a.enabled&&a.setEnabled(T)},e[9]=a,e[10]=y):y=e[10];const N=a.isSaving;let x;e[11]!==i?(x=i("settings.openchamber.desktopNetwork.field.quakeMode"),e[11]=i,e[12]=x):x=e[12];let I;e[13]!==i?(I=i("settings.openchamber.desktopNetwork.field.quakeModeDescription"),e[13]=i,e[14]=I):I=e[14];let j;e[15]!==i?(j=i("settings.openchamber.desktopNetwork.field.quakeModeAria"),e[15]=i,e[16]=j):j=e[16];let D;e[17]!==a.enabled||e[18]!==a.isSaving||e[19]!==y||e[20]!==x||e[21]!==I||e[22]!==j?(D=s.jsx(it,{settingsItem:"sessions.desktop-quake-mode",checked:S,onChange:y,disabled:N,label:x,info:I,ariaLabel:j}),e[17]=a.enabled,e[18]=a.isSaving,e[19]=y,e[20]=x,e[21]=I,e[22]=j,e[23]=D):D=e[23];let C;e[24]!==a||e[25]!==i?(C=a.enabled?s.jsxs(kt,{label:i("settings.openchamber.desktopNetwork.field.quakeModeShortcut"),info:i("settings.openchamber.desktopNetwork.field.quakeModeShortcutDescription"),description:a.combo&&!a.active?s.jsx("span",{className:"block text-[var(--status-warning)]",children:i("settings.openchamber.desktopNetwork.field.quakeModeShortcutInactive")}):void 0,children:[s.jsx("kbd",{className:"min-w-32 rounded-md border border-border bg-muted px-2 py-1 text-center typography-meta text-foreground",children:a.combo?Rn(a.combo):i("settings.openchamber.keyboardShortcuts.unassigned")}),s.jsx(q,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",disabled:a.isSaving,onClick:()=>l(!0),children:i("settings.openchamber.keyboardShortcuts.actions.edit")}),a.storedCombo?s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",disabled:a.isSaving,onClick:()=>{a.saveShortcut(null)},children:i("settings.common.actions.reset")}):null]}):null,e[24]=a,e[25]=i,e[26]=C):C=e[26];let P;e[27]!==w||e[28]!==a||e[29]!==i?(P=a.enabled?s.jsx(kt,{label:i("settings.openchamber.desktopNetwork.field.quakeModeHeight"),info:i("settings.openchamber.desktopNetwork.field.quakeModeHeightDescription"),children:s.jsxs(Tt,{value:w,onValueChange:T=>{const O=Number(T);Number.isFinite(O)&&a.setHeight(O)},disabled:a.isSaving,children:[s.jsx(Pt,{className:nn,"aria-label":i("settings.openchamber.desktopNetwork.field.quakeModeHeightAria"),children:s.jsx(Ut,{})}),s.jsx(At,{children:$r.map(B2)})]})}):null,e[27]=w,e[28]=a,e[29]=i,e[30]=P):P=e[30];const A=r?f:null;let R;e[31]===Symbol.for("react.memo_cache_sentinel")?(R=T=>{T||l(!1)},e[31]=R):R=e[31];let K;e[32]!==v||e[33]!==p||e[34]!==A?(K=s.jsx(zl,{action:A,overrides:p,onSave:v,onOpenChange:R,maxChords:1,maxKeys:5}),e[32]=v,e[33]=p,e[34]=A,e[35]=K):K=e[35];let F;return e[36]!==D||e[37]!==C||e[38]!==P||e[39]!==K?(F=s.jsxs(s.Fragment,{children:[D,C,P,K]}),e[36]=D,e[37]=C,e[38]=P,e[39]=K,e[40]=F):F=e[40],F};function z2(t){return t.shortcutOverrides}function U2(t){return t.setShortcutOverride}function $2(t){return t.id==="quake_mode_global"}function B2(t){return s.jsx(ot,{value:String(t),children:`${Math.round(t*100)}%`},t)}const _2=(t,e)=>{const{t:a}=ze(),[n,o]=Be.useState(null),[i,r]=Be.useState(!1);Be.useEffect(()=>{if(!t){o(null);return}let p=!1;return(async()=>{const h=await cu();p||o(h)})(),()=>{p=!0}},[t]);const l=n?.supported===!0,u=Be.useCallback(async p=>{if(!l||i)return null;r(!0),e(null);try{const h=await p();if(!h?.supported)throw new Error(a("settings.openchamber.desktopNetwork.error.quakeModeSaveFailed"));return o(h),h}catch(h){return e(h instanceof Error?h.message:a("settings.openchamber.desktopNetwork.error.quakeModeSaveFailed")),null}finally{r(!1)}},[i,e,l,a]),m=Be.useCallback(p=>{u(()=>Qg(p))},[u]),d=Be.useCallback(async p=>{const h=await u(()=>Hr(p));return h?h.error==="unsupported-combo"?(e(a("settings.openchamber.desktopNetwork.error.quakeModeShortcutUnsupported")),!1):!0:!1},[u,e,a]),f=Be.useCallback(p=>{u(()=>Yg(p))},[u]),g=Be.useCallback(()=>{Hr(Pn).then(p=>{p&&o(p)})},[]);return{supported:l,enabled:n?.enabled===!0,combo:n?.combo??null,storedCombo:n?.storedCombo??null,active:n?.active===!0,heightFraction:n?.heightFraction??1,isSaving:i,setEnabled:m,saveShortcut:d,setHeight:f,release:g}},wm=()=>{const{t}=ze(),e=as()&&Qa(),a=e&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",n=e&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="linux",[o,i]=Be.useState(!1),[r,l]=Be.useState(!1),[u,m]=Be.useState(!1),[d,f]=Be.useState(""),[g,p]=Be.useState(!1),[h,w]=Be.useState(!1),[b,k]=Be.useState(null),[v,S]=Be.useState(!0),[y,N]=Be.useState(!1),[x,I]=Be.useState(!1),[j,D]=Be.useState(!1),[C,P]=Be.useState(!1),[A,R]=Be.useState(!1),[K,F]=Be.useState(!1),[T,O]=Be.useState(!1),[E,B]=Be.useState(!0),[_,H]=Be.useState(!0),[ne,z]=Be.useState(!1),[$,V]=Be.useState(!1),[G,ee]=Be.useState(!1),[ae,X]=Be.useState(!1),[Q,le]=Be.useState(!1),[Z,fe]=Be.useState(!1),[Y,be]=Be.useState(null),[Ee,se]=Be.useState(!1),[re,je]=Be.useState(!1),[ie,Pe]=Be.useState(!1),ke=oe(he=>he.shortcutOverrides),Ae=oe(he=>he.setShortcutOverride),Te=Be.useMemo(()=>kl().find(he=>he.id==="mini_chat_global")??null,[]),[Ke,ge]=Be.useState(null),Re=_2(e,ge),{release:Oe}=Re,pe=Be.useMemo(()=>Re.combo?{...ke,quake_mode_global:Re.combo}:ke,[Re.combo,ke]),[xe,Ne]=Be.useState(null);Be.useEffect(()=>{if(!e){S(!1);return}let he=!1;return(async()=>{try{const ye=await xn();if(!ye)throw new Error(t("settings.openchamber.desktopNetwork.error.loadFailed"));if(he)return;const qe=ye.desktopLanAccessEnabled===!0;i(qe),l(qe),m(ye.hasDesktopUiPassword===!0),f(""),p(!1),w(ye.desktopLanAccessActive===!0),k(ye.desktopLanAccessBlockedReason??null);const Ze=ye.desktopMacMenuBarEnabled!==!1;B(Ze),H(Ze);const pt=ye.desktopLinuxNativeFrame===!0;z(pt),V(pt),ge(null)}catch(ye){he||ge(ye instanceof Error?ye.message:t("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{he||S(!1)}})(),()=>{he=!0}},[e,t]),Be.useEffect(()=>{if(!e){I(!1);return}let he=!1;return(async()=>{const ye=await Zg();he||(I(ye?.supported===!0),D(ye?.enabled===!0))})(),()=>{he=!0}},[e]),Be.useEffect(()=>{if(!e){R(!1);return}let he=!1;return(async()=>{const ye=await Xg();he||(R(ye?.supported===!0),F(ye?.enabled===!0))})(),()=>{he=!0}},[e]),Be.useEffect(()=>{if(!e){ee(!1);return}let he=!1;return(async()=>{const ye=await ef();he||(ee(ye?.supported===!0),X(ye?.enabled===!0))})(),()=>{he=!0}},[e]),Be.useEffect(()=>{if(!e){fe(!1);return}let he=!1;return(async()=>{const ye=await du();he||(fe(ye?.supported===!0),be(ye?.combo??null),se(ye?.active===!0))})(),()=>{he=!0}},[e]),Be.useEffect(()=>{if(!e||!r){Ne(null);return}let he=!1;return(async()=>{const ye=await au();he||Ne(ye)})(),()=>{he=!0}},[r,e]);const de=d.trim(),Ue=de.length>0||g,Ie=r!==o||Ue||_!==E||$!==ne,De=Be.useMemo(()=>{if(typeof window>"u")return null;const ye=Ri()||window.location.href;let qe=0;try{qe=Number(new URL(ye).port)}catch{qe=Number(window.location.port)}return Number.isFinite(qe)&&qe>0?qe:null},[]),Je=r&&h&&xe&&De?`http://${xe}:${De}`:null,tt=de.length>0||u&&!g,mt=r&&!tt,ht=o&&!h&&b==="missing-password",ft=Ai(he=>he.networkAccessBlocked)||b==="enterprise-mode",xt=v||y||!Ie||mt,Qe=Be.useCallback(he=>{f(he),he.trim()&&p(!1)},[]),lt=Be.useCallback(()=>{f(""),p(!0),l(!1)},[]),Ye=Be.useCallback(async()=>{if(!x||C)return;const he=!j;D(he),P(!0),ge(null);try{const ye=await tf(he);if(!ye?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported"));D(ye.enabled)}catch(ye){D(!he),ge(ye instanceof Error?ye.message:t("settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed"))}finally{P(!1)}},[C,j,x,t]),at=Be.useCallback(async()=>{if(!A||T)return;const he=!K;F(he),O(!0),ge(null);try{const ye=await sf(he);if(!ye)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"));if(!ye.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTrayUnsupported"));F(ye.enabled)}catch(ye){F(!he),ge(ye instanceof Error?ye.message:t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"))}finally{O(!1)}},[T,K,A,t]),dt=Be.useCallback(async()=>{if(!G||Q)return;const he=!ae;X(he),le(!0),ge(null);try{const ye=await nf(he);if(!ye?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.keepAwakeUnsupported"));X(ye.enabled)}catch(ye){X(!he),ge(ye instanceof Error?ye.message:t("settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed"))}finally{le(!1)}},[Q,ae,G,t]),_e=Be.useCallback(async he=>{if(!Z||re)return!1;je(!0),ge(null);try{const ye=await qr(he);if(!ye?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutSaveFailed"));return be(ye.combo??null),se(ye.active===!0),ye.error==="unsupported-combo"?(ge(t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutUnsupported")),!1):!0}catch(ye){return ge(ye instanceof Error?ye.message:t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutSaveFailed")),!1}finally{je(!1)}},[re,Z,t]),nt=Be.useCallback((he,ye,qe)=>{_e(ye).then(Ze=>{if(!(!Ze||!qe)){if(qe==="quake_mode_global"){Oe();return}Ae(qe,Pn),yt({shortcutOverrides:{...ke,[qe]:Pn}})}})},[_e,Oe,Ae,ke]),te=Be.useCallback(()=>{qr(null).then(he=>{he&&(be(he.combo??null),se(he.active===!0))})},[]),ue=Be.useCallback(async()=>{if(Ie){N(!0),ge(null);try{if(!(await yt({desktopLanAccessEnabled:r,...de?{desktopUiPassword:de}:g?{desktopUiPassword:""}:{},desktopMacMenuBarEnabled:_,desktopLinuxNativeFrame:$})).ok)throw new Error(t("settings.openchamber.desktopNetwork.error.saveFailed"));if(i(r),de?m(!0):g&&m(!1),f(""),p(!1),B(_),z($),!await af())throw new Error(t("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(he){ge(he instanceof Error?he.message:t("settings.openchamber.desktopNetwork.error.saveFailed")),N(!1)}}},[$,_,r,Ie,de,g,t]);return e?s.jsxs(He,{title:t("settings.openchamber.desktopNetwork.title"),children:[s.jsxs("div",{className:"space-y-3",children:[x||a||n||A||G||Z||Re.supported?s.jsxs("div",{className:bs,children:[x?s.jsx(it,{settingsItem:"sessions.desktop-launch-at-login",checked:j,onChange:he=>{he!==j&&Ye()},disabled:C,label:t("settings.openchamber.desktopNetwork.field.launchAtLogin"),info:t("settings.openchamber.desktopNetwork.field.launchAtLoginDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.launchAtLoginAria")}):null,a?s.jsx(it,{settingsItem:"sessions.desktop-mac-menu-bar",checked:_,onChange:H,disabled:v||y,label:t("settings.openchamber.desktopNetwork.field.macMenuBar"),info:t("settings.openchamber.desktopNetwork.field.macMenuBarDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.macMenuBarAria")}):null,n?s.jsx(it,{settingsItem:"sessions.desktop-linux-native-frame",checked:$,onChange:V,disabled:v||y,label:t("settings.openchamber.desktopNetwork.field.linuxNativeFrame"),info:t("settings.openchamber.desktopNetwork.field.linuxNativeFrameDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.linuxNativeFrame")}):null,A?s.jsx(it,{settingsItem:"sessions.desktop-minimize-to-tray",checked:K,onChange:he=>{he!==K&&at()},disabled:T,label:t("settings.openchamber.desktopNetwork.field.minimizeToTray"),info:t("settings.openchamber.desktopNetwork.field.minimizeToTrayDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.minimizeToTrayAria")}):null,G?s.jsx(it,{settingsItem:"sessions.desktop-keep-awake",checked:ae,onChange:he=>{he!==ae&&dt()},disabled:Q,label:t("settings.openchamber.desktopNetwork.field.keepAwake"),info:t("settings.openchamber.desktopNetwork.field.keepAwakeDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.keepAwakeAria")}):null,Z?s.jsxs(kt,{settingsItem:"sessions.desktop-mini-chat-global-shortcut",label:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcut"),info:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutDescription"),description:Y&&!Ee?s.jsx("span",{className:"block text-[var(--status-warning)]",children:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutInactive")}):void 0,children:[s.jsx("kbd",{className:"min-w-32 rounded-md border border-border bg-muted px-2 py-1 text-center typography-meta text-foreground",children:Y?Rn(Y):t("settings.openchamber.keyboardShortcuts.unassigned")}),s.jsx(q,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",disabled:re,onClick:()=>Pe(!0),children:t("settings.openchamber.keyboardShortcuts.actions.edit")}),Y?s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",disabled:re,onClick:()=>{_e(null)},children:t("settings.common.actions.reset")}):null]}):null,s.jsx(K2,{quake:Re,miniChatCombo:Y,onReleaseMiniChatShortcut:te})]}):null,s.jsxs(Mt,{settingsItem:"sessions.desktop-ui-password",label:s.jsx("label",{htmlFor:"desktop-ui-password",children:t("settings.openchamber.desktopPassword.field.password")}),info:t("settings.openchamber.desktopPassword.field.passwordDescription"),children:[s.jsx(Ve,{id:"desktop-ui-password",type:"password",className:"h-8 min-w-0 flex-1",value:d,onChange:he=>Qe(he.target.value),placeholder:t(u&&!g?"settings.openchamber.desktopPassword.field.passwordSetPlaceholder":"settings.openchamber.desktopPassword.field.passwordPlaceholder"),disabled:v||y,required:r&&!tt,"aria-invalid":mt}),u&&!g?s.jsx(q,{type:"button",variant:"ghost",size:"xs",onClick:lt,disabled:v||y,className:"shrink-0 !font-normal",children:t("settings.openchamber.desktopPassword.actions.removePassword")}):null]}),s.jsx("div",{className:bs,children:s.jsx(it,{settingsItem:"sessions.desktop-lan-access",checked:r&&!ft,onChange:l,disabled:v||y||ft,label:t("settings.openchamber.desktopNetwork.field.allowLanAccess"),info:t("settings.openchamber.desktopNetwork.field.allowLanAccessDescription"),description:ft?s.jsx("span",{className:"block",children:t("settings.openchamber.desktopNetwork.field.enterpriseBlocked")}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.warning")}),mt||ht?s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.passwordRequiredWarning")}):null]}),ariaLabel:t("settings.openchamber.desktopNetwork.field.allowLanAccessAria")})}),Ke?s.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:Ke}):null,Je&&!ft?s.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[t(Ie&&!o?"settings.openchamber.desktopNetwork.hint.openAfterRestart":"settings.openchamber.desktopNetwork.hint.openNow"),s.jsx("span",{className:"font-mono text-foreground",children:Je})]}):null,s.jsx("div",{className:"flex justify-start py-1.5",children:s.jsx(q,{type:"button",size:"xs",onClick:ue,disabled:xt,className:"shrink-0 !font-normal",children:t(y?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")})})]}),s.jsx(zl,{action:ie?Te:null,overrides:pe,onSave:nt,onOpenChange:he=>{he||Pe(!1)},maxChords:1,maxKeys:5})]}):null},V2=["session","models","panels","navigation","application"],H2=()=>{const t=$e.c(34),{t:e}=ze(),a=oe(q2),n=oe(W2),o=oe(G2),i=oe(J2),[r,l]=c.useState(null),[u,m]=c.useState(null);let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{du().then(E=>m(E?.combo??null)).catch(Q2)},t[0]=d):d=t[0];const f=d;let g,p;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{f()},p=[f],t[1]=g,t[2]=p):(g=t[1],p=t[2]),c.useEffect(g,p);const[h,w]=c.useState(null);let b;t[3]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{cu().then(E=>w(E?.combo??null)).catch(Y2)},t[3]=b):b=t[3];const k=b;let v,S;t[4]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{k()},S=[k],t[4]=v,t[5]=S):(v=t[4],S=t[5]),c.useEffect(v,S);let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=kl(),t[6]=y):y=t[6];const N=y,x=Z2;let I;t[7]!==n||t[8]!==a?(I=(E,B,_)=>{const H={...a,[E]:B};n(E,B),_==="mini_chat_global"?qr(null).then(ne=>{ne&&m(ne.combo)}):_==="quake_mode_global"?Hr(Pn).then(ne=>{ne&&w(ne.combo)}):_&&(H[_]=Pn,n(_,Pn)),x(H)},t[7]=n,t[8]=a,t[9]=I):I=t[9];const j=I;let D;t[10]!==o||t[11]!==a?(D=E=>{const B={...a};delete B[E],o(E),x(B)},t[10]=o,t[11]=a,t[12]=D):D=t[12];const C=D;let P;t[13]!==a||t[14]!==e?(P=E=>{const B="prefixStyle"in E&&E.prefixStyle,_=B?xg(E.id,a):su(E.id,a),H=Rn(_,e("settings.openchamber.keyboardShortcuts.unassigned"));if(!B||!_||_===Pn)return H;const ne=E.id==="switch_session_tab"?e("settings.openchamber.keyboardShortcuts.action.switch_session_tab.suffix"):e("settings.openchamber.keyboardShortcuts.action.switch_context_surface.suffix");return`${H}${ne}`},t[13]=a,t[14]=e,t[15]=P):P=t[15];const A=P;let R;t[16]!==u||t[17]!==h||t[18]!==a?(R={...a},u&&(R.mini_chat_global=u),h&&(R.quake_mode_global=h),t[16]=u,t[17]=h,t[18]=a,t[19]=R):R=t[19];let K;t[20]!==i||t[21]!==C||t[22]!==A||t[23]!==a||t[24]!==e?(K=V2.map((E,B)=>{const _=N.filter(H=>H.category===E);return _.length===0?null:s.jsx(He,{settingsItem:B===0?"shortcuts.keyboard-shortcuts":void 0,title:e(`settings.openchamber.keyboardShortcuts.category.${E}`),divider:B!==0,info:B===0?e("settings.openchamber.keyboardShortcuts.tooltip"):void 0,headerAction:B===0?s.jsx(q,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{i(),x({})},children:e("settings.openchamber.keyboardShortcuts.actions.resetAll")}):void 0,children:s.jsx("div",{className:"space-y-2",children:_.map(H=>s.jsxs(kt,{label:e(H.settingsLabelKey),children:[s.jsx("kbd",{className:"min-w-32 rounded-md border border-border bg-muted px-2 py-1 text-center typography-meta text-foreground",children:A(H)}),s.jsx(q,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>{f(),k(),l(H)},children:e("settings.openchamber.keyboardShortcuts.actions.edit")}),H.id in a?s.jsx(q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>C(H.id),children:e("settings.common.actions.reset")}):null]},H.id))})},E)}),t[20]=i,t[21]=C,t[22]=A,t[23]=a,t[24]=e,t[25]=K):K=t[25];let F;t[26]===Symbol.for("react.memo_cache_sentinel")?(F=E=>{E||l(null)},t[26]=F):F=t[26];let T;t[27]!==r||t[28]!==R||t[29]!==j?(T=s.jsx(zl,{action:r,overrides:R,onSave:j,onOpenChange:F}),t[27]=r,t[28]=R,t[29]=j,t[30]=T):T=t[30];let O;return t[31]!==K||t[32]!==T?(O=s.jsxs(s.Fragment,{children:[K,T]}),t[31]=K,t[32]=T,t[33]=O):O=t[33],O};function q2(t){return t.shortcutOverrides}function W2(t){return t.setShortcutOverride}function G2(t){return t.clearShortcutOverride}function J2(t){return t.resetAllShortcutOverrides}function Q2(){}function Y2(){}function Z2(t){yt({shortcutOverrides:t})}const Sm=()=>{const t=$e.c(2),[e,a]=c.useState(0);let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>Ro(()=>a(dS)),o=[],t[0]=n,t[1]=o):(n=t[0],o=t[1]),c.useEffect(n,o),e},X2=t=>{const e=$e.c(91),{section:a}=t,{t:n}=ze(),{isMobile:o}=Fn(),i=Sm();let r;e[0]!==o?(r=o&&ca(),e[0]=o,e[1]=r):r=e[1];const l=r;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=cs(),e[2]=u):u=e[2];const m=u;let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=as()&&Qa(),e[3]=d):d=e[3];const f=d;if(!a){let z;e[4]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx($o,{}),e[4]=z):z=e[4];let $;e[5]!==i?($=s.jsx(gm,{},i),e[5]=i,e[6]=$):$=e[6];let V,G,ee;e[7]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(um,{}),G=f&&s.jsx(wm,{}),ee=!m&&s.jsx(bm,{}),e[7]=V,e[8]=G,e[9]=ee):(V=e[7],G=e[8],ee=e[9]);let ae;e[10]!==i?(ae=!m&&s.jsx(xm,{},i),e[10]=i,e[11]=ae):ae=e[11];let X,Q,le,Z,fe;e[12]===Symbol.for("react.memo_cache_sentinel")?(X=!m&&s.jsx(vm,{}),Q=s.jsx(cm,{}),le=!m&&s.jsx(dm,{}),Z=s.jsx(pm,{}),fe=ca()&&!as()&&!m&&!wl()&&s.jsx(mm,{}),e[12]=X,e[13]=Q,e[14]=le,e[15]=Z,e[16]=fe):(X=e[12],Q=e[13],le=e[14],Z=e[15],fe=e[16]);let Y;e[17]!==l?(Y=l&&s.jsx(hu,{}),e[17]=l,e[18]=Y):Y=e[18];let be;return e[19]!==Y||e[20]!==$||e[21]!==ae?(be=s.jsxs(Yt,{showSaveStatus:!0,className:"openchamber-page-body space-y-3 sm:space-y-6",children:[z,$,V,G,ee,ae,X,Q,le,Z,fe,Y]}),e[19]=Y,e[20]=$,e[21]=ae,e[22]=be):be=e[22],be}let g;e[23]!==i||e[24]!==a?(g=()=>{switch(a){case"general":return s.jsx(tS,{});case"visual":return s.jsx(sS,{});case"chat":return s.jsx(nS,{});case"sessions":return s.jsx(aS,{runtimeEndpointEpoch:i});case"shortcuts":return s.jsx(eS,{});case"git":return s.jsx(iS,{});case"notifications":return s.jsx(oS,{});case"voice":return s.jsx(rS,{});case"tunnel":return s.jsx(cS,{});case"spaces":return s.jsx(lS,{});default:return null}},e[23]=i,e[24]=a,e[25]=g):g=e[25];const p=g;let h;e[26]!==n?(h=n("settings.page.general.title"),e[26]=n,e[27]=h):h=e[27];let w;e[28]!==n?(w=n("settings.page.appearance.title"),e[28]=n,e[29]=w):w=e[29];let b;e[30]!==n?(b=n("settings.page.chat.title"),e[30]=n,e[31]=b):b=e[31];let k;e[32]!==n?(k=n("settings.page.sessions.title"),e[32]=n,e[33]=k):k=e[33];let v;e[34]!==n?(v=n("settings.page.shortcuts.title"),e[34]=n,e[35]=v):v=e[35];let S;e[36]!==n?(S=n("settings.page.git.title"),e[36]=n,e[37]=S):S=e[37];let y;e[38]!==n?(y=n("settings.page.git.title"),e[38]=n,e[39]=y):y=e[39];let N;e[40]!==n?(N=n("settings.page.notifications.title"),e[40]=n,e[41]=N):N=e[41];let x;e[42]!==n?(x=n("settings.page.voice.title"),e[42]=n,e[43]=x):x=e[43];let I;e[44]!==n?(I=n("settings.page.tunnel.title"),e[44]=n,e[45]=I):I=e[45];let j;e[46]!==n?(j=n("settings.openchamber.spaces.title"),e[46]=n,e[47]=j):j=e[47];let D;e[48]!==S||e[49]!==y||e[50]!==N||e[51]!==x||e[52]!==I||e[53]!==j||e[54]!==h||e[55]!==w||e[56]!==b||e[57]!==k||e[58]!==v?(D={general:h,visual:w,chat:b,sessions:k,shortcuts:v,git:S,github:y,notifications:N,voice:x,tunnel:I,spaces:j},e[48]=S,e[49]=y,e[50]=N,e[51]=x,e[52]=I,e[53]=j,e[54]=h,e[55]=w,e[56]=b,e[57]=k,e[58]=v,e[59]=D):D=e[59];const C=D[a];let P;e[60]!==n?(P=n("settings.page.general.description"),e[60]=n,e[61]=P):P=e[61];let A;e[62]!==n?(A=n("settings.page.appearance.description"),e[62]=n,e[63]=A):A=e[63];let R;e[64]!==n?(R=n("settings.page.chat.description"),e[64]=n,e[65]=R):R=e[65];let K;e[66]!==n?(K=n("settings.page.sessions.description"),e[66]=n,e[67]=K):K=e[67];let F;e[68]!==n?(F=n("settings.page.shortcuts.description"),e[68]=n,e[69]=F):F=e[69];let T;e[70]!==n?(T=n("settings.page.notifications.description"),e[70]=n,e[71]=T):T=e[71];let O;e[72]!==n?(O=n("settings.page.voice.description"),e[72]=n,e[73]=O):O=e[73];let E;e[74]!==n?(E=n("settings.page.tunnel.description"),e[74]=n,e[75]=E):E=e[75];let B;e[76]!==P||e[77]!==A||e[78]!==R||e[79]!==K||e[80]!==F||e[81]!==T||e[82]!==O||e[83]!==E?(B={general:P,visual:A,chat:R,sessions:K,shortcuts:F,git:void 0,github:void 0,notifications:T,voice:O,tunnel:E,spaces:void 0},e[76]=P,e[77]=A,e[78]=R,e[79]=K,e[80]=F,e[81]=T,e[82]=O,e[83]=E,e[84]=B):B=e[84];const _=B[a];let H;e[85]!==p?(H=p(),e[85]=p,e[86]=H):H=e[86];let ne;return e[87]!==_||e[88]!==C||e[89]!==H?(ne=s.jsx(Yt,{title:C,description:_,showSaveStatus:!0,className:"openchamber-page-body",children:H}),e[87]=_,e[88]=C,e[89]=H,e[90]=ne):ne=e[90],ne},eS=()=>{const t=$e.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(H2,{}),t[0]=e):e=t[0],e},tS=()=>{const t=$e.c(15);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=cs(),t[0]=e):e=t[0];const a=e,n=Sm();let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o=as()&&Qa(),t[1]=o):o=t[1];const i=o;let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=ca()&&!as()&&!a&&!wl(),t[2]=r):r=t[2];const l=r;let u,m,d,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=i&&s.jsx(wm,{}),m=l&&s.jsx(mm,{}),d=s.jsx(pm,{}),f=!a&&s.jsx(bm,{}),t[3]=u,t[4]=m,t[5]=d,t[6]=f):(u=t[3],m=t[4],d=t[5],f=t[6]);let g;t[7]!==n?(g=!a&&s.jsx(xm,{},n),t[7]=n,t[8]=g):g=t[8];let p;t[9]===Symbol.for("react.memo_cache_sentinel")?(p=!a&&s.jsx(vm,{}),t[9]=p):p=t[9];let h,w;t[10]===Symbol.for("react.memo_cache_sentinel")?(w=a?[]:["fileTreeSide"],h=a?[]:["sessionTabs"],t[10]=h,t[11]=w):(h=t[10],w=t[11]);let b;t[12]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx($o,{visibleSettings:["fileEditorKeymap",...w,...h,"autoSaveEnabled",...a?[]:["confirmFileTreeMove"],...a?[]:["layoutAnimations"],...a?[]:["openLinksInBrowserPanel","openTrackerLinksOnBoard"],...a?[]:["terminalQuickKeys"],...a?[]:["terminalShell"],...a?[]:["terminalLoginShell"],"messageTransport","reportUsage"]}),t[12]=b):b=t[12];let k;return t[13]!==g?(k=s.jsxs(s.Fragment,{children:[u,m,d,f,g,p,b]}),t[13]=g,t[14]=k):k=t[14],k},sS=()=>{const t=$e.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=cs(),t[0]=e):e=t[0];const a=e;let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx($o,{visibleSettings:["theme","windowControlsPosition","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat",...a?[]:["weekStart"],"fontSize","terminalFontSize","editorFontSize","spacing","scrollbars","inputBarOffset","animatedActivityIndicators"]}),t[1]=n):n=t[1],n},nS=()=>{const t=$e.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx($o,{visibleSettings:["sessionGoal","sessionAssist","activityRenderMode","userMessageRendering","mermaidRendering","reasoning","showToolFileIcons","showTurnChangedFiles","collapsibleUserMessages","promptNavigatorEnabled","wideChatLayout","codeBlockLineWrap","tableCellWrap","copyMessagesAsPlainText","splitAssistantMessageActions","subagentReadOnlyBanner","diffLayout","inputHistoryScope","inputHistoryLimit","messageSearch","dotfiles","fileViewerPreview","followUpBehavior","persistDraft","inputSpellcheck","largeTextPaste","enterToSend"]}),t[0]=e):e=t[0],e},aS=t=>{const e=$e.c(7),{runtimeEndpointEpoch:a}=t;let n;e[0]!==a?(n=s.jsx(gm,{},a),e[0]=a,e[1]=n):n=e[1];let o,i,r;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(um,{}),i=s.jsx(cm,{}),r=!cs()&&s.jsx(dm,{}),e[2]=o,e[3]=i,e[4]=r):(o=e[2],i=e[3],r=e[4]);let l;return e[5]!==n?(l=s.jsxs(s.Fragment,{children:[n,o,i,r]}),e[5]=n,e[6]=l):l=e[6],l},iS=()=>{const t=$e.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Hu,{}),t[0]=e):e=t[0],e},oS=()=>{const t=$e.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Fw,{}),t[0]=e):e=t[0],e},rS=()=>{const t=$e.c(1);if(cs())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Hw,{}),t[0]=e):e=t[0],e},lS=()=>{if($e.c(1),cs()||!uo)return null},cS=()=>{const t=$e.c(1);if(cs())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(s2,{}),t[0]=e):e=t[0],e};function dS(t){return t+1}const uS=[{id:"chat.activity-default",page:"chat",titleKey:"settings.openchamber.visual.section.activityDefault",keywords:["activity","collapsed","expanded","live","tools","history"]},{id:"appearance.language",page:"appearance",titleKey:"settings.appearance.language.label",descriptionKey:"settings.appearance.language.description",keywords:["locale","translation","ui language"]},{id:"appearance.time-format",page:"appearance",titleKey:"settings.openchamber.visual.field.timeFormat",keywords:["clock","12h","24h"]},{id:"appearance.week-start",page:"appearance",titleKey:"settings.openchamber.visual.field.weekStartsOn",keywords:["calendar","monday","sunday"]},{id:"appearance.light-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.lightTheme",keywords:["theme","color","light mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.dark-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.darkTheme",keywords:["theme","color","dark mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.import-theme",page:"appearance",titleKey:"settings.themeImport.action",descriptionKey:"settings.themeImport.catalogHint",keywords:["theme","import","vscode","open vsx","openvsx","json","jsonc","syntax","palette"],isAvailable:t=>!t.isVSCode},{id:"appearance.dock-badge",page:"appearance",titleKey:"settings.openchamber.visual.field.dockBadge",descriptionKey:"settings.openchamber.visual.field.dockBadgeHint",keywords:["dock","badge","unread","unseen","counter","count","notification","macos"],isAvailable:t=>t.isMac},{id:"appearance.scrollbars",page:"appearance",titleKey:"settings.openchamber.visual.field.alwaysShowScrollbars",descriptionKey:"settings.openchamber.visual.field.alwaysShowScrollbarsHint",keywords:["scrollbar","scrollbars","scroll","mouse","wheel","accessibility","always visible"]},{id:"appearance.pwa-install-name",page:"appearance",titleKey:"settings.openchamber.visual.field.installAppName",descriptionKey:"settings.openchamber.visual.field.installAppNameHint",keywords:["pwa","installed app"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.pwa-orientation",page:"appearance",titleKey:"settings.openchamber.visual.field.installOrientation",descriptionKey:"settings.openchamber.visual.field.installOrientationHint",keywords:["pwa","portrait","landscape"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.mobile-keyboard-mode",page:"appearance",titleKey:"settings.openchamber.visual.field.mobileKeyboardMode",descriptionKey:"settings.openchamber.visual.field.mobileKeyboardModeHint",keywords:["mobile","keyboard","resize"],isAvailable:t=>t.isMobile&&t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.animated-activity-indicators",page:"appearance",titleKey:"settings.openchamber.visual.field.animatedActivityIndicators",descriptionKey:"settings.openchamber.visual.field.animatedActivityIndicatorsInfo",keywords:["spinner","animation","session","activity","motion","running","indicator"]},{id:"appearance.interface-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.interfaceFontSize",keywords:["font","text size","ui scale"],isAvailable:t=>!t.isMobile},{id:"appearance.terminal-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalFontSize",keywords:["terminal","font","text size"]},{id:"appearance.terminal-shell",page:"general",titleKey:"settings.openchamber.visual.field.terminalShell",descriptionKey:"settings.openchamber.visual.field.terminalShellHint",keywords:["terminal","shell","bash","zsh","fish","pwsh","powershell"],isAvailable:t=>!t.isVSCode},{id:"appearance.editor-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.editorFontSize",keywords:["editor","font","text size","code"]},{id:"appearance.spacing-density",page:"appearance",titleKey:"settings.openchamber.visual.field.spacingDensity",keywords:["density","compact","comfortable","spacing"]},{id:"appearance.input-bar-offset",page:"appearance",titleKey:"settings.openchamber.visual.field.inputBarOffset",descriptionKey:"settings.openchamber.visual.field.inputBarOffsetTooltip",keywords:["input","home bar","offset"],isAvailable:t=>t.isMobile},{id:"appearance.auto-save-enabled",page:"general",titleKey:"settings.openchamber.visual.field.autoSaveEnabled",descriptionKey:"settings.openchamber.visual.field.autoSaveEnabledInfo",keywords:["editor","autosave","auto-save","files","save"]},{id:"appearance.confirm-file-tree-move",page:"general",titleKey:"settings.openchamber.visual.field.confirmFileTreeMove",keywords:["files","tree","move","drag","drop","confirm"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.file-tree-side",page:"general",titleKey:"settings.openchamber.visual.field.fileTreeSide",keywords:["files","tree","explorer","left","right","side","editor"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.layout-animations",page:"general",titleKey:"settings.openchamber.visual.field.layoutAnimations",descriptionKey:"settings.openchamber.visual.field.layoutAnimationsInfo",keywords:["animation","motion","sidebar","panel","slide","instant"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.open-links-in-browser-panel",page:"general",titleKey:"settings.openchamber.visual.field.openLinksInBrowserPanel",descriptionKey:"settings.openchamber.visual.field.openLinksInBrowserPanelInfo",keywords:["links","url","browser","open","preview","external"],isAvailable:t=>t.isDesktop&&!t.isMobile&&!t.isVSCode},{id:"appearance.open-tracker-links-on-board",page:"general",titleKey:"settings.openchamber.visual.field.openTrackerLinksOnBoard",descriptionKey:"settings.openchamber.visual.field.openTrackerLinksOnBoardInfo",keywords:["links","github","gitlab","linear","issue","pull request","merge request","board"],isAvailable:t=>!t.isVSCode},{id:"appearance.file-editor-keymap",page:"general",titleKey:"settings.openchamber.visual.field.fileEditorKeymap",keywords:["editor","vim","keymap"]},{id:"appearance.session-tabs",page:"general",titleKey:"settings.openchamber.visual.field.sessionTabsGroup",descriptionKey:"settings.openchamber.visual.field.sessionTabsInfo",keywords:["session","tabs","header","working set"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.terminal-quick-keys",page:"general",titleKey:"settings.openchamber.visual.field.terminalQuickKeys",descriptionKey:"settings.openchamber.visual.field.terminalQuickKeysTooltip",keywords:["terminal","keyboard","esc","ctrl","arrows"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.usage-reports",page:"general",titleKey:"settings.openchamber.visual.field.sendAnonymousUsageReports",descriptionKey:"settings.openchamber.visual.field.sendAnonymousUsageReportsHint",keywords:["telemetry","analytics"]},{id:"general.app-links",page:"general",titleKey:"settings.openchamber.appLinks.title",descriptionKey:"settings.openchamber.appLinks.info",keywords:["security","app link","deep link","scheme","protocol","obsidian","notion"]},{id:"chat.message-transport",page:"general",titleKey:"settings.openchamber.visual.section.messageStreamTransport",keywords:["streaming","sse","websocket"]},{id:"chat.session-recap",page:"chat",titleKey:"settings.openchamber.visual.field.sessionRecap",keywords:["recap","assist","small model","summary"]},{id:"chat.session-assistance",page:"chat",titleKey:"settings.openchamber.visual.section.sessionAssistance",keywords:["recap","suggestion","subagent"]},{id:"chat.session-suggestion",page:"chat",titleKey:"settings.openchamber.visual.field.sessionSuggestion",keywords:["suggestion","assist","small model","follow up"]},{id:"chat.session-review-offer",page:"chat",titleKey:"settings.openchamber.visual.field.sessionReviewOffer",descriptionKey:"settings.openchamber.visual.field.sessionReviewOfferInfo",keywords:["review","walkthrough","changes","diff","jev","classification"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal",page:"chat",titleKey:"settings.openchamber.visual.field.sessionGoal",keywords:["goal","objective","auto continue"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-checker",page:"chat",titleKey:"settings.openchamber.visual.goal.checkerLabel",keywords:["goal","progress","check","jev","classification","small model"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-max-turns",page:"chat",titleKey:"settings.openchamber.visual.goal.maxTurnsLabel",keywords:["goal","turns","limit","continuations","safety"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-budget",page:"chat",titleKey:"settings.openchamber.visual.goal.budgetLabel",keywords:["goal","budget","tokens","limit"],isAvailable:t=>!t.isVSCode},{id:"chat.reasoning-traces",page:"chat",titleKey:"settings.openchamber.visual.field.showReasoningTraces",keywords:["thinking","reasoning"]},{id:"chat.reasoning",page:"chat",titleKey:"settings.openchamber.visual.section.reasoning",keywords:["thinking","traces","collapse","expand","streaming"]},{id:"chat.streaming",page:"chat",titleKey:"settings.openchamber.visual.section.streaming",keywords:["stream","scroll"]},{id:"chat.streaming-auto-follow",page:"chat",titleKey:"settings.openchamber.visual.field.streamingAutoFollow",descriptionKey:"settings.openchamber.visual.field.streamingAutoFollowInfo",keywords:["autoscroll","auto-scroll","follow","stick to bottom","streaming"]},{id:"chat.prompt-navigator",page:"chat",titleKey:"settings.openchamber.visual.field.promptNavigatorEnabled",keywords:["prompt","navigator","navigation","timeline","scroll"]},{id:"chat.collapsible-user-messages",page:"chat",titleKey:"settings.openchamber.visual.field.collapsibleUserMessages",keywords:["collapse","expand","clamp","long messages","user messages"]},{id:"chat.wide-layout",page:"chat",titleKey:"settings.openchamber.visual.field.wideChatLayout",keywords:["layout","wide","messages"]},{id:"chat.message-appearance",page:"chat",titleKey:"settings.openchamber.visual.section.messageAppearance",keywords:["layout","messages","appearance"]},{id:"chat.code-block-line-wrap",page:"chat",titleKey:"settings.openchamber.visual.field.codeBlockLineWrap",keywords:["code","wrap","line wrap","markdown"]},{id:"chat.table-cell-wrap",page:"chat",titleKey:"settings.openchamber.visual.field.tableCellWrap",descriptionKey:"settings.openchamber.visual.field.tableCellWrapInfo",keywords:["table","wrap","cell","columns","markdown"]},{id:"chat.copy-plain-text",page:"chat",titleKey:"settings.openchamber.visual.field.copyMessagesAsPlainText",descriptionKey:"settings.openchamber.visual.field.copyMessagesAsPlainTextInfo",keywords:["copy","clipboard","plain text","markdown","selection"]},{id:"chat.inline-assistant-actions",page:"chat",titleKey:"settings.openchamber.visual.field.showSplitAssistantMessageActions",descriptionKey:"settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip",keywords:["copy","save image","read aloud"]},{id:"chat.draft-starters-visible",page:"chat",titleKey:"settings.openchamber.visual.field.draftStartersVisible",keywords:["starter","starters","new session","welcome","suggestions"]},{id:"chat.subagent-read-only-banner",page:"chat",titleKey:"settings.openchamber.visual.field.allowPromptingSubagentSessions",keywords:["subagent","read only","prompt","banner"]},{id:"chat.tool-file-icons",page:"chat",titleKey:"settings.openchamber.visual.field.showToolFileIcons",keywords:["tools","files","icons"]},{id:"chat.tools-and-files",page:"chat",titleKey:"settings.openchamber.visual.section.toolsAndFiles",keywords:["tools","files","dotfiles"]},{id:"chat.changed-files",page:"chat",titleKey:"settings.openchamber.visual.field.showTurnChangedFiles",keywords:["changed files","turns"]},{id:"chat.dotfiles",page:"chat",titleKey:"settings.openchamber.visual.field.showDotfiles",keywords:["hidden files"],isAvailable:t=>!t.isVSCode},{id:"chat.follow-up-behavior",page:"chat",titleKey:"settings.openchamber.visual.section.followUpBehavior",descriptionKey:"settings.openchamber.visual.field.followUpBehaviorDescription",keywords:["follow up","queue","steer","send immediately"]},{id:"chat.input-history-scope",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryScope",descriptionKey:"settings.openchamber.visual.field.inputHistoryScopeDescription",keywords:["input history","composer history","global","session","reuse"]},{id:"chat.input-history-limit",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryLimit",descriptionKey:"settings.openchamber.visual.field.inputHistoryLimitDescription",keywords:["history limit","prompt recall","remember prompts","composer history","submitted prompts","trim history"]},{id:"chat.message-search",page:"chat",titleKey:"settings.openchamber.messageSearch.title",keywords:["search","find","index","messages","history","full text"],isAvailable:t=>!t.isVSCode},{id:"chat.message-search-enabled",page:"chat",titleKey:"settings.openchamber.messageSearch.field.enabled",keywords:["search","find","index","messages"],isAvailable:t=>!t.isVSCode},{id:"chat.message-search-reasoning",page:"chat",titleKey:"settings.openchamber.messageSearch.field.reasoning",keywords:["search","reasoning","thinking","index"],isAvailable:t=>!t.isVSCode},{id:"chat.persist-drafts",page:"chat",titleKey:"settings.openchamber.visual.field.persistDraftMessages",keywords:["draft","message"]},{id:"chat.composer",page:"chat",titleKey:"settings.openchamber.visual.section.composer",keywords:["input","draft","spellcheck","paste"]},{id:"chat.spellcheck",page:"chat",titleKey:"settings.openchamber.visual.field.enableSpellcheckInTextInputs",keywords:["spelling","input"],isAvailable:t=>!t.isMobile},{id:"chat.large-text-paste",page:"chat",titleKey:"settings.openchamber.visual.field.largeTextPaste",descriptionKey:"settings.openchamber.visual.field.largeTextPasteHint",keywords:["paste","clipboard","attachment","large","text","file","double paste","ctrl v","cmd v"]},{id:"chat.enter-to-send",page:"chat",titleKey:"settings.openchamber.visual.field.enterToSend",descriptionKey:"settings.openchamber.visual.field.enterToSendHint",keywords:["enter","shift enter","ctrl enter","cmd enter","mod enter","send","newline"],isAvailable:t=>!t.isMobile},{id:"sessions.default-model",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultModel",keywords:["model","provider","new sessions"]},{id:"sessions.default-thinking",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultThinking",keywords:["thinking","reasoning","variant"]},{id:"sessions.default-agent",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultAgent",keywords:["agent","new sessions"]},{id:"sessions.deletion-dialog",page:"sessions",titleKey:"settings.openchamber.defaults.field.showDeletionDialog",keywords:["delete","confirmation"]},{id:"sessions.warming",page:"sessions",titleKey:"settings.openchamber.defaults.field.sessionWarming",descriptionKey:"settings.openchamber.defaults.field.sessionWarmingInfo",keywords:["warming","warm","cache","prompt cache","keep-alive","idle"]},{id:"sessions.permission-default",page:"sessions",titleKey:"settings.sessions.permissions.defaultMode",descriptionKey:"settings.sessions.permissions.defaultModeInfo",keywords:["permissions","auto-accept","accept","safety net","ask","shield","approval","new session"],isAvailable:t=>!t.isVSCode},{id:"sessions.show-chats",page:"sessions",titleKey:"settings.openchamber.defaults.field.showChats",keywords:["chats","sidebar","hide","show","section"],isAvailable:t=>!t.isVSCode},{id:"sessions.work",page:"sessions",titleKey:"settings.openchamber.sessionWork.title",descriptionKey:"settings.openchamber.sessionWork.info",keywords:["in work","in progress","track","done","inbox","sidebar","recent","jev"]},{id:"sessions.work-enabled",page:"sessions",titleKey:"settings.openchamber.sessionWork.field.enabled",keywords:["in work","in progress","track","done","sidebar"]},{id:"sessions.small-model",page:"sessions",titleKey:"settings.openchamber.defaults.smallModel.title",descriptionKey:"settings.openchamber.defaults.smallModel.description",keywords:["small model","utility","summary","recap","cheap","override"]},{id:"sessions.walkthrough-model",page:"sessions",titleKey:"settings.openchamber.defaults.walkthroughModel.title",descriptionKey:"settings.openchamber.defaults.walkthroughModel.description",keywords:["walkthrough","diff","review","changes","structured output","model","override"]},{id:"sessions.auto-cleanup",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.enableAutoCleanup",descriptionKey:"settings.openchamber.sessionRetention.tooltip",keywords:["retention","archive","delete"]},{id:"sessions.merged-worktree-cleanup",page:"sessions",titleKey:"settings.openchamber.mergedWorktreeCleanup.field.enable",descriptionKey:"settings.openchamber.mergedWorktreeCleanup.field.enableDescription",keywords:["pr","pull request","merged","worktree","branch","archive","cleanup","remove"]},{id:"sessions.retention-only-archived",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.onlyArchived",descriptionKey:"settings.openchamber.sessionRetention.field.onlyArchivedDescription",keywords:["archive","archived","only","delete","cleanup","retention"]},{id:"sessions.retention-period",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.retentionPeriod",keywords:["days","cleanup","retention"]},{id:"sessions.retention-action",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.whenSessionsExpire",keywords:["archive","delete","expire"]},{id:"sessions.desktop-launch-at-login",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.launchAtLogin",descriptionKey:"settings.openchamber.desktopNetwork.field.launchAtLoginDescription",keywords:["desktop","startup","login","launch","background","autostart"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-window-controls-position",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsPosition",descriptionKey:"settings.openchamber.desktopNetwork.field.windowControlsPositionDescription",keywords:["desktop","window","controls","minimize","maximize","close","titlebar","linux","windows"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-window-controls-style",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsStyle",keywords:["desktop","window","controls","style","traffic","lights","classic","macos","titlebar"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-mac-menu-bar",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.macMenuBar",descriptionKey:"settings.openchamber.desktopNetwork.field.macMenuBarDescription",keywords:["desktop","menu bar","tray","status item","macos","background"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isMac},{id:"sessions.desktop-linux-native-frame",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.linuxNativeFrame",descriptionKey:"settings.openchamber.desktopNetwork.field.linuxNativeFrameDescription",keywords:["desktop","linux","title bar","titlebar","window","frame","decorations","gnome","kde"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isLinux},{id:"sessions.desktop-minimize-to-tray",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.minimizeToTray",descriptionKey:"settings.openchamber.desktopNetwork.field.minimizeToTrayDescription",keywords:["desktop","tray","system tray","minimize","close","background","windows","linux"],isAvailable:t=>t.isDesktopLocalOrigin&&(t.isWindows||t.isLinux)},{id:"sessions.desktop-keep-awake",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.keepAwake",descriptionKey:"settings.openchamber.desktopNetwork.field.keepAwakeDescription",keywords:["desktop","sleep","awake","server","mobile","phone"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-mini-chat-global-shortcut",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.miniChatGlobalShortcut",descriptionKey:"settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutDescription",keywords:["desktop","mini chat","shortcut","hotkey","global","keyboard"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-quake-mode",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.quakeMode",descriptionKey:"settings.openchamber.desktopNetwork.field.quakeModeDescription",keywords:["desktop","quake","dropdown","hotkey","shortcut","height","global","background","tray","terminal"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-ui-password",page:"general",titleKey:"settings.openchamber.desktopPassword.field.password",descriptionKey:"settings.openchamber.desktopPassword.field.passwordDescription",keywords:["desktop","password","auth","login"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-lan-access",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.allowLanAccess",descriptionKey:"settings.openchamber.desktopNetwork.field.allowLanAccessDescription",keywords:["desktop","lan","network","phone","tablet"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.opencode-binary",page:"general",titleKey:"settings.openchamber.opencodeCli.field.binaryPath",keywords:["opencode","cli","binary","path"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-restart",page:"general",titleKey:"settings.openchamber.opencodeCli.actions.restart",keywords:["opencode","restart","reload","plugin"],isAvailable:t=>!t.isVSCode},{id:"general.environment-variables",page:"general",titleKey:"settings.environment.user.title",descriptionKey:"settings.environment.user.info",keywords:["environment","env","variables","api key","token","secret","opencode","terminal","git"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-update-notifications",page:"general",titleKey:"settings.openchamber.opencodeCli.field.showUpdateNotifications",keywords:["opencode","cli","updates"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-control-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentControlTool",descriptionKey:"settings.openchamber.tools.field.agentControlToolInfo",keywords:["agent","tool","orchestration","openchamber","sessions","schedule","control"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-worktree-move",page:"general",titleKey:"settings.openchamber.tools.field.agentWorktreeMove",descriptionKey:"settings.openchamber.tools.field.agentWorktreeMoveInfo",keywords:["agent","worktree","branch","move","session","ask","pull request"],isAvailable:t=>!t.isVSCode&&oe.getState().agentControlToolEnabled},{id:"sessions.agent-web-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentWebTool",descriptionKey:"settings.openchamber.tools.field.agentWebToolInfo",keywords:["agent","tool","web","browser","page","preview","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.browser-provider",page:"general",titleKey:"settings.openchamber.tools.browserProvider.label",descriptionKey:"settings.openchamber.tools.browserProvider.info",keywords:["agent","browser","provider","extension","chrome","server","headless"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-notify-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentNotifyTool",descriptionKey:"settings.openchamber.tools.field.agentNotifyToolInfo",keywords:["agent","tool","notify","notification","alert","ping","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-render-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentRenderTool",descriptionKey:"settings.openchamber.tools.field.agentRenderToolInfo",keywords:["agent","tool","render","page","html","chart","table","diagram","generative","ui","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-knowledge-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentKnowledgeTool",descriptionKey:"settings.openchamber.tools.field.agentKnowledgeToolInfo",keywords:["agent","tool","project","knowledge","notes","todos","plans","openchamber"],isAvailable:t=>!t.isVSCode},{id:"general.isolated-spaces",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.field.enabled",descriptionKey:"settings.openchamber.spaces.field.enabledInfo",keywords:["isolated","space","spaces","container","docker","sandbox","agent"],isAvailable:t=>!t.isVSCode&&uo},{id:"general.isolated-spaces-idle-stop",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.idleStop.enabled",descriptionKey:"settings.openchamber.spaces.idleStop.enabledInfo",keywords:["idle","stop","space","spaces","container","hours","timeout","sleep"],isAvailable:t=>!t.isVSCode&&uo&&oe.getState().isolatedSpacesEnabled},{id:"general.isolated-spaces-machine",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.places.machine.label",descriptionKey:"settings.openchamber.spaces.places.machine.info",keywords:["machine","ssh","remote","docker","space","spaces","host","server"],isAvailable:t=>!t.isVSCode&&uo&&oe.getState().isolatedSpacesEnabled},{id:"sessions.agent-memory-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentMemoryTool",descriptionKey:"settings.openchamber.tools.field.agentMemoryToolInfo",keywords:["agent","tool","memory","remember","recall","preferences","openchamber"],isAvailable:t=>!t.isVSCode&&oe.getState().agentMemoryFeatureAvailable},{id:"git.gitlab-account",page:"integrations",titleKey:"settings.gitlab.title",descriptionKey:"settings.gitlab.info",keywords:["gitlab","account","oauth","pat","merge request","issues","glab"],isAvailable:t=>!t.isVSCode},{id:"git.gitlab-connect",page:"integrations",titleKey:"settings.gitlab.actions.connect",keywords:["gitlab","connect","add account","oauth","pat","token","instance"],isAvailable:t=>!t.isVSCode},{id:"routing.token",page:"routing",titleKey:"settings.routing.token.label",descriptionKey:"settings.routing.token.info",keywords:["jev","typesafe","api key","token","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"sessions.agent-tools-code-mode",page:"general",titleKey:"settings.openchamber.tools.field.agentToolsCodeMode",descriptionKey:"settings.openchamber.tools.field.agentToolsCodeModeInfo",keywords:["agent","tool","code mode","codemode","execute","openchamber"],isAvailable:t=>!t.isVSCode},{id:"routing.enabled",page:"routing",titleKey:"settings.routing.auto.enable",descriptionKey:"settings.routing.auto.enableInfo",keywords:["auto","routing","model","jev","automatic"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.preserve-cache",page:"routing",titleKey:"settings.routing.auto.preserveCache",descriptionKey:"settings.routing.auto.preserveCacheInfo",keywords:["cache","prompt cache","auto","routing","switch","model","cost"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.fallback-model",page:"routing",titleKey:"settings.routing.auto.fallbackModel",descriptionKey:"settings.routing.auto.fallbackModelInfo",keywords:["fallback","default","model","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.add-category",page:"routing",titleKey:"settings.routing.categories.title",descriptionKey:"settings.routing.categories.description",keywords:["category","categories","task type","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"git.identities",page:"git",titleKey:"settings.gitIdentities.page.section.title",descriptionKey:"settings.gitIdentities.page.empty.description",keywords:["identity","profile","author","email","credentials","account","transport","ssh","ssh key","signing","commit signing","ssh signing","gpg"]},{id:"git.changes-view",page:"git",titleKey:"settings.openchamber.git.changesViewTitle",keywords:["changes","flat list","tree view"]},{id:"git.gitmoji",page:"git",titleKey:"settings.openchamber.git.enableGitmoji",keywords:["commit","emoji"]},{id:"git.gitignored-files",page:"git",titleKey:"settings.openchamber.git.showGitignored",keywords:["ignored","files","gitignore"]},{id:"usage.work-status-panel",page:"usage",titleKey:"settings.usage.page.options.showInWorkStatus",descriptionKey:"settings.usage.page.options.showInWorkStatusTooltip",keywords:["quota","work","status","panel"]},{id:"usage.model-quotas",page:"usage",titleKey:"settings.usage.page.section.modelQuotas",keywords:["models","quota","limits","tokens"]},{id:"projects.name",page:"projects",titleKey:"settings.projects.page.field.projectName",keywords:["label","display name","project metadata"]},{id:"projects.default-agent",page:"projects",titleKey:"settings.projects.page.field.projectAgent",keywords:["agent","default","new chat","project metadata"]},{id:"projects.default-model",page:"projects",titleKey:"settings.projects.page.field.projectModel",keywords:["model","default","new chat","project metadata"]},{id:"projects.default-thinking",page:"projects",titleKey:"settings.projects.page.field.projectThinking",keywords:["thinking","variant","reasoning","effort","model","project metadata"]},{id:"projects.icon",page:"projects",titleKey:"settings.projects.page.field.projectIcon",keywords:["icon","favicon","upload","color","accent color","appearance","project metadata"]},{id:"projects.actions",page:"projects",titleKey:"settings.projects.actions.title",descriptionKey:"settings.projects.actions.info",keywords:["run","run button","commands","dev server","scripts","project actions"]},{id:"projects.worktree",page:"projects",titleKey:"settings.projects.page.section.worktree",keywords:["worktree","branch","repository"]},{id:"projects.worktree.setup.wait",page:"projects",titleKey:"settings.openchamber.worktrees.setup.waitForCommands",keywords:["worktree","setup commands","bootstrap","wait"]},{id:"projects.worktree.setup.replace",page:"projects",titleKey:"settings.projects.shared.replaceMode",keywords:["worktree","setup commands","shared","team","only mine"]},{id:"projects.environment",page:"projects",titleKey:"settings.projects.environment.title",descriptionKey:"settings.projects.environment.info",keywords:["environment","env","variables","direnv","devenv","nix","envrc","path","terminal","git hooks"],isAvailable:t=>!t.isVSCode},{id:"projects.shared",page:"projects",titleKey:"settings.projects.team.title",descriptionKey:"settings.projects.team.info",keywords:["shared","team","repository",".openchamber","project.json","trust"]},{id:"projects.shared.plansDir",page:"projects",titleKey:"settings.projects.shared.plansDir",descriptionKey:"settings.projects.shared.plansDirInfo",keywords:["plans","folder","shared","team","docs"]},{id:"remote-instances.client-auth",page:"remote-instances",titleKey:"settings.remoteInstances.clientAuth.title",descriptionKey:"settings.remoteInstances.clientAuth.description",keywords:["pairing link","client token","connect desktop","remote access","relay","devices","connect from anywhere"],isAvailable:t=>!t.isVSCode},{id:"remote-instances.direct-hosts",page:"remote-instances",titleKey:"settings.remoteInstances.direct.title",descriptionKey:"settings.remoteInstances.direct.description",keywords:["server url","connection token","import link","host switcher","additional headers","request headers","cloudflare access","service token"],isAvailable:t=>t.isDesktop},{id:"behavior.system-prompt",page:"behavior",titleKey:"settings.behavior.page.section.systemPrompt",descriptionKey:"settings.behavior.page.warning.title",keywords:["agents.md","global instructions","system prompt"]},{id:"behavior.response-style",page:"behavior",titleKey:"settings.behavior.page.section.responseStyle",descriptionKey:"settings.behavior.page.responseStyle.tooltip",keywords:["tone","concise","detailed","custom instructions"]},{id:"agents.create",page:"agents",titleKey:"settings.agents.page.title.new",keywords:["create","add","new agent"]},{id:"agents.name",page:"agents",titleKey:"settings.agents.page.field.agentName",keywords:["agent","name"]},{id:"agents.mode",page:"agents",titleKey:"settings.agents.page.field.mode",descriptionKey:"settings.agents.page.field.modeTooltip",keywords:["primary","subagent","visibility"]},{id:"agents.color",page:"agents",titleKey:"settings.agents.page.field.color",descriptionKey:"settings.agents.page.field.colorTooltip",keywords:["colour","hex","accent"]},{id:"agents.model",page:"agents",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"agents.variant",page:"agents",titleKey:"settings.agents.page.field.variant",descriptionKey:"settings.agents.page.field.variantTooltip",keywords:["thinking","reasoning","variant","depth"]},{id:"agents.temperature",page:"agents",titleKey:"settings.agents.page.field.temperature",descriptionKey:"settings.agents.page.field.temperatureTooltip",keywords:["randomness","creative"]},{id:"agents.top-p",page:"agents",titleKey:"settings.agents.page.field.topP",descriptionKey:"settings.agents.page.field.topPTooltip",keywords:["sampling","nucleus"]},{id:"agents.system-prompt",page:"agents",titleKey:"settings.agents.page.section.systemPrompt",keywords:["prompt","instructions"]},{id:"agents.steps",page:"agents",titleKey:"settings.agents.page.field.steps",descriptionKey:"settings.agents.page.field.stepsTooltip",keywords:["steps","loop","tool calls"]},{id:"agents.permissions",page:"agents",titleKey:"settings.agents.page.section.toolPermissions",keywords:["tools","permissions","rules","allow","ask","deny"]},{id:"commands.create",page:"commands",titleKey:"settings.commands.page.title.new",keywords:["create","add","new command"]},{id:"commands.name",page:"commands",titleKey:"settings.commands.page.field.commandName",keywords:["slash command","name"]},{id:"commands.agent",page:"commands",titleKey:"settings.commands.page.field.overrideAgent",keywords:["agent","execution"]},{id:"commands.model",page:"commands",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"commands.variant",page:"commands",titleKey:"settings.agents.page.field.variant",keywords:["variant","reasoning","thinking"]},{id:"commands.subagent",page:"commands",titleKey:"settings.commands.page.field.subagent",descriptionKey:"settings.commands.page.field.subagentTooltip",keywords:["subagent","background","child session"]},{id:"commands.template",page:"commands",titleKey:"settings.commands.page.section.template",keywords:["prompt","template","arguments","shell","file"]},{id:"mcp.create",page:"mcp",titleKey:"settings.mcp.sidebar.actions.addServerTitle",keywords:["create","add","server"]},{id:"mcp.server",page:"mcp",titleKey:"settings.mcp.page.server.title",keywords:["server","name","transport"]},{id:"mcp.command",page:"mcp",titleKey:"settings.mcp.page.connection.command",keywords:["stdio","local","command"]},{id:"mcp.environment",page:"mcp",titleKey:"settings.mcp.page.env.title",keywords:["env","variables","api key"]},{id:"mcp.advanced",page:"mcp",titleKey:"settings.mcp.page.advanced.title",keywords:["oauth","headers","timeout","code mode","codemode"]},{id:"plugins.create",page:"plugins",titleKey:"settings.plugins.sidebar.actions.addTitle",keywords:["add","plugin","npm","path","file"]},{id:"plugins.spec",page:"plugins",titleKey:"settings.plugins.page.field.spec",keywords:["npm","package","path"]},{id:"plugins.options",page:"plugins",titleKey:"settings.plugins.page.field.options",keywords:["json","configuration"]},{id:"plugins.content",page:"plugins",titleKey:"settings.plugins.page.field.content",keywords:["file","code"]},{id:"snippets.create",page:"snippets",titleKey:"settings.snippets.sidebar.actions.create",keywords:["add","new snippet"]},{id:"snippets.content",page:"snippets",titleKey:"settings.snippets.page.field.content",keywords:["markdown","prompt","template"]},{id:"providers.connect",page:"providers",titleKey:"settings.providers.page.connect.title",keywords:["add provider","connect provider","credentials"]},{id:"providers.classification",page:"providers",titleKey:"settings.classification.page.title",descriptionKey:"settings.classification.page.description",keywords:["jev","typesafe","zen","api key","token","safety net","auto","routing","classification","promotion","off","disable","privacy","custom endpoint","base url","openai-compatible","system one","self-hosted","proxy"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"providers.custom",page:"providers",titleKey:"settings.providers.page.custom.title",descriptionKey:"settings.providers.page.custom.description",keywords:["other","custom","openai-compatible","base url","api key"]},{id:"providers.auth",page:"providers",titleKey:"settings.providers.accounts.title",keywords:["api key","oauth","credentials","accounts","switch account","disconnect"]},{id:"providers.models",page:"providers",titleKey:"settings.providers.page.models.title",keywords:["models","hide","show"]},{id:"web-search.provider",page:"web-search",titleKey:"settings.webSearch.section.provider",descriptionKey:"settings.webSearch.section.providerInfo",keywords:["web search","websearch","internet","default provider","disable","off","random"]},{id:"web-search.keys",page:"web-search",titleKey:"settings.webSearch.section.keys",keywords:["api key","exa","tavily","firecrawl","parallel","tinyfish","credentials"]},{id:"skills.create",page:"skills.installed",titleKey:"settings.skills.page.title.newSkill",keywords:["create","add","new skill"]},{id:"skills.basic-information",page:"skills.installed",titleKey:"settings.skills.page.section.basicInformation",keywords:["name","location","description","manual","invocation","autoinvoke"]},{id:"skills.instructions",page:"skills.installed",titleKey:"settings.skills.page.section.instructions",keywords:["markdown","skill.md","content"]},{id:"skills.supporting-files",page:"skills.installed",titleKey:"settings.skills.page.section.supportingFiles",keywords:["files","resources"]},{id:"skills.catalog.source",page:"skills.catalog",titleKey:"settings.skills.catalog.page.section.sourceRepository",keywords:["catalog","repository","source","refresh"]},{id:"skills.catalog.search",page:"skills.catalog",titleKey:"settings.skills.catalog.shared.field.searchSkillsPlaceholder",keywords:["find skills","install skills","catalog search"]},{id:"skills.catalog.add-catalog",page:"skills.catalog",titleKey:"settings.skills.catalog.page.actions.addCatalog",keywords:["external repository","add source","catalog"]},{id:"magic-prompts.visible-prompt",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.visiblePrompt",keywords:["prompt text","user message","template"],isAvailable:t=>!t.isVSCode},{id:"magic-prompts.instructions",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.instructions",keywords:["hidden prompt","instructions","template"],isAvailable:t=>!t.isVSCode},{id:"magic-prompts.reset-overrides",page:"magic-prompts",titleKey:"settings.magicPrompts.page.actions.resetAllOverrides",keywords:["reset","default prompts","overrides"],isAvailable:t=>!t.isVSCode},{id:"shortcuts.keyboard-shortcuts",page:"shortcuts",titleKey:"settings.openchamber.keyboardShortcuts.title",descriptionKey:"settings.openchamber.keyboardShortcuts.tooltip",keywords:["keyboard","hotkeys","bindings"]},{id:"voice.playback",page:"voice",titleKey:"settings.voice.page.section.playbackAndSummary",keywords:["tts","read aloud","voice","provider","speech rate","speech pitch","speech volume","tts input mode","markdown"]},{id:"voice.speech-recognition",page:"voice",titleKey:"settings.voice.page.section.speechRecognition",keywords:["stt","dictation","voice input","transcribe","whisper","parakeet","microphone"]},{id:"tunnel.provider",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.provider",descriptionKey:"settings.openchamber.tunnel.description",keywords:["remote access","cloudflare","ngrok"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.type",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.tunnelType",keywords:["quick","managed remote","managed local"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.ttl",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.connectLinkTtl",descriptionKey:"settings.openchamber.tunnel.field.tunnelSessionTtl",keywords:["expiry","expiration","session ttl","connect link ttl"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.managed-remote",page:"tunnel",titleKey:"settings.openchamber.tunnel.section.savedManagedRemoteTunnels",keywords:["cloudflare","hostname","token","managed remote"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.managed-local-config",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.configurationFile",descriptionKey:"settings.openchamber.tunnel.note.managedLocalUsesConfig",keywords:["cloudflared","config","yaml","json","managed local"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.start",page:"tunnel",titleKey:"settings.openchamber.tunnel.actions.startTunnel",descriptionKey:"settings.openchamber.tunnel.note.connectLinksOneTime",keywords:["connect link","qr code","public url","remote access"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"notifications.delivery",page:"notifications",titleKey:"settings.notifications.page.delivery.title",keywords:["desktop notifications","system notifications"]},{id:"notifications.events",page:"notifications",titleKey:"settings.notifications.page.events.title",keywords:["completion","subtasks","errors","questions"]},{id:"notifications.push",page:"notifications",titleKey:"settings.notifications.page.push.title",keywords:["background","push"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"integrations.first-party",page:"integrations",titleKey:"settings.integrations.firstParty.title",descriptionKey:"settings.integrations.firstParty.info",keywords:["built-in","first-party","native","github","linear"],isAvailable:t=>!t.isVSCode},{id:"integrations.github",page:"integrations",titleKey:"settings.integrations.github.title",descriptionKey:"settings.integrations.github.description",keywords:["github","account","oauth","gh","cli","prs","pull request","issues","connect"],isAvailable:t=>!t.isVSCode},{id:"git.github-connect",page:"integrations",titleKey:"settings.github.page.actions.connect",keywords:["github","connect","add account","oauth","device flow"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear",page:"integrations",titleKey:"settings.integrations.linear.title",descriptionKey:"settings.integrations.linear.description",keywords:["linear","issues","oauth","connect","workspace"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.add-workspace",page:"integrations",titleKey:"settings.integrations.linear.actions.addWorkspace",descriptionKey:"settings.integrations.linear.description",keywords:["linear","workspace","add","connect","oauth"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.mapping",page:"integrations",titleKey:"settings.integrations.linear.mapping.defaultProject",descriptionKey:"settings.integrations.linear.mapping.defaultProject.info",keywords:["linear","project","team","map","workspace","directory"],isAvailable:t=>!t.isVSCode},{id:"integrations.third-party",page:"integrations",titleKey:"settings.integrations.thirdParty.title",descriptionKey:"settings.integrations.thirdParty.info",keywords:["plugin","provider","install","update","remove","subscription"],isAvailable:t=>!t.isVSCode},{id:"integrations.third-party.opencode-claude",page:"integrations",titleKey:"settings.integrations.thirdParty.opencodeClaude.name",descriptionKey:"settings.integrations.thirdParty.opencodeClaude.description",keywords:["claude","anthropic","claude code","pro","max","agent sdk","@openchamber/opencode-claude"],isAvailable:t=>!t.isVSCode},{id:"integrations.extensions",page:"integrations",titleKey:"settings.integrations.extensionCatalog.title",descriptionKey:"settings.integrations.extensionCatalog.info",keywords:["extension","install","update","remove","openchamber"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.extensions.excalidraw",page:"integrations",titleKey:"settings.integrations.extensionCatalog.excalidraw.name",descriptionKey:"settings.integrations.extensionCatalog.excalidraw.description",keywords:["excalidraw","drawing","diagram","canvas","whiteboard","obsidian","sketch"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.guests",page:"integrations",titleKey:"settings.integrations.guests.title",descriptionKey:"settings.integrations.guests.info",keywords:["guest","extension","oauth","clickup","gitlab","panel","connect"],isAvailable:t=>!t.isVSCode},{id:"extensions.add",page:"extensions",titleKey:"settings.extensions.add.label",descriptionKey:"settings.extensions.add.info",keywords:["folder","path","zip","git","url","install","guest","panel"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.gitIdentity",page:"extensions",titleKey:"settings.extensions.identity.title",descriptionKey:"settings.extensions.add.info",keywords:["ssh","key","identity","git","private","clone","extension"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.updates.check",page:"extensions",titleKey:"settings.extensions.updates.check",keywords:["update","upgrade","version","git","extension","guest","refresh"],isAvailable:t=>!t.isVSCode&&!t.isMobile}];function Rd(t){return t.trim().toLocaleLowerCase()}function mS({query:t,runtimeCtx:e,visiblePageSlugs:a,t:n,getPageTitle:o}){const i=Rd(t);if(!i)return[];const r=a?new Set(a):null,l=i.split(/\s+/).filter(Boolean);return uS.flatMap(u=>{if(r&&!r.has(u.page))return[];const m=za(u.page);if(!m||m.isAvailable&&!m.isAvailable(e)||u.isAvailable&&!u.isAvailable(e))return[];const d=n(u.titleKey),f=u.descriptionKey?n(u.descriptionKey):null,g=Rd([d,f,o(u.page),...u.keywords??[]].filter(Boolean).join(" "));return l.every(p=>g.includes(p))?[{...u,title:d,description:f,pageTitle:o(u.page)}]:[]})}const Fd=280,pS=32,Nm="__openchamberSettingsDetail",gS=30,fS=["general","appearance","chat","notifications","sessions","routing","shortcuts","voice","integrations","extensions","usage","about","projects","remote-instances","tunnel","git","isolated-spaces","providers","web-search","agents","behavior","commands","mcp","plugins","magic-prompts","snippets","skills.installed","skills.catalog"],hS=["general","projects","opencode","content"];function bS(t,e,a,n,o){const i=cs(),r=!t&&ca();return{isVSCode:i,isWeb:r,isDesktop:t,isMobile:e,routingAvailable:a,enterpriseMode:n,jevBlockedByEnterprise:o}}function Od(t,e){return t.isAvailable?t.isAvailable(e):!0}function vi(t,e){const a=new Set(e);let n=t,o=1;for(;a.has(n);)n=`${t}-${o}`,o+=1;return n}function Br(t){const e=t?.[Nm];return e?.page==null||e.stage!=="page-content"?null:{page:Gr(e.page),stage:e.stage}}function xS(){return window.history.state??{}}const LS=({onClose:t,forceMobile:e,isWindowed:a,visiblePageSlugs:n,initialMobileStage:o="nav",registerBackHandler:i})=>{const{t:r}=ze(),l=Fn(),u=e??l.isMobile,m=oe(pe=>pe.settingsPage),d=oe(pe=>pe.isSettingsDialogOpen),f=oe(pe=>pe.setSettingsPage),g=oe(pe=>pe.shortcutOverrides.open_settings),p=Gr(m),[h,w]=c.useState(o),b=c.useRef(o==="nav"?p:null);c.useEffect(()=>{!u&&p==="home"&&f("general")},[u,f,p]);const[k,v]=c.useState(""),[S,y]=c.useState(null),[N,x]=c.useState(0),I=c.useRef(null),j=c.useRef(!1),D=c.useRef([]),C=c.useRef(0),P=c.useRef(!1),A=c.useMemo(()=>as(),[]),R=c.useMemo(()=>as()&&Qa(),[]),K=c.useMemo(()=>as()&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),F=c.useMemo(()=>as()&&window.__OPENCHAMBER_PLATFORM__==="win32",[]),T=c.useMemo(()=>as()&&window.__OPENCHAMBER_PLATFORM__==="linux",[]),O=oe(pe=>pe.routingFeatureAvailable),E=Ln(),B=vg(),_=c.useMemo(()=>bS(A,u,O,E,B),[A,u,O,E,B]),H=c.useMemo(()=>{const pe=n?new Set(n):null;return yf.filter(xe=>xe.slug!=="home").filter(xe=>!pe||pe.has(xe.slug)).filter(xe=>Od(xe,_)).filter(xe=>!(_.isVSCode&&xe.slug==="projects")).filter(xe=>!(u&&xe.slug==="shortcuts"))},[_,u,n]),ne=c.useMemo(()=>{const pe=new Map(fS.map((xe,Ne)=>[xe,Ne]));return H.slice().sort((xe,Ne)=>(pe.get(xe.slug)??999)-(pe.get(Ne.slug)??999))},[H]),z=un(pe=>pe.activeProjectId),$=Us();c.useEffect(()=>{if(!(!d&&!_.isVSCode&&!a)){if(p==="agents"){hn.getState().loadAgents($);return}if(p==="commands"){qa.getState().loadCommands($);return}if(p==="mcp"){An.getState().loadMcpConfigs({directory:$});return}if(p==="plugins"){Lt.getState().loadPlugins();return}(p==="skills.installed"||p==="skills.catalog")&&(Ws.getState().loadSkills($),fn.getState().loadCatalog()),p==="snippets"&&vo.getState().loadSnippets()}},[z,d,a,_.isVSCode,$,p]);const V=c.useCallback(pe=>{if(f(pe),b.current=pe,!u)return;const xe=za(pe);if(!xe||xe.slug==="home"){w("nav");return}w(xe.kind==="split"?"page-sidebar":"page-content")},[u,f]),G=c.useMemo(()=>za(p),[p]),ee=c.useMemo(()=>({general:"general",appearance:"visual",chat:"chat",shortcuts:"shortcuts",sessions:"sessions",notifications:"notifications",voice:"voice",tunnel:"tunnel","isolated-spaces":"spaces"}),[]),ae=c.useCallback(pe=>{switch(pe){case"general":return r("settings.page.general.title");case"projects":return r("settings.page.projects.title");case"remote-instances":return r("settings.page.remoteInstances.title");case"providers":return r("settings.page.providers.title");case"web-search":return r("settings.page.webSearch.title");case"usage":return r("settings.page.usage.title");case"agents":return r("settings.page.agents.title");case"behavior":return r("settings.page.behavior.title");case"commands":return r("settings.page.commands.title");case"mcp":return r("settings.page.mcp.title");case"plugins":return r("settings.page.plugins.title");case"skills.installed":return r("settings.page.skills.title");case"skills.catalog":return r("settings.page.skillsCatalog.title");case"git":return r("settings.page.git.title");case"integrations":return r("settings.page.integrations.title");case"extensions":return r("settings.page.extensions.title");case"appearance":return r("settings.page.appearance.title");case"chat":return r("settings.page.chat.title");case"shortcuts":return r("settings.page.shortcuts.title");case"sessions":return r("settings.page.sessions.title");case"routing":return r("settings.page.routing.title");case"magic-prompts":return r("settings.page.magicPrompts.title");case"snippets":return r("settings.page.snippets.title");case"notifications":return r("settings.page.notifications.title");case"voice":return r("settings.page.voice.title");case"tunnel":return r("settings.page.tunnel.title");case"isolated-spaces":return r("settings.openchamber.spaces.title");case"about":return r("settings.page.about.title");default:return r("settings.view.home.title")}},[r]),X=c.useMemo(()=>mS({query:k,runtimeCtx:{..._,isDesktopLocalOrigin:R,isMac:K,isWindows:F,isLinux:T},visiblePageSlugs:n,t:r,getPageTitle:ae}),[ae,R,K,F,T,_,k,r,n]),Q=c.useCallback(pe=>{if(pe.id.startsWith("agents.")){const Ne=hn.getState(),de=vi("new-agent",Ne.agents.map(Ue=>Ue.name));return Ne.setAgentDraft({name:de,scope:"user"}),Ne.setSelectedAgent(de),pe.id==="agents.create"?"agents.name":pe.id}if(pe.id.startsWith("commands.")){const Ne=qa.getState(),de=vi("new-command",Ne.commands.map(Ue=>Ue.name));return Ne.setCommandDraft({name:de,scope:"user"}),Ne.setSelectedCommand(de),pe.id==="commands.create"?"commands.name":pe.id}if(pe.id.startsWith("mcp.")){const Ne=An.getState(),de=vi("new-mcp-server",Ne.mcpServers.map(Ue=>Ue.name));return Ne.setMcpDraft({name:de,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),Ne.setSelectedMcp(de),pe.id==="mcp.create"?"mcp.server":pe.id}if(pe.id.startsWith("snippets.")){const Ne=vo.getState(),de=vi("new-snippet",Ne.snippets.map(Ue=>Ue.name));return Ne.setSnippetDraft({name:de,scope:"global"}),Ne.setSelectedSnippet(de),pe.id==="snippets.create"?"snippets.content":pe.id}if(pe.id.startsWith("skills.")){const Ne=Ws.getState(),de=vi("new-skill",Ne.skills.map(Ue=>Ue.name));return Ne.setSkillDraft({name:de,scope:"user",source:"opencode",description:"",instructions:""}),Ne.setSelectedSkill(de),pe.id==="skills.create"?"skills.basic-information":pe.id}if(pe.id==="providers.connect"&&oe.getState().setSettingsProvidersConnectRequested(!0),pe.id==="providers.classification"&&oe.getState().setSettingsProvidersClassificationRequested(!0),pe.id==="plugins.create")return"plugins.spec";const xe=Yf(pe.id);return xe&&Yr.getState().setTab(xe),pe.id},[]),le=c.useMemo(()=>{const pe=[],xe=new Map;for(const Ne of X){let de=xe.get(Ne.page);de||(de={page:Ne.page,pageTitle:Ne.pageTitle,results:[]},xe.set(Ne.page,de),pe.push(de)),de.results.push(Ne)}return pe},[X]);c.useEffect(()=>{x(0),C.current=0,P.current=!1},[k]),c.useEffect(()=>{C.current=N},[N]),c.useEffect(()=>{D.current[N]?.scrollIntoView({block:"nearest"})},[N]),c.useEffect(()=>{N>=X.length&&x(Math.max(0,X.length-1)),D.current.length=X.length},[N,X.length]);const Z=c.useCallback(pe=>{const xe=Q(pe);y(xe),V(pe.page),u&&w("page-content"),pe.id==="plugins.create"&&window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("openchamber:settings-open-plugin-add"))},50)},[u,V,Q]),fe=c.useCallback(pe=>{if(k.trim()){if(pe.key==="Escape"){pe.preventDefault(),v("");return}if(X.length!==0){if(pe.key==="ArrowDown"){pe.preventDefault(),P.current=!0,x(xe=>(xe+1)%X.length);return}if(pe.key==="ArrowUp"){pe.preventDefault(),P.current=!0,x(xe=>(xe-1+X.length)%X.length);return}if(pe.key==="Enter"){pe.preventDefault();const xe=(C.current%X.length+X.length)%X.length,Ne=X[xe]??X[0];Ne&&Z(Ne)}}}},[Z,k,X]),Y=oe(pe=>pe.settingsJumpRequest);c.useEffect(()=>{Y&&(oe.getState().clearSettingsJumpRequest(),y(Y.itemId),V(Gr(Y.page)),u&&w("page-content"))},[u,V,Y]),c.useEffect(()=>{const pe=S;if(!pe)return;let xe=!1,Ne=0,de=0;const Ue=()=>{if(xe)return;const Ie=globalThis.CSS?.escape?globalThis.CSS.escape(pe):pe.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),De=I.current?.querySelector(`[data-settings-item="${Ie}"]`);if(!De){Ne+=1,Ne<gS&&(de=window.requestAnimationFrame(Ue));return}y(null),De.scrollIntoView({block:"center",behavior:"smooth"}),De.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{De.removeAttribute("data-settings-search-highlight")},1600)};return de=window.requestAnimationFrame(Ue),()=>{xe=!0,window.cancelAnimationFrame(de)}},[S,p]);const be=c.useCallback(()=>s.jsx("div",{className:"flex h-full items-center justify-center px-6",children:s.jsxs("div",{className:"max-w-md text-center",children:[s.jsx("div",{className:On,children:r("settings.view.unavailable.title")}),s.jsx("p",{className:"typography-ui text-muted-foreground mt-1",children:r("settings.view.unavailable.description")})]})}),[r]),Ee=c.useCallback((pe,xe)=>{switch(pe){case"projects":return s.jsx(kv,{onItemSelect:xe.onItemSelect});case"agents":return s.jsx(ah,{onItemSelect:xe.onItemSelect});case"commands":return s.jsx(qh,{onItemSelect:xe.onItemSelect});case"skills.installed":return s.jsx(Mx,{onItemSelect:xe.onItemSelect});case"usage":return s.jsx(h1,{onItemSelect:xe.onItemSelect});case"magic-prompts":return s.jsx(K1,{onItemSelect:xe.onItemSelect});case"snippets":return s.jsx(B1,{onItemSelect:xe.onItemSelect});default:return null}},[]),se=c.useCallback(pe=>{const xe=za(pe);if(xe&&!Od(xe,_))return be();switch(pe){case"projects":return s.jsx(Iv,{});case"remote-instances":return s.jsx(ty,{});case"agents":return s.jsx(Ph,{});case"behavior":return s.jsx(Rh,{});case"commands":return s.jsx(Xh,{});case"mcp":return s.jsx(Ob,{});case"plugins":return s.jsx(gx,{});case"skills.installed":return s.jsx(Ec,{view:"installed"});case"skills.catalog":return s.jsx(Ec,{view:"catalog"});case"providers":return s.jsx(g1,{});case"web-search":return s.jsx(zh,{});case"usage":return s.jsx(O1,{});case"about":return s.jsx(Yt,{title:r("settings.page.about.title"),showSaveStatus:!1,children:s.jsx(hu,{})});case"magic-prompts":return s.jsx($1,{});case"snippets":return s.jsx(q1,{});case"git":return s.jsx(Z1,{});case"integrations":return s.jsx(Wj,{});case"routing":return s.jsx(tk,{});case"extensions":return s.jsx(gk,{});case"general":case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"voice":case"tunnel":case"isolated-spaces":{const Ne=ee[pe]??"visual";return s.jsx(X2,{section:Ne})}default:return null}},[ee,be,_,r]);c.useEffect(()=>{if(!u||h!=="nav"||p==="home"||b.current===p)return;const pe=za(p);!pe||pe.slug==="home"||(b.current=p,w(pe.kind==="split"?"page-sidebar":"page-content"))},[u,h,p]);const re=u&&h!=="nav",je=u&&h==="page-content"&&G?.kind==="split",ie=r(je?"settings.view.actions.back":re?"settings.view.actions.backToSettings":"settings.view.actions.closeSettings"),Pe=su("open_settings",g===void 0?void 0:{open_settings:g}),ke=Pe?r("settings.view.actions.closeSettingsWithShortcut",{shortcut:Rn(Pe)}):r("settings.view.actions.closeSettings"),Ae=c.useCallback(pe=>{if(_.isVSCode)return;const xe=Br(window.history.state);xe?.page===pe&&xe.stage==="page-content"||window.history.pushState({...xS(),[Nm]:{page:pe,stage:"page-content"}},"",window.location.href)},[_.isVSCode]),Te=c.useCallback(()=>{j.current=!0,w("page-content"),Ae(p)},[Ae,p]);c.useEffect(()=>{if(!u||h!=="page-content"||!j.current)return;j.current=!1;const pe=window.requestAnimationFrame(()=>{I.current?.querySelector("[data-settings-page-heading]")?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(pe)}},[u,h,p]);const Ke=c.useCallback(()=>{if(je){if(Br(window.history.state)?.page===p&&!_.isVSCode){window.history.back();return}w("page-sidebar");return}w("nav")},[je,_.isVSCode,p]);c.useEffect(()=>{if(i)return i(()=>!u||h==="nav"?!1:(Ke(),!0)),()=>i(null)},[Ke,u,h,i]),c.useEffect(()=>{if(!u||_.isVSCode)return;const pe=xe=>{if(za(p)?.kind!=="split")return;if(Br(xe.state)?.page===p){w("page-content");return}w(de=>de==="page-content"?"page-sidebar":de)};return window.addEventListener("popstate",pe),()=>{window.removeEventListener("popstate",pe)}},[u,_.isVSCode,p]);const ge=()=>{const pe=k.trim().length>0;return s.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"px-4 pt-3",children:s.jsxs("div",{className:"oc-surface-elevated flex h-10 items-center gap-1.5 rounded-md border border-border bg-surface-elevated/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-ring sm:h-8",children:[s.jsx(J,{name:"search",className:"h-4 w-4 shrink-0"}),s.jsx("input",{value:k,onChange:xe=>v(xe.target.value),onKeyDown:fe,placeholder:r("settings.view.search.placeholder"),"aria-label":r("settings.view.search.aria"),className:"typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70"}),pe&&s.jsx("button",{type:"button",onClick:()=>v(""),"aria-label":r("settings.view.search.clear"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5",children:s.jsx(J,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsx(Ts,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx("div",{className:"flex flex-col gap-0.5 px-4 pt-4 pb-2",children:pe?X.length>0?(()=>{let xe=0;return le.map(Ne=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70",children:Ne.pageTitle}),Ne.results.map(de=>{const Ue=xe;xe+=1;const Ie=Ue===N,De=!!de.description;return s.jsxs("button",{type:"button",ref:Je=>{D.current[Ue]=Je},onMouseMove:()=>{P.current=!1,x(Ue)},onClick:()=>Z(de),className:Me("flex w-full flex-col rounded-md px-2 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",De?"min-h-11 py-1.5":"py-2",Ie?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:de.title}),De&&s.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:de.description})]},de.id)})]},Ne.page))})():s.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:r("settings.view.search.noResults")}):(()=>{const xe=new Map;for(const de of ne){const Ue=de.group,Ie=xe.get(Ue);Ie?Ie.push(de):xe.set(Ue,[de])}return hS.map(de=>({group:de,pages:xe.get(de)??[]})).filter(de=>de.pages.length>0).map(({group:de,pages:Ue},Ie)=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:Me("px-3 pb-1 typography-micro font-semibold uppercase tracking-wide text-muted-foreground sm:px-2 sm:pb-0.5",Ie===0?"pt-1":"pt-4 sm:pt-3"),children:r(`settings.view.nav.group.${de}`)}),Ue.map(De=>{const Je=p===De.slug&&!(u&&h==="nav"),tt=jf(De.slug);return!tt&&De.slug!=="mcp"?null:s.jsx(eu,{children:s.jsx(tu,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>V(De.slug),"aria-current":Je?"page":void 0,className:Me("flex h-11 w-full items-center gap-2.5 rounded-md px-3 overflow-hidden sm:h-8 sm:gap-2 sm:px-2",Je?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[De.slug==="mcp"?s.jsx(yg,{className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}):s.jsx(J,{name:tt,className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}),s.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap overflow-hidden transition-opacity duration-150 opacity-100",children:[s.jsx("span",{className:"typography-ui-label font-normal truncate",children:ae(De.slug)}),De.slug==="tunnel"&&s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:r("settings.view.badge.beta")})]})]})})},De.slug)})]},de))})()})})]})},Re=()=>{if(h==="nav")return s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx(Qn,{children:ge()})})});if(!G)return s.jsx("div",{className:"flex-1 bg-background"});if(h==="page-sidebar"){if(G.kind!=="split"){const xe=se(p);return s.jsx(Ts,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Qn,{children:xe})})}return s.jsx(Ts,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Qn,{children:Ee(p,{onItemSelect:Te})})})}const pe=se(p);return s.jsx(Ts,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Qn,{children:pe})})},Oe=()=>{if(!G||p==="home")return null;const pe=t?pS:0,xe=s.jsx(kf.Provider,{value:pe,children:s.jsx(Qn,{children:se(p)})});return G.kind==="split"?s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[s.jsx("div",{className:Me("border-e",_.isVSCode?"bg-background":"bg-sidebar"),style:{width:Fd,minWidth:Fd,borderColor:"var(--interactive-border)"},children:s.jsx(Qn,{children:Ee(p,{})})}),s.jsx(Ts,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,verticalTrackStart:pe,children:xe})]}):s.jsx(Ts,{outerClassName:"h-full min-h-0",className:"bg-background",disableHorizontal:!0,verticalTrackStart:pe,children:xe})};return s.jsxs("div",{ref:I,"data-settings-view":"true",className:Me("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),children:[u?s.jsxs("div",{className:Me("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",h!=="nav"&&"border-b","bg-background"),style:h!=="nav"?{borderColor:"var(--interactive-border)"}:void 0,children:[re?s.jsx("button",{type:"button",onClick:Ke,"aria-label":ie,className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(J,{name:"arrow-left-s",className:"h-5 w-5"})}):null,s.jsx("div",{className:"min-w-0 flex-1 px-2 typography-ui-label font-medium text-foreground truncate",children:h==="nav"?r("settings.view.home.title"):G?ae(G.slug):r("settings.view.home.title")}),t&&s.jsx("button",{type:"button",onClick:t,"aria-label":r("settings.view.actions.closeSettings"),title:ke,className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(J,{name:"close",className:"h-5 w-5"})})]}):s.jsxs(s.Fragment,{children:[re&&s.jsx("div",{className:Me("absolute inset-s-3 z-50",a?"top-2":"top-3"),children:s.jsx("button",{type:"button",onClick:Ke,"aria-label":r("settings.view.actions.back"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(J,{name:"arrow-left-s",className:"h-5 w-5"})})}),t&&s.jsx("div",{className:Me("absolute inset-e-0.5 z-50",a?"top-0.5":"top-1"),children:s.jsx("button",{type:"button",onClick:t,"aria-label":r("settings.view.actions.closeSettings"),title:ke,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(J,{name:"close",className:"h-5 w-5"})})})]}),s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:u?Re():s.jsxs(s.Fragment,{children:[s.jsx("div",{className:Me("relative flex h-full min-h-0 w-36 min-w-36 flex-col overflow-hidden border-e sm:w-64 sm:min-w-64",A?"bg-sidebar":_.isVSCode?"bg-background":"bg-sidebar"),style:{borderColor:"var(--interactive-border)"},children:s.jsx(Qn,{children:ge()})}),s.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:Oe()})]})})]})};export{hu as A,LS as S};
|