openpond 0.2.16 → 0.2.17

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.
Files changed (85) hide show
  1. package/dist/app-server.js +1 -1
  2. package/dist/chunks/{app-server-runtime-TAFUJGQS.js → app-server-runtime-Q7NJ6PXF.js} +1 -1
  3. package/dist/chunks/{chunk-3QVNGZFY.js → chunk-BE35DIOI.js} +1 -1
  4. package/dist/chunks/{chunk-RFPSEQO2.js → chunk-CULWDNK3.js} +218 -218
  5. package/dist/chunks/{chunk-OTUTSGMI.js → chunk-G54T4IWQ.js} +1 -1
  6. package/dist/chunks/{chunk-UQ4OBVRS.js → chunk-GHKJKXDF.js} +1 -1
  7. package/dist/chunks/{cli-AUDD3IP5.js → cli-BCBRWI2M.js} +1 -1
  8. package/dist/chunks/{src-VWAWQGVE.js → src-ITECV3AD.js} +25 -25
  9. package/dist/chunks/{workspaces-EGHYKQZF.js → workspaces-WI56RXUN.js} +1 -1
  10. package/dist/cli.js +1 -1
  11. package/dist/web/assets/{App-BGI70Zj6.js → App-DQfdLgyV.js} +3 -3
  12. package/dist/web/assets/{AppDialog-D4siaKMi.js → AppDialog-BnldMLvF.js} +1 -1
  13. package/dist/web/assets/{AppTerminalPanel-DSaxM9R8.js → AppTerminalPanel-DR5SeX9y.js} +2 -2
  14. package/dist/web/assets/{AppsView-C14dtBI0.js → AppsView-Bu_XEgkd.js} +1 -1
  15. package/dist/web/assets/{BrowserSidebar-BbB0tvuH.js → BrowserSidebar-BdKPWbN8.js} +1 -1
  16. package/dist/web/assets/{CartesianChart-GJVxLGBn.js → CartesianChart-CSkLcF_5.js} +1 -1
  17. package/dist/web/assets/{CollaborationTabs-wT2ymsi7.js → CollaborationTabs-C9cRq5ob.js} +1 -1
  18. package/dist/web/assets/{CommandMenu-DLe1d-iP.js → CommandMenu-Deqzk3u9.js} +1 -1
  19. package/dist/web/assets/{CommunityView-BoTn5n7e.js → CommunityView-B5dKYacH.js} +1 -1
  20. package/dist/web/assets/{ComposerCreateImproveStrip-S2sXX8UJ.js → ComposerCreateImproveStrip-5LPlQFN4.js} +1 -1
  21. package/dist/web/assets/{GetStartedView-DhpWR1nb.js → GetStartedView-DmuGykfx.js} +1 -1
  22. package/dist/web/assets/HostedModelLearningReview-BRPSFNza.js +1 -0
  23. package/dist/web/assets/{HostedModelLearningSettings-BN4bvlGK.js → HostedModelLearningSettings-BsdX-CkH.js} +1 -1
  24. package/dist/web/assets/{LabModelVersionDetailPage-B0jRK9u9.js → LabModelVersionDetailPage-BUO5cpDh.js} +1 -1
  25. package/dist/web/assets/{LabSkillSidebar-CoHjFsXh.js → LabSkillSidebar-mTpdM-G8.js} +1 -1
  26. package/dist/web/assets/{LabsRoute-B5UTYHeh.js → LabsRoute-BhfxBg5_.js} +4 -4
  27. package/dist/web/assets/{MainChatThread-CcH2yLdM.js → MainChatThread-BAxA18lN.js} +2 -2
  28. package/dist/web/assets/{MainPane-BT58d6eG.js → MainPane-Dv5USGqR.js} +4 -4
  29. package/dist/web/assets/{MarkdownText-D43uIpOy.js → MarkdownText-DWGLUbdE.js} +1 -1
  30. package/dist/web/assets/{Messages-DarNW0e1.js → Messages-CuhCtaya.js} +1 -1
  31. package/dist/web/assets/{NativeSkillSidebar-3yNmqIFw.js → NativeSkillSidebar-B8OMVpPT.js} +1 -1
  32. package/dist/web/assets/{NewExperienceSwitcher-Cle9jAk2.js → NewExperienceSwitcher-kIKV8_Wd.js} +1 -1
  33. package/dist/web/assets/{NewProjectDialog-DFAGQHU5.js → NewProjectDialog-B-7dHoT6.js} +1 -1
  34. package/dist/web/assets/{OutputsPage-BvoFsIeo.js → OutputsPage-C4DRT8pF.js} +1 -1
  35. package/dist/web/assets/{ProjectsPage-DLo3YoMa.js → ProjectsPage-CLjW6Kc3.js} +1 -1
  36. package/dist/web/assets/{RightChatPanelStack-B4v_t1S8.js → RightChatPanelStack-C4-4VLb-.js} +1 -1
  37. package/dist/web/assets/{RightSidebarHomePanel-jZW_Bepf.js → RightSidebarHomePanel-CVbfOg2p.js} +1 -1
  38. package/dist/web/assets/{ScheduledWorkPage-DLX-weE0.js → ScheduledWorkPage-CWzwbOOZ.js} +1 -1
  39. package/dist/web/assets/{SettingsView-Bjf1bZOw.js → SettingsView-BIwO8elm.js} +6 -6
  40. package/dist/web/assets/{SettingsView-B9Tn0_zX.css → SettingsView-BaWWvIJW.css} +1 -1
  41. package/dist/web/assets/{TeamChatView-BqhLy7OA.js → TeamChatView-miR9w_53.js} +1 -1
  42. package/dist/web/assets/{TerminalOverlay-CJTUNqkk.js → TerminalOverlay-BOmx_hJX.js} +1 -1
  43. package/dist/web/assets/{TrainingCreationPanel-smGwEmo9.js → TrainingCreationPanel-DSRejaYV.js} +1 -1
  44. package/dist/web/assets/{TrainingDraftPanel-B2UKQHN3.js → TrainingDraftPanel-XBH6Uh0_.js} +1 -1
  45. package/dist/web/assets/{UsageSettingsSection-eyvYtzgi.js → UsageSettingsSection-DROtDdak.js} +1 -1
  46. package/dist/web/assets/{WorkSidebarPanel-DoruAoEt.js → WorkSidebarPanel-CHwObGs6.js} +1 -1
  47. package/dist/web/assets/{WorkspaceDiffPanel-DeHSMDXy.js → WorkspaceDiffPanel-BoB_1R8w.js} +3 -3
  48. package/dist/web/assets/{WorkspaceEnvironmentMenu-sgYQj7uK.js → WorkspaceEnvironmentMenu-Dvqy2NJP.js} +1 -1
  49. package/dist/web/assets/{WorkspaceGitDialogs-WpfoEpEk.js → WorkspaceGitDialogs-BC45mifk.js} +1 -1
  50. package/dist/web/assets/{WorkspaceMonacoEditor-jqG5AL7d.js → WorkspaceMonacoEditor-cDO3Elh0.js} +3 -3
  51. package/dist/web/assets/{arrow-up-right-Dw1pcY62.js → arrow-up-right-Dv3nebbh.js} +1 -1
  52. package/dist/web/assets/{chat-file-links-BYbiaIO1.js → chat-file-links-DQYtkwit.js} +1 -1
  53. package/dist/web/assets/chevron-up-BUOpWd2a.js +1 -0
  54. package/dist/web/assets/{clipboard-Dfk4RCIt.js → clipboard-CnNPmg50.js} +1 -1
  55. package/dist/web/assets/{cloud-upload-BCFuH4X6.js → cloud-upload-DisZOwXE.js} +1 -1
  56. package/dist/web/assets/{cssMode-D4TD1xov.js → cssMode-Bd8sFlb5.js} +1 -1
  57. package/dist/web/assets/{folder-open-DvI8m5Sx.js → folder-open-D0PIN0Cj.js} +1 -1
  58. package/dist/web/assets/{folder-plus-By8mYY0v.js → folder-plus-DTNZNwa9.js} +1 -1
  59. package/dist/web/assets/{git-commit-horizontal-BaO4kijC.js → git-commit-horizontal-C0QdA7uv.js} +1 -1
  60. package/dist/web/assets/{htmlMode-M02_qd4A.js → htmlMode-Cu-nKV7Z.js} +1 -1
  61. package/dist/web/assets/{index-BvXW3YXD.js → index-De4k_YMo.js} +2 -2
  62. package/dist/web/assets/{info-Dc_GhhOz.js → info-B-n_omgE.js} +1 -1
  63. package/dist/web/assets/{jsonMode-DiQI8vFK.js → jsonMode-B377iBCv.js} +1 -1
  64. package/dist/web/assets/{lspLanguageFeatures-tEe-JDHC.js → lspLanguageFeatures-BBHfVtV0.js} +1 -1
  65. package/dist/web/assets/{minimize-2-DGtAI2xp.js → minimize-2-C6JQGKgk.js} +1 -1
  66. package/dist/web/assets/{monaco.contribution-BdUm7liL.js → monaco.contribution-B0l6Oe3a.js} +2 -2
  67. package/dist/web/assets/{monaco.contribution-1SG8tKDo.js → monaco.contribution-BDLeUQLG.js} +2 -2
  68. package/dist/web/assets/{monaco.contribution-4H5UNLKI.js → monaco.contribution-CCSCAu65.js} +2 -2
  69. package/dist/web/assets/{monaco.contribution-COeaSn0J.js → monaco.contribution-CIq6sYw4.js} +2 -2
  70. package/dist/web/assets/{play-Dm-ygxKN.js → play-B5O4Hz_W.js} +1 -1
  71. package/dist/web/assets/{python-rqeHprul.js → python-BQkq0gZA.js} +1 -1
  72. package/dist/web/assets/{refresh-cw-BIkrZ0pv.js → refresh-cw-D2E-pp4H.js} +1 -1
  73. package/dist/web/assets/{save-EdH_bDsl.js → save-CPNNuWwp.js} +1 -1
  74. package/dist/web/assets/{square-pCmN_gDj.js → square-DUgXVoF0.js} +1 -1
  75. package/dist/web/assets/{toggleHighContrast-BJSQSsib.js → toggleHighContrast-BbQBtO9I.js} +1 -1
  76. package/dist/web/assets/{tsMode-3mUrkBEX.js → tsMode-CsVhouTE.js} +1 -1
  77. package/dist/web/assets/{upload-BPPE0xhi.js → upload-t7xHt3GY.js} +1 -1
  78. package/dist/web/assets/{useLocalAgentSchedules-CHOz2V-t.js → useLocalAgentSchedules-D4lJelHt.js} +1 -1
  79. package/dist/web/assets/{wifi-off-217UMa2b.js → wifi-off-B_QPKtA-.js} +1 -1
  80. package/dist/web/assets/{workers-T9yMlI_c.js → workers-p7TrE4Qa.js} +1 -1
  81. package/dist/web/assets/{yaml-DjGDwz3-.js → yaml-C8adeAyH.js} +1 -1
  82. package/dist/web/index.html +1 -1
  83. package/package.json +1 -1
  84. package/dist/web/assets/HostedModelLearningReview-BHboiGq4.js +0 -1
  85. package/dist/web/assets/chevron-up-DI8qm7Ek.js +0 -1
