openpond 0.0.35 → 0.0.36

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 (118) hide show
  1. package/dist/chunks/{app-layer-GUF2CKYH.js → app-layer-4AA4YYGK.js} +3 -3
  2. package/dist/chunks/{apps-DIVHAUOV.js → apps-V2JTB5MD.js} +3 -3
  3. package/dist/chunks/{chunk-FRPL5XPX.js → chunk-3DOOLZZM.js} +1 -1
  4. package/dist/chunks/{chunk-CRFB72X2.js → chunk-3JJBNVNX.js} +3 -3
  5. package/dist/chunks/{chunk-GUGFYXFS.js → chunk-65BVQIHR.js} +4 -4
  6. package/dist/chunks/{chunk-NTRTK6C6.js → chunk-6L5WJF7T.js} +2 -2
  7. package/dist/chunks/{chunk-SECNDLPQ.js → chunk-7IPF4X3K.js} +67 -1
  8. package/dist/chunks/{chunk-ZZOTKXRD.js → chunk-CJSD5ADV.js} +2 -2
  9. package/dist/chunks/{chunk-TXJ4TIDO.js → chunk-G6WW2656.js} +1 -1
  10. package/dist/chunks/{chunk-II2ERA2H.js → chunk-GALAW74P.js} +2 -2
  11. package/dist/chunks/{chunk-4Y25BACE.js → chunk-JAS6QZ2W.js} +1 -1
  12. package/dist/chunks/{chunk-EY52SLOQ.js → chunk-MJT7EW5Q.js} +1 -1
  13. package/dist/chunks/{chunk-2GV3QBBZ.js → chunk-MSX2J653.js} +1 -1
  14. package/dist/chunks/{chunk-YPK2W34Z.js → chunk-NVTC3XOA.js} +1 -1
  15. package/dist/chunks/{chunk-XIF53VR3.js → chunk-NWQTF6O4.js} +1 -1
  16. package/dist/chunks/{chunk-RLQGMSW7.js → chunk-NWVIUBJ3.js} +2 -2
  17. package/dist/chunks/{chunk-S3VA47DG.js → chunk-TYYR7KWY.js} +3 -3
  18. package/dist/chunks/{chunk-LUA5QGQP.js → chunk-YLULZMWE.js} +33 -33
  19. package/dist/chunks/{chunk-2I5TZW66.js → chunk-YRFQKUZD.js} +40 -1
  20. package/dist/chunks/{cli-3AEIYSMD.js → cli-4JA3SIDE.js} +6 -6
  21. package/dist/chunks/{cli-HUVI6ELM.js → cli-RJHEE4FA.js} +4 -4
  22. package/dist/chunks/{core-commands-2HUTKFHQ.js → core-commands-CQSPCVC4.js} +4 -4
  23. package/dist/chunks/{extend-PAJMXYKV.js → extend-4MZ75SHV.js} +9 -9
  24. package/dist/chunks/{harness-UWAS2VAN.js → harness-YVZU42S7.js} +3 -3
  25. package/dist/chunks/{help-M7D2XAOX.js → help-6SULYXVS.js} +1 -1
  26. package/dist/chunks/{opchat-FQ2CJVM6.js → opchat-XGS4AXHA.js} +5 -5
  27. package/dist/chunks/{organizations-L5N6LJ7O.js → organizations-4GFQ3NT2.js} +4 -4
  28. package/dist/chunks/{profile-KH5IKVNY.js → profile-VWMBIHIE.js} +7 -7
  29. package/dist/chunks/{project-agent-F4NHVRGY.js → project-agent-SQ6ODALG.js} +6 -6
  30. package/dist/chunks/{sandbox-command-DDXRQNB6.js → sandbox-command-34S2V7BN.js} +4 -4
  31. package/dist/chunks/{sandbox-template-5EEEQKR5.js → sandbox-template-VP5HMGQI.js} +5 -5
  32. package/dist/chunks/{src-34FV42HE.js → src-X3R3XIJT.js} +403 -28
  33. package/dist/chunks/{src-LHZWUSD7.js → src-YHUMH6W6.js} +2 -2
  34. package/dist/chunks/{teams-bot-HFWO5GOV.js → teams-bot-EIVRNO5S.js} +3 -3
  35. package/dist/chunks/{workspaces-LO44JAC2.js → workspaces-2N52V3BI.js} +2 -2
  36. package/dist/cli.js +10 -10
  37. package/dist/web/assets/{AppDialog-T3j6O3yg.js → AppDialog-j4N-gIi3.js} +1 -1
  38. package/dist/web/assets/{AppsView-70Qqf9eJ.js → AppsView-YiK3pqNb.js} +1 -1
  39. package/dist/web/assets/{BrowserSidebar-CdBLHdNW.js → BrowserSidebar-BWFLEQ8j.js} +1 -1
  40. package/dist/web/assets/{CloudWorkView-C5-jvlOo.js → CloudWorkView-3sS_1bhN.js} +1 -1
  41. package/dist/web/assets/CommandMenu-B11OrTCq.js +1 -0
  42. package/dist/web/assets/{CommunityView-BHUJ9Hun.js → CommunityView-DXyXTWhP.js} +1 -1
  43. package/dist/web/assets/ComposerCreateImproveStrip-3NoRiJJq.js +1 -0
  44. package/dist/web/assets/{GetStartedView-CIXScviw.js → GetStartedView-CPV5lgVH.js} +1 -1
  45. package/dist/web/assets/LabsRoute-B_nsEZXy.js +3 -0
  46. package/dist/web/assets/LabsRoute-dNN-odU0.css +1 -0
  47. package/dist/web/assets/MainChatThread-Dg7p3R2O.js +2 -0
  48. package/dist/web/assets/{MakeAgentTutorialLearningPanel-r7jyZVc0.js → MakeAgentTutorialLearningPanel-C6F-kJQd.js} +2 -2
  49. package/dist/web/assets/{MarkdownText-E35C404I.js → MarkdownText-CkVkr3P1.js} +3 -3
  50. package/dist/web/assets/Messages-C7uHGoFw.js +10 -0
  51. package/dist/web/assets/{NativeSkillSidebar-Qgccncuc.js → NativeSkillSidebar-BPpoHjEW.js} +1 -1
  52. package/dist/web/assets/{NewProjectDialog-BowacUmA.js → NewProjectDialog-DBMhkTvD.js} +1 -1
  53. package/dist/web/assets/{PostTrainingLearningPanel-oJu5qaHK.js → PostTrainingLearningPanel-B1Rp7iIL.js} +2 -2
  54. package/dist/web/assets/{PostTrainingStatusPill-B9Eoc4s0.js → PostTrainingStatusPill-BGZ9h5eW.js} +1 -1
  55. package/dist/web/assets/{ProfileSettingsSection-Dnh92gDH.js → ProfileSettingsSection-2NOHEz2b.js} +1 -1
  56. package/dist/web/assets/RightChatPanelStack-CLK7_zKe.js +1 -0
  57. package/dist/web/assets/{SettingsView-Bjehxwt1.js → SettingsView-BAqea_KX.js} +4 -4
  58. package/dist/web/assets/{TeamChatView-Tn4X5cuY.js → TeamChatView-qVscSedQ.js} +2 -2
  59. package/dist/web/assets/{TerminalOverlay-DoX5LYzK.js → TerminalOverlay-Bkw7XqMy.js} +1 -1
  60. package/dist/web/assets/TrainingCreationPanel-COg1wvw8.js +1 -0
  61. package/dist/web/assets/{TrainingDraftPanel-Da6uGu9y.js → TrainingDraftPanel-BNK2znmI.js} +1 -1
  62. package/dist/web/assets/{UsageSettingsSection-DKky0p47.js → UsageSettingsSection-CUxBaohC.js} +1 -1
  63. package/dist/web/assets/WorkspaceDiffPanel-qfFj8IRq.js +14 -0
  64. package/dist/web/assets/{WorkspaceEnvironmentMenu-Ba4M8z1N.js → WorkspaceEnvironmentMenu-C0-mH7oF.js} +3 -3
  65. package/dist/web/assets/{WorkspaceGitDialogs-CSepNOb8.js → WorkspaceGitDialogs-VvC2px0X.js} +1 -1
  66. package/dist/web/assets/{WorkspaceMonacoEditor-LhFdzCRs.js → WorkspaceMonacoEditor-CUIwoHv1.js} +3 -3
  67. package/dist/web/assets/{activity-bW02ZsBD.js → activity-BhqHgkfJ.js} +1 -1
  68. package/dist/web/assets/{boxes-B1dRA1pi.js → boxes-BpqUKFIm.js} +1 -1
  69. package/dist/web/assets/{chevron-up-CySy6WNq.js → chevron-up-BTn9DVRP.js} +1 -1
  70. package/dist/web/assets/{circle-x-DY8vKAKi.js → circle-x-B9Qa8o5a.js} +1 -1
  71. package/dist/web/assets/{copy-DuHI1UZ_.js → copy-BsYs6wBI.js} +1 -1
  72. package/dist/web/assets/{create-pipeline-request-CGBcdK9r.js → create-pipeline-request-vxgKoAvv.js} +3 -3
  73. package/dist/web/assets/{credit-card-Bot0OuTl.js → credit-card-BCePAwMI.js} +1 -1
  74. package/dist/web/assets/{cssMode-BIjAothW.js → cssMode-mw8RI2fR.js} +1 -1
  75. package/dist/web/assets/{git-branch-Cm02aNWq.js → git-branch-C7qQYFIs.js} +1 -1
  76. package/dist/web/assets/{git-commit-horizontal-FYILXW0v.js → git-commit-horizontal-CbX4pTOA.js} +1 -1
  77. package/dist/web/assets/{htmlMode-zO2xLLgL.js → htmlMode-Cc4Czh_M.js} +1 -1
  78. package/dist/web/assets/index-9tbdqUau.css +1 -0
  79. package/dist/web/assets/index-B_3z_lxq.js +1 -0
  80. package/dist/web/assets/index-Cr_RZ7GD.js +177 -0
  81. package/dist/web/assets/{info-DeuEU_RO.js → info-BNGbwgtq.js} +1 -1
  82. package/dist/web/assets/{jsonMode-D2A3mj4n.js → jsonMode-CbqbqGVz.js} +1 -1
  83. package/dist/web/assets/{lspLanguageFeatures-aPSqvscU.js → lspLanguageFeatures-DKiKr5tH.js} +1 -1
  84. package/dist/web/assets/make-agent-tutorial-KKauJpB9.js +2 -0
  85. package/dist/web/assets/{monaco.contribution-KqCt1n9-.js → monaco.contribution-CNgwz_pw.js} +2 -2
  86. package/dist/web/assets/{monaco.contribution-DAq6Jihl.js → monaco.contribution-CdUAX47Q.js} +2 -2
  87. package/dist/web/assets/{monaco.contribution-Do3Jjslo.js → monaco.contribution-D_-wu578.js} +2 -2
  88. package/dist/web/assets/{monaco.contribution-CHVe9CQ9.js → monaco.contribution-Dxc4IxFM.js} +2 -2
  89. package/dist/web/assets/{monitor-DXvHWFeW.js → monitor-CNdx_GTg.js} +1 -1
  90. package/dist/web/assets/{play-BIHyH-Yu.js → play-BLRANWaV.js} +1 -1
  91. package/dist/web/assets/{python-g3mtmU2J.js → python-DYgDMu2R.js} +1 -1
  92. package/dist/web/assets/{refresh-cw-Daz0oqwK.js → refresh-cw-BFjjwYNf.js} +1 -1
  93. package/dist/web/assets/{reply-wu9DIBuK.js → reply-D012cuZl.js} +1 -1
  94. package/dist/web/assets/{rotate-cw-D7q9GgNc.js → rotate-cw-CTfjlR4G.js} +1 -1
  95. package/dist/web/assets/{save-BVFY6VTI.js → save-B1zYlRyN.js} +1 -1
  96. package/dist/web/assets/{toggleHighContrast-D9C_WUDu.js → toggleHighContrast-D9XFH7EA.js} +1 -1
  97. package/dist/web/assets/{training-1du5QD-P.css → training-BN8CALIc.css} +1 -1
  98. package/dist/web/assets/{tsMode-B4lEUN5X.js → tsMode-BU-tuKsY.js} +1 -1
  99. package/dist/web/assets/{upload-DNbYB4Rl.js → upload-DU_81jvL.js} +1 -1
  100. package/dist/web/assets/{wifi-off-C5QLifIJ.js → wifi-off-TPsBnbGW.js} +1 -1
  101. package/dist/web/assets/{workers-CV4BZb_x.js → workers-NhWySRdT.js} +1 -1
  102. package/dist/web/assets/{yaml-3ah8oX43.js → yaml-DWXa_3ZL.js} +1 -1
  103. package/dist/web/index.html +2 -2
  104. package/package.json +1 -1
  105. package/dist/web/assets/CommandMenu-B3Y4MvmT.js +0 -1
  106. package/dist/web/assets/ComposerCreateImproveStrip-DeRI5XEO.js +0 -1
  107. package/dist/web/assets/LabsRoute-CgKtVYTP.css +0 -1
  108. package/dist/web/assets/LabsRoute-Cs_R1fuu.js +0 -3
  109. package/dist/web/assets/MainChatThread-h7VSA_Rc.js +0 -2
  110. package/dist/web/assets/Messages-BANZuAnA.js +0 -10
  111. package/dist/web/assets/RightChatPanelStack-pGwbt6Wy.js +0 -1
  112. package/dist/web/assets/TrainingCreationPanel-BLSf1Bnp.js +0 -1
  113. package/dist/web/assets/WorkspaceDiffPanel-DTRtW9n8.js +0 -14
  114. package/dist/web/assets/circle-alert-DMHz5tj_.js +0 -1
  115. package/dist/web/assets/index-B5AN29EO.js +0 -177
  116. package/dist/web/assets/index-BnwYyUgT.js +0 -1
  117. package/dist/web/assets/index-COGlKIJ4.css +0 -1
  118. package/dist/web/assets/make-agent-tutorial-A2W9Ajwv.js +0 -2
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-DKky0p47.js","./index-B5AN29EO.js","./index-COGlKIJ4.css","./activity-bW02ZsBD.js","./index-BnwYyUgT.js","./UsageSettingsSection-O8VK0qBL.css"])))=>i.map(i=>d[i]);
2
- import{d as de,j as e,r as i,u as ys,X as Le,e as Gs,o as Ws,f as qs,g as Vs,h as Ks,p as Hs,D as Ce,E as Js,k as He,l as Ys,m as Zs,n as E,q as Xs,s as qe,t as Ns,v as Qs,w as et,L as st,x as tt,y as Je,z as ke,A as ye,B as Ee,G as nt,H as at,I as lt,J as it,K as re,N as rt,O as Ve,Q as Ss,T as es,R as ot,M as ct,U as dt,V as ut,W as ws,Y as mt,Z as ht,_ as ss,a as gt,$ as pt,a0 as ft,a1 as xt,a2 as vt,a3 as jt,a4 as oe,a5 as ts,a6 as Oe,a7 as Me,a8 as bt,a9 as yt,aa as Nt,ab as St,ac as wt,ad as Ct}from"./index-B5AN29EO.js";import{R as kt,P as Pt}from"./ProfileSettingsSection-Dnh92gDH.js";import{R as he}from"./refresh-cw-Daz0oqwK.js";/* empty css */import{S as Ye}from"./save-BVFY6VTI.js";import{C as Rt}from"./chevron-up-CySy6WNq.js";import{C as Cs}from"./circle-alert-DMHz5tj_.js";import{P as Mt}from"./play-BIHyH-Yu.js";import{R as It}from"./rotate-cw-D7q9GgNc.js";import{B as ks,W as Dt,S as ns}from"./wifi-off-C5QLifIJ.js";import{C as Ps}from"./credit-card-Bot0OuTl.js";import{M as At}from"./monitor-DXvHWFeW.js";import{r as Tt}from"./index-BnwYyUgT.js";import{C as Rs}from"./copy-DuHI1UZ_.js";import"./git-commit-horizontal-FYILXW0v.js";const Et=[["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"}]],Ot=de("clipboard-copy",Et);const Lt=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Ut=de("code-xml",Lt);const $t=[["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"}]],Bt=de("hard-drive",$t);const zt=[["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"}]],le=de("key-round",zt);const _t=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Ft=de("power",_t);const Gt=[["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"}]],Ms=de("radio-tower",Gt);const Wt=[["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"}]],Is=de("sliders-horizontal",Wt);const qt=[["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"}]],Vt=de("circle-user",qt);function as({handle:s,image:t}){const a=s?.trim().slice(0,1).toUpperCase()||"+";return e.jsx("div",{className:"account-avatar",children:t?e.jsx("img",{src:t,alt:""}):e.jsx("span",{children:a})})}function Ae({state:s,label:t}){return e.jsx("span",{className:`account-state ${s}`,children:t??s.replace("_"," ")})}function Kt(s,t){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:t?.handle,currentBaseUrl:t?.baseUrl??null}}function ls(s,t){const a=t.trim().replace(/\/+$/,"");if(!a)throw new Error(`${s} is required.`);try{const n=new URL(a);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("unsupported protocol")}catch{throw new Error(`${s} must be an absolute http or https URL.`)}return a}function is({account:s,busy:t,initialApiKey:a="",mode:n="update",onClose:l,onSave:o}){const m=i.useId(),r=n==="connect",[j,v]=i.useState(a),[b,x]=i.useState(s?.baseUrl??""),[f,h]=i.useState(s?.apiBaseUrl??""),[c,u]=i.useState(null),[g,S]=i.useState(null);ys(g),i.useEffect(()=>{v(a),x(s?.baseUrl??""),h(s?.apiBaseUrl??""),u(null),S(null)},[s?.apiBaseUrl,s?.baseUrl,s?.handle,a]);async function d(y){y.preventDefault(),u(null),S(null);const R=j.trim();if(r&&!R){u("API key is required.");return}let N,w;try{N=ls("Base URL",b),w=ls("API base URL",f)}catch(I){u(I instanceof Error?I.message:String(I));return}try{const I=Kt(n,s);await o({...I,baseUrl:N,apiBaseUrl:w,apiKey:r?R:void 0,environment:s?.environment??null})}catch(I){S(I instanceof Error?I.message:String(I))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&!t&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":m,onSubmit:y=>{d(y)},children:[e.jsx("button",{className:"git-dialog-close",disabled:t,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(Le,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:r?e.jsx(le,{size:18}):e.jsx(Is,{size:18})}),e.jsx("h2",{id:m,children:r?"Environment account":"Environment endpoints"}),r?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoFocus:!0,disabled:t,placeholder:"opk_...",type:"password",value:j,onChange:y=>v(y.target.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{autoFocus:!r,disabled:t,inputMode:"url",value:b,onChange:y=>x(y.target.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API base URL"}),e.jsx("input",{disabled:t,inputMode:"url",value:f,onChange:y=>h(y.target.value)})]}),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",disabled:t,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:t,type:"submit",children:[e.jsx(Ye,{size:14}),e.jsx("span",{children:t?"Saving":r?"Connect account":"Update account"})]})]})]})})}const Fe="https://openpond.ai/settings/api-keys",Ht="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 Jt({payload:s,connection:t,apiKey:a,saving:n,refreshingAccounts:l,setApiKey:o,saveAccount:m,saveEnvironmentAccount:r,refreshAccounts:j,switchAccount:v,onPayload:b,onPreferences:x,onError:f,onToast:h}){const c=s?.account,u=c?.state??"loading",g=u==="signed_in",S=u==="signed_out",d=u==="auth_error",y=c?.email?.trim()||null,R=c?.accounts??[],[N,w]=i.useState([]),[,I]=i.useState(!1),[z,T]=i.useState(null),[P,p]=i.useState(null),[C,O]=i.useState(null),[L,G]=i.useState(null),[q,$]=i.useState(!1),[M,V]=i.useState(!1),[X,K]=i.useState(null),{confirmAction:ee,confirmDialog:te,resolveConfirmDialog:F}=Gs(),D=R.find(k=>k.isActive)??R[0]??null,H=s?.preferences.defaultTeamId?.trim()||null,ne=C??H,ae=Ws(c),ge=s?.accountMeta.asOf??"",pe=Ie(c?.environment,D?.environment),ue=g?Ie(D?.displayLabel,D?.handle,c?.label,c?.activeProfile?.handle,"Signed in"):d?"Account needs attention":S?"No account connected":"Loading account",fe=g?y??rs(pe):d?c?.error??"Reconnect this account to restore OpenPond cloud features.":S?"Cloud projects, hosted agents, wallet, and team defaults are disabled until you sign in.":"Checking account status.",xe=R.length>0,ve=S?"Sign in to OpenPond":d?"Reconnect account":"Add or update account",J=S?"Paste an OpenPond API key to connect this desktop app.":d?"Paste a fresh OpenPond API key for the active account.":"Saved to OpenPond CLI config.",je=S?"Sign in":d?"Reconnect":"Save account",B=i.useMemo(()=>N.filter(k=>k.status==="active"),[N]),Ue=(i.useMemo(()=>ne?B.find(k=>k.teamId===ne)??null:null,[B,ne])??qs(B))?.teamId??"",Ne=i.useMemo(()=>B.map(k=>({value:k.teamId,label:Ie(k.displayName,k.name,k.slug,"Team"),description:Vs(k.role)})),[B]),$e=Ue||Ne[0]?.value||"",Be=Ne.length>0,ze=!t||!!P||!!z||B.length===0,Pe=L?Ge(L):null,Re=!!(Pe&&X===Pe),A=Yt(D?.baseUrl??c?.baseUrl),U=g||d;i.useEffect(()=>{if(!t||!ae){w([]),T(null),I(!1);return}let k=!1;const Q=Ks(ae);return Q?(w(Q),I(!1)):(w([]),I(!0)),T(null),Hs({accountKey:ae,force:!!ge,fetchOrganizations:async()=>(await E.organizations(t)).organizations.map(Xs).filter(Z=>!!Z).filter(Z=>Z.status==="active")}).then(W=>{k||w(W)}).catch(W=>{k||(Q||w([]),T(W instanceof Error?W.message:String(W)))}).finally(()=>{k||I(!1)}),()=>{k=!0}},[ge,t,ae]),i.useEffect(()=>{C&&H===C&&O(null)},[H,C]);async function _(k,Q={notify:!0}){const W=B.find(Z=>Z.teamId===k)??null;if(!(!t||!W||P||(C??H)===W.teamId)){O(W.teamId),p(W.teamId),f(null),Zs({teamId:W.teamId,accountKey:ae,force:!0,fetchAgents:async Z=>(await E.listSandboxAgents(t,{teamId:Z})).agents}).catch(()=>{});try{x(await E.savePreferences(t,{defaultTeamId:W.teamId})),Q.notify&&h?.("Default team updated","success")}catch(Z){O(null),f(Z instanceof Error?Z.message:String(Z))}finally{p(null)}}}async function se(k="Continue"){return U?ee({title:"Change active OpenPond account?",body:Ht,confirmLabel:k,cancelLabel:"Cancel"}):!0}async function be(k){if(k.preventDefault(),q){V(!0);return}await se(je)&&await m(k)}async function Bs(k){await se("Save account")&&(await r({apiKey:k.apiKey??"",handle:k.handle,baseUrl:k.baseUrl,apiBaseUrl:k.apiBaseUrl,environment:os(k.environment)}),V(!1),$(!1))}async function zs(k){if(!t||!L)throw new Error("OpenPond server connection is not ready.");if(L.isActive&&!await se("Save endpoints"))return;const Q=Ge(L);K(Q),f(null);try{const W=await E.updateOpenPondAccountConfig(t,{handle:k.handle??L.handle,currentBaseUrl:k.currentBaseUrl,baseUrl:k.baseUrl,apiBaseUrl:k.apiBaseUrl,chatApiBaseUrl:null,environment:os(k.environment),setActive:L.isActive});b(W),h?.("Account endpoints updated","success"),G(null)}catch(W){throw f(W instanceof Error?W.message:String(W)),W}finally{K(null)}}async function _s(k){const Q=k.handle?.trim()||"";Q&&await se("Switch account")&&await v(Q,k.baseUrl)}return e.jsxs("section",{className:"account-settings",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsx("h1",{children:"Account"}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!t||n||l,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{j()},children:e.jsx(he,{size:15,className:l?"settings-spin":void 0})})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(as,{handle:ue,image:g?c?.avatarUrl??D?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:ue}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:g&&y?"private-account-email":g?void 0:"account-summary-copy",tabIndex:g&&y?0:void 0,children:fe}),g&&Be?e.jsx(Ce,{className:"account-team-dropdown",compact:!0,disabled:ze,label:"Default team",options:Ne,value:$e,onChange:k=>{_(k)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(Ae,{state:u,label:S?"not signed in":void 0})})]}),e.jsxs("form",{className:"account-login-form",onSubmit:k=>{be(k)},children:[S||d?e.jsxs("div",{className:"account-signin-panel",children:[e.jsx(le,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:S?"Connect this app to your OpenPond account":"Refresh the saved OpenPond credential"}),e.jsx("span",{children:S?"Local projects stay available without sign-in; cloud agents, wallet, teams, and hosted runs need an account.":"The saved credential could not authenticate. Replace it to resume cloud features."})]}),e.jsxs("a",{className:"settings-secondary account-api-key-link",href:A,rel:"noreferrer",target:"_blank",children:[e.jsx(Js,{size:14}),e.jsx("span",{children:"Create key"})]})]}):null,e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:ve}),e.jsx("small",{children:J})]}),e.jsxs("div",{className:"account-form-grid",children:[e.jsxs("label",{children:[e.jsx("span",{children:"API key"}),e.jsx("input",{value:a,onChange:k=>o(k.target.value),placeholder:"opk_...",type:"password"})]}),e.jsxs("div",{className:"account-environment-field",children:[e.jsx("span",{children:"Environment"}),e.jsxs("button",{className:`account-env-toggle account-form-env-toggle ${q?"active":""}`,disabled:n,type:"button","aria-pressed":q,onClick:()=>$(k=>!k),children:[e.jsx("span",{className:"account-env-toggle-switch","aria-hidden":"true"}),e.jsx("span",{children:"Environment"})]})]})]}),e.jsxs("button",{className:"settings-primary",disabled:n||!q&&!a.trim(),children:[e.jsx(He,{size:15}),e.jsx("span",{children:n?"Saving":je})]})]}),xe?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:[R.length," account",R.length===1?"":"s"]})]}),R.map(k=>{const Q=k.handle?.trim()||"",W=Ie(k.displayLabel,k.handle,"Unknown account"),Z=k.email?.trim()||null,_e=Zt(k.environment),Fs=Ge(k);return e.jsxs("div",{className:"account-row",children:[e.jsx(as,{handle:W,image:k.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:W}),Z?e.jsx("span",{className:"private-account-email",tabIndex:0,children:Z}):null,e.jsx("span",{children:rs(k.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsxs("button",{className:`account-env-toggle ${_e?"active":""}`,disabled:!t||n||!!X||!Q,type:"button","aria-pressed":_e,title:"Configure environment endpoints",onClick:()=>G(k),children:[e.jsx("span",{className:"account-env-toggle-switch","aria-hidden":"true"}),e.jsx("span",{children:"Environment"})]}),k.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):e.jsx("button",{className:"inline-action",disabled:n||!Q,type:"button",onClick:()=>{_s(k)},children:"Use"})]}),e.jsx(Ae,{state:k.authHealth})]},Fs)})]}):null,c?.products&&c.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:[c.products.length," active"]})]}),c.products.map(k=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:k.name}),e.jsx("span",{children:k.type})]}),e.jsx(Ae,{state:k.status})]},k.id))]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:s?.server.runtimeVersion??"Runtime loading"}),e.jsx("strong",{children:t?.serverUrl??"loading"})]}),s?.appsMeta.lastRefreshError&&e.jsxs("div",{className:"settings-footnote warning",children:[e.jsx("span",{children:"Last refresh error"}),e.jsx("strong",{children:s.appsMeta.lastRefreshError})]}),L?e.jsx(is,{account:L,busy:Re,onClose:()=>{Re||G(null)},onSave:zs}):null,M?e.jsx(is,{account:D,busy:n,initialApiKey:a,mode:"connect",onClose:()=>{n||V(!1)},onSave:Bs}):null,e.jsx(Ys,{state:te,onResolve:F})]})}function Ge(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function Ie(...s){for(const t of s){const a=t?.trim();if(a)return a}return""}function rs(s){const t=s.trim().toLowerCase();return!t||t==="production"?"Production":"Environment"}function Yt(s){const t=s?.trim().replace(/\/+$/,"");if(!t)return Fe;try{const a=new URL(t);return a.protocol!=="http:"&&a.protocol!=="https:"?Fe:`${t}/settings/api-keys`}catch{return Fe}}function os(s){const t=s?.trim();return!t||t.toLowerCase()==="production"?"custom":t}function Zt(s){const t=s?.trim().toLowerCase();return!!(t&&t!=="production")}function Xt({advancedWorkspaceControls:s,defaultBranchPrefix:t,defaultNewProjectDirectory:a,preferences:n,saving:l,chooseDefaultProjectDirectory:o,saveDefaults:m,setAdvancedWorkspaceControls:r,setDefaultBranchPrefix:j,setDefaultNewProjectDirectory:v}){const b=qe(t)===n.defaultBranchPrefix&&a.trim()===n.defaultNewProjectDirectory&&s===n.advancedWorkspaceControls;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Defaults"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:x=>{m(x)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:x=>r(x.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:t,disabled:l,placeholder:"feat/",onChange:x=>j(x.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:x=>v(x.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{o()},children:[e.jsx(Ns,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||b,children:e.jsx("span",{children:l?"Saving":"Save defaults"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[qe(t),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||n.defaultNewProjectDirectory})]})]})}function Qt({diagnostics:s,diagnosticsAvailable:t,diagnosticsBusy:a,diagnosticsStatus:n,logDir:l,logLineLimit:o,logLines:m,logViewBusy:r,logViewSummary:j,logViewportRef:v,tailLogs:b,copyRecentLogs:x,exportDiagnosticsBundle:f,loadOlderLogs:h,openLogsFolder:c,refreshLogView:u,toggleTailLogs:g}){const S=s.filter(y=>y.name==="diagnostic"&&y.status==="failed").slice().reverse().map(en),d=typeof window>"u"?void 0:window.openpond;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Diagnostics"}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Recent errors"}),e.jsxs("small",{children:[S.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:S.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):S.map(y=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Cs,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:y.message}),e.jsx("time",{dateTime:y.timestamp,children:y.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:y.surface}),y.status?e.jsx("span",{children:y.status}):null,y.sequence?e.jsxs("span",{children:["#",y.sequence]}):null]}),y.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:y.detail})]}):null]})]},y.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:t?"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||!d?.openLogsFolder,onClick:()=>{c()},children:[e.jsx(Ns,{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||!d?.exportDiagnostics,onClick:()=>{f()},children:[e.jsx(Qs,{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||!d?.copyRecentLogs,onClick:()=>{x()},children:[e.jsx(Ot,{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:j}),e.jsx("button",{type:"button",className:`settings-icon-button ${b?"active":""}`,title:b?"Pause tail":"Tail logs","aria-label":b?"Pause tail":"Tail logs",disabled:!d?.readRecentLogs,onClick:g,children:b?e.jsx(et,{size:15}):e.jsx(Mt,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:r!==null||!d?.readRecentLogs,onClick:()=>{u(o,"refresh")},children:e.jsx(he,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:r!==null||!d?.readRecentLogs,onClick:h,children:[e.jsx(Rt,{size:15}),e.jsx("span",{children:r==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:v,className:"diagnostics-log-viewer",role:"log","aria-live":b?"polite":"off",children:m.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:r?"Loading logs":"No log lines"}):m.map((y,R)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:y.file}),e.jsx("code",{children:y.line})]},`${y.file}:${y.timestamp}:${y.index}:${R}`))}),l&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:l})]})]}),n&&e.jsxs("div",{className:`settings-footnote ${n.warning?"warning":""}`,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:n.value})]})]})}function en(s){const t=cs(s.data),a=cs(t.context),l=ce(t.stack)??ce(t.detail)??ce(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:tn(s.timestamp),message:sn(s,t),surface:ce(t.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function sn(s,t){return ce(s.error)??ce(s.output)??ce(t.message)??ce(t.error)??"Diagnostic event"}function tn(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function cs(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function ce(s){return typeof s=="string"&&s.trim()?s.trim():null}const ds=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function nn({editorPreferences:s,lspStatus:t,preferences:a,restarting:n,saving:l,statusLoading:o,refreshLspStatus:m,restartLanguageServers:r,saveEditorSettings:j,setEditorPreferences:v,setLanguageCustomCommand:b,setLanguageMode:x}){const f=JSON.stringify(s)!==JSON.stringify(a.editor),h=new Map(t?.languages.map(c=>[c.language,c])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:c=>{j(c)},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(Ce,{value:s.languageServers,disabled:l,label:"Language servers",options:st,onChange:c=>v(u=>({...u,languageServers:c}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:c=>v(u=>({...u,diagnosticsWhileEditing:c.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:c=>v(u=>({...u,checkOnSave:c.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:ds.map(c=>{const u=s.languages[c.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:c.label}),e.jsx("span",{children:us(h.get(c.id),o)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Ce,{value:u.mode,disabled:l||s.languageServers==="off",label:`${c.label} language server mode`,options:tt,onChange:g=>x(c.id,g)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:u.customCommand,disabled:l||s.languageServers==="off"||u.mode!=="custom",placeholder:c.placeholder,onChange:g=>b(c.id,g.target.value)})]})]},c.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!f,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:o?"Checking":t?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:o||n,onClick:()=>{m()},children:e.jsx(he,{className:o?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:o||n,onClick:()=>{r()},children:[e.jsx(It,{className:n?"settings-spin":void 0,size:15}),e.jsx("span",{children:n?"Restarting":"Restart"})]})]})]}),ds.map(c=>{const u=h.get(c.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:c.label}),e.jsx("span",{title:u?.command??u?.message??void 0,children:u?.command??u?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${u?.status??"missing"}`,children:us(u,o)})]},c.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 us(s,t){return t&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function an({goalStorageLocation:s,preferences:t,saving:a,saveDefaults:n,setGoalStorageLocation:l}){return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Goals"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:o=>{n(o)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Storage"}),e.jsx("small",{children:"Controls where local goal state, plans, and artifacts are written"})]}),e.jsxs("div",{className:"settings-radio-group",children:[e.jsxs("label",{className:"settings-radio-row",children:[e.jsx("input",{type:"radio",name:"goal-storage-location",checked:s==="global",disabled:a,onChange:()=>l("global")}),e.jsxs("span",{children:[e.jsx("strong",{children:"User home"}),e.jsx("small",{children:"Store goal files under ~/.openpond/goals."})]})]}),e.jsxs("label",{className:"settings-radio-row",children:[e.jsx("input",{type:"radio",name:"goal-storage-location",checked:s==="workspace",disabled:a,onChange:()=>l("workspace")}),e.jsxs("span",{children:[e.jsx("strong",{children:"Working directory"}),e.jsx("small",{children:"Store goal files in the current workspace under .openpond/goals."})]})]})]}),e.jsx("button",{className:"settings-primary",disabled:a||s===t.goalStorageLocation,children:e.jsx("span",{children:a?"Saving":"Save goals"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Goal storage"}),e.jsx("strong",{children:s==="global"?"~/.openpond/goals":".openpond/goals in the working directory"})]})]})}function ln({contextCompactionAutoEnabled:s,preferences:t,saving:a,saveDefaults:n,setContextCompactionAutoEnabled:l}){return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:o=>{n(o)},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:a,onChange:o=>l(o.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:a||s===t.contextCompaction.autoEnabled,children:e.jsx("span",{children:a?"Saving":"Save context"})})]})]})}function rn({insightsEnabled:s,insightsUseDefaultModel:t,insightsProvider:a,insightsModel:n,insightsEvidenceSources:l,preferences:o,providers:m,saving:r,saveDefaults:j,changeInsightsProvider:v,setInsightsEnabled:b,setInsightsUseDefaultModel:x,setInsightsModel:f,setInsightsEvidenceSourceEnabled:h}){const c=Je(m,{enabledOnly:!0}),u=ke(a,m),g="settings-insights-model-options",S=s===o.insightsEnabled&&hn(l,o.insightsEvidenceSources)&&gn({useDefault:t,provider:a,model:n},o);return e.jsxs("section",{className:"account-settings insights-settings",children:[e.jsx("h1",{children:"Insights"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:d=>{j(d)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Background agent"}),e.jsx("small",{children:"Controls the background Insights agent"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:r,onChange:d=>b(d.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Run background Insights"}),e.jsx("small",{children:"Startup and interval scans run while the app is open."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:t,disabled:r,onChange:d=>x(d.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Use default chat model"}),e.jsxs("small",{children:[ye(o.defaultChatProvider,m)," /"," ",Ee(o.defaultChatModel,m,o.defaultChatProvider)]})]})]}),t?null:e.jsxs("div",{className:"provider-settings-grid two",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Insights provider"}),e.jsx("select",{value:a,disabled:r,onChange:d=>v(d.target.value),children:c.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:"Insights model"}),e.jsx("input",{value:n,disabled:r,list:g,onChange:d=>f(d.target.value)}),e.jsx("datalist",{id:g,children:u.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))})]})]}),e.jsx("div",{className:"settings-check-grid","aria-label":"Insights evidence sources",children:As.map(d=>e.jsxs("label",{className:"settings-check-row compact",children:[e.jsx("input",{type:"checkbox",checked:l[d.key],disabled:r,onChange:y=>h(d.key,y.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:d.label}),e.jsx("small",{children:d.description})]})]},d.key))}),e.jsx("button",{className:"settings-primary",disabled:r||S,children:e.jsx("span",{children:r?"Saving":"Save insights"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Insights model"}),e.jsx("strong",{children:t?"Default chat model":`${ye(a,m)} / ${n}`})]})]})}function on({subagentsEnabled:s,subagentDelegationMode:t,subagentsUseDefaultModel:a,subagentsProvider:n,subagentsModel:l,subagentRoles:o,subagentsMaxConcurrentRuns:m,subagentsMaxConcurrentRunsPerProvider:r,subagentsMaxConcurrentRunsPerWorkspaceTarget:j,preferences:v,providers:b,saving:x,saveDefaults:f,changeSubagentsProvider:h,setSubagentsEnabled:c,setSubagentDelegationMode:u,setSubagentsUseDefaultModel:g,setSubagentsModel:S,setSubagentsMaxConcurrentRuns:d,setSubagentsMaxConcurrentRunsPerProvider:y,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:R,setSubagentRoleEnabled:N,setSubagentRoleIsolationMode:w,setSubagentRoleMaxConcurrentRuns:I,setSubagentRoleModel:z,setSubagentRolePeerMessages:T,setSubagentRoleToolPolicy:P,changeSubagentRoleProvider:p}){const C=Je(b,{enabledOnly:!0}),O=a?v.defaultChatProvider:n,L=a?v.defaultChatModel:l,G=Ds(ke(O,b),L),q=a?null:{providerId:n,modelId:l.trim()},$=pn({enabled:s,delegationMode:t,defaultModelRef:q,roles:o,maxConcurrentRuns:m,maxConcurrentRunsPerProvider:r,maxConcurrentRunsPerWorkspaceTarget:j},v);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:M=>{f(M)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Subagents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${$?"":" dirty"}`,disabled:x||$,children:e.jsx("span",{children:x?"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:x,onChange:M=>c(M.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:t,disabled:x||!s,onChange:M=>u(M.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:O,disabled:x||!s,onChange:M=>{g(!1),h(M.target.value)},children:C.map(M=>e.jsx("option",{value:M.value,children:M.label},M.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:L,disabled:x||!s,onChange:M=>{g(!1),S(M.target.value)},children:G.map(M=>e.jsx("option",{value:M.value,children:M.label},M.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:o.map(M=>{const V=nt.find(D=>D.id===M.id),X=M.modelRef?.providerId??O,K=M.modelRef?.modelId||at(X,b)||L,ee=mn(C,b,{providerId:X,modelId:K}),te=Te(X,K),F=x||!s||!M.enabled;return e.jsxs("section",{className:`subagent-role-row${M.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:V?.label??M.id}),e.jsx("small",{children:V?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${V?.label??M.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:M.enabled,disabled:x||!s,onChange:D=>N(M.id,D.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:te,disabled:F,onChange:D=>{const H=ee.find(ne=>ne.value===D.target.value);H&&(p(M.id,H.providerId),z(M.id,H.modelId))},children:ee.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:"Isolation"}),e.jsx("select",{value:M.isolationMode,disabled:F,onChange:D=>w(M.id,D.target.value),children:cn.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:"Tools"}),e.jsx("select",{value:M.toolPolicy,disabled:F,onChange:D=>P(M.id,D.target.value),children:dn.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:"Peer messages"}),e.jsx("select",{value:M.peerMessages,disabled:F,onChange:D=>T(M.id,D.target.value),children:un.map(D=>e.jsx("option",{value:D.value,children:D.label},D.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:M.maxConcurrentRuns,disabled:F,onChange:D=>I(M.id,ms(D.target.value,1))})]})})]},M.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:m,disabled:x||!s,onChange:M=>d(ms(M.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:r??"",placeholder:"No cap",disabled:x||!s,onChange:M=>y(Ke(M.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:j??"",placeholder:"No cap",disabled:x||!s,onChange:M=>R(Ke(M.target.value))})]})]})]})]})})}const cn=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],dn=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],un=[{value:"goal_scoped",label:"Scoped handoffs"},{value:"disabled",label:"Disabled"}];function Ds(s,t){const a=t.trim();return!a||s.some(n=>n.value===a)?s:[{value:a,label:a},...s]}function Te(s,t){return JSON.stringify([s,t])}function mn(s,t,a){const n=[];for(const l of s){const o=Ds(ke(l.value,t),l.value===a.providerId?a.modelId:"");for(const m of o)n.push({value:Te(l.value,m.value),label:`${l.label} / ${m.label}`,providerId:l.value,modelId:m.value})}return a.modelId&&!n.some(l=>l.value===Te(a.providerId,a.modelId))&&n.unshift({value:Te(a.providerId,a.modelId),label:`${ye(a.providerId,t)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),n}const As=[{key:"createEdit",label:"Create/Improve",description:"Waiting, blocked, or failed Create/Improve runs."},{key:"stuckTurns",label:"Stuck turns",description:"Failed or long-running active turns."},{key:"toolFailures",label:"Tool failures",description:"Repeated tool or action failures."},{key:"abandonedGoals",label:"Abandoned goals",description:"Goal loops left active too long."},{key:"userCorrections",label:"Corrections",description:"Repeated correction-style prompts."},{key:"unresolvedConversations",label:"Unresolved chats",description:"Long chats with unresolved recent work."},{key:"usageAnomalies",label:"Usage",description:"Spikes, failures, missing usage, and latency changes."}];function hn(s,t){return As.every(a=>s[a.key]===t[a.key])}function gn(s,t){return s.useDefault?!t.insightsModelRef:t.insightsModelRef?.providerId===s.provider&&t.insightsModelRef?.modelId===s.model.trim()}function Ke(s){const t=s.trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function ms(s,t){return Ke(s)??t}function pn(s,t){const a=t.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&fn(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 fn(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const xn=[{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 vn({currentUserId:s,enabled:t,mode:a,threads:n,onModeChange:l,onThreadMuteChange:o}){const[m,r]=i.useState(null),[j,v]=i.useState(null);ys(j);const b=i.useMemo(()=>n.filter(h=>h.archivedAt===null).map(h=>({thread:h,label:jn(h,s)})).sort((h,c)=>{const u=+!!c.thread.mutedAt-+!!h.thread.mutedAt;return u!==0?u:h.label.localeCompare(c.label)}),[s,n]),x=b.filter(({thread:h})=>!!h.mutedAt).length,f=i.useCallback(async h=>{r(h.id),v(null),await o(h.id,!h.mutedAt)||v("Could not update this conversation. Try again."),r(null)},[o]);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:xn.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:x===1?"1 muted":`${x} muted`})]}),t?b.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):b.map(({thread:h,label:c})=>{const u=!!h.mutedAt,g=m===h.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${u?" muted":""}`,children:u?e.jsx(lt,{size:15}):e.jsx(ks,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:c}),e.jsx("small",{children:u?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:m!==null,onClick:()=>{f(h)},children:g?"Saving":u?"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 jn(s,t){return s.kind==="general"||s.kind==="channel"?`#${s.title?.trim()||"general"}`:s.kind==="dm"?s.participants.find(a=>a.userId!==t)?.name??s.title?.trim()??"Direct message":s.title?.trim()||s.participants.filter(a=>a.userId!==t).map(a=>a.name).join(", ")||"Group conversation"}function bn({canSaveCurrentTemplate:s,personalizationTemplateId:t,personalizationTemplateOptions:a,saveAsNewOpen:n,saving:l,selectedPersonalizationTemplate:o,selectedTemplateIsCustom:m,soulDraft:r,templateNameDraft:j,changePersonalizationTemplate:v,changeSoulDraft:b,openSaveAsNew:x,resetPersonalizationDraft:f,savePersonalization:h,setSaveAsNewOpen:c,setTemplateNameDraft:u}){function g(S){S.preventDefault(),h(n)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:g,children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agent style"}),e.jsx("div",{className:"settings-heading-actions",children:n?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"settings-heading-input",value:j,onChange:S=>u(S.target.value),placeholder:"Name","aria-label":"Template name"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Cancel","aria-label":"Cancel",disabled:l,onClick:()=>c(!1),children:e.jsx(Le,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!r.trim()||!j.trim(),onClick:()=>{h(!0)},children:e.jsx(it,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:m?"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||!o||!r.trim(),onClick:x,children:e.jsx(He,{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(Ce,{value:t,disabled:l||a.length===0,label:"Personalization template",options:a,onChange:S=>{v(S)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:r,onChange:S=>b(S.target.value),spellCheck:!1})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Reset to template","aria-label":"Reset to template",disabled:l||!o,onClick:f,children:e.jsx(kt,{size:15})}),m&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(Ye,{size:15})})]})]})]})}const yn=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],Nn=120,Sn=new Set(["openai","xai","zai"]),wn=new Set(["chatgpt-subscription"]),Cn="https://api.z.ai/api/coding/paas/v4";function hs(s){return s.split(/[\n,]/).map(t=>t.trim()).filter(Boolean)}function Ts(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 Es(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function gs(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 kn(s){return s?.trim().replace(/\/+$/,"")??""}function Os(s,t){return s.id==="zai"&&kn(t.providers.zai?.baseUrl)===Cn}function Pn(s,t){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":Os(s,t)?"Coding Plan key":"API key"}function Rn(s,t){const a=t.modelCaches[s.id];if(s.routing.localByok&&s.enabled&&!s.credential.connected||!s.enabled&&s.id!=="openpond")return"";const n=Math.max(a?.models.length??0,s.modelIds.length),l=s.defaultModel?Ee(s.defaultModel,t,s.id):"",o=n===1?"1 model":`${n} models`,m=Pn(s,t);return[Ts(s),m,a?o:"",l].filter(Boolean).join(" · ")}function Mn(s){return s!=="openpond"&&Ve(s)}function Ze(s){return s?Sn.has(s.id)||s.credentialModes.some(t=>wn.has(t)):!1}function In(s){return Ze(s)?["api","subscription"]:["api"]}function ps(s,t){return!s||!t||!Ze(s)?"api":s.credential.source==="chatgpt_subscription"||Os(s,t)?"subscription":"api"}function fs(s,t){const a=rt.filter(n=>!!s?.statuses[n]);return t?a.filter(n=>Ze(s?.statuses[n])):a}function Dn(s){if(!s)return"Never";const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString()}function An(s,t,a=Nn){const n=[],l=new Set,o=new Set(t.map(r=>r.trim()).filter(Boolean)),m=r=>{l.has(r.value)||n.length>=a||(l.add(r.value),n.push(r))};for(const r of s)o.has(r.value)&&m(r);for(const r of s)m(r);return n}function Tn({account:s,codex:t,providers:a,providerBusy:n,validationMessage:l,deleteProviderCredential:o,loadProviderModels:m,refreshProviderModels:r,saveProviderConfig:j,saveProviderCredential:v,startOpenAiSubscriptionAuth:b,validateProvider:x}){const[f,h]=i.useState(null),[c,u]=i.useState(!1),g=i.useMemo(()=>fs(a,!1),[a]),S=i.useMemo(()=>fs(a,c),[a,c]),d=f?a?.statuses[f]??null:null;function y(R,N){h(R),N&&m(R)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Providers"}),a?e.jsxs("div",{className:"provider-manager-panel",children:[e.jsxs("div",{className:"account-list-heading provider-manager-heading",children:[e.jsxs("div",{className:"provider-manager-title-row",children:[e.jsx("span",{children:"Model providers"}),e.jsxs("label",{className:"settings-check-row compact provider-subscription-filter",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:R=>u(R.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[S.length," of ",g.length," presets"]})]}),S.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:S.map(R=>{const N=a.statuses[R],w=a.modelCaches[R],I=N.modelIds.length>0&&(w?.models.length??0)<N.modelIds.length,z=n?.startsWith(`${R}:`)??!1,T=Mn(R),P=R==="openpond"||!!a.providers[R]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${N.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:P,disabled:!T||z,onChange:p=>{y(R,!1),j(R,{enabled:p.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:N.displayName})}),e.jsxs("div",{className:`provider-row-status ${Es(N)}`,children:[z?e.jsx(re,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:Rn(N,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{y(R,I)},children:"Details"})]},R)})}):e.jsxs("div",{className:"empty-account-list provider-manager-empty",children:[e.jsx("strong",{children:"No subscription providers"}),e.jsx("span",{children:"Turn off the filter to show API-key providers."})]})]}):null,l?e.jsxs("div",{className:"settings-footnote provider-validation-message",children:[e.jsx("span",{children:"Last validation"}),e.jsx("strong",{children:l})]}):null,f&&d&&a?e.jsx(En,{account:s,codex:t,providerId:f,providerBusy:n,settings:a,status:d,onClose:()=>h(null),onDeleteCredential:o,onRefreshModels:r,onSaveConfig:j,onSaveCredential:v,onStartOpenAiSubscriptionAuth:b,onValidate:x}):null]})}function En({account:s,codex:t,providerId:a,providerBusy:n,settings:l,status:o,onClose:m,onDeleteCredential:r,onRefreshModels:j,onSaveConfig:v,onSaveCredential:b,onStartOpenAiSubscriptionAuth:x,onValidate:f}){const h=l.providers[a],c=l.modelCaches[a],u=i.useId(),g=i.useRef(a),S=Math.max(c?.models.length??0,o.modelIds.length),d=o.routing.localByok&&Ve(a)&&a!=="codex",y=i.useMemo(()=>d?In(o):[],[d,o]),R=y.includes("subscription"),[N,w]=i.useState(()=>ps(o,l)),I=d&&N==="subscription"&&R,z=P=>`${u}-${P}-panel`,T=a==="codex"?"Codex app server":h?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return i.useEffect(()=>{if(g.current!==a){g.current=a,w(ps(o,l));return}d&&!y.includes(N)&&w("api")},[N,y,d,a,l,o]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:m,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${o.displayName} provider details`,onMouseDown:P=>P.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:m,children:e.jsx(Le,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:o.displayName}),e.jsx("span",{children:ye(a,l)})]}),e.jsx("div",{className:`provider-state-pill ${Es(o)}`,children:Ts(o)})]}),d?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${o.displayName} mode`,children:y.map(P=>e.jsx("button",{type:"button",role:"tab",id:`${u}-${P}`,className:N===P?"active":void 0,"aria-selected":N===P,"aria-controls":z(P),onClick:()=>w(P),children:P==="api"?"API":"Subscription"},P))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:gs(o),children:gs(o)})]}),I?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:T,children:T})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:h?.defaultModel??o.defaultModel??void 0,children:h?.defaultModel??o.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:c?.lastError??void 0,children:[S," cached · ",Dn(c?.fetchedAt)]})]})]}),a==="codex"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{title:t?.account?.email??void 0,children:t?.account?.label??t?.account?.email??"Not signed in"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Binary"}),e.jsx("dd",{title:t?.binaryPath??void 0,children:t?.binaryPath??"Not found"})]})]}):null,o.credential.lastError||c?.lastError||o.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:o.credential.lastError??c?.lastError??o.lastError??void 0,children:o.credential.lastError??c?.lastError??o.lastError})]}):null]}),a==="codex"?e.jsx(On,{providerBusy:n,status:o,onValidate:f}):d&&h&&c?e.jsx(Ln,{credentialTab:N,credentialTabsId:u,hasSubscriptionTab:R,providerId:a,providerBusy:n,settings:l,status:o,onDeleteCredential:r,onRefreshModels:j,onSaveConfig:v,onSaveCredential:b,onStartOpenAiSubscriptionAuth:x,onValidate:f}):o.routing.localByok&&!Ve(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Cs,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function On({providerBusy:s,status:t,onValidate:a}){const n=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(le,{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:n,onClick:()=>{a("codex",{modelId:t.defaultModel??void 0})},children:[n?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(Ss,{size:14}),e.jsx("span",{children:n?"Testing":"Test Codex login"})]})})]})}function Ln({credentialTab:s,credentialTabsId:t,hasSubscriptionTab:a,providerId:n,providerBusy:l,settings:o,status:m,onDeleteCredential:r,onRefreshModels:j,onSaveConfig:v,onSaveCredential:b,onStartOpenAiSubscriptionAuth:x,onValidate:f}){const h=o.providers[n],c=i.useMemo(()=>ke(n,o),[n,o]),u=`provider-models-${n}`,g=i.useRef(n),[S,d]=i.useState(h.baseUrl??""),[y,R]=i.useState(h.defaultModel??""),[N,w]=i.useState(h.modelOverrides.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-CUxBaohC.js","./index-Cr_RZ7GD.js","./index-9tbdqUau.css","./activity-BhqHgkfJ.js","./index-B_3z_lxq.js","./UsageSettingsSection-O8VK0qBL.css"])))=>i.map(i=>d[i]);
2
+ import{d as de,j as e,r as i,u as ys,X as Le,e as Gs,o as Ws,f as qs,g as Vs,h as Ks,p as Hs,D as Ce,E as Js,k as He,l as Ys,m as Zs,n as E,q as Xs,s as qe,t as Ns,v as Ss,w as Qs,x as et,L as st,y as tt,z as Je,A as ke,G as ye,H as Ee,I as nt,J as at,K as lt,N as it,O as re,Q as rt,R as Ve,T as ws,U as es,V as ot,M as ct,W as dt,Y as ut,Z as Cs,_ as mt,$ as ht,a0 as ss,a as gt,a1 as pt,a2 as ft,a3 as xt,a4 as vt,a5 as jt,a6 as oe,a7 as ts,a8 as Oe,a9 as Me,aa as bt,ab as yt,ac as Nt,ad as St,ae as wt,af as Ct}from"./index-Cr_RZ7GD.js";import{R as kt,P as Pt}from"./ProfileSettingsSection-2NOHEz2b.js";import{R as he}from"./refresh-cw-BFjjwYNf.js";/* empty css */import{S as Ye}from"./save-B1zYlRyN.js";import{C as Rt}from"./chevron-up-BTn9DVRP.js";import{P as Mt}from"./play-BLRANWaV.js";import{R as It}from"./rotate-cw-CTfjlR4G.js";import{B as ks,W as Dt,S as ns}from"./wifi-off-TPsBnbGW.js";import{C as Ps}from"./credit-card-BCePAwMI.js";import{M as At}from"./monitor-CNdx_GTg.js";import{r as Tt}from"./index-B_3z_lxq.js";import{C as Rs}from"./copy-BsYs6wBI.js";import"./git-commit-horizontal-CbX4pTOA.js";const Et=[["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"}]],Ot=de("clipboard-copy",Et);const Lt=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Ut=de("code-xml",Lt);const $t=[["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"}]],Bt=de("hard-drive",$t);const zt=[["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"}]],le=de("key-round",zt);const _t=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Ft=de("power",_t);const Gt=[["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"}]],Ms=de("radio-tower",Gt);const Wt=[["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"}]],Is=de("sliders-horizontal",Wt);const qt=[["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"}]],Vt=de("circle-user",qt);function as({handle:s,image:t}){const a=s?.trim().slice(0,1).toUpperCase()||"+";return e.jsx("div",{className:"account-avatar",children:t?e.jsx("img",{src:t,alt:""}):e.jsx("span",{children:a})})}function Ae({state:s,label:t}){return e.jsx("span",{className:`account-state ${s}`,children:t??s.replace("_"," ")})}function Kt(s,t){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:t?.handle,currentBaseUrl:t?.baseUrl??null}}function ls(s,t){const a=t.trim().replace(/\/+$/,"");if(!a)throw new Error(`${s} is required.`);try{const n=new URL(a);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("unsupported protocol")}catch{throw new Error(`${s} must be an absolute http or https URL.`)}return a}function is({account:s,busy:t,initialApiKey:a="",mode:n="update",onClose:l,onSave:o}){const m=i.useId(),r=n==="connect",[j,v]=i.useState(a),[b,x]=i.useState(s?.baseUrl??""),[f,h]=i.useState(s?.apiBaseUrl??""),[c,u]=i.useState(null),[g,S]=i.useState(null);ys(g),i.useEffect(()=>{v(a),x(s?.baseUrl??""),h(s?.apiBaseUrl??""),u(null),S(null)},[s?.apiBaseUrl,s?.baseUrl,s?.handle,a]);async function d(y){y.preventDefault(),u(null),S(null);const R=j.trim();if(r&&!R){u("API key is required.");return}let N,w;try{N=ls("Base URL",b),w=ls("API base URL",f)}catch(I){u(I instanceof Error?I.message:String(I));return}try{const I=Kt(n,s);await o({...I,baseUrl:N,apiBaseUrl:w,apiKey:r?R:void 0,environment:s?.environment??null})}catch(I){S(I instanceof Error?I.message:String(I))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&!t&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":m,onSubmit:y=>{d(y)},children:[e.jsx("button",{className:"git-dialog-close",disabled:t,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(Le,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:r?e.jsx(le,{size:18}):e.jsx(Is,{size:18})}),e.jsx("h2",{id:m,children:r?"Environment account":"Environment endpoints"}),r?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoFocus:!0,disabled:t,placeholder:"opk_...",type:"password",value:j,onChange:y=>v(y.target.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{autoFocus:!r,disabled:t,inputMode:"url",value:b,onChange:y=>x(y.target.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API base URL"}),e.jsx("input",{disabled:t,inputMode:"url",value:f,onChange:y=>h(y.target.value)})]}),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",disabled:t,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:t,type:"submit",children:[e.jsx(Ye,{size:14}),e.jsx("span",{children:t?"Saving":r?"Connect account":"Update account"})]})]})]})})}const Fe="https://openpond.ai/settings/api-keys",Ht="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 Jt({payload:s,connection:t,apiKey:a,saving:n,refreshingAccounts:l,setApiKey:o,saveAccount:m,saveEnvironmentAccount:r,refreshAccounts:j,switchAccount:v,onPayload:b,onPreferences:x,onError:f,onToast:h}){const c=s?.account,u=c?.state??"loading",g=u==="signed_in",S=u==="signed_out",d=u==="auth_error",y=c?.email?.trim()||null,R=c?.accounts??[],[N,w]=i.useState([]),[,I]=i.useState(!1),[z,T]=i.useState(null),[P,p]=i.useState(null),[C,O]=i.useState(null),[L,G]=i.useState(null),[q,$]=i.useState(!1),[M,V]=i.useState(!1),[X,K]=i.useState(null),{confirmAction:ee,confirmDialog:te,resolveConfirmDialog:F}=Gs(),D=R.find(k=>k.isActive)??R[0]??null,H=s?.preferences.defaultTeamId?.trim()||null,ne=C??H,ae=Ws(c),ge=s?.accountMeta.asOf??"",pe=Ie(c?.environment,D?.environment),ue=g?Ie(D?.displayLabel,D?.handle,c?.label,c?.activeProfile?.handle,"Signed in"):d?"Account needs attention":S?"No account connected":"Loading account",fe=g?y??rs(pe):d?c?.error??"Reconnect this account to restore OpenPond cloud features.":S?"Cloud projects, hosted agents, wallet, and team defaults are disabled until you sign in.":"Checking account status.",xe=R.length>0,ve=S?"Sign in to OpenPond":d?"Reconnect account":"Add or update account",J=S?"Paste an OpenPond API key to connect this desktop app.":d?"Paste a fresh OpenPond API key for the active account.":"Saved to OpenPond CLI config.",je=S?"Sign in":d?"Reconnect":"Save account",B=i.useMemo(()=>N.filter(k=>k.status==="active"),[N]),Ue=(i.useMemo(()=>ne?B.find(k=>k.teamId===ne)??null:null,[B,ne])??qs(B))?.teamId??"",Ne=i.useMemo(()=>B.map(k=>({value:k.teamId,label:Ie(k.displayName,k.name,k.slug,"Team"),description:Vs(k.role)})),[B]),$e=Ue||Ne[0]?.value||"",Be=Ne.length>0,ze=!t||!!P||!!z||B.length===0,Pe=L?Ge(L):null,Re=!!(Pe&&X===Pe),A=Yt(D?.baseUrl??c?.baseUrl),U=g||d;i.useEffect(()=>{if(!t||!ae){w([]),T(null),I(!1);return}let k=!1;const Q=Ks(ae);return Q?(w(Q),I(!1)):(w([]),I(!0)),T(null),Hs({accountKey:ae,force:!!ge,fetchOrganizations:async()=>(await E.organizations(t)).organizations.map(Xs).filter(Z=>!!Z).filter(Z=>Z.status==="active")}).then(W=>{k||w(W)}).catch(W=>{k||(Q||w([]),T(W instanceof Error?W.message:String(W)))}).finally(()=>{k||I(!1)}),()=>{k=!0}},[ge,t,ae]),i.useEffect(()=>{C&&H===C&&O(null)},[H,C]);async function _(k,Q={notify:!0}){const W=B.find(Z=>Z.teamId===k)??null;if(!(!t||!W||P||(C??H)===W.teamId)){O(W.teamId),p(W.teamId),f(null),Zs({teamId:W.teamId,accountKey:ae,force:!0,fetchAgents:async Z=>(await E.listSandboxAgents(t,{teamId:Z})).agents}).catch(()=>{});try{x(await E.savePreferences(t,{defaultTeamId:W.teamId})),Q.notify&&h?.("Default team updated","success")}catch(Z){O(null),f(Z instanceof Error?Z.message:String(Z))}finally{p(null)}}}async function se(k="Continue"){return U?ee({title:"Change active OpenPond account?",body:Ht,confirmLabel:k,cancelLabel:"Cancel"}):!0}async function be(k){if(k.preventDefault(),q){V(!0);return}await se(je)&&await m(k)}async function Bs(k){await se("Save account")&&(await r({apiKey:k.apiKey??"",handle:k.handle,baseUrl:k.baseUrl,apiBaseUrl:k.apiBaseUrl,environment:os(k.environment)}),V(!1),$(!1))}async function zs(k){if(!t||!L)throw new Error("OpenPond server connection is not ready.");if(L.isActive&&!await se("Save endpoints"))return;const Q=Ge(L);K(Q),f(null);try{const W=await E.updateOpenPondAccountConfig(t,{handle:k.handle??L.handle,currentBaseUrl:k.currentBaseUrl,baseUrl:k.baseUrl,apiBaseUrl:k.apiBaseUrl,chatApiBaseUrl:null,environment:os(k.environment),setActive:L.isActive});b(W),h?.("Account endpoints updated","success"),G(null)}catch(W){throw f(W instanceof Error?W.message:String(W)),W}finally{K(null)}}async function _s(k){const Q=k.handle?.trim()||"";Q&&await se("Switch account")&&await v(Q,k.baseUrl)}return e.jsxs("section",{className:"account-settings",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsx("h1",{children:"Account"}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!t||n||l,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{j()},children:e.jsx(he,{size:15,className:l?"settings-spin":void 0})})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(as,{handle:ue,image:g?c?.avatarUrl??D?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:ue}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:g&&y?"private-account-email":g?void 0:"account-summary-copy",tabIndex:g&&y?0:void 0,children:fe}),g&&Be?e.jsx(Ce,{className:"account-team-dropdown",compact:!0,disabled:ze,label:"Default team",options:Ne,value:$e,onChange:k=>{_(k)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(Ae,{state:u,label:S?"not signed in":void 0})})]}),e.jsxs("form",{className:"account-login-form",onSubmit:k=>{be(k)},children:[S||d?e.jsxs("div",{className:"account-signin-panel",children:[e.jsx(le,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:S?"Connect this app to your OpenPond account":"Refresh the saved OpenPond credential"}),e.jsx("span",{children:S?"Local projects stay available without sign-in; cloud agents, wallet, teams, and hosted runs need an account.":"The saved credential could not authenticate. Replace it to resume cloud features."})]}),e.jsxs("a",{className:"settings-secondary account-api-key-link",href:A,rel:"noreferrer",target:"_blank",children:[e.jsx(Js,{size:14}),e.jsx("span",{children:"Create key"})]})]}):null,e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:ve}),e.jsx("small",{children:J})]}),e.jsxs("div",{className:"account-form-grid",children:[e.jsxs("label",{children:[e.jsx("span",{children:"API key"}),e.jsx("input",{value:a,onChange:k=>o(k.target.value),placeholder:"opk_...",type:"password"})]}),e.jsxs("div",{className:"account-environment-field",children:[e.jsx("span",{children:"Environment"}),e.jsxs("button",{className:`account-env-toggle account-form-env-toggle ${q?"active":""}`,disabled:n,type:"button","aria-pressed":q,onClick:()=>$(k=>!k),children:[e.jsx("span",{className:"account-env-toggle-switch","aria-hidden":"true"}),e.jsx("span",{children:"Environment"})]})]})]}),e.jsxs("button",{className:"settings-primary",disabled:n||!q&&!a.trim(),children:[e.jsx(He,{size:15}),e.jsx("span",{children:n?"Saving":je})]})]}),xe?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:[R.length," account",R.length===1?"":"s"]})]}),R.map(k=>{const Q=k.handle?.trim()||"",W=Ie(k.displayLabel,k.handle,"Unknown account"),Z=k.email?.trim()||null,_e=Zt(k.environment),Fs=Ge(k);return e.jsxs("div",{className:"account-row",children:[e.jsx(as,{handle:W,image:k.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:W}),Z?e.jsx("span",{className:"private-account-email",tabIndex:0,children:Z}):null,e.jsx("span",{children:rs(k.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsxs("button",{className:`account-env-toggle ${_e?"active":""}`,disabled:!t||n||!!X||!Q,type:"button","aria-pressed":_e,title:"Configure environment endpoints",onClick:()=>G(k),children:[e.jsx("span",{className:"account-env-toggle-switch","aria-hidden":"true"}),e.jsx("span",{children:"Environment"})]}),k.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):e.jsx("button",{className:"inline-action",disabled:n||!Q,type:"button",onClick:()=>{_s(k)},children:"Use"})]}),e.jsx(Ae,{state:k.authHealth})]},Fs)})]}):null,c?.products&&c.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:[c.products.length," active"]})]}),c.products.map(k=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:k.name}),e.jsx("span",{children:k.type})]}),e.jsx(Ae,{state:k.status})]},k.id))]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:s?.server.runtimeVersion??"Runtime loading"}),e.jsx("strong",{children:t?.serverUrl??"loading"})]}),s?.appsMeta.lastRefreshError&&e.jsxs("div",{className:"settings-footnote warning",children:[e.jsx("span",{children:"Last refresh error"}),e.jsx("strong",{children:s.appsMeta.lastRefreshError})]}),L?e.jsx(is,{account:L,busy:Re,onClose:()=>{Re||G(null)},onSave:zs}):null,M?e.jsx(is,{account:D,busy:n,initialApiKey:a,mode:"connect",onClose:()=>{n||V(!1)},onSave:Bs}):null,e.jsx(Ys,{state:te,onResolve:F})]})}function Ge(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function Ie(...s){for(const t of s){const a=t?.trim();if(a)return a}return""}function rs(s){const t=s.trim().toLowerCase();return!t||t==="production"?"Production":"Environment"}function Yt(s){const t=s?.trim().replace(/\/+$/,"");if(!t)return Fe;try{const a=new URL(t);return a.protocol!=="http:"&&a.protocol!=="https:"?Fe:`${t}/settings/api-keys`}catch{return Fe}}function os(s){const t=s?.trim();return!t||t.toLowerCase()==="production"?"custom":t}function Zt(s){const t=s?.trim().toLowerCase();return!!(t&&t!=="production")}function Xt({advancedWorkspaceControls:s,defaultBranchPrefix:t,defaultNewProjectDirectory:a,preferences:n,saving:l,chooseDefaultProjectDirectory:o,saveDefaults:m,setAdvancedWorkspaceControls:r,setDefaultBranchPrefix:j,setDefaultNewProjectDirectory:v}){const b=qe(t)===n.defaultBranchPrefix&&a.trim()===n.defaultNewProjectDirectory&&s===n.advancedWorkspaceControls;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Defaults"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:x=>{m(x)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:x=>r(x.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:t,disabled:l,placeholder:"feat/",onChange:x=>j(x.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:x=>v(x.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{o()},children:[e.jsx(Ns,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||b,children:e.jsx("span",{children:l?"Saving":"Save defaults"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[qe(t),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||n.defaultNewProjectDirectory})]})]})}function Qt({diagnostics:s,diagnosticsAvailable:t,diagnosticsBusy:a,diagnosticsStatus:n,logDir:l,logLineLimit:o,logLines:m,logViewBusy:r,logViewSummary:j,logViewportRef:v,tailLogs:b,copyRecentLogs:x,exportDiagnosticsBundle:f,loadOlderLogs:h,openLogsFolder:c,refreshLogView:u,toggleTailLogs:g}){const S=s.filter(y=>y.name==="diagnostic"&&y.status==="failed").slice().reverse().map(en),d=typeof window>"u"?void 0:window.openpond;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Diagnostics"}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Recent errors"}),e.jsxs("small",{children:[S.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:S.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):S.map(y=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Ss,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:y.message}),e.jsx("time",{dateTime:y.timestamp,children:y.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:y.surface}),y.status?e.jsx("span",{children:y.status}):null,y.sequence?e.jsxs("span",{children:["#",y.sequence]}):null]}),y.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:y.detail})]}):null]})]},y.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:t?"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||!d?.openLogsFolder,onClick:()=>{c()},children:[e.jsx(Ns,{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||!d?.exportDiagnostics,onClick:()=>{f()},children:[e.jsx(Qs,{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||!d?.copyRecentLogs,onClick:()=>{x()},children:[e.jsx(Ot,{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:j}),e.jsx("button",{type:"button",className:`settings-icon-button ${b?"active":""}`,title:b?"Pause tail":"Tail logs","aria-label":b?"Pause tail":"Tail logs",disabled:!d?.readRecentLogs,onClick:g,children:b?e.jsx(et,{size:15}):e.jsx(Mt,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:r!==null||!d?.readRecentLogs,onClick:()=>{u(o,"refresh")},children:e.jsx(he,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:r!==null||!d?.readRecentLogs,onClick:h,children:[e.jsx(Rt,{size:15}),e.jsx("span",{children:r==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:v,className:"diagnostics-log-viewer",role:"log","aria-live":b?"polite":"off",children:m.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:r?"Loading logs":"No log lines"}):m.map((y,R)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:y.file}),e.jsx("code",{children:y.line})]},`${y.file}:${y.timestamp}:${y.index}:${R}`))}),l&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:l})]})]}),n&&e.jsxs("div",{className:`settings-footnote ${n.warning?"warning":""}`,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:n.value})]})]})}function en(s){const t=cs(s.data),a=cs(t.context),l=ce(t.stack)??ce(t.detail)??ce(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:tn(s.timestamp),message:sn(s,t),surface:ce(t.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function sn(s,t){return ce(s.error)??ce(s.output)??ce(t.message)??ce(t.error)??"Diagnostic event"}function tn(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function cs(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function ce(s){return typeof s=="string"&&s.trim()?s.trim():null}const ds=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function nn({editorPreferences:s,lspStatus:t,preferences:a,restarting:n,saving:l,statusLoading:o,refreshLspStatus:m,restartLanguageServers:r,saveEditorSettings:j,setEditorPreferences:v,setLanguageCustomCommand:b,setLanguageMode:x}){const f=JSON.stringify(s)!==JSON.stringify(a.editor),h=new Map(t?.languages.map(c=>[c.language,c])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:c=>{j(c)},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(Ce,{value:s.languageServers,disabled:l,label:"Language servers",options:st,onChange:c=>v(u=>({...u,languageServers:c}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:c=>v(u=>({...u,diagnosticsWhileEditing:c.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:c=>v(u=>({...u,checkOnSave:c.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:ds.map(c=>{const u=s.languages[c.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:c.label}),e.jsx("span",{children:us(h.get(c.id),o)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Ce,{value:u.mode,disabled:l||s.languageServers==="off",label:`${c.label} language server mode`,options:tt,onChange:g=>x(c.id,g)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:u.customCommand,disabled:l||s.languageServers==="off"||u.mode!=="custom",placeholder:c.placeholder,onChange:g=>b(c.id,g.target.value)})]})]},c.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!f,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:o?"Checking":t?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:o||n,onClick:()=>{m()},children:e.jsx(he,{className:o?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:o||n,onClick:()=>{r()},children:[e.jsx(It,{className:n?"settings-spin":void 0,size:15}),e.jsx("span",{children:n?"Restarting":"Restart"})]})]})]}),ds.map(c=>{const u=h.get(c.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:c.label}),e.jsx("span",{title:u?.command??u?.message??void 0,children:u?.command??u?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${u?.status??"missing"}`,children:us(u,o)})]},c.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 us(s,t){return t&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function an({goalStorageLocation:s,preferences:t,saving:a,saveDefaults:n,setGoalStorageLocation:l}){return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Goals"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:o=>{n(o)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Storage"}),e.jsx("small",{children:"Controls where local goal state, plans, and artifacts are written"})]}),e.jsxs("div",{className:"settings-radio-group",children:[e.jsxs("label",{className:"settings-radio-row",children:[e.jsx("input",{type:"radio",name:"goal-storage-location",checked:s==="global",disabled:a,onChange:()=>l("global")}),e.jsxs("span",{children:[e.jsx("strong",{children:"User home"}),e.jsx("small",{children:"Store goal files under ~/.openpond/goals."})]})]}),e.jsxs("label",{className:"settings-radio-row",children:[e.jsx("input",{type:"radio",name:"goal-storage-location",checked:s==="workspace",disabled:a,onChange:()=>l("workspace")}),e.jsxs("span",{children:[e.jsx("strong",{children:"Working directory"}),e.jsx("small",{children:"Store goal files in the current workspace under .openpond/goals."})]})]})]}),e.jsx("button",{className:"settings-primary",disabled:a||s===t.goalStorageLocation,children:e.jsx("span",{children:a?"Saving":"Save goals"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Goal storage"}),e.jsx("strong",{children:s==="global"?"~/.openpond/goals":".openpond/goals in the working directory"})]})]})}function ln({contextCompactionAutoEnabled:s,preferences:t,saving:a,saveDefaults:n,setContextCompactionAutoEnabled:l}){return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:o=>{n(o)},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:a,onChange:o=>l(o.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:a||s===t.contextCompaction.autoEnabled,children:e.jsx("span",{children:a?"Saving":"Save context"})})]})]})}function rn({insightsEnabled:s,insightsUseDefaultModel:t,insightsProvider:a,insightsModel:n,insightsEvidenceSources:l,preferences:o,providers:m,saving:r,saveDefaults:j,changeInsightsProvider:v,setInsightsEnabled:b,setInsightsUseDefaultModel:x,setInsightsModel:f,setInsightsEvidenceSourceEnabled:h}){const c=Je(m,{enabledOnly:!0}),u=ke(a,m),g="settings-insights-model-options",S=s===o.insightsEnabled&&hn(l,o.insightsEvidenceSources)&&gn({useDefault:t,provider:a,model:n},o);return e.jsxs("section",{className:"account-settings insights-settings",children:[e.jsx("h1",{children:"Insights"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:d=>{j(d)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Background agent"}),e.jsx("small",{children:"Controls the background Insights agent"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:r,onChange:d=>b(d.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Run background Insights"}),e.jsx("small",{children:"Startup and interval scans run while the app is open."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:t,disabled:r,onChange:d=>x(d.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Use default chat model"}),e.jsxs("small",{children:[ye(o.defaultChatProvider,m)," /"," ",Ee(o.defaultChatModel,m,o.defaultChatProvider)]})]})]}),t?null:e.jsxs("div",{className:"provider-settings-grid two",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Insights provider"}),e.jsx("select",{value:a,disabled:r,onChange:d=>v(d.target.value),children:c.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:"Insights model"}),e.jsx("input",{value:n,disabled:r,list:g,onChange:d=>f(d.target.value)}),e.jsx("datalist",{id:g,children:u.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))})]})]}),e.jsx("div",{className:"settings-check-grid","aria-label":"Insights evidence sources",children:As.map(d=>e.jsxs("label",{className:"settings-check-row compact",children:[e.jsx("input",{type:"checkbox",checked:l[d.key],disabled:r,onChange:y=>h(d.key,y.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:d.label}),e.jsx("small",{children:d.description})]})]},d.key))}),e.jsx("button",{className:"settings-primary",disabled:r||S,children:e.jsx("span",{children:r?"Saving":"Save insights"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Insights model"}),e.jsx("strong",{children:t?"Default chat model":`${ye(a,m)} / ${n}`})]})]})}function on({subagentsEnabled:s,subagentDelegationMode:t,subagentsUseDefaultModel:a,subagentsProvider:n,subagentsModel:l,subagentRoles:o,subagentsMaxConcurrentRuns:m,subagentsMaxConcurrentRunsPerProvider:r,subagentsMaxConcurrentRunsPerWorkspaceTarget:j,preferences:v,providers:b,saving:x,saveDefaults:f,changeSubagentsProvider:h,setSubagentsEnabled:c,setSubagentDelegationMode:u,setSubagentsUseDefaultModel:g,setSubagentsModel:S,setSubagentsMaxConcurrentRuns:d,setSubagentsMaxConcurrentRunsPerProvider:y,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:R,setSubagentRoleEnabled:N,setSubagentRoleIsolationMode:w,setSubagentRoleMaxConcurrentRuns:I,setSubagentRoleModel:z,setSubagentRolePeerMessages:T,setSubagentRoleToolPolicy:P,changeSubagentRoleProvider:p}){const C=Je(b,{enabledOnly:!0}),O=a?v.defaultChatProvider:n,L=a?v.defaultChatModel:l,G=Ds(ke(O,b),L),q=a?null:{providerId:n,modelId:l.trim()},$=pn({enabled:s,delegationMode:t,defaultModelRef:q,roles:o,maxConcurrentRuns:m,maxConcurrentRunsPerProvider:r,maxConcurrentRunsPerWorkspaceTarget:j},v);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:M=>{f(M)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Subagents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${$?"":" dirty"}`,disabled:x||$,children:e.jsx("span",{children:x?"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:x,onChange:M=>c(M.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:t,disabled:x||!s,onChange:M=>u(M.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:O,disabled:x||!s,onChange:M=>{g(!1),h(M.target.value)},children:C.map(M=>e.jsx("option",{value:M.value,children:M.label},M.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:L,disabled:x||!s,onChange:M=>{g(!1),S(M.target.value)},children:G.map(M=>e.jsx("option",{value:M.value,children:M.label},M.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:o.map(M=>{const V=nt.find(D=>D.id===M.id),X=M.modelRef?.providerId??O,K=M.modelRef?.modelId||at(X,b)||L,ee=mn(C,b,{providerId:X,modelId:K}),te=Te(X,K),F=x||!s||!M.enabled;return e.jsxs("section",{className:`subagent-role-row${M.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:V?.label??M.id}),e.jsx("small",{children:V?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${V?.label??M.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:M.enabled,disabled:x||!s,onChange:D=>N(M.id,D.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:te,disabled:F,onChange:D=>{const H=ee.find(ne=>ne.value===D.target.value);H&&(p(M.id,H.providerId),z(M.id,H.modelId))},children:ee.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:"Isolation"}),e.jsx("select",{value:M.isolationMode,disabled:F,onChange:D=>w(M.id,D.target.value),children:cn.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:"Tools"}),e.jsx("select",{value:M.toolPolicy,disabled:F,onChange:D=>P(M.id,D.target.value),children:dn.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:"Peer messages"}),e.jsx("select",{value:M.peerMessages,disabled:F,onChange:D=>T(M.id,D.target.value),children:un.map(D=>e.jsx("option",{value:D.value,children:D.label},D.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:M.maxConcurrentRuns,disabled:F,onChange:D=>I(M.id,ms(D.target.value,1))})]})})]},M.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:m,disabled:x||!s,onChange:M=>d(ms(M.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:r??"",placeholder:"No cap",disabled:x||!s,onChange:M=>y(Ke(M.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:j??"",placeholder:"No cap",disabled:x||!s,onChange:M=>R(Ke(M.target.value))})]})]})]})]})})}const cn=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],dn=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],un=[{value:"goal_scoped",label:"Scoped handoffs"},{value:"disabled",label:"Disabled"}];function Ds(s,t){const a=t.trim();return!a||s.some(n=>n.value===a)?s:[{value:a,label:a},...s]}function Te(s,t){return JSON.stringify([s,t])}function mn(s,t,a){const n=[];for(const l of s){const o=Ds(ke(l.value,t),l.value===a.providerId?a.modelId:"");for(const m of o)n.push({value:Te(l.value,m.value),label:`${l.label} / ${m.label}`,providerId:l.value,modelId:m.value})}return a.modelId&&!n.some(l=>l.value===Te(a.providerId,a.modelId))&&n.unshift({value:Te(a.providerId,a.modelId),label:`${ye(a.providerId,t)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),n}const As=[{key:"createEdit",label:"Create/Improve",description:"Waiting, blocked, or failed Create/Improve runs."},{key:"stuckTurns",label:"Stuck turns",description:"Failed or long-running active turns."},{key:"toolFailures",label:"Tool failures",description:"Repeated tool or action failures."},{key:"abandonedGoals",label:"Abandoned goals",description:"Goal loops left active too long."},{key:"userCorrections",label:"Corrections",description:"Repeated correction-style prompts."},{key:"unresolvedConversations",label:"Unresolved chats",description:"Long chats with unresolved recent work."},{key:"usageAnomalies",label:"Usage",description:"Spikes, failures, missing usage, and latency changes."}];function hn(s,t){return As.every(a=>s[a.key]===t[a.key])}function gn(s,t){return s.useDefault?!t.insightsModelRef:t.insightsModelRef?.providerId===s.provider&&t.insightsModelRef?.modelId===s.model.trim()}function Ke(s){const t=s.trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function ms(s,t){return Ke(s)??t}function pn(s,t){const a=t.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&fn(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 fn(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const xn=[{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 vn({currentUserId:s,enabled:t,mode:a,threads:n,onModeChange:l,onThreadMuteChange:o}){const[m,r]=i.useState(null),[j,v]=i.useState(null);ys(j);const b=i.useMemo(()=>n.filter(h=>h.archivedAt===null).map(h=>({thread:h,label:jn(h,s)})).sort((h,c)=>{const u=+!!c.thread.mutedAt-+!!h.thread.mutedAt;return u!==0?u:h.label.localeCompare(c.label)}),[s,n]),x=b.filter(({thread:h})=>!!h.mutedAt).length,f=i.useCallback(async h=>{r(h.id),v(null),await o(h.id,!h.mutedAt)||v("Could not update this conversation. Try again."),r(null)},[o]);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:xn.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:x===1?"1 muted":`${x} muted`})]}),t?b.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):b.map(({thread:h,label:c})=>{const u=!!h.mutedAt,g=m===h.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${u?" muted":""}`,children:u?e.jsx(lt,{size:15}):e.jsx(ks,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:c}),e.jsx("small",{children:u?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:m!==null,onClick:()=>{f(h)},children:g?"Saving":u?"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 jn(s,t){return s.kind==="general"||s.kind==="channel"?`#${s.title?.trim()||"general"}`:s.kind==="dm"?s.participants.find(a=>a.userId!==t)?.name??s.title?.trim()??"Direct message":s.title?.trim()||s.participants.filter(a=>a.userId!==t).map(a=>a.name).join(", ")||"Group conversation"}function bn({canSaveCurrentTemplate:s,personalizationTemplateId:t,personalizationTemplateOptions:a,saveAsNewOpen:n,saving:l,selectedPersonalizationTemplate:o,selectedTemplateIsCustom:m,soulDraft:r,templateNameDraft:j,changePersonalizationTemplate:v,changeSoulDraft:b,openSaveAsNew:x,resetPersonalizationDraft:f,savePersonalization:h,setSaveAsNewOpen:c,setTemplateNameDraft:u}){function g(S){S.preventDefault(),h(n)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:g,children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agent style"}),e.jsx("div",{className:"settings-heading-actions",children:n?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"settings-heading-input",value:j,onChange:S=>u(S.target.value),placeholder:"Name","aria-label":"Template name"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Cancel","aria-label":"Cancel",disabled:l,onClick:()=>c(!1),children:e.jsx(Le,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!r.trim()||!j.trim(),onClick:()=>{h(!0)},children:e.jsx(it,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:m?"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||!o||!r.trim(),onClick:x,children:e.jsx(He,{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(Ce,{value:t,disabled:l||a.length===0,label:"Personalization template",options:a,onChange:S=>{v(S)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:r,onChange:S=>b(S.target.value),spellCheck:!1})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Reset to template","aria-label":"Reset to template",disabled:l||!o,onClick:f,children:e.jsx(kt,{size:15})}),m&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(Ye,{size:15})})]})]})]})}const yn=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],Nn=120,Sn=new Set(["openai","xai","zai"]),wn=new Set(["chatgpt-subscription"]),Cn="https://api.z.ai/api/coding/paas/v4";function hs(s){return s.split(/[\n,]/).map(t=>t.trim()).filter(Boolean)}function Ts(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 Es(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function gs(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 kn(s){return s?.trim().replace(/\/+$/,"")??""}function Os(s,t){return s.id==="zai"&&kn(t.providers.zai?.baseUrl)===Cn}function Pn(s,t){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":Os(s,t)?"Coding Plan key":"API key"}function Rn(s,t){const a=t.modelCaches[s.id];if(s.routing.localByok&&s.enabled&&!s.credential.connected||!s.enabled&&s.id!=="openpond")return"";const n=Math.max(a?.models.length??0,s.modelIds.length),l=s.defaultModel?Ee(s.defaultModel,t,s.id):"",o=n===1?"1 model":`${n} models`,m=Pn(s,t);return[Ts(s),m,a?o:"",l].filter(Boolean).join(" · ")}function Mn(s){return s!=="openpond"&&Ve(s)}function Ze(s){return s?Sn.has(s.id)||s.credentialModes.some(t=>wn.has(t)):!1}function In(s){return Ze(s)?["api","subscription"]:["api"]}function ps(s,t){return!s||!t||!Ze(s)?"api":s.credential.source==="chatgpt_subscription"||Os(s,t)?"subscription":"api"}function fs(s,t){const a=rt.filter(n=>!!s?.statuses[n]);return t?a.filter(n=>Ze(s?.statuses[n])):a}function Dn(s){if(!s)return"Never";const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString()}function An(s,t,a=Nn){const n=[],l=new Set,o=new Set(t.map(r=>r.trim()).filter(Boolean)),m=r=>{l.has(r.value)||n.length>=a||(l.add(r.value),n.push(r))};for(const r of s)o.has(r.value)&&m(r);for(const r of s)m(r);return n}function Tn({account:s,codex:t,providers:a,providerBusy:n,validationMessage:l,deleteProviderCredential:o,loadProviderModels:m,refreshProviderModels:r,saveProviderConfig:j,saveProviderCredential:v,startOpenAiSubscriptionAuth:b,validateProvider:x}){const[f,h]=i.useState(null),[c,u]=i.useState(!1),g=i.useMemo(()=>fs(a,!1),[a]),S=i.useMemo(()=>fs(a,c),[a,c]),d=f?a?.statuses[f]??null:null;function y(R,N){h(R),N&&m(R)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Providers"}),a?e.jsxs("div",{className:"provider-manager-panel",children:[e.jsxs("div",{className:"account-list-heading provider-manager-heading",children:[e.jsxs("div",{className:"provider-manager-title-row",children:[e.jsx("span",{children:"Model providers"}),e.jsxs("label",{className:"settings-check-row compact provider-subscription-filter",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:R=>u(R.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[S.length," of ",g.length," presets"]})]}),S.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:S.map(R=>{const N=a.statuses[R],w=a.modelCaches[R],I=N.modelIds.length>0&&(w?.models.length??0)<N.modelIds.length,z=n?.startsWith(`${R}:`)??!1,T=Mn(R),P=R==="openpond"||!!a.providers[R]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${N.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:P,disabled:!T||z,onChange:p=>{y(R,!1),j(R,{enabled:p.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:N.displayName})}),e.jsxs("div",{className:`provider-row-status ${Es(N)}`,children:[z?e.jsx(re,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:Rn(N,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{y(R,I)},children:"Details"})]},R)})}):e.jsxs("div",{className:"empty-account-list provider-manager-empty",children:[e.jsx("strong",{children:"No subscription providers"}),e.jsx("span",{children:"Turn off the filter to show API-key providers."})]})]}):null,l?e.jsxs("div",{className:"settings-footnote provider-validation-message",children:[e.jsx("span",{children:"Last validation"}),e.jsx("strong",{children:l})]}):null,f&&d&&a?e.jsx(En,{account:s,codex:t,providerId:f,providerBusy:n,settings:a,status:d,onClose:()=>h(null),onDeleteCredential:o,onRefreshModels:r,onSaveConfig:j,onSaveCredential:v,onStartOpenAiSubscriptionAuth:b,onValidate:x}):null]})}function En({account:s,codex:t,providerId:a,providerBusy:n,settings:l,status:o,onClose:m,onDeleteCredential:r,onRefreshModels:j,onSaveConfig:v,onSaveCredential:b,onStartOpenAiSubscriptionAuth:x,onValidate:f}){const h=l.providers[a],c=l.modelCaches[a],u=i.useId(),g=i.useRef(a),S=Math.max(c?.models.length??0,o.modelIds.length),d=o.routing.localByok&&Ve(a)&&a!=="codex",y=i.useMemo(()=>d?In(o):[],[d,o]),R=y.includes("subscription"),[N,w]=i.useState(()=>ps(o,l)),I=d&&N==="subscription"&&R,z=P=>`${u}-${P}-panel`,T=a==="codex"?"Codex app server":h?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return i.useEffect(()=>{if(g.current!==a){g.current=a,w(ps(o,l));return}d&&!y.includes(N)&&w("api")},[N,y,d,a,l,o]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:m,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${o.displayName} provider details`,onMouseDown:P=>P.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:m,children:e.jsx(Le,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:o.displayName}),e.jsx("span",{children:ye(a,l)})]}),e.jsx("div",{className:`provider-state-pill ${Es(o)}`,children:Ts(o)})]}),d?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${o.displayName} mode`,children:y.map(P=>e.jsx("button",{type:"button",role:"tab",id:`${u}-${P}`,className:N===P?"active":void 0,"aria-selected":N===P,"aria-controls":z(P),onClick:()=>w(P),children:P==="api"?"API":"Subscription"},P))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:gs(o),children:gs(o)})]}),I?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:T,children:T})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:h?.defaultModel??o.defaultModel??void 0,children:h?.defaultModel??o.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:c?.lastError??void 0,children:[S," cached · ",Dn(c?.fetchedAt)]})]})]}),a==="codex"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{title:t?.account?.email??void 0,children:t?.account?.label??t?.account?.email??"Not signed in"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Binary"}),e.jsx("dd",{title:t?.binaryPath??void 0,children:t?.binaryPath??"Not found"})]})]}):null,o.credential.lastError||c?.lastError||o.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:o.credential.lastError??c?.lastError??o.lastError??void 0,children:o.credential.lastError??c?.lastError??o.lastError})]}):null]}),a==="codex"?e.jsx(On,{providerBusy:n,status:o,onValidate:f}):d&&h&&c?e.jsx(Ln,{credentialTab:N,credentialTabsId:u,hasSubscriptionTab:R,providerId:a,providerBusy:n,settings:l,status:o,onDeleteCredential:r,onRefreshModels:j,onSaveConfig:v,onSaveCredential:b,onStartOpenAiSubscriptionAuth:x,onValidate:f}):o.routing.localByok&&!Ve(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Ss,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function On({providerBusy:s,status:t,onValidate:a}){const n=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(le,{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:n,onClick:()=>{a("codex",{modelId:t.defaultModel??void 0})},children:[n?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(ws,{size:14}),e.jsx("span",{children:n?"Testing":"Test Codex login"})]})})]})}function Ln({credentialTab:s,credentialTabsId:t,hasSubscriptionTab:a,providerId:n,providerBusy:l,settings:o,status:m,onDeleteCredential:r,onRefreshModels:j,onSaveConfig:v,onSaveCredential:b,onStartOpenAiSubscriptionAuth:x,onValidate:f}){const h=o.providers[n],c=i.useMemo(()=>ke(n,o),[n,o]),u=`provider-models-${n}`,g=i.useRef(n),[S,d]=i.useState(h.baseUrl??""),[y,R]=i.useState(h.defaultModel??""),[N,w]=i.useState(h.modelOverrides.join(`
3
3
  `)),[I,z]=i.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[T,P]=i.useState("local_secret"),[p,C]=i.useState(""),[O,L]=i.useState(""),G=l===`${n}:config`,q=l===`${n}:credential`,$=l===`${n}:validate`,M=l===`${n}:models`,V=l==="openai:credential",X=n==="openai",K=n==="xai",ee=n==="zai",F=(B=>`${t}-${B}-panel`)(s),D=s==="subscription"&&a,H=s==="subscription"&&ee?"coding-plan":"api",ne=H==="coding-plan"?"Coding Plan key":"API key",ae=m.credential.connected?H==="coding-plan"?"Replace saved plan key":"Replace saved key":ne,ge=H==="coding-plan"?"Save plan key":"Save key",pe=i.useMemo(()=>An(c,[y,...hs(N)]),[y,c,N]),ue=Math.max(0,c.length-pe.length);i.useEffect(()=>{if(g.current!==n){g.current=n,z({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),d(h.baseUrl??""),R(h.defaultModel??""),w(h.modelOverrides.join(`
