@openchamber/web 1.13.3 → 1.13.4
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/bin/cli-output.js +0 -7
- package/bin/cli.js +132 -5548
- package/bin/cli.test.js +674 -0
- package/bin/lib/DOCUMENTATION.md +121 -0
- package/bin/lib/cli-args.js +726 -0
- package/bin/lib/cli-errors.js +18 -0
- package/bin/lib/cli-executables.js +54 -0
- package/bin/lib/cli-http.js +215 -0
- package/bin/lib/cli-lifecycle.js +421 -0
- package/bin/lib/cli-log-files.js +93 -0
- package/bin/lib/cli-network.js +153 -0
- package/bin/lib/cli-paths.js +111 -0
- package/bin/lib/cli-ports.js +51 -0
- package/bin/lib/cli-process.js +292 -0
- package/bin/lib/cli-startup.js +370 -0
- package/bin/lib/cli-tunnel-capabilities.js +9 -0
- package/bin/lib/cli-tunnel-profiles.js +366 -0
- package/bin/lib/cli-tunnel-utils.js +300 -0
- package/bin/lib/commands-connect-url.js +173 -0
- package/bin/lib/commands-lifecycle.js +396 -0
- package/bin/lib/commands-logs.js +110 -0
- package/bin/lib/commands-serve.js +396 -0
- package/bin/lib/commands-startup.js +64 -0
- package/bin/lib/commands-status.js +114 -0
- package/bin/lib/commands-tunnel.js +1757 -0
- package/bin/lib/commands-update.js +141 -0
- package/dist/assets/{DiagramView-BmHROYsX.js → DiagramView-BAoYIAGR.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DiJE-v5Q.js → MarkdownRendererImpl-B0NE4mIY.js} +3 -3
- package/dist/assets/MultiRunWindow-BT4kt6aB.js +1 -0
- package/dist/assets/NewWorktreeDialog-Bx-zQyBp.js +167 -0
- package/dist/assets/{OnboardingScreen-DpBF8dKJ.js → OnboardingScreen-CbJOPUxm.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-1xaHUxPK.js → SessionSwitcherDropdown-BbUzUNEi.js} +1 -1
- package/dist/assets/{SettingsWindow-ChwLyQAe.js → SettingsWindow-CSb8eo8p.js} +1 -1
- package/dist/assets/{TerminalView-DGEBNuAp.js → TerminalView-ME5MOz7S.js} +1 -1
- package/dist/assets/es-Bk-yR0w-.js +15 -0
- package/dist/assets/fr-f1ibV7QU.js +13 -0
- package/dist/assets/index-B82A6jBD.css +1 -0
- package/dist/assets/index-BsXkdBYx.js +3 -0
- package/dist/assets/ja-D9mS3zWP.js +15 -0
- package/dist/assets/ko-Cpl1IA3D.js +15 -0
- package/dist/assets/{main-fm_8J7Lk.js → main-D6eC2bnV.js} +2 -2
- package/dist/assets/main-fsOGbLGZ.js +214 -0
- package/dist/assets/miniChat-DKGU29GZ.js +2 -0
- package/dist/assets/mobile-YHQHMYWC.js +2 -0
- package/dist/assets/pl-CYke_fxL.js +15 -0
- package/dist/assets/pt-BR-Clb6Z8up.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-3vxeddJO.js +2 -0
- package/dist/assets/{renderMobileApp-6s0G1iIJ.js → renderMobileApp-BrvLHYCY.js} +5 -5
- package/dist/assets/uk-CXn8cxXa.js +15 -0
- package/dist/assets/{useAppFontEffects-CV5C5O0r.js → useAppFontEffects-b7bqtGFf.js} +124 -119
- package/dist/assets/{vendor-.bun-CC_Xso_s.js → vendor-.bun-By2L9XvG.js} +1 -1
- package/dist/assets/zh-CN-BRwwlEdG.js +15 -0
- package/dist/assets/zh-TW-D5pg5Z8l.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +1 -1
- package/server/lib/cloudflare-tunnel.js +2 -2
- package/server/lib/event-stream/global-hub.js +1 -1
- package/server/lib/event-stream/index.js +0 -12
- package/server/lib/event-stream/runtime.js +1 -1
- package/server/lib/git/service.js +18 -0
- package/server/lib/git/service.test.js +48 -0
- package/server/lib/notifications/index.js +1 -4
- package/server/lib/opencode/agents.js +0 -6
- package/server/lib/opencode/commands.js +0 -5
- package/server/lib/opencode/config-entity-routes.js +39 -21
- package/server/lib/opencode/feature-routes-runtime.js +27 -62
- package/server/lib/opencode/lifecycle.js +13 -1
- package/server/lib/opencode/npm-registry.js +3 -3
- package/server/lib/opencode/proxy.js +3 -3
- package/server/lib/opencode/shared.js +0 -6
- package/server/lib/opencode/skills.js +0 -2
- package/server/lib/opencode/snippets.js +0 -2
- package/server/lib/package-manager.js +5 -5
- package/server/lib/projects/project-config.js +0 -8
- package/server/lib/quota/DOCUMENTATION.md +3 -1
- package/server/lib/quota/providers/claude.js +1 -1
- package/server/lib/quota/providers/codex.js +1 -1
- package/server/lib/quota/providers/copilot.js +1 -1
- package/server/lib/quota/providers/cursor.js +1 -1
- package/server/lib/quota/providers/google/auth.js +2 -2
- package/server/lib/quota/providers/google/index.js +0 -27
- package/server/lib/quota/providers/google/transforms.js +1 -1
- package/server/lib/quota/providers/index.js +1 -1
- package/server/lib/quota/providers/kimi.js +1 -1
- package/server/lib/quota/providers/minimax-cn-coding-plan.js +1 -1
- package/server/lib/quota/providers/minimax-coding-plan.js +1 -1
- package/server/lib/quota/providers/nanogpt.js +1 -1
- package/server/lib/quota/providers/ollama-cloud.js +1 -1
- package/server/lib/quota/providers/openai.js +4 -4
- package/server/lib/quota/providers/openrouter.js +1 -1
- package/server/lib/quota/providers/wafer.js +1 -1
- package/server/lib/quota/providers/zai.js +1 -1
- package/server/lib/quota/providers/zhipuai-coding-plan.js +1 -1
- package/server/lib/skills-catalog/cache.js +0 -4
- package/server/lib/skills-catalog/clawdhub/api.js +0 -32
- package/server/lib/skills-catalog/clawdhub/scan.js +0 -52
- package/server/lib/skills-catalog/curated-sources.js +1 -1
- package/server/lib/skills-catalog/source.js +5 -0
- package/server/lib/terminal/runtime.js +11 -9
- package/server/lib/text/summarization.js +1 -1
- package/server/lib/tunnels/providers/ngrok.js +1 -1
- package/server/lib/tunnels/types.js +2 -2
- package/dist/assets/MultiRunWindow-yZoCT7F7.js +0 -1
- package/dist/assets/NewWorktreeDialog-CTMiE7Xd.js +0 -167
- package/dist/assets/es-CTE-E8we.js +0 -15
- package/dist/assets/fr-TVkZpyEo.js +0 -13
- package/dist/assets/index-B4pCDMbq.css +0 -1
- package/dist/assets/index-D9uMvTQF.js +0 -3
- package/dist/assets/ko-D_UCJIIL.js +0 -15
- package/dist/assets/main-eAd3a6tx.js +0 -214
- package/dist/assets/miniChat-Bbjg31IC.js +0 -2
- package/dist/assets/mobile-B3_j_DsB.js +0 -2
- package/dist/assets/pl-nDEkk-GZ.js +0 -15
- package/dist/assets/pt-BR-B_g2RcgU.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-CB13zs6N.js +0 -2
- package/dist/assets/uk-CWLhnPGW.js +0 -15
- package/dist/assets/zh-CN-BFxe1b5m.js +0 -15
- package/dist/assets/zh-TW-n-d-xbGV.js +0 -15
- package/server/lib/opencode/index.js +0 -95
- package/server/lib/quota/providers/interface.js +0 -55
- package/server/lib/skills-catalog/clawdhub/index.js +0 -30
- package/server/lib/skills-catalog/index.js +0 -42
- package/server/lib/terminal/index.js +0 -31
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import{ak as pc,e as rt,al as gc,j as t,H as je,am as hc,an as fc,a as rn,d as Zn,p as $r,b as Ur,R as l,L as Ss,ab as xc,ac as yc,aa as bc,ad as vc,a8 as jc,a9 as wc,ae as Nc,ao as kc,ap as Sc,aq as Cc,u as Pc,l as Ic,n as Dc,w as Ac,C as Ec,S as Mc,ar as Rc,a6 as Tc,D as Fc,q as Lc,as as Oc,at as zc,au as Kc,av as $c,aw as Uc,X as Rs,ax as Bc,ay as yn,az as Zr,aA as Vc,aB as _c,aC as Ha,aD as Hc,aE as Wc,aF as qc,aG as ei,aH as Ma,aI as ti,k as wa,aJ as ml,aK as Br,aL as Oa,aM as ul,aN as si,aO as Gc,aP as Jc,aQ as Qc,aR as Yc,aS as ni,aT as Te,aU as na,aV as Xc,aW as Zc,aX as ed,aY as td,aZ as sd,a_ as pl,a7 as nd,a$ as ai,b0 as ad,b1 as rd,b2 as id,b3 as od}from"./vendor-.bun-CC_Xso_s.js";import{du as za,r as Ra,v as Ta,m as ce,dv as Na,dw as ka,dx as Sa,D as as,u as dt,I as M,ax as Dt,ay as At,az as Et,dy as ld,av as Hs,a$ as Ut,a_ as Bt,aZ as Vt,bD as Jt,w as jr,bc as Vr,p as un,au as Cs,t as B,cl as gl,B as G,dz as In,dA as cd,dB as dd,dg as md,dC as ud,dD as pd,dE as gd,z as Ps,dF as hd,cQ as fd,cR as xd,cS as yd,c3 as bd,aq as ds,as as ms,c4 as vd,at as us,aT as Ka,dG as jd,dH as kn,aY as _t,bp as qt,bL as Yt,n as it,dI as Qn,ap as js,Q as ut,dd as wd,bE as Ft,bF as Lt,bG as Kt,bH as Ot,bI as ht,ba as ps,aU as _r,dJ as pn,bb as It,dK as hl,dL as Nd,dM as kd,dN as $a,dO as _s,dP as Dn,aW as fl,dQ as Sn,dR as Sd,dS as Cd,dT as Pd,dU as Id,dV as Dd,dW as Ad,dX as Bs,dY as Ed,q as Ua,c9 as ri,k as Md,cb as wr,a3 as xl,E as Rd,P as yl,G as bl,cd as Td,O as ii,cZ as Fd,db as vl,d2 as Ld,cy as Od,dZ as oi,d_ as zd,d$ as Kd,e0 as li,e1 as $d,e2 as Ud,e3 as Bd,e4 as Vd,aw as _d,e5 as Hd,H as Wd,K as qd,a as Hr,aH as ci,e6 as di,e7 as mi,aK as zn,e8 as Wa,e9 as Gd,ea as Jd,ad as An,a5 as en,ac as jl,ab as Qd,eb as Yd,ec as ui,ae as Xd,af as Zd,a6 as em,aB as tm,aC as sm,aD as wl,ed as qa,ee as pi,ef as nm,eg as am,eh as rm,ei as im,d3 as Ba,R as Vs,ej as om,cc as Nl,ek as lm,el as cm,em as dm,en as mm,eo as Ga,ep as gi,eq as um,er as pm,es as gm,et as hm,eu as fm,ev as Ja,ew as xm,ex as hi,ey as Wn,ez as ym,aQ as fi,eA as wn,aP as bm,eB as vm,eC as xi,eD as yi,X as Ys,F as jm,S as wm,eE as Nm,cj as aa,bh as Nr,bi as kr,bj as Sr,bk as Cr,bl as Us,bm as Es,bM as Cn,M as Gn,eF as bi,bY as km,eG as kl,bO as Sm,d7 as Cm,f as Pm,eH as Qa,a2 as Im,b4 as ra,bS as Dm,eI as Am,eJ as Em,eK as Mm,eL as Rm}from"./useAppFontEffects-CV5C5O0r.js";import{D as Yn,e as jt,o as Ns,u as vs,a1 as Tm,a2 as vi,a3 as Fm,a4 as Lm,w as gs,K as mn,b as Ke,j as ea,f as Pt,a as Xn,q as Fs,h as fs,a5 as Om,F as zm,a6 as Ya,E as Km,a7 as ji,a8 as $m,x as Um,a9 as wi,aa as Ni,ab as ki,ac as Si,ad as Xa,ae as Ci,C as Sl,af as Bm,ag as Vm,ah as _m,a0 as Hm,L as Wm,ai as qm,aj as Gm,ak as Jm}from"./index-D9uMvTQF.js";import{g as Qm,s as Ym}from"./mobileLayoutPreference-Dio-WWkI.js";function Xm(){return new Worker(pc,{type:"module"})}const Zm=["typescript","javascript","tsx","jsx","json","markdown"],Pr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Pi,Ii;const Di=s=>{const e=Pr[s],n=new gc({workerFactory:Xm,poolSize:e.poolSize,totalASTLRUCacheSize:e.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:Zm,lineDiffType:e.lineDiffType,preferredHighlighter:"shiki-wasm"});return n.initialize(),n},eu=s=>{if(!(typeof window>"u"))return s==="split"?(Ii??=Di("split"),Ii):(Pi??=Di("unified"),Pi)},tu=s=>{const e=rt.c(7),{children:n,renderTheme:a}=s,r=Ir("unified"),i=Ir("split");let o,d;e[0]!==a||e[1]!==i||e[2]!==r?(o=()=>{r&&r.setRenderOptions({theme:a,lineDiffType:Pr.unified.lineDiffType}),i&&i.setRenderOptions({theme:a,lineDiffType:Pr.split.lineDiffType})},d=[a,i,r],e[0]=a,e[1]=i,e[2]=r,e[3]=o,e[4]=d):(o=e[3],d=e[4]),je.useEffect(o,d);let c;return e[5]!==n?(c=t.jsx(t.Fragment,{children:n}),e[5]=n,e[6]=c):c=e[6],c},Pv=s=>{const e=rt.c(11),{children:n}=s,a=za();let r,i;if(e[0]!==a?.availableThemes||e[1]!==a?.darkThemeId||e[2]!==a?.lightThemeId){const f=Ra(!1),m=Ra(!0),p=a?.lightThemeId??f.metadata.id,u=a?.darkThemeId??m.metadata.id;i=a?.availableThemes.find(S=>S.metadata.id===p)??f,r=a?.availableThemes.find(S=>S.metadata.id===u)??m,Ta(i),Ta(r),e[0]=a?.availableThemes,e[1]=a?.darkThemeId,e[2]=a?.lightThemeId,e[3]=r,e[4]=i}else r=e[3],i=e[4];let o;e[5]!==r.metadata.id||e[6]!==i.metadata.id?(o={light:i.metadata.id,dark:r.metadata.id},e[5]=r.metadata.id,e[6]=i.metadata.id,e[7]=o):o=e[7];const d=o;let c;return e[8]!==n||e[9]!==d?(c=t.jsx(tu,{renderTheme:d,children:n}),e[8]=n,e[9]=d,e[10]=c):c=e[10],c},Ir=s=>{const e=rt.c(2),n=s===void 0?"unified":s;let a;return e[0]!==n?(a=eu(n),e[0]=n,e[1]=a):a=e[1],a};function su(s){const e=rt.c(4);let n,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx("path",{d:"M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z"}),a=t.jsx("path",{d:"M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z"}),e[0]=n,e[1]=a):(n=e[0],a=e[1]);let r;return e[2]!==s?(r=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",fillRule:"evenodd",viewBox:"-0.5 -0.5 25 25",...s,children:[n,a]}),e[2]=s,e[3]=r):r=e[3],r}const Fa=je.forwardRef((s,e)=>{const n=rt.c(11);let a,r;n[0]!==s?({className:a,...r}=s,n[0]=s,n[1]=a,n[2]=r):(a=n[1],r=n[2]);let i;n[3]!==a?(i=ce("peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]",a),n[3]=a,n[4]=i):i=n[4];let o;n[5]===Symbol.for("react.memo_cache_sentinel")?(o={width:"36px",height:"20px",minWidth:"36px",minHeight:"20px"},n[5]=o):o=n[5];let d;n[6]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(hc,{className:ce("pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0"),style:{width:"16px",height:"16px",minWidth:"16px",minHeight:"16px"}}),n[6]=d):d=n[6];let c;return n[7]!==r||n[8]!==e||n[9]!==i?(c=t.jsx(fc,{className:i,style:o,...r,ref:e,children:d}),n[7]=r,n[8]=e,n[9]=i,n[10]=c):c=n[10],c});Fa.displayName="Switch";const ia=()=>{try{const e=as.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();const n=Ns.getDirectory();if(n?.trim())return n.trim()}catch(s){console.warn("[McpConfigStore] Error resolving config directory:",s)}return null},Ai=s=>s?Object.entries(s).map(([e,n])=>({key:e,value:n})):[],Ei=s=>{const e=s.filter(n=>n.key.trim());if(e.length!==0)return Object.fromEntries(e.map(n=>[n.key.trim(),n.value]))},oa=s=>typeof s!="string"?void 0:s.trim()||void 0,Za=800,nu=5e3,au="__default__",Dr=new Map,er=new Map,Cl=s=>s?.trim()||au,tr=s=>{Dr.delete(Cl(s))},Mn=rn()(Zn($r((s,e)=>({mcpServers:[],selectedMcpName:null,isLoading:!1,mcpDraft:null,setSelectedMcp:n=>s({selectedMcpName:n}),setMcpDraft:n=>s({mcpDraft:n}),loadMcpConfigs:async n=>{const a=ia(),r=Cl(a),i=Date.now(),o=Dr.get(r)??0,d=e().mcpServers.length>0;if(!n?.force&&d&&i-o<nu)return!0;const c=er.get(r);if(!n?.force&&c)return c;const f=(async()=>{s({isLoading:!0});try{const m=a?`?directory=${encodeURIComponent(a)}`:"",p=await jt(`/api/config/mcp${m}`,{headers:a?{"x-opencode-directory":a}:void 0});if(!p.ok)throw new Error("Failed to load MCP configs");const u=await p.json();return s({mcpServers:u,isLoading:!1}),Dr.set(r,Date.now()),!0}catch(m){return console.error("[McpConfigStore] Failed to load MCP configs:",m),s({isLoading:!1}),!1}})();er.set(r,f);try{return await f}finally{er.delete(r)}},createMcp:async n=>{Na("Creating MCP server configuration…");let a=!1;try{const r=Mi(n),i=ia(),o=i?`?directory=${encodeURIComponent(i)}`:"",d=await jt(`/api/config/mcp/${encodeURIComponent(n.name)}${o}`,{method:"POST",headers:{"Content-Type":"application/json",...i?{"x-opencode-directory":i}:{}},body:JSON.stringify(r)}),c=await d.json().catch(()=>null);if(!d.ok)throw new Error(c?.error||"Failed to create MCP server");return tr(i),c?.requiresReload?(a=!0,await ka({message:c.message,delayMs:c.reloadDelayMs??Za,scopes:["all"]}),await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):(await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning})}catch(r){return console.error("[McpConfigStore] Failed to create MCP:",r),{ok:!1}}finally{a||Sa()}},updateMcp:async(n,a)=>{Na("Updating MCP server configuration…");let r=!1;try{const i=Mi(a),o=ia(),d=o?`?directory=${encodeURIComponent(o)}`:"",c=await jt(`/api/config/mcp/${encodeURIComponent(n)}${d}`,{method:"PATCH",headers:{"Content-Type":"application/json",...o?{"x-opencode-directory":o}:{}},body:JSON.stringify(i)}),f=await c.json().catch(()=>null);if(!c.ok)throw new Error(f?.error||"Failed to update MCP server");return tr(o),f?.requiresReload?(r=!0,await ka({message:f.message,delayMs:f.reloadDelayMs??Za,scopes:["all"]}),await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:f?.reloadFailed===!0,message:f?.message,warning:f?.warning}):(await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:f?.reloadFailed===!0,message:f?.message,warning:f?.warning})}catch(i){throw console.error("[McpConfigStore] Failed to update MCP:",i),i}finally{r||Sa()}},deleteMcp:async n=>{Na("Deleting MCP server configuration…");let a=!1;try{const r=ia(),i=r?`?directory=${encodeURIComponent(r)}`:"",o=await jt(`/api/config/mcp/${encodeURIComponent(n)}${i}`,{method:"DELETE",headers:r?{"x-opencode-directory":r}:void 0}),d=await o.json().catch(()=>null);if(!o.ok)throw new Error(d?.error||"Failed to delete MCP server");return tr(r),d?.requiresReload&&(a=!0,await ka({message:d.message,delayMs:d.reloadDelayMs??Za,scopes:["all"]})),e().selectedMcpName===n&&s({selectedMcpName:null}),await e().loadMcpConfigs({force:!0}),{ok:!0,reloadFailed:d?.reloadFailed===!0,message:d?.message,warning:d?.warning}}catch(r){return console.error("[McpConfigStore] Failed to delete MCP:",r),{ok:!1}}finally{a||Sa()}},getMcpByName:n=>e().mcpServers.find(a=>a.name===n)}),{name:"mcp-config-store",storage:Ur(()=>Yn()),partialize:s=>({selectedMcpName:s.selectedMcpName})}),{name:"mcp-config-store"}));function Mi(s){const e={};if(s.scope!==void 0&&(e.scope=s.scope),s.type!==void 0&&(e.type=s.type),(s.type==="local"||s.command!==void 0)&&(e.command=(s.command??[]).filter(n=>n.trim())),(s.type==="remote"||s.url!==void 0)&&(e.url=s.url?.trim()??""),s.environment!==void 0&&(e.environment=Ei(s.environment)??{}),s.headers!==void 0&&(e.headers=Ei(s.headers)??{}),s.oauthEnabled!==void 0||s.oauthClientId!==void 0||s.oauthClientSecret!==void 0||s.oauthScope!==void 0||s.oauthRedirectUri!==void 0)if(s.oauthEnabled===!1)e.oauth=!1;else{const n={clientId:oa(s.oauthClientId),clientSecret:oa(s.oauthClientSecret),scope:oa(s.oauthScope),redirectUri:oa(s.oauthRedirectUri)};n.clientId||n.clientSecret||n.scope||n.redirectUri?e.oauth=n:s.oauthEnabled?e.oauth={}:e.oauth=!1}if(s.timeout!==void 0){const n=Number(s.timeout);Number.isFinite(n)&&n>0?e.timeout=n:e.timeout=null}return s.enabled!==void 0&&(e.enabled=s.enabled),e}const ru={},iu={},$s=s=>{if(typeof s!="string")return null;const e=s.trim();if(!e)return null;const n=e.replace(/\\/g,"/");return n.length>1?n.replace(/\/+$/,""):n},vn=s=>$s(s)??"__global__",ln=s=>{const e=$s(s);return e?Ns.getScopedApiClient(e):Ns.getApiClient()},is=rn()(Zn((s,e)=>({byDirectory:{},diagnosticsByDirectory:{},loadingKeys:{},lastErrorKeys:{},getStatusForDirectory:n=>{const a=vn(n??vs.getState().currentDirectory);return e().byDirectory[a]??ru},getDiagnosticForDirectory:n=>{const a=vn(n??vs.getState().currentDirectory);return e().diagnosticsByDirectory[a]??iu},getErrorForDirectory:n=>{const a=vn(n??vs.getState().currentDirectory);return e().lastErrorKeys[a]??null},refresh:async n=>{const a=$s(n?.directory??vs.getState().currentDirectory),r=vn(a);n?.silent||s(i=>({loadingKeys:{...i.loadingKeys,[r]:!0},lastErrorKeys:{...i.lastErrorKeys,[r]:null}}));try{const d=(await ln(a).mcp.status()).data??{};s(c=>({byDirectory:{...c.byDirectory,[r]:d},diagnosticsByDirectory:{...c.diagnosticsByDirectory,[r]:Object.fromEntries(Object.entries(c.diagnosticsByDirectory[r]??{}).filter(([f])=>!d[f]))},loadingKeys:{...c.loadingKeys,[r]:!1},lastErrorKeys:{...c.lastErrorKeys,[r]:null}}))}catch(i){const o=i instanceof Error?i.message:"Failed to load MCP status";s(d=>({loadingKeys:{...d.loadingKeys,[r]:!1},lastErrorKeys:{...d.lastErrorKeys,[r]:o}}))}},connect:async(n,a)=>{const r=$s(a??vs.getState().currentDirectory),i=vn(r),o=ln(r);try{await o.mcp.connect({name:n},{throwOnError:!0})}catch(d){const c=d instanceof Error?d.message:"Connection failed";throw s(f=>({diagnosticsByDirectory:{...f.diagnosticsByDirectory,[i]:{...f.diagnosticsByDirectory[i]??{},[n]:{status:"failed",error:c}}}})),d}await e().refresh({directory:r,silent:!0})},disconnect:async(n,a)=>{const r=$s(a??vs.getState().currentDirectory);await ln(r).mcp.disconnect({name:n},{throwOnError:!0}),await e().refresh({directory:r,silent:!0})},startAuth:async(n,a)=>{const r=$s(a??vs.getState().currentDirectory),d=(await ln(r).mcp.auth.start({name:n},{throwOnError:!0})).data?.authorizationUrl;if(!d)throw new Error("Authorization URL was not returned");return d},completeAuth:async(n,a,r)=>{const i=$s(r??vs.getState().currentDirectory);await ln(i).mcp.auth.callback({name:n,code:a},{throwOnError:!0}),await e().refresh({directory:i,silent:!0})},clearAuth:async(n,a)=>{const r=$s(a??vs.getState().currentDirectory);await ln(r).mcp.auth.remove({name:n},{throwOnError:!0}),await e().refresh({directory:r,silent:!0})},testConnection:async(n,a)=>{const r=$s(a??vs.getState().currentDirectory),i=vn(r),o=ln(r),c=e().getStatusForDirectory(r)[n]?.status==="connected";let f,m;try{await o.mcp.connect({name:n},{throwOnError:!0})}catch(S){f=S instanceof Error?S.message:"Connection failed",s(h=>({diagnosticsByDirectory:{...h.diagnosticsByDirectory,[i]:{...h.diagnosticsByDirectory[i]??{},[n]:{status:"failed",error:f??"Connection failed"}}}}))}await e().refresh({directory:r,silent:!0});const p=e().getStatusForDirectory(r)[n],u=p;if(!c&&p?.status==="connected"){try{await o.mcp.disconnect({name:n},{throwOnError:!0})}catch(S){m=`Connection test succeeded, but cleanup disconnect failed: ${S instanceof Error?S.message:"Disconnect failed"}`}await e().refresh({directory:r,silent:!0})}return{status:u??e().getStatusForDirectory(r)[n],error:f,warning:m}}}))),ou=(s,e)=>{if(!s)return e("mcpDropdown.status.unknown");switch(s.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:s.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");case"needs_client_registration":return e("mcpDropdown.status.needsRegistration",{error:s.error||""});default:return s.status}},lu=s=>{switch(s?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},Iv=({active:s,className:e,headerAction:n,listClassName:a,hideHeader:r=!1,mobileListDensity:i=!1})=>{const{t:o}=dt(),c=vs(k=>k.currentDirectory)??null,f=is(k=>k.getStatusForDirectory(c)),m=is(k=>k.refresh),p=is(k=>k.connect),u=is(k=>k.disconnect),S=Mn(k=>k.mcpServers),h=Mn(k=>k.loadMcpConfigs),[g,x]=l.useState(!1),[D,N]=l.useState(null);l.useEffect(()=>{m({directory:c,silent:!0})},[m,c]),l.useEffect(()=>{h({force:!0})},[h]),l.useEffect(()=>{s&&Promise.all([m({directory:c,silent:!0}),h({force:!0})])},[s,m,c,h]);const w=l.useMemo(()=>{const k=new Set(Object.keys(f));for(const j of S)j?.name&&k.add(j.name);return Array.from(k).sort((j,y)=>j.localeCompare(y))},[S,f]),A=l.useCallback(k=>{if(k?.preventDefault(),g)return;x(!0);const j=new Promise(y=>setTimeout(y,500));Promise.all([m({directory:c}),j]).finally(()=>{x(!1)})},[g,m,c]);return t.jsxs("div",{className:ce("w-full",e),children:[r?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:o("mcpDropdown.title")}),c&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:c.split("/").pop()||c})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:g,onClick:A,"aria-label":o("mcpDropdown.actions.refreshAria"),children:t.jsx(M,{name:"refresh",className:ce("h-4 w-4",g&&"animate-spin")})})]})]})}),t.jsxs("div",{className:ce("max-h-64 overflow-y-auto py-2",i&&"space-y-1 py-3",a),children:[w.map(k=>{const j=f[k],y=lu(j),P=j?.status==="connected",z=D===k,R=ou(j,o);return t.jsxs("div",{className:ce("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",i?"gap-3 px-4 py-3":"gap-2 px-4 py-1.5"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx("span",{className:ce("rounded-full flex-shrink-0",i?"h-2.5 w-2.5":"h-2 w-2",y==="success"&&"bg-status-success",y==="error"&&"bg-status-error",y==="warning"&&"bg-status-warning",y==="default"&&"bg-muted-foreground/40"),"aria-label":R})}),t.jsx(Et,{side:"left",children:t.jsx("p",{children:R})})]}),t.jsx("span",{className:ce("truncate",i?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:k})]})}),t.jsx(Fa,{checked:P,disabled:z,className:"data-[checked]:bg-status-info",onCheckedChange:async I=>{N(k);try{I?await p(k,c):await u(k,c)}finally{N(null)}}})]},k)}),w.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:o("mcpDropdown.empty.configureInConfig")})]})]})};function cu(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=ld();return s}catch{return"unknown"}}function du(){const s=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(s==="arm64"||s==="aarch64")return"arm64";if(s==="x64"||s==="amd64"||s==="x86_64")return"x64";const n=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(n==="arm"||n==="arm64"||n==="aarch64")return"arm64";if(n==="x86"||n==="x64"||n==="amd64")return"x64";const a=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return a.includes("aarch64")||a.includes("arm64")||a.includes("armv")?"arm64":a.includes("x86_64")||a.includes("x64")||a.includes("amd64")||a.includes("win64")?"x64":"unknown"}function mu(){if(typeof navigator>"u")return"web";const s=(navigator.platform||"").toLowerCase();return s.includes("mac")?"macos":s.includes("win")?"windows":s.includes("linux")?"linux":"web"}function uu(s){const e=Ke.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});return n.set("deviceClass",cu()),n.set("arch",du()),n.set("platform",mu()),s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",ea()?"local":"remote"),n):s==="vscode"?(n.set("appType","vscode"),n.set("instanceMode","local"),n):(n.set("appType","web"),n.set("instanceMode","unknown"),n)}async function Ri(s,e){try{const n=uu(s),a=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e||s==="vscode"&&a&&n.set("currentVersion",a);const r=await jt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Server responded with ${r.status}`);const i=await r.json();return{available:i.available??!1,version:i.version,currentVersion:i.currentVersion??"unknown",body:i.body,nextSuggestedCheckInSec:typeof i.nextSuggestedCheckInSec=="number"&&Number.isFinite(i.nextSuggestedCheckInSec)?i.nextSuggestedCheckInSec:void 0,packageManager:i.packageManager,updateCommand:i.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function pu(){return Lm()?"desktop":gs()?"vscode":mn()?"web":null}const Ti={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},Pl=rn()((s,e)=>({...Ti,checkForUpdates:async()=>{const n=pu();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let a=null,r=null;if(n==="desktop"){const i=await vi();return s({checking:!1,available:i?.available??!1,info:i,lastChecked:Date.now(),nextCheckInSec:null}),r}else n==="web"?(a=await Ri("web"),r=a?.nextSuggestedCheckInSec??null):n==="vscode"&&(r=(await Ri("vscode"))?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:a?.available??!1,info:n==="vscode"?null:a,lastChecked:Date.now(),nextCheckInSec:r}),r}catch(a){return s({checking:!1,error:a instanceof Error?a.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:n,runtimeType:a}=e();if(!(a!=="desktop"||!n)){s({downloading:!0,error:null,progress:null});try{const r=await vi();if(!r?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(o=>({info:o.info?{...o.info,...r,body:o.info.body||r.body,available:o.info.available}:r})),!await Fm(o=>{s({progress:o})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(r){s({downloading:!1,error:r instanceof Error?r.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:a}=e();if(!(a!=="desktop"||!n))try{if(!await Tm())throw new Error("Desktop restart only works on Local instance")}catch(r){s({error:r instanceof Error?r.message:"Failed to restart"})}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(Ti)}})),Fi="https://github.com/btriapitsyn/openchamber/releases";function gu(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(Vr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function hu(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Li(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function fu(s,e){const n=s.split(".").map(r=>Number.parseInt(r,10)),a=e.split(".").map(r=>Number.parseInt(r,10));for(let r=0;r<3;r+=1){const i=Number.isFinite(n[r])?n[r]:0,o=Number.isFinite(a[r])?a[r]:0;if(i!==o)return o-i}return 0}function xu(s){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[];let a;for(;(a=e.exec(s))!==null;)n.push({version:a[1]??"",date:a[2]??"",start:a.index});return n.length===0?[]:n.map((r,i)=>{const o=n[i+1]?.start??s.length,d=s.slice(r.start,o).trim();return{version:r.version,date:r.date,start:r.start,end:o,raw:d}})}const Oi=2e3,yu=600*1e3;async function bu(){try{const s=await jt("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}});return s.ok?{success:!0,autoRestart:(await s.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await s.json().catch(()=>({}))).error||`Server error: ${s.status}`}}catch(s){return{success:!1,error:s instanceof Error?s.message:void 0}}}async function vu(){try{return(await jt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function ju(s,e=Math.ceil(yu/Oi),n=Oi){for(let a=0;a<e;a++){try{const r=await jt("/api/openchamber/update-check",{method:"GET",headers:{Accept:"application/json"}});if(r.ok){const i=await r.json().catch(()=>null);if(i&&i.available===!1||i&&typeof i.currentVersion=="string"&&typeof s=="string"&&i.currentVersion!==s)return!0}else if((r.status===401||r.status===403)&&await vu())return!0}catch{}await new Promise(r=>setTimeout(r,n))}return!1}const zi=({open:s,onOpenChange:e,info:n,downloading:a,downloaded:r,progress:i,error:o,onDownload:d,onRestart:c,runtimeType:f="desktop"})=>{const{t:m}=dt(),[p,u]=je.useState(!1),[S,h]=je.useState("idle"),[g,x]=je.useState(null),D=n?.version?`${Fi}/tag/v${n.version}`:Fi,N=i?.total?Math.round(i.downloaded/i.total*100):0,w=f==="web",A=n?.updateCommand||"openchamber update";je.useEffect(()=>{s||(h("idle"),x(null))},[s]);const k=async()=>{(await un(A)).ok&&(u(!0),setTimeout(()=>u(!1),2e3))},j=je.useCallback(async R=>{await Hs(R)},[]),y=je.useCallback(async()=>{h("updating"),x(null);const R=await bu();if(!R.success){h("error"),x(R.error||m("updateDialog.error.updateFailed"));return}R.autoRestart&&(h("restarting"),await new Promise(v=>setTimeout(v,2e3))),h("reconnecting"),await ju(n?.currentVersion)?window.location.reload():(h("error"),x(m("updateDialog.error.takingLonger")))},[n?.currentVersion,m]),P=S!=="idle"&&S!=="error",z=je.useMemo(()=>{if(!n?.body)return null;const R=n.body.trim();if(!R)return null;const I=xu(R);if(I.length===0)return{kind:"raw",title:m("updateDialog.changelog.title"),content:Li(R)};const v=[...I].sort((b,L)=>fu(b.version,L.version));return{kind:"sections",title:m("updateDialog.changelog.title"),sections:v.map(b=>({version:b.version,dateLabel:gu(b.date),content:Li(hu(b.raw)||R)}))}},[n?.body,m]);return t.jsx(Ut,{open:s,onOpenChange:P?void 0:e,children:t.jsxs(Bt,{className:"max-w-4xl p-5 bg-background border-[var(--interactive-border)]",showCloseButton:!0,children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsxs(Vt,{className:"flex items-center gap-2.5",children:[t.jsx(M,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:m(S==="restarting"||S==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(n?.currentVersion||n?.version)&&t.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ml-3",children:[n?.currentVersion&&t.jsx("span",{className:"text-muted-foreground",children:n.currentVersion}),n?.currentVersion&&n?.version&&t.jsx("span",{className:"text-muted-foreground/50",children:"→"}),n?.version&&t.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:n.version})]})]}),t.jsxs("div",{className:"space-y-2",children:[w&&P&&t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(M,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[S==="updating"&&m("updateDialog.status.installingUpdate"),S==="restarting"&&m("updateDialog.status.serverRestarting"),S==="reconnecting"&&m("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:m("updateDialog.status.autoReloadHint")})]}),z&&!P&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(Jt,{className:"max-h-[400px] p-0",fillContainer:!1,children:z.kind==="raw"?t.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:R=>{const v=R.target.closest("a");v&&v.href&&(R.preventDefault(),R.stopPropagation(),j(v.href))},children:t.jsx(jr,{content:z.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:z.sections.map(R=>t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",R.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:R.dateLabel})]}),t.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:I=>{const b=I.target.closest("a");b&&b.href&&(I.preventDefault(),I.stopPropagation(),j(b.href))},children:t.jsx(jr,{content:R.content,disableLinkSafety:!0,enableFileReferences:!1})})]},R.version))})})}),w&&S==="error"&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(M,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:m("updateDialog.fallback.updateViaTerminal")})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]",children:[t.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:A}),t.jsx("button",{onClick:k,className:ce("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",p&&"text-[var(--status-success)]"),title:m(p?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:p?t.jsx(M,{name:"check",className:"h-4 w-4"}):t.jsx(M,{name:"clipboard",className:"h-4 w-4"})})]})]}),!w&&a&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:m("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[N,"%"]})]}),t.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${N}%`}})})]}),(o||g)&&t.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:t.jsx("p",{className:"text-sm text-[var(--status-error)]",children:o||g})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[t.jsx(M,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!w&&!r&&!a&&t.jsxs("button",{onClick:d,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(M,{name:"download",className:"h-4 w-4"}),m("updateDialog.actions.downloadUpdate")]}),!w&&a&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(M,{name:"loader",className:"h-4 w-4 animate-spin"}),m("updateDialog.status.downloading")]}),!w&&r&&t.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[t.jsx(M,{name:"restart",className:"h-4 w-4"}),m("updateDialog.actions.restartToUpdate")]}),w&&!P&&t.jsxs("button",{onClick:y,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(M,{name:"download",className:"h-4 w-4"}),m("updateDialog.actions.updateNow")]}),w&&P&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(M,{name:"loader",className:"h-4 w-4 animate-spin"}),m("updateDialog.status.updating")]})]})]})]})})},Ki="https://github.com/openchamber/openchamber",wu="https://discord.gg/ZYRSdnwwKA",$i="https://x.com/openchamber_dev",Nu=800,Il=({initialUpdateDialogOpen:s=!1})=>{const{t:e}=dt(),[n,a]=l.useState(s),[r,i]=l.useState(!1),[o,d]=l.useState(null),[c,f]=l.useState(null),m=Pl(Ss(g=>({info:g.info,checking:g.checking,available:g.available,error:g.error,downloading:g.downloading,downloaded:g.downloaded,progress:g.progress,runtimeType:g.runtimeType,checkForUpdates:g.checkForUpdates,downloadUpdate:g.downloadUpdate,restartToUpdate:g.restartToUpdate}))),{isMobile:p}=Cs(),u=o||m.info?.currentVersion||"unknown";l.useEffect(()=>{let g=!1;return(async()=>{try{const D=await jt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const N=await D.json().catch(()=>null),w=typeof N?.openchamberVersion=="string"&&N.openchamberVersion.trim().length>0?N.openchamberVersion.trim():null;g||d(w)}catch{g||d(null)}})(),()=>{g=!0}},[]),l.useEffect(()=>{let g=!1;return(async()=>{try{const D=await jt("/api/opencode/upgrade-status",{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const N=await D.json().catch(()=>null),w=typeof N?.currentVersion=="string"&&N.currentVersion.trim().length>0?N.currentVersion.trim():null;g||f(w)}catch{g||f(null)}})(),()=>{g=!0}},[]);const S=l.useRef(!1);l.useEffect(()=>{if(m.checking)i(!0),S.current=!0;else if(r){const g=setTimeout(()=>{i(!1),S.current&&!m.available&&!m.error&&(B.success(e("settings.openchamber.about.toast.latestVersion")),S.current=!1)},Nu);return()=>clearTimeout(g)}},[e,m.checking,r,m.available,m.error]);const h=m.checking||r;return p?t.jsxs("div",{className:"w-full space-y-6 pb-2",children:[t.jsxs("div",{className:"flex flex-col items-center text-center",children:[t.jsx(gl,{width:72,height:72}),t.jsx("h2",{className:"mt-4 typography-ui-header font-semibold text-foreground",children:"OpenChamber"}),t.jsxs("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:[t.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:u})}),t.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:c||e("settings.openchamber.about.state.unknown")})})]})]}),t.jsxs("div",{className:"flex justify-center",children:[!m.available&&!m.error&&t.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:()=>m.checkForUpdates(),disabled:h,className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[h?t.jsx(M,{name:"loader",className:"size-4 animate-spin"}):t.jsx(M,{name:"refresh",className:"size-4"}),e(h?"settings.openchamber.about.state.checking":"settings.openchamber.about.actions.checkForUpdates")]}),!h&&m.available&&t.jsxs(G,{type:"button",variant:"default",size:"sm",onClick:()=>a(!0),className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[t.jsx(M,{name:"download",className:"size-4"}),e("settings.openchamber.about.actions.updateToVersion",{version:m.info?.version||""})]})]}),m.error&&t.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:m.error}),t.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[t.jsxs("div",{className:"flex items-center justify-center gap-5",children:[t.jsxs("a",{href:Ki,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[t.jsx(M,{name:"github-fill",className:"size-5"}),t.jsx("span",{children:"GitHub"})]}),t.jsxs("a",{href:wu,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[t.jsx(M,{name:"discord-fill",className:"size-5"}),t.jsx("span",{children:"Discord"})]})]}),t.jsxs("a",{href:$i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[t.jsx(M,{name:"twitter-xfill",className:"size-5"}),t.jsx("span",{children:"@openchamber_dev"})]})]}),t.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),t.jsx(zi,{open:n,onOpenChange:a,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]}):t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-3 px-1",children:t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:e("settings.openchamber.about.title")})}),t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 px-4 py-3 border-b border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.openchamber.about.field.version")}),t.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:u})]}),t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.openchamber.about.field.openCodeVersion")}),t.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:c||e("settings.openchamber.about.state.unknown")})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[m.checking&&t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(M,{name:"loader",className:"h-4 w-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!m.checking&&m.available&&t.jsxs(G,{size:"sm",variant:"default",onClick:()=>a(!0),children:[t.jsx(M,{name:"download",className:"h-4 w-4 mr-1"}),e("settings.openchamber.about.actions.updateToVersion",{version:m.info?.version||""})]}),!m.checking&&!m.available&&!m.error&&t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),t.jsx(G,{size:"sm",variant:"outline",onClick:()=>m.checkForUpdates(),disabled:m.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),m.error&&t.jsx("div",{className:"px-3 py-2 border-b border-[var(--surface-subtle)]",children:t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:m.error})}),t.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[t.jsxs("a",{href:Ki,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[t.jsx(M,{name:"github-fill",className:"h-4 w-4"}),t.jsx("span",{children:"GitHub"})]}),t.jsxs("a",{href:$i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[t.jsx(M,{name:"twitter-xfill",className:"h-4 w-4"}),t.jsx("span",{children:"@openchamber_dev"})]})]})]}),t.jsx(zi,{open:n,onOpenChange:a,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]})},Dv=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),ku=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),Su=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Cu=s=>!s||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),Kn="opencode-update-available",la="opencode-upgrade-progress",Pu=5e3,Iu=[1e4,6e4],Ui="opencode-update-toast-dismissed-version",Av=()=>{const{t:s}=dt(),e=Ke(o=>o.showOpenCodeUpdateNotifications),n=je.useRef(new Set),a=je.useRef(!1);je.useEffect(()=>{e||B.dismiss(Kn)},[e]);const r=je.useCallback(()=>{B.dismiss(la),In({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),i=je.useCallback(async()=>{if(!a.current){a.current=!0,B.dismiss(Kn),B.message(s("opencodeUpdate.toast.upgrading.title"),{id:la,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(M,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const o=await jt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),d=await o.json().catch(()=>null);if(!o.ok||d?.success===!1)throw new Error(d?.error||o.statusText||s("opencodeUpdate.toast.failed.description"));B.success(s("opencodeUpdate.toast.updated.title"),{id:la,description:d?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:d.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(M,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:r}})}catch(o){B.error(s("opencodeUpdate.toast.failed.title"),{id:la,description:o instanceof Error?o.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{a.current=!1}}},[r,s]);return je.useEffect(()=>{const o=p=>{if(!Ke.getState().showOpenCodeUpdateNotifications){B.dismiss(Kn);return}ku({version:p,dismissedVersion:Yn().getItem(Ui),seenVersions:n.current})&&(n.current.add(p),B.info(s("opencodeUpdate.toast.available.title"),{id:Kn,description:s("opencodeUpdate.toast.available.description",{version:p}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:i},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Yn().setItem(Ui,p),Pt({openCodeUpdateToastDismissedVersion:p}),B.dismiss(Kn)}}}))},d=p=>{const u=Su(p.detail);o(u)};let c=!1;const f=[],m=async p=>{try{const u=await jt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!u.ok)throw new Error(u.statusText||"OpenCode upgrade status check failed");const S=await u.json().catch(()=>null),h=Cu(S);!c&&h&&o(h)}catch{const u=Iu[p];!c&&u!==void 0&&f.push(setTimeout(()=>{m(p+1)},u))}};return e&&f.push(setTimeout(()=>{m(0)},Pu)),window.addEventListener("openchamber:opencode-update-available",d),()=>{c=!0;for(const p of f)clearTimeout(p);window.removeEventListener("openchamber:opencode-update-available",d)}},[i,e,s]),null},Ev=()=>{const s=rt.c(3),[e,n]=l.useState(Du),{isUpdating:a}=e;let r,i;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>dd(n),i=[],s[0]=r,s[1]=i):(r=s[0],i=s[1]),l.useEffect(r,i),!a)return null;let o;return s[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(gl,{width:80,height:80,isAnimated:!0})}),s[2]=o):o=s[2],o};function Du(){return cd()}class Au extends l.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){this.setState({error:e,errorInfo:n})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(md,{className:"w-full max-w-md",children:[t.jsx(ud,{className:"text-center",children:t.jsxs(pd,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(M,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(gd,{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&t.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&t.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[t.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(G,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(M,{name:"restart",className:"h-4 w-4 mr-2"}),this.props.texts.resetAction]})}),t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function Eu(s){const e=rt.c(22),{t:n}=dt();let a;e[0]!==n?(a=n("chat.errorBoundary.title"),e[0]=n,e[1]=a):a=e[1];let r;e[2]!==n?(r=n("chat.errorBoundary.description"),e[2]=n,e[3]=r):r=e[3];let i;e[4]!==n?(i=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=i):i=e[5];let o;e[6]!==n?(o=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=o):o=e[7];let d;e[8]!==n?(d=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=d):d=e[9];let c;e[10]!==n?(c=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=c):c=e[11];let f;e[12]!==a||e[13]!==r||e[14]!==i||e[15]!==o||e[16]!==d||e[17]!==c?(f={title:a,description:r,sessionLabel:i,detailsSummary:o,resetAction:d,persistentHint:c},e[12]=a,e[13]=r,e[14]=i,e[15]=o,e[16]=d,e[17]=c,e[18]=f):f=e[18];let m;return e[19]!==s||e[20]!==f?(m=t.jsx(Au,{...s,texts:f}),e[19]=s,e[20]=f,e[21]=m):m=e[21],m}const Mv=s=>{const e=rt.c(5),{readOnly:n}=s,a=n===void 0?!1:n,i=Ps(Mu)||void 0;let o;e[0]!==a?(o=t.jsx(hd,{readOnly:a}),e[0]=a,e[1]=o):o=e[1];let d;return e[2]!==i||e[3]!==o?(d=t.jsx(Eu,{sessionId:i,children:o}),e[2]=i,e[3]=o,e[4]=d):d=e[4],d};function Mu(s){return s.currentSessionId}function tn(s){const e=rt.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let a;return e[2]!==n?(a=t.jsx(xc,{...n}),e[2]=n,e[3]=a):a=e[3],a}function sn(s){const e=rt.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let a;return e[2]!==n?(a=t.jsx(yc,{...n}),e[2]=n,e[3]=a):a=e[3],a}function nn(s){const e=rt.c(20);let n,a,r,i,o;e[0]!==s?({className:a,positionerClassName:r,children:n,style:o,...i}=s,e[0]=s,e[1]=n,e[2]=a,e[3]=r,e[4]=i,e[5]=o):(n=e[1],a=e[2],r=e[3],i=e[4],o=e[5]);let d;e[6]!==r?(d=ce("app-region-no-drag z-50",r),e[6]=r,e[7]=d):d=e[7];let c;e[8]!==o?(c={backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)",...o},e[8]=o,e[9]=c):c=e[9];let f;e[10]!==a?(f=ce(fd,a),e[10]=a,e[11]=f):f=e[11];let m;e[12]!==n||e[13]!==i||e[14]!==c||e[15]!==f?(m=t.jsx(bc,{"data-slot":"dropdown-menu-content",style:c,className:f,...i,children:n}),e[12]=n,e[13]=i,e[14]=c,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=t.jsx(jc,{children:t.jsx(wc,{className:d,children:m})}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}function Ws(s){const e=rt.c(8);let n,a;e[0]!==s?({className:n,...a}=s,e[0]=s,e[1]=n,e[2]=a):(n=e[1],a=e[2]);let r;e[3]!==n?(r=ce(xd,n),e[3]=n,e[4]=r):r=e[4];let i;return e[5]!==a||e[6]!==r?(i=t.jsx(vc,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i}function Rv(s){const e=rt.c(8);let n,a;e[0]!==s?({className:n,...a}=s,e[0]=s,e[1]=n,e[2]=a):(n=e[1],a=e[2]);let r;e[3]!==n?(r=ce(yd,n),e[3]=n,e[4]=r):r=e[4];let i;return e[5]!==a||e[6]!==r?(i=t.jsx(Nc,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i}const Dl=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),ta=s=>{const e=rt.c(39),{className:n}=s,{t:a}=dt(),r=as(Ru),i=as(Tu),o=as(Fu),d=gs();let c;e[0]!==r?(c=[...r].sort(Lu),e[0]=r,e[1]=c):c=e[1];const f=c;let m;e:{if(f.length===0){m=null;break e}let L;e[2]!==i||e[3]!==f?(L=f.find(E=>E.id===i)??f[0],e[2]=i,e[3]=f,e[4]=L):L=e[4],m=L}const p=m;if(d||f.length===0)return null;let u;e[5]!==p||e[6]!==a?(u=p?.label&&p.label.trim().length>0?p.label:p?.path.split("/").filter(Boolean).pop()||p?.path||a("settings.shared.projectSelector.fallbackProject"),e[5]=p,e[6]=a,e[7]=u):u=e[7];const S=u;let h;e[8]!==S?(h=Dl(S),e[8]=S,e[9]=h):h=e[9];const g=h;let x;e[10]!==n?(x=ce(n),e[10]=n,e[11]=x):x=e[11];let D;e[12]!==a?(D=a("settings.shared.projectSelector.switchProjectAria"),e[12]=a,e[13]=D):D=e[13];let N;e[14]!==a?(N=a("settings.shared.projectSelector.switchProjectTitle"),e[14]=a,e[15]=N):N=e[15];let w,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=ce("text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none","hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70","flex items-center gap-1.5 text-left"),A=t.jsx(M,{name:"folder",className:"h-4 w-4 opacity-70"}),e[16]=w,e[17]=A):(w=e[16],A=e[17]);let k;e[18]!==g?(k=t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:g}),e[18]=g,e[19]=k):k=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(M,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[20]=j):j=e[20];let y;e[21]!==k||e[22]!==D||e[23]!==N?(y=t.jsx(ds,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":D,title:N,className:w,children:[A,k,j]})}),e[21]=k,e[22]=D,e[23]=N,e[24]=y):y=e[24];const P=p?.id??"";let z;e[25]!==o?(z=L=>{L&&o(L)},e[25]=o,e[26]=z):z=e[26];let R;e[27]!==f?(R=f.map(Ou),e[27]=f,e[28]=R):R=e[28];let I;e[29]!==P||e[30]!==z||e[31]!==R?(I=t.jsx(ms,{align:"start",className:"w-auto",children:t.jsx(vd,{value:P,onValueChange:z,children:R})}),e[29]=P,e[30]=z,e[31]=R,e[32]=I):I=e[32];let v;e[33]!==y||e[34]!==I?(v=t.jsxs(us,{children:[y,I]}),e[33]=y,e[34]=I,e[35]=v):v=e[35];let b;return e[36]!==v||e[37]!==x?(b=t.jsx("div",{className:x,children:v}),e[36]=v,e[37]=x,e[38]=b):b=e[38],b};function Ru(s){return s.projects}function Tu(s){return s.activeProjectId}function Fu(s){return s.setActiveProject}function Lu(s,e){return(s.label||s.path).localeCompare(e.label||e.path)}function Ou(s){const e=s.label?.trim()?s.label.trim():s.path.split("/").filter(Boolean).pop()||s.path,n=Dl(e);return t.jsx(bd,{value:s.id,children:t.jsx("span",{className:"min-w-0 truncate typography-ui",children:n})},s.id)}function zu(s,e){return`opencode:sidebar-group:${s}:${e}`}const Ar=s=>{const e=rt.c(33),{label:n,count:a,storageKey:r,defaultExpanded:i,children:o}=s,d=i===void 0?!0:i;let c;e[0]!==n||e[1]!==r?(c=zu(r,n),e[0]=n,e[1]=r,e[2]=c):c=e[2];const f=c,m=l.useId();let p;e[3]!==d||e[4]!==f?(p=()=>{try{const I=localStorage.getItem(f);if(I!==null)return I==="true"}catch{}return d},e[3]=d,e[4]=f,e[5]=p):p=e[5];const[u,S]=je.useState(p);let h,g;e[6]!==u||e[7]!==f?(h=()=>{try{localStorage.setItem(f,String(u))}catch{}},g=[f,u],e[6]=u,e[7]=f,e[8]=h,e[9]=g):(h=e[8],g=e[9]),je.useEffect(h,g);let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>S(Ku),e[10]=x):x=e[10];let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D=ce("flex w-full items-center gap-1 rounded-md px-2 py-1 text-left","text-xs font-semibold uppercase tracking-wide text-muted-foreground","hover:bg-[var(--interactive-hover)] transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50"),e[11]=D):D=e[11];const N=!u&&"-rotate-90";let w;e[12]!==N?(w=ce("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",N),e[12]=N,e[13]=w):w=e[13];let A;e[14]!==w?(A=t.jsx(M,{name:"arrow-down-s",className:w}),e[14]=w,e[15]=A):A=e[15];let k;e[16]!==n?(k=t.jsx("span",{className:"flex-1 truncate",children:n}),e[16]=n,e[17]=k):k=e[17];let j;e[18]!==a?(j=t.jsx("span",{className:"ml-1 tabular-nums opacity-60",children:a}),e[18]=a,e[19]=j):j=e[19];let y;e[20]!==m||e[21]!==u||e[22]!==A||e[23]!==k||e[24]!==j?(y=t.jsxs("button",{type:"button",onClick:x,"aria-expanded":u,"aria-controls":m,className:D,children:[A,k,j]}),e[20]=m,e[21]=u,e[22]=A,e[23]=k,e[24]=j,e[25]=y):y=e[25];const P=!u;let z;e[26]!==o||e[27]!==m||e[28]!==P?(z=t.jsx("div",{id:m,hidden:P,className:"mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]",children:o}),e[26]=o,e[27]=m,e[28]=P,e[29]=z):z=e[29];let R;return e[30]!==y||e[31]!==z?(R=t.jsxs("div",{children:[y,z]}),e[30]=y,e[31]=z,e[32]=R):R=e[32],R};function Ku(s){return!s}const $u=s=>{if(!Array.isArray(s))return[];const e=[];for(const n of s){if(!n||typeof n!="object")continue;const a=n;typeof a.permission!="string"||typeof a.pattern!="string"||typeof a.action!="string"||a.action!=="allow"&&a.action!=="ask"&&a.action!=="deny"||e.push({permission:a.permission,pattern:a.pattern,action:a.action})}return e},Uu=s=>{const e=new Map;for(const n of s)!n.permission||n.permission==="invalid"||n.pattern&&e.set(`${n.permission}::${n.pattern}`,n);return Array.from(e.values())},Bi=s=>{const e=Uu($u(s));if(e.length===0)return;const n={};for(const r of e)r.permission&&((n[r.permission]||={})[r.pattern]=r.action);const a={};for(const[r,i]of Object.entries(n)){const o=Object.keys(i);if(o.length===1&&o[0]==="*"){a[r]=i["*"];continue}a[r]=i}return Object.keys(a).length>0?a:void 0},Bu=({onItemSelect:s})=>{const{t:e}=dt(),[n,a]=l.useState(null),[r,i]=l.useState(""),[o,d]=l.useState(null),[c,f]=l.useState(null),[m,p]=l.useState(!1),[u,S]=l.useState(null),{selectedAgentName:h,agents:g,setSelectedAgent:x,setAgentDraft:D,createAgent:N,deleteAgent:w,loadAgents:A}=Ka(Ss(T=>({selectedAgentName:T.selectedAgentName,agents:T.agents,setSelectedAgent:T.setSelectedAgent,setAgentDraft:T.setAgentDraft,createAgent:T.createAgent,deleteAgent:T.deleteAgent,loadAgents:T.loadAgents})));l.useEffect(()=>{A()},[A]);const k="bg-background",j=()=>{const T="new-agent";let Y=T,F=1;for(;g.some(V=>V.name===Y);)Y=`${T}-${F}`,F++;D({name:Y,scope:"user"}),x(Y),s?.()},y=async T=>{if(kn(T)){B.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(T),f("delete")},P=async T=>{kn(T)&&(d(T),f("reset"))},z=()=>{d(null),f(null)},R=async()=>{if(!(!o||!c)){p(!0);try{await w(o.name,o.scope)?(c==="delete"?B.success(e("settings.agents.sidebar.toast.agentDeleted",{name:o.name})):B.success(e("settings.agents.sidebar.toast.agentReset",{name:o.name})),z()):c==="delete"?B.error(e("settings.agents.sidebar.toast.deleteFailed")):B.error(e("settings.agents.sidebar.toast.resetFailed"))}catch(T){const Y=T instanceof Error?T.message:"",F=/built-in|not deletable|not found/i.test(Y);c==="delete"?B.error(e(F?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed")):B.error(e("settings.agents.sidebar.toast.resetFailed"))}p(!1)}},I=T=>{const Y=T.name;let F=1,V=`${Y}-copy`;for(;g.some(se=>se.name===V);)F++,V=`${Y}-copy-${F}`;const Q=T,ie=T.model?.providerID&&T.model?.modelID?`${T.model.providerID}/${T.model.modelID}`:null,X=T;D({name:V,scope:Q.scope||"user",description:T.description,model:ie,variant:T.variant,temperature:T.temperature,top_p:T.topP,prompt:T.prompt,mode:T.mode,permission:Bi(T.permission),disable:X.disable}),x(V)},v=T=>{i(T.name),a(T)},b=async()=>{if(!n)return;const T=r.trim().replace(/\s+/g,"-");if(!T){B.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(T===n.name){a(null);return}if(g.some(Q=>Q.name===T)){B.error(e("settings.agents.sidebar.toast.agentExists"));return}const Y=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,F=n;await N({name:T,description:n.description,model:Y,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:Bi(n.permission),disable:F.disable,scope:F.scope})?await w(n.name,F.scope)?(B.success(`Agent renamed to "${T}"`),x(T)):B.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):B.error(e("settings.agents.sidebar.toast.renameFailed")),a(null)},L=T=>{switch(T){case"primary":return t.jsx(M,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return t.jsx(M,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return t.jsx(M,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},E=g.filter(T=>!jd(T)),J=E.filter(kn),_=E.filter(T=>!kn(T)),{groupedCustomAgents:Z,ungroupedCustomAgents:H}=je.useMemo(()=>{const T={},Y=[];for(const V of _){const Q=V;Q.group?(T[Q.group]||(T[Q.group]=[]),T[Q.group].push(V)):Y.push(V)}return{groupedCustomAgents:Object.keys(T).sort((V,Q)=>V.localeCompare(Q)).map(V=>({name:V,agents:T[V]})),ungroupedCustomAgents:Y}},[_]);return t.jsxs("div",{className:ce("flex h-full flex-col",k),children:[t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:e("settings.agents.sidebar.title")}),t.jsx(ta,{className:"mb-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:E.length})}),t.jsx(G,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:j,children:t.jsx(M,{name:"add",className:"h-3.5 w-3.5"})})]})]}),t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:E.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(M,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[J.length>0&&t.jsxs(t.Fragment,{children:[t.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")}),J.map(T=>t.jsx(sr,{agent:T,isSelected:h===T.name,onSelect:()=>{x(T.name),s?.()},onReset:()=>P(T),onDuplicate:()=>I(T),getAgentModeIcon:L,isMenuOpen:u===T.name,onMenuOpenChange:Y=>S(Y?T.name:null)},T.name))]}),_.length>0&&t.jsxs(t.Fragment,{children:[t.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")}),Z.map(({name:T,agents:Y})=>t.jsx(Ar,{label:T,count:Y.length,storageKey:"agents",children:Y.map(F=>t.jsx(sr,{agent:F,isSelected:h===F.name,onSelect:()=>{x(F.name),s?.()},onRename:()=>v(F),onDelete:()=>y(F),onDuplicate:()=>I(F),getAgentModeIcon:L,isMenuOpen:u===F.name,onMenuOpenChange:V=>S(V?F.name:null)},F.name))},T)),H.map(T=>t.jsx(sr,{agent:T,isSelected:h===T.name,onSelect:()=>{x(T.name),s?.()},onRename:()=>v(T),onDelete:()=>y(T),onDuplicate:()=>I(T),getAgentModeIcon:L,isMenuOpen:u===T.name,onMenuOpenChange:Y=>S(Y?T.name:null)},T.name))]})]})}),t.jsx(Ut,{open:o!==null&&c!==null,onOpenChange:T=>{!T&&!m&&z()},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:e(c==="delete"?"settings.agents.sidebar.dialog.deleteTitle":"settings.agents.sidebar.dialog.resetTitle")}),t.jsx(qt,{children:c==="delete"?e("settings.agents.sidebar.dialog.deleteDescription",{name:o?.name??""}):e("settings.agents.sidebar.dialog.resetDescription",{name:o?.name??""})})]}),t.jsxs(Yt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:z,disabled:m,children:e("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",onClick:R,disabled:m,children:e(c==="delete"?"settings.common.actions.delete":"settings.common.actions.reset")})]})]})}),t.jsx(Ut,{open:n!==null,onOpenChange:T=>!T&&a(null),children:t.jsxs(Bt,{children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:e("settings.agents.sidebar.renameDialog.title")}),t.jsx(qt,{children:e("settings.agents.sidebar.renameDialog.description",{name:n?.name??""})})]}),t.jsx(it,{value:r,onChange:T=>i(T.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:T=>{T.key==="Enter"&&b()}}),t.jsxs(Yt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>a(null),children:e("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",onClick:b,children:e("settings.common.actions.rename")})]})]})})]})},sr=s=>{const e=rt.c(52),{agent:n,isSelected:a,onSelect:r,onDelete:i,onReset:o,onRename:d,onDuplicate:c,getAgentModeIcon:f,isMenuOpen:m,onMenuOpenChange:p}=s,{t:u}=dt(),S=n;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=Qn(),e[0]=h):h=e[0];const g=h,[x,D]=l.useState(!1);let N;e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==o||e[5]!==u?(N=F=>t.jsxs(t.Fragment,{children:[d&&t.jsxs(F,{onClick:V=>{V.stopPropagation(),d()},children:[t.jsx(M,{name:"edit",className:"h-4 w-4 mr-px"}),u("settings.common.actions.rename")]}),t.jsxs(F,{onClick:V=>{V.stopPropagation(),c()},children:[t.jsx(M,{name:"file-copy",className:"h-4 w-4 mr-px"}),u("settings.common.actions.duplicate")]}),o&&t.jsxs(F,{onClick:V=>{V.stopPropagation(),o()},children:[t.jsx(M,{name:"restart",className:"h-4 w-4 mr-px"}),u("settings.common.actions.reset")]}),i&&t.jsxs(F,{onClick:V=>{V.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(M,{name:"delete-bin",className:"h-4 w-4 mr-px"}),u("settings.common.actions.delete")]})]}),e[1]=i,e[2]=c,e[3]=d,e[4]=o,e[5]=u,e[6]=N):N=e[6];const w=N,A=a?"bg-interactive-selection":"hover:bg-interactive-hover";let k;e[7]!==A?(k=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",A),e[7]=A,e[8]=k):k=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=g?void 0:F=>{F.preventDefault(),D(!0)},e[9]=j):j=e[9];let y;e[10]!==k?(y=t.jsx("div",{className:k,onContextMenu:j}),e[10]=k,e[11]=y):y=e[11];let P;e[12]!==n.name?(P=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[12]=n.name,e[13]=P):P=e[13];let z;e[14]!==n.mode||e[15]!==f?(z=f(n.mode),e[14]=n.mode,e[15]=f,e[16]=z):z=e[16];let R;e[17]!==n||e[18]!==S.scope||e[19]!==u?(R=(S.scope||kn(n))&&t.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:kn(n)?u("settings.agents.sidebar.badge.system"):S.scope}),e[17]=n,e[18]=S.scope,e[19]=u,e[20]=R):R=e[20];let I;e[21]!==P||e[22]!==z||e[23]!==R?(I=t.jsxs("div",{className:"flex items-center gap-1.5",children:[P,z,R]}),e[21]=P,e[22]=z,e[23]=R,e[24]=I):I=e[24];let v;e[25]!==n.description?(v=n.description&&t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n.description}),e[25]=n.description,e[26]=v):v=e[26];let b;e[27]!==r||e[28]!==I||e[29]!==v?(b=t.jsxs("button",{onClick:r,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[I,v]}),e[27]=r,e[28]=I,e[29]=v,e[30]=b):b=e[30];let L;e[31]!==p?(L=F=>{F&&D(!1),p(F)},e[31]=p,e[32]=L):L=e[32];let E;e[33]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(ds,{asChild:!0,children:t.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=E):E=e[33];let J;e[34]!==w?(J=t.jsx(ms,{align:"end",className:"w-fit min-w-20",children:w(js)}),e[34]=w,e[35]=J):J=e[35];let _;e[36]!==m||e[37]!==L||e[38]!==J?(_=t.jsxs(us,{open:m,onOpenChange:L,children:[E,J]}),e[36]=m,e[37]=L,e[38]=J,e[39]=_):_=e[39];let Z;e[40]!==b||e[41]!==_?(Z=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[b,_]}),e[40]=b,e[41]=_,e[42]=Z):Z=e[42];let H;e[43]!==Z||e[44]!==y?(H=t.jsx(sn,{render:y,children:Z}),e[43]=Z,e[44]=y,e[45]=H):H=e[45];let T;e[46]!==w?(T=t.jsx(nn,{className:"w-fit min-w-20",children:w(Ws)}),e[46]=w,e[47]=T):T=e[47];let Y;return e[48]!==x||e[49]!==H||e[50]!==T?(Y=t.jsxs(tn,{open:x,onOpenChange:D,children:[H,T]}),e[48]=x,e[49]=H,e[50]=T,e[51]=Y):Y=e[51],Y};function Vi(s,e,n){return Math.min(n,Math.max(e,s))}function Vu(s){if(!Number.isFinite(s))return 0;const e=String(s);if(e.includes("e-")){const[,a]=e.split("e-");return Number(a)||0}const n=e.split(".");return n.length===2?n[1].length:0}function _i(s,e){const n=Vu(e);return n<=0?s:Number(s.toFixed(n))}const xs=je.forwardRef((s,e)=>{const n=rt.c(125);let a,r,i,o,d,c,f,m,p,u,S,h,g;n[0]!==s?({value:g,onValueChange:f,min:p,max:u,step:S,className:a,containerClassName:r,onBlur:d,disabled:i,fallbackValue:o,onClear:c,emptyLabel:h,...m}=s,n[0]=s,n[1]=a,n[2]=r,n[3]=i,n[4]=o,n[5]=d,n[6]=c,n[7]=f,n[8]=m,n[9]=p,n[10]=u,n[11]=S,n[12]=h,n[13]=g):(a=n[1],r=n[2],i=n[3],o=n[4],d=n[5],c=n[6],f=n[7],m=n[8],p=n[9],u=n[10],S=n[11],h=n[12],g=n[13]);const x=p===void 0?-1/0:p,D=u===void 0?1/0:u,N=S===void 0?1:S,w=h===void 0?"—":h,{t:A}=dt();let k;n[14]!==g?(k=()=>g===void 0?"":String(g),n[14]=g,n[15]=k):k=n[15];const[j,y]=je.useState(k),{isMobile:P}=Cs(),z=je.useRef(!1),R=je.useRef(null);let I;n[16]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{if(typeof document>"u"||typeof window>"u")return;R.current?.();const Ae=Le=>{Le.preventDefault(),Le.stopPropagation(),Le.stopImmediatePropagation?.(),R.current?.()},Pe=window.setTimeout(()=>{R.current?.()},700),Re=()=>{window.clearTimeout(Pe),document.removeEventListener("click",Ae,!0),R.current=null};R.current=Re,document.addEventListener("click",Ae,!0)},n[16]=I):I=n[16];const v=I;let b,L;n[17]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>{R.current?.()},L=[],n[17]=b,n[18]=L):(b=n[17],L=n[18]),je.useEffect(b,L);let E,J;n[19]!==g?(J=()=>{y(g===void 0?"":String(g))},E=[g],n[19]=g,n[20]=E,n[21]=J):(E=n[20],J=n[21]),je.useEffect(J,E);let _;e:{if(g!==void 0){_=g;break e}if(o!==void 0){_=o;break e}if(Number.isFinite(x)){_=x;break e}_=0}const Z=_;let H;n[22]!==D||n[23]!==x||n[24]!==f||n[25]!==N?(H=Ae=>{const Pe=Vi(Ae,x,D);f(_i(Pe,N))},n[22]=D,n[23]=x,n[24]=f,n[25]=N,n[26]=H):H=n[26];const T=H;let Y;n[27]!==T||n[28]!==c?(Y=Ae=>{const Pe=Ae.target.value;if(y(Pe),Pe.trim()===""){c?.();return}const Re=Number(Pe);Number.isFinite(Re)&&T(Re)},n[27]=T,n[28]=c,n[29]=Y):Y=n[29];const F=Y;let V;n[30]!==j||n[31]!==D||n[32]!==x||n[33]!==d||n[34]!==c||n[35]!==f||n[36]!==N||n[37]!==g?(V=Ae=>{if(j.trim()===""){c||y(g===void 0?"":String(g)),d?.(Ae);return}const Pe=Number(j);if(!Number.isFinite(Pe))y(g===void 0?"":String(g));else{const Re=Vi(Pe,x,D),Le=_i(Re,N);Le!==g&&f(Le),y(String(Le))}d?.(Ae)},n[30]=j,n[31]=D,n[32]=x,n[33]=d,n[34]=c,n[35]=f,n[36]=N,n[37]=g,n[38]=V):V=n[38];const Q=V,ie=!!(i||Z>=D),X=!!(i||Z<=x);let se;n[39]!==Z||n[40]!==T||n[41]!==X||n[42]!==N?(se=()=>{X||T(Z-N)},n[39]=Z,n[40]=T,n[41]=X,n[42]=N,n[43]=se):se=n[43];const me=se;let oe;n[44]!==Z||n[45]!==T||n[46]!==ie||n[47]!==N?(oe=()=>{ie||T(Z+N)},n[44]=Z,n[45]=T,n[46]=ie,n[47]=N,n[48]=oe):oe=n[48];const xe=oe;let we;if(n[49]!==a||n[50]!==r||n[51]!==X||n[52]!==j||n[53]!==w||n[54]!==me||n[55]!==xe||n[56]!==ie||n[57]!==P||n[58]!==A||n[59]!==g){we=Symbol.for("react.early_return_sentinel");e:{const Ae=Re=>Le=>{Le.preventDefault(),Le.stopPropagation(),z.current=!0,v(),Re()},Pe=Re=>Le=>{if(z.current){z.current=!1,Le.preventDefault(),Le.stopPropagation();return}Re()};if(P){let Re;n[61]!==r?(Re=ce("flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain","[-webkit-user-select:none] [-webkit-touch-callout:none]","disabled:pointer-events-none disabled:opacity-50",r),n[61]=r,n[62]=Re):Re=n[62];let Le;n[63]!==A?(Le=A("numberInput.actions.decreaseAria"),n[63]=A,n[64]=Le):Le=n[64];const $e=Ae(me),Be=Pe(me),Oe=!X&&"active:bg-interactive-hover";let Ue;n[65]!==Oe?(Ue=ce("grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none","text-muted-foreground","disabled:pointer-events-none disabled:opacity-50",Oe),n[65]=Oe,n[66]=Ue):Ue=n[66];let le;n[67]===Symbol.for("react.memo_cache_sentinel")?(le=t.jsx(M,{name:"subtract",className:"block h-4 w-4"}),n[67]=le):le=n[67];const W=t.jsx("button",{type:"button","aria-label":Le,disabled:X,onTouchStart:$e,onClick:Be,className:Ue,children:le});let de;n[68]!==a?(de=ce("flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5","text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]",a),n[68]=a,n[69]=de):de=n[69];const Ne=g===void 0?w:j;let Ee;n[70]!==de||n[71]!==Ne?(Ee=t.jsx("div",{className:de,"aria-live":"polite",children:Ne}),n[70]=de,n[71]=Ne,n[72]=Ee):Ee=n[72];let Ce;n[73]!==A?(Ce=A("numberInput.actions.increaseAria"),n[73]=A,n[74]=Ce):Ce=n[74];const He=Ae(xe),q=Pe(xe),$=!ie&&"active:bg-interactive-hover";let fe;n[75]!==$?(fe=ce("grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none","text-muted-foreground","disabled:pointer-events-none disabled:opacity-50",$),n[75]=$,n[76]=fe):fe=n[76];let O;n[77]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(M,{name:"add",className:"block h-4 w-4"}),n[77]=O):O=n[77];const Fe=t.jsx("button",{type:"button","aria-label":Ce,disabled:ie,onTouchStart:He,onClick:q,className:fe,children:O});let Je;n[78]!==Re||n[79]!==W||n[80]!==Ee||n[81]!==Fe?(Je=t.jsxs("div",{className:Re,children:[W,Ee,Fe]}),n[78]=Re,n[79]=W,n[80]=Ee,n[81]=Fe,n[82]=Je):Je=n[82],we=Je;break e}}n[49]=a,n[50]=r,n[51]=X,n[52]=j,n[53]=w,n[54]=me,n[55]=xe,n[56]=ie,n[57]=P,n[58]=A,n[59]=g,n[60]=we}else we=n[60];if(we!==Symbol.for("react.early_return_sentinel"))return we;let he;n[83]!==r?(he=ce("flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent","disabled:pointer-events-none disabled:opacity-50",r),n[83]=r,n[84]=he):he=n[84];let Ie;n[85]!==A?(Ie=A("numberInput.actions.decreaseAria"),n[85]=A,n[86]=Ie):Ie=n[86];let ve;n[87]!==Z||n[88]!==T||n[89]!==N?(ve=()=>T(Z-N),n[87]=Z,n[88]=T,n[89]=N,n[90]=ve):ve=n[90];let ye,be;n[91]===Symbol.for("react.memo_cache_sentinel")?(ye=ce("flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation","text-muted-foreground hover:bg-interactive-hover hover:text-foreground","disabled:pointer-events-none disabled:opacity-50"),be=t.jsx(M,{name:"subtract",className:"block h-3.5 w-3.5"}),n[91]=ye,n[92]=be):(ye=n[91],be=n[92]);let te;n[93]!==X||n[94]!==Ie||n[95]!==ve?(te=t.jsx("button",{type:"button","aria-label":Ie,disabled:X,onClick:ve,className:ye,children:be}),n[93]=X,n[94]=Ie,n[95]=ve,n[96]=te):te=n[96];const re=m.inputMode??"numeric";let ge;n[97]!==a?(ge=ce("h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]","placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground","appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","disabled:pointer-events-none disabled:cursor-not-allowed",a),n[97]=a,n[98]=ge):ge=n[98];let U;n[99]!==i||n[100]!==j||n[101]!==Q||n[102]!==F||n[103]!==m||n[104]!==e||n[105]!==re||n[106]!==ge?(U=t.jsx("input",{...m,ref:e,type:"text",inputMode:re,value:j,onChange:F,onBlur:Q,disabled:i,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:ge}),n[99]=i,n[100]=j,n[101]=Q,n[102]=F,n[103]=m,n[104]=e,n[105]=re,n[106]=ge,n[107]=U):U=n[107];let ee;n[108]!==A?(ee=A("numberInput.actions.increaseAria"),n[108]=A,n[109]=ee):ee=n[109];let ne;n[110]!==Z||n[111]!==T||n[112]!==N?(ne=()=>T(Z+N),n[110]=Z,n[111]=T,n[112]=N,n[113]=ne):ne=n[113];let ue,Me;n[114]===Symbol.for("react.memo_cache_sentinel")?(ue=ce("flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation","text-muted-foreground hover:bg-interactive-hover hover:text-foreground","disabled:pointer-events-none disabled:opacity-50"),Me=t.jsx(M,{name:"add",className:"block h-3.5 w-3.5"}),n[114]=ue,n[115]=Me):(ue=n[114],Me=n[115]);let ke;n[116]!==ie||n[117]!==ee||n[118]!==ne?(ke=t.jsx("button",{type:"button","aria-label":ee,disabled:ie,onClick:ne,className:ue,children:Me}),n[116]=ie,n[117]=ee,n[118]=ne,n[119]=ke):ke=n[119];let De;return n[120]!==he||n[121]!==te||n[122]!==U||n[123]!==ke?(De=t.jsxs("div",{className:he,children:[te,U,ke]}),n[120]=he,n[121]=te,n[122]=U,n[123]=ke,n[124]=De):De=n[124],De});xs.displayName="NumberInput";const Hi=["*","read","edit","glob","grep","list","bash","task","skill","lsp","todoread","todowrite","webfetch","websearch","codesearch","external_directory","doom_loop","question","plan_enter","plan_exit"],Ca=s=>s==="allow"||s==="ask"||s==="deny",dn=(s,e)=>`${s}::${e}`,an=s=>{const e=new Map;for(const n of s)!n.permission||n.permission==="invalid"||n.pattern&&Ca(n.action)&&e.set(dn(n.permission,n.pattern),{permission:n.permission,pattern:n.pattern,action:n.action});return Array.from(e.values())},ca=s=>{const e=new Map;for(const n of an(s))e.set(dn(n.permission,n.pattern),n);return e},Wi=s=>[...s].sort((e,n)=>{const a=e.permission.localeCompare(n.permission);return a!==0?a:e.pattern.localeCompare(n.pattern)}),_u=(s,e)=>{const n=Wi(an(s)),a=Wi(an(e));return n.length!==a.length?!1:n.every((r,i)=>{const o=a[i];return r.permission===o.permission&&r.pattern===o.pattern&&r.action===o.action})},Hu=s=>s.find(n=>n.permission==="*"&&n.pattern==="*")?.action??"allow",Wu=(s,e)=>an(s).filter(n=>!(n.permission==="*"&&n.pattern==="*")).filter(n=>n.pattern!=="*"||n.action!==e),nr=s=>{if(Array.isArray(s))return an(s);if(Ca(s))return[{permission:"*",pattern:"*",action:s}];if(!s||typeof s!="object"||Array.isArray(s))return[];const e=[];for(const[n,a]of Object.entries(s))if(n!=="__originalKeys"){if(Ca(a)){e.push({permission:n,pattern:"*",action:a});continue}if(a&&typeof a=="object"&&!Array.isArray(a))for(const[r,i]of Object.entries(a))Ca(i)&&e.push({permission:n,pattern:r,action:i})}return e},qu=(s,e)=>{const n=an(e),a={};for(const i of n)(a[i.permission]||={})[i.pattern]=i.action;const r={};for(const[i,o]of Object.entries(a))if(i!=="*"){if(Object.keys(o).length===1&&o["*"]){r[i]=o["*"];continue}r[i]=o}return Object.keys(r).length===0?s:(s!=="allow"&&(r["*"]=s),r)},Gu=(s,e)=>{const n=pn(e);if(!n)return[];const r=s.find(i=>i.id===n.providerId)?.models?.find(i=>i.id===n.modelId);return r?.variants?Object.keys(r.variants):[]},Ju=()=>{const{t:s}=dt(),{isMobile:e}=Cs(),n=ut(W=>W.providers),{selectedAgentName:a,getAgentByName:r,createAgent:i,updateAgent:o,agents:d,agentDraft:c,setAgentDraft:f}=Ka(Ss(W=>({selectedAgentName:W.selectedAgentName,getAgentByName:W.getAgentByName,createAgent:W.createAgent,updateAgent:W.updateAgent,agents:W.agents,agentDraft:W.agentDraft,setAgentDraft:W.setAgentDraft}))),m=a?r(a):null,p=!!(c&&c.name===a&&!m),[u,S]=l.useState(""),[h,g]=l.useState("user"),[x,D]=l.useState(""),[N,w]=l.useState("subagent"),[A,k]=l.useState(""),[j,y]=l.useState(""),[P,z]=l.useState(void 0),[R,I]=l.useState(void 0),[v,b]=l.useState(""),[L,E]=l.useState("allow"),[J,_]=l.useState([]),[Z,H]=l.useState([]),[T,Y]=l.useState(""),[F,V]=l.useState("*"),[Q,ie]=l.useState(!1),[X,se]=l.useState(!1),me=l.useRef(null),oe=vs(W=>W.currentDirectory??null),[xe,we]=l.useState([]),he=l.useMemo(()=>Gu(n,A),[A,n]),Ie=he.length>0,ve=l.useMemo(()=>!j||!he.includes(j)?"__default":j,[j,he]),ye=Ie&&(!j||he.includes(j)),be=wd(W=>W.permission);l.useEffect(()=>{let W=!1;return(async()=>{const Ne=await Ns.listToolIds({directory:oe});if(W)return;const Ee=new Set(["write","patch","multiedit"]),Ce=Ne.map(He=>typeof He=="string"?He.trim():"").filter(Boolean).filter(He=>He!=="*").filter(He=>He!=="invalid").filter(He=>!Ee.has(He));we(Array.from(new Set(Ce)).sort((He,q)=>He.localeCompare(q)))})(),()=>{W=!0}},[oe]);const te=l.useMemo(()=>{const W=new Set;for(const de of d){const Ne=an(nr(de.permission));for(const Ee of Ne)Ee.permission&&Ee.permission!=="*"&&Ee.permission!=="invalid"&&W.add(Ee.permission)}for(const de of Object.values(be))for(const Ne of de){const Ee=Ne.permission?.trim();Ee&&Ee!=="invalid"&&W.add(Ee)}for(const de of xe)W.add(de);return Array.from(W).sort((de,Ne)=>de.localeCompare(Ne))},[d,be,xe]),re=l.useMemo(()=>ca(J),[J]),ge=l.useMemo(()=>ca(Z),[Z]),U=l.useCallback(W=>ge.get(dn(W,"*"))?.action,[ge]),ee=l.useCallback(W=>Z.filter(de=>de.permission===W&&de.pattern!=="*").sort((de,Ne)=>de.pattern.localeCompare(Ne.pattern)),[Z]),ne=l.useMemo(()=>{const W=new Set;for(const de of Hi)W.add(de);for(const de of te)W.add(de);return Array.from(W).sort((de,Ne)=>de.localeCompare(Ne))},[te]),ue=l.useCallback(W=>{const de=W==="*"?L:U(W)??L,Ne=ee(W),Ee=!1,Ce=Ne.reduce((q,$)=>(q[$.action]=(q[$.action]??0)+1,q),{allow:0,ask:0,deny:0}),He=["allow","ask","deny"].filter(q=>Ce[q]>0).map(q=>`${Ce[q]} ${q}`).join(", ");return{defaultAction:de,patternRulesCount:Ne.length,patternSummary:He,hasDefaultHint:Ee}},[ee,U,L]),Me=l.useCallback(W=>s(W==="allow"?"settings.common.permission.allow":W==="deny"?"settings.common.permission.deny":"settings.common.permission.ask"),[s]),ke=l.useCallback(W=>W==="global"?s("settings.common.scope.global"):Me(W),[Me,s]),De=l.useMemo(()=>{const W=new Set;for(const de of Hi)W.add(de);for(const de of te)W.add(de);return Array.from(W).sort((de,Ne)=>de.localeCompare(Ne))},[te]),Ae=l.useCallback((W,de,Ne)=>{H(Ee=>{const Ce=ca(Ee);return Ce.set(dn(W,de),{permission:W,pattern:de,action:Ne}),Array.from(Ce.values())})},[]),Pe=l.useCallback((W,de)=>{H(Ne=>{const Ee=ca(Ne);return Ee.delete(dn(W,de)),Array.from(Ee.values())})},[]),Re=l.useCallback((W,de)=>{const Ne=re.get(dn(W,de));if(Ne){Ae(W,de,Ne.action);return}Pe(W,de)},[re,Pe,Ae]),Le=l.useCallback((W,de,Ne)=>{Ae(W,de,Ne)},[Ae]),$e=l.useCallback(W=>{E(W),H(de=>de.filter(Ne=>!(Ne.pattern==="*"&&Ne.action===W)))},[]),Be=l.useCallback(W=>{const de=T.trim();if(!de){B.error(s("settings.agents.page.toast.permissionNameRequired"));return}const Ne=F.trim()||"*";if(de==="*"&&Ne==="*"){$e(W),Y(""),V("*");return}Ne==="*"&&de!=="*"&&W===L?Pe(de,"*"):Ae(de,Ne,W),Y(""),V("*")},[L,T,F,Pe,$e,s,Ae]),Oe=l.useCallback(W=>W==="*"?s("settings.agents.page.permissions.defaultLabel"):W==="webfetch"?"WebFetch":W==="websearch"?"WebSearch":W==="codesearch"?"CodeSearch":W==="doom_loop"?"Doom Loop":W==="external_directory"?"External Directory":W==="todowrite"?"TodoWrite":W==="todoread"?"TodoRead":W.split(/[_-]+/g).filter(Boolean).map(de=>de.charAt(0).toUpperCase()+de.slice(1)).join(" "),[s]);l.useEffect(()=>{Y(""),V("*");const W=de=>{const Ne=an(de),Ee=Hu(Ne),Ce=Wu(Ne,Ee);return E(Ee),_(Ce),H(Ce),{global:Ee,rules:Ce}};if(p&&c){const de=c.name||"",Ne=c.scope||"user",Ee=c.description||"",Ce=c.mode||"subagent",He=c.model||"",q=c.variant||"",$=c.temperature??void 0,fe=c.top_p??void 0,O=c.prompt||"";S(de),g(Ne),D(Ee),w(Ce),k(He),y(q),z($),I(fe),b(O);const Fe=nr(c.permission),Je=W(Fe);me.current={draftName:de,draftScope:Ne,description:Ee,mode:Ce,model:He,variant:q,temperature:$,topP:fe,prompt:O,globalPermission:Je.global,permissionRules:Je.rules};return}if(m&&a===m.name){const de=m.description||"",Ne=m.mode||"subagent",Ee=m.model?.providerID&&m.model?.modelID?`${m.model.providerID}/${m.model.modelID}`:"",Ce=m.variant||"",He=m.temperature,q=m.topP,$=m.prompt||"";D(de),w(Ne),k(Ee),y(Ce),z(He),I(q),b($);const fe=W(nr(m.permission));me.current={draftName:"",draftScope:"user",description:de,mode:Ne,model:Ee,variant:Ce,temperature:He,topP:q,prompt:$,globalPermission:fe.global,permissionRules:fe.rules}}},[c,p,m,a]);const Ue=l.useMemo(()=>{const W=me.current;return W?!!(p&&(u!==W.draftName||h!==W.draftScope)||x!==W.description||N!==W.mode||A!==W.model||j!==W.variant||P!==W.temperature||R!==W.topP||v!==W.prompt||L!==W.globalPermission||!_u(Z,W.permissionRules)):!1},[x,u,h,L,p,N,A,Z,v,P,R,j]),le=async()=>{const W=p?u.trim().replace(/\s+/g,"-"):a?.trim();if(!W){B.error(s("settings.agents.sidebar.toast.agentNameRequired"));return}if(p&&d.some(de=>de.name===W)){B.error(s("settings.agents.sidebar.toast.agentExists"));return}se(!0);try{const de=A.trim(),Ne=j.trim(),Ee=v.trim(),Ce=qu(L,Z),He={name:W,description:x.trim()||void 0,mode:N,model:de===""?null:de,variant:Ne===""?null:Ne||void 0,temperature:P??null,top_p:R??null,prompt:Ee||(p?void 0:null),permission:Ce,scope:p?h:void 0};let q;p?(q=await i(He),q&&f(null)):q=await o(W,He),q?B.success(s(p?"settings.agents.page.toast.created":"settings.agents.page.toast.updated")):B.error(s(p?"settings.agents.page.toast.createFailed":"settings.agents.page.toast.updateFailed"))}catch(de){console.error("Error saving agent:",de);const Ne=de instanceof Error&&de.message?de.message:s("settings.agents.page.toast.saveUnexpectedError");B.error(Ne)}finally{se(!1)}};return a?t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{className:"mb-4 flex items-center justify-between gap-4",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:p?s("settings.agents.page.title.new"):a}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:s(p?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit")})]})}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.agents.page.section.identityRole")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[p&&t.jsxs("div",{"data-settings-item":"agents.name",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.agentName")})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"@"}),t.jsx(it,{value:u,onChange:W=>S(W.target.value),placeholder:s("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),t.jsxs(Ft,{value:h,onValueChange:W=>g(W),children:[t.jsx(Lt,{className:"w-fit min-w-[100px]",children:t.jsx(Kt,{placeholder:s("settings.agents.page.field.scopePlaceholder")})}),t.jsxs(Ot,{align:"end",children:[t.jsx(ht,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{name:"user-3",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.global")})]})}),t.jsx(ht,{value:"project",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{name:"folder",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.project")})]})})]})]})]})]}),t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.common.field.description")}),t.jsx("div",{className:"mt-1.5",children:t.jsx(ps,{value:x,onChange:W=>D(W.target.value),placeholder:s("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]}),t.jsx("div",{"data-settings-item":"agents.mode",className:"pb-1.5 pt-0.5",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.mode")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.agents.page.field.modeTooltip")})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(G,{variant:"chip",size:"xs","aria-pressed":N==="primary",onClick:()=>w("primary"),className:"!font-normal",children:s("settings.agents.page.mode.primary")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":N==="subagent",onClick:()=>w("subagent"),className:"!font-normal",children:s("settings.agents.page.mode.subagent")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":N==="all",onClick:()=>w("all"),className:"!font-normal",children:s("settings.agents.page.mode.all")})]})]})})]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.agents.page.section.modelParameters")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{"data-settings-item":"agents.model",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.overrideModel")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(_r,{providerId:pn(A)?.providerId??"",modelId:pn(A)?.modelId??"",onChange:(W,de)=>{k(W&&de?`${W}/${de}`:""),y("")}})})]}),t.jsxs("div",{"data-settings-item":"agents.variant",className:ce("py-1.5",e?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsxs("div",{className:ce("flex min-w-0 flex-col",e?"w-full":"sm:w-56 shrink-0"),children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.variant")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.agents.page.field.variantTooltip")})]})]}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.agents.page.field.variantHint")})]}),t.jsx("div",{className:ce("flex items-center gap-2",e?"w-full":"w-fit"),children:ye?t.jsxs(Ft,{value:ve,onValueChange:W=>y(W==="__default"?"":W),children:[t.jsx(Lt,{className:ce("max-w-full",e?"w-full":"w-fit min-w-[10rem]"),children:t.jsx(Kt,{placeholder:s("settings.agents.page.field.variantPlaceholder"),children:W=>W==="__default"?s("chat.modelControls.default"):W})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"__default",children:s("chat.modelControls.default")}),he.map(W=>t.jsx(ht,{value:W,children:W},W))]})]}):t.jsxs(t.Fragment,{children:[t.jsx(it,{value:j,onChange:W=>y(W.target.value),placeholder:s("settings.agents.page.field.variantPlaceholder"),disabled:!A&&!j,className:ce("h-7 w-40",e&&"w-full")}),j&&t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>y(""),className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":s("settings.common.actions.clear"),title:s("settings.common.actions.clear"),children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})})]}),t.jsxs("div",{"data-settings-item":"agents.temperature",className:ce("py-1.5",e?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsxs("div",{className:ce("flex min-w-0 flex-col",e?"w-full":"sm:w-56 shrink-0"),children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.temperature")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.agents.page.field.temperatureTooltip")})]})]}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.agents.page.field.temperatureRange")})]}),t.jsxs("div",{className:ce("flex items-center gap-2",e?"w-full":"w-fit"),children:[t.jsx(xs,{value:P,fallbackValue:.7,onValueChange:z,onClear:()=>z(void 0),min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),P!==void 0&&t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>z(void 0),className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":s("settings.agents.page.field.clearTemperatureAria"),title:s("settings.common.actions.clear"),children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})]}),t.jsxs("div",{"data-settings-item":"agents.top-p",className:ce("py-1.5",e?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsxs("div",{className:ce("flex min-w-0 flex-col",e?"w-full":"sm:w-56 shrink-0"),children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.topP")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.agents.page.field.topPTooltip")})]})]}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.agents.page.field.topPRange")})]}),t.jsxs("div",{className:ce("flex items-center gap-2",e?"w-full":"w-fit"),children:[t.jsx(xs,{value:R,fallbackValue:.9,onValueChange:I,onClear:()=>I(void 0),min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:"w-16"}),R!==void 0&&t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>I(void 0),className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":s("settings.agents.page.field.clearTopPAria"),title:s("settings.common.actions.clear"),children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})]})]})]}),t.jsxs("div",{"data-settings-item":"agents.system-prompt",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.agents.page.section.systemPrompt")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsx(ps,{value:v,onChange:W=>b(W.target.value),placeholder:s("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y"})})]}),t.jsxs("div",{"data-settings-item":"agents.permissions",className:"mb-2",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center justify-between gap-4",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.agents.page.section.toolPermissions")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ie(W=>!W),children:s(Q?"settings.agents.page.permissions.hideEditor":"settings.agents.page.permissions.advancedEditor")})]}),Q?t.jsxs("div",{className:"space-y-6 px-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.permissions.globalDefault")}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 font-mono",children:"*"})]}),t.jsxs(Ft,{value:L,onValueChange:W=>$e(W),children:[t.jsx(Lt,{className:"w-[100px]",children:t.jsx(Kt,{children:Me(L)})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"allow",children:s("settings.common.permission.allow")}),t.jsx(ht,{value:"ask",children:s("settings.common.permission.ask")}),t.jsx(ht,{value:"deny",children:s("settings.common.permission.deny")})]})]})]}),t.jsx("div",{className:"space-y-4",children:ne.filter(W=>W!=="*").map(W=>{const de=Oe(W),{defaultAction:Ne,patternRulesCount:Ee}=ue(W),Ce=U(W),He=Ce??"global",q=ee(W),$=["allow","ask","deny"].filter(fe=>fe!==L);return t.jsxs("div",{className:"border-t border-[var(--surface-subtle)] pt-2",children:[t.jsxs("div",{className:"flex items-center justify-between py-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:de}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 font-mono",children:W})]}),t.jsx("div",{className:"typography-micro text-muted-foreground",children:Ee>0?s("settings.agents.page.permissions.globalSummary",{summary:Ne}):Ne})]}),t.jsxs("div",{className:"space-y-1 pl-2 mt-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground",children:s("settings.agents.page.permissions.pattern")}),t.jsx("span",{className:"typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded",children:"*"}),Ce&&t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>Re(W,"*"),className:"px-1.5 py-0 h-5",children:t.jsx(M,{name:"subtract",className:"h-3.5 w-3.5 text-muted-foreground hover:text-foreground"})})]}),t.jsxs(Ft,{value:He,onValueChange:fe=>{if(fe==="global"){Pe(W,"*");return}Ae(W,"*",fe)},children:[t.jsx(Lt,{className:"w-[90px]",children:t.jsx(Kt,{children:ke(He)})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"global",children:s("settings.common.scope.global")}),$.map(fe=>t.jsx(ht,{value:fe,className:"capitalize",children:Me(fe)},fe))]})]})]}),q.map(fe=>{const O=dn(fe.permission,fe.pattern),Fe=re.get(O),Je=!Fe,Xe=!!(Fe&&Fe.action!==fe.action);return t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground",children:s("settings.agents.page.permissions.pattern")}),t.jsx("span",{className:"typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded",children:fe.pattern}),Je&&t.jsx("span",{className:"typography-micro text-[var(--status-success)]",children:s("settings.common.badge.new")}),Xe&&t.jsx("span",{className:"typography-micro text-[var(--status-warning)]",children:s("settings.common.badge.modified")}),(Je||Xe)&&t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>Je?Pe(fe.permission,fe.pattern):Re(fe.permission,fe.pattern),className:"px-1.5 py-0 h-5",children:t.jsx(M,{name:"subtract",className:"h-3.5 w-3.5 text-muted-foreground hover:text-foreground"})})]}),t.jsxs(Ft,{value:fe.action,onValueChange:et=>Le(fe.permission,fe.pattern,et),children:[t.jsx(Lt,{className:"w-[90px]",children:t.jsx(Kt,{children:Me(fe.action)})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"allow",children:s("settings.common.permission.allow")}),t.jsx(ht,{value:"ask",children:s("settings.common.permission.ask")}),t.jsx(ht,{value:"deny",children:s("settings.common.permission.deny")})]})]})]},O)})]})]},W)})}),t.jsxs("div",{className:"border-t border-[var(--surface-subtle)] pt-3",children:[t.jsx("h4",{className:"typography-ui-label text-foreground mb-2",children:s("settings.agents.page.permissions.addCustomRule")}),t.jsxs("div",{className:"flex flex-col sm:flex-row items-end sm:items-center gap-2",children:[t.jsxs(Ft,{value:T,onValueChange:Y,children:[t.jsx(Lt,{className:"w-full sm:w-[160px]",children:T?t.jsx("span",{className:"truncate",children:Oe(T)}):t.jsx("span",{className:"text-muted-foreground",children:s("settings.agents.page.permissions.permissionPlaceholder")})}),t.jsx(Ot,{children:De.map(W=>t.jsx(ht,{value:W,children:t.jsx("div",{className:"flex items-center justify-between gap-2 w-full",children:t.jsx("span",{children:Oe(W)})})},W))})]}),t.jsx(it,{value:F,onChange:W=>V(W.target.value),placeholder:s("settings.agents.page.permissions.patternPlaceholder"),className:"h-7 flex-1 font-mono text-xs"}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Be("allow"),children:s("settings.common.permission.allow")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Be("ask"),children:s("settings.common.permission.ask")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Be("deny"),children:s("settings.common.permission.deny")})]})]})]})]}):t.jsx("section",{className:"px-2 pb-2 pt-0 space-y-0",children:ne.map((W,de)=>{const{defaultAction:Ne,patternRulesCount:Ee,patternSummary:Ce,hasDefaultHint:He}=ue(W),q=Oe(W),$=He?`${Ne} (env blocked)`:Ne;return t.jsxs("div",{className:ce("flex flex-col gap-1 py-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-8",de>0&&"border-t border-[var(--surface-subtle)]"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:q}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block",children:W})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[Ee>0?t.jsx("span",{className:"typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:s("settings.agents.page.permissions.globalSummary",{summary:$})}):t.jsx("span",{className:ce("typography-micro capitalize px-1.5 py-0.5 rounded",$==="allow"?"text-[var(--status-success)] bg-[var(--status-success)]/10":$==="deny"?"text-[var(--status-error)] bg-[var(--status-error)]/10":"text-[var(--status-warning)] bg-[var(--status-warning)]/10"),children:$}),Ee>0&&t.jsx("span",{className:"typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:s("settings.agents.page.permissions.rulesSummary",{summary:Ce})})]})]},W)})})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(G,{onClick:le,disabled:X||!Ue,size:"xs",className:"!font-normal",children:s(X?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(M,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.agents.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.agents.page.empty.description")})]})})},Qu="~/.config/opencode/AGENTS.md",Al=async(s,e)=>{const n=await s.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},Yu=s=>s.length>0&&!s.endsWith(`
|
|
2
|
-
`)?`${s}
|
|
3
|
-
`:s,da={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},Xu=(s,e)=>s==="custom"?e:kd(s),Zu=s=>s==="custom"?"custom":hl(s)?s:"concise",qi={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"},Gi=async(s,e)=>{const n=await jt("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(await Al(n,e))},ep=()=>{const{t:s}=dt(),[e,n]=l.useState(""),[a,r]=l.useState(da.responseStyleEnabled),[i,o]=l.useState(da.responseStylePreset),[d,c]=l.useState(da.responseStyleCustomInstructions),[f,m]=l.useState(!0),[p,u]=l.useState(!1),[S,h]=l.useState(""),g=l.useRef(null);l.useEffect(()=>{const w=new AbortController;return(async()=>{try{const[k,j]=await Promise.all([jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"},signal:w.signal}),jt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:w.signal})]);let y=da;if(k.ok){const P=await k.json();y={...y,responseStyleEnabled:P.responseStyleEnabled===!0,responseStylePreset:Zu(P.responseStylePreset),responseStyleCustomInstructions:typeof P.responseStyleCustomInstructions=="string"?P.responseStyleCustomInstructions:""},typeof P.globalBehaviorPrompt=="string"&&(y={...y,prompt:P.globalBehaviorPrompt})}if(!y.prompt.trim()&&j.ok){const P=await j.json();typeof P.content=="string"&&(y={...y,prompt:P.content})}n(y.prompt),r(y.responseStyleEnabled),o(y.responseStylePreset),c(y.responseStyleCustomInstructions),h(y.prompt),g.current={enabled:y.responseStyleEnabled,preset:y.responseStylePreset,custom:y.responseStyleCustomInstructions}}catch(k){k.name!=="AbortError"&&console.warn("Failed to load behavior settings:",k)}finally{m(!1)}})(),()=>w.abort()},[]),l.useEffect(()=>{if(f)return;const w=g.current;if(w&&w.enabled===a&&w.preset===i&&w.custom===d)return;const A={enabled:a,preset:i,custom:d},k=setTimeout(async()=>{try{await Gi({responseStyleEnabled:A.enabled,responseStylePreset:A.preset,responseStyleCustomInstructions:A.custom},s("settings.behavior.page.toast.saveFailed")),g.current=A}catch(j){const y=j instanceof Error?j.message:s("settings.behavior.page.toast.saveFailed");B.error(y)}},400);return()=>clearTimeout(k)},[a,i,d,f,s]);const x=Xu(i,d),D=e!==S,N=async()=>{u(!0);try{const w=Yu(e),A=await jt("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:w})});if(!A.ok)throw new Error(await Al(A,s("settings.behavior.page.toast.saveFailed")));await Gi({globalBehaviorPrompt:w},s("settings.behavior.page.toast.saveFailed")),n(w),h(w),B.success(s("settings.behavior.page.toast.saved"))}catch(w){console.error("Failed to save behavior:",w);const A=w instanceof Error?w.message:s("settings.behavior.page.toast.saveFailed");B.error(A)}finally{u(!1)}};return t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8 space-y-6",children:[t.jsx("div",{className:"space-y-1",children:t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground",children:s("settings.behavior.page.title")})}),t.jsxs("div",{"data-settings-item":"behavior.system-prompt",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.behavior.page.section.systemPrompt")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"font-medium text-foreground",children:s("settings.behavior.page.warning.title")}),t.jsx("p",{children:s("settings.behavior.page.warning.description",{path:Qu})})]})})]})]})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsx(ps,{value:e,onChange:w=>n(w.target.value),placeholder:s("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"}),t.jsx(G,{onClick:N,disabled:p||!D||f,size:"xs",className:"!font-normal",children:s(p?"settings.common.actions.saving":"settings.common.actions.saveChanges")})]})]}),t.jsxs("div",{"data-settings-item":"behavior.response-style",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.behavior.page.section.responseStyle")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.behavior.page.responseStyle.tooltip")})]})]})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("label",{className:"flex items-center gap-2 typography-ui-label text-foreground",children:[t.jsx(It,{checked:a,onChange:r,disabled:f,ariaLabel:s("settings.behavior.page.responseStyle.enableAria")}),s("settings.behavior.page.responseStyle.enable")]}),t.jsxs(Ft,{value:i,onValueChange:w=>o(w),disabled:f||!a,children:[t.jsx(Lt,{className:"w-full sm:w-56",size:"lg",children:t.jsx(Kt,{children:w=>w==="custom"?s("settings.behavior.page.responseStyle.option.custom"):hl(w)?s(qi[w]):null})}),t.jsxs(Ot,{children:[Nd.map(w=>t.jsx(ht,{value:w,children:s(qi[w])},w)),t.jsx(ht,{value:"custom",children:s("settings.behavior.page.responseStyle.option.custom")})]})]}),t.jsx(ps,{value:x,onChange:w=>c(w.target.value),placeholder:s("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:f||!a||i!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})]})})},tp=s=>{const e=rt.c(169),{onItemSelect:n}=s,{t:a}=dt(),[r,i]=l.useState(null),[o,d]=l.useState(""),[c,f]=l.useState(null),[m,p]=l.useState(null),[u,S]=l.useState(!1),[h,g]=l.useState(null),{selectedCommandName:x,commands:D,setSelectedCommand:N,setCommandDraft:w,createCommand:A,deleteCommand:k,loadCommands:j}=$a(Ss(sp)),y=_s(np),P=_s(ap);let z,R;e[0]!==j||e[1]!==P?(z=()=>{j(),P()},R=[j,P],e[0]=j,e[1]=P,e[2]=z,e[3]=R):(z=e[2],R=e[3]),l.useEffect(z,R);let I;e[4]!==y?(I=new Set(y.map(rp)),e[4]=y,e[5]=I):I=e[5];const v=I;let b;if(e[6]!==D||e[7]!==v){let pe;e[9]!==v?(pe=st=>!v.has(st.name),e[9]=v,e[10]=pe):pe=e[10],b=D.filter(pe),e[6]=D,e[7]=v,e[8]=b}else b=e[8];const L=b;let E,J;e[11]!==x||e[12]!==N||e[13]!==v?(E=()=>{x&&v.has(x)&&N(null)},J=[x,N,v],e[11]=x,e[12]=N,e[13]=v,e[14]=E,e[15]=J):(E=e[14],J=e[15]),l.useEffect(E,J);let _;e[16]!==D||e[17]!==n||e[18]!==w||e[19]!==N?(_=()=>{let pe="new-command",st=1;for(;D.some(nt=>nt.name===pe);)pe=`new-command-${st}`,st++;w({name:pe,scope:"user"}),N(pe),n?.()},e[16]=D,e[17]=n,e[18]=w,e[19]=N,e[20]=_):_=e[20];const Z=_;let H;e[21]!==a?(H=async pe=>{if(Dn(pe)){B.error(a("settings.commands.sidebar.toast.builtInCannotDelete"));return}f(pe),p("delete")},e[21]=a,e[22]=H):H=e[22];const T=H;let Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=async pe=>{Dn(pe)&&(f(pe),p("reset"))},e[23]=Y):Y=e[23];const F=Y;let V;e[24]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{f(null),p(null)},e[24]=V):V=e[24];const Q=V;let ie;e[25]!==c||e[26]!==m||e[27]!==k||e[28]!==a?(ie=async()=>{if(!c||!m)return;S(!0),await k(c.name)?(m==="delete"?B.success(a("settings.commands.sidebar.toast.commandDeleted",{name:c.name})):B.success(a("settings.commands.sidebar.toast.commandReset",{name:c.name})),Q()):m==="delete"?B.error(a("settings.commands.sidebar.toast.deleteFailed")):B.error(a("settings.commands.sidebar.toast.resetFailed")),S(!1)},e[25]=c,e[26]=m,e[27]=k,e[28]=a,e[29]=ie):ie=e[29];const X=ie;let se;e[30]!==D||e[31]!==w||e[32]!==N?(se=pe=>{const st=pe.name;let nt=1,Ge=`${st}-copy`;for(;D.some(ft=>ft.name===Ge);)nt++,Ge=`${st}-copy-${nt}`;w({name:Ge,scope:pe.scope||"user",description:pe.description,template:pe.template,agent:pe.agent,model:pe.model}),N(Ge)},e[30]=D,e[31]=w,e[32]=N,e[33]=se):se=e[33];const me=se;let oe;e[34]===Symbol.for("react.memo_cache_sentinel")?(oe=pe=>{d(pe.name),i(pe)},e[34]=oe):oe=e[34];const xe=oe;let we;e[35]!==D||e[36]!==A||e[37]!==k||e[38]!==r||e[39]!==o||e[40]!==N||e[41]!==a?(we=async()=>{if(!r)return;const pe=o.trim().replace(/\s+/g,"-");if(!pe){B.error(a("settings.commands.sidebar.toast.commandNameRequired"));return}if(pe===r.name){i(null);return}if(D.some(nt=>nt.name===pe)){B.error(a("settings.commands.sidebar.toast.commandExists"));return}await A({name:pe,description:r.description,template:r.template,agent:r.agent,model:r.model})?await k(r.name)?(B.success(`Command renamed to "${pe}"`),N(pe)):B.error(a("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):B.error(a("settings.commands.sidebar.toast.renameFailed")),i(null)},e[35]=D,e[36]=A,e[37]=k,e[38]=r,e[39]=o,e[40]=N,e[41]=a,e[42]=we):we=e[42];const he=we;let Ie,ve,ye,be,te,re;if(e[43]!==L||e[44]!==Z||e[45]!==T||e[46]!==me||e[47]!==n||e[48]!==h||e[49]!==x||e[50]!==N||e[51]!==a){const pe=L.filter(Dn),st=L.filter(ip);e[58]===Symbol.for("react.memo_cache_sentinel")?(te=ce("flex h-full flex-col","bg-background"),e[58]=te):te=e[58];let nt;e[59]!==a?(nt=a("settings.commands.sidebar.title"),e[59]=a,e[60]=nt):nt=e[60];let Ge;e[61]!==nt?(Ge=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:nt}),e[61]=nt,e[62]=Ge):Ge=e[62];let ft;e[63]===Symbol.for("react.memo_cache_sentinel")?(ft=t.jsx(ta,{className:"mb-3"}),e[63]=ft):ft=e[63];let wt;e[64]!==L.length||e[65]!==a?(wt=a("settings.commands.sidebar.total",{count:L.length}),e[64]=L.length,e[65]=a,e[66]=wt):wt=e[66];let Ct;e[67]!==wt?(Ct=t.jsx("span",{className:"typography-meta text-muted-foreground",children:wt}),e[67]=wt,e[68]=Ct):Ct=e[68];let ae;e[69]===Symbol.for("react.memo_cache_sentinel")?(ae=t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),e[69]=ae):ae=e[69];let Ve;e[70]!==Z?(Ve=t.jsx(G,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:Z,children:ae}),e[70]=Z,e[71]=Ve):Ve=e[71];let tt;e[72]!==Ct||e[73]!==Ve?(tt=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Ct,Ve]}),e[72]=Ct,e[73]=Ve,e[74]=tt):tt=e[74],e[75]!==Ge||e[76]!==tt?(re=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[Ge,ft,tt]}),e[75]=Ge,e[76]=tt,e[77]=re):re=e[77],Ie=Jt,ve="flex-1 min-h-0",ye="space-y-1 px-3 py-2",be=L.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(M,{name:"terminal-box",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:a("settings.commands.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.commands.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[pe.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.commands.sidebar.section.builtIn")}),[...pe].sort(op).map(Ye=>t.jsx(Ji,{command:Ye,isSelected:x===Ye.name,onSelect:()=>{N(Ye.name),n?.()},onReset:()=>F(Ye),onDuplicate:()=>me(Ye),isMenuOpen:h===Ye.name,onMenuOpenChange:yt=>g(yt?Ye.name:null)},Ye.name))]}),st.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.commands.sidebar.section.custom")}),[...st].sort(lp).map(Ye=>t.jsx(Ji,{command:Ye,isSelected:x===Ye.name,onSelect:()=>{N(Ye.name),n?.()},onRename:()=>xe(Ye),onDelete:()=>T(Ye),onDuplicate:()=>me(Ye),isMenuOpen:h===Ye.name,onMenuOpenChange:yt=>g(yt?Ye.name:null)},Ye.name))]})]}),e[43]=L,e[44]=Z,e[45]=T,e[46]=me,e[47]=n,e[48]=h,e[49]=x,e[50]=N,e[51]=a,e[52]=Ie,e[53]=ve,e[54]=ye,e[55]=be,e[56]=te,e[57]=re}else Ie=e[52],ve=e[53],ye=e[54],be=e[55],te=e[56],re=e[57];let ge;e[78]!==Ie||e[79]!==ve||e[80]!==ye||e[81]!==be?(ge=t.jsx(Ie,{outerClassName:ve,className:ye,children:be}),e[78]=Ie,e[79]=ve,e[80]=ye,e[81]=be,e[82]=ge):ge=e[82];const U=c!==null&&m!==null;let ee;e[83]!==u?(ee=pe=>{!pe&&!u&&Q()},e[83]=u,e[84]=ee):ee=e[84];let ne;e[85]!==m||e[86]!==a?(ne=a(m==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[85]=m,e[86]=a,e[87]=ne):ne=e[87];let ue;e[88]!==ne?(ue=t.jsx(Vt,{children:ne}),e[88]=ne,e[89]=ue):ue=e[89];let Me;e[90]!==c?.name||e[91]!==m||e[92]!==a?(Me=m==="delete"?a("settings.commands.sidebar.dialog.deleteDescription",{name:c?.name??""}):a("settings.commands.sidebar.dialog.resetDescription",{name:c?.name??""}),e[90]=c?.name,e[91]=m,e[92]=a,e[93]=Me):Me=e[93];let ke;e[94]!==Me?(ke=t.jsx(qt,{children:Me}),e[94]=Me,e[95]=ke):ke=e[95];let De;e[96]!==ue||e[97]!==ke?(De=t.jsxs(_t,{children:[ue,ke]}),e[96]=ue,e[97]=ke,e[98]=De):De=e[98];let Ae;e[99]!==a?(Ae=a("settings.common.actions.cancel"),e[99]=a,e[100]=Ae):Ae=e[100];let Pe;e[101]!==u||e[102]!==Ae?(Pe=t.jsx(G,{size:"sm",variant:"ghost",onClick:Q,disabled:u,children:Ae}),e[101]=u,e[102]=Ae,e[103]=Pe):Pe=e[103];let Re;e[104]!==m||e[105]!==a?(Re=a(m==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[104]=m,e[105]=a,e[106]=Re):Re=e[106];let Le;e[107]!==X||e[108]!==u||e[109]!==Re?(Le=t.jsx(G,{size:"sm",onClick:X,disabled:u,children:Re}),e[107]=X,e[108]=u,e[109]=Re,e[110]=Le):Le=e[110];let $e;e[111]!==Pe||e[112]!==Le?($e=t.jsxs(Yt,{children:[Pe,Le]}),e[111]=Pe,e[112]=Le,e[113]=$e):$e=e[113];let Be;e[114]!==De||e[115]!==$e?(Be=t.jsxs(Bt,{className:"max-w-md",children:[De,$e]}),e[114]=De,e[115]=$e,e[116]=Be):Be=e[116];let Oe;e[117]!==U||e[118]!==ee||e[119]!==Be?(Oe=t.jsx(Ut,{open:U,onOpenChange:ee,children:Be}),e[117]=U,e[118]=ee,e[119]=Be,e[120]=Oe):Oe=e[120];const Ue=r!==null;let le;e[121]===Symbol.for("react.memo_cache_sentinel")?(le=pe=>!pe&&i(null),e[121]=le):le=e[121];let W;e[122]!==a?(W=a("settings.commands.sidebar.renameDialog.title"),e[122]=a,e[123]=W):W=e[123];let de;e[124]!==W?(de=t.jsx(Vt,{children:W}),e[124]=W,e[125]=de):de=e[125];const Ne=r?.name??"";let Ee;e[126]!==a||e[127]!==Ne?(Ee=a("settings.commands.sidebar.renameDialog.description",{name:Ne}),e[126]=a,e[127]=Ne,e[128]=Ee):Ee=e[128];let Ce;e[129]!==Ee?(Ce=t.jsx(qt,{children:Ee}),e[129]=Ee,e[130]=Ce):Ce=e[130];let He;e[131]!==de||e[132]!==Ce?(He=t.jsxs(_t,{children:[de,Ce]}),e[131]=de,e[132]=Ce,e[133]=He):He=e[133];let q;e[134]===Symbol.for("react.memo_cache_sentinel")?(q=pe=>d(pe.target.value),e[134]=q):q=e[134];let $;e[135]!==a?($=a("settings.commands.sidebar.renameDialog.placeholder"),e[135]=a,e[136]=$):$=e[136];let fe;e[137]!==he?(fe=pe=>{pe.key==="Enter"&&he()},e[137]=he,e[138]=fe):fe=e[138];let O;e[139]!==o||e[140]!==$||e[141]!==fe?(O=t.jsx(it,{value:o,onChange:q,placeholder:$,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:fe}),e[139]=o,e[140]=$,e[141]=fe,e[142]=O):O=e[142];let Fe;e[143]===Symbol.for("react.memo_cache_sentinel")?(Fe=()=>i(null),e[143]=Fe):Fe=e[143];let Je;e[144]!==a?(Je=a("settings.common.actions.cancel"),e[144]=a,e[145]=Je):Je=e[145];let Xe;e[146]!==Je?(Xe=t.jsx(G,{size:"sm",variant:"ghost",onClick:Fe,children:Je}),e[146]=Je,e[147]=Xe):Xe=e[147];let et;e[148]!==a?(et=a("settings.common.actions.rename"),e[148]=a,e[149]=et):et=e[149];let at;e[150]!==he||e[151]!==et?(at=t.jsx(G,{size:"sm",onClick:he,children:et}),e[150]=he,e[151]=et,e[152]=at):at=e[152];let lt;e[153]!==Xe||e[154]!==at?(lt=t.jsxs(Yt,{children:[Xe,at]}),e[153]=Xe,e[154]=at,e[155]=lt):lt=e[155];let Ze;e[156]!==He||e[157]!==O||e[158]!==lt?(Ze=t.jsxs(Bt,{children:[He,O,lt]}),e[156]=He,e[157]=O,e[158]=lt,e[159]=Ze):Ze=e[159];let We;e[160]!==Ue||e[161]!==Ze?(We=t.jsx(Ut,{open:Ue,onOpenChange:le,children:Ze}),e[160]=Ue,e[161]=Ze,e[162]=We):We=e[162];let pt;return e[163]!==te||e[164]!==re||e[165]!==ge||e[166]!==Oe||e[167]!==We?(pt=t.jsxs("div",{className:te,children:[re,ge,Oe,We]}),e[163]=te,e[164]=re,e[165]=ge,e[166]=Oe,e[167]=We,e[168]=pt):pt=e[168],pt},Ji=s=>{const e=rt.c(47),{command:n,isSelected:a,onSelect:r,onDelete:i,onReset:o,onRename:d,onDuplicate:c,isMenuOpen:f,onMenuOpenChange:m}=s,{t:p}=dt();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Qn(),e[0]=u):u=e[0];const S=u,[h,g]=l.useState(!1);let x;e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==o||e[5]!==p?(x=H=>t.jsxs(t.Fragment,{children:[d&&t.jsxs(H,{onClick:T=>{T.stopPropagation(),d()},children:[t.jsx(M,{name:"edit",className:"h-4 w-4 mr-px"}),p("settings.common.actions.rename")]}),t.jsxs(H,{onClick:T=>{T.stopPropagation(),c()},children:[t.jsx(M,{name:"file-copy",className:"h-4 w-4 mr-px"}),p("settings.common.actions.duplicate")]}),o&&t.jsxs(H,{onClick:T=>{T.stopPropagation(),o()},children:[t.jsx(M,{name:"restart",className:"h-4 w-4 mr-px"}),p("settings.common.actions.reset")]}),i&&t.jsxs(H,{onClick:T=>{T.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(M,{name:"delete-bin",className:"h-4 w-4 mr-px"}),p("settings.common.actions.delete")]})]}),e[1]=i,e[2]=c,e[3]=d,e[4]=o,e[5]=p,e[6]=x):x=e[6];const D=x,N=a?"bg-interactive-selection":"hover:bg-interactive-hover";let w;e[7]!==N?(w=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",N),e[7]=N,e[8]=w):w=e[8];let A;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=S?void 0:H=>{H.preventDefault(),g(!0)},e[9]=A):A=e[9];let k;e[10]!==w?(k=t.jsx("div",{className:w,onContextMenu:A}),e[10]=w,e[11]=k):k=e[11];let j;e[12]!==n.name?(j=t.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",n.name]}),e[12]=n.name,e[13]=j):j=e[13];let y;e[14]!==n||e[15]!==p?(y=(n.scope||Dn(n))&&t.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:Dn(n)?p("settings.agents.sidebar.badge.system"):n.scope}),e[14]=n,e[15]=p,e[16]=y):y=e[16];let P;e[17]!==j||e[18]!==y?(P=t.jsxs("div",{className:"flex items-center gap-2",children:[j,y]}),e[17]=j,e[18]=y,e[19]=P):P=e[19];let z;e[20]!==n.description?(z=n.description&&t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n.description}),e[20]=n.description,e[21]=z):z=e[21];let R;e[22]!==r||e[23]!==z||e[24]!==P?(R=t.jsxs("button",{onClick:r,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[P,z]}),e[22]=r,e[23]=z,e[24]=P,e[25]=R):R=e[25];let I;e[26]!==m?(I=H=>{H&&g(!1),m(H)},e[26]=m,e[27]=I):I=e[27];let v;e[28]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(ds,{asChild:!0,children:t.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=v):v=e[28];let b;e[29]!==D?(b=t.jsx(ms,{align:"end",className:"w-fit min-w-20",children:D(js)}),e[29]=D,e[30]=b):b=e[30];let L;e[31]!==f||e[32]!==I||e[33]!==b?(L=t.jsxs(us,{open:f,onOpenChange:I,children:[v,b]}),e[31]=f,e[32]=I,e[33]=b,e[34]=L):L=e[34];let E;e[35]!==R||e[36]!==L?(E=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[R,L]}),e[35]=R,e[36]=L,e[37]=E):E=e[37];let J;e[38]!==E||e[39]!==k?(J=t.jsx(sn,{render:k,children:E}),e[38]=E,e[39]=k,e[40]=J):J=e[40];let _;e[41]!==D?(_=t.jsx(nn,{className:"w-fit min-w-20",children:D(Ws)}),e[41]=D,e[42]=_):_=e[42];let Z;return e[43]!==h||e[44]!==J||e[45]!==_?(Z=t.jsxs(tn,{open:h,onOpenChange:g,children:[J,_]}),e[43]=h,e[44]=J,e[45]=_,e[46]=Z):Z=e[46],Z};function sp(s){return{selectedCommandName:s.selectedCommandName,commands:s.commands,setSelectedCommand:s.setSelectedCommand,setCommandDraft:s.setCommandDraft,createCommand:s.createCommand,deleteCommand:s.deleteCommand,loadCommands:s.loadCommands}}function np(s){return s.skills}function ap(s){return s.loadSkills}function rp(s){return s.name}function ip(s){return!Dn(s)}function op(s,e){return s.name.localeCompare(e.name)}function lp(s,e){return s.name.localeCompare(e.name)}const cp=()=>{const{t:s}=dt(),{selectedCommandName:e,getCommandByName:n,createCommand:a,updateCommand:r,commands:i,commandDraft:o,setCommandDraft:d}=$a(Ss(I=>({selectedCommandName:I.selectedCommandName,getCommandByName:I.getCommandByName,createCommand:I.createCommand,updateCommand:I.updateCommand,commands:I.commands,commandDraft:I.commandDraft,setCommandDraft:I.setCommandDraft}))),c=e?n(e):null,f=!!(o&&o.name===e&&!c),[m,p]=l.useState(""),[u,S]=l.useState("user"),[h,g]=l.useState(""),[x,D]=l.useState(""),[N,w]=l.useState(""),[A,k]=l.useState(""),[j,y]=l.useState(!1),P=l.useRef(null);l.useEffect(()=>{if(f&&o){const I=o.name||"",v=o.scope||"user",b=o.description||"",L=o.agent||"",E=o.model||"",J=o.template||"";p(I),S(v),g(b),D(L),w(E),k(J),P.current={draftName:I,draftScope:v,description:b,agent:L,model:E,template:J}}else if(c){const I=c.description||"",v=c.agent||"",b=c.model||"",L=c.template||"";g(I),D(v),w(b),k(L),P.current={draftName:"",draftScope:"user",description:I,agent:v,model:b,template:L}}},[c,f,e,i,o]);const z=l.useMemo(()=>{const I=P.current;return I?!!(f&&(m!==I.draftName||u!==I.draftScope)||h!==I.description||x!==I.agent||N!==I.model||A!==I.template):!1},[x,h,m,u,f,N,A]),R=async()=>{const I=f?m.trim().replace(/\s+/g,"-"):e?.trim();if(!I){B.error(s("settings.commands.sidebar.toast.commandNameRequired"));return}if(!A.trim()){B.error(s("settings.commands.page.toast.templateRequired"));return}if(f&&i.some(v=>v.name===I)){B.error(s("settings.commands.sidebar.toast.commandExists"));return}y(!0);try{const v=x.trim(),b=N.trim(),L=A.trim(),E={name:I,description:h.trim()||void 0,agent:v===""?null:v,model:b===""?null:b,template:L,scope:f?u:void 0};let J;f?(J=await a(E),J&&d(null)):J=await r(I,E),J?B.success(s(f?"settings.commands.page.toast.created":"settings.commands.page.toast.updated")):B.error(s(f?"settings.commands.page.toast.createFailed":"settings.commands.page.toast.updateFailed"))}catch(v){console.error("Error saving command:",v),B.error(s("settings.commands.page.toast.saveUnexpectedError"))}finally{y(!1)}};return e?t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{className:"mb-4 flex items-center justify-between gap-4",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:f?s("settings.commands.page.title.new"):`/${e}`}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:s(f?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit")})]})}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.commands.page.section.identity")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[f&&t.jsxs("div",{"data-settings-item":"commands.name",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.commands.page.field.commandName")})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"/"}),t.jsx(it,{value:m,onChange:I=>p(I.target.value),placeholder:s("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),t.jsxs(Ft,{value:u,onValueChange:I=>S(I),children:[t.jsx(Lt,{className:"w-fit min-w-[100px]",children:t.jsx(Kt,{placeholder:s("settings.agents.page.field.scopePlaceholder")})}),t.jsxs(Ot,{align:"end",children:[t.jsx(ht,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{name:"user-3",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.global")})]})}),t.jsx(ht,{value:"project",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{name:"folder",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.project")})]})})]})]})]})]}),t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.common.field.description")}),t.jsx("div",{className:"mt-1.5",children:t.jsx(ps,{value:h,onChange:I=>g(I.target.value),placeholder:s("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.commands.page.section.executionContext")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{"data-settings-item":"commands.agent",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.commands.page.field.overrideAgent")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(fl,{agentName:x,onChange:I=>D(I)})})]}),t.jsxs("div",{"data-settings-item":"commands.model",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.agents.page.field.overrideModel")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(_r,{providerId:pn(N)?.providerId??"",modelId:pn(N)?.modelId??"",onChange:(I,v)=>{w(I&&v?`${I}/${v}`:"")}})})]})]})]}),t.jsxs("div",{"data-settings-item":"commands.template",className:"mb-2",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.commands.page.section.template")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsx(ps,{value:A,onChange:I=>k(I.target.value),placeholder:s("settings.commands.page.field.templatePlaceholder"),rows:12,className:"w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y"})}),t.jsx("div",{className:"mt-2 px-2",children:t.jsxs("p",{className:"typography-meta text-muted-foreground",children:[t.jsx("code",{className:"text-foreground",children:"$ARGUMENTS"})," ",s("settings.commands.page.templateHint.userInput")," ·"," ",t.jsx("code",{className:"text-foreground",children:"!`cmd`"})," ",s("settings.commands.page.templateHint.shellOutput")," ·"," ",t.jsx("code",{className:"text-foreground",children:"@file"})," ",s("settings.commands.page.templateHint.fileContents")]})})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(G,{onClick:R,disabled:j||!z,size:"xs",className:"!font-normal",children:s(j?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(M,{name:"terminal-box",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.commands.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.commands.page.empty.description")})]})})},Qi=s=>{switch(s){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"idle"}},Yi=s=>{const e=rt.c(5),{tone:n,enabled:a}=s;if(!a){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0"}),e[0]=o):o=e[0],o}let r;e[1]!==n?(r=ce("inline-block h-2 w-2 rounded-full flex-shrink-0",{success:"bg-[var(--status-success)]",error:"bg-[var(--status-error)]",warning:"bg-[var(--status-warning)]",idle:"bg-muted-foreground/40"}[n]),e[1]=n,e[2]=r):r=e[2];let i;return e[3]!==r?(i=t.jsx("span",{className:r}),e[3]=r,e[4]=i):i=e[4],i},dp=s=>{const e=rt.c(120),{onItemSelect:n}=s,{t:a}=dt(),{mcpServers:r,selectedMcpName:i,setSelectedMcp:o,setMcpDraft:d,loadMcpConfigs:c,deleteMcp:f}=Mn(Ss(mp)),m=vs(up);let p;e[0]!==m?(p=Ce=>Ce.getStatusForDirectory(m??null),e[0]=m,e[1]=p):p=e[1];const u=is(p),S=is(pp),h=is(gp),[g,x]=l.useState(null),[D,N]=l.useState(!1),[w,A]=l.useState(null),[k,j]=l.useState(null),[y,P]=l.useState(!1);let z;e[2]!==r?(z=r.filter(hp),e[2]=r,e[3]=z):z=e[3];const R=z;let I;e[4]!==r?(I=r.filter(fp),e[4]=r,e[5]=I):I=e[5];const v=I;let b,L;e[6]!==c?(b=()=>{c()},L=[c],e[6]=c,e[7]=b,e[8]=L):(b=e[7],L=e[8]),l.useEffect(b,L);let E;e[9]!==m||e[10]!==h||e[11]!==y||e[12]!==S?(E=()=>{if(y)return;P(!0);const Ce=new Promise(xp);Promise.all([S({directory:m,silent:!0}),Ce]).then(()=>{const He=h(m);He&&B.error(He)}).finally(()=>{P(!1)})},e[9]=m,e[10]=h,e[11]=y,e[12]=S,e[13]=E):E=e[13];const J=E;let _;e[14]!==r||e[15]!==n||e[16]!==d||e[17]!==o?(_=()=>{let Ce="new-mcp-server",He=1;for(;r.some($=>$.name===Ce);)Ce=`new-mcp-server-${He}`,He++;d({name:Ce,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),o(Ce),n?.()},e[14]=r,e[15]=n,e[16]=d,e[17]=o,e[18]=_):_=e[18];const Z=_;let H;e[19]!==f||e[20]!==g||e[21]!==a?(H=async()=>{if(!g)return;N(!0);const Ce=await f(g.name);Ce.ok?Ce.reloadFailed?B.warning(Ce.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:Ce.warning||a("settings.mcp.sidebar.toast.refreshListIfStale")}):B.success(Ce.message||a("settings.mcp.sidebar.toast.serverDeleted",{name:g.name})):B.error(a("settings.mcp.sidebar.toast.deleteFailed")),x(null),N(!1)},e[19]=f,e[20]=g,e[21]=a,e[22]=H):H=e[22];const T=H;let Y;e[23]!==a?(Y=(Ce,He)=>t.jsxs(He,{onClick:q=>{q.stopPropagation(),x(Ce)},className:"text-destructive focus:text-destructive",children:[t.jsx(M,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]}),e[23]=a,e[24]=Y):Y=e[24];const F=Y;let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=ce("flex h-full flex-col","bg-background"),e[25]=V):V=e[25];let Q;e[26]!==a?(Q=a("settings.mcp.sidebar.title"),e[26]=a,e[27]=Q):Q=e[27];let ie;e[28]!==Q?(ie=t.jsx("h2",{className:"text-base font-semibold text-foreground",children:Q}),e[28]=Q,e[29]=ie):ie=e[29];let X;e[30]!==a?(X=a("settings.mcp.sidebar.actions.refreshStatusAria"),e[30]=a,e[31]=X):X=e[31];let se;e[32]!==a?(se=a("settings.mcp.sidebar.actions.refreshStatusTitle"),e[32]=a,e[33]=se):se=e[33];const me=y&&"animate-spin";let oe;e[34]!==me?(oe=ce("h-4 w-4",me),e[34]=me,e[35]=oe):oe=e[35];let xe;e[36]!==oe?(xe=t.jsx(M,{name:"refresh",className:oe}),e[36]=oe,e[37]=xe):xe=e[37];let we;e[38]!==J||e[39]!==y||e[40]!==X||e[41]!==se||e[42]!==xe?(we=t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:y,onClick:J,"aria-label":X,title:se,children:xe}),e[38]=J,e[39]=y,e[40]=X,e[41]=se,e[42]=xe,e[43]=we):we=e[43];let he;e[44]!==ie||e[45]!==we?(he=t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[ie,we]}),e[44]=ie,e[45]=we,e[46]=he):he=e[46];let Ie;e[47]===Symbol.for("react.memo_cache_sentinel")?(Ie=t.jsx(ta,{className:"mb-3"}),e[47]=Ie):Ie=e[47];let ve;e[48]!==r.length||e[49]!==a?(ve=a("settings.mcp.sidebar.total",{count:r.length}),e[48]=r.length,e[49]=a,e[50]=ve):ve=e[50];let ye;e[51]!==ve?(ye=t.jsx("span",{className:"typography-meta text-muted-foreground",children:ve}),e[51]=ve,e[52]=ye):ye=e[52];let be;e[53]!==a?(be=a("settings.mcp.sidebar.actions.addServerTitle"),e[53]=a,e[54]=be):be=e[54];let te;e[55]===Symbol.for("react.memo_cache_sentinel")?(te=t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),e[55]=te):te=e[55];let re;e[56]!==Z||e[57]!==be?(re=t.jsx(G,{size:"sm","data-settings-item":"mcp.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:Z,title:be,children:te}),e[56]=Z,e[57]=be,e[58]=re):re=e[58];let ge;e[59]!==ye||e[60]!==re?(ge=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ye,re]}),e[59]=ye,e[60]=re,e[61]=ge):ge=e[61];let U;e[62]!==he||e[63]!==ge?(U=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[he,Ie,ge]}),e[62]=he,e[63]=ge,e[64]=U):U=e[64];let ee;e[65]!==r.length||e[66]!==u||e[67]!==n||e[68]!==w||e[69]!==R||e[70]!==F||e[71]!==k||e[72]!==i||e[73]!==d||e[74]!==o||e[75]!==a||e[76]!==v?(ee=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:r.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(M,{name:"plug",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:a("settings.mcp.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.mcp.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[R.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.mcp.sidebar.group.projectServers")}),R.map(Ce=>{const He=u[Ce.name],q=Qi(He?.status),$=i===Ce.name,fe=Qn();return t.jsxs(tn,{open:k===Ce.name,onOpenChange:O=>j(O?Ce.name:null),children:[t.jsxs(sn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",$?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:fe?void 0:O=>{O.preventDefault(),j(Ce.name)}}),children:[t.jsxs("button",{onClick:()=>{o(Ce.name),d(null),n?.()},className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{tone:q,enabled:Ce.enabled}),t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:Ce.name}),t.jsx("span",{title:Ce.type==="local"?a("settings.mcp.sidebar.serverType.localTitle"):a("settings.mcp.sidebar.serverType.remoteTitle"),children:Ce.type==="local"?t.jsx(M,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):t.jsx(M,{name:"global",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"})})]}),t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight pl-4",children:Ce.type==="local"?Ce.command?.join(" ")??"":Ce.url??""})]}),t.jsxs(us,{open:w===Ce.name,onOpenChange:O=>{O&&j(null),A(O?Ce.name:null)},children:[t.jsx(ds,{asChild:!0,children:t.jsx(G,{size:"xs",variant:"ghost",className:"flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ms,{align:"end",className:"w-fit min-w-20",children:F(Ce,js)})]})]}),t.jsx(nn,{className:"w-fit min-w-20",children:F(Ce,Ws)})]},Ce.name)})]}),v.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.mcp.sidebar.group.userServers")}),v.map(Ce=>{const He=u[Ce.name],q=Qi(He?.status),$=i===Ce.name,fe=Qn();return t.jsxs(tn,{open:k===Ce.name,onOpenChange:O=>j(O?Ce.name:null),children:[t.jsxs(sn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",$?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:fe?void 0:O=>{O.preventDefault(),j(Ce.name)}}),children:[t.jsxs("button",{onClick:()=>{o(Ce.name),d(null),n?.()},className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{tone:q,enabled:Ce.enabled}),t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:Ce.name}),t.jsx("span",{title:Ce.type==="local"?a("settings.mcp.sidebar.serverType.localTitle"):a("settings.mcp.sidebar.serverType.remoteTitle"),children:Ce.type==="local"?t.jsx(M,{name:"server",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"}):t.jsx(M,{name:"global",className:"h-3 w-3 text-muted-foreground/60 flex-shrink-0"})})]}),t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight pl-4",children:Ce.type==="local"?Ce.command?.join(" ")??"":Ce.url??""})]}),t.jsxs(us,{open:w===Ce.name,onOpenChange:O=>{O&&j(null),A(O?Ce.name:null)},children:[t.jsx(ds,{asChild:!0,children:t.jsx(G,{size:"xs",variant:"ghost",className:"flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ms,{align:"end",className:"w-fit min-w-20",children:F(Ce,js)})]})]}),t.jsx(nn,{className:"w-fit min-w-20",children:F(Ce,Ws)})]},Ce.name)})]})]})}),e[65]=r.length,e[66]=u,e[67]=n,e[68]=w,e[69]=R,e[70]=F,e[71]=k,e[72]=i,e[73]=d,e[74]=o,e[75]=a,e[76]=v,e[77]=ee):ee=e[77];const ne=g!==null;let ue;e[78]!==D?(ue=Ce=>{!Ce&&!D&&x(null)},e[78]=D,e[79]=ue):ue=e[79];let Me;e[80]!==a?(Me=a("settings.mcp.sidebar.deleteDialog.title"),e[80]=a,e[81]=Me):Me=e[81];let ke;e[82]!==Me?(ke=t.jsx(Vt,{children:Me}),e[82]=Me,e[83]=ke):ke=e[83];const De=g?.name||"";let Ae;e[84]!==a||e[85]!==De?(Ae=a("settings.mcp.sidebar.deleteDialog.descriptionPrefix",{name:De}),e[84]=a,e[85]=De,e[86]=Ae):Ae=e[86];let Pe;e[87]===Symbol.for("react.memo_cache_sentinel")?(Pe=t.jsx("code",{className:"text-foreground",children:"opencode.json"}),e[87]=Pe):Pe=e[87];let Re;e[88]!==Ae?(Re=t.jsxs(qt,{children:[Ae," ",Pe,"."]}),e[88]=Ae,e[89]=Re):Re=e[89];let Le;e[90]!==ke||e[91]!==Re?(Le=t.jsxs(_t,{children:[ke,Re]}),e[90]=ke,e[91]=Re,e[92]=Le):Le=e[92];let $e;e[93]===Symbol.for("react.memo_cache_sentinel")?($e=()=>x(null),e[93]=$e):$e=e[93];let Be;e[94]!==a?(Be=a("settings.common.actions.cancel"),e[94]=a,e[95]=Be):Be=e[95];let Oe;e[96]!==D||e[97]!==Be?(Oe=t.jsx(G,{size:"sm",variant:"ghost",onClick:$e,disabled:D,children:Be}),e[96]=D,e[97]=Be,e[98]=Oe):Oe=e[98];let Ue;e[99]!==D||e[100]!==a?(Ue=a(D?"settings.mcp.sidebar.actions.deleting":"settings.common.actions.delete"),e[99]=D,e[100]=a,e[101]=Ue):Ue=e[101];let le;e[102]!==T||e[103]!==D||e[104]!==Ue?(le=t.jsx(G,{size:"sm",onClick:T,disabled:D,children:Ue}),e[102]=T,e[103]=D,e[104]=Ue,e[105]=le):le=e[105];let W;e[106]!==Oe||e[107]!==le?(W=t.jsxs(Yt,{children:[Oe,le]}),e[106]=Oe,e[107]=le,e[108]=W):W=e[108];let de;e[109]!==Le||e[110]!==W?(de=t.jsxs(Bt,{className:"max-w-md",children:[Le,W]}),e[109]=Le,e[110]=W,e[111]=de):de=e[111];let Ne;e[112]!==ne||e[113]!==ue||e[114]!==de?(Ne=t.jsx(Ut,{open:ne,onOpenChange:ue,children:de}),e[112]=ne,e[113]=ue,e[114]=de,e[115]=Ne):Ne=e[115];let Ee;return e[116]!==U||e[117]!==ee||e[118]!==Ne?(Ee=t.jsxs("div",{className:V,children:[U,ee,Ne]}),e[116]=U,e[117]=ee,e[118]=Ne,e[119]=Ee):Ee=e[119],Ee};function mp(s){return{mcpServers:s.mcpServers,selectedMcpName:s.selectedMcpName,setSelectedMcp:s.setSelectedMcp,setMcpDraft:s.setMcpDraft,loadMcpConfigs:s.loadMcpConfigs,deleteMcp:s.deleteMcp}}function up(s){return s.currentDirectory}function pp(s){return s.refresh}function gp(s){return s.getErrorForDirectory}function hp(s){return s.scope==="project"}function fp(s){return s.scope!=="project"}function xp(s){return setTimeout(s,500)}function Ts(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function $n(s){return Array.isArray(s)&&s.every(e=>typeof e=="string")}function Ms(s,e){return e!==void 0?{ok:!1,error:s,parsed:e}:{ok:!1,error:s}}function ma(s,e,n){const a=yp(n),r=typeof n.url=="string"?n.url.trim():"",i=Xi(n,"env","environment"),o=Xi(n,"headers"),d=bp(n),c=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.clientId??"").trim():"",f=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.clientSecret??"").trim():"",m=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.scope??"").trim():"",p=typeof n.oauth=="object"&&n.oauth!==null?String(n.oauth.redirectUri??"").trim():"",u=vp(n),S=jp(n);return{ok:!0,name:s,type:e,command:a,url:r,environment:i,headers:o,oauthEnabled:d,oauthClientId:c,oauthClientSecret:f,oauthScope:m,oauthRedirectUri:p,timeout:u,enabled:S}}function yp(s){const e=s.command,n=s.args;if($n(e)&&$n(n))return[...e,...n];if($n(e))return e;if(typeof e=="string"&&e.trim()){const a=e.trim().split(/\s+/);return $n(n)?[...a,...n]:a}return $n(n)?n:[]}function Xi(s,...e){for(const n of e){const a=s[n];if(!Ts(a))continue;const r=Object.entries(a).filter(([i,o])=>i&&typeof o=="string");if(r.length>0)return r.map(([i,o])=>({key:i,value:String(o)}))}return[]}function bp(s){if(s.oauth===!1||s.oauth===null||s.oauth===void 0||!Ts(s.oauth))return!1;const e=s.oauth;return!!(typeof e.clientId=="string"&&e.clientId.trim()||typeof e.clientSecret=="string"&&e.clientSecret.trim()||typeof e.scope=="string"&&e.scope.trim()||typeof e.redirectUri=="string"&&e.redirectUri.trim())}function vp(s){const e=s.timeout;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return String(Math.floor(e));if(typeof e=="string"&&e.trim()){const n=Number(e);if(Number.isFinite(n)&&n>0)return String(Math.floor(n))}return""}function jp(s){return"disabled"in s&&s.disabled===!0?!1:"enabled"in s?!!s.enabled:!0}function wp(s){const e=s.mcpServers;if(Ts(e)){const a=Object.keys(e);if(a.length===1){const r=a[0],i=e[r];if(Ts(i))return{name:r,entry:i}}if(a.length>1)return null}const n=Object.keys(s).filter(a=>{const r=s[a];return a!=="mcpServers"&&Ts(r)});if(n.length===1){const a=n[0],r=s[a];if(El(r))return{name:a,entry:r}}return null}function El(s){return s.type==="local"||s.type==="remote"||Array.isArray(s.command)||typeof s.url=="string"||Array.isArray(s.args)}function Np(s,e){let n;try{const d=s.trim();if(!d)return Ms("No JSON content provided");n=JSON.parse(d)}catch(d){return Ms(d instanceof Error?`Invalid JSON: ${d.message}`:"Invalid JSON")}if(!Ts(n))return Ms("Expected a JSON object, not an array or primitive");const a=n,r=a.mcpServers;if(Ts(r)){const d=Object.keys(r);if(d.length===0)return Ms("mcpServers object is empty",n);if(d.length>1)return Ms("Paste one server at a time. Found "+d.length+" servers in mcpServers",n);const c=d[0],f=r[c];return Ts(f)?ma(c,ua(f),f):Ms("Server entry is not a valid object",n)}const i=a.mcp;if(Ts(i)){const d=Object.keys(i);if(d.length===0)return Ms("mcp object is empty",n);if(d.length>1)return Ms("Paste one server at a time. Found "+d.length+" servers in mcp",n);const c=d[0],f=i[c];return Ts(f)?ma(c,ua(f),f):Ms("Server entry in mcp is not a valid object",n)}const o=wp(a);if(o)return ma(o.name,ua(o.entry),o.entry);if(El(a)){const d=ua(a),c=typeof a.name=="string"&&a.name.trim()?a.name.trim():e?.fallbackName;return ma(c,d,a)}return Ms("No recognizable MCP server configuration found in JSON",n)}function ua(s){return s.type==="remote"?"remote":s.type==="local"?"local":typeof s.url=="string"&&s.url.trim()?"remote":(Array.isArray(s.command)||typeof s.command=="string"||Array.isArray(s.args),"local")}function kp(s,e,n){const a=n?.isNewServer??!1,r=s.name,i=a&&r?r:e.name??"";return{...e,name:i,type:s.type,command:s.type==="local"?s.command:[],url:s.type==="remote"?s.url:"",environment:s.environment,headers:s.type==="remote"?s.headers:[],oauthEnabled:s.type==="remote"?s.oauthEnabled:!1,oauthClientId:s.type==="remote"?s.oauthClientId:"",oauthClientSecret:s.type==="remote"?s.oauthClientSecret:"",oauthScope:s.type==="remote"?s.oauthScope:"",oauthRedirectUri:s.type==="remote"?s.oauthRedirectUri:"",timeout:s.type==="remote"?s.timeout:"",enabled:s.enabled}}const Sp="/mcp/oauth/callback",Cp=s=>{if(typeof window>"u")return null;try{const e=s.replace(/-/g,"+").replace(/_/g,"/"),n=e.length%4===0?"":"=".repeat(4-e.length%4),a=window.atob(e+n),r=Uint8Array.from(a,i=>i.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}},Pp=s=>{const e=Ip(s.get("state"));if(e)return e;const n=s.get("server");if(typeof n!="string"||!n.trim())return null;const a=s.get("directory");return{name:n.trim(),directory:typeof a=="string"&&a.trim()?a.trim():null}},Ml=s=>{const e=s.get("state");return typeof e!="string"?null:e.trim()||null},Ip=s=>{if(typeof s!="string"||!s.trim())return null;const e=Cp(s.trim());if(!e)return null;try{const n=JSON.parse(e);return n?.v!==1||typeof n.n!="string"||!n.n.trim()?null:{name:n.n.trim(),directory:typeof n.d=="string"&&n.d.trim()?n.d.trim():null}}catch{return null}},gn=Sc,hn=s=>{const e=rt.c(14);let n,a,r,i;e[0]!==s?({className:r,asChild:n,children:a,...i}=s,e[0]=s,e[1]=n,e[2]=a,e[3]=r,e[4]=i):(n=e[1],a=e[2],r=e[3],i=e[4]);let o;e[5]!==n||e[6]!==a?(o=n&&je.isValidElement(a)?{render:a}:{children:a},e[5]=n,e[6]=a,e[7]=o):o=e[7];const d=o;let c;e[8]!==r?(c=ce("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",r),e[8]=r,e[9]=c):c=e[9];let f;return e[10]!==i||e[11]!==d||e[12]!==c?(f=t.jsx(kc,{className:c,...i,...d}),e[10]=i,e[11]=d,e[12]=c,e[13]=f):f=e[13],f},fn=s=>{const e=rt.c(8);let n,a;e[0]!==s?({className:n,...a}=s,e[0]=s,e[1]=n,e[2]=a):(n=e[1],a=e[2]);let r;e[3]!==n?(r=ce("overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down",n),e[3]=n,e[4]=r):r=e[4];let i;return e[5]!==a||e[6]!==r?(i=t.jsx(Cc,{className:r,...a}),e[5]=a,e[6]=r,e[7]=i):i=e[7],i};function Dp(s){const e=[];let n="",a=!1,r=!1;for(let i=0;i<s.length;i++){const o=s[i];if(o==="'"&&!r){a=!a;continue}if(o==='"'&&!a){r=!r;continue}if((o===" "||o===" ")&&!a&&!r){n&&(e.push(n),n="");continue}n+=o}return n&&e.push(n),e}function Ap(s){const e=s.trim();if(!e)return{code:null,context:null,stateKey:null};try{const n=new URL(e),a=n.searchParams.get("code");if(typeof a=="string"&&a.trim())return{code:a.trim(),context:Pp(n.searchParams),stateKey:Ml(n.searchParams)}}catch{}return{code:e,context:null,stateKey:null}}const Ep=({value:s,onChange:e,pasteCommandTitle:n,pasteCommandLabel:a,pasteSuccess:r,clipboardReadFailed:i,preview:o})=>{const[d,c]=l.useState(()=>s.join(`
|
|
4
|
-
`)),f=l.useRef(s);l.useEffect(()=>{JSON.stringify(f.current)!==JSON.stringify(s)&&(f.current=s,c(s.join(`
|
|
5
|
-
`)))},[s]);const m=u=>{const S=u.split(`
|
|
6
|
-
`).filter(h=>h.trim().length>0);e(S)},p=async()=>{try{const S=(await navigator.clipboard.readText()).trim(),h=S.includes(`
|
|
7
|
-
`)?S.split(`
|
|
8
|
-
`).filter(g=>g.trim()):Dp(S);c(h.join(`
|
|
9
|
-
`)),e(h),B.success(r(h.length))}catch{B.error(i)}};return t.jsxs("div",{className:"space-y-2","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",children:[t.jsx("div",{className:"flex items-center justify-end gap-2",children:t.jsxs(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:p,type:"button",title:n,children:[t.jsx(M,{name:"clipboard",className:"h-3 w-3"}),a]})}),t.jsx(ps,{value:d,onChange:u=>{c(u.target.value),m(u.target.value)},onBlur:()=>{const u=d.split(`
|
|
10
|
-
`).map(S=>S.trimEnd()).join(`
|
|
11
|
-
`);c(u),m(u)},placeholder:`npx
|
|
12
|
-
-y
|
|
13
|
-
@modelcontextprotocol/server-postgres
|
|
14
|
-
postgresql://user:pass@host/db`,rows:Math.max(4,s.length+1),className:"font-mono typography-meta resize-y min-h-[80px]",spellCheck:!1}),s.length>0&&t.jsxs("details",{className:"group",children:[t.jsx("summary",{className:"typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground",children:o(s.length)}),t.jsx("div",{className:"mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto",children:t.jsx("code",{className:"typography-micro text-foreground/80 whitespace-pre",children:s.map((u,S)=>t.jsxs("span",{className:"block",children:[t.jsxs("span",{className:"text-muted-foreground select-none mr-2",children:["[",S,"]"]}),u]},S))})})]})]})},Mp=s=>s.toUpperCase().replace(/[^A-Z0-9_]/g,"_"),Zi=({value:s,onChange:e,keyTransform:n=Mp,keyPlaceholder:a="API_KEY",keyInputClassName:r="w-36 shrink-0 font-mono typography-meta uppercase",pasteLabel:i="Paste .env",pasteTitle:o="Paste KEY=VALUE lines from clipboard",noPairsFoundError:d,importSuccess:c,clipboardReadFailed:f,keyLabel:m,valueLabel:p,valuePlaceholder:u,hideValueTitle:S,showValueTitle:h,addVariable:g,plainTextWarning:x,removeVariableAria:D})=>{const[N,w]=l.useState(new Set),A=()=>e([...s,{key:"",value:""}]),k=R=>{e(s.filter((I,v)=>v!==R)),w(I=>{const v=new Set(I);return v.delete(R),v})},j=(R,I,v)=>{const b=[...s];b[R]={...b[R],[I]:v},e(b)},y=R=>{w(I=>{const v=new Set(I);return v.has(R)?v.delete(R):v.add(R),v})},P=async()=>{try{const R=await navigator.clipboard.readText(),I=[];for(const b of R.split(`
|
|
15
|
-
`)){const L=b.trim();if(!L||L.startsWith("#"))continue;const E=L.indexOf("=");if(E===-1)continue;const J=L.slice(0,E).trim();let _=L.slice(E+1).trim();(_.startsWith('"')&&_.endsWith('"')||_.startsWith("'")&&_.endsWith("'"))&&(_=_.slice(1,-1)),J&&I.push({key:J,value:_})}if(I.length===0){B.error(d);return}const v=[...s];for(const b of I){const L=v.findIndex(E=>E.key===b.key);L!==-1?v[L]=b:v.push(b)}e(v),B.success(c(I.length))}catch{B.error(f)}},z=s.some(R=>R.value.length>0);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"typography-micro text-muted-foreground w-32 shrink-0",children:m}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:p})]}),t.jsxs(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:P,type:"button",title:o,children:[t.jsx(M,{name:"clipboard",className:"h-3 w-3"}),i]})]}),t.jsx("div",{className:"space-y-1.5",children:s.map((R,I)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(it,{value:R.key,onChange:v=>j(I,"key",n(v.target.value)),placeholder:a,className:r,"data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),t.jsxs("div",{className:"relative flex-1 flex items-center",children:[t.jsx(it,{type:N.has(I)?"text":"password",value:R.value,onChange:v=>j(I,"value",v.target.value),placeholder:u,className:"font-mono typography-meta pr-8 w-full",autoComplete:"new-password","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),t.jsx("button",{type:"button",onClick:()=>y(I),className:"absolute right-2 text-muted-foreground/60 hover:text-muted-foreground",title:N.has(I)?S:h,children:N.has(I)?t.jsx(M,{name:"eye-off",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"eye",className:"h-3.5 w-3.5"})})]}),t.jsx(G,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>k(I),"aria-label":D,children:t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},I))}),t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:A,type:"button",children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),g]}),z&&t.jsx("p",{className:"typography-micro text-muted-foreground/60",children:x})]})},eo=s=>{const e=rt.c(14),{status:n,enabled:a,getStatusLabel:r,variant:i}=s,o=i===void 0?"compact":i;if(!a||!n)return null;let d,c;if(e[0]!==r||e[1]!==n||e[2]!==o){c=Symbol.for("react.early_return_sentinel");e:{const u={connected:{text:"text-[var(--status-success)]",bg:"bg-[var(--status-success)]/10"},failed:{text:"text-[var(--status-error)]",bg:"bg-[var(--status-error)]/10"},needs_auth:{text:"text-[var(--status-warning)]",bg:"bg-[var(--status-warning)]/10"},needs_client_registration:{text:"text-[var(--status-warning)]",bg:"bg-[var(--status-warning)]/10"}}[n]??{text:"text-muted-foreground",bg:""};if(o==="pill"){const S=ce("typography-micro font-medium rounded-full px-2 py-0.5",u.text,u.bg);let h;e[5]!==r||e[6]!==n?(h=r(n),e[5]=r,e[6]=n,e[7]=h):h=e[7],c=t.jsxs("span",{className:S,children:["● ",h]});break e}d=ce("typography-micro font-medium",u.text)}e[0]=r,e[1]=n,e[2]=o,e[3]=d,e[4]=c}else d=e[3],c=e[4];if(c!==Symbol.for("react.early_return_sentinel"))return c;let f;e[8]!==r||e[9]!==n?(f=r(n),e[8]=r,e[9]=n,e[10]=f):f=e[10];let m;return e[11]!==d||e[12]!==f?(m=t.jsxs("span",{className:d,children:["● ",f]}),e[11]=d,e[12]=f,e[13]=m):m=e[13],m},Rp=(s,e,n)=>{switch(s){case"connected":return e("settings.mcp.page.status.description.connected");case"failed":return n?.trim()||e("settings.mcp.page.status.description.failedDefault");case"needs_auth":return e("settings.mcp.page.status.description.needsAuth");case"needs_client_registration":return n?.trim()||e("settings.mcp.page.status.description.needsClientRegistrationDefault");case"disabled":return e("settings.mcp.page.status.description.disabled");default:return e("settings.mcp.page.status.description.default")}},Tp=s=>{switch(s){case"failed":return"border-[var(--status-error-border)] bg-[var(--status-error-background)]";case"needs_auth":case"needs_client_registration":return"border-[var(--status-warning-border)] bg-[var(--status-warning-background)]";default:return"border-[var(--interactive-border)] bg-[var(--surface-elevated)]"}},Fp=(s,e,n,a)=>!!(s==="failed"||s==="needs_auth"||s==="needs_client_registration"||e||n||a),to=(s,e)=>{if(typeof window>"u")return null;const n=new URL(Sp,Xn()||window.location.origin);return typeof s=="string"&&s.trim()&&n.searchParams.set("server",s.trim()),typeof e=="string"&&e.trim()&&n.searchParams.set("directory",e.trim()),n.toString()},Lp=async s=>{const e=await jt("/api/mcp/auth/pending",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:s.state,name:s.name,directory:typeof s.directory=="string"&&s.directory.trim()?s.directory.trim():null})});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error(n?.error||"Failed to prepare MCP authorization callback")}},Op=async s=>{const e=await jt(`/api/mcp/auth/pending?state=${encodeURIComponent(s)}`);if(!e.ok)return null;const n=await e.json().catch(()=>null);return n?.name?.trim()?{name:n.name.trim(),directory:typeof n.directory=="string"&&n.directory.trim()?n.directory.trim():null}:null},Un=async s=>{typeof s!="string"||!s.trim()||await jt(`/api/mcp/auth/pending?state=${encodeURIComponent(s.trim())}`,{method:"DELETE"}).catch(()=>{})},ar=(s,e,n)=>{const a=s instanceof Error?s.message:e;return/oauth state required/i.test(a)?n("settings.mcp.page.toast.authSessionExpired"):a},zp=(s,e)=>{const n=typeof e=="string"&&e.trim()?e.trim():"__global__";return`${s??"__none__"}::${n}`},Kp=()=>{const{t:s}=dt(),e=l.useCallback((Se,vt)=>s(Se,vt),[s]),{selectedMcpName:n,mcpServers:a,mcpDraft:r,setMcpDraft:i,setSelectedMcp:o,getMcpByName:d,createMcp:c,updateMcp:f,deleteMcp:m}=Mn(Ss(Se=>({selectedMcpName:Se.selectedMcpName,mcpServers:Se.mcpServers,mcpDraft:Se.mcpDraft,setMcpDraft:Se.setMcpDraft,setSelectedMcp:Se.setSelectedMcp,getMcpByName:Se.getMcpByName,createMcp:Se.createMcp,updateMcp:Se.updateMcp,deleteMcp:Se.deleteMcp}))),p=vs(Se=>Se.currentDirectory),u=l.useMemo(()=>gs(),[]),S=is(Se=>Se.getStatusForDirectory(p??null)),h=is(Se=>Se.getDiagnosticForDirectory(p??null)),g=is(Se=>Se.refresh),x=is(Se=>Se.connect),D=is(Se=>Se.disconnect),N=is(Se=>Se.startAuth),w=is(Se=>Se.completeAuth),A=is(Se=>Se.clearAuth),k=is(Se=>Se.testConnection),j=n?d(n):null,y=!!(r&&r.name===n&&!j),[P,z]=l.useState(""),[R,I]=l.useState("user"),[v,b]=l.useState("local"),[L,E]=l.useState([]),[J,_]=l.useState(""),[Z,H]=l.useState([]),[T,Y]=l.useState([]),[F,V]=l.useState(!0),[Q,ie]=l.useState(""),[X,se]=l.useState(""),[me,oe]=l.useState(""),[xe,we]=l.useState(""),[he,Ie]=l.useState(""),[ve,ye]=l.useState(!0),[be,te]=l.useState(!1),[re,ge]=l.useState(!1),[U,ee]=l.useState(!1),[ne,ue]=l.useState(!1),[Me,ke]=l.useState(!1),[De,Ae]=l.useState(!1),[Pe,Re]=l.useState(!1),[Le,$e]=l.useState(!1),[Be,Oe]=l.useState(null),[Ue,le]=l.useState(null),[W,de]=l.useState(""),[Ne,Ee]=l.useState(!1),Ce=l.useRef(0),He=l.useRef(!1),[q,$]=l.useState(!1),[fe,O]=l.useState(!1),[Fe,Je]=l.useState(""),[Xe,et]=l.useState(null),at=l.useMemo(()=>zp(n,p),[p,n]),lt=l.useRef(at),Ze=l.useRef(null),We=l.useCallback(()=>{Oe(null),le(null),de(""),Ee(!1),Ce.current=0,$e(!1),ke(!1),Ae(!1),He.current=!1},[]),pt=l.useCallback(()=>{Je(""),et(null),O(!0)},[]),pe=l.useCallback(async()=>{try{const Se=await navigator.clipboard.readText();Je(Se),et(null)}catch{B.error(s("settings.mcp.page.toast.clipboardReadFailed"))}},[s]),st=l.useCallback(()=>{const Se=Np(Fe,{fallbackName:P});if(!Se.ok){et(Se.error);return}const Nt=kp(Se,{name:P,scope:R,type:v,command:L,url:J,environment:Z,headers:T,oauthEnabled:F,oauthClientId:Q,oauthClientSecret:X,oauthScope:me,oauthRedirectUri:xe,timeout:he,enabled:ve},{isNewServer:y});z(Nt.name),b(Nt.type),E(Nt.command??[]),_(Nt.url??""),H(Nt.environment??[]),Y(Nt.headers??[]),V(Nt.oauthEnabled??!1),ie(Nt.oauthClientId??""),se(Nt.oauthClientSecret??""),oe(Nt.oauthScope??""),we(Nt.oauthRedirectUri??""),Ie(Nt.timeout??""),ye(Nt.enabled??!0),O(!1),Je(""),et(null),B.success(s("settings.mcp.page.toast.configImported"))},[Fe,P,R,v,L,J,Z,T,F,Q,X,me,xe,he,ve,y,s]);l.useEffect(()=>{if(y&&r){z(r.name),I(r.scope||"user"),b(r.type),E(r.command),_(r.url),H(r.environment),Y(r.headers),V(r.oauthEnabled),ie(r.oauthClientId),se(r.oauthClientSecret),oe(r.oauthScope),we(r.oauthRedirectUri),Ie(r.timeout),ye(r.enabled),$(!1),Ze.current={mcpType:r.type,command:r.command,url:r.url,envEntries:r.environment,headerEntries:r.headers,oauthEnabled:r.oauthEnabled,oauthClientId:r.oauthClientId,oauthClientSecret:r.oauthClientSecret,oauthScope:r.oauthScope,oauthRedirectUri:r.oauthRedirectUri,timeout:r.timeout,enabled:r.enabled};return}if(j){I(j.scope==="project"?"project":"user");const Se=Ai(j.environment),vt=j.type==="remote"?j:null,Nt=Ai(vt?.headers),ct=vt?.oauth,St=ct&&typeof ct=="object"?ct:null,$t=ct!==!1,ys=j.type,ns=ys==="local"?j.command??[]:[],bs=ys==="remote"?j.url??"":"",Qe=typeof vt?.timeout=="number"&&Number.isFinite(vt.timeout)?String(vt.timeout):"";b(ys),E(ns),_(bs),H(Se),Y(Nt),V($t),ie($t?St?.clientId??"":""),se($t?St?.clientSecret??"":""),oe($t?St?.scope??"":""),we($t?St?.redirectUri??"":""),Ie(Qe),ye(j.enabled),$(!1),Ze.current={mcpType:ys,command:ns,url:bs,envEntries:Se,headerEntries:Nt,oauthEnabled:$t,oauthClientId:$t?St?.clientId??"":"",oauthClientSecret:$t?St?.clientSecret??"":"",oauthScope:$t?St?.scope??"":"",oauthRedirectUri:$t?St?.redirectUri??"":"",timeout:Qe,enabled:j.enabled}}},[j,y,r]);const nt=l.useMemo(()=>{const Se=Ze.current;return Se?v!==Se.mcpType||ve!==Se.enabled||JSON.stringify(L)!==JSON.stringify(Se.command)||J!==Se.url||JSON.stringify(Z)!==JSON.stringify(Se.envEntries)||JSON.stringify(T)!==JSON.stringify(Se.headerEntries)||F!==Se.oauthEnabled||Q!==Se.oauthClientId||X!==Se.oauthClientSecret||me!==Se.oauthScope||xe!==Se.oauthRedirectUri||he!==Se.timeout:!1},[v,L,J,Z,T,F,Q,X,me,xe,he,ve]),Ge=async()=>{const Se=y?P.trim():n??"";if(!Se){B.error(s("settings.mcp.page.toast.nameRequired"));return}if(y&&a.some(Nt=>Nt.name===Se)){B.error(s("settings.mcp.page.toast.serverNameExists"));return}if(v==="local"&&L.filter(Boolean).length===0){B.error(s("settings.mcp.page.toast.localCommandRequired"));return}if(v==="remote"&&!J.trim()){B.error(s("settings.mcp.page.toast.remoteUrlRequired"));return}const vt={name:Se,scope:R,type:v,command:L,url:J,environment:Z,headers:T,oauthEnabled:F,oauthClientId:Q,oauthClientSecret:X,oauthScope:me,oauthRedirectUri:xe,timeout:he,enabled:ve};te(!0);try{const Nt=y?await c(vt):await f(Se,vt);Nt.ok?(await Un(Ue),We(),y&&(i(null),o(Se)),await g({directory:p,silent:!0}),Nt.reloadFailed?B.warning(Nt.message||s(y?"settings.mcp.page.toast.serverCreatedReloadFailed":"settings.mcp.page.toast.savedReloadFailed"),{description:Nt.warning||s("settings.mcp.page.toast.retryRefreshHint")}):B.success(Nt.message||s(y?"settings.mcp.page.toast.serverCreatedReloading":"settings.mcp.page.toast.savedReloading"))):B.error(s("settings.mcp.page.toast.saveFailed"))}catch(Nt){B.error(Nt instanceof Error?Nt.message:s("settings.mcp.page.toast.unexpectedError"))}finally{te(!1)}},ft=async()=>{if(!n)return;ee(!0);const Se=await m(n);Se.ok?(await Un(Ue),We(),Se.reloadFailed?B.warning(Se.message||s("settings.mcp.page.toast.serverDeletedReloadFailed",{name:n}),{description:Se.warning||s("settings.mcp.page.toast.refreshListIfStale")}):B.success(Se.message||s("settings.mcp.page.toast.serverDeleted",{name:n})),ge(!1)):B.error(s("settings.mcp.page.toast.deleteFailed")),ee(!1)},wt=async()=>{if(n){ue(!0);try{if(S[n]?.status==="connected")await D(n,p),B.success(s("settings.mcp.page.toast.disconnected"));else{await x(n,p),await g({directory:p,silent:!0});const vt=is.getState().getStatusForDirectory(p??null)[n];vt?.status==="connected"?B.success(s("settings.mcp.page.toast.connected")):vt?.status==="needs_auth"?B.message(s("settings.mcp.page.toast.connectionNeedsAuthorization")):vt?.status==="needs_client_registration"?B.message(s("settings.mcp.page.toast.connectionNeedsClientRegistration")):vt?.status==="failed"?B.error(vt.error||s("settings.mcp.page.toast.connectionFailed")):B.message(s("settings.mcp.page.toast.connectionAttemptFinished"));return}await g({directory:p,silent:!0})}catch(Se){B.error(Se instanceof Error?Se.message:s("settings.mcp.page.toast.connectionFailed"))}finally{ue(!1)}}},Ct=l.useCallback(()=>y?(B.error(s("settings.mcp.page.toast.createServerBeforeLiveActions")),!1):nt?(B.error(s("settings.mcp.page.toast.saveBeforeLiveActions")),!1):!0,[nt,y,s]),ae=l.useCallback(async(Se=!1)=>{try{await g({directory:p,silent:Se})}catch(vt){Se||B.error(vt instanceof Error?vt.message:s("settings.mcp.page.toast.refreshStatusFailed"))}},[p,g,s]);l.useEffect(()=>{ae(!0)},[ae]),l.useEffect(()=>{lt.current=at,ue(!1),Re(!1),We()},[We,at]);const Ve=l.useCallback(async()=>{if(!n||v!=="remote"||!Ct())return;ke(!0);const Se=at;let vt=null;try{const Nt=is.getState().getStatusForDirectory(p??null)[n]?.status;He.current=Nt==="needs_auth"||Nt==="needs_client_registration";const ct=to(n,p);if(!ct)throw new Error(s("settings.mcp.page.toast.oauthRedirectUrlBuildFailed"));if(!xe.trim()&&!u){const ns=await f(n,{oauthEnabled:F,oauthClientId:Q,oauthClientSecret:X,oauthScope:me,oauthRedirectUri:ct});if(!ns.ok)throw new Error(s("settings.mcp.page.toast.oauthBrowserCallbackSaveFailed"));if(ns.reloadFailed)throw new Error(ns.warning||ns.message||s("settings.mcp.page.toast.openCodeReloadFailedAfterCallbackSave"));if(lt.current!==Se)return;we(ct),Ze.current=Ze.current?{...Ze.current,oauthRedirectUri:ct}:Ze.current}const St=await N(n,p),$t=Ml(new URL(St).searchParams);if($t&&(vt=$t,await Lp({state:$t,name:n,directory:p})),lt.current!==Se)return;Oe(St),le($t??null),Ee(!0),Ce.current=0;const ys=await Hs(St);if(lt.current!==Se)return;ys?B.message(s(u?"settings.mcp.page.toast.completeAuthorizationInBrowserWithPaste":"settings.mcp.page.toast.completeAuthorizationInBrowser")):B.error(s("settings.mcp.page.toast.openAuthorizationUrlFailed"))}catch(Nt){await Un(vt),lt.current===Se&&B.error(ar(Nt,s("settings.mcp.page.toast.authorizationStartFailed"),e))}finally{lt.current===Se&&ke(!1)}},[p,u,v,Q,X,F,xe,me,Ct,at,n,N,s,e,f]),tt=l.useCallback(async()=>{if(!n||!Ct())return;Ae(!0);const Se=at;try{if(await A(n,p),lt.current!==Se)return;Oe(null),le(null),de(""),Ee(!1),Ce.current=0,await Un(Ue),B.success(s("settings.mcp.page.toast.savedAuthorizationRemoved"))}catch(vt){lt.current===Se&&B.error(ar(vt,s("settings.mcp.page.toast.clearAuthorizationFailed"),e))}finally{lt.current===Se&&Ae(!1)}},[Ue,A,p,Ct,at,n,s,e]),Ye=l.useCallback(async()=>{if(!Be)return;if((await un(Be)).ok){B.success(s("settings.mcp.page.toast.authorizationUrlCopied"));return}B.error(s("settings.mcp.page.toast.authorizationUrlCopyFailed"))},[Be,s]),yt=l.useCallback(async()=>{const Se=Ap(W);if(!Se.code){B.error(s("settings.mcp.page.toast.pasteCallbackOrCodeFirst"));return}const vt=Se.stateKey?await Op(Se.stateKey):null,Nt=Se.context??vt,ct=Nt?.name??n,St=Nt?.directory??p;if(!ct){B.error(s("settings.mcp.page.toast.missingServerDetails"));return}if(!Nt&&!Ct())return;$e(!0);const $t=at;try{if(await w(ct,Se.code,St),await Un(Se.stateKey??Ue),lt.current!==$t)return;de(""),Oe(null),le(null),Ee(!1),Ce.current=0,B.success(ct===n?s("settings.mcp.page.toast.authorizationCompleted"):s("settings.mcp.page.toast.authorizationCompletedFor",{name:ct}))}catch(ys){lt.current===$t&&B.error(ar(ys,s("settings.mcp.page.toast.authorizationCompleteFailed"),e))}finally{lt.current===$t&&$e(!1)}},[W,Ue,w,p,Ct,at,n,s,e]),ze=l.useCallback(async()=>{if(!(!n||!Ct())){if(!ve){B.error(s("settings.mcp.page.toast.enableServerBeforeTest"));return}Re(!0);try{const Se=await k(n,p),vt=Se.status?.status;Se.warning?B.warning(Se.warning):vt==="connected"?B.success(s("settings.mcp.page.toast.connectionTestSucceeded")):vt==="needs_auth"?B.message(s("settings.mcp.page.toast.connectionNeedsAuthorization")):vt==="needs_client_registration"?B.message(s("settings.mcp.page.toast.connectionNeedsClientRegistration")):vt==="failed"?B.error(Se.status?.error||Se.error||s("settings.mcp.page.toast.connectionTestFailed")):Se.error?B.error(Se.error):B.message(s("settings.mcp.page.toast.connectionTestFinished"))}catch(Se){B.error(Se instanceof Error?Se.message:s("settings.mcp.page.toast.connectionTestFailed"))}finally{Re(!1)}}},[p,ve,Ct,n,s,k]);if(l.useEffect(()=>{if(!Ne||!n)return;const Se=window.setInterval(()=>{(async()=>{Ce.current+=1,await g({directory:p,silent:!0});const vt=is.getState().getStatusForDirectory(p??null)[n];if(vt){if(He.current&&vt.status!=="needs_auth"&&vt.status!=="needs_client_registration"){Ee(!1),Ce.current=0,He.current=!1,Oe(null),de(""),vt.status==="connected"&&B.success(s("settings.mcp.page.toast.authorizationCompleted"));return}if(!He.current&&vt.status==="failed"){Ee(!1),Ce.current=0,He.current=!1,B.error(vt.error||s("settings.mcp.page.toast.authorizationFailed"));return}Ce.current>=30&&(Ee(!1),Ce.current=0,He.current=!1,B.message(s("settings.mcp.page.toast.authorizationStillInProgress")))}})()},2e3);return()=>{window.clearInterval(Se)}},[p,Ne,g,n,s]),!n)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(M,{name:"plug",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.mcp.page.empty.selectServer")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.mcp.page.empty.addNewOne")})]})});const _e=S[n],ot=n?h[n]:void 0,bt=_e??ot,Mt=_e?.status==="connected",Qt=_e?.status==="needs_auth"||_e?.status==="needs_client_registration",Xt=u?null:to(n,p),rs=Rp(bt?.status,e,bt&&"error"in bt?bt.error:void 0),Wt=Se=>{switch(Se){case"connected":return s("settings.mcp.page.status.label.connected");case"failed":return s("settings.mcp.page.status.label.failed");case"needs_auth":return s("settings.mcp.page.status.label.needsAuth");case"needs_client_registration":return s("settings.mcp.page.status.label.needsRegistration");default:return Se}};return t.jsxs(Jt,{outerClassName:"h-full",className:"w-full",children:[t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"min-w-0",children:[y?t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:s("settings.mcp.page.header.newServer")}):t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:n}),t.jsx(eo,{status:bt?.status,enabled:ve,getStatusLabel:Wt,variant:"pill"})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:y?s("settings.mcp.page.header.configureNewServer"):s("settings.mcp.page.header.transport",{type:s(v==="local"?"settings.mcp.page.transport.local":"settings.mcp.page.transport.remote")})}),!y&&t.jsxs(t.Fragment,{children:[t.jsx(G,{variant:Mt?"outline":"default",size:"xs",className:"!font-normal",onClick:wt,disabled:ne||!ve,children:s(ne?"settings.mcp.page.actions.working":Mt?"settings.mcp.page.actions.disconnect":"settings.mcp.page.actions.connect")}),v==="remote"&&t.jsxs(t.Fragment,{children:[t.jsx(G,{variant:Qt?"default":"outline",size:"xs",className:"!font-normal",onClick:()=>{Ve()},disabled:Me||!ve,children:s(Me?"settings.mcp.page.actions.starting":Qt?"settings.mcp.page.actions.authorize":"settings.mcp.page.actions.reauthorize")}),t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{tt()},disabled:De||!ve,children:s(De?"settings.mcp.page.actions.clearing":"settings.mcp.page.actions.clearAuth")})]}),Mt&&t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{ze()},disabled:Pe||!ve,children:s(Pe?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.test")})]})]})]})}),!y&&Fp(bt?.status,Be,Qt,Ne)&&t.jsx("div",{className:"mb-6 px-2",children:t.jsxs("div",{className:ce("rounded-lg border p-3",Tp(bt?.status)),children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.status.runtimeStatus")}),t.jsx(eo,{status:bt?.status,enabled:ve,getStatusLabel:Wt})]}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:rs}),t.jsx("p",{className:"typography-micro text-muted-foreground/80",children:R==="project"?s("settings.mcp.page.status.projectScopedTo",{directory:p??s("settings.mcp.page.status.activeProject")}):s("settings.mcp.page.status.userScoped")})]}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:!Mt&&t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{ze()},disabled:Pe||!ve,children:s(Pe?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.testConnection")})}),Be&&t.jsx("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-2",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-micro text-muted-foreground",children:s("settings.mcp.page.auth.authorizationUrl")}),t.jsx("div",{className:"break-all typography-micro text-foreground font-mono",children:Be}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Hs(Be)},children:[t.jsx(M,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.mcp.page.actions.openInBrowser")]}),t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ye()},children:[t.jsx(M,{name:"clipboard",className:"h-3.5 w-3.5"}),s("settings.mcp.page.actions.copyLink")]})]})]})}),v==="remote"&&(Qt||Ne||Be)&&t.jsx("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-3",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.auth.manualFallbackTitle")}),t.jsx("p",{className:"mt-1 typography-micro text-muted-foreground",children:s("settings.mcp.page.auth.manualFallbackDescription")})]}),t.jsx(ps,{value:W,onChange:Se=>de(Se.target.value),placeholder:s("settings.mcp.page.auth.callbackInputPlaceholder"),rows:3,className:"font-mono typography-meta resize-y","data-bwignore":"true","data-1p-ignore":"true",spellCheck:!1}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{yt()},disabled:Le,children:s(Le?"settings.mcp.page.actions.completing":"settings.mcp.page.actions.completeAuthorization")})})]})})]}),Ne&&t.jsx("p",{className:"mt-4 typography-micro text-muted-foreground",children:s("settings.mcp.page.auth.waitingForOpenCode")})]})}),t.jsxs("div",{"data-settings-item":"mcp.server",className:"mb-6",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.mcp.page.server.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[y&&t.jsxs("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.server.name")})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsx(it,{value:P,onChange:Se=>z(Se.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"-")),placeholder:s("settings.mcp.page.server.namePlaceholder"),className:"h-7 w-48 font-mono px-2",autoFocus:!0}),t.jsxs(Ft,{value:R,onValueChange:Se=>I(Se),children:[t.jsx(Lt,{className:"!h-7 !w-7 !min-w-0 !px-0 !py-0 justify-center [&>svg:last-child]:hidden",title:s(R==="user"?"settings.common.scope.global":"settings.common.scope.project"),children:R==="user"?t.jsx(M,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"folder",className:"h-3.5 w-3.5"})}),t.jsxs(Ot,{align:"end",children:[t.jsx(ht,{value:"user",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{name:"user-3",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.global")})]})}),t.jsx(ht,{value:"project",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{name:"folder",className:"h-3.5 w-3.5"}),t.jsx("span",{children:s("settings.common.scope.project")})]})})]})]})]})]}),y&&t.jsx("div",{className:"py-1.5",children:t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:pt,type:"button",title:s("settings.mcp.page.server.importJsonTitle"),children:[t.jsx(M,{name:"file-code",className:"h-3.5 w-3.5"}),s("settings.mcp.page.server.importJson")]})}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":ve,onClick:()=>ye(!ve),onKeyDown:Se=>{(Se.key===" "||Se.key==="Enter")&&(Se.preventDefault(),ye(!ve))},children:[t.jsx(It,{checked:ve,onChange:ye,ariaLabel:s("settings.mcp.page.server.enableAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.server.enable")})]}),t.jsx("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:t.jsxs("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.server.transportMode")}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(G,{variant:"chip",size:"xs","aria-pressed":v==="local",onClick:()=>b("local"),className:"!font-normal",children:s("settings.mcp.page.transport.local")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":v==="remote",onClick:()=>b("remote"),className:"!font-normal",children:s("settings.mcp.page.transport.remote")})]})]})})]})]}),t.jsxs("div",{"data-settings-item":"mcp.command",className:"mb-6",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s(v==="local"?"settings.mcp.page.connection.command":"settings.mcp.page.connection.serverUrl")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:v==="local"?t.jsx(Ep,{value:L,onChange:E,pasteCommandTitle:s("settings.mcp.page.connection.pasteCommandTitle"),pasteCommandLabel:s("settings.mcp.page.connection.pasteCommand"),pasteSuccess:Se=>s("settings.mcp.page.toast.pastedArgumentsCount",{count:Se}),clipboardReadFailed:s("settings.mcp.page.toast.clipboardReadFailed"),preview:Se=>s("settings.mcp.page.connection.previewArgs",{count:Se})}):t.jsx(it,{value:J,onChange:Se=>_(Se.target.value),placeholder:s("settings.mcp.page.connection.serverUrlPlaceholder"),className:"font-mono typography-meta"})})]}),v==="remote"&&t.jsxs("div",{"data-settings-item":"mcp.advanced",className:"mb-6",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.mcp.page.advanced.title")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsxs(gn,{open:q,onOpenChange:$,children:[t.jsxs(hn,{className:"flex w-full items-center justify-between py-0.5 group",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[t.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:s("settings.mcp.page.advanced.configure")}),t.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",s(F?"settings.mcp.page.advanced.autoDetect":"settings.mcp.page.advanced.custom")," · ",T.length," ",s("settings.mcp.page.advanced.headers"),he?` · ${he}ms`:"",")"]})]}),q?t.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(M,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(fn,{className:"pt-2",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.advanced.timeoutMs")})}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(it,{type:"number",min:"1",step:"1",value:he,onChange:Se=>Ie(Se.target.value),placeholder:"5000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})})]}),t.jsx("p",{className:"typography-micro text-muted-foreground sm:pl-64",children:s("settings.mcp.page.advanced.timeoutHint")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"mb-2 typography-ui-label text-foreground",children:[s("settings.mcp.page.advanced.requestHeaders"),T.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",T.length,")"]})]}),t.jsx(Zi,{value:T,onChange:Y,keyTransform:Se=>Se.trimStart(),keyPlaceholder:s("settings.mcp.page.advanced.headerNamePlaceholder"),keyInputClassName:"w-36 shrink-0 font-mono typography-meta",pasteLabel:s("settings.mcp.page.advanced.pasteHeaders"),pasteTitle:s("settings.mcp.page.advanced.pasteHeadersTitle"),noPairsFoundError:s("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:Se=>s("settings.mcp.page.toast.importedVariablesCount",{count:Se}),clipboardReadFailed:s("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:s("settings.mcp.page.env.key"),valueLabel:s("settings.mcp.page.env.value"),valuePlaceholder:s("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:s("settings.mcp.page.env.hide"),showValueTitle:s("settings.mcp.page.env.show"),addVariable:s("settings.mcp.page.env.addVariable"),plainTextWarning:s("settings.mcp.page.env.plainTextWarning"),removeVariableAria:s("settings.mcp.page.env.removeVariableAria")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":F,onClick:()=>V(!F),onKeyDown:Se=>{(Se.key===" "||Se.key==="Enter")&&(Se.preventDefault(),V(!F))},children:[t.jsx(It,{checked:F,onChange:V,ariaLabel:s("settings.mcp.page.advanced.oauthAutoDetectionAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.mcp.page.advanced.oauthAutoDetection")})]}),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.jsx(it,{value:Q,onChange:Se=>ie(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthClientIdPlaceholder"),className:"font-mono typography-meta",disabled:!F,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(it,{value:X,onChange:Se=>se(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthClientSecretPlaceholder"),className:"font-mono typography-meta",disabled:!F,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(it,{value:me,onChange:Se=>oe(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthScopesPlaceholder"),className:"font-mono typography-meta",disabled:!F,"data-bwignore":"true","data-1p-ignore":"true"}),t.jsx(it,{value:xe,onChange:Se=>we(Se.target.value),placeholder:s("settings.mcp.page.advanced.oauthRedirectUriPlaceholder"),className:"font-mono typography-meta",disabled:!F,"data-bwignore":"true","data-1p-ignore":"true"})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:s("settings.mcp.page.advanced.oauthHint")}),Xt&&t.jsxs("p",{className:"typography-micro text-muted-foreground",children:[s("settings.mcp.page.advanced.oauthCallbackHint"),t.jsx("span",{className:"mt-1 block break-all font-mono text-foreground/80",children:Xt})]})]})]})})]})})]}),t.jsxs("div",{"data-settings-item":"mcp.environment",className:"mb-2",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("h3",{className:"typography-ui-header font-medium text-foreground",children:[s("settings.mcp.page.env.title"),Z.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",Z.length,")"]})]})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:Z.length===0?t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:()=>H([{key:"",value:""}]),children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),s("settings.mcp.page.env.addEnvironmentVariable")]}):t.jsx(Zi,{value:Z,onChange:H,keyPlaceholder:s("settings.mcp.page.env.keyPlaceholder"),pasteLabel:s("settings.mcp.page.env.pasteEnv"),pasteTitle:s("settings.mcp.page.env.pasteEnvTitle"),noPairsFoundError:s("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:Se=>s("settings.mcp.page.toast.importedVariablesCount",{count:Se}),clipboardReadFailed:s("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:s("settings.mcp.page.env.key"),valueLabel:s("settings.mcp.page.env.value"),valuePlaceholder:s("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:s("settings.mcp.page.env.hide"),showValueTitle:s("settings.mcp.page.env.show"),addVariable:s("settings.mcp.page.env.addVariable"),plainTextWarning:s("settings.mcp.page.env.plainTextWarning"),removeVariableAria:s("settings.mcp.page.env.removeVariableAria")})})]}),t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[t.jsx(G,{onClick:Ge,disabled:be||!nt&&!y,size:"xs",className:"!font-normal",children:s(be?"settings.common.actions.saving":y?"settings.common.actions.create":"settings.common.actions.saveChanges")}),!y&&t.jsx(G,{variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>ge(!0),children:s("settings.common.actions.delete")})]})]}),t.jsx(Ut,{open:fe,onOpenChange:Se=>{Se||(O(!1),Je(""),et(null))},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.mcp.page.importDialog.title")}),t.jsx(qt,{children:s("settings.mcp.page.importDialog.description")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(ps,{value:Fe,onChange:Se=>{Je(Se.target.value),et(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 resize-y",spellCheck:!1,"data-bwignore":"true","data-1p-ignore":"true"}),Xe&&t.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:Xe}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:pe,type:"button",children:[t.jsx(M,{name:"clipboard",className:"h-3.5 w-3.5"}),s("settings.mcp.page.importDialog.pasteFromClipboard")]})})]}),t.jsxs(Yt,{children:[t.jsx(G,{variant:"outline",onClick:()=>{O(!1),Je(""),et(null)},className:"text-foreground",children:s("settings.common.actions.cancel")}),t.jsx(G,{onClick:st,disabled:!Fe.trim(),size:"sm",children:s("settings.common.actions.import")})]})]})}),t.jsx(Ut,{open:re,onOpenChange:Se=>{!Se&&!U&&ge(!1)},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.mcp.page.deleteDialog.title",{name:n??""})}),t.jsxs(qt,{children:[s("settings.mcp.page.deleteDialog.descriptionPrefix")," ",t.jsx("code",{className:"text-foreground",children:"opencode.json"}),"."," ",s("settings.mcp.page.deleteDialog.descriptionSuffix")]})]}),t.jsxs(Yt,{children:[t.jsx(G,{variant:"outline",onClick:()=>ge(!1),disabled:U,className:"text-foreground",children:s("settings.common.actions.cancel")}),t.jsx(G,{variant:"destructive",size:"sm",onClick:ft,disabled:U,children:s(U?"settings.mcp.page.actions.deleting":"settings.common.actions.delete")})]})]})})]})},$p=({transform:s})=>({...s,y:0}),Up=s=>{const e=rt.c(18),{id:n,children:a,className:r}=s;let i;e[0]!==n?(i={id:n},e[0]=n,e[1]=i):i=e[1];const{attributes:o,listeners:d,setNodeRef:c,transform:f,transition:m,isDragging:p}=Ac(i);let u;e[2]!==f?(u=Ec.Transform.toString(f),e[2]=f,e[3]=u):u=e[3];let S;e[4]!==u||e[5]!==m?(S={transform:u,transition:m},e[4]=u,e[5]=m,e[6]=S):S=e[6];const h=p&&"opacity-50";let g;e[7]!==r||e[8]!==h?(g=ce("h-full rounded-md",r,h),e[7]=r,e[8]=h,e[9]=g):g=e[9];let x;return e[10]!==o||e[11]!==a||e[12]!==n||e[13]!==d||e[14]!==c||e[15]!==S||e[16]!==g?(x=t.jsx("div",{ref:c,"data-sortable-tab-id":n,style:S,className:g,...o,...d,children:a}),e[10]=o,e[11]=a,e[12]=n,e[13]=d,e[14]=c,e[15]=S,e[16]=g,e[17]=x):x=e[17],x},Bp=s=>{const e=rt.c(6),{id:n,children:a,className:r}=s;let i;e[0]!==r?(i=ce("h-full",r),e[0]=r,e[1]=i):i=e[1];let o;return e[2]!==a||e[3]!==n||e[4]!==i?(o=t.jsx("div",{className:i,"data-sortable-tab-id":n,children:a}),e[2]=a,e[3]=n,e[4]=i,e[5]=o):o=e[5],o},xn=s=>{const e=rt.c(121),{items:n,activeId:a,onSelect:r,onClose:i,onReorder:o,layoutMode:d,variant:c,activePillInsetClassName:f,activePillButtonClassName:m,inactiveTabsIconOnly:p,iconOnlyActiveTab:u,animateActivePill:S,activePillLowercase:h,className:g}=s,x=d===void 0?"scrollable":d,D=c===void 0?"default":c,N=p===void 0?!1:p,w=u===void 0?!1:u,A=h===void 0?!0:h,{t:k}=dt(),j=Ke(Vp),{isTablet:y}=Cs(),P=j||y,z=l.useRef(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={left:!1,right:!1},e[0]=R):R=e[0];const[I,v]=l.useState(R);let b;e[1]!==n?(b=n.map(_p),e[1]=n,e[2]=b):b=e[2];const L=b,E=x==="scrollable",J=D==="default",_=D==="active-pill",Z=D==="animated",H=_||Z,T=J,Y=H||T,F=_&&E,V=H,Q=S??Z,ie=typeof o=="function",X=ie?Up:Bp;let se;e[3]===Symbol.for("react.memo_cache_sentinel")?(se=new Map,e[3]=se):se=e[3];const me=l.useRef(se),[oe,xe]=l.useState(null);let we;e[4]===Symbol.for("react.memo_cache_sentinel")?(we={activationConstraint:{distance:8}},e[4]=we):we=e[4];const he=Pc(Ic(Dc,we)),Ie=Hp;let ve;e[5]===Symbol.for("react.memo_cache_sentinel")?(ve=(Ze,We)=>{if(We){me.current.set(Ze,We);return}me.current.delete(Ze)},e[5]=ve):ve=e[5];const ye=ve;let be;e[6]!==a||e[7]!==Y?(be=()=>{if(!Y||!a){xe(Wp);return}const Ze=z.current,We=me.current.get(a);if(!Ze||!We){xe(qp);return}let pt=0,pe=0,st=We;for(;st&&st!==Ze;)pt=pt+st.offsetLeft,pe=pe+st.offsetTop,st=st.offsetParent;const nt={left:pt,top:pe,width:We.offsetWidth,height:We.offsetHeight};xe(Ge=>Ie(Ge,nt)?Ge:nt)},e[6]=a,e[7]=Y,e[8]=be):be=e[8];const te=be;let re;e[9]!==E?(re=()=>{if(!E){v({left:!1,right:!1});return}const Ze=z.current;if(!Ze){v({left:!1,right:!1});return}v({left:Ze.scrollLeft>2,right:Ze.scrollLeft+Ze.clientWidth<Ze.scrollWidth-2})},e[9]=E,e[10]=re):re=e[10];const ge=re;let U;e[11]!==E||e[12]!==ge?(U=()=>{if(!E){v({left:!1,right:!1});return}const Ze=z.current;if(!Ze)return;ge(),Ze.addEventListener("scroll",ge,{passive:!0});const We=new ResizeObserver(ge);return We.observe(Ze),()=>{Ze.removeEventListener("scroll",ge),We.disconnect()}},e[11]=E,e[12]=ge,e[13]=U):U=e[13];let ee;e[14]!==E||e[15]!==n.length||e[16]!==ge?(ee=[E,n.length,ge],e[14]=E,e[15]=n.length,e[16]=ge,e[17]=ee):ee=e[17],l.useEffect(U,ee);let ne;e[18]!==a||e[19]!==te||e[20]!==Y?(ne=()=>{if(!Y){xe(null);return}te();const Ze=z.current;if(!Ze)return;const We=new ResizeObserver(te);if(We.observe(Ze),a){const pt=me.current.get(a);pt&&We.observe(pt)}return()=>{We.disconnect()}},e[18]=a,e[19]=te,e[20]=Y,e[21]=ne):ne=e[21];let ue;e[22]!==a||e[23]!==n.length||e[24]!==te||e[25]!==Y?(ue=[a,n.length,te,Y],e[22]=a,e[23]=n.length,e[24]=te,e[25]=Y,e[26]=ue):ue=e[26],l.useEffect(ne,ue);let Me;e[27]!==te?(Me=()=>{te()},e[27]=te,e[28]=Me):Me=e[28],l.useLayoutEffect(Me);let ke;e[29]!==a||e[30]!==E||e[31]!==ge?(ke=()=>{if(!E||!a)return;const Ze=z.current;if(!Ze)return;const We=window.requestAnimationFrame(()=>{const pt=typeof window.CSS?.escape=="function"?window.CSS.escape(a):a.replace(/"/g,'\\"'),pe=Ze.querySelector(`[data-sortable-tab-id="${pt}"]`);pe&&(pe.scrollIntoView({block:"nearest",inline:"nearest"}),ge())});return()=>{window.cancelAnimationFrame(We)}},e[29]=a,e[30]=E,e[31]=ge,e[32]=ke):ke=e[32];let De;e[33]!==a||e[34]!==E||e[35]!==n.length||e[36]!==ge?(De=[a,E,n.length,ge],e[33]=a,e[34]=E,e[35]=n.length,e[36]=ge,e[37]=De):De=e[37],l.useEffect(ke,De);let Ae;e[38]!==o?(Ae=Ze=>{if(!o)return;const{active:We,over:pt}=Ze;!pt||We.id===pt.id||o(String(We.id),String(pt.id))},e[38]=o,e[39]=Ae):Ae=e[39];const Pe=Ae;let Re;e[40]!==g?(Re=ce("relative flex h-full min-w-0 flex-1",g),e[40]=g,e[41]=Re):Re=e[41];let Le;e[42]!==E||e[43]!==I||e[44]!==H?(Le=E&&I.left?t.jsx("div",{className:ce("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",H?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[42]=E,e[43]=I,e[44]=H,e[45]=Le):Le=e[45];let $e;e[46]!==E||e[47]!==I||e[48]!==H?($e=E&&I.right?t.jsx("div",{className:ce("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",H?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[46]=E,e[47]=I,e[48]=H,e[49]=$e):$e=e[49];const Be=H?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",Oe=H&&"@container/pill-tabs",Ue=H&&"pill-tabs__track",le=H&&(f??"gap-0.5 py-0.5"),W=T&&"items-center overflow-y-hidden",de=V&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_2%,transparent)] p-0.5 gap-0.5",Ne=E?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Ee;e[50]!==Be||e[51]!==Oe||e[52]!==Ue||e[53]!==le||e[54]!==W||e[55]!==de||e[56]!==Ne?(Ee=ce("relative flex h-full min-w-0 flex-1",Be,Oe,Ue,le,W,de,Ne),e[50]=Be,e[51]=Oe,e[52]=Ue,e[53]=le,e[54]=W,e[55]=de,e[56]=Ne,e[57]=Ee):Ee=e[57];let Ce;e[58]!==E?(Ce=E?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[58]=E,e[59]=Ce):Ce=e[59];let He;e[60]!==k?(He=k("sortableTabsStrip.aria.tabs"),e[60]=k,e[61]=He):He=e[61];let q;e[62]!==oe||e[63]!==Q||e[64]!==H?(q=H&&oe?t.jsx("div",{className:ce("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-border/60"),style:{transform:`translate3d(${oe.left}px, ${oe.top}px, 0)`,width:`${oe.width}px`,height:`${oe.height}px`,transition:Q?"transform 300ms cubic-bezier(0.65, 0, 0.35, 1), width 300ms cubic-bezier(0.65, 0, 0.35, 1), height 300ms cubic-bezier(0.65, 0, 0.35, 1)":void 0}}):null,e[62]=oe,e[63]=Q,e[64]=H,e[65]=q):q=e[65];let $;e[66]!==oe||e[67]!==T?($=T&&oe?t.jsx("div",{className:"pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",style:{transform:`translate3d(${oe.left}px, 0, 0)`,width:`${oe.width}px`},"aria-hidden":!0}):null,e[66]=oe,e[67]=T,e[68]=$):$=e[68];let fe;if(e[69]!==X||e[70]!==a||e[71]!==m||e[72]!==A||e[73]!==P||e[74]!==w||e[75]!==N||e[76]!==_||e[77]!==j||e[78]!==E||e[79]!==n||e[80]!==i||e[81]!==r||e[82]!==F||e[83]!==H){let Ze;e[85]!==X||e[86]!==a||e[87]!==m||e[88]!==A||e[89]!==P||e[90]!==w||e[91]!==N||e[92]!==_||e[93]!==j||e[94]!==E||e[95]!==i||e[96]!==r||e[97]!==F||e[98]!==H?(Ze=We=>{const pt=We.id===a,pe=N&&H&&!pt&&!!We.icon,st=!pe,nt=!!We.icon&&(!w||pt),Ge=N&&H&&pt&&!E&&!F,ft=We.closable!==!1&&!!i,wt=ft&&!!We.icon,Ct=E||F?void 0:H?Ge?"flex-none basis-auto":j?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",ae=ft?tt=>{tt.button===1&&(tt.preventDefault(),tt.stopPropagation(),i?.(We.id))}:void 0,Ve=ft?Gp:void 0;return t.jsx(X,{id:We.id,className:Ct,children:t.jsxs("div",{ref:tt=>ye(We.id,tt),onAuxClick:ae,onMouseDown:Ve,className:ce("group flex h-full min-w-0 flex-nowrap items-center",E||F?"shrink-0":H?"w-full":"w-full min-w-0",H?"relative z-10 bg-transparent":pt?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("button",{type:"button",role:"tab","aria-selected":pt,"aria-label":pe?We.title??We.label:void 0,onClick:()=>r(We.id),className:ce(H?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",H&&A?"lowercase":null,H&&(pe?"gap-0":"gap-1.5"),H?F?"shrink-0 whitespace-nowrap px-3 text-center":E?"max-w-56 shrink-0 px-3 text-center":pe?"px-2 !min-w-0 text-center":Ge?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":E?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",H?m??(_?j?"h-[38px]":"h-[31px]":"h-7"):null,H?pt?"text-foreground":"text-muted-foreground hover:text-foreground":null,H?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:We.title??We.label,children:H?t.jsxs(t.Fragment,{children:[nt?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:ce("flex items-center justify-center transition-opacity",wt&&(P?"opacity-0":"group-hover:opacity-0")),children:We.icon}),wt?t.jsx("span",{role:"button",tabIndex:-1,className:ce("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",P?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Jp,onClick:tt=>{tt.stopPropagation(),i?.(We.id)},"aria-label":We.closeLabel??`Close ${We.label} tab`,title:We.closeLabel??`Close ${We.label} tab`,children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,st?t.jsx("span",{className:"animated-tabs__label truncate",children:We.label}):null]}):t.jsxs("span",{className:ce("flex min-w-0 flex-nowrap items-center gap-1.5",!E&&"justify-center"),children:[nt?t.jsxs("span",{className:ce("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",pt?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:ce("flex items-center justify-center transition-opacity",wt&&(P?"opacity-0":"group-hover:opacity-0")),children:We.icon}),wt?t.jsx("span",{role:"button",tabIndex:-1,className:ce("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",P?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Qp,onClick:tt=>{tt.stopPropagation(),i?.(We.id)},"aria-label":We.closeLabel??`Close ${We.label} tab`,title:We.closeLabel??`Close ${We.label} tab`,children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:We.label})]})}),ft&&!wt?t.jsx("button",{type:"button",onPointerDown:Yp,onClick:tt=>{tt.stopPropagation(),i?.(We.id)},className:ce("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",H?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",H?pt?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":pt?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":We.closeLabel??`Close ${We.label} tab`,title:We.closeLabel??`Close ${We.label} tab`,children:t.jsx(M,{name:"close",className:"h-3 w-3"})}):null]})},We.id)},e[85]=X,e[86]=a,e[87]=m,e[88]=A,e[89]=P,e[90]=w,e[91]=N,e[92]=_,e[93]=j,e[94]=E,e[95]=i,e[96]=r,e[97]=F,e[98]=H,e[99]=Ze):Ze=e[99],fe=n.map(Ze),e[69]=X,e[70]=a,e[71]=m,e[72]=A,e[73]=P,e[74]=w,e[75]=N,e[76]=_,e[77]=j,e[78]=E,e[79]=n,e[80]=i,e[81]=r,e[82]=F,e[83]=H,e[84]=fe}else fe=e[84];let O;e[100]!==Ee||e[101]!==Ce||e[102]!==He||e[103]!==q||e[104]!==$||e[105]!==fe?(O=t.jsxs("div",{ref:z,className:Ee,style:Ce,role:"tablist","aria-label":He,children:[q,$,fe]}),e[100]=Ee,e[101]=Ce,e[102]=He,e[103]=q,e[104]=$,e[105]=fe,e[106]=O):O=e[106];let Fe;e[107]!==Re||e[108]!==Le||e[109]!==$e||e[110]!==O?(Fe=t.jsxs("div",{className:Re,children:[Le,$e,O]}),e[107]=Re,e[108]=Le,e[109]=$e,e[110]=O,e[111]=Fe):Fe=e[111];const Je=Fe;if(!ie)return Je;let Xe;e[112]===Symbol.for("react.memo_cache_sentinel")?(Xe=[$p],e[112]=Xe):Xe=e[112];let et;e[113]!==L||e[114]!==Je?(et=t.jsx(Mc,{items:L,strategy:Rc,children:Je}),e[113]=L,e[114]=Je,e[115]=et):et=e[115];let at;e[116]===Symbol.for("react.memo_cache_sentinel")?(at=t.jsx(Tc,{dropAnimation:null}),e[116]=at):at=e[116];let lt;return e[117]!==Pe||e[118]!==he||e[119]!==et?(lt=t.jsxs(Fc,{sensors:he,collisionDetection:Lc,onDragEnd:Pe,modifiers:Xe,children:[et,at]}),e[117]=Pe,e[118]=he,e[119]=et,e[120]=lt):lt=e[120],lt};function Vp(s){return s.isMobile}function _p(s){return s.id}function Hp(s,e){return!s||!e?s===e:Math.abs(s.left-e.left)<.5&&Math.abs(s.top-e.top)<.5&&Math.abs(s.width-e.width)<.5&&Math.abs(s.height-e.height)<.5}function Wp(s){return s===null?s:null}function qp(s){return s===null?s:null}function Gp(s){s.button===1&&s.preventDefault()}function Jp(s){s.stopPropagation()}function Qp(s){s.stopPropagation()}function Yp(s){s.stopPropagation()}const Pa=()=>{try{const e=as.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();const n=Ns.getDirectory();if(n?.trim())return n.trim()}catch(s){console.warn("[PluginsStore] Error resolving config directory:",s)}return null},Xp=800,Zp=5e3,eg="__default__",Er=new Map,rr=new Map,tg=1500,Rl=s=>s?.trim()||eg,sg=s=>{Er.delete(Rl(s))},os=rn()(Zn($r((s,e)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:n=>s({selectedId:n}),setDraft:n=>s({draft:n}),loadPlugins:async n=>{const a=Pa(),r=Rl(a),i=Date.now(),o=Er.get(r)??0,d=e().entries.length>0||e().files.length>0;if(!n?.force&&d&&i-o<Zp)return!0;const c=rr.get(r);if(!n?.force&&c)return c;const f=(async()=>{s({isLoading:!0});try{const m=await jt(Xs("/api/config/plugins",a),{headers:Bn(a)});if(!m.ok)throw new Error("Failed to load plugins");const p=await Ia(m);return s({entries:p.entries??[],files:p.files??[],isLoading:!1}),Er.set(r,Date.now()),n?.force||e().loadRegistryInfo(),!0}catch(m){return console.error("[PluginsStore] Failed to load plugins:",m),s({isLoading:!1}),!1}})();rr.set(r,f);try{return await f}finally{rr.delete(r)}},loadRegistryInfo:async n=>{const a=ag(n?.specs??e().entries.map(r=>r.spec));if(a.length===0){s({isLoadingRegistry:!1});return}s({isLoadingRegistry:!0});try{const r=Pa(),i={...e().registryInfo};for(const o of rg(a)){const d=await jt(ng(o,n?.force===!0,r),{headers:Bn(r)});if(!d.ok)throw new Error("Failed to load plugin registry info");const c=await Ia(d);for(const f of c.results??[])i[f.spec]=f}s({registryInfo:i,isLoadingRegistry:!1})}catch(r){console.error("[PluginsStore] Failed to load plugin registry info:",r),s({isLoadingRegistry:!1})}},updateToLatest:async n=>{const a=e().entries.find(i=>i.id===n);if(!a)return{ok:!1};const r=e().registryInfo[a.spec];return!r||r.kind!=="npm-ok"||!r.hasUpdate||!r.latestVersion?{ok:!1}:await e().updateEntry(n,{spec:`${r.name}@${r.latestVersion}`})},createEntry:async n=>{const a=await jn("Creating plugin entry…",async r=>await jt(Xs("/api/config/plugins/entry",r),{method:"POST",headers:pa(r),body:JSON.stringify(so(n))}),e);return a.ok&&e().loadRegistryInfo({specs:[n.spec],force:!0}),a},updateEntry:async(n,a)=>{const r=e().entries.find(d=>d.id===n)?.spec,i=a.spec??r,o=await jn("Updating plugin entry…",async d=>await jt(Xs(`/api/config/plugins/entry/${encodeURIComponent(n)}`,d),{method:"PATCH",headers:pa(d),body:JSON.stringify(so(a))}),e);return o.ok&&i&&e().loadRegistryInfo({specs:[i],force:!0}),o},deleteEntry:async n=>{const a=e().entries.find(i=>i.id===n),r=await jn("Deleting plugin entry…",async i=>await jt(Xs(`/api/config/plugins/entry/${encodeURIComponent(n)}`,i),{method:"DELETE",headers:Bn(i)}),e);if(r.ok&&e().selectedId===n&&s({selectedId:null}),r.ok&&a){const i={...e().registryInfo};delete i[a.spec],s({registryInfo:i})}return r},readFile:async n=>{try{const a=Pa(),r=await jt(Xs(`/api/config/plugins/file/${encodeURIComponent(n)}`,a),{headers:Bn(a)});if(!r.ok)throw new Error("Failed to read plugin file");return await Ia(r)}catch(a){return console.error("[PluginsStore] Failed to read plugin file:",a),null}},createFile:async n=>jn("Creating plugin file…",async a=>await jt(Xs("/api/config/plugins/file",a),{method:"POST",headers:pa(a),body:JSON.stringify(n)}),e),updateFile:async(n,a)=>jn("Updating plugin file…",async r=>await jt(Xs(`/api/config/plugins/file/${encodeURIComponent(n)}`,r),{method:"PUT",headers:pa(r),body:JSON.stringify(a)}),e),deleteFile:async n=>{const a=await jn("Deleting plugin file…",async r=>await jt(Xs(`/api/config/plugins/file/${encodeURIComponent(n)}`,r),{method:"DELETE",headers:Bn(r)}),e);return a.ok&&e().selectedId===n&&s({selectedId:null}),a},getById:n=>e().entries.find(a=>a.id===n)??e().files.find(a=>a.id===n)}),{name:"plugins-store",storage:Ur(()=>Yn()),partialize:s=>({selectedId:s.selectedId})}),{name:"plugins-store"}));function Xs(s,e){const n=e?`?directory=${encodeURIComponent(e)}`:"";return`${s}${n}`}function ng(s,e,n){const a=new URLSearchParams;e&&a.set("refresh","true"),n&&a.set("directory",n);const r=a.toString();return`/api/config/plugins/registry?${`specs=${s.map(encodeURIComponent).join(",")}`}${r?`&${r}`:""}`}function ag(s){return Array.from(new Set(s.map(e=>e.trim()).filter(Boolean)))}function rg(s){const e=[];let n=[],a=0;for(const r of s){const i=encodeURIComponent(r),o=n.length===0?i.length:a+1+i.length;n.length>0&&o>tg?(e.push(n),n=[r],a=i.length):(n.push(r),a=o)}return n.length>0&&e.push(n),e}function Bn(s){return s?{"x-opencode-directory":s}:void 0}function pa(s){return{"Content-Type":"application/json",...s?{"x-opencode-directory":s}:{}}}function so(s){const e={};return s.spec!==void 0&&(e.spec=s.spec),s.options!==void 0&&(e.options=s.options),s.scope!==void 0&&(e.scope=s.scope),e}async function jn(s,e,n){Na(s);let a=!1;try{const r=Pa(),i=await e(r),o=await Ia(i).catch(()=>null);if(!i.ok)throw new Error(o?.error||"Failed to update plugin configuration");return sg(r),o?.requiresReload&&(a=!0,await ka({message:o.message,delayMs:o.reloadDelayMs??Xp,scopes:["all"]})),await n().loadPlugins({force:!0}),{ok:!0,reloadFailed:o?.reloadFailed===!0,message:o?.message,warning:o?.warning}}catch(r){return console.error("[PluginsStore] Failed to update plugin configuration:",r),{ok:!1}}finally{a||Sa()}}async function Ia(s){return await s.json()}const ig=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function og(s){const e=s.trim();if(e==="")return{ok:!0,value:void 0};try{const n=JSON.parse(e);return n===null||typeof n!="object"||Array.isArray(n)?{ok:!1}:{ok:!0,value:n}}catch{return{ok:!1}}}const lg=({open:s,onOpenChange:e,defaultScope:n="user"})=>{const{t:a}=dt(),r=os(E=>E.createEntry),i=os(E=>E.createFile),[o,d]=l.useState("npm"),[c,f]=l.useState(""),[m,p]=l.useState(""),[u,S]=l.useState(""),[h,g]=l.useState(""),[x,D]=l.useState(n),[N,w]=l.useState(!1),A=l.useCallback(()=>{f(""),p(""),S(""),g(""),D(n)},[n]);l.useEffect(()=>{s&&(d("npm"),A())},[s,A]);const k=E=>{E!==o&&(d(E),A())},j=l.useMemo(()=>og(m),[m]),y=!j.ok,P=o==="file"&&u.trim()!==""&&!ig.test(u.trim()),z=(o==="npm"||o==="path")&&c.trim()==="",R=o==="file"&&h.trim()==="",I=o==="file"&&u.trim()==="",v=N||y||o==="npm"&&z||o==="path"&&z||o==="file"&&(I||P||R),b=async()=>{if(!v){w(!0);try{let E;o==="file"?E=await i({fileName:u.trim(),content:h,scope:x}):E=await r({spec:c.trim(),options:j.ok?j.value:void 0,scope:x}),E.ok?(B.success(E.message||a("settings.plugins.toast.created")),E.reloadFailed&&B.warning(a("settings.plugins.toast.reloadFailed")),e(!1)):B.error(E.message||a("settings.plugins.sidebar.toast.deleteFailed"))}finally{w(!1)}}},L=l.useMemo(()=>[{id:"npm",label:a("settings.plugins.dialog.add.tab.npm")},{id:"path",label:a("settings.plugins.dialog.add.tab.path")},{id:"file",label:a("settings.plugins.dialog.add.tab.file")}],[a]);return t.jsx(Ut,{open:s,onOpenChange:E=>{!E&&N||e(E)},children:t.jsxs(Bt,{className:"max-w-xl",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:a("settings.plugins.dialog.add.title")}),t.jsx(qt,{children:a("settings.plugins.sidebar.empty.description")})]}),t.jsx(xn,{items:L,activeId:o,onSelect:E=>k(E),layoutMode:"fit",variant:"active-pill",activePillLowercase:!1,className:"h-10"}),t.jsxs("div",{className:"flex flex-col gap-4",children:[(o==="npm"||o==="path")&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{"data-settings-item":"plugins.spec",className:"flex flex-col gap-1.5",children:[t.jsx("label",{htmlFor:"plugin-spec",className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.spec")}),t.jsx(it,{id:"plugin-spec",value:c,onChange:E=>f(E.target.value),placeholder:a("settings.plugins.page.field.spec.placeholder"),"aria-invalid":z?!1:void 0,disabled:N}),z&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:a("settings.plugins.validation.specRequired")})]}),t.jsxs("div",{"data-settings-item":"plugins.options",className:"flex flex-col gap-1.5",children:[t.jsx("label",{htmlFor:"plugin-options",className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.options")}),t.jsx(ps,{id:"plugin-options",value:m,onChange:E=>p(E.target.value),rows:5,className:"font-mono",hasError:y,disabled:N}),y&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:a("settings.plugins.page.field.options.invalidJson")})]})]}),o==="file"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{"data-settings-item":"plugins.content",className:"flex flex-col gap-1.5",children:[t.jsx("label",{htmlFor:"plugin-filename",className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.fileName")}),t.jsx(it,{id:"plugin-filename",value:u,onChange:E=>S(E.target.value),placeholder:"my-plugin.ts","aria-invalid":P||void 0,disabled:N}),P&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:a("settings.plugins.validation.fileName")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{htmlFor:"plugin-content",className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.content")}),t.jsx(ps,{id:"plugin-content",value:h,onChange:E=>g(E.target.value),rows:16,className:"font-mono",disabled:N})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:a("settings.plugins.page.field.scope")}),t.jsx("div",{className:"flex items-center gap-4",children:["user","project"].map(E=>{const J=x===E,_=a(E==="user"?"settings.plugins.scope.user":"settings.plugins.scope.project");return t.jsxs("button",{type:"button",onClick:()=>D(E),disabled:N,className:"flex items-center gap-2 py-1 text-left disabled:opacity-50",children:[t.jsx(Sn,{checked:J,onChange:()=>D(E),ariaLabel:_}),t.jsx("span",{className:ce("typography-ui-label font-normal",J?"text-foreground":"text-foreground/60"),children:_})]},E)})})]})]}),t.jsxs(Yt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>e(!1),disabled:N,children:a("settings.plugins.dialog.add.action.cancel")}),t.jsxs(G,{size:"sm",onClick:()=>{b()},disabled:v,children:[N?t.jsx(M,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}):null,a("settings.plugins.dialog.add.action.submit")]})]})]})})},cg=s=>{const e=rt.c(33),{spec:n}=s;let a;e[0]!==n?(a=d=>d.registryInfo[n],e[0]=n,e[1]=a):a=e[1];const r=os(a),{t:i}=dt();if(!r)return null;const o=dg;switch(r.kind){case"npm-ok":{if(!r.hasUpdate||!r.latestVersion)return null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(M,{name:"arrow-up-s",className:"h-3 w-3"}),e[2]=d):d=e[2];let c;e[3]!==r.latestVersion?(c=t.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[var(--status-success)]",children:[d,r.latestVersion]}),e[3]=r.latestVersion,e[4]=c):c=e[4];let f;return e[5]!==r.currentVersion||e[6]!==r.latestVersion||e[7]!==i||e[8]!==c?(f=o(c,i("settings.plugins.registry.badge.update.tooltip",{current:r.currentVersion??"",latest:r.latestVersion})),e[5]=r.currentVersion,e[6]=r.latestVersion,e[7]=i,e[8]=c,e[9]=f):f=e[9],f}case"npm-missing-version":{let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(M,{name:"error-warning",className:"h-3 w-3 text-[var(--status-warning)]"}),e[10]=d):d=e[10];let c;return e[11]!==r.currentVersion||e[12]!==r.name||e[13]!==i?(c=o(d,i("settings.plugins.registry.badge.missingVersion.tooltip",{version:r.currentVersion,name:r.name})),e[11]=r.currentVersion,e[12]=r.name,e[13]=i,e[14]=c):c=e[14],c}case"npm-missing-package":{let d;e[15]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(M,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[15]=d):d=e[15];let c;return e[16]!==r.name||e[17]!==i?(c=o(d,i("settings.plugins.registry.badge.missingPackage.tooltip",{name:r.name})),e[16]=r.name,e[17]=i,e[18]=c):c=e[18],c}case"npm-malformed":{let d;e[19]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(M,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[19]=d):d=e[19];let c;return e[20]!==i?(c=o(d,i("settings.plugins.registry.badge.malformed.tooltip")),e[20]=i,e[21]=c):c=e[21],c}case"npm-network":{let d;e[22]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(M,{name:"cloud-off",className:"h-3 w-3 text-muted-foreground"}),e[22]=d):d=e[22];let c;return e[23]!==i?(c=o(d,i("settings.plugins.registry.badge.network.tooltip")),e[23]=i,e[24]=c):c=e[24],c}case"path-missing":{let d;e[25]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(M,{name:"error-warning",className:"h-3 w-3 text-[var(--status-error)]"}),e[25]=d):d=e[25];let c;return e[26]!==r.absolutePath||e[27]!==i?(c=o(d,i("settings.plugins.registry.badge.pathMissing.tooltip",{path:r.absolutePath})),e[26]=r.absolutePath,e[27]=i,e[28]=c):c=e[28],c}case"path-unreadable":{let d;e[29]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(M,{name:"error-warning",className:"h-3 w-3 text-[var(--status-warning)]"}),e[29]=d):d=e[29];let c;return e[30]!==r.absolutePath||e[31]!==i?(c=o(d,i("settings.plugins.registry.badge.pathUnreadable.tooltip",{path:r.absolutePath})),e[30]=r.absolutePath,e[31]=i,e[32]=c):c=e[32],c}case"path-ok":return null;default:return null}};function dg(s,e){return t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-xs",children:s})}),t.jsx(Et,{children:e})]})}const Tl=s=>{const e=rt.c(26),{header:n,footer:a,children:r,className:i,variant:o}=s,d=o===void 0?"sidebar":o,c=gs(),f=l.useRef(null),[m,p]=l.useState(!1),[u,S]=l.useState(!1),h=d==="background"||c?"bg-background":"bg-sidebar",g=h==="bg-background"?"var(--surface-background)":"var(--surface-muted)";let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const v=f.current;if(!v){p(!1),S(!1);return}if(!(v.scrollHeight>v.clientHeight+1)){p(!1),S(!1);return}p(v.scrollTop>1),S(v.scrollTop+v.clientHeight<v.scrollHeight-1)},e[0]=x):x=e[0];const D=x;let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{D()},e[1]=N):N=e[1];let w;e[2]!==r?(w=[r,D],e[2]=r,e[3]=w):w=e[3],l.useEffect(N,w);let A,k;e[4]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const v=f.current;if(!v)return;const b=()=>D();return v.addEventListener("scroll",b,{passive:!0}),()=>v.removeEventListener("scroll",b)},k=[D],e[4]=A,e[5]=k):(A=e[4],k=e[5]),l.useEffect(A,k);let j;e[6]!==h||e[7]!==i?(j=ce("flex h-full flex-col",h,i),e[6]=h,e[7]=i,e[8]=j):j=e[8];let y;e[9]!==r?(y=t.jsx(Jt,{ref:f,outerClassName:"flex-1 min-h-0",className:"space-y-0.5 px-3 py-2 overflow-x-hidden",children:r}),e[9]=r,e[10]=y):y=e[10];let P;e[11]!==g||e[12]!==m?(P=m&&t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-4",style:{background:`linear-gradient(to bottom, ${g} 0%, transparent 100%)`}}),e[11]=g,e[12]=m,e[13]=P):P=e[13];let z;e[14]!==g||e[15]!==u?(z=u&&t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6",style:{background:`linear-gradient(to top, ${g} 0%, transparent 100%)`}}),e[14]=g,e[15]=u,e[16]=z):z=e[16];let R;e[17]!==z||e[18]!==y||e[19]!==P?(R=t.jsxs("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[y,P,z]}),e[17]=z,e[18]=y,e[19]=P,e[20]=R):R=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==R||e[24]!==j?(I=t.jsxs("div",{className:j,children:[n,R,a]}),e[21]=a,e[22]=n,e[23]=R,e[24]=j,e[25]=I):I=e[25],I},Mr=s=>{const e=rt.c(23),{title:n,metadata:a,selected:r,onSelect:i,icon:o,actions:d,className:c}=s,f=r===void 0?!1:r,m=d&&d.length>0,p=f?"bg-interactive-selection":"hover:bg-interactive-hover";let u;e[0]!==c||e[1]!==p?(u=ce("group relative flex items-center rounded-md px-1.5 py-0.5 transition-all duration-200",p,c),e[0]=c,e[1]=p,e[2]=u):u=e[2];let S;e[3]!==n?(S=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n}),e[3]=n,e[4]=S):S=e[4];let h;e[5]!==o||e[6]!==S?(h=t.jsxs("div",{className:"flex items-center gap-1.5",children:[o,S]}),e[5]=o,e[6]=S,e[7]=h):h=e[7];let g;e[8]!==a?(g=a&&t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a}),e[8]=a,e[9]=g):g=e[9];let x;e[10]!==i||e[11]!==h||e[12]!==g?(x=t.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[h,g]}),e[10]=i,e[11]=h,e[12]=g,e[13]=x):x=e[13];let D;e[14]!==d||e[15]!==m?(D=m&&t.jsxs(us,{children:[t.jsx(ds,{asChild:!0,children:t.jsx(G,{size:"icon",variant:"ghost",className:"h-6 w-6 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ms,{align:"end",className:"w-fit min-w-20",children:d.map(mg)})]}),e[14]=d,e[15]=m,e[16]=D):D=e[16];let N;e[17]!==x||e[18]!==D?(N=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[x,D]}),e[17]=x,e[18]=D,e[19]=N):N=e[19];let w;return e[20]!==u||e[21]!==N?(w=t.jsx("div",{className:u,children:N}),e[20]=u,e[21]=N,e[22]=w):w=e[22],w};function mg(s){const e=s.icon;return t.jsxs(js,{onClick:n=>{n.stopPropagation(),s.onClick()},className:ce(s.destructive&&"text-destructive focus:text-destructive"),children:[e&&t.jsx(M,{name:e,className:"h-4 w-4 mr-px"}),s.label]},s.label)}const ug=s=>s.parsedKind==="npm"?"code-box":"folder",pg=s=>{const e=rt.c(144),{onItemSelect:n,onAddClick:a}=s,{t:r}=dt(),{entries:i,files:o,selectedId:d,setSelected:c,deleteEntry:f,deleteFile:m,loadPlugins:p}=os(Ss(gg)),u=os(hg),S=os(fg),h=os(xg),g=os(yg),[x,D]=l.useState(null),[N,w]=l.useState(!1),[A,k]=l.useState(!1);let j,y;e[0]!==p?(j=()=>{p()},y=[p],e[0]=p,e[1]=j,e[2]=y):(j=e[1],y=e[2]),l.useEffect(j,y);let P,z;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const pe=()=>k(!0);return window.addEventListener("openchamber:settings-open-plugin-add",pe),()=>window.removeEventListener("openchamber:settings-open-plugin-add",pe)},z=[],e[3]=P,e[4]=z):(P=e[3],z=e[4]),l.useEffect(P,z);let R;if(e[5]!==i||e[6]!==u){R={userEntries:0,projectEntries:0};for(const pe of i){const st=u[pe.spec];st?.kind==="npm-ok"&&st.hasUpdate&&(pe.scope==="user"?R.userEntries=R.userEntries+1:pe.scope==="project"&&(R.projectEntries=R.projectEntries+1))}e[5]=i,e[6]=u,e[7]=R}else R=e[7];const I=R;let v;e[8]!==i?(v=i.filter(bg),e[8]=i,e[9]=v):v=e[9];const b=v;let L;e[10]!==i?(L=i.filter(vg),e[10]=i,e[11]=L):L=e[11];const E=L;let J;e[12]!==o?(J=o.filter(jg),e[12]=o,e[13]=J):J=e[13];const _=J;let Z;e[14]!==o?(Z=o.filter(wg),e[14]=o,e[15]=Z):Z=e[15];const H=Z,T=i.length+o.length,Y=T===0;let F;e[16]!==a?(F=()=>{a?a():k(!0)},e[16]=a,e[17]=F):F=e[17];const V=F;let Q;e[18]!==n||e[19]!==c?(Q=pe=>{c(pe),n?.()},e[18]=n,e[19]=c,e[20]=Q):Q=e[20];const ie=Q;let X;e[21]!==i||e[22]!==u||e[23]!==r||e[24]!==g?(X=async pe=>{const st=i.find(wt=>wt.id===pe);if(!st)return;const nt=u[st.spec];if(!nt||nt.kind!=="npm-ok"||!nt.hasUpdate||!nt.latestVersion)return;const Ge=nt.latestVersion;(await g(pe)).ok?B.success(r("settings.plugins.toast.updatedToLatest",{version:Ge})):B.error(r("settings.plugins.toast.refreshFailed"))},e[21]=i,e[22]=u,e[23]=r,e[24]=g,e[25]=X):X=e[25];const se=X;let me;e[26]!==h||e[27]!==r?(me=async()=>{B.info(r("settings.plugins.toast.refreshing"));try{await h({force:!0})}catch{B.error(r("settings.plugins.toast.refreshFailed"))}},e[26]=h,e[27]=r,e[28]=me):me=e[28];const oe=me;let xe;e[29]!==f||e[30]!==m||e[31]!==x||e[32]!==r?(xe=async()=>{if(!x)return;w(!0);const pe=x.kind==="entry"?await f(x.id):await m(x.id);pe.ok?B.success(pe.message||r("settings.plugins.sidebar.toast.deleted",{name:x.label})):B.error(r("settings.plugins.sidebar.toast.deleteFailed")),D(null),w(!1)},e[29]=f,e[30]=m,e[31]=x,e[32]=r,e[33]=xe):xe=e[33];const we=xe;let he;e[34]!==ie||e[35]!==se||e[36]!==u||e[37]!==d||e[38]!==r?(he=pe=>{const st=u[pe.spec],nt=st?.kind==="npm-ok"&&st.hasUpdate&&!!st.latestVersion,Ge=[];return nt&&Ge.push({label:r("settings.plugins.sidebar.actions.updateToLatest"),icon:"arrow-up-s",onClick:()=>{se(pe.id)}}),Ge.push({label:r("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onClick:()=>D({kind:"entry",id:pe.id,label:pe.spec})}),t.jsx(Mr,{title:t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:pe.spec}),t.jsx(cg,{spec:pe.spec})]}),metadata:pe.parsedKind==="npm"?r("settings.plugins.sidebar.kind.npm"):r("settings.plugins.sidebar.kind.path"),selected:d===pe.id,onSelect:()=>ie(pe.id),icon:t.jsx(M,{name:ug(pe),className:"h-4 w-4 flex-shrink-0 text-muted-foreground/70"}),actions:Ge},pe.id)},e[34]=ie,e[35]=se,e[36]=u,e[37]=d,e[38]=r,e[39]=he):he=e[39];const Ie=he;let ve;e[40]!==ie||e[41]!==d||e[42]!==r?(ve=pe=>t.jsx(Mr,{title:pe.fileName,metadata:r("settings.plugins.sidebar.kind.file"),selected:d===pe.id,onSelect:()=>ie(pe.id),icon:t.jsx(M,{name:"file-text",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/70"}),actions:[{label:r("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onClick:()=>D({kind:"file",id:pe.id,label:pe.fileName})}]},pe.id),e[40]=ie,e[41]=d,e[42]=r,e[43]=ve):ve=e[43];const ye=ve;let be;e[44]!==r?(be=(pe,st,nt)=>{const Ge=nt===void 0?0:nt;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[pe,Ge>0&&t.jsx("span",{className:"ml-2 normal-case font-normal text-[var(--status-success)]",children:r(Ge===1?"settings.plugins.sidebar.group.updatesAvailable_one":"settings.plugins.sidebar.group.updatesAvailable_other",{count:Ge})})]}),st]})},e[44]=r,e[45]=be):be=e[45];const te=be;let re;e[46]!==r?(re=r("settings.plugins.sidebar.title"),e[46]=r,e[47]=re):re=e[47];let ge;e[48]!==re?(ge=t.jsx("div",{className:"mb-3 flex items-center justify-between gap-3",children:t.jsx("h2",{className:"text-base font-semibold text-foreground",children:re})}),e[48]=re,e[49]=ge):ge=e[49];let U;e[50]!==r||e[51]!==T?(U=r("settings.plugins.sidebar.total",{count:T}),e[50]=r,e[51]=T,e[52]=U):U=e[52];let ee;e[53]!==U?(ee=t.jsx("span",{className:"typography-meta text-muted-foreground",children:U}),e[53]=U,e[54]=ee):ee=e[54];let ne;e[55]!==oe?(ne=()=>{oe()},e[55]=oe,e[56]=ne):ne=e[56];let ue;e[57]!==r?(ue=r("settings.plugins.sidebar.actions.refresh"),e[57]=r,e[58]=ue):ue=e[58];let Me;e[59]!==r?(Me=r("settings.plugins.sidebar.actions.refresh"),e[59]=r,e[60]=Me):Me=e[60];const ke=S?"size-4 animate-spin":"size-4";let De;e[61]!==ke?(De=t.jsx(M,{name:"refresh",className:ke}),e[61]=ke,e[62]=De):De=e[62];let Ae;e[63]!==S||e[64]!==ne||e[65]!==ue||e[66]!==Me||e[67]!==De?(Ae=t.jsx(G,{type:"button","data-settings-item":"plugins.create",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:ne,disabled:S,"aria-label":ue,title:Me,children:De}),e[63]=S,e[64]=ne,e[65]=ue,e[66]=Me,e[67]=De,e[68]=Ae):Ae=e[68];let Pe;e[69]!==r?(Pe=r("settings.plugins.sidebar.actions.addTitle"),e[69]=r,e[70]=Pe):Pe=e[70];let Re;e[71]!==r?(Re=r("settings.plugins.sidebar.actions.addTitle"),e[71]=r,e[72]=Re):Re=e[72];let Le;e[73]===Symbol.for("react.memo_cache_sentinel")?(Le=t.jsx(M,{name:"add",className:"size-4"}),e[73]=Le):Le=e[73];let $e;e[74]!==V||e[75]!==Pe||e[76]!==Re?($e=t.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:V,"aria-label":Pe,title:Re,children:Le}),e[74]=V,e[75]=Pe,e[76]=Re,e[77]=$e):$e=e[77];let Be;e[78]!==Ae||e[79]!==$e?(Be=t.jsxs("div",{className:"flex items-center gap-1",children:[Ae,$e]}),e[78]=Ae,e[79]=$e,e[80]=Be):Be=e[80];let Oe;e[81]!==ee||e[82]!==Be?(Oe=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ee,Be]}),e[81]=ee,e[82]=Be,e[83]=Oe):Oe=e[83];let Ue;e[84]!==ge||e[85]!==Oe?(Ue=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[ge,Oe]}),e[84]=ge,e[85]=Oe,e[86]=Ue):Ue=e[86];let le;e[87]!==Y||e[88]!==E||e[89]!==H||e[90]!==Ie||e[91]!==ye||e[92]!==te||e[93]!==r||e[94]!==I||e[95]!==b||e[96]!==_?(le=Y?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(M,{name:"plug",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:r("settings.plugins.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:r("settings.plugins.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[b.length>0&&te(r("settings.plugins.sidebar.group.userEntries"),b.map(Ie),I.userEntries),_.length>0&&te(r("settings.plugins.sidebar.group.userFiles"),_.map(ye)),E.length>0&&te(r("settings.plugins.sidebar.group.projectEntries"),E.map(Ie),I.projectEntries),H.length>0&&te(r("settings.plugins.sidebar.group.projectFiles"),H.map(ye))]}),e[87]=Y,e[88]=E,e[89]=H,e[90]=Ie,e[91]=ye,e[92]=te,e[93]=r,e[94]=I,e[95]=b,e[96]=_,e[97]=le):le=e[97];let W;e[98]!==Ue||e[99]!==le?(W=t.jsx(Tl,{variant:"background",header:Ue,children:le}),e[98]=Ue,e[99]=le,e[100]=W):W=e[100];let de;e[101]!==A?(de=t.jsx(lg,{open:A,onOpenChange:k}),e[101]=A,e[102]=de):de=e[102];const Ne=x!==null;let Ee;e[103]!==N?(Ee=pe=>{!pe&&!N&&D(null)},e[103]=N,e[104]=Ee):Ee=e[104];let Ce;e[105]!==r?(Ce=r("settings.plugins.sidebar.deleteDialog.title"),e[105]=r,e[106]=Ce):Ce=e[106];let He;e[107]!==Ce?(He=t.jsx(Vt,{children:Ce}),e[107]=Ce,e[108]=He):He=e[108];const q=x?.label??"";let $;e[109]!==r||e[110]!==q?($=r("settings.plugins.sidebar.deleteDialog.description",{name:q}),e[109]=r,e[110]=q,e[111]=$):$=e[111];let fe;e[112]!==$?(fe=t.jsx(qt,{children:$}),e[112]=$,e[113]=fe):fe=e[113];let O;e[114]!==He||e[115]!==fe?(O=t.jsxs(_t,{children:[He,fe]}),e[114]=He,e[115]=fe,e[116]=O):O=e[116];let Fe;e[117]===Symbol.for("react.memo_cache_sentinel")?(Fe=()=>D(null),e[117]=Fe):Fe=e[117];let Je;e[118]!==r?(Je=r("settings.common.actions.cancel"),e[118]=r,e[119]=Je):Je=e[119];let Xe;e[120]!==N||e[121]!==Je?(Xe=t.jsx(G,{size:"sm",variant:"ghost",onClick:Fe,disabled:N,children:Je}),e[120]=N,e[121]=Je,e[122]=Xe):Xe=e[122];let et;e[123]!==N||e[124]!==r?(et=r(N?"settings.plugins.sidebar.actions.deleting":"settings.common.actions.delete"),e[123]=N,e[124]=r,e[125]=et):et=e[125];let at;e[126]!==we||e[127]!==N||e[128]!==et?(at=t.jsx(G,{size:"sm",variant:"destructive",onClick:we,disabled:N,children:et}),e[126]=we,e[127]=N,e[128]=et,e[129]=at):at=e[129];let lt;e[130]!==Xe||e[131]!==at?(lt=t.jsxs(Yt,{children:[Xe,at]}),e[130]=Xe,e[131]=at,e[132]=lt):lt=e[132];let Ze;e[133]!==O||e[134]!==lt?(Ze=t.jsxs(Bt,{className:"max-w-md",children:[O,lt]}),e[133]=O,e[134]=lt,e[135]=Ze):Ze=e[135];let We;e[136]!==Ne||e[137]!==Ee||e[138]!==Ze?(We=t.jsx(Ut,{open:Ne,onOpenChange:Ee,children:Ze}),e[136]=Ne,e[137]=Ee,e[138]=Ze,e[139]=We):We=e[139];let pt;return e[140]!==W||e[141]!==de||e[142]!==We?(pt=t.jsxs(t.Fragment,{children:[W,de,We]}),e[140]=W,e[141]=de,e[142]=We,e[143]=pt):pt=e[143],pt};function gg(s){return{entries:s.entries,files:s.files,selectedId:s.selectedId,setSelected:s.setSelected,deleteEntry:s.deleteEntry,deleteFile:s.deleteFile,loadPlugins:s.loadPlugins}}function hg(s){return s.registryInfo}function fg(s){return s.isLoadingRegistry}function xg(s){return s.loadRegistryInfo}function yg(s){return s.updateToLatest}function bg(s){return s.scope==="user"}function vg(s){return s.scope==="project"}function jg(s){return s.scope==="user"}function wg(s){return s.scope==="project"}const Rr=s=>{const e=rt.c(10),{children:n,className:a,outerClassName:r}=s;let i;e[0]!==r?(i=ce("h-full",r),e[0]=r,e[1]=i):i=e[1];let o;e[2]!==a?(o=ce("mx-auto max-w-3xl space-y-6 p-3 sm:p-6 sm:pt-8",a),e[2]=a,e[3]=o):o=e[3];let d;e[4]!==n||e[5]!==o?(d=t.jsx("div",{className:o,children:n}),e[4]=n,e[5]=o,e[6]=d):d=e[6];let c;return e[7]!==i||e[8]!==d?(c=t.jsx(Jt,{outerClassName:i,className:"w-full",children:d}),e[7]=i,e[8]=d,e[9]=c):c=e[9],c},Ng=({entryId:s,spec:e})=>{const{t:n}=dt(),a=os(p=>p.registryInfo[e]),r=os(p=>p.updateToLatest),[i,o]=l.useState(!1);if(!a)return null;if(a.kind==="npm-ok"){if(!a.hasUpdate||!a.latestVersion)return null;const p=a.latestVersion,u=a.currentVersion??"",S=async()=>{o(!0);try{(await r(s)).ok?B.success(n("settings.plugins.toast.updatedToLatest",{version:p})):B.error(n("settings.plugins.toast.refreshFailed"))}finally{o(!1)}};return t.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[t.jsx(M,{name:"arrow-up",className:"h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-success)]",children:n("settings.plugins.registry.banner.updateAvailable.title")}),t.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:n("settings.plugins.registry.banner.updateAvailable.description",{current:u,latest:p})})]}),t.jsx(G,{variant:"default",size:"sm",onClick:()=>{S()},disabled:i,children:n("settings.plugins.registry.banner.updateAvailable.action",{latest:p})})]})}if(a.kind==="path-ok")return null;if(a.kind==="npm-network")return t.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[t.jsx(M,{name:"cloud-off",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"typography-micro text-muted-foreground",children:n("settings.plugins.registry.badge.network.tooltip")})})]});const d=a.kind==="path-unreadable",c=d?"var(--status-warning)":"var(--status-error)",f=d?"alert":"error-warning",m=(()=>{switch(a.kind){case"npm-missing-version":return n("settings.plugins.registry.banner.invalid.missingVersion");case"npm-missing-package":return n("settings.plugins.registry.banner.invalid.missingPackage");case"npm-malformed":return n("settings.plugins.registry.banner.invalid.malformed");case"path-missing":return n("settings.plugins.registry.banner.invalid.pathMissing");case"path-unreadable":return n("settings.plugins.registry.banner.invalid.pathUnreadable")}})();return t.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[t.jsx(M,{name:f,className:"h-5 w-5 shrink-0 mt-0.5",style:{color:c}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"typography-label",style:{color:c},children:n("settings.plugins.registry.banner.invalid.title")}),t.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:m})]})]})};function kg(s){const e=s.trim();if(e.length===0)return{ok:!0,value:void 0};try{const n=JSON.parse(e);return n===null||typeof n!="object"||Array.isArray(n)?{ok:!1}:{ok:!0,value:n}}catch{return{ok:!1}}}function Fl(s){return!s||Object.keys(s).length===0?"":JSON.stringify(s,null,2)}function no(s){return{mode:"entry",scope:s.scope,spec:s.spec,optionsJson:Fl(s.options),fileName:"",content:""}}function ao(s,e){return{mode:"file",scope:s.scope,spec:"",optionsJson:"",fileName:s.fileName,content:e}}const ro=s=>{const e=rt.c(4),{scope:n,label:a}=s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=ce("typography-micro font-medium rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-muted-foreground","border border-[var(--interactive-border)]"),e[0]=r):r=e[0];let i;return e[1]!==a||e[2]!==n?(i=t.jsx("span",{className:r,"data-scope":n,children:a}),e[1]=a,e[2]=n,e[3]=i):i=e[3],i},Sg=()=>{const{t:s}=dt(),e=os(x=>x.selectedId),n=os(x=>x.entries),a=os(x=>x.files),r=os(x=>x.draft),i=os(x=>x.setDraft),o=os(x=>x.updateEntry),d=os(x=>x.updateFile),c=os(x=>x.readFile),f=l.useMemo(()=>e?n.find(x=>x.id===e)??null:null,[n,e]),m=l.useMemo(()=>e?a.find(x=>x.id===e)??null:null,[a,e]),[p,u]=l.useState(!1),[S,h]=l.useState(!1),g=l.useRef(new Map);if(l.useEffect(()=>{let x=!1;return f?(i(no(f)),()=>{x=!0}):m?(h(!0),(async()=>{const D=await c(m.id);if(x)return;h(!1);const N=D?.content??"";g.current.set(m.id,N),i(ao(m,N))})(),()=>{x=!0}):(i(null),()=>{x=!0})},[f,m,c,i]),!e)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(M,{name:"plug",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.plugins.page.empty.select")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.plugins.page.empty.add")})]})});if(f&&r&&r.mode==="entry"){const x=kg(r.optionsJson),D=x.ok,N=r.spec!==f.spec||r.optionsJson!==Fl(f.options),w=()=>{i(no(f))},A=async()=>{if(!D)return;const k=r.spec.trim();if(!k){B.error(s("settings.plugins.validation.specRequired"));return}u(!0);try{const j=await o(f.id,{spec:k,options:x.value});j.ok?j.reloadFailed?B.warning(j.message||s("settings.plugins.toast.reloadFailed"),{description:j.warning}):B.success(j.message||s("settings.plugins.toast.updated")):B.error(j.message||s("settings.plugins.toast.reloadFailed"))}finally{u(!1)}};return t.jsxs(Rr,{children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:s("settings.plugins.page.header.entry")}),t.jsx(ro,{scope:f.scope,label:f.scope==="project"?s("settings.plugins.sidebar.group.projectEntries"):s("settings.plugins.sidebar.group.userEntries")})]})}),t.jsx(Ng,{entryId:f.id,spec:f.spec}),t.jsxs("div",{"data-settings-item":"plugins.spec",className:"space-y-1.5",children:[t.jsx("label",{className:"typography-meta text-muted-foreground",children:s("settings.plugins.page.field.spec")}),t.jsx(it,{value:r.spec,onChange:k=>i({...r,spec:k.target.value}),placeholder:s("settings.plugins.page.field.spec.placeholder"),className:"font-mono typography-meta",spellCheck:!1})]}),t.jsxs("div",{"data-settings-item":"plugins.options",className:"space-y-1.5",children:[t.jsx("label",{className:"typography-meta text-muted-foreground",children:s("settings.plugins.page.field.options")}),t.jsx(ps,{value:r.optionsJson,onChange:k=>i({...r,optionsJson:k.target.value}),rows:10,className:ce("font-mono typography-meta min-h-[200px]",!D&&"border-[var(--status-error-border)]"),spellCheck:!1,placeholder:"{ }"}),!D&&t.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:s("settings.plugins.page.field.options.invalidJson")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"default",size:"sm",onClick:()=>{A()},disabled:!N||!D||p,children:s("settings.plugins.page.action.save")}),t.jsx(G,{variant:"outline",size:"sm",onClick:w,disabled:!N||p,children:s("settings.plugins.page.action.discard")})]})]})}if(m&&r&&r.mode==="file"){const x=g.current.get(m.id)??"",D=r.content!==x||r.fileName!==m.fileName,N=()=>{(async()=>{h(!0);const k=(await c(m.id))?.content??"";h(!1),g.current.set(m.id,k),i(ao(m,k))})()},w=async()=>{u(!0);try{const A=await d(m.id,{content:r.content});A.ok?(g.current.set(m.id,r.content),A.reloadFailed?B.warning(A.message||s("settings.plugins.toast.reloadFailed"),{description:A.warning}):B.success(A.message||s("settings.plugins.toast.updated"))):B.error(A.message||s("settings.plugins.toast.reloadFailed"))}finally{u(!1)}};return t.jsxs(Rr,{children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:s("settings.plugins.page.header.file")}),t.jsx(ro,{scope:m.scope,label:m.scope==="project"?s("settings.plugins.sidebar.group.projectFiles"):s("settings.plugins.sidebar.group.userFiles")}),t.jsx("span",{className:ce("typography-micro font-mono rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-foreground","border border-[var(--interactive-border)]"),children:m.fileName})]})}),t.jsxs("div",{"data-settings-item":"plugins.content",className:"space-y-1.5",children:[t.jsx("label",{className:"typography-meta text-muted-foreground",children:s("settings.plugins.page.field.content")}),t.jsx(ps,{value:r.content,onChange:A=>i({...r,content:A.target.value}),rows:16,className:"font-mono typography-meta min-h-[320px]",spellCheck:!1,disabled:S})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"default",size:"sm",onClick:()=>{w()},disabled:!D||p||S,children:s("settings.plugins.page.action.save")}),t.jsx(G,{variant:"outline",size:"sm",onClick:N,disabled:p||S,children:s("settings.plugins.page.action.discard")})]})]})}return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"text-center text-muted-foreground",children:t.jsx(M,{name:"loader-4",className:"mx-auto mb-3 h-6 w-6 animate-spin opacity-50"})})})},Cg="<built-in>",Nn=s=>s?.path===Cg,Pg=s=>{const e=rt.c(150),{onItemSelect:n}=s,{t:a}=dt(),[r,i]=l.useState(null),[o,d]=l.useState(""),[c,f]=l.useState(null),[m,p]=l.useState(!1),[u,S]=l.useState(null),{selectedSkillName:h,skills:g,setSelectedSkill:x,setSkillDraft:D,createSkill:N,deleteSkill:w,getSkillDetail:A}=_s(Ss(Ig));let k;e[0]!==n||e[1]!==x||e[2]!==D||e[3]!==g?(k=()=>{let pe="new-skill",st=1;for(;g.some(nt=>nt.name===pe);)pe=`new-skill-${st}`,st++;D({name:pe,scope:"user",source:"opencode",description:""}),x(pe),n?.()},e[0]=n,e[1]=x,e[2]=D,e[3]=g,e[4]=k):k=e[4];const j=k;let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=async pe=>{Nn(pe)||f(pe)},e[5]=y):y=e[5];const P=y;let z;e[6]!==c||e[7]!==w||e[8]!==a?(z=async()=>{if(!c)return;if(Nn(c)){f(null);return}p(!0),await w(c.name)?(B.success(a("settings.skills.sidebar.toast.skillDeleted",{name:c.name})),f(null)):B.error(a("settings.skills.sidebar.toast.deleteSkillFailed")),p(!1)},e[6]=c,e[7]=w,e[8]=a,e[9]=z):z=e[9];const R=z;let I;e[10]!==A||e[11]!==x||e[12]!==D||e[13]!==g||e[14]!==a?(I=async pe=>{if(Nn(pe))return;const st=pe.name;let nt=1,Ge=`${st}-copy`;for(;g.some(wt=>wt.name===Ge);)nt++,Ge=`${st}-copy-${nt}`;const ft=await A(pe.name);if(!ft){B.error(a("settings.skills.sidebar.toast.duplicateLoadFailed"));return}D({name:Ge,scope:pe.scope||"user",source:pe.source||"opencode",description:(ft.sources.md.fields.includes("description"),""),instructions:""}),x(Ge)},e[10]=A,e[11]=x,e[12]=D,e[13]=g,e[14]=a,e[15]=I):I=e[15];const v=I;let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=pe=>{Nn(pe)||(d(pe.name),i(pe))},e[16]=b):b=e[16];const L=b;let E;e[17]!==N||e[18]!==w||e[19]!==A||e[20]!==r||e[21]!==o||e[22]!==x||e[23]!==g||e[24]!==a?(E=async()=>{if(!r)return;if(Nn(r)){i(null);return}const pe=o.trim().replace(/\s+/g,"-").toLowerCase();if(!pe){B.error(a("settings.skills.page.toast.skillNameRequired"));return}if(pe===r.name){i(null);return}if(g.some(Ge=>Ge.name===pe)){B.error(a("settings.skills.page.toast.skillExists"));return}if(!await A(r.name)){B.error(a("settings.skills.sidebar.toast.renameLoadFailed")),i(null);return}await N({name:pe,description:"Renamed skill",scope:r.scope,source:r.source})?await w(r.name)?(B.success(`Skill renamed to "${pe}"`),x(pe)):B.error(a("settings.skills.sidebar.toast.removeOldAfterRenameFailed")):B.error(a("settings.skills.sidebar.toast.renameFailed")),i(null)},e[17]=N,e[18]=w,e[19]=A,e[20]=r,e[21]=o,e[22]=x,e[23]=g,e[24]=a,e[25]=E):E=e[25];const J=E;let _;e[26]!==g?(_=g.filter(Dg),e[26]=g,e[27]=_):_=e[27];const Z=_;let H;e[28]!==g?(H=g.filter(Ag),e[28]=g,e[29]=H):H=e[29];const T=H;let Y;e[30]===Symbol.for("react.memo_cache_sentinel")?(Y=function(st){const nt={},Ge=[];for(const wt of st)wt.group?(nt[wt.group]||(nt[wt.group]=[]),nt[wt.group].push(wt)):Ge.push(wt);const ft=Object.keys(nt).sort(Eg).map(wt=>({name:wt,skills:[...nt[wt]].sort(Mg)}));return Ge.sort(Rg),{sortedGroups:ft,ungrouped:Ge}},e[30]=Y):Y=e[30];const F=Y;let V;e[31]!==Z?(V=F(Z),e[31]=Z,e[32]=V):V=e[32];const Q=V;let ie;e[33]!==T?(ie=F(T),e[33]=T,e[34]=ie):ie=e[34];const X=ie;let se;e[35]===Symbol.for("react.memo_cache_sentinel")?(se=ce("flex h-full flex-col","bg-background"),e[35]=se):se=e[35];let me;e[36]!==a?(me=a("settings.skills.sidebar.title"),e[36]=a,e[37]=me):me=e[37];let oe;e[38]!==me?(oe=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:me}),e[38]=me,e[39]=oe):oe=e[39];let xe;e[40]===Symbol.for("react.memo_cache_sentinel")?(xe=t.jsx(ta,{className:"mb-3"}),e[40]=xe):xe=e[40];let we;e[41]!==g.length||e[42]!==a?(we=a("settings.skills.sidebar.total",{count:g.length}),e[41]=g.length,e[42]=a,e[43]=we):we=e[43];let he;e[44]!==we?(he=t.jsx("span",{className:"typography-meta text-muted-foreground",children:we}),e[44]=we,e[45]=he):he=e[45];let Ie;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ie=t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),e[46]=Ie):Ie=e[46];let ve;e[47]!==j?(ve=t.jsx(G,{size:"sm","data-settings-item":"skills.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:j,children:Ie}),e[47]=j,e[48]=ve):ve=e[48];let ye;e[49]!==he||e[50]!==ve?(ye=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[he,ve]}),e[49]=he,e[50]=ve,e[51]=ye):ye=e[51];let be;e[52]!==oe||e[53]!==ye?(be=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[oe,xe,ye]}),e[52]=oe,e[53]=ye,e[54]=be):be=e[54];let te;e[55]!==Q||e[56]!==X||e[57]!==v||e[58]!==n||e[59]!==u||e[60]!==Z||e[61]!==h||e[62]!==x||e[63]!==g.length||e[64]!==a||e[65]!==T?(te=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:g.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(M,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:a("settings.skills.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.skills.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.skills.sidebar.section.project")}),Q.sortedGroups.map(pe=>{const{name:st,skills:nt}=pe;return t.jsx(Ar,{label:st,count:nt.length,storageKey:"project-skills",children:nt.map(Ge=>t.jsx(ga,{skill:Ge,isSelected:h===Ge.name,onSelect:()=>{x(Ge.name),n?.()},onRename:()=>L(Ge),onDelete:()=>P(Ge),onDuplicate:()=>v(Ge),isMenuOpen:u===Ge.name,onMenuOpenChange:ft=>S(ft?Ge.name:null)},Ge.name))},st)}),Q.ungrouped.map(pe=>t.jsx(ga,{skill:pe,isSelected:h===pe.name,onSelect:()=>{x(pe.name),n?.()},onRename:()=>L(pe),onDelete:()=>P(pe),onDuplicate:()=>v(pe),isMenuOpen:u===pe.name,onMenuOpenChange:st=>S(st?pe.name:null)},pe.name))]}),T.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.skills.sidebar.section.user")}),X.sortedGroups.map(pe=>{const{name:st,skills:nt}=pe;return t.jsx(Ar,{label:st,count:nt.length,storageKey:"user-skills",children:nt.map(Ge=>t.jsx(ga,{skill:Ge,isSelected:h===Ge.name,onSelect:()=>{x(Ge.name),n?.()},onRename:()=>L(Ge),onDelete:()=>P(Ge),onDuplicate:()=>v(Ge),isMenuOpen:u===Ge.name,onMenuOpenChange:ft=>S(ft?Ge.name:null)},Ge.name))},st)}),X.ungrouped.map(pe=>t.jsx(ga,{skill:pe,isSelected:h===pe.name,onSelect:()=>{x(pe.name),n?.()},onRename:()=>L(pe),onDelete:()=>P(pe),onDuplicate:()=>v(pe),isMenuOpen:u===pe.name,onMenuOpenChange:st=>S(st?pe.name:null)},pe.name))]})]})}),e[55]=Q,e[56]=X,e[57]=v,e[58]=n,e[59]=u,e[60]=Z,e[61]=h,e[62]=x,e[63]=g.length,e[64]=a,e[65]=T,e[66]=te):te=e[66];const re=c!==null;let ge;e[67]!==m?(ge=pe=>{!pe&&!m&&f(null)},e[67]=m,e[68]=ge):ge=e[68];let U;e[69]!==a?(U=a("settings.skills.sidebar.deleteDialog.title"),e[69]=a,e[70]=U):U=e[70];let ee;e[71]!==U?(ee=t.jsx(Vt,{children:U}),e[71]=U,e[72]=ee):ee=e[72];const ne=c?.name??"";let ue;e[73]!==a||e[74]!==ne?(ue=a("settings.skills.sidebar.deleteDialog.description",{name:ne}),e[73]=a,e[74]=ne,e[75]=ue):ue=e[75];let Me;e[76]!==ue?(Me=t.jsx(qt,{children:ue}),e[76]=ue,e[77]=Me):Me=e[77];let ke;e[78]!==ee||e[79]!==Me?(ke=t.jsxs(_t,{children:[ee,Me]}),e[78]=ee,e[79]=Me,e[80]=ke):ke=e[80];let De;e[81]===Symbol.for("react.memo_cache_sentinel")?(De=()=>f(null),e[81]=De):De=e[81];let Ae;e[82]!==a?(Ae=a("settings.common.actions.cancel"),e[82]=a,e[83]=Ae):Ae=e[83];let Pe;e[84]!==m||e[85]!==Ae?(Pe=t.jsx(G,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:De,disabled:m,children:Ae}),e[84]=m,e[85]=Ae,e[86]=Pe):Pe=e[86];let Re;e[87]!==a?(Re=a("settings.common.actions.delete"),e[87]=a,e[88]=Re):Re=e[88];let Le;e[89]!==R||e[90]!==m||e[91]!==Re?(Le=t.jsx(G,{size:"sm",onClick:R,disabled:m,children:Re}),e[89]=R,e[90]=m,e[91]=Re,e[92]=Le):Le=e[92];let $e;e[93]!==Pe||e[94]!==Le?($e=t.jsxs(Yt,{children:[Pe,Le]}),e[93]=Pe,e[94]=Le,e[95]=$e):$e=e[95];let Be;e[96]!==ke||e[97]!==$e?(Be=t.jsxs(Bt,{className:"max-w-md",children:[ke,$e]}),e[96]=ke,e[97]=$e,e[98]=Be):Be=e[98];let Oe;e[99]!==re||e[100]!==ge||e[101]!==Be?(Oe=t.jsx(Ut,{open:re,onOpenChange:ge,children:Be}),e[99]=re,e[100]=ge,e[101]=Be,e[102]=Oe):Oe=e[102];const Ue=r!==null;let le;e[103]===Symbol.for("react.memo_cache_sentinel")?(le=pe=>!pe&&i(null),e[103]=le):le=e[103];let W;e[104]!==a?(W=a("settings.skills.sidebar.renameDialog.title"),e[104]=a,e[105]=W):W=e[105];let de;e[106]!==W?(de=t.jsx(Vt,{children:W}),e[106]=W,e[107]=de):de=e[107];const Ne=r?.name??"";let Ee;e[108]!==a||e[109]!==Ne?(Ee=a("settings.skills.sidebar.renameDialog.description",{name:Ne}),e[108]=a,e[109]=Ne,e[110]=Ee):Ee=e[110];let Ce;e[111]!==Ee?(Ce=t.jsx(qt,{children:Ee}),e[111]=Ee,e[112]=Ce):Ce=e[112];let He;e[113]!==de||e[114]!==Ce?(He=t.jsxs(_t,{children:[de,Ce]}),e[113]=de,e[114]=Ce,e[115]=He):He=e[115];let q;e[116]===Symbol.for("react.memo_cache_sentinel")?(q=pe=>d(pe.target.value),e[116]=q):q=e[116];let $;e[117]!==a?($=a("settings.skills.sidebar.renameDialog.placeholder"),e[117]=a,e[118]=$):$=e[118];let fe;e[119]!==J?(fe=pe=>{pe.key==="Enter"&&J()},e[119]=J,e[120]=fe):fe=e[120];let O;e[121]!==o||e[122]!==$||e[123]!==fe?(O=t.jsx(it,{value:o,onChange:q,placeholder:$,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:fe}),e[121]=o,e[122]=$,e[123]=fe,e[124]=O):O=e[124];let Fe;e[125]===Symbol.for("react.memo_cache_sentinel")?(Fe=()=>i(null),e[125]=Fe):Fe=e[125];let Je;e[126]!==a?(Je=a("settings.common.actions.cancel"),e[126]=a,e[127]=Je):Je=e[127];let Xe;e[128]!==Je?(Xe=t.jsx(G,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:Fe,children:Je}),e[128]=Je,e[129]=Xe):Xe=e[129];let et;e[130]!==a?(et=a("settings.common.actions.rename"),e[130]=a,e[131]=et):et=e[131];let at;e[132]!==J||e[133]!==et?(at=t.jsx(G,{size:"sm",onClick:J,children:et}),e[132]=J,e[133]=et,e[134]=at):at=e[134];let lt;e[135]!==Xe||e[136]!==at?(lt=t.jsxs(Yt,{children:[Xe,at]}),e[135]=Xe,e[136]=at,e[137]=lt):lt=e[137];let Ze;e[138]!==He||e[139]!==O||e[140]!==lt?(Ze=t.jsxs(Bt,{children:[He,O,lt]}),e[138]=He,e[139]=O,e[140]=lt,e[141]=Ze):Ze=e[141];let We;e[142]!==Ue||e[143]!==Ze?(We=t.jsx(Ut,{open:Ue,onOpenChange:le,children:Ze}),e[142]=Ue,e[143]=Ze,e[144]=We):We=e[144];let pt;return e[145]!==be||e[146]!==te||e[147]!==Oe||e[148]!==We?(pt=t.jsxs("div",{className:se,children:[be,te,Oe,We]}),e[145]=be,e[146]=te,e[147]=Oe,e[148]=We,e[149]=pt):pt=e[149],pt},ga=s=>{const e=rt.c(49),{skill:n,isSelected:a,onSelect:r,onDelete:i,onRename:o,onDuplicate:d,isMenuOpen:c,onMenuOpenChange:f}=s,{t:m}=dt();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=Qn(),e[0]=p):p=e[0];const u=p;let S;e[1]!==n.source||e[2]!==m?(S=n.source==="claude"?m("settings.skills.sidebar.badge.claude"):n.source==="agents"?m("settings.skills.sidebar.badge.agents"):m("settings.skills.sidebar.badge.opencode"),e[1]=n.source,e[2]=m,e[3]=S):S=e[3];const h=S;let g;e[4]!==n?(g=Nn(n),e[4]=n,e[5]=g):g=e[5];const x=g,[D,N]=l.useState(!1);let w;e[6]!==i||e[7]!==d||e[8]!==o||e[9]!==m?(w=T=>t.jsxs(t.Fragment,{children:[t.jsxs(T,{onClick:Y=>{Y.stopPropagation(),o()},children:[t.jsx(M,{name:"edit",className:"h-4 w-4 mr-px"}),m("settings.common.actions.rename")]}),t.jsxs(T,{onClick:Y=>{Y.stopPropagation(),d()},children:[t.jsx(M,{name:"file-copy",className:"h-4 w-4 mr-px"}),m("settings.common.actions.duplicate")]}),t.jsxs(T,{onClick:Y=>{Y.stopPropagation(),i()},className:"text-destructive focus:text-destructive",children:[t.jsx(M,{name:"delete-bin",className:"h-4 w-4 mr-px"}),m("settings.common.actions.delete")]})]}),e[6]=i,e[7]=d,e[8]=o,e[9]=m,e[10]=w):w=e[10];const A=w,k=!x&&D,j=a?"bg-interactive-selection":"hover:bg-interactive-hover";let y;e[11]!==j?(y=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",j),e[11]=j,e[12]=y):y=e[12];let P;e[13]!==x?(P=!u&&!x?T=>{T.preventDefault(),N(!0)}:void 0,e[13]=x,e[14]=P):P=e[14];let z;e[15]!==y||e[16]!==P?(z=t.jsx("div",{className:y,onContextMenu:P}),e[15]=y,e[16]=P,e[17]=z):z=e[17];let R;e[18]!==n.name?(R=t.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[18]=n.name,e[19]=R):R=e[19];let I;e[20]!==n.scope?(I=t.jsx("span",{className:"typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50",children:n.scope}),e[20]=n.scope,e[21]=I):I=e[21];let v;e[22]!==h?(v=t.jsx("span",{className:"typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50",children:h}),e[22]=h,e[23]=v):v=e[23];let b;e[24]!==R||e[25]!==I||e[26]!==v?(b=t.jsxs("div",{className:"flex items-center gap-1.5",children:[R,I,v]}),e[24]=R,e[25]=I,e[26]=v,e[27]=b):b=e[27];let L;e[28]!==r||e[29]!==b?(L=t.jsx("button",{onClick:r,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:b}),e[28]=r,e[29]=b,e[30]=L):L=e[30];let E;e[31]!==x||e[32]!==c||e[33]!==f||e[34]!==A?(E=x?null:t.jsxs(us,{open:c,onOpenChange:T=>{T&&N(!1),f(T)},children:[t.jsx(ds,{asChild:!0,children:t.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:t.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ms,{align:"end",className:"w-fit min-w-20",children:A(js)})]}),e[31]=x,e[32]=c,e[33]=f,e[34]=A,e[35]=E):E=e[35];let J;e[36]!==L||e[37]!==E?(J=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[L,E]}),e[36]=L,e[37]=E,e[38]=J):J=e[38];let _;e[39]!==J||e[40]!==z?(_=t.jsx(sn,{render:z,children:J}),e[39]=J,e[40]=z,e[41]=_):_=e[41];let Z;e[42]!==x||e[43]!==A?(Z=x?null:t.jsx(nn,{className:"w-fit min-w-20",children:A(Ws)}),e[42]=x,e[43]=A,e[44]=Z):Z=e[44];let H;return e[45]!==_||e[46]!==Z||e[47]!==k?(H=t.jsxs(tn,{open:k,onOpenChange:N,children:[_,Z]}),e[45]=_,e[46]=Z,e[47]=k,e[48]=H):H=e[48],H};function Ig(s){return{selectedSkillName:s.selectedSkillName,skills:s.skills,setSelectedSkill:s.setSelectedSkill,setSkillDraft:s.setSkillDraft,createSkill:s.createSkill,deleteSkill:s.deleteSkill,getSkillDetail:s.getSkillDetail}}function Dg(s){return s.scope==="project"}function Ag(s){return s.scope==="user"}function Eg(s,e){return s.localeCompare(e)}function Mg(s,e){return s.name.localeCompare(e.name)}function Rg(s,e){return s.name.localeCompare(e.name)}const Tg=s=>s!==null&&typeof s=="object"&&"updateStatus"in s&&typeof s.updateStatus=="function",Fg=s=>{const e=document.createElement("div");e.className="cm-vim-panel";const n=$c(s);if(!n)return{top:!1,dom:e};n.state.statusbar=e;const a=n.state.vimPlugin;return Tg(a)&&a.updateStatus(),{top:!1,dom:e,destroy(){n.state.statusbar===e&&(n.state.statusbar=null)}}};function io(s){return s?[Oc(),zc.of(Fg),Kc()]:[]}const Lg={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},Og={case:"Match case",re:"Regular expression",word:"Match whole word"};function zg(s){const e=s.querySelector(".cm-search");if(e){for(const[n,a]of Object.entries(Lg)){const r=e.querySelector(`button[name="${n}"]`);r&&!r.title&&(r.title=a)}for(const[n,a]of Object.entries(Og)){const i=e.querySelector(`input[name="${n}"]`)?.parentElement;i&&!i.title&&(i.title=a)}}}const ir=new WeakMap;function Kg(s,e){const n=Ma(s.state);if(!n.valid)return ir.delete(s),0;const a=ir.get(s);if(!e&&a?.doc===s.state.doc&&a.query.eq(n))return a.total;const r=n.getCursor(s.state);let i=0;for(let o=r.next();!o.done;o=r.next())i+=1;return ir.set(s,{query:n,doc:s.state.doc,total:i}),i}function $g(s){const e=Ma(s.state);if(!e.valid)return 0;const n=s.state.selection.main,a=e.getCursor(s.state);let r=0,i=0;for(let o=a.next();!o.done;o=a.next()){const d=o.value;if(r+=1,i===0&&(i=r),n.from===d.from&&n.to===d.to||n.from<d.to&&n.to>d.from||d.from>=n.head)return r}return i}function oo(s,e,n=!1){const a=s.querySelector(".cm-search");if(!a)return;let r=a.querySelector(".cm-search-message");if(!r){r=document.createElement("span"),r.className="cm-search-message",r.setAttribute("aria-live","polite");const d=a.querySelector('button[name="next"]'),c=d?.parentNode===a?d:a.firstChild;a.insertBefore(r,c)}const i=Kg(e,n),o=i===0?0:$g(e);r.textContent=i===0?"":`${o}/${i}`}const lo=new yn,co=new yn,mo=new yn,uo=new yn,po=new yn,go=new yn,ho=new yn,fo=s=>s,or=Gc,Ug=Jc,Bg=Qc;class Vg extends Yc{constructor(e,n){super(),this.id=e,this.containerMap=n}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement("div"),e.className="oc-block-widget",e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}}const xo=(s,e)=>!s||s.length===0?[]:ul.define({create(n){const a=new Br,r=[...s].sort((i,o)=>i.afterLine-o.afterLine);for(const i of r){const o=n.doc.lines;if(i.afterLine>o)continue;const d=n.doc.line(i.afterLine);a.add(d.to,d.to,Oa.widget({widget:new Vg(i.id,e),block:!0,side:1}))}return a.finish()},update(n,a){return n.map(a.changes)},provide:n=>Rs.decorations.from(n)}),yo=s=>{if(!s)return[];const e=Math.max(1,s.start),n=Math.max(e,s.end);return ml.fromClass(class{decorations;constructor(a){this.decorations=this.build(a)}update(a){(a.docChanged||a.viewportChanged)&&(this.decorations=this.build(a.view))}build(a){const r=new Br;for(let i=e;i<=n&&i<=a.state.doc.lines;i+=1){const o=a.state.doc.line(i);r.add(o.from,o.from,Oa.line({class:"oc-cm-selected-line"}))}return r.finish()}},{decorations:a=>a.decorations})};function bo({value:s,onChange:e,extensions:n,className:a,readOnly:r,lineNumbersConfig:i,highlightLines:o,onViewReady:d,onViewDestroy:c,blockWidgets:f,enableSearch:m,searchOpen:p,onSearchOpenChange:u,vimMode:S}){const h=l.useRef(null),g=l.useRef(null),x=l.useRef(s),D=l.useRef(e),N=l.useRef(d),w=l.useRef(c),A=l.useRef(u),k=l.useRef(f),j=l.useRef(S),y=l.useRef(new Map),[P,z]=l.useState([]),R=l.useCallback(v=>{const b=(v??[]).map(L=>{const E=y.current.get(L.id);return E?{id:L.id,content:L.content,container:E}:null}).filter(L=>L!==null);z(L=>L.length===b.length&&L.every((E,J)=>{const _=b[J];return E.id===_.id&&E.content===_.content&&E.container===_.container})?L:b)},[]),I=l.useCallback(v=>{const b=h.current,L=v??g.current;if(!b||!L)return;const E=L.dom.querySelector(".cm-gutters"),J=E instanceof HTMLElement?E.getBoundingClientRect().width:0;b.style.setProperty("--oc-editor-gutter-width",`${J}px`)},[]);return l.useEffect(()=>{x.current=s},[s]),l.useEffect(()=>{D.current=e},[e]),l.useEffect(()=>{N.current=d,w.current=c},[d,c]),l.useEffect(()=>{A.current=u},[u]),l.useEffect(()=>{k.current=f,R(f)},[f,R]),l.useEffect(()=>{if(!h.current)return;const v=(()=>{if(typeof document>"u")return null;const L=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(L)return L;const E=window.__OPENCHAMBER_CSP_NONCE__;return typeof E=="string"&&E.length>0?E:null})(),b=Uc.create({doc:x.current,extensions:[...v?[Rs.cspNonce.of(v)]:[],Bc({fixed:!0}),lo.of(Zr(i)),Vc(),_c.of(" "),ho.of(io(S)),Ha.of([Hc,...Wc,...qc]),Rs.updateListener.of(L=>{I(L.view),(L.viewportChanged||L.geometryChanged)&&R(k.current);const E=ei(L.startState),J=ei(L.state);E!==J&&A.current?.(J);const _=!Ma(L.startState).eq(Ma(L.state));if(J&&(E!==J||_||L.docChanged||L.selectionSet)&&oo(L.view.dom,L.view,E!==J||_||L.docChanged),!L.docChanged)return;const Z=L.state.doc.toString();x.current=Z,D.current(Z),R(k.current)}),co.of(Rs.editable.of(!r)),mo.of(n??[]),uo.of(yo(o)),po.of(xo(f,y.current)),go.of(m?[ti({top:!0}),Ha.of(fo(si))]:[])]});return g.current=new Rs({state:b,parent:h.current}),or(g.current,g.current.state.doc.length,200),g.current.requestMeasure(),requestAnimationFrame(()=>{I(g.current),R(k.current)}),g.current&&N.current?.(g.current),()=>{w.current?.(),g.current?.destroy(),g.current=null,z([])}},[k,I,R]),l.useEffect(()=>{const v=g.current;v&&(v.dispatch({effects:[lo.reconfigure(Zr(i)),co.reconfigure(Rs.editable.of(!r)),mo.reconfigure(n??[]),uo.reconfigure(yo(o)),po.reconfigure(xo(f,y.current)),go.reconfigure(m?[ti({top:!0}),Ha.of(fo(si))]:[])]}),or(v,v.state.doc.length,200),v.requestMeasure(),requestAnimationFrame(()=>{I(v),R(k.current)}))},[n,o,i,r,f,m,I,R]),l.useEffect(()=>{const v=g.current;if(!v){j.current=S;return}j.current!==S&&(j.current=S,v.dispatch({effects:ho.reconfigure(io(S))}))},[S]),l.useEffect(()=>{const v=g.current;!v||m===!1||(p?(Ug(v),requestAnimationFrame(()=>{zg(v.dom),oo(v.dom,v,!0)})):Bg(v))},[p,m]),l.useEffect(()=>{const v=g.current;if(!v)return;const b=v.state.doc.toString();b!==s&&(v.dispatch({changes:{from:0,to:b.length,insert:s}}),or(v,v.state.doc.length,300),v.requestMeasure(),requestAnimationFrame(()=>I(v)))},[s,I]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:h,className:ce("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",a)}),P.map(v=>wa.createPortal(v.content,v.container,v.id))]})}const _g=s=>{const e=rt.c(11),{currentMode:n,onToggle:a}=s,r=n==="preview",i=r?"Switch to edit mode":"Switch to preview mode",o=r?"Edit":"Preview";let d;e[0]!==r?(d=r?t.jsx(M,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(M,{name:"eye-off",className:"size-4","aria-hidden":"true"}),e[0]=r,e[1]=d):d=e[1];let c;e[2]!==i||e[3]!==a||e[4]!==d?(c=t.jsx(At,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",onClick:a,"aria-label":i,className:"h-5 w-5 p-0",children:d})}),e[2]=i,e[3]=a,e[4]=d,e[5]=c):c=e[5];let f;e[6]!==o?(f=t.jsx(Et,{sideOffset:8,children:o}),e[6]=o,e[7]=f):f=e[7];let m;return e[8]!==c||e[9]!==f?(m=t.jsxs(Dt,{children:[c,f]}),e[8]=c,e[9]=f,e[10]=m):m=e[10],m},ks=rn()(Zn($r((s,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:n=>{s({selectedProfileId:n})},loadProfiles:async()=>{s({isLoading:!0});const n=e().profiles;try{const a=await Ad();return s({profiles:a,isLoading:!1}),!0}catch(a){return console.error("Failed to load git identity profiles:",a),s({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{const n=await Dd();if(n&&n.userName&&n.userEmail){const a={id:"global",name:"Global Identity",userName:n.userName,userEmail:n.userEmail,authType:n.sshCommand?"ssh":void 0,sshKey:n.sshCommand?n.sshCommand.replace("ssh -i ",""):null,color:"info",icon:"house"};s({globalIdentity:a})}else s({globalIdentity:null});return!0}catch(n){return console.error("Failed to load global git identity:",n),s({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{const n=await Id();return s({discoveredCredentials:n}),!0}catch(n){return console.error("Failed to discover git credentials:",n),s({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{const n=a=>{if(typeof a!="string")return null;const r=a.trim();return r.length>0?r:null};try{let a=null;if(a===null){const r=Fs()?.settings;if(r)try{const o=(await r.load())?.settings||{};a=n(o.defaultGitIdentityId)}catch{}}if(a===null)try{const r=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(r.ok){const i=await r.json().catch(()=>null);a=n(i?.defaultGitIdentityId)}}catch{}return s({defaultGitIdentityId:a}),!0}catch(a){return console.error("Failed to load default git identity setting:",a),!1}},setDefaultGitIdentityId:async n=>{try{const a=typeof n=="string"?n.trim():"",r=a.length>0?a:"";return await Pt({defaultGitIdentityId:r}),s({defaultGitIdentityId:r.length>0?r:null}),!0}catch(a){return console.error("Failed to save default git identity setting:",a),!1}},createProfile:async n=>{try{const a={...n,id:n.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:n.color||"keyword",icon:n.icon||"branch"};return await Pd(a),await e().loadProfiles(),!0}catch(a){return console.error("Failed to create git identity profile:",a),!1}},updateProfile:async(n,a)=>{try{const r=e().profiles.find(o=>o.id===n);if(!r)throw new Error("Profile not found");const i={...r,...a};return await Cd(n,i),await e().loadProfiles(),!0}catch(r){return console.error("Failed to update git identity profile:",r),!1}},deleteProfile:async n=>{try{return await Sd(n),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(a){return console.error("Failed to delete git identity profile:",a),!1}},getProfileById:n=>{const{profiles:a,globalIdentity:r}=e();return n==="global"?r||void 0:a.find(i=>i.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:a}=e();return a.filter(r=>!n.some(i=>i.authType==="token"&&i.host===r.host))}}),{name:"git-identities-store",storage:Ur(()=>Yn()),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=ks);const Hg=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,Wg=s=>{const e=s.trim(),n=e.startsWith("https://")?"https":e.startsWith("git@")?"ssh":"shorthand";if(n==="ssh")return`${e.split(":")[1].replace(/\.git$/i,"")}`;if(n==="https")return e.split("/").slice(3).filter(Boolean).join("/").replace(/\.git$/i,"");const a=e.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return a?`${a[1]}/${a[2].replace(/\.git$/i,"")}`:e},qg=async()=>{try{const s=Fs()?.settings;if(s)return(await s.load())?.settings||{};const e=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});return e.ok?await e.json().catch(()=>null):null}catch{return null}},Gg=s=>{const e=rt.c(160),{open:n,onOpenChange:a}=s,{t:r}=dt(),i=Bs(Jg),o=Bs(Qg),d=Bs(Yg),c=Bs(Xg),f=Bs(Zg),m=ks(eh),p=ks(th),[u,S]=l.useState(""),[h,g]=l.useState(""),[x,D]=l.useState("");let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0];const[w,A]=l.useState(N),[k,j]=l.useState(null),[y,P]=l.useState(!1);let z;e[1]===Symbol.for("react.memo_cache_sentinel")?(z=[],e[1]=z):z=e[1];const[R,I]=l.useState(z),[v,b]=l.useState(null),L=l.useRef(0);let E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=pe=>{L.current=L.current+1,P(!1),j(null),pe?.clearIdentity&&(I([]),b(null))},e[2]=E):E=e[2];const J=E;let _,Z;e[3]!==p||e[4]!==n?(_=()=>{n&&(L.current=L.current+1,S(""),g(""),D(""),j(null),P(!1),I([]),b(null),p(),(async()=>{const pe=await qg(),st=Array.isArray(pe?.skillCatalogs)?pe?.skillCatalogs:[];A(st||[])})())},Z=[n,p],e[3]=p,e[4]=n,e[5]=_,e[6]=Z):(_=e[5],Z=e[6]),l.useEffect(_,Z);let H;e[7]!==h?(H=h.trim(),e[7]=h,e[8]=H):H=e[8];const T=H;let Y;e[9]!==x?(Y=x.trim(),e[9]=x,e[10]=Y):Y=e[10];const F=Y;let V;if(e[11]!==w||e[12]!==T||e[13]!==F){let pe;e[15]!==T||e[16]!==F?(pe=st=>{const nt=(st.source||"").trim(),Ge=(st.subpath||"").trim();return nt===T&&Ge===F},e[15]=T,e[16]=F,e[17]=pe):pe=e[17],V=w.some(pe),e[11]=w,e[12]=T,e[13]=F,e[14]=V}else V=e[14];const Q=V;let ie;e[18]!==m||e[19]!==v||e[20]!==u||e[21]!==i||e[22]!==h||e[23]!==x||e[24]!==r?(ie=async()=>{const pe=h.trim();if(!pe){B.error(r("settings.skills.catalog.add.toast.repositoryRequired"));return}u.trim()||S(Wg(pe)),P(!1),j(null);const st=L.current+1;L.current=st;const nt=await i({source:pe,subpath:x.trim()||void 0,gitIdentityId:v||void 0});if(L.current!==st)return;if(!nt.ok){if(nt.error?.kind==="authRequired"){if(gs()){B.error(r("settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode"));return}const ft=nt.error.identities||[];if(I(ft),!v&&ft.length>0){const wt=m&&m!=="global"&&ft.some(Ct=>Ct.id===m)?m:ft[0].id;b(wt)}B.error(r("settings.skills.catalog.add.toast.authenticationRequiredScan"));return}B.error(nt.error?.message||r("settings.skills.catalog.add.toast.scanFailed"));return}const Ge=nt.items?.length||0;if(j(Ge),Ge===0){B.error(r("settings.skills.catalog.add.toast.noSkillsFound")),P(!1);return}I([]),P(!0),B.success(r("settings.skills.catalog.shared.toast.foundSkills",{count:Ge}))},e[18]=m,e[19]=v,e[20]=u,e[21]=i,e[22]=h,e[23]=x,e[24]=r,e[25]=ie):ie=e[25];const X=ie;let se;e[26]!==w||e[27]!==v||e[28]!==Q||e[29]!==u||e[30]!==o||e[31]!==d||e[32]!==a||e[33]!==y||e[34]!==c||e[35]!==h||e[36]!==x||e[37]!==r?(se=async()=>{const pe=u.trim(),st=h.trim(),nt=x.trim();if(!pe){B.error(r("settings.skills.catalog.add.toast.catalogNameRequired"));return}if(!st){B.error(r("settings.skills.catalog.add.toast.repositoryRequired"));return}if(!y){B.error(r("settings.skills.catalog.add.toast.scanBeforeAdd"));return}if(Q){B.error(r("settings.skills.catalog.add.toast.catalogAlreadyExists"));return}const Ge={id:Hg(),label:pe,source:st,...nt?{subpath:nt}:{},...v?{gitIdentityId:v}:{}},ft=[...w,Ge];try{await Pt({skillCatalogs:ft}),A(ft),B.success(r("settings.skills.catalog.add.toast.catalogAdded")),await o({refresh:!0}),await d(Ge.id,{refresh:!0}),c(Ge.id),a(!1)}catch(wt){const Ct=wt;B.error(Ct instanceof Error?Ct.message:r("settings.skills.catalog.add.toast.saveFailed"))}},e[26]=w,e[27]=v,e[28]=Q,e[29]=u,e[30]=o,e[31]=d,e[32]=a,e[33]=y,e[34]=c,e[35]=h,e[36]=x,e[37]=r,e[38]=se):se=e[38];const me=se;let oe;e[39]!==r?(oe=r("settings.skills.catalog.add.title"),e[39]=r,e[40]=oe):oe=e[40];let xe;e[41]!==oe?(xe=t.jsx(Vt,{children:oe}),e[41]=oe,e[42]=xe):xe=e[42];let we;e[43]!==r?(we=r("settings.skills.catalog.add.descriptionPrefix"),e[43]=r,e[44]=we):we=e[44];let he;e[45]===Symbol.for("react.memo_cache_sentinel")?(he=t.jsx("code",{className:"font-mono",children:"SKILL.md"}),e[45]=he):he=e[45];let Ie;e[46]!==r?(Ie=r("settings.skills.catalog.add.descriptionSuffix"),e[46]=r,e[47]=Ie):Ie=e[47];let ve;e[48]!==we||e[49]!==Ie?(ve=t.jsxs(qt,{children:[we," ",he,Ie]}),e[48]=we,e[49]=Ie,e[50]=ve):ve=e[50];let ye;e[51]!==xe||e[52]!==ve?(ye=t.jsxs(_t,{children:[xe,ve]}),e[51]=xe,e[52]=ve,e[53]=ye):ye=e[53];let be;e[54]!==r?(be=r("settings.skills.catalog.add.field.catalogName"),e[54]=r,e[55]=be):be=e[55];let te;e[56]!==be?(te=t.jsx("label",{className:"typography-ui-label text-foreground",children:be}),e[56]=be,e[57]=te):te=e[57];let re;e[58]===Symbol.for("react.memo_cache_sentinel")?(re=pe=>S(pe.target.value),e[58]=re):re=e[58];let ge;e[59]!==r?(ge=r("settings.skills.catalog.add.field.catalogNamePlaceholder"),e[59]=r,e[60]=ge):ge=e[60];let U;e[61]!==u||e[62]!==ge?(U=t.jsx(it,{value:u,onChange:re,placeholder:ge}),e[61]=u,e[62]=ge,e[63]=U):U=e[63];let ee;e[64]!==te||e[65]!==U?(ee=t.jsxs("div",{className:"space-y-2",children:[te,U]}),e[64]=te,e[65]=U,e[66]=ee):ee=e[66];let ne;e[67]!==r?(ne=r("settings.skills.catalog.add.field.repository"),e[67]=r,e[68]=ne):ne=e[68];let ue;e[69]!==ne?(ue=t.jsx("label",{className:"typography-ui-label text-foreground",children:ne}),e[69]=ne,e[70]=ue):ue=e[70];let Me;e[71]===Symbol.for("react.memo_cache_sentinel")?(Me=pe=>{g(pe.target.value),J({clearIdentity:!0})},e[71]=Me):Me=e[71];let ke;e[72]!==r?(ke=r("settings.skills.catalog.shared.field.repositoryPlaceholder"),e[72]=r,e[73]=ke):ke=e[73];let De;e[74]!==h||e[75]!==ke?(De=t.jsx(it,{value:h,onChange:Me,placeholder:ke}),e[74]=h,e[75]=ke,e[76]=De):De=e[76];let Ae;e[77]!==r?(Ae=r("settings.skills.catalog.add.field.repositoryHint"),e[77]=r,e[78]=Ae):Ae=e[78];let Pe;e[79]!==Ae?(Pe=t.jsx("p",{className:"typography-micro text-muted-foreground",children:Ae}),e[79]=Ae,e[80]=Pe):Pe=e[80];let Re;e[81]!==ue||e[82]!==De||e[83]!==Pe?(Re=t.jsxs("div",{className:"space-y-2",children:[ue,De,Pe]}),e[81]=ue,e[82]=De,e[83]=Pe,e[84]=Re):Re=e[84];let Le;e[85]!==r?(Le=r("settings.skills.catalog.add.field.optionalSubpath"),e[85]=r,e[86]=Le):Le=e[86];let $e;e[87]!==Le?($e=t.jsx("label",{className:"typography-ui-label text-foreground",children:Le}),e[87]=Le,e[88]=$e):$e=e[88];let Be;e[89]===Symbol.for("react.memo_cache_sentinel")?(Be=pe=>{D(pe.target.value),J({clearIdentity:!0})},e[89]=Be):Be=e[89];let Oe;e[90]!==r?(Oe=r("settings.skills.catalog.shared.field.subpathPlaceholder"),e[90]=r,e[91]=Oe):Oe=e[91];let Ue;e[92]!==x||e[93]!==Oe?(Ue=t.jsx(it,{value:x,onChange:Be,placeholder:Oe}),e[92]=x,e[93]=Oe,e[94]=Ue):Ue=e[94];let le;e[95]!==$e||e[96]!==Ue?(le=t.jsxs("div",{className:"space-y-2",children:[$e,Ue]}),e[95]=$e,e[96]=Ue,e[97]=le):le=e[97];let W;e[98]!==v||e[99]!==R||e[100]!==r?(W=R.length>0&&!gs()?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-[var(--status-warning)]",children:r("settings.skills.catalog.shared.auth.title")}),t.jsx("span",{className:"typography-meta text-muted-foreground ml-2",children:r("settings.skills.catalog.shared.auth.description")})]}),t.jsxs(Ft,{value:v||"",onValueChange:pe=>{b(pe),J()},children:[t.jsx(Lt,{className:"w-fit",children:t.jsx("span",{children:R.find(pe=>pe.id===v)?.name||r("settings.skills.catalog.shared.auth.chooseIdentity")})}),t.jsx(Ot,{align:"start",children:R.map(sh)})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:r("settings.skills.catalog.shared.auth.footerHint")})]}):null,e[98]=v,e[99]=R,e[100]=r,e[101]=W):W=e[101];let de;e[102]!==k||e[103]!==r?(de=k!==null?t.jsx("div",{className:"typography-meta text-muted-foreground",children:r("settings.skills.catalog.add.scanResult",{count:k})}):null,e[102]=k,e[103]=r,e[104]=de):de=e[104];let Ne;e[105]!==Q||e[106]!==r?(Ne=Q?t.jsx("div",{className:"typography-meta text-muted-foreground",children:r("settings.skills.catalog.add.duplicateMessage")}):null,e[105]=Q,e[106]=r,e[107]=Ne):Ne=e[107];let Ee;e[108]!==ee||e[109]!==Re||e[110]!==le||e[111]!==W||e[112]!==de||e[113]!==Ne?(Ee=t.jsxs("div",{className:"space-y-4",children:[ee,Re,le,W,de,Ne]}),e[108]=ee,e[109]=Re,e[110]=le,e[111]=W,e[112]=de,e[113]=Ne,e[114]=Ee):Ee=e[114];let Ce;e[115]!==a?(Ce=()=>a(!1),e[115]=a,e[116]=Ce):Ce=e[116];let He;e[117]!==r?(He=r("settings.common.actions.cancel"),e[117]=r,e[118]=He):He=e[118];let q;e[119]!==Ce||e[120]!==He?(q=t.jsx(G,{size:"sm",variant:"ghost",onClick:Ce,children:He}),e[119]=Ce,e[120]=He,e[121]=q):q=e[121];let $;e[122]!==X?($=()=>{X()},e[122]=X,e[123]=$):$=e[123];let fe;e[124]!==f||e[125]!==h?(fe=f||!h.trim(),e[124]=f,e[125]=h,e[126]=fe):fe=e[126];let O;e[127]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(M,{name:"git-repository",className:"h-4 w-4"}),e[127]=O):O=e[127];let Fe;e[128]!==f||e[129]!==r?(Fe=r(f?"settings.skills.catalog.shared.actions.scanning":"settings.skills.catalog.shared.actions.scan"),e[128]=f,e[129]=r,e[130]=Fe):Fe=e[130];let Je;e[131]!==$||e[132]!==fe||e[133]!==Fe?(Je=t.jsxs(G,{size:"sm",className:"gap-2",variant:"ghost",onClick:$,disabled:fe,children:[O,Fe]}),e[131]=$,e[132]=fe,e[133]=Fe,e[134]=Je):Je=e[134];let Xe;e[135]!==me?(Xe=()=>{me()},e[135]=me,e[136]=Xe):Xe=e[136];let et;e[137]!==Q||e[138]!==u||e[139]!==y||e[140]!==h?(et=!y||Q||!u.trim()||!h.trim(),e[137]=Q,e[138]=u,e[139]=y,e[140]=h,e[141]=et):et=e[141];let at;e[142]!==r?(at=r("settings.skills.catalog.add.actions.addCatalog"),e[142]=r,e[143]=at):at=e[143];let lt;e[144]!==Xe||e[145]!==et||e[146]!==at?(lt=t.jsx(G,{size:"sm",onClick:Xe,disabled:et,children:at}),e[144]=Xe,e[145]=et,e[146]=at,e[147]=lt):lt=e[147];let Ze;e[148]!==q||e[149]!==Je||e[150]!==lt?(Ze=t.jsxs(Yt,{children:[q,Je,lt]}),e[148]=q,e[149]=Je,e[150]=lt,e[151]=Ze):Ze=e[151];let We;e[152]!==ye||e[153]!==Ee||e[154]!==Ze?(We=t.jsxs(Bt,{className:"max-w-xl",children:[ye,Ee,Ze]}),e[152]=ye,e[153]=Ee,e[154]=Ze,e[155]=We):We=e[155];let pt;return e[156]!==a||e[157]!==n||e[158]!==We?(pt=t.jsx(Ut,{open:n,onOpenChange:a,children:We}),e[156]=a,e[157]=n,e[158]=We,e[159]=pt):pt=e[159],pt};function Jg(s){return s.scanRepo}function Qg(s){return s.loadCatalog}function Yg(s){return s.loadSource}function Xg(s){return s.setSelectedSource}function Zg(s){return s.isScanning}function eh(s){return s.defaultGitIdentityId}function th(s){return s.loadDefaultGitIdentityId}function sh(s){return t.jsx(ht,{value:s.id,children:s.name},s.id)}const nh=s=>{const e=rt.c(85),{open:n,onOpenChange:a,conflicts:r,onConfirm:i}=s,{t:o}=dt();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const[c,f]=l.useState(d);let m,p;e[1]!==r||e[2]!==n?(m=()=>{if(!n)return;const me={};for(const oe of r)me[oe.skillName]="skip";f(me)},p=[n,r],e[1]=r,e[2]=n,e[3]=m,e[4]=p):(m=e[3],p=e[4]),l.useEffect(m,p);let u;e[5]!==r?(u=me=>{const oe={};for(const xe of r)oe[xe.skillName]=me;f(oe)},e[5]=r,e[6]=u):u=e[6];const S=u;let h;e[7]!==r||e[8]!==c?(h=r.length>0&&r.every(me=>c[me.skillName]),e[7]=r,e[8]=c,e[9]=h):h=e[9];const g=h;let x;e[10]!==o?(x=o("settings.skills.catalog.conflicts.title"),e[10]=o,e[11]=x):x=e[11];let D;e[12]!==x?(D=t.jsx(Vt,{children:x}),e[12]=x,e[13]=D):D=e[13];let N;e[14]!==o?(N=o("settings.skills.catalog.conflicts.description"),e[14]=o,e[15]=N):N=e[15];let w;e[16]!==N?(w=t.jsx(qt,{children:N}),e[16]=N,e[17]=w):w=e[17];let A;e[18]!==D||e[19]!==w?(A=t.jsxs(_t,{children:[D,w]}),e[18]=D,e[19]=w,e[20]=A):A=e[20];let k;e[21]!==r.length||e[22]!==o?(k=o("settings.skills.catalog.conflicts.count",{count:r.length}),e[21]=r.length,e[22]=o,e[23]=k):k=e[23];let j;e[24]!==k?(j=t.jsx("span",{className:"typography-meta text-muted-foreground",children:k}),e[24]=k,e[25]=j):j=e[25];let y;e[26]!==S?(y=()=>S("skip"),e[26]=S,e[27]=y):y=e[27];let P;e[28]!==o?(P=o("settings.skills.catalog.conflicts.actions.skipAll"),e[28]=o,e[29]=P):P=e[29];let z;e[30]!==y||e[31]!==P?(z=t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:y,children:P}),e[30]=y,e[31]=P,e[32]=z):z=e[32];let R;e[33]!==S?(R=()=>S("overwrite"),e[33]=S,e[34]=R):R=e[34];let I;e[35]!==o?(I=o("settings.skills.catalog.conflicts.actions.overwriteAll"),e[35]=o,e[36]=I):I=e[36];let v;e[37]!==R||e[38]!==I?(v=t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:R,children:I}),e[37]=R,e[38]=I,e[39]=v):v=e[39];let b;e[40]!==z||e[41]!==v?(b=t.jsxs("div",{className:"flex items-center gap-2",children:[z,v]}),e[40]=z,e[41]=v,e[42]=b):b=e[42];let L;e[43]!==j||e[44]!==b?(L=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[j,b]}),e[43]=j,e[44]=b,e[45]=L):L=e[45];let E;if(e[46]!==r||e[47]!==c||e[48]!==o){let me;e[50]!==c||e[51]!==o?(me=oe=>t.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label truncate",children:oe.skillName}),t.jsx("div",{className:"typography-micro text-muted-foreground",children:o("settings.skills.catalog.conflicts.installedIn",{scope:oe.scope==="project"?o("settings.skills.catalog.conflicts.scope.project"):o("settings.skills.catalog.conflicts.scope.user"),source:oe.source==="agents"?o("settings.skills.catalog.conflicts.source.agents"):o("settings.skills.catalog.conflicts.source.opencode")})})]}),t.jsxs(Ft,{value:c[oe.skillName]||"skip",onValueChange:xe=>f(we=>({...we,[oe.skillName]:xe})),children:[t.jsx(Lt,{className:"w-fit",children:t.jsx("span",{className:"capitalize",children:(c[oe.skillName]||"skip")==="overwrite"?o("settings.skills.catalog.conflicts.decision.overwrite"):o("settings.skills.catalog.conflicts.decision.skip")})}),t.jsxs(Ot,{align:"end",children:[t.jsx(ht,{value:"skip",className:"pr-2 [&>span:first-child]:hidden",children:o("settings.skills.catalog.conflicts.decision.skip")}),t.jsx(ht,{value:"overwrite",className:"pr-2 [&>span:first-child]:hidden",children:o("settings.skills.catalog.conflicts.decision.overwrite")})]})]})]},oe.skillName),e[50]=c,e[51]=o,e[52]=me):me=e[52],E=r.map(me),e[46]=r,e[47]=c,e[48]=o,e[49]=E}else E=e[49];let J;e[53]!==E?(J=t.jsx("div",{className:"space-y-2",children:E}),e[53]=E,e[54]=J):J=e[54];let _;e[55]!==L||e[56]!==J?(_=t.jsxs("div",{className:"space-y-3",children:[L,J]}),e[55]=L,e[56]=J,e[57]=_):_=e[57];let Z;e[58]!==a?(Z=()=>a(!1),e[58]=a,e[59]=Z):Z=e[59];let H;e[60]!==o?(H=o("settings.common.actions.cancel"),e[60]=o,e[61]=H):H=e[61];let T;e[62]!==Z||e[63]!==H?(T=t.jsx(G,{size:"sm",variant:"ghost",onClick:Z,children:H}),e[62]=Z,e[63]=H,e[64]=T):T=e[64];let Y;e[65]!==c||e[66]!==i?(Y=()=>i(c),e[65]=c,e[66]=i,e[67]=Y):Y=e[67];const F=!g;let V;e[68]!==o?(V=o("settings.skills.catalog.conflicts.actions.continue"),e[68]=o,e[69]=V):V=e[69];let Q;e[70]!==Y||e[71]!==F||e[72]!==V?(Q=t.jsx(G,{size:"sm",onClick:Y,disabled:F,children:V}),e[70]=Y,e[71]=F,e[72]=V,e[73]=Q):Q=e[73];let ie;e[74]!==T||e[75]!==Q?(ie=t.jsxs(Yt,{children:[T,Q]}),e[74]=T,e[75]=Q,e[76]=ie):ie=e[76];let X;e[77]!==A||e[78]!==_||e[79]!==ie?(X=t.jsxs(Bt,{className:"max-w-2xl",children:[A,_,ie]}),e[77]=A,e[78]=_,e[79]=ie,e[80]=X):X=e[80];let se;return e[81]!==a||e[82]!==n||e[83]!==X?(se=t.jsx(Ut,{open:n,onOpenChange:a,children:X}),e[81]=a,e[82]=n,e[83]=X,e[84]=se):se=e[84],se},Wr=[{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 Jn(s,e){return s==="project"&&e==="claude"?"project-claude":s==="project"&&e==="agents"?"project-agents":e==="claude"?"user-claude":s==="project"?"project-opencode":e==="agents"?"user-agents":"user-opencode"}function Ll(s){if(s==="user-claude")return{scope:"user",source:"claude"};if(s==="project-claude")return{scope:"project",source:"claude"};const e=Wr.find(n=>n.value===s);return e?{scope:e.scope,source:e.source}:{scope:"user",source:"opencode"}}const ah=s=>{const e=rt.c(124),{open:n,onOpenChange:a,item:r}=s,{t:i}=dt(),o=Bs(rh),d=Bs(ih),[c,f]=l.useState("user"),[m,p]=l.useState("opencode"),u=as(oh),S=as(lh),[h,g]=l.useState(null),[x,D]=l.useState(!1);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0];const[w,A]=l.useState(N),[k,j]=l.useState(null);let y,P;e[1]!==S||e[2]!==n?(y=()=>{n&&(f("user"),p("opencode"),g(S),D(!1),A([]),j(null))},P=[n,S],e[1]=S,e[2]=n,e[3]=y,e[4]=P):(y=e[3],P=e[4]),l.useEffect(y,P);let z;e[5]!==i?(z=le=>{switch(le){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]=z):z=e[6];const R=z;let I;e[7]!==i?(I=le=>{switch(le){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]=I):I=e[8];const v=I;let b;e:{if(u.length===0){b=null;break e}if(h&&u.some(le=>le.id===h)){b=h;break e}if(S&&u.some(le=>le.id===S)){b=S;break e}b=u[0]?.id??null}const L=b;let E;e:{if(c!=="project"){E=null;break e}const le=L;if(!le){E=null;break e}let W;if(e[9]!==le||e[10]!==u){let Ne;e[12]!==le?(Ne=Ee=>Ee.id===le,e[12]=le,e[13]=Ne):Ne=e[13],W=u.find(Ne),e[9]=le,e[10]=u,e[11]=W}else W=e[11];E=W?.path??null}const J=E;let _;e[14]!==o||e[15]!==r||e[16]!==a||e[17]!==i?(_=async le=>{const W={skillDir:le.skillDir};r?.clawdhub&&(W.clawdhub={slug:r.clawdhub.slug,version:r.clawdhub.version});const de=await o({source:le.source,subpath:le.subpath,gitIdentityId:r?.gitIdentityId,scope:le.scope,targetSource:le.targetSource,selections:[W],conflictPolicy:"prompt",conflictDecisions:le.conflictDecisions},{directory:le.directoryOverride??null});if(de.ok){B.success(i("settings.skills.catalog.installSkill.toast.installed")),a(!1);return}if(de.error?.kind==="conflicts"){j({source:le.source,subpath:le.subpath,scope:le.scope,targetSource:le.targetSource,skillDir:le.skillDir,directoryOverride:le.directoryOverride??null}),A(de.error.conflicts),D(!0);return}if(de.error?.kind==="authRequired"){B.error(de.error.message||i("settings.skills.catalog.installSkill.toast.authRequired"));return}B.error(de.error?.message||i("settings.skills.catalog.installSkill.toast.installFailed"))},e[14]=o,e[15]=r,e[16]=a,e[17]=i,e[18]=_):_=e[18];const Z=_;if(!r)return null;let H;e[19]!==i?(H=i("settings.skills.catalog.installSkill.title"),e[19]=i,e[20]=H):H=e[20];let T;e[21]!==H?(T=t.jsx(Vt,{children:H}),e[21]=H,e[22]=T):T=e[22];let Y;e[23]!==i?(Y=i("settings.skills.catalog.installSkill.descriptionPrefix"),e[23]=i,e[24]=Y):Y=e[24];let F;e[25]!==r.skillName?(F=t.jsx("span",{className:"font-semibold text-foreground",children:r.skillName}),e[25]=r.skillName,e[26]=F):F=e[26];let V;e[27]!==i?(V=i("settings.skills.catalog.installSkill.descriptionSuffix"),e[27]=i,e[28]=V):V=e[28];let Q;e[29]!==Y||e[30]!==F||e[31]!==V?(Q=t.jsxs(qt,{children:[Y," ",F," ",V]}),e[29]=Y,e[30]=F,e[31]=V,e[32]=Q):Q=e[32];let ie;e[33]!==T||e[34]!==Q?(ie=t.jsxs(_t,{children:[T,Q]}),e[33]=T,e[34]=Q,e[35]=ie):ie=e[35];let X;e[36]!==i?(X=i("settings.skills.catalog.installSkill.field.destination"),e[36]=i,e[37]=X):X=e[37];let se;e[38]!==X?(se=t.jsx("span",{className:"typography-ui-label text-foreground",children:X}),e[38]=X,e[39]=se):se=e[39];let me;e[40]!==c||e[41]!==m?(me=Jn(c,m),e[40]=c,e[41]=m,e[42]=me):me=e[42];let oe;e[43]===Symbol.for("react.memo_cache_sentinel")?(oe=le=>{const W=Ll(le);f(W.scope),p(W.source==="agents"?"agents":"opencode")},e[43]=oe):oe=e[43];let xe;e[44]!==c?(xe=c==="user"?t.jsx(M,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"folder",className:"h-3.5 w-3.5"}),e[44]=c,e[45]=xe):xe=e[45];let we;e[46]!==m?(we=m==="agents"?t.jsx(M,{name:"robot-2",className:"h-3.5 w-3.5"}):null,e[46]=m,e[47]=we):we=e[47];let he;e[48]!==R||e[49]!==c||e[50]!==m?(he=R(Jn(c,m)),e[48]=R,e[49]=c,e[50]=m,e[51]=he):he=e[51];let Ie;e[52]!==he?(Ie=t.jsx("span",{children:he}),e[52]=he,e[53]=Ie):Ie=e[53];let ve;e[54]!==xe||e[55]!==we||e[56]!==Ie?(ve=t.jsxs(Lt,{className:"w-fit gap-1.5",children:[xe,we,Ie]}),e[54]=xe,e[55]=we,e[56]=Ie,e[57]=ve):ve=e[57];let ye;e[58]!==v||e[59]!==R?(ye=Wr.map(le=>t.jsx(ht,{value:le.value,className:"pr-2 [&>span:first-child]:hidden",children:t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[le.scope==="user"?t.jsx(M,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"folder",className:"h-3.5 w-3.5"}),le.source==="agents"?t.jsx(M,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:R(le.value)})]}),t.jsx("span",{className:"typography-micro text-muted-foreground ml-5",children:v(le.value)})]})},le.value)),e[58]=v,e[59]=R,e[60]=ye):ye=e[60];let be;e[61]!==ye?(be=t.jsx(Ot,{align:"start",children:ye}),e[61]=ye,e[62]=be):be=e[62];let te;e[63]!==me||e[64]!==ve||e[65]!==be?(te=t.jsxs(Ft,{value:me,onValueChange:oe,children:[ve,be]}),e[63]=me,e[64]=ve,e[65]=be,e[66]=te):te=e[66];let re;e[67]!==se||e[68]!==te?(re=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[se,te]}),e[67]=se,e[68]=te,e[69]=re):re=e[69];let ge;e[70]!==u||e[71]!==L||e[72]!==c||e[73]!==i?(ge=c==="project"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.skills.catalog.installSkill.field.project")}),u.length===0?t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.skills.catalog.installSkill.field.noProjects")}):t.jsxs(Ft,{value:L??"",onValueChange:le=>g(le),disabled:u.length===1,children:[t.jsx(Lt,{className:"w-fit",children:t.jsx(Kt,{placeholder:i("settings.skills.catalog.installSkill.field.chooseProjectPlaceholder")})}),t.jsx(Ot,{align:"start",children:u.map(ch)})]})]}),e[70]=u,e[71]=L,e[72]=c,e[73]=i,e[74]=ge):ge=e[74];let U;e[75]!==r.warnings?(U=r.warnings?.length?t.jsx("div",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded",children:r.warnings.join(" · ")}):null,e[75]=r.warnings,e[76]=U):U=e[76];let ee;e[77]!==re||e[78]!==ge||e[79]!==U?(ee=t.jsxs("div",{className:"mt-2 space-y-3",children:[re,ge,U]}),e[77]=re,e[78]=ge,e[79]=U,e[80]=ee):ee=e[80];let ne;e[81]!==a?(ne=()=>a(!1),e[81]=a,e[82]=ne):ne=e[82];let ue;e[83]!==i?(ue=i("settings.common.actions.cancel"),e[83]=i,e[84]=ue):ue=e[84];let Me;e[85]!==ne||e[86]!==ue?(Me=t.jsx(G,{size:"sm",variant:"ghost",onClick:ne,children:ue}),e[85]=ne,e[86]=ue,e[87]=Me):Me=e[87];const ke=d||!r.installable||c==="project"&&!J;let De;e[88]!==J||e[89]!==Z||e[90]!==r.repoSource||e[91]!==r.repoSubpath||e[92]!==r.skillDir||e[93]!==c||e[94]!==m?(De=()=>{Z({source:r.repoSource,subpath:r.repoSubpath,scope:c,targetSource:m,skillDir:r.skillDir,directoryOverride:J})},e[88]=J,e[89]=Z,e[90]=r.repoSource,e[91]=r.repoSubpath,e[92]=r.skillDir,e[93]=c,e[94]=m,e[95]=De):De=e[95];let Ae;e[96]!==d||e[97]!==i?(Ae=i(d?"settings.skills.catalog.installSkill.actions.installing":"settings.skills.catalog.installSkill.actions.install"),e[96]=d,e[97]=i,e[98]=Ae):Ae=e[98];let Pe;e[99]!==ke||e[100]!==De||e[101]!==Ae?(Pe=t.jsx(G,{size:"sm",disabled:ke,onClick:De,children:Ae}),e[99]=ke,e[100]=De,e[101]=Ae,e[102]=Pe):Pe=e[102];let Re;e[103]!==Me||e[104]!==Pe?(Re=t.jsxs(Yt,{children:[Me,Pe]}),e[103]=Me,e[104]=Pe,e[105]=Re):Re=e[105];let Le;e[106]!==ie||e[107]!==ee||e[108]!==Re?(Le=t.jsxs(Bt,{className:"max-w-md",children:[ie,ee,Re]}),e[106]=ie,e[107]=ee,e[108]=Re,e[109]=Le):Le=e[109];let $e;e[110]!==a||e[111]!==n||e[112]!==Le?($e=t.jsx(Ut,{open:n,onOpenChange:a,children:Le}),e[110]=a,e[111]=n,e[112]=Le,e[113]=$e):$e=e[113];let Be;e[114]!==k||e[115]!==Z?(Be=le=>{k&&(Z({source:k.source,subpath:k.subpath,scope:k.scope,targetSource:k.targetSource,skillDir:k.skillDir,conflictDecisions:le,directoryOverride:k.directoryOverride??null}),D(!1))},e[114]=k,e[115]=Z,e[116]=Be):Be=e[116];let Oe;e[117]!==w||e[118]!==x||e[119]!==Be?(Oe=t.jsx(nh,{open:x,onOpenChange:D,conflicts:w,onConfirm:Be}),e[117]=w,e[118]=x,e[119]=Be,e[120]=Oe):Oe=e[120];let Ue;return e[121]!==$e||e[122]!==Oe?(Ue=t.jsxs(t.Fragment,{children:[$e,Oe]}),e[121]=$e,e[122]=Oe,e[123]=Ue):Ue=e[123],Ue};function rh(s){return s.installSkills}function ih(s){return s.isInstalling}function oh(s){return s.projects}function lh(s){return s.activeProjectId}function ch(s){return t.jsx(ht,{value:s.id,children:s.label||s.path},s.id)}const dh=async()=>{try{const s=Fs()?.settings;if(s)return(await s.load())?.settings||{};const e=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});return e.ok?await e.json().catch(()=>null):null}catch{return null}},mh=({mode:s,onModeChange:e,showModeTabs:n=!0})=>{const{t:a}=dt(),{sources:r,itemsBySource:i,selectedSourceId:o,setSelectedSource:d,loadCatalog:c,loadSource:f,loadMoreClawdHub:m,isLoadingCatalog:p,isLoadingSource:u,isLoadingMore:S,loadedSourceIds:h,clawdhubHasMoreBySource:g,lastCatalogError:x}=Bs(Ss(T=>({sources:T.sources,itemsBySource:T.itemsBySource,selectedSourceId:T.selectedSourceId,setSelectedSource:T.setSelectedSource,loadCatalog:T.loadCatalog,loadSource:T.loadSource,loadMoreClawdHub:T.loadMoreClawdHub,isLoadingCatalog:T.isLoadingCatalog,isLoadingSource:T.isLoadingSource,isLoadingMore:T.isLoadingMore,loadedSourceIds:T.loadedSourceIds,clawdhubHasMoreBySource:T.clawdhubHasMoreBySource,lastCatalogError:T.lastCatalogError}))),[D,N]=l.useState(""),[w,A]=l.useState(!1),[k,j]=l.useState(!1),[y,P]=l.useState(null),[z,R]=l.useState(!1),[I,v]=l.useState(!1);l.useEffect(()=>{c()},[c]),l.useEffect(()=>{o&&(h[o]||f(o))},[o,h,f]);const b=l.useMemo(()=>o?i[o]||[]:[],[i,o]),L=l.useMemo(()=>{const T=D.trim().toLowerCase();return T?b.filter(Y=>{const F=Y.skillName.toLowerCase(),V=(Y.description||"").toLowerCase(),Q=(Y.frontmatterName||"").toLowerCase();return F.includes(T)||V.includes(T)||Q.includes(T)}):b},[b,D]),E=l.useMemo(()=>r.find(T=>T.id===o)||null,[r,o]),J=!!(o&&o.startsWith("custom:")),_=E?.source==="clawdhub:registry"||E?.sourceType==="clawdhub",Z=!!(o&&(g[o]??!0)),H=async()=>{if(!(!o||!J)){R(!0);try{const T=await dh(),F=(Array.isArray(T?.skillCatalogs)?T?.skillCatalogs:[]).filter(V=>V.id!==o);await Pt({skillCatalogs:F}),await c({refresh:!0}),v(!1)}finally{R(!1)}}};return t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsxs("div",{className:"mb-4",children:[n&&t.jsx("div",{className:"mb-4",children:t.jsx("div",{className:"h-10",children:t.jsx(xn,{items:[{id:"manual",label:a("settings.skills.catalog.page.mode.manual")},{id:"external",label:a("settings.skills.catalog.page.mode.external")}],activeId:s,onSelect:T=>e(T),layoutMode:"fit",variant:"animated",animateActivePill:!1,className:"h-full"})})}),t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground px-1",children:a("settings.skills.catalog.page.title")})]}),t.jsxs("div",{"data-settings-item":"skills.catalog.source",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:a("settings.skills.catalog.page.section.sourceRepository")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1.5",children:[t.jsxs(Ft,{value:o||"",onValueChange:T=>d(T),children:[t.jsx(Lt,{className:"w-fit",children:t.jsx(Kt,{placeholder:a("settings.skills.catalog.page.field.selectSourcePlaceholder"),children:E?.label})}),t.jsx(Ot,{align:"start",children:r.map(T=>t.jsx(ht,{value:T.id,children:T.label},T.id))})]}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>{o?f(o,{refresh:!0}):c({refresh:!0})},disabled:p||u,title:a("settings.skills.catalog.page.actions.refreshTitle"),children:t.jsx(M,{name:"refresh",className:ce("h-3.5 w-3.5",(p||u)&&"animate-spin")})}),J&&t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>v(!0),disabled:z,title:a("settings.skills.catalog.page.actions.removeCatalogTitle"),children:t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(G,{"data-settings-item":"skills.catalog.add-catalog",size:"xs",className:"!font-normal gap-1",onClick:()=>A(!0),children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"})," ",a("settings.skills.catalog.page.actions.addCatalog")]})]}),t.jsxs("div",{"data-settings-item":"skills.catalog.search",className:"py-1.5",children:[t.jsxs("div",{className:"relative",children:[t.jsx(M,{name:"search",className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),t.jsx(it,{value:D,onChange:T=>N(T.target.value),placeholder:a("settings.skills.catalog.shared.field.searchSkillsPlaceholder"),className:"h-7 pl-8 w-full sm:w-64"})]}),t.jsx("span",{className:"typography-meta text-muted-foreground mt-1 block",children:p?a("settings.skills.catalog.page.loading.catalog"):a("settings.skills.catalog.page.foundCount",{count:L.length})})]})]})]}),x&&t.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[t.jsx("div",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:a("settings.skills.catalog.page.error.catalogTitle")}),t.jsx("div",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:x.message})]}),t.jsxs("div",{className:"mb-8",children:[t.jsx("section",{className:"px-2 pb-2 pt-0",children:L.length===0&&!u?t.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[t.jsx("p",{className:"typography-body",children:a("settings.skills.catalog.page.empty.noSkillsTitle")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.skills.catalog.page.empty.noSkillsDescription")})]}):u?t.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[t.jsx(M,{name:"refresh",className:"mx-auto mb-3 h-5 w-5 animate-spin opacity-50"}),t.jsx("p",{className:"typography-meta",children:a("settings.skills.catalog.page.loading.skills")})]}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:L.map(T=>{const Y=T.installed?.isInstalled,F=T.installed?.scope;return t.jsx("div",{className:"py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:T.skillName}),Y&&t.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:a("settings.skills.catalog.page.badge.installed",{scope:F||a("settings.skills.catalog.page.badge.unknown")})}),!T.installable&&t.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:a("settings.skills.catalog.page.badge.notInstallable")})]}),T.description?t.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 line-clamp-2",children:T.description}):t.jsx("div",{className:"typography-meta text-muted-foreground/50 mt-0.5 italic",children:a("settings.skills.catalog.shared.noDescription")}),T.clawdhub&&t.jsxs("div",{className:"typography-micro text-muted-foreground mt-1.5 flex items-center gap-3",children:[T.clawdhub.owner&&t.jsxs("span",{children:[a("settings.skills.catalog.page.byOwnerPrefix")," ",t.jsx("span",{className:"font-medium text-foreground/80",children:T.clawdhub.owner})]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(M,{name:"download",className:"h-3 w-3"}),T.clawdhub.downloads?.toLocaleString()??0]}),(T.clawdhub.stars??0)>0&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(M,{name:"star",className:"h-3 w-3"}),T.clawdhub.stars]}),t.jsxs("span",{className:"bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:["v",T.clawdhub.version]})]}),T.warnings?.length?t.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:T.warnings.join(" · ")}):null]}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal shrink-0",disabled:!T.installable,onClick:()=>{P(T),j(!0)},children:a("settings.skills.catalog.shared.actions.install")})]})},`${T.sourceId}:${T.skillDir}`)})})}),_&&Z&&!u&&L.length>0&&t.jsx("div",{className:"flex justify-center mt-2 px-2",children:t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{m()},disabled:S,children:a(S?"settings.skills.catalog.page.loading.more":"settings.skills.catalog.page.actions.loadMoreSkills")})})]}),t.jsx(Gg,{open:w,onOpenChange:A}),t.jsx(ah,{open:k,onOpenChange:j,item:y}),t.jsx(Ut,{open:I,onOpenChange:T=>{z||v(T)},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:a("settings.skills.catalog.page.removeDialog.title")}),t.jsx(qt,{children:a("settings.skills.catalog.page.removeDialog.description")})]}),t.jsxs(Yt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>v(!1),disabled:z,children:a("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",variant:"destructive",onClick:()=>{H()},disabled:z,children:a("settings.skills.catalog.page.actions.removeCatalog")})]})]})})]})})};function vo(s,e){const n=s.metadata.variant==="dark",a=s.config?.fonts?.mono||"monospace",r=s.colors.syntax.highlights||{},i=s.colors.syntax.tokens||{},o=Rs.theme({"&":{backgroundColor:"var(--background)",color:s.colors.syntax.base.foreground,fontSize:"var(--text-code)",lineHeight:"1.5rem",position:"relative"},".cm-scroller":{fontFamily:a,backgroundColor:"var(--background)"},".cm-comment":{color:s.colors.syntax.base.comment},".cm-keyword":{color:s.colors.syntax.base.keyword},".cm-string":{color:s.colors.syntax.base.string},".cm-string-2":{color:i.stringEscape||s.colors.syntax.base.string},".cm-number":{color:s.colors.syntax.base.number},".cm-operator":{color:s.colors.syntax.base.operator},".cm-punctuation":{color:i.punctuation||s.colors.syntax.base.comment},".cm-atom":{color:i.boolean||s.colors.syntax.base.number},".cm-builtin":{color:i.functionCall||s.colors.syntax.base.function},".cm-def":{color:i.variableGlobal||s.colors.syntax.base.variable},".cm-attribute":{color:i.variableOther||i.variableProperty||s.colors.syntax.base.operator},".cm-meta":{color:s.colors.syntax.base.comment},".cm-property":{color:i.variableProperty||s.colors.syntax.base.keyword},".cm-variable":{color:s.colors.syntax.base.variable},".cm-variable-2":{color:i.variableOther||s.colors.syntax.base.function},".cm-variable-3":{color:i.variableGlobal||s.colors.syntax.base.type},".cm-tag":{color:i.tag||s.colors.syntax.base.keyword},".cm-link":{color:i.url||s.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:s.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:s.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:s.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:r.lineNumber||s.colors.syntax.base.comment,borderRight:`1px solid ${s.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:r.lineNumberActive||s.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:s.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:s.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${s.colors.interactive.border}`,backgroundColor:s.colors.surface.elevated,color:s.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${s.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${s.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${s.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:s.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${s.colors.interactive.border}`,backgroundColor:s.colors.surface.background,color:s.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:s.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:s.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:s.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:s.colors.interactive.hover,borderColor:s.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:s.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:s.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:s.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:s.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:s.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:s.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:s.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:s.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${s.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:s.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:s.colors.interactive.hover,color:s.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:s.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${s.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:s.colors.interactive.selection,color:s.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${s.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:n}),d=ni.define([{tag:[Te.comment,Te.docComment,Te.meta,Te.documentMeta],class:"cm-comment"},{tag:[Te.keyword,Te.controlKeyword,Te.moduleKeyword,Te.definitionKeyword,Te.modifier],class:"cm-keyword"},{tag:[Te.operatorKeyword,Te.operator,Te.derefOperator,Te.updateOperator,Te.definitionOperator,Te.typeOperator,Te.controlOperator,Te.logicOperator,Te.bitwiseOperator,Te.arithmeticOperator,Te.compareOperator],class:"cm-operator"},{tag:[Te.punctuation,Te.separator,Te.bracket,Te.paren,Te.brace,Te.squareBracket,Te.angleBracket],class:"cm-punctuation"},{tag:[Te.string,Te.regexp,Te.attributeValue,Te.special(Te.string),Te.monospace],class:"cm-string"},{tag:Te.escape,class:"cm-string-2"},{tag:[Te.number,Te.bool,Te.atom,Te.null,Te.self],class:"cm-number"},{tag:[Te.function(Te.variableName),Te.function(Te.definition(Te.variableName)),Te.function(Te.propertyName),Te.standard(Te.variableName),Te.special(Te.variableName)],class:"cm-builtin"},{tag:Te.definition(Te.variableName),class:"cm-def"},{tag:[Te.variableName,Te.local(Te.variableName),Te.constant(Te.variableName),Te.literal],class:"cm-variable"},{tag:Te.propertyName,class:"cm-property"},{tag:Te.attributeName,class:"cm-attribute"},{tag:[Te.className,Te.typeName,Te.namespace],class:"cm-variable-3"},{tag:[Te.tagName,Te.labelName,Te.annotation,Te.macroName],class:"cm-tag"},{tag:Te.link,class:"cm-link"},{tag:[Te.heading,Te.heading1,Te.heading2,Te.heading3,Te.heading4,Te.heading5,Te.heading6],class:"cm-keyword"}]),c=ni.define([{tag:[Te.comment,Te.docComment,Te.meta,Te.documentMeta],color:s.colors.syntax.base.comment},{tag:[Te.keyword,Te.controlKeyword,Te.moduleKeyword,Te.definitionKeyword,Te.modifier],color:s.colors.syntax.base.keyword},{tag:[Te.operatorKeyword,Te.operator,Te.derefOperator,Te.updateOperator,Te.definitionOperator,Te.typeOperator,Te.controlOperator,Te.logicOperator,Te.bitwiseOperator,Te.arithmeticOperator,Te.compareOperator],color:s.colors.syntax.base.operator},{tag:[Te.string,Te.regexp,Te.attributeValue,Te.special(Te.string),Te.monospace],color:s.colors.syntax.base.string},{tag:Te.escape,color:i.stringEscape||s.colors.syntax.base.string},{tag:[Te.number,Te.bool,Te.atom,Te.null,Te.self],color:s.colors.syntax.base.number},{tag:[Te.function(Te.variableName),Te.function(Te.definition(Te.variableName)),Te.function(Te.propertyName),Te.standard(Te.variableName),Te.special(Te.variableName)],color:s.colors.syntax.base.function},{tag:Te.definition(Te.variableName),color:i.variableGlobal||s.colors.syntax.base.variable},{tag:[Te.variableName,Te.local(Te.variableName),Te.constant(Te.variableName),Te.literal],color:s.colors.syntax.base.variable},{tag:Te.propertyName,color:i.variableProperty||s.colors.syntax.base.variable},{tag:Te.attributeName,color:i.variableOther||s.colors.syntax.base.variable},{tag:[Te.className,Te.typeName,Te.namespace],color:s.colors.syntax.base.type},{tag:[Te.tagName,Te.labelName,Te.annotation,Te.macroName],color:i.tag||s.colors.syntax.base.keyword},{tag:Te.link,color:i.url||s.colors.syntax.base.function,textDecoration:"underline"},{tag:[Te.punctuation,Te.separator,Te.bracket,Te.paren,Te.brace,Te.squareBracket,Te.angleBracket],color:i.punctuation||s.colors.syntax.base.comment}]);return e?.syntaxColors===!1?[o]:[o,na(Xc,{fallback:!0}),na(Zc),na(d),na(c)]}const uh=180,Ol=ed.define(),ph=1,gh=2,hh=4,jo=new Map,fh=(s,e)=>{const n=`${s}|${e}`,a=jo.get(n);if(a)return a;let r="";s&&(r+=`color:${s};`),e&ph&&(r+="font-style:italic;"),e&gh&&(r+="font-weight:bold;"),e&hh&&(r+="text-decoration:underline;");const i=Oa.mark({attributes:{style:r}});return jo.set(n,i),i},xh=(s,e)=>{const n=new Br,a=s.state.doc,r=Math.min(e.length,a.lines);for(let i=0;i<r;i+=1){const o=e[i];if(!o||o.length===0)continue;const d=a.line(i+1);let c=d.from;for(const[f,m,p]of o){if(f<=0)continue;const u=c,S=Math.min(c+f,d.to);c+=f,!(S<=u)&&(!m&&!p||n.add(u,S,fh(m,p)))}}return n.finish()},yh=ul.define({create(){return Oa.none},update(s,e){let n=s.map(e.changes);for(const a of e.effects)a.is(Ol)&&(n=a.value);return n},provide:s=>Rs.decorations.from(s)}),bh=s=>ml.fromClass(class{timer;generation=0;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},uh)}async tokenize(e){const n=++this.generation,a=e.state.doc.toString(),r=await Ed(a,s.language,s.themeName,s.theme);r&&n===this.generation&&e.state.doc.length===a.length&&e.dispatch({effects:Ol.of(xh(e,r))})}destroy(){this.timer&&clearTimeout(this.timer)}}),vh=s=>[yh,bh(s)],jh=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(mh,{mode:"external",onModeChange:Ph,showModeTabs:!1}),s[0]=e):e=s[0],e},wh="SKILL.md",Nh="h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]",Da=(s,e)=>{const n=td({description:s}).trimEnd(),a=e.trimStart();return`---
|
|
23
|
-
${n}
|
|
24
|
-
---${a?`
|
|
25
|
-
|
|
26
|
-
${a}`:`
|
|
27
|
-
`}`},kh=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),zl=s=>{const e=s.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!e)return{description:null,instructions:s};let n=null;try{const a=sd(e[1]);if(kh(a)){const r=a.description;typeof r=="string"&&(n=r)}}catch{n=null}return{description:n,instructions:e[2].replace(/^\r?\n/,"")}},Sh=(s,e)=>{const n=zl(s);return Da(e,n.instructions)},Ch=()=>{const{t:s}=dt(),{currentTheme:e}=Ua(),{selectedSkillName:n,getSkillByName:a,getSkillDetail:r,createSkill:i,updateSkill:o,skills:d,skillDraft:c,setSkillDraft:f,setSelectedSkill:m}=_s(Ss(le=>({selectedSkillName:le.selectedSkillName,getSkillByName:le.getSkillByName,getSkillDetail:le.getSkillDetail,createSkill:le.createSkill,updateSkill:le.updateSkill,skills:le.skills,skillDraft:le.skillDraft,setSkillDraft:le.setSkillDraft,setSelectedSkill:le.setSelectedSkill}))),p=n?a(n):null,u=!!(c&&c.name===n&&!p),S=!!(n&&!p&&!c),h=p?.path==="<built-in>";l.useEffect(()=>{S&&m(null)},[S,m]);const[g,x]=l.useState(""),[D,N]=l.useState("user"),[w,A]=l.useState("opencode"),[k,j]=l.useState(""),[y,P]=l.useState(""),[z,R]=l.useState(()=>Da("","")),[I,v]=l.useState("edit"),[b,L]=l.useState([]),[E,J]=l.useState([]),[_,Z]=l.useState(!1),[H,T]=l.useState(!1),[Y,F]=l.useState(""),[V,Q]=l.useState(""),[ie,X]=l.useState(!1),[se,me]=l.useState(""),[oe,xe]=l.useState(""),[we,he]=l.useState(null),[Ie,ve]=l.useState(!1),[ye,be]=l.useState(""),[te,re]=l.useState(null),[ge,U]=l.useState(!1),ee=u?g.trim()!==""||k.trim()!==""||y.trim()!==""||E.length>0:k!==Y||y!==V,ne=we?oe!==ye:se.trim()!=="",ue=l.useCallback(le=>{switch(le){case"project-opencode":return s("settings.skills.location.option.projectOpencode.label");case"user-claude":return s("settings.skills.location.option.userClaude.label");case"project-claude":return s("settings.skills.location.option.projectClaude.label");case"user-agents":return s("settings.skills.location.option.userAgents.label");case"project-agents":return s("settings.skills.location.option.projectAgents.label");default:return s("settings.skills.location.option.userOpencode.label")}},[s]),Me=l.useCallback(le=>{switch(le){case"project-opencode":return s("settings.skills.location.option.projectOpencode.description");case"user-claude":return s("settings.skills.location.option.userClaude.description");case"project-claude":return s("settings.skills.location.option.projectClaude.description");case"user-agents":return s("settings.skills.location.option.userAgents.description");case"project-agents":return s("settings.skills.location.option.projectAgents.description");default:return s("settings.skills.location.option.userOpencode.description")}},[s]);l.useEffect(()=>{(async()=>{if(u&&c){const W=c.description||"",de=c.instructions||"";x(c.name||""),N(c.scope||"user"),A(c.source==="agents"?"agents":"opencode"),j(W),P(de),R(Da(W,de)),F(""),Q(""),L([]),J(c.pendingFiles||[])}else if(n&&p){T(!0);try{const W=await r(n);if(W){const de=W.sources.md,Ne=de.description||"",Ee=de.instructions||"";j(Ne),P(Ee),R(Da(Ne,Ee)),F(Ne),Q(Ee),L(de.supportingFiles||[])}}catch(W){console.error("Failed to load skill details:",W)}finally{T(!1)}}})()},[p,u,n,d,c,r]);const ke=l.useMemo(()=>{const le=[vo(e)],W=ri(wh);return W&&le.push(W),le.push(Rs.lineWrapping),le},[e]),De=l.useMemo(()=>{const le=se.trim()||"supporting-file.md",W=Md(le),de=!!W&&W!=="markdown",Ne=[vo(e,de?{syntaxColors:!1}:void 0)],Ee=ri(le);return Ee&&Ne.push(Ee),de&&W&&Ne.push(vh({language:W,themeName:e.metadata.id,theme:wr(e)})),Ne.push(Rs.lineWrapping),Ne},[e,se]),Ae=l.useCallback(le=>{j(le),R(W=>Sh(W,le))},[]),Pe=l.useCallback(le=>{R(le);const W=zl(le);j(W.description??""),P(W.instructions)},[]),Re=async()=>{const le=u?g.trim().replace(/\s+/g,"-").toLowerCase():n?.trim();if(!le){B.error(s("settings.skills.page.toast.skillNameRequired"));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(le)||le.length>64){B.error(s("settings.skills.page.toast.invalidSkillName"));return}if(!k.trim()){B.error(s("settings.skills.page.toast.descriptionRequired"));return}if(u&&d.some(W=>W.name===le)){B.error(s("settings.skills.page.toast.skillExists"));return}Z(!0);try{const W={name:le,description:k.trim(),instructions:y.trim()||void 0,scope:u?D:void 0,source:u?w:void 0,targetPath:u?void 0:p?.path,supportingFiles:u&&E.length>0?E:void 0};let de;u?(de=await i(W),de&&(f(null),J([]),m(le))):(de=await o(le,W),de&&(F(k.trim()),Q(y.trim()))),de?B.success(s(u?"settings.skills.page.toast.skillCreated":"settings.skills.page.toast.skillUpdated")):B.error(s(u?"settings.skills.page.toast.createSkillFailed":"settings.skills.page.toast.updateSkillFailed"))}catch(W){console.error("Error saving skill:",W),B.error(s("settings.skills.page.toast.saveUnexpectedError"))}finally{Z(!1)}},Le=()=>{he(null),me(""),xe(""),be(""),X(!0)},$e=async le=>{if(he(le),me(le),u){const de=E.find(Ne=>Ne.path===le)?.content||"";xe(de),be(de),X(!0);return}if(n){ve(!0),X(!0);try{const{readSupportingFile:W}=_s.getState(),de=await W(n,le);xe(de||""),be(de||"")}catch{B.error(s("settings.skills.page.toast.loadFileContentFailed")),xe(""),be("")}finally{ve(!1)}}},Be=async()=>{if(!se.trim()){B.error(s("settings.skills.page.toast.fileNameRequired"));return}const le=se.trim(),W=we!==null;if(u){if(W)J(Ee=>Ee.map(Ce=>Ce.path===we?{path:le,content:oe}:Ce)),B.success(s("settings.skills.page.toast.fileUpdated",{path:le}));else{if(E.some(Ee=>Ee.path===le)){B.error(s("settings.skills.page.toast.fileExists"));return}J(Ee=>[...Ee,{path:le,content:oe}]),B.success(s("settings.skills.page.toast.fileAdded",{path:le}))}X(!1),he(null);return}if(!n){B.error(s("settings.skills.page.toast.noSkillSelected"));return}const{writeSupportingFile:de}=_s.getState();if(await de(n,le,oe)){B.success(W?s("settings.skills.page.toast.fileUpdated",{path:le}):s("settings.skills.page.toast.fileCreated",{path:le})),X(!1),he(null);const Ee=await r(n);Ee&&L(Ee.sources.md.supportingFiles||[])}else B.error(s(W?"settings.skills.page.toast.updateFileFailed":"settings.skills.page.toast.createFileFailed"))},Oe=le=>{if(u){J(W=>W.filter(de=>de.path!==le)),B.success(s("settings.skills.page.toast.fileRemoved",{path:le}));return}n&&re(le)},Ue=async()=>{if(!te||!n)return;U(!0);const{deleteSupportingFile:le}=_s.getState();if(await le(n,te)){B.success(s("settings.skills.page.toast.fileDeleted",{path:te}));const de=await r(n);de&&L(de.sources.md.supportingFiles||[]),re(null)}else B.error(s("settings.skills.page.toast.deleteFileFailed"));U(!1)};return!n&&!c||S?t.jsx("div",{className:"flex h-full items-center justify-center px-4",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(M,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.skills.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.skills.page.empty.description")})]})}):H?t.jsx("div",{className:"flex h-full items-center justify-center px-4",children:t.jsx("div",{className:"text-center text-muted-foreground",children:t.jsx("p",{className:"typography-body",children:s("settings.skills.page.loading.details")})})}):t.jsxs(Jt,{outerClassName:"h-full",className:"w-full",children:[t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate flex items-center gap-2",children:u?s("settings.skills.page.title.newSkill"):n}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:p?s("settings.skills.page.subtitle.skillLocation",{location:ue(Jn(p.scope,p.source))}):s("settings.skills.page.subtitle.newSkill")})]})}),t.jsxs("div",{"data-settings-item":"skills.basic-information",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.skills.page.section.basicInformation")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[u&&t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.skills.page.field.skillNameLocation")}),t.jsx("span",{className:"typography-meta text-muted-foreground ml-2",children:s("settings.skills.page.field.skillNameHint")}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx(it,{value:g,onChange:le=>x(le.target.value.toLowerCase().replace(/\s+/g,"-")),placeholder:s("settings.skills.page.field.skillNamePlaceholder"),className:"h-7 w-40 px-2"}),t.jsxs(Ft,{value:Jn(D,w),onValueChange:le=>{const W=Ll(le);N(W.scope),A(W.source==="agents"?"agents":"opencode")},children:[t.jsxs(Lt,{className:"w-fit gap-1.5",children:[D==="user"?t.jsx(M,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"folder",className:"h-3.5 w-3.5"}),w==="agents"?t.jsx(M,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:ue(Jn(D,w))})]}),t.jsx(Ot,{align:"start",children:Wr.map(le=>t.jsx(ht,{value:le.value,children:t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[le.scope==="user"?t.jsx(M,{name:"user-3",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"folder",className:"h-3.5 w-3.5"}),le.source==="agents"?t.jsx(M,{name:"robot-2",className:"h-3.5 w-3.5"}):null,t.jsx("span",{children:ue(le.value)})]}),t.jsx("span",{className:"typography-micro text-muted-foreground ml-6",children:Me(le.value)})]})},le.value))})]})]})]}),t.jsxs("div",{className:"py-1.5",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[s("settings.common.field.description")," ",t.jsx("span",{className:"text-[var(--status-error)]",children:"*"})]}),t.jsx("span",{className:"typography-meta text-muted-foreground ml-2",children:s("settings.skills.page.field.descriptionHint")}),t.jsx("div",{className:"mt-1.5",children:t.jsx(ps,{value:k,onChange:le=>Ae(le.target.value),placeholder:s("settings.skills.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] max-h-32 bg-transparent",disabled:h})})]})]})]}),t.jsxs("div",{"data-settings-item":"skills.instructions",className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center justify-between gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.skills.page.section.instructions")}),t.jsx(_g,{currentMode:I==="preview"?"preview":"edit",onToggle:()=>v(le=>le==="preview"?"edit":"preview")})]}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsx("div",{className:ce("overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",Nh),children:I==="preview"?t.jsx(Jt,{outerClassName:"h-full",className:"h-full",children:t.jsx("div",{className:"min-h-full px-4 py-3",children:t.jsx(jr,{content:z,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})}):t.jsx(bo,{value:z,onChange:Pe,readOnly:h,extensions:ke,className:"h-full",enableSearch:!0})})})]}),t.jsxs("div",{"data-settings-item":"skills.supporting-files",className:"mb-2",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.skills.page.section.supportingFiles")}),t.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:Le,disabled:h,children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"})," ",s("settings.skills.page.actions.addFile")]})]}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:(()=>{const le=u?E:b;return le.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground py-1.5",children:s("settings.skills.page.supportingFiles.empty")}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:le.map(W=>t.jsxs("div",{className:"flex items-center gap-2 py-1.5 cursor-pointer group",onClick:()=>$e(W.path),children:[t.jsx(M,{name:"file",className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:W.path}),u&&t.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:s("settings.skills.page.badge.pending")}),!h&&t.jsx(G,{size:"sm",variant:"ghost",className:"h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity",onClick:de=>{de.stopPropagation(),Oe(W.path)},children:t.jsx(M,{name:"delete-bin",className:"h-3 w-3"})})]},W.path))})})()})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(G,{onClick:Re,disabled:h||_||!ee,size:"xs",className:"!font-normal",children:s(_?"settings.common.actions.saving":u?"settings.skills.page.actions.createSkill":"settings.common.actions.saveChanges")})})]}),t.jsx(Ut,{open:te!==null,onOpenChange:le=>{!le&&!ge&&re(null)},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.skills.page.deleteFileDialog.title")}),t.jsx(qt,{children:s("settings.skills.page.deleteFileDialog.description",{path:te??""})})]}),t.jsxs(Yt,{children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>re(null),disabled:ge,children:s("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",variant:"destructive",onClick:Ue,disabled:ge,children:s("settings.common.actions.delete")})]})]})}),t.jsx(Ut,{open:ie,onOpenChange:le=>{X(le),le||he(null)},children:t.jsxs(Bt,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[t.jsxs(_t,{className:"flex-shrink-0",children:[t.jsx(Vt,{children:s(we?"settings.skills.page.fileDialog.titleEdit":"settings.skills.page.fileDialog.titleAdd")}),t.jsx(qt,{children:s(we?"settings.skills.page.fileDialog.descriptionEdit":"settings.skills.page.fileDialog.descriptionAdd")})]}),Ie?t.jsx("div",{className:"flex-1 flex items-center justify-center py-8",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.skills.page.loading.fileContent")})}):t.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col pt-2",children:[t.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:s("settings.skills.page.fileDialog.field.filePath")}),t.jsx(it,{value:se,onChange:le=>me(le.target.value),placeholder:s("settings.skills.page.fileDialog.field.filePathPlaceholder"),className:"text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]",disabled:we!==null}),!we&&t.jsx("p",{className:"typography-micro text-muted-foreground",children:s("settings.skills.page.fileDialog.field.filePathHint")})]}),t.jsxs("div",{className:"space-y-2 flex-1 min-h-0 flex flex-col",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground flex-shrink-0",children:s("settings.skills.page.fileDialog.field.content")}),t.jsx("div",{className:"h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",children:t.jsx(bo,{value:oe,onChange:xe,extensions:De,className:"h-full",enableSearch:!0})})]})]}),t.jsxs(Yt,{className:"mt-4",children:[t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>{X(!1),he(null)},children:s("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",onClick:Be,disabled:Ie||!ne,children:s(we?"settings.common.actions.saveChanges":"settings.skills.page.actions.createFile")})]})]})})]})},wo=s=>{const e=rt.c(2),{view:n}=s,a=n===void 0?"installed":n;let r;return e[0]!==a?(r=a==="catalog"?t.jsx(jh,{}):t.jsx(Ch,{}),e[0]=a,e[1]=r):r=e[1],r};function Ph(){}const Ih=s=>{const e=rt.c(38),{onItemSelect:n}=s,{t:a}=dt(),r=as(Dh),i=Ke(Ah),o=Ke(Eh),{currentTheme:d}=Ua();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=gs(),e[0]=c):c=e[0];const f=c,m=Mh;let p,u;e[1]!==r||e[2]!==i||e[3]!==o?(p=()=>{if(r.length===0){i!==null&&o(null);return}i&&r.some(y=>y.id===i)||o(r[0].id)},u=[r,i,o],e[1]=r,e[2]=i,e[3]=o,e[4]=p,e[5]=u):(p=e[4],u=e[5]),l.useEffect(p,u);let S;e[6]===Symbol.for("react.memo_cache_sentinel")?(S=ce("border-b px-3","pt-4 pb-3"),e[6]=S):S=e[6];let h;e[7]!==a?(h=a("settings.page.projects.title"),e[7]=a,e[8]=h):h=e[8];let g;e[9]!==h?(g=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:h}),e[9]=h,e[10]=g):g=e[10];let x;e[11]!==r.length||e[12]!==a?(x=a("settings.projects.sidebar.total",{count:r.length}),e[11]=r.length,e[12]=a,e[13]=x):x=e[13];let D;e[14]!==x?(D=t.jsx("span",{className:"typography-meta text-muted-foreground",children:x}),e[14]=x,e[15]=D):D=e[15];let N;e[16]!==a?(N=!f&&t.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:m,"aria-label":a("settings.projects.sidebar.actions.addProject"),children:t.jsx(M,{name:"add",className:"size-4"})}),e[16]=a,e[17]=N):N=e[17];let w;e[18]!==D||e[19]!==N?(w=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[D,N]}),e[18]=D,e[19]=N,e[20]=w):w=e[20];let A;e[21]!==w||e[22]!==g?(A=t.jsxs("div",{className:S,children:[g,w]}),e[21]=w,e[22]=g,e[23]=A):A=e[23];let k;if(e[24]!==d||e[25]!==n||e[26]!==r||e[27]!==i||e[28]!==o){let y;e[30]!==d||e[31]!==n||e[32]!==i||e[33]!==o?(y=P=>{const z=P.id===i,R=P.icon?Rd[P.icon]:null,I=P.color?yl[P.color]??null:null,v=R?t.jsx(M,{name:R,className:ce("h-4 w-4",z?"text-foreground":"text-muted-foreground/70"),style:I?{color:I}:void 0}):t.jsx(M,{name:"folder",className:ce("h-4 w-4",z?"text-foreground":"text-muted-foreground/70"),style:I?{color:I}:void 0}),b=P.iconImage?t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:P.iconBackground?{backgroundColor:P.iconBackground}:void 0,children:t.jsx(bl,{project:P,options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:v})}):v;return t.jsx(Mr,{title:P.label||P.path,icon:b,selected:z,onSelect:()=>{o(P.id),n?.()}},P.id)},e[30]=d,e[31]=n,e[32]=i,e[33]=o,e[34]=y):y=e[34],k=r.map(y),e[24]=d,e[25]=n,e[26]=r,e[27]=i,e[28]=o,e[29]=k}else k=e[29];let j;return e[35]!==A||e[36]!==k?(j=t.jsx(Tl,{variant:"background",header:A,children:k}),e[35]=A,e[36]=k,e[37]=j):j=e[37],j};function Dh(s){return s.projects}function Ah(s){return s.settingsProjectsSelectedId}function Eh(s){return s.setSettingsProjectsSelectedId}function Mh(){xl.requestDirectoryDialog()}const Rh=({projectRef:s=null})=>{const{t:e}=dt(),{isMobile:n,isTablet:a}=Cs(),r=n||a,i=as(b=>b.getActiveProject()),o=s?.path??i?.path??null,d=Ps(b=>b.getWorktreeMetadata),c=Td(),f=vs(b=>b.homeDirectory),[m,p]=l.useState([]),[u,S]=l.useState(!1),[h,g]=l.useState(null),[x,D]=l.useState([]),[N,w]=l.useState(!1),A=l.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!o?null:{id:i.id,path:o},[i?.id,o,s?.id,s?.path]),k=l.useCallback(async()=>{if(!(!A||h===!1))try{const b=await ii(A);D(b)}catch{}},[A,h]);l.useEffect(()=>{if(!o)return;let b=!1;return g(null),(async()=>{try{const L=await Fd(o);if(b)return;g(L)}catch{}})(),()=>{b=!0}},[o]),l.useEffect(()=>{if(!A){D([]),w(!1);return}if(h===!1){D([]),w(!1);return}let b=!1;return w(!0),D([]),(async()=>{try{const L=await ii(A);if(b)return;D(L)}catch{}finally{b||w(!1)}})(),()=>{b=!0}},[A,h]),l.useEffect(()=>{if(!A)return;let b=!1;return S(!0),(async()=>{try{const L=await vl(A);b||p(L.length>0?L:[""])}catch{b||p([""])}finally{b||S(!1)}})(),()=>{b=!0}},[A]);const j=l.useCallback((b,L)=>{p(E=>{const J=[...E];return J[b]=L,J})},[]),y=l.useCallback(()=>{p(b=>[...b,""])},[]),P=l.useCallback(async b=>{if(!A)return;const L=b.filter(E=>E.trim().length>0);await Ld(A,L)},[A]),z=l.useCallback(b=>{p(L=>{const E=L.filter((J,_)=>_!==b);return P(E),E.length>0?E:[""]})},[P]),R=l.useCallback(()=>{P(m)},[P,m]),I=l.useCallback(b=>{const L=F=>F.replace(/\\/g,"/").replace(/\/+$/,""),E=L(b.path),J=c.filter(F=>{const V=d(F.id);if(V?.path&&L(V.path)===E)return!0;const Q=F.directory;return!!(Q&&L(Q)===E)}),_=new Set(J.map(F=>F.id)),Z=F=>{const V=c.filter(ie=>{const X=ie.parentID;return X&&F.has(X)});if(V.length===0)return[];const Q=new Set(V.map(ie=>ie.id));return[...V,...Z(Q)]},H=Z(_),T=new Set,Y=[...J,...H].filter(F=>T.has(F.id)?!1:(T.add(F.id),!0));xl.requestDelete({sessions:Y,mode:"worktree",worktree:b})},[c,d]),v=l.useMemo(()=>c.map(b=>b.id).join(","),[c]);return l.useEffect(()=>{h&&o&&k()},[v,h,o,k]),o?h===!1?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.worktrees.state.gitOnly")}):t.jsxs("div",{className:"max-w-[44rem] space-y-5",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-normal text-foreground",children:e("settings.openchamber.worktrees.setup.title")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsxs(Et,{sideOffset:8,className:"max-w-xs",children:[e("settings.openchamber.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",e("settings.openchamber.worktrees.setup.tooltipSuffix")]})]})]})}),u?t.jsx("p",{className:"typography-meta text-muted-foreground px-1",children:e("settings.openchamber.worktrees.setup.loading")}):t.jsxs("div",{className:"space-y-2 px-1",children:[m.map((b,L)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(it,{value:b,onChange:E=>j(L,E.target.value),onBlur:R,placeholder:e("settings.openchamber.worktrees.setup.commandPlaceholder"),className:"h-7 w-[30rem] max-w-full font-mono text-xs"}),t.jsx("button",{type:"button",onClick:()=>{z(L)},className:"flex-shrink-0 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("settings.openchamber.worktrees.setup.removeCommandAria"),children:t.jsx(M,{name:"close",className:"h-4 w-4"})})]},L)),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:y,children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),e("settings.openchamber.worktrees.setup.addCommand")]})]})]}),t.jsxs("div",{className:"space-y-2 border-t border-border/40 pt-4",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-normal text-foreground",children:e("settings.openchamber.worktrees.list.title")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:e("settings.openchamber.worktrees.list.tooltip")})]})]})}),N?t.jsx("p",{className:"typography-meta text-muted-foreground px-1",children:e("settings.openchamber.worktrees.list.loading")}):x.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70 px-1",children:e("settings.openchamber.worktrees.list.empty")}):t.jsx("div",{className:"space-y-1 px-1 max-w-[32.5rem]",children:x.map(b=>t.jsxs("div",{className:"group flex w-full items-center gap-2 py-1.5",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("p",{className:"typography-meta text-foreground truncate min-w-0",children:b.label||b.branch||e("settings.openchamber.worktrees.list.detachedHead")}),t.jsx("span",{className:"typography-micro text-muted-foreground/60 px-1.5 py-[1px] rounded bg-sidebar-accent/40 flex-shrink-0 self-center leading-none",children:"OpenCode"})]}),t.jsx("p",{className:"typography-micro text-muted-foreground/60 truncate",children:Od(b.path,f)})]}),t.jsx("button",{type:"button",onClick:()=>I(b),className:ce("flex-shrink-0 flex h-7 w-7 items-center justify-center rounded text-muted-foreground/50 hover:text-destructive hover:bg-destructive/10 transition-opacity focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",r?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":e("settings.openchamber.worktrees.list.deleteWorktreeAria",{name:b.branch||b.label||b.path}),children:t.jsx(M,{name:"delete-bin",className:"h-4 w-4"})})]},b.path))})]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.worktrees.state.selectProject")})},No=(s,e)=>e.updatedAtMs-s.updatedAtMs,cs=rn((s,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){s({isLoading:!0,error:null});try{const[n,a]=await Promise.all([Ud(),li()]),r={};for(const i of a.sort(No))r[i.id]=i;e().listenerReady||await Bd(i=>{s(o=>({statusesById:{...o.statusesById,[i.id]:i}}))}),s({instances:n.instances,statusesById:r,isLoading:!1,initialized:!0,listenerReady:!0})}catch(n){s({isLoading:!1,error:n instanceof Error?n.message:String(n)})}}},loadImports:async()=>{if(!e().isImportsLoading){s({isImportsLoading:!0,error:null});try{const n=await $d();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await li(),a={};for(const r of n.sort(No))a[r.id]=r;s({statusesById:a})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await Kd({instances:n}),s({instances:n,isSaving:!1}),await e().refreshStatuses()}catch(a){throw s({isSaving:!1,error:a instanceof Error?a.message:String(a)}),a}},upsertInstance:async n=>{const a=e().instances,r=a.some(i=>i.id===n.id)?a.map(i=>i.id===n.id?n:i):[n,...a];await e().setInstances(r)},createFromCommand:async(n,a,r)=>{const i=Vd(n,a);r&&r.trim()&&(i.nickname=r.trim()),await e().upsertInstance(i)},removeInstance:async n=>{await oi(n).catch(()=>{});const a=e().instances.filter(r=>r.id!==n);await e().setInstances(a),s(r=>{const i={...r.statusesById};return delete i[n],{statusesById:i}})},connect:async n=>{s({error:null});try{await zd(n),await e().refreshStatuses()}catch(a){throw s({error:a instanceof Error?a.message:String(a)}),a}},disconnect:async n=>{s({error:null});try{await oi(n),await e().refreshStatuses()}catch(a){throw s({error:a instanceof Error?a.message:String(a)}),a}},retry:async n=>{await e().connect(n)},getStatus:n=>e().statusesById[n]||null,clearError:()=>s({error:null})})),Kl=[{key:"play",label:"Play",Icon:"play"},{key:"build",label:"Build",Icon:"hammer"},{key:"lint",label:"Lint",Icon:"checkbox-circle"},{key:"terminal",label:"Terminal",Icon:"terminal-box"},{key:"tools",label:"Tools",Icon:"tools"},{key:"bug",label:"Bug",Icon:"bug"},{key:"flask",label:"Flask",Icon:"flask"},{key:"rocket",label:"Rocket",Icon:"rocket"},{key:"code",label:"Code",Icon:"code"},{key:"server",label:"Server",Icon:"server"},{key:"branch",label:"Branch",Icon:"git-branch"},{key:"search",label:"Search",Icon:"search"},{key:"settings",label:"Settings",Icon:"settings-3"},{key:"brain",label:"Brain",Icon:"brain-ai-3"},{key:"stack",label:"Stack",Icon:"stack"},{key:"robot",label:"Robot",Icon:"robot-2"},{key:"command",label:"Command",Icon:"command"},{key:"file",label:"File",Icon:"file-text"}],Th=Object.fromEntries(Kl.map(s=>[s.key,s.Icon])),Fh="openchamber:project-actions-updated",Lh=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},Tv=(s,e)=>`${Lh(s)}::${e}`,Oh=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},ko=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},zh=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=ko(e.localPort),a=ko(e.remotePort);if(!n||!a)return null;const r=Oh(e.localHost||s.localForward.bindHost||"127.0.0.1"),i=(e.remoteHost||"127.0.0.1").trim(),o=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${o} - ${r}:${n} -> ${i}:${a}`,url:`http://${r}:${n}`}},$l=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const a of n.portForwards){const r=zh(n,a);r&&e.push(r)}return e},Fv=(s,e)=>{const n=(s||"").trim();return n&&$l(e).find(i=>i.id===n)?.url||null},Kh=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,$h=()=>({id:Kh(),name:"",command:"",icon:"play"}),Uh=({projectRef:s})=>{const{t:e}=dt(),n=l.useMemo(()=>fs(),[]),a=cs(y=>y.instances),r=cs(y=>y.load),[i,o]=l.useState([]),[d,c]=l.useState(!1),[f,m]=l.useState(!1),[p,u]=l.useState(null),[S,h]=l.useState({});l.useEffect(()=>{n&&r().catch(()=>{})},[n,r]),l.useEffect(()=>{let y=!1;return c(!0),(async()=>{try{const P=await _d(s);if(y)return;o(P.actions),u(JSON.stringify({actions:P.actions}))}catch{if(y)return;o([]),u(JSON.stringify({actions:[]}))}finally{y||c(!1)}})(),()=>{y=!0}},[s]);const g=l.useMemo(()=>n?$l(a):[],[a,n]),x=l.useMemo(()=>i.some(P=>P.name.trim().length===0||P.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[i,e]),D=l.useMemo(()=>p===null?!1:p!==JSON.stringify({actions:i}),[i,p]),N=l.useCallback(()=>{const y=$h();o(P=>[...P,y]),h(P=>({...P,[y.id]:!0}))},[]),w=l.useCallback(y=>{o(P=>P.filter(z=>z.id!==y)),h(P=>{const z={...P};return delete z[y],z})},[]),A=l.useCallback((y,P)=>{o(z=>z.map(R=>R.id===y?P(R):R))},[]),k=l.useCallback(async()=>{if(x){B.error(x);return}m(!0);try{if(!await Hd(s,{actions:i,primaryActionId:null})){B.error(e("settings.projects.actions.toast.saveFailed"));return}u(JSON.stringify({actions:i})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Fh,{detail:{projectId:s.id}})),B.success(e("settings.projects.actions.toast.saved"))}catch{B.error(e("settings.projects.actions.toast.saveFailed"))}finally{m(!1)}},[i,s,e,x]),j=!f&&!d&&D&&!x;return t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"mb-1 flex items-start justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:e("settings.projects.actions.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.description")})]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:N,children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]})]}),t.jsxs("section",{className:"pb-2 pt-0 space-y-2",children:[d?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):i.length===0?t.jsx("div",{className:"py-2",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")})}):t.jsx("div",{className:"space-y-0 max-w-[30rem]",children:i.map(y=>{const P=y.icon||"play",z=Th[P]||"play",R=S[y.id]??!1,I=y.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(gn,{open:R,onOpenChange:v=>{h(b=>({...b,[y.id]:v}))},className:ce("py-1.5"),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(hn,{className:"group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[R?t.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(M,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(M,{name:z,className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:I})})})]}),t.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>w(y.id),children:t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(fn,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-2 pb-6 pl-3 pr-3",children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsxs(us,{children:[t.jsx(ds,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]","aria-label":e("settings.projects.actions.field.selectIconAria"),children:t.jsx(M,{name:z,className:"h-4 w-4"})})}),t.jsx(ms,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:Kl.map(v=>{const b=v.Icon,L=(y.icon||"play")===v.key;return t.jsx("button",{type:"button",onClick:()=>A(y.id,E=>({...E,icon:v.key})),className:ce("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",L&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:v.label}),children:t.jsx(M,{name:b,className:"h-4 w-4"})},v.key)})})})]}),t.jsx(it,{value:y.name,onChange:v=>A(y.id,b=>({...b,name:v.target.value})),placeholder:e("settings.projects.actions.field.actionNamePlaceholder"),className:"h-7 max-w-[14rem]"})]}),t.jsxs("div",{className:"py-1",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.command")}),t.jsx(ps,{value:y.command,onChange:v=>A(y.id,b=>({...b,command:v.target.value})),placeholder:e("settings.projects.actions.field.commandPlaceholder"),className:"min-h-[88px] max-w-[30rem] font-mono text-xs"})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.projects.actions.field.autoOpenUrl")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2",role:"button",tabIndex:0,"aria-pressed":y.autoOpenUrl===!0,onClick:()=>A(y.id,v=>({...v,...v.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:v=>{(v.key===" "||v.key==="Enter")&&(v.preventDefault(),A(y.id,b=>({...b,...b.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(It,{checked:y.autoOpenUrl===!0,onChange:v=>A(y.id,b=>({...b,...v?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:I})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),y.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(it,{value:y.openUrl||"",onChange:v=>A(y.id,b=>({...b,openUrl:v.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:e("settings.projects.actions.field.overrideUrlTooltip")})]})]}),n?t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.desktopSshForward")}),g.length>0?t.jsxs(Ft,{value:y.desktopOpenSshForward&&g.some(v=>v.id===y.desktopOpenSshForward)?y.desktopOpenSshForward:"__none__",onValueChange:v=>{A(y.id,b=>({...b,...v==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:v}}))},children:[t.jsx(Lt,{className:"h-7 w-full max-w-[30rem]",children:t.jsx(Kt,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),g.map(v=>t.jsx(ht,{value:v.id,children:v.label},v.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},y.id)})}),t.jsxs("div",{className:"pt-3",children:[x?t.jsx("p",{className:"typography-meta mb-2 text-[var(--status-warning)]",children:x}):null,t.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:k,disabled:!j,children:e(f?"settings.common.actions.saving":"settings.projects.actions.actions.save")})]})]})]})},Bh=()=>{const s=rt.c(197),{t:e}=dt(),n=as(Vh),a=as(_h),r=as(Hh),i=as(Wh),o=as(qh),d=Ke(Gh),c=Ke(Jh),{currentTheme:f}=Ua();let m;e:{if(!d){m=null;break e}let ct;s[0]!==n||s[1]!==d?(ct=n.find(St=>St.id===d)??null,s[0]=n,s[1]=d,s[2]=ct):ct=s[2],m=ct}const p=m;let u,S;s[3]!==n||s[4]!==d||s[5]!==c?(u=()=>{if(n.length===0){c(null);return}d&&n.some(ct=>ct.id===d)||c(n[0].id)},S=[n,d,c],s[3]=n,s[4]=d,s[5]=c,s[6]=u,s[7]=S):(u=s[6],S=s[7]),l.useEffect(u,S);const[h,g]=l.useState(""),[x,D]=l.useState(null),[N,w]=l.useState(null),[A,k]=l.useState(null),[j,y]=l.useState(!1),[P,z]=l.useState(!1),[R,I]=l.useState(!1),[v,b]=l.useState(!1),[L,E]=l.useState(null),[J,_]=l.useState(null),[Z,H]=l.useState(!1),T=l.useRef(null);let Y;s[8]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>{E(null),_(Qh)},s[8]=Y):Y=s[8];const F=Y;let V;e:{if(!p){V=null;break e}let ct;s[9]!==p.id||s[10]!==p.path?(ct={id:p.id,path:p.path},s[9]=p.id,s[10]=p.path,s[11]=ct):ct=s[11],V=ct}const Q=V;let ie,X;s[12]!==p?(ie=()=>{if(!p){g(""),D(null),w(null),k(null);return}g(p.label??""),D(p.icon??null),w(p.color??null),k(p.iconBackground??null),b(!1),F(),H(!1)},X=[p,F],s[12]=p,s[13]=ie,s[14]=X):(ie=s[13],X=s[14]),l.useEffect(ie,X);let se,me;s[15]===Symbol.for("react.memo_cache_sentinel")?(se=()=>()=>{F()},me=[F],s[15]=se,s[16]=me):(se=s[15],me=s[16]),l.useEffect(se,me);let oe;s[17]!==N||s[18]!==x||s[19]!==A||s[20]!==h||s[21]!==v||s[22]!==L||s[23]!==p?(oe=!!p&&(h.trim()!==(p?.label??"").trim()||x!==(p?.icon??null)||N!==(p?.color??null)||A!==(p?.iconBackground??null)||v||!!L),s[17]=N,s[18]=x,s[19]=A,s[20]=h,s[21]=v,s[22]=L,s[23]=p,s[24]=oe):oe=s[24];const xe=oe;let we;s[25]!==N||s[26]!==x||s[27]!==A||s[28]!==h||s[29]!==v||s[30]!==L||s[31]!==i||s[32]!==p||s[33]!==e||s[34]!==a||s[35]!==r?(we=async()=>{if(!p)return;if(L){y(!0);const St=await r(p.id,L);if(y(!1),!St.ok){B.error(St.error||e("settings.projects.page.toast.uploadIconFailed"));return}B.success(e("settings.projects.page.toast.iconUpdated")),F(),b(!1)}const ct=v&&!!p.iconImage;if(ct){z(!0);const St=await i(p.id);if(z(!1),!St.ok){B.error(St.error||e("settings.projects.page.toast.removeIconFailed"));return}B.success(e("settings.projects.page.toast.iconRemoved")),b(!1),k(null)}a(p.id,{label:h.trim(),icon:x,color:N,iconBackground:ct?null:A})},s[25]=N,s[26]=x,s[27]=A,s[28]=h,s[29]=v,s[30]=L,s[31]=i,s[32]=p,s[33]=e,s[34]=a,s[35]=r,s[36]=we):we=s[36];const he=we,Ie=N?yl[N]??null:null,ve=!!p?.iconImage,ye=!!(L&&J),be=p?.iconImage?.source==="custom",te=ve&&!v||ye,re=te,U=!Z&&(ye||!!(p&&ve&&!v));let ee;s[37]!==j||s[38]!==p?(ee=ct=>{!p||!ct||j||(b(!1),H(!1),E(ct),_(St=>(St&&URL.revokeObjectURL(St),URL.createObjectURL(ct))))},s[37]=j,s[38]=p,s[39]=ee):ee=s[39];const ne=ee;let ue;s[40]!==ye||s[41]!==re||s[42]!==ve||s[43]!==P||s[44]!==p?(ue=()=>{!p||!re||P||(ye&&F(),b(!!ve),H(!1))},s[40]=ye,s[41]=re,s[42]=ve,s[43]=P,s[44]=p,s[45]=ue):ue=s[45];const Me=ue;let ke;s[46]!==o||s[47]!==R||s[48]!==p||s[49]!==e?(ke=async()=>{!p||R||(F(),b(!1),H(!1),I(!0),o(p.id).then(ct=>{if(!ct.ok){B.error(ct.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(ct.skipped){B.success(e("settings.projects.page.toast.customIconAlreadySet"));return}B.success(e("settings.projects.page.toast.iconDiscovered"))}).finally(()=>{I(!1)}))},s[46]=o,s[47]=R,s[48]=p,s[49]=e,s[50]=ke):ke=s[50];const De=ke;if(!p){let ct;s[51]!==e?(ct=e("settings.projects.page.empty.noProjects"),s[51]=e,s[52]=ct):ct=s[52];let St;return s[53]!==ct?(St=t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsx("div",{className:"mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:ct})})}),s[53]=ct,s[54]=St):St=s[54],St}let Ae;s[55]!==p.label||s[56]!==e?(Ae=p.label??e("settings.projects.page.title.default"),s[55]=p.label,s[56]=e,s[57]=Ae):Ae=s[57];let Pe;s[58]!==Ae?(Pe=t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:Ae}),s[58]=Ae,s[59]=Pe):Pe=s[59];let Re;s[60]!==p.path?(Re=t.jsx("p",{className:"typography-meta text-muted-foreground truncate",title:p.path,children:p.path}),s[60]=p.path,s[61]=Re):Re=s[61];let Le;s[62]!==Pe||s[63]!==Re?(Le=t.jsx("div",{className:"mb-4 flex items-center justify-between gap-4",children:t.jsxs("div",{className:"min-w-0",children:[Pe,Re]})}),s[62]=Pe,s[63]=Re,s[64]=Le):Le=s[64];let $e;s[65]!==e?($e=e("settings.projects.page.field.projectName"),s[65]=e,s[66]=$e):$e=s[66];let Be;s[67]!==$e?(Be=t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:$e})}),s[67]=$e,s[68]=Be):Be=s[68];let Oe;s[69]===Symbol.for("react.memo_cache_sentinel")?(Oe=ct=>g(ct.target.value),s[69]=Oe):Oe=s[69];let Ue;s[70]!==e?(Ue=e("settings.projects.page.field.projectNamePlaceholder"),s[70]=e,s[71]=Ue):Ue=s[71];let le;s[72]!==h||s[73]!==Ue?(le=t.jsx("div",{className:"mt-1.5 flex min-w-0 items-center gap-2",children:t.jsx(it,{value:h,onChange:Oe,placeholder:Ue,className:"h-7 min-w-0 w-full sm:max-w-[19rem]"})}),s[72]=h,s[73]=Ue,s[74]=le):le=s[74];let W;s[75]!==Be||s[76]!==le?(W=t.jsxs("div",{"data-settings-item":"projects.name",className:"py-1.5",children:[Be,le]}),s[75]=Be,s[76]=le,s[77]=W):W=s[77];let de;s[78]!==e?(de=e("settings.projects.page.field.accentColor"),s[78]=e,s[79]=de):de=s[79];let Ne;s[80]!==de?(Ne=t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:de})}),s[80]=de,s[81]=Ne):Ne=s[81];let Ee;s[82]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>w(null),s[82]=Ee):Ee=s[82];const Ce=N===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let He;s[83]!==Ce?(He=ce("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ce),s[83]=Ce,s[84]=He):He=s[84];let q;s[85]!==e?(q=e("settings.projects.page.field.none"),s[85]=e,s[86]=q):q=s[86];let $;s[87]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx(M,{name:"close",className:"h-4 w-4 text-muted-foreground"}),s[87]=$):$=s[87];let fe;s[88]!==He||s[89]!==q?(fe=t.jsx("button",{type:"button",onClick:Ee,className:He,title:q,children:$}),s[88]=He,s[89]=q,s[90]=fe):fe=s[90];let O;s[91]!==N?(O=Wd.map(ct=>t.jsx("button",{type:"button",onClick:()=>w(ct.key),className:ce("h-7 w-7 rounded-md border transition-colors",N===ct.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:ct.cssVar},title:ct.label},ct.key)),s[91]=N,s[92]=O):O=s[92];let Fe;s[93]!==fe||s[94]!==O?(Fe=t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2",children:[fe,O]}),s[93]=fe,s[94]=O,s[95]=Fe):Fe=s[95];let Je;s[96]!==Ne||s[97]!==Fe?(Je=t.jsxs("div",{"data-settings-item":"projects.accent-color",className:"py-1.5",children:[Ne,Fe]}),s[96]=Ne,s[97]=Fe,s[98]=Je):Je=s[98];let Xe;s[99]!==e?(Xe=e("settings.projects.page.field.projectIcon"),s[99]=e,s[100]=Xe):Xe=s[100];let et;s[101]!==Xe?(et=t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:Xe})}),s[101]=Xe,s[102]=et):et=s[102];let at;s[103]!==ne?(at=t.jsx("input",{ref:T,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:ct=>{const St=ct.target.files?.[0]??null;ne(St),ct.currentTarget.value=""}}),s[103]=ne,s[104]=at):at=s[104];let lt;s[105]===Symbol.for("react.memo_cache_sentinel")?(lt=()=>D(null),s[105]=lt):lt=s[105];const Ze=x===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let We;s[106]!==Ze?(We=ce("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ze),s[106]=Ze,s[107]=We):We=s[107];let pt;s[108]!==e?(pt=e("settings.projects.page.field.none"),s[108]=e,s[109]=pt):pt=s[109];let pe;s[110]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsx(M,{name:"close",className:"h-4 w-4 text-muted-foreground"}),s[110]=pe):pe=s[110];let st;s[111]!==We||s[112]!==pt?(st=t.jsx("button",{type:"button",onClick:lt,className:We,title:pt,children:pe}),s[111]=We,s[112]=pt,s[113]=st):st=s[113];let nt;s[114]!==Ie||s[115]!==x?(nt=qd.map(ct=>{const St=ct.Icon;return t.jsx("button",{type:"button",onClick:()=>D(ct.key),className:ce("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",x===ct.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:ct.label,children:t.jsx(M,{name:St,className:"w-4 h-4",style:Ie&&x===ct.key?{color:Ie}:void 0})},ct.key)}),s[114]=Ie,s[115]=x,s[116]=nt):nt=s[116];let Ge;s[117]!==st||s[118]!==nt?(Ge=t.jsxs("div",{className:"mt-1.5 flex max-w-[22rem] flex-wrap items-center gap-2",children:[st,nt]}),s[117]=st,s[118]=nt,s[119]=Ge):Ge=s[119];let ft;s[120]!==f||s[121]!==te||s[122]!==ye||s[123]!==A||s[124]!==J||s[125]!==p||s[126]!==U||s[127]!==e?(ft=te&&U&&t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.projects.page.field.preview")}),t.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1",children:t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:A?{backgroundColor:A}:void 0,children:ye&&J?t.jsx("img",{src:J,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>H(!0)}):p?t.jsx(bl,{project:p,options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>H(!0)}):null})})]}),s[120]=f,s[121]=te,s[122]=ye,s[123]=A,s[124]=J,s[125]=p,s[126]=U,s[127]=e,s[128]=ft):ft=s[128];let wt;s[129]!==te||s[130]!==A||s[131]!==e?(wt=te&&t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:A??"#000000",onChange:ct=>k(ct.target.value),className:"h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1","aria-label":e("settings.projects.page.field.projectIconBackgroundAria")}),t.jsx(it,{value:A??"",onChange:ct=>k(ct.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(G,{type:"button",size:"xs",variant:"outline",onClick:()=>k(null),className:"h-7 w-7 p-0","aria-label":e("settings.projects.page.field.clearIconBackgroundAria"),title:e("settings.projects.page.field.clearBackground"),disabled:!A,children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]}),s[129]=te,s[130]=A,s[131]=e,s[132]=wt):wt=s[132];let Ct;s[133]!==De||s[134]!==be||s[135]!==R||s[136]!==j||s[137]!==e?(Ct=!be&&t.jsxs(t.Fragment,{children:[t.jsx(G,{size:"xs",className:"h-6 !font-normal",onClick:()=>T.current?.click(),disabled:j,children:e(j?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(G,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{De()},disabled:R,children:e(R?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),s[133]=De,s[134]=be,s[135]=R,s[136]=j,s[137]=e,s[138]=Ct):Ct=s[138];let ae;s[139]!==Me||s[140]!==re||s[141]!==P||s[142]!==e?(ae=re&&t.jsx(G,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{Me()},disabled:P,children:e(P?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),s[139]=Me,s[140]=re,s[141]=P,s[142]=e,s[143]=ae):ae=s[143];let Ve;s[144]!==P||s[145]!==v||s[146]!==e?(Ve=v&&t.jsx(G,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>b(!1),disabled:P,children:e("settings.projects.page.actions.undoRemove")}),s[144]=P,s[145]=v,s[146]=e,s[147]=Ve):Ve=s[147];let tt;s[148]!==Ct||s[149]!==ae||s[150]!==Ve?(tt=t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[Ct,ae,Ve]}),s[148]=Ct,s[149]=ae,s[150]=Ve,s[151]=tt):tt=s[151];let Ye;s[152]!==et||s[153]!==at||s[154]!==Ge||s[155]!==ft||s[156]!==wt||s[157]!==tt?(Ye=t.jsxs("div",{"data-settings-item":"projects.icon",className:"py-1.5",children:[et,at,Ge,ft,wt,tt]}),s[152]=et,s[153]=at,s[154]=Ge,s[155]=ft,s[156]=wt,s[157]=tt,s[158]=Ye):Ye=s[158];let yt;s[159]!==W||s[160]!==Je||s[161]!==Ye?(yt=t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[W,Je,Ye]}),s[159]=W,s[160]=Je,s[161]=Ye,s[162]=yt):yt=s[162];let ze;s[163]!==xe||s[164]!==P||s[165]!==j||s[166]!==h?(ze=!xe||h.trim().length===0||j||P,s[163]=xe,s[164]=P,s[165]=j,s[166]=h,s[167]=ze):ze=s[167];let _e;s[168]!==e?(_e=e("settings.common.actions.saveChanges"),s[168]=e,s[169]=_e):_e=s[169];let ot;s[170]!==he||s[171]!==ze||s[172]!==_e?(ot=t.jsx("div",{className:"mt-0.5 px-2 py-1",children:t.jsx(G,{onClick:he,disabled:ze,size:"xs",className:"!font-normal",children:_e})}),s[170]=he,s[171]=ze,s[172]=_e,s[173]=ot):ot=s[173];let bt;s[174]!==yt||s[175]!==ot?(bt=t.jsxs("div",{className:"mb-8",children:[yt,ot]}),s[174]=yt,s[175]=ot,s[176]=bt):bt=s[176];let Mt;s[177]!==Q?(Mt=Q&&t.jsx(Uh,{projectRef:Q}),s[177]=Q,s[178]=Mt):Mt=s[178];let Qt;s[179]!==Mt?(Qt=t.jsx("div",{"data-settings-item":"projects.worktree",className:"mb-8",children:t.jsx("section",{className:"px-2 pb-2 pt-0",children:Mt})}),s[179]=Mt,s[180]=Qt):Qt=s[180];let Xt;s[181]!==e?(Xt=e("settings.projects.page.section.worktree"),s[181]=e,s[182]=Xt):Xt=s[182];let rs;s[183]!==Xt?(rs=t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:Xt})}),s[183]=Xt,s[184]=rs):rs=s[184];let Wt;s[185]!==Q?(Wt=Q&&t.jsx(Rh,{projectRef:Q}),s[185]=Q,s[186]=Wt):Wt=s[186];let Se;s[187]!==Wt?(Se=t.jsx("section",{className:"px-2 pb-2 pt-0",children:Wt}),s[187]=Wt,s[188]=Se):Se=s[188];let vt;s[189]!==rs||s[190]!==Se?(vt=t.jsxs("div",{className:"mb-8",children:[rs,Se]}),s[189]=rs,s[190]=Se,s[191]=vt):vt=s[191];let Nt;return s[192]!==Le||s[193]!==bt||s[194]!==Qt||s[195]!==vt?(Nt=t.jsx(Jt,{outerClassName:"h-full",className:"w-full bg-background",children:t.jsxs("div",{className:"mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8",children:[Le,bt,Qt,vt]})}),s[192]=Le,s[193]=bt,s[194]=Qt,s[195]=vt,s[196]=Nt):Nt=s[196],Nt};function Vh(s){return s.projects}function _h(s){return s.updateProjectMeta}function Hh(s){return s.uploadProjectIcon}function Wh(s){return s.removeProjectIcon}function qh(s){return s.discoverProjectIcon}function Gh(s){return s.settingsProjectsSelectedId}function Jh(s){return s.setSettingsProjectsSelectedId}function Qh(s){return s&&URL.revokeObjectURL(s),null}const Ul=s=>({v:1,serverUrl:s.serverUrl.trim().replace(/\/+$/,""),token:s.token.trim(),...s.label?.trim()?{label:s.label.trim()}:{}}),Yh=s=>{const e=new URLSearchParams;return e.set("v",String(s.v)),e.set("server",s.serverUrl),e.set("token",s.token),s.label&&e.set("label",s.label),`openchamber://connect?${e.toString()}`},Xh=s=>{const e=s.trim();if(!e)return null;try{const n=new URL(e);if(n.protocol!=="openchamber:"||n.hostname!=="connect")return null;const a=n.searchParams.get("v"),r=n.searchParams.get("server")?.trim()||"",i=n.searchParams.get("token")?.trim()||"",o=n.searchParams.get("label")?.trim()||"";if(a!=="1"||!r||!i)return null;try{const d=new URL(r);if(d.protocol!=="http:"&&d.protocol!=="https:")return null}catch{return null}return Ul({serverUrl:r,token:i,label:o})}catch{return null}},Tr=()=>Math.floor(2e4+Math.random()*3e4),Zh=s=>{const e=(s instanceof Error?s.message:String(s)).toLowerCase();return e.includes("address already in use")||e.includes("eaddrinuse")||e.includes("port already in use")},So=s=>{switch(s){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"}},ef=new Set(["config_resolved","auth_check","master_connecting","remote_probe","installing","updating","server_detecting","server_starting","forwarding"]),Bl=s=>!!(s&&ef.has(s)),Co=s=>s==="ready"?"bg-[var(--status-success)] animate-pulse":s==="error"?"bg-[var(--status-error)] animate-pulse":s==="degraded"||Bl(s)?"bg-[var(--status-warning)] animate-pulse":"bg-muted-foreground/40",tf=s=>s.type==="dynamic"?`${s.localHost||"127.0.0.1"}:${s.localPort||0}`:s.type==="remote"?`${s.remoteHost||"127.0.0.1"}:${s.remotePort||0} -> ${s.localHost||"127.0.0.1"}:${s.localPort||0}`:`${s.localHost||"127.0.0.1"}:${s.localPort||0} -> ${s.remoteHost||"127.0.0.1"}:${s.remotePort||0}`,sf=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:"local",localHost:"127.0.0.1",localPort:Tr(),remoteHost:"127.0.0.1",remotePort:80}),nf=s=>s.trim().replace(/\*/g,"host").replace(/\?/g,"x")||"user@host",Ks=s=>{const e=rt.c(8),{label:n,hint:a}=s;let r;e[0]!==n?(r=t.jsx("span",{children:n}),e[0]=n,e[1]=r):r=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),e[2]=i):i=e[2];let o;e[3]!==a?(o=t.jsxs(Dt,{children:[i,t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:t.jsx("div",{className:"typography-meta text-foreground",children:a})})]}),e[3]=a,e[4]=o):o=e[4];let d;return e[5]!==r||e[6]!==o?(d=t.jsxs("span",{className:"inline-flex items-center gap-1 typography-meta text-muted-foreground",children:[r,o]}),e[5]=r,e[6]=o,e[7]=d):d=e[7],d},af=s=>{switch(s){case"remote":return"settings.remoteInstances.page.forwardTypeDescription.remote";case"dynamic":return"settings.remoteInstances.page.forwardTypeDescription.dynamic";default:return"settings.remoteInstances.page.forwardTypeDescription.local"}},Po=(s,e)=>{const n=(s||"").trim();return`${!n||n==="127.0.0.1"||n==="::1"?"localhost":n}:${e||0}`},rf=s=>{const e=(s||"").trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},of=s=>{const e=s.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!e)return s;const n=Number(e[1]),a=Number.isFinite(n)?new Date(n).toISOString():e[1],r=(e[2]||"INFO").toUpperCase(),i=e[3]||"";return`[${a}] [${r}] ${i}`},lr=s=>{const e=s.trim();if(e)try{window.location.assign(e)}catch{window.location.href=e}},lf=s=>{const e=s.sshCommand.trim(),n=s.nickname?.trim(),a=s.portForwards.map(r=>({...r,localHost:r.localHost?.trim()||"127.0.0.1",localPort:typeof r.localPort=="number"?Math.max(1,Math.min(65535,Math.round(r.localPort))):void 0,remoteHost:r.remoteHost?.trim(),remotePort:typeof r.remotePort=="number"?Math.max(1,Math.min(65535,Math.round(r.remotePort))):void 0}));return{...s,sshCommand:e,...n?{nickname:n}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(s.connectionTimeoutSec||60))),localForward:{...s.localForward,bindHost:s.localForward.bindHost==="localhost"||s.localForward.bindHost==="0.0.0.0"?s.localForward.bindHost:"127.0.0.1",preferredLocalPort:typeof s.localForward.preferredLocalPort=="number"?Math.max(1,Math.min(65535,Math.round(s.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...s.remoteOpenchamber,preferredPort:typeof s.remoteOpenchamber.preferredPort=="number"?Math.max(1,Math.min(65535,Math.round(s.remoteOpenchamber.preferredPort))):void 0},portForwards:a}},cf=()=>{const{t:s}=dt(),{clientAuth:e}=Hr(),n=fs(),a=cs(K=>K.instances),r=cs(K=>K.statusesById),i=cs(K=>K.importCandidates),o=cs(K=>K.isLoading),d=cs(K=>K.isImportsLoading),c=cs(K=>K.isSaving),f=cs(K=>K.error),m=cs(K=>K.load),p=cs(K=>K.loadImports),u=cs(K=>K.refreshStatuses),S=cs(K=>K.upsertInstance),h=cs(K=>K.createFromCommand),g=cs(K=>K.removeInstance),x=cs(K=>K.connect),D=cs(K=>K.disconnect),N=cs(K=>K.retry),w=Ke(K=>K.settingsRemoteInstancesSelectedId),A=Ke(K=>K.setSettingsRemoteInstancesSelectedId),k=l.useMemo(()=>w&&a.find(K=>K.id===w)||null,[a,w]),[j,y]=l.useState(null),[P,z]=l.useState(!1),[R,I]=l.useState(!1),[v,b]=l.useState(null),[L,E]=l.useState([]),[J,_]=l.useState(null),[Z,H]=l.useState(""),[T,Y]=l.useState(!1),[F,V]=l.useState({}),[Q,ie]=l.useState(!1),[X,se]=l.useState(!1),[me,oe]=l.useState(()=>Date.now()),[xe,we]=l.useState([]),[he,Ie]=l.useState("local"),[ve,ye]=l.useState(!1),[be,te]=l.useState(!1),[re,ge]=l.useState(""),[U,ee]=l.useState(""),[ne,ue]=l.useState(""),[Me,ke]=l.useState(""),[De,Ae]=l.useState(null),[Pe,Re]=l.useState(!1),[Le,$e]=l.useState(!1),[Be,Oe]=l.useState(null),[Ue,le]=l.useState(""),[W,de]=l.useState(""),[Ne,Ee]=l.useState(""),[Ce,He]=l.useState([]),[q,$]=l.useState(!1),[fe,O]=l.useState(""),[Fe,Je]=l.useState(null),[Xe,et]=l.useState(null),[at,lt]=l.useState(null),[Ze,We]=l.useState(null),pt=l.useMemo(()=>Ce.filter(K=>!!K.revokedAt).length,[Ce]),[pe,st]=l.useState(!1),[nt,Ge]=l.useState("ssh user@example.com"),[ft,wt]=l.useState("");l.useEffect(()=>{m(),p()},[m,p]);const Ct=l.useCallback(async()=>{ye(!0),Ae(null);try{const K=await ci();we(K.hosts||[]),Ie(K.defaultHostId||"local")}catch(K){Ae(K instanceof Error?K.message:String(K))}finally{ye(!1)}},[]);l.useEffect(()=>{Ct()},[Ct]);const ae=l.useCallback(async(K,qe=he)=>{te(!0),Ae(null);try{await di({hosts:K,defaultHostId:qe,initialHostChoiceCompleted:!0}),we(K),Ie(qe)}catch(kt){Ae(kt instanceof Error?kt.message:String(kt))}finally{te(!1)}},[he]),Ve=l.useCallback(async()=>{const K=mi(U);if(!K){Ae(s("desktopHostSwitcher.error.invalidUrl"));return}const qe=K.persistedUrl,Tt={id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,label:re.trim()||zn(qe),url:qe,apiUrl:qe,...ne.trim()?{clientToken:ne.trim()}:{}};await ae([Tt,...xe],he),ge(""),ee(""),ue(""),Re(!1),K.redeemUrl&&lr(K.redeemUrl)},[he,xe,re,ne,U,ae,s]),tt=l.useCallback(async()=>{const K=Xh(Me);if(!K){Ae(s("settings.remoteInstances.direct.error.invalidConnectLink"));return}const qe=Wa(K.serverUrl);if(!qe){Ae(s("desktopHostSwitcher.error.invalidUrl"));return}const kt=xe.find(Tt=>Wa(Tt.apiUrl||Tt.url)===qe);if(kt){const Tt=xe.map(ts=>ts.id===kt.id?{...ts,label:K.label||ts.label,url:qe,apiUrl:qe,clientToken:K.token}:ts);await ae(Tt,he)}else{const Tt=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`;await ae([{id:Tt,label:K.label||zn(qe),url:qe,apiUrl:qe,clientToken:K.token},...xe],he)}ke(""),Ae(null),$e(!1)},[Me,he,xe,ae,s]),Ye=l.useCallback(async K=>{const qe=xe.filter(Tt=>Tt.id!==K);await ae(qe,he===K?"local":he),Be===K&&Oe(null)},[he,Be,xe,ae]),yt=l.useCallback(K=>{Oe(K.id),le(K.label),de(K.apiUrl||K.url),Ee(K.clientToken||""),Ae(null)},[]),ze=l.useCallback(async()=>{if(!Be)return;const K=mi(W);if(!K){Ae(s("desktopHostSwitcher.error.invalidUrl"));return}const qe=K.persistedUrl,kt=xe.map(Tt=>Tt.id===Be?{...Tt,label:Ue.trim()||zn(qe),url:qe,apiUrl:qe,clientToken:Ne.trim()||void 0}:Tt);await ae(kt,he),Oe(null),K.redeemUrl&&lr(K.redeemUrl)},[he,Ue,Ne,W,Be,xe,ae,s]),_e=l.useCallback(async()=>{const K=nt.trim();if(!K){B.error(s("settings.remoteInstances.page.toast.sshCommandRequired"));return}const qe=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await h(qe,K,ft.trim()||s("settings.remoteInstances.sidebar.newSshInstanceName")),A(qe),st(!1),Ge("ssh user@example.com"),wt(""),B.success(s("settings.remoteInstances.page.toast.instanceCreated"))}catch(kt){B.error(s("settings.remoteInstances.sidebar.toast.createFailed"),{description:kt instanceof Error?kt.message:String(kt)})}},[h,A,nt,ft,s]),ot=l.useCallback(async K=>{await ae(xe,K)},[xe,ae]),bt=l.useCallback(async()=>{if(e){$(!0),et(null);try{He(await e.listClients())}catch(K){et(K instanceof Error?K.message:String(K))}finally{$(!1)}}},[e]);l.useEffect(()=>{bt()},[bt]);const Mt=l.useCallback(async()=>{if(e){et(null);try{const K=await e.createClient({label:fe.trim()||void 0});Je(K.token),O(""),await bt()}catch(K){et(K instanceof Error?K.message:String(K))}}},[e,bt,fe]),Qt=l.useCallback(async()=>{if(e){et(null);try{const K=Wa(Xn())||window.location.origin,qe=await e.createClient({label:fe.trim()||"Paired client"}),kt=Ul({serverUrl:K,token:qe.token,label:fe||"OpenChamber"}),Tt=Yh(kt);Je(qe.token),lt(Tt),We(await pl.toDataURL(Tt,{width:192,margin:1})),O(""),await bt()}catch(K){et(K instanceof Error?K.message:String(K))}}},[e,bt,fe]),Xt=l.useCallback(async K=>{if(!e)return;const qe=K.clientKind==="desktop-local";et(null);try{if(await e.revokeClient(K.id),qe&&fs()){const kt=await ci();await di({hosts:kt.hosts,defaultHostId:kt.defaultHostId,initialHostChoiceCompleted:kt.initialHostChoiceCompleted,localClientToken:null}),He(Tt=>Tt.map(ts=>ts.id===K.id?{...ts,revokedAt:new Date().toISOString()}:ts)),Om({apiBaseUrl:Xn(),clientToken:null,runtimeKey:"local"});return}await bt()}catch(kt){et(kt instanceof Error?kt.message:String(kt))}},[e,bt]),rs=l.useCallback(async()=>{if(e){et(null);try{await e.purgeRevokedClients(),await bt()}catch(K){et(K instanceof Error?K.message:String(K))}}},[e,bt]);l.useEffect(()=>{y(k)},[k]),l.useEffect(()=>{if(!w)return;const K=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||u()},2e3);return()=>{window.clearInterval(K)}},[u,w]),l.useEffect(()=>{let K=null,qe=Date.now();const kt=()=>{const ts=Date.now();ts-qe>=1e3&&(oe(ts),qe=ts),K=requestAnimationFrame(kt)};(typeof document>"u"||document.visibilityState==="visible")&&(K=requestAnimationFrame(kt));const Tt=()=>{document.visibilityState==="visible"&&K===null?K=requestAnimationFrame(kt):document.visibilityState!=="visible"&&K!==null&&(cancelAnimationFrame(K),K=null)};return document.addEventListener("visibilitychange",Tt),()=>{document.removeEventListener("visibilitychange",Tt),K!==null&&cancelAnimationFrame(K)}},[]);const Wt=w?r[w]:null,Se=Wt?.phase,vt=Se==="ready",Nt=Se==="degraded",ct=Bl(Se),$t=vt||(ct||Nt),ys=Wt?Math.max(0,me-Wt.updatedAtMs):0,ns=Nt&&ys>12e3,bs=l.useMemo(()=>!j||!k?!1:JSON.stringify(j)!==JSON.stringify(k),[j,k]),Qe=l.useCallback(K=>{y(qe=>qe&&K(qe))},[]),mt=l.useCallback(async()=>{if(!j)return;const K=lf(j);if(!K.sshCommand.trim()){B.error(s("settings.remoteInstances.page.toast.sshCommandRequired"));return}if(!(K.localForward.bindHost==="0.0.0.0"&&!window.confirm(s("settings.remoteInstances.page.confirm.bindAllInterfaces")))){if(K.auth.sshPassword?.enabled&&K.auth.sshPassword.value?.trim()&&K.auth.sshPassword.store!=="settings"){const qe=window.confirm(s("settings.remoteInstances.page.confirm.storeSshPasswordPlaintext"));K.auth.sshPassword.store=qe?"settings":"never",qe||(K.auth.sshPassword.value=void 0)}if(K.auth.openchamberPassword?.enabled&&K.auth.openchamberPassword.value?.trim()&&K.auth.openchamberPassword.store!=="settings"){const qe=window.confirm(s("settings.remoteInstances.page.confirm.storeUiPasswordPlaintext"));K.auth.openchamberPassword.store=qe?"settings":"never",qe||(K.auth.openchamberPassword.value=void 0)}try{await S(K),B.success(s("settings.remoteInstances.page.toast.instanceSaved"))}catch(qe){B.error(s("settings.remoteInstances.page.toast.saveFailed"),{description:qe instanceof Error?qe.message:String(qe)})}}},[j,s,S]),xt=l.useCallback(async(K,qe)=>{const kt=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await h(kt,`ssh ${qe}`,K),A(kt),B.success(s("settings.remoteInstances.page.toast.instanceCreated")),!0}catch(Tt){return B.error(s("settings.remoteInstances.sidebar.toast.createFailed"),{description:Tt instanceof Error?Tt.message:String(Tt)}),!1}},[h,A,s]),Rt=l.useCallback(()=>{T||(_(null),H(""))},[T]),es=l.useCallback((K,qe)=>{if(qe){_(K),H(nf(K));return}xt(K,K)},[xt]),Zt=l.useCallback(async()=>{const K=J,qe=Z.trim();if(K){if(!qe){B.error(s("settings.remoteInstances.page.toast.destinationRequired"));return}Y(!0);try{await xt(K,qe)&&(_(null),H(""))}finally{Y(!1)}}},[xt,Z,J,s]),qs=l.useCallback(async()=>{if(k)try{await x(k.id);return}catch(K){if(!Zh(K)||!window.confirm(s("settings.remoteInstances.sidebar.confirm.localPortInUseRetry")))throw K;const kt={...k,localForward:{...k.localForward,preferredLocalPort:Tr()}};await S(kt),await x(kt.id),B.success(s("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}},[x,k,s,S]),Ls=l.useCallback(async K=>(await Gd(K,600)).map(kt=>of(kt)),[]),Tn=l.useCallback(async()=>{if(j){z(!0),I(!0),b(null);try{const K=await Ls(j.id);E(K)}catch(K){E([]),b(K instanceof Error?K.message:String(K))}finally{I(!1)}}},[j,Ls]);l.useEffect(()=>{if(!P||!j)return;let K=!1;const qe=async()=>{try{const Tt=await Ls(j.id);K||(E(Tt),b(null))}catch(Tt){K||b(Tt instanceof Error?Tt.message:String(Tt))}};qe();const kt=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||qe()},1e3);return()=>{K=!0,window.clearInterval(kt)}},[j,P,Ls]);const As=l.useMemo(()=>L.join(`
|
|
28
|
-
`),[L]),Gs=l.useCallback(()=>{if(!As.trim()){B.error(s("settings.remoteInstances.page.toast.noLogsToCopy"));return}un(As).then(K=>{K.ok&&B.success(s("settings.remoteInstances.page.toast.logsCopied"))})},[As,s]),Js=l.useCallback(async()=>{if(j)try{await Jd(j.id),E([]),B.success(s("settings.remoteInstances.page.toast.logsCleared"))}catch(K){B.error(s("settings.remoteInstances.page.toast.clearLogsFailed"),{description:K instanceof Error?K.message:String(K)})}},[j,s]),Fn=l.useCallback(async()=>{if(!Wt?.localUrl){B.error(s("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}const K=Wt.localUrl.trim();if(!K){B.error(s("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}lr(K)},[Wt?.localUrl,s]),Va=l.useCallback(()=>{if(!j)return;ie(!0),($t?D(j.id):qs()).catch(qe=>{const kt=$t?vt?"settings.remoteInstances.page.toast.disconnectFailed":"settings.remoteInstances.page.toast.cancelConnectionFailed":"settings.remoteInstances.page.toast.connectFailed";B.error(s(kt),{description:qe instanceof Error?qe.message:String(qe)})}).finally(()=>{ie(!1)})},[$t,qs,D,j,vt,s]),Ln=l.useCallback(()=>{if(!j||ct)return;se(!0),(Nt?D(j.id).then(()=>qs()):N(j.id)).catch(qe=>{B.error(s("settings.remoteInstances.page.toast.retryFailed"),{description:qe instanceof Error?qe.message:String(qe)})}).finally(()=>{se(!1)})},[qs,D,j,ct,Nt,N,s]),Os=s(ct?"settings.remoteInstances.page.actions.connecting":Nt?ns?"settings.remoteInstances.page.actions.reconnectNow":"settings.remoteInstances.page.actions.reconnecting":"settings.remoteInstances.sidebar.actions.retry"),bn=!Q&&!X&&(Se==="error"||Se==="idle"||!Se||Nt&&ns)&&!ct,Qs=s(vt?"settings.remoteInstances.sidebar.actions.disconnect":$t?"settings.remoteInstances.page.actions.cancel":"settings.remoteInstances.sidebar.actions.connect");if(!j)return t.jsxs(Rr,{children:[e?t.jsxs("div",{"data-settings-item":"remote-instances.client-auth",className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.clientAuth.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.description")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[t.jsx(it,{className:"h-8",value:fe,onChange:K=>O(K.target.value),placeholder:s("settings.remoteInstances.clientAuth.field.labelPlaceholder")}),t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Mt()},children:s("settings.remoteInstances.clientAuth.actions.create")}),t.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Qt()},children:s("settings.remoteInstances.clientAuth.actions.pair")})]}),at?t.jsxs("div",{className:"flex flex-col gap-3 rounded-md border border-[var(--interactive-border)] p-2 sm:flex-row",children:[Ze?t.jsx("img",{src:Ze,alt:s("settings.remoteInstances.clientAuth.qrAlt"),className:"size-48 self-start"}):null,t.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.pairingUrl")}),t.jsx("code",{className:"block select-all break-all typography-code text-foreground",children:at}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{un(at)},children:[t.jsx(M,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.common.actions.copyAll")]})]})]}):null,Fe?t.jsxs("div",{className:"space-y-1 rounded-md border border-[var(--interactive-border)] p-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.createdToken")}),t.jsx("code",{className:"block select-all break-all typography-code text-foreground",children:Fe})]}):null,t.jsxs("div",{className:"space-y-1",children:[pt>0?t.jsx("div",{className:"flex justify-end",children:t.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{rs()},children:s("settings.remoteInstances.clientAuth.actions.clearRevoked")})}):null,q?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.state.loading")}):Ce.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.clientAuth.state.empty")}):Ce.map(K=>{const qe=K.clientKind==="desktop-local";return t.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("p",{className:"typography-ui-label text-foreground truncate",children:K.label}),qe?t.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:s("settings.remoteInstances.clientAuth.state.thisDevice")}):null]}),t.jsx("p",{className:"typography-micro text-muted-foreground truncate",children:K.revokedAt?s("settings.remoteInstances.clientAuth.state.revoked"):K.lastUsedAt?s("settings.remoteInstances.clientAuth.lastUsed",{date:K.lastUsedAt}):s("settings.remoteInstances.clientAuth.neverUsed")})]}),t.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Xt(K)},disabled:!!K.revokedAt,children:s("settings.remoteInstances.clientAuth.actions.revoke")})]},K.id)})]}),Xe?t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Xe}):null]})]}):null,n?t.jsxs("div",{"data-settings-item":"remote-instances.direct-hosts",className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.direct.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.description")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.remoteInstances.direct.note")}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>$e(!0),disabled:be,children:s("settings.remoteInstances.direct.import.action")}),t.jsxs(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>Re(!0),disabled:be,children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.direct.actions.add")]})]})]}),t.jsx("div",{className:"space-y-1",children:ve?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.state.loading")}):xe.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.direct.state.empty")}):xe.map(K=>t.jsx("div",{className:"py-1.5",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("p",{className:"typography-ui-label text-foreground truncate",children:zn(K.label)}),he===K.id?t.jsx("span",{className:"typography-micro text-muted-foreground",children:s("desktopHostSwitcher.header.default")}):null]}),t.jsx("p",{className:"typography-micro text-muted-foreground font-mono truncate",children:zn(K.apiUrl||K.url)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ot(K.id)},disabled:be||he===K.id,"aria-label":s("desktopHostSwitcher.actions.setAsDefaultAria"),children:he===K.id?t.jsx(M,{name:"star-fill",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"star",className:"h-3.5 w-3.5"})}),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>yt(K),disabled:be,children:[t.jsx(M,{name:"pencil",className:"h-3.5 w-3.5"}),s("desktopHostSwitcher.actions.edit")]}),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Ye(K.id)},disabled:be,children:[t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.delete")]})]})]})},K.id))}),De?t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:De}):null]})]}):null,n?t.jsx(Ut,{open:Pe,onOpenChange:Re,children:t.jsxs(Bt,{className:"sm:max-w-lg",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.remoteInstances.direct.actions.add")}),t.jsx(qt,{children:s("settings.remoteInstances.direct.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),Ve()},children:[t.jsx(it,{className:"h-8",value:re,onChange:K=>ge(K.target.value),placeholder:s("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:be}),t.jsx(it,{className:"h-8",value:U,onChange:K=>ee(K.target.value),placeholder:s("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:be,autoFocus:!0}),t.jsx(it,{className:"h-8",value:ne,onChange:K=>ue(K.target.value),placeholder:s("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:be}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Re(!1),disabled:be,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:be||!U.trim(),children:s("settings.remoteInstances.direct.actions.add")})]})]})]})}):null,n?t.jsx(Ut,{open:!!Be,onOpenChange:K=>{K||Oe(null)},children:t.jsxs(Bt,{className:"sm:max-w-lg",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("desktopHostSwitcher.actions.edit")}),t.jsx(qt,{children:s("settings.remoteInstances.direct.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),ze()},children:[t.jsx(it,{className:"h-8",value:Ue,onChange:K=>le(K.target.value),placeholder:s("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:be}),t.jsx(it,{className:"h-8",value:W,onChange:K=>de(K.target.value),placeholder:s("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:be,autoFocus:!0}),t.jsx(it,{className:"h-8",value:Ne,onChange:K=>Ee(K.target.value),placeholder:s("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:be}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Oe(null),disabled:be,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:be,children:s("settings.common.actions.saveChanges")})]})]})]})}):null,n?t.jsx(Ut,{open:Le,onOpenChange:$e,children:t.jsxs(Bt,{className:"sm:max-w-lg",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.remoteInstances.direct.import.action")}),t.jsx(qt,{children:s("settings.remoteInstances.direct.import.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),tt()},children:[t.jsx(it,{className:"h-8",value:Me,onChange:K=>ke(K.target.value),placeholder:s("settings.remoteInstances.direct.import.placeholder"),disabled:be,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>$e(!1),disabled:be,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:be||!Me.trim(),children:s("settings.remoteInstances.direct.import.action")})]})]})]})}):null,n?t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsx("div",{className:"mb-1 px-1 space-y-0.5",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.sidebar.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.sidebar.total",{count:a.length})})]}),t.jsxs(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>st(!0),children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.sidebar.actions.addSshInstance")]})]})}),t.jsx("section",{className:"px-2 pb-2 pt-0 space-y-1",children:o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.import.loading")}):a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.import.noneFound")}):a.map(K=>{const qe=r[K.id],kt=K.nickname?.trim()||K.sshParsed?.destination||K.id,Tt=qe?.phase,ts=Tt==="ready";return t.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:`h-2 w-2 rounded-full ${Co(Tt)}`}),t.jsx("p",{className:"typography-ui-label text-foreground truncate",children:kt})]}),t.jsxs("p",{className:"typography-micro text-muted-foreground truncate",children:[s(So(Tt)),qe?.localUrl?` · ${qe.localUrl}`:""]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{(ts?D(K.id):x(K.id)).catch(gt=>B.error(s(ts?"settings.remoteInstances.sidebar.toast.disconnectFailed":"settings.remoteInstances.sidebar.toast.connectFailed"),{description:gt instanceof Error?gt.message:String(gt)}))},children:[ts?t.jsx(M,{name:"stop",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"plug-2",className:"h-3.5 w-3.5"}),s(ts?"settings.remoteInstances.sidebar.actions.disconnect":"settings.remoteInstances.sidebar.actions.connect")]}),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>A(K.id),children:[t.jsx(M,{name:"pencil",className:"h-3.5 w-3.5"}),s("desktopHostSwitcher.actions.edit")]}),t.jsxs(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{window.confirm(s("settings.remoteInstances.page.confirm.removeInstance"))&&g(K.id).catch(gt=>B.error(s("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:gt instanceof Error?gt.message:String(gt)}))},children:[t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.delete")]})]})]},K.id)})})]}):null,n?t.jsx(Ut,{open:pe,onOpenChange:st,children:t.jsxs(Bt,{className:"sm:max-w-lg",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.remoteInstances.sidebar.actions.addSshInstance")}),t.jsx(qt,{children:s("settings.remoteInstances.page.section.instanceDescription")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),_e()},children:[t.jsx(it,{className:"h-8",value:ft,onChange:K=>wt(K.target.value),placeholder:s("settings.remoteInstances.page.field.nicknamePlaceholder"),disabled:c}),t.jsx(it,{className:"h-8",value:nt,onChange:K=>Ge(K.target.value),placeholder:s("settings.remoteInstances.page.field.sshCommandPlaceholder"),disabled:c,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>st(!1),disabled:c,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:c||!nt.trim(),children:s("settings.common.actions.create")})]})]})]})}):null,n?t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsx("div",{className:"mb-1 px-1 space-y-0.5",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.import.sectionTitle")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:d?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.import.loading")}):i.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.import.noneFound")}):t.jsx("div",{children:i.map(K=>t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-3 last:border-b-0",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"typography-ui-label font-medium text-foreground truncate",children:[K.host,K.pattern?` ${s("settings.remoteInstances.page.import.patternSuffix")}`:""]}),t.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:K.sshCommand})]}),t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{es(K.host,K.pattern)},children:s("settings.common.actions.import")})]},`${K.source}:${K.host}`))})})]}):null,t.jsx(Ut,{open:!!J,onOpenChange:K=>{K||Rt()},children:t.jsxs(Bt,{className:"sm:max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.remoteInstances.page.patternDialog.title")}),t.jsx(qt,{children:J?s("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:J}):s("settings.remoteInstances.page.patternDialog.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),Zt()},children:[t.jsx(it,{value:Z,onChange:K=>H(K.target.value),placeholder:s("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Rt,disabled:T,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:T,children:s("settings.remoteInstances.page.actions.create")})]})]})]})})]});const sa=j.remoteOpenchamber.mode==="managed",_a=j.nickname?.trim()||j.sshParsed?.destination||j.id;return t.jsx(Ut,{open:!!j,onOpenChange:K=>{K||A(null)},children:t.jsxs(Bt,{className:"sm:max-w-4xl max-h-[90vh] overflow-auto",children:[t.jsxs("div",{className:"mb-6 px-1",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:_a}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${Co(Se)}`}),t.jsx("span",{children:s(So(Se))}),Wt?.localUrl?t.jsx("span",{className:"font-mono text-foreground/80",children:Wt.localUrl}):null,ns?t.jsx("span",{children:s("settings.remoteInstances.page.status.reconnectStale")}):null]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.actions")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.actionsDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(G,{type:"button",variant:$t?"outline":"default",size:"xs",className:"!font-normal",onClick:Va,disabled:Q||X,children:[$t?t.jsx(M,{name:"stop",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"plug-2",className:"h-3.5 w-3.5"}),Qs]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Ln,disabled:!bn,children:[t.jsx(M,{name:"refresh",className:`h-3.5 w-3.5 ${ct||Nt&&!ns?"animate-spin":""}`}),Os]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Tn()},children:[t.jsx(M,{name:"terminal-window",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.logs")]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal text-[var(--status-error)] border-[var(--status-error)]/30 hover:text-[var(--status-error)]",onClick:()=>{window.confirm(s("settings.remoteInstances.page.confirm.removeInstance"))&&g(j.id).then(()=>{A(null),B.success(s("settings.remoteInstances.page.toast.instanceRemoved"))}).catch(qe=>{B.error(s("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:qe instanceof Error?qe.message:String(qe)})})},children:[t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.sidebar.actions.remove")]})]}),Wt?.localUrl?t.jsxs("div",{className:"flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx("span",{children:s("settings.remoteInstances.page.status.currentLocalUrl")}),t.jsx("span",{className:"font-mono text-foreground/90",children:Wt.localUrl})]}):null]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.instance")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.instanceDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.sshCommand")}),t.jsx(it,{className:"h-7 md:max-w-xl",value:j.sshCommand,onChange:K=>Qe(qe=>({...qe,sshCommand:K.target.value})),placeholder:s("settings.remoteInstances.page.field.sshCommandPlaceholder")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.nickname")}),t.jsx(it,{className:"h-7 md:max-w-sm",value:j.nickname||"",onChange:K=>Qe(qe=>({...qe,nickname:K.target.value})),placeholder:s("settings.remoteInstances.page.field.nicknamePlaceholder")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.connectionTimeoutSeconds")}),t.jsx(xs,{containerClassName:"w-fit",min:5,max:240,step:1,className:"w-16 tabular-nums",value:j.connectionTimeoutSec,onValueChange:K=>{Qe(qe=>({...qe,connectionTimeoutSec:Number.isFinite(K)?K:qe.connectionTimeoutSec}))}})]})]})]}),t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.remoteServer")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.remoteServerDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:s("settings.remoteInstances.page.field.mode"),hint:s("settings.remoteInstances.page.field.modeHint")})}),t.jsxs(Ft,{value:j.remoteOpenchamber.mode,onValueChange:K=>Qe(qe=>({...qe,remoteOpenchamber:{...qe.remoteOpenchamber,mode:K==="external"?"external":"managed"}})),children:[t.jsx(Lt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Kt,{placeholder:s("settings.remoteInstances.page.field.modePlaceholder")})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"managed",children:s("settings.remoteInstances.page.field.modeManaged")}),t.jsx(ht,{value:"external",children:s("settings.remoteInstances.page.field.modeExternal")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:s("settings.remoteInstances.page.field.preferredRemotePort"),hint:s("settings.remoteInstances.page.field.preferredRemotePortHint")})}),t.jsx(xs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-20 tabular-nums",value:j.remoteOpenchamber.preferredPort,onValueChange:K=>{Qe(qe=>({...qe,remoteOpenchamber:{...qe.remoteOpenchamber,preferredPort:Number.isFinite(K)&&K>0?K:void 0}}))},onClear:()=>{Qe(K=>({...K,remoteOpenchamber:{...K.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:s("settings.remoteInstances.page.field.auto")})]}),sa?t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:s("settings.remoteInstances.page.field.installMethod"),hint:s("settings.remoteInstances.page.field.installMethodHint")})}),t.jsxs(Ft,{value:j.remoteOpenchamber.installMethod,onValueChange:K=>Qe(qe=>({...qe,remoteOpenchamber:{...qe.remoteOpenchamber,installMethod:K==="npm"||K==="download_release"||K==="upload_bundle"?K:"bun"}})),children:[t.jsx(Lt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Kt,{placeholder:s("settings.remoteInstances.page.field.selectInstallMethodPlaceholder")})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"bun",children:"bun"}),t.jsx(ht,{value:"npm",children:"npm"}),t.jsx(ht,{value:"download_release",children:s("settings.remoteInstances.page.field.installMethodDownloadRelease")}),t.jsx(ht,{value:"upload_bundle",children:s("settings.remoteInstances.page.field.installMethodUploadBundle")})]})]})]}):null,sa?t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:s("settings.remoteInstances.page.field.keepServerRunning"),hint:s("settings.remoteInstances.page.field.keepServerRunningHint")})}),t.jsx("div",{className:"flex w-full items-center gap-2 md:max-w-xs",children:t.jsx(Fa,{checked:j.remoteOpenchamber.keepRunning,onCheckedChange:K=>Qe(qe=>({...qe,remoteOpenchamber:{...qe.remoteOpenchamber,keepRunning:K}}))})})]}):null]})]}),t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.mainTunnel")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.mainTunnelDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:s("settings.remoteInstances.page.field.bindHost"),hint:s("settings.remoteInstances.page.field.bindHostHint")})}),t.jsxs(Ft,{value:j.localForward.bindHost,onValueChange:K=>{K==="0.0.0.0"&&!window.confirm(s("settings.remoteInstances.page.confirm.bindAllInterfaces"))||Qe(qe=>({...qe,localForward:{...qe.localForward,bindHost:K==="localhost"||K==="0.0.0.0"?K:"127.0.0.1"}}))},children:[t.jsx(Lt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Kt,{placeholder:s("settings.remoteInstances.page.field.selectBindHostPlaceholder")})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"127.0.0.1",children:"127.0.0.1"}),t.jsx(ht,{value:"localhost",children:"localhost"}),t.jsx(ht,{value:"0.0.0.0",children:"0.0.0.0"})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:s("settings.remoteInstances.page.field.preferredLocalPort"),hint:s("settings.remoteInstances.page.field.preferredLocalPortHint")})}),t.jsxs("div",{className:"flex w-full items-center gap-2 md:max-w-sm",children:[t.jsx(xs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-20 tabular-nums",value:j.localForward.preferredLocalPort,onValueChange:K=>{Qe(qe=>({...qe,localForward:{...qe.localForward,preferredLocalPort:Number.isFinite(K)&&K>0?K:void 0}}))},onClear:()=>{Qe(K=>({...K,localForward:{...K.localForward,preferredLocalPort:void 0}}))},emptyLabel:s("settings.remoteInstances.page.field.auto")}),t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal h-7 w-7 px-0",title:s("settings.remoteInstances.page.actions.pickRandomPort"),onClick:()=>Qe(K=>({...K,localForward:{...K.localForward,preferredLocalPort:Tr()}})),children:t.jsx(M,{name:"shuffle",className:"h-3.5 w-3.5"})})]})]})]})]}),t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.authentication")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.authenticationDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.sshPasswordOptional")}),t.jsx(it,{className:"h-7 md:max-w-sm",type:"password",value:j.auth.sshPassword?.value||"",onChange:K=>Qe(qe=>({...qe,auth:{...qe.auth,sshPassword:{enabled:K.target.value.trim().length>0,value:K.target.value,store:qe.auth.sshPassword?.store||"never"}}})),placeholder:s("settings.remoteInstances.page.field.sshPasswordPlaceholder")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:s("settings.remoteInstances.page.field.uiPasswordOptional")}),t.jsx(it,{className:"h-7 md:max-w-sm",type:"password",value:j.auth.openchamberPassword?.value||"",onChange:K=>Qe(qe=>({...qe,auth:{...qe.auth,openchamberPassword:{enabled:K.target.value.trim().length>0,value:K.target.value,store:qe.auth.openchamberPassword?.store||"never"}}})),placeholder:s("settings.remoteInstances.page.field.uiPasswordPlaceholder")})]})]})]}),t.jsxs("div",{className:"mb-8 border-t border-[var(--surface-subtle)] pt-8",children:[t.jsxs("div",{className:"mb-1 px-1 space-y-0.5",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.remoteInstances.page.section.portForwards")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.section.portForwardsDescription")})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[j.portForwards.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground/80",children:s("settings.remoteInstances.page.empty.noExtraForwards")}):null,j.portForwards.map((K,qe)=>{const kt=Gt=>{Qe(ls=>({...ls,portForwards:ls.portForwards.map((Xr,uc)=>uc===qe?Gt(Xr):Xr)}))},Tt=K.type==="remote"?"Local target":"Local listen",ts=K.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.",C=K.type==="remote"?"Remote listen":"Remote target",gt=K.type==="remote"?"Remote host and port where SSH creates the -R listener.":"Remote host and port that receives traffic from local -L listener.",zt=Po(K.localHost||"localhost",K.localPort),ss=Po(K.remoteHost||"localhost",K.remotePort),Is=K.type==="local"&&typeof K.localPort=="number"&&K.localPort>0,zs=Is?`http://${rf(K.localHost)}:${K.localPort}`:"",on=!!F[K.id],On=K.type==="local"?s("settings.remoteInstances.page.forwardType.local"):K.type==="remote"?s("settings.remoteInstances.page.forwardType.remote"):s("settings.remoteInstances.page.forwardType.dynamic");return t.jsxs(gn,{open:on,onOpenChange:Gt=>{V(ls=>({...ls,[K.id]:Gt}))},className:`${qe>0?"border-t border-[var(--surface-subtle)]":""} py-2`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"min-w-0 flex items-center gap-2",children:t.jsxs(hn,{className:"flex items-center gap-2 group",children:[t.jsx(M,{name:"arrow-down-s",className:`h-4 w-4 text-muted-foreground transition-transform ${on?"rotate-180":""}`}),t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:tf(K)}),t.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:On})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Fa,{checked:K.enabled,onCheckedChange:Gt=>kt(ls=>({...ls,enabled:Gt})),"aria-label":s("settings.remoteInstances.page.actions.enableForwardAria")}),t.jsx(G,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>Qe(Gt=>({...Gt,portForwards:Gt.portForwards.filter(ls=>ls.id!==K.id)})),children:t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),t.jsx(fn,{className:"pt-2",children:t.jsxs("div",{className:"space-y-0 pb-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:s(af(K.type))}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:s("settings.remoteInstances.page.field.forwardType"),hint:s("settings.remoteInstances.page.field.forwardTypeHint")})}),t.jsxs(Ft,{value:K.type,onValueChange:Gt=>kt(ls=>({...ls,type:Gt==="dynamic"||Gt==="remote"?Gt:"local"})),children:[t.jsx(Lt,{className:"h-7 w-fit min-w-[140px]",children:t.jsx(Kt,{placeholder:s("settings.remoteInstances.page.field.typePlaceholder")})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"local",children:s("settings.remoteInstances.page.forwardType.local")}),t.jsx(ht,{value:"remote",children:s("settings.remoteInstances.page.forwardType.remote")}),t.jsx(ht,{value:"dynamic",children:s("settings.remoteInstances.page.forwardType.dynamic")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:Tt,hint:ts})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(it,{className:"h-7 w-32",value:K.localHost||"127.0.0.1",onChange:Gt=>kt(ls=>({...ls,localHost:Gt.target.value})),placeholder:s("settings.remoteInstances.page.field.localHostPlaceholder")}),t.jsx("span",{className:"text-muted-foreground",children:":"}),t.jsx(xs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-16 tabular-nums",value:K.localPort,onValueChange:Gt=>{kt(ls=>({...ls,localPort:Number.isFinite(Gt)&&Gt>0?Gt:void 0}))},onClear:()=>{kt(Gt=>({...Gt,localPort:void 0}))},emptyLabel:s("settings.remoteInstances.page.field.auto")})]})]}),K.type!=="dynamic"?t.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[t.jsx("div",{className:"w-56 shrink-0",children:t.jsx(Ks,{label:C,hint:gt})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(it,{className:"h-7 w-32",value:K.remoteHost||"",onChange:Gt=>kt(ls=>({...ls,remoteHost:Gt.target.value})),placeholder:s("settings.remoteInstances.page.field.remoteHostPlaceholder")}),t.jsx("span",{className:"text-muted-foreground",children:":"}),t.jsx(xs,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-16 tabular-nums",value:K.remotePort,onValueChange:Gt=>{kt(ls=>({...ls,remotePort:Number.isFinite(Gt)&&Gt>0?Gt:void 0}))},onClear:()=>{kt(Gt=>({...Gt,remotePort:void 0}))},emptyLabel:s("settings.remoteInstances.page.field.auto")})]})]}):null,t.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md bg-[var(--surface-subtle)] p-2",children:[t.jsx("div",{className:"flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80",children:K.type==="dynamic"?t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:zt}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.localSocks5")})]}):K.type==="remote"?t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"server",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:ss}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.remote")}),t.jsx(M,{name:"arrow-right",className:"h-3.5 w-3.5"}),t.jsx(M,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:zt}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.local")})]}):t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"computer",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:zt}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.local")}),t.jsx(M,{name:"arrow-right",className:"h-3.5 w-3.5"}),t.jsx(M,{name:"server",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"font-mono text-foreground",children:ss}),t.jsx("span",{children:s("settings.remoteInstances.page.preview.remote")})]})}),Is?t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Hs(zs).then(Gt=>{Gt||B.error(s("settings.remoteInstances.page.toast.openLocalEndpointFailed"))})},children:[t.jsx(M,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.openLocal")]}):null]})]})})]},K.id)}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal mt-1",onClick:()=>{const K=sf();Qe(qe=>({...qe,portForwards:[...qe.portForwards,K]})),V(qe=>({...qe,[K.id]:!0}))},children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.addForward")]})]})]}),t.jsx("div",{className:"mt-8 border-t border-[var(--interactive-border)] pt-3",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{mt()},disabled:!bs||c,children:s("settings.common.actions.saveChanges")}),Wt?.localUrl?t.jsxs(t.Fragment,{children:[t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{un(Wt.localUrl||"").then(K=>{K.ok&&B.success(s("settings.remoteInstances.page.toast.localUrlCopied"))})},children:[t.jsx(M,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.copyLocalUrl")]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Fn()},children:[t.jsx(M,{name:"external-link",className:"h-3.5 w-3.5"}),s("settings.remoteInstances.page.actions.open")]})]}):null,f?t.jsx("div",{className:"ml-auto typography-meta text-[var(--status-error)]",children:f}):null]})}),t.jsx(Ut,{open:P,onOpenChange:z,children:t.jsxs(Bt,{className:"sm:max-w-2xl",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.remoteInstances.page.logsDialog.title")}),t.jsx(qt,{children:j?.nickname?.trim()||j?.sshParsed?.destination||j?.id||s("settings.remoteInstances.page.logsDialog.selectedInstanceFallback")})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Gs,disabled:R||!As.trim(),children:[t.jsx(M,{name:"file-copy",className:"h-3.5 w-3.5"}),s("settings.common.actions.copyAll")]}),t.jsxs(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Js()},disabled:R,children:[t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"}),s("settings.common.actions.clear")]})]}),R?t.jsx("div",{className:"typography-meta text-muted-foreground",children:s("settings.remoteInstances.page.logsDialog.loading")}):v?t.jsx("div",{className:"typography-meta text-[var(--status-error)]",children:v}):t.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:L.length>0?L.join(`
|
|
29
|
-
`):s("settings.remoteInstances.page.logsDialog.empty")})]})}),t.jsx(Ut,{open:!!J,onOpenChange:K=>{K||Rt()},children:t.jsxs(Bt,{className:"sm:max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:s("settings.remoteInstances.page.patternDialog.title")}),t.jsx(qt,{children:J?s("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:J}):s("settings.remoteInstances.page.patternDialog.description")})]}),t.jsxs("form",{className:"space-y-3",onSubmit:K=>{K.preventDefault(),Zt()},children:[t.jsx(it,{value:Z,onChange:K=>H(K.target.value),placeholder:s("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Rt,disabled:T,children:s("settings.common.actions.cancel")}),t.jsx(G,{type:"submit",size:"xs",className:"!font-normal",disabled:T,children:s("settings.common.actions.create")})]})]})]})})]})})},df="__add_provider__",mf=()=>{const s=Ns.getDirectory();return typeof s=="string"&&s.trim().length>0?s.trim():null},uf=({onItemSelect:s})=>{const{t:e}=dt(),n=ut(u=>u.providers),a=ut(u=>u.selectedProviderId),r=ut(u=>u.setSelectedProvider),i=as(u=>u.activeProjectId),[o,d]=l.useState({}),c=l.useMemo(()=>mf(),[i]);l.useEffect(()=>{if(n.length===0){d({});return}let u=!1;return(async()=>{const h=n.map(async g=>{try{const x=c?`?directory=${encodeURIComponent(c)}`:"",D=await jt(`/api/provider/${encodeURIComponent(g.id)}/source${x}`,{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const N=await D.json().catch(()=>null),w=N?.sources??N?.data?.sources;if(!w||u)return;d(A=>({...A,[g.id]:w}))}catch{}});await Promise.all(h)})(),()=>{u=!0}},[c,n]);const f="bg-background",m=l.useMemo(()=>n.filter(u=>!!o[u.id]?.project?.exists),[n,o]),p=l.useMemo(()=>n.filter(u=>!o[u.id]?.project?.exists),[n,o]);return t.jsxs("div",{className:ce("flex h-full flex-col",f),children:[t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:e("settings.providers.sidebar.title")}),t.jsx(ta,{className:"mb-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.providers.sidebar.total",{count:n.length})}),t.jsx(G,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:()=>{r(df),s?.()},"aria-label":e("settings.providers.sidebar.actions.connectProviderAria"),title:e("settings.providers.sidebar.actions.connectProviderTitle"),children:t.jsx(M,{name:"add",className:"h-3.5 w-3.5"})})]})]}),t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:n.length===0?t.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[t.jsx(M,{name:"stack",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),t.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.providers.sidebar.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.providers.sidebar.empty.description")})]}):t.jsxs(t.Fragment,{children:[p.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.providers.sidebar.section.userProviders")}),p.map(u=>t.jsx(Io,{provider:u,selectedProviderId:a,onSelect:()=>{r(u.id),s?.()}},u.id))]}),m.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ce("px-2 pb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",p.length>0?"pt-3":"pt-2"),children:e("settings.providers.sidebar.section.projectProviders")}),m.map(u=>t.jsx(Io,{provider:u,selectedProviderId:a,onSelect:()=>{r(u.id),s?.()}},u.id))]})]})})]})},Io=s=>{const e=rt.c(17),{provider:n,selectedProviderId:a,onSelect:r}=s,i=Array.isArray(n.models)?n.models.length:0,o=n.id===a,d=n.id,c=o?"bg-interactive-selection":"hover:bg-interactive-hover";let f;e[0]!==c?(f=ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",c),e[0]=c,e[1]=f):f=e[1];let m;e[2]!==n.id?(m=t.jsx(An,{providerId:n.id,className:"h-4 w-4 flex-shrink-0"}),e[2]=n.id,e[3]=m):m=e[3];const p=n.name||n.id;let u;e[4]!==p?(u=t.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:p}),e[4]=p,e[5]=u):u=e[5];let S;e[6]!==i?(S=t.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:i}),e[6]=i,e[7]=S):S=e[7];let h;e[8]!==r||e[9]!==m||e[10]!==u||e[11]!==S?(h=t.jsxs("button",{type:"button",onClick:r,className:"flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[m,u,S]}),e[8]=r,e[9]=m,e[10]=u,e[11]=S,e[12]=h):h=e[12];let g;return e[13]!==n.id||e[14]!==f||e[15]!==h?(g=t.jsx("div",{className:f,children:h},d),e[13]=n.id,e[14]=f,e[15]=h,e[16]=g):g=e[16],g},pf=s=>s,gf=s=>new Intl.NumberFormat(Vr(),{notation:"compact",compactDisplay:"short",maximumFractionDigits:1,minimumFractionDigits:0}).format(s),Do=s=>{if(typeof s!="number"||Number.isNaN(s))return null;if(s===0)return"0";const e=gf(s);return e.endsWith(".0")?e.slice(0,-2):e},ha="__add_provider__",Rn=s=>typeof s=="object"&&s!==null,Ao=s=>{const e=typeof s.type=="string"?s.type:"",n=`${s.name??""} ${s.label??""}`.toLowerCase(),a=`${e} ${n}`.toLowerCase();return a.includes("oauth")?"oauth":a.includes("api")?"api":e.toLowerCase()},hf=s=>{if(!Rn(s))return{};const e={};for(const[n,a]of Object.entries(s))Array.isArray(a)&&(e[n]=a.filter(r=>Rn(r)));return e},ff=s=>{if(typeof s=="string")return{id:s};if(!Rn(s))return null;const e=typeof s.id=="string"&&s.id||typeof s.providerID=="string"&&s.providerID||typeof s.slug=="string"&&s.slug||typeof s.name=="string"&&s.name;if(!e)return null;const n=typeof s.name=="string"?s.name:void 0;return{id:e,name:n}},xf=s=>{let e=[];Array.isArray(s)?e=s:Rn(s)&&(Array.isArray(s.all)?e=s.all:Array.isArray(s.providers)&&(e=s.providers));const n=e.map(r=>ff(r)).filter(r=>!!r),a=new Set;return n.filter(r=>a.has(r.id)?!1:(a.add(r.id),!0))},yf=()=>{const{t:s}=dt(),e=ut(U=>U.providers),n=ut(U=>U.selectedProviderId),a=ut(U=>U.setSelectedProvider),r=ut(U=>U.getModelMetadata),i=Ke(U=>U.hiddenModels),o=Ke(U=>U.toggleHiddenModel),d=Ke(U=>U.hideAllModels),c=Ke(U=>U.showAllModels),[f,m]=l.useState({}),[p,u]=l.useState(!1),[S,h]=l.useState({}),[g,x]=l.useState(null),[D,N]=l.useState(""),[w,A]=l.useState(null),[k,j]=l.useState({}),[y,P]=l.useState({}),[z,R]=l.useState([]),[I,v]=l.useState(!1),[b,L]=l.useState(null),[E,J]=l.useState(""),[_,Z]=l.useState(""),[H,T]=l.useState(!1),[Y,F]=l.useState({}),[V,Q]=l.useState(!1),ie=n===ha;l.useEffect(()=>{!n&&e.length>0&&a(e[0].id)},[e,n,a]),l.useEffect(()=>{if(!ie)return;let U=!0;return(async()=>{u(!0);try{const ne=await Ns.getSdkClient().provider.auth();if(ne.error)throw new Error(`provider.auth failed: ${String(ne.error)}`);if(!U)return;m(hf(ne.data))}catch(ne){if(!U)return;console.error("Failed to load provider auth methods:",ne),B.error(s("settings.providers.page.toast.authMethodsLoadFailed"))}finally{U&&u(!1)}})(),()=>{U=!1}},[ie,s]),l.useEffect(()=>{if(!pf(ie))return;let U=!0;return(async()=>{v(!0),L(null);try{const ne=await Ns.getSdkClient().provider.list();if(ne.error)throw new Error(`provider.list failed: ${String(ne.error)}`);if(!U)return;R(xf(ne.data))}catch(ne){if(!U)return;console.error("Failed to load available providers:",ne),L(s("settings.providers.page.state.unableToLoadProviderList"))}finally{U&&v(!1)}})(),()=>{U=!1}},[ie,s]);const X=l.useMemo(()=>new Set(e.map(U=>U.id)),[e]),se=l.useMemo(()=>z.filter(U=>!X.has(U.id)).sort((U,ee)=>{const ne=(U.name||U.id).toLowerCase(),ue=(ee.name||ee.id).toLowerCase();return ne.localeCompare(ue)}),[z,X]);l.useEffect(()=>{n===ha&&E&&!se.some(U=>U.id===E)&&J("")},[n,E,se]),l.useEffect(()=>{if(n===ha){Q(!0);return}Q(!1)},[n,s]),l.useEffect(()=>{if(!n||n===ha)return;let U=!1;return(async()=>{try{const ne=await jt(`/api/provider/${encodeURIComponent(n)}/source`,{method:"GET",headers:{Accept:"application/json"}}),ue=await ne.json().catch(()=>null);if(!ne.ok)throw new Error(ue?.error||s("settings.providers.page.toast.providerSourcesLoadFailed"));const Me=ue?.sources??ue?.data?.sources;!U&&Me&&F(ke=>({...ke,[n]:Me}))}catch(ne){U||console.error("Failed to load provider sources:",ne)}})(),()=>{U=!0}},[n,s]);const me=e.find(U=>U.id===n),oe=n?Y[n]:void 0,xe=async U=>{const ee=S[U]?.trim()??"";if(!ee){B.error(s("settings.providers.page.toast.apiKeyRequired"));return}const ne=`api:${U}`;x(ne);try{if((await Ns.getSdkClient().auth.set({providerID:U,auth:{type:"api",key:ee}})).error)throw new Error(s("settings.providers.page.toast.apiKeySaveFailed"));B.success(s("settings.providers.page.toast.apiKeySaved")),h(Me=>({...Me,[U]:""})),await In({scopes:["providers"],mode:"active"}),a(U)}catch(ue){console.error("Failed to save API key:",ue),B.error(s("settings.providers.page.toast.apiKeySaveFailed"))}finally{x(null)}},we=async(U,ee)=>{const ne=`oauth:${U}:${ee}`;x(ne);try{const ue=await Ns.getSdkClient().provider.oauth.authorize({providerID:U,method:ee});if(ue.error)throw new Error(s("settings.providers.page.toast.oauthStartFailed"));const Me=Rn(ue.data)?ue.data:{},ke=Me.data,De=Rn(ke)?ke:Me,Ae=typeof De.url=="string"&&De.url||typeof De.verification_uri_complete=="string"&&De.verification_uri_complete||typeof De.verification_uri=="string"&&De.verification_uri||void 0,Pe=typeof De.instructions=="string"&&De.instructions||typeof De.message=="string"&&De.message||void 0,Re=typeof De.user_code=="string"&&De.user_code||typeof De.code=="string"&&De.code||typeof De.userCode=="string"&&De.userCode||void 0;if(!Ae&&!Pe&&!Re)throw new Error(s("settings.providers.page.toast.oauthDetailsMissing"));const Le=`${U}:${ee}`;P($e=>({...$e,[Le]:{url:Ae,instructions:Pe,userCode:Re}})),Ae&&Hs(Ae),A({providerId:U,methodIndex:ee}),B.message(s("settings.providers.page.toast.completeOAuthInBrowser"))}catch(ue){console.error("Failed to start OAuth flow:",ue),B.error(s("settings.providers.page.toast.oauthStartFailed"))}finally{x(null)}},he=async(U,ee)=>{const ne=`${U}:${ee}`,ue=k[ne]?.trim(),Me=`oauth-complete:${U}:${ee}`;x(Me);try{const ke={method:ee};if(ue&&(ke.code=ue),(await Ns.getSdkClient().provider.oauth.callback({providerID:U,method:ke.method,code:ke.code})).error)throw new Error(s("settings.providers.page.toast.oauthCompleteFailed"));B.success(s("settings.providers.page.toast.oauthCompleted")),j(Ae=>({...Ae,[ne]:""})),A(null),await In({scopes:["providers"],mode:"active"}),a(U)}catch(ke){console.error("Failed to complete OAuth flow:",ke),B.error(s("settings.providers.page.toast.oauthCompleteFailed"))}finally{x(null)}},Ie=async U=>{const ee=await un(U);if(ee.ok){B.success(s("settings.providers.page.toast.oauthLinkCopied"));return}console.error("Failed to copy OAuth link:",ee.error),B.error(s("settings.providers.page.toast.oauthLinkCopyFailed"))},ve=async U=>{const ee=await un(U);if(ee.ok){B.success(s("settings.providers.page.toast.deviceCodeCopied"));return}console.error("Failed to copy device code:",ee.error),B.error(s("settings.providers.page.toast.deviceCodeCopyFailed"))},ye=async U=>{const ee=`disconnect:${U}`;x(ee);try{const ne=await jt(`/api/provider/${encodeURIComponent(U)}/auth?scope=all`,{method:"DELETE",headers:{Accept:"application/json"}}),ue=await ne.json().catch(()=>null);if(!ne.ok)throw new Error(ue?.error||s("settings.providers.page.toast.providerDisconnectFailed"));B.success(s("settings.providers.page.toast.providerDisconnected")),await In({scopes:["providers"],mode:"active"})}catch(ne){console.error("Failed to disconnect provider:",ne),B.error(s("settings.providers.page.toast.providerDisconnectFailed"))}finally{x(null)}};if(!ie&&e.length===0)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(M,{name:"stack",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.providers.page.empty.noProvidersDetected")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.providers.page.empty.checkOpenCodeConfiguration")})]})});if(ie)return t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsx("div",{"data-settings-item":"providers.connect",className:"mb-4",children:t.jsx("h1",{className:"typography-ui-header font-semibold text-foreground",children:s("settings.providers.page.connect.title")})}),t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h2",{className:"typography-ui-header font-medium text-foreground",children:s("settings.providers.page.connect.selectProviderTitle")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.providers.page.connect.providerField")}),I?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.providers.page.state.loading")}):b?t.jsx("p",{className:"typography-meta text-muted-foreground",children:b}):se.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.providers.page.connect.allProvidersConnected")}):t.jsxs(us,{open:H,onOpenChange:U=>{T(U),U||Z("")},children:[t.jsx(ds,{asChild:!0,children:t.jsxs("button",{type:"button",className:ce("flex items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover h-6 w-fit"),children:[t.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[E?t.jsx(An,{providerId:E,className:"h-3.5 w-3.5 flex-shrink-0"}):null,t.jsx("span",{className:ce("truncate typography-ui-label font-normal",E?"text-foreground":"text-muted-foreground"),children:E?se.find(U=>U.id===E)?.name||E:s("settings.providers.page.connect.selectProviderPlaceholder")})]}),t.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/50"})]})}),t.jsxs(ms,{align:"start",className:"w-[280px] p-0",onCloseAutoFocus:U=>U.preventDefault(),children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2",onKeyDown:U=>U.stopPropagation(),children:[t.jsx(M,{name:"search",className:"h-4 w-4 text-muted-foreground"}),t.jsx("input",{type:"text",value:_,onChange:U=>Z(U.target.value),onKeyDown:U=>U.stopPropagation(),placeholder:s("settings.providers.page.connect.searchProvidersPlaceholder"),className:"flex-1 bg-transparent typography-meta outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),t.jsx(Jt,{outerClassName:"max-h-[240px]",className:"p-1",children:(()=>{const U=se.filter(ee=>{const ne=_.toLowerCase();return(ee.name||ee.id).toLowerCase().includes(ne)||ee.id.toLowerCase().includes(ne)});return U.length===0?t.jsx("p",{className:"py-4 text-center typography-meta text-muted-foreground",children:s("settings.providers.page.connect.noProvidersFound")}):U.map(ee=>t.jsxs(js,{onSelect:()=>{J(ee.id),T(!1),Z("")},className:"flex items-center justify-between",children:[t.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(An,{providerId:ee.id,className:"h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:ee.name||ee.id})]}),E===ee.id&&t.jsx(M,{name:"check",className:"h-4 w-4 text-[var(--primary-base)]"})]},ee.id))})()})]})]})]})})]}),E&&t.jsxs("div",{"data-settings-item":"providers.auth",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h2",{className:"typography-ui-header font-medium text-foreground",children:s("settings.providers.page.auth.title")})}),p?t.jsx("p",{className:"typography-meta text-muted-foreground px-2",children:s("settings.providers.page.auth.loadingMethods")}):t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-4",children:[t.jsxs("div",{className:"py-1.5",children:[t.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[s("settings.providers.page.auth.apiKeyLabel"),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.providers.page.auth.apiKeyTooltip")})]})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5",children:[t.jsx(it,{type:"password",value:S[E]??"",onChange:U=>h(ee=>({...ee,[E]:U.target.value})),placeholder:s("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),t.jsx(G,{size:"xs",className:"!font-normal shrink-0",onClick:()=>xe(E),disabled:g===`api:${E}`,children:g===`api:${E}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.saveKey")})]})]}),(()=>{const ee=(f[E]??[]).filter(ne=>Ao(ne)==="oauth");return ee.length===0?null:t.jsx("div",{className:"space-y-4 border-t border-[var(--surface-subtle)] pt-2",children:ee.map((ne,ue)=>{const Me=ne.label||ne.name||s("settings.providers.page.auth.oauthMethodFallback",{index:String(ue+1)}),ke=`${E}:${ue}`,De=w?.providerId===E&&w?.methodIndex===ue;return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:Me}),(ne.description||ne.help)&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:String(ne.description||ne.help)})]}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>we(E,ue),disabled:g===`oauth:${E}:${ue}`,children:s("settings.providers.page.actions.connect")})]}),y[ke]?.instructions&&t.jsx("p",{className:"typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded",children:y[ke]?.instructions}),y[ke]?.userCode&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(it,{value:y[ke]?.userCode,readOnly:!0,className:"font-mono text-center tracking-widest"}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ve(y[ke]?.userCode??""),children:s("settings.providers.page.actions.copyCode")})]}),y[ke]?.url&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(it,{value:y[ke]?.url,readOnly:!0,className:"text-xs text-muted-foreground"}),t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Hs(y[ke]?.url??""),children:s("settings.providers.page.actions.open")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ie(y[ke]?.url??""),children:s("settings.providers.page.actions.copy")})]})]}),De&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(it,{value:k[ke]??"",onChange:Ae=>j(Pe=>({...Pe,[ke]:Ae.target.value})),placeholder:s("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs"}),t.jsx(G,{size:"xs",className:"!font-normal",onClick:()=>he(E,ue),disabled:g===`oauth-complete:${E}:${ue}`,children:g===`oauth-complete:${E}:${ue}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.complete")})]})]},`${E}-${Me}`)})})})()]})]})]})});if(!me)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(M,{name:"stack",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.providers.page.empty.selectProviderFromSidebar")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.providers.page.empty.reviewDetailsAndConfigureAuth")})]})});const be=Array.isArray(me.models)?me.models:[],re=(f[me.id]??[]).filter(U=>Ao(U)==="oauth"),ge=be.filter(U=>{const ee=typeof U?.name=="string"?U.name:"",ne=typeof U?.id=="string"?U.id:"",ue=D.trim().toLowerCase();return ue?ee.toLowerCase().includes(ue)||ne.toLowerCase().includes(ue):!0});return t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx(An,{providerId:me.id,className:"h-5 w-5 shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:me.name||me.id}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:t.jsx("span",{className:"font-mono",children:me.id})})]})]}),t.jsxs("div",{"data-settings-item":"providers.auth",className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center justify-between gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.providers.page.auth.title")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Q(U=>!U),children:s(V?"settings.providers.page.actions.hide":"settings.providers.page.actions.reconnect")})]}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:V?p?t.jsx("div",{className:"py-1.5 typography-meta text-muted-foreground",children:s("settings.providers.page.auth.loadingMethods")}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"py-1.5",children:[t.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[s("settings.providers.page.auth.apiKeyLabel"),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.providers.page.auth.apiKeyTooltip")})]})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5",children:[t.jsx(it,{type:"password",value:S[me.id]??"",onChange:U=>h(ee=>({...ee,[me.id]:U.target.value})),placeholder:s("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),t.jsx(G,{size:"xs",className:"!font-normal shrink-0",onClick:()=>xe(me.id),disabled:g===`api:${me.id}`,children:g===`api:${me.id}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.saveKey")})]})]}),re.length>0&&t.jsx("div",{className:"space-y-4 border-t border-[var(--surface-subtle)] pt-2",children:re.map((U,ee)=>{const ne=U.label||U.name||s("settings.providers.page.auth.oauthMethodFallback",{index:String(ee+1)}),ue=`${me.id}:${ee}`,Me=w?.providerId===me.id&&w?.methodIndex===ee;return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:ne}),(U.description||U.help)&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:String(U.description||U.help)})]}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>we(me.id,ee),disabled:g===`oauth:${me.id}:${ee}`,children:s("settings.providers.page.actions.connect")})]}),y[ue]?.instructions&&t.jsx("p",{className:"typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded",children:y[ue]?.instructions}),y[ue]?.userCode&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(it,{value:y[ue]?.userCode,readOnly:!0,className:"font-mono text-center tracking-widest"}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ve(y[ue]?.userCode??""),children:s("settings.providers.page.actions.copyCode")})]}),y[ue]?.url&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(it,{value:y[ue]?.url,readOnly:!0,className:"text-xs text-muted-foreground"}),t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Hs(y[ue]?.url??""),children:s("settings.providers.page.actions.open")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ie(y[ue]?.url??""),children:s("settings.providers.page.actions.copy")})]})]}),Me&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx(it,{value:k[ue]??"",onChange:ke=>j(De=>({...De,[ue]:ke.target.value})),placeholder:s("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs"}),t.jsx(G,{size:"xs",className:"!font-normal",onClick:()=>he(me.id,ee),disabled:g===`oauth-complete:${me.id}:${ee}`,children:g===`oauth-complete:${me.id}:${ee}`?s("settings.providers.page.actions.saving"):s("settings.providers.page.actions.complete")})]})]},`${me.id}-${ne}`)})})]}):t.jsxs("div",{className:"flex items-center gap-1.5 py-1.5",children:[t.jsx(M,{name:"check",className:"w-4 h-4 text-[var(--status-success)] shrink-0"}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.providers.page.auth.connected")}),t.jsx("span",{className:"typography-meta text-muted-foreground ml-1",children:s("settings.providers.page.auth.useReconnectHint")})]})})]}),t.jsxs("div",{"data-settings-item":"providers.connection-details",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.providers.page.connectionDetails.title")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsxs("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col",children:oe&&(oe.auth.exists||oe.user.exists||oe.project.exists||oe.custom?.exists)?t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[s("settings.providers.page.connectionDetails.configuredIn")," ",[oe.auth.exists?s("settings.providers.page.connectionDetails.source.authCredentials"):null,oe.user.exists?s("settings.providers.page.connectionDetails.source.userConfig"):null,oe.project.exists?s("settings.providers.page.connectionDetails.source.projectConfig"):null,oe.custom?.exists?s("settings.providers.page.connectionDetails.source.customConfig"):null].filter(Boolean).join(", ")]}):t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.providers.page.connectionDetails.noActiveSource")})}),t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>ye(me.id),disabled:g===`disconnect:${me.id}`,children:g===`disconnect:${me.id}`?s("settings.providers.page.actions.disconnecting"):s("settings.providers.page.actions.disconnect")})]})})]}),t.jsxs("div",{"data-settings-item":"providers.models",className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1 flex items-center justify-between gap-2",children:[t.jsxs("h3",{className:"typography-ui-header font-medium text-foreground",children:[s("settings.providers.page.models.title"),be.length>0&&t.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",be.length,")"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const U=be.map(ee=>typeof ee?.id=="string"?ee.id:"").filter(ee=>ee.length>0);d(me.id,U)},children:s("settings.providers.page.actions.hideAll")}),t.jsx(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>c(me.id),children:s("settings.providers.page.actions.showAll")})]})]}),t.jsxs("section",{className:"px-2 pb-2 pt-0",children:[t.jsxs("div",{className:"relative mb-2",children:[t.jsx(M,{name:"search",className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),t.jsx(it,{value:D,onChange:U=>N(U.target.value),placeholder:s("settings.providers.page.models.filterPlaceholder"),className:"h-7 pl-8 w-full"})]}),ge.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground py-4 text-center",children:s("settings.providers.page.models.noModelsMatchFilter")}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:ge.map(U=>{const ee=typeof U?.id=="string"?U.id:"",ne=typeof U?.name=="string"?U.name:ee,ue=ee?r(me.id,ee):void 0,Me=i.some(Pe=>Pe.providerID===me.id&&Pe.modelID===ee),ke=Do(ue?.limit?.context),De=Do(ue?.limit?.output),Ae=[];return ue?.tool_call&&Ae.push({key:"tools",icon:"tools",label:s("settings.providers.page.models.capability.toolCalling")}),ue?.reasoning&&Ae.push({key:"reasoning",icon:"brain-ai-3",label:s("settings.providers.page.models.capability.reasoning")}),ue?.attachment&&Ae.push({key:"image",icon:"file-image",label:s("settings.providers.page.models.capability.imageInput")}),t.jsx("div",{className:"py-1.5",children:t.jsxs("div",{className:ce("flex items-center gap-3",Me&&"opacity-50"),children:[t.jsx("span",{className:"typography-meta font-medium text-foreground truncate flex-1 min-w-0",children:ne}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(ke||De)&&t.jsxs("span",{className:"typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:[ke?`${ke} ${s("settings.providers.page.models.tokenBadge.context")}`:"",ke&&De?" · ":"",De?`${De} ${s("settings.providers.page.models.tokenBadge.output")}`:""]}),Ae.length>0&&t.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:Ae.map(({key:Pe,icon:Re,label:Le})=>t.jsx("span",{className:"flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]",title:Le,"aria-label":Le,children:t.jsx(M,{name:Re,className:"h-3 w-3"})},Pe))}),t.jsx("button",{type:"button",onClick:()=>o(me.id,ee),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50",title:s(Me?"settings.providers.page.models.actions.showModelInSelectors":"settings.providers.page.models.actions.hideModelFromSelectors"),"aria-label":s(Me?"settings.providers.page.models.actions.showModel":"settings.providers.page.models.actions.hideModel"),children:Me?t.jsx(M,{name:"eye-off",className:"h-3.5 w-3.5"}):t.jsx(M,{name:"eye",className:"h-3.5 w-3.5"})})]})]})},ee)})})]})]})]})})};function Eo(s){const e=s.indexOf("/");if(e!==-1){const n=s.substring(0,e);if(n==="gemini"||n==="antigravity")return s.substring(e+1)}return s}const bf=[{id:"gemini-auth",label:"Gemini",matcher:s=>s.startsWith("gemini/"),order:1},{id:"antigravity-auth",label:"Antigravity",matcher:s=>s.startsWith("antigravity/"),order:2}],Vl={google:bf};function _l(s,e){const n=Vl[e]??[];for(const a of n)if(a.matcher(s))return a;return null}function vf(s){return Vl[s]??[]}function jf(s){return[...s].sort((e,n)=>e.order-n.order)}function Lv(s,e){const n=new Map;for(const a of Object.keys(s)){const i=_l(a,e)?.id??null;n.has(i)||n.set(i,[]),n.get(i).push(a)}return n}function wf(s,e,n){const a=new Map;for(const r of s){const i=e(r),d=_l(i,n)?.id??null;a.has(d)||a.set(d,[]),a.get(d).push(r)}return a}function Nf(s,e){return e.filter(n=>{const a=n.toLowerCase(),r=a.includes("/")?a.split("/")[1]:a;return!!(r.startsWith("gemini-3-")||r.startsWith("claude-"))})}const qr=6e4,Mo=s=>{const e=en.map(u=>u.id),n=typeof s?.usageAutoRefresh=="boolean"?s.usageAutoRefresh:!1,a=typeof s?.usageRefreshIntervalMs=="number"&&Number.isFinite(s.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(s.usageRefreshIntervalMs))):qr,r=s?.usageDisplayMode==="remaining"?"remaining":"usage",i=typeof s?.usageShowPredValues=="boolean"?s.usageShowPredValues:!1,o=Array.isArray(s?.usageDropdownProviders)?s?.usageDropdownProviders:null,d=o?o.filter(u=>typeof u=="string"&&e.includes(u)):e,c={},f=s?.usageSelectedModels;if(f&&typeof f=="object")for(const[u,S]of Object.entries(f))Array.isArray(S)&&(c[u]=S.filter(h=>typeof h=="string"));const m={},p=s?.usageExpandedFamilies;if(p&&typeof p=="object")for(const[u,S]of Object.entries(p))Array.isArray(S)&&(m[u]=S.filter(h=>typeof h=="string"));return{autoRefresh:n,refreshIntervalMs:a,displayMode:r,showPredValues:i,dropdownProviderIds:d,selectedModels:c,expandedFamilies:m}},kf=async()=>{const s=Fs()?.settings;if(s)try{const n=(await s.load())?.settings;return Mo(n??null)}catch{}if(!gs()){const e=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(e.ok){const n=await e.json().catch(()=>null);return Mo(n)}}return{autoRefresh:!1,refreshIntervalMs:qr,displayMode:"usage",showPredValues:!1,dropdownProviderIds:en.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Ht=rn()(Zn((s,e)=>({results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:qr,displayMode:"usage",showPredValues:!1,dropdownProviderIds:en.map(n=>n.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{try{const n=await kf();s(n)}catch(n){console.warn("Failed to load usage settings:",n)}},fetchAllQuotas:async()=>{s({isLoading:!0,error:null});const n=en.map(a=>a.id);try{await Promise.all(n.map(a=>e().fetchProviderQuota(a))),s({isLoading:!1,lastUpdated:Date.now()})}catch(a){const r=a instanceof Error?a.message:"Failed to fetch quotas";s({isLoading:!1,error:r})}},fetchProviderQuota:async n=>{s(a=>({isFetchingProvider:{...a.isFetchingProvider,[n]:!0}}));try{const a=await jt(`/api/quota/${encodeURIComponent(n)}`),r=await a.json().catch(()=>null);if(!a.ok)throw new Error(r?.error||"Failed to fetch quota");const i=r;s(o=>{const d=o.results.filter(c=>c.providerId!==n);return d.push(i),{results:d,error:null}})}catch(a){const r=a instanceof Error?a.message:"Failed to fetch quota",i={providerId:n,providerName:n,ok:!1,configured:!1,error:r,usage:null,fetchedAt:Date.now()};s(o=>{const d=o.results.filter(c=>c.providerId!==n);return d.push(i),{results:d,error:r}})}finally{s(a=>({isFetchingProvider:{...a.isFetchingProvider,[n]:!1}}))}},setSelectedProvider:n=>s({selectedProviderId:n}),setAutoRefresh:n=>s({autoRefresh:n}),setRefreshInterval:n=>{const a=Math.max(3e4,Math.min(3e5,Math.round(n)));s({refreshIntervalMs:a})},setDisplayMode:n=>s({displayMode:n}),setShowPredValues:n=>s({showPredValues:n}),setDropdownProviderIds:n=>s({dropdownProviderIds:n}),setSelectedModels:(n,a)=>{s(r=>({selectedModels:{...r.selectedModels,[n]:a}}))},toggleModelSelected:(n,a)=>{s(r=>{const i=r.selectedModels[n]??[],d=i.includes(a)?i.filter(c=>c!==a):[...i,a];return{selectedModels:{...r.selectedModels,[n]:d}}})},setExpandedFamilies:(n,a)=>{s(r=>({expandedFamilies:{...r.expandedFamilies,[n]:a}})),Pt({usageExpandedFamilies:e().expandedFamilies})},toggleFamilyExpanded:(n,a)=>{s(r=>{const i=r.expandedFamilies[n]??[],d=i.includes(a)?i.filter(c=>c!==a):[...i,a];return{expandedFamilies:{...r.expandedFamilies,[n]:d}}}),Pt({usageExpandedFamilies:e().expandedFamilies})},applyDefaultSelections:(n,a)=>{if((e().selectedModels[n]?.length??0)>0)return;const i=Nf(n,a);i.length!==0&&(s(o=>({selectedModels:{...o.selectedModels,[n]:i}})),Pt({usageSelectedModels:e().selectedModels}))}}),{name:"quota-store"})),Sf=()=>{const s=rt.c(5),e=Ht(Cf),n=Ht(Pf),a=Ht(If);let r,i;s[0]!==e||s[1]!==a||s[2]!==n?(r=()=>{if(!e)return;const o=window.setInterval(()=>{a()},n);return()=>window.clearInterval(o)},i=[e,n,a],s[0]=e,s[1]=a,s[2]=n,s[3]=r,s[4]=i):(r=s[3],i=s[4]),l.useEffect(r,i)};function Cf(s){return s.autoRefresh}function Pf(s){return s.refreshIntervalMs}function If(s){return s.fetchAllQuotas}const Df=s=>{const e=s?.windows??{},n=Object.values(e).map(a=>a.usedPercent).filter(a=>typeof a=="number");return n.length===0?null:Math.max(...n)},Af=s=>{const e=rt.c(122),{onItemSelect:n}=s,{t:a}=dt(),r=Ht(Ef),i=Ht(Mf),o=Ht(Rf),d=Ht(Tf),c=Ht(Ff),f=Ht(Lf),m=Ht(Of),p=Ht(zf),u=Ht(Kf),S=Ht($f),h=Ht(Uf),g=Ht(Bf),x=Ht(Vf),D=Ht(_f);let N,w;e[0]!==D?(N=()=>{D()},w=[D],e[0]=D,e[1]=N,e[2]=w):(N=e[1],w=e[2]),l.useEffect(N,w);const A=Hf;let k;e[3]!==u?(k=Ne=>{u(Ne),A({usageAutoRefresh:Ne})},e[3]=u,e[4]=k):k=e[4];const j=k;let y;e[5]!==S?(y=Ne=>{const Ee=Number(Ne);Number.isFinite(Ee)&&(S(Ee),A({usageRefreshIntervalMs:Ee}))},e[5]=S,e[6]=y):y=e[6];const P=y;let z;e[7]!==h?(z=Ne=>{Ne!=="usage"&&Ne!=="remaining"||(h(Ne),A({usageDisplayMode:Ne}))},e[7]=h,e[8]=z):z=e[8];const R=z;let I;e[9]!==x?(I=Ne=>{x(Ne),A({usageShowPredValues:Ne})},e[9]=x,e[10]=I):I=e[10];const v=I;let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=ce("flex h-full flex-col","bg-background"),e[11]=b):b=e[11];let L;e[12]!==a?(L=a("settings.usage.sidebar.title"),e[12]=a,e[13]=L):L=e[13];let E;e[14]!==L?(E=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:L}),e[14]=L,e[15]=E):E=e[15];let J;e[16]!==a?(J=a("settings.usage.sidebar.total",{count:en.length}),e[16]=a,e[17]=J):J=e[17];let _;e[18]!==J?(_=t.jsx("span",{className:"typography-meta text-muted-foreground",children:J}),e[18]=J,e[19]=_):_=e[19];let Z;e[20]!==a?(Z=a("settings.usage.sidebar.actions.toggleAutoRefreshAria"),e[20]=a,e[21]=Z):Z=e[21];let H;e[22]!==j||e[23]!==Z||e[24]!==f?(H=t.jsx(At,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx(It,{checked:f,onChange:j,ariaLabel:Z})})}),e[22]=j,e[23]=Z,e[24]=f,e[25]=H):H=e[25];let T;e[26]!==a?(T=a("settings.usage.sidebar.tooltip.autoRefresh"),e[26]=a,e[27]=T):T=e[27];let Y;e[28]!==T?(Y=t.jsx(Et,{side:"bottom",children:T}),e[28]=T,e[29]=Y):Y=e[29];let F;e[30]!==H||e[31]!==Y?(F=t.jsxs(Dt,{children:[H,Y]}),e[30]=H,e[31]=Y,e[32]=F):F=e[32];const V=String(m),Q=!f;let ie;e[33]!==a?(ie=a("settings.usage.sidebar.field.intervalPlaceholder"),e[33]=a,e[34]=ie):ie=e[34];let X;e[35]!==ie?(X=t.jsx(Lt,{className:"w-fit",children:t.jsx(Kt,{placeholder:ie})}),e[35]=ie,e[36]=X):X=e[36];let se;e[37]===Symbol.for("react.memo_cache_sentinel")?(se=t.jsxs(Ot,{children:[t.jsx(ht,{value:"30000",children:"30s"}),t.jsx(ht,{value:"60000",children:"1m"}),t.jsx(ht,{value:"300000",children:"5m"})]}),e[37]=se):se=e[37];let me;e[38]!==P||e[39]!==V||e[40]!==Q||e[41]!==X?(me=t.jsxs(Ft,{value:V,onValueChange:P,disabled:Q,children:[X,se]}),e[38]=P,e[39]=V,e[40]=Q,e[41]=X,e[42]=me):me=e[42];let oe;e[43]!==d?(oe=()=>d(),e[43]=d,e[44]=oe):oe=e[44];let xe;e[45]!==a?(xe=a("settings.usage.sidebar.actions.refreshAria"),e[45]=a,e[46]=xe):xe=e[46];let we;e[47]!==a?(we=a("settings.usage.sidebar.actions.refreshTitle"),e[47]=a,e[48]=we):we=e[48];const he=c&&"animate-spin";let Ie;e[49]!==he?(Ie=ce("h-3.5 w-3.5",he),e[49]=he,e[50]=Ie):Ie=e[50];let ve;e[51]!==Ie?(ve=t.jsx(M,{name:"refresh",className:Ie}),e[51]=Ie,e[52]=ve):ve=e[52];let ye;e[53]!==c||e[54]!==oe||e[55]!==xe||e[56]!==we||e[57]!==ve?(ye=t.jsx(G,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 text-muted-foreground",onClick:oe,"aria-label":xe,title:we,disabled:c,children:ve}),e[53]=c,e[54]=oe,e[55]=xe,e[56]=we,e[57]=ve,e[58]=ye):ye=e[58];let be;e[59]!==F||e[60]!==me||e[61]!==ye?(be=t.jsxs("div",{className:"flex items-center gap-2",children:[F,me,ye]}),e[59]=F,e[60]=me,e[61]=ye,e[62]=be):be=e[62];let te;e[63]!==_||e[64]!==be?(te=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[_,be]}),e[63]=_,e[64]=be,e[65]=te):te=e[65];let re;e[66]!==a?(re=a("settings.usage.sidebar.field.display"),e[66]=a,e[67]=re):re=e[67];let ge;e[68]!==re?(ge=t.jsx("span",{className:"typography-micro text-muted-foreground",children:re}),e[68]=re,e[69]=ge):ge=e[69];let U;e[70]!==a?(U=a("settings.usage.sidebar.field.displayModePlaceholder"),e[70]=a,e[71]=U):U=e[71];let ee;e[72]!==U?(ee=t.jsx(Lt,{className:"w-fit",children:t.jsx(Kt,{placeholder:U})}),e[72]=U,e[73]=ee):ee=e[73];let ne;e[74]!==a?(ne=a("settings.usage.sidebar.field.displayModeUsage"),e[74]=a,e[75]=ne):ne=e[75];let ue;e[76]!==ne?(ue=t.jsx(ht,{value:"usage",children:ne}),e[76]=ne,e[77]=ue):ue=e[77];let Me;e[78]!==a?(Me=a("settings.usage.sidebar.field.displayModeRemaining"),e[78]=a,e[79]=Me):Me=e[79];let ke;e[80]!==Me?(ke=t.jsx(ht,{value:"remaining",children:Me}),e[80]=Me,e[81]=ke):ke=e[81];let De;e[82]!==ue||e[83]!==ke?(De=t.jsxs(Ot,{children:[ue,ke]}),e[82]=ue,e[83]=ke,e[84]=De):De=e[84];let Ae;e[85]!==R||e[86]!==ee||e[87]!==De||e[88]!==p?(Ae=t.jsxs(Ft,{value:p,onValueChange:R,children:[ee,De]}),e[85]=R,e[86]=ee,e[87]=De,e[88]=p,e[89]=Ae):Ae=e[89];let Pe;e[90]!==ge||e[91]!==Ae?(Pe=t.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[ge,Ae]}),e[90]=ge,e[91]=Ae,e[92]=Pe):Pe=e[92];let Re;e[93]!==a?(Re=a("settings.usage.sidebar.field.showPredictions"),e[93]=a,e[94]=Re):Re=e[94];let Le;e[95]!==Re?(Le=t.jsx("span",{className:"typography-micro text-muted-foreground",children:Re}),e[95]=Re,e[96]=Le):Le=e[96];let $e;e[97]!==a?($e=a("settings.usage.sidebar.field.showPredictions"),e[97]=a,e[98]=$e):$e=e[98];let Be;e[99]!==v||e[100]!==g||e[101]!==$e?(Be=t.jsx(It,{checked:g,onChange:v,ariaLabel:$e}),e[99]=v,e[100]=g,e[101]=$e,e[102]=Be):Be=e[102];let Oe;e[103]!==Le||e[104]!==Be?(Oe=t.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[Le,Be]}),e[103]=Le,e[104]=Be,e[105]=Oe):Oe=e[105];let Ue;e[106]!==te||e[107]!==Pe||e[108]!==Oe||e[109]!==E?(Ue=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[E,te,Pe,Oe]}),e[106]=te,e[107]=Pe,e[108]=Oe,e[109]=E,e[110]=Ue):Ue=e[110];let le;e[111]!==n||e[112]!==r||e[113]!==i||e[114]!==o||e[115]!==a?(le=en.map(Ne=>{const Ee=r.find(O=>O.providerId===Ne.id),Ce=Df(Ee?.usage),He=jl(Ce),q=Ne.id===i,$=Ee?.configured??!1,fe=$?He==="critical"?{backgroundColor:"var(--status-error)"}:He==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"}:{backgroundColor:"var(--surface-muted-foreground)",opacity:.4};return t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",q?"bg-interactive-selection":"hover:bg-interactive-hover"),children:t.jsxs("button",{type:"button",onClick:()=>{o(Ne.id),n?.()},className:"flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsx("span",{className:"h-2.5 w-2.5 rounded-full flex-shrink-0",style:fe}),t.jsx(An,{providerId:Ne.id,className:"h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:Ne.name}),!$&&t.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:a("settings.usage.sidebar.status.notSet")})]})},Ne.id)}),e[111]=n,e[112]=r,e[113]=i,e[114]=o,e[115]=a,e[116]=le):le=e[116];let W;e[117]!==le?(W=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:le}),e[117]=le,e[118]=W):W=e[118];let de;return e[119]!==Ue||e[120]!==W?(de=t.jsxs("div",{className:b,children:[Ue,W]}),e[119]=Ue,e[120]=W,e[121]=de):de=e[121],de};function Ef(s){return s.results}function Mf(s){return s.selectedProviderId}function Rf(s){return s.setSelectedProvider}function Tf(s){return s.fetchAllQuotas}function Ff(s){return s.isLoading}function Lf(s){return s.autoRefresh}function Of(s){return s.refreshIntervalMs}function zf(s){return s.displayMode}function Kf(s){return s.setAutoRefresh}function $f(s){return s.setRefreshInterval}function Uf(s){return s.setDisplayMode}function Bf(s){return s.showPredValues}function Vf(s){return s.setShowPredValues}function _f(s){return s.loadSettings}async function Hf(s){try{await Pt(s)}catch(e){console.warn("Failed to save usage settings:",e)}}const Wf=s=>{const e=rt.c(20),{percent:n,tonePercent:a,className:r,expectedMarkerPercent:i}=s;let o;e[0]!==n?(o=Qd(n)??0,e[0]=n,e[1]=o):o=e[1];const d=o,c=a??n;let f;e[2]!==c?(f=jl(c),e[2]=c,e[3]=f):f=e[3];const m=f,p=i!=null?Math.max(0,Math.min(100,i)):null;let u;e[4]!==m?(u=m==="critical"?{backgroundColor:"var(--status-error)"}:m==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=m,e[5]=u):u=e[5];const S=u;let h;e[6]!==r?(h=ce("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",r),e[6]=r,e[7]=h):h=e[7];const g=`${d}%`;let x;e[8]!==S||e[9]!==g?(x={...S,width:g},e[8]=S,e[9]=g,e[10]=x):x=e[10];let D;e[11]!==d||e[12]!==x?(D=t.jsx("div",{className:"h-full transition-all duration-300",style:x,role:"progressbar","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100}),e[11]=d,e[12]=x,e[13]=D):D=e[13];let N;e[14]!==p?(N=p!=null&&p>0&&p<100&&t.jsx("div",{className:"absolute top-0 h-full w-0.5 bg-foreground",style:{left:`${p}%`},title:`Expected usage if spread evenly: ${Math.round(p)}% of quota`,"aria-hidden":"true"}),e[14]=p,e[15]=N):N=e[15];let w;return e[16]!==h||e[17]!==D||e[18]!==N?(w=t.jsxs("div",{className:h,children:[D,N]}),e[16]=h,e[17]=D,e[18]=N,e[19]=w):w=e[19],w},qf=s=>{const e=rt.c(67),{paceInfo:n,className:a,compact:r}=s,i=r===void 0?!1:r,{t:o}=dt();let d;e[0]!==n.status?(d=Yd(n.status),e[0]=n.status,e[1]=d):d=e[1];const c=d;let f;e:{switch(n.status){case"on-track":{let y;e[2]!==o?(y=o("settings.usage.pace.status.onTrack"),e[2]=o,e[3]=y):y=e[3],f=y;break e}case"slightly-fast":{let y;e[4]!==o?(y=o("settings.usage.pace.status.slightlyFast"),e[4]=o,e[5]=y):y=e[5],f=y;break e}case"too-fast":{let y;e[6]!==o?(y=o("settings.usage.pace.status.tooFast"),e[6]=o,e[7]=y):y=e[7],f=y;break e}case"exhausted":{let y;e[8]!==o?(y=o("settings.usage.pace.status.usedUp"),e[8]=o,e[9]=y):y=e[9],f=y;break e}}f=void 0}const m=f;let p;e[10]!==n.predictText||e[11]!==o?(p=o("settings.usage.pace.predictionTooltip",{prediction:n.predictText}),e[10]=n.predictText,e[11]=o,e[12]=p):p=e[12];const u=p;if(i){let y;e[13]!==a?(y=ce("flex items-center gap-1.5",a),e[13]=a,e[14]=y):y=e[14];let P;e[15]!==c?(P={backgroundColor:c},e[15]=c,e[16]=P):P=e[16];let z;e[17]!==m||e[18]!==P?(z=t.jsx("div",{className:"h-2 w-2 rounded-full flex-shrink-0",style:P,title:m}),e[17]=m,e[18]=P,e[19]=z):z=e[19];let R;e[20]!==c?(R={color:c},e[20]=c,e[21]=R):R=e[21];const I=n.isExhausted?void 0:u;let v;e[22]!==n.isExhausted||e[23]!==n.predictText||e[24]!==n.remainingSeconds||e[25]!==o?(v=n.isExhausted?t.jsx(t.Fragment,{children:o("settings.usage.pace.wait",{duration:ui(n.remainingSeconds)})}):t.jsx(t.Fragment,{children:o("settings.usage.pace.prediction",{prediction:n.predictText})}),e[22]=n.isExhausted,e[23]=n.predictText,e[24]=n.remainingSeconds,e[25]=o,e[26]=v):v=e[26];let b;e[27]!==v||e[28]!==R||e[29]!==I?(b=t.jsx("span",{className:"typography-micro tabular-nums",style:R,title:I,children:v}),e[27]=v,e[28]=R,e[29]=I,e[30]=b):b=e[30];let L;return e[31]!==b||e[32]!==y||e[33]!==z?(L=t.jsxs("div",{className:y,children:[z,b]}),e[31]=b,e[32]=y,e[33]=z,e[34]=L):L=e[34],L}let S;e[35]!==a?(S=ce("flex items-center justify-between gap-2",a),e[35]=a,e[36]=S):S=e[36];let h;e[37]!==n.isExhausted||e[38]!==n.paceRateText||e[39]!==o?(h=!n.isExhausted&&t.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.usage.pace.rate",{rate:n.paceRateText})}),e[37]=n.isExhausted,e[38]=n.paceRateText,e[39]=o,e[40]=h):h=e[40];let g;e[41]!==h?(g=t.jsx("div",{className:"flex items-center gap-1.5",children:h}),e[41]=h,e[42]=g):g=e[42];let x;e[43]!==c?(x={color:c},e[43]=c,e[44]=x):x=e[44];let D;e[45]!==n.isExhausted||e[46]!==n.predictText||e[47]!==n.remainingSeconds||e[48]!==u||e[49]!==m||e[50]!==o?(D=n.isExhausted?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-medium",children:m}),t.jsx("span",{className:"text-muted-foreground",children:o("settings.usage.pace.waitSeparator")}),t.jsx("span",{className:"font-medium",children:ui(n.remainingSeconds)})]}):t.jsxs("span",{title:u,children:[t.jsx("span",{className:"text-muted-foreground",children:o("settings.usage.pace.predictionLabel")}),t.jsx("span",{className:"font-medium",children:n.predictText})]}),e[45]=n.isExhausted,e[46]=n.predictText,e[47]=n.remainingSeconds,e[48]=u,e[49]=m,e[50]=o,e[51]=D):D=e[51];let N;e[52]!==x||e[53]!==D?(N=t.jsx("span",{className:"typography-micro tabular-nums",style:x,children:D}),e[52]=x,e[53]=D,e[54]=N):N=e[54];let w;e[55]!==c?(w={backgroundColor:c},e[55]=c,e[56]=w):w=e[56];let A;e[57]!==m||e[58]!==w?(A=t.jsx("div",{className:"h-2 w-2 rounded-full flex-shrink-0",style:w,title:m}),e[57]=m,e[58]=w,e[59]=A):A=e[59];let k;e[60]!==N||e[61]!==A?(k=t.jsxs("div",{className:"flex items-center gap-1.5",children:[N,A]}),e[60]=N,e[61]=A,e[62]=k):k=e[62];let j;return e[63]!==k||e[64]!==S||e[65]!==g?(j=t.jsxs("div",{className:S,children:[g,k]}),e[63]=k,e[64]=S,e[65]=g,e[66]=j):j=e[66],j},cr=s=>{const e=rt.c(54),{title:n,window:a,subtitle:r,showToggle:i,toggleEnabled:o,onToggle:d}=s,c=i===void 0?!1:i,f=o===void 0?!1:o,m=Ht(Gf),p=Ht(Jf),u=Ke(Qf),S=m==="remaining"?a.remainingPercent:a.usedPercent,h=m==="remaining"?"remaining":"used";let g;e[0]!==S||e[1]!==a.valueLabel?(g=Xd(a.valueLabel,S),e[0]=S,e[1]=a.valueLabel,e[2]=g):g=e[2];const x=g,D=a.resetAfterFormatted??a.resetAtFormatted;let N;e[3]!==D||e[4]!==u||e[5]!==a.resetAt?(N=Zd(a.resetAt,D,u),e[3]=D,e[4]=u,e[5]=a.resetAt,e[6]=N):N=e[6];const w=N;let A;e[7]!==n?(A=em(n),e[7]=n,e[8]=A):A=e[8];const k=A;let j;e[9]!==n||e[10]!==a.resetAt||e[11]!==a.usedPercent||e[12]!==a.windowSeconds?(j=tm(a.usedPercent,a.resetAt,a.windowSeconds,n),e[9]=n,e[10]=a.resetAt,e[11]=a.usedPercent,e[12]=a.windowSeconds,e[13]=j):j=e[13];const y=j;let P;e:{if(!y||y.dailyAllocationPercent===null){P=null;break e}const X=sm(y.elapsedRatio);P=m==="remaining"?100-X:X}const z=P;let R;e[14]!==d||e[15]!==c||e[16]!==f?(R=c&&t.jsx(It,{checked:f,onChange:X=>d?.(X),ariaLabel:"Show in dropdown"}),e[14]=d,e[15]=c,e[16]=f,e[17]=R):R=e[17];let I;e[18]!==k?(I=t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:k}),e[18]=k,e[19]=I):I=e[19];let v;e[20]!==r?(v=r&&t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:r}),e[20]=r,e[21]=v):v=e[21];let b;e[22]!==I||e[23]!==v?(b=t.jsxs("div",{className:"min-w-0 flex flex-col",children:[I,v]}),e[22]=I,e[23]=v,e[24]=b):b=e[24];let L;e[25]!==b||e[26]!==R?(L=t.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[R,b]}),e[25]=b,e[26]=R,e[27]=L):L=e[27];const E=x==="-"?"":x;let J;e[28]!==E?(J=t.jsx("div",{className:"typography-ui-label text-foreground tabular-nums flex items-center justify-end",children:E}),e[28]=E,e[29]=J):J=e[29];let _;e[30]!==L||e[31]!==J?(_=t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[L,J]}),e[30]=L,e[31]=J,e[32]=_):_=e[32];let Z;e[33]!==S||e[34]!==z||e[35]!==a.usedPercent?(Z=t.jsx(Wf,{percent:S,tonePercent:a.usedPercent,expectedMarkerPercent:z,className:"h-1.5"}),e[33]=S,e[34]=z,e[35]=a.usedPercent,e[36]=Z):Z=e[36];const H=w?`Resets ${w}`:"";let T;e[37]!==H?(T=t.jsx("span",{className:"typography-micro text-muted-foreground",children:H}),e[37]=H,e[38]=T):T=e[38];let Y;e[39]!==h?(Y=t.jsx("span",{className:"typography-micro text-muted-foreground",children:h}),e[39]=h,e[40]=Y):Y=e[40];let F;e[41]!==T||e[42]!==Y?(F=t.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[T,Y]}),e[41]=T,e[42]=Y,e[43]=F):F=e[43];let V;e[44]!==Z||e[45]!==F?(V=t.jsxs("div",{className:"mt-2.5",children:[Z,F]}),e[44]=Z,e[45]=F,e[46]=V):V=e[46];let Q;e[47]!==y||e[48]!==p?(Q=y&&p&&t.jsx("div",{className:"mt-1.5",children:t.jsx(qf,{paceInfo:y})}),e[47]=y,e[48]=p,e[49]=Q):Q=e[49];let ie;return e[50]!==_||e[51]!==V||e[52]!==Q?(ie=t.jsxs("div",{className:"py-3",children:[_,V,Q]}),e[50]=_,e[51]=V,e[52]=Q,e[53]=ie):ie=e[53],ie};function Gf(s){return s.displayMode}function Jf(s){return s.showPredValues}function Qf(s){return s.timeFormatPreference}const Yf=(s,e)=>{if(!s)return"-";try{return wl(s,e,{fallback:"-"})}catch{return"-"}},Xf=()=>{const{t:s}=dt(),e=Ke(b=>b.timeFormatPreference),n=Ht(b=>b.results),a=Ht(b=>b.selectedProviderId),r=Ht(b=>b.setSelectedProvider),i=Ht(b=>b.loadSettings),o=Ht(b=>b.fetchAllQuotas),d=Ht(b=>b.isLoading),c=Ht(b=>b.lastUpdated),f=Ht(b=>b.error),m=Ht(b=>b.dropdownProviderIds),p=Ht(b=>b.setDropdownProviderIds),u=Ht(b=>b.selectedModels),S=Ht(b=>b.toggleModelSelected),h=Ht(b=>b.applyDefaultSelections);Sf(),l.useEffect(()=>{i(),o()},[i,o]),l.useEffect(()=>{if(a||n.length===0)return;const b=n.find(L=>L.configured)?.providerId;r(b??en[0]?.id??null)},[n,a,r]);const g=n.find(b=>b.providerId===a)??null,D=en.find(b=>b.id===a)?.name??a??s("settings.usage.sidebar.title"),N=g?.usage,w=a?m.includes(a):!1,A=l.useCallback(b=>{if(!a)return;const L=b?Array.from(new Set([...m,a])):m.filter(E=>E!==a);p(L),Pt({usageDropdownProviders:L})},[m,a,p]),k=l.useMemo(()=>N?.models?Object.entries(N.models).map(([b,L])=>({name:b,windows:L})).filter(b=>Object.keys(b.windows.windows).length>0):[],[N?.models]);l.useEffect(()=>{a&&k.length>0&&h(a,k.map(b=>b.name))},[a,k,h]);const j=l.useMemo(()=>!a||k.length===0?new Map:wf(k,b=>b.name,a),[k,a]),y=l.useMemo(()=>{if(!a)return[];const b=vf(a);return jf(b)},[a]),[P,z]=l.useState(()=>({})),R=l.useCallback(b=>{z(L=>({...L,[b]:!L[b]}))},[]),I=l.useCallback(b=>{if(!a)return;S(a,b);const L=u[a]??[],J=L.includes(b)?L.filter(Z=>Z!==b):[...L,b],_={...u,[a]:J};Pt({usageSelectedModels:_})},[a,u,S]),v=a?u[a]??[]:[];return a?t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx(An,{providerId:a,className:"h-5 w-5 shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:s("settings.usage.page.header.providerUsage",{provider:D})}),t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:d?t.jsx("span",{className:"animate-pulse",children:s("settings.usage.page.header.refreshing")}):s("settings.usage.page.header.lastUpdated",{time:Yf(c,e)})})]})]}),t.jsx("div",{"data-settings-item":"usage.header-menu",className:"mb-8 px-2",children:t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":w,onClick:()=>A(!w),onKeyDown:b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),A(!w))},children:[t.jsx(It,{checked:w,onChange:A,ariaLabel:s("settings.usage.page.options.showInHeaderAria")}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.usage.page.options.showInHeader")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.usage.page.options.showInHeaderTooltip")})]})]})]})}),!g&&t.jsx("div",{className:"mb-8 px-2",children:t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.usage.page.state.noData")})}),f&&t.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[t.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:s("settings.usage.page.state.refreshFailedTitle")}),t.jsx("p",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:f})]}),g&&!g.configured&&t.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3",children:[t.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-warning)]",children:s("settings.usage.page.state.providerNotConfiguredTitle")}),t.jsx("p",{className:"typography-meta text-[var(--status-warning)]/80 mt-1",children:s("settings.usage.page.state.providerNotConfiguredDescription")})]}),N?.windows&&Object.keys(N.windows).length>0&&t.jsx("div",{"data-settings-item":"usage.model-quotas",className:"mb-8",children:t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Object.entries(N.windows).map(([b,L])=>t.jsx(cr,{title:b,window:L},b))})})}),k.length>0&&t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.usage.page.section.modelQuotas")})}),t.jsxs("div",{className:"space-y-3",children:[y.map(b=>{const L=j.get(b.id)??[];if(L.length===0)return null;const E=P[b.id]??!1;return t.jsx("section",{className:"p-2",children:t.jsxs(gn,{open:!E,onOpenChange:()=>R(b.id),children:[t.jsxs(hn,{className:"flex w-full items-center justify-between py-0.5 group",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[t.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:b.label}),t.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",L.length,")"]})]}),E?t.jsx(M,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(fn,{children:t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:L.map(J=>{const _=Object.entries(J.windows.windows);if(_.length===0)return null;const[Z,H]=_[0],T=v.includes(J.name);return t.jsx(cr,{title:Z,subtitle:Eo(J.name),window:H,showToggle:!0,toggleEnabled:T,onToggle:()=>I(J.name)},J.name)})})})]})},b.id)}),(()=>{const b=j.get(null)??[];if(b.length===0)return null;const L=P.other??!1;return t.jsx("section",{className:"p-2",children:t.jsxs(gn,{open:!L,onOpenChange:()=>R("other"),children:[t.jsxs(hn,{className:"flex w-full items-center justify-between py-0.5 group",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[t.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:s("settings.usage.page.section.otherModels")}),t.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",b.length,")"]})]}),L?t.jsx(M,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):t.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),t.jsx(fn,{children:t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:b.map(E=>{const J=Object.entries(E.windows.windows);if(J.length===0)return null;const[_,Z]=J[0],H=v.includes(E.name);return t.jsx(cr,{title:_,subtitle:Eo(E.name),window:Z,showToggle:!0,toggleEnabled:H,onToggle:()=>I(E.name)},E.name)})})})]})})})()]})]}),g?.configured&&N&&Object.keys(N.windows??{}).length===0&&k.length===0&&t.jsxs("div",{className:"mb-8 px-2",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.usage.page.state.noQuotaWindowsTitle")}),t.jsx("p",{className:"typography-meta text-muted-foreground mt-1",children:s("settings.usage.page.state.noQuotaWindowsDescription")})]})]})}):t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t.jsx("p",{className:"typography-body",children:s("settings.usage.page.empty.selectProvider")})})},Zf="git.commit.generate",Fr=rn(s=>({selectedPromptId:Zf,setSelectedPromptId:e=>{s(n=>n.selectedPromptId===e?n:{selectedPromptId:e})}})),ex=s=>{const e=rt.c(23),{onItemSelect:n}=s,{t:a}=dt(),r=Fr(tx),i=Fr(sx);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={groupKey:"settings.magicPrompts.sidebar.group.git",items:[{id:"git.commit.generate",titleKey:"settings.magicPrompts.sidebar.item.gitCommitGenerate"},{id:"git.pr.generate",titleKey:"settings.magicPrompts.sidebar.item.gitPrGenerate"},{id:"git.conflict.resolve",titleKey:"settings.magicPrompts.sidebar.item.gitConflictResolve"},{id:"git.integrate.cherrypick.resolve",titleKey:"settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve"}]},e[0]=o):o=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={groupKey:"settings.magicPrompts.sidebar.group.github",items:[{id:"github.pr.review",titleKey:"settings.magicPrompts.sidebar.item.githubPrReview"},{id:"github.issue.review",titleKey:"settings.magicPrompts.sidebar.item.githubIssueReview"},{id:"github.pr.checks.review",titleKey:"settings.magicPrompts.sidebar.item.githubPrFailedChecksReview"},{id:"github.pr.comments.review",titleKey:"settings.magicPrompts.sidebar.item.githubPrCommentsReview"},{id:"github.pr.comment.single",titleKey:"settings.magicPrompts.sidebar.item.githubSinglePrCommentReview"}]},e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={groupKey:"settings.magicPrompts.sidebar.group.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[2]=c):c=e[2];let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=[o,d,c,{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.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[3]=f):f=e[3];const m=f;let p;e[4]!==a?(p=a("settings.magicPrompts.sidebar.title"),e[4]=a,e[5]=p):p=e[5];let u;e[6]!==p?(u=t.jsx("h2",{className:"text-base font-semibold text-foreground",children:p}),e[6]=p,e[7]=u):u=e[7];let S;e[8]!==a?(S=a("settings.magicPrompts.sidebar.description"),e[8]=a,e[9]=S):S=e[9];let h;e[10]!==S?(h=t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:S}),e[10]=S,e[11]=h):h=e[11];let g;e[12]!==u||e[13]!==h?(g=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[u,h]}),e[12]=u,e[13]=h,e[14]=g):g=e[14];let x;e[15]!==n||e[16]!==r||e[17]!==i||e[18]!==a?(x=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"space-y-3 px-3 py-2 overflow-x-hidden",children:m.map(N=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"typography-micro px-1 text-muted-foreground",children:a(N.groupKey)}),N.items.map(w=>{const A=r===w.id;return t.jsx("button",{type:"button",onClick:()=>{i(w.id),n?.()},className:ce("flex w-full items-center rounded-md px-2 py-1.5 text-left transition-colors",A?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-ui-label truncate font-normal",children:a(w.titleKey)})},w.id)})]},N.groupKey))}),e[15]=n,e[16]=r,e[17]=i,e[18]=a,e[19]=x):x=e[19];let D;return e[20]!==x||e[21]!==g?(D=t.jsxs("div",{className:"flex h-full flex-col bg-background",children:[g,x]}),e[20]=x,e[21]=g,e[22]=D):D=e[22],D};function tx(s){return s.selectedPromptId}function sx(s){return s.setSelectedPromptId}const Ro={"git.commit.generate":{titleKey:"settings.magicPrompts.page.group.gitCommitGenerate.title",descriptionKey:"settings.magicPrompts.page.group.gitCommitGenerate.description",blocks:[{id:"git.commit.generate.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.commit.generate.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.pr.generate":{titleKey:"settings.magicPrompts.page.group.gitPrGenerate.title",descriptionKey:"settings.magicPrompts.page.group.gitPrGenerate.description",blocks:[{id:"git.pr.generate.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.pr.generate.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.pr.review":{titleKey:"settings.magicPrompts.page.group.githubPrReview.title",descriptionKey:"settings.magicPrompts.page.group.githubPrReview.description",blocks:[{id:"github.pr.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.pr.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.issue.review":{titleKey:"settings.magicPrompts.page.group.githubIssueReview.title",descriptionKey:"settings.magicPrompts.page.group.githubIssueReview.description",blocks:[{id:"github.issue.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.issue.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.pr.checks.review":{titleKey:"settings.magicPrompts.page.group.githubPrFailedChecksReview.title",descriptionKey:"settings.magicPrompts.page.group.githubPrFailedChecksReview.description",blocks:[{id:"github.pr.checks.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.pr.checks.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.pr.comments.review":{titleKey:"settings.magicPrompts.page.group.githubPrCommentsReview.title",descriptionKey:"settings.magicPrompts.page.group.githubPrCommentsReview.description",blocks:[{id:"github.pr.comments.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.pr.comments.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"github.pr.comment.single":{titleKey:"settings.magicPrompts.page.group.githubSinglePrCommentReview.title",descriptionKey:"settings.magicPrompts.page.group.githubSinglePrCommentReview.description",blocks:[{id:"github.pr.comment.single.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"github.pr.comment.single.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.conflict.resolve":{titleKey:"settings.magicPrompts.page.group.gitConflictResolve.title",descriptionKey:"settings.magicPrompts.page.group.gitConflictResolve.description",blocks:[{id:"git.conflict.resolve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.conflict.resolve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.integrate.cherrypick.resolve":{titleKey:"settings.magicPrompts.page.group.gitCherrypickConflictResolve.title",descriptionKey:"settings.magicPrompts.page.group.gitCherrypickConflictResolve.description",blocks:[{id:"git.integrate.cherrypick.resolve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.integrate.cherrypick.resolve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"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.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"}]}},To=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),dr=s=>s.endsWith(".visible"),nx=()=>{const{t:s}=dt(),e=l.useCallback(j=>s(j),[s]),n=Fr(j=>j.selectedPromptId),[a,r]=l.useState(!0),[i,o]=l.useState({}),[d,c]=l.useState({}),[f,m]=l.useState({}),[p,u]=l.useState({}),[S,h]=l.useState(!1);l.useEffect(()=>{let j=!0;return(async()=>{r(!0);try{const P=await im();if(!j)return;o(P)}catch(P){console.warn("Failed to load magic prompts:",P),B.error(s("settings.magicPrompts.page.toast.loadFailed"))}finally{j&&r(!1)}})(),()=>{j=!1}},[s]);const g=Ro[n]??Ro["git.commit.generate"],x=l.useCallback(j=>To(i,j)?i[j]:qa(j),[i]),D=l.useCallback(j=>d[j]??x(j),[d,x]),N=l.useCallback((j,y)=>{c(P=>P[j]===y?P:{...P,[j]:y})},[]),w=l.useCallback(async j=>{const y=D(j);if(dr(j)&&y.trim().length===0){B.error(s("settings.magicPrompts.page.toast.visiblePromptRequired"));return}m(P=>({...P,[j]:!0}));try{const P=y===qa(j)?await pi(j):await nm(j,y);o(P.overrides),B.success(s("settings.magicPrompts.page.toast.saved"))}catch(P){const z=P instanceof Error?P.message:String(P);B.error(s("settings.magicPrompts.page.toast.saveFailed"),{description:z})}finally{m(P=>({...P,[j]:!1}))}},[D,s]),A=l.useCallback(async j=>{u(y=>({...y,[j]:!0}));try{const y=await pi(j);o(y.overrides),c(P=>({...P,[j]:qa(j)})),B.success(s("settings.magicPrompts.page.toast.resetSuccess"))}catch(y){const P=y instanceof Error?y.message:String(y);B.error(s("settings.magicPrompts.page.toast.resetFailed"),{description:P})}finally{u(y=>({...y,[j]:!1}))}},[s]),k=l.useCallback(async()=>{h(!0);try{const j=await am();o(j.overrides),c({}),B.success(s("settings.magicPrompts.page.toast.resetAllSuccess"))}catch(j){const y=j instanceof Error?j.message:String(j);B.error(s("settings.magicPrompts.page.toast.resetAllFailed"),{description:y})}finally{h(!1)}},[s]);return a?t.jsxs("div",{className:"py-6 px-6 flex items-center gap-2 text-muted-foreground",children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":s("settings.magicPrompts.page.loading.aria")}),t.jsx("span",{className:"typography-ui",children:s("settings.magicPrompts.page.loading.text")})]}):t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto w-full max-w-4xl px-6 py-6 space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsx("div",{className:"space-y-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground",children:e(g.titleKey)}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:e(g.descriptionKey)})]})]})}),t.jsx(G,{"data-settings-item":"magic-prompts.reset-overrides",variant:"outline",size:"sm",onClick:()=>{k()},disabled:S||Object.keys(i).length===0,children:s(S?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetAllOverrides")})]}),g.blocks.map((j,y)=>{const P=rm(j.id),z=x(j.id),R=D(j.id),I=To(i,j.id),v=R!==z,b=dr(j.id)&&R.trim().length===0,L=f[j.id]===!0,E=p[j.id]===!0;return t.jsxs("section",{"data-settings-item":dr(j.id)?"magic-prompts.visible-prompt":"magic-prompts.instructions",className:y>0?"space-y-3 pt-5 border-t border-border":"space-y-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:e(j.titleKey)}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:P.description})]})]}),P.placeholders&&P.placeholders.length>0&&t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[s("settings.magicPrompts.page.placeholdersLabel")," ",P.placeholders.map(J=>`{{${J.key}}}`).join(", ")]})]}),t.jsx(ps,{value:R,onChange:J=>N(j.id,J.target.value),className:"min-h-[220px] font-mono text-sm"}),b&&t.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:s("settings.magicPrompts.page.validation.visiblePromptRequired")}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground",children:s(v?"settings.magicPrompts.page.status.unsavedChanges":I?"settings.magicPrompts.page.status.usingSavedOverride":"settings.magicPrompts.page.status.usingBuiltinDefault")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"outline",size:"sm",onClick:()=>{A(j.id)},disabled:!I||L||E,children:s(E?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetToDefault")}),t.jsx(G,{size:"sm",onClick:()=>{w(j.id)},disabled:!v||L||E||b,children:s(L?"settings.common.actions.saving":"settings.magicPrompts.page.actions.save")})]})]})]},j.id)})]})})},ax=s=>{const e=rt.c(89),{onItemSelect:n}=s,{t:a}=dt(),[r,i]=l.useState(null),[o,d]=l.useState(null),[c,f]=l.useState(null),{selectedSnippetName:m,snippets:p,setSelectedSnippet:u,setSnippetDraft:S,deleteSnippet:h,loadSnippets:g}=Ba(Ss(rx));let x,D;e[0]!==g?(x=()=>{g()},D=[g],e[0]=g,e[1]=x,e[2]=D):(x=e[1],D=e[2]),l.useEffect(x,D);let N;e[3]!==n||e[4]!==u||e[5]!==S||e[6]!==p?(N=async()=>{const te=new Set(p.map(ix));let re="new-snippet",ge=1;for(;te.has(re);)re=`new-snippet-${ge++}`;S({name:re,scope:"global"}),u(re),n?.()},e[3]=n,e[4]=u,e[5]=S,e[6]=p,e[7]=N):N=e[7];const w=N;let A;e[8]!==r||e[9]!==h||e[10]!==a?(A=async()=>{if(!r)return;await h(r.name)?(B.success(a("settings.snippets.sidebar.toast.deleted")),i(null)):B.error(a("settings.snippets.sidebar.toast.deleteFailed"))},e[8]=r,e[9]=h,e[10]=a,e[11]=A):A=e[11];const k=A;let j;e[12]!==p?(j=[...p].sort(ox),e[12]=p,e[13]=j):j=e[13];const y=j;let P;e[14]===Symbol.for("react.memo_cache_sentinel")?(P=ce("flex h-full flex-col","bg-background"),e[14]=P):P=e[14];let z;e[15]!==a?(z=a("settings.snippets.sidebar.title"),e[15]=a,e[16]=z):z=e[16];let R;e[17]!==z?(R=t.jsx("h2",{className:"text-base font-semibold text-foreground mb-3",children:z}),e[17]=z,e[18]=R):R=e[18];let I;e[19]!==p.length||e[20]!==a?(I=a("settings.snippets.sidebar.total",{count:p.length}),e[19]=p.length,e[20]=a,e[21]=I):I=e[21];let v;e[22]!==I?(v=t.jsx("span",{className:"typography-meta text-muted-foreground",children:I}),e[22]=I,e[23]=v):v=e[23];let b;e[24]!==a?(b=a("settings.snippets.sidebar.actions.create"),e[24]=a,e[25]=b):b=e[25];let L;e[26]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),e[26]=L):L=e[26];let E;e[27]!==w||e[28]!==b?(E=t.jsx(G,{size:"sm","data-settings-item":"snippets.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:w,"aria-label":b,children:L}),e[27]=w,e[28]=b,e[29]=E):E=e[29];let J;e[30]!==v||e[31]!==E?(J=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,E]}),e[30]=v,e[31]=E,e[32]=J):J=e[32];let _;e[33]!==J||e[34]!==R?(_=t.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[R,J]}),e[33]=J,e[34]=R,e[35]=_):_=e[35];let Z;if(e[36]!==n||e[37]!==o||e[38]!==c||e[39]!==m||e[40]!==u||e[41]!==y||e[42]!==a){let te;e[44]!==n||e[45]!==o||e[46]!==c||e[47]!==m||e[48]!==u||e[49]!==a?(te=re=>t.jsxs(tn,{open:c===re.name,onOpenChange:ge=>f(ge?re.name:null),children:[t.jsxs(sn,{render:t.jsx("div",{className:ce("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",m===re.name?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:ge=>{ge.preventDefault(),f(re.name)}}),children:[t.jsxs("button",{onClick:()=>{u(re.name),n?.()},className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["#",re.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:a(`snippets.source.${re.source}`)})]}),t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:re.description||re.content.replace(/\s+/g," ").substring(0,80)})]}),t.jsxs(us,{open:o===re.name,onOpenChange:ge=>{ge&&f(null),d(ge?re.name:null)},children:[t.jsx(ds,{asChild:!0,children:t.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100","aria-label":a("settings.snippets.sidebar.actions.more",{name:re.name}),children:t.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),t.jsx(ms,{align:"end",className:"w-fit min-w-20",children:t.jsxs(js,{onClick:ge=>{ge.stopPropagation(),i(re)},className:"text-destructive focus:text-destructive",children:[t.jsx(M,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]})})]})]}),t.jsx(nn,{className:"w-fit min-w-20",children:t.jsxs(Ws,{onClick:ge=>{ge.stopPropagation(),i(re)},className:"text-destructive focus:text-destructive",children:[t.jsx(M,{name:"delete-bin",className:"h-4 w-4 mr-px"}),a("settings.common.actions.delete")]})})]},`${re.source}:${re.filePath}`),e[44]=n,e[45]=o,e[46]=c,e[47]=m,e[48]=u,e[49]=a,e[50]=te):te=e[50],Z=y.map(te),e[36]=n,e[37]=o,e[38]=c,e[39]=m,e[40]=u,e[41]=y,e[42]=a,e[43]=Z}else Z=e[43];let H;e[51]!==Z?(H=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2",children:Z}),e[51]=Z,e[52]=H):H=e[52];const T=r!==null;let Y;e[53]===Symbol.for("react.memo_cache_sentinel")?(Y=te=>{te||i(null)},e[53]=Y):Y=e[53];let F;e[54]!==a?(F=a("settings.snippets.sidebar.dialog.deleteTitle"),e[54]=a,e[55]=F):F=e[55];let V;e[56]!==F?(V=t.jsx(Vt,{children:F}),e[56]=F,e[57]=V):V=e[57];const Q=r?.name??"";let ie;e[58]!==a||e[59]!==Q?(ie=a("settings.snippets.sidebar.dialog.deleteDescription",{name:Q}),e[58]=a,e[59]=Q,e[60]=ie):ie=e[60];let X;e[61]!==ie?(X=t.jsx(qt,{children:ie}),e[61]=ie,e[62]=X):X=e[62];let se;e[63]!==V||e[64]!==X?(se=t.jsxs(_t,{children:[V,X]}),e[63]=V,e[64]=X,e[65]=se):se=e[65];let me;e[66]===Symbol.for("react.memo_cache_sentinel")?(me=()=>i(null),e[66]=me):me=e[66];let oe;e[67]!==a?(oe=a("settings.common.actions.cancel"),e[67]=a,e[68]=oe):oe=e[68];let xe;e[69]!==oe?(xe=t.jsx(G,{size:"sm",variant:"ghost",onClick:me,children:oe}),e[69]=oe,e[70]=xe):xe=e[70];let we;e[71]!==a?(we=a("settings.common.actions.delete"),e[71]=a,e[72]=we):we=e[72];let he;e[73]!==k||e[74]!==we?(he=t.jsx(G,{size:"sm",onClick:k,children:we}),e[73]=k,e[74]=we,e[75]=he):he=e[75];let Ie;e[76]!==xe||e[77]!==he?(Ie=t.jsxs(Yt,{children:[xe,he]}),e[76]=xe,e[77]=he,e[78]=Ie):Ie=e[78];let ve;e[79]!==se||e[80]!==Ie?(ve=t.jsxs(Bt,{className:"max-w-md",children:[se,Ie]}),e[79]=se,e[80]=Ie,e[81]=ve):ve=e[81];let ye;e[82]!==T||e[83]!==ve?(ye=t.jsx(Ut,{open:T,onOpenChange:Y,children:ve}),e[82]=T,e[83]=ve,e[84]=ye):ye=e[84];let be;return e[85]!==_||e[86]!==H||e[87]!==ye?(be=t.jsxs("div",{className:P,children:[_,H,ye]}),e[85]=_,e[86]=H,e[87]=ye,e[88]=be):be=e[88],be};function rx(s){return{selectedSnippetName:s.selectedSnippetName,snippets:s.snippets,setSelectedSnippet:s.setSelectedSnippet,setSnippetDraft:s.setSnippetDraft,deleteSnippet:s.deleteSnippet,loadSnippets:s.loadSnippets}}function ix(s){return s.name}function ox(s,e){return s.name.localeCompare(e.name)}const lx=()=>{const{t:s}=dt(),{selectedSnippetName:e,snippets:n,snippetDraft:a,setSnippetDraft:r,updateSnippet:i,createSnippet:o}=Ba(Ss(P=>({selectedSnippetName:P.selectedSnippetName,snippets:P.snippets,snippetDraft:P.snippetDraft,setSnippetDraft:P.setSnippetDraft,updateSnippet:P.updateSnippet,createSnippet:P.createSnippet}))),d=l.useMemo(()=>e?n.find(P=>P.name===e||P.aliases.includes(e))??null:null,[e,n]),c=!!(a&&a.name===e&&!d),[f,m]=l.useState(""),[p,u]=l.useState("global"),[S,h]=l.useState(""),[g,x]=l.useState(""),[D,N]=l.useState(""),[w,A]=l.useState(!1),k=l.useRef(null);l.useEffect(()=>{if(c&&a){const P={draftName:a.name||"",draftScope:a.scope||"global",description:a.description||"",aliases:(a.aliases||[]).join(", "),content:a.content||""};m(P.draftName),u(P.draftScope),h(P.description),x(P.aliases),N(P.content),k.current=P}else if(d){const P={draftName:"",draftScope:"global",description:d.description??"",aliases:d.aliases.join(", "),content:d.content};h(P.description),x(P.aliases),N(P.content),k.current=P}},[d,c,e,a]);const j=l.useMemo(()=>{const P=k.current;return P?c&&f!==P.draftName||c&&p!==P.draftScope?!0:S!==P.description||g!==P.aliases||D!==P.content:!1},[g,D,S,f,p,c]),y=async()=>{const P=c?f.trim().replace(/\s+/g,"-"):e?.trim();if(!P){B.error(s("settings.snippets.page.toast.nameRequired"));return}if(!D.trim()){B.error(s("settings.snippets.page.toast.contentRequired"));return}const z=g.split(",").map(R=>R.trim()).filter(Boolean);A(!0);try{if(!(c?await o(P,D,{aliases:z,description:S,scope:p}):await i(P,{content:D,aliases:z,description:S}))){B.error(s("settings.snippets.page.toast.saveFailed"));return}B.success(s("settings.snippets.page.toast.saved")),c&&r(null)}finally{A(!1)}};return e?t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8",children:[t.jsxs("div",{className:"mb-4 min-w-0",children:[t.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:c?s("settings.snippets.page.title.new"):`#${e}`}),d?t.jsx("p",{className:"typography-meta text-muted-foreground truncate",children:d.filePath}):null]}),t.jsxs("div",{className:"mb-8 space-y-3 px-2",children:[t.jsxs("div",{children:[c?t.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:"#"}),t.jsx(it,{value:f,onChange:P=>m(P.target.value),placeholder:s("settings.snippets.page.field.namePlaceholder"),className:"h-7 w-44 px-2"}),t.jsxs(Ft,{value:p,onValueChange:P=>u(P),children:[t.jsx(Lt,{className:"w-fit min-w-[100px]",children:t.jsx(Kt,{})}),t.jsxs(Ot,{align:"end",children:[t.jsx(ht,{value:"global",children:s("settings.common.scope.global")}),t.jsx(ht,{value:"project",children:s("settings.common.scope.project")})]})]})]}):null,t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.common.field.description")}),t.jsx(it,{value:S,onChange:P=>h(P.target.value),placeholder:s("settings.snippets.page.field.descriptionPlaceholder"),className:"mt-1.5 h-7 w-full max-w-sm px-2"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.snippets.page.field.aliases")}),t.jsx(it,{value:g,onChange:P=>x(P.target.value),placeholder:s("settings.snippets.page.field.aliasesPlaceholder"),className:"mt-1.5 h-7 w-full max-w-sm px-2"})]})]}),t.jsxs("div",{"data-settings-item":"snippets.content",className:"mb-2 px-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.snippets.page.field.content")}),t.jsx(ps,{value:D,onChange:P=>N(P.target.value),placeholder:s("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"}),t.jsx("p",{className:"mt-2 typography-meta text-muted-foreground",children:s("settings.snippets.page.hint")})]}),t.jsx("div",{className:"px-2 py-1",children:t.jsx(G,{onClick:y,disabled:w||!j,size:"xs",className:"!font-normal",children:s(w?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"text-center text-muted-foreground",children:[t.jsx(M,{name:"file-text",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),t.jsx("p",{className:"typography-body",children:s("settings.snippets.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:s("settings.snippets.page.empty.description")})]})})},Hl=()=>{const{t:s}=dt(),e=ut(p=>p.settingsGitmojiEnabled),n=ut(p=>p.setSettingsGitmojiEnabled),a=zm(),r=Ke(p=>p.gitChangesViewMode),i=Ke(p=>p.setGitChangesViewMode),[o,d]=l.useState(!0),c=l.useMemo(()=>[{id:"flat",label:s("settings.openchamber.git.option.flatList")},{id:"tree",label:s("settings.openchamber.git.option.treeView")}],[s]);l.useEffect(()=>{(async()=>{try{let u=null;if(!u){const S=Fs()?.settings;if(S)try{const g=(await S.load())?.settings;g&&(u={gitmojiEnabled:typeof g.gitmojiEnabled=="boolean"?g.gitmojiEnabled:void 0,gitChangesViewMode:g.gitChangesViewMode==="flat"||g.gitChangesViewMode==="tree"?g.gitChangesViewMode:void 0})}catch{}}if(!u){const S=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});S.ok&&(u=await S.json())}u&&(typeof u.gitmojiEnabled=="boolean"&&n(u.gitmojiEnabled),(u.gitChangesViewMode==="flat"||u.gitChangesViewMode==="tree")&&i(u.gitChangesViewMode))}catch(u){console.warn("Failed to load git settings:",u)}finally{d(!1)}})()},[i,n]);const f=l.useCallback(async p=>{n(p);try{await Pt({gitmojiEnabled:p})}catch(u){console.warn("Failed to save gitmoji setting:",u)}},[n]),m=l.useCallback(p=>{p!==r&&(i(p),Pt({gitChangesViewMode:p}))},[r,i]);return o?null:t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.git.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[t.jsxs("div",{"data-settings-item":"git.changes-view",className:"pt-1 pb-1",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.git.changesViewTitle")}),t.jsx("div",{role:"radiogroup","aria-label":s("settings.openchamber.git.changesViewAria"),className:"mt-0.5 space-y-0",children:c.map(p=>{const u=r===p.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":u,onClick:()=>{m(p.id)},onKeyDown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),m(p.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Sn,{checked:u,onChange:()=>{m(p.id)},ariaLabel:s("settings.openchamber.git.optionAria",{option:p.label})}),t.jsx("span",{className:u?"typography-ui-label font-normal text-foreground":"typography-ui-label font-normal text-foreground/50",children:p.label})]},p.id)})})]}),t.jsxs("div",{"data-settings-item":"git.gitmoji",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":e,onClick:()=>{f(!e)},onKeyDown:p=>{(p.key===" "||p.key==="Enter")&&(p.preventDefault(),f(!e))},children:[t.jsx(It,{checked:e,onChange:p=>{f(p)},ariaLabel:s("settings.openchamber.git.enableGitmojiAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.git.enableGitmoji")})]}),t.jsxs("div",{"data-settings-item":"git.gitignored-files",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":a,onClick:()=>Ya(!a),onKeyDown:p=>{(p.key===" "||p.key==="Enter")&&(p.preventDefault(),Ya(!a))},children:[t.jsx(It,{checked:a,onChange:Ya,ariaLabel:s("settings.openchamber.git.showGitignoredAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.git.showGitignored")})]})]})]})},Wl=()=>{const{t:s}=dt(),{isMobile:e}=Cs(),n=Fs()?.github,a=Vs(v=>v.status),r=Vs(v=>v.isLoading),i=Vs(v=>v.hasChecked),o=Vs(v=>v.refreshStatus),d=Vs(v=>v.setStatus),c=l.useCallback(async v=>{await Hs(v)},[]),[f,m]=l.useState(!1),[p,u]=l.useState(null),[S,h]=l.useState(null),g=l.useRef(null),x=l.useCallback(()=>{g.current!=null&&(window.clearInterval(g.current),g.current=null),h(null)},[]);l.useEffect(()=>((async()=>{try{i||await o(n)}catch(v){console.warn("Failed to load GitHub auth status:",v)}})(),()=>{x()}),[i,o,n,x]);const D=l.useCallback(async()=>{m(!0);try{const v=n?await n.authStart():await(async()=>{const L=await jt("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),E=await L.json().catch(()=>null);if(!L.ok||!E||!("deviceCode"in E))throw new Error(E?.error||L.statusText);return E})();u(v),h(Math.max(1,v.interval)*1e3);const b=v.verificationUriComplete||v.verificationUri;c(b)}catch(v){console.error("Failed to start GitHub connect:",v),B.error(s("settings.github.page.toast.startConnectFailed"))}finally{m(!1)}},[c,n,s]),N=l.useCallback(async v=>{if(n)return n.authComplete(v);const b=await jt("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:v})}),L=await b.json().catch(()=>null);if(!b.ok||!L)throw new Error(L?.error||b.statusText);return L},[n]);l.useEffect(()=>{if(!(!p?.deviceCode||!S)&&g.current==null)return g.current=window.setInterval(()=>{(async()=>{try{const v=await N(p.deviceCode);if(v.connected){B.success(s("settings.github.page.toast.connected")),u(null),x(),await o(n,{force:!0});return}v.status==="slow_down"&&h(b=>b?b+5e3:5e3),(v.status==="expired_token"||v.status==="access_denied")&&(B.error(v.error||s("settings.github.page.toast.authorizationFailed")),u(null),x())}catch(v){console.warn("GitHub polling failed:",v)}})()},S),()=>{g.current!=null&&(window.clearInterval(g.current),g.current=null)}},[p,S,N,o,n,x,s]);const w=l.useCallback(async v=>{m(!0);try{if(n)await n.authSetGhCliDisabled(v);else{const b=await jt("/api/github/auth/gh-cli",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({disabled:v})}),L=await b.json().catch(()=>null);if(!b.ok)throw new Error(L?.error||b.statusText)}B.success(s(v?"settings.github.page.toast.ghCliDisabled":"settings.github.page.toast.ghCliEnabled")),await o(n,{force:!0})}catch(b){console.error("Failed to update gh CLI setting:",b),B.error(s("settings.github.page.toast.ghCliUpdateFailed"))}finally{m(!1)}},[o,n,s]),A=l.useCallback(async()=>{m(!0);try{if(x(),u(null),n)await n.authDisconnect();else{const v=await jt("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}});if(!v.ok)throw new Error(v.statusText)}B.success(s("settings.github.page.toast.disconnected")),await o(n,{force:!0})}catch(v){console.error("Failed to disconnect GitHub:",v),B.error(s("settings.github.page.toast.disconnectFailed"))}finally{m(!1)}},[o,n,x,s]),k=l.useCallback(async v=>{if(v){m(!0);try{const b=n?await n.authActivate(v):await(async()=>{const L=await jt("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:v})}),E=await L.json().catch(()=>null);if(!L.ok||!E)throw new Error(E?.error||L.statusText);return E})();d(b),B.success(s("settings.github.page.toast.accountSwitched"))}catch(b){console.error("Failed to switch GitHub account:",b),B.error(s("settings.github.page.toast.accountSwitchFailed"))}finally{m(!1)}}},[n,d,s]);if(r)return null;const j=!!a?.connected,y=a?.user,z=(a?.accounts??[]).filter(v=>!v.current),R=a?.ghCli??null,I=R?.active?s("settings.github.page.accountSource.cli"):s("settings.github.page.accountSource.oauth");return t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-3 px-1 flex items-start justify-between gap-4",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:s("settings.github.page.oauth.title")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.github.page.tooltip.connectAccount")})]})]})}),t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[j?t.jsxs("div",{className:ce("px-4 py-3",e?"flex flex-col gap-3":"flex items-center justify-between gap-4"),children:[t.jsxs("div",{className:ce("flex min-w-0 items-center gap-4",e?"w-full":void 0),children:[y?.avatarUrl?t.jsx("img",{src:y.avatarUrl,alt:y.login?s("settings.github.page.avatarAlt.withLogin",{login:y.login}):s("settings.github.page.avatarAlt.fallback"),className:"h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):t.jsx("div",{className:"h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:y?.name?.trim()||y?.login||"GitHub"}),t.jsxs("div",{className:ce("flex items-center gap-2 typography-meta text-muted-foreground mt-0.5",e?"flex-wrap":"truncate"),children:[t.jsx(M,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"font-mono",children:y?.login||s("settings.github.page.label.unknownUser")}),y?.email&&t.jsx("span",{className:"opacity-50",children:"•"}),y?.email&&t.jsx("span",{children:y.email}),t.jsx("span",{className:"opacity-50",children:"•"}),t.jsx("span",{children:I})]}),a?.scope&&t.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:s("settings.github.page.label.scopes",{value:a.scope})}),R?.active&&t.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:s("settings.github.page.ghCli.activeDescription")})]})]}),R?.active?t.jsx(G,{size:"sm",variant:"outline",onClick:()=>w(!0),disabled:f,className:ce(e?"w-full":void 0),children:s("settings.github.page.ghCli.actions.disable")}):t.jsx(G,{size:"sm",variant:"outline",onClick:A,disabled:f,className:ce("text-[var(--status-error)] hover:text-[var(--status-error)]",e?"w-full":void 0),children:s("settings.github.page.actions.disconnect")})]}):t.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-4",children:[t.jsx("div",{className:"flex min-w-0 flex-col",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.github.page.status.notConnected")})}),t.jsx(G,{size:"sm",variant:"default",onClick:D,disabled:f,children:s("settings.github.page.actions.connect")})]}),z.length>0&&t.jsxs("div",{className:"mt-2 border-t border-[var(--surface-subtle)] pt-2 px-2 pb-1",children:[t.jsx("div",{className:"typography-micro text-muted-foreground mb-2 px-1",children:s("settings.github.page.label.otherAccounts")}),t.jsx("div",{className:"space-y-1",children:z.map(v=>{const b=v.user,L=v.source==="gh-cli"?s("settings.github.page.accountSource.cli"):s("settings.github.page.accountSource.oauth");return t.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:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[b?.avatarUrl?t.jsx("img",{src:b.avatarUrl,alt:b.login?s("settings.github.page.avatarAlt.withLogin",{login:b.login}):s("settings.github.page.avatarAlt.fallback"),className:"h-6 w-6 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):t.jsx("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]",children:t.jsx(M,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),t.jsxs("div",{className:"min-w-0 flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:b?.name?.trim()||b?.login||"GitHub"}),b?.login&&t.jsxs("span",{className:"typography-micro text-muted-foreground truncate",children:[t.jsx("span",{className:"font-mono",children:b.login}),t.jsx("span",{className:"mx-1 opacity-50",children:"·"}),t.jsx("span",{children:L})]})]})]}),t.jsx(G,{size:"sm",variant:"ghost",onClick:()=>k(v.id),disabled:f,children:s("settings.github.page.actions.switchTo")})]},v.id)})})]})]}),j&&t.jsx("div",{className:"mt-2 px-2 pb-2",children:t.jsx(G,{size:"sm",variant:"outline",onClick:D,disabled:f,className:ce(e?"w-full":void 0),children:s("settings.github.page.actions.addAccount")})}),p&&t.jsxs("div",{className:"mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h4",{className:"typography-ui-label text-foreground",children:s("settings.github.page.flow.title")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.github.page.flow.description")})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3 mt-4",children:[t.jsx("div",{className:"font-mono text-xl tracking-widest text-foreground bg-[var(--surface-muted)] px-3 py-1.5 rounded-md border border-[var(--interactive-border)]",children:p.userCode}),t.jsx(G,{size:"sm",asChild:!0,children:t.jsx("a",{href:p.verificationUriComplete||p.verificationUri,target:"_blank",rel:"noopener noreferrer",children:s("settings.github.page.actions.openGithub")})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[t.jsx("span",{className:"typography-micro text-muted-foreground animate-pulse",children:s("settings.github.page.flow.waiting")}),t.jsx(G,{size:"sm",variant:"ghost",disabled:f,onClick:()=>{x(),u(null)},children:s("settings.common.actions.cancel")})]})]}),R?.available&&!R?.active&&(!R.user||R.disabled)&&t.jsxs("div",{className:"mt-6",children:[t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground mb-3 px-1",children:s("settings.github.page.ghCli.title")}),t.jsx("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden",children:t.jsxs("div",{className:ce("px-4 py-3",e?"flex flex-col gap-3":"flex items-center justify-between gap-4"),children:[t.jsxs("div",{className:ce("flex min-w-0 items-center gap-4",e?"w-full":void 0),children:[R.user?.avatarUrl?t.jsx("img",{src:R.user.avatarUrl,alt:R.user.login?s("settings.github.page.avatarAlt.withLogin",{login:R.user.login}):s("settings.github.page.avatarAlt.fallback"),className:"h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):t.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]",children:t.jsx(M,{name:"github-fill",className:"h-4 w-4 text-muted-foreground"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[!R.disabled&&R.user&&t.jsx("div",{className:"typography-ui-label text-foreground truncate",children:R.user.name?.trim()||R.user.login||"GitHub"}),!R.disabled&&R.user?.login&&t.jsxs("div",{className:ce("flex items-center gap-2 typography-meta text-muted-foreground mt-0.5",e?"flex-wrap":"truncate"),children:[t.jsx(M,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"font-mono",children:R.user.login}),R.user.email&&t.jsx("span",{className:"opacity-50",children:"•"}),R.user.email&&t.jsx("span",{children:R.user.email})]}),t.jsx("div",{className:ce("typography-meta text-muted-foreground",R.disabled?"opacity-60":void 0),children:R.disabled?s("settings.github.page.ghCli.disabledDescription"):s("settings.github.page.ghCli.fallbackDescription")})]})]}),t.jsx(G,{size:"sm",variant:"outline",onClick:()=>w(!R.disabled),disabled:f,className:ce(e?"w-full":void 0),children:R.disabled?s("settings.github.page.ghCli.actions.enable"):s("settings.github.page.ghCli.actions.disable")})]})})]})]})},Fo=[{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)"}],cx=[{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"}],dx=({open:s,onOpenChange:e,profileId:n,importData:a})=>{const{t:r}=dt(),i=ks(X=>X.getProfileById),o=ks(X=>X.createProfile),d=ks(X=>X.updateProfile),c=ks(X=>X.deleteProfile),f=l.useMemo(()=>n&&n!=="new"&&!a?i(n):null,[n,i,a]),m=n==="new"||a!=null,p=n==="global",[u,S]=l.useState(""),[h,g]=l.useState(""),[x,D]=l.useState(""),[N,w]=l.useState("ssh"),[A,k]=l.useState(""),[j,y]=l.useState(!1),[P,z]=l.useState(""),[R,I]=l.useState(""),[v,b]=l.useState("keyword"),[L,E]=l.useState("branch"),[J,_]=l.useState(!1),[Z,H]=l.useState(!1),[T,Y]=l.useState(!1);l.useEffect(()=>{if(s){if(a){const X=a.host.split("/"),se=X.length>=3?X[X.length-1]:a.host;S(se),g(a.username),D(""),w("token"),k(""),y(!1),z(""),I(a.host),b("string"),E("code")}else if(m)S(""),g(""),D(""),w("ssh"),k(""),y(!1),z(""),I(""),b("keyword"),E("branch");else if(f)S(f.name),g(f.userName),D(f.userEmail),w(f.authType||"ssh"),k(f.sshKey||""),y(f.signCommits===!0),z(f.signingKey||""),I(f.host||""),b(f.color||"keyword"),E(f.icon||"branch");else if(p){const X=i("global");X&&(S(X.name),g(X.userName),D(X.userEmail),w(X.authType||"ssh"),k(X.sshKey||""),y(!1),z(""),I(X.host||""),b(X.color||"keyword"),E(X.icon||"branch"))}}},[s,n,f,m,a,p,i]);const F=async()=>{if(!h.trim()||!x.trim()){B.error(r("settings.gitIdentities.editor.toast.userNameEmailRequired"));return}if(N==="token"&&!R.trim()){B.error(r("settings.gitIdentities.editor.toast.hostRequiredForToken"));return}if(j&&!P.trim()){B.error(r("settings.gitIdentities.editor.toast.signingKeyRequired"));return}_(!0);try{const X={name:u.trim()||h.trim(),userName:h.trim(),userEmail:x.trim(),authType:N,sshKey:N==="ssh"&&A.trim()||null,signCommits:j,signingKey:P.trim()||null,host:N==="token"&&R.trim()||null,color:v,icon:L};let se;if(m)se=await o(X);else if(n)se=await d(n,X);else return;se?(B.success(r(m?"settings.gitIdentities.editor.toast.profileCreated":"settings.gitIdentities.editor.toast.profileUpdated")),e(!1)):B.error(r(m?"settings.gitIdentities.editor.toast.createProfileFailed":"settings.gitIdentities.editor.toast.updateProfileFailed"))}catch(X){console.error("Error saving profile:",X),B.error(r("settings.gitIdentities.editor.toast.saveUnexpectedError"))}finally{_(!1)}},V=async()=>{if(!(!n||m)){Y(!0);try{await c(n)?(B.success(r("settings.gitIdentities.editor.toast.profileDeleted")),H(!1),e(!1)):B.error(r("settings.gitIdentities.editor.toast.deleteProfileFailed"))}catch(X){console.error("Error deleting profile:",X),B.error(r("settings.gitIdentities.editor.toast.deleteUnexpectedError"))}finally{Y(!1)}}},Q=l.useMemo(()=>Fo.find(se=>se.key===v)?.cssVar||"var(--syntax-keyword)",[v]),ie=a?r("settings.gitIdentities.editor.title.importCredential"):m?r("settings.gitIdentities.editor.title.newIdentity"):p?r("settings.gitIdentities.editor.title.globalIdentity"):f?.name||r("settings.gitIdentities.editor.title.editIdentity");return t.jsxs(t.Fragment,{children:[t.jsx(Ut,{open:s,onOpenChange:e,children:t.jsxs(Bt,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:ie}),t.jsx(qt,{children:r(p?"settings.gitIdentities.editor.description.globalReadOnly":m?"settings.gitIdentities.editor.description.newProfile":"settings.gitIdentities.editor.description.editProfile")})]}),t.jsxs("div",{className:"space-y-5 py-2",children:[!p&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"typography-ui-label text-foreground block mb-1.5",children:r("settings.gitIdentities.editor.field.profileName")}),t.jsx(it,{value:u,onChange:X=>S(X.target.value),placeholder:r("settings.gitIdentities.editor.field.profileNamePlaceholder"),className:"h-8"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.color")}),t.jsx("div",{className:"flex gap-1.5",children:Fo.map(X=>t.jsx("button",{type:"button",onClick:()=>b(X.key),className:ce("w-6 h-6 rounded-md border-2 transition-all cursor-pointer",v===X.key?"border-foreground scale-110":"border-transparent hover:border-border"),style:{backgroundColor:X.cssVar},title:X.label},X.key))})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.icon")}),t.jsx("div",{className:"flex gap-1.5",children:cx.map(X=>{const se=X.Icon;return t.jsx("button",{type:"button",onClick:()=>E(X.key),className:ce("w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer",L===X.key?"border-[var(--interactive-border)] bg-[var(--surface-muted)]":"border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50"),title:X.label,children:t.jsx(M,{name:se,className:"w-3.5 h-3.5",style:{color:L===X.key?Q:"var(--surface-muted-foreground)"}})},X.key)})})]})]}),!p&&t.jsx("div",{className:"border-t border-border/40"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.userName")}),!p&&t.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.userNameTooltip")})]})]}),t.jsx(it,{value:h,onChange:X=>g(X.target.value),placeholder:r("settings.gitIdentities.editor.field.userNamePlaceholder"),required:!p,readOnly:p,disabled:p,className:"h-8"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.emailAddress")}),!p&&t.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.emailAddressTooltip")})]})]}),t.jsx(it,{type:"email",value:x,onChange:X=>D(X.target.value),placeholder:r("settings.gitIdentities.editor.field.emailAddressPlaceholder"),required:!p,readOnly:p,disabled:p,className:"h-8"})]})]}),!p&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-border/40"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.authMethod")}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(G,{size:"sm",type:"button",variant:"chip","aria-pressed":N==="ssh",onClick:()=>w("ssh"),children:[t.jsx(M,{name:"lock-2",className:"w-3.5 h-3.5 mr-1"})," SSH"]}),t.jsxs(G,{size:"sm",type:"button",variant:"chip","aria-pressed":N==="token",onClick:()=>w("token"),children:[t.jsx(M,{name:"key",className:"w-3.5 h-3.5 mr-1"})," ",r("settings.gitIdentities.editor.field.authToken")]})]})]}),N==="ssh"&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.sshKeyPath")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.sshKeyPathTooltip")})]})]}),t.jsx(it,{value:A,onChange:X=>k(X.target.value),placeholder:r("settings.gitIdentities.editor.field.sshKeyPathPlaceholder"),className:"h-8 font-mono text-xs"})]}),t.jsxs("div",{className:"border-t border-border/40 pt-3 space-y-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(It,{checked:j,onChange:y,ariaLabel:r("settings.gitIdentities.editor.field.signCommits")}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.signCommits")}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:r("settings.gitIdentities.editor.section.commitSigning")})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.signingKey")})}),t.jsx(it,{value:P,onChange:X=>z(X.target.value),placeholder:r("settings.gitIdentities.editor.field.signingKeyPlaceholder"),disabled:!j,className:"h-8 font-mono text-xs"})]})]}),N==="token"&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",children:r("settings.gitIdentities.editor.field.host")}),t.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:r("settings.gitIdentities.editor.field.hostTooltip")})]})]}),t.jsx(it,{value:R,onChange:X=>I(X.target.value),placeholder:r("settings.gitIdentities.editor.field.hostPlaceholder"),required:!0,className:"h-8 font-mono text-xs"})]})]})]})]}),t.jsxs(Yt,{className:"gap-2",children:[!p&&!m&&t.jsxs(G,{variant:"outline",size:"sm",onClick:()=>H(!0),className:"text-[var(--status-error)] hover:text-[var(--status-error)] border-[var(--status-error)]/30 hover:bg-[var(--status-error)]/10 mr-auto",children:[t.jsx(M,{name:"delete-bin",className:"w-3.5 h-3.5 mr-1"})," ",r("settings.common.actions.delete")]}),t.jsx(G,{variant:"ghost",size:"sm",onClick:()=>e(!1),className:"text-foreground hover:bg-interactive-hover hover:text-foreground",children:r(p?"settings.gitIdentities.editor.actions.close":"settings.common.actions.cancel")}),!p&&t.jsx(G,{size:"sm",onClick:F,disabled:J,children:r(J?"settings.common.actions.saving":m?"settings.gitIdentities.editor.actions.create":"settings.gitIdentities.editor.actions.save")})]})]})}),t.jsx(Ut,{open:Z,onOpenChange:X=>{T||H(X)},children:t.jsxs(Bt,{className:"max-w-md",children:[t.jsxs(_t,{children:[t.jsx(Vt,{children:r("settings.gitIdentities.page.deleteDialog.title")}),t.jsx(qt,{children:r("settings.gitIdentities.page.deleteDialog.description",{name:f?.name||u})})]}),t.jsxs(Yt,{children:[t.jsx(G,{variant:"ghost",onClick:()=>H(!1),disabled:T,children:r("settings.common.actions.cancel")}),t.jsx(G,{size:"sm",variant:"destructive",onClick:()=>{V()},disabled:T,children:r("settings.common.actions.delete")})]})]})})]})},mx={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart"},ux={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)"},px=()=>{const s=rt.c(118),{t:e}=dt(),{profiles:n,globalIdentity:a,defaultGitIdentityId:r,deleteProfile:i,loadProfiles:o,loadGlobalIdentity:d,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:f,setDefaultGitIdentityId:m,getUnimportedCredentials:p}=ks(Ss(hx)),[u,S]=l.useState(!1),[h,g]=l.useState(null),[x,D]=l.useState(null),[N,w]=l.useState(null),[A,k]=l.useState(!1);let j,y;s[0]!==f||s[1]!==c||s[2]!==d||s[3]!==o?(j=()=>{o(),d(),c(),f()},y=[o,d,c,f],s[0]=f,s[1]=c,s[2]=d,s[3]=o,s[4]=j,s[5]=y):(j=s[4],y=s[5]),l.useEffect(j,y);let P,z,R,I,v,b,L,E,J,_,Z,H,T,Y;if(s[6]!==r||s[7]!==N||s[8]!==i||s[9]!==p||s[10]!==a||s[11]!==n||s[12]!==m||s[13]!==e){const De=p();let Ae;s[28]===Symbol.for("react.memo_cache_sentinel")?(Ae=(Ne,Ee)=>{g(Ne),D(Ee??null),S(!0)},s[28]=Ae):Ae=s[28];const Pe=Ae;let Re;s[29]!==r||s[30]!==m||s[31]!==e?(Re=async Ne=>{const Ee=r===Ne?null:Ne;if(!await m(Ee)){B.error(e("settings.gitIdentities.page.toast.updateDefaultFailed"));return}B.success(e(Ee?"settings.gitIdentities.page.toast.defaultUpdated":"settings.gitIdentities.page.toast.defaultUnset"))},s[29]=r,s[30]=m,s[31]=e,s[32]=Re):Re=s[32];const Le=Re;let $e;s[33]!==N||s[34]!==i||s[35]!==e?($e=async()=>{if(!N)return;k(!0),await i(N.id)?(B.success(e("settings.gitIdentities.page.toast.profileDeleted",{name:N.name})),w(null)):B.error(e("settings.gitIdentities.page.toast.deleteProfileFailed")),k(!1)},s[33]=N,s[34]=i,s[35]=e,s[36]=$e):$e=s[36],z=$e,P=Jt,v="h-full",b="w-full bg-background",R="mx-auto w-full max-w-3xl space-y-6 p-3 sm:p-6 sm:pt-8",s[37]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("div",{"data-settings-item":"git.github-account",children:t.jsx(Wl,{})}),s[37]=I):I=s[37],H="git.identities",T="border-t border-border/40 pt-6";let Be;s[38]!==e?(Be=e("settings.gitIdentities.page.section.title"),s[38]=e,s[39]=Be):Be=s[39];let Oe;s[40]!==Be?(Oe=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:Be})}),s[40]=Be,s[41]=Oe):Oe=s[41];let Ue,le;s[42]===Symbol.for("react.memo_cache_sentinel")?(Ue=()=>Pe("new"),le=t.jsx(M,{name:"add",className:"w-3.5 h-3.5 mr-1"}),s[42]=Ue,s[43]=le):(Ue=s[42],le=s[43]);let W;s[44]!==e?(W=e("settings.common.badge.new"),s[44]=e,s[45]=W):W=s[45];let de;s[46]!==W?(de=t.jsxs(G,{size:"sm",variant:"outline",onClick:Ue,children:[le," ",W]}),s[46]=W,s[47]=de):de=s[47],s[48]!==Oe||s[49]!==de?(Y=t.jsxs("div",{className:"mb-3 px-1 flex items-start justify-between gap-4",children:[Oe,de]}),s[48]=Oe,s[49]=de,s[50]=Y):Y=s[50],L="rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",E=a&&t.jsx(Lo,{profile:a,isDefault:r==="global",onEdit:()=>Pe("global"),onToggleDefault:()=>Le("global"),isReadOnly:!0,hasBorder:n.length>0||De.length>0}),J=n.map((Ne,Ee)=>t.jsx(Lo,{profile:Ne,isDefault:r===Ne.id,onEdit:()=>Pe(Ne.id),onToggleDefault:()=>Le(Ne.id),onDelete:()=>w(Ne),hasBorder:Ee<n.length-1||De.length>0},Ne.id)),_=!a&&n.length===0&&De.length===0&&t.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground",children:[t.jsx(M,{name:"shield-keyhole",className:"mx-auto mb-2 h-8 w-8 opacity-40"}),t.jsx("p",{className:"typography-ui-label",children:e("settings.gitIdentities.page.empty.title")}),t.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.gitIdentities.page.empty.description")})]}),Z=De.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-4 py-2 border-t border-[var(--surface-subtle)]",children:t.jsx("span",{className:"typography-micro text-muted-foreground",children:e("settings.gitIdentities.page.discoveredCredentials.title")})}),De.map((Ne,Ee)=>t.jsx(gx,{credential:Ne,onImport:()=>Pe("new",{host:Ne.host,username:Ne.username}),hasBorder:Ee<De.length-1},`${Ne.host}-${Ne.username}`))]}),s[6]=r,s[7]=N,s[8]=i,s[9]=p,s[10]=a,s[11]=n,s[12]=m,s[13]=e,s[14]=P,s[15]=z,s[16]=R,s[17]=I,s[18]=v,s[19]=b,s[20]=L,s[21]=E,s[22]=J,s[23]=_,s[24]=Z,s[25]=H,s[26]=T,s[27]=Y}else P=s[14],z=s[15],R=s[16],I=s[17],v=s[18],b=s[19],L=s[20],E=s[21],J=s[22],_=s[23],Z=s[24],H=s[25],T=s[26],Y=s[27];let F;s[51]!==L||s[52]!==E||s[53]!==J||s[54]!==_||s[55]!==Z?(F=t.jsxs("div",{className:L,children:[E,J,_,Z]}),s[51]=L,s[52]=E,s[53]=J,s[54]=_,s[55]=Z,s[56]=F):F=s[56];let V;s[57]!==F||s[58]!==H||s[59]!==T||s[60]!==Y?(V=t.jsxs("div",{"data-settings-item":H,className:T,children:[Y,F]}),s[57]=F,s[58]=H,s[59]=T,s[60]=Y,s[61]=V):V=s[61];let Q;s[62]===Symbol.for("react.memo_cache_sentinel")?(Q=t.jsx(Hl,{}),s[62]=Q):Q=s[62];let ie;s[63]!==R||s[64]!==I||s[65]!==V?(ie=t.jsxs("div",{className:R,children:[I,V,Q]}),s[63]=R,s[64]=I,s[65]=V,s[66]=ie):ie=s[66];let X;s[67]!==P||s[68]!==v||s[69]!==b||s[70]!==ie?(X=t.jsx(P,{outerClassName:v,className:b,children:ie}),s[67]=P,s[68]=v,s[69]=b,s[70]=ie,s[71]=X):X=s[71];let se;s[72]!==x||s[73]!==u||s[74]!==h?(se=t.jsx(dx,{open:u,onOpenChange:S,profileId:h,importData:x}),s[72]=x,s[73]=u,s[74]=h,s[75]=se):se=s[75];const me=N!==null;let oe;s[76]!==A?(oe=De=>{A||De||w(null)},s[76]=A,s[77]=oe):oe=s[77];let xe;s[78]!==e?(xe=e("settings.gitIdentities.page.deleteDialog.title"),s[78]=e,s[79]=xe):xe=s[79];let we;s[80]!==xe?(we=t.jsx(Vt,{children:xe}),s[80]=xe,s[81]=we):we=s[81];const he=N?.name??"";let Ie;s[82]!==e||s[83]!==he?(Ie=e("settings.gitIdentities.page.deleteDialog.description",{name:he}),s[82]=e,s[83]=he,s[84]=Ie):Ie=s[84];let ve;s[85]!==Ie?(ve=t.jsx(qt,{children:Ie}),s[85]=Ie,s[86]=ve):ve=s[86];let ye;s[87]!==we||s[88]!==ve?(ye=t.jsxs(_t,{children:[we,ve]}),s[87]=we,s[88]=ve,s[89]=ye):ye=s[89];let be;s[90]===Symbol.for("react.memo_cache_sentinel")?(be=()=>w(null),s[90]=be):be=s[90];let te;s[91]!==e?(te=e("settings.common.actions.cancel"),s[91]=e,s[92]=te):te=s[92];let re;s[93]!==A||s[94]!==te?(re=t.jsx(G,{variant:"ghost",onClick:be,disabled:A,children:te}),s[93]=A,s[94]=te,s[95]=re):re=s[95];let ge;s[96]!==z?(ge=()=>{z()},s[96]=z,s[97]=ge):ge=s[97];let U;s[98]!==e?(U=e("settings.common.actions.delete"),s[98]=e,s[99]=U):U=s[99];let ee;s[100]!==A||s[101]!==ge||s[102]!==U?(ee=t.jsx(G,{size:"sm",variant:"destructive",onClick:ge,disabled:A,children:U}),s[100]=A,s[101]=ge,s[102]=U,s[103]=ee):ee=s[103];let ne;s[104]!==re||s[105]!==ee?(ne=t.jsxs(Yt,{children:[re,ee]}),s[104]=re,s[105]=ee,s[106]=ne):ne=s[106];let ue;s[107]!==ye||s[108]!==ne?(ue=t.jsxs(Bt,{className:"max-w-md",children:[ye,ne]}),s[107]=ye,s[108]=ne,s[109]=ue):ue=s[109];let Me;s[110]!==me||s[111]!==oe||s[112]!==ue?(Me=t.jsx(Ut,{open:me,onOpenChange:oe,children:ue}),s[110]=me,s[111]=oe,s[112]=ue,s[113]=Me):Me=s[113];let ke;return s[114]!==X||s[115]!==se||s[116]!==Me?(ke=t.jsxs(t.Fragment,{children:[X,se,Me]}),s[114]=X,s[115]=se,s[116]=Me,s[117]=ke):ke=s[117],ke},Lo=s=>{const e=rt.c(56),{profile:n,isDefault:a,onEdit:r,onToggleDefault:i,onDelete:o,isReadOnly:d,hasBorder:c}=s,{t:f}=dt(),[m,p]=l.useState(!1),u=mx[n.icon||"branch"]||"git-branch",S=ux[n.color||""],h=n.authType||"ssh";let g;e[0]!==r?(g=V=>{V.currentTarget===V.target&&(V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),r()))},e[0]=r,e[1]=g):g=e[1];const x=g;let D;e[2]!==a||e[3]!==d||e[4]!==o||e[5]!==i||e[6]!==f?(D=V=>t.jsxs(t.Fragment,{children:[t.jsx(V,{onClick:Q=>{Q.stopPropagation(),i()},children:f(a?"settings.gitIdentities.page.actions.unsetDefault":"settings.gitIdentities.page.actions.setAsDefault")}),!d&&o&&t.jsxs(V,{onClick:Q=>{Q.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[t.jsx(M,{name:"delete-bin",className:"h-4 w-4 mr-px"}),f("settings.common.actions.delete")]})]}),e[2]=a,e[3]=d,e[4]=o,e[5]=i,e[6]=f,e[7]=D):D=e[7];const N=D,w=c&&"border-b border-[var(--surface-subtle)]";let A;e[8]!==w?(A=ce("group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer",w),e[8]=w,e[9]=A):A=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=V=>{V.preventDefault(),p(!0)},e[10]=k):k=e[10];let j;e[11]!==x||e[12]!==r||e[13]!==A?(j=t.jsx("div",{className:A,onClick:r,role:"button",tabIndex:0,onKeyDown:x,onContextMenu:k}),e[11]=x,e[12]=r,e[13]=A,e[14]=j):j=e[14];let y;e[15]!==S?(y={color:S},e[15]=S,e[16]=y):y=e[16];let P;e[17]!==u||e[18]!==y?(P=t.jsx(M,{name:u,className:"w-4 h-4 shrink-0",style:y}),e[17]=u,e[18]=y,e[19]=P):P=e[19];let z;e[20]!==n.name?(z=t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:n.name}),e[20]=n.name,e[21]=z):z=e[21];let R;e[22]!==h?(R=t.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:h}),e[22]=h,e[23]=R):R=e[23];let I;e[24]!==a||e[25]!==f?(I=a&&t.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:f("settings.gitIdentities.page.badge.default")}),e[24]=a,e[25]=f,e[26]=I):I=e[26];let v;e[27]!==d||e[28]!==f?(v=d&&t.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:f("settings.agents.sidebar.badge.system")}),e[27]=d,e[28]=f,e[29]=v):v=e[29];let b;e[30]!==R||e[31]!==I||e[32]!==v||e[33]!==z?(b=t.jsxs("div",{className:"flex items-center gap-1.5",children:[z,R,I,v]}),e[30]=R,e[31]=I,e[32]=v,e[33]=z,e[34]=b):b=e[34];const L=h==="token"&&n.host?n.host:n.userEmail;let E;e[35]!==L?(E=t.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:L}),e[35]=L,e[36]=E):E=e[36];let J;e[37]!==b||e[38]!==E?(J=t.jsxs("div",{className:"min-w-0",children:[b,E]}),e[37]=b,e[38]=E,e[39]=J):J=e[39];let _;e[40]!==J||e[41]!==P?(_=t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[P,J]}),e[40]=J,e[41]=P,e[42]=_):_=e[42];let Z;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(ds,{asChild:!0,children:t.jsx(G,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:fx,children:t.jsx(M,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[43]=Z):Z=e[43];let H;e[44]!==N?(H=t.jsxs(us,{children:[Z,t.jsx(ms,{align:"end",className:"w-fit min-w-28",children:N(js)})]}),e[44]=N,e[45]=H):H=e[45];let T;e[46]!==_||e[47]!==H||e[48]!==j?(T=t.jsxs(sn,{render:j,children:[_,H]}),e[46]=_,e[47]=H,e[48]=j,e[49]=T):T=e[49];let Y;e[50]!==N?(Y=t.jsx(nn,{className:"w-fit min-w-28",children:N(Ws)}),e[50]=N,e[51]=Y):Y=e[51];let F;return e[52]!==m||e[53]!==T||e[54]!==Y?(F=t.jsxs(tn,{open:m,onOpenChange:p,children:[T,Y]}),e[52]=m,e[53]=T,e[54]=Y,e[55]=F):F=e[55],F},gx=s=>{const e=rt.c(21),{credential:n,onImport:a,hasBorder:r}=s,{t:i}=dt();let o;e[0]!==n.host?(o=n.host.split("/"),e[0]=n.host,e[1]=o):o=e[1];const d=o,c=d.length>=3?d[d.length-1]:n.host,f=n.host.includes("/"),m=r&&"border-b border-[var(--surface-subtle)]";let p;e[2]!==m?(p=ce("flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30",m),e[2]=m,e[3]=p):p=e[3];let u;e[4]!==c?(u=t.jsx("span",{className:"typography-ui-label text-foreground truncate block",children:c}),e[4]=c,e[5]=u):u=e[5];const S=f?n.host:n.username;let h;e[6]!==S?(h=t.jsx("span",{className:"typography-micro text-muted-foreground/60 truncate block leading-tight",children:S}),e[6]=S,e[7]=h):h=e[7];let g;e[8]!==u||e[9]!==h?(g=t.jsxs("div",{className:"min-w-0",children:[u,h]}),e[8]=u,e[9]=h,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(M,{name:"download",className:"h-3 w-3"}),e[11]=x):x=e[11];let D;e[12]!==i?(D=i("settings.gitIdentities.page.actions.import"),e[12]=i,e[13]=D):D=e[13];let N;e[14]!==a||e[15]!==D?(N=t.jsxs(G,{size:"sm",variant:"ghost",onClick:a,className:"gap-1 shrink-0",children:[x,D]}),e[14]=a,e[15]=D,e[16]=N):N=e[16];let w;return e[17]!==N||e[18]!==p||e[19]!==g?(w=t.jsxs("div",{className:p,children:[g,N]}),e[17]=N,e[18]=p,e[19]=g,e[20]=w):w=e[20],w};function hx(s){return{profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,deleteProfile:s.deleteProfile,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDiscoveredCredentials:s.loadDiscoveredCredentials,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId,setDefaultGitIdentityId:s.setDefaultGitIdentityId,getUnimportedCredentials:s.getUnimportedCredentials}}function fx(s){return s.stopPropagation()}const ql=()=>{const s=om();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},xx=()=>{const s=rt.c(2),[e,n]=l.useState(yx);let a,r;return s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],o=()=>{n(ql())};o();for(const d of i)typeof d.addEventListener=="function"?d.addEventListener("change",o):typeof d.addListener=="function"&&d.addListener(o);return window.addEventListener("appinstalled",o),window.addEventListener("focus",o),()=>{for(const d of i)typeof d.removeEventListener=="function"?d.removeEventListener("change",o):typeof d.removeListener=="function"&&d.removeListener(o);window.removeEventListener("appinstalled",o),window.removeEventListener("focus",o)}},r=[],s[0]=a,s[1]=r):(a=s[0],r=s[1]),l.useEffect(a,r),e};function yx(){return ql()}const bx=[{value:"system",labelKey:"settings.openchamber.visual.option.themeMode.system"},{value:"light",labelKey:"settings.openchamber.visual.option.themeMode.light"},{value:"dark",labelKey:"settings.openchamber.visual.option.themeMode.dark"}],vx=[{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"}],jx=[{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"}],Vn="OpenChamber - AI Coding Assistant",Oo=[{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"}],zo=[{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"}],wx=[{value:"default",labelKey:"settings.openchamber.visual.option.mobileLayout.default"},{value:"new",labelKey:"settings.openchamber.visual.option.mobileLayout.new"}],mr=s=>s==="portrait"||s==="landscape"?s:"system",Nx=[{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"}],kx=[{id:"sorted",labelKey:"settings.openchamber.visual.option.chatRenderMode.sorted.label",descriptionKey:"settings.openchamber.visual.option.chatRenderMode.sorted.description"},{id:"live",labelKey:"settings.openchamber.visual.option.chatRenderMode.live.label",descriptionKey:"settings.openchamber.visual.option.chatRenderMode.live.description"}],Ko=[{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"}],Sx=[{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"}],$o=[{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"}],Uo=[{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"}],Cx=s=>s==="markdown"?"markdown":"plain",Gr=({visibleSettings:s})=>{const{locale:e,locales:n,setLocale:a,label:r,t:i}=dt(),o=l.useCallback(C=>i(C),[i]),{isMobile:d}=Cs(),{browserTab:c}=xx(),f=Km(),m=Ke(C=>C.showReasoningTraces),p=Ke(C=>C.setShowReasoningTraces),u=Ke(C=>C.collapsibleThinkingBlocks),S=Ke(C=>C.setCollapsibleThinkingBlocks),h=Ke(C=>C.mermaidRenderingMode),g=Ke(C=>C.setMermaidRenderingMode),x=Ke(C=>C.userMessageRenderingMode),D=Ke(C=>C.setUserMessageRenderingMode),N=Ke(C=>C.collapsibleUserMessages),w=Ke(C=>C.setCollapsibleUserMessages),A=Ke(C=>C.stickyUserHeader),k=Ke(C=>C.setStickyUserHeader),j=Ke(C=>C.expandedEditorToolbar),y=Ke(C=>C.setExpandedEditorToolbar),P=Ke(C=>C.wideChatLayoutEnabled),z=Ke(C=>C.setWideChatLayoutEnabled),R=Ke(C=>C.chatRenderMode),I=Ke(C=>C.setChatRenderMode),v=Ke(C=>C.activityRenderMode),b=Ke(C=>C.setActivityRenderMode),L=Ke(C=>C.fontSize),E=Ke(C=>C.setFontSize),J=Ke(C=>C.terminalFontSize),_=Ke(C=>C.setTerminalFontSize),Z=Ke(C=>C.uiFont),H=Ke(C=>C.setUiFont),T=Ke(C=>C.monoFont),Y=Ke(C=>C.setMonoFont),F=Ke(C=>C.padding),V=Ke(C=>C.setPadding),Q=Ke(C=>C.inputBarOffset),ie=Ke(C=>C.setInputBarOffset),X=Ke(C=>C.mobileKeyboardMode),se=Ke(C=>C.setMobileKeyboardMode),me=Ke(C=>C.diffLayoutPreference),oe=Ke(C=>C.setDiffLayoutPreference),xe=Ke(C=>C.showTerminalQuickKeysOnDesktop),we=Ke(C=>C.setShowTerminalQuickKeysOnDesktop),he=Ke(C=>C.fileEditorKeymap),Ie=Ke(C=>C.setFileEditorKeymap),ve=ji(C=>C.queueModeEnabled),ye=ji(C=>C.setQueueMode),be=Ke(C=>C.persistChatDraft),te=Ke(C=>C.setPersistChatDraft),re=Ke(C=>C.inputSpellcheckEnabled),ge=Ke(C=>C.setInputSpellcheckEnabled),U=Ke(C=>C.showToolFileIcons),ee=Ke(C=>C.setShowToolFileIcons),ne=Ke(C=>C.showTurnChangedFiles),ue=Ke(C=>C.setShowTurnChangedFiles),Me=Ke(C=>C.showExpandedBashTools),ke=Ke(C=>C.setShowExpandedBashTools),De=Ke(C=>C.showExpandedEditTools),Ae=Ke(C=>C.setShowExpandedEditTools),Pe=Ke(C=>C.timeFormatPreference),Re=Ke(C=>C.setTimeFormatPreference),Le=Ke(C=>C.weekStartPreference),$e=Ke(C=>C.setWeekStartPreference),Be=Ke(C=>C.showSplitAssistantMessageActions),Oe=Ke(C=>C.setShowSplitAssistantMessageActions),Ue=ut(C=>C.settingsMessageStreamTransport),le=ut(C=>C.setSettingsMessageStreamTransport),W=ut(C=>C.settingsDefaultFileViewerPreview),de=ut(C=>C.setSettingsDefaultFileViewerPreview),Ne=Ke(C=>C.isSettingsDialogOpen),{themeMode:Ee,setThemeMode:Ce,availableThemes:He,customThemesLoading:q,reloadCustomThemes:$,lightThemeId:fe,darkThemeId:O,setLightThemePreference:Fe,setDarkThemePreference:Je}=Ua(),[Xe,et]=l.useState(!1),at=l.useMemo(()=>fs()&&typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.macVibrancySupported===!0,[]),lt=typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.macVibrancy===!0,[Ze,We]=l.useState(lt),[pt,pe]=l.useState(!1),[st,nt]=l.useState(0),Ge=Ke(C=>C.reportUsage),ft=Ke(C=>C.setReportUsage),wt=l.useCallback(C=>{ft(C),Pt({reportUsage:C})},[ft]),Ct=Ne&&(s?s.includes("chatRenderMode"):!0);l.useEffect(()=>{if(!Ct)return;let C=null,gt=Date.now();const zt=()=>{const Is=Date.now();Is-gt>=420&&(nt(zs=>(zs+1)%24),gt=Is),C=requestAnimationFrame(zt)};(typeof document>"u"||document.visibilityState==="visible")&&(C=requestAnimationFrame(zt));const ss=()=>{document.visibilityState==="visible"&&C===null?C=requestAnimationFrame(zt):document.visibilityState!=="visible"&&C!==null&&(cancelAnimationFrame(C),C=null)};return document.addEventListener("visibilitychange",ss),()=>{document.removeEventListener("visibilitychange",ss),C!==null&&cancelAnimationFrame(C)}},[Ct]);const ae=l.useCallback(C=>{D(C),Pt({userMessageRenderingMode:C})},[D]),Ve=l.useCallback(C=>{k(C),Pt({stickyUserHeader:C})},[k]),tt=l.useCallback(C=>{y(C),Pt({expandedEditorToolbar:C})},[y]),Ye=l.useCallback(C=>{w(C),Pt({collapsibleUserMessages:C})},[w]),yt=l.useCallback(C=>{z(C),Pt({wideChatLayoutEnabled:C})},[z]),ze=l.useCallback(C=>{Oe(C),Pt({showSplitAssistantMessageActions:C})},[Oe]),_e=l.useCallback(C=>{ge(C),Pt({inputSpellcheckEnabled:C})},[ge]),ot=l.useCallback(C=>{I(C),Pt({chatRenderMode:C})},[I]),bt=l.useCallback(C=>{le(C),Pt({messageStreamTransport:C})},[le]),Mt=l.useCallback(C=>{b(C),Pt({activityRenderMode:C})},[b]),Qt=l.useCallback(C=>{g(C),Pt({mermaidRenderingMode:C})},[g]),Xt=l.useCallback(C=>{ee(C),Pt({showToolFileIcons:C})},[ee]),rs=l.useCallback(C=>{ue(C),Pt({showTurnChangedFiles:C})},[ue]),Wt=l.useCallback(C=>{de(C),Pt({defaultFileViewerPreview:C}),window.dispatchEvent(new CustomEvent("openchamber:file-viewer-preview-mode-changed",{detail:{enabled:C}}))},[de]),Se=l.useCallback(C=>{ke(C),Pt({showExpandedBashTools:C})},[ke]),vt=l.useCallback(C=>{Ae(C),Pt({showExpandedEditTools:C})},[Ae]),Nt=l.useCallback(C=>{Re(C),Pt({timeFormatPreference:C})},[Re]),ct=l.useCallback(C=>{$e(C),Pt({weekStartPreference:C})},[$e]),St=l.useMemo(()=>He.filter(C=>C.metadata.variant==="light").sort((C,gt)=>C.metadata.name.localeCompare(gt.metadata.name)),[He]),$t=l.useMemo(()=>He.filter(C=>C.metadata.variant==="dark").sort((C,gt)=>C.metadata.name.localeCompare(gt.metadata.name)),[He]),ys=l.useMemo(()=>St.find(C=>C.metadata.id===fe)??St[0],[St,fe]),ns=l.useMemo(()=>$t.find(C=>C.metadata.id===O)??$t[0],[$t,O]),bs=l.useCallback((C,gt)=>{const zt=gt==="dark"?" Dark":" Light";return C.endsWith(zt)?C.slice(0,-zt.length):C},[]),Qe=C=>s?s.includes(C):!0,mt=gs(),xt=Qe("theme")&&!mt,Rt=Qe("theme")||Qe("timeFormat")||Qe("weekStart"),es=d&&mn()&&!fs()&&!mt,Zt=mt?Rt:Qe("theme")||es||Qe("pwaInstallName")||Qe("pwaOrientation")||Qe("timeFormat")||Qe("weekStart"),qs=Qe("fontSize")||Qe("terminalFontSize")||Qe("spacing")||Qe("inputBarOffset"),Ls=Qe("terminalQuickKeys")&&!d||Qe("fileEditorKeymap")||Qe("expandedEditorToolbar"),Tn=Qe("mermaidRendering")||Qe("userMessageRendering")||Qe("chatRenderMode")||Qe("messageTransport")||Qe("activityRenderMode")&&R==="sorted"||Qe("collapsibleUserMessages")||Qe("stickyUserHeader")||Qe("wideChatLayout")||Qe("splitAssistantMessageActions")||Qe("diffLayout")||Qe("dotfiles")||Qe("fileViewerPreview")||Qe("reasoning")||Qe("queueMode")||Qe("persistDraft")||Qe("showToolFileIcons")||Qe("expandedTools")||!d&&Qe("inputSpellcheck"),As=Qe("pwaInstallName")&&mn()&&c&&!fs()&&!mt,Gs=Qe("pwaOrientation")&&mn()&&!fs()&&!mt,Js=Qe("mobileKeyboardMode")&&mn()&&!fs()&&!mt&&$m(),[Fn,Va]=l.useState(()=>Qm()),[Ln,Os]=l.useState(""),[bn,Qs]=l.useState("system"),sa=l.useMemo(()=>{const C=$o.find(gt=>gt.id===Pe);return o(C?.labelKey??"settings.openchamber.visual.option.timeFormat.auto.label")},[Pe,o]),_a=l.useMemo(()=>{const C=Uo.find(gt=>gt.id===Le);return o(C?.labelKey??"settings.openchamber.visual.option.weekStart.auto.label")},[Le,o]),K=l.useMemo(()=>{const C=Oo.find(gt=>gt.id===bn);return C?o(C.labelKey):void 0},[bn,o]),qe=l.useMemo(()=>{const C=zo.find(gt=>gt.id===X);return C?o(C.labelKey):void 0},[X,o]),kt=l.useCallback(C=>{C!==Fn&&(Va(C),Ym(C),window.location.reload())},[Fn]),Tt=l.useCallback(async C=>{if(typeof window>"u")return;const gt=window,ss=C.trim().replace(/\s+/g," ").slice(0,64);if(await Pt({pwaAppName:ss}),typeof gt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__=="function"){const Is=gt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(ss);Os(Is);return}Os(ss||Vn),gt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),ts=l.useCallback(async C=>{if(typeof window>"u")return;const gt=window,zt=mr(C);if(await Pt({pwaOrientation:zt}),typeof gt.__OPENCHAMBER_SET_PWA_ORIENTATION__=="function"){const ss=gt.__OPENCHAMBER_SET_PWA_ORIENTATION__(zt);Qs(ss);return}Qs(zt),gt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);return l.useEffect(()=>{if(typeof window>"u"||!As&&!Gs&&!Js)return;let C=!1;return(async()=>{try{const zt=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!zt.ok){C||Os(Vn);return}const ss=await zt.json().catch(()=>({})),zs=(typeof ss?.pwaAppName=="string"?ss.pwaAppName:"").trim().replace(/\s+/g," ").slice(0,64),on=mr(ss?.pwaOrientation),On=Ci(ss?.mobileKeyboardMode);C||(As&&Os(zs||Vn),Gs&&Qs(on),Js&&se(On))}catch{C||(As&&Os(Vn),Gs&&Qs("system"),Js&&se("native"))}})(),()=>{C=!0}},[se,Js,As,Gs]),t.jsxs("div",{className:"space-y-8",children:[Zt&&t.jsxs("div",{className:"mb-8 space-y-6",children:[xt&&t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsx("span",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.colorMode")}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:bx.map(C=>t.jsx(G,{variant:"chip",size:"xs","aria-pressed":Ee===C.value,className:"!font-normal",onClick:()=>Ce(C.value),children:o(C.labelKey)},C.value))})]}),es&&t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5 py-1.5",children:[t.jsx("span",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.mobileLayout")}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:wx.map(C=>t.jsx(G,{variant:"chip",size:"xs","aria-pressed":Fn===C.value,className:"!font-normal",onClick:()=>kt(C.value),children:o(C.labelKey)},C.value))})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[t.jsxs("div",{"data-settings-item":"appearance.light-theme",className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.openchamber.visual.field.lightTheme")}),t.jsxs(Ft,{value:ys?.metadata.id??"",onValueChange:Fe,children:[t.jsx(Lt,{"aria-label":i("settings.openchamber.visual.field.selectLightThemeAria"),className:"w-fit",children:t.jsx(Kt,{placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),children:ys?bs(ys.metadata.name,"light"):void 0})}),t.jsx(Ot,{children:St.map(C=>t.jsx(ht,{value:C.metadata.id,children:bs(C.metadata.name,"light")},C.metadata.id))})]})]}),t.jsxs("div",{"data-settings-item":"appearance.dark-theme",className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.openchamber.visual.field.darkTheme")}),t.jsxs(Ft,{value:ns?.metadata.id??"",onValueChange:Je,children:[t.jsx(Lt,{"aria-label":i("settings.openchamber.visual.field.selectDarkThemeAria"),className:"w-fit",children:t.jsx(Kt,{placeholder:i("settings.openchamber.visual.field.selectThemePlaceholder"),children:ns?bs(ns.metadata.name,"dark"):void 0})}),t.jsx(Ot,{children:$t.map(C=>t.jsx(ht,{value:C.metadata.id,children:bs(C.metadata.name,"dark")},C.metadata.id))})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[t.jsx("button",{type:"button",disabled:q||Xe,onClick:()=>{const C=Date.now();et(!0),$().finally(()=>{const gt=Date.now()-C;if(gt<500){window.setTimeout(()=>{et(!1)},500-gt);return}et(!1)})},className:"inline-flex items-center typography-ui-label font-normal text-foreground underline decoration-[1px] underline-offset-2 hover:text-foreground/80 disabled:cursor-not-allowed disabled:text-muted-foreground/60",children:i(Xe?"settings.openchamber.visual.actions.reloadingThemes":"settings.openchamber.visual.actions.reloadThemes")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx("button",{type:"button",className:"flex items-center justify-center rounded-md p-1 text-muted-foreground/70 hover:text-foreground","aria-label":i("settings.openchamber.visual.field.themeImportInfoAria"),children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5"})})}),t.jsx(Et,{sideOffset:8,children:i("settings.openchamber.visual.field.themeImportInfoTooltip")})]})]}),at&&t.jsxs("div",{"data-settings-item":"appearance.window-transparency",className:"flex flex-col gap-1.5 border-t border-border/40 pt-3",children:[t.jsxs("div",{className:"group flex cursor-pointer items-start gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":Ze,onClick:()=>{pt||We(!Ze)},onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),pt||We(!Ze))},children:[t.jsx(It,{checked:Ze,onChange:We,disabled:pt,ariaLabel:i("settings.openchamber.visual.field.macVibrancy")}),t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.macVibrancy")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.macVibrancyHint")})]})]}),Ze!==lt&&t.jsx("div",{className:"pl-6",children:t.jsx(G,{variant:"outline",size:"sm",disabled:pt,onClick:()=>{pe(!0),Um("desktop_set_vibrancy",{enabled:Ze})},children:i(pt?"settings.openchamber.visual.actions.restarting":"settings.openchamber.visual.actions.saveAndRestart")})})]})]}),Rt&&t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.localization")}),t.jsxs("div",{"data-settings-item":"appearance.language",className:"grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.appearance.language.label")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.appearance.language.description")})]}),t.jsxs(Ft,{value:e,onValueChange:C=>a(C),children:[t.jsx(Lt,{"aria-label":i("settings.appearance.language.select"),className:"w-fit",children:t.jsx(Kt,{children:r(e)})}),t.jsx(Ot,{children:n.map(C=>t.jsx(ht,{value:C,children:r(C)},C))})]})]}),(Qe("timeFormat")||Qe("weekStart"))&&t.jsxs("div",{className:"grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[Qe("timeFormat")&&t.jsxs("div",{"data-settings-item":"appearance.time-format",className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.openchamber.visual.field.timeFormat")}),t.jsxs(Ft,{value:Pe,onValueChange:C=>Nt(C),children:[t.jsx(Lt,{"aria-label":i("settings.openchamber.visual.field.selectTimeFormatAria"),className:"w-fit",children:t.jsx(Kt,{children:sa})}),t.jsx(Ot,{children:$o.map(C=>t.jsx(ht,{value:C.id,children:o(C.labelKey)},C.id))})]})]}),Qe("weekStart")&&t.jsxs("div",{"data-settings-item":"appearance.week-start",className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground shrink-0",children:i("settings.openchamber.visual.field.weekStartsOn")}),t.jsxs(Ft,{value:Le,onValueChange:C=>ct(C),children:[t.jsx(Lt,{"aria-label":i("settings.openchamber.visual.field.selectWeekStartAria"),className:"w-fit",children:t.jsx(Kt,{children:_a})}),t.jsx(Ot,{children:Uo.map(C=>t.jsx(ht,{value:C.id,children:o(C.labelKey)},C.id))})]})]})]})]}),(As||Gs||Js)&&t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[As&&t.jsxs("div",{"data-settings-item":"appearance.pwa-install-name",className:"py-1.5 space-y-1.5",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.installAppName")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.installAppNameHint")})]}),t.jsxs("div",{className:"flex w-full max-w-[28rem] items-center gap-2",children:[t.jsx(it,{value:Ln,onChange:C=>{Os(C.target.value)},onBlur:()=>{Tt(Ln)},onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),Tt(Ln))},className:"h-7",maxLength:64,"aria-label":i("settings.openchamber.visual.field.pwaInstallAppNameAria")}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Os(Vn),Tt("")},className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetInstallAppNameAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Gs&&t.jsxs("div",{"data-settings-item":"appearance.pwa-orientation",className:"py-1.5 space-y-1.5",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.installOrientation")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.installOrientationHint")})]}),t.jsxs("div",{className:"flex w-full max-w-[18rem] items-center gap-2",children:[t.jsxs(Ft,{value:bn,onValueChange:C=>{const gt=mr(C);Qs(gt),ts(gt)},children:[t.jsx(Lt,{"aria-label":i("settings.openchamber.visual.field.pwaInstallOrientationAria"),className:"w-full",children:t.jsx(Kt,{placeholder:i("settings.openchamber.visual.field.selectOrientationPlaceholder"),children:K})}),t.jsx(Ot,{children:Oo.map(C=>t.jsx(ht,{value:C.id,children:o(C.labelKey)},C.id))})]}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Qs("system"),ts("system")},disabled:bn==="system",className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetInstallOrientationAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Js&&t.jsxs("div",{"data-settings-item":"appearance.mobile-keyboard-mode",className:"py-1.5 space-y-1.5",children:[t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.mobileKeyboardMode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:i("settings.openchamber.visual.field.mobileKeyboardModeHint")})]}),t.jsxs("div",{className:"flex w-full max-w-[18rem] items-center gap-2",children:[t.jsxs(Ft,{value:X,onValueChange:C=>{const gt=Ci(C);se(gt),Pt({mobileKeyboardMode:gt})},children:[t.jsx(Lt,{"aria-label":i("settings.openchamber.visual.field.mobileKeyboardModeAria"),className:"w-full",children:t.jsx(Kt,{placeholder:i("settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder"),children:qe})}),t.jsx(Ot,{children:zo.map(C=>t.jsx(ht,{value:C.id,children:o(C.labelKey)},C.id))})]}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{se("native"),Pt({mobileKeyboardMode:"native"})},disabled:X==="native",className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetMobileKeyboardModeAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]})]}),qs&&t.jsx("div",{className:"mb-8 space-y-3",children:t.jsxs("section",{className:"p-2 space-y-0.5",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.spacingAndLayout")}),t.jsxs("div",{className:"pl-2",children:[Qe("fontSize")&&!d&&t.jsxs("div",{"data-settings-item":"appearance.interface-font-size",className:"flex items-center gap-8 py-1",children:[t.jsx("div",{className:"flex min-w-0 flex-col w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.interfaceFont")})}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[t.jsxs(Ft,{value:Z,onValueChange:C=>H(C),children:[t.jsx(Lt,{"aria-label":i("settings.openchamber.visual.field.selectInterfaceFontAria"),className:"w-[13rem]",children:t.jsx(Kt,{children:wi.find(C=>C.id===Z)?.label})}),t.jsx(Ot,{children:wi.map(C=>t.jsx(ht,{value:C.id,children:t.jsx("span",{style:{fontFamily:C.stack},children:C.label})},C.id))})]}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>H(Ni),disabled:Z===Ni,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetInterfaceFontAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Qe("terminalFontSize")&&t.jsxs("div",{className:ce("py-1",d?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsx("div",{className:ce("flex min-w-0 flex-col",d?"w-full":"w-56 shrink-0"),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.codeFont")})}),t.jsxs("div",{className:ce("flex items-center gap-2",d?"w-full":"w-fit"),children:[t.jsxs(Ft,{value:T,onValueChange:C=>Y(C),children:[t.jsx(Lt,{"aria-label":i("settings.openchamber.visual.field.selectCodeFontAria"),className:"w-[13rem]",children:t.jsx(Kt,{children:ki.find(C=>C.id===T)?.label})}),t.jsx(Ot,{children:ki.map(C=>t.jsx(ht,{value:C.id,children:t.jsx("span",{style:{fontFamily:C.stack},children:C.label})},C.id))})]}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>Y(Si),disabled:T===Si,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetCodeFontAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Qe("fontSize")&&!d&&t.jsxs("div",{className:"flex items-center gap-8 py-1",children:[t.jsx("div",{className:"flex min-w-0 flex-col w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.interfaceFontSize")})}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[t.jsx(xs,{value:L,onValueChange:E,min:50,max:200,step:5,"aria-label":i("settings.openchamber.visual.field.fontSizePercentageAria"),className:"w-16"}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>E(100),disabled:L===100,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetFontSizeAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Qe("terminalFontSize")&&t.jsxs("div",{"data-settings-item":"appearance.terminal-font-size",className:ce("py-1",d?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsx("div",{className:ce("flex min-w-0 flex-col",d?"w-full":"w-56 shrink-0"),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.terminalFontSize")})}),t.jsxs("div",{className:ce("flex items-center gap-2",d?"w-full":"w-fit"),children:[t.jsx(xs,{value:J,onValueChange:_,min:9,max:52,step:1,className:"w-16"}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>_(13),disabled:J===13,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetTerminalFontSizeAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Qe("spacing")&&t.jsxs("div",{"data-settings-item":"appearance.spacing-density",className:ce("py-1",d?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsx("div",{className:ce("flex min-w-0 flex-col",d?"w-full":"w-56 shrink-0"),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.spacingDensity")})}),t.jsxs("div",{className:ce("flex items-center gap-2",d?"w-full":"w-fit"),children:[t.jsx(xs,{value:F,onValueChange:V,min:50,max:200,step:5,className:"w-16"}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>V(100),disabled:F===100,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetSpacingAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]}),Qe("inputBarOffset")&&t.jsxs("div",{"data-settings-item":"appearance.input-bar-offset",className:ce("py-1",d?"flex flex-col gap-3":"flex items-center gap-8"),children:[t.jsx("div",{className:ce("flex min-w-0 flex-col",d?"w-full":"w-56 shrink-0"),children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.inputBarOffset")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.inputBarOffsetTooltip")})]})]})}),t.jsxs("div",{className:ce("flex items-center gap-2",d?"w-full":"w-fit"),children:[t.jsx(xs,{value:Q,onValueChange:ie,min:0,max:100,step:5,className:"w-16"}),t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>ie(0),disabled:Q===0,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":i("settings.openchamber.visual.actions.resetInputBarOffsetAria"),title:i("settings.common.actions.reset"),children:t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]})]})}),Ls&&t.jsx("div",{className:"space-y-3",children:t.jsxs("section",{className:"px-2 pb-2 pt-0",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.navigation")}),Qe("fileEditorKeymap")&&t.jsxs("div",{"data-settings-item":"appearance.file-editor-keymap",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-start sm:gap-8",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:i("settings.openchamber.visual.field.fileEditorKeymap")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.field.fileEditorKeymap"),className:"space-y-0",children:["default","vim"].map(C=>{const gt=he===C,zt=i(`settings.openchamber.visual.option.fileEditorKeymap.${C}`);return t.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-2 py-0.5 text-left",role:"radio","aria-checked":gt,onClick:()=>Ie(C),children:[t.jsx("span",{"aria-hidden":!0,className:ce("relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full transition-[background-color,box-shadow] duration-200 ease-out",gt?"bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none":"bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)]"),children:t.jsx("span",{className:ce("block h-[5px] w-[5px] rounded-full bg-white",!gt&&"opacity-0")})}),t.jsx("span",{className:ce("typography-ui-label font-normal",gt?"text-foreground":"text-foreground/50"),children:zt})]},C)})})]}),Qe("expandedEditorToolbar")&&t.jsxs("div",{"data-settings-item":"appearance.expanded-editor-toolbar",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":j,onClick:()=>tt(!j),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),tt(!j))},children:[t.jsx(It,{checked:j,onChange:tt,ariaLabel:i("settings.openchamber.visual.field.expandedEditorToolbarAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.expandedEditorToolbar")})]}),Qe("terminalQuickKeys")&&!d&&t.jsxs("div",{"data-settings-item":"appearance.terminal-quick-keys",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":xe,onClick:()=>we(!xe),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),we(!xe))},children:[t.jsx(It,{checked:xe,onChange:we,ariaLabel:i("settings.openchamber.visual.field.terminalQuickKeysAria")}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.terminalQuickKeys")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.terminalQuickKeysTooltip")})]})]})]})]})}),Tn&&t.jsxs("div",{className:"space-y-3",children:[(Qe("userMessageRendering")||Qe("mermaidRendering")||Qe("chatRenderMode")||Qe("messageTransport")||Qe("activityRenderMode")&&R==="sorted"||Qe("diffLayout")&&!mt)&&t.jsxs("div",{className:"grid grid-cols-1 gap-y-2 md:grid-cols-[minmax(0,16rem)_minmax(0,16rem)] md:justify-start md:gap-x-2",children:[Qe("chatRenderMode")&&t.jsxs("section",{"data-settings-item":"chat.render-mode",className:"p-2 md:col-span-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.chatRenderMode")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.chatRenderModeAria"),className:"mt-1 grid w-full max-w-[26rem] grid-cols-1 gap-3 sm:grid-cols-2",children:kx.map(C=>{const gt=R===C.id,zt=st%12;return t.jsxs("button",{type:"button",onClick:()=>ot(C.id),"aria-pressed":gt,className:ce("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",gt?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsx("span",{className:ce("typography-ui-label",gt?"text-foreground":"text-muted-foreground"),children:o(C.labelKey)}),t.jsx("div",{className:"mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2",children:C.id==="live"?t.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(ss=>{const Is=ss*3+1,zs=zt-Is+1,on=zs<=0?0:zs===1?42:zs===2?68:92,On=on>0;return t.jsxs("div",{className:ce("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",On?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55"}),t.jsx("span",{className:"h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none",style:{width:`${on}%`}})]},ss)})}):t.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(ss=>{const Is=zt>=(ss+1)*3;return t.jsxs("div",{className:ce("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",Is?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55"}),t.jsx("span",{className:"h-1.5 rounded bg-muted-foreground/30",style:{width:"92%"}})]},ss)})})})]},C.id)})})]}),Qe("messageTransport")&&t.jsxs("section",{"data-settings-item":"chat.message-transport",className:"p-2 md:col-span-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.messageStreamTransport")}),t.jsxs("div",{className:"mt-1 flex max-w-[24rem] flex-col gap-2",children:[t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:Ko.map(C=>t.jsx(G,{variant:"chip",size:"xs","aria-pressed":Ue===C.id,className:"!font-normal",onClick:()=>bt(C.id),children:o(C.labelKey)},C.id))}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:(()=>{const C=Ko.find(gt=>gt.id===Ue);return C?.descriptionKey?o(C.descriptionKey):""})()})]})]}),Qe("activityRenderMode")&&R==="sorted"&&t.jsxs("section",{className:"p-2 md:col-span-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.activityDefault")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.activityDefaultAria"),className:"mt-0.5 space-y-0",children:Sx.map(C=>{const gt=v===C.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":gt,onClick:()=>Mt(C.id),onKeyDown:zt=>{(zt.key===" "||zt.key==="Enter")&&(zt.preventDefault(),Mt(C.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Sn,{checked:gt,onChange:()=>Mt(C.id),ariaLabel:i("settings.openchamber.visual.field.activityDefaultModeAria",{option:o(C.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",gt?"text-foreground":"text-foreground/50"),children:o(C.labelKey)})]},C.id)})})]}),Qe("expandedTools")&&t.jsxs("section",{className:"p-2 md:col-span-2 space-y-0.5",children:[t.jsx("div",{className:"typography-ui-header font-medium text-foreground py-1.5",children:i("settings.openchamber.visual.section.showToolsOpenedByDefault")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":Me,onClick:()=>Se(!Me),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),Se(!Me))},children:[t.jsx(It,{checked:Me,onChange:Se,ariaLabel:i("settings.openchamber.visual.field.showExpandedBashToolsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.bash")})]}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":De,onClick:()=>vt(!De),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),vt(!De))},children:[t.jsx(It,{checked:De,onChange:vt,ariaLabel:i("settings.openchamber.visual.field.showExpandedEditToolsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.editTools")})]})]}),Qe("userMessageRendering")&&t.jsxs("section",{className:"p-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.userMessageRendering")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.userMessageRenderingAria"),className:"mt-0.5 space-y-0",children:Nx.map(C=>{const gt=Cx(x)===C.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":gt,onClick:()=>ae(C.id),onKeyDown:zt=>{(zt.key===" "||zt.key==="Enter")&&(zt.preventDefault(),ae(C.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Sn,{checked:gt,onChange:()=>ae(C.id),ariaLabel:i("settings.openchamber.visual.field.userMessageRenderingAria",{option:o(C.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",gt?"text-foreground":"text-foreground/50"),children:o(C.labelKey)})]},C.id)})})]}),Qe("mermaidRendering")&&t.jsxs("section",{className:"p-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.mermaidRendering")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.mermaidRenderingAria"),className:"mt-0.5 space-y-0",children:jx.map(C=>{const gt=h===C.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":gt,onClick:()=>Qt(C.id),onKeyDown:zt=>{(zt.key===" "||zt.key==="Enter")&&(zt.preventDefault(),Qt(C.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Sn,{checked:gt,onChange:()=>Qt(C.id),ariaLabel:i("settings.openchamber.visual.field.mermaidRenderingAria",{option:o(C.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",gt?"text-foreground":"text-foreground/50"),children:o(C.labelKey)})]},C.id)})})]}),Qe("diffLayout")&&!mt&&t.jsxs("section",{className:"p-2",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground",children:i("settings.openchamber.visual.section.diffLayout")}),t.jsx("div",{role:"radiogroup","aria-label":i("settings.openchamber.visual.section.diffLayoutAria"),className:"mt-0.5 space-y-0",children:vx.map(C=>{const gt=me===C.id;return t.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":gt,onClick:()=>oe(C.id),onKeyDown:zt=>{(zt.key===" "||zt.key==="Enter")&&(zt.preventDefault(),oe(C.id))},className:"flex w-full items-center gap-2 py-0 text-left",children:[t.jsx(Sn,{checked:gt,onChange:()=>oe(C.id),ariaLabel:i("settings.openchamber.visual.field.diffLayoutAria",{option:o(C.labelKey)})}),t.jsx("span",{className:ce("typography-ui-label font-normal",gt?"text-foreground":"text-foreground/50"),children:o(C.labelKey)})]},C.id)})})]})]}),(Qe("collapsibleUserMessages")||Qe("stickyUserHeader")||Qe("wideChatLayout")||Qe("splitAssistantMessageActions")||Qe("dotfiles")||Qe("fileViewerPreview")||Qe("queueMode")||Qe("persistDraft")||Qe("showToolFileIcons")||Qe("showTurnChangedFiles")||!d&&Qe("inputSpellcheck")||Qe("reasoning"))&&t.jsxs("section",{className:"p-2 space-y-0.5",children:[Qe("reasoning")&&t.jsxs("div",{"data-settings-item":"chat.reasoning-traces",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":m,onClick:()=>p(!m),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),p(!m))},children:[t.jsx(It,{checked:m,onChange:p,ariaLabel:i("settings.openchamber.visual.field.showReasoningTracesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showReasoningTraces")})]}),Qe("reasoning")&&m&&t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":u,onClick:()=>S(!u),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),S(!u))},children:[t.jsx(It,{checked:u,onChange:S,ariaLabel:i("settings.openchamber.visual.field.collapsibleThinkingBlocksAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.collapsibleThinkingBlocks")})]}),Qe("collapsibleUserMessages")&&t.jsxs("div",{"data-settings-item":"chat.collapsible-user-messages",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":N,onClick:()=>Ye(!N),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),Ye(!N))},children:[t.jsx(It,{checked:N,onChange:Ye,ariaLabel:i("settings.openchamber.visual.field.collapsibleUserMessagesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.collapsibleUserMessages")})]}),Qe("stickyUserHeader")&&t.jsxs("div",{"data-settings-item":"chat.sticky-user-header",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":A,onClick:()=>Ve(!A),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),Ve(!A))},children:[t.jsx(It,{checked:A,onChange:Ve,ariaLabel:i("settings.openchamber.visual.field.stickyUserHeaderAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.stickyUserHeader")})]}),Qe("wideChatLayout")&&t.jsxs("div",{"data-settings-item":"chat.wide-layout",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":P,onClick:()=>yt(!P),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),yt(!P))},children:[t.jsx(It,{checked:P,onChange:yt,ariaLabel:i("settings.openchamber.visual.field.wideChatLayoutAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.wideChatLayout")})]}),Qe("splitAssistantMessageActions")&&t.jsxs("div",{"data-settings-item":"chat.inline-assistant-actions",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":Be,onClick:()=>ze(!Be),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),ze(!Be))},children:[t.jsx(It,{checked:Be,onChange:ze,ariaLabel:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsAria")}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showSplitAssistantMessageActions")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 cursor-help text-muted-foreground/60"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip")})]})]})]}),Qe("showToolFileIcons")&&t.jsxs("div",{"data-settings-item":"chat.tool-file-icons",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":U,onClick:()=>Xt(!U),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),Xt(!U))},children:[t.jsx(It,{checked:U,onChange:Xt,ariaLabel:i("settings.openchamber.visual.field.showToolFileIconsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showToolFileIcons")})]}),Qe("showTurnChangedFiles")&&t.jsxs("div",{"data-settings-item":"chat.changed-files",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":ne,onClick:()=>rs(!ne),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),rs(!ne))},children:[t.jsx(It,{checked:ne,onChange:rs,ariaLabel:i("settings.openchamber.visual.field.showTurnChangedFilesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showTurnChangedFiles")})]}),Qe("dotfiles")&&!gs()&&t.jsxs("div",{"data-settings-item":"chat.dotfiles",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":f,onClick:()=>Xa(!f),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),Xa(!f))},children:[t.jsx(It,{checked:f,onChange:Xa,ariaLabel:i("settings.openchamber.visual.field.showDotfilesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.showDotfiles")})]}),Qe("fileViewerPreview")&&t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":W,onClick:()=>Wt(!W),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),Wt(!W))},children:[t.jsx("span",{onClick:C=>C.stopPropagation(),children:t.jsx(It,{checked:W,onChange:Wt,ariaLabel:i("settings.openchamber.defaults.field.openFilesPreviewAria")})}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.defaults.field.openFilesPreview")})]}),Qe("queueMode")&&t.jsxs("div",{"data-settings-item":"chat.queue-mode",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":ve,onClick:()=>ye(!ve),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),ye(!ve))},children:[t.jsx(It,{checked:ve,onChange:ye,ariaLabel:i("settings.openchamber.visual.field.queueMessagesByDefaultAria")}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.queueMessagesByDefault")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:i("settings.openchamber.visual.field.queueMessagesByDefaultTooltip",{modifier:Nl()})})]})]})]}),Qe("persistDraft")&&t.jsxs("div",{"data-settings-item":"chat.persist-drafts",className:"group flex cursor-pointer items-center gap-2 py-0.5",role:"button",tabIndex:0,"aria-pressed":be,onClick:()=>te(!be),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),te(!be))},children:[t.jsx(It,{checked:be,onChange:te,ariaLabel:i("settings.openchamber.visual.field.persistDraftMessagesAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.persistDraftMessages")})]}),!d&&Qe("inputSpellcheck")&&t.jsxs("div",{"data-settings-item":"chat.spellcheck",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":re,onClick:()=>_e(!re),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),_e(!re))},children:[t.jsx(It,{checked:re,onChange:_e,ariaLabel:i("settings.openchamber.visual.field.enableSpellcheckInTextInputsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.enableSpellcheckInTextInputs")})]})]})]}),Qe("reportUsage")&&t.jsx("div",{className:"space-y-3",children:t.jsxs("section",{className:"px-2 pb-2 pt-0",children:[t.jsx("h4",{className:"typography-ui-header font-medium text-foreground mb-2",children:i("settings.openchamber.visual.section.privacy")}),t.jsxs("div",{"data-settings-item":"appearance.usage-reports",className:"flex items-start gap-2 py-1.5",children:[t.jsx(It,{checked:Ge,onChange:wt,ariaLabel:i("settings.openchamber.visual.field.sendAnonymousUsageReportsAria")}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[t.jsx("div",{className:"group flex cursor-pointer",role:"button",tabIndex:0,"aria-pressed":Ge,onClick:()=>wt(!Ge),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),wt(!Ge))},children:t.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.openchamber.visual.field.sendAnonymousUsageReports")})}),t.jsx("span",{className:"typography-meta text-muted-foreground pointer-events-none",children:i("settings.openchamber.visual.field.sendAnonymousUsageReportsHint")})]})]})]})})]})},Px=1,Ix=365,Bo=30,Dx=[{value:"archive",labelKey:"settings.openchamber.sessionRetention.action.archive"},{value:"delete",labelKey:"settings.openchamber.sessionRetention.action.delete"}],Gl=()=>{const s=rt.c(113),{t:e}=dt(),n=Ke(Ax),a=Ke(Ex),r=Ke(Mx),i=Ke(Rx),o=Ke(Tx),d=Ke(Fx);let c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={autoRun:!1},s[0]=c):c=s[0];const{candidates:f,isRunning:m,runCleanup:p,action:u}=lm(c),S=f.length;let h;s[1]!==p||s[2]!==e?(h=async()=>{const ne=await p({force:!0});if(ne.completedIds.length===0&&ne.failedIds.length===0){B.message(ne.action==="archive"?e("settings.openchamber.sessionRetention.toast.noneEligibleArchive"):e("settings.openchamber.sessionRetention.toast.noneEligibleDelete"));return}ne.completedIds.length>0&&B.success(ne.action==="archive"?e("settings.openchamber.sessionRetention.toast.archivedCount",{count:ne.completedIds.length}):e("settings.openchamber.sessionRetention.toast.deletedCount",{count:ne.completedIds.length})),ne.failedIds.length>0&&B.error(ne.action==="archive"?e("settings.openchamber.sessionRetention.toast.failedArchiveCount",{count:ne.failedIds.length}):e("settings.openchamber.sessionRetention.toast.failedDeleteCount",{count:ne.failedIds.length}))},s[1]=p,s[2]=e,s[3]=h):h=s[3];const g=h;let x;s[4]!==e?(x=e("settings.openchamber.sessionRetention.title"),s[4]=e,s[5]=x):x=s[5];let D;s[6]!==x?(D=t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:x}),s[6]=x,s[7]=D):D=s[7];let N;s[8]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),s[8]=N):N=s[8];let w;s[9]!==e?(w=e("settings.openchamber.sessionRetention.tooltip"),s[9]=e,s[10]=w):w=s[10];let A;s[11]!==w?(A=t.jsxs(Dt,{children:[N,t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:w})]}),s[11]=w,s[12]=A):A=s[12];let k;s[13]!==D||s[14]!==A?(k=t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[D,A]})}),s[13]=D,s[14]=A,s[15]=k):k=s[15];let j,y;s[16]!==n||s[17]!==i?(j=()=>i(!n),y=ne=>{(ne.key===" "||ne.key==="Enter")&&(ne.preventDefault(),i(!n))},s[16]=n,s[17]=i,s[18]=j,s[19]=y):(j=s[18],y=s[19]);let P;s[20]!==e?(P=e("settings.openchamber.sessionRetention.field.enableAutoCleanupAria"),s[20]=e,s[21]=P):P=s[21];let z;s[22]!==n||s[23]!==i||s[24]!==P?(z=t.jsx(It,{checked:n,onChange:i,ariaLabel:P}),s[22]=n,s[23]=i,s[24]=P,s[25]=z):z=s[25];let R;s[26]!==e?(R=e("settings.openchamber.sessionRetention.field.enableAutoCleanup"),s[26]=e,s[27]=R):R=s[27];let I;s[28]!==R?(I=t.jsx("span",{className:"typography-ui-label text-foreground",children:R}),s[28]=R,s[29]=I):I=s[29];let v;s[30]!==n||s[31]!==z||s[32]!==I||s[33]!==j||s[34]!==y?(v=t.jsxs("div",{"data-settings-item":"sessions.auto-cleanup",className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":n,onClick:j,onKeyDown:y,children:[z,I]}),s[30]=n,s[31]=z,s[32]=I,s[33]=j,s[34]=y,s[35]=v):v=s[35];let b;s[36]!==e?(b=e("settings.openchamber.sessionRetention.field.retentionPeriod"),s[36]=e,s[37]=b):b=s[37];let L;s[38]!==b?(L=t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:b})}),s[38]=b,s[39]=L):L=s[39];let E;s[40]!==e?(E=e("settings.openchamber.sessionRetention.field.retentionPeriodAria"),s[40]=e,s[41]=E):E=s[41];let J;s[42]!==a||s[43]!==o||s[44]!==E?(J=t.jsx(xs,{value:a,onValueChange:o,min:Px,max:Ix,step:1,"aria-label":E,className:"w-20 tabular-nums"}),s[42]=a,s[43]=o,s[44]=E,s[45]=J):J=s[45];let _;s[46]!==e?(_=e("settings.openchamber.sessionRetention.field.days"),s[46]=e,s[47]=_):_=s[47];let Z;s[48]!==_?(Z=t.jsx("span",{className:"typography-ui-label text-muted-foreground",children:_}),s[48]=_,s[49]=Z):Z=s[49];let H;s[50]!==o?(H=()=>o(Bo),s[50]=o,s[51]=H):H=s[51];const T=a===Bo;let Y;s[52]!==e?(Y=e("settings.openchamber.sessionRetention.actions.resetRetentionAria"),s[52]=e,s[53]=Y):Y=s[53];let F;s[54]!==e?(F=e("settings.common.actions.reset"),s[54]=e,s[55]=F):F=s[55];let V;s[56]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(M,{name:"restart",className:"h-3.5 w-3.5"}),s[56]=V):V=s[56];let Q;s[57]!==H||s[58]!==T||s[59]!==Y||s[60]!==F?(Q=t.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:H,disabled:T,className:"h-7 w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":Y,title:F,children:V}),s[57]=H,s[58]=T,s[59]=Y,s[60]=F,s[61]=Q):Q=s[61];let ie;s[62]!==J||s[63]!==Z||s[64]!==Q?(ie=t.jsxs("div",{className:"flex items-center gap-2 sm:w-fit",children:[J,Z,Q]}),s[62]=J,s[63]=Z,s[64]=Q,s[65]=ie):ie=s[65];let X;s[66]!==L||s[67]!==ie?(X=t.jsxs("div",{"data-settings-item":"sessions.retention-period",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[L,ie]}),s[66]=L,s[67]=ie,s[68]=X):X=s[68];let se;s[69]!==e?(se=e("settings.openchamber.sessionRetention.field.whenSessionsExpire"),s[69]=e,s[70]=se):se=s[70];let me;s[71]!==se?(me=t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:se})}),s[71]=se,s[72]=me):me=s[72];let oe;s[73]!==r||s[74]!==d||s[75]!==e?(oe=Dx.map(ne=>t.jsx(G,{type:"button",variant:"chip",size:"xs","aria-pressed":r===ne.value,className:"!font-normal",onClick:()=>d(ne.value),children:e(ne.labelKey)},ne.value)),s[73]=r,s[74]=d,s[75]=e,s[76]=oe):oe=s[76];let xe;s[77]!==oe?(xe=t.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:w-fit",children:oe}),s[77]=oe,s[78]=xe):xe=s[78];let we;s[79]!==me||s[80]!==xe?(we=t.jsxs("div",{"data-settings-item":"sessions.retention-action",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[me,xe]}),s[79]=me,s[80]=xe,s[81]=we):we=s[81];let he;s[82]!==v||s[83]!==X||s[84]!==we?(he=t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[v,X,we]}),s[82]=v,s[83]=X,s[84]=we,s[85]=he):he=s[85];let Ie;s[86]!==e?(Ie=e("settings.openchamber.sessionRetention.manualCleanup.title"),s[86]=e,s[87]=Ie):Ie=s[87];let ve;s[88]!==Ie?(ve=t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("p",{className:"typography-meta text-foreground font-medium",children:Ie})}),s[88]=Ie,s[89]=ve):ve=s[89];let ye;s[90]!==m||s[91]!==e?(ye=e(m?"settings.openchamber.sessionRetention.actions.cleaningUp":"settings.openchamber.sessionRetention.actions.runCleanupNow"),s[90]=m,s[91]=e,s[92]=ye):ye=s[92];let be;s[93]!==g||s[94]!==m||s[95]!==ye?(be=t.jsx("div",{className:"flex items-center gap-2 sm:w-fit",children:t.jsx(G,{type:"button",variant:"outline",size:"xs",onClick:g,disabled:m,className:"!font-normal",children:ye})}),s[93]=g,s[94]=m,s[95]=ye,s[96]=be):be=s[96];let te;s[97]!==ve||s[98]!==be?(te=t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8",children:[ve,be]}),s[97]=ve,s[98]=be,s[99]=te):te=s[99];let re;s[100]!==u||s[101]!==S||s[102]!==e?(re=u==="archive"?e("settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow",{count:S}):e("settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow",{count:S}),s[100]=u,s[101]=S,s[102]=e,s[103]=re):re=s[103];let ge;s[104]!==re?(ge=t.jsx("p",{className:"typography-meta text-muted-foreground",children:re}),s[104]=re,s[105]=ge):ge=s[105];let U;s[106]!==te||s[107]!==ge?(U=t.jsxs("div",{className:"mt-1 px-2 py-1.5 space-y-1",children:[te,ge]}),s[106]=te,s[107]=ge,s[108]=U):U=s[108];let ee;return s[109]!==he||s[110]!==U||s[111]!==k?(ee=t.jsxs("div",{className:"mb-8",children:[k,he,U]}),s[109]=he,s[110]=U,s[111]=k,s[112]=ee):ee=s[112],ee};function Ax(s){return s.autoDeleteEnabled}function Ex(s){return s.autoDeleteAfterDays}function Mx(s){return s.sessionRetentionAction}function Rx(s){return s.setAutoDeleteEnabled}function Tx(s){return s.setAutoDeleteAfterDays}function Fx(s){return s.setSessionRetentionAction}const Vo=(s,e,n)=>!s||!Number.isFinite(s)?e:new Intl.DateTimeFormat(Vr(),{dateStyle:"medium",timeStyle:"short",hour12:n==="auto"?void 0:n==="12h"}).format(s),Jl=()=>{const{t:s}=dt(),e=Ke(y=>y.timeFormatPreference),[n,a]=l.useState(!1),[r,i]=l.useState(!0),[o,d]=l.useState(!1),[c,f]=l.useState(null),[m,p]=l.useState(!1),[u,S]=l.useState([]),[h,g]=l.useState(cm),[x,D]=l.useState(""),N=l.useMemo(()=>dm(),[]),w=l.useCallback(async()=>{i(!0),D("");try{const y=await mm();S(y)}catch(y){const P=y instanceof Error?y.message:s("settings.openchamber.passkeys.toast.loadFailed");D(P)}finally{i(!1)}},[s]);l.useEffect(()=>{let y=!1;return(async()=>{try{if(!N.supported){y||(a(!1),i(!1));return}y||a(!0)}catch{y||a(!1)}if(!y){const P=await Ga();if(g(P),!P.enabled){S([]),i(!1);return}await w()}})(),()=>{y=!0,gi()}},[w,N.supported]);const A=l.useCallback(async()=>{if(!h.enabled){const y=s("settings.openchamber.passkeys.toast.enableUiPasswordFirst");D(y),B.message(y);return}if(!n){D(N.reason),B.message(N.reason);return}if(o){gi(),d(!1);return}D(""),d(!0);try{await um(),g(await Ga()),await w(),B.success(s("settings.openchamber.passkeys.toast.added"))}catch(y){if(pm(y)){B.message(s("settings.openchamber.passkeys.toast.setupCanceled"));return}const P=y instanceof Error?y.message:s("settings.openchamber.passkeys.toast.addFailed");D(P),B.error(P)}finally{d(!1)}},[o,w,h.enabled,N.reason,n,s]),k=l.useCallback(async y=>{f(y),D("");try{await gm(y),g(await Ga()),await w(),B.success(s("settings.openchamber.passkeys.toast.removed"))}catch(P){const z=P instanceof Error?P.message:s("settings.openchamber.passkeys.toast.removeFailed");D(z),B.error(z)}finally{f(null)}},[w,s]),j=l.useCallback(async()=>{p(!0),D("");try{await hm(),window.location.reload()}catch(y){const P=y instanceof Error?y.message:s("settings.openchamber.passkeys.toast.clearAuthFailed");D(P),B.error(P),p(!1)}},[s]);return t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.passkeys.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-2",children:[t.jsxs("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.passkeys.field.currentDevice")})}),t.jsxs("div",{className:"flex items-center gap-2 sm:w-fit",children:[t.jsx(G,{type:"button",variant:o?"secondary":"outline",size:"xs",onClick:()=>{A()},disabled:r||m,className:"!font-normal",children:s(o?"settings.openchamber.passkeys.actions.cancelSetup":"settings.openchamber.passkeys.actions.add")}),t.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:()=>{j()},disabled:r||o||m,className:"!font-normal text-muted-foreground hover:text-foreground",children:s(m?"settings.openchamber.passkeys.actions.signingOut":"settings.openchamber.passkeys.actions.signOutEverywhere")})]})]}),!h.enabled&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.passkeys.state.uiPasswordRequired")}),h.enabled&&!n&&t.jsx("p",{className:"typography-meta text-muted-foreground",children:N.reason}),r?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.passkeys.state.loading")}):u.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.passkeys.state.noneSaved")}):t.jsx("div",{className:"space-y-1 pt-1",children:u.map(y=>t.jsxs("div",{className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:y.label})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:y.lastUsedAt?s("settings.openchamber.passkeys.item.lastUsed",{time:Vo(y.lastUsedAt,s("settings.openchamber.passkeys.time.neverUsed"),e)}):s("settings.openchamber.passkeys.item.added",{time:Vo(y.createdAt,s("settings.openchamber.passkeys.time.neverUsed"),e)})}),t.jsx(G,{type:"button",variant:"ghost",size:"xs",onClick:()=>{k(y.id)},disabled:c===y.id,className:"!font-normal text-muted-foreground hover:text-foreground",children:c===y.id?s("settings.openchamber.passkeys.actions.removing"):s("settings.common.actions.delete")})]})]},y.id))})]}),x&&t.jsx("div",{className:"mt-1 px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:x})})]})},Lx=s=>{const e=pn(s);return e||{providerId:"",modelId:""}},Ql=()=>{const{t:s}=dt(),e=ut(I=>I.setProvider),n=ut(I=>I.setModel),a=ut(I=>I.setAgent),r=ut(I=>I.setCurrentVariant),i=ut(I=>I.setSettingsDefaultModel),o=ut(I=>I.setSettingsDefaultVariant),d=ut(I=>I.setSettingsDefaultAgent),c=Ke(I=>I.showDeletionDialog),f=Ke(I=>I.setShowDeletionDialog),m=ut(I=>I.providers),[p,u]=l.useState(),[S,h]=l.useState(),[g,x]=l.useState(),[D,N]=l.useState(!0),w=l.useMemo(()=>Lx(p),[p]);l.useEffect(()=>{(async()=>{try{let v=null;if(!v){const b=Fs()?.settings;if(b)try{const E=(await b.load())?.settings;E&&(v={defaultModel:typeof E.defaultModel=="string"?E.defaultModel:void 0,defaultVariant:typeof E.defaultVariant=="string"?E.defaultVariant:void 0,defaultAgent:typeof E.defaultAgent=="string"?E.defaultAgent:void 0})}catch{}}if(!v){const b=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});b.ok&&(v=await b.json())}if(v){const b=typeof v.defaultModel=="string"&&v.defaultModel.trim().length>0?v.defaultModel.trim():void 0,L=typeof v.defaultVariant=="string"&&v.defaultVariant.trim().length>0?v.defaultVariant.trim():void 0,E=typeof v.defaultAgent=="string"&&v.defaultAgent.trim().length>0?v.defaultAgent.trim():void 0;b!==void 0&&u(b),L!==void 0&&h(L),E!==void 0&&x(E)}}catch(v){console.warn("Failed to load defaults settings:",v)}finally{N(!1)}})()},[]);const A=l.useCallback(async(I,v)=>{const b=I&&v?`${I}/${v}`:void 0;u(b),h(void 0),o(void 0),r(void 0),i(b),I&&v&&m.find(E=>E.id===I)&&(e(I),n(v));try{await Pt({defaultModel:b??"",defaultVariant:""});const L=await jt("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultModel:b})});L.ok||console.warn("Failed to save default model to server:",L.status,L.statusText)}catch(L){console.warn("Failed to save default model:",L)}},[m,r,n,e,i,o]),k="__default__",j=l.useCallback(I=>I===k?s("settings.openchamber.defaults.option.default"):I.charAt(0).toUpperCase()+I.slice(1),[s]),y=l.useCallback(async I=>{const v=I===k?void 0:I||void 0;h(v),o(v),r(v);try{await Pt({defaultVariant:v??""})}catch(b){console.warn("Failed to save default variant:",b)}},[r,o]),P=l.useCallback(async I=>{const v=I||void 0;x(v),d(v),I&&a(I);try{await Pt({defaultAgent:v??""})}catch(b){console.warn("Failed to save default agent:",b)}},[a,d]),z=l.useMemo(()=>{if(!w.providerId||!w.modelId)return[];const b=m.find(L=>L.id===w.providerId)?.models.find(L=>L.id===w.modelId)?.variants;return b?Object.keys(b):[]},[w.modelId,w.providerId,m]),R=z.length>0;return l.useEffect(()=>{!R&&S&&(h(void 0),o(void 0),r(void 0),Pt({defaultVariant:""}).catch(()=>{}))},[S,r,o,R]),D?null:t.jsxs("div",{className:"mb-6",children:[t.jsx("div",{className:"mb-0.5 px-1",children:t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.defaults.title")})})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{className:"mt-0 mb-1 typography-meta text-muted-foreground",children:[s("settings.openchamber.defaults.summaryPrefix")," ",w.providerId?t.jsxs("span",{className:"text-foreground",children:[w.providerId,"/",w.modelId,R?` (${S??s("settings.openchamber.defaults.option.defaultLowercase")})`:""]}):t.jsx("span",{className:"text-foreground",children:s("settings.openchamber.defaults.summaryOpenCodeDefault")}),g&&t.jsxs(t.Fragment,{children:[" / ",t.jsx("span",{className:"text-foreground",children:g})]})]}),t.jsxs("div",{"data-settings-item":"sessions.default-model",className:ce("flex flex-col gap-2 py-1 sm:flex-row sm:items-center sm:gap-8"),children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.defaultModel")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(_r,{providerId:w.providerId,modelId:w.modelId,onChange:A})})]}),t.jsxs("div",{"data-settings-item":"sessions.default-thinking",className:"flex flex-col gap-2 py-1 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.defaultThinking")})}),t.jsx("div",{className:"flex items-center gap-2 sm:w-fit",children:t.jsxs(Ft,{value:S??k,onValueChange:y,disabled:!R,children:[t.jsx(Lt,{className:"w-fit min-w-[120px]",children:t.jsx(Kt,{placeholder:s("settings.openchamber.defaults.field.thinkingPlaceholder"),children:j(S??k)})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:k,children:s("settings.openchamber.defaults.option.default")}),z.map(I=>t.jsx(ht,{value:I,children:j(I)},I))]})]})})]}),t.jsxs("div",{"data-settings-item":"sessions.default-agent",className:"flex flex-col gap-2 py-1 sm:flex-row sm:items-center sm:gap-8",children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.defaultAgent")})}),t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:t.jsx(fl,{agentName:g||"",onChange:P})})]}),t.jsxs("div",{"data-settings-item":"sessions.deletion-dialog",className:"group flex cursor-pointer items-center gap-2 py-1",role:"button",tabIndex:0,"aria-pressed":c,onClick:()=>f(!c),onKeyDown:I=>{(I.key===" "||I.key==="Enter")&&(I.preventDefault(),f(!c))},children:[t.jsx(It,{checked:c,onChange:f,ariaLabel:s("settings.openchamber.defaults.field.showDeletionDialogAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.defaults.field.showDeletionDialog")})]})]})]})},_o={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"}},Ox={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"},zx=()=>{const{t:s}=dt(),e=l.useMemo(()=>fs(),[]),n=l.useMemo(()=>gs(),[]),a=!e&&!n,r=Ke(F=>F.nativeNotificationsEnabled),i=Ke(F=>F.setNativeNotificationsEnabled),o=Ke(F=>F.notificationMode),d=Ke(F=>F.setNotificationMode),c=Ke(F=>F.notifyOnSubtasks),f=Ke(F=>F.setNotifyOnSubtasks),m=Ke(F=>F.notifyOnCompletion),p=Ke(F=>F.setNotifyOnCompletion),u=Ke(F=>F.notifyOnError),S=Ke(F=>F.setNotifyOnError),h=Ke(F=>F.notifyOnQuestion),g=Ke(F=>F.setNotifyOnQuestion),x=Ke(F=>F.notificationTemplates),D=Ke(F=>F.setNotificationTemplates),[N,w]=l.useState("default"),[A,k]=l.useState(!1),[j,y]=l.useState(!1),[P,z]=l.useState(!1);l.useEffect(()=>{if(!a){k(!1),y(!1);return}typeof Notification<"u"&&w(Notification.permission);const F=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;k(F),(async()=>{if(!F){y(!1);return}try{const Q=await navigator.serviceWorker.getRegistration();if(!Q){y(!1);return}const ie=await Q.pushManager.getSubscription();y(!!ie)}catch{y(!1)}})()},[a]);const R=async F=>{if(e){i(F);return}if(!a){i(F);return}if(F&&typeof Notification<"u"&&Notification.permission==="default")try{const V=await Notification.requestPermission();w(V),V==="granted"?i(!0):B.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.description")})}catch(V){console.error("Failed to request notification permission:",V),B.error(s("settings.notifications.page.toast.requestPermissionFailed"))}else i(!!(F&&N==="granted"))},I=e||n||a&&typeof Notification<"u"&&Notification.permission==="granted",v=(F,V,Q)=>{D({...x,[F]:{...x[F],[V]:Q}})},b=F=>{const V="=".repeat((4-F.length%4)%4),Q=(F+V).replace(/-/g,"+").replace(/_/g,"/"),ie=atob(Q),X=new Uint8Array(ie.length);for(let se=0;se<ie.length;se+=1)X[se]=ie.charCodeAt(se);return X},L=async(F,V,Q)=>{let ie=null;const X=new Promise((se,me)=>{ie=setTimeout(()=>{me(new Error(Q))},V)});try{return await Promise.race([F,X])}finally{ie&&clearTimeout(ie)}},E=async F=>{if(F.active)return;const V=F.installing||F.waiting;V&&V.state!=="activated"&&await L(new Promise(Q=>{const ie=()=>{V.state==="activated"&&(V.removeEventListener("statechange",ie),Q())};V.addEventListener("statechange",ie),ie()}),15e3,"Service worker activation timed out")},J=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const F=[{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 V=null;for(const Q of F)try{const ie=Q.opts?navigator.serviceWorker.register("/sw.js",Q.opts):navigator.serviceWorker.register("/sw.js");return await L(ie,1e4,`Service worker registration timed out (${Q.label})`)}catch(ie){V=ie}throw V instanceof Error?V:new Error("Service worker registration failed")},_=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const F=await navigator.serviceWorker.getRegistration();if(F)return F;const V=await J();try{await V.update()}catch{}return await E(V),V},Z=F=>{const V=F,Q=[`type=${typeof F}`,`toString=${String(F)}`,`name=${String(V?.name??"")}`,`message=${String(V?.message??"")}`];let ie="";try{ie=JSON.stringify(F)}catch{}return{summary:Q.filter(Boolean).join(" | "),json:ie,stack:typeof V?.stack=="string"?V.stack:""}},H=async()=>{const F=Fs();if(!F?.notifications){B.error(s("settings.notifications.page.toast.notificationsApiUnavailable"));return}try{await F.notifications.notifyAgentCompletion({title:s("settings.notifications.page.testNotification.title"),body:s("settings.notifications.page.testNotification.body"),tag:"openchamber-test"})?B.success(s("settings.notifications.page.toast.testNotificationSent")):B.error(s("settings.notifications.page.toast.testNotificationFailed"))}catch(V){console.error("Test notification failed:",V),B.error(s("settings.notifications.page.toast.testNotificationFailed"))}},T=async()=>{if(!A){B.error(s("settings.notifications.page.toast.pushUnsupported"));return}const F=Fs();if(!F?.push){B.error(s("settings.notifications.page.toast.pushApiUnavailable"));return}z(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const xe=await Notification.requestPermission();if(w(xe),xe!=="granted"){B.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){B.error(s("settings.notifications.page.toast.permissionDenied.title"),{description:s("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}const V=await F.push.getVapidPublicKey();if(!V?.publicKey){B.error(s("settings.notifications.page.toast.pushKeyLoadFailed"));return}const Q=await _();await E(Q);const ie=await Q.pushManager.getSubscription();if(!("pushManager"in Q)||!Q.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const se=(ie??await L(Q.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:b(V.publicKey)}),15e3,"Push subscription timed out")).toJSON(),me=se.keys;if(!se.endpoint||!me?.p256dh||!me.auth)throw new Error("Push subscription missing keys");if(!(await L(F.push.subscribe({endpoint:se.endpoint,keys:{p256dh:me.p256dh,auth:me.auth},origin:typeof window<"u"?window.location.origin:void 0}),15e3,"Push subscribe request timed out"))?.ok){B.error(s("settings.notifications.page.toast.enableBackgroundFailed"));return}y(!0),B.success(s("settings.notifications.page.toast.backgroundEnabled"))}catch(V){console.error("[Push] Enable failed:",V);const Q=Z(V);B.error(s("settings.notifications.page.toast.enableBackgroundFailed"),{description:Q.summary})}finally{z(!1)}},Y=async()=>{if(!A){y(!1);return}const F=Fs();if(!F?.push){B.error(s("settings.notifications.page.toast.pushApiUnavailable"));return}z(!0);try{const Q=await(await _()).pushManager.getSubscription();if(!Q){y(!1);return}const ie=Q.endpoint;await Q.unsubscribe(),await F.push.unsubscribe({endpoint:ie}),y(!1),B.success(s("settings.notifications.page.toast.backgroundDisabled"))}finally{z(!1)}};return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{"data-settings-item":"notifications.delivery",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.notifications.page.delivery.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":r&&I,onClick:()=>{R(!(r&&I))},onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),R(!(r&&I)))},children:[t.jsx(It,{checked:r&&I,onChange:F=>{R(F)},ariaLabel:s("settings.notifications.page.delivery.enableAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.delivery.enableLabel")})]}),r&&I&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":o==="always",onClick:()=>d(o==="always"?"hidden-only":"always"),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),d(o==="always"?"hidden-only":"always"))},children:[t.jsx(It,{checked:o==="always",onChange:F=>d(F?"always":"hidden-only"),ariaLabel:s("settings.notifications.page.delivery.focusedAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.delivery.focusedLabel")})]}),t.jsx("div",{className:"py-2",children:t.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{H()},children:s("settings.notifications.page.delivery.testAction")})})]})]}),a&&t.jsxs("div",{className:"mt-1 px-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.notifications.page.delivery.browserPermissionHint")}),N==="denied"&&t.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:s("settings.notifications.page.delivery.permissionDenied")}),N==="granted"&&!r&&t.jsx("p",{className:"typography-meta text-muted-foreground/70 mt-1",children:s("settings.notifications.page.delivery.permissionGrantedButDisabled")})]}),n&&t.jsx("div",{className:"mt-1 px-2",children:t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.notifications.page.delivery.vscodeHint")})})]}),r&&I&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{"data-settings-item":"notifications.events",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.notifications.page.events.title")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":m,onClick:()=>p(!m),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),p(!m))},children:[t.jsx(It,{checked:m,onChange:p,ariaLabel:s("settings.notifications.page.events.completionAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.completionLabel")})]}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":c,onClick:()=>f(!c),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),f(!c))},children:[t.jsx(It,{checked:c,onChange:f,ariaLabel:s("settings.notifications.page.events.subtaskAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.subtaskLabel")})]}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":u,onClick:()=>S(!u),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),S(!u))},children:[t.jsx(It,{checked:u,onChange:S,ariaLabel:s("settings.notifications.page.events.errorAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.errorLabel")})]}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":h,onClick:()=>g(!h),onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&(F.preventDefault(),g(!h))},children:[t.jsx(It,{checked:h,onChange:g,ariaLabel:s("settings.notifications.page.events.questionAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.notifications.page.events.questionLabel")})]})]})]}),t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"mb-1 px-1",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.notifications.page.template.title")}),t.jsxs("p",{className:"typography-meta text-muted-foreground mt-0.5",children:[s("settings.notifications.page.template.variablesLabel")," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{project_name}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{worktree}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{branch}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{session_name}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{agent_name}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{model_name}"})," ",t.jsx("code",{className:"text-[var(--primary-base)]",children:"{last_message}"})]})]}),t.jsx("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2 md:gap-3",children:["completion","subtask","error","question"].map(F=>t.jsxs("section",{className:"p-2",children:[t.jsx("span",{className:"typography-ui-label text-foreground font-normal capitalize block",children:s(Ox[F])}),t.jsxs("div",{className:"mt-1.5 space-y-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:s("settings.notifications.page.template.field.title")}),t.jsx(it,{value:x[F].title,onChange:V=>v(F,"title",V.target.value),className:"h-7",placeholder:s(_o[F].titleKey)})]}),t.jsxs("div",{children:[t.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:s("settings.notifications.page.template.field.message")}),t.jsx(it,{value:x[F].message,onChange:V=>v(F,"message",V.target.value),className:"h-7",placeholder:s(_o[F].messageKey)})]})]})]},F))})]})]}),a&&t.jsxs("div",{"data-settings-item":"notifications.push",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.notifications.page.push.title")})}),t.jsx("section",{className:"px-2 pb-2 pt-0",children:t.jsxs("div",{className:"flex items-start gap-2 py-1.5",children:[t.jsx(It,{checked:A?j:!1,disabled:!A||P,onChange:F=>{F?T():Y()},ariaLabel:s("settings.notifications.page.push.enableAria")}),t.jsxs("div",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:ce("typography-ui-label",A?"text-foreground":"text-muted-foreground"),children:s("settings.notifications.page.push.enableLabel")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s(A?"settings.notifications.page.push.supportedHint":"settings.notifications.page.push.unsupportedHint")})]}),P&&t.jsx("div",{className:"pt-0.5 text-muted-foreground",children:t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":s("settings.notifications.page.push.loadingAria")})})]})})]})]})},ws=s=>{if(!s)return;s.pause();const{src:e}=s;e.startsWith("blob:")&&URL.revokeObjectURL(e),s.removeAttribute("src"),s.load()},Kx=[{value:"en-US",label:"English"},{value:"es-ES",label:"Español"},{value:"fr-FR",label:"Français"},{value:"de-DE",label:"Deutsch"},{value:"ja-JP",label:"日本語"},{value:"zh-CN",label:"中文"},{value:"pt-BR",label:"Português"},{value:"it-IT",label:"Italiano"},{value:"ko-KR",label:"한국어"},{value:"uk-UA",label:"Українська"}],$x=s=>{const e=rt.c(45),{modelId:n}=s,{t:a}=dt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=Wn.getModelStatus(),e[0]=r):r=e[0];const[i,o]=je.useState(r),[d,c]=je.useState(!1);let f,m;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const j=y=>o(y);return Wn.onModelStatusChange=j,Vx},m=[],e[1]=f,e[2]=m):(f=e[1],m=e[2]),je.useEffect(f,m);const p=Wn.getCurrentModelId(),u=i.state==="downloading"||i.state==="loading";let S,h;e[3]!==i.state?(S=()=>{i.state!=="downloading"&&i.state!=="loading"&&c(!1)},h=[i.state],e[3]=i.state,e[4]=S,e[5]=h):(S=e[4],h=e[5]),je.useEffect(S,h);let g;e[6]!==n?(g=async()=>{c(!0);try{await Wn.loadModel(n)}catch{}},e[6]=n,e[7]=g):g=e[7];const x=g;if(i.state==="ready"&&p===n){let j;e[8]!==a?(j=a("settings.voice.page.stt.wasmLoaded"),e[8]=a,e[9]=j):j=e[9];let y;return e[10]!==j?(y=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"typography-ui-compact text-green-600 dark:text-green-400",children:j})}),e[10]=j,e[11]=y):y=e[11],y}if(u){let j;e[12]!==i.progress||e[13]!==i.state?(j=i.state==="downloading"?Math.round(i.progress):void 0,e[12]=i.progress,e[13]=i.state,e[14]=j):j=e[14];const y=j;let P;e[15]!==i.state||e[16]!==a?(P=i.state==="downloading"?a("settings.voice.page.stt.wasmDownloading"):a("settings.voice.page.stt.wasmLoading"),e[15]=i.state,e[16]=a,e[17]=P):P=e[17];const z=y!==void 0?` (${y}%)`:"";let R;return e[18]!==P||e[19]!==z?(R=t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs("span",{className:"typography-ui-compact text-muted-foreground",children:[P,z]})}),e[18]=P,e[19]=z,e[20]=R):R=e[20],R}if(i.state==="error"){let j;e[21]!==i.error?(j=t.jsx("span",{className:"typography-ui-compact text-destructive",children:i.error}),e[21]=i.error,e[22]=j):j=e[22];let y;e[23]!==a?(y=a("settings.voice.page.stt.wasmRetry"),e[23]=a,e[24]=y):y=e[24];let P;e[25]!==x||e[26]!==d||e[27]!==y?(P=t.jsx(G,{variant:"chip",size:"xs",disabled:d,onClick:x,children:y}),e[25]=x,e[26]=d,e[27]=y,e[28]=P):P=e[28];let z;return e[29]!==j||e[30]!==P?(z=t.jsxs("div",{className:"flex items-center gap-2",children:[j,P]}),e[29]=j,e[30]=P,e[31]=z):z=e[31],z}let D;e[32]!==a?(D=a("settings.voice.page.stt.wasmNotLoaded"),e[32]=a,e[33]=D):D=e[33];let N;e[34]!==D?(N=t.jsx("span",{className:"typography-ui-compact text-muted-foreground",children:D}),e[34]=D,e[35]=N):N=e[35];let w;e[36]!==a?(w=a("settings.voice.page.stt.wasmDownload"),e[36]=a,e[37]=w):w=e[37];let A;e[38]!==x||e[39]!==d||e[40]!==w?(A=t.jsx(G,{variant:"chip",size:"xs",disabled:d,onClick:x,children:w}),e[38]=x,e[39]=d,e[40]=w,e[41]=A):A=e[41];let k;return e[42]!==A||e[43]!==N?(k=t.jsxs("div",{className:"flex items-center gap-2",children:[N,A]}),e[42]=A,e[43]=N,e[44]=k):k=e[44],k},Ux=[{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"}],Bx=()=>{const{t:s}=dt(),{isMobile:e}=Cs(),{isSupported:n,language:a,setLanguage:r}=fm(),i=ut(O=>O.voiceProvider),o=ut(O=>O.setVoiceProvider),d=ut(O=>O.speechRate),c=ut(O=>O.setSpeechRate),f=ut(O=>O.speechPitch),m=ut(O=>O.setSpeechPitch),p=ut(O=>O.speechVolume),u=ut(O=>O.setSpeechVolume),S=ut(O=>O.sayVoice),h=ut(O=>O.setSayVoice),g=ut(O=>O.browserVoice),x=ut(O=>O.setBrowserVoice),D=ut(O=>O.openaiVoice),N=ut(O=>O.setOpenaiVoice),w=ut(O=>O.openaiApiKey),A=ut(O=>O.setOpenaiApiKey),k=ut(O=>O.openaiCompatibleUrl),j=ut(O=>O.setOpenaiCompatibleUrl),y=ut(O=>O.openaiCompatibleApiKey),P=ut(O=>O.setOpenaiCompatibleApiKey),z=ut(O=>O.openaiCompatibleVoice),R=ut(O=>O.setOpenaiCompatibleVoice),I=ut(O=>O.openaiCompatibleTtsModel),v=ut(O=>O.setOpenaiCompatibleTtsModel),b=ut(O=>O.showMessageTTSButtons),L=ut(O=>O.ttsInputMode),E=ut(O=>O.setTtsInputMode),J=ut(O=>O.sttProvider),_=ut(O=>O.setSttProvider),Z=ut(O=>O.sttServerUrl),H=ut(O=>O.setSttServerUrl),T=ut(O=>O.sttApiKey),Y=ut(O=>O.setSttApiKey),F=ut(O=>O.sttModel),V=ut(O=>O.setSttModel),Q=ut(O=>O.wasmSttModel),ie=ut(O=>O.setWasmSttModel),X=ut(O=>O.sttLanguage),se=ut(O=>O.setSttLanguage),me=ut(O=>O.sttSilenceThresholdDb),oe=ut(O=>O.setSttSilenceThresholdDb),xe=ut(O=>O.sttSilenceHoldMs),we=ut(O=>O.setSttSilenceHoldMs),he=ut(O=>O.sttTranscribeOnStop),Ie=ut(O=>O.setSttTranscribeOnStop),ve=ut(O=>O.setShowMessageTTSButtons),ye=ut(O=>O.voiceModeEnabled),be=ut(O=>O.setVoiceModeEnabled),[te,re]=je.useState(!1),[ge,U]=je.useState([]),[ee,ne]=je.useState(!1),[ue,Me]=je.useState(null),[ke,De]=je.useState(!1),[Ae,Pe]=je.useState(!1),[Re,Le]=je.useState(null),[$e,Be]=je.useState(!1),[Oe,Ue]=je.useState(null),[le,W]=je.useState([]),[de,Ne]=je.useState(!1);je.useEffect(()=>((async()=>{const Fe=await Ja.waitForVoices();W(Fe)})(),"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=()=>{W(window.speechSynthesis.getVoices())}),()=>{"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);const Ee=je.useMemo(()=>le.filter(O=>O.lang).sort((O,Fe)=>{const Je=O.lang.startsWith("en"),Xe=Fe.lang.startsWith("en");if(Je&&!Xe)return-1;if(!Je&&Xe)return 1;const et=O.lang.localeCompare(Fe.lang);return et!==0?et:O.name.localeCompare(Fe.name)}),[le]),Ce=je.useCallback(()=>{if(de){Ja.cancelSpeech(),Ne(!1);return}const O=le.find(et=>et.name===g),Fe=O?.name??s("settings.voice.page.preview.browserVoiceFallback"),Je=s("settings.voice.page.preview.voiceLine",{voiceName:Fe});Ne(!0);const Xe=new SpeechSynthesisUtterance(Je);Xe.rate=d,Xe.pitch=f,Xe.volume=p,O&&(Xe.voice=O,Xe.lang=O.lang),Xe.onend=()=>Ne(!1),Xe.onerror=()=>Ne(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(Xe)},[g,le,d,f,p,de,s]);je.useEffect(()=>()=>{de&&Ja.cancelSpeech()},[de]),je.useEffect(()=>{if(!ye||i!=="openai"&&i!=="openai-compatible"){De(w.trim().length>0);return}(async()=>{try{const Xe=(await(await jt("/api/tts/status")).json()).available,et=w.trim().length>0;De(Xe||et)}catch{De(w.trim().length>0)}})()},[w,ye,i]),je.useEffect(()=>{if(!ye){re(!1),U([]);return}jt("/api/tts/say/status").then(O=>O.json()).then(O=>{if(re(O.available),O.voices){const Fe=O.voices.filter((Je,Xe,et)=>et.findIndex(at=>at.name===Je.name)===Xe).sort((Je,Xe)=>Je.name.localeCompare(Xe.name));U(Fe)}}).catch(()=>{re(!1)})},[ye]);const He=je.useCallback(async()=>{if(ue){ws(ue),Me(null),ne(!1);return}ne(!0);let O=null;try{const Fe=await jt("/api/tts/say/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.voiceLine",{voiceName:S}),voice:S,rate:Math.round(100+(d-.5)*200)})});if(!Fe.ok)throw new Error("Preview failed");const Je=await Fe.blob(),Xe=URL.createObjectURL(Je);O=new Audio(Xe),O.onended=()=>{ws(O),Me(null),ne(!1)},O.onerror=()=>{ws(O),Me(null),ne(!1)},Me(O),await O.play()}catch{ws(O),Me(null),ne(!1)}},[S,d,ue,s]);je.useEffect(()=>()=>{ws(ue)},[ue]);const q=je.useCallback(async()=>{if(Re){ws(Re),Le(null),Pe(!1);return}Pe(!0);let O=null;try{const Fe=await jt("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.voiceLine",{voiceName:D}),voice:D,speed:d,apiKey:w||void 0})});if(!Fe.ok){const et=await Fe.json().catch(()=>({error:"Unknown error"}));throw new Error(et.error||`HTTP ${Fe.status}`)}const Je=await Fe.blob(),Xe=URL.createObjectURL(Je);O=new Audio(Xe),O.onended=()=>{ws(O),Le(null),Pe(!1)},O.onerror=()=>{ws(O),Le(null),Pe(!1)},Le(O),await O.play()}catch{ws(O),Le(null),Pe(!1)}},[D,d,Re,w,s]);je.useEffect(()=>()=>{ws(Re)},[Re]);const $=je.useCallback(async()=>{if(Oe){ws(Oe),Ue(null),Be(!1);return}if(!k.trim())return;Be(!0);let O=null;try{const Fe=await jt("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:s("settings.voice.page.preview.customServerLine"),voice:z,model:I||void 0,speed:d,baseURL:k,apiKey:y||void 0})});if(!Fe.ok){const et=await Fe.json().catch(()=>({error:"Unknown error"}));throw new Error(et.error||`HTTP ${Fe.status}`)}const Je=await Fe.blob(),Xe=URL.createObjectURL(Je);O=new Audio(Xe),O.onended=()=>{ws(O),Ue(null),Be(!1)},O.onerror=()=>{ws(O),Ue(null),Be(!1)},Ue(O),await O.play()}catch{ws(O),Ue(null),Be(!1)}},[k,z,I,y,d,Oe,s]);je.useEffect(()=>()=>{ws(Oe)},[Oe]);const fe="flex-1 min-w-0 h-1.5 bg-[var(--interactive-border)] rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:border-0 disabled:opacity-50";return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{"data-settings-item":"voice.voice-setup",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.voice.page.section.voiceSetup")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":ye,onClick:()=>be(!ye),onKeyDown:O=>{(O.key===" "||O.key==="Enter")&&(O.preventDefault(),be(!ye))},children:[t.jsx(It,{checked:ye,onChange:be,ariaLabel:s("settings.voice.page.field.enableVoiceModeAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.enableVoiceMode")})]}),ye&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pb-1.5 pt-0.5",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.provider")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:t.jsxs("ul",{className:"space-y-1",children:[t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.browser")})," ",s("settings.voice.page.tooltip.browser")]}),t.jsxs("li",{children:[t.jsx("strong",{children:"OpenAI:"})," ",s("settings.voice.page.tooltip.openai")]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.custom")})," ",s("settings.voice.page.tooltip.custom")]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.say")})," ",s("settings.voice.page.tooltip.say")]})]})})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(G,{variant:"chip",size:"xs","aria-pressed":i==="browser",onClick:()=>o("browser"),className:"!font-normal",children:s("settings.voice.page.provider.browser")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":i==="openai",onClick:()=>o("openai"),className:"!font-normal",children:"OpenAI"}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":i==="openai-compatible",onClick:()=>o("openai-compatible"),className:"!font-normal",children:s("settings.voice.page.provider.custom")}),te&&t.jsxs(G,{variant:"chip",size:"xs","aria-pressed":i==="say",onClick:()=>o("say"),className:"!font-normal",children:[t.jsx(M,{name:"apple",className:"w-3.5 h-3.5 mr-0.5"}),s("settings.voice.page.provider.say")]})]})]})}),i==="openai"&&t.jsxs("div",{className:"py-1.5",children:[t.jsx("span",{className:ce("typography-ui-label text-foreground",!ke&&"text-[var(--status-error)]"),children:s("settings.voice.page.field.apiKey")}),t.jsx("span",{className:ce("typography-meta ml-2",ke?"text-muted-foreground":"text-[var(--status-error)]/80"),children:s(ke&&!w?"settings.voice.page.field.apiKeyHintUsingConfig":ke?"settings.voice.page.field.apiKeyHintProvide":"settings.voice.page.field.apiKeyHintRequired")}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"password",value:w,onChange:O=>A(O.target.value),placeholder:"sk-...",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),w&&t.jsx("button",{type:"button",onClick:()=>A(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(M,{name:"close",className:"w-3.5 h-3.5"})})]})]}),i==="openai-compatible"&&t.jsxs("div",{className:"py-1.5 space-y-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:ce("typography-ui-label text-foreground",!k.trim()&&"text-[var(--status-error)]"),children:s("settings.voice.page.field.serverUrl")}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:s("settings.voice.page.field.serverUrlHint")}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"text",value:k,onChange:O=>j(O.target.value),placeholder:"http://localhost:8880/v1",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),k&&t.jsx("button",{type:"button",onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(M,{name:"close",className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:"API Key"}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:"Optional"}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"password",value:y,onChange:O=>P(O.target.value),placeholder:"sk-...",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),y&&t.jsx("button",{type:"button",onClick:()=>P(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(M,{name:"close",className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.model")}),t.jsx("div",{className:"relative mt-1.5 max-w-xs",children:t.jsx("input",{type:"text",value:I,onChange:O=>v(O.target.value),placeholder:"speaches-ai/Kokoro-82M-v1.0-ONNX",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"})})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.voice")}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:s("settings.voice.page.field.voiceIdentifierHint")}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx("div",{className:"relative max-w-xs flex-1",children:t.jsx("input",{type:"text",value:z,onChange:O=>R(O.target.value),placeholder:"af_sky",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"})}),t.jsx(G,{size:"xs",variant:"ghost",onClick:$,title:s("settings.voice.page.actions.preview"),disabled:!k.trim(),children:$e?t.jsx(M,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(M,{name:"play",className:"w-3.5 h-3.5"})})]})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.voice")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[i==="openai"&&ke&&t.jsxs(t.Fragment,{children:[t.jsxs(Ft,{value:D,onValueChange:N,children:[t.jsx(Lt,{className:"w-fit",children:t.jsx(Kt,{placeholder:s("settings.voice.page.field.selectVoicePlaceholder")})}),t.jsx(Ot,{children:Ux.map(O=>t.jsx(ht,{value:O.value,children:O.label},O.value))})]}),t.jsx(G,{size:"xs",variant:"ghost",onClick:q,title:s("settings.voice.page.actions.preview"),children:Ae?t.jsx(M,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(M,{name:"play",className:"w-3.5 h-3.5"})})]}),i==="openai-compatible"&&t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.voice.page.field.configuredAbove")}),i==="say"&&te&&ge.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs(Ft,{value:S,onValueChange:h,children:[t.jsx(Lt,{className:"w-fit",children:t.jsx(Kt,{placeholder:s("settings.voice.page.field.selectVoicePlaceholder")})}),t.jsx(Ot,{children:ge.map(O=>t.jsx(ht,{value:O.name,children:O.name},O.name))})]}),t.jsx(G,{size:"xs",variant:"ghost",onClick:He,title:s("settings.voice.page.actions.preview"),children:ee?t.jsx(M,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(M,{name:"play",className:"w-3.5 h-3.5"})})]}),i==="browser"&&Ee.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs(Ft,{value:g||"$auto",onValueChange:O=>x(O==="$auto"?"":O),children:[t.jsx(Lt,{className:"w-fit max-w-[200px]",children:t.jsx(Kt,{placeholder:s("settings.voice.page.field.auto")})}),t.jsxs(Ot,{children:[t.jsx(ht,{value:"$auto",children:s("settings.voice.page.field.auto")}),Ee.map(O=>t.jsxs(ht,{value:O.name,children:[O.name," (",O.lang,")"]},O.name))]})]}),t.jsx(G,{size:"xs",variant:"ghost",onClick:Ce,title:s("settings.voice.page.actions.preview"),children:de?t.jsx(M,{name:"stop",className:"w-3.5 h-3.5"}):t.jsx(M,{name:"play",className:"w-3.5 h-3.5"})})]})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.speechRate")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:.5,max:2,step:.1,value:d,onChange:O=>c(Number(O.target.value)),disabled:!n,className:fe}),t.jsx(xs,{value:d,onValueChange:c,min:.5,max:2,step:.1,className:"w-16 tabular-nums"})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.speechPitch")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:.5,max:2,step:.1,value:f,onChange:O=>m(Number(O.target.value)),disabled:!n,className:fe}),t.jsx(xs,{value:f,onValueChange:m,min:.5,max:2,step:.1,className:"w-16 tabular-nums"})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.speechVolume")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:0,max:1,step:.1,value:p,onChange:O=>u(Number(O.target.value)),disabled:!n,className:fe}),e?t.jsx(xs,{value:Math.round(p*100),onValueChange:O=>u(O/100),min:0,max:100,step:10,className:"w-16 tabular-nums"}):t.jsxs("span",{className:"typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right",children:[Math.round(p*100),"%"]})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.language")}),t.jsx("div",{className:"flex items-center gap-2 w-fit",children:t.jsxs(Ft,{value:a,onValueChange:r,disabled:!n,children:[t.jsx(Lt,{className:"w-fit",children:t.jsx(Kt,{placeholder:s("settings.voice.page.field.selectLanguagePlaceholder")})}),t.jsx(Ot,{children:Kx.map(O=>t.jsx(ht,{value:O.value,children:O.label},O.value))})]})})]})]})]})]}),ye&&t.jsxs("div",{"data-settings-item":"voice.speech-recognition",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.voice.page.section.speechRecognition")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsx("div",{className:"pb-1.5 pt-0.5",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.provider")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:t.jsxs("ul",{className:"space-y-1",children:[t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.browser")})," ",s("settings.voice.page.tooltip.sttBrowser")]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("settings.voice.page.provider.server")})," ",s("settings.voice.page.tooltip.sttServer")]})]})})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(G,{variant:"chip",size:"xs","aria-pressed":J==="browser",onClick:()=>_("browser"),className:"!font-normal",children:s("settings.voice.page.provider.browser")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":J==="server",onClick:()=>_("server"),className:"!font-normal",children:s("settings.voice.page.provider.server")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":J==="wasm",onClick:()=>_("wasm"),className:"!font-normal",children:s("settings.voice.page.provider.wasm")})]})]})}),J==="server"&&t.jsxs("div",{className:"py-1.5 space-y-2",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":he,onClick:()=>Ie(!he),onKeyDown:O=>{(O.key===" "||O.key==="Enter")&&(O.preventDefault(),Ie(!he))},children:[t.jsx(It,{checked:he,onChange:Ie,ariaLabel:s("settings.voice.page.field.transcribeOnStopAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.transcribeOnStop")})]}),!xm.isSupported()&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:s("settings.voice.page.field.sttBrowserSupportError")}),t.jsxs("div",{children:[t.jsx("span",{className:ce("typography-ui-label text-foreground",!Z.trim()&&"text-[var(--status-error)]"),children:s("settings.voice.page.field.serverUrl")}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:s("settings.voice.page.field.sttServerUrlHint")}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"text",value:Z,onChange:O=>H(O.target.value),placeholder:"http://localhost:8001/v1",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),Z&&t.jsx("button",{type:"button",onClick:()=>H(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(M,{name:"close",className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:"API Key"}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:"Optional"}),t.jsxs("div",{className:"relative mt-1.5 max-w-xs",children:[t.jsx("input",{type:"password",value:T,onChange:O=>Y(O.target.value),placeholder:"sk-...",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"}),T&&t.jsx("button",{type:"button",onClick:()=>Y(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:t.jsx(M,{name:"close",className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.model")}),t.jsx("div",{className:"relative mt-1.5 max-w-xs",children:t.jsx("input",{type:"text",value:F,onChange:O=>V(O.target.value),placeholder:"deepdml/faster-whisper-large-v3-turbo-ct2",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"})})]}),t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.language")}),t.jsx("span",{className:"typography-meta ml-2 text-muted-foreground",children:s("settings.voice.page.field.sttLanguageHint")}),t.jsx("div",{className:"relative mt-1.5 max-w-[8rem]",children:t.jsx("input",{type:"text",value:X,onChange:O=>se(O.target.value),placeholder:"auto",className:"w-full h-7 rounded-lg border border-input bg-transparent px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50 focus:border-primary/70"})})]}),t.jsxs("div",{className:"flex items-center gap-8 py-0.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.silenceThreshold")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:-60,max:-20,step:1,value:me,onChange:O=>oe(Number(O.target.value)),className:fe}),t.jsxs("span",{className:"typography-ui-label text-foreground tabular-nums min-w-[3.5rem] text-right",children:[me," dB"]})]})]}),t.jsxs("div",{className:"flex items-center gap-8 py-0.5",children:[t.jsx("span",{className:"typography-ui-label text-foreground sm:w-56 shrink-0",children:s("settings.voice.page.field.silenceHold")}),t.jsxs("div",{className:"flex items-center gap-2 w-fit",children:[!e&&t.jsx("input",{type:"range",min:500,max:3e3,step:100,value:xe,onChange:O=>we(Number(O.target.value)),className:fe}),t.jsx(xs,{value:xe,onValueChange:we,min:500,max:3e3,step:100,className:"w-20 tabular-nums"}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s("settings.voice.page.field.millisecondsUnit")})]})]})]}),J==="wasm"&&t.jsxs("div",{className:"py-1.5 space-y-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"typography-ui-label text-muted-foreground",children:s("settings.voice.page.stt.wasmModel")}),t.jsxs(Ft,{value:Q,onValueChange:ie,children:[t.jsx(Lt,{className:"mt-0.5",children:t.jsx(Kt,{placeholder:s("settings.voice.page.stt.wasmModel")})}),t.jsx(Ot,{children:hi.map(O=>t.jsx(ht,{value:O.id,children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{children:O.name}),t.jsxs("span",{className:"typography-ui-compact text-muted-foreground",children:[O.size," · ",O.languages]})]})},O.id))})]}),t.jsx("p",{className:"typography-ui-compact text-muted-foreground mt-0.5",children:hi.find(O=>O.id===Q)?.description})]}),t.jsx($x,{modelId:Q})]})]})]}),t.jsxs("div",{"data-settings-item":"voice.playback",className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.voice.page.section.playbackAndSummary")})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0",children:[t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2 py-1.5",role:"button",tabIndex:0,"aria-pressed":b,onClick:()=>ve(!b),onKeyDown:O=>{(O.key===" "||O.key==="Enter")&&(O.preventDefault(),ve(!b))},children:[t.jsx(It,{checked:b,onChange:ve,ariaLabel:s("settings.voice.page.field.messageReadAloudButtonAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.messageReadAloudButton")})]}),t.jsx("div",{className:"pb-1.5 pt-0.5",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.voice.page.field.ttsInputMode")})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsx(G,{variant:"chip",size:"xs","aria-pressed":L==="sanitized",onClick:()=>E("sanitized"),className:"!font-normal",children:s("settings.voice.page.field.ttsInputModeSanitized")}),t.jsx(G,{variant:"chip",size:"xs","aria-pressed":L==="raw",onClick:()=>E("raw"),className:"!font-normal",children:s("settings.voice.page.field.ttsInputModeRaw")})]})]})})]}),ye&&n&&t.jsx("div",{className:"mt-2 px-2",children:t.jsxs("p",{className:"typography-meta text-muted-foreground",children:[s("settings.voice.page.hint.shiftClickPrefix")," ",t.jsx("kbd",{className:"px-1 py-0.5 mx-0.5 rounded border border-[var(--interactive-border)] bg-background typography-mono text-[10px]",children:"Shift"})," + ",t.jsx("kbd",{className:"px-1 py-0.5 mx-0.5 rounded border border-[var(--interactive-border)] bg-background typography-mono text-[10px]",children:"Click"})," ",s("settings.voice.page.hint.shiftClickSuffix")]})})]})]})};function Vx(){Wn.onModelStatusChange=null}const fa=[{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}],xa=[{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}],_x="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",Hx="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",ur=[{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"}],Wx=[".yml",".yaml",".json"],qx="settings.openchamber.tunnel.error.invalidConfigExtension",_n=s=>{const e=s.trim().toLowerCase();return Wx.some(n=>e.endsWith(n))},Gx=s=>s==="ngrok"?"ngrok":"cloudflared",Yl=()=>{if(typeof window<"u"&&typeof window.__OPENCHAMBER_PLATFORM__=="string"){const e=window.__OPENCHAMBER_PLATFORM__;if(e==="win32"||e==="darwin"||e==="linux")return e}const s=typeof navigator<"u"?`${navigator.platform||""} ${navigator.userAgent||""}`.toLowerCase():"";return s.includes("win")?"win32":s.includes("mac")?"darwin":"linux"},Jx=(s,e=Yl())=>s==="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/cloudflared/downloads/",pr=(s,e)=>{const n=typeof e?.provider=="string"&&e.provider.trim().length>0?e.provider.trim().toLowerCase():s,a=typeof e?.dependency=="string"&&e.dependency.trim().length>0?e.dependency.trim():Gx(n),r=typeof e?.platform=="string"&&e.platform.trim().length>0?e.platform.trim():Yl(),i=typeof e?.installCommand=="string"&&e.installCommand.trim().length>0?e.installCommand.trim():Jx(n,r);return{provider:n,dependency:a,installCommand:i}},Xl=s=>s==="cloudflare"?"Cloudflare":s==="ngrok"?"Ngrok":s,Ho=s=>{const e=rt.c(11),{provider:n}=s;let a;e[0]!==n?(a=Xl(n),e[0]=n,e[1]=a):a=e[1];const r=a,d=n==="cloudflare"||n==="ngrok"?"text-[var(--status-warning)]":"text-muted-foreground";let c;e[2]!==d?(c=ce("size-4 shrink-0",d),e[2]=d,e[3]=c):c=e[3];let f;e[4]!==c?(f=t.jsx(M,{name:"cloud",className:c}),e[4]=c,e[5]=f):f=e[5];let m;e[6]!==r?(m=t.jsx("span",{children:r}),e[6]=r,e[7]=m):m=e[7];let p;return e[8]!==f||e[9]!==m?(p=t.jsxs("span",{className:"flex items-center gap-2",children:[f,m]}),e[8]=f,e[9]=m,e[10]=p):p=e[10],p},Zs=s=>s==="quick"?"quick":s==="managed-remote"?"managed-remote":s==="managed-local"?"managed-local":"quick",Lr=(s,e,n)=>s.find(r=>r.ms===e)?.value||n,Wo=(s,e,n)=>{const a=Lr(s,e,n);return s.find(r=>r.value===a)?.label||a},qo=s=>{const e=Math.max(0,s),n=Math.floor(e/1e3),a=Math.floor(n/3600),r=Math.floor(n%3600/60),i=n%60;return a>0?`${a}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`},Qx=(s,e)=>wl(s,e,{hour:"2-digit",precision:"second"}),Aa=s=>{const e=s.trim();if(!e)return"";try{return(e.includes("://")?new URL(e):new URL(`https://${e}`)).hostname.trim().toLowerCase()}catch{return e.toLowerCase()}},Yx=s=>{if(!Array.isArray(s))return[];const e=new Set,n=new Set,a=[];for(const r of s){if(!r||typeof r!="object")continue;const i=r,o=typeof i.id=="string"?i.id.trim():"",d=typeof i.name=="string"?i.name.trim():"",c=Aa(typeof i.hostname=="string"?i.hostname:"");!o||!d||!c||e.has(o)||n.has(c)||(e.add(o),n.add(c),a.push({id:o,name:d,hostname:c}))}return a},Xx=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,Zx=()=>{const{t:s}=dt(),e=Ke(ae=>ae.timeFormatPreference),n=l.useCallback(ae=>s(ae),[s]),[a,r]=l.useState("checking"),[i,o]=l.useState(null),[d,c]=l.useState(null),[f,m]=l.useState(null),[p,u]=l.useState(null),[S,h]=l.useState(null),[g,x]=l.useState(!1),[D,N]=l.useState(!1),[w,A]=l.useState(!1),[k,j]=l.useState("cloudflare"),[y,P]=l.useState(()=>pr("cloudflare")),[z,R]=l.useState([]),[I,v]=l.useState("quick"),[b,L]=l.useState(null),[E,J]=l.useState([]),[_,Z]=l.useState({}),[H,T]=l.useState(""),[Y,F]=l.useState({}),[V,Q]=l.useState(new Set),[ie,X]=l.useState(!1),[se,me]=l.useState(""),[oe,xe]=l.useState(""),[we,he]=l.useState(""),[Ie,ve]=l.useState(1800*1e3),[ye,be]=l.useState(480*60*1e3),[te,re]=l.useState(""),[ge,U]=l.useState([]),[ee,ne]=l.useState(()=>Date.now()),[ue,Me]=l.useState(null),ke=s(qx),De=l.useRef(null),Ae=l.useMemo(()=>b?!_n(b):!1,[b]),Pe=l.useMemo(()=>E.find(ae=>ae.id===H)||E[0]||null,[E,H]),Re=l.useMemo(()=>ge.map(ae=>{const Ve=ae.expiresAt<=ee,tt=ae.status==="active"&&!Ve,Ye=tt?qo(ae.expiresAt-ee):ae.inactiveReason==="expired"||Ve?"expired":"inactive",yt=Ye==="expired"?s("settings.openchamber.tunnel.state.expired"):ae.inactiveReason==="tunnel-revoked"?s("settings.openchamber.tunnel.state.revoked"):s("settings.openchamber.tunnel.state.inactive"),ze=Zs(ae.mode);return{...ae,isActive:tt,mode:ze,remainingTextForSession:Ye,inactiveLabel:yt}}),[ee,ge,s]),Le=l.useMemo(()=>i?.connectUrl?i.bootstrapExpiresAt===null?!0:i.bootstrapExpiresAt>ee:!1,[ee,i?.bootstrapExpiresAt,i?.connectUrl]),$e=l.useMemo(()=>!i||a!=="active"&&a!=="stopping"?!1:d===I,[d,a,i,I]),Be=l.useMemo(()=>!i||a!=="active"||!d?!1:d!==I,[d,a,i,I]),Oe=l.useMemo(()=>{if(typeof ue=="number"&&Number.isFinite(ue)&&ue>0)return ue;if(typeof window>"u")return null;const Ve=Xn()||window.location.href;let tt=0;try{tt=Number(new URL(Ve).port)}catch{tt=Number(window.location.port)}return Number.isFinite(tt)&&tt>0?tt:null},[ue]),Ue=l.useMemo(()=>z.find(ae=>ae.provider===k)??null,[z,k]),le=l.useMemo(()=>{const ae=new Set(Ue?.modes?.map(Ve=>Ve.key).filter(Ve=>Ve==="quick"||Ve==="managed-remote"||Ve==="managed-local"));return ae.size===0?ur:ur.filter(Ve=>ae.has(Ve.value))},[Ue]),W=l.useMemo(()=>le.some(ae=>ae.value==="managed-remote"||ae.value==="managed-local"),[le]),de=l.useMemo(()=>y.provider===k?y:pr(k),[y,k]),Ne=l.useCallback(async ae=>{await Hs(ae)},[]),Ee=l.useCallback((ae,Ve)=>(P(pr(Ve,ae)),ae.available===!0),[]),Ce=l.useCallback(async(ae,Ve)=>{try{const tt=await jt("/api/openchamber/tunnel/check",{query:{provider:ae},...Ve?{signal:Ve}:{}});if(!tt.ok)return null;const Ye=await tt.json();if(Ve?.aborted)return null;const yt=Ee(Ye,ae);return r(ze=>ze==="checking"||ze==="starting"||ze==="active"||ze==="stopping"?ze:yt?"idle":"not-available"),yt}catch{return null}},[Ee]),He=l.useCallback(async ae=>{try{const[Ve,tt,Ye,yt]=await Promise.all([jt("/api/openchamber/tunnel/check",{signal:ae}),jt("/api/openchamber/tunnel/status",{signal:ae}),jt("/api/config/settings",{signal:ae,headers:{Accept:"application/json"}}),jt("/api/openchamber/tunnel/providers",{signal:ae})]),ze=await Ve.json(),_e=await tt.json(),ot=Ye.ok?await Ye.json():{},bt=yt.ok?await yt.json():{},Mt=_e.ttlConfig?.bootstrapTtlMs??(ot?.tunnelBootstrapTtlMs===null?null:typeof ot?.tunnelBootstrapTtlMs=="number"?ot.tunnelBootstrapTtlMs:1800*1e3),Qt=typeof _e.ttlConfig?.sessionTtlMs=="number"?_e.ttlConfig.sessionTtlMs:typeof ot?.tunnelSessionTtlMs=="number"?ot.tunnelSessionTtlMs:480*60*1e3,Xt=Zs(_e.mode??ot?.tunnelMode),rs=typeof ot?.tunnelProvider=="string"&&ot.tunnelProvider.trim().length>0?ot.tunnelProvider.trim().toLowerCase():"cloudflare",Wt=typeof ot?.managedLocalTunnelConfigPath=="string"&&ot.managedLocalTunnelConfigPath.trim()||null,Se=Ee(ze,rs),vt=Yx(_e?.managedRemoteTunnelPresets),Nt=typeof _e.managedRemoteTunnelHostname=="string"?_e.managedRemoteTunnelHostname:"",ct=vt.length>0?vt:Nt?[{id:`legacy-${Aa(Nt)}`,name:Nt,hostname:Aa(Nt)}]:[],St=ct[0]?.id||"";if(ve(Mt),be(Qt),j(rs),R(Array.isArray(bt?.providers)?bt.providers:[]),v(Xt),L(Wt),J(ct),T(St),U(Array.isArray(_e.activeSessions)?_e.activeSessions:[]),c(_e.activeTunnelMode?Zs(_e.activeTunnelMode):_e.active&&_e.mode?Zs(_e.mode):null),Q(new Set(Array.isArray(_e.managedRemoteTunnelTokenPresetIds)?_e.managedRemoteTunnelTokenPresetIds:[])),Me(typeof _e.localPort=="number"?_e.localPort:null),_e.active&&_e.url){o({url:_e.url,connectUrl:null,bootstrapExpiresAt:typeof _e.bootstrapExpiresAt=="number"?_e.bootstrapExpiresAt:null}),r("active");return}r(Se?"idle":"not-available")}catch{ae.aborted||(r("error"),u(s("settings.openchamber.tunnel.toast.checkAvailabilityFailed")))}},[Ee,s]);l.useEffect(()=>{const ae=new AbortController;return He(ae.signal),()=>ae.abort()},[He]),l.useEffect(()=>{if(!i?.connectUrl){m(null);return}let ae=!1;return pl.toDataURL(i.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(Ve=>{ae||m(Ve)}).catch(()=>{ae||m(null)}),()=>{ae=!0}},[i?.connectUrl]),l.useEffect(()=>{if(!i?.bootstrapExpiresAt){re(s("settings.openchamber.tunnel.state.noExpiry"));return}let ae=null,Ve=Date.now();const tt=()=>{const ze=i.bootstrapExpiresAt?i.bootstrapExpiresAt-Date.now():0;ze<=0?re(s("settings.openchamber.tunnel.state.expired")):re(qo(ze))},Ye=()=>{const ze=Date.now();ze-Ve>=1e3&&(tt(),Ve=ze),ae=requestAnimationFrame(Ye)};tt(),(typeof document>"u"||document.visibilityState==="visible")&&(ae=requestAnimationFrame(Ye));const yt=()=>{document.visibilityState==="visible"&&ae===null?ae=requestAnimationFrame(Ye):document.visibilityState!=="visible"&&ae!==null&&(cancelAnimationFrame(ae),ae=null)};return document.addEventListener("visibilitychange",yt),()=>{document.removeEventListener("visibilitychange",yt),ae!==null&&cancelAnimationFrame(ae)}},[s,i?.bootstrapExpiresAt]),l.useEffect(()=>{let ae=null,Ve=Date.now();const tt=()=>{const yt=Date.now();yt-Ve>=1e3&&(ne(yt),Ve=yt),ae=requestAnimationFrame(tt)};(typeof document>"u"||document.visibilityState==="visible")&&(ae=requestAnimationFrame(tt));const Ye=()=>{document.visibilityState==="visible"&&ae===null?ae=requestAnimationFrame(tt):document.visibilityState!=="visible"&&ae!==null&&(cancelAnimationFrame(ae),ae=null)};return document.addEventListener("visibilitychange",Ye),()=>{document.removeEventListener("visibilitychange",Ye),ae!==null&&cancelAnimationFrame(ae)}},[]),l.useEffect(()=>{if(a==="starting"||a==="stopping"||a==="checking")return;let ae=!1;const Ve=async()=>{try{const Ye=await jt("/api/openchamber/tunnel/status");if(!Ye.ok||ae)return;const yt=await Ye.json();if(ae)return;U(Array.isArray(yt.activeSessions)?yt.activeSessions:[]),Q(new Set(Array.isArray(yt.managedRemoteTunnelTokenPresetIds)?yt.managedRemoteTunnelTokenPresetIds:[])),Me(typeof yt.localPort=="number"?yt.localPort:null)}catch{}},tt=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Ve()},5e3);return()=>{ae=!0,window.clearInterval(tt)}},[a]);const q=l.useCallback(async ae=>{A(!0);try{await Pt(ae),Object.prototype.hasOwnProperty.call(ae,"tunnelMode")&&ae.tunnelMode&&v(ae.tunnelMode),Object.prototype.hasOwnProperty.call(ae,"tunnelProvider")&&typeof ae.tunnelProvider=="string"&&j(ae.tunnelProvider),Object.prototype.hasOwnProperty.call(ae,"managedLocalTunnelConfigPath")&&L(ae.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(ae,"managedRemoteTunnelPresets")&&ae.managedRemoteTunnelPresets&&J(ae.managedRemoteTunnelPresets)}catch{B.error(s("settings.openchamber.tunnel.toast.saveSettingsFailed"))}finally{A(!1)}},[s]),$=l.useCallback(async(ae,Ve)=>{N(!0);try{await Pt({tunnelBootstrapTtlMs:ae,tunnelSessionTtlMs:Ve})}catch{B.error(s("settings.openchamber.tunnel.toast.saveTtlFailed"))}finally{N(!1)}},[s]),fe=l.useCallback(async ae=>{const Ve=ae.token.trim();if(Ve)try{const tt={...Y,[ae.presetId]:Ve};await Pt({managedRemoteTunnelPresetTokens:tt}),Q(Ye=>{const yt=new Set(Ye);return yt.add(ae.presetId),yt})}catch{B.error(s("settings.openchamber.tunnel.toast.saveTokenFailed"))}},[Y,s]),O=l.useCallback(async ae=>{h(null),u(null);const Ve=z.find(Ye=>Ye.provider===ae),tt=Ve?.modes?.some(Ye=>Ye.key===I)?I:Zs(Ve?.modes?.[0]?.key);await q({tunnelProvider:ae,tunnelMode:tt}),Ce(ae)},[z,Ce,q,I]),Fe=l.useCallback(async()=>{const ae=await Sl({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(ae.success&&typeof ae.path=="string"&&ae.path.trim().length>0){const Ve=ae.path.trim();if(!_n(Ve)){B.error(ke);return}L(Ve),await q({managedLocalTunnelConfigPath:Ve});return}De.current?.click()},[ke,q]),Je=l.useCallback(ae=>{const Ve=ae.trim();L(Ve.length>0?Ve:null)},[]),Xe=l.useCallback(async()=>{if(b&&!_n(b)){B.error(ke);return}await q({managedLocalTunnelConfigPath:b})},[ke,b,q]),et=l.useCallback(async()=>{L(null),await q({managedLocalTunnelConfigPath:null})},[q]),at=l.useCallback(async ae=>{const Ve=ae.target.files?.[0];if(!Ve)return;const tt=Ve.name.trim();if(tt.length!==0){if(!_n(tt)){B.error(ke);return}L(tt),await q({managedLocalTunnelConfigPath:tt}),ae.target.value=""}},[ke,q]),lt=l.useCallback(async()=>{if(u(null),h(null),I==="managed-local"&&b&&!_n(b)){u(ke),B.error(ke);return}r("starting");try{let ae="",Ve="";if(I==="managed-remote"){if(!Pe){r("idle"),h(s("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst")),B.error(s("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst"));return}ae=Pe.hostname,Ve=(Y[Pe.id]||"").trim(),await q({tunnelMode:"managed-remote",managedRemoteTunnelPresets:E})}const tt=await jt("/api/openchamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:k,mode:I,...I==="managed-remote"&&Pe?{managedRemoteTunnelPresetId:Pe.id,managedRemoteTunnelPresetName:Pe.name}:{},...I==="managed-remote"&&ae?{managedRemoteTunnelHostname:ae}:{},...I==="managed-remote"&&Ve?{managedRemoteTunnelToken:Ve}:{},...I==="managed-local"&&b?{configPath:b}:{}})}),Ye=await tt.json();if(!tt.ok||!Ye.ok){if(I==="managed-remote"&&typeof Ye.error=="string"&&Ye.error.includes("Managed remote tunnel token is required")){r("idle"),h(s("settings.openchamber.tunnel.toast.managedRemoteTokenRequiredBeforeStarting")),B.error(s("settings.openchamber.tunnel.toast.addManagedRemoteTokenBeforeStarting"));return}r("error"),u(Ye.error||s("settings.openchamber.tunnel.toast.startFailed")),B.error(Ye.error||s("settings.openchamber.tunnel.toast.startFailed"));return}const yt=typeof Ye.url=="string"?Ye.url:"";if(!yt){r("error"),u(s("settings.openchamber.tunnel.toast.startedButNoPublicUrl")),B.error(s("settings.openchamber.tunnel.toast.startedButNoPublicUrl"));return}if(o({url:yt,connectUrl:typeof Ye.connectUrl=="string"?Ye.connectUrl:null,bootstrapExpiresAt:typeof Ye.bootstrapExpiresAt=="number"?Ye.bootstrapExpiresAt:null}),c(Ye.activeTunnelMode?Zs(Ye.activeTunnelMode):Ye.mode?Zs(Ye.mode):I),U(Array.isArray(Ye.activeSessions)?Ye.activeSessions:[]),Array.isArray(Ye.managedRemoteTunnelTokenPresetIds)&&Q(new Set(Ye.managedRemoteTunnelTokenPresetIds)),typeof Ye.localPort=="number"&&Me(Ye.localPort),typeof Ye.mode=="string"&&v(Zs(Ye.mode)),r("active"),Ye.replacedTunnel){const ze=typeof Ye.revokedBootstrapCount=="number"?Ye.revokedBootstrapCount:0,_e=typeof Ye.invalidatedSessionCount=="number"?Ye.invalidatedSessionCount:0;ze===1&&_e===1?B.warning(s("settings.openchamber.tunnel.toast.replacedTunnelSingleSingle")):ze===1?B.warning(s("settings.openchamber.tunnel.toast.replacedTunnelSingleManySessions",{invalidatedSessionCount:_e})):_e===1?B.warning(s("settings.openchamber.tunnel.toast.replacedTunnelManyLinksSingleSession",{revokedBootstrapCount:ze})):B.warning(s("settings.openchamber.tunnel.toast.replacedTunnelManyMany",{revokedBootstrapCount:ze,invalidatedSessionCount:_e}))}else B.success(s("settings.openchamber.tunnel.toast.linkReady"))}catch{r("error"),u(s("settings.openchamber.tunnel.toast.startFailed")),B.error(s("settings.openchamber.tunnel.toast.startFailed"))}},[ke,E,q,Pe,Y,s,k,I,b]),Ze=l.useCallback(async()=>{r("stopping");try{await jt("/api/openchamber/tunnel/stop",{method:"POST"});const ae=await jt("/api/openchamber/tunnel/status");if(ae.ok){const Ve=await ae.json();U(Array.isArray(Ve.activeSessions)?Ve.activeSessions:[]),Q(new Set(Array.isArray(Ve.managedRemoteTunnelTokenPresetIds)?Ve.managedRemoteTunnelTokenPresetIds:[])),Me(typeof Ve.localPort=="number"?Ve.localPort:null)}o(null),c(null),m(null),r("idle"),B.success(s("settings.openchamber.tunnel.toast.stopped"))}catch{r("error"),u(s("settings.openchamber.tunnel.toast.stopFailed")),B.error(s("settings.openchamber.tunnel.toast.stopFailed"))}},[s]),We=l.useCallback(async()=>{if(i?.connectUrl)try{await navigator.clipboard.writeText(i.connectUrl),x(!0),B.success(s("settings.openchamber.tunnel.toast.connectLinkCopied")),setTimeout(()=>x(!1),2e3)}catch{B.error(s("settings.openchamber.tunnel.toast.copyUrlFailed"))}},[s,i?.connectUrl]),pt=l.useCallback(async ae=>{const Ve=fa.find(tt=>tt.value===ae);Ve&&(ve(Ve.ms),await $(Ve.ms,ye))},[$,ye]),pe=l.useCallback(async ae=>{const Ve=xa.find(tt=>tt.value===ae);!Ve||Ve.ms===null||(be(Ve.ms),await $(Ie,Ve.ms))},[Ie,$]),st=l.useCallback(async ae=>{h(null),u(null),a!=="active"&&a!=="stopping"&&a!=="starting"&&r("idle"),await q({tunnelMode:ae,managedRemoteTunnelPresets:E})},[E,q,a]),nt=l.useCallback(async(ae,Ve)=>{try{await Pt({managedRemoteTunnelPresets:Ve})}catch{B.error(s("settings.openchamber.tunnel.toast.saveSelectedManagedRemoteFailed"))}},[s]),Ge=l.useCallback(ae=>{const Ve=E.find(tt=>tt.id===ae);Ve&&(T(Ve.id),h(null),nt(Ve,E))},[E,nt]),ft=l.useCallback(async()=>{const ae=se.trim(),Ve=Aa(oe),tt=we.trim();if(!ae){B.error(s("settings.openchamber.tunnel.toast.tunnelNameRequired"));return}if(!Ve){B.error(s("settings.openchamber.tunnel.toast.managedRemoteHostnameRequired"));return}if(!tt){B.error(s("settings.openchamber.tunnel.toast.managedRemoteTokenRequired"));return}if(E.some(ze=>ze.hostname===Ve)){B.error(s("settings.openchamber.tunnel.toast.hostnameAlreadyExists"));return}const Ye={id:Xx(),name:ae,hostname:Ve},yt=[...E,Ye];J(yt),T(Ye.id),Z(ze=>({...ze,[Ye.id]:!0})),F(ze=>({...ze,[Ye.id]:tt})),h(null),X(!1),me(""),xe(""),he(""),await q({tunnelMode:"managed-remote",managedRemoteTunnelPresets:yt,managedRemoteTunnelPresetTokens:{...Y,[Ye.id]:tt}}),await fe({presetId:Ye.id,presetName:Ye.name,hostname:Ye.hostname,token:tt}),B.success(s("settings.openchamber.tunnel.toast.managedRemoteSaved"))},[E,oe,se,we,fe,q,Y,s]),wt=l.useCallback(async ae=>{const Ve=E.find(_e=>_e.id===ae);if(!Ve)return;const tt=E.filter(_e=>_e.id!==Ve.id),Ye=tt[0]?.id||"",yt=H===Ve.id?Ye:H,ze=Object.fromEntries(Object.entries(Y).filter(([_e,ot])=>_e!==Ve.id&&ot.trim().length>0));J(tt),T(yt),Z(_e=>{const ot={..._e};return delete ot[Ve.id],ot}),F(_e=>{const ot={..._e};return delete ot[Ve.id],ot}),Q(_e=>{const ot=new Set(_e);return ot.delete(Ve.id),ot}),h(null),await q({managedRemoteTunnelPresets:tt,managedRemoteTunnelPresetTokens:ze}),B.success(s("settings.openchamber.tunnel.toast.managedRemoteRemoved"))},[E,q,H,Y,s]),Ct="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 a==="checking"?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":s("settings.openchamber.tunnel.state.loading")})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:s("settings.openchamber.tunnel.title")}),t.jsx("p",{className:"typography-meta mt-0 text-muted-foreground/70",children:s("settings.openchamber.tunnel.description")}),t.jsx("p",{className:"typography-meta mt-0 text-muted-foreground/60",children:s("settings.openchamber.tunnel.note.serverSideEnforced")}),t.jsx("p",{className:"typography-meta mt-0 text-muted-foreground/60",children:s("settings.openchamber.tunnel.note.connectLinksOneTime")})]}),Re.length>0&&t.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:t.jsxs("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)]/30 p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[t.jsx(M,{name:"information",className:"size-4 text-[var(--status-info)]"}),t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.section.redeemedAccessLinks")})]}),t.jsx("div",{className:"space-y-1",children:Re.map(ae=>{const Ve=ae.mode==="quick",tt=ae.mode==="managed-remote",Ye=Ve?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":tt?"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)]",yt=ae.isActive?Ve?"text-[var(--status-warning)]":tt?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",ze=s(Ve?"settings.openchamber.tunnel.badge.quick":tt?"settings.openchamber.tunnel.badge.remote":"settings.openchamber.tunnel.badge.local");return t.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:[t.jsx(M,{name:"checkbox-blank-circle-fill",className:ce("size-2.5 shrink-0",yt)}),t.jsx("span",{className:ce("typography-micro rounded border px-1.5 py-0.5 uppercase",Ye),children:ze}),t.jsx("span",{className:"typography-meta text-muted-foreground/80",children:s("settings.openchamber.tunnel.session.redeemedAt",{time:Qx(ae.createdAt,e)})}),t.jsx("span",{className:"typography-meta text-foreground",children:ae.isActive?s("settings.openchamber.tunnel.session.expiresIn",{remaining:ae.remainingTextForSession}):ae.inactiveLabel===s("settings.openchamber.tunnel.state.inactive")?s("settings.openchamber.tunnel.state.inactive"):s("settings.openchamber.tunnel.session.inactiveWithReason",{reason:ae.inactiveLabel})})]},ae.sessionId)})})]})}),a==="not-available"&&t.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:t.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-[var(--status-warning)]/30 bg-[var(--status-warning)]/5 p-3",children:[t.jsx(M,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"typography-meta font-medium text-foreground",children:s("settings.openchamber.tunnel.notAvailable.dependencyNotFound",{dependency:de.dependency})}),t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.openchamber.tunnel.notAvailable.installHint")}),t.jsx("code",{className:"typography-code block rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:de.installCommand})]})]})}),t.jsxs("section",{className:"space-y-4 px-2 pb-2 pt-0",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{"data-settings-item":"tunnel.provider",className:"space-y-1.5",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.field.provider")}),t.jsxs(Ft,{value:k,onValueChange:ae=>{O(ae)},disabled:w||a==="starting"||a==="stopping",children:[t.jsx(Lt,{className:"max-w-[16rem]",children:t.jsx(Kt,{placeholder:s("settings.openchamber.tunnel.field.providerPlaceholder"),children:Xl(k)})}),t.jsxs(Ot,{children:[z.length>0?z.map(ae=>t.jsx(ht,{value:ae.provider,children:t.jsx(Ho,{provider:ae.provider})},ae.provider)):t.jsx(ht,{value:"cloudflare",children:t.jsx(Ho,{provider:"cloudflare"})}),t.jsx(ht,{value:"__more-soon",disabled:!0,children:s("settings.openchamber.tunnel.option.moreProvidersSoon")})]})]})]}),t.jsxs("div",{"data-settings-item":"tunnel.type",className:"space-y-1.5",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.field.tunnelType")}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:le.map(ae=>t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(G,{variant:"chip",size:"xs","aria-pressed":I===ae.value,className:"!font-normal",onClick:()=>{st(ae.value)},disabled:w||a==="starting"||a==="stopping",children:n(ae.labelKey)})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:n(ae.tooltipKey)})]},ae.value))})]})]}),t.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:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label shrink-0 text-foreground",children:s("settings.openchamber.tunnel.field.connectLinkTtl")}),t.jsxs(Ft,{value:Lr(fa,Ie,"1800000"),onValueChange:ae=>{pt(ae)},disabled:D||w||a==="starting"||a==="stopping",children:[t.jsx(Lt,{className:"max-w-[11rem] min-w-0",children:t.jsx(Kt,{className:"truncate",children:Wo(fa,Ie,"1800000")})}),t.jsx(Ot,{children:fa.map(ae=>t.jsx(ht,{value:ae.value,children:ae.label},ae.value))})]})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"typography-ui-label shrink-0 text-foreground",children:s("settings.openchamber.tunnel.field.tunnelSessionTtl")}),t.jsxs(Ft,{value:Lr(xa,ye,"28800000"),onValueChange:ae=>{pe(ae)},disabled:D||w||a==="starting"||a==="stopping",children:[t.jsx(Lt,{className:"max-w-[11rem] min-w-0",children:t.jsx(Kt,{className:"truncate",children:Wo(xa,ye,"28800000")})}),t.jsx(Ot,{children:xa.map(ae=>t.jsx(ht,{value:ae.value,children:ae.label},ae.value))})]})]})]}),I==="quick"&&t.jsx("div",{className:"rounded-lg border border-[var(--status-warning)]/35 bg-[var(--status-warning)]/10 p-3",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:s("settings.openchamber.tunnel.option.mode.quick.tooltip")}),W&&t.jsx("p",{className:"typography-meta mt-1 text-[var(--status-warning)]",children:s("settings.openchamber.tunnel.warning.quickModeReliability")})]})]})}),I==="managed-remote"&&t.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 Oe=="number"&&t.jsx("div",{className:"rounded-md border border-[var(--status-info-border)] bg-[var(--status-info-background)]/35 px-2 py-1.5",children:t.jsxs("p",{className:"typography-meta text-[var(--status-info)]",children:[s("settings.openchamber.tunnel.note.cloudflareConnectorTarget")," ",t.jsxs("code",{children:["http://localhost:",Oe]})]})}),t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.section.savedManagedRemoteTunnels")}),t.jsxs(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>X(ae=>!ae),disabled:a==="starting"||a==="stopping"||w,children:[t.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),s("settings.common.actions.create")]})]}),E.length>0?t.jsx("div",{className:"overflow-hidden rounded-md border border-[var(--surface-subtle)]",children:E.map((ae,Ve)=>{const tt=Y[ae.id]||"",Ye=V.has(ae.id),yt=_[ae.id]??!1;return t.jsx("div",{className:ce(Ve<E.length-1&&"border-b border-[var(--surface-subtle)]"),children:t.jsxs(gn,{open:yt,onOpenChange:ze=>{Z(_e=>({..._e,[ae.id]:ze})),ze&&Ge(ae.id)},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2 px-3",children:[t.jsxs(hn,{type:"button",className:"group flex-1 justify-start gap-2 rounded-md px-0 py-1 pr-1 text-left hover:bg-[var(--interactive-hover)]",disabled:a==="starting"||a==="stopping"||w,children:[yt?t.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(M,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"typography-ui-label min-w-0 flex-1 truncate text-foreground",children:ae.name})]}),t.jsx(G,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-[var(--status-error)]","aria-label":s("settings.openchamber.tunnel.actions.removePresetAria",{name:ae.name}),onClick:()=>{wt(ae.id)},disabled:a==="starting"||a==="stopping"||w,children:t.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(fn,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-1 px-3 pb-2",children:[t.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[s("settings.openchamber.tunnel.field.hostnameLabel")," ",t.jsx("code",{children:ae.hostname})]}),t.jsx(it,{type:"password",value:tt,onChange:ze=>{const _e=ze.target.value;h(null),F(ot=>({...ot,[ae.id]:_e}))},onBlur:ze=>{const _e=ze.currentTarget.value.trim();_e&&fe({presetId:ae.id,presetName:ae.name,hostname:ae.hostname,token:_e})},placeholder:s(Ye?"settings.openchamber.tunnel.field.savedTokenAvailablePlaceholder":"settings.openchamber.tunnel.field.pasteTokenPlaceholder"),className:"h-7",disabled:a==="starting"||a==="stopping"}),t.jsx("div",{className:"flex items-center justify-end",children:t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",disabled:a==="starting"||a==="stopping"||tt.trim().length===0,onClick:()=>{fe({presetId:ae.id,presetName:ae.name,hostname:ae.hostname,token:tt})},children:s("settings.openchamber.tunnel.actions.saveToken")})})]})})]})},ae.id)})}):t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s("settings.openchamber.tunnel.empty.noManagedRemoteTunnels")}),ie&&t.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--surface-subtle)] p-2",children:[t.jsx(it,{value:se,onChange:ae=>me(ae.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetNamePlaceholder"),className:"h-7",disabled:w||a==="starting"||a==="stopping"}),t.jsx(it,{value:oe,onChange:ae=>xe(ae.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetHostnamePlaceholder"),className:"h-7",disabled:w||a==="starting"||a==="stopping"}),t.jsx(it,{type:"password",value:we,onChange:ae=>he(ae.target.value),placeholder:s("settings.openchamber.tunnel.field.newPresetTokenPlaceholder"),className:"h-7",disabled:w||a==="starting"||a==="stopping"}),typeof Oe=="number"&&t.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[s("settings.openchamber.tunnel.note.cloudflareConnectorTargetUse")," ",t.jsxs("code",{children:["http://localhost:",Oe]}),"."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ft()},disabled:w||a==="starting"||a==="stopping",children:s("settings.common.actions.saveChanges")}),t.jsx(G,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{X(!1),me(""),xe(""),he("")},disabled:w||a==="starting"||a==="stopping",children:s("settings.common.actions.cancel")})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("p",{className:"typography-meta text-muted-foreground/80",children:s("settings.openchamber.tunnel.note.tokensSavedPerTunnel")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground/70 hover:text-foreground","aria-label":s("settings.openchamber.tunnel.field.managedRemoteTokenInfoAria"),children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5"})})}),t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:s("settings.openchamber.tunnel.tooltip.tokensSavedPath")})]})]}),!Pe&&S&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:S})]}),I==="managed-local"&&t.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:t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.field.configurationFile")}),t.jsx("input",{ref:De,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:ae=>{at(ae)}}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(it,{value:b||"",onChange:ae=>{Je(ae.target.value)},onBlur:()=>{Xe()},placeholder:s("settings.openchamber.tunnel.field.configurationFilePlaceholder"),className:"h-7",disabled:a==="starting"||a==="stopping"||w}),t.jsx(G,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":s("settings.openchamber.tunnel.actions.browseConfigFileAria"),onClick:()=>{Fe()},disabled:a==="starting"||a==="stopping"||w,children:t.jsx(M,{name:"folder",className:"size-3.5"})}),b&&t.jsx(G,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":s("settings.openchamber.tunnel.actions.clearConfigFileAria"),onClick:()=>{et()},disabled:a==="starting"||a==="stopping"||w,children:t.jsx(M,{name:"close",className:"size-3.5"})})]}),t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:s(b?"settings.openchamber.tunnel.note.customConfigUsed":"settings.openchamber.tunnel.note.defaultConfigUsed")}),Ae&&t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:ke})]})}),!$e&&t.jsxs("div",{"data-settings-item":"tunnel.start",className:"space-y-6",children:[t.jsx("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)] p-3",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M,{name:"information",className:"mt-0.5 size-4 shrink-0 text-[var(--status-info)]"}),t.jsxs("div",{className:"space-y-1",children:[I==="managed-remote"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:s("settings.openchamber.tunnel.note.managedRemoteRequiresDomain")}),t.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:()=>{Ne(_x)},children:[s("settings.openchamber.tunnel.actions.openManagedRemoteDocs"),t.jsx(M,{name:"external-link",className:"size-3.5"})]})]}),I==="managed-local"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:s("settings.openchamber.tunnel.note.managedLocalUsesConfig")}),t.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:()=>{Ne(Hx)},children:[s("settings.openchamber.tunnel.actions.openManagedLocalDocs"),t.jsx(M,{name:"external-link",className:"size-3.5"})]})]}),t.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:s("settings.openchamber.tunnel.note.startModeAndGenerateLink",{mode:n(ur.find(ae=>ae.value===I)?.labelKey??"settings.openchamber.tunnel.option.mode.quick.label")})})]})]})}),I==="managed-remote"&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.tunnel.field.managedRemoteTunnelToConnect")}),t.jsxs(Ft,{value:H||(E[0]?.id??""),onValueChange:ae=>{Ge(ae)},disabled:w||a==="starting"||a==="stopping"||E.length<=1,children:[t.jsx(Lt,{children:t.jsx(Kt,{placeholder:s("settings.openchamber.tunnel.field.selectSavedTunnelPlaceholder"),children:Pe?.name})}),t.jsx(Ot,{fitContent:!0,children:E.map(ae=>t.jsx(ht,{value:ae.id,children:ae.name},ae.id))})]})]}),Be&&t.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:s("settings.openchamber.tunnel.warning.replacesActiveTunnel")})]})}),t.jsx(G,{size:"sm",variant:"outline",onClick:lt,disabled:a==="starting"||w||I==="managed-remote"&&!Pe||I==="managed-local"&&Ae,className:ce(Ct,a==="starting"&&"opacity-70"),children:a==="starting"?t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"})," ",s("settings.openchamber.tunnel.actions.startingTunnel")]}):s("settings.openchamber.tunnel.actions.startTunnel")})]})]}),$e&&i&&t.jsxs("section",{"data-settings-item":"tunnel.start",className:"space-y-4 px-2 pb-2 pt-0",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--status-success)]"}),t.jsx("p",{className:"typography-meta font-medium text-foreground",children:s("settings.openchamber.tunnel.state.tunnelReady")})]}),t.jsxs("div",{children:[t.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:s("settings.openchamber.tunnel.field.publicUrlHint")}),t.jsx("code",{className:"typography-code block truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:i.url})]}),Le&&i.connectUrl&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:s("settings.openchamber.tunnel.field.connectLink")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"typography-code flex-1 truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:i.connectUrl}),t.jsxs(G,{size:"sm",variant:"ghost",onClick:We,className:"shrink-0 gap-1.5",children:[g?t.jsx(M,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):t.jsx(M,{name:"file-copy",className:"size-3.5"}),s(g?"settings.openchamber.tunnel.actions.copied":"settings.common.actions.copyAll")]})]}),t.jsxs("p",{className:"typography-meta mt-1 text-muted-foreground/70",children:[s("settings.openchamber.tunnel.field.expires"),": ",i.bootstrapExpiresAt?te:s("settings.openchamber.tunnel.state.never")]})]}),t.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border/50 bg-[var(--surface-elevated)] p-4",children:[f?t.jsx("img",{src:f,alt:s("settings.openchamber.tunnel.field.connectQrAlt"),className:"size-48"}):t.jsx("div",{className:"size-48 rounded bg-muted/30"}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:s("settings.openchamber.tunnel.note.scanQrToConnect")})]})]})]}),t.jsx("div",{className:"pt-1",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(G,{size:"sm",variant:"outline",onClick:lt,disabled:a==="stopping"||w||I==="managed-local"&&Ae,className:Ct,children:[t.jsx(M,{name:"restart",className:"size-3.5"}),s("settings.openchamber.tunnel.actions.newConnectLink")]}),t.jsx(G,{size:"sm",variant:"ghost",onClick:Ze,disabled:a==="stopping"||w,className:"gap-2 text-[var(--status-error)]",children:a==="stopping"?t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"})," ",s("settings.openchamber.tunnel.actions.stopping")]}):s("settings.openchamber.tunnel.actions.stopTunnel")})]})})]}),a==="error"&&p&&t.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[t.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:p}),t.jsx(G,{size:"sm",variant:"ghost",onClick:lt,children:s("settings.openchamber.tunnel.actions.retry")})]})]})},Zl=()=>{const{t:s}=dt(),[e,n]=je.useState(""),[a,r]=je.useState(!0),[i,o]=je.useState(!1),d=Ke(u=>u.showOpenCodeUpdateNotifications),c=Ke(u=>u.setShowOpenCodeUpdateNotifications);je.useEffect(()=>{let u=!1;return(async()=>{try{const S=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!S.ok)return;const h=await S.json().catch(()=>null);if(u||!h)return;const g=typeof h.opencodeBinary=="string"?h.opencodeBinary.trim():"";n(g)}catch{}finally{u||r(!1)}})(),()=>{u=!0}},[]);const f=je.useCallback(async()=>{if(!(typeof window>"u")&&fs())try{const u=await Sl();u.success&&u.path&&u.path.trim().length>0&&n(u.path.trim())}catch{}},[]),m=je.useCallback(async()=>{o(!0);try{await Pt({opencodeBinary:e.trim()}),await In({message:s("settings.openchamber.opencodeCli.actions.restartingOpenCode"),mode:"projects",scopes:["all"]})}finally{o(!1)}},[s,e]),p=je.useCallback(u=>{c(u),Pt({showOpenCodeUpdateNotifications:u})},[c]);return t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.opencodeCli.title")}),t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),t.jsxs(Et,{sideOffset:8,className:"max-w-xs",children:[s("settings.openchamber.opencodeCli.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs",children:"opencode"}),s("settings.openchamber.opencodeCli.tooltipSuffix")]})]})]})}),t.jsxs("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:[t.jsxs("div",{"data-settings-item":"sessions.opencode-binary",className:"flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-3",children:[t.jsx("div",{className:"flex min-w-0 flex-col shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.opencodeCli.field.binaryPath")})}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2 sm:w-[20rem]",children:[t.jsx(it,{value:e,onChange:u=>n(u.target.value),placeholder:s("settings.openchamber.opencodeCli.field.binaryPathPlaceholder"),disabled:a||i,className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(G,{type:"button",variant:"outline",size:"xs",onClick:f,disabled:a||i||!fs(),className:"h-7 w-7 p-0","aria-label":s("settings.openchamber.opencodeCli.actions.browseAria"),title:s("settings.openchamber.opencodeCli.actions.browse"),children:t.jsx(M,{name:"folder",className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"py-1.5",children:t.jsxs("div",{className:"typography-micro text-muted-foreground/70",children:[s("settings.openchamber.opencodeCli.tipPrefix")," ",t.jsx("span",{className:"font-mono",children:"OPENCODE_BINARY"})," ",s("settings.openchamber.opencodeCli.tipMiddle")," ",t.jsx("span",{className:"font-mono",children:"~/.config/openchamber/settings.json"}),"."]})}),t.jsxs("label",{"data-settings-item":"sessions.opencode-update-notifications",className:"flex cursor-pointer items-center gap-2 py-1.5",children:[t.jsx(It,{checked:d,onChange:p,ariaLabel:s("settings.openchamber.opencodeCli.field.showUpdateNotificationsAria")}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.opencodeCli.field.showUpdateNotifications")})]}),t.jsx("div",{className:"flex justify-start py-1.5",children:t.jsx(G,{type:"button",size:"xs",onClick:m,disabled:a||i,className:"shrink-0 !font-normal",children:s(i?"settings.common.actions.saving":"settings.openchamber.opencodeCli.actions.saveAndReload")})})]})]})},ec=()=>{const{t:s}=dt(),e=fs()&&ea(),[n,a]=je.useState(!1),[r,i]=je.useState(!1),[o,d]=je.useState(""),[c,f]=je.useState(""),[m,p]=je.useState(!1),[u,S]=je.useState(null),[h,g]=je.useState(!0),[x,D]=je.useState(!1),[N,w]=je.useState(!1),[A,k]=je.useState(!1),[j,y]=je.useState(!1),[P,z]=je.useState(null),[R,I]=je.useState(null);je.useEffect(()=>{if(!e){g(!1);return}let F=!1;return(async()=>{try{const V=await jt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!V.ok)throw new Error(s("settings.openchamber.desktopNetwork.error.loadFailed"));const Q=await V.json().catch(()=>null);if(F)return;const ie=Q?.desktopLanAccessEnabled===!0,X=typeof Q?.desktopUiPassword=="string"?Q.desktopUiPassword:"";a(ie),i(ie),d(X),f(X),p(Q?.desktopLanAccessActive===!0),S(typeof Q?.desktopLanAccessBlockedReason=="string"?Q.desktopLanAccessBlockedReason:null),z(null)}catch(V){F||z(V instanceof Error?V.message:s("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{F||g(!1)}})(),()=>{F=!0}},[e,s]),je.useEffect(()=>{if(!e){w(!1);return}let F=!1;return(async()=>{const V=await Bm();F||(w(V?.supported===!0),k(V?.enabled===!0))})(),()=>{F=!0}},[e]),je.useEffect(()=>{if(!e||!r){I(null);return}let F=!1;return(async()=>{const V=await Vm();F||I(V)})(),()=>{F=!0}},[r,e]);const v=r!==n||c!==o,b=je.useMemo(()=>{if(typeof window>"u")return null;const V=Xn()||window.location.href;let Q=0;try{Q=Number(new URL(V).port)}catch{Q=Number(window.location.port)}return Number.isFinite(Q)&&Q>0?Q:null},[]),L=r&&m&&R&&b?`http://${R}:${b}`:null,E=r&&!c.trim(),J=n&&!m&&u==="missing-password",_=h||x||!v||E,Z=je.useCallback(()=>{i(F=>!F)},[]),H=je.useCallback(F=>{f(F),F.trim()||i(!1)},[]),T=je.useCallback(async()=>{if(!N||j)return;const F=!A;k(F),y(!0),z(null);try{const V=await _m(F);if(!V?.supported)throw new Error(s("settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported"));k(V.enabled)}catch(V){k(!F),z(V instanceof Error?V.message:s("settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed"))}finally{y(!1)}},[j,A,N,s]),Y=je.useCallback(async()=>{if(v){D(!0),z(null);try{if(!(await jt("/api/config/settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({desktopLanAccessEnabled:r,desktopUiPassword:c})})).ok)throw new Error(s("settings.openchamber.desktopNetwork.error.saveFailed"));if(a(r),d(c),!await Hm())throw new Error(s("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(F){z(F instanceof Error?F.message:s("settings.openchamber.desktopNetwork.error.saveFailed")),D(!1)}}},[c,r,v,s]);return e?t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"mb-1 px-1",children:t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:s("settings.openchamber.desktopNetwork.title")})}),t.jsxs("section",{className:"space-y-2 px-2 pb-2 pt-0",children:[N?t.jsxs("div",{"data-settings-item":"sessions.desktop-launch-at-login",className:"group flex cursor-pointer items-start gap-2 py-1.5",role:"button",tabIndex:0,onClick:T,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),T())},children:[t.jsx(It,{checked:A,onChange:T,ariaLabel:s("settings.openchamber.desktopNetwork.field.launchAtLoginAria"),disabled:j}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.desktopNetwork.field.launchAtLogin")}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:s("settings.openchamber.desktopNetwork.field.launchAtLoginDescription")})]})]}):null,t.jsxs("div",{"data-settings-item":"sessions.desktop-ui-password",className:"space-y-1 py-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground",htmlFor:"desktop-ui-password",children:s("settings.openchamber.desktopPassword.field.password")}),t.jsx(it,{id:"desktop-ui-password",type:"password",className:"h-7 max-w-sm",value:c,onChange:F=>H(F.target.value),placeholder:s("settings.openchamber.desktopPassword.field.passwordPlaceholder"),disabled:h||x,required:r,"aria-invalid":E}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:s("settings.openchamber.desktopPassword.field.passwordDescription")})]}),t.jsxs("div",{"data-settings-item":"sessions.desktop-lan-access",className:"group flex cursor-pointer items-start gap-2 py-1.5",role:"button",tabIndex:0,onClick:Z,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),Z())},children:[t.jsx(It,{checked:r,onChange:Z,ariaLabel:s("settings.openchamber.desktopNetwork.field.allowLanAccessAria"),disabled:h||x}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:s("settings.openchamber.desktopNetwork.field.allowLanAccess")}),t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:s("settings.openchamber.desktopNetwork.field.allowLanAccessDescription")}),t.jsx("div",{className:"typography-micro text-[var(--status-warning)]/85",children:s("settings.openchamber.desktopNetwork.field.warning")}),E||J?t.jsx("div",{className:"typography-micro text-[var(--status-warning)]/85",children:s("settings.openchamber.desktopNetwork.field.passwordRequiredWarning")}):null]})]}),P?t.jsx("div",{className:"px-2 typography-micro text-[var(--status-error)]",children:P}):null,L?t.jsxs("div",{className:"px-2 typography-micro text-muted-foreground/80",children:[s(v&&!n?"settings.openchamber.desktopNetwork.hint.openAfterRestart":"settings.openchamber.desktopNetwork.hint.openNow"),t.jsx("span",{className:"font-mono text-foreground",children:L})]}):null,t.jsx("div",{className:"flex justify-start py-1.5",children:t.jsx(G,{type:"button",size:"xs",onClick:Y,disabled:_,className:"shrink-0 !font-normal",children:s(x?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")})})]})]}):null},ey=new Set(["shift","control","alt","meta"]),ty=s=>{if(ey.has(s.key.toLowerCase()))return null;const e=[];(s.metaKey||s.ctrlKey)&&e.push("mod"),s.shiftKey&&e.push("shift"),s.altKey&&e.push("alt");const n=vm(s.key);return n?(e.push(n),wn(e.join("+"))):null},sy=()=>{const s=rt.c(61),{t:e}=dt();let n;s[0]!==e?(n=oe=>e(oe),s[0]=e,s[1]=n):n=s[1];const a=n,r=Ke(ny),i=Ke(ay),o=Ke(ry),d=Ke(iy);let c;s[2]===Symbol.for("react.memo_cache_sentinel")?(c=ym(),s[2]=c):c=s[2];const f=c;let m;s[3]!==a?(m=(oe,xe)=>{const we=`settings.openchamber.keyboardShortcuts.action.${oe}.label`,he=a(we);return he===we?xe:he},s[3]=a,s[4]=m):m=s[4];const p=m,[u,S]=l.useState(null);let h;s[5]===Symbol.for("react.memo_cache_sentinel")?(h={},s[5]=h):h=s[5];const[g,x]=l.useState(h),[D,N]=l.useState(""),[w,A]=l.useState(""),[k,j]=l.useState(null),y=oy;let P;s[6]!==r?(P=(oe,xe)=>{const we=wn(xe);for(const he of f){if(he.id===oe)continue;const Ie=fi(he.id,r);if(wn(Ie)===we)return he.id}return null},s[6]=r,s[7]=P):P=s[7];const z=P;let R;s[8]!==z||s[9]!==i||s[10]!==r||s[11]!==e?(R=(oe,xe)=>{const we=wn(xe),he=z(oe,we);if(he){j({actionId:oe,combo:we,conflictActionId:he}),N("");return}const Ie={...r,[oe]:we};i(oe,we),y(Ie),j(null),N(""),A(xi(we)?e("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut"):""),x(ve=>{const ye={...ve};return delete ye[oe],ye})},s[8]=z,s[9]=i,s[10]=r,s[11]=e,s[12]=R):R=s[12];const I=R;let v;s[13]!==k||s[14]!==i||s[15]!==r||s[16]!==e?(v=()=>{if(!k)return;const oe={...r,[k.conflictActionId]:yi,[k.actionId]:k.combo};i(k.conflictActionId,yi),i(k.actionId,k.combo),y(oe),j(null),N(""),A(xi(k.combo)?e("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut"):""),x(xe=>{const we={...xe};return delete we[k.actionId],we})},s[13]=k,s[14]=i,s[15]=r,s[16]=e,s[17]=v):v=s[17];const b=v;let L;s[18]!==o||s[19]!==r?(L=oe=>{const xe={...r};delete xe[oe],o(oe),y(xe),x(we=>{const he={...we};return delete he[oe],he}),j(null),N(""),A("")},s[18]=o,s[19]=r,s[20]=L):L=s[20];const E=L;let J;s[21]!==e?(J=e("settings.openchamber.keyboardShortcuts.title"),s[21]=e,s[22]=J):J=s[22];let _;s[23]!==J?(_=t.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:J}),s[23]=J,s[24]=_):_=s[24];let Z;s[25]!==d?(Z=()=>{d(),y({}),x({}),j(null),N(""),A("")},s[25]=d,s[26]=Z):Z=s[26];let H;s[27]!==e?(H=e("settings.openchamber.keyboardShortcuts.actions.resetAll"),s[27]=e,s[28]=H):H=s[28];let T;s[29]!==Z||s[30]!==H?(T=t.jsx(G,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Z,children:H}),s[29]=Z,s[30]=H,s[31]=T):T=s[31];let Y;s[32]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx(At,{asChild:!0,children:t.jsx(M,{name:"information",className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-help"})}),s[32]=Y):Y=s[32];let F;s[33]!==e?(F=e("settings.openchamber.keyboardShortcuts.tooltip"),s[33]=e,s[34]=F):F=s[34];let V;s[35]!==F?(V=t.jsxs(Dt,{children:[Y,t.jsx(Et,{sideOffset:8,className:"max-w-xs",children:F})]}),s[35]=F,s[36]=V):V=s[36];let Q;s[37]!==T||s[38]!==V||s[39]!==_?(Q=t.jsx("div",{className:"mb-1 px-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[_,T,V]})}),s[37]=T,s[38]=V,s[39]=_,s[40]=Q):Q=s[40];let ie;s[41]!==b||s[42]!==D||s[43]!==k||s[44]!==e||s[45]!==w?(ie=(D||w||k)&&t.jsxs("div",{className:"mb-2 space-y-2 px-1",children:[k&&t.jsxs("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[t.jsx("span",{className:"typography-meta text-foreground",children:e("settings.openchamber.keyboardShortcuts.overwritePrompt")}),t.jsxs("div",{className:"flex gap-2 shrink-0",children:[t.jsx(G,{type:"button",size:"xs",className:"!font-normal",onClick:b,children:e("settings.openchamber.keyboardShortcuts.actions.overwrite")}),t.jsx(G,{type:"button",size:"xs",className:"!font-normal",variant:"ghost",onClick:()=>j(null),children:e("settings.common.actions.cancel")})]})]}),D&&t.jsx("div",{className:"rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground",children:D}),w&&t.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground",children:w})]}),s[41]=b,s[42]=D,s[43]=k,s[44]=e,s[45]=w,s[46]=ie):ie=s[46];let X;s[47]!==p||s[48]!==u||s[49]!==g||s[50]!==E||s[51]!==I||s[52]!==r||s[53]!==e?(X=f.map((oe,xe)=>{const we=fi(oe.id,r),he=g[oe.id],Ie=he??we,ve=typeof he=="string"&&wn(he)!==wn(we);return t.jsxs("div",{className:ce("flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:gap-8",xe>0&&"border-t border-[var(--surface-subtle)]"),children:[t.jsx("div",{className:"flex min-w-0 flex-col sm:w-56 shrink-0",children:t.jsx("span",{className:"typography-ui-label text-foreground",children:p(oe.id,oe.label)})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial",children:[t.jsx(it,{readOnly:!0,value:u===oe.id?e("settings.openchamber.keyboardShortcuts.field.pressKeys"):bm(Ie),onFocus:()=>{S(oe.id),N("")},onBlur:()=>{u===oe.id&&S(null)},onKeyDown:ye=>{if(ye.preventDefault(),ye.stopPropagation(),ye.key==="Escape"){S(null);return}const be=ty(ye);be&&(x(te=>({...te,[oe.id]:be})),S(null),j(null),N(""))},className:"h-7 w-40 min-w-0 typography-ui-label text-center"}),t.jsx(G,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>{const ye=g[oe.id];if(!ye){N(e("settings.openchamber.keyboardShortcuts.error.captureFirst"));return}I(oe.id,ye)},disabled:!ve,children:e("settings.common.actions.saveChanges")}),t.jsx(G,{type:"button",size:"xs",className:"!font-normal",variant:"ghost",onClick:()=>E(oe.id),children:e("settings.common.actions.reset")})]})]},oe.id)}),s[47]=p,s[48]=u,s[49]=g,s[50]=E,s[51]=I,s[52]=r,s[53]=e,s[54]=X):X=s[54];let se;s[55]!==X?(se=t.jsx("section",{className:"px-2 pb-2 pt-0 space-y-0.5",children:X}),s[55]=X,s[56]=se):se=s[56];let me;return s[57]!==Q||s[58]!==ie||s[59]!==se?(me=t.jsxs("div",{"data-settings-item":"shortcuts.keyboard-shortcuts",className:"mb-8",children:[Q,ie,se]}),s[57]=Q,s[58]=ie,s[59]=se,s[60]=me):me=s[60],me};function ny(s){return s.shortcutOverrides}function ay(s){return s.setShortcutOverride}function ry(s){return s.clearShortcutOverride}function iy(s){return s.resetAllShortcutOverrides}function oy(s){Pt({shortcutOverrides:s})}const tc=()=>{const s=rt.c(2),[e,n]=l.useState(0);let a,r;return s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>Wm(()=>n(yy)),r=[],s[0]=a,s[1]=r):(a=s[0],r=s[1]),l.useEffect(a,r),e},ly=s=>{const e=rt.c(20),{section:n}=s,{isMobile:a}=Cs();tc();let r;e[0]!==a?(r=a&&mn(),e[0]=a,e[1]=r):r=e[1];const i=r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=gs(),e[2]=o):o=e[2];const d=o;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=fs()&&ea(),e[3]=c):c=e[3];const f=c;if(!n){let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Gr,{}),e[4]=h):h=e[4];let g,x,D;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Ql,{})}),x=f&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(ec,{})}),D=!d&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Zl,{})}),e[5]=g,e[6]=x,e[7]=D):(g=e[5],x=e[6],D=e[7]);let N;e[8]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Gl,{})}),e[8]=N):N=e[8];let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Jl,{})}),e[9]=w):w=e[9];let A;e[10]!==i?(A=i&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Il,{})}),e[10]=i,e[11]=A):A=e[11];let k;return e[12]!==A?(k=t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsxs("div",{className:"openchamber-page-body mx-auto max-w-3xl space-y-3 p-3 sm:space-y-6 sm:p-6 sm:pt-8",children:[h,g,x,D,N,w,A]})}),e[12]=A,e[13]=k):k=e[13],k}let m;e[14]!==n?(m=()=>{switch(n){case"visual":return t.jsx(dy,{});case"chat":return t.jsx(my,{});case"sessions":return t.jsx(uy,{});case"shortcuts":return t.jsx(cy,{});case"git":return t.jsx(py,{});case"github":return t.jsx(gy,{});case"notifications":return t.jsx(hy,{});case"voice":return t.jsx(fy,{});case"tunnel":return t.jsx(xy,{});default:return null}},e[14]=n,e[15]=m):m=e[15];const p=m;let u;e[16]!==p?(u=p(),e[16]=p,e[17]=u):u=e[17];let S;return e[18]!==u?(S=t.jsx(Jt,{outerClassName:"h-full",className:"w-full",children:t.jsx("div",{className:"openchamber-page-body mx-auto max-w-3xl space-y-6 p-3 sm:p-6 sm:pt-8",children:u})}),e[18]=u,e[19]=S):S=e[19],S},cy=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(sy,{}),s[0]=e):e=s[0],e},dy=()=>{const s=rt.c(3);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=gs(),s[0]=e):e=s[0];const n=e;let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=n?[]:["weekStart"],s[1]=a):a=s[1];let r;return s[2]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Gr,{visibleSettings:["theme","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat",...a,"fontSize","terminalFontSize","fileEditorKeymap","spacing","inputBarOffset","expandedEditorToolbar",...n?[]:["terminalQuickKeys"],"reportUsage"]}),s[2]=r):r=s[2],r},my=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Gr,{visibleSettings:["chatRenderMode","messageTransport","activityRenderMode","userMessageRendering","mermaidRendering","reasoning","showToolFileIcons","showTurnChangedFiles","expandedTools","collapsibleUserMessages","stickyUserHeader","wideChatLayout","splitAssistantMessageActions","diffLayout","dotfiles","fileViewerPreview","queueMode","persistDraft","inputSpellcheck"]}),s[0]=e):e=s[0],e},uy=()=>{const s=rt.c(7);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=gs(),s[0]=e):e=s[0];const n=e;tc();let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=fs()&&ea(),s[1]=a):a=s[1];const r=a;let i,o,d;s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Ql,{}),o=r&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(ec,{})}),d=!n&&t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Zl,{})}),s[2]=i,s[3]=o,s[4]=d):(i=s[2],o=s[3],d=s[4]);let c;s[5]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Gl,{})}),s[5]=c):c=s[5];let f;return s[6]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsxs("div",{className:"space-y-6",children:[i,o,d,c,t.jsx("div",{className:"border-t border-border/40 pt-6",children:t.jsx(Jl,{})})]}),s[6]=f):f=s[6],f},py=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"space-y-6",children:t.jsx(Hl,{})}),s[0]=e):e=s[0],e},gy=()=>{const s=rt.c(1);if(gs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Wl,{}),s[0]=e):e=s[0],e},hy=()=>{const s=rt.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(zx,{}),s[0]=e):e=s[0],e},fy=()=>{const s=rt.c(1);if(gs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Bx,{}),s[0]=e):e=s[0],e},xy=()=>{const s=rt.c(1);if(gs())return null;let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Zx,{}),s[0]=e):e=s[0],e};function yy(s){return s+1}const sc=[{slug:"home",title:"Settings",group:"general",kind:"single",description:"Search and jump to common pages.",keywords:["search","settings"]},{slug:"projects",title:"Projects",group:"projects",kind:"split",keywords:["project","projects","worktree","worktrees","repo","repository","directory"]},{slug:"remote-instances",title:"Remote Instances",group:"projects",kind:"single",keywords:["ssh","remote","instances","tunnels","forwarding","connection"],isAvailable:s=>!s.isVSCode},{slug:"providers",title:"Providers",group:"opencode",kind:"split",keywords:["provider","providers","models","model","api key","api keys","openai","anthropic","ollama","credentials"]},{slug:"usage",title:"Usage",group:"usage",kind:"split",keywords:["quota","billing","tokens","usage","limits"]},{slug:"agents",title:"Agents",group:"opencode",kind:"split",keywords:["agent","agents","prompts","tools","permissions"]},{slug:"behavior",title:"Behavior",group:"opencode",kind:"single",keywords:["behavior","agents.md","system prompt","global rules","instructions","override"]},{slug:"commands",title:"Commands",group:"opencode",kind:"split",keywords:["command","commands","slash","macros","automation"]},{slug:"mcp",title:"MCP",group:"opencode",kind:"split",keywords:["mcp","model context protocol","servers","tools","remote","stdio"]},{slug:"plugins",title:"Plugins",group:"opencode",kind:"split",keywords:["plugin","plugins","extensions","addons","npm","opencode-wakatime"]},{slug:"skills.installed",title:"Skills",group:"skills",kind:"split",keywords:["skill","skills","instructions","install","catalog"]},{slug:"skills.catalog",title:"Skills Catalog",group:"skills",kind:"single",keywords:["install","catalog","external","repository","skills catalog"]},{slug:"git",title:"Git",group:"git",kind:"single",keywords:["git","github","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji","oauth","prs","issues"],isAvailable:s=>!s.isVSCode},{slug:"appearance",title:"Appearance",group:"appearance",kind:"single",keywords:["theme","font","spacing","padding","corner radius","radius","input bar","keyboard","viewport","mobile","terminal","pwa","install name","app shortcuts"]},{slug:"chat",title:"Chat",group:"general",kind:"single",keywords:["tools","diff","reasoning","dotfiles","draft","queue","output","copy","image","split messages","message actions"]},{slug:"shortcuts",title:"Shortcuts",group:"general",kind:"single",keywords:["keyboard","hotkeys","shortcuts","bindings"],isAvailable:s=>!s.isVSCode},{slug:"sessions",title:"Sessions",group:"general",kind:"single",keywords:["defaults","default agent","default model","retention","memory","limits","zen"]},{slug:"magic-prompts",title:"Magic Prompts",group:"general",kind:"split",keywords:["prompts","templates","git","github","review","commit","pull request"],isAvailable:s=>!s.isVSCode},{slug:"snippets",title:"Snippets",group:"general",kind:"split",keywords:["prompt","templates","multi-run","strategy","approach"]},{slug:"notifications",title:"Notifications",group:"general",kind:"single",keywords:["alerts","native","summary","summarization"]},{slug:"voice",title:"Voice",group:"advanced",kind:"single",keywords:["tts","speech","voice"],isAvailable:s=>!s.isVSCode},{slug:"tunnel",title:"Remote Tunnel",group:"advanced",kind:"single",keywords:["tunnel","cloudflare","qr","remote","mobile","share"],isAvailable:s=>!s.isVSCode},{slug:"about",title:"About",group:"advanced",kind:"single",keywords:["about","version","updates","release","changelog"],isAvailable:s=>s.isMobile}],by={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function Pn(s){const e=s.trim().toLowerCase();return sc.find(n=>n.slug===e)??null}function Jr(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=by[e];if(n)return n;const a=Pn(e);return a?a.slug:"home"}const vy=[{id:"appearance.language",page:"appearance",titleKey:"settings.appearance.language.label",descriptionKey:"settings.appearance.language.description",keywords:["locale","translation","ui language"]},{id:"appearance.time-format",page:"appearance",titleKey:"settings.openchamber.visual.field.timeFormat",keywords:["clock","12h","24h"]},{id:"appearance.week-start",page:"appearance",titleKey:"settings.openchamber.visual.field.weekStartsOn",keywords:["calendar","monday","sunday"],isAvailable:s=>!s.isVSCode},{id:"appearance.light-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.lightTheme",keywords:["theme","color","light mode"],isAvailable:s=>!s.isVSCode},{id:"appearance.dark-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.darkTheme",keywords:["theme","color","dark mode"],isAvailable:s=>!s.isVSCode},{id:"appearance.window-transparency",page:"appearance",titleKey:"settings.openchamber.visual.field.macVibrancy",descriptionKey:"settings.openchamber.visual.field.macVibrancyHint",keywords:["transparent","transparency","vibrancy","blur","macos","opaque"],isAvailable:s=>s.isDesktopLocalOrigin},{id:"appearance.pwa-install-name",page:"appearance",titleKey:"settings.openchamber.visual.field.installAppName",descriptionKey:"settings.openchamber.visual.field.installAppNameHint",keywords:["pwa","installed app"],isAvailable:s=>s.isWeb&&!s.isDesktop&&!s.isVSCode},{id:"appearance.pwa-orientation",page:"appearance",titleKey:"settings.openchamber.visual.field.installOrientation",descriptionKey:"settings.openchamber.visual.field.installOrientationHint",keywords:["pwa","portrait","landscape"],isAvailable:s=>s.isWeb&&!s.isDesktop&&!s.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:s=>s.isMobile&&s.isWeb&&!s.isDesktop&&!s.isVSCode},{id:"appearance.interface-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.interfaceFontSize",keywords:["font","text size","ui scale"],isAvailable:s=>!s.isMobile},{id:"appearance.terminal-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalFontSize",keywords:["terminal","font","text size"]},{id:"appearance.spacing-density",page:"appearance",titleKey:"settings.openchamber.visual.field.spacingDensity",keywords:["density","compact","comfortable","spacing"]},{id:"appearance.input-bar-offset",page:"appearance",titleKey:"settings.openchamber.visual.field.inputBarOffset",descriptionKey:"settings.openchamber.visual.field.inputBarOffsetTooltip",keywords:["input","home bar","offset"]},{id:"appearance.expanded-editor-toolbar",page:"appearance",titleKey:"settings.openchamber.visual.field.expandedEditorToolbar",keywords:["editor","toolbar","tabs","docked","files"]},{id:"appearance.file-editor-keymap",page:"appearance",titleKey:"settings.openchamber.visual.field.fileEditorKeymap",keywords:["editor","vim","keymap"]},{id:"appearance.terminal-quick-keys",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalQuickKeys",descriptionKey:"settings.openchamber.visual.field.terminalQuickKeysTooltip",keywords:["terminal","keyboard","esc","ctrl","arrows"],isAvailable:s=>!s.isMobile&&!s.isVSCode},{id:"appearance.usage-reports",page:"appearance",titleKey:"settings.openchamber.visual.field.sendAnonymousUsageReports",descriptionKey:"settings.openchamber.visual.field.sendAnonymousUsageReportsHint",keywords:["telemetry","analytics"]},{id:"chat.render-mode",page:"chat",titleKey:"settings.openchamber.visual.section.chatRenderMode",keywords:["messages","conversation","rendering"]},{id:"chat.message-transport",page:"chat",titleKey:"settings.openchamber.visual.section.messageStreamTransport",keywords:["streaming","sse","websocket"]},{id:"chat.reasoning-traces",page:"chat",titleKey:"settings.openchamber.visual.field.showReasoningTraces",keywords:["thinking","reasoning"]},{id:"chat.sticky-user-header",page:"chat",titleKey:"settings.openchamber.visual.field.stickyUserHeader",keywords:["messages","header"]},{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.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.tool-file-icons",page:"chat",titleKey:"settings.openchamber.visual.field.showToolFileIcons",keywords:["tools","files","icons"]},{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:s=>!s.isVSCode},{id:"chat.queue-mode",page:"chat",titleKey:"settings.openchamber.visual.field.queueMessagesByDefault",descriptionKey:"settings.openchamber.visual.field.queueMessagesByDefaultTooltip",keywords:["queue","enter","send"]},{id:"chat.persist-drafts",page:"chat",titleKey:"settings.openchamber.visual.field.persistDraftMessages",keywords:["draft","message"]},{id:"chat.spellcheck",page:"chat",titleKey:"settings.openchamber.visual.field.enableSpellcheckInTextInputs",keywords:["spelling","input"],isAvailable:s=>!s.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.auto-cleanup",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.enableAutoCleanup",descriptionKey:"settings.openchamber.sessionRetention.tooltip",keywords:["retention","archive","delete"]},{id:"sessions.retention-period",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.retentionPeriod",keywords:["days","cleanup","retention"]},{id:"sessions.retention-action",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.whenSessionsExpire",keywords:["archive","delete","expire"]},{id:"sessions.desktop-launch-at-login",page:"sessions",titleKey:"settings.openchamber.desktopNetwork.field.launchAtLogin",descriptionKey:"settings.openchamber.desktopNetwork.field.launchAtLoginDescription",keywords:["desktop","startup","login"],isAvailable:s=>s.isDesktopLocalOrigin},{id:"sessions.desktop-ui-password",page:"sessions",titleKey:"settings.openchamber.desktopPassword.field.password",descriptionKey:"settings.openchamber.desktopPassword.field.passwordDescription",keywords:["desktop","password","auth","login"],isAvailable:s=>s.isDesktopLocalOrigin},{id:"sessions.desktop-lan-access",page:"sessions",titleKey:"settings.openchamber.desktopNetwork.field.allowLanAccess",descriptionKey:"settings.openchamber.desktopNetwork.field.allowLanAccessDescription",keywords:["desktop","lan","network","phone","tablet"],isAvailable:s=>s.isDesktopLocalOrigin},{id:"sessions.opencode-binary",page:"sessions",titleKey:"settings.openchamber.opencodeCli.field.binaryPath",keywords:["opencode","cli","binary","path"],isAvailable:s=>!s.isVSCode},{id:"sessions.opencode-update-notifications",page:"sessions",titleKey:"settings.openchamber.opencodeCli.field.showUpdateNotifications",keywords:["opencode","cli","updates"],isAvailable:s=>!s.isVSCode},{id:"git.github-account",page:"git",titleKey:"settings.github.page.actions.connect",keywords:["github","account","oauth","prs","issues"]},{id:"git.identities",page:"git",titleKey:"settings.gitIdentities.page.section.title",descriptionKey:"settings.gitIdentities.page.empty.description",keywords:["identity","profile","author","email","credentials","signing","commit signing","ssh signing","gpg"]},{id:"git.changes-view",page:"git",titleKey:"settings.openchamber.git.changesViewTitle",keywords:["changes","flat list","tree view"]},{id:"git.gitmoji",page:"git",titleKey:"settings.openchamber.git.enableGitmoji",keywords:["commit","emoji"]},{id:"git.gitignored-files",page:"git",titleKey:"settings.openchamber.git.showGitignored",keywords:["ignored","files","gitignore"]},{id:"usage.header-menu",page:"usage",titleKey:"settings.usage.page.options.showInHeader",descriptionKey:"settings.usage.page.options.showInHeaderTooltip",keywords:["quota","header","dropdown"]},{id:"usage.model-quotas",page:"usage",titleKey:"settings.usage.page.section.modelQuotas",keywords:["models","quota","limits","tokens"]},{id:"projects.name",page:"projects",titleKey:"settings.projects.page.field.projectName",keywords:["label","display name","project metadata"]},{id:"projects.accent-color",page:"projects",titleKey:"settings.projects.page.field.accentColor",keywords:["color","appearance","project metadata"]},{id:"projects.icon",page:"projects",titleKey:"settings.projects.page.field.projectIcon",keywords:["icon","favicon","upload","project metadata"]},{id:"projects.worktree",page:"projects",titleKey:"settings.projects.page.section.worktree",keywords:["worktree","branch","repository"]},{id:"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"],isAvailable:s=>!s.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"],isAvailable:s=>s.isDesktop},{id:"behavior.system-prompt",page:"behavior",titleKey:"settings.behavior.page.section.systemPrompt",descriptionKey:"settings.behavior.page.warning.title",keywords:["agents.md","global instructions","system prompt"]},{id:"behavior.response-style",page:"behavior",titleKey:"settings.behavior.page.section.responseStyle",descriptionKey:"settings.behavior.page.responseStyle.tooltip",keywords:["tone","concise","detailed","custom instructions"]},{id:"agents.create",page:"agents",titleKey:"settings.agents.page.title.new",keywords:["create","add","new agent"]},{id:"agents.name",page:"agents",titleKey:"settings.agents.page.field.agentName",keywords:["agent","name"]},{id:"agents.mode",page:"agents",titleKey:"settings.agents.page.field.mode",descriptionKey:"settings.agents.page.field.modeTooltip",keywords:["primary","subagent","visibility"]},{id:"agents.model",page:"agents",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"agents.variant",page:"agents",titleKey:"settings.agents.page.field.variant",descriptionKey:"settings.agents.page.field.variantTooltip",keywords:["thinking","reasoning","variant","depth"]},{id:"agents.temperature",page:"agents",titleKey:"settings.agents.page.field.temperature",descriptionKey:"settings.agents.page.field.temperatureTooltip",keywords:["randomness","creative"]},{id:"agents.top-p",page:"agents",titleKey:"settings.agents.page.field.topP",descriptionKey:"settings.agents.page.field.topPTooltip",keywords:["sampling","nucleus"]},{id:"agents.system-prompt",page:"agents",titleKey:"settings.agents.page.section.systemPrompt",keywords:["prompt","instructions"]},{id:"agents.permissions",page:"agents",titleKey:"settings.agents.page.section.toolPermissions",keywords:["tools","permissions","allow","ask","deny"]},{id:"commands.create",page:"commands",titleKey:"settings.commands.page.title.new",keywords:["create","add","new command"]},{id:"commands.name",page:"commands",titleKey:"settings.commands.page.field.commandName",keywords:["slash command","name"]},{id:"commands.agent",page:"commands",titleKey:"settings.commands.page.field.overrideAgent",keywords:["agent","execution"]},{id:"commands.model",page:"commands",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"commands.template",page:"commands",titleKey:"settings.commands.page.section.template",keywords:["prompt","template","arguments","shell","file"]},{id:"mcp.create",page:"mcp",titleKey:"settings.mcp.sidebar.actions.addServerTitle",keywords:["create","add","server"]},{id:"mcp.server",page:"mcp",titleKey:"settings.mcp.page.server.title",keywords:["server","name","transport"]},{id:"mcp.command",page:"mcp",titleKey:"settings.mcp.page.connection.command",keywords:["stdio","local","command"]},{id:"mcp.environment",page:"mcp",titleKey:"settings.mcp.page.env.title",keywords:["env","variables","api key"]},{id:"mcp.advanced",page:"mcp",titleKey:"settings.mcp.page.advanced.title",keywords:["oauth","headers","timeout"]},{id:"plugins.create",page:"plugins",titleKey:"settings.plugins.sidebar.actions.addTitle",keywords:["add","plugin","npm","path","file"]},{id:"plugins.spec",page:"plugins",titleKey:"settings.plugins.page.field.spec",keywords:["npm","package","path"]},{id:"plugins.options",page:"plugins",titleKey:"settings.plugins.page.field.options",keywords:["json","configuration"]},{id:"plugins.content",page:"plugins",titleKey:"settings.plugins.page.field.content",keywords:["file","code"]},{id:"snippets.create",page:"snippets",titleKey:"settings.snippets.sidebar.actions.create",keywords:["add","new snippet"]},{id:"snippets.content",page:"snippets",titleKey:"settings.snippets.page.field.content",keywords:["markdown","prompt","template"]},{id:"providers.connect",page:"providers",titleKey:"settings.providers.page.connect.title",keywords:["add provider","connect provider","credentials"]},{id:"providers.auth",page:"providers",titleKey:"settings.providers.page.auth.title",keywords:["api key","oauth","credentials"]},{id:"providers.connection-details",page:"providers",titleKey:"settings.providers.page.connectionDetails.title",keywords:["config","source","disconnect"]},{id:"providers.models",page:"providers",titleKey:"settings.providers.page.models.title",keywords:["models","hide","show"]},{id:"skills.create",page:"skills.installed",titleKey:"settings.skills.page.title.newSkill",keywords:["create","add","new skill"]},{id:"skills.basic-information",page:"skills.installed",titleKey:"settings.skills.page.section.basicInformation",keywords:["name","location","description"]},{id:"skills.instructions",page:"skills.installed",titleKey:"settings.skills.page.section.instructions",keywords:["markdown","skill.md","content"]},{id:"skills.supporting-files",page:"skills.installed",titleKey:"settings.skills.page.section.supportingFiles",keywords:["files","resources"]},{id:"skills.catalog.source",page:"skills.catalog",titleKey:"settings.skills.catalog.page.section.sourceRepository",keywords:["catalog","repository","source","refresh"]},{id:"skills.catalog.search",page:"skills.catalog",titleKey:"settings.skills.catalog.shared.field.searchSkillsPlaceholder",keywords:["find skills","install skills","catalog search"]},{id:"skills.catalog.add-catalog",page:"skills.catalog",titleKey:"settings.skills.catalog.page.actions.addCatalog",keywords:["external repository","add source","catalog"]},{id:"magic-prompts.visible-prompt",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.visiblePrompt",keywords:["prompt text","user message","template"],isAvailable:s=>!s.isVSCode},{id:"magic-prompts.instructions",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.instructions",keywords:["hidden prompt","instructions","template"],isAvailable:s=>!s.isVSCode},{id:"magic-prompts.reset-overrides",page:"magic-prompts",titleKey:"settings.magicPrompts.page.actions.resetAllOverrides",keywords:["reset","default prompts","overrides"],isAvailable:s=>!s.isVSCode},{id:"shortcuts.keyboard-shortcuts",page:"shortcuts",titleKey:"settings.openchamber.keyboardShortcuts.title",descriptionKey:"settings.openchamber.keyboardShortcuts.tooltip",keywords:["keyboard","hotkeys","bindings"]},{id:"voice.voice-setup",page:"voice",titleKey:"settings.voice.page.section.voiceSetup",keywords:["tts","voice mode","provider","speech rate","speech pitch","speech volume","language"]},{id:"voice.speech-recognition",page:"voice",titleKey:"settings.voice.page.section.speechRecognition",keywords:["stt","transcribe","whisper","microphone","silence threshold"]},{id:"voice.playback",page:"voice",titleKey:"settings.voice.page.section.playbackAndSummary",keywords:["read aloud","tts input mode","summary","markdown"]},{id:"tunnel.provider",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.provider",descriptionKey:"settings.openchamber.tunnel.description",keywords:["remote access","cloudflare","ngrok"],isAvailable:s=>!s.isVSCode},{id:"tunnel.type",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.tunnelType",keywords:["quick","managed remote","managed local"],isAvailable:s=>!s.isVSCode},{id:"tunnel.ttl",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.connectLinkTtl",descriptionKey:"settings.openchamber.tunnel.field.tunnelSessionTtl",keywords:["expiry","expiration","session ttl","connect link ttl"],isAvailable:s=>!s.isVSCode},{id:"tunnel.managed-remote",page:"tunnel",titleKey:"settings.openchamber.tunnel.section.savedManagedRemoteTunnels",keywords:["cloudflare","hostname","token","managed remote"],isAvailable:s=>!s.isVSCode},{id:"tunnel.managed-local-config",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.configurationFile",descriptionKey:"settings.openchamber.tunnel.note.managedLocalUsesConfig",keywords:["cloudflared","config","yaml","json","managed local"],isAvailable:s=>!s.isVSCode},{id:"tunnel.start",page:"tunnel",titleKey:"settings.openchamber.tunnel.actions.startTunnel",descriptionKey:"settings.openchamber.tunnel.note.connectLinksOneTime",keywords:["connect link","qr code","public url","remote access"],isAvailable:s=>!s.isVSCode},{id:"notifications.delivery",page:"notifications",titleKey:"settings.notifications.page.delivery.title",keywords:["desktop notifications","system notifications"]},{id:"notifications.events",page:"notifications",titleKey:"settings.notifications.page.events.title",keywords:["completion","subtasks","errors","questions"]},{id:"notifications.push",page:"notifications",titleKey:"settings.notifications.page.push.title",keywords:["background","push"],isAvailable:s=>s.isWeb&&!s.isDesktop&&!s.isVSCode}];function Go(s){return s.trim().toLocaleLowerCase()}function jy({query:s,runtimeCtx:e,visiblePageSlugs:n,t:a,getPageTitle:r}){const i=Go(s);if(!i)return[];const o=n?new Set(n):null,d=i.split(/\s+/).filter(Boolean);return vy.flatMap(c=>{if(o&&!o.has(c.page))return[];const f=Pn(c.page);if(!f||f.isAvailable&&!f.isAvailable(e)||c.isAvailable&&!c.isAvailable(e))return[];const m=a(c.titleKey),p=c.descriptionKey?a(c.descriptionKey):null,u=Go([m,p,r(c.page),...c.keywords??[]].filter(Boolean).join(" "));return d.every(S=>u.includes(S))?[{...c,title:m,description:p,pageTitle:r(c.page)}]:[]})}const Or=176,zr=280,Jo=8,nc="__openchamberSettingsDetail";function gr(s){return Math.min(zr,Math.max(Or,s))}const wy=["appearance","chat","notifications","sessions","shortcuts","git","magic-prompts","snippets","projects","remote-instances","agents","behavior","commands","mcp","plugins","providers","usage","skills.installed","skills.catalog","voice","tunnel","about"],Ny={icon:"chat-thread"},ky="__add_provider__";function Sy(s,e){const n=gs(),a=!s&&mn();return{isVSCode:n,isWeb:a,isDesktop:s,isMobile:e}}function Qo(s,e){return s.isAvailable?s.isAvailable(e):!0}function Kr(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function Hn(s,e){const n=new Set(e);let a=s,r=1;for(;n.has(a);)a=`${s}-${r}`,r+=1;return a}function hr(s){if(!Kr(s))return null;const e=s[nc];if(!Kr(e))return null;const n=e.page,a=e.stage;return typeof n!="string"||a!=="page-content"?null:{page:Jr(n),stage:a}}function Cy(){return typeof window>"u"||!Kr(window.history.state)?{}:window.history.state}function ac(s){switch(s){case"projects":return"folders";case"remote-instances":return"server";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return Ny.icon;case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"providers":return"cloud";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"code-box";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"global";case"about":return"information";case"home":return null;default:return"robot-2"}}const fr=s=>{const e=rt.c(95),{onOpen:n}=s,{t:a}=dt();let r;e[0]!==a?(r=a("settings.view.home.title"),e[0]=a,e[1]=r):r=e[1];let i;e[2]!==r?(i=t.jsx("h1",{className:"typography-ui-header font-semibold text-foreground",children:r}),e[2]=r,e[3]=i):i=e[3];let o;e[4]!==a?(o=a("settings.view.home.description"),e[4]=a,e[5]=o):o=e[5];let d;e[6]!==o?(d=t.jsx("p",{className:"typography-ui text-muted-foreground",children:o}),e[6]=o,e[7]=d):d=e[7];let c;e[8]!==i||e[9]!==d?(c=t.jsxs("div",{className:"space-y-1",children:[i,d]}),e[8]=i,e[9]=d,e[10]=c):c=e[10];let f;e[11]!==n?(f=()=>n("providers"),e[11]=n,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[13]=m):m=e[13];let p;e[14]!==a?(p=a("settings.view.home.cards.providers.title"),e[14]=a,e[15]=p):p=e[15];let u;e[16]!==p?(u=t.jsx("div",{className:"typography-ui-label text-foreground",children:p}),e[16]=p,e[17]=u):u=e[17];let S;e[18]!==a?(S=a("settings.view.home.cards.providers.description"),e[18]=a,e[19]=S):S=e[19];let h;e[20]!==S?(h=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:S}),e[20]=S,e[21]=h):h=e[21];let g;e[22]!==h||e[23]!==f||e[24]!==u?(g=t.jsxs("button",{type:"button",onClick:f,className:m,children:[u,h]}),e[22]=h,e[23]=f,e[24]=u,e[25]=g):g=e[25];let x;e[26]!==n?(x=()=>n("agents"),e[26]=n,e[27]=x):x=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[28]=D):D=e[28];let N;e[29]!==a?(N=a("settings.view.home.cards.agents.title"),e[29]=a,e[30]=N):N=e[30];let w;e[31]!==N?(w=t.jsx("div",{className:"typography-ui-label text-foreground",children:N}),e[31]=N,e[32]=w):w=e[32];let A;e[33]!==a?(A=a("settings.view.home.cards.agents.description"),e[33]=a,e[34]=A):A=e[34];let k;e[35]!==A?(k=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:A}),e[35]=A,e[36]=k):k=e[36];let j;e[37]!==x||e[38]!==w||e[39]!==k?(j=t.jsxs("button",{type:"button",onClick:x,className:D,children:[w,k]}),e[37]=x,e[38]=w,e[39]=k,e[40]=j):j=e[40];let y;e[41]!==n?(y=()=>n("skills.catalog"),e[41]=n,e[42]=y):y=e[42];let P;e[43]===Symbol.for("react.memo_cache_sentinel")?(P=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[43]=P):P=e[43];let z;e[44]!==a?(z=a("settings.view.home.cards.skillsCatalog.title"),e[44]=a,e[45]=z):z=e[45];let R;e[46]!==z?(R=t.jsx("div",{className:"typography-ui-label text-foreground",children:z}),e[46]=z,e[47]=R):R=e[47];let I;e[48]!==a?(I=a("settings.view.home.cards.skillsCatalog.description"),e[48]=a,e[49]=I):I=e[49];let v;e[50]!==I?(v=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:I}),e[50]=I,e[51]=v):v=e[51];let b;e[52]!==y||e[53]!==R||e[54]!==v?(b=t.jsxs("button",{type:"button",onClick:y,className:P,children:[R,v]}),e[52]=y,e[53]=R,e[54]=v,e[55]=b):b=e[55];let L;e[56]!==n?(L=()=>n("mcp"),e[56]=n,e[57]=L):L=e[57];let E;e[58]===Symbol.for("react.memo_cache_sentinel")?(E=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[58]=E):E=e[58];let J;e[59]!==a?(J=a("settings.view.home.cards.mcp.title"),e[59]=a,e[60]=J):J=e[60];let _;e[61]!==J?(_=t.jsx("div",{className:"typography-ui-label text-foreground",children:J}),e[61]=J,e[62]=_):_=e[62];let Z;e[63]!==a?(Z=a("settings.view.home.cards.mcp.description"),e[63]=a,e[64]=Z):Z=e[64];let H;e[65]!==Z?(H=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:Z}),e[65]=Z,e[66]=H):H=e[66];let T;e[67]!==L||e[68]!==_||e[69]!==H?(T=t.jsxs("button",{type:"button",onClick:L,className:E,children:[_,H]}),e[67]=L,e[68]=_,e[69]=H,e[70]=T):T=e[70];let Y;e[71]!==n?(Y=()=>n("usage"),e[71]=n,e[72]=Y):Y=e[72];let F;e[73]===Symbol.for("react.memo_cache_sentinel")?(F=ce("rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left","hover:bg-[var(--interactive-hover)] transition-colors"),e[73]=F):F=e[73];let V;e[74]!==a?(V=a("settings.view.home.cards.usage.title"),e[74]=a,e[75]=V):V=e[75];let Q;e[76]!==V?(Q=t.jsx("div",{className:"typography-ui-label text-foreground",children:V}),e[76]=V,e[77]=Q):Q=e[77];let ie;e[78]!==a?(ie=a("settings.view.home.cards.usage.description"),e[78]=a,e[79]=ie):ie=e[79];let X;e[80]!==ie?(X=t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:ie}),e[80]=ie,e[81]=X):X=e[81];let se;e[82]!==Y||e[83]!==Q||e[84]!==X?(se=t.jsxs("button",{type:"button",onClick:Y,className:F,children:[Q,X]}),e[82]=Y,e[83]=Q,e[84]=X,e[85]=se):se=e[85];let me;e[86]!==g||e[87]!==j||e[88]!==b||e[89]!==T||e[90]!==se?(me=t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[g,j,b,T,se]}),e[86]=g,e[87]=j,e[88]=b,e[89]=T,e[90]=se,e[91]=me):me=e[91];let oe;return e[92]!==me||e[93]!==c?(oe=t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"mx-auto w-full max-w-3xl px-6 py-6 space-y-6",children:[c,me]})}),e[92]=me,e[93]=c,e[94]=oe):oe=e[94],oe},Py=s=>{const e=rt.c(126),{onClose:n,forceMobile:a,isWindowed:r,visiblePageSlugs:i,initialMobileStage:o}=s,d=o===void 0?"nav":o,{t:c}=dt(),f=Cs(),m=a??f.isMobile,p=Ke(Iy),u=Ke(Dy),S=Ke(Ay);let h;e[0]!==p?(h=Jr(p),e[0]=p,e[1]=h):h=e[1];const g=h,[x,D]=l.useState(d),N=l.useRef(null),[w,A]=l.useState(216),[k,j]=l.useState(""),[y,P]=l.useState(null),[z,R]=l.useState(0),[I,v]=l.useState(!1),[b,L]=l.useState(!1),E=l.useRef(0),J=l.useRef(w),_=l.useRef(null);let Z;e[2]===Symbol.for("react.memo_cache_sentinel")?(Z=[],e[2]=Z):Z=e[2];const H=l.useRef(Z),T=l.useRef(0),Y=l.useRef(!1);let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=fs(),e[3]=F):F=e[3];const V=F;let Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q=fs()&&ea(),e[4]=Q):Q=e[4];const ie=Q;let X;e[5]!==m?(X=Sy(V,m),e[5]=m,e[6]=X):X=e[6];const se=X;let me;if(e[7]!==m||e[8]!==se||e[9]!==i){const mt=i?new Set(i):null;let xt;e[11]!==se?(xt=Zt=>Qo(Zt,se),e[11]=se,e[12]=xt):xt=e[12];let Rt;e[13]!==se.isVSCode?(Rt=Zt=>!(se.isVSCode&&Zt.slug==="projects"),e[13]=se.isVSCode,e[14]=Rt):Rt=e[14];let es;e[15]!==m?(es=Zt=>!(m&&Zt.slug==="shortcuts"),e[15]=m,e[16]=es):es=e[16],me=sc.filter(Ey).filter(Zt=>!mt||mt.has(Zt.slug)).filter(xt).filter(Rt).filter(es),e[7]=m,e[8]=se,e[9]=i,e[10]=me}else me=e[10];const oe=me;let xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=new Map(wy.map(My)),e[17]=xe):xe=e[17];const we=xe;let he;if(e[18]!==oe){let mt;e[20]===Symbol.for("react.memo_cache_sentinel")?(mt=(xt,Rt)=>(we.get(xt.slug)??999)-(we.get(Rt.slug)??999),e[20]=mt):mt=e[20],he=oe.slice().sort(mt),e[18]=oe,e[19]=he}else he=e[19];const Ie=he,ve=as(Ry);let ye,be;e[21]!==I?(ye=()=>{if(typeof window>"u")return;const mt=()=>{if(!I){const xt=gr(Math.floor(window.innerWidth*.12));A(xt)}};return window.addEventListener("resize",mt),()=>window.removeEventListener("resize",mt)},be=[I],e[21]=I,e[22]=ye,e[23]=be):(ye=e[22],be=e[23]),l.useEffect(ye,be);let te,re;e[24]!==b?(te=()=>{if(!b)return;const mt=Rt=>{const es=Rt.clientX-E.current,Zt=gr(J.current+es);A(Zt),v(!0)},xt=()=>L(!1);return window.addEventListener("pointermove",mt),window.addEventListener("pointerup",xt,{once:!0}),()=>{window.removeEventListener("pointermove",mt),window.removeEventListener("pointerup",xt)}},re=[b],e[24]=b,e[25]=te,e[26]=re):(te=e[25],re=e[26]),l.useEffect(te,re);let ge;e[27]!==w?(ge=mt=>{L(!0),E.current=mt.clientX,J.current=w,mt.preventDefault()},e[27]=w,e[28]=ge):ge=e[28];const U=ge;let ee;e[29]!==w?(ee=mt=>{const xt=mt.shiftKey?Jo*4:Jo;let Rt;e:switch(mt.key){case"ArrowLeft":{Rt=w-xt;break e}case"ArrowRight":{Rt=w+xt;break e}case"Home":{Rt=Or;break e}case"End":{Rt=zr;break e}default:return}mt.preventDefault(),A(gr(Rt)),v(!0)},e[29]=w,e[30]=ee):ee=e[30];const ne=ee;let ue;e[31]!==u||e[32]!==r||e[33]!==se.isVSCode||e[34]!==g?(ue=()=>{if(!(!u&&!se.isVSCode&&!r)){if(g==="agents"){Ka.getState().loadAgents();return}if(g==="commands"){$a.getState().loadCommands();return}if(g==="mcp"){Mn.getState().loadMcpConfigs();return}if(g==="plugins"){os.getState().loadPlugins();return}(g==="skills.installed"||g==="skills.catalog")&&(_s.getState().loadSkills(),Bs.getState().loadCatalog()),g==="snippets"&&Ba.getState().loadSnippets()}},e[31]=u,e[32]=r,e[33]=se.isVSCode,e[34]=g,e[35]=ue):ue=e[35];let Me;e[36]!==ve||e[37]!==u||e[38]!==r||e[39]!==se.isVSCode||e[40]!==g?(Me=[ve,u,r,se.isVSCode,g],e[36]=ve,e[37]=u,e[38]=r,e[39]=se.isVSCode,e[40]=g,e[41]=Me):Me=e[41],l.useEffect(ue,Me);let ke;e[42]!==m||e[43]!==S?(ke=mt=>{if(S(mt),N.current=mt,!m)return;const xt=Pn(mt);if(!xt||xt.slug==="home"){D("nav");return}D(xt.kind==="split"?"page-sidebar":"page-content")},e[42]=m,e[43]=S,e[44]=ke):ke=e[44];const De=ke;let Ae;e[45]!==g?(Ae=Pn(g),e[45]=g,e[46]=Ae):Ae=e[46];const Pe=Ae;let Re;e[47]===Symbol.for("react.memo_cache_sentinel")?(Re={appearance:"visual",chat:"chat",shortcuts:"shortcuts",sessions:"sessions",notifications:"notifications",voice:"voice",tunnel:"tunnel"},e[47]=Re):Re=e[47];const Le=Re;let $e;e[48]!==c?($e=mt=>{switch(mt){case"projects":return c("settings.page.projects.title");case"remote-instances":return c("settings.page.remoteInstances.title");case"providers":return c("settings.page.providers.title");case"usage":return c("settings.page.usage.title");case"agents":return c("settings.page.agents.title");case"behavior":return c("settings.page.behavior.title");case"commands":return c("settings.page.commands.title");case"mcp":return c("settings.page.mcp.title");case"plugins":return c("settings.page.plugins.title");case"skills.installed":return c("settings.page.skills.title");case"skills.catalog":return c("settings.page.skillsCatalog.title");case"git":return c("settings.page.git.title");case"appearance":return c("settings.page.appearance.title");case"chat":return c("settings.page.chat.title");case"shortcuts":return c("settings.page.shortcuts.title");case"sessions":return c("settings.page.sessions.title");case"magic-prompts":return c("settings.page.magicPrompts.title");case"snippets":return c("settings.page.snippets.title");case"notifications":return c("settings.page.notifications.title");case"voice":return c("settings.page.voice.title");case"tunnel":return c("settings.page.tunnel.title");case"about":return c("settings.page.about.title");default:return c("settings.view.home.title")}},e[48]=c,e[49]=$e):$e=e[49];const Be=$e;let Oe;e[50]!==Be||e[51]!==se||e[52]!==k||e[53]!==c||e[54]!==i?(Oe=jy({query:k,runtimeCtx:{...se,isDesktopLocalOrigin:ie},visiblePageSlugs:i,t:c,getPageTitle:Be}),e[50]=Be,e[51]=se,e[52]=k,e[53]=c,e[54]=i,e[55]=Oe):Oe=e[55];const Ue=Oe,le=Ky;let W;if(e[56]!==Ue){W=[];const mt=new Map;for(const xt of Ue){let Rt=mt.get(xt.page);Rt||(Rt={page:xt.page,pageTitle:xt.pageTitle,results:[]},mt.set(xt.page,Rt),W.push(Rt)),Rt.results.push(xt)}e[56]=Ue,e[57]=W}else W=e[57];const de=W;let Ne;e[58]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>{R(0),T.current=0,Y.current=!1},e[58]=Ne):Ne=e[58];let Ee;e[59]!==k?(Ee=[k],e[59]=k,e[60]=Ee):Ee=e[60],l.useEffect(Ne,Ee);let Ce,He;e[61]!==z?(Ce=()=>{T.current=z},He=[z],e[61]=z,e[62]=Ce,e[63]=He):(Ce=e[62],He=e[63]),l.useEffect(Ce,He);let q,$;e[64]!==z?(q=()=>{H.current[z]?.scrollIntoView({block:"nearest"})},$=[z],e[64]=z,e[65]=q,e[66]=$):(q=e[65],$=e[66]),l.useEffect(q,$);let fe,O;e[67]!==z||e[68]!==Ue.length?(fe=()=>{z>=Ue.length&&R(Math.max(0,Ue.length-1)),H.current.length=Ue.length},O=[z,Ue.length],e[67]=z,e[68]=Ue.length,e[69]=fe,e[70]=O):(fe=e[69],O=e[70]),l.useEffect(fe,O);let Fe;e[71]!==m||e[72]!==De?(Fe=mt=>{const xt=le(mt);P(xt),De(mt.page),m&&D("page-content"),mt.id==="plugins.create"&&typeof window<"u"&&window.setTimeout($y,50)},e[71]=m,e[72]=De,e[73]=Fe):Fe=e[73];const Je=Fe;let Xe;e[74]!==Je||e[75]!==k||e[76]!==Ue?(Xe=mt=>{if(k.trim()){if(mt.key==="Escape"){mt.preventDefault(),j("");return}if(Ue.length!==0){if(mt.key==="ArrowDown"){mt.preventDefault(),Y.current=!0,R(xt=>(xt+1)%Ue.length);return}if(mt.key==="ArrowUp"){mt.preventDefault(),Y.current=!0,R(xt=>(xt-1+Ue.length)%Ue.length);return}if(mt.key==="Enter"){mt.preventDefault();const xt=(T.current%Ue.length+Ue.length)%Ue.length,Rt=Ue[xt]??Ue[0];Rt&&Je(Rt)}}}},e[74]=Je,e[75]=k,e[76]=Ue,e[77]=Xe):Xe=e[77];const et=Xe;let at;e[78]!==y?(at=()=>{const mt=y;if(!mt)return;let xt=!1;const Rt=window.requestAnimationFrame(()=>{if(xt)return;const es=typeof CSS<"u"&&CSS.escape?CSS.escape(mt):mt.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Zt=_.current?.querySelector(`[data-settings-item="${es}"]`);Zt&&(P(null),Zt.scrollIntoView({block:"center",behavior:"smooth"}),Zt.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{Zt.removeAttribute("data-settings-search-highlight")},1600))});return()=>{xt=!0,window.cancelAnimationFrame(Rt)}},e[78]=y,e[79]=at):at=e[79];let lt;e[80]!==y||e[81]!==g?(lt=[y,g],e[80]=y,e[81]=g,e[82]=lt):lt=e[82],l.useEffect(at,lt);let Ze;e[83]!==c?(Ze=()=>t.jsx("div",{className:"flex h-full items-center justify-center px-6",children:t.jsxs("div",{className:"max-w-md text-center",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:c("settings.view.unavailable.title")}),t.jsx("p",{className:"typography-ui text-muted-foreground mt-1",children:c("settings.view.unavailable.description")})]})}),e[83]=c,e[84]=Ze):Ze=e[84];const We=Ze,pt=Uy;let pe;e[85]!==De||e[86]!==We||e[87]!==se?(pe=mt=>{const xt=Pn(mt);if(xt&&!Qo(xt,se))return We();switch(mt){case"home":return t.jsx(fr,{onOpen:De});case"projects":return t.jsx(Bh,{});case"remote-instances":return t.jsx(cf,{});case"agents":return t.jsx(Ju,{});case"behavior":return t.jsx(ep,{});case"commands":return t.jsx(cp,{});case"mcp":return t.jsx(Kp,{});case"plugins":return t.jsx(Sg,{});case"skills.installed":return t.jsx(wo,{view:"installed"});case"skills.catalog":return t.jsx(wo,{view:"catalog"});case"providers":return t.jsx(yf,{});case"usage":return t.jsx(Xf,{});case"about":return t.jsx("div",{className:"h-full overflow-auto px-5 py-6",children:t.jsx(Il,{})});case"magic-prompts":return t.jsx(nx,{});case"snippets":return t.jsx(lx,{});case"git":return t.jsx(px,{});case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"voice":case"tunnel":{const Rt=Le[mt]??"visual";return t.jsx(ly,{section:Rt})}default:return t.jsx(fr,{onOpen:De})}},e[85]=De,e[86]=We,e[87]=se,e[88]=pe):pe=e[88];const st=pe;let nt,Ge;e[89]!==m||e[90]!==x||e[91]!==g?(nt=()=>{if(!m||x!=="nav"||g==="home"||N.current===g)return;const mt=Pn(g);!mt||mt.slug==="home"||(N.current=g,D(mt.kind==="split"?"page-sidebar":"page-content"))},Ge=[m,x,g],e[89]=m,e[90]=x,e[91]=g,e[92]=nt,e[93]=Ge):(nt=e[92],Ge=e[93]),l.useEffect(nt,Ge);const ft=m&&x!=="nav",wt=m&&x==="page-content"&&g==="skills.installed",Ct=x==="page-content"&&Pe?.kind==="split"&&!wt;let ae;e[94]!==wt||e[95]!==ft||e[96]!==c?(ae=c(wt?"settings.view.actions.back":ft?"settings.view.actions.backToSettings":"settings.view.actions.closeSettings"),e[94]=wt,e[95]=ft,e[96]=c,e[97]=ae):ae=e[97];const Ve=ae,tt=Nl();let Ye;e[98]!==se.isVSCode?(Ye=mt=>{if(typeof window>"u"||se.isVSCode)return;const xt=hr(window.history.state);xt?.page===mt&&xt.stage==="page-content"||window.history.pushState({...Cy(),[nc]:{page:mt,stage:"page-content"}},"",window.location.href)},e[98]=se.isVSCode,e[99]=Ye):Ye=e[99];const yt=Ye;let ze;e[100]!==yt||e[101]!==g?(ze=()=>{D("page-content"),g==="skills.installed"&&yt(g)},e[100]=yt,e[101]=g,e[102]=ze):ze=e[102];const _e=ze;let ot;e[103]!==wt||e[104]!==se.isVSCode||e[105]!==g?(ot=()=>{if(wt){if((typeof window<"u"?hr(window.history.state):null)?.page===g&&!se.isVSCode){window.history.back();return}D("page-sidebar");return}D("nav")},e[103]=wt,e[104]=se.isVSCode,e[105]=g,e[106]=ot):ot=e[106];const bt=ot;let Mt,Qt;e[107]!==m||e[108]!==se.isVSCode||e[109]!==g?(Mt=()=>{if(!m||se.isVSCode)return;const mt=xt=>{if(g!=="skills.installed")return;if(hr(xt.state)?.page==="skills.installed"){D("page-content");return}D(By)};return window.addEventListener("popstate",mt),()=>{window.removeEventListener("popstate",mt)}},Qt=[m,se.isVSCode,g],e[107]=m,e[108]=se.isVSCode,e[109]=g,e[110]=Mt,e[111]=Qt):(Mt=e[110],Qt=e[111]),l.useEffect(Mt,Qt);let Xt;e[112]===Symbol.for("react.memo_cache_sentinel")?(Xt=()=>{D("page-sidebar")},e[112]=Xt):Xt=e[112];const rs=Xt,Wt=()=>{const mt=k.trim().length>0;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[t.jsx("div",{className:"px-2 pt-3",children:t.jsxs("div",{className:"flex h-10 items-center gap-1.5 rounded-md border border-border bg-background/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-primary/40 sm:h-8",children:[t.jsx(M,{name:"search",className:"h-4 w-4 shrink-0"}),t.jsx("input",{value:k,onChange:xt=>j(xt.target.value),onKeyDown:et,placeholder:c("settings.view.search.placeholder"),"aria-label":c("settings.view.search.aria"),className:"typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70"}),mt&&t.jsx("button",{type:"button",onClick:()=>j(""),"aria-label":c("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:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden",children:t.jsx("div",{className:"flex flex-col gap-0.5 pt-4 pb-2 px-2",children:mt?Ue.length>0?(()=>{let xt=0;return de.map(Rt=>t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("div",{className:"px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70",children:Rt.pageTitle}),Rt.results.map(es=>{const Zt=xt;xt=xt+1;const qs=Zt===z,Ls=!!es.description;return t.jsxs("button",{type:"button",ref:Tn=>{H.current[Zt]=Tn},onMouseMove:()=>{Y.current=!1,R(Zt)},onClick:()=>Je(es),className:ce("flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Ls?"min-h-11 py-1.5":"py-2",qs?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:es.title}),Ls&&t.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:es.description})]},es.id)})]},Rt.page))})():t.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:c("settings.view.search.noResults")}):Ie.map(xt=>{const Rt=g===xt.slug,es=ac(xt.slug);return!es&&xt.slug!=="mcp"?null:t.jsx(Dt,{children:t.jsx(At,{asChild:!0,children:t.jsxs("button",{type:"button",onClick:()=>De(xt.slug),"aria-current":Rt?"page":void 0,className:ce("flex h-8 items-center gap-2 rounded-md px-2 overflow-hidden",Rt?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[xt.slug==="mcp"?t.jsx(su,{className:"h-4 w-4 shrink-0"}):t.jsx(M,{name:es,className:"h-4 w-4 shrink-0"}),t.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap overflow-hidden transition-opacity duration-150 opacity-100",children:[t.jsx("span",{className:"typography-ui-label font-normal truncate",children:Be(xt.slug)}),(xt.slug==="voice"||xt.slug==="tunnel")&&t.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:c("settings.view.badge.beta")})]})]})})},xt.slug)})})}),t.jsx("div",{className:"overflow-hidden transition-opacity duration-150 opacity-100",children:t.jsx("div",{className:"border-t border-border bg-sidebar px-2 py-1 space-y-0.5",children:!se.isVSCode&&t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsxs("button",{type:"button",className:ce("flex h-7 w-full items-center gap-2 rounded-md px-2 overflow-hidden whitespace-nowrap","text-sm font-semibold text-sidebar-foreground/90","hover:text-sidebar-foreground hover:bg-interactive-hover"),onClick:_y,children:[t.jsx(M,{name:"restart",className:"h-4 w-4 shrink-0"}),t.jsx("span",{children:c("settings.view.actions.reloadOpenCode")})]})}),t.jsx(Et,{children:c("settings.view.actions.reloadOpenCodeTooltip")})]})})})]})},Se=()=>{if(x==="nav")return t.jsx("div",{className:ce("flex-1 min-h-0 overflow-hidden",se.isVSCode?"bg-background":"bg-sidebar"),children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:t.jsx(Ys,{children:Wt()})})});if(!Pe)return t.jsx("div",{className:"flex-1 bg-background"});if(x==="page-sidebar"){if(Pe.kind!=="split"){const xt=st(g);return t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Ys,{children:xt})})}return t.jsx("div",{className:ce("flex-1 min-h-0 overflow-hidden",se.isVSCode?"bg-background":"bg-sidebar"),children:t.jsx(Ys,{children:pt(g,{onItemSelect:_e})})})}const mt=st(g);return t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Ys,{children:mt})})};let vt;e[113]!==Pe||e[114]!==De||e[115]!==st||e[116]!==se.isVSCode||e[117]!==g?(vt=()=>!Pe||g==="home"?t.jsx(fr,{onOpen:De}):Pe.kind==="split"?t.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:ce("w-[264px] min-w-[264px] border-r",se.isVSCode?"bg-background":"bg-sidebar"),style:{borderColor:"var(--interactive-border)"},children:t.jsx(Ys,{children:pt(g,{})})}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:t.jsx(Ys,{children:st(g)})})]}):t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(Ys,{children:st(g)})}),e[113]=Pe,e[114]=De,e[115]=st,e[116]=se.isVSCode,e[117]=g,e[118]=vt):vt=e[118];const Nt=vt,ct="true";let St;e[119]===Symbol.for("react.memo_cache_sentinel")?(St=ce("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),e[119]=St):St=e[119];const $t=m?t.jsxs("div",{className:ce("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b px-3","bg-background"),style:{borderColor:"var(--interactive-border)"},children:[ft||n?t.jsx("button",{type:"button",onClick:ft?bt:n,"aria-label":Ve,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-primary",children:t.jsx(M,{name:"arrow-left-s",className:"h-5 w-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-2 typography-ui-label font-medium text-foreground truncate",children:x==="nav"?c("settings.view.home.title"):Pe?Be(Pe.slug):c("settings.view.home.title")}),Ct&&t.jsx("button",{type:"button",onClick:rs,"aria-label":c("settings.view.actions.openSectionList"),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-primary",children:t.jsx(M,{name:"list-unordered",className:"h-5 w-5"})}),n&&t.jsx("button",{type:"button",onClick:n,"aria-label":c("settings.view.actions.closeSettings"),title:c("settings.view.actions.closeSettingsWithShortcut",{shortcut:tt}),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-primary",children:t.jsx(M,{name:"close",className:"h-5 w-5"})})]}):t.jsxs(t.Fragment,{children:[ft&&t.jsx("div",{className:ce("absolute left-3 z-50",r?"top-2":"top-3"),children:t.jsx("button",{type:"button",onClick:bt,"aria-label":c("settings.view.actions.back"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(M,{name:"arrow-left-s",className:"h-5 w-5"})})}),n&&t.jsx("div",{className:ce("absolute right-0.5 z-50",r?"top-0.5":"top-1"),children:t.jsx("button",{type:"button",onClick:n,"aria-label":c("settings.view.actions.closeSettings"),title:c("settings.view.actions.closeSettingsWithShortcut",{shortcut:tt}),className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(M,{name:"close",className:"h-5 w-5"})})})]}),ys="flex flex-1 min-h-0 overflow-hidden",ns=m?Se():t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:ce("relative flex h-full min-h-0 flex-col overflow-hidden border-r",V?"bg-sidebar":se.isVSCode?"bg-background":"bg-sidebar",b?"":"transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]"),style:{width:`${w}px`,minWidth:`${w}px`,borderColor:"var(--interactive-border)"},children:[t.jsx("div",{className:ce("absolute right-0 top-0 z-20 h-full w-[6px] -mr-[3px] cursor-col-resize","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",b?"bg-primary/30":"bg-transparent hover:bg-primary/20"),tabIndex:0,onPointerDown:U,onKeyDown:ne,role:"separator","aria-orientation":"vertical","aria-valuemin":Or,"aria-valuemax":zr,"aria-valuenow":w,"aria-label":c("settings.view.actions.resizeNavigation")}),t.jsx(Ys,{children:Wt()})]}),t.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:Nt()})]});let bs;e[120]!==ns?(bs=t.jsx("div",{className:ys,children:ns}),e[120]=ns,e[121]=bs):bs=e[121];let Qe;return e[122]!==St||e[123]!==$t||e[124]!==bs?(Qe=t.jsxs("div",{ref:_,"data-settings-view":ct,className:St,children:[$t,bs]}),e[122]=St,e[123]=$t,e[124]=bs,e[125]=Qe):Qe=e[125],Qe};function Iy(s){return s.settingsPage}function Dy(s){return s.isSettingsDialogOpen}function Ay(s){return s.setSettingsPage}function Ey(s){return s.slug!=="home"}function My(s,e){return[s,e]}function Ry(s){return s.activeProjectId}function Ty(s){return s.name}function Fy(s){return s.name}function Ly(s){return s.name}function Oy(s){return s.name}function zy(s){return s.name}function Ky(s){if(s.id.startsWith("agents.")){const e=Ka.getState(),n=Hn("new-agent",e.agents.map(Ty));return e.setAgentDraft({name:n,scope:"user"}),e.setSelectedAgent(n),s.id==="agents.create"?"agents.name":s.id}if(s.id.startsWith("commands.")){const e=$a.getState(),n=Hn("new-command",e.commands.map(Fy));return e.setCommandDraft({name:n,scope:"user"}),e.setSelectedCommand(n),s.id==="commands.create"?"commands.name":s.id}if(s.id.startsWith("mcp.")){const e=Mn.getState(),n=Hn("new-mcp-server",e.mcpServers.map(Ly));return e.setMcpDraft({name:n,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),e.setSelectedMcp(n),s.id==="mcp.create"?"mcp.server":s.id}if(s.id.startsWith("snippets.")){const e=Ba.getState(),n=Hn("new-snippet",e.snippets.map(Oy));return e.setSnippetDraft({name:n,scope:"global"}),e.setSelectedSnippet(n),s.id==="snippets.create"?"snippets.content":s.id}if(s.id.startsWith("skills.")){const e=_s.getState(),n=Hn("new-skill",e.skills.map(zy));return e.setSkillDraft({name:n,scope:"user",source:"opencode",description:"",instructions:""}),e.setSelectedSkill(n),s.id==="skills.create"?"skills.basic-information":s.id}return s.id==="providers.connect"&&ut.getState().setSelectedProvider(ky),s.id==="plugins.create"?"plugins.spec":s.id}function $y(){window.dispatchEvent(new CustomEvent("openchamber:settings-open-plugin-add"))}function Uy(s,e){switch(s){case"projects":return t.jsx(Ih,{onItemSelect:e.onItemSelect});case"agents":return t.jsx(Bu,{onItemSelect:e.onItemSelect});case"commands":return t.jsx(tp,{onItemSelect:e.onItemSelect});case"mcp":return t.jsx(dp,{onItemSelect:e.onItemSelect});case"plugins":return t.jsx(pg,{onItemSelect:e.onItemSelect});case"skills.installed":return t.jsx(Pg,{onItemSelect:e.onItemSelect});case"providers":return t.jsx(uf,{onItemSelect:e.onItemSelect});case"usage":return t.jsx(Af,{onItemSelect:e.onItemSelect});case"magic-prompts":return t.jsx(ex,{onItemSelect:e.onItemSelect});case"snippets":return t.jsx(ax,{onItemSelect:e.onItemSelect});default:return null}}function By(s){return s==="page-content"?"page-sidebar":s}function Vy(){}function _y(){In({message:"Restarting OpenCode…",mode:"projects",scopes:["all"]}).catch(Vy)}const Ov=Object.freeze(Object.defineProperty({__proto__:null,SettingsView:Py,getSettingsNavIcon:ac},Symbol.toStringTag,{value:"Module"})),Hy=["chat","git","diff","terminal","files","diagram"],Wy=["settings","agents","commands","skills","providers","usage","git-identities"],Ds={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function Yo(s){const e=qy();return{sessionId:Gy(e),tab:Jy(e),settingsPath:Qy(e),diffFile:Yy(e)}}function qy(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function Gy(s){const e=s.get(Ds.SESSION);return!e||e.trim().length===0?null:e.trim()}function Jy(s){const e=s.get(Ds.TAB);if(!e)return null;const n=e.toLowerCase().trim();return Hy.includes(n)?n:null}function Qy(s){const e=s.get(Ds.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="openchamber"||n==="general"||n==="preferences"?"home":(Wy.includes(n),n)}function Yy(s){const e=s.get(Ds.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function Xo(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(Ds.SESSION)||s.has(Ds.TAB)||s.has(Ds.SETTINGS)||s.has(Ds.FILE)}catch{return!1}}const Xy="chat";function rc(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(Ds.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(Ds.SETTINGS,n),e}return s.tab!==Xy&&e.set(Ds.TAB,s.tab),s.tab==="diff"&&s.diffFile&&s.diffFile.trim().length>0&&e.set(Ds.FILE,s.diffFile),e}function Zy(s,e){const n=typeof window<"u"?window.location.pathname:"/",a=s.toString();return a?`${n}?${a}`:n}function eb(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=rc(s),a=[...e.entries()].sort((i,o)=>i[0].localeCompare(o[0])),r=[...n.entries()].sort((i,o)=>i[0].localeCompare(o[0]));if(a.length!==r.length)return!1;for(let i=0;i<a.length;i++)if(a[i][0]!==r[i][0]||a[i][1]!==r[i][1])return!1;return!0}catch{return!0}}function tb(s,e={}){if(!(typeof window>"u")&&!sb()&&!(!e.force&&eb(s)))try{const n=rc(s),a=Zy(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",a):window.history.pushState({route:s},"",a)}catch{}}function sb(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function nb(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function zv(){const s=l.useMemo(()=>nb(),[]),e=l.useRef(!1),n=l.useRef(!1),a=Ps(p=>p.setCurrentSession),r=Ke(p=>p.setActiveMainTab),i=Ke(p=>p.setSettingsDialogOpen),o=Ke(p=>p.setSettingsPage),d=Ke(p=>p.navigateToDiff),c=l.useCallback(async p=>{if(!n.current){n.current=!0;try{if(p.sessionId){const u=Ps.getState().currentSessionId;p.sessionId!==u&&await a(p.sessionId)}if(p.settingsPath){o(Jr(p.settingsPath)),i(!0);return}Ke.getState().isSettingsDialogOpen&&i(!1),p.tab&&r(p.tab),p.diffFile&&(p.tab==="diff"||!p.tab)&&d(p.diffFile)}finally{n.current=!1}}},[a,r,i,o,d]),f=l.useCallback(()=>{const p=Ps.getState(),u=Ke.getState();return{sessionId:p.currentSessionId,tab:u.activeMainTab,isSettingsOpen:u.isSettingsDialogOpen,settingsPath:u.settingsPage,diffFile:u.pendingDiffFile}},[]),m=l.useCallback((p={})=>{if(s||n.current)return;const u=f();tb(u,p)},[s,f]);l.useEffect(()=>{if(e.current||(e.current=!0,!Xo()))return;const p=Yo();(async()=>(await c(p),s||m({replace:!0})))()},[c,s,m]),l.useEffect(()=>{if(s)return;let p=Ps.getState().currentSessionId;return Ps.subscribe(S=>{const h=S.currentSessionId;h===p||n.current||(p=h,m())})},[s,m]),l.useEffect(()=>{if(s)return;let p=Ke.getState().activeMainTab,u=Ke.getState().isSettingsDialogOpen,S=Ke.getState().settingsPage,h=Ke.getState().pendingDiffFile;return Ke.subscribe(x=>{if(n.current)return;const D=x.activeMainTab!==p,N=x.isSettingsDialogOpen!==u,w=x.settingsPage!==S,A=x.pendingDiffFile!==h&&x.activeMainTab==="diff";p=x.activeMainTab,u=x.isSettingsDialogOpen,S=x.settingsPage,h=x.pendingDiffFile,(D||N||w||A)&&m()})},[s,m]),l.useEffect(()=>{if(typeof window>"u"||s)return;const p=()=>{const u=Yo();if(Xo())c(u);else{const S=Ke.getState();S.isSettingsDialogOpen&&i(!1),S.activeMainTab!=="chat"&&r("chat")}};return window.addEventListener("popstate",p),()=>{window.removeEventListener("popstate",p)}},[c,s,r,i])}function Kv(){const s=rt.c(5),e=Pl(rb),n=l.useRef(e);let a,r;s[0]!==e?(a=()=>{n.current=e},r=[e],s[0]=e,s[1]=a,s[2]=r):(a=s[1],r=s[2]),l.useEffect(a,r);let i,o;s[3]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{let d=!1,c=null;const f=ab,m=p=>{d||(c=window.setTimeout(async()=>{const u=await n.current(),S=typeof u=="number"&&Number.isFinite(u)?f(u):36e5;m(S)},p))};return m(3e3),()=>{d=!0,c!==null&&window.clearTimeout(c)}},o=[],s[3]=i,s[4]=o):(i=s[3],o=s[4]),l.useEffect(i,o)}function ab(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function rb(s){return s.checkForUpdates}const ic={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},ib=ic.M;function ob(s){const e=s.index?.trim(),n=s.working_dir?.trim();return e&&e!=="?"?e.charAt(0):n?n.charAt(0):e?.charAt(0)||n?.charAt(0)||"M"}function lb(s){const e=ob(s);return ic[e]??ib}const cb=l.memo(function(e){const n=rt.c(58),{file:a,actionLabel:r,actionSymbol:i,onAction:o,onViewDiff:d,onRevert:c,isReverting:f,stats:m,rowPaddingClassName:p,indentPx:u,actionAtStart:S,showRevert:h}=e,g=u===void 0?0:u,x=S===void 0?!1:S,D=h===void 0?!0:h;let N;n[0]!==a?(N=lb(a),n[0]=a,n[1]=N):N=n[1];const w=N,{t:A}=dt(),k=w.description,j=m?.insertions??0,y=m?.deletions??0;let P;n[2]!==o||n[3]!==d?(P=he=>{he.key===" "?(he.preventDefault(),o()):he.key==="Enter"&&(he.preventDefault(),d())},n[2]=o,n[3]=d,n[4]=P):P=n[4];const z=P;let R;n[5]!==o?(R=he=>{he.preventDefault(),he.stopPropagation(),o()},n[5]=o,n[6]=R):R=n[6];const I=R;let v;n[7]!==c?(v=he=>{he.preventDefault(),he.stopPropagation(),c()},n[7]=c,n[8]=v):v=n[8];const b=v;let L;n[9]!==r||n[10]!==i||n[11]!==I?(L=t.jsx("button",{type:"button",onClick:I,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":r,title:r,children:i}),n[9]=r,n[10]=i,n[11]=I,n[12]=L):L=n[12];const E=L,J=`group flex items-center gap-2 py-1.5 cursor-pointer ${p??"px-3"}`;let _;n[13]!==g?(_=g>0?{paddingLeft:`${g}px`}:void 0,n[13]=g,n[14]=_):_=n[14];const Z=x?E:null;let H;n[15]!==w.color?(H={color:w.color},n[15]=w.color,n[16]=H):H=n[16];let T;n[17]!==w.code||n[18]!==k||n[19]!==H?(T=t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:H,title:k,"aria-label":k,children:w.code}),n[17]=w.code,n[18]=k,n[19]=H,n[20]=T):T=n[20];let Y;n[21]!==a.path?(Y=t.jsx(jm,{filePath:a.path,className:"h-3.5 w-3.5 shrink-0"}),n[21]=a.path,n[22]=Y):Y=n[22];let F;if(n[23]!==a.path){e:{const he=a.path.lastIndexOf("/");if(he===-1){let ge;n[25]===Symbol.for("react.memo_cache_sentinel")?(ge={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},n[25]=ge):ge=n[25],F=t.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ge,title:a.path,children:a.path});break e}const Ie=a.path.slice(0,he),ve=a.path.slice(he);let ye;n[26]===Symbol.for("react.memo_cache_sentinel")?(ye={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},n[26]=ye):ye=n[26];let be;n[27]===Symbol.for("react.memo_cache_sentinel")?(be=t.jsx("span",{className:"text-muted-foreground",children:"/"}),n[27]=be):be=n[27];const te=t.jsx("span",{className:"text-foreground",children:ve.slice(1)});let re;n[28]!==te?(re=t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[be,te]}),n[28]=te,n[29]=re):re=n[29],F=t.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:a.path,children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:ye,children:Ie}),re]})}n[23]=a.path,n[24]=F}else F=n[24];let V;n[30]===Symbol.for("react.memo_cache_sentinel")?(V={color:"var(--status-success)"},n[30]=V):V=n[30];let Q;n[31]!==j?(Q=t.jsxs("span",{style:V,children:["+",j]}),n[31]=j,n[32]=Q):Q=n[32];let ie,X;n[33]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),X={color:"var(--status-error)"},n[33]=ie,n[34]=X):(ie=n[33],X=n[34]);let se;n[35]!==y?(se=t.jsxs("span",{style:X,children:["-",y]}),n[35]=y,n[36]=se):se=n[36];let me;n[37]!==Q||n[38]!==se?(me=t.jsxs("span",{className:"shrink-0 typography-micro",children:[Q,ie,se]}),n[37]=Q,n[38]=se,n[39]=me):me=n[39];let oe;n[40]!==a.path||n[41]!==b||n[42]!==f||n[43]!==D||n[44]!==A?(oe=D?t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx("button",{type:"button",onClick:b,disabled:f,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":A("gitView.changes.revertFileAria",{path:a.path}),children:f?t.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(M,{name:"arrow-go-back",className:"size-3.5"})})}),t.jsx(Et,{sideOffset:8,children:A("gitView.changes.revertFileTooltip")})]}):null,n[40]=a.path,n[41]=b,n[42]=f,n[43]=D,n[44]=A,n[45]=oe):oe=n[45];const xe=x?null:E;let we;return n[46]!==z||n[47]!==d||n[48]!==_||n[49]!==Z||n[50]!==T||n[51]!==Y||n[52]!==F||n[53]!==me||n[54]!==oe||n[55]!==xe||n[56]!==J?(we=t.jsxs("div",{className:J,role:"button",tabIndex:0,onClick:d,onKeyDown:z,style:_,children:[Z,T,Y,F,me,oe,xe]}),n[46]=z,n[47]=d,n[48]=_,n[49]=Z,n[50]=T,n[51]=Y,n[52]=F,n[53]=me,n[54]=oe,n[55]=xe,n[56]=J,n[57]=we):we=n[57],we}),Zo=14,oc=s=>s.replace(/\\/g,"/").replace(/^\/+/,"").trim(),el=(s,e)=>({id:`dir:${s}`,path:s,name:e,children:new Map,directFiles:[],files:[]}),db=s=>{const e=el("","");for(const n of s){const a=oc(n.path);if(!a)continue;const i=a.split("/").filter(Boolean).slice(0,-1);let o=e;if(o.files.push(n),i.length>0){let d="";for(const c of i){d=d?`${d}/${c}`:c;const f=o.children.get(c);if(f){f.files.push(n),o=f;continue}const m=el(d,c);m.files.push(n),o.children.set(c,m),o=m}}o.directFiles.push(n)}return e},mb=(s,e)=>{const n=[],a=(r,i)=>{const o=Array.from(r.children.values()).sort((c,f)=>c.path.localeCompare(f.path));for(const c of o)n.push({key:c.id,kind:"directory",depth:i,directory:c}),e.has(c.path)&&a(c,i+1);const d=[...r.directFiles].sort((c,f)=>c.path.localeCompare(f.path));for(const c of d)n.push({key:`file:${oc(c.path)}`,kind:"file",depth:i,file:c})};return a(s,0),n},ub=1e3,ya=34,xr=30,ba="pl-0 pr-2",yr=(s,e)=>`${s} ${e}`,$v=s=>{const e=rt.c(158),{groups:n,diffStats:a,revertingPaths:r,isRevertingAll:i,headerBackgroundClassName:o,onVisiblePathsChange:d,onRevertAll:c,onRevertDirectory:f}=s,m=i===void 0?!1:i,p=o===void 0?"bg-sidebar":o,{t:u}=dt(),S=l.useRef(null),g=Ke(pb)==="tree";let x;e[0]!==n?(x=n.filter(gb),e[0]=n,e[1]=x):x=e[1];const D=x;let N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=new Set,e[2]=N):N=e[2];const[w,A]=l.useState(N);let k;e[3]===Symbol.for("react.memo_cache_sentinel")?(k=new Set,e[3]=k):k=e[3];const[j,y]=l.useState(k),[P,z]=l.useState(!1),[R,I]=l.useState(null);let v;e[4]!==D?(v=D.map(hb),e[4]=D,e[5]=v):v=e[5];const b=v;let L;e[6]!==b||e[7]!==D?(L=[],D.forEach((ze,_e)=>{Array.from(b[_e]?.children.values()??[]).forEach(ot=>{L.push(yr(ze.id,ot.path))})}),e[6]=b,e[7]=D,e[8]=L):L=e[8];const E=L;let J,_;e[9]!==g||e[10]!==E?(J=()=>{g&&y(ze=>{const _e=new Set,ot=new Set(E);return ze.forEach(bt=>{(bt.slice(bt.indexOf(" ")+1).includes("/")||ot.has(bt))&&_e.add(bt)}),E.forEach(bt=>_e.add(bt)),_e})},_=[g,E],e[9]=g,e[10]=E,e[11]=J,e[12]=_):(J=e[11],_=e[12]),l.useEffect(J,_);let Z;if(e[13]!==w||e[14]!==j||e[15]!==g||e[16]!==c||e[17]!==b||e[18]!==D){if(Z=[],D.forEach((ze,_e)=>{if(Z.push({type:"header",key:`header:${ze.id}`,groupIndex:_e}),!w.has(ze.id)){if(g){const ot=new Set;j.forEach(Mt=>{Mt.startsWith(`${ze.id} `)&&ot.add(Mt.slice(ze.id.length+1))}),mb(b[_e],ot).forEach(Mt=>{Mt.kind==="file"?Z.push({type:"file",key:`${ze.id}:${Mt.key}`,groupIndex:_e,file:Mt.file,depth:Mt.depth}):Z.push({type:"directory",key:`${ze.id}:${Mt.key}`,groupIndex:_e,directory:Mt.directory,depth:Mt.depth})});return}ze.entries.forEach(ot=>{Z.push({type:"file",key:`${ze.id}:file:${ot.path}`,groupIndex:_e,file:ot,depth:0})})}}),c&&D.length>0){let ze;e[20]===Symbol.for("react.memo_cache_sentinel")?(ze={type:"revert-all",key:"revert-all"},e[20]=ze):ze=e[20],Z.push(ze)}e[13]=w,e[14]=j,e[15]=g,e[16]=c,e[17]=b,e[18]=D,e[19]=Z}else Z=e[19];const H=Z,T=H.length,Y=T>=ub,F=l.useRef(null),[V,Q]=l.useState(0);let ie;e[21]===Symbol.for("react.memo_cache_sentinel")?(ie=ze=>{const _e=F.current,ot=_e?_e.findItemIndex(ze):Math.floor(ze/ya);Q(bt=>bt===ot?bt:ot)},e[21]=ie):ie=e[21];const X=ie;let se,me;e[22]!==d||e[23]!==T||e[24]!==H||e[25]!==Y||e[26]!==V?(se=()=>{if(!d)return;const ze=fb;if(T===0){d([]);return}if(!Y){const _e=[];for(const ot of H)if(ot.type==="file"&&(_e.push(ot.file.path),_e.length>=xr))break;d(_e);return}d(H.slice(V,V+Math.ceil((S.current?.clientHeight??0)/ya)+xr).map(_e=>ze(_e)).filter(xb).slice(0,xr))},me=[d,T,H,Y,V],e[22]=d,e[23]=T,e[24]=H,e[25]=Y,e[26]=V,e[27]=se,e[28]=me):(se=e[27],me=e[28]),l.useEffect(se,me);let oe;e[29]===Symbol.for("react.memo_cache_sentinel")?(oe=ze=>{A(_e=>{const ot=new Set(_e);return ot.has(ze)?ot.delete(ze):ot.add(ze),ot})},e[29]=oe):oe=e[29];const xe=oe;let we;e[30]===Symbol.for("react.memo_cache_sentinel")?(we=(ze,_e)=>{y(ot=>{const bt=new Set(ot),Mt=yr(ze,_e);return bt.has(Mt)?bt.delete(Mt):bt.add(Mt),bt})},e[30]=we):we=e[30];const he=we;let Ie;e[31]!==D?(Ie=new Set,D.forEach(ze=>ze.entries.forEach(_e=>Ie.add(_e.path))),e[31]=D,e[32]=Ie):Ie=e[32];let ve;e[33]!==Ie?(ve=Array.from(Ie),e[33]=Ie,e[34]=ve):ve=e[34];const ye=ve,be=ye.length;let te;e[35]!==m||e[36]!==R||e[37]!==r?(te=R?m||R.paths.some(ze=>r.has(ze)):!1,e[35]=m,e[36]=R,e[37]=r,e[38]=te):te=e[38];const re=te;let ge;e[39]!==ye||e[40]!==m||e[41]!==c?(ge=async()=>{!c||m||ye.length===0||(await c(ye),z(!1))},e[39]=ye,e[40]=m,e[41]=c,e[42]=ge):ge=e[42];const U=ge;let ee;e[43]!==re||e[44]!==f||e[45]!==R?(ee=async()=>{!f||!R||re||(await f(R.paths),I(null))},e[43]=re,e[44]=f,e[45]=R,e[46]=ee):ee=e[46];const ne=ee;let ue;e[47]!==w||e[48]!==p?(ue=(ze,_e)=>{const ot=w.has(ze.id),bt=ze.entries.length;return t.jsxs("div",{className:ce("sticky top-0 z-10 flex items-center gap-2 py-2",p,ba,!_e&&"mt-1 border-t border-border/40"),children:[t.jsx("button",{type:"button",onClick:()=>ze.onActionAll(ze.entries.map(yb)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":ze.actionAllLabel,title:ze.actionAllLabel,children:ze.actionSymbol}),t.jsxs("button",{type:"button",onClick:()=>xe(ze.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!ot,children:[t.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:ze.title}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:bt}),t.jsx(M,{name:"arrow-down-s",className:ce("size-3.5 shrink-0 text-muted-foreground transition-transform",ot&&"-rotate-90")})]})]})},e[47]=w,e[48]=p,e[49]=ue):ue=e[49];const Me=ue;let ke;e[50]!==j||e[51]!==m||e[52]!==f||e[53]!==r||e[54]!==u?(ke=(ze,_e,ot)=>{const bt=j.has(yr(ze.id,_e.path)),Mt=_e.files.map(bb),Qt=m||Mt.some(Xt=>r.has(Xt));return t.jsxs("div",{className:ce("group flex items-center gap-2 py-1.5",ba),style:{paddingLeft:`${ot*Zo}px`},children:[t.jsxs("button",{type:"button",onClick:()=>he(ze.id,_e.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":bt?u("gitView.changes.collapseDirectoryAria",{path:_e.path}):u("gitView.changes.expandDirectoryAria",{path:_e.path}),children:[bt?t.jsx(M,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):t.jsx(M,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:_e.path,children:_e.name}),t.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:_e.files.length})]}),ze.showRevertActions!==!1&&f?t.jsx("button",{type:"button",onClick:()=>I({path:_e.path,paths:Mt,count:Mt.length}),disabled:Qt,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":u("gitView.changes.revertDirectoryAria",{path:_e.path}),title:u("gitView.changes.revertDirectoryTooltip"),children:Qt?t.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(M,{name:"arrow-go-back",className:"size-3.5"})}):null,t.jsx("button",{type:"button",onClick:()=>ze.onActionAll(_e.files.map(vb)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":u(ze.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:_e.path}),title:u(ze.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:_e.path}),children:ze.actionSymbol})]})},e[50]=j,e[51]=m,e[52]=f,e[53]=r,e[54]=u,e[55]=ke):ke=e[55];const De=ke;let Ae;e[56]!==a||e[57]!==m||e[58]!==g||e[59]!==De||e[60]!==Me||e[61]!==r||e[62]!==u||e[63]!==D?(Ae=(ze,_e)=>{if(ze.type==="revert-all")return t.jsx("div",{className:ce("flex justify-end py-2",ba),children:t.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>z(!0),disabled:m,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[t.jsx(M,{name:"arrow-go-back",className:"size-3.5"}),u("gitView.changes.revertAll")]})});const ot=D[ze.groupIndex];if(!ot)return null;if(ze.type==="header")return Me(ot,_e);if(ze.type==="directory")return De(ot,ze.directory,ze.depth);const bt=ze.file;return t.jsx(cb,{file:bt,actionLabel:ot.getActionLabel(bt.path),actionSymbol:ot.actionSymbol,onAction:()=>ot.onActionFile(bt.path),stats:a?.[bt.path],onViewDiff:()=>ot.onViewDiff(bt.path),onRevert:()=>ot.onRevertFile(bt.path),isReverting:r.has(bt.path)||m,rowPaddingClassName:ba,indentPx:ze.depth*Zo,actionAtStart:!g,showRevert:ot.showRevertActions!==!1})},e[56]=a,e[57]=m,e[58]=g,e[59]=De,e[60]=Me,e[61]=r,e[62]=u,e[63]=D,e[64]=Ae):Ae=e[64];const Pe=Ae;let Re;e[65]!==H?(Re=ze=>{const _e=H[ze],ot=H[ze-1];return!_e||!ot||_e.type!=="file"&&_e.type!=="directory"||ot.type!=="file"&&ot.type!=="directory"?!1:ot.groupIndex===_e.groupIndex},e[65]=H,e[66]=Re):Re=e[66];const Le=Re;let $e;e[67]!==Pe||e[68]!==H||e[69]!==Y||e[70]!==Le||e[71]!==u?($e=t.jsx(wm,{ref:S,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:Y?t.jsx(nd,{ref:F,data:H,itemSize:ya,bufferSize:ya*12,scrollRef:S,onScroll:X,children:(ze,_e)=>t.jsx("div",{className:ce("relative",Le(_e)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:Pe(ze,_e===0)},ze.key)}):t.jsx("div",{role:"list","aria-label":u("gitView.changes.changedFilesAria"),children:H.map((ze,_e)=>t.jsx("div",{className:ce("relative",Le(_e)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:Pe(ze,_e===0)},ze.key))})}),e[67]=Pe,e[68]=H,e[69]=Y,e[70]=Le,e[71]=u,e[72]=$e):$e=e[72];let Be;e[73]===Symbol.for("react.memo_cache_sentinel")?(Be=t.jsx(Nm,{containerRef:S,disableHorizontal:!0}),e[73]=Be):Be=e[73];let Oe;e[74]!==$e?(Oe=t.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[$e,Be]}),e[74]=$e,e[75]=Oe):Oe=e[75];let Ue;e[76]!==m?(Ue=ze=>{!m&&!ze&&z(!1)},e[76]=m,e[77]=Ue):Ue=e[77];let le;e[78]!==u?(le=u("gitView.changes.revertAllDialogTitle"),e[78]=u,e[79]=le):le=e[79];let W;e[80]!==le?(W=t.jsx(Vt,{children:le}),e[80]=le,e[81]=W):W=e[81];let de;e[82]!==be||e[83]!==u?(de=be===1?u("gitView.changes.revertAllDescriptionSingle",{count:be}):u("gitView.changes.revertAllDescriptionPlural",{count:be}),e[82]=be,e[83]=u,e[84]=de):de=e[84];let Ne;e[85]!==de?(Ne=t.jsx(qt,{children:de}),e[85]=de,e[86]=Ne):Ne=e[86];let Ee;e[87]!==W||e[88]!==Ne?(Ee=t.jsxs(_t,{children:[W,Ne]}),e[87]=W,e[88]=Ne,e[89]=Ee):Ee=e[89];let Ce;e[90]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>z(!1),e[90]=Ce):Ce=e[90];let He;e[91]!==u?(He=u("gitView.common.cancel"),e[91]=u,e[92]=He):He=e[92];let q;e[93]!==m||e[94]!==He?(q=t.jsx(G,{variant:"outline",size:"sm",onClick:Ce,disabled:m,children:He}),e[93]=m,e[94]=He,e[95]=q):q=e[95];let $;e[96]!==U?($=()=>{U()},e[96]=U,e[97]=$):$=e[97];let fe;e[98]!==m||e[99]!==u?(fe=u(m?"gitView.changes.reverting":"gitView.changes.revertAll"),e[98]=m,e[99]=u,e[100]=fe):fe=e[100];let O;e[101]!==m||e[102]!==$||e[103]!==fe?(O=t.jsx(G,{variant:"destructive",size:"sm",onClick:$,disabled:m,children:fe}),e[101]=m,e[102]=$,e[103]=fe,e[104]=O):O=e[104];let Fe;e[105]!==q||e[106]!==O?(Fe=t.jsxs(Yt,{children:[q,O]}),e[105]=q,e[106]=O,e[107]=Fe):Fe=e[107];let Je;e[108]!==Ee||e[109]!==Fe?(Je=t.jsxs(Bt,{className:"max-w-md",children:[Ee,Fe]}),e[108]=Ee,e[109]=Fe,e[110]=Je):Je=e[110];let Xe;e[111]!==P||e[112]!==Ue||e[113]!==Je?(Xe=t.jsx(Ut,{open:P,onOpenChange:Ue,children:Je}),e[111]=P,e[112]=Ue,e[113]=Je,e[114]=Xe):Xe=e[114];const et=!!R;let at;e[115]!==re?(at=ze=>{!re&&!ze&&I(null)},e[115]=re,e[116]=at):at=e[116];let lt;e[117]!==u?(lt=u("gitView.changes.revertDirectoryDialogTitle"),e[117]=u,e[118]=lt):lt=e[118];let Ze;e[119]!==lt?(Ze=t.jsx(Vt,{children:lt}),e[119]=lt,e[120]=Ze):Ze=e[120];let We;e[121]!==R||e[122]!==u?(We=R?R.count===1?u("gitView.changes.revertDirectoryDescriptionSingle",{count:R.count,path:R.path}):u("gitView.changes.revertDirectoryDescriptionPlural",{count:R.count,path:R.path}):null,e[121]=R,e[122]=u,e[123]=We):We=e[123];let pt;e[124]!==We?(pt=t.jsx(qt,{children:We}),e[124]=We,e[125]=pt):pt=e[125];let pe;e[126]!==Ze||e[127]!==pt?(pe=t.jsxs(_t,{children:[Ze,pt]}),e[126]=Ze,e[127]=pt,e[128]=pe):pe=e[128];let st;e[129]===Symbol.for("react.memo_cache_sentinel")?(st=()=>I(null),e[129]=st):st=e[129];let nt;e[130]!==u?(nt=u("gitView.common.cancel"),e[130]=u,e[131]=nt):nt=e[131];let Ge;e[132]!==re||e[133]!==nt?(Ge=t.jsx(G,{variant:"outline",size:"sm",onClick:st,disabled:re,children:nt}),e[132]=re,e[133]=nt,e[134]=Ge):Ge=e[134];let ft;e[135]!==ne?(ft=()=>{ne()},e[135]=ne,e[136]=ft):ft=e[136];const wt=re||!R;let Ct;e[137]!==re||e[138]!==u?(Ct=u(re?"gitView.changes.reverting":"gitView.changes.revertDirectory"),e[137]=re,e[138]=u,e[139]=Ct):Ct=e[139];let ae;e[140]!==ft||e[141]!==wt||e[142]!==Ct?(ae=t.jsx(G,{variant:"destructive",size:"sm",onClick:ft,disabled:wt,children:Ct}),e[140]=ft,e[141]=wt,e[142]=Ct,e[143]=ae):ae=e[143];let Ve;e[144]!==Ge||e[145]!==ae?(Ve=t.jsxs(Yt,{children:[Ge,ae]}),e[144]=Ge,e[145]=ae,e[146]=Ve):Ve=e[146];let tt;e[147]!==pe||e[148]!==Ve?(tt=t.jsxs(Bt,{className:"max-w-md",children:[pe,Ve]}),e[147]=pe,e[148]=Ve,e[149]=tt):tt=e[149];let Ye;e[150]!==et||e[151]!==at||e[152]!==tt?(Ye=t.jsx(Ut,{open:et,onOpenChange:at,children:tt}),e[150]=et,e[151]=at,e[152]=tt,e[153]=Ye):Ye=e[153];let yt;return e[154]!==Oe||e[155]!==Xe||e[156]!==Ye?(yt=t.jsxs(t.Fragment,{children:[Oe,Xe,Ye]}),e[154]=Oe,e[155]=Xe,e[156]=Ye,e[157]=yt):yt=e[157],yt};function pb(s){return s.gitChangesViewMode}function gb(s){return s.entries.length>0}function hb(s){return db(s.entries)}function fb(s){return s&&s.type==="file"?s.file.path:null}function xb(s){return!!s}function yb(s){return s.path}function bb(s){return s.path}function vb(s){return s.path}const br=38,va=200,jb=s=>{const e=rt.c(20),{value:n,onChange:a,placeholder:r,disabled:i,hasTouchInput:o,isMobile:d}=s,c=i===void 0?!1:i,f=o===void 0?!1:o,m=d===void 0?!1:d,{t:p}=dt(),u=l.useRef(null),S=Ke(wb);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{const z=u.current;if(!z)return;const R=document.activeElement===z,I=()=>{z.style.height=`${br}px`;const b=z.scrollHeight,L=Math.min(Math.max(b,br),va);z.style.height=`${L}px`,z.style.overflowY=b>va?"auto":"hidden",b>va&&!R&&(z.scrollTop=z.scrollHeight)};I();const v=window.requestAnimationFrame(I);return()=>{window.cancelAnimationFrame(v)}},e[0]=h):h=e[0];let g;e[1]!==n?(g=[n],e[1]=n,e[2]=g):g=e[2],l.useLayoutEffect(h,g);let x;e[3]!==a?(x=z=>a(z.target.value),e[3]=a,e[4]=x):x=e[4];let D;e[5]!==r||e[6]!==p?(D=r??p("gitView.commit.messagePlaceholder"),e[5]=r,e[6]=p,e[7]=D):D=e[7];const N=f?"on":"off",w=f?"sentences":"off",A=m||S,k=c&&"opacity-50";let j;e[8]!==k?(j=ce("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",k),e[8]=k,e[9]=j):j=e[9];let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y={minHeight:br,maxHeight:va},e[10]=y):y=e[10];let P;return e[11]!==c||e[12]!==A||e[13]!==j||e[14]!==x||e[15]!==D||e[16]!==N||e[17]!==w||e[18]!==n?(P=t.jsx("textarea",{ref:u,value:n,onChange:x,placeholder:D,rows:1,disabled:c,autoCorrect:N,autoCapitalize:w,spellCheck:A,className:j,style:y}),e[11]=c,e[12]=A,e[13]=j,e[14]=x,e[15]=D,e[16]=N,e[17]=w,e[18]=n,e[19]=P):P=e[19],P};function wb(s){return s.inputSpellcheckEnabled}const Nb=s=>{const e=rt.c(30),{highlights:n,onInsert:a}=s,{t:r}=dt();if(n.length===0)return null;let i;e[0]!==n||e[1]!==a?(i=()=>{a(n)},e[0]=n,e[1]=a,e[2]=i):i=e[2];const o=i;let d;e[3]!==r?(d=r("gitView.commit.aiHighlights.title"),e[3]=r,e[4]=d):d=e[4];let c;e[5]!==d?(c=t.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=c):c=e[6];let f;e[7]!==r?(f=r("gitView.commit.aiHighlights.insertAria"),e[7]=r,e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(M,{name:"arrow-down",className:"size-4"}),e[9]=m):m=e[9];let p;e[10]!==o||e[11]!==f?(p=t.jsx(At,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon",className:"size-6",onClick:o,"aria-label":f,children:m})}),e[10]=o,e[11]=f,e[12]=p):p=e[12];let u;e[13]!==r?(u=r("gitView.commit.aiHighlights.insertTooltip"),e[13]=r,e[14]=u):u=e[14];let S;e[15]!==u?(S=t.jsx(Et,{sideOffset:8,children:u}),e[15]=u,e[16]=S):S=e[16];let h;e[17]!==p||e[18]!==S?(h=t.jsxs(Dt,{children:[p,S]}),e[17]=p,e[18]=S,e[19]=h):h=e[19];let g;e[20]!==c||e[21]!==h?(g=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c,h]}),e[20]=c,e[21]=h,e[22]=g):g=e[22];let x;e[23]!==n?(x=n.map(kb),e[23]=n,e[24]=x):x=e[24];let D;e[25]!==x?(D=t.jsx("ul",{className:"space-y-1",children:x}),e[25]=x,e[26]=D):D=e[26];let N;return e[27]!==g||e[28]!==D?(N=t.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[g,D]}),e[27]=g,e[28]=D,e[29]=N):N=e[29],N};function kb(s,e){return t.jsx("li",{className:"typography-meta text-foreground",children:s},`${s}-${e}`)}const Uv=s=>{const e=rt.c(75),{stagedCount:n,commitMessage:a,onCommitMessageChange:r,generatedHighlights:i,onInsertHighlights:o,onGenerateMessage:d,isGeneratingMessage:c,onCommit:f,onCommitAndPush:m,commitAction:p,hasPendingIndexMutation:u,gitmojiEnabled:S,onOpenGitmojiPicker:h}=s,g=u===void 0?!1:u,{t:x}=dt(),D=n>0;let N;e[0]!==p||e[1]!==a||e[2]!==g||e[3]!==D?(N=a.trim()&&D&&p===null&&!g,e[0]=p,e[1]=a,e[2]=g,e[3]=D,e[4]=N):N=e[4];const w=N,{isMobile:A,hasTouchInput:k}=Cs();let j;e[5]!==x?(j=x("gitView.commit.title"),e[5]=x,e[6]=j):j=e[6];let y;e[7]!==j?(y=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:j}),e[7]=j,e[8]=y):y=e[8];let P;e[9]!==D||e[10]!==x?(P=D?null:t.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:x("gitView.commit.stageFilesHint")}),e[9]=D,e[10]=x,e[11]=P):P=e[11];let z;e[12]!==y||e[13]!==P?(z=t.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[y,P]}),e[12]=y,e[13]=P,e[14]=z):z=e[14];let R;e[15]!==i||e[16]!==o?(R=t.jsx(Nb,{highlights:i,onInsert:o}),e[15]=i,e[16]=o,e[17]=R):R=e[17];let I;e[18]!==x?(I=x("gitView.commit.messagePlaceholder"),e[18]=x,e[19]=I):I=e[19];const v=p!==null;let b;e[20]!==a||e[21]!==k||e[22]!==A||e[23]!==r||e[24]!==I||e[25]!==v?(b=t.jsx(jb,{value:a,onChange:r,placeholder:I,disabled:v,hasTouchInput:k,isMobile:A}),e[20]=a,e[21]=k,e[22]=A,e[23]=r,e[24]=I,e[25]=v,e[26]=b):b=e[26];let L;e[27]!==S||e[28]!==h||e[29]!==x?(L=S&&t.jsxs(G,{variant:"outline",size:"sm",onClick:h,className:"w-fit",type:"button",children:[t.jsx(M,{name:"emotion-happy",className:"size-4"}),x("gitView.commit.addGitmoji")]}),e[27]=S,e[28]=h,e[29]=x,e[30]=L):L=e[30];const E=c||p!==null||g||n===0;let J;e[31]!==x?(J=x("gitView.commit.generateAria"),e[31]=x,e[32]=J):J=e[32];let _;e[33]!==c?(_=c?t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(M,{name:"ai-generate-2",className:"size-4 text-primary"}),e[33]=c,e[34]=_):_=e[34];let Z;e[35]!==x?(Z=x("gitView.commit.generate"),e[35]=x,e[36]=Z):Z=e[36];let H;e[37]!==Z?(H=t.jsx("span",{className:"commit-actions__label",children:Z}),e[37]=Z,e[38]=H):H=e[38];let T;e[39]!==d||e[40]!==E||e[41]!==J||e[42]!==_||e[43]!==H?(T=t.jsxs(G,{variant:"outline",size:"sm",onClick:d,disabled:E,type:"button","aria-label":J,className:"commit-actions__btn",children:[_,H]}),e[39]=d,e[40]=E,e[41]=J,e[42]=_,e[43]=H,e[44]=T):T=e[44];let Y;e[45]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx("div",{className:"flex-1"}),e[45]=Y):Y=e[45];const F=!w||c;let V;e[46]!==x?(V=x("gitView.commit.commitAria"),e[46]=x,e[47]=V):V=e[47];let Q;e[48]!==p||e[49]!==x?(Q=p==="commit"?t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"commit-actions__label",children:x("gitView.commit.committing")})]}):t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"git-commit",className:"size-4"}),t.jsx("span",{className:"commit-actions__label",children:x("gitView.commit.commit")})]}),e[48]=p,e[49]=x,e[50]=Q):Q=e[50];let ie;e[51]!==f||e[52]!==F||e[53]!==V||e[54]!==Q?(ie=t.jsx(G,{size:"sm",variant:"outline",onClick:f,disabled:F,className:"commit-actions__btn whitespace-nowrap","aria-label":V,children:Q}),e[51]=f,e[52]=F,e[53]=V,e[54]=Q,e[55]=ie):ie=e[55];let X;e[56]!==w||e[57]!==p||e[58]!==c||e[59]!==A||e[60]!==m||e[61]!==x?(X=A?t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(G,{variant:"default",size:"sm",onClick:()=>m(),disabled:!w||c,className:"h-7 w-7 p-0","aria-label":x("gitView.commit.pushAria"),children:p==="commitAndPush"?t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(M,{name:"arrow-up",className:"size-3.5"})})}),t.jsx(Et,{side:"top",children:t.jsx("p",{children:x("gitView.commit.push")})})]}):t.jsx(G,{size:"sm",variant:"default",onClick:()=>m(),disabled:!w||c,className:"commit-actions__btn","aria-label":x("gitView.commit.pushAria"),children:p==="commitAndPush"?t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:x("gitView.commit.pushing")})]}):t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"arrow-up",className:"size-3.5"}),t.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:x("gitView.commit.push")})]})}),e[56]=w,e[57]=p,e[58]=c,e[59]=A,e[60]=m,e[61]=x,e[62]=X):X=e[62];let se;e[63]!==T||e[64]!==ie||e[65]!==X?(se=t.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[T,Y,ie,X]}),e[63]=T,e[64]=ie,e[65]=X,e[66]=se):se=e[66];let me;e[67]!==b||e[68]!==L||e[69]!==se||e[70]!==R?(me=t.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[R,b,L,se]}),e[67]=b,e[68]=L,e[69]=se,e[70]=R,e[71]=me):me=e[71];let oe;return e[72]!==me||e[73]!==z?(oe=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[z,me]}),e[72]=me,e[73]=z,e[74]=oe):oe=e[74],oe},Sb=s=>{const e=rt.c(41),{syncAction:n,remotes:a,onFetch:r,onSync:i,onRemoveRemote:o,disabled:d,removingRemoteName:c,aheadCount:f,behindCount:m,trackingRemoteName:p,hasUncommittedChanges:u}=s,S=a===void 0?[]:a,h=c===void 0?null:c,g=f===void 0?0:f,x=m===void 0?0:m,D=u===void 0?!1:u,{t:N}=dt(),w=l.useRef(!1),A=!!h,k=S.find(re=>re.name===p)??S[0],j=x>0&&D,y=d||n!==null||A||!k||j,P=d||n!==null||A||S.length===0,z=g>0||x>0;let R;e[0]!==N?(R=N("gitView.sync.sync"),e[0]=N,e[1]=R):R=e[1];const I=x>0?`↓${x}`:null,v=g>0?`↑${g}`:null;let b;e[2]!==R||e[3]!==I||e[4]!==v?(b=[R,I,v].filter(Boolean),e[2]=R,e[3]=I,e[4]=v,e[5]=b):b=e[5];const L=b.join(" "),E=j?N("gitView.sync.commitOrStashTooltip"):k?z?N("gitView.sync.syncChangesTooltip",{ahead:g,behind:x}):N("gitView.sync.syncChanges"):N("gitView.sync.noRemoteTooltip"),J=()=>{k&&i(k)},_="inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden";let Z;e[6]===Symbol.for("react.memo_cache_sentinel")?(Z=ce("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[6]=Z):Z=e[6];let H;e[7]!==N?(H=N("gitView.sync.syncChanges"),e[7]=N,e[8]=H):H=e[8];let T;e[9]!==n?(T=n==="sync"?t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(M,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=T):T=e[10];let Y;e[11]!==L?(Y=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:L}),e[11]=L,e[12]=Y):Y=e[12];let F;e[13]!==J||e[14]!==y||e[15]!==H||e[16]!==T||e[17]!==Y?(F=t.jsx(At,{asChild:!0,children:t.jsxs("button",{type:"button",onClick:J,disabled:y,className:Z,"aria-label":H,children:[T,Y]})}),e[13]=J,e[14]=y,e[15]=H,e[16]=T,e[17]=Y,e[18]=F):F=e[18];let V;e[19]!==E?(V=t.jsx(Et,{sideOffset:8,children:E}),e[19]=E,e[20]=V):V=e[20];let Q;e[21]!==F||e[22]!==V?(Q=t.jsxs(Dt,{children:[F,V]}),e[21]=F,e[22]=V,e[23]=Q):Q=e[23];const ie=us;let X;e[24]===Symbol.for("react.memo_cache_sentinel")?(X=ce("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[24]=X):X=e[24];let se;e[25]!==N?(se=N("gitView.sync.moreActionsAria"),e[25]=N,e[26]=se):se=e[26];let me;e[27]===Symbol.for("react.memo_cache_sentinel")?(me=t.jsx(M,{name:"arrow-down-s",className:"size-4"}),e[27]=me):me=e[27];let oe;e[28]!==P||e[29]!==se?(oe=t.jsx(ds,{asChild:!0,children:t.jsx("button",{type:"button",className:X,disabled:P,"aria-label":se,children:me})}),e[28]=P,e[29]=se,e[30]=oe):oe=e[30];const xe=ms,we="start",he=-40,Ie="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",ve=S.map(re=>t.jsx(js,{onSelect:ge=>{if(w.current){ge.preventDefault(),w.current=!1;return}r(re)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(M,{name:"refresh",className:"size-4 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:N("gitView.sync.fetchFromRemote",{name:re.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:re.fetchUrl})]})}),o&&re.name!==p?t.jsx(G,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||A,onPointerDown:ge=>{w.current=!0,ge.preventDefault(),ge.stopPropagation()},onClick:ge=>{w.current=!0,ge.preventDefault(),ge.stopPropagation(),o(re)},"aria-label":N("gitView.header.removeRemoteAria",{name:re.name}),title:N("gitView.header.removeRemoteTitle",{name:re.name}),children:h===re.name?t.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(M,{name:"close",className:"size-3.5"})}):null]})},re.name));let ye;e[31]!==xe||e[32]!==ve?(ye=t.jsx(xe,{align:we,alignOffset:he,className:Ie,children:ve}),e[31]=xe,e[32]=ve,e[33]=ye):ye=e[33];let be;e[34]!==ie||e[35]!==oe||e[36]!==ye?(be=t.jsxs(ie,{children:[oe,ye]}),e[34]=ie,e[35]=oe,e[36]=ye,e[37]=be):be=e[37];let te;return e[38]!==Q||e[39]!==be?(te=t.jsxs("div",{className:_,children:[Q,be]}),e[38]=Q,e[39]=be,e[40]=te):te=e[40],te};function Cb(s){const e=rt.c(85),{draft:n,onEdit:a,onDelete:r,className:i,maxWidth:o}=s,{t:d}=dt(),f=za()?.currentTheme,[m,p]=je.useState(!1),[u,S]=je.useState(!1),h=typeof n.text=="string"?n.text:"";let g;e[0]!==h?(g=h.length>150||h.split(`
|
|
30
|
-
`).length>3,e[0]=h,e[1]=g):g=e[1];const x=g;let D;e[2]!==i?(D=ce("rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden transition-all duration-200",i),e[2]=i,e[3]=D):D=e[3];const N=f?.colors?.surface?.elevated,w=f?.colors?.interactive?.border,A=o?`${Math.max(200,Math.floor(o))}px`:void 0;let k;e[4]!==N||e[5]!==w||e[6]!==A?(k={backgroundColor:N,borderColor:w,maxWidth:A},e[4]=N,e[5]=w,e[6]=A,e[7]=k):k=e[7];let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=U=>{U.preventDefault(),S(!0)},e[8]=j):j=e[8];let y;e[9]!==D||e[10]!==k?(y=t.jsx("div",{className:D,style:k,"data-comment-card":"true",onContextMenu:j}),e[9]=D,e[10]=k,e[11]=y):y=e[11];let P;e[12]!==n.fileLabel?(P=t.jsx("span",{className:"truncate max-w-[200px]",title:n.fileLabel,children:n.fileLabel}),e[12]=n.fileLabel,e[13]=P):P=e[13];let z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("span",{children:"•"}),e[14]=z):z=e[14];let R;e[15]!==n.endLine||e[16]!==n.startLine||e[17]!==d?(R=d("inlineComment.range.lines",{start:n.startLine,end:n.endLine}),e[15]=n.endLine,e[16]=n.startLine,e[17]=d,e[18]=R):R=e[18];let I;e[19]!==R?(I=t.jsx("span",{children:R}),e[19]=R,e[20]=I):I=e[20];let v;e[21]!==n.side?(v=n.side&&t.jsxs("span",{children:["(",n.side,")"]}),e[21]=n.side,e[22]=v):v=e[22];let b;e[23]!==I||e[24]!==v||e[25]!==P?(b=t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-1.5",children:[P,z,I,v]}),e[23]=I,e[24]=v,e[25]=P,e[26]=b):b=e[26];const L=m||!x,E=!m&&x&&"line-clamp-3";let J;e[27]!==E?(J=ce("text-sm whitespace-pre-wrap break-words leading-relaxed",E),e[27]=E,e[28]=J):J=e[28];let _;e[29]!==h||e[30]!==J?(_=t.jsx("div",{className:J,children:h}),e[29]=h,e[30]=J,e[31]=_):_=e[31];let Z;e[32]!==x||e[33]!==m||e[34]!==d?(Z=x&&t.jsx(hn,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-6 px-0 mt-1 text-xs text-muted-foreground hover:text-foreground w-full justify-start",children:m?t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"arrow-up-s",className:"size-3 mr-1"}),d("inlineComment.actions.showLess")]}):t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"arrow-down-s",className:"size-3 mr-1"}),d("inlineComment.actions.showMore")]})})}),e[32]=x,e[33]=m,e[34]=d,e[35]=Z):Z=e[35];let H;e[36]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsx(fn,{}),e[36]=H):H=e[36];let T;e[37]!==L||e[38]!==_||e[39]!==Z?(T=t.jsxs(gn,{open:L,onOpenChange:p,children:[_,Z,H]}),e[37]=L,e[38]=_,e[39]=Z,e[40]=T):T=e[40];let Y;e[41]!==b||e[42]!==T?(Y=t.jsxs("div",{className:"flex-1 min-w-0",children:[b,T]}),e[41]=b,e[42]=T,e[43]=Y):Y=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(ds,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground",children:t.jsx(M,{name:"more",className:"size-4"})})}),e[44]=F):F=e[44];let V;e[45]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(M,{name:"edit",className:"size-4 mr-2"}),e[45]=V):V=e[45];let Q;e[46]!==d?(Q=d("inlineComment.actions.editComment"),e[46]=d,e[47]=Q):Q=e[47];let ie;e[48]!==a||e[49]!==Q?(ie=t.jsxs(js,{onClick:a,children:[V,Q]}),e[48]=a,e[49]=Q,e[50]=ie):ie=e[50];let X;e[51]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx(M,{name:"delete-bin",className:"size-4 mr-2"}),e[51]=X):X=e[51];let se;e[52]!==d?(se=d("inlineComment.actions.deleteComment"),e[52]=d,e[53]=se):se=e[53];let me;e[54]!==r||e[55]!==se?(me=t.jsxs(js,{onClick:r,className:"text-destructive",children:[X,se]}),e[54]=r,e[55]=se,e[56]=me):me=e[56];let oe;e[57]!==ie||e[58]!==me?(oe=t.jsxs(us,{children:[F,t.jsxs(ms,{align:"end",children:[ie,me]})]}),e[57]=ie,e[58]=me,e[59]=oe):oe=e[59];let xe;e[60]!==Y||e[61]!==oe?(xe=t.jsxs("div",{className:"flex items-start justify-between gap-2 p-3",children:[Y,oe]}),e[60]=Y,e[61]=oe,e[62]=xe):xe=e[62];let we;e[63]!==xe||e[64]!==y?(we=t.jsx(sn,{render:y,children:xe}),e[63]=xe,e[64]=y,e[65]=we):we=e[65];let he;e[66]===Symbol.for("react.memo_cache_sentinel")?(he=t.jsx(M,{name:"edit",className:"size-4 mr-2"}),e[66]=he):he=e[66];let Ie;e[67]!==d?(Ie=d("inlineComment.actions.editComment"),e[67]=d,e[68]=Ie):Ie=e[68];let ve;e[69]!==a||e[70]!==Ie?(ve=t.jsxs(Ws,{onClick:a,children:[he,Ie]}),e[69]=a,e[70]=Ie,e[71]=ve):ve=e[71];let ye;e[72]===Symbol.for("react.memo_cache_sentinel")?(ye=t.jsx(M,{name:"delete-bin",className:"size-4 mr-2"}),e[72]=ye):ye=e[72];let be;e[73]!==d?(be=d("inlineComment.actions.deleteComment"),e[73]=d,e[74]=be):be=e[74];let te;e[75]!==r||e[76]!==be?(te=t.jsxs(Ws,{onClick:r,className:"text-destructive focus:text-destructive",children:[ye,be]}),e[75]=r,e[76]=be,e[77]=te):te=e[77];let re;e[78]!==ve||e[79]!==te?(re=t.jsxs(nn,{children:[ve,te]}),e[78]=ve,e[79]=te,e[80]=re):re=e[80];let ge;return e[81]!==u||e[82]!==we||e[83]!==re?(ge=t.jsxs(tn,{open:u,onOpenChange:S,children:[we,re]}),e[81]=u,e[82]=we,e[83]=re,e[84]=ge):ge=e[84],ge}function tl(s){const e=rt.c(62),{initialText:n,onTextChange:a,onSave:r,onCancel:i,fileLabel:o,lineRange:d,isEditing:c,className:f,maxWidth:m}=s,p=n===void 0?"":n,u=c===void 0?!1:c,{t:S}=dt(),g=za()?.currentTheme,{isMobile:x}=Cs(),[D,N]=l.useState(p),w=je.useRef(null);let A;e[0]!==a?(A=ne=>{N(ne),a?.(ne)},e[0]=a,e[1]=A):A=e[1];const k=A,j=je.useRef(d);let y,P;e[2]!==d?(y=()=>{d&&(j.current=d)},P=[d],e[2]=d,e[3]=y,e[4]=P):(y=e[3],P=e[4]),je.useEffect(y,P);const z=Rb,R=z(d);let I,v;e[5]!==x?(I=()=>{const ne=w.current;if(!ne)return;const ue=ne.closest(".overlay-scrollbar-container"),Me=ue?.scrollTop??window.scrollY,ke=ue?.scrollLeft??window.scrollX;if(x){ne.scrollIntoView({behavior:"auto",block:"nearest"});try{ne.focus({preventScroll:!0})}catch{ne.focus()}return}try{ne.focus({preventScroll:!0})}catch{ne.focus()}const De=ne.value.length;try{ne.setSelectionRange(De,De)}catch{}requestAnimationFrame(()=>{ue?(ue.scrollTop=Me,ue.scrollLeft=ke):window.scrollTo({top:Me,left:ke})})},v=[x],e[5]=x,e[6]=I,e[7]=v):(I=e[6],v=e[7]),je.useEffect(I,v);let b;e[8]!==i||e[9]!==r||e[10]!==D?(b=ne=>{(ne.metaKey||ne.ctrlKey)&&ne.key==="Enter"?(ne.preventDefault(),D.trim()&&r(D,z(j.current))):ne.key==="Escape"&&(ne.preventDefault(),i())},e[8]=i,e[9]=r,e[10]=D,e[11]=b):b=e[11];const L=b;let E;e[12]!==r||e[13]!==D?(E=ne=>{ne.stopPropagation(),D.trim()&&r(D,z(j.current))},e[12]=r,e[13]=D,e[14]=E):E=e[14];const J=E;let _;e[15]!==f?(_=ce("rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden animate-in fade-in zoom-in-95 duration-200",f),e[15]=f,e[16]=_):_=e[16];const Z=g?.colors?.surface?.elevated,H=g?.colors?.interactive?.border,T=m?`${Math.max(200,Math.floor(m))}px`:void 0;let Y;e[17]!==Z||e[18]!==H||e[19]!==T?(Y={backgroundColor:Z,borderColor:H,maxWidth:T},e[17]=Z,e[18]=H,e[19]=T,e[20]=Y):Y=e[20];const F="true",V=Mb,Q=Eb,ie="p-3",X=(o||d)&&t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-2",children:[o&&t.jsx("span",{className:"truncate max-w-[200px]",children:o}),o&&d&&t.jsx("span",{children:"•"}),R&&t.jsx("span",{children:S("inlineComment.range.lines",{start:R.start,end:R.end})})]});let se;e[21]!==k?(se=ne=>k(ne.target.value),e[21]=k,e[22]=se):se=e[22];let me;e[23]!==x||e[24]!==S?(me=S(x?"inlineComment.input.placeholderShort":"inlineComment.input.placeholder"),e[23]=x,e[24]=S,e[25]=me):me=e[25];let oe;e[26]!==L||e[27]!==se||e[28]!==me||e[29]!==D?(oe=t.jsx(ps,{simple:!0,ref:w,value:D,onChange:se,onKeyDown:L,placeholder:me,outerClassName:"rounded-[var(--radius-xl)] bg-[var(--surface-subtle)] ring-1 ring-inset ring-border/60 focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]",className:"min-h-[80px] px-3 py-2.5 text-sm resize-y"}),e[26]=L,e[27]=se,e[28]=me,e[29]=D,e[30]=oe):oe=e[30];let xe;e[31]!==S?(xe=S("inlineComment.actions.cancel"),e[31]=S,e[32]=xe):xe=e[32];let we;e[33]!==i||e[34]!==xe?(we=t.jsx(G,{variant:"ghost",size:"sm",onClick:i,onPointerDown:Ab,onTouchStart:Db,className:"h-8 text-muted-foreground hover:text-foreground",children:xe}),e[33]=i,e[34]=xe,e[35]=we):we=e[35];let he;e[36]!==D?(he=D.trim(),e[36]=D,e[37]=he):he=e[37];const Ie=!he,ve=g?.colors?.status?.success,ye=g?.colors?.status?.successForeground;let be;e[38]!==ve||e[39]!==ye?(be={backgroundColor:ve,color:ye},e[38]=ve,e[39]=ye,e[40]=be):be=e[40];let te;e[41]!==u||e[42]!==S?(te=S(u?"inlineComment.actions.save":"inlineComment.actions.comment"),e[41]=u,e[42]=S,e[43]=te):te=e[43];let re;e[44]!==J||e[45]!==Ie||e[46]!==be||e[47]!==te?(re=t.jsx(G,{size:"sm",onClick:J,onPointerDown:Ib,onTouchStart:Pb,disabled:Ie,className:"h-8 min-w-[80px]",style:be,children:te}),e[44]=J,e[45]=Ie,e[46]=be,e[47]=te,e[48]=re):re=e[48];let ge;e[49]!==we||e[50]!==re?(ge=t.jsxs("div",{className:"flex items-center justify-end gap-2 mt-3",children:[we,re]}),e[49]=we,e[50]=re,e[51]=ge):ge=e[51];let U;e[52]!==X||e[53]!==oe||e[54]!==ge?(U=t.jsxs("div",{className:ie,children:[X,oe,ge]}),e[52]=X,e[53]=oe,e[54]=ge,e[55]=U):U=e[55];let ee;return e[56]!==_||e[57]!==Y||e[58]!==V||e[59]!==Q||e[60]!==U?(ee=t.jsx("div",{className:_,style:Y,"data-comment-input":F,onPointerDown:V,onTouchStart:Q,children:U}),e[56]=_,e[57]=Y,e[58]=V,e[59]=Q,e[60]=U,e[61]=ee):ee=e[61],ee}function Pb(s){return s.stopPropagation()}function Ib(s){return s.stopPropagation()}function Db(s){return s.stopPropagation()}function Ab(s){return s.stopPropagation()}function Eb(s){return s.stopPropagation()}function Mb(s){return s.stopPropagation()}function Rb(s){if(!s)return;const e=Math.min(s.start,s.end),n=Math.max(s.start,s.end);return{...s,start:e,end:n}}const Tb=s=>{const e=Math.min(s.startLine,s.endLine),n=Math.max(s.startLine,s.endLine);return{...s,startLine:e,endLine:n}},sl=s=>{const e=Math.min(s.start,s.end),n=Math.max(s.start,s.end);return{...s,start:e,end:n}};function Fb(s){const e=rt.c(40),{t:n}=dt(),{source:a,fileLabel:r,language:i,getCodeForRange:o,toStoreRange:d,fromDraftRange:c}=s,f=Ps(Ub),m=Ps($b),p=aa(Kb),u=aa(zb),S=aa(Ob),h=aa(Lb),[g,x]=l.useState(null),[D,N]=l.useState(""),[w,A]=l.useState(null),k=f??(m?"draft":null);let j;e:{if(!k||!r){let F;e[0]===Symbol.for("react.memo_cache_sentinel")?(F=[],e[0]=F):F=e[0],j=F;break e}let H;e[1]!==h||e[2]!==k?(H=h[k]??[],e[1]=h,e[2]=k,e[3]=H):H=e[3];const T=H;let Y;if(e[4]!==r||e[5]!==T||e[6]!==a){let F;e[8]!==r||e[9]!==a?(F=V=>V.source===a&&V.fileLabel===r,e[8]=r,e[9]=a,e[10]=F):F=e[10],Y=T.filter(F),e[4]=r,e[5]=T,e[6]=a,e[7]=Y}else Y=e[7];j=Y}const y=j;let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{x(null),N(""),A(null)},e[11]=P):P=e[11];const z=P;let R;e[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{z()},e[12]=R):R=e[12];const I=R;let v;e[13]!==c?(v=H=>{const T=sl(c(H));x(T),N(H.text),A(H.id)},e[13]=c,e[14]=v):v=e[14];const b=v;let L;e[15]!==w||e[16]!==S?(L=H=>{S(H.sessionKey,H.id),w===H.id&&z()},e[15]=w,e[16]=S,e[17]=L):L=e[17];const E=L;let J;e[18]!==p||e[19]!==w||e[20]!==r||e[21]!==o||e[22]!==i||e[23]!==g||e[24]!==k||e[25]!==a||e[26]!==n||e[27]!==d||e[28]!==u?(J=(H,T)=>{const Y=T??g,F=H.trim();if(!Y||!F||!r)return;if(!k){B.error(n("inlineComment.toast.selectSessionToSave"));return}const V=sl(Y),Q=Tb(d(V)),ie=o(V);w?u(k,w,{fileLabel:r,startLine:Q.startLine,endLine:Q.endLine,side:Q.side,code:ie,language:i,text:F}):p({sessionKey:k,source:a,fileLabel:r,startLine:Q.startLine,endLine:Q.endLine,side:Q.side,code:ie,language:i,text:F}),z()},e[18]=p,e[19]=w,e[20]=r,e[21]=o,e[22]=i,e[23]=g,e[24]=k,e[25]=a,e[26]=n,e[27]=d,e[28]=u,e[29]=J):J=e[29];const _=J;let Z;return e[30]!==D||e[31]!==E||e[32]!==y||e[33]!==w||e[34]!==c||e[35]!==_||e[36]!==g||e[37]!==k||e[38]!==b?(Z={sessionKey:k,drafts:y,selection:g,setSelection:x,commentText:D,setCommentText:N,editingDraftId:w,setEditingDraftId:A,reset:z,cancel:I,startEdit:b,deleteDraft:E,saveComment:_,fromDraftRange:c},e[30]=D,e[31]=E,e[32]=y,e[33]=w,e[34]=c,e[35]=_,e[36]=g,e[37]=k,e[38]=b,e[39]=Z):Z=e[39],Z}function Lb(s){return s.drafts}function Ob(s){return s.removeDraft}function zb(s){return s.updateDraft}function Kb(s){return s.addDraft}function $b(s){return s.newSessionDraft?.open}function Ub(s){return s.currentSessionId}const Ea=s=>{if(s.type==="new"){const e=Math.min(s.selection.start,s.selection.end),n=Math.max(s.selection.start,s.selection.end);return`new-comment-${s.selection.side??"additions"}-${e}-${n}`}return`draft-${s.draft.id}`},Bb=s=>{const{drafts:e,editingDraftId:n,selection:a}=s,r=[];for(const i of e){if(!Number.isFinite(i.endLine))continue;const o=Math.max(1,Math.floor(i.endLine)),d=i.side==="original"?"deletions":"additions";r.push({lineNumber:o,side:d,metadata:{type:i.id===n?"edit":"saved",draft:i}})}return a&&!n&&r.push({lineNumber:Math.max(a.start,a.end),side:a.side??"additions",metadata:{type:"new",selection:a}}),r};function Vb(s){const e=s.trim();if(!e)return null;if(/^-?\d+(\.\d+)?$/.test(e)){const n=Number.parseFloat(e);return Number.isFinite(n)?n:null}if(e.endsWith("px")){const n=Number.parseFloat(e.slice(0,-2));return Number.isFinite(n)?n:null}return null}function nl(s){if(!(!s||s<=0))return Math.max(200,Math.floor(s))}function _b(s){const{diffRootRef:e,drafts:n,selection:a,editingDraftId:r,commentText:i,onTextChange:o,fileLabel:d,onSave:c,onCancel:f,onEdit:m,onDelete:p}=s,[u,S]=l.useState(0),[h,g]=l.useState(null),x=l.useMemo(()=>!a||r?null:Ea({type:"new",selection:a}),[r,a]),D=l.useMemo(()=>{const A=n.map(k=>Ea({type:k.id===r?"edit":"saved",draft:k}));return x&&A.push(x),A},[n,r,x]),N=l.useCallback(A=>{const k=e.current;if(!k)return null;const j=k.querySelector("diffs-container");if(!(j instanceof HTMLElement))return null;const y=j.querySelector(`[data-annotation-id="${A}"]`);if(y instanceof HTMLElement)return y;const P=j.shadowRoot;return P?P.querySelector(`[data-annotation-id="${A}"]`):null},[e]);l.useEffect(()=>{if(D.length===0)return;let A=!1,k=0;const j=12,y=()=>{A||D.every(z=>!!N(z))||k>=j||(k+=1,requestAnimationFrame(()=>{A||(S(z=>z+1),y())}))};return y(),()=>{A=!0}},[D,N]),l.useEffect(()=>{const A=e.current;if(!A)return;const k=()=>{const y=getComputedStyle(A),P=Vb(y.getPropertyValue("--oc-context-panel-width")),z=A.getBoundingClientRect(),R=P??z.width;g(R>0?R:null)};k();const j=new ResizeObserver(()=>{k()});return j.observe(A),window.addEventListener("resize",k),()=>{j.disconnect(),window.removeEventListener("resize",k)}},[e]);const w=l.useCallback(A=>{const j=e.current?.getBoundingClientRect(),y=A.closest("[data-annotation-content]"),P=y instanceof HTMLElement?y.getBoundingClientRect():A.getBoundingClientRect(),z=[P.width];j&&z.push(j.right-P.left);const R=z.filter(I=>Number.isFinite(I)&&I>0);return R.length>0?nl(Math.min(...R)):nl(h)},[e,h]);return t.jsxs(t.Fragment,{children:[n.map(A=>{const k=Ea({type:A.id===r?"edit":"saved",draft:A}),j=N(k);if(!j)return null;const y=w(j);return A.id===r?wa.createPortal(t.jsx(tl,{initialText:i,onTextChange:o,fileLabel:d,lineRange:{start:A.startLine,end:A.endLine,side:A.side==="original"?"deletions":"additions"},isEditing:!0,onSave:c,onCancel:f,maxWidth:y}),j,`draft-edit-${A.id}`):wa.createPortal(t.jsx(Cb,{draft:A,onEdit:()=>m(A),onDelete:()=>p(A),maxWidth:y}),j,`draft-card-${A.id}`)}),a&&!r&&x&&(()=>{const A=N(x);if(!A)return null;const k=w(A);return wa.createPortal(t.jsx(tl,{initialText:i,onTextChange:o,fileLabel:d,lineRange:a,isEditing:!1,onSave:c,onCancel:f,maxWidth:k}),A,x)})()]})}const al=5e5,Hb=`
|
|
31
|
-
:host {
|
|
32
|
-
font-family: var(--font-mono);
|
|
33
|
-
font-size: var(--text-code);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
pre, [data-code] {
|
|
37
|
-
font-family: var(--font-mono);
|
|
38
|
-
font-size: var(--text-code);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* Mobile touch selection support */
|
|
42
|
-
[data-line-number] {
|
|
43
|
-
touch-action: manipulation;
|
|
44
|
-
-webkit-tap-highlight-color: transparent;
|
|
45
|
-
cursor: pointer;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/* Ensure interactive line numbers work on touch */
|
|
49
|
-
pre[data-interactive-line-numbers] [data-line-number] {
|
|
50
|
-
touch-action: manipulation;
|
|
51
|
-
}
|
|
52
|
-
`,Wb=`
|
|
53
|
-
${Hb}
|
|
54
|
-
|
|
55
|
-
:host {
|
|
56
|
-
--diffs-bg-separator-override: var(--surface-elevated);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
[data-diff-header],
|
|
60
|
-
[data-diff] {
|
|
61
|
-
[data-separator] {
|
|
62
|
-
height: 24px !important;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
[data-separator="line-info-basic"] {
|
|
67
|
-
height: 24px !important;
|
|
68
|
-
background: var(--diffs-bg) !important;
|
|
69
|
-
position: relative;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
[data-diff-type="single"] [data-gutter],
|
|
73
|
-
[data-diff-type="split"] [data-deletions] [data-gutter] {
|
|
74
|
-
[data-separator-wrapper] {
|
|
75
|
-
position: absolute;
|
|
76
|
-
left: 100%;
|
|
77
|
-
display: flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
gap: unset;
|
|
80
|
-
width: max-content;
|
|
81
|
-
background: transparent;
|
|
82
|
-
color: var(--diffs-fg-number);
|
|
83
|
-
font-family: var(--diffs-header-font-family, var(--font-sans));
|
|
84
|
-
font-size: 0.75rem;
|
|
85
|
-
line-height: 1;
|
|
86
|
-
margin-left: calc(-2ch - 2px);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
[data-separator-wrapper][data-separator-multi-button] {
|
|
90
|
-
margin-left: calc(-3ch - 2px);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[data-expand-button],
|
|
94
|
-
[data-separator-content] {
|
|
95
|
-
display: block;
|
|
96
|
-
align-self: unset;
|
|
97
|
-
min-width: unset;
|
|
98
|
-
min-height: unset;
|
|
99
|
-
padding: 0;
|
|
100
|
-
flex-shrink: 0;
|
|
101
|
-
grid-column: unset;
|
|
102
|
-
border: none;
|
|
103
|
-
width: auto;
|
|
104
|
-
height: auto;
|
|
105
|
-
background-color: transparent;
|
|
106
|
-
color: inherit;
|
|
107
|
-
font: inherit;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
[data-expand-button]:not([data-expand-all-button]) {
|
|
111
|
-
&[data-expand-down]::before {
|
|
112
|
-
content: '\\2191';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&[data-expand-up]::before {
|
|
116
|
-
content: '\\2193';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
&[data-expand-both]::before {
|
|
120
|
-
content: '\\2195';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
svg {
|
|
124
|
-
display: none;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
[data-separator-content] {
|
|
129
|
-
background: transparent;
|
|
130
|
-
margin-left: calc(2px + 1ch);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
[data-expand-all-button] {
|
|
134
|
-
position: relative;
|
|
135
|
-
margin-left: 14px;
|
|
136
|
-
text-transform: lowercase;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
[data-expand-all-button]::before {
|
|
140
|
-
content: '';
|
|
141
|
-
display: block;
|
|
142
|
-
position: absolute;
|
|
143
|
-
top: 50%;
|
|
144
|
-
left: -8px;
|
|
145
|
-
margin-top: -1px;
|
|
146
|
-
width: 3px;
|
|
147
|
-
height: 3px;
|
|
148
|
-
border-radius: 2px;
|
|
149
|
-
background-color: var(--diffs-fg-number);
|
|
150
|
-
pointer-events: none;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
[data-separator-content]:hover,
|
|
154
|
-
[data-expand-button]:hover,
|
|
155
|
-
[data-expand-all-button]:hover {
|
|
156
|
-
color: var(--diffs-fg);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
[data-expand-all-button]:hover {
|
|
160
|
-
text-decoration: underline;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
`;function qb(s){let e=2166136261;for(let n=0;n<s.length;n+=1)e^=s.charCodeAt(n),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function rl(s){const e=s.length>400?`${s.slice(0,200)}${s.slice(-200)}`:s;return`${s.length}:${qb(e)}`}const Gb=(s,e,n,a)=>{const r=a.side==="deletions",o=(n?(r?n.deletionLines:n.additionLines).join(""):r?s:e).split(`
|
|
164
|
-
`),d=Math.min(a.start,a.end),c=Math.max(a.start,a.end),f=Math.max(1,d),m=Math.min(o.length,c);return f>m?"":o.slice(f-1,m).join(`
|
|
165
|
-
`)},Jb=(s,e)=>s===e?!0:!s||!e?!1:s.start===e.start&&s.end===e.end&&s.side===e.side,Qb=s=>s==="auto"||s==="scroll"||s==="overlay",Yb=s=>{let e=s?.parentElement??null;for(;e;){const n=window.getComputedStyle(e);if(Qb(n.overflowY))return e;e=e.parentElement}return null},Xb=(s,e)=>{if(!s||!e||typeof window>"u")return()=>{};const n=Yb(s);if(!n)return()=>{};const a=e.getBoundingClientRect().height;if(!a)return()=>{};const r=s.getBoundingClientRect().top-n.getBoundingClientRect().top,i=e.style.minHeight;e.style.minHeight=`${Math.ceil(a)}px`;let o=!1;return()=>{if(o)return;o=!0,e.style.minHeight=i;const c=s.getBoundingClientRect().top-n.getBoundingClientRect().top-r;c&&(n.scrollTop+=c)}},Zb=(s,e)=>{if(typeof window>"u")return()=>{};let n=null,a=null,r=!1;const i=()=>{r||(a?.disconnect(),a=null,n=window.requestAnimationFrame(()=>{n=window.requestAnimationFrame(()=>{r||e()})}))},o=()=>s.querySelector("diffs-container")?.shadowRoot??void 0,d=(c=o())=>!!c?.querySelector("[data-line]");return d()?i():typeof MutationObserver<"u"?(a=new MutationObserver(()=>{const c=o();if(c){if(d(c)){i();return}a?.disconnect(),a=new MutationObserver(()=>{d(c)&&i()}),a.observe(c,{childList:!0,subtree:!0})}}),a.observe(s,{childList:!0,subtree:!0})):n=window.requestAnimationFrame(i),()=>{r=!0,a?.disconnect(),n!==null&&window.cancelAnimationFrame(n)}},ja=new WeakMap,ev={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function tv(s){const e=s.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const n=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:n instanceof HTMLElement?n:void 0}}return{key:document,root:document,content:void 0}}function sv(s){if(typeof document>"u")return null;const e=tv(s);let n=ja.get(e.key);if(!n){const r=new od;r.setup(e.root,e.content),n={virtualizer:r,refs:0},ja.set(e.key,n)}n.refs+=1;let a=!1;return{virtualizer:n.virtualizer,root:e.root,release:()=>{if(a)return;a=!0;const r=ja.get(e.key);r&&(r.refs-=1,!(r.refs>0)&&(r.virtualizer.cleanUp(),ja.delete(e.key)))}}}const nv=(s,e,n)=>{if(typeof window>"u")return()=>{};const a=[],r=()=>{try{s.rerender()}catch{}const i=e?.root;i instanceof HTMLElement?i.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),n()};return a.push(window.requestAnimationFrame(r)),a.push(window.requestAnimationFrame(()=>{a.push(window.requestAnimationFrame(r))})),()=>{for(const i of a)window.cancelAnimationFrame(i)}},Bv=({original:s,modified:e,fileDiff:n,language:a,fileName:r,renderSideBySide:i,wrapLines:o,layout:d="fill",enableComments:c=!0})=>{const f=za(),m=f?.currentTheme.metadata.variant==="dark",p=f?.availableThemes.find(U=>U.metadata.id===f.lightThemeId)??Ra(!1),u=f?.availableThemes.find(U=>U.metadata.id===f.darkThemeId)??Ra(!0),{isMobile:S}=Cs(),h=Fb({source:"diff",fileLabel:r||"unknown",language:a,getCodeForRange:U=>Gb(s,e,n,U),toStoreRange:U=>({startLine:U.start,endLine:U.end,side:U.side==="deletions"?"original":"modified"}),fromDraftRange:U=>({start:U.startLine,end:U.endLine,side:U.side==="original"?"deletions":"additions"})}),{drafts:g,selection:x,setSelection:D,commentText:N,setCommentText:w,editingDraftId:A,saveComment:k,cancel:j,startEdit:y,deleteDraft:P}=h,z=je.useRef(null),R=je.useRef(null),I=je.useRef(""),v=je.useRef(!1),b=je.useRef(null);je.useEffect(()=>{z.current=x},[x]),je.useEffect(()=>{R.current=A},[A]),je.useEffect(()=>{I.current=N},[N]);const L=je.useCallback(U=>{if(!c||v.current)return;const ee=z.current;if(!(!U&&ee&&I.current.trim())){if(S&&ee&&U&&U.side===ee.side){const ne=Math.min(ee.start,U.start),ue=Math.max(ee.end,U.end);D({...U,start:ne,end:ue})}else D(U);U&&(R.current||w(""))}},[c,S,w,D]),E=je.useCallback(()=>{j()},[j]),J=je.useCallback(U=>{const ee=document.createElement("div");ee.style.position="relative";const ne=Ea(U.metadata);return ee.dataset.annotationId=ne,ee.dataset.annotationSide=U.side,ee.dataset.annotationLine=String(U.lineNumber),ee},[]),_=je.useCallback((U,ee)=>{k(U,ee??x??void 0)},[k,x]),Z=je.useCallback(U=>{D(U);const ee=Q.current;if(ee)try{v.current=!0,ee.setSelectedLines(U),b.current=U}catch{}finally{v.current=!1}},[D]),H=je.useCallback(U=>{const ee=U.closest("[data-line-type]")?.getAttribute("data-line-type")??U.getAttribute("data-line-type");if(ee==="change-deletion")return"deletions";if(ee==="change-addition")return"additions";const ne=U.getAttribute("data-column-side")??U.getAttribute("data-side")??U.closest("[data-column-side]")?.getAttribute("data-column-side");if(ne==="deletions"||ne==="left"||ne==="original")return"deletions";if(ne==="additions"||ne==="right"||ne==="modified")return"additions";const ue=U.closest("[data-line-type]");if(ue instanceof HTMLElement){const Me=ue.getBoundingClientRect(),ke=U.getBoundingClientRect(),De=Me.left+Me.width/2;return ke.left+ke.width/2<De?"deletions":"additions"}return"additions"},[]);Ta(p),Ta(u);const T=`${p.metadata.id}:${u.metadata.id}:${m?"dark":"light"}`,Y=je.useMemo(()=>{if(n){const U=n.deletionLines.reduce((ne,ue)=>ne+ue.length,0),ee=n.additionLines.reduce((ne,ue)=>ne+ue.length,0);return Math.max(U,ee)>al}return Math.max(s.length,e.length)>al},[n,e.length,s.length]),F=je.useRef(null),V=je.useRef(null),Q=je.useRef(null),ie=je.useRef(null),X=je.useRef(null),se=je.useRef(null),me=je.useRef(void 0),oe=je.useRef(void 0),xe=je.useRef(void 0),we=je.useRef(void 0),[,he]=l.useReducer(U=>U+1,0),Ie=Ir(Y?"unified":i?"split":"unified"),ve=je.useMemo(()=>wr(p),[p]),ye=je.useMemo(()=>wr(u),[u]);l.useLayoutEffect(()=>{const U=F.current;if(!U)return;const ee=U.querySelector("diffs-container");if(!ee)return;const ne=m?ye:ve,ue=(Ue,le)=>Ue.colors?.[le],Me=ue(ve,"terminal.ansiGreen"),ke=ue(ve,"terminal.ansiRed"),De=ue(ve,"terminal.ansiBlue"),Ae=ue(ye,"terminal.ansiGreen"),Pe=ue(ye,"terminal.ansiRed"),Re=ue(ye,"terminal.ansiBlue");ee.style.setProperty("--shiki-light",ve.fg),ee.style.setProperty("--shiki-light-bg",ve.bg),Me&&ee.style.setProperty("--shiki-light-addition-color",Me),ke&&ee.style.setProperty("--shiki-light-deletion-color",ke),De&&ee.style.setProperty("--shiki-light-modified-color",De),ee.style.setProperty("--shiki-dark",ye.fg),ee.style.setProperty("--shiki-dark-bg",ye.bg),Ae&&ee.style.setProperty("--shiki-dark-addition-color",Ae),Pe&&ee.style.setProperty("--shiki-dark-deletion-color",Pe),Re&&ee.style.setProperty("--shiki-dark-modified-color",Re),ee.style.setProperty("--diffs-bg",ne.bg),ee.style.setProperty("--diffs-fg",ne.fg);const Le=m?Ae:Me,$e=m?Pe:ke,Be=m?Re:De;Le&&ee.style.setProperty("--diffs-addition-color-override",Le),$e&&ee.style.setProperty("--diffs-deletion-color-override",$e),Be&&ee.style.setProperty("--diffs-modified-color-override",Be);const Oe=ee.shadowRoot?.querySelector("pre");Oe&&(Oe.style.setProperty("--shiki-light",ve.fg),Oe.style.setProperty("--shiki-light-bg",ve.bg),Me&&Oe.style.setProperty("--shiki-light-addition-color",Me),ke&&Oe.style.setProperty("--shiki-light-deletion-color",ke),De&&Oe.style.setProperty("--shiki-light-modified-color",De),Oe.style.setProperty("--shiki-dark",ye.fg),Oe.style.setProperty("--shiki-dark-bg",ye.bg),Ae&&Oe.style.setProperty("--shiki-dark-addition-color",Ae),Pe&&Oe.style.setProperty("--shiki-dark-deletion-color",Pe),Re&&Oe.style.setProperty("--shiki-dark-modified-color",Re),Oe.style.setProperty("--diffs-bg",ne.bg),Oe.style.setProperty("--diffs-fg",ne.fg),Le&&Oe.style.setProperty("--diffs-addition-color-override",Le),$e&&Oe.style.setProperty("--diffs-deletion-color-override",$e),Be&&Oe.style.setProperty("--diffs-modified-color-override",Be))},[ye,T,m,ve]);const be=je.useMemo(()=>({theme:{dark:u.metadata.id,light:p.metadata.id},themeType:m?"dark":"light",diffStyle:i?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:Y?0:1e3,maxLineLengthForHighlighting:Y?1:1e3,tokenizeMaxLineLength:Y?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:o?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:c,enableHoverUtility:!1,onLineSelected:c?L:void 0,unsafeCSS:Wb,renderAnnotation:c?J:void 0}),[u.metadata.id,c,m,Y,p.metadata.id,i,o,L,J]),te=je.useMemo(()=>c?Bb({drafts:g,editingDraftId:A,selection:x}):[],[A,c,g,x]),re=je.useRef(te);if(je.useEffect(()=>{re.current=te},[te]),je.useEffect(()=>{const U=V.current;return()=>{Q.current?.cleanUp(),Q.current=null,ie.current?.release(),ie.current=null,X.current=null,se.current=null,me.current=void 0,oe.current=void 0,xe.current=void 0,we.current=void 0,U&&(U.innerHTML="")}},[]),je.useEffect(()=>{if(typeof window>"u")return;const U=V.current,ee=F.current;if(!U||!Ie)return;const ne=Xb(ee,U);let ue=ie.current;ue||(ue=sv(U),ie.current=ue),ie.current=ue;const Me=ue?.virtualizer??null,ke=n?void 0:{name:r||"",contents:s,lang:a,cacheKey:`old:${T}:${r}:${rl(s)}`},De=n?void 0:{name:r||"",contents:e,lang:a,cacheKey:`new:${T}:${r}:${rl(e)}`},Ae=n?oe.current!==n:oe.current!==void 0||!ke||!De||!xe.current||!we.current||!ai(xe.current,ke)||!ai(we.current,De),Pe=Q.current,Re=!!(Pe&&(X.current!==Me||se.current!==Ie||Me&&(me.current!==be.hunkSeparators||Ae)));Re&&(Pe?.cleanUp(),Q.current=null,U.innerHTML="");let Le=Q.current;const $e=!Re&&Pe?!ad(Pe.options,be):!1;if(Le?Le.setOptions(be):(Le=ue?new rd(be,ue.virtualizer,ev,Ie):new id(be,Ie),Q.current=Le,b.current=null),X.current=Me,se.current=Ie,me.current=Me?be.hunkSeparators:void 0,oe.current=n,xe.current=ke,we.current=De,n)Le.render({fileDiff:n,forceRender:$e,lineAnnotations:re.current,containerWrapper:U});else{if(!ke||!De)return;Le.render({oldFile:ke,newFile:De,forceRender:$e,lineAnnotations:re.current,containerWrapper:U})}const Be=Zb(U,()=>{ne(),nv(Le,ue,he)});return()=>{Be(),ne()}},[T,n,r,a,e,be,s,Ie]),je.useEffect(()=>{const U=Q.current;if(U){try{U.setLineAnnotations(te)}catch(ee){console.error("Failed to apply diff line annotations",ee);try{U.setLineAnnotations([])}catch{}}requestAnimationFrame(()=>{if(Q.current===U){try{U.rerender()}catch{}he()}})}},[te]),je.useEffect(()=>{const U=Q.current;if(!U||x!==null)return;const ee=b.current;if(!Jb(x,ee))try{v.current=!0,U.setSelectedLines(x),b.current=x}catch{}finally{v.current=!1}},[x]),je.useEffect(()=>{if(!c)return;const U=V.current;if(!U)return;let ee=null,ne=()=>{};const ue=()=>{const ke=U.querySelector("diffs-container")?.shadowRoot;if(!ke){ee=requestAnimationFrame(ue);return}const De=Ae=>{if(!(Ae instanceof MouseEvent)||Ae.button!==0||!(Ae.target instanceof Element))return;const Pe=Ae.target.closest("[data-column-number]");if(!(Pe instanceof HTMLElement))return;const Re=Pe.getAttribute("data-column-number"),Le=Re?parseInt(Re,10):NaN;if(Number.isNaN(Le))return;const $e=H(Pe);L({start:Le,end:Le,side:$e}),Ae.preventDefault(),Ae.stopPropagation()};ke.addEventListener("click",De,!0),ne=()=>{ke.removeEventListener("click",De,!0)}};return ue(),()=>{ee!==null&&cancelAnimationFrame(ee),ne()}},[T,c,r,L,H]),je.useEffect(()=>{const U=V.current;if(!U)return;let ee=null,ne=null;const Me=setTimeout(()=>{const ke=U.querySelector("diffs-container");if(!(ke instanceof HTMLElement))return;const De=ke.shadowRoot;ee=new MutationObserver(()=>{ne&&cancelAnimationFrame(ne),ne=requestAnimationFrame(()=>{he(),ne=null})}),ee.observe(ke,{childList:!0,subtree:!0}),De&&ee.observe(De,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(Me),ne&&cancelAnimationFrame(ne),ee?.disconnect()}},[T,r]),typeof window>"u")return null;const ge=c?t.jsx(_b,{diffRootRef:F,drafts:g,selection:x,editingDraftId:A,commentText:N,onTextChange:w,fileLabel:r?.split("/").pop()??"",onSave:_,onCancel:E,onEdit:U=>{Z({start:U.startLine,end:U.endLine,side:U.side==="original"?"deletions":"additions"}),y(U)},onDelete:P}):null;return d==="fill"?t.jsx("div",{className:ce("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:t.jsxs("div",{className:"flex-1 relative min-h-0",children:[t.jsx(Jt,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:t.jsx("div",{ref:F,className:"size-full relative",children:t.jsx("div",{ref:V,className:"size-full"})})}),ge]})}):t.jsxs("div",{className:ce("relative","w-full"),children:[t.jsx("div",{ref:F,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative",children:t.jsx("div",{ref:V,className:"w-full"})}),ge]})},av=()=>{const s=rt.c(13),[e,n]=je.useState(!1);let a,r;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(fs())},r=[],s[0]=a,s[1]=r):(a=s[0],r=s[1]),je.useEffect(a,r);let i;s[2]!==e?(i=async u=>e?await qm(u):{success:!0,path:u},s[2]=e,s[3]=i):i=s[3];const o=i;let d;s[4]!==e?(d=async u=>e?await Gm():{success:!0},s[4]=e,s[5]=d):d=s[5];const c=d;let f;s[6]!==e?(f=async u=>e?await Jm():{success:!0},s[6]=e,s[7]=f):f=s[7];const m=f;let p;return s[8]!==e||s[9]!==o||s[10]!==c||s[11]!==m?(p={isDesktop:e,requestAccess:o,startAccessing:c,stopAccessing:m},s[8]=e,s[9]=o,s[10]=c,s[11]=m,s[12]=p):p=s[12],p},rv=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),iv=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:a,onCheckout:r,onCreate:i,remotes:o=[],disabled:d=!1})=>{const{t:c}=dt(),[f,m]=l.useState(!1),[p,u]=l.useState(""),[S,h]=l.useState(!1),[g,x]=l.useState(!1),[D,N]=l.useState(""),[w,A]=l.useState(!1),k=l.useRef(null),j=l.useCallback(_=>{_.stopPropagation()},[]),y=o.length>1,P=l.useMemo(()=>rv(D),[D]),z=l.useMemo(()=>{const _=p.toLowerCase();return _?e.filter(Z=>Z.toLowerCase().includes(_)):e},[p,e]),R=l.useMemo(()=>{const _=p.toLowerCase();return _?n.filter(Z=>Z.toLowerCase().includes(_)):n},[p,n]),I=_=>{if(_===s){m(!1);return}r(_),m(!1),u("")},v=()=>{h(!0),setTimeout(()=>k.current?.focus(),50)},b=async()=>{if(!(!P||w)){if(y){x(!0);return}A(!0);try{await i(P,o[0]),N(""),h(!1),m(!1)}finally{A(!1)}}},L=async _=>{if(!(!P||w)){A(!0);try{await i(P,_),N(""),h(!1),x(!1),m(!1)}finally{A(!1)}}},E=()=>{x(!1)},J=()=>{N(""),h(!1),x(!1)};return l.useEffect(()=>{f||(u(""),h(!1),x(!1),N(""))},[f]),t.jsxs(us,{open:f,onOpenChange:m,children:[t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(ds,{asChild:!0,children:t.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:d,children:[t.jsx(M,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||c("gitView.branch.detachedHead")}),t.jsx(M,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(Et,{sideOffset:8,children:c("gitView.branch.currentBranchTooltip")})]}),t.jsx(ms,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(Nr,{className:"h-full min-h-0",children:[t.jsx(kr,{placeholder:c("gitView.branch.searchPlaceholder"),value:p,onValueChange:u,onKeyDown:j}),t.jsxs(Sr,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Cr,{children:c("gitView.branch.empty")}),t.jsx(Us,{children:g?t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("button",{type:"button",onClick:E,disabled:w,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(M,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[c("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:P})," ",c("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:o.map(_=>t.jsxs("button",{type:"button",onClick:()=>L(_),disabled:w,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[w?t.jsx(M,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,_.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:_.pushUrl})]},_.name))})]}):S?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:k,placeholder:c("gitView.branch.newBranchPlaceholder"),value:D,onChange:_=>N(_.target.value),onClick:_=>_.stopPropagation(),onKeyDown:_=>{j(_),_.key==="Enter"?(_.preventDefault(),b()):_.key==="Escape"&&(_.preventDefault(),J())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:b,disabled:!P||w,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:w?t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(M,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:J,disabled:w,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(M,{name:"close",className:"size-4"})})]}):t.jsxs(Es,{onSelect:v,children:[t.jsx(M,{name:"add",className:"size-4"}),t.jsx("span",{children:c("gitView.branch.create")})]})}),t.jsx(Cn,{}),t.jsxs(Us,{heading:c("gitView.branch.localBranches"),children:[z.map(_=>t.jsxs(Es,{onSelect:()=>I(_),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:_}),(a?.[_]?.ahead||a?.[_]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[a[_].ahead||0," ahead ·"," ",a[_].behind||0," behind"]})]}),s===_&&t.jsx("span",{className:"typography-micro text-primary",children:c("gitView.branch.currentBadge")})]},`local-${_}`)),z.length===0&&t.jsx(Es,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noLocalBranches")})})]}),t.jsx(Cn,{}),t.jsxs(Us,{heading:c("gitView.branch.remoteBranches"),children:[R.map(_=>t.jsx(Es,{onSelect:()=>I(_),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:_})},`remote-${_}`)),R.length===0&&t.jsx(Es,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noRemoteBranches")})})]})]})]})})]})},ov=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),lv=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:a}=dt(),[r,i]=l.useState(!1),[o,d]=l.useState(s||""),[c,f]=l.useState(!1),m=l.useRef(null),p=()=>{!s||!e||(d(s),i(!0),setTimeout(()=>m.current?.focus(),0))},u=async()=>{if(!s||!e||!o.trim())return;const g=ov(o);if(g===s){i(!1);return}f(!0);try{await e(s,g),i(!1),d("")}finally{f(!1)}},S=()=>{i(!1),d("")},h=g=>{g.key==="Enter"?(g.preventDefault(),u()):g.key==="Escape"&&(g.preventDefault(),S())};return r?t.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:t.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:g=>{g.preventDefault(),u()},children:[t.jsx(M,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:m,value:o,onChange:g=>d(g.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:a("gitView.branch.namePlaceholder"),onKeyDown:h,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:c,"aria-label":a(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:a(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:c?t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(M,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:S,disabled:c,"aria-label":a("gitView.branch.renameCancel"),title:a("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(M,{name:"close",className:"size-4"})})]})}):t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[t.jsx(M,{name:"git-branch",className:"size-4 text-primary shrink-0"}),t.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[t.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||a("gitView.branch.detachedHead")}),n&&e&&s&&t.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:p,title:a("gitView.branch.renameTitle"),children:t.jsx(M,{name:"edit",className:"size-4"})})]})]})},cv={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3"},dv={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function lc(s){return s&&dv[s]||"var(--primary)"}const il=s=>{const e=rt.c(8),{icon:n,className:a,colorToken:r}=s,i=cv[n??"branch"]??"user-3";let o;e[0]!==r?(o=lc(r),e[0]=r,e[1]=o):o=e[1];let d;e[2]!==o?(d={color:o},e[2]=o,e[3]=d):d=e[3];let c;return e[4]!==a||e[5]!==i||e[6]!==d?(c=t.jsx(M,{name:i,className:a,style:d}),e[4]=a,e[5]=i,e[6]=d,e[7]=c):c=e[7],c},cc=s=>{const e=rt.c(35),{activeProfile:n,identities:a,onSelect:r,isApplying:i,iconOnly:o}=s,d=o===void 0?!1:o,{t:c}=dt(),f=i||a.length===0,m=n?.color;let p;e[0]!==m?(p=lc(m),e[0]=m,e[1]=p):p=e[1];let u;e[2]!==p?(u={color:p},e[2]=p,e[3]=u):u=e[3];let S;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==i?(S=i?t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(il,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=i,e[7]=S):S=e[7];let h;e[8]!==n?.name||e[9]!==d||e[10]!==c?(h=!d&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||c("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=d,e[10]=c,e[11]=h):h=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(M,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=g):g=e[12];let x;e[13]!==f||e[14]!==u||e[15]!==S||e[16]!==h?(x=t.jsx(At,{asChild:!0,children:t.jsx(ds,{asChild:!0,children:t.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",style:u,disabled:f,children:[S,h,g]})})}),e[13]=f,e[14]=u,e[15]=S,e[16]=h,e[17]=x):x=e[17];let D;e[18]!==c?(D=c("gitView.header.identityTooltip"),e[18]=c,e[19]=D):D=e[19];let N;e[20]!==D?(N=t.jsx(Et,{sideOffset:8,children:D}),e[20]=D,e[21]=N):N=e[21];let w;e[22]!==N||e[23]!==x?(w=t.jsxs(Dt,{children:[x,N]}),e[22]=N,e[23]=x,e[24]=w):w=e[24];let A;e[25]!==n?.id||e[26]!==a||e[27]!==r||e[28]!==c?(A=a.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:c("gitView.header.noProfiles")})}):a.map(y=>{const P=n?.id===y.id;return t.jsx(js,{onSelect:()=>r(y),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(il,{icon:y.icon,colorToken:y.color,className:"size-4"}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:y.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:y.userEmail})]}),P?t.jsx(M,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},y.id)}),e[25]=n?.id,e[26]=a,e[27]=r,e[28]=c,e[29]=A):A=e[29];let k;e[30]!==A?(k=t.jsx(ms,{align:"end",className:"w-64",children:A}),e[30]=A,e[31]=k):k=e[31];let j;return e[32]!==w||e[33]!==k?(j=t.jsxs(us,{children:[w,k]}),e[32]=w,e[33]=k,e[34]=j):j=e[34],j},mv=s=>{const e=rt.c(21),{comparison:n,trackingBranch:a,tooltipDelayMs:r}=s,i=r===void 0?1e3:r,{t:o}=dt(),d=`${n.remote}/${n.branch}`,c=n.ahead===0&&n.behind===0;let f;e[0]!==o||e[1]!==d||e[2]!==a?(f=a?o("gitView.header.upstreamTooltipTracking",{target:d,tracking:a}):o("gitView.header.upstreamTooltip",{target:d}),e[0]=o,e[1]=d,e[2]=a,e[3]=f):f=e[3];const m=f;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(M,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=p):p=e[4];let u;e[5]!==d?(u=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:d}),e[5]=d,e[6]=u):u=e[6];let S;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==c||e[10]!==o?(S=c?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:o("gitView.header.upstreamSynced")}):t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[n.ahead>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",n.ahead]}):null,n.behind>0?t.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",n.behind]}):null]}),e[7]=n.ahead,e[8]=n.behind,e[9]=c,e[10]=o,e[11]=S):S=e[11];let h;e[12]!==u||e[13]!==S?(h=t.jsx(At,{asChild:!0,children:t.jsxs("div",{className:"inline-flex h-8 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[p,u,S]})}),e[12]=u,e[13]=S,e[14]=h):h=e[14];let g;e[15]!==m?(g=t.jsx(Et,{sideOffset:8,children:m}),e[15]=m,e[16]=g):g=e[16];let x;return e[17]!==h||e[18]!==g||e[19]!==i?(x=t.jsxs(Dt,{delayDuration:i,children:[h,g]}),e[17]=h,e[18]=g,e[19]=i,e[20]=x):x=e[20],x},Vv=s=>{const e=rt.c(54),{status:n,localBranches:a,remoteBranches:r,branchInfo:i,syncAction:o,remotes:d,onFetch:c,onSync:f,onRemoveRemote:m,removingRemoteName:p,onCheckoutBranch:u,onCreateBranch:S,onRenameBranch:h,activeIdentityProfile:g,availableIdentities:x,onSelectIdentity:D,isApplyingIdentity:N,isWorktreeMode:w,onOpenHistory:A,onOpenGraph:k,onOpenStashes:j,actionTabItems:y,activeActionTab:P,onSelectActionTab:z}=s,{t:R}=dt();if(!n)return null;let I;e[0]!==k||e[1]!==A||e[2]!==j||e[3]!==R?(I=A||k||j?t.jsxs(us,{children:[t.jsxs(Dt,{children:[t.jsx(At,{asChild:!0,children:t.jsx(ds,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":R("gitView.header.repositoryViews"),children:t.jsx(M,{name:"git-repository",className:"size-4"})})})}),t.jsx(Et,{sideOffset:8,children:R("gitView.header.repositoryViews")})]}),t.jsxs(ms,{align:"end",children:[A?t.jsxs(js,{onSelect:A,children:[t.jsx(M,{name:"history",className:"size-4"}),R("gitView.history.title")]}):null,k?t.jsxs(js,{onSelect:k,children:[t.jsx(M,{name:"git-merge",className:"size-4"}),R("gitView.graph.title")]}):null,j?t.jsxs(js,{onSelect:j,children:[t.jsx(M,{name:"archive-stack",className:"size-4"}),R("gitView.stashes.title")]}):null]})]}):null,e[0]=k,e[1]=A,e[2]=j,e[3]=R,e[4]=I):I=e[4];let v;e[5]!==I?(v=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:I}),e[5]=I,e[6]=v):v=e[6];const b=v,L=!n;let E;e[7]!==n.tracking?(E=n.tracking?.split("/")[0],e[7]=n.tracking,e[8]=E):E=e[8];const J=(n.files?.length??0)>0;let _;e[9]!==c||e[10]!==m||e[11]!==f||e[12]!==d||e[13]!==p||e[14]!==n.ahead||e[15]!==n.behind||e[16]!==o||e[17]!==L||e[18]!==E||e[19]!==J?(_=t.jsx(Sb,{syncAction:o,remotes:d,onFetch:c,onSync:f,onRemoveRemote:m,removingRemoteName:p,disabled:L,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:E,hasUncommittedChanges:J}),e[9]=c,e[10]=m,e[11]=f,e[12]=d,e[13]=p,e[14]=n.ahead,e[15]=n.behind,e[16]=o,e[17]=L,e[18]=E,e[19]=J,e[20]=_):_=e[20];const Z=_;let H;e[21]!==n.tracking||e[22]!==n.upstreamComparison?(H=n.upstreamComparison?t.jsx(mv,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[21]=n.tracking,e[22]=n.upstreamComparison,e[23]=H):H=e[23];const T=H;let Y;e[24]!==g||e[25]!==x||e[26]!==N||e[27]!==D?(Y=t.jsx(cc,{activeProfile:g,identities:x,onSelect:D,isApplying:N,iconOnly:!0}),e[24]=g,e[25]=x,e[26]=N,e[27]=D,e[28]=Y):Y=e[28];const F=Y;let V;e[29]!==i||e[30]!==w||e[31]!==a||e[32]!==u||e[33]!==S||e[34]!==h||e[35]!==r||e[36]!==d||e[37]!==n.current?(V=t.jsx("div",{className:"min-w-0 flex-1",children:w?t.jsx(lv,{currentBranch:n.current,onRename:h}):t.jsx(iv,{currentBranch:n.current,localBranches:a,remoteBranches:r,branchInfo:i,onCheckout:u,onCreate:S,remotes:d})}),e[29]=i,e[30]=w,e[31]=a,e[32]=u,e[33]=S,e[34]=h,e[35]=r,e[36]=d,e[37]=n.current,e[38]=V):V=e[38];let Q;e[39]!==F||e[40]!==b?(Q=t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[b,F]}),e[39]=F,e[40]=b,e[41]=Q):Q=e[41];let ie;e[42]!==Q||e[43]!==V?(ie=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[V,Q]}),e[42]=Q,e[43]=V,e[44]=ie):ie=e[44];let X;e[45]!==y||e[46]!==P||e[47]!==z||e[48]!==Z||e[49]!==T?(X=y&&P&&z?t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(xn,{items:y,activeId:P,onSelect:z,layoutMode:"fit",variant:"active-pill",iconOnlyActiveTab:!0,activePillButtonClassName:"h-7",className:"h-full"})}),T?t.jsx("div",{className:"min-w-0 shrink",children:T}):null,t.jsx("div",{className:"shrink-0",children:Z})]}):null,e[45]=y,e[46]=P,e[47]=z,e[48]=Z,e[49]=T,e[50]=X):X=e[50];let se;return e[51]!==ie||e[52]!==X?(se=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[ie,X]}),e[51]=ie,e[52]=X,e[53]=se):se=e[53],se},uv=s=>s==="/",La=s=>s.replace(/\\/g,"/"),Qr=s=>{if(!s||uv(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},En=s=>s.endsWith("/"),pv=s=>{const e=s.trim();return!e||En(e)?e:`${e}/`},Yr=s=>s.lastIndexOf("/"),dc=s=>{if(En(s))return s;const e=Yr(s);return e<0?s:s.slice(0,e+1)},gv=s=>{const e=Yr(s);return s.slice(e+1)},mc=s=>{const e=Qr(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Yr(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},hv=s=>En(s)&&mc(s)!==null,fv=(s,e)=>`${dc(s)}${e}/`,cn=s=>{if(!s)return null;const e=Qr(La(s.trim()));return e?e.toLowerCase():null},ol=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},xv=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,vr=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},yv=async()=>{try{const s=await jt("/api/fs/home",{method:"GET",headers:{Accept:"application/json"}});if(s.ok){const e=await s.json();if(typeof e.home=="string"&&e.home.trim().length>0)return La(e.home.trim())}}catch{}return Ns.getFilesystemHome().catch(()=>null)},_v=({open:s,onOpenChange:e})=>{const{t:n}=dt(),a=vs($=>$.homeDirectory),r=as($=>$.projects),i=as($=>$.addProject),o=ks($=>$.profiles),d=ks($=>$.globalIdentity),c=ks($=>$.defaultGitIdentityId),f=ks($=>$.loadProfiles),m=ks($=>$.loadGlobalIdentity),p=ks($=>$.loadDefaultGitIdentityId),{isDesktop:u,requestAccess:S,startAccessing:h}=av(),{isMobile:g}=Cs(),x=l.useRef(null),D=l.useRef(null),N=l.useRef(new Map),[w,A]=l.useState(""),[k,j]=l.useState("~/"),[y,P]=l.useState([]),[z,R]=l.useState(!1),[I,v]=l.useState(!1),[b,L]=l.useState(0),[E,J]=l.useState(!1),[_,Z]=l.useState(!1),[H,T]=l.useState(0),[Y,F]=l.useState(!1),[V,Q]=l.useState(""),[ie,X]=l.useState(null),[se,me]=l.useState(!1),oe=w||a,xe=l.useMemo(()=>new Set(r.map($=>cn($.path)).filter($=>!!$)),[r]);l.useEffect(()=>{if(!s)return;j("~/"),P([]),L(0),J(!1),Z(!1),F(!1),Q(""),X(null),me(!1),requestAnimationFrame(()=>vr(x.current));let $=!1;return(async()=>{const O=await yv();$||(A(O||a||""),requestAnimationFrame(()=>vr(x.current)))})(),()=>{$=!0}},[a,s]),l.useEffect(()=>{s&&(f(),m(),p())},[p,f,m,s]);const we=l.useMemo(()=>{const $=new Map;d&&$.set(d.id,d);for(const fe of o)$.set(fe.id,fe);return Array.from($.values())},[o,d]);l.useEffect(()=>{if(!s||!Y||ie!==null)return;const $=typeof c=="string"?c.trim():"";if($&&we.some(O=>O.id===$)){X($);return}const fe=we.find(O=>O.authType==="ssh"||O.sshKey);fe&&X(fe.id)},[we,c,Y,s,ie]);const he=l.useMemo(()=>we.find($=>$.id===ie)??null,[we,ie]),Ie=l.useMemo(()=>dc(k),[k]),ve=l.useMemo(()=>En(k)?"":gv(k),[k]),ye=l.useMemo(()=>oe?ol(Ie,oe):"",[Ie,oe]);l.useEffect(()=>{if(!s||!ye){P([]);return}let $=!1;return R(!0),v(!1),Ns.listLocalDirectory(ye).then(fe=>{if($)return;v(!1);const O=fe.filter(Fe=>Fe.isDirectory).map(Fe=>({name:Fe.name,path:La(Fe.path)})).sort((Fe,Je)=>Fe.name.localeCompare(Je.name));P(O)}).catch(()=>{$||(P([]),v(!0))}).finally(()=>{$||R(!1)}),()=>{$=!0}},[ye,s]);const be=l.useMemo(()=>{const $=ve.toLowerCase(),fe=se||ve.startsWith(".");return y.filter(O=>O.name.toLowerCase().startsWith($)&&(fe||!O.name.startsWith(".")))},[ve,y,se]),te=l.useMemo(()=>{const $=[];hv(k)&&$.push({type:"up",value:"browse:up",name:"..",path:mc(k)});for(const fe of be){const O=cn(fe.path);$.push({type:"directory",value:`browse:${fe.path}`,name:fe.name,path:fe.path,disabled:!!(O&&xe.has(O))})}return $},[xe,be,k]);l.useEffect(()=>{L(0)},[k,te.length]);const re=l.useMemo(()=>oe?Qr(ol(k,oe)):"",[oe,k]),ge=cn(re),U=!!(ge&&xe.has(ge)),ee=l.useMemo(()=>ve?be.find($=>$.name===ve)??null:null,[ve,be]),ne=!!(re&&!U&&(En(k)&&I||!En(k)&&ve.trim().length>0&&ee===null)),ue=!E&&!_&&!U&&!!re,Me=ue&&V.trim().length>0,ke=te[b]??null,De=!!(ke&&(ke.type==="up"||ke.type==="directory"&&!ke.disabled)),Ae=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl",Pe=n(U?"directoryExplorerDialog.actions.alreadyAdded":Y?E?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":E?"directoryExplorerDialog.actions.adding":ne?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");l.useLayoutEffect(()=>{const $=D.current;if(!$)return;const fe=()=>T(Math.ceil($.getBoundingClientRect().width));if(fe(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(fe);return O.observe($),()=>O.disconnect()},[Pe]),l.useLayoutEffect(()=>{const $=x.current;$&&($.scrollLeft=$.scrollWidth)},[H,k]),l.useLayoutEffect(()=>{s&&vr(x.current)},[s]),l.useLayoutEffect(()=>{const $=te[b];$&&N.current.get($.value)?.scrollIntoView({block:"nearest"})},[b,te]);const Re=l.useCallback(()=>{e(!1)},[e]),Le=l.useCallback(($,fe)=>{$.stopPropagation();const O=cn(fe);if(O&&xe.has(O))return;i(fe)||B.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")})},[i,xe,n]),$e=l.useCallback(async $=>{if(!$||E)return;const fe=cn($);if(fe&&xe.has(fe))return;let O=$;J(!0);try{const Fe=!Y&&ne&&cn($)===cn(re);if(Y){const Xe=V.trim();if(!Xe){B.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}O=(await Ns.cloneRepository({remoteUrl:Xe,destinationPath:$,gitIdentityId:he?.id??null})).path}else Fe&&await Ns.createDirectory($);if(!i(O)){B.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Re()}catch(Fe){B.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Fe instanceof Error?Fe.message:n("directoryExplorerDialog.toast.unknownError")})}finally{J(!1)}},[i,xe,V,Re,Y,E,he?.id,ne,re,n]),Be=l.useCallback($=>{j(pv($))},[]),Oe=l.useCallback($=>{j(fv(k,$.name))},[k]),Ue=l.useCallback($=>{if($){if($.type==="up"){$.path&&Be($.path);return}$.disabled||Oe($)}},[Be,Oe]),le=l.useCallback(async()=>{if(!(!u||_)){Z(!0);try{const $=await S(re);if(!$.success||!$.path){$.error&&$.error!=="Directory selection cancelled"&&B.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:$.error});return}const fe=await h($.path);if(!fe.success){B.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:fe.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}await $e($.path)}catch($){B.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:$ instanceof Error?$.message:n("directoryExplorerDialog.toast.unknownError")})}finally{Z(!1)}}},[$e,u,_,S,h,n,re]),W=l.useCallback($=>{if($.key==="ArrowDown"){$.preventDefault(),L(fe=>Math.min(te.length-1,fe+1));return}if($.key==="ArrowUp"){$.preventDefault(),L(fe=>Math.max(0,fe-1));return}if($.key==="Enter"){if($.preventDefault(),xv($)){$e(re);return}De&&Ue(ke);return}$.key==="Backspace"&&k===""&&($.preventDefault(),Re())},[Ue,$e,Re,De,ke,k,te.length,re]),de=t.jsxs("button",{type:"button",onClick:()=>me($=>!$),className:"flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40",children:[se?t.jsx(M,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(M,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),Ne=t.jsxs("div",{className:"px-2.5 py-1.5",children:[Y?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(it,{value:V,onChange:$=>Q($.target.value),placeholder:n("directoryExplorerDialog.clone.remoteUrlPlaceholder"),className:"min-w-0 flex-1 border-border/60 bg-[var(--surface-elevated)] font-mono typography-ui-label shadow-none",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),t.jsx(cc,{activeProfile:he,identities:we,onSelect:$=>X($.id),isApplying:E,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(M,{name:"folder-add",className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80"}),t.jsx(it,{ref:x,value:k,onChange:$=>j(La($.target.value)),onKeyDown:W,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!g&&H>0?{paddingRight:`${H+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),g?null:t.jsx(G,{ref:D,variant:"outline",size:"xs",tabIndex:-1,className:"absolute right-1.5 top-1/2 h-7 -translate-y-1/2 gap-1 px-2 typography-meta",disabled:Y?!Me:!ue,onMouseDown:$=>$.preventDefault(),onClick:()=>{$e(re)},title:Pe,children:Pe})]})]}),Ee=t.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm",children:t.jsxs("div",{className:"max-h-[min(28rem,58vh)] overflow-y-auto p-2",children:[t.jsx("div",{className:"px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80",children:n("directoryExplorerDialog.browse.directories")}),z?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):te.length===0?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.empty")}):t.jsx("div",{className:"space-y-0.5",children:te.map(($,fe)=>{const O=fe===b;return t.jsxs("button",{ref:Fe=>{Fe?N.current.set($.value,Fe):N.current.delete($.value)},type:"button",disabled:$.type==="directory"&&$.disabled,onMouseEnter:()=>L(fe),onMouseDown:Fe=>Fe.preventDefault(),onClick:()=>Ue($),className:ce("flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",O&&"bg-interactive-selection text-interactive-selection-foreground",!O&&"hover:bg-interactive-hover/50",$.type==="directory"&&$.disabled&&"cursor-not-allowed opacity-45 hover:bg-transparent"),children:[$.type==="up"?t.jsx(M,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(M,{name:"folder-6",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}),t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t.jsx("span",{className:"truncate typography-ui-label text-foreground",children:$.name})}),$.type==="directory"&&$.disabled?t.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground",children:n("directoryExplorerDialog.browse.addedBadge")}):$.type==="directory"?t.jsx("button",{type:"button",onMouseDown:Fe=>Fe.stopPropagation(),onClick:Fe=>Le(Fe,$.path),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",title:n("directoryExplorerDialog.browse.quickAdd"),children:t.jsx(M,{name:"add",className:"h-3.5 w-3.5"})}):null]},$.value)})})]})}),Ce=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[Ne,Ee]}),He=t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(M,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(M,{name:"arrow-down-s",className:"-ml-1 h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.navigate")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(M,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.select")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:Ae}),t.jsx(M,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),q=()=>t.jsxs(t.Fragment,{children:[g?null:He,t.jsxs("div",{className:ce("flex w-full flex-row justify-end gap-2 sm:w-auto",g&&"justify-stretch"),children:[u?t.jsx(G,{variant:"ghost",size:"xs",onClick:le,disabled:E||_||Y,children:n(_?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(G,{variant:"ghost",size:"xs",onClick:()=>F($=>!$),disabled:E||_,className:ce(g&&"flex-1"),children:n(Y?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),g?t.jsx(G,{size:"xs",onClick:()=>{$e(re)},disabled:Y?!Me:!ue,className:"flex-1",children:Pe}):null]})]});return g?t.jsx(Gn,{open:s,onClose:Re,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px] max-w-full",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:q()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:de}),Ce]})}):t.jsx(Ut,{open:s,onOpenChange:e,children:t.jsxs(Bt,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(_t,{className:"px-5 pb-2 pt-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(Vt,{children:n("directoryExplorerDialog.title")}),t.jsx(qt,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),de]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:Ce}),t.jsx(Yt,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:q()})]})})};function ll(s){const{localBranches:e,remoteBranches:n,query:a}=s,r=a.trim();if(!r)return{matching:[],otherLocal:e,otherRemote:n};const i=bi(e,r,m=>m),o=bi(n,r,m=>m),d=[],c=i.other,f=o.other;for(const m of i.matching)d.push({label:m,value:m,source:"local"});for(const m of o.matching)d.push({label:m,value:`remotes/${m}`,source:"remote"});return d.sort((m,p)=>{const u=m.label.localeCompare(p.label,void 0,{sensitivity:"accent"});return u!==0?u:m.source!==p.source?m.source.localeCompare(p.source):m.value.localeCompare(p.value)}),{matching:d,otherLocal:c,otherRemote:f}}function bv({open:s,onOpenChange:e,onSelect:n}){const{t:a}=dt(),r=Ke(te=>te.isMobile),{github:i}=Hr(),o=Vs(te=>te.status),d=Vs(te=>te.hasChecked),c=Ke(te=>te.setSettingsDialogOpen),f=Ke(te=>te.setSettingsPage),m=as(te=>te.getActiveProject()),p=m?.path??null,u=je.useMemo(()=>p&&m?{id:m.id,path:p}:null,[m,p]),[S,h]=je.useState("issues"),[g,x]=je.useState(""),[D,N]=je.useState([]),[w,A]=je.useState([]),[k,j]=je.useState(!1),[y,P]=je.useState(!1),[z,R]=je.useState(null),[I,v]=je.useState(null),[b,L]=je.useState(null),[E,J]=je.useState(!1),[_,Z]=je.useState(new Map),[H,T]=je.useState(1),[Y,F]=je.useState(!1),V=km(g,350),Q=je.useCallback(async te=>{if(!(!p||!i)&&!(d&&o?.connected===!1)){j(!0),R(null),T(1),F(!1);try{if(S==="issues"&&i.issuesList){const re=await i.issuesList(p,{page:1,query:te});re.connected===!1?(R(a("session.githubIntegration.error.notConnected")),N([])):(N(re.issues??[]),T(re.page??1),F(!!re.hasMore))}else if(S==="prs"&&i.prsList){const re=await i.prsList(p,{page:1,query:te});re.connected===!1?(R(a("session.githubIntegration.error.notConnected")),A([])):(A(re.prs??[]),T(re.page??1),F(!!re.hasMore))}}catch(re){R(re instanceof Error?re.message:a("session.githubIntegration.error.loadDataFailed"))}finally{j(!1)}}},[p,i,d,o,S,a]);je.useEffect(()=>{if(!s||!p||d&&o?.connected===!1||!i)return;if(!V.trim()){Q();return}const te=new AbortController;j(!0),R(null),T(1),F(!1);const re=S==="issues"&&i.issuesList?i.issuesList(p,{page:1,query:V.trim()}):S==="prs"&&i.prsList?i.prsList(p,{page:1,query:V.trim()}):null;if(!re){j(!1);return}return re.then(ge=>{te.signal.aborted||("issues"in ge?ge.connected===!1?(R(a("session.githubIntegration.error.notConnected")),N([])):(N(ge.issues??[]),T(ge.page??1),F(!!ge.hasMore)):"prs"in ge&&(ge.connected===!1?(R(a("session.githubIntegration.error.notConnected")),A([])):(A(ge.prs??[]),T(ge.page??1),F(!!ge.hasMore))))}).catch(ge=>{te.signal.aborted||R(ge instanceof Error?ge.message:a("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{te.signal.aborted||j(!1)}),()=>te.abort()},[s,p,i,d,o,S,V,Q,a]);const ie=je.useCallback(async()=>{if(!(!p||!i)&&!(k||y)&&Y){P(!0);try{const te=H+1;if(S==="issues"&&i.issuesList){const re=V.trim()?await i.issuesList(p,{page:te,query:V.trim()}):await i.issuesList(p,{page:te});re.connected!==!1&&(N(ge=>[...ge,...re.issues??[]]),T(re.page??te),F(!!re.hasMore))}else if(S==="prs"&&i.prsList){const re=V.trim()?await i.prsList(p,{page:te,query:V.trim()}):await i.prsList(p,{page:te});re.connected!==!1&&(A(ge=>[...ge,...re.prs??[]]),T(re.page??te),F(!!re.hasMore))}}catch{}finally{P(!1)}}},[p,i,S,H,Y,k,y,V]);je.useEffect(()=>{if(!s){h("issues"),x(""),N([]),A([]),v(null),L(null),J(!1),R(null),Z(new Map),T(1),F(!1);return}Q()},[s,Q]);const X=je.useCallback(async te=>{if(!(!u||!te)&&!_.has(te))try{const ge=(await kl(u,{mode:"new",branchName:te,worktreeName:te})).errors.find(U=>U.code==="branch_in_use");Z(U=>new Map(U).set(te,{isValid:!ge,error:ge?a(ge.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{Z(re=>new Map(re).set(te,{isValid:!1,error:a("session.githubIntegration.validation.failed")}))}},[u,_,a]);je.useEffect(()=>{!s||S!=="prs"||w.forEach(te=>{te.head&&X(te.head)})},[s,S,w,X]);const se=d&&o?.connected===!0,me=()=>{f("github"),c(!0)},oe=te=>{v(te),L(null)},xe=te=>{L(te),v(null)},we=()=>{I?n({type:"issue",item:I}):b&&n({type:"pr",item:b,includeDiff:E}),e(!1)},he=()=>{v(null),L(null),J(!1)},Ie=I||b&&_.get(b.head??"")?.isValid!==!1,ve=te=>te.head?_.get(te.head)?.isValid===!1:!0,ye=t.jsx(t.Fragment,{children:se?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(M,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(it,{value:g,onChange:te=>x(te.target.value),placeholder:a(S==="issues"?"session.githubIntegration.search.issuesPlaceholder":"session.githubIntegration.search.prsPlaceholder"),className:"h-8 pl-9"})]}),t.jsx("div",{className:"mt-2 h-[300px] overflow-hidden",children:t.jsxs("div",{className:"h-full overflow-y-auto",children:[k&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(M,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),z&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive",children:[t.jsx(M,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:z})]})}),!k&&!z&&S==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[D.length>0?D.map(te=>t.jsx("button",{onClick:()=>oe(te),className:ce("w-full text-left px-2 py-1.5 rounded transition-colors",I?.number===te.number?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",te.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:te.title}),te.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block",children:[te.sourceRepo.owner,"/",te.sourceRepo.repo]}):null]})]})},`${te.sourceRepo?.owner??""}-${te.sourceRepo?.repo??""}-${te.number}`)):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:a("session.githubIntegration.empty.noIssuesFound")}),Y&&!y&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{ie()},className:"h-7 text-xs",children:a("session.githubIntegration.actions.loadMore")})}),y&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!k&&!z&&S==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[w.length>0?w.map(te=>{const re=ve(te),ge=te.head?_.get(te.head):void 0;return t.jsx("button",{onClick:()=>!re&&xe(te),disabled:re,className:ce("w-full text-left px-2 py-1.5 rounded transition-colors",b?.number===te.number?"bg-interactive-selection text-interactive-selection-foreground":re?"opacity-50 cursor-not-allowed":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",te.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:te.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[te.head," → ",te.base]}),te.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[te.sourceRepo.owner,"/",te.sourceRepo.repo]}):null,re&&ge?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:ge.error})]})]})]})},`${te.sourceRepo?.owner??""}-${te.sourceRepo?.repo??""}-${te.number}`)}):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:a("session.githubIntegration.empty.noPullRequestsFound")}),Y&&!y&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{ie()},className:"h-7 text-xs",children:a("session.githubIntegration.actions.loadMore")})}),y&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]})]})})]}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 gap-4",children:[t.jsx(M,{name:"github",className:"h-12 w-12 text-muted-foreground"}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:a("session.githubIntegration.connect.title")}),t.jsx("p",{className:"typography-small text-muted-foreground mt-1",children:a("session.githubIntegration.connect.description")})]}),t.jsx(G,{onClick:me,size:"sm",children:a("session.githubIntegration.connect.action")})]})}),be=t.jsxs("div",{className:ce("w-full",r?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:ce("flex items-center gap-4",r?"w-full justify-center order-1":"flex-1"),children:[!r&&(I||b)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(M,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate max-w-[150px]",children:I?a("session.githubIntegration.selected.issueNumber",{number:I.number}):a("session.githubIntegration.selected.prNumber",{number:b?.number??""})}),t.jsx("button",{onClick:he,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]}),S==="prs"&&b&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(It,{checked:E,onChange:te=>J(te),ariaLabel:a("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:a("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:ce("flex gap-2",r?"w-full order-2":"justify-end"),children:[t.jsx(G,{variant:"outline",size:"sm",onClick:()=>e(!1),className:ce(r&&"flex-1"),children:a("session.githubIntegration.actions.cancel")}),t.jsx(G,{size:"sm",onClick:we,disabled:!Ie,className:ce(r&&"flex-1"),children:a("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:r?t.jsx(Gn,{open:s,title:a("session.githubIntegration.title"),onClose:()=>e(!1),footer:se?be:void 0,renderHeader:te=>t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border/40",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:a("session.githubIntegration.title")}),te]}),t.jsx("div",{className:"w-full",children:t.jsx(xn,{items:[{id:"issues",label:a("session.githubIntegration.tabs.issues"),icon:t.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:a("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(M,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:S,onSelect:re=>{h(re),x("")},variant:"active-pill",layoutMode:"fit"})}),(I||b)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(M,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:I?a("session.githubIntegration.selected.issueNumber",{number:I.number}):a("session.githubIntegration.selected.prNumber",{number:b?.number??""})}),t.jsx("button",{onClick:he,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:ye}):t.jsx(Ut,{open:s,onOpenChange:e,children:t.jsxs(Bt,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(_t,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Vt,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(M,{name:"github",className:"h-5 w-5"}),a("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(xn,{items:[{id:"issues",label:a("session.githubIntegration.tabs.issues"),icon:t.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:a("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(M,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:S,onSelect:te=>{h(te),x("")},variant:"active-pill",layoutMode:"fit"})})]})}),ye,t.jsx(Yt,{className:"mt-1",children:be})]})})})}const qn=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),hs=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,"").split("/").join("-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,80),cl="oc:lastWorktreeSourceBranch",vv=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",dl=(s,e,n)=>{const a=qn(s.head||"");if(!a)throw new Error("PR head branch is missing");if(e.includes(a))return{existingBranch:a,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:a};const r=n.find(f=>{const m=f.indexOf("/");return m<=0||m>=f.length-1?!1:f.slice(m+1)===a});if(r){const f=r.indexOf("/"),m=r.slice(0,f);return{existingBranch:`remotes/${r}`,setUpstream:!0,upstreamRemote:m,upstreamBranch:a,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${m}/${a}`}}const i=String(s.headLabel||"").split(":")[0]?.trim(),o=s.headRepo?.owner||i||"pr-head",d=`pr-${vv(o)}`,c=s.headRepo?.sshUrl||s.headRepo?.cloneUrl||"";if(!c)throw new Error("PR head repository URL is unavailable");return{existingBranch:`remotes/${d}/${a}`,setUpstream:!0,upstreamRemote:d,upstreamBranch:a,ensureRemoteName:d,ensureRemoteUrl:c,sourceLabel:`${d}/${a}`}},jv=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
|
|
166
|
-
${JSON.stringify(e,null,2)}`},wv=s=>`GitHub pull request context (JSON)
|
|
167
|
-
${JSON.stringify(s,null,2)}`;function Hv({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:a}=dt(),{github:r,git:i}=Hr(),o=Ke(q=>q.isMobile),d=Vs(q=>q.status),c=Vs(q=>q.hasChecked),f=as(q=>q.getActiveProject()),m=f?.path??null,p=je.useMemo(()=>m&&f?{id:f.id,path:m}:null,[f,m]),[u,S]=je.useState("new-branch"),[h,g]=je.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1}),[x,D]=je.useState({selectedBranch:"",worktreeName:""}),N=Sm(m),w=Cm(m),A=Pm(q=>q.fetchBranches),k=je.useMemo(()=>N?.all?N.all.filter(q=>!q.startsWith("remotes/")).sort():[],[N]),j=je.useMemo(()=>N?.all?N.all.filter(q=>q.startsWith("remotes/")).map(q=>q.replace(/^remotes\//,"")).sort():[],[N]),y=Ps(q=>q.availableWorktreesByProject),P=je.useMemo(()=>{if(!m)return new Set;const q=y.get(m)??[];return new Set(q.map($=>$.name))},[y,m]),z=je.useCallback((q=10)=>{for(let $=0;$<q;$++){const fe=Qa();if(!P.has(fe))return fe}return`${Qa()}-${Date.now().toString(36).slice(-4)}`},[P]),[R,I]=je.useState(!1),[v,b]=je.useState(!1),[L,E]=je.useState(!1),[J,_]=je.useState(!1),[Z,H]=je.useState(!1),[T,Y]=je.useState(""),[F,V]=je.useState(""),Q=je.useRef(null),ie=je.useRef(null),X=je.useRef(null),se=je.useRef(null),me=je.useCallback(q=>{q.stopPropagation()},[]),oe=je.useCallback(q=>{let $=q;for(;$&&$!==document.body;){const{overflowY:fe}=window.getComputedStyle($);if((fe==="auto"||fe==="scroll")&&$.scrollHeight>$.clientHeight)return $;$=$.parentElement}return null},[]),xe=je.useCallback(q=>{q&&(q.scrollTop=0)},[]),we=je.useCallback(q=>{const $=q.current?.querySelector('[data-slot="command-list"]')??null;xe($)},[xe]),he=je.useCallback(q=>{const $=oe(q.current);xe($)},[oe,xe]),Ie=je.useMemo(()=>ll({localBranches:k,remoteBranches:j,query:T}),[k,j,T]),ve=je.useMemo(()=>ll({localBranches:k,remoteBranches:j,query:F}),[k,j,F]),ye=T.trim().length>0,be=F.trim().length>0,te=Ie.matching.length>0,re=ve.matching.length>0,ge=!!(m&&i),U=je.useCallback(()=>{!m||!i||A(m,i)},[m,i,A]);je.useEffect(()=>{!s||!m||!i||N?.all||A(m,i)},[s,m,i,N?.all,A]),je.useEffect(()=>{!v&&!J&&Y("")},[v,J]),je.useEffect(()=>{!L&&!Z&&V("")},[L,Z]),je.useEffect(()=>{v&&we(Q),J&&he(X)},[v,J,T,we,he]),je.useEffect(()=>{L&&we(ie),Z&&he(se)},[L,Z,F,we,he]);const[ee,ne]=je.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[ue,Me]=je.useState(!1),[ke,De]=je.useState(null),Ae=je.useCallback(()=>{const q=ut.getState(),$=q.getVisibleAgents();if(q.settingsDefaultAgent){const fe=$.find(O=>O.name===q.settingsDefaultAgent);if(fe)return fe.name}return $.find(fe=>fe.name==="build")?.name||$[0]?.name},[]),Pe=je.useCallback(()=>{const q=ut.getState(),$=q.settingsDefaultModel;if(!$)return null;const fe=pn($);if(!fe)return null;const{providerId:O,modelId:Fe}=fe;return q.getModelMetadata(O,Fe)?{providerID:O,modelID:Fe}:null},[]),Re=je.useCallback((q,$)=>{const fe=ut.getState(),O=fe.settingsDefaultVariant,Fe=fe.currentProviderId===q&&fe.currentModelId===$?fe.currentVariant:void 0,et=fe.providers.find(at=>at.id===q)?.models.find(at=>at.id===$)?.variants;if(!et)return O||Fe||void 0;if(O&&Object.prototype.hasOwnProperty.call(et,O))return O;if(Fe&&Object.prototype.hasOwnProperty.call(et,Fe))return Fe},[]),Le=je.useCallback(async q=>{if(!m||!r)return;const $=ut.getState(),fe=Im.getState().lastUsedProvider,O=Pe(),Fe=O?.providerID||$.currentProviderId||fe?.providerID,Je=O?.modelID||$.currentModelId||fe?.modelID,Xe=Ae()||$.currentAgentName||void 0;if(!Fe||!Je){B.error(a("session.newWorktree.error.noModelSelected"));return}const et=Re(Fe,Je);if(q.issue){if(!r.issueGet||!r.issueComments)return;const at=await r.issueGet(m,q.issue.number);if(at.connected===!1||!at.repo||!at.issue)throw new Error("Failed to load issue context");const lt=await r.issueComments(m,q.issue.number);if(lt.connected===!1)throw new Error("Failed to load issue comments");const Ze=await ra("github.issue.review.visible",{issue_number:String(q.issue.number)}),We=await ra("github.issue.review.instructions"),pt=jv({repo:at.repo,issue:at.issue,comments:lt.comments??[]});await Ps.getState().sendMessage(Ze,Fe,Je,Xe,void 0,void 0,[{text:We,synthetic:!0},{text:pt,synthetic:!0}],et,void 0,{sessionId:q.sessionId}),B.success(a("session.newWorktree.toast.sessionFromIssue"));return}if(q.pr){if(!r.prContext)return;const at=await r.prContext(m,q.pr.number,{includeDiff:q.includeDiff,includeCheckDetails:!1});if(at.connected===!1||!at.repo||!at.pr)throw new Error("Failed to load PR context");const lt=await ra("github.pr.review.visible",{pr_number:String(q.pr.number)}),Ze=await ra("github.pr.review.instructions"),We=wv(at);await Ps.getState().sendMessage(lt,Fe,Je,Xe,void 0,void 0,[{text:Ze,synthetic:!0},{text:We,synthetic:!0}],et,void 0,{sessionId:q.sessionId}),B.success(a("session.newWorktree.toast.sessionFromPr"))}},[r,m,Ae,Pe,Re,a]),$e=u==="new-branch"?h:x;je.useEffect(()=>{if(!N?.all||!m||h.sourceBranch)return;(async()=>{try{const $=await Dm(m).catch(()=>null),fe=localStorage.getItem(cl),O=fe&&N.all?.includes(fe)?fe:$&&N.all?.includes($)?$:N.all?.includes("main")?"main":N.all?.includes("master")?"master":N.all?.[0]||"";O&&g(Fe=>({...Fe,sourceBranch:O}))}catch{}})()},[N,m,h.sourceBranch]),je.useEffect(()=>{if(!s)return;S("new-branch"),D({selectedBranch:"",worktreeName:""}),b(!1),E(!1),_(!1),H(!1),Y(""),V(""),ne({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const q=z();g({branchName:q,worktreeName:q,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1})},[s,z]),je.useEffect(()=>{if(u!=="new-branch"||!h.isSyncingWorktreeName)return;const q=qn(h.branchName),$=hs(q);g(fe=>({...fe,worktreeName:$}))},[u,h.branchName,h.isSyncingWorktreeName]);const Be=je.useCallback(async()=>{if(!p||!ee.touched||ue)return;ke&&ke.abort();const q=new AbortController;De(q),ne($=>({...$,isValidating:!0}));try{const $=u==="new-branch"?h.branchName:x.selectedBranch,fe=$e.worktreeName,O=qn($),Fe=hs(fe);let Je=null,Xe=null;if(O||(Je=a("session.newWorktree.error.branchNameRequired")),Fe||(Xe=a("session.newWorktree.error.worktreeDirectoryRequired")),O&&Fe){const et=u==="new-branch"?h.linkedPr:null,at=et?dl(et,k,j):null,lt=await kl(p,{mode:u==="existing-branch"||at?"existing":"new",branchName:O,worktreeName:Fe,existingBranch:at?.existingBranch??(u==="existing-branch"?O:void 0),...at?.ensureRemoteName?{ensureRemoteName:at.ensureRemoteName}:{},...at?.ensureRemoteUrl?{ensureRemoteUrl:at.ensureRemoteUrl}:{}});if(q.signal.aborted)return;lt.ok||lt.errors.forEach(Ze=>{if(Ze.code==="worktree_exists"){Xe=Xe??Ze.message;return}Ze.code.startsWith("branch_")&&(Je=Je??Ze.message)})}q.signal.aborted||ne(et=>({...et,isValidating:!1,branchError:Je,worktreeError:Xe}))}catch{q.signal.aborted||ne($=>({...$,isValidating:!1}))}},[p,u,h.branchName,h.linkedPr,x.selectedBranch,$e.worktreeName,k,j,ee.touched,ke,ue,a]),Oe=u==="new-branch"?h.branchName:x.selectedBranch;je.useEffect(()=>{if(!s||!p||!ee.touched||ue)return;const q=setTimeout(()=>{Be()},300);return()=>clearTimeout(q)},[$e.worktreeName,Oe,s,p,Be,ee.touched,ue]);const Ue=async()=>{if(!p||!m){B.error(a("session.newWorktree.error.noActiveProject"));return}ne(Fe=>({...Fe,touched:!0}));const q=u==="new-branch"?h.branchName:x.selectedBranch,$=$e.worktreeName,fe=qn(q),O=hs($);if(!fe){B.error(a("session.newWorktree.error.branchNameRequired"));return}if(!O){B.error(a("session.newWorktree.error.worktreeDirectoryRequired"));return}ke&&(ke.abort(),De(null)),ne(Fe=>({...Fe,isValidating:!1,branchError:null,worktreeError:null})),Me(!0);try{const Fe=u==="new-branch"?h.linkedPr:null,Je=u==="new-branch"?h.linkedIssue:null,Xe=u==="new-branch"?h.linkedPr:null,et=u==="new-branch"?h.includePrDiff:!1,at=!!(Je||Xe),lt=await vl(p),Ze=h.sourceBranch;let We="";const pt=(()=>{if(Fe){const Ge=dl(Fe,k,j);return We=Ge.sourceLabel,{preferredName:fe||O,mode:"existing",branchName:fe,worktreeName:O,existingBranch:Ge.existingBranch,setupCommands:lt,setUpstream:Ge.setUpstream,upstreamRemote:Ge.upstreamRemote,upstreamBranch:Ge.upstreamBranch,returnAfterDirectoryCreated:!0,...Ge.ensureRemoteName?{ensureRemoteName:Ge.ensureRemoteName}:{},...Ge.ensureRemoteUrl?{ensureRemoteUrl:Ge.ensureRemoteUrl}:{}}}return We=u==="new-branch"?Ze:"",{preferredName:fe||O,mode:u==="existing-branch"?"existing":"new",branchName:u==="existing-branch"?void 0:fe,worktreeName:O,existingBranch:u==="existing-branch"?fe:void 0,setupCommands:lt,returnAfterDirectoryCreated:!0,...Ze&&u==="new-branch"?{startRef:Ze}:{}}})(),pe=await Am(m,pt),st=await Em(p,pe);let nt=null;if(at){const Ge=Je?`#${Je.number} ${Je.title}`.trim():Xe?`#${Xe.number} ${Xe.title}`.trim():a("session.newWorktree.newSessionTitle"),ft=await Mm(Ge,st.path,null);if(!ft?.id)throw new Error("Failed to create session");nt=ft.id,n?.(st.path,{sessionId:nt}),e(!1),Me(!1),Rm(ft.id,Ge).catch(()=>{});try{Ps.getState().initializeNewOpenChamberSession(ft.id,ut.getState().agents)}catch{}}else e(!1),Me(!1);h.sourceBranch&&u==="new-branch"&&!h.linkedPr&&localStorage.setItem(cl,h.sourceBranch),B.success(a("session.newWorktree.toast.worktreeCreated"),{description:a("session.newWorktree.toast.worktreeCreatedDescription",{target:`${st.branch||st.name}${We?` ${a("session.newWorktree.fromSource",{source:We})}`:""}`})}),nt?Le({sessionId:nt,directory:st.path,issue:Je,pr:Xe,includeDiff:et}).catch(Ge=>{const ft=Ge instanceof Error?Ge.message:a("session.newWorktree.error.sendGitHubContextFailed");B.error(a("session.newWorktree.error.sendGitHubContextFailed"),{description:ft})}):n?.(st.path)}catch(Fe){const Je=Fe instanceof Error?Fe.message:a("session.newWorktree.error.createWorktreeFailed");B.error(a("session.newWorktree.error.createWorktreeFailed"),{description:Je})}finally{Me(!1)}},le=q=>{S(q),ne($=>({...$,touched:!1,branchError:null,worktreeError:null}))},W=q=>{if(!q){g($=>({...$,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:""}));return}if(q.type==="issue"){const $=q.item,fe=`issue-${$.number}-${Qa()}`;g(O=>({...O,linkedIssue:$,linkedPr:null,includePrDiff:!1,branchName:fe,worktreeName:hs(fe),isSyncingWorktreeName:!0}))}else if(q.type==="pr"){const $=q.item;g(fe=>({...fe,linkedPr:$,linkedIssue:null,includePrDiff:q.includeDiff??!1,branchName:$.head,worktreeName:hs($.head),isSyncingWorktreeName:!0}))}},de=c&&d?.connected===!0,Ee=(u==="existing-branch"?!!x.selectedBranch&&!!x.worktreeName&&!ee.branchError&&!ee.worktreeError:!!qn(h.branchName)&&!!h.worktreeName&&!ee.branchError&&!ee.worktreeError)&&!ue,Ce=()=>{g(q=>({...q,linkedIssue:null,linkedPr:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},He=t.jsxs("div",{className:ce("flex gap-2",o?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:ce("flex items-center gap-1.5 text-destructive",o?"w-full justify-center order-first":"mr-auto"),children:ee.touched&&(ee.branchError||ee.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ee.branchError||ee.worktreeError})]})}),t.jsxs("div",{className:ce("flex gap-2",o&&"w-full"),children:[t.jsx(G,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:ue,className:ce(o&&"flex-1"),children:a("session.newWorktree.actions.cancel")}),t.jsxs(G,{size:"sm",onClick:Ue,disabled:!Ee||ue,className:ce("gap-1.5",o&&"flex-1"),children:[ue&&t.jsx(M,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),a(ue?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[o?t.jsxs(Gn,{open:s,title:a("session.newWorktree.title"),onClose:()=>e(!1),footer:He,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(xn,{items:[{id:"new-branch",label:a("session.newWorktree.mode.newBranch"),icon:t.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:a("session.newWorktree.mode.existingBranch"),icon:t.jsx(M,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:u,onSelect:q=>le(q),variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[u==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(G,{variant:"outline",size:"sm",onClick:()=>_(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:x.selectedBranch?"text-foreground":"text-muted-foreground",children:x.selectedBranch||a("session.newWorktree.chooseBranch")}),t.jsx(M,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:U,disabled:!ge||w,title:a("session.newWorktree.fetchBranches"),children:w?t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(M,{name:"refresh",className:"size-4"})})]}),t.jsx(Gn,{open:J,title:a("session.newWorktree.selectBranch"),onClose:()=>_(!1),children:t.jsxs("div",{className:"space-y-4",ref:X,children:[t.jsx(it,{value:T,onChange:q=>Y(q.target.value),placeholder:a("session.newWorktree.searchBranches"),className:"h-8"}),w?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):k.length===0&&j.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[ye&&te&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:Ie.matching.map(q=>t.jsx("button",{onClick:()=>{D($=>({...$,selectedBranch:q.value,worktreeName:hs(q.label)})),ne($=>({...$,touched:!0})),_(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",x.selectedBranch===q.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:q.label})},`${q.source}-${q.value}`))})]}),ye&&!te&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),Ie.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a(ye?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:Ie.otherLocal.map(q=>t.jsx("button",{onClick:()=>{D($=>({...$,selectedBranch:q,worktreeName:hs(q)})),ne($=>({...$,touched:!0})),_(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",x.selectedBranch===q?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:q})},q))})]}),Ie.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a(ye?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:Ie.otherRemote.map(q=>t.jsx("button",{onClick:()=>{D($=>({...$,selectedBranch:`remotes/${q}`,worktreeName:hs(q)})),ne($=>({...$,touched:!0})),_(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",x.selectedBranch===`remotes/${q}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:q})},`remotes/${q}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex flex-col items-start gap-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.branchName")}),u==="new-branch"&&de&&t.jsxs(G,{variant:"outline",size:"sm",onClick:()=>I(!0),className:"gap-1.5 h-7",children:[t.jsx(M,{name:"github",className:"size-4 text-status-success"}),h.linkedIssue||h.linkedPr?a("session.newWorktree.actions.change"):a("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(it,{value:h.branchName,onChange:q=>{g($=>({...$,branchName:q.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ne(q=>({...q,touched:!0})),placeholder:a("session.newWorktree.branchNamePlaceholder"),disabled:!!h.linkedPr,className:ce("h-8",ee.touched&&ee.branchError&&"border-destructive",h.linkedPr&&"bg-muted text-muted-foreground")}),h.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(M,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.usingPrBranch",{branch:h.linkedPr.head})})]}),h.linkedIssue&&!h.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(M,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.fromIssue",{number:h.linkedIssue.number,title:h.linkedIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:a("session.newWorktree.worktreeDirectory")}),u!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const q=hs(u==="new-branch"?h.branchName:"");g($=>({...$,worktreeName:q,isSyncingWorktreeName:!0}))},disabled:!h.branchName||h.worktreeName===hs(h.branchName),className:ce("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",h.worktreeName===hs(h.branchName)||!h.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:a("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(M,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:a("session.newWorktree.actions.reset")})]})]}),t.jsx(it,{value:$e.worktreeName,onChange:q=>{u==="new-branch"?g($=>({...$,worktreeName:q.target.value,isSyncingWorktreeName:!1})):D($=>({...$,worktreeName:q.target.value}))},onBlur:()=>ne(q=>({...q,touched:!0})),placeholder:a("session.newWorktree.worktreeDirectoryPlaceholder"),className:ce("h-8",ee.touched&&ee.worktreeError&&"border-destructive")})]}),u==="new-branch"&&!h.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.sourceBranch")}),t.jsxs(G,{variant:"outline",size:"sm",onClick:()=>H(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:h.sourceBranch?"text-foreground":"text-muted-foreground",children:h.sourceBranch||a("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(M,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),h.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:a("session.newWorktree.newBranchFromSource",{source:h.sourceBranch})}),t.jsx(Gn,{open:Z,title:a("session.newWorktree.selectSourceBranch"),onClose:()=>H(!1),children:t.jsxs("div",{className:"space-y-4",ref:se,children:[t.jsx(it,{value:F,onChange:q=>V(q.target.value),placeholder:a("session.newWorktree.searchBranches"),className:"h-8"}),w?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):k.length===0&&j.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[be&&re&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:ve.matching.map(q=>t.jsx("button",{onClick:()=>{g($=>({...$,sourceBranch:q.value})),H(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",h.sourceBranch===q.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:q.label})},`${q.source}-${q.value}`))})]}),be&&!re&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),ve.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a(be?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:ve.otherLocal.map(q=>t.jsx("button",{onClick:()=>{g($=>({...$,sourceBranch:q})),H(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",h.sourceBranch===q?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:q})},q))})]}),ve.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:a(be?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:ve.otherRemote.map(q=>t.jsx("button",{onClick:()=>{g($=>({...$,sourceBranch:`remotes/${q}`})),H(!1)},className:ce("w-full text-left px-3 py-2.5 rounded-md transition-colors",h.sourceBranch===`remotes/${q}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:q})},`remotes/${q}`))})]})]})]})})]}),(h.linkedIssue||h.linkedPr)&&u==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),h.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.issueNumber",{number:h.linkedIssue.number})}),h.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.prNumber",{number:h.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:h.linkedIssue?.title||h.linkedPr?.title}),t.jsx("a",{href:h.linkedIssue?.url||h.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:q=>q.stopPropagation(),children:t.jsx(M,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:Ce,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]}),h.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[h.linkedPr.head," → ",h.linkedPr.base]}),h.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:a("session.newWorktree.includeDiffBadge")})]})]})]})]}):t.jsx(Ut,{open:s,onOpenChange:e,children:t.jsxs(Bt,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(_t,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Vt,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(M,{name:"git-branch",className:"h-5 w-5"}),a("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(xn,{items:[{id:"new-branch",label:a("session.newWorktree.mode.newBranch"),icon:t.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:a("session.newWorktree.mode.existingBranch"),icon:t.jsx(M,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:u,onSelect:q=>le(q),variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[u==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(us,{open:v,onOpenChange:b,children:[t.jsx(ds,{asChild:!0,children:t.jsxs(G,{variant:"outline",size:"sm",className:"h-9 min-w-[220px] max-w-full justify-between gap-2",children:[t.jsx("span",{className:ce("truncate",x.selectedBranch?"text-foreground":"text-muted-foreground"),children:x.selectedBranch||a("session.newWorktree.chooseBranch")}),t.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(ms,{align:"start",sideOffset:6,portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:Q,children:t.jsxs(Nr,{shouldFilter:!1,children:[t.jsx(kr,{placeholder:a("session.newWorktree.searchBranches"),value:T,onValueChange:Y,onKeyDown:me}),t.jsx(Sr,{disableHorizontal:!0,children:w?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):k.length===0&&j.length===0?t.jsx(Cr,{children:a("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ye&&te&&t.jsx(Us,{heading:a("session.newWorktree.matchingBranches"),children:Ie.matching.map(q=>t.jsx(Es,{value:q.value,onSelect:()=>{D($=>({...$,selectedBranch:q.value,worktreeName:hs(q.label)})),ne($=>({...$,touched:!0})),b(!1)},children:t.jsx("span",{className:"typography-small break-all",children:q.label})},`${q.source}-${q.value}`))}),ye&&!te&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),Ie.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[ye&&t.jsx(Cn,{}),t.jsx(Us,{heading:a(ye?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:Ie.otherLocal.map(q=>t.jsx(Es,{value:q,onSelect:()=>{D($=>({...$,selectedBranch:q,worktreeName:hs(q)})),ne($=>({...$,touched:!0})),b(!1)},children:t.jsx("span",{className:"typography-small break-all",children:q})},`local-${q}`))})]}),Ie.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(Ie.otherLocal.length>0||ye)&&t.jsx(Cn,{}),t.jsx(Us,{heading:a(ye?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:Ie.otherRemote.map(q=>t.jsx(Es,{value:`remotes/${q}`,onSelect:()=>{D($=>({...$,selectedBranch:`remotes/${q}`,worktreeName:hs(q)})),ne($=>({...$,touched:!0})),b(!1)},children:t.jsx("span",{className:"typography-small break-all",children:q})},`remote-${q}`))})]})]})})]})})]}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:U,disabled:!ge||w,title:a("session.newWorktree.fetchBranches"),children:w?t.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(M,{name:"refresh",className:"size-4"})})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.branchName")}),u==="new-branch"&&de&&t.jsxs(G,{variant:"outline",size:"sm",onClick:()=>I(!0),className:"gap-1.5 h-7",children:[t.jsx(M,{name:"github",className:"size-4 text-status-success"}),h.linkedIssue||h.linkedPr?a("session.newWorktree.actions.change"):a("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(it,{value:h.branchName,onChange:q=>{g($=>({...$,branchName:q.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ne(q=>({...q,touched:!0})),placeholder:a("session.newWorktree.branchNamePlaceholder"),disabled:!!h.linkedPr,className:ce("h-8",ee.touched&&ee.branchError&&"border-destructive",h.linkedPr&&"bg-muted text-muted-foreground")}),h.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(M,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.usingPrBranch",{branch:h.linkedPr.head})})]}),h.linkedIssue&&!h.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(M,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:a("session.newWorktree.fromIssue",{number:h.linkedIssue.number,title:h.linkedIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:a("session.newWorktree.worktreeDirectory")}),u!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const q=hs(u==="new-branch"?h.branchName:"");g($=>({...$,worktreeName:q,isSyncingWorktreeName:!0}))},disabled:!h.branchName||h.worktreeName===hs(h.branchName),className:ce("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",h.worktreeName===hs(h.branchName)||!h.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:a("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(M,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:a("session.newWorktree.actions.reset")})]})]}),t.jsx(it,{value:$e.worktreeName,onChange:q=>{u==="new-branch"?g($=>({...$,worktreeName:q.target.value,isSyncingWorktreeName:!1})):D($=>({...$,worktreeName:q.target.value}))},onBlur:()=>ne(q=>({...q,touched:!0})),placeholder:a("session.newWorktree.worktreeDirectoryPlaceholder"),className:ce("h-8",ee.touched&&ee.worktreeError&&"border-destructive")})]}),u==="new-branch"&&!h.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:a("session.newWorktree.sourceBranch")}),t.jsxs(us,{open:L,onOpenChange:E,children:[t.jsx(ds,{asChild:!0,children:t.jsxs(G,{variant:"outline",size:"sm",className:"h-9 min-w-[220px] max-w-full justify-between gap-2",children:[t.jsx("span",{className:ce("truncate",h.sourceBranch?"text-foreground":"text-muted-foreground"),children:h.sourceBranch||a("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(ms,{align:"start",portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:ie,children:t.jsxs(Nr,{shouldFilter:!1,children:[t.jsx(kr,{placeholder:a("session.newWorktree.searchBranches"),value:F,onValueChange:V,onKeyDown:me}),t.jsx(Sr,{disableHorizontal:!0,children:w?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:a("session.newWorktree.loadingBranches")}):k.length===0&&j.length===0?t.jsx(Cr,{children:a("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[be&&re&&t.jsx(Us,{heading:a("session.newWorktree.matchingBranches"),children:ve.matching.map(q=>t.jsx(Es,{value:q.value,onSelect:()=>{g($=>({...$,sourceBranch:q.value})),E(!1)},children:t.jsx("span",{className:"typography-small break-all",children:q.label})},`${q.source}-${q.value}`))}),be&&!re&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:a("session.newWorktree.noMatchingBranches")}),ve.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[be&&t.jsx(Cn,{}),t.jsx(Us,{heading:a(be?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:ve.otherLocal.map(q=>t.jsx(Es,{value:q,onSelect:()=>{g($=>({...$,sourceBranch:q})),E(!1)},children:t.jsx("span",{className:"typography-small break-all",children:q})},`local-${q}`))})]}),ve.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(ve.otherLocal.length>0||be)&&t.jsx(Cn,{}),t.jsx(Us,{heading:a(be?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:ve.otherRemote.map(q=>t.jsx(Es,{value:`remotes/${q}`,onSelect:()=>{g($=>({...$,sourceBranch:`remotes/${q}`})),E(!1)},children:t.jsx("span",{className:"typography-small break-all",children:q})},`remote-${q}`))})]})]})})]})})]}),h.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:a("session.newWorktree.newBranchFromSource",{source:h.sourceBranch})})]}),(h.linkedIssue||h.linkedPr)&&u==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),h.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.issueNumber",{number:h.linkedIssue.number})}),h.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:a("session.newWorktree.prNumber",{number:h.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:h.linkedIssue?.title||h.linkedPr?.title}),t.jsx("a",{href:h.linkedIssue?.url||h.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:q=>q.stopPropagation(),children:t.jsx(M,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:Ce,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]}),h.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[h.linkedPr.head," → ",h.linkedPr.base]}),h.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:a("session.newWorktree.includeDiffBadge")})]})]})]}),t.jsxs(Yt,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:ee.touched&&(ee.branchError||ee.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(M,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ee.branchError||ee.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:ue,children:a("session.newWorktree.actions.cancel")}),t.jsxs(G,{size:"sm",onClick:Ue,disabled:!Ee||ue,className:"gap-1.5",children:[ue&&t.jsx(M,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),a(ue?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(bv,{open:R,onOpenChange:I,onSelect:W})]})}export{_g as $,Il as A,fn as B,$v as C,_v as D,Lv as E,vf as F,jf as G,zi as H,tl as I,ks as J,Vv as K,nn as L,Iv as M,Hv as N,Av as O,Bv as P,Rv as Q,Ws as R,Sb as S,sn as T,Wf as U,tn as V,Fb as W,sl as X,vo as Y,vh as Z,bo as _,Uv as a,sc as a0,ac as a1,xx as a2,Dv as a3,Pp as a4,Ml as a5,Sp as a6,Ov as a7,Hb as b,zv as c,Ev as d,Pl as e,Mn as f,is as g,Py as h,Ht as i,Sf as j,Eo as k,su as l,Mv as m,Pv as n,Cb as o,cs as p,Lh as q,Fh as r,Fv as s,Tv as t,Kv as u,Th as v,xn as w,qf as x,gn as y,hn as z};
|