@@ -1,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-eyvYtzgi.js","./index-BvXW3YXD.js","./index-C5EoPZr0.css","./App-BGI70Zj6.js","./App-7h_oHCFd.css","./arrow-up-right-Dw1pcY62.js","./CartesianChart-GJVxLGBn.js","./UsageSettingsSection-Csg3diiE.css"])))=>i.map(i=>d[i]);
2
- import{r,j as e,_ as Cn}from"./index-BvXW3YXD.js";import{c as je,ay as gs,t as Rn,az as xs,aA as Pn,aB as ls,X as ce,aC as is,aD as Ks,aE as An,aF as Dn,aG as In,aH as $n,aI as En,v as $,aJ as Mn,P as ge,D as Ie,aK as On,aL as Js,aM as Ln,aN as Ze,aO as Ys,aP as Tn,aQ as zn,aR as Un,W as Qs,G as Be,aS as Bn,H as Hn,Y as Te,h as rs,aT as Xe,aU as Ge,af as _n,C as Fn,aV as Me,I as es,aW as Gn,m as ze,aX as oe,aY as qn,aZ as ss,a_ as ns,a$ as Zs,b0 as Wn,g as Vn,av as Xs,b1 as Kn,ar as js,B as Jn,f as en,b2 as Yn,b3 as Qn,x as Zn,b4 as Xn,U as ts,a6 as qe,b5 as Ne,aj as et,b6 as st,b7 as nt,b8 as tt,b9 as at,ba as lt,bb as it}from"./App-BGI70Zj6.js";import{R as ae}from"./refresh-cw-BIkrZ0pv.js";import{T as ke,P as sn,B as He,W as rt,A as ot,C as ct}from"./chat-file-links-BYbiaIO1.js";/* empty css */import{S as os}from"./save-EdH_bDsl.js";import{F as nn}from"./folder-open-DvI8m5Sx.js";import{C as dt}from"./chevron-up-DI8qm7Ek.js";import{P as tn}from"./play-Dm-ygxKN.js";import{B as ut,a as an,W as ht,S as mt}from"./wifi-off-217UMa2b.js";import{R as _e,u as pt}from"./useLocalAgentSchedules-CHOz2V-t.js";import{C as xe}from"./cloud-upload-BCFuH4X6.js";import{G as Ue}from"./git-commit-horizontal-BaO4kijC.js";import{F as ft}from"./folder-plus-By8mYY0v.js";import{A as gt}from"./AppDialog-D4siaKMi.js";import{C as ln,W as xt}from"./WorkspaceDiffPanel-DeHSMDXy.js";import"./MarkdownText-D43uIpOy.js";import"./desktop-files-BQj1J-ob.js";import"./training-model-data-CKOkpBBL.js";import"./info-Dc_GhhOz.js";import"./minimize-2-DGtAI2xp.js";import"./clipboard-Dfk4RCIt.js";const jt=[["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"}]],vt=je("clipboard-copy",jt);const bt=[["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"}]],yt=je("eye",bt);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"}]],wt=je("hard-drive",Nt);const St=[["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=je("key-round",St);const kt=[["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"}]],rn=je("radio-tower",kt);const Ct=[["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"}]],Rt=je("rotate-cw",Ct);const Pt=[["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"}]],At=je("sliders-horizontal",Pt);const Dt=[["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"}]],vs=je("circle-user",Dt);function bs({connection:s,bannerOnly:n=!1,onOpen:a,onSaved:t}){const[l,i]=r.useState(null),[d,c]=r.useState(null),[m,p]=r.useState(null),[o,f]=r.useState(!1),[u,h]=r.useState(null),[j,y]=r.useState(!1),[w,R]=r.useState(gs);Rn(()=>R(gs()));const P=r.useRef(0),k=r.useCallback(async x=>{if(!s)return;const A=++P.current,L=await xs(s,"/v1/configuration",{signal:x});!x?.aborted&&A===P.current&&i(L)},[s]);r.useEffect(()=>{i(null),c(null),p(null),h(null);const x=new AbortController,A=()=>{k(x.signal).catch(E=>{x.signal.aborted||h(String(E))})};A();const L=window.setInterval(A,3e3);return()=>{P.current+=1,x.abort(),window.clearInterval(L)}},[k]);async function C(x,A){if(!(!s||!l)){y(!0),h(null);try{const L=x==="restore"?{action:x,revision:A,expectedRevision:l.rawRevision}:x==="validate"?{action:x,text:d??l.text??`schema_version = 1
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-DROtDdak.js","./index-De4k_YMo.js","./index-C5EoPZr0.css","./App-DQfdLgyV.js","./App-7h_oHCFd.css","./arrow-up-right-Dv3nebbh.js","./CartesianChart-CSkLcF_5.js","./UsageSettingsSection-Csg3diiE.css"])))=>i.map(i=>d[i]);
2
+ import{r,j as e,_ as Cn}from"./index-De4k_YMo.js";import{c as je,ay as gs,t as Rn,az as xs,aA as Pn,aB as ls,X as ce,aC as is,aD as Ks,aE as An,aF as Dn,aG as In,aH as $n,aI as En,v as $,aJ as Mn,P as ge,D as Ie,aK as On,aL as Js,aM as Ln,aN as Ze,aO as Ys,aP as Tn,aQ as zn,aR as Un,W as Qs,G as Be,aS as Bn,H as Hn,Y as Te,h as rs,aT as Xe,aU as Ge,af as _n,C as Fn,aV as Me,I as es,aW as Gn,m as ze,aX as oe,aY as qn,aZ as ss,a_ as ns,a$ as Zs,b0 as Wn,g as Vn,av as Xs,b1 as Kn,ar as js,B as Jn,f as en,b2 as Yn,b3 as Qn,x as Zn,b4 as Xn,U as ts,a6 as qe,b5 as Ne,aj as et,b6 as st,b7 as nt,b8 as tt,b9 as at,ba as lt,bb as it}from"./App-DQfdLgyV.js";import{R as le}from"./refresh-cw-D2E-pp4H.js";import{T as ke,P as sn,B as He,W as rt,A as ot,C as ct}from"./chat-file-links-DQYtkwit.js";/* empty css */import{S as os}from"./save-CPNNuWwp.js";import{F as nn}from"./folder-open-D0PIN0Cj.js";import{C as dt}from"./chevron-up-BUOpWd2a.js";import{P as tn}from"./play-B5O4Hz_W.js";import{B as ut,a as an,W as ht,S as mt}from"./wifi-off-B_QPKtA-.js";import{R as _e,u as pt}from"./useLocalAgentSchedules-D4lJelHt.js";import{C as xe}from"./cloud-upload-DisZOwXE.js";import{G as Ue}from"./git-commit-horizontal-C0QdA7uv.js";import{F as ft}from"./folder-plus-DTNZNwa9.js";import{A as gt}from"./AppDialog-BnldMLvF.js";import{C as ln,W as xt}from"./WorkspaceDiffPanel-BoB_1R8w.js";import"./MarkdownText-DWGLUbdE.js";import"./desktop-files-BQj1J-ob.js";import"./training-model-data-CKOkpBBL.js";import"./info-B-n_omgE.js";import"./minimize-2-C6JQGKgk.js";import"./clipboard-CnNPmg50.js";const jt=[["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"}]],vt=je("clipboard-copy",jt);const bt=[["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"}]],yt=je("eye",bt);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"}]],wt=je("hard-drive",Nt);const St=[["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=je("key-round",St);const kt=[["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"}]],rn=je("radio-tower",kt);const Ct=[["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"}]],Rt=je("rotate-cw",Ct);const Pt=[["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"}]],At=je("sliders-horizontal",Pt);const Dt=[["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"}]],vs=je("circle-user",Dt);function bs({connection:s,bannerOnly:n=!1,onOpen:a,onSaved:t}){const[l,i]=r.useState(null),[d,c]=r.useState(null),[m,p]=r.useState(null),[o,f]=r.useState(!1),[u,h]=r.useState(null),[j,y]=r.useState(!1),[w,R]=r.useState(gs);Rn(()=>R(gs()));const P=r.useRef(0),k=r.useCallback(async x=>{if(!s)return;const A=++P.current,L=await xs(s,"/v1/configuration",{signal:x});!x?.aborted&&A===P.current&&i(L)},[s]);r.useEffect(()=>{i(null),c(null),p(null),h(null);const x=new AbortController,A=()=>{k(x.signal).catch(E=>{x.signal.aborted||h(String(E))})};A();const L=window.setInterval(A,3e3);return()=>{P.current+=1,x.abort(),window.clearInterval(L)}},[k]);async function C(x,A){if(!(!s||!l)){y(!0),h(null);try{const L=x==="restore"?{action:x,revision:A,expectedRevision:l.rawRevision}:x==="validate"?{action:x,text:d??l.text??`schema_version = 1
3
3
  `}:{action:x,text:d??l.text??`schema_version = 1
4
4
  `,expectedRevision:m??l.rawRevision};await xs(s,"/v1/configuration",{method:"POST",body:JSON.stringify(L)}),x!=="validate"&&(c(null),p(null),await k(),await t?.()),h(x==="validate"?"Configuration is valid.":"Saved. Changes apply to the next turn.")}catch(L){h(L instanceof Error?L.message:String(L))}finally{y(!1)}}}return!s||n&&!l?.issue&&!w?null:e.jsxs("section",{className:`account-settings configuration-settings ${n?"configuration-banner":""}`,"aria-label":"Configuration",children:[n?null:e.jsxs("header",{children:[e.jsx("h1",{children:"Configuration"}),e.jsx("p",{children:"Manage your settings in one TOML file. The controls below save to the same file; unset an override to inherit its default."})]}),w?e.jsxs("p",{role:"alert",children:[w," ",e.jsx("button",{type:"button",onClick:Pn,children:"Retry saving preferences"})]}):null,l?.issue?e.jsxs("div",{role:"alert",children:[e.jsx("strong",{children:"Configuration needs attention"}),e.jsx("p",{children:l.issue.message}),e.jsx("p",{children:e.jsxs("code",{children:[l.issue.path,l.issue.line?`:${l.issue.line}:${l.issue.column??1}`:""]})}),e.jsxs("p",{children:[l.issue.action," Affected turns are blocked until this is corrected."]}),e.jsx("button",{type:"button",onClick:()=>{n?a?.():f(!0)},children:"Open configuration"})]}):null,n?null:e.jsxs("details",{open:o,onToggle:x=>f(x.currentTarget.open),children:[e.jsx("summary",{children:"Configuration file and sources"}),e.jsx("p",{children:e.jsx("code",{children:l?.path??"Loading…"})}),e.jsx("p",{children:"Unset an override to inherit its default. Changes apply to the next turn; current turns retain their model settings."}),e.jsx("textarea",{"aria-label":"TOML configuration",spellCheck:!1,rows:18,style:{width:"100%",fontFamily:"monospace"},value:d??l?.text??`schema_version = 1
5
- `,onChange:x=>{d===null&&p(l?.rawRevision??null),c(x.target.value)}}),d!==null&&l?.rawRevision!==m?e.jsx("p",{role:"alert",children:"The file changed elsewhere. Reload before saving your edits."}):null,e.jsxs("div",{className:"configuration-actions",children:[e.jsx("button",{type:"button",disabled:j||!l,onClick:()=>{C("validate")},children:"Validate"}),e.jsx("button",{type:"button",disabled:j||!l||d!==null&&l.rawRevision!==m,onClick:()=>{C("replace")},children:"Save config"}),e.jsx("button",{type:"button",disabled:j,onClick:()=>{c(null),p(null),k().catch(x=>h(String(x)))},children:"Reload file"})]}),l?.recoverableRevisions.length?e.jsxs("label",{children:["Restore a verified revision ",e.jsxs("select",{value:"",disabled:j,onChange:x=>{x.target.value&&C("restore",x.target.value)},children:[e.jsx("option",{value:"",children:"Choose a revision…"}),l.recoverableRevisions.map(x=>e.jsxs("option",{value:x.revision,children:[new Date(x.createdAt).toLocaleString()," · ",x.revision.slice(0,12)]},x.revision))]})]}):null,l?.effective?e.jsxs("details",{children:[e.jsx("summary",{children:"Effective values and sources"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Setting"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Location"})]})}),e.jsx("tbody",{children:Object.entries(l.effective.provenance).map(([x,A])=>e.jsxs("tr",{children:[e.jsx("td",{children:JSON.parse(x).join(".")}),e.jsx("td",{children:A.layer==="user"?"Set here":`Inherited from ${A.layer}`}),e.jsx("td",{children:A.path})]},x))})]}),e.jsx("pre",{children:JSON.stringify(l.effective.document,null,2)})]}):null]}),u?e.jsx("p",{role:"status",children:u}):null]})}function ys({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 We({state:s,label:n}){return e.jsx("span",{className:`account-state ${s}`,children:n??s.replace("_"," ")})}const Ns="https://openpond.ai",ws="https://api.openpond.ai";function It(s,n){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:n?.handle,currentBaseUrl:n?.baseUrl??null}}function $t(s,n){return s==="update"&&n?{baseUrl:n.baseUrl??Ns,apiBaseUrl:n.apiBaseUrl??ws,chatApiBaseUrl:n.chatApiBaseUrl,environment:n.environment??"production"}:{baseUrl:Ns,apiBaseUrl:ws,environment:"production"}}function Ss({account:s,busy:n,initialApiKey:a="",mode:t="update",onClose:l,onSave:i}){const d=r.useId(),c=t==="connect",[m,p]=r.useState(a),[o,f]=r.useState(null),[u,h]=r.useState(null);ls(u),r.useEffect(()=>{p(a),f(null),h(null)},[s?.handle,a]);async function j(y){y.preventDefault(),f(null),h(null);const w=m.trim();if(c&&!w){f("API key is required.");return}try{const R=It(t,s),P=$t(t,s);await i({...R,...P,apiKey:c?w:void 0})}catch(R){h(R instanceof Error?R.message:String(R))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&!n&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":d,onSubmit:y=>{j(y)},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:c?e.jsx(pe,{size:18}):e.jsx(is,{size:18})}),e.jsx("h2",{id:d,children:c?"Add account":"Account environment"}),c?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."}),c?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:m,onChange:y=>p(y.target.value)})]}):null,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",disabled:n,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:n,type:"submit",children:[e.jsx(os,{size:14}),e.jsx("span",{children:n?"Saving":c?"Connect account":"Update account"})]})]})]})})}const Et="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 Mt({payload:s,connection:n,saving:a,refreshingAccounts:t,saveAccount:l,refreshAccounts:i,switchAccount:d,removeAccount:c,onPayload:m,onPreferences:p,onError:o,onToast:f}){const u=s?.account,h=u?.state??"loading",j=h==="signed_in",y=h==="signed_out",w=h==="auth_error",R=u?.email?.trim()||null,P=u?.accounts??[],[k,C]=r.useState([]),[,x]=r.useState(!1),[A,L]=r.useState(null),[E,v]=r.useState(null),[S,N]=r.useState(null),[b,T]=r.useState(null),[_,F]=r.useState(!1),[J,W]=r.useState(null),[D,Y]=r.useState(null),[H,ee]=r.useState(!1),{confirmAction:X,confirmDialog:le,resolveConfirmDialog:G}=Ks(),g=P.find(O=>O.isActive)??P[0]??null,U=s?.preferences.defaultTeamId?.trim()||null,q=S??U,ie=An(u),de=s?.accountMeta.asOf??"",se=ve(u?.environment,g?.environment),ne=j?ve(g?.displayLabel,g?.handle,u?.label,u?.activeProfile?.handle,"Signed in"):w?"Account needs attention":y?"No account connected":"Loading account",ue=j?R??ks(se):w?"Not connected":y?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",he=P.length>0,re=w?Ot(u?.error):null,M=r.useMemo(()=>k.filter(O=>O.status==="active"),[k]),B=(r.useMemo(()=>q?M.find(O=>O.teamId===q)??null:null,[M,q])??Dn(M))?.teamId??"",Z=r.useMemo(()=>M.map(O=>({value:O.teamId,label:ve(O.displayName,O.name,O.slug,"Team"),description:In(O.role)})),[M]),Q=B||Z[0]?.value||"",Ae=Z.length>0,gn=!n||!!E||!!A||M.length===0,us=b?Ve(b):null,hs=!!(us&&J===us),xn=j||w,jn=ve(D?.version,s?.server.version,"Loading"),ms=D?D.devMode?"Dev mode":D.packaged?`${Ut(D.releaseChannel)} build`:"Local build":null,ps=Tt(ve(g?.baseUrl,u?.activeProfile?.baseUrl,u?.baseUrl,"https://openpond.ai"));r.useEffect(()=>{const O=window.openpond?.getDesktopRuntimeInfo;if(!O)return;let K=!1;return O().then(V=>{K||Y(V)}).catch(()=>{K||Y(null)}),()=>{K=!0}},[]),r.useEffect(()=>{if(!n||!ie){C([]),L(null),x(!1);return}let O=!1;const K=$n(ie);return K?(C(K),x(!1)):(C([]),x(!0)),L(null),En({accountKey:ie,force:!!de,fetchOrganizations:async()=>(await $.organizations(n)).organizations.map(Mn).filter(te=>!!te).filter(te=>te.status==="active")}).then(V=>{O||C(V)}).catch(V=>{O||(K||C([]),L(V instanceof Error?V.message:String(V)))}).finally(()=>{O||x(!1)}),()=>{O=!0}},[de,n,ie]),r.useEffect(()=>{S&&U===S&&N(null)},[U,S]);async function vn(O,K={notify:!0}){const V=M.find(te=>te.teamId===O)??null;if(!(!n||!V||E||(S??U)===V.teamId)){N(V.teamId),v(V.teamId),o(null),Ln({teamId:V.teamId,accountKey:ie,force:!0,fetchAgents:async te=>(await $.listSandboxAgents(n,{teamId:te})).agents}).catch(()=>{});try{p(await $.savePreferences(n,{defaultTeamId:V.teamId})),K.notify&&f?.("Default team updated","success")}catch(te){N(null),o(te instanceof Error?te.message:String(te))}finally{v(null)}}}async function Fe(O="Continue"){return xn?X({title:"Change active OpenPond account?",body:Et,confirmLabel:O,cancelLabel:"Cancel"}):!0}async function bn(O){await Fe("Save account")&&(await l({apiKey:O.apiKey??"",handle:O.handle,baseUrl:O.baseUrl,apiBaseUrl:O.apiBaseUrl,environment:O.environment}),F(!1))}async function yn(O){if(!n||!b)throw new Error("OpenPond server connection is not ready.");if(b.isActive&&!await Fe("Save endpoints"))return;const K=Ve(b);W(K),o(null);try{const V=await $.updateOpenPondAccountConfig(n,{handle:O.handle??b.handle,currentBaseUrl:O.currentBaseUrl,baseUrl:O.baseUrl,apiBaseUrl:O.apiBaseUrl,chatApiBaseUrl:O.chatApiBaseUrl,environment:Lt(O.environment),setActive:b.isActive});m(V),f?.("Account endpoints updated","success"),T(null)}catch(V){throw o(V instanceof Error?V.message:String(V)),V}finally{W(null)}}async function Nn(O){const K=O.handle?.trim()||"";K&&await Fe("Switch account")&&await d(K,O.baseUrl)}async function wn(O){const K=O.handle?.trim()||"";if(!K||O.isActive)return;const V=ve(O.displayLabel,O.email,O.handle,"this account");await X({title:"Remove saved account?",body:`Remove ${V} 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 c(K,O.baseUrl)&&f?.("Account removed","success")}async function Sn(){const O=window.openpond?.reloadDesktopApp;if(!(!O||H)){ee(!0),o(null);try{const K=await O();if(!K.ok)throw new Error(K.error??"OpenPond could not refresh the app.")}catch(K){ee(!1),o(K instanceof Error?K.message:String(K))}}}async function kn(){const O=window.openpond?.browser;O?.openExternal&&(await O.openExternal({conversationId:"openpond-account-sign-up",url:ps})).ok||window.open(ps,"_blank","noopener,noreferrer")}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:()=>F(!0),children:[e.jsx(ge,{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(ae,{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(ys,{handle:ne,image:j?u?.avatarUrl??g?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:ne}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:j&&R?"private-account-email":j?void 0:"account-summary-copy",tabIndex:j&&R?0:void 0,children:ue}),j&&Ae?e.jsx(Ie,{className:"account-team-dropdown",compact:!0,disabled:gn,label:"Default team",options:Z,value:Q,onChange:O=>{vn(O)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(We,{state:h,label:y?"not signed in":void 0})})]}),he?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:[P.length," account",P.length===1?"":"s"]})]}),e.jsx("p",{className:"account-list-note",children:"Switch to another account before removing the active account."}),P.map(O=>{const K=O.handle?.trim()||"",V=ve(O.displayLabel,O.handle,"Unknown account"),te=O.email?.trim()||null,fs=Ve(O);return e.jsxs("div",{className:"account-row",children:[e.jsx(ys,{handle:V,image:O.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:V}),te?e.jsx("span",{className:"private-account-email",tabIndex:0,children:te}):null,e.jsx("span",{children:ks(O.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(We,{state:O.authHealth}),O.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:"settings-icon-button ghost account-endpoint-action",disabled:!n||a||!!J||!K,type:"button","aria-label":`Configure ${V} environment`,title:"Configure account environment",onClick:()=>T(O),children:e.jsx(is,{size:15})}),O.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:a||!K,type:"button",onClick:()=>{Nn(O)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:a||!K,type:"button","aria-label":`Remove ${V}`,title:`Remove ${V}`,onClick:()=>{wn(O)},children:e.jsx(ke,{size:13})})]})]})]},fs)})]}):null,u?.products&&u.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:[u.products.length," active"]})]}),u.products.map(O=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:O.name}),e.jsx("span",{children:O.type})]}),e.jsx(We,{state:O.status})]},O.id))]}),e.jsxs("div",{className:"settings-footnote account-build-footnote",children:[e.jsxs("div",{className:"account-build-details",children:[e.jsx("span",{children:"Build version"}),e.jsxs("div",{className:"account-build-version",children:[e.jsx("strong",{children:zt(jn)}),ms?e.jsx("span",{className:`account-build-context${D?.devMode?" development":""}`,children:ms}):null]})]}),e.jsxs("div",{className:"account-build-actions",children:[D?.canReload?e.jsxs("button",{className:"settings-secondary compact",disabled:H,type:"button",title:"Reload the local Electron app",onClick:()=>{Sn()},children:[e.jsx(ae,{className:H?"settings-spin":void 0,size:14}),e.jsx("span",{children:H?"Refreshing":"Refresh app"})]}):null,j?null:e.jsxs("button",{className:"settings-primary compact account-sign-up-action",type:"button",onClick:()=>{kn()},children:[e.jsx("span",{children:"Sign up"}),e.jsx(On,{size:13})]})]})]}),re?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:re})]}):null,b?e.jsx(Ss,{account:b,busy:hs,onClose:()=>{hs||T(null)},onSave:yn}):null,_?e.jsx(Ss,{busy:a,mode:"connect",onClose:()=>{a||F(!1)},onSave:bn}):null,e.jsx(Js,{state:le,onResolve:G})]})}function Ve(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function ve(...s){for(const n of s){const a=n?.trim();if(a)return a}return""}function Ot(s){const n=s?.trim();if(!n)return null;const a=n.toLowerCase();return a.includes("protected deployment")?"OpenPond could not reach the account service. Restart and try again.":a.includes("unexpected token '<'")||a.includes("<!doctype")?"OpenPond received a web login page instead of account data. Restart and 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 ks(s){const n=s.trim().toLowerCase();return!n||n==="production"?"Production":"Environment"}function Lt(s){const n=s?.trim();return!n||n.toLowerCase()==="production"?"custom":n}function Tt(s){try{return new URL("/login",s).toString()}catch{return"https://openpond.ai/login"}}function zt(s){const n=s.trim();return!n||n==="Loading"?"Loading":n.startsWith("v")?n:`v${n}`}function Ut(s){return s&&`${s[0].toUpperCase()}${s.slice(1)}`}function Bt({advancedWorkspaceControls:s,defaultBranchPrefix:n,defaultNewProjectDirectory:a,preferences:t,saving:l,steerActiveResponses:i,chooseDefaultProjectDirectory:d,saveDefaults:c,setAdvancedWorkspaceControls:m,setSteerActiveResponses:p,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:f}){const u=Ze(n)===t.defaultBranchPrefix&&a.trim()===t.defaultNewProjectDirectory&&s===t.advancedWorkspaceControls&&i===t.steerActiveResponses;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h2",{children:"General"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:h=>{c(h)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:i,disabled:l,onChange:h=>p(h.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Steer active responses"}),e.jsx("small",{children:"Send a new message into the active response immediately. Turn this off to queue it instead."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:h=>m(h.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:h=>o(h.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:h=>f(h.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{d()},children:[e.jsx(nn,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||u,children:e.jsx("span",{children:l?"Saving":"Save settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[Ze(n),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||t.defaultNewProjectDirectory})]})]})}function Ht({diagnostics:s,diagnosticsAvailable:n,diagnosticsBusy:a,diagnosticsStatus:t,logDir:l,logLineLimit:i,logLines:d,logViewBusy:c,logViewSummary:m,logViewportRef:p,tailLogs:o,copyRecentLogs:f,exportDiagnosticsBundle:u,loadOlderLogs:h,openLogsFolder:j,refreshLogView:y,toggleTailLogs:w}){const R=s.filter(k=>k.name==="diagnostic"&&k.status==="failed").slice().reverse().map(_t),P=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:[R.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:R.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):R.map(k=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Ys,{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||!P?.openLogsFolder,onClick:()=>{j()},children:[e.jsx(nn,{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||!P?.exportDiagnostics,onClick:()=>{u()},children:[e.jsx(Tn,{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||!P?.copyRecentLogs,onClick:()=>{f()},children:[e.jsx(vt,{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:m}),e.jsx("button",{type:"button",className:`settings-icon-button ${o?"active":""}`,title:o?"Pause tail":"Tail logs","aria-label":o?"Pause tail":"Tail logs",disabled:!P?.readRecentLogs,onClick:w,children:o?e.jsx(sn,{size:15}):e.jsx(tn,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:c!==null||!P?.readRecentLogs,onClick:()=>{y(i,"refresh")},children:e.jsx(ae,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:c!==null||!P?.readRecentLogs,onClick:h,children:[e.jsx(dt,{size:15}),e.jsx("span",{children:c==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:p,className:"diagnostics-log-viewer",role:"log","aria-live":o?"polite":"off",children:d.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:c?"Loading logs":"No log lines"}):d.map((k,C)=>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}:${C}`))}),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 _t(s){const n=Cs(s.data),a=Cs(n.context),l=fe(n.stack)??fe(n.detail)??fe(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:Gt(s.timestamp),message:Ft(s,n),surface:fe(n.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function Ft(s,n){return fe(s.error)??fe(s.output)??fe(n.message)??fe(n.error)??"Diagnostic event"}function Gt(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Cs(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function fe(s){return typeof s=="string"&&s.trim()?s.trim():null}const Rs=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function qt({editorPreferences:s,lspStatus:n,preferences:a,restarting:t,saving:l,statusLoading:i,refreshLspStatus:d,restartLanguageServers:c,saveEditorSettings:m,setEditorPreferences:p,setLanguageCustomCommand:o,setLanguageMode:f}){const u=JSON.stringify(s)!==JSON.stringify(a.editor),h=new Map(n?.languages.map(j=>[j.language,j])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:j=>{m(j)},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(Ie,{value:s.languageServers,disabled:l,label:"Language servers",options:zn,onChange:j=>p(y=>({...y,languageServers:j}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:j=>p(y=>({...y,diagnosticsWhileEditing:j.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:j=>p(y=>({...y,checkOnSave:j.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:Rs.map(j=>{const y=s.languages[j.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:j.label}),e.jsx("span",{children:Ps(h.get(j.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Ie,{value:y.mode,disabled:l||s.languageServers==="off",label:`${j.label} language server mode`,options:Un,onChange:w=>f(j.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:j.placeholder,onChange:w=>o(j.id,w.target.value)})]})]},j.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!u,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:()=>{d()},children:e.jsx(ae,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||t,onClick:()=>{c()},children:[e.jsx(Rt,{className:t?"settings-spin":void 0,size:15}),e.jsx("span",{children:t?"Restarting":"Restart"})]})]})]}),Rs.map(j=>{const y=h.get(j.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:j.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:Ps(y,i)})]},j.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 Ps(s,n){return n&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function As({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:d=>{l(d)},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:d=>i(d.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 Wt({subagentsEnabled:s,subagentDelegationMode:n,subagentsUseDefaultModel:a,subagentsProvider:t,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:d,subagentsMaxConcurrentRunsPerProvider:c,subagentsMaxConcurrentRunsPerWorkspaceTarget:m,preferences:p,providers:o,saving:f,saveDefaults:u,changeSubagentsProvider:h,setSubagentsEnabled:j,setSubagentDelegationMode:y,setSubagentsUseDefaultModel:w,setSubagentsModel:R,setSubagentsMaxConcurrentRuns:P,setSubagentsMaxConcurrentRunsPerProvider:k,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:C,setSubagentRoleEnabled:x,setSubagentRoleIsolationMode:A,setSubagentRoleMaxConcurrentRuns:L,setSubagentRoleModel:E,setSubagentRolePeerMessages:v,setSubagentRoleToolPolicy:S,changeSubagentRoleProvider:N}){const b=Qs(o,{enabledOnly:!0}),T=a?p.defaultChatProvider:t,_=a?p.defaultChatModel:l,F=on(Be(T,o),_),J=a?null:{providerId:t,modelId:l.trim()},W=Qt({enabled:s,delegationMode:n,defaultModelRef:J,roles:i,maxConcurrentRuns:d,maxConcurrentRunsPerProvider:c,maxConcurrentRunsPerWorkspaceTarget:m},p);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:D=>{u(D)},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${W?"":" dirty"}`,disabled:f||W,children:e.jsx("span",{children:f?"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:f,onChange:D=>j(D.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:f||!s,onChange:D=>y(D.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:T,disabled:f||!s,onChange:D=>{w(!1),h(D.target.value)},children:b.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:_,disabled:f||!s,onChange:D=>{w(!1),R(D.target.value)},children:F.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map(D=>{const Y=Bn.find(g=>g.id===D.id),H=D.modelRef?.providerId??T,ee=D.modelRef?.modelId||Hn(H,o)||_,X=Yt(b,o,{providerId:H,modelId:ee}),le=Le(H,ee),G=f||!s||!D.enabled;return e.jsxs("section",{className:`subagent-role-row${D.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:Y?.label??D.id}),e.jsx("small",{children:Y?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${Y?.label??D.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:D.enabled,disabled:f||!s,onChange:g=>x(D.id,g.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:le,disabled:G,onChange:g=>{const U=X.find(q=>q.value===g.target.value);U&&(N(D.id,U.providerId),E(D.id,U.modelId))},children:X.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:D.isolationMode,disabled:G,onChange:g=>A(D.id,g.target.value),children:Vt.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:D.toolPolicy,disabled:G,onChange:g=>S(D.id,g.target.value),children:Kt.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:D.peerMessages,disabled:G,onChange:g=>v(D.id,g.target.value),children:Jt.map(g=>e.jsx("option",{value:g.value,children:g.label},g.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:D.maxConcurrentRuns,disabled:G,onChange:g=>L(D.id,Ds(g.target.value,1))})]})})]},D.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:d,disabled:f||!s,onChange:D=>P(Ds(D.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:c??"",placeholder:"No cap",disabled:f||!s,onChange:D=>k(as(D.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:m??"",placeholder:"No cap",disabled:f||!s,onChange:D=>C(as(D.target.value))})]})]})]})]})})}const Vt=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],Kt=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],Jt=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function on(s,n){const a=n.trim();return!a||s.some(t=>t.value===a)?s:[{value:a,label:a},...s]}function Le(s,n){return JSON.stringify([s,n])}function Yt(s,n,a){const t=[];for(const l of s){const i=on(Be(l.value,n),l.value===a.providerId?a.modelId:"");for(const d of i)t.push({value:Le(l.value,d.value),label:`${l.label} / ${d.label}`,providerId:l.value,modelId:d.value})}return a.modelId&&!t.some(l=>l.value===Le(a.providerId,a.modelId))&&t.unshift({value:Le(a.providerId,a.modelId),label:`${Te(a.providerId,n)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),t}function as(s){const n=s.trim();if(!n)return null;const a=Number(n);return Number.isFinite(a)?a:null}function Ds(s,n){return as(s)??n}function Qt(s,n){const a=n.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&Zt(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 Zt(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const Xt=[{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 ea({currentUserId:s,enabled:n,mode:a,threads:t,onModeChange:l,onThreadMuteChange:i}){const[d,c]=r.useState(null),[m,p]=r.useState(null);ls(m);const o=r.useMemo(()=>t.filter(h=>h.archivedAt===null).map(h=>({thread:h,label:sa(h,s)})).sort((h,j)=>{const y=+!!j.thread.mutedAt-+!!h.thread.mutedAt;return y!==0?y:h.label.localeCompare(j.label)}),[s,t]),f=o.filter(({thread:h})=>!!h.mutedAt).length,u=r.useCallback(async h=>{c(h.id),p(null),await i(h.id,!h.mutedAt)||p("Could not update this conversation. Try again."),c(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:Xt.map(h=>e.jsxs("label",{className:`notification-mode-option${a===h.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===h.mode,onChange:()=>l(h.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:h.label}),e.jsx("small",{children:h.detail})]})]},h.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:f===1?"1 muted":`${f} muted`})]}),n?o.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):o.map(({thread:h,label:j})=>{const y=!!h.mutedAt,w=d===h.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${y?" muted":""}`,children:y?e.jsx(ut,{size:15}):e.jsx(an,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:j}),e.jsx("small",{children:y?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:d!==null,onClick:()=>{u(h)},children:w?"Saving":y?"Unmute":"Mute"})]},h.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 sa(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 na({canSaveCurrentTemplate:s,personalizationTemplateId:n,personalizationTemplateOptions:a,saveAsNewOpen:t,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:d,soulDraft:c,templateNameDraft:m,changePersonalizationTemplate:p,changeSoulDraft:o,openSaveAsNew:f,resetPersonalizationDraft:u,savePersonalization:h,setSaveAsNewOpen:j,setTemplateNameDraft:y}){function w(R){R.preventDefault(),h(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:m,onChange:R=>y(R.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:()=>j(!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||!c.trim()||!m.trim(),onClick:()=>{h(!0)},children:e.jsx(rs,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:d?"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||!c.trim(),onClick:f,children:e.jsx(ge,{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(Ie,{value:n,disabled:l||a.length===0,label:"Personalization template",options:a,onChange:R=>{p(R)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:c,onChange:R=>o(R.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:u,children:e.jsx(_e,{size:15})}),d&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(os,{size:15})})]})]})]})}function ta({connection:s,profile:n,selectedDefaultTeamId:a}){const t=pt(s),l=ia(t.schedules);return ls(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(Is,{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(aa,{}),n.agents.map(i=>e.jsx(la,{agent:i,defaultAction:n.summary.defaultAction,profile:n,selectedDefaultTeamId:a},i.id)),l.paused.map(i=>e.jsx(Is,{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 aa(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{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($e,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx($e,{status:{state:"ready",label:"Built in"}})})]})}function la({agent:s,defaultAction:n,profile:a,selectedDefaultTeamId:t}){const l=ca(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(He,{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($e,{status:l.check})}),e.jsx("td",{children:e.jsx($e,{status:l.sync})})]})}function Is({pending:s,refreshing:n,schedule:a,onRefresh:t,onRun:l,onToggle:i}){const d=ra(a),c=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(He,{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($e,{status:d})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:oa(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(ae,{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(_e,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:c,"aria-label":`${c}: ${a.scheduleName}`,onClick:i,children:a.enabled?e.jsx(sn,{size:14}):e.jsx(tn,{size:14})})]})]})})]})}function $e({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function ia(s){const n=[],a=[];for(const t of s)t.enabled?n.push(t):a.push(t);return n.sort((t,l)=>$s(t)-$s(l)),{active:n,paused:a}}function $s(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function ra(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 oa(s){const n=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&n.push(`next ${Es(s.nextRunAt)}`),s.lastRunAt&&n.push(`last ${Es(s.lastRunAt)}`),n.join(" - ")}function Es(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 ca(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||ua(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(da(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 da(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}function ua(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}async function ha(s){const n=s.catalog.workflows.find(l=>l.workflow.id===s.workflowId);if(!n)throw new Error("Selected Profile workflow is unavailable.");const a=s.client??$,t=await a.createSession(s.connection,{experience:"work",provider:"openpond",currentProfile:s.catalog.profileRef,profileWorkflowBinding:n.binding,title:n.workflow.label});return await a.sendTurn(s.connection,t.id,{prompt:n.workflow.label,workflowInput:s.value,approvalPolicy:"on-request",sandbox:"workspace-write",codexPermissionMode:"default"}),t.id}function ma({connection:s,selectedProfileKey:n,onError:a,onOpenSession:t,onToast:l}){const[i,d]=r.useState(null),[c,m]=r.useState(!1),[p,o]=r.useState(null),[f,u]=r.useState("{}"),[h,j]=r.useState(!1),[y,w]=r.useState(null);r.useEffect(()=>{if(!s||!n){d(null);return}let k=!0;return m(!0),d(null),o(null),w(null),$.profileWorkflows(s).then(C=>{k&&d(C)}).catch(C=>{k&&w(C instanceof Error?C.message:String(C))}).finally(()=>{k&&m(!1)}),()=>{k=!1}},[s,n]);const R=i?.workflows.find(k=>k.workflow.id===p);async function P(k){if(k.preventDefault(),!s||!i||!R||h)return;let C;try{C=JSON.parse(f)}catch{w("Workflow input must be valid JSON.");return}j(!0),w(null),a(null);try{const x=await ha({connection:s,catalog:i,workflowId:R.workflow.id,value:C});t?.(x),l?.(`Started ${R.workflow.label}`,"success"),o(null),u("{}")}catch(x){const A=x instanceof Error?x.message:String(x);w(A),a(A)}finally{j(!1)}}return n?e.jsxs("section",{"aria-label":"Profile workflows",className:"profile-workflows",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Workflows"}),e.jsx("p",{children:"Run a workflow from this Profile’s released source."})]}),c?e.jsx("p",{children:"Loading workflows…"}):null,y?e.jsx("p",{role:"alert",children:y}):null,i&&i.workflows.length===0?e.jsx("p",{children:"No workflows in this Profile yet."}):null,i?.workflows.map(k=>e.jsxs("div",{className:"profile-workflows-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:k.workflow.label}),e.jsx("p",{children:k.workflow.description}),e.jsxs("small",{children:["Source ",k.binding.sourceRevision.slice(0,10)," · release ",k.binding.harnessRelease.contentHash.slice(0,10)]})]}),e.jsx("button",{disabled:h,onClick:()=>{w(null),u("{}"),o(k.workflow.id)},type:"button",children:"Run"})]},k.workflow.id)),R?e.jsxs("form",{className:"profile-workflows-form",onSubmit:P,children:[e.jsxs("h4",{children:["Run ",R.workflow.label]}),e.jsx("label",{htmlFor:"profile-workflow-input",children:"Input JSON"}),e.jsx("textarea",{id:"profile-workflow-input",onChange:k=>u(k.target.value),value:f}),e.jsx("pre",{children:JSON.stringify(R.workflow.inputSchema,null,2)}),e.jsx("button",{disabled:h,type:"submit",children:h?"Starting…":"Start workflow"}),e.jsx("button",{disabled:h,onClick:()=>o(null),type:"button",children:"Cancel"})]}):null]}):null}function Ms(s){switch(s.kind){case"profile":return"Complete Profile";case"workflow":return`Workflow · ${s.workflowId}`;case"skill":return`Skill · ${s.skillPath}`;case"agent_action":return`Agent action · ${s.actionId}`}}function De(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString()}function pa(s){return Object.values(s.statuses).flatMap(n=>{if(!n.enabled||!n.available||!n.credential.connected)return[];const a=s.providers[n.id];return[...new Set([...n.modelIds,...s.modelCaches[n.id]?.models.map(l=>l.id)??[],...a?.modelOverrides??[],n.defaultModel,a?.defaultModel].filter(l=>!!l))].map(l=>({key:JSON.stringify([n.id,l]),providerId:n.id,modelId:l,label:`${n.displayName} · ${l}`}))})}function fa({connection:s,selectedProfileKey:n}){const[a,t]=r.useState(null),[l,i]=r.useState(null),[d,c]=r.useState(50),[m,p]=r.useState(20),[o,f]=r.useState(20),[u,h]=r.useState([]),[j,y]=r.useState(!1),[w,R]=r.useState([]),[P,k]=r.useState(""),[C,x]=r.useState(null),[A,L]=r.useState(!1),[E,v]=r.useState(!1),[S,N]=r.useState(null),[b,T]=r.useState(null),[_,F]=r.useState(!1),[J,W]=r.useState(null);if(r.useEffect(()=>{if(!s||!n){t(null),R([]),x(null);return}let g=!0;return F(!0),t(null),i(null),c(50),p(20),f(20),h([]),R([]),k(""),x(null),T(null),W(null),$.profileEvaluations(s).then(U=>{g&&t(U)}).catch(U=>{g&&W(U instanceof Error?U.message:String(U))}).finally(()=>{g&&F(!1)}),$.providerSettings(s).then(U=>{if(!g)return;const q=pa(U);R(q),k(q[0]?.key??"")}).catch(U=>{g&&W(U instanceof Error?U.message:String(U))}),()=>{g=!1}},[s,n]),!n)return null;const D=a?.definitions.find(g=>g.id===l),Y=D?a?.runs.filter(g=>g.manifest.profileEvaluation?.definitionId===D.id)??[]:[],H=async()=>{const g=w.find(q=>q.key===P);if(!s||!D||!g||A)return;const U={id:`evaluation-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),definitionId:D.id,modelRef:{providerId:g.providerId,modelId:g.modelId}};L(!0),x(null),T(null),W(null);try{x({request:U,prepared:await $.profileEvaluationPrepare(s,U)})}catch(q){W(q instanceof Error?q.message:String(q))}finally{L(!1)}},ee=async()=>{if(!(!s||!C||E)){v(!0),W(null);try{const g=await $.profileEvaluationRun(s,C.request);t(await $.profileEvaluations(s)),x(null),T(`Run ${g.manifest.id} ${g.passed?"passed":"did not pass"}.`)}catch(g){W(g instanceof Error?g.message:String(g))}finally{v(!1)}}},X=async g=>{const U=w.find(q=>q.key===P);if(!(!s||!U||S)){N(g),T(null),W(null);try{const q=await $.profileEvaluationRunSuite(s,{id:`suite-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),suiteId:g,modelRef:{providerId:U.providerId,modelId:U.modelId}});t(await $.profileEvaluations(s)),T(`Suite ${q.id} ${q.passed?"passed":"did not pass"}.`)}catch(q){W(q instanceof Error?q.message:String(q))}finally{N(null)}}},le=g=>{h(U=>U.includes(g)?U.filter(q=>q!==g):[...U,g])},G=async()=>{if(!(!s||u.length<2||j)){y(!0),W(null);try{await $.profileEvaluationCompare(s,u),t(await $.profileEvaluations(s)),h([])}catch(g){W(g instanceof Error?g.message:String(g))}finally{y(!1)}}};return e.jsxs("section",{"aria-label":"Profile evaluations",className:"profile-evaluations",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Evaluations"}),e.jsx("p",{children:"Checks and retained results for this Profile’s released components."})]}),_?e.jsx("p",{children:"Loading evaluations…"}):null,J?e.jsx("p",{role:"alert",children:J}):null,b?e.jsx("p",{role:"status",children:b}):null,a&&a.definitions.length===0?e.jsx("p",{children:"No evaluations in this Profile yet."}):null,a?.suites.length?e.jsxs("div",{className:"profile-evaluations-suites","aria-label":"Evaluation suites",children:[e.jsx("label",{htmlFor:"profile-evaluation-suite-model",children:"Suite model"}),e.jsx("select",{id:"profile-evaluation-suite-model",value:P,disabled:!!S,onChange:g=>k(g.target.value),children:w.map(g=>e.jsx("option",{value:g.key,children:g.label},g.key))}),w.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run a suite."}):null,a.suites.map(g=>e.jsxs("div",{className:"profile-evaluations-suite",children:[e.jsx("strong",{children:g.label}),e.jsxs("span",{children:[g.scope==="profile"?"Profile suite":"Component suite"," · ",g.definitionIds.length," checks"]}),e.jsx("button",{type:"button",disabled:!P||!!S||E,onClick:()=>{X(g.id)},children:S===g.id?"Running suite…":"Run suite"}),a.suiteRuns.filter(U=>U.suiteId===g.id).slice(0,5).map(U=>e.jsxs("small",{children:[De(U.completedAt)," · ",U.passed?"Passed":"Did not pass"," · ",U.members.length," checks · ",U.id]},U.id))]},g.id))]}):null,a?.definitions.map(g=>{const U=a.runs.find(q=>q.manifest.profileEvaluation?.definitionId===g.id);return e.jsxs("div",{className:"profile-evaluations-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:g.label}),e.jsx("p",{children:g.description||Ms(g.target)}),e.jsxs("small",{children:[Ms(g.target)," · ",g.taskIds.length," tasks · ",g.seeds.length," seeds"]}),U?e.jsxs("small",{children:["Latest: ",U.passed?"Passed":"Did not pass"," · ",U.metric.value===null?"No score":`${Math.round(U.metric.value*100)}%`," · ",De(U.completedAt)]}):null]}),e.jsx("button",{type:"button","aria-expanded":l===g.id,onClick:()=>{i(l===g.id?null:g.id),c(50),p(20),x(null)},children:l===g.id?"Hide details":"View details"})]},g.id)}),D?e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsx("h4",{children:D.label}),e.jsxs("p",{children:["Taskset ",D.tasksetRelease.id," · ",D.tasksetRelease.contentHash.slice(0,12)]}),e.jsxs("p",{children:["Frozen split: ",D.split," · Minimum pass rate: ",Math.round(D.criterion.minimumPassRate*100),"%"]}),e.jsxs("div",{className:"profile-evaluations-run-form",children:[e.jsx("label",{htmlFor:"profile-evaluation-model",children:"Model"}),e.jsx("select",{id:"profile-evaluation-model",value:P,disabled:A||E,onChange:g=>{k(g.target.value),x(null)},children:w.map(g=>e.jsx("option",{value:g.key,children:g.label},g.key))}),w.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run this check."}):null,e.jsx("button",{type:"button",disabled:!P||A||E,onClick:()=>{H()},children:A?"Checking run…":"Check run setup"}),C?e.jsxs("div",{className:"profile-evaluations-run-plan",children:[e.jsx("strong",{children:"Run setup"}),e.jsxs("small",{children:["Profile source ",C.prepared.manifest.profileEvaluation?.sourceRevision.slice(0,12)," · Harness ",C.prepared.manifest.execution.kind==="harness"?C.prepared.manifest.execution.harnessRelease.id:""]}),e.jsxs("small",{children:["Taskset ",C.prepared.taskset.id," · ",C.prepared.manifest.population.length," attempts · ",C.prepared.manifest.limits.timeoutMs/1e3,"s per attempt"]}),e.jsxs("small",{children:["Connected app scopes: ",C.prepared.taskset.connectedAppScopes.join(", ")||"none declared"]}),e.jsx("button",{type:"button",disabled:E,onClick:()=>{ee()},children:E?"Running evaluation…":"Run evaluation"})]}):null]}),e.jsxs("div",{className:"profile-evaluations-cases",children:[e.jsx("strong",{children:"Task cases"}),e.jsx("ul",{children:D.taskIds.slice(0,d).map(g=>e.jsx("li",{children:g},g))}),D.taskIds.length>d?e.jsx("button",{type:"button",onClick:()=>c(g=>g+50),children:"Show more cases"}):null,e.jsxs("span",{children:["Seeds: ",D.seeds.join(", ")]})]}),e.jsxs("div",{className:"profile-evaluations-history",children:[e.jsx("strong",{children:"Run history"}),Y.length===0?e.jsx("p",{children:"No runs for this check yet."}):e.jsx("ul",{children:Y.slice(0,m).map(g=>e.jsxs("li",{children:[e.jsxs("span",{children:[De(g.completedAt)," · ",g.passed?"Passed":"Did not pass"," · ",g.receiptRefs.length," attempts"]}),e.jsxs("small",{children:["Model ",g.manifest.policy.kind==="model"?`${g.manifest.policy.model.provider}/${g.manifest.policy.model.model}`:"fixture"," · Source ",g.manifest.profileEvaluation?.sourceRevision.slice(0,10)," · Run ",g.manifest.id]})]},g.manifest.id))}),Y.length>m?e.jsx("button",{type:"button",onClick:()=>p(g=>g+20),children:"Show more runs"}):null]})]}):null,a&&a.runs.length>1?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Compare evaluation runs",children:[e.jsx("h4",{children:"Compare runs"}),e.jsx("p",{children:"Select two or more runs. Comparisons require the same Taskset, cases, environment, grading policy, limits, and runtime."}),e.jsx("div",{className:"profile-evaluations-comparison-runs",children:a.runs.slice(0,o).map(g=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:u.includes(g.manifest.id),onChange:()=>le(g.manifest.id),disabled:j}),e.jsxs("span",{children:[e.jsxs("strong",{children:[g.manifest.profileEvaluation?.definitionId??"Profile evaluation"," · ",g.metric.value===null?"No score":`${Math.round(g.metric.value*100)}%`]}),e.jsxs("small",{children:[De(g.completedAt)," · ",g.manifest.policy.kind==="model"?`${g.manifest.policy.model.provider}/${g.manifest.policy.model.model}`:"fixture"," · Source ",g.manifest.profileEvaluation?.sourceRevision.slice(0,10)," · ",g.manifest.id]})]})]},g.manifest.id))}),a.runs.length>o?e.jsx("button",{type:"button",onClick:()=>f(g=>g+20),children:"Show more runs"}):null,e.jsx("button",{type:"button",disabled:u.length<2||j,onClick:()=>{G()},children:j?"Comparing…":`Save comparison of ${u.length} runs`})]}):null,a&&a.comparisons.length>0?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Saved evaluation comparisons",children:[e.jsx("h4",{children:"Saved comparisons"}),e.jsx("ul",{children:a.comparisons.map(g=>e.jsxs("li",{children:[e.jsxs("strong",{children:[De(g.createdAt)," · ",g.members.length," runs"]}),e.jsx("ul",{children:g.members.map(U=>e.jsxs("li",{children:[U.source.definitionId," · ",U.policy.kind==="model"?`${U.policy.model.provider}/${U.policy.model.model}`:"fixture"," · Source ",U.source.sourceRevision.slice(0,10)," · ",U.score===null?"No score":`${Math.round(U.score*100)}%`]},U.runManifest.id))})]},g.id))})]}):null]})}function ga({actions:s,busy:n,library:a,onSelect:t}){const l=a.profiles.find(d=>Xe(d.ref,a.lastUsed))??a.profiles[0]??null,i=l?Ge(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:d=>{const c=_n(a,d.currentTarget.value),m=a.profiles.find(p=>Xe(p.ref,c));m&&t(m)},children:a.profiles.length?a.profiles.map(d=>e.jsx("option",{value:Ge(d.ref),children:d.name},Ge(d.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Fn,{"aria-hidden":"true",size:14})]}),s]})}function xa({addDisabled:s,commitDisabled:n,commitLabel:a,refreshDisabled:t,repoDisabled:l,syncDisabled:i,syncLabel:d,syncStatus:c,onAdd:m,onCommit:p,onRefresh:o,onRepo:f,onSync:u}){const[h,j]=r.useState(!1),y=r.useRef(null);r.useEffect(()=>{if(!h)return;function R(k){y.current?.contains(k.target)||j(!1)}function P(k){k.key==="Escape"&&j(!1)}return document.addEventListener("pointerdown",R),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",R),document.removeEventListener("keydown",P)}},[h]);function w(R){j(!1),R()}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":h,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>j(R=>!R),children:e.jsx(is,{size:15})}),h?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>w(p),children:[e.jsx(Ue,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>w(u),children:[e.jsx(xe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:d}),c?e.jsx("small",{children:c}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>w(f),children:[e.jsx(Me,{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(o),children:[e.jsx(ae,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>w(m),children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const ja=[{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 va({connection:s,entry:n,onClose:a,onPublished:t}){const[l,i]=r.useState("github"),[d,c]=r.useState(""),[m,p]=r.useState(`${n.name}-profile`),[o,f]=r.useState("public"),[u,h]=r.useState(()=>n.state.agents.filter(b=>b.enabled).map(b=>b.id)),[j,y]=r.useState(()=>n.state.skills.filter(b=>b.enabled).map(b=>b.name)),[w,R]=r.useState([]),[P,k]=r.useState(null),[C,x]=r.useState(null),[A,L]=r.useState(null),E=r.useMemo(()=>({ref:n.ref,selection:{agentIds:u,skillNames:j,optionalContent:w},target:{provider:l,owner:d.trim()||null,repository:m.trim(),visibility:l==="github"?"public":o}}),[u,n.ref,w,d,l,m,j,o]);function v(b,T,_){return _?[...new Set([...b,T])]:b.filter(F=>F!==T)}async function S(b){if(b.preventDefault(),!(!m.trim()||C)){x("preview"),L(null);try{k(await $.profilePublicationPreview(s,E))}catch(T){L(T instanceof Error?T.message:String(T))}finally{x(null)}}}async function N(){if(!(!P||P.blockedReasons.length>0||C)){x("publish"),L(null);try{const b=await $.profilePublicationPublish(s,{...E,expectedSourceHash:P.sourceHash,confirmed:!0});t(`Published ${n.name} to ${b.owner}/${b.repository}`),a()}catch(b){L(b instanceof Error?b.message:String(b))}finally{x(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:b=>b.stopPropagation(),onSubmit:S,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!C,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."}),P?e.jsx(ba,{preview:P}):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"),f("public")}}),e.jsx(es,{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"),f("private")}}),e.jsx(Gn,{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:d,placeholder:"Uses gh account",onChange:b=>c(b.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:m,onChange:b=>p(b.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:o,onChange:b=>f(b.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(Ke,{title:"Agents",empty:"No Agents in this Profile",children:n.state.agents.map(b=>e.jsx(Je,{checked:u.includes(b.id),label:b.name,detail:b.path,onChange:T=>h(_=>v(_,b.id,T))},b.id))}),e.jsx(Ke,{title:"Skills",empty:"No Skills in this Profile",children:n.state.skills.map(b=>e.jsx(Je,{checked:j.includes(b.name),label:b.name,detail:b.description||b.path,onChange:T=>y(_=>v(_,b.name,T))},b.name))}),e.jsx(Ke,{title:"Optional content",empty:"",children:ja.map(b=>e.jsx(Je,{checked:w.includes(b.id),label:b.label,detail:b.detail,onChange:T=>R(_=>v(_,b.id,T))},b.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:!!C,type:"button",onClick:P?()=>k(null):a,children:P?"Back":"Cancel"}),P?e.jsxs("button",{className:"git-dialog-primary",disabled:!!C||P.blockedReasons.length>0,type:"button",onClick:()=>{N()},children:[e.jsx(xe,{size:14}),e.jsx("span",{children:C==="publish"?"Publishing":P.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!C||!m.trim(),type:"submit",children:C==="preview"?"Building preview":"Review exact files"})]})]})})}function Ke({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 Je({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 ba({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 · ",Os(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," · ",Os(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 Os(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function ya({section:s="all",catalogPresentation:n="list",payload:a,connection:t,onPayload:l,onError:i,onToast:d,onSkillCommand:c,onOpenSession:m,overviewContent:p}){const[o,f]=r.useState(""),[u,h]=r.useState(null),[j,y]=r.useState(!1),[w,R]=r.useState(null),[P,k]=r.useState(null),C=a?.profile??null,x=a?.preferences.defaultTeamId?.trim()||"",A=s==="all"||s==="profile"||s==="controls",L=s==="all"||s==="profile",E=s==="all"||s==="agents",v=s==="all"||s==="profile";async function S(H){t&&(l(await $.bootstrap(t)),d?.(H,"success"))}async function N(H,ee){if(!(!t||u)){h(H),i(null);try{await ee()}catch(X){i(X instanceof Error?X.message:String(X))}finally{h(null)}}}function b(){N("init",async()=>{await $.profileInit(t,{}),await S("Profile initialized")})}function T(){N("commit",async()=>{await $.profileCommit(t,{message:o.trim()||null}),f(""),await S("Profile commit complete")})}function _(){N("push",async()=>{if(!x)throw new Error("Select a default team before syncing a hosted profile.");await $.profileCheck(t,{kind:"all"}),await $.profilePush(t,{teamId:x,ensureHosted:!0,message:null}),await S("Profile synced to hosted profile repo")})}function F(H){N(`select:${H.ref.profileId}`,async()=>{await $.profileSelect(t,H.ref),await S(`Using ${H.name}`)})}function J(H){N("add",async()=>{H.source==="blank"?await $.profileInit(t,{path:H.path,profile:H.profile,template:"blank-profile"}):H.source==="local"?await $.profileLoad(t,H):await $.profileInstall(t,H),y(!1),await S(H.source==="blank"?`${H.profile} created`:"Profile added")})}function W(H){N("update",async()=>{await $.profileUpdate(t,H.ref),await S(`${H.name} updated`)})}function D(H){N("remove",async()=>{await $.profileRemove(t,H.ref),R(null),await S("Profile removed from this device")})}function Y(){N("refresh",async()=>{await S("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[C?.mode==="local"?e.jsxs(e.Fragment,{children:[A?e.jsxs(e.Fragment,{children:[L&&n==="select"?e.jsx(ga,{actions:e.jsx(Ls,{connection:t,onAdd:()=>y(!0),onRefresh:Y,presentation:"menu",profile:C,profileBusy:u,profileCommitMessage:o,selectedDefaultTeamId:x,syncDisabledReason:Ts(C,x),setProfileCommitMessage:f,submitProfileCommit:T,submitProfilePush:_}),busy:!!u,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:F}):e.jsxs(e.Fragment,{children:[L?e.jsx(Na,{busy:!!u,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>y(!0),onRefresh:Y,onRemove:R,onPublish:k,onUpdate:W,onSelect:F}):null,e.jsx(Ls,{connection:t,profile:C,profileBusy:u,profileCommitMessage:o,selectedDefaultTeamId:x,syncDisabledReason:Ts(C,x),setProfileCommitMessage:f,submitProfileCommit:T,submitProfilePush:_})]}),p]}):null,E?e.jsx(ta,{connection:t,profile:C,selectedDefaultTeamId:x}):null,v?e.jsxs(e.Fragment,{children:[e.jsx(Pa,{onSkillCommand:c,profile:C}),e.jsx(ma,{connection:t,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null,onError:i,onOpenSession:m,onToast:d}),e.jsx(fa,{connection:t,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null})]}):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||!!u,type:"button",onClick:()=>y(!0),children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!!u,type:"button",onClick:b,children:[e.jsx(ge,{size:14}),e.jsx("span",{children:u==="init"?"Creating":"Create starter Profile"})]})]})]}),j?e.jsx(wa,{busy:!!u,onClose:()=>y(!1),onSubmit:J}):null,w?e.jsx(Sa,{busy:!!u,entry:w,onClose:()=>R(null),onConfirm:()=>D(w)}):null,P&&t?e.jsx(va,{connection:t,entry:P,onClose:()=>k(null),onPublished:H=>d?.(H,"success")}):null]})}function Na({busy:s,library:n,onAdd:a,onRefresh:t,onRemove:l,onPublish:i,onSelect:d,onUpdate:c}){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(ae,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),n.profiles.map(m=>{const p=Xe(m.ref,n.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${p?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||d(m)},onKeyDown:o=>{s||o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),d(m))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Me,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:m.name}),e.jsx("span",{title:m.repoPath,children:m.repoPath})]})]}),e.jsx(cn,{status:{state:m.state.error?"warning":"ready",label:m.state.error?"error":p?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:m.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:m.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[m.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),c(m)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),c(m))},children:[e.jsx(ae,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),i(m)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),i(m))},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 ${m.name}`,onClick:o=>{o.stopPropagation(),l(m)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),l(m))},children:[e.jsx(ke,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${m.ref.source}:${m.ref.repositoryId}:${m.ref.profileId}`)})]})}function wa({busy:s,onClose:n,onSubmit:a}){const[t,l]=r.useState("blank"),[i,d]=r.useState(""),[c,m]=r.useState(""),[p,o]=r.useState("");function f(u){if(u.preventDefault(),s)return;if(t==="blank"){const j=p.trim();if(!j)return;a({source:t,path:i.trim()||null,profile:j});return}if(t==="local"){const j=i.trim();if(!j)return;a({source:t,path:j,profile:p.trim()||null});return}const h=c.trim();h&&a({source:t,repositoryId:h,profile:p.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:u=>u.stopPropagation(),onSubmit:f,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(Me,{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:u=>d(u.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:u=>d(u.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:c,placeholder:"owner/repository",onChange:u=>m(u.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:p,placeholder:t==="blank"?"research":"Uses repository default",onChange:u=>o(u.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"?p:t==="local"?i:c).trim(),type:"submit",children:t==="blank"?"Create Profile":"Add Profile"})]})]})})}function Sa({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(ke,{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 Ls({connection:s,onAdd:n,onRefresh:a,presentation:t="toolbar",profile:l,profileBusy:i,profileCommitMessage:d,selectedDefaultTeamId:c,syncDisabledReason:m,setProfileCommitMessage:p,submitProfileCommit:o,submitProfilePush:f}){const[u,h]=r.useState(!1),[j,y]=r.useState(!1),[w,R]=r.useState(!1),P=!s||!!i;return e.jsxs(e.Fragment,{children:[t==="menu"&&n&&a?e.jsx(xa,{addDisabled:!!i,commitDisabled:P,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:P,repoDisabled:!!i||!l,syncDisabled:P||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?Ye(l,c):null,onAdd:n,onCommit:()=>y(!0),onRefresh:a,onRepo:()=>h(!0),onSync:()=>R(!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:P,type:"button",onClick:()=>y(!0),children:[e.jsx(Ue,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:P||!l,type:"button",onClick:()=>R(!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:()=>h(!0),children:[e.jsx(Me,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${Ye(l,c)}`,children:[e.jsx(xe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:Ye(l,c)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),u&&l?e.jsx(Ra,{profile:l,profileBusy:i,onClose:()=>h(!1)}):null,j?e.jsx(ka,{disabled:P,profileBusy:i,profileCommitMessage:d,setProfileCommitMessage:p,submitProfileCommit:o,onClose:()=>y(!1)}):null,w&&l?e.jsx(Ca,{disabled:P,profile:l,profileBusy:i,selectedDefaultTeamId:c,syncDisabledReason:m,submitProfilePush:f,onClose:()=>R(!1)}):null]})}function ka({disabled:s,profileBusy:n,profileCommitMessage:a,setProfileCommitMessage:t,submitProfileCommit:l,onClose:i}){function d(c){c.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:c=>c.stopPropagation(),onSubmit:d,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(Ue,{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:c=>t(c.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(Ue,{size:14}),e.jsx("span",{children:n==="commit"?"Committing":"Commit"})]})]})]})})}function Ca({disabled:s,profile:n,profileBusy:a,selectedDefaultTeamId:t,syncDisabledReason:l,submitProfilePush:i,onClose:d}){const c=Da(n,t),m=c.reduce((f,u)=>f+u.count,0),p=!s&&!l;function o(f){f.preventDefault(),p&&(i(),d())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:d,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:f=>f.stopPropagation(),onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:d,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:[m," ",m===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",Ce(n.summary.localHead??n.git?.head)," - Last pushed"," ",Ce(n.hosted?.lastPushedLocalHead)]})]}),c.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:c.map(f=>e.jsxs("div",{className:`profile-dialog-diff-row ${f.tone??""}`,children:[e.jsx("strong",{children:f.label}),e.jsx("span",{children:f.detail})]},f.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:d,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!p,type:"submit",children:[e.jsx(xe,{size:14}),e.jsx("span",{children:a==="push"?"Syncing":"Confirm sync"})]})]})]})})}function Ra({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(Me,{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"," · ",Ce(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 Pa({onSkillCommand:s,profile:n}){const a=n.skills.slice().sort((i,d)=>i.name.localeCompare(d.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(ze,{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(cn,{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 cn({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function Ce(s){return s?s.slice(0,10):"None"}function Ye(s,n){return dn(s,n)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${Ce(s.hosted.sourceCommitSha)}`:"Not pushed"}function Ts(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 Da(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(dn(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 ${Ce(t)} has not been pushed since ${Ce(l)}.`,count:1}),s.git?.dirty){const c=(s.git.fileCount??s.git.files.length)||(s.diff.fileCount??s.diff.files.length)||1;a.push({label:"Uncommitted files",detail:`${c} local ${c===1?"file":"files"} changed.`,count:c,tone:"warning"})}const d=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 d>0&&a.push({label:"Profile changes",detail:Ia(s),count:d,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 dn(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}const $a=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],Ea=120,Ma=new Set(["openai","xai","zai"]),Oa=new Set(["chatgpt-subscription"]),La="https://api.z.ai/api/coding/paas/v4";function zs(s){return s.split(/[\n,]/).map(n=>n.trim()).filter(Boolean)}function un(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 hn(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function Us(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 Ta(s){return s?.trim().replace(/\/+$/,"")??""}function mn(s,n){return s.id==="zai"&&Ta(n.providers.zai?.baseUrl)===La}function za(s,n){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":mn(s,n)?"Coding Plan key":"API key"}function Ua(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?ns(s.defaultModel,n,s.id):"",i=t===1?"1 model":`${t} models`,d=za(s,n);return[un(s),d,a?i:"",l].filter(Boolean).join(" · ")}function Ba(s){return s!=="openpond"&&ss(s)}function cs(s){return s?Ma.has(s.id)||s.credentialModes.some(n=>Oa.has(n)):!1}function Ha(s){return cs(s)?["api","subscription"]:["api"]}function Bs(s,n){return!s||!n||!cs(s)?"api":s.credential.source==="chatgpt_subscription"||mn(s,n)?"subscription":"api"}function Hs(s,n){const a=qn.filter(t=>!!s?.statuses[t]);return n?a.filter(t=>cs(s?.statuses[t])):a}function _a(s){if(!s)return"Never";const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString()}function Fa(s,n,a=Ea){const t=[],l=new Set,i=new Set(n.map(c=>c.trim()).filter(Boolean)),d=c=>{l.has(c.value)||t.length>=a||(l.add(c.value),t.push(c))};for(const c of s)i.has(c.value)&&d(c);for(const c of s)d(c);return t}function Ga({account:s,codex:n,providers:a,providerBusy:t,validationMessage:l,deleteProviderCredential:i,loadProviderModels:d,refreshProviderModels:c,saveProviderConfig:m,saveProviderCredential:p,startOpenAiSubscriptionAuth:o,validateProvider:f}){const[u,h]=r.useState(null),[j,y]=r.useState(!1),w=r.useMemo(()=>Hs(a,!1),[a]),R=r.useMemo(()=>Hs(a,j),[a,j]),P=u?a?.statuses[u]??null:null;function k(C,x){h(C),x&&d(C)}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:j,onChange:C=>y(C.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[R.length," of ",w.length," presets"]})]}),R.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:R.map(C=>{const x=a.statuses[C],A=a.modelCaches[C],L=x.modelIds.length>0&&(A?.models.length??0)<x.modelIds.length,E=t?.startsWith(`${C}:`)??!1,v=Ba(C),S=C==="openpond"||!!a.providers[C]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${x.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:S,disabled:!v||E,onChange:N=>{k(C,!1),m(C,{enabled:N.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:x.displayName})}),e.jsxs("div",{className:`provider-row-status ${hn(x)}`,children:[E?e.jsx(oe,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:Ua(x,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{k(C,L)},children:"Details"})]},C)})}):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,u&&P&&a?e.jsx(qa,{account:s,codex:n,providerId:u,providerBusy:t,settings:a,status:P,onClose:()=>h(null),onDeleteCredential:i,onRefreshModels:c,onSaveConfig:m,onSaveCredential:p,onStartOpenAiSubscriptionAuth:o,onValidate:f}):null]})}function qa({account:s,codex:n,providerId:a,providerBusy:t,settings:l,status:i,onClose:d,onDeleteCredential:c,onRefreshModels:m,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:f,onValidate:u}){const h=l.providers[a],j=l.modelCaches[a],y=r.useId(),w=r.useRef(a),R=Math.max(j?.models.length??0,i.modelIds.length),P=i.routing.localByok&&ss(a)&&a!=="codex",k=r.useMemo(()=>P?Ha(i):[],[P,i]),C=k.includes("subscription"),[x,A]=r.useState(()=>Bs(i,l)),L=P&&x==="subscription"&&C,E=S=>`${y}-${S}-panel`,v=a==="codex"?"Codex app server":h?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return r.useEffect(()=>{if(w.current!==a){w.current=a,A(Bs(i,l));return}P&&!k.includes(x)&&A("api")},[x,k,P,a,l,i]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:d,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${i.displayName} provider details`,onMouseDown:S=>S.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:d,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:Te(a,l)})]}),e.jsx("div",{className:`provider-state-pill ${hn(i)}`,children:un(i)})]}),P?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:k.map(S=>e.jsx("button",{type:"button",role:"tab",id:`${y}-${S}`,className:x===S?"active":void 0,"aria-selected":x===S,"aria-controls":E(S),onClick:()=>A(S),children:S==="api"?"API":"Subscription"},S))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:Us(i),children:Us(i)})]}),L?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:v,children:v})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:h?.defaultModel??i.defaultModel??void 0,children:h?.defaultModel??i.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:j?.lastError??void 0,children:[R," cached · ",_a(j?.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||j?.lastError||i.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:i.credential.lastError??j?.lastError??i.lastError??void 0,children:i.credential.lastError??j?.lastError??i.lastError})]}):null]}),a==="codex"?e.jsx(Wa,{providerBusy:t,status:i,onValidate:u}):P&&h&&j?e.jsx(Va,{credentialTab:x,credentialTabsId:y,hasSubscriptionTab:C,providerId:a,providerBusy:t,settings:l,status:i,onDeleteCredential:c,onRefreshModels:m,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:f,onValidate:u}):i.routing.localByok&&!ss(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Ys,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function Wa({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(oe,{size:14,className:"settings-spin"}):e.jsx(Zs,{size:14}),e.jsx("span",{children:t?"Testing":"Test Codex login"})]})})]})}function Va({credentialTab:s,credentialTabsId:n,hasSubscriptionTab:a,providerId:t,providerBusy:l,settings:i,status:d,onDeleteCredential:c,onRefreshModels:m,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:f,onValidate:u}){const h=i.providers[t],j=r.useMemo(()=>Be(t,i),[t,i]),y=`provider-models-${t}`,w=r.useRef(t),[R,P]=r.useState(h.baseUrl??""),[k,C]=r.useState(h.defaultModel??""),[x,A]=r.useState(h.modelOverrides.join(`
6
- `)),[L,E]=r.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[v,S]=r.useState("local_secret"),[N,b]=r.useState(""),[T,_]=r.useState(""),F=l===`${t}:config`,J=l===`${t}:credential`,W=l===`${t}:validate`,D=l===`${t}:models`,Y=l==="openai:credential",H=t==="openai",ee=t==="xai",X=t==="zai",G=(z=>`${n}-${z}-panel`)(s),g=s==="subscription"&&a,U=s==="subscription"&&X?"coding-plan":"api",q=U==="coding-plan"?"Coding Plan key":"API key",ie=d.credential.connected?U==="coding-plan"?"Replace saved plan key":"Replace saved key":q,de=U==="coding-plan"?"Save plan key":"Save key",se=r.useMemo(()=>Fa(j,[k,...zs(x)]),[k,j,x]),ne=Math.max(0,j.length-se.length);r.useEffect(()=>{if(w.current!==t){w.current=t,E({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),P(h.baseUrl??""),C(h.defaultModel??""),A(h.modelOverrides.join(`
5
+ `,onChange:x=>{d===null&&p(l?.rawRevision??null),c(x.target.value)}}),d!==null&&l?.rawRevision!==m?e.jsx("p",{role:"alert",children:"The file changed elsewhere. Reload before saving your edits."}):null,e.jsxs("div",{className:"configuration-actions",children:[e.jsx("button",{type:"button",disabled:j||!l,onClick:()=>{C("validate")},children:"Validate"}),e.jsx("button",{type:"button",disabled:j||!l||d!==null&&l.rawRevision!==m,onClick:()=>{C("replace")},children:"Save config"}),e.jsx("button",{type:"button",disabled:j,onClick:()=>{c(null),p(null),k().catch(x=>h(String(x)))},children:"Reload file"})]}),l?.recoverableRevisions.length?e.jsxs("label",{children:["Restore a verified revision ",e.jsxs("select",{value:"",disabled:j,onChange:x=>{x.target.value&&C("restore",x.target.value)},children:[e.jsx("option",{value:"",children:"Choose a revision…"}),l.recoverableRevisions.map(x=>e.jsxs("option",{value:x.revision,children:[new Date(x.createdAt).toLocaleString()," · ",x.revision.slice(0,12)]},x.revision))]})]}):null,l?.effective?e.jsxs("details",{children:[e.jsx("summary",{children:"Effective values and sources"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Setting"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Location"})]})}),e.jsx("tbody",{children:Object.entries(l.effective.provenance).map(([x,A])=>e.jsxs("tr",{children:[e.jsx("td",{children:JSON.parse(x).join(".")}),e.jsx("td",{children:A.layer==="user"?"Set here":`Inherited from ${A.layer}`}),e.jsx("td",{children:A.path})]},x))})]}),e.jsx("pre",{children:JSON.stringify(l.effective.document,null,2)})]}):null]}),u?e.jsx("p",{role:"status",children:u}):null]})}function ys({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 We({state:s,label:n}){return e.jsx("span",{className:`account-state ${s}`,children:n??s.replace("_"," ")})}const Ns="https://openpond.ai",ws="https://api.openpond.ai";function It(s,n){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:n?.handle,currentBaseUrl:n?.baseUrl??null}}function $t(s,n){return s==="update"&&n?{baseUrl:n.baseUrl??Ns,apiBaseUrl:n.apiBaseUrl??ws,chatApiBaseUrl:n.chatApiBaseUrl,environment:n.environment??"production"}:{baseUrl:Ns,apiBaseUrl:ws,environment:"production"}}function Ss({account:s,busy:n,initialApiKey:a="",mode:t="update",onClose:l,onSave:i}){const d=r.useId(),c=t==="connect",[m,p]=r.useState(a),[o,f]=r.useState(null),[u,h]=r.useState(null);ls(u),r.useEffect(()=>{p(a),f(null),h(null)},[s?.handle,a]);async function j(y){y.preventDefault(),f(null),h(null);const w=m.trim();if(c&&!w){f("API key is required.");return}try{const R=It(t,s),P=$t(t,s);await i({...R,...P,apiKey:c?w:void 0})}catch(R){h(R instanceof Error?R.message:String(R))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&!n&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":d,onSubmit:y=>{j(y)},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:c?e.jsx(pe,{size:18}):e.jsx(is,{size:18})}),e.jsx("h2",{id:d,children:c?"Add account":"Account environment"}),c?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."}),c?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:m,onChange:y=>p(y.target.value)})]}):null,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",disabled:n,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:n,type:"submit",children:[e.jsx(os,{size:14}),e.jsx("span",{children:n?"Saving":c?"Connect account":"Update account"})]})]})]})})}const Et="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 Mt({payload:s,connection:n,saving:a,refreshingAccounts:t,saveAccount:l,refreshAccounts:i,switchAccount:d,removeAccount:c,onPayload:m,onPreferences:p,onError:o,onToast:f}){const u=s?.account,h=u?.state??"loading",j=h==="signed_in",y=h==="signed_out",w=h==="auth_error",R=u?.email?.trim()||null,P=u?.accounts??[],[k,C]=r.useState([]),[,x]=r.useState(!1),[A,L]=r.useState(null),[E,v]=r.useState(null),[S,N]=r.useState(null),[b,z]=r.useState(null),[F,G]=r.useState(!1),[J,W]=r.useState(null),[D,Y]=r.useState(null),[H,ee]=r.useState(!1),{confirmAction:X,confirmDialog:ie,resolveConfirmDialog:q}=Ks(),g=P.find(O=>O.isActive)??P[0]??null,T=s?.preferences.defaultTeamId?.trim()||null,_=S??T,ne=An(u),de=s?.accountMeta.asOf??"",se=ve(u?.environment,g?.environment),te=j?ve(g?.displayLabel,g?.handle,u?.label,u?.activeProfile?.handle,"Signed in"):w?"Account needs attention":y?"No account connected":"Loading account",ue=j?R??ks(se):w?"Not connected":y?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",he=P.length>0,re=w?Ot(u?.error):null,M=r.useMemo(()=>k.filter(O=>O.status==="active"),[k]),B=(r.useMemo(()=>_?M.find(O=>O.teamId===_)??null:null,[M,_])??Dn(M))?.teamId??"",Z=r.useMemo(()=>M.map(O=>({value:O.teamId,label:ve(O.displayName,O.name,O.slug,"Team"),description:In(O.role)})),[M]),Q=B||Z[0]?.value||"",Ae=Z.length>0,gn=!n||!!E||!!A||M.length===0,us=b?Ve(b):null,hs=!!(us&&J===us),xn=j||w,jn=ve(D?.version,s?.server.version,"Loading"),ms=D?D.devMode?"Dev mode":D.packaged?`${Ut(D.releaseChannel)} build`:"Local build":null,ps=Tt(ve(g?.baseUrl,u?.activeProfile?.baseUrl,u?.baseUrl,"https://openpond.ai"));r.useEffect(()=>{const O=window.openpond?.getDesktopRuntimeInfo;if(!O)return;let K=!1;return O().then(V=>{K||Y(V)}).catch(()=>{K||Y(null)}),()=>{K=!0}},[]),r.useEffect(()=>{if(!n||!ne){C([]),L(null),x(!1);return}let O=!1;const K=$n(ne);return K?(C(K),x(!1)):(C([]),x(!0)),L(null),En({accountKey:ne,force:!!de,fetchOrganizations:async()=>(await $.organizations(n)).organizations.map(Mn).filter(ae=>!!ae).filter(ae=>ae.status==="active")}).then(V=>{O||C(V)}).catch(V=>{O||(K||C([]),L(V instanceof Error?V.message:String(V)))}).finally(()=>{O||x(!1)}),()=>{O=!0}},[de,n,ne]),r.useEffect(()=>{S&&T===S&&N(null)},[T,S]);async function vn(O,K={notify:!0}){const V=M.find(ae=>ae.teamId===O)??null;if(!(!n||!V||E||(S??T)===V.teamId)){N(V.teamId),v(V.teamId),o(null),Ln({teamId:V.teamId,accountKey:ne,force:!0,fetchAgents:async ae=>(await $.listSandboxAgents(n,{teamId:ae})).agents}).catch(()=>{});try{p(await $.savePreferences(n,{defaultTeamId:V.teamId})),K.notify&&f?.("Default team updated","success")}catch(ae){N(null),o(ae instanceof Error?ae.message:String(ae))}finally{v(null)}}}async function Fe(O="Continue"){return xn?X({title:"Change active OpenPond account?",body:Et,confirmLabel:O,cancelLabel:"Cancel"}):!0}async function bn(O){await Fe("Save account")&&(await l({apiKey:O.apiKey??"",handle:O.handle,baseUrl:O.baseUrl,apiBaseUrl:O.apiBaseUrl,environment:O.environment}),G(!1))}async function yn(O){if(!n||!b)throw new Error("OpenPond server connection is not ready.");if(b.isActive&&!await Fe("Save endpoints"))return;const K=Ve(b);W(K),o(null);try{const V=await $.updateOpenPondAccountConfig(n,{handle:O.handle??b.handle,currentBaseUrl:O.currentBaseUrl,baseUrl:O.baseUrl,apiBaseUrl:O.apiBaseUrl,chatApiBaseUrl:O.chatApiBaseUrl,environment:Lt(O.environment),setActive:b.isActive});m(V),f?.("Account endpoints updated","success"),z(null)}catch(V){throw o(V instanceof Error?V.message:String(V)),V}finally{W(null)}}async function Nn(O){const K=O.handle?.trim()||"";K&&await Fe("Switch account")&&await d(K,O.baseUrl)}async function wn(O){const K=O.handle?.trim()||"";if(!K||O.isActive)return;const V=ve(O.displayLabel,O.email,O.handle,"this account");await X({title:"Remove saved account?",body:`Remove ${V} 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 c(K,O.baseUrl)&&f?.("Account removed","success")}async function Sn(){const O=window.openpond?.reloadDesktopApp;if(!(!O||H)){ee(!0),o(null);try{const K=await O();if(!K.ok)throw new Error(K.error??"OpenPond could not refresh the app.")}catch(K){ee(!1),o(K instanceof Error?K.message:String(K))}}}async function kn(){const O=window.openpond?.browser;O?.openExternal&&(await O.openExternal({conversationId:"openpond-account-sign-up",url:ps})).ok||window.open(ps,"_blank","noopener,noreferrer")}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(ge,{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(le,{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(ys,{handle:te,image:j?u?.avatarUrl??g?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:te}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:j&&R?"private-account-email":j?void 0:"account-summary-copy",tabIndex:j&&R?0:void 0,children:ue}),j&&Ae?e.jsx(Ie,{className:"account-team-dropdown",compact:!0,disabled:gn,label:"Default team",options:Z,value:Q,onChange:O=>{vn(O)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(We,{state:h,label:y?"not signed in":void 0})})]}),he?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:[P.length," account",P.length===1?"":"s"]})]}),e.jsx("p",{className:"account-list-note",children:"Switch to another account before removing the active account."}),P.map(O=>{const K=O.handle?.trim()||"",V=ve(O.displayLabel,O.handle,"Unknown account"),ae=O.email?.trim()||null,fs=Ve(O);return e.jsxs("div",{className:"account-row",children:[e.jsx(ys,{handle:V,image:O.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:V}),ae?e.jsx("span",{className:"private-account-email",tabIndex:0,children:ae}):null,e.jsx("span",{children:ks(O.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(We,{state:O.authHealth}),O.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:"settings-icon-button ghost account-endpoint-action",disabled:!n||a||!!J||!K,type:"button","aria-label":`Configure ${V} environment`,title:"Configure account environment",onClick:()=>z(O),children:e.jsx(is,{size:15})}),O.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:a||!K,type:"button",onClick:()=>{Nn(O)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:a||!K,type:"button","aria-label":`Remove ${V}`,title:`Remove ${V}`,onClick:()=>{wn(O)},children:e.jsx(ke,{size:13})})]})]})]},fs)})]}):null,u?.products&&u.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:[u.products.length," active"]})]}),u.products.map(O=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:O.name}),e.jsx("span",{children:O.type})]}),e.jsx(We,{state:O.status})]},O.id))]}),e.jsxs("div",{className:"settings-footnote account-build-footnote",children:[e.jsxs("div",{className:"account-build-details",children:[e.jsx("span",{children:"Build version"}),e.jsxs("div",{className:"account-build-version",children:[e.jsx("strong",{children:zt(jn)}),ms?e.jsx("span",{className:`account-build-context${D?.devMode?" development":""}`,children:ms}):null]})]}),e.jsxs("div",{className:"account-build-actions",children:[D?.canReload?e.jsxs("button",{className:"settings-secondary compact",disabled:H,type:"button",title:"Reload the local Electron app",onClick:()=>{Sn()},children:[e.jsx(le,{className:H?"settings-spin":void 0,size:14}),e.jsx("span",{children:H?"Refreshing":"Refresh app"})]}):null,j?null:e.jsxs("button",{className:"settings-primary compact account-sign-up-action",type:"button",onClick:()=>{kn()},children:[e.jsx("span",{children:"Sign up"}),e.jsx(On,{size:13})]})]})]}),re?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:re})]}):null,b?e.jsx(Ss,{account:b,busy:hs,onClose:()=>{hs||z(null)},onSave:yn}):null,F?e.jsx(Ss,{busy:a,mode:"connect",onClose:()=>{a||G(!1)},onSave:bn}):null,e.jsx(Js,{state:ie,onResolve:q})]})}function Ve(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function ve(...s){for(const n of s){const a=n?.trim();if(a)return a}return""}function Ot(s){const n=s?.trim();if(!n)return null;const a=n.toLowerCase();return a.includes("protected deployment")?"OpenPond could not reach the account service. Restart and try again.":a.includes("unexpected token '<'")||a.includes("<!doctype")?"OpenPond received a web login page instead of account data. Restart and 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 ks(s){const n=s.trim().toLowerCase();return!n||n==="production"?"Production":"Environment"}function Lt(s){const n=s?.trim();return!n||n.toLowerCase()==="production"?"custom":n}function Tt(s){try{return new URL("/login",s).toString()}catch{return"https://openpond.ai/login"}}function zt(s){const n=s.trim();return!n||n==="Loading"?"Loading":n.startsWith("v")?n:`v${n}`}function Ut(s){return s&&`${s[0].toUpperCase()}${s.slice(1)}`}function Bt({advancedWorkspaceControls:s,defaultBranchPrefix:n,defaultNewProjectDirectory:a,preferences:t,saving:l,steerActiveResponses:i,chooseDefaultProjectDirectory:d,saveDefaults:c,setAdvancedWorkspaceControls:m,setSteerActiveResponses:p,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:f}){const u=Ze(n)===t.defaultBranchPrefix&&a.trim()===t.defaultNewProjectDirectory&&s===t.advancedWorkspaceControls&&i===t.steerActiveResponses;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h2",{children:"General"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:h=>{c(h)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:i,disabled:l,onChange:h=>p(h.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Steer active responses"}),e.jsx("small",{children:"Send a new message into the active response immediately. Turn this off to queue it instead."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:h=>m(h.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:h=>o(h.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:h=>f(h.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{d()},children:[e.jsx(nn,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||u,children:e.jsx("span",{children:l?"Saving":"Save settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[Ze(n),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||t.defaultNewProjectDirectory})]})]})}function Ht({diagnostics:s,diagnosticsAvailable:n,diagnosticsBusy:a,diagnosticsStatus:t,logDir:l,logLineLimit:i,logLines:d,logViewBusy:c,logViewSummary:m,logViewportRef:p,tailLogs:o,copyRecentLogs:f,exportDiagnosticsBundle:u,loadOlderLogs:h,openLogsFolder:j,refreshLogView:y,toggleTailLogs:w}){const R=s.filter(k=>k.name==="diagnostic"&&k.status==="failed").slice().reverse().map(_t),P=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:[R.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:R.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):R.map(k=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Ys,{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||!P?.openLogsFolder,onClick:()=>{j()},children:[e.jsx(nn,{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||!P?.exportDiagnostics,onClick:()=>{u()},children:[e.jsx(Tn,{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||!P?.copyRecentLogs,onClick:()=>{f()},children:[e.jsx(vt,{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:m}),e.jsx("button",{type:"button",className:`settings-icon-button ${o?"active":""}`,title:o?"Pause tail":"Tail logs","aria-label":o?"Pause tail":"Tail logs",disabled:!P?.readRecentLogs,onClick:w,children:o?e.jsx(sn,{size:15}):e.jsx(tn,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:c!==null||!P?.readRecentLogs,onClick:()=>{y(i,"refresh")},children:e.jsx(le,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:c!==null||!P?.readRecentLogs,onClick:h,children:[e.jsx(dt,{size:15}),e.jsx("span",{children:c==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:p,className:"diagnostics-log-viewer",role:"log","aria-live":o?"polite":"off",children:d.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:c?"Loading logs":"No log lines"}):d.map((k,C)=>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}:${C}`))}),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 _t(s){const n=Cs(s.data),a=Cs(n.context),l=fe(n.stack)??fe(n.detail)??fe(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:Gt(s.timestamp),message:Ft(s,n),surface:fe(n.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function Ft(s,n){return fe(s.error)??fe(s.output)??fe(n.message)??fe(n.error)??"Diagnostic event"}function Gt(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Cs(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function fe(s){return typeof s=="string"&&s.trim()?s.trim():null}const Rs=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function qt({editorPreferences:s,lspStatus:n,preferences:a,restarting:t,saving:l,statusLoading:i,refreshLspStatus:d,restartLanguageServers:c,saveEditorSettings:m,setEditorPreferences:p,setLanguageCustomCommand:o,setLanguageMode:f}){const u=JSON.stringify(s)!==JSON.stringify(a.editor),h=new Map(n?.languages.map(j=>[j.language,j])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:j=>{m(j)},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(Ie,{value:s.languageServers,disabled:l,label:"Language servers",options:zn,onChange:j=>p(y=>({...y,languageServers:j}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:j=>p(y=>({...y,diagnosticsWhileEditing:j.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:j=>p(y=>({...y,checkOnSave:j.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:Rs.map(j=>{const y=s.languages[j.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:j.label}),e.jsx("span",{children:Ps(h.get(j.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Ie,{value:y.mode,disabled:l||s.languageServers==="off",label:`${j.label} language server mode`,options:Un,onChange:w=>f(j.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:j.placeholder,onChange:w=>o(j.id,w.target.value)})]})]},j.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!u,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:()=>{d()},children:e.jsx(le,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||t,onClick:()=>{c()},children:[e.jsx(Rt,{className:t?"settings-spin":void 0,size:15}),e.jsx("span",{children:t?"Restarting":"Restart"})]})]})]}),Rs.map(j=>{const y=h.get(j.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:j.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:Ps(y,i)})]},j.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 Ps(s,n){return n&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function As({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:d=>{l(d)},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:d=>i(d.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 Wt({subagentsEnabled:s,subagentDelegationMode:n,subagentsUseDefaultModel:a,subagentsProvider:t,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:d,subagentsMaxConcurrentRunsPerProvider:c,subagentsMaxConcurrentRunsPerWorkspaceTarget:m,preferences:p,providers:o,saving:f,saveDefaults:u,changeSubagentsProvider:h,setSubagentsEnabled:j,setSubagentDelegationMode:y,setSubagentsUseDefaultModel:w,setSubagentsModel:R,setSubagentsMaxConcurrentRuns:P,setSubagentsMaxConcurrentRunsPerProvider:k,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:C,setSubagentRoleEnabled:x,setSubagentRoleIsolationMode:A,setSubagentRoleMaxConcurrentRuns:L,setSubagentRoleModel:E,setSubagentRolePeerMessages:v,setSubagentRoleToolPolicy:S,changeSubagentRoleProvider:N}){const b=Qs(o,{enabledOnly:!0}),z=a?p.defaultChatProvider:t,F=a?p.defaultChatModel:l,G=on(Be(z,o),F),J=a?null:{providerId:t,modelId:l.trim()},W=Qt({enabled:s,delegationMode:n,defaultModelRef:J,roles:i,maxConcurrentRuns:d,maxConcurrentRunsPerProvider:c,maxConcurrentRunsPerWorkspaceTarget:m},p);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:D=>{u(D)},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${W?"":" dirty"}`,disabled:f||W,children:e.jsx("span",{children:f?"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:f,onChange:D=>j(D.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:f||!s,onChange:D=>y(D.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:z,disabled:f||!s,onChange:D=>{w(!1),h(D.target.value)},children:b.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:F,disabled:f||!s,onChange:D=>{w(!1),R(D.target.value)},children:G.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map(D=>{const Y=Bn.find(g=>g.id===D.id),H=D.modelRef?.providerId??z,ee=D.modelRef?.modelId||Hn(H,o)||F,X=Yt(b,o,{providerId:H,modelId:ee}),ie=Le(H,ee),q=f||!s||!D.enabled;return e.jsxs("section",{className:`subagent-role-row${D.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:Y?.label??D.id}),e.jsx("small",{children:Y?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${Y?.label??D.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:D.enabled,disabled:f||!s,onChange:g=>x(D.id,g.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:ie,disabled:q,onChange:g=>{const T=X.find(_=>_.value===g.target.value);T&&(N(D.id,T.providerId),E(D.id,T.modelId))},children:X.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:D.isolationMode,disabled:q,onChange:g=>A(D.id,g.target.value),children:Vt.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:D.toolPolicy,disabled:q,onChange:g=>S(D.id,g.target.value),children:Kt.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:D.peerMessages,disabled:q,onChange:g=>v(D.id,g.target.value),children:Jt.map(g=>e.jsx("option",{value:g.value,children:g.label},g.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:D.maxConcurrentRuns,disabled:q,onChange:g=>L(D.id,Ds(g.target.value,1))})]})})]},D.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:d,disabled:f||!s,onChange:D=>P(Ds(D.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:c??"",placeholder:"No cap",disabled:f||!s,onChange:D=>k(as(D.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:m??"",placeholder:"No cap",disabled:f||!s,onChange:D=>C(as(D.target.value))})]})]})]})]})})}const Vt=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],Kt=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],Jt=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function on(s,n){const a=n.trim();return!a||s.some(t=>t.value===a)?s:[{value:a,label:a},...s]}function Le(s,n){return JSON.stringify([s,n])}function Yt(s,n,a){const t=[];for(const l of s){const i=on(Be(l.value,n),l.value===a.providerId?a.modelId:"");for(const d of i)t.push({value:Le(l.value,d.value),label:`${l.label} / ${d.label}`,providerId:l.value,modelId:d.value})}return a.modelId&&!t.some(l=>l.value===Le(a.providerId,a.modelId))&&t.unshift({value:Le(a.providerId,a.modelId),label:`${Te(a.providerId,n)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),t}function as(s){const n=s.trim();if(!n)return null;const a=Number(n);return Number.isFinite(a)?a:null}function Ds(s,n){return as(s)??n}function Qt(s,n){const a=n.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&Zt(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 Zt(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const Xt=[{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 ea({currentUserId:s,enabled:n,mode:a,threads:t,onModeChange:l,onThreadMuteChange:i}){const[d,c]=r.useState(null),[m,p]=r.useState(null);ls(m);const o=r.useMemo(()=>t.filter(h=>h.archivedAt===null).map(h=>({thread:h,label:sa(h,s)})).sort((h,j)=>{const y=+!!j.thread.mutedAt-+!!h.thread.mutedAt;return y!==0?y:h.label.localeCompare(j.label)}),[s,t]),f=o.filter(({thread:h})=>!!h.mutedAt).length,u=r.useCallback(async h=>{c(h.id),p(null),await i(h.id,!h.mutedAt)||p("Could not update this conversation. Try again."),c(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:Xt.map(h=>e.jsxs("label",{className:`notification-mode-option${a===h.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===h.mode,onChange:()=>l(h.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:h.label}),e.jsx("small",{children:h.detail})]})]},h.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:f===1?"1 muted":`${f} muted`})]}),n?o.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):o.map(({thread:h,label:j})=>{const y=!!h.mutedAt,w=d===h.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${y?" muted":""}`,children:y?e.jsx(ut,{size:15}):e.jsx(an,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:j}),e.jsx("small",{children:y?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:d!==null,onClick:()=>{u(h)},children:w?"Saving":y?"Unmute":"Mute"})]},h.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 sa(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 na({canSaveCurrentTemplate:s,personalizationTemplateId:n,personalizationTemplateOptions:a,saveAsNewOpen:t,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:d,soulDraft:c,templateNameDraft:m,changePersonalizationTemplate:p,changeSoulDraft:o,openSaveAsNew:f,resetPersonalizationDraft:u,savePersonalization:h,setSaveAsNewOpen:j,setTemplateNameDraft:y}){function w(R){R.preventDefault(),h(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:m,onChange:R=>y(R.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:()=>j(!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||!c.trim()||!m.trim(),onClick:()=>{h(!0)},children:e.jsx(rs,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:d?"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||!c.trim(),onClick:f,children:e.jsx(ge,{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(Ie,{value:n,disabled:l||a.length===0,label:"Personalization template",options:a,onChange:R=>{p(R)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:c,onChange:R=>o(R.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:u,children:e.jsx(_e,{size:15})}),d&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(os,{size:15})})]})]})]})}function ta({connection:s,profile:n,selectedDefaultTeamId:a}){const t=pt(s),l=ia(t.schedules);return ls(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(Is,{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(aa,{}),n.agents.map(i=>e.jsx(la,{agent:i,defaultAction:n.summary.defaultAction,profile:n,selectedDefaultTeamId:a},i.id)),l.paused.map(i=>e.jsx(Is,{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 aa(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{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($e,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx($e,{status:{state:"ready",label:"Built in"}})})]})}function la({agent:s,defaultAction:n,profile:a,selectedDefaultTeamId:t}){const l=ca(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(He,{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($e,{status:l.check})}),e.jsx("td",{children:e.jsx($e,{status:l.sync})})]})}function Is({pending:s,refreshing:n,schedule:a,onRefresh:t,onRun:l,onToggle:i}){const d=ra(a),c=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(He,{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($e,{status:d})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:oa(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(le,{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(_e,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:c,"aria-label":`${c}: ${a.scheduleName}`,onClick:i,children:a.enabled?e.jsx(sn,{size:14}):e.jsx(tn,{size:14})})]})]})})]})}function $e({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function ia(s){const n=[],a=[];for(const t of s)t.enabled?n.push(t):a.push(t);return n.sort((t,l)=>$s(t)-$s(l)),{active:n,paused:a}}function $s(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function ra(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 oa(s){const n=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&n.push(`next ${Es(s.nextRunAt)}`),s.lastRunAt&&n.push(`last ${Es(s.lastRunAt)}`),n.join(" - ")}function Es(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 ca(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||ua(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(da(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 da(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}function ua(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}async function ha(s){const n=s.catalog.workflows.find(l=>l.workflow.id===s.workflowId);if(!n)throw new Error("Selected Profile workflow is unavailable.");const a=s.client??$,t=await a.createSession(s.connection,{experience:"work",provider:"openpond",currentProfile:s.catalog.profileRef,profileWorkflowBinding:n.binding,title:n.workflow.label});return await a.sendTurn(s.connection,t.id,{prompt:n.workflow.label,workflowInput:s.value,approvalPolicy:"on-request",sandbox:"workspace-write",codexPermissionMode:"default"}),t.id}function ma({connection:s,selectedProfileKey:n,onError:a,onOpenSession:t,onToast:l}){const[i,d]=r.useState(null),[c,m]=r.useState(!1),[p,o]=r.useState(null),[f,u]=r.useState("{}"),[h,j]=r.useState(!1),[y,w]=r.useState(null);r.useEffect(()=>{if(!s||!n){d(null);return}let k=!0;return m(!0),d(null),o(null),w(null),$.profileWorkflows(s).then(C=>{k&&d(C)}).catch(C=>{k&&w(C instanceof Error?C.message:String(C))}).finally(()=>{k&&m(!1)}),()=>{k=!1}},[s,n]);const R=i?.workflows.find(k=>k.workflow.id===p);async function P(k){if(k.preventDefault(),!s||!i||!R||h)return;let C;try{C=JSON.parse(f)}catch{w("Workflow input must be valid JSON.");return}j(!0),w(null),a(null);try{const x=await ha({connection:s,catalog:i,workflowId:R.workflow.id,value:C});t?.(x),l?.(`Started ${R.workflow.label}`,"success"),o(null),u("{}")}catch(x){const A=x instanceof Error?x.message:String(x);w(A),a(A)}finally{j(!1)}}return n?e.jsxs("section",{"aria-label":"Profile workflows",className:"profile-workflows",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Workflows"}),e.jsx("p",{children:"Run a workflow from this Profile’s released source."})]}),c?e.jsx("p",{children:"Loading workflows…"}):null,y?e.jsx("p",{role:"alert",children:y}):null,i&&i.workflows.length===0?e.jsx("p",{children:"No workflows in this Profile yet."}):null,i?.workflows.map(k=>e.jsxs("div",{className:"profile-workflows-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:k.workflow.label}),e.jsx("p",{children:k.workflow.description}),e.jsxs("small",{children:["Source ",k.binding.sourceRevision.slice(0,10)," · release ",k.binding.harnessRelease.contentHash.slice(0,10)]})]}),e.jsx("button",{disabled:h,onClick:()=>{w(null),u("{}"),o(k.workflow.id)},type:"button",children:"Run"})]},k.workflow.id)),R?e.jsxs("form",{className:"profile-workflows-form",onSubmit:P,children:[e.jsxs("h4",{children:["Run ",R.workflow.label]}),e.jsx("label",{htmlFor:"profile-workflow-input",children:"Input JSON"}),e.jsx("textarea",{id:"profile-workflow-input",onChange:k=>u(k.target.value),value:f}),e.jsx("pre",{children:JSON.stringify(R.workflow.inputSchema,null,2)}),e.jsx("button",{disabled:h,type:"submit",children:h?"Starting…":"Start workflow"}),e.jsx("button",{disabled:h,onClick:()=>o(null),type:"button",children:"Cancel"})]}):null]}):null}function Ms(s){switch(s.kind){case"profile":return"Complete Profile";case"workflow":return`Workflow · ${s.workflowId}`;case"skill":return`Skill · ${s.skillPath}`;case"agent_action":return`Agent action · ${s.actionId}`}}function De(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString()}function pa(s){return Object.values(s.statuses).flatMap(n=>{if(!n.enabled||!n.available||!n.credential.connected)return[];const a=s.providers[n.id];return[...new Set([...n.modelIds,...s.modelCaches[n.id]?.models.map(l=>l.id)??[],...a?.modelOverrides??[],n.defaultModel,a?.defaultModel].filter(l=>!!l))].map(l=>({key:JSON.stringify([n.id,l]),providerId:n.id,modelId:l,label:`${n.displayName} · ${l}`}))})}function fa({connection:s,selectedProfileKey:n}){const[a,t]=r.useState(null),[l,i]=r.useState(null),[d,c]=r.useState(50),[m,p]=r.useState(20),[o,f]=r.useState(20),[u,h]=r.useState([]),[j,y]=r.useState(!1),[w,R]=r.useState([]),[P,k]=r.useState(""),[C,x]=r.useState(null),[A,L]=r.useState(!1),[E,v]=r.useState(!1),[S,N]=r.useState(null),[b,z]=r.useState(null),[F,G]=r.useState(!1),[J,W]=r.useState(null);if(r.useEffect(()=>{if(!s||!n){t(null),R([]),x(null);return}let g=!0;return G(!0),t(null),i(null),c(50),p(20),f(20),h([]),R([]),k(""),x(null),z(null),W(null),$.profileEvaluations(s).then(T=>{g&&t(T)}).catch(T=>{g&&W(T instanceof Error?T.message:String(T))}).finally(()=>{g&&G(!1)}),$.providerSettings(s).then(T=>{if(!g)return;const _=pa(T);R(_),k(_[0]?.key??"")}).catch(T=>{g&&W(T instanceof Error?T.message:String(T))}),()=>{g=!1}},[s,n]),!n)return null;const D=a?.definitions.find(g=>g.id===l),Y=D?a?.runs.filter(g=>g.manifest.profileEvaluation?.definitionId===D.id)??[]:[],H=async()=>{const g=w.find(_=>_.key===P);if(!s||!D||!g||A)return;const T={id:`evaluation-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),definitionId:D.id,modelRef:{providerId:g.providerId,modelId:g.modelId}};L(!0),x(null),z(null),W(null);try{x({request:T,prepared:await $.profileEvaluationPrepare(s,T)})}catch(_){W(_ instanceof Error?_.message:String(_))}finally{L(!1)}},ee=async()=>{if(!(!s||!C||E)){v(!0),W(null);try{const g=await $.profileEvaluationRun(s,{...C.request,expectedManifestHash:C.prepared.manifest.contentHash});t(await $.profileEvaluations(s)),x(null),z(`Run ${g.manifest.id} ${g.passed?"passed":"did not pass"}.`)}catch(g){W(g instanceof Error?g.message:String(g))}finally{v(!1)}}},X=async g=>{const T=w.find(_=>_.key===P);if(!(!s||!T||S)){N(g),z(null),W(null);try{const _=await $.profileEvaluationRunSuite(s,{id:`suite-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),suiteId:g,modelRef:{providerId:T.providerId,modelId:T.modelId}});t(await $.profileEvaluations(s)),z(`Suite ${_.id} ${_.passed?"passed":"did not pass"}.`)}catch(_){W(_ instanceof Error?_.message:String(_))}finally{N(null)}}},ie=g=>{h(T=>T.includes(g)?T.filter(_=>_!==g):[...T,g])},q=async()=>{if(!(!s||u.length<2||j)){y(!0),W(null);try{await $.profileEvaluationCompare(s,u),t(await $.profileEvaluations(s)),h([])}catch(g){W(g instanceof Error?g.message:String(g))}finally{y(!1)}}};return e.jsxs("section",{"aria-label":"Profile evaluations",className:"profile-evaluations",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Evaluations"}),e.jsx("p",{children:"Checks and retained results for this Profile’s released components."})]}),F?e.jsx("p",{children:"Loading evaluations…"}):null,J?e.jsx("p",{role:"alert",children:J}):null,b?e.jsx("p",{role:"status",children:b}):null,a&&a.definitions.length===0?e.jsx("p",{children:"No evaluations in this Profile yet."}):null,a?.suites.length?e.jsxs("div",{className:"profile-evaluations-suites","aria-label":"Evaluation suites",children:[e.jsx("label",{htmlFor:"profile-evaluation-suite-model",children:"Suite model"}),e.jsx("select",{id:"profile-evaluation-suite-model",value:P,disabled:!!S,onChange:g=>k(g.target.value),children:w.map(g=>e.jsx("option",{value:g.key,children:g.label},g.key))}),w.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run a suite."}):null,a.suites.map(g=>e.jsxs("div",{className:"profile-evaluations-suite",children:[e.jsx("strong",{children:g.label}),e.jsxs("span",{children:[g.scope==="profile"?"Profile suite":"Component suite"," · ",g.definitionIds.length," checks"]}),e.jsx("button",{type:"button",disabled:!P||!!S||E,onClick:()=>{X(g.id)},children:S===g.id?"Running suite…":"Run suite"}),a.suiteRuns.filter(T=>T.suiteId===g.id).slice(0,5).map(T=>e.jsxs("details",{className:"profile-evaluations-suite-run",children:[e.jsxs("summary",{children:[De(T.completedAt)," · ",T.passed?"Passed":"Did not pass"," · ",T.members.length," checks"]}),e.jsxs("small",{children:["Profile source ",T.sourceRevision.slice(0,12)," · Suite run ",T.id]}),e.jsx("ul",{children:T.members.map(_=>e.jsxs("li",{children:[e.jsx("strong",{children:T.sourceRevision===a.sourceRevision?a.definitions.find(ne=>ne.id===_.definitionId)?.label??_.definitionId:_.definitionId}),e.jsxs("span",{children:[_.passed?"Passed":"Did not pass"," · ",_.score===null?"No score":`${Math.round(_.score*100)}%`," · Run ",_.runManifest.id]})]},_.runManifest.id))})]},T.id))]},g.id))]}):null,a?.definitions.map(g=>{const T=a.runs.find(_=>_.manifest.profileEvaluation?.definitionId===g.id);return e.jsxs("div",{className:"profile-evaluations-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:g.label}),e.jsx("p",{children:g.description||Ms(g.target)}),e.jsxs("small",{children:[Ms(g.target)," · ",g.taskIds.length," tasks · ",g.seeds.length," seeds"]}),T?e.jsxs("small",{children:["Latest: ",T.passed?"Passed":"Did not pass"," · ",T.metric.value===null?"No score":`${Math.round(T.metric.value*100)}%`," · ",De(T.completedAt)]}):null]}),e.jsx("button",{type:"button","aria-expanded":l===g.id,onClick:()=>{i(l===g.id?null:g.id),c(50),p(20),x(null)},children:l===g.id?"Hide details":"View details"})]},g.id)}),D?e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsx("h4",{children:D.label}),e.jsxs("p",{children:["Taskset ",D.tasksetRelease.id," · ",D.tasksetRelease.contentHash.slice(0,12)]}),e.jsxs("p",{children:["Frozen split: ",D.split," · Minimum pass rate: ",Math.round(D.criterion.minimumPassRate*100),"%"]}),e.jsxs("div",{className:"profile-evaluations-run-form",children:[e.jsx("label",{htmlFor:"profile-evaluation-model",children:"Model"}),e.jsx("select",{id:"profile-evaluation-model",value:P,disabled:A||E,onChange:g=>{k(g.target.value),x(null)},children:w.map(g=>e.jsx("option",{value:g.key,children:g.label},g.key))}),w.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run this check."}):null,e.jsx("button",{type:"button",disabled:!P||A||E,onClick:()=>{H()},children:A?"Checking run…":"Check run setup"}),C?e.jsxs("div",{className:"profile-evaluations-run-plan",children:[e.jsx("strong",{children:"Run setup"}),e.jsxs("small",{children:["Profile source ",C.prepared.manifest.profileEvaluation?.sourceRevision.slice(0,12)," · Harness ",C.prepared.manifest.execution.kind==="harness"?C.prepared.manifest.execution.harnessRelease.id:""]}),e.jsxs("small",{children:["Taskset ",C.prepared.taskset.id," · ",C.prepared.manifest.population.length," attempts · ",C.prepared.manifest.limits.timeoutMs/1e3,"s per attempt"]}),e.jsxs("small",{children:["Connected app scopes: ",C.prepared.taskset.connectedAppScopes.join(", ")||"none declared"]}),e.jsx("button",{type:"button",disabled:E,onClick:()=>{ee()},children:E?"Running evaluation…":"Run evaluation"})]}):null]}),e.jsxs("div",{className:"profile-evaluations-cases",children:[e.jsx("strong",{children:"Task cases"}),e.jsx("ul",{children:D.taskIds.slice(0,d).map(g=>e.jsx("li",{children:g},g))}),D.taskIds.length>d?e.jsx("button",{type:"button",onClick:()=>c(g=>g+50),children:"Show more cases"}):null,e.jsxs("span",{children:["Seeds: ",D.seeds.join(", ")]})]}),e.jsxs("div",{className:"profile-evaluations-history",children:[e.jsx("strong",{children:"Run history"}),Y.length===0?e.jsx("p",{children:"No runs for this check yet."}):e.jsx("ul",{children:Y.slice(0,m).map(g=>e.jsxs("li",{children:[e.jsxs("span",{children:[De(g.completedAt)," · ",g.passed?"Passed":"Did not pass"," · ",g.receiptRefs.length," attempts"]}),e.jsxs("small",{children:["Model ",g.manifest.policy.kind==="model"?`${g.manifest.policy.model.provider}/${g.manifest.policy.model.model}`:"fixture"," · Source ",g.manifest.profileEvaluation?.sourceRevision.slice(0,10)," · Run ",g.manifest.id]})]},g.manifest.id))}),Y.length>m?e.jsx("button",{type:"button",onClick:()=>p(g=>g+20),children:"Show more runs"}):null]})]}):null,a&&a.runs.length>1?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Compare evaluation runs",children:[e.jsx("h4",{children:"Compare runs"}),e.jsx("p",{children:"Select two or more runs. Comparisons require the same Taskset, cases, environment, grading policy, limits, and runtime."}),e.jsx("div",{className:"profile-evaluations-comparison-runs",children:a.runs.slice(0,o).map(g=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:u.includes(g.manifest.id),onChange:()=>ie(g.manifest.id),disabled:j}),e.jsxs("span",{children:[e.jsxs("strong",{children:[g.manifest.profileEvaluation?.definitionId??"Profile evaluation"," · ",g.metric.value===null?"No score":`${Math.round(g.metric.value*100)}%`]}),e.jsxs("small",{children:[De(g.completedAt)," · ",g.manifest.policy.kind==="model"?`${g.manifest.policy.model.provider}/${g.manifest.policy.model.model}`:"fixture"," · Source ",g.manifest.profileEvaluation?.sourceRevision.slice(0,10)," · ",g.manifest.id]})]})]},g.manifest.id))}),a.runs.length>o?e.jsx("button",{type:"button",onClick:()=>f(g=>g+20),children:"Show more runs"}):null,e.jsx("button",{type:"button",disabled:u.length<2||j,onClick:()=>{q()},children:j?"Comparing…":`Save comparison of ${u.length} runs`})]}):null,a&&a.comparisons.length>0?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Saved evaluation comparisons",children:[e.jsx("h4",{children:"Saved comparisons"}),e.jsx("ul",{children:a.comparisons.map(g=>e.jsxs("li",{children:[e.jsxs("strong",{children:[De(g.createdAt)," · ",g.members.length," runs"]}),e.jsx("ul",{children:g.members.map(T=>e.jsxs("li",{children:[T.source.definitionId," · ",T.policy.kind==="model"?`${T.policy.model.provider}/${T.policy.model.model}`:"fixture"," · Source ",T.source.sourceRevision.slice(0,10)," · ",T.score===null?"No score":`${Math.round(T.score*100)}%`]},T.runManifest.id))})]},g.id))})]}):null]})}function ga({actions:s,busy:n,library:a,onSelect:t}){const l=a.profiles.find(d=>Xe(d.ref,a.lastUsed))??a.profiles[0]??null,i=l?Ge(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:d=>{const c=_n(a,d.currentTarget.value),m=a.profiles.find(p=>Xe(p.ref,c));m&&t(m)},children:a.profiles.length?a.profiles.map(d=>e.jsx("option",{value:Ge(d.ref),children:d.name},Ge(d.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Fn,{"aria-hidden":"true",size:14})]}),s]})}function xa({addDisabled:s,commitDisabled:n,commitLabel:a,refreshDisabled:t,repoDisabled:l,syncDisabled:i,syncLabel:d,syncStatus:c,onAdd:m,onCommit:p,onRefresh:o,onRepo:f,onSync:u}){const[h,j]=r.useState(!1),y=r.useRef(null);r.useEffect(()=>{if(!h)return;function R(k){y.current?.contains(k.target)||j(!1)}function P(k){k.key==="Escape"&&j(!1)}return document.addEventListener("pointerdown",R),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",R),document.removeEventListener("keydown",P)}},[h]);function w(R){j(!1),R()}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":h,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>j(R=>!R),children:e.jsx(is,{size:15})}),h?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>w(p),children:[e.jsx(Ue,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>w(u),children:[e.jsx(xe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:d}),c?e.jsx("small",{children:c}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>w(f),children:[e.jsx(Me,{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(o),children:[e.jsx(le,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>w(m),children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const ja=[{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 va({connection:s,entry:n,onClose:a,onPublished:t}){const[l,i]=r.useState("github"),[d,c]=r.useState(""),[m,p]=r.useState(`${n.name}-profile`),[o,f]=r.useState("public"),[u,h]=r.useState(()=>n.state.agents.filter(b=>b.enabled).map(b=>b.id)),[j,y]=r.useState(()=>n.state.skills.filter(b=>b.enabled).map(b=>b.name)),[w,R]=r.useState([]),[P,k]=r.useState(null),[C,x]=r.useState(null),[A,L]=r.useState(null),E=r.useMemo(()=>({ref:n.ref,selection:{agentIds:u,skillNames:j,optionalContent:w},target:{provider:l,owner:d.trim()||null,repository:m.trim(),visibility:l==="github"?"public":o}}),[u,n.ref,w,d,l,m,j,o]);function v(b,z,F){return F?[...new Set([...b,z])]:b.filter(G=>G!==z)}async function S(b){if(b.preventDefault(),!(!m.trim()||C)){x("preview"),L(null);try{k(await $.profilePublicationPreview(s,E))}catch(z){L(z instanceof Error?z.message:String(z))}finally{x(null)}}}async function N(){if(!(!P||P.blockedReasons.length>0||C)){x("publish"),L(null);try{const b=await $.profilePublicationPublish(s,{...E,expectedSourceHash:P.sourceHash,confirmed:!0});t(`Published ${n.name} to ${b.owner}/${b.repository}`),a()}catch(b){L(b instanceof Error?b.message:String(b))}finally{x(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:b=>b.stopPropagation(),onSubmit:S,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!C,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."}),P?e.jsx(ba,{preview:P}):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"),f("public")}}),e.jsx(es,{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"),f("private")}}),e.jsx(Gn,{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:d,placeholder:"Uses gh account",onChange:b=>c(b.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:m,onChange:b=>p(b.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:o,onChange:b=>f(b.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(Ke,{title:"Agents",empty:"No Agents in this Profile",children:n.state.agents.map(b=>e.jsx(Je,{checked:u.includes(b.id),label:b.name,detail:b.path,onChange:z=>h(F=>v(F,b.id,z))},b.id))}),e.jsx(Ke,{title:"Skills",empty:"No Skills in this Profile",children:n.state.skills.map(b=>e.jsx(Je,{checked:j.includes(b.name),label:b.name,detail:b.description||b.path,onChange:z=>y(F=>v(F,b.name,z))},b.name))}),e.jsx(Ke,{title:"Optional content",empty:"",children:ja.map(b=>e.jsx(Je,{checked:w.includes(b.id),label:b.label,detail:b.detail,onChange:z=>R(F=>v(F,b.id,z))},b.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:!!C,type:"button",onClick:P?()=>k(null):a,children:P?"Back":"Cancel"}),P?e.jsxs("button",{className:"git-dialog-primary",disabled:!!C||P.blockedReasons.length>0,type:"button",onClick:()=>{N()},children:[e.jsx(xe,{size:14}),e.jsx("span",{children:C==="publish"?"Publishing":P.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!C||!m.trim(),type:"submit",children:C==="preview"?"Building preview":"Review exact files"})]})]})})}function Ke({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 Je({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 ba({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 · ",Os(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," · ",Os(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 Os(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function ya({section:s="all",catalogPresentation:n="list",payload:a,connection:t,onPayload:l,onError:i,onToast:d,onSkillCommand:c,onOpenSession:m,overviewContent:p}){const[o,f]=r.useState(""),[u,h]=r.useState(null),[j,y]=r.useState(!1),[w,R]=r.useState(null),[P,k]=r.useState(null),C=a?.profile??null,x=a?.preferences.defaultTeamId?.trim()||"",A=s==="all"||s==="profile"||s==="controls",L=s==="all"||s==="profile",E=s==="all"||s==="agents",v=s==="all"||s==="profile";async function S(H){t&&(l(await $.bootstrap(t)),d?.(H,"success"))}async function N(H,ee){if(!(!t||u)){h(H),i(null);try{await ee()}catch(X){i(X instanceof Error?X.message:String(X))}finally{h(null)}}}function b(){N("init",async()=>{await $.profileInit(t,{}),await S("Profile initialized")})}function z(){N("commit",async()=>{await $.profileCommit(t,{message:o.trim()||null}),f(""),await S("Profile commit complete")})}function F(){N("push",async()=>{if(!x)throw new Error("Select a default team before syncing a hosted profile.");await $.profileCheck(t,{kind:"all"}),await $.profilePush(t,{teamId:x,ensureHosted:!0,message:null}),await S("Profile synced to hosted profile repo")})}function G(H){N(`select:${H.ref.profileId}`,async()=>{await $.profileSelect(t,H.ref),await S(`Using ${H.name}`)})}function J(H){N("add",async()=>{H.source==="blank"?await $.profileInit(t,{path:H.path,profile:H.profile,template:"blank-profile"}):H.source==="local"?await $.profileLoad(t,H):await $.profileInstall(t,H),y(!1),await S(H.source==="blank"?`${H.profile} created`:"Profile added")})}function W(H){N("update",async()=>{await $.profileUpdate(t,H.ref),await S(`${H.name} updated`)})}function D(H){N("remove",async()=>{await $.profileRemove(t,H.ref),R(null),await S("Profile removed from this device")})}function Y(){N("refresh",async()=>{await S("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[C?.mode==="local"?e.jsxs(e.Fragment,{children:[A?e.jsxs(e.Fragment,{children:[L&&n==="select"?e.jsx(ga,{actions:e.jsx(Ls,{connection:t,onAdd:()=>y(!0),onRefresh:Y,presentation:"menu",profile:C,profileBusy:u,profileCommitMessage:o,selectedDefaultTeamId:x,syncDisabledReason:Ts(C,x),setProfileCommitMessage:f,submitProfileCommit:z,submitProfilePush:F}),busy:!!u,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:G}):e.jsxs(e.Fragment,{children:[L?e.jsx(Na,{busy:!!u,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>y(!0),onRefresh:Y,onRemove:R,onPublish:k,onUpdate:W,onSelect:G}):null,e.jsx(Ls,{connection:t,profile:C,profileBusy:u,profileCommitMessage:o,selectedDefaultTeamId:x,syncDisabledReason:Ts(C,x),setProfileCommitMessage:f,submitProfileCommit:z,submitProfilePush:F})]}),p]}):null,E?e.jsx(ta,{connection:t,profile:C,selectedDefaultTeamId:x}):null,v?e.jsxs(e.Fragment,{children:[e.jsx(Pa,{onSkillCommand:c,profile:C}),e.jsx(ma,{connection:t,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null,onError:i,onOpenSession:m,onToast:d}),e.jsx(fa,{connection:t,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null})]}):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||!!u,type:"button",onClick:()=>y(!0),children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!!u,type:"button",onClick:b,children:[e.jsx(ge,{size:14}),e.jsx("span",{children:u==="init"?"Creating":"Create starter Profile"})]})]})]}),j?e.jsx(wa,{busy:!!u,onClose:()=>y(!1),onSubmit:J}):null,w?e.jsx(Sa,{busy:!!u,entry:w,onClose:()=>R(null),onConfirm:()=>D(w)}):null,P&&t?e.jsx(va,{connection:t,entry:P,onClose:()=>k(null),onPublished:H=>d?.(H,"success")}):null]})}function Na({busy:s,library:n,onAdd:a,onRefresh:t,onRemove:l,onPublish:i,onSelect:d,onUpdate:c}){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(le,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),n.profiles.map(m=>{const p=Xe(m.ref,n.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${p?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||d(m)},onKeyDown:o=>{s||o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),d(m))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Me,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:m.name}),e.jsx("span",{title:m.repoPath,children:m.repoPath})]})]}),e.jsx(cn,{status:{state:m.state.error?"warning":"ready",label:m.state.error?"error":p?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:m.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:m.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[m.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),c(m)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),c(m))},children:[e.jsx(le,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),i(m)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),i(m))},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 ${m.name}`,onClick:o=>{o.stopPropagation(),l(m)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),l(m))},children:[e.jsx(ke,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${m.ref.source}:${m.ref.repositoryId}:${m.ref.profileId}`)})]})}function wa({busy:s,onClose:n,onSubmit:a}){const[t,l]=r.useState("blank"),[i,d]=r.useState(""),[c,m]=r.useState(""),[p,o]=r.useState("");function f(u){if(u.preventDefault(),s)return;if(t==="blank"){const j=p.trim();if(!j)return;a({source:t,path:i.trim()||null,profile:j});return}if(t==="local"){const j=i.trim();if(!j)return;a({source:t,path:j,profile:p.trim()||null});return}const h=c.trim();h&&a({source:t,repositoryId:h,profile:p.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:u=>u.stopPropagation(),onSubmit:f,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(Me,{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:u=>d(u.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:u=>d(u.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:c,placeholder:"owner/repository",onChange:u=>m(u.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:p,placeholder:t==="blank"?"research":"Uses repository default",onChange:u=>o(u.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"?p:t==="local"?i:c).trim(),type:"submit",children:t==="blank"?"Create Profile":"Add Profile"})]})]})})}function Sa({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(ke,{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 Ls({connection:s,onAdd:n,onRefresh:a,presentation:t="toolbar",profile:l,profileBusy:i,profileCommitMessage:d,selectedDefaultTeamId:c,syncDisabledReason:m,setProfileCommitMessage:p,submitProfileCommit:o,submitProfilePush:f}){const[u,h]=r.useState(!1),[j,y]=r.useState(!1),[w,R]=r.useState(!1),P=!s||!!i;return e.jsxs(e.Fragment,{children:[t==="menu"&&n&&a?e.jsx(xa,{addDisabled:!!i,commitDisabled:P,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:P,repoDisabled:!!i||!l,syncDisabled:P||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?Ye(l,c):null,onAdd:n,onCommit:()=>y(!0),onRefresh:a,onRepo:()=>h(!0),onSync:()=>R(!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:P,type:"button",onClick:()=>y(!0),children:[e.jsx(Ue,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:P||!l,type:"button",onClick:()=>R(!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:()=>h(!0),children:[e.jsx(Me,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${Ye(l,c)}`,children:[e.jsx(xe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:Ye(l,c)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),u&&l?e.jsx(Ra,{profile:l,profileBusy:i,onClose:()=>h(!1)}):null,j?e.jsx(ka,{disabled:P,profileBusy:i,profileCommitMessage:d,setProfileCommitMessage:p,submitProfileCommit:o,onClose:()=>y(!1)}):null,w&&l?e.jsx(Ca,{disabled:P,profile:l,profileBusy:i,selectedDefaultTeamId:c,syncDisabledReason:m,submitProfilePush:f,onClose:()=>R(!1)}):null]})}function ka({disabled:s,profileBusy:n,profileCommitMessage:a,setProfileCommitMessage:t,submitProfileCommit:l,onClose:i}){function d(c){c.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:c=>c.stopPropagation(),onSubmit:d,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(Ue,{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:c=>t(c.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(Ue,{size:14}),e.jsx("span",{children:n==="commit"?"Committing":"Commit"})]})]})]})})}function Ca({disabled:s,profile:n,profileBusy:a,selectedDefaultTeamId:t,syncDisabledReason:l,submitProfilePush:i,onClose:d}){const c=Da(n,t),m=c.reduce((f,u)=>f+u.count,0),p=!s&&!l;function o(f){f.preventDefault(),p&&(i(),d())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:d,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:f=>f.stopPropagation(),onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:d,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:[m," ",m===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",Ce(n.summary.localHead??n.git?.head)," - Last pushed"," ",Ce(n.hosted?.lastPushedLocalHead)]})]}),c.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:c.map(f=>e.jsxs("div",{className:`profile-dialog-diff-row ${f.tone??""}`,children:[e.jsx("strong",{children:f.label}),e.jsx("span",{children:f.detail})]},f.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:d,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!p,type:"submit",children:[e.jsx(xe,{size:14}),e.jsx("span",{children:a==="push"?"Syncing":"Confirm sync"})]})]})]})})}function Ra({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(Me,{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"," · ",Ce(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 Pa({onSkillCommand:s,profile:n}){const a=n.skills.slice().sort((i,d)=>i.name.localeCompare(d.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(ze,{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(cn,{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 cn({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function Ce(s){return s?s.slice(0,10):"None"}function Ye(s,n){return dn(s,n)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${Ce(s.hosted.sourceCommitSha)}`:"Not pushed"}function Ts(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 Da(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(dn(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 ${Ce(t)} has not been pushed since ${Ce(l)}.`,count:1}),s.git?.dirty){const c=(s.git.fileCount??s.git.files.length)||(s.diff.fileCount??s.diff.files.length)||1;a.push({label:"Uncommitted files",detail:`${c} local ${c===1?"file":"files"} changed.`,count:c,tone:"warning"})}const d=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 d>0&&a.push({label:"Profile changes",detail:Ia(s),count:d,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 dn(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}const $a=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],Ea=120,Ma=new Set(["openai","xai","zai"]),Oa=new Set(["chatgpt-subscription"]),La="https://api.z.ai/api/coding/paas/v4";function zs(s){return s.split(/[\n,]/).map(n=>n.trim()).filter(Boolean)}function un(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 hn(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function Us(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 Ta(s){return s?.trim().replace(/\/+$/,"")??""}function mn(s,n){return s.id==="zai"&&Ta(n.providers.zai?.baseUrl)===La}function za(s,n){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":mn(s,n)?"Coding Plan key":"API key"}function Ua(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?ns(s.defaultModel,n,s.id):"",i=t===1?"1 model":`${t} models`,d=za(s,n);return[un(s),d,a?i:"",l].filter(Boolean).join(" · ")}function Ba(s){return s!=="openpond"&&ss(s)}function cs(s){return s?Ma.has(s.id)||s.credentialModes.some(n=>Oa.has(n)):!1}function Ha(s){return cs(s)?["api","subscription"]:["api"]}function Bs(s,n){return!s||!n||!cs(s)?"api":s.credential.source==="chatgpt_subscription"||mn(s,n)?"subscription":"api"}function Hs(s,n){const a=qn.filter(t=>!!s?.statuses[t]);return n?a.filter(t=>cs(s?.statuses[t])):a}function _a(s){if(!s)return"Never";const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString()}function Fa(s,n,a=Ea){const t=[],l=new Set,i=new Set(n.map(c=>c.trim()).filter(Boolean)),d=c=>{l.has(c.value)||t.length>=a||(l.add(c.value),t.push(c))};for(const c of s)i.has(c.value)&&d(c);for(const c of s)d(c);return t}function Ga({account:s,codex:n,providers:a,providerBusy:t,validationMessage:l,deleteProviderCredential:i,loadProviderModels:d,refreshProviderModels:c,saveProviderConfig:m,saveProviderCredential:p,startOpenAiSubscriptionAuth:o,validateProvider:f}){const[u,h]=r.useState(null),[j,y]=r.useState(!1),w=r.useMemo(()=>Hs(a,!1),[a]),R=r.useMemo(()=>Hs(a,j),[a,j]),P=u?a?.statuses[u]??null:null;function k(C,x){h(C),x&&d(C)}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:j,onChange:C=>y(C.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[R.length," of ",w.length," presets"]})]}),R.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:R.map(C=>{const x=a.statuses[C],A=a.modelCaches[C],L=x.modelIds.length>0&&(A?.models.length??0)<x.modelIds.length,E=t?.startsWith(`${C}:`)??!1,v=Ba(C),S=C==="openpond"||!!a.providers[C]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${x.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:S,disabled:!v||E,onChange:N=>{k(C,!1),m(C,{enabled:N.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:x.displayName})}),e.jsxs("div",{className:`provider-row-status ${hn(x)}`,children:[E?e.jsx(oe,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:Ua(x,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{k(C,L)},children:"Details"})]},C)})}):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,u&&P&&a?e.jsx(qa,{account:s,codex:n,providerId:u,providerBusy:t,settings:a,status:P,onClose:()=>h(null),onDeleteCredential:i,onRefreshModels:c,onSaveConfig:m,onSaveCredential:p,onStartOpenAiSubscriptionAuth:o,onValidate:f}):null]})}function qa({account:s,codex:n,providerId:a,providerBusy:t,settings:l,status:i,onClose:d,onDeleteCredential:c,onRefreshModels:m,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:f,onValidate:u}){const h=l.providers[a],j=l.modelCaches[a],y=r.useId(),w=r.useRef(a),R=Math.max(j?.models.length??0,i.modelIds.length),P=i.routing.localByok&&ss(a)&&a!=="codex",k=r.useMemo(()=>P?Ha(i):[],[P,i]),C=k.includes("subscription"),[x,A]=r.useState(()=>Bs(i,l)),L=P&&x==="subscription"&&C,E=S=>`${y}-${S}-panel`,v=a==="codex"?"Codex app server":h?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return r.useEffect(()=>{if(w.current!==a){w.current=a,A(Bs(i,l));return}P&&!k.includes(x)&&A("api")},[x,k,P,a,l,i]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:d,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${i.displayName} provider details`,onMouseDown:S=>S.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:d,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:Te(a,l)})]}),e.jsx("div",{className:`provider-state-pill ${hn(i)}`,children:un(i)})]}),P?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:k.map(S=>e.jsx("button",{type:"button",role:"tab",id:`${y}-${S}`,className:x===S?"active":void 0,"aria-selected":x===S,"aria-controls":E(S),onClick:()=>A(S),children:S==="api"?"API":"Subscription"},S))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:Us(i),children:Us(i)})]}),L?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:v,children:v})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:h?.defaultModel??i.defaultModel??void 0,children:h?.defaultModel??i.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:j?.lastError??void 0,children:[R," cached · ",_a(j?.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||j?.lastError||i.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:i.credential.lastError??j?.lastError??i.lastError??void 0,children:i.credential.lastError??j?.lastError??i.lastError})]}):null]}),a==="codex"?e.jsx(Wa,{providerBusy:t,status:i,onValidate:u}):P&&h&&j?e.jsx(Va,{credentialTab:x,credentialTabsId:y,hasSubscriptionTab:C,providerId:a,providerBusy:t,settings:l,status:i,onDeleteCredential:c,onRefreshModels:m,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:f,onValidate:u}):i.routing.localByok&&!ss(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Ys,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function Wa({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(oe,{size:14,className:"settings-spin"}):e.jsx(Zs,{size:14}),e.jsx("span",{children:t?"Testing":"Test Codex login"})]})})]})}function Va({credentialTab:s,credentialTabsId:n,hasSubscriptionTab:a,providerId:t,providerBusy:l,settings:i,status:d,onDeleteCredential:c,onRefreshModels:m,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:f,onValidate:u}){const h=i.providers[t],j=r.useMemo(()=>Be(t,i),[t,i]),y=`provider-models-${t}`,w=r.useRef(t),[R,P]=r.useState(h.baseUrl??""),[k,C]=r.useState(h.defaultModel??""),[x,A]=r.useState(h.modelOverrides.join(`
6
+ `)),[L,E]=r.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[v,S]=r.useState("local_secret"),[N,b]=r.useState(""),[z,F]=r.useState(""),G=l===`${t}:config`,J=l===`${t}:credential`,W=l===`${t}:validate`,D=l===`${t}:models`,Y=l==="openai:credential",H=t==="openai",ee=t==="xai",X=t==="zai",q=(U=>`${n}-${U}-panel`)(s),g=s==="subscription"&&a,T=s==="subscription"&&X?"coding-plan":"api",_=T==="coding-plan"?"Coding Plan key":"API key",ne=d.credential.connected?T==="coding-plan"?"Replace saved plan key":"Replace saved key":_,de=T==="coding-plan"?"Save plan key":"Save key",se=r.useMemo(()=>Fa(j,[k,...zs(x)]),[k,j,x]),te=Math.max(0,j.length-se.length);r.useEffect(()=>{if(w.current!==t){w.current=t,E({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),P(h.baseUrl??""),C(h.defaultModel??""),A(h.modelOverrides.join(`
7
7
  `));return}L.baseUrl||P(h.baseUrl??""),L.defaultModel||C(h.defaultModel??""),L.modelOverrides||A(h.modelOverrides.join(`
8
- `))},[h.baseUrl,h.defaultModel,h.modelOverrides,L.baseUrl,L.defaultModel,L.modelOverrides,t]);const ue=v==="env"?!!T.trim():!!N.trim();async function he(z){z.preventDefault(),await p(t,{enabled:!0,baseUrl:R.trim()||null,defaultModel:k.trim()||null,modelOverrides:zs(x)}),E({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function re(z){if(z.preventDefault(),!!ue){if(v==="env"){await o(t,{source:"env",envVar:T.trim()});return}await o(t,{source:"local_secret",value:N}),b("")}}function M({panel:z=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:z?G:void 0,role:z?"tabpanel":void 0,"aria-labelledby":z?`${n}-${s}`:void 0,onSubmit:B=>{re(B)},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(Ie,{value:v,disabled:J,label:"Credential source",options:$a,onChange:B=>S(B)})]}),v==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:T,disabled:J,placeholder:"PROVIDER_API_KEY",onChange:B=>_(B.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:q}),e.jsx("input",{type:"password",value:N,disabled:J,placeholder:ie,autoComplete:"off",onChange:B=>b(B.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:J||!ue,children:[J?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:J?"Saving":de})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${d.displayName} credential`,disabled:J||!d.credential.connected,onClick:()=>{c(t)},children:e.jsx(ke,{size:15})})]})]})}function I(){return H?e.jsxs("div",{className:"provider-subscription-panel",id:G,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:Y,onClick:()=>{f("browser")},children:[Y?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:Y?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:Y,onClick:()=>{f("device")},children:[Y?e.jsx(oe,{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 ${d.displayName} credential`,disabled:Y||!d.credential.connected,onClick:()=>{c(t)},children:e.jsx(ke,{size:15})})]})]}):ee?e.jsx("div",{className:"provider-subscription-panel",id:G,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."})]})}):X?e.jsxs("div",{className:"provider-subscription-panel",id:G,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."})]}),M({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[g?null:e.jsxs("form",{className:"provider-card-form",onSubmit:z=>{he(z)},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:R,disabled:F,placeholder:"https://api.example.com/v1",onChange:z=>{E(B=>({...B,baseUrl:!0})),P(z.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:y,value:k,disabled:F,placeholder:"Model id",onChange:z=>{E(B=>({...B,defaultModel:!0})),C(z.currentTarget.value)}}),e.jsx("datalist",{id:y,children:se.map(z=>e.jsx("option",{value:z.value,children:z.label},z.value))}),ne>0?e.jsxs("small",{children:[ne," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:F,children:[F?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(os,{size:14}),e.jsx("span",{children:F?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:D,onClick:()=>{m(t)},children:[D?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(ae,{size:14}),e.jsx("span",{children:D?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:W||!k.trim(),onClick:()=>{u(t,{baseUrl:R.trim()||void 0,modelId:k.trim()||void 0})},children:[W?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(Zs,{size:14}),e.jsx("span",{children:W?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:g?I():M()})]})}function Ka({status:s,busy:n,flashTailscaleUp:a,refresh:t,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:d,copyTailscaleUpCommand:c,copyServeCommand:m,copyServeSetupUrl:p,copyOperatorCommand:o,createRemoteLink:f}){const u=s?.tailscale.installed??!1,h=s?.serve.enabled??!1,j=s?.serve.reachable??!1,y=!!(s?.webUiAvailable&&u),w=h?!!s?.remoteWebUrl:y,P=(s?.tailscale.peers??[]).filter(x=>!x.isSelf),k=!!s?.tailscale.error?.includes("set --operator"),C=!!(h&&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 ${j?"online":h?"configured":""}`,children:u?e.jsx(rn,{size:18}):e.jsx(ht,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:j?"Tailscale Serve is reachable":h?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Qa(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(ae,{className:n==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:n!==null||!u||!h&&!y,onClick:()=>{h?i():l()},children:[e.jsx(Wn,{size:15}),e.jsx("span",{children:h?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:C?"Browser UI":"Tailscale + Serve"})]})}),C&&e.jsx(me,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:n==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||n!==null,onAction:d}),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:c}),e.jsx(me,{label:"Serve command",value:s?.serveCommand??null,actionLabel:n==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||n!==null,onAction:m}),s?.serve.setupUrl&&e.jsx(me,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:n==="copy-serve-setup"?"Copying":"Copy",disabled:n!==null,onAction:p}),k&&e.jsx(me,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:n==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||n!==null,onAction:o}),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:[P.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:n!==null||!w,onClick:()=>{f()},children:e.jsx("span",{children:h?"Copy link":"Create link"})})]}),s?P.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."})]}):P.map(x=>e.jsx(Ya,{peer:x},x.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(Ja,{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 Ja({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 Ya({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 Qa(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 Za=[{items:[{section:"account",label:"Account",Icon:vs},{section:"notifications",label:"Notifications",Icon:an},{section:"providers",label:"Providers",Icon:Xs},{section:"usage",label:"Activity",Icon:Kn}]},{label:"Harness",items:[{section:"harness",label:"Overview",Icon:rt},{section:"harness-refiner",label:"Refiner",Icon:js},{section:"harness-continuous-review",label:"Continuous Review",Icon:ae},{section:"harness-contents",label:"Contents",Icon:Jn},{section:"harness-releases",label:"Releases",Icon:ot}]},{label:"Customization",items:[{section:"configuration",label:"Configuration",Icon:At},{section:"personalization",label:"Personalization",Icon:js},{section:"editor",label:"Editor",Icon:ct},{section:"skills",label:"Skills",Icon:ze}]},{label:"Agents",items:[{section:"profile",label:"Profiles",Icon:vs},{section:"subagents",label:"Agents",Icon:He}]},{label:"System",items:[{section:"dataset-storage",label:"Dataset Storage",Icon:wt},{section:"remote",label:"Remote Access",Icon:rn},{section:"diagnostics",label:"Diagnostics",Icon:mt}]}];function Xa({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(Vn,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Za.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:d,Icon:c})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>a(i),children:[e.jsx(c,{size:16}),e.jsx("span",{children:d})]},i))]},t.label??`settings-${l}`))})]})}function el({catalog:s,connection:n,onCatalog:a,onError:t,onOpenExtension:l,onToast:i}){const[d,c]=r.useState(""),[m,p]=r.useState(""),[o,f]=r.useState(null),[u,h]=r.useState(null),[j,y]=r.useState(null),w=r.useCallback(v=>{const S=v instanceof Error?v.message:String(v);y(S),t(S),i?.(S,"error")},[t,i]),R=r.useCallback(()=>{y(null),t(null)},[t]),P=r.useCallback(async v=>{if(v?.preventDefault(),!(!n||!d.trim()||u)){R(),h("preview");try{const S=await $.extensionPreview(n,{source:d.trim(),...m.trim()?{ref:m.trim()}:{}});f(S)}catch(S){f(null),w(S)}finally{h(null)}}},[u,R,n,w,m,d]),k=r.useCallback(async()=>{if(!(!n||!o||u)){R(),h("install");try{const v=await $.extensionAdd(n,{source:o.repositoryUrl,ref:o.requestedRef});a(v.catalog),c(""),p(""),f(null),i?.(`Installed ${v.extension.owner}/${v.extension.repo}.`,"success")}catch(v){w(v)}finally{h(null)}}},[u,R,n,a,i,o,w]),C=r.useCallback(async v=>{if(!(!n||u)){R(),h(`update:${v.id}`);try{const S=await $.extensionUpdate(n,v);a(S.catalog);const N=S.extension.resolvedCommit===v.resolvedCommit&&S.extension.packageHash===v.packageHash;i?.(N?`${v.owner}/${v.repo} is already current.`:`Updated ${v.owner}/${v.repo}.`,"success")}catch(S){w(S)}finally{h(null)}}},[u,R,n,a,i,w]),x=r.useCallback(async()=>{if(!(!n||u||s.extensions.length===0)){R(),h("update-all");try{const v=await $.extensionUpdateAll(n);a(v.catalog);const S=`Updated ${v.updated.length}; ${v.unchanged.length} already current${v.failed.length?`; ${v.failed.length} failed`:""}.`;i?.(S,v.failed.length?"error":"success"),v.failed.length&&y(v.failed.map(N=>N.error).join(" "))}catch(v){w(v)}finally{h(null)}}},[u,s.extensions.length,R,n,a,i,w]),A=r.useCallback(async v=>{if(!(!n||u)&&window.confirm(`Remove ${v.owner}/${v.repo} and its ${v.skills.length} installed skill${v.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){R(),h(`remove:${v.id}`);try{const S=await $.extensionRemove(n,v);a(S.catalog),i?.(`Removed ${v.owner}/${v.repo}.`,"success")}catch(S){w(S)}finally{h(null)}}},[u,R,n,a,i,w]),L=r.useCallback(v=>{c(v),f(null),y(null)},[]),E=r.useCallback(v=>{p(v),f(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||u!==null||s.extensions.length===0,type:"button",onClick:()=>{x()},children:[u==="update-all"?e.jsx(oe,{className:"settings-spin",size:13}):e.jsx(ae,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:v=>{P(v)},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||u!==null,placeholder:"owner/repo",value:d,onChange:v=>L(v.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!n||u!==null,placeholder:"Default branch",value:m,onChange:v=>E(v.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!d.trim()||u!==null,type:"submit",children:[u==="preview"?e.jsx(oe,{className:"settings-spin",size:14}):e.jsx(es,{size:14}),u==="preview"?"Checking":"Preview"]})]}),j||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:j??s.error}):null,o?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[o.owner,"/",o.repo]}),e.jsxs("span",{children:[o.skills.length," skill",o.skills.length===1?"":"s"," at ",o.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:o.skills.map(v=>e.jsx("span",{children:v.name},v.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:u!==null,type:"button",onClick:()=>{k()},children:[u==="install"?e.jsx(oe,{className:"settings-spin",size:14}):e.jsx(ge,{size:14}),u==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(v=>{const S=u===`update:${v.id}`,N=u===`remove:${v.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${v.owner}/${v.repo} extension source`,className:"github-extension-open",disabled:!n||u!==null,type:"button",onClick:()=>l(v),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(es,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsxs("strong",{children:[v.owner,"/",v.repo]}),e.jsx("span",{children:v.skills.map(b=>b.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[v.skills.length," skill",v.skills.length===1?"":"s"]}),e.jsxs("span",{children:[v.requestedRef," · ",v.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${v.validationStatus==="valid"?"":"invalid"}`,children:v.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(en,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${v.owner}/${v.repo}`,className:"settings-icon-button ghost",disabled:u!==null,title:"Update extension",type:"button",onClick:()=>{C(v)},children:S?e.jsx(oe,{className:"settings-spin",size:14}):e.jsx(ae,{size:14})}),e.jsx("button",{"aria-label":`Remove ${v.owner}/${v.repo}`,className:"settings-icon-button ghost danger",disabled:u!==null,title:"Remove extension",type:"button",onClick:()=>{A(v)},children:N?e.jsx(oe,{className:"settings-spin",size:14}):e.jsx(ke,{size:14})})]})]},v.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function sl({onOpenSkill:s,onOpenExtension:n,personalSkills:a,extensionCatalog:t,connection:l,onExtensionCatalog:i,onError:d,onToast:c}){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(el,{catalog:t,connection:l,onCatalog:i,onError:d,onOpenExtension:n,onToast:c}),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(m=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(ze,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:m.name}),e.jsx("span",{children:m.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:m.resourceFiles.length?`${m.resourceFiles.length} packaged resource${m.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:m.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${m.validationStatus==="valid"?"":"invalid"}`,children:m.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},m.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"})]}),Yn.map(m=>{const p=Qn(m.provider)?.label??m.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(m),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(ze,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:m.name}),e.jsx("span",{children:m.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:p}),e.jsx("span",{children:m.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(en,{size:16,"aria-hidden":"true"})]},m.name)})]})]})}const ds="default";function nl({connection:s,embedded:n=!1,onError:a,onPreferences:t,preferences:l,providers:i}){const d=l.training,[c,m]=r.useState(Qe(d.defaultModelRef)),[p,o]=r.useState(d.creationMode),[f,u]=r.useState(d.autoApproveEvidence),[h,j]=r.useState(!1),y=r.useMemo(()=>Qs(i,{includeUnavailable:!0}),[i]),w=r.useMemo(()=>y.map(x=>({provider:x,models:Be(x.value,i)})).filter(x=>x.models.length>0),[y,i]),R=tl(c),P=Zn(l.defaultChatProvider,l.defaultChatModel,i)?` · ${al(l.codexReasoningEffort)} reasoning`:"",k=ll(R,d.defaultModelRef??null)&&p===d.creationMode&&f===d.autoApproveEvidence;r.useEffect(()=>{m(Qe(d.defaultModelRef)),o(d.creationMode),u(d.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,d.autoApproveEvidence,d.creationMode,d.defaultModelRef]);async function C(x){if(x.preventDefault(),!!s){j(!0),a(null);try{t(await $.savePreferences(s,{training:{defaultModelRef:R,creationMode:p,autoApproveEvidence:f}}))}catch(A){a(A instanceof Error?A.message:String(A))}finally{j(!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:x=>{C(x)},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:c,disabled:h,onChange:x=>m(x.target.value),children:[e.jsxs("option",{value:ds,children:["Use chat default — ",Te(l.defaultChatProvider,i)," · ",ns(l.defaultChatModel,i,l.defaultChatProvider),P]}),w.map(x=>e.jsx("optgroup",{label:x.provider.label,children:x.models.map(A=>e.jsx("option",{value:Qe({providerId:x.provider.value,modelId:A.value}),children:A.label},A.value))},x.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:p,disabled:h,onChange:x=>o(x.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:f,disabled:h,onChange:x=>u(x.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:h||k,children:e.jsx("span",{children:h?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:R?`${Te(R.providerId,i)} / ${ns(R.modelId,i,R.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 Qe(s){return s?JSON.stringify([s.providerId,s.modelId]):ds}function tl(s){if(s===ds)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 al(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function ll(s,n){return s?.providerId===n?.providerId&&s?.modelId===n?.modelId}function il({disabled:s,onChange:n,storageRoots:a,value:t}){const l=r.useId(),[i,d]=r.useState(!1),c=Fs(t),m=f=>f.datasetStorePath,p="Dataset",o=a.find(f=>Fs(m(f))===c)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:l,children:[p," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${p} storage drive`,className:"model-storage-select",disabled:s,id:l,title:t??"No Dataset storage configured",value:t??"",onChange:f=>n(f.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),t&&!o?e.jsx("option",{value:t,children:"Manual location"}):null,a.map(f=>e.jsxs("option",{disabled:!f.mounted||!f.writable,title:m(f),value:m(f),children:[f.label," · ",dl(f.kind)," · ",ul(f)]},f.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:()=>d(!0),children:e.jsx(ge,{size:15})})]}),i?rl(e.jsx(ol,{initialPath:t??"",purpose:"dataset",onClose:()=>d(!1),onUse:f=>{n(f),d(!1)}})):null]})}function rl(s){return typeof document>"u"?s:Xn.createPortal(s,document.body)}function ol({initialPath:s,onClose:n,onUse:a,purpose:t="model"}){const l=r.useId(),[i,d]=r.useState(s),c=cl(i);r.useEffect(()=>{const p=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]);function m(p){p.preventDefault(),p.stopPropagation(),!c&&a(i.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:p=>{p.target===p.currentTarget&&n()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:m,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(ft,{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:p=>d(p.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()&&c?e.jsx("div",{className:"profile-dialog-warning",children:c}):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:!!c,type:"submit",children:"Use location"})]})]})})}function cl(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 dl(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function ul(s){return s.mounted?s.writable?`${hl(s.freeBytes)} free`:"Read only":"Not mounted"}function Fs(s){const n=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(n)?n.toLowerCase():n}function hl(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 ml({state:s,catalog:n,busy:a,catalogLoading:t,onRefresh:l,onSave:i}){const[d,c]=r.useState(s?.settings.datasetStorePath??null);r.useEffect(()=>{c(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const m=r.useMemo(()=>s?.storageRoots.find(u=>Gs(u.datasetStorePath)===Gs(d))??null,[d,s?.storageRoots]),p=d===(s?.settings.datasetStorePath??null),o=n?.datasets??[];async function f(u){u.preventDefault(),await i(d)}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(ae,{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:m?.label??(d?"Manual location":"Not configured")}),e.jsx("small",{children:d??"Choose a writable local or mounted location before importing a Dataset."}),m?e.jsxs("small",{children:[xl(m.kind)," · ",m.freeBytes==null?"Free space unknown":`${pn(m.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:u=>{f(u)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(il,{disabled:a!==null,onChange:c,storageRoots:s?.storageRoots??[],value:d}),e.jsx("button",{className:"settings-primary",disabled:a!==null||p,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:o.length})]}),o.length?o.map(u=>e.jsx(pl,{dataset:u},u.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t?"Loading registered Datasets":"No registered Datasets"})})]})]})}function pl({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:[fn(s.rowCount)," rows"," · ",fl(s)," · ",n," · ",s.sizeBytes==null?"Size unavailable":pn(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?gl(s.status):"Unavailable"})]})}function fl(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])=>`${fn(Number(t))} ${a}`).join(" · ")||"No split rows"}function pn(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 fn(s){return new Intl.NumberFormat().format(s)}function Gs(s){return s?.replace(/[\\/]+$/,"")??""}function gl(s){return s.replaceAll("_"," ").replace(/^./,n=>n.toUpperCase())}function xl(s){return s.replace(/^./,n=>n.toUpperCase())}function Ee(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function Se(s){return s?s.slice(0,10):"none"}function ye(s){const n=s.replaceAll("_"," ");return`${n.charAt(0).toUpperCase()}${n.slice(1)}`}function jl(s){return s==="unresolved"?"Watching":s==="confirmed"?"Ready for Refiner":ye(s)}function vl({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?Se(t.contentHash):"Not created"})]},a))})}function bl({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:jl(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:Ee(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:Se(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:ye(n.kind)}),e.jsx("code",{children:Se(n.evidence.contentHash)}),e.jsx("time",{children:Ee(n.occurredAt)})]},`${n.evidence.id}:${n.evidence.contentHash}`))})]}):null]})]})}function yl({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:ye(a.classification)}),e.jsx("strong",{children:a.claim?.statement??a.reason}),e.jsxs("small",{children:[a.selectedEvidence.length," selected"]}),e.jsx("time",{children:Ee(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:ye(a.nextAuthority)})]})]}),e.jsx(vl,{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 Nl({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:ye(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsxs("small",{children:[ye(s.signal.strength)," signal"]}),e.jsx("time",{children:Ee(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:Se(s.review.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Taskset"}),e.jsx("dd",{children:e.jsx("code",{children:Se(s.tasksetRelease?.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Baseline"}),e.jsx("dd",{children:e.jsx("code",{children:Se(s.baselineEvaluation?.contentHash)})})]})]})]})]})}function wl({acceptingReviewId:s,candidates:n,onAcceptTasksetReview:a,qualifications:t,reviews:l,schedule:i}){const d=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 ${d?"harness-status-advanced":""}`,children:d?"On":"Off"})}),e.jsx("td",{children:i.activityEnabled?`${i.activityBatchSize} new outcomes`:"Manual only"}),e.jsx("td",{children:Ee(i.lastRunAt)}),e.jsx("td",{children:i.lastResult?ye(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(c=>e.jsx(bl,{candidate:c},`${c.id}:${c.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(c=>e.jsx(yl,{accepting:s===c.id,onAcceptTasksetReview:a,review:c},`${c.id}:${c.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(c=>e.jsx(Nl,{receipt:c},`${c.id}:${c.contentHash}`))})]}):null]})}const Sl="Update the Refiner Review Profile. Inspect the current profile first, ask what should change if it is not already clear, and show the exact release transition.";function qs(s){const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function we(s){return s?s.slice(0,10):"none"}function kl({busyReleaseHash:s,history:n,onRequestRelease:a,onStartAuthoring:t}){const l=r.useMemo(()=>{const i=new Map;for(const d of n.transitions)i.has(d.nextRelease.contentHash)||i.set(d.nextRelease.contentHash,d);return i},[n.transitions]);return e.jsxs(e.Fragment,{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:"Review Profile"}),e.jsx("p",{children:"Separately versioned policy composed with the immutable Refiner Core."})]}),t?e.jsx("button",{className:"settings-primary compact",onClick:()=>t(Sl),type:"button",children:"Edit with Work"}):null]}),e.jsxs("div",{className:"harness-summary-grid",children:[e.jsxs("article",{children:[e.jsx("span",{children:"Active release"}),e.jsx("strong",{children:we(n.binding.release.contentHash)}),e.jsxs("small",{children:["Binding revision ",n.binding.revision]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Profile"}),e.jsx("strong",{children:n.currentRelease.profile.name}),e.jsxs("small",{children:[n.currentRelease.profile.id,"@",n.currentRelease.profile.version]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Core"}),e.jsx("strong",{children:n.currentRelease.coreVersion}),e.jsx("small",{children:we(n.currentRelease.coreHash)})]})]}),e.jsx("p",{children:n.currentRelease.profile.objective}),n.currentRelease.profile.instructions.length?e.jsx("div",{className:"harness-edit-list",children:n.currentRelease.profile.instructions.map(i=>e.jsx("section",{className:"harness-edit",children:e.jsxs("div",{children:[e.jsx("strong",{children:i.id}),e.jsx("span",{children:i.text})]})},i.id))}):e.jsx("div",{className:"harness-empty compact",children:"The default profile adds no instructions beyond the Refiner Core."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Profile releases"}),e.jsx("p",{children:"Immutable definition history. Rollback changes future reviews only."})]}),e.jsx("span",{children:n.releases.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:"Profile"}),e.jsx("th",{children:"Release"}),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(i=>{const d=i.contentHash===n.binding.release.contentHash,c=!d&&l.get(i.contentHash)?.bindingChanged===!1,m=c?"activate":"rollback";return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("strong",{children:i.profile.name}),e.jsxs("small",{children:[i.profile.id,"@",i.profile.version," · ",i.profile.instructions.length," instructions"]})]}),e.jsx("td",{children:e.jsx("code",{children:we(i.contentHash)})}),e.jsx("td",{children:qs(i.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:d?"active":c?"draft":"immutable"})}),e.jsx("td",{children:d?null:e.jsx("button",{"aria-label":`${c?"Activate":"Roll back"} Refiner release`,className:"harness-table-icon-action",disabled:s!==null,onClick:()=>a(i,m),title:`${c?"Activate":"Roll back"} Refiner release`,type:"button",children:c?e.jsx(rs,{size:14}):e.jsx(_e,{size:14})})})]},i.contentHash)})})]})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Definition changes"}),e.jsx("p",{children:"Receipts record which release changed, why, and which authoring Skill produced it."})]}),e.jsx("span",{children:n.transitions.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:"Operation"}),e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Release transition"}),e.jsx("th",{children:"Validation"}),e.jsx("th",{children:"Created"})]})}),e.jsx("tbody",{children:n.transitions.map(i=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("span",{className:"harness-status",children:[i.operation,i.bindingChanged?" · active":" · draft"]})}),e.jsxs("td",{children:[e.jsx("strong",{children:i.reason}),e.jsx("small",{children:i.authoringSkillHash?`Skill ${we(i.authoringSkillHash)}`:i.actor})]}),e.jsx("td",{children:e.jsxs("code",{children:[we(i.previousRelease?.contentHash)," → ",we(i.nextRelease.contentHash)]})}),e.jsx("td",{children:i.validation.valid?"Passed":i.validation.messages.join("; ")}),e.jsx("td",{children:qs(i.createdAt)})]},i.contentHash))})]})})]})]})}const Cl={enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},Rl={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 Re(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function Pe(s){return s?s.slice(0,10):"none"}function Ws(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 ${Pe(a.contentHash)}`}}function Pl({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:Re(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(rs,{size:13})," Approve and release"]})]})]})}function Al({change:s,onClose:n}){const a=s.proposal;return e.jsxs(gt,{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 Dl({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(Pl,{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:Re(l.at)})]},l.id))}):e.jsx("div",{className:"harness-empty compact",children:"No Harness learning activity yet."})]})]})}function Il({history:s,refiner:n,busyReleaseHash:a,onRequestRefinerRelease:t,onStartRefinerAuthoring:l,onOpenChangeDiff:i,onOpenSourceSession:d}){const[c,m]=r.useState(null);return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx(kl,{busyReleaseHash:a,history:n,onRequestRelease:t,onStartAuthoring:l}),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(p=>{const o=p.trigger?.runRef??null,f=p.proposal;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:f?.expectedOutcome??p.receipt.reason})}),e.jsx("td",{children:e.jsx("code",{children:f?.edits[0]?.target??f?.route??"workspace"})}),e.jsx("td",{children:e.jsx("code",{children:Pe(p.receipt.nextRelease?.contentHash)})}),e.jsx("td",{children:Re(p.receipt.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`harness-status harness-status-${p.receipt.decision}`,children:p.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:()=>m(p),title:"View evidence and exact edits",type:"button",children:e.jsx(yt,{size:14})}),p.receipt.nextRelease?e.jsx("button",{"aria-label":"View release diff",className:"harness-table-icon-action",onClick:()=>i(p),title:"View release diff",type:"button",children:e.jsx(ln,{size:14})}):null,o&&d?e.jsx("button",{"aria-label":"Open source conversation",className:"harness-table-icon-action",onClick:()=>d(o),title:"Open source conversation",type:"button",children:e.jsx(Xs,{size:14})}):null]})})]},`${p.receipt.id}:${p.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(p=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("p",{children:p.decision.reason})}),e.jsx("td",{children:e.jsx("p",{children:p.trigger?.reason??"Completed work"})}),e.jsx("td",{children:Re(p.decision.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:p.decision.route})})]},`${p.decision.id}:${p.decision.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No recommendations have been routed."})]}),c?e.jsx(Al,{change:c,onClose:()=>m(null)}):null]})}function $l(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 El(s){return s<1024?`${s} B`:`${(s/1024).toFixed(s<10240?1:0)} KB`}function Ml({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:$l(t.path)})}),e.jsx("td",{children:e.jsx("code",{children:t.path})}),e.jsx("td",{children:El(t.sizeBytes)}),e.jsx("td",{children:e.jsx("code",{children:Pe(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:Re(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:Pe(l.contentHash)})]})}),e.jsxs("td",{children:[l.files.length," files"]}),e.jsx("td",{children:Re(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(ln,{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(_e,{size:14})})]})})]},`${l.id}:${l.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness releases exist yet."})]})}function Ll({connection:s,enabled:n,onAcceptEvaluationReview:a,onError:t,onDefaultReleaseDiff:l,onOpenReleaseDiff:i,onOpenSourceSession:d,onStartRefinerAuthoring:c,onToast:m,page:p}){const[o,f]=r.useState(null),[u,h]=r.useState(null),[j,y]=r.useState(null),[w,R]=r.useState(!1),[P,k]=r.useState(null),[C,x]=r.useState(null),[A,L]=r.useState(!1),[E,v]=r.useState(!1),[S,N]=r.useState(null),{confirmAction:b,confirmDialog:T,resolveConfirmDialog:_}=Ks(),F=!!(o?.evaluationReviewSchedule.activityEnabled||o?.evaluationReviewSchedule.enabled),[J,W]=r.useState(!1),[D,Y]=r.useState(!1);r.useEffect(()=>{o&&W(o.backgroundReview.enabled)},[o?.backgroundReview.enabled]),r.useEffect(()=>{Y(F)},[F]);const H=r.useCallback(async()=>{if(s){R(!0);try{const[M,I]=await Promise.all([$.harnessHistory(s),$.refinerHistory(s)]);f(M),h(I);const z=M.releases.findIndex(Z=>Z.current),B=z>=0?M.releases[z]:null;M.workspace&&B&&l(Ws(M.workspace.id,M.releases[z+1]??null,B)),t(null)}catch(M){t(M instanceof Error?M.message:String(M))}finally{R(!1)}}},[s,l,t]);r.useEffect(()=>{n&&H()},[n,p,H]);const ee=r.useCallback(async M=>{if(!(!s||!o?.workspace)){v(!0);try{const I=await $.reviewHarnessEvaluation(s,{workspaceId:o.workspace.id,maxEstimatedCostUsd:M});f(I.history),t(null),m?.(`Continuous Review completed: ${I.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(I){t(I instanceof Error?I.message:String(I))}finally{v(!1)}}},[s,o,t,m]),X=r.useCallback(async(M,I,z)=>{if(!(!s||!o?.workspace)){L(!0);try{let B=o;M==="refiner"&&I!==o.backgroundReview.enabled&&(B=(await $.updateHarnessBackgroundReview(s,{workspaceId:o.workspace.id,enabled:I})).history);const Z=o.evaluationReviewSchedule.activityEnabled||o.evaluationReviewSchedule.enabled;if(M==="continuous-review"&&(z!==Z||o.evaluationReviewSchedule.enabled)){const Q=o.evaluationReviewSchedule;B=(await $.updateHarnessEvaluationReviewSchedule(s,{workspaceId:o.workspace.id,enabled:!1,activityEnabled:z,activityBatchSize:Q.activityBatchSize,cadence:"manual",maxEstimatedCostUsd:Q.maxEstimatedCostUsd})).history}f(B),t(null),m?.(`${M==="refiner"?"Refiner":"Continuous Review"} settings applied.`,"success")}catch(B){t(B instanceof Error?B.message:String(B))}finally{L(!1)}}},[s,o,t,m]),le=r.useCallback(async M=>{if(o?.workspace){N(M.id);try{await a(o.workspace.id,{id:M.id,contentHash:M.contentHash})&&(t(null),m?.("Taskset review opened in Models.","success"))}catch(I){t(I instanceof Error?I.message:String(I))}finally{N(null)}}},[o?.workspace,a,t,m]),G=r.useCallback((M,I)=>{o?.workspace&&i(Ws(o.workspace.id,M,I))},[o?.workspace,i]),g=r.useCallback(M=>{!o?.workspace||!M.receipt.nextRelease||i({workspaceId:o.workspace.id,baseRelease:M.receipt.previousRelease,targetRelease:M.receipt.nextRelease,title:M.proposal?.expectedOutcome??M.receipt.reason})},[o?.workspace,i]),U=r.useCallback(async M=>{if(!(!s||!o?.workspace)){k(M.contentHash);try{const I=await $.rollbackHarness(s,{workspaceId:o.workspace.id,targetRelease:{id:M.id,contentHash:M.contentHash}});f(I.history),t(null),m?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(I){t(I instanceof Error?I.message:String(I))}finally{k(null)}}},[s,o?.workspace,t,m]),q=r.useCallback(async M=>{await b({title:"Roll back Harness release?",body:`New work will use ${Pe(M.contentHash)}. Active runs remain pinned to their current release.`,confirmLabel:"Roll back"})&&await U(M)},[b,U]),ie=r.useCallback(async(M,I)=>{if(!(!s||!await b({title:I==="activate"?"Activate Refiner release?":"Roll back Refiner release?",body:`Future reviews will use ${M.profile.name} at ${Pe(M.contentHash)}. Existing work remains pinned.`,confirmLabel:I==="activate"?"Activate":"Roll back"}))){y(M.contentHash);try{const B={release:{id:M.id,contentHash:M.contentHash},reason:`${I==="activate"?"Activate":"Rollback"} from Settings to ${M.profile.id}@${M.profile.version}.`,actor:"settings-user"};h(await(I==="activate"?$.activateRefinerRelease(s,B):$.rollbackRefinerRelease(s,B))),t(null),m?.(`Refiner ${I==="activate"?"activated":"rolled back"}. Existing work remains pinned.`,"success")}catch(B){t(B instanceof Error?B.message:String(B))}finally{y(null)}}},[b,s,t,m]),de=r.useCallback(async(M,I)=>{if(!(!s||!o?.workspace)){x(M.proposal.id);try{const z=await $.reviewHarnessProposal(s,{workspaceId:o.workspace.id,proposal:{id:M.proposal.id,contentHash:M.proposal.contentHash},decision:I});f(z.history),t(null),m?.(I==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",I==="approve"?"success":"info")}catch(z){t(z instanceof Error?z.message:String(z))}finally{x(null)}}},[s,o?.workspace,t,m]),se=o?.releases.find(M=>M.current)??o?.releases[0]??null,ne=se?o?.releases.indexOf(se)??-1:-1,ue=Rl[p],he=o?p==="refiner"?J!==o.backgroundReview.enabled:D!==F||o.evaluationReviewSchedule.enabled:!1,re=p==="refiner"||p==="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:ue.title}),e.jsx("p",{children:ue.description})]}),o?.workspace&&re?e.jsxs("div",{className:"harness-page-header-actions",children:[p==="continuous-review"?e.jsx("button",{className:"settings-secondary compact",disabled:E,onClick:()=>{ee(o.evaluationReviewSchedule.maxEstimatedCostUsd)},type:"button",children:E?"Reviewing…":"Review now"}):null,e.jsxs("label",{className:"harness-page-toggle",children:[e.jsx("span",{children:p==="refiner"?J?"On":"Off":D?"On":"Off"}),e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{"aria-label":p==="refiner"?"Enable Refiner":"Enable Continuous Review",checked:p==="refiner"?J:D,disabled:A,onChange:M=>p==="refiner"?W(M.target.checked):Y(M.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("button",{className:"settings-primary compact",disabled:A||!he,onClick:()=>{X(p,J,D)},type:"button",children:A?"Applying…":"Apply changes"})]}):null]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&w&&!o?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,o&&!o.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,o?.workspace&&p==="overview"?e.jsx(Dl,{history:o,onReviewProposal:de,reviewingProposalId:C}):null,o&&u&&p==="refiner"?e.jsx(Il,{busyReleaseHash:j,history:o,refiner:u,onOpenChangeDiff:g,onOpenSourceSession:d,onRequestRefinerRelease:(M,I)=>{ie(M,I)},onStartRefinerAuthoring:c}):null,o?.workspace&&p==="continuous-review"?e.jsx(wl,{acceptingReviewId:S,candidates:o.refinementCandidates,onAcceptTasksetReview:M=>{le(M)},qualifications:o.modelImprovementQualifications,reviews:o.evaluationReviews,schedule:o.evaluationReviewSchedule??Cl}):null,o?.workspace&&p==="contents"?e.jsx(Ml,{history:o,onOpenCurrentRelease:()=>{se&&G(ne>=0?o.releases[ne+1]??null:null,se)}}):null,o?.workspace&&p==="releases"?e.jsx(Ol,{busy:P!==null,history:o,onOpenDiff:G,onRequestRollback:M=>{q(M)}}):null,e.jsx(Js,{onResolve:_,state:T})]})}function Vs(s){return s?s.slice(0,10):"initial"}function Tl({connection:s,expanded:n,onResizeStart:a,onToggleExpanded:t,selection:l}){const[i,d]=r.useState(null),[c,m]=r.useState(null),[p,o]=r.useState(!0),f=r.useCallback(async()=>{m(null),o(!0);try{d(await $.harnessReleaseDiff(s,l))}catch(j){d(null),m(j instanceof Error?j.message:String(j))}finally{o(!1)}},[s,l]);r.useEffect(()=>{f()},[f]);const u=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(j=>j.path),files:i.files,error:null,updatedAt:""}:null,[i,l.title,l.workspaceId]),h=`${l.title} · ${Vs(l.baseRelease?.contentHash)} → ${Vs(l.targetRelease.contentHash)}`;return e.jsx(xt,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:u,editorPreferences:null,expanded:n,filesWithPreview:!0,loading:p,onOpenBrowserUrl:()=>{},onRefresh:f,onResizeStart:a,onToggleExpanded:t,readOnly:!0,workspaceError:c,workspaceInitialized:!0,workspaceName:h})}function zl({connection:s,onError:n,onPayload:a}){const[t,l]=r.useState(!1),[i,d]=r.useState(!1);async function c(f,u){if(s){l(!0),n(null);try{const h=await $.switchOpenPondAccount(s,{handle:f,baseUrl:u??null}),j=await $.savePreferences(s,{defaultTeamId:null});a({...h,preferences:j.preferences})}catch(h){n(h instanceof Error?h.message:String(h))}finally{l(!1)}}}async function m(f,u){if(!s)return!1;l(!0),n(null);try{return a(await $.removeOpenPondAccount(s,{handle:f,baseUrl:u??null})),!0}catch(h){return n(h instanceof Error?h.message:String(h)),!1}finally{l(!1)}}async function p(f){if(!(!s||!f.apiKey.trim())){l(!0),n(null);try{const u=f.handle?.trim(),h=f.environment?.trim(),j=await $.saveOpenPondAccount(s,{apiKey:f.apiKey.trim(),handle:u||void 0,baseUrl:f.baseUrl,apiBaseUrl:f.apiBaseUrl,environment:h||"custom",setActive:!0}),y=await $.savePreferences(s,{defaultTeamId:null});a({...j,preferences:y.preferences})}catch(u){throw n(u instanceof Error?u.message:String(u)),u}finally{l(!1)}}}async function o(){if(s){d(!0),n(null);try{a(await $.refreshOpenPondAccounts(s))}catch(f){n(f instanceof Error?f.message:String(f))}finally{d(!1)}}}return{refreshingAccounts:i,saving:t,refreshAccounts:o,removeAccount:m,saveAccount:p,switchAccount:c}}function Ul({connection:s,onError:n,onPreferences:a,preferences:t,providers:l}){const[i,d]=r.useState(t.defaultBranchPrefix),[c,m]=r.useState(t.defaultNewProjectDirectory),[p,o]=r.useState(t.advancedWorkspaceControls),[f,u]=r.useState(t.steerActiveResponses),[h,j]=r.useState(t.contextCompaction.autoEnabled),[y,w]=r.useState(t.subagents.enabled),[R,P]=r.useState(t.subagents.delegationMode),[k,C]=r.useState(!t.subagents.defaultModelRef),[x,A]=r.useState(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),[L,E]=r.useState(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),[v,S]=r.useState(t.subagents.roles),[N,b]=r.useState(t.subagents.maxConcurrentRuns),[T,_]=r.useState(t.subagents.maxConcurrentRunsPerProvider),[F,J]=r.useState(t.subagents.maxConcurrentRunsPerWorkspaceTarget),[W,D]=r.useState(!1),Y=k?null:{providerId:x,modelId:L.trim()},H=y!==t.subagents.enabled||R!==t.subagents.delegationMode||!Bl(Y,t.subagents.defaultModelRef)||N!==t.subagents.maxConcurrentRuns||T!==t.subagents.maxConcurrentRunsPerProvider||F!==t.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(v)!==JSON.stringify(t.subagents.roles);r.useEffect(()=>{d(t.defaultBranchPrefix),m(t.defaultNewProjectDirectory),o(t.advancedWorkspaceControls),u(t.steerActiveResponses),j(t.contextCompaction.autoEnabled),w(t.subagents.enabled),P(t.subagents.delegationMode),C(!t.subagents.defaultModelRef),A(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),E(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),S(t.subagents.roles),b(t.subagents.maxConcurrentRuns),_(t.subagents.maxConcurrentRunsPerProvider),J(t.subagents.maxConcurrentRunsPerWorkspaceTarget)},[t.defaultChatProvider,t.defaultChatModel,t.defaultBranchPrefix,t.defaultNewProjectDirectory,t.advancedWorkspaceControls,t.steerActiveResponses,t.contextCompaction.autoEnabled,t.subagents]);function ee(I){A(I),E(z=>ts(I,z,l))}function X(){return k?t.defaultChatProvider:x}function le(){return k?t.defaultChatModel:L}function G(I,z){S(B=>B.map(Z=>Z.id===I?z(Z):Z))}function g(I,z){G(I,B=>({...B,enabled:z}))}function U(I,z){G(I,B=>({...B,background:z}))}function q(I,z){G(I,B=>{if(z)return{...B,modelRef:null};const Z=B.modelRef?.providerId??X(),Q=B.modelRef?.modelId??le();return{...B,modelRef:qe(Z,Q,l)??null}})}function ie(I,z){G(I,B=>({...B,modelRef:qe(z,B.modelRef?.modelId??le(),l)??null}))}function de(I,z){G(I,B=>{const Z=B.modelRef?.providerId??X(),Q=z.trim();return{...B,modelRef:Q?{providerId:Z,modelId:Q}:null}})}function se(I,z){G(I,B=>({...B,isolationMode:z}))}function ne(I,z){G(I,B=>({...B,toolPolicy:z}))}function ue(I,z){G(I,B=>({...B,peerMessages:z}))}function he(I,z){G(I,B=>({...B,maxConcurrentRuns:be(z,1,16)}))}async function re(){let I=null;if(window.openpond?.selectFolder){const z=await window.openpond.selectFolder();if(z.canceled)return;I=z.path}else I=window.prompt("Default new project directory",c);I?.trim()&&m(I.trim())}async function M(I){if(I.preventDefault(),!!s){D(!0),n(null);try{a(await $.savePreferences(s,{defaultBranchPrefix:Ze(i),defaultNewProjectDirectory:c.trim(),advancedWorkspaceControls:p,steerActiveResponses:f,contextCompaction:{...t.contextCompaction,autoEnabled:h},subagents:{enabled:y,workspaceDefaultsVersion:t.subagents.workspaceDefaultsVersion,toolDefaultsVersion:t.subagents.toolDefaultsVersion,delegationMode:R,defaultModelRef:k?null:qe(x,L,l)??null,roles:v,maxConcurrentRuns:be(N,1,32),maxConcurrentRunsPerProvider:T===null?null:be(T,1,32),maxConcurrentRunsPerWorkspaceTarget:F===null?null:be(F,1,32)}}))}catch(z){n(z instanceof Error?z.message:String(z))}finally{D(!1)}}}return{advancedWorkspaceControls:p,steerActiveResponses:f,contextCompactionAutoEnabled:h,defaultBranchPrefix:i,defaultNewProjectDirectory:c,subagentsEnabled:y,subagentDelegationMode:R,subagentsUseDefaultModel:k,subagentsProvider:x,subagentsModel:L,subagentRoles:v,subagentsMaxConcurrentRuns:N,subagentsMaxConcurrentRunsPerProvider:T,subagentsMaxConcurrentRunsPerWorkspaceTarget:F,subagentsDirty:H,saving:W,chooseDefaultProjectDirectory:re,saveDefaults:M,changeSubagentsProvider:ee,changeSubagentRoleProvider:ie,setAdvancedWorkspaceControls:o,setSteerActiveResponses:u,setContextCompactionAutoEnabled:j,setDefaultBranchPrefix:d,setDefaultNewProjectDirectory:m,setSubagentsUseDefaultModel:C,setSubagentsModel:E,setSubagentsEnabled:w,setSubagentDelegationMode:I=>P(I),setSubagentsMaxConcurrentRuns:I=>b(be(I,1,32)),setSubagentsMaxConcurrentRunsPerProvider:I=>_(I===null?null:be(I,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:I=>J(I===null?null:be(I,1,32)),setSubagentRoleBackground:U,setSubagentRoleEnabled:g,setSubagentRoleIsolationMode:se,setSubagentRoleMaxConcurrentRuns:he,setSubagentRoleModel:de,setSubagentRolePeerMessages:ue,setSubagentRoleToolPolicy:ne,setSubagentRoleUseDefaultModel:q}}function be(s,n,a){return Number.isFinite(s)?Math.min(a,Math.max(n,Math.trunc(s))):n}function Bl(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const Hl=15e3,_l=100,Fl=100,Gl=2500;function ql({onError:s,section:n}){const[a,t]=r.useState(null),[l,i]=r.useState(null),[d,c]=r.useState(_l),[m,p]=r.useState([]),[o,f]=r.useState(null),[u,h]=r.useState(!0),j=r.useRef(null),[y,w]=r.useState(null),R=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),k=!!window.openpond?.readRecentLogs?`${m.length} of ${d} line${d===1?"":"s"}${u?" tailing":""}`:"Unavailable";r.useEffect(()=>{n==="diagnostics"&&C(d,"refresh",{quiet:!0})},[n]),r.useEffect(()=>{if(n!=="diagnostics"||!u||!window.openpond?.readRecentLogs)return;let S=!1;const N=window.setInterval(()=>{S||(S=!0,C(d,"refresh",{quiet:!0}).finally(()=>{S=!1}))},Gl);return()=>window.clearInterval(N)},[n,u,d]),r.useEffect(()=>{if(n!=="diagnostics"||!u)return;const S=j.current;S&&(S.scrollTop=S.scrollHeight)},[n,u,m]);async function C(S=d,N="refresh",b={}){const T=window.openpond?.readRecentLogs;if(!T){const _="Log view is not available in this runtime.";b.quiet||(w({label:"Logs",value:_,warning:!0}),s(_));return}b.quiet||i(N);try{const _=await Oe(T(S),"Read logs");if(!_.ok)throw new Error(_.error);c(_.lineLimit),f(_.logDir),p(_.lines),b.quiet?w(F=>F?.label==="Logs"?null:F):w(null)}catch(_){const F=_ instanceof Error?_.message:String(_);w({label:"Logs",value:F,warning:!0}),b.quiet||s(F)}finally{b.quiet||i(null)}}function x(){h(!1),C(d+Fl,"older")}function A(){const S=!u;h(S),S&&C(d,"refresh",{quiet:!0})}async function L(){const S=window.openpond?.openLogsFolder;if(!S){const N="Desktop logs are not available in this runtime.";w({label:"Logs",value:N,warning:!0}),s(N);return}t("logs"),s(null);try{const N=await Oe(S(),"Open logs");if(!N.ok)throw new Error(N.error??"Could not open the logs folder.");w(null)}catch(N){const b=N instanceof Error?N.message:String(N);w({label:"Logs",value:b,warning:!0}),s(b)}finally{t(null)}}async function E(){const S=window.openpond?.copyRecentLogs;if(!S){const N="Recent log copy is not available in this runtime.";w({label:"Copy",value:N,warning:!0}),s(N);return}t("copy"),s(null);try{const N=await Oe(S(1e3),"Copy recent logs");if(!N.ok)throw new Error(N.error??"Could not copy recent logs.");w({label:"Copy",value:N.lines?`Copied ${N.lines} recent log lines.`:"Copied recent logs."})}catch(N){const b=N instanceof Error?N.message:String(N);w({label:"Copy",value:b,warning:!0}),s(b)}finally{t(null)}}async function v(){const S=window.openpond?.exportDiagnostics;if(!S){const N="Diagnostics export is not available in this runtime.";w({label:"Export",value:N,warning:!0}),s(N);return}t("export"),s(null);try{const N=await Oe(S(),"Export diagnostics");if(!N.ok)throw new Error(N.error??"Could not export diagnostics.");w({label:"Export",value:N.path?`Saved to ${N.path}`:"Diagnostics exported."})}catch(N){const b=N instanceof Error?N.message:String(N);w({label:"Export",value:b,warning:!0}),s(b)}finally{t(null)}}return{diagnosticsAvailable:R,diagnosticsBusy:a,diagnosticsStatus:y,logDir:o,logLineLimit:d,logLines:m,logViewBusy:l,logViewSummary:k,logViewportRef:j,tailLogs:u,copyRecentLogs:E,exportDiagnosticsBundle:v,loadOlderLogs:x,openLogsFolder:L,refreshLogView:C,toggleTailLogs:A}}async function Oe(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.`))},Hl)})])}finally{a!==void 0&&window.clearTimeout(a)}}function Wl({connection:s,enabled:n,onError:a,onPreferences:t,onToast:l,preferences:i}){const[d,c]=r.useState(i.editor),[m,p]=r.useState(null),[o,f]=r.useState(!1),[u,h]=r.useState(!1),[j,y]=r.useState(!1);r.useEffect(()=>{c(i.editor)},[i.editor]);const w=r.useCallback(async()=>{if(s){h(!0);try{p(await $.workspaceLspSettingsStatus(s))}catch(x){a(x instanceof Error?x.message:String(x))}finally{h(!1)}}},[s,a]);r.useEffect(()=>{!n||!s||w()},[s,n,w]);function R(x,A){c(L=>({...L,languages:{...L.languages,[x]:{...L.languages[x],mode:A}}}))}function P(x,A){c(L=>({...L,languages:{...L.languages,[x]:{...L.languages[x],customCommand:A}}}))}async function k(x){if(x.preventDefault(),!!s){f(!0),a(null);try{const A=await $.savePreferences(s,{editor:d});t(A),p(await $.workspaceLspSettingsStatus(s))}catch(A){a(A instanceof Error?A.message:String(A))}finally{f(!1)}}}async function C(){if(s){y(!0),a(null);try{await $.restartWorkspaceLsp(s),p(await $.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(x){a(x instanceof Error?x.message:String(x))}finally{y(!1)}}}return{editorPreferences:d,lspStatus:m,restarting:j,saving:o,statusLoading:u,refreshLspStatus:w,restartLanguageServers:C,saveEditorSettings:k,setEditorPreferences:c,setLanguageCustomCommand:P,setLanguageMode:R}}function Vl({connection:s,onError:n,onPayload:a,personalization:t}){const l=r.useMemo(()=>t.templates.map(v=>({value:v.id,label:v.name,description:v.id===t.activeTemplateId?"Selected":v.source==="built_in"?v.description:void 0})),[t.activeTemplateId,t.templates]),[i,d]=r.useState(t.activeTemplateId),[c,m]=r.useState(t.soul),[p,o]=r.useState(""),[f,u]=r.useState(!1),[h,j]=r.useState(!1),y=t.templates.find(v=>v.id===i)??t.templates[0],w=y?.source==="custom",R=y?c!==y.content:!0,P=i!==t.activeTemplateId||c!==t.soul||R,k=!!(w&&c.trim()&&y&&P);r.useEffect(()=>{d(t.activeTemplateId),m(t.soul);const v=t.templates.find(S=>S.id===t.activeTemplateId);o(v?`${v.name} Copy`:""),u(!1)},[t.activeTemplateId,t.soul,t.templates]);async function C(v=!1){if(!v&&!w)return;const S=v?p:y?.name;if(!(!s||!c.trim()||!S?.trim())){j(!0),n(null);try{a(await $.savePersonalization(s,{activeTemplateId:i,templateName:S,soul:c,saveAsNew:v})),u(!1)}catch(N){n(N instanceof Error?N.message:String(N))}finally{j(!1)}}}async function x(v){const S=t.templates.find(N=>N.id===v);if(S&&(d(S.id),o(`${S.name} Copy`),m(S.content),u(!1),!!s)){j(!0),n(null);try{a(await $.savePersonalization(s,{activeTemplateId:S.id,templateName:S.name,soul:S.content,saveAsNew:!1}))}catch(N){n(N instanceof Error?N.message:String(N))}finally{j(!1)}}}function A(){y&&(o(`${y.name} Copy`),m(y.content),u(!1))}function L(v){m(v),y&&!w&&v!==y.content&&u(!0)}function E(){y&&(o(`${y.name} Copy`),u(!0))}return{canSaveCurrentTemplate:k,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:f,saving:h,selectedPersonalizationTemplate:y,selectedTemplateIsCustom:w,soulDraft:c,templateNameDraft:p,changePersonalizationTemplate:x,changeSoulDraft:L,openSaveAsNew:E,resetPersonalizationDraft:A,savePersonalization:C,setSaveAsNewOpen:u,setTemplateNameDraft:o}}function Kl({connection:s,onError:n,onPreferences:a,onProviders:t,preferences:l,providers:i}){const[d,c]=r.useState(l.defaultChatProvider),[m,p]=r.useState(l.defaultChatModel),[o,f]=r.useState(!1),[u,h]=r.useState(null),[j,y]=r.useState(null);r.useEffect(()=>{c(l.defaultChatProvider),p(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function w(N){if(N.preventDefault(),!!s){f(!0),n(null);try{a(await $.savePreferences(s,{defaultChatProvider:d,defaultChatModel:ts(d,m,i)}))}catch(b){n(b instanceof Error?b.message:String(b))}finally{f(!1)}}}function R(N){c(N),p(b=>ts(N,b,i))}async function P(N,b,T){if(!s)return null;h(`${N}:${b}`),y(null),n(null);try{return await T()}catch(_){return n(_ instanceof Error?_.message:String(_)),null}finally{h(null)}}async function k(N,b){await P(N,"config",async()=>{const T=await $.saveProviderSettings(s,{providers:{[N]:b}});return t(T),T})}async function C(N,b){await P(N,"credential",async()=>{const T=await $.saveProviderCredential(s,N,b);return t(T),T})}async function x(N){await P(N,"credential",async()=>{const b=await $.deleteProviderCredential(s,N,{});return t(b),b})}async function A(N){return P("openai","credential",async()=>{const b=await $.startOpenAiSubscriptionAuth(s,{method:N});return b.method==="browser"?(window.open(b.url,"_blank","noopener,noreferrer"),y("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(b.url,"_blank","noopener,noreferrer"),y(`OpenAI device login started. Enter code ${b.userCode}.`)),L(b.expiresAt),b})}async function L(N){if(s)for(;Date.now()<N;){await new Promise(b=>setTimeout(b,2500));try{const b=await $.providerSettings(s);t(b);const T=b.statuses.openai?.credential;if(T?.connected&&T.source==="chatgpt_subscription"){y("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function E(N){await P(N,"models",async()=>{const b=await $.refreshProviderModels(s,N,{force:!0});return t(b.providers),b})}async function v(N){await P(N,"models",async()=>{const b=await $.loadProviderModels(s,N,{limit:500});return t(b.providers),b})}async function S(N,b={}){await P(N,"validate",async()=>{const T=await $.validateProviderCredential(s,N,b);return y(T.ok?`${N} validated${T.modelId?` with ${T.modelId}`:""}.`:T.errors.join(`
9
- `)||`${N} validation failed.`),t(T.providers),T})}return{defaultModel:m,defaultProvider:d,providerBusy:u,saving:o,validationMessage:j,changeDefaultProvider:R,deleteProviderCredential:x,loadProviderModels:v,refreshProviderModels:E,saveProviderConfig:k,saveProviderCredential:C,saveProviders:w,setDefaultModel:p,startOpenAiSubscriptionAuth:A,validateProvider:S}}function Jl({connection:s,enabled:n,onError:a,onToast:t}){const[l,i]=r.useState(null),[d,c]=r.useState(null),[m,p]=r.useState(!1),o=r.useRef(null),f=r.useCallback(async(A={})=>{if(s){A.quiet||c("refresh");try{const L=await $.remoteAccess(s);i(L),a(null)}catch(L){a(L instanceof Error?L.message:String(L))}finally{A.quiet||c(null)}}},[s,a]);r.useEffect(()=>{!n||!s||f({quiet:!0})},[s,n,f]),r.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);function u(){o.current!==null&&window.clearTimeout(o.current),p(!1),window.setTimeout(()=>{p(!0),o.current=window.setTimeout(()=>{p(!1),o.current=null},1500)},0)}async function h(){if(a(null),!!s)try{i(await $.remoteAccess(s))}catch{}}async function j(){if(!s)return null;l&&!l.tailscale.running&&u(),c("enable");try{const A=await $.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"):(u(),t?.(A.message||"Tailscale is not running. Run Tailscale up first.","error")),A.status}catch{return await h(),u(),t?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{c(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.")){c("disable");try{const A=await $.disableRemoteAccess(s);i(A.status),a(null)}catch{await h()}finally{c(null)}}}async function w(){l?.remoteWebUrl&&(c("copy-link"),await Ne(l.remoteWebUrl),c(null))}async function R(){l?.serveCommand&&(c("copy-command"),await Ne(l.serveCommand),c(null))}async function P(){l?.serve.setupUrl&&(c("copy-serve-setup"),await Ne(l.serve.setupUrl),c(null))}async function k(){l?.tailscaleUpCommand&&(c("copy-up-command"),await Ne(l.tailscaleUpCommand),c(null))}async function C(){l?.operatorCommand&&(c("copy-operator"),await Ne(l.operatorCommand),c(null))}async function x(){if(!l?.serve.enabled){const A=await j();A?.serve.enabled&&A.remoteWebUrl&&await Ne(A.remoteWebUrl);return}await w()}return{status:l,busy:d,flashTailscaleUp:m,refresh:f,enableRemoteAccess:j,disableRemoteAccess:y,copyRemoteLink:w,copyTailscaleUpCommand:k,copyServeCommand:R,copyServeSetupUrl:P,copyOperatorCommand:C,createRemoteLink:x}}function Yl(s){const[n,a]=r.useState(null),[t,l]=r.useState(null),i=r.useCallback(async()=>{if(s.connection){l("load");try{a(await $.datasetStorageState(s.connection)),s.onError(null)}catch(c){s.onError(c instanceof Error?c.message:String(c))}finally{l(null)}}},[s.connection,s.onError]),d=r.useCallback(async c=>{if(!s.connection||!c)return!1;l("save");try{return a(await $.updateDatasetStorage(s.connection,c)),s.onError(null),!0}catch(m){return s.onError(m instanceof Error?m.message:String(m)),!1}finally{l(null)}},[s.connection,s.onError]);return r.useEffect(()=>{s.enabled&&i()},[s.enabled,i]),{state:n,busy:t,refresh:i,save:d}}function Ql(s){const{connection:n,enabled:a,onError:t,profileId:l}=s,[i,d]=r.useState(null),[c,m]=r.useState(!1),p=r.useCallback(async()=>{if(n){m(!0);try{d(await $.datasetCatalog(n,l)),t(null)}catch(o){t(Zl(o))}finally{m(!1)}}},[n,t,l]);return r.useEffect(()=>{a&&p()},[a,p]),{catalog:i,loading:c,refresh:p}}function Zl(s){return s instanceof Error?s.message:String(s)}const Xl=new Set(["harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases"]);function ei(s){return s==="harness-refiner"?"refiner":s==="harness-continuous-review"?"continuous-review":s==="harness-contents"?"contents":s==="harness-releases"?"releases":"overview"}const si=r.lazy(()=>Cn(()=>import("./UsageSettingsSection-eyvYtzgi.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function Si({payload:s,connection:n,diagnostics:a,onPayload:t,onError:l,onToast:i,onBack:d,onOpenSourceSession:c,onStartRefinerAuthoring:m,onAcceptEvaluationReview:p,onOpenSkill:o,onOpenExtension:f,teamChatCurrentUserId:u,teamChatEnabled:h,teamChatNotificationMode:j,teamChatThreads:y,onTeamChatNotificationModeChange:w,onTeamChatThreadMuteChange:R,diffPanelWidth:P,diffPanelResizing:k,diffPanelExpanded:C,onDiffPanelResizeStart:x,onDiffPanelExpandedChange:A,initialSection:L="account"}){const[E,v]=r.useState(L),[S,N]=r.useState(null),[b,T]=r.useState(!1),_=s?.codex??null,F=r.useMemo(()=>et(s?.preferences),[s?.preferences]),J=s?.personalization??st,W=a??s?.diagnostics??[],D=nt()&&tt(n?.platform),Y=r.useCallback(Q=>{s&&t({...s,providers:Q})},[t,s]),H=r.useCallback(Q=>{s&&t({...s,preferences:Q.preferences})},[t,s]),ee=r.useCallback(Q=>{s&&t({...s,extensionCatalog:Q})},[t,s]),X=zl({connection:n,onError:l,onPayload:t}),le=Kl({connection:n,onError:l,onPayload:t,onPreferences:H,onProviders:Y,preferences:F,providers:s?.providers??null}),G=Ul({connection:n,onError:l,onPayload:t,onPreferences:H,preferences:F,providers:s?.providers??null}),g=Wl({connection:n,enabled:E==="editor",onError:l,onPayload:t,onPreferences:H,onToast:i,preferences:F}),U=Vl({connection:n,onError:l,onPayload:t,personalization:J}),q=ql({onError:l,section:E}),ie=Jl({connection:n,enabled:E==="remote",onError:l,onToast:i}),de=E==="dataset-storage",se=Yl({connection:n,enabled:de,onError:l}),ne=Ql({connection:n,enabled:de,onError:l,profileId:s?.profile.activeProfile??"default"}),ue=se.save,he=r.useCallback(async()=>{await Promise.all([se.refresh(),ne.refresh()])},[se.refresh,ne.refresh]),re=r.useCallback(()=>E!=="subagents"||!G.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[G.subagentsDirty,E]),M=r.useCallback(Q=>{Q!==E&&re()&&(T(!1),A(!1),v(Q),at({kind:"settings",section:Q}))},[re,A,E]),I=r.useCallback(()=>{re()&&(T(!1),A(!1),d())},[re,d,A]);r.useEffect(()=>{v(L)},[L]),r.useEffect(()=>{if(E!=="subagents"||!G.subagentsDirty)return;const Q=Ae=>{Ae.preventDefault(),Ae.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",Q),()=>window.removeEventListener("beforeunload",Q)},[G.subagentsDirty,E]);const z={"--diff-panel-width":`${P}px`},B=Xl.has(E),Z=B&&b&&S;return e.jsxs("div",{className:`settings-shell ${D?"platform-macos":""} ${Z?"harness-diff-open":""} ${C?"harness-diff-expanded":""} ${k?"diff-panel-resizing":""}`,style:z,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[B?e.jsx("button",{type:"button",className:`topbar-diff-button ${Z?"active":""}`,title:`${Z?"Hide":"Show"} sidebar`,"aria-label":`${Z?"Hide":"Show"} sidebar`,"aria-pressed":!!Z,disabled:!S,onClick:()=>T(Q=>!Q),children:e.jsx(lt,{size:16})}):null,e.jsx(it,{platform:n?.platform})]}),e.jsx(Xa,{section:E,onBack:I,onSectionChange:M}),e.jsxs("main",{className:`settings-content ${E==="profile"||B?"settings-content-wide":""}`,children:[E!=="configuration"?e.jsx(bs,{connection:n,bannerOnly:!0,onOpen:()=>M("configuration")}):null,E==="account"?e.jsx(Mt,{payload:s,connection:n,onPayload:t,onPreferences:H,onError:l,onToast:i,...X}):E==="notifications"?e.jsx(ea,{currentUserId:u,enabled:h,mode:j,threads:y,onModeChange:w,onThreadMuteChange:R}):B?e.jsx(Ll,{connection:n,enabled:B,onAcceptEvaluationReview:p,onError:l,onDefaultReleaseDiff:N,onOpenSourceSession:c,onStartRefinerAuthoring:m,onOpenReleaseDiff:Q=>{N(Q),T(!0)},onToast:i,page:ei(E)}):E==="profile"?e.jsx(ya,{payload:s,connection:n,onPayload:t,onError:l,onToast:i,onOpenSession:c}):E==="skills"?e.jsx(sl,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:n,onExtensionCatalog:ee,onError:l,onToast:i,onOpenSkill:o,onOpenExtension:f}):E==="providers"?e.jsx(Ga,{account:s?.account??null,codex:_,providers:s?.providers??null,...le}):E==="dataset-storage"?e.jsx(ml,{state:se.state,catalog:ne.catalog,busy:se.busy,catalogLoading:ne.loading,onRefresh:he,onSave:ue}):E==="configuration"?e.jsxs("div",{className:"settings-stacked-sections configuration-page",children:[e.jsx(bs,{connection:n,onSaved:async()=>{n&&t(await $.bootstrap(n))}}),e.jsx(Bt,{preferences:F,...G}),e.jsx(As,{embedded:!0,preferences:F,...G})]}):E==="context"?e.jsx(As,{preferences:F,...G}):E==="training"?e.jsx(nl,{connection:n,onError:l,onPreferences:H,preferences:F,providers:s?.providers??null}):E==="subagents"?e.jsx(Wt,{preferences:F,providers:s?.providers??null,...G}):E==="editor"?e.jsx(qt,{preferences:F,...g}):E==="remote"?e.jsx(Ka,{...ie}):E==="usage"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(si,{account:s?.account??null,connection:n,enabled:E==="usage",onError:l,onOpenSourceSession:c})}):E==="personalization"?e.jsx(na,{...U}):e.jsx(Ht,{diagnostics:W,...q})]}),B&&n&&Z?e.jsx(Tl,{connection:n,expanded:C,onResizeStart:x,onToggleExpanded:()=>A(!C),selection:Z}):null]})}export{Si as SettingsView};
8
+ `))},[h.baseUrl,h.defaultModel,h.modelOverrides,L.baseUrl,L.defaultModel,L.modelOverrides,t]);const ue=v==="env"?!!z.trim():!!N.trim();async function he(U){U.preventDefault(),await p(t,{enabled:!0,baseUrl:R.trim()||null,defaultModel:k.trim()||null,modelOverrides:zs(x)}),E({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function re(U){if(U.preventDefault(),!!ue){if(v==="env"){await o(t,{source:"env",envVar:z.trim()});return}await o(t,{source:"local_secret",value:N}),b("")}}function M({panel:U=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:U?q:void 0,role:U?"tabpanel":void 0,"aria-labelledby":U?`${n}-${s}`:void 0,onSubmit:B=>{re(B)},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(Ie,{value:v,disabled:J,label:"Credential source",options:$a,onChange:B=>S(B)})]}),v==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:z,disabled:J,placeholder:"PROVIDER_API_KEY",onChange:B=>F(B.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:_}),e.jsx("input",{type:"password",value:N,disabled:J,placeholder:ne,autoComplete:"off",onChange:B=>b(B.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:J||!ue,children:[J?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:J?"Saving":de})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${d.displayName} credential`,disabled:J||!d.credential.connected,onClick:()=>{c(t)},children:e.jsx(ke,{size:15})})]})]})}function I(){return H?e.jsxs("div",{className:"provider-subscription-panel",id:q,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:Y,onClick:()=>{f("browser")},children:[Y?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:Y?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:Y,onClick:()=>{f("device")},children:[Y?e.jsx(oe,{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 ${d.displayName} credential`,disabled:Y||!d.credential.connected,onClick:()=>{c(t)},children:e.jsx(ke,{size:15})})]})]}):ee?e.jsx("div",{className:"provider-subscription-panel",id:q,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."})]})}):X?e.jsxs("div",{className:"provider-subscription-panel",id:q,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."})]}),M({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[g?null:e.jsxs("form",{className:"provider-card-form",onSubmit:U=>{he(U)},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:R,disabled:G,placeholder:"https://api.example.com/v1",onChange:U=>{E(B=>({...B,baseUrl:!0})),P(U.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:U=>{E(B=>({...B,defaultModel:!0})),C(U.currentTarget.value)}}),e.jsx("datalist",{id:y,children:se.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))}),te>0?e.jsxs("small",{children:[te," 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(oe,{size:14,className:"settings-spin"}):e.jsx(os,{size:14}),e.jsx("span",{children:G?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:D,onClick:()=>{m(t)},children:[D?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(le,{size:14}),e.jsx("span",{children:D?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:W||!k.trim(),onClick:()=>{u(t,{baseUrl:R.trim()||void 0,modelId:k.trim()||void 0})},children:[W?e.jsx(oe,{size:14,className:"settings-spin"}):e.jsx(Zs,{size:14}),e.jsx("span",{children:W?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:g?I():M()})]})}function Ka({status:s,busy:n,flashTailscaleUp:a,refresh:t,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:d,copyTailscaleUpCommand:c,copyServeCommand:m,copyServeSetupUrl:p,copyOperatorCommand:o,createRemoteLink:f}){const u=s?.tailscale.installed??!1,h=s?.serve.enabled??!1,j=s?.serve.reachable??!1,y=!!(s?.webUiAvailable&&u),w=h?!!s?.remoteWebUrl:y,P=(s?.tailscale.peers??[]).filter(x=>!x.isSelf),k=!!s?.tailscale.error?.includes("set --operator"),C=!!(h&&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 ${j?"online":h?"configured":""}`,children:u?e.jsx(rn,{size:18}):e.jsx(ht,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:j?"Tailscale Serve is reachable":h?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Qa(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(le,{className:n==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:n!==null||!u||!h&&!y,onClick:()=>{h?i():l()},children:[e.jsx(Wn,{size:15}),e.jsx("span",{children:h?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:C?"Browser UI":"Tailscale + Serve"})]})}),C&&e.jsx(me,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:n==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||n!==null,onAction:d}),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:c}),e.jsx(me,{label:"Serve command",value:s?.serveCommand??null,actionLabel:n==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||n!==null,onAction:m}),s?.serve.setupUrl&&e.jsx(me,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:n==="copy-serve-setup"?"Copying":"Copy",disabled:n!==null,onAction:p}),k&&e.jsx(me,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:n==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||n!==null,onAction:o}),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:[P.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:n!==null||!w,onClick:()=>{f()},children:e.jsx("span",{children:h?"Copy link":"Create link"})})]}),s?P.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."})]}):P.map(x=>e.jsx(Ya,{peer:x},x.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(Ja,{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 Ja({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 Ya({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 Qa(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 Za=[{items:[{section:"account",label:"Account",Icon:vs},{section:"notifications",label:"Notifications",Icon:an},{section:"providers",label:"Providers",Icon:Xs},{section:"usage",label:"Activity",Icon:Kn}]},{label:"Harness",items:[{section:"harness",label:"Overview",Icon:rt},{section:"harness-refiner",label:"Refiner",Icon:js},{section:"harness-continuous-review",label:"Continuous Review",Icon:le},{section:"harness-contents",label:"Contents",Icon:Jn},{section:"harness-releases",label:"Releases",Icon:ot}]},{label:"Customization",items:[{section:"configuration",label:"Configuration",Icon:At},{section:"personalization",label:"Personalization",Icon:js},{section:"editor",label:"Editor",Icon:ct},{section:"skills",label:"Skills",Icon:ze}]},{label:"Agents",items:[{section:"profile",label:"Profiles",Icon:vs},{section:"subagents",label:"Agents",Icon:He}]},{label:"System",items:[{section:"dataset-storage",label:"Dataset Storage",Icon:wt},{section:"remote",label:"Remote Access",Icon:rn},{section:"diagnostics",label:"Diagnostics",Icon:mt}]}];function Xa({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(Vn,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Za.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:d,Icon:c})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>a(i),children:[e.jsx(c,{size:16}),e.jsx("span",{children:d})]},i))]},t.label??`settings-${l}`))})]})}function el({catalog:s,connection:n,onCatalog:a,onError:t,onOpenExtension:l,onToast:i}){const[d,c]=r.useState(""),[m,p]=r.useState(""),[o,f]=r.useState(null),[u,h]=r.useState(null),[j,y]=r.useState(null),w=r.useCallback(v=>{const S=v instanceof Error?v.message:String(v);y(S),t(S),i?.(S,"error")},[t,i]),R=r.useCallback(()=>{y(null),t(null)},[t]),P=r.useCallback(async v=>{if(v?.preventDefault(),!(!n||!d.trim()||u)){R(),h("preview");try{const S=await $.extensionPreview(n,{source:d.trim(),...m.trim()?{ref:m.trim()}:{}});f(S)}catch(S){f(null),w(S)}finally{h(null)}}},[u,R,n,w,m,d]),k=r.useCallback(async()=>{if(!(!n||!o||u)){R(),h("install");try{const v=await $.extensionAdd(n,{source:o.repositoryUrl,ref:o.requestedRef});a(v.catalog),c(""),p(""),f(null),i?.(`Installed ${v.extension.owner}/${v.extension.repo}.`,"success")}catch(v){w(v)}finally{h(null)}}},[u,R,n,a,i,o,w]),C=r.useCallback(async v=>{if(!(!n||u)){R(),h(`update:${v.id}`);try{const S=await $.extensionUpdate(n,v);a(S.catalog);const N=S.extension.resolvedCommit===v.resolvedCommit&&S.extension.packageHash===v.packageHash;i?.(N?`${v.owner}/${v.repo} is already current.`:`Updated ${v.owner}/${v.repo}.`,"success")}catch(S){w(S)}finally{h(null)}}},[u,R,n,a,i,w]),x=r.useCallback(async()=>{if(!(!n||u||s.extensions.length===0)){R(),h("update-all");try{const v=await $.extensionUpdateAll(n);a(v.catalog);const S=`Updated ${v.updated.length}; ${v.unchanged.length} already current${v.failed.length?`; ${v.failed.length} failed`:""}.`;i?.(S,v.failed.length?"error":"success"),v.failed.length&&y(v.failed.map(N=>N.error).join(" "))}catch(v){w(v)}finally{h(null)}}},[u,s.extensions.length,R,n,a,i,w]),A=r.useCallback(async v=>{if(!(!n||u)&&window.confirm(`Remove ${v.owner}/${v.repo} and its ${v.skills.length} installed skill${v.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){R(),h(`remove:${v.id}`);try{const S=await $.extensionRemove(n,v);a(S.catalog),i?.(`Removed ${v.owner}/${v.repo}.`,"success")}catch(S){w(S)}finally{h(null)}}},[u,R,n,a,i,w]),L=r.useCallback(v=>{c(v),f(null),y(null)},[]),E=r.useCallback(v=>{p(v),f(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||u!==null||s.extensions.length===0,type:"button",onClick:()=>{x()},children:[u==="update-all"?e.jsx(oe,{className:"settings-spin",size:13}):e.jsx(le,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:v=>{P(v)},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||u!==null,placeholder:"owner/repo",value:d,onChange:v=>L(v.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!n||u!==null,placeholder:"Default branch",value:m,onChange:v=>E(v.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!d.trim()||u!==null,type:"submit",children:[u==="preview"?e.jsx(oe,{className:"settings-spin",size:14}):e.jsx(es,{size:14}),u==="preview"?"Checking":"Preview"]})]}),j||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:j??s.error}):null,o?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[o.owner,"/",o.repo]}),e.jsxs("span",{children:[o.skills.length," skill",o.skills.length===1?"":"s"," at ",o.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:o.skills.map(v=>e.jsx("span",{children:v.name},v.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:u!==null,type:"button",onClick:()=>{k()},children:[u==="install"?e.jsx(oe,{className:"settings-spin",size:14}):e.jsx(ge,{size:14}),u==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(v=>{const S=u===`update:${v.id}`,N=u===`remove:${v.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${v.owner}/${v.repo} extension source`,className:"github-extension-open",disabled:!n||u!==null,type:"button",onClick:()=>l(v),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(es,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsxs("strong",{children:[v.owner,"/",v.repo]}),e.jsx("span",{children:v.skills.map(b=>b.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[v.skills.length," skill",v.skills.length===1?"":"s"]}),e.jsxs("span",{children:[v.requestedRef," · ",v.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${v.validationStatus==="valid"?"":"invalid"}`,children:v.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(en,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${v.owner}/${v.repo}`,className:"settings-icon-button ghost",disabled:u!==null,title:"Update extension",type:"button",onClick:()=>{C(v)},children:S?e.jsx(oe,{className:"settings-spin",size:14}):e.jsx(le,{size:14})}),e.jsx("button",{"aria-label":`Remove ${v.owner}/${v.repo}`,className:"settings-icon-button ghost danger",disabled:u!==null,title:"Remove extension",type:"button",onClick:()=>{A(v)},children:N?e.jsx(oe,{className:"settings-spin",size:14}):e.jsx(ke,{size:14})})]})]},v.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function sl({onOpenSkill:s,onOpenExtension:n,personalSkills:a,extensionCatalog:t,connection:l,onExtensionCatalog:i,onError:d,onToast:c}){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(el,{catalog:t,connection:l,onCatalog:i,onError:d,onOpenExtension:n,onToast:c}),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(m=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(ze,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:m.name}),e.jsx("span",{children:m.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:m.resourceFiles.length?`${m.resourceFiles.length} packaged resource${m.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:m.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${m.validationStatus==="valid"?"":"invalid"}`,children:m.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},m.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"})]}),Yn.map(m=>{const p=Qn(m.provider)?.label??m.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(m),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(ze,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:m.name}),e.jsx("span",{children:m.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:p}),e.jsx("span",{children:m.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(en,{size:16,"aria-hidden":"true"})]},m.name)})]})]})}const ds="default";function nl({connection:s,embedded:n=!1,onError:a,onPreferences:t,preferences:l,providers:i}){const d=l.training,[c,m]=r.useState(Qe(d.defaultModelRef)),[p,o]=r.useState(d.creationMode),[f,u]=r.useState(d.autoApproveEvidence),[h,j]=r.useState(!1),y=r.useMemo(()=>Qs(i,{includeUnavailable:!0}),[i]),w=r.useMemo(()=>y.map(x=>({provider:x,models:Be(x.value,i)})).filter(x=>x.models.length>0),[y,i]),R=tl(c),P=Zn(l.defaultChatProvider,l.defaultChatModel,i)?` · ${al(l.codexReasoningEffort)} reasoning`:"",k=ll(R,d.defaultModelRef??null)&&p===d.creationMode&&f===d.autoApproveEvidence;r.useEffect(()=>{m(Qe(d.defaultModelRef)),o(d.creationMode),u(d.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,d.autoApproveEvidence,d.creationMode,d.defaultModelRef]);async function C(x){if(x.preventDefault(),!!s){j(!0),a(null);try{t(await $.savePreferences(s,{training:{defaultModelRef:R,creationMode:p,autoApproveEvidence:f}}))}catch(A){a(A instanceof Error?A.message:String(A))}finally{j(!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:x=>{C(x)},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:c,disabled:h,onChange:x=>m(x.target.value),children:[e.jsxs("option",{value:ds,children:["Use chat default — ",Te(l.defaultChatProvider,i)," · ",ns(l.defaultChatModel,i,l.defaultChatProvider),P]}),w.map(x=>e.jsx("optgroup",{label:x.provider.label,children:x.models.map(A=>e.jsx("option",{value:Qe({providerId:x.provider.value,modelId:A.value}),children:A.label},A.value))},x.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:p,disabled:h,onChange:x=>o(x.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:f,disabled:h,onChange:x=>u(x.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:h||k,children:e.jsx("span",{children:h?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:R?`${Te(R.providerId,i)} / ${ns(R.modelId,i,R.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 Qe(s){return s?JSON.stringify([s.providerId,s.modelId]):ds}function tl(s){if(s===ds)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 al(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function ll(s,n){return s?.providerId===n?.providerId&&s?.modelId===n?.modelId}function il({disabled:s,onChange:n,storageRoots:a,value:t}){const l=r.useId(),[i,d]=r.useState(!1),c=Fs(t),m=f=>f.datasetStorePath,p="Dataset",o=a.find(f=>Fs(m(f))===c)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:l,children:[p," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${p} storage drive`,className:"model-storage-select",disabled:s,id:l,title:t??"No Dataset storage configured",value:t??"",onChange:f=>n(f.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),t&&!o?e.jsx("option",{value:t,children:"Manual location"}):null,a.map(f=>e.jsxs("option",{disabled:!f.mounted||!f.writable,title:m(f),value:m(f),children:[f.label," · ",dl(f.kind)," · ",ul(f)]},f.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:()=>d(!0),children:e.jsx(ge,{size:15})})]}),i?rl(e.jsx(ol,{initialPath:t??"",purpose:"dataset",onClose:()=>d(!1),onUse:f=>{n(f),d(!1)}})):null]})}function rl(s){return typeof document>"u"?s:Xn.createPortal(s,document.body)}function ol({initialPath:s,onClose:n,onUse:a,purpose:t="model"}){const l=r.useId(),[i,d]=r.useState(s),c=cl(i);r.useEffect(()=>{const p=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]);function m(p){p.preventDefault(),p.stopPropagation(),!c&&a(i.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:p=>{p.target===p.currentTarget&&n()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:m,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(ft,{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:p=>d(p.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()&&c?e.jsx("div",{className:"profile-dialog-warning",children:c}):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:!!c,type:"submit",children:"Use location"})]})]})})}function cl(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 dl(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function ul(s){return s.mounted?s.writable?`${hl(s.freeBytes)} free`:"Read only":"Not mounted"}function Fs(s){const n=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(n)?n.toLowerCase():n}function hl(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 ml({state:s,catalog:n,busy:a,catalogLoading:t,onRefresh:l,onSave:i}){const[d,c]=r.useState(s?.settings.datasetStorePath??null);r.useEffect(()=>{c(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const m=r.useMemo(()=>s?.storageRoots.find(u=>Gs(u.datasetStorePath)===Gs(d))??null,[d,s?.storageRoots]),p=d===(s?.settings.datasetStorePath??null),o=n?.datasets??[];async function f(u){u.preventDefault(),await i(d)}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(le,{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:m?.label??(d?"Manual location":"Not configured")}),e.jsx("small",{children:d??"Choose a writable local or mounted location before importing a Dataset."}),m?e.jsxs("small",{children:[xl(m.kind)," · ",m.freeBytes==null?"Free space unknown":`${pn(m.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:u=>{f(u)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(il,{disabled:a!==null,onChange:c,storageRoots:s?.storageRoots??[],value:d}),e.jsx("button",{className:"settings-primary",disabled:a!==null||p,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:o.length})]}),o.length?o.map(u=>e.jsx(pl,{dataset:u},u.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t?"Loading registered Datasets":"No registered Datasets"})})]})]})}function pl({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:[fn(s.rowCount)," rows"," · ",fl(s)," · ",n," · ",s.sizeBytes==null?"Size unavailable":pn(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?gl(s.status):"Unavailable"})]})}function fl(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])=>`${fn(Number(t))} ${a}`).join(" · ")||"No split rows"}function pn(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 fn(s){return new Intl.NumberFormat().format(s)}function Gs(s){return s?.replace(/[\\/]+$/,"")??""}function gl(s){return s.replaceAll("_"," ").replace(/^./,n=>n.toUpperCase())}function xl(s){return s.replace(/^./,n=>n.toUpperCase())}function Ee(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function Se(s){return s?s.slice(0,10):"none"}function ye(s){const n=s.replaceAll("_"," ");return`${n.charAt(0).toUpperCase()}${n.slice(1)}`}function jl(s){return s==="unresolved"?"Watching":s==="confirmed"?"Ready for Refiner":ye(s)}function vl({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?Se(t.contentHash):"Not created"})]},a))})}function bl({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:jl(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:Ee(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:Se(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:ye(n.kind)}),e.jsx("code",{children:Se(n.evidence.contentHash)}),e.jsx("time",{children:Ee(n.occurredAt)})]},`${n.evidence.id}:${n.evidence.contentHash}`))})]}):null]})]})}function yl({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:ye(a.classification)}),e.jsx("strong",{children:a.claim?.statement??a.reason}),e.jsxs("small",{children:[a.selectedEvidence.length," selected"]}),e.jsx("time",{children:Ee(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:ye(a.nextAuthority)})]})]}),e.jsx(vl,{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 Nl({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:ye(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsxs("small",{children:[ye(s.signal.strength)," signal"]}),e.jsx("time",{children:Ee(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:Se(s.review.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Taskset"}),e.jsx("dd",{children:e.jsx("code",{children:Se(s.tasksetRelease?.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Baseline"}),e.jsx("dd",{children:e.jsx("code",{children:Se(s.baselineEvaluation?.contentHash)})})]})]})]})]})}function wl({acceptingReviewId:s,candidates:n,onAcceptTasksetReview:a,qualifications:t,reviews:l,schedule:i}){const d=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 ${d?"harness-status-advanced":""}`,children:d?"On":"Off"})}),e.jsx("td",{children:i.activityEnabled?`${i.activityBatchSize} new outcomes`:"Manual only"}),e.jsx("td",{children:Ee(i.lastRunAt)}),e.jsx("td",{children:i.lastResult?ye(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(c=>e.jsx(bl,{candidate:c},`${c.id}:${c.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(c=>e.jsx(yl,{accepting:s===c.id,onAcceptTasksetReview:a,review:c},`${c.id}:${c.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(c=>e.jsx(Nl,{receipt:c},`${c.id}:${c.contentHash}`))})]}):null]})}const Sl="Update the Refiner Review Profile. Inspect the current profile first, ask what should change if it is not already clear, and show the exact release transition.";function qs(s){const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function we(s){return s?s.slice(0,10):"none"}function kl({busyReleaseHash:s,history:n,onRequestRelease:a,onStartAuthoring:t}){const l=r.useMemo(()=>{const i=new Map;for(const d of n.transitions)i.has(d.nextRelease.contentHash)||i.set(d.nextRelease.contentHash,d);return i},[n.transitions]);return e.jsxs(e.Fragment,{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:"Review Profile"}),e.jsx("p",{children:"Separately versioned policy composed with the immutable Refiner Core."})]}),t?e.jsx("button",{className:"settings-primary compact",onClick:()=>t(Sl),type:"button",children:"Edit with Work"}):null]}),e.jsxs("div",{className:"harness-summary-grid",children:[e.jsxs("article",{children:[e.jsx("span",{children:"Active release"}),e.jsx("strong",{children:we(n.binding.release.contentHash)}),e.jsxs("small",{children:["Binding revision ",n.binding.revision]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Profile"}),e.jsx("strong",{children:n.currentRelease.profile.name}),e.jsxs("small",{children:[n.currentRelease.profile.id,"@",n.currentRelease.profile.version]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Core"}),e.jsx("strong",{children:n.currentRelease.coreVersion}),e.jsx("small",{children:we(n.currentRelease.coreHash)})]})]}),e.jsx("p",{children:n.currentRelease.profile.objective}),n.currentRelease.profile.instructions.length?e.jsx("div",{className:"harness-edit-list",children:n.currentRelease.profile.instructions.map(i=>e.jsx("section",{className:"harness-edit",children:e.jsxs("div",{children:[e.jsx("strong",{children:i.id}),e.jsx("span",{children:i.text})]})},i.id))}):e.jsx("div",{className:"harness-empty compact",children:"The default profile adds no instructions beyond the Refiner Core."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Profile releases"}),e.jsx("p",{children:"Immutable definition history. Rollback changes future reviews only."})]}),e.jsx("span",{children:n.releases.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:"Profile"}),e.jsx("th",{children:"Release"}),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(i=>{const d=i.contentHash===n.binding.release.contentHash,c=!d&&l.get(i.contentHash)?.bindingChanged===!1,m=c?"activate":"rollback";return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("strong",{children:i.profile.name}),e.jsxs("small",{children:[i.profile.id,"@",i.profile.version," · ",i.profile.instructions.length," instructions"]})]}),e.jsx("td",{children:e.jsx("code",{children:we(i.contentHash)})}),e.jsx("td",{children:qs(i.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:d?"active":c?"draft":"immutable"})}),e.jsx("td",{children:d?null:e.jsx("button",{"aria-label":`${c?"Activate":"Roll back"} Refiner release`,className:"harness-table-icon-action",disabled:s!==null,onClick:()=>a(i,m),title:`${c?"Activate":"Roll back"} Refiner release`,type:"button",children:c?e.jsx(rs,{size:14}):e.jsx(_e,{size:14})})})]},i.contentHash)})})]})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Definition changes"}),e.jsx("p",{children:"Receipts record which release changed, why, and which authoring Skill produced it."})]}),e.jsx("span",{children:n.transitions.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:"Operation"}),e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Release transition"}),e.jsx("th",{children:"Validation"}),e.jsx("th",{children:"Created"})]})}),e.jsx("tbody",{children:n.transitions.map(i=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("span",{className:"harness-status",children:[i.operation,i.bindingChanged?" · active":" · draft"]})}),e.jsxs("td",{children:[e.jsx("strong",{children:i.reason}),e.jsx("small",{children:i.authoringSkillHash?`Skill ${we(i.authoringSkillHash)}`:i.actor})]}),e.jsx("td",{children:e.jsxs("code",{children:[we(i.previousRelease?.contentHash)," → ",we(i.nextRelease.contentHash)]})}),e.jsx("td",{children:i.validation.valid?"Passed":i.validation.messages.join("; ")}),e.jsx("td",{children:qs(i.createdAt)})]},i.contentHash))})]})})]})]})}const Cl={enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},Rl={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 Re(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function Pe(s){return s?s.slice(0,10):"none"}function Ws(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 ${Pe(a.contentHash)}`}}function Pl({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:Re(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(rs,{size:13})," Approve and release"]})]})]})}function Al({change:s,onClose:n}){const a=s.proposal;return e.jsxs(gt,{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 Dl({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(Pl,{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:Re(l.at)})]},l.id))}):e.jsx("div",{className:"harness-empty compact",children:"No Harness learning activity yet."})]})]})}function Il({history:s,refiner:n,busyReleaseHash:a,onRequestRefinerRelease:t,onStartRefinerAuthoring:l,onOpenChangeDiff:i,onOpenSourceSession:d}){const[c,m]=r.useState(null);return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx(kl,{busyReleaseHash:a,history:n,onRequestRelease:t,onStartAuthoring:l}),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(p=>{const o=p.trigger?.runRef??null,f=p.proposal;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:f?.expectedOutcome??p.receipt.reason})}),e.jsx("td",{children:e.jsx("code",{children:f?.edits[0]?.target??f?.route??"workspace"})}),e.jsx("td",{children:e.jsx("code",{children:Pe(p.receipt.nextRelease?.contentHash)})}),e.jsx("td",{children:Re(p.receipt.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`harness-status harness-status-${p.receipt.decision}`,children:p.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:()=>m(p),title:"View evidence and exact edits",type:"button",children:e.jsx(yt,{size:14})}),p.receipt.nextRelease?e.jsx("button",{"aria-label":"View release diff",className:"harness-table-icon-action",onClick:()=>i(p),title:"View release diff",type:"button",children:e.jsx(ln,{size:14})}):null,o&&d?e.jsx("button",{"aria-label":"Open source conversation",className:"harness-table-icon-action",onClick:()=>d(o),title:"Open source conversation",type:"button",children:e.jsx(Xs,{size:14})}):null]})})]},`${p.receipt.id}:${p.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(p=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("p",{children:p.decision.reason})}),e.jsx("td",{children:e.jsx("p",{children:p.trigger?.reason??"Completed work"})}),e.jsx("td",{children:Re(p.decision.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:p.decision.route})})]},`${p.decision.id}:${p.decision.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No recommendations have been routed."})]}),c?e.jsx(Al,{change:c,onClose:()=>m(null)}):null]})}function $l(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 El(s){return s<1024?`${s} B`:`${(s/1024).toFixed(s<10240?1:0)} KB`}function Ml({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:$l(t.path)})}),e.jsx("td",{children:e.jsx("code",{children:t.path})}),e.jsx("td",{children:El(t.sizeBytes)}),e.jsx("td",{children:e.jsx("code",{children:Pe(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:Re(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:Pe(l.contentHash)})]})}),e.jsxs("td",{children:[l.files.length," files"]}),e.jsx("td",{children:Re(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(ln,{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(_e,{size:14})})]})})]},`${l.id}:${l.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness releases exist yet."})]})}function Ll({connection:s,enabled:n,onAcceptEvaluationReview:a,onError:t,onDefaultReleaseDiff:l,onOpenReleaseDiff:i,onOpenSourceSession:d,onStartRefinerAuthoring:c,onToast:m,page:p}){const[o,f]=r.useState(null),[u,h]=r.useState(null),[j,y]=r.useState(null),[w,R]=r.useState(!1),[P,k]=r.useState(null),[C,x]=r.useState(null),[A,L]=r.useState(!1),[E,v]=r.useState(!1),[S,N]=r.useState(null),{confirmAction:b,confirmDialog:z,resolveConfirmDialog:F}=Ks(),G=!!(o?.evaluationReviewSchedule.activityEnabled||o?.evaluationReviewSchedule.enabled),[J,W]=r.useState(!1),[D,Y]=r.useState(!1);r.useEffect(()=>{o&&W(o.backgroundReview.enabled)},[o?.backgroundReview.enabled]),r.useEffect(()=>{Y(G)},[G]);const H=r.useCallback(async()=>{if(s){R(!0);try{const[M,I]=await Promise.all([$.harnessHistory(s),$.refinerHistory(s)]);f(M),h(I);const U=M.releases.findIndex(Z=>Z.current),B=U>=0?M.releases[U]:null;M.workspace&&B&&l(Ws(M.workspace.id,M.releases[U+1]??null,B)),t(null)}catch(M){t(M instanceof Error?M.message:String(M))}finally{R(!1)}}},[s,l,t]);r.useEffect(()=>{n&&H()},[n,p,H]);const ee=r.useCallback(async M=>{if(!(!s||!o?.workspace)){v(!0);try{const I=await $.reviewHarnessEvaluation(s,{workspaceId:o.workspace.id,maxEstimatedCostUsd:M});f(I.history),t(null),m?.(`Continuous Review completed: ${I.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(I){t(I instanceof Error?I.message:String(I))}finally{v(!1)}}},[s,o,t,m]),X=r.useCallback(async(M,I,U)=>{if(!(!s||!o?.workspace)){L(!0);try{let B=o;M==="refiner"&&I!==o.backgroundReview.enabled&&(B=(await $.updateHarnessBackgroundReview(s,{workspaceId:o.workspace.id,enabled:I})).history);const Z=o.evaluationReviewSchedule.activityEnabled||o.evaluationReviewSchedule.enabled;if(M==="continuous-review"&&(U!==Z||o.evaluationReviewSchedule.enabled)){const Q=o.evaluationReviewSchedule;B=(await $.updateHarnessEvaluationReviewSchedule(s,{workspaceId:o.workspace.id,enabled:!1,activityEnabled:U,activityBatchSize:Q.activityBatchSize,cadence:"manual",maxEstimatedCostUsd:Q.maxEstimatedCostUsd})).history}f(B),t(null),m?.(`${M==="refiner"?"Refiner":"Continuous Review"} settings applied.`,"success")}catch(B){t(B instanceof Error?B.message:String(B))}finally{L(!1)}}},[s,o,t,m]),ie=r.useCallback(async M=>{if(o?.workspace){N(M.id);try{await a(o.workspace.id,{id:M.id,contentHash:M.contentHash})&&(t(null),m?.("Taskset review opened in Models.","success"))}catch(I){t(I instanceof Error?I.message:String(I))}finally{N(null)}}},[o?.workspace,a,t,m]),q=r.useCallback((M,I)=>{o?.workspace&&i(Ws(o.workspace.id,M,I))},[o?.workspace,i]),g=r.useCallback(M=>{!o?.workspace||!M.receipt.nextRelease||i({workspaceId:o.workspace.id,baseRelease:M.receipt.previousRelease,targetRelease:M.receipt.nextRelease,title:M.proposal?.expectedOutcome??M.receipt.reason})},[o?.workspace,i]),T=r.useCallback(async M=>{if(!(!s||!o?.workspace)){k(M.contentHash);try{const I=await $.rollbackHarness(s,{workspaceId:o.workspace.id,targetRelease:{id:M.id,contentHash:M.contentHash}});f(I.history),t(null),m?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(I){t(I instanceof Error?I.message:String(I))}finally{k(null)}}},[s,o?.workspace,t,m]),_=r.useCallback(async M=>{await b({title:"Roll back Harness release?",body:`New work will use ${Pe(M.contentHash)}. Active runs remain pinned to their current release.`,confirmLabel:"Roll back"})&&await T(M)},[b,T]),ne=r.useCallback(async(M,I)=>{if(!(!s||!await b({title:I==="activate"?"Activate Refiner release?":"Roll back Refiner release?",body:`Future reviews will use ${M.profile.name} at ${Pe(M.contentHash)}. Existing work remains pinned.`,confirmLabel:I==="activate"?"Activate":"Roll back"}))){y(M.contentHash);try{const B={release:{id:M.id,contentHash:M.contentHash},reason:`${I==="activate"?"Activate":"Rollback"} from Settings to ${M.profile.id}@${M.profile.version}.`,actor:"settings-user"};h(await(I==="activate"?$.activateRefinerRelease(s,B):$.rollbackRefinerRelease(s,B))),t(null),m?.(`Refiner ${I==="activate"?"activated":"rolled back"}. Existing work remains pinned.`,"success")}catch(B){t(B instanceof Error?B.message:String(B))}finally{y(null)}}},[b,s,t,m]),de=r.useCallback(async(M,I)=>{if(!(!s||!o?.workspace)){x(M.proposal.id);try{const U=await $.reviewHarnessProposal(s,{workspaceId:o.workspace.id,proposal:{id:M.proposal.id,contentHash:M.proposal.contentHash},decision:I});f(U.history),t(null),m?.(I==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",I==="approve"?"success":"info")}catch(U){t(U instanceof Error?U.message:String(U))}finally{x(null)}}},[s,o?.workspace,t,m]),se=o?.releases.find(M=>M.current)??o?.releases[0]??null,te=se?o?.releases.indexOf(se)??-1:-1,ue=Rl[p],he=o?p==="refiner"?J!==o.backgroundReview.enabled:D!==G||o.evaluationReviewSchedule.enabled:!1,re=p==="refiner"||p==="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:ue.title}),e.jsx("p",{children:ue.description})]}),o?.workspace&&re?e.jsxs("div",{className:"harness-page-header-actions",children:[p==="continuous-review"?e.jsx("button",{className:"settings-secondary compact",disabled:E,onClick:()=>{ee(o.evaluationReviewSchedule.maxEstimatedCostUsd)},type:"button",children:E?"Reviewing…":"Review now"}):null,e.jsxs("label",{className:"harness-page-toggle",children:[e.jsx("span",{children:p==="refiner"?J?"On":"Off":D?"On":"Off"}),e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{"aria-label":p==="refiner"?"Enable Refiner":"Enable Continuous Review",checked:p==="refiner"?J:D,disabled:A,onChange:M=>p==="refiner"?W(M.target.checked):Y(M.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("button",{className:"settings-primary compact",disabled:A||!he,onClick:()=>{X(p,J,D)},type:"button",children:A?"Applying…":"Apply changes"})]}):null]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&w&&!o?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,o&&!o.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,o?.workspace&&p==="overview"?e.jsx(Dl,{history:o,onReviewProposal:de,reviewingProposalId:C}):null,o&&u&&p==="refiner"?e.jsx(Il,{busyReleaseHash:j,history:o,refiner:u,onOpenChangeDiff:g,onOpenSourceSession:d,onRequestRefinerRelease:(M,I)=>{ne(M,I)},onStartRefinerAuthoring:c}):null,o?.workspace&&p==="continuous-review"?e.jsx(wl,{acceptingReviewId:S,candidates:o.refinementCandidates,onAcceptTasksetReview:M=>{ie(M)},qualifications:o.modelImprovementQualifications,reviews:o.evaluationReviews,schedule:o.evaluationReviewSchedule??Cl}):null,o?.workspace&&p==="contents"?e.jsx(Ml,{history:o,onOpenCurrentRelease:()=>{se&&q(te>=0?o.releases[te+1]??null:null,se)}}):null,o?.workspace&&p==="releases"?e.jsx(Ol,{busy:P!==null,history:o,onOpenDiff:q,onRequestRollback:M=>{_(M)}}):null,e.jsx(Js,{onResolve:F,state:z})]})}function Vs(s){return s?s.slice(0,10):"initial"}function Tl({connection:s,expanded:n,onResizeStart:a,onToggleExpanded:t,selection:l}){const[i,d]=r.useState(null),[c,m]=r.useState(null),[p,o]=r.useState(!0),f=r.useCallback(async()=>{m(null),o(!0);try{d(await $.harnessReleaseDiff(s,l))}catch(j){d(null),m(j instanceof Error?j.message:String(j))}finally{o(!1)}},[s,l]);r.useEffect(()=>{f()},[f]);const u=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(j=>j.path),files:i.files,error:null,updatedAt:""}:null,[i,l.title,l.workspaceId]),h=`${l.title} · ${Vs(l.baseRelease?.contentHash)} → ${Vs(l.targetRelease.contentHash)}`;return e.jsx(xt,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:u,editorPreferences:null,expanded:n,filesWithPreview:!0,loading:p,onOpenBrowserUrl:()=>{},onRefresh:f,onResizeStart:a,onToggleExpanded:t,readOnly:!0,workspaceError:c,workspaceInitialized:!0,workspaceName:h})}function zl({connection:s,onError:n,onPayload:a}){const[t,l]=r.useState(!1),[i,d]=r.useState(!1);async function c(f,u){if(s){l(!0),n(null);try{const h=await $.switchOpenPondAccount(s,{handle:f,baseUrl:u??null}),j=await $.savePreferences(s,{defaultTeamId:null});a({...h,preferences:j.preferences})}catch(h){n(h instanceof Error?h.message:String(h))}finally{l(!1)}}}async function m(f,u){if(!s)return!1;l(!0),n(null);try{return a(await $.removeOpenPondAccount(s,{handle:f,baseUrl:u??null})),!0}catch(h){return n(h instanceof Error?h.message:String(h)),!1}finally{l(!1)}}async function p(f){if(!(!s||!f.apiKey.trim())){l(!0),n(null);try{const u=f.handle?.trim(),h=f.environment?.trim(),j=await $.saveOpenPondAccount(s,{apiKey:f.apiKey.trim(),handle:u||void 0,baseUrl:f.baseUrl,apiBaseUrl:f.apiBaseUrl,environment:h||"custom",setActive:!0}),y=await $.savePreferences(s,{defaultTeamId:null});a({...j,preferences:y.preferences})}catch(u){throw n(u instanceof Error?u.message:String(u)),u}finally{l(!1)}}}async function o(){if(s){d(!0),n(null);try{a(await $.refreshOpenPondAccounts(s))}catch(f){n(f instanceof Error?f.message:String(f))}finally{d(!1)}}}return{refreshingAccounts:i,saving:t,refreshAccounts:o,removeAccount:m,saveAccount:p,switchAccount:c}}function Ul({connection:s,onError:n,onPreferences:a,preferences:t,providers:l}){const[i,d]=r.useState(t.defaultBranchPrefix),[c,m]=r.useState(t.defaultNewProjectDirectory),[p,o]=r.useState(t.advancedWorkspaceControls),[f,u]=r.useState(t.steerActiveResponses),[h,j]=r.useState(t.contextCompaction.autoEnabled),[y,w]=r.useState(t.subagents.enabled),[R,P]=r.useState(t.subagents.delegationMode),[k,C]=r.useState(!t.subagents.defaultModelRef),[x,A]=r.useState(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),[L,E]=r.useState(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),[v,S]=r.useState(t.subagents.roles),[N,b]=r.useState(t.subagents.maxConcurrentRuns),[z,F]=r.useState(t.subagents.maxConcurrentRunsPerProvider),[G,J]=r.useState(t.subagents.maxConcurrentRunsPerWorkspaceTarget),[W,D]=r.useState(!1),Y=k?null:{providerId:x,modelId:L.trim()},H=y!==t.subagents.enabled||R!==t.subagents.delegationMode||!Bl(Y,t.subagents.defaultModelRef)||N!==t.subagents.maxConcurrentRuns||z!==t.subagents.maxConcurrentRunsPerProvider||G!==t.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(v)!==JSON.stringify(t.subagents.roles);r.useEffect(()=>{d(t.defaultBranchPrefix),m(t.defaultNewProjectDirectory),o(t.advancedWorkspaceControls),u(t.steerActiveResponses),j(t.contextCompaction.autoEnabled),w(t.subagents.enabled),P(t.subagents.delegationMode),C(!t.subagents.defaultModelRef),A(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),E(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),S(t.subagents.roles),b(t.subagents.maxConcurrentRuns),F(t.subagents.maxConcurrentRunsPerProvider),J(t.subagents.maxConcurrentRunsPerWorkspaceTarget)},[t.defaultChatProvider,t.defaultChatModel,t.defaultBranchPrefix,t.defaultNewProjectDirectory,t.advancedWorkspaceControls,t.steerActiveResponses,t.contextCompaction.autoEnabled,t.subagents]);function ee(I){A(I),E(U=>ts(I,U,l))}function X(){return k?t.defaultChatProvider:x}function ie(){return k?t.defaultChatModel:L}function q(I,U){S(B=>B.map(Z=>Z.id===I?U(Z):Z))}function g(I,U){q(I,B=>({...B,enabled:U}))}function T(I,U){q(I,B=>({...B,background:U}))}function _(I,U){q(I,B=>{if(U)return{...B,modelRef:null};const Z=B.modelRef?.providerId??X(),Q=B.modelRef?.modelId??ie();return{...B,modelRef:qe(Z,Q,l)??null}})}function ne(I,U){q(I,B=>({...B,modelRef:qe(U,B.modelRef?.modelId??ie(),l)??null}))}function de(I,U){q(I,B=>{const Z=B.modelRef?.providerId??X(),Q=U.trim();return{...B,modelRef:Q?{providerId:Z,modelId:Q}:null}})}function se(I,U){q(I,B=>({...B,isolationMode:U}))}function te(I,U){q(I,B=>({...B,toolPolicy:U}))}function ue(I,U){q(I,B=>({...B,peerMessages:U}))}function he(I,U){q(I,B=>({...B,maxConcurrentRuns:be(U,1,16)}))}async function re(){let I=null;if(window.openpond?.selectFolder){const U=await window.openpond.selectFolder();if(U.canceled)return;I=U.path}else I=window.prompt("Default new project directory",c);I?.trim()&&m(I.trim())}async function M(I){if(I.preventDefault(),!!s){D(!0),n(null);try{a(await $.savePreferences(s,{defaultBranchPrefix:Ze(i),defaultNewProjectDirectory:c.trim(),advancedWorkspaceControls:p,steerActiveResponses:f,contextCompaction:{...t.contextCompaction,autoEnabled:h},subagents:{enabled:y,workspaceDefaultsVersion:t.subagents.workspaceDefaultsVersion,toolDefaultsVersion:t.subagents.toolDefaultsVersion,delegationMode:R,defaultModelRef:k?null:qe(x,L,l)??null,roles:v,maxConcurrentRuns:be(N,1,32),maxConcurrentRunsPerProvider:z===null?null:be(z,1,32),maxConcurrentRunsPerWorkspaceTarget:G===null?null:be(G,1,32)}}))}catch(U){n(U instanceof Error?U.message:String(U))}finally{D(!1)}}}return{advancedWorkspaceControls:p,steerActiveResponses:f,contextCompactionAutoEnabled:h,defaultBranchPrefix:i,defaultNewProjectDirectory:c,subagentsEnabled:y,subagentDelegationMode:R,subagentsUseDefaultModel:k,subagentsProvider:x,subagentsModel:L,subagentRoles:v,subagentsMaxConcurrentRuns:N,subagentsMaxConcurrentRunsPerProvider:z,subagentsMaxConcurrentRunsPerWorkspaceTarget:G,subagentsDirty:H,saving:W,chooseDefaultProjectDirectory:re,saveDefaults:M,changeSubagentsProvider:ee,changeSubagentRoleProvider:ne,setAdvancedWorkspaceControls:o,setSteerActiveResponses:u,setContextCompactionAutoEnabled:j,setDefaultBranchPrefix:d,setDefaultNewProjectDirectory:m,setSubagentsUseDefaultModel:C,setSubagentsModel:E,setSubagentsEnabled:w,setSubagentDelegationMode:I=>P(I),setSubagentsMaxConcurrentRuns:I=>b(be(I,1,32)),setSubagentsMaxConcurrentRunsPerProvider:I=>F(I===null?null:be(I,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:I=>J(I===null?null:be(I,1,32)),setSubagentRoleBackground:T,setSubagentRoleEnabled:g,setSubagentRoleIsolationMode:se,setSubagentRoleMaxConcurrentRuns:he,setSubagentRoleModel:de,setSubagentRolePeerMessages:ue,setSubagentRoleToolPolicy:te,setSubagentRoleUseDefaultModel:_}}function be(s,n,a){return Number.isFinite(s)?Math.min(a,Math.max(n,Math.trunc(s))):n}function Bl(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const Hl=15e3,_l=100,Fl=100,Gl=2500;function ql({onError:s,section:n}){const[a,t]=r.useState(null),[l,i]=r.useState(null),[d,c]=r.useState(_l),[m,p]=r.useState([]),[o,f]=r.useState(null),[u,h]=r.useState(!0),j=r.useRef(null),[y,w]=r.useState(null),R=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),k=!!window.openpond?.readRecentLogs?`${m.length} of ${d} line${d===1?"":"s"}${u?" tailing":""}`:"Unavailable";r.useEffect(()=>{n==="diagnostics"&&C(d,"refresh",{quiet:!0})},[n]),r.useEffect(()=>{if(n!=="diagnostics"||!u||!window.openpond?.readRecentLogs)return;let S=!1;const N=window.setInterval(()=>{S||(S=!0,C(d,"refresh",{quiet:!0}).finally(()=>{S=!1}))},Gl);return()=>window.clearInterval(N)},[n,u,d]),r.useEffect(()=>{if(n!=="diagnostics"||!u)return;const S=j.current;S&&(S.scrollTop=S.scrollHeight)},[n,u,m]);async function C(S=d,N="refresh",b={}){const z=window.openpond?.readRecentLogs;if(!z){const F="Log view is not available in this runtime.";b.quiet||(w({label:"Logs",value:F,warning:!0}),s(F));return}b.quiet||i(N);try{const F=await Oe(z(S),"Read logs");if(!F.ok)throw new Error(F.error);c(F.lineLimit),f(F.logDir),p(F.lines),b.quiet?w(G=>G?.label==="Logs"?null:G):w(null)}catch(F){const G=F instanceof Error?F.message:String(F);w({label:"Logs",value:G,warning:!0}),b.quiet||s(G)}finally{b.quiet||i(null)}}function x(){h(!1),C(d+Fl,"older")}function A(){const S=!u;h(S),S&&C(d,"refresh",{quiet:!0})}async function L(){const S=window.openpond?.openLogsFolder;if(!S){const N="Desktop logs are not available in this runtime.";w({label:"Logs",value:N,warning:!0}),s(N);return}t("logs"),s(null);try{const N=await Oe(S(),"Open logs");if(!N.ok)throw new Error(N.error??"Could not open the logs folder.");w(null)}catch(N){const b=N instanceof Error?N.message:String(N);w({label:"Logs",value:b,warning:!0}),s(b)}finally{t(null)}}async function E(){const S=window.openpond?.copyRecentLogs;if(!S){const N="Recent log copy is not available in this runtime.";w({label:"Copy",value:N,warning:!0}),s(N);return}t("copy"),s(null);try{const N=await Oe(S(1e3),"Copy recent logs");if(!N.ok)throw new Error(N.error??"Could not copy recent logs.");w({label:"Copy",value:N.lines?`Copied ${N.lines} recent log lines.`:"Copied recent logs."})}catch(N){const b=N instanceof Error?N.message:String(N);w({label:"Copy",value:b,warning:!0}),s(b)}finally{t(null)}}async function v(){const S=window.openpond?.exportDiagnostics;if(!S){const N="Diagnostics export is not available in this runtime.";w({label:"Export",value:N,warning:!0}),s(N);return}t("export"),s(null);try{const N=await Oe(S(),"Export diagnostics");if(!N.ok)throw new Error(N.error??"Could not export diagnostics.");w({label:"Export",value:N.path?`Saved to ${N.path}`:"Diagnostics exported."})}catch(N){const b=N instanceof Error?N.message:String(N);w({label:"Export",value:b,warning:!0}),s(b)}finally{t(null)}}return{diagnosticsAvailable:R,diagnosticsBusy:a,diagnosticsStatus:y,logDir:o,logLineLimit:d,logLines:m,logViewBusy:l,logViewSummary:k,logViewportRef:j,tailLogs:u,copyRecentLogs:E,exportDiagnosticsBundle:v,loadOlderLogs:x,openLogsFolder:L,refreshLogView:C,toggleTailLogs:A}}async function Oe(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.`))},Hl)})])}finally{a!==void 0&&window.clearTimeout(a)}}function Wl({connection:s,enabled:n,onError:a,onPreferences:t,onToast:l,preferences:i}){const[d,c]=r.useState(i.editor),[m,p]=r.useState(null),[o,f]=r.useState(!1),[u,h]=r.useState(!1),[j,y]=r.useState(!1);r.useEffect(()=>{c(i.editor)},[i.editor]);const w=r.useCallback(async()=>{if(s){h(!0);try{p(await $.workspaceLspSettingsStatus(s))}catch(x){a(x instanceof Error?x.message:String(x))}finally{h(!1)}}},[s,a]);r.useEffect(()=>{!n||!s||w()},[s,n,w]);function R(x,A){c(L=>({...L,languages:{...L.languages,[x]:{...L.languages[x],mode:A}}}))}function P(x,A){c(L=>({...L,languages:{...L.languages,[x]:{...L.languages[x],customCommand:A}}}))}async function k(x){if(x.preventDefault(),!!s){f(!0),a(null);try{const A=await $.savePreferences(s,{editor:d});t(A),p(await $.workspaceLspSettingsStatus(s))}catch(A){a(A instanceof Error?A.message:String(A))}finally{f(!1)}}}async function C(){if(s){y(!0),a(null);try{await $.restartWorkspaceLsp(s),p(await $.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(x){a(x instanceof Error?x.message:String(x))}finally{y(!1)}}}return{editorPreferences:d,lspStatus:m,restarting:j,saving:o,statusLoading:u,refreshLspStatus:w,restartLanguageServers:C,saveEditorSettings:k,setEditorPreferences:c,setLanguageCustomCommand:P,setLanguageMode:R}}function Vl({connection:s,onError:n,onPayload:a,personalization:t}){const l=r.useMemo(()=>t.templates.map(v=>({value:v.id,label:v.name,description:v.id===t.activeTemplateId?"Selected":v.source==="built_in"?v.description:void 0})),[t.activeTemplateId,t.templates]),[i,d]=r.useState(t.activeTemplateId),[c,m]=r.useState(t.soul),[p,o]=r.useState(""),[f,u]=r.useState(!1),[h,j]=r.useState(!1),y=t.templates.find(v=>v.id===i)??t.templates[0],w=y?.source==="custom",R=y?c!==y.content:!0,P=i!==t.activeTemplateId||c!==t.soul||R,k=!!(w&&c.trim()&&y&&P);r.useEffect(()=>{d(t.activeTemplateId),m(t.soul);const v=t.templates.find(S=>S.id===t.activeTemplateId);o(v?`${v.name} Copy`:""),u(!1)},[t.activeTemplateId,t.soul,t.templates]);async function C(v=!1){if(!v&&!w)return;const S=v?p:y?.name;if(!(!s||!c.trim()||!S?.trim())){j(!0),n(null);try{a(await $.savePersonalization(s,{activeTemplateId:i,templateName:S,soul:c,saveAsNew:v})),u(!1)}catch(N){n(N instanceof Error?N.message:String(N))}finally{j(!1)}}}async function x(v){const S=t.templates.find(N=>N.id===v);if(S&&(d(S.id),o(`${S.name} Copy`),m(S.content),u(!1),!!s)){j(!0),n(null);try{a(await $.savePersonalization(s,{activeTemplateId:S.id,templateName:S.name,soul:S.content,saveAsNew:!1}))}catch(N){n(N instanceof Error?N.message:String(N))}finally{j(!1)}}}function A(){y&&(o(`${y.name} Copy`),m(y.content),u(!1))}function L(v){m(v),y&&!w&&v!==y.content&&u(!0)}function E(){y&&(o(`${y.name} Copy`),u(!0))}return{canSaveCurrentTemplate:k,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:f,saving:h,selectedPersonalizationTemplate:y,selectedTemplateIsCustom:w,soulDraft:c,templateNameDraft:p,changePersonalizationTemplate:x,changeSoulDraft:L,openSaveAsNew:E,resetPersonalizationDraft:A,savePersonalization:C,setSaveAsNewOpen:u,setTemplateNameDraft:o}}function Kl({connection:s,onError:n,onPreferences:a,onProviders:t,preferences:l,providers:i}){const[d,c]=r.useState(l.defaultChatProvider),[m,p]=r.useState(l.defaultChatModel),[o,f]=r.useState(!1),[u,h]=r.useState(null),[j,y]=r.useState(null);r.useEffect(()=>{c(l.defaultChatProvider),p(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function w(N){if(N.preventDefault(),!!s){f(!0),n(null);try{a(await $.savePreferences(s,{defaultChatProvider:d,defaultChatModel:ts(d,m,i)}))}catch(b){n(b instanceof Error?b.message:String(b))}finally{f(!1)}}}function R(N){c(N),p(b=>ts(N,b,i))}async function P(N,b,z){if(!s)return null;h(`${N}:${b}`),y(null),n(null);try{return await z()}catch(F){return n(F instanceof Error?F.message:String(F)),null}finally{h(null)}}async function k(N,b){await P(N,"config",async()=>{const z=await $.saveProviderSettings(s,{providers:{[N]:b}});return t(z),z})}async function C(N,b){await P(N,"credential",async()=>{const z=await $.saveProviderCredential(s,N,b);return t(z),z})}async function x(N){await P(N,"credential",async()=>{const b=await $.deleteProviderCredential(s,N,{});return t(b),b})}async function A(N){return P("openai","credential",async()=>{const b=await $.startOpenAiSubscriptionAuth(s,{method:N});return b.method==="browser"?(window.open(b.url,"_blank","noopener,noreferrer"),y("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(b.url,"_blank","noopener,noreferrer"),y(`OpenAI device login started. Enter code ${b.userCode}.`)),L(b.expiresAt),b})}async function L(N){if(s)for(;Date.now()<N;){await new Promise(b=>setTimeout(b,2500));try{const b=await $.providerSettings(s);t(b);const z=b.statuses.openai?.credential;if(z?.connected&&z.source==="chatgpt_subscription"){y("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function E(N){await P(N,"models",async()=>{const b=await $.refreshProviderModels(s,N,{force:!0});return t(b.providers),b})}async function v(N){await P(N,"models",async()=>{const b=await $.loadProviderModels(s,N,{limit:500});return t(b.providers),b})}async function S(N,b={}){await P(N,"validate",async()=>{const z=await $.validateProviderCredential(s,N,b);return y(z.ok?`${N} validated${z.modelId?` with ${z.modelId}`:""}.`:z.errors.join(`
9
+ `)||`${N} validation failed.`),t(z.providers),z})}return{defaultModel:m,defaultProvider:d,providerBusy:u,saving:o,validationMessage:j,changeDefaultProvider:R,deleteProviderCredential:x,loadProviderModels:v,refreshProviderModels:E,saveProviderConfig:k,saveProviderCredential:C,saveProviders:w,setDefaultModel:p,startOpenAiSubscriptionAuth:A,validateProvider:S}}function Jl({connection:s,enabled:n,onError:a,onToast:t}){const[l,i]=r.useState(null),[d,c]=r.useState(null),[m,p]=r.useState(!1),o=r.useRef(null),f=r.useCallback(async(A={})=>{if(s){A.quiet||c("refresh");try{const L=await $.remoteAccess(s);i(L),a(null)}catch(L){a(L instanceof Error?L.message:String(L))}finally{A.quiet||c(null)}}},[s,a]);r.useEffect(()=>{!n||!s||f({quiet:!0})},[s,n,f]),r.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);function u(){o.current!==null&&window.clearTimeout(o.current),p(!1),window.setTimeout(()=>{p(!0),o.current=window.setTimeout(()=>{p(!1),o.current=null},1500)},0)}async function h(){if(a(null),!!s)try{i(await $.remoteAccess(s))}catch{}}async function j(){if(!s)return null;l&&!l.tailscale.running&&u(),c("enable");try{const A=await $.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"):(u(),t?.(A.message||"Tailscale is not running. Run Tailscale up first.","error")),A.status}catch{return await h(),u(),t?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{c(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.")){c("disable");try{const A=await $.disableRemoteAccess(s);i(A.status),a(null)}catch{await h()}finally{c(null)}}}async function w(){l?.remoteWebUrl&&(c("copy-link"),await Ne(l.remoteWebUrl),c(null))}async function R(){l?.serveCommand&&(c("copy-command"),await Ne(l.serveCommand),c(null))}async function P(){l?.serve.setupUrl&&(c("copy-serve-setup"),await Ne(l.serve.setupUrl),c(null))}async function k(){l?.tailscaleUpCommand&&(c("copy-up-command"),await Ne(l.tailscaleUpCommand),c(null))}async function C(){l?.operatorCommand&&(c("copy-operator"),await Ne(l.operatorCommand),c(null))}async function x(){if(!l?.serve.enabled){const A=await j();A?.serve.enabled&&A.remoteWebUrl&&await Ne(A.remoteWebUrl);return}await w()}return{status:l,busy:d,flashTailscaleUp:m,refresh:f,enableRemoteAccess:j,disableRemoteAccess:y,copyRemoteLink:w,copyTailscaleUpCommand:k,copyServeCommand:R,copyServeSetupUrl:P,copyOperatorCommand:C,createRemoteLink:x}}function Yl(s){const[n,a]=r.useState(null),[t,l]=r.useState(null),i=r.useCallback(async()=>{if(s.connection){l("load");try{a(await $.datasetStorageState(s.connection)),s.onError(null)}catch(c){s.onError(c instanceof Error?c.message:String(c))}finally{l(null)}}},[s.connection,s.onError]),d=r.useCallback(async c=>{if(!s.connection||!c)return!1;l("save");try{return a(await $.updateDatasetStorage(s.connection,c)),s.onError(null),!0}catch(m){return s.onError(m instanceof Error?m.message:String(m)),!1}finally{l(null)}},[s.connection,s.onError]);return r.useEffect(()=>{s.enabled&&i()},[s.enabled,i]),{state:n,busy:t,refresh:i,save:d}}function Ql(s){const{connection:n,enabled:a,onError:t,profileId:l}=s,[i,d]=r.useState(null),[c,m]=r.useState(!1),p=r.useCallback(async()=>{if(n){m(!0);try{d(await $.datasetCatalog(n,l)),t(null)}catch(o){t(Zl(o))}finally{m(!1)}}},[n,t,l]);return r.useEffect(()=>{a&&p()},[a,p]),{catalog:i,loading:c,refresh:p}}function Zl(s){return s instanceof Error?s.message:String(s)}const Xl=new Set(["harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases"]);function ei(s){return s==="harness-refiner"?"refiner":s==="harness-continuous-review"?"continuous-review":s==="harness-contents"?"contents":s==="harness-releases"?"releases":"overview"}const si=r.lazy(()=>Cn(()=>import("./UsageSettingsSection-DROtDdak.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function Si({payload:s,connection:n,diagnostics:a,onPayload:t,onError:l,onToast:i,onBack:d,onOpenSourceSession:c,onStartRefinerAuthoring:m,onAcceptEvaluationReview:p,onOpenSkill:o,onOpenExtension:f,teamChatCurrentUserId:u,teamChatEnabled:h,teamChatNotificationMode:j,teamChatThreads:y,onTeamChatNotificationModeChange:w,onTeamChatThreadMuteChange:R,diffPanelWidth:P,diffPanelResizing:k,diffPanelExpanded:C,onDiffPanelResizeStart:x,onDiffPanelExpandedChange:A,initialSection:L="account"}){const[E,v]=r.useState(L),[S,N]=r.useState(null),[b,z]=r.useState(!1),F=s?.codex??null,G=r.useMemo(()=>et(s?.preferences),[s?.preferences]),J=s?.personalization??st,W=a??s?.diagnostics??[],D=nt()&&tt(n?.platform),Y=r.useCallback(Q=>{s&&t({...s,providers:Q})},[t,s]),H=r.useCallback(Q=>{s&&t({...s,preferences:Q.preferences})},[t,s]),ee=r.useCallback(Q=>{s&&t({...s,extensionCatalog:Q})},[t,s]),X=zl({connection:n,onError:l,onPayload:t}),ie=Kl({connection:n,onError:l,onPayload:t,onPreferences:H,onProviders:Y,preferences:G,providers:s?.providers??null}),q=Ul({connection:n,onError:l,onPayload:t,onPreferences:H,preferences:G,providers:s?.providers??null}),g=Wl({connection:n,enabled:E==="editor",onError:l,onPayload:t,onPreferences:H,onToast:i,preferences:G}),T=Vl({connection:n,onError:l,onPayload:t,personalization:J}),_=ql({onError:l,section:E}),ne=Jl({connection:n,enabled:E==="remote",onError:l,onToast:i}),de=E==="dataset-storage",se=Yl({connection:n,enabled:de,onError:l}),te=Ql({connection:n,enabled:de,onError:l,profileId:s?.profile.activeProfile??"default"}),ue=se.save,he=r.useCallback(async()=>{await Promise.all([se.refresh(),te.refresh()])},[se.refresh,te.refresh]),re=r.useCallback(()=>E!=="subagents"||!q.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[q.subagentsDirty,E]),M=r.useCallback(Q=>{Q!==E&&re()&&(z(!1),A(!1),v(Q),at({kind:"settings",section:Q}))},[re,A,E]),I=r.useCallback(()=>{re()&&(z(!1),A(!1),d())},[re,d,A]);r.useEffect(()=>{v(L)},[L]),r.useEffect(()=>{if(E!=="subagents"||!q.subagentsDirty)return;const Q=Ae=>{Ae.preventDefault(),Ae.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",Q),()=>window.removeEventListener("beforeunload",Q)},[q.subagentsDirty,E]);const U={"--diff-panel-width":`${P}px`},B=Xl.has(E),Z=B&&b&&S;return e.jsxs("div",{className:`settings-shell ${D?"platform-macos":""} ${Z?"harness-diff-open":""} ${C?"harness-diff-expanded":""} ${k?"diff-panel-resizing":""}`,style:U,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[B?e.jsx("button",{type:"button",className:`topbar-diff-button ${Z?"active":""}`,title:`${Z?"Hide":"Show"} sidebar`,"aria-label":`${Z?"Hide":"Show"} sidebar`,"aria-pressed":!!Z,disabled:!S,onClick:()=>z(Q=>!Q),children:e.jsx(lt,{size:16})}):null,e.jsx(it,{platform:n?.platform})]}),e.jsx(Xa,{section:E,onBack:I,onSectionChange:M}),e.jsxs("main",{className:`settings-content ${E==="profile"||B?"settings-content-wide":""}`,children:[E!=="configuration"?e.jsx(bs,{connection:n,bannerOnly:!0,onOpen:()=>M("configuration")}):null,E==="account"?e.jsx(Mt,{payload:s,connection:n,onPayload:t,onPreferences:H,onError:l,onToast:i,...X}):E==="notifications"?e.jsx(ea,{currentUserId:u,enabled:h,mode:j,threads:y,onModeChange:w,onThreadMuteChange:R}):B?e.jsx(Ll,{connection:n,enabled:B,onAcceptEvaluationReview:p,onError:l,onDefaultReleaseDiff:N,onOpenSourceSession:c,onStartRefinerAuthoring:m,onOpenReleaseDiff:Q=>{N(Q),z(!0)},onToast:i,page:ei(E)}):E==="profile"?e.jsx(ya,{payload:s,connection:n,onPayload:t,onError:l,onToast:i,onOpenSession:c}):E==="skills"?e.jsx(sl,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:n,onExtensionCatalog:ee,onError:l,onToast:i,onOpenSkill:o,onOpenExtension:f}):E==="providers"?e.jsx(Ga,{account:s?.account??null,codex:F,providers:s?.providers??null,...ie}):E==="dataset-storage"?e.jsx(ml,{state:se.state,catalog:te.catalog,busy:se.busy,catalogLoading:te.loading,onRefresh:he,onSave:ue}):E==="configuration"?e.jsxs("div",{className:"settings-stacked-sections configuration-page",children:[e.jsx(bs,{connection:n,onSaved:async()=>{n&&t(await $.bootstrap(n))}}),e.jsx(Bt,{preferences:G,...q}),e.jsx(As,{embedded:!0,preferences:G,...q})]}):E==="context"?e.jsx(As,{preferences:G,...q}):E==="training"?e.jsx(nl,{connection:n,onError:l,onPreferences:H,preferences:G,providers:s?.providers??null}):E==="subagents"?e.jsx(Wt,{preferences:G,providers:s?.providers??null,...q}):E==="editor"?e.jsx(qt,{preferences:G,...g}):E==="remote"?e.jsx(Ka,{...ne}):E==="usage"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(si,{account:s?.account??null,connection:n,enabled:E==="usage",onError:l,onOpenSourceSession:c})}):E==="personalization"?e.jsx(na,{...T}):e.jsx(Ht,{diagnostics:W,..._})]}),B&&n&&Z?e.jsx(Tl,{connection:n,expanded:C,onResizeStart:x,onToggleExpanded:()=>A(!C),selection:Z}):null]})}export{Si as SettingsView};