dorkos 0.126.0 → 0.126.2

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 (309) hide show
  1. package/dist/bin/cli.js +1225 -562
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-2c9n8B32.js → AboutPage-BQ66xWcJ.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-muwC_jif.js → ActivityErrorState-CPbfgXjw.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-2aUz3zv0.js → ActivityPage-CesljfZn.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-nQBqDCak.js → ActivityRow-DzhwE0ht.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-ChpyilnO.js → AdapterIcon-BXJkyF5g.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-DRKQp5Gh.js → AdapterSetupWizard-CwKYl1vG.js} +2 -2
  10. package/dist/client/assets/{AgentOptionRow-CeVPhvTq.js → AgentOptionRow-0VdNzXCF.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-D8YX1P_q.js → AgentPicker-Ldh64iOA.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-refCLvuV.js → AgentRequestCard-CmAlDGTr.js} +3 -3
  13. package/dist/client/assets/{AppearancePage-BDTIp3j0.js → AppearancePage-DmsZPHst.js} +1 -1
  14. package/dist/client/assets/ApplyToOverridesDialog-Ct1W283T.js +1 -0
  15. package/dist/client/assets/{AttentionSignalRow-Dn4rP542.js → AttentionSignalRow-B7gezgzA.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-B0sy0nRk.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-Nqvr65_g.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-DMYB-vWm.js → BindingDialog-CpBZoSZU.js} +1 -1
  18. package/dist/client/assets/{BlintzCanvas-D9ZLEDXc.js → BlintzCanvas-BCtfZPrs.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent-DMqGpNWm.js → CanvasCsvContent-DYksqzaf.js} +1 -1
  20. package/dist/client/assets/{CanvasFileContent-Bxhc86lv.js → CanvasFileContent-CqEqSxuJ.js} +2 -2
  21. package/dist/client/assets/{CanvasModel3dContent-D783Ql7m.js → CanvasModel3dContent-vR6ze4IR.js} +2 -2
  22. package/dist/client/assets/{ChannelComposer-BNlD-d2W.js → ChannelComposer-BVACOdph.js} +5 -5
  23. package/dist/client/assets/{ChatAppsOff-eRAfqzJR.js → ChatAppsOff-VsPP2Hye.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorDiff-CqEUAG6G.js → CodeMirrorDiff-CmKjH03N.js} +1 -1
  25. package/dist/client/assets/{CodeMirrorEditor-BM1ANude.js → CodeMirrorEditor-BtNgazuc.js} +1 -1
  26. package/dist/client/assets/{CommitmentList-C3QvbbGF.js → CommitmentList-D9I-CmNy.js} +1 -1
  27. package/dist/client/assets/{CommitmentsPage-bmqKNd-Z.js → CommitmentsPage-BORMYDZb.js} +1 -1
  28. package/dist/client/assets/{ComputerResourceView-78falOZG.js → ComputerResourceView-BZ9BxgOi.js} +1 -1
  29. package/dist/client/assets/{ComputerViewer-DZ2RiDbn.js → ComputerViewer-CbuU9tXK.js} +1 -1
  30. package/dist/client/assets/{ConnectionAccessLists-CXsNyR4U.js → ConnectionAccessLists-uE-Fzp6Y.js} +1 -1
  31. package/dist/client/assets/{ConnectionsPage-bpkRfRRK.js → ConnectionsPage-D7QTHeQQ.js} +1 -1
  32. package/dist/client/assets/{ConventionPage-rYtICYjS.js → ConventionPage-PS2WWCyB.js} +1 -1
  33. package/dist/client/assets/{ExtensionPageRoute-DXTqUrR4.js → ExtensionPageRoute-Cn7bYxGB.js} +2 -2
  34. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-CCNB3_Gb.js → FloatingTanStackRouterDevtools-CqogiFob-DKGNSXVz.js} +1 -1
  35. package/dist/client/assets/{ForwardConsentHost-BfVnJ6oD.js → ForwardConsentHost-CLIHtWwq.js} +1 -1
  36. package/dist/client/assets/HandlePage-BjlcYr_l.js +1 -0
  37. package/dist/client/assets/{HeartbeatPage-DdAfcR81.js → HeartbeatPage-7MTowke-.js} +1 -1
  38. package/dist/client/assets/{KeyEntry-CR7GBqXf.js → KeyEntry-Cf7D0Oo6.js} +1 -1
  39. package/dist/client/assets/{LexicalField-RAoub3wq.js → LexicalField-DqvzeMr3.js} +1 -1
  40. package/dist/client/assets/{ManagesPage-CEhYj9ov.js → ManagesPage-DxR4zWMf.js} +1 -1
  41. package/dist/client/assets/{Marketplace-DtxHDbF4.js → Marketplace-V_92jKOn.js} +1 -1
  42. package/dist/client/assets/{MarketplaceSourcesView-CSFvFtV_.js → MarketplaceSourcesView-CjCVMP_d.js} +1 -1
  43. package/dist/client/assets/{McpAppFrame-1mPdRK9p.js → McpAppFrame-4JDJsrmg.js} +2 -2
  44. package/dist/client/assets/{McpSigninBody--HfjMnE1.js → McpSigninBody-DG1XX7XT.js} +1 -1
  45. package/dist/client/assets/{Model3dViewer-BT2SY67i.js → Model3dViewer-DedBFHsl.js} +1 -1
  46. package/dist/client/assets/NamePage-A8X09lY7.js +1 -0
  47. package/dist/client/assets/{NewDirectMessageMenu-QUtJTzKI.js → NewDirectMessageMenu-C8t7x-sB.js} +1 -1
  48. package/dist/client/assets/{NotificationsPage-D3fleW0i.js → NotificationsPage-DwGFE3F6.js} +1 -1
  49. package/dist/client/assets/{OpenMeshSwitch-8WEn0WrA.js → OpenMeshSwitch-DPmTA9eg.js} +2 -2
  50. package/dist/client/assets/OperatorIdentityForm-Cu0h8Xqy.js +1 -0
  51. package/dist/client/assets/{PermissionHistory-5stLHBu8.js → PermissionHistory-zD6ksrl2.js} +1 -1
  52. package/dist/client/assets/PermissionsPage-Durcnmie.js +1 -0
  53. package/dist/client/assets/{PersonalityPopover-DIbsJ6HP.js → PersonalityPopover-DuRjJuLj.js} +1 -1
  54. package/dist/client/assets/PhotoPage-DP5WoeFd.js +1 -0
  55. package/dist/client/assets/{PreviewRefusedNotice-CjT7jQ45.js → PreviewRefusedNotice-hlYrFDQM.js} +1 -1
  56. package/dist/client/assets/{ProfileFields-gZNaFBow.js → ProfileFields-x-x8vgNo.js} +1 -1
  57. package/dist/client/assets/{ProfilePanelContainer-DYf7L8xJ.js → ProfilePanelContainer-8WxopRj2.js} +1 -1
  58. package/dist/client/assets/{ProfileRolePicker-DclYXFSP.js → ProfileRolePicker-BfciiNpr.js} +1 -1
  59. package/dist/client/assets/{PromptSuggestionChips-k9HolS90.js → PromptSuggestionChips-D34Zeaq_.js} +1 -1
  60. package/dist/client/assets/{ReportsToPopover-Bh5KrFbJ.js → ReportsToPopover-BhqA5qXi.js} +1 -1
  61. package/dist/client/assets/{RoomSurface-32U7Wl6Z.js → RoomSurface-BlMNuQsT.js} +1 -1
  62. package/dist/client/assets/{RoomsPage-sdMZgHla.js → RoomsPage-C52AOHIE.js} +1 -1
  63. package/dist/client/assets/{RunsOnPopover-B5_Jz7ir.js → RunsOnPopover-DLhEKwXF.js} +1 -1
  64. package/dist/client/assets/{RuntimeConnectFlow-C_6ozpAK.js → RuntimeConnectFlow-D3H5Fpkc.js} +1 -1
  65. package/dist/client/assets/{RuntimeSetupDialog-BDvzruM4.js → RuntimeSetupDialog-DPU4QIY9.js} +1 -1
  66. package/dist/client/assets/{SeenDevices-CZ--8ljN.js → SeenDevices-CDSHTsL7.js} +2 -2
  67. package/dist/client/assets/{SessionsPage-BKyrJh1O.js → SessionsPage-Crh3D3Jj.js} +1 -1
  68. package/dist/client/assets/{SettingsDialog-E5hPag3F.js → SettingsDialog-D0Oh-ku1.js} +4 -4
  69. package/dist/client/assets/{SkillsPage-BeL6zfgw.js → SkillsPage-BPexZwnJ.js} +1 -1
  70. package/dist/client/assets/{TaskDialogWrapper-B-IP5hYv.js → TaskDialogWrapper-D6RB8E59.js} +1 -1
  71. package/dist/client/assets/{TasksEmptyState-BcftWVbk.js → TasksEmptyState-Di3SbhJM.js} +2 -2
  72. package/dist/client/assets/{TasksPage-CmroTI1v.js → TasksPage-CDLsY1Ww.js} +1 -1
  73. package/dist/client/assets/{TeamComputerEntry-DbfoZrZz.js → TeamComputerEntry-B_q-oVSs.js} +1 -1
  74. package/dist/client/assets/{ToolsPage-h-PS45fZ.js → ToolsPage-gvIVTnwf.js} +1 -1
  75. package/dist/client/assets/{TopologyGraph-Bk_0y0Yy.js → TopologyGraph-Bp8aL_qw.js} +1 -1
  76. package/dist/client/assets/{TourHost-D4La-1-E.js → TourHost-Cg8EHvod.js} +1 -1
  77. package/dist/client/assets/{UnlinkDialog-CWd4fhT4.js → UnlinkDialog-Ddd1Yxfk.js} +1 -1
  78. package/dist/client/assets/{UnreadDivider-Bvg9QLn9.js → UnreadDivider-LL4_YtF0.js} +1 -1
  79. package/dist/client/assets/{WidgetErrorCard-DictdlWO.js → WidgetErrorCard-BA3P7hNv.js} +6 -6
  80. package/dist/client/assets/WithheldExtensionsNotice-quqWNbus.js +1 -0
  81. package/dist/client/assets/{WorkView-DxThzZ0w.js → WorkView-C_h8sclU.js} +1 -1
  82. package/dist/client/assets/_shell-D9q8zLfr.js +80 -0
  83. package/dist/client/assets/{_shell._home-CBNsPEH4.js → _shell._home-CrTxBB3h.js} +1 -1
  84. package/dist/client/assets/_shell._home.activity-2M0BJkbQ.js +1 -0
  85. package/dist/client/assets/_shell._home.index-BTJhhEWN.js +3 -0
  86. package/dist/client/assets/_shell._home.tasks-Dfrqv2nl.js +1 -0
  87. package/dist/client/assets/{_shell._home.workspaces-3R3VtH7x.js → _shell._home.workspaces-DPLQXDdH.js} +1 -1
  88. package/dist/client/assets/{_shell.channels-DRslcaiA.js → _shell.channels-CJqfUTZ1.js} +1 -1
  89. package/dist/client/assets/{_shell.connections-BPQxNUPD.js → _shell.connections-Cpe1hru3.js} +1 -1
  90. package/dist/client/assets/{_shell.feedback-requests-DkXEk3qm.js → _shell.feedback-requests-BeWCqScf.js} +2 -2
  91. package/dist/client/assets/_shell.marketplace-CzLqm8iR.js +1 -0
  92. package/dist/client/assets/_shell.marketplace_.sources-DtraxnMx.js +1 -0
  93. package/dist/client/assets/_shell.session-72JEfodU.js +1 -0
  94. package/dist/client/assets/{_shell.team-CZu-l34d.js → _shell.team-EPvcS7RS.js} +3 -3
  95. package/dist/client/assets/{_shell.threads-Cz-EZQXr.js → _shell.threads-NJDzq9dv.js} +1 -1
  96. package/dist/client/assets/_shell.x._extensionId-CcJi8pKR.js +1 -0
  97. package/dist/client/assets/_shell.x._extensionId_._-CcJi8pKR.js +1 -0
  98. package/dist/client/assets/{abnfDiagram-WEYOIA3C-4hI8_uRi.js → abnfDiagram-WEYOIA3C-DUHshdrR.js} +1 -1
  99. package/dist/client/assets/{access-copy-BegDAoeR.js → access-copy-DHfPjN3G.js} +1 -1
  100. package/dist/client/assets/{arc-DgydwPM5.js → arc-sP6zNsGB.js} +1 -1
  101. package/dist/client/assets/{architectureDiagram-ZHVYKT53-4kexDkbn.js → architectureDiagram-ZHVYKT53-C8PTjsPx.js} +1 -1
  102. package/dist/client/assets/{banner-CYV5jQI0.js → banner-CVrzHqOT.js} +1 -1
  103. package/dist/client/assets/{blockDiagram-RJAE7QA3-BUP4L5_m.js → blockDiagram-RJAE7QA3-Cydde2fz.js} +1 -1
  104. package/dist/client/assets/{c4Diagram-XDPPPE54-B4HK3S3o.js → c4Diagram-XDPPPE54-DbM6KAK7.js} +1 -1
  105. package/dist/client/assets/{card-6VNSI3kT.js → card-DA_Z-FYX.js} +1 -1
  106. package/dist/client/assets/channel-DMgpNBDz.js +1 -0
  107. package/dist/client/assets/{chunk-2E7WHVMD-Bhw5hCVI.js → chunk-2E7WHVMD-CEbspaNh.js} +1 -1
  108. package/dist/client/assets/{chunk-2Q5K7J3B-CeUgfCvO.js → chunk-2Q5K7J3B-DDP1SiE0.js} +1 -1
  109. package/dist/client/assets/{chunk-4EMNKR2T-DqSZunXx.js → chunk-4EMNKR2T-BFjozJqd.js} +1 -1
  110. package/dist/client/assets/{chunk-55XCU76K-Bigp9-bU.js → chunk-55XCU76K-0JSp6acZ.js} +1 -1
  111. package/dist/client/assets/{chunk-5VM5RSS4-DF1L8DrH.js → chunk-5VM5RSS4-DswTXnmp.js} +1 -1
  112. package/dist/client/assets/{chunk-JWPE2WC7-lcFap_43.js → chunk-JWPE2WC7-D0PYncYV.js} +1 -1
  113. package/dist/client/assets/{chunk-VQ5W62QI-Bgmsy9NF.js → chunk-VQ5W62QI-r5T-ZVBs.js} +1 -1
  114. package/dist/client/assets/{chunk-XXDRQBXY-DFFzLm_u.js → chunk-XXDRQBXY-D8kkjktE.js} +1 -1
  115. package/dist/client/assets/{chunk-ZCHMQSOR-B4aJwBdo.js → chunk-ZCHMQSOR-D6XtRzln.js} +2 -2
  116. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-BdUAMGnS.js → classDiagram-v2-4MYWR3UA-DUPDMGfm.js} +1 -1
  117. package/dist/client/assets/{command-Dz2pZLle.js → command-BvXBgZfv.js} +1 -1
  118. package/dist/client/assets/{cose-bilkent-JH36ORCC-BdJxQmWe.js → cose-bilkent-JH36ORCC-tiQpE-Q8.js} +1 -1
  119. package/dist/client/assets/{cpu-CjKJ8pVl.js → cpu-mx7zDf7k.js} +1 -1
  120. package/dist/client/assets/{cynefin-EF2NZ3EQ-BvnDWKe0.js → cynefin-EF2NZ3EQ-BjAUxFfb.js} +1 -1
  121. package/dist/client/assets/{cynefinDiagram-WF24UDRP-DKL8UyvS.js → cynefinDiagram-WF24UDRP-PmlyltXR.js} +1 -1
  122. package/dist/client/assets/{dagre-NK4GIZVX-CCuJpxlY.js → dagre-NK4GIZVX-DDePjPkn.js} +1 -1
  123. package/dist/client/assets/{diagram-CBK3MWTC-C1jeuv8r.js → diagram-CBK3MWTC-D7N3T4Fx.js} +1 -1
  124. package/dist/client/assets/{diagram-I5XIIV2D-CSnTyOU0.js → diagram-I5XIIV2D-BfZHSbR2.js} +1 -1
  125. package/dist/client/assets/{diagram-ODIL2UCW-9w6q1YKi.js → diagram-ODIL2UCW-sXAa9bzN.js} +1 -1
  126. package/dist/client/assets/{diagram-PFBEJUXE-BMFBmD0P.js → diagram-PFBEJUXE-Dfd_61WO.js} +1 -1
  127. package/dist/client/assets/{diagram-RJA3I4VV-D9Utl6qX.js → diagram-RJA3I4VV-BCzdEfnM.js} +1 -1
  128. package/dist/client/assets/{diagram-TYUNFSNR-u_ogc51l.js → diagram-TYUNFSNR-BMqtz6sZ.js} +1 -1
  129. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-Bg_smbFH.js → ebnfDiagram-V4P3TTPT-CyWj1615.js} +1 -1
  130. package/dist/client/assets/{elk-QONTBCTQ-CtuwbIK2.js → elk-QONTBCTQ-BkQMBXse.js} +1 -1
  131. package/dist/client/assets/{empty-state-CbFKhqwB.js → empty-state-Dv5iV4jb.js} +1 -1
  132. package/dist/client/assets/{erDiagram-KYQIGQAA-MlvYHdZ7.js → erDiagram-KYQIGQAA-DiPsX7uU.js} +1 -1
  133. package/dist/client/assets/{execution-config-BjNjQoBp.js → execution-config-Bej0Ot8e.js} +1 -1
  134. package/dist/client/assets/{file-JokR8lB2.js → file-DXbyb23e.js} +1 -1
  135. package/dist/client/assets/{file-exclamation-point-sl45DZYe.js → file-exclamation-point-C8XqHyzY.js} +1 -1
  136. package/dist/client/assets/{file-text-C4PxLfBm.js → file-text-CRTgqqkn.js} +1 -1
  137. package/dist/client/assets/{find-latest-widget-fence-Bc1LICCy.js → find-latest-widget-fence-D1i7qNny.js} +5 -5
  138. package/dist/client/assets/{flowDiagram-IUGLLWBU-BlrKbUnh.js → flowDiagram-IUGLLWBU-BSM44aJP.js} +1 -1
  139. package/dist/client/assets/{form-1NlezfMg.js → form-DYSiVEri.js} +1 -1
  140. package/dist/client/assets/{format-cron-C57sE3sK.js → format-cron-DYYwmo-o.js} +1 -1
  141. package/dist/client/assets/{ganttDiagram-R7GPNTJY-BhCCQ-d7.js → ganttDiagram-R7GPNTJY-BWCjYexX.js} +1 -1
  142. package/dist/client/assets/{git-branch-BXEb1Sqq.js → git-branch-1zYKSuur.js} +1 -1
  143. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-Chl1aqHg.js → gitGraphDiagram-PDYL7XHY-ULC7Zunc.js} +1 -1
  144. package/dist/client/assets/{graph-DIIpUxLd.js → graph-BsZzo5TN.js} +1 -1
  145. package/dist/client/assets/{heart-CUs7jdhV.js → heart-C4CSHUW7.js} +1 -1
  146. package/dist/client/assets/{highlighted-body-KPVGNVTW-DlDHGjld.js → highlighted-body-KPVGNVTW-CFECg7iB.js} +1 -1
  147. package/dist/client/assets/{image-lightbox-BczXKBTZ.js → image-lightbox-M9t3Wulc.js} +1 -1
  148. package/dist/client/assets/{image-off-Ch98GGBJ.js → image-off-c01kxBAm.js} +1 -1
  149. package/dist/client/assets/{index-D6NjBiAq.js → index-B-7P1Q9s.js} +1 -1
  150. package/dist/client/assets/{index-BAnl5kwm.js → index-B3xeyV6n.js} +1 -1
  151. package/dist/client/assets/{index-DwrBsA10.js → index-B6Scr7KJ.js} +213 -213
  152. package/dist/client/assets/{index-Ev7FZl9a.js → index-BIVIHPoe.js} +1 -1
  153. package/dist/client/assets/{index-hyqRnlFg.js → index-BRH6C3LJ.js} +1 -1
  154. package/dist/client/assets/{index-CQTeDD0B.js → index-BScgHCO_.js} +1 -1
  155. package/dist/client/assets/{index-pQstFziR.js → index-BSxkprTm.js} +3 -3
  156. package/dist/client/assets/{index-DaZdDh7o.js → index-BTGRc0hC.js} +1 -1
  157. package/dist/client/assets/{index-CaVP52c1.js → index-BYY8HEOz.js} +1 -1
  158. package/dist/client/assets/{index-Cn1ZEy3S.js → index-B_he44rF.js} +1 -1
  159. package/dist/client/assets/{index-rKEUwjq8.js → index-BnXWm8Db.js} +1 -1
  160. package/dist/client/assets/{index-BQlnEL5t.js → index-BqwCOIbF.js} +1 -1
  161. package/dist/client/assets/{index-8FrM4Unx.js → index-Br35Gqfz.js} +1 -1
  162. package/dist/client/assets/{index-BC41bN42.js → index-C1XazYWZ.js} +1 -1
  163. package/dist/client/assets/{index-DMfV6rUz.js → index-C3swXqWW.js} +1 -1
  164. package/dist/client/assets/{index-B0p2_o3r.js → index-CAAsqmfP.js} +1 -1
  165. package/dist/client/assets/{index-DzLIbXMR.js → index-CAjKQnAd.js} +1 -1
  166. package/dist/client/assets/{index-vU7itvE8.js → index-Ce3HZQem.js} +1 -1
  167. package/dist/client/assets/{index-CnNGTb8f.js → index-CnltS8ym.js} +1 -1
  168. package/dist/client/assets/{index-ByIDaFWv.js → index-D847rJXW.js} +1 -1
  169. package/dist/client/assets/{index-CYhf-E_N.js → index-DG13Cp5o.js} +1 -1
  170. package/dist/client/assets/{index-CoHeCySh.js → index-DIDUjTkq.js} +1 -1
  171. package/dist/client/assets/{index-slBSiB-H.js → index-DQTTC52E.js} +1 -1
  172. package/dist/client/assets/{index-BiyMpL0z.js → index-DhYnXLRT.js} +1 -1
  173. package/dist/client/assets/{index-HnW-eS5i.js → index-DhkfALZp.js} +1 -1
  174. package/dist/client/assets/{index-BVjrgWDa.js → index-DhoaVQXu.js} +1 -1
  175. package/dist/client/assets/{index-D1Be28yK.js → index-DrENuQdJ.js} +1 -1
  176. package/dist/client/assets/{index-B0q1o1JU.js → index-DrQqkQq_.js} +1 -1
  177. package/dist/client/assets/{index-0MDZSAdr.js → index-DsasLE1l.js} +1 -1
  178. package/dist/client/assets/{index-CSOhBvPV.js → index-Dt7RONID.js} +1 -1
  179. package/dist/client/assets/{index-Czar7aPT.js → index-Du4HX97h.js} +2 -2
  180. package/dist/client/assets/{index-37h1E-65.js → index-DyN65ufd.js} +1 -1
  181. package/dist/client/assets/{index-BNJa5z6K.js → index-DzHj8lCz.js} +6 -6
  182. package/dist/client/assets/{index-BwHCH3tE.js → index-FwAvbbet.js} +1 -1
  183. package/dist/client/assets/{index-DlZ77Qfj.js → index-JG_0k1NX.js} +1 -1
  184. package/dist/client/assets/{index-BRyEtRBO.js → index-LpaxG4VS.js} +1 -1
  185. package/dist/client/assets/{index-D_9H4FdK.js → index-UJq1qaku.js} +1 -1
  186. package/dist/client/assets/{index-Cnjpi7ar.js → index-XEE1k4cl.js} +1 -1
  187. package/dist/client/assets/{index-BzqkXlms.js → index-YXyEu3Ia.js} +1 -1
  188. package/dist/client/assets/index-e6oawwKv.js +1 -0
  189. package/dist/client/assets/index-j30EyYIU.js +1 -0
  190. package/dist/client/assets/{index-Cw0QRsnv.js → index-jLIoULQt.js} +1 -1
  191. package/dist/client/assets/{index-CFJcOzPD.js → index-uLbyd6YP.js} +1 -1
  192. package/dist/client/assets/{index.esm-DM8Bqi3n.js → index.esm-CZ68Qd2t.js} +1 -1
  193. package/dist/client/assets/{infoDiagram-MVDRKAX5-C0p1eP9j.js → infoDiagram-MVDRKAX5-BCjhXqIT.js} +1 -1
  194. package/dist/client/assets/{inline-code-CNmpgW3O.js → inline-code-BKPMIXZR.js} +1 -1
  195. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-COdxgYUT.js → ishikawaDiagram-HPEHV2GE-C9rsv2nh.js} +1 -1
  196. package/dist/client/assets/{journeyDiagram-BOSHW7O7-C84Ny9n9.js → journeyDiagram-BOSHW7O7-BRYr1XL1.js} +1 -1
  197. package/dist/client/assets/{kanban-definition-FNSA4HC5-ECSXhFX0.js → kanban-definition-FNSA4HC5-2ey8FXEn.js} +1 -1
  198. package/dist/client/assets/{layers-JgRwJGyf.js → layers-DE3wjQuk.js} +1 -1
  199. package/dist/client/assets/{lightbulb-BhQB8sFP.js → lightbulb-BXJIRUdm.js} +1 -1
  200. package/dist/client/assets/{link-2-B4byjdgg.js → link-2-DzWm9OxA.js} +1 -1
  201. package/dist/client/assets/{list-runtime-types-M5_gxIg1.js → list-runtime-types-BhkZkTrB.js} +1 -1
  202. package/dist/client/assets/{markdown-content-C3qWcii6.js → markdown-content-Bk9lCksw.js} +1 -1
  203. package/dist/client/assets/{mention-pill-DUbgdKmA.js → mention-pill-os_7QQu2.js} +1 -1
  204. package/dist/client/assets/{mermaid.core-BQiwaVjZ.js → mermaid.core-BcRUBvZd.js} +4 -4
  205. package/dist/client/assets/{message-square-off-AjtFFe_u.js → message-square-off-DuOiETNI.js} +1 -1
  206. package/dist/client/assets/{mindmap-definition-6OY57UG3-BfA6EqgP.js → mindmap-definition-6OY57UG3-DBhXkS2i.js} +1 -1
  207. package/dist/client/assets/{more-details-itSF4Fah.js → more-details-Bt9nlPmS.js} +1 -1
  208. package/dist/client/assets/{owner-notice-B6JRjE_c.js → owner-notice-4ZSBxa2K.js} +1 -1
  209. package/dist/client/assets/{package-5YQSitlR.js → package-BmOMrNwc.js} +1 -1
  210. package/dist/client/assets/{page-container-DBPUOYYM.js → page-container-LomhzyuS.js} +1 -1
  211. package/dist/client/assets/{pane-resize-handle-Kwb3zKa6.js → pane-resize-handle-BOtzx5Q4.js} +1 -1
  212. package/dist/client/assets/{paperclip-IRKZTEQw.js → paperclip-C1tkiT74.js} +1 -1
  213. package/dist/client/assets/{path-input-BHkA4fFw.js → path-input-JHTlL97W.js} +1 -1
  214. package/dist/client/assets/{pegDiagram-ECIUJNBX-CqIy9WDe.js → pegDiagram-ECIUJNBX-B01fb3t0.js} +1 -1
  215. package/dist/client/assets/{pieDiagram-GNMPY74T-C5yI3cvV.js → pieDiagram-GNMPY74T-BJ7JYrTk.js} +1 -1
  216. package/dist/client/assets/{plug-CupdBXaG.js → plug-CsqfQsYq.js} +1 -1
  217. package/dist/client/assets/{primer-trigger-Ci_XRRfX.js → primer-trigger-DLdK7lVr.js} +2 -2
  218. package/dist/client/assets/{profile-errors-aEsWNifs.js → profile-errors-CpvSy5wY.js} +1 -1
  219. package/dist/client/assets/{progress-Bpmb837n.js → progress-qB87L0zJ.js} +1 -1
  220. package/dist/client/assets/{quadrantDiagram-D57K4MC3-DyCDNvk7.js → quadrantDiagram-D57K4MC3-mJYGGmOV.js} +1 -1
  221. package/dist/client/assets/{query-error-state-s6AJaHa3.js → query-error-state-MyJ1ivia.js} +1 -1
  222. package/dist/client/assets/{radio-Ci6Ghks8.js → radio-DJV7l0fv.js} +1 -1
  223. package/dist/client/assets/{railroadDiagram-Y72NRBL7-B3u1B937.js → railroadDiagram-Y72NRBL7-BlXWwQe2.js} +1 -1
  224. package/dist/client/assets/registry-BrjQCdmG.js +1 -0
  225. package/dist/client/assets/{registry-NGfn1R2_.js → registry-tJrGs7kB.js} +4 -4
  226. package/dist/client/assets/{relay-trace-schemas-hOFIzdY-.js → relay-trace-schemas-TH0-GYCB.js} +2 -2
  227. package/dist/client/assets/{repeat-B1S2ceC2.js → repeat-CBnopqBr.js} +1 -1
  228. package/dist/client/assets/{requirementDiagram-EQYSW5RA-CdG-unip.js → requirementDiagram-EQYSW5RA-Dqr1Y74x.js} +1 -1
  229. package/dist/client/assets/{room-files-source-J7gnN1gx.js → room-files-source-BFo0FEUP.js} +1 -1
  230. package/dist/client/assets/{rotate-ccw-clock-7Q2akPFi.js → rotate-ccw-clock-D9XRHj5E.js} +1 -1
  231. package/dist/client/assets/{rotate-cw-DK3Rzmlh.js → rotate-cw-DNa7ENG3.js} +1 -1
  232. package/dist/client/assets/{sankeyDiagram-SY24JHO5-D3Z4Qk2b.js → sankeyDiagram-SY24JHO5-DGYZs_kW.js} +1 -1
  233. package/dist/client/assets/{scroll-area-6Gelypei.js → scroll-area-Bf6IGziJ.js} +1 -1
  234. package/dist/client/assets/search-x-DFBBEouE.js +6 -0
  235. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-RXPgeLr6.js → sequenceDiagram-BLEHNHQU-BW3u4L9y.js} +1 -1
  236. package/dist/client/assets/{shield-x-D8lJ0Op0.js → shield-x-WGxwrtNV.js} +1 -1
  237. package/dist/client/assets/{signed-in-NOeTLLso.js → signed-in-eV4_EXuv.js} +1 -1
  238. package/dist/client/assets/{sizeCapture-INFHLROL-q7qki1pK.js → sizeCapture-INFHLROL-C1TpueOu.js} +1 -1
  239. package/dist/client/assets/{soul-file-DTEcjDxP.js → soul-file-e1iYX9IV.js} +1 -1
  240. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-DFs6IVbj.js → stateDiagram-v2-A6IESKWZ-DvrHUauN.js} +1 -1
  241. package/dist/client/assets/{swimlanes-B3ENRKFQ-D1A-3JE-.js → swimlanes-B3ENRKFQ-BUbTcoId.js} +1 -1
  242. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-wkooBe_N.js +8 -0
  243. package/dist/client/assets/{table-CuBPM_bg.js → table-DsxLk3Gx.js} +1 -1
  244. package/dist/client/assets/{timeline-definition-JXYKGLGB-CLHy0rAb.js → timeline-definition-JXYKGLGB-CzbVpGxn.js} +1 -1
  245. package/dist/client/assets/{trust-posture-BXXe8F8n.js → trust-posture-Blofy7eE.js} +1 -1
  246. package/dist/client/assets/{unplug-Cuej6sM6.js → unplug-B6dUhqA7.js} +1 -1
  247. package/dist/client/assets/{unverified-catalog-notice-BbK4SCJp.js → unverified-catalog-notice-6pwZtIjx.js} +1 -1
  248. package/dist/client/assets/{use-adapter-catalog-Cy7ENVZN.js → use-adapter-catalog-J43bUHJu.js} +1 -1
  249. package/dist/client/assets/{use-bindings-Tj0BcF4m.js → use-bindings-BgXZ0D7k.js} +1 -1
  250. package/dist/client/assets/{use-composer-prefs-BrQVpwRi.js → use-composer-prefs--zO2mm_M.js} +1 -1
  251. package/dist/client/assets/{use-connector-management-CLZQXgln.js → use-connector-management-9Q7wHb06.js} +1 -1
  252. package/dist/client/assets/{use-deep-link-scroll-BeqtUhj2.js → use-deep-link-scroll-CXqwdwGr.js} +1 -1
  253. package/dist/client/assets/{use-delete-binding-d7ii9iFQ.js → use-delete-binding-BBQNMtUY.js} +1 -1
  254. package/dist/client/assets/{use-dev-links-MYOV3h2q.js → use-dev-links-C643CCcq.js} +1 -1
  255. package/dist/client/assets/{use-direct-message-panel-C_lXDYnB.js → use-direct-message-panel-BD_daG2E.js} +1 -1
  256. package/dist/client/assets/{use-external-adapter-catalog-kMFSEJGV.js → use-external-adapter-catalog-BjbC1V6t.js} +1 -1
  257. package/dist/client/assets/{use-full-activity-feed-MFSkvnza.js → use-full-activity-feed-DUH8r8jx.js} +1 -1
  258. package/dist/client/assets/use-is-below-desktop-DAZnwJGB.js +1 -0
  259. package/dist/client/assets/{use-local-browser-1oVtlmXD.js → use-local-browser-P93oA-F5.js} +1 -1
  260. package/dist/client/assets/{use-mesh-topology-BJs6M6kh.js → use-mesh-topology-B0k0gLoW.js} +1 -1
  261. package/dist/client/assets/{use-mounted-ref-DitdlmSI.js → use-mounted-ref-DE7EQsBF.js} +1 -1
  262. package/dist/client/assets/{use-notification-prefs-CXbRTRLF.js → use-notification-prefs-B8JtshQ0.js} +1 -1
  263. package/dist/client/assets/use-pending-read-DeGO1wGC.js +1 -0
  264. package/dist/client/assets/{use-personality-commit-DQrWyVGT.js → use-personality-commit-Dh5Sejj_.js} +1 -1
  265. package/dist/client/assets/{use-promo-activation-CgdBHk2f.js → use-promo-activation-C9FWA7ru.js} +3 -3
  266. package/dist/client/assets/{use-promo-dismissals-DprcDmfs.js → use-promo-dismissals-BIfafj9f.js} +1 -1
  267. package/dist/client/assets/{use-pulse-freshness-BtMzHCs3.js → use-pulse-freshness-CxzVMmVK.js} +1 -1
  268. package/dist/client/assets/{use-relay-config-CGBlgXC2.js → use-relay-config-DQE3dmJ2.js} +1 -1
  269. package/dist/client/assets/{use-room-follow-claim-Db5U7kWT.js → use-room-follow-claim-B1QPFaUb.js} +1 -1
  270. package/dist/client/assets/{use-room-sessions-K6mdH-Tb.js → use-room-sessions-CdjzO67_.js} +1 -1
  271. package/dist/client/assets/{use-roving-tab-list-B2zxa_F_.js → use-roving-tab-list-Nu-MIapD.js} +1 -1
  272. package/dist/client/assets/{use-session-canvas-D4G5fO_a.js → use-session-canvas-BfKGOpNy.js} +8 -8
  273. package/dist/client/assets/{use-status-budget-UccdTZ7o.js → use-status-budget-DgeTxC3h.js} +3 -3
  274. package/dist/client/assets/{use-transform-BBj2pwbo.js → use-transform-CiJqtMBf.js} +1 -1
  275. package/dist/client/assets/{use-unclaimed-chats-BidDnyt8.js → use-unclaimed-chats-Blkq6U4D.js} +1 -1
  276. package/dist/client/assets/use-update-config-BFFW_6Mc.js +1 -0
  277. package/dist/client/assets/{useMutationState-RYxTf1aD.js → useMutationState-lbcdmnfE.js} +1 -1
  278. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-Bjmcc2gK.js → usecaseDiagram-WPOLBNNX-BM36oESm.js} +1 -1
  279. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-Cd6C9CxW.js → vennDiagram-Q3Y3IDCW-Zrybcs91.js} +1 -1
  280. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-CzWWmwUL.js → wardleyDiagram-IVAIDKWA-CO4pzGG0.js} +1 -1
  281. package/dist/client/assets/{xychartDiagram-4URNHDU4-DSUn9rhA.js → xychartDiagram-4URNHDU4-pi_wF1CM.js} +1 -1
  282. package/dist/client/index.html +1 -1
  283. package/dist/server/index.js +70428 -68011
  284. package/dist/server/index.js.map +2 -2
  285. package/package.json +4 -4
  286. package/dist/client/assets/ApplyToOverridesDialog-C-XL9N4W.js +0 -1
  287. package/dist/client/assets/HandlePage-BH_G4sMV.js +0 -1
  288. package/dist/client/assets/NamePage-CaJsVRhh.js +0 -1
  289. package/dist/client/assets/OperatorIdentityForm-BRKAQS0D.js +0 -1
  290. package/dist/client/assets/PermissionsPage-C2pB1TCJ.js +0 -1
  291. package/dist/client/assets/PhotoPage-33Xh8sq1.js +0 -1
  292. package/dist/client/assets/_shell-CX_gaQPE.js +0 -80
  293. package/dist/client/assets/_shell._home.activity-DpSGWVSW.js +0 -1
  294. package/dist/client/assets/_shell._home.index-BWH93iWg.js +0 -3
  295. package/dist/client/assets/_shell._home.tasks-Ive4UW8c.js +0 -1
  296. package/dist/client/assets/_shell.marketplace-D8deZF5L.js +0 -1
  297. package/dist/client/assets/_shell.marketplace_.sources-BHG9MqWR.js +0 -1
  298. package/dist/client/assets/_shell.session-CkdA2hgF.js +0 -1
  299. package/dist/client/assets/_shell.x._extensionId-Cry6E5KK.js +0 -1
  300. package/dist/client/assets/_shell.x._extensionId_._-Cry6E5KK.js +0 -1
  301. package/dist/client/assets/channel-Bf4e4rlX.js +0 -1
  302. package/dist/client/assets/index-BThp0Av1.js +0 -1
  303. package/dist/client/assets/index-Dv6HjbCS.js +0 -1
  304. package/dist/client/assets/registry-DatwH4jj.js +0 -1
  305. package/dist/client/assets/search-x-Be8VetKs.js +0 -6
  306. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-hZFkkqUb.js +0 -8
  307. package/dist/client/assets/use-is-below-desktop-CJJ4zMQO.js +0 -1
  308. package/dist/client/assets/use-pending-read-CvX1lOb8.js +0 -1
  309. package/dist/client/assets/use-update-config-D8g4P42J.js +0 -1
@@ -1,12 +1,12 @@
1
- import{r as m,O as hn,oN as It,oO as ha,hj as pn,j as e,oP as pa,oQ as ga,d2 as et,d3 as st,oR as fa,d4 as ja,oS as ya,d6 as tt,d7 as nt,oT as ba,oU as va,oV as Na,oW as ka,oX as wa,oY as Ca,G as L,oZ as Sa,aN as Se,by as Le,ar as Te,o_ as Aa,o$ as Ta,e as ee,bg as R,bh as D,hG as fe,b8 as we,B as b,x as fs,eQ as at,bi as $,bJ as me,g$ as Fe,p0 as Oa,li as Ea,X as rt,bK as xe,bL as te,bM as ne,bN as ae,bO as re,bP as ie,bR as pe,a0 as Me,fA as Ra,gO as gn,p1 as it,a2 as Y,a3 as V,lo as js,em as X,I as J,ef as oe,eg as le,eh as ce,ei as de,ej as P,jp as ot,J as Ke,io as fn,fg as ds,a1 as U,a4 as ge,p2 as Da,_ as se,p3 as jn,ks as lt,p4 as Ia,p5 as Pa,$ as He,fh as yn,fi as bn,fj as zs,fk as Us,fl as Ks,p6 as La,p7 as $a,bS as _a,ap as as,bE as Oe,C as Be,Q as Ye,T as Ve,f as Fa,V as Qe,l3 as Ma,mK as za,eV as _,ed as je,e9 as ys,jW as bs,e8 as Ge,eb as vs,l1 as Ua,p8 as vn,l2 as ct,mb as Ka,p9 as ze,pa as Ba,pb as Wa,pc as qa,pd as Ha,a7 as $e,pe as Ya,eq as Ns,pf as us,d5 as Nn,eB as kn,dM as wn,pg as Va,ph as Qa,pi as Ga,pj as Xa,pk as Ja,pl as Za,pm as er,pn as sr,po as tr,jX as nr,pp as ar,gq as Ts,aY as Ee,dF as dt,aI as G,U as We,ee as rr,hn as ks,ho as _e,m5 as Cn,gP as ir,gW as or,gT as Sn,bX as ue,gV as ws,hT as lr,gS as cr,pq as dr,aS as ur,mv as Bs,pr as Ws,cO as mr,e6 as xr,am as ms,jN as Pe,ps as hr,lj as An,lk as qs,bz as pr,bA as gr,pt as fr,bB as jr,bD as yr,pu as br,h0 as vr,pv as Nr,pw as ut,px as Tn,py as ke,pz as kr,pA as wr,ec as On,nD as Cr,a8 as En,pB as Rn,eO as mt,a9 as xt,ai as Sr,aj as Ar,c1 as Tr,gK as Or,e7 as Er,pC as Rr,c$ as Dr,g8 as Ir,g9 as Pr,ga as Lr,ak as $r,kC as Dn,kD as _r,jB as Fr,pD as Mr,dT as zr,h6 as Ur,dj as Kr,dk as Br,dl as Wr,pE as qr,en as ht,ir as Hr,jq as pt,pF as Yr,pG as Vr,pH as De,pI as rs,pJ as Pt,pK as Lt,pL as Qr,pM as Gr,gb as Xr,cu as In,l as Pn,y as Jr,pN as Zr,pO as ei,eP as si,pP as ti,ii as ni,e2 as Ln,eN as ai,aJ as ri,fz as ii,id as Ce,bf as oi,pQ as li,pR as ci,pS as di,pT as ui,pU as mi,cx as xi,l0 as hi,cj as pi,ck as gi,pV as fi,jg as ji,pW as yi,pX as bi,g4 as vi,n as Ni,ba as ki,ia as wi,eo as Ci,mJ as Si,i9 as Ai,ke as Ti}from"./index-DwrBsA10.js";import{a as Oi}from"./ProfilePanelContainer-DYf7L8xJ.js";import{u as ye}from"./use-update-config-D8g4P42J.js";import{u as Ei,a as Ri}from"./use-composer-prefs-BrQVpwRi.js";import{I as qe}from"./trust-posture-BXXe8F8n.js";import{u as $n,a as Di,i as Ii}from"./use-notification-prefs-CXbRTRLF.js";import{u as _n}from"./use-bindings-Tj0BcF4m.js";import{T as Pi,a as Li,B as xs,u as $i,i as hs,f as ls,r as _i,b as $t,w as Os,c as gt,d as Hs,C as Fn,e as Fi,K as Mi,U as zi,S as Ui,g as Ki,h as Bi,A as Mn,j as Wi,W as _t,k as qi,l as Hi,m as Yi,P as Vi,O as Qi,n as Gi}from"./SeenDevices-CZ--8ljN.js";import{M as Cs}from"./more-details-itSF4Fah.js";import{u as zn}from"./use-deep-link-scroll-BeqtUhj2.js";import{a as Xi,u as ft}from"./use-relay-config-CGBlgXC2.js";import{Q as Xe}from"./query-error-state-s6AJaHa3.js";import{b as Ji,C as Zi,u as eo,a as so,K as to}from"./KeyEntry-CR7GBqXf.js";import{s as no,e as jt}from"./access-copy-BegDAoeR.js";import{c as Un,W as Ft,a as Kn}from"./connection-copy--MA7AN04.js";import{u as Bn,b as ao}from"./use-adapter-catalog-Cy7ENVZN.js";import{C as ro,R as io,g as oo,u as lo,r as co}from"./ChatAppsOff-eRAfqzJR.js";import{a as uo,B as mo}from"./BindingDialog-DMYB-vWm.js";import{D as xo,a as ho}from"./dead-letter-reasons-DtBHju9v.js";import{C as po}from"./relay-trace-schemas-hOFIzdY-.js";import{u as Wn,B as go}from"./ApplyToOverridesDialog-C-XL9N4W.js";import{P as fo,a as jo,D as yo}from"./PermissionHistory-5stLHBu8.js";import{s as qn}from"./settings-for-runtime-BoOa-ZFG.js";import{l as bo}from"./list-runtime-types-M5_gxIg1.js";import{I as vo}from"./inline-code-CNmpgW3O.js";import{r as Ys,d as Hn,b as No,D as yt,u as ko,C as wo}from"./RuntimeConnectFlow-C_6ozpAK.js";import{k as Co,e as cs}from"./execution-config-BjNjQoBp.js";import{U as So}from"./unverified-catalog-notice-BbK4SCJp.js";import{P as Ao}from"./path-input-BHkA4fFw.js";import{C as To}from"./runtime-connect-Dn0T5YWv.js";import{U as Oo}from"./unplug-Cuej6sM6.js";import{L as Eo}from"./link-2-B4byjdgg.js";import{P as Ro,S as Do}from"./progress-Bpmb837n.js";import{C as Io,a as Po}from"./cpu-CjKJ8pVl.js";import"./ProfileFields-gZNaFBow.js";import"./profile-errors-aEsWNifs.js";import"./use-mounted-ref-DitdlmSI.js";import"./ProfileRolePicker-DclYXFSP.js";import"./use-promo-dismissals-DprcDmfs.js";import"./empty-state-CbFKhqwB.js";import"./form-1NlezfMg.js";import"./useMutationState-RYxTf1aD.js";function Lo({open:s,initialTab:t,defaultTab:n}){const[a,r]=m.useState(t??n),[i,o]=m.useState(s);return s!==i&&(o(s),s&&t&&r(t)),[a,r]}/**
1
+ import{r as m,O as pn,oP as It,oQ as pa,hl as gn,j as e,oR as ga,oS as fa,d2 as et,d3 as st,oT as ja,d4 as ya,oU as ba,d6 as tt,d7 as nt,oV as va,oW as Na,oX as ka,oY as wa,oZ as Ca,o_ as Sa,G as L,o$ as Aa,aN as Se,by as Le,ar as Te,p0 as Ta,p1 as Ea,e as ee,bg as R,bh as D,hI as fe,b8 as we,B as b,x as fs,eS as at,bi as _,bJ as me,h1 as Fe,p2 as Oa,lk as Ra,X as rt,bK as xe,bL as te,bM as ne,bN as ae,bO as re,bP as ie,bR as pe,a0 as Me,fC as Da,gQ as fn,p3 as it,a2 as Y,a3 as V,lq as js,eo as X,I as J,eh as oe,ei as le,ej as ce,ek as de,el as P,jr as ot,J as Ke,iq as jn,fi as ds,a1 as U,a4 as ge,p4 as Ia,_ as se,p5 as yn,ku as lt,p6 as Pa,p7 as La,$ as He,fj as bn,fk as vn,fl as zs,fm as Us,fn as Ks,p8 as _a,p9 as $a,bS as Fa,ap as as,bE as Ee,C as Be,Q as Ye,T as Ve,f as Ma,V as Qe,l5 as za,mM as Ua,eX as $,ef as je,eb as ys,jY as bs,ea as Ge,ed as vs,l3 as Ka,pa as Nn,l4 as ct,md as Ba,pb as ze,pc as Wa,pd as qa,pe as Ha,pf as Ya,a7 as _e,pg as Va,es as Ns,ph as us,d5 as kn,eD as wn,dO as Cn,pi as Qa,pj as Ga,pk as Xa,pl as Ja,pm as Za,pn as er,po as sr,pp as tr,pq as nr,jZ as ar,pr as rr,gs as Ts,aY as Oe,dH as dt,aI as G,U as We,eg as ir,hp as ks,hq as $e,m7 as Sn,gR as or,gY as lr,gV as An,bX as ue,gX as ws,hV as cr,gU as dr,ps as ur,aS as mr,mx as Bs,pt as Ws,cO as xr,e8 as hr,am as ms,jP as Pe,pu as pr,ll as Tn,lm as qs,bz as gr,bA as fr,pv as jr,bB as yr,bD as br,pw as vr,h2 as Nr,px as kr,py as ut,pz as En,pA as ke,pB as wr,pC as Cr,ee as On,nF as Sr,a8 as Rn,pD as Dn,eQ as mt,a9 as xt,ai as Ar,aj as Tr,c1 as Er,gM as Or,e9 as Rr,pE as Dr,c$ as Ir,ga as Pr,gb as Lr,gc as _r,ak as $r,kE as In,kF as Fr,jD as Mr,pF as zr,dV as Ur,h8 as Kr,dl as Br,dm as Wr,dn as qr,pG as Hr,ep as ht,it as Yr,js as pt,pH as Vr,pI as Qr,pJ as De,pK as rs,pL as Pt,pM as Lt,pN as Gr,pO as Xr,gd as Jr,cu as Pn,l as Ln,y as Zr,pP as ei,pQ as si,eR as ti,pR as ni,ik as ai,e4 as _n,eP as ri,aJ as ii,fB as oi,ig as Ce,bf as li,pS as ci,pT as di,pU as ui,pV as mi,pW as xi,cx as hi,l2 as pi,cj as gi,ck as fi,pX as ji,ji as yi,pY as bi,pZ as vi,g6 as Ni,n as ki,ba as wi,ic as Ci,eq as Si,mL as Ai,ib as Ti,kg as Ei}from"./index-B6Scr7KJ.js";import{a as Oi}from"./ProfilePanelContainer-8WxopRj2.js";import{u as ye}from"./use-update-config-BFFW_6Mc.js";import{u as Ri,a as Di}from"./use-composer-prefs--zO2mm_M.js";import{I as qe}from"./trust-posture-Blofy7eE.js";import{u as $n,a as Ii,i as Pi}from"./use-notification-prefs-B8JtshQ0.js";import{u as Fn}from"./use-bindings-BgXZ0D7k.js";import{T as Li,a as _i,B as xs,u as $i,i as hs,f as ls,r as Fi,b as _t,w as Es,c as gt,d as Hs,C as Mn,e as Mi,K as zi,U as Ui,S as Ki,g as Bi,h as Wi,A as zn,j as qi,W as $t,k as Hi,l as Yi,m as Vi,P as Qi,O as Gi,n as Xi}from"./SeenDevices-CDSHTsL7.js";import{M as Cs}from"./more-details-Bt9nlPmS.js";import{u as Un}from"./use-deep-link-scroll-CXqwdwGr.js";import{a as Ji,u as ft}from"./use-relay-config-DQE3dmJ2.js";import{Q as Xe}from"./query-error-state-MyJ1ivia.js";import{b as Zi,C as eo,u as so,a as to,K as no}from"./KeyEntry-Cf7D0Oo6.js";import{s as ao,e as jt}from"./access-copy-DHfPjN3G.js";import{c as Kn,W as Ft,a as Bn}from"./connection-copy--MA7AN04.js";import{u as Wn,b as ro}from"./use-adapter-catalog-J43bUHJu.js";import{C as io,R as oo,g as lo,u as co,r as uo}from"./ChatAppsOff-VsPP2Hye.js";import{a as mo,B as xo}from"./BindingDialog-CpBZoSZU.js";import{D as ho,a as po}from"./dead-letter-reasons-DtBHju9v.js";import{C as go}from"./relay-trace-schemas-TH0-GYCB.js";import{u as qn,B as fo,R as Mt}from"./ApplyToOverridesDialog-Ct1W283T.js";import{P as jo,a as yo,D as bo}from"./PermissionHistory-zD6ksrl2.js";import{s as Hn}from"./settings-for-runtime-BoOa-ZFG.js";import{l as vo}from"./list-runtime-types-BhkZkTrB.js";import{I as No}from"./inline-code-BKPMIXZR.js";import{r as Ys,d as Yn,b as ko,D as yt,u as wo,C as Co}from"./RuntimeConnectFlow-D3H5Fpkc.js";import{k as So,e as cs}from"./execution-config-Bej0Ot8e.js";import{U as Ao}from"./unverified-catalog-notice-6pwZtIjx.js";import{P as To}from"./path-input-JHTlL97W.js";import{C as Eo}from"./runtime-connect-Dn0T5YWv.js";import{U as Oo}from"./unplug-B6dUhqA7.js";import{L as Ro}from"./link-2-DzWm9OxA.js";import{P as Do,S as Io}from"./progress-qB87L0zJ.js";import{C as Po,a as Lo}from"./cpu-mx7zDf7k.js";import"./ProfileFields-x-x8vgNo.js";import"./profile-errors-CpvSy5wY.js";import"./use-mounted-ref-DE7EQsBF.js";import"./ProfileRolePicker-BfciiNpr.js";import"./use-promo-dismissals-BIfafj9f.js";import"./empty-state-Dv5iV4jb.js";import"./form-DYSiVEri.js";import"./useMutationState-lbcdmnfE.js";function _o({open:s,initialTab:t,defaultTab:n}){const[a,r]=m.useState(t??n),[i,o]=m.useState(s);return s!==i&&(o(s),s&&t&&r(t)),[a,r]}/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Yn={name:"palette",size:24,node:[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]};Yn.node;const $o=hn(Yn);/**
6
+ */const Vn={name:"palette",size:24,node:[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]};Vn.node;const $o=pn(Vn);/**
7
7
  * @license lucide-react v1.48.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Vn={name:"settings-2",size:24,node:[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]};Vn.node;const _o=hn(Vn);function Fo({storageKey:s,dialogOpen:t,activeInGroup:n,activeTab:a}){const[r,i]=m.useState(()=>It(s,!1)),[o,l]=m.useState(t),c=t&&n?a:null,[d,u]=m.useState(null);let x=r;return t!==o&&(l(t),t&&(x=It(s,!1))),c!==d&&(u(c),c!==null&&(x=!0)),x!==r&&i(x),[x,p=>{ha(s,p),i(p)}]}function Mo({open:s,onOpenChange:t,title:n,description:a,headerSlot:r,defaultTab:i,initialTab:o,tabs:l,extensionSlot:c,maxWidth:d="max-w-2xl",minHeight:u="min-h-[280px]",maximized:x=!1,foldedGroup:h,testId:p}){const f=pn(c??"settings.tabs"),g=c?[...l,...f.map(Uo)]:l,y=[];for(const S of g)y.includes(S.group)||y.push(S.group);const N=h==null?void 0:h.group;N!==void 0&&y.includes(N)&&(y.splice(y.indexOf(N),1),y.push(N));const j=g.some(S=>S.group),C=o&&g.some(S=>S.id===o)?o:null;m.useEffect(()=>{},[o,C,i]);const[O,A]=Lo({open:s,initialTab:C,defaultTab:i}),T=N!==void 0&&g.some(S=>S.id===O&&S.group===N),[E,v]=Fo({storageKey:(h==null?void 0:h.storageKey)??"",dialogOpen:s,activeInGroup:T,activeTab:O}),k=m.useId(),Z=S=>S.map(K=>e.jsx(Sa,{value:K.id,icon:K.icon,children:K.label},K.id)),H=N===void 0?[]:g.filter(S=>S.group===N&&(E||S.id===O)),F=N!==void 0&&g.some(S=>S.group===N),M=m.useRef(!1);m.useEffect(()=>{var S,K,I;!E||!M.current||(M.current=!1,(I=(K=(S=document.getElementById(k))==null?void 0:S.querySelector("[data-value]"))==null?void 0:K.scrollIntoView)==null||I.call(K,{block:"nearest"}))},[E,k]);const W=F?e.jsxs(e.Fragment,{children:[e.jsx(pa,{expanded:E,onExpandedChange:S=>{M.current=S,v(S)},controls:H.length>0?k:void 0,children:N}),H.length>0&&e.jsx(ga,{id:k,label:N,children:Z(H)})]}):void 0;return e.jsx(et,{open:s,onOpenChange:t,children:e.jsx(st,{"data-testid":p,className:L("max-h-[85vh] gap-0 p-0",d,x&&"md:h-[92svh] md:max-h-[92svh] md:w-[95vw] md:max-w-[90rem]"),children:e.jsxs(fa,{value:O,onValueChange:S=>A(S),children:[e.jsx(ja,{}),e.jsxs(ya,{children:[e.jsx(tt,{className:"text-sm font-medium",children:n}),e.jsx(nt,{className:a?"text-muted-foreground text-xs":"sr-only",children:a??"Dialog"}),r]}),e.jsxs(ba,{children:[e.jsx(va,{footer:W,children:j?y.filter(S=>S===void 0||S!==N).map(S=>e.jsxs(m.Fragment,{children:[S&&e.jsx(Na,{children:S}),Z(g.filter(K=>K.group===S))]},S??"__ungrouped")):Z(g)}),e.jsx(ka,{className:L(u,"p-4"),children:g.map(S=>{const K=S.component;return e.jsx(wa,{value:S.id,children:e.jsxs("div",{className:"max-w-3xl space-y-4",children:[e.jsx(Ca,{actions:S.actions,description:S.description,children:S.label}),e.jsx(m.Suspense,{fallback:e.jsx(zo,{}),children:e.jsx(K,{})})]})},S.id)})})]})]})})})}function zo(){return e.jsx("div",{className:"text-muted-foreground py-8 text-center text-sm",children:"Loading…"})}function Uo(s){return{id:s.id,label:s.label,icon:s.icon,component:s.component,group:s.group??"Add-ons"}}function Ko(){const{data:s}=Se(),t=ye(),n=s==null?void 0:s.welcomeBack,a=m.useCallback(i=>{t.mutate({welcomeBack:{enabled:i}})},[t]),r=m.useCallback(i=>{t.mutate({welcomeBack:{offersEnabled:i}})},[t]);return{enabled:(n==null?void 0:n.enabled)??!1,absenceThresholdMinutes:(n==null?void 0:n.absenceThresholdMinutes)??0,maxPosts:(n==null?void 0:n.maxPosts)??0,offersEnabled:(n==null?void 0:n.offersEnabled)??!1,setEnabled:a,setOffersEnabled:r,isAvailable:n!==void 0,isPending:t.isPending}}function Bo({className:s}){const[t,n]=m.useState(!1);return e.jsxs("div",{className:L("w-full",s),children:[e.jsx(Pi,{open:t,onToggle:()=>n(a=>!a)}),e.jsx(Le,{initial:!1,children:t&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[0,0,.2,1]},className:"overflow-hidden",children:e.jsx("div",{className:"pt-2",children:e.jsx(Li,{})})},"payload")})]})}function Qn(s){return{connectionId:s.connectionId,name:`${no(s.toolkit)} (${s.label})`,agentCount:s.agentCount,everyAgent:s.everyAgent!==null,usable:s.readiness.state==="ready"}}function bt(s){return s.filter(t=>t.readiness.state!=="gone"&&t.mode==="managed").map(Qn)}function Gn(s){return{stopping:s.filter(t=>t.usable),idle:s.filter(t=>!t.usable)}}function ps(s){return`${s} ${s===1?"app":"apps"}`}function Mt({app:s}){return e.jsxs("li",{children:[s.name,s.everyAgent?e.jsx("span",{className:"text-muted-foreground",children:" · used by every agent"}):s.agentCount>0&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· used by ",s.agentCount," ",s.agentCount===1?"agent":"agents"]})]})}function Vs({stopping:s,idle:t,stopLine:n}){if(s.length===0&&t.length===0)return null;const a="text-foreground max-h-40 list-disc space-y-1 overflow-y-auto pl-5 text-sm";return e.jsxs("div",{className:"space-y-3 text-sm","data-testid":"connection-impact-list",children:[s.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:n}),e.jsx("ul",{className:a,children:s.map(r=>e.jsx(Mt,{app:r},r.connectionId))})]}),t.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-muted-foreground",children:[t.length===1?"This app":`These ${t.length} apps`," can’t be used now either way:"]}),e.jsx("ul",{className:a,children:t.map(r=>e.jsx(Mt,{app:r},r.connectionId))})]})]})}function Wo({signedOut:s,children:t}){var x;const{view:n,start:a,unlink:r,cancel:i,starting:o,unlinking:l,startError:c,unlinkError:d}=Aa();qo(n,a);const u=((x=Ta().data)==null?void 0:x.linked)===!0;return n.kind==="loading"?e.jsx(ee,{className:"h-24 w-full"}):n.kind==="linked"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Vo,{view:n,start:a,starting:o,startError:c,dismiss:i}),t,e.jsx(Qo,{unlink:r,unlinking:l,unlinkError:d})]}):e.jsxs("div",{className:"space-y-4",children:[!u&&s,e.jsx(R,{children:e.jsx(D,{children:e.jsx(Ho,{view:n,start:a,cancel:i,starting:o,startError:c,relinking:u})})})]})}function qo(s,t){const{section:n,setSection:a}=fe(),r=m.useRef(!1),i=n===Ea;m.useEffect(()=>{if(!i){r.current=!1;return}r.current||s.kind==="loading"||(r.current=!0,a(null),s.kind!=="pending"&&t())},[i,s.kind,t,a])}function Ho({view:s,start:t,cancel:n,starting:a,startError:r,relinking:i}){switch(s.kind){case"idle":return e.jsx(Yo,{start:t,starting:a,startError:r});case"pending":return e.jsx(Oa,{view:s,cancel:n,relinking:i},s.userCode);case"expired":return e.jsx(Es,{title:"Your code expired",description:"It ran out before you approved it.",actionLabel:"Get a new code",onAction:t,pending:a});case"denied":return e.jsx(Es,{title:"Link request denied",description:"It was turned down on dorkos.ai.",actionLabel:"Link this computer",onAction:t,pending:a});case"revoked":return e.jsx(Es,{title:"This computer was unlinked",description:"DorkOS removed its access to your account.",actionLabel:"Link again",onAction:t,pending:a})}}function Yo({start:s,starting:t,startError:n}){var N;const a=m.useId(),{data:r}=Se(),i=ye(),o=((N=r==null?void 0:r.telemetry)==null?void 0:N.linkAnalyticsToAccount)??!1,l=Ra({value:o,generation:0});l.read().value!==o&&l.write({value:o,generation:l.read().generation+1});const c=l.read().generation,[d,u]=m.useState(null),x=d!==null&&d.generation===c?d.value:o,h=j=>u({generation:c,value:j}),[p,f]=m.useState(null),g=m.useCallback(async()=>{f(null);try{await i.mutateAsync({telemetry:{linkAnalyticsToAccount:x}})}catch{f("Couldn’t save your choice. Try again.");return}await s()},[i,x,s]),y=t||i.isPending;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(gn,{id:a,checked:x,onCheckedChange:j=>h(j===!0),disabled:y,className:"mt-0.5"}),e.jsxs("label",{htmlFor:a,className:"space-y-1 text-sm leading-snug",children:[e.jsx("span",{className:"font-medium",children:"Link usage counts to your account"}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:"See this install’s anonymous usage counts when signed in."}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:"Applies when you link. To change it later, link again."})]})]}),e.jsxs(b,{onClick:()=>void g(),disabled:y,children:[y?e.jsx(fs,{className:"mr-1.5"}):e.jsx(Eo,{className:"mr-1.5 size-(--size-icon-sm)"}),y?"Starting…":"Link this computer"]}),(p??n)&&e.jsx("p",{className:"text-destructive text-sm",role:"alert",children:p??n})]})}function Vo({view:s,start:t,starting:n,startError:a,dismiss:r}){return e.jsxs("div",{className:"space-y-4",children:[s.relinkOutcome&&e.jsx(Xo,{outcome:s.relinkOutcome,dismiss:r}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Signed in"}),s.accountLabel?e.jsx("p",{className:"text-foreground truncate text-sm",children:s.accountLabel}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Syncing account…"}),s.lastHeartbeatAt&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Last synced ",we(s.lastHeartbeatAt).toLowerCase()]})]}),e.jsxs(b,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void t(),disabled:n,children:[n?e.jsx(fs,{className:"mr-1.5"}):e.jsx(at,{className:"mr-1.5 size-3.5"}),"Link again"]})]}),a&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:a})]})}function Qo({unlink:s,unlinking:t,unlinkError:n}){return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Unlink this computer",description:"Stops using your DorkOS account. You can link again anytime.",children:e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsxs(b,{variant:"outline",size:"sm",disabled:t,"aria-label":"Unlink this computer",children:[e.jsx(Oo,{className:L("mr-1.5 size-3.5",t&&"animate-pulse")}),t?"Unlinking…":"Unlink"]})}),e.jsx(Jo,{unlink:s})]})}),n&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:n})]})})}const Go={denied:"The new link was turned down on dorkos.ai.",expired:"The new link’s code expired.",failed:"The new link couldn’t finish."};function Xo({outcome:s,dismiss:t}){return e.jsxs("div",{role:"status",className:"bg-muted/40 flex items-start gap-2 rounded-lg p-3 text-sm",children:[e.jsxs("p",{className:"min-w-0 flex-1",children:[Go[s]," This computer is still linked."]}),e.jsx(b,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",className:"-my-1 shrink-0",onClick:()=>void t(),children:e.jsx(rt,{className:"size-3.5"})})]})}function Jo({unlink:s}){const t=jt(),n=t.data?bt(t.data.connections):[],{stopping:a,idle:r}=Gn(n);return e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Unlink this computer?"}),e.jsx(ae,{children:"It stops using your DorkOS account. You can link again anytime."})]}),t.isPending?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Checking which apps use this account…"}):t.isError?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t check which apps use this account. Any that do will stop working."}):e.jsx(Vs,{stopping:a,idle:r,stopLine:`${a.length===1?"This app":`These ${a.length} apps`} will stop working for every agent:`}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:()=>void s(),children:a.length>0?`Unlink and stop ${ps(a.length)}`:"Unlink"})]})]})}function Es({title:s,description:t,actionLabel:n,onAction:a,pending:r}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Me,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:s}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t})]})]}),e.jsxs(b,{onClick:()=>void a(),disabled:r,children:[r?e.jsx(fs,{className:"mr-1.5"}):e.jsx(at,{className:"mr-1.5 size-(--size-icon-sm)"}),n]})]})}const vt=["auth","api-keys"];function Zo(){const s=it();return Y({queryKey:vt,queryFn:async()=>{const{data:t,error:n}=await s.apiKey.list();if(n||!t)throw new Error("Couldn’t load API keys. Try again.");return t.apiKeys},staleTime:3e4})}function el(){const s=it(),t=V(),[n,a]=m.useState(!1),[r,i]=m.useState(null);return{run:m.useCallback(async(l,c)=>{a(!0),i(null);const{data:d,error:u}=await s.apiKey.create({name:l.trim()||void 0,expiresIn:c??null});return a(!1),u||!d?(i(u??{message:"Couldn’t create the key. Try again.",status:0}),null):(await t.invalidateQueries({queryKey:vt}),d)},[s,t]),isPending:n,error:r,reset:()=>i(null)}}function sl(){const s=it(),t=V(),[n,a]=m.useState(null),[r,i]=m.useState(null);return{run:m.useCallback(async l=>{a(l),i(null);const{error:c}=await s.apiKey.delete({keyId:l});return a(null),c?(i(c),!1):(await t.invalidateQueries({queryKey:vt}),!0)},[s,t]),pendingId:n,error:r,reset:()=>i(null)}}const zt=[{label:"Never",value:"never",seconds:null},{label:"7 days",value:"7d",seconds:3600*24*7},{label:"30 days",value:"30d",seconds:3600*24*30},{label:"90 days",value:"90d",seconds:3600*24*90}];function tl({loginRequired:s=!0}={}){const t=m.useId(),{data:n,isError:a,isFetching:r,isLoading:i,refetch:o}=Zo(),l=el(),c=sl(),[d,u]=m.useState(""),[x,h]=m.useState("never"),[p,f]=m.useState(null);async function g(){var j;const y=((j=zt.find(C=>C.value===x))==null?void 0:j.seconds)??null,N=await l.run(d,y);N&&(f(N),u(""),h("never"))}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"API keys"})]}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Keys for MCP clients, scripts and agents. Send one as a"," ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]}),!s&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Keys still work with login off. Revoke any you don’t need."})]}),p?e.jsx(nl,{created:p,onDone:()=>f(null)}):e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"min-w-40 flex-1 space-y-1.5",children:[e.jsx(X,{htmlFor:t,children:"Name"}),e.jsx(J,{id:t,placeholder:"e.g. laptop-cli",value:d,onChange:y=>u(y.target.value)})]}),e.jsxs("div",{className:"w-32 space-y-1.5",children:[e.jsx(X,{children:"Expires"}),e.jsxs(oe,{value:x,onValueChange:h,children:[e.jsx(le,{children:e.jsx(ce,{})}),e.jsx(de,{children:zt.map(y=>e.jsx(P,{value:y.value,children:y.label},y.value))})]})]}),e.jsx(b,{onClick:g,disabled:l.isPending,children:l.isPending?"Creating…":"Create key"})]}),l.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:l.error.message}),e.jsx("div",{className:"space-y-1.5",children:i?e.jsx(ee,{className:"h-9 w-full"}):a?e.jsx(Xe,{title:"Couldn’t load API keys",description:"No keys were changed. Try again.",onRetry:()=>void o(),isRetrying:r,className:"py-6"}):n&&n.length>0?n.map(y=>e.jsx(al,{apiKey:y,revoking:c.pendingId===y.id,onRevoke:()=>c.run(y.id)},y.id)):e.jsx("p",{className:"text-muted-foreground text-xs",children:"No API keys yet."})}),c.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:c.error.message})]})}function nl({created:s,onDone:t}){const{copied:n,failed:a,copy:r}=ot();return e.jsxs("div",{className:"border-primary/40 bg-primary/5 space-y-3 rounded-lg border p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Copy your key now. It won’t be shown again."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s.key}),e.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1.5 transition-colors",onClick:()=>void r(s.key),"aria-label":a?"Couldn’t copy API key. Try again":"Copy API key",children:n?e.jsx(Ke,{className:"text-status-success size-4"}):a?e.jsx(rt,{className:"text-destructive size-4"}):e.jsx(fn,{className:"size-4"})})]}),e.jsx(b,{variant:"outline",size:"sm",onClick:t,children:"Done"})]})}function al({apiKey:s,revoking:t,onRevoke:n}){const a=s.name||"Unnamed key",r=s.start?`${s.start}…`:s.prefix||"";return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a}),e.jsxs("p",{className:"text-muted-foreground font-mono text-xs",children:[r,s.expiresAt?` · expires ${new Date(s.expiresAt).toLocaleDateString()}`:" · no expiry"]})]}),e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",disabled:t,"aria-label":`Revoke ${a}`,children:e.jsx(ds,{className:"size-3.5"})})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsxs(ne,{children:["Revoke “",a,"”?"]}),e.jsx(ae,{children:"Anything using it loses access right away. This can’t be undone."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:n,children:"Revoke key"})]})]})]})]})}const Ut=["auth","signed-in-devices"];function rl(s){if((s==null?void 0:s.status)===404)return"That list was out of date. It’s up to date now.";const t=s instanceof Error?s.message:"";return t&&!/^HTTP \d+$/.test(t)?t:"Couldn’t sign that out. Try again."}function il(s=!0){const t=U(),n=V(),[a,r]=m.useState(null),[i,o]=m.useState(null),l=Y({queryKey:Ut,queryFn:()=>t.listSignedInDevices(),enabled:s,retry:!1,staleTime:1e4}),c=ge({mutationFn:d=>d(),onMutate:()=>o(null),onError:d=>o(rl(d)),onSettled:()=>{r(null),n.invalidateQueries({queryKey:Ut})}});return{data:l.data,isLoading:l.isLoading,isError:l.isError,isFetching:l.isFetching,refetch:()=>void l.refetch(),pendingId:a,signingOutOthers:c.isPending&&a===null,error:i,signOutDevice:d=>{r(d),c.mutate(()=>t.signOutDevice(d))},signOutEverywhereElse:()=>c.mutate(()=>t.signOutEverywhereElse())}}const ol={local:null,wifi:"Wi-Fi",tunnel:"Remote access",managed:"Remote access",network:"Another network",hub:"DorkOS in the cloud"};function ll(){var r,i;const s=il(),t=((r=s.data)==null?void 0:r.sessions)??[],n=((i=s.data)==null?void 0:i.canSignOutOthers)??!1,a=t.some(o=>!o.current);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Signed-in devices"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Signing a device out closes everything it had open."})]}),e.jsx("div",{className:"space-y-1.5",children:s.isLoading?e.jsx(ee,{className:"h-12 w-full"}):s.isError?e.jsx(Xe,{title:"Couldn’t load signed-in devices",description:"Nothing was signed out. Try again.",onRetry:s.refetch,isRetrying:s.isFetching,className:"py-6"}):t.length>0?t.map(o=>e.jsx(cl,{device:o,canSignOut:!o.current&&n,signingOut:s.pendingId===o.id,onSignOut:()=>s.signOutDevice(o.id)},o.id)):e.jsx("p",{className:"text-muted-foreground text-xs",children:"No devices are signed in."})}),a&&!n&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Sign out other devices on the computer DorkOS runs on."}),a&&n&&e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"outline",size:"sm",disabled:s.signingOutOthers,children:s.signingOutOthers?"Signing out…":"Sign out everywhere else"})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Sign out everywhere else?"}),e.jsx(ae,{children:"Every other device must sign in again. This one stays signed in."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:s.signOutEverywhereElse,children:"Sign out everywhere else"})]})]})]}),s.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:s.error})]})}function cl({device:s,canSignOut:t,signingOut:n,onSignOut:a}){const r=ol[s.route],i=`Last active ${dl(we(s.lastSeenAt))}`;return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:s.name}),s.current&&e.jsx(se,{variant:"secondary",children:"This device"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:r?`${r} · ${i}`:i})]}),t&&e.jsxs(b,{variant:"ghost",size:"sm",onClick:a,disabled:n,"aria-label":`Sign out ${s.name}`,children:[e.jsx(jn,{className:"mr-1.5 size-3.5"}),n?"Signing out…":"Sign out"]})]})}function dl(s){return s.replace(/^(Just now|Yesterday)/,t=>t.toLowerCase())}function ul(){var p,f;const s=lt(),{data:t,refetch:n}=Se(),a=ye(),r=Ia(),i=Pa(),o=((p=t==null?void 0:t.auth)==null?void 0:p.enabled)??!1,l=((f=t==null?void 0:t.auth)==null?void 0:f.ownerEmail)??null,[c,d]=m.useState(null);function u(g){g?d(l?{kind:"sign-in",email:l}:{kind:"create"}):a.mutate({auth:{enabled:!1}})}async function x(){await a.mutateAsync({auth:{enabled:!0}}),d(null)}async function h(g){var j;const{data:y}=await n(),N=((j=y==null?void 0:y.auth)==null?void 0:j.ownerEmail)??g;N&&d({kind:"sign-in",email:N})}return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:s?"You sign in here with your DorkOS account.":"Other devices always need your password. This computer can ask for it too."})}),e.jsx(R,{children:e.jsxs(D,{children:[!s&&e.jsx($,{label:"Ask for a password on this computer too",description:o?"This computer asks for your password before DorkOS opens.":"This computer opens DorkOS without a password.",children:e.jsx(He,{checked:o,onCheckedChange:u,"aria-label":"Ask for a password on this computer too"})}),r&&e.jsx($,{label:"Signed in",description:(r==null?void 0:r.email)??"Owner account",children:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>i.run(),disabled:i.isPending,children:[e.jsx(jn,{className:"mr-1.5 size-3.5"}),i.isPending?"Signing out…":"Sign out"]})})]})}),(r||l)&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(ll,{})})}),(o||r)&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(tl,{loginRequired:o})})}),e.jsx(yn,{open:c!==null,onOpenChange:g=>!g&&d(null),children:e.jsx(bn,{children:(c==null?void 0:c.kind)==="sign-in"?e.jsxs(e.Fragment,{children:[e.jsxs(zs,{children:[e.jsx(Us,{children:"Ask for a password here too"}),e.jsx(Ks,{children:"This turns on once your password checks out."})]}),e.jsx(La,{ownerEmail:c.email,onVerified:x,onCancel:()=>d(null)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(zs,{children:[e.jsx(Us,{children:"Create an owner account"}),e.jsx(Ks,{children:"This becomes your sign-in on every device."})]}),e.jsx($a,{submitLabel:"Create account & ask here too",onCreated:x,onOwnerExists:h,onCancel:()=>d(null)})]})})})]})}function ml(s){const t=U();return Y({queryKey:["relay","trace",s],queryFn:()=>t.getRelayTrace(s),enabled:!!s,staleTime:3e4})}function Nt(){const s=U();return Y({queryKey:["relay","metrics"],queryFn:()=>s.getRelayDeliveryMetrics(),staleTime:3e4,refetchInterval:3e4})}const Kt=["relay","conversations"],xl=500,hl=15e3;function pl(s=!0){const t=U(),n=_a({coalesceMs:xl}),a=()=>{s&&n([{queryKey:[...Kt]}])};return as("relay_message",a),as("relay_signal",a),as("relay_flow",a),as("relay_dead_letter",a),Y({queryKey:[...Kt],queryFn:()=>t.listRelayConversations(),enabled:s,refetchInterval:hl})}function gl(s,t){var r,i;const n=new Set(t.map(o=>o.providerInstanceId)),a={dorkosAccount:bt(s),byKeyInstance:{}};for(const o of s)o.readiness.state==="gone"||o.mode==="managed"||n.has(o.providerInstanceId)&&((r=a.byKeyInstance)[i=o.providerInstanceId]??(r[i]=[])).push(Qn(o));return a}function Xn({testId:s,name:t,detail:n,status:a,usedForNewApps:r=!1,actions:i,children:o}){return e.jsxs("li",{"data-testid":s,className:"space-y-3 px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 text-sm font-medium",children:[t,r&&e.jsx(se,{size:"xs",variant:"secondary","data-testid":"used-for-new-apps",children:"Used for new apps"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:n})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:L("size-2 rounded-full",Oe[a.tone]),"aria-hidden":!0}),a.label]}),i&&e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:i})]}),o]})}function fl(s){return s==="user"?"using your account key":s==="project"?"using your project key":null}function jl(s,t){return s.registered&&!t?{tone:"warning",label:"Can’t run actions"}:s.registered?{tone:"success",label:"Working"}:s.configured?{tone:"error",label:"Not working"}:{tone:"warning",label:"Key removed"}}function yl(s){return s==="composio"?"Composio project":s==="nango"?"Nango environment":`${Un(s)} account`}function bl({status:s,apps:t,usedForNewApps:n=!1,way:a}){const r=(a==null?void 0:a.canRunActions)!==!1,[i,o]=m.useState(!1),[l,c]=m.useState(null),d=Ji(),u=Un(s.type),x=s.configured?fl(s.keyKind):null,h=[`${ps(t.length)} connected`,x].filter(Boolean).join(" · "),{stopping:p,idle:f}=Gn(t),g=()=>{t.length===0||!s.configured?o(!0):c("change")};return e.jsxs(Xn,{testId:`connection-way-${s.type}`,name:Kn(s.type),detail:h,status:jl(s,r),usedForNewApps:n,actions:e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"sm",variant:"outline",onClick:g,disabled:i,children:s.configured?"Change key":"Add key again"}),s.configured&&e.jsx(b,{size:"sm",variant:"ghost",className:"text-destructive",disabled:d.isPending,onClick:()=>c("remove"),children:d.isPending?"Removing…":"Remove…"})]}),children:[s.error&&e.jsx("p",{role:"alert",className:"text-destructive border-destructive/30 bg-destructive/5 rounded-md border px-3 py-2 text-xs leading-relaxed",children:s.error}),s.registered&&!r&&e.jsx("p",{className:"text-muted-foreground text-xs",children:a!=null&&a.keyCanFix?Ft.accountKeyCannotRunActions:Ft.cannotRunActions}),!s.configured&&t.length>0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"These apps stopped when the key was removed. Add it again to restore them."}),i&&e.jsx(Zi,{type:s.type,submitLabel:"Save key",onSaved:()=>o(!1),onCancel:()=>o(!1)}),e.jsx(me,{open:l!==null,onOpenChange:y=>{y||c(null)},children:e.jsx(xe,{children:l==="change"?e.jsxs(e.Fragment,{children:[e.jsxs(te,{children:[e.jsxs(ne,{children:["Change your ",u," key?"]}),e.jsx(ae,{children:"A new key pauses these apps until you review their access."})]}),e.jsx(Vs,{stopping:p,idle:f,stopLine:p.length===1?"This app pauses until you review it on the Connections page:":`These ${p.length} apps pause until you review them on the Connections page:`}),e.jsxs("div",{className:"text-muted-foreground space-y-1 text-sm",children:[e.jsx("p",{children:"Nothing changes until you save the new key."}),e.jsx("p",{children:"A key that doesn’t work stops every app until you fix it."}),e.jsxs("p",{children:["A key from a different ",yl(s.type)," can’t reach them at all."]})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Keep this key"}),e.jsx(pe,{onClick:()=>{c(null),o(!0)},children:"Continue to a new key"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(te,{children:[e.jsxs(ne,{children:["Remove your ",u," key?"]}),e.jsx(ae,{children:t.length===0?"No apps use this key right now.":"Your sign-ins are kept. Add the same key again to restore these apps."})]}),e.jsx(Vs,{stopping:p,idle:f,stopLine:`${p.length===1?"This app":`These ${p.length} apps`} will stop working for every agent:`}),e.jsxs(re,{children:[e.jsx(ie,{children:"Keep key"}),e.jsx(pe,{onClick:()=>d.mutate({provider:s.type}),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:p.length>0?`Remove key and stop ${ps(p.length)}`:"Remove key"})]})]})})})]})}function vl({onManageAccount:s,onOpenConnectionsPage:t}){var O,A,T,E;const n=U(),a=Y({queryKey:Ma,queryFn:()=>n.getCloudStatus(),staleTime:3e4}),r=eo(),i=so(),o=jt();if(r.isPending||o.isPending)return e.jsxs("div",{className:"space-y-2","aria-label":"Loading how DorkOS reaches your apps",children:[e.jsx(ee,{className:"h-16 rounded-lg"}),e.jsx(ee,{className:"h-16 rounded-lg"})]});if(r.isError||o.isError)return e.jsx(Xe,{title:"Couldn’t check how DorkOS reaches your apps",description:"Try again. Nothing was changed.",onRetry:()=>{r.isError&&r.refetch(),o.isError&&o.refetch()},isRetrying:r.isFetching||o.isFetching});const l=r.data,c=gl(o.data.connections,l),d=((O=a.data)==null?void 0:O.linked)===!0,u=d||a.isError||c.dorkosAccount.length>0,x=l.filter(v=>{var k;return v.configured||(((k=c.byKeyInstance[v.providerInstanceId])==null?void 0:k.length)??0)>0}),h=l.filter(v=>!x.includes(v)),p=a.isSuccess&&!u,f=!u&&x.length===0;if(f&&a.isPending)return e.jsx(ee,{className:"h-16 rounded-lg","aria-label":"Checking your DorkOS account"});const g=((A=i.data)==null?void 0:A.newApps.status)==="ready"?i.data.newApps.way:null,y=((T=i.data)==null?void 0:T.ways)??[],N=((E=y.find(v=>v.kind==="dorkos_account"))==null?void 0:E.status)!=="unavailable",j=(u?1:0)+x.length>1,C=e.jsx(wl,{keys:h,offerAccount:p,onManageAccount:s});return f?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted/40 space-y-3 rounded-lg p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Set up with your first app"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect an app and DorkOS asks how to reach it. You answer once."})]}),e.jsx(b,{size:"sm",variant:"outline",onClick:t,children:"Open the Connections page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Or set one up here now:"}),C]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("ul",{className:"divide-border divide-y rounded-lg border",children:[u&&e.jsx(Nl,{linked:d,reachesApps:N,checkFailed:a.isError,retrying:a.isFetching,onRetry:()=>void a.refetch(),apps:c.dorkosAccount,usedForNewApps:j&&(g==null?void 0:g.kind)==="dorkos_account",onManageAccount:s}),x.map(v=>e.jsx(bl,{status:v,apps:c.byKeyInstance[v.providerInstanceId]??[],usedForNewApps:j&&(g==null?void 0:g.kind)==="own_key"&&g.type===v.type,way:y.find(k=>k.kind==="own_key"&&k.type===v.type)},v.providerInstanceId))]}),(h.length>0||p)&&e.jsx(kl,{label:"Add another way",children:C})]})}function Nl({linked:s,reachesApps:t,checkFailed:n,retrying:a,onRetry:r,apps:i,usedForNewApps:o,onManageAccount:l}){const c=s?t?{tone:"success",label:"Working"}:{tone:"warning",label:"Can’t reach apps"}:n?{tone:"neutral",label:"Couldn’t check"}:{tone:"warning",label:"Not linked"};return e.jsxs(Xn,{testId:"connection-way-dorkos-account",name:"Your DorkOS account",detail:n&&i.length===0?"Couldn’t check your DorkOS account":`${ps(i.length)} connected`,status:c,usedForNewApps:o,actions:e.jsxs(e.Fragment,{children:[n&&e.jsx(b,{size:"sm",variant:"outline",onClick:r,disabled:a,children:a?"Checking…":"Try again"}),e.jsxs(b,{size:"sm",variant:"outline",onClick:l,children:["Manage account",e.jsx(Be,{className:"size-3.5","aria-hidden":!0})]})]}),children:[s&&!t&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Linked, but can’t reach apps now. Its apps won’t work until then."}),!s&&!n&&i.length>0&&e.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-xs",children:[e.jsx("p",{children:"These apps stopped when the account was unlinked."}),e.jsx("p",{children:"Linking the same DorkOS account again can restore them. Otherwise, reconnect them."})]})]})}function kl({label:s,children:t}){return e.jsxs(Ye,{children:[e.jsxs(Ve,{className:"text-muted-foreground hover:text-foreground focus-ring flex items-center gap-1.5 rounded-md text-sm font-medium",children:[e.jsx(Fa,{className:"size-4","aria-hidden":!0}),s]}),e.jsx(Qe,{className:"pt-3",children:t})]})}function wl({keys:s,offerAccount:t,onManageAccount:n}){return s.length===0&&!t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Every way is set up."}):e.jsxs("ul",{className:"divide-border divide-y rounded-lg border",children:[t&&e.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-48",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your DorkOS account"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Link this computer, then connect apps."})]}),e.jsxs(b,{size:"sm",variant:"outline",onClick:n,children:["Link account",e.jsx(Be,{className:"size-3.5","aria-hidden":!0})]})]}),s.map(a=>e.jsxs("li",{"data-testid":`add-connection-way-${a.type}`,className:"space-y-2 px-4 py-3",children:[e.jsx("p",{className:"text-sm font-medium",children:Kn(a.type)}),e.jsx(to,{status:a})]},a.providerInstanceId))]})}const Cl=3,Sl=3e5,Bt={min:1,max:20},Wt={min:10,max:3600},qt=1e3;function Al(){const s=Xi();return s.isLoading?e.jsx(ee,{className:"h-40 rounded-lg","aria-label":"Loading chat app settings"}):s.isError?e.jsx(Xe,{title:"Couldn’t check chat apps",description:"Check that DorkOS is running, then try again.",onRetry:s.retry,isRetrying:s.isRetrying}):s.enabled?e.jsx(Tl,{}):e.jsx(ro,{relay:s,variant:"block"})}function Tl(){var o,l,c;const s=Bn(!0),{mutate:t}=za(),{mutate:n}=ao();if(s.isPending)return e.jsx(ee,{className:"h-40 rounded-lg","aria-label":"Loading chat app settings"});if(s.isError)return e.jsx(Xe,{title:"Couldn’t load chat app settings",description:"Try again. Nothing was changed.",onRetry:()=>void s.refetch(),isRetrying:s.isFetching});const a=(o=s.data.find(d=>d.manifest.category==="internal"&&d.manifest.type==="claude-code"))==null?void 0:o.instances[0];if(!a)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing to set. Chat messages can’t start agents here."});const r=Number(((l=a.config)==null?void 0:l.maxConcurrent)??Cl),i=Number(((c=a.config)==null?void 0:c.defaultTimeoutMs)??Sl);return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Start working right away",description:"New messages start the agent at once.",checked:a.enabled,onCheckedChange:d=>t({id:a.id,enabled:d})}),e.jsx($,{label:"Most chats at once",description:"More wait their turn.",children:e.jsx(xs,{"aria-label":"Most chats at once",value:r,min:Bt.min,max:Bt.max,onCommit:d=>n({id:a.id,config:{maxConcurrent:d}})})}),e.jsx($,{label:"Give up after",description:"Seconds a message waits before it’s turned away.",children:e.jsx(xs,{"aria-label":"Give up after, in seconds",value:Math.round(i/qt),min:Wt.min,max:Wt.max,onCommit:d=>n({id:a.id,config:{defaultTimeoutMs:d*qt}})})})]})})}function Ol(s,t=()=>null,n={}){return s?[...new Set([...Object.keys(s.runtimes),...Object.keys(s.defaults??{})])].flatMap(r=>{var c,d,u,x,h,p;const i=(c=s.defaults)==null?void 0:c[r],o=(i==null?void 0:i.runsOn)==="credits",l=s.enabled&&s.runtimes[r]==="wired";return!l&&!o?[]:[{runtime:r,name:je(r).label,on:o,chosenBy:o?(i==null?void 0:i.chosenBy)??null:null,canTurnOn:l,canTurnOff:!0,unreachable:!l,previousSignIn:t(r),scope:(u=(d=n[r])==null?void 0:d.credits)==null?void 0:u.scope,caveat:(h=(x=n[r])==null?void 0:x.credits)==null?void 0:h.caveat,hasAccountPicks:((p=n[r])==null?void 0:p.supportsAccounts)===!0}]}):[]}function El(s){return!s||s.killed?[]:Object.entries(s.runtimes).filter(([,t])=>t==="wired").map(([t])=>je(t).label)}function Jn(){const{data:s}=ys(),t=bs(),{data:n}=Ge(),{accounts:a,ownResolvedAccount:r,nameFor:i}=vs(),o=Ol(s,d=>d==="claude-code"&&r?Rl(r,a,i):null,n==null?void 0:n.capabilities),l=(d,u)=>{const x=o.find(h=>h.runtime===d);x===void 0||x.on===u||(u?!x.canTurnOn:!x.canTurnOff)||t.mutate({runtime:d,useCredits:u})},c=t.isError?`Couldn’t change that. ${Zn(t.error)}`:null;return{rows:o,pending:t.isPending,failure:c,setOn:l}}function Rl(s,t,n){const a=t.find(i=>i.path===s);if(a)return a.label;const r=n(s);return r===Ua(s,[])?null:r}const Dl="Try again in a moment.";function Zn(s){return vn(s)??Dl}function Il(){var c;const{rows:s}=Jn(),t=jt(),n=$i(!0),a=ct(),r=s.filter(d=>d.on).map(d=>d.name),i=t.data?bt(t.data.connections):[],o=a&&((c=n.data)!=null&&c.available)?n.data.communities:[],l=r.length===0&&i.length===0&&o.length===0;return e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"What’s on your account"}),l?e.jsx("p",{className:"text-muted-foreground text-sm",children:a?"Nothing uses this account yet. Agents on credits, connected apps and spaces show here.":"Nothing uses this account yet. Agents on credits and connected apps show here."}):e.jsxs("dl",{className:"space-y-3 text-sm",children:[r.length>0&&e.jsx(Rs,{label:"Running on credits",items:r}),i.length>0&&e.jsx(Rs,{label:"Connected apps",items:i.map(d=>d.name)}),o.length>0&&e.jsx(Rs,{label:"Spaces",items:o.map(d=>d.name)})]})]})})}function Rs({label:s,items:t}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:s}),e.jsx("dd",{className:"font-medium",children:t.join(", ")})]})}function Pl(){const s=Ka(n=>n.sessions),{data:t}=Ge();return m.useMemo(()=>{var i;let n=0,a=0;for(const o of Object.values(s)){const l=(i=o.sessionStatus)==null?void 0:i.costUsd;typeof l=="number"&&l>0&&(n+=l,a+=1)}const r=Object.entries((t==null?void 0:t.capabilities)??{}).filter(([,o])=>o.supportsCostTracking===!1).map(([o])=>o).sort();return{totalUsd:n,sessionCount:a,runtimesWithoutCost:r,hasAnything:a>0||r.length>0}},[s,t])}function Ll(s,t,n){return s===0&&BigInt(n)>0n?`<0.001 ${t}`:`${s.toLocaleString("en-US",{maximumFractionDigits:3})} ${t}`}const Ht=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:"UTC"}),Yt=1440*60*1e3;function $l(s,t){const n=new Date(t),a=n.getTime()%Yt===0?new Date(n.getTime()-Yt):n;return`${Ht.format(new Date(s))} – ${Ht.format(a)}`}function gs(){return e.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t read the credit figures from your DorkOS account."})}function _l({otherCharges:s,denomination:t}){const n=(s==null?void 0:s.rows)??[];if(n.length===0)return null;const a=hs(t);return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Other charges"}),!a&&e.jsx(gs,{}),e.jsx("ul",{className:"space-y-2 text-sm",children:n.map((r,i)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:r.displayName}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[Ll(r.units,r.unit,r.dorkosPriceMicro)," ·"," ",e.jsx("span",{className:"whitespace-nowrap",children:$l(r.periodStart,r.periodEnd)})]})]}),a&&e.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:ls(r.dorkosPriceMicro,t)})]},`${i}-${r.periodStart}-${r.unit}`))})]})}function Fl(){const{data:s}=ze(),{data:t}=Ba("seat"),n=Pl();if(!(s!=null&&s.available))return null;const a=s.balance,r=a===null?null:_i(a.allowance.remainingMicro,a.allowance.grantedMicro),i=a==null?void 0:a.denomination,o=$t(a==null?void 0:a.allowance.remainingMicro,i),l=Os($t(a==null?void 0:a.allowance.grantedMicro,i)),c=gt(a==null?void 0:a.purchased.remainingMicro,i,"position"),d=ls(a==null?void 0:a.owedMicro,i),u=d===null||d==="0"?null:Os(d),x=a?Ml(a.allowance.resetsAt):null,h=t!=null&&t.available?t.usage.rows:[],p=t!=null&&t.available?t.usage.denomination:void 0,f=hs(p),g=t!=null&&t.available?Os(ls(t.usage.totals.dorkosPriceMicro,p)):null,y=t!=null&&t.available?t.usage.otherCharges:void 0;return e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Credits"}),a!==null&&(hs(i)?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-3 text-sm",children:[o!==null&&l!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Included"}),e.jsxs("dd",{className:"font-medium",children:[o," of ",l," left"]})]}),c!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Added"}),e.jsx("dd",{className:"font-medium",children:c})]}),u!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Owed"}),e.jsx("dd",{className:"font-medium",children:u})]})]}),r!==null&&e.jsx(Ro,{value:r*100,"aria-label":"Included left"}),x!==null&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Included credits renew ",x,"."]})]}):e.jsx(gs,{})),h.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where the credits went"}),!f&&e.jsx(gs,{}),e.jsx("ul",{className:"space-y-1 text-sm",children:h.map(N=>e.jsxs("li",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("span",{className:"truncate",children:N.displayName}),f&&e.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:ls(N.dorkosPriceMicro,p)})]},N.key))}),g!==null&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Total for the last 30 days: ",g]})]}),e.jsx(_l,{otherCharges:y,denomination:p}),n.hasAnything&&e.jsxs("div",{className:"space-y-1 border-t pt-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"On this machine"}),n.sessionCount>0&&e.jsxs("p",{className:"text-sm",children:[n.totalUsd.toFixed(2)," across ",n.sessionCount," ",n.sessionCount===1?"open chat":"open chats",", by their own estimate."]}),n.runtimesWithoutCost.length>0&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[n.runtimesWithoutCost.join(", ")," report no cost, so they’re left out."]})]})]})})}function Ml(s){const t=new Date(s);return Number.isNaN(t.getTime())?null:`on ${t.toLocaleDateString(void 0,{day:"numeric",month:"short"})}`}const zl=6e4,Ul=2**31-1;function Kl(){const s=U(),[t,n]=m.useState(null),[a,r]=m.useState({kind:"idle"}),[i,o]=m.useState(null),l=m.useRef(!1),c=m.useCallback(async()=>{if(l.current)return!1;l.current=!0,r({kind:"requesting"});try{const x=await s.requestCloudAccountDeletion();return x.ok?(n(x.deletion),r({kind:"idle"}),!0):(r({kind:"failed",notice:"problem"in x?{problem:x.problem}:{message:x.message}}),!1)}catch{return r({kind:"failed",notice:Wa}),!1}finally{l.current=!1}},[s]),d=m.useCallback(()=>{l.current||r({kind:"idle"})},[]);m.useEffect(()=>{if(t===null||t.confirmBy===null)return;const x=Date.parse(t.confirmBy)-Date.now();if(Number.isNaN(x)||x>Ul)return;const h=setTimeout(()=>o(t),Math.max(0,x));return()=>clearTimeout(h)},[t]);const u=t!==null&&i===t;return Bl(t!==null&&!u),{sent:t,expired:u,attempt:a,request:c,reset:d}}function Bl(s){const t=V(),n=qa();m.useEffect(()=>{if(!s)return;let a=!1,r=!1;const i=async()=>{if(a||r)return;r=!0;let d=null;try{d=await n({expected:!0})}catch{}finally{r=!1}a||d===null||d.linked||(a=!0,c(),t.invalidateQueries({queryKey:Ha.all}),$e.success("This computer is unlinked",{description:"The deletion is confirmed. Everything on this computer stays."}))},o=()=>void i();window.addEventListener("focus",o);const l=setInterval(()=>void i(),zl);function c(){window.removeEventListener("focus",o),clearInterval(l)}return()=>{a=!0,c()}},[s,n,t])}function ea({heading:s="Your data"}){const{data:t}=ze(),{state:n,request:a,download:r}=Ya();return t!=null&&t.available?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:s}),n.kind==="requested"?n.export.downloadUrl!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm",children:"Your export is ready."}),e.jsxs(b,{type:"button",size:"sm",variant:"outline",onClick:r,children:["Download your data",e.jsx(Ns,{className:"size-3.5","aria-hidden":!0})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{role:"status",className:"text-sm",children:n.export.emailRequested?"Your export is being prepared. You’ll get an email when it’s ready.":"Your export is being prepared. Check back in a few minutes."}),e.jsx(b,{type:"button",size:"sm",variant:"outline",onClick:a,children:"Check again"})]}):e.jsx(b,{type:"button",size:"sm",variant:"outline",disabled:n.kind==="requesting","aria-busy":n.kind==="requesting",onClick:a,children:n.kind==="requesting"?"Asking…":"Export your account data"}),n.kind==="failed"&&e.jsx(us,{notice:n.notice})]}):null}const Ds="delete";function Wl(s){const t=new Date(s);return Number.isNaN(t.getTime())?null:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function ql(){const{data:s}=ze(),{sent:t,expired:n,attempt:a,request:r,reset:i}=Kl(),[o,l]=m.useState(!1),[c,d]=m.useState(""),u=m.useRef(null),x=m.useRef(null),h=m.useRef(null);if(!(s!=null&&s.available))return null;const p=c.trim().toLowerCase()===Ds,f=a.kind==="requesting",g=a.kind==="failed"?a.notice:null,y=j=>{f||(l(j),j||(d(""),i()))},N=()=>{!p||f||r().then(j=>{j&&(l(!1),d(""))})};return e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Delete your DorkOS account"}),t!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{ref:x,role:"status",tabIndex:-1,className:"text-sm outline-none",children:n?"The link has expired, so nothing was deleted. Send a new one to carry on.":e.jsx(Hl,{sentTo:t.confirmationSentTo,confirmBy:t.confirmBy})}),e.jsx(b,{type:"button",size:"sm",variant:"outline",disabled:f,"aria-busy":f,onClick:()=>void r(),children:f?"Sending…":"Send a new link"}),g!==null&&e.jsx(us,{notice:g})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Ends your plan and erases the account for good. Everything on this computer stays."}),e.jsx(b,{ref:h,type:"button",size:"sm",variant:"destructive",onClick:()=>l(!0),children:"Delete your DorkOS account…"})]}),e.jsx(et,{open:o,onOpenChange:y,children:e.jsxs(st,{className:"min-h-0 sm:max-w-md",onOpenAutoFocus:j=>{var C;j.preventDefault(),(C=u.current)==null||C.focus()},onCloseAutoFocus:j=>{const C=x.current??h.current;C!==null&&(j.preventDefault(),C.focus())},children:[e.jsxs(Nn,{children:[e.jsx(tt,{children:"Delete your DorkOS account?"}),e.jsx(nt,{children:"This can’t be undone. Nothing is deleted until you follow the emailed link."})]}),e.jsx(kn,{children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"What goes"}),e.jsxs("ul",{className:"text-muted-foreground list-inside list-disc space-y-1",children:[e.jsx("li",{children:"Your plan, which ends right away"}),e.jsx("li",{children:"Credits you haven’t used"}),e.jsx("li",{children:"The seats on your account"}),e.jsx("li",{children:"Everything else your DorkOS account holds"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"What stays"}),e.jsx("p",{className:"text-muted-foreground",children:"Everything on this computer: your agents, chats, projects and files."}),e.jsx("p",{className:"text-muted-foreground",children:"This computer unlinks and keeps working on its own."})]}),e.jsx(ea,{heading:"Want a copy first?"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:"delete-account-confirm",className:"font-medium",children:["Type ",e.jsx("strong",{children:Ds})," to confirm"]}),e.jsx(J,{ref:u,id:"delete-account-confirm","data-testid":"delete-account-confirm-input",value:c,onChange:j=>d(j.target.value),onKeyDown:j=>{j.key==="Enter"&&N()},placeholder:Ds,autoComplete:"off",disabled:f})]}),g!==null&&e.jsx(us,{notice:g})]})}),e.jsxs(wn,{children:[e.jsx(Va,{asChild:!0,children:e.jsx(b,{variant:"outline",disabled:f,children:"Cancel"})}),e.jsx(b,{variant:"destructive",disabled:!p||f,"aria-busy":f,onClick:N,children:f?"Sending…":"Email me the link"})]})]})})]})}function Hl({sentTo:s,confirmBy:t}){const n=t===null?null:Wl(t);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"block",children:["Check your email. A link went to ",e.jsx("span",{className:"font-medium",children:s}),"."]})," ",e.jsxs("span",{className:"block",children:["Your account is deleted only when you follow it",n===null?".":`, and the link works until ${n}.`]})," ",e.jsx("span",{className:"block",children:"This computer then unlinks on its own."})]})}const Yl={month:"a month",year:"a year"};function Vl(){const{data:s}=ze(),t=Qa();return s!=null&&s.available?e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Manage on the web"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Payments happen on the DorkOS website. Each of these opens in your browser."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Qs,{billing:t,page:"portal",children:"Billing and invoices"}),e.jsx(Qs,{billing:t,page:"topup",children:"Add credits"})]}),e.jsx(Ql,{billing:t,currentPlanId:s.entitlements.planId}),e.jsx(us,{notice:t.notice}),e.jsx(ea,{}),e.jsx(ql,{})]})}):null}function Qs({billing:s,page:t,children:n}){var r;const a=((r=s.pending)==null?void 0:r.page)===t;return e.jsxs(b,{type:"button",size:"sm",variant:"outline",disabled:s.pending!==null,"aria-busy":a,onClick:()=>s.open({page:t}),children:[a?"Opening…":n,e.jsx(Ns,{className:"size-3.5","aria-hidden":!0})]})}function Ql({billing:s,currentPlanId:t}){const{data:n}=Ga();if(!(n!=null&&n.available)||n.offers.offers.length===0)return null;const{offers:a,denomination:r}=n.offers;return a.some(i=>i.planId===t)?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Change plan"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Switch to another plan, or end yours, on the billing page."}),e.jsx(Qs,{billing:s,page:"portal",children:"Change plan"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Choose a plan"}),e.jsx("ul",{className:"divide-y rounded-md border",children:a.map(i=>{var d;const o=r?Hs(i.amountMicro,r):null,l=Yl[i.interval],c=((d=s.pending)==null?void 0:d.skuId)===i.skuId;return e.jsxs("li",{className:"flex items-center justify-between gap-3 px-3 py-2 text-sm",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium",children:i.displayName}),o!==null&&e.jsx("p",{className:"text-muted-foreground text-xs",children:l?`${o} ${l}`:o})]}),e.jsxs(b,{type:"button",size:"sm",variant:"outline",disabled:s.pending!==null,"aria-busy":c,"aria-label":`Choose ${i.displayName}${l?`, billed ${l}`:""}`,onClick:()=>s.open({page:"checkout",skuId:i.skuId}),children:[c?"Opening…":"Choose",e.jsx(Ns,{className:"size-3.5","aria-hidden":!0})]})]},i.skuId)})})]})}const Gl={byo:"Bring your own tunnel",on_demand:"Reachable when you open it",always_available:"Always reachable"},Xl={none:"Not available",addon:"Available separately",included:"Included"},Jl={community:"Community",priority:"Priority"};function Zl(){const{data:s}=ze(),t=ct();if(!(s!=null&&s.available))return null;const{entitlements:n}=s,{limits:a,seats:r}=n,i=n.denomination,o=gt(a.includedCreditsMicro,i,"position"),l=!hs(i);return e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Your plan"}),e.jsx("p",{className:"text-base font-semibold",children:n.planDisplayName})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-3 text-sm sm:grid-cols-3",children:[e.jsx(Ne,{label:"People",value:`${n.used.personSeats} of ${a.personSeatsIncluded}`}),e.jsx(Ne,{label:"Agents with an address",value:`${n.used.agentSeats} of ${a.agentSeatsIncluded}`}),e.jsx(Ne,{label:"Seats assigned",value:`${r.assigned} of ${r.total}`}),o!==null&&e.jsx(Ne,{label:"Included credits",value:o}),e.jsx(Ne,{label:"Cloud hours",value:`${a.cloudHours}`}),e.jsx(Ne,{label:"Storage",value:`${a.storageGb} GB`}),e.jsx(Ne,{label:"Remote access",value:Gl[a.remoteAccess]}),e.jsx(Ne,{label:"Custom address",value:Xl[a.customAddress]}),e.jsx(Ne,{label:"Support",value:Jl[a.support]})]}),l&&e.jsx(gs,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Only agents with an address take a seat. Local-only agents take none."}),e.jsx(Fn,{withSpaces:t})]})]})})}function Ne({label:s,value:t}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:s}),e.jsx("dd",{className:"font-medium",children:t})]})}function ec(){const{data:s}=Xa(),[t,n]=m.useState(null),a=s!=null&&s.available?s.orgs:[];m.useEffect(()=>{t===null&&a.length>0&&n(a[0].id)},[t,a]);const{data:r,isLoading:i,isError:o}=Ja(t),{data:l}=Za(t),{assign:c,release:d}=er(t),[u,x]=m.useState(null),[h,p]=m.useState(null);if(!(s!=null&&s.available))return null;if(i&&!r)return e.jsx(ee,{className:"h-24 w-full"});if(o)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t load your seats. Try again later."});if(!(r!=null&&r.available)||r.seats.length===0&&a.length<=1)return null;const f=l!=null&&l.available?l.members:[],g=j=>{x(null),p(null),!j.ok&&("problem"in j?x(j.problem):p(j.message))},y=async j=>{try{g(await d.mutateAsync(j))}catch{x(null),p("Couldn’t reach your account just now. Nothing changed.")}},N=async(j,C)=>{try{g(await c.mutateAsync({seatId:j,subject:{kind:"user",id:C}}))}catch{x(null),p("Couldn’t reach your account just now. Nothing changed.")}};return e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Seats"}),a.length>1&&e.jsx("select",{className:"border-input bg-background rounded-md border px-2 py-1 text-sm","aria-label":"Organization",value:t??"",onChange:j=>n(j.target.value),children:a.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))})]}),r.seats.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"No seats in this organization."}):e.jsx("ul",{className:"divide-y",children:r.seats.map(j=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:tc(j)}),e.jsx("p",{className:"text-muted-foreground text-xs",children:j.assignedAt?`Assigned ${we(j.assignedAt)}`:"Not assigned"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(se,{variant:"secondary",children:j.status}),j.status==="assigned"?e.jsx(b,{variant:"outline",size:"sm",disabled:d.isPending,onClick:()=>void y(j.id),children:"Release"}):f.length>0&&e.jsxs("select",{className:"border-input bg-background rounded-md border px-2 py-1 text-sm","aria-label":"Assign this seat to",defaultValue:"",disabled:c.isPending,onChange:C=>{const O=C.target.value;O!==""&&N(j.id,O)},children:[e.jsx("option",{value:"",children:"Assign to…"}),f.map(C=>e.jsx("option",{value:C.userId,children:sc(C,f)},C.id))]})]})]},j.id))}),u!==null&&e.jsxs("div",{className:"border-destructive/40 bg-destructive/5 space-y-1 rounded-md border px-3 py-2",children:[e.jsx("p",{className:"text-sm font-medium",children:u.title}),u.detail!==void 0&&e.jsx("p",{className:"text-sm",children:u.detail}),u.requiredPlanDisplayName!==void 0&&e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This needs ",u.requiredPlanDisplayName,"."]})]}),h!==null&&e.jsx("div",{className:"border-destructive/40 bg-destructive/5 rounded-md border px-3 py-2",children:e.jsx("p",{className:"text-sm",children:h})})]})})}function sc(s,t){return t.filter(a=>a.role===s.role).length===1?s.role:`${s.role} · ${s.userId}`}function tc(s){return s.address!==null?s.address.canonical:s.kind==="person"?"Person":"Agent"}function nc(){const{data:s}=sr(),[t,n]=m.useState(!1);if(t||!(s!=null&&s.available))return null;const{nudge:a}=s,r=a.denomination,i=gt(a.trailing30Micro,r,"charge"),o=Hs(a.suggestedPlanPriceMicro,r),l=Hs(a.savingMicro,r);return l===null||i===null||o===null?null:e.jsxs("div",{className:"bg-muted/50 flex items-start justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("p",{className:"text-sm",children:["Your last 30 days: ",i,". ",a.suggestedPlanDisplayName,": ",o,". Difference: ",l,"."]}),a.dismissible&&e.jsx(b,{variant:"ghost",size:"icon-sm",className:"size-6 shrink-0","aria-label":"Dismiss",onClick:()=>n(!0),children:e.jsx(rt,{className:"size-4"})})]})}function sa(s){return je(s).label}function ac(s){const t=s.map(sa);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function rc(){const{data:s}=ys(),t=(s==null?void 0:s.notices)??[];return t.length===0?null:e.jsx("div",{className:"space-y-2","data-testid":"credits-notices",children:t.map(n=>e.jsx(ic,{notice:n},n.kind==="signed-in"?`signed-in:${n.runtime}`:n.kind))})}function ic({notice:s}){const t=tr(),n=nr(s.kind==="filled"?s.runtimes:[]),a=ar(),r=bs(),i=fe(),o=t.isPending||a.isPending||r.isPending,l=[r,a,t].find(u=>u.isError),c=l?e.jsxs("p",{role:"alert",className:"text-destructive text-sm",children:["Couldn’t change that. ",Zn(l.error)]}):null;if(s.kind==="filled"){const u=ac(s.runtimes);return e.jsxs(Ts,{className:"space-y-2","data-testid":"credits-notice-filled",children:[e.jsxs("p",{className:"text-sm",children:[u," now ",s.runtimes.length===1?"runs":"run"," on your DorkOS credits."]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.runtimes.length===1?"It":"They"," had no working sign-in when you linked."]}),n.map(x=>e.jsx("p",{className:"text-muted-foreground text-sm",children:x},x)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{size:"sm",variant:"outline",disabled:o,onClick:()=>{t.mutate({kind:"filled"}),i.open("runtimes")},children:"Change"}),e.jsx(b,{size:"sm",variant:"outline",disabled:o,onClick:()=>a.mutate(),children:"Undo all"}),e.jsx(b,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"filled"}),children:"OK"})]}),c]})}if(s.kind==="offer")return e.jsxs(Ts,{className:"space-y-2","data-testid":"credits-notice-offer",children:[e.jsx("p",{className:"text-sm",children:"Your DorkOS account can pay for Claude Code. Nothing changes until you turn it on."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{size:"sm",disabled:o,onClick:()=>r.mutate({runtime:"claude-code",useCredits:!0}),children:"Use DorkOS credits"}),e.jsx(b,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"offer"}),children:"Not now"})]}),c]});const d=sa(s.runtime);return e.jsxs(Ts,{className:"space-y-2","data-testid":"credits-notice-signed-in",children:[e.jsxs("p",{className:"text-sm",children:["You’re signed in to ",d," now. It still uses your credits until you switch back."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(b,{size:"sm",variant:"outline",disabled:o,onClick:()=>r.mutate({runtime:s.runtime,useCredits:!1}),children:["Use my ",d," sign-in"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"signed-in",runtime:s.runtime}),children:"Keep credits"})]}),c]})}function oc(){const{rows:s,pending:t,failure:n,setOn:a}=Jn();return s.length===0?null:e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Use credits for"}),e.jsx(rc,{}),s.map(r=>e.jsx($,{label:r.name,description:lc(r),children:e.jsx(He,{checked:r.on,disabled:t||(r.on?!r.canTurnOff:!r.canTurnOn),onCheckedChange:i=>a(r.runtime,i),"aria-label":`Use credits for ${r.name}`})},r.runtime)),n!==null&&e.jsx("p",{className:"text-destructive text-sm",role:"alert",children:n})]})})}function lc(s){const t=cc(s);return s.caveat?`${t} ${s.caveat}`:t}function cc(s){if(s.on&&s.unreachable)return`${s.name} can’t run on credits now, so new work stops. Turn this off to continue.`;if(!s.on)return s.previousSignIn===null?`New ${s.name} work uses its own sign-in.`:`New ${s.name} work uses ${s.previousSignIn}.`;const t=s.previousSignIn===null?"Turning this off puts it back on its own sign-in.":`Turning this off puts it back on ${s.previousSignIn}.`;return s.chosenBy==="default"?`DorkOS turned this on when you linked, because ${s.name} had no sign-in. ${t}`:s.scope==="runtime"?`${s.name} runs on your DorkOS credits, chats already going included. ${t} It can't be switched while ${s.name} is in the middle of a reply.`:s.hasAccountPicks?`New ${s.name} work runs on your DorkOS credits unless an agent or a chat picks another account. ${t}`:`New ${s.name} chats run on your DorkOS credits. ${t}`}function dc(){const{data:s,isError:t,isPending:n}=ze();return n?e.jsx(ee,{className:"h-40 w-full"}):t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t reach your DorkOS account. Local agents still work."}):e.jsxs("div",{className:"space-y-4",children:[s.available?e.jsxs(e.Fragment,{children:[e.jsx(nc,{}),e.jsx(Zl,{}),e.jsx(Fl,{})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"No plan details to show yet."}),e.jsx(oc,{}),e.jsx(Il,{}),e.jsx(ec,{}),e.jsx(Vl,{})]})}function uc(s){if(s<60)return`${s} minutes`;const t=Math.round(s/60);return t<48?t===1?"an hour":`${t} hours`:`${Math.round(t/24)} days`}function mc(){const{enabled:s,absenceThresholdMinutes:t,offersEnabled:n,setEnabled:a,setOffersEnabled:r,isAvailable:i}=Ko();return i?e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Coming back"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Welcome-back notes",description:e.jsxs(e.Fragment,{children:[`Agents may leave a short note in your team channel after ${uc(t)} away.`," ",e.jsxs(qe,{label:"About welcome-back notes",children:[e.jsx("p",{children:"Off means no note, and no agent time spent checking."}),e.jsx("p",{children:"This setting follows you to every device."})]})]}),checked:s,onCheckedChange:a}),s&&e.jsx(_,{label:"Next-step offers",description:"Notes can end with a decision for you. Each runs that agent for a turn.",checked:n,onCheckedChange:r})]})})]}):null}function xc(){var s;return typeof window>"u"||(s=window.electronAPI)==null?void 0:s.tabSession}function hc(){const s=xc(),[t,n]=m.useState(null);if(m.useEffect(()=>{if(!s)return;let r=!0;return s.getStartupMode().then(i=>{r&&n(i)}),()=>{r=!1}},[s]),!s||t===null)return null;const a=r=>{r!=="reopen"&&r!=="fresh"||(n(r),s.setStartupMode(r).then(i=>{i&&n(i)}))};return e.jsx($,{label:"When DorkOS opens",description:"After a quit. Updates and crashes always bring your tabs back.",children:e.jsxs(oe,{value:t,onValueChange:a,children:[e.jsx(le,{className:"w-40","aria-label":"When DorkOS opens",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"reopen",children:"Reopen your tabs"}),e.jsx(P,{value:"fresh",children:"Start fresh"})]})]})})}function pc(){const{showTimestamps:s,setShowTimestamps:t,expandToolCalls:n,setExpandToolCalls:a,autoHideToolCalls:r,setAutoHideToolCalls:i,showTaskCelebrations:o,setShowTaskCelebrations:l,promoEnabled:c,setPromoEnabled:d,enableMessagePolling:u,setEnableMessagePolling:x,setOnboardingHiddenForSession:h}=Ee(),p=Ei(),{setRichText:f}=Ri(),{close:g}=fe(),y=ye(),N=V(),j=()=>{y.mutate({onboarding:{completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null,completedAt:null}},{onSuccess:()=>{N.invalidateQueries({queryKey:G.all})}}),h(!1),g()};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Chat"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Show timestamps",description:"Shows the time on each message.",checked:s,onCheckedChange:t}),e.jsx(_,{label:"Expand tool calls",description:"Opens tool call details in messages.",checked:n,onCheckedChange:a}),e.jsx(_,{label:"Auto-hide tool calls",description:"Finished tool calls fade after a moment.",checked:r,onCheckedChange:i}),e.jsx(_,{label:"To-do celebrations",description:"Animates finished to-dos.",checked:o,onCheckedChange:l}),e.jsx(_,{label:"Format text as you type",description:"Bold, headings and lists show as you write.",checked:p,onCheckedChange:f}),e.jsx(_,{label:"Watch for work started elsewhere",description:"Work started in a terminal shows up here sooner.",checked:u,onCheckedChange:x})]})})]}),dt()&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Tabs"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx(hc,{})})})]}),e.jsx(mc,{}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Discovery"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Feature suggestions",description:"Feature tips on the dashboard and sidebar.",checked:c,onCheckedChange:d}),e.jsx($,{label:"Replay setup",description:"Go through first-run setup again.",children:e.jsx(b,{variant:"outline",size:"sm",onClick:j,disabled:y.isPending,children:"Replay setup"})})]})})]})]})}function gc(){const s=Fi(),t=U(),n=V(),a=m.useCallback(async i=>{await t.updateConfig({keepAwake:{whileAgentsWork:i}}),await Promise.all([n.invalidateQueries({queryKey:[...Mi]}),n.invalidateQueries({queryKey:G.all})])},[t,n]);if(!s)return null;const r=s.supported?null:zi[s.reason??"platform"];return e.jsxs("div",{className:"space-y-2","data-section":Ui.section,children:[e.jsx("p",{className:"text-sm font-medium",children:"Sleep"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx(_,{label:"Keep this computer awake while agents work",description:e.jsxs("span",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:"Stays awake during chats, rooms and tasks. Sleeps as usual when idle."}),e.jsx("span",{"data-testid":"sleep-settings-note",children:r??Bi})]}),checked:s.enabled,onCheckedChange:i=>void a(i),disabled:!Ki(s)})})})]})}const Gs={login:{id:"reconnect",label:"Fix sign-in"},"provider-picker":{id:"change",label:"Change"}};function fc({type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:r,reconnect:i,toggleable:o,expanded:l,onToggleExpanded:c,bodyId:d,children:u}){const x=je(s),h=x.icon,p=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--runtime-accent)]/10 text-[var(--runtime-accent)]",children:e.jsx(h,{size:24})}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:x.label}),a&&e.jsx(se,{variant:"outline",className:"shrink-0 border-[var(--runtime-accent)]/40 bg-[var(--runtime-accent)]/10 text-[var(--runtime-accent)]","data-testid":`runtime-default-pill-${s}`,children:"Default"})]}),t&&e.jsx("span",{className:"text-muted-foreground truncate text-xs",children:t})]})]}),f=i?Gs[i.kind]:null;return e.jsxs("div",{className:"flex flex-col gap-1.5 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[o?e.jsx("button",{type:"button",onClick:c,"aria-expanded":l,"aria-controls":l?d:void 0,className:"focus-ring -m-1 flex min-w-0 flex-1 items-start gap-3 rounded-md p-1 text-left","data-testid":`runtime-card-toggle-${s}`,children:p}):e.jsx("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:p}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 pt-0.5",children:[n&&e.jsxs("span",{className:"text-status-success-fg inline-flex items-center gap-1 text-xs whitespace-nowrap","data-testid":`runtime-ready-${s}`,children:[e.jsx(Ke,{className:"size-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Ready"})]}),n&&f&&e.jsx("button",{type:"button",onClick:i==null?void 0:i.onOpen,className:"focus-ring text-muted-foreground hover:text-foreground hidden rounded-sm text-xs whitespace-nowrap underline-offset-2 transition-colors hover:underline sm:inline-flex","data-testid":`runtime-${f.id}-${s}`,children:f.label}),n&&!a&&r&&e.jsx("button",{type:"button",onClick:r,className:"focus-ring text-muted-foreground hover:text-foreground hidden rounded-sm text-xs whitespace-nowrap underline-offset-2 transition-colors hover:underline sm:inline-flex","data-testid":`runtime-make-default-${s}`,children:"Make default"}),o&&e.jsx("button",{type:"button",onClick:c,"aria-expanded":l,"aria-controls":l?d:void 0,"aria-label":`${l?"Hide":"Show"} ${x.label} ${n?"settings":"setup"}`,className:"focus-ring text-muted-foreground hover:text-foreground -m-1 inline-flex rounded-sm p-1 transition-colors","data-testid":`runtime-card-chevron-${s}`,children:e.jsx(We,{className:L("size-4 transition-transform",l&&"rotate-180")})})]})]}),u&&(o?e.jsx("button",{type:"button",tabIndex:-1,onClick:c,className:"focus-ring w-full rounded-md pl-12 text-left","data-testid":`runtime-card-summary-toggle-${s}`,children:u}):e.jsx("div",{className:"w-full pl-12",children:u}))]})}const Is="__inherit__";function jc({runtimeType:s,runtimeLabel:t,models:n,value:a,onChange:r,disabled:i,inheritLabel:o="Automatic",description:l}){const c=Co(n),d=a!==null&&c!==void 0&&!c.includes(a),u=(n??[]).some(h=>h.unverified),x=m.useId();return e.jsx($,{label:"Model",description:l??`Which ${t} model new chats start on. Automatic lets ${t} pick.`,orientation:"vertical",children:e.jsxs("div",{className:"w-52 space-y-1.5",children:[e.jsxs(oe,{value:a??Is,disabled:i,onValueChange:h=>r(h===Is?null:h),children:[e.jsx(le,{className:"w-full","aria-label":`Default ${t} model`,...u?{"aria-describedby":x}:{},"data-testid":`runtime-model-select-${s}`,children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:Is,children:o}),(n??[]).map(h=>e.jsx(P,{value:h.value,children:h.displayName},h.value)),a!==null&&!(n??[]).some(h=>h.value===a)&&e.jsx(P,{value:a,children:d?`${a} (no longer offered)`:a})]})]}),u&&e.jsx(So,{id:x})]})})}const Ie="__inherit__",yc=5;function bc({runtimeType:s,runtimeLabel:t,supportsEffort:n,selectedModel:a,configuredModelId:r,value:i,onChange:o,disabled:l}){const c=a?a.supportsEffort??!1:!0,d=rr.filter(u=>!(a!=null&&a.supportedEffortLevels)||a.supportedEffortLevels.includes(u));return e.jsx($,{label:"Effort",description:"How much effort new chats put into answers.",orientation:"vertical",children:n?c?d.length+1>yc?e.jsxs(oe,{value:i??Ie,disabled:l,onValueChange:u=>o(u===Ie?null:u),children:[e.jsx(le,{className:"w-52","aria-label":`Default ${t} effort`,"data-testid":`runtime-effort-${s}`,children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:Ie,children:"Automatic"}),d.map(u=>e.jsx(P,{value:u,children:cs(u)},u))]})]}):e.jsxs(ks,{"aria-label":`Default ${t} effort`,"data-testid":`runtime-effort-${s}`,disabled:l,value:i??Ie,onValueChange:u=>o(u===Ie?null:u),children:[e.jsx(_e,{value:Ie,children:e.jsx("span",{className:"truncate",children:"Automatic"})}),d.map(u=>e.jsx(_e,{value:u,children:e.jsx("span",{className:"truncate",children:cs(u)})},u))]}):e.jsxs("div",{className:"flex flex-col gap-1","data-testid":`runtime-effort-model-unsupported-${s}`,children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:[(a==null?void 0:a.displayName)??r," doesn’t take an effort setting"]}),i&&e.jsxs("button",{type:"button",onClick:()=>o(null),disabled:l,className:"focus-ring text-status-warning-fg self-start rounded-sm text-xs underline-offset-2 hover:underline disabled:pointer-events-none disabled:opacity-50","data-testid":`runtime-effort-clear-${s}`,children:[cs(i)," is saved but unused. Clear it"]})]}):e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":`runtime-effort-unsupported-${s}`,children:["Not supported by ",t]})})}const Xs={ask:"Asks before acting",act:"Pauses at big steps",autonomy:"Full autonomy"};function vc({runtimeType:s,runtimeLabel:t,descriptors:n,stop:a,globalStop:r,onChange:i,disabled:o}){var p;const l=a!==null,c=a??r,d=(p=Cn(n).find(f=>f.stop===c))==null?void 0:p.mode,u=(d==null?void 0:d.id)??"",x=c==="autonomy"&&(a===null||a===r),h=d!==void 0&&ir(d)&&!x;return e.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":`runtime-trust-${s}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where it stops for you"}),l?e.jsx(b,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",disabled:o,onClick:()=>i(null),children:"Use the shared setting"}):e.jsx("span",{className:"text-muted-foreground text-3xs tracking-wide uppercase","data-testid":`runtime-trust-global-${s}`,children:"Global setting"})]}),n.length===0?e.jsxs("p",{"data-testid":`runtime-trust-unavailable-${s}`,className:"text-muted-foreground px-1 text-xs leading-relaxed",children:[t," hasn’t listed its options yet. New chats use its own setting."]}):e.jsx(or,{mode:u,descriptors:n,stopLabels:Xs,disabled:o===!0,strandsWorkingMode:!0,strandedNote:`${t} has no setting here. New chats use its own.`,onChangeMode:f=>{const g=n.find(y=>y.id===f);g&&i(g.stop)}}),h&&e.jsx(Sn,{mode:u,descriptor:d,className:"px-1"})]})}const Nc="One sign-in away from its settings.",kc="Your default isn’t connected, so new chats can’t start.",wc=(s,t)=>`Your ${s} sign-in runs out in ${t}. Sign in again to keep agents working.`,Cc=s=>`Your ${s} sign-in stops working soon. Sign in again now.`,Sc=s=>`${s} keeps no settings here. It uses its own model and the setting below.`,Ac="Starts with";function Tc({type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:r,expanded:i,onToggleExpanded:o,summary:l,connectSlot:c,reconnect:d,reconnectPanel:u,model:x,effort:h,trust:p,storesDefaults:f=!0,sections:g,renderSection:y,setupDetails:N,setupBadge:j,expiringSignIn:C,className:O}){const A=je(s),T=m.useId(),[E,v]=m.useState(!1),k=n||!!N,Z=a&&!n,H=(g??[]).flatMap(F=>{const M=y==null?void 0:y(F.kind);return M?[e.jsx("div",{"data-testid":`runtime-card-section-${F.kind}-${s}`,children:M},F.kind)]:[]});return e.jsxs("article",{style:{"--runtime-accent":A.accent},className:L("bg-card border-border shadow-soft rounded-lg border",a&&"border-[var(--runtime-accent)]/40 ring-1 ring-[var(--runtime-accent)]/30",O),"data-testid":`runtime-card-${s}`,children:[e.jsx(fc,{type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:r,reconnect:d,toggleable:k,expanded:i,onToggleExpanded:o,bodyId:T,children:n?!i&&l.length>0&&e.jsxs("span",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs","data-testid":`runtime-card-summary-${s}`,children:[e.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:Ac}),l.map((F,M)=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-x-1.5 whitespace-nowrap",children:[M>0&&e.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 shrink-0",children:"·"}),e.jsx("span",{className:L("min-w-0 truncate",F.inherited?"text-muted-foreground":"text-foreground font-medium"),"data-inherited":F.inherited===!0,"data-testid":`runtime-card-summary-segment-${F.kind}-${M}`,children:F.label})]},`${F.kind}-${F.label}`))]}):e.jsx("span",{className:"text-muted-foreground text-xs","data-testid":`runtime-card-locked-${s}`,children:Nc})}),Z&&e.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1.5 px-4 pb-3 text-xs","data-testid":`runtime-default-broken-${s}`,children:[e.jsx(ue,{className:"mt-px size-3.5 shrink-0","aria-hidden":!0}),kc]}),C&&e.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1.5 px-4 pb-3 text-xs","data-testid":`runtime-sign-in-expiring-${s}`,children:[e.jsx(ue,{className:"mt-px size-3.5 shrink-0","aria-hidden":!0}),C.timeLeft===null?Cc(A.label):wc(A.label,C.timeLeft)]}),!n&&c&&e.jsx("div",{className:"px-4 pb-4",children:c}),n&&u&&e.jsx("div",{className:"px-4 pb-4",children:u}),i&&k&&e.jsxs("div",{id:T,className:"border-border/60 space-y-5 border-t px-4 py-4","data-testid":`runtime-card-body-${s}`,children:[n&&(d||!a&&r)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 sm:hidden",children:[d&&e.jsx("button",{type:"button",onClick:d.onOpen,className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs underline-offset-2 transition-colors hover:underline","data-testid":`runtime-${Gs[d.kind].id}-compact-${s}`,children:Gs[d.kind].label}),!a&&r&&e.jsx("button",{type:"button",onClick:r,className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs underline-offset-2 transition-colors hover:underline","data-testid":`runtime-make-default-compact-${s}`,children:"Make default"})]}),n&&(f?e.jsxs(e.Fragment,{children:[e.jsx(jc,{runtimeType:s,runtimeLabel:A.label,...x}),e.jsx(bc,{runtimeType:s,runtimeLabel:A.label,...h}),e.jsx(vc,{runtimeType:s,runtimeLabel:A.label,...p}),H]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":`runtime-card-no-settings-${s}`,children:Sc(A.label)}),H]})),N&&e.jsx(ws,{open:E,onOpenChange:v,trigger:"Setup details",badge:j,className:"bg-transparent",children:N})]})]})}const Oc="Automatic",Ec={ask:"Asks first",act:"Pauses at big steps",autonomy:"Full autonomy"},Rc={"claude-accounts":s=>`runs on ${s}`,"opencode-power-source":s=>s};function Dc(s){var a,r,i,o,l,c;if(!s.ready)return[];const t=[],n=(a=s.model)==null?void 0:a.trim();if(n){const d=(r=s.models)==null?void 0:r.find(u=>u.value===n);t.push({kind:"model",label:(d==null?void 0:d.displayName)??n,inherited:!1})}else t.push({kind:"model",label:s.inheritModelLabel??Oc,inherited:!0});(i=s.settings)!=null&&i.supportsEffort&&s.effort&&s.modelTakesEffort!==!1&&t.push({kind:"effort",label:`${cs(s.effort)} effort`}),s.trustStop&&t.push({kind:"trust",label:Ec[s.trustStop],inherited:s.trustInherited??!1});for(const d of((o=s.settings)==null?void 0:o.sections)??[]){const u=(c=(l=s.sectionValues)==null?void 0:l[d.kind])==null?void 0:c.trim(),x=Rc[d.kind];u&&x&&t.push({kind:"section",label:x(u)})}return t}function Ic(s){const t=s.map(n=>n.label);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Pc({stop:s,effectiveStop:t,runtimes:n,onChange:a,onChangeRuntime:r}){var x;const i=s??t,o=Cn(lr),l=n.filter(h=>h.stop==="autonomy"),c=i==="autonomy",d=c||l.length>0,u=(x=o.find(h=>h.stop===(d?"autonomy":i)))==null?void 0:x.mode;return e.jsxs("section",{className:"@container/trust-row flex flex-col gap-2","data-testid":"global-trust-row",children:[e.jsxs("div",{className:"flex flex-col gap-3 @2xl/trust-row:flex-row @2xl/trust-row:items-center @2xl/trust-row:justify-between @2xl/trust-row:gap-6",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where chats stop for you"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Cards above use this unless set otherwise."}),e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"global-trust-row-timing",children:[e.jsx("span",{children:"Applies to all chats from their next turn."})," ",e.jsx("span",{children:"Chats you set by hand only follow it down."})]})]}),e.jsx(ks,{"aria-label":"Where chats stop for you",className:"w-full @2xl/trust-row:w-auto @2xl/trust-row:shrink-0",value:i,onValueChange:h=>a(h),children:o.map(({stop:h,mode:p})=>e.jsxs(_e,{value:h,"aria-label":Xs[h],children:[e.jsx(cr,{descriptor:p,className:"size-(--size-icon-xs) shrink-0"}),e.jsx("span",{className:"truncate",children:Xs[h]})]},h))})]}),(c||l.length>0)&&e.jsxs("p",{className:`flex items-start gap-1.5 px-1 text-xs ${dr.power}`,"data-testid":"default-trust-stop-standing-note",children:[e.jsx(ur,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[c?"New chats run at full power":`New chats on ${Ic(l)} run at full power`,"."," ",e.jsx("button",{type:"button",className:"focus-ring rounded-sm underline underline-offset-2",onClick:()=>{c&&a("ask");for(const h of l)r(h.runtime,null)},children:"Change"})]})]}),e.jsx(Sn,{descriptor:u,className:"px-1"})]})}const Lc=[{key:"five_hour",label:"5-hour window"},{key:"seven_day",label:"Weekly"}];function ta(s,t=new Date){return!!s&&(s.windows.length>0||na(s.spend,t))}function na(s,t=new Date){if(!s)return!1;const n=new Date(s.periodStart);return Number.isNaN(n.getTime())?!1:n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()}function $c({spend:s}){return e.jsxs("p",{className:"text-muted-foreground text-xs tabular-nums","data-slot":"spend-line",children:[mr(s.costUsd)," spent this month"]})}function aa({usage:s,name:t,now:n=new Date}){if(!ta(s,n))return null;const a=s.windows.length>0;return e.jsxs("div",{className:"space-y-2","data-slot":"account-usage-bars",children:[t&&e.jsx("p",{className:"text-sm font-medium",children:t}),a?Lc.map(({key:r,label:i})=>e.jsx(Bs,{window:Ws(s,r),label:i},r)):na(s.spend,n)&&e.jsx($c,{spend:s.spend})]})}function Vt(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function _c(s,t){if(s===null)return null;const n=new Date(s);if(Number.isNaN(n.getTime()))return null;const a=Math.round((Vt(t)-Vt(n))/864e5);return a<=0?"used today":a===1?"used yesterday":`used ${a} days ago`}function Fc({folders:s,onAdd:t,onDismiss:n,error:a=null,disabled:r=!1}){const i=m.useId();if(s.length===0)return null;const o=new Date;return e.jsxs("div",{role:"group","aria-labelledby":i,className:"bg-muted/50 rounded-md border border-dashed px-3 py-1.5","data-testid":"found-accounts-group",children:[e.jsx("p",{id:i,className:"text-muted-foreground py-1 text-xs",children:"Found on this computer"}),e.jsx("ul",{className:"divide-y",children:s.map(l=>{const c=_c(l.lastUsedAt,o),d=(a==null?void 0:a.path)===l.path?a.message:null;return e.jsxs("li",{className:"py-2","data-testid":"found-account-row",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"min-w-40 flex-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-sm",children:[e.jsx("span",{className:"font-semibold break-all",children:l.name}),c&&e.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:["· ",c]}),l.orgManaged&&e.jsx("span",{className:L("text-2xs rounded-full px-2 leading-5 whitespace-nowrap",xr.warning),children:"managed by an organization"})]}),e.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",title:l.path,children:ms(l.path)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx(b,{size:"sm",variant:l.orgManaged?"outline":"default",onClick:()=>t(l),disabled:r,"aria-label":`Add ${l.name}`,children:"Add"}),e.jsx(b,{size:"sm",variant:"outline",onClick:()=>n(l),disabled:r,"aria-label":`Dismiss ${l.name}`,children:"Dismiss"})]})]}),d&&e.jsxs("p",{role:"alert",className:"text-destructive mt-1 flex items-start gap-1.5 text-xs","data-testid":"found-account-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:d})]})]},l.path)})})]})}function ra(s){return s.length<=1?s[0]??"":`${s.slice(0,-1).join(", ")} and ${s[s.length-1]}`}function kt(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function wt(){const s=V();return()=>{s.invalidateQueries({queryKey:G.all}),s.invalidateQueries({queryKey:Pe.all})}}function Mc({onlyProjects:s}){return s===null?null:e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-only-for",children:s.length===0?hr:`Only for ${ra(s.map(t=>t.name))}`})}function zc({open:s,onOpenChange:t,accountId:n,accountName:a,current:r}){const i=U(),o=wt(),l=m.useId(),c=Y({queryKey:Pe.projects(),queryFn:()=>i.listProjects(),enabled:s}),[d,u]=m.useState(r===null?"any":"only"),[x,h]=m.useState(()=>new Set((r??[]).map(A=>A.root))),[p,f]=m.useState(!1),g=ge({mutationFn:()=>i.setAccountOnlyProjects(n,d==="any"?null:[...x]),onSuccess:()=>{o(),t(!1)}}),y=c.data??[],N=(r??[]).filter(A=>!y.some(T=>T.root===A.root)),j=[...y,...N];function C(){if(d==="only"&&x.size===0){f(!0);return}f(!1),g.mutate()}function O(A,T){f(!1),h(E=>{const v=new Set(E);return T?v.add(A):v.delete(A),v})}return e.jsx(et,{open:s,onOpenChange:t,children:e.jsxs(st,{className:"max-h-[85vh] md:max-w-md",children:[e.jsxs(Nn,{children:[e.jsxs(tt,{className:"text-sm font-medium",children:["Where can ",a," work?"]}),e.jsx(nt,{className:"text-muted-foreground text-xs",children:"Nobody can use it anywhere else, even in folders outside a project."})]}),e.jsxs(kn,{className:"space-y-3",children:[e.jsxs(An,{value:d,onValueChange:A=>u(A),"aria-labelledby":l,children:[e.jsxs("span",{id:l,className:"sr-only",children:["Where ",a," can work"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qs,{value:"any",id:`${l}-any`}),e.jsx(X,{htmlFor:`${l}-any`,className:"text-sm font-normal",children:"Any project"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qs,{value:"only",id:`${l}-only`}),e.jsx(X,{htmlFor:`${l}-only`,className:"text-sm font-normal",children:"Only these projects"})]})]}),d==="only"&&e.jsxs("div",{className:"space-y-1.5 pl-6","data-testid":"limit-projects-list",children:[c.isPending&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Looking for projects…"}),!c.isPending&&j.length===0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"No projects yet. Start a chat in one first."}),j.map(A=>{const T=`${l}-${A.root}`;return e.jsxs("div",{className:"flex min-h-11 items-center gap-2 md:min-h-8",children:[e.jsx(gn,{id:T,checked:x.has(A.root),onCheckedChange:E=>O(A.root,E===!0)}),e.jsx(X,{htmlFor:T,className:"min-w-0 text-sm font-normal",children:e.jsx("span",{className:"truncate",children:A.name})})]},A.root)})]}),p&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Pick a project, or choose Any project."})]}),g.isError&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:kt(g.error)})]})]}),e.jsxs(wn,{children:[e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(b,{size:"sm",onClick:C,disabled:g.isPending,children:"Save"})]})]})})}function Uc({limits:s,nameForId:t}){const n=U(),a=wt(),r=m.useId(),i=ge({mutationFn:o=>n.setProjectAccounts(o,null),onSuccess:a});return s.length===0?null:e.jsxs("div",{role:"group","aria-labelledby":r,className:"rounded-md border px-3 py-1.5","data-testid":"project-limits",children:[e.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[e.jsx("p",{id:r,className:"text-muted-foreground text-xs",children:"Project limits"}),e.jsxs(qe,{label:"About project limits",children:[e.jsx("p",{children:"The Flow extension or a script sets each project’s list."}),e.jsx("p",{children:"Remove a limit to let that project use every account."})]})]}),e.jsx("p",{className:"text-muted-foreground pb-1 text-xs","data-testid":"project-limits-note",children:"These projects use only the accounts listed."}),e.jsx("ul",{className:"divide-y",children:s.map(({project:o,allow:l})=>e.jsxs("li",{className:"flex flex-wrap items-center gap-2 py-2","data-testid":"project-limit-row",children:[e.jsxs("div",{className:"min-w-40 flex-1",children:[e.jsx("p",{className:"text-sm font-medium break-all",children:o.name}),e.jsx("p",{className:"text-muted-foreground text-xs",children:l.length===0?"Uses no account":`Uses only ${ra(l.map(t))}`})]}),e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>i.mutate(o.root),disabled:i.isPending,"aria-label":`Let ${o.name} use every account`,children:"Remove"})]},o.root))}),i.isError&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 pb-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:kt(i.error)})]})]})}const Kc=["blue","green","amber","purple","pink","teal","indigo","stone"],is=[...br.map((s,t)=>({name:Kc[t]??s,hex:s})),{name:"Default",hex:null}];function Bc({name:s,color:t,colorIsDefault:n,onChoose:a,disabled:r,defaultOpen:i=!1}){const[o,l]=m.useState(i),c=m.useRef([]),d=is.findIndex(p=>p.hex===null?n:!n&&p.hex===t.toLowerCase()),u=d===-1?0:d;function x(p){l(!1),a(p)}function h(p){var j;const f=p.key==="ArrowRight"||p.key==="ArrowDown"?1:p.key==="ArrowLeft"||p.key==="ArrowUp"?-1:0;if(f===0)return;p.preventDefault();const g=c.current.findIndex(C=>C===document.activeElement),N=((g===-1?u:g)+f+is.length)%is.length;(j=c.current[N])==null||j.focus()}return e.jsxs(pr,{open:o,onOpenChange:l,children:[e.jsx(gr,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Color for ${s}`,"aria-haspopup":"dialog",disabled:r,className:"focus-visible:ring-ring -m-1 inline-flex shrink-0 rounded-full p-1 focus-visible:ring-2 focus-visible:outline-none",children:e.jsx(fr,{color:t,name:s,size:"md"})})}),e.jsxs(jr,{className:"w-auto p-3",align:"start",children:[e.jsxs(yr,{className:"sr-only",children:["Color for ",s]}),e.jsx("div",{role:"radiogroup","aria-label":`Color for ${s}`,className:"flex flex-wrap items-center gap-1.5",onKeyDown:h,children:is.map((p,f)=>{const g=f===d;return e.jsx("button",{ref:y=>{c.current[f]=y},type:"button",role:"radio","aria-checked":g,"aria-label":p.name,title:p.name,tabIndex:f===u?0:-1,onClick:()=>x(p.hex),className:L("focus-visible:ring-ring inline-flex items-center justify-center rounded-full focus-visible:ring-2 focus-visible:outline-none",p.hex===null?"text-foreground hover:bg-muted h-6 gap-1 border px-2 text-xs":"size-6 bg-(--swatch) text-white",g&&p.hex!==null&&"ring-foreground ring-2 ring-offset-2"),style:p.hex?{"--swatch":p.hex}:void 0,children:p.hex===null?e.jsxs(e.Fragment,{children:[g&&e.jsx(Ke,{className:"size-3","aria-hidden":!0}),"Default"]}):g&&e.jsx(Ke,{className:"size-3.5","aria-hidden":!0})},p.name)})})]})]})}function Wc(s){const t=U(),n=wt();return ge({mutationFn:a=>t.setAccountNoAutoMove(s,a),onSuccess:n})}function qc({accountId:s,noAutoMove:t,disabled:n}){const a=m.useId(),r=Wc(s),i=r.isPending?r.variables===!1:!t;return e.jsxs("div",{className:"mt-1 space-y-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(He,{id:a,size:"sm",className:"mt-0.5",checked:i,onCheckedChange:o=>r.mutate(!o),disabled:n||r.isPending,"data-testid":"claude-account-auto-move"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(X,{htmlFor:a,className:"text-xs font-normal",children:"Move agents here automatically"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"When an agent runs out in a room, it can continue here."})]})]}),r.error&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:kt(r.error)})]})]})}function Hc({name:s,rule:t,disabled:n}){const[a,r]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(Mc,{onlyProjects:t.onlyProjects}),e.jsx(b,{variant:"link",size:"sm",className:"text-muted-foreground h-auto px-0 py-0.5 text-xs",onClick:()=>r(!0),disabled:n,children:"Limit to projects…"}),a&&e.jsx(zc,{open:!0,onOpenChange:r,accountId:t.accountId,accountName:s,current:t.onlyProjects}),t.noAutoMove!==void 0&&e.jsx(qc,{accountId:t.accountId,noAutoMove:t.noAutoMove,disabled:n})]})}function Qt({name:s,account:t,isActive:n,onRemove:a,onChooseColor:r,rule:i,disabled:o,identity:l,signInState:c}){return e.jsxs("div",{className:"flex items-start gap-3","data-testid":"claude-account-row",children:[l&&e.jsx("span",{className:"mt-1 flex",children:e.jsx(Bc,{name:s,color:t.color,colorIsDefault:t.colorIsDefault,onChoose:r,disabled:o})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium",children:[s,n&&e.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:"in use"})]}),e.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",title:t.path,children:ms(t.path)}),e.jsx(Mn,{accountRoot:t.path,name:s,state:c}),i&&e.jsx(Hc,{name:s,rule:i,disabled:o}),!t.isAccountRoot&&e.jsxs("p",{className:"text-muted-foreground mt-1 flex items-start gap-1.5 text-xs","data-testid":"claude-account-not-ready",children:[e.jsx(ue,{className:"text-destructive mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Not a Claude Code account yet. No chats show from it."})]})]}),l&&e.jsxs("div",{className:"w-36 shrink-0 space-y-1 pt-0.5",children:[e.jsx(Bs,{window:Ws(l.usage,"five_hour"),label:"5h",compact:!0}),e.jsx(Bs,{window:Ws(l.usage,"seven_day"),label:"wk",compact:!0})]}),a?e.jsx(b,{variant:"ghost",size:"sm",onClick:a,disabled:o,"aria-label":`Remove ${s}`,children:e.jsx(ds,{className:"size-3.5"})}):e.jsx("span",{"aria-hidden":"true","data-testid":"claude-account-remove-spacer",className:L(vr({variant:"ghost",size:"sm"}),"invisible"),children:e.jsx(ds,{className:"size-3.5"})})]})}const Ps="__default__",Ls="__credits__";function os(s){return s.flatMap(t=>t.id?[t.id]:[])}function Js(s){const t=new Set([En,...s.flatMap(n=>n.id?[n.id]:[])]);return s.map(n=>{const a=n.id??Rn({label:n.label,path:n.path,taken:t});return t.add(a),{id:a,path:n.path,label:n.label,color:n.colorIsDefault?null:n.color}})}function Gt(s,t,n){const a=Js(s),r=Rn({label:n,path:t,taken:[En,...a.map(i=>i.id)]});return[...a,{id:r,path:t,label:n,color:null}]}function $s(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function Yc(){var ss,ve;const{data:s}=Se(),{nameFor:t,credits:n}=vs(),a=ye(),r=bs(),i=V(),[o,l]=m.useState(""),[c,d]=m.useState(""),[u,x]=m.useState(!1),[h,p]=m.useState(!1),[f,g]=m.useState(null),[y,N]=m.useState(null),j=U(),C=Y({queryKey:Pe.found(),queryFn:()=>j.getFoundClaudeFolders()}),O=ge({mutationFn:w=>j.dismissFoundClaudeFolder(w.path),onMutate:()=>N(null),onSuccess:()=>i.invalidateQueries({queryKey:Pe.found()}),onError:(w,B)=>N({path:B.path,message:$s(w)})}),A=Nr("claude-code"),T=ut("claude-code",{fetch:!0}),E=pn("settings.tabs").some(w=>w.id===Tn),v=s==null?void 0:s.claudeCode,k=(v==null?void 0:v.accounts)??[],Z=v==null?void 0:v.resolvedAccount,H=(v==null?void 0:v.inherited)??!0,F=v==null?void 0:v.resolvedAccountId,M=F&&F!==ke?k.find(w=>w.id===F):void 0,W=(M==null?void 0:M.path)??Z,S=n!==null&&(n.available||n.isDefault),K=n!=null&&n.isDefault?Ls:H||!W?Ps:W,I=A?T.byId.get(ke):void 0,be=o.trim(),Re=k.some(w=>w.path===be),Je=be.length>0&&!kr(be),Ze=be.length>0&&!Re&&!Je;function he(w,B,Q=g){g(null),N(null),a.mutate({runtimes:{claudeCode:w}},{onSuccess:()=>{i.invalidateQueries({queryKey:G.all}),i.invalidateQueries({queryKey:Pe.usage("claude-code")}),B==null||B()},onError:q=>Q($s(q))})}function es(w){g(null);const B=q=>g($s(q));if(w===Ls){r.mutate({runtime:"claude-code",useCredits:!0},{onError:B});return}const Q=w===Ps?null:w;if(n!=null&&n.isDefault){r.mutate({runtime:"claude-code",useCredits:!1},{onError:B,onSuccess:()=>{const q=H?null:(v==null?void 0:v.resolvedAccount)??null;Q!==q&&he({defaultAccount:Q})}});return}he({defaultAccount:Q})}function Ss(){Ze&&he({accounts:Gt(k,be,c.trim()||null),accountsSeen:os(k)},()=>{l(""),d(""),x(!1)})}function At(w){he({accounts:Gt(k,w.path,null),accountsSeen:os(k)},()=>void i.invalidateQueries({queryKey:Pe.found()}),B=>N({path:w.path,message:B}))}function As(w,B){he({accounts:Js(k).map((Q,q)=>k[q].path===w?{...Q,color:B}:Q),accountsSeen:os(k)})}function Ue(w){const B=Js(k.filter(q=>q.path!==w)),Q=!H&&M!==void 0&&M.path===w;he({accounts:B,accountsSeen:os(k),...Q&&{defaultAccount:null}})}return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"claude-accounts-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Runs on"}),e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground h-auto px-1 py-0 text-xs",onClick:()=>x(w=>!w),"aria-expanded":u,children:"Add account"})]}),!A&&e.jsx(Vc,{accounts:k,usage:T}),v&&k.length===0&&!A&&e.jsx(Mn,{accountRoot:v.resolvedAccount,name:t(v.resolvedAccount),state:(ss=T.byId.get(ke))==null?void 0:ss.signInState}),e.jsx($,{label:"Default account",description:"New chats run on this unless the agent or the chat picks another.",children:e.jsxs(oe,{value:K,onValueChange:es,disabled:r.isPending,children:[e.jsx(le,{className:"w-52","aria-label":"Default account","data-testid":"claude-account-select",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:Ps,children:H&&Z?`Default (${ms(Z)})`:"Default"}),wr(k,H?null:W).map(w=>e.jsx(P,{value:w.path,children:t(w.path)},w.path)),S&&e.jsx(P,{value:Ls,children:On})]})]})}),(n==null?void 0:n.isDefault)&&n.chosenBy==="default"&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-credits-chosen-for-you",children:"DorkOS chose this when you linked your account. Claude Code had no working sign-in."}),(n==null?void 0:n.isDefault)&&!n.available&&e.jsxs("div",{className:"text-muted-foreground text-xs","data-testid":"claude-credits-unavailable",children:[e.jsx("p",{children:"DorkOS credits aren’t available, so new chats here won’t start."}),e.jsx("p",{children:"Sign in to your DorkOS account again, or pick another account."})]}),(v==null?void 0:v.launchOverride)&&!F&&e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-launch-override",children:["New chats use ",ms(v.launchOverride.path),", from the server’s $CLAUDE_CONFIG_DIR."]}),k.map(w=>{var B;return e.jsx(Qt,{name:t(w.path),account:w,signInState:(B=T.byPath.get(w.path))==null?void 0:B.signInState,isActive:w.id!==null&&w.id===F,onRemove:()=>Ue(w.path),onChooseColor:Q=>As(w.path,Q),rule:w.id?{accountId:w.id,onlyProjects:w.onlyProjects??null,noAutoMove:w.noAutoMove===!0}:null,disabled:a.isPending,identity:A?{usage:(w.id?T.byId.get(w.id):void 0)??T.byPath.get(w.path)}:null},w.path)}),I&&e.jsx(Qt,{signInState:I.signInState,name:I.label??t(I.path),account:{path:I.path,color:(v==null?void 0:v.defaultAccountResolvedColor)??I.color,colorIsDefault:((v==null?void 0:v.defaultAccountColor)??null)===null,isAccountRoot:!0},isActive:F===ke,onChooseColor:w=>he({defaultAccountColor:w}),rule:{accountId:ke,onlyProjects:(v==null?void 0:v.defaultAccountOnlyProjects)??null},disabled:a.isPending,identity:{usage:I}}),e.jsx(Uc,{limits:(v==null?void 0:v.projectAccounts)??[],nameForId:w=>{if(w===ke)return(I==null?void 0:I.label)??"Main";const B=k.find(Q=>Q.id===w);return B?t(B.path):w}}),e.jsx(Fc,{folders:((ve=C.data)==null?void 0:ve.folders)??[],onAdd:At,onDismiss:w=>O.mutate(w),error:y,disabled:a.isPending||O.isPending}),A&&E&&e.jsx(Qc,{}),u&&e.jsx($,{orientation:"vertical",label:"Add an account",description:e.jsxs(e.Fragment,{children:["Pick the account’s Claude Code folder, then name it."," ",e.jsxs(qe,{label:"About adding an account",children:[e.jsx("p",{children:"Name it after the client it bills."}),e.jsx("p",{children:"DorkOS only reads the folder. It never signs you in or moves anything."})]})]}),children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ao,{"aria-label":"Account folder",placeholder:"/Users/you/.claude2",value:o,onChange:l,onBrowse:()=>p(!0),browseTestId:"browse-claude-account","data-testid":"claude-account-path"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{htmlFor:"claude-account-label",className:"text-muted-foreground text-xs",children:"Name"}),e.jsx(J,{id:"claude-account-label",placeholder:"Acme Corp",value:c,onChange:w=>d(w.target.value),className:"h-11 flex-1 md:h-8"}),e.jsx(b,{size:"sm",onClick:Ss,disabled:!Ze||a.isPending,children:"Add"})]}),Re&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-duplicate",children:"That folder is already added."}),Je&&e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-not-absolute",children:["Use the full path, like ",e.jsx("code",{children:"/Users/you/.claude2"}),". A path starting with"," ",e.jsx("code",{children:"~"})," won’t work."]})]})}),f&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs","data-testid":"claude-account-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:f})]}),e.jsx(Cr,{open:h,onOpenChange:p,onSelect:l,initialPath:be||null})]})}function Vc({accounts:s,usage:t}){const{nameFor:n}=vs();if(s.length>1)return null;const a=s[0],r=a?(a.id?t.byId.get(a.id):void 0)??t.byPath.get(a.path):t.byId.get(ke);if(!r)return null;const i=a?n(a.path):r.label??n(r.path);return e.jsx(aa,{usage:r,name:i})}function Qc(){const{setTab:s}=fe();return e.jsxs("p",{className:"bg-muted text-muted-foreground rounded-md px-3 py-2 text-xs",children:["Flow uses these accounts. Choose how in"," ",e.jsx("button",{type:"button",onClick:()=>s(Tn),className:"text-foreground font-semibold underline-offset-2 hover:underline",children:"Settings → Flow"}),"."]})}function Gc({type:s,provider:t,renderConnect:n}){const[a,r]=m.useState(!1);return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"power-source-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Power source"}),t&&!a&&e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground h-auto px-1 py-0 text-xs",onClick:()=>r(!0),"data-testid":"power-source-change",children:"Change"})]}),t?e.jsx("p",{className:"text-sm font-medium","data-testid":"power-source-current",children:Hn(t)}):e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"power-source-empty",children:[xt(s)," was signed in outside DorkOS, so its model source is unknown."]}),t&&a&&e.jsxs("div",{className:"space-y-2","data-testid":"power-source-panel",children:[n({type:s,connect:{kind:"provider-picker",label:"Change power source"},currentProvider:t,onConnected:()=>r(!1)}),e.jsx("button",{type:"button",onClick:()=>r(!1),className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs transition-colors","data-testid":"power-source-cancel",children:"Keep current source"})]})]})}function Xc({type:s}){var a;const{data:t}=mt(),n=(a=t==null?void 0:t.runtimes[s])==null?void 0:a.provider;return e.jsx(Gc,{type:s,...n?{provider:n}:{},renderConnect:Ys})}function Jc(s,t){return s==="effort"?`effort ${t}`:s==="account"||s==="runtime"?`runs on ${t}`:`${s} ${t}`}function Zc({exceptions:s}={}){const t=Wi({checkModels:s===void 0}),n=s??t.exceptions,a=fe();function r(i){a.close(),Tr.getState().openProfileDocked(i)}return n.length===0?null:e.jsxs("div",{className:"space-y-1","data-testid":"execution-exceptions-strip",children:[e.jsx("p",{className:"text-muted-foreground px-1 text-xs",children:"These agents run on something else:"}),e.jsx("ul",{className:"divide-border bg-card divide-y overflow-hidden rounded-lg border",children:n.map(({path:i,agent:o,report:l})=>{const c=l.isBroken?l.breakages.map(u=>u.message).join(" "):l.deviations.map(u=>Jc(u.field,u.label)).join(", "),d=Sr(o);return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(i),className:"hover:bg-accent flex w-full items-center gap-2 px-3 py-2 text-left transition-colors","data-testid":l.isBroken?"execution-exception-broken":"execution-exception",children:[e.jsx(Ar,{color:d.color,emoji:d.emoji,size:"xs"}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-start sm:gap-3",children:[e.jsx("span",{className:"truncate text-sm font-medium sm:pt-px",children:o.name}),e.jsxs("span",{className:L("flex min-w-0 items-start gap-1.5 text-xs sm:ml-auto sm:max-w-[65%]",l.isBroken?"text-status-warning-fg":"text-muted-foreground"),children:[l.isBroken&&e.jsx(Me,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"line-clamp-2",title:c,children:c})]})]})]})},i)})})]})}function ed(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function ia(){const{data:s}=Ge(),t=ye(),n=V(),[a,r]=m.useState(null),i=m.useCallback(c=>{r(null),t.mutate(c,{onSuccess:()=>{n.invalidateQueries({queryKey:G.all}),n.invalidateQueries({queryKey:Or.all})},onError:d=>r(ed(d))})},[t,n]),o=m.useCallback((c,d)=>{var x;if(c===null){i({runtimes:{defaultTrustStop:d}});return}const u=(x=qn(s,c))==null?void 0:x.configSection;u&&i({runtimes:{[u]:{defaultTrustStop:d}}})},[s,i]),l=m.useCallback(()=>r(null),[]);return{changeTrustStop:o,writeError:a,clearWriteError:l,isPending:t.isPending}}const sd={healthy:"success",delivered:"success",connected:"success",pending:"info",starting:"info",new:"info",reconnecting:"warning",degraded:"warning",warning:"warning",rate_limited:"warning",failed:"error",error:"error",disconnected:"error",inactive:"neutral",stopped:"neutral"};function Ct(s){return sd[s]??"neutral"}function td(s){return Oe[Ct(s)]}function nd(s){return Er[Ct(s)]}function ad(s){return Rr[Ct(s)]}const rd={delivered:"success",failed:"error",no_subscriber:"neutral",sent:"info",timeout:"neutral"};function id(s){return Oe[rd[s]]??Oe.neutral}function od(s){return new Date(s).toLocaleTimeString()}function Xt(s,t){if(s==null||t==null)return null;const n=new Date(t).getTime()-new Date(s).getTime();return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function ld({messageId:s,onClose:t}){const{data:n,isLoading:a,error:r}=ml(s);if(a)return e.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading trace…"});if(r||!n)return e.jsx("div",{className:"text-destructive p-4 text-sm",children:"Couldn’t load where this message went."});const{traceId:i,spans:o}=n;return e.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-muted-foreground font-mono text-xs",children:["Trace: ",i.slice(0,8),"…"]}),t&&e.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-xs",children:"Close"})]}),e.jsx("div",{className:"border-border relative ml-3 border-l pl-6",children:o.map(l=>{const c=Xt(l.sentAt,l.deliveredAt),d=Xt(l.deliveredAt,l.processedAt);return e.jsxs("div",{className:"relative pb-4 last:pb-0",children:[e.jsx("div",{className:`absolute top-1 -left-[calc(1.5rem+0.3125rem)] h-2.5 w-2.5 rounded-full ${id(l.status)}`}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:l.subject}),e.jsx("span",{className:"bg-muted rounded px-1.5 py-0.5 text-xs",children:l.status})]}),e.jsxs("div",{className:"text-muted-foreground flex gap-3 text-xs",children:[e.jsxs("span",{children:["Sent: ",od(l.sentAt)]}),c&&e.jsxs("span",{children:["Delivery: ",c]}),d&&e.jsxs("span",{children:["Processing: ",d]})]}),l.errorMessage&&e.jsx("div",{className:"bg-destructive/10 text-destructive mt-1 rounded px-2 py-1 text-xs",children:l.errorMessage})]})]},l.id)})})]})}function _s(s){if(s.payload&&typeof s.payload=="object"){const n=s.payload;if(typeof n.adapterId=="string")return n.adapterId}const t=s.from.raw.match(/^relay\.human\.([^.]+)/);return t?t[1]:""}function Jt(s){if(s.payload&&typeof s.payload=="object"){const t=s.payload;if(typeof t.chatId=="string")return t.chatId}}function Zt(s){if(s.payload&&typeof s.payload=="object"){const n=s.payload.channelType;if(n==="dm"||n==="group"||n==="channel"||n==="thread")return n}}const cd={delivered:"Delivered",failed:"Error",pending:"Pending"};function en(s){return new Date(s).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}function dd(s){return s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`}function ud(s){return s.status==="delivered"?s.responseCount>0?`delivered · ${s.responseCount} chunks`:"delivered":s.failureReason??cd[s.status].toLowerCase()}function md({conversation:s}){const[t,n]=m.useState(!1),[a,r]=m.useState(!1),[i,o]=m.useState(!1),[l,c]=m.useState(""),[d,u]=m.useState(!1),[x,h]=m.useState(!1),{data:p}=Dr(),f=m.useMemo(()=>(p==null?void 0:p.agents)??[],[p]),{mutate:g}=uo(),{data:y=[]}=_n(),N=_s(s),j=m.useMemo(()=>y.filter(k=>k.adapterId===N),[y,N]),C=td(s.status),O=nd(s.status),A=ad(s.status),T=m.useCallback(()=>{f.find(Z=>Z.id===l)&&(g({adapterId:_s(s),agentId:l,sessionStrategy:"per-chat",label:"",chatId:Jt(s),channelType:Zt(s)}),c(""),u(!1))},[f,l,s,g]),E=m.useCallback(()=>{u(!1),h(!0)},[]),v=m.useCallback(k=>{g({adapterId:k.adapterId,agentId:k.agentId,sessionStrategy:k.sessionStrategy,label:k.label,chatId:k.chatId,channelType:k.channelType,canInitiate:k.canInitiate,canReply:k.canReply,canReceive:k.canReceive}),h(!1)},[g]);return e.jsxs("div",{className:L("hover:bg-muted/50 w-full rounded-lg border border-l-2 text-left transition-colors hover:shadow-sm",A,t&&"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-start gap-2 p-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex min-w-0 flex-1 items-start gap-2",children:[e.jsx("span",{className:L("mt-1 size-2 shrink-0 rounded-full",C)}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsx("span",{className:"inline-block w-8 font-medium",children:"From"}),e.jsx("span",{className:"text-foreground",children:s.from.label})]}),e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsx("span",{className:"inline-block w-8 font-medium",children:"To"}),e.jsx("span",{className:"text-foreground",children:s.to.label})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.preview&&e.jsxs("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:["“",s.preview,"”"]}),e.jsx("span",{className:L("shrink-0 text-xs",O),children:ud(s)})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:we(s.sentAt)}),e.jsxs(Ir,{open:d,onOpenChange:u,children:[e.jsx(Pr,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:k=>k.stopPropagation(),"aria-label":"Route to agent",children:[e.jsx(io,{className:"mr-1 size-3"}),"Route"]})}),e.jsxs(Lr,{className:"w-64 space-y-3 p-3",align:"end",children:[e.jsx("p",{className:"text-xs font-medium",children:"Route to agent"}),j.length>0&&e.jsx("div",{className:"rounded border border-blue-200 bg-blue-50 px-2 py-1.5 text-xs dark:border-blue-900 dark:bg-blue-950",children:e.jsxs("p",{className:"font-medium text-blue-800 dark:text-blue-200",children:["Already goes to ",j.length," ",j.length===1?"agent":"agents"]})}),e.jsxs(oe,{value:l,onValueChange:c,children:[e.jsx(le,{responsive:!1,className:"h-8 text-xs",children:e.jsx(ce,{placeholder:"Select agent"})}),e.jsx(de,{children:f.map(k=>e.jsx(P,{value:k.id,children:$r(k)},k.id))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{variant:"link",size:"sm",className:"h-6 px-0 text-xs",onClick:E,children:"More options…"}),e.jsx(b,{size:"sm",className:"h-7 text-xs",disabled:!l,onClick:T,children:"Add connection"})]})]})]})]})]}),x&&e.jsx(mo,{open:!0,onOpenChange:k=>{k||h(!1)},mode:"create",initialValues:{adapterId:_s(s),agentId:l||void 0,chatId:Jt(s),channelType:Zt(s)},onConfirm:v}),e.jsx(Le,{initial:!1,children:t&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"space-y-3 border-t px-3 pt-3 pb-3",children:[s.payload!=null&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"Content"}),e.jsx("pre",{className:"bg-muted mt-1 max-h-40 overflow-auto rounded p-2 font-mono text-xs",children:JSON.stringify(s.payload,null,2)})]}),e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsxs("span",{children:["Sent ",en(s.sentAt)]}),s.completedAt&&e.jsxs("span",{children:[" · Completed ",en(s.completedAt)]}),s.durationMs!=null&&e.jsxs("span",{children:[" · Duration: ",dd(s.durationMs)]}),s.responseCount>0&&e.jsxs("span",{children:[" · ",s.responseCount," reply parts"]})]}),s.failureReason&&e.jsx("div",{className:"bg-destructive/10 text-destructive rounded px-2 py-1 text-xs",children:s.failureReason}),e.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),r(!a)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[a?e.jsx(We,{className:"size-3.5"}):e.jsx(Be,{className:"size-3.5"}),"Technical details"]}),e.jsx(Le,{initial:!1,children:a&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Subject"}),e.jsx("dd",{className:"truncate font-mono",children:s.subject}),s.sessionId&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Chat"}),e.jsx("dd",{className:"font-mono",children:s.sessionId.slice(0,8)})]}),s.traceId&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Trace ID"}),e.jsxs("dd",{className:"font-mono",children:[s.traceId.slice(0,12),"…"]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Source"}),e.jsx("dd",{className:"truncate font-mono",children:s.from.raw}),e.jsx("dt",{className:"text-muted-foreground",children:"Destination"}),e.jsx("dd",{className:"truncate font-mono",children:s.to.raw})]})})}),s.traceId&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),o(!i)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[i?e.jsx(We,{className:"size-3.5"}):e.jsx(Be,{className:"size-3.5"}),"Trace timeline"]}),e.jsx(Le,{initial:!1,children:i&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsx(ld,{messageId:s.traceId,onClose:()=>o(!1)})})})]})]})})})]})}const xd={hop_limit:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400",ttl_expired:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",cycle_detected:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",budget_exhausted:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"},hd="bg-muted text-muted-foreground";function pd(s,t){const n=we(s),a=we(t);return n===a?a:`${n} to ${a}`}function gd({group:s}){const[t,n]=m.useState(!1),a=_r(),r=xo[s.reason]??ho,i=xd[s.reason]??hd;return e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/50 p-3 dark:border-red-900/40 dark:bg-red-950/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Me,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:s.source}),e.jsx(se,{className:L("shrink-0 border-0 font-normal",i),children:r}),e.jsx(se,{variant:"destructive",className:"shrink-0 tabular-nums",children:s.count.toLocaleString()})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:pd(s.firstSeen,s.lastSeen)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.sample!=null&&e.jsxs(e.Fragment,{children:[e.jsxs(b,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n(!0),children:[e.jsx(Fr,{className:"mr-1 size-3"}),"See one"]}),e.jsx(yn,{open:t,onOpenChange:n,children:e.jsxs(bn,{className:"max-w-lg",children:[e.jsxs(zs,{children:[e.jsx(Us,{children:"What was sent"}),e.jsxs(Ks,{children:["Never arrived: ",r,"."]})]}),e.jsx("pre",{className:"bg-muted max-h-80 overflow-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(s.sample,null,2)})]})})]}),e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-7 px-2 text-xs",disabled:a.isPending,children:[e.jsx(ds,{className:"mr-1 size-3"}),"Clear these"]})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Clear these messages?"}),e.jsxs(ae,{children:["Clears ",s.count," message",s.count!==1?"s":""," from"," ",e.jsx("span",{className:"font-medium",children:s.source})," (",r,"). They won’t be sent, and this can’t be undone."]})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:()=>a.mutate({source:s.source,reason:s.reason}),children:"Clear these"})]})]})]})]})]})})}function fd({enabled:s=!0}){const{data:t=[],isLoading:n}=Dn(s),{data:a}=Nt(),r=a==null?void 0:a.budgetRejections,i=r&&Object.values(r).some(o=>o>0);return n||t.length===0?null:e.jsxs("div",{className:"space-y-2",children:[i&&e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-900 dark:bg-amber-950",children:e.jsxs("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200",children:["Not delivered: ",r.hopLimit," too many hand-offs,"," ",r.cycleDetected," loops, ",r.budgetExhausted," over limit,"," ",r.ttlExpired," expired"]})}),t.map(o=>e.jsx(gd,{group:o},`${o.source}:${o.reason}`))]})}function jd({enabled:s}){const{data:t}=Nt();if(!s||!t)return null;const n=[{label:"Total",value:t.totalMessages,variant:"default"},{label:"Delivered",value:t.deliveredCount,variant:"success"},{label:"Errors",value:t.failedCount,variant:t.failedCount>0?"danger":"default"},{label:"No listener",value:t.noSubscriberCount,variant:"default"},{label:"Never arrived",value:t.deadLetteredCount,variant:t.deadLetteredCount>0?"warning":"default"}];return e.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.map(({label:a,value:r,variant:i})=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:a}),e.jsx("span",{className:L("font-medium tabular-nums",i==="success"&&r>0&&"text-status-success-fg",i==="danger"&&"text-destructive",i==="warning"&&"text-status-warning-fg"),children:r.toLocaleString()})]},a)),t.avgDeliveryLatencyMs!=null&&e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg"}),e.jsx("span",{className:"font-medium tabular-nums",children:t.avgDeliveryLatencyMs<1e3?`${Math.round(t.avgDeliveryLatencyMs)}ms`:`${(t.avgDeliveryLatencyMs/1e3).toFixed(1)}s`})]})]})}function yd(s){return s.startsWith("relay.agent.")?"chat":s.startsWith("relay.system.tasks.")?"tasks":"system"}const bd={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}},vd={initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}};function Nd(s,t,n,a){return s.filter(r=>{if(t!=="all"&&yd(r.subject)!==t||n!=="all"&&r.status!==n)return!1;if(a){const i=a.toLowerCase();if(!(r.from.label.toLowerCase().includes(i)||r.to.label.toLowerCase().includes(i)||r.preview.toLowerCase().includes(i)||r.subject.toLowerCase().includes(i)))return!1}return!0})}function kd({enabled:s,deadLetterRef:t,onSwitchToIntegrations:n,autoShowFailures:a}){const[r,i]=m.useState("all"),[o,l]=m.useState("all"),[c,d]=m.useState(""),[u,x]=m.useState(null),{data:h,isLoading:p}=pl(s),{data:f=[]}=Dn(s),g=m.useMemo(()=>(h==null?void 0:h.conversations)??[],[h==null?void 0:h.conversations]);f.length>0;const y=m.useRef(null);m.useEffect(()=>{g.length>0&&y.current===null&&(y.current=new Set(g.map(E=>E.id)))},[g]);const N=u!==null&&(u.afterAutoShow||!a)?u:null,j=N!==null,C=N!==null?N.open:!!a||f.length>0,O=r!=="all"||o!=="all"||c!=="",A=Nd(g,r,o,c);function T(){i("all"),l("all"),d("")}return p?e.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(E=>e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted animate-breath size-4 rounded"}),e.jsx("div",{className:"bg-muted animate-breath h-4 w-40 rounded"}),e.jsx("div",{className:"bg-muted animate-breath ml-auto h-3 w-16 rounded"})]})},E))}):e.jsxs(e.Fragment,{children:[e.jsx(jd,{enabled:s}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(oe,{value:r,onValueChange:E=>i(E),children:[e.jsx(le,{className:"w-32",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"all",children:"All sources"}),e.jsx(P,{value:"chat",children:"Chat messages"}),e.jsx(P,{value:"tasks",children:"Scheduled runs"}),e.jsx(P,{value:"system",children:"System"})]})]}),e.jsxs(oe,{value:o,onValueChange:E=>l(E),children:[e.jsx(le,{className:"w-32",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"all",children:"All statuses"}),e.jsx(P,{value:"delivered",children:"Delivered"}),e.jsx(P,{value:"failed",children:"Error"}),e.jsx(P,{value:"pending",children:"Pending"})]})]}),e.jsxs(b,{variant:C?"secondary":"ghost",size:"sm",className:"relative",onClick:()=>{x({open:!C,afterAutoShow:a??!1})},"aria-pressed":C,"aria-label":"Show messages that never arrived",children:[e.jsx(Me,{className:"mr-1 size-3.5"}),"Never arrived",f.length>0&&!C&&j&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full bg-red-500"})]}),e.jsx(J,{className:"h-9 w-44",placeholder:"Filter by agent or message…",value:c,onChange:E=>d(E.target.value),"aria-label":"Search chats"}),O&&e.jsx(b,{variant:"ghost",size:"sm",onClick:T,children:"Clear filters"}),e.jsx("div",{className:"ml-auto",children:e.jsx(po,{})})]}),C&&e.jsx("div",{ref:t,children:e.jsx(fd,{enabled:s})}),A.length===0&&!O?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[e.jsx("div",{className:"pointer-events-none mb-2 w-full max-w-sm opacity-20 select-none",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-44 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-24 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})})]})}),e.jsx(Mr,{className:"text-muted-foreground/50 size-10"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No activity yet"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages between your agents show up here."})]})]}):A.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[e.jsx(zr,{className:"text-muted-foreground/50 size-10"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No messages match your filters"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try different filters."})]}),e.jsx(b,{variant:"ghost",size:"sm",onClick:T,children:"Clear filters"})]}):e.jsx("div",{className:"space-y-2",children:e.jsx(Le,{mode:"popLayout",children:A.map(E=>{const k=y.current!==null&&!y.current.has(E.id)?bd:vd;return e.jsx(Te.div,{...k,children:e.jsx(md,{conversation:E})},E.id)})})})]})]})}const sn={healthy:Oe.success,degraded:Oe.warning,critical:Oe.error};function wd(s){return s==null?"—":s<1?"<1ms":`${Math.round(s)}ms`}function Cd(s,t,n){const a=s.totalMessages>0?s.failedCount/s.totalMessages:0;if(n===0)return{state:"healthy",message:"No connections yet"};if(a>.5||t===0){const r=Math.round(a*100);return{state:"critical",message:`${s.failedCount} messages had errors today (${r}%)`}}if(t<n||a>=.05){const r=n-t;return r>0?{state:"degraded",message:`${r} connection${r>1?"s":""} disconnected`}:{state:"degraded",message:`${s.failedCount} error${s.failedCount!==1?"s":""} in the last day`}}return{state:"healthy",message:`${t} connection${t>1?"s":""} active`}}function Sd(s){const{data:t=[],isLoading:n}=Bn(s),a=t.flatMap(o=>o.instances),r=a.length,i=a.filter(o=>o.status.state==="connected").length;return{total:r,connected:i,isLoading:n}}function Ad({enabled:s=!0,onFailedClick:t}){const n=ft(),{data:a,isLoading:r}=Nt(),{total:i,connected:o,isLoading:l}=Sd(s&&n);if(!n||!s||r||l||!a)return null;const{state:c,message:d}=Cd(a,o,i),u=(c==="degraded"||c==="critical")&&t!=null,x=wd(a.avgDeliveryLatencyMs),h=`${a.totalMessages} messages today · ${a.failedCount} errors · ${x} average delivery`;return e.jsx(Ur,{children:e.jsx("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs",children:c==="healthy"?e.jsxs(Kr,{children:[e.jsx(Br,{asChild:!0,children:e.jsxs("span",{className:"flex min-w-0 flex-1 cursor-default items-center gap-1.5",children:[e.jsx("span",{className:`size-2 shrink-0 rounded-full ${sn[c]}`,"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:d}),a.avgDeliveryLatencyMs!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:x})]})]})}),e.jsx(Wr,{side:"bottom",children:h})]}):e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:`size-2 shrink-0 rounded-full ${sn[c]}`,"aria-hidden":"true"}),u?e.jsx("button",{type:"button",onClick:t,className:"truncate text-left hover:underline","aria-label":`${d}. Show messages with problems`,children:d}):e.jsx("span",{className:"truncate",children:d})]})})})}function Td(){const{data:s}=Wn();return s!=null&&s.newAgentRecordUnreadable?e.jsxs("div",{"data-testid":"permissions-record-unreadable",className:"text-muted-foreground rounded-md border px-3 py-2 text-sm",children:[e.jsx("p",{role:"status",children:"Some agents may do less than their own settings allow."}),e.jsxs(Cs,{className:"mt-1",children:[e.jsx("p",{children:"DorkOS couldn’t read its list of checked agents."}),e.jsx("p",{children:"Each agent gets the stricter of its own and everyone’s settings."}),e.jsx("p",{children:"It tries again when you add or remove an agent."})]})]}):null}function tn(s){const t=s instanceof Error?s.message:"";return t&&!/^HTTP \d+$/.test(t)?t:"Couldn’t change that. Try again."}function Od(s){var p,f;const t=U(),n=V(),[a,r]=m.useState(null),[i,o]=m.useState(null),l=Y({queryKey:_t,queryFn:()=>t.listSessionRelayPasskeys(),enabled:s,retry:!1,refetchOnWindowFocus:!0}),c=((p=l.data)==null?void 0:p.keys)??[],d=ge({mutationFn:async g=>{try{const y=await g.send();if(!g.pending.go(y.approveUrl))throw new Error("Couldn’t open your browser. Try again.")}catch(y){throw g.pending.close(),y}},onMutate:()=>r(null),onSuccess:()=>o(c.length),gcTime:0,onError:g=>r(tn(g))}),u=ge({mutationFn:g=>g(),onMutate:()=>r(null),onSuccess:g=>n.setQueryData(_t,g),gcTime:0,onError:g=>r(tn(g))}),x={onSettled:()=>d.reset()},h={onSettled:()=>u.reset()};return{keys:c,damaged:((f=l.data)==null?void 0:f.damaged)===!0,busy:d.isPending||u.isPending,waiting:i!==null&&c.length<=i,error:a,add:(g,y)=>{const N=qr();if(!N){r("Allow pop-ups for this page, then try again.");return}d.mutate({send:()=>t.startSessionRelayPasskey({label:g,password:y}),pending:N},x)},remove:(g,y)=>u.mutate(()=>t.removeSessionRelayPasskey(g,y),h),removeDamaged:g=>u.mutate(()=>t.removeDamagedSessionRelayPasskeys(g),h)}}function oa({prompt:s,onClose:t}){const n=m.useId(),[a,r]=m.useState(""),i=()=>{r(""),t()};return e.jsx(me,{open:s!==null,onOpenChange:o=>!o&&i(),children:e.jsx(xe,{children:e.jsxs("form",{className:"space-y-4",onSubmit:o=>{o.preventDefault(),s==null||s.run(a),i()},children:[e.jsxs(te,{children:[e.jsx(ne,{children:s==null?void 0:s.title}),e.jsx(ae,{children:"Enter your password for this computer."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:n,children:"Password"}),e.jsx(ht,{id:n,value:a,onChange:o=>r(o.target.value),autoComplete:"current-password"})]}),e.jsxs(re,{children:[e.jsx(ie,{type:"button",children:"Cancel"}),e.jsx(b,{type:"submit",disabled:!a,children:s==null?void 0:s.confirm})]})]})})})}function Ed({open:s,onClose:t,passkeys:n}){const a=m.useId(),r=m.useId(),[i,o]=m.useState(""),[l,c]=m.useState(""),d=()=>{o(""),c(""),t()};return e.jsx(me,{open:s,onOpenChange:u=>!u&&d(),children:e.jsx(xe,{children:e.jsxs("form",{className:"space-y-4",onSubmit:u=>{u.preventDefault(),n.add(i.trim(),l),d()},children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Add a passkey"}),e.jsx(ae,{children:"Your browser opens to create it. Then come back here."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:a,children:"Name"}),e.jsx(J,{id:a,value:i,onChange:u=>o(u.target.value),placeholder:"MacBook passkey",maxLength:64,autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:r,children:"Your password for this computer"}),e.jsx(ht,{id:r,value:l,onChange:u=>c(u.target.value),autoComplete:"current-password"})]}),e.jsxs(re,{children:[e.jsx(ie,{type:"button",children:"Cancel"}),e.jsx(b,{type:"submit",disabled:!i.trim()||!l,children:"Continue"})]})]})})})}function Rd(){const s=Od(!0),[t,n]=m.useState(!1),[a,r]=m.useState(null);return e.jsxs("div",{className:"space-y-2",children:[e.jsx(oa,{prompt:a,onClose:()=>r(null)}),e.jsx(Ed,{open:t,onClose:()=>n(!1),passkeys:s}),s.damaged?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-destructive text-xs",children:"Passkey file is damaged. Remove it to start again."}),e.jsx(b,{variant:"outline",size:"sm",disabled:s.busy,onClick:()=>r({title:"Remove the damaged passkey file?",confirm:"Remove",run:s.removeDamaged}),children:"Remove"})]}):s.keys.length===0?e.jsx("p",{className:"text-muted-foreground text-xs",children:"No passkeys yet."}):e.jsx("ul",{className:"space-y-1","data-testid":"approval-passkeys",children:s.keys.map(i=>e.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsxs("span",{className:"min-w-0 truncate",children:[i.label,e.jsxs("span",{className:"text-muted-foreground ml-2 font-mono text-xs",children:["…",i.credentialId.slice(-6)]})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:["Added ",we(i.addedAt)]}),e.jsx(b,{variant:"ghost",size:"sm",disabled:s.busy,"aria-label":`Remove ${i.label}`,onClick:()=>r({title:"Remove this passkey?",confirm:"Remove",run:o=>s.remove(i.credentialId,o)}),children:"Remove"})]})]},i.credentialId))}),e.jsx(b,{variant:"outline",size:"sm",disabled:s.busy||s.damaged,onClick:()=>n(!0),children:"Add a passkey"}),s.waiting&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Finish in your browser. This list updates when you return."}),s.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:s.error})]})}function Dd({atThisComputer:s}){const t=Hr();return e.jsxs("div",{className:"space-y-1.5","data-testid":"approval-passkeys-section",children:[e.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Approvals from the web"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Approve tool calls from your hub with a passkey made for this computer."}),t||!s?e.jsx("p",{className:"text-muted-foreground text-xs",children:"Manage passkeys at this computer."}):e.jsx(Rd,{})]})}function Id(s){if(!s)return"";try{return new URL(s).host}catch{return s}}function Pd({access:s,status:t}){const n=m.useId(),a=m.useId(),r=m.useId(),[i,o]=m.useState(""),[l,c]=m.useState(t.suggestedName),[d,u]=m.useState(""),x=!s.canChange||s.busy;return e.jsxs("form",{className:"space-y-3",onSubmit:h=>{h.preventDefault(),s.link({linkCode:i.trim(),computerName:l.trim(),password:d}),u("")},children:[e.jsx("p",{className:"text-sm",children:"Your DorkOS account, or DorkOS itself, can run commands here through your agents."}),e.jsxs(Ye,{children:[e.jsxs(Ve,{className:"text-muted-foreground hover:text-foreground group flex items-center gap-1 text-xs",children:[e.jsx(Be,{className:"size-3 transition-transform group-data-[state=open]:rotate-90"}),"Learn more"]}),e.jsx(Qe,{children:e.jsx("p",{className:"text-muted-foreground pt-1 text-xs",children:"Chats pass through the hub that made this code. Turn this off here anytime."})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:n,children:"Link code"}),e.jsx(J,{id:n,value:i,onChange:h=>o(h.target.value),placeholder:"XXXX-XXXX-XXXX-XXXX@your-hub",autoComplete:"off",spellCheck:!1,disabled:x})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:a,children:"Name for this computer"}),e.jsx(J,{id:a,value:l,onChange:h=>c(h.target.value),maxLength:64,disabled:x})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:r,children:"Your password for this computer"}),e.jsx(ht,{id:r,value:d,onChange:h=>u(h.target.value),autoComplete:"current-password",disabled:x})]}),e.jsx(b,{type:"submit",size:"sm",disabled:x||!i.trim()||!l.trim()||!d,children:"Link"})]})}function nn({value:s,title:t,description:n,disabled:a,comingSoon:r}){const i=m.useId();return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(qs,{value:s,id:i,disabled:a,className:"mt-0.5"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(X,{htmlFor:i,className:L("text-sm",a&&"opacity-60"),children:[t,r&&e.jsx(se,{variant:"secondary",className:"ml-2",children:"Coming soon"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:n})]})]})}function Ld(s){return s.paused?"Paused":s.connected?"Connected":"Not connected"}function $d({access:s,status:t}){const n=!s.canChange||s.busy,[a,r]=m.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(oa,{prompt:a,onClose:()=>r(null)}),e.jsxs("div",{children:[e.jsx("p",{className:"truncate text-sm",children:Id(t.hubOrigin)}),e.jsx("p",{className:"text-muted-foreground text-xs",children:Ld(t)})]}),e.jsxs(An,{value:t.level,onValueChange:i=>i==="full"?r({title:"Allow Full control from the web?",confirm:"Allow",run:o=>s.setLevel("full",o)}):s.setLevel(i),"aria-label":"What the web can do here",disabled:n,children:[e.jsx(nn,{value:"chat",title:"Chat",description:"Read and send messages. Questions and approvals wait for you here.",disabled:n}),e.jsx(nn,{value:"full",title:"Full control",description:"Also open the terminal, files and settings from the web.",disabled:!0,comingSoon:!0})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{variant:"outline",size:"sm",disabled:n,onClick:()=>t.paused?r({title:"Resume chat from the web?",confirm:"Resume",run:s.resume}):s.pause(),children:t.paused?"Resume":"Pause"}),e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"outline",size:"sm",disabled:n,children:"Unlink"})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Unlink from your hub?"}),e.jsx(ae,{children:"Chatting from the web stops now. You can link again anytime."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:s.unlink,children:"Unlink"})]})]})]})]})]})}function _d({className:s}){const t=qi(),n=t.status,a=Hi((n==null?void 0:n.linked)===!0);return!t.available||!n?null:e.jsxs("section",{"aria-labelledby":"web-access-title",className:L("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsx("p",{id:"web-access-title",className:"text-sm font-medium",children:"Chat from the web"}),!t.canChange&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Change this on the computer DorkOS runs on."}),n.linked?e.jsxs(e.Fragment,{children:[e.jsx($d,{access:t,status:n}),e.jsx(Yi,{devices:a}),e.jsx(Dd,{atThisComputer:t.atThisComputer})]}):e.jsx(Pd,{access:t,status:n}),t.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.error})]})}const la="/sw.js",Fs=["push","subscriptions"],Fd=["push","vapid-public-key"],St="dorkos.push.device-id";function Md(){var j,C;const s=U(),t=V(),[n,a]=m.useState(null),[r,i]=m.useState(an),o=zd(),l=Y({queryKey:[...Fd],queryFn:()=>s.getPushVapidPublicKey(),enabled:o==="available",staleTime:1/0}),c=Y({queryKey:[...Fs],queryFn:()=>s.listPushSubscriptions()}),d=ge({mutationFn:async O=>{const A=await Ud(O);return s.registerPushSubscription(A)},onSuccess:O=>{qd(O.subscription.id),i(O.subscription.id),t.invalidateQueries({queryKey:[...Fs]})},meta:{suppressErrorToast:!0}}),u=ge({mutationFn:O=>s.deletePushSubscription(O),onSuccess:(O,A)=>{an()===A&&(rn(),i(null),Kd()),t.invalidateQueries({queryKey:[...Fs]})},meta:{suppressErrorToast:!0}}),x=(j=c.data)==null?void 0:j.subscriptions,h=x!==void 0&&r!==null&&!x.some(O=>O.id===r),p=h?null:r;m.useEffect(()=>{h&&rn()},[h]);const f=((C=l.data)==null?void 0:C.key)??null,g=m.useCallback(async()=>{if(a(null),f===null){a("Couldn’t set up notifications on this computer. Try again later.");return}try{await d.mutateAsync(f)}catch(O){a(Bd(O))}},[d,f]),y=m.useCallback(async O=>{a(null);try{await u.mutateAsync(O)}catch{a("Couldn’t remove that device. Try again.")}},[u]);return{availability:o!=="available"?o:l.isSuccess&&f===null?"server-unavailable":"available",devices:x??[],devicesLoaded:c.isSuccess,localDeviceId:p,subscribe:g,remove:y,isPending:d.isPending||u.isPending,error:n}}function zd(){return dt()?"desktop-shell":typeof window>"u"||typeof navigator>"u"||!("serviceWorker"in navigator)||!("PushManager"in window)?"unsupported":window.isSecureContext===!1?"insecure-context":"available"}async function Ud(s){var c,d;const t=await navigator.serviceWorker.register(la,{scope:"/"});await navigator.serviceWorker.ready;const n=await Notification.requestPermission();if(n!=="granted")throw new ca(n);const i=(await t.pushManager.getSubscription()??await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Wd(s)})).toJSON(),o=(c=i.keys)==null?void 0:c.p256dh,l=(d=i.keys)==null?void 0:d.auth;if(typeof i.endpoint!="string"||!o||!l)throw new Error("This browser produced a subscription DorkOS cannot use.");return{endpoint:i.endpoint,keys:{p256dh:o,auth:l}}}async function Kd(){try{const s=await navigator.serviceWorker.getRegistration(la),t=await(s==null?void 0:s.pushManager.getSubscription());await(t==null?void 0:t.unsubscribe())}catch{}}class ca extends Error{constructor(t){super(`Notification permission was ${t}`),this.permission=t,this.name="PushPermissionError"}}function Bd(s){return s instanceof ca?s.permission==="denied"?"Your browser blocks notifications from DorkOS. Allow them in this site’s settings.":"Allow notifications so DorkOS can reach this device.":"Couldn’t set up this device for notifications. Try again."}function Wd(s){const t=s.padEnd(s.length+(4-s.length%4)%4,"="),n=atob(t.replace(/-/g,"+").replace(/_/g,"/")),a=new Uint8Array(new ArrayBuffer(n.length));for(let r=0;r<n.length;r+=1)a[r]=n.charCodeAt(r);return a}function an(){try{return window.localStorage.getItem(St)}catch{return null}}function qd(s){try{window.localStorage.setItem(St,s)}catch{}}function rn(){try{window.localStorage.removeItem(St)}catch{}}const Hd=[{value:1,label:"1 min"},{value:2,label:"2 min"},{value:5,label:"5 min"},{value:15,label:"15 min"},{value:"never",label:"Never"}];function Yd(s){return s==="never"?"never":Number(s)}function Vd(){const{prefs:s,setPrefs:t,isPending:n}=$n(),a=Md(),r=_n(),i=(r.data??[]).some(c=>c.enabled&&c.canInitiate),o=s.escalation.phoneAfterMinutes==="never",l=a.devicesLoaded&&r.isSuccess;return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{orientation:"vertical",label:"Reach you elsewhere after",description:"DorkOS pings your devices and chat apps. Answering one quiets the rest.",children:e.jsx(ks,{value:String(s.escalation.phoneAfterMinutes),onValueChange:c=>t({escalation:{phoneAfterMinutes:Yd(c)}}),disabled:n,"aria-label":"Wait before reaching you elsewhere",children:Hd.map(c=>e.jsx(_e,{value:String(c.value),children:c.label},String(c.value)))})}),l&&!o&&a.devices.length===0&&!i&&e.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:"Nothing can reach you yet. Add this device, or a chat app in Connections."}),e.jsx($,{orientation:"vertical",label:"Devices DorkOS can reach",description:Qd(a.availability),children:e.jsxs("div",{className:"w-full space-y-3",children:[a.devices.length>0&&e.jsx("ul",{className:"divide-border divide-y","aria-label":"Subscribed devices",children:a.devices.map(c=>e.jsxs("li",{className:"flex items-center justify-between gap-4 py-2 first:pt-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm",children:Gd(c,a.localDeviceId)}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Added ",we(c.createdAt)]})]}),e.jsx(b,{variant:"ghost",size:"sm",disabled:a.isPending,onClick:()=>void a.remove(c.id),children:"Remove"})]},c.id))}),a.availability==="available"&&a.localDeviceId===null&&e.jsx(b,{variant:"outline",size:"sm",disabled:a.isPending,onClick:()=>void a.subscribe(),children:"Add this device"}),a.error!==null&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:a.error})]})})]})})}function Qd(s){switch(s){case"available":return"Added browsers get notified even when DorkOS is closed. Add your phone’s browser.";case"desktop-shell":return"The desktop app shows its own notifications. Add your phone’s browser instead.";case"unsupported":return"This browser can’t get notifications while DorkOS is closed. Other devices still work.";case"insecure-context":return"This needs a secure connection. Open DorkOS at localhost or over HTTPS.";case"server-unavailable":return"DorkOS couldn’t set up notifications on this computer. No device can be added now."}}function Gd(s,t){return s.id===t?"This device":s.service==="unknown"?"Another device":`Another device (${s.service})`}function Xd(){return e.jsx(Oi,{})}function Jd({onClick:s}){return e.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"})}function Zd(){const{setTheme:s}=pt(),t=Ee(n=>n.resetAppearance);return e.jsx(Jd,{onClick:()=>{t(),s("system")}})}function eu(){const{theme:s,setTheme:t}=pt(),{fontFamily:n,setFontFamily:a,fontSize:r,setFontSize:i}=Ee();return e.jsx("div",{className:"space-y-4",children:e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Theme",children:e.jsxs(oe,{value:s,onValueChange:t,children:[e.jsx(le,{className:"w-32",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"dark",children:"Dark"}),e.jsx(P,{value:"system",children:"System"})]})]})}),e.jsx($,{label:"Font family",children:e.jsxs(oe,{value:n,onValueChange:o=>a(o),children:[e.jsx(le,{className:"w-40",children:e.jsx(ce,{})}),e.jsx(de,{children:Yr.map(o=>e.jsx(P,{value:o.key,children:e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:o.displayName}),e.jsx("span",{className:"text-muted-foreground truncate text-xs",children:o.description})]})},o.key))})]})}),e.jsx($,{label:"Font size",children:e.jsxs(oe,{value:r,onValueChange:o=>i(o),children:[e.jsx(le,{className:"w-32",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"small",children:"Small"}),e.jsx(P,{value:"medium",children:"Medium"}),e.jsx(P,{value:"large",children:"Large"})]})]})})]})})})}function su(){const{prefs:s,setPrefs:t,isPending:n}=$n(),{permission:a,request:r}=Di(),i=dt(),[o,l]=m.useState(!1);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Knock when an agent needs you",description:"Plays when something waits on you.",checked:s.sounds.knock,onCheckedChange:c=>t({sounds:{knock:c}}),disabled:n}),e.jsx(_,{label:"Chime when everything is answered",description:"Plays when nothing is waiting.",checked:s.sounds.allClear,onCheckedChange:c=>t({sounds:{allClear:c}}),disabled:n}),e.jsx(_,{label:"Chime every time a turn finishes",description:"Every reply. Noisy with many agents.",checked:s.sounds.turnEnd,onCheckedChange:c=>t({sounds:{turnEnd:c}}),disabled:n})]})}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Notifications from your browser",description:tu(a,i),children:!i&&a==="default"&&e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void r(),children:"Turn on"})}),e.jsx(_,{label:"Notify when work finishes while you’re away",description:"Anything waiting on you always gets through.",checked:s.notifyOnTurnCompleteWhileAway,onCheckedChange:c=>t({notifyOnTurnCompleteWhileAway:c}),disabled:n})]})}),e.jsx(Vd,{}),e.jsx(ws,{open:o,onOpenChange:l,trigger:"Get these on your phone",children:e.jsxs("ol",{className:"text-muted-foreground list-decimal space-y-1.5 pl-4 text-xs",children:[e.jsx("li",{children:"Open DorkOS on your phone, at your Remote access address."}),e.jsx("li",{children:"Choose “Add to Home Screen”. iPhone needs this for notifications."}),e.jsx("li",{children:"Open Settings there and add it as a device above."})]})})]})}function tu(s,t){return t?"The desktop app shows its own notifications.":s==="granted"?"Allowed, even while this tab is hidden.":s==="denied"?"Blocked. Change it in your browser’s settings for this site.":s==="unsupported"?"This browser cannot show notifications.":"Not turned on yet."}const nu=[{key:"maxAgentDepth",label:"Replies in a row",description:`Agents pause after this many replies in a row. Default: ${rs.maxAgentDepth}.`,details:["Your next message starts the count over.","Set it to 0 to stop automatic replies."],min:De.maxAgentDepth.min,max:De.maxAgentDepth.max},{key:"maxTurnsPerAgentPerCascade",label:"Replies from one agent",description:`Most turns one agent takes in one back-and-forth. Default: ${rs.maxTurnsPerAgentPerCascade}.`,details:["Progress notes an agent posts while it works don’t count extra."],min:De.maxTurnsPerAgentPerCascade.min,max:De.maxTurnsPerAgentPerCascade.max},{key:"maxAutomaticTurnsPerRoomPerHour",label:"Replies in one room each hour",description:`Most automatic replies one room runs in an hour. Default: ${rs.maxAutomaticTurnsPerRoomPerHour}.`,details:["It keeps one busy room from using up the whole allowance below."],min:De.maxAutoTurnsPerHour.min,max:De.maxAutoTurnsPerHour.max},{key:"maxAutomaticTurnsTotalPerHour",label:"Replies everywhere each hour",description:`Most automatic replies across all rooms in an hour. Default: ${rs.maxAutomaticTurnsTotalPerHour}.`,details:["This caps what automatic replies can cost you.","No room can set its own."],min:Pt.min,max:Pt.max}],on="Chats at once";function au(){const{limits:s,unsupported:t,loadError:n,maxConcurrentTurnsPerAgent:a,setLimits:r}=Vr();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"How far agents reply to each other, and how many chats each runs."}),e.jsxs(Cs,{className:"text-xs",children:[e.jsx("p",{children:"Every message you send starts the reply counts over."}),e.jsx("p",{children:"A room can have limits of its own, in the panel beside it."})]})]}),s===null?e.jsx(R,{children:e.jsx(D,{children:n!==null?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t load these settings. Close Settings and open it again."}):t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This version of DorkOS doesn’t have these settings. Update to change them."}):[0,1,2,3,4].map(i=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx(ee,{className:"h-4 w-40"}),e.jsx(ee,{className:"h-3 w-full max-w-xs"})]}),e.jsx(ee,{className:"h-9 w-24"})]},i))})}):e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Limit automatic replies",description:s.turnLimitsEnabled?"Agents pause when they reach a limit below.":"Agents reply to each other without limit until you press Stop.",checked:s.turnLimitsEnabled,onCheckedChange:i=>r({turnLimitsEnabled:i})}),nu.map(i=>e.jsx($,{orientation:"vertical",label:i.label,description:e.jsxs(e.Fragment,{children:[i.description," ",e.jsx(qe,{label:`About ${i.label.toLowerCase()}`,children:i.details.map(o=>e.jsx("p",{children:o},o))})]}),children:e.jsx(xs,{"aria-label":i.label,value:s[i.key],min:i.min,max:i.max,disabled:!s.turnLimitsEnabled,onCommit:o=>r({[i.key]:o})})},i.key))]})}),s!==null&&a!==null&&e.jsx(R,{children:e.jsx(D,{children:e.jsx($,{orientation:"vertical",label:on,description:e.jsxs(e.Fragment,{children:[`How many chats one agent works in at once. Default: ${Qr}.`," ",e.jsx(qe,{label:"About chats at once",children:e.jsx("p",{children:"Higher is faster, but turns that change the same files can collide."})})]}),children:e.jsx(xs,{"aria-label":on,value:a,min:Lt.min,max:Lt.max,onCommit:i=>r({maxConcurrentTurnsPerAgent:i})})})})})]})}function ru(){const s=fe(),t=Gr(),n=Xr(),a=ft();zn(s.section);const r=()=>{s.close(),n()};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Access and chat app settings. Your apps are on the"," ",e.jsx(b,{variant:"link",className:"h-auto p-0 text-xs",onClick:r,children:"Connections page"}),"."]}),e.jsxs("section",{"data-section":"ways","aria-labelledby":"settings-connection-ways",className:"space-y-3",children:[e.jsx("h3",{id:"settings-connection-ways",className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"How DorkOS reaches your apps"}),e.jsx(vl,{onManageAccount:()=>{t.onValueChange("account")},onOpenConnectionsPage:r})]}),e.jsxs("section",{"data-section":"chat-apps","aria-labelledby":"settings-chat-apps",className:"space-y-3",children:[e.jsx("h3",{id:"settings-chat-apps",className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Chat apps"}),e.jsx(Al,{}),a&&e.jsxs(Ye,{children:[e.jsx(Ve,{className:"text-muted-foreground hover:text-foreground focus-ring rounded-md text-sm font-medium",children:"Message history"}),e.jsxs(Qe,{className:"space-y-3 pt-3",children:[e.jsx(Ad,{enabled:!0}),e.jsx(kd,{enabled:!0})]})]})]})]})}function iu(){const{data:s}=Wn(),t=ia();return s?e.jsxs(e.Fragment,{children:[e.jsx(yo,{files:s.filesAndCommands,preset:s.preset,onChange:n=>t.changeTrustStop(null,n),disabled:t.isPending,runtimeLabel:n=>je(n).label}),t.writeError?e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.writeError}):null]}):null}function ou(){const s=In(),{close:t}=fe();return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Td,{}),e.jsx(R,{children:e.jsx(D,{className:"@container space-y-2",children:e.jsx(Vi,{surface:"settings"})})}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"What agents may do"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Allowed runs without asking. Ask waits for your yes. Blocked is refused."," ",go]}),e.jsx(R,{children:e.jsxs(D,{className:"divide-border divide-y",children:[e.jsx(iu,{}),e.jsx(fo,{scope:{kind:"default"}})]})})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"History"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx(jo,{})})})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Connected accounts have their own permissions, in"," ",e.jsx(b,{variant:"link",size:"sm",className:"h-auto p-0 text-sm",onClick:()=>{t(),s({...Pn.connections()})},children:"Connections"}),"."]})]})}function da(s,t){return(s==null?void 0:s.enabled)===!0&&s.runtimes[t]==="wired"}function lu(s,t){var n,a;return((a=(n=s==null?void 0:s.defaults)==null?void 0:n[t])==null?void 0:a.runsOn)==="credits"||da(s,t)}function cu(s,t,n){const a=t==="runtime"?`A change moves every ${s} chat, so it can't be made while ${s} is in the middle of a reply.`:`A change applies to new ${s} chats. One already going stays on what it started on.`;return n?`DorkOS chose credits when you linked, because ${s} had no sign-in. ${a}`:a}function du({type:s,runsOn:t,chosenByDorkos:n,scope:a,caveat:r,canChooseCredits:i,pending:o,failure:l,onChange:c}){const d=xt(s);return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"credits-runs-on-section",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Runs on"}),e.jsxs(ks,{"aria-label":`What ${d} runs on`,className:"w-full",value:t,disabled:o,onValueChange:u=>c(u),children:[e.jsx(_e,{value:"own-sign-in",children:e.jsxs("span",{className:"truncate",children:["Your ",d," sign-in"]})}),e.jsx(_e,{value:"credits",disabled:!i&&t!=="credits",children:e.jsx("span",{className:"truncate",children:On})})]}),e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"credits-runs-on-note",children:t==="credits"&&!i?`${d} can’t run on credits now, so new work stops. Switch to your own sign-in.`:cu(d,a,n)}),r?e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"credits-runs-on-caveat",children:r}):null,l!==null&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:l})]})}function uu({type:s}){var l,c;const{data:t}=ys(),n=bs(),a=(l=Jr(s))==null?void 0:l.credits,r=a==null?void 0:a.scope;if(!lu(t,s))return null;const i=(c=t==null?void 0:t.defaults)==null?void 0:c[s],o=(i==null?void 0:i.runsOn)==="credits"?"credits":"own-sign-in";return e.jsx(du,{type:s,runsOn:o,chosenByDorkos:o==="credits"&&(i==null?void 0:i.chosenBy)==="default",scope:r,...a!=null&&a.caveat?{caveat:a.caveat}:{},canChooseCredits:da(t,s),pending:n.isPending,failure:n.isError?`Couldn’t change that. ${vn(n.error)??"Try again in a moment."}`:null,onChange:d=>{d!==o&&n.mutate({runtime:s,useCredits:d==="credits"})}})}function mu({type:s}){const{byId:t,byPath:n}=ut(s),a=t.get(ke)??n.values().next().value;return ta(a)?e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","aria-label":`${je(s).label} usage`,children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Usage"}),e.jsx(aa,{usage:a})]}):null}const Ms={"claude-accounts":()=>e.jsx(Yc,{}),"credits-runs-on":({type:s})=>e.jsx(uu,{type:s}),"opencode-power-source":({type:s})=>e.jsx(Xc,{type:s}),"runtime-usage":({type:s})=>e.jsx(mu,{type:s})};function xu(s,t){var n;return((n=Ms[s])==null?void 0:n.call(Ms,t))??null}function hu(s){const t=U(),{data:n}=Y({queryKey:["doe-inference"],queryFn:()=>t.getDoeInference(),enabled:s}),a=(n==null?void 0:n.autoProtocol)??null,r=!s||n===void 0?null:n.inference!==null?"own":a!==null?"credits":"none",{data:i}=Y({queryKey:["doe-credits-models",a],queryFn:()=>t.getDoeCreditsModels(a??"anthropic-messages"),enabled:r==="credits"});return{state:r,models:i==null?void 0:i.models.map(o=>({value:o.id,displayName:o.displayName,description:"",contextWindow:o.contextWindow,maxOutputTokens:o.maxOutputTokens,paidFromCredits:!0}))}}const pu="a model chosen by DorkOS";function gu(s){switch(s){case"credits":return{inheritLabel:To,description:"Which model new chats start on."};case"own":return{description:"Change it in the DorkOS setup."};case"none":return{inheritLabel:"None yet",description:"Connect AI to choose a model."};case null:return{}}}const fu={login:{id:"reconnect",cancelLabel:"Keep current sign-in"},"provider-picker":{id:"change",cancelLabel:"Keep current source"}};function ju(s,t){return ai(s)==="provider-picker"?t?{kind:"provider-picker",connect:{kind:"provider-picker",label:"Change power source"},currentProvider:t}:null:ri.includes(s)?{kind:"login",connect:{kind:"login",label:`Reconnect ${xt(s)}`}}:null}function yu(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function bu({type:s,isDefault:t,trustStop:n,globalStop:a,onChangeTrustStop:r,onMakeDefault:i}){var Tt,Ot,Et,Rt,Dt;const{data:o}=Se(),{nameFor:l,resolvedAccount:c,inherited:d}=vs();ut(Zr.includes(s)?s:null,{fetch:!0});const{data:u}=Ge(),{data:x}=mt(),{registered:h}=ei(s),p=ye(),f=V(),g=U(),[y,N]=m.useState(!1),[j,C]=m.useState(!1),[O,A]=m.useState(null),[T,E]=m.useState(!1),v=si(x,s,h),k=v.state==="ready",Z=No(),H=hu(s==="doe"&&Z),F=H.state==="credits"&&k,M=je(s),W=qn(u,s),S=(Tt=o==null?void 0:o.executionDefaults)==null?void 0:Tt.perRuntime.find(z=>z.runtime===s),K=(S==null?void 0:S.model)??null,I=x==null?void 0:x.runtimes[s],be=ti(x,s),{data:Re}=Y({...ni(g,{runtime:s}),enabled:k&&(y||K!==null)});function Je(z){A(null),p.mutate({runtimes:z},{onSuccess:()=>{f.invalidateQueries({queryKey:G.all}),E(!0)},onError:ns=>A(yu(ns))})}const Ze=W?W.configSection!==null:!0,he=W===void 0;function es(z){const ns=W==null?void 0:W.configSection;ns&&Je({[ns]:z})}const Ss=n??a,As={"claude-accounts":!(o==null?void 0:o.claudeCode)||d||!c?null:l(c),"opencode-power-source":I!=null&&I.provider?Hn(I.provider):null},Ue=K?(Re??[]).find(z=>z.value===K):void 0,ss=Dc({ready:k,settings:W,model:K,models:F?H.models:Re,...F?{inheritModelLabel:pu}:{},effort:S==null?void 0:S.effort,modelTakesEffort:Ue?Ue.supportsEffort??!1:void 0,trustStop:Ss,trustInherited:n===null,sectionValues:As}),ve=I==null?void 0:I.dependencies.find(z=>z.status!=="satisfied"&&z.installHint),w=(ve==null?void 0:ve.installHint)??((Ot=M.setup)==null?void 0:Ot.installCommand),B=(ve==null?void 0:ve.infoUrl)??((Et=M.setup)==null?void 0:Et.infoUrl),Q=!k&&v.connect?e.jsx("div",{"data-testid":`runtime-card-connect-${s}`,children:v.connect.kind==="install"?e.jsx(vu,{type:s,label:v.connect.label,installCommand:w,installInfoUrl:B}):Ys({type:s,connect:v.connect})}):null,q=k?ju(s,I==null?void 0:I.provider):null;!q&&j&&C(!1);const ts=q?fu[q.kind]:null,ua=q&&ts&&j?e.jsxs("div",{className:"space-y-2","data-testid":`runtime-${ts.id}-panel-${s}`,children:[Ys({type:s,connect:q.connect,...q.currentProvider?{currentProvider:q.currentProvider}:{},onConnected:()=>C(!1)}),e.jsx("button",{type:"button",onClick:()=>C(!1),className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs transition-colors","data-testid":`runtime-${ts.id}-cancel-${s}`,children:ts.cancelLabel})]}):null,ma=I?I.dependencies.map(z=>e.jsx(Nu,{dep:z},z.name)):M.setup?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Not set up here. Install it, then turn on ",e.jsxs(vo,{children:["runtimes.",s]})," in your DorkOS config."]}),e.jsx(yt,{command:M.setup.installCommand,infoUrl:M.setup.infoUrl,copyLabel:`Copy install command for ${M.label}`})]}):void 0,Ae=I==null?void 0:I.dependencies.filter(z=>z.status!=="satisfied"),xa=I?e.jsx(se,{variant:"secondary",className:L("text-xs",Ae!=null&&Ae.length?"text-status-warning-fg":""),children:Ae!=null&&Ae.length?`${Ae.length} missing`:`${I.dependencies.length} ${I.dependencies.length===1?"check":"checks"}`}):void 0;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Tc,{type:s,...M.subtitle?{subtitle:M.subtitle}:{},ready:k,isDefault:t,onMakeDefault:i,expanded:y,onToggleExpanded:()=>N(z=>!z),summary:ss,...be?{expiringSignIn:be}:{},connectSlot:Q,...q&&!j?{reconnect:{kind:q.kind,onOpen:()=>C(!0)}}:{},reconnectPanel:ua,model:{models:F?H.models:Re,value:K,onChange:z=>es({defaultModel:z}),disabled:he||s==="doe"&&!F,...gu(H.state==="credits"&&!k?"none":H.state)},effort:{supportsEffort:(W==null?void 0:W.supportsEffort)??!0,selectedModel:Ue,configuredModelId:K,value:(S==null?void 0:S.effort)??null,onChange:z=>es({defaultEffort:z}),disabled:he},trust:{descriptors:((Dt=(Rt=u==null?void 0:u.capabilities[s])==null?void 0:Rt.permissionModes)==null?void 0:Dt.values)??[],stop:n,globalStop:a,onChange:r,disabled:he},storesDefaults:Ze,sections:W==null?void 0:W.sections,renderSection:z=>xu(z,{type:s}),setupDetails:ma,setupBadge:xa}),T&&e.jsx("p",{className:"text-muted-foreground px-4 text-xs","data-testid":`runtime-card-timing-${s}`,children:"Applies to new chats only."}),O&&e.jsxs("p",{className:"text-destructive flex items-start gap-1.5 px-4 text-xs","data-testid":`runtime-card-error-${s}`,children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:O})]})]})}function vu({type:s,label:t,installCommand:n,installInfoUrl:a}){const r=je(s),i=Ln(),{provision:o,isPending:l,isError:c,errorMessage:d,progress:u,result:x}=ko(s);if(l||x!=null&&x.ok){const h=(u==null?void 0:u.message)??`Installing ${r.label}…`;return e.jsxs(Te.div,{className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:i?!1:{opacity:0},animate:{opacity:1},"data-testid":"provision-progress",children:[e.jsx(fs,{size:"xs",className:L("text-muted-foreground shrink-0",i&&"animate-none")}),e.jsx(Le,{mode:"wait",children:e.jsx(Te.span,{className:"truncate text-xs",initial:i?!1:{opacity:0},animate:{opacity:1},exit:i?void 0:{opacity:0},transition:{duration:.2},children:h},h)})]})}return c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:d}),n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"You can install it yourself instead:"}),e.jsx(yt,{command:n,infoUrl:a,copyLabel:`Copy install command for ${r.label}`})]}),e.jsx(b,{size:"sm",onClick:o,children:"Try again"})]}):e.jsxs("div",{children:[e.jsx(b,{size:"sm",onClick:o,children:t}),n&&e.jsx(wo,{command:n,runtimeLabel:r.label})]})}function Nu({dep:s}){const t=s.status==="satisfied";return e.jsxs("div",{className:"space-y-2","data-testid":"runtime-setup-dependency",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-x-2",children:[t?e.jsx(Ke,{className:"text-status-success size-3.5 shrink-0"}):e.jsx(ue,{className:"text-status-warning-dot size-3.5 shrink-0"}),e.jsx("span",{className:"text-sm",children:s.name}),e.jsx("p",{className:"text-muted-foreground col-start-2 mt-1 text-xs",children:t&&s.version?`v${s.version}`:s.description})]}),!t&&(s.installHint||s.infoUrl)&&e.jsx(yt,{command:s.installHint,infoUrl:s.infoUrl,copyLabel:`Copy install command for ${s.name}`})]})}function ku(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function wu(){var C,O,A;const s=mt(),{data:t}=Ge(),{data:n}=Se(),a=ye(),r=V(),i=ia(),o=Ln(),[l,c]=m.useState(null),d=bo(t?Object.keys(t.capabilities):[]),u=n==null?void 0:n.executionDefaults,x=(u==null?void 0:u.runtime)??"claude-code",h=(u==null?void 0:u.perRuntime)??[],p=(C=t==null?void 0:t.capabilities[x])==null?void 0:C.permissionModes,f=((A=(O=p==null?void 0:p.values)==null?void 0:O.find(T=>T.id===p.default))==null?void 0:A.stop)??"ask",g=(u==null?void 0:u.trustStop)??f;function y(T){c(null),a.mutate({runtimes:{default:T}},{onSuccess:()=>void r.invalidateQueries({queryKey:G.all}),onError:E=>c(ku(E))})}const N=h.map(T=>({runtime:T.runtime,label:je(T.runtime).label,stop:T.trustStop})),j=l??i.writeError;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Runtimes are the AI tools that do the work."}),e.jsx("button",{type:"button",onClick:()=>void s.refetch(),disabled:s.isFetching,"aria-label":"Check runtimes again",title:"Check again",className:"focus-ring text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1 transition-colors disabled:opacity-50","data-testid":"runtimes-recheck",children:e.jsx(at,{className:L("size-3.5",s.isFetching&&!o&&"animate-spin")})})]}),e.jsx("div",{className:"space-y-3",children:d.map(T=>{var E;return e.jsx(bu,{type:T,isDefault:T===x,trustStop:((E=h.find(v=>v.runtime===T))==null?void 0:E.trustStop)??null,globalStop:g,onChangeTrustStop:v=>i.changeTrustStop(T,v),onMakeDefault:()=>y(T)},T)})}),j&&e.jsxs("p",{className:"text-destructive flex items-start gap-1.5 text-xs","data-testid":"runtimes-tab-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:j})]}),e.jsx(Pc,{stop:(u==null?void 0:u.trustStop)??null,effectiveStop:f,runtimes:N,onChange:T=>i.changeTrustStop(null,T),onChangeRuntime:(T,E)=>i.changeTrustStop(T,E)}),e.jsx(Zc,{})]})}const Cu=["fatal","error","warn","info","debug","trace"];function Su(){const s=U(),{data:t,isLoading:n,isError:a,error:r,refetch:i,isRefetching:o}=Y({queryKey:G.current(),queryFn:()=>s.getConfig(),staleTime:3e4});return e.jsx("div",{className:"space-y-3",children:a&&!t?e.jsx(Eu,{detail:r instanceof Error?r.message:null,onRetry:()=>void i(),isRetrying:o}):n?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((l,c)=>e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx("div",{className:"bg-muted animate-breath h-4 w-24 rounded"}),e.jsx("div",{className:"bg-muted animate-breath h-4 w-16 rounded"})]},c))}):t?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[t.isDevMode?e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Development build"}),e.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"Running from source. Update checks are off."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Zs,{label:"Version",value:t.version}),t.latestVersion&&Ii(t.latestVersion,t.version)&&e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Update available: v",t.latestVersion]})}),e.jsxs("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:["Run"," ",e.jsx("code",{className:"text-3xs rounded bg-amber-100 px-1 py-0.5 font-mono dark:bg-amber-900/50",children:"npm update -g dorkos"})," ","to update"]})]})]}),e.jsx(Ru,{port:t.port}),e.jsx(Zs,{label:"Uptime",value:Du(t.uptime)})]}),e.jsx(Au,{config:t}),e.jsx(Tu,{config:t})]}):null})}function Au({config:s}){const[t,n]=m.useState(!1),a=[{label:"Working folder",value:s.workingDirectory},{label:"Data folder",value:s.dorkHome},{label:"Boundary",value:s.boundary},{label:"Node.js",value:s.nodeVersion}];return e.jsx(ws,{open:t,onOpenChange:n,trigger:"Diagnostics",action:e.jsx(Ce,{value:a.map(r=>`${r.label}: ${r.value}`).join(`
12
- `),label:"Copy all diagnostics"}),children:e.jsx("div",{className:"space-y-1",children:a.map(r=>e.jsx(Zs,{label:r.label,value:r.value,mono:!0,truncate:!0},r.label))})})}function Tu({config:s}){const[t,n]=m.useState(!1),a=U(),r=V(),i=s.logging,o=m.useCallback(async l=>{const c=i??{level:"info",maxLogSizeKb:500,maxLogFiles:14};await a.updateConfig({logging:{...c,...l}}),await r.invalidateQueries({queryKey:G.all})},[a,r,i]);return i?e.jsxs(ws,{open:t,onOpenChange:n,trigger:"Logging",badge:e.jsx("span",{className:"text-muted-foreground text-xs",children:i.level}),children:[e.jsx($,{label:"Log level",description:"How much detail DorkOS writes down.",children:e.jsxs(oe,{value:i.level,onValueChange:l=>o({level:l}),children:[e.jsx(le,{className:"w-28",children:e.jsx(ce,{})}),e.jsx(de,{children:Cu.map(l=>e.jsx(P,{value:l,children:l},l))})]})}),e.jsx($,{label:"Biggest log file",description:"When DorkOS starts a new file.",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{type:"number",min:100,max:10240,value:i.maxLogSizeKb,onChange:l=>{const c=parseInt(l.target.value,10);c>=100&&c<=10240&&o({maxLogSizeKb:c})},className:"w-24"}),e.jsx("span",{className:"text-muted-foreground text-xs",children:"KB"})]})}),e.jsx($,{label:"Days of logs kept",description:"From 1 to 30, up to 200 MB in all.",children:e.jsx(J,{type:"number",min:1,max:30,value:i.maxLogFiles,onChange:l=>{const c=parseInt(l.target.value,10);c>=1&&c<=30&&o({maxLogFiles:c})},className:"w-20"})}),s.dorkHome&&e.jsx(Ou,{dorkHome:s.dorkHome})]}):null}function Ou({dorkHome:s}){const{copied:t,failed:n,copy:a}=ot(),r=`${s}/logs`;function i(){return t?e.jsx("span",{className:"text-xs",children:"Copied"}):n?e.jsx("span",{className:"text-destructive text-xs",children:"Couldn’t copy"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"max-w-40 truncate font-mono text-xs",dir:"rtl",title:r,children:e.jsx("bdi",{dir:"ltr",children:r})}),e.jsx(fn,{className:"size-3 shrink-0"})]})}return e.jsx($,{label:"Log location",description:"Where DorkOS keeps these files.",children:e.jsx("button",{type:"button",onClick:()=>void a(r),className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 transition-colors",children:i()})})}function Eu({detail:s,onRetry:t,isRetrying:n}){return e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Can’t reach the DorkOS server"}),e.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"It may be restarting. Try again shortly."}),s?e.jsx("p",{className:"text-3xs mt-1 font-mono break-words text-amber-700/80 dark:text-amber-300/80",children:s}):null,e.jsx(b,{variant:"outline",size:"sm",className:"mt-2",onClick:t,disabled:n,"aria-label":"Try reaching the server again",children:n?"Trying…":"Try again"})]})}function Ru({port:s}){const t=`http://localhost:${s}`;return e.jsxs("div",{className:"border-border/60 -mx-1 mt-3 mb-3 space-y-2 border-b px-1 pb-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Address"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Where DorkOS runs on this computer. Bookmark it or share it."})]}),e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-1.5 gap-y-2",children:[e.jsx(ln,{url:t,label:"DorkOS address",children:e.jsx("button",{type:"button",onClick:()=>ii(t),className:"text-muted-foreground hover:text-foreground focus-ring rounded-sm p-1 transition-colors","aria-label":"Open DorkOS in your browser",title:"Open in your browser",children:e.jsx(Ns,{className:"size-3.5"})})}),e.jsx("p",{className:"text-muted-foreground col-span-2 text-xs",children:"For MCP clients like Claude Code or Cursor. Paste it, don’t visit it."}),e.jsx(ln,{url:`${t}/mcp`,label:"MCP endpoint"})]})]})}function ln({url:s,label:t,children:n}){return e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"bg-muted min-w-0 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ce,{value:s,label:`Copy the ${t}`}),n]})]})}function Zs({label:s,value:t,mono:n,truncate:a,muted:r}){const{copied:i,failed:o,copy:l}=ot();function c(){return i?e.jsx("span",{className:"text-muted-foreground text-xs",children:"Copied"}):o?e.jsx("span",{className:"text-destructive text-xs",children:"Couldn’t copy"}):e.jsx("span",{className:L("text-right text-sm",n&&"font-mono",a&&"max-w-48 min-w-0 truncate",r&&"text-muted-foreground"),dir:a?"rtl":void 0,title:t,children:e.jsx("bdi",{dir:"ltr",children:t})})}return e.jsxs("button",{type:"button",onClick:()=>void l(t),className:"hover:bg-muted/50 active:bg-muted/70 -mx-1 flex w-full items-center justify-between gap-4 rounded px-1 py-1 transition-colors duration-100",children:[e.jsx("span",{className:"text-muted-foreground shrink-0 text-sm",children:s}),c()]})}function Du(s){const t=Math.floor(s/3600),n=Math.floor(s%3600/60),a=Math.floor(s%60),r=[];return t>0&&r.push(`${t}h`),n>0&&r.push(`${n}m`),r.push(`${a}s`),r.join(" ")}function Iu({scheduler:s,onUpdate:t}){return e.jsxs(e.Fragment,{children:[e.jsx($,{label:"Scheduled runs at once",description:"How many tasks can run at once.",children:e.jsx(J,{type:"number",min:1,max:10,value:s.maxConcurrentRuns,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=10&&t({maxConcurrentRuns:a})},className:"w-20"})}),e.jsx($,{label:"Run history",description:"How many finished runs to keep.",children:e.jsx(J,{type:"number",min:1,max:1e4,value:s.retentionCount,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&t({retentionCount:a})},className:"w-24"})})]})}function cn(s){return s.lockedByEnv?s.running:s.enabledInConfig??s.running}function dn(s,t,n){const a=Pu(s,t);return a?`${n} ${a}`:n}function Pu(s,t){if(s.lockedByEnv)return`${t} on this computer controls this switch.`;const n=s.enabledInConfig??s.running;return n&&!s.running&&s.initError?"It’s on, but didn’t start last time. Nothing is running.":n!==s.running?"Saved. Applies the next time DorkOS starts.":null}function Lu({tasks:s,relay:t,onTasksChange:n,onRelayChange:a}){return e.jsxs("div",{className:"space-y-4","data-testid":"background-systems",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"These run in the background. Turning one off also stops its tools."}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Scheduled runs",description:dn(s,"DORKOS_TASKS_ENABLED","Runs scheduled tasks when they’re due. Off means nothing runs on a schedule."),checked:cn(s),onCheckedChange:n,disabled:s.lockedByEnv===!0}),e.jsx(_,{label:"Agent messaging",description:dn(t,"DORKOS_RELAY_ENABLED","Carries messages between agents and chat apps. Off stops Telegram and Slack too."),checked:cn(t),onCheckedChange:a,disabled:t.lockedByEnv===!0})]})})]})}function $u(){return e.jsxs("div",{className:"flex gap-3 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[e.jsx(Me,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Not for agents that run inside DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Those agents already have these tools. Adding them twice stops every tool call."}),e.jsxs(Cs,{className:"text-xs",children:[e.jsx("p",{children:"Claude rejects the repeated tool names with “Tool names must be unique”."}),e.jsx("p",{children:"This is for apps running on their own: Claude Code, Cursor, Windsurf."})]})]})]})}function _u({endpoint:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Endpoint"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"The address to give other apps"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsx(Ce,{value:s})]})]})}function Fu({rateLimit:s,onUpdate:t}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(_,{label:"Cap incoming requests",description:"Limits how often other apps can call DorkOS.",checked:s.enabled,onCheckedChange:n=>t({enabled:n}),ariaLabel:"Toggle rate limiting"}),s.enabled&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:"mcp-max-requests",className:"text-muted-foreground text-xs",children:"Max requests"}),e.jsx(J,{id:"mcp-max-requests",type:"number",min:1,max:1e3,value:s.maxPerWindow,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=1e3&&t({maxPerWindow:a})},className:"w-20"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:"mcp-window-secs",className:"text-muted-foreground text-xs",children:"Window (sec)"}),e.jsx(J,{id:"mcp-window-secs",type:"number",min:1,max:3600,value:s.windowSecs,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=3600&&t({windowSecs:a})},className:"w-20"})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Changes apply after DorkOS restarts."})]})]})}function Mu(s,t){const n=t?`Bearer ${t}`:"Bearer dork_mcp_YOUR_API_KEY";return{claudeCode:JSON.stringify({mcpServers:{"dorkos-external":{type:"http",url:s,headers:{Authorization:n}}}},null,2),claudeCodeCli:`claude mcp add-json dorkos-external '${JSON.stringify({type:"http",url:s,headers:{Authorization:n}})}'`,cursor:JSON.stringify({mcpServers:{"dorkos-external":{url:s,headers:{Authorization:n}}}},null,2),windsurf:JSON.stringify({mcpServers:{"dorkos-external":{serverUrl:s,headers:{Authorization:n}}}},null,2)}}function zu({endpoint:s,apiKey:t}){const[n,a]=m.useState(!1),[r,i]=m.useState("claude-code"),o=Mu(s,t),l=r==="claude-code"?o.claudeCode:r==="cursor"?o.cursor:o.windsurf;return e.jsxs(Ye,{open:n,onOpenChange:a,children:[e.jsxs(Ve,{className:"flex w-full items-center justify-between text-sm font-medium",children:[e.jsx("span",{children:"Setup instructions"}),e.jsx(We,{className:L("text-muted-foreground size-3.5 transition-transform duration-150",!n&&"-rotate-90")})]}),e.jsx(Qe,{children:e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("div",{className:"bg-muted flex gap-0.5 rounded-md p-0.5",children:["claude-code","cursor","windsurf"].map(c=>e.jsx("button",{onClick:()=>i(c),className:L("flex-1 rounded-sm px-3 py-1.5 text-xs font-medium transition-colors",r===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c==="claude-code"?"Claude Code":c==="cursor"?"Cursor":"Windsurf"},c))}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:l}),e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(Ce,{value:l})})]}),r==="claude-code"&&e.jsxs("div",{className:"relative",children:[e.jsx("p",{className:"text-muted-foreground mb-1 text-xs",children:"Or add it from the terminal:"}),e.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:o.claudeCodeCli}),e.jsx("div",{className:"absolute right-2 bottom-2",children:e.jsx(Ce,{value:o.claudeCodeCli})})]})]})})]})}function Uu({mcp:s,authEnabled:t}){const n=U(),a=V(),[r,i]=m.useState(!1),o=m.useCallback(()=>a.invalidateQueries({queryKey:G.all}),[a]),l=m.useCallback(async f=>{await n.updateConfig({mcp:{enabled:f,rateLimit:s.rateLimit}}),await o()},[n,s.rateLimit,o]),c=m.useCallback(async f=>{await n.updateConfig({mcp:{enabled:s.enabled,rateLimit:{...s.rateLimit,...f}}}),await o()},[n,s.enabled,s.rateLimit,o]),[d,u]=m.useState(null),x=m.useCallback(async()=>{const{localToken:f}=await n.revealMcpLocalToken();u(f)},[n]),h=m.useCallback(async()=>{const{localToken:f}=await n.rotateMcpLocalToken();u(f),await o()},[n,o]),p=s.enabled?s.authConfigured?e.jsx(se,{variant:"outline",tone:"success",children:"Enabled"}):e.jsx(se,{variant:"outline",tone:"warning",children:"Not protected"}):e.jsx(se,{variant:"secondary",children:"Disabled"});return e.jsx(R,{children:e.jsxs(Ye,{open:r,onOpenChange:i,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Connect other apps to DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Lets Claude Code, Cursor and others use DorkOS tools"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[p,e.jsx(He,{checked:s.enabled,onCheckedChange:l,"aria-label":"Toggle access for other apps"}),e.jsx(Ve,{asChild:!0,children:e.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${r?"Collapse":"Expand"} MCP server settings`,children:e.jsx(We,{className:L("size-3.5 transition-transform duration-150",!r&&"-rotate-90")})})})]})]}),e.jsx(Qe,{children:e.jsxs(D,{className:"border-t",children:[e.jsx($u,{}),e.jsx(Ku,{}),e.jsx(_u,{endpoint:s.endpoint}),e.jsx(Bu,{authSource:s.authSource,authEnabled:t,revealedToken:d,onReveal:x,onRotate:h}),e.jsx(Fu,{rateLimit:s.rateLimit,onUpdate:c}),e.jsx(zu,{endpoint:s.endpoint,apiKey:d})]})})]})})}function Ku(){const s=In(),{close:t}=fe();return e.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["To give an agent another server’s tools, open its profile."," ",e.jsx(b,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>{t(),s({...Pn.team()})},children:"Open the Team page"})]})}function Bu({authSource:s,authEnabled:t,revealedToken:n,onReveal:a,onRotate:r}){return s==="env"?e.jsx($,{label:"Authentication",description:"Protected by the MCP_API_KEY environment variable.",children:e.jsx(se,{variant:"outline",children:"Environment variable"})}):s==="local-token"?e.jsx(Wu,{revealedToken:n,onReveal:a,onRotate:r}):s==="none"&&!t?e.jsx($,{label:"Authentication",description:"Couldn’t make a token for other apps. Use a personal API key instead.",children:e.jsx(se,{variant:"outline",tone:"warning",children:"No key yet"})}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"text-muted-foreground size-3.5"}),e.jsx("p",{className:"text-sm font-medium",children:"Authentication"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Other apps sign in with a personal API key."}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Make one in Settings → Login & security. Send it as a"," ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]})]})}function Wu({revealedToken:s,onReveal:t,onRotate:n}){const[a,r]=m.useState(!1),[i,o]=m.useState(!1),[l,c]=m.useState(!1);async function d(){c(!0);try{await t()}catch(x){$e.error("Couldn’t show the token.",{description:x instanceof Error?x.message:"Try again in a moment."})}finally{c(!1)}}async function u(){o(!0);try{await n(),r(!1)}catch(x){$e.error("Couldn’t make a new token.",{description:x instanceof Error?x.message:"The old one still works."})}finally{o(!1)}}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"text-muted-foreground size-3.5"}),e.jsx("p",{className:"text-sm font-medium",children:"Local MCP token"})]}),e.jsxs(me,{open:a,onOpenChange:r,children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"outline",size:"sm",children:"Rotate"})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Rotate the local MCP token?"}),e.jsx(ae,{children:"The old token stops working. Apps need the new one. This can’t be undone."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{disabled:i,onClick:x=>{x.preventDefault(),u()},children:i?"Rotating…":"Rotate token"})]})]})]})]}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Paste it into your MCP client as a ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"It guards tools that change things. Read-only checks work without it."}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Only apps on this computer can use it. Other devices need a personal API key."}),s?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsx(Ce,{value:s})]}):e.jsx(b,{variant:"outline",size:"sm",onClick:d,disabled:l,children:l?"Revealing…":"Reveal token"})]})}function qu(){var x,h,p,f,g,y,N;const s=lt(),t=ft(),n=oi(),a=U(),r=V(),{section:i}=fe();zn(i);const{data:o}=Y({queryKey:G.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),l=o==null?void 0:o.scheduler,c=m.useCallback(async j=>{const C=l??{maxConcurrentRuns:1,retentionCount:100};await a.updateConfig({scheduler:{...C,...j}}),await r.invalidateQueries({queryKey:G.all})},[a,r,l]),d=m.useCallback(async j=>{await a.updateConfig({scheduler:{enabled:j}}),await r.invalidateQueries({queryKey:G.all})},[a,r]),u=m.useCallback(async j=>{await a.updateConfig({relay:{enabled:j}}),await r.invalidateQueries({queryKey:G.all})},[a,r]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Lu,{tasks:{running:n,enabledInConfig:(x=o==null?void 0:o.tasks)==null?void 0:x.enabledInConfig,lockedByEnv:(h=o==null?void 0:o.tasks)==null?void 0:h.lockedByEnv,initError:(p=o==null?void 0:o.tasks)==null?void 0:p.initError},relay:{running:t,enabledInConfig:(f=o==null?void 0:o.relay)==null?void 0:f.enabledInConfig,lockedByEnv:(g=o==null?void 0:o.relay)==null?void 0:g.lockedByEnv,initError:(y=o==null?void 0:o.relay)==null?void 0:y.initError},onTasksChange:j=>void d(j),onRelayChange:j=>void u(j)}),l&&n&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(Iu,{scheduler:l,onUpdate:c})})}),!s&&e.jsx(gc,{}),(o==null?void 0:o.mcp)&&e.jsx("div",{"data-section":"external-mcp",children:e.jsx(Uu,{mcp:o.mcp,authEnabled:((N=o.auth)==null?void 0:N.enabled)===!0})})]})}const un=["hub","computers"];function Hu(){var d;const s=U(),t=V(),[n,a]=m.useState(null),[r,i]=m.useState(null),o=Y({queryKey:un,queryFn:()=>s.listHubComputers(),retry:!1,staleTime:15e3}),l=ge({mutationFn:()=>s.createHubLinkCode(),onMutate:()=>i(null),onSuccess:u=>a(u),onError:()=>i("Couldn’t make a code. Try again.")}),c=ge({mutationFn:u=>s.removeHubComputer(u),onMutate:()=>i(null),onSuccess:()=>t.invalidateQueries({queryKey:un}),onError:()=>i("Couldn’t remove that computer. Try again.")});return{isHub:o.isSuccess,computers:((d=o.data)==null?void 0:d.computers)??[],linkCode:n,error:r,minting:l.isPending,removing:c.isPending?c.variables??null:null,mint:()=>l.mutate(),dismissCode:()=>a(null),remove:u=>c.mutate(u)}}function Yu(s){const t=new Date(s);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function Vu({code:s,onDone:t}){const n=Yu(s.expiresAt);return e.jsxs("div",{className:"bg-muted space-y-2 rounded-md p-3",children:[e.jsx("p",{className:"text-sm",children:"Paste this code into DorkOS on the computer to link."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 truncate font-mono text-sm","data-testid":"hub-link-code",children:s.linkCode}),e.jsx(Ce,{value:s.linkCode,label:"Copy code"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:n?`Works once, until ${n}.`:"Works once, for 10 minutes."}),e.jsx(b,{variant:"ghost",size:"sm",onClick:t,children:"Done"})]})]})}function Qu({computer:s,removing:t,onRemove:n}){const a=s.computerName??s.computerId;return e.jsxs("li",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm",children:a}),e.jsx("p",{className:"text-muted-foreground text-xs",children:s.connected?"Connected":"Not connected"})]}),e.jsx(b,{variant:"outline",size:"sm",onClick:n,disabled:t,"aria-label":`Remove ${a}`,children:"Remove"})]})}function Gu({className:s}){const t=Hu();return t.isHub?e.jsxs("section",{"aria-labelledby":"linked-computers-title",className:L("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{id:"linked-computers-title",className:"text-sm font-medium",children:"Linked computers"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Chat with the agents on your own computers from here."})]}),e.jsx(b,{size:"sm",onClick:t.mint,disabled:t.minting,children:"Link a computer"})]}),t.linkCode&&e.jsx(Vu,{code:t.linkCode,onDone:t.dismissCode}),t.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.error}),t.computers.length===0?e.jsx("p",{className:"text-muted-foreground text-xs",children:"No computers linked yet."}):e.jsx("ul",{className:"space-y-2",children:t.computers.map(n=>e.jsx(Qu,{computer:n,removing:t.removing===n.computerId,onRemove:()=>t.remove(n.computerId)},n.computerId))})]}):null}function Xu(){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Gu,{}),e.jsx(_d,{}),e.jsxs(Wo,{signedOut:e.jsx(Ju,{}),children:[e.jsx(Qi,{}),e.jsx(dc,{})]})]})}function Ju(){const{data:s}=ys(),t=El(s),n=ct();return e.jsxs("div",{className:"space-y-2",children:[t.length>0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"Link a DorkOS account to:"}),e.jsxs("ul",{className:"text-muted-foreground list-disc space-y-1 pl-5 text-sm",children:[e.jsxs("li",{children:["Use one account for ",t.join(" and "),": run"," ",t.length===1?"it":"them"," on your DorkOS credits."]}),e.jsx("li",{children:"See your plan, credits and seats here."})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Link a DorkOS account to see your plan, credits and seats here."}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Everything else works without one."})]}),e.jsx(Fn,{withSpaces:n})]})}const mn=["lan-access"],Zu=15e3;function em(){const s=U(),t=V(),[n,a]=m.useState(!1),[r,i]=m.useState(null),{data:o}=Y({queryKey:mn,queryFn:()=>s.getLanAccess(),refetchInterval:Zu}),l=m.useCallback(async c=>{const d=async u=>{a(!0),i(null);try{const x=await s.setLanAccess(u);t.setQueryData(mn,x),t.invalidateQueries({queryKey:G.current()})}catch(x){(x==null?void 0:x.code)==="AUTH_REQUIRED_FOR_EXPOSURE"?li({reason:"exposure",message:"Wi-Fi access needs a login.",onComplete:()=>void d(!0)}):i(x instanceof Error&&x.message?x.message:"Could not change that.")}finally{a(!1)}};await d(c)},[s,t]);return{status:o,busy:n,error:r,setEnabled:l}}function sm(s){const t=s.localName??s.addresses[0];return t?`http://${t}:${s.port}`:null}function xn({url:s,label:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("code",{className:"truncate text-sm",children:s}),e.jsx(Ce,{value:s,label:t})]})}function tm({status:s}){const t=sm(s);if(!t)return e.jsx("p",{className:"text-muted-foreground text-xs",children:"Join a Wi-Fi network to get an address."});const n=s.localName?s.addresses.map(a=>`http://${a}:${s.port}`):s.addresses.slice(1).map(a=>`http://${a}:${s.port}`);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ci,{url:t,size:160}),e.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"Scan with a phone or tablet on the same Wi-Fi."}),e.jsx(xn,{url:t,label:"Copy address"}),n.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"If that name doesn’t open, use:"}),n.map(a=>e.jsx(xn,{url:a,label:"Copy address"},a))]})]})}function nm({className:s}){const{status:t,busy:n,error:a,setEnabled:r}=em();if(!t)return null;const i=t.setByEnvironment!==null,o=i||!t.supported,l=a??t.error;return e.jsxs("section",{"aria-labelledby":"lan-access-title",className:L("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{id:"lan-access-title",className:"text-sm font-medium",children:"Let devices on my Wi-Fi in"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"For home or office Wi-Fi. It isn’t encrypted yet."})]}),e.jsx(He,{"aria-labelledby":"lan-access-title",checked:o?!1:t.enabled,onCheckedChange:c=>void r(c),disabled:n||o})]}),i&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[t.setByEnvironment," is set, so it decides where DorkOS listens."]}),l&&e.jsx("p",{className:"text-destructive text-xs",children:l}),t.listening&&e.jsx(tm,{status:t})]})}function am(){const s=di({open:!0}),t=ui({machine:s});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(mi,{machine:s,actions:t}),e.jsx(xi,{}),e.jsx(nm,{})]})}function rm(){const{data:s}=Se(),t=ye(),n=s==null?void 0:s.telemetry,a=(r,i)=>{t.mutate({telemetry:{[r]:i,userHasDecided:!0}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Nothing is shared unless a switch below is on."," ",e.jsx("a",{href:hi("/telemetry"),target:"_blank",rel:"noopener noreferrer",className:"text-foreground underline underline-offset-2",children:"Read the full contract"}),"."]}),e.jsxs(Cs,{className:"text-xs",children:[e.jsx("p",{children:"The three count switches are anonymous. They never send prompts, code or file paths."}),e.jsx("p",{children:"The counts never send before the first-run notice."}),e.jsx("p",{children:"Crash reports and AI run data are separate. Both start off."})]})]}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Share anonymous install counts",description:"Counts marketplace installs, to rank packages and spot broken ones.",checked:(n==null?void 0:n.install)??!1,onCheckedChange:r=>a("install",r),disabled:t.isPending}),e.jsx(_,{label:"Share an anonymous daily heartbeat",description:"One anonymous ping a day, to count active installs. Exact payload below.",checked:(n==null?void 0:n.heartbeat)??!1,onCheckedChange:r=>a("heartbeat",r),disabled:t.isPending}),e.jsx(_,{label:"Share anonymous feature-usage events",description:"Counts events like app start and finished setup, plus any install tag.",checked:(n==null?void 0:n.usage)??!1,onCheckedChange:r=>a("usage",r),disabled:t.isPending}),e.jsx(_,{label:"Share AI run metadata",description:"Model, tokens, time and cost per turn. Never your prompts, code or chats.",checked:(n==null?void 0:n.aiMetadata)??!1,onCheckedChange:r=>a("aiMetadata",r),disabled:t.isPending}),e.jsx(_,{label:"Share crash reports",description:"A scrubbed report to dorkos.ai when something breaks. No error messages, paths or code.",checked:(n==null?void 0:n.errorReporting)??!1,onCheckedChange:r=>a("errorReporting",r),disabled:t.isPending})]})}),e.jsx(Bo,{})]})}async function im(s){const t=new Map;for(let n=0;n<localStorage.length;n++){const a=localStorage.key(n);if(a===null)continue;const r=localStorage.getItem(a);r!==null&&t.set(a,r)}localStorage.clear();try{return await s()}catch(n){for(const[a,r]of t)localStorage.setItem(a,r);throw n}}function om({open:s,onOpenChange:t,onResetComplete:n}){const[a,r]=m.useState(""),[i,o]=m.useState(!1),l=U(),c=a==="reset";async function d(){o(!0);try{const x=oo();if(x)await im(async()=>{lo(await x.resetAllData())});else{const{token:h}=await l.prepareReset();await l.resetAllData("reset",h),localStorage.clear()}t(!1),n()}catch(x){$e.error("Couldn’t reset your data.",{description:x instanceof Error?x.message:"Some of it may already be gone. Try again."})}finally{o(!1)}}function u(x){x||(r(""),o(!1)),t(x)}return e.jsx(me,{open:s,onOpenChange:u,children:e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Reset all data?"}),e.jsx(ae,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"This deletes all DorkOS data for good, including:"}),e.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[e.jsx("li",{children:"Scheduled tasks and their run history"}),e.jsx("li",{children:"Agent messaging setup and messages"}),e.jsx("li",{children:"DorkOS’s list of your agents"}),e.jsx("li",{children:"Your config file and preferences"}),e.jsx("li",{children:"Server logs"})]}),e.jsx("p",{children:"DorkOS restarts on its own. This device’s preferences are cleared too."}),e.jsx("p",{className:"font-semibold",children:"This can’t be undone."})]})})]}),e.jsx("div",{className:"py-2",children:e.jsx(J,{placeholder:"Type “reset” to continue",value:a,onChange:x=>r(x.target.value),"data-testid":"reset-confirm-input"})}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{disabled:!c||i,onClick:d,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 dark:bg-destructive/60",children:i?"Resetting…":"Reset all data"})]})]})})}function lm({open:s,onOpenChange:t}){const n=Ee(i=>i.resetAllSettings),{setTheme:a}=pt();function r(){n(),a("system"),t(!1),$e.success("Settings are back to defaults")}return e.jsx(me,{open:s,onOpenChange:t,children:e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Reset all settings?"}),e.jsx(ae,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"Theme, text, toggles and layouts on this device go back to default."}),e.jsx("p",{children:"Nothing you made is deleted. Your projects, agents and chats stay."})]})})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:r,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 dark:bg-destructive/60",children:"Reset settings"})]})]})})}function cm({open:s,onOpenChange:t,onRestartComplete:n}){const[a,r]=m.useState(!1),i=U();async function o(){r(!0);try{await co(i),t(!1),n()}catch(l){$e.error("Couldn’t restart DorkOS.",{description:l instanceof Error?l.message:"It may not have restarted. Try again."})}finally{r(!1)}}return e.jsx(me,{open:s,onOpenChange:t,children:e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Restart DorkOS?"}),e.jsx(ae,{children:"Anything running right now stops. DorkOS is back in seconds."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{disabled:a,onClick:o,children:a?"Restarting…":"Restart DorkOS"})]})]})})}function dm(){const[s,t]=m.useState(!1),[n,a]=m.useState(!1),[r,i]=m.useState(!1),o=Ee(l=>l.setRestartOverlayOpen);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(R,{className:"border-destructive/50",children:e.jsxs(D,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Reset all settings"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Theme, text, toggles and layouts on this device go back to default."}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Your projects, agents and chats stay."})]}),e.jsx(b,{variant:"destructive",size:"sm",onClick:()=>a(!0),children:"Reset settings"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Reset all data"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Deletes everything DorkOS saved, then restarts it. Can’t be undone."})]}),e.jsx(b,{variant:"destructive",size:"sm",onClick:()=>t(!0),children:"Reset data"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Restart DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Anything running right now stops."})]}),e.jsx(b,{variant:"destructive",size:"sm",onClick:()=>i(!0),children:"Restart"})]})]})}),e.jsx(lm,{open:n,onOpenChange:a}),e.jsx(om,{open:s,onOpenChange:t,onResetComplete:()=>o(!0)}),e.jsx(cm,{open:r,onOpenChange:i,onRestartComplete:()=>o(!0)})]})}function um(){const s=pi(),t=gi(),{setShowSessions:n}=fi();return s?e.jsx(_,{label:"Show sessions",description:"See the working session behind each chat: model, account and context.",checked:t,onCheckedChange:n}):null}function mm(s,t){return s.split(".").reduceRight((a,r)=>({[r]:a}),t)}function xm(s,t,n){const a=[s];return t!==void 0&&a.push(t),n!==void 0&&a.push(`${n} on this computer controls this switch.`),a.join(" ")}function hm(){const{data:s,isLoading:t}=Se(),n=ye(),a=Ee(o=>o.devtoolsOpen),r=Ee(o=>o.toggleDevtools),i=(s==null?void 0:s.experiments)??[];return e.jsxs("div",{className:"space-y-6","data-testid":"experiments-tab",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Unfinished features you can try early."}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Show dev tools",description:"Opens a panel showing what the app has loaded.",checked:a,onCheckedChange:()=>r()}),e.jsx(um,{})]})}),t?null:i.length===0?e.jsx("p",{className:"text-muted-foreground text-sm","data-testid":"experiments-empty",children:"No experiments right now. New ones show up here."}):e.jsx(R,{children:e.jsx(D,{children:i.map(o=>e.jsx(_,{label:o.title,description:xm(o.description,o.costNote,o.envOverride),checked:o.enabled,onCheckedChange:l=>n.mutate(mm(o.key,l)),disabled:o.lockedByEnv},o.key))})}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"These start off. Each one graduates or goes away."})]})}const pm={group:yi,storageKey:ji.SETTINGS_ADVANCED_OPEN},gm={profile:{icon:Ti,component:Xd},account:{icon:Po,component:Xu},appearance:{icon:$o,component:eu,actions:e.jsx(Zd,{})},preferences:{icon:_o,component:pc},notifications:{icon:Ai,component:su},runtimes:{icon:Io,component:wu},permissions:{icon:js,component:ou},connections:{icon:Si,component:ru},security:{icon:Ci,component:ul},"remote-access":{icon:wi,component:am},privacy:{icon:ki,component:rm},server:{icon:Do,component:Su},tools:{icon:Gi,component:qu},rooms:{icon:Ni,component:au},experiments:{icon:vi,component:hm},danger:{icon:Me,component:dm}};function fm(s){return bi(s).map(t=>({id:t.id,label:t.label,group:t.group,...gm[t.id]}))}function ix({open:s,onOpenChange:t}){const{activeTab:n}=fe(),a=lt(),r=m.useMemo(()=>fm(a),[a]);return e.jsx(Mo,{open:s,onOpenChange:t,title:"Settings",description:"Application settings",defaultTab:"appearance",initialTab:n,tabs:r,extensionSlot:"settings.tabs",maximized:!0,foldedGroup:pm,testId:"settings-dialog"})}export{ix as SettingsDialog};
11
+ */const Qn={name:"settings-2",size:24,node:[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]};Qn.node;const Fo=pn(Qn);function Mo({storageKey:s,dialogOpen:t,activeInGroup:n,activeTab:a}){const[r,i]=m.useState(()=>It(s,!1)),[o,l]=m.useState(t),c=t&&n?a:null,[d,u]=m.useState(null);let x=r;return t!==o&&(l(t),t&&(x=It(s,!1))),c!==d&&(u(c),c!==null&&(x=!0)),x!==r&&i(x),[x,p=>{pa(s,p),i(p)}]}function zo({open:s,onOpenChange:t,title:n,description:a,headerSlot:r,defaultTab:i,initialTab:o,tabs:l,extensionSlot:c,maxWidth:d="max-w-2xl",minHeight:u="min-h-[280px]",maximized:x=!1,foldedGroup:h,testId:p}){const f=gn(c??"settings.tabs"),g=c?[...l,...f.map(Ko)]:l,y=[];for(const S of g)y.includes(S.group)||y.push(S.group);const N=h==null?void 0:h.group;N!==void 0&&y.includes(N)&&(y.splice(y.indexOf(N),1),y.push(N));const j=g.some(S=>S.group),C=o&&g.some(S=>S.id===o)?o:null;m.useEffect(()=>{},[o,C,i]);const[E,A]=_o({open:s,initialTab:C,defaultTab:i}),T=N!==void 0&&g.some(S=>S.id===E&&S.group===N),[O,v]=Mo({storageKey:(h==null?void 0:h.storageKey)??"",dialogOpen:s,activeInGroup:T,activeTab:E}),k=m.useId(),Z=S=>S.map(K=>e.jsx(Aa,{value:K.id,icon:K.icon,children:K.label},K.id)),H=N===void 0?[]:g.filter(S=>S.group===N&&(O||S.id===E)),F=N!==void 0&&g.some(S=>S.group===N),M=m.useRef(!1);m.useEffect(()=>{var S,K,I;!O||!M.current||(M.current=!1,(I=(K=(S=document.getElementById(k))==null?void 0:S.querySelector("[data-value]"))==null?void 0:K.scrollIntoView)==null||I.call(K,{block:"nearest"}))},[O,k]);const W=F?e.jsxs(e.Fragment,{children:[e.jsx(ga,{expanded:O,onExpandedChange:S=>{M.current=S,v(S)},controls:H.length>0?k:void 0,children:N}),H.length>0&&e.jsx(fa,{id:k,label:N,children:Z(H)})]}):void 0;return e.jsx(et,{open:s,onOpenChange:t,children:e.jsx(st,{"data-testid":p,className:L("max-h-[85vh] gap-0 p-0",d,x&&"md:h-[92svh] md:max-h-[92svh] md:w-[95vw] md:max-w-[90rem]"),children:e.jsxs(ja,{value:E,onValueChange:S=>A(S),children:[e.jsx(ya,{}),e.jsxs(ba,{children:[e.jsx(tt,{className:"text-sm font-medium",children:n}),e.jsx(nt,{className:a?"text-muted-foreground text-xs":"sr-only",children:a??"Dialog"}),r]}),e.jsxs(va,{children:[e.jsx(Na,{footer:W,children:j?y.filter(S=>S===void 0||S!==N).map(S=>e.jsxs(m.Fragment,{children:[S&&e.jsx(ka,{children:S}),Z(g.filter(K=>K.group===S))]},S??"__ungrouped")):Z(g)}),e.jsx(wa,{className:L(u,"p-4"),children:g.map(S=>{const K=S.component;return e.jsx(Ca,{value:S.id,children:e.jsxs("div",{className:"max-w-3xl space-y-4",children:[e.jsx(Sa,{actions:S.actions,description:S.description,children:S.label}),e.jsx(m.Suspense,{fallback:e.jsx(Uo,{}),children:e.jsx(K,{})})]})},S.id)})})]})]})})})}function Uo(){return e.jsx("div",{className:"text-muted-foreground py-8 text-center text-sm",children:"Loading…"})}function Ko(s){return{id:s.id,label:s.label,icon:s.icon,component:s.component,group:s.group??"Add-ons"}}function Bo(){const{data:s}=Se(),t=ye(),n=s==null?void 0:s.welcomeBack,a=m.useCallback(i=>{t.mutate({welcomeBack:{enabled:i}})},[t]),r=m.useCallback(i=>{t.mutate({welcomeBack:{offersEnabled:i}})},[t]);return{enabled:(n==null?void 0:n.enabled)??!1,absenceThresholdMinutes:(n==null?void 0:n.absenceThresholdMinutes)??0,maxPosts:(n==null?void 0:n.maxPosts)??0,offersEnabled:(n==null?void 0:n.offersEnabled)??!1,setEnabled:a,setOffersEnabled:r,isAvailable:n!==void 0,isPending:t.isPending}}function Wo({className:s}){const[t,n]=m.useState(!1);return e.jsxs("div",{className:L("w-full",s),children:[e.jsx(Li,{open:t,onToggle:()=>n(a=>!a)}),e.jsx(Le,{initial:!1,children:t&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[0,0,.2,1]},className:"overflow-hidden",children:e.jsx("div",{className:"pt-2",children:e.jsx(_i,{})})},"payload")})]})}function Gn(s){return{connectionId:s.connectionId,name:`${ao(s.toolkit)} (${s.label})`,agentCount:s.agentCount,everyAgent:s.everyAgent!==null,usable:s.readiness.state==="ready"}}function bt(s){return s.filter(t=>t.readiness.state!=="gone"&&t.mode==="managed").map(Gn)}function Xn(s){return{stopping:s.filter(t=>t.usable),idle:s.filter(t=>!t.usable)}}function ps(s){return`${s} ${s===1?"app":"apps"}`}function zt({app:s}){return e.jsxs("li",{children:[s.name,s.everyAgent?e.jsx("span",{className:"text-muted-foreground",children:" · used by every agent"}):s.agentCount>0&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· used by ",s.agentCount," ",s.agentCount===1?"agent":"agents"]})]})}function Vs({stopping:s,idle:t,stopLine:n}){if(s.length===0&&t.length===0)return null;const a="text-foreground max-h-40 list-disc space-y-1 overflow-y-auto pl-5 text-sm";return e.jsxs("div",{className:"space-y-3 text-sm","data-testid":"connection-impact-list",children:[s.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:n}),e.jsx("ul",{className:a,children:s.map(r=>e.jsx(zt,{app:r},r.connectionId))})]}),t.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-muted-foreground",children:[t.length===1?"This app":`These ${t.length} apps`," can’t be used now either way:"]}),e.jsx("ul",{className:a,children:t.map(r=>e.jsx(zt,{app:r},r.connectionId))})]})]})}function qo({signedOut:s,children:t}){var x;const{view:n,start:a,unlink:r,cancel:i,starting:o,unlinking:l,startError:c,unlinkError:d}=Ta();Ho(n,a);const u=((x=Ea().data)==null?void 0:x.linked)===!0;return n.kind==="loading"?e.jsx(ee,{className:"h-24 w-full"}):n.kind==="linked"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Qo,{view:n,start:a,starting:o,startError:c,dismiss:i}),t,e.jsx(Go,{unlink:r,unlinking:l,unlinkError:d})]}):e.jsxs("div",{className:"space-y-4",children:[!u&&s,e.jsx(R,{children:e.jsx(D,{children:e.jsx(Yo,{view:n,start:a,cancel:i,starting:o,startError:c,relinking:u})})})]})}function Ho(s,t){const{section:n,setSection:a}=fe(),r=m.useRef(!1),i=n===Ra;m.useEffect(()=>{if(!i){r.current=!1;return}r.current||s.kind==="loading"||(r.current=!0,a(null),s.kind!=="pending"&&t())},[i,s.kind,t,a])}function Yo({view:s,start:t,cancel:n,starting:a,startError:r,relinking:i}){switch(s.kind){case"idle":return e.jsx(Vo,{start:t,starting:a,startError:r});case"pending":return e.jsx(Oa,{view:s,cancel:n,relinking:i},s.userCode);case"expired":return e.jsx(Os,{title:"Your code expired",description:"It ran out before you approved it.",actionLabel:"Get a new code",onAction:t,pending:a});case"denied":return e.jsx(Os,{title:"Link request denied",description:"It was turned down on dorkos.ai.",actionLabel:"Link this computer",onAction:t,pending:a});case"revoked":return e.jsx(Os,{title:"This computer was unlinked",description:"DorkOS removed its access to your account.",actionLabel:"Link again",onAction:t,pending:a})}}function Vo({start:s,starting:t,startError:n}){var N;const a=m.useId(),{data:r}=Se(),i=ye(),o=((N=r==null?void 0:r.telemetry)==null?void 0:N.linkAnalyticsToAccount)??!1,l=Da({value:o,generation:0});l.read().value!==o&&l.write({value:o,generation:l.read().generation+1});const c=l.read().generation,[d,u]=m.useState(null),x=d!==null&&d.generation===c?d.value:o,h=j=>u({generation:c,value:j}),[p,f]=m.useState(null),g=m.useCallback(async()=>{f(null);try{await i.mutateAsync({telemetry:{linkAnalyticsToAccount:x}})}catch{f("Couldn’t save your choice. Try again.");return}await s()},[i,x,s]),y=t||i.isPending;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(fn,{id:a,checked:x,onCheckedChange:j=>h(j===!0),disabled:y,className:"mt-0.5"}),e.jsxs("label",{htmlFor:a,className:"space-y-1 text-sm leading-snug",children:[e.jsx("span",{className:"font-medium",children:"Link usage counts to your account"}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:"See this install’s anonymous usage counts when signed in."}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:"Applies when you link. To change it later, link again."})]})]}),e.jsxs(b,{onClick:()=>void g(),disabled:y,children:[y?e.jsx(fs,{className:"mr-1.5"}):e.jsx(Ro,{className:"mr-1.5 size-(--size-icon-sm)"}),y?"Starting…":"Link this computer"]}),(p??n)&&e.jsx("p",{className:"text-destructive text-sm",role:"alert",children:p??n})]})}function Qo({view:s,start:t,starting:n,startError:a,dismiss:r}){return e.jsxs("div",{className:"space-y-4",children:[s.relinkOutcome&&e.jsx(Jo,{outcome:s.relinkOutcome,dismiss:r}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Signed in"}),s.accountLabel?e.jsx("p",{className:"text-foreground truncate text-sm",children:s.accountLabel}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Syncing account…"}),s.lastHeartbeatAt&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Last synced ",we(s.lastHeartbeatAt).toLowerCase()]})]}),e.jsxs(b,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void t(),disabled:n,children:[n?e.jsx(fs,{className:"mr-1.5"}):e.jsx(at,{className:"mr-1.5 size-3.5"}),"Link again"]})]}),a&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:a})]})}function Go({unlink:s,unlinking:t,unlinkError:n}){return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Unlink this computer",description:"Stops using your DorkOS account. You can link again anytime.",children:e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsxs(b,{variant:"outline",size:"sm",disabled:t,"aria-label":"Unlink this computer",children:[e.jsx(Oo,{className:L("mr-1.5 size-3.5",t&&"animate-pulse")}),t?"Unlinking…":"Unlink"]})}),e.jsx(Zo,{unlink:s})]})}),n&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:n})]})})}const Xo={denied:"The new link was turned down on dorkos.ai.",expired:"The new link’s code expired.",failed:"The new link couldn’t finish."};function Jo({outcome:s,dismiss:t}){return e.jsxs("div",{role:"status",className:"bg-muted/40 flex items-start gap-2 rounded-lg p-3 text-sm",children:[e.jsxs("p",{className:"min-w-0 flex-1",children:[Xo[s]," This computer is still linked."]}),e.jsx(b,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",className:"-my-1 shrink-0",onClick:()=>void t(),children:e.jsx(rt,{className:"size-3.5"})})]})}function Zo({unlink:s}){const t=jt(),n=t.data?bt(t.data.connections):[],{stopping:a,idle:r}=Xn(n);return e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Unlink this computer?"}),e.jsx(ae,{children:"It stops using your DorkOS account. You can link again anytime."})]}),t.isPending?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Checking which apps use this account…"}):t.isError?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t check which apps use this account. Any that do will stop working."}):e.jsx(Vs,{stopping:a,idle:r,stopLine:`${a.length===1?"This app":`These ${a.length} apps`} will stop working for every agent:`}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:()=>void s(),children:a.length>0?`Unlink and stop ${ps(a.length)}`:"Unlink"})]})]})}function Os({title:s,description:t,actionLabel:n,onAction:a,pending:r}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Me,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:s}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t})]})]}),e.jsxs(b,{onClick:()=>void a(),disabled:r,children:[r?e.jsx(fs,{className:"mr-1.5"}):e.jsx(at,{className:"mr-1.5 size-(--size-icon-sm)"}),n]})]})}const vt=["auth","api-keys"];function el(){const s=it();return Y({queryKey:vt,queryFn:async()=>{const{data:t,error:n}=await s.apiKey.list();if(n||!t)throw new Error("Couldn’t load API keys. Try again.");return t.apiKeys},staleTime:3e4})}function sl(){const s=it(),t=V(),[n,a]=m.useState(!1),[r,i]=m.useState(null);return{run:m.useCallback(async(l,c)=>{a(!0),i(null);const{data:d,error:u}=await s.apiKey.create({name:l.trim()||void 0,expiresIn:c??null});return a(!1),u||!d?(i(u??{message:"Couldn’t create the key. Try again.",status:0}),null):(await t.invalidateQueries({queryKey:vt}),d)},[s,t]),isPending:n,error:r,reset:()=>i(null)}}function tl(){const s=it(),t=V(),[n,a]=m.useState(null),[r,i]=m.useState(null);return{run:m.useCallback(async l=>{a(l),i(null);const{error:c}=await s.apiKey.delete({keyId:l});return a(null),c?(i(c),!1):(await t.invalidateQueries({queryKey:vt}),!0)},[s,t]),pendingId:n,error:r,reset:()=>i(null)}}const Ut=[{label:"Never",value:"never",seconds:null},{label:"7 days",value:"7d",seconds:3600*24*7},{label:"30 days",value:"30d",seconds:3600*24*30},{label:"90 days",value:"90d",seconds:3600*24*90}];function nl({loginRequired:s=!0}={}){const t=m.useId(),{data:n,isError:a,isFetching:r,isLoading:i,refetch:o}=el(),l=sl(),c=tl(),[d,u]=m.useState(""),[x,h]=m.useState("never"),[p,f]=m.useState(null);async function g(){var j;const y=((j=Ut.find(C=>C.value===x))==null?void 0:j.seconds)??null,N=await l.run(d,y);N&&(f(N),u(""),h("never"))}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"API keys"})]}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Keys for MCP clients, scripts and agents. Send one as a"," ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]}),!s&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Keys still work with login off. Revoke any you don’t need."})]}),p?e.jsx(al,{created:p,onDone:()=>f(null)}):e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"min-w-40 flex-1 space-y-1.5",children:[e.jsx(X,{htmlFor:t,children:"Name"}),e.jsx(J,{id:t,placeholder:"e.g. laptop-cli",value:d,onChange:y=>u(y.target.value)})]}),e.jsxs("div",{className:"w-32 space-y-1.5",children:[e.jsx(X,{children:"Expires"}),e.jsxs(oe,{value:x,onValueChange:h,children:[e.jsx(le,{children:e.jsx(ce,{})}),e.jsx(de,{children:Ut.map(y=>e.jsx(P,{value:y.value,children:y.label},y.value))})]})]}),e.jsx(b,{onClick:g,disabled:l.isPending,children:l.isPending?"Creating…":"Create key"})]}),l.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:l.error.message}),e.jsx("div",{className:"space-y-1.5",children:i?e.jsx(ee,{className:"h-9 w-full"}):a?e.jsx(Xe,{title:"Couldn’t load API keys",description:"No keys were changed. Try again.",onRetry:()=>void o(),isRetrying:r,className:"py-6"}):n&&n.length>0?n.map(y=>e.jsx(rl,{apiKey:y,revoking:c.pendingId===y.id,onRevoke:()=>c.run(y.id)},y.id)):e.jsx("p",{className:"text-muted-foreground text-xs",children:"No API keys yet."})}),c.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:c.error.message})]})}function al({created:s,onDone:t}){const{copied:n,failed:a,copy:r}=ot();return e.jsxs("div",{className:"border-primary/40 bg-primary/5 space-y-3 rounded-lg border p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Copy your key now. It won’t be shown again."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s.key}),e.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1.5 transition-colors",onClick:()=>void r(s.key),"aria-label":a?"Couldn’t copy API key. Try again":"Copy API key",children:n?e.jsx(Ke,{className:"text-status-success size-4"}):a?e.jsx(rt,{className:"text-destructive size-4"}):e.jsx(jn,{className:"size-4"})})]}),e.jsx(b,{variant:"outline",size:"sm",onClick:t,children:"Done"})]})}function rl({apiKey:s,revoking:t,onRevoke:n}){const a=s.name||"Unnamed key",r=s.start?`${s.start}…`:s.prefix||"";return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a}),e.jsxs("p",{className:"text-muted-foreground font-mono text-xs",children:[r,s.expiresAt?` · expires ${new Date(s.expiresAt).toLocaleDateString()}`:" · no expiry"]})]}),e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",disabled:t,"aria-label":`Revoke ${a}`,children:e.jsx(ds,{className:"size-3.5"})})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsxs(ne,{children:["Revoke “",a,"”?"]}),e.jsx(ae,{children:"Anything using it loses access right away. This can’t be undone."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:n,children:"Revoke key"})]})]})]})]})}const Kt=["auth","signed-in-devices"];function il(s){if((s==null?void 0:s.status)===404)return"That list was out of date. It’s up to date now.";const t=s instanceof Error?s.message:"";return t&&!/^HTTP \d+$/.test(t)?t:"Couldn’t sign that out. Try again."}function ol(s=!0){const t=U(),n=V(),[a,r]=m.useState(null),[i,o]=m.useState(null),l=Y({queryKey:Kt,queryFn:()=>t.listSignedInDevices(),enabled:s,retry:!1,staleTime:1e4}),c=ge({mutationFn:d=>d(),onMutate:()=>o(null),onError:d=>o(il(d)),onSettled:()=>{r(null),n.invalidateQueries({queryKey:Kt})}});return{data:l.data,isLoading:l.isLoading,isError:l.isError,isFetching:l.isFetching,refetch:()=>void l.refetch(),pendingId:a,signingOutOthers:c.isPending&&a===null,error:i,signOutDevice:d=>{r(d),c.mutate(()=>t.signOutDevice(d))},signOutEverywhereElse:()=>c.mutate(()=>t.signOutEverywhereElse())}}const ll={local:null,wifi:"Wi-Fi",tunnel:"Remote access",managed:"Remote access",network:"Another network",hub:"DorkOS in the cloud"};function cl(){var r,i;const s=ol(),t=((r=s.data)==null?void 0:r.sessions)??[],n=((i=s.data)==null?void 0:i.canSignOutOthers)??!1,a=t.some(o=>!o.current);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ia,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"Signed-in devices"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Signing a device out closes everything it had open."})]}),e.jsx("div",{className:"space-y-1.5",children:s.isLoading?e.jsx(ee,{className:"h-12 w-full"}):s.isError?e.jsx(Xe,{title:"Couldn’t load signed-in devices",description:"Nothing was signed out. Try again.",onRetry:s.refetch,isRetrying:s.isFetching,className:"py-6"}):t.length>0?t.map(o=>e.jsx(dl,{device:o,canSignOut:!o.current&&n,signingOut:s.pendingId===o.id,onSignOut:()=>s.signOutDevice(o.id)},o.id)):e.jsx("p",{className:"text-muted-foreground text-xs",children:"No devices are signed in."})}),a&&!n&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Sign out other devices on the computer DorkOS runs on."}),a&&n&&e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"outline",size:"sm",disabled:s.signingOutOthers,children:s.signingOutOthers?"Signing out…":"Sign out everywhere else"})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Sign out everywhere else?"}),e.jsx(ae,{children:"Every other device must sign in again. This one stays signed in."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:s.signOutEverywhereElse,children:"Sign out everywhere else"})]})]})]}),s.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:s.error})]})}function dl({device:s,canSignOut:t,signingOut:n,onSignOut:a}){const r=ll[s.route],i=`Last active ${ul(we(s.lastSeenAt))}`;return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:s.name}),s.current&&e.jsx(se,{variant:"secondary",children:"This device"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:r?`${r} · ${i}`:i})]}),t&&e.jsxs(b,{variant:"ghost",size:"sm",onClick:a,disabled:n,"aria-label":`Sign out ${s.name}`,children:[e.jsx(yn,{className:"mr-1.5 size-3.5"}),n?"Signing out…":"Sign out"]})]})}function ul(s){return s.replace(/^(Just now|Yesterday)/,t=>t.toLowerCase())}function ml(){var p,f;const s=lt(),{data:t,refetch:n}=Se(),a=ye(),r=Pa(),i=La(),o=((p=t==null?void 0:t.auth)==null?void 0:p.enabled)??!1,l=((f=t==null?void 0:t.auth)==null?void 0:f.ownerEmail)??null,[c,d]=m.useState(null);function u(g){g?d(l?{kind:"sign-in",email:l}:{kind:"create"}):a.mutate({auth:{enabled:!1}})}async function x(){await a.mutateAsync({auth:{enabled:!0}}),d(null)}async function h(g){var j;const{data:y}=await n(),N=((j=y==null?void 0:y.auth)==null?void 0:j.ownerEmail)??g;N&&d({kind:"sign-in",email:N})}return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:s?"You sign in here with your DorkOS account.":"Other devices always need your password. This computer can ask for it too."})}),e.jsx(R,{children:e.jsxs(D,{children:[!s&&e.jsx(_,{label:"Ask for a password on this computer too",description:o?"This computer asks for your password before DorkOS opens.":"This computer opens DorkOS without a password.",children:e.jsx(He,{checked:o,onCheckedChange:u,"aria-label":"Ask for a password on this computer too"})}),r&&e.jsx(_,{label:"Signed in",description:(r==null?void 0:r.email)??"Owner account",children:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>i.run(),disabled:i.isPending,children:[e.jsx(yn,{className:"mr-1.5 size-3.5"}),i.isPending?"Signing out…":"Sign out"]})})]})}),(r||l)&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(cl,{})})}),(o||r)&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(nl,{loginRequired:o})})}),e.jsx(bn,{open:c!==null,onOpenChange:g=>!g&&d(null),children:e.jsx(vn,{children:(c==null?void 0:c.kind)==="sign-in"?e.jsxs(e.Fragment,{children:[e.jsxs(zs,{children:[e.jsx(Us,{children:"Ask for a password here too"}),e.jsx(Ks,{children:"This turns on once your password checks out."})]}),e.jsx(_a,{ownerEmail:c.email,onVerified:x,onCancel:()=>d(null)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(zs,{children:[e.jsx(Us,{children:"Create an owner account"}),e.jsx(Ks,{children:"This becomes your sign-in on every device."})]}),e.jsx($a,{submitLabel:"Create account & ask here too",onCreated:x,onOwnerExists:h,onCancel:()=>d(null)})]})})})]})}function xl(s){const t=U();return Y({queryKey:["relay","trace",s],queryFn:()=>t.getRelayTrace(s),enabled:!!s,staleTime:3e4})}function Nt(){const s=U();return Y({queryKey:["relay","metrics"],queryFn:()=>s.getRelayDeliveryMetrics(),staleTime:3e4,refetchInterval:3e4})}const Bt=["relay","conversations"],hl=500,pl=15e3;function gl(s=!0){const t=U(),n=Fa({coalesceMs:hl}),a=()=>{s&&n([{queryKey:[...Bt]}])};return as("relay_message",a),as("relay_signal",a),as("relay_flow",a),as("relay_dead_letter",a),Y({queryKey:[...Bt],queryFn:()=>t.listRelayConversations(),enabled:s,refetchInterval:pl})}function fl(s,t){var r,i;const n=new Set(t.map(o=>o.providerInstanceId)),a={dorkosAccount:bt(s),byKeyInstance:{}};for(const o of s)o.readiness.state==="gone"||o.mode==="managed"||n.has(o.providerInstanceId)&&((r=a.byKeyInstance)[i=o.providerInstanceId]??(r[i]=[])).push(Gn(o));return a}function Jn({testId:s,name:t,detail:n,status:a,usedForNewApps:r=!1,actions:i,children:o}){return e.jsxs("li",{"data-testid":s,className:"space-y-3 px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 text-sm font-medium",children:[t,r&&e.jsx(se,{size:"xs",variant:"secondary","data-testid":"used-for-new-apps",children:"Used for new apps"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:n})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:L("size-2 rounded-full",Ee[a.tone]),"aria-hidden":!0}),a.label]}),i&&e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:i})]}),o]})}function jl(s){return s==="user"?"using your account key":s==="project"?"using your project key":null}function yl(s,t){return s.registered&&!t?{tone:"warning",label:"Can’t run actions"}:s.registered?{tone:"success",label:"Working"}:s.configured?{tone:"error",label:"Not working"}:{tone:"warning",label:"Key removed"}}function bl(s){return s==="composio"?"Composio project":s==="nango"?"Nango environment":`${Kn(s)} account`}function vl({status:s,apps:t,usedForNewApps:n=!1,way:a}){const r=(a==null?void 0:a.canRunActions)!==!1,[i,o]=m.useState(!1),[l,c]=m.useState(null),d=Zi(),u=Kn(s.type),x=s.configured?jl(s.keyKind):null,h=[`${ps(t.length)} connected`,x].filter(Boolean).join(" · "),{stopping:p,idle:f}=Xn(t),g=()=>{t.length===0||!s.configured?o(!0):c("change")};return e.jsxs(Jn,{testId:`connection-way-${s.type}`,name:Bn(s.type),detail:h,status:yl(s,r),usedForNewApps:n,actions:e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"sm",variant:"outline",onClick:g,disabled:i,children:s.configured?"Change key":"Add key again"}),s.configured&&e.jsx(b,{size:"sm",variant:"ghost",className:"text-destructive",disabled:d.isPending,onClick:()=>c("remove"),children:d.isPending?"Removing…":"Remove…"})]}),children:[s.error&&e.jsx("p",{role:"alert",className:"text-destructive border-destructive/30 bg-destructive/5 rounded-md border px-3 py-2 text-xs leading-relaxed",children:s.error}),s.registered&&!r&&e.jsx("p",{className:"text-muted-foreground text-xs",children:a!=null&&a.keyCanFix?Ft.accountKeyCannotRunActions:Ft.cannotRunActions}),!s.configured&&t.length>0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"These apps stopped when the key was removed. Add it again to restore them."}),i&&e.jsx(eo,{type:s.type,submitLabel:"Save key",onSaved:()=>o(!1),onCancel:()=>o(!1)}),e.jsx(me,{open:l!==null,onOpenChange:y=>{y||c(null)},children:e.jsx(xe,{children:l==="change"?e.jsxs(e.Fragment,{children:[e.jsxs(te,{children:[e.jsxs(ne,{children:["Change your ",u," key?"]}),e.jsx(ae,{children:"A new key pauses these apps until you review their access."})]}),e.jsx(Vs,{stopping:p,idle:f,stopLine:p.length===1?"This app pauses until you review it on the Connections page:":`These ${p.length} apps pause until you review them on the Connections page:`}),e.jsxs("div",{className:"text-muted-foreground space-y-1 text-sm",children:[e.jsx("p",{children:"Nothing changes until you save the new key."}),e.jsx("p",{children:"A key that doesn’t work stops every app until you fix it."}),e.jsxs("p",{children:["A key from a different ",bl(s.type)," can’t reach them at all."]})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Keep this key"}),e.jsx(pe,{onClick:()=>{c(null),o(!0)},children:"Continue to a new key"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(te,{children:[e.jsxs(ne,{children:["Remove your ",u," key?"]}),e.jsx(ae,{children:t.length===0?"No apps use this key right now.":"Your sign-ins are kept. Add the same key again to restore these apps."})]}),e.jsx(Vs,{stopping:p,idle:f,stopLine:`${p.length===1?"This app":`These ${p.length} apps`} will stop working for every agent:`}),e.jsxs(re,{children:[e.jsx(ie,{children:"Keep key"}),e.jsx(pe,{onClick:()=>d.mutate({provider:s.type}),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:p.length>0?`Remove key and stop ${ps(p.length)}`:"Remove key"})]})]})})})]})}function Nl({onManageAccount:s,onOpenConnectionsPage:t}){var E,A,T,O;const n=U(),a=Y({queryKey:za,queryFn:()=>n.getCloudStatus(),staleTime:3e4}),r=so(),i=to(),o=jt();if(r.isPending||o.isPending)return e.jsxs("div",{className:"space-y-2","aria-label":"Loading how DorkOS reaches your apps",children:[e.jsx(ee,{className:"h-16 rounded-lg"}),e.jsx(ee,{className:"h-16 rounded-lg"})]});if(r.isError||o.isError)return e.jsx(Xe,{title:"Couldn’t check how DorkOS reaches your apps",description:"Try again. Nothing was changed.",onRetry:()=>{r.isError&&r.refetch(),o.isError&&o.refetch()},isRetrying:r.isFetching||o.isFetching});const l=r.data,c=fl(o.data.connections,l),d=((E=a.data)==null?void 0:E.linked)===!0,u=d||a.isError||c.dorkosAccount.length>0,x=l.filter(v=>{var k;return v.configured||(((k=c.byKeyInstance[v.providerInstanceId])==null?void 0:k.length)??0)>0}),h=l.filter(v=>!x.includes(v)),p=a.isSuccess&&!u,f=!u&&x.length===0;if(f&&a.isPending)return e.jsx(ee,{className:"h-16 rounded-lg","aria-label":"Checking your DorkOS account"});const g=((A=i.data)==null?void 0:A.newApps.status)==="ready"?i.data.newApps.way:null,y=((T=i.data)==null?void 0:T.ways)??[],N=((O=y.find(v=>v.kind==="dorkos_account"))==null?void 0:O.status)!=="unavailable",j=(u?1:0)+x.length>1,C=e.jsx(Cl,{keys:h,offerAccount:p,onManageAccount:s});return f?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted/40 space-y-3 rounded-lg p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Set up with your first app"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect an app and DorkOS asks how to reach it. You answer once."})]}),e.jsx(b,{size:"sm",variant:"outline",onClick:t,children:"Open the Connections page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Or set one up here now:"}),C]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("ul",{className:"divide-border divide-y rounded-lg border",children:[u&&e.jsx(kl,{linked:d,reachesApps:N,checkFailed:a.isError,retrying:a.isFetching,onRetry:()=>void a.refetch(),apps:c.dorkosAccount,usedForNewApps:j&&(g==null?void 0:g.kind)==="dorkos_account",onManageAccount:s}),x.map(v=>e.jsx(vl,{status:v,apps:c.byKeyInstance[v.providerInstanceId]??[],usedForNewApps:j&&(g==null?void 0:g.kind)==="own_key"&&g.type===v.type,way:y.find(k=>k.kind==="own_key"&&k.type===v.type)},v.providerInstanceId))]}),(h.length>0||p)&&e.jsx(wl,{label:"Add another way",children:C})]})}function kl({linked:s,reachesApps:t,checkFailed:n,retrying:a,onRetry:r,apps:i,usedForNewApps:o,onManageAccount:l}){const c=s?t?{tone:"success",label:"Working"}:{tone:"warning",label:"Can’t reach apps"}:n?{tone:"neutral",label:"Couldn’t check"}:{tone:"warning",label:"Not linked"};return e.jsxs(Jn,{testId:"connection-way-dorkos-account",name:"Your DorkOS account",detail:n&&i.length===0?"Couldn’t check your DorkOS account":`${ps(i.length)} connected`,status:c,usedForNewApps:o,actions:e.jsxs(e.Fragment,{children:[n&&e.jsx(b,{size:"sm",variant:"outline",onClick:r,disabled:a,children:a?"Checking…":"Try again"}),e.jsxs(b,{size:"sm",variant:"outline",onClick:l,children:["Manage account",e.jsx(Be,{className:"size-3.5","aria-hidden":!0})]})]}),children:[s&&!t&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Linked, but can’t reach apps now. Its apps won’t work until then."}),!s&&!n&&i.length>0&&e.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-xs",children:[e.jsx("p",{children:"These apps stopped when the account was unlinked."}),e.jsx("p",{children:"Linking the same DorkOS account again can restore them. Otherwise, reconnect them."})]})]})}function wl({label:s,children:t}){return e.jsxs(Ye,{children:[e.jsxs(Ve,{className:"text-muted-foreground hover:text-foreground focus-ring flex items-center gap-1.5 rounded-md text-sm font-medium",children:[e.jsx(Ma,{className:"size-4","aria-hidden":!0}),s]}),e.jsx(Qe,{className:"pt-3",children:t})]})}function Cl({keys:s,offerAccount:t,onManageAccount:n}){return s.length===0&&!t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Every way is set up."}):e.jsxs("ul",{className:"divide-border divide-y rounded-lg border",children:[t&&e.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-48",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your DorkOS account"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Link this computer, then connect apps."})]}),e.jsxs(b,{size:"sm",variant:"outline",onClick:n,children:["Link account",e.jsx(Be,{className:"size-3.5","aria-hidden":!0})]})]}),s.map(a=>e.jsxs("li",{"data-testid":`add-connection-way-${a.type}`,className:"space-y-2 px-4 py-3",children:[e.jsx("p",{className:"text-sm font-medium",children:Bn(a.type)}),e.jsx(no,{status:a})]},a.providerInstanceId))]})}const Sl=3,Al=3e5,Wt={min:1,max:20},qt={min:10,max:3600},Ht=1e3;function Tl(){const s=Ji();return s.isLoading?e.jsx(ee,{className:"h-40 rounded-lg","aria-label":"Loading chat app settings"}):s.isError?e.jsx(Xe,{title:"Couldn’t check chat apps",description:"Check that DorkOS is running, then try again.",onRetry:s.retry,isRetrying:s.isRetrying}):s.enabled?e.jsx(El,{}):e.jsx(io,{relay:s,variant:"block"})}function El(){var o,l,c;const s=Wn(!0),{mutate:t}=Ua(),{mutate:n}=ro();if(s.isPending)return e.jsx(ee,{className:"h-40 rounded-lg","aria-label":"Loading chat app settings"});if(s.isError)return e.jsx(Xe,{title:"Couldn’t load chat app settings",description:"Try again. Nothing was changed.",onRetry:()=>void s.refetch(),isRetrying:s.isFetching});const a=(o=s.data.find(d=>d.manifest.category==="internal"&&d.manifest.type==="claude-code"))==null?void 0:o.instances[0];if(!a)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing to set. Chat messages can’t start agents here."});const r=Number(((l=a.config)==null?void 0:l.maxConcurrent)??Sl),i=Number(((c=a.config)==null?void 0:c.defaultTimeoutMs)??Al);return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Start working right away",description:"New messages start the agent at once.",checked:a.enabled,onCheckedChange:d=>t({id:a.id,enabled:d})}),e.jsx(_,{label:"Most chats at once",description:"More wait their turn.",children:e.jsx(xs,{"aria-label":"Most chats at once",value:r,min:Wt.min,max:Wt.max,onCommit:d=>n({id:a.id,config:{maxConcurrent:d}})})}),e.jsx(_,{label:"Give up after",description:"Seconds a message waits before it’s turned away.",children:e.jsx(xs,{"aria-label":"Give up after, in seconds",value:Math.round(i/Ht),min:qt.min,max:qt.max,onCommit:d=>n({id:a.id,config:{defaultTimeoutMs:d*Ht}})})})]})})}function Ol(s,t=()=>null,n={}){return s?[...new Set([...Object.keys(s.runtimes),...Object.keys(s.defaults??{})])].flatMap(r=>{var c,d,u,x,h,p;const i=(c=s.defaults)==null?void 0:c[r],o=(i==null?void 0:i.runsOn)==="credits",l=s.enabled&&s.runtimes[r]==="wired";return!l&&!o?[]:[{runtime:r,name:je(r).label,on:o,chosenBy:o?(i==null?void 0:i.chosenBy)??null:null,canTurnOn:l,canTurnOff:!0,unreachable:!l,previousSignIn:t(r),scope:(u=(d=n[r])==null?void 0:d.credits)==null?void 0:u.scope,caveat:(h=(x=n[r])==null?void 0:x.credits)==null?void 0:h.caveat,hasAccountPicks:((p=n[r])==null?void 0:p.supportsAccounts)===!0}]}):[]}function Rl(s){return!s||s.killed?[]:Object.entries(s.runtimes).filter(([,t])=>t==="wired").map(([t])=>je(t).label)}function Zn(){const{data:s}=ys(),t=bs(),{data:n}=Ge(),{accounts:a,ownResolvedAccount:r,nameFor:i}=vs(),o=Ol(s,d=>d==="claude-code"&&r?Dl(r,a,i):null,n==null?void 0:n.capabilities),l=(d,u)=>{const x=o.find(h=>h.runtime===d);x===void 0||x.on===u||(u?!x.canTurnOn:!x.canTurnOff)||t.mutate({runtime:d,useCredits:u})},c=t.isError?`Couldn’t change that. ${ea(t.error)}`:null;return{rows:o,pending:t.isPending,failure:c,setOn:l}}function Dl(s,t,n){const a=t.find(i=>i.path===s);if(a)return a.label;const r=n(s);return r===Ka(s,[])?null:r}const Il="Try again in a moment.";function ea(s){return Nn(s)??Il}function Pl(){var c;const{rows:s}=Zn(),t=jt(),n=$i(!0),a=ct(),r=s.filter(d=>d.on).map(d=>d.name),i=t.data?bt(t.data.connections):[],o=a&&((c=n.data)!=null&&c.available)?n.data.communities:[],l=r.length===0&&i.length===0&&o.length===0;return e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"What’s on your account"}),l?e.jsx("p",{className:"text-muted-foreground text-sm",children:a?"Nothing uses this account yet. Agents on credits, connected apps and spaces show here.":"Nothing uses this account yet. Agents on credits and connected apps show here."}):e.jsxs("dl",{className:"space-y-3 text-sm",children:[r.length>0&&e.jsx(Rs,{label:"Running on credits",items:r}),i.length>0&&e.jsx(Rs,{label:"Connected apps",items:i.map(d=>d.name)}),o.length>0&&e.jsx(Rs,{label:"Spaces",items:o.map(d=>d.name)})]})]})})}function Rs({label:s,items:t}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:s}),e.jsx("dd",{className:"font-medium",children:t.join(", ")})]})}function Ll(){const s=Ba(n=>n.sessions),{data:t}=Ge();return m.useMemo(()=>{var i;let n=0,a=0;for(const o of Object.values(s)){const l=(i=o.sessionStatus)==null?void 0:i.costUsd;typeof l=="number"&&l>0&&(n+=l,a+=1)}const r=Object.entries((t==null?void 0:t.capabilities)??{}).filter(([,o])=>o.supportsCostTracking===!1).map(([o])=>o).sort();return{totalUsd:n,sessionCount:a,runtimesWithoutCost:r,hasAnything:a>0||r.length>0}},[s,t])}function _l(s,t,n){return s===0&&BigInt(n)>0n?`<0.001 ${t}`:`${s.toLocaleString("en-US",{maximumFractionDigits:3})} ${t}`}const Yt=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:"UTC"}),Vt=1440*60*1e3;function $l(s,t){const n=new Date(t),a=n.getTime()%Vt===0?new Date(n.getTime()-Vt):n;return`${Yt.format(new Date(s))} – ${Yt.format(a)}`}function gs(){return e.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t read the credit figures from your DorkOS account."})}function Fl({otherCharges:s,denomination:t}){const n=(s==null?void 0:s.rows)??[];if(n.length===0)return null;const a=hs(t);return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Other charges"}),!a&&e.jsx(gs,{}),e.jsx("ul",{className:"space-y-2 text-sm",children:n.map((r,i)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:r.displayName}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[_l(r.units,r.unit,r.dorkosPriceMicro)," ·"," ",e.jsx("span",{className:"whitespace-nowrap",children:$l(r.periodStart,r.periodEnd)})]})]}),a&&e.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:ls(r.dorkosPriceMicro,t)})]},`${i}-${r.periodStart}-${r.unit}`))})]})}function Ml(){const{data:s}=ze(),{data:t}=Wa("seat"),n=Ll();if(!(s!=null&&s.available))return null;const a=s.balance,r=a===null?null:Fi(a.allowance.remainingMicro,a.allowance.grantedMicro),i=a==null?void 0:a.denomination,o=_t(a==null?void 0:a.allowance.remainingMicro,i),l=Es(_t(a==null?void 0:a.allowance.grantedMicro,i)),c=gt(a==null?void 0:a.purchased.remainingMicro,i,"position"),d=ls(a==null?void 0:a.owedMicro,i),u=d===null||d==="0"?null:Es(d),x=a?zl(a.allowance.resetsAt):null,h=t!=null&&t.available?t.usage.rows:[],p=t!=null&&t.available?t.usage.denomination:void 0,f=hs(p),g=t!=null&&t.available?Es(ls(t.usage.totals.dorkosPriceMicro,p)):null,y=t!=null&&t.available?t.usage.otherCharges:void 0;return e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Credits"}),a!==null&&(hs(i)?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-3 text-sm",children:[o!==null&&l!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Included"}),e.jsxs("dd",{className:"font-medium",children:[o," of ",l," left"]})]}),c!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Added"}),e.jsx("dd",{className:"font-medium",children:c})]}),u!==null&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:"Owed"}),e.jsx("dd",{className:"font-medium",children:u})]})]}),r!==null&&e.jsx(Do,{value:r*100,"aria-label":"Included left"}),x!==null&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Included credits renew ",x,"."]})]}):e.jsx(gs,{})),h.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where the credits went"}),!f&&e.jsx(gs,{}),e.jsx("ul",{className:"space-y-1 text-sm",children:h.map(N=>e.jsxs("li",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("span",{className:"truncate",children:N.displayName}),f&&e.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:ls(N.dorkosPriceMicro,p)})]},N.key))}),g!==null&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Total for the last 30 days: ",g]})]}),e.jsx(Fl,{otherCharges:y,denomination:p}),n.hasAnything&&e.jsxs("div",{className:"space-y-1 border-t pt-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"On this machine"}),n.sessionCount>0&&e.jsxs("p",{className:"text-sm",children:[n.totalUsd.toFixed(2)," across ",n.sessionCount," ",n.sessionCount===1?"open chat":"open chats",", by their own estimate."]}),n.runtimesWithoutCost.length>0&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[n.runtimesWithoutCost.join(", ")," report no cost, so they’re left out."]})]})]})})}function zl(s){const t=new Date(s);return Number.isNaN(t.getTime())?null:`on ${t.toLocaleDateString(void 0,{day:"numeric",month:"short"})}`}const Ul=6e4,Kl=2**31-1;function Bl(){const s=U(),[t,n]=m.useState(null),[a,r]=m.useState({kind:"idle"}),[i,o]=m.useState(null),l=m.useRef(!1),c=m.useCallback(async()=>{if(l.current)return!1;l.current=!0,r({kind:"requesting"});try{const x=await s.requestCloudAccountDeletion();return x.ok?(n(x.deletion),r({kind:"idle"}),!0):(r({kind:"failed",notice:"problem"in x?{problem:x.problem}:{message:x.message}}),!1)}catch{return r({kind:"failed",notice:qa}),!1}finally{l.current=!1}},[s]),d=m.useCallback(()=>{l.current||r({kind:"idle"})},[]);m.useEffect(()=>{if(t===null||t.confirmBy===null)return;const x=Date.parse(t.confirmBy)-Date.now();if(Number.isNaN(x)||x>Kl)return;const h=setTimeout(()=>o(t),Math.max(0,x));return()=>clearTimeout(h)},[t]);const u=t!==null&&i===t;return Wl(t!==null&&!u),{sent:t,expired:u,attempt:a,request:c,reset:d}}function Wl(s){const t=V(),n=Ha();m.useEffect(()=>{if(!s)return;let a=!1,r=!1;const i=async()=>{if(a||r)return;r=!0;let d=null;try{d=await n({expected:!0})}catch{}finally{r=!1}a||d===null||d.linked||(a=!0,c(),t.invalidateQueries({queryKey:Ya.all}),_e.success("This computer is unlinked",{description:"The deletion is confirmed. Everything on this computer stays."}))},o=()=>void i();window.addEventListener("focus",o);const l=setInterval(()=>void i(),Ul);function c(){window.removeEventListener("focus",o),clearInterval(l)}return()=>{a=!0,c()}},[s,n,t])}function sa({heading:s="Your data"}){const{data:t}=ze(),{state:n,request:a,download:r}=Va();return t!=null&&t.available?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:s}),n.kind==="requested"?n.export.downloadUrl!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm",children:"Your export is ready."}),e.jsxs(b,{type:"button",size:"sm",variant:"outline",onClick:r,children:["Download your data",e.jsx(Ns,{className:"size-3.5","aria-hidden":!0})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{role:"status",className:"text-sm",children:n.export.emailRequested?"Your export is being prepared. You’ll get an email when it’s ready.":"Your export is being prepared. Check back in a few minutes."}),e.jsx(b,{type:"button",size:"sm",variant:"outline",onClick:a,children:"Check again"})]}):e.jsx(b,{type:"button",size:"sm",variant:"outline",disabled:n.kind==="requesting","aria-busy":n.kind==="requesting",onClick:a,children:n.kind==="requesting"?"Asking…":"Export your account data"}),n.kind==="failed"&&e.jsx(us,{notice:n.notice})]}):null}const Ds="delete";function ql(s){const t=new Date(s);return Number.isNaN(t.getTime())?null:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function Hl(){const{data:s}=ze(),{sent:t,expired:n,attempt:a,request:r,reset:i}=Bl(),[o,l]=m.useState(!1),[c,d]=m.useState(""),u=m.useRef(null),x=m.useRef(null),h=m.useRef(null);if(!(s!=null&&s.available))return null;const p=c.trim().toLowerCase()===Ds,f=a.kind==="requesting",g=a.kind==="failed"?a.notice:null,y=j=>{f||(l(j),j||(d(""),i()))},N=()=>{!p||f||r().then(j=>{j&&(l(!1),d(""))})};return e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Delete your DorkOS account"}),t!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{ref:x,role:"status",tabIndex:-1,className:"text-sm outline-none",children:n?"The link has expired, so nothing was deleted. Send a new one to carry on.":e.jsx(Yl,{sentTo:t.confirmationSentTo,confirmBy:t.confirmBy})}),e.jsx(b,{type:"button",size:"sm",variant:"outline",disabled:f,"aria-busy":f,onClick:()=>void r(),children:f?"Sending…":"Send a new link"}),g!==null&&e.jsx(us,{notice:g})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Ends your plan and erases the account for good. Everything on this computer stays."}),e.jsx(b,{ref:h,type:"button",size:"sm",variant:"destructive",onClick:()=>l(!0),children:"Delete your DorkOS account…"})]}),e.jsx(et,{open:o,onOpenChange:y,children:e.jsxs(st,{className:"min-h-0 sm:max-w-md",onOpenAutoFocus:j=>{var C;j.preventDefault(),(C=u.current)==null||C.focus()},onCloseAutoFocus:j=>{const C=x.current??h.current;C!==null&&(j.preventDefault(),C.focus())},children:[e.jsxs(kn,{children:[e.jsx(tt,{children:"Delete your DorkOS account?"}),e.jsx(nt,{children:"This can’t be undone. Nothing is deleted until you follow the emailed link."})]}),e.jsx(wn,{children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"What goes"}),e.jsxs("ul",{className:"text-muted-foreground list-inside list-disc space-y-1",children:[e.jsx("li",{children:"Your plan, which ends right away"}),e.jsx("li",{children:"Credits you haven’t used"}),e.jsx("li",{children:"The seats on your account"}),e.jsx("li",{children:"Everything else your DorkOS account holds"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"What stays"}),e.jsx("p",{className:"text-muted-foreground",children:"Everything on this computer: your agents, chats, projects and files."}),e.jsx("p",{className:"text-muted-foreground",children:"This computer unlinks and keeps working on its own."})]}),e.jsx(sa,{heading:"Want a copy first?"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:"delete-account-confirm",className:"font-medium",children:["Type ",e.jsx("strong",{children:Ds})," to confirm"]}),e.jsx(J,{ref:u,id:"delete-account-confirm","data-testid":"delete-account-confirm-input",value:c,onChange:j=>d(j.target.value),onKeyDown:j=>{j.key==="Enter"&&N()},placeholder:Ds,autoComplete:"off",disabled:f})]}),g!==null&&e.jsx(us,{notice:g})]})}),e.jsxs(Cn,{children:[e.jsx(Qa,{asChild:!0,children:e.jsx(b,{variant:"outline",disabled:f,children:"Cancel"})}),e.jsx(b,{variant:"destructive",disabled:!p||f,"aria-busy":f,onClick:N,children:f?"Sending…":"Email me the link"})]})]})})]})}function Yl({sentTo:s,confirmBy:t}){const n=t===null?null:ql(t);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"block",children:["Check your email. A link went to ",e.jsx("span",{className:"font-medium",children:s}),"."]})," ",e.jsxs("span",{className:"block",children:["Your account is deleted only when you follow it",n===null?".":`, and the link works until ${n}.`]})," ",e.jsx("span",{className:"block",children:"This computer then unlinks on its own."})]})}const Vl={month:"a month",year:"a year"};function Ql(){const{data:s}=ze(),t=Ga();return s!=null&&s.available?e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Manage on the web"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Payments happen on the DorkOS website. Each of these opens in your browser."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Qs,{billing:t,page:"portal",children:"Billing and invoices"}),e.jsx(Qs,{billing:t,page:"topup",children:"Add credits"})]}),e.jsx(Gl,{billing:t,currentPlanId:s.entitlements.planId}),e.jsx(us,{notice:t.notice}),e.jsx(sa,{}),e.jsx(Hl,{})]})}):null}function Qs({billing:s,page:t,children:n}){var r;const a=((r=s.pending)==null?void 0:r.page)===t;return e.jsxs(b,{type:"button",size:"sm",variant:"outline",disabled:s.pending!==null,"aria-busy":a,onClick:()=>s.open({page:t}),children:[a?"Opening…":n,e.jsx(Ns,{className:"size-3.5","aria-hidden":!0})]})}function Gl({billing:s,currentPlanId:t}){const{data:n}=Xa();if(!(n!=null&&n.available)||n.offers.offers.length===0)return null;const{offers:a,denomination:r}=n.offers;return a.some(i=>i.planId===t)?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Change plan"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Switch to another plan, or end yours, on the billing page."}),e.jsx(Qs,{billing:s,page:"portal",children:"Change plan"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Choose a plan"}),e.jsx("ul",{className:"divide-y rounded-md border",children:a.map(i=>{var d;const o=r?Hs(i.amountMicro,r):null,l=Vl[i.interval],c=((d=s.pending)==null?void 0:d.skuId)===i.skuId;return e.jsxs("li",{className:"flex items-center justify-between gap-3 px-3 py-2 text-sm",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium",children:i.displayName}),o!==null&&e.jsx("p",{className:"text-muted-foreground text-xs",children:l?`${o} ${l}`:o})]}),e.jsxs(b,{type:"button",size:"sm",variant:"outline",disabled:s.pending!==null,"aria-busy":c,"aria-label":`Choose ${i.displayName}${l?`, billed ${l}`:""}`,onClick:()=>s.open({page:"checkout",skuId:i.skuId}),children:[c?"Opening…":"Choose",e.jsx(Ns,{className:"size-3.5","aria-hidden":!0})]})]},i.skuId)})})]})}const Xl={byo:"Bring your own tunnel",on_demand:"Reachable when you open it",always_available:"Always reachable"},Jl={none:"Not available",addon:"Available separately",included:"Included"},Zl={community:"Community",priority:"Priority"};function ec(){const{data:s}=ze(),t=ct();if(!(s!=null&&s.available))return null;const{entitlements:n}=s,{limits:a,seats:r}=n,i=n.denomination,o=gt(a.includedCreditsMicro,i,"position"),l=!hs(i);return e.jsx(R,{children:e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Your plan"}),e.jsx("p",{className:"text-base font-semibold",children:n.planDisplayName})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-3 text-sm sm:grid-cols-3",children:[e.jsx(Ne,{label:"People",value:`${n.used.personSeats} of ${a.personSeatsIncluded}`}),e.jsx(Ne,{label:"Agents with an address",value:`${n.used.agentSeats} of ${a.agentSeatsIncluded}`}),e.jsx(Ne,{label:"Seats assigned",value:`${r.assigned} of ${r.total}`}),o!==null&&e.jsx(Ne,{label:"Included credits",value:o}),e.jsx(Ne,{label:"Cloud hours",value:`${a.cloudHours}`}),e.jsx(Ne,{label:"Storage",value:`${a.storageGb} GB`}),e.jsx(Ne,{label:"Remote access",value:Xl[a.remoteAccess]}),e.jsx(Ne,{label:"Custom address",value:Jl[a.customAddress]}),e.jsx(Ne,{label:"Support",value:Zl[a.support]})]}),l&&e.jsx(gs,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Only agents with an address take a seat. Local-only agents take none."}),e.jsx(Mn,{withSpaces:t})]})]})})}function Ne({label:s,value:t}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs",children:s}),e.jsx("dd",{className:"font-medium",children:t})]})}function sc(){const{data:s}=Ja(),[t,n]=m.useState(null),a=s!=null&&s.available?s.orgs:[];m.useEffect(()=>{t===null&&a.length>0&&n(a[0].id)},[t,a]);const{data:r,isLoading:i,isError:o}=Za(t),{data:l}=er(t),{assign:c,release:d}=sr(t),[u,x]=m.useState(null),[h,p]=m.useState(null);if(!(s!=null&&s.available))return null;if(i&&!r)return e.jsx(ee,{className:"h-24 w-full"});if(o)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t load your seats. Try again later."});if(!(r!=null&&r.available)||r.seats.length===0&&a.length<=1)return null;const f=l!=null&&l.available?l.members:[],g=j=>{x(null),p(null),!j.ok&&("problem"in j?x(j.problem):p(j.message))},y=async j=>{try{g(await d.mutateAsync(j))}catch{x(null),p("Couldn’t reach your account just now. Nothing changed.")}},N=async(j,C)=>{try{g(await c.mutateAsync({seatId:j,subject:{kind:"user",id:C}}))}catch{x(null),p("Couldn’t reach your account just now. Nothing changed.")}};return e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Seats"}),a.length>1&&e.jsx("select",{className:"border-input bg-background rounded-md border px-2 py-1 text-sm","aria-label":"Organization",value:t??"",onChange:j=>n(j.target.value),children:a.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))})]}),r.seats.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"No seats in this organization."}):e.jsx("ul",{className:"divide-y",children:r.seats.map(j=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:nc(j)}),e.jsx("p",{className:"text-muted-foreground text-xs",children:j.assignedAt?`Assigned ${we(j.assignedAt)}`:"Not assigned"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(se,{variant:"secondary",children:j.status}),j.status==="assigned"?e.jsx(b,{variant:"outline",size:"sm",disabled:d.isPending,onClick:()=>void y(j.id),children:"Release"}):f.length>0&&e.jsxs("select",{className:"border-input bg-background rounded-md border px-2 py-1 text-sm","aria-label":"Assign this seat to",defaultValue:"",disabled:c.isPending,onChange:C=>{const E=C.target.value;E!==""&&N(j.id,E)},children:[e.jsx("option",{value:"",children:"Assign to…"}),f.map(C=>e.jsx("option",{value:C.userId,children:tc(C,f)},C.id))]})]})]},j.id))}),u!==null&&e.jsxs("div",{className:"border-destructive/40 bg-destructive/5 space-y-1 rounded-md border px-3 py-2",children:[e.jsx("p",{className:"text-sm font-medium",children:u.title}),u.detail!==void 0&&e.jsx("p",{className:"text-sm",children:u.detail}),u.requiredPlanDisplayName!==void 0&&e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This needs ",u.requiredPlanDisplayName,"."]})]}),h!==null&&e.jsx("div",{className:"border-destructive/40 bg-destructive/5 rounded-md border px-3 py-2",children:e.jsx("p",{className:"text-sm",children:h})})]})})}function tc(s,t){return t.filter(a=>a.role===s.role).length===1?s.role:`${s.role} · ${s.userId}`}function nc(s){return s.address!==null?s.address.canonical:s.kind==="person"?"Person":"Agent"}function ac(){const{data:s}=tr(),[t,n]=m.useState(!1);if(t||!(s!=null&&s.available))return null;const{nudge:a}=s,r=a.denomination,i=gt(a.trailing30Micro,r,"charge"),o=Hs(a.suggestedPlanPriceMicro,r),l=Hs(a.savingMicro,r);return l===null||i===null||o===null?null:e.jsxs("div",{className:"bg-muted/50 flex items-start justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("p",{className:"text-sm",children:["Your last 30 days: ",i,". ",a.suggestedPlanDisplayName,": ",o,". Difference: ",l,"."]}),a.dismissible&&e.jsx(b,{variant:"ghost",size:"icon-sm",className:"size-6 shrink-0","aria-label":"Dismiss",onClick:()=>n(!0),children:e.jsx(rt,{className:"size-4"})})]})}function ta(s){return je(s).label}function rc(s){const t=s.map(ta);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function ic(){const{data:s}=ys(),t=(s==null?void 0:s.notices)??[];return t.length===0?null:e.jsx("div",{className:"space-y-2","data-testid":"credits-notices",children:t.map(n=>e.jsx(oc,{notice:n},n.kind==="signed-in"?`signed-in:${n.runtime}`:n.kind))})}function oc({notice:s}){const t=nr(),n=ar(s.kind==="filled"?s.runtimes:[]),a=rr(),r=bs(),i=fe(),o=t.isPending||a.isPending||r.isPending,l=[r,a,t].find(u=>u.isError),c=l?e.jsxs("p",{role:"alert",className:"text-destructive text-sm",children:["Couldn’t change that. ",ea(l.error)]}):null;if(s.kind==="filled"){const u=rc(s.runtimes);return e.jsxs(Ts,{className:"space-y-2","data-testid":"credits-notice-filled",children:[e.jsxs("p",{className:"text-sm",children:[u," now ",s.runtimes.length===1?"runs":"run"," on your DorkOS credits."]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.runtimes.length===1?"It":"They"," had no working sign-in when you linked."]}),n.map(x=>e.jsx("p",{className:"text-muted-foreground text-sm",children:x},x)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{size:"sm",variant:"outline",disabled:o,onClick:()=>{t.mutate({kind:"filled"}),i.open("runtimes")},children:"Change"}),e.jsx(b,{size:"sm",variant:"outline",disabled:o,onClick:()=>a.mutate(),children:"Undo all"}),e.jsx(b,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"filled"}),children:"OK"})]}),c]})}if(s.kind==="offer")return e.jsxs(Ts,{className:"space-y-2","data-testid":"credits-notice-offer",children:[e.jsx("p",{className:"text-sm",children:"Your DorkOS account can pay for Claude Code. Nothing changes until you turn it on."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{size:"sm",disabled:o,onClick:()=>r.mutate({runtime:"claude-code",useCredits:!0}),children:"Use DorkOS credits"}),e.jsx(b,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"offer"}),children:"Not now"})]}),c]});const d=ta(s.runtime);return e.jsxs(Ts,{className:"space-y-2","data-testid":"credits-notice-signed-in",children:[e.jsxs("p",{className:"text-sm",children:["You’re signed in to ",d," now. It still uses your credits until you switch back."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(b,{size:"sm",variant:"outline",disabled:o,onClick:()=>r.mutate({runtime:s.runtime,useCredits:!1}),children:["Use my ",d," sign-in"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:o,onClick:()=>t.mutate({kind:"signed-in",runtime:s.runtime}),children:"Keep credits"})]}),c]})}function lc(){const{rows:s,pending:t,failure:n,setOn:a}=Zn();return s.length===0?null:e.jsx(R,{children:e.jsxs(D,{className:"space-y-3",children:[e.jsx("p",{className:"text-muted-foreground text-xs tracking-wide uppercase",children:"Use credits for"}),e.jsx(ic,{}),s.map(r=>e.jsx(_,{label:r.name,description:cc(r),children:e.jsx(He,{checked:r.on,disabled:t||(r.on?!r.canTurnOff:!r.canTurnOn),onCheckedChange:i=>a(r.runtime,i),"aria-label":`Use credits for ${r.name}`})},r.runtime)),n!==null&&e.jsx("p",{className:"text-destructive text-sm",role:"alert",children:n})]})})}function cc(s){const t=dc(s);return s.caveat?`${t} ${s.caveat}`:t}function dc(s){if(s.on&&s.unreachable)return`${s.name} can’t run on credits now, so new work stops. Turn this off to continue.`;if(!s.on)return s.previousSignIn===null?`New ${s.name} work uses its own sign-in.`:`New ${s.name} work uses ${s.previousSignIn}.`;const t=s.previousSignIn===null?"Turning this off puts it back on its own sign-in.":`Turning this off puts it back on ${s.previousSignIn}.`;return s.chosenBy==="default"?`DorkOS turned this on when you linked, because ${s.name} had no sign-in. ${t}`:s.scope==="runtime"?`${s.name} runs on your DorkOS credits, chats already going included. ${t} It can't be switched while ${s.name} is in the middle of a reply.`:s.hasAccountPicks?`New ${s.name} work runs on your DorkOS credits unless an agent or a chat picks another account. ${t}`:`New ${s.name} chats run on your DorkOS credits. ${t}`}function uc(){const{data:s,isError:t,isPending:n}=ze();return n?e.jsx(ee,{className:"h-40 w-full"}):t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t reach your DorkOS account. Local agents still work."}):e.jsxs("div",{className:"space-y-4",children:[s.available?e.jsxs(e.Fragment,{children:[e.jsx(ac,{}),e.jsx(ec,{}),e.jsx(Ml,{})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"No plan details to show yet."}),e.jsx(lc,{}),e.jsx(Pl,{}),e.jsx(sc,{}),e.jsx(Ql,{})]})}function mc(s){if(s<60)return`${s} minutes`;const t=Math.round(s/60);return t<48?t===1?"an hour":`${t} hours`:`${Math.round(t/24)} days`}function xc(){const{enabled:s,absenceThresholdMinutes:t,offersEnabled:n,setEnabled:a,setOffersEnabled:r,isAvailable:i}=Bo();return i?e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Coming back"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Welcome-back notes",description:e.jsxs(e.Fragment,{children:[`Agents may leave a short note in your team channel after ${mc(t)} away.`," ",e.jsxs(qe,{label:"About welcome-back notes",children:[e.jsx("p",{children:"Off means no note, and no agent time spent checking."}),e.jsx("p",{children:"This setting follows you to every device."})]})]}),checked:s,onCheckedChange:a}),s&&e.jsx($,{label:"Next-step offers",description:"Notes can end with a decision for you. Each runs that agent for a turn.",checked:n,onCheckedChange:r})]})})]}):null}function hc(){var s;return typeof window>"u"||(s=window.electronAPI)==null?void 0:s.tabSession}function pc(){const s=hc(),[t,n]=m.useState(null);if(m.useEffect(()=>{if(!s)return;let r=!0;return s.getStartupMode().then(i=>{r&&n(i)}),()=>{r=!1}},[s]),!s||t===null)return null;const a=r=>{r!=="reopen"&&r!=="fresh"||(n(r),s.setStartupMode(r).then(i=>{i&&n(i)}))};return e.jsx(_,{label:"When DorkOS opens",description:"After a quit. Updates and crashes always bring your tabs back.",children:e.jsxs(oe,{value:t,onValueChange:a,children:[e.jsx(le,{className:"w-40","aria-label":"When DorkOS opens",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"reopen",children:"Reopen your tabs"}),e.jsx(P,{value:"fresh",children:"Start fresh"})]})]})})}function gc(){const{showTimestamps:s,setShowTimestamps:t,expandToolCalls:n,setExpandToolCalls:a,autoHideToolCalls:r,setAutoHideToolCalls:i,showTaskCelebrations:o,setShowTaskCelebrations:l,promoEnabled:c,setPromoEnabled:d,enableMessagePolling:u,setEnableMessagePolling:x,setOnboardingHiddenForSession:h}=Oe(),p=Ri(),{setRichText:f}=Di(),{close:g}=fe(),y=ye(),N=V(),j=()=>{y.mutate({onboarding:{completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null,completedAt:null}},{onSuccess:()=>{N.invalidateQueries({queryKey:G.all})}}),h(!1),g()};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Chat"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Show timestamps",description:"Shows the time on each message.",checked:s,onCheckedChange:t}),e.jsx($,{label:"Expand tool calls",description:"Opens tool call details in messages.",checked:n,onCheckedChange:a}),e.jsx($,{label:"Auto-hide tool calls",description:"Finished tool calls fade after a moment.",checked:r,onCheckedChange:i}),e.jsx($,{label:"To-do celebrations",description:"Animates finished to-dos.",checked:o,onCheckedChange:l}),e.jsx($,{label:"Format text as you type",description:"Bold, headings and lists show as you write.",checked:p,onCheckedChange:f}),e.jsx($,{label:"Watch for work started elsewhere",description:"Work started in a terminal shows up here sooner.",checked:u,onCheckedChange:x})]})})]}),dt()&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Tabs"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx(pc,{})})})]}),e.jsx(xc,{}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Discovery"}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Feature suggestions",description:"Feature tips on the dashboard and sidebar.",checked:c,onCheckedChange:d}),e.jsx(_,{label:"Replay setup",description:"Go through first-run setup again.",children:e.jsx(b,{variant:"outline",size:"sm",onClick:j,disabled:y.isPending,children:"Replay setup"})})]})})]})]})}function fc(){const s=Mi(),t=U(),n=V(),a=m.useCallback(async i=>{await t.updateConfig({keepAwake:{whileAgentsWork:i}}),await Promise.all([n.invalidateQueries({queryKey:[...zi]}),n.invalidateQueries({queryKey:G.all})])},[t,n]);if(!s)return null;const r=s.supported?null:Ui[s.reason??"platform"];return e.jsxs("div",{className:"space-y-2","data-section":Ki.section,children:[e.jsx("p",{className:"text-sm font-medium",children:"Sleep"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx($,{label:"Keep this computer awake while agents work",description:e.jsxs("span",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:"Stays awake during chats, rooms and tasks. Sleeps as usual when idle."}),e.jsx("span",{"data-testid":"sleep-settings-note",children:r??Wi})]}),checked:s.enabled,onCheckedChange:i=>void a(i),disabled:!Bi(s)})})})]})}const Gs={login:{id:"reconnect",label:"Fix sign-in"},"provider-picker":{id:"change",label:"Change"}};function jc({type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:r,reconnect:i,toggleable:o,expanded:l,onToggleExpanded:c,bodyId:d,children:u}){const x=je(s),h=x.icon,p=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--runtime-accent)]/10 text-[var(--runtime-accent)]",children:e.jsx(h,{size:24})}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:x.label}),a&&e.jsx(se,{variant:"outline",className:"shrink-0 border-[var(--runtime-accent)]/40 bg-[var(--runtime-accent)]/10 text-[var(--runtime-accent)]","data-testid":`runtime-default-pill-${s}`,children:"Default"})]}),t&&e.jsx("span",{className:"text-muted-foreground truncate text-xs",children:t})]})]}),f=i?Gs[i.kind]:null;return e.jsxs("div",{className:"flex flex-col gap-1.5 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[o?e.jsx("button",{type:"button",onClick:c,"aria-expanded":l,"aria-controls":l?d:void 0,className:"focus-ring -m-1 flex min-w-0 flex-1 items-start gap-3 rounded-md p-1 text-left","data-testid":`runtime-card-toggle-${s}`,children:p}):e.jsx("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:p}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 pt-0.5",children:[n&&e.jsxs("span",{className:"text-status-success-fg inline-flex items-center gap-1 text-xs whitespace-nowrap","data-testid":`runtime-ready-${s}`,children:[e.jsx(Ke,{className:"size-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Ready"})]}),n&&f&&e.jsx("button",{type:"button",onClick:i==null?void 0:i.onOpen,className:"focus-ring text-muted-foreground hover:text-foreground hidden rounded-sm text-xs whitespace-nowrap underline-offset-2 transition-colors hover:underline sm:inline-flex","data-testid":`runtime-${f.id}-${s}`,children:f.label}),n&&!a&&r&&e.jsx("button",{type:"button",onClick:r,className:"focus-ring text-muted-foreground hover:text-foreground hidden rounded-sm text-xs whitespace-nowrap underline-offset-2 transition-colors hover:underline sm:inline-flex","data-testid":`runtime-make-default-${s}`,children:"Make default"}),o&&e.jsx("button",{type:"button",onClick:c,"aria-expanded":l,"aria-controls":l?d:void 0,"aria-label":`${l?"Hide":"Show"} ${x.label} ${n?"settings":"setup"}`,className:"focus-ring text-muted-foreground hover:text-foreground -m-1 inline-flex rounded-sm p-1 transition-colors","data-testid":`runtime-card-chevron-${s}`,children:e.jsx(We,{className:L("size-4 transition-transform",l&&"rotate-180")})})]})]}),u&&(o?e.jsx("button",{type:"button",tabIndex:-1,onClick:c,className:"focus-ring w-full rounded-md pl-12 text-left","data-testid":`runtime-card-summary-toggle-${s}`,children:u}):e.jsx("div",{className:"w-full pl-12",children:u}))]})}const Is="__inherit__";function yc({runtimeType:s,runtimeLabel:t,models:n,value:a,onChange:r,disabled:i,inheritLabel:o="Automatic",description:l}){const c=So(n),d=a!==null&&c!==void 0&&!c.includes(a),u=(n??[]).some(h=>h.unverified),x=m.useId();return e.jsx(_,{label:"Model",description:l??`Which ${t} model new chats start on. Automatic lets ${t} pick.`,orientation:"vertical",children:e.jsxs("div",{className:"w-52 space-y-1.5",children:[e.jsxs(oe,{value:a??Is,disabled:i,onValueChange:h=>r(h===Is?null:h),children:[e.jsx(le,{className:"w-full","aria-label":`Default ${t} model`,...u?{"aria-describedby":x}:{},"data-testid":`runtime-model-select-${s}`,children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:Is,children:o}),(n??[]).map(h=>e.jsx(P,{value:h.value,children:h.displayName},h.value)),a!==null&&!(n??[]).some(h=>h.value===a)&&e.jsx(P,{value:a,children:d?`${a} (no longer offered)`:a})]})]}),u&&e.jsx(Ao,{id:x})]})})}const Ie="__inherit__",bc=5;function vc({runtimeType:s,runtimeLabel:t,supportsEffort:n,selectedModel:a,configuredModelId:r,value:i,onChange:o,disabled:l}){const c=a?a.supportsEffort??!1:!0,d=ir.filter(u=>!(a!=null&&a.supportedEffortLevels)||a.supportedEffortLevels.includes(u));return e.jsx(_,{label:"Effort",description:"How much effort new chats put into answers.",orientation:"vertical",children:n?c?d.length+1>bc?e.jsxs(oe,{value:i??Ie,disabled:l,onValueChange:u=>o(u===Ie?null:u),children:[e.jsx(le,{className:"w-52","aria-label":`Default ${t} effort`,"data-testid":`runtime-effort-${s}`,children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:Ie,children:"Automatic"}),d.map(u=>e.jsx(P,{value:u,children:cs(u)},u))]})]}):e.jsxs(ks,{"aria-label":`Default ${t} effort`,"data-testid":`runtime-effort-${s}`,disabled:l,value:i??Ie,onValueChange:u=>o(u===Ie?null:u),children:[e.jsx($e,{value:Ie,children:e.jsx("span",{className:"truncate",children:"Automatic"})}),d.map(u=>e.jsx($e,{value:u,children:e.jsx("span",{className:"truncate",children:cs(u)})},u))]}):e.jsxs("div",{className:"flex flex-col gap-1","data-testid":`runtime-effort-model-unsupported-${s}`,children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:[(a==null?void 0:a.displayName)??r," doesn’t take an effort setting"]}),i&&e.jsxs("button",{type:"button",onClick:()=>o(null),disabled:l,className:"focus-ring text-status-warning-fg self-start rounded-sm text-xs underline-offset-2 hover:underline disabled:pointer-events-none disabled:opacity-50","data-testid":`runtime-effort-clear-${s}`,children:[cs(i)," is saved but unused. Clear it"]})]}):e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":`runtime-effort-unsupported-${s}`,children:["Not supported by ",t]})})}const Xs={ask:"Asks before acting",act:"Pauses at big steps",autonomy:"Full autonomy"};function Nc({runtimeType:s,runtimeLabel:t,descriptors:n,stop:a,globalStop:r,onChange:i,disabled:o}){var p;const l=a!==null,c=a??r,d=(p=Sn(n).find(f=>f.stop===c))==null?void 0:p.mode,u=(d==null?void 0:d.id)??"",x=c==="autonomy"&&(a===null||a===r),h=d!==void 0&&or(d)&&!x;return e.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":`runtime-trust-${s}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where it stops for you"}),l?e.jsx(b,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",disabled:o,onClick:()=>i(null),children:"Use the shared setting"}):e.jsx("span",{className:"text-muted-foreground text-3xs tracking-wide uppercase","data-testid":`runtime-trust-global-${s}`,children:"Global setting"})]}),n.length===0?e.jsxs("p",{"data-testid":`runtime-trust-unavailable-${s}`,className:"text-muted-foreground px-1 text-xs leading-relaxed",children:[t," hasn’t listed its options yet. New chats use its own setting."]}):e.jsx(lr,{mode:u,descriptors:n,stopLabels:Xs,disabled:o===!0,strandsWorkingMode:!0,strandedNote:`${t} has no setting here. New chats use its own.`,onChangeMode:f=>{const g=n.find(y=>y.id===f);g&&i(g.stop)}}),h&&e.jsx(An,{mode:u,descriptor:d,className:"px-1"})]})}const kc="One sign-in away from its settings.",wc="Your default isn’t connected, so new chats can’t start.",Cc=(s,t)=>`Your ${s} sign-in runs out in ${t}. Sign in again to keep agents working.`,Sc=s=>`Your ${s} sign-in stops working soon. Sign in again now.`,Ac=s=>`${s} keeps no settings here. It uses its own model and the setting below.`,Tc="Starts with";function Ec({type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:r,expanded:i,onToggleExpanded:o,summary:l,connectSlot:c,reconnect:d,reconnectPanel:u,model:x,effort:h,trust:p,storesDefaults:f=!0,sections:g,renderSection:y,setupDetails:N,setupBadge:j,expiringSignIn:C,className:E}){const A=je(s),T=m.useId(),[O,v]=m.useState(!1),k=n||!!N,Z=a&&!n,H=(g??[]).flatMap(F=>{const M=y==null?void 0:y(F.kind);return M?[e.jsx("div",{"data-testid":`runtime-card-section-${F.kind}-${s}`,children:M},F.kind)]:[]});return e.jsxs("article",{style:{"--runtime-accent":A.accent},className:L("bg-card border-border shadow-soft rounded-lg border",a&&"border-[var(--runtime-accent)]/40 ring-1 ring-[var(--runtime-accent)]/30",E),"data-testid":`runtime-card-${s}`,children:[e.jsx(jc,{type:s,subtitle:t,ready:n,isDefault:a,onMakeDefault:r,reconnect:d,toggleable:k,expanded:i,onToggleExpanded:o,bodyId:T,children:n?!i&&l.length>0&&e.jsxs("span",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs","data-testid":`runtime-card-summary-${s}`,children:[e.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:Tc}),l.map((F,M)=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-x-1.5 whitespace-nowrap",children:[M>0&&e.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 shrink-0",children:"·"}),e.jsx("span",{className:L("min-w-0 truncate",F.inherited?"text-muted-foreground":"text-foreground font-medium"),"data-inherited":F.inherited===!0,"data-testid":`runtime-card-summary-segment-${F.kind}-${M}`,children:F.label})]},`${F.kind}-${F.label}`))]}):e.jsx("span",{className:"text-muted-foreground text-xs","data-testid":`runtime-card-locked-${s}`,children:kc})}),Z&&e.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1.5 px-4 pb-3 text-xs","data-testid":`runtime-default-broken-${s}`,children:[e.jsx(ue,{className:"mt-px size-3.5 shrink-0","aria-hidden":!0}),wc]}),C&&e.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1.5 px-4 pb-3 text-xs","data-testid":`runtime-sign-in-expiring-${s}`,children:[e.jsx(ue,{className:"mt-px size-3.5 shrink-0","aria-hidden":!0}),C.timeLeft===null?Sc(A.label):Cc(A.label,C.timeLeft)]}),!n&&c&&e.jsx("div",{className:"px-4 pb-4",children:c}),n&&u&&e.jsx("div",{className:"px-4 pb-4",children:u}),i&&k&&e.jsxs("div",{id:T,className:"border-border/60 space-y-5 border-t px-4 py-4","data-testid":`runtime-card-body-${s}`,children:[n&&(d||!a&&r)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 sm:hidden",children:[d&&e.jsx("button",{type:"button",onClick:d.onOpen,className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs underline-offset-2 transition-colors hover:underline","data-testid":`runtime-${Gs[d.kind].id}-compact-${s}`,children:Gs[d.kind].label}),!a&&r&&e.jsx("button",{type:"button",onClick:r,className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs underline-offset-2 transition-colors hover:underline","data-testid":`runtime-make-default-compact-${s}`,children:"Make default"})]}),n&&(f?e.jsxs(e.Fragment,{children:[e.jsx(yc,{runtimeType:s,runtimeLabel:A.label,...x}),e.jsx(vc,{runtimeType:s,runtimeLabel:A.label,...h}),e.jsx(Nc,{runtimeType:s,runtimeLabel:A.label,...p}),H]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":`runtime-card-no-settings-${s}`,children:Ac(A.label)}),H]})),N&&e.jsx(ws,{open:O,onOpenChange:v,trigger:"Setup details",badge:j,className:"bg-transparent",children:N})]})]})}const Oc="Automatic",Rc={ask:"Asks first",act:"Pauses at big steps",autonomy:"Full autonomy"},Dc={"claude-accounts":s=>`runs on ${s}`,"opencode-power-source":s=>s};function Ic(s){var a,r,i,o,l,c;if(!s.ready)return[];const t=[],n=(a=s.model)==null?void 0:a.trim();if(n){const d=(r=s.models)==null?void 0:r.find(u=>u.value===n);t.push({kind:"model",label:(d==null?void 0:d.displayName)??n,inherited:!1})}else t.push({kind:"model",label:s.inheritModelLabel??Oc,inherited:!0});(i=s.settings)!=null&&i.supportsEffort&&s.effort&&s.modelTakesEffort!==!1&&t.push({kind:"effort",label:`${cs(s.effort)} effort`}),s.trustStop&&t.push({kind:"trust",label:Rc[s.trustStop],inherited:s.trustInherited??!1});for(const d of((o=s.settings)==null?void 0:o.sections)??[]){const u=(c=(l=s.sectionValues)==null?void 0:l[d.kind])==null?void 0:c.trim(),x=Dc[d.kind];u&&x&&t.push({kind:"section",label:x(u)})}return t}function Pc(s){const t=s.map(n=>n.label);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Lc({stop:s,effectiveStop:t,runtimes:n,onChange:a,onChangeRuntime:r}){var x;const i=s??t,o=Sn(cr),l=n.filter(h=>h.stop==="autonomy"),c=i==="autonomy",d=c||l.length>0,u=(x=o.find(h=>h.stop===(d?"autonomy":i)))==null?void 0:x.mode;return e.jsxs("section",{className:"@container/trust-row flex flex-col gap-2","data-testid":"global-trust-row",children:[e.jsxs("div",{className:"flex flex-col gap-3 @2xl/trust-row:flex-row @2xl/trust-row:items-center @2xl/trust-row:justify-between @2xl/trust-row:gap-6",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:"Where chats stop for you"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Cards above use this unless set otherwise."}),e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"global-trust-row-timing",children:[e.jsx("span",{children:"Applies to all chats from their next turn."})," ",e.jsx("span",{children:"Chats you set by hand only follow it down."})]})]}),e.jsx(ks,{"aria-label":"Where chats stop for you",className:"w-full @2xl/trust-row:w-auto @2xl/trust-row:shrink-0",value:i,onValueChange:h=>a(h),children:o.map(({stop:h,mode:p})=>e.jsxs($e,{value:h,"aria-label":Xs[h],children:[e.jsx(dr,{descriptor:p,className:"size-(--size-icon-xs) shrink-0"}),e.jsx("span",{className:"truncate",children:Xs[h]})]},h))})]}),(c||l.length>0)&&e.jsxs("p",{className:`flex items-start gap-1.5 px-1 text-xs ${ur.power}`,"data-testid":"default-trust-stop-standing-note",children:[e.jsx(mr,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[c?"New chats run at full power":`New chats on ${Pc(l)} run at full power`,"."," ",e.jsx("button",{type:"button",className:"focus-ring rounded-sm underline underline-offset-2",onClick:()=>{c&&a("ask");for(const h of l)r(h.runtime,null)},children:"Change"})]})]}),e.jsx(An,{descriptor:u,className:"px-1"})]})}const _c=[{key:"five_hour",label:"5-hour window"},{key:"seven_day",label:"Weekly"}];function na(s,t=new Date){return!!s&&(s.windows.length>0||aa(s.spend,t))}function aa(s,t=new Date){if(!s)return!1;const n=new Date(s.periodStart);return Number.isNaN(n.getTime())?!1:n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()}function $c({spend:s}){return e.jsxs("p",{className:"text-muted-foreground text-xs tabular-nums","data-slot":"spend-line",children:[xr(s.costUsd)," spent this month"]})}function ra({usage:s,name:t,now:n=new Date}){if(!na(s,n))return null;const a=s.windows.length>0;return e.jsxs("div",{className:"space-y-2","data-slot":"account-usage-bars",children:[t&&e.jsx("p",{className:"text-sm font-medium",children:t}),a?_c.map(({key:r,label:i})=>e.jsx(Bs,{window:Ws(s,r),label:i},r)):aa(s.spend,n)&&e.jsx($c,{spend:s.spend})]})}function Qt(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function Fc(s,t){if(s===null)return null;const n=new Date(s);if(Number.isNaN(n.getTime()))return null;const a=Math.round((Qt(t)-Qt(n))/864e5);return a<=0?"used today":a===1?"used yesterday":`used ${a} days ago`}function Mc({folders:s,onAdd:t,onDismiss:n,error:a=null,disabled:r=!1}){const i=m.useId();if(s.length===0)return null;const o=new Date;return e.jsxs("div",{role:"group","aria-labelledby":i,className:"bg-muted/50 rounded-md border border-dashed px-3 py-1.5","data-testid":"found-accounts-group",children:[e.jsx("p",{id:i,className:"text-muted-foreground py-1 text-xs",children:"Found on this computer"}),e.jsx("ul",{className:"divide-y",children:s.map(l=>{const c=Fc(l.lastUsedAt,o),d=(a==null?void 0:a.path)===l.path?a.message:null;return e.jsxs("li",{className:"py-2","data-testid":"found-account-row",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"min-w-40 flex-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-sm",children:[e.jsx("span",{className:"font-semibold break-all",children:l.name}),c&&e.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:["· ",c]}),l.orgManaged&&e.jsx("span",{className:L("text-2xs rounded-full px-2 leading-5 whitespace-nowrap",hr.warning),children:"managed by an organization"})]}),e.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",title:l.path,children:ms(l.path)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx(b,{size:"sm",variant:l.orgManaged?"outline":"default",onClick:()=>t(l),disabled:r,"aria-label":`Add ${l.name}`,children:"Add"}),e.jsx(b,{size:"sm",variant:"outline",onClick:()=>n(l),disabled:r,"aria-label":`Dismiss ${l.name}`,children:"Dismiss"})]})]}),d&&e.jsxs("p",{role:"alert",className:"text-destructive mt-1 flex items-start gap-1.5 text-xs","data-testid":"found-account-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:d})]})]},l.path)})})]})}function ia(s){return s.length<=1?s[0]??"":`${s.slice(0,-1).join(", ")} and ${s[s.length-1]}`}function kt(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function wt(){const s=V();return()=>{s.invalidateQueries({queryKey:G.all}),s.invalidateQueries({queryKey:Pe.all})}}function zc({onlyProjects:s}){return s===null?null:e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-only-for",children:s.length===0?pr:`Only for ${ia(s.map(t=>t.name))}`})}function Uc({open:s,onOpenChange:t,accountId:n,accountName:a,current:r}){const i=U(),o=wt(),l=m.useId(),c=Y({queryKey:Pe.projects(),queryFn:()=>i.listProjects(),enabled:s}),[d,u]=m.useState(r===null?"any":"only"),[x,h]=m.useState(()=>new Set((r??[]).map(A=>A.root))),[p,f]=m.useState(!1),g=ge({mutationFn:()=>i.setAccountOnlyProjects(n,d==="any"?null:[...x]),onSuccess:()=>{o(),t(!1)}}),y=c.data??[],N=(r??[]).filter(A=>!y.some(T=>T.root===A.root)),j=[...y,...N];function C(){if(d==="only"&&x.size===0){f(!0);return}f(!1),g.mutate()}function E(A,T){f(!1),h(O=>{const v=new Set(O);return T?v.add(A):v.delete(A),v})}return e.jsx(et,{open:s,onOpenChange:t,children:e.jsxs(st,{className:"max-h-[85vh] md:max-w-md",children:[e.jsxs(kn,{children:[e.jsxs(tt,{className:"text-sm font-medium",children:["Where can ",a," work?"]}),e.jsx(nt,{className:"text-muted-foreground text-xs",children:"Nobody can use it anywhere else, even in folders outside a project."})]}),e.jsxs(wn,{className:"space-y-3",children:[e.jsxs(Tn,{value:d,onValueChange:A=>u(A),"aria-labelledby":l,children:[e.jsxs("span",{id:l,className:"sr-only",children:["Where ",a," can work"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qs,{value:"any",id:`${l}-any`}),e.jsx(X,{htmlFor:`${l}-any`,className:"text-sm font-normal",children:"Any project"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qs,{value:"only",id:`${l}-only`}),e.jsx(X,{htmlFor:`${l}-only`,className:"text-sm font-normal",children:"Only these projects"})]})]}),d==="only"&&e.jsxs("div",{className:"space-y-1.5 pl-6","data-testid":"limit-projects-list",children:[c.isPending&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Looking for projects…"}),!c.isPending&&j.length===0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"No projects yet. Start a chat in one first."}),j.map(A=>{const T=`${l}-${A.root}`;return e.jsxs("div",{className:"flex min-h-11 items-center gap-2 md:min-h-8",children:[e.jsx(fn,{id:T,checked:x.has(A.root),onCheckedChange:O=>E(A.root,O===!0)}),e.jsx(X,{htmlFor:T,className:"min-w-0 text-sm font-normal",children:e.jsx("span",{className:"truncate",children:A.name})})]},A.root)})]}),p&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Pick a project, or choose Any project."})]}),g.isError&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:kt(g.error)})]})]}),e.jsxs(Cn,{children:[e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(b,{size:"sm",onClick:C,disabled:g.isPending,children:"Save"})]})]})})}function Kc({limits:s,nameForId:t}){const n=U(),a=wt(),r=m.useId(),i=ge({mutationFn:o=>n.setProjectAccounts(o,null),onSuccess:a});return s.length===0?null:e.jsxs("div",{role:"group","aria-labelledby":r,className:"rounded-md border px-3 py-1.5","data-testid":"project-limits",children:[e.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[e.jsx("p",{id:r,className:"text-muted-foreground text-xs",children:"Project limits"}),e.jsxs(qe,{label:"About project limits",children:[e.jsx("p",{children:"The Flow extension or a script sets each project’s list."}),e.jsx("p",{children:"Remove a limit to let that project use every account."})]})]}),e.jsx("p",{className:"text-muted-foreground pb-1 text-xs","data-testid":"project-limits-note",children:"These projects use only the accounts listed."}),e.jsx("ul",{className:"divide-y",children:s.map(({project:o,allow:l})=>e.jsxs("li",{className:"flex flex-wrap items-center gap-2 py-2","data-testid":"project-limit-row",children:[e.jsxs("div",{className:"min-w-40 flex-1",children:[e.jsx("p",{className:"text-sm font-medium break-all",children:o.name}),e.jsx("p",{className:"text-muted-foreground text-xs",children:l.length===0?"Uses no account":`Uses only ${ia(l.map(t))}`})]}),e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>i.mutate(o.root),disabled:i.isPending,"aria-label":`Let ${o.name} use every account`,children:"Remove"})]},o.root))}),i.isError&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 pb-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:kt(i.error)})]})]})}const Bc=["blue","green","amber","purple","pink","teal","indigo","stone"],is=[...vr.map((s,t)=>({name:Bc[t]??s,hex:s})),{name:"Default",hex:null}];function Wc({name:s,color:t,colorIsDefault:n,onChoose:a,disabled:r,defaultOpen:i=!1}){const[o,l]=m.useState(i),c=m.useRef([]),d=is.findIndex(p=>p.hex===null?n:!n&&p.hex===t.toLowerCase()),u=d===-1?0:d;function x(p){l(!1),a(p)}function h(p){var j;const f=p.key==="ArrowRight"||p.key==="ArrowDown"?1:p.key==="ArrowLeft"||p.key==="ArrowUp"?-1:0;if(f===0)return;p.preventDefault();const g=c.current.findIndex(C=>C===document.activeElement),N=((g===-1?u:g)+f+is.length)%is.length;(j=c.current[N])==null||j.focus()}return e.jsxs(gr,{open:o,onOpenChange:l,children:[e.jsx(fr,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Color for ${s}`,"aria-haspopup":"dialog",disabled:r,className:"focus-visible:ring-ring -m-1 inline-flex shrink-0 rounded-full p-1 focus-visible:ring-2 focus-visible:outline-none",children:e.jsx(jr,{color:t,name:s,size:"md"})})}),e.jsxs(yr,{className:"w-auto p-3",align:"start",children:[e.jsxs(br,{className:"sr-only",children:["Color for ",s]}),e.jsx("div",{role:"radiogroup","aria-label":`Color for ${s}`,className:"flex flex-wrap items-center gap-1.5",onKeyDown:h,children:is.map((p,f)=>{const g=f===d;return e.jsx("button",{ref:y=>{c.current[f]=y},type:"button",role:"radio","aria-checked":g,"aria-label":p.name,title:p.name,tabIndex:f===u?0:-1,onClick:()=>x(p.hex),className:L("focus-visible:ring-ring inline-flex items-center justify-center rounded-full focus-visible:ring-2 focus-visible:outline-none",p.hex===null?"text-foreground hover:bg-muted h-6 gap-1 border px-2 text-xs":"size-6 bg-(--swatch) text-white",g&&p.hex!==null&&"ring-foreground ring-2 ring-offset-2"),style:p.hex?{"--swatch":p.hex}:void 0,children:p.hex===null?e.jsxs(e.Fragment,{children:[g&&e.jsx(Ke,{className:"size-3","aria-hidden":!0}),"Default"]}):g&&e.jsx(Ke,{className:"size-3.5","aria-hidden":!0})},p.name)})})]})]})}function qc(s){const t=U(),n=wt();return ge({mutationFn:a=>t.setAccountNoAutoMove(s,a),onSuccess:n})}function Hc({accountId:s,noAutoMove:t,disabled:n}){const a=m.useId(),r=qc(s),i=r.isPending?r.variables===!1:!t;return e.jsxs("div",{className:"mt-1 space-y-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(He,{id:a,size:"sm",className:"mt-0.5",checked:i,onCheckedChange:o=>r.mutate(!o),disabled:n||r.isPending,"data-testid":"claude-account-auto-move"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(X,{htmlFor:a,className:"text-xs font-normal",children:"Move agents here automatically"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"When an agent runs out in a room, it can continue here."})]})]}),r.error&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:kt(r.error)})]})]})}function Yc({name:s,rule:t,disabled:n}){const[a,r]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(zc,{onlyProjects:t.onlyProjects}),e.jsx(b,{variant:"link",size:"sm",className:"text-muted-foreground h-auto px-0 py-0.5 text-xs",onClick:()=>r(!0),disabled:n,children:"Limit to projects…"}),a&&e.jsx(Uc,{open:!0,onOpenChange:r,accountId:t.accountId,accountName:s,current:t.onlyProjects}),t.noAutoMove!==void 0&&e.jsx(Hc,{accountId:t.accountId,noAutoMove:t.noAutoMove,disabled:n})]})}function Gt({name:s,account:t,isActive:n,onRemove:a,onChooseColor:r,rule:i,disabled:o,identity:l,signInState:c}){return e.jsxs("div",{className:"flex items-start gap-3","data-testid":"claude-account-row",children:[l&&e.jsx("span",{className:"mt-1 flex",children:e.jsx(Wc,{name:s,color:t.color,colorIsDefault:t.colorIsDefault,onChoose:r,disabled:o})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium",children:[s,n&&e.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:"in use"})]}),e.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",title:t.path,children:ms(t.path)}),e.jsx(zn,{accountRoot:t.path,name:s,state:c}),i&&e.jsx(Yc,{name:s,rule:i,disabled:o}),!t.isAccountRoot&&e.jsxs("p",{className:"text-muted-foreground mt-1 flex items-start gap-1.5 text-xs","data-testid":"claude-account-not-ready",children:[e.jsx(ue,{className:"text-destructive mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Not a Claude Code account yet. No chats show from it."})]})]}),l&&e.jsxs("div",{className:"w-36 shrink-0 space-y-1 pt-0.5",children:[e.jsx(Bs,{window:Ws(l.usage,"five_hour"),label:"5h",compact:!0}),e.jsx(Bs,{window:Ws(l.usage,"seven_day"),label:"wk",compact:!0})]}),a?e.jsx(b,{variant:"ghost",size:"sm",onClick:a,disabled:o,"aria-label":`Remove ${s}`,children:e.jsx(ds,{className:"size-3.5"})}):e.jsx("span",{"aria-hidden":"true","data-testid":"claude-account-remove-spacer",className:L(Nr({variant:"ghost",size:"sm"}),"invisible"),children:e.jsx(ds,{className:"size-3.5"})})]})}const Ps="__default__",Ls="__credits__";function os(s){return s.flatMap(t=>t.id?[t.id]:[])}function Js(s){const t=new Set([Rn,...s.flatMap(n=>n.id?[n.id]:[])]);return s.map(n=>{const a=n.id??Dn({label:n.label,path:n.path,taken:t});return t.add(a),{id:a,path:n.path,label:n.label,color:n.colorIsDefault?null:n.color}})}function Xt(s,t,n){const a=Js(s),r=Dn({label:n,path:t,taken:[Rn,...a.map(i=>i.id)]});return[...a,{id:r,path:t,label:n,color:null}]}function _s(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function Vc(){var ss,ve;const{data:s}=Se(),{nameFor:t,credits:n}=vs(),a=ye(),r=bs(),i=V(),[o,l]=m.useState(""),[c,d]=m.useState(""),[u,x]=m.useState(!1),[h,p]=m.useState(!1),[f,g]=m.useState(null),[y,N]=m.useState(null),j=U(),C=Y({queryKey:Pe.found(),queryFn:()=>j.getFoundClaudeFolders()}),E=ge({mutationFn:w=>j.dismissFoundClaudeFolder(w.path),onMutate:()=>N(null),onSuccess:()=>i.invalidateQueries({queryKey:Pe.found()}),onError:(w,B)=>N({path:B.path,message:_s(w)})}),A=kr("claude-code"),T=ut("claude-code",{fetch:!0}),O=gn("settings.tabs").some(w=>w.id===En),v=s==null?void 0:s.claudeCode,k=(v==null?void 0:v.accounts)??[],Z=v==null?void 0:v.resolvedAccount,H=(v==null?void 0:v.inherited)??!0,F=v==null?void 0:v.resolvedAccountId,M=F&&F!==ke?k.find(w=>w.id===F):void 0,W=(M==null?void 0:M.path)??Z,S=n!==null&&(n.available||n.isDefault),K=n!=null&&n.isDefault?Ls:H||!W?Ps:W,I=A?T.byId.get(ke):void 0,be=o.trim(),Re=k.some(w=>w.path===be),Je=be.length>0&&!wr(be),Ze=be.length>0&&!Re&&!Je;function he(w,B,Q=g){g(null),N(null),a.mutate({runtimes:{claudeCode:w}},{onSuccess:()=>{i.invalidateQueries({queryKey:G.all}),i.invalidateQueries({queryKey:Pe.usage("claude-code")}),B==null||B()},onError:q=>Q(_s(q))})}function es(w){g(null);const B=q=>g(_s(q));if(w===Ls){r.mutate({runtime:"claude-code",useCredits:!0},{onError:B});return}const Q=w===Ps?null:w;if(n!=null&&n.isDefault){r.mutate({runtime:"claude-code",useCredits:!1},{onError:B,onSuccess:()=>{const q=H?null:(v==null?void 0:v.resolvedAccount)??null;Q!==q&&he({defaultAccount:Q})}});return}he({defaultAccount:Q})}function Ss(){Ze&&he({accounts:Xt(k,be,c.trim()||null),accountsSeen:os(k)},()=>{l(""),d(""),x(!1)})}function At(w){he({accounts:Xt(k,w.path,null),accountsSeen:os(k)},()=>void i.invalidateQueries({queryKey:Pe.found()}),B=>N({path:w.path,message:B}))}function As(w,B){he({accounts:Js(k).map((Q,q)=>k[q].path===w?{...Q,color:B}:Q),accountsSeen:os(k)})}function Ue(w){const B=Js(k.filter(q=>q.path!==w)),Q=!H&&M!==void 0&&M.path===w;he({accounts:B,accountsSeen:os(k),...Q&&{defaultAccount:null}})}return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"claude-accounts-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Runs on"}),e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground h-auto px-1 py-0 text-xs",onClick:()=>x(w=>!w),"aria-expanded":u,children:"Add account"})]}),!A&&e.jsx(Qc,{accounts:k,usage:T}),v&&k.length===0&&!A&&e.jsx(zn,{accountRoot:v.resolvedAccount,name:t(v.resolvedAccount),state:(ss=T.byId.get(ke))==null?void 0:ss.signInState}),e.jsx(_,{label:"Default account",description:"New chats run on this unless the agent or the chat picks another.",children:e.jsxs(oe,{value:K,onValueChange:es,disabled:r.isPending,children:[e.jsx(le,{className:"w-52","aria-label":"Default account","data-testid":"claude-account-select",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:Ps,children:H&&Z?`Default (${ms(Z)})`:"Default"}),Cr(k,H?null:W).map(w=>e.jsx(P,{value:w.path,children:t(w.path)},w.path)),S&&e.jsx(P,{value:Ls,children:On})]})]})}),(n==null?void 0:n.isDefault)&&n.chosenBy==="default"&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-credits-chosen-for-you",children:"DorkOS chose this when you linked your account. Claude Code had no working sign-in."}),(n==null?void 0:n.isDefault)&&!n.available&&e.jsxs("div",{className:"text-muted-foreground text-xs","data-testid":"claude-credits-unavailable",children:[e.jsx("p",{children:"DorkOS credits aren’t available, so new chats here won’t start."}),e.jsx("p",{children:"Sign in to your DorkOS account again, or pick another account."})]}),(v==null?void 0:v.launchOverride)&&!F&&e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-launch-override",children:["New chats use ",ms(v.launchOverride.path),", from the server’s $CLAUDE_CONFIG_DIR."]}),k.map(w=>{var B;return e.jsx(Gt,{name:t(w.path),account:w,signInState:(B=T.byPath.get(w.path))==null?void 0:B.signInState,isActive:w.id!==null&&w.id===F,onRemove:()=>Ue(w.path),onChooseColor:Q=>As(w.path,Q),rule:w.id?{accountId:w.id,onlyProjects:w.onlyProjects??null,noAutoMove:w.noAutoMove===!0}:null,disabled:a.isPending,identity:A?{usage:(w.id?T.byId.get(w.id):void 0)??T.byPath.get(w.path)}:null},w.path)}),I&&e.jsx(Gt,{signInState:I.signInState,name:I.label??t(I.path),account:{path:I.path,color:(v==null?void 0:v.defaultAccountResolvedColor)??I.color,colorIsDefault:((v==null?void 0:v.defaultAccountColor)??null)===null,isAccountRoot:!0},isActive:F===ke,onChooseColor:w=>he({defaultAccountColor:w}),rule:{accountId:ke,onlyProjects:(v==null?void 0:v.defaultAccountOnlyProjects)??null},disabled:a.isPending,identity:{usage:I}}),e.jsx(Kc,{limits:(v==null?void 0:v.projectAccounts)??[],nameForId:w=>{if(w===ke)return(I==null?void 0:I.label)??"Main";const B=k.find(Q=>Q.id===w);return B?t(B.path):w}}),e.jsx(Mc,{folders:((ve=C.data)==null?void 0:ve.folders)??[],onAdd:At,onDismiss:w=>E.mutate(w),error:y,disabled:a.isPending||E.isPending}),A&&O&&e.jsx(Gc,{}),u&&e.jsx(_,{orientation:"vertical",label:"Add an account",description:e.jsxs(e.Fragment,{children:["Pick the account’s Claude Code folder, then name it."," ",e.jsxs(qe,{label:"About adding an account",children:[e.jsx("p",{children:"Name it after the client it bills."}),e.jsx("p",{children:"DorkOS only reads the folder. It never signs you in or moves anything."})]})]}),children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(To,{"aria-label":"Account folder",placeholder:"/Users/you/.claude2",value:o,onChange:l,onBrowse:()=>p(!0),browseTestId:"browse-claude-account","data-testid":"claude-account-path"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{htmlFor:"claude-account-label",className:"text-muted-foreground text-xs",children:"Name"}),e.jsx(J,{id:"claude-account-label",placeholder:"Acme Corp",value:c,onChange:w=>d(w.target.value),className:"h-11 flex-1 md:h-8"}),e.jsx(b,{size:"sm",onClick:Ss,disabled:!Ze||a.isPending,children:"Add"})]}),Re&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-duplicate",children:"That folder is already added."}),Je&&e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"claude-account-not-absolute",children:["Use the full path, like ",e.jsx("code",{children:"/Users/you/.claude2"}),". A path starting with"," ",e.jsx("code",{children:"~"})," won’t work."]})]})}),f&&e.jsxs("p",{role:"alert",className:"text-destructive flex items-start gap-1.5 text-xs","data-testid":"claude-account-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:f})]}),e.jsx(Sr,{open:h,onOpenChange:p,onSelect:l,initialPath:be||null})]})}function Qc({accounts:s,usage:t}){const{nameFor:n}=vs();if(s.length>1)return null;const a=s[0],r=a?(a.id?t.byId.get(a.id):void 0)??t.byPath.get(a.path):t.byId.get(ke);if(!r)return null;const i=a?n(a.path):r.label??n(r.path);return e.jsx(ra,{usage:r,name:i})}function Gc(){const{setTab:s}=fe();return e.jsxs("p",{className:"bg-muted text-muted-foreground rounded-md px-3 py-2 text-xs",children:["Flow uses these accounts. Choose how in"," ",e.jsx("button",{type:"button",onClick:()=>s(En),className:"text-foreground font-semibold underline-offset-2 hover:underline",children:"Settings → Flow"}),"."]})}function Xc({type:s,provider:t,renderConnect:n}){const[a,r]=m.useState(!1);return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"power-source-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Power source"}),t&&!a&&e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground h-auto px-1 py-0 text-xs",onClick:()=>r(!0),"data-testid":"power-source-change",children:"Change"})]}),t?e.jsx("p",{className:"text-sm font-medium","data-testid":"power-source-current",children:Yn(t)}):e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"power-source-empty",children:[xt(s)," was signed in outside DorkOS, so its model source is unknown."]}),t&&a&&e.jsxs("div",{className:"space-y-2","data-testid":"power-source-panel",children:[n({type:s,connect:{kind:"provider-picker",label:"Change power source"},currentProvider:t,onConnected:()=>r(!1)}),e.jsx("button",{type:"button",onClick:()=>r(!1),className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs transition-colors","data-testid":"power-source-cancel",children:"Keep current source"})]})]})}function Jc({type:s}){var a;const{data:t}=mt(),n=(a=t==null?void 0:t.runtimes[s])==null?void 0:a.provider;return e.jsx(Xc,{type:s,...n?{provider:n}:{},renderConnect:Ys})}function Zc(s,t){return s==="effort"?`effort ${t}`:s==="account"||s==="runtime"?`runs on ${t}`:`${s} ${t}`}function ed({exceptions:s}={}){const t=qi({checkModels:s===void 0}),n=s??t.exceptions,a=fe();function r(i){a.close(),Er.getState().openProfileDocked(i)}return n.length===0?null:e.jsxs("div",{className:"space-y-1","data-testid":"execution-exceptions-strip",children:[e.jsx("p",{className:"text-muted-foreground px-1 text-xs",children:"These agents run on something else:"}),e.jsx("ul",{className:"divide-border bg-card divide-y overflow-hidden rounded-lg border",children:n.map(({path:i,agent:o,report:l})=>{const c=l.isBroken?l.breakages.map(u=>u.message).join(" "):l.deviations.map(u=>Zc(u.field,u.label)).join(", "),d=Ar(o);return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(i),className:"hover:bg-accent flex w-full items-center gap-2 px-3 py-2 text-left transition-colors","data-testid":l.isBroken?"execution-exception-broken":"execution-exception",children:[e.jsx(Tr,{color:d.color,emoji:d.emoji,size:"xs"}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-start sm:gap-3",children:[e.jsx("span",{className:"truncate text-sm font-medium sm:pt-px",children:o.name}),e.jsxs("span",{className:L("flex min-w-0 items-start gap-1.5 text-xs sm:ml-auto sm:max-w-[65%]",l.isBroken?"text-status-warning-fg":"text-muted-foreground"),children:[l.isBroken&&e.jsx(Me,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"line-clamp-2",title:c,children:c})]})]})]})},i)})})]})}function sd(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function oa(){const{data:s}=Ge(),t=ye(),n=V(),[a,r]=m.useState(null),i=m.useCallback(c=>{r(null),t.mutate(c,{onSuccess:()=>{n.invalidateQueries({queryKey:G.all}),n.invalidateQueries({queryKey:Or.all})},onError:d=>r(sd(d))})},[t,n]),o=m.useCallback((c,d)=>{var x;if(c===null){i({runtimes:{defaultTrustStop:d}});return}const u=(x=Hn(s,c))==null?void 0:x.configSection;u&&i({runtimes:{[u]:{defaultTrustStop:d}}})},[s,i]),l=m.useCallback(()=>r(null),[]);return{changeTrustStop:o,writeError:a,clearWriteError:l,isPending:t.isPending}}const td={healthy:"success",delivered:"success",connected:"success",pending:"info",starting:"info",new:"info",reconnecting:"warning",degraded:"warning",warning:"warning",rate_limited:"warning",failed:"error",error:"error",disconnected:"error",inactive:"neutral",stopped:"neutral"};function Ct(s){return td[s]??"neutral"}function nd(s){return Ee[Ct(s)]}function ad(s){return Rr[Ct(s)]}function rd(s){return Dr[Ct(s)]}const id={delivered:"success",failed:"error",no_subscriber:"neutral",sent:"info",timeout:"neutral"};function od(s){return Ee[id[s]]??Ee.neutral}function ld(s){return new Date(s).toLocaleTimeString()}function Jt(s,t){if(s==null||t==null)return null;const n=new Date(t).getTime()-new Date(s).getTime();return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function cd({messageId:s,onClose:t}){const{data:n,isLoading:a,error:r}=xl(s);if(a)return e.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading trace…"});if(r||!n)return e.jsx("div",{className:"text-destructive p-4 text-sm",children:"Couldn’t load where this message went."});const{traceId:i,spans:o}=n;return e.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-muted-foreground font-mono text-xs",children:["Trace: ",i.slice(0,8),"…"]}),t&&e.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-xs",children:"Close"})]}),e.jsx("div",{className:"border-border relative ml-3 border-l pl-6",children:o.map(l=>{const c=Jt(l.sentAt,l.deliveredAt),d=Jt(l.deliveredAt,l.processedAt);return e.jsxs("div",{className:"relative pb-4 last:pb-0",children:[e.jsx("div",{className:`absolute top-1 -left-[calc(1.5rem+0.3125rem)] h-2.5 w-2.5 rounded-full ${od(l.status)}`}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:l.subject}),e.jsx("span",{className:"bg-muted rounded px-1.5 py-0.5 text-xs",children:l.status})]}),e.jsxs("div",{className:"text-muted-foreground flex gap-3 text-xs",children:[e.jsxs("span",{children:["Sent: ",ld(l.sentAt)]}),c&&e.jsxs("span",{children:["Delivery: ",c]}),d&&e.jsxs("span",{children:["Processing: ",d]})]}),l.errorMessage&&e.jsx("div",{className:"bg-destructive/10 text-destructive mt-1 rounded px-2 py-1 text-xs",children:l.errorMessage})]})]},l.id)})})]})}function $s(s){if(s.payload&&typeof s.payload=="object"){const n=s.payload;if(typeof n.adapterId=="string")return n.adapterId}const t=s.from.raw.match(/^relay\.human\.([^.]+)/);return t?t[1]:""}function Zt(s){if(s.payload&&typeof s.payload=="object"){const t=s.payload;if(typeof t.chatId=="string")return t.chatId}}function en(s){if(s.payload&&typeof s.payload=="object"){const n=s.payload.channelType;if(n==="dm"||n==="group"||n==="channel"||n==="thread")return n}}const dd={delivered:"Delivered",failed:"Error",pending:"Pending"};function sn(s){return new Date(s).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}function ud(s){return s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`}function md(s){return s.status==="delivered"?s.responseCount>0?`delivered · ${s.responseCount} chunks`:"delivered":s.failureReason??dd[s.status].toLowerCase()}function xd({conversation:s}){const[t,n]=m.useState(!1),[a,r]=m.useState(!1),[i,o]=m.useState(!1),[l,c]=m.useState(""),[d,u]=m.useState(!1),[x,h]=m.useState(!1),{data:p}=Ir(),f=m.useMemo(()=>(p==null?void 0:p.agents)??[],[p]),{mutate:g}=mo(),{data:y=[]}=Fn(),N=$s(s),j=m.useMemo(()=>y.filter(k=>k.adapterId===N),[y,N]),C=nd(s.status),E=ad(s.status),A=rd(s.status),T=m.useCallback(()=>{f.find(Z=>Z.id===l)&&(g({adapterId:$s(s),agentId:l,sessionStrategy:"per-chat",label:"",chatId:Zt(s),channelType:en(s)}),c(""),u(!1))},[f,l,s,g]),O=m.useCallback(()=>{u(!1),h(!0)},[]),v=m.useCallback(k=>{g({adapterId:k.adapterId,agentId:k.agentId,sessionStrategy:k.sessionStrategy,label:k.label,chatId:k.chatId,channelType:k.channelType,canInitiate:k.canInitiate,canReply:k.canReply,canReceive:k.canReceive}),h(!1)},[g]);return e.jsxs("div",{className:L("hover:bg-muted/50 w-full rounded-lg border border-l-2 text-left transition-colors hover:shadow-sm",A,t&&"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-start gap-2 p-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex min-w-0 flex-1 items-start gap-2",children:[e.jsx("span",{className:L("mt-1 size-2 shrink-0 rounded-full",C)}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsx("span",{className:"inline-block w-8 font-medium",children:"From"}),e.jsx("span",{className:"text-foreground",children:s.from.label})]}),e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsx("span",{className:"inline-block w-8 font-medium",children:"To"}),e.jsx("span",{className:"text-foreground",children:s.to.label})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.preview&&e.jsxs("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:["“",s.preview,"”"]}),e.jsx("span",{className:L("shrink-0 text-xs",E),children:md(s)})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:we(s.sentAt)}),e.jsxs(Pr,{open:d,onOpenChange:u,children:[e.jsx(Lr,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:k=>k.stopPropagation(),"aria-label":"Route to agent",children:[e.jsx(oo,{className:"mr-1 size-3"}),"Route"]})}),e.jsxs(_r,{className:"w-64 space-y-3 p-3",align:"end",children:[e.jsx("p",{className:"text-xs font-medium",children:"Route to agent"}),j.length>0&&e.jsx("div",{className:"rounded border border-blue-200 bg-blue-50 px-2 py-1.5 text-xs dark:border-blue-900 dark:bg-blue-950",children:e.jsxs("p",{className:"font-medium text-blue-800 dark:text-blue-200",children:["Already goes to ",j.length," ",j.length===1?"agent":"agents"]})}),e.jsxs(oe,{value:l,onValueChange:c,children:[e.jsx(le,{responsive:!1,className:"h-8 text-xs",children:e.jsx(ce,{placeholder:"Select agent"})}),e.jsx(de,{children:f.map(k=>e.jsx(P,{value:k.id,children:$r(k)},k.id))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{variant:"link",size:"sm",className:"h-6 px-0 text-xs",onClick:O,children:"More options…"}),e.jsx(b,{size:"sm",className:"h-7 text-xs",disabled:!l,onClick:T,children:"Add connection"})]})]})]})]})]}),x&&e.jsx(xo,{open:!0,onOpenChange:k=>{k||h(!1)},mode:"create",initialValues:{adapterId:$s(s),agentId:l||void 0,chatId:Zt(s),channelType:en(s)},onConfirm:v}),e.jsx(Le,{initial:!1,children:t&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"space-y-3 border-t px-3 pt-3 pb-3",children:[s.payload!=null&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"Content"}),e.jsx("pre",{className:"bg-muted mt-1 max-h-40 overflow-auto rounded p-2 font-mono text-xs",children:JSON.stringify(s.payload,null,2)})]}),e.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.jsxs("span",{children:["Sent ",sn(s.sentAt)]}),s.completedAt&&e.jsxs("span",{children:[" · Completed ",sn(s.completedAt)]}),s.durationMs!=null&&e.jsxs("span",{children:[" · Duration: ",ud(s.durationMs)]}),s.responseCount>0&&e.jsxs("span",{children:[" · ",s.responseCount," reply parts"]})]}),s.failureReason&&e.jsx("div",{className:"bg-destructive/10 text-destructive rounded px-2 py-1 text-xs",children:s.failureReason}),e.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),r(!a)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[a?e.jsx(We,{className:"size-3.5"}):e.jsx(Be,{className:"size-3.5"}),"Technical details"]}),e.jsx(Le,{initial:!1,children:a&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Subject"}),e.jsx("dd",{className:"truncate font-mono",children:s.subject}),s.sessionId&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Chat"}),e.jsx("dd",{className:"font-mono",children:s.sessionId.slice(0,8)})]}),s.traceId&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Trace ID"}),e.jsxs("dd",{className:"font-mono",children:[s.traceId.slice(0,12),"…"]})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Source"}),e.jsx("dd",{className:"truncate font-mono",children:s.from.raw}),e.jsx("dt",{className:"text-muted-foreground",children:"Destination"}),e.jsx("dd",{className:"truncate font-mono",children:s.to.raw})]})})}),s.traceId&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),o(!i)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[i?e.jsx(We,{className:"size-3.5"}):e.jsx(Be,{className:"size-3.5"}),"Trace timeline"]}),e.jsx(Le,{initial:!1,children:i&&e.jsx(Te.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsx(cd,{messageId:s.traceId,onClose:()=>o(!1)})})})]})]})})})]})}const hd={hop_limit:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400",ttl_expired:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",cycle_detected:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",budget_exhausted:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"},pd="bg-muted text-muted-foreground";function gd(s,t){const n=we(s),a=we(t);return n===a?a:`${n} to ${a}`}function fd({group:s}){const[t,n]=m.useState(!1),a=Fr(),r=ho[s.reason]??po,i=hd[s.reason]??pd;return e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/50 p-3 dark:border-red-900/40 dark:bg-red-950/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Me,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:s.source}),e.jsx(se,{className:L("shrink-0 border-0 font-normal",i),children:r}),e.jsx(se,{variant:"destructive",className:"shrink-0 tabular-nums",children:s.count.toLocaleString()})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:gd(s.firstSeen,s.lastSeen)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.sample!=null&&e.jsxs(e.Fragment,{children:[e.jsxs(b,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n(!0),children:[e.jsx(Mr,{className:"mr-1 size-3"}),"See one"]}),e.jsx(bn,{open:t,onOpenChange:n,children:e.jsxs(vn,{className:"max-w-lg",children:[e.jsxs(zs,{children:[e.jsx(Us,{children:"What was sent"}),e.jsxs(Ks,{children:["Never arrived: ",r,"."]})]}),e.jsx("pre",{className:"bg-muted max-h-80 overflow-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(s.sample,null,2)})]})})]}),e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-7 px-2 text-xs",disabled:a.isPending,children:[e.jsx(ds,{className:"mr-1 size-3"}),"Clear these"]})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Clear these messages?"}),e.jsxs(ae,{children:["Clears ",s.count," message",s.count!==1?"s":""," from"," ",e.jsx("span",{className:"font-medium",children:s.source})," (",r,"). They won’t be sent, and this can’t be undone."]})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:()=>a.mutate({source:s.source,reason:s.reason}),children:"Clear these"})]})]})]})]})]})})}function jd({enabled:s=!0}){const{data:t=[],isLoading:n}=In(s),{data:a}=Nt(),r=a==null?void 0:a.budgetRejections,i=r&&Object.values(r).some(o=>o>0);return n||t.length===0?null:e.jsxs("div",{className:"space-y-2",children:[i&&e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-900 dark:bg-amber-950",children:e.jsxs("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200",children:["Not delivered: ",r.hopLimit," too many hand-offs,"," ",r.cycleDetected," loops, ",r.budgetExhausted," over limit,"," ",r.ttlExpired," expired"]})}),t.map(o=>e.jsx(fd,{group:o},`${o.source}:${o.reason}`))]})}function yd({enabled:s}){const{data:t}=Nt();if(!s||!t)return null;const n=[{label:"Total",value:t.totalMessages,variant:"default"},{label:"Delivered",value:t.deliveredCount,variant:"success"},{label:"Errors",value:t.failedCount,variant:t.failedCount>0?"danger":"default"},{label:"No listener",value:t.noSubscriberCount,variant:"default"},{label:"Never arrived",value:t.deadLetteredCount,variant:t.deadLetteredCount>0?"warning":"default"}];return e.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.map(({label:a,value:r,variant:i})=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:a}),e.jsx("span",{className:L("font-medium tabular-nums",i==="success"&&r>0&&"text-status-success-fg",i==="danger"&&"text-destructive",i==="warning"&&"text-status-warning-fg"),children:r.toLocaleString()})]},a)),t.avgDeliveryLatencyMs!=null&&e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg"}),e.jsx("span",{className:"font-medium tabular-nums",children:t.avgDeliveryLatencyMs<1e3?`${Math.round(t.avgDeliveryLatencyMs)}ms`:`${(t.avgDeliveryLatencyMs/1e3).toFixed(1)}s`})]})]})}function bd(s){return s.startsWith("relay.agent.")?"chat":s.startsWith("relay.system.tasks.")?"tasks":"system"}const vd={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}},Nd={initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}};function kd(s,t,n,a){return s.filter(r=>{if(t!=="all"&&bd(r.subject)!==t||n!=="all"&&r.status!==n)return!1;if(a){const i=a.toLowerCase();if(!(r.from.label.toLowerCase().includes(i)||r.to.label.toLowerCase().includes(i)||r.preview.toLowerCase().includes(i)||r.subject.toLowerCase().includes(i)))return!1}return!0})}function wd({enabled:s,deadLetterRef:t,onSwitchToIntegrations:n,autoShowFailures:a}){const[r,i]=m.useState("all"),[o,l]=m.useState("all"),[c,d]=m.useState(""),[u,x]=m.useState(null),{data:h,isLoading:p}=gl(s),{data:f=[]}=In(s),g=m.useMemo(()=>(h==null?void 0:h.conversations)??[],[h==null?void 0:h.conversations]);f.length>0;const y=m.useRef(null);m.useEffect(()=>{g.length>0&&y.current===null&&(y.current=new Set(g.map(O=>O.id)))},[g]);const N=u!==null&&(u.afterAutoShow||!a)?u:null,j=N!==null,C=N!==null?N.open:!!a||f.length>0,E=r!=="all"||o!=="all"||c!=="",A=kd(g,r,o,c);function T(){i("all"),l("all"),d("")}return p?e.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(O=>e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted animate-breath size-4 rounded"}),e.jsx("div",{className:"bg-muted animate-breath h-4 w-40 rounded"}),e.jsx("div",{className:"bg-muted animate-breath ml-auto h-3 w-16 rounded"})]})},O))}):e.jsxs(e.Fragment,{children:[e.jsx(yd,{enabled:s}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(oe,{value:r,onValueChange:O=>i(O),children:[e.jsx(le,{className:"w-32",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"all",children:"All sources"}),e.jsx(P,{value:"chat",children:"Chat messages"}),e.jsx(P,{value:"tasks",children:"Scheduled runs"}),e.jsx(P,{value:"system",children:"System"})]})]}),e.jsxs(oe,{value:o,onValueChange:O=>l(O),children:[e.jsx(le,{className:"w-32",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"all",children:"All statuses"}),e.jsx(P,{value:"delivered",children:"Delivered"}),e.jsx(P,{value:"failed",children:"Error"}),e.jsx(P,{value:"pending",children:"Pending"})]})]}),e.jsxs(b,{variant:C?"secondary":"ghost",size:"sm",className:"relative",onClick:()=>{x({open:!C,afterAutoShow:a??!1})},"aria-pressed":C,"aria-label":"Show messages that never arrived",children:[e.jsx(Me,{className:"mr-1 size-3.5"}),"Never arrived",f.length>0&&!C&&j&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full bg-red-500"})]}),e.jsx(J,{className:"h-9 w-44",placeholder:"Filter by agent or message…",value:c,onChange:O=>d(O.target.value),"aria-label":"Search chats"}),E&&e.jsx(b,{variant:"ghost",size:"sm",onClick:T,children:"Clear filters"}),e.jsx("div",{className:"ml-auto",children:e.jsx(go,{})})]}),C&&e.jsx("div",{ref:t,children:e.jsx(jd,{enabled:s})}),A.length===0&&!E?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[e.jsx("div",{className:"pointer-events-none mb-2 w-full max-w-sm opacity-20 select-none",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-44 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-muted size-4 rounded"}),e.jsx("div",{className:"bg-muted h-3 w-24 rounded"}),e.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})})]})}),e.jsx(zr,{className:"text-muted-foreground/50 size-10"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No activity yet"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages between your agents show up here."})]})]}):A.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[e.jsx(Ur,{className:"text-muted-foreground/50 size-10"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No messages match your filters"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try different filters."})]}),e.jsx(b,{variant:"ghost",size:"sm",onClick:T,children:"Clear filters"})]}):e.jsx("div",{className:"space-y-2",children:e.jsx(Le,{mode:"popLayout",children:A.map(O=>{const k=y.current!==null&&!y.current.has(O.id)?vd:Nd;return e.jsx(Te.div,{...k,children:e.jsx(xd,{conversation:O})},O.id)})})})]})]})}const tn={healthy:Ee.success,degraded:Ee.warning,critical:Ee.error};function Cd(s){return s==null?"—":s<1?"<1ms":`${Math.round(s)}ms`}function Sd(s,t,n){const a=s.totalMessages>0?s.failedCount/s.totalMessages:0;if(n===0)return{state:"healthy",message:"No connections yet"};if(a>.5||t===0){const r=Math.round(a*100);return{state:"critical",message:`${s.failedCount} messages had errors today (${r}%)`}}if(t<n||a>=.05){const r=n-t;return r>0?{state:"degraded",message:`${r} connection${r>1?"s":""} disconnected`}:{state:"degraded",message:`${s.failedCount} error${s.failedCount!==1?"s":""} in the last day`}}return{state:"healthy",message:`${t} connection${t>1?"s":""} active`}}function Ad(s){const{data:t=[],isLoading:n}=Wn(s),a=t.flatMap(o=>o.instances),r=a.length,i=a.filter(o=>o.status.state==="connected").length;return{total:r,connected:i,isLoading:n}}function Td({enabled:s=!0,onFailedClick:t}){const n=ft(),{data:a,isLoading:r}=Nt(),{total:i,connected:o,isLoading:l}=Ad(s&&n);if(!n||!s||r||l||!a)return null;const{state:c,message:d}=Sd(a,o,i),u=(c==="degraded"||c==="critical")&&t!=null,x=Cd(a.avgDeliveryLatencyMs),h=`${a.totalMessages} messages today · ${a.failedCount} errors · ${x} average delivery`;return e.jsx(Kr,{children:e.jsx("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs",children:c==="healthy"?e.jsxs(Br,{children:[e.jsx(Wr,{asChild:!0,children:e.jsxs("span",{className:"flex min-w-0 flex-1 cursor-default items-center gap-1.5",children:[e.jsx("span",{className:`size-2 shrink-0 rounded-full ${tn[c]}`,"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:d}),a.avgDeliveryLatencyMs!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:x})]})]})}),e.jsx(qr,{side:"bottom",children:h})]}):e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:`size-2 shrink-0 rounded-full ${tn[c]}`,"aria-hidden":"true"}),u?e.jsx("button",{type:"button",onClick:t,className:"truncate text-left hover:underline","aria-label":`${d}. Show messages with problems`,children:d}):e.jsx("span",{className:"truncate",children:d})]})})})}function Ed(){const{data:s}=qn();return s!=null&&s.newAgentRecordUnreadable?e.jsxs("div",{"data-testid":"permissions-record-unreadable",className:"text-muted-foreground rounded-md border px-3 py-2 text-sm",children:[e.jsx("p",{role:"status",children:"Some agents may do less than their own settings allow."}),e.jsxs(Cs,{className:"mt-1",children:[e.jsx("p",{children:"DorkOS couldn’t read its list of checked agents."}),e.jsx("p",{children:"Each agent gets the stricter of its own and everyone’s settings."}),e.jsx("p",{children:"It tries again when you add or remove an agent."})]})]}):null}function nn(s){const t=s instanceof Error?s.message:"";return t&&!/^HTTP \d+$/.test(t)?t:"Couldn’t change that. Try again."}function Od(s){var p,f;const t=U(),n=V(),[a,r]=m.useState(null),[i,o]=m.useState(null),l=Y({queryKey:$t,queryFn:()=>t.listSessionRelayPasskeys(),enabled:s,retry:!1,refetchOnWindowFocus:!0}),c=((p=l.data)==null?void 0:p.keys)??[],d=ge({mutationFn:async g=>{try{const y=await g.send();if(!g.pending.go(y.approveUrl))throw new Error("Couldn’t open your browser. Try again.")}catch(y){throw g.pending.close(),y}},onMutate:()=>r(null),onSuccess:()=>o(c.length),gcTime:0,onError:g=>r(nn(g))}),u=ge({mutationFn:g=>g(),onMutate:()=>r(null),onSuccess:g=>n.setQueryData($t,g),gcTime:0,onError:g=>r(nn(g))}),x={onSettled:()=>d.reset()},h={onSettled:()=>u.reset()};return{keys:c,damaged:((f=l.data)==null?void 0:f.damaged)===!0,busy:d.isPending||u.isPending,waiting:i!==null&&c.length<=i,error:a,add:(g,y)=>{const N=Hr();if(!N){r("Allow pop-ups for this page, then try again.");return}d.mutate({send:()=>t.startSessionRelayPasskey({label:g,password:y}),pending:N},x)},remove:(g,y)=>u.mutate(()=>t.removeSessionRelayPasskey(g,y),h),removeDamaged:g=>u.mutate(()=>t.removeDamagedSessionRelayPasskeys(g),h)}}function la({prompt:s,onClose:t}){const n=m.useId(),[a,r]=m.useState(""),i=()=>{r(""),t()};return e.jsx(me,{open:s!==null,onOpenChange:o=>!o&&i(),children:e.jsx(xe,{children:e.jsxs("form",{className:"space-y-4",onSubmit:o=>{o.preventDefault(),s==null||s.run(a),i()},children:[e.jsxs(te,{children:[e.jsx(ne,{children:s==null?void 0:s.title}),e.jsx(ae,{children:"Enter your password for this computer."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:n,children:"Password"}),e.jsx(ht,{id:n,value:a,onChange:o=>r(o.target.value),autoComplete:"current-password"})]}),e.jsxs(re,{children:[e.jsx(ie,{type:"button",children:"Cancel"}),e.jsx(b,{type:"submit",disabled:!a,children:s==null?void 0:s.confirm})]})]})})})}function Rd({open:s,onClose:t,passkeys:n}){const a=m.useId(),r=m.useId(),[i,o]=m.useState(""),[l,c]=m.useState(""),d=()=>{o(""),c(""),t()};return e.jsx(me,{open:s,onOpenChange:u=>!u&&d(),children:e.jsx(xe,{children:e.jsxs("form",{className:"space-y-4",onSubmit:u=>{u.preventDefault(),n.add(i.trim(),l),d()},children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Add a passkey"}),e.jsx(ae,{children:"Your browser opens to create it. Then come back here."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:a,children:"Name"}),e.jsx(J,{id:a,value:i,onChange:u=>o(u.target.value),placeholder:"MacBook passkey",maxLength:64,autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:r,children:"Your password for this computer"}),e.jsx(ht,{id:r,value:l,onChange:u=>c(u.target.value),autoComplete:"current-password"})]}),e.jsxs(re,{children:[e.jsx(ie,{type:"button",children:"Cancel"}),e.jsx(b,{type:"submit",disabled:!i.trim()||!l,children:"Continue"})]})]})})})}function Dd(){const s=Od(!0),[t,n]=m.useState(!1),[a,r]=m.useState(null);return e.jsxs("div",{className:"space-y-2",children:[e.jsx(la,{prompt:a,onClose:()=>r(null)}),e.jsx(Rd,{open:t,onClose:()=>n(!1),passkeys:s}),s.damaged?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-destructive text-xs",children:"Passkey file is damaged. Remove it to start again."}),e.jsx(b,{variant:"outline",size:"sm",disabled:s.busy,onClick:()=>r({title:"Remove the damaged passkey file?",confirm:"Remove",run:s.removeDamaged}),children:"Remove"})]}):s.keys.length===0?e.jsx("p",{className:"text-muted-foreground text-xs",children:"No passkeys yet."}):e.jsx("ul",{className:"space-y-1","data-testid":"approval-passkeys",children:s.keys.map(i=>e.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsxs("span",{className:"min-w-0 truncate",children:[i.label,e.jsxs("span",{className:"text-muted-foreground ml-2 font-mono text-xs",children:["…",i.credentialId.slice(-6)]})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:["Added ",we(i.addedAt)]}),e.jsx(b,{variant:"ghost",size:"sm",disabled:s.busy,"aria-label":`Remove ${i.label}`,onClick:()=>r({title:"Remove this passkey?",confirm:"Remove",run:o=>s.remove(i.credentialId,o)}),children:"Remove"})]})]},i.credentialId))}),e.jsx(b,{variant:"outline",size:"sm",disabled:s.busy||s.damaged,onClick:()=>n(!0),children:"Add a passkey"}),s.waiting&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Finish in your browser. This list updates when you return."}),s.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:s.error})]})}function Id({atThisComputer:s}){const t=Yr();return e.jsxs("div",{className:"space-y-1.5","data-testid":"approval-passkeys-section",children:[e.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Approvals from the web"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Approve tool calls from your hub with a passkey made for this computer."}),t||!s?e.jsx("p",{className:"text-muted-foreground text-xs",children:"Manage passkeys at this computer."}):e.jsx(Dd,{})]})}function Pd(s){if(!s)return"";try{return new URL(s).host}catch{return s}}function Ld({access:s,status:t}){const n=m.useId(),a=m.useId(),r=m.useId(),[i,o]=m.useState(""),[l,c]=m.useState(t.suggestedName),[d,u]=m.useState(""),x=!s.canChange||s.busy;return e.jsxs("form",{className:"space-y-3",onSubmit:h=>{h.preventDefault(),s.link({linkCode:i.trim(),computerName:l.trim(),password:d}),u("")},children:[e.jsx("p",{className:"text-sm",children:"Your DorkOS account, or DorkOS itself, can run commands here through your agents."}),e.jsxs(Ye,{children:[e.jsxs(Ve,{className:"text-muted-foreground hover:text-foreground group flex items-center gap-1 text-xs",children:[e.jsx(Be,{className:"size-3 transition-transform group-data-[state=open]:rotate-90"}),"Learn more"]}),e.jsx(Qe,{children:e.jsx("p",{className:"text-muted-foreground pt-1 text-xs",children:"Chats pass through the hub that made this code. Turn this off here anytime."})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:n,children:"Link code"}),e.jsx(J,{id:n,value:i,onChange:h=>o(h.target.value),placeholder:"XXXX-XXXX-XXXX-XXXX@your-hub",autoComplete:"off",spellCheck:!1,disabled:x})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:a,children:"Name for this computer"}),e.jsx(J,{id:a,value:l,onChange:h=>c(h.target.value),maxLength:64,disabled:x})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(X,{htmlFor:r,children:"Your password for this computer"}),e.jsx(ht,{id:r,value:d,onChange:h=>u(h.target.value),autoComplete:"current-password",disabled:x})]}),e.jsx(b,{type:"submit",size:"sm",disabled:x||!i.trim()||!l.trim()||!d,children:"Link"})]})}function an({value:s,title:t,description:n,disabled:a,comingSoon:r}){const i=m.useId();return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(qs,{value:s,id:i,disabled:a,className:"mt-0.5"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(X,{htmlFor:i,className:L("text-sm",a&&"opacity-60"),children:[t,r&&e.jsx(se,{variant:"secondary",className:"ml-2",children:"Coming soon"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:n})]})]})}function _d(s){return s.paused?"Paused":s.connected?"Connected":"Not connected"}function $d({access:s,status:t}){const n=!s.canChange||s.busy,[a,r]=m.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(la,{prompt:a,onClose:()=>r(null)}),e.jsxs("div",{children:[e.jsx("p",{className:"truncate text-sm",children:Pd(t.hubOrigin)}),e.jsx("p",{className:"text-muted-foreground text-xs",children:_d(t)})]}),e.jsxs(Tn,{value:t.level,onValueChange:i=>i==="full"?r({title:"Allow Full control from the web?",confirm:"Allow",run:o=>s.setLevel("full",o)}):s.setLevel(i),"aria-label":"What the web can do here",disabled:n,children:[e.jsx(an,{value:"chat",title:"Chat",description:"Read and send messages. Questions and approvals wait for you here.",disabled:n}),e.jsx(an,{value:"full",title:"Full control",description:"Also open the terminal, files and settings from the web.",disabled:!0,comingSoon:!0})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{variant:"outline",size:"sm",disabled:n,onClick:()=>t.paused?r({title:"Resume chat from the web?",confirm:"Resume",run:s.resume}):s.pause(),children:t.paused?"Resume":"Pause"}),e.jsxs(me,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"outline",size:"sm",disabled:n,children:"Unlink"})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Unlink from your hub?"}),e.jsx(ae,{children:"Chatting from the web stops now. You can link again anytime."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:s.unlink,children:"Unlink"})]})]})]})]})]})}function Fd({className:s}){const t=Hi(),n=t.status,a=Yi((n==null?void 0:n.linked)===!0);return!t.available||!n?null:e.jsxs("section",{"aria-labelledby":"web-access-title",className:L("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsx("p",{id:"web-access-title",className:"text-sm font-medium",children:"Chat from the web"}),!t.canChange&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Change this on the computer DorkOS runs on."}),n.linked?e.jsxs(e.Fragment,{children:[e.jsx($d,{access:t,status:n}),e.jsx(Vi,{devices:a}),e.jsx(Id,{atThisComputer:t.atThisComputer})]}):e.jsx(Ld,{access:t,status:n}),t.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.error})]})}const ca="/sw.js",Fs=["push","subscriptions"],Md=["push","vapid-public-key"],St="dorkos.push.device-id";function zd(){var j,C;const s=U(),t=V(),[n,a]=m.useState(null),[r,i]=m.useState(rn),o=Ud(),l=Y({queryKey:[...Md],queryFn:()=>s.getPushVapidPublicKey(),enabled:o==="available",staleTime:1/0}),c=Y({queryKey:[...Fs],queryFn:()=>s.listPushSubscriptions()}),d=ge({mutationFn:async E=>{const A=await Kd(E);return s.registerPushSubscription(A)},onSuccess:E=>{Hd(E.subscription.id),i(E.subscription.id),t.invalidateQueries({queryKey:[...Fs]})},meta:{suppressErrorToast:!0}}),u=ge({mutationFn:E=>s.deletePushSubscription(E),onSuccess:(E,A)=>{rn()===A&&(on(),i(null),Bd()),t.invalidateQueries({queryKey:[...Fs]})},meta:{suppressErrorToast:!0}}),x=(j=c.data)==null?void 0:j.subscriptions,h=x!==void 0&&r!==null&&!x.some(E=>E.id===r),p=h?null:r;m.useEffect(()=>{h&&on()},[h]);const f=((C=l.data)==null?void 0:C.key)??null,g=m.useCallback(async()=>{if(a(null),f===null){a("Couldn’t set up notifications on this computer. Try again later.");return}try{await d.mutateAsync(f)}catch(E){a(Wd(E))}},[d,f]),y=m.useCallback(async E=>{a(null);try{await u.mutateAsync(E)}catch{a("Couldn’t remove that device. Try again.")}},[u]);return{availability:o!=="available"?o:l.isSuccess&&f===null?"server-unavailable":"available",devices:x??[],devicesLoaded:c.isSuccess,localDeviceId:p,subscribe:g,remove:y,isPending:d.isPending||u.isPending,error:n}}function Ud(){return dt()?"desktop-shell":typeof window>"u"||typeof navigator>"u"||!("serviceWorker"in navigator)||!("PushManager"in window)?"unsupported":window.isSecureContext===!1?"insecure-context":"available"}async function Kd(s){var c,d;const t=await navigator.serviceWorker.register(ca,{scope:"/"});await navigator.serviceWorker.ready;const n=await Notification.requestPermission();if(n!=="granted")throw new da(n);const i=(await t.pushManager.getSubscription()??await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:qd(s)})).toJSON(),o=(c=i.keys)==null?void 0:c.p256dh,l=(d=i.keys)==null?void 0:d.auth;if(typeof i.endpoint!="string"||!o||!l)throw new Error("This browser produced a subscription DorkOS cannot use.");return{endpoint:i.endpoint,keys:{p256dh:o,auth:l}}}async function Bd(){try{const s=await navigator.serviceWorker.getRegistration(ca),t=await(s==null?void 0:s.pushManager.getSubscription());await(t==null?void 0:t.unsubscribe())}catch{}}class da extends Error{constructor(t){super(`Notification permission was ${t}`),this.permission=t,this.name="PushPermissionError"}}function Wd(s){return s instanceof da?s.permission==="denied"?"Your browser blocks notifications from DorkOS. Allow them in this site’s settings.":"Allow notifications so DorkOS can reach this device.":"Couldn’t set up this device for notifications. Try again."}function qd(s){const t=s.padEnd(s.length+(4-s.length%4)%4,"="),n=atob(t.replace(/-/g,"+").replace(/_/g,"/")),a=new Uint8Array(new ArrayBuffer(n.length));for(let r=0;r<n.length;r+=1)a[r]=n.charCodeAt(r);return a}function rn(){try{return window.localStorage.getItem(St)}catch{return null}}function Hd(s){try{window.localStorage.setItem(St,s)}catch{}}function on(){try{window.localStorage.removeItem(St)}catch{}}const Yd=[{value:1,label:"1 min"},{value:2,label:"2 min"},{value:5,label:"5 min"},{value:15,label:"15 min"},{value:"never",label:"Never"}];function Vd(s){return s==="never"?"never":Number(s)}function Qd(){const{prefs:s,setPrefs:t,isPending:n}=$n(),a=zd(),r=Fn(),i=(r.data??[]).some(c=>c.enabled&&c.canInitiate),o=s.escalation.phoneAfterMinutes==="never",l=a.devicesLoaded&&r.isSuccess;return e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{orientation:"vertical",label:"Reach you elsewhere after",description:"DorkOS pings your devices and chat apps. Answering one quiets the rest.",children:e.jsx(ks,{value:String(s.escalation.phoneAfterMinutes),onValueChange:c=>t({escalation:{phoneAfterMinutes:Vd(c)}}),disabled:n,"aria-label":"Wait before reaching you elsewhere",children:Yd.map(c=>e.jsx($e,{value:String(c.value),children:c.label},String(c.value)))})}),l&&!o&&a.devices.length===0&&!i&&e.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:"Nothing can reach you yet. Add this device, or a chat app in Connections."}),e.jsx(_,{orientation:"vertical",label:"Devices DorkOS can reach",description:Gd(a.availability),children:e.jsxs("div",{className:"w-full space-y-3",children:[a.devices.length>0&&e.jsx("ul",{className:"divide-border divide-y","aria-label":"Subscribed devices",children:a.devices.map(c=>e.jsxs("li",{className:"flex items-center justify-between gap-4 py-2 first:pt-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm",children:Xd(c,a.localDeviceId)}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Added ",we(c.createdAt)]})]}),e.jsx(b,{variant:"ghost",size:"sm",disabled:a.isPending,onClick:()=>void a.remove(c.id),children:"Remove"})]},c.id))}),a.availability==="available"&&a.localDeviceId===null&&e.jsx(b,{variant:"outline",size:"sm",disabled:a.isPending,onClick:()=>void a.subscribe(),children:"Add this device"}),a.error!==null&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:a.error})]})})]})})}function Gd(s){switch(s){case"available":return"Added browsers get notified even when DorkOS is closed. Add your phone’s browser.";case"desktop-shell":return"The desktop app shows its own notifications. Add your phone’s browser instead.";case"unsupported":return"This browser can’t get notifications while DorkOS is closed. Other devices still work.";case"insecure-context":return"This needs a secure connection. Open DorkOS at localhost or over HTTPS.";case"server-unavailable":return"DorkOS couldn’t set up notifications on this computer. No device can be added now."}}function Xd(s,t){return s.id===t?"This device":s.service==="unknown"?"Another device":`Another device (${s.service})`}function Jd(){return e.jsx(Oi,{})}function Zd({onClick:s}){return e.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"})}function eu(){const{setTheme:s}=pt(),t=Oe(n=>n.resetAppearance);return e.jsx(Zd,{onClick:()=>{t(),s("system")}})}function su(){const{theme:s,setTheme:t}=pt(),{fontFamily:n,setFontFamily:a,fontSize:r,setFontSize:i}=Oe();return e.jsx("div",{className:"space-y-4",children:e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Theme",children:e.jsxs(oe,{value:s,onValueChange:t,children:[e.jsx(le,{className:"w-32",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"dark",children:"Dark"}),e.jsx(P,{value:"system",children:"System"})]})]})}),e.jsx(_,{label:"Font family",children:e.jsxs(oe,{value:n,onValueChange:o=>a(o),children:[e.jsx(le,{className:"w-40",children:e.jsx(ce,{})}),e.jsx(de,{children:Vr.map(o=>e.jsx(P,{value:o.key,children:e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:o.displayName}),e.jsx("span",{className:"text-muted-foreground truncate text-xs",children:o.description})]})},o.key))})]})}),e.jsx(_,{label:"Font size",children:e.jsxs(oe,{value:r,onValueChange:o=>i(o),children:[e.jsx(le,{className:"w-32",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(P,{value:"small",children:"Small"}),e.jsx(P,{value:"medium",children:"Medium"}),e.jsx(P,{value:"large",children:"Large"})]})]})})]})})})}function tu(){const{prefs:s,setPrefs:t,isPending:n}=$n(),{permission:a,request:r}=Ii(),i=dt(),[o,l]=m.useState(!1);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Knock when an agent needs you",description:"Plays when something waits on you.",checked:s.sounds.knock,onCheckedChange:c=>t({sounds:{knock:c}}),disabled:n}),e.jsx($,{label:"Chime when everything is answered",description:"Plays when nothing is waiting.",checked:s.sounds.allClear,onCheckedChange:c=>t({sounds:{allClear:c}}),disabled:n}),e.jsx($,{label:"Chime every time a turn finishes",description:"Every reply. Noisy with many agents.",checked:s.sounds.turnEnd,onCheckedChange:c=>t({sounds:{turnEnd:c}}),disabled:n})]})}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx(_,{label:"Notifications from your browser",description:nu(a,i),children:!i&&a==="default"&&e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void r(),children:"Turn on"})}),e.jsx($,{label:"Notify when work finishes while you’re away",description:"Anything waiting on you always gets through.",checked:s.notifyOnTurnCompleteWhileAway,onCheckedChange:c=>t({notifyOnTurnCompleteWhileAway:c}),disabled:n})]})}),e.jsx(Qd,{}),e.jsx(ws,{open:o,onOpenChange:l,trigger:"Get these on your phone",children:e.jsxs("ol",{className:"text-muted-foreground list-decimal space-y-1.5 pl-4 text-xs",children:[e.jsx("li",{children:"Open DorkOS on your phone, at your Remote access address."}),e.jsx("li",{children:"Choose “Add to Home Screen”. iPhone needs this for notifications."}),e.jsx("li",{children:"Open Settings there and add it as a device above."})]})})]})}function nu(s,t){return t?"The desktop app shows its own notifications.":s==="granted"?"Allowed, even while this tab is hidden.":s==="denied"?"Blocked. Change it in your browser’s settings for this site.":s==="unsupported"?"This browser cannot show notifications.":"Not turned on yet."}const au=[{key:"maxAgentDepth",label:"Replies in a row",description:`Agents pause after this many replies in a row. Default: ${rs.maxAgentDepth}.`,details:["Your next message starts the count over.","Set it to 0 to stop automatic replies."],min:De.maxAgentDepth.min,max:De.maxAgentDepth.max},{key:"maxTurnsPerAgentPerCascade",label:"Replies from one agent",description:`Most turns one agent takes in one back-and-forth. Default: ${rs.maxTurnsPerAgentPerCascade}.`,details:["Progress notes an agent posts while it works don’t count extra."],min:De.maxTurnsPerAgentPerCascade.min,max:De.maxTurnsPerAgentPerCascade.max},{key:"maxAutomaticTurnsPerRoomPerHour",label:"Replies in one room each hour",description:`Most automatic replies one room runs in an hour. Default: ${rs.maxAutomaticTurnsPerRoomPerHour}.`,details:["It keeps one busy room from using up the whole allowance below."],min:De.maxAutoTurnsPerHour.min,max:De.maxAutoTurnsPerHour.max},{key:"maxAutomaticTurnsTotalPerHour",label:"Replies everywhere each hour",description:`Most automatic replies across all rooms in an hour. Default: ${rs.maxAutomaticTurnsTotalPerHour}.`,details:["This caps what automatic replies can cost you.","No room can set its own."],min:Pt.min,max:Pt.max}],ln="Chats at once";function ru(){const{limits:s,unsupported:t,loadError:n,maxConcurrentTurnsPerAgent:a,setLimits:r}=Qr();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"How far agents reply to each other, and how many chats each runs."}),e.jsxs(Cs,{className:"text-xs",children:[e.jsx("p",{children:"Every message you send starts the reply counts over."}),e.jsx("p",{children:"A room can have limits of its own, in the panel beside it."})]})]}),s===null?e.jsx(R,{children:e.jsx(D,{children:n!==null?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t load these settings. Close Settings and open it again."}):t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This version of DorkOS doesn’t have these settings. Update to change them."}):[0,1,2,3,4].map(i=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx(ee,{className:"h-4 w-40"}),e.jsx(ee,{className:"h-3 w-full max-w-xs"})]}),e.jsx(ee,{className:"h-9 w-24"})]},i))})}):e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Limit automatic replies",description:s.turnLimitsEnabled?"Agents pause when they reach a limit below.":"Agents reply to each other without limit until you press Stop.",checked:s.turnLimitsEnabled,onCheckedChange:i=>r({turnLimitsEnabled:i})}),au.map(i=>e.jsx(_,{orientation:"vertical",label:i.label,description:e.jsxs(e.Fragment,{children:[i.description," ",e.jsx(qe,{label:`About ${i.label.toLowerCase()}`,children:i.details.map(o=>e.jsx("p",{children:o},o))})]}),children:e.jsx(xs,{"aria-label":i.label,value:s[i.key],min:i.min,max:i.max,disabled:!s.turnLimitsEnabled,onCommit:o=>r({[i.key]:o})})},i.key))]})}),s!==null&&a!==null&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(_,{orientation:"vertical",label:ln,description:e.jsxs(e.Fragment,{children:[`How many chats one agent works in at once. Default: ${Gr}.`," ",e.jsx(qe,{label:"About chats at once",children:e.jsx("p",{children:"Higher is faster, but turns that change the same files can collide."})})]}),children:e.jsx(xs,{"aria-label":ln,value:a,min:Lt.min,max:Lt.max,onCommit:i=>r({maxConcurrentTurnsPerAgent:i})})})})})]})}function iu(){const s=fe(),t=Xr(),n=Jr(),a=ft();Un(s.section);const r=()=>{s.close(),n()};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Access and chat app settings. Your apps are on the"," ",e.jsx(b,{variant:"link",className:"h-auto p-0 text-xs",onClick:r,children:"Connections page"}),"."]}),e.jsxs("section",{"data-section":"ways","aria-labelledby":"settings-connection-ways",className:"space-y-3",children:[e.jsx("h3",{id:"settings-connection-ways",className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"How DorkOS reaches your apps"}),e.jsx(Nl,{onManageAccount:()=>{t.onValueChange("account")},onOpenConnectionsPage:r})]}),e.jsxs("section",{"data-section":"chat-apps","aria-labelledby":"settings-chat-apps",className:"space-y-3",children:[e.jsx("h3",{id:"settings-chat-apps",className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Chat apps"}),e.jsx(Tl,{}),a&&e.jsxs(Ye,{children:[e.jsx(Ve,{className:"text-muted-foreground hover:text-foreground focus-ring rounded-md text-sm font-medium",children:"Message history"}),e.jsxs(Qe,{className:"space-y-3 pt-3",children:[e.jsx(Td,{enabled:!0}),e.jsx(wd,{enabled:!0})]})]})]})]})}function ou(){const{data:s}=qn(),t=oa();return s?e.jsxs(e.Fragment,{children:[e.jsx(bo,{files:s.filesAndCommands,preset:s.preset,onChange:n=>t.changeTrustStop(null,n),disabled:t.isPending,runtimeLabel:n=>je(n).label}),t.writeError?e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.writeError}):null]}):null}function lu(){const s=Pn(),{close:t}=fe();return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ed,{}),e.jsx(R,{children:e.jsx(D,{className:"@container space-y-2",children:e.jsx(Qi,{surface:"settings"})})}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"What agents may do"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Allowed runs without asking. Ask waits for your yes. Blocked is refused."," ",fo," ",Mt[0]," ",Mt[1]]}),e.jsx(R,{children:e.jsxs(D,{className:"divide-border divide-y",children:[e.jsx(ou,{}),e.jsx(jo,{scope:{kind:"default"}})]})})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"History"}),e.jsx(R,{children:e.jsx(D,{children:e.jsx(yo,{})})})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Connected accounts have their own permissions, in"," ",e.jsx(b,{variant:"link",size:"sm",className:"h-auto p-0 text-sm",onClick:()=>{t(),s({...Ln.connections()})},children:"Connections"}),"."]})]})}function ua(s,t){return(s==null?void 0:s.enabled)===!0&&s.runtimes[t]==="wired"}function cu(s,t){var n,a;return((a=(n=s==null?void 0:s.defaults)==null?void 0:n[t])==null?void 0:a.runsOn)==="credits"||ua(s,t)}function du(s,t,n){const a=t==="runtime"?`A change moves every ${s} chat, so it can't be made while ${s} is in the middle of a reply.`:`A change applies to new ${s} chats. One already going stays on what it started on.`;return n?`DorkOS chose credits when you linked, because ${s} had no sign-in. ${a}`:a}function uu({type:s,runsOn:t,chosenByDorkos:n,scope:a,caveat:r,canChooseCredits:i,pending:o,failure:l,onChange:c}){const d=xt(s);return e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","data-testid":"credits-runs-on-section",children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Runs on"}),e.jsxs(ks,{"aria-label":`What ${d} runs on`,className:"w-full",value:t,disabled:o,onValueChange:u=>c(u),children:[e.jsx($e,{value:"own-sign-in",children:e.jsxs("span",{className:"truncate",children:["Your ",d," sign-in"]})}),e.jsx($e,{value:"credits",disabled:!i&&t!=="credits",children:e.jsx("span",{className:"truncate",children:On})})]}),e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"credits-runs-on-note",children:t==="credits"&&!i?`${d} can’t run on credits now, so new work stops. Switch to your own sign-in.`:du(d,a,n)}),r?e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"credits-runs-on-caveat",children:r}):null,l!==null&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:l})]})}function mu({type:s}){var l,c;const{data:t}=ys(),n=bs(),a=(l=Zr(s))==null?void 0:l.credits,r=a==null?void 0:a.scope;if(!cu(t,s))return null;const i=(c=t==null?void 0:t.defaults)==null?void 0:c[s],o=(i==null?void 0:i.runsOn)==="credits"?"credits":"own-sign-in";return e.jsx(uu,{type:s,runsOn:o,chosenByDorkos:o==="credits"&&(i==null?void 0:i.chosenBy)==="default",scope:r,...a!=null&&a.caveat?{caveat:a.caveat}:{},canChooseCredits:ua(t,s),pending:n.isPending,failure:n.isError?`Couldn’t change that. ${Nn(n.error)??"Try again in a moment."}`:null,onChange:d=>{d!==o&&n.mutate({runtime:s,useCredits:d==="credits"})}})}function xu({type:s}){const{byId:t,byPath:n}=ut(s),a=t.get(ke)??n.values().next().value;return na(a)?e.jsxs("section",{className:"bg-muted/30 space-y-3 rounded-lg border p-3","aria-label":`${je(s).label} usage`,children:[e.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Usage"}),e.jsx(ra,{usage:a})]}):null}const Ms={"claude-accounts":()=>e.jsx(Vc,{}),"credits-runs-on":({type:s})=>e.jsx(mu,{type:s}),"opencode-power-source":({type:s})=>e.jsx(Jc,{type:s}),"runtime-usage":({type:s})=>e.jsx(xu,{type:s})};function hu(s,t){var n;return((n=Ms[s])==null?void 0:n.call(Ms,t))??null}function pu(s){const t=U(),{data:n}=Y({queryKey:["doe-inference"],queryFn:()=>t.getDoeInference(),enabled:s}),a=(n==null?void 0:n.autoProtocol)??null,r=!s||n===void 0?null:n.inference!==null?"own":a!==null?"credits":"none",{data:i}=Y({queryKey:["doe-credits-models",a],queryFn:()=>t.getDoeCreditsModels(a??"anthropic-messages"),enabled:r==="credits"});return{state:r,models:i==null?void 0:i.models.map(o=>({value:o.id,displayName:o.displayName,description:"",contextWindow:o.contextWindow,maxOutputTokens:o.maxOutputTokens,paidFromCredits:!0}))}}const gu="a model chosen by DorkOS";function fu(s){switch(s){case"credits":return{inheritLabel:Eo,description:"Which model new chats start on."};case"own":return{description:"Change it in the DorkOS setup."};case"none":return{inheritLabel:"None yet",description:"Connect AI to choose a model."};case null:return{}}}const ju={login:{id:"reconnect",cancelLabel:"Keep current sign-in"},"provider-picker":{id:"change",cancelLabel:"Keep current source"}};function yu(s,t){return ri(s)==="provider-picker"?t?{kind:"provider-picker",connect:{kind:"provider-picker",label:"Change power source"},currentProvider:t}:null:ii.includes(s)?{kind:"login",connect:{kind:"login",label:`Reconnect ${xt(s)}`}}:null}function bu(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function vu({type:s,isDefault:t,trustStop:n,globalStop:a,onChangeTrustStop:r,onMakeDefault:i}){var Tt,Et,Ot,Rt,Dt;const{data:o}=Se(),{nameFor:l,resolvedAccount:c,inherited:d}=vs();ut(ei.includes(s)?s:null,{fetch:!0});const{data:u}=Ge(),{data:x}=mt(),{registered:h}=si(s),p=ye(),f=V(),g=U(),[y,N]=m.useState(!1),[j,C]=m.useState(!1),[E,A]=m.useState(null),[T,O]=m.useState(!1),v=ti(x,s,h),k=v.state==="ready",Z=ko(),H=pu(s==="doe"&&Z),F=H.state==="credits"&&k,M=je(s),W=Hn(u,s),S=(Tt=o==null?void 0:o.executionDefaults)==null?void 0:Tt.perRuntime.find(z=>z.runtime===s),K=(S==null?void 0:S.model)??null,I=x==null?void 0:x.runtimes[s],be=ni(x,s),{data:Re}=Y({...ai(g,{runtime:s}),enabled:k&&(y||K!==null)});function Je(z){A(null),p.mutate({runtimes:z},{onSuccess:()=>{f.invalidateQueries({queryKey:G.all}),O(!0)},onError:ns=>A(bu(ns))})}const Ze=W?W.configSection!==null:!0,he=W===void 0;function es(z){const ns=W==null?void 0:W.configSection;ns&&Je({[ns]:z})}const Ss=n??a,As={"claude-accounts":!(o==null?void 0:o.claudeCode)||d||!c?null:l(c),"opencode-power-source":I!=null&&I.provider?Yn(I.provider):null},Ue=K?(Re??[]).find(z=>z.value===K):void 0,ss=Ic({ready:k,settings:W,model:K,models:F?H.models:Re,...F?{inheritModelLabel:gu}:{},effort:S==null?void 0:S.effort,modelTakesEffort:Ue?Ue.supportsEffort??!1:void 0,trustStop:Ss,trustInherited:n===null,sectionValues:As}),ve=I==null?void 0:I.dependencies.find(z=>z.status!=="satisfied"&&z.installHint),w=(ve==null?void 0:ve.installHint)??((Et=M.setup)==null?void 0:Et.installCommand),B=(ve==null?void 0:ve.infoUrl)??((Ot=M.setup)==null?void 0:Ot.infoUrl),Q=!k&&v.connect?e.jsx("div",{"data-testid":`runtime-card-connect-${s}`,children:v.connect.kind==="install"?e.jsx(Nu,{type:s,label:v.connect.label,installCommand:w,installInfoUrl:B}):Ys({type:s,connect:v.connect})}):null,q=k?yu(s,I==null?void 0:I.provider):null;!q&&j&&C(!1);const ts=q?ju[q.kind]:null,ma=q&&ts&&j?e.jsxs("div",{className:"space-y-2","data-testid":`runtime-${ts.id}-panel-${s}`,children:[Ys({type:s,connect:q.connect,...q.currentProvider?{currentProvider:q.currentProvider}:{},onConnected:()=>C(!1)}),e.jsx("button",{type:"button",onClick:()=>C(!1),className:"focus-ring text-muted-foreground hover:text-foreground rounded-sm text-xs transition-colors","data-testid":`runtime-${ts.id}-cancel-${s}`,children:ts.cancelLabel})]}):null,xa=I?I.dependencies.map(z=>e.jsx(ku,{dep:z},z.name)):M.setup?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Not set up here. Install it, then turn on ",e.jsxs(No,{children:["runtimes.",s]})," in your DorkOS config."]}),e.jsx(yt,{command:M.setup.installCommand,infoUrl:M.setup.infoUrl,copyLabel:`Copy install command for ${M.label}`})]}):void 0,Ae=I==null?void 0:I.dependencies.filter(z=>z.status!=="satisfied"),ha=I?e.jsx(se,{variant:"secondary",className:L("text-xs",Ae!=null&&Ae.length?"text-status-warning-fg":""),children:Ae!=null&&Ae.length?`${Ae.length} missing`:`${I.dependencies.length} ${I.dependencies.length===1?"check":"checks"}`}):void 0;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Ec,{type:s,...M.subtitle?{subtitle:M.subtitle}:{},ready:k,isDefault:t,onMakeDefault:i,expanded:y,onToggleExpanded:()=>N(z=>!z),summary:ss,...be?{expiringSignIn:be}:{},connectSlot:Q,...q&&!j?{reconnect:{kind:q.kind,onOpen:()=>C(!0)}}:{},reconnectPanel:ma,model:{models:F?H.models:Re,value:K,onChange:z=>es({defaultModel:z}),disabled:he||s==="doe"&&!F,...fu(H.state==="credits"&&!k?"none":H.state)},effort:{supportsEffort:(W==null?void 0:W.supportsEffort)??!0,selectedModel:Ue,configuredModelId:K,value:(S==null?void 0:S.effort)??null,onChange:z=>es({defaultEffort:z}),disabled:he},trust:{descriptors:((Dt=(Rt=u==null?void 0:u.capabilities[s])==null?void 0:Rt.permissionModes)==null?void 0:Dt.values)??[],stop:n,globalStop:a,onChange:r,disabled:he},storesDefaults:Ze,sections:W==null?void 0:W.sections,renderSection:z=>hu(z,{type:s}),setupDetails:xa,setupBadge:ha}),T&&e.jsx("p",{className:"text-muted-foreground px-4 text-xs","data-testid":`runtime-card-timing-${s}`,children:"Applies to new chats only."}),E&&e.jsxs("p",{className:"text-destructive flex items-start gap-1.5 px-4 text-xs","data-testid":`runtime-card-error-${s}`,children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:E})]})]})}function Nu({type:s,label:t,installCommand:n,installInfoUrl:a}){const r=je(s),i=_n(),{provision:o,isPending:l,isError:c,errorMessage:d,progress:u,result:x}=wo(s);if(l||x!=null&&x.ok){const h=(u==null?void 0:u.message)??`Installing ${r.label}…`;return e.jsxs(Te.div,{className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:i?!1:{opacity:0},animate:{opacity:1},"data-testid":"provision-progress",children:[e.jsx(fs,{size:"xs",className:L("text-muted-foreground shrink-0",i&&"animate-none")}),e.jsx(Le,{mode:"wait",children:e.jsx(Te.span,{className:"truncate text-xs",initial:i?!1:{opacity:0},animate:{opacity:1},exit:i?void 0:{opacity:0},transition:{duration:.2},children:h},h)})]})}return c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:d}),n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"You can install it yourself instead:"}),e.jsx(yt,{command:n,infoUrl:a,copyLabel:`Copy install command for ${r.label}`})]}),e.jsx(b,{size:"sm",onClick:o,children:"Try again"})]}):e.jsxs("div",{children:[e.jsx(b,{size:"sm",onClick:o,children:t}),n&&e.jsx(Co,{command:n,runtimeLabel:r.label})]})}function ku({dep:s}){const t=s.status==="satisfied";return e.jsxs("div",{className:"space-y-2","data-testid":"runtime-setup-dependency",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-x-2",children:[t?e.jsx(Ke,{className:"text-status-success size-3.5 shrink-0"}):e.jsx(ue,{className:"text-status-warning-dot size-3.5 shrink-0"}),e.jsx("span",{className:"text-sm",children:s.name}),e.jsx("p",{className:"text-muted-foreground col-start-2 mt-1 text-xs",children:t&&s.version?`v${s.version}`:s.description})]}),!t&&(s.installHint||s.infoUrl)&&e.jsx(yt,{command:s.installHint,infoUrl:s.infoUrl,copyLabel:`Copy install command for ${s.name}`})]})}function wu(s){return s instanceof Error&&s.message||"Couldn’t save that. Try again."}function Cu(){var C,E,A;const s=mt(),{data:t}=Ge(),{data:n}=Se(),a=ye(),r=V(),i=oa(),o=_n(),[l,c]=m.useState(null),d=vo(t?Object.keys(t.capabilities):[]),u=n==null?void 0:n.executionDefaults,x=(u==null?void 0:u.runtime)??"claude-code",h=(u==null?void 0:u.perRuntime)??[],p=(C=t==null?void 0:t.capabilities[x])==null?void 0:C.permissionModes,f=((A=(E=p==null?void 0:p.values)==null?void 0:E.find(T=>T.id===p.default))==null?void 0:A.stop)??"ask",g=(u==null?void 0:u.trustStop)??f;function y(T){c(null),a.mutate({runtimes:{default:T}},{onSuccess:()=>void r.invalidateQueries({queryKey:G.all}),onError:O=>c(wu(O))})}const N=h.map(T=>({runtime:T.runtime,label:je(T.runtime).label,stop:T.trustStop})),j=l??i.writeError;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Runtimes are the AI tools that do the work."}),e.jsx("button",{type:"button",onClick:()=>void s.refetch(),disabled:s.isFetching,"aria-label":"Check runtimes again",title:"Check again",className:"focus-ring text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1 transition-colors disabled:opacity-50","data-testid":"runtimes-recheck",children:e.jsx(at,{className:L("size-3.5",s.isFetching&&!o&&"animate-spin")})})]}),e.jsx("div",{className:"space-y-3",children:d.map(T=>{var O;return e.jsx(vu,{type:T,isDefault:T===x,trustStop:((O=h.find(v=>v.runtime===T))==null?void 0:O.trustStop)??null,globalStop:g,onChangeTrustStop:v=>i.changeTrustStop(T,v),onMakeDefault:()=>y(T)},T)})}),j&&e.jsxs("p",{className:"text-destructive flex items-start gap-1.5 text-xs","data-testid":"runtimes-tab-error",children:[e.jsx(ue,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{children:j})]}),e.jsx(Lc,{stop:(u==null?void 0:u.trustStop)??null,effectiveStop:f,runtimes:N,onChange:T=>i.changeTrustStop(null,T),onChangeRuntime:(T,O)=>i.changeTrustStop(T,O)}),e.jsx(ed,{})]})}const Su=["fatal","error","warn","info","debug","trace"];function Au(){const s=U(),{data:t,isLoading:n,isError:a,error:r,refetch:i,isRefetching:o}=Y({queryKey:G.current(),queryFn:()=>s.getConfig(),staleTime:3e4});return e.jsx("div",{className:"space-y-3",children:a&&!t?e.jsx(Ru,{detail:r instanceof Error?r.message:null,onRetry:()=>void i(),isRetrying:o}):n?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((l,c)=>e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx("div",{className:"bg-muted animate-breath h-4 w-24 rounded"}),e.jsx("div",{className:"bg-muted animate-breath h-4 w-16 rounded"})]},c))}):t?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[t.isDevMode?e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Development build"}),e.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"Running from source. Update checks are off."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Zs,{label:"Version",value:t.version}),t.latestVersion&&Pi(t.latestVersion,t.version)&&e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Update available: v",t.latestVersion]})}),e.jsxs("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:["Run"," ",e.jsx("code",{className:"text-3xs rounded bg-amber-100 px-1 py-0.5 font-mono dark:bg-amber-900/50",children:"npm update -g dorkos"})," ","to update"]})]})]}),e.jsx(Du,{port:t.port}),e.jsx(Zs,{label:"Uptime",value:Iu(t.uptime)})]}),e.jsx(Tu,{config:t}),e.jsx(Eu,{config:t})]}):null})}function Tu({config:s}){const[t,n]=m.useState(!1),a=[{label:"Working folder",value:s.workingDirectory},{label:"Data folder",value:s.dorkHome},{label:"Boundary",value:s.boundary},{label:"Node.js",value:s.nodeVersion}];return e.jsx(ws,{open:t,onOpenChange:n,trigger:"Diagnostics",action:e.jsx(Ce,{value:a.map(r=>`${r.label}: ${r.value}`).join(`
12
+ `),label:"Copy all diagnostics"}),children:e.jsx("div",{className:"space-y-1",children:a.map(r=>e.jsx(Zs,{label:r.label,value:r.value,mono:!0,truncate:!0},r.label))})})}function Eu({config:s}){const[t,n]=m.useState(!1),a=U(),r=V(),i=s.logging,o=m.useCallback(async l=>{const c=i??{level:"info",maxLogSizeKb:500,maxLogFiles:14};await a.updateConfig({logging:{...c,...l}}),await r.invalidateQueries({queryKey:G.all})},[a,r,i]);return i?e.jsxs(ws,{open:t,onOpenChange:n,trigger:"Logging",badge:e.jsx("span",{className:"text-muted-foreground text-xs",children:i.level}),children:[e.jsx(_,{label:"Log level",description:"How much detail DorkOS writes down.",children:e.jsxs(oe,{value:i.level,onValueChange:l=>o({level:l}),children:[e.jsx(le,{className:"w-28",children:e.jsx(ce,{})}),e.jsx(de,{children:Su.map(l=>e.jsx(P,{value:l,children:l},l))})]})}),e.jsx(_,{label:"Biggest log file",description:"When DorkOS starts a new file.",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{type:"number",min:100,max:10240,value:i.maxLogSizeKb,onChange:l=>{const c=parseInt(l.target.value,10);c>=100&&c<=10240&&o({maxLogSizeKb:c})},className:"w-24"}),e.jsx("span",{className:"text-muted-foreground text-xs",children:"KB"})]})}),e.jsx(_,{label:"Days of logs kept",description:"From 1 to 30, up to 200 MB in all.",children:e.jsx(J,{type:"number",min:1,max:30,value:i.maxLogFiles,onChange:l=>{const c=parseInt(l.target.value,10);c>=1&&c<=30&&o({maxLogFiles:c})},className:"w-20"})}),s.dorkHome&&e.jsx(Ou,{dorkHome:s.dorkHome})]}):null}function Ou({dorkHome:s}){const{copied:t,failed:n,copy:a}=ot(),r=`${s}/logs`;function i(){return t?e.jsx("span",{className:"text-xs",children:"Copied"}):n?e.jsx("span",{className:"text-destructive text-xs",children:"Couldn’t copy"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"max-w-40 truncate font-mono text-xs",dir:"rtl",title:r,children:e.jsx("bdi",{dir:"ltr",children:r})}),e.jsx(jn,{className:"size-3 shrink-0"})]})}return e.jsx(_,{label:"Log location",description:"Where DorkOS keeps these files.",children:e.jsx("button",{type:"button",onClick:()=>void a(r),className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 transition-colors",children:i()})})}function Ru({detail:s,onRetry:t,isRetrying:n}){return e.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[e.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Can’t reach the DorkOS server"}),e.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"It may be restarting. Try again shortly."}),s?e.jsx("p",{className:"text-3xs mt-1 font-mono break-words text-amber-700/80 dark:text-amber-300/80",children:s}):null,e.jsx(b,{variant:"outline",size:"sm",className:"mt-2",onClick:t,disabled:n,"aria-label":"Try reaching the server again",children:n?"Trying…":"Try again"})]})}function Du({port:s}){const t=`http://localhost:${s}`;return e.jsxs("div",{className:"border-border/60 -mx-1 mt-3 mb-3 space-y-2 border-b px-1 pb-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Address"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Where DorkOS runs on this computer. Bookmark it or share it."})]}),e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-1.5 gap-y-2",children:[e.jsx(cn,{url:t,label:"DorkOS address",children:e.jsx("button",{type:"button",onClick:()=>oi(t),className:"text-muted-foreground hover:text-foreground focus-ring rounded-sm p-1 transition-colors","aria-label":"Open DorkOS in your browser",title:"Open in your browser",children:e.jsx(Ns,{className:"size-3.5"})})}),e.jsx("p",{className:"text-muted-foreground col-span-2 text-xs",children:"For MCP clients like Claude Code or Cursor. Paste it, don’t visit it."}),e.jsx(cn,{url:`${t}/mcp`,label:"MCP endpoint"})]})]})}function cn({url:s,label:t,children:n}){return e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"bg-muted min-w-0 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ce,{value:s,label:`Copy the ${t}`}),n]})]})}function Zs({label:s,value:t,mono:n,truncate:a,muted:r}){const{copied:i,failed:o,copy:l}=ot();function c(){return i?e.jsx("span",{className:"text-muted-foreground text-xs",children:"Copied"}):o?e.jsx("span",{className:"text-destructive text-xs",children:"Couldn’t copy"}):e.jsx("span",{className:L("text-right text-sm",n&&"font-mono",a&&"max-w-48 min-w-0 truncate",r&&"text-muted-foreground"),dir:a?"rtl":void 0,title:t,children:e.jsx("bdi",{dir:"ltr",children:t})})}return e.jsxs("button",{type:"button",onClick:()=>void l(t),className:"hover:bg-muted/50 active:bg-muted/70 -mx-1 flex w-full items-center justify-between gap-4 rounded px-1 py-1 transition-colors duration-100",children:[e.jsx("span",{className:"text-muted-foreground shrink-0 text-sm",children:s}),c()]})}function Iu(s){const t=Math.floor(s/3600),n=Math.floor(s%3600/60),a=Math.floor(s%60),r=[];return t>0&&r.push(`${t}h`),n>0&&r.push(`${n}m`),r.push(`${a}s`),r.join(" ")}function Pu({scheduler:s,onUpdate:t}){return e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Scheduled runs at once",description:"How many tasks can run at once.",children:e.jsx(J,{type:"number",min:1,max:10,value:s.maxConcurrentRuns,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=10&&t({maxConcurrentRuns:a})},className:"w-20"})}),e.jsx(_,{label:"Run history",description:"How many finished runs to keep.",children:e.jsx(J,{type:"number",min:1,max:1e4,value:s.retentionCount,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&t({retentionCount:a})},className:"w-24"})})]})}function dn(s){return s.lockedByEnv?s.running:s.enabledInConfig??s.running}function un(s,t,n){const a=Lu(s,t);return a?`${n} ${a}`:n}function Lu(s,t){if(s.lockedByEnv)return`${t} on this computer controls this switch.`;const n=s.enabledInConfig??s.running;return n&&!s.running&&s.initError?"It’s on, but didn’t start last time. Nothing is running.":n!==s.running?"Saved. Applies the next time DorkOS starts.":null}function _u({tasks:s,relay:t,onTasksChange:n,onRelayChange:a}){return e.jsxs("div",{className:"space-y-4","data-testid":"background-systems",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"These run in the background. Turning one off also stops its tools."}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Scheduled runs",description:un(s,"DORKOS_TASKS_ENABLED","Runs scheduled tasks when they’re due. Off means nothing runs on a schedule."),checked:dn(s),onCheckedChange:n,disabled:s.lockedByEnv===!0}),e.jsx($,{label:"Agent messaging",description:un(t,"DORKOS_RELAY_ENABLED","Carries messages between agents and chat apps. Off stops Telegram and Slack too."),checked:dn(t),onCheckedChange:a,disabled:t.lockedByEnv===!0})]})})]})}function $u(){return e.jsxs("div",{className:"flex gap-3 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[e.jsx(Me,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Not for agents that run inside DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Those agents already have these tools. Adding them twice stops every tool call."}),e.jsxs(Cs,{className:"text-xs",children:[e.jsx("p",{children:"Claude rejects the repeated tool names with “Tool names must be unique”."}),e.jsx("p",{children:"This is for apps running on their own: Claude Code, Cursor, Windsurf."})]})]})]})}function Fu({endpoint:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Endpoint"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"The address to give other apps"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsx(Ce,{value:s})]})]})}function Mu({rateLimit:s,onUpdate:t}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx($,{label:"Cap incoming requests",description:"Limits how often other apps can call DorkOS.",checked:s.enabled,onCheckedChange:n=>t({enabled:n}),ariaLabel:"Toggle rate limiting"}),s.enabled&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:"mcp-max-requests",className:"text-muted-foreground text-xs",children:"Max requests"}),e.jsx(J,{id:"mcp-max-requests",type:"number",min:1,max:1e3,value:s.maxPerWindow,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=1e3&&t({maxPerWindow:a})},className:"w-20"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:"mcp-window-secs",className:"text-muted-foreground text-xs",children:"Window (sec)"}),e.jsx(J,{id:"mcp-window-secs",type:"number",min:1,max:3600,value:s.windowSecs,onChange:n=>{const a=parseInt(n.target.value,10);a>=1&&a<=3600&&t({windowSecs:a})},className:"w-20"})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Changes apply after DorkOS restarts."})]})]})}function zu(s,t){const n=t?`Bearer ${t}`:"Bearer dork_mcp_YOUR_API_KEY";return{claudeCode:JSON.stringify({mcpServers:{"dorkos-external":{type:"http",url:s,headers:{Authorization:n}}}},null,2),claudeCodeCli:`claude mcp add-json dorkos-external '${JSON.stringify({type:"http",url:s,headers:{Authorization:n}})}'`,cursor:JSON.stringify({mcpServers:{"dorkos-external":{url:s,headers:{Authorization:n}}}},null,2),windsurf:JSON.stringify({mcpServers:{"dorkos-external":{serverUrl:s,headers:{Authorization:n}}}},null,2)}}function Uu({endpoint:s,apiKey:t}){const[n,a]=m.useState(!1),[r,i]=m.useState("claude-code"),o=zu(s,t),l=r==="claude-code"?o.claudeCode:r==="cursor"?o.cursor:o.windsurf;return e.jsxs(Ye,{open:n,onOpenChange:a,children:[e.jsxs(Ve,{className:"flex w-full items-center justify-between text-sm font-medium",children:[e.jsx("span",{children:"Setup instructions"}),e.jsx(We,{className:L("text-muted-foreground size-3.5 transition-transform duration-150",!n&&"-rotate-90")})]}),e.jsx(Qe,{children:e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("div",{className:"bg-muted flex gap-0.5 rounded-md p-0.5",children:["claude-code","cursor","windsurf"].map(c=>e.jsx("button",{onClick:()=>i(c),className:L("flex-1 rounded-sm px-3 py-1.5 text-xs font-medium transition-colors",r===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c==="claude-code"?"Claude Code":c==="cursor"?"Cursor":"Windsurf"},c))}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:l}),e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(Ce,{value:l})})]}),r==="claude-code"&&e.jsxs("div",{className:"relative",children:[e.jsx("p",{className:"text-muted-foreground mb-1 text-xs",children:"Or add it from the terminal:"}),e.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:o.claudeCodeCli}),e.jsx("div",{className:"absolute right-2 bottom-2",children:e.jsx(Ce,{value:o.claudeCodeCli})})]})]})})]})}function Ku({mcp:s,authEnabled:t}){const n=U(),a=V(),[r,i]=m.useState(!1),o=m.useCallback(()=>a.invalidateQueries({queryKey:G.all}),[a]),l=m.useCallback(async f=>{await n.updateConfig({mcp:{enabled:f,rateLimit:s.rateLimit}}),await o()},[n,s.rateLimit,o]),c=m.useCallback(async f=>{await n.updateConfig({mcp:{enabled:s.enabled,rateLimit:{...s.rateLimit,...f}}}),await o()},[n,s.enabled,s.rateLimit,o]),[d,u]=m.useState(null),x=m.useCallback(async()=>{const{localToken:f}=await n.revealMcpLocalToken();u(f)},[n]),h=m.useCallback(async()=>{const{localToken:f}=await n.rotateMcpLocalToken();u(f),await o()},[n,o]),p=s.enabled?s.authConfigured?e.jsx(se,{variant:"outline",tone:"success",children:"Enabled"}):e.jsx(se,{variant:"outline",tone:"warning",children:"Not protected"}):e.jsx(se,{variant:"secondary",children:"Disabled"});return e.jsx(R,{children:e.jsxs(Ye,{open:r,onOpenChange:i,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Connect other apps to DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Lets Claude Code, Cursor and others use DorkOS tools"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[p,e.jsx(He,{checked:s.enabled,onCheckedChange:l,"aria-label":"Toggle access for other apps"}),e.jsx(Ve,{asChild:!0,children:e.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${r?"Collapse":"Expand"} MCP server settings`,children:e.jsx(We,{className:L("size-3.5 transition-transform duration-150",!r&&"-rotate-90")})})})]})]}),e.jsx(Qe,{children:e.jsxs(D,{className:"border-t",children:[e.jsx($u,{}),e.jsx(Bu,{}),e.jsx(Fu,{endpoint:s.endpoint}),e.jsx(Wu,{authSource:s.authSource,authEnabled:t,revealedToken:d,onReveal:x,onRotate:h}),e.jsx(Mu,{rateLimit:s.rateLimit,onUpdate:c}),e.jsx(Uu,{endpoint:s.endpoint,apiKey:d})]})})]})})}function Bu(){const s=Pn(),{close:t}=fe();return e.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["To give an agent another server’s tools, open its profile."," ",e.jsx(b,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>{t(),s({...Ln.team()})},children:"Open the Team page"})]})}function Wu({authSource:s,authEnabled:t,revealedToken:n,onReveal:a,onRotate:r}){return s==="env"?e.jsx(_,{label:"Authentication",description:"Protected by the MCP_API_KEY environment variable.",children:e.jsx(se,{variant:"outline",children:"Environment variable"})}):s==="local-token"?e.jsx(qu,{revealedToken:n,onReveal:a,onRotate:r}):s==="none"&&!t?e.jsx(_,{label:"Authentication",description:"Couldn’t make a token for other apps. Use a personal API key instead.",children:e.jsx(se,{variant:"outline",tone:"warning",children:"No key yet"})}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"text-muted-foreground size-3.5"}),e.jsx("p",{className:"text-sm font-medium",children:"Authentication"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Other apps sign in with a personal API key."}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Make one in Settings → Login & security. Send it as a"," ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]})]})}function qu({revealedToken:s,onReveal:t,onRotate:n}){const[a,r]=m.useState(!1),[i,o]=m.useState(!1),[l,c]=m.useState(!1);async function d(){c(!0);try{await t()}catch(x){_e.error("Couldn’t show the token.",{description:x instanceof Error?x.message:"Try again in a moment."})}finally{c(!1)}}async function u(){o(!0);try{await n(),r(!1)}catch(x){_e.error("Couldn’t make a new token.",{description:x instanceof Error?x.message:"The old one still works."})}finally{o(!1)}}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"text-muted-foreground size-3.5"}),e.jsx("p",{className:"text-sm font-medium",children:"Local MCP token"})]}),e.jsxs(me,{open:a,onOpenChange:r,children:[e.jsx(Fe,{asChild:!0,children:e.jsx(b,{variant:"outline",size:"sm",children:"Rotate"})}),e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Rotate the local MCP token?"}),e.jsx(ae,{children:"The old token stops working. Apps need the new one. This can’t be undone."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{disabled:i,onClick:x=>{x.preventDefault(),u()},children:i?"Rotating…":"Rotate token"})]})]})]})]}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Paste it into your MCP client as a ",e.jsx("code",{className:"font-mono",children:"Bearer"})," token."]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"It guards tools that change things. Read-only checks work without it."}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Only apps on this computer can use it. Other devices need a personal API key."}),s?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:s}),e.jsx(Ce,{value:s})]}):e.jsx(b,{variant:"outline",size:"sm",onClick:d,disabled:l,children:l?"Revealing…":"Reveal token"})]})}function Hu(){var x,h,p,f,g,y,N;const s=lt(),t=ft(),n=li(),a=U(),r=V(),{section:i}=fe();Un(i);const{data:o}=Y({queryKey:G.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),l=o==null?void 0:o.scheduler,c=m.useCallback(async j=>{const C=l??{maxConcurrentRuns:1,retentionCount:100};await a.updateConfig({scheduler:{...C,...j}}),await r.invalidateQueries({queryKey:G.all})},[a,r,l]),d=m.useCallback(async j=>{await a.updateConfig({scheduler:{enabled:j}}),await r.invalidateQueries({queryKey:G.all})},[a,r]),u=m.useCallback(async j=>{await a.updateConfig({relay:{enabled:j}}),await r.invalidateQueries({queryKey:G.all})},[a,r]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(_u,{tasks:{running:n,enabledInConfig:(x=o==null?void 0:o.tasks)==null?void 0:x.enabledInConfig,lockedByEnv:(h=o==null?void 0:o.tasks)==null?void 0:h.lockedByEnv,initError:(p=o==null?void 0:o.tasks)==null?void 0:p.initError},relay:{running:t,enabledInConfig:(f=o==null?void 0:o.relay)==null?void 0:f.enabledInConfig,lockedByEnv:(g=o==null?void 0:o.relay)==null?void 0:g.lockedByEnv,initError:(y=o==null?void 0:o.relay)==null?void 0:y.initError},onTasksChange:j=>void d(j),onRelayChange:j=>void u(j)}),l&&n&&e.jsx(R,{children:e.jsx(D,{children:e.jsx(Pu,{scheduler:l,onUpdate:c})})}),!s&&e.jsx(fc,{}),(o==null?void 0:o.mcp)&&e.jsx("div",{"data-section":"external-mcp",children:e.jsx(Ku,{mcp:o.mcp,authEnabled:((N=o.auth)==null?void 0:N.enabled)===!0})})]})}const mn=["hub","computers"];function Yu(){var d;const s=U(),t=V(),[n,a]=m.useState(null),[r,i]=m.useState(null),o=Y({queryKey:mn,queryFn:()=>s.listHubComputers(),retry:!1,staleTime:15e3}),l=ge({mutationFn:()=>s.createHubLinkCode(),onMutate:()=>i(null),onSuccess:u=>a(u),onError:()=>i("Couldn’t make a code. Try again.")}),c=ge({mutationFn:u=>s.removeHubComputer(u),onMutate:()=>i(null),onSuccess:()=>t.invalidateQueries({queryKey:mn}),onError:()=>i("Couldn’t remove that computer. Try again.")});return{isHub:o.isSuccess,computers:((d=o.data)==null?void 0:d.computers)??[],linkCode:n,error:r,minting:l.isPending,removing:c.isPending?c.variables??null:null,mint:()=>l.mutate(),dismissCode:()=>a(null),remove:u=>c.mutate(u)}}function Vu(s){const t=new Date(s);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function Qu({code:s,onDone:t}){const n=Vu(s.expiresAt);return e.jsxs("div",{className:"bg-muted space-y-2 rounded-md p-3",children:[e.jsx("p",{className:"text-sm",children:"Paste this code into DorkOS on the computer to link."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 truncate font-mono text-sm","data-testid":"hub-link-code",children:s.linkCode}),e.jsx(Ce,{value:s.linkCode,label:"Copy code"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:n?`Works once, until ${n}.`:"Works once, for 10 minutes."}),e.jsx(b,{variant:"ghost",size:"sm",onClick:t,children:"Done"})]})]})}function Gu({computer:s,removing:t,onRemove:n}){const a=s.computerName??s.computerId;return e.jsxs("li",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm",children:a}),e.jsx("p",{className:"text-muted-foreground text-xs",children:s.connected?"Connected":"Not connected"})]}),e.jsx(b,{variant:"outline",size:"sm",onClick:n,disabled:t,"aria-label":`Remove ${a}`,children:"Remove"})]})}function Xu({className:s}){const t=Yu();return t.isHub?e.jsxs("section",{"aria-labelledby":"linked-computers-title",className:L("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{id:"linked-computers-title",className:"text-sm font-medium",children:"Linked computers"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Chat with the agents on your own computers from here."})]}),e.jsx(b,{size:"sm",onClick:t.mint,disabled:t.minting,children:"Link a computer"})]}),t.linkCode&&e.jsx(Qu,{code:t.linkCode,onDone:t.dismissCode}),t.error&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:t.error}),t.computers.length===0?e.jsx("p",{className:"text-muted-foreground text-xs",children:"No computers linked yet."}):e.jsx("ul",{className:"space-y-2",children:t.computers.map(n=>e.jsx(Gu,{computer:n,removing:t.removing===n.computerId,onRemove:()=>t.remove(n.computerId)},n.computerId))})]}):null}function Ju(){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Xu,{}),e.jsx(Fd,{}),e.jsxs(qo,{signedOut:e.jsx(Zu,{}),children:[e.jsx(Gi,{}),e.jsx(uc,{})]})]})}function Zu(){const{data:s}=ys(),t=Rl(s),n=ct();return e.jsxs("div",{className:"space-y-2",children:[t.length>0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"Link a DorkOS account to:"}),e.jsxs("ul",{className:"text-muted-foreground list-disc space-y-1 pl-5 text-sm",children:[e.jsxs("li",{children:["Use one account for ",t.join(" and "),": run"," ",t.length===1?"it":"them"," on your DorkOS credits."]}),e.jsx("li",{children:"See your plan, credits and seats here."})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Link a DorkOS account to see your plan, credits and seats here."}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Everything else works without one."})]}),e.jsx(Mn,{withSpaces:n})]})}const xn=["lan-access"],em=15e3;function sm(){const s=U(),t=V(),[n,a]=m.useState(!1),[r,i]=m.useState(null),{data:o}=Y({queryKey:xn,queryFn:()=>s.getLanAccess(),refetchInterval:em}),l=m.useCallback(async c=>{const d=async u=>{a(!0),i(null);try{const x=await s.setLanAccess(u);t.setQueryData(xn,x),t.invalidateQueries({queryKey:G.current()})}catch(x){(x==null?void 0:x.code)==="AUTH_REQUIRED_FOR_EXPOSURE"?ci({reason:"exposure",message:"Wi-Fi access needs a login.",onComplete:()=>void d(!0)}):i(x instanceof Error&&x.message?x.message:"Could not change that.")}finally{a(!1)}};await d(c)},[s,t]);return{status:o,busy:n,error:r,setEnabled:l}}function tm(s){const t=s.localName??s.addresses[0];return t?`http://${t}:${s.port}`:null}function hn({url:s,label:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("code",{className:"truncate text-sm",children:s}),e.jsx(Ce,{value:s,label:t})]})}function nm({status:s}){const t=tm(s);if(!t)return e.jsx("p",{className:"text-muted-foreground text-xs",children:"Join a Wi-Fi network to get an address."});const n=s.localName?s.addresses.map(a=>`http://${a}:${s.port}`):s.addresses.slice(1).map(a=>`http://${a}:${s.port}`);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(di,{url:t,size:160}),e.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"Scan with a phone or tablet on the same Wi-Fi."}),e.jsx(hn,{url:t,label:"Copy address"}),n.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"If that name doesn’t open, use:"}),n.map(a=>e.jsx(hn,{url:a,label:"Copy address"},a))]})]})}function am({className:s}){const{status:t,busy:n,error:a,setEnabled:r}=sm();if(!t)return null;const i=t.setByEnvironment!==null,o=i||!t.supported,l=a??t.error;return e.jsxs("section",{"aria-labelledby":"lan-access-title",className:L("border-border bg-muted/30 space-y-3 rounded-lg border p-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{id:"lan-access-title",className:"text-sm font-medium",children:"Let devices on my Wi-Fi in"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"For home or office Wi-Fi. It isn’t encrypted yet."})]}),e.jsx(He,{"aria-labelledby":"lan-access-title",checked:o?!1:t.enabled,onCheckedChange:c=>void r(c),disabled:n||o})]}),i&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[t.setByEnvironment," is set, so it decides where DorkOS listens."]}),l&&e.jsx("p",{className:"text-destructive text-xs",children:l}),t.listening&&e.jsx(nm,{status:t})]})}function rm(){const s=ui({open:!0}),t=mi({machine:s});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(xi,{machine:s,actions:t}),e.jsx(hi,{}),e.jsx(am,{})]})}function im(){const{data:s}=Se(),t=ye(),n=s==null?void 0:s.telemetry,a=(r,i)=>{t.mutate({telemetry:{[r]:i,userHasDecided:!0}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Nothing is shared unless a switch below is on."," ",e.jsx("a",{href:pi("/telemetry"),target:"_blank",rel:"noopener noreferrer",className:"text-foreground underline underline-offset-2",children:"Read the full contract"}),"."]}),e.jsxs(Cs,{className:"text-xs",children:[e.jsx("p",{children:"The three count switches are anonymous. They never send prompts, code or file paths."}),e.jsx("p",{children:"The counts never send before the first-run notice."}),e.jsx("p",{children:"Crash reports and AI run data are separate. Both start off."})]})]}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Share anonymous install counts",description:"Counts marketplace installs, to rank packages and spot broken ones.",checked:(n==null?void 0:n.install)??!1,onCheckedChange:r=>a("install",r),disabled:t.isPending}),e.jsx($,{label:"Share an anonymous daily heartbeat",description:"One anonymous ping a day, to count active installs. Exact payload below.",checked:(n==null?void 0:n.heartbeat)??!1,onCheckedChange:r=>a("heartbeat",r),disabled:t.isPending}),e.jsx($,{label:"Share anonymous feature-usage events",description:"Counts events like app start and finished setup, plus any install tag.",checked:(n==null?void 0:n.usage)??!1,onCheckedChange:r=>a("usage",r),disabled:t.isPending}),e.jsx($,{label:"Share AI run metadata",description:"Model, tokens, time and cost per turn. Never your prompts, code or chats.",checked:(n==null?void 0:n.aiMetadata)??!1,onCheckedChange:r=>a("aiMetadata",r),disabled:t.isPending}),e.jsx($,{label:"Share crash reports",description:"A scrubbed report to dorkos.ai when something breaks. No error messages, paths or code.",checked:(n==null?void 0:n.errorReporting)??!1,onCheckedChange:r=>a("errorReporting",r),disabled:t.isPending})]})}),e.jsx(Wo,{})]})}async function om(s){const t=new Map;for(let n=0;n<localStorage.length;n++){const a=localStorage.key(n);if(a===null)continue;const r=localStorage.getItem(a);r!==null&&t.set(a,r)}localStorage.clear();try{return await s()}catch(n){for(const[a,r]of t)localStorage.setItem(a,r);throw n}}function lm({open:s,onOpenChange:t,onResetComplete:n}){const[a,r]=m.useState(""),[i,o]=m.useState(!1),l=U(),c=a==="reset";async function d(){o(!0);try{const x=lo();if(x)await om(async()=>{co(await x.resetAllData())});else{const{token:h}=await l.prepareReset();await l.resetAllData("reset",h),localStorage.clear()}t(!1),n()}catch(x){_e.error("Couldn’t reset your data.",{description:x instanceof Error?x.message:"Some of it may already be gone. Try again."})}finally{o(!1)}}function u(x){x||(r(""),o(!1)),t(x)}return e.jsx(me,{open:s,onOpenChange:u,children:e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Reset all data?"}),e.jsx(ae,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"This deletes all DorkOS data for good, including:"}),e.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[e.jsx("li",{children:"Scheduled tasks and their run history"}),e.jsx("li",{children:"Agent messaging setup and messages"}),e.jsx("li",{children:"DorkOS’s list of your agents"}),e.jsx("li",{children:"Your config file and preferences"}),e.jsx("li",{children:"Server logs"})]}),e.jsx("p",{children:"DorkOS restarts on its own. This device’s preferences are cleared too."}),e.jsx("p",{className:"font-semibold",children:"This can’t be undone."})]})})]}),e.jsx("div",{className:"py-2",children:e.jsx(J,{placeholder:"Type “reset” to continue",value:a,onChange:x=>r(x.target.value),"data-testid":"reset-confirm-input"})}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{disabled:!c||i,onClick:d,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 dark:bg-destructive/60",children:i?"Resetting…":"Reset all data"})]})]})})}function cm({open:s,onOpenChange:t}){const n=Oe(i=>i.resetAllSettings),{setTheme:a}=pt();function r(){n(),a("system"),t(!1),_e.success("Settings are back to defaults")}return e.jsx(me,{open:s,onOpenChange:t,children:e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Reset all settings?"}),e.jsx(ae,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"Theme, text, toggles and layouts on this device go back to default."}),e.jsx("p",{children:"Nothing you made is deleted. Your projects, agents and chats stay."})]})})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{onClick:r,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 dark:bg-destructive/60",children:"Reset settings"})]})]})})}function dm({open:s,onOpenChange:t,onRestartComplete:n}){const[a,r]=m.useState(!1),i=U();async function o(){r(!0);try{await uo(i),t(!1),n()}catch(l){_e.error("Couldn’t restart DorkOS.",{description:l instanceof Error?l.message:"It may not have restarted. Try again."})}finally{r(!1)}}return e.jsx(me,{open:s,onOpenChange:t,children:e.jsxs(xe,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:"Restart DorkOS?"}),e.jsx(ae,{children:"Anything running right now stops. DorkOS is back in seconds."})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(pe,{disabled:a,onClick:o,children:a?"Restarting…":"Restart DorkOS"})]})]})})}function um(){const[s,t]=m.useState(!1),[n,a]=m.useState(!1),[r,i]=m.useState(!1),o=Oe(l=>l.setRestartOverlayOpen);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(R,{className:"border-destructive/50",children:e.jsxs(D,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Reset all settings"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Theme, text, toggles and layouts on this device go back to default."}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Your projects, agents and chats stay."})]}),e.jsx(b,{variant:"destructive",size:"sm",onClick:()=>a(!0),children:"Reset settings"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Reset all data"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Deletes everything DorkOS saved, then restarts it. Can’t be undone."})]}),e.jsx(b,{variant:"destructive",size:"sm",onClick:()=>t(!0),children:"Reset data"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Restart DorkOS"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Anything running right now stops."})]}),e.jsx(b,{variant:"destructive",size:"sm",onClick:()=>i(!0),children:"Restart"})]})]})}),e.jsx(cm,{open:n,onOpenChange:a}),e.jsx(lm,{open:s,onOpenChange:t,onResetComplete:()=>o(!0)}),e.jsx(dm,{open:r,onOpenChange:i,onRestartComplete:()=>o(!0)})]})}function mm(){const s=gi(),t=fi(),{setShowSessions:n}=ji();return s?e.jsx($,{label:"Show sessions",description:"See the working session behind each chat: model, account and context.",checked:t,onCheckedChange:n}):null}function xm(s,t){return s.split(".").reduceRight((a,r)=>({[r]:a}),t)}function hm(s,t,n){const a=[s];return t!==void 0&&a.push(t),n!==void 0&&a.push(`${n} on this computer controls this switch.`),a.join(" ")}function pm(){const{data:s,isLoading:t}=Se(),n=ye(),a=Oe(o=>o.devtoolsOpen),r=Oe(o=>o.toggleDevtools),i=(s==null?void 0:s.experiments)??[];return e.jsxs("div",{className:"space-y-6","data-testid":"experiments-tab",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Unfinished features you can try early."}),e.jsx(R,{children:e.jsxs(D,{children:[e.jsx($,{label:"Show dev tools",description:"Opens a panel showing what the app has loaded.",checked:a,onCheckedChange:()=>r()}),e.jsx(mm,{})]})}),t?null:i.length===0?e.jsx("p",{className:"text-muted-foreground text-sm","data-testid":"experiments-empty",children:"No experiments right now. New ones show up here."}):e.jsx(R,{children:e.jsx(D,{children:i.map(o=>e.jsx($,{label:o.title,description:hm(o.description,o.costNote,o.envOverride),checked:o.enabled,onCheckedChange:l=>n.mutate(xm(o.key,l)),disabled:o.lockedByEnv},o.key))})}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"These start off. Each one graduates or goes away."})]})}const gm={group:bi,storageKey:yi.SETTINGS_ADVANCED_OPEN},fm={profile:{icon:Ei,component:Jd},account:{icon:Lo,component:Ju},appearance:{icon:$o,component:su,actions:e.jsx(eu,{})},preferences:{icon:Fo,component:gc},notifications:{icon:Ti,component:tu},runtimes:{icon:Po,component:Cu},permissions:{icon:js,component:lu},connections:{icon:Ai,component:iu},security:{icon:Si,component:ml},"remote-access":{icon:Ci,component:rm},privacy:{icon:wi,component:im},server:{icon:Io,component:Au},tools:{icon:Xi,component:Hu},rooms:{icon:ki,component:ru},experiments:{icon:Ni,component:pm},danger:{icon:Me,component:um}};function jm(s){return vi(s).map(t=>({id:t.id,label:t.label,group:t.group,...fm[t.id]}))}function ox({open:s,onOpenChange:t}){const{activeTab:n}=fe(),a=lt(),r=m.useMemo(()=>jm(a),[a]);return e.jsx(zo,{open:s,onOpenChange:t,title:"Settings",description:"Application settings",defaultTab:"appearance",initialTab:n,tabs:r,extensionSlot:"settings.tabs",maximized:!0,foldedGroup:gm,testId:"settings-dialog"})}export{ox as SettingsDialog};