4
4
  `));return}I.baseUrl||d(h.baseUrl??""),I.defaultModel||R(h.defaultModel??""),I.modelOverrides||w(h.modelOverrides.join(`
5
- `))},[h.baseUrl,h.defaultModel,h.modelOverrides,I.baseUrl,I.defaultModel,I.modelOverrides,n]);const fe=T==="env"?!!O.trim():!!p.trim();async function xe(B){B.preventDefault(),await v(n,{enabled:!0,baseUrl:S.trim()||null,defaultModel:y.trim()||null,modelOverrides:hs(N)}),z({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function ve(B){if(B.preventDefault(),!!fe){if(T==="env"){await b(n,{source:"env",envVar:O.trim()});return}await b(n,{source:"local_secret",value:p}),C("")}}function J({panel:B=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:B?F:void 0,role:B?"tabpanel":void 0,"aria-labelledby":B?`${t}-${s}`:void 0,onSubmit:Y=>{ve(Y)},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(Ce,{value:T,disabled:q,label:"Credential source",options:yn,onChange:Y=>P(Y)})]}),T==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:O,disabled:q,placeholder:"PROVIDER_API_KEY",onChange:Y=>L(Y.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:ne}),e.jsx("input",{type:"password",value:p,disabled:q,placeholder:ae,autoComplete:"off",onChange:Y=>C(Y.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:q||!fe,children:[q?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(le,{size:14}),e.jsx("span",{children:q?"Saving":ge})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${m.displayName} credential`,disabled:q||!m.credential.connected,onClick:()=>{r(n)},children:e.jsx(es,{size:15})})]})]})}function je(){return X?e.jsxs("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(le,{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:V,onClick:()=>{x("browser")},children:[V?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(le,{size:14}),e.jsx("span",{children:V?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:V,onClick:()=>{x("device")},children:[V?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(le,{size:14}),e.jsx("span",{children:"Device code"})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${m.displayName} credential`,disabled:V||!m.credential.connected,onClick:()=>{r(n)},children:e.jsx(es,{size:15})})]})]}):K?e.jsx("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:e.jsxs("div",{className:"provider-dialog-note xai-provider-note",children:[e.jsx(le,{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."})]})}):ee?e.jsxs("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note subscription-provider-note",children:[e.jsx(le,{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."})]}),J({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[D?null:e.jsxs("form",{className:"provider-card-form",onSubmit:B=>{xe(B)},children:[e.jsxs("div",{className:"provider-card-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{value:S,disabled:G,placeholder:"https://api.example.com/v1",onChange:B=>{z(Y=>({...Y,baseUrl:!0})),d(B.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:u,value:y,disabled:G,placeholder:"Model id",onChange:B=>{z(Y=>({...Y,defaultModel:!0})),R(B.currentTarget.value)}}),e.jsx("datalist",{id:u,children:pe.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))}),ue>0?e.jsxs("small",{children:[ue," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:G,children:[G?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(Ye,{size:14}),e.jsx("span",{children:G?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:M,onClick:()=>{j(n)},children:[M?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(he,{size:14}),e.jsx("span",{children:M?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:$||!y.trim(),onClick:()=>{f(n,{baseUrl:S.trim()||void 0,modelId:y.trim()||void 0})},children:[$?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(Ss,{size:14}),e.jsx("span",{children:$?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:D?je():J()})]})}function Un({status:s,busy:t,flashTailscaleUp:a,refresh:n,enableRemoteAccess:l,disableRemoteAccess:o,copyRemoteLink:m,copyTailscaleUpCommand:r,copyServeCommand:j,copyServeSetupUrl:v,copyOperatorCommand:b,createRemoteLink:x}){const f=s?.tailscale.installed??!1,h=s?.serve.enabled??!1,c=s?.serve.reachable??!1,u=!!(s?.webUiAvailable&&f),g=h?!!s?.remoteWebUrl:u,d=(s?.tailscale.peers??[]).filter(N=>!N.isSelf),y=!!s?.tailscale.error?.includes("set --operator"),R=!!(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 ${c?"online":h?"configured":""}`,children:f?e.jsx(Ms,{size:18}):e.jsx(Dt,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:c?"Tailscale Serve is reachable":h?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?zn(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:t!==null,onClick:()=>{n()},children:e.jsx(he,{className:t==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:t!==null||!f||!h&&!u,onClick:()=>{h?o():l()},children:[e.jsx(Ft,{size:15}),e.jsx("span",{children:h?t==="disable"?"Turning off":"Turn off":t==="enable"?"Turning on":"Turn on"})]})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsx("div",{className:"account-list-heading remote-access-link-heading",children:e.jsxs("div",{children:[e.jsx("span",{children:"OpenPond link"}),e.jsx("small",{children:R?"Browser UI":"Tailscale + Serve"})]})}),R&&e.jsx(ie,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:t==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||t!==null,onAction:m}),e.jsx(ie,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:a,actionLabel:t==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||t!==null,onAction:r}),e.jsx(ie,{label:"Serve command",value:s?.serveCommand??null,actionLabel:t==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||t!==null,onAction:j}),s?.serve.setupUrl&&e.jsx(ie,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:t==="copy-serve-setup"?"Copying":"Copy",disabled:t!==null,onAction:v}),y&&e.jsx(ie,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:t==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||t!==null,onAction:b}),e.jsx(ie,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(ie,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(ie,{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:[d.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:t!==null||!g,onClick:()=>{x()},children:e.jsx("span",{children:h?"Copy link":"Create link"})})]}),s?d.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."})]}):d.map(N=>e.jsx(Bn,{peer:N},N.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($n,{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 ie({actionLabel:s,disabled:t,flash:a,label:n,onAction:l,value:o}){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:n}),e.jsx("code",{children:o??"Not available"})]}),l&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:t,onClick:()=>{l()},children:e.jsx("span",{children:s??"Copy"})})]})}function $n({status:s}){const t=[{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:t.map(n=>e.jsx(xs,{label:n.label,value:n.value},n.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(n=>e.jsx(xs,{label:n.label,value:n.value},n.label))})]})}function xs({label:s,value:t}){return e.jsxs("div",{className:"remote-access-environment-cell",children:[e.jsx("strong",{children:s}),e.jsx("span",{children:t})]})}function Bn({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 zn(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 _n=[{items:[{section:"account",label:"Account",Icon:Vt},{section:"notifications",label:"Notifications",Icon:ks},{section:"providers",label:"Providers",Icon:ct},{section:"compute",label:"Compute",Icon:At},{section:"dataset-storage",label:"Dataset Storage",Icon:Bt},{section:"wallet",label:"Wallet",Icon:Ps},{section:"usage",label:"Activity",Icon:dt},{section:"defaults",label:"Defaults",Icon:Is}]},{label:"Harness",items:[{section:"profile",label:"My Profile",Icon:ut},{section:"skills",label:"Skills",Icon:ws},{section:"goals",label:"Goals",Icon:ns},{section:"context",label:"Context",Icon:mt},{section:"insights",label:"Insights",Icon:ht},{section:"training",label:"Training",Icon:ss},{section:"subagents",label:"Subagents",Icon:ss}]},{items:[{section:"editor",label:"Editor",Icon:Ut},{section:"remote",label:"Remote",Icon:Ms},{section:"personalization",label:"Personalization",Icon:gt},{section:"diagnostics",label:"Diagnostics",Icon:ns}]}];function Fn({section:s,onBack:t,onSectionChange:a}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back",onClick:t,children:[e.jsx(ot,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:_n.map((n,l)=>e.jsxs("div",{className:"settings-nav-group",children:[n.label?e.jsx("div",{className:"settings-nav-heading",children:n.label}):null,n.items.map(({section:o,label:m,Icon:r})=>e.jsxs("button",{className:`settings-nav-item ${s===o?"active":""}`,onClick:()=>a(o),children:[e.jsx(r,{size:16}),e.jsx("span",{children:m})]},o))]},n.label??`settings-${l}`))})]})}function Gn({onOpenNativeSkill:s}){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:"Read-only operating instructions that ship with OpenPond and are loaded when an agent uses the matching app."})]})}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Native skills"}),e.jsx("small",{children:"Bundled with this OpenPond build"})]}),pt.map(t=>{const a=ft(t.provider)?.label??t.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(t),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(ws,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:t.name}),e.jsx("span",{children:t.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:a}),e.jsx("span",{children:t.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(xt,{size:16,"aria-hidden":"true"})]},t.name)})]})]})}const Xe="default";function Wn({connection:s,embedded:t=!1,onError:a,onPreferences:n,preferences:l,providers:o}){const m=l.training,[r,j]=i.useState(We(m.defaultModelRef)),[v,b]=i.useState(m.creationMode),[x,f]=i.useState(m.autoApproveEvidence),[h,c]=i.useState(!1),u=i.useMemo(()=>Je(o,{includeUnavailable:!0}),[o]),g=i.useMemo(()=>u.map(N=>({provider:N,models:ke(N.value,o)})).filter(N=>N.models.length>0),[u,o]),S=qn(r),d=vt(l.defaultChatProvider,l.defaultChatModel,o)?` · ${Vn(l.codexReasoningEffort)} reasoning`:"",y=Kn(S,m.defaultModelRef??null)&&v===m.creationMode&&x===m.autoApproveEvidence;i.useEffect(()=>{j(We(m.defaultModelRef)),b(m.creationMode),f(m.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,m.autoApproveEvidence,m.creationMode,m.defaultModelRef]);async function R(N){if(N.preventDefault(),!!s){c(!0),a(null);try{n(await E.savePreferences(s,{training:{defaultModelRef:S,creationMode:v,autoApproveEvidence:x}}))}catch(w){a(w instanceof Error?w.message:String(w))}finally{c(!1)}}}return e.jsxs("section",{className:`account-settings training-settings${t?" embedded":""}`,children:[t?null:e.jsx("h1",{children:"Training"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:N=>{R(N)},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:r,disabled:h,onChange:N=>j(N.target.value),children:[e.jsxs("option",{value:Xe,children:["Use chat default — ",ye(l.defaultChatProvider,o)," · ",Ee(l.defaultChatModel,o,l.defaultChatProvider),d]}),g.map(N=>e.jsx("optgroup",{label:N.provider.label,children:N.models.map(w=>e.jsx("option",{value:We({providerId:N.provider.value,modelId:w.value}),children:w.label},w.value))},N.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:v,disabled:h,onChange:N=>b(N.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:x,disabled:h,onChange:N=>f(N.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||y,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:S?`${ye(S.providerId,o)} / ${Ee(S.modelId,o,S.providerId)}`:"Chat default"})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Safety boundary"}),e.jsx("strong",{children:"Taskset and training approvals always required"})]})]})}function We(s){return s?JSON.stringify([s.providerId,s.modelId]):Xe}function qn(s){if(s===Xe)return null;try{const t=JSON.parse(s);return!Array.isArray(t)||t.length!==2||typeof t[0]!="string"||typeof t[1]!="string"?null:{providerId:t[0],modelId:t[1]}}catch{return null}}function Vn(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function Kn(s,t){return s?.providerId===t?.providerId&&s?.modelId===t?.modelId}function Ls({disabled:s,onChange:t,purpose:a="model",storageRoots:n,value:l}){const o=i.useId(),[m,r]=i.useState(!1),j=vs(l),v=f=>a==="dataset"?f.datasetStorePath:f.modelStorePath,b=a==="dataset"?"Dataset":"Model",x=n.find(f=>vs(v(f))===j)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:o,children:[b," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${b} storage drive`,className:"model-storage-select",disabled:s,id:o,title:l??`No ${a} storage configured`,value:l??"",onChange:f=>t(f.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),l&&!x?e.jsx("option",{value:l,children:"Manual location"}):null,n.map(f=>e.jsxs("option",{disabled:!f.mounted||!f.writable,title:v(f),value:v(f),children:[f.label," · ",Zn(f.kind)," · ",Xn(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 ${a} storage location`,onClick:()=>r(!0),children:e.jsx(He,{size:15})})]}),m?Hn(e.jsx(Jn,{initialPath:l??"",purpose:a,onClose:()=>r(!1),onUse:f=>{t(f),r(!1)}})):null]})}function Hn(s){return typeof document>"u"?s:Tt.createPortal(s,document.body)}function Jn({initialPath:s,onClose:t,onUse:a,purpose:n="model"}){const l=i.useId(),[o,m]=i.useState(s),r=Yn(o);i.useEffect(()=>{const v=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[t]);function j(v){v.preventDefault(),v.stopPropagation(),!r&&a(o.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:j,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${n} storage`,onClick:t,children:e.jsx(Le,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(jt,{size:18})}),e.jsxs("h2",{id:l,children:["Manual ",n," 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:o,placeholder:n==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:v=>m(v.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."}),o.trim()&&r?e.jsx("div",{className:"profile-dialog-warning",children:r}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",type:"button",onClick:t,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:!!r,type:"submit",children:"Use location"})]})]})})}function Yn(s){const t=s.trim();return t?/^[a-z][a-z\d+.-]*:\/\//i.test(t)?"Use the mounted folder path, not an smb:// or other network URL.":t==="~"||t.startsWith("~/")||t.startsWith("/")||t.startsWith("\\\\")||/^[a-z]:[\\/]/i.test(t)?null:"Enter an absolute mounted folder path.":"Enter a mounted folder path."}function Zn(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function Xn(s){return s.mounted?s.writable?`${Qn(s.freeBytes)} free`:"Read only":"Not mounted"}function vs(s){const t=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(t)?t.toLowerCase():t}function Qn(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function ea({state:s,busy:t,title:a="Compute",onScan:n,onSave:l,onDownloadSmolLm2:o,onCancelDownload:m}){const r=s?.inventory??null,[j,v]=i.useState(s?.settings.modelStorePath??null),[b,x]=i.useState(s?.settings.defaultDeviceIds[0]??"automatic");i.useEffect(()=>{v(s?.settings.modelStorePath??null)},[s?.settings.modelStorePath]),i.useEffect(()=>{x(s?.settings.defaultDeviceIds[0]??"automatic")},[s?.settings.defaultDeviceIds]);const f=j===(s?.settings.modelStorePath??null)&&b===(s?.settings.defaultDeviceIds[0]??"automatic"),h=i.useMemo(()=>r?.devices.filter(d=>d.kind!=="cpu"&&d.available)??[],[r?.devices]),c=r?.models.find(d=>d.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,u=[...r?.downloads??[]].reverse().find(d=>d.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,g=!!(u&&["queued","downloading","verifying","cancelling"].includes(u.status));async function S(d){d.preventDefault(),await l(j,s?.settings.datasetStorePath??null,b==="automatic"?[]:[b])}return e.jsxs("section",{className:"account-settings compute-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsx("h1",{children:a}),e.jsx("button",{className:"settings-icon-button",type:"button",title:"Scan compute","aria-label":"Scan compute",disabled:t!==null,onClick:()=>{n()},children:e.jsx(he,{size:15,className:t==="scan"?"settings-spin":void 0})})]}),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:r?`${r.host.operatingSystem} · ${r.host.architecture}`:t==="load"?"Loading this machine":"This machine has not been scanned"}),e.jsx("small",{children:r?`${r.devices.length} device${r.devices.length===1?"":"s"} · ${we(r.host.totalMemoryBytes)} memory · scanned ${aa(r.scannedAt)}`:"Run a bounded native scan to discover local training capabilities."})]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:d=>{S(d)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Defaults"})}),e.jsx(Ls,{disabled:t!==null,storageRoots:r?.storageRoots??[],value:j,onChange:v}),e.jsx("div",{className:"provider-settings-grid single compute-device-default",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default device"}),e.jsxs("select",{value:b,disabled:t!==null,onChange:d=>x(d.target.value),children:[e.jsx("option",{value:"automatic",children:"Automatic"}),h.map(d=>e.jsx("option",{value:d.id,children:d.name},d.id))]})]})}),e.jsx("button",{className:"settings-primary",disabled:t!==null||f,children:t==="save"?"Saving":"Save compute settings"})]}),e.jsx(js,{title:"Devices",empty:"No devices discovered",rows:(r?.devices??[]).map(d=>({id:d.id,title:d.name,detail:sa(d),meta:d.available?"Available":d.unavailableReason??"Unavailable"}))}),e.jsx(js,{title:"Runtimes",empty:"No runtimes discovered",rows:(r?.runtimes??[]).map(d=>({id:d.id,title:ta(d.kind),detail:d.version??d.detail??"Not installed",meta:d.state==="available"?"Available":"Unavailable"}))}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Models"}),e.jsxs("div",{className:"compute-heading-actions",children:[g&&u?e.jsx("button",{type:"button",className:"settings-secondary",disabled:u.status==="cancelling",onClick:()=>{m(u.id)},children:u.status==="cancelling"?"Cancelling":"Cancel"}):c?null:e.jsx("button",{type:"button",className:"settings-secondary",disabled:!s?.settings.modelStorePath,onClick:()=>{o()},children:"Download SmolLM2"}),e.jsx("small",{children:r?.models.length??0})]})]}),u&&!c?e.jsxs("div",{className:"compute-download-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"SmolLM2 135M Instruct"}),e.jsx("small",{children:u.status==="failed"?u.error:`${na(u.status)} · ${we(u.downloadedBytes)} of ${we(u.expectedBytes)} · Apache-2.0`})]}),e.jsx("progress",{max:u.expectedBytes,value:u.downloadedBytes})]}):null,r?.models.length?r.models.map(d=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:d.name}),e.jsxs("small",{children:[d.source," · ",d.format," · ",we(d.sizeBytes)]})]}),e.jsx("span",{children:d.trainingCompatible?"Trainable":d.inferenceCompatible?"Inference only":"Unsupported"})]},d.id)):u?null:e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"No recognized local models"})})]}),r?.warnings.length?e.jsxs("details",{className:"compute-diagnostics",children:[e.jsx("summary",{children:"Diagnostics"}),e.jsx("ul",{children:r.warnings.map(d=>e.jsx("li",{children:d},d))})]}):null]})}function js({title:s,empty:t,rows:a}){return e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:s}),e.jsx("small",{children:a.length})]}),a.length?a.map(n=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:n.title}),e.jsx("small",{children:n.detail})]}),e.jsx("span",{children:n.meta})]},n.id)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t})})]})}function sa(s){return[s.vendor,s.kind,s.totalMemoryBytes?we(s.totalMemoryBytes):null,s.computeCapability?`compute ${s.computeCapability}`:null].filter(Boolean).join(" · ")}function ta(s){return s==="trl_peft"?"TRL / PEFT":s.toUpperCase()}function na(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function aa(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function we(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function la({state:s,catalog:t,busy:a,catalogLoading:n,onRefresh:l,onSave:o}){const[m,r]=i.useState(s?.settings.datasetStorePath??null);i.useEffect(()=>{r(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const j=i.useMemo(()=>s?.inventory?.storageRoots.find(f=>bs(f.datasetStorePath)===bs(m))??null,[m,s?.inventory?.storageRoots]),v=m===(s?.settings.datasetStorePath??null),b=t?.datasets??[];async function x(f){f.preventDefault(),await o(m)}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||n,onClick:()=>{l()},title:"Refresh Dataset storage",type:"button",children:e.jsx(he,{className:n?"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:j?.label??(m?"Manual location":"Not configured")}),e.jsx("small",{children:m??"Choose a writable local or mounted location before importing a Dataset."}),j?e.jsxs("small",{children:[ca(j.kind)," · ",j.freeBytes==null?"Free space unknown":`${Us(j.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:f=>{x(f)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(Ls,{disabled:a!==null,onChange:r,purpose:"dataset",storageRoots:s?.inventory?.storageRoots??[],value:m}),e.jsx("button",{className:"settings-primary",disabled:a!==null||v,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:b.length})]}),b.length?b.map(f=>e.jsx(ia,{dataset:f},f.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:n?"Loading registered Datasets":"No registered Datasets"})})]})]})}function ia({dataset:s}){const t=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:[$s(s.rowCount)," rows"," · ",ra(s)," · ",t," · ",s.sizeBytes==null?"Size unavailable":Us(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?oa(s.status):"Unavailable"})]})}function ra(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,n])=>`${$s(Number(n))} ${a}`).join(" · ")||"No split rows"}function Us(s){if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function $s(s){return new Intl.NumberFormat().format(s)}function bs(s){return s?.replace(/[\\/]+$/,"")??""}function oa(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function ca(s){return s.replace(/^./,t=>t.toUpperCase())}function da({payload:s}){const t=s?.account??null,a=t?.profile??null,n=t?.products??[],l=t?.balance?.breakdown??[],o=t?.state==="signed_in"?t?.label??t?.activeProfile?.handle??"OpenPond account":"Not signed in",m=a?.turnkeyOperatingWalletAddress??null,r=n.length>0?n.map(x=>x.name).join(", "):"None",j=[{label:"Personal wallet",address:a?.turnkeyWalletAddress??null},{label:"Operating wallet",address:m}],v=t?.state??"loading",b=v==="signed_in"?"active":void 0;return e.jsxs("section",{className:"wallet-view","aria-label":"Wallet",children:[e.jsxs("div",{className:"wallet-credit-card",children:[e.jsxs("div",{className:"wallet-card-top",children:[e.jsxs("div",{className:"wallet-card-brand",children:[e.jsx(Ps,{size:18}),e.jsx("span",{children:"OpenPond"})]}),e.jsx(Ae,{state:v,label:b})]}),e.jsxs("div",{className:"wallet-card-balance",children:[e.jsx("span",{children:"Balance"}),e.jsx("strong",{children:t?.balanceLabel??"$0.00"}),e.jsx(ua,{address:m})]}),e.jsxs("div",{className:"wallet-card-bottom",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Account"}),e.jsx("strong",{children:o})]}),e.jsxs("div",{className:"wallet-card-products",children:[e.jsx("span",{children:"Products"}),e.jsx("strong",{title:r,children:r})]})]})]}),e.jsxs("div",{className:"wallet-content-grid",children:[e.jsxs("section",{className:"wallet-panel",children:[e.jsx("div",{className:"wallet-panel-header",children:e.jsx("div",{children:e.jsx("span",{children:"Assets"})})}),e.jsx("div",{className:"wallet-asset-list",children:l.length>0?l.map(x=>e.jsx(ha,{asset:x},`${x.wallet}-${x.chain}-${x.asset}`)):e.jsx("div",{className:"wallet-asset-row empty",children:e.jsxs("div",{children:[e.jsx("strong",{children:"No assets found"}),e.jsx("span",{children:"Refresh after funding the operating wallet."})]})})})]}),e.jsx("div",{className:"wallet-side-stack",children:e.jsxs("section",{className:"wallet-panel",children:[e.jsx("div",{className:"wallet-panel-header",children:e.jsx("div",{children:e.jsx("span",{children:"Wallets"})})}),e.jsx("div",{className:"wallet-address-list",children:j.map(x=>e.jsx(ma,{label:x.label,address:x.address},x.label))})]})})]})]})}function ua({address:s}){const t=s?.trim()||null;return e.jsxs("div",{className:`wallet-card-address ${t?"":"empty"}`,children:[e.jsx("span",{children:"Operating wallet"}),e.jsxs("div",{children:[e.jsx("code",{children:t??"Not available"}),e.jsx("button",{type:"button",className:"wallet-copy-button ghost",title:"Copy operating wallet","aria-label":"Copy operating wallet",disabled:!t,onClick:()=>{t&&oe(t)},children:e.jsx(Rs,{size:12})})]})]})}function ma({label:s,address:t}){const a=t?.trim()||null;return e.jsx("div",{className:`wallet-address-row ${a?"":"empty"}`,children:e.jsxs("div",{children:[e.jsx("span",{children:s}),e.jsxs("div",{className:"wallet-address-line",children:[e.jsx("code",{children:a??"Not available"}),e.jsx("button",{type:"button",className:"wallet-copy-button ghost",title:`Copy ${s}`,"aria-label":`Copy ${s}`,disabled:!a,onClick:()=>{a&&oe(a)},children:e.jsx(Rs,{size:12})})]})]})})}function ha({asset:s}){const t=pa(s.amount,s.asset),a=fa(s.usdValue),n=ga(s.asset);return e.jsxs("div",{className:"wallet-asset-row",children:[e.jsxs("div",{className:"wallet-asset-identity",children:[n?e.jsx("img",{src:n,alt:""}):e.jsx("span",{className:"wallet-token-fallback",children:s.asset.slice(0,1)}),e.jsx("strong",{children:s.asset}),e.jsx("span",{children:s.chain})]}),e.jsxs("div",{className:"wallet-asset-values",children:[e.jsx("strong",{children:t}),e.jsx("span",{children:a})]})]})}function ga(s){switch(s.trim().toUpperCase()){case"ETH":return ts.ETH;case"USDC":return ts.USDC;default:return null}}function pa(s,t){if(!s)return`0 ${t}`;const a=Number(s);return Number.isFinite(a)?`${new Intl.NumberFormat("en-US",{maximumFractionDigits:a>=1?4:8}).format(a)} ${t}`:`${s} ${t}`}function fa(s){if(s===null)return"$0.00";const t=typeof s=="number"?s:Number(s);return Number.isFinite(t)?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(t):"$0.00"}function xa({connection:s,onError:t,onPayload:a}){const[n,l]=i.useState(""),[o,m]=i.useState(!1),[r,j]=i.useState(!1);i.useEffect(()=>{s||l("")},[s]);async function v(h,c){if(s){m(!0),t(null);try{const u=await E.switchOpenPondAccount(s,{handle:h,baseUrl:c??null}),g=await E.savePreferences(s,{defaultTeamId:null});a({...u,preferences:g.preferences})}catch(u){t(u instanceof Error?u.message:String(u))}finally{m(!1)}}}async function b(h){if(h.preventDefault(),!(!s||!n.trim())){m(!0),t(null);try{const c=await E.saveOpenPondAccount(s,{apiKey:n.trim(),setActive:!0}),u=await E.savePreferences(s,{defaultTeamId:null});a({...c,preferences:u.preferences}),l("")}catch(c){t(c instanceof Error?c.message:String(c))}finally{m(!1)}}}async function x(h){if(!(!s||!h.apiKey.trim())){m(!0),t(null);try{const c=h.handle?.trim(),u=h.environment?.trim(),g=await E.saveOpenPondAccount(s,{apiKey:h.apiKey.trim(),handle:c||void 0,baseUrl:h.baseUrl,apiBaseUrl:h.apiBaseUrl,environment:u||"custom",setActive:!0}),S=await E.savePreferences(s,{defaultTeamId:null});a({...g,preferences:S.preferences}),l("")}catch(c){throw t(c instanceof Error?c.message:String(c)),c}finally{m(!1)}}}async function f(){if(s){j(!0),t(null);try{a(await E.refreshOpenPondAccounts(s))}catch(h){t(h instanceof Error?h.message:String(h))}finally{j(!1)}}}return{apiKey:n,refreshingAccounts:r,saving:o,refreshAccounts:f,saveAccount:b,saveEnvironmentAccount:x,setApiKey:l,switchAccount:v}}function va({connection:s,onError:t,onPreferences:a,preferences:n,providers:l}){const[o,m]=i.useState(n.defaultBranchPrefix),[r,j]=i.useState(n.defaultNewProjectDirectory),[v,b]=i.useState(n.goalStorageLocation),[x,f]=i.useState(n.advancedWorkspaceControls),[h,c]=i.useState(n.contextCompaction.autoEnabled),[u,g]=i.useState(n.insightsEnabled),[S,d]=i.useState(!n.insightsModelRef),[y,R]=i.useState(n.insightsModelRef?.providerId??n.defaultChatProvider),[N,w]=i.useState(n.insightsModelRef?.modelId??n.defaultChatModel),[I,z]=i.useState(n.insightsEvidenceSources),[T,P]=i.useState(n.subagents.enabled),[p,C]=i.useState(n.subagents.delegationMode),[O,L]=i.useState(!n.subagents.defaultModelRef),[G,q]=i.useState(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),[$,M]=i.useState(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),[V,X]=i.useState(n.subagents.roles),[K,ee]=i.useState(n.subagents.maxConcurrentRuns),[te,F]=i.useState(n.subagents.maxConcurrentRunsPerProvider),[D,H]=i.useState(n.subagents.maxConcurrentRunsPerWorkspaceTarget),[ne,ae]=i.useState(!1),ge=O?null:{providerId:G,modelId:$.trim()},pe=T!==n.subagents.enabled||p!==n.subagents.delegationMode||!ja(ge,n.subagents.defaultModelRef)||K!==n.subagents.maxConcurrentRuns||te!==n.subagents.maxConcurrentRunsPerProvider||D!==n.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(V)!==JSON.stringify(n.subagents.roles);i.useEffect(()=>{m(n.defaultBranchPrefix),j(n.defaultNewProjectDirectory),b(n.goalStorageLocation),f(n.advancedWorkspaceControls),c(n.contextCompaction.autoEnabled),g(n.insightsEnabled),d(!n.insightsModelRef),R(n.insightsModelRef?.providerId??n.defaultChatProvider),w(n.insightsModelRef?.modelId??n.defaultChatModel),z(n.insightsEvidenceSources),P(n.subagents.enabled),C(n.subagents.delegationMode),L(!n.subagents.defaultModelRef),q(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),M(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),X(n.subagents.roles),ee(n.subagents.maxConcurrentRuns),F(n.subagents.maxConcurrentRunsPerProvider),H(n.subagents.maxConcurrentRunsPerWorkspaceTarget)},[n.defaultChatProvider,n.defaultChatModel,n.defaultBranchPrefix,n.defaultNewProjectDirectory,n.goalStorageLocation,n.advancedWorkspaceControls,n.contextCompaction.autoEnabled,n.insightsEnabled,n.insightsModelRef,n.insightsEvidenceSources,n.subagents]);function ue(A){R(A),w(U=>Oe(A,U,l))}function fe(A){q(A),M(U=>Oe(A,U,l))}function xe(){return O?n.defaultChatProvider:G}function ve(){return O?n.defaultChatModel:$}function J(A,U){X(_=>_.map(se=>se.id===A?U(se):se))}function je(A,U){J(A,_=>({..._,enabled:U}))}function B(A,U){J(A,_=>({..._,background:U}))}function Y(A,U){J(A,_=>{if(U)return{..._,modelRef:null};const se=_.modelRef?.providerId??xe(),be=_.modelRef?.modelId??ve();return{..._,modelRef:Me(se,be,l)??null}})}function Qe(A,U){J(A,_=>({..._,modelRef:Me(U,_.modelRef?.modelId??ve(),l)??null}))}function Ue(A,U){J(A,_=>{const se=_.modelRef?.providerId??xe(),be=U.trim();return{..._,modelRef:be?{providerId:se,modelId:be}:null}})}function Ne(A,U){J(A,_=>({..._,isolationMode:U}))}function $e(A,U){J(A,_=>({..._,toolPolicy:U}))}function Be(A,U){J(A,_=>({..._,peerMessages:U}))}function ze(A,U){J(A,_=>({..._,maxConcurrentRuns:me(U,1,16)}))}async function Pe(){let A=null;if(window.openpond?.selectFolder){const U=await window.openpond.selectFolder();if(U.canceled)return;A=U.path}else A=window.prompt("Default new project directory",r);A?.trim()&&j(A.trim())}async function Re(A){if(A.preventDefault(),!!s){ae(!0),t(null);try{a(await E.savePreferences(s,{defaultBranchPrefix:qe(o),defaultNewProjectDirectory:r.trim(),goalStorageLocation:v,advancedWorkspaceControls:x,contextCompaction:{...n.contextCompaction,autoEnabled:h},insightsEnabled:u,insightsModelRef:S?null:Me(y,N,l)??null,insightsEvidenceSources:I,subagents:{enabled:T,workspaceDefaultsVersion:n.subagents.workspaceDefaultsVersion,toolDefaultsVersion:n.subagents.toolDefaultsVersion,delegationMode:p,defaultModelRef:O?null:Me(G,$,l)??null,roles:V,maxConcurrentRuns:me(K,1,32),maxConcurrentRunsPerProvider:te===null?null:me(te,1,32),maxConcurrentRunsPerWorkspaceTarget:D===null?null:me(D,1,32)}}))}catch(U){t(U instanceof Error?U.message:String(U))}finally{ae(!1)}}}return{advancedWorkspaceControls:x,contextCompactionAutoEnabled:h,defaultBranchPrefix:o,defaultNewProjectDirectory:r,goalStorageLocation:v,insightsEnabled:u,insightsUseDefaultModel:S,insightsProvider:y,insightsModel:N,insightsEvidenceSources:I,subagentsEnabled:T,subagentDelegationMode:p,subagentsUseDefaultModel:O,subagentsProvider:G,subagentsModel:$,subagentRoles:V,subagentsMaxConcurrentRuns:K,subagentsMaxConcurrentRunsPerProvider:te,subagentsMaxConcurrentRunsPerWorkspaceTarget:D,subagentsDirty:pe,saving:ne,chooseDefaultProjectDirectory:Pe,saveDefaults:Re,changeInsightsProvider:ue,changeSubagentsProvider:fe,changeSubagentRoleProvider:Qe,setAdvancedWorkspaceControls:f,setContextCompactionAutoEnabled:c,setDefaultBranchPrefix:m,setDefaultNewProjectDirectory:j,setGoalStorageLocation:b,setInsightsEnabled:g,setInsightsUseDefaultModel:d,setInsightsModel:w,setSubagentsUseDefaultModel:L,setSubagentsModel:M,setInsightsEvidenceSourceEnabled:(A,U)=>z(_=>({..._,[A]:U})),setSubagentsEnabled:P,setSubagentDelegationMode:A=>C(A),setSubagentsMaxConcurrentRuns:A=>ee(me(A,1,32)),setSubagentsMaxConcurrentRunsPerProvider:A=>F(A===null?null:me(A,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:A=>H(A===null?null:me(A,1,32)),setSubagentRoleBackground:B,setSubagentRoleEnabled:je,setSubagentRoleIsolationMode:Ne,setSubagentRoleMaxConcurrentRuns:ze,setSubagentRoleModel:Ue,setSubagentRolePeerMessages:Be,setSubagentRoleToolPolicy:$e,setSubagentRoleUseDefaultModel:Y}}function me(s,t,a){return Number.isFinite(s)?Math.min(a,Math.max(t,Math.trunc(s))):t}function ja(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const ba=15e3,ya=100,Na=100,Sa=2500;function wa({onError:s,section:t}){const[a,n]=i.useState(null),[l,o]=i.useState(null),[m,r]=i.useState(ya),[j,v]=i.useState([]),[b,x]=i.useState(null),[f,h]=i.useState(!0),c=i.useRef(null),[u,g]=i.useState(null),S=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),y=!!window.openpond?.readRecentLogs?`${j.length} of ${m} line${m===1?"":"s"}${f?" tailing":""}`:"Unavailable";i.useEffect(()=>{t==="diagnostics"&&R(m,"refresh",{quiet:!0})},[t]),i.useEffect(()=>{if(t!=="diagnostics"||!f||!window.openpond?.readRecentLogs)return;let P=!1;const p=window.setInterval(()=>{P||(P=!0,R(m,"refresh",{quiet:!0}).finally(()=>{P=!1}))},Sa);return()=>window.clearInterval(p)},[t,f,m]),i.useEffect(()=>{if(t!=="diagnostics"||!f)return;const P=c.current;P&&(P.scrollTop=P.scrollHeight)},[t,f,j]);async function R(P=m,p="refresh",C={}){const O=window.openpond?.readRecentLogs;if(!O){const L="Log view is not available in this runtime.";C.quiet||(g({label:"Logs",value:L,warning:!0}),s(L));return}C.quiet||o(p);try{const L=await De(O(P),"Read logs");if(!L.ok)throw new Error(L.error);r(L.lineLimit),x(L.logDir),v(L.lines),C.quiet?g(G=>G?.label==="Logs"?null:G):g(null)}catch(L){const G=L instanceof Error?L.message:String(L);g({label:"Logs",value:G,warning:!0}),C.quiet||s(G)}finally{C.quiet||o(null)}}function N(){h(!1),R(m+Na,"older")}function w(){const P=!f;h(P),P&&R(m,"refresh",{quiet:!0})}async function I(){const P=window.openpond?.openLogsFolder;if(!P){const p="Desktop logs are not available in this runtime.";g({label:"Logs",value:p,warning:!0}),s(p);return}n("logs"),s(null);try{const p=await De(P(),"Open logs");if(!p.ok)throw new Error(p.error??"Could not open the logs folder.");g(null)}catch(p){const C=p instanceof Error?p.message:String(p);g({label:"Logs",value:C,warning:!0}),s(C)}finally{n(null)}}async function z(){const P=window.openpond?.copyRecentLogs;if(!P){const p="Recent log copy is not available in this runtime.";g({label:"Copy",value:p,warning:!0}),s(p);return}n("copy"),s(null);try{const p=await De(P(1e3),"Copy recent logs");if(!p.ok)throw new Error(p.error??"Could not copy recent logs.");g({label:"Copy",value:p.lines?`Copied ${p.lines} recent log lines.`:"Copied recent logs."})}catch(p){const C=p instanceof Error?p.message:String(p);g({label:"Copy",value:C,warning:!0}),s(C)}finally{n(null)}}async function T(){const P=window.openpond?.exportDiagnostics;if(!P){const p="Diagnostics export is not available in this runtime.";g({label:"Export",value:p,warning:!0}),s(p);return}n("export"),s(null);try{const p=await De(P(),"Export diagnostics");if(!p.ok)throw new Error(p.error??"Could not export diagnostics.");g({label:"Export",value:p.path?`Saved to ${p.path}`:"Diagnostics exported."})}catch(p){const C=p instanceof Error?p.message:String(p);g({label:"Export",value:C,warning:!0}),s(C)}finally{n(null)}}return{diagnosticsAvailable:S,diagnosticsBusy:a,diagnosticsStatus:u,logDir:b,logLineLimit:m,logLines:j,logViewBusy:l,logViewSummary:y,logViewportRef:c,tailLogs:f,copyRecentLogs:z,exportDiagnosticsBundle:T,loadOlderLogs:N,openLogsFolder:I,refreshLogView:R,toggleTailLogs:w}}async function De(s,t){let a;try{return await Promise.race([s,new Promise((n,l)=>{a=window.setTimeout(()=>{l(new Error(`${t} did not receive a desktop response.`))},ba)})])}finally{a!==void 0&&window.clearTimeout(a)}}function Ca({connection:s,enabled:t,onError:a,onPreferences:n,onToast:l,preferences:o}){const[m,r]=i.useState(o.editor),[j,v]=i.useState(null),[b,x]=i.useState(!1),[f,h]=i.useState(!1),[c,u]=i.useState(!1);i.useEffect(()=>{r(o.editor)},[o.editor]);const g=i.useCallback(async()=>{if(s){h(!0);try{v(await E.workspaceLspSettingsStatus(s))}catch(N){a(N instanceof Error?N.message:String(N))}finally{h(!1)}}},[s,a]);i.useEffect(()=>{!t||!s||g()},[s,t,g]);function S(N,w){r(I=>({...I,languages:{...I.languages,[N]:{...I.languages[N],mode:w}}}))}function d(N,w){r(I=>({...I,languages:{...I.languages,[N]:{...I.languages[N],customCommand:w}}}))}async function y(N){if(N.preventDefault(),!!s){x(!0),a(null);try{const w=await E.savePreferences(s,{editor:m});n(w),v(await E.workspaceLspSettingsStatus(s))}catch(w){a(w instanceof Error?w.message:String(w))}finally{x(!1)}}}async function R(){if(s){u(!0),a(null);try{await E.restartWorkspaceLsp(s),v(await E.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(N){a(N instanceof Error?N.message:String(N))}finally{u(!1)}}}return{editorPreferences:m,lspStatus:j,restarting:c,saving:b,statusLoading:f,refreshLspStatus:g,restartLanguageServers:R,saveEditorSettings:y,setEditorPreferences:r,setLanguageCustomCommand:d,setLanguageMode:S}}function ka({connection:s,onError:t,onPayload:a,personalization:n}){const l=i.useMemo(()=>n.templates.map(T=>({value:T.id,label:T.name,description:T.id===n.activeTemplateId?"Selected":T.source==="built_in"?T.description:void 0})),[n.activeTemplateId,n.templates]),[o,m]=i.useState(n.activeTemplateId),[r,j]=i.useState(n.soul),[v,b]=i.useState(""),[x,f]=i.useState(!1),[h,c]=i.useState(!1),u=n.templates.find(T=>T.id===o)??n.templates[0],g=u?.source==="custom",S=u?r!==u.content:!0,d=o!==n.activeTemplateId||r!==n.soul||S,y=!!(g&&r.trim()&&u&&d);i.useEffect(()=>{m(n.activeTemplateId),j(n.soul);const T=n.templates.find(P=>P.id===n.activeTemplateId);b(T?`${T.name} Copy`:""),f(!1)},[n.activeTemplateId,n.soul,n.templates]);async function R(T=!1){if(!T&&!g)return;const P=T?v:u?.name;if(!(!s||!r.trim()||!P?.trim())){c(!0),t(null);try{a(await E.savePersonalization(s,{activeTemplateId:o,templateName:P,soul:r,saveAsNew:T})),f(!1)}catch(p){t(p instanceof Error?p.message:String(p))}finally{c(!1)}}}async function N(T){const P=n.templates.find(p=>p.id===T);if(P&&(m(P.id),b(`${P.name} Copy`),j(P.content),f(!1),!!s)){c(!0),t(null);try{a(await E.savePersonalization(s,{activeTemplateId:P.id,templateName:P.name,soul:P.content,saveAsNew:!1}))}catch(p){t(p instanceof Error?p.message:String(p))}finally{c(!1)}}}function w(){u&&(b(`${u.name} Copy`),j(u.content),f(!1))}function I(T){j(T),u&&!g&&T!==u.content&&f(!0)}function z(){u&&(b(`${u.name} Copy`),f(!0))}return{canSaveCurrentTemplate:y,personalizationTemplateId:o,personalizationTemplateOptions:l,saveAsNewOpen:x,saving:h,selectedPersonalizationTemplate:u,selectedTemplateIsCustom:g,soulDraft:r,templateNameDraft:v,changePersonalizationTemplate:N,changeSoulDraft:I,openSaveAsNew:z,resetPersonalizationDraft:w,savePersonalization:R,setSaveAsNewOpen:f,setTemplateNameDraft:b}}function Pa({connection:s,onError:t,onPreferences:a,onProviders:n,preferences:l,providers:o}){const[m,r]=i.useState(l.defaultChatProvider),[j,v]=i.useState(l.defaultChatModel),[b,x]=i.useState(!1),[f,h]=i.useState(null),[c,u]=i.useState(null);i.useEffect(()=>{r(l.defaultChatProvider),v(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function g(p){if(p.preventDefault(),!!s){x(!0),t(null);try{a(await E.savePreferences(s,{defaultChatProvider:m,defaultChatModel:Oe(m,j,o)}))}catch(C){t(C instanceof Error?C.message:String(C))}finally{x(!1)}}}function S(p){r(p),v(C=>Oe(p,C,o))}async function d(p,C,O){if(!s)return null;h(`${p}:${C}`),u(null),t(null);try{return await O()}catch(L){return t(L instanceof Error?L.message:String(L)),null}finally{h(null)}}async function y(p,C){await d(p,"config",async()=>{const O=await E.saveProviderSettings(s,{providers:{[p]:C}});return n(O),O})}async function R(p,C){await d(p,"credential",async()=>{const O=await E.saveProviderCredential(s,p,C);return n(O),O})}async function N(p){await d(p,"credential",async()=>{const C=await E.deleteProviderCredential(s,p,{});return n(C),C})}async function w(p){return d("openai","credential",async()=>{const C=await E.startOpenAiSubscriptionAuth(s,{method:p});return C.method==="browser"?(window.open(C.url,"_blank","noopener,noreferrer"),u("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(C.url,"_blank","noopener,noreferrer"),u(`OpenAI device login started. Enter code ${C.userCode}.`)),I(C.expiresAt),C})}async function I(p){if(s)for(;Date.now()<p;){await new Promise(C=>setTimeout(C,2500));try{const C=await E.providerSettings(s);n(C);const O=C.statuses.openai?.credential;if(O?.connected&&O.source==="chatgpt_subscription"){u("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function z(p){await d(p,"models",async()=>{const C=await E.refreshProviderModels(s,p,{force:!0});return n(C.providers),C})}async function T(p){await d(p,"models",async()=>{const C=await E.loadProviderModels(s,p,{limit:500});return n(C.providers),C})}async function P(p,C={}){await d(p,"validate",async()=>{const O=await E.validateProviderCredential(s,p,C);return u(O.ok?`${p} validated${O.modelId?` with ${O.modelId}`:""}.`:O.errors.join(`
6
- `)||`${p} validation failed.`),n(O.providers),O})}return{defaultModel:j,defaultProvider:m,providerBusy:f,saving:b,validationMessage:c,changeDefaultProvider:S,deleteProviderCredential:N,loadProviderModels:T,refreshProviderModels:z,saveProviderConfig:y,saveProviderCredential:R,saveProviders:g,setDefaultModel:v,startOpenAiSubscriptionAuth:w,validateProvider:P}}function Ra({connection:s,enabled:t,onError:a,onToast:n}){const[l,o]=i.useState(null),[m,r]=i.useState(null),[j,v]=i.useState(!1),b=i.useRef(null),x=i.useCallback(async(w={})=>{if(s){w.quiet||r("refresh");try{const I=await E.remoteAccess(s);o(I),a(null)}catch(I){a(I instanceof Error?I.message:String(I))}finally{w.quiet||r(null)}}},[s,a]);i.useEffect(()=>{!t||!s||x({quiet:!0})},[s,t,x]),i.useEffect(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function f(){b.current!==null&&window.clearTimeout(b.current),v(!1),window.setTimeout(()=>{v(!0),b.current=window.setTimeout(()=>{v(!1),b.current=null},1500)},0)}async function h(){if(a(null),!!s)try{o(await E.remoteAccess(s))}catch{}}async function c(){if(!s)return null;l&&!l.tailscale.running&&f(),r("enable");try{const w=await E.enableRemoteAccess(s);return o(w.status),a(null),w.status.tailscale.running?!w.status.serve.enabled&&w.status.serve.error&&n?.(w.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":w.message||w.status.serve.error,"error"):(f(),n?.(w.message||"Tailscale is not running. Run Tailscale up first.","error")),w.status}catch{return await h(),f(),n?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{r(null)}}async function u(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){r("disable");try{const w=await E.disableRemoteAccess(s);o(w.status),a(null)}catch{await h()}finally{r(null)}}}async function g(){l?.remoteWebUrl&&(r("copy-link"),await oe(l.remoteWebUrl),r(null))}async function S(){l?.serveCommand&&(r("copy-command"),await oe(l.serveCommand),r(null))}async function d(){l?.serve.setupUrl&&(r("copy-serve-setup"),await oe(l.serve.setupUrl),r(null))}async function y(){l?.tailscaleUpCommand&&(r("copy-up-command"),await oe(l.tailscaleUpCommand),r(null))}async function R(){l?.operatorCommand&&(r("copy-operator"),await oe(l.operatorCommand),r(null))}async function N(){if(!l?.serve.enabled){const w=await c();w?.serve.enabled&&w.remoteWebUrl&&await oe(w.remoteWebUrl);return}await g()}return{status:l,busy:m,flashTailscaleUp:j,refresh:x,enableRemoteAccess:c,disableRemoteAccess:u,copyRemoteLink:g,copyTailscaleUpCommand:y,copyServeCommand:S,copyServeSetupUrl:d,copyOperatorCommand:R,createRemoteLink:N}}function Ma(s){const{connection:t,enabled:a,onError:n}=s,[l,o]=i.useState(null),[m,r]=i.useState(null),j=i.useCallback(async()=>{if(t){r("load");try{const c=await E.computeState(t);o(c),n(null)}catch(c){n(Se(c))}finally{r(null)}}},[t,n]),v=i.useCallback(async()=>{if(t){r("scan");try{const c=await E.scanCompute(t),u=await E.computeState(t);o({...u,inventory:c,scanning:!1}),n(null)}catch(c){n(Se(c))}finally{r(null)}}},[t,n]),b=i.useCallback(async(c,u,g)=>{if(!t)return!1;r("save");try{const S=await E.updateComputeSettings(t,{modelStorePath:c,datasetStorePath:u,defaultDeviceIds:g}),d=await E.computeState(t);return o({...d,settings:S}),n(null),!0}catch(S){return n(Se(S)),!1}finally{r(null)}},[t,n]),x=i.useCallback(async()=>{if(t)try{await E.downloadSmolLm2(t),await j()}catch(c){n(Se(c))}},[t,n,j]),f=i.useCallback(async c=>{if(t)try{await E.cancelModelDownload(t,c),await j()}catch(u){n(Se(u))}},[t,n,j]);i.useEffect(()=>{a&&j()},[a,j]);const h=l?.inventory?.downloads.some(c=>["queued","downloading","verifying","cancelling"].includes(c.status))??!1;return i.useEffect(()=>{if(!a||!h)return;const c=window.setInterval(()=>{j()},1e3);return()=>window.clearInterval(c)},[a,h,j]),{state:l,busy:m,refresh:j,scan:v,save:b,downloadSmolLm2:x,cancelDownload:f}}function Se(s){return s instanceof Error?s.message:String(s)}function Ia(s){const{connection:t,enabled:a,onError:n,profileId:l}=s,[o,m]=i.useState(null),[r,j]=i.useState(!1),v=i.useCallback(async()=>{if(t){j(!0);try{m(await E.datasetCatalog(t,l)),n(null)}catch(b){n(Da(b))}finally{j(!1)}}},[t,n,l]);return i.useEffect(()=>{a&&v()},[a,v]),{catalog:o,loading:r,refresh:v}}function Da(s){return s instanceof Error?s.message:String(s)}const Aa=i.lazy(()=>Ct(()=>import("./UsageSettingsSection-DKky0p47.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function Ha({payload:s,connection:t,diagnostics:a,onPayload:n,onError:l,onToast:o,onBack:m,onOpenSourceSession:r,onOpenNativeSkill:j,teamChatCurrentUserId:v,teamChatEnabled:b,teamChatNotificationMode:x,teamChatThreads:f,onTeamChatNotificationModeChange:h,onTeamChatThreadMuteChange:c,initialSection:u="account"}){const[g,S]=i.useState(u),d=s?.codex??null,y=i.useMemo(()=>bt(s?.preferences),[s?.preferences]),R=s?.personalization??yt,N=a??s?.diagnostics??[],w=Nt()&&St(t?.platform),I=i.useCallback(F=>{s&&n({...s,providers:F})},[n,s]),z=i.useCallback(F=>{s&&n({...s,preferences:F.preferences})},[n,s]),T=xa({connection:t,onError:l,onPayload:n}),P=Pa({connection:t,onError:l,onPayload:n,onPreferences:z,onProviders:I,preferences:y,providers:s?.providers??null}),p=va({connection:t,onError:l,onPayload:n,onPreferences:z,preferences:y,providers:s?.providers??null}),C=Ca({connection:t,enabled:g==="editor",onError:l,onPayload:n,onPreferences:z,onToast:o,preferences:y}),O=ka({connection:t,onError:l,onPayload:n,personalization:R}),L=wa({onError:l,section:g}),G=Ra({connection:t,enabled:g==="remote",onError:l,onToast:o}),q=g==="dataset-storage",$=Ma({connection:t,enabled:g==="compute"||q,onError:l}),M=Ia({connection:t,enabled:q,onError:l,profileId:s?.profile.activeProfile??"default"}),V=i.useCallback(F=>$.save($.state?.settings.modelStorePath??null,F,$.state?.settings.defaultDeviceIds??[]),[$.save,$.state?.settings.defaultDeviceIds,$.state?.settings.modelStorePath]),X=i.useCallback(async()=>{await Promise.all([$.refresh(),M.refresh()])},[$.refresh,M.refresh]),K=i.useCallback(()=>g!=="subagents"||!p.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[p.subagentsDirty,g]),ee=i.useCallback(F=>{F!==g&&K()&&S(F)},[K,g]),te=i.useCallback(()=>{K()&&m()},[K,m]);return i.useEffect(()=>{S(u)},[u]),i.useEffect(()=>{if(g!=="subagents"||!p.subagentsDirty)return;const F=D=>{D.preventDefault(),D.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",F),()=>window.removeEventListener("beforeunload",F)},[p.subagentsDirty,g]),e.jsxs("div",{className:`settings-shell ${w?"platform-macos":""}`,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsx("div",{className:"settings-window-controls",children:e.jsx(wt,{platform:t?.platform})}),e.jsx(Fn,{section:g,onBack:te,onSectionChange:ee}),e.jsx("main",{className:"settings-content",children:g==="account"?e.jsx(Jt,{payload:s,connection:t,onPayload:n,onPreferences:z,onError:l,onToast:o,...T}):g==="notifications"?e.jsx(vn,{currentUserId:v,enabled:b,mode:x,threads:f,onModeChange:h,onThreadMuteChange:c}):g==="wallet"?e.jsx(da,{payload:s}):g==="profile"?e.jsx(Pt,{payload:s,connection:t,onPayload:n,onError:l,onToast:o}):g==="skills"?e.jsx(Gn,{onOpenNativeSkill:j}):g==="providers"?e.jsx(Tn,{account:s?.account??null,codex:d,providers:s?.providers??null,...P}):g==="compute"?e.jsx(ea,{state:$.state,busy:$.busy,onScan:$.scan,onSave:$.save,onDownloadSmolLm2:$.downloadSmolLm2,onCancelDownload:$.cancelDownload}):g==="dataset-storage"?e.jsx(la,{state:$.state,catalog:M.catalog,busy:$.busy,catalogLoading:M.loading,onRefresh:X,onSave:V}):g==="defaults"?e.jsx(Xt,{preferences:y,...p}):g==="goals"?e.jsx(an,{preferences:y,...p}):g==="context"?e.jsx(ln,{preferences:y,...p}):g==="insights"?e.jsx(rn,{preferences:y,providers:s?.providers??null,...p}):g==="training"?e.jsx(Wn,{connection:t,onError:l,onPreferences:z,preferences:y,providers:s?.providers??null}):g==="subagents"?e.jsx(on,{preferences:y,providers:s?.providers??null,...p}):g==="editor"?e.jsx(nn,{preferences:y,...C}):g==="remote"?e.jsx(Un,{...G}):g==="usage"?e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(Aa,{account:s?.account??null,connection:t,enabled:g==="usage",onError:l,onOpenSourceSession:r})}):g==="personalization"?e.jsx(bn,{...O}):e.jsx(Qt,{diagnostics:N,...L})})]})}export{Ha as SettingsView};
5
+ `))},[h.baseUrl,h.defaultModel,h.modelOverrides,I.baseUrl,I.defaultModel,I.modelOverrides,n]);const fe=T==="env"?!!O.trim():!!p.trim();async function xe(B){B.preventDefault(),await v(n,{enabled:!0,baseUrl:S.trim()||null,defaultModel:y.trim()||null,modelOverrides:hs(N)}),z({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function ve(B){if(B.preventDefault(),!!fe){if(T==="env"){await b(n,{source:"env",envVar:O.trim()});return}await b(n,{source:"local_secret",value:p}),C("")}}function J({panel:B=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:B?F:void 0,role:B?"tabpanel":void 0,"aria-labelledby":B?`${t}-${s}`:void 0,onSubmit:Y=>{ve(Y)},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(Ce,{value:T,disabled:q,label:"Credential source",options:yn,onChange:Y=>P(Y)})]}),T==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:O,disabled:q,placeholder:"PROVIDER_API_KEY",onChange:Y=>L(Y.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:ne}),e.jsx("input",{type:"password",value:p,disabled:q,placeholder:ae,autoComplete:"off",onChange:Y=>C(Y.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:q||!fe,children:[q?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(le,{size:14}),e.jsx("span",{children:q?"Saving":ge})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${m.displayName} credential`,disabled:q||!m.credential.connected,onClick:()=>{r(n)},children:e.jsx(es,{size:15})})]})]})}function je(){return X?e.jsxs("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(le,{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:V,onClick:()=>{x("browser")},children:[V?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(le,{size:14}),e.jsx("span",{children:V?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:V,onClick:()=>{x("device")},children:[V?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(le,{size:14}),e.jsx("span",{children:"Device code"})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${m.displayName} credential`,disabled:V||!m.credential.connected,onClick:()=>{r(n)},children:e.jsx(es,{size:15})})]})]}):K?e.jsx("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:e.jsxs("div",{className:"provider-dialog-note xai-provider-note",children:[e.jsx(le,{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."})]})}):ee?e.jsxs("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note subscription-provider-note",children:[e.jsx(le,{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."})]}),J({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[D?null:e.jsxs("form",{className:"provider-card-form",onSubmit:B=>{xe(B)},children:[e.jsxs("div",{className:"provider-card-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{value:S,disabled:G,placeholder:"https://api.example.com/v1",onChange:B=>{z(Y=>({...Y,baseUrl:!0})),d(B.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:u,value:y,disabled:G,placeholder:"Model id",onChange:B=>{z(Y=>({...Y,defaultModel:!0})),R(B.currentTarget.value)}}),e.jsx("datalist",{id:u,children:pe.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))}),ue>0?e.jsxs("small",{children:[ue," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:G,children:[G?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(Ye,{size:14}),e.jsx("span",{children:G?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:M,onClick:()=>{j(n)},children:[M?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(he,{size:14}),e.jsx("span",{children:M?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:$||!y.trim(),onClick:()=>{f(n,{baseUrl:S.trim()||void 0,modelId:y.trim()||void 0})},children:[$?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(ws,{size:14}),e.jsx("span",{children:$?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:D?je():J()})]})}function Un({status:s,busy:t,flashTailscaleUp:a,refresh:n,enableRemoteAccess:l,disableRemoteAccess:o,copyRemoteLink:m,copyTailscaleUpCommand:r,copyServeCommand:j,copyServeSetupUrl:v,copyOperatorCommand:b,createRemoteLink:x}){const f=s?.tailscale.installed??!1,h=s?.serve.enabled??!1,c=s?.serve.reachable??!1,u=!!(s?.webUiAvailable&&f),g=h?!!s?.remoteWebUrl:u,d=(s?.tailscale.peers??[]).filter(N=>!N.isSelf),y=!!s?.tailscale.error?.includes("set --operator"),R=!!(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 ${c?"online":h?"configured":""}`,children:f?e.jsx(Ms,{size:18}):e.jsx(Dt,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:c?"Tailscale Serve is reachable":h?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?zn(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:t!==null,onClick:()=>{n()},children:e.jsx(he,{className:t==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:t!==null||!f||!h&&!u,onClick:()=>{h?o():l()},children:[e.jsx(Ft,{size:15}),e.jsx("span",{children:h?t==="disable"?"Turning off":"Turn off":t==="enable"?"Turning on":"Turn on"})]})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsx("div",{className:"account-list-heading remote-access-link-heading",children:e.jsxs("div",{children:[e.jsx("span",{children:"OpenPond link"}),e.jsx("small",{children:R?"Browser UI":"Tailscale + Serve"})]})}),R&&e.jsx(ie,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:t==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||t!==null,onAction:m}),e.jsx(ie,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:a,actionLabel:t==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||t!==null,onAction:r}),e.jsx(ie,{label:"Serve command",value:s?.serveCommand??null,actionLabel:t==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||t!==null,onAction:j}),s?.serve.setupUrl&&e.jsx(ie,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:t==="copy-serve-setup"?"Copying":"Copy",disabled:t!==null,onAction:v}),y&&e.jsx(ie,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:t==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||t!==null,onAction:b}),e.jsx(ie,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(ie,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(ie,{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:[d.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:t!==null||!g,onClick:()=>{x()},children:e.jsx("span",{children:h?"Copy link":"Create link"})})]}),s?d.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."})]}):d.map(N=>e.jsx(Bn,{peer:N},N.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($n,{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 ie({actionLabel:s,disabled:t,flash:a,label:n,onAction:l,value:o}){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:n}),e.jsx("code",{children:o??"Not available"})]}),l&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:t,onClick:()=>{l()},children:e.jsx("span",{children:s??"Copy"})})]})}function $n({status:s}){const t=[{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:t.map(n=>e.jsx(xs,{label:n.label,value:n.value},n.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(n=>e.jsx(xs,{label:n.label,value:n.value},n.label))})]})}function xs({label:s,value:t}){return e.jsxs("div",{className:"remote-access-environment-cell",children:[e.jsx("strong",{children:s}),e.jsx("span",{children:t})]})}function Bn({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 zn(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 _n=[{items:[{section:"account",label:"Account",Icon:Vt},{section:"notifications",label:"Notifications",Icon:ks},{section:"providers",label:"Providers",Icon:ct},{section:"compute",label:"Compute",Icon:At},{section:"dataset-storage",label:"Dataset Storage",Icon:Bt},{section:"wallet",label:"Wallet",Icon:Ps},{section:"usage",label:"Activity",Icon:dt},{section:"defaults",label:"Defaults",Icon:Is}]},{label:"Harness",items:[{section:"profile",label:"My Profile",Icon:ut},{section:"skills",label:"Skills",Icon:Cs},{section:"goals",label:"Goals",Icon:ns},{section:"context",label:"Context",Icon:mt},{section:"insights",label:"Insights",Icon:ht},{section:"training",label:"Training",Icon:ss},{section:"subagents",label:"Subagents",Icon:ss}]},{items:[{section:"editor",label:"Editor",Icon:Ut},{section:"remote",label:"Remote",Icon:Ms},{section:"personalization",label:"Personalization",Icon:gt},{section:"diagnostics",label:"Diagnostics",Icon:ns}]}];function Fn({section:s,onBack:t,onSectionChange:a}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back",onClick:t,children:[e.jsx(ot,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:_n.map((n,l)=>e.jsxs("div",{className:"settings-nav-group",children:[n.label?e.jsx("div",{className:"settings-nav-heading",children:n.label}):null,n.items.map(({section:o,label:m,Icon:r})=>e.jsxs("button",{className:`settings-nav-item ${s===o?"active":""}`,onClick:()=>a(o),children:[e.jsx(r,{size:16}),e.jsx("span",{children:m})]},o))]},n.label??`settings-${l}`))})]})}function Gn({onOpenNativeSkill:s}){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:"Read-only operating instructions that ship with OpenPond and are loaded when an agent uses the matching app."})]})}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Native skills"}),e.jsx("small",{children:"Bundled with this OpenPond build"})]}),pt.map(t=>{const a=ft(t.provider)?.label??t.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(t),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Cs,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:t.name}),e.jsx("span",{children:t.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:a}),e.jsx("span",{children:t.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(xt,{size:16,"aria-hidden":"true"})]},t.name)})]})]})}const Xe="default";function Wn({connection:s,embedded:t=!1,onError:a,onPreferences:n,preferences:l,providers:o}){const m=l.training,[r,j]=i.useState(We(m.defaultModelRef)),[v,b]=i.useState(m.creationMode),[x,f]=i.useState(m.autoApproveEvidence),[h,c]=i.useState(!1),u=i.useMemo(()=>Je(o,{includeUnavailable:!0}),[o]),g=i.useMemo(()=>u.map(N=>({provider:N,models:ke(N.value,o)})).filter(N=>N.models.length>0),[u,o]),S=qn(r),d=vt(l.defaultChatProvider,l.defaultChatModel,o)?` · ${Vn(l.codexReasoningEffort)} reasoning`:"",y=Kn(S,m.defaultModelRef??null)&&v===m.creationMode&&x===m.autoApproveEvidence;i.useEffect(()=>{j(We(m.defaultModelRef)),b(m.creationMode),f(m.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,m.autoApproveEvidence,m.creationMode,m.defaultModelRef]);async function R(N){if(N.preventDefault(),!!s){c(!0),a(null);try{n(await E.savePreferences(s,{training:{defaultModelRef:S,creationMode:v,autoApproveEvidence:x}}))}catch(w){a(w instanceof Error?w.message:String(w))}finally{c(!1)}}}return e.jsxs("section",{className:`account-settings training-settings${t?" embedded":""}`,children:[t?null:e.jsx("h1",{children:"Training"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:N=>{R(N)},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:r,disabled:h,onChange:N=>j(N.target.value),children:[e.jsxs("option",{value:Xe,children:["Use chat default — ",ye(l.defaultChatProvider,o)," · ",Ee(l.defaultChatModel,o,l.defaultChatProvider),d]}),g.map(N=>e.jsx("optgroup",{label:N.provider.label,children:N.models.map(w=>e.jsx("option",{value:We({providerId:N.provider.value,modelId:w.value}),children:w.label},w.value))},N.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:v,disabled:h,onChange:N=>b(N.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:x,disabled:h,onChange:N=>f(N.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||y,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:S?`${ye(S.providerId,o)} / ${Ee(S.modelId,o,S.providerId)}`:"Chat default"})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Safety boundary"}),e.jsx("strong",{children:"Taskset and training approvals always required"})]})]})}function We(s){return s?JSON.stringify([s.providerId,s.modelId]):Xe}function qn(s){if(s===Xe)return null;try{const t=JSON.parse(s);return!Array.isArray(t)||t.length!==2||typeof t[0]!="string"||typeof t[1]!="string"?null:{providerId:t[0],modelId:t[1]}}catch{return null}}function Vn(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function Kn(s,t){return s?.providerId===t?.providerId&&s?.modelId===t?.modelId}function Ls({disabled:s,onChange:t,purpose:a="model",storageRoots:n,value:l}){const o=i.useId(),[m,r]=i.useState(!1),j=vs(l),v=f=>a==="dataset"?f.datasetStorePath:f.modelStorePath,b=a==="dataset"?"Dataset":"Model",x=n.find(f=>vs(v(f))===j)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:o,children:[b," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${b} storage drive`,className:"model-storage-select",disabled:s,id:o,title:l??`No ${a} storage configured`,value:l??"",onChange:f=>t(f.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),l&&!x?e.jsx("option",{value:l,children:"Manual location"}):null,n.map(f=>e.jsxs("option",{disabled:!f.mounted||!f.writable,title:v(f),value:v(f),children:[f.label," · ",Zn(f.kind)," · ",Xn(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 ${a} storage location`,onClick:()=>r(!0),children:e.jsx(He,{size:15})})]}),m?Hn(e.jsx(Jn,{initialPath:l??"",purpose:a,onClose:()=>r(!1),onUse:f=>{t(f),r(!1)}})):null]})}function Hn(s){return typeof document>"u"?s:Tt.createPortal(s,document.body)}function Jn({initialPath:s,onClose:t,onUse:a,purpose:n="model"}){const l=i.useId(),[o,m]=i.useState(s),r=Yn(o);i.useEffect(()=>{const v=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[t]);function j(v){v.preventDefault(),v.stopPropagation(),!r&&a(o.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:j,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${n} storage`,onClick:t,children:e.jsx(Le,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(jt,{size:18})}),e.jsxs("h2",{id:l,children:["Manual ",n," 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:o,placeholder:n==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:v=>m(v.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."}),o.trim()&&r?e.jsx("div",{className:"profile-dialog-warning",children:r}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",type:"button",onClick:t,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:!!r,type:"submit",children:"Use location"})]})]})})}function Yn(s){const t=s.trim();return t?/^[a-z][a-z\d+.-]*:\/\//i.test(t)?"Use the mounted folder path, not an smb:// or other network URL.":t==="~"||t.startsWith("~/")||t.startsWith("/")||t.startsWith("\\\\")||/^[a-z]:[\\/]/i.test(t)?null:"Enter an absolute mounted folder path.":"Enter a mounted folder path."}function Zn(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function Xn(s){return s.mounted?s.writable?`${Qn(s.freeBytes)} free`:"Read only":"Not mounted"}function vs(s){const t=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(t)?t.toLowerCase():t}function Qn(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function ea({state:s,busy:t,title:a="Compute",onScan:n,onSave:l,onDownloadSmolLm2:o,onCancelDownload:m}){const r=s?.inventory??null,[j,v]=i.useState(s?.settings.modelStorePath??null),[b,x]=i.useState(s?.settings.defaultDeviceIds[0]??"automatic");i.useEffect(()=>{v(s?.settings.modelStorePath??null)},[s?.settings.modelStorePath]),i.useEffect(()=>{x(s?.settings.defaultDeviceIds[0]??"automatic")},[s?.settings.defaultDeviceIds]);const f=j===(s?.settings.modelStorePath??null)&&b===(s?.settings.defaultDeviceIds[0]??"automatic"),h=i.useMemo(()=>r?.devices.filter(d=>d.kind!=="cpu"&&d.available)??[],[r?.devices]),c=r?.models.find(d=>d.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,u=[...r?.downloads??[]].reverse().find(d=>d.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,g=!!(u&&["queued","downloading","verifying","cancelling"].includes(u.status));async function S(d){d.preventDefault(),await l(j,s?.settings.datasetStorePath??null,b==="automatic"?[]:[b])}return e.jsxs("section",{className:"account-settings compute-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsx("h1",{children:a}),e.jsx("button",{className:"settings-icon-button",type:"button",title:"Scan compute","aria-label":"Scan compute",disabled:t!==null,onClick:()=>{n()},children:e.jsx(he,{size:15,className:t==="scan"?"settings-spin":void 0})})]}),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:r?`${r.host.operatingSystem} · ${r.host.architecture}`:t==="load"?"Loading this machine":"This machine has not been scanned"}),e.jsx("small",{children:r?`${r.devices.length} device${r.devices.length===1?"":"s"} · ${we(r.host.totalMemoryBytes)} memory · scanned ${aa(r.scannedAt)}`:"Run a bounded native scan to discover local training capabilities."})]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:d=>{S(d)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Defaults"})}),e.jsx(Ls,{disabled:t!==null,storageRoots:r?.storageRoots??[],value:j,onChange:v}),e.jsx("div",{className:"provider-settings-grid single compute-device-default",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default device"}),e.jsxs("select",{value:b,disabled:t!==null,onChange:d=>x(d.target.value),children:[e.jsx("option",{value:"automatic",children:"Automatic"}),h.map(d=>e.jsx("option",{value:d.id,children:d.name},d.id))]})]})}),e.jsx("button",{className:"settings-primary",disabled:t!==null||f,children:t==="save"?"Saving":"Save compute settings"})]}),e.jsx(js,{title:"Devices",empty:"No devices discovered",rows:(r?.devices??[]).map(d=>({id:d.id,title:d.name,detail:sa(d),meta:d.available?"Available":d.unavailableReason??"Unavailable"}))}),e.jsx(js,{title:"Runtimes",empty:"No runtimes discovered",rows:(r?.runtimes??[]).map(d=>({id:d.id,title:ta(d.kind),detail:d.version??d.detail??"Not installed",meta:d.state==="available"?"Available":"Unavailable"}))}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Models"}),e.jsxs("div",{className:"compute-heading-actions",children:[g&&u?e.jsx("button",{type:"button",className:"settings-secondary",disabled:u.status==="cancelling",onClick:()=>{m(u.id)},children:u.status==="cancelling"?"Cancelling":"Cancel"}):c?null:e.jsx("button",{type:"button",className:"settings-secondary",disabled:!s?.settings.modelStorePath,onClick:()=>{o()},children:"Download SmolLM2"}),e.jsx("small",{children:r?.models.length??0})]})]}),u&&!c?e.jsxs("div",{className:"compute-download-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"SmolLM2 135M Instruct"}),e.jsx("small",{children:u.status==="failed"?u.error:`${na(u.status)} · ${we(u.downloadedBytes)} of ${we(u.expectedBytes)} · Apache-2.0`})]}),e.jsx("progress",{max:u.expectedBytes,value:u.downloadedBytes})]}):null,r?.models.length?r.models.map(d=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:d.name}),e.jsxs("small",{children:[d.source," · ",d.format," · ",we(d.sizeBytes)]})]}),e.jsx("span",{children:d.trainingCompatible?"Trainable":d.inferenceCompatible?"Inference only":"Unsupported"})]},d.id)):u?null:e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"No recognized local models"})})]}),r?.warnings.length?e.jsxs("details",{className:"compute-diagnostics",children:[e.jsx("summary",{children:"Diagnostics"}),e.jsx("ul",{children:r.warnings.map(d=>e.jsx("li",{children:d},d))})]}):null]})}function js({title:s,empty:t,rows:a}){return e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:s}),e.jsx("small",{children:a.length})]}),a.length?a.map(n=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:n.title}),e.jsx("small",{children:n.detail})]}),e.jsx("span",{children:n.meta})]},n.id)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t})})]})}function sa(s){return[s.vendor,s.kind,s.totalMemoryBytes?we(s.totalMemoryBytes):null,s.computeCapability?`compute ${s.computeCapability}`:null].filter(Boolean).join(" · ")}function ta(s){return s==="trl_peft"?"TRL / PEFT":s.toUpperCase()}function na(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function aa(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function we(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function la({state:s,catalog:t,busy:a,catalogLoading:n,onRefresh:l,onSave:o}){const[m,r]=i.useState(s?.settings.datasetStorePath??null);i.useEffect(()=>{r(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const j=i.useMemo(()=>s?.inventory?.storageRoots.find(f=>bs(f.datasetStorePath)===bs(m))??null,[m,s?.inventory?.storageRoots]),v=m===(s?.settings.datasetStorePath??null),b=t?.datasets??[];async function x(f){f.preventDefault(),await o(m)}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||n,onClick:()=>{l()},title:"Refresh Dataset storage",type:"button",children:e.jsx(he,{className:n?"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:j?.label??(m?"Manual location":"Not configured")}),e.jsx("small",{children:m??"Choose a writable local or mounted location before importing a Dataset."}),j?e.jsxs("small",{children:[ca(j.kind)," · ",j.freeBytes==null?"Free space unknown":`${Us(j.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:f=>{x(f)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(Ls,{disabled:a!==null,onChange:r,purpose:"dataset",storageRoots:s?.inventory?.storageRoots??[],value:m}),e.jsx("button",{className:"settings-primary",disabled:a!==null||v,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:b.length})]}),b.length?b.map(f=>e.jsx(ia,{dataset:f},f.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:n?"Loading registered Datasets":"No registered Datasets"})})]})]})}function ia({dataset:s}){const t=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:[$s(s.rowCount)," rows"," · ",ra(s)," · ",t," · ",s.sizeBytes==null?"Size unavailable":Us(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?oa(s.status):"Unavailable"})]})}function ra(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,n])=>`${$s(Number(n))} ${a}`).join(" · ")||"No split rows"}function Us(s){if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function $s(s){return new Intl.NumberFormat().format(s)}function bs(s){return s?.replace(/[\\/]+$/,"")??""}function oa(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function ca(s){return s.replace(/^./,t=>t.toUpperCase())}function da({payload:s}){const t=s?.account??null,a=t?.profile??null,n=t?.products??[],l=t?.balance?.breakdown??[],o=t?.state==="signed_in"?t?.label??t?.activeProfile?.handle??"OpenPond account":"Not signed in",m=a?.turnkeyOperatingWalletAddress??null,r=n.length>0?n.map(x=>x.name).join(", "):"None",j=[{label:"Personal wallet",address:a?.turnkeyWalletAddress??null},{label:"Operating wallet",address:m}],v=t?.state??"loading",b=v==="signed_in"?"active":void 0;return e.jsxs("section",{className:"wallet-view","aria-label":"Wallet",children:[e.jsxs("div",{className:"wallet-credit-card",children:[e.jsxs("div",{className:"wallet-card-top",children:[e.jsxs("div",{className:"wallet-card-brand",children:[e.jsx(Ps,{size:18}),e.jsx("span",{children:"OpenPond"})]}),e.jsx(Ae,{state:v,label:b})]}),e.jsxs("div",{className:"wallet-card-balance",children:[e.jsx("span",{children:"Balance"}),e.jsx("strong",{children:t?.balanceLabel??"$0.00"}),e.jsx(ua,{address:m})]}),e.jsxs("div",{className:"wallet-card-bottom",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Account"}),e.jsx("strong",{children:o})]}),e.jsxs("div",{className:"wallet-card-products",children:[e.jsx("span",{children:"Products"}),e.jsx("strong",{title:r,children:r})]})]})]}),e.jsxs("div",{className:"wallet-content-grid",children:[e.jsxs("section",{className:"wallet-panel",children:[e.jsx("div",{className:"wallet-panel-header",children:e.jsx("div",{children:e.jsx("span",{children:"Assets"})})}),e.jsx("div",{className:"wallet-asset-list",children:l.length>0?l.map(x=>e.jsx(ha,{asset:x},`${x.wallet}-${x.chain}-${x.asset}`)):e.jsx("div",{className:"wallet-asset-row empty",children:e.jsxs("div",{children:[e.jsx("strong",{children:"No assets found"}),e.jsx("span",{children:"Refresh after funding the operating wallet."})]})})})]}),e.jsx("div",{className:"wallet-side-stack",children:e.jsxs("section",{className:"wallet-panel",children:[e.jsx("div",{className:"wallet-panel-header",children:e.jsx("div",{children:e.jsx("span",{children:"Wallets"})})}),e.jsx("div",{className:"wallet-address-list",children:j.map(x=>e.jsx(ma,{label:x.label,address:x.address},x.label))})]})})]})]})}function ua({address:s}){const t=s?.trim()||null;return e.jsxs("div",{className:`wallet-card-address ${t?"":"empty"}`,children:[e.jsx("span",{children:"Operating wallet"}),e.jsxs("div",{children:[e.jsx("code",{children:t??"Not available"}),e.jsx("button",{type:"button",className:"wallet-copy-button ghost",title:"Copy operating wallet","aria-label":"Copy operating wallet",disabled:!t,onClick:()=>{t&&oe(t)},children:e.jsx(Rs,{size:12})})]})]})}function ma({label:s,address:t}){const a=t?.trim()||null;return e.jsx("div",{className:`wallet-address-row ${a?"":"empty"}`,children:e.jsxs("div",{children:[e.jsx("span",{children:s}),e.jsxs("div",{className:"wallet-address-line",children:[e.jsx("code",{children:a??"Not available"}),e.jsx("button",{type:"button",className:"wallet-copy-button ghost",title:`Copy ${s}`,"aria-label":`Copy ${s}`,disabled:!a,onClick:()=>{a&&oe(a)},children:e.jsx(Rs,{size:12})})]})]})})}function ha({asset:s}){const t=pa(s.amount,s.asset),a=fa(s.usdValue),n=ga(s.asset);return e.jsxs("div",{className:"wallet-asset-row",children:[e.jsxs("div",{className:"wallet-asset-identity",children:[n?e.jsx("img",{src:n,alt:""}):e.jsx("span",{className:"wallet-token-fallback",children:s.asset.slice(0,1)}),e.jsx("strong",{children:s.asset}),e.jsx("span",{children:s.chain})]}),e.jsxs("div",{className:"wallet-asset-values",children:[e.jsx("strong",{children:t}),e.jsx("span",{children:a})]})]})}function ga(s){switch(s.trim().toUpperCase()){case"ETH":return ts.ETH;case"USDC":return ts.USDC;default:return null}}function pa(s,t){if(!s)return`0 ${t}`;const a=Number(s);return Number.isFinite(a)?`${new Intl.NumberFormat("en-US",{maximumFractionDigits:a>=1?4:8}).format(a)} ${t}`:`${s} ${t}`}function fa(s){if(s===null)return"$0.00";const t=typeof s=="number"?s:Number(s);return Number.isFinite(t)?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(t):"$0.00"}function xa({connection:s,onError:t,onPayload:a}){const[n,l]=i.useState(""),[o,m]=i.useState(!1),[r,j]=i.useState(!1);i.useEffect(()=>{s||l("")},[s]);async function v(h,c){if(s){m(!0),t(null);try{const u=await E.switchOpenPondAccount(s,{handle:h,baseUrl:c??null}),g=await E.savePreferences(s,{defaultTeamId:null});a({...u,preferences:g.preferences})}catch(u){t(u instanceof Error?u.message:String(u))}finally{m(!1)}}}async function b(h){if(h.preventDefault(),!(!s||!n.trim())){m(!0),t(null);try{const c=await E.saveOpenPondAccount(s,{apiKey:n.trim(),setActive:!0}),u=await E.savePreferences(s,{defaultTeamId:null});a({...c,preferences:u.preferences}),l("")}catch(c){t(c instanceof Error?c.message:String(c))}finally{m(!1)}}}async function x(h){if(!(!s||!h.apiKey.trim())){m(!0),t(null);try{const c=h.handle?.trim(),u=h.environment?.trim(),g=await E.saveOpenPondAccount(s,{apiKey:h.apiKey.trim(),handle:c||void 0,baseUrl:h.baseUrl,apiBaseUrl:h.apiBaseUrl,environment:u||"custom",setActive:!0}),S=await E.savePreferences(s,{defaultTeamId:null});a({...g,preferences:S.preferences}),l("")}catch(c){throw t(c instanceof Error?c.message:String(c)),c}finally{m(!1)}}}async function f(){if(s){j(!0),t(null);try{a(await E.refreshOpenPondAccounts(s))}catch(h){t(h instanceof Error?h.message:String(h))}finally{j(!1)}}}return{apiKey:n,refreshingAccounts:r,saving:o,refreshAccounts:f,saveAccount:b,saveEnvironmentAccount:x,setApiKey:l,switchAccount:v}}function va({connection:s,onError:t,onPreferences:a,preferences:n,providers:l}){const[o,m]=i.useState(n.defaultBranchPrefix),[r,j]=i.useState(n.defaultNewProjectDirectory),[v,b]=i.useState(n.goalStorageLocation),[x,f]=i.useState(n.advancedWorkspaceControls),[h,c]=i.useState(n.contextCompaction.autoEnabled),[u,g]=i.useState(n.insightsEnabled),[S,d]=i.useState(!n.insightsModelRef),[y,R]=i.useState(n.insightsModelRef?.providerId??n.defaultChatProvider),[N,w]=i.useState(n.insightsModelRef?.modelId??n.defaultChatModel),[I,z]=i.useState(n.insightsEvidenceSources),[T,P]=i.useState(n.subagents.enabled),[p,C]=i.useState(n.subagents.delegationMode),[O,L]=i.useState(!n.subagents.defaultModelRef),[G,q]=i.useState(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),[$,M]=i.useState(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),[V,X]=i.useState(n.subagents.roles),[K,ee]=i.useState(n.subagents.maxConcurrentRuns),[te,F]=i.useState(n.subagents.maxConcurrentRunsPerProvider),[D,H]=i.useState(n.subagents.maxConcurrentRunsPerWorkspaceTarget),[ne,ae]=i.useState(!1),ge=O?null:{providerId:G,modelId:$.trim()},pe=T!==n.subagents.enabled||p!==n.subagents.delegationMode||!ja(ge,n.subagents.defaultModelRef)||K!==n.subagents.maxConcurrentRuns||te!==n.subagents.maxConcurrentRunsPerProvider||D!==n.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(V)!==JSON.stringify(n.subagents.roles);i.useEffect(()=>{m(n.defaultBranchPrefix),j(n.defaultNewProjectDirectory),b(n.goalStorageLocation),f(n.advancedWorkspaceControls),c(n.contextCompaction.autoEnabled),g(n.insightsEnabled),d(!n.insightsModelRef),R(n.insightsModelRef?.providerId??n.defaultChatProvider),w(n.insightsModelRef?.modelId??n.defaultChatModel),z(n.insightsEvidenceSources),P(n.subagents.enabled),C(n.subagents.delegationMode),L(!n.subagents.defaultModelRef),q(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),M(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),X(n.subagents.roles),ee(n.subagents.maxConcurrentRuns),F(n.subagents.maxConcurrentRunsPerProvider),H(n.subagents.maxConcurrentRunsPerWorkspaceTarget)},[n.defaultChatProvider,n.defaultChatModel,n.defaultBranchPrefix,n.defaultNewProjectDirectory,n.goalStorageLocation,n.advancedWorkspaceControls,n.contextCompaction.autoEnabled,n.insightsEnabled,n.insightsModelRef,n.insightsEvidenceSources,n.subagents]);function ue(A){R(A),w(U=>Oe(A,U,l))}function fe(A){q(A),M(U=>Oe(A,U,l))}function xe(){return O?n.defaultChatProvider:G}function ve(){return O?n.defaultChatModel:$}function J(A,U){X(_=>_.map(se=>se.id===A?U(se):se))}function je(A,U){J(A,_=>({..._,enabled:U}))}function B(A,U){J(A,_=>({..._,background:U}))}function Y(A,U){J(A,_=>{if(U)return{..._,modelRef:null};const se=_.modelRef?.providerId??xe(),be=_.modelRef?.modelId??ve();return{..._,modelRef:Me(se,be,l)??null}})}function Qe(A,U){J(A,_=>({..._,modelRef:Me(U,_.modelRef?.modelId??ve(),l)??null}))}function Ue(A,U){J(A,_=>{const se=_.modelRef?.providerId??xe(),be=U.trim();return{..._,modelRef:be?{providerId:se,modelId:be}:null}})}function Ne(A,U){J(A,_=>({..._,isolationMode:U}))}function $e(A,U){J(A,_=>({..._,toolPolicy:U}))}function Be(A,U){J(A,_=>({..._,peerMessages:U}))}function ze(A,U){J(A,_=>({..._,maxConcurrentRuns:me(U,1,16)}))}async function Pe(){let A=null;if(window.openpond?.selectFolder){const U=await window.openpond.selectFolder();if(U.canceled)return;A=U.path}else A=window.prompt("Default new project directory",r);A?.trim()&&j(A.trim())}async function Re(A){if(A.preventDefault(),!!s){ae(!0),t(null);try{a(await E.savePreferences(s,{defaultBranchPrefix:qe(o),defaultNewProjectDirectory:r.trim(),goalStorageLocation:v,advancedWorkspaceControls:x,contextCompaction:{...n.contextCompaction,autoEnabled:h},insightsEnabled:u,insightsModelRef:S?null:Me(y,N,l)??null,insightsEvidenceSources:I,subagents:{enabled:T,workspaceDefaultsVersion:n.subagents.workspaceDefaultsVersion,toolDefaultsVersion:n.subagents.toolDefaultsVersion,delegationMode:p,defaultModelRef:O?null:Me(G,$,l)??null,roles:V,maxConcurrentRuns:me(K,1,32),maxConcurrentRunsPerProvider:te===null?null:me(te,1,32),maxConcurrentRunsPerWorkspaceTarget:D===null?null:me(D,1,32)}}))}catch(U){t(U instanceof Error?U.message:String(U))}finally{ae(!1)}}}return{advancedWorkspaceControls:x,contextCompactionAutoEnabled:h,defaultBranchPrefix:o,defaultNewProjectDirectory:r,goalStorageLocation:v,insightsEnabled:u,insightsUseDefaultModel:S,insightsProvider:y,insightsModel:N,insightsEvidenceSources:I,subagentsEnabled:T,subagentDelegationMode:p,subagentsUseDefaultModel:O,subagentsProvider:G,subagentsModel:$,subagentRoles:V,subagentsMaxConcurrentRuns:K,subagentsMaxConcurrentRunsPerProvider:te,subagentsMaxConcurrentRunsPerWorkspaceTarget:D,subagentsDirty:pe,saving:ne,chooseDefaultProjectDirectory:Pe,saveDefaults:Re,changeInsightsProvider:ue,changeSubagentsProvider:fe,changeSubagentRoleProvider:Qe,setAdvancedWorkspaceControls:f,setContextCompactionAutoEnabled:c,setDefaultBranchPrefix:m,setDefaultNewProjectDirectory:j,setGoalStorageLocation:b,setInsightsEnabled:g,setInsightsUseDefaultModel:d,setInsightsModel:w,setSubagentsUseDefaultModel:L,setSubagentsModel:M,setInsightsEvidenceSourceEnabled:(A,U)=>z(_=>({..._,[A]:U})),setSubagentsEnabled:P,setSubagentDelegationMode:A=>C(A),setSubagentsMaxConcurrentRuns:A=>ee(me(A,1,32)),setSubagentsMaxConcurrentRunsPerProvider:A=>F(A===null?null:me(A,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:A=>H(A===null?null:me(A,1,32)),setSubagentRoleBackground:B,setSubagentRoleEnabled:je,setSubagentRoleIsolationMode:Ne,setSubagentRoleMaxConcurrentRuns:ze,setSubagentRoleModel:Ue,setSubagentRolePeerMessages:Be,setSubagentRoleToolPolicy:$e,setSubagentRoleUseDefaultModel:Y}}function me(s,t,a){return Number.isFinite(s)?Math.min(a,Math.max(t,Math.trunc(s))):t}function ja(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const ba=15e3,ya=100,Na=100,Sa=2500;function wa({onError:s,section:t}){const[a,n]=i.useState(null),[l,o]=i.useState(null),[m,r]=i.useState(ya),[j,v]=i.useState([]),[b,x]=i.useState(null),[f,h]=i.useState(!0),c=i.useRef(null),[u,g]=i.useState(null),S=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),y=!!window.openpond?.readRecentLogs?`${j.length} of ${m} line${m===1?"":"s"}${f?" tailing":""}`:"Unavailable";i.useEffect(()=>{t==="diagnostics"&&R(m,"refresh",{quiet:!0})},[t]),i.useEffect(()=>{if(t!=="diagnostics"||!f||!window.openpond?.readRecentLogs)return;let P=!1;const p=window.setInterval(()=>{P||(P=!0,R(m,"refresh",{quiet:!0}).finally(()=>{P=!1}))},Sa);return()=>window.clearInterval(p)},[t,f,m]),i.useEffect(()=>{if(t!=="diagnostics"||!f)return;const P=c.current;P&&(P.scrollTop=P.scrollHeight)},[t,f,j]);async function R(P=m,p="refresh",C={}){const O=window.openpond?.readRecentLogs;if(!O){const L="Log view is not available in this runtime.";C.quiet||(g({label:"Logs",value:L,warning:!0}),s(L));return}C.quiet||o(p);try{const L=await De(O(P),"Read logs");if(!L.ok)throw new Error(L.error);r(L.lineLimit),x(L.logDir),v(L.lines),C.quiet?g(G=>G?.label==="Logs"?null:G):g(null)}catch(L){const G=L instanceof Error?L.message:String(L);g({label:"Logs",value:G,warning:!0}),C.quiet||s(G)}finally{C.quiet||o(null)}}function N(){h(!1),R(m+Na,"older")}function w(){const P=!f;h(P),P&&R(m,"refresh",{quiet:!0})}async function I(){const P=window.openpond?.openLogsFolder;if(!P){const p="Desktop logs are not available in this runtime.";g({label:"Logs",value:p,warning:!0}),s(p);return}n("logs"),s(null);try{const p=await De(P(),"Open logs");if(!p.ok)throw new Error(p.error??"Could not open the logs folder.");g(null)}catch(p){const C=p instanceof Error?p.message:String(p);g({label:"Logs",value:C,warning:!0}),s(C)}finally{n(null)}}async function z(){const P=window.openpond?.copyRecentLogs;if(!P){const p="Recent log copy is not available in this runtime.";g({label:"Copy",value:p,warning:!0}),s(p);return}n("copy"),s(null);try{const p=await De(P(1e3),"Copy recent logs");if(!p.ok)throw new Error(p.error??"Could not copy recent logs.");g({label:"Copy",value:p.lines?`Copied ${p.lines} recent log lines.`:"Copied recent logs."})}catch(p){const C=p instanceof Error?p.message:String(p);g({label:"Copy",value:C,warning:!0}),s(C)}finally{n(null)}}async function T(){const P=window.openpond?.exportDiagnostics;if(!P){const p="Diagnostics export is not available in this runtime.";g({label:"Export",value:p,warning:!0}),s(p);return}n("export"),s(null);try{const p=await De(P(),"Export diagnostics");if(!p.ok)throw new Error(p.error??"Could not export diagnostics.");g({label:"Export",value:p.path?`Saved to ${p.path}`:"Diagnostics exported."})}catch(p){const C=p instanceof Error?p.message:String(p);g({label:"Export",value:C,warning:!0}),s(C)}finally{n(null)}}return{diagnosticsAvailable:S,diagnosticsBusy:a,diagnosticsStatus:u,logDir:b,logLineLimit:m,logLines:j,logViewBusy:l,logViewSummary:y,logViewportRef:c,tailLogs:f,copyRecentLogs:z,exportDiagnosticsBundle:T,loadOlderLogs:N,openLogsFolder:I,refreshLogView:R,toggleTailLogs:w}}async function De(s,t){let a;try{return await Promise.race([s,new Promise((n,l)=>{a=window.setTimeout(()=>{l(new Error(`${t} did not receive a desktop response.`))},ba)})])}finally{a!==void 0&&window.clearTimeout(a)}}function Ca({connection:s,enabled:t,onError:a,onPreferences:n,onToast:l,preferences:o}){const[m,r]=i.useState(o.editor),[j,v]=i.useState(null),[b,x]=i.useState(!1),[f,h]=i.useState(!1),[c,u]=i.useState(!1);i.useEffect(()=>{r(o.editor)},[o.editor]);const g=i.useCallback(async()=>{if(s){h(!0);try{v(await E.workspaceLspSettingsStatus(s))}catch(N){a(N instanceof Error?N.message:String(N))}finally{h(!1)}}},[s,a]);i.useEffect(()=>{!t||!s||g()},[s,t,g]);function S(N,w){r(I=>({...I,languages:{...I.languages,[N]:{...I.languages[N],mode:w}}}))}function d(N,w){r(I=>({...I,languages:{...I.languages,[N]:{...I.languages[N],customCommand:w}}}))}async function y(N){if(N.preventDefault(),!!s){x(!0),a(null);try{const w=await E.savePreferences(s,{editor:m});n(w),v(await E.workspaceLspSettingsStatus(s))}catch(w){a(w instanceof Error?w.message:String(w))}finally{x(!1)}}}async function R(){if(s){u(!0),a(null);try{await E.restartWorkspaceLsp(s),v(await E.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(N){a(N instanceof Error?N.message:String(N))}finally{u(!1)}}}return{editorPreferences:m,lspStatus:j,restarting:c,saving:b,statusLoading:f,refreshLspStatus:g,restartLanguageServers:R,saveEditorSettings:y,setEditorPreferences:r,setLanguageCustomCommand:d,setLanguageMode:S}}function ka({connection:s,onError:t,onPayload:a,personalization:n}){const l=i.useMemo(()=>n.templates.map(T=>({value:T.id,label:T.name,description:T.id===n.activeTemplateId?"Selected":T.source==="built_in"?T.description:void 0})),[n.activeTemplateId,n.templates]),[o,m]=i.useState(n.activeTemplateId),[r,j]=i.useState(n.soul),[v,b]=i.useState(""),[x,f]=i.useState(!1),[h,c]=i.useState(!1),u=n.templates.find(T=>T.id===o)??n.templates[0],g=u?.source==="custom",S=u?r!==u.content:!0,d=o!==n.activeTemplateId||r!==n.soul||S,y=!!(g&&r.trim()&&u&&d);i.useEffect(()=>{m(n.activeTemplateId),j(n.soul);const T=n.templates.find(P=>P.id===n.activeTemplateId);b(T?`${T.name} Copy`:""),f(!1)},[n.activeTemplateId,n.soul,n.templates]);async function R(T=!1){if(!T&&!g)return;const P=T?v:u?.name;if(!(!s||!r.trim()||!P?.trim())){c(!0),t(null);try{a(await E.savePersonalization(s,{activeTemplateId:o,templateName:P,soul:r,saveAsNew:T})),f(!1)}catch(p){t(p instanceof Error?p.message:String(p))}finally{c(!1)}}}async function N(T){const P=n.templates.find(p=>p.id===T);if(P&&(m(P.id),b(`${P.name} Copy`),j(P.content),f(!1),!!s)){c(!0),t(null);try{a(await E.savePersonalization(s,{activeTemplateId:P.id,templateName:P.name,soul:P.content,saveAsNew:!1}))}catch(p){t(p instanceof Error?p.message:String(p))}finally{c(!1)}}}function w(){u&&(b(`${u.name} Copy`),j(u.content),f(!1))}function I(T){j(T),u&&!g&&T!==u.content&&f(!0)}function z(){u&&(b(`${u.name} Copy`),f(!0))}return{canSaveCurrentTemplate:y,personalizationTemplateId:o,personalizationTemplateOptions:l,saveAsNewOpen:x,saving:h,selectedPersonalizationTemplate:u,selectedTemplateIsCustom:g,soulDraft:r,templateNameDraft:v,changePersonalizationTemplate:N,changeSoulDraft:I,openSaveAsNew:z,resetPersonalizationDraft:w,savePersonalization:R,setSaveAsNewOpen:f,setTemplateNameDraft:b}}function Pa({connection:s,onError:t,onPreferences:a,onProviders:n,preferences:l,providers:o}){const[m,r]=i.useState(l.defaultChatProvider),[j,v]=i.useState(l.defaultChatModel),[b,x]=i.useState(!1),[f,h]=i.useState(null),[c,u]=i.useState(null);i.useEffect(()=>{r(l.defaultChatProvider),v(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function g(p){if(p.preventDefault(),!!s){x(!0),t(null);try{a(await E.savePreferences(s,{defaultChatProvider:m,defaultChatModel:Oe(m,j,o)}))}catch(C){t(C instanceof Error?C.message:String(C))}finally{x(!1)}}}function S(p){r(p),v(C=>Oe(p,C,o))}async function d(p,C,O){if(!s)return null;h(`${p}:${C}`),u(null),t(null);try{return await O()}catch(L){return t(L instanceof Error?L.message:String(L)),null}finally{h(null)}}async function y(p,C){await d(p,"config",async()=>{const O=await E.saveProviderSettings(s,{providers:{[p]:C}});return n(O),O})}async function R(p,C){await d(p,"credential",async()=>{const O=await E.saveProviderCredential(s,p,C);return n(O),O})}async function N(p){await d(p,"credential",async()=>{const C=await E.deleteProviderCredential(s,p,{});return n(C),C})}async function w(p){return d("openai","credential",async()=>{const C=await E.startOpenAiSubscriptionAuth(s,{method:p});return C.method==="browser"?(window.open(C.url,"_blank","noopener,noreferrer"),u("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(C.url,"_blank","noopener,noreferrer"),u(`OpenAI device login started. Enter code ${C.userCode}.`)),I(C.expiresAt),C})}async function I(p){if(s)for(;Date.now()<p;){await new Promise(C=>setTimeout(C,2500));try{const C=await E.providerSettings(s);n(C);const O=C.statuses.openai?.credential;if(O?.connected&&O.source==="chatgpt_subscription"){u("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function z(p){await d(p,"models",async()=>{const C=await E.refreshProviderModels(s,p,{force:!0});return n(C.providers),C})}async function T(p){await d(p,"models",async()=>{const C=await E.loadProviderModels(s,p,{limit:500});return n(C.providers),C})}async function P(p,C={}){await d(p,"validate",async()=>{const O=await E.validateProviderCredential(s,p,C);return u(O.ok?`${p} validated${O.modelId?` with ${O.modelId}`:""}.`:O.errors.join(`
6
+ `)||`${p} validation failed.`),n(O.providers),O})}return{defaultModel:j,defaultProvider:m,providerBusy:f,saving:b,validationMessage:c,changeDefaultProvider:S,deleteProviderCredential:N,loadProviderModels:T,refreshProviderModels:z,saveProviderConfig:y,saveProviderCredential:R,saveProviders:g,setDefaultModel:v,startOpenAiSubscriptionAuth:w,validateProvider:P}}function Ra({connection:s,enabled:t,onError:a,onToast:n}){const[l,o]=i.useState(null),[m,r]=i.useState(null),[j,v]=i.useState(!1),b=i.useRef(null),x=i.useCallback(async(w={})=>{if(s){w.quiet||r("refresh");try{const I=await E.remoteAccess(s);o(I),a(null)}catch(I){a(I instanceof Error?I.message:String(I))}finally{w.quiet||r(null)}}},[s,a]);i.useEffect(()=>{!t||!s||x({quiet:!0})},[s,t,x]),i.useEffect(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function f(){b.current!==null&&window.clearTimeout(b.current),v(!1),window.setTimeout(()=>{v(!0),b.current=window.setTimeout(()=>{v(!1),b.current=null},1500)},0)}async function h(){if(a(null),!!s)try{o(await E.remoteAccess(s))}catch{}}async function c(){if(!s)return null;l&&!l.tailscale.running&&f(),r("enable");try{const w=await E.enableRemoteAccess(s);return o(w.status),a(null),w.status.tailscale.running?!w.status.serve.enabled&&w.status.serve.error&&n?.(w.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":w.message||w.status.serve.error,"error"):(f(),n?.(w.message||"Tailscale is not running. Run Tailscale up first.","error")),w.status}catch{return await h(),f(),n?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{r(null)}}async function u(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){r("disable");try{const w=await E.disableRemoteAccess(s);o(w.status),a(null)}catch{await h()}finally{r(null)}}}async function g(){l?.remoteWebUrl&&(r("copy-link"),await oe(l.remoteWebUrl),r(null))}async function S(){l?.serveCommand&&(r("copy-command"),await oe(l.serveCommand),r(null))}async function d(){l?.serve.setupUrl&&(r("copy-serve-setup"),await oe(l.serve.setupUrl),r(null))}async function y(){l?.tailscaleUpCommand&&(r("copy-up-command"),await oe(l.tailscaleUpCommand),r(null))}async function R(){l?.operatorCommand&&(r("copy-operator"),await oe(l.operatorCommand),r(null))}async function N(){if(!l?.serve.enabled){const w=await c();w?.serve.enabled&&w.remoteWebUrl&&await oe(w.remoteWebUrl);return}await g()}return{status:l,busy:m,flashTailscaleUp:j,refresh:x,enableRemoteAccess:c,disableRemoteAccess:u,copyRemoteLink:g,copyTailscaleUpCommand:y,copyServeCommand:S,copyServeSetupUrl:d,copyOperatorCommand:R,createRemoteLink:N}}function Ma(s){const{connection:t,enabled:a,onError:n}=s,[l,o]=i.useState(null),[m,r]=i.useState(null),j=i.useCallback(async()=>{if(t){r("load");try{const c=await E.computeState(t);o(c),n(null)}catch(c){n(Se(c))}finally{r(null)}}},[t,n]),v=i.useCallback(async()=>{if(t){r("scan");try{const c=await E.scanCompute(t),u=await E.computeState(t);o({...u,inventory:c,scanning:!1}),n(null)}catch(c){n(Se(c))}finally{r(null)}}},[t,n]),b=i.useCallback(async(c,u,g)=>{if(!t)return!1;r("save");try{const S=await E.updateComputeSettings(t,{modelStorePath:c,datasetStorePath:u,defaultDeviceIds:g}),d=await E.computeState(t);return o({...d,settings:S}),n(null),!0}catch(S){return n(Se(S)),!1}finally{r(null)}},[t,n]),x=i.useCallback(async()=>{if(t)try{await E.downloadSmolLm2(t),await j()}catch(c){n(Se(c))}},[t,n,j]),f=i.useCallback(async c=>{if(t)try{await E.cancelModelDownload(t,c),await j()}catch(u){n(Se(u))}},[t,n,j]);i.useEffect(()=>{a&&j()},[a,j]);const h=l?.inventory?.downloads.some(c=>["queued","downloading","verifying","cancelling"].includes(c.status))??!1;return i.useEffect(()=>{if(!a||!h)return;const c=window.setInterval(()=>{j()},1e3);return()=>window.clearInterval(c)},[a,h,j]),{state:l,busy:m,refresh:j,scan:v,save:b,downloadSmolLm2:x,cancelDownload:f}}function Se(s){return s instanceof Error?s.message:String(s)}function Ia(s){const{connection:t,enabled:a,onError:n,profileId:l}=s,[o,m]=i.useState(null),[r,j]=i.useState(!1),v=i.useCallback(async()=>{if(t){j(!0);try{m(await E.datasetCatalog(t,l)),n(null)}catch(b){n(Da(b))}finally{j(!1)}}},[t,n,l]);return i.useEffect(()=>{a&&v()},[a,v]),{catalog:o,loading:r,refresh:v}}function Da(s){return s instanceof Error?s.message:String(s)}const Aa=i.lazy(()=>Ct(()=>import("./UsageSettingsSection-CUxBaohC.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function Ka({payload:s,connection:t,diagnostics:a,onPayload:n,onError:l,onToast:o,onBack:m,onOpenSourceSession:r,onOpenNativeSkill:j,teamChatCurrentUserId:v,teamChatEnabled:b,teamChatNotificationMode:x,teamChatThreads:f,onTeamChatNotificationModeChange:h,onTeamChatThreadMuteChange:c,initialSection:u="account"}){const[g,S]=i.useState(u),d=s?.codex??null,y=i.useMemo(()=>bt(s?.preferences),[s?.preferences]),R=s?.personalization??yt,N=a??s?.diagnostics??[],w=Nt()&&St(t?.platform),I=i.useCallback(F=>{s&&n({...s,providers:F})},[n,s]),z=i.useCallback(F=>{s&&n({...s,preferences:F.preferences})},[n,s]),T=xa({connection:t,onError:l,onPayload:n}),P=Pa({connection:t,onError:l,onPayload:n,onPreferences:z,onProviders:I,preferences:y,providers:s?.providers??null}),p=va({connection:t,onError:l,onPayload:n,onPreferences:z,preferences:y,providers:s?.providers??null}),C=Ca({connection:t,enabled:g==="editor",onError:l,onPayload:n,onPreferences:z,onToast:o,preferences:y}),O=ka({connection:t,onError:l,onPayload:n,personalization:R}),L=wa({onError:l,section:g}),G=Ra({connection:t,enabled:g==="remote",onError:l,onToast:o}),q=g==="dataset-storage",$=Ma({connection:t,enabled:g==="compute"||q,onError:l}),M=Ia({connection:t,enabled:q,onError:l,profileId:s?.profile.activeProfile??"default"}),V=i.useCallback(F=>$.save($.state?.settings.modelStorePath??null,F,$.state?.settings.defaultDeviceIds??[]),[$.save,$.state?.settings.defaultDeviceIds,$.state?.settings.modelStorePath]),X=i.useCallback(async()=>{await Promise.all([$.refresh(),M.refresh()])},[$.refresh,M.refresh]),K=i.useCallback(()=>g!=="subagents"||!p.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[p.subagentsDirty,g]),ee=i.useCallback(F=>{F!==g&&K()&&S(F)},[K,g]),te=i.useCallback(()=>{K()&&m()},[K,m]);return i.useEffect(()=>{S(u)},[u]),i.useEffect(()=>{if(g!=="subagents"||!p.subagentsDirty)return;const F=D=>{D.preventDefault(),D.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",F),()=>window.removeEventListener("beforeunload",F)},[p.subagentsDirty,g]),e.jsxs("div",{className:`settings-shell ${w?"platform-macos":""}`,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsx("div",{className:"settings-window-controls",children:e.jsx(wt,{platform:t?.platform})}),e.jsx(Fn,{section:g,onBack:te,onSectionChange:ee}),e.jsx("main",{className:"settings-content",children:g==="account"?e.jsx(Jt,{payload:s,connection:t,onPayload:n,onPreferences:z,onError:l,onToast:o,...T}):g==="notifications"?e.jsx(vn,{currentUserId:v,enabled:b,mode:x,threads:f,onModeChange:h,onThreadMuteChange:c}):g==="wallet"?e.jsx(da,{payload:s}):g==="profile"?e.jsx(Pt,{payload:s,connection:t,onPayload:n,onError:l,onToast:o}):g==="skills"?e.jsx(Gn,{onOpenNativeSkill:j}):g==="providers"?e.jsx(Tn,{account:s?.account??null,codex:d,providers:s?.providers??null,...P}):g==="compute"?e.jsx(ea,{state:$.state,busy:$.busy,onScan:$.scan,onSave:$.save,onDownloadSmolLm2:$.downloadSmolLm2,onCancelDownload:$.cancelDownload}):g==="dataset-storage"?e.jsx(la,{state:$.state,catalog:M.catalog,busy:$.busy,catalogLoading:M.loading,onRefresh:X,onSave:V}):g==="defaults"?e.jsx(Xt,{preferences:y,...p}):g==="goals"?e.jsx(an,{preferences:y,...p}):g==="context"?e.jsx(ln,{preferences:y,...p}):g==="insights"?e.jsx(rn,{preferences:y,providers:s?.providers??null,...p}):g==="training"?e.jsx(Wn,{connection:t,onError:l,onPreferences:z,preferences:y,providers:s?.providers??null}):g==="subagents"?e.jsx(on,{preferences:y,providers:s?.providers??null,...p}):g==="editor"?e.jsx(nn,{preferences:y,...C}):g==="remote"?e.jsx(Un,{...G}):g==="usage"?e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(Aa,{account:s?.account??null,connection:t,enabled:g==="usage",onError:l,onOpenSourceSession:r})}):g==="personalization"?e.jsx(bn,{...O}):e.jsx(Qt,{diagnostics:N,...L})})]})}export{Ka as SettingsView};