openpond 0.0.63 → 0.0.64
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/chunks/{app-layer-TUAFALOE.js → app-layer-NCSTDSNQ.js} +2 -2
- package/dist/chunks/{app-server-runtime-O26LVUYH.js → app-server-runtime-XWIG4OWY.js} +6 -6
- package/dist/chunks/{apps-KSZRA7Y2.js → apps-HEG7FEEV.js} +2 -2
- package/dist/chunks/{chunk-66KQLYSH.js → chunk-57XKCMOZ.js} +1 -1
- package/dist/chunks/{chunk-JTFDOA2P.js → chunk-6FZNXLVN.js} +17 -5
- package/dist/chunks/{chunk-IXA5PMXC.js → chunk-BRLUAT6S.js} +1 -1
- package/dist/chunks/{chunk-7IFPXSSJ.js → chunk-C7TOCBGY.js} +1 -1
- package/dist/chunks/{chunk-6FKBOGA4.js → chunk-EWP6VGHP.js} +1 -1
- package/dist/chunks/{chunk-V2CTXKS2.js → chunk-HM6Z3PEC.js} +19 -16
- package/dist/chunks/{chunk-KGU437HZ.js → chunk-JMHOO2IG.js} +2 -2
- package/dist/chunks/{chunk-7UVEB2AZ.js → chunk-THYIAXOB.js} +2 -2
- package/dist/chunks/{chunk-LEL5AQJU.js → chunk-U345JN44.js} +1 -1
- package/dist/chunks/{chunk-YDH34BGG.js → chunk-WT3THPTX.js} +32 -32
- package/dist/chunks/{cli-LPFU4ULD.js → cli-3BI2QBI2.js} +5 -5
- package/dist/chunks/{core-commands-OEOBYFIW.js → core-commands-Y4ZMQXO4.js} +3 -3
- package/dist/chunks/{desktop-test-BRLZF3O7.js → desktop-test-YRFKONLO.js} +2 -2
- package/dist/chunks/{extension-5BUCIDKG.js → extension-4MFKIC6Q.js} +2 -2
- package/dist/chunks/{help-MT6VPW4X.js → help-STXVR4NO.js} +1 -1
- package/dist/chunks/{opchat-O4DVKNFW.js → opchat-CCVKI5GH.js} +2 -2
- package/dist/chunks/{organizations-ACNOJ57Q.js → organizations-AS76SGLP.js} +4 -4
- package/dist/chunks/{profile-7LLWXAJE.js → profile-QNWDNZY3.js} +2 -2
- package/dist/chunks/{project-agent-RVYQYTU2.js → project-agent-GPZL7KAL.js} +2 -2
- package/dist/chunks/{sandbox-command-QST23BX5.js → sandbox-command-LC63MMAA.js} +2 -2
- package/dist/chunks/{sandbox-template-N7UG3P6V.js → sandbox-template-FPQLZ4IP.js} +3 -3
- package/dist/chunks/{src-CPM5Q7T5.js → src-6NIBZPH2.js} +3 -3
- package/dist/chunks/{src-M37V6NVU.js → src-DQFVZZUR.js} +7 -7
- package/dist/chunks/{teams-bot-ITTI47XS.js → teams-bot-YTX7IC2J.js} +2 -2
- package/dist/chunks/{workspaces-CYBR37US.js → workspaces-IXF7MIQV.js} +2 -2
- package/dist/cli.js +13 -13
- package/dist/web/assets/{AppDialog-wIb8mGQ0.js → AppDialog-DacC7BcY.js} +1 -1
- package/dist/web/assets/{AppsView-D097dPIV.js → AppsView-mkeAkrvr.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-DrD-o_yB.js → BrowserSidebar-1aEC6gsF.js} +1 -1
- package/dist/web/assets/{CommandMenu-L5LelA2h.js → CommandMenu-BN6J3ecV.js} +1 -1
- package/dist/web/assets/{CommunityView-DUJ8NryS.js → CommunityView-B2v9Q4cw.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-BP-7DmQG.js → ComposerCreateImproveStrip-BH8Ath1h.js} +1 -1
- package/dist/web/assets/{GetStartedView-B7gB6Hii.js → GetStartedView-B-R-KSva.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-CNDz2a6I.js → LabModelVersionDetailPage-Bhfa7T00.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-BImOQcjk.js → LabSkillSidebar-CbYdG0RN.js} +1 -1
- package/dist/web/assets/{LabsRoute-BauSK1is.js → LabsRoute-DFV5vV6Z.js} +3 -3
- package/dist/web/assets/{MainChatThread-BZvAqQO6.js → MainChatThread-COiXI7ri.js} +2 -2
- package/dist/web/assets/MainPane-CQCLhV5C.js +6 -0
- package/dist/web/assets/MarkdownText-R3MC5S30.js +9 -0
- package/dist/web/assets/{Messages-DijmQL-z.js → Messages-DpZ8mIz8.js} +1 -1
- package/dist/web/assets/{NativeSkillSidebar-aCkrdGa0.js → NativeSkillSidebar-BfcMqLHA.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-D98WIQzr.js → NewProjectDialog-DqTX1Eeo.js} +1 -1
- package/dist/web/assets/{OutputsPage-BA0c6cfy.js → OutputsPage-DfZYswx2.js} +1 -1
- package/dist/web/assets/{RightChatPanelStack-DKDEmrEH.js → RightChatPanelStack-DH8QjiDY.js} +1 -1
- package/dist/web/assets/{ScheduledWorkPage-DeHi99mv.js → ScheduledWorkPage-DkaVUnwj.js} +1 -1
- package/dist/web/assets/SettingsView-BRPrJuP5.css +1 -0
- package/dist/web/assets/SettingsView-StVFsSJ6.js +6 -0
- package/dist/web/assets/{TeamChatView-D2mCoLZ3.js → TeamChatView-CqZOnQh2.js} +1 -1
- package/dist/web/assets/{TerminalOverlay-BHMsVp4L.js → TerminalOverlay-CnFv6FZT.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-CPnMWgkt.js → TrainingCreationPanel-CWzyzmyT.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-0scEtzSW.js → TrainingDraftPanel-BVHx0HZ0.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-COoCLLg6.js → UsageSettingsSection-Bdvm66WK.js} +1 -1
- package/dist/web/assets/{WorkspaceDiffPanel-BFTwZ_dB.js → WorkspaceDiffPanel-DUCjD1GA.js} +5 -5
- package/dist/web/assets/{WorkspaceEnvironmentMenu-DFlkdd9T.js → WorkspaceEnvironmentMenu-DHGrt_ie.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs-Dt3LO27Z.js → WorkspaceGitDialogs-hI57yjPL.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-3g05teoR.js → WorkspaceMonacoEditor-DPv-1uO6.js} +3 -3
- package/dist/web/assets/{arrow-up-right-DYGSWA2J.js → arrow-up-right-BDcNd1rt.js} +1 -1
- package/dist/web/assets/{chevron-up-4qfvI9iW.js → chevron-up-XTMMnfnf.js} +1 -1
- package/dist/web/assets/{cloud-upload-COReKxOy.js → cloud-upload-D6bS8rS2.js} +1 -1
- package/dist/web/assets/{cssMode-BbH67BYF.js → cssMode-CvN9o8bP.js} +1 -1
- package/dist/web/assets/{folder-open-9OjGqNgP.js → folder-open-8C5l7A93.js} +1 -1
- package/dist/web/assets/{folder-plus-DF5E6zr3.js → folder-plus-B9Wqb9yd.js} +1 -1
- package/dist/web/assets/{git-branch-eCwyZXMl.js → git-branch-C45ve7zh.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-cPm51DqY.js → git-commit-horizontal-CGoLIyKK.js} +1 -1
- package/dist/web/assets/{htmlMode-DD6Oge4x.js → htmlMode-DxLP6j5r.js} +1 -1
- package/dist/web/assets/index-BYgrO3wt.js +1 -0
- package/dist/web/assets/index-CHqMtVfF.css +1 -0
- package/dist/web/assets/{index-BO2W2U23.js → index-LrGasYyx.js} +29 -29
- package/dist/web/assets/{info-p1mFpqBI.js → info-DTObFlHw.js} +1 -1
- package/dist/web/assets/{jsonMode-C2Xd56A_.js → jsonMode-C3_fOSJu.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-BjYEk4gJ.js → lspLanguageFeatures-0c-UKStE.js} +1 -1
- package/dist/web/assets/{monaco.contribution-quEPEMQZ.js → monaco.contribution-CF1DgPPC.js} +2 -2
- package/dist/web/assets/{monaco.contribution-C7WMqwmc.js → monaco.contribution-CFLEc9Ly.js} +2 -2
- package/dist/web/assets/{monaco.contribution-Bo-5m7yy.js → monaco.contribution-Cb7KlQ6G.js} +2 -2
- package/dist/web/assets/{monaco.contribution-DzWlEgU1.js → monaco.contribution-Dsug_FPj.js} +2 -2
- package/dist/web/assets/{play-Ctx-iMqd.js → play-Cbsyrwkw.js} +1 -1
- package/dist/web/assets/{python-Cm64qCpk.js → python-DVcVB2lF.js} +1 -1
- package/dist/web/assets/{refresh-cw-Bn28jIl0.js → refresh-cw-ChUK_QfF.js} +1 -1
- package/dist/web/assets/{save-BM5IQX65.js → save-Doep-KC7.js} +1 -1
- package/dist/web/assets/{square-DAGpFfSr.js → square-B5q2aneb.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-DLW8Fnck.js → toggleHighContrast-CTZp7RE7.js} +1 -1
- package/dist/web/assets/{tsMode-BleUN_8S.js → tsMode-GfNadOOB.js} +1 -1
- package/dist/web/assets/{upload-vaAKFfxi.js → upload-DcewuCTa.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-Ccenbqf6.js → useLocalAgentSchedules-BwltnId8.js} +1 -1
- package/dist/web/assets/{wifi-off-DJA9KReb.js → wifi-off-cXPyKIzd.js} +1 -1
- package/dist/web/assets/{workers-CFG-afha.js → workers-CP6kCS63.js} +1 -1
- package/dist/web/assets/{yaml-Cs8iZKVC.js → yaml-w0GP6yKf.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/MainPane-CuhwxMxg.js +0 -6
- package/dist/web/assets/MarkdownText-gwAue4u5.js +0 -9
- package/dist/web/assets/SettingsView--fL3Ecuy.js +0 -6
- package/dist/web/assets/SettingsView-BS5m5vdt.css +0 -1
- package/dist/web/assets/index-BRLugX1S.js +0 -1
- package/dist/web/assets/index-Y7IoiSlQ.css +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-Bdvm66WK.js","./index-LrGasYyx.js","./index-CHqMtVfF.css","./arrow-up-right-BDcNd1rt.js","./index-BYgrO3wt.js","./UsageSettingsSection-O8VK0qBL.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as he,j as e,r,ay as ts,X as ce,az as as,aA as Ts,aB as un,aC as hn,aD as mn,aE as pn,aF as gn,P as fe,aG as Ls,aH as fn,p as M,aI as xn,aJ as Ke,aK as zs,aL as jn,aM as bn,aN as vn,L as Us,u as Le,aO as yn,v as Nn,M as Me,d as Bs,aP as Je,aQ as Be,ah as wn,C as Sn,aR as De,G as Ye,a1 as Cn,i as Oe,aS as re,aT as kn,aU as Qe,aV as Ze,a4 as _s,A as Pn,a2 as Hs,a3 as Rn,as as ds,B as An,a as Fs,aW as Dn,aX as $n,q as En,J as Xe,a8 as _e,aY as ve,ak as In,aZ as Mn,a_ as On,a$ as Tn,$ as Ln,b0 as zn,_ as Un}from"./index-LrGasYyx.js";import{R as oe}from"./refresh-cw-ChUK_QfF.js";import{D as Pe,T as Ne,P as Gs,B as ze,W as Bn,A as _n,C as Hn}from"./MarkdownText-R3MC5S30.js";/* empty css */import{S as ls}from"./save-Doep-KC7.js";import{F as qs}from"./folder-open-8C5l7A93.js";import{C as Fn}from"./chevron-up-XTMMnfnf.js";import{P as Vs}from"./play-Cbsyrwkw.js";import{B as Gn,a as Ws,W as qn,S as Vn}from"./wifi-off-cXPyKIzd.js";import{R as is,u as Wn}from"./useLocalAgentSchedules-BwltnId8.js";import{C as xe}from"./cloud-upload-D6bS8rS2.js";import{G as Te}from"./git-commit-horizontal-CGoLIyKK.js";import{r as Kn}from"./index-BYgrO3wt.js";import{F as Jn}from"./folder-plus-B9Wqb9yd.js";import{A as Yn}from"./AppDialog-DacC7BcY.js";import{C as Ks,W as Qn}from"./WorkspaceDiffPanel-DUCjD1GA.js";import"./training-model-data-V8276E5q.js";import"./info-DTObFlHw.js";const Zn=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],Xn=he("clipboard-copy",Zn);const et=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],st=he("eye",et);const nt=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],tt=he("hard-drive",nt);const at=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],pe=he("key-round",at);const lt=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],it=he("power",lt);const rt=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],Js=he("radio-tower",rt);const ot=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],ct=he("rotate-cw",ot);const dt=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],ut=he("sliders-horizontal",dt);const ht=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],us=he("circle-user",ht);function hs({handle:s,image:n}){const a=s?.trim().slice(0,1).toUpperCase()||"+";return e.jsx("div",{className:"account-avatar",children:n?e.jsx("img",{src:n,alt:""}):e.jsx("span",{children:a})})}function He({state:s,label:n}){return e.jsx("span",{className:`account-state ${s}`,children:n??s.replace("_"," ")})}const es="https://openpond.ai",ss="https://api.openpond.ai";function mt(s,n){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:n?.handle,currentBaseUrl:n?.baseUrl??null}}function ms(s,n){const a=n.trim().replace(/\/+$/,"");if(!a)throw new Error(`${s} is required.`);try{const t=new URL(a);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("unsupported protocol")}catch{throw new Error(`${s} must be an absolute http or https URL.`)}return a}function ps({account:s,busy:n,initialApiKey:a="",mode:t="update",onClose:l,onSave:i}){const c=r.useId(),o=t==="connect",[u,d]=r.useState(a),[f,p]=r.useState(!1),[h,g]=r.useState(s?.baseUrl??es),[x,y]=r.useState(s?.apiBaseUrl??ss),[w,S]=r.useState(null),[C,k]=r.useState(null);ts(C),r.useEffect(()=>{d(a),p(!1),g(s?.baseUrl??es),y(s?.apiBaseUrl??ss),S(null),k(null)},[s?.apiBaseUrl,s?.baseUrl,s?.handle,a]);async function R(b){b.preventDefault(),S(null),k(null);const A=u.trim();if(o&&!A){S("API key is required.");return}let P,B;try{P=ms("Base URL",h),B=ms("API base URL",x)}catch(m){S(m instanceof Error?m.message:String(m));return}try{const m=mt(t,s);await i({...m,baseUrl:P,apiBaseUrl:B,apiKey:o?A:void 0,environment:pt(P,B)})}catch(m){k(m instanceof Error?m.message:String(m))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&!n&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":c,onSubmit:b=>{R(b)},children:[e.jsx("button",{className:"git-dialog-close",disabled:n,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(ce,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:o?e.jsx(pe,{size:18}):e.jsx(as,{size:18})}),e.jsx("h2",{id:c,children:o?"Add account":"Account environment"}),o?e.jsx("p",{children:"Enter your OpenPond API key to connect another account."}):e.jsx("p",{children:"Update the web and API endpoints used by this account."}),o?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoFocus:!0,disabled:n,placeholder:"opk_...",type:"password",value:u,onChange:b=>d(b.target.value)})]}):null,o?e.jsxs("label",{className:"git-dialog-toggle account-dialog-advanced-toggle",children:[e.jsx("input",{checked:f,disabled:n,type:"checkbox",onChange:b=>p(b.target.checked)}),e.jsx("span",{}),"Advanced"]}):null,!o||f?e.jsxs("div",{className:"account-dialog-advanced-fields",children:[e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{autoFocus:!o,disabled:n,inputMode:"url",value:h,onChange:b=>g(b.target.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API base URL"}),e.jsx("input",{disabled:n,inputMode:"url",value:x,onChange:b=>y(b.target.value)})]})]}):null,w?e.jsx("div",{className:"profile-dialog-warning",children:w}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:n,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:n,type:"submit",children:[e.jsx(ls,{size:14}),e.jsx("span",{children:n?"Saving":o?"Connect account":"Update account"})]})]})]})})}function pt(s,n){return s===es&&n===ss?"production":"custom"}const gt="Changing the active OpenPond account rechecks cloud projects, hosted agents, default team, and profile sync for that account. Local projects stay on this machine; projects uploaded from another account will need to be synced again for this account.";function ft({payload:s,connection:n,saving:a,refreshingAccounts:t,saveAccount:l,refreshAccounts:i,switchAccount:c,removeAccount:o,onPayload:u,onPreferences:d,onError:f,onToast:p}){const h=s?.account,g=h?.state??"loading",x=g==="signed_in",y=g==="signed_out",w=g==="auth_error",S=h?.email?.trim()||null,C=h?.accounts??[],[k,R]=r.useState([]),[,b]=r.useState(!1),[A,P]=r.useState(null),[B,m]=r.useState(null),[N,v]=r.useState(null),[j,$]=r.useState(null),[O,G]=r.useState(!1),[Y,ee]=r.useState(null),{confirmAction:E,confirmDialog:L,resolveConfirmDialog:te}=Ts(),Q=C.find(D=>D.isActive)??C[0]??null,J=s?.preferences.defaultTeamId?.trim()||null,Z=N??J,K=un(h),U=s?.accountMeta.asOf??"",ae=ke(h?.environment,Q?.environment),ie=x?ke(Q?.displayLabel,Q?.handle,h?.label,h?.activeProfile?.handle,"Signed in"):w?"Account needs attention":y?"No account connected":"Loading account",ue=x?S??gs(ae):w?"Not connected":y?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",I=C.length>0,z=w?xt(h?.error):null,V=r.useMemo(()=>k.filter(D=>D.status==="active"),[k]),T=(r.useMemo(()=>Z?V.find(D=>D.teamId===Z)??null:null,[V,Z])??hn(V))?.teamId??"",_=r.useMemo(()=>V.map(D=>({value:D.teamId,label:ke(D.displayName,D.name,D.slug,"Team"),description:mn(D.role)})),[V]),F=T||_[0]?.value||"",H=_.length>0,W=!n||!!B||!!A||V.length===0,X=j?Fe(j):null,Ce=!!(X&&Y===X),an=x||w;r.useEffect(()=>{if(!n||!K){R([]),P(null),b(!1);return}let D=!1;const ne=pn(K);return ne?(R(ne),b(!1)):(R([]),b(!0)),P(null),gn({accountKey:K,force:!!U,fetchOrganizations:async()=>(await M.organizations(n)).organizations.map(xn).filter(le=>!!le).filter(le=>le.status==="active")}).then(q=>{D||R(q)}).catch(q=>{D||(ne||R([]),P(q instanceof Error?q.message:String(q)))}).finally(()=>{D||b(!1)}),()=>{D=!0}},[U,n,K]),r.useEffect(()=>{N&&J===N&&v(null)},[J,N]);async function ln(D,ne={notify:!0}){const q=V.find(le=>le.teamId===D)??null;if(!(!n||!q||B||(N??J)===q.teamId)){v(q.teamId),m(q.teamId),f(null),fn({teamId:q.teamId,accountKey:K,force:!0,fetchAgents:async le=>(await M.listSandboxAgents(n,{teamId:le})).agents}).catch(()=>{});try{d(await M.savePreferences(n,{defaultTeamId:q.teamId})),ne.notify&&p?.("Default team updated","success")}catch(le){v(null),f(le instanceof Error?le.message:String(le))}finally{m(null)}}}async function Ue(D="Continue"){return an?E({title:"Change active OpenPond account?",body:gt,confirmLabel:D,cancelLabel:"Cancel"}):!0}async function rn(D){await Ue("Save account")&&(await l({apiKey:D.apiKey??"",handle:D.handle,baseUrl:D.baseUrl,apiBaseUrl:D.apiBaseUrl,environment:D.environment}),G(!1))}async function on(D){if(!n||!j)throw new Error("OpenPond server connection is not ready.");if(j.isActive&&!await Ue("Save endpoints"))return;const ne=Fe(j);ee(ne),f(null);try{const q=await M.updateOpenPondAccountConfig(n,{handle:D.handle??j.handle,currentBaseUrl:D.currentBaseUrl,baseUrl:D.baseUrl,apiBaseUrl:D.apiBaseUrl,chatApiBaseUrl:null,environment:jt(D.environment),setActive:j.isActive});u(q),p?.("Account endpoints updated","success"),$(null)}catch(q){throw f(q instanceof Error?q.message:String(q)),q}finally{ee(null)}}async function cn(D){const ne=D.handle?.trim()||"";ne&&await Ue("Switch account")&&await c(ne,D.baseUrl)}async function dn(D){const ne=D.handle?.trim()||"";if(!ne||D.isActive)return;const q=ke(D.displayLabel,D.email,D.handle,"this account");await E({title:"Remove saved account?",body:`Remove ${q} from this device? Its saved credential and endpoint settings will be deleted. This does not delete any OpenPond cloud data.`,confirmLabel:"Remove account",cancelLabel:"Cancel",tone:"danger"})&&await o(ne,D.baseUrl)&&p?.("Account removed","success")}return e.jsxs("section",{className:"account-settings",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsx("h1",{children:"Account"}),e.jsxs("div",{className:"account-settings-title-actions",children:[e.jsxs("button",{className:"settings-secondary compact account-add-action",disabled:!n||a,type:"button",onClick:()=>G(!0),children:[e.jsx(fe,{size:14}),e.jsx("span",{children:"Add account"})]}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!n||a||t,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{i()},children:e.jsx(oe,{size:15,className:t?"settings-spin":void 0})})]})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(hs,{handle:ie,image:x?h?.avatarUrl??Q?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:ie}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:x&&S?"private-account-email":x?void 0:"account-summary-copy",tabIndex:x&&S?0:void 0,children:ue}),x&&H?e.jsx(Pe,{className:"account-team-dropdown",compact:!0,disabled:W,label:"Default team",options:_,value:F,onChange:D=>{ln(D)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(He,{state:g,label:y?"not signed in":void 0})})]}),I?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"OpenPond accounts"}),e.jsxs("small",{children:[C.length," account",C.length===1?"":"s"]})]}),e.jsx("p",{className:"account-list-note",children:"Switch to another account before removing the active account."}),C.map(D=>{const ne=D.handle?.trim()||"",q=ke(D.displayLabel,D.handle,"Unknown account"),le=D.email?.trim()||null,cs=Fe(D);return e.jsxs("div",{className:"account-row",children:[e.jsx(hs,{handle:q,image:D.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:q}),le?e.jsx("span",{className:"private-account-email",tabIndex:0,children:le}):null,e.jsx("span",{children:gs(D.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(He,{state:D.authHealth}),D.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:"settings-icon-button ghost account-endpoint-action",disabled:!n||a||!!Y||!ne,type:"button","aria-label":`Configure ${q} environment`,title:"Configure account environment",onClick:()=>$(D),children:e.jsx(as,{size:15})}),D.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:a||!ne,type:"button",onClick:()=>{cn(D)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:a||!ne,type:"button","aria-label":`Remove ${q}`,title:`Remove ${q}`,onClick:()=>{dn(D)},children:e.jsx(Ne,{size:13})})]})]})]},cs)})]}):null,h?.products&&h.products.length>0&&e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Products"}),e.jsxs("small",{children:[h.products.length," active"]})]}),h.products.map(D=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:D.name}),e.jsx("span",{children:D.type})]}),e.jsx(He,{state:D.status})]},D.id))]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:s?.server.runtimeVersion??"Runtime loading"}),e.jsx("strong",{children:n?.serverUrl??"loading"})]}),z?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:z})]}):null,j?e.jsx(ps,{account:j,busy:Ce,onClose:()=>{Ce||$(null)},onSave:on}):null,O?e.jsx(ps,{busy:a,mode:"connect",onClose:()=>{a||G(!1)},onSave:rn}):null,e.jsx(Ls,{state:L,onResolve:te})]})}function Fe(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function ke(...s){for(const n of s){const a=n?.trim();if(a)return a}return""}function xt(s){const n=s?.trim();if(!n)return null;const a=n.toLowerCase();return a.includes("protected deployment")||a.includes("vercel_auth_enabled")?"Staging is protected by Vercel. Restart OpenPond after signing in to Vercel, then try again.":a.includes("unexpected token '<'")||a.includes("<!doctype")||a.includes("vercel.com/sso-api")?"OpenPond received a web login page instead of account data. Restart after signing in to Vercel, then try again.":a.includes("401")||a.includes("unauthorized")||a.includes("could not authenticate")?"The API key could not authenticate. Check the key and account environment, then try again.":n.length>220?`${n.slice(0,217)}...`:n}function gs(s){const n=s.trim().toLowerCase();return!n||n==="production"?"Production":"Environment"}function jt(s){const n=s?.trim();return!n||n.toLowerCase()==="production"?"custom":n}function bt({advancedWorkspaceControls:s,defaultBranchPrefix:n,defaultNewProjectDirectory:a,preferences:t,saving:l,chooseDefaultProjectDirectory:i,saveDefaults:c,setAdvancedWorkspaceControls:o,setDefaultBranchPrefix:u,setDefaultNewProjectDirectory:d}){const f=Ke(n)===t.defaultBranchPrefix&&a.trim()===t.defaultNewProjectDirectory&&s===t.advancedWorkspaceControls;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Defaults"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:p=>{c(p)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:p=>o(p.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Show advanced Git controls"}),e.jsx("small",{children:"Show branch, commit, and push controls for local project workflows."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Git branches"}),e.jsx("small",{children:"Used for advanced and non-managed branch creation"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Branch prefix"}),e.jsx("input",{value:n,disabled:l,placeholder:"feat/",onChange:p=>u(p.target.value)})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Projects"}),e.jsx("small",{children:"Used when starting a new local project from scratch"})]}),e.jsxs("div",{className:"settings-path-row",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"New project directory"}),e.jsx("input",{value:a,disabled:l,placeholder:"~/Documents/OpenPond Projects",onChange:p=>d(p.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{i()},children:[e.jsx(qs,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||f,children:e.jsx("span",{children:l?"Saving":"Save defaults"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[Ke(n),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||t.defaultNewProjectDirectory})]})]})}function vt({diagnostics:s,diagnosticsAvailable:n,diagnosticsBusy:a,diagnosticsStatus:t,logDir:l,logLineLimit:i,logLines:c,logViewBusy:o,logViewSummary:u,logViewportRef:d,tailLogs:f,copyRecentLogs:p,exportDiagnosticsBundle:h,loadOlderLogs:g,openLogsFolder:x,refreshLogView:y,toggleTailLogs:w}){const S=s.filter(k=>k.name==="diagnostic"&&k.status==="failed").slice().reverse().map(yt),C=typeof window>"u"?void 0:window.openpond;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Diagnostics"}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Recent errors"}),e.jsxs("small",{children:[S.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:S.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):S.map(k=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(zs,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:k.message}),e.jsx("time",{dateTime:k.timestamp,children:k.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:k.surface}),k.status?e.jsx("span",{children:k.status}):null,k.sequence?e.jsxs("span",{children:["#",k.sequence]}):null]}),k.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:k.detail})]}):null]})]},k.id))})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Logs"}),e.jsx("small",{children:n?"Desktop":"Unavailable"})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Logs folder"}),e.jsx("span",{children:"Desktop and server logs"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!C?.openLogsFolder,onClick:()=>{x()},children:[e.jsx(qs,{size:15}),e.jsx("span",{children:a==="logs"?"Opening":"Open"})]})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Diagnostics export"}),e.jsx("span",{children:"Support folder with diagnostics.txt"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!C?.exportDiagnostics,onClick:()=>{h()},children:[e.jsx(jn,{size:15}),e.jsx("span",{children:a==="export"?"Exporting":"Export"})]})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Recent logs"}),e.jsx("span",{children:"Last 1000 lines to clipboard"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!C?.copyRecentLogs,onClick:()=>{p()},children:[e.jsx(Xn,{size:15}),e.jsx("span",{children:a==="copy"?"Copying":"Copy"})]})]})]}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Log view"}),e.jsxs("div",{className:"settings-heading-actions diagnostics-log-actions",children:[e.jsx("small",{children:u}),e.jsx("button",{type:"button",className:`settings-icon-button ${f?"active":""}`,title:f?"Pause tail":"Tail logs","aria-label":f?"Pause tail":"Tail logs",disabled:!C?.readRecentLogs,onClick:w,children:f?e.jsx(Gs,{size:15}):e.jsx(Vs,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:o!==null||!C?.readRecentLogs,onClick:()=>{y(i,"refresh")},children:e.jsx(oe,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:o!==null||!C?.readRecentLogs,onClick:g,children:[e.jsx(Fn,{size:15}),e.jsx("span",{children:o==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:d,className:"diagnostics-log-viewer",role:"log","aria-live":f?"polite":"off",children:c.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:o?"Loading logs":"No log lines"}):c.map((k,R)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:k.file}),e.jsx("code",{children:k.line})]},`${k.file}:${k.timestamp}:${k.index}:${R}`))}),l&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:l})]})]}),t&&e.jsxs("div",{className:`settings-footnote ${t.warning?"warning":""}`,children:[e.jsx("span",{children:t.label}),e.jsx("strong",{children:t.value})]})]})}function yt(s){const n=fs(s.data),a=fs(n.context),l=ge(n.stack)??ge(n.detail)??ge(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:wt(s.timestamp),message:Nt(s,n),surface:ge(n.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function Nt(s,n){return ge(s.error)??ge(s.output)??ge(n.message)??ge(n.error)??"Diagnostic event"}function wt(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function fs(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function ge(s){return typeof s=="string"&&s.trim()?s.trim():null}const xs=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function St({editorPreferences:s,lspStatus:n,preferences:a,restarting:t,saving:l,statusLoading:i,refreshLspStatus:c,restartLanguageServers:o,saveEditorSettings:u,setEditorPreferences:d,setLanguageCustomCommand:f,setLanguageMode:p}){const h=JSON.stringify(s)!==JSON.stringify(a.editor),g=new Map(n?.languages.map(x=>[x.language,x])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:x=>{u(x)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Language servers"}),e.jsx("small",{children:"Local tools"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Language servers"}),e.jsx(Pe,{value:s.languageServers,disabled:l,label:"Language servers",options:bn,onChange:x=>d(y=>({...y,languageServers:x}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:x=>d(y=>({...y,diagnosticsWhileEditing:x.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Diagnostics while editing"}),e.jsx("small",{children:"Update Monaco markers as the local buffer changes."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.checkOnSave,disabled:l||s.languageServers==="off",onChange:x=>d(y=>({...y,checkOnSave:x.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Check on save"}),e.jsx("small",{children:"Refresh diagnostics after writing a file."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Languages"}),e.jsx("small",{children:"Auto, disabled, or custom executable"})]}),e.jsx("div",{className:"lsp-language-list",children:xs.map(x=>{const y=s.languages[x.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:x.label}),e.jsx("span",{children:js(g.get(x.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Pe,{value:y.mode,disabled:l||s.languageServers==="off",label:`${x.label} language server mode`,options:vn,onChange:w=>p(x.id,w)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:y.customCommand,disabled:l||s.languageServers==="off"||y.mode!=="custom",placeholder:x.placeholder,onChange:w=>f(x.id,w.target.value)})]})]},x.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!h,children:e.jsx("span",{children:l?"Saving":"Save editor settings"})})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"LSP status"}),e.jsxs("div",{className:"settings-heading-actions",children:[e.jsx("small",{children:i?"Checking":n?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:i||t,onClick:()=>{c()},children:e.jsx(oe,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||t,onClick:()=>{o()},children:[e.jsx(ct,{className:t?"settings-spin":void 0,size:15}),e.jsx("span",{children:t?"Restarting":"Restart"})]})]})]}),xs.map(x=>{const y=g.get(x.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:x.label}),e.jsx("span",{title:y?.command??y?.message??void 0,children:y?.command??y?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${y?.status??"missing"}`,children:js(y,i)})]},x.id)})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Project config"}),e.jsx("strong",{children:"Uses tsconfig, pyrightconfig, pyproject, and Cargo files when present"})]})]})}function js(s,n){return n&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function bs({contextCompactionAutoEnabled:s,embedded:n=!1,preferences:a,saving:t,saveDefaults:l,setContextCompactionAutoEnabled:i}){return e.jsxs("section",{className:`account-settings${n?" account-settings-embedded":""}`,children:[n?e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Context"}),e.jsx("small",{children:"Compaction defaults for long chats"})]}):e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:c=>{l(c)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Compaction"}),e.jsx("small",{children:"Controls automatic compaction for long OpenPond and BYOK chats"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:t,onChange:c=>i(c.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Auto compact long chats"}),e.jsx("small",{children:"Summarize older turns at 85% context before the selected model runs out. The transcript stays visible."})]})]}),e.jsx("button",{className:"settings-primary",disabled:t||s===a.contextCompaction.autoEnabled,children:e.jsx("span",{children:t?"Saving":"Save context"})})]})]})}function Ct({subagentsEnabled:s,subagentDelegationMode:n,subagentsUseDefaultModel:a,subagentsProvider:t,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:c,subagentsMaxConcurrentRunsPerProvider:o,subagentsMaxConcurrentRunsPerWorkspaceTarget:u,preferences:d,providers:f,saving:p,saveDefaults:h,changeSubagentsProvider:g,setSubagentsEnabled:x,setSubagentDelegationMode:y,setSubagentsUseDefaultModel:w,setSubagentsModel:S,setSubagentsMaxConcurrentRuns:C,setSubagentsMaxConcurrentRunsPerProvider:k,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:R,setSubagentRoleEnabled:b,setSubagentRoleIsolationMode:A,setSubagentRoleMaxConcurrentRuns:P,setSubagentRoleModel:B,setSubagentRolePeerMessages:m,setSubagentRoleToolPolicy:N,changeSubagentRoleProvider:v}){const j=Us(f,{enabledOnly:!0}),$=a?d.defaultChatProvider:t,O=a?d.defaultChatModel:l,G=Ys(Le($,f),O),Y=a?null:{providerId:t,modelId:l.trim()},ee=Dt({enabled:s,delegationMode:n,defaultModelRef:Y,roles:i,maxConcurrentRuns:c,maxConcurrentRunsPerProvider:o,maxConcurrentRunsPerWorkspaceTarget:u},d);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:E=>{h(E)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Agents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${ee?"":" dirty"}`,disabled:p||ee,children:e.jsx("span",{children:p?"Saving":"Save agents"})}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":"Allow subagents",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:p,onChange:E=>x(E.target.checked)}),e.jsx("span",{})]})]})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Default delegation"}),e.jsx("small",{children:"Used unless a task overrides it from the composer."})]})}),e.jsx("div",{className:"subagent-field-grid two",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Subagent use"}),e.jsxs("select",{value:n,disabled:p||!s,onChange:E=>y(E.target.value),children:[e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"balanced",children:"Balanced"}),e.jsx("option",{value:"proactive",children:"Proactive"})]})]})})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsx("div",{children:e.jsx("span",{children:"Default model"})})}),e.jsxs("div",{className:"subagent-field-grid two",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Provider"}),e.jsx("select",{value:$,disabled:p||!s,onChange:E=>{w(!1),g(E.target.value)},children:j.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:O,disabled:p||!s,onChange:E=>{w(!1),S(E.target.value)},children:G.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map(E=>{const L=yn.find(U=>U.id===E.id),te=E.modelRef?.providerId??$,Q=E.modelRef?.modelId||Nn(te,f)||O,J=At(j,f,{providerId:te,modelId:Q}),Z=Ie(te,Q),K=p||!s||!E.enabled;return e.jsxs("section",{className:`subagent-role-row${E.enabled?"":" disabled"}`,children:[e.jsxs("div",{className:"subagent-settings-card-header subagent-role-header",children:[e.jsxs("div",{className:"subagent-role-title",children:[e.jsx("span",{children:L?.label??E.id}),e.jsx("small",{children:L?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${L?.label??E.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:E.enabled,disabled:p||!s,onChange:U=>b(E.id,U.target.checked)}),e.jsx("span",{})]})]}),e.jsxs("div",{className:"subagent-role-controls",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:Z,disabled:K,onChange:U=>{const ae=J.find(ie=>ie.value===U.target.value);ae&&(v(E.id,ae.providerId),B(E.id,ae.modelId))},children:J.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:E.isolationMode,disabled:K,onChange:U=>A(E.id,U.target.value),children:kt.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:E.toolPolicy,disabled:K,onChange:U=>N(E.id,U.target.value),children:Pt.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:E.peerMessages,disabled:K,onChange:U=>m(E.id,U.target.value),children:Rt.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]})]}),e.jsx("div",{className:"subagent-role-budget-grid",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Role concurrency"}),e.jsx("input",{type:"number",min:1,max:16,value:E.maxConcurrentRuns,disabled:K,onChange:U=>P(E.id,vs(U.target.value,1))})]})})]},E.id)})}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Limits"}),e.jsx("small",{children:"Controls child worker concurrency."})]})}),e.jsxs("div",{className:"subagent-field-grid four",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Total concurrency"}),e.jsx("input",{type:"number",min:1,max:32,value:c,disabled:p||!s,onChange:E=>C(vs(E.target.value,1))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per provider"}),e.jsx("input",{type:"number",min:1,max:32,value:o??"",placeholder:"No cap",disabled:p||!s,onChange:E=>k(ns(E.target.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per workspace"}),e.jsx("input",{type:"number",min:1,max:32,value:u??"",placeholder:"No cap",disabled:p||!s,onChange:E=>R(ns(E.target.value))})]})]})]})]})})}const kt=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],Pt=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],Rt=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function Ys(s,n){const a=n.trim();return!a||s.some(t=>t.value===a)?s:[{value:a,label:a},...s]}function Ie(s,n){return JSON.stringify([s,n])}function At(s,n,a){const t=[];for(const l of s){const i=Ys(Le(l.value,n),l.value===a.providerId?a.modelId:"");for(const c of i)t.push({value:Ie(l.value,c.value),label:`${l.label} / ${c.label}`,providerId:l.value,modelId:c.value})}return a.modelId&&!t.some(l=>l.value===Ie(a.providerId,a.modelId))&&t.unshift({value:Ie(a.providerId,a.modelId),label:`${Me(a.providerId,n)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),t}function ns(s){const n=s.trim();if(!n)return null;const a=Number(n);return Number.isFinite(a)?a:null}function vs(s,n){return ns(s)??n}function Dt(s,n){const a=n.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&$t(s.defaultModelRef,a.defaultModelRef)&&s.maxConcurrentRuns===a.maxConcurrentRuns&&s.maxConcurrentRunsPerProvider===a.maxConcurrentRunsPerProvider&&s.maxConcurrentRunsPerWorkspaceTarget===a.maxConcurrentRunsPerWorkspaceTarget&&JSON.stringify(s.roles)===JSON.stringify(a.roles)}function $t(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const Et=[{mode:"all",label:"All new messages",detail:"Show an in-app alert for every Team Chat message."},{mode:"direct_mentions",label:"Direct messages and mentions",detail:"Show alerts for direct messages and messages that mention you."},{mode:"none",label:"Nothing",detail:"Keep unread counts without showing message alerts."}];function It({currentUserId:s,enabled:n,mode:a,threads:t,onModeChange:l,onThreadMuteChange:i}){const[c,o]=r.useState(null),[u,d]=r.useState(null);ts(u);const f=r.useMemo(()=>t.filter(g=>g.archivedAt===null).map(g=>({thread:g,label:Mt(g,s)})).sort((g,x)=>{const y=+!!x.thread.mutedAt-+!!g.thread.mutedAt;return y!==0?y:g.label.localeCompare(x.label)}),[s,t]),p=f.filter(({thread:g})=>!!g.mutedAt).length,h=r.useCallback(async g=>{o(g.id),d(null),await i(g.id,!g.mutedAt)||d("Could not update this conversation. Try again."),o(null)},[i]);return e.jsxs("section",{className:"account-settings notifications-settings",children:[e.jsx("h1",{children:"Notifications"}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Team chat notifications"}),e.jsx("small",{children:"In-app alerts"})]}),e.jsx("div",{className:"notification-mode-list",role:"radiogroup","aria-label":"Notify me about",children:Et.map(g=>e.jsxs("label",{className:`notification-mode-option${a===g.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===g.mode,onChange:()=>l(g.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:g.label}),e.jsx("small",{children:g.detail})]})]},g.mode))})]}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Conversation overrides"}),e.jsx("small",{children:p===1?"1 muted":`${p} muted`})]}),n?f.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):f.map(({thread:g,label:x})=>{const y=!!g.mutedAt,w=c===g.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${y?" muted":""}`,children:y?e.jsx(Gn,{size:15}):e.jsx(Ws,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:x}),e.jsx("small",{children:y?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:c!==null,onClick:()=>{h(g)},children:w?"Saving":y?"Unmute":"Mute"})]},g.id)}):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Connect a team to manage conversation overrides."})})]}),e.jsx("div",{className:"settings-footnote",children:e.jsx("span",{children:"Muted conversations never show alerts. Unread counts remain available."})})]})}function Mt(s,n){return s.kind==="general"||s.kind==="channel"?`#${s.title?.trim()||"general"}`:s.kind==="dm"?s.participants.find(a=>a.userId!==n)?.name??s.title?.trim()??"Direct message":s.title?.trim()||s.participants.filter(a=>a.userId!==n).map(a=>a.name).join(", ")||"Group conversation"}function Ot({canSaveCurrentTemplate:s,personalizationTemplateId:n,personalizationTemplateOptions:a,saveAsNewOpen:t,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:c,soulDraft:o,templateNameDraft:u,changePersonalizationTemplate:d,changeSoulDraft:f,openSaveAsNew:p,resetPersonalizationDraft:h,savePersonalization:g,setSaveAsNewOpen:x,setTemplateNameDraft:y}){function w(S){S.preventDefault(),g(t)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:w,children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agent style"}),e.jsx("div",{className:"settings-heading-actions",children:t?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"settings-heading-input",value:u,onChange:S=>y(S.target.value),placeholder:"Name","aria-label":"Template name"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Cancel","aria-label":"Cancel",disabled:l,onClick:()=>x(!1),children:e.jsx(ce,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!o.trim()||!u.trim(),onClick:()=>{g(!0)},children:e.jsx(Bs,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:c?"Custom template":"Built-in template"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Save as new","aria-label":"Save as new",disabled:l||!i||!o.trim(),onClick:p,children:e.jsx(fe,{size:15})})]})})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Template"}),e.jsx(Pe,{value:n,disabled:l||a.length===0,label:"Personalization template",options:a,onChange:S=>{d(S)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:o,onChange:S=>f(S.target.value),spellCheck:!1})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Reset to template","aria-label":"Reset to template",disabled:l||!i,onClick:h,children:e.jsx(is,{size:15})}),c&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(ls,{size:15})})]})]})]})}function Tt({connection:s,profile:n,selectedDefaultTeamId:a}){const t=Wn(s),l=Ut(t.schedules);return ts(t.error,{prefix:"Local schedules"}),e.jsxs("div",{className:"account-list profile-agent-list","aria-label":"Profile agents",children:[e.jsx("div",{className:"account-list-heading profile-agent-list-heading",children:e.jsx("span",{children:"Agents"})}),e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-agent-table","aria-label":"Profile agents table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-agent-column"}),e.jsx("col",{className:"profile-action-column"}),e.jsx("col",{className:"profile-check-column"}),e.jsx("col",{className:"profile-sync-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Agent"}),e.jsx("th",{scope:"col",children:"Action"}),e.jsx("th",{scope:"col",children:"Check"}),e.jsx("th",{scope:"col",children:"Sync"})]})}),e.jsxs("tbody",{children:[l.active.map(i=>e.jsx(ys,{pending:t.pendingScheduleIds.has(i.id),schedule:i,refreshing:t.loading,onRefresh:()=>{t.refresh()},onRun:()=>{t.run(i)},onToggle:()=>{t.toggle(i)}},i.id)),e.jsx(Lt,{}),n.agents.map(i=>e.jsx(zt,{agent:i,defaultAction:n.summary.defaultAction,profile:n,selectedDefaultTeamId:a},i.id)),l.paused.map(i=>e.jsx(ys,{pending:t.pendingScheduleIds.has(i.id),schedule:i,refreshing:t.loading,onRefresh:()=>{t.refresh()},onRun:()=>{t.run(i)},onToggle:()=>{t.toggle(i)}},i.id))]})]})})]})}function Lt(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(ze,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:"Dataset Builder"}),e.jsx("span",{children:"Built in · every Profile"})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:"Design · Materialize · Test"})})}),e.jsx("td",{children:e.jsx(Re,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx(Re,{status:{state:"ready",label:"Built in"}})})]})}function zt({agent:s,defaultAction:n,profile:a,selectedDefaultTeamId:t}){const l=Ht(a,s,t);return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(ze,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsx("span",{title:s.path,children:s.path})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:n??"None"})})}),e.jsx("td",{children:e.jsx(Re,{status:l.check})}),e.jsx("td",{children:e.jsx(Re,{status:l.sync})})]})}function ys({pending:s,refreshing:n,schedule:a,onRefresh:t,onRun:l,onToggle:i}){const c=Bt(a),o=a.enabled?"Pause schedule":"Resume schedule";return e.jsxs("tr",{className:"profile-agent-row profile-schedule-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(ze,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.localProjectName}),e.jsxs("span",{title:a.scheduleName,children:["schedule: ",a.scheduleName]})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{title:a.targetAction,children:a.targetAction})})}),e.jsx("td",{children:e.jsx(Re,{status:c})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:_t(a),children:a.enabled?a.scheduleExpression:"Paused"}),e.jsxs("div",{className:"profile-schedule-controls","aria-label":`${a.scheduleName} schedule controls`,children:[e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:n,type:"button",title:"Refresh local schedules","aria-label":"Refresh local schedules",onClick:t,children:e.jsx(oe,{size:14,className:n?"settings-spin":void 0})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:"Run now","aria-label":`Run ${a.scheduleName} now`,onClick:l,children:e.jsx(is,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:o,"aria-label":`${o}: ${a.scheduleName}`,onClick:i,children:a.enabled?e.jsx(Gs,{size:14}):e.jsx(Vs,{size:14})})]})]})})]})}function Re({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function Ut(s){const n=[],a=[];for(const t of s)t.enabled?n.push(t):a.push(t);return n.sort((t,l)=>Ns(t)-Ns(l)),{active:n,paused:a}}function Ns(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function Bt(s){return s.enabled?s.lastError||s.lastRunStatus==="failed"?{state:"warning",label:"Failed"}:s.lastRunStatus==="running"?{state:"loading",label:"Running"}:s.lastRunStatus==="queued"?{state:"loading",label:"Queued"}:s.lastRunStatus==="skipped"?{state:"warning",label:"Skipped"}:s.lastRunStatus==="succeeded"?{state:"ready",label:"Succeeded"}:{state:"loading",label:"Scheduled"}:{state:"disabled",label:"Paused"}}function _t(s){const n=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&n.push(`next ${ws(s.nextRunAt)}`),s.lastRunAt&&n.push(`last ${ws(s.lastRunAt)}`),n.join(" - ")}function ws(s){const n=new Date(s);return Number.isFinite(n.getTime())?n.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):s}function Ht(s,n,a){if(!n.enabled)return{check:{state:"disabled",label:"Disabled"},sync:{state:"disabled",label:"Disabled"}};if(s.error)return{check:{state:"warning",label:"Error"},sync:{state:"warning",label:"Blocked"}};if(s.setupGate.blockingCount>0)return{check:{state:"warning",label:"Setup"},sync:{state:"warning",label:"Blocked"}};if(s.git?.dirty||Gt(s,n)>0)return{check:{state:"loading",label:"Pending"},sync:{state:"warning",label:"Changed"}};if(s.catalog.stale)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(!s.lastCheck)return{check:{state:"loading",label:"Unchecked"},sync:{state:"loading",label:"Waiting"}};if(s.lastCheck.status==="failed")return{check:{state:"warning",label:"Failed"},sync:{state:"warning",label:"Blocked"}};if(!s.summary.checkFresh)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(Ft(s,a))return{check:{state:"ready",label:"Passed"},sync:{state:"warning",label:"Sync acct"}};const t=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null;return!(s.summary.hostedHead??s.hosted?.sourceCommitSha??null)&&!l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Not synced"}}:t&&l&&t!==l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Needed"}}:{check:{state:"ready",label:"Passed"},sync:{state:"ready",label:"Synced"}}}function Ft(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}function Gt(s,n){let a=0;s.diff.changedAgents.includes(n.id)&&(a+=1),s.diff.newAgents.includes(n.id)&&(a+=1),s.diff.deletedAgents.includes(n.id)&&(a+=1);const t=n.path.replace(/^profiles\/[^/]+\//,"");for(const l of s.diff.files){const i=l.path.replace(/^profiles\/[^/]+\//,"");(i===t||i.startsWith(`${t}/`)||i.startsWith(`agents/${n.id}/`))&&(a+=1)}return a}function qt({actions:s,busy:n,library:a,onSelect:t}){const l=a.profiles.find(c=>Je(c.ref,a.lastUsed))??a.profiles[0]??null,i=l?Be(l.ref):"";return e.jsxs("div",{className:"profile-selector-bar",children:[e.jsxs("label",{className:"profile-selector-control",children:[e.jsx("select",{"aria-label":"Active profile",disabled:n||a.profiles.length===0,value:i,onChange:c=>{const o=wn(a,c.currentTarget.value),u=a.profiles.find(d=>Je(d.ref,o));u&&t(u)},children:a.profiles.length?a.profiles.map(c=>e.jsx("option",{value:Be(c.ref),children:c.name},Be(c.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Sn,{"aria-hidden":"true",size:14})]}),s]})}function Vt({addDisabled:s,commitDisabled:n,commitLabel:a,refreshDisabled:t,repoDisabled:l,syncDisabled:i,syncLabel:c,syncStatus:o,onAdd:u,onCommit:d,onRefresh:f,onRepo:p,onSync:h}){const[g,x]=r.useState(!1),y=r.useRef(null);r.useEffect(()=>{if(!g)return;function S(k){y.current?.contains(k.target)||x(!1)}function C(k){k.key==="Escape"&&x(!1)}return document.addEventListener("pointerdown",S),document.addEventListener("keydown",C),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",C)}},[g]);function w(S){x(!1),S()}return e.jsx("div",{className:"profile-selector-actions",children:e.jsxs("div",{className:"profile-settings-menu-root",ref:y,children:[e.jsx("button",{"aria-expanded":g,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>x(S=>!S),children:e.jsx(as,{size:15})}),g?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>w(d),children:[e.jsx(Te,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>w(h),children:[e.jsx(xe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:c}),o?e.jsx("small",{children:o}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>w(p),children:[e.jsx(De,{size:14}),e.jsx("span",{children:"Repository"})]}),e.jsx("div",{className:"profile-settings-menu-separator",role:"separator"}),e.jsxs("button",{disabled:t,role:"menuitem",type:"button",onClick:()=>w(f),children:[e.jsx(oe,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>w(u),children:[e.jsx(fe,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const Wt=[{id:"actions",label:"Actions",detail:"Profile-level reusable actions"},{id:"prompts",label:"Prompts",detail:"Shared prompt files"},{id:"goals",label:"Goals",detail:"Goal definitions; never started automatically"},{id:"evals",label:"Evals",detail:"Evaluation definitions and fixtures"},{id:"examples",label:"Examples",detail:"Example inputs and usage"},{id:"tasksets",label:"Tasksets",detail:"Training and evaluation tasksets"},{id:"extensions",label:"Extension declarations",detail:"Third-party extension metadata"}];function Kt({connection:s,entry:n,onClose:a,onPublished:t}){const[l,i]=r.useState("github"),[c,o]=r.useState(""),[u,d]=r.useState(`${n.name}-profile`),[f,p]=r.useState("public"),[h,g]=r.useState(()=>n.state.agents.filter(j=>j.enabled).map(j=>j.id)),[x,y]=r.useState(()=>n.state.skills.filter(j=>j.enabled).map(j=>j.name)),[w,S]=r.useState([]),[C,k]=r.useState(null),[R,b]=r.useState(null),[A,P]=r.useState(null),B=r.useMemo(()=>({ref:n.ref,selection:{agentIds:h,skillNames:x,optionalContent:w},target:{provider:l,owner:c.trim()||null,repository:u.trim(),visibility:l==="github"?"public":f}}),[h,n.ref,w,c,l,u,x,f]);function m(j,$,O){return O?[...new Set([...j,$])]:j.filter(G=>G!==$)}async function N(j){if(j.preventDefault(),!(!u.trim()||R)){b("preview"),P(null);try{k(await M.profilePublicationPreview(s,B))}catch($){P($ instanceof Error?$.message:String($))}finally{b(null)}}}async function v(){if(!(!C||C.blockedReasons.length>0||R)){b("publish"),P(null);try{const j=await M.profilePublicationPublish(s,{...B,expectedSourceHash:C.sourceHash,confirmed:!0});t(`Published ${n.name} to ${j.owner}/${j.repository}`),a()}catch(j){P(j instanceof Error?j.message:String(j))}finally{b(null)}}}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("form",{className:"git-dialog profile-publication-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-publication-title",onMouseDown:j=>j.stopPropagation(),onSubmit:N,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!R,type:"button","aria-label":"Close",onClick:a,children:e.jsx(ce,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(xe,{size:18})}),e.jsxs("h2",{id:"profile-publication-title",children:["Publish ",n.name]}),e.jsx("p",{children:"Choose the exact Agents, Skills, and optional files to share. OpenPond will show the complete file list before it pushes anything."}),C?e.jsx(Jt,{preview:C}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:"Destination"}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:l==="github",onChange:()=>{i("github"),p("public")}}),e.jsx(Ye,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"GitHub"}),e.jsx("small",{children:"Published publicly with your signed-in gh CLI"})]})]}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:l==="openpond_git",onChange:()=>{i("openpond_git"),p("private")}}),e.jsx(Cn,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"OpenPond Git"}),e.jsx("small",{children:"Private by default; uses the same repository format"})]})]})]}),e.jsxs("div",{className:"profile-publication-target-fields",children:[l==="github"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"GitHub owner (optional)"}),e.jsx("input",{value:c,placeholder:"Uses gh account",onChange:j=>o(j.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:u,onChange:j=>d(j.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:f,onChange:j=>p(j.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(Ge,{title:"Agents",empty:"No Agents in this Profile",children:n.state.agents.map(j=>e.jsx(qe,{checked:h.includes(j.id),label:j.name,detail:j.path,onChange:$=>g(O=>m(O,j.id,$))},j.id))}),e.jsx(Ge,{title:"Skills",empty:"No Skills in this Profile",children:n.state.skills.map(j=>e.jsx(qe,{checked:x.includes(j.name),label:j.name,detail:j.description||j.path,onChange:$=>y(O=>m(O,j.name,$))},j.name))}),e.jsx(Ge,{title:"Optional content",empty:"",children:Wt.map(j=>e.jsx(qe,{checked:w.includes(j.id),label:j.label,detail:j.detail,onChange:$=>S(O=>m(O,j.id,$))},j.id))})]}),A?e.jsx("div",{className:"profile-dialog-warning",children:A}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!R,type:"button",onClick:C?()=>k(null):a,children:C?"Back":"Cancel"}),C?e.jsxs("button",{className:"git-dialog-primary",disabled:!!R||C.blockedReasons.length>0,type:"button",onClick:()=>{v()},children:[e.jsx(xe,{size:14}),e.jsx("span",{children:R==="publish"?"Publishing":C.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!R||!u.trim(),type:"submit",children:R==="preview"?"Building preview":"Review exact files"})]})]})})}function Ge({title:s,empty:n,children:a}){const t=Array.isArray(a)?a.length:a?1:0;return e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:s}),t?a:e.jsx("span",{className:"profile-publication-empty",children:n})]})}function qe({checked:s,label:n,detail:a,onChange:t}){return e.jsxs("label",{className:"profile-publication-selection",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:l=>t(l.currentTarget.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:n}),e.jsx("small",{children:a})]})]})}function Jt({preview:s}){const n=s.files.reduce((a,t)=>a+t.sizeBytes,0);return e.jsxs("div",{className:"profile-publication-preview",children:[e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[s.files.length," files · ",Ss(n)]}),e.jsx("span",{children:s.sourceRevision?.slice(0,10)??"No source revision"})]}),s.blockedReasons.map(a=>e.jsx("div",{className:"profile-dialog-warning",children:a},a)),s.warnings.map(a=>e.jsx("div",{className:"profile-publication-warning",children:a},a)),e.jsx("div",{className:"profile-publication-file-list","aria-label":"Exact files to publish",children:s.files.map(a=>e.jsxs("div",{children:[e.jsx("span",{title:a.path,children:a.path}),e.jsxs("small",{children:[a.category," · ",Ss(a.sizeBytes)]})]},a.path))}),s.excludedFiles.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[s.excludedFiles.length," excluded sensitive/runtime files"]}),s.excludedFiles.map(a=>e.jsx("code",{children:a},a))]}):null]})}function Ss(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function Yt({section:s="all",catalogPresentation:n="list",payload:a,connection:t,onPayload:l,onError:i,onToast:c,onSkillCommand:o,overviewContent:u}){const[d,f]=r.useState(""),[p,h]=r.useState(null),[g,x]=r.useState(!1),[y,w]=r.useState(null),[S,C]=r.useState(null),k=a?.profile??null,R=a?.preferences.defaultTeamId?.trim()||"",b=s==="all"||s==="profile"||s==="controls",A=s==="all"||s==="profile",P=s==="all"||s==="agents",B=s==="all"||s==="profile";async function m(L){t&&(l(await M.bootstrap(t)),c?.(L,"success"))}async function N(L,te){if(!(!t||p)){h(L),i(null);try{await te()}catch(Q){i(Q instanceof Error?Q.message:String(Q))}finally{h(null)}}}function v(){N("init",async()=>{await M.profileInit(t,{}),await m("Profile initialized")})}function j(){N("commit",async()=>{await M.profileCommit(t,{message:d.trim()||null}),f(""),await m("Profile commit complete")})}function $(){N("push",async()=>{if(!R)throw new Error("Select a default team before syncing a hosted profile.");await M.profileCheck(t,{kind:"all"}),await M.profilePush(t,{teamId:R,ensureHosted:!0,message:null}),await m("Profile synced to hosted profile repo")})}function O(L){N(`select:${L.ref.profileId}`,async()=>{await M.profileSelect(t,L.ref),await m(`Using ${L.name}`)})}function G(L){N("add",async()=>{L.source==="blank"?await M.profileInit(t,{path:L.path,profile:L.profile,template:"blank-profile"}):L.source==="local"?await M.profileLoad(t,L):await M.profileInstall(t,L),x(!1),await m(L.source==="blank"?`${L.profile} created`:"Profile added")})}function Y(L){N("update",async()=>{await M.profileUpdate(t,L.ref),await m(`${L.name} updated`)})}function ee(L){N("remove",async()=>{await M.profileRemove(t,L.ref),w(null),await m("Profile removed from this device")})}function E(){N("refresh",async()=>{await m("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[k?.mode==="local"?e.jsxs(e.Fragment,{children:[b?e.jsxs(e.Fragment,{children:[A&&n==="select"?e.jsx(qt,{actions:e.jsx(Cs,{connection:t,onAdd:()=>x(!0),onRefresh:E,presentation:"menu",profile:k,profileBusy:p,profileCommitMessage:d,selectedDefaultTeamId:R,syncDisabledReason:ks(k,R),setProfileCommitMessage:f,submitProfileCommit:j,submitProfilePush:$}),busy:!!p,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:O}):e.jsxs(e.Fragment,{children:[A?e.jsx(Qt,{busy:!!p,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>x(!0),onRefresh:E,onRemove:w,onPublish:C,onUpdate:Y,onSelect:O}):null,e.jsx(Cs,{connection:t,profile:k,profileBusy:p,profileCommitMessage:d,selectedDefaultTeamId:R,syncDisabledReason:ks(k,R),setProfileCommitMessage:f,submitProfileCommit:j,submitProfilePush:$})]}),u]}):null,P?e.jsx(Tt,{connection:t,profile:k,selectedDefaultTeamId:R}):null,B?e.jsx(ta,{onSkillCommand:o,profile:k}):null]}):s==="agents"?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agents"}),e.jsx("small",{children:"Profile required"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Open Profile to create or load a Profile before managing agents."})]})]}):e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Summary"}),e.jsx("small",{children:"Not loaded"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Create an empty Profile, start with an Agent template, or add an existing repository."}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!!p,type:"button",onClick:()=>x(!0),children:[e.jsx(fe,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!!p,type:"button",onClick:v,children:[e.jsx(fe,{size:14}),e.jsx("span",{children:p==="init"?"Creating":"Create starter Profile"})]})]})]}),g?e.jsx(Zt,{busy:!!p,onClose:()=>x(!1),onSubmit:G}):null,y?e.jsx(Xt,{busy:!!p,entry:y,onClose:()=>w(null),onConfirm:()=>ee(y)}):null,S&&t?e.jsx(Kt,{connection:t,entry:S,onClose:()=>C(null),onPublished:L=>c?.(L,"success")}):null]})}function Qt({busy:s,library:n,onAdd:a,onRefresh:t,onRemove:l,onPublish:i,onSelect:c,onUpdate:o}){return e.jsxs("div",{className:"account-list profile-catalog-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Profiles"}),e.jsxs("div",{className:"profile-skill-heading-actions",children:[e.jsxs("small",{children:[n.profiles.length," installed"]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:t,children:[e.jsx(oe,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(fe,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),n.profiles.map(u=>{const d=Je(u.ref,n.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${d?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||c(u)},onKeyDown:f=>{s||f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),c(u))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(De,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:u.name}),e.jsx("span",{title:u.repoPath,children:u.repoPath})]})]}),e.jsx(Qs,{status:{state:u.state.error?"warning":"ready",label:u.state.error?"error":d?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:u.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:u.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[u.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:f=>{f.stopPropagation(),o(u)},onKeyDown:f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),f.stopPropagation(),o(u))},children:[e.jsx(oe,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:f=>{f.stopPropagation(),i(u)},onKeyDown:f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),f.stopPropagation(),i(u))},children:[e.jsx(xe,{size:14}),e.jsx("span",{children:"Publish"})]}),e.jsxs("span",{className:"settings-secondary compact profile-remove-button",role:"button",tabIndex:0,"aria-label":`Remove ${u.name}`,onClick:f=>{f.stopPropagation(),l(u)},onKeyDown:f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),f.stopPropagation(),l(u))},children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${u.ref.source}:${u.ref.repositoryId}:${u.ref.profileId}`)})]})}function Zt({busy:s,onClose:n,onSubmit:a}){const[t,l]=r.useState("blank"),[i,c]=r.useState(""),[o,u]=r.useState(""),[d,f]=r.useState("");function p(h){if(h.preventDefault(),s)return;if(t==="blank"){const x=d.trim();if(!x)return;a({source:t,path:i.trim()||null,profile:x});return}if(t==="local"){const x=i.trim();if(!x)return;a({source:t,path:x,profile:d.trim()||null});return}const g=o.trim();g&&a({source:t,repositoryId:g,profile:d.trim()||null})}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:n,children:e.jsxs("form",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"add-profile-title",onMouseDown:h=>h.stopPropagation(),onSubmit:p,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:n,children:e.jsx(ce,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(De,{size:18})}),e.jsx("h2",{id:"add-profile-title",children:"Add Profile"}),e.jsx("p",{children:"Create a blank Profile, add a local repository, or install a shareable Profile from Git."}),e.jsxs("div",{className:"profile-add-source-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t==="blank",onChange:()=>l("blank")}),"New blank"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t==="local",onChange:()=>l("local")}),"Local"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t==="github",onChange:()=>l("github")}),"GitHub"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t==="openpond_git",onChange:()=>l("openpond_git")}),"OpenPond Git"]})]}),t==="blank"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path (optional)"}),e.jsx("input",{disabled:s,value:i,placeholder:"Uses the default local Profile repository",onChange:h=>c(h.currentTarget.value)})]}):t==="local"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path"}),e.jsx("input",{autoFocus:!0,disabled:s,value:i,placeholder:"/path/to/profile-repo",onChange:h=>c(h.currentTarget.value)})]}):e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:[t==="github"?"GitHub":"OpenPond Git"," repository"]}),e.jsx("input",{autoFocus:!0,disabled:s,value:o,placeholder:"owner/repository",onChange:h=>u(h.currentTarget.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:t==="blank"?"Profile name":"Profile name (optional)"}),e.jsx("input",{autoFocus:t==="blank",disabled:s,value:d,placeholder:t==="blank"?"research":"Uses repository default",onChange:h=>f(h.currentTarget.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:n,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:s||!(t==="blank"?d:t==="local"?i:o).trim(),type:"submit",children:t==="blank"?"Create Profile":"Add Profile"})]})]})})}function Xt({busy:s,entry:n,onClose:a,onConfirm:t}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"remove-profile-title",onMouseDown:l=>l.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:a,children:e.jsx(ce,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Ne,{size:18})}),e.jsxs("h2",{id:"remove-profile-title",children:["Remove ",n.name,"?"]}),e.jsx("p",{children:"This removes the Profile from OpenPond on this device. It does not delete the repository or any source files."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:n.name}),e.jsx("span",{children:n.repoPath})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:a,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary danger",disabled:s,type:"button",onClick:t,children:"Remove"})]})]})})}function Cs({connection:s,onAdd:n,onRefresh:a,presentation:t="toolbar",profile:l,profileBusy:i,profileCommitMessage:c,selectedDefaultTeamId:o,syncDisabledReason:u,setProfileCommitMessage:d,submitProfileCommit:f,submitProfilePush:p}){const[h,g]=r.useState(!1),[x,y]=r.useState(!1),[w,S]=r.useState(!1),C=!s||!!i;return e.jsxs(e.Fragment,{children:[t==="menu"&&n&&a?e.jsx(Vt,{addDisabled:!!i,commitDisabled:C,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:C,repoDisabled:!!i||!l,syncDisabled:C||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?Ve(l,o):null,onAdd:n,onCommit:()=>y(!0),onRefresh:a,onRepo:()=>g(!0),onSync:()=>S(!0)}):e.jsx("div",{className:"profile-control-panel",children:e.jsxs("div",{className:"profile-control-toolbar",children:[e.jsxs("div",{className:"profile-control-actions",children:[e.jsxs("button",{className:"settings-secondary",disabled:C,type:"button",onClick:()=>y(!0),children:[e.jsx(Te,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:C||!l,type:"button",onClick:()=>S(!0),children:[e.jsx(xe,{size:14}),e.jsx("span",{children:i==="push"?"Syncing":"Sync"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!!i||!l,type:"button",onClick:()=>g(!0),children:[e.jsx(De,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${Ve(l,o)}`,children:[e.jsx(xe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:Ve(l,o)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),h&&l?e.jsx(na,{profile:l,profileBusy:i,onClose:()=>g(!1)}):null,x?e.jsx(ea,{disabled:C,profileBusy:i,profileCommitMessage:c,setProfileCommitMessage:d,submitProfileCommit:f,onClose:()=>y(!1)}):null,w&&l?e.jsx(sa,{disabled:C,profile:l,profileBusy:i,selectedDefaultTeamId:o,syncDisabledReason:u,submitProfilePush:p,onClose:()=>S(!1)}):null]})}function ea({disabled:s,profileBusy:n,profileCommitMessage:a,setProfileCommitMessage:t,submitProfileCommit:l,onClose:i}){function c(o){o.preventDefault(),!s&&(l(),i())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:i,children:e.jsxs("form",{className:"git-dialog profile-commit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-commit-dialog-title",onMouseDown:o=>o.stopPropagation(),onSubmit:c,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!n,type:"button",title:"Close","aria-label":"Close",onClick:i,children:e.jsx(ce,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Te,{size:18})}),e.jsx("h2",{id:"profile-commit-dialog-title",children:"Commit profile"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Commit message"}),e.jsx("input",{autoFocus:!0,value:a,disabled:!!n,placeholder:"Update OpenPond profile",onChange:o=>t(o.target.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!n,type:"button",onClick:i,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:s,type:"submit",children:[e.jsx(Te,{size:14}),e.jsx("span",{children:n==="commit"?"Committing":"Commit"})]})]})]})})}function sa({disabled:s,profile:n,profileBusy:a,selectedDefaultTeamId:t,syncDisabledReason:l,submitProfilePush:i,onClose:c}){const o=la(n,t),u=o.reduce((p,h)=>p+h.count,0),d=!s&&!l;function f(p){p.preventDefault(),d&&(i(),c())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:c,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:p=>p.stopPropagation(),onSubmit:f,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:c,children:e.jsx(ce,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(xe,{size:18})}),e.jsx("h2",{id:"profile-sync-dialog-title",children:"Sync profile"}),e.jsx("p",{className:"profile-sync-explainer",children:"Sync publishes this committed Profile source for your team, so its Agents can be shared in team chat and attached to hosted sandboxes."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[u," ",u===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",we(n.summary.localHead??n.git?.head)," - Last pushed"," ",we(n.hosted?.lastPushedLocalHead)]})]}),o.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:o.map(p=>e.jsxs("div",{className:`profile-dialog-diff-row ${p.tone??""}`,children:[e.jsx("strong",{children:p.label}),e.jsx("span",{children:p.detail})]},p.label))}):e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:e.jsxs("div",{className:"profile-dialog-diff-row",children:[e.jsx("strong",{children:"Aligned"}),e.jsx("span",{children:"Current local profile source has already been pushed."})]})}),l?e.jsx("div",{className:"profile-dialog-warning",children:l}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!a,type:"button",onClick:c,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!d,type:"submit",children:[e.jsx(xe,{size:14}),e.jsx("span",{children:a==="push"?"Syncing":"Confirm sync"})]})]})]})})}function na({profile:s,profileBusy:n,onClose:a}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog profile-path-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-path-dialog-title",onMouseDown:t=>t.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:!!n,type:"button",title:"Close","aria-label":"Close",onClick:a,children:e.jsx(ce,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(De,{size:18})}),e.jsx("h2",{id:"profile-path-dialog-title",children:"Profile repo"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Profile repo path"}),e.jsx("input",{"aria-label":"Profile repo path",readOnly:!0,value:s.repoPath??""})]}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:s.git?.isRepo?"Git-backed":"Git setup required"}),e.jsxs("span",{children:[s.git?.branch??"No branch"," · ",we(s.git?.head)]})]}),e.jsx("div",{className:"git-dialog-footer",children:e.jsx("button",{className:"git-dialog-secondary",disabled:!!n,type:"button",onClick:a,children:"Close"})})]})})}function ta({onSkillCommand:s,profile:n}){const a=n.skills.slice().sort((i,c)=>i.name.localeCompare(c.name)),t=!s;function l(i){s?.(i)}return e.jsxs("div",{className:"account-list profile-skill-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Skills"}),e.jsx("div",{className:"profile-skill-heading-actions",children:e.jsxs("small",{children:[n.skillCatalog.skillCount," tracked"]})})]}),a.length?e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-skill-table","aria-label":"Profile skills table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-skill-name-column"}),e.jsx("col",{className:"profile-skill-trigger-column"}),e.jsx("col",{className:"profile-skill-status-column"}),e.jsx("col",{className:"profile-skill-source-column"}),e.jsx("col",{className:"profile-skill-actions-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Skill"}),e.jsx("th",{scope:"col",children:"Trigger"}),e.jsx("th",{scope:"col",children:"Status"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:a.map(i=>e.jsx(aa,{commandDisabled:t,onSkillCommand:l,skill:i},i.name))})]})}):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No profile skills found"}),e.jsx("span",{children:"Use /skill create to add reusable profile instructions."})]})]})}function aa({commandDisabled:s,onSkillCommand:n,skill:a}){const t=a.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:a.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Oe,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.name}),e.jsx("span",{title:a.path,children:a.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:a.description,children:a.description||"No description"}),e.jsx("td",{children:e.jsx(Qs,{status:t})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:a.sourcePath,children:a.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[e.jsx("button",{className:"settings-secondary compact",disabled:s||!a.enabled,type:"button",title:`Use ${a.name}`,onClick:()=>n(`$${a.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${a.name}`,onClick:()=>n(`/skill edit ${a.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function Qs({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function we(s){return s?s.slice(0,10):"None"}function Ve(s,n){return Zs(s,n)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${we(s.hosted.sourceCommitSha)}`:"Not pushed"}function ks(s,n){return n?s.git?.head?s.git.dirty?"Commit local profile changes before syncing.":null:"Commit the profile before syncing.":"Select a default team before syncing."}function la(s,n){const a=[],t=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null,i=s.summary.hostedHead??s.hosted?.sourceCommitSha??null;if(Zs(s,n)&&a.push({label:"Account",detail:"Hosted profile metadata was synced under a different default team.",count:1,tone:"warning"}),!i&&!l?a.push({label:"Hosted source",detail:"No hosted profile commit has been recorded.",count:1}):t&&l&&t!==l&&a.push({label:"Commit",detail:`Local ${we(t)} has not been pushed since ${we(l)}.`,count:1}),s.git?.dirty){const o=s.git.files.length||s.diff.files.length||1;a.push({label:"Uncommitted files",detail:`${o} local ${o===1?"file":"files"} changed.`,count:o,tone:"warning"})}const c=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length+s.diff.changedSkills.length+s.diff.changedActions.length+s.diff.changedExtensions.length+s.diff.setupChanges.length+s.diff.envRequirementChanges.length;return c>0&&a.push({label:"Profile changes",detail:ia(s),count:c,tone:s.git?.dirty?"warning":void 0}),s.catalog.stale&&a.push({label:"Catalog",detail:"Action catalog artifacts are stale or missing.",count:1,tone:"warning"}),s.setupGate.blockingCount>0&&a.push({label:"Setup",detail:`${s.setupGate.blockingCount} blocking setup ${s.setupGate.blockingCount===1?"requirement":"requirements"}.`,count:s.setupGate.blockingCount,tone:"warning"}),a}function ia(s){const n=[],a=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length;return a&&n.push(`${a} agent ${a===1?"change":"changes"}`),s.diff.changedActions.length&&n.push(`${s.diff.changedActions.length} action ${s.diff.changedActions.length===1?"change":"changes"}`),s.diff.changedSkills.length&&n.push(`${s.diff.changedSkills.length} skill ${s.diff.changedSkills.length===1?"change":"changes"}`),s.diff.changedExtensions.length&&n.push(`${s.diff.changedExtensions.length} extension ${s.diff.changedExtensions.length===1?"change":"changes"}`),s.diff.setupChanges.length&&n.push(`${s.diff.setupChanges.length} setup ${s.diff.setupChanges.length===1?"change":"changes"}`),s.diff.envRequirementChanges.length&&n.push(`${s.diff.envRequirementChanges.length} env ${s.diff.envRequirementChanges.length===1?"change":"changes"}`),n.join(", ")||"Profile source has local changes."}function Zs(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}const ra=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],oa=120,ca=new Set(["openai","xai","zai"]),da=new Set(["chatgpt-subscription"]),ua="https://api.z.ai/api/coding/paas/v4";function Ps(s){return s.split(/[\n,]/).map(n=>n.trim()).filter(Boolean)}function Xs(s){return s?s.available?"Ready":s.credential.connected?"Configured":s.credential.lastError||s.lastError?"Needs attention":s.id==="codex"?"Needs Codex login":s.routing.localByok?"Needs key":s.enabled?"Enabled":"Off":"Unknown"}function en(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function Rs(s){return s.credential.connected?s.credential.redacted?s.credential.redacted:s.credential.source==="chatgpt_subscription"?"ChatGPT subscription":s.credential.source:s.credential.lastError??"Not connected"}function ha(s){return s?.trim().replace(/\/+$/,"")??""}function sn(s,n){return s.id==="zai"&&ha(n.providers.zai?.baseUrl)===ua}function ma(s,n){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":sn(s,n)?"Coding Plan key":"API key"}function pa(s,n){const a=n.modelCaches[s.id];if(s.routing.localByok&&s.enabled&&!s.credential.connected||!s.enabled&&s.id!=="openpond")return"";const t=Math.max(a?.models.length??0,s.modelIds.length),l=s.defaultModel?Ze(s.defaultModel,n,s.id):"",i=t===1?"1 model":`${t} models`,c=ma(s,n);return[Xs(s),c,a?i:"",l].filter(Boolean).join(" · ")}function ga(s){return s!=="openpond"&&Qe(s)}function rs(s){return s?ca.has(s.id)||s.credentialModes.some(n=>da.has(n)):!1}function fa(s){return rs(s)?["api","subscription"]:["api"]}function As(s,n){return!s||!n||!rs(s)?"api":s.credential.source==="chatgpt_subscription"||sn(s,n)?"subscription":"api"}function Ds(s,n){const a=kn.filter(t=>!!s?.statuses[t]);return n?a.filter(t=>rs(s?.statuses[t])):a}function xa(s){if(!s)return"Never";const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString()}function ja(s,n,a=oa){const t=[],l=new Set,i=new Set(n.map(o=>o.trim()).filter(Boolean)),c=o=>{l.has(o.value)||t.length>=a||(l.add(o.value),t.push(o))};for(const o of s)i.has(o.value)&&c(o);for(const o of s)c(o);return t}function ba({account:s,codex:n,providers:a,providerBusy:t,validationMessage:l,deleteProviderCredential:i,loadProviderModels:c,refreshProviderModels:o,saveProviderConfig:u,saveProviderCredential:d,startOpenAiSubscriptionAuth:f,validateProvider:p}){const[h,g]=r.useState(null),[x,y]=r.useState(!1),w=r.useMemo(()=>Ds(a,!1),[a]),S=r.useMemo(()=>Ds(a,x),[a,x]),C=h?a?.statuses[h]??null:null;function k(R,b){g(R),b&&c(R)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Providers"}),a?e.jsxs("div",{className:"provider-manager-panel",children:[e.jsxs("div",{className:"account-list-heading provider-manager-heading",children:[e.jsxs("div",{className:"provider-manager-title-row",children:[e.jsx("span",{children:"Model providers"}),e.jsxs("label",{className:"settings-check-row compact provider-subscription-filter",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:R=>y(R.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[S.length," of ",w.length," presets"]})]}),S.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:S.map(R=>{const b=a.statuses[R],A=a.modelCaches[R],P=b.modelIds.length>0&&(A?.models.length??0)<b.modelIds.length,B=t?.startsWith(`${R}:`)??!1,m=ga(R),N=R==="openpond"||!!a.providers[R]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${b.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:N,disabled:!m||B,onChange:v=>{k(R,!1),u(R,{enabled:v.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:b.displayName})}),e.jsxs("div",{className:`provider-row-status ${en(b)}`,children:[B?e.jsx(re,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:pa(b,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{k(R,P)},children:"Details"})]},R)})}):e.jsxs("div",{className:"empty-account-list provider-manager-empty",children:[e.jsx("strong",{children:"No subscription providers"}),e.jsx("span",{children:"Turn off the filter to show API-key providers."})]})]}):null,l?e.jsxs("div",{className:"settings-footnote provider-validation-message",children:[e.jsx("span",{children:"Last validation"}),e.jsx("strong",{children:l})]}):null,h&&C&&a?e.jsx(va,{account:s,codex:n,providerId:h,providerBusy:t,settings:a,status:C,onClose:()=>g(null),onDeleteCredential:i,onRefreshModels:o,onSaveConfig:u,onSaveCredential:d,onStartOpenAiSubscriptionAuth:f,onValidate:p}):null]})}function va({account:s,codex:n,providerId:a,providerBusy:t,settings:l,status:i,onClose:c,onDeleteCredential:o,onRefreshModels:u,onSaveConfig:d,onSaveCredential:f,onStartOpenAiSubscriptionAuth:p,onValidate:h}){const g=l.providers[a],x=l.modelCaches[a],y=r.useId(),w=r.useRef(a),S=Math.max(x?.models.length??0,i.modelIds.length),C=i.routing.localByok&&Qe(a)&&a!=="codex",k=r.useMemo(()=>C?fa(i):[],[C,i]),R=k.includes("subscription"),[b,A]=r.useState(()=>As(i,l)),P=C&&b==="subscription"&&R,B=N=>`${y}-${N}-panel`,m=a==="codex"?"Codex app server":g?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return r.useEffect(()=>{if(w.current!==a){w.current=a,A(As(i,l));return}C&&!k.includes(b)&&A("api")},[b,k,C,a,l,i]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:c,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${i.displayName} provider details`,onMouseDown:N=>N.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:c,children:e.jsx(ce,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:i.displayName}),e.jsx("span",{children:Me(a,l)})]}),e.jsx("div",{className:`provider-state-pill ${en(i)}`,children:Xs(i)})]}),C?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:k.map(N=>e.jsx("button",{type:"button",role:"tab",id:`${y}-${N}`,className:b===N?"active":void 0,"aria-selected":b===N,"aria-controls":B(N),onClick:()=>A(N),children:N==="api"?"API":"Subscription"},N))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:Rs(i),children:Rs(i)})]}),P?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:m,children:m})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:g?.defaultModel??i.defaultModel??void 0,children:g?.defaultModel??i.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:x?.lastError??void 0,children:[S," cached · ",xa(x?.fetchedAt)]})]})]}),a==="codex"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{title:n?.account?.email??void 0,children:n?.account?.label??n?.account?.email??"Not signed in"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Binary"}),e.jsx("dd",{title:n?.binaryPath??void 0,children:n?.binaryPath??"Not found"})]})]}):null,i.credential.lastError||x?.lastError||i.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:i.credential.lastError??x?.lastError??i.lastError??void 0,children:i.credential.lastError??x?.lastError??i.lastError})]}):null]}),a==="codex"?e.jsx(ya,{providerBusy:t,status:i,onValidate:h}):C&&g&&x?e.jsx(Na,{credentialTab:b,credentialTabsId:y,hasSubscriptionTab:R,providerId:a,providerBusy:t,settings:l,status:i,onDeleteCredential:o,onRefreshModels:u,onSaveConfig:d,onSaveCredential:f,onStartOpenAiSubscriptionAuth:p,onValidate:h}):i.routing.localByok&&!Qe(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(zs,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function ya({providerBusy:s,status:n,onValidate:a}){const t=s==="codex:validate";return e.jsxs("div",{className:"provider-dialog-body codex-provider-body",children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(pe,{size:15}),e.jsxs("span",{children:["Uses your local ",e.jsx("code",{children:"codex login"})," session through the Codex app server. This route is separate from OpenAI Platform API-key billing."]})]}),e.jsx("div",{className:"settings-button-row codex-provider-actions",children:e.jsxs("button",{type:"button",className:"settings-secondary",disabled:t,onClick:()=>{a("codex",{modelId:n.defaultModel??void 0})},children:[t?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(_s,{size:14}),e.jsx("span",{children:t?"Testing":"Test Codex login"})]})})]})}function Na({credentialTab:s,credentialTabsId:n,hasSubscriptionTab:a,providerId:t,providerBusy:l,settings:i,status:c,onDeleteCredential:o,onRefreshModels:u,onSaveConfig:d,onSaveCredential:f,onStartOpenAiSubscriptionAuth:p,onValidate:h}){const g=i.providers[t],x=r.useMemo(()=>Le(t,i),[t,i]),y=`provider-models-${t}`,w=r.useRef(t),[S,C]=r.useState(g.baseUrl??""),[k,R]=r.useState(g.defaultModel??""),[b,A]=r.useState(g.modelOverrides.join(`
|
|
3
|
+
`)),[P,B]=r.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[m,N]=r.useState("local_secret"),[v,j]=r.useState(""),[$,O]=r.useState(""),G=l===`${t}:config`,Y=l===`${t}:credential`,ee=l===`${t}:validate`,E=l===`${t}:models`,L=l==="openai:credential",te=t==="openai",Q=t==="xai",J=t==="zai",K=(H=>`${n}-${H}-panel`)(s),U=s==="subscription"&&a,ae=s==="subscription"&&J?"coding-plan":"api",ie=ae==="coding-plan"?"Coding Plan key":"API key",ue=c.credential.connected?ae==="coding-plan"?"Replace saved plan key":"Replace saved key":ie,I=ae==="coding-plan"?"Save plan key":"Save key",z=r.useMemo(()=>ja(x,[k,...Ps(b)]),[k,x,b]),V=Math.max(0,x.length-z.length);r.useEffect(()=>{if(w.current!==t){w.current=t,B({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),C(g.baseUrl??""),R(g.defaultModel??""),A(g.modelOverrides.join(`
|
|
4
|
+
`));return}P.baseUrl||C(g.baseUrl??""),P.defaultModel||R(g.defaultModel??""),P.modelOverrides||A(g.modelOverrides.join(`
|
|
5
|
+
`))},[g.baseUrl,g.defaultModel,g.modelOverrides,P.baseUrl,P.defaultModel,P.modelOverrides,t]);const se=m==="env"?!!$.trim():!!v.trim();async function de(H){H.preventDefault(),await d(t,{enabled:!0,baseUrl:S.trim()||null,defaultModel:k.trim()||null,modelOverrides:Ps(b)}),B({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function T(H){if(H.preventDefault(),!!se){if(m==="env"){await f(t,{source:"env",envVar:$.trim()});return}await f(t,{source:"local_secret",value:v}),j("")}}function _({panel:H=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:H?K:void 0,role:H?"tabpanel":void 0,"aria-labelledby":H?`${n}-${s}`:void 0,onSubmit:W=>{T(W)},children:[e.jsxs("div",{className:"provider-card-grid credential-grid",children:[e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Credential source"}),e.jsx(Pe,{value:m,disabled:Y,label:"Credential source",options:ra,onChange:W=>N(W)})]}),m==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:$,disabled:Y,placeholder:"PROVIDER_API_KEY",onChange:W=>O(W.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:ie}),e.jsx("input",{type:"password",value:v,disabled:Y,placeholder:ue,autoComplete:"off",onChange:W=>j(W.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:Y||!se,children:[Y?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:Y?"Saving":I})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${c.displayName} credential`,disabled:Y||!c.credential.connected,onClick:()=>{o(t)},children:e.jsx(Ne,{size:15})})]})]})}function F(){return te?e.jsxs("div",{className:"provider-subscription-panel",id:K,role:"tabpanel","aria-labelledby":`${n}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(pe,{size:15}),e.jsx("span",{children:"ChatGPT subscription auth opens OpenAI login and stores a refresh token locally. API keys remain available under the API tab for raw Platform billing."})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{type:"button",className:"settings-secondary",disabled:L,onClick:()=>{p("browser")},children:[L?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:L?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:L,onClick:()=>{p("device")},children:[L?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:"Device code"})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${c.displayName} credential`,disabled:L||!c.credential.connected,onClick:()=>{o(t)},children:e.jsx(Ne,{size:15})})]})]}):Q?e.jsx("div",{className:"provider-subscription-panel",id:K,role:"tabpanel","aria-labelledby":`${n}-subscription`,children:e.jsxs("div",{className:"provider-dialog-note xai-provider-note",children:[e.jsx(pe,{size:15}),e.jsx("span",{children:"SuperGrok includes Grok app and Grok Build access. xAI API calls here still use an xAI Console API key with API credits or invoiced billing, so there is no separate Connect SuperGrok step yet."})]})}):J?e.jsxs("div",{className:"provider-subscription-panel",id:K,role:"tabpanel","aria-labelledby":`${n}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note subscription-provider-note",children:[e.jsx(pe,{size:15}),e.jsx("span",{children:"GLM Coding Plan uses a plan API key with the dedicated Coding endpoint. General Z.ai API keys and balances are separate."})]}),_({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[U?null:e.jsxs("form",{className:"provider-card-form",onSubmit:H=>{de(H)},children:[e.jsxs("div",{className:"provider-card-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{value:S,disabled:G,placeholder:"https://api.example.com/v1",onChange:H=>{B(W=>({...W,baseUrl:!0})),C(H.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:y,value:k,disabled:G,placeholder:"Model id",onChange:H=>{B(W=>({...W,defaultModel:!0})),R(H.currentTarget.value)}}),e.jsx("datalist",{id:y,children:z.map(H=>e.jsx("option",{value:H.value,children:H.label},H.value))}),V>0?e.jsxs("small",{children:[V," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:G,children:[G?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(ls,{size:14}),e.jsx("span",{children:G?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:E,onClick:()=>{u(t)},children:[E?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(oe,{size:14}),e.jsx("span",{children:E?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:ee||!k.trim(),onClick:()=>{h(t,{baseUrl:S.trim()||void 0,modelId:k.trim()||void 0})},children:[ee?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(_s,{size:14}),e.jsx("span",{children:ee?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:U?F():_()})]})}function wa({status:s,busy:n,flashTailscaleUp:a,refresh:t,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:c,copyTailscaleUpCommand:o,copyServeCommand:u,copyServeSetupUrl:d,copyOperatorCommand:f,createRemoteLink:p}){const h=s?.tailscale.installed??!1,g=s?.serve.enabled??!1,x=s?.serve.reachable??!1,y=!!(s?.webUiAvailable&&h),w=g?!!s?.remoteWebUrl:y,C=(s?.tailscale.peers??[]).filter(b=>!b.isSelf),k=!!s?.tailscale.error?.includes("set --operator"),R=!!(g&&s?.remoteWebUrl);return e.jsxs("section",{className:"account-settings remote-access-settings",children:[e.jsx("h1",{children:"Remote access"}),e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx("div",{className:`remote-access-icon ${x?"online":g?"configured":""}`,children:h?e.jsx(Js,{size:18}):e.jsx(qn,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:x?"Tailscale Serve is reachable":g?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?ka(s):"Checking Tailscale"})]})]}),e.jsxs("div",{className:"account-summary-actions",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh remote access","aria-label":"Refresh remote access",disabled:n!==null,onClick:()=>{t()},children:e.jsx(oe,{className:n==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:n!==null||!h||!g&&!y,onClick:()=>{g?i():l()},children:[e.jsx(it,{size:15}),e.jsx("span",{children:g?n==="disable"?"Turning off":"Turn off":n==="enable"?"Turning on":"Turn on"})]})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsx("div",{className:"account-list-heading remote-access-link-heading",children:e.jsxs("div",{children:[e.jsx("span",{children:"OpenPond link"}),e.jsx("small",{children:R?"Browser UI":"Tailscale + Serve"})]})}),R&&e.jsx(me,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:n==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||n!==null,onAction:c}),e.jsx(me,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:a,actionLabel:n==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||n!==null,onAction:o}),e.jsx(me,{label:"Serve command",value:s?.serveCommand??null,actionLabel:n==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||n!==null,onAction:u}),s?.serve.setupUrl&&e.jsx(me,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:n==="copy-serve-setup"?"Copying":"Copy",disabled:n!==null,onAction:d}),k&&e.jsx(me,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:n==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||n!==null,onAction:f}),e.jsx(me,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(me,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(me,{label:"Disable command",value:s?.disableCommand??null})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading remote-access-link-heading",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Authorized clients"}),e.jsxs("small",{children:[C.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:n!==null||!w,onClick:()=>{p()},children:e.jsx("span",{children:g?"Copy link":"Create link"})})]}),s?C.length===0?e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No clients reported"}),e.jsx("span",{children:s?.tailscale.running?"Tailscale did not return peer devices.":"Tailscale is not running."})]}):C.map(b=>e.jsx(Ca,{peer:b},b.id)):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"Checking clients"}),e.jsx("span",{children:"Loading tailnet devices."})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Remote environment"}),e.jsx("small",{children:s?.tailscale.tailnetName??"Tailnet"})]}),e.jsx(Sa,{status:s})]}),s?.serve.configText&&e.jsxs("div",{className:"remote-access-config",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Tailscale config"}),e.jsx("small",{children:s.serve.enabled?"OpenPond target found":"No OpenPond target"})]}),e.jsx("pre",{children:s.serve.configText})]})]})}function me({actionLabel:s,disabled:n,flash:a,label:t,onAction:l,value:i}){return e.jsxs("div",{className:"product-row remote-access-value-row",children:[e.jsxs("div",{children:[e.jsx("strong",{className:a?"flash":void 0,children:t}),e.jsx("code",{children:i??"Not available"})]}),l&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:n,onClick:()=>{l()},children:e.jsx("span",{children:s??"Copy"})})]})}function Sa({status:s}){const n=[{label:"State",value:s?.tailscale.backendState??"Unknown"},{label:"Machine",value:s?.tailscale.machineName??"Unknown"},{label:"Tailnet",value:s?.tailscale.tailnetName??"Unknown"}],a=[{label:"Tailscale IP",value:s?.tailscale.tailscaleIps.join(", ")||"Unknown"},{label:"HTTPS host",value:s?.serve.httpsHost??s?.tailscale.dnsName??"Unknown"}];return e.jsxs("div",{className:"remote-access-environment",children:[e.jsx("div",{className:"remote-access-environment-row three",children:n.map(t=>e.jsx($s,{label:t.label,value:t.value},t.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(t=>e.jsx($s,{label:t.label,value:t.value},t.label))})]})}function $s({label:s,value:n}){return e.jsxs("div",{className:"remote-access-environment-cell",children:[e.jsx("strong",{children:s}),e.jsx("span",{children:n})]})}function Ca({peer:s}){return e.jsxs("div",{className:"account-row remote-access-peer-row",children:[e.jsx("div",{className:`remote-access-peer-dot ${s.online?"online":""}`}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:s.name}),e.jsx("span",{children:s.dnsName??s.tailscaleIps[0]??"No address"})]}),e.jsx("span",{className:`account-state ${s.online?"signed_in":""}`,children:s.online?"Online":"Offline"}),e.jsx("span",{className:"account-state",children:s.os??"Unknown"})]})}function ka(s){return s.tailscale.installed?s.tailscale.running?s.webUiAvailable?s.serve.reachable?s.remoteUrl??"Tailnet link ready":s.remoteUrl?`${s.remoteUrl} ready to configure`:"Tailnet DNS unavailable":"Browser UI is not served by this process":s.tailscale.authUrl?"Tailscale needs sign-in":"Tailscale is not running":"Tailscale is not installed"}const Pa=[{items:[{section:"account",label:"Account",Icon:us},{section:"notifications",label:"Notifications",Icon:Ws},{section:"providers",label:"Providers",Icon:Hs},{section:"usage",label:"Activity",Icon:Rn}]},{label:"Harness",items:[{section:"harness",label:"Overview",Icon:Bn},{section:"harness-refiner",label:"Refiner",Icon:ds},{section:"harness-continuous-review",label:"Continuous Review",Icon:oe},{section:"harness-contents",label:"Contents",Icon:An},{section:"harness-releases",label:"Releases",Icon:_n}]},{label:"Customization",items:[{section:"defaults",label:"Defaults",Icon:ut},{section:"personalization",label:"Personalization",Icon:ds},{section:"editor",label:"Editor",Icon:Hn},{section:"skills",label:"Skills",Icon:Oe}]},{label:"Agents",items:[{section:"profile",label:"Profiles",Icon:us},{section:"subagents",label:"Agents",Icon:ze}]},{label:"System",items:[{section:"dataset-storage",label:"Dataset Storage",Icon:tt},{section:"remote",label:"Remote Access",Icon:Js},{section:"diagnostics",label:"Diagnostics",Icon:Vn}]}];function Ra({section:s,onBack:n,onSectionChange:a}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back","aria-label":"Back to app",onClick:n,children:[e.jsx(Pn,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Pa.map((t,l)=>e.jsxs("div",{className:"settings-nav-group",children:[t.label?e.jsx("div",{className:"settings-nav-heading",children:t.label}):null,t.items.map(({section:i,label:c,Icon:o})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>a(i),children:[e.jsx(o,{size:16}),e.jsx("span",{children:c})]},i))]},t.label??`settings-${l}`))})]})}function Aa({catalog:s,connection:n,onCatalog:a,onError:t,onOpenExtension:l,onToast:i}){const[c,o]=r.useState(""),[u,d]=r.useState(""),[f,p]=r.useState(null),[h,g]=r.useState(null),[x,y]=r.useState(null),w=r.useCallback(m=>{const N=m instanceof Error?m.message:String(m);y(N),t(N),i?.(N,"error")},[t,i]),S=r.useCallback(()=>{y(null),t(null)},[t]),C=r.useCallback(async m=>{if(m?.preventDefault(),!(!n||!c.trim()||h)){S(),g("preview");try{const N=await M.extensionPreview(n,{source:c.trim(),...u.trim()?{ref:u.trim()}:{}});p(N)}catch(N){p(null),w(N)}finally{g(null)}}},[h,S,n,w,u,c]),k=r.useCallback(async()=>{if(!(!n||!f||h)){S(),g("install");try{const m=await M.extensionAdd(n,{source:f.repositoryUrl,ref:f.requestedRef});a(m.catalog),o(""),d(""),p(null),i?.(`Installed ${m.extension.owner}/${m.extension.repo}.`,"success")}catch(m){w(m)}finally{g(null)}}},[h,S,n,a,i,f,w]),R=r.useCallback(async m=>{if(!(!n||h)){S(),g(`update:${m.id}`);try{const N=await M.extensionUpdate(n,m);a(N.catalog);const v=N.extension.resolvedCommit===m.resolvedCommit&&N.extension.packageHash===m.packageHash;i?.(v?`${m.owner}/${m.repo} is already current.`:`Updated ${m.owner}/${m.repo}.`,"success")}catch(N){w(N)}finally{g(null)}}},[h,S,n,a,i,w]),b=r.useCallback(async()=>{if(!(!n||h||s.extensions.length===0)){S(),g("update-all");try{const m=await M.extensionUpdateAll(n);a(m.catalog);const N=`Updated ${m.updated.length}; ${m.unchanged.length} already current${m.failed.length?`; ${m.failed.length} failed`:""}.`;i?.(N,m.failed.length?"error":"success"),m.failed.length&&y(m.failed.map(v=>v.error).join(" "))}catch(m){w(m)}finally{g(null)}}},[h,s.extensions.length,S,n,a,i,w]),A=r.useCallback(async m=>{if(!(!n||h)&&window.confirm(`Remove ${m.owner}/${m.repo} and its ${m.skills.length} installed skill${m.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){S(),g(`remove:${m.id}`);try{const N=await M.extensionRemove(n,m);a(N.catalog),i?.(`Removed ${m.owner}/${m.repo}.`,"success")}catch(N){w(N)}finally{g(null)}}},[h,S,n,a,i,w]),P=r.useCallback(m=>{o(m),p(null),y(null)},[]),B=r.useCallback(m=>{d(m),p(null),y(null)},[]);return e.jsxs("div",{className:"account-list native-skills-list github-extensions-list",children:[e.jsxs("div",{className:"account-list-heading github-extensions-heading",children:[e.jsx("span",{children:"Third-party extensions"}),e.jsxs("div",{className:"github-extensions-heading-actions",children:[e.jsxs("small",{children:[s.extensions.length," installed from GitHub"]}),e.jsxs("button",{className:"settings-secondary compact",disabled:!n||h!==null||s.extensions.length===0,type:"button",onClick:()=>{b()},children:[h==="update-all"?e.jsx(re,{className:"settings-spin",size:13}):e.jsx(oe,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:m=>{C(m)},children:[e.jsxs("div",{className:"github-extension-add-copy",children:[e.jsx("strong",{children:"Add a GitHub skill pack"}),e.jsx("span",{children:"Use a skills-CLI-compatible owner/repo or GitHub URL. OpenPond installs it locally without running setup code."})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{disabled:!n||h!==null,placeholder:"owner/repo",value:c,onChange:m=>P(m.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!n||h!==null,placeholder:"Default branch",value:u,onChange:m=>B(m.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!c.trim()||h!==null,type:"submit",children:[h==="preview"?e.jsx(re,{className:"settings-spin",size:14}):e.jsx(Ye,{size:14}),h==="preview"?"Checking":"Preview"]})]}),x||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:x??s.error}):null,f?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[f.owner,"/",f.repo]}),e.jsxs("span",{children:[f.skills.length," skill",f.skills.length===1?"":"s"," at ",f.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:f.skills.map(m=>e.jsx("span",{children:m.name},m.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:h!==null,type:"button",onClick:()=>{k()},children:[h==="install"?e.jsx(re,{className:"settings-spin",size:14}):e.jsx(fe,{size:14}),h==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(m=>{const N=h===`update:${m.id}`,v=h===`remove:${m.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${m.owner}/${m.repo} extension source`,className:"github-extension-open",disabled:!n||h!==null,type:"button",onClick:()=>l(m),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Ye,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsxs("strong",{children:[m.owner,"/",m.repo]}),e.jsx("span",{children:m.skills.map(j=>j.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[m.skills.length," skill",m.skills.length===1?"":"s"]}),e.jsxs("span",{children:[m.requestedRef," · ",m.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${m.validationStatus==="valid"?"":"invalid"}`,children:m.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(Fs,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${m.owner}/${m.repo}`,className:"settings-icon-button ghost",disabled:h!==null,title:"Update extension",type:"button",onClick:()=>{R(m)},children:N?e.jsx(re,{className:"settings-spin",size:14}):e.jsx(oe,{size:14})}),e.jsx("button",{"aria-label":`Remove ${m.owner}/${m.repo}`,className:"settings-icon-button ghost danger",disabled:h!==null,title:"Remove extension",type:"button",onClick:()=>{A(m)},children:v?e.jsx(re,{className:"settings-spin",size:14}):e.jsx(Ne,{size:14})})]})]},m.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function Da({onOpenSkill:s,onOpenExtension:n,personalSkills:a,extensionCatalog:t,connection:l,onExtensionCatalog:i,onError:c,onToast:o}){return e.jsxs("section",{className:"account-settings skills-settings","aria-labelledby":"skills-settings-title",children:[e.jsx("header",{className:"skills-settings-header",children:e.jsxs("div",{children:[e.jsx("h1",{id:"skills-settings-title",children:"Skills"}),e.jsx("p",{children:"Install third-party GitHub packs, inspect personal Codex skills, and view instructions bundled with OpenPond."})]})}),e.jsx(Aa,{catalog:t,connection:l,onCatalog:i,onError:c,onOpenExtension:n,onToast:o}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Personal Codex skills"}),e.jsx("small",{children:"Discovered from your local Codex skills folder"})]}),a.length?a.map(u=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Oe,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:u.name}),e.jsx("span",{children:u.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:u.resourceFiles.length?`${u.resourceFiles.length} packaged resource${u.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:u.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${u.validationStatus==="valid"?"":"invalid"}`,children:u.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},u.sourcePath)):e.jsx("div",{className:"skills-settings-empty",children:"No personal Codex skills found."})]}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"App integration skills"}),e.jsx("small",{children:"Bundled with this OpenPond build"})]}),Dn.map(u=>{const d=$n(u.provider)?.label??u.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(u),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Oe,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:u.name}),e.jsx("span",{children:u.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:d}),e.jsx("span",{children:u.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(Fs,{size:16,"aria-hidden":"true"})]},u.name)})]})]})}const os="default";function $a({connection:s,embedded:n=!1,onError:a,onPreferences:t,preferences:l,providers:i}){const c=l.training,[o,u]=r.useState(We(c.defaultModelRef)),[d,f]=r.useState(c.creationMode),[p,h]=r.useState(c.autoApproveEvidence),[g,x]=r.useState(!1),y=r.useMemo(()=>Us(i,{includeUnavailable:!0}),[i]),w=r.useMemo(()=>y.map(b=>({provider:b,models:Le(b.value,i)})).filter(b=>b.models.length>0),[y,i]),S=Ea(o),C=En(l.defaultChatProvider,l.defaultChatModel,i)?` · ${Ia(l.codexReasoningEffort)} reasoning`:"",k=Ma(S,c.defaultModelRef??null)&&d===c.creationMode&&p===c.autoApproveEvidence;r.useEffect(()=>{u(We(c.defaultModelRef)),f(c.creationMode),h(c.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,c.autoApproveEvidence,c.creationMode,c.defaultModelRef]);async function R(b){if(b.preventDefault(),!!s){x(!0),a(null);try{t(await M.savePreferences(s,{training:{defaultModelRef:S,creationMode:d,autoApproveEvidence:p}}))}catch(A){a(A instanceof Error?A.message:String(A))}finally{x(!1)}}}return e.jsxs("section",{className:`account-settings training-settings${n?" embedded":""}`,children:[n?null:e.jsx("h1",{children:"Training"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:b=>{R(b)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Taskset authoring"}),e.jsx("small",{children:"The coding model that proposes tasks, graders, fixtures, and policy boundaries"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Authoring model"}),e.jsxs("select",{value:o,disabled:g,onChange:b=>u(b.target.value),children:[e.jsxs("option",{value:os,children:["Use chat default — ",Me(l.defaultChatProvider,i)," · ",Ze(l.defaultChatModel,i,l.defaultChatProvider),C]}),w.map(b=>e.jsx("optgroup",{label:b.provider.label,children:b.models.map(A=>e.jsx("option",{value:We({providerId:b.provider.value,modelId:A.value}),children:A.label},A.value))},b.provider.value))]}),e.jsx("small",{children:"By default, /train follows the same provider, model, and reasoning level selected for chat."})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Default flow"}),e.jsx("small",{children:"Used by /train and Task Creator unless you choose another mode"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Task Creator mode"}),e.jsxs("select",{value:d,disabled:g,onChange:b=>f(b.target.value),children:[e.jsx("option",{value:"customize",children:"Guided plan — review and revise before materializing"}),e.jsx("option",{value:"defaults",children:"Fast draft — use reversible defaults"})]})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Evidence confirmation"}),e.jsx("small",{children:"Controls the first authoring gate; materialization and training remain separate"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:p,disabled:g,onChange:b=>h(b.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Skip evidence confirmation"}),e.jsx("small",{children:"Immediately send excerpts from explicitly selected chats to the authoring model. This never approves Taskset materialization or training spend."})]})]}),e.jsx("button",{className:"settings-primary",disabled:g||k,children:e.jsx("span",{children:g?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:S?`${Me(S.providerId,i)} / ${Ze(S.modelId,i,S.providerId)}`:"Chat default"})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Safety boundary"}),e.jsx("strong",{children:"Taskset and training approvals always required"})]})]})}function We(s){return s?JSON.stringify([s.providerId,s.modelId]):os}function Ea(s){if(s===os)return null;try{const n=JSON.parse(s);return!Array.isArray(n)||n.length!==2||typeof n[0]!="string"||typeof n[1]!="string"?null:{providerId:n[0],modelId:n[1]}}catch{return null}}function Ia(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function Ma(s,n){return s?.providerId===n?.providerId&&s?.modelId===n?.modelId}function Oa({disabled:s,onChange:n,storageRoots:a,value:t}){const l=r.useId(),[i,c]=r.useState(!1),o=Es(t),u=p=>p.datasetStorePath,d="Dataset",f=a.find(p=>Es(u(p))===o)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:l,children:[d," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${d} storage drive`,className:"model-storage-select",disabled:s,id:l,title:t??"No Dataset storage configured",value:t??"",onChange:p=>n(p.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),t&&!f?e.jsx("option",{value:t,children:"Manual location"}):null,a.map(p=>e.jsxs("option",{disabled:!p.mounted||!p.writable,title:u(p),value:u(p),children:[p.label," · ",Ua(p.kind)," · ",Ba(p)]},p.id))]}),e.jsx("button",{className:"settings-icon-button model-storage-add",disabled:s,type:"button",title:"Add manual location","aria-label":"Add manual Dataset storage location",onClick:()=>c(!0),children:e.jsx(fe,{size:15})})]}),i?Ta(e.jsx(La,{initialPath:t??"",purpose:"dataset",onClose:()=>c(!1),onUse:p=>{n(p),c(!1)}})):null]})}function Ta(s){return typeof document>"u"?s:Kn.createPortal(s,document.body)}function La({initialPath:s,onClose:n,onUse:a,purpose:t="model"}){const l=r.useId(),[i,c]=r.useState(s),o=za(i);r.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]);function u(d){d.preventDefault(),d.stopPropagation(),!o&&a(i.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&n()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:u,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${t} storage`,onClick:n,children:e.jsx(ce,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Jn,{size:18})}),e.jsxs("h2",{id:l,children:["Manual ",t," storage"]}),e.jsx("p",{children:"Enter an absolute path to a folder mounted on this machine."}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Mounted folder path"}),e.jsx("input",{autoFocus:!0,spellCheck:!1,value:i,placeholder:t==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:d=>c(d.target.value)})]}),e.jsx("div",{className:"model-storage-dialog-note",children:"For SMB, connect the share in Files or Finder first, then paste its mounted folder path. OpenPond uses your operating system’s existing connection and credentials."}),i.trim()&&o?e.jsx("div",{className:"profile-dialog-warning",children:o}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",type:"button",onClick:n,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:!!o,type:"submit",children:"Use location"})]})]})})}function za(s){const n=s.trim();return n?/^[a-z][a-z\d+.-]*:\/\//i.test(n)?"Use the mounted folder path, not an smb:// or other network URL.":n==="~"||n.startsWith("~/")||n.startsWith("/")||n.startsWith("\\\\")||/^[a-z]:[\\/]/i.test(n)?null:"Enter an absolute mounted folder path.":"Enter a mounted folder path."}function Ua(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function Ba(s){return s.mounted?s.writable?`${_a(s.freeBytes)} free`:"Read only":"Not mounted"}function Es(s){const n=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(n)?n.toLowerCase():n}function _a(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const n=["KB","MB","GB","TB"];let a=s,t=-1;do a/=1024,t+=1;while(a>=1024&&t<n.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${n[t]}`}function Ha({state:s,catalog:n,busy:a,catalogLoading:t,onRefresh:l,onSave:i}){const[c,o]=r.useState(s?.settings.datasetStorePath??null);r.useEffect(()=>{o(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const u=r.useMemo(()=>s?.storageRoots.find(h=>Is(h.datasetStorePath)===Is(c))??null,[c,s?.storageRoots]),d=c===(s?.settings.datasetStorePath??null),f=n?.datasets??[];async function p(h){h.preventDefault(),await i(c)}return e.jsxs("section",{className:"account-settings compute-settings dataset-storage-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Dataset Storage"}),e.jsx("p",{className:"dataset-storage-intro",children:"Choose where Dataset artifacts are saved and review registered Datasets without loading their rows."})]}),e.jsx("button",{"aria-label":"Refresh Dataset storage",className:"settings-icon-button",disabled:a!==null||t,onClick:()=>{l()},title:"Refresh Dataset storage",type:"button",children:e.jsx(oe,{className:t?"settings-spin":void 0,size:15})})]}),e.jsx("div",{className:"account-summary",children:e.jsx("div",{className:"account-summary-main compute-summary-main",children:e.jsxs("div",{children:[e.jsx("strong",{children:u?.label??(c?"Manual location":"Not configured")}),e.jsx("small",{children:c??"Choose a writable local or mounted location before importing a Dataset."}),u?e.jsxs("small",{children:[Va(u.kind)," · ",u.freeBytes==null?"Free space unknown":`${nn(u.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:h=>{p(h)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(Oa,{disabled:a!==null,onChange:o,storageRoots:s?.storageRoots??[],value:c}),e.jsx("button",{className:"settings-primary",disabled:a!==null||d,children:a==="save"?"Saving":"Save Dataset storage"})]}),e.jsxs("div",{className:"account-list dataset-storage-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Registered Datasets"}),e.jsx("small",{children:f.length})]}),f.length?f.map(h=>e.jsx(Fa,{dataset:h},h.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t?"Loading registered Datasets":"No registered Datasets"})})]})]})}function Fa({dataset:s}){const n=s.storageKind==="parquet"?"Parquet":"Inline Taskset";return e.jsxs("div",{className:"compute-row dataset-storage-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsxs("small",{children:[tn(s.rowCount)," rows"," · ",Ga(s)," · ",n," · ",s.sizeBytes==null?"Size unavailable":nn(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?qa(s.status):"Unavailable"})]})}function Ga(s){return[["train",s.splitCounts.train],["validation",s.splitCounts.validation],["test",s.splitCounts.test],["frozen eval",s.splitCounts.frozen_eval]].filter(([,a])=>Number(a)>0).map(([a,t])=>`${tn(Number(t))} ${a}`).join(" · ")||"No split rows"}function nn(s){if(s<1024)return`${s} B`;const n=["KB","MB","GB","TB"];let a=s,t=-1;do a/=1024,t+=1;while(a>=1024&&t<n.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${n[t]}`}function tn(s){return new Intl.NumberFormat().format(s)}function Is(s){return s?.replace(/[\\/]+$/,"")??""}function qa(s){return s.replaceAll("_"," ").replace(/^./,n=>n.toUpperCase())}function Va(s){return s.replace(/^./,n=>n.toUpperCase())}function Ae(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function ye(s){return s?s.slice(0,10):"none"}function be(s){const n=s.replaceAll("_"," ");return`${n.charAt(0).toUpperCase()}${n.slice(1)}`}function Wa(s){return s==="unresolved"?"Watching":s==="confirmed"?"Ready for Refiner":be(s)}function Ka({review:s}){const n=[["Taskset",s.tasksetProposal],["Baseline evaluation",s.evaluation],["Training qualification",s.trainingQualification]];return e.jsx("div",{className:"harness-review-lineage","aria-label":"Review lineage",children:n.map(([a,t])=>e.jsxs("div",{className:t?"linked":"pending",children:[e.jsx("span",{children:a}),e.jsx("code",{children:t?ye(t.contentHash):"Not created"})]},a))})}function Ja({candidate:s}){return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${s.status}`,children:Wa(s.status)}),e.jsx("strong",{children:s.statement}),e.jsxs("small",{children:[s.occurrences.length," occurrence",s.occurrences.length===1?"":"s"]}),e.jsx("time",{children:Ae(s.updatedAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:s.resolution?.reason??s.recurrenceFamily}),e.jsxs("dl",{className:"harness-compact-metadata",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Pattern"}),e.jsx("dd",{children:s.recurrenceFamily})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Fingerprint"}),e.jsx("dd",{children:e.jsx("code",{children:ye(s.fingerprint)})})]})]}),s.occurrences.length?e.jsxs("details",{className:"harness-history-details",children:[e.jsx("summary",{children:"Evidence receipts"}),e.jsx("ul",{className:"harness-evidence-list",children:s.occurrences.map(n=>e.jsxs("li",{children:[e.jsx("span",{children:be(n.kind)}),e.jsx("code",{children:ye(n.evidence.contentHash)}),e.jsx("time",{children:Ae(n.occurredAt)})]},`${n.evidence.id}:${n.evidence.contentHash}`))})]}):null]})]})}function Ya({accepting:s,onAcceptTasksetReview:n,review:a}){const t=a.classification==="taskset"&&a.nextAuthority==="human_review"&&a.tasksetProposal===null;return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${a.classification}`,children:be(a.classification)}),e.jsx("strong",{children:a.claim?.statement??a.reason}),e.jsxs("small",{children:[a.selectedEvidence.length," selected"]}),e.jsx("time",{children:Ae(a.createdAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:a.reason}),e.jsxs("div",{className:"harness-review-metrics",children:[e.jsxs("span",{children:[e.jsx("strong",{children:a.selectedEvidence.length})," selected"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.excludedEvidence.length})," excluded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.claim?.independentOccurrences??0})," independent occurrences"]}),e.jsxs("span",{children:["Next: ",e.jsx("strong",{children:be(a.nextAuthority)})]})]}),e.jsx(Ka,{review:a}),t?e.jsx("div",{className:"harness-history-actions",children:e.jsx("button",{className:"settings-primary compact",disabled:s,onClick:()=>n(a),type:"button",children:s?"Opening Taskset review…":"Build training Taskset"})}):null]})]})}function Qa({receipt:s}){return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${s.decision}`,children:be(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsxs("small",{children:[be(s.signal.strength)," signal"]}),e.jsx("time",{children:Ae(s.createdAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:s.reasons.join(" ")}),e.jsxs("dl",{className:"harness-compact-metadata",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Review"}),e.jsx("dd",{children:e.jsx("code",{children:ye(s.review.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Taskset"}),e.jsx("dd",{children:e.jsx("code",{children:ye(s.tasksetRelease?.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Baseline"}),e.jsx("dd",{children:e.jsx("code",{children:ye(s.baselineEvaluation?.contentHash)})})]})]})]})]})}function Za({acceptingReviewId:s,candidates:n,onAcceptTasksetReview:a,qualifications:t,reviews:l,schedule:i}){const c=i.activityEnabled||i.enabled;return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx("section",{className:"harness-history-section","aria-label":"Continuous Review status",children:e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-review-status-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Trigger"}),e.jsx("th",{children:"Last review"}),e.jsx("th",{children:"Last result"})]})}),e.jsx("tbody",{children:e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:`harness-status ${c?"harness-status-advanced":""}`,children:c?"On":"Off"})}),e.jsx("td",{children:i.activityEnabled?`${i.activityBatchSize} new outcomes`:"Manual only"}),e.jsx("td",{children:Ae(i.lastRunAt)}),e.jsx("td",{children:i.lastResult?be(i.lastResult.classification):"No completed review"})]})})]})})}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Patterns"}),e.jsx("p",{children:"Recurring evidence being watched or ready for the Refiner."})]}),e.jsx("span",{children:n.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:n.length?n.map(o=>e.jsx(Ja,{candidate:o},`${o.id}:${o.contentHash}`)):e.jsx("div",{className:"harness-empty compact",children:"No recurring patterns are being tracked."})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Review history"}),e.jsx("p",{children:"Receipts stay compact; expand one for evidence and downstream lineage."})]}),e.jsx("span",{children:l.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:l.length?l.map(o=>e.jsx(Ya,{accepting:s===o.id,onAcceptTasksetReview:a,review:o},`${o.id}:${o.contentHash}`)):e.jsx("div",{className:"harness-empty compact",children:"No Continuous Review receipts yet."})})]}),t.length?e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Training handoffs"}),e.jsx("p",{children:"Evidence-bound qualification receipts created for Models."})]}),e.jsx("span",{children:t.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:t.map(o=>e.jsx(Qa,{receipt:o},`${o.id}:${o.contentHash}`))})]}):null]})}const Xa={enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},el={overview:{title:"Harness overview",description:"Current state, items needing attention, and recent learning activity."},refiner:{title:"Refiner",description:"Validated per-turn improvements and recommendations routed outside the Harness."},"continuous-review":{title:"Continuous Review",description:"Recurring patterns found across completed work and their immutable review receipts."},contents:{title:"Harness contents",description:"The instructions, skills, agents, and memory available in the current release."},releases:{title:"Harness releases",description:"Immutable versions, diffs, and rollback controls."}};function Se(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function $e(s){return s?s.slice(0,10):"none"}function Ms(s,n,a){return{workspaceId:s,baseRelease:n?{id:n.id,contentHash:n.contentHash}:null,targetRelease:{id:a.id,contentHash:a.contentHash},title:a.current?"Current Harness release":`Harness release ${$e(a.contentHash)}`}}function sl({review:s,busy:n,onReview:a}){return e.jsxs("article",{className:"harness-history-card harness-review-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"review required"}),e.jsxs("span",{children:[s.proposal.route," · ",s.proposal.edits[0]?.operation??"change"]})]}),e.jsx("h2",{children:s.proposal.expectedOutcome})]}),e.jsx("time",{children:Se(s.proposal.createdAt)})]}),e.jsx("p",{children:s.proposal.edits.map(t=>t.summary).join(" ")}),e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Exact edits (",s.proposal.edits.length,")"]}),e.jsx("div",{className:"harness-edit-list",children:s.proposal.edits.map(t=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.operation," · ",t.target]}),e.jsx("span",{children:t.summary})]}),t.content!==null?e.jsx("pre",{children:t.content}):e.jsx("p",{children:"File deleted."})]},t.id))})]}),s.validations.length?e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Validation receipts (",s.validations.length,")"]}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(t=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${t.status}`,children:t.status}),e.jsx("strong",{children:t.kind.replaceAll("_"," ")}),e.jsx("span",{children:t.summary})]},t.id))})]}):null,e.jsxs("footer",{className:"harness-review-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:n,onClick:()=>a(s,"decline"),type:"button",children:[e.jsx(ce,{size:13})," Decline"]}),e.jsxs("button",{className:"settings-primary compact",disabled:n||s.validations.some(t=>t.status!=="passed"),onClick:()=>a(s,"approve"),type:"button",children:[e.jsx(Bs,{size:13})," Approve and release"]})]})]})}function nl({change:s,onClose:n}){const a=s.proposal;return e.jsxs(Yn,{ariaLabel:"Refiner change details",backdropClassName:"harness-details-dialog-backdrop",className:"harness-details-dialog",onClose:n,children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsx("span",{className:`harness-status harness-status-${s.receipt.decision}`,children:s.receipt.decision.replaceAll("_"," ")}),e.jsx("h2",{children:a?.expectedOutcome??s.receipt.reason}),e.jsx("p",{children:s.receipt.reason})]}),e.jsx("button",{"aria-label":"Close change details",onClick:n,type:"button",children:e.jsx(ce,{size:16})})]}),e.jsxs("div",{className:"harness-details-dialog-body",children:[a?.edits.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Exact edits"}),e.jsx("div",{className:"harness-edit-list",children:a.edits.map(t=>e.jsxs("article",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.operation," · ",t.target]}),e.jsx("span",{children:t.summary})]}),t.content!==null?e.jsx("pre",{children:t.content}):e.jsx("p",{children:"File deleted."})]},t.id))})]}):null,s.validations.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Validation"}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(t=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${t.status}`,children:t.status}),e.jsx("strong",{children:t.kind.replaceAll("_"," ")}),e.jsx("span",{children:t.summary})]},t.id))})]}):null]})]})}function tl({history:s,reviewingProposalId:n,onReviewProposal:a}){const t=r.useMemo(()=>[...s.changes.map(l=>({id:`change:${l.receipt.id}`,at:l.receipt.createdAt,kind:"Refiner",title:l.proposal?.expectedOutcome??l.receipt.reason,detail:l.receipt.decision.replaceAll("_"," ")})),...s.routes.map(l=>({id:`route:${l.decision.id}`,at:l.decision.createdAt,kind:"Routed",title:l.decision.reason,detail:l.decision.route})),...s.evaluationReviews.map(l=>({id:`review:${l.id}`,at:l.createdAt,kind:"Continuous Review",title:l.claim?.statement??l.reason,detail:l.classification.replaceAll("_"," ")}))].sort((l,i)=>i.at.localeCompare(l.at)).slice(0,6),[s]);return e.jsxs("div",{className:"harness-page-sections",children:[s.pendingReviews.length?e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Needs review"}),e.jsx("p",{children:"Sensitive or high-impact proposals require your approval."})]}),e.jsx("span",{children:s.pendingReviews.length})]}),s.pendingReviews.map(l=>e.jsx(sl,{busy:n!==null,onReview:a,review:l},`${l.proposal.id}:${l.proposal.contentHash}`))]}):null,e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Recent activity"}),e.jsx("p",{children:"The latest events from both learning loops."})]}),e.jsx("span",{children:t.length})]}),t.length?e.jsx("div",{className:"harness-activity-list",children:t.map(l=>e.jsxs("article",{children:[e.jsx("span",{children:l.kind}),e.jsxs("div",{children:[e.jsx("strong",{children:l.title}),e.jsx("small",{children:l.detail})]}),e.jsx("time",{children:Se(l.at)})]},l.id))}):e.jsx("div",{className:"harness-empty compact",children:"No Harness learning activity yet."})]})]})}function al({history:s,onOpenChangeDiff:n,onOpenSourceSession:a}){const[t,l]=r.useState(null);return e.jsxs("div",{className:"harness-page-sections",children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Applied changes"}),e.jsx("p",{children:"Every release transition with exact edits and validation receipts."})]}),e.jsx("span",{children:s.changes.length})]}),s.changes.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-refiner-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Target"}),e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Result"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:s.changes.map(i=>{const c=i.trigger?.runRef??null,o=i.proposal;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:o?.expectedOutcome??i.receipt.reason})}),e.jsx("td",{children:e.jsx("code",{children:o?.edits[0]?.target??o?.route??"workspace"})}),e.jsx("td",{children:e.jsx("code",{children:$e(i.receipt.nextRelease?.contentHash)})}),e.jsx("td",{children:Se(i.receipt.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`harness-status harness-status-${i.receipt.decision}`,children:i.receipt.decision.replaceAll("_"," ")})}),e.jsx("td",{children:e.jsxs("div",{className:"harness-inline-actions",children:[e.jsx("button",{"aria-label":"View evidence and exact edits",className:"harness-table-icon-action",onClick:()=>l(i),title:"View evidence and exact edits",type:"button",children:e.jsx(st,{size:14})}),i.receipt.nextRelease?e.jsx("button",{"aria-label":"View release diff",className:"harness-table-icon-action",onClick:()=>n(i),title:"View release diff",type:"button",children:e.jsx(Ks,{size:14})}):null,c&&a?e.jsx("button",{"aria-label":"Open source conversation",className:"harness-table-icon-action",onClick:()=>a(c),title:"Open source conversation",type:"button",children:e.jsx(Hs,{size:14})}):null]})})]},`${i.receipt.id}:${i.receipt.contentHash}`)})})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness changes have been applied."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Routed recommendations"}),e.jsx("p",{children:"Observations sent to runtime, product, Tasksets, or training without mutating the Harness."})]}),e.jsx("span",{children:s.routes.length})]}),s.routes.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-route-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Recommendation"}),e.jsx("th",{children:"Source evidence"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Route"})]})}),e.jsx("tbody",{children:s.routes.map(i=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("p",{children:i.decision.reason})}),e.jsx("td",{children:e.jsx("p",{children:i.trigger?.reason??"Completed work"})}),e.jsx("td",{children:Se(i.decision.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:i.decision.route})})]},`${i.decision.id}:${i.decision.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No recommendations have been routed."})]}),t?e.jsx(nl,{change:t,onClose:()=>l(null)}):null]})}function ll(s){return s.includes("/skills/")||s.startsWith("skills/")?"Skill":s.includes("/agents/")||s.startsWith("agents/")?"Agent":s.includes("memory")?"Memory":s.endsWith(".md")?"Instruction":"File"}function il(s){return s<1024?`${s} B`:`${(s/1024).toFixed(s<10240?1:0)} KB`}function rl({history:s,onOpenCurrentRelease:n}){const a=s.releases.find(t=>t.current)??s.releases[0]??null;return e.jsxs("div",{className:"harness-page-sections",children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Current release"}),e.jsx("p",{children:"Read-only source contents currently supplied by the Personal Harness."})]}),a?e.jsx("button",{className:"settings-secondary compact",onClick:n,type:"button",children:"View release diff"}):null]}),a?.files.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Size"}),e.jsx("th",{children:"Revision"})]})}),e.jsx("tbody",{children:a.files.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:ll(t.path)})}),e.jsx("td",{children:e.jsx("code",{children:t.path})}),e.jsx("td",{children:il(t.sizeBytes)}),e.jsx("td",{children:e.jsx("code",{children:$e(t.contentHash)})})]},t.id))})]})}):e.jsx("div",{className:"harness-empty compact",children:"The current release has no source files."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Memory"}),e.jsx("p",{children:"Bounded memory available through search; it is not copied into every prompt."})]}),e.jsx("span",{children:s.memories.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:s.memories.length?s.memories.map(t=>e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"harness-status",children:"Memory"}),e.jsx("strong",{children:t.key}),e.jsxs("small",{children:["revision ",t.revision]}),e.jsx("time",{children:Se(t.updatedAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:t.content}),t.tags.length?e.jsx("small",{children:t.tags.join(" · ")}):null]})]},`${t.id}:${t.revision}`)):e.jsx("div",{className:"harness-empty compact",children:"No Harness memory has been saved."})})]})]})}function ol({busy:s,history:n,onOpenDiff:a,onRequestRollback:t}){return e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Release history"}),e.jsx("p",{children:"New work uses the current release; active runs stay pinned to the version they started with."})]}),e.jsx("span",{children:n.releases.length})]}),n.releases.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-release-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Contents"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:n.releases.map((l,i)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:"harness-release-identity",children:[e.jsx("strong",{children:l.id}),e.jsx("code",{children:$e(l.contentHash)})]})}),e.jsxs("td",{children:[l.files.length," files"]}),e.jsx("td",{children:Se(l.createdAt)}),e.jsx("td",{children:l.current?e.jsx("span",{className:"harness-current-pill",children:"Current"}):e.jsx("span",{className:"harness-status",children:"Previous"})}),e.jsx("td",{children:e.jsxs("div",{className:"harness-inline-actions",children:[e.jsx("button",{"aria-label":"View release changes",className:"harness-table-icon-action",onClick:()=>a(n.releases[i+1]??null,l),title:"View release changes",type:"button",children:e.jsx(Ks,{size:14})}),l.current?null:e.jsx("button",{"aria-label":"Roll back to release",className:"harness-table-icon-action",disabled:s,onClick:()=>t(l),title:"Roll back to release",type:"button",children:e.jsx(is,{size:14})})]})})]},`${l.id}:${l.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness releases exist yet."})]})}function cl({connection:s,enabled:n,onAcceptEvaluationReview:a,onError:t,onDefaultReleaseDiff:l,onOpenReleaseDiff:i,onOpenSourceSession:c,onToast:o,page:u}){const[d,f]=r.useState(null),[p,h]=r.useState(!1),[g,x]=r.useState(null),[y,w]=r.useState(null),[S,C]=r.useState(!1),[k,R]=r.useState(!1),[b,A]=r.useState(null),{confirmAction:P,confirmDialog:B,resolveConfirmDialog:m}=Ts(),N=!!(d?.evaluationReviewSchedule.activityEnabled||d?.evaluationReviewSchedule.enabled),[v,j]=r.useState(!1),[$,O]=r.useState(!1);r.useEffect(()=>{d&&j(d.backgroundReview.enabled)},[d?.backgroundReview.enabled]),r.useEffect(()=>{O(N)},[N]);const G=r.useCallback(async()=>{if(s){h(!0);try{const I=await M.harnessHistory(s);f(I);const z=I.releases.findIndex(se=>se.current),V=z>=0?I.releases[z]:null;I.workspace&&V&&l(Ms(I.workspace.id,I.releases[z+1]??null,V)),t(null)}catch(I){t(I instanceof Error?I.message:String(I))}finally{h(!1)}}},[s,l,t]);r.useEffect(()=>{n&&G()},[n,u,G]);const Y=r.useCallback(async I=>{if(!(!s||!d?.workspace)){R(!0);try{const z=await M.reviewHarnessEvaluation(s,{workspaceId:d.workspace.id,maxEstimatedCostUsd:I});f(z.history),t(null),o?.(`Continuous Review completed: ${z.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(z){t(z instanceof Error?z.message:String(z))}finally{R(!1)}}},[s,d,t,o]),ee=r.useCallback(async(I,z,V)=>{if(!(!s||!d?.workspace)){C(!0);try{let se=d;I==="refiner"&&z!==d.backgroundReview.enabled&&(se=(await M.updateHarnessBackgroundReview(s,{workspaceId:d.workspace.id,enabled:z})).history);const de=d.evaluationReviewSchedule.activityEnabled||d.evaluationReviewSchedule.enabled;if(I==="continuous-review"&&(V!==de||d.evaluationReviewSchedule.enabled)){const T=d.evaluationReviewSchedule;se=(await M.updateHarnessEvaluationReviewSchedule(s,{workspaceId:d.workspace.id,enabled:!1,activityEnabled:V,activityBatchSize:T.activityBatchSize,cadence:"manual",maxEstimatedCostUsd:T.maxEstimatedCostUsd})).history}f(se),t(null),o?.(`${I==="refiner"?"Refiner":"Continuous Review"} settings applied.`,"success")}catch(se){t(se instanceof Error?se.message:String(se))}finally{C(!1)}}},[s,d,t,o]),E=r.useCallback(async I=>{if(d?.workspace){A(I.id);try{await a(d.workspace.id,{id:I.id,contentHash:I.contentHash})&&(t(null),o?.("Taskset review opened in Models.","success"))}catch(z){t(z instanceof Error?z.message:String(z))}finally{A(null)}}},[d?.workspace,a,t,o]),L=r.useCallback((I,z)=>{d?.workspace&&i(Ms(d.workspace.id,I,z))},[d?.workspace,i]),te=r.useCallback(I=>{!d?.workspace||!I.receipt.nextRelease||i({workspaceId:d.workspace.id,baseRelease:I.receipt.previousRelease,targetRelease:I.receipt.nextRelease,title:I.proposal?.expectedOutcome??I.receipt.reason})},[d?.workspace,i]),Q=r.useCallback(async I=>{if(!(!s||!d?.workspace)){x(I.contentHash);try{const z=await M.rollbackHarness(s,{workspaceId:d.workspace.id,targetRelease:{id:I.id,contentHash:I.contentHash}});f(z.history),t(null),o?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(z){t(z instanceof Error?z.message:String(z))}finally{x(null)}}},[s,d?.workspace,t,o]),J=r.useCallback(async I=>{await P({title:"Roll back Harness release?",body:`New work will use ${$e(I.contentHash)}. Active runs remain pinned to their current release.`,confirmLabel:"Roll back"})&&await Q(I)},[P,Q]),Z=r.useCallback(async(I,z)=>{if(!(!s||!d?.workspace)){w(I.proposal.id);try{const V=await M.reviewHarnessProposal(s,{workspaceId:d.workspace.id,proposal:{id:I.proposal.id,contentHash:I.proposal.contentHash},decision:z});f(V.history),t(null),o?.(z==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",z==="approve"?"success":"info")}catch(V){t(V instanceof Error?V.message:String(V))}finally{w(null)}}},[s,d?.workspace,t,o]),K=d?.releases.find(I=>I.current)??d?.releases[0]??null,U=K?d?.releases.indexOf(K)??-1:-1,ae=el[u],ie=d?u==="refiner"?v!==d.backgroundReview.enabled:$!==N||d.evaluationReviewSchedule.enabled:!1,ue=u==="refiner"||u==="continuous-review";return e.jsxs("section",{className:"account-settings harness-history-settings","aria-labelledby":"harness-history-title",children:[e.jsxs("div",{className:"account-settings-title harness-page-title",children:[e.jsxs("div",{children:[e.jsx("h1",{id:"harness-history-title",children:ae.title}),e.jsx("p",{children:ae.description})]}),d?.workspace&&ue?e.jsxs("div",{className:"harness-page-header-actions",children:[u==="continuous-review"?e.jsx("button",{className:"settings-secondary compact",disabled:k,onClick:()=>{Y(d.evaluationReviewSchedule.maxEstimatedCostUsd)},type:"button",children:k?"Reviewing…":"Review now"}):null,e.jsxs("label",{className:"harness-page-toggle",children:[e.jsx("span",{children:u==="refiner"?v?"On":"Off":$?"On":"Off"}),e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{"aria-label":u==="refiner"?"Enable Refiner":"Enable Continuous Review",checked:u==="refiner"?v:$,disabled:S,onChange:I=>u==="refiner"?j(I.target.checked):O(I.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("button",{className:"settings-primary compact",disabled:S||!ie,onClick:()=>{ee(u,v,$)},type:"button",children:S?"Applying…":"Apply changes"})]}):null]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&p&&!d?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,d&&!d.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,d?.workspace&&u==="overview"?e.jsx(tl,{history:d,onReviewProposal:Z,reviewingProposalId:y}):null,d?.workspace&&u==="refiner"?e.jsx(al,{history:d,onOpenChangeDiff:te,onOpenSourceSession:c}):null,d?.workspace&&u==="continuous-review"?e.jsx(Za,{acceptingReviewId:b,candidates:d.refinementCandidates,onAcceptTasksetReview:I=>{E(I)},qualifications:d.modelImprovementQualifications,reviews:d.evaluationReviews,schedule:d.evaluationReviewSchedule??Xa}):null,d?.workspace&&u==="contents"?e.jsx(rl,{history:d,onOpenCurrentRelease:()=>{K&&L(U>=0?d.releases[U+1]??null:null,K)}}):null,d?.workspace&&u==="releases"?e.jsx(ol,{busy:g!==null,history:d,onOpenDiff:L,onRequestRollback:I=>{J(I)}}):null,e.jsx(Ls,{onResolve:m,state:B})]})}function Os(s){return s?s.slice(0,10):"initial"}function dl({connection:s,expanded:n,onResizeStart:a,onToggleExpanded:t,selection:l}){const[i,c]=r.useState(null),[o,u]=r.useState(null),[d,f]=r.useState(!0),p=r.useCallback(async()=>{u(null),f(!0);try{c(await M.harnessReleaseDiff(s,l))}catch(x){c(null),u(x instanceof Error?x.message:String(x))}finally{f(!1)}},[s,l]);r.useEffect(()=>{p()},[p]);const h=r.useMemo(()=>i?{appId:`harness:${l.workspaceId}`,repoPath:l.title,initialized:!0,dirty:i.filesChanged>0,filesChanged:i.filesChanged,additions:i.additions,deletions:i.deletions,repoFiles:i.files.map(x=>x.path),files:i.files,error:null,updatedAt:""}:null,[i,l.title,l.workspaceId]),g=`${l.title} · ${Os(l.baseRelease?.contentHash)} → ${Os(l.targetRelease.contentHash)}`;return e.jsx(Qn,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:h,editorPreferences:null,expanded:n,filesWithPreview:!0,loading:d,onOpenBrowserUrl:()=>{},onRefresh:p,onResizeStart:a,onToggleExpanded:t,readOnly:!0,workspaceError:o,workspaceInitialized:!0,workspaceName:g})}function ul({connection:s,onError:n,onPayload:a}){const[t,l]=r.useState(!1),[i,c]=r.useState(!1);async function o(p,h){if(s){l(!0),n(null);try{const g=await M.switchOpenPondAccount(s,{handle:p,baseUrl:h??null}),x=await M.savePreferences(s,{defaultTeamId:null});a({...g,preferences:x.preferences})}catch(g){n(g instanceof Error?g.message:String(g))}finally{l(!1)}}}async function u(p,h){if(!s)return!1;l(!0),n(null);try{return a(await M.removeOpenPondAccount(s,{handle:p,baseUrl:h??null})),!0}catch(g){return n(g instanceof Error?g.message:String(g)),!1}finally{l(!1)}}async function d(p){if(!(!s||!p.apiKey.trim())){l(!0),n(null);try{const h=p.handle?.trim(),g=p.environment?.trim(),x=await M.saveOpenPondAccount(s,{apiKey:p.apiKey.trim(),handle:h||void 0,baseUrl:p.baseUrl,apiBaseUrl:p.apiBaseUrl,environment:g||"custom",setActive:!0}),y=await M.savePreferences(s,{defaultTeamId:null});a({...x,preferences:y.preferences})}catch(h){throw n(h instanceof Error?h.message:String(h)),h}finally{l(!1)}}}async function f(){if(s){c(!0),n(null);try{a(await M.refreshOpenPondAccounts(s))}catch(p){n(p instanceof Error?p.message:String(p))}finally{c(!1)}}}return{refreshingAccounts:i,saving:t,refreshAccounts:f,removeAccount:u,saveAccount:d,switchAccount:o}}function hl({connection:s,onError:n,onPreferences:a,preferences:t,providers:l}){const[i,c]=r.useState(t.defaultBranchPrefix),[o,u]=r.useState(t.defaultNewProjectDirectory),[d,f]=r.useState(t.advancedWorkspaceControls),[p,h]=r.useState(t.contextCompaction.autoEnabled),[g,x]=r.useState(t.subagents.enabled),[y,w]=r.useState(t.subagents.delegationMode),[S,C]=r.useState(!t.subagents.defaultModelRef),[k,R]=r.useState(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),[b,A]=r.useState(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),[P,B]=r.useState(t.subagents.roles),[m,N]=r.useState(t.subagents.maxConcurrentRuns),[v,j]=r.useState(t.subagents.maxConcurrentRunsPerProvider),[$,O]=r.useState(t.subagents.maxConcurrentRunsPerWorkspaceTarget),[G,Y]=r.useState(!1),ee=S?null:{providerId:k,modelId:b.trim()},E=g!==t.subagents.enabled||y!==t.subagents.delegationMode||!ml(ee,t.subagents.defaultModelRef)||m!==t.subagents.maxConcurrentRuns||v!==t.subagents.maxConcurrentRunsPerProvider||$!==t.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(P)!==JSON.stringify(t.subagents.roles);r.useEffect(()=>{c(t.defaultBranchPrefix),u(t.defaultNewProjectDirectory),f(t.advancedWorkspaceControls),h(t.contextCompaction.autoEnabled),x(t.subagents.enabled),w(t.subagents.delegationMode),C(!t.subagents.defaultModelRef),R(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),A(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),B(t.subagents.roles),N(t.subagents.maxConcurrentRuns),j(t.subagents.maxConcurrentRunsPerProvider),O(t.subagents.maxConcurrentRunsPerWorkspaceTarget)},[t.defaultChatProvider,t.defaultChatModel,t.defaultBranchPrefix,t.defaultNewProjectDirectory,t.advancedWorkspaceControls,t.contextCompaction.autoEnabled,t.subagents]);function L(T){R(T),A(_=>Xe(T,_,l))}function te(){return S?t.defaultChatProvider:k}function Q(){return S?t.defaultChatModel:b}function J(T,_){B(F=>F.map(H=>H.id===T?_(H):H))}function Z(T,_){J(T,F=>({...F,enabled:_}))}function K(T,_){J(T,F=>({...F,background:_}))}function U(T,_){J(T,F=>{if(_)return{...F,modelRef:null};const H=F.modelRef?.providerId??te(),W=F.modelRef?.modelId??Q();return{...F,modelRef:_e(H,W,l)??null}})}function ae(T,_){J(T,F=>({...F,modelRef:_e(_,F.modelRef?.modelId??Q(),l)??null}))}function ie(T,_){J(T,F=>{const H=F.modelRef?.providerId??te(),W=_.trim();return{...F,modelRef:W?{providerId:H,modelId:W}:null}})}function ue(T,_){J(T,F=>({...F,isolationMode:_}))}function I(T,_){J(T,F=>({...F,toolPolicy:_}))}function z(T,_){J(T,F=>({...F,peerMessages:_}))}function V(T,_){J(T,F=>({...F,maxConcurrentRuns:je(_,1,16)}))}async function se(){let T=null;if(window.openpond?.selectFolder){const _=await window.openpond.selectFolder();if(_.canceled)return;T=_.path}else T=window.prompt("Default new project directory",o);T?.trim()&&u(T.trim())}async function de(T){if(T.preventDefault(),!!s){Y(!0),n(null);try{a(await M.savePreferences(s,{defaultBranchPrefix:Ke(i),defaultNewProjectDirectory:o.trim(),advancedWorkspaceControls:d,contextCompaction:{...t.contextCompaction,autoEnabled:p},subagents:{enabled:g,workspaceDefaultsVersion:t.subagents.workspaceDefaultsVersion,toolDefaultsVersion:t.subagents.toolDefaultsVersion,delegationMode:y,defaultModelRef:S?null:_e(k,b,l)??null,roles:P,maxConcurrentRuns:je(m,1,32),maxConcurrentRunsPerProvider:v===null?null:je(v,1,32),maxConcurrentRunsPerWorkspaceTarget:$===null?null:je($,1,32)}}))}catch(_){n(_ instanceof Error?_.message:String(_))}finally{Y(!1)}}}return{advancedWorkspaceControls:d,contextCompactionAutoEnabled:p,defaultBranchPrefix:i,defaultNewProjectDirectory:o,subagentsEnabled:g,subagentDelegationMode:y,subagentsUseDefaultModel:S,subagentsProvider:k,subagentsModel:b,subagentRoles:P,subagentsMaxConcurrentRuns:m,subagentsMaxConcurrentRunsPerProvider:v,subagentsMaxConcurrentRunsPerWorkspaceTarget:$,subagentsDirty:E,saving:G,chooseDefaultProjectDirectory:se,saveDefaults:de,changeSubagentsProvider:L,changeSubagentRoleProvider:ae,setAdvancedWorkspaceControls:f,setContextCompactionAutoEnabled:h,setDefaultBranchPrefix:c,setDefaultNewProjectDirectory:u,setSubagentsUseDefaultModel:C,setSubagentsModel:A,setSubagentsEnabled:x,setSubagentDelegationMode:T=>w(T),setSubagentsMaxConcurrentRuns:T=>N(je(T,1,32)),setSubagentsMaxConcurrentRunsPerProvider:T=>j(T===null?null:je(T,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:T=>O(T===null?null:je(T,1,32)),setSubagentRoleBackground:K,setSubagentRoleEnabled:Z,setSubagentRoleIsolationMode:ue,setSubagentRoleMaxConcurrentRuns:V,setSubagentRoleModel:ie,setSubagentRolePeerMessages:z,setSubagentRoleToolPolicy:I,setSubagentRoleUseDefaultModel:U}}function je(s,n,a){return Number.isFinite(s)?Math.min(a,Math.max(n,Math.trunc(s))):n}function ml(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const pl=15e3,gl=100,fl=100,xl=2500;function jl({onError:s,section:n}){const[a,t]=r.useState(null),[l,i]=r.useState(null),[c,o]=r.useState(gl),[u,d]=r.useState([]),[f,p]=r.useState(null),[h,g]=r.useState(!0),x=r.useRef(null),[y,w]=r.useState(null),S=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),k=!!window.openpond?.readRecentLogs?`${u.length} of ${c} line${c===1?"":"s"}${h?" tailing":""}`:"Unavailable";r.useEffect(()=>{n==="diagnostics"&&R(c,"refresh",{quiet:!0})},[n]),r.useEffect(()=>{if(n!=="diagnostics"||!h||!window.openpond?.readRecentLogs)return;let N=!1;const v=window.setInterval(()=>{N||(N=!0,R(c,"refresh",{quiet:!0}).finally(()=>{N=!1}))},xl);return()=>window.clearInterval(v)},[n,h,c]),r.useEffect(()=>{if(n!=="diagnostics"||!h)return;const N=x.current;N&&(N.scrollTop=N.scrollHeight)},[n,h,u]);async function R(N=c,v="refresh",j={}){const $=window.openpond?.readRecentLogs;if(!$){const O="Log view is not available in this runtime.";j.quiet||(w({label:"Logs",value:O,warning:!0}),s(O));return}j.quiet||i(v);try{const O=await Ee($(N),"Read logs");if(!O.ok)throw new Error(O.error);o(O.lineLimit),p(O.logDir),d(O.lines),j.quiet?w(G=>G?.label==="Logs"?null:G):w(null)}catch(O){const G=O instanceof Error?O.message:String(O);w({label:"Logs",value:G,warning:!0}),j.quiet||s(G)}finally{j.quiet||i(null)}}function b(){g(!1),R(c+fl,"older")}function A(){const N=!h;g(N),N&&R(c,"refresh",{quiet:!0})}async function P(){const N=window.openpond?.openLogsFolder;if(!N){const v="Desktop logs are not available in this runtime.";w({label:"Logs",value:v,warning:!0}),s(v);return}t("logs"),s(null);try{const v=await Ee(N(),"Open logs");if(!v.ok)throw new Error(v.error??"Could not open the logs folder.");w(null)}catch(v){const j=v instanceof Error?v.message:String(v);w({label:"Logs",value:j,warning:!0}),s(j)}finally{t(null)}}async function B(){const N=window.openpond?.copyRecentLogs;if(!N){const v="Recent log copy is not available in this runtime.";w({label:"Copy",value:v,warning:!0}),s(v);return}t("copy"),s(null);try{const v=await Ee(N(1e3),"Copy recent logs");if(!v.ok)throw new Error(v.error??"Could not copy recent logs.");w({label:"Copy",value:v.lines?`Copied ${v.lines} recent log lines.`:"Copied recent logs."})}catch(v){const j=v instanceof Error?v.message:String(v);w({label:"Copy",value:j,warning:!0}),s(j)}finally{t(null)}}async function m(){const N=window.openpond?.exportDiagnostics;if(!N){const v="Diagnostics export is not available in this runtime.";w({label:"Export",value:v,warning:!0}),s(v);return}t("export"),s(null);try{const v=await Ee(N(),"Export diagnostics");if(!v.ok)throw new Error(v.error??"Could not export diagnostics.");w({label:"Export",value:v.path?`Saved to ${v.path}`:"Diagnostics exported."})}catch(v){const j=v instanceof Error?v.message:String(v);w({label:"Export",value:j,warning:!0}),s(j)}finally{t(null)}}return{diagnosticsAvailable:S,diagnosticsBusy:a,diagnosticsStatus:y,logDir:f,logLineLimit:c,logLines:u,logViewBusy:l,logViewSummary:k,logViewportRef:x,tailLogs:h,copyRecentLogs:B,exportDiagnosticsBundle:m,loadOlderLogs:b,openLogsFolder:P,refreshLogView:R,toggleTailLogs:A}}async function Ee(s,n){let a;try{return await Promise.race([s,new Promise((t,l)=>{a=window.setTimeout(()=>{l(new Error(`${n} did not receive a desktop response.`))},pl)})])}finally{a!==void 0&&window.clearTimeout(a)}}function bl({connection:s,enabled:n,onError:a,onPreferences:t,onToast:l,preferences:i}){const[c,o]=r.useState(i.editor),[u,d]=r.useState(null),[f,p]=r.useState(!1),[h,g]=r.useState(!1),[x,y]=r.useState(!1);r.useEffect(()=>{o(i.editor)},[i.editor]);const w=r.useCallback(async()=>{if(s){g(!0);try{d(await M.workspaceLspSettingsStatus(s))}catch(b){a(b instanceof Error?b.message:String(b))}finally{g(!1)}}},[s,a]);r.useEffect(()=>{!n||!s||w()},[s,n,w]);function S(b,A){o(P=>({...P,languages:{...P.languages,[b]:{...P.languages[b],mode:A}}}))}function C(b,A){o(P=>({...P,languages:{...P.languages,[b]:{...P.languages[b],customCommand:A}}}))}async function k(b){if(b.preventDefault(),!!s){p(!0),a(null);try{const A=await M.savePreferences(s,{editor:c});t(A),d(await M.workspaceLspSettingsStatus(s))}catch(A){a(A instanceof Error?A.message:String(A))}finally{p(!1)}}}async function R(){if(s){y(!0),a(null);try{await M.restartWorkspaceLsp(s),d(await M.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(b){a(b instanceof Error?b.message:String(b))}finally{y(!1)}}}return{editorPreferences:c,lspStatus:u,restarting:x,saving:f,statusLoading:h,refreshLspStatus:w,restartLanguageServers:R,saveEditorSettings:k,setEditorPreferences:o,setLanguageCustomCommand:C,setLanguageMode:S}}function vl({connection:s,onError:n,onPayload:a,personalization:t}){const l=r.useMemo(()=>t.templates.map(m=>({value:m.id,label:m.name,description:m.id===t.activeTemplateId?"Selected":m.source==="built_in"?m.description:void 0})),[t.activeTemplateId,t.templates]),[i,c]=r.useState(t.activeTemplateId),[o,u]=r.useState(t.soul),[d,f]=r.useState(""),[p,h]=r.useState(!1),[g,x]=r.useState(!1),y=t.templates.find(m=>m.id===i)??t.templates[0],w=y?.source==="custom",S=y?o!==y.content:!0,C=i!==t.activeTemplateId||o!==t.soul||S,k=!!(w&&o.trim()&&y&&C);r.useEffect(()=>{c(t.activeTemplateId),u(t.soul);const m=t.templates.find(N=>N.id===t.activeTemplateId);f(m?`${m.name} Copy`:""),h(!1)},[t.activeTemplateId,t.soul,t.templates]);async function R(m=!1){if(!m&&!w)return;const N=m?d:y?.name;if(!(!s||!o.trim()||!N?.trim())){x(!0),n(null);try{a(await M.savePersonalization(s,{activeTemplateId:i,templateName:N,soul:o,saveAsNew:m})),h(!1)}catch(v){n(v instanceof Error?v.message:String(v))}finally{x(!1)}}}async function b(m){const N=t.templates.find(v=>v.id===m);if(N&&(c(N.id),f(`${N.name} Copy`),u(N.content),h(!1),!!s)){x(!0),n(null);try{a(await M.savePersonalization(s,{activeTemplateId:N.id,templateName:N.name,soul:N.content,saveAsNew:!1}))}catch(v){n(v instanceof Error?v.message:String(v))}finally{x(!1)}}}function A(){y&&(f(`${y.name} Copy`),u(y.content),h(!1))}function P(m){u(m),y&&!w&&m!==y.content&&h(!0)}function B(){y&&(f(`${y.name} Copy`),h(!0))}return{canSaveCurrentTemplate:k,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:p,saving:g,selectedPersonalizationTemplate:y,selectedTemplateIsCustom:w,soulDraft:o,templateNameDraft:d,changePersonalizationTemplate:b,changeSoulDraft:P,openSaveAsNew:B,resetPersonalizationDraft:A,savePersonalization:R,setSaveAsNewOpen:h,setTemplateNameDraft:f}}function yl({connection:s,onError:n,onPreferences:a,onProviders:t,preferences:l,providers:i}){const[c,o]=r.useState(l.defaultChatProvider),[u,d]=r.useState(l.defaultChatModel),[f,p]=r.useState(!1),[h,g]=r.useState(null),[x,y]=r.useState(null);r.useEffect(()=>{o(l.defaultChatProvider),d(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function w(v){if(v.preventDefault(),!!s){p(!0),n(null);try{a(await M.savePreferences(s,{defaultChatProvider:c,defaultChatModel:Xe(c,u,i)}))}catch(j){n(j instanceof Error?j.message:String(j))}finally{p(!1)}}}function S(v){o(v),d(j=>Xe(v,j,i))}async function C(v,j,$){if(!s)return null;g(`${v}:${j}`),y(null),n(null);try{return await $()}catch(O){return n(O instanceof Error?O.message:String(O)),null}finally{g(null)}}async function k(v,j){await C(v,"config",async()=>{const $=await M.saveProviderSettings(s,{providers:{[v]:j}});return t($),$})}async function R(v,j){await C(v,"credential",async()=>{const $=await M.saveProviderCredential(s,v,j);return t($),$})}async function b(v){await C(v,"credential",async()=>{const j=await M.deleteProviderCredential(s,v,{});return t(j),j})}async function A(v){return C("openai","credential",async()=>{const j=await M.startOpenAiSubscriptionAuth(s,{method:v});return j.method==="browser"?(window.open(j.url,"_blank","noopener,noreferrer"),y("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(j.url,"_blank","noopener,noreferrer"),y(`OpenAI device login started. Enter code ${j.userCode}.`)),P(j.expiresAt),j})}async function P(v){if(s)for(;Date.now()<v;){await new Promise(j=>setTimeout(j,2500));try{const j=await M.providerSettings(s);t(j);const $=j.statuses.openai?.credential;if($?.connected&&$.source==="chatgpt_subscription"){y("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function B(v){await C(v,"models",async()=>{const j=await M.refreshProviderModels(s,v,{force:!0});return t(j.providers),j})}async function m(v){await C(v,"models",async()=>{const j=await M.loadProviderModels(s,v,{limit:500});return t(j.providers),j})}async function N(v,j={}){await C(v,"validate",async()=>{const $=await M.validateProviderCredential(s,v,j);return y($.ok?`${v} validated${$.modelId?` with ${$.modelId}`:""}.`:$.errors.join(`
|
|
6
|
+
`)||`${v} validation failed.`),t($.providers),$})}return{defaultModel:u,defaultProvider:c,providerBusy:h,saving:f,validationMessage:x,changeDefaultProvider:S,deleteProviderCredential:b,loadProviderModels:m,refreshProviderModels:B,saveProviderConfig:k,saveProviderCredential:R,saveProviders:w,setDefaultModel:d,startOpenAiSubscriptionAuth:A,validateProvider:N}}function Nl({connection:s,enabled:n,onError:a,onToast:t}){const[l,i]=r.useState(null),[c,o]=r.useState(null),[u,d]=r.useState(!1),f=r.useRef(null),p=r.useCallback(async(A={})=>{if(s){A.quiet||o("refresh");try{const P=await M.remoteAccess(s);i(P),a(null)}catch(P){a(P instanceof Error?P.message:String(P))}finally{A.quiet||o(null)}}},[s,a]);r.useEffect(()=>{!n||!s||p({quiet:!0})},[s,n,p]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);function h(){f.current!==null&&window.clearTimeout(f.current),d(!1),window.setTimeout(()=>{d(!0),f.current=window.setTimeout(()=>{d(!1),f.current=null},1500)},0)}async function g(){if(a(null),!!s)try{i(await M.remoteAccess(s))}catch{}}async function x(){if(!s)return null;l&&!l.tailscale.running&&h(),o("enable");try{const A=await M.enableRemoteAccess(s);return i(A.status),a(null),A.status.tailscale.running?!A.status.serve.enabled&&A.status.serve.error&&t?.(A.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":A.message||A.status.serve.error,"error"):(h(),t?.(A.message||"Tailscale is not running. Run Tailscale up first.","error")),A.status}catch{return await g(),h(),t?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{o(null)}}async function y(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){o("disable");try{const A=await M.disableRemoteAccess(s);i(A.status),a(null)}catch{await g()}finally{o(null)}}}async function w(){l?.remoteWebUrl&&(o("copy-link"),await ve(l.remoteWebUrl),o(null))}async function S(){l?.serveCommand&&(o("copy-command"),await ve(l.serveCommand),o(null))}async function C(){l?.serve.setupUrl&&(o("copy-serve-setup"),await ve(l.serve.setupUrl),o(null))}async function k(){l?.tailscaleUpCommand&&(o("copy-up-command"),await ve(l.tailscaleUpCommand),o(null))}async function R(){l?.operatorCommand&&(o("copy-operator"),await ve(l.operatorCommand),o(null))}async function b(){if(!l?.serve.enabled){const A=await x();A?.serve.enabled&&A.remoteWebUrl&&await ve(A.remoteWebUrl);return}await w()}return{status:l,busy:c,flashTailscaleUp:u,refresh:p,enableRemoteAccess:x,disableRemoteAccess:y,copyRemoteLink:w,copyTailscaleUpCommand:k,copyServeCommand:S,copyServeSetupUrl:C,copyOperatorCommand:R,createRemoteLink:b}}function wl(s){const[n,a]=r.useState(null),[t,l]=r.useState(null),i=r.useCallback(async()=>{if(s.connection){l("load");try{a(await M.datasetStorageState(s.connection)),s.onError(null)}catch(o){s.onError(o instanceof Error?o.message:String(o))}finally{l(null)}}},[s.connection,s.onError]),c=r.useCallback(async o=>{if(!s.connection||!o)return!1;l("save");try{return a(await M.updateDatasetStorage(s.connection,o)),s.onError(null),!0}catch(u){return s.onError(u instanceof Error?u.message:String(u)),!1}finally{l(null)}},[s.connection,s.onError]);return r.useEffect(()=>{s.enabled&&i()},[s.enabled,i]),{state:n,busy:t,refresh:i,save:c}}function Sl(s){const{connection:n,enabled:a,onError:t,profileId:l}=s,[i,c]=r.useState(null),[o,u]=r.useState(!1),d=r.useCallback(async()=>{if(n){u(!0);try{c(await M.datasetCatalog(n,l)),t(null)}catch(f){t(Cl(f))}finally{u(!1)}}},[n,t,l]);return r.useEffect(()=>{a&&d()},[a,d]),{catalog:i,loading:o,refresh:d}}function Cl(s){return s instanceof Error?s.message:String(s)}const kl=new Set(["harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases"]);function Pl(s){return s==="harness-refiner"?"refiner":s==="harness-continuous-review"?"continuous-review":s==="harness-contents"?"contents":s==="harness-releases"?"releases":"overview"}const Rl=r.lazy(()=>Un(()=>import("./UsageSettingsSection-Bdvm66WK.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function Wl({payload:s,connection:n,diagnostics:a,onPayload:t,onError:l,onToast:i,onBack:c,onOpenSourceSession:o,onAcceptEvaluationReview:u,onOpenSkill:d,onOpenExtension:f,teamChatCurrentUserId:p,teamChatEnabled:h,teamChatNotificationMode:g,teamChatThreads:x,onTeamChatNotificationModeChange:y,onTeamChatThreadMuteChange:w,diffPanelWidth:S,diffPanelResizing:C,diffPanelExpanded:k,onDiffPanelResizeStart:R,onDiffPanelExpandedChange:b,initialSection:A="account"}){const[P,B]=r.useState(A),[m,N]=r.useState(null),[v,j]=r.useState(!1),$=s?.codex??null,O=r.useMemo(()=>In(s?.preferences),[s?.preferences]),G=s?.personalization??Mn,Y=a??s?.diagnostics??[],ee=On()&&Tn(n?.platform),E=r.useCallback(X=>{s&&t({...s,providers:X})},[t,s]),L=r.useCallback(X=>{s&&t({...s,preferences:X.preferences})},[t,s]),te=r.useCallback(X=>{s&&t({...s,extensionCatalog:X})},[t,s]),Q=ul({connection:n,onError:l,onPayload:t}),J=yl({connection:n,onError:l,onPayload:t,onPreferences:L,onProviders:E,preferences:O,providers:s?.providers??null}),Z=hl({connection:n,onError:l,onPayload:t,onPreferences:L,preferences:O,providers:s?.providers??null}),K=bl({connection:n,enabled:P==="editor",onError:l,onPayload:t,onPreferences:L,onToast:i,preferences:O}),U=vl({connection:n,onError:l,onPayload:t,personalization:G}),ae=jl({onError:l,section:P}),ie=Nl({connection:n,enabled:P==="remote",onError:l,onToast:i}),ue=P==="dataset-storage",I=wl({connection:n,enabled:ue,onError:l}),z=Sl({connection:n,enabled:ue,onError:l,profileId:s?.profile.activeProfile??"default"}),V=I.save,se=r.useCallback(async()=>{await Promise.all([I.refresh(),z.refresh()])},[I.refresh,z.refresh]),de=r.useCallback(()=>P!=="subagents"||!Z.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[Z.subagentsDirty,P]),T=r.useCallback(X=>{X!==P&&de()&&(j(!1),b(!1),B(X))},[de,b,P]),_=r.useCallback(()=>{de()&&(j(!1),b(!1),c())},[de,c,b]);r.useEffect(()=>{B(A)},[A]),r.useEffect(()=>{if(P!=="subagents"||!Z.subagentsDirty)return;const X=Ce=>{Ce.preventDefault(),Ce.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",X),()=>window.removeEventListener("beforeunload",X)},[Z.subagentsDirty,P]);const F={"--diff-panel-width":`${S}px`},H=kl.has(P),W=H&&v&&m;return e.jsxs("div",{className:`settings-shell ${ee?"platform-macos":""} ${W?"harness-diff-open":""} ${k?"harness-diff-expanded":""} ${C?"diff-panel-resizing":""}`,style:F,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[H?e.jsx("button",{type:"button",className:`topbar-diff-button ${W?"active":""}`,title:`${W?"Hide":"Show"} sidebar`,"aria-label":`${W?"Hide":"Show"} sidebar`,"aria-pressed":!!W,disabled:!m,onClick:()=>j(X=>!X),children:e.jsx(Ln,{size:16})}):null,e.jsx(zn,{platform:n?.platform})]}),e.jsx(Ra,{section:P,onBack:_,onSectionChange:T}),e.jsx("main",{className:`settings-content ${P==="profile"||H?"settings-content-wide":""}`,children:P==="account"?e.jsx(ft,{payload:s,connection:n,onPayload:t,onPreferences:L,onError:l,onToast:i,...Q}):P==="notifications"?e.jsx(It,{currentUserId:p,enabled:h,mode:g,threads:x,onModeChange:y,onThreadMuteChange:w}):H?e.jsx(cl,{connection:n,enabled:H,onAcceptEvaluationReview:u,onError:l,onDefaultReleaseDiff:N,onOpenSourceSession:o,onOpenReleaseDiff:X=>{N(X),j(!0)},onToast:i,page:Pl(P)}):P==="profile"?e.jsx(Yt,{payload:s,connection:n,onPayload:t,onError:l,onToast:i}):P==="skills"?e.jsx(Da,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:n,onExtensionCatalog:te,onError:l,onToast:i,onOpenSkill:d,onOpenExtension:f}):P==="providers"?e.jsx(ba,{account:s?.account??null,codex:$,providers:s?.providers??null,...J}):P==="dataset-storage"?e.jsx(Ha,{state:I.state,catalog:z.catalog,busy:I.busy,catalogLoading:z.loading,onRefresh:se,onSave:V}):P==="defaults"?e.jsxs("div",{className:"settings-stacked-sections",children:[e.jsx(bt,{preferences:O,...Z}),e.jsx(bs,{embedded:!0,preferences:O,...Z})]}):P==="context"?e.jsx(bs,{preferences:O,...Z}):P==="training"?e.jsx($a,{connection:n,onError:l,onPreferences:L,preferences:O,providers:s?.providers??null}):P==="subagents"?e.jsx(Ct,{preferences:O,providers:s?.providers??null,...Z}):P==="editor"?e.jsx(St,{preferences:O,...K}):P==="remote"?e.jsx(wa,{...ie}):P==="usage"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(Rl,{account:s?.account??null,connection:n,enabled:P==="usage",onError:l,onOpenSourceSession:o})}):P==="personalization"?e.jsx(Ot,{...U}):e.jsx(vt,{diagnostics:Y,...ae})}),H&&n&&W?e.jsx(dl,{connection:n,expanded:k,onResizeStart:R,onToggleExpanded:()=>b(!k),selection:W}):null]})}export{Wl as SettingsView};
|