openpond 0.2.58 → 0.2.59

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 (290) hide show
  1. package/dist/app-server.d.ts +1 -1
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/{actions-command-QU4H53OG.js → actions-command-JJ3CU7J6.js} +1 -1
  4. package/dist/chunks/{app-layer-NSTE5HIT.js → app-layer-KAUZAHGE.js} +1 -1
  5. package/dist/chunks/{app-server-connected-apps-JHGWLBXT.js → app-server-connected-apps-SXGZOUJJ.js} +1 -1
  6. package/dist/chunks/{app-server-evaluations-K52NAQLP.js → app-server-evaluations-N4OMTPCI.js} +1 -1
  7. package/dist/chunks/{app-server-harness-services-QMUOEYOA.js → app-server-harness-services-DDFUMNYC.js} +1 -1
  8. package/dist/chunks/app-server-runtime-SVB6L26M.js +2 -0
  9. package/dist/chunks/{apps-BKTOR4F7.js → apps-EZB56RHV.js} +1 -1
  10. package/dist/chunks/{chunk-SDXFLO7J.js → chunk-22VMH6JV.js} +1 -1
  11. package/dist/chunks/{chunk-FTEOCCPB.js → chunk-25JDHAZ5.js} +1 -1
  12. package/dist/chunks/{chunk-HDGTHRY7.js → chunk-2G4BEISF.js} +1 -1
  13. package/dist/chunks/{chunk-O72BSKSO.js → chunk-2L5XWJJ5.js} +1 -1
  14. package/dist/chunks/{chunk-QL4OIPEZ.js → chunk-2RNQQNB7.js} +2 -2
  15. package/dist/chunks/{chunk-O6ULLQJ6.js → chunk-2WKUBGIF.js} +1 -1
  16. package/dist/chunks/{chunk-F4KOGISR.js → chunk-37MWETFU.js} +1 -1
  17. package/dist/chunks/{chunk-D74JEERO.js → chunk-3CDEBKSU.js} +1 -1
  18. package/dist/chunks/{chunk-APB4O67E.js → chunk-4EDIRCD3.js} +1 -1
  19. package/dist/chunks/{chunk-JYKRR7E5.js → chunk-4GPXTISD.js} +1 -1
  20. package/dist/chunks/chunk-57TRXBLT.js +3 -0
  21. package/dist/chunks/{chunk-LQQNBVEB.js → chunk-76M2MEHV.js} +1 -1
  22. package/dist/chunks/{chunk-HCYX6RHP.js → chunk-776WNDV2.js} +1 -1
  23. package/dist/chunks/{chunk-RWWE5OXU.js → chunk-7AVNZF36.js} +1 -1
  24. package/dist/chunks/{chunk-65PL62KH.js → chunk-7K7O3CKY.js} +1 -1
  25. package/dist/chunks/chunk-7UH4YDA7.js +3 -0
  26. package/dist/chunks/{chunk-IIZ4CWBX.js → chunk-ABZ2ZOLU.js} +1 -1
  27. package/dist/chunks/{chunk-ZRDGQDZL.js → chunk-ANFDRKUU.js} +1 -1
  28. package/dist/chunks/{chunk-JUHZ5S3R.js → chunk-AQD7K4Z5.js} +1 -1
  29. package/dist/chunks/{chunk-4D7HWVWD.js → chunk-ARLOVWQ3.js} +1 -1
  30. package/dist/chunks/{chunk-7SC46OFC.js → chunk-ATAOHSFR.js} +1 -1
  31. package/dist/chunks/{chunk-TTVS6JMC.js → chunk-BE6SS65L.js} +2 -2
  32. package/dist/chunks/{chunk-Z54O534A.js → chunk-BGJYITVI.js} +1 -1
  33. package/dist/chunks/{chunk-BLXEAZCQ.js → chunk-BL3YH2QU.js} +1 -1
  34. package/dist/chunks/{chunk-2D4Y3HNW.js → chunk-BO5JZYWG.js} +1 -1
  35. package/dist/chunks/{chunk-ZGTOK7ZK.js → chunk-BQS7Z4AP.js} +1 -1
  36. package/dist/chunks/{chunk-NH6UUX5S.js → chunk-BRORSFJX.js} +3 -3
  37. package/dist/chunks/{chunk-HPBQ4VTW.js → chunk-BVQWVIGK.js} +1 -1
  38. package/dist/chunks/{chunk-SWUEFLOH.js → chunk-C37PUHA6.js} +1 -1
  39. package/dist/chunks/{chunk-3VUATFZD.js → chunk-CGWA54LE.js} +1 -1
  40. package/dist/chunks/{chunk-NC27T4AB.js → chunk-CKMSBAI2.js} +1 -1
  41. package/dist/chunks/{chunk-TJ6GVTYB.js → chunk-COHMDT7A.js} +7 -7
  42. package/dist/chunks/{chunk-JDEEWOD7.js → chunk-DPHAN6N3.js} +1 -1
  43. package/dist/chunks/{chunk-YOQRYNLP.js → chunk-DZUN5YWB.js} +1 -1
  44. package/dist/chunks/{chunk-ROGF26KV.js → chunk-E72UU4VX.js} +1 -1
  45. package/dist/chunks/{chunk-ABD5M2D2.js → chunk-EOBHQ3JT.js} +1 -1
  46. package/dist/chunks/chunk-EQOV34UH.js +2 -0
  47. package/dist/chunks/chunk-EUMXMT3S.js +2 -0
  48. package/dist/chunks/{chunk-773TH7FN.js → chunk-EWOSLZDX.js} +1 -1
  49. package/dist/chunks/{chunk-HIOKCIL7.js → chunk-FAYASU7Z.js} +1 -1
  50. package/dist/chunks/{chunk-EIRYMSEG.js → chunk-FKJHEZCW.js} +1 -1
  51. package/dist/chunks/{chunk-Q2QL6UWN.js → chunk-GL3NX3F3.js} +1 -1
  52. package/dist/chunks/{chunk-UKMA4R6X.js → chunk-GOPFFQZU.js} +1 -1
  53. package/dist/chunks/{chunk-RAXOSUSW.js → chunk-GUOLMLZN.js} +1 -1
  54. package/dist/chunks/{chunk-YNH3NMPF.js → chunk-GVZLGS2U.js} +1 -1
  55. package/dist/chunks/chunk-GYJQKCEO.js +5 -0
  56. package/dist/chunks/{chunk-XDQMGUWL.js → chunk-H7ATCPPB.js} +1 -1
  57. package/dist/chunks/{chunk-XX6SMFDY.js → chunk-IFDALGZE.js} +4 -4
  58. package/dist/chunks/{chunk-H4QHIHMK.js → chunk-IRV6GWGG.js} +3 -3
  59. package/dist/chunks/chunk-JFXINDOQ.js +3 -0
  60. package/dist/chunks/{chunk-PRGBLQVH.js → chunk-JMBQYBPI.js} +1 -1
  61. package/dist/chunks/{chunk-DBK66CJP.js → chunk-JQKSXCAJ.js} +1 -1
  62. package/dist/chunks/{chunk-DARVPBZ4.js → chunk-JUQMSHNR.js} +1 -1
  63. package/dist/chunks/{chunk-3Z47M3YY.js → chunk-K44RHALX.js} +1 -1
  64. package/dist/chunks/{chunk-4EPSHPZL.js → chunk-KO3HNMLJ.js} +1 -1
  65. package/dist/chunks/{chunk-4NESNOK5.js → chunk-LNCHFVHT.js} +1 -1
  66. package/dist/chunks/{chunk-7E6T7GP5.js → chunk-LPWBIGKW.js} +1 -1
  67. package/dist/chunks/{chunk-X2HIHF2I.js → chunk-MFMYWZK2.js} +1 -1
  68. package/dist/chunks/{chunk-A6USMRWK.js → chunk-MMQRHR3V.js} +1 -1
  69. package/dist/chunks/{chunk-I7AQMAQI.js → chunk-MNC4YUDI.js} +6 -6
  70. package/dist/chunks/{chunk-RNQF63ZR.js → chunk-N6ENLEMY.js} +2 -2
  71. package/dist/chunks/{chunk-JAJ46T5X.js → chunk-NTB2O4RP.js} +1 -1
  72. package/dist/chunks/{chunk-OQKJGTTO.js → chunk-O3RF72BT.js} +1 -1
  73. package/dist/chunks/{chunk-JE7RJZOA.js → chunk-O4VIXU7A.js} +1 -1
  74. package/dist/chunks/{chunk-5MCNZCVQ.js → chunk-OLDK2LKJ.js} +1 -1
  75. package/dist/chunks/{chunk-VVCKLCF3.js → chunk-OX3XZKGK.js} +2 -2
  76. package/dist/chunks/{chunk-SDAUS5PY.js → chunk-P2RSBSCT.js} +1 -1
  77. package/dist/chunks/{chunk-EKM2D7JU.js → chunk-PFSMXKTI.js} +1 -1
  78. package/dist/chunks/{chunk-FUOEIDMA.js → chunk-PH6IORGZ.js} +1 -1
  79. package/dist/chunks/{chunk-L3KCP52O.js → chunk-PQJTYOR2.js} +1 -1
  80. package/dist/chunks/{chunk-OLLLZVHF.js → chunk-PY6K2JRH.js} +1 -1
  81. package/dist/chunks/{chunk-EYPCBBMS.js → chunk-RBZH6A6M.js} +1 -1
  82. package/dist/chunks/{chunk-6QSSIT62.js → chunk-RZUEVS64.js} +1 -1
  83. package/dist/chunks/{chunk-Q5LEXXJG.js → chunk-SF5HJ7PL.js} +4 -4
  84. package/dist/chunks/{chunk-NHQ36THU.js → chunk-TG7P7BSV.js} +1 -1
  85. package/dist/chunks/{chunk-G3RXYI2L.js → chunk-TIHXUKFD.js} +1 -1
  86. package/dist/chunks/{chunk-QOGJAQDO.js → chunk-TKLBP3MM.js} +1 -1
  87. package/dist/chunks/{chunk-M4JWQSV7.js → chunk-U2MAPON2.js} +1 -1
  88. package/dist/chunks/chunk-U5FKRYJO.js +86 -0
  89. package/dist/chunks/{chunk-QNG27G3T.js → chunk-V34H7Y2T.js} +2 -2
  90. package/dist/chunks/chunk-VGRMAGOK.js +9 -0
  91. package/dist/chunks/chunk-VRODAXFS.js +145 -0
  92. package/dist/chunks/{chunk-EIEZHFIW.js → chunk-WC42WOLG.js} +1 -1
  93. package/dist/chunks/{chunk-OS3LO5J3.js → chunk-WRI4XKSK.js} +1 -1
  94. package/dist/chunks/{chunk-4EQA2M7K.js → chunk-XJZSIXEO.js} +2 -2
  95. package/dist/chunks/{chunk-25MBPJVY.js → chunk-XMKCCLGB.js} +1 -1
  96. package/dist/chunks/{chunk-HZEIRHEB.js → chunk-XMWXH7TS.js} +1 -1
  97. package/dist/chunks/chunk-YCQSVHCD.js +9 -0
  98. package/dist/chunks/{chunk-B7RFL4N2.js → chunk-YHHF4Q7Y.js} +1 -1
  99. package/dist/chunks/{chunk-DMVD2RFZ.js → chunk-ZAN4DYLH.js} +1 -1
  100. package/dist/chunks/{chunk-5IPFI25K.js → chunk-ZH3K7LKQ.js} +1 -1
  101. package/dist/chunks/cli-5DFVQL5Y.js +2 -0
  102. package/dist/chunks/{configuration-command-6C5UO7GE.js → configuration-command-JS6U3RMC.js} +1 -1
  103. package/dist/chunks/connected-app-executor-UBMGMV76.js +2 -0
  104. package/dist/chunks/{connected-evidence-GH2ATNEX.js → connected-evidence-NLAIEVQ3.js} +1 -1
  105. package/dist/chunks/connection-NZSD3U5O.js +2 -0
  106. package/dist/chunks/{continual-6CQAMTTR.js → continual-WFPIDWPH.js} +1 -1
  107. package/dist/chunks/core-commands-U4IBRRY5.js +2 -0
  108. package/dist/chunks/{datasets-7BNMVJOY.js → datasets-UX47DTTB.js} +1 -1
  109. package/dist/chunks/{desktop-test-3CUHVLXV.js → desktop-test-UUU7PD4P.js} +1 -1
  110. package/dist/chunks/{dist-VYC5VMQB.js → dist-OGLX76LL.js} +1 -1
  111. package/dist/chunks/{dist-ZVJPJLXR.js → dist-W5MJYSPF.js} +1 -1
  112. package/dist/chunks/{evaluation-coordination-XEF5L7KZ.js → evaluation-coordination-3YQN5JQW.js} +1 -1
  113. package/dist/chunks/{experiment-improvements-KRX2DP27.js → experiment-improvements-ZRVD2AGY.js} +1 -1
  114. package/dist/chunks/{experiments-DFGQYA4O.js → experiments-JEB5A2N5.js} +1 -1
  115. package/dist/chunks/{extension-XKXXOP5N.js → extension-JCUA3RWV.js} +1 -1
  116. package/dist/chunks/{help-S7THC6IE.js → help-KA4OINP5.js} +1 -1
  117. package/dist/chunks/host-profile-evaluation-tools-2URLU5SG.js +2 -0
  118. package/dist/chunks/host-profile-external-dataset-B2AQNSDR.js +2 -0
  119. package/dist/chunks/{hosted-app-server-composition-T5IWGOTA.js → hosted-app-server-composition-VJQ3FM4I.js} +1 -1
  120. package/dist/chunks/{hosted-experiment-improvement-HVMDGS75.js → hosted-experiment-improvement-42YWXB3P.js} +1 -1
  121. package/dist/chunks/hosted-harness-runtime-BM4WONJN.js +2 -0
  122. package/dist/chunks/{hosted-profile-candidate-EXNN6MVN.js → hosted-profile-candidate-HVVC43XQ.js} +1 -1
  123. package/dist/chunks/hosted-profile-compiler-RKDWHYK3.js +2 -0
  124. package/dist/chunks/{hosted-profile-evaluation-control-TJVER3NW.js → hosted-profile-evaluation-control-57V24UGU.js} +1 -1
  125. package/dist/chunks/{hosted-profile-evaluation-inspection-ZUANDYZ6.js → hosted-profile-evaluation-inspection-BUWLCKCD.js} +1 -1
  126. package/dist/chunks/{hosted-profile-evaluation-preparation-ORVZ6MBD.js → hosted-profile-evaluation-preparation-3XLRR6UH.js} +1 -1
  127. package/dist/chunks/{hosted-tasksets-ANAE2PIW.js → hosted-tasksets-THKM5QY5.js} +1 -1
  128. package/dist/chunks/{human-review-WR777ODH.js → human-review-CSYAW4PC.js} +1 -1
  129. package/dist/chunks/import-CBDJ4DME.js +3 -0
  130. package/dist/chunks/local-harness-improvement-runtime-3T6E7I5Q.js +2 -0
  131. package/dist/chunks/local-harness-taskset-review-LQPQBALH.js +2 -0
  132. package/dist/chunks/{opchat-T4QTNEIY.js → opchat-6ADSONAD.js} +1 -1
  133. package/dist/chunks/{organizations-75L5DZDV.js → organizations-GT24ZTCN.js} +1 -1
  134. package/dist/chunks/{profile-TFZMUEDR.js → profile-Y2MCSOUK.js} +1 -1
  135. package/dist/chunks/project-action-payload-GHSLE7K3.js +2 -0
  136. package/dist/chunks/{project-agent-6RRO233B.js → project-agent-YYSQIHVE.js} +1 -1
  137. package/dist/chunks/{published-experiment-source-HVP5IGRH.js → published-experiment-source-5TMGLKDM.js} +1 -1
  138. package/dist/chunks/refiner-profile-service-ZK7KAFP5.js +2 -0
  139. package/dist/chunks/{runtime-A7OZXM43.js → runtime-QFXCXSVB.js} +2 -2
  140. package/dist/chunks/{sandbox-command-IU5XFTJP.js → sandbox-command-U6346TVJ.js} +1 -1
  141. package/dist/chunks/{sandbox-template-C4V6T36U.js → sandbox-template-XWWPWWNR.js} +1 -1
  142. package/dist/chunks/saved-work-SWHZ4OLO.js +2 -0
  143. package/dist/chunks/{send-turn-XTAIS2JN.js → send-turn-SIXOZUVJ.js} +1 -1
  144. package/dist/chunks/{src-DZL5T2MT.js → src-6SHCCYEN.js} +1 -1
  145. package/dist/chunks/{src-R36AGJY7.js → src-EZAKCCUV.js} +103 -103
  146. package/dist/chunks/standalone-experiment-turn-owner-LIAQWTGI.js +2 -0
  147. package/dist/chunks/{store-continual-support-reviews-LJPNG4SP.js → store-continual-support-reviews-GDX6CSUU.js} +1 -1
  148. package/dist/chunks/{store-conversation-serving-KPC62UEY.js → store-conversation-serving-W55XMDH4.js} +1 -1
  149. package/dist/chunks/{store-create-improve-SW5FTBTL.js → store-create-improve-A7E7CUPZ.js} +1 -1
  150. package/dist/chunks/{store-datasets-WMA7AJKN.js → store-datasets-HKF3EO7B.js} +1 -1
  151. package/dist/chunks/{store-evaluation-results-ZO6R653G.js → store-evaluation-results-645RFBGR.js} +1 -1
  152. package/dist/chunks/{store-human-review-7QQ7ZQ6P.js → store-human-review-F5KESW52.js} +1 -1
  153. package/dist/chunks/{store-learned-preference-migration-validation-NADPXOTG.js → store-learned-preference-migration-validation-V27XD4I7.js} +1 -1
  154. package/dist/chunks/{store-local-experiments-SAULQSBN.js → store-local-experiments-HWQWNTIU.js} +1 -1
  155. package/dist/chunks/{store-model-batch-review-VKLDYGH3.js → store-model-batch-review-TOCSDVAP.js} +1 -1
  156. package/dist/chunks/{store-model-configuration-BYRJUR3C.js → store-model-configuration-6543ASY2.js} +1 -1
  157. package/dist/chunks/{store-sidebar-file-bookmarks-VB5GTLFY.js → store-sidebar-file-bookmarks-53B7QIGS.js} +1 -1
  158. package/dist/chunks/{store-sidebar-preferences-GWIOG2NH.js → store-sidebar-preferences-YXGEJVUO.js} +1 -1
  159. package/dist/chunks/{store-subagents-T7R2Z6TB.js → store-subagents-HRCAK7VZ.js} +1 -1
  160. package/dist/chunks/{store-task-inbox-QPE44OSS.js → store-task-inbox-WF74W4U2.js} +1 -1
  161. package/dist/chunks/{store-task-inventory-I3RDRI52.js → store-task-inventory-KHCTEZVK.js} +1 -1
  162. package/dist/chunks/{store-taskset-drafts-2IULRV2W.js → store-taskset-drafts-3ACG5AVX.js} +1 -1
  163. package/dist/chunks/{store-training-B2TW2MLA.js → store-training-R46WOGXB.js} +1 -1
  164. package/dist/chunks/{store-training-jobs-VBNG23RL.js → store-training-jobs-D4LECE7O.js} +1 -1
  165. package/dist/chunks/{store-training-models-OMV5FIC4.js → store-training-models-EQVNXOVB.js} +1 -1
  166. package/dist/chunks/{taskset-EQRFQBYM.js → taskset-NR2X2UOK.js} +1 -1
  167. package/dist/chunks/{taskset-packages-XC6HEE3K.js → taskset-packages-ONULEIVI.js} +1 -1
  168. package/dist/chunks/{teams-bot-EAPGPTHZ.js → teams-bot-CHUYMD6K.js} +1 -1
  169. package/dist/chunks/{training-UF6RPI4T.js → training-IDSGYGU2.js} +1 -1
  170. package/dist/chunks/{web-search-CZ3NCLPY.js → web-search-BPON7H5N.js} +1 -1
  171. package/dist/chunks/{workspaces-EKKE5NAC.js → workspaces-2TJRDM5K.js} +1 -1
  172. package/dist/cli.js +1 -1
  173. package/dist/index.js +1 -1
  174. package/dist/web/assets/App-pcwmC4IR.js +154 -0
  175. package/dist/web/assets/{AppDialog-t2Fx5tK3.js → AppDialog-CdHad7GT.js} +1 -1
  176. package/dist/web/assets/{AppTerminalPanel-Dj1Y32oI.js → AppTerminalPanel-CrmoOgd4.js} +2 -2
  177. package/dist/web/assets/AppsView-0P6cBsD4.js +1 -0
  178. package/dist/web/assets/{BrowserSidebar-jhWi4rVm.js → BrowserSidebar-Cb6edJw6.js} +1 -1
  179. package/dist/web/assets/{CartesianChart-C1DIx0Ia.js → CartesianChart-B2Sxi0lv.js} +1 -1
  180. package/dist/web/assets/{CollaborationTabs-Bdr-HmOL.js → CollaborationTabs-PP0AIXhb.js} +1 -1
  181. package/dist/web/assets/{CommandMenu-Ux2yOHAc.js → CommandMenu-GfQIMe6W.js} +1 -1
  182. package/dist/web/assets/{CommunityView-DPEeVKFn.js → CommunityView-V6KmMl5n.js} +1 -1
  183. package/dist/web/assets/ComposerCreateImproveStrip-oeVeyhPX.js +1 -0
  184. package/dist/web/assets/ConversationImportsSettings-CuQcvVgE.js +1 -0
  185. package/dist/web/assets/ConversationImportsSettings-PfUa8V7X.css +1 -0
  186. package/dist/web/assets/{GetStartedView-CFHP0AaI.js → GetStartedView-2oZ068h_.js} +1 -1
  187. package/dist/web/assets/{HostedModelLearningReview-D8BGTPVN.js → HostedModelLearningReview-DLzak_Vf.js} +1 -1
  188. package/dist/web/assets/{HostedModelLearningSettings-JS1S7vNO.js → HostedModelLearningSettings-Eca6Pd9R.js} +1 -1
  189. package/dist/web/assets/{LabModelVersionDetailPage-Dx5Q3xV2.js → LabModelVersionDetailPage-DsBblnMp.js} +1 -1
  190. package/dist/web/assets/LabSkillSidebar-DDknttrB.js +1 -0
  191. package/dist/web/assets/{LabsRoute-CyYF8-dw.js → LabsRoute-CgNiUHsy.js} +4 -4
  192. package/dist/web/assets/MainChatThread-yCVg99LU.js +2 -0
  193. package/dist/web/assets/MainPane-C86le7UF.js +65 -0
  194. package/dist/web/assets/{MarkdownText-BR4V6lNO.js → MarkdownText-BBVriBCj.js} +1 -1
  195. package/dist/web/assets/{NativeSkillSidebar-DU9IEgIO.js → NativeSkillSidebar-D2uVZkqh.js} +1 -1
  196. package/dist/web/assets/{NewExperienceSwitcher-mIy6FzCj.js → NewExperienceSwitcher-DuD6GScJ.js} +1 -1
  197. package/dist/web/assets/{NewProjectDialog-RfTZTHxl.js → NewProjectDialog-B6XZkJrU.js} +1 -1
  198. package/dist/web/assets/OutputsPage-PUlmcWjv.js +1 -0
  199. package/dist/web/assets/{ProjectsPage-CE6QUB-b.js → ProjectsPage-DWBRmej6.js} +1 -1
  200. package/dist/web/assets/RightChatPanelStack-HaCVep4t.js +1 -0
  201. package/dist/web/assets/{RightSidebarHomePanel-CK0rP3WT.js → RightSidebarHomePanel-BUtdPb2L.js} +1 -1
  202. package/dist/web/assets/{ScheduledWorkPage-vOrYv8pp.js → ScheduledWorkPage-Dg9GkGrT.js} +1 -1
  203. package/dist/web/assets/SettingsView-DjjnCnlb.css +1 -0
  204. package/dist/web/assets/{SettingsView-DCKVrfjj.js → SettingsView-DtldfnV-.js} +4 -4
  205. package/dist/web/assets/{TeamChatView-Bwrjr-vk.js → TeamChatView-C71JX4je.js} +2 -2
  206. package/dist/web/assets/{TerminalOverlay-DhPoKZAq.js → TerminalOverlay-B4F6Q36s.js} +1 -1
  207. package/dist/web/assets/TrainingCreationPanel-B9MxFzQx.js +1 -0
  208. package/dist/web/assets/{TrainingDraftPanel-C9cRX5qf.js → TrainingDraftPanel-7C48sHfC.js} +1 -1
  209. package/dist/web/assets/{UsageSettingsSection-CrdcSGeW.js → UsageSettingsSection-CC57FcUB.js} +1 -1
  210. package/dist/web/assets/{WorkSidebarPanel-DSSikNFQ.js → WorkSidebarPanel-Cto1usLM.js} +1 -1
  211. package/dist/web/assets/{WorkspaceDiffPanel-BAFo0CPN.js → WorkspaceDiffPanel-CL7wi3kp.js} +3 -3
  212. package/dist/web/assets/{WorkspaceEnvironmentMenu-BVHAhwnJ.js → WorkspaceEnvironmentMenu-zdzSDofs.js} +18 -18
  213. package/dist/web/assets/{WorkspaceGitDialogs-CwVoiDQ2.js → WorkspaceGitDialogs-CZSmjnrc.js} +1 -1
  214. package/dist/web/assets/{WorkspaceMonacoEditor-TxLyhzNp.js → WorkspaceMonacoEditor-TrUDJMKb.js} +3 -3
  215. package/dist/web/assets/agent-connections-4Dza2mDg.js +1 -0
  216. package/dist/web/assets/{arrow-up-right-C9aE8Mfz.js → arrow-up-right-xKb5kWQJ.js} +1 -1
  217. package/dist/web/assets/{chunk-P3BRSSRD-DUGfuKA8.js → chunk-P3BRSSRD-BsGTkgyC.js} +1 -1
  218. package/dist/web/assets/{clipboard-Dk158Qp4.js → clipboard-BgjV3aCx.js} +1 -1
  219. package/dist/web/assets/{cloud-upload-k9eqBsHr.js → cloud-upload-Bw9XUsKQ.js} +1 -1
  220. package/dist/web/assets/{cssMode-CO35ARZp.js → cssMode-DxsFJGb-.js} +1 -1
  221. package/dist/web/assets/{folder-open-sYgceW_f.js → folder-open-CbmUjIYS.js} +1 -1
  222. package/dist/web/assets/{folder-plus-CS0R49m9.js → folder-plus-slsst7Ct.js} +1 -1
  223. package/dist/web/assets/{git-commit-horizontal-DrGxH2h4.js → git-commit-horizontal-BIS-8MuS.js} +1 -1
  224. package/dist/web/assets/{htmlMode-REMmzdfq.js → htmlMode-BE4VOrZo.js} +1 -1
  225. package/dist/web/assets/{index-C8aCGagb.js → index-DEg0S7Qk.js} +2 -2
  226. package/dist/web/assets/index-erq7hUne.css +1 -0
  227. package/dist/web/assets/{info-DLdbiUrh.js → info-5bL9xSSf.js} +1 -1
  228. package/dist/web/assets/{jsonMode-KEdMfkIf.js → jsonMode-CYimnBhD.js} +1 -1
  229. package/dist/web/assets/{lspLanguageFeatures-5KZwEoxW.js → lspLanguageFeatures-CiFuk-P7.js} +1 -1
  230. package/dist/web/assets/{minimize-2-CqcI4zcM.js → minimize-2-BGVWKvTg.js} +1 -1
  231. package/dist/web/assets/{monaco.contribution-omszXBEj.js → monaco.contribution-BTY4dJ0f.js} +2 -2
  232. package/dist/web/assets/{monaco.contribution-BJGj65F9.js → monaco.contribution-C7sMrcos.js} +2 -2
  233. package/dist/web/assets/{monaco.contribution-DO10L0zW.js → monaco.contribution-DUE3CQph.js} +2 -2
  234. package/dist/web/assets/{monaco.contribution-Cly9Wt7L.js → monaco.contribution-DkLVGT8N.js} +2 -2
  235. package/dist/web/assets/{monitor-BFVCcbxp.js → monitor-B5hx_tzp.js} +1 -1
  236. package/dist/web/assets/{play-C469pVZq.js → play-pmSO95Qg.js} +1 -1
  237. package/dist/web/assets/{python-Dw0YcVy9.js → python-CiZvL3LX.js} +1 -1
  238. package/dist/web/assets/{save-CtSjPydi.js → save-CvYL4DUg.js} +1 -1
  239. package/dist/web/assets/{square-BuImvLhT.js → square-DT_uFOml.js} +1 -1
  240. package/dist/web/assets/{toggleHighContrast-DjCO9lIP.js → toggleHighContrast-CrE1_HY0.js} +1 -1
  241. package/dist/web/assets/{tsMode-BAOnxKd6.js → tsMode-CI_PdZmj.js} +1 -1
  242. package/dist/web/assets/{upload-2JkFZo3h.js → upload-PVi8vC3T.js} +1 -1
  243. package/dist/web/assets/{useLocalAgentSchedules-BNqAisfS.js → useLocalAgentSchedules-BHJNVf42.js} +1 -1
  244. package/dist/web/assets/useProviderSettings-CU3zXyie.js +5 -0
  245. package/dist/web/assets/{useProviderSettings-CmL_BaxP.css → useProviderSettings-Cktvzinz.css} +1 -1
  246. package/dist/web/assets/{useSessionTurnCache-BHU2-Jmz.js → useSessionTurnCache-BE7cipLX.js} +1 -1
  247. package/dist/web/assets/{wifi-off-CpOAH62M.js → wifi-off-7WiFuOhD.js} +1 -1
  248. package/dist/web/assets/{workers-0QvlA2T5.js → workers-Cv8r4CvM.js} +1 -1
  249. package/dist/web/assets/{yaml-BK3qxo7D.js → yaml-Bj7mdkV2.js} +1 -1
  250. package/dist/web/index.html +2 -2
  251. package/docs/command-reference.md +10 -3
  252. package/docs/conversation-imports.md +57 -0
  253. package/package.json +1 -1
  254. package/dist/chunks/app-server-runtime-ISGGLQHU.js +0 -2
  255. package/dist/chunks/chunk-6UDGARFC.js +0 -143
  256. package/dist/chunks/chunk-FV2R5RUN.js +0 -3
  257. package/dist/chunks/chunk-HY3GOBFJ.js +0 -58
  258. package/dist/chunks/chunk-I3HZKJB3.js +0 -2
  259. package/dist/chunks/chunk-I3VVWNUW.js +0 -5
  260. package/dist/chunks/chunk-KG325WTN.js +0 -2
  261. package/dist/chunks/chunk-VRIEKBBH.js +0 -9
  262. package/dist/chunks/chunk-WJ43MJ3F.js +0 -2
  263. package/dist/chunks/chunk-ZTNHW2K7.js +0 -10
  264. package/dist/chunks/cli-XZENDZ7Z.js +0 -2
  265. package/dist/chunks/connected-app-executor-LQNIU5NR.js +0 -2
  266. package/dist/chunks/connection-HTF6CC7M.js +0 -2
  267. package/dist/chunks/core-commands-A2DGGIPS.js +0 -2
  268. package/dist/chunks/host-profile-evaluation-tools-JOFBL5OF.js +0 -2
  269. package/dist/chunks/host-profile-external-dataset-K3ICDHIP.js +0 -2
  270. package/dist/chunks/hosted-harness-runtime-YCKB6NBI.js +0 -2
  271. package/dist/chunks/hosted-profile-compiler-IYLLHCRY.js +0 -2
  272. package/dist/chunks/import-MLZUHITH.js +0 -4
  273. package/dist/chunks/local-harness-improvement-runtime-QRFGPFRM.js +0 -2
  274. package/dist/chunks/local-harness-taskset-review-HR7KLY4B.js +0 -2
  275. package/dist/chunks/project-action-payload-JDS6OQAW.js +0 -2
  276. package/dist/chunks/refiner-profile-service-FDTQKY33.js +0 -2
  277. package/dist/chunks/saved-work-SHEEDZ6Z.js +0 -2
  278. package/dist/chunks/standalone-experiment-turn-owner-JCY5LL5R.js +0 -2
  279. package/dist/web/assets/App-s-CJswyt.js +0 -154
  280. package/dist/web/assets/AppsView-BYE5EBDJ.js +0 -1
  281. package/dist/web/assets/ComposerCreateImproveStrip-CEgh4OtN.js +0 -1
  282. package/dist/web/assets/LabSkillSidebar-BxffN-pN.js +0 -1
  283. package/dist/web/assets/MainChatThread-DZpcFRFl.js +0 -2
  284. package/dist/web/assets/MainPane-5DTtwVCk.js +0 -65
  285. package/dist/web/assets/OutputsPage-Cr1Spf7S.js +0 -1
  286. package/dist/web/assets/RightChatPanelStack-T6VRWuHo.js +0 -1
  287. package/dist/web/assets/SettingsView-Dulr_xlq.css +0 -1
  288. package/dist/web/assets/TrainingCreationPanel-BXHfohNm.js +0 -1
  289. package/dist/web/assets/index-3iPNbbER.css +0 -1
  290. package/dist/web/assets/useProviderSettings-C4L4wDoh.js +0 -5
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UsageSettingsSection-CrdcSGeW.js","assets/index-C8aCGagb.js","assets/index-3iPNbbER.css","assets/App-s-CJswyt.js","assets/App-CaRMZoxo.css","assets/arrow-up-right-C9aE8Mfz.js","assets/CartesianChart-C1DIx0Ia.js","assets/UsageSettingsSection-Csg3diiE.css"])))=>i.map(i=>d[i]);
2
- import{r as l,j as e,_ as vt}from"./index-C8aCGagb.js";import{e as Pe,g as ye,bb as xs,U as bt,bc as yt,bd as us,X as pe,be as hs,bf as Js,bg as Nt,bh as wt,bi as St,bj as kt,V as U,bk as Ys,t as Ne,aA as he,S as Ve,aO as Ct,bl as Qs,bm as Rt,bn as ls,aF as Pt,bo as At,bp as It,bq as Et,ae as Xs,p as ms,br as $t,r as Dt,af as rs,x as ps,bs as Ye,I as He,bt as os,bu as Ze,aW as Tt,C as Lt,bv as Fe,a2 as cs,aJ as Ot,K as Ke,bw as Ut,bx as Mt,w as zt,b8 as Zs,by as Ht,aG as js,J as Bt,bz as Me,v as et,bA as _t,bB as Ft,Y as Wt,bC as vs,aD as qt,ac as Gt,ap as es,a_ as Vt,bD as Kt,bE as Jt,bF as Yt,bG as Qt,aC as Xt,bH as Zt}from"./App-s-CJswyt.js";import{K as en,u as sn,P as tn}from"./useProviderSettings-C4L4wDoh.js";/* empty css */import{S as st}from"./save-CtSjPydi.js";import{T as Qe,P as tt,d as nn,W as an,A as ln,C as rn,c as Ie}from"./MarkdownText-BR4V6lNO.js";import{F as nt}from"./folder-open-sYgceW_f.js";import{P as at}from"./play-C469pVZq.js";import{B as on,a as it,W as cn,S as dn}from"./wifi-off-CpOAH62M.js";import{C as we}from"./cloud-upload-k9eqBsHr.js";import{G as Je}from"./git-commit-horizontal-DrGxH2h4.js";import{u as un}from"./useLocalAgentSchedules-BNqAisfS.js";import{F as hn}from"./folder-plus-CS0R49m9.js";import{A as mn}from"./AppDialog-t2Fx5tK3.js";import{C as lt,W as pn}from"./WorkspaceDiffPanel-BAFo0CPN.js";import"./training-model-data-CKOkpBBL.js";import"./info-DLdbiUrh.js";import"./minimize-2-CqcI4zcM.js";import"./clipboard-Dk158Qp4.js";const fn=[["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"}]],gn=Pe("clipboard-copy",fn);const xn=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],jn=Pe("eye",xn);const vn=[["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"}]],bn=Pe("hard-drive",vn);const yn=[["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"}]],rt=Pe("radio-tower",yn);const Nn=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],wn=Pe("rotate-cw",Nn);const Sn=[["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"}]],kn=Pe("sliders-horizontal",Sn);const Cn=[["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"}]],bs=Pe("circle-user",Cn);function Rn({connection:s}){const[t,a]=l.useState(null),[n,i]=l.useState({model:null,watchHostedThreads:!0,watchLocalThreads:!0,watchWorkflows:!0,notifications:"attention",supervision:{mode:"off",intervalMinutes:5}}),[r,u]=l.useState(0),[d,c]=l.useState(null),[m,o]=l.useState(!1),[f,p]=l.useState(()=>localStorage.getItem("openpond:ponder-notifications")==="on");l.useEffect(()=>{if(!s)return;const x=new AbortController;return a(null),i({model:null,watchHostedThreads:!0,watchLocalThreads:!0,watchWorkflows:!0,notifications:"attention",supervision:{mode:"off",intervalMinutes:5}}),c(null),ye(s,"/v1/ponder/settings",{signal:x.signal}).then(N=>{a(N),i(N.settings)}).catch(N=>{x.signal.aborted||c(N instanceof Error?N.message:String(N))}),()=>x.abort()},[s,r]);async function g(){if(!(!s||!t||m)){o(!0);try{const x=await ye(s,"/v1/ponder/settings",{method:"POST",body:JSON.stringify(n)});i(x.settings),c(null),window.dispatchEvent(new Event("ponder-settings-changed"))}catch(x){c(x instanceof Error?x.message:String(x))}finally{o(!1)}}}async function j(){if(!f&&!window.openpond?.notify){if(!("Notification"in window)){c("Notifications are unavailable in this browser.");return}if(await Notification.requestPermission()!=="granted"){c("Allow notifications in your browser settings to enable them.");return}}const x=!f;p(x),localStorage.setItem("openpond:ponder-notifications",x?"on":"off")}const v=t?.models.find(x=>x.modelId===n?.model?.modelId&&x.providerId===n?.model?.providerId);return e.jsxs("section",{className:"account-settings",children:[e.jsxs("header",{className:"section-heading",children:[e.jsx("h2",{children:"Ponder Pal"}),e.jsx("p",{children:"Use your deployed model and keep track of your conversations and workflows."})]}),d&&e.jsx("p",{role:"alert",children:d}),d&&!t&&e.jsx("button",{type:"button",onClick:()=>u(x=>x+1),children:"Retry"}),!t&&!d&&e.jsx("p",{role:"status",children:"Fetching model choices and saved preferences…"}),e.jsxs("fieldset",{disabled:!t||m,className:"account-list",children:[e.jsxs("label",{children:["Model",e.jsxs("select",{value:n.model?`${n.model.providerId}|${n.model.modelId}`:"default",onChange:x=>{const N=t?.models.find(k=>`${k.providerId}|${k.modelId}`===x.target.value);i({...n,model:N?{providerId:N.providerId,modelId:N.modelId,reasoningEffort:N.defaultReasoningEffort}:null})},children:[e.jsx("option",{value:"default",children:"Ponder model — shared Qwen, then your accepted version"}),t?.models.map(x=>e.jsx("option",{value:`${x.providerId}|${x.modelId}`,children:x.displayName},`${x.providerId}|${x.modelId}`)),n.model&&!v&&e.jsx("option",{value:`${n.model.providerId}|${n.model.modelId}`,children:"Selected model is unavailable"})]})]}),v&&v.reasoningOptions.length>0&&e.jsxs("label",{children:["Reasoning",e.jsx("select",{value:n.model?.reasoningEffort,onChange:x=>i({...n,model:{...n.model,reasoningEffort:x.target.value}}),children:v.reasoningOptions.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))})]}),e.jsx("p",{children:"Your trained model appears here once it is deployed and available to your account."}),[["watchHostedThreads","Follow hosted conversations"],["watchLocalThreads","Share local thread titles and run status"],["watchWorkflows","Follow workflows and their runs"]].map(([x,N])=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:n[x],onChange:k=>i({...n,[x]:k.target.checked})}),N]},x)),e.jsx("p",{children:"Activity gives Ponder Pal context. It does not automatically message or change your tasks."}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:n.supervision.mode==="recommend",onChange:x=>i({...n,supervision:{...n.supervision,mode:x.target.checked?"recommend":"off"}})}),"Recommend changes when hosted work needs attention"]}),e.jsxs("label",{children:["Check for missed updates",e.jsxs("select",{value:n.supervision.intervalMinutes,onChange:x=>i({...n,supervision:{...n.supervision,intervalMinutes:Number(x.target.value)}}),children:[e.jsx("option",{value:5,children:"Every 5 minutes"}),e.jsx("option",{value:10,children:"Every 10 minutes"})]})]}),e.jsx("p",{children:"Task updates trigger reviews. Unchanged work is skipped. You review and send each proposed message."}),e.jsxs("label",{children:["Notifications",e.jsxs("select",{value:n.notifications,onChange:x=>i({...n,notifications:x.target.value}),children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"attention",children:"Completions and things that need attention"}),e.jsx("option",{value:"all",children:"All activity"})]})]}),e.jsx("button",{type:"button",onClick:()=>{j()},children:f?"Disable notifications on this device":"Enable notifications on this device"}),e.jsx("button",{type:"button",disabled:!t||m,onClick:()=>{g()},children:m?"Saving…":"Save"})]})]})}function ys({connection:s,bannerOnly:t=!1,onOpen:a,onSaved:n}){const[i,r]=l.useState(null),[u,d]=l.useState(null),[c,m]=l.useState(null),[o,f]=l.useState(!1),[p,g]=l.useState(null),[j,v]=l.useState(!1),[x,N]=l.useState(xs);bt(()=>N(xs()));const k=l.useRef(0),A=l.useCallback(async y=>{if(!s)return;const R=++k.current,O=await ye(s,"/v1/configuration",{signal:y});!y?.aborted&&R===k.current&&r(O)},[s]);l.useEffect(()=>{r(null),d(null),m(null),g(null);const y=new AbortController,R=()=>{A(y.signal).catch(I=>{y.signal.aborted||g(String(I))})};R();const O=window.setInterval(R,3e3);return()=>{k.current+=1,y.abort(),window.clearInterval(O)}},[A]);async function $(y,R){if(!(!s||!i)){v(!0),g(null);try{const O=y==="restore"?{action:y,revision:R,expectedRevision:i.rawRevision}:y==="validate"?{action:y,text:u??i.text??`schema_version = 1
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ConversationImportsSettings-CuQcvVgE.js","assets/index-DEg0S7Qk.js","assets/index-erq7hUne.css","assets/App-pcwmC4IR.js","assets/App-CaRMZoxo.css","assets/agent-connections-4Dza2mDg.js","assets/ConversationImportsSettings-PfUa8V7X.css","assets/UsageSettingsSection-CC57FcUB.js","assets/arrow-up-right-xKb5kWQJ.js","assets/CartesianChart-B2Sxi0lv.js","assets/UsageSettingsSection-Csg3diiE.css"])))=>i.map(i=>d[i]);
2
+ import{r as l,j as e,_ as Js}from"./index-DEg0S7Qk.js";import{e as Pe,g as ye,bc as xs,V as bt,bd as yt,be as us,X as pe,bf as hs,bg as Ys,bh as Nt,bi as St,bj as wt,bk as kt,W as U,bl as Qs,v as Ne,aB as de,T as Ve,aP as Ct,bm as Xs,bn as Rt,bo as ls,aG as Pt,bp as At,bq as It,br as Et,af as Zs,q as ms,bs as $t,t as Dt,ag as rs,y as ps,bt as Ye,J as He,bu as os,bv as Ze,aX as Lt,C as Tt,bw as Fe,a3 as cs,aK as Ot,L as Ke,bx as Ut,by as Mt,x as zt,b9 as et,bz as Ht,aH as js,K as Bt,bA as Me,w as st,bB as _t,bC as Ft,Z as Wt,bD as vs,aE as qt,ad as Gt,aq as es,a$ as Vt,bE as Kt,bF as Jt,bG as Yt,bH as Qt,aD as Xt,bI as Zt}from"./App-pcwmC4IR.js";import{K as en,u as sn,P as tn}from"./useProviderSettings-CU3zXyie.js";/* empty css */import{S as tt}from"./save-CvYL4DUg.js";import{T as Qe,P as nt,d as nn,W as an,A as ln,C as rn,c as Ie}from"./MarkdownText-BBVriBCj.js";import{F as at}from"./folder-open-CbmUjIYS.js";import{P as it}from"./play-pmSO95Qg.js";import{B as on,a as lt,W as cn,S as dn}from"./wifi-off-7WiFuOhD.js";import{C as Se}from"./cloud-upload-Bw9XUsKQ.js";import{G as Je}from"./git-commit-horizontal-BIS-8MuS.js";import{u as un}from"./useLocalAgentSchedules-BHJNVf42.js";import{F as hn}from"./folder-plus-slsst7Ct.js";import{A as mn}from"./AppDialog-CdHad7GT.js";import{C as rt,W as pn}from"./WorkspaceDiffPanel-CL7wi3kp.js";import"./training-model-data-CKOkpBBL.js";import"./info-5bL9xSSf.js";import"./minimize-2-BGVWKvTg.js";import"./clipboard-BgjV3aCx.js";const fn=[["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"}]],gn=Pe("clipboard-copy",fn);const xn=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],jn=Pe("eye",xn);const vn=[["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"}]],bn=Pe("hard-drive",vn);const yn=[["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"}]],ot=Pe("radio-tower",yn);const Nn=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Sn=Pe("rotate-cw",Nn);const wn=[["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"}]],kn=Pe("sliders-horizontal",wn);const Cn=[["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"}]],bs=Pe("circle-user",Cn);function Rn({connection:s}){const[t,a]=l.useState(null),[n,i]=l.useState({model:null,watchHostedThreads:!0,watchLocalThreads:!0,watchWorkflows:!0,notifications:"attention",supervision:{mode:"off",intervalMinutes:5}}),[r,u]=l.useState(0),[d,c]=l.useState(null),[m,o]=l.useState(!1),[f,p]=l.useState(()=>localStorage.getItem("openpond:ponder-notifications")==="on");l.useEffect(()=>{if(!s)return;const x=new AbortController;return a(null),i({model:null,watchHostedThreads:!0,watchLocalThreads:!0,watchWorkflows:!0,notifications:"attention",supervision:{mode:"off",intervalMinutes:5}}),c(null),ye(s,"/v1/ponder/settings",{signal:x.signal}).then(N=>{a(N),i(N.settings)}).catch(N=>{x.signal.aborted||c(N instanceof Error?N.message:String(N))}),()=>x.abort()},[s,r]);async function g(){if(!(!s||!t||m)){o(!0);try{const x=await ye(s,"/v1/ponder/settings",{method:"POST",body:JSON.stringify(n)});i(x.settings),c(null),window.dispatchEvent(new Event("ponder-settings-changed"))}catch(x){c(x instanceof Error?x.message:String(x))}finally{o(!1)}}}async function j(){if(!f&&!window.openpond?.notify){if(!("Notification"in window)){c("Notifications are unavailable in this browser.");return}if(await Notification.requestPermission()!=="granted"){c("Allow notifications in your browser settings to enable them.");return}}const x=!f;p(x),localStorage.setItem("openpond:ponder-notifications",x?"on":"off")}const v=t?.models.find(x=>x.modelId===n?.model?.modelId&&x.providerId===n?.model?.providerId);return e.jsxs("section",{className:"account-settings",children:[e.jsxs("header",{className:"section-heading",children:[e.jsx("h2",{children:"Ponder Pal"}),e.jsx("p",{children:"Use your deployed model and keep track of your conversations and workflows."})]}),d&&e.jsx("p",{role:"alert",children:d}),d&&!t&&e.jsx("button",{type:"button",onClick:()=>u(x=>x+1),children:"Retry"}),!t&&!d&&e.jsx("p",{role:"status",children:"Fetching model choices and saved preferences…"}),e.jsxs("fieldset",{disabled:!t||m,className:"account-list",children:[e.jsxs("label",{children:["Model",e.jsxs("select",{value:n.model?`${n.model.providerId}|${n.model.modelId}`:"default",onChange:x=>{const N=t?.models.find(k=>`${k.providerId}|${k.modelId}`===x.target.value);i({...n,model:N?{providerId:N.providerId,modelId:N.modelId,reasoningEffort:N.defaultReasoningEffort}:null})},children:[e.jsx("option",{value:"default",children:"Ponder model — shared Qwen, then your accepted version"}),t?.models.map(x=>e.jsx("option",{value:`${x.providerId}|${x.modelId}`,children:x.displayName},`${x.providerId}|${x.modelId}`)),n.model&&!v&&e.jsx("option",{value:`${n.model.providerId}|${n.model.modelId}`,children:"Selected model is unavailable"})]})]}),v&&v.reasoningOptions.length>0&&e.jsxs("label",{children:["Reasoning",e.jsx("select",{value:n.model?.reasoningEffort,onChange:x=>i({...n,model:{...n.model,reasoningEffort:x.target.value}}),children:v.reasoningOptions.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))})]}),e.jsx("p",{children:"Your trained model appears here once it is deployed and available to your account."}),[["watchHostedThreads","Follow hosted conversations"],["watchLocalThreads","Share local thread titles and run status"],["watchWorkflows","Follow workflows and their runs"]].map(([x,N])=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:n[x],onChange:k=>i({...n,[x]:k.target.checked})}),N]},x)),e.jsx("p",{children:"Activity gives Ponder Pal context. It does not automatically message or change your tasks."}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:n.supervision.mode==="recommend",onChange:x=>i({...n,supervision:{...n.supervision,mode:x.target.checked?"recommend":"off"}})}),"Recommend changes when hosted work needs attention"]}),e.jsxs("label",{children:["Check for missed updates",e.jsxs("select",{value:n.supervision.intervalMinutes,onChange:x=>i({...n,supervision:{...n.supervision,intervalMinutes:Number(x.target.value)}}),children:[e.jsx("option",{value:5,children:"Every 5 minutes"}),e.jsx("option",{value:10,children:"Every 10 minutes"})]})]}),e.jsx("p",{children:"Task updates trigger reviews. Unchanged work is skipped. You review and send each proposed message."}),e.jsxs("label",{children:["Notifications",e.jsxs("select",{value:n.notifications,onChange:x=>i({...n,notifications:x.target.value}),children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"attention",children:"Completions and things that need attention"}),e.jsx("option",{value:"all",children:"All activity"})]})]}),e.jsx("button",{type:"button",onClick:()=>{j()},children:f?"Disable notifications on this device":"Enable notifications on this device"}),e.jsx("button",{type:"button",disabled:!t||m,onClick:()=>{g()},children:m?"Saving…":"Save"})]})]})}function ys({connection:s,bannerOnly:t=!1,onOpen:a,onSaved:n}){const[i,r]=l.useState(null),[u,d]=l.useState(null),[c,m]=l.useState(null),[o,f]=l.useState(!1),[p,g]=l.useState(null),[j,v]=l.useState(!1),[x,N]=l.useState(xs);bt(()=>N(xs()));const k=l.useRef(0),I=l.useCallback(async y=>{if(!s)return;const R=++k.current,O=await ye(s,"/v1/configuration",{signal:y});!y?.aborted&&R===k.current&&r(O)},[s]);l.useEffect(()=>{r(null),d(null),m(null),g(null);const y=new AbortController,R=()=>{I(y.signal).catch(A=>{y.signal.aborted||g(String(A))})};R();const O=window.setInterval(R,3e3);return()=>{k.current+=1,y.abort(),window.clearInterval(O)}},[I]);async function $(y,R){if(!(!s||!i)){v(!0),g(null);try{const O=y==="restore"?{action:y,revision:R,expectedRevision:i.rawRevision}:y==="validate"?{action:y,text:u??i.text??`schema_version = 1
3
3
  `}:{action:y,text:u??i.text??`schema_version = 1
4
- `,expectedRevision:c??i.rawRevision};await ye(s,"/v1/configuration",{method:"POST",body:JSON.stringify(O)}),y!=="validate"&&(d(null),m(null),await A(),await n?.()),g(y==="validate"?"Configuration is valid.":"Saved. Changes apply to the next turn.")}catch(O){g(O instanceof Error?O.message:String(O))}finally{v(!1)}}}return!s||t&&!i?.issue&&!x?null:e.jsxs("section",{className:`account-settings configuration-settings ${t?"configuration-banner":""}`,"aria-label":"Configuration",children:[t?null:e.jsxs("header",{children:[e.jsx("h1",{children:"Configuration"}),e.jsx("p",{children:"Manage your settings in one TOML file. The controls below save to the same file; unset an override to inherit its default."})]}),x?e.jsxs("p",{role:"alert",children:[x," ",e.jsx("button",{type:"button",onClick:yt,children:"Retry saving preferences"})]}):null,i?.issue?e.jsxs("div",{role:"alert",children:[e.jsx("strong",{children:"Configuration needs attention"}),e.jsx("p",{children:i.issue.message}),e.jsx("p",{children:e.jsxs("code",{children:[i.issue.path,i.issue.line?`:${i.issue.line}:${i.issue.column??1}`:""]})}),e.jsxs("p",{children:[i.issue.action," Affected turns are blocked until this is corrected."]}),e.jsx("button",{type:"button",onClick:()=>{t?a?.():f(!0)},children:"Open configuration"})]}):null,t?null:e.jsxs("details",{open:o,onToggle:y=>f(y.currentTarget.open),children:[e.jsx("summary",{children:"Configuration file and sources"}),e.jsx("p",{children:e.jsx("code",{children:i?.path??"Loading…"})}),e.jsx("p",{children:"Unset an override to inherit its default. Changes apply to the next turn; current turns retain their model settings."}),e.jsx("textarea",{"aria-label":"TOML configuration",spellCheck:!1,rows:18,style:{width:"100%",fontFamily:"monospace"},value:u??i?.text??`schema_version = 1
5
- `,onChange:y=>{u===null&&m(i?.rawRevision??null),d(y.target.value)}}),u!==null&&i?.rawRevision!==c?e.jsx("p",{role:"alert",children:"The file changed elsewhere. Reload before saving your edits."}):null,e.jsxs("div",{className:"configuration-actions",children:[e.jsx("button",{type:"button",disabled:j||!i,onClick:()=>{$("validate")},children:"Validate"}),e.jsx("button",{type:"button",disabled:j||!i||u!==null&&i.rawRevision!==c,onClick:()=>{$("replace")},children:"Save config"}),e.jsx("button",{type:"button",disabled:j,onClick:()=>{d(null),m(null),A().catch(y=>g(String(y)))},children:"Reload file"})]}),i?.recoverableRevisions.length?e.jsxs("label",{children:["Restore a verified revision ",e.jsxs("select",{value:"",disabled:j,onChange:y=>{y.target.value&&$("restore",y.target.value)},children:[e.jsx("option",{value:"",children:"Choose a revision…"}),i.recoverableRevisions.map(y=>e.jsxs("option",{value:y.revision,children:[new Date(y.createdAt).toLocaleString()," · ",y.revision.slice(0,12)]},y.revision))]})]}):null,i?.effective?e.jsxs("details",{children:[e.jsx("summary",{children:"Effective values and sources"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Setting"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Location"})]})}),e.jsx("tbody",{children:Object.entries(i.effective.provenance).map(([y,R])=>e.jsxs("tr",{children:[e.jsx("td",{children:JSON.parse(y).join(".")}),e.jsx("td",{children:R.layer==="user"?"Set here":`Inherited from ${R.layer}`}),e.jsx("td",{children:R.path})]},y))})]}),e.jsx("pre",{children:JSON.stringify(i.effective.document,null,2)})]}):null]}),p?e.jsx("p",{role:"status",children:p}):null]})}function Ns({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 ws({state:s,label:t}){return e.jsx("span",{className:`account-state ${s}`,children:t??s.replace("_"," ")})}const Pn="https://www.openpond.ai",An="https://api.openpond.ai";function Ss(s){try{const a=new URL(s).hostname.toLowerCase();if(a==="openpond.ai"||a==="www.openpond.ai")return An}catch{}return""}function ks(s,t){try{const a=new URL(s);if(a.protocol==="https:"||a.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(a.hostname))return null}catch{}return`${t} must be an https:// URL (or http:// for localhost).`}function Cs({account:s,busy:t,mode:a="update",onClose:n,onSave:i,onRemove:r}){const u=l.useId(),d=l.useRef(null),c=a==="connect",m=s?.baseUrl??Pn,o=s?.apiBaseUrl??Ss(m),[f,p]=l.useState(m),[g,j]=l.useState(o),[v,x]=l.useState(""),[N,k]=l.useState(null),[A,$]=l.useState(null);us(A);function y(I){p(I),j(I.trim().replace(/\/+$/,"")===m?o:Ss(I))}async function R(I){I.preventDefault(),k(null),$(null);const h=v.trim(),w=f.trim().replace(/\/+$/,""),C=g.trim().replace(/\/+$/,""),S=(c&&!h?"API key is required.":null)??ks(w,"Environment URL")??ks(C,"API URL");if(S){k(S),(S.startsWith("Environment URL")||S.startsWith("API URL"))&&d.current&&(d.current.open=!0);return}try{await i({handle:c?void 0:s?.handle,currentBaseUrl:c?null:s?.baseUrl??null,baseUrl:w,apiBaseUrl:C,chatApiBaseUrl:c||C!==o?null:s?.chatApiBaseUrl,apiKey:h||void 0,environment:new URL(w).hostname.replace(/^www\./,"")==="openpond.ai"?"production":"custom"})}catch(M){$(M instanceof Error?M.message:String(M))}}async function O(){r&&await r()&&n()}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:I=>{I.target===I.currentTarget&&!t&&n()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":u,onSubmit:I=>{R(I)},children:[e.jsx("button",{className:"git-dialog-close",disabled:t,type:"button",title:"Close","aria-label":"Close",onClick:n,children:e.jsx(pe,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:c?e.jsx(en,{size:18}):e.jsx(hs,{size:18})}),e.jsx("h2",{id:u,children:c?"Add account":"Account settings"}),e.jsx("p",{children:c?"Connect an OpenPond account with an API key.":"Review this account and its verified key access."}),!c&&s?e.jsxs("div",{className:"account-dialog-details",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Account"}),e.jsx("strong",{children:s.displayLabel||s.handle})]}),s.email?e.jsxs("div",{children:[e.jsx("span",{children:"Email"}),e.jsx("strong",{children:s.email})]}):null,e.jsxs("div",{children:[e.jsx("span",{children:"Handle"}),e.jsx("strong",{children:s.handle})]}),e.jsxs("div",{children:[e.jsx("span",{children:"API key"}),e.jsx("strong",{children:s.apiKeyHint??(s.authHealth==="signed_in"?"Connected with a session":"No saved API key")})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Access"}),e.jsx("strong",{children:s.apiKeyAccess?s.apiKeyAccess.teamId?"This workspace":s.apiKeyAccess.ownerType==="user"?"All my workspaces":"Account access":"Not verified"})]}),s.apiKeyAccess?e.jsxs("div",{children:[e.jsx("span",{children:"Scopes"}),e.jsx("strong",{children:s.apiKeyAccess.scopes.join(", ")||"No scopes"})]}):null]}):null,c?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoComplete:"off",disabled:t,placeholder:"opk_...",type:"password",value:v,onChange:I=>x(I.target.value)})]}):null,e.jsxs("details",{className:"account-dialog-advanced",ref:d,children:[e.jsx("summary",{children:"Advanced"}),e.jsxs("div",{className:"account-dialog-advanced-fields",children:[c?null:e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Replace API key"}),e.jsx("input",{autoComplete:"off",disabled:t,placeholder:"Leave blank to keep the current key",type:"password",value:v,onChange:I=>x(I.target.value)}),e.jsx("small",{children:"Enter a new key to replace the saved credential."})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Environment URL"}),e.jsx("input",{disabled:t,inputMode:"url",spellCheck:!1,type:"url",value:f,onChange:I=>y(I.target.value)}),e.jsx("small",{children:"Change this URL to connect this account to another environment."})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API URL"}),e.jsx("input",{disabled:t,inputMode:"url",spellCheck:!1,type:"url",value:g,onChange:I=>j(I.target.value)}),e.jsx("small",{children:"Enter the API URL for a custom environment."})]})]})]}),N?e.jsx("div",{className:"profile-dialog-warning",children:N}):null,e.jsx("div",{className:"git-dialog-footer account-dialog-footer",children:e.jsxs("div",{className:"account-dialog-save-actions",children:[!c&&r?e.jsxs("button",{className:"git-dialog-secondary account-dialog-remove",disabled:t,type:"button",onClick:()=>{O()},children:[e.jsx(Qe,{size:14})," Remove account"]}):null,e.jsx("button",{className:"git-dialog-secondary",disabled:t,type:"button",onClick:n,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:t,type:"submit",children:[e.jsx(st,{size:14}),e.jsx("span",{children:t?"Saving":c?"Connect account":"Save changes"})]})]})})]})})}const In="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 En({payload:s,connection:t,saving:a,refreshingAccounts:n,saveAccount:i,refreshAccounts:r,switchAccount:u,removeAccount:d,onPayload:c,onPreferences:m,onError:o,onToast:f}){const p=s?.account,g=p?.state??"loading",j=g==="signed_in",v=g==="signed_out",x=g==="auth_error",N=p?.email?.trim()||null,k=p?.accounts??[],[A,$]=l.useState([]),[,y]=l.useState(!1),[R,O]=l.useState(null),[I,h]=l.useState(!1),[w,C]=l.useState(void 0),S=l.useRef(0),[M,F]=l.useState(null),[W,se]=l.useState(!1),[X,D]=l.useState(null),[Z,te]=l.useState(null),[B,le]=l.useState(!1),{confirmAction:ie,confirmDialog:V,resolveConfirmDialog:q}=Js(),Y=k.find(T=>T.isActive)??k[0]??null,de=s?.preferences.defaultTeamId?.trim()||null,re=w===void 0?de:w,oe=Nt(p),K=s?.accountMeta.asOf??"",Q=Se(p?.environment,Y?.environment),ue=j?Se(Y?.displayLabel,Y?.handle,p?.label,p?.activeProfile?.handle,"Signed in"):x?"Account needs attention":v?"No account connected":"Loading account",ee=j?N??Rs(Y?.baseUrl??p?.baseUrl,Q):x?"Not connected":v?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",me=k.length>0,L=x?$n(p?.error):null,P=l.useMemo(()=>A.filter(T=>T.status==="active"),[A]),H=l.useMemo(()=>{const T=[{value:"",label:"Personal account",description:"Your personal tasks and computers"},...P.map(G=>({value:G.teamId,label:Se(G.displayName,G.name,G.slug,"Team"),description:wt(G.role)}))];return re&&!T.some(G=>G.value===re)&&T.push({value:re,label:"Selected workspace",description:re}),T},[P,re]),z=re??"",ne=!t||I,ce=M?ss(M):null,ae=!!(ce&&X===ce),Ae=j||x,Oe=Se(Z?.version,s?.server.version,"Loading"),b=Z?Z.devMode?"Dev mode":Z.packaged?`${Ln(Z.releaseChannel)} build`:"Local build":null,E=Dn(Se(Y?.baseUrl,p?.activeProfile?.baseUrl,p?.baseUrl,"https://openpond.ai"));l.useEffect(()=>{const T=window.openpond?.getDesktopRuntimeInfo;if(!T)return;let G=!1;return T().then(J=>{G||te(J)}).catch(()=>{G||te(null)}),()=>{G=!0}},[]),l.useEffect(()=>{if(!t||!oe){$([]),O(null),y(!1);return}let T=!1;const G=St(oe);return G?($(G),y(!1)):($([]),y(!0)),O(null),kt({accountKey:oe,force:!!K,fetchOrganizations:async()=>(await U.organizations(t)).organizations.map(Ys).filter(ge=>!!ge).filter(ge=>ge.status==="active")}).then(J=>{T||$(J)}).catch(J=>{T||(G||$([]),O(J instanceof Error?J.message:String(J)))}).finally(()=>{T||y(!1)}),()=>{T=!0}},[K,t,oe]),l.useEffect(()=>(++S.current,C(void 0),h(!1),()=>{++S.current}),[t,oe]),l.useEffect(()=>{w!==void 0&&de===w&&C(void 0)},[de,w]);async function _(T,G={notify:!0}){const J=T||null,ge=P.find(xe=>xe.teamId===J)??null;if(!t||J!==null&&!ge||I||re===J)return;C(J),h(!0);const Ue=S.current;o(null),J&&Rt({teamId:J,accountKey:oe,force:!0,fetchAgents:async xe=>(await U.listSandboxAgents(t,{teamId:xe})).agents}).catch(()=>{});try{const xe=await U.savePreferences(t,{defaultTeamId:J});if(Ue!==S.current)return;m(xe),G.notify&&f?.(J?"Workspace selected":"Personal account selected","success")}catch(xe){if(Ue!==S.current)return;C(void 0),o(xe instanceof Error?xe.message:String(xe))}finally{Ue===S.current&&h(!1)}}async function fe(T="Continue"){return Ae?ie({title:"Change active OpenPond account?",body:In,confirmLabel:T,cancelLabel:"Cancel"}):!0}async function Xe(T){await fe("Save account")&&(await i({apiKey:T.apiKey??"",handle:T.handle,baseUrl:T.baseUrl,apiBaseUrl:T.apiBaseUrl,environment:T.environment}),se(!1))}async function pt(T){if(!t||!M)throw new Error("OpenPond server connection is not ready.");if(M.isActive&&!await fe("Save endpoints"))return;const G=ss(M);D(G),o(null);try{const J=await U.updateOpenPondAccountConfig(t,{handle:T.handle??M.handle,currentBaseUrl:T.currentBaseUrl,apiKey:T.apiKey,baseUrl:T.baseUrl,apiBaseUrl:T.apiBaseUrl,chatApiBaseUrl:T.chatApiBaseUrl,environment:T.environment,setActive:M.isActive});c(J),f?.("Account updated","success"),F(null)}catch(J){throw o(J instanceof Error?J.message:String(J)),J}finally{D(null)}}async function ft(T){const G=T.handle?.trim()||"";G&&await fe("Switch account")&&await u(G,T.baseUrl)}async function gt(T){const G=T.handle?.trim()||"";if(!G)return!1;const J=Se(T.displayLabel,T.email,T.handle,"this account");return await ie({title:"Remove saved account?",body:`Remove ${J} from this device? Its saved credential and endpoint settings will be deleted. This does not delete any OpenPond cloud data.`,confirmLabel:"Remove account",cancelLabel:"Cancel",tone:"danger"})&&await d(G,T.baseUrl)?(f?.("Account removed","success"),!0):!1}async function xt(){const T=window.openpond?.reloadDesktopApp;if(!(!T||B)){le(!0),o(null);try{const G=await T();if(!G.ok)throw new Error(G.error??"OpenPond could not refresh the app.")}catch(G){le(!1),o(G instanceof Error?G.message:String(G))}}}async function jt(){const T=window.openpond?.browser;T?.openExternal&&(await T.openExternal({conversationId:"openpond-account-sign-up",url:E})).ok||window.open(E,"_blank","noopener,noreferrer")}return e.jsxs("section",{className:"account-settings",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsx("h1",{children:"Account"}),e.jsxs("div",{className:"account-settings-title-actions",children:[e.jsxs("button",{className:"settings-secondary compact account-add-action",disabled:!t||a,type:"button",onClick:()=>se(!0),children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Add account"})]}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!t||a||n,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{r()},children:e.jsx(he,{size:15,className:n?"settings-spin":void 0})})]})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(Ns,{handle:ue,image:j?p?.avatarUrl??Y?.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:j&&N?"private-account-email":j?void 0:"account-summary-copy",tabIndex:j&&N?0:void 0,children:ee}),j?e.jsx(Ve,{className:"account-team-dropdown",compact:!0,disabled:ne,label:"Workspace",options:H,value:z,onChange:T=>{_(T)}}):null,j&&R?e.jsx("small",{role:"status",children:"Workspaces could not be loaded. Personal access remains available."}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(ws,{state:g,label:v?"not signed in":void 0})})]}),me?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:[k.length," account",k.length===1?"":"s"]})]}),k.map(T=>{const G=T.handle?.trim()||"",J=Se(T.displayLabel,T.handle,"Unknown account"),ge=T.email?.trim()||null,Ue=ss(T);return e.jsxs("div",{className:"account-row",children:[e.jsx(Ns,{handle:J,image:T.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:J}),ge?e.jsx("span",{className:"private-account-email",tabIndex:0,children:ge}):null,e.jsx("span",{children:Rs(T.baseUrl,T.environment)}),T.apiKeyHint?e.jsxs("span",{children:["API key ",T.apiKeyHint]}):null]}),e.jsxs("div",{className:"account-row-actions",children:[T.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,T.isActive?null:e.jsx("button",{className:"inline-action",disabled:a||!G,type:"button",onClick:()=>{ft(T)},children:"Use"}),e.jsx("button",{className:"settings-icon-button ghost account-endpoint-action",disabled:!t||a||!!X||!G,type:"button","aria-label":`Settings for ${J}`,title:"Account settings",onClick:()=>F(T),children:e.jsx(hs,{size:15})})]})]},Ue)})]}):null,p?.products&&p.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:[p.products.length," active"]})]}),p.products.map(T=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:T.name}),e.jsx("span",{children:T.type})]}),e.jsx(ws,{state:T.status})]},T.id))]}),e.jsxs("div",{className:"settings-footnote account-build-footnote",children:[e.jsxs("div",{className:"account-build-details",children:[e.jsx("span",{children:"Build version"}),e.jsxs("div",{className:"account-build-version",children:[e.jsx("strong",{children:Tn(Oe)}),b?e.jsx("span",{className:`account-build-context${Z?.devMode?" development":""}`,children:b}):null]})]}),e.jsxs("div",{className:"account-build-actions",children:[Z?.canReload?e.jsxs("button",{className:"settings-secondary compact",disabled:B,type:"button",title:"Reload the local Electron app",onClick:()=>{xt()},children:[e.jsx(he,{className:B?"settings-spin":void 0,size:14}),e.jsx("span",{children:B?"Refreshing":"Refresh app"})]}):null,j?null:e.jsxs("button",{className:"settings-primary compact account-sign-up-action",type:"button",onClick:()=>{jt()},children:[e.jsx("span",{children:"Sign up"}),e.jsx(Ct,{size:13})]})]})]}),L?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:L})]}):null,M?e.jsx(Cs,{account:M,busy:ae||a,onClose:()=>{ae||F(null)},onSave:pt,onRemove:()=>gt(M)},ce):null,W?e.jsx(Cs,{busy:a,mode:"connect",onClose:()=>{a||se(!1)},onSave:Xe}):null,e.jsx(Qs,{state:V,onResolve:q})]})}function ss(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function Se(...s){for(const t of s){const a=t?.trim();if(a)return a}return""}function $n(s){const t=s?.trim();if(!t)return null;const a=t.toLowerCase();return a.includes("protected deployment")?"OpenPond could not reach the account service. Restart and try again.":a.includes("unexpected token '<'")||a.includes("<!doctype")?"OpenPond received a web login page instead of account data. Restart and try again.":a.includes("401")||a.includes("unauthorized")||a.includes("could not authenticate")?"The API key could not authenticate. Check the key and account environment, then try again.":t.length>220?`${t.slice(0,217)}...`:t}function Rs(s,t){try{if(s)return new URL(s).host}catch{}return t?.trim()||"openpond.ai"}function Dn(s){try{return new URL("/login",s).toString()}catch{return"https://openpond.ai/login"}}function Tn(s){const t=s.trim();return!t||t==="Loading"?"Loading":t.startsWith("v")?t:`v${t}`}function Ln(s){return s&&`${s[0].toUpperCase()}${s.slice(1)}`}function On({advancedWorkspaceControls:s,defaultBranchPrefix:t,defaultNewProjectDirectory:a,preferences:n,saving:i,steerActiveResponses:r,chooseDefaultProjectDirectory:u,saveDefaults:d,setAdvancedWorkspaceControls:c,setSteerActiveResponses:m,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:f}){const p=ls(t)===n.defaultBranchPrefix&&a.trim()===n.defaultNewProjectDirectory&&s===n.advancedWorkspaceControls&&r===n.steerActiveResponses;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h2",{children:"General"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:g=>{d(g)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:r,disabled:i,onChange:g=>m(g.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Steer active responses"}),e.jsx("small",{children:"Send a new message into the active response immediately. Turn this off to queue it instead."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:i,onChange:g=>c(g.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:i,placeholder:"feat/",onChange:g=>o(g.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:i,placeholder:"~/Documents/OpenPond Projects",onChange:g=>f(g.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i,onClick:()=>{u()},children:[e.jsx(nt,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:i||p,children:e.jsx("span",{children:i?"Saving":"Save settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[ls(t),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||n.defaultNewProjectDirectory})]})]})}function Un({diagnostics:s,diagnosticsAvailable:t,diagnosticsBusy:a,diagnosticsStatus:n,logDir:i,logLineLimit:r,logLines:u,logViewBusy:d,logViewSummary:c,logViewportRef:m,tailLogs:o,copyRecentLogs:f,exportDiagnosticsBundle:p,loadOlderLogs:g,openLogsFolder:j,refreshLogView:v,toggleTailLogs:x}){const N=s.filter(A=>A.name==="diagnostic"&&A.status==="failed").slice().reverse().map(Mn),k=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:[N.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:N.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):N.map(A=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Pt,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:A.message}),e.jsx("time",{dateTime:A.timestamp,children:A.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:A.surface}),A.status?e.jsx("span",{children:A.status}):null,A.sequence?e.jsxs("span",{children:["#",A.sequence]}):null]}),A.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:A.detail})]}):null]})]},A.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||!k?.openLogsFolder,onClick:()=>{j()},children:[e.jsx(nt,{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||!k?.exportDiagnostics,onClick:()=>{p()},children:[e.jsx(At,{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||!k?.copyRecentLogs,onClick:()=>{f()},children:[e.jsx(gn,{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:c}),e.jsx("button",{type:"button",className:`settings-icon-button ${o?"active":""}`,title:o?"Pause tail":"Tail logs","aria-label":o?"Pause tail":"Tail logs",disabled:!k?.readRecentLogs,onClick:x,children:o?e.jsx(tt,{size:15}):e.jsx(at,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:d!==null||!k?.readRecentLogs,onClick:()=>{v(r,"refresh")},children:e.jsx(he,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:d!==null||!k?.readRecentLogs,onClick:g,children:[e.jsx(nn,{size:15}),e.jsx("span",{children:d==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:m,className:"diagnostics-log-viewer",role:"log","aria-live":o?"polite":"off",children:u.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:d?"Loading logs":"No log lines"}):u.map((A,$)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:A.file}),e.jsx("code",{children:A.line})]},`${A.file}:${A.timestamp}:${A.index}:${$}`))}),i&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:i})]})]}),n&&e.jsxs("div",{className:`settings-footnote ${n.warning?"warning":""}`,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:n.value})]})]})}function Mn(s){const t=Ps(s.data),a=Ps(t.context),i=be(t.stack)??be(t.detail)??be(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:Hn(s.timestamp),message:zn(s,t),surface:be(t.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:i}}function zn(s,t){return be(s.error)??be(s.output)??be(t.message)??be(t.error)??"Diagnostic event"}function Hn(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Ps(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function be(s){return typeof s=="string"&&s.trim()?s.trim():null}const As=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function Bn({editorPreferences:s,lspStatus:t,preferences:a,restarting:n,saving:i,statusLoading:r,refreshLspStatus:u,restartLanguageServers:d,saveEditorSettings:c,setEditorPreferences:m,setLanguageCustomCommand:o,setLanguageMode:f}){const p=JSON.stringify(s)!==JSON.stringify(a.editor),g=new Map(t?.languages.map(j=>[j.language,j])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:j=>{c(j)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Language servers"}),e.jsx("small",{children:"Local tools"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Language servers"}),e.jsx(Ve,{value:s.languageServers,disabled:i,label:"Language servers",options:It,onChange:j=>m(v=>({...v,languageServers:j}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:i||s.languageServers==="off",onChange:j=>m(v=>({...v,diagnosticsWhileEditing:j.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Diagnostics while editing"}),e.jsx("small",{children:"Update Monaco markers as the local buffer changes."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.checkOnSave,disabled:i||s.languageServers==="off",onChange:j=>m(v=>({...v,checkOnSave:j.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Check on save"}),e.jsx("small",{children:"Refresh diagnostics after writing a file."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Languages"}),e.jsx("small",{children:"Auto, disabled, or custom executable"})]}),e.jsx("div",{className:"lsp-language-list",children:As.map(j=>{const v=s.languages[j.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:j.label}),e.jsx("span",{children:Is(g.get(j.id),r)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Ve,{value:v.mode,disabled:i||s.languageServers==="off",label:`${j.label} language server mode`,options:Et,onChange:x=>f(j.id,x)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:v.customCommand,disabled:i||s.languageServers==="off"||v.mode!=="custom",placeholder:j.placeholder,onChange:x=>o(j.id,x.target.value)})]})]},j.id)})}),e.jsx("button",{className:"settings-primary",disabled:i||!p,children:e.jsx("span",{children:i?"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:r?"Checking":t?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:r||n,onClick:()=>{u()},children:e.jsx(he,{className:r?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:r||n,onClick:()=>{d()},children:[e.jsx(wn,{className:n?"settings-spin":void 0,size:15}),e.jsx("span",{children:n?"Restarting":"Restart"})]})]})]}),As.map(j=>{const v=g.get(j.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:j.label}),e.jsx("span",{title:v?.command??v?.message??void 0,children:v?.command??v?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${v?.status??"missing"}`,children:Is(v,r)})]},j.id)})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Project config"}),e.jsx("strong",{children:"Uses tsconfig, pyrightconfig, pyproject, and Cargo files when present"})]})]})}function Is(s,t){return t&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function Es({contextCompactionAutoEnabled:s,embedded:t=!1,preferences:a,saving:n,saveDefaults:i,setContextCompactionAutoEnabled:r}){return e.jsxs("section",{className:`account-settings${t?" account-settings-embedded":""}`,children:[t?e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Context"}),e.jsx("small",{children:"Compaction defaults for long chats"})]}):e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:u=>{i(u)},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:n,onChange:u=>r(u.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:n||s===a.contextCompaction.autoEnabled,children:e.jsx("span",{children:n?"Saving":"Save context"})})]})]})}function _n({subagentsEnabled:s,subagentDelegationMode:t,subagentsUseDefaultModel:a,subagentsProvider:n,subagentsModel:i,subagentRoles:r,subagentsMaxConcurrentRuns:u,subagentsMaxConcurrentRunsPerProvider:d,subagentsMaxConcurrentRunsPerWorkspaceTarget:c,preferences:m,providers:o,saving:f,saveDefaults:p,changeSubagentsProvider:g,setSubagentsEnabled:j,setSubagentDelegationMode:v,setSubagentsUseDefaultModel:x,setSubagentsModel:N,setSubagentsMaxConcurrentRuns:k,setSubagentsMaxConcurrentRunsPerProvider:A,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:$,setSubagentRoleEnabled:y,setSubagentRoleIsolationMode:R,setSubagentRoleMaxConcurrentRuns:O,setSubagentRoleModel:I,setSubagentRolePeerMessages:h,setSubagentRoleToolPolicy:w,changeSubagentRoleProvider:C}){const S=Xs(o,{enabledOnly:!0}),M=a?m.defaultChatProvider:n,F=a?m.defaultChatModel:i,W=ot(ms(M,o),F),se=a?null:{providerId:n,modelId:i.trim()},X=Vn({enabled:s,delegationMode:t,defaultModelRef:se,roles:r,maxConcurrentRuns:u,maxConcurrentRunsPerProvider:d,maxConcurrentRunsPerWorkspaceTarget:c},m);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:D=>{p(D)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Agents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${X?"":" dirty"}`,disabled:f||X,children:e.jsx("span",{children:f?"Saving":"Save agents"})}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":"Allow subagents",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:f,onChange:D=>j(D.target.checked)}),e.jsx("span",{})]})]})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Default delegation"}),e.jsx("small",{children:"Used unless a task overrides it from the composer."})]})}),e.jsx("div",{className:"subagent-field-grid two",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Subagent use"}),e.jsxs("select",{value:t,disabled:f||!s,onChange:D=>v(D.target.value),children:[e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"balanced",children:"Balanced"}),e.jsx("option",{value:"proactive",children:"Proactive"})]})]})})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsx("div",{children:e.jsx("span",{children:"Default model"})})}),e.jsxs("div",{className:"subagent-field-grid two",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Provider"}),e.jsx("select",{value:M,disabled:f||!s,onChange:D=>{x(!1),g(D.target.value)},children:S.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:F,disabled:f||!s,onChange:D=>{x(!1),N(D.target.value)},children:W.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:r.map(D=>{const Z=$t.find(q=>q.id===D.id),te=D.modelRef?.providerId??M,B=D.modelRef?.modelId||Dt(te,o)||F,le=Gn(S,o,{providerId:te,modelId:B}),ie=Ge(te,B),V=f||!s||!D.enabled;return e.jsxs("section",{className:`subagent-role-row${D.enabled?"":" disabled"}`,children:[e.jsxs("div",{className:"subagent-settings-card-header subagent-role-header",children:[e.jsxs("div",{className:"subagent-role-title",children:[e.jsx("span",{children:Z?.label??D.id}),e.jsx("small",{children:Z?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${Z?.label??D.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:D.enabled,disabled:f||!s,onChange:q=>y(D.id,q.target.checked)}),e.jsx("span",{})]})]}),e.jsxs("div",{className:"subagent-role-controls",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:ie,disabled:V,onChange:q=>{const Y=le.find(de=>de.value===q.target.value);Y&&(C(D.id,Y.providerId),I(D.id,Y.modelId))},children:le.map(q=>e.jsx("option",{value:q.value,children:q.label},q.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:D.isolationMode,disabled:V,onChange:q=>R(D.id,q.target.value),children:Fn.map(q=>e.jsx("option",{value:q.value,children:q.label},q.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:D.toolPolicy,disabled:V,onChange:q=>w(D.id,q.target.value),children:Wn.map(q=>e.jsx("option",{value:q.value,children:q.label},q.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:D.peerMessages,disabled:V,onChange:q=>h(D.id,q.target.value),children:qn.map(q=>e.jsx("option",{value:q.value,children:q.label},q.value))})]})]}),e.jsx("div",{className:"subagent-role-budget-grid",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Role concurrency"}),e.jsx("input",{type:"number",min:1,max:16,value:D.maxConcurrentRuns,disabled:V,onChange:q=>O(D.id,$s(q.target.value,1))})]})})]},D.id)})}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Limits"}),e.jsx("small",{children:"Controls child worker concurrency."})]})}),e.jsxs("div",{className:"subagent-field-grid four",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Total concurrency"}),e.jsx("input",{type:"number",min:1,max:32,value:u,disabled:f||!s,onChange:D=>k($s(D.target.value,1))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per provider"}),e.jsx("input",{type:"number",min:1,max:32,value:d??"",placeholder:"No cap",disabled:f||!s,onChange:D=>A(ds(D.target.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per workspace"}),e.jsx("input",{type:"number",min:1,max:32,value:c??"",placeholder:"No cap",disabled:f||!s,onChange:D=>$(ds(D.target.value))})]})]})]})]})})}const Fn=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],Wn=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],qn=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function ot(s,t){const a=t.trim();return!a||s.some(n=>n.value===a)?s:[{value:a,label:a},...s]}function Ge(s,t){return JSON.stringify([s,t])}function Gn(s,t,a){const n=[];for(const i of s){const r=ot(ms(i.value,t),i.value===a.providerId?a.modelId:"");for(const u of r)n.push({value:Ge(i.value,u.value),label:`${i.label} / ${u.label}`,providerId:i.value,modelId:u.value})}return a.modelId&&!n.some(i=>i.value===Ge(a.providerId,a.modelId))&&n.unshift({value:Ge(a.providerId,a.modelId),label:`${rs(a.providerId,t)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),n}function ds(s){const t=s.trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function $s(s,t){return ds(s)??t}function Vn(s,t){const a=t.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&Kn(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 Kn(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const Jn=[{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 Yn({currentUserId:s,enabled:t,mode:a,threads:n,onModeChange:i,onThreadMuteChange:r}){const[u,d]=l.useState(null),[c,m]=l.useState(null);us(c);const o=l.useMemo(()=>n.filter(g=>g.archivedAt===null).map(g=>({thread:g,label:Qn(g,s)})).sort((g,j)=>{const v=+!!j.thread.mutedAt-+!!g.thread.mutedAt;return v!==0?v:g.label.localeCompare(j.label)}),[s,n]),f=o.filter(({thread:g})=>!!g.mutedAt).length,p=l.useCallback(async g=>{d(g.id),m(null),await r(g.id,!g.mutedAt)||m("Could not update this conversation. Try again."),d(null)},[r]);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:Jn.map(g=>e.jsxs("label",{className:`notification-mode-option${a===g.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===g.mode,onChange:()=>i(g.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:g.label}),e.jsx("small",{children:g.detail})]})]},g.mode))})]}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Conversation overrides"}),e.jsx("small",{children:f===1?"1 muted":`${f} muted`})]}),t?o.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):o.map(({thread:g,label:j})=>{const v=!!g.mutedAt,x=u===g.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${v?" muted":""}`,children:v?e.jsx(on,{size:15}):e.jsx(it,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:j}),e.jsx("small",{children:v?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:u!==null,onClick:()=>{p(g)},children:x?"Saving":v?"Unmute":"Mute"})]},g.id)}):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Connect a team to manage conversation overrides."})})]}),e.jsx("div",{className:"settings-footnote",children:e.jsx("span",{children:"Muted conversations never show alerts. Unread counts remain available."})})]})}function Qn(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 Xn({canSaveCurrentTemplate:s,personalizationTemplateId:t,personalizationTemplateOptions:a,saveAsNewOpen:n,saving:i,selectedPersonalizationTemplate:r,selectedTemplateIsCustom:u,soulDraft:d,templateNameDraft:c,changePersonalizationTemplate:m,changeSoulDraft:o,openSaveAsNew:f,resetPersonalizationDraft:p,savePersonalization:g,setSaveAsNewOpen:j,setTemplateNameDraft:v}){function x(N){N.preventDefault(),g(n)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:x,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:c,onChange:N=>v(N.target.value),placeholder:"Name","aria-label":"Template name"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Cancel","aria-label":"Cancel",disabled:i,onClick:()=>j(!1),children:e.jsx(pe,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:i||!d.trim()||!c.trim(),onClick:()=>{g(!0)},children:e.jsx(ps,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:u?"Custom template":"Built-in template"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Save as new","aria-label":"Save as new",disabled:i||!r||!d.trim(),onClick:f,children:e.jsx(Ne,{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(Ve,{value:t,disabled:i||a.length===0,label:"Personalization template",options:a,onChange:N=>{m(N)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:d,onChange:N=>o(N.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:i||!r,onClick:p,children:e.jsx(Ye,{size:15})}),u&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:i||!s,children:e.jsx(st,{size:15})})]})]})]})}function Zn({connection:s,profile:t,selectedDefaultTeamId:a}){const n=un(s),i=ta(n.schedules);return us(n.error,{prefix:"Local schedules"}),e.jsxs("div",{className:"account-list profile-agent-list","aria-label":"Profile agents",children:[e.jsx("div",{className:"account-list-heading profile-agent-list-heading",children:e.jsx("span",{children:"Agents"})}),e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-agent-table","aria-label":"Profile agents table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-agent-column"}),e.jsx("col",{className:"profile-action-column"}),e.jsx("col",{className:"profile-check-column"}),e.jsx("col",{className:"profile-sync-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Agent"}),e.jsx("th",{scope:"col",children:"Action"}),e.jsx("th",{scope:"col",children:"Check"}),e.jsx("th",{scope:"col",children:"Sync"})]})}),e.jsxs("tbody",{children:[i.active.map(r=>e.jsx(Ds,{pending:n.pendingScheduleIds.has(r.id),schedule:r,refreshing:n.loading,onRefresh:()=>{n.refresh()},onRun:()=>{n.run(r)},onToggle:()=>{n.toggle(r)}},r.id)),e.jsx(ea,{}),t.agents.map(r=>e.jsx(sa,{agent:r,defaultAction:t.summary.defaultAction,profile:t,selectedDefaultTeamId:a},r.id)),i.paused.map(r=>e.jsx(Ds,{pending:n.pendingScheduleIds.has(r.id),schedule:r,refreshing:n.loading,onRefresh:()=>{n.refresh()},onRun:()=>{n.run(r)},onToggle:()=>{n.toggle(r)}},r.id))]})]})})]})}function ea(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:"Dataset Builder"}),e.jsx("span",{children:"Built in · every Profile"})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:"Design · Materialize · Test"})})}),e.jsx("td",{children:e.jsx(Be,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx(Be,{status:{state:"ready",label:"Built in"}})})]})}function sa({agent:s,defaultAction:t,profile:a,selectedDefaultTeamId:n}){const i=ia(a,s,n);return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsx("span",{title:s.path,children:s.path})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:t??"None"})})}),e.jsx("td",{children:e.jsx(Be,{status:i.check})}),e.jsx("td",{children:e.jsx(Be,{status:i.sync})})]})}function Ds({pending:s,refreshing:t,schedule:a,onRefresh:n,onRun:i,onToggle:r}){const u=na(a),d=a.enabled?"Pause schedule":"Resume schedule";return e.jsxs("tr",{className:"profile-agent-row profile-schedule-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.localProjectName}),e.jsxs("span",{title:a.scheduleName,children:["schedule: ",a.scheduleName]})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{title:a.targetAction,children:a.targetAction})})}),e.jsx("td",{children:e.jsx(Be,{status:u})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:aa(a),children:a.enabled?a.scheduleExpression:"Paused"}),e.jsxs("div",{className:"profile-schedule-controls","aria-label":`${a.scheduleName} schedule controls`,children:[e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:t,type:"button",title:"Refresh local schedules","aria-label":"Refresh local schedules",onClick:n,children:e.jsx(he,{size:14,className:t?"settings-spin":void 0})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:"Run now","aria-label":`Run ${a.scheduleName} now`,onClick:i,children:e.jsx(Ye,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:d,"aria-label":`${d}: ${a.scheduleName}`,onClick:r,children:a.enabled?e.jsx(tt,{size:14}):e.jsx(at,{size:14})})]})]})})]})}function Be({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function ta(s){const t=[],a=[];for(const n of s)n.enabled?t.push(n):a.push(n);return t.sort((n,i)=>Ts(n)-Ts(i)),{active:t,paused:a}}function Ts(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function na(s){return s.enabled?s.lastError||s.lastRunStatus==="failed"?{state:"warning",label:"Failed"}:s.lastRunStatus==="running"?{state:"loading",label:"Running"}:s.lastRunStatus==="queued"?{state:"loading",label:"Queued"}:s.lastRunStatus==="skipped"?{state:"warning",label:"Skipped"}:s.lastRunStatus==="succeeded"?{state:"ready",label:"Succeeded"}:{state:"loading",label:"Scheduled"}:{state:"disabled",label:"Paused"}}function aa(s){const t=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&t.push(`next ${Ls(s.nextRunAt)}`),s.lastRunAt&&t.push(`last ${Ls(s.lastRunAt)}`),t.join(" - ")}function Ls(s){const t=new Date(s);return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):s}function ia(s,t,a){if(!t.enabled)return{check:{state:"disabled",label:"Disabled"},sync:{state:"disabled",label:"Disabled"}};if(s.error)return{check:{state:"warning",label:"Error"},sync:{state:"warning",label:"Blocked"}};if(s.setupGate.blockingCount>0)return{check:{state:"warning",label:"Setup"},sync:{state:"warning",label:"Blocked"}};if(s.git?.dirty||ra(s,t)>0)return{check:{state:"loading",label:"Pending"},sync:{state:"warning",label:"Changed"}};if(s.catalog.stale)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(!s.lastCheck)return{check:{state:"loading",label:"Unchecked"},sync:{state:"loading",label:"Waiting"}};if(s.lastCheck.status==="failed")return{check:{state:"warning",label:"Failed"},sync:{state:"warning",label:"Blocked"}};if(!s.summary.checkFresh)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(la(s,a))return{check:{state:"ready",label:"Passed"},sync:{state:"warning",label:"Sync acct"}};const n=s.summary.localHead??s.git?.head??null,i=s.hosted?.lastPushedLocalHead??null;return!(s.summary.hostedHead??s.hosted?.sourceCommitSha??null)&&!i?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Not synced"}}:n&&i&&n!==i?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Needed"}}:{check:{state:"ready",label:"Passed"},sync:{state:"ready",label:"Synced"}}}function la(s,t){const a=s.hosted?.teamId?.trim()??"";return!!(a&&t&&a!==t)}function ra(s,t){let a=0;s.diff.changedAgents.includes(t.id)&&(a+=1),s.diff.newAgents.includes(t.id)&&(a+=1),s.diff.deletedAgents.includes(t.id)&&(a+=1);const n=t.path.replace(/^profiles\/[^/]+\//,"");for(const i of s.diff.files){const r=i.path.replace(/^profiles\/[^/]+\//,"");(r===n||r.startsWith(`${n}/`)||r.startsWith(`agents/${t.id}/`))&&(a+=1)}return a}function Os(s){return s.policy.kind==="model"?`${s.policy.model.provider}/${s.policy.model.model}`:"Fixture"}function oa({comparison:s}){const t=[...new Set(s.members.map(n=>n.source.sourceRevision))],a=[...new Set(s.members.map(Os))];return e.jsxs("table",{className:"profile-evaluations-comparison-matrix",children:[e.jsxs("caption",{children:["Same frozen Taskset ",s.tasksetRelease.id," across Profile source and model choices"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Profile source"}),a.map(n=>e.jsx("th",{scope:"col",children:n},n))]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",title:n,children:n.slice(0,12)}),a.map(i=>{const r=s.members.filter(u=>u.source.sourceRevision===n&&Os(u)===i);return e.jsx("td",{children:r.length?r.map(u=>e.jsxs("div",{children:[e.jsx("strong",{children:u.score===null?"No score":`${Math.round(u.score*100)}%`}),e.jsxs("small",{children:[" · Run ",u.runManifest.id]})]},u.runManifest.id)):"—"},i)})]},n))})]})}function fs(s){switch(s.kind){case"profile":return"Complete Profile";case"workflow":return`Workflow · ${s.workflowId}`;case"skill":return`Skill · ${s.skillPath}`;case"agent_action":return`Agent action · ${s.actionId}`}}function ve(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString()}function Ce(s){return s===null?"No score":`${Math.round(s*100)}%`}function ct(s){return s.manifest.policy.kind==="model"?`${s.manifest.policy.model.provider}/${s.manifest.policy.model.model}`:"Fixture"}function ca({catalog:s,evaluations:t,onEvaluate:a,onOpenRun:n,busy:i}){const[r,u]=l.useState(null);return e.jsxs("section",{className:"profile-workflows","aria-label":"Profile workflows",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Workflows"}),e.jsx("p",{children:"Open a workflow to review its instructions and linked evaluations."})]}),s.workflows.length?e.jsx("div",{className:"profile-table-scroll",children:e.jsxs("table",{className:"profile-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Workflow"}),e.jsx("th",{scope:"col",children:"Evaluations"}),e.jsx("th",{scope:"col",children:"Runs"}),e.jsx("th",{scope:"col",children:"Latest result"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:s.workflows.map(({workflow:d,binding:c})=>{const m=t?.definitions.filter(p=>p.target.kind==="workflow"&&p.target.workflowId===d.id)??[],o=t?.runs.filter(p=>p.manifest.profileEvaluation?.target.kind==="workflow"&&p.manifest.profileEvaluation.target.workflowId===d.id)??[],f=o[0];return e.jsxs(l.Fragment,{children:[e.jsxs("tr",{children:[e.jsxs("th",{scope:"row",children:[e.jsx("button",{type:"button","aria-expanded":r===d.id,onClick:()=>u(p=>p===d.id?null:d.id),children:d.label}),e.jsx("small",{children:d.description})]}),e.jsx("td",{children:t?m.length:"—"}),e.jsx("td",{children:t?o.length:"—"}),e.jsx("td",{children:f?e.jsxs("button",{type:"button",onClick:()=>n(f),children:[f.passed?"Passed":"Did not pass"," · ",Ce(f.metric.value),e.jsx("small",{children:ve(f.completedAt)})]}):"Not run"}),e.jsx("td",{children:e.jsx("button",{type:"button",disabled:i||!t,onClick:()=>a(d.id),children:m.length?"Run Evaluation":"View evaluations"})})]}),r===d.id?e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsx("strong",{children:d.label}),e.jsxs("p",{children:["Revision ",c.sourceRevision.slice(0,12)," · Release ",c.harnessRelease.contentHash.slice(0,12)]}),d.skillPaths.length?e.jsxs("p",{children:["Skills: ",d.skillPaths.join(", ")]}):null,e.jsxs("details",{children:[e.jsx("summary",{children:d.invocation.kind==="instructions"?"Instructions":"Action configuration"}),e.jsx("pre",{children:d.invocation.kind==="instructions"?d.invocation.instructions:JSON.stringify(d.invocation,null,2)})]}),e.jsx("strong",{children:"Linked evaluations"}),m.length?e.jsx("ul",{children:m.map(p=>e.jsxs("li",{children:[p.label," · ",p.taskIds.length," tasks · ",p.seeds.length," seeds"]},p.id))}):e.jsx("p",{children:t?"No evaluation definition targets this workflow. Add one in the Profile’s evals catalog to run it.":"Evaluation catalog unavailable."}),e.jsx("button",{type:"button",disabled:i||!t,onClick:()=>a(d.id),children:m.length?"Run Evaluation":"View evaluation history"})]})})}):null]},d.id)})})]})}):e.jsx("p",{children:"No workflows in this Profile yet."})]})}function da({runs:s,definitions:t,sourceRevision:a,onOpen:n,onSave:i,savingReportId:r}){const[u,d]=l.useState(20);return e.jsxs("div",{className:"profile-evaluations-history",children:[e.jsx("h4",{children:"Run history"}),s.length?e.jsx("div",{className:"profile-table-scroll",children:e.jsxs("table",{className:"profile-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Evaluation / target"}),e.jsx("th",{scope:"col",children:"Completed"}),e.jsx("th",{scope:"col",children:"Model"}),e.jsx("th",{scope:"col",children:"Result"}),e.jsx("th",{scope:"col",children:"Score"}),e.jsx("th",{scope:"col",children:"Attempts"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:s.slice(0,u).map(c=>{const m=c.manifest.profileEvaluation,o=m?.sourceRevision===a?t.find(f=>f.id===m.definitionId):null;return e.jsxs("tr",{children:[e.jsxs("th",{scope:"row",children:[e.jsx("button",{type:"button",onClick:()=>n(c),children:o?.label??m?.definitionId??c.manifest.id}),m?e.jsx("small",{children:fs(m.target)}):null]}),e.jsx("td",{children:ve(c.completedAt)}),e.jsx("td",{children:ct(c)}),e.jsx("td",{children:c.passed?"Passed":"Did not pass"}),e.jsx("td",{children:Ce(c.metric.value)}),e.jsx("td",{children:c.receiptRefs.length}),e.jsx("td",{title:m?.sourceRevision,children:m?.sourceRevision.slice(0,10)??"—"}),e.jsxs("td",{children:[e.jsx("button",{type:"button",onClick:()=>n(c),children:"View results"})," ",e.jsx("button",{type:"button",disabled:!!r,onClick:()=>i(c.manifest.id),children:r===c.manifest.id?"Saving…":"Save report"})]})]},c.manifest.id)})})]})}):e.jsx("p",{children:"No evaluation runs yet."}),s.length>u?e.jsx("button",{type:"button",onClick:()=>d(c=>c+20),children:"Show more runs"}):null]})}function ze(s){return ye(s,"/v1/profile/evaluations/discover",{method:"POST",body:JSON.stringify({view:"history"})})}function Us(s,t,a){return ye(s,"/v1/profile/evaluations/discover",{method:"POST",body:JSON.stringify(t),signal:a})}function ua({connection:s,run:t,onClose:a}){const n=l.useRef(null),[i,r]=l.useState([]),[u,d]=l.useState(null),[c,m]=l.useState(null),[o,f]=l.useState(!0),[p,g]=l.useState(!1),[j,v]=l.useState(null),[x,N]=l.useState(null),[k,A]=l.useState(0),[$,y]=l.useState(50),[R,O]=l.useState(null);l.useEffect(()=>{n.current?.showModal()},[]),l.useEffect(()=>{const h=new AbortController;return f(!0),v(null),Us(s,{runId:t.manifest.id},h.signal).then(w=>{h.signal.aborted||r(w.cases)}).catch(w=>{h.signal.aborted||v(w instanceof Error?w.message:String(w))}).finally(()=>{h.signal.aborted||f(!1)}),()=>h.abort()},[s,t.manifest.id,k]),l.useEffect(()=>{if(!u)return;const h=new AbortController;return g(!0),N(null),Us(s,{runId:t.manifest.id,receiptId:u,...R?{eventAfterId:R}:{}},h.signal).then(w=>{h.signal.aborted||m(w.cases[0]??null)}).catch(w=>{h.signal.aborted||N(w instanceof Error?w.message:String(w))}).finally(()=>{h.signal.aborted||g(!1)}),()=>h.abort()},[s,t.manifest.id,u,R,k]);const I=t.manifest.profileEvaluation;return e.jsx("dialog",{ref:n,className:"profile-evaluation-dialog","aria-labelledby":"profile-run-title",onCancel:a,onClick:h=>{if(h.target===h.currentTarget){const w=h.currentTarget.getBoundingClientRect();(h.clientX<w.left||h.clientX>w.right||h.clientY<w.top||h.clientY>w.bottom)&&a()}},children:e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsxs("header",{className:"profile-evaluation-dialog-header",children:[e.jsx("h2",{id:"profile-run-title",children:"Evaluation results"}),e.jsx("button",{type:"button",autoFocus:!0,onClick:a,children:"Close"})]}),e.jsxs("strong",{children:[I?.definitionId??t.manifest.id," · ",t.passed?"Passed":"Did not pass"," · ",Ce(t.metric.value)]}),e.jsxs("p",{children:[I?fs(I.target):"Profile evaluation"," · ",ct(t)," · ",ve(t.completedAt)]}),e.jsxs("p",{children:["Pass rate ",Ce(t.passRate)," · Source ",I?.sourceRevision," · Run ",t.manifest.id]}),e.jsxs("details",{children:[e.jsx("summary",{children:"Frozen run configuration"}),e.jsx("pre",{children:JSON.stringify(t.manifest,null,2)})]}),o?e.jsx("p",{role:"status",children:"Loading case results…"}):null,j?e.jsxs("p",{role:"alert",children:[j," ",e.jsx("button",{type:"button",onClick:()=>A(h=>h+1),children:"Retry"})]}):null,e.jsx("div",{className:"profile-table-scroll",children:e.jsxs("table",{className:"profile-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Task"}),e.jsx("th",{scope:"col",children:"Seed"}),e.jsx("th",{scope:"col",children:"Result"}),e.jsx("th",{scope:"col",children:"Score"}),e.jsx("th",{scope:"col",children:"Grading"}),e.jsx("th",{scope:"col",children:"Latency"}),e.jsx("th",{scope:"col",children:"Cost"})]})}),e.jsx("tbody",{children:i.slice(0,$).map(h=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx("button",{type:"button","aria-pressed":u===h.receiptId,onClick:()=>{u===h.receiptId&&!R||(d(h.receiptId),m(null),O(null))},children:h.taskId})}),e.jsx("td",{children:h.seed}),e.jsx("td",{children:h.passed?"Passed":"Did not pass"}),e.jsx("td",{children:Ce(h.score)}),e.jsxs("td",{children:[h.gradingStatus,h.failureClass?` · ${h.failureClass}`:""]}),e.jsxs("td",{children:[h.latencyMs.toLocaleString()," ms"]}),e.jsx("td",{children:h.costUsd===null?"Unknown":`$${h.costUsd.toFixed(4)}`})]},h.receiptId))})]})}),i.length>$?e.jsx("button",{type:"button",onClick:()=>y(h=>h+50),children:"Show more cases"}):null,p?e.jsx("p",{role:"status",children:"Loading case evidence…"}):null,x?e.jsxs("p",{role:"alert",children:[x," ",e.jsx("button",{type:"button",onClick:()=>A(h=>h+1),children:"Retry"})]}):null,c?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Case evidence",children:[e.jsxs("h3",{children:[c.taskId," · Seed ",c.seed]}),e.jsx("h4",{children:"Grader feedback"}),e.jsx("p",{children:"Evaluations use the graders pinned by their Taskset. Each result below identifies the grader and version used for this case."}),c.feedback.length?c.feedback.map(h=>e.jsxs("div",{children:[e.jsxs("strong",{children:[h.graderId," · ",h.graderVersion," · ",Ce(h.score)," · ",h.passed?"Passed":"Did not pass"]}),e.jsx("ul",{children:h.feedback.map((w,C)=>e.jsx("li",{children:w},C))})]},`${h.graderId}:${h.graderVersion}`)):e.jsx("p",{children:"No grader feedback retained for this case."}),c.evidence?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Input"}),e.jsx("pre",{children:c.evidence.prompt}),e.jsx("h4",{children:"Output"}),e.jsx("pre",{children:c.evidence.output?.text??c.evidence.partialOutput?.text??"No output retained."}),c.evidence.error?e.jsx("p",{role:"alert",children:c.evidence.error}):null,e.jsxs("details",{children:[e.jsxs("summary",{children:["Trace · ",c.evidence.eventCount," events"]}),e.jsx("pre",{children:JSON.stringify(c.evidence.events,null,2)}),R?e.jsx("button",{type:"button",disabled:p,onClick:()=>O(null),children:"First trace page"}):null,c.evidence.nextEventCursor?e.jsx("button",{type:"button",disabled:p,onClick:()=>O(c.evidence.nextEventCursor),children:"Next trace page"}):null]})]}):e.jsx("p",{children:"No policy trace retained for this case. Scores and grader feedback are available above."}),e.jsxs("details",{children:[e.jsx("summary",{children:"Case receipt"}),e.jsx("pre",{children:JSON.stringify(c.receipt,null,2)})]})]}):null]})})}function We(s,t){return s.kind===t.kind&&(t.kind==="profile"||s.kind==="workflow"&&s.workflowId===t.id||s.kind==="skill"&&s.skillPath===t.id)}function ha(s){return Object.values(s.statuses).flatMap(t=>{if(!t.enabled||!t.available||!t.credential.connected)return[];const a=s.providers[t.id];return[...new Set([...t.modelIds,...s.modelCaches[t.id]?.models.map(i=>i.id)??[],...a?.modelOverrides??[],t.defaultModel,a?.defaultModel].filter(i=>!!i))].map(i=>({key:JSON.stringify([t.id,i]),providerId:t.id,modelId:i,label:`${t.displayName} · ${i}`}))})}function ma({connection:s,selectedProfileKey:t,focusTarget:a}){const n=l.useRef(null),[i,r]=l.useState(null),[u,d]=l.useState(null),[c,m]=l.useState(null),[o,f]=l.useState(null),[p,g]=l.useState(null),j=l.useRef(null),[v,x]=l.useState(null),[N,k]=l.useState(null),[A,$]=l.useState(50),[y,R]=l.useState(20),[O,I]=l.useState([]),[h,w]=l.useState(!1),[C,S]=l.useState(null),[M,F]=l.useState([]),[W,se]=l.useState(""),[X,D]=l.useState(null),[Z,te]=l.useState(!1),[B,le]=l.useState(!1),[ie,V]=l.useState(null),[q,Y]=l.useState(null),[de,re]=l.useState(!1),[oe,K]=l.useState(null);if(l.useEffect(()=>{if(!s||!t){x(null),d(null),r(null),g(null),F([]),D(null);return}let b=!0;return re(!0),x(null),d(null),r(null),m(null),f(null),g(null),j.current=null,k(null),$(50),R(20),I([]),F([]),se(""),D(null),Y(null),K(null),ze(s).then(E=>{b&&d(E)}).catch(E=>{b&&K(E instanceof Error?E.message:String(E))}),U.profileWorkflows(s).then(E=>{b&&r(E)}).catch(E=>{b&&m(E instanceof Error?E.message:String(E))}),U.profileEvaluations(s).then(E=>{b&&x(E)}).catch(E=>{b&&K(E instanceof Error?E.message:String(E))}).finally(()=>{b&&re(!1)}),U.providerSettings(s).then(E=>{if(!b)return;const _=ha(E);F(_),se(_[0]?.key??"")}).catch(E=>{b&&K(E instanceof Error?E.message:String(E))}),()=>{b=!1}},[s,t]),l.useEffect(()=>{if(!a||!v||j.current===a)return;j.current=a;const b=v.definitions.find(E=>We(E.target,a));f(a),k(b?.id??null),D(null),$(50),Y(b?null:"No evaluation definition is saved for this Profile component."),n.current?.scrollIntoView({behavior:"smooth",block:"start"})},[v,a]),!t)return null;const Q=v?.definitions.find(b=>b.id===N),ue=v?.definitions.filter(b=>!o||We(b.target,o))??[],ee=u??v,me=v?{...v,runs:ee?.runs??[],suiteRuns:ee?.suiteRuns??[]}:null,L=ee?.runs.filter(b=>o?!!(b.manifest.profileEvaluation&&We(b.manifest.profileEvaluation.target,o)):!Q||b.manifest.profileEvaluation?.definitionId===Q.id)??[],P=Z||B||!!ie,H=b=>{const E={kind:"workflow",id:b};f(E),k(v?.definitions.find(_=>We(_.target,E))?.id??null),D(null),Y(null),$(50),n.current?.scrollIntoView({behavior:"smooth",block:"start"})},z=async()=>{const b=M.find(_=>_.key===W);if(!s||!Q||!b||Z)return;const E={id:`evaluation-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),definitionId:Q.id,modelRef:{providerId:b.providerId,modelId:b.modelId}};te(!0),D(null),Y(null),K(null);try{D({request:E,prepared:await U.profileEvaluationPrepare(s,E)})}catch(_){K(_ instanceof Error?_.message:String(_))}finally{te(!1)}},ne=async()=>{if(!(!s||!X||B)){le(!0),K(null);try{const b=await U.profileEvaluationRun(s,{...X.request,expectedManifestHash:X.prepared.manifest.contentHash});D(null),g(b),Y(`Run ${b.manifest.id} ${b.passed?"passed":"did not pass"}.`),d(await ze(s))}catch(b){K(b instanceof Error?b.message:String(b))}finally{le(!1)}}},ce=async b=>{const E=M.find(_=>_.key===W);if(!(!s||!E||ie)){V(b),Y(null),K(null);try{const _=await U.profileEvaluationRunSuite(s,{id:`suite-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),suiteId:b,modelRef:{providerId:E.providerId,modelId:E.modelId}});d(await ze(s)),Y(`Suite ${_.id} ${_.passed?"passed":"did not pass"}.`)}catch(_){K(_ instanceof Error?_.message:String(_))}finally{V(null)}}},ae=b=>{I(E=>E.includes(b)?E.filter(_=>_!==b):[...E,b])},Ae=async()=>{if(!(!s||O.length<2||h)){w(!0),K(null);try{await U.profileEvaluationCompare(s,O),d(await ze(s)),I([])}catch(b){K(b instanceof Error?b.message:String(b))}finally{w(!1)}}},Oe=async(b,E)=>{if(!(!s||C)){S(E),K(null);try{const _=await U.profileEvaluationSaveReport(s,b,E);d(await ze(s)),Y(`Report ${_.id} saved to Profile source. Commit and publish the Profile when ready.`)}catch(_){K(_ instanceof Error?_.message:String(_))}finally{S(null)}}};return e.jsxs(e.Fragment,{children:[i?e.jsx(ca,{catalog:i,evaluations:me,onEvaluate:H,onOpenRun:g,busy:P}):null,c?e.jsx("p",{role:"alert",children:c}):null,e.jsxs("section",{ref:n,"aria-label":"Profile evaluations",className:"profile-evaluations",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Evaluations"}),e.jsx("p",{children:"Checks and retained results for this Profile’s released components."})]}),de?e.jsx("p",{children:"Loading evaluations…"}):null,oe?e.jsx("p",{role:"alert",children:oe}):null,q?e.jsx("p",{role:"status",children:q}):null,o?e.jsxs("div",{className:"profile-evaluation-scope",children:[e.jsx("strong",{children:o.kind==="workflow"?`Workflow · ${o.id}`:o.kind==="skill"?`Skill · ${o.id}`:"Complete Profile"}),e.jsx("button",{type:"button",disabled:P,onClick:()=>{f(null),k(null),D(null),Y(null)},children:"Show all evaluations"})]}):null,v&&!ue.length?e.jsx("p",{children:o?"No evaluation definitions target this component. Add a definition in the Profile’s evals catalog to run it. Retained runs are shown below.":"No evaluations in this Profile yet."}):null,v?.suites.length?e.jsxs("div",{className:"profile-evaluations-suites","aria-label":"Evaluation suites",children:[e.jsx("label",{htmlFor:"profile-evaluation-suite-model",children:"Suite model"}),e.jsx("select",{id:"profile-evaluation-suite-model",value:W,disabled:P,onChange:b=>{se(b.target.value),D(null)},children:M.map(b=>e.jsx("option",{value:b.key,children:b.label},b.key))}),M.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run a suite."}):null,v.suites.map(b=>e.jsxs("div",{className:"profile-evaluations-suite",children:[e.jsx("strong",{children:b.label}),e.jsxs("span",{children:[b.scope==="profile"?"Profile suite":"Component suite"," · ",b.definitionIds.length," checks"]}),e.jsx("button",{type:"button",disabled:!W||P,onClick:()=>{ce(b.id)},children:ie===b.id?"Running suite…":"Run suite"}),(ee?.suiteRuns??[]).filter(E=>E.suiteId===b.id).slice(0,5).map(E=>e.jsxs("details",{className:"profile-evaluations-suite-run",children:[e.jsxs("summary",{children:[ve(E.completedAt)," · ",E.passed?"Passed":"Did not pass"," · ",E.members.length," checks"]}),e.jsxs("small",{children:["Profile source ",E.sourceRevision.slice(0,12)," · Suite run ",E.id]}),e.jsx("button",{type:"button",disabled:!!C,onClick:()=>{Oe("suite",E.id)},children:C===E.id?"Saving report…":"Save report to Profile"}),e.jsx("ul",{children:E.members.map(_=>e.jsxs("li",{children:[e.jsx("strong",{children:E.sourceRevision===v.sourceRevision?v.definitions.find(fe=>fe.id===_.definitionId)?.label??_.definitionId:_.definitionId}),e.jsx("button",{type:"button",onClick:()=>{const fe=ee?.runs.find(Xe=>Xe.manifest.id===_.runManifest.id);fe&&g(fe)},disabled:!ee?.runs.some(fe=>fe.manifest.id===_.runManifest.id),children:"View results"}),e.jsxs("span",{children:[_.passed?"Passed":"Did not pass"," · ",_.score===null?"No score":`${Math.round(_.score*100)}%`," · Run ",_.runManifest.id]})]},_.runManifest.id))})]},E.id))]},b.id))]}):null,ue.length?e.jsx("div",{className:"profile-table-scroll",children:e.jsxs("table",{className:"profile-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Evaluation"}),e.jsx("th",{scope:"col",children:"Target"}),e.jsx("th",{scope:"col",children:"Tasks / seeds"}),e.jsx("th",{scope:"col",children:"Latest result"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:ue.map(b=>{const E=ee?.runs.find(_=>_.manifest.profileEvaluation?.definitionId===b.id);return e.jsxs("tr",{children:[e.jsxs("th",{scope:"row",children:[e.jsx("strong",{children:b.label}),e.jsx("small",{children:b.description})]}),e.jsx("td",{children:fs(b.target)}),e.jsxs("td",{children:[b.taskIds.length," / ",b.seeds.length]}),e.jsx("td",{children:E?e.jsxs("button",{type:"button",onClick:()=>g(E),children:[E.passed?"Passed":"Did not pass"," · ",Ce(E.metric.value),e.jsx("small",{children:ve(E.completedAt)})]}):"Not run"}),e.jsx("td",{children:e.jsx("button",{type:"button",disabled:P,"aria-expanded":N===b.id,onClick:()=>{k(_=>_===b.id?null:b.id),$(50),D(null),Y(null)},children:N===b.id?"Hide details":"View / Run Evaluation"})})]},b.id)})})]})}):null,Q?e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsx("h4",{children:Q.label}),e.jsxs("p",{children:["Taskset ",Q.tasksetRelease.id," · ",Q.tasksetRelease.contentHash.slice(0,12)]}),e.jsxs("p",{children:["Frozen split: ",Q.split," · Minimum pass rate: ",Math.round(Q.criterion.minimumPassRate*100),"% · ",Q.criterion.requireComplete?"All attempts required":"Incomplete runs allowed"]}),e.jsx("p",{children:"This evaluation runs the selected component against its Taskset’s frozen cases and graders."}),e.jsxs("details",{children:[e.jsx("summary",{children:"Evaluation definition"}),e.jsx("pre",{children:JSON.stringify(Q,null,2)})]}),e.jsxs("div",{className:"profile-evaluations-run-form",children:[e.jsx("label",{htmlFor:"profile-evaluation-model",children:"Model"}),e.jsx("select",{id:"profile-evaluation-model",value:W,disabled:P,onChange:b=>{se(b.target.value),D(null)},children:M.map(b=>e.jsx("option",{value:b.key,children:b.label},b.key))}),M.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run this check."}):null,e.jsx("button",{type:"button",disabled:!W||P,onClick:()=>{z()},children:Z?"Checking run…":"Check run setup"}),X?e.jsxs("div",{className:"profile-evaluations-run-plan",children:[e.jsx("strong",{children:"Run setup"}),e.jsxs("small",{children:["Profile source ",X.prepared.manifest.profileEvaluation?.sourceRevision.slice(0,12)," · Harness ",X.prepared.manifest.execution.kind==="harness"?X.prepared.manifest.execution.harnessRelease.id:""]}),e.jsxs("small",{children:["Taskset ",X.prepared.taskset.id," · ",X.prepared.manifest.population.length," attempts · ",X.prepared.manifest.limits.timeoutMs/1e3,"s per attempt"]}),e.jsxs("small",{children:["Connected app scopes: ",X.prepared.taskset.connectedAppScopes.join(", ")||"none declared"]}),e.jsx("button",{type:"button",disabled:B,onClick:()=>{ne()},children:B?"Running evaluation…":"Run evaluation"})]}):null]}),e.jsxs("div",{className:"profile-evaluations-cases",children:[e.jsx("strong",{children:"Task cases"}),e.jsx("ul",{children:Q.taskIds.slice(0,A).map(b=>e.jsx("li",{children:b},b))}),Q.taskIds.length>A?e.jsx("button",{type:"button",onClick:()=>$(b=>b+50),children:"Show more cases"}):null,e.jsxs("span",{children:["Seeds: ",Q.seeds.join(", ")]})]})]}):null,ee?e.jsx(da,{runs:L,definitions:v?.definitions??[],sourceRevision:v?.sourceRevision??"",onOpen:g,onSave:b=>{Oe("run",b)},savingReportId:C},N??JSON.stringify(o)):null,ee&&ee.runs.length>1?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Compare evaluation runs",children:[e.jsx("h4",{children:"Compare runs"}),e.jsx("p",{children:"Select two or more runs. Comparisons require the same Taskset, cases, environment, grading policy, limits, and runtime."}),e.jsx("div",{className:"profile-evaluations-comparison-runs",children:ee.runs.slice(0,y).map(b=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:O.includes(b.manifest.id),onChange:()=>ae(b.manifest.id),disabled:h}),e.jsxs("span",{children:[e.jsxs("strong",{children:[b.manifest.profileEvaluation?.definitionId??"Profile evaluation"," · ",b.metric.value===null?"No score":`${Math.round(b.metric.value*100)}%`]}),e.jsxs("small",{children:[ve(b.completedAt)," · ",b.manifest.policy.kind==="model"?`${b.manifest.policy.model.provider}/${b.manifest.policy.model.model}`:"fixture"," · Source ",b.manifest.profileEvaluation?.sourceRevision.slice(0,10)," · ",b.manifest.id]})]})]},b.manifest.id))}),ee.runs.length>y?e.jsx("button",{type:"button",onClick:()=>R(b=>b+20),children:"Show more runs"}):null,e.jsx("button",{type:"button",disabled:O.length<2||h,onClick:()=>{Ae()},children:h?"Comparing…":`Save comparison of ${O.length} runs`})]}):null,ee&&ee.comparisons.length>0?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Saved evaluation comparisons",children:[e.jsx("h4",{children:"Saved comparisons"}),e.jsx("ul",{children:ee.comparisons.map(b=>e.jsxs("li",{children:[e.jsxs("strong",{children:[ve(b.createdAt)," · ",b.members.length," runs"]}),e.jsx("button",{type:"button",disabled:!!C,onClick:()=>{Oe("comparison",b.id)},children:C===b.id?"Saving report…":"Save report to Profile"}),e.jsx("ul",{children:b.members.map(E=>e.jsxs("li",{children:[E.source.definitionId," · ",E.policy.kind==="model"?`${E.policy.model.provider}/${E.policy.model.model}`:"fixture"," · Source ",E.source.sourceRevision.slice(0,10)," · ",E.score===null?"No score":`${Math.round(E.score*100)}%`]},E.runManifest.id))}),e.jsx(oa,{comparison:b})]},b.id))})]}):null,ee?.reports.length?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Profile evaluation reports",children:[e.jsx("h4",{children:"Reports saved in Profile source"}),e.jsx("ul",{children:ee.reports.map(b=>e.jsxs("li",{children:[e.jsxs("strong",{children:[ve(b.createdAt)," · ",b.summary.passedChecks,"/",b.summary.totalChecks," checks passed"]}),e.jsxs("small",{children:["Tested source ",b.testedSources.map(E=>E.sourceRevision.slice(0,10)).join(", ")," · Evidence ",b.evidence.map(E=>E.id).join(", ")]})]},b.id))})]}):null]}),s&&p?e.jsx(ua,{connection:s,run:p,onClose:()=>g(null)},p.manifest.id):null]})}function pa({actions:s,busy:t,library:a,onSelect:n}){const i=a.profiles.find(u=>os(u.ref,a.lastUsed))??a.profiles[0]??null,r=i?Ze(i.ref):"";return e.jsxs("div",{className:"profile-selector-bar",children:[e.jsxs("label",{className:"profile-selector-control",children:[e.jsx("select",{"aria-label":"Active profile",disabled:t||a.profiles.length===0,value:r,onChange:u=>{const d=Tt(a,u.currentTarget.value),c=a.profiles.find(m=>os(m.ref,d));c&&n(c)},children:a.profiles.length?a.profiles.map(u=>e.jsx("option",{value:Ze(u.ref),children:u.name},Ze(u.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Lt,{"aria-hidden":"true",size:14})]}),s]})}function fa({addDisabled:s,commitDisabled:t,commitLabel:a,refreshDisabled:n,repoDisabled:i,syncDisabled:r,syncLabel:u,syncStatus:d,onAdd:c,onCommit:m,onRefresh:o,onRepo:f,onSync:p}){const[g,j]=l.useState(!1),v=l.useRef(null);l.useEffect(()=>{if(!g)return;function N(A){v.current?.contains(A.target)||j(!1)}function k(A){A.key==="Escape"&&j(!1)}return document.addEventListener("pointerdown",N),document.addEventListener("keydown",k),()=>{document.removeEventListener("pointerdown",N),document.removeEventListener("keydown",k)}},[g]);function x(N){j(!1),N()}return e.jsx("div",{className:"profile-selector-actions",children:e.jsxs("div",{className:"profile-settings-menu-root",ref:v,children:[e.jsx("button",{"aria-expanded":g,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>j(N=>!N),children:e.jsx(hs,{size:15})}),g?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:t,role:"menuitem",type:"button",onClick:()=>x(m),children:[e.jsx(Je,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:r,role:"menuitem",type:"button",onClick:()=>x(p),children:[e.jsx(we,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:u}),d?e.jsx("small",{children:d}):null]})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>x(f),children:[e.jsx(Fe,{size:14}),e.jsx("span",{children:"Repository"})]}),e.jsx("div",{className:"profile-settings-menu-separator",role:"separator"}),e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>x(o),children:[e.jsx(he,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>x(c),children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const ga=[{id:"actions",label:"Actions",detail:"Profile-level reusable actions"},{id:"workflows",label:"Workflows",detail:"Workflow definitions and actions"},{id:"instructions",label:"Instructions",detail:"Profile instructions used by evaluations"},{id:"prompts",label:"Prompts",detail:"Shared prompt files"},{id:"goals",label:"Goals",detail:"Goal definitions; never started automatically"},{id:"evals",label:"Evals",detail:"Evaluation definitions and fixtures"},{id:"examples",label:"Examples",detail:"Example inputs and usage"},{id:"tasksets",label:"Tasksets",detail:"Training and evaluation tasksets"},{id:"extensions",label:"Extension declarations",detail:"Third-party extension metadata"}];function xa({connection:s,entry:t,onClose:a,onPublished:n}){const[i,r]=l.useState("github"),[u,d]=l.useState(""),[c,m]=l.useState(`${t.name}-profile`),[o,f]=l.useState("public"),[p,g]=l.useState(()=>t.state.agents.filter(S=>S.enabled).map(S=>S.id)),[j,v]=l.useState(()=>t.state.skills.filter(S=>S.enabled).map(S=>S.name)),[x,N]=l.useState([]),[k,A]=l.useState(null),[$,y]=l.useState(null),[R,O]=l.useState(null),I=l.useMemo(()=>({ref:t.ref,selection:{agentIds:p,skillNames:j,optionalContent:x},target:{provider:i,owner:u.trim()||null,repository:c.trim(),visibility:i==="github"?"public":o}}),[p,t.ref,x,u,i,c,j,o]);function h(S,M,F){return F?[...new Set([...S,M])]:S.filter(W=>W!==M)}async function w(S){if(S.preventDefault(),!(!c.trim()||$)){y("preview"),O(null);try{A(await U.profilePublicationPreview(s,I))}catch(M){O(M instanceof Error?M.message:String(M))}finally{y(null)}}}async function C(){if(!(!k||k.blockedReasons.length>0||$)){y("publish"),O(null);try{const S=await U.profilePublicationPublish(s,{...I,expectedSourceHash:k.sourceHash,confirmed:!0});n(`Published ${t.name} to ${S.owner}/${S.repository}`),a()}catch(S){O(S instanceof Error?S.message:String(S))}finally{y(null)}}}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("form",{className:"git-dialog profile-publication-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-publication-title",onMouseDown:S=>S.stopPropagation(),onSubmit:w,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!$,type:"button","aria-label":"Close",onClick:a,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(we,{size:18})}),e.jsxs("h2",{id:"profile-publication-title",children:["Publish ",t.name]}),e.jsx("p",{children:"Choose the exact Agents, Skills, workflows, and optional files to share. OpenPond will show the complete file list before it pushes anything."}),k?e.jsx(ja,{preview:k}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:"Destination"}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:i==="github",onChange:()=>{r("github"),f("public")}}),e.jsx(cs,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"GitHub"}),e.jsx("small",{children:"Published publicly with your signed-in gh CLI"})]})]}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:i==="openpond_git",onChange:()=>{r("openpond_git"),f("private")}}),e.jsx(Ot,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"OpenPond Git"}),e.jsx("small",{children:"Private by default; uses the same repository format"})]})]})]}),e.jsxs("div",{className:"profile-publication-target-fields",children:[i==="github"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"GitHub owner (optional)"}),e.jsx("input",{value:u,placeholder:"Uses gh account",onChange:S=>d(S.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:c,onChange:S=>m(S.currentTarget.value)})]}),i==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:o,onChange:S=>f(S.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(ts,{title:"Agents",empty:"No Agents in this Profile",children:t.state.agents.map(S=>e.jsx(ns,{checked:p.includes(S.id),label:S.name,detail:S.path,onChange:M=>g(F=>h(F,S.id,M))},S.id))}),e.jsx(ts,{title:"Skills",empty:"No Skills in this Profile",children:t.state.skills.map(S=>e.jsx(ns,{checked:j.includes(S.name),label:S.name,detail:S.description||S.path,onChange:M=>v(F=>h(F,S.name,M))},S.name))}),e.jsx(ts,{title:"Optional content",empty:"",children:ga.map(S=>e.jsx(ns,{checked:x.includes(S.id),label:S.label,detail:S.detail,onChange:M=>N(F=>h(F,S.id,M))},S.id))})]}),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",disabled:!!$,type:"button",onClick:k?()=>A(null):a,children:k?"Back":"Cancel"}),k?e.jsxs("button",{className:"git-dialog-primary",disabled:!!$||k.blockedReasons.length>0,type:"button",onClick:()=>{C()},children:[e.jsx(we,{size:14}),e.jsx("span",{children:$==="publish"?"Publishing":k.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!$||!c.trim(),type:"submit",children:$==="preview"?"Building preview":"Review exact files"})]})]})})}function ts({title:s,empty:t,children:a}){const n=Array.isArray(a)?a.length:a?1:0;return e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:s}),n?a:e.jsx("span",{className:"profile-publication-empty",children:t})]})}function ns({checked:s,label:t,detail:a,onChange:n}){return e.jsxs("label",{className:"profile-publication-selection",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:i=>n(i.currentTarget.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:t}),e.jsx("small",{children:a})]})]})}function ja({preview:s}){const t=s.files.reduce((a,n)=>a+n.sizeBytes,0);return e.jsxs("div",{className:"profile-publication-preview",children:[e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[s.files.length," files · ",Ms(t)]}),e.jsx("span",{children:s.sourceRevision?.slice(0,10)??"No source revision"})]}),s.blockedReasons.map(a=>e.jsx("div",{className:"profile-dialog-warning",children:a},a)),s.warnings.map(a=>e.jsx("div",{className:"profile-publication-warning",children:a},a)),e.jsx("div",{className:"profile-publication-file-list","aria-label":"Exact files to publish",children:s.files.map(a=>e.jsxs("div",{children:[e.jsx("span",{title:a.path,children:a.path}),e.jsxs("small",{children:[a.category," · ",Ms(a.sizeBytes)]})]},a.path))}),s.excludedFiles.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[s.excludedFiles.length," excluded sensitive/runtime files"]}),s.excludedFiles.map(a=>e.jsx("code",{children:a},a))]}):null]})}function Ms(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function va({section:s="all",catalogPresentation:t="list",payload:a,connection:n,onPayload:i,onError:r,onToast:u,onSkillCommand:d,overviewContent:c}){const[m,o]=l.useState(""),[f,p]=l.useState(null),[g,j]=l.useState(!1),[v,x]=l.useState(null),[N,k]=l.useState(null),[A,$]=l.useState(null),y=a?.profile??null,R=a?.preferences.defaultTeamId?.trim()||"",O=s==="all"||s==="profile"||s==="controls",I=s==="all"||s==="profile",h=s==="all"||s==="agents",w=s==="all"||s==="profile";async function C(B){n&&(i(await U.bootstrap(n)),u?.(B,"success"))}async function S(B,le){if(!(!n||f)){p(B),r(null);try{await le()}catch(ie){r(ie instanceof Error?ie.message:String(ie))}finally{p(null)}}}function M(){S("init",async()=>{await U.profileInit(n,{}),await C("Profile initialized")})}function F(){S("commit",async()=>{await U.profileCommit(n,{message:m.trim()||null}),o(""),await C("Profile commit complete")})}function W(){S("push",async()=>{if(!R)throw new Error("Select a default team before syncing a hosted profile.");await U.profileCheck(n,{kind:"all"}),await U.profilePush(n,{teamId:R,ensureHosted:!0,message:null}),await C("Profile synced to hosted profile repo")})}function se(B){S(`select:${B.ref.profileId}`,async()=>{await U.profileSelect(n,B.ref),await C(`Using ${B.name}`)})}function X(B){S("add",async()=>{B.source==="blank"?await U.profileInit(n,{path:B.path,profile:B.profile,template:"blank-profile"}):B.source==="local"?await U.profileLoad(n,B):await U.profileInstall(n,B),j(!1),await C(B.source==="blank"?`${B.profile} created`:"Profile added")})}function D(B){S("update",async()=>{await U.profileUpdate(n,B.ref),await C(`${B.name} updated`)})}function Z(B){S("remove",async()=>{await U.profileRemove(n,B.ref),x(null),await C("Profile removed from this device")})}function te(){S("refresh",async()=>{await C("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[y?.mode==="local"?e.jsxs(e.Fragment,{children:[O?e.jsxs(e.Fragment,{children:[I&&t==="select"?e.jsx(pa,{actions:e.jsx(zs,{connection:n,onAdd:()=>j(!0),onRefresh:te,presentation:"menu",profile:y,profileBusy:f,profileCommitMessage:m,selectedDefaultTeamId:R,syncDisabledReason:Hs(y,R),setProfileCommitMessage:o,submitProfileCommit:F,submitProfilePush:W}),busy:!!f,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:se}):e.jsxs(e.Fragment,{children:[I?e.jsx(ba,{busy:!!f,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>j(!0),onRefresh:te,onRemove:x,onPublish:k,onUpdate:D,onSelect:se}):null,e.jsx(zs,{connection:n,profile:y,profileBusy:f,profileCommitMessage:m,selectedDefaultTeamId:R,syncDisabledReason:Hs(y,R),setProfileCommitMessage:o,submitProfileCommit:F,submitProfilePush:W})]}),c]}):null,h?e.jsx(Zn,{connection:n,profile:y,selectedDefaultTeamId:R}):null,w?e.jsxs(e.Fragment,{children:[e.jsx(Ca,{onSkillCommand:d,onEvaluate:B=>$({kind:"skill",id:B}),profile:y}),e.jsx(ma,{connection:n,focusTarget:A,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null},JSON.stringify(a?.profileLibrary?.lastUsed??null))]}):null]}):s==="agents"?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agents"}),e.jsx("small",{children:"Profile required"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Open Profile to create or load a Profile before managing agents."})]})]}):e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Summary"}),e.jsx("small",{children:"Not loaded"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Create an empty Profile, start with an Agent template, or add an existing repository."}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!!f,type:"button",onClick:()=>j(!0),children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!!f,type:"button",onClick:M,children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:f==="init"?"Creating":"Create starter Profile"})]})]})]}),g?e.jsx(ya,{busy:!!f,onClose:()=>j(!1),onSubmit:X}):null,v?e.jsx(Na,{busy:!!f,entry:v,onClose:()=>x(null),onConfirm:()=>Z(v)}):null,N&&n?e.jsx(xa,{connection:n,entry:N,onClose:()=>k(null),onPublished:B=>u?.(B,"success")}):null]})}function ba({busy:s,library:t,onAdd:a,onRefresh:n,onRemove:i,onPublish:r,onSelect:u,onUpdate:d}){return e.jsxs("div",{className:"account-list profile-catalog-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Profiles"}),e.jsxs("div",{className:"profile-skill-heading-actions",children:[e.jsxs("small",{children:[t.profiles.length," installed"]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:n,children:[e.jsx(he,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),t.profiles.map(c=>{const m=os(c.ref,t.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${m?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||u(c)},onKeyDown:o=>{s||o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),u(c))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Fe,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:c.name}),e.jsx("span",{title:c.repoPath,children:c.repoPath})]})]}),e.jsx(dt,{status:{state:c.state.error?"warning":"ready",label:c.state.error?"error":m?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:c.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:c.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[c.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),d(c)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),d(c))},children:[e.jsx(he,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),r(c)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),r(c))},children:[e.jsx(we,{size:14}),e.jsx("span",{children:"Publish"})]}),e.jsxs("span",{className:"settings-secondary compact profile-remove-button",role:"button",tabIndex:0,"aria-label":`Remove ${c.name}`,onClick:o=>{o.stopPropagation(),i(c)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),i(c))},children:[e.jsx(Qe,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${c.ref.source}:${c.ref.repositoryId}:${c.ref.profileId}`)})]})}function ya({busy:s,onClose:t,onSubmit:a}){const[n,i]=l.useState("blank"),[r,u]=l.useState(""),[d,c]=l.useState(""),[m,o]=l.useState("");function f(p){if(p.preventDefault(),s)return;if(n==="blank"){const j=m.trim();if(!j)return;a({source:n,path:r.trim()||null,profile:j});return}if(n==="local"){const j=r.trim();if(!j)return;a({source:n,path:j,profile:m.trim()||null});return}const g=d.trim();g&&a({source:n,repositoryId:g,profile:m.trim()||null})}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:t,children:e.jsxs("form",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"add-profile-title",onMouseDown:p=>p.stopPropagation(),onSubmit:f,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:t,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Fe,{size:18})}),e.jsx("h2",{id:"add-profile-title",children:"Add Profile"}),e.jsx("p",{children:"Create a blank Profile, add a local repository, or install a shareable Profile from Git."}),e.jsxs("div",{className:"profile-add-source-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="blank",onChange:()=>i("blank")}),"New blank"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="local",onChange:()=>i("local")}),"Local"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="github",onChange:()=>i("github")}),"GitHub"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="openpond_git",onChange:()=>i("openpond_git")}),"OpenPond Git"]})]}),n==="blank"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path (optional)"}),e.jsx("input",{disabled:s,value:r,placeholder:"Uses the default local Profile repository",onChange:p=>u(p.currentTarget.value)})]}):n==="local"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path"}),e.jsx("input",{autoFocus:!0,disabled:s,value:r,placeholder:"/path/to/profile-repo",onChange:p=>u(p.currentTarget.value)})]}):e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:[n==="github"?"GitHub":"OpenPond Git"," repository"]}),e.jsx("input",{autoFocus:!0,disabled:s,value:d,placeholder:"owner/repository",onChange:p=>c(p.currentTarget.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:n==="blank"?"Profile name":"Profile name (optional)"}),e.jsx("input",{autoFocus:n==="blank",disabled:s,value:m,placeholder:n==="blank"?"research":"Uses repository default",onChange:p=>o(p.currentTarget.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:t,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:s||!(n==="blank"?m:n==="local"?r:d).trim(),type:"submit",children:n==="blank"?"Create Profile":"Add Profile"})]})]})})}function Na({busy:s,entry:t,onClose:a,onConfirm:n}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"remove-profile-title",onMouseDown:i=>i.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:a,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Qe,{size:18})}),e.jsxs("h2",{id:"remove-profile-title",children:["Remove ",t.name,"?"]}),e.jsx("p",{children:"This removes the Profile from OpenPond on this device. It does not delete the repository or any source files."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:t.name}),e.jsx("span",{children:t.repoPath})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:a,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary danger",disabled:s,type:"button",onClick:n,children:"Remove"})]})]})})}function zs({connection:s,onAdd:t,onRefresh:a,presentation:n="toolbar",profile:i,profileBusy:r,profileCommitMessage:u,selectedDefaultTeamId:d,syncDisabledReason:c,setProfileCommitMessage:m,submitProfileCommit:o,submitProfilePush:f}){const[p,g]=l.useState(!1),[j,v]=l.useState(!1),[x,N]=l.useState(!1),k=!s||!!r;return e.jsxs(e.Fragment,{children:[n==="menu"&&t&&a?e.jsx(fa,{addDisabled:!!r,commitDisabled:k,commitLabel:r==="commit"?"Committing":"Commit",refreshDisabled:k,repoDisabled:!!r||!i,syncDisabled:k||!i,syncLabel:r==="push"?"Syncing":"Sync",syncStatus:i?as(i,d):null,onAdd:t,onCommit:()=>v(!0),onRefresh:a,onRepo:()=>g(!0),onSync:()=>N(!0)}):e.jsx("div",{className:"profile-control-panel",children:e.jsxs("div",{className:"profile-control-toolbar",children:[e.jsxs("div",{className:"profile-control-actions",children:[e.jsxs("button",{className:"settings-secondary",disabled:k,type:"button",onClick:()=>v(!0),children:[e.jsx(Je,{size:14}),e.jsx("span",{children:r==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:k||!i,type:"button",onClick:()=>N(!0),children:[e.jsx(we,{size:14}),e.jsx("span",{children:r==="push"?"Syncing":"Sync"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!!r||!i,type:"button",onClick:()=>g(!0),children:[e.jsx(Fe,{size:14}),e.jsx("span",{children:"Repo"})]}),i?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${as(i,d)}`,children:[e.jsx(we,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:as(i,d)})]}):null]}),i?e.jsx("span",{className:`profile-local-status ${i.summary.state}`,title:i.summary.message,children:i.summary.message}):null]})}),p&&i?e.jsx(ka,{profile:i,profileBusy:r,onClose:()=>g(!1)}):null,j?e.jsx(wa,{disabled:k,profileBusy:r,profileCommitMessage:u,setProfileCommitMessage:m,submitProfileCommit:o,onClose:()=>v(!1)}):null,x&&i?e.jsx(Sa,{disabled:k,profile:i,profileBusy:r,selectedDefaultTeamId:d,syncDisabledReason:c,submitProfilePush:f,onClose:()=>N(!1)}):null]})}function wa({disabled:s,profileBusy:t,profileCommitMessage:a,setProfileCommitMessage:n,submitProfileCommit:i,onClose:r}){function u(d){d.preventDefault(),!s&&(i(),r())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:r,children:e.jsxs("form",{className:"git-dialog profile-commit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-commit-dialog-title",onMouseDown:d=>d.stopPropagation(),onSubmit:u,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:r,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Je,{size:18})}),e.jsx("h2",{id:"profile-commit-dialog-title",children:"Commit profile"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Commit message"}),e.jsx("input",{autoFocus:!0,value:a,disabled:!!t,placeholder:"Update OpenPond profile",onChange:d=>n(d.target.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:r,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:s,type:"submit",children:[e.jsx(Je,{size:14}),e.jsx("span",{children:t==="commit"?"Committing":"Commit"})]})]})]})})}function Sa({disabled:s,profile:t,profileBusy:a,selectedDefaultTeamId:n,syncDisabledReason:i,submitProfilePush:r,onClose:u}){const d=Pa(t,n),c=d.reduce((f,p)=>f+p.count,0),m=!s&&!i;function o(f){f.preventDefault(),m&&(r(),u())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:u,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:f=>f.stopPropagation(),onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:u,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(we,{size:18})}),e.jsx("h2",{id:"profile-sync-dialog-title",children:"Sync profile"}),e.jsx("p",{className:"profile-sync-explainer",children:"Sync publishes this committed Profile source for your team, so its Agents can be shared in team chat and attached to hosted sandboxes."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[c," ",c===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",De(t.summary.localHead??t.git?.head)," - Last pushed"," ",De(t.hosted?.lastPushedLocalHead)]})]}),d.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:d.map(f=>e.jsxs("div",{className:`profile-dialog-diff-row ${f.tone??""}`,children:[e.jsx("strong",{children:f.label}),e.jsx("span",{children:f.detail})]},f.label))}):e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:e.jsxs("div",{className:"profile-dialog-diff-row",children:[e.jsx("strong",{children:"Aligned"}),e.jsx("span",{children:"Current local profile source has already been pushed."})]})}),i?e.jsx("div",{className:"profile-dialog-warning",children:i}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!a,type:"button",onClick:u,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!m,type:"submit",children:[e.jsx(we,{size:14}),e.jsx("span",{children:a==="push"?"Syncing":"Confirm sync"})]})]})]})})}function ka({profile:s,profileBusy:t,onClose:a}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog profile-path-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-path-dialog-title",onMouseDown:n=>n.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:a,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Fe,{size:18})}),e.jsx("h2",{id:"profile-path-dialog-title",children:"Profile repo"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Profile repo path"}),e.jsx("input",{"aria-label":"Profile repo path",readOnly:!0,value:s.repoPath??""})]}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:s.git?.isRepo?"Git-backed":"Git setup required"}),e.jsxs("span",{children:[s.git?.branch??"No branch"," · ",De(s.git?.head)]})]}),e.jsx("div",{className:"git-dialog-footer",children:e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:a,children:"Close"})})]})})}function Ca({onSkillCommand:s,onEvaluate:t,profile:a}){const n=a.skills.slice().sort((u,d)=>u.name.localeCompare(d.name)),i=!s;function r(u){s?.(u)}return e.jsxs("div",{className:"account-list profile-skill-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Skills"}),e.jsx("div",{className:"profile-skill-heading-actions",children:e.jsxs("small",{children:[a.skillCatalog.skillCount," tracked"]})})]}),n.length?e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-skill-table","aria-label":"Profile skills table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-skill-name-column"}),e.jsx("col",{className:"profile-skill-trigger-column"}),e.jsx("col",{className:"profile-skill-status-column"}),e.jsx("col",{className:"profile-skill-source-column"}),e.jsx("col",{className:"profile-skill-actions-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Skill"}),e.jsx("th",{scope:"col",children:"Trigger"}),e.jsx("th",{scope:"col",children:"Status"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:n.map(u=>e.jsx(Ra,{commandDisabled:i,onSkillCommand:r,onEvaluate:t,skill:u},u.name))})]})}):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No profile skills found"}),e.jsx("span",{children:"Use /skill create to add reusable profile instructions."})]})]})}function Ra({commandDisabled:s,onSkillCommand:t,onEvaluate:a,skill:n}){const i=n.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:n.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Ke,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:n.name}),e.jsx("span",{title:n.path,children:n.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:n.description,children:n.description||"No description"}),e.jsx("td",{children:e.jsx(dt,{status:i})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:n.sourcePath,children:n.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[a?e.jsx("button",{className:"settings-secondary compact",type:"button",onClick:()=>a(n.path),children:"Evaluate"}):null,e.jsx("button",{className:"settings-secondary compact",disabled:s||!n.enabled,type:"button",title:`Use ${n.name}`,onClick:()=>t(`$${n.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${n.name}`,onClick:()=>t(`/skill edit ${n.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function dt({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function De(s){return s?s.slice(0,10):"None"}function as(s,t){return ut(s,t)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${De(s.hosted.sourceCommitSha)}`:"Not pushed"}function Hs(s,t){return t?s.git?.head?s.git.dirty?"Commit local profile changes before syncing.":null:"Commit the profile before syncing.":"Select a default team before syncing."}function Pa(s,t){const a=[],n=s.summary.localHead??s.git?.head??null,i=s.hosted?.lastPushedLocalHead??null,r=s.summary.hostedHead??s.hosted?.sourceCommitSha??null;if(ut(s,t)&&a.push({label:"Account",detail:"Hosted profile metadata was synced under a different default team.",count:1,tone:"warning"}),!r&&!i?a.push({label:"Hosted source",detail:"No hosted profile commit has been recorded.",count:1}):n&&i&&n!==i&&a.push({label:"Commit",detail:`Local ${De(n)} has not been pushed since ${De(i)}.`,count:1}),s.git?.dirty){const d=(s.git.fileCount??s.git.files.length)||(s.diff.fileCount??s.diff.files.length)||1;a.push({label:"Uncommitted files",detail:`${d} local ${d===1?"file":"files"} changed.`,count:d,tone:"warning"})}const u=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length+s.diff.changedSkills.length+s.diff.changedActions.length+s.diff.changedExtensions.length+s.diff.setupChanges.length+s.diff.envRequirementChanges.length;return u>0&&a.push({label:"Profile changes",detail:Aa(s),count:u,tone:s.git?.dirty?"warning":void 0}),s.catalog.stale&&a.push({label:"Catalog",detail:"Action catalog artifacts are stale or missing.",count:1,tone:"warning"}),s.setupGate.blockingCount>0&&a.push({label:"Setup",detail:`${s.setupGate.blockingCount} blocking setup ${s.setupGate.blockingCount===1?"requirement":"requirements"}.`,count:s.setupGate.blockingCount,tone:"warning"}),a}function Aa(s){const t=[],a=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length;return a&&t.push(`${a} agent ${a===1?"change":"changes"}`),s.diff.changedActions.length&&t.push(`${s.diff.changedActions.length} action ${s.diff.changedActions.length===1?"change":"changes"}`),s.diff.changedSkills.length&&t.push(`${s.diff.changedSkills.length} skill ${s.diff.changedSkills.length===1?"change":"changes"}`),s.diff.changedExtensions.length&&t.push(`${s.diff.changedExtensions.length} extension ${s.diff.changedExtensions.length===1?"change":"changes"}`),s.diff.setupChanges.length&&t.push(`${s.diff.setupChanges.length} setup ${s.diff.setupChanges.length===1?"change":"changes"}`),s.diff.envRequirementChanges.length&&t.push(`${s.diff.envRequirementChanges.length} env ${s.diff.envRequirementChanges.length===1?"change":"changes"}`),t.join(", ")||"Profile source has local changes."}function ut(s,t){const a=s.hosted?.teamId?.trim()??"";return!!(a&&t&&a!==t)}function Ia({status:s,busy:t,flashTailscaleUp:a,refresh:n,enableRemoteAccess:i,disableRemoteAccess:r,copyRemoteLink:u,copyTailscaleUpCommand:d,copyServeCommand:c,copyServeSetupUrl:m,copyOperatorCommand:o,createRemoteLink:f}){const p=s?.tailscale.installed??!1,g=s?.serve.enabled??!1,j=s?.serve.reachable??!1,v=!!(s?.webUiAvailable&&p),x=g?!!s?.remoteWebUrl:v,k=(s?.tailscale.peers??[]).filter(y=>!y.isSelf),A=!!s?.tailscale.error?.includes("set --operator"),$=!!(g&&s?.remoteWebUrl);return e.jsxs("section",{className:"account-settings remote-access-settings",children:[e.jsx("h1",{children:"Remote access"}),e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx("div",{className:`remote-access-icon ${j?"online":g?"configured":""}`,children:p?e.jsx(rt,{size:18}):e.jsx(cn,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:j?"Tailscale Serve is reachable":g?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Da(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||!p||!g&&!v,onClick:()=>{g?r():i()},children:[e.jsx(Ut,{size:15}),e.jsx("span",{children:g?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:$?"Browser UI":"Tailscale + Serve"})]})}),$&&e.jsx(je,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:t==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||t!==null,onAction:u}),e.jsx(je,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:a,actionLabel:t==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||t!==null,onAction:d}),e.jsx(je,{label:"Serve command",value:s?.serveCommand??null,actionLabel:t==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||t!==null,onAction:c}),s?.serve.setupUrl&&e.jsx(je,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:t==="copy-serve-setup"?"Copying":"Copy",disabled:t!==null,onAction:m}),A&&e.jsx(je,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:t==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||t!==null,onAction:o}),e.jsx(je,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(je,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(je,{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:[k.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:t!==null||!x,onClick:()=>{f()},children:e.jsx("span",{children:g?"Copy link":"Create link"})})]}),s?k.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."})]}):k.map(y=>e.jsx($a,{peer:y},y.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(Ea,{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 je({actionLabel:s,disabled:t,flash:a,label:n,onAction:i,value:r}){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:r??"Not available"})]}),i&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:t,onClick:()=>{i()},children:e.jsx("span",{children:s??"Copy"})})]})}function Ea({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(Bs,{label:n.label,value:n.value},n.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(n=>e.jsx(Bs,{label:n.label,value:n.value},n.label))})]})}function Bs({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 $a({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 Da(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"}function Ta({device:s,self:t,busy:a,webBaseUrl:n,teamId:i,act:r}){const[u,d]=l.useState(s.name);l.useEffect(()=>d(s.name),[s.name]);const c=i===null?"remoteScope=personal":`remoteTeam=${encodeURIComponent(i)}`,m=n?`${n}/?remoteDevice=${encodeURIComponent(s.id)}&${c}`:null;return e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsxs("div",{className:"remote-access-device-details",children:[e.jsxs("strong",{children:[s.name,t?" · This computer":""]}),e.jsxs("small",{children:[s.status.replaceAll("_"," ")," · ",s.taskCount," tasks at last sync"]}),e.jsxs("small",{children:["Last seen"," ",s.lastSeenAt?new Date(s.lastSeenAt).toLocaleString():"never"," ","· Catalog synced"," ",s.lastCatalogSyncAt?new Date(s.lastCatalogSyncAt).toLocaleString():"never"]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Computer name"}),e.jsx("input",{value:u,maxLength:200,disabled:a,onChange:o=>d(o.target.value)})]})]}),e.jsxs("div",{className:"account-summary-actions",children:[m&&e.jsx("a",{className:"settings-secondary",href:m,target:"_blank",rel:"noreferrer",children:"Open tasks"}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:a||!u.trim()||u.trim()===s.name,onClick:()=>{r("rename",{deviceId:s.id,revision:s.revision,name:u.trim()})},children:"Save name"}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:a||!s.enabled,onClick:()=>{r(t?"disable":"disable-device",t?{}:{deviceId:s.id,revision:s.revision})},children:"Turn off"}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:a,onClick:()=>{r("remove",{deviceId:s.id,revision:s.revision})},children:"Remove"})]})]})}const La={signed_out:"Sign in required",connecting:"Connecting",connected:"Connected",reconnecting:"Reconnecting",offline:"Offline",off:"Off",update_required:"Update required"},_s={protocol_unsupported:"Install the latest OpenPond desktop app to connect to this relay.",authentication_timeout:"The relay did not confirm authentication. Retry the connection.",authentication_expired:"Relay authentication expired. Retry the connection.",relay_backpressure:"The relay is busy. OpenPond will retry automatically.",connection_lost:"The relay connection was lost. OpenPond will retry automatically.",connection_failed:"Unable to reach the relay. Check your network connection and retry."};function Fs(s,t){return s instanceof Error?s.message==="remote_account_changing"?"Your account settings are being updated. Try again shortly.":s.message:t}function Oa({connection:s,onError:t}){const[a,n]=l.useState(null),[i,r]=l.useState(null),[u,d]=l.useState(!1),[c,m]=l.useState(null),o=l.useRef(0),f=l.useRef(a),p=l.useRef(!1),g=l.useRef(null),j=l.useCallback(async()=>{if(g.current)return;const N=++o.current;if(!s){f.current=null,n(null);return}const k=new AbortController;g.current=k,m(null);try{const A=await ye(s,"/v1/account-remote-access",{signal:AbortSignal.any([k.signal,AbortSignal.timeout(15e3)])});o.current===N&&(f.current=A,n(A))}catch(A){!k.signal.aborted&&o.current===N&&m(A instanceof Error&&A.name==="TimeoutError"?"Loading your computers timed out. Retry to load their current status.":Fs(A,"Unable to load your computers."))}finally{g.current===k&&(g.current=null)}},[s]);l.useEffect(()=>{f.current=null,n(null),m(null),j();let N=Date.now();const k=window.setInterval(()=>{if(p.current)return;(["connecting","reconnecting"].includes(f.current?.state??"")||Date.now()-N>=15e3)&&(N=Date.now(),j())},1e3);return()=>{++o.current,g.current?.abort(),g.current=null,window.clearInterval(k)}},[j]),l.useEffect(()=>{r(null);const N=a?.team?.id;if(!s||!a?.account||!N)return;let k=!0;return Mt.organizations(s).then(A=>{const $=A.organizations.map(Ys).find(y=>y?.teamId===N);k&&$&&r($.displayName||$.name||$.slug)}).catch(()=>{}),()=>{k=!1}},[s,a?.account?.id,a?.team?.id]);async function v(N,k={}){if(!s||p.current)return;g.current?.abort(),g.current=null;const A=++o.current;p.current=!0,d(!0),t(null);try{const $=await ye(s,`/v1/account-remote-access/${N}`,{method:"POST",body:JSON.stringify(k)});o.current===A&&(f.current=$,n($))}catch($){o.current===A&&(t(Fs($,"Unable to update remote access.")),await j())}finally{p.current=!1,d(!1)}}const x=!!a?.account;return e.jsxs("section",{className:"account-settings remote-access-settings",children:[e.jsx("h1",{children:"Remote access"}),e.jsx("p",{children:"View this computer’s tasks and send instructions from your signed-in OpenPond account. Tasks run on this computer."}),a?.account&&e.jsxs("p",{children:["Account: ",a.account.label," · ",a.team?`Workspace: ${i??a.team.id}`:"Personal account"]}),e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsx("div",{className:"account-summary-main",children:e.jsxs("div",{children:[e.jsxs("strong",{children:["This computer",a?.device?.name?` · ${a.device.name}`:""]}),e.jsx("small",{role:"status",children:a?La[a.state]:c?"Unable to load":"Checking connection…"}),a?.device&&e.jsxs("small",{children:["Catalog synced"," ",a.device.lastCatalogSyncAt?new Date(a.device.lastCatalogSyncAt).toLocaleString():"never"]})]})}),e.jsxs("div",{className:"account-summary-actions",children:[e.jsx("button",{className:"settings-secondary",type:"button",disabled:u||!x,onClick:()=>{v(a?.enabled?"disable":"enable")},children:u?"Updating…":a?.enabled?"Turn off":"Turn on"}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:u||(a?!x||!a.enabled:!s||!c),onClick:()=>a?void v("retry"):void j(),children:a?"Retry connection":"Retry loading"})]})]}),c&&e.jsx("p",{role:"alert",children:c}),a?.state==="signed_out"&&e.jsx("p",{children:"Sign in from Settings → Account to connect this computer."}),a?.account&&!a.team&&e.jsx("p",{children:"Personal access includes tasks owned by your OpenPond account. To use workspace tasks, select that workspace in Settings → Account."}),a?.team&&e.jsx("p",{children:"This connection includes tasks owned by the selected workspace. Choose Personal account in Settings → Account to use your personal tasks."}),a?.reason&&_s[a.reason]&&e.jsxs("p",{role:"status",children:[_s[a.reason],a.state==="update_required"&&a.minimumSupportedProtocolVersion?` This relay requires protocol ${a.minimumSupportedProtocolVersion}; this app uses protocol ${a.supportedProtocolVersion}.`:""]}),a?.device?.removed&&e.jsx("p",{children:"This computer was removed. Turn on remote access here to enroll it again."}),e.jsx("p",{children:"Turning off remote access applies to your personal account and its workspaces on this computer. It stays off after restart and sign-in until you turn it on here. Sleeping or closing the app makes this computer unavailable."}),e.jsx("p",{children:"History fetched through OpenPond may be cached for 24 hours. Turning off or removing a computer blocks remote history and controls; its local history stays on that computer."}),e.jsx("h2",{children:"Your computers"}),a?.devices.length===0&&e.jsx("p",{children:"No computers are enrolled."}),a?.devices.map(N=>e.jsx(Ta,{device:N,self:N.id===a.device?.id,busy:u,webBaseUrl:a.webBaseUrl,teamId:a.team?.id??null,act:v},N.id)),!!a?.unresolvedTasks.length&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Choose ownership for older tasks"}),e.jsx("p",{children:"These tasks have no recorded account owner. Only add tasks that belong to you. Their local history is preserved."}),a.unresolvedTasks.map(N=>e.jsxs("div",{className:"account-summary",children:[e.jsx("strong",{className:"remote-access-task-title",children:N.title}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:u,onClick:()=>{v("attach",{sessionId:N.id,expectedRevision:N.revision})},children:"Add to my account"})]},N.id))]})]})}const Ua=[{items:[{section:"account",label:"Account",Icon:bs},{section:"ponder",label:"Ponder Pal",Icon:He},{section:"notifications",label:"Notifications",Icon:it},{section:"providers",label:"Providers",Icon:Zs},{section:"usage",label:"Activity",Icon:Ht}]},{label:"Harness",items:[{section:"harness",label:"Overview",Icon:an},{section:"harness-refiner",label:"Refiner",Icon:js},{section:"harness-continuous-review",label:"Continuous Review",Icon:he},{section:"harness-contents",label:"Contents",Icon:Bt},{section:"harness-releases",label:"Releases",Icon:ln}]},{label:"Customization",items:[{section:"configuration",label:"Configuration",Icon:kn},{section:"personalization",label:"Personalization",Icon:js},{section:"editor",label:"Editor",Icon:rn},{section:"skills",label:"Skills",Icon:Ke}]},{label:"Agents",items:[{section:"profile",label:"Profiles",Icon:bs},{section:"subagents",label:"Agents",Icon:He}]},{label:"System",items:[{section:"dataset-storage",label:"Dataset Storage",Icon:bn},{section:"remote",label:"Remote Access",Icon:rt},{section:"diagnostics",label:"Diagnostics",Icon:dn}]}];function Ma({section:s,onBack:t,onSectionChange:a}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back","aria-label":"Back to app",onClick:t,children:[e.jsx(zt,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Ua.map((n,i)=>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:r,label:u,Icon:d})=>e.jsxs("button",{className:`settings-nav-item ${s===r?"active":""}`,onClick:()=>a(r),children:[e.jsx(d,{size:16}),e.jsx("span",{children:u})]},r))]},n.label??`settings-${i}`))})]})}function za({catalog:s,connection:t,onCatalog:a,onError:n,onOpenExtension:i,onToast:r}){const[u,d]=l.useState(""),[c,m]=l.useState(""),[o,f]=l.useState(null),[p,g]=l.useState(null),[j,v]=l.useState(null),x=l.useCallback(h=>{const w=h instanceof Error?h.message:String(h);v(w),n(w),r?.(w,"error")},[n,r]),N=l.useCallback(()=>{v(null),n(null)},[n]),k=l.useCallback(async h=>{if(h?.preventDefault(),!(!t||!u.trim()||p)){N(),g("preview");try{const w=await U.extensionPreview(t,{source:u.trim(),...c.trim()?{ref:c.trim()}:{}});f(w)}catch(w){f(null),x(w)}finally{g(null)}}},[p,N,t,x,c,u]),A=l.useCallback(async()=>{if(!(!t||!o||p)){N(),g("install");try{const h=await U.extensionAdd(t,{source:o.repositoryUrl,ref:o.requestedRef});a(h.catalog),d(""),m(""),f(null),r?.(`Installed ${h.extension.owner}/${h.extension.repo}.`,"success")}catch(h){x(h)}finally{g(null)}}},[p,N,t,a,r,o,x]),$=l.useCallback(async h=>{if(!(!t||p)){N(),g(`update:${h.id}`);try{const w=await U.extensionUpdate(t,h);a(w.catalog);const C=w.extension.resolvedCommit===h.resolvedCommit&&w.extension.packageHash===h.packageHash;r?.(C?`${h.owner}/${h.repo} is already current.`:`Updated ${h.owner}/${h.repo}.`,"success")}catch(w){x(w)}finally{g(null)}}},[p,N,t,a,r,x]),y=l.useCallback(async()=>{if(!(!t||p||s.extensions.length===0)){N(),g("update-all");try{const h=await U.extensionUpdateAll(t);a(h.catalog);const w=`Updated ${h.updated.length}; ${h.unchanged.length} already current${h.failed.length?`; ${h.failed.length} failed`:""}.`;r?.(w,h.failed.length?"error":"success"),h.failed.length&&v(h.failed.map(C=>C.error).join(" "))}catch(h){x(h)}finally{g(null)}}},[p,s.extensions.length,N,t,a,r,x]),R=l.useCallback(async h=>{if(!(!t||p)&&window.confirm(`Remove ${h.owner}/${h.repo} and its ${h.skills.length} installed skill${h.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){N(),g(`remove:${h.id}`);try{const w=await U.extensionRemove(t,h);a(w.catalog),r?.(`Removed ${h.owner}/${h.repo}.`,"success")}catch(w){x(w)}finally{g(null)}}},[p,N,t,a,r,x]),O=l.useCallback(h=>{d(h),f(null),v(null)},[]),I=l.useCallback(h=>{m(h),f(null),v(null)},[]);return e.jsxs("div",{className:"account-list native-skills-list github-extensions-list",children:[e.jsxs("div",{className:"account-list-heading github-extensions-heading",children:[e.jsx("span",{children:"Third-party extensions"}),e.jsxs("div",{className:"github-extensions-heading-actions",children:[e.jsxs("small",{children:[s.extensions.length," installed from GitHub"]}),e.jsxs("button",{className:"settings-secondary compact",disabled:!t||p!==null||s.extensions.length===0,type:"button",onClick:()=>{y()},children:[p==="update-all"?e.jsx(Me,{className:"settings-spin",size:13}):e.jsx(he,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:h=>{k(h)},children:[e.jsxs("div",{className:"github-extension-add-copy",children:[e.jsx("strong",{children:"Add a GitHub skill pack"}),e.jsx("span",{children:"Use a skills-CLI-compatible owner/repo or GitHub URL. OpenPond installs it locally without running setup code."})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{disabled:!t||p!==null,placeholder:"owner/repo",value:u,onChange:h=>O(h.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!t||p!==null,placeholder:"Default branch",value:c,onChange:h=>I(h.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!u.trim()||p!==null,type:"submit",children:[p==="preview"?e.jsx(Me,{className:"settings-spin",size:14}):e.jsx(cs,{size:14}),p==="preview"?"Checking":"Preview"]})]}),j||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:j??s.error}):null,o?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[o.owner,"/",o.repo]}),e.jsxs("span",{children:[o.skills.length," skill",o.skills.length===1?"":"s"," at ",o.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:o.skills.map(h=>e.jsx("span",{children:h.name},h.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:p!==null,type:"button",onClick:()=>{A()},children:[p==="install"?e.jsx(Me,{className:"settings-spin",size:14}):e.jsx(Ne,{size:14}),p==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(h=>{const w=p===`update:${h.id}`,C=p===`remove:${h.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${h.owner}/${h.repo} extension source`,className:"github-extension-open",disabled:!t||p!==null,type:"button",onClick:()=>i(h),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.jsxs("strong",{children:[h.owner,"/",h.repo]}),e.jsx("span",{children:h.skills.map(S=>S.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[h.skills.length," skill",h.skills.length===1?"":"s"]}),e.jsxs("span",{children:[h.requestedRef," · ",h.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${h.validationStatus==="valid"?"":"invalid"}`,children:h.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(et,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${h.owner}/${h.repo}`,className:"settings-icon-button ghost",disabled:p!==null,title:"Update extension",type:"button",onClick:()=>{$(h)},children:w?e.jsx(Me,{className:"settings-spin",size:14}):e.jsx(he,{size:14})}),e.jsx("button",{"aria-label":`Remove ${h.owner}/${h.repo}`,className:"settings-icon-button ghost danger",disabled:p!==null,title:"Remove extension",type:"button",onClick:()=>{R(h)},children:C?e.jsx(Me,{className:"settings-spin",size:14}):e.jsx(Qe,{size:14})})]})]},h.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function Ha({onOpenSkill:s,onOpenExtension:t,personalSkills:a,extensionCatalog:n,connection:i,onExtensionCatalog:r,onError:u,onToast:d}){return e.jsxs("section",{className:"account-settings skills-settings","aria-labelledby":"skills-settings-title",children:[e.jsx("header",{className:"skills-settings-header",children:e.jsxs("div",{children:[e.jsx("h1",{id:"skills-settings-title",children:"Skills"}),e.jsx("p",{children:"Install third-party GitHub packs, inspect personal Codex skills, and view instructions bundled with OpenPond."})]})}),e.jsx(za,{catalog:n,connection:i,onCatalog:r,onError:u,onOpenExtension:t,onToast:d}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Personal Codex skills"}),e.jsx("small",{children:"Discovered from your local Codex skills folder"})]}),a.length?a.map(c=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Ke,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:c.name}),e.jsx("span",{children:c.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:c.resourceFiles.length?`${c.resourceFiles.length} packaged resource${c.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:c.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${c.validationStatus==="valid"?"":"invalid"}`,children:c.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},c.sourcePath)):e.jsx("div",{className:"skills-settings-empty",children:"No personal Codex skills found."})]}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"App integration skills"}),e.jsx("small",{children:"Bundled with this OpenPond build"})]}),_t.map(c=>{const m=Ft(c.provider)?.label??c.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(c),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Ke,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:c.name}),e.jsx("span",{children:c.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:m}),e.jsx("span",{children:c.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(et,{size:16,"aria-hidden":"true"})]},c.name)})]})]})}const gs="default";function Ba({connection:s,embedded:t=!1,onError:a,onPreferences:n,preferences:i,providers:r}){const u=i.training,[d,c]=l.useState(is(u.defaultModelRef)),[m,o]=l.useState(u.creationMode),[f,p]=l.useState(u.autoApproveEvidence),[g,j]=l.useState(!1),v=l.useMemo(()=>Xs(r,{includeUnavailable:!0}),[r]),x=l.useMemo(()=>v.map(y=>({provider:y,models:ms(y.value,r)})).filter(y=>y.models.length>0),[v,r]),N=_a(d),k=Wt(i.defaultChatProvider,i.defaultChatModel,r)?` · ${Fa(i.codexReasoningEffort)} reasoning`:"",A=Wa(N,u.defaultModelRef??null)&&m===u.creationMode&&f===u.autoApproveEvidence;l.useEffect(()=>{c(is(u.defaultModelRef)),o(u.creationMode),p(u.autoApproveEvidence)},[i.defaultChatModel,i.defaultChatProvider,u.autoApproveEvidence,u.creationMode,u.defaultModelRef]);async function $(y){if(y.preventDefault(),!!s){j(!0),a(null);try{n(await U.savePreferences(s,{training:{defaultModelRef:N,creationMode:m,autoApproveEvidence:f}}))}catch(R){a(R instanceof Error?R.message:String(R))}finally{j(!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:y=>{$(y)},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:d,disabled:g,onChange:y=>c(y.target.value),children:[e.jsxs("option",{value:gs,children:["Use chat default — ",rs(i.defaultChatProvider,r)," · ",vs(i.defaultChatModel,r,i.defaultChatProvider),k]}),x.map(y=>e.jsx("optgroup",{label:y.provider.label,children:y.models.map(R=>e.jsx("option",{value:is({providerId:y.provider.value,modelId:R.value}),children:R.label},R.value))},y.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:m,disabled:g,onChange:y=>o(y.target.value),children:[e.jsx("option",{value:"customize",children:"Guided plan — review and revise before materializing"}),e.jsx("option",{value:"defaults",children:"Fast draft — use reversible defaults"})]})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Evidence confirmation"}),e.jsx("small",{children:"Controls the first authoring gate; materialization and training remain separate"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:f,disabled:g,onChange:y=>p(y.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Skip evidence confirmation"}),e.jsx("small",{children:"Immediately send excerpts from explicitly selected chats to the authoring model. This never approves Taskset materialization or training spend."})]})]}),e.jsx("button",{className:"settings-primary",disabled:g||A,children:e.jsx("span",{children:g?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:N?`${rs(N.providerId,r)} / ${vs(N.modelId,r,N.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 is(s){return s?JSON.stringify([s.providerId,s.modelId]):gs}function _a(s){if(s===gs)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 Fa(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function Wa(s,t){return s?.providerId===t?.providerId&&s?.modelId===t?.modelId}function qa({disabled:s,onChange:t,storageRoots:a,value:n}){const i=l.useId(),[r,u]=l.useState(!1),d=Ws(n),c=f=>f.datasetStorePath,m="Dataset",o=a.find(f=>Ws(c(f))===d)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:i,children:[m," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${m} storage drive`,className:"model-storage-select",disabled:s,id:i,title:n??"No Dataset storage configured",value:n??"",onChange:f=>t(f.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),n&&!o?e.jsx("option",{value:n,children:"Manual location"}):null,a.map(f=>e.jsxs("option",{disabled:!f.mounted||!f.writable,title:c(f),value:c(f),children:[f.label," · ",Ja(f.kind)," · ",Ya(f)]},f.id))]}),e.jsx("button",{className:"settings-icon-button model-storage-add",disabled:s,type:"button",title:"Add manual location","aria-label":"Add manual Dataset storage location",onClick:()=>u(!0),children:e.jsx(Ne,{size:15})})]}),r?Ga(e.jsx(Va,{initialPath:n??"",purpose:"dataset",onClose:()=>u(!1),onUse:f=>{t(f),u(!1)}})):null]})}function Ga(s){return typeof document>"u"?s:qt.createPortal(s,document.body)}function Va({initialPath:s,onClose:t,onUse:a,purpose:n="model"}){const i=l.useId(),[r,u]=l.useState(s),d=Ka(r);l.useEffect(()=>{const m=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);function c(m){m.preventDefault(),m.stopPropagation(),!d&&a(r.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:m=>{m.target===m.currentTarget&&t()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":i,onSubmit:c,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${n} storage`,onClick:t,children:e.jsx(pe,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(hn,{size:18})}),e.jsxs("h2",{id:i,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:r,placeholder:n==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:m=>u(m.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."}),r.trim()&&d?e.jsx("div",{className:"profile-dialog-warning",children:d}):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:!!d,type:"submit",children:"Use location"})]})]})})}function Ka(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 Ja(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function Ya(s){return s.mounted?s.writable?`${Qa(s.freeBytes)} free`:"Read only":"Not mounted"}function Ws(s){const t=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(t)?t.toLowerCase():t}function Qa(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 Xa({state:s,catalog:t,busy:a,catalogLoading:n,onRefresh:i,onSave:r}){const[u,d]=l.useState(s?.settings.datasetStorePath??null);l.useEffect(()=>{d(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const c=l.useMemo(()=>s?.storageRoots.find(p=>qs(p.datasetStorePath)===qs(u))??null,[u,s?.storageRoots]),m=u===(s?.settings.datasetStorePath??null),o=t?.datasets??[];async function f(p){p.preventDefault(),await r(u)}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:()=>{i()},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:c?.label??(u?"Manual location":"Not configured")}),e.jsx("small",{children:u??"Choose a writable local or mounted location before importing a Dataset."}),c?e.jsxs("small",{children:[ti(c.kind)," · ",c.freeBytes==null?"Free space unknown":`${ht(c.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:p=>{f(p)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(qa,{disabled:a!==null,onChange:d,storageRoots:s?.storageRoots??[],value:u}),e.jsx("button",{className:"settings-primary",disabled:a!==null||m,children:a==="save"?"Saving":"Save Dataset storage"})]}),e.jsxs("div",{className:"account-list dataset-storage-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Registered Datasets"}),e.jsx("small",{children:o.length})]}),o.length?o.map(p=>e.jsx(Za,{dataset:p},p.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:n?"Loading registered Datasets":"No registered Datasets"})})]})]})}function Za({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:[mt(s.rowCount)," rows"," · ",ei(s)," · ",t," · ",s.sizeBytes==null?"Size unavailable":ht(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?si(s.status):"Unavailable"})]})}function ei(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])=>`${mt(Number(n))} ${a}`).join(" · ")||"No split rows"}function ht(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 mt(s){return new Intl.NumberFormat().format(s)}function qs(s){return s?.replace(/[\\/]+$/,"")??""}function si(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function ti(s){return s.replace(/^./,t=>t.toUpperCase())}function _e(s){if(!s)return"Not yet";const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function $e(s){return s?s.slice(0,10):"none"}function Re(s){const t=s.replaceAll("_"," ");return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function ni(s){return s==="unresolved"?"Watching":s==="confirmed"?"Ready for Refiner":Re(s)}function ai({review:s}){const t=[["Taskset",s.tasksetProposal],["Baseline evaluation",s.evaluation],["Training qualification",s.trainingQualification]];return e.jsx("div",{className:"harness-review-lineage","aria-label":"Review lineage",children:t.map(([a,n])=>e.jsxs("div",{className:n?"linked":"pending",children:[e.jsx("span",{children:a}),e.jsx("code",{children:n?$e(n.contentHash):"Not created"})]},a))})}function ii({candidate:s}){return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${s.status}`,children:ni(s.status)}),e.jsx("strong",{children:s.statement}),e.jsxs("small",{children:[s.occurrences.length," occurrence",s.occurrences.length===1?"":"s"]}),e.jsx("time",{children:_e(s.updatedAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:s.resolution?.reason??s.recurrenceFamily}),e.jsxs("dl",{className:"harness-compact-metadata",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Pattern"}),e.jsx("dd",{children:s.recurrenceFamily})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Fingerprint"}),e.jsx("dd",{children:e.jsx("code",{children:$e(s.fingerprint)})})]})]}),s.occurrences.length?e.jsxs("details",{className:"harness-history-details",children:[e.jsx("summary",{children:"Evidence receipts"}),e.jsx("ul",{className:"harness-evidence-list",children:s.occurrences.map(t=>e.jsxs("li",{children:[e.jsx("span",{children:Re(t.kind)}),e.jsx("code",{children:$e(t.evidence.contentHash)}),e.jsx("time",{children:_e(t.occurredAt)})]},`${t.evidence.id}:${t.evidence.contentHash}`))})]}):null]})]})}function li({accepting:s,onAcceptTasksetReview:t,review:a}){const n=a.classification==="taskset"&&a.nextAuthority==="human_review"&&a.tasksetProposal===null;return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${a.classification}`,children:Re(a.classification)}),e.jsx("strong",{children:a.claim?.statement??a.reason}),e.jsxs("small",{children:[a.selectedEvidence.length," selected"]}),e.jsx("time",{children:_e(a.createdAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:a.reason}),e.jsxs("div",{className:"harness-review-metrics",children:[e.jsxs("span",{children:[e.jsx("strong",{children:a.selectedEvidence.length})," selected"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.excludedEvidence.length})," excluded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.claim?.independentOccurrences??0})," independent occurrences"]}),e.jsxs("span",{children:["Next: ",e.jsx("strong",{children:Re(a.nextAuthority)})]})]}),e.jsx(ai,{review:a}),n?e.jsx("div",{className:"harness-history-actions",children:e.jsx("button",{className:"settings-primary compact",disabled:s,onClick:()=>t(a),type:"button",children:s?"Opening Taskset review…":"Build training Taskset"})}):null]})]})}function ri({receipt:s}){return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${s.decision}`,children:Re(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsxs("small",{children:[Re(s.signal.strength)," signal"]}),e.jsx("time",{children:_e(s.createdAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:s.reasons.join(" ")}),e.jsxs("dl",{className:"harness-compact-metadata",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Review"}),e.jsx("dd",{children:e.jsx("code",{children:$e(s.review.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Taskset"}),e.jsx("dd",{children:e.jsx("code",{children:$e(s.tasksetRelease?.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Baseline"}),e.jsx("dd",{children:e.jsx("code",{children:$e(s.baselineEvaluation?.contentHash)})})]})]})]})]})}function oi({acceptingReviewId:s,candidates:t,onAcceptTasksetReview:a,qualifications:n,reviews:i,schedule:r}){const u=r.activityEnabled||r.enabled;return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx("section",{className:"harness-history-section","aria-label":"Continuous Review status",children:e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-review-status-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Trigger"}),e.jsx("th",{children:"Last review"}),e.jsx("th",{children:"Last result"})]})}),e.jsx("tbody",{children:e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:`harness-status ${u?"harness-status-advanced":""}`,children:u?"On":"Off"})}),e.jsx("td",{children:r.activityEnabled?`${r.activityBatchSize} new outcomes`:"Manual only"}),e.jsx("td",{children:_e(r.lastRunAt)}),e.jsx("td",{children:r.lastResult?Re(r.lastResult.classification):"No completed review"})]})})]})})}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Patterns"}),e.jsx("p",{children:"Recurring evidence being watched or ready for the Refiner."})]}),e.jsx("span",{children:t.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:t.length?t.map(d=>e.jsx(ii,{candidate:d},`${d.id}:${d.contentHash}`)):e.jsx("div",{className:"harness-empty compact",children:"No recurring patterns are being tracked."})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Review history"}),e.jsx("p",{children:"Receipts stay compact; expand one for evidence and downstream lineage."})]}),e.jsx("span",{children:i.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:i.length?i.map(d=>e.jsx(li,{accepting:s===d.id,onAcceptTasksetReview:a,review:d},`${d.id}:${d.contentHash}`)):e.jsx("div",{className:"harness-empty compact",children:"No Continuous Review receipts yet."})})]}),n.length?e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Training handoffs"}),e.jsx("p",{children:"Evidence-bound qualification receipts created for Models."})]}),e.jsx("span",{children:n.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:n.map(d=>e.jsx(ri,{receipt:d},`${d.id}:${d.contentHash}`))})]}):null]})}const ci="Update the Refiner Review Profile. Inspect the current profile first, ask what should change if it is not already clear, and show the exact release transition.";function Gs(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Ee(s){return s?s.slice(0,10):"none"}function di({busyReleaseHash:s,history:t,onRequestRelease:a,onStartAuthoring:n}){const i=l.useMemo(()=>{const r=new Map;for(const u of t.transitions)r.has(u.nextRelease.contentHash)||r.set(u.nextRelease.contentHash,u);return r},[t.transitions]);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Review Profile"}),e.jsx("p",{children:"Separately versioned policy composed with the immutable Refiner Core."})]}),n?e.jsx("button",{className:"settings-primary compact",onClick:()=>n(ci),type:"button",children:"Edit with Work"}):null]}),e.jsxs("div",{className:"harness-summary-grid",children:[e.jsxs("article",{children:[e.jsx("span",{children:"Active release"}),e.jsx("strong",{children:Ee(t.binding.release.contentHash)}),e.jsxs("small",{children:["Binding revision ",t.binding.revision]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Profile"}),e.jsx("strong",{children:t.currentRelease.profile.name}),e.jsxs("small",{children:[t.currentRelease.profile.id,"@",t.currentRelease.profile.version]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Core"}),e.jsx("strong",{children:t.currentRelease.coreVersion}),e.jsx("small",{children:Ee(t.currentRelease.coreHash)})]})]}),e.jsx("p",{children:t.currentRelease.profile.objective}),t.currentRelease.profile.instructions.length?e.jsx("div",{className:"harness-edit-list",children:t.currentRelease.profile.instructions.map(r=>e.jsx("section",{className:"harness-edit",children:e.jsxs("div",{children:[e.jsx("strong",{children:r.id}),e.jsx("span",{children:r.text})]})},r.id))}):e.jsx("div",{className:"harness-empty compact",children:"The default profile adds no instructions beyond the Refiner Core."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Profile releases"}),e.jsx("p",{children:"Immutable definition history. Rollback changes future reviews only."})]}),e.jsx("span",{children:t.releases.length})]}),e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Profile"}),e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:t.releases.map(r=>{const u=r.contentHash===t.binding.release.contentHash,d=!u&&i.get(r.contentHash)?.bindingChanged===!1,c=d?"activate":"rollback";return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("strong",{children:r.profile.name}),e.jsxs("small",{children:[r.profile.id,"@",r.profile.version," · ",r.profile.instructions.length," instructions"]})]}),e.jsx("td",{children:e.jsx("code",{children:Ee(r.contentHash)})}),e.jsx("td",{children:Gs(r.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:u?"active":d?"draft":"immutable"})}),e.jsx("td",{children:u?null:e.jsx("button",{"aria-label":`${d?"Activate":"Roll back"} Refiner release`,className:"harness-table-icon-action",disabled:s!==null,onClick:()=>a(r,c),title:`${d?"Activate":"Roll back"} Refiner release`,type:"button",children:d?e.jsx(ps,{size:14}):e.jsx(Ye,{size:14})})})]},r.contentHash)})})]})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Definition changes"}),e.jsx("p",{children:"Receipts record which release changed, why, and which authoring Skill produced it."})]}),e.jsx("span",{children:t.transitions.length})]}),e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Operation"}),e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Release transition"}),e.jsx("th",{children:"Validation"}),e.jsx("th",{children:"Created"})]})}),e.jsx("tbody",{children:t.transitions.map(r=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("span",{className:"harness-status",children:[r.operation,r.bindingChanged?" · active":" · draft"]})}),e.jsxs("td",{children:[e.jsx("strong",{children:r.reason}),e.jsx("small",{children:r.authoringSkillHash?`Skill ${Ee(r.authoringSkillHash)}`:r.actor})]}),e.jsx("td",{children:e.jsxs("code",{children:[Ee(r.previousRelease?.contentHash)," → ",Ee(r.nextRelease.contentHash)]})}),e.jsx("td",{children:r.validation.valid?"Passed":r.validation.messages.join("; ")}),e.jsx("td",{children:Gs(r.createdAt)})]},r.contentHash))})]})})]})]})}const ui={enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},hi={overview:{title:"Harness overview",description:"Current state, items needing attention, and recent learning activity."},refiner:{title:"Refiner",description:"Validated per-turn improvements and recommendations routed outside the Harness."},"continuous-review":{title:"Continuous Review",description:"Recurring patterns found across completed work and their immutable review receipts."},contents:{title:"Harness contents",description:"The instructions, skills, agents, and memory available in the current release."},releases:{title:"Harness releases",description:"Immutable versions, diffs, and rollback controls."}};function Te(s){if(!s)return"Not yet";const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Le(s){return s?s.slice(0,10):"none"}function Vs(s,t,a){return{workspaceId:s,baseRelease:t?{id:t.id,contentHash:t.contentHash}:null,targetRelease:{id:a.id,contentHash:a.contentHash},title:a.current?"Current Harness release":`Harness release ${Le(a.contentHash)}`}}function mi({review:s,busy:t,onReview:a}){return e.jsxs("article",{className:"harness-history-card harness-review-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"review required"}),e.jsxs("span",{children:[s.proposal.route," · ",s.proposal.edits[0]?.operation??"change"]})]}),e.jsx("h2",{children:s.proposal.expectedOutcome})]}),e.jsx("time",{children:Te(s.proposal.createdAt)})]}),e.jsx("p",{children:s.proposal.edits.map(n=>n.summary).join(" ")}),e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Exact edits (",s.proposal.edits.length,")"]}),e.jsx("div",{className:"harness-edit-list",children:s.proposal.edits.map(n=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[n.operation," · ",n.target]}),e.jsx("span",{children:n.summary})]}),n.content!==null?e.jsx("pre",{children:n.content}):e.jsx("p",{children:"File deleted."})]},n.id))})]}),s.validations.length?e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Validation receipts (",s.validations.length,")"]}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(n=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${n.status}`,children:n.status}),e.jsx("strong",{children:n.kind.replaceAll("_"," ")}),e.jsx("span",{children:n.summary})]},n.id))})]}):null,e.jsxs("footer",{className:"harness-review-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:t,onClick:()=>a(s,"decline"),type:"button",children:[e.jsx(pe,{size:13})," Decline"]}),e.jsxs("button",{className:"settings-primary compact",disabled:t||s.validations.some(n=>n.status!=="passed"),onClick:()=>a(s,"approve"),type:"button",children:[e.jsx(ps,{size:13})," Approve and release"]})]})]})}function pi({change:s,onClose:t}){const a=s.proposal;return e.jsxs(mn,{ariaLabel:"Refiner change details",backdropClassName:"harness-details-dialog-backdrop",className:"harness-details-dialog",onClose:t,children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsx("span",{className:`harness-status harness-status-${s.receipt.decision}`,children:s.receipt.decision.replaceAll("_"," ")}),e.jsx("h2",{children:a?.expectedOutcome??s.receipt.reason}),e.jsx("p",{children:s.receipt.reason})]}),e.jsx("button",{"aria-label":"Close change details",onClick:t,type:"button",children:e.jsx(pe,{size:16})})]}),e.jsxs("div",{className:"harness-details-dialog-body",children:[a?.edits.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Exact edits"}),e.jsx("div",{className:"harness-edit-list",children:a.edits.map(n=>e.jsxs("article",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[n.operation," · ",n.target]}),e.jsx("span",{children:n.summary})]}),n.content!==null?e.jsx("pre",{children:n.content}):e.jsx("p",{children:"File deleted."})]},n.id))})]}):null,s.validations.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Validation"}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(n=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${n.status}`,children:n.status}),e.jsx("strong",{children:n.kind.replaceAll("_"," ")}),e.jsx("span",{children:n.summary})]},n.id))})]}):null]})]})}function fi({history:s,reviewingProposalId:t,onReviewProposal:a}){const n=l.useMemo(()=>[...s.changes.map(i=>({id:`change:${i.receipt.id}`,at:i.receipt.createdAt,kind:"Refiner",title:i.proposal?.expectedOutcome??i.receipt.reason,detail:i.receipt.decision.replaceAll("_"," ")})),...s.routes.map(i=>({id:`route:${i.decision.id}`,at:i.decision.createdAt,kind:"Routed",title:i.decision.reason,detail:i.decision.route})),...s.evaluationReviews.map(i=>({id:`review:${i.id}`,at:i.createdAt,kind:"Continuous Review",title:i.claim?.statement??i.reason,detail:i.classification.replaceAll("_"," ")}))].sort((i,r)=>r.at.localeCompare(i.at)).slice(0,6),[s]);return e.jsxs("div",{className:"harness-page-sections",children:[s.pendingReviews.length?e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Needs review"}),e.jsx("p",{children:"Sensitive or high-impact proposals require your approval."})]}),e.jsx("span",{children:s.pendingReviews.length})]}),s.pendingReviews.map(i=>e.jsx(mi,{busy:t!==null,onReview:a,review:i},`${i.proposal.id}:${i.proposal.contentHash}`))]}):null,e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Recent activity"}),e.jsx("p",{children:"The latest events from both learning loops."})]}),e.jsx("span",{children:n.length})]}),n.length?e.jsx("div",{className:"harness-activity-list",children:n.map(i=>e.jsxs("article",{children:[e.jsx("span",{children:i.kind}),e.jsxs("div",{children:[e.jsx("strong",{children:i.title}),e.jsx("small",{children:i.detail})]}),e.jsx("time",{children:Te(i.at)})]},i.id))}):e.jsx("div",{className:"harness-empty compact",children:"No Harness learning activity yet."})]})]})}function gi({history:s,refiner:t,busyReleaseHash:a,onRequestRefinerRelease:n,onStartRefinerAuthoring:i,onOpenChangeDiff:r,onOpenSourceSession:u}){const[d,c]=l.useState(null);return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx(di,{busyReleaseHash:a,history:t,onRequestRelease:n,onStartAuthoring:i}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Applied changes"}),e.jsx("p",{children:"Every release transition with exact edits and validation receipts."})]}),e.jsx("span",{children:s.changes.length})]}),s.changes.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-refiner-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Target"}),e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Result"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:s.changes.map(m=>{const o=m.trigger?.runRef??null,f=m.proposal;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:f?.expectedOutcome??m.receipt.reason})}),e.jsx("td",{children:e.jsx("code",{children:f?.edits[0]?.target??f?.route??"workspace"})}),e.jsx("td",{children:e.jsx("code",{children:Le(m.receipt.nextRelease?.contentHash)})}),e.jsx("td",{children:Te(m.receipt.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`harness-status harness-status-${m.receipt.decision}`,children:m.receipt.decision.replaceAll("_"," ")})}),e.jsx("td",{children:e.jsxs("div",{className:"harness-inline-actions",children:[e.jsx("button",{"aria-label":"View evidence and exact edits",className:"harness-table-icon-action",onClick:()=>c(m),title:"View evidence and exact edits",type:"button",children:e.jsx(jn,{size:14})}),m.receipt.nextRelease?e.jsx("button",{"aria-label":"View release diff",className:"harness-table-icon-action",onClick:()=>r(m),title:"View release diff",type:"button",children:e.jsx(lt,{size:14})}):null,o&&u?e.jsx("button",{"aria-label":"Open source conversation",className:"harness-table-icon-action",onClick:()=>u(o),title:"Open source conversation",type:"button",children:e.jsx(Zs,{size:14})}):null]})})]},`${m.receipt.id}:${m.receipt.contentHash}`)})})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness changes have been applied."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Routed recommendations"}),e.jsx("p",{children:"Observations sent to runtime, product, Tasksets, or training without mutating the Harness."})]}),e.jsx("span",{children:s.routes.length})]}),s.routes.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-route-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Recommendation"}),e.jsx("th",{children:"Source evidence"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Route"})]})}),e.jsx("tbody",{children:s.routes.map(m=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("p",{children:m.decision.reason})}),e.jsx("td",{children:e.jsx("p",{children:m.trigger?.reason??"Completed work"})}),e.jsx("td",{children:Te(m.decision.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:m.decision.route})})]},`${m.decision.id}:${m.decision.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No recommendations have been routed."})]}),d?e.jsx(pi,{change:d,onClose:()=>c(null)}):null]})}function xi(s){return s.includes("/skills/")||s.startsWith("skills/")?"Skill":s.includes("/agents/")||s.startsWith("agents/")?"Agent":s.includes("memory")?"Memory":s.endsWith(".md")?"Instruction":"File"}function ji(s){return s<1024?`${s} B`:`${(s/1024).toFixed(s<10240?1:0)} KB`}function vi({history:s,onOpenCurrentRelease:t}){const a=s.releases.find(n=>n.current)??s.releases[0]??null;return e.jsxs("div",{className:"harness-page-sections",children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Current release"}),e.jsx("p",{children:"Read-only source contents currently supplied by the Personal Harness."})]}),a?e.jsx("button",{className:"settings-secondary compact",onClick:t,type:"button",children:"View release diff"}):null]}),a?.files.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Size"}),e.jsx("th",{children:"Revision"})]})}),e.jsx("tbody",{children:a.files.map(n=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:xi(n.path)})}),e.jsx("td",{children:e.jsx("code",{children:n.path})}),e.jsx("td",{children:ji(n.sizeBytes)}),e.jsx("td",{children:e.jsx("code",{children:Le(n.contentHash)})})]},n.id))})]})}):e.jsx("div",{className:"harness-empty compact",children:"The current release has no source files."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Memory"}),e.jsx("p",{children:"Bounded memory available through search; it is not copied into every prompt."})]}),e.jsx("span",{children:s.memories.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:s.memories.length?s.memories.map(n=>e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"harness-status",children:"Memory"}),e.jsx("strong",{children:n.key}),e.jsxs("small",{children:["revision ",n.revision]}),e.jsx("time",{children:Te(n.updatedAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:n.content}),n.tags.length?e.jsx("small",{children:n.tags.join(" · ")}):null]})]},`${n.id}:${n.revision}`)):e.jsx("div",{className:"harness-empty compact",children:"No Harness memory has been saved."})})]})]})}function bi({busy:s,history:t,onOpenDiff:a,onRequestRollback:n}){return e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Release history"}),e.jsx("p",{children:"New work uses the current release; active runs stay pinned to the version they started with."})]}),e.jsx("span",{children:t.releases.length})]}),t.releases.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-release-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Contents"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:t.releases.map((i,r)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:"harness-release-identity",children:[e.jsx("strong",{children:i.id}),e.jsx("code",{children:Le(i.contentHash)})]})}),e.jsxs("td",{children:[i.files.length," files"]}),e.jsx("td",{children:Te(i.createdAt)}),e.jsx("td",{children:i.current?e.jsx("span",{className:"harness-current-pill",children:"Current"}):e.jsx("span",{className:"harness-status",children:"Previous"})}),e.jsx("td",{children:e.jsxs("div",{className:"harness-inline-actions",children:[e.jsx("button",{"aria-label":"View release changes",className:"harness-table-icon-action",onClick:()=>a(t.releases[r+1]??null,i),title:"View release changes",type:"button",children:e.jsx(lt,{size:14})}),i.current?null:e.jsx("button",{"aria-label":"Roll back to release",className:"harness-table-icon-action",disabled:s,onClick:()=>n(i),title:"Roll back to release",type:"button",children:e.jsx(Ye,{size:14})})]})})]},`${i.id}:${i.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness releases exist yet."})]})}function yi({connection:s,enabled:t,onAcceptEvaluationReview:a,onError:n,onDefaultReleaseDiff:i,onOpenReleaseDiff:r,onOpenSourceSession:u,onStartRefinerAuthoring:d,onToast:c,page:m}){const[o,f]=l.useState(null),[p,g]=l.useState(null),[j,v]=l.useState(null),[x,N]=l.useState(!1),[k,A]=l.useState(null),[$,y]=l.useState(null),[R,O]=l.useState(!1),[I,h]=l.useState(!1),[w,C]=l.useState(null),{confirmAction:S,confirmDialog:M,resolveConfirmDialog:F}=Js(),W=!!(o?.evaluationReviewSchedule.activityEnabled||o?.evaluationReviewSchedule.enabled),[se,X]=l.useState(!1),[D,Z]=l.useState(!1);l.useEffect(()=>{o&&X(o.backgroundReview.enabled)},[o?.backgroundReview.enabled]),l.useEffect(()=>{Z(W)},[W]);const te=l.useCallback(async()=>{if(s){N(!0);try{const[L,P]=await Promise.all([U.harnessHistory(s),U.refinerHistory(s)]);f(L),g(P);const H=L.releases.findIndex(ne=>ne.current),z=H>=0?L.releases[H]:null;L.workspace&&z&&i(Vs(L.workspace.id,L.releases[H+1]??null,z)),n(null)}catch(L){n(L instanceof Error?L.message:String(L))}finally{N(!1)}}},[s,i,n]);l.useEffect(()=>{t&&te()},[t,m,te]);const B=l.useCallback(async L=>{if(!(!s||!o?.workspace)){h(!0);try{const P=await U.reviewHarnessEvaluation(s,{workspaceId:o.workspace.id,maxEstimatedCostUsd:L});f(P.history),n(null),c?.(`Continuous Review completed: ${P.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(P){n(P instanceof Error?P.message:String(P))}finally{h(!1)}}},[s,o,n,c]),le=l.useCallback(async(L,P,H)=>{if(!(!s||!o?.workspace)){O(!0);try{let z=o;L==="refiner"&&P!==o.backgroundReview.enabled&&(z=(await U.updateHarnessBackgroundReview(s,{workspaceId:o.workspace.id,enabled:P})).history);const ne=o.evaluationReviewSchedule.activityEnabled||o.evaluationReviewSchedule.enabled;if(L==="continuous-review"&&(H!==ne||o.evaluationReviewSchedule.enabled)){const ce=o.evaluationReviewSchedule;z=(await U.updateHarnessEvaluationReviewSchedule(s,{workspaceId:o.workspace.id,enabled:!1,activityEnabled:H,activityBatchSize:ce.activityBatchSize,cadence:"manual",maxEstimatedCostUsd:ce.maxEstimatedCostUsd})).history}f(z),n(null),c?.(`${L==="refiner"?"Refiner":"Continuous Review"} settings applied.`,"success")}catch(z){n(z instanceof Error?z.message:String(z))}finally{O(!1)}}},[s,o,n,c]),ie=l.useCallback(async L=>{if(o?.workspace){C(L.id);try{await a(o.workspace.id,{id:L.id,contentHash:L.contentHash})&&(n(null),c?.("Taskset review opened in Models.","success"))}catch(P){n(P instanceof Error?P.message:String(P))}finally{C(null)}}},[o?.workspace,a,n,c]),V=l.useCallback((L,P)=>{o?.workspace&&r(Vs(o.workspace.id,L,P))},[o?.workspace,r]),q=l.useCallback(L=>{!o?.workspace||!L.receipt.nextRelease||r({workspaceId:o.workspace.id,baseRelease:L.receipt.previousRelease,targetRelease:L.receipt.nextRelease,title:L.proposal?.expectedOutcome??L.receipt.reason})},[o?.workspace,r]),Y=l.useCallback(async L=>{if(!(!s||!o?.workspace)){A(L.contentHash);try{const P=await U.rollbackHarness(s,{workspaceId:o.workspace.id,targetRelease:{id:L.id,contentHash:L.contentHash}});f(P.history),n(null),c?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(P){n(P instanceof Error?P.message:String(P))}finally{A(null)}}},[s,o?.workspace,n,c]),de=l.useCallback(async L=>{await S({title:"Roll back Harness release?",body:`New work will use ${Le(L.contentHash)}. Active runs remain pinned to their current release.`,confirmLabel:"Roll back"})&&await Y(L)},[S,Y]),re=l.useCallback(async(L,P)=>{if(!(!s||!await S({title:P==="activate"?"Activate Refiner release?":"Roll back Refiner release?",body:`Future reviews will use ${L.profile.name} at ${Le(L.contentHash)}. Existing work remains pinned.`,confirmLabel:P==="activate"?"Activate":"Roll back"}))){v(L.contentHash);try{const z={release:{id:L.id,contentHash:L.contentHash},reason:`${P==="activate"?"Activate":"Rollback"} from Settings to ${L.profile.id}@${L.profile.version}.`,actor:"settings-user"};g(await(P==="activate"?U.activateRefinerRelease(s,z):U.rollbackRefinerRelease(s,z))),n(null),c?.(`Refiner ${P==="activate"?"activated":"rolled back"}. Existing work remains pinned.`,"success")}catch(z){n(z instanceof Error?z.message:String(z))}finally{v(null)}}},[S,s,n,c]),oe=l.useCallback(async(L,P)=>{if(!(!s||!o?.workspace)){y(L.proposal.id);try{const H=await U.reviewHarnessProposal(s,{workspaceId:o.workspace.id,proposal:{id:L.proposal.id,contentHash:L.proposal.contentHash},decision:P});f(H.history),n(null),c?.(P==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",P==="approve"?"success":"info")}catch(H){n(H instanceof Error?H.message:String(H))}finally{y(null)}}},[s,o?.workspace,n,c]),K=o?.releases.find(L=>L.current)??o?.releases[0]??null,Q=K?o?.releases.indexOf(K)??-1:-1,ue=hi[m],ee=o?m==="refiner"?se!==o.backgroundReview.enabled:D!==W||o.evaluationReviewSchedule.enabled:!1,me=m==="refiner"||m==="continuous-review";return e.jsxs("section",{className:"account-settings harness-history-settings","aria-labelledby":"harness-history-title",children:[e.jsxs("div",{className:"account-settings-title harness-page-title",children:[e.jsxs("div",{children:[e.jsx("h1",{id:"harness-history-title",children:ue.title}),e.jsx("p",{children:ue.description})]}),o?.workspace&&me?e.jsxs("div",{className:"harness-page-header-actions",children:[m==="continuous-review"?e.jsx("button",{className:"settings-secondary compact",disabled:I,onClick:()=>{B(o.evaluationReviewSchedule.maxEstimatedCostUsd)},type:"button",children:I?"Reviewing…":"Review now"}):null,e.jsxs("label",{className:"harness-page-toggle",children:[e.jsx("span",{children:m==="refiner"?se?"On":"Off":D?"On":"Off"}),e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{"aria-label":m==="refiner"?"Enable Refiner":"Enable Continuous Review",checked:m==="refiner"?se:D,disabled:R,onChange:L=>m==="refiner"?X(L.target.checked):Z(L.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("button",{className:"settings-primary compact",disabled:R||!ee,onClick:()=>{le(m,se,D)},type:"button",children:R?"Applying…":"Apply changes"})]}):null]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&x&&!o?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,o&&!o.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,o?.workspace&&m==="overview"?e.jsx(fi,{history:o,onReviewProposal:oe,reviewingProposalId:$}):null,o&&p&&m==="refiner"?e.jsx(gi,{busyReleaseHash:j,history:o,refiner:p,onOpenChangeDiff:q,onOpenSourceSession:u,onRequestRefinerRelease:(L,P)=>{re(L,P)},onStartRefinerAuthoring:d}):null,o?.workspace&&m==="continuous-review"?e.jsx(oi,{acceptingReviewId:w,candidates:o.refinementCandidates,onAcceptTasksetReview:L=>{ie(L)},qualifications:o.modelImprovementQualifications,reviews:o.evaluationReviews,schedule:o.evaluationReviewSchedule??ui}):null,o?.workspace&&m==="contents"?e.jsx(vi,{history:o,onOpenCurrentRelease:()=>{K&&V(Q>=0?o.releases[Q+1]??null:null,K)}}):null,o?.workspace&&m==="releases"?e.jsx(bi,{busy:k!==null,history:o,onOpenDiff:V,onRequestRollback:L=>{de(L)}}):null,e.jsx(Qs,{onResolve:F,state:M})]})}function Ks(s){return s?s.slice(0,10):"initial"}function Ni({connection:s,expanded:t,onResizeStart:a,onToggleExpanded:n,selection:i}){const[r,u]=l.useState(null),[d,c]=l.useState(null),[m,o]=l.useState(!0),f=l.useCallback(async()=>{c(null),o(!0);try{u(await U.harnessReleaseDiff(s,i))}catch(j){u(null),c(j instanceof Error?j.message:String(j))}finally{o(!1)}},[s,i]);l.useEffect(()=>{f()},[f]);const p=l.useMemo(()=>r?{appId:`harness:${i.workspaceId}`,repoPath:i.title,initialized:!0,dirty:r.filesChanged>0,filesChanged:r.filesChanged,additions:r.additions,deletions:r.deletions,repoFiles:r.files.map(j=>j.path),files:r.files,error:null,updatedAt:""}:null,[r,i.title,i.workspaceId]),g=`${i.title} · ${Ks(i.baseRelease?.contentHash)} → ${Ks(i.targetRelease.contentHash)}`;return e.jsx(pn,{appId:`harness:${i.workspaceId}`,workspaceId:`harness:${i.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:p,editorPreferences:null,expanded:t,filesWithPreview:!0,loading:m,onOpenBrowserUrl:()=>{},onRefresh:f,onResizeStart:a,onToggleExpanded:n,readOnly:!0,workspaceError:d,workspaceInitialized:!0,workspaceName:g})}function wi({connection:s,onError:t,onPayload:a}){const[n,i]=l.useState(!1),[r,u]=l.useState(!1);async function d(f,p){if(s){i(!0),t(null);try{const g=await U.switchOpenPondAccount(s,{handle:f,baseUrl:p??null});a(g)}catch(g){t(g instanceof Error?g.message:String(g))}finally{i(!1)}}}async function c(f,p){if(!s)return!1;i(!0),t(null);try{const g=await U.removeOpenPondAccount(s,{handle:f,baseUrl:p??null});return a(g),!0}catch(g){return t(g instanceof Error?g.message:String(g)),!1}finally{i(!1)}}async function m(f){if(!(!s||!f.apiKey.trim())){i(!0),t(null);try{const p=f.handle?.trim(),g=f.environment?.trim(),j=await U.saveOpenPondAccount(s,{apiKey:f.apiKey.trim(),handle:p||void 0,baseUrl:f.baseUrl,apiBaseUrl:f.apiBaseUrl,environment:g||"custom",setActive:!0});a(j)}catch(p){throw t(p instanceof Error?p.message:String(p)),p}finally{i(!1)}}}async function o(){if(s){u(!0),t(null);try{a(await U.refreshOpenPondAccounts(s))}catch(f){t(f instanceof Error?f.message:String(f))}finally{u(!1)}}}return{refreshingAccounts:r,saving:n,refreshAccounts:o,removeAccount:c,saveAccount:m,switchAccount:d}}function Si({connection:s,onError:t,onPreferences:a,preferences:n,providers:i}){const[r,u]=l.useState(n.defaultBranchPrefix),[d,c]=l.useState(n.defaultNewProjectDirectory),[m,o]=l.useState(n.advancedWorkspaceControls),[f,p]=l.useState(n.steerActiveResponses),[g,j]=l.useState(n.contextCompaction.autoEnabled),[v,x]=l.useState(n.subagents.enabled),[N,k]=l.useState(n.subagents.delegationMode),[A,$]=l.useState(!n.subagents.defaultModelRef),[y,R]=l.useState(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),[O,I]=l.useState(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),[h,w]=l.useState(n.subagents.roles),[C,S]=l.useState(n.subagents.maxConcurrentRuns),[M,F]=l.useState(n.subagents.maxConcurrentRunsPerProvider),[W,se]=l.useState(n.subagents.maxConcurrentRunsPerWorkspaceTarget),[X,D]=l.useState(!1),Z=A?null:{providerId:y,modelId:O.trim()},te=v!==n.subagents.enabled||N!==n.subagents.delegationMode||!ki(Z,n.subagents.defaultModelRef)||C!==n.subagents.maxConcurrentRuns||M!==n.subagents.maxConcurrentRunsPerProvider||W!==n.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(h)!==JSON.stringify(n.subagents.roles);l.useEffect(()=>{u(n.defaultBranchPrefix),c(n.defaultNewProjectDirectory),o(n.advancedWorkspaceControls),p(n.steerActiveResponses),j(n.contextCompaction.autoEnabled),x(n.subagents.enabled),k(n.subagents.delegationMode),$(!n.subagents.defaultModelRef),R(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),I(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),w(n.subagents.roles),S(n.subagents.maxConcurrentRuns),F(n.subagents.maxConcurrentRunsPerProvider),se(n.subagents.maxConcurrentRunsPerWorkspaceTarget)},[n.defaultChatProvider,n.defaultChatModel,n.defaultBranchPrefix,n.defaultNewProjectDirectory,n.advancedWorkspaceControls,n.steerActiveResponses,n.contextCompaction.autoEnabled,n.subagents]);function B(P){R(P),I(H=>Gt(P,H,i))}function le(){return A?n.defaultChatProvider:y}function ie(){return A?n.defaultChatModel:O}function V(P,H){w(z=>z.map(ne=>ne.id===P?H(ne):ne))}function q(P,H){V(P,z=>({...z,enabled:H}))}function Y(P,H){V(P,z=>({...z,background:H}))}function de(P,H){V(P,z=>{if(H)return{...z,modelRef:null};const ne=z.modelRef?.providerId??le(),ce=z.modelRef?.modelId??ie();return{...z,modelRef:es(ne,ce,i)??null}})}function re(P,H){V(P,z=>({...z,modelRef:es(H,z.modelRef?.modelId??ie(),i)??null}))}function oe(P,H){V(P,z=>{const ne=z.modelRef?.providerId??le(),ce=H.trim();return{...z,modelRef:ce?{providerId:ne,modelId:ce}:null}})}function K(P,H){V(P,z=>({...z,isolationMode:H}))}function Q(P,H){V(P,z=>({...z,toolPolicy:H}))}function ue(P,H){V(P,z=>({...z,peerMessages:H}))}function ee(P,H){V(P,z=>({...z,maxConcurrentRuns:ke(H,1,16)}))}async function me(){let P=null;if(window.openpond?.selectFolder){const H=await window.openpond.selectFolder();if(H.canceled)return;P=H.path}else P=window.prompt("Default new project directory",d);P?.trim()&&c(P.trim())}async function L(P){if(P.preventDefault(),!!s){D(!0),t(null);try{a(await U.savePreferences(s,{defaultBranchPrefix:ls(r),defaultNewProjectDirectory:d.trim(),advancedWorkspaceControls:m,steerActiveResponses:f,contextCompaction:{...n.contextCompaction,autoEnabled:g},subagents:{enabled:v,workspaceDefaultsVersion:n.subagents.workspaceDefaultsVersion,toolDefaultsVersion:n.subagents.toolDefaultsVersion,delegationMode:N,defaultModelRef:A?null:es(y,O,i)??null,roles:h,maxConcurrentRuns:ke(C,1,32),maxConcurrentRunsPerProvider:M===null?null:ke(M,1,32),maxConcurrentRunsPerWorkspaceTarget:W===null?null:ke(W,1,32)}}))}catch(H){t(H instanceof Error?H.message:String(H))}finally{D(!1)}}}return{advancedWorkspaceControls:m,steerActiveResponses:f,contextCompactionAutoEnabled:g,defaultBranchPrefix:r,defaultNewProjectDirectory:d,subagentsEnabled:v,subagentDelegationMode:N,subagentsUseDefaultModel:A,subagentsProvider:y,subagentsModel:O,subagentRoles:h,subagentsMaxConcurrentRuns:C,subagentsMaxConcurrentRunsPerProvider:M,subagentsMaxConcurrentRunsPerWorkspaceTarget:W,subagentsDirty:te,saving:X,chooseDefaultProjectDirectory:me,saveDefaults:L,changeSubagentsProvider:B,changeSubagentRoleProvider:re,setAdvancedWorkspaceControls:o,setSteerActiveResponses:p,setContextCompactionAutoEnabled:j,setDefaultBranchPrefix:u,setDefaultNewProjectDirectory:c,setSubagentsUseDefaultModel:$,setSubagentsModel:I,setSubagentsEnabled:x,setSubagentDelegationMode:P=>k(P),setSubagentsMaxConcurrentRuns:P=>S(ke(P,1,32)),setSubagentsMaxConcurrentRunsPerProvider:P=>F(P===null?null:ke(P,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:P=>se(P===null?null:ke(P,1,32)),setSubagentRoleBackground:Y,setSubagentRoleEnabled:q,setSubagentRoleIsolationMode:K,setSubagentRoleMaxConcurrentRuns:ee,setSubagentRoleModel:oe,setSubagentRolePeerMessages:ue,setSubagentRoleToolPolicy:Q,setSubagentRoleUseDefaultModel:de}}function ke(s,t,a){return Number.isFinite(s)?Math.min(a,Math.max(t,Math.trunc(s))):t}function ki(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const Ci=15e3,Ri=100,Pi=100,Ai=2500;function Ii({onError:s,section:t}){const[a,n]=l.useState(null),[i,r]=l.useState(null),[u,d]=l.useState(Ri),[c,m]=l.useState([]),[o,f]=l.useState(null),[p,g]=l.useState(!0),j=l.useRef(null),[v,x]=l.useState(null),N=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),A=!!window.openpond?.readRecentLogs?`${c.length} of ${u} line${u===1?"":"s"}${p?" tailing":""}`:"Unavailable";l.useEffect(()=>{t==="diagnostics"&&$(u,"refresh",{quiet:!0})},[t]),l.useEffect(()=>{if(t!=="diagnostics"||!p||!window.openpond?.readRecentLogs)return;let w=!1;const C=window.setInterval(()=>{w||(w=!0,$(u,"refresh",{quiet:!0}).finally(()=>{w=!1}))},Ai);return()=>window.clearInterval(C)},[t,p,u]),l.useEffect(()=>{if(t!=="diagnostics"||!p)return;const w=j.current;w&&(w.scrollTop=w.scrollHeight)},[t,p,c]);async function $(w=u,C="refresh",S={}){const M=window.openpond?.readRecentLogs;if(!M){const F="Log view is not available in this runtime.";S.quiet||(x({label:"Logs",value:F,warning:!0}),s(F));return}S.quiet||r(C);try{const F=await qe(M(w),"Read logs");if(!F.ok)throw new Error(F.error);d(F.lineLimit),f(F.logDir),m(F.lines),S.quiet?x(W=>W?.label==="Logs"?null:W):x(null)}catch(F){const W=F instanceof Error?F.message:String(F);x({label:"Logs",value:W,warning:!0}),S.quiet||s(W)}finally{S.quiet||r(null)}}function y(){g(!1),$(u+Pi,"older")}function R(){const w=!p;g(w),w&&$(u,"refresh",{quiet:!0})}async function O(){const w=window.openpond?.openLogsFolder;if(!w){const C="Desktop logs are not available in this runtime.";x({label:"Logs",value:C,warning:!0}),s(C);return}n("logs"),s(null);try{const C=await qe(w(),"Open logs");if(!C.ok)throw new Error(C.error??"Could not open the logs folder.");x(null)}catch(C){const S=C instanceof Error?C.message:String(C);x({label:"Logs",value:S,warning:!0}),s(S)}finally{n(null)}}async function I(){const w=window.openpond?.copyRecentLogs;if(!w){const C="Recent log copy is not available in this runtime.";x({label:"Copy",value:C,warning:!0}),s(C);return}n("copy"),s(null);try{const C=await qe(w(1e3),"Copy recent logs");if(!C.ok)throw new Error(C.error??"Could not copy recent logs.");x({label:"Copy",value:C.lines?`Copied ${C.lines} recent log lines.`:"Copied recent logs."})}catch(C){const S=C instanceof Error?C.message:String(C);x({label:"Copy",value:S,warning:!0}),s(S)}finally{n(null)}}async function h(){const w=window.openpond?.exportDiagnostics;if(!w){const C="Diagnostics export is not available in this runtime.";x({label:"Export",value:C,warning:!0}),s(C);return}n("export"),s(null);try{const C=await qe(w(),"Export diagnostics");if(!C.ok)throw new Error(C.error??"Could not export diagnostics.");x({label:"Export",value:C.path?`Saved to ${C.path}`:"Diagnostics exported."})}catch(C){const S=C instanceof Error?C.message:String(C);x({label:"Export",value:S,warning:!0}),s(S)}finally{n(null)}}return{diagnosticsAvailable:N,diagnosticsBusy:a,diagnosticsStatus:v,logDir:o,logLineLimit:u,logLines:c,logViewBusy:i,logViewSummary:A,logViewportRef:j,tailLogs:p,copyRecentLogs:I,exportDiagnosticsBundle:h,loadOlderLogs:y,openLogsFolder:O,refreshLogView:$,toggleTailLogs:R}}async function qe(s,t){let a;try{return await Promise.race([s,new Promise((n,i)=>{a=window.setTimeout(()=>{i(new Error(`${t} did not receive a desktop response.`))},Ci)})])}finally{a!==void 0&&window.clearTimeout(a)}}function Ei({connection:s,enabled:t,onError:a,onPreferences:n,onToast:i,preferences:r}){const[u,d]=l.useState(r.editor),[c,m]=l.useState(null),[o,f]=l.useState(!1),[p,g]=l.useState(!1),[j,v]=l.useState(!1);l.useEffect(()=>{d(r.editor)},[r.editor]);const x=l.useCallback(async()=>{if(s){g(!0);try{m(await U.workspaceLspSettingsStatus(s))}catch(y){a(y instanceof Error?y.message:String(y))}finally{g(!1)}}},[s,a]);l.useEffect(()=>{!t||!s||x()},[s,t,x]);function N(y,R){d(O=>({...O,languages:{...O.languages,[y]:{...O.languages[y],mode:R}}}))}function k(y,R){d(O=>({...O,languages:{...O.languages,[y]:{...O.languages[y],customCommand:R}}}))}async function A(y){if(y.preventDefault(),!!s){f(!0),a(null);try{const R=await U.savePreferences(s,{editor:u});n(R),m(await U.workspaceLspSettingsStatus(s))}catch(R){a(R instanceof Error?R.message:String(R))}finally{f(!1)}}}async function $(){if(s){v(!0),a(null);try{await U.restartWorkspaceLsp(s),m(await U.workspaceLspSettingsStatus(s)),i?.("Language servers restarted.","success")}catch(y){a(y instanceof Error?y.message:String(y))}finally{v(!1)}}}return{editorPreferences:u,lspStatus:c,restarting:j,saving:o,statusLoading:p,refreshLspStatus:x,restartLanguageServers:$,saveEditorSettings:A,setEditorPreferences:d,setLanguageCustomCommand:k,setLanguageMode:N}}function $i({connection:s,onError:t,onPayload:a,personalization:n}){const i=l.useMemo(()=>n.templates.map(h=>({value:h.id,label:h.name,description:h.id===n.activeTemplateId?"Selected":h.source==="built_in"?h.description:void 0})),[n.activeTemplateId,n.templates]),[r,u]=l.useState(n.activeTemplateId),[d,c]=l.useState(n.soul),[m,o]=l.useState(""),[f,p]=l.useState(!1),[g,j]=l.useState(!1),v=n.templates.find(h=>h.id===r)??n.templates[0],x=v?.source==="custom",N=v?d!==v.content:!0,k=r!==n.activeTemplateId||d!==n.soul||N,A=!!(x&&d.trim()&&v&&k);l.useEffect(()=>{u(n.activeTemplateId),c(n.soul);const h=n.templates.find(w=>w.id===n.activeTemplateId);o(h?`${h.name} Copy`:""),p(!1)},[n.activeTemplateId,n.soul,n.templates]);async function $(h=!1){if(!h&&!x)return;const w=h?m:v?.name;if(!(!s||!d.trim()||!w?.trim())){j(!0),t(null);try{a(await U.savePersonalization(s,{activeTemplateId:r,templateName:w,soul:d,saveAsNew:h})),p(!1)}catch(C){t(C instanceof Error?C.message:String(C))}finally{j(!1)}}}async function y(h){const w=n.templates.find(C=>C.id===h);if(w&&(u(w.id),o(`${w.name} Copy`),c(w.content),p(!1),!!s)){j(!0),t(null);try{a(await U.savePersonalization(s,{activeTemplateId:w.id,templateName:w.name,soul:w.content,saveAsNew:!1}))}catch(C){t(C instanceof Error?C.message:String(C))}finally{j(!1)}}}function R(){v&&(o(`${v.name} Copy`),c(v.content),p(!1))}function O(h){c(h),v&&!x&&h!==v.content&&p(!0)}function I(){v&&(o(`${v.name} Copy`),p(!0))}return{canSaveCurrentTemplate:A,personalizationTemplateId:r,personalizationTemplateOptions:i,saveAsNewOpen:f,saving:g,selectedPersonalizationTemplate:v,selectedTemplateIsCustom:x,soulDraft:d,templateNameDraft:m,changePersonalizationTemplate:y,changeSoulDraft:O,openSaveAsNew:I,resetPersonalizationDraft:R,savePersonalization:$,setSaveAsNewOpen:p,setTemplateNameDraft:o}}function Di({connection:s,enabled:t,onError:a,onToast:n}){const[i,r]=l.useState(null),[u,d]=l.useState(null),[c,m]=l.useState(!1),o=l.useRef(null),f=l.useCallback(async(R={})=>{if(s){R.quiet||d("refresh");try{const O=await U.remoteAccess(s);r(O),a(null)}catch(O){a(O instanceof Error?O.message:String(O))}finally{R.quiet||d(null)}}},[s,a]);l.useEffect(()=>{!t||!s||f({quiet:!0})},[s,t,f]),l.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);function p(){o.current!==null&&window.clearTimeout(o.current),m(!1),window.setTimeout(()=>{m(!0),o.current=window.setTimeout(()=>{m(!1),o.current=null},1500)},0)}async function g(){if(a(null),!!s)try{r(await U.remoteAccess(s))}catch{}}async function j(){if(!s)return null;i&&!i.tailscale.running&&p(),d("enable");try{const R=await U.enableRemoteAccess(s);return r(R.status),a(null),R.status.tailscale.running?!R.status.serve.enabled&&R.status.serve.error&&n?.(R.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":R.message||R.status.serve.error,"error"):(p(),n?.(R.message||"Tailscale is not running. Run Tailscale up first.","error")),R.status}catch{return await g(),p(),n?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{d(null)}}async function v(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){d("disable");try{const R=await U.disableRemoteAccess(s);r(R.status),a(null)}catch{await g()}finally{d(null)}}}async function x(){i?.remoteWebUrl&&(d("copy-link"),await Ie(i.remoteWebUrl),d(null))}async function N(){i?.serveCommand&&(d("copy-command"),await Ie(i.serveCommand),d(null))}async function k(){i?.serve.setupUrl&&(d("copy-serve-setup"),await Ie(i.serve.setupUrl),d(null))}async function A(){i?.tailscaleUpCommand&&(d("copy-up-command"),await Ie(i.tailscaleUpCommand),d(null))}async function $(){i?.operatorCommand&&(d("copy-operator"),await Ie(i.operatorCommand),d(null))}async function y(){if(!i?.serve.enabled){const R=await j();R?.serve.enabled&&R.remoteWebUrl&&await Ie(R.remoteWebUrl);return}await x()}return{status:i,busy:u,flashTailscaleUp:c,refresh:f,enableRemoteAccess:j,disableRemoteAccess:v,copyRemoteLink:x,copyTailscaleUpCommand:A,copyServeCommand:N,copyServeSetupUrl:k,copyOperatorCommand:$,createRemoteLink:y}}function Ti(s){const[t,a]=l.useState(null),[n,i]=l.useState(null),r=l.useCallback(async()=>{if(s.connection){i("load");try{a(await U.datasetStorageState(s.connection)),s.onError(null)}catch(d){s.onError(d instanceof Error?d.message:String(d))}finally{i(null)}}},[s.connection,s.onError]),u=l.useCallback(async d=>{if(!s.connection||!d)return!1;i("save");try{return a(await U.updateDatasetStorage(s.connection,d)),s.onError(null),!0}catch(c){return s.onError(c instanceof Error?c.message:String(c)),!1}finally{i(null)}},[s.connection,s.onError]);return l.useEffect(()=>{s.enabled&&r()},[s.enabled,r]),{state:t,busy:n,refresh:r,save:u}}function Li(s){const{connection:t,enabled:a,onError:n,profileId:i}=s,[r,u]=l.useState(null),[d,c]=l.useState(!1),m=l.useCallback(async()=>{if(t){c(!0);try{u(await U.datasetCatalog(t,i)),n(null)}catch(o){n(Oi(o))}finally{c(!1)}}},[t,n,i]);return l.useEffect(()=>{a&&m()},[a,m]),{catalog:r,loading:d,refresh:m}}function Oi(s){return s instanceof Error?s.message:String(s)}const Ui=new Set(["harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases"]);function Mi(s){return s==="harness-refiner"?"refiner":s==="harness-continuous-review"?"continuous-review":s==="harness-contents"?"contents":s==="harness-releases"?"releases":"overview"}const zi=l.lazy(()=>vt(()=>import("./UsageSettingsSection-CrdcSGeW.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(s=>({default:s.UsageSettingsSection})));function ll({payload:s,connection:t,diagnostics:a,onPayload:n,onError:i,onToast:r,onBack:u,onOpenSourceSession:d,onStartRefinerAuthoring:c,onAcceptEvaluationReview:m,onOpenSkill:o,onOpenExtension:f,teamChatCurrentUserId:p,teamChatEnabled:g,teamChatNotificationMode:j,teamChatThreads:v,onTeamChatNotificationModeChange:x,onTeamChatThreadMuteChange:N,diffPanelWidth:k,diffPanelResizing:A,diffPanelExpanded:$,onDiffPanelResizeStart:y,onDiffPanelExpandedChange:R,initialSection:O="account"}){const[I,h]=l.useState(O),[w,C]=l.useState(null),[S,M]=l.useState(!1),F=s?.codex??null,W=l.useMemo(()=>Vt(s?.preferences),[s?.preferences]),se=s?.personalization??Kt,X=a??s?.diagnostics??[],D=Jt()&&Yt(t?.platform),Z=l.useCallback(ae=>{s&&n({...s,providers:ae})},[n,s]),te=l.useCallback(ae=>{s&&n({...s,preferences:ae.preferences})},[n,s]),B=l.useCallback(ae=>{s&&n({...s,extensionCatalog:ae})},[n,s]),le=wi({connection:t,onError:i,onPayload:n}),ie=sn({connection:t,onError:i,onPayload:n,onPreferences:te,onProviders:Z,preferences:W,providers:s?.providers??null}),V=Si({connection:t,onError:i,onPayload:n,onPreferences:te,preferences:W,providers:s?.providers??null}),q=Ei({connection:t,enabled:I==="editor",onError:i,onPayload:n,onPreferences:te,onToast:r,preferences:W}),Y=$i({connection:t,onError:i,onPayload:n,personalization:se}),de=Ii({onError:i,section:I}),re=Di({connection:t,enabled:I==="remote",onError:i,onToast:r}),oe=I==="dataset-storage",K=Ti({connection:t,enabled:oe,onError:i}),Q=Li({connection:t,enabled:oe,onError:i,profileId:s?.profile.activeProfile??"default"}),ue=K.save,ee=l.useCallback(async()=>{await Promise.all([K.refresh(),Q.refresh()])},[K.refresh,Q.refresh]),me=l.useCallback(()=>I!=="subagents"||!V.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[V.subagentsDirty,I]),L=l.useCallback(ae=>{ae!==I&&me()&&(M(!1),R(!1),h(ae),Qt({kind:"settings",section:ae}))},[me,R,I]),P=l.useCallback(()=>{me()&&(M(!1),R(!1),u())},[me,u,R]);l.useEffect(()=>{h(O)},[O]),l.useEffect(()=>{if(I!=="subagents"||!V.subagentsDirty)return;const ae=Ae=>{Ae.preventDefault(),Ae.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",ae),()=>window.removeEventListener("beforeunload",ae)},[V.subagentsDirty,I]);const H={"--diff-panel-width":`${k}px`},z=Ui.has(I),ne=z&&S&&w,ce=JSON.stringify([s?.profile.activeProfile,s?.account.activeProfile,s?.account.baseUrl,s?.account.apiBaseUrl,s?.account.profile?.id,s?.account.state,s?.preferences.defaultTeamId??null]);return e.jsxs("div",{className:`settings-shell ${D?"platform-macos":""} ${ne?"harness-diff-open":""} ${$?"harness-diff-expanded":""} ${A?"diff-panel-resizing":""}`,style:H,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[z?e.jsx("button",{type:"button",className:`topbar-diff-button ${ne?"active":""}`,title:`${ne?"Hide":"Show"} sidebar`,"aria-label":`${ne?"Hide":"Show"} sidebar`,"aria-pressed":!!ne,disabled:!w,onClick:()=>M(ae=>!ae),children:e.jsx(Xt,{size:16})}):null,e.jsx(Zt,{platform:t?.platform})]}),e.jsx(Ma,{section:I,onBack:P,onSectionChange:L}),e.jsxs("main",{className:`settings-content ${I==="profile"||z?"settings-content-wide":""}`,children:[I!=="configuration"?e.jsx(ys,{connection:t,bannerOnly:!0,onOpen:()=>L("configuration")}):null,I==="account"?e.jsx(En,{payload:s,connection:t,onPayload:n,onPreferences:te,onError:i,onToast:r,...le}):I==="ponder"?e.jsx(Rn,{connection:t},JSON.stringify([s?.account.activeProfile,s?.account.baseUrl,s?.account.profile?.id,s?.account.state,s?.preferences.defaultTeamId])):I==="notifications"?e.jsx(Yn,{currentUserId:p,enabled:g,mode:j,threads:v,onModeChange:x,onThreadMuteChange:N}):z?e.jsx(yi,{connection:t,enabled:z,onAcceptEvaluationReview:m,onError:i,onDefaultReleaseDiff:C,onOpenSourceSession:d,onStartRefinerAuthoring:c,onOpenReleaseDiff:ae=>{C(ae),M(!0)},onToast:r,page:Mi(I)}):I==="profile"?e.jsx(va,{payload:s,connection:t,onPayload:n,onError:i,onToast:r,onOpenSession:d}):I==="skills"?e.jsx(Ha,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:t,onExtensionCatalog:B,onError:i,onToast:r,onOpenSkill:o,onOpenExtension:f}):I==="providers"?e.jsx(tn,{onProvidersChanged:Z,connection:t,account:s?.account??null,codex:F,providers:s?.providers??null,...ie}):I==="dataset-storage"?e.jsx(Xa,{state:K.state,catalog:Q.catalog,busy:K.busy,catalogLoading:Q.loading,onRefresh:ee,onSave:ue}):I==="configuration"?e.jsxs("div",{className:"settings-stacked-sections configuration-page",children:[e.jsx(ys,{connection:t,onSaved:async()=>{t&&n(await U.bootstrap(t))}}),e.jsx(On,{preferences:W,...V}),e.jsx(Es,{embedded:!0,preferences:W,...V})]}):I==="context"?e.jsx(Es,{preferences:W,...V}):I==="training"?e.jsx(Ba,{connection:t,onError:i,onPreferences:te,preferences:W,providers:s?.providers??null}):I==="subagents"?e.jsx(_n,{preferences:W,providers:s?.providers??null,...V}):I==="editor"?e.jsx(Bn,{preferences:W,...q}):I==="remote"?e.jsxs(e.Fragment,{children:[e.jsx(Oa,{connection:t,onError:i},ce),e.jsxs("details",{children:[e.jsx("summary",{children:"Direct Tailscale access"}),e.jsx(Ia,{...re})]})]}):I==="usage"?e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(zi,{account:s?.account??null,connection:t,enabled:I==="usage",onError:i,onOpenSourceSession:d})}):I==="personalization"?e.jsx(Xn,{...Y}):e.jsx(Un,{diagnostics:X,...de})]}),z&&t&&ne?e.jsx(Ni,{connection:t,expanded:$,onResizeStart:y,onToggleExpanded:()=>R(!$),selection:ne}):null]})}export{ll as SettingsView};
4
+ `,expectedRevision:c??i.rawRevision};await ye(s,"/v1/configuration",{method:"POST",body:JSON.stringify(O)}),y!=="validate"&&(d(null),m(null),await I(),await n?.()),g(y==="validate"?"Configuration is valid.":"Saved. Changes apply to the next turn.")}catch(O){g(O instanceof Error?O.message:String(O))}finally{v(!1)}}}return!s||t&&!i?.issue&&!x?null:e.jsxs("section",{className:`account-settings configuration-settings ${t?"configuration-banner":""}`,"aria-label":"Configuration",children:[t?null:e.jsxs("header",{children:[e.jsx("h1",{children:"Configuration"}),e.jsx("p",{children:"Manage your settings in one TOML file. The controls below save to the same file; unset an override to inherit its default."})]}),x?e.jsxs("p",{role:"alert",children:[x," ",e.jsx("button",{type:"button",onClick:yt,children:"Retry saving preferences"})]}):null,i?.issue?e.jsxs("div",{role:"alert",children:[e.jsx("strong",{children:"Configuration needs attention"}),e.jsx("p",{children:i.issue.message}),e.jsx("p",{children:e.jsxs("code",{children:[i.issue.path,i.issue.line?`:${i.issue.line}:${i.issue.column??1}`:""]})}),e.jsxs("p",{children:[i.issue.action," Affected turns are blocked until this is corrected."]}),e.jsx("button",{type:"button",onClick:()=>{t?a?.():f(!0)},children:"Open configuration"})]}):null,t?null:e.jsxs("details",{open:o,onToggle:y=>f(y.currentTarget.open),children:[e.jsx("summary",{children:"Configuration file and sources"}),e.jsx("p",{children:e.jsx("code",{children:i?.path??"Loading…"})}),e.jsx("p",{children:"Unset an override to inherit its default. Changes apply to the next turn; current turns retain their model settings."}),e.jsx("textarea",{"aria-label":"TOML configuration",spellCheck:!1,rows:18,style:{width:"100%",fontFamily:"monospace"},value:u??i?.text??`schema_version = 1
5
+ `,onChange:y=>{u===null&&m(i?.rawRevision??null),d(y.target.value)}}),u!==null&&i?.rawRevision!==c?e.jsx("p",{role:"alert",children:"The file changed elsewhere. Reload before saving your edits."}):null,e.jsxs("div",{className:"configuration-actions",children:[e.jsx("button",{type:"button",disabled:j||!i,onClick:()=>{$("validate")},children:"Validate"}),e.jsx("button",{type:"button",disabled:j||!i||u!==null&&i.rawRevision!==c,onClick:()=>{$("replace")},children:"Save config"}),e.jsx("button",{type:"button",disabled:j,onClick:()=>{d(null),m(null),I().catch(y=>g(String(y)))},children:"Reload file"})]}),i?.recoverableRevisions.length?e.jsxs("label",{children:["Restore a verified revision ",e.jsxs("select",{value:"",disabled:j,onChange:y=>{y.target.value&&$("restore",y.target.value)},children:[e.jsx("option",{value:"",children:"Choose a revision…"}),i.recoverableRevisions.map(y=>e.jsxs("option",{value:y.revision,children:[new Date(y.createdAt).toLocaleString()," · ",y.revision.slice(0,12)]},y.revision))]})]}):null,i?.effective?e.jsxs("details",{children:[e.jsx("summary",{children:"Effective values and sources"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Setting"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Location"})]})}),e.jsx("tbody",{children:Object.entries(i.effective.provenance).map(([y,R])=>e.jsxs("tr",{children:[e.jsx("td",{children:JSON.parse(y).join(".")}),e.jsx("td",{children:R.layer==="user"?"Set here":`Inherited from ${R.layer}`}),e.jsx("td",{children:R.path})]},y))})]}),e.jsx("pre",{children:JSON.stringify(i.effective.document,null,2)})]}):null]}),p?e.jsx("p",{role:"status",children:p}):null]})}function Ns({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 Ss({state:s,label:t}){return e.jsx("span",{className:`account-state ${s}`,children:t??s.replace("_"," ")})}const Pn="https://www.openpond.ai",An="https://api.openpond.ai";function ws(s){try{const a=new URL(s).hostname.toLowerCase();if(a==="openpond.ai"||a==="www.openpond.ai")return An}catch{}return""}function ks(s,t){try{const a=new URL(s);if(a.protocol==="https:"||a.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(a.hostname))return null}catch{}return`${t} must be an https:// URL (or http:// for localhost).`}function Cs({account:s,busy:t,mode:a="update",onClose:n,onSave:i,onRemove:r}){const u=l.useId(),d=l.useRef(null),c=a==="connect",m=s?.baseUrl??Pn,o=s?.apiBaseUrl??ws(m),[f,p]=l.useState(m),[g,j]=l.useState(o),[v,x]=l.useState(""),[N,k]=l.useState(null),[I,$]=l.useState(null);us(I);function y(A){p(A),j(A.trim().replace(/\/+$/,"")===m?o:ws(A))}async function R(A){A.preventDefault(),k(null),$(null);const h=v.trim(),S=f.trim().replace(/\/+$/,""),C=g.trim().replace(/\/+$/,""),w=(c&&!h?"API key is required.":null)??ks(S,"Environment URL")??ks(C,"API URL");if(w){k(w),(w.startsWith("Environment URL")||w.startsWith("API URL"))&&d.current&&(d.current.open=!0);return}try{await i({handle:c?void 0:s?.handle,currentBaseUrl:c?null:s?.baseUrl??null,baseUrl:S,apiBaseUrl:C,chatApiBaseUrl:c||C!==o?null:s?.chatApiBaseUrl,apiKey:h||void 0,environment:new URL(S).hostname.replace(/^www\./,"")==="openpond.ai"?"production":"custom"})}catch(M){$(M instanceof Error?M.message:String(M))}}async function O(){r&&await r()&&n()}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:A=>{A.target===A.currentTarget&&!t&&n()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":u,onSubmit:A=>{R(A)},children:[e.jsx("button",{className:"git-dialog-close",disabled:t,type:"button",title:"Close","aria-label":"Close",onClick:n,children:e.jsx(pe,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:c?e.jsx(en,{size:18}):e.jsx(hs,{size:18})}),e.jsx("h2",{id:u,children:c?"Add account":"Account settings"}),e.jsx("p",{children:c?"Connect an OpenPond account with an API key.":"Review this account and its verified key access."}),!c&&s?e.jsxs("div",{className:"account-dialog-details",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Account"}),e.jsx("strong",{children:s.displayLabel||s.handle})]}),s.email?e.jsxs("div",{children:[e.jsx("span",{children:"Email"}),e.jsx("strong",{children:s.email})]}):null,e.jsxs("div",{children:[e.jsx("span",{children:"Handle"}),e.jsx("strong",{children:s.handle})]}),e.jsxs("div",{children:[e.jsx("span",{children:"API key"}),e.jsx("strong",{children:s.apiKeyHint??(s.authHealth==="signed_in"?"Connected with a session":"No saved API key")})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Access"}),e.jsx("strong",{children:s.apiKeyAccess?s.apiKeyAccess.teamId?"This workspace":s.apiKeyAccess.ownerType==="user"?"All my workspaces":"Account access":"Not verified"})]}),s.apiKeyAccess?e.jsxs("div",{children:[e.jsx("span",{children:"Scopes"}),e.jsx("strong",{children:s.apiKeyAccess.scopes.join(", ")||"No scopes"})]}):null]}):null,c?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoComplete:"off",disabled:t,placeholder:"opk_...",type:"password",value:v,onChange:A=>x(A.target.value)})]}):null,e.jsxs("details",{className:"account-dialog-advanced",ref:d,children:[e.jsx("summary",{children:"Advanced"}),e.jsxs("div",{className:"account-dialog-advanced-fields",children:[c?null:e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Replace API key"}),e.jsx("input",{autoComplete:"off",disabled:t,placeholder:"Leave blank to keep the current key",type:"password",value:v,onChange:A=>x(A.target.value)}),e.jsx("small",{children:"Enter a new key to replace the saved credential."})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Environment URL"}),e.jsx("input",{disabled:t,inputMode:"url",spellCheck:!1,type:"url",value:f,onChange:A=>y(A.target.value)}),e.jsx("small",{children:"Change this URL to connect this account to another environment."})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API URL"}),e.jsx("input",{disabled:t,inputMode:"url",spellCheck:!1,type:"url",value:g,onChange:A=>j(A.target.value)}),e.jsx("small",{children:"Enter the API URL for a custom environment."})]})]})]}),N?e.jsx("div",{className:"profile-dialog-warning",children:N}):null,e.jsx("div",{className:"git-dialog-footer account-dialog-footer",children:e.jsxs("div",{className:"account-dialog-save-actions",children:[!c&&r?e.jsxs("button",{className:"git-dialog-secondary account-dialog-remove",disabled:t,type:"button",onClick:()=>{O()},children:[e.jsx(Qe,{size:14})," Remove account"]}):null,e.jsx("button",{className:"git-dialog-secondary",disabled:t,type:"button",onClick:n,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:t,type:"submit",children:[e.jsx(tt,{size:14}),e.jsx("span",{children:t?"Saving":c?"Connect account":"Save changes"})]})]})})]})})}const In="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 En({payload:s,connection:t,saving:a,refreshingAccounts:n,saveAccount:i,refreshAccounts:r,switchAccount:u,removeAccount:d,onPayload:c,onPreferences:m,onError:o,onToast:f}){const p=s?.account,g=p?.state??"loading",j=g==="signed_in",v=g==="signed_out",x=g==="auth_error",N=p?.email?.trim()||null,k=p?.accounts??[],[I,$]=l.useState([]),[,y]=l.useState(!1),[R,O]=l.useState(null),[A,h]=l.useState(!1),[S,C]=l.useState(void 0),w=l.useRef(0),[M,F]=l.useState(null),[W,se]=l.useState(!1),[X,D]=l.useState(null),[Z,te]=l.useState(null),[B,le]=l.useState(!1),{confirmAction:ie,confirmDialog:V,resolveConfirmDialog:q}=Ys(),Y=k.find(L=>L.isActive)??k[0]??null,ue=s?.preferences.defaultTeamId?.trim()||null,re=S===void 0?ue:S,oe=Nt(p),K=s?.accountMeta.asOf??"",Q=we(p?.environment,Y?.environment),he=j?we(Y?.displayLabel,Y?.handle,p?.label,p?.activeProfile?.handle,"Signed in"):x?"Account needs attention":v?"No account connected":"Loading account",ee=j?N??Rs(Y?.baseUrl??p?.baseUrl,Q):x?"Not connected":v?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",me=k.length>0,T=x?$n(p?.error):null,P=l.useMemo(()=>I.filter(L=>L.status==="active"),[I]),H=l.useMemo(()=>{const L=[{value:"",label:"Personal account",description:"Your personal tasks and computers"},...P.map(G=>({value:G.teamId,label:we(G.displayName,G.name,G.slug,"Team"),description:St(G.role)}))];return re&&!L.some(G=>G.value===re)&&L.push({value:re,label:"Selected workspace",description:re}),L},[P,re]),z=re??"",ne=!t||A,ce=M?ss(M):null,ae=!!(ce&&X===ce),Ae=j||x,Oe=we(Z?.version,s?.server.version,"Loading"),b=Z?Z.devMode?"Dev mode":Z.packaged?`${Tn(Z.releaseChannel)} build`:"Local build":null,E=Dn(we(Y?.baseUrl,p?.activeProfile?.baseUrl,p?.baseUrl,"https://openpond.ai"));l.useEffect(()=>{const L=window.openpond?.getDesktopRuntimeInfo;if(!L)return;let G=!1;return L().then(J=>{G||te(J)}).catch(()=>{G||te(null)}),()=>{G=!0}},[]),l.useEffect(()=>{if(!t||!oe){$([]),O(null),y(!1);return}let L=!1;const G=wt(oe);return G?($(G),y(!1)):($([]),y(!0)),O(null),kt({accountKey:oe,force:!!K,fetchOrganizations:async()=>(await U.organizations(t)).organizations.map(Qs).filter(ge=>!!ge).filter(ge=>ge.status==="active")}).then(J=>{L||$(J)}).catch(J=>{L||(G||$([]),O(J instanceof Error?J.message:String(J)))}).finally(()=>{L||y(!1)}),()=>{L=!0}},[K,t,oe]),l.useEffect(()=>(++w.current,C(void 0),h(!1),()=>{++w.current}),[t,oe]),l.useEffect(()=>{S!==void 0&&ue===S&&C(void 0)},[ue,S]);async function _(L,G={notify:!0}){const J=L||null,ge=P.find(xe=>xe.teamId===J)??null;if(!t||J!==null&&!ge||A||re===J)return;C(J),h(!0);const Ue=w.current;o(null),J&&Rt({teamId:J,accountKey:oe,force:!0,fetchAgents:async xe=>(await U.listSandboxAgents(t,{teamId:xe})).agents}).catch(()=>{});try{const xe=await U.savePreferences(t,{defaultTeamId:J});if(Ue!==w.current)return;m(xe),G.notify&&f?.(J?"Workspace selected":"Personal account selected","success")}catch(xe){if(Ue!==w.current)return;C(void 0),o(xe instanceof Error?xe.message:String(xe))}finally{Ue===w.current&&h(!1)}}async function fe(L="Continue"){return Ae?ie({title:"Change active OpenPond account?",body:In,confirmLabel:L,cancelLabel:"Cancel"}):!0}async function Xe(L){await fe("Save account")&&(await i({apiKey:L.apiKey??"",handle:L.handle,baseUrl:L.baseUrl,apiBaseUrl:L.apiBaseUrl,environment:L.environment}),se(!1))}async function ft(L){if(!t||!M)throw new Error("OpenPond server connection is not ready.");if(M.isActive&&!await fe("Save endpoints"))return;const G=ss(M);D(G),o(null);try{const J=await U.updateOpenPondAccountConfig(t,{handle:L.handle??M.handle,currentBaseUrl:L.currentBaseUrl,apiKey:L.apiKey,baseUrl:L.baseUrl,apiBaseUrl:L.apiBaseUrl,chatApiBaseUrl:L.chatApiBaseUrl,environment:L.environment,setActive:M.isActive});c(J),f?.("Account updated","success"),F(null)}catch(J){throw o(J instanceof Error?J.message:String(J)),J}finally{D(null)}}async function gt(L){const G=L.handle?.trim()||"";G&&await fe("Switch account")&&await u(G,L.baseUrl)}async function xt(L){const G=L.handle?.trim()||"";if(!G)return!1;const J=we(L.displayLabel,L.email,L.handle,"this account");return await ie({title:"Remove saved account?",body:`Remove ${J} from this device? Its saved credential and endpoint settings will be deleted. This does not delete any OpenPond cloud data.`,confirmLabel:"Remove account",cancelLabel:"Cancel",tone:"danger"})&&await d(G,L.baseUrl)?(f?.("Account removed","success"),!0):!1}async function jt(){const L=window.openpond?.reloadDesktopApp;if(!(!L||B)){le(!0),o(null);try{const G=await L();if(!G.ok)throw new Error(G.error??"OpenPond could not refresh the app.")}catch(G){le(!1),o(G instanceof Error?G.message:String(G))}}}async function vt(){const L=window.openpond?.browser;L?.openExternal&&(await L.openExternal({conversationId:"openpond-account-sign-up",url:E})).ok||window.open(E,"_blank","noopener,noreferrer")}return e.jsxs("section",{className:"account-settings",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsx("h1",{children:"Account"}),e.jsxs("div",{className:"account-settings-title-actions",children:[e.jsxs("button",{className:"settings-secondary compact account-add-action",disabled:!t||a,type:"button",onClick:()=>se(!0),children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Add account"})]}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!t||a||n,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{r()},children:e.jsx(de,{size:15,className:n?"settings-spin":void 0})})]})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(Ns,{handle:he,image:j?p?.avatarUrl??Y?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:he}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:j&&N?"private-account-email":j?void 0:"account-summary-copy",tabIndex:j&&N?0:void 0,children:ee}),j?e.jsx(Ve,{className:"account-team-dropdown",compact:!0,disabled:ne,label:"Workspace",options:H,value:z,onChange:L=>{_(L)}}):null,j&&R?e.jsx("small",{role:"status",children:"Workspaces could not be loaded. Personal access remains available."}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(Ss,{state:g,label:v?"not signed in":void 0})})]}),me?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:[k.length," account",k.length===1?"":"s"]})]}),k.map(L=>{const G=L.handle?.trim()||"",J=we(L.displayLabel,L.handle,"Unknown account"),ge=L.email?.trim()||null,Ue=ss(L);return e.jsxs("div",{className:"account-row",children:[e.jsx(Ns,{handle:J,image:L.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:J}),ge?e.jsx("span",{className:"private-account-email",tabIndex:0,children:ge}):null,e.jsx("span",{children:Rs(L.baseUrl,L.environment)}),L.apiKeyHint?e.jsxs("span",{children:["API key ",L.apiKeyHint]}):null]}),e.jsxs("div",{className:"account-row-actions",children:[L.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,L.isActive?null:e.jsx("button",{className:"inline-action",disabled:a||!G,type:"button",onClick:()=>{gt(L)},children:"Use"}),e.jsx("button",{className:"settings-icon-button ghost account-endpoint-action",disabled:!t||a||!!X||!G,type:"button","aria-label":`Settings for ${J}`,title:"Account settings",onClick:()=>F(L),children:e.jsx(hs,{size:15})})]})]},Ue)})]}):null,p?.products&&p.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:[p.products.length," active"]})]}),p.products.map(L=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:L.name}),e.jsx("span",{children:L.type})]}),e.jsx(Ss,{state:L.status})]},L.id))]}),e.jsxs("div",{className:"settings-footnote account-build-footnote",children:[e.jsxs("div",{className:"account-build-details",children:[e.jsx("span",{children:"Build version"}),e.jsxs("div",{className:"account-build-version",children:[e.jsx("strong",{children:Ln(Oe)}),b?e.jsx("span",{className:`account-build-context${Z?.devMode?" development":""}`,children:b}):null]})]}),e.jsxs("div",{className:"account-build-actions",children:[Z?.canReload?e.jsxs("button",{className:"settings-secondary compact",disabled:B,type:"button",title:"Reload the local Electron app",onClick:()=>{jt()},children:[e.jsx(de,{className:B?"settings-spin":void 0,size:14}),e.jsx("span",{children:B?"Refreshing":"Refresh app"})]}):null,j?null:e.jsxs("button",{className:"settings-primary compact account-sign-up-action",type:"button",onClick:()=>{vt()},children:[e.jsx("span",{children:"Sign up"}),e.jsx(Ct,{size:13})]})]})]}),T?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:T})]}):null,M?e.jsx(Cs,{account:M,busy:ae||a,onClose:()=>{ae||F(null)},onSave:ft,onRemove:()=>xt(M)},ce):null,W?e.jsx(Cs,{busy:a,mode:"connect",onClose:()=>{a||se(!1)},onSave:Xe}):null,e.jsx(Xs,{state:V,onResolve:q})]})}function ss(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function we(...s){for(const t of s){const a=t?.trim();if(a)return a}return""}function $n(s){const t=s?.trim();if(!t)return null;const a=t.toLowerCase();return a.includes("protected deployment")?"OpenPond could not reach the account service. Restart and try again.":a.includes("unexpected token '<'")||a.includes("<!doctype")?"OpenPond received a web login page instead of account data. Restart and try again.":a.includes("401")||a.includes("unauthorized")||a.includes("could not authenticate")?"The API key could not authenticate. Check the key and account environment, then try again.":t.length>220?`${t.slice(0,217)}...`:t}function Rs(s,t){try{if(s)return new URL(s).host}catch{}return t?.trim()||"openpond.ai"}function Dn(s){try{return new URL("/login",s).toString()}catch{return"https://openpond.ai/login"}}function Ln(s){const t=s.trim();return!t||t==="Loading"?"Loading":t.startsWith("v")?t:`v${t}`}function Tn(s){return s&&`${s[0].toUpperCase()}${s.slice(1)}`}function On({advancedWorkspaceControls:s,defaultBranchPrefix:t,defaultNewProjectDirectory:a,preferences:n,saving:i,steerActiveResponses:r,chooseDefaultProjectDirectory:u,saveDefaults:d,setAdvancedWorkspaceControls:c,setSteerActiveResponses:m,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:f}){const p=ls(t)===n.defaultBranchPrefix&&a.trim()===n.defaultNewProjectDirectory&&s===n.advancedWorkspaceControls&&r===n.steerActiveResponses;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h2",{children:"General"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:g=>{d(g)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:r,disabled:i,onChange:g=>m(g.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Steer active responses"}),e.jsx("small",{children:"Send a new message into the active response immediately. Turn this off to queue it instead."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:i,onChange:g=>c(g.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:i,placeholder:"feat/",onChange:g=>o(g.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:i,placeholder:"~/Documents/OpenPond Projects",onChange:g=>f(g.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i,onClick:()=>{u()},children:[e.jsx(at,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:i||p,children:e.jsx("span",{children:i?"Saving":"Save settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[ls(t),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||n.defaultNewProjectDirectory})]})]})}function Un({diagnostics:s,diagnosticsAvailable:t,diagnosticsBusy:a,diagnosticsStatus:n,logDir:i,logLineLimit:r,logLines:u,logViewBusy:d,logViewSummary:c,logViewportRef:m,tailLogs:o,copyRecentLogs:f,exportDiagnosticsBundle:p,loadOlderLogs:g,openLogsFolder:j,refreshLogView:v,toggleTailLogs:x}){const N=s.filter(I=>I.name==="diagnostic"&&I.status==="failed").slice().reverse().map(Mn),k=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:[N.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:N.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):N.map(I=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Pt,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:I.message}),e.jsx("time",{dateTime:I.timestamp,children:I.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:I.surface}),I.status?e.jsx("span",{children:I.status}):null,I.sequence?e.jsxs("span",{children:["#",I.sequence]}):null]}),I.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:I.detail})]}):null]})]},I.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||!k?.openLogsFolder,onClick:()=>{j()},children:[e.jsx(at,{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||!k?.exportDiagnostics,onClick:()=>{p()},children:[e.jsx(At,{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||!k?.copyRecentLogs,onClick:()=>{f()},children:[e.jsx(gn,{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:c}),e.jsx("button",{type:"button",className:`settings-icon-button ${o?"active":""}`,title:o?"Pause tail":"Tail logs","aria-label":o?"Pause tail":"Tail logs",disabled:!k?.readRecentLogs,onClick:x,children:o?e.jsx(nt,{size:15}):e.jsx(it,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:d!==null||!k?.readRecentLogs,onClick:()=>{v(r,"refresh")},children:e.jsx(de,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:d!==null||!k?.readRecentLogs,onClick:g,children:[e.jsx(nn,{size:15}),e.jsx("span",{children:d==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:m,className:"diagnostics-log-viewer",role:"log","aria-live":o?"polite":"off",children:u.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:d?"Loading logs":"No log lines"}):u.map((I,$)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:I.file}),e.jsx("code",{children:I.line})]},`${I.file}:${I.timestamp}:${I.index}:${$}`))}),i&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:i})]})]}),n&&e.jsxs("div",{className:`settings-footnote ${n.warning?"warning":""}`,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:n.value})]})]})}function Mn(s){const t=Ps(s.data),a=Ps(t.context),i=be(t.stack)??be(t.detail)??be(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:Hn(s.timestamp),message:zn(s,t),surface:be(t.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:i}}function zn(s,t){return be(s.error)??be(s.output)??be(t.message)??be(t.error)??"Diagnostic event"}function Hn(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Ps(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function be(s){return typeof s=="string"&&s.trim()?s.trim():null}const As=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function Bn({editorPreferences:s,lspStatus:t,preferences:a,restarting:n,saving:i,statusLoading:r,refreshLspStatus:u,restartLanguageServers:d,saveEditorSettings:c,setEditorPreferences:m,setLanguageCustomCommand:o,setLanguageMode:f}){const p=JSON.stringify(s)!==JSON.stringify(a.editor),g=new Map(t?.languages.map(j=>[j.language,j])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:j=>{c(j)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Language servers"}),e.jsx("small",{children:"Local tools"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Language servers"}),e.jsx(Ve,{value:s.languageServers,disabled:i,label:"Language servers",options:It,onChange:j=>m(v=>({...v,languageServers:j}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:i||s.languageServers==="off",onChange:j=>m(v=>({...v,diagnosticsWhileEditing:j.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Diagnostics while editing"}),e.jsx("small",{children:"Update Monaco markers as the local buffer changes."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.checkOnSave,disabled:i||s.languageServers==="off",onChange:j=>m(v=>({...v,checkOnSave:j.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Check on save"}),e.jsx("small",{children:"Refresh diagnostics after writing a file."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Languages"}),e.jsx("small",{children:"Auto, disabled, or custom executable"})]}),e.jsx("div",{className:"lsp-language-list",children:As.map(j=>{const v=s.languages[j.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:j.label}),e.jsx("span",{children:Is(g.get(j.id),r)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Ve,{value:v.mode,disabled:i||s.languageServers==="off",label:`${j.label} language server mode`,options:Et,onChange:x=>f(j.id,x)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:v.customCommand,disabled:i||s.languageServers==="off"||v.mode!=="custom",placeholder:j.placeholder,onChange:x=>o(j.id,x.target.value)})]})]},j.id)})}),e.jsx("button",{className:"settings-primary",disabled:i||!p,children:e.jsx("span",{children:i?"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:r?"Checking":t?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:r||n,onClick:()=>{u()},children:e.jsx(de,{className:r?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:r||n,onClick:()=>{d()},children:[e.jsx(Sn,{className:n?"settings-spin":void 0,size:15}),e.jsx("span",{children:n?"Restarting":"Restart"})]})]})]}),As.map(j=>{const v=g.get(j.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:j.label}),e.jsx("span",{title:v?.command??v?.message??void 0,children:v?.command??v?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${v?.status??"missing"}`,children:Is(v,r)})]},j.id)})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Project config"}),e.jsx("strong",{children:"Uses tsconfig, pyrightconfig, pyproject, and Cargo files when present"})]})]})}function Is(s,t){return t&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function Es({contextCompactionAutoEnabled:s,embedded:t=!1,preferences:a,saving:n,saveDefaults:i,setContextCompactionAutoEnabled:r}){return e.jsxs("section",{className:`account-settings${t?" account-settings-embedded":""}`,children:[t?e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Context"}),e.jsx("small",{children:"Compaction defaults for long chats"})]}):e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:u=>{i(u)},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:n,onChange:u=>r(u.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:n||s===a.contextCompaction.autoEnabled,children:e.jsx("span",{children:n?"Saving":"Save context"})})]})]})}function _n({subagentsEnabled:s,subagentDelegationMode:t,subagentsUseDefaultModel:a,subagentsProvider:n,subagentsModel:i,subagentRoles:r,subagentsMaxConcurrentRuns:u,subagentsMaxConcurrentRunsPerProvider:d,subagentsMaxConcurrentRunsPerWorkspaceTarget:c,preferences:m,providers:o,saving:f,saveDefaults:p,changeSubagentsProvider:g,setSubagentsEnabled:j,setSubagentDelegationMode:v,setSubagentsUseDefaultModel:x,setSubagentsModel:N,setSubagentsMaxConcurrentRuns:k,setSubagentsMaxConcurrentRunsPerProvider:I,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:$,setSubagentRoleEnabled:y,setSubagentRoleIsolationMode:R,setSubagentRoleMaxConcurrentRuns:O,setSubagentRoleModel:A,setSubagentRolePeerMessages:h,setSubagentRoleToolPolicy:S,changeSubagentRoleProvider:C}){const w=Zs(o,{enabledOnly:!0}),M=a?m.defaultChatProvider:n,F=a?m.defaultChatModel:i,W=ct(ms(M,o),F),se=a?null:{providerId:n,modelId:i.trim()},X=Vn({enabled:s,delegationMode:t,defaultModelRef:se,roles:r,maxConcurrentRuns:u,maxConcurrentRunsPerProvider:d,maxConcurrentRunsPerWorkspaceTarget:c},m);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:D=>{p(D)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Agents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${X?"":" dirty"}`,disabled:f||X,children:e.jsx("span",{children:f?"Saving":"Save agents"})}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":"Allow subagents",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:f,onChange:D=>j(D.target.checked)}),e.jsx("span",{})]})]})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Default delegation"}),e.jsx("small",{children:"Used unless a task overrides it from the composer."})]})}),e.jsx("div",{className:"subagent-field-grid two",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Subagent use"}),e.jsxs("select",{value:t,disabled:f||!s,onChange:D=>v(D.target.value),children:[e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"balanced",children:"Balanced"}),e.jsx("option",{value:"proactive",children:"Proactive"})]})]})})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsx("div",{children:e.jsx("span",{children:"Default model"})})}),e.jsxs("div",{className:"subagent-field-grid two",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Provider"}),e.jsx("select",{value:M,disabled:f||!s,onChange:D=>{x(!1),g(D.target.value)},children:w.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:F,disabled:f||!s,onChange:D=>{x(!1),N(D.target.value)},children:W.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:r.map(D=>{const Z=$t.find(q=>q.id===D.id),te=D.modelRef?.providerId??M,B=D.modelRef?.modelId||Dt(te,o)||F,le=Gn(w,o,{providerId:te,modelId:B}),ie=Ge(te,B),V=f||!s||!D.enabled;return e.jsxs("section",{className:`subagent-role-row${D.enabled?"":" disabled"}`,children:[e.jsxs("div",{className:"subagent-settings-card-header subagent-role-header",children:[e.jsxs("div",{className:"subagent-role-title",children:[e.jsx("span",{children:Z?.label??D.id}),e.jsx("small",{children:Z?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${Z?.label??D.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:D.enabled,disabled:f||!s,onChange:q=>y(D.id,q.target.checked)}),e.jsx("span",{})]})]}),e.jsxs("div",{className:"subagent-role-controls",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:ie,disabled:V,onChange:q=>{const Y=le.find(ue=>ue.value===q.target.value);Y&&(C(D.id,Y.providerId),A(D.id,Y.modelId))},children:le.map(q=>e.jsx("option",{value:q.value,children:q.label},q.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:D.isolationMode,disabled:V,onChange:q=>R(D.id,q.target.value),children:Fn.map(q=>e.jsx("option",{value:q.value,children:q.label},q.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:D.toolPolicy,disabled:V,onChange:q=>S(D.id,q.target.value),children:Wn.map(q=>e.jsx("option",{value:q.value,children:q.label},q.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:D.peerMessages,disabled:V,onChange:q=>h(D.id,q.target.value),children:qn.map(q=>e.jsx("option",{value:q.value,children:q.label},q.value))})]})]}),e.jsx("div",{className:"subagent-role-budget-grid",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Role concurrency"}),e.jsx("input",{type:"number",min:1,max:16,value:D.maxConcurrentRuns,disabled:V,onChange:q=>O(D.id,$s(q.target.value,1))})]})})]},D.id)})}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Limits"}),e.jsx("small",{children:"Controls child worker concurrency."})]})}),e.jsxs("div",{className:"subagent-field-grid four",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Total concurrency"}),e.jsx("input",{type:"number",min:1,max:32,value:u,disabled:f||!s,onChange:D=>k($s(D.target.value,1))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per provider"}),e.jsx("input",{type:"number",min:1,max:32,value:d??"",placeholder:"No cap",disabled:f||!s,onChange:D=>I(ds(D.target.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per workspace"}),e.jsx("input",{type:"number",min:1,max:32,value:c??"",placeholder:"No cap",disabled:f||!s,onChange:D=>$(ds(D.target.value))})]})]})]})]})})}const Fn=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],Wn=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],qn=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function ct(s,t){const a=t.trim();return!a||s.some(n=>n.value===a)?s:[{value:a,label:a},...s]}function Ge(s,t){return JSON.stringify([s,t])}function Gn(s,t,a){const n=[];for(const i of s){const r=ct(ms(i.value,t),i.value===a.providerId?a.modelId:"");for(const u of r)n.push({value:Ge(i.value,u.value),label:`${i.label} / ${u.label}`,providerId:i.value,modelId:u.value})}return a.modelId&&!n.some(i=>i.value===Ge(a.providerId,a.modelId))&&n.unshift({value:Ge(a.providerId,a.modelId),label:`${rs(a.providerId,t)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),n}function ds(s){const t=s.trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function $s(s,t){return ds(s)??t}function Vn(s,t){const a=t.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&Kn(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 Kn(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const Jn=[{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 Yn({currentUserId:s,enabled:t,mode:a,threads:n,onModeChange:i,onThreadMuteChange:r}){const[u,d]=l.useState(null),[c,m]=l.useState(null);us(c);const o=l.useMemo(()=>n.filter(g=>g.archivedAt===null).map(g=>({thread:g,label:Qn(g,s)})).sort((g,j)=>{const v=+!!j.thread.mutedAt-+!!g.thread.mutedAt;return v!==0?v:g.label.localeCompare(j.label)}),[s,n]),f=o.filter(({thread:g})=>!!g.mutedAt).length,p=l.useCallback(async g=>{d(g.id),m(null),await r(g.id,!g.mutedAt)||m("Could not update this conversation. Try again."),d(null)},[r]);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:Jn.map(g=>e.jsxs("label",{className:`notification-mode-option${a===g.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===g.mode,onChange:()=>i(g.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:g.label}),e.jsx("small",{children:g.detail})]})]},g.mode))})]}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Conversation overrides"}),e.jsx("small",{children:f===1?"1 muted":`${f} muted`})]}),t?o.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):o.map(({thread:g,label:j})=>{const v=!!g.mutedAt,x=u===g.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${v?" muted":""}`,children:v?e.jsx(on,{size:15}):e.jsx(lt,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:j}),e.jsx("small",{children:v?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:u!==null,onClick:()=>{p(g)},children:x?"Saving":v?"Unmute":"Mute"})]},g.id)}):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Connect a team to manage conversation overrides."})})]}),e.jsx("div",{className:"settings-footnote",children:e.jsx("span",{children:"Muted conversations never show alerts. Unread counts remain available."})})]})}function Qn(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 Xn({canSaveCurrentTemplate:s,personalizationTemplateId:t,personalizationTemplateOptions:a,saveAsNewOpen:n,saving:i,selectedPersonalizationTemplate:r,selectedTemplateIsCustom:u,soulDraft:d,templateNameDraft:c,changePersonalizationTemplate:m,changeSoulDraft:o,openSaveAsNew:f,resetPersonalizationDraft:p,savePersonalization:g,setSaveAsNewOpen:j,setTemplateNameDraft:v}){function x(N){N.preventDefault(),g(n)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:x,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:c,onChange:N=>v(N.target.value),placeholder:"Name","aria-label":"Template name"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Cancel","aria-label":"Cancel",disabled:i,onClick:()=>j(!1),children:e.jsx(pe,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:i||!d.trim()||!c.trim(),onClick:()=>{g(!0)},children:e.jsx(ps,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:u?"Custom template":"Built-in template"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Save as new","aria-label":"Save as new",disabled:i||!r||!d.trim(),onClick:f,children:e.jsx(Ne,{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(Ve,{value:t,disabled:i||a.length===0,label:"Personalization template",options:a,onChange:N=>{m(N)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:d,onChange:N=>o(N.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:i||!r,onClick:p,children:e.jsx(Ye,{size:15})}),u&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:i||!s,children:e.jsx(tt,{size:15})})]})]})]})}function Zn({connection:s,profile:t,selectedDefaultTeamId:a}){const n=un(s),i=ta(n.schedules);return us(n.error,{prefix:"Local schedules"}),e.jsxs("div",{className:"account-list profile-agent-list","aria-label":"Profile agents",children:[e.jsx("div",{className:"account-list-heading profile-agent-list-heading",children:e.jsx("span",{children:"Agents"})}),e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-agent-table","aria-label":"Profile agents table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-agent-column"}),e.jsx("col",{className:"profile-action-column"}),e.jsx("col",{className:"profile-check-column"}),e.jsx("col",{className:"profile-sync-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Agent"}),e.jsx("th",{scope:"col",children:"Action"}),e.jsx("th",{scope:"col",children:"Check"}),e.jsx("th",{scope:"col",children:"Sync"})]})}),e.jsxs("tbody",{children:[i.active.map(r=>e.jsx(Ds,{pending:n.pendingScheduleIds.has(r.id),schedule:r,refreshing:n.loading,onRefresh:()=>{n.refresh()},onRun:()=>{n.run(r)},onToggle:()=>{n.toggle(r)}},r.id)),e.jsx(ea,{}),t.agents.map(r=>e.jsx(sa,{agent:r,defaultAction:t.summary.defaultAction,profile:t,selectedDefaultTeamId:a},r.id)),i.paused.map(r=>e.jsx(Ds,{pending:n.pendingScheduleIds.has(r.id),schedule:r,refreshing:n.loading,onRefresh:()=>{n.refresh()},onRun:()=>{n.run(r)},onToggle:()=>{n.toggle(r)}},r.id))]})]})})]})}function ea(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:"Dataset Builder"}),e.jsx("span",{children:"Built in · every Profile"})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:"Design · Materialize · Test"})})}),e.jsx("td",{children:e.jsx(Be,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx(Be,{status:{state:"ready",label:"Built in"}})})]})}function sa({agent:s,defaultAction:t,profile:a,selectedDefaultTeamId:n}){const i=ia(a,s,n);return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsx("span",{title:s.path,children:s.path})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:t??"None"})})}),e.jsx("td",{children:e.jsx(Be,{status:i.check})}),e.jsx("td",{children:e.jsx(Be,{status:i.sync})})]})}function Ds({pending:s,refreshing:t,schedule:a,onRefresh:n,onRun:i,onToggle:r}){const u=na(a),d=a.enabled?"Pause schedule":"Resume schedule";return e.jsxs("tr",{className:"profile-agent-row profile-schedule-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.localProjectName}),e.jsxs("span",{title:a.scheduleName,children:["schedule: ",a.scheduleName]})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{title:a.targetAction,children:a.targetAction})})}),e.jsx("td",{children:e.jsx(Be,{status:u})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:aa(a),children:a.enabled?a.scheduleExpression:"Paused"}),e.jsxs("div",{className:"profile-schedule-controls","aria-label":`${a.scheduleName} schedule controls`,children:[e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:t,type:"button",title:"Refresh local schedules","aria-label":"Refresh local schedules",onClick:n,children:e.jsx(de,{size:14,className:t?"settings-spin":void 0})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:"Run now","aria-label":`Run ${a.scheduleName} now`,onClick:i,children:e.jsx(Ye,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:d,"aria-label":`${d}: ${a.scheduleName}`,onClick:r,children:a.enabled?e.jsx(nt,{size:14}):e.jsx(it,{size:14})})]})]})})]})}function Be({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function ta(s){const t=[],a=[];for(const n of s)n.enabled?t.push(n):a.push(n);return t.sort((n,i)=>Ls(n)-Ls(i)),{active:t,paused:a}}function Ls(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function na(s){return s.enabled?s.lastError||s.lastRunStatus==="failed"?{state:"warning",label:"Failed"}:s.lastRunStatus==="running"?{state:"loading",label:"Running"}:s.lastRunStatus==="queued"?{state:"loading",label:"Queued"}:s.lastRunStatus==="skipped"?{state:"warning",label:"Skipped"}:s.lastRunStatus==="succeeded"?{state:"ready",label:"Succeeded"}:{state:"loading",label:"Scheduled"}:{state:"disabled",label:"Paused"}}function aa(s){const t=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&t.push(`next ${Ts(s.nextRunAt)}`),s.lastRunAt&&t.push(`last ${Ts(s.lastRunAt)}`),t.join(" - ")}function Ts(s){const t=new Date(s);return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):s}function ia(s,t,a){if(!t.enabled)return{check:{state:"disabled",label:"Disabled"},sync:{state:"disabled",label:"Disabled"}};if(s.error)return{check:{state:"warning",label:"Error"},sync:{state:"warning",label:"Blocked"}};if(s.setupGate.blockingCount>0)return{check:{state:"warning",label:"Setup"},sync:{state:"warning",label:"Blocked"}};if(s.git?.dirty||ra(s,t)>0)return{check:{state:"loading",label:"Pending"},sync:{state:"warning",label:"Changed"}};if(s.catalog.stale)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(!s.lastCheck)return{check:{state:"loading",label:"Unchecked"},sync:{state:"loading",label:"Waiting"}};if(s.lastCheck.status==="failed")return{check:{state:"warning",label:"Failed"},sync:{state:"warning",label:"Blocked"}};if(!s.summary.checkFresh)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(la(s,a))return{check:{state:"ready",label:"Passed"},sync:{state:"warning",label:"Sync acct"}};const n=s.summary.localHead??s.git?.head??null,i=s.hosted?.lastPushedLocalHead??null;return!(s.summary.hostedHead??s.hosted?.sourceCommitSha??null)&&!i?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Not synced"}}:n&&i&&n!==i?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Needed"}}:{check:{state:"ready",label:"Passed"},sync:{state:"ready",label:"Synced"}}}function la(s,t){const a=s.hosted?.teamId?.trim()??"";return!!(a&&t&&a!==t)}function ra(s,t){let a=0;s.diff.changedAgents.includes(t.id)&&(a+=1),s.diff.newAgents.includes(t.id)&&(a+=1),s.diff.deletedAgents.includes(t.id)&&(a+=1);const n=t.path.replace(/^profiles\/[^/]+\//,"");for(const i of s.diff.files){const r=i.path.replace(/^profiles\/[^/]+\//,"");(r===n||r.startsWith(`${n}/`)||r.startsWith(`agents/${t.id}/`))&&(a+=1)}return a}function Os(s){return s.policy.kind==="model"?`${s.policy.model.provider}/${s.policy.model.model}`:"Fixture"}function oa({comparison:s}){const t=[...new Set(s.members.map(n=>n.source.sourceRevision))],a=[...new Set(s.members.map(Os))];return e.jsxs("table",{className:"profile-evaluations-comparison-matrix",children:[e.jsxs("caption",{children:["Same frozen Taskset ",s.tasksetRelease.id," across Profile source and model choices"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Profile source"}),a.map(n=>e.jsx("th",{scope:"col",children:n},n))]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",title:n,children:n.slice(0,12)}),a.map(i=>{const r=s.members.filter(u=>u.source.sourceRevision===n&&Os(u)===i);return e.jsx("td",{children:r.length?r.map(u=>e.jsxs("div",{children:[e.jsx("strong",{children:u.score===null?"No score":`${Math.round(u.score*100)}%`}),e.jsxs("small",{children:[" · Run ",u.runManifest.id]})]},u.runManifest.id)):"—"},i)})]},n))})]})}function fs(s){switch(s.kind){case"profile":return"Complete Profile";case"workflow":return`Workflow · ${s.workflowId}`;case"skill":return`Skill · ${s.skillPath}`;case"agent_action":return`Agent action · ${s.actionId}`}}function ve(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString()}function Ce(s){return s===null?"No score":`${Math.round(s*100)}%`}function dt(s){return s.manifest.policy.kind==="model"?`${s.manifest.policy.model.provider}/${s.manifest.policy.model.model}`:"Fixture"}function ca({catalog:s,evaluations:t,onEvaluate:a,onOpenRun:n,busy:i}){const[r,u]=l.useState(null);return e.jsxs("section",{className:"profile-workflows","aria-label":"Profile workflows",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Workflows"}),e.jsx("p",{children:"Open a workflow to review its instructions and linked evaluations."})]}),s.workflows.length?e.jsx("div",{className:"profile-table-scroll",children:e.jsxs("table",{className:"profile-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Workflow"}),e.jsx("th",{scope:"col",children:"Evaluations"}),e.jsx("th",{scope:"col",children:"Runs"}),e.jsx("th",{scope:"col",children:"Latest result"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:s.workflows.map(({workflow:d,binding:c})=>{const m=t?.definitions.filter(p=>p.target.kind==="workflow"&&p.target.workflowId===d.id)??[],o=t?.runs.filter(p=>p.manifest.profileEvaluation?.target.kind==="workflow"&&p.manifest.profileEvaluation.target.workflowId===d.id)??[],f=o[0];return e.jsxs(l.Fragment,{children:[e.jsxs("tr",{children:[e.jsxs("th",{scope:"row",children:[e.jsx("button",{type:"button","aria-expanded":r===d.id,onClick:()=>u(p=>p===d.id?null:d.id),children:d.label}),e.jsx("small",{children:d.description})]}),e.jsx("td",{children:t?m.length:"—"}),e.jsx("td",{children:t?o.length:"—"}),e.jsx("td",{children:f?e.jsxs("button",{type:"button",onClick:()=>n(f),children:[f.passed?"Passed":"Did not pass"," · ",Ce(f.metric.value),e.jsx("small",{children:ve(f.completedAt)})]}):"Not run"}),e.jsx("td",{children:e.jsx("button",{type:"button",disabled:i||!t,onClick:()=>a(d.id),children:m.length?"Run Evaluation":"View evaluations"})})]}),r===d.id?e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsx("strong",{children:d.label}),e.jsxs("p",{children:["Revision ",c.sourceRevision.slice(0,12)," · Release ",c.harnessRelease.contentHash.slice(0,12)]}),d.skillPaths.length?e.jsxs("p",{children:["Skills: ",d.skillPaths.join(", ")]}):null,e.jsxs("details",{children:[e.jsx("summary",{children:d.invocation.kind==="instructions"?"Instructions":"Action configuration"}),e.jsx("pre",{children:d.invocation.kind==="instructions"?d.invocation.instructions:JSON.stringify(d.invocation,null,2)})]}),e.jsx("strong",{children:"Linked evaluations"}),m.length?e.jsx("ul",{children:m.map(p=>e.jsxs("li",{children:[p.label," · ",p.taskIds.length," tasks · ",p.seeds.length," seeds"]},p.id))}):e.jsx("p",{children:t?"No evaluation definition targets this workflow. Add one in the Profile’s evals catalog to run it.":"Evaluation catalog unavailable."}),e.jsx("button",{type:"button",disabled:i||!t,onClick:()=>a(d.id),children:m.length?"Run Evaluation":"View evaluation history"})]})})}):null]},d.id)})})]})}):e.jsx("p",{children:"No workflows in this Profile yet."})]})}function da({runs:s,definitions:t,sourceRevision:a,onOpen:n,onSave:i,savingReportId:r}){const[u,d]=l.useState(20);return e.jsxs("div",{className:"profile-evaluations-history",children:[e.jsx("h4",{children:"Run history"}),s.length?e.jsx("div",{className:"profile-table-scroll",children:e.jsxs("table",{className:"profile-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Evaluation / target"}),e.jsx("th",{scope:"col",children:"Completed"}),e.jsx("th",{scope:"col",children:"Model"}),e.jsx("th",{scope:"col",children:"Result"}),e.jsx("th",{scope:"col",children:"Score"}),e.jsx("th",{scope:"col",children:"Attempts"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:s.slice(0,u).map(c=>{const m=c.manifest.profileEvaluation,o=m?.sourceRevision===a?t.find(f=>f.id===m.definitionId):null;return e.jsxs("tr",{children:[e.jsxs("th",{scope:"row",children:[e.jsx("button",{type:"button",onClick:()=>n(c),children:o?.label??m?.definitionId??c.manifest.id}),m?e.jsx("small",{children:fs(m.target)}):null]}),e.jsx("td",{children:ve(c.completedAt)}),e.jsx("td",{children:dt(c)}),e.jsx("td",{children:c.passed?"Passed":"Did not pass"}),e.jsx("td",{children:Ce(c.metric.value)}),e.jsx("td",{children:c.receiptRefs.length}),e.jsx("td",{title:m?.sourceRevision,children:m?.sourceRevision.slice(0,10)??"—"}),e.jsxs("td",{children:[e.jsx("button",{type:"button",onClick:()=>n(c),children:"View results"})," ",e.jsx("button",{type:"button",disabled:!!r,onClick:()=>i(c.manifest.id),children:r===c.manifest.id?"Saving…":"Save report"})]})]},c.manifest.id)})})]})}):e.jsx("p",{children:"No evaluation runs yet."}),s.length>u?e.jsx("button",{type:"button",onClick:()=>d(c=>c+20),children:"Show more runs"}):null]})}function ze(s){return ye(s,"/v1/profile/evaluations/discover",{method:"POST",body:JSON.stringify({view:"history"})})}function Us(s,t,a){return ye(s,"/v1/profile/evaluations/discover",{method:"POST",body:JSON.stringify(t),signal:a})}function ua({connection:s,run:t,onClose:a}){const n=l.useRef(null),[i,r]=l.useState([]),[u,d]=l.useState(null),[c,m]=l.useState(null),[o,f]=l.useState(!0),[p,g]=l.useState(!1),[j,v]=l.useState(null),[x,N]=l.useState(null),[k,I]=l.useState(0),[$,y]=l.useState(50),[R,O]=l.useState(null);l.useEffect(()=>{n.current?.showModal()},[]),l.useEffect(()=>{const h=new AbortController;return f(!0),v(null),Us(s,{runId:t.manifest.id},h.signal).then(S=>{h.signal.aborted||r(S.cases)}).catch(S=>{h.signal.aborted||v(S instanceof Error?S.message:String(S))}).finally(()=>{h.signal.aborted||f(!1)}),()=>h.abort()},[s,t.manifest.id,k]),l.useEffect(()=>{if(!u)return;const h=new AbortController;return g(!0),N(null),Us(s,{runId:t.manifest.id,receiptId:u,...R?{eventAfterId:R}:{}},h.signal).then(S=>{h.signal.aborted||m(S.cases[0]??null)}).catch(S=>{h.signal.aborted||N(S instanceof Error?S.message:String(S))}).finally(()=>{h.signal.aborted||g(!1)}),()=>h.abort()},[s,t.manifest.id,u,R,k]);const A=t.manifest.profileEvaluation;return e.jsx("dialog",{ref:n,className:"profile-evaluation-dialog","aria-labelledby":"profile-run-title",onCancel:a,onClick:h=>{if(h.target===h.currentTarget){const S=h.currentTarget.getBoundingClientRect();(h.clientX<S.left||h.clientX>S.right||h.clientY<S.top||h.clientY>S.bottom)&&a()}},children:e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsxs("header",{className:"profile-evaluation-dialog-header",children:[e.jsx("h2",{id:"profile-run-title",children:"Evaluation results"}),e.jsx("button",{type:"button",autoFocus:!0,onClick:a,children:"Close"})]}),e.jsxs("strong",{children:[A?.definitionId??t.manifest.id," · ",t.passed?"Passed":"Did not pass"," · ",Ce(t.metric.value)]}),e.jsxs("p",{children:[A?fs(A.target):"Profile evaluation"," · ",dt(t)," · ",ve(t.completedAt)]}),e.jsxs("p",{children:["Pass rate ",Ce(t.passRate)," · Source ",A?.sourceRevision," · Run ",t.manifest.id]}),e.jsxs("details",{children:[e.jsx("summary",{children:"Frozen run configuration"}),e.jsx("pre",{children:JSON.stringify(t.manifest,null,2)})]}),o?e.jsx("p",{role:"status",children:"Loading case results…"}):null,j?e.jsxs("p",{role:"alert",children:[j," ",e.jsx("button",{type:"button",onClick:()=>I(h=>h+1),children:"Retry"})]}):null,e.jsx("div",{className:"profile-table-scroll",children:e.jsxs("table",{className:"profile-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Task"}),e.jsx("th",{scope:"col",children:"Seed"}),e.jsx("th",{scope:"col",children:"Result"}),e.jsx("th",{scope:"col",children:"Score"}),e.jsx("th",{scope:"col",children:"Grading"}),e.jsx("th",{scope:"col",children:"Latency"}),e.jsx("th",{scope:"col",children:"Cost"})]})}),e.jsx("tbody",{children:i.slice(0,$).map(h=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx("button",{type:"button","aria-pressed":u===h.receiptId,onClick:()=>{u===h.receiptId&&!R||(d(h.receiptId),m(null),O(null))},children:h.taskId})}),e.jsx("td",{children:h.seed}),e.jsx("td",{children:h.passed?"Passed":"Did not pass"}),e.jsx("td",{children:Ce(h.score)}),e.jsxs("td",{children:[h.gradingStatus,h.failureClass?` · ${h.failureClass}`:""]}),e.jsxs("td",{children:[h.latencyMs.toLocaleString()," ms"]}),e.jsx("td",{children:h.costUsd===null?"Unknown":`$${h.costUsd.toFixed(4)}`})]},h.receiptId))})]})}),i.length>$?e.jsx("button",{type:"button",onClick:()=>y(h=>h+50),children:"Show more cases"}):null,p?e.jsx("p",{role:"status",children:"Loading case evidence…"}):null,x?e.jsxs("p",{role:"alert",children:[x," ",e.jsx("button",{type:"button",onClick:()=>I(h=>h+1),children:"Retry"})]}):null,c?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Case evidence",children:[e.jsxs("h3",{children:[c.taskId," · Seed ",c.seed]}),e.jsx("h4",{children:"Grader feedback"}),e.jsx("p",{children:"Evaluations use the graders pinned by their Taskset. Each result below identifies the grader and version used for this case."}),c.feedback.length?c.feedback.map(h=>e.jsxs("div",{children:[e.jsxs("strong",{children:[h.graderId," · ",h.graderVersion," · ",Ce(h.score)," · ",h.passed?"Passed":"Did not pass"]}),e.jsx("ul",{children:h.feedback.map((S,C)=>e.jsx("li",{children:S},C))})]},`${h.graderId}:${h.graderVersion}`)):e.jsx("p",{children:"No grader feedback retained for this case."}),c.evidence?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Input"}),e.jsx("pre",{children:c.evidence.prompt}),e.jsx("h4",{children:"Output"}),e.jsx("pre",{children:c.evidence.output?.text??c.evidence.partialOutput?.text??"No output retained."}),c.evidence.error?e.jsx("p",{role:"alert",children:c.evidence.error}):null,e.jsxs("details",{children:[e.jsxs("summary",{children:["Trace · ",c.evidence.eventCount," events"]}),e.jsx("pre",{children:JSON.stringify(c.evidence.events,null,2)}),R?e.jsx("button",{type:"button",disabled:p,onClick:()=>O(null),children:"First trace page"}):null,c.evidence.nextEventCursor?e.jsx("button",{type:"button",disabled:p,onClick:()=>O(c.evidence.nextEventCursor),children:"Next trace page"}):null]})]}):e.jsx("p",{children:"No policy trace retained for this case. Scores and grader feedback are available above."}),e.jsxs("details",{children:[e.jsx("summary",{children:"Case receipt"}),e.jsx("pre",{children:JSON.stringify(c.receipt,null,2)})]})]}):null]})})}function We(s,t){return s.kind===t.kind&&(t.kind==="profile"||s.kind==="workflow"&&s.workflowId===t.id||s.kind==="skill"&&s.skillPath===t.id)}function ha(s){return Object.values(s.statuses).flatMap(t=>{if(!t.enabled||!t.available||!t.credential.connected)return[];const a=s.providers[t.id];return[...new Set([...t.modelIds,...s.modelCaches[t.id]?.models.map(i=>i.id)??[],...a?.modelOverrides??[],t.defaultModel,a?.defaultModel].filter(i=>!!i))].map(i=>({key:JSON.stringify([t.id,i]),providerId:t.id,modelId:i,label:`${t.displayName} · ${i}`}))})}function ma({connection:s,selectedProfileKey:t,focusTarget:a}){const n=l.useRef(null),[i,r]=l.useState(null),[u,d]=l.useState(null),[c,m]=l.useState(null),[o,f]=l.useState(null),[p,g]=l.useState(null),j=l.useRef(null),[v,x]=l.useState(null),[N,k]=l.useState(null),[I,$]=l.useState(50),[y,R]=l.useState(20),[O,A]=l.useState([]),[h,S]=l.useState(!1),[C,w]=l.useState(null),[M,F]=l.useState([]),[W,se]=l.useState(""),[X,D]=l.useState(null),[Z,te]=l.useState(!1),[B,le]=l.useState(!1),[ie,V]=l.useState(null),[q,Y]=l.useState(null),[ue,re]=l.useState(!1),[oe,K]=l.useState(null);if(l.useEffect(()=>{if(!s||!t){x(null),d(null),r(null),g(null),F([]),D(null);return}let b=!0;return re(!0),x(null),d(null),r(null),m(null),f(null),g(null),j.current=null,k(null),$(50),R(20),A([]),F([]),se(""),D(null),Y(null),K(null),ze(s).then(E=>{b&&d(E)}).catch(E=>{b&&K(E instanceof Error?E.message:String(E))}),U.profileWorkflows(s).then(E=>{b&&r(E)}).catch(E=>{b&&m(E instanceof Error?E.message:String(E))}),U.profileEvaluations(s).then(E=>{b&&x(E)}).catch(E=>{b&&K(E instanceof Error?E.message:String(E))}).finally(()=>{b&&re(!1)}),U.providerSettings(s).then(E=>{if(!b)return;const _=ha(E);F(_),se(_[0]?.key??"")}).catch(E=>{b&&K(E instanceof Error?E.message:String(E))}),()=>{b=!1}},[s,t]),l.useEffect(()=>{if(!a||!v||j.current===a)return;j.current=a;const b=v.definitions.find(E=>We(E.target,a));f(a),k(b?.id??null),D(null),$(50),Y(b?null:"No evaluation definition is saved for this Profile component."),n.current?.scrollIntoView({behavior:"smooth",block:"start"})},[v,a]),!t)return null;const Q=v?.definitions.find(b=>b.id===N),he=v?.definitions.filter(b=>!o||We(b.target,o))??[],ee=u??v,me=v?{...v,runs:ee?.runs??[],suiteRuns:ee?.suiteRuns??[]}:null,T=ee?.runs.filter(b=>o?!!(b.manifest.profileEvaluation&&We(b.manifest.profileEvaluation.target,o)):!Q||b.manifest.profileEvaluation?.definitionId===Q.id)??[],P=Z||B||!!ie,H=b=>{const E={kind:"workflow",id:b};f(E),k(v?.definitions.find(_=>We(_.target,E))?.id??null),D(null),Y(null),$(50),n.current?.scrollIntoView({behavior:"smooth",block:"start"})},z=async()=>{const b=M.find(_=>_.key===W);if(!s||!Q||!b||Z)return;const E={id:`evaluation-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),definitionId:Q.id,modelRef:{providerId:b.providerId,modelId:b.modelId}};te(!0),D(null),Y(null),K(null);try{D({request:E,prepared:await U.profileEvaluationPrepare(s,E)})}catch(_){K(_ instanceof Error?_.message:String(_))}finally{te(!1)}},ne=async()=>{if(!(!s||!X||B)){le(!0),K(null);try{const b=await U.profileEvaluationRun(s,{...X.request,expectedManifestHash:X.prepared.manifest.contentHash});D(null),g(b),Y(`Run ${b.manifest.id} ${b.passed?"passed":"did not pass"}.`),d(await ze(s))}catch(b){K(b instanceof Error?b.message:String(b))}finally{le(!1)}}},ce=async b=>{const E=M.find(_=>_.key===W);if(!(!s||!E||ie)){V(b),Y(null),K(null);try{const _=await U.profileEvaluationRunSuite(s,{id:`suite-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),suiteId:b,modelRef:{providerId:E.providerId,modelId:E.modelId}});d(await ze(s)),Y(`Suite ${_.id} ${_.passed?"passed":"did not pass"}.`)}catch(_){K(_ instanceof Error?_.message:String(_))}finally{V(null)}}},ae=b=>{A(E=>E.includes(b)?E.filter(_=>_!==b):[...E,b])},Ae=async()=>{if(!(!s||O.length<2||h)){S(!0),K(null);try{await U.profileEvaluationCompare(s,O),d(await ze(s)),A([])}catch(b){K(b instanceof Error?b.message:String(b))}finally{S(!1)}}},Oe=async(b,E)=>{if(!(!s||C)){w(E),K(null);try{const _=await U.profileEvaluationSaveReport(s,b,E);d(await ze(s)),Y(`Report ${_.id} saved to Profile source. Commit and publish the Profile when ready.`)}catch(_){K(_ instanceof Error?_.message:String(_))}finally{w(null)}}};return e.jsxs(e.Fragment,{children:[i?e.jsx(ca,{catalog:i,evaluations:me,onEvaluate:H,onOpenRun:g,busy:P}):null,c?e.jsx("p",{role:"alert",children:c}):null,e.jsxs("section",{ref:n,"aria-label":"Profile evaluations",className:"profile-evaluations",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Evaluations"}),e.jsx("p",{children:"Checks and retained results for this Profile’s released components."})]}),ue?e.jsx("p",{children:"Loading evaluations…"}):null,oe?e.jsx("p",{role:"alert",children:oe}):null,q?e.jsx("p",{role:"status",children:q}):null,o?e.jsxs("div",{className:"profile-evaluation-scope",children:[e.jsx("strong",{children:o.kind==="workflow"?`Workflow · ${o.id}`:o.kind==="skill"?`Skill · ${o.id}`:"Complete Profile"}),e.jsx("button",{type:"button",disabled:P,onClick:()=>{f(null),k(null),D(null),Y(null)},children:"Show all evaluations"})]}):null,v&&!he.length?e.jsx("p",{children:o?"No evaluation definitions target this component. Add a definition in the Profile’s evals catalog to run it. Retained runs are shown below.":"No evaluations in this Profile yet."}):null,v?.suites.length?e.jsxs("div",{className:"profile-evaluations-suites","aria-label":"Evaluation suites",children:[e.jsx("label",{htmlFor:"profile-evaluation-suite-model",children:"Suite model"}),e.jsx("select",{id:"profile-evaluation-suite-model",value:W,disabled:P,onChange:b=>{se(b.target.value),D(null)},children:M.map(b=>e.jsx("option",{value:b.key,children:b.label},b.key))}),M.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run a suite."}):null,v.suites.map(b=>e.jsxs("div",{className:"profile-evaluations-suite",children:[e.jsx("strong",{children:b.label}),e.jsxs("span",{children:[b.scope==="profile"?"Profile suite":"Component suite"," · ",b.definitionIds.length," checks"]}),e.jsx("button",{type:"button",disabled:!W||P,onClick:()=>{ce(b.id)},children:ie===b.id?"Running suite…":"Run suite"}),(ee?.suiteRuns??[]).filter(E=>E.suiteId===b.id).slice(0,5).map(E=>e.jsxs("details",{className:"profile-evaluations-suite-run",children:[e.jsxs("summary",{children:[ve(E.completedAt)," · ",E.passed?"Passed":"Did not pass"," · ",E.members.length," checks"]}),e.jsxs("small",{children:["Profile source ",E.sourceRevision.slice(0,12)," · Suite run ",E.id]}),e.jsx("button",{type:"button",disabled:!!C,onClick:()=>{Oe("suite",E.id)},children:C===E.id?"Saving report…":"Save report to Profile"}),e.jsx("ul",{children:E.members.map(_=>e.jsxs("li",{children:[e.jsx("strong",{children:E.sourceRevision===v.sourceRevision?v.definitions.find(fe=>fe.id===_.definitionId)?.label??_.definitionId:_.definitionId}),e.jsx("button",{type:"button",onClick:()=>{const fe=ee?.runs.find(Xe=>Xe.manifest.id===_.runManifest.id);fe&&g(fe)},disabled:!ee?.runs.some(fe=>fe.manifest.id===_.runManifest.id),children:"View results"}),e.jsxs("span",{children:[_.passed?"Passed":"Did not pass"," · ",_.score===null?"No score":`${Math.round(_.score*100)}%`," · Run ",_.runManifest.id]})]},_.runManifest.id))})]},E.id))]},b.id))]}):null,he.length?e.jsx("div",{className:"profile-table-scroll",children:e.jsxs("table",{className:"profile-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Evaluation"}),e.jsx("th",{scope:"col",children:"Target"}),e.jsx("th",{scope:"col",children:"Tasks / seeds"}),e.jsx("th",{scope:"col",children:"Latest result"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:he.map(b=>{const E=ee?.runs.find(_=>_.manifest.profileEvaluation?.definitionId===b.id);return e.jsxs("tr",{children:[e.jsxs("th",{scope:"row",children:[e.jsx("strong",{children:b.label}),e.jsx("small",{children:b.description})]}),e.jsx("td",{children:fs(b.target)}),e.jsxs("td",{children:[b.taskIds.length," / ",b.seeds.length]}),e.jsx("td",{children:E?e.jsxs("button",{type:"button",onClick:()=>g(E),children:[E.passed?"Passed":"Did not pass"," · ",Ce(E.metric.value),e.jsx("small",{children:ve(E.completedAt)})]}):"Not run"}),e.jsx("td",{children:e.jsx("button",{type:"button",disabled:P,"aria-expanded":N===b.id,onClick:()=>{k(_=>_===b.id?null:b.id),$(50),D(null),Y(null)},children:N===b.id?"Hide details":"View / Run Evaluation"})})]},b.id)})})]})}):null,Q?e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsx("h4",{children:Q.label}),e.jsxs("p",{children:["Taskset ",Q.tasksetRelease.id," · ",Q.tasksetRelease.contentHash.slice(0,12)]}),e.jsxs("p",{children:["Frozen split: ",Q.split," · Minimum pass rate: ",Math.round(Q.criterion.minimumPassRate*100),"% · ",Q.criterion.requireComplete?"All attempts required":"Incomplete runs allowed"]}),e.jsx("p",{children:"This evaluation runs the selected component against its Taskset’s frozen cases and graders."}),e.jsxs("details",{children:[e.jsx("summary",{children:"Evaluation definition"}),e.jsx("pre",{children:JSON.stringify(Q,null,2)})]}),e.jsxs("div",{className:"profile-evaluations-run-form",children:[e.jsx("label",{htmlFor:"profile-evaluation-model",children:"Model"}),e.jsx("select",{id:"profile-evaluation-model",value:W,disabled:P,onChange:b=>{se(b.target.value),D(null)},children:M.map(b=>e.jsx("option",{value:b.key,children:b.label},b.key))}),M.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run this check."}):null,e.jsx("button",{type:"button",disabled:!W||P,onClick:()=>{z()},children:Z?"Checking run…":"Check run setup"}),X?e.jsxs("div",{className:"profile-evaluations-run-plan",children:[e.jsx("strong",{children:"Run setup"}),e.jsxs("small",{children:["Profile source ",X.prepared.manifest.profileEvaluation?.sourceRevision.slice(0,12)," · Harness ",X.prepared.manifest.execution.kind==="harness"?X.prepared.manifest.execution.harnessRelease.id:""]}),e.jsxs("small",{children:["Taskset ",X.prepared.taskset.id," · ",X.prepared.manifest.population.length," attempts · ",X.prepared.manifest.limits.timeoutMs/1e3,"s per attempt"]}),e.jsxs("small",{children:["Connected app scopes: ",X.prepared.taskset.connectedAppScopes.join(", ")||"none declared"]}),e.jsx("button",{type:"button",disabled:B,onClick:()=>{ne()},children:B?"Running evaluation…":"Run evaluation"})]}):null]}),e.jsxs("div",{className:"profile-evaluations-cases",children:[e.jsx("strong",{children:"Task cases"}),e.jsx("ul",{children:Q.taskIds.slice(0,I).map(b=>e.jsx("li",{children:b},b))}),Q.taskIds.length>I?e.jsx("button",{type:"button",onClick:()=>$(b=>b+50),children:"Show more cases"}):null,e.jsxs("span",{children:["Seeds: ",Q.seeds.join(", ")]})]})]}):null,ee?e.jsx(da,{runs:T,definitions:v?.definitions??[],sourceRevision:v?.sourceRevision??"",onOpen:g,onSave:b=>{Oe("run",b)},savingReportId:C},N??JSON.stringify(o)):null,ee&&ee.runs.length>1?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Compare evaluation runs",children:[e.jsx("h4",{children:"Compare runs"}),e.jsx("p",{children:"Select two or more runs. Comparisons require the same Taskset, cases, environment, grading policy, limits, and runtime."}),e.jsx("div",{className:"profile-evaluations-comparison-runs",children:ee.runs.slice(0,y).map(b=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:O.includes(b.manifest.id),onChange:()=>ae(b.manifest.id),disabled:h}),e.jsxs("span",{children:[e.jsxs("strong",{children:[b.manifest.profileEvaluation?.definitionId??"Profile evaluation"," · ",b.metric.value===null?"No score":`${Math.round(b.metric.value*100)}%`]}),e.jsxs("small",{children:[ve(b.completedAt)," · ",b.manifest.policy.kind==="model"?`${b.manifest.policy.model.provider}/${b.manifest.policy.model.model}`:"fixture"," · Source ",b.manifest.profileEvaluation?.sourceRevision.slice(0,10)," · ",b.manifest.id]})]})]},b.manifest.id))}),ee.runs.length>y?e.jsx("button",{type:"button",onClick:()=>R(b=>b+20),children:"Show more runs"}):null,e.jsx("button",{type:"button",disabled:O.length<2||h,onClick:()=>{Ae()},children:h?"Comparing…":`Save comparison of ${O.length} runs`})]}):null,ee&&ee.comparisons.length>0?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Saved evaluation comparisons",children:[e.jsx("h4",{children:"Saved comparisons"}),e.jsx("ul",{children:ee.comparisons.map(b=>e.jsxs("li",{children:[e.jsxs("strong",{children:[ve(b.createdAt)," · ",b.members.length," runs"]}),e.jsx("button",{type:"button",disabled:!!C,onClick:()=>{Oe("comparison",b.id)},children:C===b.id?"Saving report…":"Save report to Profile"}),e.jsx("ul",{children:b.members.map(E=>e.jsxs("li",{children:[E.source.definitionId," · ",E.policy.kind==="model"?`${E.policy.model.provider}/${E.policy.model.model}`:"fixture"," · Source ",E.source.sourceRevision.slice(0,10)," · ",E.score===null?"No score":`${Math.round(E.score*100)}%`]},E.runManifest.id))}),e.jsx(oa,{comparison:b})]},b.id))})]}):null,ee?.reports.length?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Profile evaluation reports",children:[e.jsx("h4",{children:"Reports saved in Profile source"}),e.jsx("ul",{children:ee.reports.map(b=>e.jsxs("li",{children:[e.jsxs("strong",{children:[ve(b.createdAt)," · ",b.summary.passedChecks,"/",b.summary.totalChecks," checks passed"]}),e.jsxs("small",{children:["Tested source ",b.testedSources.map(E=>E.sourceRevision.slice(0,10)).join(", ")," · Evidence ",b.evidence.map(E=>E.id).join(", ")]})]},b.id))})]}):null]}),s&&p?e.jsx(ua,{connection:s,run:p,onClose:()=>g(null)},p.manifest.id):null]})}function pa({actions:s,busy:t,library:a,onSelect:n}){const i=a.profiles.find(u=>os(u.ref,a.lastUsed))??a.profiles[0]??null,r=i?Ze(i.ref):"";return e.jsxs("div",{className:"profile-selector-bar",children:[e.jsxs("label",{className:"profile-selector-control",children:[e.jsx("select",{"aria-label":"Active profile",disabled:t||a.profiles.length===0,value:r,onChange:u=>{const d=Lt(a,u.currentTarget.value),c=a.profiles.find(m=>os(m.ref,d));c&&n(c)},children:a.profiles.length?a.profiles.map(u=>e.jsx("option",{value:Ze(u.ref),children:u.name},Ze(u.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Tt,{"aria-hidden":"true",size:14})]}),s]})}function fa({addDisabled:s,commitDisabled:t,commitLabel:a,refreshDisabled:n,repoDisabled:i,syncDisabled:r,syncLabel:u,syncStatus:d,onAdd:c,onCommit:m,onRefresh:o,onRepo:f,onSync:p}){const[g,j]=l.useState(!1),v=l.useRef(null);l.useEffect(()=>{if(!g)return;function N(I){v.current?.contains(I.target)||j(!1)}function k(I){I.key==="Escape"&&j(!1)}return document.addEventListener("pointerdown",N),document.addEventListener("keydown",k),()=>{document.removeEventListener("pointerdown",N),document.removeEventListener("keydown",k)}},[g]);function x(N){j(!1),N()}return e.jsx("div",{className:"profile-selector-actions",children:e.jsxs("div",{className:"profile-settings-menu-root",ref:v,children:[e.jsx("button",{"aria-expanded":g,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>j(N=>!N),children:e.jsx(hs,{size:15})}),g?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:t,role:"menuitem",type:"button",onClick:()=>x(m),children:[e.jsx(Je,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:r,role:"menuitem",type:"button",onClick:()=>x(p),children:[e.jsx(Se,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:u}),d?e.jsx("small",{children:d}):null]})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>x(f),children:[e.jsx(Fe,{size:14}),e.jsx("span",{children:"Repository"})]}),e.jsx("div",{className:"profile-settings-menu-separator",role:"separator"}),e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>x(o),children:[e.jsx(de,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>x(c),children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const ga=[{id:"actions",label:"Actions",detail:"Profile-level reusable actions"},{id:"workflows",label:"Workflows",detail:"Workflow definitions and actions"},{id:"instructions",label:"Instructions",detail:"Profile instructions used by evaluations"},{id:"prompts",label:"Prompts",detail:"Shared prompt files"},{id:"goals",label:"Goals",detail:"Goal definitions; never started automatically"},{id:"evals",label:"Evals",detail:"Evaluation definitions and fixtures"},{id:"examples",label:"Examples",detail:"Example inputs and usage"},{id:"tasksets",label:"Tasksets",detail:"Training and evaluation tasksets"},{id:"extensions",label:"Extension declarations",detail:"Third-party extension metadata"}];function xa({connection:s,entry:t,onClose:a,onPublished:n}){const[i,r]=l.useState("github"),[u,d]=l.useState(""),[c,m]=l.useState(`${t.name}-profile`),[o,f]=l.useState("public"),[p,g]=l.useState(()=>t.state.agents.filter(w=>w.enabled).map(w=>w.id)),[j,v]=l.useState(()=>t.state.skills.filter(w=>w.enabled).map(w=>w.name)),[x,N]=l.useState([]),[k,I]=l.useState(null),[$,y]=l.useState(null),[R,O]=l.useState(null),A=l.useMemo(()=>({ref:t.ref,selection:{agentIds:p,skillNames:j,optionalContent:x},target:{provider:i,owner:u.trim()||null,repository:c.trim(),visibility:i==="github"?"public":o}}),[p,t.ref,x,u,i,c,j,o]);function h(w,M,F){return F?[...new Set([...w,M])]:w.filter(W=>W!==M)}async function S(w){if(w.preventDefault(),!(!c.trim()||$)){y("preview"),O(null);try{I(await U.profilePublicationPreview(s,A))}catch(M){O(M instanceof Error?M.message:String(M))}finally{y(null)}}}async function C(){if(!(!k||k.blockedReasons.length>0||$)){y("publish"),O(null);try{const w=await U.profilePublicationPublish(s,{...A,expectedSourceHash:k.sourceHash,confirmed:!0});n(`Published ${t.name} to ${w.owner}/${w.repository}`),a()}catch(w){O(w instanceof Error?w.message:String(w))}finally{y(null)}}}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("form",{className:"git-dialog profile-publication-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-publication-title",onMouseDown:w=>w.stopPropagation(),onSubmit:S,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!$,type:"button","aria-label":"Close",onClick:a,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Se,{size:18})}),e.jsxs("h2",{id:"profile-publication-title",children:["Publish ",t.name]}),e.jsx("p",{children:"Choose the exact Agents, Skills, workflows, and optional files to share. OpenPond will show the complete file list before it pushes anything."}),k?e.jsx(ja,{preview:k}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:"Destination"}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:i==="github",onChange:()=>{r("github"),f("public")}}),e.jsx(cs,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"GitHub"}),e.jsx("small",{children:"Published publicly with your signed-in gh CLI"})]})]}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:i==="openpond_git",onChange:()=>{r("openpond_git"),f("private")}}),e.jsx(Ot,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"OpenPond Git"}),e.jsx("small",{children:"Private by default; uses the same repository format"})]})]})]}),e.jsxs("div",{className:"profile-publication-target-fields",children:[i==="github"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"GitHub owner (optional)"}),e.jsx("input",{value:u,placeholder:"Uses gh account",onChange:w=>d(w.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:c,onChange:w=>m(w.currentTarget.value)})]}),i==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:o,onChange:w=>f(w.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(ts,{title:"Agents",empty:"No Agents in this Profile",children:t.state.agents.map(w=>e.jsx(ns,{checked:p.includes(w.id),label:w.name,detail:w.path,onChange:M=>g(F=>h(F,w.id,M))},w.id))}),e.jsx(ts,{title:"Skills",empty:"No Skills in this Profile",children:t.state.skills.map(w=>e.jsx(ns,{checked:j.includes(w.name),label:w.name,detail:w.description||w.path,onChange:M=>v(F=>h(F,w.name,M))},w.name))}),e.jsx(ts,{title:"Optional content",empty:"",children:ga.map(w=>e.jsx(ns,{checked:x.includes(w.id),label:w.label,detail:w.detail,onChange:M=>N(F=>h(F,w.id,M))},w.id))})]}),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",disabled:!!$,type:"button",onClick:k?()=>I(null):a,children:k?"Back":"Cancel"}),k?e.jsxs("button",{className:"git-dialog-primary",disabled:!!$||k.blockedReasons.length>0,type:"button",onClick:()=>{C()},children:[e.jsx(Se,{size:14}),e.jsx("span",{children:$==="publish"?"Publishing":k.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!$||!c.trim(),type:"submit",children:$==="preview"?"Building preview":"Review exact files"})]})]})})}function ts({title:s,empty:t,children:a}){const n=Array.isArray(a)?a.length:a?1:0;return e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:s}),n?a:e.jsx("span",{className:"profile-publication-empty",children:t})]})}function ns({checked:s,label:t,detail:a,onChange:n}){return e.jsxs("label",{className:"profile-publication-selection",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:i=>n(i.currentTarget.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:t}),e.jsx("small",{children:a})]})]})}function ja({preview:s}){const t=s.files.reduce((a,n)=>a+n.sizeBytes,0);return e.jsxs("div",{className:"profile-publication-preview",children:[e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[s.files.length," files · ",Ms(t)]}),e.jsx("span",{children:s.sourceRevision?.slice(0,10)??"No source revision"})]}),s.blockedReasons.map(a=>e.jsx("div",{className:"profile-dialog-warning",children:a},a)),s.warnings.map(a=>e.jsx("div",{className:"profile-publication-warning",children:a},a)),e.jsx("div",{className:"profile-publication-file-list","aria-label":"Exact files to publish",children:s.files.map(a=>e.jsxs("div",{children:[e.jsx("span",{title:a.path,children:a.path}),e.jsxs("small",{children:[a.category," · ",Ms(a.sizeBytes)]})]},a.path))}),s.excludedFiles.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[s.excludedFiles.length," excluded sensitive/runtime files"]}),s.excludedFiles.map(a=>e.jsx("code",{children:a},a))]}):null]})}function Ms(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function va({section:s="all",catalogPresentation:t="list",payload:a,connection:n,onPayload:i,onError:r,onToast:u,onSkillCommand:d,overviewContent:c}){const[m,o]=l.useState(""),[f,p]=l.useState(null),[g,j]=l.useState(!1),[v,x]=l.useState(null),[N,k]=l.useState(null),[I,$]=l.useState(null),y=a?.profile??null,R=a?.preferences.defaultTeamId?.trim()||"",O=s==="all"||s==="profile"||s==="controls",A=s==="all"||s==="profile",h=s==="all"||s==="agents",S=s==="all"||s==="profile";async function C(B){n&&(i(await U.bootstrap(n)),u?.(B,"success"))}async function w(B,le){if(!(!n||f)){p(B),r(null);try{await le()}catch(ie){r(ie instanceof Error?ie.message:String(ie))}finally{p(null)}}}function M(){w("init",async()=>{await U.profileInit(n,{}),await C("Profile initialized")})}function F(){w("commit",async()=>{await U.profileCommit(n,{message:m.trim()||null}),o(""),await C("Profile commit complete")})}function W(){w("push",async()=>{if(!R)throw new Error("Select a default team before syncing a hosted profile.");await U.profileCheck(n,{kind:"all"}),await U.profilePush(n,{teamId:R,ensureHosted:!0,message:null}),await C("Profile synced to hosted profile repo")})}function se(B){w(`select:${B.ref.profileId}`,async()=>{await U.profileSelect(n,B.ref),await C(`Using ${B.name}`)})}function X(B){w("add",async()=>{B.source==="blank"?await U.profileInit(n,{path:B.path,profile:B.profile,template:"blank-profile"}):B.source==="local"?await U.profileLoad(n,B):await U.profileInstall(n,B),j(!1),await C(B.source==="blank"?`${B.profile} created`:"Profile added")})}function D(B){w("update",async()=>{await U.profileUpdate(n,B.ref),await C(`${B.name} updated`)})}function Z(B){w("remove",async()=>{await U.profileRemove(n,B.ref),x(null),await C("Profile removed from this device")})}function te(){w("refresh",async()=>{await C("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[y?.mode==="local"?e.jsxs(e.Fragment,{children:[O?e.jsxs(e.Fragment,{children:[A&&t==="select"?e.jsx(pa,{actions:e.jsx(zs,{connection:n,onAdd:()=>j(!0),onRefresh:te,presentation:"menu",profile:y,profileBusy:f,profileCommitMessage:m,selectedDefaultTeamId:R,syncDisabledReason:Hs(y,R),setProfileCommitMessage:o,submitProfileCommit:F,submitProfilePush:W}),busy:!!f,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:se}):e.jsxs(e.Fragment,{children:[A?e.jsx(ba,{busy:!!f,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>j(!0),onRefresh:te,onRemove:x,onPublish:k,onUpdate:D,onSelect:se}):null,e.jsx(zs,{connection:n,profile:y,profileBusy:f,profileCommitMessage:m,selectedDefaultTeamId:R,syncDisabledReason:Hs(y,R),setProfileCommitMessage:o,submitProfileCommit:F,submitProfilePush:W})]}),c]}):null,h?e.jsx(Zn,{connection:n,profile:y,selectedDefaultTeamId:R}):null,S?e.jsxs(e.Fragment,{children:[e.jsx(Ca,{onSkillCommand:d,onEvaluate:B=>$({kind:"skill",id:B}),profile:y}),e.jsx(ma,{connection:n,focusTarget:I,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null},JSON.stringify(a?.profileLibrary?.lastUsed??null))]}):null]}):s==="agents"?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agents"}),e.jsx("small",{children:"Profile required"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Open Profile to create or load a Profile before managing agents."})]})]}):e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Summary"}),e.jsx("small",{children:"Not loaded"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Create an empty Profile, start with an Agent template, or add an existing repository."}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!!f,type:"button",onClick:()=>j(!0),children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!!f,type:"button",onClick:M,children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:f==="init"?"Creating":"Create starter Profile"})]})]})]}),g?e.jsx(ya,{busy:!!f,onClose:()=>j(!1),onSubmit:X}):null,v?e.jsx(Na,{busy:!!f,entry:v,onClose:()=>x(null),onConfirm:()=>Z(v)}):null,N&&n?e.jsx(xa,{connection:n,entry:N,onClose:()=>k(null),onPublished:B=>u?.(B,"success")}):null]})}function ba({busy:s,library:t,onAdd:a,onRefresh:n,onRemove:i,onPublish:r,onSelect:u,onUpdate:d}){return e.jsxs("div",{className:"account-list profile-catalog-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Profiles"}),e.jsxs("div",{className:"profile-skill-heading-actions",children:[e.jsxs("small",{children:[t.profiles.length," installed"]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:n,children:[e.jsx(de,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),t.profiles.map(c=>{const m=os(c.ref,t.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${m?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||u(c)},onKeyDown:o=>{s||o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),u(c))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Fe,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:c.name}),e.jsx("span",{title:c.repoPath,children:c.repoPath})]})]}),e.jsx(ut,{status:{state:c.state.error?"warning":"ready",label:c.state.error?"error":m?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:c.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:c.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[c.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),d(c)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),d(c))},children:[e.jsx(de,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),r(c)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),r(c))},children:[e.jsx(Se,{size:14}),e.jsx("span",{children:"Publish"})]}),e.jsxs("span",{className:"settings-secondary compact profile-remove-button",role:"button",tabIndex:0,"aria-label":`Remove ${c.name}`,onClick:o=>{o.stopPropagation(),i(c)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),i(c))},children:[e.jsx(Qe,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${c.ref.source}:${c.ref.repositoryId}:${c.ref.profileId}`)})]})}function ya({busy:s,onClose:t,onSubmit:a}){const[n,i]=l.useState("blank"),[r,u]=l.useState(""),[d,c]=l.useState(""),[m,o]=l.useState("");function f(p){if(p.preventDefault(),s)return;if(n==="blank"){const j=m.trim();if(!j)return;a({source:n,path:r.trim()||null,profile:j});return}if(n==="local"){const j=r.trim();if(!j)return;a({source:n,path:j,profile:m.trim()||null});return}const g=d.trim();g&&a({source:n,repositoryId:g,profile:m.trim()||null})}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:t,children:e.jsxs("form",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"add-profile-title",onMouseDown:p=>p.stopPropagation(),onSubmit:f,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:t,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Fe,{size:18})}),e.jsx("h2",{id:"add-profile-title",children:"Add Profile"}),e.jsx("p",{children:"Create a blank Profile, add a local repository, or install a shareable Profile from Git."}),e.jsxs("div",{className:"profile-add-source-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="blank",onChange:()=>i("blank")}),"New blank"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="local",onChange:()=>i("local")}),"Local"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="github",onChange:()=>i("github")}),"GitHub"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="openpond_git",onChange:()=>i("openpond_git")}),"OpenPond Git"]})]}),n==="blank"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path (optional)"}),e.jsx("input",{disabled:s,value:r,placeholder:"Uses the default local Profile repository",onChange:p=>u(p.currentTarget.value)})]}):n==="local"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path"}),e.jsx("input",{autoFocus:!0,disabled:s,value:r,placeholder:"/path/to/profile-repo",onChange:p=>u(p.currentTarget.value)})]}):e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:[n==="github"?"GitHub":"OpenPond Git"," repository"]}),e.jsx("input",{autoFocus:!0,disabled:s,value:d,placeholder:"owner/repository",onChange:p=>c(p.currentTarget.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:n==="blank"?"Profile name":"Profile name (optional)"}),e.jsx("input",{autoFocus:n==="blank",disabled:s,value:m,placeholder:n==="blank"?"research":"Uses repository default",onChange:p=>o(p.currentTarget.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:t,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:s||!(n==="blank"?m:n==="local"?r:d).trim(),type:"submit",children:n==="blank"?"Create Profile":"Add Profile"})]})]})})}function Na({busy:s,entry:t,onClose:a,onConfirm:n}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"remove-profile-title",onMouseDown:i=>i.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:a,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Qe,{size:18})}),e.jsxs("h2",{id:"remove-profile-title",children:["Remove ",t.name,"?"]}),e.jsx("p",{children:"This removes the Profile from OpenPond on this device. It does not delete the repository or any source files."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:t.name}),e.jsx("span",{children:t.repoPath})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:a,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary danger",disabled:s,type:"button",onClick:n,children:"Remove"})]})]})})}function zs({connection:s,onAdd:t,onRefresh:a,presentation:n="toolbar",profile:i,profileBusy:r,profileCommitMessage:u,selectedDefaultTeamId:d,syncDisabledReason:c,setProfileCommitMessage:m,submitProfileCommit:o,submitProfilePush:f}){const[p,g]=l.useState(!1),[j,v]=l.useState(!1),[x,N]=l.useState(!1),k=!s||!!r;return e.jsxs(e.Fragment,{children:[n==="menu"&&t&&a?e.jsx(fa,{addDisabled:!!r,commitDisabled:k,commitLabel:r==="commit"?"Committing":"Commit",refreshDisabled:k,repoDisabled:!!r||!i,syncDisabled:k||!i,syncLabel:r==="push"?"Syncing":"Sync",syncStatus:i?as(i,d):null,onAdd:t,onCommit:()=>v(!0),onRefresh:a,onRepo:()=>g(!0),onSync:()=>N(!0)}):e.jsx("div",{className:"profile-control-panel",children:e.jsxs("div",{className:"profile-control-toolbar",children:[e.jsxs("div",{className:"profile-control-actions",children:[e.jsxs("button",{className:"settings-secondary",disabled:k,type:"button",onClick:()=>v(!0),children:[e.jsx(Je,{size:14}),e.jsx("span",{children:r==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:k||!i,type:"button",onClick:()=>N(!0),children:[e.jsx(Se,{size:14}),e.jsx("span",{children:r==="push"?"Syncing":"Sync"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!!r||!i,type:"button",onClick:()=>g(!0),children:[e.jsx(Fe,{size:14}),e.jsx("span",{children:"Repo"})]}),i?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${as(i,d)}`,children:[e.jsx(Se,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:as(i,d)})]}):null]}),i?e.jsx("span",{className:`profile-local-status ${i.summary.state}`,title:i.summary.message,children:i.summary.message}):null]})}),p&&i?e.jsx(ka,{profile:i,profileBusy:r,onClose:()=>g(!1)}):null,j?e.jsx(Sa,{disabled:k,profileBusy:r,profileCommitMessage:u,setProfileCommitMessage:m,submitProfileCommit:o,onClose:()=>v(!1)}):null,x&&i?e.jsx(wa,{disabled:k,profile:i,profileBusy:r,selectedDefaultTeamId:d,syncDisabledReason:c,submitProfilePush:f,onClose:()=>N(!1)}):null]})}function Sa({disabled:s,profileBusy:t,profileCommitMessage:a,setProfileCommitMessage:n,submitProfileCommit:i,onClose:r}){function u(d){d.preventDefault(),!s&&(i(),r())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:r,children:e.jsxs("form",{className:"git-dialog profile-commit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-commit-dialog-title",onMouseDown:d=>d.stopPropagation(),onSubmit:u,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:r,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Je,{size:18})}),e.jsx("h2",{id:"profile-commit-dialog-title",children:"Commit profile"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Commit message"}),e.jsx("input",{autoFocus:!0,value:a,disabled:!!t,placeholder:"Update OpenPond profile",onChange:d=>n(d.target.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:r,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:s,type:"submit",children:[e.jsx(Je,{size:14}),e.jsx("span",{children:t==="commit"?"Committing":"Commit"})]})]})]})})}function wa({disabled:s,profile:t,profileBusy:a,selectedDefaultTeamId:n,syncDisabledReason:i,submitProfilePush:r,onClose:u}){const d=Pa(t,n),c=d.reduce((f,p)=>f+p.count,0),m=!s&&!i;function o(f){f.preventDefault(),m&&(r(),u())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:u,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:f=>f.stopPropagation(),onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:u,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Se,{size:18})}),e.jsx("h2",{id:"profile-sync-dialog-title",children:"Sync profile"}),e.jsx("p",{className:"profile-sync-explainer",children:"Sync publishes this committed Profile source for your team, so its Agents can be shared in team chat and attached to hosted sandboxes."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[c," ",c===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",De(t.summary.localHead??t.git?.head)," - Last pushed"," ",De(t.hosted?.lastPushedLocalHead)]})]}),d.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:d.map(f=>e.jsxs("div",{className:`profile-dialog-diff-row ${f.tone??""}`,children:[e.jsx("strong",{children:f.label}),e.jsx("span",{children:f.detail})]},f.label))}):e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:e.jsxs("div",{className:"profile-dialog-diff-row",children:[e.jsx("strong",{children:"Aligned"}),e.jsx("span",{children:"Current local profile source has already been pushed."})]})}),i?e.jsx("div",{className:"profile-dialog-warning",children:i}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!a,type:"button",onClick:u,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!m,type:"submit",children:[e.jsx(Se,{size:14}),e.jsx("span",{children:a==="push"?"Syncing":"Confirm sync"})]})]})]})})}function ka({profile:s,profileBusy:t,onClose:a}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog profile-path-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-path-dialog-title",onMouseDown:n=>n.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:a,children:e.jsx(pe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Fe,{size:18})}),e.jsx("h2",{id:"profile-path-dialog-title",children:"Profile repo"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Profile repo path"}),e.jsx("input",{"aria-label":"Profile repo path",readOnly:!0,value:s.repoPath??""})]}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:s.git?.isRepo?"Git-backed":"Git setup required"}),e.jsxs("span",{children:[s.git?.branch??"No branch"," · ",De(s.git?.head)]})]}),e.jsx("div",{className:"git-dialog-footer",children:e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:a,children:"Close"})})]})})}function Ca({onSkillCommand:s,onEvaluate:t,profile:a}){const n=a.skills.slice().sort((u,d)=>u.name.localeCompare(d.name)),i=!s;function r(u){s?.(u)}return e.jsxs("div",{className:"account-list profile-skill-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Skills"}),e.jsx("div",{className:"profile-skill-heading-actions",children:e.jsxs("small",{children:[a.skillCatalog.skillCount," tracked"]})})]}),n.length?e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-skill-table","aria-label":"Profile skills table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-skill-name-column"}),e.jsx("col",{className:"profile-skill-trigger-column"}),e.jsx("col",{className:"profile-skill-status-column"}),e.jsx("col",{className:"profile-skill-source-column"}),e.jsx("col",{className:"profile-skill-actions-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Skill"}),e.jsx("th",{scope:"col",children:"Trigger"}),e.jsx("th",{scope:"col",children:"Status"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:n.map(u=>e.jsx(Ra,{commandDisabled:i,onSkillCommand:r,onEvaluate:t,skill:u},u.name))})]})}):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No profile skills found"}),e.jsx("span",{children:"Use /skill create to add reusable profile instructions."})]})]})}function Ra({commandDisabled:s,onSkillCommand:t,onEvaluate:a,skill:n}){const i=n.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:n.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Ke,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:n.name}),e.jsx("span",{title:n.path,children:n.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:n.description,children:n.description||"No description"}),e.jsx("td",{children:e.jsx(ut,{status:i})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:n.sourcePath,children:n.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[a?e.jsx("button",{className:"settings-secondary compact",type:"button",onClick:()=>a(n.path),children:"Evaluate"}):null,e.jsx("button",{className:"settings-secondary compact",disabled:s||!n.enabled,type:"button",title:`Use ${n.name}`,onClick:()=>t(`$${n.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${n.name}`,onClick:()=>t(`/skill edit ${n.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function ut({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function De(s){return s?s.slice(0,10):"None"}function as(s,t){return ht(s,t)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${De(s.hosted.sourceCommitSha)}`:"Not pushed"}function Hs(s,t){return t?s.git?.head?s.git.dirty?"Commit local profile changes before syncing.":null:"Commit the profile before syncing.":"Select a default team before syncing."}function Pa(s,t){const a=[],n=s.summary.localHead??s.git?.head??null,i=s.hosted?.lastPushedLocalHead??null,r=s.summary.hostedHead??s.hosted?.sourceCommitSha??null;if(ht(s,t)&&a.push({label:"Account",detail:"Hosted profile metadata was synced under a different default team.",count:1,tone:"warning"}),!r&&!i?a.push({label:"Hosted source",detail:"No hosted profile commit has been recorded.",count:1}):n&&i&&n!==i&&a.push({label:"Commit",detail:`Local ${De(n)} has not been pushed since ${De(i)}.`,count:1}),s.git?.dirty){const d=(s.git.fileCount??s.git.files.length)||(s.diff.fileCount??s.diff.files.length)||1;a.push({label:"Uncommitted files",detail:`${d} local ${d===1?"file":"files"} changed.`,count:d,tone:"warning"})}const u=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length+s.diff.changedSkills.length+s.diff.changedActions.length+s.diff.changedExtensions.length+s.diff.setupChanges.length+s.diff.envRequirementChanges.length;return u>0&&a.push({label:"Profile changes",detail:Aa(s),count:u,tone:s.git?.dirty?"warning":void 0}),s.catalog.stale&&a.push({label:"Catalog",detail:"Action catalog artifacts are stale or missing.",count:1,tone:"warning"}),s.setupGate.blockingCount>0&&a.push({label:"Setup",detail:`${s.setupGate.blockingCount} blocking setup ${s.setupGate.blockingCount===1?"requirement":"requirements"}.`,count:s.setupGate.blockingCount,tone:"warning"}),a}function Aa(s){const t=[],a=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length;return a&&t.push(`${a} agent ${a===1?"change":"changes"}`),s.diff.changedActions.length&&t.push(`${s.diff.changedActions.length} action ${s.diff.changedActions.length===1?"change":"changes"}`),s.diff.changedSkills.length&&t.push(`${s.diff.changedSkills.length} skill ${s.diff.changedSkills.length===1?"change":"changes"}`),s.diff.changedExtensions.length&&t.push(`${s.diff.changedExtensions.length} extension ${s.diff.changedExtensions.length===1?"change":"changes"}`),s.diff.setupChanges.length&&t.push(`${s.diff.setupChanges.length} setup ${s.diff.setupChanges.length===1?"change":"changes"}`),s.diff.envRequirementChanges.length&&t.push(`${s.diff.envRequirementChanges.length} env ${s.diff.envRequirementChanges.length===1?"change":"changes"}`),t.join(", ")||"Profile source has local changes."}function ht(s,t){const a=s.hosted?.teamId?.trim()??"";return!!(a&&t&&a!==t)}function Ia({status:s,busy:t,flashTailscaleUp:a,refresh:n,enableRemoteAccess:i,disableRemoteAccess:r,copyRemoteLink:u,copyTailscaleUpCommand:d,copyServeCommand:c,copyServeSetupUrl:m,copyOperatorCommand:o,createRemoteLink:f}){const p=s?.tailscale.installed??!1,g=s?.serve.enabled??!1,j=s?.serve.reachable??!1,v=!!(s?.webUiAvailable&&p),x=g?!!s?.remoteWebUrl:v,k=(s?.tailscale.peers??[]).filter(y=>!y.isSelf),I=!!s?.tailscale.error?.includes("set --operator"),$=!!(g&&s?.remoteWebUrl);return e.jsxs("section",{className:"account-settings remote-access-settings",children:[e.jsx("h1",{children:"Remote access"}),e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx("div",{className:`remote-access-icon ${j?"online":g?"configured":""}`,children:p?e.jsx(ot,{size:18}):e.jsx(cn,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:j?"Tailscale Serve is reachable":g?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Da(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(de,{className:t==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:t!==null||!p||!g&&!v,onClick:()=>{g?r():i()},children:[e.jsx(Ut,{size:15}),e.jsx("span",{children:g?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:$?"Browser UI":"Tailscale + Serve"})]})}),$&&e.jsx(je,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:t==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||t!==null,onAction:u}),e.jsx(je,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:a,actionLabel:t==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||t!==null,onAction:d}),e.jsx(je,{label:"Serve command",value:s?.serveCommand??null,actionLabel:t==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||t!==null,onAction:c}),s?.serve.setupUrl&&e.jsx(je,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:t==="copy-serve-setup"?"Copying":"Copy",disabled:t!==null,onAction:m}),I&&e.jsx(je,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:t==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||t!==null,onAction:o}),e.jsx(je,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(je,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(je,{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:[k.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:t!==null||!x,onClick:()=>{f()},children:e.jsx("span",{children:g?"Copy link":"Create link"})})]}),s?k.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."})]}):k.map(y=>e.jsx($a,{peer:y},y.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(Ea,{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 je({actionLabel:s,disabled:t,flash:a,label:n,onAction:i,value:r}){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:r??"Not available"})]}),i&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:t,onClick:()=>{i()},children:e.jsx("span",{children:s??"Copy"})})]})}function Ea({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(Bs,{label:n.label,value:n.value},n.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(n=>e.jsx(Bs,{label:n.label,value:n.value},n.label))})]})}function Bs({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 $a({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 Da(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"}function La({device:s,self:t,busy:a,webBaseUrl:n,teamId:i,act:r}){const[u,d]=l.useState(s.name);l.useEffect(()=>d(s.name),[s.name]);const c=i===null?"remoteScope=personal":`remoteTeam=${encodeURIComponent(i)}`,m=n?`${n}/?remoteDevice=${encodeURIComponent(s.id)}&${c}`:null;return e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsxs("div",{className:"remote-access-device-details",children:[e.jsxs("strong",{children:[s.name,t?" · This computer":""]}),e.jsxs("small",{children:[s.status.replaceAll("_"," ")," · ",s.taskCount," tasks at last sync"]}),e.jsxs("small",{children:["Last seen"," ",s.lastSeenAt?new Date(s.lastSeenAt).toLocaleString():"never"," ","· Catalog synced"," ",s.lastCatalogSyncAt?new Date(s.lastCatalogSyncAt).toLocaleString():"never"]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Computer name"}),e.jsx("input",{value:u,maxLength:200,disabled:a,onChange:o=>d(o.target.value)})]})]}),e.jsxs("div",{className:"account-summary-actions",children:[m&&e.jsx("a",{className:"settings-secondary",href:m,target:"_blank",rel:"noreferrer",children:"Open tasks"}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:a||!u.trim()||u.trim()===s.name,onClick:()=>{r("rename",{deviceId:s.id,revision:s.revision,name:u.trim()})},children:"Save name"}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:a||!s.enabled,onClick:()=>{r(t?"disable":"disable-device",t?{}:{deviceId:s.id,revision:s.revision})},children:"Turn off"}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:a,onClick:()=>{r("remove",{deviceId:s.id,revision:s.revision})},children:"Remove"})]})]})}const Ta={signed_out:"Sign in required",connecting:"Connecting",connected:"Connected",reconnecting:"Reconnecting",offline:"Offline",off:"Off",update_required:"Update required"},_s={protocol_unsupported:"Install the latest OpenPond desktop app to connect to this relay.",authentication_timeout:"The relay did not confirm authentication. Retry the connection.",authentication_expired:"Relay authentication expired. Retry the connection.",relay_backpressure:"The relay is busy. OpenPond will retry automatically.",connection_lost:"The relay connection was lost. OpenPond will retry automatically.",connection_failed:"Unable to reach the relay. Check your network connection and retry."};function Fs(s,t){return s instanceof Error?s.message==="remote_account_changing"?"Your account settings are being updated. Try again shortly.":s.message:t}function Oa({connection:s,onError:t}){const[a,n]=l.useState(null),[i,r]=l.useState(null),[u,d]=l.useState(!1),[c,m]=l.useState(null),o=l.useRef(0),f=l.useRef(a),p=l.useRef(!1),g=l.useRef(null),j=l.useCallback(async()=>{if(g.current)return;const N=++o.current;if(!s){f.current=null,n(null);return}const k=new AbortController;g.current=k,m(null);try{const I=await ye(s,"/v1/account-remote-access",{signal:AbortSignal.any([k.signal,AbortSignal.timeout(15e3)])});o.current===N&&(f.current=I,n(I))}catch(I){!k.signal.aborted&&o.current===N&&m(I instanceof Error&&I.name==="TimeoutError"?"Loading your computers timed out. Retry to load their current status.":Fs(I,"Unable to load your computers."))}finally{g.current===k&&(g.current=null)}},[s]);l.useEffect(()=>{f.current=null,n(null),m(null),j();let N=Date.now();const k=window.setInterval(()=>{if(p.current)return;(["connecting","reconnecting"].includes(f.current?.state??"")||Date.now()-N>=15e3)&&(N=Date.now(),j())},1e3);return()=>{++o.current,g.current?.abort(),g.current=null,window.clearInterval(k)}},[j]),l.useEffect(()=>{r(null);const N=a?.team?.id;if(!s||!a?.account||!N)return;let k=!0;return Mt.organizations(s).then(I=>{const $=I.organizations.map(Qs).find(y=>y?.teamId===N);k&&$&&r($.displayName||$.name||$.slug)}).catch(()=>{}),()=>{k=!1}},[s,a?.account?.id,a?.team?.id]);async function v(N,k={}){if(!s||p.current)return;g.current?.abort(),g.current=null;const I=++o.current;p.current=!0,d(!0),t(null);try{const $=await ye(s,`/v1/account-remote-access/${N}`,{method:"POST",body:JSON.stringify(k)});o.current===I&&(f.current=$,n($))}catch($){o.current===I&&(t(Fs($,"Unable to update remote access.")),await j())}finally{p.current=!1,d(!1)}}const x=!!a?.account;return e.jsxs("section",{className:"account-settings remote-access-settings",children:[e.jsx("h1",{children:"Remote access"}),e.jsx("p",{children:"View this computer’s tasks and send instructions from your signed-in OpenPond account. Tasks run on this computer."}),a?.account&&e.jsxs("p",{children:["Account: ",a.account.label," · ",a.team?`Workspace: ${i??a.team.id}`:"Personal account"]}),e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsx("div",{className:"account-summary-main",children:e.jsxs("div",{children:[e.jsxs("strong",{children:["This computer",a?.device?.name?` · ${a.device.name}`:""]}),e.jsx("small",{role:"status",children:a?Ta[a.state]:c?"Unable to load":"Checking connection…"}),a?.device&&e.jsxs("small",{children:["Catalog synced"," ",a.device.lastCatalogSyncAt?new Date(a.device.lastCatalogSyncAt).toLocaleString():"never"]})]})}),e.jsxs("div",{className:"account-summary-actions",children:[e.jsx("button",{className:"settings-secondary",type:"button",disabled:u||!x,onClick:()=>{v(a?.enabled?"disable":"enable")},children:u?"Updating…":a?.enabled?"Turn off":"Turn on"}),e.jsx("button",{className:"settings-secondary",type:"button",disabled:u||(a?!x||!a.enabled:!s||!c),onClick:()=>a?void v("retry"):void j(),children:a?"Retry connection":"Retry loading"})]})]}),c&&e.jsx("p",{role:"alert",children:c}),a?.state==="signed_out"&&e.jsx("p",{children:"Sign in from Settings → Account to connect this computer."}),a?.account&&!a.team&&e.jsx("p",{children:"Personal access includes tasks owned by your OpenPond account. To use workspace tasks, select that workspace in Settings → Account."}),a?.team&&e.jsx("p",{children:"This connection includes tasks owned by the selected workspace. Choose Personal account in Settings → Account to use your personal tasks."}),a?.reason&&_s[a.reason]&&e.jsxs("p",{role:"status",children:[_s[a.reason],a.state==="update_required"&&a.minimumSupportedProtocolVersion?` This relay requires protocol ${a.minimumSupportedProtocolVersion}; this app uses protocol ${a.supportedProtocolVersion}.`:""]}),a?.device?.removed&&e.jsx("p",{children:"This computer was removed. Turn on remote access here to enroll it again."}),e.jsx("p",{children:"Turning off remote access applies to your personal account and its workspaces on this computer. It stays off after restart and sign-in until you turn it on here. Sleeping or closing the app makes this computer unavailable."}),e.jsx("p",{children:"History fetched through OpenPond may be cached for 24 hours. Turning off or removing a computer blocks remote history and controls; its local history stays on that computer."}),e.jsx("h2",{children:"Your computers"}),a?.devices.length===0&&e.jsx("p",{children:"No computers are enrolled."}),a?.devices.map(N=>e.jsx(La,{device:N,self:N.id===a.device?.id,busy:u,webBaseUrl:a.webBaseUrl,teamId:a.team?.id??null,act:v},N.id))]})}const Ua=[{items:[{section:"account",label:"Account",Icon:bs},{section:"ponder",label:"Ponder Pal",Icon:He},{section:"notifications",label:"Notifications",Icon:lt},{section:"providers",label:"Providers",Icon:et},{section:"conversation-imports",label:"Conversation imports",Icon:de},{section:"usage",label:"Activity",Icon:Ht}]},{label:"Harness",items:[{section:"harness",label:"Overview",Icon:an},{section:"harness-refiner",label:"Refiner",Icon:js},{section:"harness-continuous-review",label:"Continuous Review",Icon:de},{section:"harness-contents",label:"Contents",Icon:Bt},{section:"harness-releases",label:"Releases",Icon:ln}]},{label:"Customization",items:[{section:"configuration",label:"Configuration",Icon:kn},{section:"personalization",label:"Personalization",Icon:js},{section:"editor",label:"Editor",Icon:rn},{section:"skills",label:"Skills",Icon:Ke}]},{label:"Agents",items:[{section:"profile",label:"Profiles",Icon:bs},{section:"subagents",label:"Agents",Icon:He}]},{label:"System",items:[{section:"dataset-storage",label:"Dataset Storage",Icon:bn},{section:"remote",label:"Remote Access",Icon:ot},{section:"diagnostics",label:"Diagnostics",Icon:dn}]}];function Ma({section:s,onBack:t,onSectionChange:a}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back","aria-label":"Back to app",onClick:t,children:[e.jsx(zt,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Ua.map((n,i)=>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:r,label:u,Icon:d})=>e.jsxs("button",{className:`settings-nav-item ${s===r?"active":""}`,onClick:()=>a(r),children:[e.jsx(d,{size:16}),e.jsx("span",{children:u})]},r))]},n.label??`settings-${i}`))})]})}function za({catalog:s,connection:t,onCatalog:a,onError:n,onOpenExtension:i,onToast:r}){const[u,d]=l.useState(""),[c,m]=l.useState(""),[o,f]=l.useState(null),[p,g]=l.useState(null),[j,v]=l.useState(null),x=l.useCallback(h=>{const S=h instanceof Error?h.message:String(h);v(S),n(S),r?.(S,"error")},[n,r]),N=l.useCallback(()=>{v(null),n(null)},[n]),k=l.useCallback(async h=>{if(h?.preventDefault(),!(!t||!u.trim()||p)){N(),g("preview");try{const S=await U.extensionPreview(t,{source:u.trim(),...c.trim()?{ref:c.trim()}:{}});f(S)}catch(S){f(null),x(S)}finally{g(null)}}},[p,N,t,x,c,u]),I=l.useCallback(async()=>{if(!(!t||!o||p)){N(),g("install");try{const h=await U.extensionAdd(t,{source:o.repositoryUrl,ref:o.requestedRef});a(h.catalog),d(""),m(""),f(null),r?.(`Installed ${h.extension.owner}/${h.extension.repo}.`,"success")}catch(h){x(h)}finally{g(null)}}},[p,N,t,a,r,o,x]),$=l.useCallback(async h=>{if(!(!t||p)){N(),g(`update:${h.id}`);try{const S=await U.extensionUpdate(t,h);a(S.catalog);const C=S.extension.resolvedCommit===h.resolvedCommit&&S.extension.packageHash===h.packageHash;r?.(C?`${h.owner}/${h.repo} is already current.`:`Updated ${h.owner}/${h.repo}.`,"success")}catch(S){x(S)}finally{g(null)}}},[p,N,t,a,r,x]),y=l.useCallback(async()=>{if(!(!t||p||s.extensions.length===0)){N(),g("update-all");try{const h=await U.extensionUpdateAll(t);a(h.catalog);const S=`Updated ${h.updated.length}; ${h.unchanged.length} already current${h.failed.length?`; ${h.failed.length} failed`:""}.`;r?.(S,h.failed.length?"error":"success"),h.failed.length&&v(h.failed.map(C=>C.error).join(" "))}catch(h){x(h)}finally{g(null)}}},[p,s.extensions.length,N,t,a,r,x]),R=l.useCallback(async h=>{if(!(!t||p)&&window.confirm(`Remove ${h.owner}/${h.repo} and its ${h.skills.length} installed skill${h.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){N(),g(`remove:${h.id}`);try{const S=await U.extensionRemove(t,h);a(S.catalog),r?.(`Removed ${h.owner}/${h.repo}.`,"success")}catch(S){x(S)}finally{g(null)}}},[p,N,t,a,r,x]),O=l.useCallback(h=>{d(h),f(null),v(null)},[]),A=l.useCallback(h=>{m(h),f(null),v(null)},[]);return e.jsxs("div",{className:"account-list native-skills-list github-extensions-list",children:[e.jsxs("div",{className:"account-list-heading github-extensions-heading",children:[e.jsx("span",{children:"Third-party extensions"}),e.jsxs("div",{className:"github-extensions-heading-actions",children:[e.jsxs("small",{children:[s.extensions.length," installed from GitHub"]}),e.jsxs("button",{className:"settings-secondary compact",disabled:!t||p!==null||s.extensions.length===0,type:"button",onClick:()=>{y()},children:[p==="update-all"?e.jsx(Me,{className:"settings-spin",size:13}):e.jsx(de,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:h=>{k(h)},children:[e.jsxs("div",{className:"github-extension-add-copy",children:[e.jsx("strong",{children:"Add a GitHub skill pack"}),e.jsx("span",{children:"Use a skills-CLI-compatible owner/repo or GitHub URL. OpenPond installs it locally without running setup code."})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{disabled:!t||p!==null,placeholder:"owner/repo",value:u,onChange:h=>O(h.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!t||p!==null,placeholder:"Default branch",value:c,onChange:h=>A(h.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!u.trim()||p!==null,type:"submit",children:[p==="preview"?e.jsx(Me,{className:"settings-spin",size:14}):e.jsx(cs,{size:14}),p==="preview"?"Checking":"Preview"]})]}),j||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:j??s.error}):null,o?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[o.owner,"/",o.repo]}),e.jsxs("span",{children:[o.skills.length," skill",o.skills.length===1?"":"s"," at ",o.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:o.skills.map(h=>e.jsx("span",{children:h.name},h.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:p!==null,type:"button",onClick:()=>{I()},children:[p==="install"?e.jsx(Me,{className:"settings-spin",size:14}):e.jsx(Ne,{size:14}),p==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(h=>{const S=p===`update:${h.id}`,C=p===`remove:${h.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${h.owner}/${h.repo} extension source`,className:"github-extension-open",disabled:!t||p!==null,type:"button",onClick:()=>i(h),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.jsxs("strong",{children:[h.owner,"/",h.repo]}),e.jsx("span",{children:h.skills.map(w=>w.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[h.skills.length," skill",h.skills.length===1?"":"s"]}),e.jsxs("span",{children:[h.requestedRef," · ",h.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${h.validationStatus==="valid"?"":"invalid"}`,children:h.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(st,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${h.owner}/${h.repo}`,className:"settings-icon-button ghost",disabled:p!==null,title:"Update extension",type:"button",onClick:()=>{$(h)},children:S?e.jsx(Me,{className:"settings-spin",size:14}):e.jsx(de,{size:14})}),e.jsx("button",{"aria-label":`Remove ${h.owner}/${h.repo}`,className:"settings-icon-button ghost danger",disabled:p!==null,title:"Remove extension",type:"button",onClick:()=>{R(h)},children:C?e.jsx(Me,{className:"settings-spin",size:14}):e.jsx(Qe,{size:14})})]})]},h.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function Ha({onOpenSkill:s,onOpenExtension:t,personalSkills:a,extensionCatalog:n,connection:i,onExtensionCatalog:r,onError:u,onToast:d}){return e.jsxs("section",{className:"account-settings skills-settings","aria-labelledby":"skills-settings-title",children:[e.jsx("header",{className:"skills-settings-header",children:e.jsxs("div",{children:[e.jsx("h1",{id:"skills-settings-title",children:"Skills"}),e.jsx("p",{children:"Install third-party GitHub packs, inspect personal Codex skills, and view instructions bundled with OpenPond."})]})}),e.jsx(za,{catalog:n,connection:i,onCatalog:r,onError:u,onOpenExtension:t,onToast:d}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Personal Codex skills"}),e.jsx("small",{children:"Discovered from your local Codex skills folder"})]}),a.length?a.map(c=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Ke,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:c.name}),e.jsx("span",{children:c.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:c.resourceFiles.length?`${c.resourceFiles.length} packaged resource${c.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:c.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${c.validationStatus==="valid"?"":"invalid"}`,children:c.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},c.sourcePath)):e.jsx("div",{className:"skills-settings-empty",children:"No personal Codex skills found."})]}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"App integration skills"}),e.jsx("small",{children:"Bundled with this OpenPond build"})]}),_t.map(c=>{const m=Ft(c.provider)?.label??c.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(c),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Ke,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:c.name}),e.jsx("span",{children:c.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:m}),e.jsx("span",{children:c.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(st,{size:16,"aria-hidden":"true"})]},c.name)})]})]})}const gs="default";function Ba({connection:s,embedded:t=!1,onError:a,onPreferences:n,preferences:i,providers:r}){const u=i.training,[d,c]=l.useState(is(u.defaultModelRef)),[m,o]=l.useState(u.creationMode),[f,p]=l.useState(u.autoApproveEvidence),[g,j]=l.useState(!1),v=l.useMemo(()=>Zs(r,{includeUnavailable:!0}),[r]),x=l.useMemo(()=>v.map(y=>({provider:y,models:ms(y.value,r)})).filter(y=>y.models.length>0),[v,r]),N=_a(d),k=Wt(i.defaultChatProvider,i.defaultChatModel,r)?` · ${Fa(i.codexReasoningEffort)} reasoning`:"",I=Wa(N,u.defaultModelRef??null)&&m===u.creationMode&&f===u.autoApproveEvidence;l.useEffect(()=>{c(is(u.defaultModelRef)),o(u.creationMode),p(u.autoApproveEvidence)},[i.defaultChatModel,i.defaultChatProvider,u.autoApproveEvidence,u.creationMode,u.defaultModelRef]);async function $(y){if(y.preventDefault(),!!s){j(!0),a(null);try{n(await U.savePreferences(s,{training:{defaultModelRef:N,creationMode:m,autoApproveEvidence:f}}))}catch(R){a(R instanceof Error?R.message:String(R))}finally{j(!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:y=>{$(y)},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:d,disabled:g,onChange:y=>c(y.target.value),children:[e.jsxs("option",{value:gs,children:["Use chat default — ",rs(i.defaultChatProvider,r)," · ",vs(i.defaultChatModel,r,i.defaultChatProvider),k]}),x.map(y=>e.jsx("optgroup",{label:y.provider.label,children:y.models.map(R=>e.jsx("option",{value:is({providerId:y.provider.value,modelId:R.value}),children:R.label},R.value))},y.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:m,disabled:g,onChange:y=>o(y.target.value),children:[e.jsx("option",{value:"customize",children:"Guided plan — review and revise before materializing"}),e.jsx("option",{value:"defaults",children:"Fast draft — use reversible defaults"})]})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Evidence confirmation"}),e.jsx("small",{children:"Controls the first authoring gate; materialization and training remain separate"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:f,disabled:g,onChange:y=>p(y.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Skip evidence confirmation"}),e.jsx("small",{children:"Immediately send excerpts from explicitly selected chats to the authoring model. This never approves Taskset materialization or training spend."})]})]}),e.jsx("button",{className:"settings-primary",disabled:g||I,children:e.jsx("span",{children:g?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:N?`${rs(N.providerId,r)} / ${vs(N.modelId,r,N.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 is(s){return s?JSON.stringify([s.providerId,s.modelId]):gs}function _a(s){if(s===gs)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 Fa(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function Wa(s,t){return s?.providerId===t?.providerId&&s?.modelId===t?.modelId}function qa({disabled:s,onChange:t,storageRoots:a,value:n}){const i=l.useId(),[r,u]=l.useState(!1),d=Ws(n),c=f=>f.datasetStorePath,m="Dataset",o=a.find(f=>Ws(c(f))===d)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:i,children:[m," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${m} storage drive`,className:"model-storage-select",disabled:s,id:i,title:n??"No Dataset storage configured",value:n??"",onChange:f=>t(f.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),n&&!o?e.jsx("option",{value:n,children:"Manual location"}):null,a.map(f=>e.jsxs("option",{disabled:!f.mounted||!f.writable,title:c(f),value:c(f),children:[f.label," · ",Ja(f.kind)," · ",Ya(f)]},f.id))]}),e.jsx("button",{className:"settings-icon-button model-storage-add",disabled:s,type:"button",title:"Add manual location","aria-label":"Add manual Dataset storage location",onClick:()=>u(!0),children:e.jsx(Ne,{size:15})})]}),r?Ga(e.jsx(Va,{initialPath:n??"",purpose:"dataset",onClose:()=>u(!1),onUse:f=>{t(f),u(!1)}})):null]})}function Ga(s){return typeof document>"u"?s:qt.createPortal(s,document.body)}function Va({initialPath:s,onClose:t,onUse:a,purpose:n="model"}){const i=l.useId(),[r,u]=l.useState(s),d=Ka(r);l.useEffect(()=>{const m=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);function c(m){m.preventDefault(),m.stopPropagation(),!d&&a(r.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:m=>{m.target===m.currentTarget&&t()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":i,onSubmit:c,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${n} storage`,onClick:t,children:e.jsx(pe,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(hn,{size:18})}),e.jsxs("h2",{id:i,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:r,placeholder:n==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:m=>u(m.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."}),r.trim()&&d?e.jsx("div",{className:"profile-dialog-warning",children:d}):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:!!d,type:"submit",children:"Use location"})]})]})})}function Ka(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 Ja(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function Ya(s){return s.mounted?s.writable?`${Qa(s.freeBytes)} free`:"Read only":"Not mounted"}function Ws(s){const t=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(t)?t.toLowerCase():t}function Qa(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 Xa({state:s,catalog:t,busy:a,catalogLoading:n,onRefresh:i,onSave:r}){const[u,d]=l.useState(s?.settings.datasetStorePath??null);l.useEffect(()=>{d(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const c=l.useMemo(()=>s?.storageRoots.find(p=>qs(p.datasetStorePath)===qs(u))??null,[u,s?.storageRoots]),m=u===(s?.settings.datasetStorePath??null),o=t?.datasets??[];async function f(p){p.preventDefault(),await r(u)}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:()=>{i()},title:"Refresh Dataset storage",type:"button",children:e.jsx(de,{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:c?.label??(u?"Manual location":"Not configured")}),e.jsx("small",{children:u??"Choose a writable local or mounted location before importing a Dataset."}),c?e.jsxs("small",{children:[ti(c.kind)," · ",c.freeBytes==null?"Free space unknown":`${mt(c.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:p=>{f(p)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(qa,{disabled:a!==null,onChange:d,storageRoots:s?.storageRoots??[],value:u}),e.jsx("button",{className:"settings-primary",disabled:a!==null||m,children:a==="save"?"Saving":"Save Dataset storage"})]}),e.jsxs("div",{className:"account-list dataset-storage-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Registered Datasets"}),e.jsx("small",{children:o.length})]}),o.length?o.map(p=>e.jsx(Za,{dataset:p},p.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:n?"Loading registered Datasets":"No registered Datasets"})})]})]})}function Za({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:[pt(s.rowCount)," rows"," · ",ei(s)," · ",t," · ",s.sizeBytes==null?"Size unavailable":mt(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?si(s.status):"Unavailable"})]})}function ei(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])=>`${pt(Number(n))} ${a}`).join(" · ")||"No split rows"}function mt(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 pt(s){return new Intl.NumberFormat().format(s)}function qs(s){return s?.replace(/[\\/]+$/,"")??""}function si(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function ti(s){return s.replace(/^./,t=>t.toUpperCase())}function _e(s){if(!s)return"Not yet";const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function $e(s){return s?s.slice(0,10):"none"}function Re(s){const t=s.replaceAll("_"," ");return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function ni(s){return s==="unresolved"?"Watching":s==="confirmed"?"Ready for Refiner":Re(s)}function ai({review:s}){const t=[["Taskset",s.tasksetProposal],["Baseline evaluation",s.evaluation],["Training qualification",s.trainingQualification]];return e.jsx("div",{className:"harness-review-lineage","aria-label":"Review lineage",children:t.map(([a,n])=>e.jsxs("div",{className:n?"linked":"pending",children:[e.jsx("span",{children:a}),e.jsx("code",{children:n?$e(n.contentHash):"Not created"})]},a))})}function ii({candidate:s}){return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${s.status}`,children:ni(s.status)}),e.jsx("strong",{children:s.statement}),e.jsxs("small",{children:[s.occurrences.length," occurrence",s.occurrences.length===1?"":"s"]}),e.jsx("time",{children:_e(s.updatedAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:s.resolution?.reason??s.recurrenceFamily}),e.jsxs("dl",{className:"harness-compact-metadata",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Pattern"}),e.jsx("dd",{children:s.recurrenceFamily})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Fingerprint"}),e.jsx("dd",{children:e.jsx("code",{children:$e(s.fingerprint)})})]})]}),s.occurrences.length?e.jsxs("details",{className:"harness-history-details",children:[e.jsx("summary",{children:"Evidence receipts"}),e.jsx("ul",{className:"harness-evidence-list",children:s.occurrences.map(t=>e.jsxs("li",{children:[e.jsx("span",{children:Re(t.kind)}),e.jsx("code",{children:$e(t.evidence.contentHash)}),e.jsx("time",{children:_e(t.occurredAt)})]},`${t.evidence.id}:${t.evidence.contentHash}`))})]}):null]})]})}function li({accepting:s,onAcceptTasksetReview:t,review:a}){const n=a.classification==="taskset"&&a.nextAuthority==="human_review"&&a.tasksetProposal===null;return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${a.classification}`,children:Re(a.classification)}),e.jsx("strong",{children:a.claim?.statement??a.reason}),e.jsxs("small",{children:[a.selectedEvidence.length," selected"]}),e.jsx("time",{children:_e(a.createdAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:a.reason}),e.jsxs("div",{className:"harness-review-metrics",children:[e.jsxs("span",{children:[e.jsx("strong",{children:a.selectedEvidence.length})," selected"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.excludedEvidence.length})," excluded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.claim?.independentOccurrences??0})," independent occurrences"]}),e.jsxs("span",{children:["Next: ",e.jsx("strong",{children:Re(a.nextAuthority)})]})]}),e.jsx(ai,{review:a}),n?e.jsx("div",{className:"harness-history-actions",children:e.jsx("button",{className:"settings-primary compact",disabled:s,onClick:()=>t(a),type:"button",children:s?"Opening Taskset review…":"Build training Taskset"})}):null]})]})}function ri({receipt:s}){return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${s.decision}`,children:Re(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsxs("small",{children:[Re(s.signal.strength)," signal"]}),e.jsx("time",{children:_e(s.createdAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:s.reasons.join(" ")}),e.jsxs("dl",{className:"harness-compact-metadata",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Review"}),e.jsx("dd",{children:e.jsx("code",{children:$e(s.review.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Taskset"}),e.jsx("dd",{children:e.jsx("code",{children:$e(s.tasksetRelease?.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Baseline"}),e.jsx("dd",{children:e.jsx("code",{children:$e(s.baselineEvaluation?.contentHash)})})]})]})]})]})}function oi({acceptingReviewId:s,candidates:t,onAcceptTasksetReview:a,qualifications:n,reviews:i,schedule:r}){const u=r.activityEnabled||r.enabled;return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx("section",{className:"harness-history-section","aria-label":"Continuous Review status",children:e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-review-status-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Trigger"}),e.jsx("th",{children:"Last review"}),e.jsx("th",{children:"Last result"})]})}),e.jsx("tbody",{children:e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:`harness-status ${u?"harness-status-advanced":""}`,children:u?"On":"Off"})}),e.jsx("td",{children:r.activityEnabled?`${r.activityBatchSize} new outcomes`:"Manual only"}),e.jsx("td",{children:_e(r.lastRunAt)}),e.jsx("td",{children:r.lastResult?Re(r.lastResult.classification):"No completed review"})]})})]})})}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Patterns"}),e.jsx("p",{children:"Recurring evidence being watched or ready for the Refiner."})]}),e.jsx("span",{children:t.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:t.length?t.map(d=>e.jsx(ii,{candidate:d},`${d.id}:${d.contentHash}`)):e.jsx("div",{className:"harness-empty compact",children:"No recurring patterns are being tracked."})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Review history"}),e.jsx("p",{children:"Receipts stay compact; expand one for evidence and downstream lineage."})]}),e.jsx("span",{children:i.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:i.length?i.map(d=>e.jsx(li,{accepting:s===d.id,onAcceptTasksetReview:a,review:d},`${d.id}:${d.contentHash}`)):e.jsx("div",{className:"harness-empty compact",children:"No Continuous Review receipts yet."})})]}),n.length?e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Training handoffs"}),e.jsx("p",{children:"Evidence-bound qualification receipts created for Models."})]}),e.jsx("span",{children:n.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:n.map(d=>e.jsx(ri,{receipt:d},`${d.id}:${d.contentHash}`))})]}):null]})}const ci="Update the Refiner Review Profile. Inspect the current profile first, ask what should change if it is not already clear, and show the exact release transition.";function Gs(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Ee(s){return s?s.slice(0,10):"none"}function di({busyReleaseHash:s,history:t,onRequestRelease:a,onStartAuthoring:n}){const i=l.useMemo(()=>{const r=new Map;for(const u of t.transitions)r.has(u.nextRelease.contentHash)||r.set(u.nextRelease.contentHash,u);return r},[t.transitions]);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Review Profile"}),e.jsx("p",{children:"Separately versioned policy composed with the immutable Refiner Core."})]}),n?e.jsx("button",{className:"settings-primary compact",onClick:()=>n(ci),type:"button",children:"Edit with Work"}):null]}),e.jsxs("div",{className:"harness-summary-grid",children:[e.jsxs("article",{children:[e.jsx("span",{children:"Active release"}),e.jsx("strong",{children:Ee(t.binding.release.contentHash)}),e.jsxs("small",{children:["Binding revision ",t.binding.revision]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Profile"}),e.jsx("strong",{children:t.currentRelease.profile.name}),e.jsxs("small",{children:[t.currentRelease.profile.id,"@",t.currentRelease.profile.version]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Core"}),e.jsx("strong",{children:t.currentRelease.coreVersion}),e.jsx("small",{children:Ee(t.currentRelease.coreHash)})]})]}),e.jsx("p",{children:t.currentRelease.profile.objective}),t.currentRelease.profile.instructions.length?e.jsx("div",{className:"harness-edit-list",children:t.currentRelease.profile.instructions.map(r=>e.jsx("section",{className:"harness-edit",children:e.jsxs("div",{children:[e.jsx("strong",{children:r.id}),e.jsx("span",{children:r.text})]})},r.id))}):e.jsx("div",{className:"harness-empty compact",children:"The default profile adds no instructions beyond the Refiner Core."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Profile releases"}),e.jsx("p",{children:"Immutable definition history. Rollback changes future reviews only."})]}),e.jsx("span",{children:t.releases.length})]}),e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Profile"}),e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:t.releases.map(r=>{const u=r.contentHash===t.binding.release.contentHash,d=!u&&i.get(r.contentHash)?.bindingChanged===!1,c=d?"activate":"rollback";return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("strong",{children:r.profile.name}),e.jsxs("small",{children:[r.profile.id,"@",r.profile.version," · ",r.profile.instructions.length," instructions"]})]}),e.jsx("td",{children:e.jsx("code",{children:Ee(r.contentHash)})}),e.jsx("td",{children:Gs(r.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:u?"active":d?"draft":"immutable"})}),e.jsx("td",{children:u?null:e.jsx("button",{"aria-label":`${d?"Activate":"Roll back"} Refiner release`,className:"harness-table-icon-action",disabled:s!==null,onClick:()=>a(r,c),title:`${d?"Activate":"Roll back"} Refiner release`,type:"button",children:d?e.jsx(ps,{size:14}):e.jsx(Ye,{size:14})})})]},r.contentHash)})})]})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Definition changes"}),e.jsx("p",{children:"Receipts record which release changed, why, and which authoring Skill produced it."})]}),e.jsx("span",{children:t.transitions.length})]}),e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Operation"}),e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Release transition"}),e.jsx("th",{children:"Validation"}),e.jsx("th",{children:"Created"})]})}),e.jsx("tbody",{children:t.transitions.map(r=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("span",{className:"harness-status",children:[r.operation,r.bindingChanged?" · active":" · draft"]})}),e.jsxs("td",{children:[e.jsx("strong",{children:r.reason}),e.jsx("small",{children:r.authoringSkillHash?`Skill ${Ee(r.authoringSkillHash)}`:r.actor})]}),e.jsx("td",{children:e.jsxs("code",{children:[Ee(r.previousRelease?.contentHash)," → ",Ee(r.nextRelease.contentHash)]})}),e.jsx("td",{children:r.validation.valid?"Passed":r.validation.messages.join("; ")}),e.jsx("td",{children:Gs(r.createdAt)})]},r.contentHash))})]})})]})]})}const ui={enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},hi={overview:{title:"Harness overview",description:"Current state, items needing attention, and recent learning activity."},refiner:{title:"Refiner",description:"Validated per-turn improvements and recommendations routed outside the Harness."},"continuous-review":{title:"Continuous Review",description:"Recurring patterns found across completed work and their immutable review receipts."},contents:{title:"Harness contents",description:"The instructions, skills, agents, and memory available in the current release."},releases:{title:"Harness releases",description:"Immutable versions, diffs, and rollback controls."}};function Le(s){if(!s)return"Not yet";const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Te(s){return s?s.slice(0,10):"none"}function Vs(s,t,a){return{workspaceId:s,baseRelease:t?{id:t.id,contentHash:t.contentHash}:null,targetRelease:{id:a.id,contentHash:a.contentHash},title:a.current?"Current Harness release":`Harness release ${Te(a.contentHash)}`}}function mi({review:s,busy:t,onReview:a}){return e.jsxs("article",{className:"harness-history-card harness-review-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"review required"}),e.jsxs("span",{children:[s.proposal.route," · ",s.proposal.edits[0]?.operation??"change"]})]}),e.jsx("h2",{children:s.proposal.expectedOutcome})]}),e.jsx("time",{children:Le(s.proposal.createdAt)})]}),e.jsx("p",{children:s.proposal.edits.map(n=>n.summary).join(" ")}),e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Exact edits (",s.proposal.edits.length,")"]}),e.jsx("div",{className:"harness-edit-list",children:s.proposal.edits.map(n=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[n.operation," · ",n.target]}),e.jsx("span",{children:n.summary})]}),n.content!==null?e.jsx("pre",{children:n.content}):e.jsx("p",{children:"File deleted."})]},n.id))})]}),s.validations.length?e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Validation receipts (",s.validations.length,")"]}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(n=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${n.status}`,children:n.status}),e.jsx("strong",{children:n.kind.replaceAll("_"," ")}),e.jsx("span",{children:n.summary})]},n.id))})]}):null,e.jsxs("footer",{className:"harness-review-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:t,onClick:()=>a(s,"decline"),type:"button",children:[e.jsx(pe,{size:13})," Decline"]}),e.jsxs("button",{className:"settings-primary compact",disabled:t||s.validations.some(n=>n.status!=="passed"),onClick:()=>a(s,"approve"),type:"button",children:[e.jsx(ps,{size:13})," Approve and release"]})]})]})}function pi({change:s,onClose:t}){const a=s.proposal;return e.jsxs(mn,{ariaLabel:"Refiner change details",backdropClassName:"harness-details-dialog-backdrop",className:"harness-details-dialog",onClose:t,children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsx("span",{className:`harness-status harness-status-${s.receipt.decision}`,children:s.receipt.decision.replaceAll("_"," ")}),e.jsx("h2",{children:a?.expectedOutcome??s.receipt.reason}),e.jsx("p",{children:s.receipt.reason})]}),e.jsx("button",{"aria-label":"Close change details",onClick:t,type:"button",children:e.jsx(pe,{size:16})})]}),e.jsxs("div",{className:"harness-details-dialog-body",children:[a?.edits.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Exact edits"}),e.jsx("div",{className:"harness-edit-list",children:a.edits.map(n=>e.jsxs("article",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[n.operation," · ",n.target]}),e.jsx("span",{children:n.summary})]}),n.content!==null?e.jsx("pre",{children:n.content}):e.jsx("p",{children:"File deleted."})]},n.id))})]}):null,s.validations.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Validation"}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(n=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${n.status}`,children:n.status}),e.jsx("strong",{children:n.kind.replaceAll("_"," ")}),e.jsx("span",{children:n.summary})]},n.id))})]}):null]})]})}function fi({history:s,reviewingProposalId:t,onReviewProposal:a}){const n=l.useMemo(()=>[...s.changes.map(i=>({id:`change:${i.receipt.id}`,at:i.receipt.createdAt,kind:"Refiner",title:i.proposal?.expectedOutcome??i.receipt.reason,detail:i.receipt.decision.replaceAll("_"," ")})),...s.routes.map(i=>({id:`route:${i.decision.id}`,at:i.decision.createdAt,kind:"Routed",title:i.decision.reason,detail:i.decision.route})),...s.evaluationReviews.map(i=>({id:`review:${i.id}`,at:i.createdAt,kind:"Continuous Review",title:i.claim?.statement??i.reason,detail:i.classification.replaceAll("_"," ")}))].sort((i,r)=>r.at.localeCompare(i.at)).slice(0,6),[s]);return e.jsxs("div",{className:"harness-page-sections",children:[s.pendingReviews.length?e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Needs review"}),e.jsx("p",{children:"Sensitive or high-impact proposals require your approval."})]}),e.jsx("span",{children:s.pendingReviews.length})]}),s.pendingReviews.map(i=>e.jsx(mi,{busy:t!==null,onReview:a,review:i},`${i.proposal.id}:${i.proposal.contentHash}`))]}):null,e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Recent activity"}),e.jsx("p",{children:"The latest events from both learning loops."})]}),e.jsx("span",{children:n.length})]}),n.length?e.jsx("div",{className:"harness-activity-list",children:n.map(i=>e.jsxs("article",{children:[e.jsx("span",{children:i.kind}),e.jsxs("div",{children:[e.jsx("strong",{children:i.title}),e.jsx("small",{children:i.detail})]}),e.jsx("time",{children:Le(i.at)})]},i.id))}):e.jsx("div",{className:"harness-empty compact",children:"No Harness learning activity yet."})]})]})}function gi({history:s,refiner:t,busyReleaseHash:a,onRequestRefinerRelease:n,onStartRefinerAuthoring:i,onOpenChangeDiff:r,onOpenSourceSession:u}){const[d,c]=l.useState(null);return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx(di,{busyReleaseHash:a,history:t,onRequestRelease:n,onStartAuthoring:i}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Applied changes"}),e.jsx("p",{children:"Every release transition with exact edits and validation receipts."})]}),e.jsx("span",{children:s.changes.length})]}),s.changes.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-refiner-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Target"}),e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Result"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:s.changes.map(m=>{const o=m.trigger?.runRef??null,f=m.proposal;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:f?.expectedOutcome??m.receipt.reason})}),e.jsx("td",{children:e.jsx("code",{children:f?.edits[0]?.target??f?.route??"workspace"})}),e.jsx("td",{children:e.jsx("code",{children:Te(m.receipt.nextRelease?.contentHash)})}),e.jsx("td",{children:Le(m.receipt.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`harness-status harness-status-${m.receipt.decision}`,children:m.receipt.decision.replaceAll("_"," ")})}),e.jsx("td",{children:e.jsxs("div",{className:"harness-inline-actions",children:[e.jsx("button",{"aria-label":"View evidence and exact edits",className:"harness-table-icon-action",onClick:()=>c(m),title:"View evidence and exact edits",type:"button",children:e.jsx(jn,{size:14})}),m.receipt.nextRelease?e.jsx("button",{"aria-label":"View release diff",className:"harness-table-icon-action",onClick:()=>r(m),title:"View release diff",type:"button",children:e.jsx(rt,{size:14})}):null,o&&u?e.jsx("button",{"aria-label":"Open source conversation",className:"harness-table-icon-action",onClick:()=>u(o),title:"Open source conversation",type:"button",children:e.jsx(et,{size:14})}):null]})})]},`${m.receipt.id}:${m.receipt.contentHash}`)})})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness changes have been applied."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Routed recommendations"}),e.jsx("p",{children:"Observations sent to runtime, product, Tasksets, or training without mutating the Harness."})]}),e.jsx("span",{children:s.routes.length})]}),s.routes.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-route-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Recommendation"}),e.jsx("th",{children:"Source evidence"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Route"})]})}),e.jsx("tbody",{children:s.routes.map(m=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("p",{children:m.decision.reason})}),e.jsx("td",{children:e.jsx("p",{children:m.trigger?.reason??"Completed work"})}),e.jsx("td",{children:Le(m.decision.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:m.decision.route})})]},`${m.decision.id}:${m.decision.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No recommendations have been routed."})]}),d?e.jsx(pi,{change:d,onClose:()=>c(null)}):null]})}function xi(s){return s.includes("/skills/")||s.startsWith("skills/")?"Skill":s.includes("/agents/")||s.startsWith("agents/")?"Agent":s.includes("memory")?"Memory":s.endsWith(".md")?"Instruction":"File"}function ji(s){return s<1024?`${s} B`:`${(s/1024).toFixed(s<10240?1:0)} KB`}function vi({history:s,onOpenCurrentRelease:t}){const a=s.releases.find(n=>n.current)??s.releases[0]??null;return e.jsxs("div",{className:"harness-page-sections",children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Current release"}),e.jsx("p",{children:"Read-only source contents currently supplied by the Personal Harness."})]}),a?e.jsx("button",{className:"settings-secondary compact",onClick:t,type:"button",children:"View release diff"}):null]}),a?.files.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Size"}),e.jsx("th",{children:"Revision"})]})}),e.jsx("tbody",{children:a.files.map(n=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:xi(n.path)})}),e.jsx("td",{children:e.jsx("code",{children:n.path})}),e.jsx("td",{children:ji(n.sizeBytes)}),e.jsx("td",{children:e.jsx("code",{children:Te(n.contentHash)})})]},n.id))})]})}):e.jsx("div",{className:"harness-empty compact",children:"The current release has no source files."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Memory"}),e.jsx("p",{children:"Bounded memory available through search; it is not copied into every prompt."})]}),e.jsx("span",{children:s.memories.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:s.memories.length?s.memories.map(n=>e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"harness-status",children:"Memory"}),e.jsx("strong",{children:n.key}),e.jsxs("small",{children:["revision ",n.revision]}),e.jsx("time",{children:Le(n.updatedAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:n.content}),n.tags.length?e.jsx("small",{children:n.tags.join(" · ")}):null]})]},`${n.id}:${n.revision}`)):e.jsx("div",{className:"harness-empty compact",children:"No Harness memory has been saved."})})]})]})}function bi({busy:s,history:t,onOpenDiff:a,onRequestRollback:n}){return e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Release history"}),e.jsx("p",{children:"New work uses the current release; active runs stay pinned to the version they started with."})]}),e.jsx("span",{children:t.releases.length})]}),t.releases.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-release-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Contents"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:t.releases.map((i,r)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:"harness-release-identity",children:[e.jsx("strong",{children:i.id}),e.jsx("code",{children:Te(i.contentHash)})]})}),e.jsxs("td",{children:[i.files.length," files"]}),e.jsx("td",{children:Le(i.createdAt)}),e.jsx("td",{children:i.current?e.jsx("span",{className:"harness-current-pill",children:"Current"}):e.jsx("span",{className:"harness-status",children:"Previous"})}),e.jsx("td",{children:e.jsxs("div",{className:"harness-inline-actions",children:[e.jsx("button",{"aria-label":"View release changes",className:"harness-table-icon-action",onClick:()=>a(t.releases[r+1]??null,i),title:"View release changes",type:"button",children:e.jsx(rt,{size:14})}),i.current?null:e.jsx("button",{"aria-label":"Roll back to release",className:"harness-table-icon-action",disabled:s,onClick:()=>n(i),title:"Roll back to release",type:"button",children:e.jsx(Ye,{size:14})})]})})]},`${i.id}:${i.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness releases exist yet."})]})}function yi({connection:s,enabled:t,onAcceptEvaluationReview:a,onError:n,onDefaultReleaseDiff:i,onOpenReleaseDiff:r,onOpenSourceSession:u,onStartRefinerAuthoring:d,onToast:c,page:m}){const[o,f]=l.useState(null),[p,g]=l.useState(null),[j,v]=l.useState(null),[x,N]=l.useState(!1),[k,I]=l.useState(null),[$,y]=l.useState(null),[R,O]=l.useState(!1),[A,h]=l.useState(!1),[S,C]=l.useState(null),{confirmAction:w,confirmDialog:M,resolveConfirmDialog:F}=Ys(),W=!!(o?.evaluationReviewSchedule.activityEnabled||o?.evaluationReviewSchedule.enabled),[se,X]=l.useState(!1),[D,Z]=l.useState(!1);l.useEffect(()=>{o&&X(o.backgroundReview.enabled)},[o?.backgroundReview.enabled]),l.useEffect(()=>{Z(W)},[W]);const te=l.useCallback(async()=>{if(s){N(!0);try{const[T,P]=await Promise.all([U.harnessHistory(s),U.refinerHistory(s)]);f(T),g(P);const H=T.releases.findIndex(ne=>ne.current),z=H>=0?T.releases[H]:null;T.workspace&&z&&i(Vs(T.workspace.id,T.releases[H+1]??null,z)),n(null)}catch(T){n(T instanceof Error?T.message:String(T))}finally{N(!1)}}},[s,i,n]);l.useEffect(()=>{t&&te()},[t,m,te]);const B=l.useCallback(async T=>{if(!(!s||!o?.workspace)){h(!0);try{const P=await U.reviewHarnessEvaluation(s,{workspaceId:o.workspace.id,maxEstimatedCostUsd:T});f(P.history),n(null),c?.(`Continuous Review completed: ${P.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(P){n(P instanceof Error?P.message:String(P))}finally{h(!1)}}},[s,o,n,c]),le=l.useCallback(async(T,P,H)=>{if(!(!s||!o?.workspace)){O(!0);try{let z=o;T==="refiner"&&P!==o.backgroundReview.enabled&&(z=(await U.updateHarnessBackgroundReview(s,{workspaceId:o.workspace.id,enabled:P})).history);const ne=o.evaluationReviewSchedule.activityEnabled||o.evaluationReviewSchedule.enabled;if(T==="continuous-review"&&(H!==ne||o.evaluationReviewSchedule.enabled)){const ce=o.evaluationReviewSchedule;z=(await U.updateHarnessEvaluationReviewSchedule(s,{workspaceId:o.workspace.id,enabled:!1,activityEnabled:H,activityBatchSize:ce.activityBatchSize,cadence:"manual",maxEstimatedCostUsd:ce.maxEstimatedCostUsd})).history}f(z),n(null),c?.(`${T==="refiner"?"Refiner":"Continuous Review"} settings applied.`,"success")}catch(z){n(z instanceof Error?z.message:String(z))}finally{O(!1)}}},[s,o,n,c]),ie=l.useCallback(async T=>{if(o?.workspace){C(T.id);try{await a(o.workspace.id,{id:T.id,contentHash:T.contentHash})&&(n(null),c?.("Taskset review opened in Models.","success"))}catch(P){n(P instanceof Error?P.message:String(P))}finally{C(null)}}},[o?.workspace,a,n,c]),V=l.useCallback((T,P)=>{o?.workspace&&r(Vs(o.workspace.id,T,P))},[o?.workspace,r]),q=l.useCallback(T=>{!o?.workspace||!T.receipt.nextRelease||r({workspaceId:o.workspace.id,baseRelease:T.receipt.previousRelease,targetRelease:T.receipt.nextRelease,title:T.proposal?.expectedOutcome??T.receipt.reason})},[o?.workspace,r]),Y=l.useCallback(async T=>{if(!(!s||!o?.workspace)){I(T.contentHash);try{const P=await U.rollbackHarness(s,{workspaceId:o.workspace.id,targetRelease:{id:T.id,contentHash:T.contentHash}});f(P.history),n(null),c?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(P){n(P instanceof Error?P.message:String(P))}finally{I(null)}}},[s,o?.workspace,n,c]),ue=l.useCallback(async T=>{await w({title:"Roll back Harness release?",body:`New work will use ${Te(T.contentHash)}. Active runs remain pinned to their current release.`,confirmLabel:"Roll back"})&&await Y(T)},[w,Y]),re=l.useCallback(async(T,P)=>{if(!(!s||!await w({title:P==="activate"?"Activate Refiner release?":"Roll back Refiner release?",body:`Future reviews will use ${T.profile.name} at ${Te(T.contentHash)}. Existing work remains pinned.`,confirmLabel:P==="activate"?"Activate":"Roll back"}))){v(T.contentHash);try{const z={release:{id:T.id,contentHash:T.contentHash},reason:`${P==="activate"?"Activate":"Rollback"} from Settings to ${T.profile.id}@${T.profile.version}.`,actor:"settings-user"};g(await(P==="activate"?U.activateRefinerRelease(s,z):U.rollbackRefinerRelease(s,z))),n(null),c?.(`Refiner ${P==="activate"?"activated":"rolled back"}. Existing work remains pinned.`,"success")}catch(z){n(z instanceof Error?z.message:String(z))}finally{v(null)}}},[w,s,n,c]),oe=l.useCallback(async(T,P)=>{if(!(!s||!o?.workspace)){y(T.proposal.id);try{const H=await U.reviewHarnessProposal(s,{workspaceId:o.workspace.id,proposal:{id:T.proposal.id,contentHash:T.proposal.contentHash},decision:P});f(H.history),n(null),c?.(P==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",P==="approve"?"success":"info")}catch(H){n(H instanceof Error?H.message:String(H))}finally{y(null)}}},[s,o?.workspace,n,c]),K=o?.releases.find(T=>T.current)??o?.releases[0]??null,Q=K?o?.releases.indexOf(K)??-1:-1,he=hi[m],ee=o?m==="refiner"?se!==o.backgroundReview.enabled:D!==W||o.evaluationReviewSchedule.enabled:!1,me=m==="refiner"||m==="continuous-review";return e.jsxs("section",{className:"account-settings harness-history-settings","aria-labelledby":"harness-history-title",children:[e.jsxs("div",{className:"account-settings-title harness-page-title",children:[e.jsxs("div",{children:[e.jsx("h1",{id:"harness-history-title",children:he.title}),e.jsx("p",{children:he.description})]}),o?.workspace&&me?e.jsxs("div",{className:"harness-page-header-actions",children:[m==="continuous-review"?e.jsx("button",{className:"settings-secondary compact",disabled:A,onClick:()=>{B(o.evaluationReviewSchedule.maxEstimatedCostUsd)},type:"button",children:A?"Reviewing…":"Review now"}):null,e.jsxs("label",{className:"harness-page-toggle",children:[e.jsx("span",{children:m==="refiner"?se?"On":"Off":D?"On":"Off"}),e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{"aria-label":m==="refiner"?"Enable Refiner":"Enable Continuous Review",checked:m==="refiner"?se:D,disabled:R,onChange:T=>m==="refiner"?X(T.target.checked):Z(T.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("button",{className:"settings-primary compact",disabled:R||!ee,onClick:()=>{le(m,se,D)},type:"button",children:R?"Applying…":"Apply changes"})]}):null]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&x&&!o?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,o&&!o.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,o?.workspace&&m==="overview"?e.jsx(fi,{history:o,onReviewProposal:oe,reviewingProposalId:$}):null,o&&p&&m==="refiner"?e.jsx(gi,{busyReleaseHash:j,history:o,refiner:p,onOpenChangeDiff:q,onOpenSourceSession:u,onRequestRefinerRelease:(T,P)=>{re(T,P)},onStartRefinerAuthoring:d}):null,o?.workspace&&m==="continuous-review"?e.jsx(oi,{acceptingReviewId:S,candidates:o.refinementCandidates,onAcceptTasksetReview:T=>{ie(T)},qualifications:o.modelImprovementQualifications,reviews:o.evaluationReviews,schedule:o.evaluationReviewSchedule??ui}):null,o?.workspace&&m==="contents"?e.jsx(vi,{history:o,onOpenCurrentRelease:()=>{K&&V(Q>=0?o.releases[Q+1]??null:null,K)}}):null,o?.workspace&&m==="releases"?e.jsx(bi,{busy:k!==null,history:o,onOpenDiff:V,onRequestRollback:T=>{ue(T)}}):null,e.jsx(Xs,{onResolve:F,state:M})]})}function Ks(s){return s?s.slice(0,10):"initial"}function Ni({connection:s,expanded:t,onResizeStart:a,onToggleExpanded:n,selection:i}){const[r,u]=l.useState(null),[d,c]=l.useState(null),[m,o]=l.useState(!0),f=l.useCallback(async()=>{c(null),o(!0);try{u(await U.harnessReleaseDiff(s,i))}catch(j){u(null),c(j instanceof Error?j.message:String(j))}finally{o(!1)}},[s,i]);l.useEffect(()=>{f()},[f]);const p=l.useMemo(()=>r?{appId:`harness:${i.workspaceId}`,repoPath:i.title,initialized:!0,dirty:r.filesChanged>0,filesChanged:r.filesChanged,additions:r.additions,deletions:r.deletions,repoFiles:r.files.map(j=>j.path),files:r.files,error:null,updatedAt:""}:null,[r,i.title,i.workspaceId]),g=`${i.title} · ${Ks(i.baseRelease?.contentHash)} → ${Ks(i.targetRelease.contentHash)}`;return e.jsx(pn,{appId:`harness:${i.workspaceId}`,workspaceId:`harness:${i.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:p,editorPreferences:null,expanded:t,filesWithPreview:!0,loading:m,onOpenBrowserUrl:()=>{},onRefresh:f,onResizeStart:a,onToggleExpanded:n,readOnly:!0,workspaceError:d,workspaceInitialized:!0,workspaceName:g})}function Si({connection:s,onError:t,onPayload:a}){const[n,i]=l.useState(!1),[r,u]=l.useState(!1);async function d(f,p){if(s){i(!0),t(null);try{const g=await U.switchOpenPondAccount(s,{handle:f,baseUrl:p??null});a(g)}catch(g){t(g instanceof Error?g.message:String(g))}finally{i(!1)}}}async function c(f,p){if(!s)return!1;i(!0),t(null);try{const g=await U.removeOpenPondAccount(s,{handle:f,baseUrl:p??null});return a(g),!0}catch(g){return t(g instanceof Error?g.message:String(g)),!1}finally{i(!1)}}async function m(f){if(!(!s||!f.apiKey.trim())){i(!0),t(null);try{const p=f.handle?.trim(),g=f.environment?.trim(),j=await U.saveOpenPondAccount(s,{apiKey:f.apiKey.trim(),handle:p||void 0,baseUrl:f.baseUrl,apiBaseUrl:f.apiBaseUrl,environment:g||"custom",setActive:!0});a(j)}catch(p){throw t(p instanceof Error?p.message:String(p)),p}finally{i(!1)}}}async function o(){if(s){u(!0),t(null);try{a(await U.refreshOpenPondAccounts(s))}catch(f){t(f instanceof Error?f.message:String(f))}finally{u(!1)}}}return{refreshingAccounts:r,saving:n,refreshAccounts:o,removeAccount:c,saveAccount:m,switchAccount:d}}function wi({connection:s,onError:t,onPreferences:a,preferences:n,providers:i}){const[r,u]=l.useState(n.defaultBranchPrefix),[d,c]=l.useState(n.defaultNewProjectDirectory),[m,o]=l.useState(n.advancedWorkspaceControls),[f,p]=l.useState(n.steerActiveResponses),[g,j]=l.useState(n.contextCompaction.autoEnabled),[v,x]=l.useState(n.subagents.enabled),[N,k]=l.useState(n.subagents.delegationMode),[I,$]=l.useState(!n.subagents.defaultModelRef),[y,R]=l.useState(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),[O,A]=l.useState(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),[h,S]=l.useState(n.subagents.roles),[C,w]=l.useState(n.subagents.maxConcurrentRuns),[M,F]=l.useState(n.subagents.maxConcurrentRunsPerProvider),[W,se]=l.useState(n.subagents.maxConcurrentRunsPerWorkspaceTarget),[X,D]=l.useState(!1),Z=I?null:{providerId:y,modelId:O.trim()},te=v!==n.subagents.enabled||N!==n.subagents.delegationMode||!ki(Z,n.subagents.defaultModelRef)||C!==n.subagents.maxConcurrentRuns||M!==n.subagents.maxConcurrentRunsPerProvider||W!==n.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(h)!==JSON.stringify(n.subagents.roles);l.useEffect(()=>{u(n.defaultBranchPrefix),c(n.defaultNewProjectDirectory),o(n.advancedWorkspaceControls),p(n.steerActiveResponses),j(n.contextCompaction.autoEnabled),x(n.subagents.enabled),k(n.subagents.delegationMode),$(!n.subagents.defaultModelRef),R(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),A(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),S(n.subagents.roles),w(n.subagents.maxConcurrentRuns),F(n.subagents.maxConcurrentRunsPerProvider),se(n.subagents.maxConcurrentRunsPerWorkspaceTarget)},[n.defaultChatProvider,n.defaultChatModel,n.defaultBranchPrefix,n.defaultNewProjectDirectory,n.advancedWorkspaceControls,n.steerActiveResponses,n.contextCompaction.autoEnabled,n.subagents]);function B(P){R(P),A(H=>Gt(P,H,i))}function le(){return I?n.defaultChatProvider:y}function ie(){return I?n.defaultChatModel:O}function V(P,H){S(z=>z.map(ne=>ne.id===P?H(ne):ne))}function q(P,H){V(P,z=>({...z,enabled:H}))}function Y(P,H){V(P,z=>({...z,background:H}))}function ue(P,H){V(P,z=>{if(H)return{...z,modelRef:null};const ne=z.modelRef?.providerId??le(),ce=z.modelRef?.modelId??ie();return{...z,modelRef:es(ne,ce,i)??null}})}function re(P,H){V(P,z=>({...z,modelRef:es(H,z.modelRef?.modelId??ie(),i)??null}))}function oe(P,H){V(P,z=>{const ne=z.modelRef?.providerId??le(),ce=H.trim();return{...z,modelRef:ce?{providerId:ne,modelId:ce}:null}})}function K(P,H){V(P,z=>({...z,isolationMode:H}))}function Q(P,H){V(P,z=>({...z,toolPolicy:H}))}function he(P,H){V(P,z=>({...z,peerMessages:H}))}function ee(P,H){V(P,z=>({...z,maxConcurrentRuns:ke(H,1,16)}))}async function me(){let P=null;if(window.openpond?.selectFolder){const H=await window.openpond.selectFolder();if(H.canceled)return;P=H.path}else P=window.prompt("Default new project directory",d);P?.trim()&&c(P.trim())}async function T(P){if(P.preventDefault(),!!s){D(!0),t(null);try{a(await U.savePreferences(s,{defaultBranchPrefix:ls(r),defaultNewProjectDirectory:d.trim(),advancedWorkspaceControls:m,steerActiveResponses:f,contextCompaction:{...n.contextCompaction,autoEnabled:g},subagents:{enabled:v,workspaceDefaultsVersion:n.subagents.workspaceDefaultsVersion,toolDefaultsVersion:n.subagents.toolDefaultsVersion,delegationMode:N,defaultModelRef:I?null:es(y,O,i)??null,roles:h,maxConcurrentRuns:ke(C,1,32),maxConcurrentRunsPerProvider:M===null?null:ke(M,1,32),maxConcurrentRunsPerWorkspaceTarget:W===null?null:ke(W,1,32)}}))}catch(H){t(H instanceof Error?H.message:String(H))}finally{D(!1)}}}return{advancedWorkspaceControls:m,steerActiveResponses:f,contextCompactionAutoEnabled:g,defaultBranchPrefix:r,defaultNewProjectDirectory:d,subagentsEnabled:v,subagentDelegationMode:N,subagentsUseDefaultModel:I,subagentsProvider:y,subagentsModel:O,subagentRoles:h,subagentsMaxConcurrentRuns:C,subagentsMaxConcurrentRunsPerProvider:M,subagentsMaxConcurrentRunsPerWorkspaceTarget:W,subagentsDirty:te,saving:X,chooseDefaultProjectDirectory:me,saveDefaults:T,changeSubagentsProvider:B,changeSubagentRoleProvider:re,setAdvancedWorkspaceControls:o,setSteerActiveResponses:p,setContextCompactionAutoEnabled:j,setDefaultBranchPrefix:u,setDefaultNewProjectDirectory:c,setSubagentsUseDefaultModel:$,setSubagentsModel:A,setSubagentsEnabled:x,setSubagentDelegationMode:P=>k(P),setSubagentsMaxConcurrentRuns:P=>w(ke(P,1,32)),setSubagentsMaxConcurrentRunsPerProvider:P=>F(P===null?null:ke(P,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:P=>se(P===null?null:ke(P,1,32)),setSubagentRoleBackground:Y,setSubagentRoleEnabled:q,setSubagentRoleIsolationMode:K,setSubagentRoleMaxConcurrentRuns:ee,setSubagentRoleModel:oe,setSubagentRolePeerMessages:he,setSubagentRoleToolPolicy:Q,setSubagentRoleUseDefaultModel:ue}}function ke(s,t,a){return Number.isFinite(s)?Math.min(a,Math.max(t,Math.trunc(s))):t}function ki(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const Ci=15e3,Ri=100,Pi=100,Ai=2500;function Ii({onError:s,section:t}){const[a,n]=l.useState(null),[i,r]=l.useState(null),[u,d]=l.useState(Ri),[c,m]=l.useState([]),[o,f]=l.useState(null),[p,g]=l.useState(!0),j=l.useRef(null),[v,x]=l.useState(null),N=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),I=!!window.openpond?.readRecentLogs?`${c.length} of ${u} line${u===1?"":"s"}${p?" tailing":""}`:"Unavailable";l.useEffect(()=>{t==="diagnostics"&&$(u,"refresh",{quiet:!0})},[t]),l.useEffect(()=>{if(t!=="diagnostics"||!p||!window.openpond?.readRecentLogs)return;let S=!1;const C=window.setInterval(()=>{S||(S=!0,$(u,"refresh",{quiet:!0}).finally(()=>{S=!1}))},Ai);return()=>window.clearInterval(C)},[t,p,u]),l.useEffect(()=>{if(t!=="diagnostics"||!p)return;const S=j.current;S&&(S.scrollTop=S.scrollHeight)},[t,p,c]);async function $(S=u,C="refresh",w={}){const M=window.openpond?.readRecentLogs;if(!M){const F="Log view is not available in this runtime.";w.quiet||(x({label:"Logs",value:F,warning:!0}),s(F));return}w.quiet||r(C);try{const F=await qe(M(S),"Read logs");if(!F.ok)throw new Error(F.error);d(F.lineLimit),f(F.logDir),m(F.lines),w.quiet?x(W=>W?.label==="Logs"?null:W):x(null)}catch(F){const W=F instanceof Error?F.message:String(F);x({label:"Logs",value:W,warning:!0}),w.quiet||s(W)}finally{w.quiet||r(null)}}function y(){g(!1),$(u+Pi,"older")}function R(){const S=!p;g(S),S&&$(u,"refresh",{quiet:!0})}async function O(){const S=window.openpond?.openLogsFolder;if(!S){const C="Desktop logs are not available in this runtime.";x({label:"Logs",value:C,warning:!0}),s(C);return}n("logs"),s(null);try{const C=await qe(S(),"Open logs");if(!C.ok)throw new Error(C.error??"Could not open the logs folder.");x(null)}catch(C){const w=C instanceof Error?C.message:String(C);x({label:"Logs",value:w,warning:!0}),s(w)}finally{n(null)}}async function A(){const S=window.openpond?.copyRecentLogs;if(!S){const C="Recent log copy is not available in this runtime.";x({label:"Copy",value:C,warning:!0}),s(C);return}n("copy"),s(null);try{const C=await qe(S(1e3),"Copy recent logs");if(!C.ok)throw new Error(C.error??"Could not copy recent logs.");x({label:"Copy",value:C.lines?`Copied ${C.lines} recent log lines.`:"Copied recent logs."})}catch(C){const w=C instanceof Error?C.message:String(C);x({label:"Copy",value:w,warning:!0}),s(w)}finally{n(null)}}async function h(){const S=window.openpond?.exportDiagnostics;if(!S){const C="Diagnostics export is not available in this runtime.";x({label:"Export",value:C,warning:!0}),s(C);return}n("export"),s(null);try{const C=await qe(S(),"Export diagnostics");if(!C.ok)throw new Error(C.error??"Could not export diagnostics.");x({label:"Export",value:C.path?`Saved to ${C.path}`:"Diagnostics exported."})}catch(C){const w=C instanceof Error?C.message:String(C);x({label:"Export",value:w,warning:!0}),s(w)}finally{n(null)}}return{diagnosticsAvailable:N,diagnosticsBusy:a,diagnosticsStatus:v,logDir:o,logLineLimit:u,logLines:c,logViewBusy:i,logViewSummary:I,logViewportRef:j,tailLogs:p,copyRecentLogs:A,exportDiagnosticsBundle:h,loadOlderLogs:y,openLogsFolder:O,refreshLogView:$,toggleTailLogs:R}}async function qe(s,t){let a;try{return await Promise.race([s,new Promise((n,i)=>{a=window.setTimeout(()=>{i(new Error(`${t} did not receive a desktop response.`))},Ci)})])}finally{a!==void 0&&window.clearTimeout(a)}}function Ei({connection:s,enabled:t,onError:a,onPreferences:n,onToast:i,preferences:r}){const[u,d]=l.useState(r.editor),[c,m]=l.useState(null),[o,f]=l.useState(!1),[p,g]=l.useState(!1),[j,v]=l.useState(!1);l.useEffect(()=>{d(r.editor)},[r.editor]);const x=l.useCallback(async()=>{if(s){g(!0);try{m(await U.workspaceLspSettingsStatus(s))}catch(y){a(y instanceof Error?y.message:String(y))}finally{g(!1)}}},[s,a]);l.useEffect(()=>{!t||!s||x()},[s,t,x]);function N(y,R){d(O=>({...O,languages:{...O.languages,[y]:{...O.languages[y],mode:R}}}))}function k(y,R){d(O=>({...O,languages:{...O.languages,[y]:{...O.languages[y],customCommand:R}}}))}async function I(y){if(y.preventDefault(),!!s){f(!0),a(null);try{const R=await U.savePreferences(s,{editor:u});n(R),m(await U.workspaceLspSettingsStatus(s))}catch(R){a(R instanceof Error?R.message:String(R))}finally{f(!1)}}}async function $(){if(s){v(!0),a(null);try{await U.restartWorkspaceLsp(s),m(await U.workspaceLspSettingsStatus(s)),i?.("Language servers restarted.","success")}catch(y){a(y instanceof Error?y.message:String(y))}finally{v(!1)}}}return{editorPreferences:u,lspStatus:c,restarting:j,saving:o,statusLoading:p,refreshLspStatus:x,restartLanguageServers:$,saveEditorSettings:I,setEditorPreferences:d,setLanguageCustomCommand:k,setLanguageMode:N}}function $i({connection:s,onError:t,onPayload:a,personalization:n}){const i=l.useMemo(()=>n.templates.map(h=>({value:h.id,label:h.name,description:h.id===n.activeTemplateId?"Selected":h.source==="built_in"?h.description:void 0})),[n.activeTemplateId,n.templates]),[r,u]=l.useState(n.activeTemplateId),[d,c]=l.useState(n.soul),[m,o]=l.useState(""),[f,p]=l.useState(!1),[g,j]=l.useState(!1),v=n.templates.find(h=>h.id===r)??n.templates[0],x=v?.source==="custom",N=v?d!==v.content:!0,k=r!==n.activeTemplateId||d!==n.soul||N,I=!!(x&&d.trim()&&v&&k);l.useEffect(()=>{u(n.activeTemplateId),c(n.soul);const h=n.templates.find(S=>S.id===n.activeTemplateId);o(h?`${h.name} Copy`:""),p(!1)},[n.activeTemplateId,n.soul,n.templates]);async function $(h=!1){if(!h&&!x)return;const S=h?m:v?.name;if(!(!s||!d.trim()||!S?.trim())){j(!0),t(null);try{a(await U.savePersonalization(s,{activeTemplateId:r,templateName:S,soul:d,saveAsNew:h})),p(!1)}catch(C){t(C instanceof Error?C.message:String(C))}finally{j(!1)}}}async function y(h){const S=n.templates.find(C=>C.id===h);if(S&&(u(S.id),o(`${S.name} Copy`),c(S.content),p(!1),!!s)){j(!0),t(null);try{a(await U.savePersonalization(s,{activeTemplateId:S.id,templateName:S.name,soul:S.content,saveAsNew:!1}))}catch(C){t(C instanceof Error?C.message:String(C))}finally{j(!1)}}}function R(){v&&(o(`${v.name} Copy`),c(v.content),p(!1))}function O(h){c(h),v&&!x&&h!==v.content&&p(!0)}function A(){v&&(o(`${v.name} Copy`),p(!0))}return{canSaveCurrentTemplate:I,personalizationTemplateId:r,personalizationTemplateOptions:i,saveAsNewOpen:f,saving:g,selectedPersonalizationTemplate:v,selectedTemplateIsCustom:x,soulDraft:d,templateNameDraft:m,changePersonalizationTemplate:y,changeSoulDraft:O,openSaveAsNew:A,resetPersonalizationDraft:R,savePersonalization:$,setSaveAsNewOpen:p,setTemplateNameDraft:o}}function Di({connection:s,enabled:t,onError:a,onToast:n}){const[i,r]=l.useState(null),[u,d]=l.useState(null),[c,m]=l.useState(!1),o=l.useRef(null),f=l.useCallback(async(R={})=>{if(s){R.quiet||d("refresh");try{const O=await U.remoteAccess(s);r(O),a(null)}catch(O){a(O instanceof Error?O.message:String(O))}finally{R.quiet||d(null)}}},[s,a]);l.useEffect(()=>{!t||!s||f({quiet:!0})},[s,t,f]),l.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);function p(){o.current!==null&&window.clearTimeout(o.current),m(!1),window.setTimeout(()=>{m(!0),o.current=window.setTimeout(()=>{m(!1),o.current=null},1500)},0)}async function g(){if(a(null),!!s)try{r(await U.remoteAccess(s))}catch{}}async function j(){if(!s)return null;i&&!i.tailscale.running&&p(),d("enable");try{const R=await U.enableRemoteAccess(s);return r(R.status),a(null),R.status.tailscale.running?!R.status.serve.enabled&&R.status.serve.error&&n?.(R.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":R.message||R.status.serve.error,"error"):(p(),n?.(R.message||"Tailscale is not running. Run Tailscale up first.","error")),R.status}catch{return await g(),p(),n?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{d(null)}}async function v(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){d("disable");try{const R=await U.disableRemoteAccess(s);r(R.status),a(null)}catch{await g()}finally{d(null)}}}async function x(){i?.remoteWebUrl&&(d("copy-link"),await Ie(i.remoteWebUrl),d(null))}async function N(){i?.serveCommand&&(d("copy-command"),await Ie(i.serveCommand),d(null))}async function k(){i?.serve.setupUrl&&(d("copy-serve-setup"),await Ie(i.serve.setupUrl),d(null))}async function I(){i?.tailscaleUpCommand&&(d("copy-up-command"),await Ie(i.tailscaleUpCommand),d(null))}async function $(){i?.operatorCommand&&(d("copy-operator"),await Ie(i.operatorCommand),d(null))}async function y(){if(!i?.serve.enabled){const R=await j();R?.serve.enabled&&R.remoteWebUrl&&await Ie(R.remoteWebUrl);return}await x()}return{status:i,busy:u,flashTailscaleUp:c,refresh:f,enableRemoteAccess:j,disableRemoteAccess:v,copyRemoteLink:x,copyTailscaleUpCommand:I,copyServeCommand:N,copyServeSetupUrl:k,copyOperatorCommand:$,createRemoteLink:y}}function Li(s){const[t,a]=l.useState(null),[n,i]=l.useState(null),r=l.useCallback(async()=>{if(s.connection){i("load");try{a(await U.datasetStorageState(s.connection)),s.onError(null)}catch(d){s.onError(d instanceof Error?d.message:String(d))}finally{i(null)}}},[s.connection,s.onError]),u=l.useCallback(async d=>{if(!s.connection||!d)return!1;i("save");try{return a(await U.updateDatasetStorage(s.connection,d)),s.onError(null),!0}catch(c){return s.onError(c instanceof Error?c.message:String(c)),!1}finally{i(null)}},[s.connection,s.onError]);return l.useEffect(()=>{s.enabled&&r()},[s.enabled,r]),{state:t,busy:n,refresh:r,save:u}}function Ti(s){const{connection:t,enabled:a,onError:n,profileId:i}=s,[r,u]=l.useState(null),[d,c]=l.useState(!1),m=l.useCallback(async()=>{if(t){c(!0);try{u(await U.datasetCatalog(t,i)),n(null)}catch(o){n(Oi(o))}finally{c(!1)}}},[t,n,i]);return l.useEffect(()=>{a&&m()},[a,m]),{catalog:r,loading:d,refresh:m}}function Oi(s){return s instanceof Error?s.message:String(s)}const Ui=new Set(["harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases"]);function Mi(s){return s==="harness-refiner"?"refiner":s==="harness-continuous-review"?"continuous-review":s==="harness-contents"?"contents":s==="harness-releases"?"releases":"overview"}const zi=l.lazy(()=>Js(()=>import("./ConversationImportsSettings-CuQcvVgE.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(s=>({default:s.ConversationImportsSettings}))),Hi=l.lazy(()=>Js(()=>import("./UsageSettingsSection-CC57FcUB.js"),__vite__mapDeps([7,1,2,3,4,8,9,10])).then(s=>({default:s.UsageSettingsSection})));function rl({payload:s,connection:t,diagnostics:a,onPayload:n,onError:i,onToast:r,onBack:u,onOpenSourceSession:d,onStartRefinerAuthoring:c,onAcceptEvaluationReview:m,onOpenSkill:o,onOpenExtension:f,teamChatCurrentUserId:p,teamChatEnabled:g,teamChatNotificationMode:j,teamChatThreads:v,onTeamChatNotificationModeChange:x,onTeamChatThreadMuteChange:N,diffPanelWidth:k,diffPanelResizing:I,diffPanelExpanded:$,onDiffPanelResizeStart:y,onDiffPanelExpandedChange:R,initialSection:O="account"}){const[A,h]=l.useState(O),[S,C]=l.useState(null),[w,M]=l.useState(!1),F=s?.codex??null,W=l.useMemo(()=>Vt(s?.preferences),[s?.preferences]),se=s?.personalization??Kt,X=a??s?.diagnostics??[],D=Jt()&&Yt(t?.platform),Z=l.useCallback(ae=>{s&&n({...s,providers:ae})},[n,s]),te=l.useCallback(ae=>{s&&n({...s,preferences:ae.preferences})},[n,s]),B=l.useCallback(ae=>{s&&n({...s,extensionCatalog:ae})},[n,s]),le=Si({connection:t,onError:i,onPayload:n}),ie=sn({connection:t,onError:i,onPayload:n,onPreferences:te,onProviders:Z,preferences:W,providers:s?.providers??null}),V=wi({connection:t,onError:i,onPayload:n,onPreferences:te,preferences:W,providers:s?.providers??null}),q=Ei({connection:t,enabled:A==="editor",onError:i,onPayload:n,onPreferences:te,onToast:r,preferences:W}),Y=$i({connection:t,onError:i,onPayload:n,personalization:se}),ue=Ii({onError:i,section:A}),re=Di({connection:t,enabled:A==="remote",onError:i,onToast:r}),oe=A==="dataset-storage",K=Li({connection:t,enabled:oe,onError:i}),Q=Ti({connection:t,enabled:oe,onError:i,profileId:s?.profile.activeProfile??"default"}),he=K.save,ee=l.useCallback(async()=>{await Promise.all([K.refresh(),Q.refresh()])},[K.refresh,Q.refresh]),me=l.useCallback(()=>A!=="subagents"||!V.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[V.subagentsDirty,A]),T=l.useCallback(ae=>{ae!==A&&me()&&(M(!1),R(!1),h(ae),Qt({kind:"settings",section:ae}))},[me,R,A]),P=l.useCallback(()=>{me()&&(M(!1),R(!1),u())},[me,u,R]);l.useEffect(()=>{h(O)},[O]),l.useEffect(()=>{if(A!=="subagents"||!V.subagentsDirty)return;const ae=Ae=>{Ae.preventDefault(),Ae.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",ae),()=>window.removeEventListener("beforeunload",ae)},[V.subagentsDirty,A]);const H={"--diff-panel-width":`${k}px`},z=Ui.has(A),ne=z&&w&&S,ce=JSON.stringify([s?.profile.activeProfile,s?.account.activeProfile,s?.account.baseUrl,s?.account.apiBaseUrl,s?.account.profile?.id,s?.account.state,s?.preferences.defaultTeamId??null]);return e.jsxs("div",{className:`settings-shell ${D?"platform-macos":""} ${ne?"harness-diff-open":""} ${$?"harness-diff-expanded":""} ${I?"diff-panel-resizing":""}`,style:H,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[z?e.jsx("button",{type:"button",className:`topbar-diff-button ${ne?"active":""}`,title:`${ne?"Hide":"Show"} sidebar`,"aria-label":`${ne?"Hide":"Show"} sidebar`,"aria-pressed":!!ne,disabled:!S,onClick:()=>M(ae=>!ae),children:e.jsx(Xt,{size:16})}):null,e.jsx(Zt,{platform:t?.platform})]}),e.jsx(Ma,{section:A,onBack:P,onSectionChange:T}),e.jsxs("main",{className:`settings-content ${A==="profile"||z?"settings-content-wide":""}`,children:[A!=="configuration"?e.jsx(ys,{connection:t,bannerOnly:!0,onOpen:()=>T("configuration")}):null,A==="account"?e.jsx(En,{payload:s,connection:t,onPayload:n,onPreferences:te,onError:i,onToast:r,...le}):A==="ponder"?e.jsx(Rn,{connection:t},JSON.stringify([s?.account.activeProfile,s?.account.baseUrl,s?.account.profile?.id,s?.account.state,s?.preferences.defaultTeamId])):A==="notifications"?e.jsx(Yn,{currentUserId:p,enabled:g,mode:j,threads:v,onModeChange:x,onThreadMuteChange:N}):z?e.jsx(yi,{connection:t,enabled:z,onAcceptEvaluationReview:m,onError:i,onDefaultReleaseDiff:C,onOpenSourceSession:d,onStartRefinerAuthoring:c,onOpenReleaseDiff:ae=>{C(ae),M(!0)},onToast:r,page:Mi(A)}):A==="profile"?e.jsx(va,{payload:s,connection:t,onPayload:n,onError:i,onToast:r,onOpenSession:d}):A==="skills"?e.jsx(Ha,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:t,onExtensionCatalog:B,onError:i,onToast:r,onOpenSkill:o,onOpenExtension:f}):A==="providers"?e.jsx(tn,{onProvidersChanged:Z,connection:t,account:s?.account??null,codex:F,providers:s?.providers??null,...ie}):A==="conversation-imports"?e.jsx(l.Suspense,{fallback:e.jsx("p",{role:"status",children:"Loading conversation imports…"}),children:e.jsx(zi,{connection:t})}):A==="dataset-storage"?e.jsx(Xa,{state:K.state,catalog:Q.catalog,busy:K.busy,catalogLoading:Q.loading,onRefresh:ee,onSave:he}):A==="configuration"?e.jsxs("div",{className:"settings-stacked-sections configuration-page",children:[e.jsx(ys,{connection:t,onSaved:async()=>{t&&n(await U.bootstrap(t))}}),e.jsx(On,{preferences:W,...V}),e.jsx(Es,{embedded:!0,preferences:W,...V})]}):A==="context"?e.jsx(Es,{preferences:W,...V}):A==="training"?e.jsx(Ba,{connection:t,onError:i,onPreferences:te,preferences:W,providers:s?.providers??null}):A==="subagents"?e.jsx(_n,{preferences:W,providers:s?.providers??null,...V}):A==="editor"?e.jsx(Bn,{preferences:W,...q}):A==="remote"?e.jsxs(e.Fragment,{children:[e.jsx(Oa,{connection:t,onError:i},ce),e.jsxs("details",{children:[e.jsx("summary",{children:"Direct Tailscale access"}),e.jsx(Ia,{...re})]})]}):A==="usage"?e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(Hi,{account:s?.account??null,connection:t,enabled:A==="usage",onError:i,onOpenSourceSession:d})}):A==="personalization"?e.jsx(Xn,{...Y}):e.jsx(Un,{diagnostics:X,...ue})]}),z&&t&&ne?e.jsx(Ni,{connection:t,expanded:$,onResizeStart:y,onToggleExpanded:()=>R(!$),selection:ne}):null]})}export{rl as SettingsView};