@openchambery/web 1.18.2-beta.47 → 1.18.2-beta.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AgentAvatar-C6E3lxmK.js +1 -0
- package/dist/assets/{AssistantView-Dd21Zo-e.js → AssistantView-B3HyFvCN.js} +1 -1
- package/dist/assets/{ChatContainer-DBfMXS7t.js → ChatContainer-CJJ0svRK.js} +4 -4
- package/dist/assets/{DiagramView-D-7CRzuH.js → DiagramView-Ctqdwb7r.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-C1bA36QM.js → MarkdownRendererImpl-D1S7TAFR.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-Df3qM-dS.js → MobileDetailNavigation-CcDKy9DS.js} +1 -1
- package/dist/assets/{MobileShareBridge-4IRX03l0.js → MobileShareBridge-JKzGwkWc.js} +1 -1
- package/dist/assets/{MobileSurface-sMIBhCDy.js → MobileSurface-KXW9k5Xo.js} +1 -1
- package/dist/assets/{MultiRunWindow-C-etq_qm.js → MultiRunWindow-BBMtMMvf.js} +1 -1
- package/dist/assets/{SettingsView-ka6dRJKE.js → SettingsView-C7KsKY0d.js} +1 -1
- package/dist/assets/{SettingsWindow-79X7TKrD.js → SettingsWindow-ImrOeuWO.js} +1 -1
- package/dist/assets/{TerminalView-BcnktfNI.js → TerminalView-HbdpmtvR.js} +1 -1
- package/dist/assets/{ToolOutputDialog-COCW2Ugt.js → ToolOutputDialog-C2RF6JZJ.js} +1 -1
- package/dist/assets/{appThemeRegistry-RkD3E8k3.js → appThemeRegistry-Cq53egpK.js} +2 -2
- package/dist/assets/{context-menu-CNHlYFR_.js → context-menu-CUf7Yvpz.js} +1 -1
- package/dist/assets/{gitApi-BzfsWWeA.js → gitApi-QH5OvaUL.js} +1 -1
- package/dist/assets/{insertionBoundaries-D7GzCNrX.js → insertionBoundaries-dGERU_2U.js} +1 -1
- package/dist/assets/{main-BI9vmQ4p.js → main-BqYwOK6d.js} +4 -4
- package/dist/assets/{main-DjXfVpAK.js → main-C3LbA4j7.js} +2 -2
- package/dist/assets/{miniChat-B-QV5_XD.js → miniChat-D7m65Qz1.js} +2 -2
- package/dist/assets/{mobile-pyhMCGu4.js → mobile-BXm5oHRc.js} +2 -2
- package/dist/assets/{multirun-CyWG9eM8.js → multirun-gB4gfJU5.js} +1 -1
- package/dist/assets/{projectMeta-C7hAHZgo.js → projectMeta-FvsMPNaZ.js} +1 -1
- package/dist/assets/{radio-Co0LvodE.js → radio-mlLmTiE9.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-Ds0v3e8V.js → renderElectronMiniChatApp-CaWUqgus.js} +2 -2
- package/dist/assets/{renderMobileApp-C0Rawk2V.js → renderMobileApp-BRKkL8QS.js} +4 -4
- package/dist/assets/{runtimeConfig-DjtCBq9M.js → runtimeConfig-ByneD-Zp.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-102y_Srv.js → runtimeEndpointReset-9poHN-AL.js} +1 -1
- package/dist/assets/{src-rCXBEJjd.css → src-B-bRIaqb.css} +1 -1
- package/dist/assets/{useAppFontEffects-CvGn9p85.js → useAppFontEffects-Bfc6VEC9.js} +2 -2
- package/dist/assets/{useDesktopWindowControlsLayout-DY3BWvQm.js → useDesktopWindowControlsLayout-C_pOkVAi.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CJNM6oxs.js → useEffectiveDirectory-CExuovMK.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-CSJe7Oso.js → useMobileNavigationStore-Dri7j9n_.js} +1 -1
- package/dist/assets/{useSessionAutoCleanup-CVU_ISq_.js → useSessionAutoCleanup-BsI23IOM.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-0HW6LvKs.js → useWorkerHighlightedLines-BTb73Pdd.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/dist/assets/AgentAvatar-y3ycseGU.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{n as l}from"./clipboard-Bu8y4WEC.js";import{t as u}from"./utils-DpGCrB3y.js";import{n as d}from"./Icon-CstxOD6I.js";import{t as f}from"./multirun-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{n as l}from"./clipboard-Bu8y4WEC.js";import{t as u}from"./utils-DpGCrB3y.js";import{n as d}from"./Icon-CstxOD6I.js";import{t as f}from"./multirun-gB4gfJU5.js";var p=c(),m=e(s(),1),h=o(),g=e=>{let o=(0,p.c)(33),{open:s,onOpenChange:c,initialPrompt:g}=e,v=m.useId(),{t:y}=l(),b=_,x;o[0]===c?x=o[1]:(x=e=>{!e&&b()||c(e)},o[0]=c,o[1]=x);let S;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,h.jsx)(t,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=S):S=o[2];let C;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=u(`relative pointer-events-auto`,`w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]`,`flex flex-col rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`),o[3]=C):C=o[3];let w;o[4]===c?w=o[5]:(w=()=>c(!1),o[4]=c,o[5]=w);let T;o[6]===y?T=o[7]:(T=y(`multiRun.window.actions.closeAria`),o[6]=y,o[7]=T);let E;o[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,h.jsx)(d,{name:`close`,className:`h-5 w-5`}),o[8]=E):E=o[8];let D;o[9]!==w||o[10]!==T?(D=(0,h.jsx)(`div`,{className:`absolute right-0.5 top-0.5 z-50`,children:(0,h.jsx)(`button`,{type:`button`,onClick:w,"aria-label":T,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:E})}),o[9]=w,o[10]=T,o[11]=D):D=o[11];let O;o[12]===y?O=o[13]:(O=y(`multiRun.window.description`),o[12]=y,o[13]=O);let k;o[14]!==v||o[15]!==O?(k=(0,h.jsx)(a,{id:v,className:`sr-only`,children:O}),o[14]=v,o[15]=O,o[16]=k):k=o[16];let A,j;o[17]===c?(A=o[18],j=o[19]):(A=()=>c(!1),j=()=>c(!1),o[17]=c,o[18]=A,o[19]=j);let M;o[20]!==g||o[21]!==A||o[22]!==j?(M=(0,h.jsx)(f,{initialPrompt:g,onCreated:A,onCancel:j,isWindowed:!0}),o[20]=g,o[21]=A,o[22]=j,o[23]=M):M=o[23];let N;o[24]!==v||o[25]!==M||o[26]!==D||o[27]!==k?(N=(0,h.jsxs)(i,{children:[S,(0,h.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,h.jsxs)(r,{"aria-describedby":v,className:C,children:[D,k,M]})})]}),o[24]=v,o[25]=M,o[26]=D,o[27]=k,o[28]=N):N=o[28];let P;return o[29]!==s||o[30]!==x||o[31]!==N?(P=(0,h.jsx)(n,{open:s,onOpenChange:x,children:N}),o[29]=s,o[30]=x,o[31]=N,o[32]=P):P=o[32],P};function _(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{g as MultiRunWindow};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{$ as n,D as r,M as i,a,j as o,o as s,r as c,t as l,u,w as d,y as f}from"./useUIStore-CJsC3a8g.js";import{$t as p,Bt as m,D as h,E as g,Ht as _,Kt as v,O as y,R as b,Ut as x,Vt as S,Xt as C,Yt as w,a as T,bn as E,cn as D,d as O,en as k,et as A,f as j,gn as M,hn as N,i as P,k as F,kn as I,l as L,mn as R,qt as z,r as B,u as V,un as H,xn as U}from"./persistence-DPmGG6sf.js";import{_ as W,a as ee,g as G,h as te,i as ne,l as re,m as ie,n as ae,p as oe,r as se,t as ce,u as le}from"./desktopHosts-DNzqqcVf.js";import{r as ue}from"./desktopRelayRestore-Dl8nD4gy.js";import{a as de,i as fe,r as pe,t as me}from"./vendor-zustand-B4dlGEM2.js";import{nt as he,rt as ge}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as _e,Nt as ve,n as ye,t as be}from"./platform-CbV34Pzu.js";import{n as xe}from"./vendor-react-DLPElpoQ.js";import{s as Se}from"./vendor-tanstack-react-query-D7pys_c9.js";import{W as Ce}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{r as we}from"./vendor-sonner-DVzioF3d.js";import{c as Te,n as Ee}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as De,r as Oe,t as ke}from"./clipboard-Bu8y4WEC.js";import{a as Ae,i as je,r as Me}from"./MobileShareBridge-4IRX03l0.js";import{$a as Ne,Do as Pe,Eo as Fe,Fa as Ie,Gi as Le,Ia as Re,Ji as ze,Ki as Be,Na as Ve,Oo as He,Pa as Ue,Qa as We,So as Ge,Vt as Ke,Wi as qe,Xa as Je,Xi as Ye,Yi as Xe,Za as Ze,_o as Qe,ai as $e,ao as et,bo as tt,ci as nt,co as rt,do as it,eo as at,fo as ot,go as st,ho as ct,hr as lt,ii as ut,io as dt,ja as ft,ko as pt,lo as mt,mo as ht,no as gt,oo as _t,pi as vt,po as yt,ro as bt,si as xt,so as St,ta as Ct,to as wt,uo as Tt,vo as Et,vr as K,wo as Dt,xo as Ot,yo as kt}from"./useMobileNavigationStore-CSJe7Oso.js";import{_ as At,a as jt,c as Mt,f as Nt,g as Pt,h as Ft,i as It,t as Lt,y as Rt}from"./MobileDetailNavigation-Df3qM-dS.js";import{i as zt}from"./useAssistantUIStore-gi2s2F--.js";import{t as Bt}from"./AgentAvatar-y3ycseGU.js";import{i as Vt,t as q}from"./utils-DpGCrB3y.js";import{n as J}from"./Icon-CstxOD6I.js";import{a as Ht,i as Ut,n as Wt,o as Gt,r as Kt,t as qt}from"./dialog-CsFlH6Lj.js";import{t as Y}from"./button-CQ8B8MBG.js";import{A as Jt,E as Yt,M as Xt,N as Zt,S as Qt,a as $t,g as en,h as tn,i as nn,j as rn,n as an,o as on,v as sn,x as cn}from"./projectMeta-C7hAHZgo.js";import{t as ln}from"./input-DVGFeMHA.js";import{i as un,n as dn,t as fn}from"./tooltip-BkJSe4NL.js";import{C as pn,D as mn,E as hn,H as gn,K as _n,M as vn,N as yn,O as bn,R as xn,S as Sn,T as Cn,U as wn,V as Tn,W as En,a as Dn,b as On,c as kn,f as An,i as jn,j as Mn,p as Nn,q as Pn,s as Fn,t as In,u as X,w as Ln,x as Rn,y as zn,z as Bn}from"./useSessionAutoCleanup-CVU_ISq_.js";import{n as Vn}from"./useThemeSystem-DMzWVJaW.js";import{A as Hn,D as Un,E as Wn,H as Gn,J as Kn,N as qn,O as Jn,Q as Yn,R as Xn,U as Zn,V as Qn,Y as $n,a as er,f as tr,h as nr,i as rr,j as ir,p as ar,q as or,r as sr,s as cr,t as lr}from"./radio-Co0LvodE.js";import{i as ur,r as dr,t as fr}from"./OverlayScrollbar-CW5VL9Qc.js";import{n as pr}from"./useRuntimeAPIs-DSLXJybW.js";import{c as mr,i as hr,n as gr}from"./appThemeRegistry-RkD3E8k3.js";import{a as _r}from"./url-DNq-9alX.js";import{p as vr}from"./markdown-worker-BJk0TBYO.js";import{t as yr}from"./sortable-tabs-strip-DuAPHzVT.js";import{$ as br,A as xr,B as Sr,C as Cr,D as wr,E as Tr,F as Er,G as Dr,H as Or,I as Z,J as kr,K as Ar,L as jr,M as Mr,N as Nr,O as Pr,P as Fr,Q as Ir,R as Lr,S as Rr,T as zr,U as Br,V as Vr,W as Hr,X as Ur,Y as Wr,Z as Gr,_ as Kr,a as qr,b as Jr,c as Yr,d as Xr,f as Zr,h as Qr,j as $r,k as ei,l as ti,m as ni,n as ri,p as ii,q as ai,s as oi,u as si,v as ci,w as li,y as ui,z as di}from"./MobileSurface-sMIBhCDy.js";import{a as fi,n as pi,r as mi,t as hi}from"./context-menu-CNHlYFR_.js";import{n as gi,r as _i,t as vi}from"./collapsible-DhqdBbXo.js";import{n as yi,t as bi}from"./vendor-yaml-DIcAK3EC.js";import{t as xi}from"./vendor-qrcode-DAuVxiQR.js";var Si=xe(),Q=e(ge(),1),$=he(),Ci=`https://github.com/yee94/openchamber`,wi=`https://discord.gg/ZYRSdnwwKA`,Ti=`https://x.com/openchamber_dev`,Ei=800,Di=({initialUpdateDialogOpen:e=!1})=>{let{t}=De(),[n,r]=Q.useState(e),[i,a]=Q.useState(!1),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(null),m=Sr(me(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),{isMobile:h}=ur(),[g,_]=Q.useState(!1),[v,y]=Q.useState(()=>nt()),b=Ee(e=>{vt(e),y(e)}),x=o||t(`settings.openchamber.about.state.unknown`),S=Ee(async()=>{if(!g){_(!0);try{let{outcome:e,eventCount:n}=await xt();if(e===`cancelled`)return;if(e===`failed`){K.error(t(`settings.openchamber.about.diagnostics.toast.failed`));return}K.success(t(n>0?`settings.openchamber.about.diagnostics.toast.exported`:`settings.openchamber.about.diagnostics.toast.empty`))}catch{K.error(t(`settings.openchamber.about.diagnostics.toast.failed`))}finally{_(!1)}}});Q.useEffect(()=>{let e=!1;return Br().then(t=>{e||s(t)}),Or().then(t=>{e||l(t)}),()=>{e=!0}},[]);let C=Vr(o,c)??x;Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await I(`/api/system/info`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.openchamberVersion==`string`&&n.openchamberVersion.trim().length>0?n.openchamberVersion.trim():null;e||d(r)}catch{e||d(null)}})(),()=>{e=!0}},[]),Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await I(`/api/opencode/upgrade-status`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.currentVersion==`string`&&n.currentVersion.trim().length>0?n.currentVersion.trim():null;e||p(r)}catch{e||p(null)}})(),()=>{e=!0}},[]);let w=Q.useRef(!1);Q.useEffect(()=>{if(m.checking)a(!0),w.current=!0;else if(i){let e=setTimeout(()=>{a(!1),w.current&&m.error?(K.error(t(`settings.openchamber.about.toast.checkFailed`),{description:m.error}),w.current=!1):w.current&&!m.available&&!m.error&&(K.success(t(`settings.openchamber.about.toast.latestVersion`)),w.current=!1)},Ei);return()=>clearTimeout(e)}},[t,m.checking,i,m.available,m.error]);let T=m.checking||i;return h?(0,$.jsxs)(`div`,{className:`w-full space-y-6 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Yn,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`OpenChamber`})]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:C})}),(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:u||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:f||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(jr,{children:!T&&m.available?(0,$.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`size-4`}),m.info?.inAppApply?t(`settings.openchamber.about.actions.applyOtaToVersion`,{version:m.info?.version||``}):m.info?.manualUpdate?t(`settings.openchamber.about.actions.installNativeToVersion`,{version:m.info?.version||``}):t(`settings.openchamber.about.actions.updateToVersion`,{version:m.info?.version||``})]}):(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m.checkForUpdates(),disabled:T,children:[T?(0,$.jsx)(J,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(J,{name:`refresh`,className:`size-4`}),t(T?`settings.openchamber.about.state.checking`:`settings.openchamber.about.actions.checkForUpdates`)]})}),m.error&&(0,$.jsx)(jr,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:m.error})}),(0,$.jsx)(Lr,{itemId:`about.diagnostics`,checked:v,onChange:b,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),v&&(0,$.jsx)(jr,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:g,onClick:()=>void S(),children:t(g?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-5`,children:[(0,$.jsxs)(`a`,{href:Ci,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:wi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`discord-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`Discord`})]})]}),(0,$.jsxs)(`a`,{href:Ti,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(di,{open:n,onOpenChange:r,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:t(`settings.openchamber.about.title`),children:[(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:x})}),(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:u||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:f||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(jr,{children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-3`,children:[m.checking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:t(`settings.openchamber.about.state.checking`)})]}),!m.checking&&m.available&&(0,$.jsxs)(Y,{size:`sm`,variant:`default`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`h-4 w-4 mr-1`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:m.info?.version||``})]}),!m.checking&&!m.available&&!m.error&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.about.state.upToDate`)}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>m.checkForUpdates(),disabled:m.checking,children:t(`settings.openchamber.about.actions.checkForUpdates`)})]})}),m.error&&(0,$.jsx)(jr,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:m.error})}),(0,$.jsx)(Lr,{itemId:`about.diagnostics`,checked:v,onChange:b,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),v&&(0,$.jsx)(jr,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:g,onClick:()=>void S(),children:t(g?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})}),(0,$.jsxs)(jr,{controlClassName:`flex-wrap`,children:[(0,$.jsxs)(`a`,{href:Ci,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Ti,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]})]}),(0,$.jsx)(di,{open:n,onOpenChange:r,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]})},Oi=`/assets/android-direct-share-1a0lp154.jpg`,ki=`/assets/ios-share-sheet-B3Dlufnc.jpg`,Ai=`/assets/select-assistant-C89IRspC.jpg`,ji=`openchamber:assistant-share-welcome:v1`,Mi=[{image:ki,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:Oi,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Ai,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],Ni=e=>{let t=(0,Si.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=De(),[s,c]=Te(ji,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=Ee(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(J,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(Gt,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(Kt,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)(Ht,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=Mi.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(Ut,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(Y,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(Wt,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(qt,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Pi=`useCommandsStore`,Fi=new Set([`init`,`review`]),Ii=e=>new Promise(t=>setTimeout(t,e)),Li=e=>Fi.has(e.name),Ri=async(e,t)=>{await Et(V,e,t),r()===t&&Pe(`commands`,{source:Pi})},zi=de()(pe(fe(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=kt(),t=r();try{return await Et(V,e,t),!0}catch{return!1}},createCommand:async t=>Bi(`POST`,t.name,t,e),updateCommand:async(t,n)=>Bi(`PATCH`,t,n,e),deleteCommand:async t=>Bi(`DELETE`,t,void 0,e),getCommandByName:e=>Qe().find(t=>t.name===e)}),{name:`commands-store`,storage:f(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Bi(e,t,n,i){Dt(`${{POST:`Creating`,PATCH:`Updating`,DELETE:`Deleting`}[e]} command configuration…`);let a=kt(),o=r(),s=!1;try{let r={};if(e===`POST`&&(r.template=n?.template||``,n?.description&&(r.description=n.description),n?.agent&&(r.agent=n.agent),n?.model&&(r.model=n.model),n?.scope&&(r.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(r[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,l=await I(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(r)}}),u=await l.json().catch(()=>null);if(!l.ok)throw Error(u?.error||`Failed to ${e.toLowerCase()} command`);return s=u?.requiresReload??!0,s?await Vi(a,o,{message:u?.message,delayMs:u?.reloadDelayMs}):await Ri(a,o),e===`DELETE`&&i({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}finally{Ge()}}async function Vi(e,t,n){n.delayMs&&await Ii(n.delayMs),Fe(n.message||`Refreshing commands…`),await Ri(e,t)}typeof window<`u`&&(window.__zustand_commands_store__=zi),pt(e=>{e.source!==Pi&&He(e,`commands`)&&zi.getState().loadCommands()});var Hi=()=>{try{let e=Ot.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=ve.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},Ui=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],Wi=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Gi=e=>{if(typeof e==`string`)return e.trim()||void 0},Ki=800,qi=de()(pe(fe((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=Hi();try{return!e?.force&&Dr(V,t).length>0||await ai(V,t,r()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{Dt(`Creating MCP server configuration…`);let n=!1,i=`directory`in(t??{})?t?.directory?.trim()||null:Hi(),a=t?.transportIdentity??r();try{let t=Ji(e),r=i?`?directory=${encodeURIComponent(i)}`:``,o=await I(`/api/config/mcp/${encodeURIComponent(e.name)}${r}`,{method:`POST`,headers:{"Content-Type":`application/json`,...i?{"x-opencode-directory":i}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return s?.requiresReload?(n=!0,await We({message:s.message,delayMs:s.reloadDelayMs??Ki,scopes:[`mcp`],queryDirectory:i,transportIdentity:a}),await ai(V,i,a),await kr(V,i,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):(await ai(V,i,a),await kr(V,i,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning})}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}finally{n||Ge()}},updateMcp:async(e,t,n)=>{Dt(`Updating MCP server configuration…`);let i=!1,a=`directory`in(n??{})?n?.directory?.trim()||null:Hi(),o=n?.transportIdentity??r();try{let n=Ji(t),r=a?`?directory=${encodeURIComponent(a)}`:``,s=await I(`/api/config/mcp/${encodeURIComponent(e)}${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return c?.requiresReload?(i=!0,await We({message:c.message,delayMs:c.reloadDelayMs??Ki,scopes:[`mcp`],queryDirectory:a,transportIdentity:o}),await ai(V,a,o),await kr(V,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):(await ai(V,a,o),await kr(V,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning})}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}finally{i||Ge()}},deleteMcp:async(n,i)=>{Dt(`Deleting MCP server configuration…`);let a=!1,o=`directory`in(i??{})?i?.directory?.trim()||null:Hi(),s=i?.transportIdentity??r();try{let r=o?`?directory=${encodeURIComponent(o)}`:``,i=await I(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),c=await i.json().catch(()=>null);if(!i.ok)throw Error(c?.error||`Failed to delete MCP server`);return c?.requiresReload&&(a=!0,await We({message:c.message,delayMs:c.reloadDelayMs??Ki,scopes:[`mcp`],queryDirectory:o,transportIdentity:s})),t().selectedMcpName===n&&e({selectedMcpName:null}),Hr.getState().clearDiagnostic(n,o,s),await ai(V,o,s),await kr(V,o,s),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}finally{a||Ge()}}}),{name:`mcp-config-store`,storage:f(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Ji(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=Wi(e.environment)??{}),e.headers!==void 0&&(t.headers=Wi(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Gi(e.oauthClientId),clientSecret:Gi(e.oauthClientSecret),scope:Gi(e.oauthScope),redirectUri:Gi(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var Yi=()=>{let e=ve.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},Xi=`useSkillsStore`,Zi=e=>new Promise(t=>setTimeout(t,e)),Qi=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=Yi();return typeof t==`string`&&t.trim()||null},$i=2e4,ea=300,ta=4,na=800,ra=200,ia=2e3,aa=de()(pe(fe((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await gt(V,Yi(),r()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=Yi(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await I(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{Dt(`Creating skill...`);let n=!1;try{let i={name:e.name,description:e.description};e.instructions&&(i.instructions=e.instructions),e.scope&&(i.scope=e.scope),e.source&&(i.source=e.source),e.supportingFiles&&(i.supportingFiles=e.supportingFiles);let a=Qi(t),o=r(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await I(`/api/config/skills/${encodeURIComponent(e.name)}${s}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to create skill`;throw Error(e)}return l?.requiresReload??!1?(n=!0,await sa({message:l?.message,delayMs:l?.reloadDelayMs,directory:a,transportIdentity:o}),!0):(await gt(V,a,o),await St(V,a,o),Pe(`skills`,{source:Xi}),!0)}catch{return!1}finally{n||Ge()}},updateSkill:async(e,t,n)=>{Dt(`Updating skill...`);let i=!1;try{let a={};t.description!==void 0&&(a.description=t.description),t.instructions!==void 0&&(a.instructions=t.instructions),t.supportingFiles!==void 0&&(a.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(a.targetPath=t.targetPath);let o=Qi(n),s=r(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await I(`/api/config/skills/${encodeURIComponent(e)}${c}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return u?.requiresReload??!1?(i=!0,await sa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await gt(V,o,s),await St(V,o,s),Pe(`skills`,{source:Xi}),!0)}catch{return!1}finally{i||Ge()}},deleteSkill:async(n,i)=>{Dt(`Deleting skill...`);let a=!1;try{let o=Qi(i),s=r(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await I(`/api/config/skills/${encodeURIComponent(n)}${c}`,{method:`DELETE`}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return u?.requiresReload??!1?(a=!0,await sa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await gt(V,o,s),await St(V,o,s),Pe(`skills`,{source:Xi}),t().selectedSkillName===n&&e({selectedSkillName:null}),!0)}catch{return!1}finally{a||Ge()}},getSkillByName:e=>wt(V,Yi()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=Yi(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=Yi(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=Yi(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:f(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=aa);async function oa(e){let t=typeof e==`number`&&e>0?Math.min(e,ea):0;t>0&&await Zi(t);let n=Date.now(),r=0,i=null;for(;Date.now()-n<$i;){r+=1,Fe(`Waiting for OpenCode… (attempt ${r})`);try{if(await ve.checkHealth())return;i=Error(`OpenCode health check reported not ready`)}catch(e){i=e}let e=Date.now()-n;await Zi(r<=ta&&e<1200?ea:Math.min(na+Math.max(0,r-ta)*ra,ia))}throw i||Error(`OpenCode did not become ready in time`)}async function sa(e){let t=e&&`directory`in e?e.directory?.trim()||null:Yi(),n=e?.transportIdentity??r();try{Fe(e?.message||`Refreshing skills…`)}catch{}try{if(await oa(e?.delayMs),r()!==n||(Fe(`Refreshing skills…`),await gt(V,t,n),r()!==n))return;await St(V,t,n),Pe(`skills`,{source:Xi})}catch(e){throw Fe(`OpenCode refresh failed. Please retry.`),await Zi(1500),e}finally{Ge()}}var ca=null;ca||=pt(e=>{if(e.source!==Xi&&He(e,`skills`)){let e=Yi(),t=r();gt(V,e,t).then(()=>St(V,e,t)).catch(()=>void 0)}});var la=e=>{let t=(0,Si.c)(37),{className:n}=e,{t:r}=De(),i=Ot(ua),a=Ot(da),o=Ot(fa),s=p(),c;t[0]===i?c=t[1]:(c=[...i].sort(pa),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let m=f,h;t[8]===n?h=t[9]:(h=q(n),t[8]=n,t[9]=h);let g;t[10]===r?g=t[11]:(g=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=g);let _;t[12]===r?_=t[13]:(_=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=_);let v,y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=q(`text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none`,`hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70`,`flex items-center gap-1.5 text-left`),y=(0,$.jsx)(J,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=v,t[15]=y):(v=t[14],y=t[15]);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(J,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=x):x=t[18];let S;t[19]!==g||t[20]!==_||t[21]!==b?(S=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":g,title:_,className:v,children:[y,b,x]})}),t[19]=g,t[20]=_,t[21]=b,t[22]=S):S=t[22];let C=d?.id??``,w;t[23]===o?w=t[24]:(w=e=>{e&&o(e)},t[23]=o,t[24]=w);let T;t[25]===l?T=t[26]:(T=l.map(ma),t[25]=l,t[26]=T);let E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,$.jsx)(Un,{align:`start`,className:`w-auto`,children:(0,$.jsx)(Hn,{value:C,onValueChange:w,children:T})}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==S||t[32]!==E?(D=(0,$.jsxs)(Wn,{children:[S,E]}),t[31]=S,t[32]=E,t[33]=D):D=t[33];let O;return t[34]!==D||t[35]!==h?(O=(0,$.jsx)(`div`,{className:h,children:D}),t[34]=D,t[35]=h,t[36]=O):O=t[36],O};function ua(e){return e.projects}function da(e){return e.activeProjectId}function fa(e){return e.setActiveProject}function pa(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function ma(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(ir,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function ha(e,t){return`opencode:sidebar-group:${e}:${t}`}var ga=e=>{let t=(0,Si.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=ha(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(_a),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(J,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=q(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(Z,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(va),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`flex w-full items-center gap-1 rounded-md px-2 py-1 text-left`,`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,`hover:bg-[var(--interactive-hover)] transition-colors duration-150`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(J,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function _a(e){return!e}function va(e){return!e}var ya=e=>{if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.permission==`string`&&typeof e.pattern==`string`&&typeof e.action==`string`&&(e.action===`allow`||e.action===`ask`||e.action===`deny`)&&t.push({permission:e.permission,pattern:e.pattern,action:e.action})}return t},ba=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&t.set(`${n.permission}::${n.pattern}`,n);return Array.from(t.values())},xa=e=>{let t=ba(ya(e));if(t.length===0)return;let n={};for(let e of t)e.permission&&((n[e.permission]||={})[e.pattern]=e.action);let r={};for(let[e,t]of Object.entries(n)){let n=Object.keys(t);if(n.length===1&&n[0]===`*`){r[e]=t[`*`];continue}r[e]=t}return Object.keys(r).length>0?r:void 0},Sa=({onItemSelect:e})=>{let{t}=De(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=at(me(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=ht();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(Je(e)){K.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{Je(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?K.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):K.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?K.error(t(`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?K.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;let i=e,a=e.model?.providerID&&e.model?.modelID?`${e.model.providerID}/${e.model.modelID}`:null,o=e;g({name:r,scope:i.scope||`user`,description:e.description,model:a,variant:e.variant,temperature:e.temperature,top_p:e.topP,prompt:e.prompt,mode:e.mode,permission:xa(e.permission),disable:o.disable}),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){K.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){K.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,o=n,s=await _({name:e,description:n.description,model:a,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:xa(n.permission),disable:o.disable,scope:o.scope});if(s.ok){let r=await v(n.name,o.scope);r.ok?(s.requiresManualRestart||r.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):K.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):K.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else K.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(J,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(J,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(J,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>!Ze(e)),j=A.filter(Je),M=A.filter(e=>!Je(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(Y,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(la,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(Z,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(Ca,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(ga,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(Ca,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(Z,{label:F,children:P.map(t=>(0,$.jsx)(Ca,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(qt,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(Wt,{className:`max-w-md`,children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(Kt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(qt,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(Wt,{children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(Kt,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(ln,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},Ca=e=>{let t=(0,Si.c)(52),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=De(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=dr(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[12]=n.name,t[13]=w);let T;t[14]!==n.mode||t[15]!==l?(T=l(n.mode),t[14]=n.mode,t[15]=l,t[16]=T):T=t[16];let E;t[17]!==n||t[18]!==p.scope||t[19]!==f?(E=(p.scope||Je(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Je(n)?f(`settings.agents.sidebar.badge.system`):p.scope}),t[17]=n,t[18]=p.scope,t[19]=f,t[20]=E):E=t[20];let D;t[21]!==w||t[22]!==T||t[23]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[w,T,E]}),t[21]=w,t[22]=T,t[23]=E,t[24]=D):D=t[24];let O;t[25]===n.description?O=t[26]:(O=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[25]=n.description,t[26]=O);let k;t[27]!==i||t[28]!==D||t[29]!==O?(k=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[D,O]}),t[27]=i,t[28]=D,t[29]=O,t[30]=k):k=t[30];let A;t[31]===d?A=t[32]:(A=e=>{e&&_(!1),d(e)},t[31]=d,t[32]=A);let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[33]=j):j=t[33];let M;t[34]===y?M=t[35]:(M=(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:y(Jn)}),t[34]=y,t[35]=M);let N;t[36]!==u||t[37]!==A||t[38]!==M?(N=(0,$.jsxs)(Wn,{open:u,onOpenChange:A,children:[j,M]}),t[36]=u,t[37]=A,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==k||t[41]!==N?(P=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[k,N]}),t[40]=k,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==P||t[44]!==C?(F=(0,$.jsx)(fi,{render:C,children:P}),t[43]=P,t[44]=C,t[45]=F):F=t[45];let I;t[46]===y?I=t[47]:(I=(0,$.jsx)(pi,{className:`w-fit min-w-20`,children:y(mi)}),t[46]=y,t[47]=I);let L;return t[48]!==g||t[49]!==F||t[50]!==I?(L=(0,$.jsxs)(hi,{open:g,onOpenChange:_,children:[F,I]}),t[48]=g,t[49]=F,t[50]=I,t[51]=L):L=t[51],L},wa=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ta=(e,t)=>{let n=wa(e),r=wa(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},Ea=(e,t)=>t?e.globalPermission!==t.globalPermission||!Ta(e.permissionRules,t.permissionRules):!1,Da=e=>{let t=e.trim();return t===``?null:t},Oa=e=>{let t=e.trim();return t===``?null:t},ka=e=>e.trim()||void 0,Aa=e=>e.trim()||null,ja=({isNewAgent:e,agentName:t,draftScope:n,draftHasExplicitPermission:r,current:i,initial:a,permissionConfig:o})=>{if(e){let e=Ea(i,a)||r,s=i.description.trim(),c=Da(i.model),l=Oa(i.variant),u=ka(i.prompt);return{name:t,mode:i.mode,...s?{description:s}:{},...c?{model:c}:{},...l?{variant:l}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...i.topP===void 0?{}:{top_p:i.topP},...u?{prompt:u}:{},...e?{permission:o}:{},...n?{scope:n}:{}}}let s={name:t};if(!a)return s;if(i.description!==a.description){let e=i.description.trim();e&&(s.description=e)}return i.mode!==a.mode&&(s.mode=i.mode),i.model!==a.model&&(s.model=Da(i.model)),i.variant!==a.variant&&(s.variant=Oa(i.variant)??null),i.temperature!==a.temperature&&(s.temperature=i.temperature??null),i.topP!==a.topP&&(s.top_p=i.topP??null),i.prompt!==a.prompt&&(s.prompt=Aa(i.prompt)),Ea(i,a)&&(s.permission=o),s},Ma=[`*`,`read`,`edit`,`glob`,`grep`,`list`,`bash`,`task`,`skill`,`lsp`,`todoread`,`todowrite`,`webfetch`,`websearch`,`codesearch`,`external_directory`,`doom_loop`,`question`,`plan_enter`,`plan_exit`],Na=e=>e===`allow`||e===`ask`||e===`deny`,Pa=(e,t)=>`${e}::${t}`,Fa=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&Na(n.action)&&t.set(Pa(n.permission,n.pattern),{permission:n.permission,pattern:n.pattern,action:n.action});return Array.from(t.values())},Ia=e=>{let t=new Map;for(let n of Fa(e))t.set(Pa(n.permission,n.pattern),n);return t},La=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ra=(e,t)=>{let n=La(Fa(e)),r=La(Fa(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},za=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,Ba=(e,t)=>Fa(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),Va=e=>{if(Array.isArray(e))return Fa(e);if(Na(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(Na(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))Na(i)&&t.push({permission:n,pattern:e,action:i})}return t},Ha=(e,t)=>{let n=Fa(t),r={};for(let e of n)(r[e.permission]||={})[e.pattern]=e.action;let i={};for(let[e,t]of Object.entries(r))if(e!==`*`){if(Object.keys(t).length===1&&t[`*`]){i[e]=t[`*`];continue}i[e]=t}return Object.keys(i).length===0?e:(e!==`allow`&&(i[`*`]=e),i)},Ua=(e,t)=>{let n=Re(t);if(!n)return[];let r=e.find(e=>e.id===n.providerId)?.models?.find(e=>e.id===n.modelId);return r?.variants?Object.keys(r.variants):[]},Wa=()=>{let{t:e}=De(),t=Ct(e=>e.providers),{selectedAgentName:n,getAgentByName:r,createAgent:i,updateAgent:a,agentDraft:o,setAgentDraft:s}=at(me(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:c=[]}=ht(),l=n?r(n):null,u=!!(o&&o.name===n&&!l),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(void 0),[T,E]=Q.useState(void 0),[D,O]=Q.useState(``),[k,A]=Q.useState(`allow`),[j,M]=Q.useState([]),[N,P]=Q.useState([]),[F,I]=Q.useState(``),[L,R]=Q.useState(`*`),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),U=Q.useRef(null),W=_e(e=>e.currentDirectory??null),[ee,G]=Q.useState([]),te=Q.useMemo(()=>Ua(t,y),[y,t]),ne=te.length>0,re=Q.useMemo(()=>!x||!te.includes(x)?`__default`:x,[x,te]),ie=ne&&(!x||te.includes(x)),ae=Ke(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await ve.listToolIds({directory:W});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));G(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[W]);let oe=Q.useMemo(()=>{let e=new Set;for(let t of c){let n=Fa(Va(t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(ae))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of ee)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[c,ae,ee]),se=Q.useMemo(()=>Ia(j),[j]),ce=Q.useMemo(()=>Ia(N),[N]),le=Q.useCallback(e=>ce.get(Pa(e,`*`))?.action,[ce]),ue=Q.useCallback(e=>N.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),[N]),de=Q.useMemo(()=>{let e=new Set;for(let t of Ma)e.add(t);for(let t of oe)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[oe]),fe=Q.useCallback(e=>{let t=e===`*`?k:le(e)??k,n=ue(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},[ue,le,k]),pe=Q.useCallback(t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),[e]),he=Q.useCallback(t=>t===`global`?e(`settings.common.scope.global`):pe(t),[pe,e]),ge=Q.useMemo(()=>{let e=new Set;for(let t of Ma)e.add(t);for(let t of oe)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[oe]),ye=Q.useCallback((e,t,n)=>{P(r=>{let i=Ia(r);return i.set(Pa(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},[]),be=Q.useCallback((e,t)=>{P(n=>{let r=Ia(n);return r.delete(Pa(e,t)),Array.from(r.values())})},[]),xe=Q.useCallback((e,t)=>{let n=se.get(Pa(e,t));if(n){ye(e,t,n.action);return}be(e,t)},[se,be,ye]),Se=Q.useCallback((e,t,n)=>{ye(e,t,n)},[ye]),Ce=Q.useCallback(e=>{A(e),P(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},[]),we=Q.useCallback(t=>{let n=F.trim();if(!n){K.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=L.trim()||`*`;if(n===`*`&&r===`*`){Ce(t),I(``),R(`*`);return}r===`*`&&n!==`*`&&t===k?be(n,`*`):ye(n,r,t),I(``),R(`*`)},[k,F,L,be,Ce,e,ye]),Te=Q.useCallback(t=>t===`*`?e(`settings.agents.page.permissions.defaultLabel`):t===`webfetch`?`WebFetch`:t===`websearch`?`WebSearch`:t===`codesearch`?`CodeSearch`:t===`doom_loop`?`Doom Loop`:t===`external_directory`?`External Directory`:t===`todowrite`?`TodoWrite`:t===`todoread`?`TodoRead`:t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),[e]);Q.useEffect(()=>{I(``),R(`*`);let e=e=>{let t=Fa(e),n=za(t),r=Ba(t,n);return A(n),M(r),P(r),{global:n,rules:r}};if(u&&o){let t=o.name||``,n=o.scope||`user`,r=o.description||``,i=o.mode||`subagent`,a=o.model||``,s=o.variant||``,c=o.temperature??void 0,l=o.top_p??void 0,u=o.prompt||``;f(t),m(n),g(r),v(i),b(a),S(s),w(c),E(l),O(u);let d=e(Va(o.permission));U.current={draftName:t,draftScope:n,description:r,mode:i,model:a,variant:s,temperature:c,topP:l,prompt:u,globalPermission:d.global,permissionRules:d.rules};return}if(l&&n===l.name){let t=l.description||``,n=l.mode||`subagent`,r=l.model?.providerID&&l.model?.modelID?`${l.model.providerID}/${l.model.modelID}`:``,i=l.variant||``,a=l.temperature,o=l.topP,s=l.prompt||``;g(t),v(n),b(r),S(i),w(a),E(o),O(s);let c=e(Va(l.permission));U.current={draftName:``,draftScope:`user`,description:t,mode:n,model:r,variant:i,temperature:a,topP:o,prompt:s,globalPermission:c.global,permissionRules:c.rules}}},[o,u,l,n]);let Ee=Q.useMemo(()=>{let e=U.current;return e?!!(u&&(d!==e.draftName||p!==e.draftScope)||h!==e.description||_!==e.mode||y!==e.model||x!==e.variant||C!==e.temperature||T!==e.topP||D!==e.prompt||k!==e.globalPermission||!Ra(N,e.permissionRules)):!1},[h,d,p,k,u,_,y,N,D,C,T,x]);return n?(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.identityRole`),children:[u&&(0,$.jsxs)(jr,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(ln,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(tn,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(en,{align:`end`,children:[(0,$.jsx)(sn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(sn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(jr,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(jr,{itemId:`agents.mode`,className:`oc-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.modelParameters`),children:[(0,$.jsx)(jr,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ar,{providerId:Re(y)?.providerId??``,modelId:Re(y)?.modelId??``,onChange:(e,t)=>{b(e&&t?`${e}/${t}`:``),S(``)},className:`oc-settings-inline-value`})}),(0,$.jsx)(jr,{itemId:`agents.variant`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.variant`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.variantTooltip`)})]})]}),description:e(`settings.agents.page.field.variantHint`),children:ie?(0,$.jsxs)(tn,{value:re,onValueChange:e=>S(e===`__default`?``:e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[10rem] max-w-full`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.variantPlaceholder`),children:t=>t===`__default`?e(`chat.modelControls.default`):t})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`__default`,children:e(`chat.modelControls.default`)}),te.map(e=>(0,$.jsx)(sn,{value:e,children:e},e))]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ln,{value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.variantPlaceholder`),disabled:!y&&!x,className:`h-7 w-40 max-w-full`}),x&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>S(``),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.common.actions.clear`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsxs)(jr,{itemId:`agents.temperature`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.temperature`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.temperatureTooltip`)})]})]}),description:e(`settings.agents.page.field.temperatureRange`),children:[(0,$.jsx)(Fr,{value:C,fallbackValue:.7,onValueChange:w,onClear:()=>w(void 0),min:0,max:2,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),C!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>w(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTemperatureAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(jr,{itemId:`agents.top-p`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.topP`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.topPTooltip`)})]})]}),description:e(`settings.agents.page.field.topPRange`),children:[(0,$.jsx)(Fr,{value:T,fallbackValue:.9,onValueChange:E,onClear:()=>E(void 0),min:0,max:1,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),T!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>E(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTopPAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),(0,$.jsx)(Er,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:D,onChange:e=>O(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>B(e=>!e),children:e(z?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:z?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(jr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(tn,{value:k,onValueChange:e=>Ce(e),children:[(0,$.jsx)(cn,{className:`w-[100px]`,children:(0,$.jsx)(Qt,{children:pe(k)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(sn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(sn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:de.filter(e=>e!==`*`).map(t=>{let n=Te(t),{defaultAction:r,patternRulesCount:i}=fe(t),a=le(t),o=a??`global`,s=ue(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==k);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>xe(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(tn,{value:o,onValueChange:e=>{if(e===`global`){be(t,`*`);return}ye(t,`*`,e)},children:[(0,$.jsx)(cn,{className:`w-[90px]`,children:(0,$.jsx)(Qt,{children:he(o)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(sn,{value:e,className:`capitalize`,children:pe(e)},e))]})]})]}),s.map(t=>{let n=Pa(t.permission,t.pattern),r=se.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i?be(t.permission,t.pattern):xe(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(tn,{value:t.action,onValueChange:e=>Se(t.permission,t.pattern,e),children:[(0,$.jsx)(cn,{className:`w-[90px]`,children:(0,$.jsx)(Qt,{children:pe(t.action)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(sn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(sn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2`,children:[(0,$.jsxs)(tn,{value:F,onValueChange:I,children:[(0,$.jsx)(cn,{className:`w-full sm:w-[160px]`,children:F?(0,$.jsx)(`span`,{className:`truncate`,children:Te(F)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(en,{children:ge.map(e=>(0,$.jsx)(sn,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:Te(e)})})},e))})]}),(0,$.jsx)(ln,{value:L,onChange:e=>R(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 flex-1 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsx)($.Fragment,{children:de.map(t=>{let{defaultAction:n,patternRulesCount:r,patternSummary:i,hasDefaultHint:a}=fe(t),o=Te(t),s=a?`${n} (env blocked)`:n;return(0,$.jsx)(jr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block`,children:t})]}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.globalSummary`,{summary:s})}):(0,$.jsx)(`span`,{className:q(`typography-micro capitalize px-1.5 py-0.5 rounded`,s===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:s===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:s}),r>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.rulesSummary`,{summary:i})})]})},t)})})})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let t=u?d.trim().replace(/\s+/g,`-`):n?.trim();if(!t){K.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&c.some(e=>e.name===t)){K.error(e(`settings.agents.sidebar.toast.agentExists`));return}H(!0);try{let n={description:h,mode:_,model:y,variant:x,temperature:C,topP:T,prompt:D,globalPermission:k,permissionRules:N},r=U.current,c=r?{description:r.description,mode:r.mode,model:r.model,variant:r.variant,temperature:r.temperature,topP:r.topP,prompt:r.prompt,globalPermission:r.globalPermission,permissionRules:r.permissionRules}:null,l=ja({isNewAgent:u,agentName:t,draftScope:u?p:void 0,draftHasExplicitPermission:u&&o?.permission!==void 0,current:n,initial:c,permissionConfig:Ha(k,N)}),d;u?(d=await i(l),d.ok&&s(null)):d=await a(t,l),d.ok?d.requiresManualRestart?K.warning(e(`settings.agents.page.toast.savedManualRestart`)):K.success(e(u?`settings.agents.page.toast.created`:`settings.agents.page.toast.updated`)):K.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);K.error(n)}finally{H(!1)}},disabled:V||!Ee,size:`xs`,className:`!font-normal`,children:e(V?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})},Ga=e=>{let t=(0,Si.c)(23),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c}=e,l=i!==void 0&&i,u=s&&s.length>0,d=l?`bg-interactive-selection`:`hover:bg-interactive-hover`,f;t[0]!==c||t[1]!==d?(f=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,d,c),t[0]=c,t[1]=d,t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==o||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,p]}),t[5]=o,t[6]=p,t[7]=m):m=t[7];let h;t[8]===r?h=t[9]:(h=r&&(0,$.jsx)(`div`,{className:`max-w-full truncate typography-micro leading-tight text-muted-foreground/60`,children:r}),t[8]=r,t[9]=h);let g;t[10]!==a||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`button`,{onClick:a,"data-mobile-press-feedback":`soft`,className:`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[m,h]}),t[10]=a,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==s||t[15]!==u?(_=u&&(0,$.jsxs)(Wn,{children:[(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`h-6 w-6 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:s.map(Ka)})]}),t[14]=s,t[15]=u,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==f||t[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),t[20]=f,t[21]=v,t[22]=y):y=t[22],y};function Ka(e){let t=e.icon;return(0,$.jsxs)(Jn,{onClick:t=>{t.stopPropagation(),e.onClick()},className:q(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(J,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var qa=e=>{let t=(0,Si.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=p(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=q(`oc-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},Ja=`__managed_workspace__`,Ya=`__current_workspace__`,Xa=()=>({enabled:!0,name:``,defaultPrompt:``,workspacePath:null,providerID:``,modelID:``,agent:null,mode:`continuous`}),Za=e=>({enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,agent:e.agent,mode:e.mode}),Qa=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,$a=e=>{let t=(0,Si.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(J,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},eo=e=>{let t=(0,Si.c)(82),{onItemSelect:n}=e,{t:r}=De(),i=Rt(),a=At(),o=i.data,s=zt(no),c=zt(ro),l=zt(io),[u,d]=Q.useState(!1),f;t[0]!==n||t[1]!==c||t[2]!==s||t[3]!==o?(f=()=>{!n&&s===null&&o?.assistants[0]&&c(o.assistants[0].id)},t[0]=n,t[1]=c,t[2]=s,t[3]=o,t[4]=f):f=t[4];let p=o?.assistants,m;t[5]!==n||t[6]!==c||t[7]!==s||t[8]!==p?(m=[n,c,s,p],t[5]=n,t[6]=c,t[7]=s,t[8]=p,t[9]=m):m=t[9],Q.useEffect(f,m);let h;t[10]!==n||t[11]!==c||t[12]!==s||t[13]!==o?.assistants||t[14]!==i.isSuccess?(h=()=>{i.isSuccess&&s&&s!==`new`&&!o?.assistants.some(e=>e.id===s)&&c(n?null:o?.assistants[0]?.id??null)},t[10]=n,t[11]=c,t[12]=s,t[13]=o?.assistants,t[14]=i.isSuccess,t[15]=h):h=t[15];let g=o?.assistants,_;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==i.isSuccess||t[20]!==g?(_=[n,c,s,g,i.isSuccess],t[16]=n,t[17]=c,t[18]=s,t[19]=i.isSuccess,t[20]=g,t[21]=_):_=t[21],Q.useEffect(h,_);let v;t[22]!==n||t[23]!==l?(v=()=>{l(),n?.()},t[22]=n,t[23]=l,t[24]=v):v=t[24];let y=Ee(v),b;t[25]!==o||t[26]!==r?(b=async e=>{if(o)try{await Ft(e,o.revision)}catch{we.error(r(`assistants.settings.toast.toggleFailed`))}},t[25]=o,t[26]=r,t[27]=b):b=t[27];let x=Ee(b);if(a.isSuccess&&!a.data.supported)return null;let S;t[28]===r?S=t[29]:(S=r(`assistants.settings.description`),t[28]=r,t[29]=S);let C;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),d(!0)},t[30]=C):C=t[30];let w;t[31]===r?w=t[32]:(w=r(`assistants.settings.descriptionLearnMore`),t[31]=r,t[32]=w);let T;t[33]===w?T=t[34]:(T=(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:C,children:w}),t[33]=w,t[34]=T);let E;t[35]!==T||t[36]!==S?(E=(0,$.jsxs)($.Fragment,{children:[S,T]}),t[35]=T,t[36]=S,t[37]=E):E=t[37];let D=o?.enabled??!1,O;t[38]===r?O=t[39]:(O=r(`assistants.settings.instanceEnabled`),t[38]=r,t[39]=O);let k;t[40]===r?k=t[41]:(k=r(`assistants.settings.instanceEnabled`),t[40]=r,t[41]=k);let A;t[42]!==D||t[43]!==O||t[44]!==k||t[45]!==x?(A=(0,$.jsx)(Lr,{itemId:`assistants.instance-enabled`,checked:D,onChange:x,label:O,ariaLabel:k}),t[42]=D,t[43]=O,t[44]=k,t[45]=x,t[46]=A):A=t[46];let j;t[47]!==E||t[48]!==A?(j=(0,$.jsx)(Z,{description:E,children:A}),t[47]=E,t[48]=A,t[49]=j):j=t[49];let M;t[50]===u?M=t[51]:(M=(0,$.jsx)(Ni,{open:u,onOpenChange:d}),t[50]=u,t[51]=M);let N;t[52]!==j||t[53]!==M?(N=(0,$.jsxs)($.Fragment,{children:[j,M]}),t[52]=j,t[53]=M,t[54]=N):N=t[54];let P;t[55]===r?P=t[56]:(P=r(`assistants.settings.listTitle`),t[55]=r,t[56]=P);let F;t[57]===P?F=t[58]:(F=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:P}),t[57]=P,t[58]=F);let I;t[59]===r?I=t[60]:(I=r(`assistants.settings.create`),t[59]=r,t[60]=I);let L;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(J,{name:`add`,className:`size-4`}),t[61]=L):L=t[61];let R;t[62]!==y||t[63]!==I?(R=(0,$.jsx)(Y,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:y,"aria-label":I,children:L}),t[62]=y,t[63]=I,t[64]=R):R=t[64];let z;t[65]!==F||t[66]!==R?(z=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[F,R]}),t[65]=F,t[66]=R,t[67]=z):z=t[67];let B;t[68]!==a.isPending||t[69]!==n||t[70]!==c||t[71]!==s||t[72]!==o||t[73]!==i.isPending||t[74]!==r?(B=i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):o?.assistants.length?o.assistants.map(e=>{let t=Ae(e.name);return(0,$.jsx)(Ga,{title:t.displayName,selected:s===e.id,onSelect:()=>{c(e.id),n?.()},icon:(0,$.jsx)(Bt,{name:e.id,emoji:t.avatarEmoji,size:24,label:t.displayName||e.name})},e.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row text-muted-foreground`,children:r(`assistants.settings.empty`)}),t[68]=a.isPending,t[69]=n,t[70]=c,t[71]=s,t[72]=o,t[73]=i.isPending,t[74]=r,t[75]=B):B=t[75];let V;t[76]!==z||t[77]!==B?(V=(0,$.jsx)(Z,{label:z,children:B}),t[76]=z,t[77]=B,t[78]=V):V=t[78];let H;return t[79]!==N||t[80]!==V?(H=(0,$.jsx)(qa,{variant:`background`,header:N,children:V}),t[79]=N,t[80]=V,t[81]=H):H=t[81],H},to=({onItemDeleted:e})=>{let{t}=De(),n=Rt(),r=At(),i=n.data,a=Ot(e=>e.projects),o=zt(e=>e.settingsSelectedAssistantID),s=zt(e=>e.selectSettingsAssistant),c=zt(e=>e.defaultShareAssistant),l=zt(e=>e.setDefaultShareAssistant),u=zt(e=>e.createRequestRevision),d=zt(e=>e.requestCreate),[f,p]=Q.useState(Xa),[m,h]=Q.useState(!1),g=Q.useRef(0),_=i?.assistants.find(e=>e.id===o)??null,v=_?Ae(_.name):null,y=Ae(f.name),b=f.workspacePath??_?.managedWorkspacePath??null,x=st(b,{enabled:!0}),S=ct(b,{enabled:!0}),C=x.data??[],w=S.data??[];Q.useEffect(()=>{_&&p(Za(_))},[_]),Q.useEffect(()=>{n.isSuccess&&o&&o!==`new`&&!_&&s(null)},[s,_,o,n.isSuccess]),Q.useEffect(()=>{o!==`new`||u<=g.current||(g.current=u,p(Xa()),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[u,o]),Q.useEffect(()=>{n.isSuccess&&r.data?.serverInstanceID&&c?.serverInstanceID===r.data.serverInstanceID&&!i?.assistants.some(e=>e.id===c.assistantID)&&l(null)},[r.data,c,l,i?.assistants,n.isSuccess]),Q.useEffect(()=>{n.isSuccess&&je()},[i?.revision,n.isSuccess]);let T=(e,t)=>{p(n=>({...n,[e]:t}))},E=Ee(()=>d()),D=Ee(async()=>{if(!f.name.trim()||!f.providerID||!f.modelID){we.error(t(`assistants.settings.validation.required`));return}h(!0);try{let e=_?await Pt(_,f):await It(f);s(e.id),we.success(t(`assistants.settings.toast.saved`))}catch{we.error(t(`assistants.settings.toast.saveFailed`))}finally{h(!1)}}),O=Ee(async()=>{if(!(!_||!window.confirm(t(`assistants.settings.deleteConfirm`,{name:_.name})))){h(!0);try{if(await jt(_),c?.assistantID===_.id){let e=await Mt();e.serverInstanceID&&c.serverInstanceID===e.serverInstanceID&&l(null)}s(null),e?.(),we.success(t(`assistants.settings.toast.deleted`))}catch{we.error(t(`assistants.settings.toast.deleteFailed`))}finally{h(!1)}}}),k=Ee(async(e,n)=>{if(!n){l(null),Me();return}try{let t=await Mt();if(!t.supported||!t.serverInstanceID)return;l({serverInstanceID:t.serverInstanceID,assistantID:e}),await Me()}catch{we.error(t(`assistants.settings.toast.toggleFailed`))}}),A=f.workspacePath===null?null:a.find(e=>e.path===f.workspacePath)??null,j=f.workspacePath!==null&&!A?f.workspacePath:null,M=f.workspacePath===null?Ja:A?A.id:Ya,N=f.workspacePath===null?(0,$.jsx)($a,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):A?(0,$.jsx)($a,{name:Qa(A),path:A.path}):(0,$.jsx)($a,{name:t(`assistants.settings.workspaceCurrentPath`),path:j??``,icon:`history`});return r.isSuccess&&!r.data.supported?null:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):n.isError&&!i?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(J,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:t(`assistants.state.unavailable`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void n.refetch(),children:t(`assistants.actions.retry`)})]}):(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n.isError&&i?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:t(`assistants.state.staleSnapshot`)}):null,o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,$.jsx)(Bt,{name:_?.id??`new`,emoji:y.avatarEmoji,size:38,label:y.displayName||f.name||t(`assistants.settings.create`)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:_?v?.displayName:t(`assistants.settings.create`)}),(0,$.jsx)(`p`,{className:`mt-0.5 typography-micro leading-none text-muted-foreground/70`,children:f.mode===`continuous`?t(`assistants.mode.continuous`):t(`assistants.mode.stateless`)})]}),_?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:O,disabled:m,className:`text-[var(--status-error)]`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`size-4`}),t(`assistants.settings.delete`)]}):null]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(jr,{itemId:`assistants.name`,label:t(`assistants.settings.name`),children:(0,$.jsx)(ln,{id:`assistant-name`,value:f.name,onChange:e=>T(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(jr,{label:t(`assistants.settings.enabled`),children:(0,$.jsx)(Zt,{checked:f.enabled,onChange:e=>T(`enabled`,e),ariaLabel:t(`assistants.settings.enabled`)})}),_?(0,$.jsx)(jr,{itemId:`assistants.default-share`,label:t(`assistants.settings.defaultShare`),children:(0,$.jsx)(Zt,{checked:c?.assistantID===_.id&&c.serverInstanceID===r.data?.serverInstanceID,onChange:e=>void k(_.id,e),ariaLabel:t(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(Er,{itemId:`assistants.prompt`,label:t(`assistants.settings.defaultPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,id:`assistant-prompt`,value:f.defaultPrompt,onChange:e=>T(`defaultPrompt`,e.target.value),placeholder:t(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsxs)(Z,{label:t(`assistants.settings.runtime`),children:[(0,$.jsx)(jr,{itemId:`assistants.model`,label:t(`assistants.settings.model`),children:(0,$.jsx)(ar,{providerId:f.providerID,modelId:f.modelID,providers:C,onChange:(e,t)=>p(n=>({...n,providerID:e,modelID:t})),className:`oc-settings-inline-value`})}),(0,$.jsx)(jr,{itemId:`assistants.agent`,label:t(`assistants.settings.agent`),children:(0,$.jsx)(nr,{agentName:f.agent??``,agents:w,onChange:e=>T(`agent`,e||null),className:`oc-settings-inline-value`})}),(0,$.jsx)(jr,{itemId:`assistants.mode`,label:t(`assistants.settings.mode`),description:f.mode===`stateless`?t(`assistants.conversation.statelessHint`):t(`assistants.conversation.continuousHint`),children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap justify-end gap-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`continuous`,`stateless`].map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":f.mode===e,onClick:()=>T(`mode`,e),children:t(e===`continuous`?`assistants.mode.continuous`:`assistants.mode.stateless`)},e))})})})]}),(0,$.jsx)(Er,{itemId:`assistants.workspace`,label:t(`assistants.settings.workspace`),description:t(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(tn,{value:M,onValueChange:e=>{if(e===Ja){T(`workspacePath`,null);return}let t=a.find(t=>t.id===e);t&&T(`workspacePath`,t.path)},children:[(0,$.jsx)(cn,{title:f.workspacePath??t(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(Qt,{children:N})}),(0,$.jsxs)(en,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(sn,{value:Ja,children:(0,$.jsx)($a,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),a.map(e=>(0,$.jsx)(sn,{value:e.id,children:(0,$.jsx)($a,{name:Qa(e),path:e.path})},e.id)),j?(0,$.jsx)(sn,{value:Ya,disabled:!0,children:(0,$.jsx)($a,{name:t(`assistants.settings.workspaceCurrentPath`),path:j,icon:`history`})}):null]})]})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(Y,{onClick:D,disabled:m,children:[m?(0,$.jsx)(J,{name:`loader-4`,className:`size-4 animate-spin`}):null,t(`assistants.settings.save`)]})})]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)(Bt,{name:`assistants-empty`,size:44}),(0,$.jsx)(`p`,{className:`typography-ui`,children:t(`assistants.settings.empty`)}),(0,$.jsxs)(Y,{"data-settings-item":`assistants.create`,size:`sm`,onClick:E,children:[(0,$.jsx)(J,{name:`add`,className:`size-4`}),t(`assistants.settings.create`)]})]})]})})};function no(e){return e.settingsSelectedAssistantID}function ro(e){return e.selectSettingsAssistant}function io(e){return e.requestCreate}var ao=`~/.config/opencode/AGENTS.md`,oo=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},so=e=>e.length>0&&!e.endsWith(`
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{$ as n,D as r,M as i,a,j as o,o as s,r as c,t as l,u,w as d,y as f}from"./useUIStore-CJsC3a8g.js";import{$t as p,Bt as m,D as h,E as g,Ht as _,Kt as v,O as y,R as b,Ut as x,Vt as S,Xt as C,Yt as w,a as T,bn as E,cn as D,d as O,en as k,et as A,f as j,gn as M,hn as N,i as P,k as F,kn as I,l as L,mn as R,qt as z,r as B,u as V,un as H,xn as U}from"./persistence-DPmGG6sf.js";import{_ as W,a as ee,g as G,h as te,i as ne,l as re,m as ie,n as ae,p as oe,r as se,t as ce,u as le}from"./desktopHosts-DNzqqcVf.js";import{r as ue}from"./desktopRelayRestore-Dl8nD4gy.js";import{a as de,i as fe,r as pe,t as me}from"./vendor-zustand-B4dlGEM2.js";import{nt as he,rt as ge}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as _e,Nt as ve,n as ye,t as be}from"./platform-CbV34Pzu.js";import{n as xe}from"./vendor-react-DLPElpoQ.js";import{s as Se}from"./vendor-tanstack-react-query-D7pys_c9.js";import{W as Ce}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{r as we}from"./vendor-sonner-DVzioF3d.js";import{c as Te,n as Ee}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as De,r as Oe,t as ke}from"./clipboard-Bu8y4WEC.js";import{a as Ae,i as je,r as Me}from"./MobileShareBridge-JKzGwkWc.js";import{$a as Ne,Do as Pe,Eo as Fe,Fa as Ie,Gi as Le,Ia as Re,Ji as ze,Ki as Be,Na as Ve,Oo as He,Pa as Ue,Qa as We,So as Ge,Vt as Ke,Wi as qe,Xa as Je,Xi as Ye,Yi as Xe,Za as Ze,_o as Qe,ai as $e,ao as et,bo as tt,ci as nt,co as rt,do as it,eo as at,fo as ot,go as st,ho as ct,hr as lt,ii as ut,io as dt,ja as ft,ko as pt,lo as mt,mo as ht,no as gt,oo as _t,pi as vt,po as yt,ro as bt,si as xt,so as St,ta as Ct,to as wt,uo as Tt,vo as Et,vr as K,wo as Dt,xo as Ot,yo as kt}from"./useMobileNavigationStore-Dri7j9n_.js";import{_ as At,a as jt,c as Mt,f as Nt,g as Pt,h as Ft,i as It,t as Lt,y as Rt}from"./MobileDetailNavigation-CcDKy9DS.js";import{i as zt}from"./useAssistantUIStore-gi2s2F--.js";import{t as Bt}from"./AgentAvatar-C6E3lxmK.js";import{i as Vt,t as q}from"./utils-DpGCrB3y.js";import{n as J}from"./Icon-CstxOD6I.js";import{a as Ht,i as Ut,n as Wt,o as Gt,r as Kt,t as qt}from"./dialog-CsFlH6Lj.js";import{t as Y}from"./button-CQ8B8MBG.js";import{A as Jt,E as Yt,M as Xt,N as Zt,S as Qt,a as $t,g as en,h as tn,i as nn,j as rn,n as an,o as on,v as sn,x as cn}from"./projectMeta-FvsMPNaZ.js";import{t as ln}from"./input-DVGFeMHA.js";import{i as un,n as dn,t as fn}from"./tooltip-BkJSe4NL.js";import{C as pn,D as mn,E as hn,H as gn,K as _n,M as vn,N as yn,O as bn,R as xn,S as Sn,T as Cn,U as wn,V as Tn,W as En,a as Dn,b as On,c as kn,f as An,i as jn,j as Mn,p as Nn,q as Pn,s as Fn,t as In,u as X,w as Ln,x as Rn,y as zn,z as Bn}from"./useSessionAutoCleanup-BsI23IOM.js";import{n as Vn}from"./useThemeSystem-DMzWVJaW.js";import{A as Hn,D as Un,E as Wn,H as Gn,J as Kn,N as qn,O as Jn,Q as Yn,R as Xn,U as Zn,V as Qn,Y as $n,a as er,f as tr,h as nr,i as rr,j as ir,p as ar,q as or,r as sr,s as cr,t as lr}from"./radio-mlLmTiE9.js";import{i as ur,r as dr,t as fr}from"./OverlayScrollbar-CW5VL9Qc.js";import{n as pr}from"./useRuntimeAPIs-DSLXJybW.js";import{c as mr,i as hr,n as gr}from"./appThemeRegistry-Cq53egpK.js";import{a as _r}from"./url-DNq-9alX.js";import{p as vr}from"./markdown-worker-BJk0TBYO.js";import{t as yr}from"./sortable-tabs-strip-DuAPHzVT.js";import{$ as br,A as xr,B as Sr,C as Cr,D as wr,E as Tr,F as Er,G as Dr,H as Or,I as Z,J as kr,K as Ar,L as jr,M as Mr,N as Nr,O as Pr,P as Fr,Q as Ir,R as Lr,S as Rr,T as zr,U as Br,V as Vr,W as Hr,X as Ur,Y as Wr,Z as Gr,_ as Kr,a as qr,b as Jr,c as Yr,d as Xr,f as Zr,h as Qr,j as $r,k as ei,l as ti,m as ni,n as ri,p as ii,q as ai,s as oi,u as si,v as ci,w as li,y as ui,z as di}from"./MobileSurface-KXW9k5Xo.js";import{a as fi,n as pi,r as mi,t as hi}from"./context-menu-CUf7Yvpz.js";import{n as gi,r as _i,t as vi}from"./collapsible-DhqdBbXo.js";import{n as yi,t as bi}from"./vendor-yaml-DIcAK3EC.js";import{t as xi}from"./vendor-qrcode-DAuVxiQR.js";var Si=xe(),Q=e(ge(),1),$=he(),Ci=`https://github.com/yee94/openchamber`,wi=`https://discord.gg/ZYRSdnwwKA`,Ti=`https://x.com/openchamber_dev`,Ei=800,Di=({initialUpdateDialogOpen:e=!1})=>{let{t}=De(),[n,r]=Q.useState(e),[i,a]=Q.useState(!1),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(null),m=Sr(me(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),{isMobile:h}=ur(),[g,_]=Q.useState(!1),[v,y]=Q.useState(()=>nt()),b=Ee(e=>{vt(e),y(e)}),x=o||t(`settings.openchamber.about.state.unknown`),S=Ee(async()=>{if(!g){_(!0);try{let{outcome:e,eventCount:n}=await xt();if(e===`cancelled`)return;if(e===`failed`){K.error(t(`settings.openchamber.about.diagnostics.toast.failed`));return}K.success(t(n>0?`settings.openchamber.about.diagnostics.toast.exported`:`settings.openchamber.about.diagnostics.toast.empty`))}catch{K.error(t(`settings.openchamber.about.diagnostics.toast.failed`))}finally{_(!1)}}});Q.useEffect(()=>{let e=!1;return Br().then(t=>{e||s(t)}),Or().then(t=>{e||l(t)}),()=>{e=!0}},[]);let C=Vr(o,c)??x;Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await I(`/api/system/info`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.openchamberVersion==`string`&&n.openchamberVersion.trim().length>0?n.openchamberVersion.trim():null;e||d(r)}catch{e||d(null)}})(),()=>{e=!0}},[]),Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await I(`/api/opencode/upgrade-status`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.currentVersion==`string`&&n.currentVersion.trim().length>0?n.currentVersion.trim():null;e||p(r)}catch{e||p(null)}})(),()=>{e=!0}},[]);let w=Q.useRef(!1);Q.useEffect(()=>{if(m.checking)a(!0),w.current=!0;else if(i){let e=setTimeout(()=>{a(!1),w.current&&m.error?(K.error(t(`settings.openchamber.about.toast.checkFailed`),{description:m.error}),w.current=!1):w.current&&!m.available&&!m.error&&(K.success(t(`settings.openchamber.about.toast.latestVersion`)),w.current=!1)},Ei);return()=>clearTimeout(e)}},[t,m.checking,i,m.available,m.error]);let T=m.checking||i;return h?(0,$.jsxs)(`div`,{className:`w-full space-y-6 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Yn,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`OpenChamber`})]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:C})}),(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:u||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:f||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(jr,{children:!T&&m.available?(0,$.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`size-4`}),m.info?.inAppApply?t(`settings.openchamber.about.actions.applyOtaToVersion`,{version:m.info?.version||``}):m.info?.manualUpdate?t(`settings.openchamber.about.actions.installNativeToVersion`,{version:m.info?.version||``}):t(`settings.openchamber.about.actions.updateToVersion`,{version:m.info?.version||``})]}):(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m.checkForUpdates(),disabled:T,children:[T?(0,$.jsx)(J,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(J,{name:`refresh`,className:`size-4`}),t(T?`settings.openchamber.about.state.checking`:`settings.openchamber.about.actions.checkForUpdates`)]})}),m.error&&(0,$.jsx)(jr,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:m.error})}),(0,$.jsx)(Lr,{itemId:`about.diagnostics`,checked:v,onChange:b,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),v&&(0,$.jsx)(jr,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:g,onClick:()=>void S(),children:t(g?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-5`,children:[(0,$.jsxs)(`a`,{href:Ci,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:wi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`discord-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`Discord`})]})]}),(0,$.jsxs)(`a`,{href:Ti,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(di,{open:n,onOpenChange:r,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:t(`settings.openchamber.about.title`),children:[(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:x})}),(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:u||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(jr,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:f||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(jr,{children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-3`,children:[m.checking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:t(`settings.openchamber.about.state.checking`)})]}),!m.checking&&m.available&&(0,$.jsxs)(Y,{size:`sm`,variant:`default`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`h-4 w-4 mr-1`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:m.info?.version||``})]}),!m.checking&&!m.available&&!m.error&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.about.state.upToDate`)}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>m.checkForUpdates(),disabled:m.checking,children:t(`settings.openchamber.about.actions.checkForUpdates`)})]})}),m.error&&(0,$.jsx)(jr,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:m.error})}),(0,$.jsx)(Lr,{itemId:`about.diagnostics`,checked:v,onChange:b,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),v&&(0,$.jsx)(jr,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:g,onClick:()=>void S(),children:t(g?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})}),(0,$.jsxs)(jr,{controlClassName:`flex-wrap`,children:[(0,$.jsxs)(`a`,{href:Ci,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Ti,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]})]}),(0,$.jsx)(di,{open:n,onOpenChange:r,info:m.info,downloading:m.downloading,downloaded:m.downloaded,progress:m.progress,error:m.error,onDownload:m.downloadUpdate,onRestart:m.restartToUpdate,runtimeType:m.runtimeType})]})},Oi=`/assets/android-direct-share-1a0lp154.jpg`,ki=`/assets/ios-share-sheet-B3Dlufnc.jpg`,Ai=`/assets/select-assistant-C89IRspC.jpg`,ji=`openchamber:assistant-share-welcome:v1`,Mi=[{image:ki,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:Oi,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Ai,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],Ni=e=>{let t=(0,Si.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=De(),[s,c]=Te(ji,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=Ee(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(J,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(Gt,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(Kt,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)(Ht,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=Mi.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(Ut,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(Y,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(Wt,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(qt,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Pi=`useCommandsStore`,Fi=new Set([`init`,`review`]),Ii=e=>new Promise(t=>setTimeout(t,e)),Li=e=>Fi.has(e.name),Ri=async(e,t)=>{await Et(V,e,t),r()===t&&Pe(`commands`,{source:Pi})},zi=de()(pe(fe(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=kt(),t=r();try{return await Et(V,e,t),!0}catch{return!1}},createCommand:async t=>Bi(`POST`,t.name,t,e),updateCommand:async(t,n)=>Bi(`PATCH`,t,n,e),deleteCommand:async t=>Bi(`DELETE`,t,void 0,e),getCommandByName:e=>Qe().find(t=>t.name===e)}),{name:`commands-store`,storage:f(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Bi(e,t,n,i){Dt(`${{POST:`Creating`,PATCH:`Updating`,DELETE:`Deleting`}[e]} command configuration…`);let a=kt(),o=r(),s=!1;try{let r={};if(e===`POST`&&(r.template=n?.template||``,n?.description&&(r.description=n.description),n?.agent&&(r.agent=n.agent),n?.model&&(r.model=n.model),n?.scope&&(r.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(r[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,l=await I(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(r)}}),u=await l.json().catch(()=>null);if(!l.ok)throw Error(u?.error||`Failed to ${e.toLowerCase()} command`);return s=u?.requiresReload??!0,s?await Vi(a,o,{message:u?.message,delayMs:u?.reloadDelayMs}):await Ri(a,o),e===`DELETE`&&i({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}finally{Ge()}}async function Vi(e,t,n){n.delayMs&&await Ii(n.delayMs),Fe(n.message||`Refreshing commands…`),await Ri(e,t)}typeof window<`u`&&(window.__zustand_commands_store__=zi),pt(e=>{e.source!==Pi&&He(e,`commands`)&&zi.getState().loadCommands()});var Hi=()=>{try{let e=Ot.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=ve.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},Ui=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],Wi=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Gi=e=>{if(typeof e==`string`)return e.trim()||void 0},Ki=800,qi=de()(pe(fe((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=Hi();try{return!e?.force&&Dr(V,t).length>0||await ai(V,t,r()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{Dt(`Creating MCP server configuration…`);let n=!1,i=`directory`in(t??{})?t?.directory?.trim()||null:Hi(),a=t?.transportIdentity??r();try{let t=Ji(e),r=i?`?directory=${encodeURIComponent(i)}`:``,o=await I(`/api/config/mcp/${encodeURIComponent(e.name)}${r}`,{method:`POST`,headers:{"Content-Type":`application/json`,...i?{"x-opencode-directory":i}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return s?.requiresReload?(n=!0,await We({message:s.message,delayMs:s.reloadDelayMs??Ki,scopes:[`mcp`],queryDirectory:i,transportIdentity:a}),await ai(V,i,a),await kr(V,i,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):(await ai(V,i,a),await kr(V,i,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning})}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}finally{n||Ge()}},updateMcp:async(e,t,n)=>{Dt(`Updating MCP server configuration…`);let i=!1,a=`directory`in(n??{})?n?.directory?.trim()||null:Hi(),o=n?.transportIdentity??r();try{let n=Ji(t),r=a?`?directory=${encodeURIComponent(a)}`:``,s=await I(`/api/config/mcp/${encodeURIComponent(e)}${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return c?.requiresReload?(i=!0,await We({message:c.message,delayMs:c.reloadDelayMs??Ki,scopes:[`mcp`],queryDirectory:a,transportIdentity:o}),await ai(V,a,o),await kr(V,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):(await ai(V,a,o),await kr(V,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning})}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}finally{i||Ge()}},deleteMcp:async(n,i)=>{Dt(`Deleting MCP server configuration…`);let a=!1,o=`directory`in(i??{})?i?.directory?.trim()||null:Hi(),s=i?.transportIdentity??r();try{let r=o?`?directory=${encodeURIComponent(o)}`:``,i=await I(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),c=await i.json().catch(()=>null);if(!i.ok)throw Error(c?.error||`Failed to delete MCP server`);return c?.requiresReload&&(a=!0,await We({message:c.message,delayMs:c.reloadDelayMs??Ki,scopes:[`mcp`],queryDirectory:o,transportIdentity:s})),t().selectedMcpName===n&&e({selectedMcpName:null}),Hr.getState().clearDiagnostic(n,o,s),await ai(V,o,s),await kr(V,o,s),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}finally{a||Ge()}}}),{name:`mcp-config-store`,storage:f(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Ji(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=Wi(e.environment)??{}),e.headers!==void 0&&(t.headers=Wi(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Gi(e.oauthClientId),clientSecret:Gi(e.oauthClientSecret),scope:Gi(e.oauthScope),redirectUri:Gi(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var Yi=()=>{let e=ve.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},Xi=`useSkillsStore`,Zi=e=>new Promise(t=>setTimeout(t,e)),Qi=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=Yi();return typeof t==`string`&&t.trim()||null},$i=2e4,ea=300,ta=4,na=800,ra=200,ia=2e3,aa=de()(pe(fe((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await gt(V,Yi(),r()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=Yi(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await I(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{Dt(`Creating skill...`);let n=!1;try{let i={name:e.name,description:e.description};e.instructions&&(i.instructions=e.instructions),e.scope&&(i.scope=e.scope),e.source&&(i.source=e.source),e.supportingFiles&&(i.supportingFiles=e.supportingFiles);let a=Qi(t),o=r(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await I(`/api/config/skills/${encodeURIComponent(e.name)}${s}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to create skill`;throw Error(e)}return l?.requiresReload??!1?(n=!0,await sa({message:l?.message,delayMs:l?.reloadDelayMs,directory:a,transportIdentity:o}),!0):(await gt(V,a,o),await St(V,a,o),Pe(`skills`,{source:Xi}),!0)}catch{return!1}finally{n||Ge()}},updateSkill:async(e,t,n)=>{Dt(`Updating skill...`);let i=!1;try{let a={};t.description!==void 0&&(a.description=t.description),t.instructions!==void 0&&(a.instructions=t.instructions),t.supportingFiles!==void 0&&(a.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(a.targetPath=t.targetPath);let o=Qi(n),s=r(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await I(`/api/config/skills/${encodeURIComponent(e)}${c}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return u?.requiresReload??!1?(i=!0,await sa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await gt(V,o,s),await St(V,o,s),Pe(`skills`,{source:Xi}),!0)}catch{return!1}finally{i||Ge()}},deleteSkill:async(n,i)=>{Dt(`Deleting skill...`);let a=!1;try{let o=Qi(i),s=r(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await I(`/api/config/skills/${encodeURIComponent(n)}${c}`,{method:`DELETE`}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return u?.requiresReload??!1?(a=!0,await sa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await gt(V,o,s),await St(V,o,s),Pe(`skills`,{source:Xi}),t().selectedSkillName===n&&e({selectedSkillName:null}),!0)}catch{return!1}finally{a||Ge()}},getSkillByName:e=>wt(V,Yi()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=Yi(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=Yi(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=Yi(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:f(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=aa);async function oa(e){let t=typeof e==`number`&&e>0?Math.min(e,ea):0;t>0&&await Zi(t);let n=Date.now(),r=0,i=null;for(;Date.now()-n<$i;){r+=1,Fe(`Waiting for OpenCode… (attempt ${r})`);try{if(await ve.checkHealth())return;i=Error(`OpenCode health check reported not ready`)}catch(e){i=e}let e=Date.now()-n;await Zi(r<=ta&&e<1200?ea:Math.min(na+Math.max(0,r-ta)*ra,ia))}throw i||Error(`OpenCode did not become ready in time`)}async function sa(e){let t=e&&`directory`in e?e.directory?.trim()||null:Yi(),n=e?.transportIdentity??r();try{Fe(e?.message||`Refreshing skills…`)}catch{}try{if(await oa(e?.delayMs),r()!==n||(Fe(`Refreshing skills…`),await gt(V,t,n),r()!==n))return;await St(V,t,n),Pe(`skills`,{source:Xi})}catch(e){throw Fe(`OpenCode refresh failed. Please retry.`),await Zi(1500),e}finally{Ge()}}var ca=null;ca||=pt(e=>{if(e.source!==Xi&&He(e,`skills`)){let e=Yi(),t=r();gt(V,e,t).then(()=>St(V,e,t)).catch(()=>void 0)}});var la=e=>{let t=(0,Si.c)(37),{className:n}=e,{t:r}=De(),i=Ot(ua),a=Ot(da),o=Ot(fa),s=p(),c;t[0]===i?c=t[1]:(c=[...i].sort(pa),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let m=f,h;t[8]===n?h=t[9]:(h=q(n),t[8]=n,t[9]=h);let g;t[10]===r?g=t[11]:(g=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=g);let _;t[12]===r?_=t[13]:(_=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=_);let v,y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=q(`text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none`,`hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70`,`flex items-center gap-1.5 text-left`),y=(0,$.jsx)(J,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=v,t[15]=y):(v=t[14],y=t[15]);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(J,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=x):x=t[18];let S;t[19]!==g||t[20]!==_||t[21]!==b?(S=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":g,title:_,className:v,children:[y,b,x]})}),t[19]=g,t[20]=_,t[21]=b,t[22]=S):S=t[22];let C=d?.id??``,w;t[23]===o?w=t[24]:(w=e=>{e&&o(e)},t[23]=o,t[24]=w);let T;t[25]===l?T=t[26]:(T=l.map(ma),t[25]=l,t[26]=T);let E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,$.jsx)(Un,{align:`start`,className:`w-auto`,children:(0,$.jsx)(Hn,{value:C,onValueChange:w,children:T})}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==S||t[32]!==E?(D=(0,$.jsxs)(Wn,{children:[S,E]}),t[31]=S,t[32]=E,t[33]=D):D=t[33];let O;return t[34]!==D||t[35]!==h?(O=(0,$.jsx)(`div`,{className:h,children:D}),t[34]=D,t[35]=h,t[36]=O):O=t[36],O};function ua(e){return e.projects}function da(e){return e.activeProjectId}function fa(e){return e.setActiveProject}function pa(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function ma(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(ir,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function ha(e,t){return`opencode:sidebar-group:${e}:${t}`}var ga=e=>{let t=(0,Si.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=ha(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(_a),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(J,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=q(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(Z,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(va),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`flex w-full items-center gap-1 rounded-md px-2 py-1 text-left`,`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,`hover:bg-[var(--interactive-hover)] transition-colors duration-150`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(J,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function _a(e){return!e}function va(e){return!e}var ya=e=>{if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.permission==`string`&&typeof e.pattern==`string`&&typeof e.action==`string`&&(e.action===`allow`||e.action===`ask`||e.action===`deny`)&&t.push({permission:e.permission,pattern:e.pattern,action:e.action})}return t},ba=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&t.set(`${n.permission}::${n.pattern}`,n);return Array.from(t.values())},xa=e=>{let t=ba(ya(e));if(t.length===0)return;let n={};for(let e of t)e.permission&&((n[e.permission]||={})[e.pattern]=e.action);let r={};for(let[e,t]of Object.entries(n)){let n=Object.keys(t);if(n.length===1&&n[0]===`*`){r[e]=t[`*`];continue}r[e]=t}return Object.keys(r).length>0?r:void 0},Sa=({onItemSelect:e})=>{let{t}=De(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=at(me(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=ht();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(Je(e)){K.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{Je(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?K.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):K.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?K.error(t(`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?K.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;let i=e,a=e.model?.providerID&&e.model?.modelID?`${e.model.providerID}/${e.model.modelID}`:null,o=e;g({name:r,scope:i.scope||`user`,description:e.description,model:a,variant:e.variant,temperature:e.temperature,top_p:e.topP,prompt:e.prompt,mode:e.mode,permission:xa(e.permission),disable:o.disable}),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){K.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){K.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,o=n,s=await _({name:e,description:n.description,model:a,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:xa(n.permission),disable:o.disable,scope:o.scope});if(s.ok){let r=await v(n.name,o.scope);r.ok?(s.requiresManualRestart||r.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):K.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):K.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else K.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(J,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(J,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(J,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>!Ze(e)),j=A.filter(Je),M=A.filter(e=>!Je(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(Y,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(la,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(Z,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(Ca,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(ga,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(Ca,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(Z,{label:F,children:P.map(t=>(0,$.jsx)(Ca,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(qt,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(Wt,{className:`max-w-md`,children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(Kt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(qt,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(Wt,{children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(Kt,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(ln,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},Ca=e=>{let t=(0,Si.c)(52),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=De(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=dr(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[12]=n.name,t[13]=w);let T;t[14]!==n.mode||t[15]!==l?(T=l(n.mode),t[14]=n.mode,t[15]=l,t[16]=T):T=t[16];let E;t[17]!==n||t[18]!==p.scope||t[19]!==f?(E=(p.scope||Je(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Je(n)?f(`settings.agents.sidebar.badge.system`):p.scope}),t[17]=n,t[18]=p.scope,t[19]=f,t[20]=E):E=t[20];let D;t[21]!==w||t[22]!==T||t[23]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[w,T,E]}),t[21]=w,t[22]=T,t[23]=E,t[24]=D):D=t[24];let O;t[25]===n.description?O=t[26]:(O=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[25]=n.description,t[26]=O);let k;t[27]!==i||t[28]!==D||t[29]!==O?(k=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[D,O]}),t[27]=i,t[28]=D,t[29]=O,t[30]=k):k=t[30];let A;t[31]===d?A=t[32]:(A=e=>{e&&_(!1),d(e)},t[31]=d,t[32]=A);let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[33]=j):j=t[33];let M;t[34]===y?M=t[35]:(M=(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:y(Jn)}),t[34]=y,t[35]=M);let N;t[36]!==u||t[37]!==A||t[38]!==M?(N=(0,$.jsxs)(Wn,{open:u,onOpenChange:A,children:[j,M]}),t[36]=u,t[37]=A,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==k||t[41]!==N?(P=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[k,N]}),t[40]=k,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==P||t[44]!==C?(F=(0,$.jsx)(fi,{render:C,children:P}),t[43]=P,t[44]=C,t[45]=F):F=t[45];let I;t[46]===y?I=t[47]:(I=(0,$.jsx)(pi,{className:`w-fit min-w-20`,children:y(mi)}),t[46]=y,t[47]=I);let L;return t[48]!==g||t[49]!==F||t[50]!==I?(L=(0,$.jsxs)(hi,{open:g,onOpenChange:_,children:[F,I]}),t[48]=g,t[49]=F,t[50]=I,t[51]=L):L=t[51],L},wa=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ta=(e,t)=>{let n=wa(e),r=wa(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},Ea=(e,t)=>t?e.globalPermission!==t.globalPermission||!Ta(e.permissionRules,t.permissionRules):!1,Da=e=>{let t=e.trim();return t===``?null:t},Oa=e=>{let t=e.trim();return t===``?null:t},ka=e=>e.trim()||void 0,Aa=e=>e.trim()||null,ja=({isNewAgent:e,agentName:t,draftScope:n,draftHasExplicitPermission:r,current:i,initial:a,permissionConfig:o})=>{if(e){let e=Ea(i,a)||r,s=i.description.trim(),c=Da(i.model),l=Oa(i.variant),u=ka(i.prompt);return{name:t,mode:i.mode,...s?{description:s}:{},...c?{model:c}:{},...l?{variant:l}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...i.topP===void 0?{}:{top_p:i.topP},...u?{prompt:u}:{},...e?{permission:o}:{},...n?{scope:n}:{}}}let s={name:t};if(!a)return s;if(i.description!==a.description){let e=i.description.trim();e&&(s.description=e)}return i.mode!==a.mode&&(s.mode=i.mode),i.model!==a.model&&(s.model=Da(i.model)),i.variant!==a.variant&&(s.variant=Oa(i.variant)??null),i.temperature!==a.temperature&&(s.temperature=i.temperature??null),i.topP!==a.topP&&(s.top_p=i.topP??null),i.prompt!==a.prompt&&(s.prompt=Aa(i.prompt)),Ea(i,a)&&(s.permission=o),s},Ma=[`*`,`read`,`edit`,`glob`,`grep`,`list`,`bash`,`task`,`skill`,`lsp`,`todoread`,`todowrite`,`webfetch`,`websearch`,`codesearch`,`external_directory`,`doom_loop`,`question`,`plan_enter`,`plan_exit`],Na=e=>e===`allow`||e===`ask`||e===`deny`,Pa=(e,t)=>`${e}::${t}`,Fa=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&Na(n.action)&&t.set(Pa(n.permission,n.pattern),{permission:n.permission,pattern:n.pattern,action:n.action});return Array.from(t.values())},Ia=e=>{let t=new Map;for(let n of Fa(e))t.set(Pa(n.permission,n.pattern),n);return t},La=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ra=(e,t)=>{let n=La(Fa(e)),r=La(Fa(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},za=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,Ba=(e,t)=>Fa(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),Va=e=>{if(Array.isArray(e))return Fa(e);if(Na(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(Na(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))Na(i)&&t.push({permission:n,pattern:e,action:i})}return t},Ha=(e,t)=>{let n=Fa(t),r={};for(let e of n)(r[e.permission]||={})[e.pattern]=e.action;let i={};for(let[e,t]of Object.entries(r))if(e!==`*`){if(Object.keys(t).length===1&&t[`*`]){i[e]=t[`*`];continue}i[e]=t}return Object.keys(i).length===0?e:(e!==`allow`&&(i[`*`]=e),i)},Ua=(e,t)=>{let n=Re(t);if(!n)return[];let r=e.find(e=>e.id===n.providerId)?.models?.find(e=>e.id===n.modelId);return r?.variants?Object.keys(r.variants):[]},Wa=()=>{let{t:e}=De(),t=Ct(e=>e.providers),{selectedAgentName:n,getAgentByName:r,createAgent:i,updateAgent:a,agentDraft:o,setAgentDraft:s}=at(me(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:c=[]}=ht(),l=n?r(n):null,u=!!(o&&o.name===n&&!l),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(void 0),[T,E]=Q.useState(void 0),[D,O]=Q.useState(``),[k,A]=Q.useState(`allow`),[j,M]=Q.useState([]),[N,P]=Q.useState([]),[F,I]=Q.useState(``),[L,R]=Q.useState(`*`),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),U=Q.useRef(null),W=_e(e=>e.currentDirectory??null),[ee,G]=Q.useState([]),te=Q.useMemo(()=>Ua(t,y),[y,t]),ne=te.length>0,re=Q.useMemo(()=>!x||!te.includes(x)?`__default`:x,[x,te]),ie=ne&&(!x||te.includes(x)),ae=Ke(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await ve.listToolIds({directory:W});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));G(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[W]);let oe=Q.useMemo(()=>{let e=new Set;for(let t of c){let n=Fa(Va(t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(ae))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of ee)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[c,ae,ee]),se=Q.useMemo(()=>Ia(j),[j]),ce=Q.useMemo(()=>Ia(N),[N]),le=Q.useCallback(e=>ce.get(Pa(e,`*`))?.action,[ce]),ue=Q.useCallback(e=>N.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),[N]),de=Q.useMemo(()=>{let e=new Set;for(let t of Ma)e.add(t);for(let t of oe)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[oe]),fe=Q.useCallback(e=>{let t=e===`*`?k:le(e)??k,n=ue(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},[ue,le,k]),pe=Q.useCallback(t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),[e]),he=Q.useCallback(t=>t===`global`?e(`settings.common.scope.global`):pe(t),[pe,e]),ge=Q.useMemo(()=>{let e=new Set;for(let t of Ma)e.add(t);for(let t of oe)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[oe]),ye=Q.useCallback((e,t,n)=>{P(r=>{let i=Ia(r);return i.set(Pa(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},[]),be=Q.useCallback((e,t)=>{P(n=>{let r=Ia(n);return r.delete(Pa(e,t)),Array.from(r.values())})},[]),xe=Q.useCallback((e,t)=>{let n=se.get(Pa(e,t));if(n){ye(e,t,n.action);return}be(e,t)},[se,be,ye]),Se=Q.useCallback((e,t,n)=>{ye(e,t,n)},[ye]),Ce=Q.useCallback(e=>{A(e),P(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},[]),we=Q.useCallback(t=>{let n=F.trim();if(!n){K.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=L.trim()||`*`;if(n===`*`&&r===`*`){Ce(t),I(``),R(`*`);return}r===`*`&&n!==`*`&&t===k?be(n,`*`):ye(n,r,t),I(``),R(`*`)},[k,F,L,be,Ce,e,ye]),Te=Q.useCallback(t=>t===`*`?e(`settings.agents.page.permissions.defaultLabel`):t===`webfetch`?`WebFetch`:t===`websearch`?`WebSearch`:t===`codesearch`?`CodeSearch`:t===`doom_loop`?`Doom Loop`:t===`external_directory`?`External Directory`:t===`todowrite`?`TodoWrite`:t===`todoread`?`TodoRead`:t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),[e]);Q.useEffect(()=>{I(``),R(`*`);let e=e=>{let t=Fa(e),n=za(t),r=Ba(t,n);return A(n),M(r),P(r),{global:n,rules:r}};if(u&&o){let t=o.name||``,n=o.scope||`user`,r=o.description||``,i=o.mode||`subagent`,a=o.model||``,s=o.variant||``,c=o.temperature??void 0,l=o.top_p??void 0,u=o.prompt||``;f(t),m(n),g(r),v(i),b(a),S(s),w(c),E(l),O(u);let d=e(Va(o.permission));U.current={draftName:t,draftScope:n,description:r,mode:i,model:a,variant:s,temperature:c,topP:l,prompt:u,globalPermission:d.global,permissionRules:d.rules};return}if(l&&n===l.name){let t=l.description||``,n=l.mode||`subagent`,r=l.model?.providerID&&l.model?.modelID?`${l.model.providerID}/${l.model.modelID}`:``,i=l.variant||``,a=l.temperature,o=l.topP,s=l.prompt||``;g(t),v(n),b(r),S(i),w(a),E(o),O(s);let c=e(Va(l.permission));U.current={draftName:``,draftScope:`user`,description:t,mode:n,model:r,variant:i,temperature:a,topP:o,prompt:s,globalPermission:c.global,permissionRules:c.rules}}},[o,u,l,n]);let Ee=Q.useMemo(()=>{let e=U.current;return e?!!(u&&(d!==e.draftName||p!==e.draftScope)||h!==e.description||_!==e.mode||y!==e.model||x!==e.variant||C!==e.temperature||T!==e.topP||D!==e.prompt||k!==e.globalPermission||!Ra(N,e.permissionRules)):!1},[h,d,p,k,u,_,y,N,D,C,T,x]);return n?(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.identityRole`),children:[u&&(0,$.jsxs)(jr,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(ln,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(tn,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(en,{align:`end`,children:[(0,$.jsx)(sn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(sn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(jr,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(jr,{itemId:`agents.mode`,className:`oc-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.modelParameters`),children:[(0,$.jsx)(jr,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ar,{providerId:Re(y)?.providerId??``,modelId:Re(y)?.modelId??``,onChange:(e,t)=>{b(e&&t?`${e}/${t}`:``),S(``)},className:`oc-settings-inline-value`})}),(0,$.jsx)(jr,{itemId:`agents.variant`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.variant`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.variantTooltip`)})]})]}),description:e(`settings.agents.page.field.variantHint`),children:ie?(0,$.jsxs)(tn,{value:re,onValueChange:e=>S(e===`__default`?``:e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[10rem] max-w-full`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.variantPlaceholder`),children:t=>t===`__default`?e(`chat.modelControls.default`):t})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`__default`,children:e(`chat.modelControls.default`)}),te.map(e=>(0,$.jsx)(sn,{value:e,children:e},e))]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ln,{value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.variantPlaceholder`),disabled:!y&&!x,className:`h-7 w-40 max-w-full`}),x&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>S(``),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.common.actions.clear`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsxs)(jr,{itemId:`agents.temperature`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.temperature`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.temperatureTooltip`)})]})]}),description:e(`settings.agents.page.field.temperatureRange`),children:[(0,$.jsx)(Fr,{value:C,fallbackValue:.7,onValueChange:w,onClear:()=>w(void 0),min:0,max:2,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),C!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>w(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTemperatureAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(jr,{itemId:`agents.top-p`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.topP`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.topPTooltip`)})]})]}),description:e(`settings.agents.page.field.topPRange`),children:[(0,$.jsx)(Fr,{value:T,fallbackValue:.9,onValueChange:E,onClear:()=>E(void 0),min:0,max:1,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),T!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>E(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTopPAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),(0,$.jsx)(Er,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:D,onChange:e=>O(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>B(e=>!e),children:e(z?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:z?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(jr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(tn,{value:k,onValueChange:e=>Ce(e),children:[(0,$.jsx)(cn,{className:`w-[100px]`,children:(0,$.jsx)(Qt,{children:pe(k)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(sn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(sn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:de.filter(e=>e!==`*`).map(t=>{let n=Te(t),{defaultAction:r,patternRulesCount:i}=fe(t),a=le(t),o=a??`global`,s=ue(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==k);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>xe(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(tn,{value:o,onValueChange:e=>{if(e===`global`){be(t,`*`);return}ye(t,`*`,e)},children:[(0,$.jsx)(cn,{className:`w-[90px]`,children:(0,$.jsx)(Qt,{children:he(o)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(sn,{value:e,className:`capitalize`,children:pe(e)},e))]})]})]}),s.map(t=>{let n=Pa(t.permission,t.pattern),r=se.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i?be(t.permission,t.pattern):xe(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(tn,{value:t.action,onValueChange:e=>Se(t.permission,t.pattern,e),children:[(0,$.jsx)(cn,{className:`w-[90px]`,children:(0,$.jsx)(Qt,{children:pe(t.action)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(sn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(sn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2`,children:[(0,$.jsxs)(tn,{value:F,onValueChange:I,children:[(0,$.jsx)(cn,{className:`w-full sm:w-[160px]`,children:F?(0,$.jsx)(`span`,{className:`truncate`,children:Te(F)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(en,{children:ge.map(e=>(0,$.jsx)(sn,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:Te(e)})})},e))})]}),(0,$.jsx)(ln,{value:L,onChange:e=>R(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 flex-1 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsx)($.Fragment,{children:de.map(t=>{let{defaultAction:n,patternRulesCount:r,patternSummary:i,hasDefaultHint:a}=fe(t),o=Te(t),s=a?`${n} (env blocked)`:n;return(0,$.jsx)(jr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block`,children:t})]}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.globalSummary`,{summary:s})}):(0,$.jsx)(`span`,{className:q(`typography-micro capitalize px-1.5 py-0.5 rounded`,s===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:s===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:s}),r>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.rulesSummary`,{summary:i})})]})},t)})})})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let t=u?d.trim().replace(/\s+/g,`-`):n?.trim();if(!t){K.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&c.some(e=>e.name===t)){K.error(e(`settings.agents.sidebar.toast.agentExists`));return}H(!0);try{let n={description:h,mode:_,model:y,variant:x,temperature:C,topP:T,prompt:D,globalPermission:k,permissionRules:N},r=U.current,c=r?{description:r.description,mode:r.mode,model:r.model,variant:r.variant,temperature:r.temperature,topP:r.topP,prompt:r.prompt,globalPermission:r.globalPermission,permissionRules:r.permissionRules}:null,l=ja({isNewAgent:u,agentName:t,draftScope:u?p:void 0,draftHasExplicitPermission:u&&o?.permission!==void 0,current:n,initial:c,permissionConfig:Ha(k,N)}),d;u?(d=await i(l),d.ok&&s(null)):d=await a(t,l),d.ok?d.requiresManualRestart?K.warning(e(`settings.agents.page.toast.savedManualRestart`)):K.success(e(u?`settings.agents.page.toast.created`:`settings.agents.page.toast.updated`)):K.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);K.error(n)}finally{H(!1)}},disabled:V||!Ee,size:`xs`,className:`!font-normal`,children:e(V?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})},Ga=e=>{let t=(0,Si.c)(23),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c}=e,l=i!==void 0&&i,u=s&&s.length>0,d=l?`bg-interactive-selection`:`hover:bg-interactive-hover`,f;t[0]!==c||t[1]!==d?(f=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,d,c),t[0]=c,t[1]=d,t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==o||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,p]}),t[5]=o,t[6]=p,t[7]=m):m=t[7];let h;t[8]===r?h=t[9]:(h=r&&(0,$.jsx)(`div`,{className:`max-w-full truncate typography-micro leading-tight text-muted-foreground/60`,children:r}),t[8]=r,t[9]=h);let g;t[10]!==a||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`button`,{onClick:a,"data-mobile-press-feedback":`soft`,className:`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[m,h]}),t[10]=a,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==s||t[15]!==u?(_=u&&(0,$.jsxs)(Wn,{children:[(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`h-6 w-6 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:s.map(Ka)})]}),t[14]=s,t[15]=u,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==f||t[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),t[20]=f,t[21]=v,t[22]=y):y=t[22],y};function Ka(e){let t=e.icon;return(0,$.jsxs)(Jn,{onClick:t=>{t.stopPropagation(),e.onClick()},className:q(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(J,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var qa=e=>{let t=(0,Si.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=p(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=q(`oc-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},Ja=`__managed_workspace__`,Ya=`__current_workspace__`,Xa=()=>({enabled:!0,name:``,defaultPrompt:``,workspacePath:null,providerID:``,modelID:``,agent:null,mode:`continuous`}),Za=e=>({enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,agent:e.agent,mode:e.mode}),Qa=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,$a=e=>{let t=(0,Si.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(J,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},eo=e=>{let t=(0,Si.c)(82),{onItemSelect:n}=e,{t:r}=De(),i=Rt(),a=At(),o=i.data,s=zt(no),c=zt(ro),l=zt(io),[u,d]=Q.useState(!1),f;t[0]!==n||t[1]!==c||t[2]!==s||t[3]!==o?(f=()=>{!n&&s===null&&o?.assistants[0]&&c(o.assistants[0].id)},t[0]=n,t[1]=c,t[2]=s,t[3]=o,t[4]=f):f=t[4];let p=o?.assistants,m;t[5]!==n||t[6]!==c||t[7]!==s||t[8]!==p?(m=[n,c,s,p],t[5]=n,t[6]=c,t[7]=s,t[8]=p,t[9]=m):m=t[9],Q.useEffect(f,m);let h;t[10]!==n||t[11]!==c||t[12]!==s||t[13]!==o?.assistants||t[14]!==i.isSuccess?(h=()=>{i.isSuccess&&s&&s!==`new`&&!o?.assistants.some(e=>e.id===s)&&c(n?null:o?.assistants[0]?.id??null)},t[10]=n,t[11]=c,t[12]=s,t[13]=o?.assistants,t[14]=i.isSuccess,t[15]=h):h=t[15];let g=o?.assistants,_;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==i.isSuccess||t[20]!==g?(_=[n,c,s,g,i.isSuccess],t[16]=n,t[17]=c,t[18]=s,t[19]=i.isSuccess,t[20]=g,t[21]=_):_=t[21],Q.useEffect(h,_);let v;t[22]!==n||t[23]!==l?(v=()=>{l(),n?.()},t[22]=n,t[23]=l,t[24]=v):v=t[24];let y=Ee(v),b;t[25]!==o||t[26]!==r?(b=async e=>{if(o)try{await Ft(e,o.revision)}catch{we.error(r(`assistants.settings.toast.toggleFailed`))}},t[25]=o,t[26]=r,t[27]=b):b=t[27];let x=Ee(b);if(a.isSuccess&&!a.data.supported)return null;let S;t[28]===r?S=t[29]:(S=r(`assistants.settings.description`),t[28]=r,t[29]=S);let C;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),d(!0)},t[30]=C):C=t[30];let w;t[31]===r?w=t[32]:(w=r(`assistants.settings.descriptionLearnMore`),t[31]=r,t[32]=w);let T;t[33]===w?T=t[34]:(T=(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:C,children:w}),t[33]=w,t[34]=T);let E;t[35]!==T||t[36]!==S?(E=(0,$.jsxs)($.Fragment,{children:[S,T]}),t[35]=T,t[36]=S,t[37]=E):E=t[37];let D=o?.enabled??!1,O;t[38]===r?O=t[39]:(O=r(`assistants.settings.instanceEnabled`),t[38]=r,t[39]=O);let k;t[40]===r?k=t[41]:(k=r(`assistants.settings.instanceEnabled`),t[40]=r,t[41]=k);let A;t[42]!==D||t[43]!==O||t[44]!==k||t[45]!==x?(A=(0,$.jsx)(Lr,{itemId:`assistants.instance-enabled`,checked:D,onChange:x,label:O,ariaLabel:k}),t[42]=D,t[43]=O,t[44]=k,t[45]=x,t[46]=A):A=t[46];let j;t[47]!==E||t[48]!==A?(j=(0,$.jsx)(Z,{description:E,children:A}),t[47]=E,t[48]=A,t[49]=j):j=t[49];let M;t[50]===u?M=t[51]:(M=(0,$.jsx)(Ni,{open:u,onOpenChange:d}),t[50]=u,t[51]=M);let N;t[52]!==j||t[53]!==M?(N=(0,$.jsxs)($.Fragment,{children:[j,M]}),t[52]=j,t[53]=M,t[54]=N):N=t[54];let P;t[55]===r?P=t[56]:(P=r(`assistants.settings.listTitle`),t[55]=r,t[56]=P);let F;t[57]===P?F=t[58]:(F=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:P}),t[57]=P,t[58]=F);let I;t[59]===r?I=t[60]:(I=r(`assistants.settings.create`),t[59]=r,t[60]=I);let L;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(J,{name:`add`,className:`size-4`}),t[61]=L):L=t[61];let R;t[62]!==y||t[63]!==I?(R=(0,$.jsx)(Y,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:y,"aria-label":I,children:L}),t[62]=y,t[63]=I,t[64]=R):R=t[64];let z;t[65]!==F||t[66]!==R?(z=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[F,R]}),t[65]=F,t[66]=R,t[67]=z):z=t[67];let B;t[68]!==a.isPending||t[69]!==n||t[70]!==c||t[71]!==s||t[72]!==o||t[73]!==i.isPending||t[74]!==r?(B=i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):o?.assistants.length?o.assistants.map(e=>{let t=Ae(e.name);return(0,$.jsx)(Ga,{title:t.displayName,selected:s===e.id,onSelect:()=>{c(e.id),n?.()},icon:(0,$.jsx)(Bt,{name:e.id,emoji:t.avatarEmoji,size:24,label:t.displayName||e.name})},e.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row text-muted-foreground`,children:r(`assistants.settings.empty`)}),t[68]=a.isPending,t[69]=n,t[70]=c,t[71]=s,t[72]=o,t[73]=i.isPending,t[74]=r,t[75]=B):B=t[75];let V;t[76]!==z||t[77]!==B?(V=(0,$.jsx)(Z,{label:z,children:B}),t[76]=z,t[77]=B,t[78]=V):V=t[78];let H;return t[79]!==N||t[80]!==V?(H=(0,$.jsx)(qa,{variant:`background`,header:N,children:V}),t[79]=N,t[80]=V,t[81]=H):H=t[81],H},to=({onItemDeleted:e})=>{let{t}=De(),n=Rt(),r=At(),i=n.data,a=Ot(e=>e.projects),o=zt(e=>e.settingsSelectedAssistantID),s=zt(e=>e.selectSettingsAssistant),c=zt(e=>e.defaultShareAssistant),l=zt(e=>e.setDefaultShareAssistant),u=zt(e=>e.createRequestRevision),d=zt(e=>e.requestCreate),[f,p]=Q.useState(Xa),[m,h]=Q.useState(!1),g=Q.useRef(0),_=i?.assistants.find(e=>e.id===o)??null,v=_?Ae(_.name):null,y=Ae(f.name),b=f.workspacePath??_?.managedWorkspacePath??null,x=st(b,{enabled:!0}),S=ct(b,{enabled:!0}),C=x.data??[],w=S.data??[];Q.useEffect(()=>{_&&p(Za(_))},[_]),Q.useEffect(()=>{n.isSuccess&&o&&o!==`new`&&!_&&s(null)},[s,_,o,n.isSuccess]),Q.useEffect(()=>{o!==`new`||u<=g.current||(g.current=u,p(Xa()),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[u,o]),Q.useEffect(()=>{n.isSuccess&&r.data?.serverInstanceID&&c?.serverInstanceID===r.data.serverInstanceID&&!i?.assistants.some(e=>e.id===c.assistantID)&&l(null)},[r.data,c,l,i?.assistants,n.isSuccess]),Q.useEffect(()=>{n.isSuccess&&je()},[i?.revision,n.isSuccess]);let T=(e,t)=>{p(n=>({...n,[e]:t}))},E=Ee(()=>d()),D=Ee(async()=>{if(!f.name.trim()||!f.providerID||!f.modelID){we.error(t(`assistants.settings.validation.required`));return}h(!0);try{let e=_?await Pt(_,f):await It(f);s(e.id),we.success(t(`assistants.settings.toast.saved`))}catch{we.error(t(`assistants.settings.toast.saveFailed`))}finally{h(!1)}}),O=Ee(async()=>{if(!(!_||!window.confirm(t(`assistants.settings.deleteConfirm`,{name:_.name})))){h(!0);try{if(await jt(_),c?.assistantID===_.id){let e=await Mt();e.serverInstanceID&&c.serverInstanceID===e.serverInstanceID&&l(null)}s(null),e?.(),we.success(t(`assistants.settings.toast.deleted`))}catch{we.error(t(`assistants.settings.toast.deleteFailed`))}finally{h(!1)}}}),k=Ee(async(e,n)=>{if(!n){l(null),Me();return}try{let t=await Mt();if(!t.supported||!t.serverInstanceID)return;l({serverInstanceID:t.serverInstanceID,assistantID:e}),await Me()}catch{we.error(t(`assistants.settings.toast.toggleFailed`))}}),A=f.workspacePath===null?null:a.find(e=>e.path===f.workspacePath)??null,j=f.workspacePath!==null&&!A?f.workspacePath:null,M=f.workspacePath===null?Ja:A?A.id:Ya,N=f.workspacePath===null?(0,$.jsx)($a,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):A?(0,$.jsx)($a,{name:Qa(A),path:A.path}):(0,$.jsx)($a,{name:t(`assistants.settings.workspaceCurrentPath`),path:j??``,icon:`history`});return r.isSuccess&&!r.data.supported?null:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):n.isError&&!i?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(J,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:t(`assistants.state.unavailable`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void n.refetch(),children:t(`assistants.actions.retry`)})]}):(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n.isError&&i?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:t(`assistants.state.staleSnapshot`)}):null,o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,$.jsx)(Bt,{name:_?.id??`new`,emoji:y.avatarEmoji,size:38,label:y.displayName||f.name||t(`assistants.settings.create`)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:_?v?.displayName:t(`assistants.settings.create`)}),(0,$.jsx)(`p`,{className:`mt-0.5 typography-micro leading-none text-muted-foreground/70`,children:f.mode===`continuous`?t(`assistants.mode.continuous`):t(`assistants.mode.stateless`)})]}),_?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:O,disabled:m,className:`text-[var(--status-error)]`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`size-4`}),t(`assistants.settings.delete`)]}):null]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(jr,{itemId:`assistants.name`,label:t(`assistants.settings.name`),children:(0,$.jsx)(ln,{id:`assistant-name`,value:f.name,onChange:e=>T(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(jr,{label:t(`assistants.settings.enabled`),children:(0,$.jsx)(Zt,{checked:f.enabled,onChange:e=>T(`enabled`,e),ariaLabel:t(`assistants.settings.enabled`)})}),_?(0,$.jsx)(jr,{itemId:`assistants.default-share`,label:t(`assistants.settings.defaultShare`),children:(0,$.jsx)(Zt,{checked:c?.assistantID===_.id&&c.serverInstanceID===r.data?.serverInstanceID,onChange:e=>void k(_.id,e),ariaLabel:t(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(Er,{itemId:`assistants.prompt`,label:t(`assistants.settings.defaultPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,id:`assistant-prompt`,value:f.defaultPrompt,onChange:e=>T(`defaultPrompt`,e.target.value),placeholder:t(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsxs)(Z,{label:t(`assistants.settings.runtime`),children:[(0,$.jsx)(jr,{itemId:`assistants.model`,label:t(`assistants.settings.model`),children:(0,$.jsx)(ar,{providerId:f.providerID,modelId:f.modelID,providers:C,onChange:(e,t)=>p(n=>({...n,providerID:e,modelID:t})),className:`oc-settings-inline-value`})}),(0,$.jsx)(jr,{itemId:`assistants.agent`,label:t(`assistants.settings.agent`),children:(0,$.jsx)(nr,{agentName:f.agent??``,agents:w,onChange:e=>T(`agent`,e||null),className:`oc-settings-inline-value`})}),(0,$.jsx)(jr,{itemId:`assistants.mode`,label:t(`assistants.settings.mode`),description:f.mode===`stateless`?t(`assistants.conversation.statelessHint`):t(`assistants.conversation.continuousHint`),children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap justify-end gap-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`continuous`,`stateless`].map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":f.mode===e,onClick:()=>T(`mode`,e),children:t(e===`continuous`?`assistants.mode.continuous`:`assistants.mode.stateless`)},e))})})})]}),(0,$.jsx)(Er,{itemId:`assistants.workspace`,label:t(`assistants.settings.workspace`),description:t(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(tn,{value:M,onValueChange:e=>{if(e===Ja){T(`workspacePath`,null);return}let t=a.find(t=>t.id===e);t&&T(`workspacePath`,t.path)},children:[(0,$.jsx)(cn,{title:f.workspacePath??t(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(Qt,{children:N})}),(0,$.jsxs)(en,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(sn,{value:Ja,children:(0,$.jsx)($a,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),a.map(e=>(0,$.jsx)(sn,{value:e.id,children:(0,$.jsx)($a,{name:Qa(e),path:e.path})},e.id)),j?(0,$.jsx)(sn,{value:Ya,disabled:!0,children:(0,$.jsx)($a,{name:t(`assistants.settings.workspaceCurrentPath`),path:j,icon:`history`})}):null]})]})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(Y,{onClick:D,disabled:m,children:[m?(0,$.jsx)(J,{name:`loader-4`,className:`size-4 animate-spin`}):null,t(`assistants.settings.save`)]})})]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)(Bt,{name:`assistants-empty`,size:44}),(0,$.jsx)(`p`,{className:`typography-ui`,children:t(`assistants.settings.empty`)}),(0,$.jsxs)(Y,{"data-settings-item":`assistants.create`,size:`sm`,onClick:E,children:[(0,$.jsx)(J,{name:`add`,className:`size-4`}),t(`assistants.settings.create`)]})]})]})})};function no(e){return e.settingsSelectedAssistantID}function ro(e){return e.selectSettingsAssistant}function io(e){return e.requestCreate}var ao=`~/.config/opencode/AGENTS.md`,oo=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},so=e=>e.length>0&&!e.endsWith(`
|
|
2
2
|
`)?`${e}\n`:e,co={prompt:``,responseStyleEnabled:!1,responseStylePreset:`concise`,responseStyleCustomInstructions:``},lo=(e,t)=>e===`custom`?t:Ve(e),uo=e=>e===`custom`?`custom`:Ue(e)?e:`concise`,fo={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`},po=async(e,t)=>{let n=await I(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(await oo(n,t));return n.json().catch(()=>null)},mo=()=>{let{t:e}=De(),t=Q.useSyncExternalStore(o,r,r),[n,i]=Q.useState(``),[a,s]=Q.useState(co.responseStyleEnabled),[c,l]=Q.useState(co.responseStylePreset),[u,d]=Q.useState(co.responseStyleCustomInstructions),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(``),b=Q.useRef(null),x=Q.useRef(null),S=Q.useRef(0),C=Q.useRef(Promise.resolve());Q.useEffect(()=>{let e=!0;return h(!1),b.current=null,x.current=null,S.current+=1,P(t).then(n=>{if(!e||t!==r())return;let i={enabled:n.responseStyleEnabled===!0,preset:uo(n.responseStylePreset),custom:typeof n.responseStyleCustomInstructions==`string`?n.responseStyleCustomInstructions:``};s(i.enabled),l(i.preset),d(i.custom),Ie({enabled:i.enabled,preset:i.preset,customInstructions:i.custom},t),b.current=i,x.current=i,h(!0)}).catch(t=>{e&&t?.name!==`AbortError`&&console.warn(`Failed to load behavior settings:`,t)}),()=>{e=!1,S.current+=1}},[t]),Q.useEffect(()=>{let e=new AbortController,n=!0;return p(!1),_(!1),(async()=>{try{let a=await I(`/api/behavior/agents-md`,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!a.ok)throw Error(`Behavior prompt request failed (${a.status})`);let o=await a.json().catch(()=>null);if(typeof o?.content!=`string`)throw Error(`Invalid behavior prompt response`);if(!n||t!==r())return;i(o.content),y(o.content),p(!0)}catch(e){n&&e?.name!==`AbortError`&&console.warn(`Failed to load behavior prompt:`,e)}})(),()=>{n=!1,e.abort()}},[t]),Q.useEffect(()=>{if(!m)return;let n={enabled:a,preset:c,custom:u},i=x.current;if(i&&i.enabled===n.enabled&&i.preset===n.preset&&i.custom===n.custom)return;x.current=n;let o=S.current+1;S.current=o;let f=setTimeout(()=>{let i=async()=>{if(t===r())try{let i=await po({responseStyleEnabled:n.enabled,responseStylePreset:n.preset,responseStyleCustomInstructions:n.custom},e(`settings.behavior.page.toast.saveFailed`));if(t!==r())return;let a=j(i),c={enabled:a.responseStyleEnabled??n.enabled,preset:a.responseStylePreset??n.preset,custom:a.responseStyleCustomInstructions??n.custom};if(Ie({enabled:c.enabled,preset:c.preset,customInstructions:c.custom},t),T({responseStyleEnabled:c.enabled,responseStylePreset:c.preset,responseStyleCustomInstructions:c.custom},t),b.current=c,o!==S.current)return;x.current=c,s(c.enabled),l(c.preset),d(c.custom)}catch(n){if(t===r()&&o===S.current){let t=b.current;x.current=t,t&&(s(t.enabled),l(t.preset),d(t.custom));let r=n instanceof Error?n.message:e(`settings.behavior.page.toast.saveFailed`);K.error(r)}}};C.current=C.current.then(i,i)},400);return()=>clearTimeout(f)},[a,c,u,m,e,t]);let w=lo(c,u),E=n!==v;return(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.behavior.page.title`)})}),(0,$.jsx)(Z,{itemId:`behavior.system-prompt`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.systemPrompt`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:e(`settings.behavior.page.warning.title`)}),(0,$.jsx)(`p`,{children:e(`settings.behavior.page.warning.description`,{path:ao})})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(on,{embedded:!0,value:n,onChange:e=>i(e.target.value),placeholder:e(`settings.behavior.page.field.systemPromptPlaceholder`),rows:12,disabled:!f,outerClassName:`min-h-[160px] max-h-[70vh]`,className:`w-full font-mono typography-meta bg-transparent`}),(0,$.jsx)(Y,{onClick:async()=>{let a=t;if(a===r()){_(!0);try{let t=so(n),o=await I(`/api/behavior/agents-md`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:t})});if(!o.ok)throw Error(await oo(o,e(`settings.behavior.page.toast.saveFailed`)));if(a!==r()||(await po({globalBehaviorPrompt:t},e(`settings.behavior.page.toast.saveFailed`)),a!==r()))return;i(t),y(t),K.success(e(`settings.behavior.page.toast.saved`))}catch(t){if(a!==r())return;console.error(`Failed to save behavior:`,t);let n=t instanceof Error?t.message:e(`settings.behavior.page.toast.saveFailed`);K.error(n)}finally{a===r()&&_(!1)}}},disabled:g||!E||!f,size:`xs`,className:`!font-normal`,children:e(g?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})]})}),(0,$.jsxs)(Z,{itemId:`behavior.response-style`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.responseStyle`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.behavior.page.responseStyle.tooltip`)})]})]}),children:[(0,$.jsxs)(jr,{label:e(`settings.behavior.page.responseStyle.enable`),children:[(0,$.jsx)(Zt,{checked:a,onChange:s,disabled:!m,ariaLabel:e(`settings.behavior.page.responseStyle.enableAria`)}),(0,$.jsxs)(tn,{value:c,onValueChange:e=>l(e),disabled:!m||!a,children:[(0,$.jsx)(cn,{className:`w-full sm:w-56`,children:(0,$.jsx)(Qt,{children:t=>t===`custom`?e(`settings.behavior.page.responseStyle.option.custom`):Ue(t)?e(fo[t]):null})}),(0,$.jsxs)(en,{children:[ft.map(t=>(0,$.jsx)(sn,{value:t,children:e(fo[t])},t)),(0,$.jsx)(sn,{value:`custom`,children:e(`settings.behavior.page.responseStyle.option.custom`)})]})]})]}),(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(on,{embedded:!0,value:w,onChange:e=>d(e.target.value),placeholder:e(`settings.behavior.page.responseStyle.customPlaceholder`),rows:5,disabled:!m||!a||c!==`custom`,outerClassName:`min-h-[120px]`,className:`w-full font-mono typography-meta bg-transparent`})})]})]})})},ho=e=>{let t=(0,Si.c)(158),{onItemSelect:n}=e,{t:r}=De(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),{selectedCommandName:g,setSelectedCommand:_,setCommandDraft:v,createCommand:y,deleteCommand:b}=zi(me(_o)),x=tt(),S;t[0]===x.data?S=t[1]:(S=x.data??[],t[0]=x.data,t[1]=S);let C=S,w=dt(),T;t[2]===w.data?T=t[3]:(T=w.data??[],t[2]=w.data,t[3]=T);let E=T,{refetch:D}=w,O,k;t[4]===D?(O=t[5],k=t[6]):(O=()=>{D()},k=[D],t[4]=D,t[5]=O,t[6]=k),Q.useEffect(O,k);let A;t[7]===E?A=t[8]:(A=new Set(E.map(vo)),t[7]=E,t[8]=A);let j=A,M;if(t[9]!==C||t[10]!==j){let e;t[12]===j?e=t[13]:(e=e=>!j.has(e.name),t[12]=j,t[13]=e),M=C.filter(e),t[9]=C,t[10]=j,t[11]=M}else M=t[11];let N=M,P,F;t[14]!==g||t[15]!==_||t[16]!==j?(P=()=>{g&&j.has(g)&&_(null)},F=[g,_,j],t[14]=g,t[15]=_,t[16]=j,t[17]=P,t[18]=F):(P=t[17],F=t[18]),Q.useEffect(P,F);let I;t[19]!==C||t[20]!==n||t[21]!==v||t[22]!==_?(I=()=>{let e=`new-command`,t=1;for(;C.some(t=>t.name===e);)e=`new-command-${t}`,t++;v({name:e,scope:`user`}),_(e),n?.()},t[19]=C,t[20]=n,t[21]=v,t[22]=_,t[23]=I):I=t[23];let L=I,R;t[24]===r?R=t[25]:(R=async e=>{if(Li(e)){K.error(r(`settings.commands.sidebar.toast.builtInCannotDelete`));return}l(e),d(`delete`)},t[24]=r,t[25]=R);let z=R,B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=async e=>{Li(e)&&(l(e),d(`reset`))},t[26]=B):B=t[26];let V=B,H;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{l(null),d(null)},t[27]=H):H=t[27];let U=H,W;t[28]!==c||t[29]!==u||t[30]!==b||t[31]!==r?(W=async()=>{!c||!u||(p(!0),await b(c.name)?(u===`delete`?K.success(r(`settings.commands.sidebar.toast.commandDeleted`,{name:c.name})):K.success(r(`settings.commands.sidebar.toast.commandReset`,{name:c.name})),U()):u===`delete`?K.error(r(`settings.commands.sidebar.toast.deleteFailed`)):K.error(r(`settings.commands.sidebar.toast.resetFailed`)),p(!1))},t[28]=c,t[29]=u,t[30]=b,t[31]=r,t[32]=W):W=t[32];let ee=W,G;t[33]!==C||t[34]!==v||t[35]!==_?(G=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;C.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;v({name:r,scope:e.scope||`user`,description:e.description,template:e.template,agent:e.agent,model:e.model}),_(r)},t[33]=C,t[34]=v,t[35]=_,t[36]=G):G=t[36];let te=G,ne;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>{s(e.name),a(e)},t[37]=ne):ne=t[37];let re=ne,ie;t[38]!==C||t[39]!==y||t[40]!==b||t[41]!==i||t[42]!==o||t[43]!==_||t[44]!==r?(ie=async()=>{if(!i)return;let e=o.trim().replace(/\s+/g,`-`);if(!e){K.error(r(`settings.commands.sidebar.toast.commandNameRequired`));return}if(e===i.name){a(null);return}if(C.some(t=>t.name===e)){K.error(r(`settings.commands.sidebar.toast.commandExists`));return}await y({name:e,description:i.description,template:i.template,agent:i.agent,model:i.model})?await b(i.name)?(K.success(`Command renamed to "${e}"`),_(e)):K.error(r(`settings.commands.sidebar.toast.removeOldAfterRenameFailed`)):K.error(r(`settings.commands.sidebar.toast.renameFailed`)),a(null)},t[38]=C,t[39]=y,t[40]=b,t[41]=i,t[42]=o,t[43]=_,t[44]=r,t[45]=ie):ie=t[45];let ae=ie,oe,se,ce;if(t[46]!==N||t[47]!==L||t[48]!==z||t[49]!==te||t[50]!==n||t[51]!==m||t[52]!==g||t[53]!==_||t[54]!==r){let e=N.filter(Li),i=N.filter(yo),a;t[58]===r?a=t[59]:(a=r(`settings.commands.sidebar.section.custom`),t[58]=r,t[59]=a);let o;t[60]===a?o=t[61]:(o=(0,$.jsx)(`span`,{children:a}),t[60]=a,t[61]=o);let s;t[62]===r?s=t[63]:(s=r(`settings.commands.page.title.new`),t[62]=r,t[63]=s);let c;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[64]=c):c=t[64];let l;t[65]!==L||t[66]!==s?(l=(0,$.jsx)(Y,{"data-settings-item":`commands.create`,size:`icon`,variant:`ghost`,onClick:L,"aria-label":s,children:c}),t[65]=L,t[66]=s,t[67]=l):l=t[67];let u;t[68]!==o||t[69]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[o,l]}),t[68]=o,t[69]=l,t[70]=u):u=t[70];let d=u;oe=`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(la,{})})}),t[71]=se):se=t[71],ce=(0,$.jsx)($.Fragment,{children:N.length===0?(0,$.jsx)(Z,{label:d,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`terminal-box`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.commands.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.commands.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[e.length>0&&(0,$.jsx)(Z,{label:r(`settings.commands.sidebar.section.builtIn`),children:[...e].sort(bo).map(e=>(0,$.jsx)(go,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onReset:()=>V(e),onDuplicate:()=>te(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}),i.length>0?(0,$.jsx)(Z,{label:d,children:[...i].sort(xo).map(e=>(0,$.jsx)(go,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onRename:()=>re(e),onDelete:()=>z(e),onDuplicate:()=>te(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}):(0,$.jsx)(Z,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[46]=N,t[47]=L,t[48]=z,t[49]=te,t[50]=n,t[51]=m,t[52]=g,t[53]=_,t[54]=r,t[55]=oe,t[56]=se,t[57]=ce}else oe=t[55],se=t[56],ce=t[57];let le=c!==null&&u!==null,ue;t[72]===f?ue=t[73]:(ue=e=>{!e&&!f&&U()},t[72]=f,t[73]=ue);let de;t[74]!==u||t[75]!==r?(de=r(u===`delete`?`settings.commands.sidebar.dialog.deleteTitle`:`settings.commands.sidebar.dialog.resetTitle`),t[74]=u,t[75]=r,t[76]=de):de=t[76];let fe;t[77]===de?fe=t[78]:(fe=(0,$.jsx)(Gt,{children:de}),t[77]=de,t[78]=fe);let pe;t[79]!==c?.name||t[80]!==u||t[81]!==r?(pe=r(u===`delete`?`settings.commands.sidebar.dialog.deleteDescription`:`settings.commands.sidebar.dialog.resetDescription`,{name:c?.name??``}),t[79]=c?.name,t[80]=u,t[81]=r,t[82]=pe):pe=t[82];let he;t[83]===pe?he=t[84]:(he=(0,$.jsx)(Kt,{children:pe}),t[83]=pe,t[84]=he);let ge;t[85]!==fe||t[86]!==he?(ge=(0,$.jsxs)(Ht,{children:[fe,he]}),t[85]=fe,t[86]=he,t[87]=ge):ge=t[87];let _e;t[88]===r?_e=t[89]:(_e=r(`settings.common.actions.cancel`),t[88]=r,t[89]=_e);let ve;t[90]!==f||t[91]!==_e?(ve=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:U,disabled:f,children:_e}),t[90]=f,t[91]=_e,t[92]=ve):ve=t[92];let ye;t[93]!==u||t[94]!==r?(ye=r(u===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`),t[93]=u,t[94]=r,t[95]=ye):ye=t[95];let be;t[96]!==ee||t[97]!==f||t[98]!==ye?(be=(0,$.jsx)(Y,{size:`sm`,onClick:ee,disabled:f,children:ye}),t[96]=ee,t[97]=f,t[98]=ye,t[99]=be):be=t[99];let xe;t[100]!==ve||t[101]!==be?(xe=(0,$.jsxs)(Ut,{children:[ve,be]}),t[100]=ve,t[101]=be,t[102]=xe):xe=t[102];let Se;t[103]!==ge||t[104]!==xe?(Se=(0,$.jsxs)(Wt,{className:`max-w-md`,children:[ge,xe]}),t[103]=ge,t[104]=xe,t[105]=Se):Se=t[105];let Ce;t[106]!==le||t[107]!==ue||t[108]!==Se?(Ce=(0,$.jsx)(qt,{open:le,onOpenChange:ue,children:Se}),t[106]=le,t[107]=ue,t[108]=Se,t[109]=Ce):Ce=t[109];let we=i!==null,Te;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>!e&&a(null),t[110]=Te):Te=t[110];let Ee;t[111]===r?Ee=t[112]:(Ee=r(`settings.commands.sidebar.renameDialog.title`),t[111]=r,t[112]=Ee);let Oe;t[113]===Ee?Oe=t[114]:(Oe=(0,$.jsx)(Gt,{children:Ee}),t[113]=Ee,t[114]=Oe);let ke=i?.name??``,Ae;t[115]!==r||t[116]!==ke?(Ae=r(`settings.commands.sidebar.renameDialog.description`,{name:ke}),t[115]=r,t[116]=ke,t[117]=Ae):Ae=t[117];let je;t[118]===Ae?je=t[119]:(je=(0,$.jsx)(Kt,{children:Ae}),t[118]=Ae,t[119]=je);let Me;t[120]!==Oe||t[121]!==je?(Me=(0,$.jsxs)(Ht,{children:[Oe,je]}),t[120]=Oe,t[121]=je,t[122]=Me):Me=t[122];let Ne;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=e=>s(e.target.value),t[123]=Ne):Ne=t[123];let Pe;t[124]===r?Pe=t[125]:(Pe=r(`settings.commands.sidebar.renameDialog.placeholder`),t[124]=r,t[125]=Pe);let Fe;t[126]===ae?Fe=t[127]:(Fe=e=>{e.key===`Enter`&&ae()},t[126]=ae,t[127]=Fe);let Ie;t[128]!==o||t[129]!==Pe||t[130]!==Fe?(Ie=(0,$.jsx)(ln,{value:o,onChange:Ne,placeholder:Pe,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Fe}),t[128]=o,t[129]=Pe,t[130]=Fe,t[131]=Ie):Ie=t[131];let Le;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(Le=()=>a(null),t[132]=Le):Le=t[132];let Re;t[133]===r?Re=t[134]:(Re=r(`settings.common.actions.cancel`),t[133]=r,t[134]=Re);let ze;t[135]===Re?ze=t[136]:(ze=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:Le,children:Re}),t[135]=Re,t[136]=ze);let Be;t[137]===r?Be=t[138]:(Be=r(`settings.common.actions.rename`),t[137]=r,t[138]=Be);let Ve;t[139]!==ae||t[140]!==Be?(Ve=(0,$.jsx)(Y,{size:`sm`,onClick:ae,children:Be}),t[139]=ae,t[140]=Be,t[141]=Ve):Ve=t[141];let He;t[142]!==ze||t[143]!==Ve?(He=(0,$.jsxs)(Ut,{children:[ze,Ve]}),t[142]=ze,t[143]=Ve,t[144]=He):He=t[144];let Ue;t[145]!==Me||t[146]!==Ie||t[147]!==He?(Ue=(0,$.jsxs)(Wt,{children:[Me,Ie,He]}),t[145]=Me,t[146]=Ie,t[147]=He,t[148]=Ue):Ue=t[148];let We;t[149]!==we||t[150]!==Ue?(We=(0,$.jsx)(qt,{open:we,onOpenChange:Te,children:Ue}),t[149]=we,t[150]=Ue,t[151]=We):We=t[151];let Ge;return t[152]!==oe||t[153]!==se||t[154]!==ce||t[155]!==Ce||t[156]!==We?(Ge=(0,$.jsxs)(`div`,{className:oe,children:[se,ce,Ce,We]}),t[152]=oe,t[153]=se,t[154]=ce,t[155]=Ce,t[156]=We,t[157]=Ge):Ge=t[157],Ge},go=e=>{let t=(0,Si.c)(47),{command:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,isMenuOpen:l,onMenuOpenChange:u}=e,{t:d}=De(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=dr(),t[0]=f):f=t[0];let p=f,[m,h]=Q.useState(!1),g;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==d?(g=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=d,t[6]=g):g=t[6];let _=g,v=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,y;t[7]===v?y=t[8]:(y=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,v),t[7]=v,t[8]=y);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=p?void 0:e=>{e.preventDefault(),h(!0)},t[9]=b):b=t[9];let x;t[10]===y?x=t[11]:(x=(0,$.jsx)(`div`,{className:y,onContextMenu:b}),t[10]=y,t[11]=x);let S;t[12]===n.name?S=t[13]:(S=(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`/`,n.name]}),t[12]=n.name,t[13]=S);let C;t[14]!==n||t[15]!==d?(C=(n.scope||Li(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Li(n)?d(`settings.agents.sidebar.badge.system`):n.scope}),t[14]=n,t[15]=d,t[16]=C):C=t[16];let w;t[17]!==S||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.description?T=t[21]:(T=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[20]=n.description,t[21]=T);let E;t[22]!==i||t[23]!==T||t[24]!==w?(E=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[w,T]}),t[22]=i,t[23]=T,t[24]=w,t[25]=E):E=t[25];let D;t[26]===u?D=t[27]:(D=e=>{e&&h(!1),u(e)},t[26]=u,t[27]=D);let O;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[28]=O):O=t[28];let k;t[29]===_?k=t[30]:(k=(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:_(Jn)}),t[29]=_,t[30]=k);let A;t[31]!==l||t[32]!==D||t[33]!==k?(A=(0,$.jsxs)(Wn,{open:l,onOpenChange:D,children:[O,k]}),t[31]=l,t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==E||t[36]!==A?(j=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[E,A]}),t[35]=E,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==j||t[39]!==x?(M=(0,$.jsx)(fi,{render:x,children:j}),t[38]=j,t[39]=x,t[40]=M):M=t[40];let N;t[41]===_?N=t[42]:(N=(0,$.jsx)(pi,{className:`w-fit min-w-20`,children:_(mi)}),t[41]=_,t[42]=N);let P;return t[43]!==m||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(hi,{open:m,onOpenChange:h,children:[M,N]}),t[43]=m,t[44]=M,t[45]=N,t[46]=P):P=t[46],P};function _o(e){return{selectedCommandName:e.selectedCommandName,setSelectedCommand:e.setSelectedCommand,setCommandDraft:e.setCommandDraft,createCommand:e.createCommand,deleteCommand:e.deleteCommand}}function vo(e){return e.name}function yo(e){return!Li(e)}function bo(e,t){return e.name.localeCompare(t.name)}function xo(e,t){return e.name.localeCompare(t.name)}var So=()=>{let{t:e}=De(),{selectedCommandName:t,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:a}=zi(me(e=>({selectedCommandName:e.selectedCommandName,createCommand:e.createCommand,updateCommand:e.updateCommand,commandDraft:e.commandDraft,setCommandDraft:e.setCommandDraft}))),o=tt(),s=Q.useMemo(()=>o.data??[],[o.data]),c=t?s.find(e=>e.name===t):null,l=!!(i&&i.name===t&&!c),[u,d]=Q.useState(``),[f,p]=Q.useState(`user`),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),w=Q.useRef(null);Q.useEffect(()=>{if(l&&i){let e=i.name||``,t=i.scope||`user`,n=i.description||``,r=i.agent||``,a=i.model||``,o=i.template||``;d(e),p(t),h(n),_(r),y(a),x(o),w.current={draftName:e,draftScope:t,description:n,agent:r,model:a,template:o}}else if(c){let e=c.description||``,t=c.agent||``,n=c.model||``,r=c.template||``;h(e),_(t),y(n),x(r),w.current={draftName:``,draftScope:`user`,description:e,agent:t,model:n,template:r}}},[c,l,t,s,i]);let T=Q.useMemo(()=>{let e=w.current;return e?!!(l&&(u!==e.draftName||f!==e.draftScope)||m!==e.description||g!==e.agent||v!==e.model||b!==e.template):!1},[g,m,u,f,l,v,b]);return t?(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:l?e(`settings.commands.page.title.new`):`/${t}`}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.commands.page.subtitle.new`:`settings.commands.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.identity`),children:[l&&(0,$.jsxs)(jr,{itemId:`commands.name`,label:e(`settings.commands.page.field.commandName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`/`}),(0,$.jsx)(ln,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.commands.page.field.commandNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(tn,{value:f,onValueChange:e=>p(e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(en,{align:`end`,children:[(0,$.jsx)(sn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(sn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(jr,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:m,onChange:e=>h(e.target.value),placeholder:e(`settings.commands.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})})]}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.executionContext`),children:[(0,$.jsx)(jr,{itemId:`commands.agent`,label:e(`settings.commands.page.field.overrideAgent`),children:(0,$.jsx)(nr,{agentName:g,onChange:e=>_(e),className:`oc-settings-inline-value`})}),(0,$.jsx)(jr,{itemId:`commands.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ar,{providerId:Re(v)?.providerId??``,modelId:Re(v)?.modelId??``,onChange:(e,t)=>{y(e&&t?`${e}/${t}`:``)},className:`oc-settings-inline-value`})})]}),(0,$.jsx)(Er,{itemId:`commands.template`,label:e(`settings.commands.page.section.template`),description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`text-foreground`,children:`$ARGUMENTS`}),` `,e(`settings.commands.page.templateHint.userInput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:"!`cmd`"}),` `,e(`settings.commands.page.templateHint.shellOutput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`@file`}),` `,e(`settings.commands.page.templateHint.fileContents`)]}),descriptionPlacement:`outside`,className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.commands.page.field.templatePlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let i=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!i){K.error(e(`settings.commands.sidebar.toast.commandNameRequired`));return}if(!b.trim()){K.error(e(`settings.commands.page.toast.templateRequired`));return}if(l&&s.some(e=>e.name===i)){K.error(e(`settings.commands.sidebar.toast.commandExists`));return}C(!0);try{let t=g.trim(),o=v.trim(),s=b.trim(),c={name:i,description:m.trim()||void 0,agent:t===``?null:t,model:o===``?null:o,template:s,scope:l?f:void 0},u;l?(u=await n(c),u&&a(null)):u=await r(i,c),u?K.success(e(l?`settings.commands.page.toast.created`:`settings.commands.page.toast.updated`)):K.error(e(l?`settings.commands.page.toast.createFailed`:`settings.commands.page.toast.updateFailed`))}catch(t){console.error(`Error saving command:`,t),K.error(e(`settings.commands.page.toast.saveUnexpectedError`))}finally{C(!1)}},disabled:S||!T,size:`xs`,className:`!font-normal`,children:e(S?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`terminal-box`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.commands.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.commands.page.empty.description`)})]})})},Co=[],wo=e=>{switch(e){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`idle`}},To=e=>{let t=(0,Si.c)(5),{tone:n,enabled:r}=e;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0`}),t[0]=e):e=t[0],e}let i;t[1]===n?i=t[2]:(i=q(`inline-block h-2 w-2 rounded-full flex-shrink-0`,{success:`bg-[var(--status-success)]`,error:`bg-[var(--status-error)]`,warning:`bg-[var(--status-warning)]`,idle:`bg-muted-foreground/40`}[n]),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`span`,{className:i}),t[3]=i,t[4]=a),a},Eo=e=>{let t=(0,Si.c)(115),{onItemSelect:n}=e,{t:i}=De(),{selectedMcpName:a,setSelectedMcp:o,setMcpDraft:s,deleteMcp:c}=qi(me(Do)),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Wr(),t[0]=l):l=t[0];let u=l,d=Ur(u),f=Gr(u),p=d.data??Co,m;t[1]===f.data?m=t[2]:(m=f.data??{},t[1]=f.data,t[2]=m);let h=m,[g,_]=Q.useState(null),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,C]=Q.useState(null),[w,T]=Q.useState(!1),E;t[3]===p?E=t[4]:(E=p.filter(Oo),t[3]=p,t[4]=E);let D=E,O;t[5]===p?O=t[6]:(O=p.filter(ko),t[5]=p,t[6]=O);let k=O,A;t[7]===w?A=t[8]:(A=()=>{if(w)return;T(!0);let e=new Promise(Ao),t=r();Promise.all([kr(V,u,t),e]).catch(jo).finally(()=>{T(!1)})},t[7]=w,t[8]=A);let j=A,M;t[9]!==p||t[10]!==n||t[11]!==s||t[12]!==o?(M=()=>{let e=`new-mcp-server`,t=1;for(;p.some(t=>t.name===e);)e=`new-mcp-server-${t}`,t++;s({name:e,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),o(e),n?.()},t[9]=p,t[10]=n,t[11]=s,t[12]=o,t[13]=M):M=t[13];let N=M,P;t[14]!==c||t[15]!==g||t[16]!==i?(P=async()=>{if(!g)return;y(!0);let e=await c(g.name,{directory:Wr(),transportIdentity:r()});e.ok?e.reloadFailed?K.warning(e.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:e.warning||i(`settings.mcp.sidebar.toast.refreshListIfStale`)}):K.success(e.message||i(`settings.mcp.sidebar.toast.serverDeleted`,{name:g.name})):K.error(i(`settings.mcp.sidebar.toast.deleteFailed`)),_(null),y(!1)},t[14]=c,t[15]=g,t[16]=i,t[17]=P):P=t[17];let F=P,I;t[18]===i?I=t[19]:(I=(e,t)=>(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),_(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),i(`settings.common.actions.delete`)]}),t[18]=i,t[19]=I);let L=I,R;t[20]===i?R=t[21]:(R=i(`settings.mcp.sidebar.group.userServers`),t[20]=i,t[21]=R);let z;t[22]===R?z=t[23]:(z=(0,$.jsx)(`span`,{children:R}),t[22]=R,t[23]=z);let B;t[24]===i?B=t[25]:(B=i(`settings.mcp.sidebar.actions.refreshStatusAria`),t[24]=i,t[25]=B);let H;t[26]===i?H=t[27]:(H=i(`settings.mcp.sidebar.actions.refreshStatusTitle`),t[26]=i,t[27]=H);let U=w&&`animate-spin`,W;t[28]===U?W=t[29]:(W=q(`h-4 w-4`,U),t[28]=U,t[29]=W);let ee;t[30]===W?ee=t[31]:(ee=(0,$.jsx)(J,{name:`refresh`,className:W}),t[30]=W,t[31]=ee);let G;t[32]!==j||t[33]!==w||t[34]!==B||t[35]!==H||t[36]!==ee?(G=(0,$.jsx)(Y,{type:`button`,size:`icon`,variant:`ghost`,disabled:w,onClick:j,"aria-label":B,title:H,children:ee}),t[32]=j,t[33]=w,t[34]=B,t[35]=H,t[36]=ee,t[37]=G):G=t[37];let te;t[38]===i?te=t[39]:(te=i(`settings.mcp.sidebar.actions.addServerTitle`),t[38]=i,t[39]=te);let ne;t[40]===i?ne=t[41]:(ne=i(`settings.mcp.sidebar.actions.addServerTitle`),t[40]=i,t[41]=ne);let re;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[42]=re):re=t[42];let ie;t[43]!==N||t[44]!==te||t[45]!==ne?(ie=(0,$.jsx)(Y,{"data-settings-item":`mcp.create`,size:`icon`,variant:`ghost`,onClick:N,"aria-label":te,title:ne,children:re}),t[43]=N,t[44]=te,t[45]=ne,t[46]=ie):ie=t[46];let ae;t[47]!==G||t[48]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[G,ie]}),t[47]=G,t[48]=ie,t[49]=ae):ae=t[49];let oe;t[50]!==z||t[51]!==ae?(oe=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[z,ae]}),t[50]=z,t[51]=ae,t[52]=oe):oe=t[52];let se=oe,ce;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(la,{})})}),t[53]=ce):ce=t[53];let le;t[54]!==d.data||t[55]!==d.error||t[56]!==d.isError||t[57]!==p.length||t[58]!==h||t[59]!==n||t[60]!==b||t[61]!==D||t[62]!==L||t[63]!==S||t[64]!==a||t[65]!==s||t[66]!==o||t[67]!==f.data||t[68]!==f.error||t[69]!==f.isError||t[70]!==i||t[71]!==k||t[72]!==se?(le=(0,$.jsx)($.Fragment,{children:d.isError&&!d.data?(0,$.jsx)(Z,{label:se,children:(0,$.jsx)(`div`,{className:`oc-settings-group-row py-12 text-center typography-meta text-[var(--status-error)]`,children:d.error.message})}):p.length===0?(0,$.jsx)(Z,{label:se,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:i(`settings.mcp.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:i(`settings.mcp.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[D.length>0&&(0,$.jsx)(Z,{label:i(`settings.mcp.sidebar.group.projectServers`),children:D.map(e=>{let t=wo((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),r=a===e.name,c=dr();return(0,$.jsxs)(hi,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(fi,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(To,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?i(`settings.mcp.sidebar.serverType.localTitle`):i(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(J,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(J,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(Wn,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:L(e,Jn)})]})]}),(0,$.jsx)(pi,{className:`w-fit min-w-20`,children:L(e,mi)})]},e.name)})}),k.length>0&&(0,$.jsx)(Z,{label:se,children:k.map(e=>{let t=wo((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),r=a===e.name,c=dr();return(0,$.jsxs)(hi,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(fi,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(To,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?i(`settings.mcp.sidebar.serverType.localTitle`):i(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(J,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(J,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(Wn,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:L(e,Jn)})]})]}),(0,$.jsx)(pi,{className:`w-fit min-w-20`,children:L(e,mi)})]},e.name)})}),k.length===0&&(0,$.jsx)(Z,{label:se,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[54]=d.data,t[55]=d.error,t[56]=d.isError,t[57]=p.length,t[58]=h,t[59]=n,t[60]=b,t[61]=D,t[62]=L,t[63]=S,t[64]=a,t[65]=s,t[66]=o,t[67]=f.data,t[68]=f.error,t[69]=f.isError,t[70]=i,t[71]=k,t[72]=se,t[73]=le):le=t[73];let ue=g!==null,de;t[74]===v?de=t[75]:(de=e=>{!e&&!v&&_(null)},t[74]=v,t[75]=de);let fe;t[76]===i?fe=t[77]:(fe=i(`settings.mcp.sidebar.deleteDialog.title`),t[76]=i,t[77]=fe);let pe;t[78]===fe?pe=t[79]:(pe=(0,$.jsx)(Gt,{children:fe}),t[78]=fe,t[79]=pe);let he=g?.name||``,ge;t[80]!==i||t[81]!==he?(ge=i(`settings.mcp.sidebar.deleteDialog.descriptionPrefix`,{name:he}),t[80]=i,t[81]=he,t[82]=ge):ge=t[82];let _e;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),t[83]=_e):_e=t[83];let ve;t[84]===ge?ve=t[85]:(ve=(0,$.jsxs)(Kt,{children:[ge,` `,_e,`.`]}),t[84]=ge,t[85]=ve);let ye;t[86]!==pe||t[87]!==ve?(ye=(0,$.jsxs)(Ht,{children:[pe,ve]}),t[86]=pe,t[87]=ve,t[88]=ye):ye=t[88];let be;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>_(null),t[89]=be):be=t[89];let xe;t[90]===i?xe=t[91]:(xe=i(`settings.common.actions.cancel`),t[90]=i,t[91]=xe);let Se;t[92]!==v||t[93]!==xe?(Se=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:be,disabled:v,children:xe}),t[92]=v,t[93]=xe,t[94]=Se):Se=t[94];let Ce;t[95]!==v||t[96]!==i?(Ce=i(v?`settings.mcp.sidebar.actions.deleting`:`settings.common.actions.delete`),t[95]=v,t[96]=i,t[97]=Ce):Ce=t[97];let we;t[98]!==F||t[99]!==v||t[100]!==Ce?(we=(0,$.jsx)(Y,{size:`sm`,onClick:F,disabled:v,children:Ce}),t[98]=F,t[99]=v,t[100]=Ce,t[101]=we):we=t[101];let Te;t[102]!==Se||t[103]!==we?(Te=(0,$.jsxs)(Ut,{children:[Se,we]}),t[102]=Se,t[103]=we,t[104]=Te):Te=t[104];let Ee;t[105]!==ye||t[106]!==Te?(Ee=(0,$.jsxs)(Wt,{className:`max-w-md`,children:[ye,Te]}),t[105]=ye,t[106]=Te,t[107]=Ee):Ee=t[107];let Oe;t[108]!==ue||t[109]!==de||t[110]!==Ee?(Oe=(0,$.jsx)(qt,{open:ue,onOpenChange:de,children:Ee}),t[108]=ue,t[109]=de,t[110]=Ee,t[111]=Oe):Oe=t[111];let ke;return t[112]!==le||t[113]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[ce,le,Oe]}),t[112]=le,t[113]=Oe,t[114]=ke):ke=t[114],ke};function Do(e){return{selectedMcpName:e.selectedMcpName,setSelectedMcp:e.setSelectedMcp,setMcpDraft:e.setMcpDraft,deleteMcp:e.deleteMcp}}function Oo(e){return e.scope===`project`}function ko(e){return e.scope!==`project`}function Ao(e){return setTimeout(e,500)}function jo(e){K.error(e instanceof Error?e.message:String(e))}function Mo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function No(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Po(e,t){return t===void 0?{ok:!1,error:e}:{ok:!1,error:e,parsed:t}}function Fo(e,t,n){return{ok:!0,name:e,type:t,command:Io(n),url:typeof n.url==`string`?n.url.trim():``,environment:Lo(n,`env`,`environment`),headers:Lo(n,`headers`),oauthEnabled:Ro(n),oauthClientId:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientId??``).trim():``,oauthClientSecret:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientSecret??``).trim():``,oauthScope:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.scope??``).trim():``,oauthRedirectUri:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.redirectUri??``).trim():``,timeout:zo(n),enabled:Bo(n)}}function Io(e){let t=e.command,n=e.args;if(No(t)&&No(n))return[...t,...n];if(No(t))return t;if(typeof t==`string`&&t.trim()){let e=t.trim().split(/\s+/);return No(n)?[...e,...n]:e}return No(n)?n:[]}function Lo(e,...t){for(let n of t){let t=e[n];if(!Mo(t))continue;let r=Object.entries(t).filter(([e,t])=>e&&typeof t==`string`);if(r.length>0)return r.map(([e,t])=>({key:e,value:String(t)}))}return[]}function Ro(e){if(e.oauth===!1||e.oauth===null||e.oauth===void 0||!Mo(e.oauth))return!1;let t=e.oauth;return!!(typeof t.clientId==`string`&&t.clientId.trim()||typeof t.clientSecret==`string`&&t.clientSecret.trim()||typeof t.scope==`string`&&t.scope.trim()||typeof t.redirectUri==`string`&&t.redirectUri.trim())}function zo(e){let t=e.timeout;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return``}function Bo(e){return`disabled`in e&&e.disabled===!0?!1:`enabled`in e?!!e.enabled:!0}function Vo(e){let t=e.mcpServers;if(Mo(t)){let e=Object.keys(t);if(e.length===1){let n=e[0],r=t[n];if(Mo(r))return{name:n,entry:r}}if(e.length>1)return null}let n=Object.keys(e).filter(t=>{let n=e[t];return t!==`mcpServers`&&Mo(n)});if(n.length===1){let t=n[0],r=e[t];if(Ho(r))return{name:t,entry:r}}return null}function Ho(e){return e.type===`local`||e.type===`remote`||Array.isArray(e.command)||typeof e.url==`string`||Array.isArray(e.args)}function Uo(e,t){let n;try{let t=e.trim();if(!t)return Po(`No JSON content provided`);n=JSON.parse(t)}catch(e){return Po(e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`)}if(!Mo(n))return Po(`Expected a JSON object, not an array or primitive`);let r=n,i=r.mcpServers;if(Mo(i)){let e=Object.keys(i);if(e.length===0)return Po(`mcpServers object is empty`,n);if(e.length>1)return Po(`Paste one server at a time. Found `+e.length+` servers in mcpServers`,n);let t=e[0],r=i[t];return Mo(r)?Fo(t,Wo(r),r):Po(`Server entry is not a valid object`,n)}let a=r.mcp;if(Mo(a)){let e=Object.keys(a);if(e.length===0)return Po(`mcp object is empty`,n);if(e.length>1)return Po(`Paste one server at a time. Found `+e.length+` servers in mcp`,n);let t=e[0],r=a[t];return Mo(r)?Fo(t,Wo(r),r):Po(`Server entry in mcp is not a valid object`,n)}let o=Vo(r);if(o)return Fo(o.name,Wo(o.entry),o.entry);if(Ho(r)){let e=Wo(r);return Fo(typeof r.name==`string`&&r.name.trim()?r.name.trim():t?.fallbackName,e,r)}return Po(`No recognizable MCP server configuration found in JSON`,n)}function Wo(e){return e.type===`remote`?`remote`:e.type===`local`?`local`:typeof e.url==`string`&&e.url.trim()?`remote`:(Array.isArray(e.command)||typeof e.command==`string`||Array.isArray(e.args),`local`)}function Go(e,t,n){let r=n?.isNewServer??!1,i=e.name,a=r&&i?i:t.name??``;return{...t,name:a,type:e.type,command:e.type===`local`?e.command:[],url:e.type===`remote`?e.url:``,environment:e.environment,headers:e.type===`remote`?e.headers:[],oauthEnabled:e.type===`remote`&&e.oauthEnabled,oauthClientId:e.type===`remote`?e.oauthClientId:``,oauthClientSecret:e.type===`remote`?e.oauthClientSecret:``,oauthScope:e.type===`remote`?e.oauthScope:``,oauthRedirectUri:e.type===`remote`?e.oauthRedirectUri:``,timeout:e.type===`remote`?e.timeout:``,enabled:e.enabled}}function Ko(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`'`&&!i){r=!r;continue}if(o===`"`&&!r){i=!i;continue}if((o===` `||o===` `)&&!r&&!i){n&&=(t.push(n),``);continue}n+=o}return n&&t.push(n),t}function qo(e){let t=e.trim();if(!t)return{code:null,context:null,stateKey:null};try{let e=new URL(t),n=e.searchParams.get(`code`);if(typeof n==`string`&&n.trim())return{code:n.trim(),context:Mr(e.searchParams),stateKey:Nr(e.searchParams)}}catch{}return{code:t,context:null,stateKey:null}}var Jo=({value:e,onChange:t,pasteCommandTitle:n,pasteCommandLabel:r,pasteSuccess:i,clipboardReadFailed:a,preview:o})=>{let[s,c]=Q.useState(()=>e.join(`
|
|
3
3
|
`)),l=Q.useRef(e);Q.useEffect(()=>{JSON.stringify(l.current)!==JSON.stringify(e)&&(l.current=e,c(e.join(`
|
|
4
4
|
`)))},[e]);let u=e=>{t(e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{n as l}from"./clipboard-Bu8y4WEC.js";import{t as u}from"./utils-DpGCrB3y.js";import{t as d}from"./SettingsView-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,X as r,Y as i,Z as a,nt as o,rt as s}from"./vendor-base-ui-CnHfUmDN.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{n as l}from"./clipboard-Bu8y4WEC.js";import{t as u}from"./utils-DpGCrB3y.js";import{t as d}from"./SettingsView-C7KsKY0d.js";var f=c(),p=e(s(),1),m=o(),h=e=>{let o=(0,f.c)(19),{open:s,onOpenChange:c}=e,{t:h}=l(),_=p.useId(),v=g,y;o[0]===c?y=o[1]:(y=e=>{!e&&v()||c(e)},o[0]=c,o[1]=y);let b;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(t,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=b):b=o[2];let x;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),o[3]=x):x=o[3];let S;o[4]===h?S=o[5]:(S=h(`settings.window.description`),o[4]=h,o[5]=S);let C;o[6]!==_||o[7]!==S?(C=(0,m.jsx)(a,{id:_,className:`sr-only`,children:S}),o[6]=_,o[7]=S,o[8]=C):C=o[8];let w;o[9]===c?w=o[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),o[9]=c,o[10]=w);let T;o[11]!==_||o[12]!==C||o[13]!==w?(T=(0,m.jsxs)(i,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(r,{"aria-describedby":_,className:x,children:[C,w]})})]}),o[11]=_,o[12]=C,o[13]=w,o[14]=T):T=o[14];let E;return o[15]!==s||o[16]!==y||o[17]!==T?(E=(0,m.jsx)(n,{open:s,onOpenChange:y,children:T}),o[15]=s,o[16]=y,o[17]=T,o[18]=E):E=o[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
|