dorkos 0.121.0 → 0.123.0

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 +532 -373
  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-CtI8gbER.js → AboutPage-BmtoPqP9.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-CHTXfBS7.js → ActivityErrorState-CEzdFJiR.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-B8p4yYJL.js → ActivityPage-mFYgTr3e.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-CSuSz-92.js → ActivityRow-Bkc0kkim.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-Qnxn0cE5.js → AdapterIcon-DVgTrgnM.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-BG8H-Lld.js → AdapterSetupWizard-I03EluU5.js} +1 -1
  10. package/dist/client/assets/{AgentOptionRow-BWFQFynn.js → AgentOptionRow-DI1TzLaR.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-CL93SET3.js → AgentPicker-CBYeBzjf.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-CamX7Tvr.js → AgentRequestCard-DQ6GYoeE.js} +3 -3
  13. package/dist/client/assets/{AppearancePage-rN70_7ih.js → AppearancePage-62xIPNPn.js} +1 -1
  14. package/dist/client/assets/{ApplyToOverridesDialog-DeWaXbgm.js → ApplyToOverridesDialog-CrqkeHQb.js} +1 -1
  15. package/dist/client/assets/{AttentionSignalRow-CKcSWExi.js → AttentionSignalRow-Coe5pYX6.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-BwYaLf2P.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-D07cg75s.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-DqPDLYbF.js → BindingDialog-DVyxVXZM.js} +1 -1
  18. package/dist/client/assets/{BlintzCanvas-DoAZs5bz.js → BlintzCanvas-BmfkiUQJ.js} +3 -3
  19. package/dist/client/assets/{BlintzCanvas-xZ3u3nk7.css → BlintzCanvas-DCXOV_yN.css} +1 -1
  20. package/dist/client/assets/{CanvasCsvContent-ViqRJuhW.js → CanvasCsvContent-CRTr-AI7.js} +2 -2
  21. package/dist/client/assets/CanvasFileContent-rOmY1s3T.js +2 -0
  22. package/dist/client/assets/CanvasModel3dContent-D7oRT6ey.js +2 -0
  23. package/dist/client/assets/{ChatAppsOff-D0PbHYqF.js → ChatAppsOff-BmuOTq83.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorDiff-DFNSXeuV.js → CodeMirrorDiff-DidSWwYJ.js} +1 -1
  25. package/dist/client/assets/{CodeMirrorEditor-AgkgsSqN.js → CodeMirrorEditor-BUAWGbRo.js} +1 -1
  26. package/dist/client/assets/{CommitmentList-0V6QivXH.js → CommitmentList-uK4CKaz0.js} +1 -1
  27. package/dist/client/assets/{CommitmentsPage-i3XoHwBj.js → CommitmentsPage-BWITH1r2.js} +1 -1
  28. package/dist/client/assets/{ComputerResourceView-RPoBc-km.js → ComputerResourceView-adgF_EZU.js} +1 -1
  29. package/dist/client/assets/{ComputerViewer-2ugaCd0H.js → ComputerViewer-D87LhxwL.js} +1 -1
  30. package/dist/client/assets/{ConnectionAccessLists-DaPP4U96.js → ConnectionAccessLists-BFEFqcSZ.js} +1 -1
  31. package/dist/client/assets/{ConnectionsPage-BVqYvfk5.js → ConnectionsPage-Cd_cLoSY.js} +1 -1
  32. package/dist/client/assets/{ConventionPage-BoqncrFd.js → ConventionPage-BSztD-gU.js} +1 -1
  33. package/dist/client/assets/{ExtensionPageRoute-BrOEeNX3.js → ExtensionPageRoute-BSge6XRv.js} +1 -1
  34. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-DLwix3K7.js → FloatingTanStackRouterDevtools-CqogiFob-TO2CUPG0.js} +1 -1
  35. package/dist/client/assets/HandlePage-BKiqymRF.js +1 -0
  36. package/dist/client/assets/{HeartbeatPage-DgXhbaBJ.js → HeartbeatPage-DIJzdOhj.js} +1 -1
  37. package/dist/client/assets/{KeyEntry-CRr32Ae5.js → KeyEntry-DJnzW3Mu.js} +1 -1
  38. package/dist/client/assets/{LexicalField-DeAoA6yr.js → LexicalField-BxzNvIjJ.js} +1 -1
  39. package/dist/client/assets/{ManagesPage-ZBWYLTZx.js → ManagesPage-BQj8KbYA.js} +1 -1
  40. package/dist/client/assets/{Marketplace-iL5p8Omt.js → Marketplace-CIG5_a_H.js} +4 -4
  41. package/dist/client/assets/{MarketplaceSourcesView-CsNLVOdP.js → MarketplaceSourcesView-16HKvFK-.js} +1 -1
  42. package/dist/client/assets/{McpAppFrame-B1WPswgk.js → McpAppFrame-5xlga1jD.js} +1 -1
  43. package/dist/client/assets/{McpSigninBody-CJ28yu0o.js → McpSigninBody-COIHpHq_.js} +1 -1
  44. package/dist/client/assets/{Model3dViewer-BIZWdK8g.js → Model3dViewer-CQ0sA_kr.js} +1 -1
  45. package/dist/client/assets/NamePage-D7W6VMYd.js +1 -0
  46. package/dist/client/assets/{NewDirectMessageMenu-DRx9e9kM.js → NewDirectMessageMenu-D092y0K9.js} +1 -1
  47. package/dist/client/assets/{NotificationsPage-cfqgSuVy.js → NotificationsPage-CskOPdhh.js} +1 -1
  48. package/dist/client/assets/{OpenMeshSwitch-BIIuKDku.js → OpenMeshSwitch-BHRm328L.js} +1 -1
  49. package/dist/client/assets/{OperatorIdentityForm-BKUSGrs6.js → OperatorIdentityForm-C3op6BIC.js} +1 -1
  50. package/dist/client/assets/{PermissionHistory-Ctdqhib6.js → PermissionHistory-CKebTVkq.js} +1 -1
  51. package/dist/client/assets/{PermissionsPage-CYA_zdrV.js → PermissionsPage-XuPOSYll.js} +1 -1
  52. package/dist/client/assets/{PersonalityPopover-BR4Cpr2C.js → PersonalityPopover-BrZjxakx.js} +1 -1
  53. package/dist/client/assets/PhotoPage-Ch1at4A6.js +1 -0
  54. package/dist/client/assets/{PreviewRefusedNotice-D1Tl265t.js → PreviewRefusedNotice-BANdpT9O.js} +1 -1
  55. package/dist/client/assets/{ProfileFields-T3vVbHRC.js → ProfileFields-Dp68ebW9.js} +1 -1
  56. package/dist/client/assets/{ProfilePanelContainer-CParzTPA.js → ProfilePanelContainer-BKwGdI90.js} +1 -1
  57. package/dist/client/assets/{ProfileRolePicker-BU4eiMKn.js → ProfileRolePicker-ClOdfLda.js} +1 -1
  58. package/dist/client/assets/{PromptSuggestionChips-CGNQc2Tf.js → PromptSuggestionChips-zcW4UJ_O.js} +1 -1
  59. package/dist/client/assets/{ReportsToPopover-Dj5U_Ppi.js → ReportsToPopover-BwDVGqFg.js} +1 -1
  60. package/dist/client/assets/RoomSurface-CSKIvyHH.js +44 -0
  61. package/dist/client/assets/{RoomsPage-Cvs3h6f0.js → RoomsPage-CAvrRbPk.js} +1 -1
  62. package/dist/client/assets/{RunsOnPopover-BUlYwRW4.js → RunsOnPopover-CQ4t9EZ-.js} +1 -1
  63. package/dist/client/assets/{RuntimeConnectFlow-ChrvjC84.js → RuntimeConnectFlow--fVpIf0B.js} +1 -1
  64. package/dist/client/assets/{RuntimeSetupDialog-BK9yo7YF.js → RuntimeSetupDialog-COpyPrqL.js} +1 -1
  65. package/dist/client/assets/SeenDevices-BPw3UgjX.js +19 -0
  66. package/dist/client/assets/{SessionsPage-CWUwU3US.js → SessionsPage-FDyYzuXs.js} +1 -1
  67. package/dist/client/assets/{SettingsDialog-BApzy0J8.js → SettingsDialog-Bdws5dbS.js} +4 -4
  68. package/dist/client/assets/{SkillsPage-z3XnApNX.js → SkillsPage-PLXEY0LB.js} +1 -1
  69. package/dist/client/assets/{TaskDialogWrapper-BEWUpAlk.js → TaskDialogWrapper-CTcW70s8.js} +1 -1
  70. package/dist/client/assets/{TasksEmptyState-CLwpLnIO.js → TasksEmptyState-8RZxhRh6.js} +1 -1
  71. package/dist/client/assets/{TasksPage-CyHjr9OZ.js → TasksPage-C-EtQXKb.js} +1 -1
  72. package/dist/client/assets/{TeamComputerEntry-BHHIofx3.js → TeamComputerEntry-qx_19Htj.js} +1 -1
  73. package/dist/client/assets/{ToolsPage-CckCco8x.js → ToolsPage-D5-fx1EA.js} +1 -1
  74. package/dist/client/assets/{TopologyGraph-Dox7aWP3.js → TopologyGraph-1wtG1BE9.js} +1 -1
  75. package/dist/client/assets/{TourHost-CTBewD-a.js → TourHost-C664E8OY.js} +1 -1
  76. package/dist/client/assets/{UnlinkDialog-CFRgExId.js → UnlinkDialog-Di1oBFA_.js} +1 -1
  77. package/dist/client/assets/{WidgetErrorCard-Dx5oPMlF.js → WidgetErrorCard-BfgGzyqg.js} +1 -1
  78. package/dist/client/assets/_shell-BLTSXXDw.js +80 -0
  79. package/dist/client/assets/{_shell._home-DnBkgWs4.js → _shell._home-Hz78BY6-.js} +1 -1
  80. package/dist/client/assets/{_shell._home.activity-CVCC-EEI.js → _shell._home.activity-BxvI0gkw.js} +1 -1
  81. package/dist/client/assets/{_shell._home.index-Ck6jxwIx.js → _shell._home.index-Cqq81f3P.js} +1 -1
  82. package/dist/client/assets/{_shell._home.tasks-B7QQAZnA.js → _shell._home.tasks-Cth56CwC.js} +1 -1
  83. package/dist/client/assets/{_shell._home.workspaces-DlrRd9tv.js → _shell._home.workspaces-DkoOJSWz.js} +1 -1
  84. package/dist/client/assets/{_shell.channels-CiWehoyl.js → _shell.channels-D_GQU4RB.js} +4 -4
  85. package/dist/client/assets/{_shell.connections-CGP5hZHq.js → _shell.connections-DZrlxs4G.js} +1 -1
  86. package/dist/client/assets/{_shell.feedback-requests-BxxNvw6j.js → _shell.feedback-requests-BTxHdsfb.js} +1 -1
  87. package/dist/client/assets/_shell.marketplace-CZxkAmFz.js +1 -0
  88. package/dist/client/assets/_shell.marketplace_.sources-Q0BTQIuE.js +1 -0
  89. package/dist/client/assets/_shell.session-DvGL0DoX.js +63 -0
  90. package/dist/client/assets/{_shell.team-CsXH3NkS.js → _shell.team-ZxGwa39m.js} +3 -3
  91. package/dist/client/assets/_shell.x._extensionId-B6Tm5KuT.js +1 -0
  92. package/dist/client/assets/_shell.x._extensionId_._-B6Tm5KuT.js +1 -0
  93. package/dist/client/assets/{abnfDiagram-WEYOIA3C-CMdkyiQ3.js → abnfDiagram-WEYOIA3C-CzqPVMdw.js} +1 -1
  94. package/dist/client/assets/{access-copy-CW-z1oMH.js → access-copy-Dj09Xk4b.js} +1 -1
  95. package/dist/client/assets/{arc-Bw7tftQk.js → arc-Bgy7ExYl.js} +1 -1
  96. package/dist/client/assets/{architectureDiagram-ZHVYKT53-BhpXALtX.js → architectureDiagram-ZHVYKT53-DYfb2p9r.js} +1 -1
  97. package/dist/client/assets/{banner-EomQNDOH.js → banner-dlsHTWSf.js} +1 -1
  98. package/dist/client/assets/{blockDiagram-RJAE7QA3-Bxk_BuZv.js → blockDiagram-RJAE7QA3-BkOzLL8s.js} +1 -1
  99. package/dist/client/assets/{c4Diagram-XDPPPE54-CYN0FwR8.js → c4Diagram-XDPPPE54-CsZm4qpD.js} +1 -1
  100. package/dist/client/assets/{card-ww4ebz8h.js → card-Dj6ZfRgu.js} +1 -1
  101. package/dist/client/assets/channel-CGffcDRq.js +1 -0
  102. package/dist/client/assets/{chunk-2E7WHVMD-IPDvYcPa.js → chunk-2E7WHVMD-GA96Jfps.js} +1 -1
  103. package/dist/client/assets/{chunk-2Q5K7J3B-DZ5bU5Ax.js → chunk-2Q5K7J3B-CW2i0IkT.js} +1 -1
  104. package/dist/client/assets/{chunk-4EMNKR2T-DrsWxa6Y.js → chunk-4EMNKR2T-BwFvnPZg.js} +1 -1
  105. package/dist/client/assets/{chunk-55XCU76K-CiBbKG0b.js → chunk-55XCU76K-MOezzAAB.js} +1 -1
  106. package/dist/client/assets/{chunk-5VM5RSS4-B3K3MUav.js → chunk-5VM5RSS4-woru6zOC.js} +1 -1
  107. package/dist/client/assets/{chunk-JWPE2WC7-CjV5RcIh.js → chunk-JWPE2WC7-CUrKlP2M.js} +1 -1
  108. package/dist/client/assets/{chunk-VQ5W62QI-CWoRr0H2.js → chunk-VQ5W62QI-CqZ2cdEu.js} +1 -1
  109. package/dist/client/assets/{chunk-XXDRQBXY-E0nvzXiG.js → chunk-XXDRQBXY-ByAcvWaE.js} +1 -1
  110. package/dist/client/assets/{chunk-ZCHMQSOR-DFop6Lvt.js → chunk-ZCHMQSOR-3nkba9kj.js} +2 -2
  111. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-B7JJfc9z.js → classDiagram-v2-4MYWR3UA-B-zZKAmI.js} +1 -1
  112. package/dist/client/assets/{command-D4fLpJxA.js → command-BAOEURY7.js} +1 -1
  113. package/dist/client/assets/{cose-bilkent-JH36ORCC-BjNppl29.js → cose-bilkent-JH36ORCC-sCKxRv1H.js} +1 -1
  114. package/dist/client/assets/{cpu-DCe0Yyml.js → cpu-TtYQqONc.js} +1 -1
  115. package/dist/client/assets/{cynefin-EF2NZ3EQ-PmRntJwW.js → cynefin-EF2NZ3EQ-CXzvL5Cg.js} +1 -1
  116. package/dist/client/assets/{cynefinDiagram-WF24UDRP-Ctdbp_Vg.js → cynefinDiagram-WF24UDRP-C0wjhu9X.js} +1 -1
  117. package/dist/client/assets/{dagre-NK4GIZVX-5tvLY2ZW.js → dagre-NK4GIZVX-Doi2IPkY.js} +1 -1
  118. package/dist/client/assets/{diagram-CBK3MWTC-DZO-XBOO.js → diagram-CBK3MWTC-11TVuPel.js} +1 -1
  119. package/dist/client/assets/{diagram-I5XIIV2D-CWBbA1Pv.js → diagram-I5XIIV2D-CJq7fHFM.js} +1 -1
  120. package/dist/client/assets/{diagram-ODIL2UCW-hP5A1tGl.js → diagram-ODIL2UCW-2Ae6unuU.js} +1 -1
  121. package/dist/client/assets/{diagram-PFBEJUXE-EI_-RoN7.js → diagram-PFBEJUXE-BXza6_iz.js} +1 -1
  122. package/dist/client/assets/{diagram-RJA3I4VV-TrYq9A4Z.js → diagram-RJA3I4VV-Z0i3uBW9.js} +1 -1
  123. package/dist/client/assets/{diagram-TYUNFSNR-BAQq2OM5.js → diagram-TYUNFSNR-Dq_-g1oP.js} +1 -1
  124. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-cKbeW9dQ.js → ebnfDiagram-V4P3TTPT-vxzIvg-W.js} +1 -1
  125. package/dist/client/assets/{elk-QONTBCTQ-wpfNPp0q.js → elk-QONTBCTQ-BBIXXtg_.js} +1 -1
  126. package/dist/client/assets/{empty-state-DXWQsHMf.js → empty-state-kISAAp0z.js} +1 -1
  127. package/dist/client/assets/{erDiagram-KYQIGQAA-Dk0OrvjE.js → erDiagram-KYQIGQAA-Bk2MeLBx.js} +1 -1
  128. package/dist/client/assets/{execution-config-CAyT2Qoo.js → execution-config-DYFe-VNC.js} +1 -1
  129. package/dist/client/assets/{file-Bf7D_47y.js → file-DEt4KgZG.js} +1 -1
  130. package/dist/client/assets/{file-exclamation-point-DZXE9_8o.js → file-exclamation-point-QqXJhXD9.js} +1 -1
  131. package/dist/client/assets/{file-text-C1ougnBY.js → file-text-CRw31ZWd.js} +1 -1
  132. package/dist/client/assets/{find-latest-widget-fence-B1_-pC-Z.js → find-latest-widget-fence-B3aaiBNI.js} +1 -1
  133. package/dist/client/assets/{flowDiagram-IUGLLWBU-CdlOoRZV.js → flowDiagram-IUGLLWBU-B53m4r8u.js} +1 -1
  134. package/dist/client/assets/{form-D7kF-U0d.js → form-Bjhk9zOn.js} +1 -1
  135. package/dist/client/assets/{format-cron-ZtliseYi.js → format-cron-9tmNIcgl.js} +1 -1
  136. package/dist/client/assets/{ganttDiagram-R7GPNTJY-x0MJLv5d.js → ganttDiagram-R7GPNTJY-CS6TN3R1.js} +1 -1
  137. package/dist/client/assets/{git-branch-B2k77X3Q.js → git-branch-DWerghmw.js} +1 -1
  138. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-CruCvk7w.js → gitGraphDiagram-PDYL7XHY-D096ZtqE.js} +1 -1
  139. package/dist/client/assets/{graph-5PBe05F8.js → graph-DQpTuPmX.js} +1 -1
  140. package/dist/client/assets/{heart-CmqGJPDc.js → heart-CRkjVW7-.js} +1 -1
  141. package/dist/client/assets/{highlighted-body-KPVGNVTW-Bqu2cQDj.js → highlighted-body-KPVGNVTW-DoVCXOMU.js} +1 -1
  142. package/dist/client/assets/{image-lightbox-BBbz-ThL.js → image-lightbox-BXzbN27o.js} +1 -1
  143. package/dist/client/assets/{image-off-BCtWIY4q.js → image-off-VyMBVwgK.js} +1 -1
  144. package/dist/client/assets/{index-8IAr9b71.js → index-1qv8ldHx.js} +1 -1
  145. package/dist/client/assets/{index-ClBIPuLA.js → index-2EaVZrJe.js} +1 -1
  146. package/dist/client/assets/{index-DcZPWi_I.js → index-8-iQ6PnT.js} +252 -247
  147. package/dist/client/assets/{index-CJ5v2_Cz.js → index-B2rBVMNl.js} +1 -1
  148. package/dist/client/assets/{index-BpmmNapD.js → index-BBcAekWE.js} +1 -1
  149. package/dist/client/assets/index-BFitbVs4.js +1 -0
  150. package/dist/client/assets/{index-xmk9Ohv9.js → index-BLkXoquZ.js} +1 -1
  151. package/dist/client/assets/{index-xaMF1mrN.js → index-BcFMs7lK.js} +1 -1
  152. package/dist/client/assets/{index-EdJm7ZN-.js → index-BiFJIg4n.js} +1 -1
  153. package/dist/client/assets/{index-BuGQxHrf.js → index-BpjEclkM.js} +1 -1
  154. package/dist/client/assets/{index-CtycM8wY.js → index-C24HfJir.js} +1 -1
  155. package/dist/client/assets/{index-DAdo_yIq.js → index-C3sW6rkN.js} +1 -1
  156. package/dist/client/assets/{index-JxeBJIuE.js → index-C6Fo2htT.js} +1 -1
  157. package/dist/client/assets/{index-B5rRtvWx.js → index-C6udJCgz.js} +1 -1
  158. package/dist/client/assets/{index-ChwNEkM8.js → index-CDuYKaGY.js} +1 -1
  159. package/dist/client/assets/{index-Cml5572f.js → index-CEVwhauU.js} +1 -1
  160. package/dist/client/assets/index-CI84yP-g.js +1 -0
  161. package/dist/client/assets/{index-BzPgsdPn.js → index-COMRALJO.js} +1 -1
  162. package/dist/client/assets/index-CiVeycsn.js +17 -0
  163. package/dist/client/assets/{index-BXZlDqvy.js → index-Cs3WB8yn.js} +1 -1
  164. package/dist/client/assets/{index-BrQGZ6iF.js → index-Csr_C1sk.js} +1 -1
  165. package/dist/client/assets/{index-CMNc_OrC.js → index-Ctqe81qr.js} +1 -1
  166. package/dist/client/assets/{index-Dmn03xST.js → index-CvhR1oZB.js} +1 -1
  167. package/dist/client/assets/{index-B6dEbNhI.js → index-CyGRWyhV.js} +1 -1
  168. package/dist/client/assets/{index-mFOJXyAE.js → index-Czm6C7FZ.js} +3 -3
  169. package/dist/client/assets/{index-1ShgR_xt.js → index-D5zUdnZM.js} +1 -1
  170. package/dist/client/assets/{index-Cv0GsC4n.js → index-DBo2XfNv.js} +1 -1
  171. package/dist/client/assets/{index-DIxzqCwG.js → index-DKWpwwxo.js} +1 -1
  172. package/dist/client/assets/{index-BXMxoWrk.js → index-DN2sTT2U.js} +1 -1
  173. package/dist/client/assets/index-DNzk9m1D.js +23 -0
  174. package/dist/client/assets/{index-CrflCTqO.css → index-DUZrTFYD.css} +1 -1
  175. package/dist/client/assets/{index-t4Ud6YTX.js → index-DX_2Mxwv.js} +1 -1
  176. package/dist/client/assets/{index-C11Ssk2u.js → index-Dgrk2udV.js} +2 -2
  177. package/dist/client/assets/{index-BCk4wW-T.js → index-DgyhdQnI.js} +1 -1
  178. package/dist/client/assets/{index-CQ0VLZf-.js → index-DmFNztTX.js} +1 -1
  179. package/dist/client/assets/{index-rWZWP3Wh.js → index-TnoaFCrj.js} +1 -1
  180. package/dist/client/assets/{index-DbDI5BAA.js → index-_emDKzsu.js} +1 -1
  181. package/dist/client/assets/{index-BIIH5CXj.js → index-b9p_y2Ql.js} +1 -1
  182. package/dist/client/assets/{index-yI1r4pSP.js → index-gIQ7FrL9.js} +1 -1
  183. package/dist/client/assets/{index-DsJWzmWw.js → index-igLqtuoO.js} +1 -1
  184. package/dist/client/assets/{index-Do6eeFps.js → index-n3-zWcH-.js} +2 -2
  185. package/dist/client/assets/{index-8TfzCkKR.js → index-rCvQat0D.js} +1 -1
  186. package/dist/client/assets/{index-BfRW2WTx.js → index-setKr4xl.js} +1 -1
  187. package/dist/client/assets/{index-DrA03bMq.js → index-t3eRSGcT.js} +1 -1
  188. package/dist/client/assets/{index.esm-CZZtbPRj.js → index.esm-bLeQzVWT.js} +1 -1
  189. package/dist/client/assets/{infoDiagram-MVDRKAX5-Bj9DD77n.js → infoDiagram-MVDRKAX5-nN_N76Fn.js} +1 -1
  190. package/dist/client/assets/{inline-code-g9PVHZI2.js → inline-code-D9bLKHjY.js} +1 -1
  191. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-DckI6dhS.js → ishikawaDiagram-HPEHV2GE-CiLFbWXd.js} +1 -1
  192. package/dist/client/assets/{journeyDiagram-BOSHW7O7-Ce1GAVa0.js → journeyDiagram-BOSHW7O7-Dn3yOv96.js} +1 -1
  193. package/dist/client/assets/{kanban-definition-FNSA4HC5-Kq5O9rZa.js → kanban-definition-FNSA4HC5-JxiBdBQC.js} +1 -1
  194. package/dist/client/assets/{layers-D3lEdRF0.js → layers-DTnLoRvE.js} +1 -1
  195. package/dist/client/assets/{lightbulb-BFE-KkFU.js → lightbulb-CRKLr5q3.js} +1 -1
  196. package/dist/client/assets/{link-2-Dvb6g-2Q.js → link-2-hgHg-lyw.js} +1 -1
  197. package/dist/client/assets/{list-runtime-types-8YGEK3Al.js → list-runtime-types-Bb33QiMC.js} +1 -1
  198. package/dist/client/assets/{markdown-content-Cqq_QMXA.js → markdown-content-D0FpU2cz.js} +1 -1
  199. package/dist/client/assets/{mention-pill-Bnzt4u2l.js → mention-pill-uuaUvwSW.js} +1 -1
  200. package/dist/client/assets/{mermaid.core-dpp59v7L.js → mermaid.core-x3Hh6iut.js} +4 -4
  201. package/dist/client/assets/{message-square-off-BX2XnEDx.js → message-square-off-B8N6YF9R.js} +1 -1
  202. package/dist/client/assets/{mindmap-definition-6OY57UG3-CFdfJO6g.js → mindmap-definition-6OY57UG3-D0SEv5Re.js} +1 -1
  203. package/dist/client/assets/{more-details-B4lBMpKi.js → more-details-CadxnGyH.js} +1 -1
  204. package/dist/client/assets/{owner-notice-ByjrIRmX.js → owner-notice-CJHyha58.js} +1 -1
  205. package/dist/client/assets/{package-6Rbxg35g.js → package-B8G7jQm-.js} +1 -1
  206. package/dist/client/assets/{page-container-DoZzad36.js → page-container-Bb-_N7lw.js} +1 -1
  207. package/dist/client/assets/{paperclip-B-jDXtxw.js → paperclip-BDeYGKqh.js} +1 -1
  208. package/dist/client/assets/{path-input-DpqUD8hN.js → path-input-BIfexEKz.js} +1 -1
  209. package/dist/client/assets/{pegDiagram-ECIUJNBX-eVnSw2Ma.js → pegDiagram-ECIUJNBX-7ivMd0-b.js} +1 -1
  210. package/dist/client/assets/{pieDiagram-GNMPY74T-BYG7LY5Q.js → pieDiagram-GNMPY74T-DGDkbFvu.js} +1 -1
  211. package/dist/client/assets/{plug-DnaAhcy4.js → plug-wP1d6OUX.js} +1 -1
  212. package/dist/client/assets/{primer-trigger-Da5ECjY8.js → primer-trigger-CEli_z4n.js} +1 -1
  213. package/dist/client/assets/{profile-errors-GbTNc2-M.js → profile-errors-C1qSJkiG.js} +1 -1
  214. package/dist/client/assets/{progress-DlIRjXIA.js → progress-DmUieXLn.js} +1 -1
  215. package/dist/client/assets/{quadrantDiagram-D57K4MC3-CRgNKuHR.js → quadrantDiagram-D57K4MC3-AFQRVSsK.js} +1 -1
  216. package/dist/client/assets/{query-error-state-DB-Jby7_.js → query-error-state--8AnWSSn.js} +1 -1
  217. package/dist/client/assets/query-keys-DeYqUDia.js +1 -0
  218. package/dist/client/assets/{radio-CaaE60ws.js → radio-mkA-Sqe0.js} +1 -1
  219. package/dist/client/assets/{railroadDiagram-Y72NRBL7-DGL-Hqz9.js → railroadDiagram-Y72NRBL7-3QBa2d3j.js} +1 -1
  220. package/dist/client/assets/registry-Bnd-HFt3.js +1 -0
  221. package/dist/client/assets/{relay-trace-schemas-CcCqyOrA.js → relay-trace-schemas-fScydQ3A.js} +1 -1
  222. package/dist/client/assets/{requirementDiagram-EQYSW5RA-DKsFpU3l.js → requirementDiagram-EQYSW5RA-BVBqcASy.js} +1 -1
  223. package/dist/client/assets/{room-files-source-CbbVpvSW.js → room-files-source-BhkPUTiP.js} +1 -1
  224. package/dist/client/assets/{rotate-ccw-clock-CeY00nlZ.js → rotate-ccw-clock-DiuTseKz.js} +1 -1
  225. package/dist/client/assets/{rotate-cw-Djl5J_x9.js → rotate-cw-DvoxWwSx.js} +1 -1
  226. package/dist/client/assets/{sankeyDiagram-SY24JHO5-BFRkDxic.js → sankeyDiagram-SY24JHO5-DFjfOD38.js} +1 -1
  227. package/dist/client/assets/{scroll-area-BOqrziJf.js → scroll-area-DYyyRqW_.js} +1 -1
  228. package/dist/client/assets/{search-x-B_mHjnlo.js → search-x-CA-FzEqZ.js} +1 -1
  229. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-fHea3KOI.js → sequenceDiagram-BLEHNHQU-Cr9LzoSF.js} +1 -1
  230. package/dist/client/assets/{shield-check-Csnr5rFy.js → shield-check-CpUB_Ju1.js} +1 -1
  231. package/dist/client/assets/{shield-x-Dhl4YvvW.js → shield-x-B0W_7qwR.js} +1 -1
  232. package/dist/client/assets/{signed-in-BMqAss8c.js → signed-in-X2utDqQS.js} +1 -1
  233. package/dist/client/assets/{sizeCapture-INFHLROL-CztsD3qF.js → sizeCapture-INFHLROL-Do_jfNyT.js} +1 -1
  234. package/dist/client/assets/{soul-file-DOfamgB5.js → soul-file-DgfhKQIK.js} +1 -1
  235. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-CWyOqZ9S.js → stateDiagram-v2-A6IESKWZ-BCi9yk_0.js} +1 -1
  236. package/dist/client/assets/{swimlanes-B3ENRKFQ-0EfOxSAX.js → swimlanes-B3ENRKFQ-3SSAw2av.js} +1 -1
  237. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-jpZCGfva.js +8 -0
  238. package/dist/client/assets/{table-L7FvN6Or.js → table-DvU_oS4E.js} +1 -1
  239. package/dist/client/assets/{terminal-C9M5a_PS.js → terminal-Dw2QZ7Dh.js} +1 -1
  240. package/dist/client/assets/{timeline-definition-JXYKGLGB-sFyYvZ20.js → timeline-definition-JXYKGLGB-DTLPXTMA.js} +1 -1
  241. package/dist/client/assets/{trust-posture-dl6qwDtI.js → trust-posture-2MR0ap9o.js} +1 -1
  242. package/dist/client/assets/{unplug-CFUEVRbc.js → unplug-CAVOLB2R.js} +1 -1
  243. package/dist/client/assets/{unverified-catalog-notice-CdYU3WEJ.js → unverified-catalog-notice-u4ikVg8J.js} +1 -1
  244. package/dist/client/assets/{use-adapter-catalog-YTofdqDJ.js → use-adapter-catalog-BQKfRxXC.js} +1 -1
  245. package/dist/client/assets/{use-bindings-CpyT6kNu.js → use-bindings-BV6HA0MD.js} +1 -1
  246. package/dist/client/assets/{use-composer-prefs-CK_EK_QJ.js → use-composer-prefs-DCSzOnEO.js} +1 -1
  247. package/dist/client/assets/{use-connector-management-DwoK8kon.js → use-connector-management-fr1tx-GZ.js} +1 -1
  248. package/dist/client/assets/{use-deep-link-scroll-CgRjt48R.js → use-deep-link-scroll-v02TbidQ.js} +1 -1
  249. package/dist/client/assets/{use-delete-binding-CfsnMXrL.js → use-delete-binding-CnziYpXo.js} +1 -1
  250. package/dist/client/assets/{use-dev-links-B3I-ZK34.js → use-dev-links-k4YWFO1v.js} +1 -1
  251. package/dist/client/assets/{use-external-adapter-catalog-aGlZNRrp.js → use-external-adapter-catalog-DoGUfa2F.js} +1 -1
  252. package/dist/client/assets/{use-full-activity-feed-B61Olhdw.js → use-full-activity-feed-CQNxgxnw.js} +1 -1
  253. package/dist/client/assets/use-is-below-desktop-DR8FEbRW.js +1 -0
  254. package/dist/client/assets/use-is-hub-BmpgFnFp.js +1 -0
  255. package/dist/client/assets/{use-jump-back-in-C39GOTHa.js → use-jump-back-in-BuO6A0P7.js} +1 -1
  256. package/dist/client/assets/{use-local-browser-DCwzB4D8.js → use-local-browser-BNzN5O1P.js} +1 -1
  257. package/dist/client/assets/{use-mesh-topology-LRYxFuZp.js → use-mesh-topology-CpIDE8lD.js} +1 -1
  258. package/dist/client/assets/{use-mounted-ref-CZaegwTr.js → use-mounted-ref-BAO3qunF.js} +1 -1
  259. package/dist/client/assets/{use-notification-prefs-FtOiUS5H.js → use-notification-prefs-CtqeH5Pk.js} +1 -1
  260. package/dist/client/assets/{use-panel-tab-placements-Dv2OPvKh.js → use-panel-tab-placements-DFobGBRm.js} +1 -1
  261. package/dist/client/assets/use-pending-read-Do0_vZ2I.js +1 -0
  262. package/dist/client/assets/{use-personality-commit-BB5aeh6p.js → use-personality-commit-BvqCwzAC.js} +1 -1
  263. package/dist/client/assets/{use-promo-activation-BW0u7n7m.js → use-promo-activation-Dz5cYm-X.js} +1 -1
  264. package/dist/client/assets/{use-promo-dismissals-BOXzW4kD.js → use-promo-dismissals-CuOsnqnZ.js} +1 -1
  265. package/dist/client/assets/{use-pulse-freshness-ClW-MLMo.js → use-pulse-freshness-qcTH6PM7.js} +1 -1
  266. package/dist/client/assets/{use-relay-config-hItHtkSr.js → use-relay-config-1mAMDNbc.js} +1 -1
  267. package/dist/client/assets/{use-room-follow-claim-wotzxUWc.js → use-room-follow-claim-CCGhsyH3.js} +1 -1
  268. package/dist/client/assets/{use-roving-tab-list-DkbO6xSs.js → use-roving-tab-list-Bsg2dfUx.js} +1 -1
  269. package/dist/client/assets/use-session-canvas-awPngMKg.js +25 -0
  270. package/dist/client/assets/{use-session-diagnostics-DmxvD-wy.js → use-session-diagnostics-D5g8Mc52.js} +2 -2
  271. package/dist/client/assets/{use-unclaimed-chats-DKpexDm3.js → use-unclaimed-chats-Db_wuzt0.js} +1 -1
  272. package/dist/client/assets/use-update-config-DwtH_H9Z.js +1 -0
  273. package/dist/client/assets/{useMutationState-Btf2Hp1a.js → useMutationState-BvwBDXKc.js} +1 -1
  274. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-DRngjDUq.js → usecaseDiagram-WPOLBNNX-1zKygEKR.js} +1 -1
  275. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-iK-dlS1-.js → vennDiagram-Q3Y3IDCW-BR2EbgGY.js} +1 -1
  276. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-sOS67Cks.js → wardleyDiagram-IVAIDKWA-D0OwouJc.js} +1 -1
  277. package/dist/client/assets/{xychartDiagram-4URNHDU4-EgnLiIao.js → xychartDiagram-4URNHDU4-BM-7_FQQ.js} +1 -1
  278. package/dist/client/index.html +2 -2
  279. package/dist/drizzle/20261018123612_session_route.sql +1 -0
  280. package/dist/drizzle/meta/20261018123612_snapshot.json +14027 -0
  281. package/dist/drizzle/meta/_journal.json +7 -0
  282. package/dist/server/index.js +31594 -28878
  283. package/dist/server/index.js.map +2 -2
  284. package/package.json +6 -6
  285. package/dist/client/assets/CanvasFileContent-ClcHZ_l-.js +0 -2
  286. package/dist/client/assets/CanvasModel3dContent-Cm3msNdQ.js +0 -2
  287. package/dist/client/assets/HandlePage-B_5GLHsp.js +0 -1
  288. package/dist/client/assets/NamePage-0nr288eM.js +0 -1
  289. package/dist/client/assets/PhotoPage-C3Ir3wlA.js +0 -1
  290. package/dist/client/assets/PresetPicker-zGvDOqTf.js +0 -19
  291. package/dist/client/assets/RoomSurface-BIyjtxKD.js +0 -44
  292. package/dist/client/assets/_shell-BHUZq_8C.js +0 -80
  293. package/dist/client/assets/_shell.marketplace-BoAmyvPt.js +0 -1
  294. package/dist/client/assets/_shell.marketplace_.sources-BpqWjkGL.js +0 -1
  295. package/dist/client/assets/_shell.session-KyPj3OxK.js +0 -61
  296. package/dist/client/assets/_shell.x._extensionId-CfiAgtoq.js +0 -1
  297. package/dist/client/assets/_shell.x._extensionId_._-CfiAgtoq.js +0 -1
  298. package/dist/client/assets/channel-DZpRF3QJ.js +0 -1
  299. package/dist/client/assets/index-Cl8trmnL.js +0 -1
  300. package/dist/client/assets/index-Cp3yShS8.js +0 -23
  301. package/dist/client/assets/index-DKDK-3KH.js +0 -17
  302. package/dist/client/assets/index-DPNBHwcQ.js +0 -1
  303. package/dist/client/assets/registry-DS1Ghdft.js +0 -1
  304. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-C7fkUKrq.js +0 -8
  305. package/dist/client/assets/use-is-below-desktop-Qwyg-mFb.js +0 -1
  306. package/dist/client/assets/use-is-hub-CSz6NDaP.js +0 -1
  307. package/dist/client/assets/use-pending-read-DBOl1ee_.js +0 -1
  308. package/dist/client/assets/use-session-canvas-C_fuAgW_.js +0 -24
  309. package/dist/client/assets/use-update-config-CSYwg557.js +0 -1
@@ -1,4 +1,4 @@
1
- import{W as te,a1 as W,a2 as de,aa as P,a3 as ae,a4 as ue,r as p,u as ke,m3 as Ce,j as s,dU as ln,dV as on,dW as cn,dX as dn,dY as un,fq as mn,d$ as ee,dj as hn,I as pn,m4 as Be,m5 as be,m6 as Ge,m7 as us,m8 as ms,e as B,lA as fn,a0 as me,m9 as xn,B as C,dy as gn,ma as Ke,mb as kn,mc as jn,ar as Qe,P as vn,G as oe,a7 as S,db as K,eY as bn,hu as yn,md as Nn,da as wn,hb as Cn,me as Pn,mf as Ye,mg as J,mh as Sn,mi as ve,J as hs,hJ as qe,b7 as $n,eW as Ve,gV as ps,_ as se,f0 as In,C as Pe,as as fs,hk as Rn,hl as Tn,hm as Dn,hn as An,mj as xs,ho as En,bK as Ln,e1 as Un,e2 as On,k9 as Fn,aq as gs,aS as ks,eX as js,dz as He,es as vs,gh as Mn,aW as bs,mk as zn,a as Le,bO as ys,cw as Se,cx as $e,cz as Ie,cA as Re,cB as Te,ju as Ns,jv as ye,dw as De,dc as Ae,x as Fe,bc as ws,hg as _n,gA as Me,gl as Kn,ml as qn,hM as Vn,mm as Hn,mn as Wn,j0 as Bn,mo as Gn,dI as Qn,mp as Yn}from"./index-DcZPWi_I.js";import{r as Jn,d as Xn,u as Cs,P as Ps,T as Zn,a as et,b as Je}from"./PreviewRefusedNotice-D1Tl265t.js";import{C as st}from"./card-ww4ebz8h.js";import{E as nt}from"./empty-state-DXWQsHMf.js";import{M as tt}from"./markdown-content-Cqq_QMXA.js";import{U as at}from"./use-unclaimed-chats-DKpexDm3.js";import{d as rt,f as lt,a as it,b as ot,c as ct,U as Ss,u as dt,e as ut}from"./UnlinkDialog-CFRgExId.js";import{M as mt}from"./more-details-B4lBMpKi.js";import{a as $s}from"./use-dev-links-B3I-ZK34.js";import{T as ht}from"./terminal-C9M5a_PS.js";import{F as Is}from"./file-Bf7D_47y.js";import{A as Rs}from"./AgentPicker-CL93SET3.js";import{u as pt}from"./useMutationState-Btf2Hp1a.js";import{F as ft}from"./file-exclamation-point-DZXE9_8o.js";import{R as Ts}from"./rotate-ccw-clock-CeY00nlZ.js";import{P as xt}from"./path-input-DpqUD8hN.js";/**
1
+ import{W as te,a1 as W,a2 as de,aa as P,a3 as ae,a4 as ue,r as p,u as ke,lV as Ce,j as s,dU as ln,dV as on,dW as cn,dX as dn,dY as un,fq as mn,d$ as ee,dj as hn,I as pn,lW as Be,lX as be,lY as Ge,lZ as us,l_ as ms,e as B,lI as fn,a0 as me,l$ as xn,B as C,dy as gn,m0 as Ke,m1 as kn,m2 as jn,ar as Qe,P as vn,G as oe,a7 as S,db as K,eY as bn,hu as yn,m3 as Nn,da as wn,hb as Cn,m4 as Pn,m5 as Ye,m6 as J,m7 as Sn,m8 as ve,J as hs,hJ as Ve,b7 as $n,eW as qe,gV as ps,_ as se,f0 as In,C as Pe,as as fs,hk as Rn,hl as Tn,hm as Dn,hn as En,m9 as xs,ho as An,bK as Ln,e1 as Un,e2 as On,kh as Fn,aq as gs,aS as ks,eX as js,dz as He,es as vs,gh as Mn,aW as bs,ma as zn,a as Le,bO as ys,cw as Se,cx as $e,cz as Ie,cA as Re,cB as Te,jC as Ns,jD as ye,dw as De,dc as Ee,x as Fe,bc as ws,hg as _n,gA as Me,gl as Kn,mb as Vn,hM as qn,mc as Hn,md as Wn,iU as Bn,me as Gn,dI as Qn,mf as Yn}from"./index-8-iQ6PnT.js";import{r as Jn,d as Xn,u as Cs,P as Ps,T as Zn,a as et,b as Je}from"./PreviewRefusedNotice-BANdpT9O.js";import{C as st}from"./card-Dj6ZfRgu.js";import{E as nt}from"./empty-state-kISAAp0z.js";import{M as tt}from"./markdown-content-D0FpU2cz.js";import{U as at}from"./use-unclaimed-chats-Db_wuzt0.js";import{d as rt,f as lt,a as it,b as ot,c as ct,U as Ss,u as dt,e as ut}from"./UnlinkDialog-Di1oBFA_.js";import{M as mt}from"./more-details-CadxnGyH.js";import{a as $s}from"./use-dev-links-k4YWFO1v.js";import{T as ht}from"./terminal-Dw2QZ7Dh.js";import{F as Is}from"./file-DEt4KgZG.js";import{A as Rs}from"./AgentPicker-CBYeBzjf.js";import{u as pt}from"./useMutationState-BvwBDXKc.js";import{F as ft}from"./file-exclamation-point-QqXJhXD9.js";import{R as Ts}from"./rotate-ccw-clock-DiuTseKz.js";import{P as xt}from"./path-input-BIfexEKz.js";/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,12 +8,12 @@ import{W as te,a1 as W,a2 as de,aa as P,a3 as ae,a4 as ue,r as p,u as ke,m3 as C
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 As={name:"circle-arrow-up",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],aliases:["arrow-up-circle"]};As.node;const kt=te(As);/**
11
+ */const Es={name:"circle-arrow-up",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],aliases:["arrow-up-circle"]};Es.node;const kt=te(Es);/**
12
12
  * @license lucide-react v1.48.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const Es={name:"file-check-corner",size:24,node:[["path",{d:"M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6",key:"g5mvt7"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14 20 2 2 4-4",key:"15kota"}]],aliases:["file-check-2"]};Es.node;const jt=te(Es);/**
16
+ */const As={name:"file-check-corner",size:24,node:[["path",{d:"M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6",key:"g5mvt7"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14 20 2 2 4-4",key:"15kota"}]],aliases:["file-check-2"]};As.node;const jt=te(As);/**
17
17
  * @license lucide-react v1.48.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
@@ -33,4 +33,4 @@ import{W as te,a1 as W,a2 as de,aa as P,a3 as ae,a4 as ue,r as p,u as ke,m3 as C
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const Fs={name:"unlink",size:24,node:[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]};Fs.node;const Nt=te(Fs);function wt(e,n){const t=W(),{enabled:r=!0,marketplace:a}=n??{};return de({queryKey:P.packageDetail(e??""),queryFn:()=>t.getMarketplacePackage(e,a),enabled:r&&e!==null,staleTime:6e4})}function je(e){const n=W();return de({queryKey:P.installed(e),queryFn:()=>n.listInstalledPackages(e),staleTime:6e4})}function Ct(e,n){const t=W();return de({queryKey:P.installedDetail(e??""),queryFn:()=>t.listPackageInstallations(e),enabled:((n==null?void 0:n.enabled)??!0)&&e!==null,staleTime:6e4})}function Pt(){const e=W();return de({queryKey:P.integrity(),queryFn:()=>e.listInstalledPackages(void 0,{verify:!0}),select:n=>new Map(n.flatMap(t=>t.integrity?[[t.installPath,t.integrity]]:[])),staleTime:6e4})}const St=10*6e4;function $t(e,n={}){const t=W();return de({queryKey:P.updates(e),queryFn:()=>t.checkMarketplaceUpdates(e),enabled:n.enabled??!0,staleTime:St,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1})}function It(){const e=W(),n=ae();return ue({mutationFn:({name:t,options:r})=>e.installMarketplacePackage(t,r),onError:t=>{t.code==="disclosure_changed"&&n.invalidateQueries({queryKey:P.preview()})},onSuccess:(t,{name:r,options:a})=>{n.invalidateQueries({queryKey:P.installed()}),a!=null&&a.projectPath&&n.invalidateQueries({queryKey:P.installed(a.projectPath)}),n.invalidateQueries({queryKey:P.packages()}),n.invalidateQueries({queryKey:P.packageDetail(r)}),n.invalidateQueries({queryKey:["commands"]}),n.invalidateQueries({queryKey:P.updates(),refetchType:"none"})}})}function Rt(){const e=W(),n=ae();return ue({mutationFn:({name:t,options:r})=>e.uninstallMarketplacePackage(t,r),onSuccess:(t,{name:r,options:a})=>{n.invalidateQueries({queryKey:P.installed()}),a!=null&&a.projectPath&&n.invalidateQueries({queryKey:P.installed(a.projectPath)}),n.invalidateQueries({queryKey:P.packageDetail(r)}),n.invalidateQueries({queryKey:["commands"]})}})}function Tt(){const e=W(),n=ae();return ue({mutationFn:({name:t,options:r})=>e.checkPackageFiles(t,r),onSettled:()=>{n.invalidateQueries({queryKey:P.integrity()})}})}function Ms(e){if(!e.applied)return e;const{applied:n,applyError:t,note:r,...a}=e;return{...a,status:"current",hasUpdate:!1,installedVersion:n.version,installedVersionSource:n.version===e.latestVersion?e.latestVersionSource:"package"}}function Dt(){const e=W(),n=ae();return ue({mutationKey:P.applyUpdates(),mutationFn:t=>e.applyMarketplaceUpdates(t),meta:{suppressErrorToast:!0},onError:t=>{t.code==="disclosure_changed"&&n.invalidateQueries({queryKey:P.updates()})},onSuccess:async t=>{const r=new Map(t.checks.map(l=>[l.installPath,Ms(l)]));n.setQueriesData({queryKey:P.updates()},l=>l&&{checks:l.checks.map(i=>r.get(i.installPath)??i)});const a=t.checks.filter(l=>l.applied);if(a.length!==0){for(const l of new Set(a.map(i=>i.packageName)))n.invalidateQueries({queryKey:P.installedDetail(l)}),n.invalidateQueries({queryKey:P.packageDetail(l)});n.invalidateQueries({queryKey:["commands"]}),await n.invalidateQueries({queryKey:P.installed()})}}})}function At(){const e=pt({filters:{mutationKey:P.applyUpdates(),status:"pending"},select:n=>{var t;return(t=n.state.variables)==null?void 0:t.targets.map(r=>r.installPath)}});return p.useMemo(()=>new Set(e.flatMap(n=>n??[])),[e])}function Et(){const e=W();return ue({mutationFn:n=>e.reviewHeldBackPackage(n),meta:{suppressErrorToast:!0}})}function Lt(e){const n=W();return de({queryKey:P.heldBack(),queryFn:()=>n.listHeldBackPackages(),enabled:e})}function Ut(){const e=W(),n=ae();return ue({mutationFn:({name:t,options:r})=>e.keepPackageFiles(t,r),meta:{suppressErrorToast:!0},onSettled:()=>{n.invalidateQueries({queryKey:P.installed()})}})}function Ot(e,n){return e.name.toLowerCase().includes(n)||(e.description??"").toLowerCase().includes(n)||(e.keywords??[]).some(t=>t.toLowerCase().includes(n))?!0:(e.tags??[]).some(t=>t.toLowerCase().includes(n))}const Ft=300,Mt=[{value:"featured",label:"Featured"},{value:"name",label:"A–Z"},{value:"popular",label:"Popular"},{value:"recent",label:"Recent"}];function zt(){const{sort:e,setSort:n}=ke(),{data:t}=Ce(),r=p.useMemo(()=>(t??[]).some(i=>i.installCount!==void 0),[t]),a=p.useMemo(()=>(t??[]).some(i=>i.updatedAt!==void 0),[t]),l=i=>i==="popular"?!r:i==="recent"?!a:!1;return s.jsxs("header",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(_t,{})}),s.jsxs(ln,{value:e,onValueChange:i=>n(i),children:[s.jsx(on,{"aria-label":"Sort packages",className:"w-28 shrink-0 text-xs sm:w-32",children:s.jsx(cn,{})}),s.jsx(dn,{children:Mt.map(i=>s.jsx(un,{value:i.value,disabled:l(i.value),className:"text-xs",children:i.label},i.value))})]})]})}function _t(){const{search:e,setSearch:n}=ke(),t=p.useRef(null),r=mn({value:e,generation:0});r.read().value!==e&&r.write({value:e,generation:r.read().generation+1});const a=r.read().generation,[l,i]=p.useState(null),o=l!==null&&l.generation===a?l.value:e,d=c=>i({generation:a,value:c});p.useEffect(()=>{if(o===e)return;const c=setTimeout(()=>n(o),Ft);return()=>clearTimeout(c)},[o,e,n]);const u=p.useCallback(c=>{var w;if(c.key!=="/"||c.metaKey||c.ctrlKey||c.altKey)return;const h=c.target,f=h==null?void 0:h.tagName;f==="INPUT"||f==="TEXTAREA"||f==="SELECT"||h!=null&&h.isContentEditable||(c.preventDefault(),(w=t.current)==null||w.focus())},[]);return p.useEffect(()=>(document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)),[u]),s.jsxs("div",{className:"group/search relative",children:[s.jsx(ee,{htmlFor:"marketplace-search",className:"sr-only",children:"Search packages"}),s.jsx(hn,{className:"text-muted-foreground group-focus-within/search:text-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 transition-colors duration-200","aria-hidden":!0}),s.jsx(pn,{ref:t,id:"marketplace-search","data-testid":"marketplace-search",value:o,onChange:c=>d(c.target.value),placeholder:"Search…",className:"pl-9 transition-shadow duration-200 focus:shadow-md max-sm:pr-3 sm:pr-10"}),s.jsx("kbd",{className:"text-muted-foreground/60 text-3xs pointer-events-none absolute top-1/2 right-3 hidden -translate-y-1/2 rounded border border-current/20 px-1.5 py-0.5 font-mono leading-none group-focus-within/search:opacity-0 sm:block",children:"/"})]})}function Kt(e,n){if(n==="all")return!0;const t=e.type??"plugin";return n===Be?t==="adapter"&&e.adapterType===Be:t===n}function qt(e,n){const t=n.search.trim().toLowerCase();return e.filter(r=>!(!Kt(r,n.type)||n.categories.length>0&&!n.categories.some(l=>{var i;return(((i=r.categories)==null?void 0:i.includes(l))??!1)||r.category===l})||n.sources.length>0&&!n.sources.includes(r.marketplace)||t&&!Ot(r,t)))}function Ee(e,n){return be(e).localeCompare(be(n))}function Vt(e,n){const t=e.marketplace===Ge?1:0,r=n.marketplace===Ge?1:0;if(t!==r)return r-t;const a=e.featured?1:0,l=n.featured?1:0;return a!==l?l-a:Ee(e,n)}function Ht(e,n){const t=e.installCount??0,r=n.installCount??0;return t!==r?r-t:Ee(e,n)}function Wt(e,n){const t=e.updatedAt??"",r=n.updatedAt??"";return t!==r?r.localeCompare(t):Ee(e,n)}function Bt(e,n){const t=[...e];switch(n){case"featured":return t.sort(Vt);case"name":return t.sort(Ee);case"popular":return t.sort(Ht);case"recent":return t.sort(Wt)}}function zs({count:e=8}){return s.jsx("div",{className:us,children:s.jsx("div",{"data-slot":"package-grid",className:ms,"aria-busy":"true","aria-label":"Loading packages",children:Array.from({length:e}).map((n,t)=>s.jsxs(st,{radius:"lg",gap:"none",className:"p-6",children:[s.jsx("div",{className:"mb-3 flex items-start justify-between gap-2",children:s.jsx(B,{className:"size-6 rounded-full"})}),s.jsx(B,{className:"mb-1 h-4 w-3/4"}),s.jsx(B,{className:"mb-3 h-3 w-16"}),s.jsx(B,{className:"mb-1 h-3 w-full"}),s.jsx(B,{className:"mb-4 h-3 w-2/3"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(B,{className:"h-7 w-16"})})]},t))})})}function xe({onResetFilters:e,resetLabel:n="Reset filters",title:t="No packages match your filters",description:r="Try another search or filter."}){return s.jsx(nt,{className:"rounded-xl border border-dashed",icon:bt,headline:t,headingLevel:3,description:r,action:e?{label:n,onClick:e,variant:"outline"}:void 0})}const Gt=/network|fetch|offline/i;function _s({error:e,onRetry:n}){const t=Gt.test(e.message),r=t?fn:me,a=t?"Couldn’t reach the marketplace":"Couldn’t load packages";return s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed py-16 text-center",children:[s.jsx(r,{className:"text-muted-foreground mb-4 size-10","aria-hidden":!0}),s.jsx("h3",{className:"mb-2 text-base font-semibold",children:a}),s.jsx("p",{className:"text-muted-foreground mb-4 max-w-sm text-sm",children:s.jsx(xn,{text:e.message})}),s.jsx(C,{variant:"outline",onClick:n,children:"Try again"})]})}const ze=20,Qt=.03,Yt={hidden:{},visible:{transition:{staggerChildren:Qt}}},Jt={hidden:e=>({opacity:e<ze?0:1,y:e<ze?12:0}),visible:{opacity:1,y:0,transition:{duration:.25,ease:"easeOut"}}};function Xt(){const{data:e,isLoading:n,error:t,refetch:r}=Ce(),{data:a}=je(),l=gn(),{type:i,categories:o,sources:d,search:u,sort:c,resetFilters:h,clearCategories:f,clearSources:w,openDetail:T}=ke(),v=Ke(),x=p.useMemo(()=>e?Bt(qt(e,{type:i,categories:o,sources:d,search:u}),c):[],[e,i,o,d,u,c]),N=p.useMemo(()=>new Set((a??[]).map(k=>k.name)),[a]),$=p.useMemo(()=>new Set((a??[]).filter(k=>k.devLink).map(k=>k.name)),[a]);if(n)return s.jsx(zs,{});if(t)return s.jsx(_s,{error:t,onRetry:()=>void r()});if(x.length===0){const k=o.length>0&&d.length===0,I=d.length>0&&o.length===0;if(k){const L=o.length===1?o[0]:null,D=L?kn(L):void 0,A=L?D?jn[D]:L:null;return s.jsx(xe,{title:A?`No packages in ${A} yet`:"No packages in these categories yet",description:"Try another category.",resetLabel:o.length===1?"Clear category":"Clear categories",onResetFilters:f})}if(I){const L=d.length===1?d[0]:null;return s.jsx(xe,{title:L?`No packages from ${L} yet`:"No packages from these sources yet",description:"Try another source.",resetLabel:d.length===1?"Clear source":"Clear sources",onResetFilters:w})}return o.length>0&&d.length>0?s.jsx(xe,{title:"No packages match these filters",description:"Reset the filters to see everything.",onResetFilters:h}):s.jsx(xe,{onResetFilters:h})}return s.jsxs("div",{className:oe(us,"space-y-4"),children:[s.jsx("div",{className:"flex items-center justify-between gap-4",children:s.jsxs("h2",{className:"text-base font-semibold",children:["All packages",s.jsxs("span",{className:"text-muted-foreground ml-2 text-sm font-normal",children:["(",x.length,")"]})]})}),s.jsx(Qe.div,{variants:l?void 0:Yt,initial:"hidden",animate:"visible","data-slot":"package-grid",className:ms,children:x.map((k,I)=>s.jsx(Qe.div,{variants:l?void 0:Jt,custom:I<ze?I:0,className:"h-full",children:s.jsx(vn,{pkg:k,installed:N.has(k.name),devLinked:$.has(k.name),onClick:()=>T(k.name),onInstallClick:()=>v(k)})},k.name))})]})}function Xe(e,n){return e instanceof Error?`Couldn’t uninstall ${n}: ${e.message}`:`Couldn’t uninstall ${n}. Try again.`}function re(e){const n=K(e.name);return e.where?`${n} from ${e.where}`:n}function Ze(e){const n=(e==null?void 0:e.warnings)??[];return n.length>0?{description:n.join(" ")}:{}}function Ks(){const e=Rt(),n=ae(),{mutate:t,mutateAsync:r}=e,a=p.useCallback(()=>{n.invalidateQueries({queryKey:[...at]})},[n]),l=p.useCallback(({where:o,...d})=>{const u=S.loading(`Uninstalling ${re({...d,where:o})}…`);t(d,{onSuccess:c=>{a(),S.success(`Uninstalled ${re({...d,where:o})}`,{id:u,...Ze(c)})},onError:c=>{S.error(Xe(c,re({...d,where:o})),{id:u})}})},[t,a]),i=p.useCallback(async({where:o,...d})=>{const u=S.loading(`Uninstalling ${re({...d,where:o})}…`);try{const c=await r(d);return a(),S.success(`Uninstalled ${re({...d,where:o})}`,{id:u,...Ze(c)}),c}catch(c){throw S.error(Xe(c,re({...d,where:o})),{id:u}),c}},[r,a]);return{...e,mutate:l,mutateAsync:i}}function qs(){const[e,n]=p.useState(null),[t,r]=p.useState(null),a=Ke(),l=c=>{var h;return{name:c.name,...rt(c),parked:((h=c.devLink)==null?void 0:h.parked)===!0}},i=p.useCallback(c=>{r(null),n(l(c))},[]),o=p.useCallback((c,h)=>{r({pkg:h,installation:c}),n({...l(c),then:"install"})},[]),d=p.useCallback(()=>n(null),[]),u=p.useCallback(c=>{if(c.then!=="install"||!t)return;const{pkg:h,installation:f}=t;r(null),a(h,f.agentPath?{agentPath:f.agentPath,agentName:f.agentName??f.agentPath}:void 0)},[t,a]);return{target:e,askUnlink:i,askInstallPublished:o,close:d,onUnlinked:u}}function Zt(e){const{data:n}=$s(),t=lt(n==null?void 0:n.links,e),r=Nn(it(e,t)),a=wn(l=>l.latest[r]);return e.devLink?ot(e.devLink,a,t):null}function ea({status:e}){switch(e.kind){case"reloaded":return s.jsx(sa,{at:e.at});case"watching":return s.jsx("p",{className:"text-muted-foreground text-xs",children:"Watching for edits."});case"reload-failed":return s.jsxs("div",{className:"text-status-warning-fg space-y-1 text-xs",children:[s.jsxs("p",{className:"flex items-start gap-1",children:[s.jsx(me,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"[overflow-wrap:anywhere]",children:e.headline})]}),s.jsx(mt,{label:"Details",openLabel:"Hide details",className:"ml-4",children:e.details.map((n,t)=>s.jsx("p",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:n},`${t}-${n}`))})]});case"folder-missing":return s.jsx(Ue,{children:"Folder missing. Restore it or unlink."});case"link-missing":return s.jsx(Ue,{children:"Its link is gone. Unlink to finish."});case"link-replaced":return s.jsx(Ue,{children:"Something else is in its place. Unlink to finish."})}}function sa({at:e}){const n=Cn(1e3);return s.jsx("time",{dateTime:e,title:new Date(e).toLocaleString(),className:"text-muted-foreground text-xs",children:ct(e,n)})}function Ue({children:e}){return s.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1 text-xs",children:[s.jsx(me,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{children:e})]})}function Vs({installation:e}){const n=Zt(e);return!e.devLink||!n?null:s.jsxs("div",{className:"mt-1.5 space-y-1","data-testid":"dev-link-details",children:[s.jsx(bn,{path:e.devLink.path}),s.jsx("div",{role:"status","aria-live":"polite","data-testid":"dev-link-status",children:s.jsx(ea,{status:n})})]})}function Hs({installation:e,published:n,label:t,onUnlink:r,onInstallPublished:a,disabled:l}){return e.devLink?e.devLink.parked?s.jsxs(C,{size:"sm",variant:"outline",onClick:r,disabled:l,"aria-label":`Use the installed copy of ${t}`,children:[s.jsx(yn,{className:"mr-1 size-3","aria-hidden":!0}),"Use installed copy"]}):s.jsxs(s.Fragment,{children:[n&&s.jsxs(C,{size:"sm",variant:"outline",onClick:()=>a(n),disabled:l,"aria-label":`Install the published version of ${t}`,children:[s.jsx(gt,{className:"mr-1 size-3","aria-hidden":!0}),"Install published version"]}),s.jsxs(C,{size:"sm",variant:"ghost",onClick:r,disabled:l,"aria-label":`Unlink ${t}`,children:[s.jsx(Nt,{className:"mr-1 size-3","aria-hidden":!0}),"Unlink"]})]}):null}function Ws(e){return e.includes("\\")&&!e.includes("/")?"\\":"/"}function es(e){return e.split(/[\\/]/)}function na(e){const n=e[0];if(n===void 0)return"";const t=Ws(n);let r=es(n).slice(0,-1);for(const a of e.slice(1)){const l=es(a).slice(0,-1);let i=0;for(;i<r.length&&i<l.length&&r[i]===l[i];)i+=1;if(r=r.slice(0,i),r.length===0)break}return r.length===0?"":r.length===1&&r[0]===""?t:r.join(t)}function ta(e,n){if(n==="")return e;const t=Ws(e),r=n.endsWith(t)?n:n+t;return e.startsWith(r)?e.slice(r.length):e}function ss(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/(^|\/)\.(?=\/|$)/g,"$1").replace(/\/+/g,"/").replace(/(.)\/$/,"$1")}function aa(e,n){if(n==="")return!1;const t=ss(n);if(t==="/"||t==="")return!0;const r=ss(e);return r===t||r.startsWith(`${t}/`)}const ra={delete:"removed",modify:"changed",create:"new"},la=["delete","modify","create"];function ns(e,n){const t=[];for(const r of la){const a=e.filter(l=>l.action===r).map(l=>ta(l.path,n)).sort((l,i)=>l.localeCompare(i));for(const l of a)t.push({text:l,tag:ra[r],...r==="delete"?{severity:"warning"}:{}})}return t}function ia(e,n){if(e.length===0)return[];const t=na(e.map(d=>d.path)),r={create:e.filter(d=>d.action==="create").length,modify:e.filter(d=>d.action==="modify").length,delete:e.filter(d=>d.action==="delete").length},a=e.length===1?"file":"files",l=t===""?"":` under ${t}`,i=[{icon:"file",label:`${e.length} ${a}${l}: ${r.create} new, ${r.modify} changed, ${r.delete} removed`,details:ns(e,t),detailsLabel:`Show ${e.length} ${a}`}];if(!n)return i;const o=e.filter(d=>!aa(d.path,n));return o.length>0&&i.push({icon:"alert-triangle",label:`${o.length} ${o.length===1?"file lands":"files land"} outside ${n}.`,severity:"warning",details:ns(o,""),detailsLabel:`Show ${o.length} ${o.length===1?"file":"files"}`}),i}function oa(e,n){const t=ia(e.fileChanges,n);if(e.npmDependencies.length>0){const r=e.npmDependencies.length;t.push({icon:"globe",label:`Download ${r} npm ${r===1?"library":"libraries"} and their dependencies`,description:e.npmDependencies.map(a=>`${a.name}@${a.range}${a.optional?" (optional)":""}`).join(", ")})}for(const r of e.extensions)t.push({icon:"puzzle",label:`Register UI extension: ${r.id}`,description:r.slots.length>0?`Slots: ${r.slots.join(", ")}`:void 0});for(const r of e.skippedLinks)t.push({icon:"alert-triangle",label:"Part of this package won’t be installed",description:r.message,severity:"warning"});return t}function Bs(e,n=Pn){const t=e.hooks.map(a=>({icon:"terminal",label:J(a.command),description:a.source?`Runs ${Ye(a.event,a.matcher)}, while ${J(a.source)} is in use`:`Runs ${Ye(a.event,a.matcher)}`,mono:!0}));for(const a of e.skillCommands){const l=Sn(a.source);t.push({icon:"terminal",label:J(a.command),description:`Runs when the ${l} "${J(a.skill)}" is used (${J(a.source)})`+(a.usesArguments?". Uses what you type after it":""),mono:!0})}for(const a of e.unreadableHooks)t.push({icon:"alert-triangle",label:"Sets up a command DorkOS couldn’t read",description:a.event?`${a.path} declares "${a.event}" in a form DorkOS can’t read`:`DorkOS can’t read ${a.path}`,severity:"warning"});const r=(a,l,i=!0)=>({icon:i?"terminal":"globe",label:a,description:`${l}. ${n}`,mono:!0});for(const a of e.mcpServers)t.push(a.command!==void 0?r(ve(a.command,a.args),`MCP server "${a.name}"`):r(J(JSON.stringify(a.url??"")),`Remote MCP server "${a.name}"`,!1));for(const a of e.lspServers)t.push(r(ve(a.command,a.args),`Language server "${a.name}"`));for(const a of e.monitors)t.push(r(ve(a.command),`Background monitor "${a.name}"${a.when?`, ${a.when}`:""}`));for(const a of e.executables)t.push(r(ve(a),"Added to the agent’s commands (bin/)"));for(const a of e.skillTools)t.push({icon:"key",label:a.tools.map(l=>J(JSON.stringify(l))).join(", "),description:`Skill "${J(a.skill)}" may use these without asking you`,mono:!0});for(const a of e.unreadableDeclarations)t.push({icon:"alert-triangle",label:"Sets up a program DorkOS couldn’t read",description:a.entry?`${a.path} declares "${a.entry}" in a form DorkOS can’t read`:`DorkOS can’t read ${a.path}`,severity:"warning"});return t}function Gs(e){return e.schedules.map(n=>({icon:"clock",label:n.name,description:Xn(n),severity:Jn(n.permissionMode)&&n.startsEnabled?"warning":"info"}))}function ca(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function da(e){const n={create:e.fileChanges.filter(u=>u.action==="create").length,modify:e.fileChanges.filter(u=>u.action==="modify").length,delete:e.fileChanges.filter(u=>u.action==="delete").length},r=[{verb:"Adds",count:n.create},{verb:"Changes",count:n.modify},{verb:"Removes",count:n.delete}].filter(u=>u.count>0).map((u,c)=>{const h=c===0?u.verb:u.verb.toLowerCase(),f=c===0?` ${u.count===1?"file":"files"}`:"";return`${h} ${u.count}${f}`}),a=r.length===0?"Changes no files":ca(r),l=e.hooks.length+e.skillCommands.length+e.unreadableHooks.length,i=l===0?"Declares no commands":`Declares ${l} ${l===1?"command":"commands"}`,o=e.mcpServers.length+e.lspServers.length+e.monitors.length+e.executables.length,d=o===0?"":` Includes ${o} ${o===1?"program":"programs"}.`;return`${a}. ${i}.${d}`}function ua(e,n={}){return{effects:oa(e,n.installBase),commands:Bs(e),schedules:Gs(e),secrets:e.secrets.map(t=>({icon:"key",label:t.key+(t.required?"":" (optional)"),description:t.description,severity:t.required?"warning":"info"})),hosts:e.externalHosts.map(t=>({icon:"globe",label:t})),dependencies:e.requires.map(t=>({icon:t.satisfied?"check":"alert-triangle",label:`${t.type}:${t.name}${t.version?`@${t.version}`:""}`,severity:t.satisfied?"info":"warning"})),conflicts:e.conflicts.map(t=>({icon:"alert-triangle",label:t.description,description:t.conflictingPackage?`Conflicts with: ${t.conflictingPackage}`:void 0,severity:t.level==="error"?"error":"warning"}))}}const ma={global:"Starts in every chat.",project:"Declared, but not started for a project install."};function We(e,n){const t={hooks:e.hooks.map(a=>({event:a.event,...a.matcher!==null&&{matcher:a.matcher},command:a.command,...a.source!==null&&{source:a.source}})),unreadableHooks:[],mcpServers:e.mcpServers.map(a=>({name:a.name,transport:a.transport,...a.command!==null&&{command:a.command,args:a.args},...a.url!==null&&{url:a.url}})),lspServers:e.lspServers.map(({name:a,command:l,args:i})=>({name:a,command:l,args:i})),monitors:e.monitors.map(({name:a,command:l,when:i})=>({name:a,command:l,...i!==null&&{when:i}})),executables:e.executables,skillTools:e.skillTools,skillCommands:e.skillCommands,unreadableDeclarations:[]},r=e.schedules.map(a=>({name:a.name,cron:a.cron,permissionMode:a.permissionMode,startsEnabled:a.startsEnabled}));return[...Bs(t,ma[n]),...Gs({schedules:r})]}const ha={hooks:[],schedules:[],mcpServers:[],lspServers:[],monitors:[],executables:[],skillTools:[],skillCommands:[]},pa=["hooks","skillCommands","mcpServers","lspServers","monitors","executables","skillTools","schedules"];function Ne(e,n){if(!(e==="hooks"||e==="skillCommands"||e==="executables"))return e==="skillTools"?n.source:n.name}function fa(e,n,t){const r=[],a=(l,i)=>We({...ha,[l]:[i]},t)[0];for(const l of pa)for(const i of e[l]){const o=a(l,i);if(!o)continue;const d=xa(l,i,n),u=d==="changed"?n[l].find(h=>Ne(l,h)===Ne(l,i)):void 0,c=u===void 0?void 0:a(l,u);r.push({row:o,change:d,...c&&{previous:c}})}return r}function xa(e,n,t){if(!t)return"unknown";const r=t[e],a=JSON.stringify(n);if(r.some(i=>JSON.stringify(i)===a))return"unchanged";const l=Ne(e,n);return l!==void 0&&r.some(i=>Ne(e,i)===l)?"changed":"new"}const ga={file:Is,puzzle:Ve,clock:$n,terminal:ht,key:vt,globe:qe,check:hs,"alert-triangle":me},we={info:"text-muted-foreground",warning:"text-status-warning-fg",error:"text-destructive"};function ka({items:e,label:n}){return s.jsxs("details",{className:"group/details mt-1.5",children:[s.jsxs("summary",{className:oe("text-muted-foreground hover:text-foreground focus-ring inline-flex cursor-pointer","list-none items-center gap-1 rounded-sm text-xs select-none","[&::-webkit-details-marker]:hidden"),children:[s.jsx(Pe,{className:"size-3 shrink-0 transition-transform duration-200 group-open/details:rotate-90"}),n]}),s.jsx("ul",{className:"bg-muted/40 mt-1.5 max-h-64 space-y-0.5 overflow-y-auto rounded-md p-2",children:e.map((t,r)=>s.jsxs("li",{className:"text-2xs flex items-baseline gap-2 font-mono",children:[t.tag&&s.jsx("span",{className:oe("w-14 shrink-0",t.severity?we[t.severity]:we.info),children:t.tag}),s.jsx("span",{className:"text-foreground min-w-0 break-all","data-testid":"file-change-path",children:t.text})]},r))})]})}function Qs(e){const n=e.split(new RegExp(`(?<=\\/)|(?=["'])`));return n.map((t,r)=>s.jsxs(p.Fragment,{children:[t,r<n.length-1&&s.jsx("wbr",{})]},r))}function ge({item:e}){const n=ga[e.icon]??Is,t=e.severity?we[e.severity]:we.info;return s.jsxs("li",{className:oe("flex items-start gap-2 text-sm",t),children:[s.jsx(n,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[e.mono?s.jsx("code",{className:"bg-muted text-foreground block rounded px-1.5 py-1 font-mono text-xs [overflow-wrap:anywhere] whitespace-pre-wrap",children:Qs(e.label)}):s.jsx("span",{className:"break-words",children:e.label}),e.description&&s.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs break-words",children:e.description}),e.details&&e.details.length>0&&s.jsx(ka,{items:e.details,label:e.detailsLabel??"Show details"})]})]})}function Z({title:e,items:n,tone:t,defaultOpen:r=!1}){const[a,l]=p.useState(r);return n.length===0?null:s.jsx(ps,{open:a,onOpenChange:l,trigger:s.jsx("span",{className:oe("text-xs font-semibold tracking-wider uppercase",t==="warning"?"text-status-warning-fg":"text-muted-foreground"),children:e}),badge:s.jsx(se,{variant:"secondary",className:"text-xs",children:n.length}),children:s.jsx("ul",{className:"space-y-1.5",children:n.map((i,o)=>s.jsx(ge,{item:i},o))})})}function ja(e){return e.isolation!==void 0}function va({extensions:e}){const[n,t]=p.useState(!0),r=e.filter(ja);return r.length===0?null:s.jsx(ps,{open:n,onOpenChange:t,trigger:s.jsx("span",{className:"text-muted-foreground text-xs font-semibold tracking-wider uppercase",children:"What its extensions can reach"}),badge:s.jsx(se,{variant:"secondary",className:"text-xs",children:r.length}),children:s.jsx("ul",{className:"space-y-3","data-testid":"preview-extension-reach",children:r.map(a=>s.jsxs("li",{className:"flex min-w-0 items-start gap-2 text-sm",children:[s.jsx(Ve,{className:"text-muted-foreground mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground font-mono text-xs break-all",children:s.jsx("bdi",{children:a.id})}),s.jsx(In,{permissions:{runtime:a.isolation.runtime,net:a.isolation.net,run:a.isolation.run.map(l=>({name:l})),agents:a.isolation.agents,...a.hasServer!==void 0?{hasServer:a.hasServer}:{}},"data-testid":`preview-extension-reach-${a.id}`})]})]},a.id))})})}function Ys({preview:e,installBase:n}){const t=ua(e,{installBase:n}),r=Object.values(t).some(a=>a.length>0);return s.jsxs("div",{className:"space-y-6",children:[r&&s.jsx("p",{className:"text-sm",children:da(e)}),s.jsx(Z,{title:"What this package will do",items:t.effects}),s.jsx(va,{extensions:e.extensions}),s.jsx(Z,{title:"Commands this package declares",items:t.commands,defaultOpen:!0}),s.jsx(Z,{title:"Jobs it will schedule",items:t.schedules,defaultOpen:!0}),s.jsx(Z,{title:"Secrets required",items:t.secrets}),s.jsx(Z,{title:"External hosts",items:t.hosts}),s.jsx(Z,{title:"Dependencies",items:t.dependencies}),s.jsx(Z,{title:"Conflicts",items:t.conflicts,tone:"warning",defaultOpen:!0})]})}function ba(e){if(typeof e=="string")return e;if(e&&typeof e=="object"&&"name"in e)return String(e.name)}function Js(e){return e.scope===void 0||e.scope==="global"}function _e(e){var n;return Js(e)?"All agents (global)":e.agentName??((n=e.agentPath)==null?void 0:n.split("/").filter(Boolean).pop())??"This agent"}function ya(e){if(!e)return null;const n=[];return e.commands>0&&n.push(`${e.commands} command${e.commands===1?"":"s"}`),e.skills>0&&n.push(`${e.skills} skill${e.skills===1?"":"s"}`),e.hooks&&n.push("hooks"),n.length>0?n.join(" · "):null}const Na=3e3;function wa(){return s.jsxs("div",{className:"space-y-4",children:[s.jsx(B,{className:"h-4 w-3/4"}),s.jsx(B,{className:"h-4 w-1/2"}),s.jsx(B,{className:"h-20 w-full rounded-lg"}),s.jsx(B,{className:"h-4 w-2/3"})]})}function Oe({icon:e,children:n}){return s.jsxs("div",{className:"bg-muted/50 flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs",children:[s.jsx(e,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:n})]})}function Ca({installation:e,isRemoving:n,isConfirmingUninstall:t,disabled:r,onReinstall:a,onUninstallClick:l,published:i,onUnlink:o,onInstallPublished:d}){const u=Js(e),c=_e(e),h=u?qe:ks,f=e.installedAt?new Date(e.installedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null;return e.devLink?s.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx(h,{className:"text-muted-foreground mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:c}),s.jsx(js,{})]}),s.jsx(Vs,{installation:e})]})]}),s.jsx("div",{className:"flex flex-wrap items-center justify-end gap-1",children:s.jsx(Hs,{installation:e,published:i,label:c,onUnlink:o,onInstallPublished:d,disabled:r})})]}):s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx(h,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:c}),e.scope==="override"&&s.jsx("span",{className:"text-3xs shrink-0 rounded-full bg-amber-100 px-1.5 py-0.5 font-medium text-amber-700 dark:bg-amber-900 dark:text-amber-300",children:"Overrides global"})]}),s.jsxs("div",{className:"text-muted-foreground text-xs",children:["v",e.version,f&&` · ${f}`]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsxs(C,{size:"sm",variant:"ghost",disabled:r,onClick:a,"aria-label":`Reinstall for ${c}`,children:[s.jsx(He,{className:"mr-1 size-3","aria-hidden":!0}),"Reinstall"]}),s.jsxs(C,{size:"sm",variant:t?"destructive":"ghost",disabled:r,onClick:l,"aria-label":t?`Uninstall ${c} now`:`Uninstall for ${c}`,className:t?"":"text-destructive hover:text-destructive",children:[s.jsx(vs,{className:"mr-1 size-3","aria-hidden":!0}),n?"Removing…":t?"Uninstall now":"Uninstall"]})]})]})}function Pa({installations:e,uninstallPendingFor:n,anyMutationPending:t,onReinstall:r,onUninstall:a,published:l,onUnlink:i,onInstallPublished:o}){var T,v;const[d,u]=p.useState(null);function c(x){d===x.installPath?(u(null),a(x)):(u(x.installPath),setTimeout(()=>{u(N=>N===x.installPath?null:N)},Na))}const h=e.some(x=>x.type==="shape"),f=ya((T=e.find(x=>x.provides))==null?void 0:T.provides)??(h?"a workspace layout, agents, and schedules":null),w=(v=e.find(x=>x.installedFrom))==null?void 0:v.installedFrom;return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{className:"text-status-success-fg flex items-center gap-2 text-sm font-medium",children:[s.jsx(hs,{className:"size-4 shrink-0","aria-hidden":!0}),e.every(x=>x.devLink)?"Dev link":e.length===1?"Installed":`Installed in ${e.length} locations`]}),s.jsx("div",{className:"space-y-2",role:"list","aria-label":"Installations",children:e.map(x=>s.jsx("div",{role:"listitem",children:s.jsx(Ca,{installation:x,isRemoving:n===x.installPath,isConfirmingUninstall:d===x.installPath,disabled:t,onReinstall:()=>r(x),onUninstallClick:()=>c(x),published:l,onUnlink:()=>i(x),onInstallPublished:N=>o(x,N)})},x.installPath))}),s.jsxs("dl",{className:"text-muted-foreground space-y-1.5 text-xs",children:[w&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(gs,{className:"size-3 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:["from ",w]})]}),f&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ve,{className:"size-3 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:["Provides ",f]})]})]})]})}function Sa(){var b;const{selectedPackageName:e,closeDetail:n}=ke(),t=Ke(),{data:r}=Ce(),a=e?(r??[]).find(y=>y.name===e)??null:null;p.useEffect(()=>{e&&r&&!r.some(y=>y.name===e)&&n()},[e,r,n]);const l=a!==null,i=(a==null?void 0:a.name)??null,{data:o,isLoading:d}=wt(i,{enabled:l}),{data:u,isLoading:c}=je(),h=a!==null?(u??[]).filter(y=>y.name===a.name):[],f=h.length>0,{data:w}=Ct(i,{enabled:f}),{data:T,isLoading:v,error:x}=Cs(i,{enabled:l&&!f&&!c}),{data:N}=fs(),$=Ks(),k=qs(),L=d||v||l&&c,D=(T==null?void 0:T.preview)??(o==null?void 0:o.preview),A=ba((o==null?void 0:o.manifest.author)??(a==null?void 0:a.author)),M=o==null?void 0:o.manifest.version,H=o==null?void 0:o.manifest.license,U=a==null?void 0:a.homepage,R=a==null?void 0:a.marketplace;function O(y){a&&t(a,y.agentPath?{agentPath:y.agentPath,agentName:_e(y)}:void 0)}function F(y){a&&$.mutate({name:a.name,options:y.agentPath?{projectPath:y.agentPath}:void 0,where:y.agentPath?_e(y):void 0})}const _=$.isPending&&$.variables?((b=h.find(y=>{var q,j;return(y.agentPath??void 0)===((j=(q=$.variables)==null?void 0:q.options)==null?void 0:j.projectPath)}))==null?void 0:b.installPath)??null:null;return s.jsxs(Rn,{open:a!==null,onOpenChange:y=>!y&&n(),children:[s.jsx(Tn,{side:"right",className:"flex w-full flex-col overflow-hidden sm:max-w-xl",children:a&&s.jsxs(s.Fragment,{children:[s.jsxs(Dn,{className:"shrink-0 space-y-4 border-b pb-6",children:[s.jsxs("div",{className:"flex items-start gap-4 pr-8",children:[s.jsx("div",{className:"bg-muted flex size-14 shrink-0 items-center justify-center rounded-xl text-3xl",children:a.icon??"📦"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx(An,{className:"text-lg",children:be(a)}),s.jsx(xs,{type:a.type??"plugin",adapterType:a.adapterType,className:"shrink-0"})]}),a.description&&s.jsx(En,{className:"mt-1.5 line-clamp-3 text-sm",children:a.description})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[M&&s.jsxs(se,{size:"xs",variant:"outline",className:"font-mono",children:["v",M]}),A&&s.jsx(Oe,{icon:Ln,children:A}),R&&s.jsx(Oe,{icon:qe,children:R}),H&&s.jsx(Oe,{icon:yt,children:H})]}),U&&s.jsxs(Un,{href:U,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 text-xs transition-colors",children:[s.jsx(On,{className:"size-3","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:U})]})]}),s.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto px-4 py-6",children:[L?s.jsx(wa,{}):f?s.jsx(Pa,{installations:w??h,uninstallPendingFor:_,anyMutationPending:$.isPending,onReinstall:O,onUninstall:F,published:a,onUnlink:k.askUnlink,onInstallPublished:k.askInstallPublished}):x?s.jsx(Ps,{error:x}):D?s.jsxs("section",{children:[s.jsx("h3",{className:"mb-3 text-sm font-semibold",children:"What this can do"}),s.jsx(Ys,{preview:D,installBase:N==null?void 0:N.dorkHome})]}):s.jsx("p",{className:"text-muted-foreground text-sm",children:"No special permissions required."}),!L&&(o==null?void 0:o.readme)&&s.jsxs("section",{children:[s.jsx("h3",{className:"mb-3 text-sm font-semibold",children:"About"}),s.jsx(tt,{content:o.readme,className:"text-sm",errorFallback:s.jsx("p",{className:"text-muted-foreground text-sm",children:"This README couldn’t be displayed."})})]})]}),s.jsxs(Fn,{className:"flex-row gap-2 border-t pt-4",children:[s.jsx(C,{variant:"ghost",onClick:n,className:"flex-1",children:"Close"}),f?s.jsx(C,{variant:"outline",disabled:$.isPending,onClick:()=>t(a),className:"flex-1",children:"Install…"}):s.jsx(C,{onClick:()=>t(a),className:"flex-1",children:"Install"})]})]})}),s.jsx(Ss,{target:k.target,onClose:k.close,onUnlinked:k.onUnlinked})]})}function ts(e,n){return e instanceof Error?`Couldn’t install ${n}: ${e.message}`:`Couldn’t install ${n}. Try again.`}function as(e,n,t){var l;const r=e.warnings.length>0?e.warnings.join(" "):void 0;return e.type==="shape"?{id:n,description:r,action:{label:"Apply…",onClick:()=>bs.getState().openShapeSwitcherToShape(e.packageName)}}:zn(e.type,(l=e.manifest)==null?void 0:l.adapterType)?{id:n,description:r,action:{label:"Open Connections",onClick:()=>t()}}:{id:n,description:r}}function $a(){const e=It(),n=Mn(),{mutate:t,mutateAsync:r}=e,a=p.useCallback(i=>{const o=K(i.name),d=S.loading(`Installing ${o}…`);t(i,{onSuccess:u=>{S.success(`Installed ${o}`,as(u,d,n))},onError:u=>{S.error(ts(u,o),{id:d})}})},[t,n]),l=p.useCallback(async i=>{const o=K(i.name),d=S.loading(`Installing ${o}…`);try{const u=await r(i);return S.success(`Installed ${o}`,as(u,d,n)),u}catch(u){throw S.error(ts(u,o),{id:d}),u}},[r,n]);return{...e,mutate:a,mutateAsync:l}}function Ia(e,n){return n==="global"?e===void 0||e==="global":e==="agent-local"||e==="override"}function Ra(e){return e.isPending?e.isReinstall?"Reinstalling…":"Installing…":e.hasBlockingConflicts?"Can’t install: conflicts found":e.isReinstall?"Reinstall":"Install"}function Ta(){var q;const e=Le(j=>j.installConfirmPackage),n=Le(j=>j.installContext),t=Le(j=>j.closeInstallConfirm),r=$a(),{data:a}=ys(),l=(a==null?void 0:a.agents)??[],i=(e==null?void 0:e.type)==="shape",o=n?"agent-local":"global",d=n?(q=l.find(j=>j.projectPath===n.agentPath))==null?void 0:q.id:void 0,[u,c]=p.useState(null),h=u!==null&&u.forContext===n?u:null,f=(h==null?void 0:h.scope)??o,w=h===null?d:h.agentId,T=j=>c({forContext:n,scope:j.scope??f,agentId:"agentId"in j?j.agentId:w}),v=i?"global":f,x=l.find(j=>j.id===w),N=v==="agent-local"?x==null?void 0:x.projectPath:void 0,$=v==="agent-local"&&!w,{data:k,isLoading:I,error:L}=Cs((e==null?void 0:e.name)??null,{enabled:e!==null&&!$,...N?{projectPath:N}:{}}),D=$?null:(k==null?void 0:k.preview)??null,{data:A}=fs(),M=N?`${N}/.dork`:A==null?void 0:A.dorkHome,H=D!==null&&D.conflicts.some(j=>j.level==="error"),{data:U}=je(N),R=!$&&(U??[]).some(j=>j.name===(e==null?void 0:e.name)&&Ia(j.scope,v)),O=!$&&L!==null,F=r.isPending||I||O||H||e===null||$,_=Ra({isPending:r.isPending,isReinstall:R,hasBlockingConflicts:H});async function b(){if(e)try{const j={...N&&{projectPath:N},...(k==null?void 0:k.disclosed)&&{approvedDisclosure:k.disclosed,approvedContentHash:k.contentHash}};await r.mutateAsync({name:e.name,options:Object.keys(j).length>0?j:void 0}),t()}catch{}}function y(j){j||t()}return s.jsx(Se,{open:e!==null,onOpenChange:y,children:s.jsx($e,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:e&&s.jsxs(s.Fragment,{children:[s.jsxs(Ie,{className:"shrink-0",children:[s.jsxs(Re,{children:[R?"Reinstall":"Install"," ",be(e),"?"]}),s.jsx(Te,{children:R?"This replaces the installed copy. Check what it does below.":"Check what this package does before you install it."})]}),s.jsx("div",{className:"shrink-0 space-y-2 px-4 sm:px-6",children:i?s.jsx("p",{className:"text-muted-foreground text-sm",children:"Shapes apply to your whole app."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:"Install for"}),s.jsxs(Ns,{value:f,onValueChange:j=>{const G=j;T(G==="global"?{scope:G,agentId:void 0}:{scope:G})},className:"gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ye,{value:"global",id:"scope-global"}),s.jsx(ee,{htmlFor:"scope-global",className:"text-sm font-normal",children:"All agents (global)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ye,{value:"agent-local",id:"scope-agent"}),s.jsx(ee,{htmlFor:"scope-agent",className:"text-sm font-normal",children:"Specific agent"})]})]}),f==="agent-local"&&s.jsx("div",{className:"pl-6",children:s.jsx(Rs,{agents:l,value:w,onValueChange:j=>T({agentId:j})})})]})}),s.jsxs(De,{className:"mt-4",children:[$&&s.jsx("p",{className:"text-muted-foreground text-sm",children:"Pick an agent to preview this install."}),I&&s.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading preview…"}),O&&s.jsx(Ps,{error:L}),D&&s.jsx(Ys,{preview:D,installBase:M})]}),s.jsxs(Ae,{className:"shrink-0",children:[s.jsx(C,{variant:"ghost",onClick:t,disabled:r.isPending,children:"Cancel"}),s.jsx(C,{onClick:b,disabled:F,children:_})]})]})})})}function Da(e){return new Map((e??[]).map(n=>[n.installPath,n]))}function rs(e){return e.startsWith("v")?e.slice(1):e}function Xs(e,n){const t=n.get(e.installPath);if(t)return t.installedVersionSource!=="package"||rs(t.installedVersion)===rs(e.version)?t:void 0}function Aa(e,n,t){const r=Xs(e,n);return t.applying.has(e.installPath)?{kind:"applying",check:r}:t.isChecking?{kind:"checking"}:r?{kind:r.status,check:r}:{kind:"unchecked"}}function Ea(e,n){const t={available:[],current:0,unknown:0};for(const r of e){if(r.devLink)continue;const a=Xs(r,n);(a==null?void 0:a.status)==="update-available"?t.available.push({installation:r,check:a}):(a==null?void 0:a.status)==="current"?t.current+=1:(a==null?void 0:a.status)==="unknown"&&(t.unknown+=1)}return t}const La=7;function X(e,n){return n==="commit"?e.slice(0,La):e.startsWith("v")?e:`v${e}`}function ce(e){var n;return e.scope!=="agent-local"&&e.scope!=="override"?null:e.agentName??((n=e.agentPath)==null?void 0:n.split("/").filter(Boolean).pop())??"agent"}function Ua(e){var n,t;return((t=(n=e.applied)==null?void 0:n.fileNotices)==null?void 0:t.some(r=>r.outcome==="kept-unproven"))??!1}function Zs({installation:e}){const n=K(e.name),t=ce(e);return t?`${n} on ${t}`:n}function Oa(e,n){if(n!=null&&n.applied){const t=Ms(n),r=X(t.installedVersion,t.installedVersionSource),a=n.applied.warnings??[];return{kind:"success",message:`Updated ${e} to ${r}`,...a.length>0&&{description:a.join(" ")}}}if(n!=null&&n.applyError)return{kind:"error",message:`Couldn’t update ${e}: ${n.applyError}`};if((n==null?void 0:n.status)==="current")return{kind:"success",message:`${e} is already up to date`};if((n==null?void 0:n.status)==="unknown"){const t=n.note?`: ${n.note}`:"";return{kind:"warning",message:`Couldn’t check ${e} for updates${t}`}}return{kind:"warning",message:`${e} wasn’t updated`}}function Fa(e){const n=e.length,t=e.filter(a=>a.applied).length,r=e.filter(a=>a.applyError).length;return t===n?{kind:"success",message:e.some(Ua)?`Updated ${n} packages. Some kept files need sorting; see their rows.`:`Updated ${n} packages`}:t>0?{kind:"warning",message:`Updated ${t} of ${n} packages. Each row shows why.`}:r>0?{kind:"error",message:`Couldn’t update ${r===n?`${n}`:`${r} of ${n}`} packages. Each row shows why.`}:e.every(a=>a.status==="current")?{kind:"success",message:`All ${n} packages are up to date`}:{kind:"warning",message:"Nothing was updated. Each row shows why."}}function Ma(e,n){const t=new Map(n.checks.map(r=>[r.installPath,r]));if(e.length===1){const r=e[0];return Oa(Zs(r),t.get(r.check.installPath))}return Fa(e.map(({check:r})=>t.get(r.installPath)??r))}function za(e,n){S[e.kind](e.message,{id:n,...e.description&&{description:e.description}})}const _a="batch_update_needs_approval",Ka="disclosure_changed";function qa(e,n){const t=e==null?void 0:e.code;return t===Ka?`${n.length===1?"This package":"One of these packages"} changed what it runs since you looked. Review it again.`:t===_a?n.length===1?`It needs your approval. Run \`dorkos marketplace update ${n[0].check.packageName} --apply\` in a terminal.`:"Each needs your approval. Run `dorkos marketplace update <name> --apply` in a terminal.":e instanceof Error?e.message:String(e)}function Va(){const{mutateAsync:e}=Dt(),n=p.useRef(new Set);return{apply:p.useCallback(r=>{const a=r.filter(({check:c})=>!n.current.has(c.installPath)),[l,...i]=a.map(({check:c})=>({installPath:c.installPath,latestVersion:c.latestVersion,disclosed:c.disclosed??null,contentHash:c.contentHash??""}));if(l===void 0)return;const o=a.map(({check:c})=>c.installPath);for(const c of o)n.current.add(c);const d=a.length===1?Zs(a[0]):`${a.length} packages`,u=S.loading(`Updating ${d}…`);e({targets:[l,...i]}).then(c=>za(Ma(a,c),u)).catch(c=>S.error(`Couldn’t update ${d}`,{id:u,description:qa(c,a)})).finally(()=>{for(const c of o)n.current.delete(c)})},[e])}}function Ha(){const e=Tt(),{mutate:n}=e,t=p.useCallback(({where:r,...a})=>{const l=r?`${K(a.name)} on ${r}`:K(a.name),i=S.loading(`Checking the files of ${l}…`);n(a,{onSuccess:o=>{(o.outcome==="rebuilt"||o.outcome==="not-needed"?S.success:S.warning)(o.message,{id:i})},onError:o=>{S.error(`Couldn’t check the files of ${l}: ${o.message}`,{id:i})}})},[n]);return{...e,mutate:t}}function Wa(){const e=Ut(),{mutate:n}=e,t=p.useCallback(r=>{n(r,{onSuccess:a=>{S.success(a.message)},onError:a=>{S.error(a.message)}})},[n]);return{...e,mutate:t}}function en(){const e=ae(),{data:n}=je(),t=((n==null?void 0:n.length)??0)>0,r=$t(void 0,{enabled:t}),{data:a,isFetching:l,error:i,refetch:o}=r,d=p.useRef(n);p.useEffect(()=>{const h=d.current;d.current=n,!(h===void 0||h===n)&&e.invalidateQueries({queryKey:P.updates(),refetchType:"none"})},[n,e]);const u=p.useMemo(()=>Da(i||a==null?void 0:a.checks),[a,i]),c=p.useMemo(()=>Ea(n??[],u),[n,u]);return{checks:u,summary:c,isChecking:l,error:i,recheck:()=>void o()}}function sn(e){const n=p.useRef(null),t=p.useRef(!1);p.useEffect(()=>{var l;if(e||!t.current)return;t.current=!1;const a=document.activeElement;(a===null||a===document.body)&&((l=n.current)==null||l.focus())},[e]);const r=p.useMemo(()=>({onFocus:()=>{t.current=!0},onBlur:a=>{a.relatedTarget!==null&&(t.current=!1)}}),[]);return{targetRef:n,controlProps:r}}function Ba(e){return e===1?"1 package is":`${e} packages are`}function Ga(e){return`${e} ${e===1?"package":"packages"}`}function Qa(e){const n=[];return e.current>0&&n.push(`${Ba(e.current)} up to date.`),e.unknown>0&&n.push(`${Ga(e.unknown)} couldn’t be checked.`),n}function Ya(e){const n=e.available.length;return n>0?{headline:`${n} ${n===1?"update":"updates"} available.`,allCurrent:!1}:e.current>0&&e.unknown===0?{headline:"All packages are up to date.",allCurrent:!0}:e.current===0&&e.unknown===0?{headline:"Not checked for updates yet.",allCurrent:!1}:{headline:"No updates found.",allCurrent:!1}}function Ja({summary:e,isChecking:n,error:t,isApplying:r,onUpdateAll:a,onRecheck:l}){const{headline:i,allCurrent:o}=Ya(e),d=o?[]:Qa(e),u=!n&&!t&&e.available.length>0,{targetRef:c,controlProps:h}=sn(u);return s.jsxs("div",{className:"bg-muted/40 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 rounded-xl px-4 py-3",children:[s.jsx("p",{ref:c,tabIndex:-1,role:"status","aria-live":"polite",className:"focus-visible:ring-ring min-w-0 rounded-sm text-sm outline-none focus-visible:ring-2",children:n?s.jsxs("span",{className:"text-muted-foreground flex items-center gap-2",children:[s.jsx(Fe,{size:"xs"}),"Checking your packages for updates…"]}):t?s.jsxs("span",{children:["Couldn’t check for updates: ",t.message]}):s.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[o&&s.jsx(ws,{className:"text-status-success-fg size-4 shrink-0","aria-hidden":!0}),s.jsx("span",{className:e.available.length>0?"font-medium":void 0,children:i}),d.map(f=>s.jsx("span",{className:"text-muted-foreground",children:f},f))]})}),!n&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(C,{size:"sm",variant:"ghost",onClick:l,disabled:r,children:[s.jsx(He,{className:"mr-1 size-3","aria-hidden":!0}),t?"Try again":"Check again"]}),u&&s.jsx(C,{size:"sm","aria-disabled":r||void 0,className:"aria-disabled:cursor-not-allowed aria-disabled:opacity-50",onClick:r?void 0:a,...h,children:"Update all…"})]})]})}const le="flex items-start gap-1.5 text-xs",ie="mt-0.5 size-3 shrink-0";function ls({text:e}){return s.jsx("p",{className:"text-muted-foreground pl-4.5 text-xs",children:e})}function Xa({state:e}){switch(e.kind){case"checking":return s.jsxs("p",{className:`${le} text-muted-foreground`,children:[s.jsx(Fe,{size:"xs",className:ie}),"Checking for updates…"]});case"applying":return s.jsxs("p",{className:`${le} text-muted-foreground`,children:[s.jsx(Fe,{size:"xs",className:ie}),e.check?`Updating to ${X(e.check.latestVersion,e.check.latestVersionSource)}…`:"Updating…"]});case"update-available":{const{check:n}=e,t=X(n.installedVersion,n.installedVersionSource),r=X(n.latestVersion,n.latestVersionSource);return s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("p",{className:`${le} text-status-info-fg font-medium`,children:[s.jsx(kt,{className:ie,"aria-hidden":!0}),s.jsxs("span",{children:["Update available: ",t," ",s.jsx("span",{"aria-hidden":!0,children:"→"}),s.jsx("span",{className:"sr-only",children:"to"})," ",r]})]}),n.note&&s.jsx(ls,{text:n.note}),n.applyError&&s.jsxs("p",{className:`${le} text-destructive`,children:[s.jsx(me,{className:ie,"aria-hidden":!0}),s.jsxs("span",{children:["Couldn’t update: ",n.applyError]})]})]})}case"current":return s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("p",{className:`${le} text-muted-foreground`,children:[s.jsx(ws,{className:ie,"aria-hidden":!0}),"Up to date"]}),e.check.note&&s.jsx(ls,{text:e.check.note})]});case"unknown":return s.jsxs("p",{className:`${le} text-muted-foreground`,children:[s.jsx(_n,{className:ie,"aria-hidden":!0}),s.jsxs("span",{children:["Couldn’t check for updates",e.check.note?`: ${e.check.note}`:""]})]});case"unchecked":return null}}const Za="Check files so updates keep your edits.";function er(e,n){return e===1?`the file you ${n}`:`the ${e} files you ${n}`}function nn(e){return[e.changed.length>0&&`Updating replaces ${er(e.changed.length,"edited")} and keeps your copies beside them.`,e.added.length>0&&(e.added.length===1?"The file you added stays.":`The ${e.added.length} files you added stay.`),e.missing.length>0&&(e.missing.length===1?"The file you removed comes back.":`The ${e.missing.length} files you removed come back.`)].filter(n=>typeof n=="string")}function sr(e){if(e.changed.length>0)return"Updating replaces your edits; copies are kept.";if(e.missing.length>0)return"Updating puts back files you removed.";if(e.added.length>0)return"Updating keeps the files you added."}function nr(e){const t=[[e.changed.length,"edited"],[e.added.length,"added"],[e.missing.length,"removed"]].filter(([i])=>i>0),r=t.reduce((i,[o])=>i+o,0),a=e.truncated?"+":"",l=`${r}${a} ${r===1?"file":"files"} changed since install`;return t.length>1?`${l} (${t.map(([i,o])=>`${i} ${o}`).join(", ")})`:l}function tn(e){return(e==null?void 0:e.status)==="unknown"&&(e.reason==="no-record"||e.reason==="inferred")}function tr(e){var r,a;const n=tn(e)?e.check:(e==null?void 0:e.status)==="clean"||(e==null?void 0:e.status)==="modified"?(r=e.unproven)==null?void 0:r.check:void 0;if(!n||n.source==="local")return!1;const t=(a=n.last)==null?void 0:a.outcome;return t!=="mismatch"&&t!=="no-source"}function ar(e){var n;return e.check.source==="local"||((n=e.check.last)==null?void 0:n.outcome)==="fetch-failed"}function ne({title:e,paths:n}){return n.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-3xs font-medium tracking-wide uppercase",children:e}),s.jsx("ul",{"aria-label":e,className:"mt-0.5 space-y-0.5",children:n.map(t=>s.jsx("li",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:t},t))})]})}function rr({unproven:e,label:n,onKeepFiles:t}){const r=e.files.length,a=e.running,l=a.length>0,i=e.check.source==="local",o=e.files.filter(d=>!a.includes(d));return s.jsxs("details",{"data-testid":"installation-integrity-unproven","data-runs":l?"true":"false",className:"group/kept mt-1 text-xs",children:[s.jsxs("summary",{className:oe("focus-ring flex cursor-pointer list-none items-start gap-1 rounded-sm select-none [&::-webkit-details-marker]:hidden",l?"text-amber-700 hover:text-amber-800 dark:text-amber-400 dark:hover:text-amber-300":"text-muted-foreground hover:text-foreground"),children:[s.jsx(Ts,{className:"mt-0.5 size-3 shrink-0 text-amber-600 dark:text-amber-400","aria-hidden":!0}),s.jsxs("span",{children:["Kept ",r," ",r===1?"file":"files"," an update couldn’t sort.",l&&` ${a.length} of ${r===1?"it":"them"} still ${a.length===1?"runs":"run"}.`]}),s.jsx(Pe,{className:"mt-0.5 size-3 shrink-0 transition-transform duration-200 group-open/kept:rotate-90","aria-hidden":!0})]}),s.jsxs("div",{className:"text-muted-foreground mt-1.5 space-y-1.5 pl-4",children:[s.jsx("p",{children:"Unclear if these are yours or leftovers, so DorkOS kept them."}),s.jsx("p",{children:i?"Keep them as yours, or delete any you don’t need.":"Check files sets aside the leftovers and keeps yours."}),e.check.last&&s.jsx("p",{children:e.check.last.message}),s.jsx(ne,{title:"Still runs",paths:a}),s.jsx(ne,{title:"Kept",paths:o}),t&&ar(e)&&s.jsx(C,{size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:t,"aria-label":`Keep the files ${n??"this package"} kept as mine`,children:"Keep these as mine"})]})]})}function lr(e){const{integrity:n}=e,t=(n==null?void 0:n.status)==="clean"||(n==null?void 0:n.status)==="modified"?n.unproven:void 0;return t?s.jsxs(s.Fragment,{children:[s.jsx(is,{...e}),s.jsx(rr,{unproven:t,label:e.label,onKeepFiles:e.onKeepFiles})]}):s.jsx(is,{...e})}function is({integrity:e,updateAvailable:n,label:t,onCheckFiles:r,isCheckingFiles:a=!1}){var l,i;if((e==null?void 0:e.status)==="modified"){const o=n?nn(e):[],d=n?sr(e):void 0;return s.jsxs("details",{"data-testid":"installation-integrity",className:"group/files mt-1 text-xs",children:[s.jsxs("summary",{className:"text-muted-foreground hover:text-foreground focus-ring flex cursor-pointer list-none items-start gap-1 rounded-sm select-none [&::-webkit-details-marker]:hidden",children:[s.jsx(ft,{className:"text-status-warning-dot mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsxs("span",{className:"flex flex-col",children:[s.jsxs("span",{children:[nr(e),"."]}),d&&s.jsx("span",{"data-testid":"installation-integrity-update",children:d})]}),s.jsx(Pe,{className:"mt-0.5 size-3 shrink-0 transition-transform duration-200 group-open/files:rotate-90","aria-hidden":!0})]}),s.jsxs("div",{className:"text-muted-foreground mt-1.5 space-y-1.5 pl-4",children:[o.map(u=>s.jsx("p",{children:u},u)),s.jsx(ne,{title:"Edited",paths:e.changed}),s.jsx(ne,{title:"Added",paths:e.added}),s.jsx(ne,{title:"Removed",paths:e.missing}),e.truncated&&s.jsx("p",{children:"Showing the first 50 of each."})]})]})}if(tn(e)){const o=((l=e.check)==null?void 0:l.source)==="local",d=(i=e.check)==null?void 0:i.last,u=o?"Installed from a folder by an older DorkOS. Reinstall so updates keep your edits.":d?d.message:`Installed by an older DorkOS. ${Za}`,c=!o&&(d==null?void 0:d.outcome)==="mismatch"&&r;return s.jsxs("p",{"data-testid":"installation-integrity",className:"text-muted-foreground mt-1 flex items-start gap-1 text-xs",children:[s.jsx(Ts,{className:"text-status-warning-dot mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:[u,c&&s.jsxs(s.Fragment,{children:[" ",s.jsx("button",{type:"button",onClick:r,disabled:a,"aria-label":`Check the files of ${t??"this package"} again`,className:"text-foreground focus-ring rounded-sm underline underline-offset-2 disabled:opacity-50",children:a?"Checking…":"Try again"})]})]})]})}return null}function os(e){if(e.length!==1)return`${e.length} packages`;const[{installation:n}]=e,t=ce(n),r=K(n.name);return t?`${r} on ${t}`:r}function an({check:e}){return e.disclosed?fa(e.disclosed,e.installedDisclosed,e.scope==="global"?"global":"project"):[]}function ir(e){const n=e.map(an),t=n.filter(i=>i.length>0).length,r=n.filter(i=>i.some(o=>o.change==="new"||o.change==="changed")).length,a=e.length===1?t===1?"The new version runs things on its own":"The new version runs nothing on its own":`${t} of ${e.length} run things on their own`;if(r===0)return a;const l=e.length===1?"it adds or changes something":`${r} ${r===1?"adds":"add"} or ${r===1?"changes":"change"} something`;return`${a} · ${l}`}function or({change:e}){return e!=="new"&&e!=="changed"?null:s.jsx(se,{variant:"outline",className:"text-3xs shrink-0 border-amber-500/60 text-amber-700 dark:text-amber-300",children:e==="new"?"New":"Changed"})}function cs({row:e,change:n,previous:t}){return s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("ul",{children:s.jsx(ge,{item:e})}),t&&s.jsxs("div",{className:"mt-1 pl-6 opacity-70",children:[s.jsx("p",{className:"text-muted-foreground text-3xs mb-0.5 font-medium tracking-wide uppercase",children:"Installed now"}),s.jsx("ul",{"aria-label":"What the installed version runs instead",children:s.jsx(ge,{item:{...t,description:void 0,details:void 0}})})]})]}),s.jsx(or,{change:n})]})}function cr(e){const n=an(e);if(n.length===0)return s.jsx("p",{className:"text-muted-foreground text-xs",children:"The new version runs nothing on its own."});const t=n.filter(a=>a.change!=="unchanged"),r=n.filter(a=>a.change==="unchanged");return s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("p",{className:"text-muted-foreground text-xs",children:["The new version runs ",n.length===1?"this":`these ${n.length}`," on its own:"]}),s.jsxs("div",{role:"list","aria-label":"What the new version runs",className:"space-y-2",children:[t.map((a,l)=>s.jsx("div",{role:"listitem",children:s.jsx(cs,{...a})},`lead-${l}`)),r.length>0&&s.jsxs("details",{className:"group/unchanged",role:"listitem",children:[s.jsxs("summary",{className:"text-muted-foreground hover:text-foreground focus-ring inline-flex cursor-pointer list-none items-center gap-1 rounded-sm text-xs select-none [&::-webkit-details-marker]:hidden",children:[s.jsx(Pe,{className:"size-3 shrink-0 transition-transform duration-200 group-open/unchanged:rotate-90"}),r.length," unchanged"]}),s.jsx("div",{className:"mt-2 space-y-2",children:r.map((a,l)=>s.jsx(cs,{...a},`same-${l}`))})]})]})]})}function dr({integrity:e,...n}){const{installation:t,check:r}=n,a=ce(t),l=X(r.installedVersion,r.installedVersionSource),i=X(r.latestVersion,r.latestVersionSource);return s.jsxs("li",{className:"bg-muted/40 space-y-2 rounded-lg px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium",children:K(t.name)}),s.jsx("div",{className:"text-muted-foreground text-xs",children:a??"All agents"}),a&&t.agentPath&&s.jsx("div",{className:"text-muted-foreground text-2xs font-mono [overflow-wrap:anywhere]",children:Qs(t.agentPath)})]}),s.jsxs("div",{className:"shrink-0 font-mono text-xs",children:[l," ",s.jsx("span",{"aria-hidden":!0,children:"→"}),s.jsx("span",{className:"sr-only",children:"to"})," ",i]})]}),(e==null?void 0:e.status)==="modified"&&nn(e).map(o=>s.jsx("p",{className:"text-muted-foreground text-xs",children:o},o)),s.jsx(cr,{...n})]})}function ur({stale:e,onCancel:n,onConfirm:t,integrityByPath:r}){return s.jsx(Se,{open:e!==null,onOpenChange:a=>!a&&n(),children:s.jsx($e,{className:"max-h-[85vh] !min-h-0 sm:max-w-xl",children:e&&s.jsxs(s.Fragment,{children:[s.jsxs(Ie,{className:"shrink-0 text-left",children:[s.jsxs(Re,{className:"text-left",children:["Update ",os(e),"?"]}),s.jsx(Te,{className:"text-left",children:e.length===1?"The newest version replaces this one in place. Check what it runs first.":"Each newest version replaces the one installed. Check what each runs first."}),s.jsx("p",{className:"text-foreground text-left text-xs font-medium","data-testid":"update-disclosure-summary",children:ir(e)})]}),s.jsx(De,{children:s.jsx("ul",{"aria-label":"Packages to update",className:"space-y-2",children:e.map(a=>s.jsx(dr,{...a,integrity:r==null?void 0:r.get(a.installation.installPath)},a.check.installPath))})}),s.jsxs(Ae,{className:"shrink-0",children:[s.jsx(C,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsxs(C,{onClick:()=>t(e),children:["Update ",os(e)]})]})]})})})}function mr(e){return e!==null&&e.heldBack!==void 0&&(e.scope===void 0||e.scope==="global")}function hr({installation:e,unproven:n,onCancel:t,onConfirm:r}){var T;const a=mr(e),l=Lt(a),i=a?(T=l.data)==null?void 0:T.find(v=>v.name===(e==null?void 0:e.name)):void 0,o=i!=null&&i.effects&&i.bindsTo?{effects:i.effects,bindsTo:i.bindsTo}:void 0,d=a&&l.isPending,u=e!==null&&n!==void 0,c=e?K(e.name):"",h=(n==null?void 0:n.running)??[],f=(n==null?void 0:n.files.filter(v=>!h.includes(v)))??[],w=o?We(o.effects,"global"):[];return s.jsx(Se,{open:u,onOpenChange:v=>!v&&t(),children:s.jsx($e,{className:"max-h-[85vh] !min-h-0 sm:max-w-lg",children:u&&e&&n&&s.jsxs(s.Fragment,{children:[s.jsxs(Ie,{className:"shrink-0 text-left",children:[s.jsxs(Re,{className:"text-left",children:["Keep these ",c," files as yours?"]}),s.jsx(Te,{className:"text-left",children:"An update couldn’t tell if these are yours or leftovers."})]}),s.jsxs(De,{className:"space-y-3 text-xs",children:[s.jsxs("div",{className:"text-muted-foreground space-y-1",children:[s.jsx("p",{children:n.check.source==="local"?"No earlier version to compare with.":"DorkOS couldn’t download the old version to compare."}),s.jsx("p",{children:"Keeping makes them yours. Updates leave them alone."}),s.jsx("p",{children:"Nothing is moved or deleted."}),h.length>0&&s.jsx("p",{children:"They now run as your own files."})]}),s.jsx(ne,{title:"Still runs",paths:h}),s.jsx(ne,{title:"Kept",paths:f}),a&&s.jsx("div",{"data-testid":"keep-files-activation",className:"space-y-1.5",children:d?s.jsxs("p",{className:"text-muted-foreground",children:["Reading what ",c," runs…"]}):o?s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-foreground font-medium",children:[c," is held back from chats."]}),s.jsx("p",{className:"text-foreground",children:"Keeping also lets it run in every chat, as it is now:"}),s.jsx("ul",{"aria-label":`What ${c} runs`,className:"space-y-1.5",children:w.map((v,x)=>s.jsx(ge,{item:v},x))})]}):s.jsxs("p",{className:"text-muted-foreground",children:[c," stays held back until you review it."]})})]}),s.jsxs(Ae,{className:"shrink-0",children:[s.jsx(C,{variant:"ghost",onClick:t,children:"Cancel"}),s.jsx(C,{disabled:d,onClick:()=>r({installRoot:e.installPath,keepKey:n.keepKey,...e.agentPath&&{projectPath:e.agentPath},...o&&{review:o}}),children:o?"Keep them and let it run":"Keep them as mine"})]})]})})})}const pr="dev_link_changed",fe={card:null,refusal:null,checking:!1};function ds(e){const n=e;return{message:(n==null?void 0:n.message)||"Couldn’t check this folder. Try again.",code:n==null?void 0:n.code}}function fr({open:e,onOpenChange:n}){var z;const[t,r]=p.useState(""),[a,l]=p.useState("global"),[i,o]=p.useState(void 0),[d,u]=p.useState(!1),[c,h]=p.useState(fe),[f,w]=p.useState(!1),[T,v]=p.useState(null),[x,N]=p.useState(null),[$,k]=p.useState(!1),I=p.useRef(0),L=dt(),D=ut(),{data:A}=ys({enabled:e}),M=(A==null?void 0:A.agents)??[],H=a==="agent-local"?(z=M.find(g=>g.id===i))==null?void 0:z.projectPath:void 0,U=a==="agent-local"&&H===void 0;function R(){I.current+=1,n(!1)}async function O(g){const V=(g.path??t).trim(),Q="projectPath"in g?g.projectPath:H,Y=g.replaceInstalled??!1;u(Y),N(null),v(null),g.keepChangedNotice||w(!1);const he=++I.current,rn=!("projectPath"in g)&&U;if(V===""||rn){h(fe);return}h(pe=>({card:g.keepCard?pe.card:null,refusal:null,checking:!0}));try{const pe=await L.mutateAsync({path:V,...Q?{scope:"project",projectPath:Q}:{scope:"global"},...Y&&{replaceInstalled:!0}});if(he!==I.current)return;h({card:{preview:pe,replaceInstalled:Y,projectPath:Q},refusal:null,checking:!1})}catch(pe){if(he!==I.current)return;h({card:null,refusal:ds(pe).message,checking:!1})}}function F(g){c.card&&O({path:c.card.preview.path,projectPath:c.card.projectPath,replaceInstalled:g,keepCard:!0})}async function _(){if(!c.card||c.checking)return;N(null);const{preview:g,replaceInstalled:V,projectPath:Q}=c.card;try{const Y=await D.mutateAsync({path:g.path,...Q?{scope:"project",projectPath:Q}:{scope:"global"},...V&&{replaceInstalled:!0},via:"app",expectedChange:g.change});if(Y.status==="approval_required"){v(Y.approval);return}S.success(`${K(g.name)} runs from your folder.`),R()}catch(Y){const he=ds(Y);if(he.code===pr){w(!0),await O({path:g.path,projectPath:Q,replaceInstalled:V,keepChangedNotice:!0});return}N(he.message)}}const b=c.card,y=(b==null?void 0:b.preview.replaces)??null,q=b?K(b.preview.name):"",j=b!=null&&b.preview.effects?We(b.preview.effects,b.projectPath?"project":"global"):[],G=(b==null?void 0:b.preview.extensions)??[],m=y===null||d&&(b==null?void 0:b.replaceInstalled)===!0,E=b===null||c.checking||!m||D.isPending||T!==null;return s.jsxs(Se,{open:e,onOpenChange:g=>g?n(!0):R(),children:[s.jsxs($e,{className:"max-h-[85vh] !min-h-0 sm:max-w-lg",children:[s.jsxs(Ie,{className:"shrink-0 text-left",children:[s.jsx(Re,{className:"text-left",children:b?`Run ${q} from this folder?`:"Link a folder"}),s.jsx(Te,{className:"text-left",children:"Run a plugin or skill pack from your own folder."})]}),s.jsxs(De,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{htmlFor:"dev-link-path",children:"Folder"}),s.jsx(xt,{id:"dev-link-path",value:t,placeholder:"/Users/you/code/my-plugin",onChange:g=>{r(g),c!==fe&&(I.current+=1,h(fe),u(!1))},onBlur:()=>void O({}),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),O({}))},onBrowse:()=>k(!0),browseTestId:"dev-link-browse","aria-describedby":c.refusal?"dev-link-refusal":void 0,"aria-invalid":c.refusal?!0:void 0,autoComplete:"off",spellCheck:!1}),c.refusal&&s.jsx("p",{id:"dev-link-refusal",role:"alert",className:"text-status-warning-fg text-xs [overflow-wrap:anywhere]",children:c.refusal}),s.jsx("p",{className:"text-muted-foreground text-xs empty:hidden","aria-live":"polite",children:c.checking?"Checking the folder…":""})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:"Run for"}),s.jsxs(Ns,{value:a,onValueChange:g=>{const V=g;l(V),V==="global"?(o(void 0),O({projectPath:void 0})):(I.current+=1,h(fe),u(!1))},className:"gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ye,{value:"global",id:"dev-link-scope-global"}),s.jsx(ee,{htmlFor:"dev-link-scope-global",className:"text-sm font-normal",children:"All agents (global)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ye,{value:"agent-local",id:"dev-link-scope-agent"}),s.jsx(ee,{htmlFor:"dev-link-scope-agent",className:"text-sm font-normal",children:"Specific agent"})]})]}),a==="agent-local"&&s.jsx("div",{className:"pl-6",children:s.jsx(Rs,{agents:M,value:i,onValueChange:g=>{var V;o(g),O({projectPath:(V=M.find(Q=>Q.id===g))==null?void 0:V.projectPath})}})}),U&&t.trim()!==""&&s.jsx("p",{className:"text-muted-foreground text-xs",children:"Pick an agent to check this folder."})]}),f&&s.jsx(Me,{tone:"info",role:"alert",children:"The folder changed. Check it again."}),b&&s.jsxs("section",{"aria-label":"What linking does",className:"space-y-3 text-sm",children:[s.jsx("code",{className:"bg-muted block rounded px-2 py-1.5 font-mono text-xs [overflow-wrap:anywhere]",children:b.preview.path}),s.jsx("p",{children:"Edits here run in DorkOS right away, without asking."}),y&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{children:["Your installed copy (v",y.version,") is set aside, not deleted."]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Kn,{id:"dev-link-replace",checked:d,onCheckedChange:g=>{c.checking||F(g===!0)},"aria-disabled":c.checking||void 0,className:"aria-disabled:cursor-not-allowed aria-disabled:opacity-50"}),s.jsx(ee,{htmlFor:"dev-link-replace",className:"text-sm leading-snug font-normal",children:"Use my folder instead of the installed copy"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"font-medium",children:"It runs:"}),j.length===0&&G.length===0?s.jsx("p",{className:"text-muted-foreground",children:"Nothing on its own."}):s.jsxs("ul",{"aria-label":`What ${q} runs`,className:"space-y-1.5",children:[G.map(g=>s.jsxs("li",{className:"text-sm [overflow-wrap:anywhere]",children:["Extension ",g]},g)),j.map((g,V)=>s.jsx(ge,{item:g},V))]})]})]}),T&&s.jsx(Me,{tone:"info",role:"status",children:"Approve it where DorkOS asks. This dialog can close."}),x&&s.jsx("p",{role:"alert",className:"text-status-warning-fg text-xs [overflow-wrap:anywhere]",children:x})]}),s.jsxs(Ae,{className:"shrink-0",children:[s.jsx(C,{variant:"ghost",onClick:R,disabled:D.isPending,children:"Cancel"}),s.jsx(C,{onClick:()=>void _(),disabled:E,children:D.isPending?"Linking…":"Link folder"})]})]}),$&&s.jsx(qn,{open:!0,onOpenChange:k,initialPath:t.trim()||null,onSelect:g=>{r(g),k(!1),O({path:g})}})]})}function xr({heldBack:e,label:n,onReviewClick:t,isRaisingReview:r}){return s.jsxs("div",{className:"text-status-warning-fg mt-1.5 flex flex-col items-start gap-1.5 text-xs sm:flex-row sm:gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Vn,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:e.note})]}),e.reviewable&&s.jsx(C,{size:"sm",variant:"outline",className:"ml-5 h-6 shrink-0 px-2 text-xs sm:ml-0",onClick:t,disabled:r,"aria-label":`Review ${n}`,children:r?"Asking…":"Review"})]})}function gr({state:e,label:n,onClick:t,focusProps:r}){if(e.kind!=="update-available"&&e.kind!=="applying")return null;const a=e.kind==="applying",{check:l}=e,i=l&&X(l.installedVersion,l.installedVersionSource),o=l&&X(l.latestVersion,l.latestVersionSource);return s.jsxs(C,{size:"sm",variant:"outline","aria-disabled":a||void 0,className:"aria-disabled:cursor-not-allowed aria-disabled:opacity-50",onClick:a?void 0:t,"aria-label":a?`Updating ${n}`:`Update ${n} from ${i} to ${o}`,...r,children:[s.jsx(He,{className:`mr-1 size-3 ${a?"animate-spin motion-reduce:animate-none":""}`,"aria-hidden":!0}),a?"Updating…":`Update to ${o}`]})}function kr(e){return(e==null?void 0:e.status)==="clean"||(e==null?void 0:e.status)==="modified"?e.unproven:void 0}function jr({installation:e,isActiveShape:n,isConfirmingUninstall:t,isUninstalling:r,updateState:a,integrity:l,isCheckingFiles:i,onCheckFilesClick:o,onKeepFilesClick:d,onApplyClick:u,onUpdateClick:c,onUninstallClick:h,onReviewClick:f,isRaisingReview:w,published:T,onUnlinkClick:v,onInstallPublishedClick:x}){const{name:N,version:$,type:k,scope:I,installedFrom:L,installedAt:D,adapterType:A}=e,M=e.dependencyWarnings??[],H=k==="shape",U=e.devLink!==void 0,R=K(N),O=D?new Date(D).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):null,F=ce(e),_=F?`${R} on ${F}`:R,{targetRef:b,controlProps:y}=sn(a.kind==="update-available"||a.kind==="applying");return s.jsxs("div",{className:"bg-card flex flex-col gap-3 rounded-xl border p-4 @2xl:flex-row @2xl:items-center @2xl:justify-between @2xl:gap-4 @2xl:p-6",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold",children:R}),s.jsx(xs,{type:k,adapterType:A}),U&&s.jsx(js,{}),e.heldBack&&s.jsx(se,{variant:"outline",className:"border-amber-500/60 text-amber-700 dark:text-amber-300",children:"Held back"}),n&&s.jsx(se,{variant:"secondary",children:"Active"}),s.jsxs(se,{variant:"outline",className:"font-mono",children:["v",$]}),I==="agent-local"&&s.jsx("span",{className:"text-3xs rounded-full bg-blue-100 px-1.5 py-0.5 font-medium text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:"Local"}),I==="override"&&s.jsx("span",{className:"text-3xs rounded-full bg-amber-100 px-1.5 py-0.5 font-medium text-amber-700 dark:bg-amber-900 dark:text-amber-300",children:"Overrides global"})]}),s.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs",children:[F&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(ks,{className:"size-3","aria-hidden":!0}),F]}),L&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(gs,{className:"size-3","aria-hidden":!0}),L]}),O&&s.jsxs("span",{children:["Installed ",O]})]}),U?s.jsx(Vs,{installation:e}):s.jsx("div",{ref:b,tabIndex:-1,"data-testid":"installation-update-status",className:"focus-visible:ring-ring mt-1.5 rounded-sm outline-none focus-visible:ring-2",children:s.jsx(Xa,{state:a})}),e.heldBack&&s.jsx(xr,{heldBack:e.heldBack,label:_,onReviewClick:f,isRaisingReview:w}),!U&&s.jsx(lr,{integrity:l,updateAvailable:a.kind==="update-available"||a.kind==="applying",label:_,onCheckFiles:o,isCheckingFiles:i,onKeepFiles:d}),M.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5",children:M.map(q=>s.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1 text-xs",children:[s.jsx(me,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{children:q})]},q))})]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[H&&!n&&s.jsxs(C,{size:"sm",variant:"outline",onClick:u,"aria-label":`Apply ${R}`,children:[s.jsx(Gn,{className:"mr-1 size-3","aria-hidden":!0}),"Apply…"]}),U&&s.jsx(Hs,{installation:e,published:T,label:_,onUnlink:v,onInstallPublished:x}),!U&&tr(l)&&s.jsxs(C,{size:"sm",variant:"outline",onClick:o,disabled:i,"aria-label":i?`Checking the files of ${_}`:`Check the files of ${_}`,children:[s.jsx(jt,{className:"mr-1 size-3","aria-hidden":!0}),i?"Checking…":"Check files"]}),!U&&s.jsx(gr,{state:a,label:_,onClick:c,focusProps:y}),!U&&s.jsxs(C,{size:"sm",variant:t?"destructive":"ghost",onClick:h,disabled:r,"aria-label":t?`Uninstall ${R}${F?` from ${F}`:""} now`:`Uninstall ${R}${F?` from ${F}`:""}`,className:t?"":"text-destructive hover:text-destructive",children:[s.jsx(vs,{className:"mr-1 size-3","aria-hidden":!0}),r?"Removing…":t?"Uninstall now":"Uninstall"]})]})]})}const vr=3e3;function br(){var G;const{data:e,isLoading:n,error:t,refetch:r}=je(),{data:a}=Hn(),l=(G=a==null?void 0:a.find(m=>m.active))==null?void 0:G.name,i=bs(m=>m.openShapeSwitcherToShape),o=Ks(),d=en(),u=At(),{apply:c}=Va(),h=Et(),{data:f}=Pt(),w=Ha(),T=Wa(),[v,x]=p.useState(null),[N,$]=p.useState(null),[k,I]=p.useState(null),[L,D]=p.useState(!1),A=qs(),{data:M}=$s(),H=(e??[]).some(m=>m.devLink&&!m.devLink.parked),{data:U}=Ce(void 0,{enabled:H}),R=m=>s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"flex justify-end",children:s.jsxs(C,{size:"sm",variant:"outline",onClick:()=>D(!0),children:[s.jsx(Bn,{className:"mr-1 size-3","aria-hidden":!0}),"Link a folder"]})}),(M==null?void 0:M.registryUnreadable)&&s.jsx(Me,{tone:"error",children:"Dev links can’t be read right now."}),m,L&&s.jsx(fr,{open:!0,onOpenChange:D}),s.jsx(Ss,{target:A.target,onClose:A.close,onUnlinked:A.onUnlinked})]});if(n)return R(s.jsx(zs,{count:3}));if(t)return R(s.jsx(_s,{error:t,onRetry:()=>void r()}));if(!e||e.length===0)return R(s.jsx(xe,{title:"No packages installed",description:"Browse the marketplace to find one."}));function O(m){N===m.installPath?(o.mutate({name:m.name,options:{purge:!1,...m.agentPath&&{projectPath:m.agentPath}},where:ce(m)??void 0}),$(null)):($(m.installPath),setTimeout(()=>{$(E=>E===m.installPath?null:E)},vr))}function F(m){h.mutate(m.name,{onSuccess:()=>S.info(`Review ${K(m.name)} on the approval card`,{description:"It stays held back until you allow it."}),onError:E=>S.error(`Couldn’t ask about ${K(m.name)}`,{description:E.message})})}function _(m){I(null),c(m)}function b(m){w.mutate({name:m.name,options:{installRoot:m.installPath,...m.agentPath&&{projectPath:m.agentPath}},where:ce(m)??void 0})}function y(m){var E,z,g;return w.isPending&&((E=w.variables)==null?void 0:E.name)===m.name&&(((g=(z=w.variables)==null?void 0:z.options)==null?void 0:g.installRoot)??m.installPath)===m.installPath}function q(m){var z;const E=o.variables;return o.isPending&&(E==null?void 0:E.name)===m.name&&(((z=E==null?void 0:E.options)==null?void 0:z.projectPath)??void 0)===(m.agentPath??void 0)}const j={isChecking:d.isChecking,applying:u};return R(s.jsxs(s.Fragment,{children:[s.jsx(Ja,{summary:d.summary,isChecking:d.isChecking,error:d.error,isApplying:u.size>0,onUpdateAll:()=>I(d.summary.available),onRecheck:d.recheck}),s.jsx("div",{className:"@container space-y-3",role:"list","aria-label":"Installed packages",children:e.map(m=>{const E=Aa(m,d.checks,j);return s.jsx("div",{role:"listitem",children:s.jsx(jr,{installation:m,isActiveShape:m.type==="shape"&&m.name===l,isConfirmingUninstall:N===m.installPath,isUninstalling:q(m),updateState:E,integrity:f==null?void 0:f.get(m.installPath),isCheckingFiles:y(m),onCheckFilesClick:()=>b(m),onKeepFilesClick:()=>x(m),onApplyClick:()=>i(m.name),onUpdateClick:()=>{if(E.kind!=="update-available")return;const z={installation:m,check:E.check};Wn(E.check.disclosed)?I([z]):c([z])},onUninstallClick:()=>O(m),onReviewClick:()=>F(m),isRaisingReview:h.isPending&&h.variables===m.name,published:U==null?void 0:U.find(z=>z.name===m.name),onUnlinkClick:()=>A.askUnlink(m),onInstallPublishedClick:z=>A.askInstallPublished(m,z)})},m.installPath)})}),s.jsx(ur,{stale:k,integrityByPath:f,onCancel:()=>I(null),onConfirm:_}),s.jsx(hr,{installation:v,unproven:v?kr(f==null?void 0:f.get(v.installPath)):void 0,onCancel:()=>x(null),onConfirm:m=>{v&&T.mutate({name:v.name,options:m}),x(null)}})]}))}function Fr(){const{view:e,setView:n}=ke(),t=en().summary.available.length;return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx(Qn,{children:"Marketplace"}),s.jsx("p",{className:"text-muted-foreground text-sm",children:e==="installed"?"Everything you’ve installed.":"Packages for your agents and for DorkOS."})]}),s.jsx(Zn,{value:e,onValueChange:r=>n(r),children:s.jsxs(et,{"aria-label":"Marketplace view",children:[s.jsx(Je,{value:"browse",children:"Browse"}),s.jsxs(Je,{value:"installed",children:["Installed",t>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,className:"bg-status-info-bg text-status-info-fg text-2xs ml-1.5 rounded-full px-1.5 font-medium tabular-nums",children:t}),s.jsxs("span",{className:"sr-only",children:[", ",t," ",t===1?"update":"updates"," available"]})]})]})]})})]}),e==="installed"?s.jsx("section",{"aria-label":"Installed packages",children:s.jsx(br,{})}):s.jsxs(s.Fragment,{children:[s.jsx(zt,{}),s.jsx(Yn,{}),s.jsx("section",{"aria-label":"All packages",children:s.jsx(Xt,{})})]}),s.jsx(Sa,{}),s.jsx(Ta,{})]})}export{br as I,Fr as M};
36
+ */const Fs={name:"unlink",size:24,node:[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]};Fs.node;const Nt=te(Fs);function wt(e,n){const t=W(),{enabled:r=!0,marketplace:a}=n??{};return de({queryKey:P.packageDetail(e??""),queryFn:()=>t.getMarketplacePackage(e,a),enabled:r&&e!==null,staleTime:6e4})}function je(e){const n=W();return de({queryKey:P.installed(e),queryFn:()=>n.listInstalledPackages(e),staleTime:6e4})}function Ct(e,n){const t=W();return de({queryKey:P.installedDetail(e??""),queryFn:()=>t.listPackageInstallations(e),enabled:((n==null?void 0:n.enabled)??!0)&&e!==null,staleTime:6e4})}function Pt(){const e=W();return de({queryKey:P.integrity(),queryFn:()=>e.listInstalledPackages(void 0,{verify:!0}),select:n=>new Map(n.flatMap(t=>t.integrity?[[t.installPath,t.integrity]]:[])),staleTime:6e4})}const St=10*6e4;function $t(e,n={}){const t=W();return de({queryKey:P.updates(e),queryFn:()=>t.checkMarketplaceUpdates(e),enabled:n.enabled??!0,staleTime:St,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1})}function It(){const e=W(),n=ae();return ue({mutationFn:({name:t,options:r})=>e.installMarketplacePackage(t,r),onError:t=>{t.code==="disclosure_changed"&&n.invalidateQueries({queryKey:P.preview()})},onSuccess:(t,{name:r,options:a})=>{n.invalidateQueries({queryKey:P.installed()}),a!=null&&a.projectPath&&n.invalidateQueries({queryKey:P.installed(a.projectPath)}),n.invalidateQueries({queryKey:P.packages()}),n.invalidateQueries({queryKey:P.packageDetail(r)}),n.invalidateQueries({queryKey:["commands"]}),n.invalidateQueries({queryKey:P.updates(),refetchType:"none"})}})}function Rt(){const e=W(),n=ae();return ue({mutationFn:({name:t,options:r})=>e.uninstallMarketplacePackage(t,r),onSuccess:(t,{name:r,options:a})=>{n.invalidateQueries({queryKey:P.installed()}),a!=null&&a.projectPath&&n.invalidateQueries({queryKey:P.installed(a.projectPath)}),n.invalidateQueries({queryKey:P.packageDetail(r)}),n.invalidateQueries({queryKey:["commands"]})}})}function Tt(){const e=W(),n=ae();return ue({mutationFn:({name:t,options:r})=>e.checkPackageFiles(t,r),onSettled:()=>{n.invalidateQueries({queryKey:P.integrity()})}})}function Ms(e){if(!e.applied)return e;const{applied:n,applyError:t,note:r,...a}=e;return{...a,status:"current",hasUpdate:!1,installedVersion:n.version,installedVersionSource:n.version===e.latestVersion?e.latestVersionSource:"package"}}function Dt(){const e=W(),n=ae();return ue({mutationKey:P.applyUpdates(),mutationFn:t=>e.applyMarketplaceUpdates(t),meta:{suppressErrorToast:!0},onError:t=>{t.code==="disclosure_changed"&&n.invalidateQueries({queryKey:P.updates()})},onSuccess:async t=>{const r=new Map(t.checks.map(l=>[l.installPath,Ms(l)]));n.setQueriesData({queryKey:P.updates()},l=>l&&{checks:l.checks.map(i=>r.get(i.installPath)??i)});const a=t.checks.filter(l=>l.applied);if(a.length!==0){for(const l of new Set(a.map(i=>i.packageName)))n.invalidateQueries({queryKey:P.installedDetail(l)}),n.invalidateQueries({queryKey:P.packageDetail(l)});n.invalidateQueries({queryKey:["commands"]}),await n.invalidateQueries({queryKey:P.installed()})}}})}function Et(){const e=pt({filters:{mutationKey:P.applyUpdates(),status:"pending"},select:n=>{var t;return(t=n.state.variables)==null?void 0:t.targets.map(r=>r.installPath)}});return p.useMemo(()=>new Set(e.flatMap(n=>n??[])),[e])}function At(){const e=W();return ue({mutationFn:n=>e.reviewHeldBackPackage(n),meta:{suppressErrorToast:!0}})}function Lt(e){const n=W();return de({queryKey:P.heldBack(),queryFn:()=>n.listHeldBackPackages(),enabled:e})}function Ut(){const e=W(),n=ae();return ue({mutationFn:({name:t,options:r})=>e.keepPackageFiles(t,r),meta:{suppressErrorToast:!0},onSettled:()=>{n.invalidateQueries({queryKey:P.installed()})}})}function Ot(e,n){return e.name.toLowerCase().includes(n)||(e.description??"").toLowerCase().includes(n)||(e.keywords??[]).some(t=>t.toLowerCase().includes(n))?!0:(e.tags??[]).some(t=>t.toLowerCase().includes(n))}const Ft=300,Mt=[{value:"featured",label:"Featured"},{value:"name",label:"A–Z"},{value:"popular",label:"Popular"},{value:"recent",label:"Recent"}];function zt(){const{sort:e,setSort:n}=ke(),{data:t}=Ce(),r=p.useMemo(()=>(t??[]).some(i=>i.installCount!==void 0),[t]),a=p.useMemo(()=>(t??[]).some(i=>i.updatedAt!==void 0),[t]),l=i=>i==="popular"?!r:i==="recent"?!a:!1;return s.jsxs("header",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(_t,{})}),s.jsxs(ln,{value:e,onValueChange:i=>n(i),children:[s.jsx(on,{"aria-label":"Sort packages",className:"w-28 shrink-0 text-xs sm:w-32",children:s.jsx(cn,{})}),s.jsx(dn,{children:Mt.map(i=>s.jsx(un,{value:i.value,disabled:l(i.value),className:"text-xs",children:i.label},i.value))})]})]})}function _t(){const{search:e,setSearch:n}=ke(),t=p.useRef(null),r=mn({value:e,generation:0});r.read().value!==e&&r.write({value:e,generation:r.read().generation+1});const a=r.read().generation,[l,i]=p.useState(null),o=l!==null&&l.generation===a?l.value:e,d=c=>i({generation:a,value:c});p.useEffect(()=>{if(o===e)return;const c=setTimeout(()=>n(o),Ft);return()=>clearTimeout(c)},[o,e,n]);const u=p.useCallback(c=>{var w;if(c.key!=="/"||c.metaKey||c.ctrlKey||c.altKey)return;const h=c.target,f=h==null?void 0:h.tagName;f==="INPUT"||f==="TEXTAREA"||f==="SELECT"||h!=null&&h.isContentEditable||(c.preventDefault(),(w=t.current)==null||w.focus())},[]);return p.useEffect(()=>(document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)),[u]),s.jsxs("div",{className:"group/search relative",children:[s.jsx(ee,{htmlFor:"marketplace-search",className:"sr-only",children:"Search packages"}),s.jsx(hn,{className:"text-muted-foreground group-focus-within/search:text-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 transition-colors duration-200","aria-hidden":!0}),s.jsx(pn,{ref:t,id:"marketplace-search","data-testid":"marketplace-search",value:o,onChange:c=>d(c.target.value),placeholder:"Search…",className:"pl-9 transition-shadow duration-200 focus:shadow-md max-sm:pr-3 sm:pr-10"}),s.jsx("kbd",{className:"text-muted-foreground/60 text-3xs pointer-events-none absolute top-1/2 right-3 hidden -translate-y-1/2 rounded border border-current/20 px-1.5 py-0.5 font-mono leading-none group-focus-within/search:opacity-0 sm:block",children:"/"})]})}function Kt(e,n){if(n==="all")return!0;const t=e.type??"plugin";return n===Be?t==="adapter"&&e.adapterType===Be:t===n}function Vt(e,n){const t=n.search.trim().toLowerCase();return e.filter(r=>!(!Kt(r,n.type)||n.categories.length>0&&!n.categories.some(l=>{var i;return(((i=r.categories)==null?void 0:i.includes(l))??!1)||r.category===l})||n.sources.length>0&&!n.sources.includes(r.marketplace)||t&&!Ot(r,t)))}function Ae(e,n){return be(e).localeCompare(be(n))}function qt(e,n){const t=e.marketplace===Ge?1:0,r=n.marketplace===Ge?1:0;if(t!==r)return r-t;const a=e.featured?1:0,l=n.featured?1:0;return a!==l?l-a:Ae(e,n)}function Ht(e,n){const t=e.installCount??0,r=n.installCount??0;return t!==r?r-t:Ae(e,n)}function Wt(e,n){const t=e.updatedAt??"",r=n.updatedAt??"";return t!==r?r.localeCompare(t):Ae(e,n)}function Bt(e,n){const t=[...e];switch(n){case"featured":return t.sort(qt);case"name":return t.sort(Ae);case"popular":return t.sort(Ht);case"recent":return t.sort(Wt)}}function zs({count:e=8}){return s.jsx("div",{className:us,children:s.jsx("div",{"data-slot":"package-grid",className:ms,"aria-busy":"true","aria-label":"Loading packages",children:Array.from({length:e}).map((n,t)=>s.jsxs(st,{radius:"lg",gap:"none",className:"p-6",children:[s.jsx("div",{className:"mb-3 flex items-start justify-between gap-2",children:s.jsx(B,{className:"size-6 rounded-full"})}),s.jsx(B,{className:"mb-1 h-4 w-3/4"}),s.jsx(B,{className:"mb-3 h-3 w-16"}),s.jsx(B,{className:"mb-1 h-3 w-full"}),s.jsx(B,{className:"mb-4 h-3 w-2/3"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(B,{className:"h-7 w-16"})})]},t))})})}function xe({onResetFilters:e,resetLabel:n="Reset filters",title:t="No packages match your filters",description:r="Try another search or filter."}){return s.jsx(nt,{className:"rounded-xl border border-dashed",icon:bt,headline:t,headingLevel:3,description:r,action:e?{label:n,onClick:e,variant:"outline"}:void 0})}const Gt=/network|fetch|offline/i;function _s({error:e,onRetry:n}){const t=Gt.test(e.message),r=t?fn:me,a=t?"Couldn’t reach the marketplace":"Couldn’t load packages";return s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed py-16 text-center",children:[s.jsx(r,{className:"text-muted-foreground mb-4 size-10","aria-hidden":!0}),s.jsx("h3",{className:"mb-2 text-base font-semibold",children:a}),s.jsx("p",{className:"text-muted-foreground mb-4 max-w-sm text-sm",children:s.jsx(xn,{text:e.message})}),s.jsx(C,{variant:"outline",onClick:n,children:"Try again"})]})}const ze=20,Qt=.03,Yt={hidden:{},visible:{transition:{staggerChildren:Qt}}},Jt={hidden:e=>({opacity:e<ze?0:1,y:e<ze?12:0}),visible:{opacity:1,y:0,transition:{duration:.25,ease:"easeOut"}}};function Xt(){const{data:e,isLoading:n,error:t,refetch:r}=Ce(),{data:a}=je(),l=gn(),{type:i,categories:o,sources:d,search:u,sort:c,resetFilters:h,clearCategories:f,clearSources:w,openDetail:T}=ke(),v=Ke(),x=p.useMemo(()=>e?Bt(Vt(e,{type:i,categories:o,sources:d,search:u}),c):[],[e,i,o,d,u,c]),N=p.useMemo(()=>new Set((a??[]).map(k=>k.name)),[a]),$=p.useMemo(()=>new Set((a??[]).filter(k=>k.devLink).map(k=>k.name)),[a]);if(n)return s.jsx(zs,{});if(t)return s.jsx(_s,{error:t,onRetry:()=>void r()});if(x.length===0){const k=o.length>0&&d.length===0,I=d.length>0&&o.length===0;if(k){const L=o.length===1?o[0]:null,D=L?kn(L):void 0,E=L?D?jn[D]:L:null;return s.jsx(xe,{title:E?`No packages in ${E} yet`:"No packages in these categories yet",description:"Try another category.",resetLabel:o.length===1?"Clear category":"Clear categories",onResetFilters:f})}if(I){const L=d.length===1?d[0]:null;return s.jsx(xe,{title:L?`No packages from ${L} yet`:"No packages from these sources yet",description:"Try another source.",resetLabel:d.length===1?"Clear source":"Clear sources",onResetFilters:w})}return o.length>0&&d.length>0?s.jsx(xe,{title:"No packages match these filters",description:"Reset the filters to see everything.",onResetFilters:h}):s.jsx(xe,{onResetFilters:h})}return s.jsxs("div",{className:oe(us,"space-y-4"),children:[s.jsx("div",{className:"flex items-center justify-between gap-4",children:s.jsxs("h2",{className:"text-base font-semibold",children:["All packages",s.jsxs("span",{className:"text-muted-foreground ml-2 text-sm font-normal",children:["(",x.length,")"]})]})}),s.jsx(Qe.div,{variants:l?void 0:Yt,initial:"hidden",animate:"visible","data-slot":"package-grid",className:ms,children:x.map((k,I)=>s.jsx(Qe.div,{variants:l?void 0:Jt,custom:I<ze?I:0,className:"h-full",children:s.jsx(vn,{pkg:k,installed:N.has(k.name),devLinked:$.has(k.name),onClick:()=>T(k.name),onInstallClick:()=>v(k)})},k.name))})]})}function Xe(e,n){return e instanceof Error?`Couldn’t uninstall ${n}: ${e.message}`:`Couldn’t uninstall ${n}. Try again.`}function re(e){const n=K(e.name);return e.where?`${n} from ${e.where}`:n}function Ze(e){const n=(e==null?void 0:e.warnings)??[];return n.length>0?{description:n.join(" ")}:{}}function Ks(){const e=Rt(),n=ae(),{mutate:t,mutateAsync:r}=e,a=p.useCallback(()=>{n.invalidateQueries({queryKey:[...at]})},[n]),l=p.useCallback(({where:o,...d})=>{const u=S.loading(`Uninstalling ${re({...d,where:o})}…`);t(d,{onSuccess:c=>{a(),S.success(`Uninstalled ${re({...d,where:o})}`,{id:u,...Ze(c)})},onError:c=>{S.error(Xe(c,re({...d,where:o})),{id:u})}})},[t,a]),i=p.useCallback(async({where:o,...d})=>{const u=S.loading(`Uninstalling ${re({...d,where:o})}…`);try{const c=await r(d);return a(),S.success(`Uninstalled ${re({...d,where:o})}`,{id:u,...Ze(c)}),c}catch(c){throw S.error(Xe(c,re({...d,where:o})),{id:u}),c}},[r,a]);return{...e,mutate:l,mutateAsync:i}}function Vs(){const[e,n]=p.useState(null),[t,r]=p.useState(null),a=Ke(),l=c=>{var h;return{name:c.name,...rt(c),parked:((h=c.devLink)==null?void 0:h.parked)===!0}},i=p.useCallback(c=>{r(null),n(l(c))},[]),o=p.useCallback((c,h)=>{r({pkg:h,installation:c}),n({...l(c),then:"install"})},[]),d=p.useCallback(()=>n(null),[]),u=p.useCallback(c=>{if(c.then!=="install"||!t)return;const{pkg:h,installation:f}=t;r(null),a(h,f.agentPath?{agentPath:f.agentPath,agentName:f.agentName??f.agentPath}:void 0)},[t,a]);return{target:e,askUnlink:i,askInstallPublished:o,close:d,onUnlinked:u}}function Zt(e){const{data:n}=$s(),t=lt(n==null?void 0:n.links,e),r=Nn(it(e,t)),a=wn(l=>l.latest[r]);return e.devLink?ot(e.devLink,a,t):null}function ea({status:e}){switch(e.kind){case"reloaded":return s.jsx(sa,{at:e.at});case"watching":return s.jsx("p",{className:"text-muted-foreground text-xs",children:"Watching for edits."});case"reload-failed":return s.jsxs("div",{className:"text-status-warning-fg space-y-1 text-xs",children:[s.jsxs("p",{className:"flex items-start gap-1",children:[s.jsx(me,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"[overflow-wrap:anywhere]",children:e.headline})]}),s.jsx(mt,{label:"Details",openLabel:"Hide details",className:"ml-4",children:e.details.map((n,t)=>s.jsx("p",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:n},`${t}-${n}`))})]});case"folder-missing":return s.jsx(Ue,{children:"Folder missing. Restore it or unlink."});case"link-missing":return s.jsx(Ue,{children:"Its link is gone. Unlink to finish."});case"link-replaced":return s.jsx(Ue,{children:"Something else is in its place. Unlink to finish."})}}function sa({at:e}){const n=Cn(1e3);return s.jsx("time",{dateTime:e,title:new Date(e).toLocaleString(),className:"text-muted-foreground text-xs",children:ct(e,n)})}function Ue({children:e}){return s.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1 text-xs",children:[s.jsx(me,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{children:e})]})}function qs({installation:e}){const n=Zt(e);return!e.devLink||!n?null:s.jsxs("div",{className:"mt-1.5 space-y-1","data-testid":"dev-link-details",children:[s.jsx(bn,{path:e.devLink.path}),s.jsx("div",{role:"status","aria-live":"polite","data-testid":"dev-link-status",children:s.jsx(ea,{status:n})})]})}function Hs({installation:e,published:n,label:t,onUnlink:r,onInstallPublished:a,disabled:l}){return e.devLink?e.devLink.parked?s.jsxs(C,{size:"sm",variant:"outline",onClick:r,disabled:l,"aria-label":`Use the installed copy of ${t}`,children:[s.jsx(yn,{className:"mr-1 size-3","aria-hidden":!0}),"Use installed copy"]}):s.jsxs(s.Fragment,{children:[n&&s.jsxs(C,{size:"sm",variant:"outline",onClick:()=>a(n),disabled:l,"aria-label":`Install the published version of ${t}`,children:[s.jsx(gt,{className:"mr-1 size-3","aria-hidden":!0}),"Install published version"]}),s.jsxs(C,{size:"sm",variant:"ghost",onClick:r,disabled:l,"aria-label":`Unlink ${t}`,children:[s.jsx(Nt,{className:"mr-1 size-3","aria-hidden":!0}),"Unlink"]})]}):null}function Ws(e){return e.includes("\\")&&!e.includes("/")?"\\":"/"}function es(e){return e.split(/[\\/]/)}function na(e){const n=e[0];if(n===void 0)return"";const t=Ws(n);let r=es(n).slice(0,-1);for(const a of e.slice(1)){const l=es(a).slice(0,-1);let i=0;for(;i<r.length&&i<l.length&&r[i]===l[i];)i+=1;if(r=r.slice(0,i),r.length===0)break}return r.length===0?"":r.length===1&&r[0]===""?t:r.join(t)}function ta(e,n){if(n==="")return e;const t=Ws(e),r=n.endsWith(t)?n:n+t;return e.startsWith(r)?e.slice(r.length):e}function ss(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/(^|\/)\.(?=\/|$)/g,"$1").replace(/\/+/g,"/").replace(/(.)\/$/,"$1")}function aa(e,n){if(n==="")return!1;const t=ss(n);if(t==="/"||t==="")return!0;const r=ss(e);return r===t||r.startsWith(`${t}/`)}const ra={delete:"removed",modify:"changed",create:"new"},la=["delete","modify","create"];function ns(e,n){const t=[];for(const r of la){const a=e.filter(l=>l.action===r).map(l=>ta(l.path,n)).sort((l,i)=>l.localeCompare(i));for(const l of a)t.push({text:l,tag:ra[r],...r==="delete"?{severity:"warning"}:{}})}return t}function ia(e,n){if(e.length===0)return[];const t=na(e.map(d=>d.path)),r={create:e.filter(d=>d.action==="create").length,modify:e.filter(d=>d.action==="modify").length,delete:e.filter(d=>d.action==="delete").length},a=e.length===1?"file":"files",l=t===""?"":` under ${t}`,i=[{icon:"file",label:`${e.length} ${a}${l}: ${r.create} new, ${r.modify} changed, ${r.delete} removed`,details:ns(e,t),detailsLabel:`Show ${e.length} ${a}`}];if(!n)return i;const o=e.filter(d=>!aa(d.path,n));return o.length>0&&i.push({icon:"alert-triangle",label:`${o.length} ${o.length===1?"file lands":"files land"} outside ${n}.`,severity:"warning",details:ns(o,""),detailsLabel:`Show ${o.length} ${o.length===1?"file":"files"}`}),i}function oa(e,n){const t=ia(e.fileChanges,n);if(e.npmDependencies.length>0){const r=e.npmDependencies.length;t.push({icon:"globe",label:`Download ${r} npm ${r===1?"library":"libraries"} and their dependencies`,description:e.npmDependencies.map(a=>`${a.name}@${a.range}${a.optional?" (optional)":""}`).join(", ")})}for(const r of e.extensions)t.push({icon:"puzzle",label:`Register UI extension: ${r.id}`,description:r.slots.length>0?`Slots: ${r.slots.join(", ")}`:void 0});for(const r of e.skippedLinks)t.push({icon:"alert-triangle",label:"Part of this package won’t be installed",description:r.message,severity:"warning"});return t}function Bs(e,n=Pn){const t=e.hooks.map(a=>({icon:"terminal",label:J(a.command),description:a.source?`Runs ${Ye(a.event,a.matcher)}, while ${J(a.source)} is in use`:`Runs ${Ye(a.event,a.matcher)}`,mono:!0}));for(const a of e.skillCommands){const l=Sn(a.source);t.push({icon:"terminal",label:J(a.command),description:`Runs when the ${l} "${J(a.skill)}" is used (${J(a.source)})`+(a.usesArguments?". Uses what you type after it":""),mono:!0})}for(const a of e.unreadableHooks)t.push({icon:"alert-triangle",label:"Sets up a command DorkOS couldn’t read",description:a.event?`${a.path} declares "${a.event}" in a form DorkOS can’t read`:`DorkOS can’t read ${a.path}`,severity:"warning"});const r=(a,l,i=!0)=>({icon:i?"terminal":"globe",label:a,description:`${l}. ${n}`,mono:!0});for(const a of e.mcpServers)t.push(a.command!==void 0?r(ve(a.command,a.args),`MCP server "${a.name}"`):r(J(JSON.stringify(a.url??"")),`Remote MCP server "${a.name}"`,!1));for(const a of e.lspServers)t.push(r(ve(a.command,a.args),`Language server "${a.name}"`));for(const a of e.monitors)t.push(r(ve(a.command),`Background monitor "${a.name}"${a.when?`, ${a.when}`:""}`));for(const a of e.executables)t.push(r(ve(a),"Added to the agent’s commands (bin/)"));for(const a of e.skillTools)t.push({icon:"key",label:a.tools.map(l=>J(JSON.stringify(l))).join(", "),description:`Skill "${J(a.skill)}" may use these without asking you`,mono:!0});for(const a of e.unreadableDeclarations)t.push({icon:"alert-triangle",label:"Sets up a program DorkOS couldn’t read",description:a.entry?`${a.path} declares "${a.entry}" in a form DorkOS can’t read`:`DorkOS can’t read ${a.path}`,severity:"warning"});return t}function Gs(e){return e.schedules.map(n=>({icon:"clock",label:n.name,description:Xn(n),severity:Jn(n.permissionMode)&&n.startsEnabled?"warning":"info"}))}function ca(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function da(e){const n={create:e.fileChanges.filter(u=>u.action==="create").length,modify:e.fileChanges.filter(u=>u.action==="modify").length,delete:e.fileChanges.filter(u=>u.action==="delete").length},r=[{verb:"Adds",count:n.create},{verb:"Changes",count:n.modify},{verb:"Removes",count:n.delete}].filter(u=>u.count>0).map((u,c)=>{const h=c===0?u.verb:u.verb.toLowerCase(),f=c===0?` ${u.count===1?"file":"files"}`:"";return`${h} ${u.count}${f}`}),a=r.length===0?"Changes no files":ca(r),l=e.hooks.length+e.skillCommands.length+e.unreadableHooks.length,i=l===0?"Declares no commands":`Declares ${l} ${l===1?"command":"commands"}`,o=e.mcpServers.length+e.lspServers.length+e.monitors.length+e.executables.length,d=o===0?"":` Includes ${o} ${o===1?"program":"programs"}.`;return`${a}. ${i}.${d}`}function ua(e,n={}){return{effects:oa(e,n.installBase),commands:Bs(e),schedules:Gs(e),secrets:e.secrets.map(t=>({icon:"key",label:t.key+(t.required?"":" (optional)"),description:t.description,severity:t.required?"warning":"info"})),hosts:e.externalHosts.map(t=>({icon:"globe",label:t})),dependencies:e.requires.map(t=>({icon:t.satisfied?"check":"alert-triangle",label:`${t.type}:${t.name}${t.version?`@${t.version}`:""}`,severity:t.satisfied?"info":"warning"})),conflicts:e.conflicts.map(t=>({icon:"alert-triangle",label:t.description,description:t.conflictingPackage?`Conflicts with: ${t.conflictingPackage}`:void 0,severity:t.level==="error"?"error":"warning"}))}}const ma={global:"Starts in every chat.",project:"Declared, but not started for a project install."};function We(e,n){const t={hooks:e.hooks.map(a=>({event:a.event,...a.matcher!==null&&{matcher:a.matcher},command:a.command,...a.source!==null&&{source:a.source}})),unreadableHooks:[],mcpServers:e.mcpServers.map(a=>({name:a.name,transport:a.transport,...a.command!==null&&{command:a.command,args:a.args},...a.url!==null&&{url:a.url}})),lspServers:e.lspServers.map(({name:a,command:l,args:i})=>({name:a,command:l,args:i})),monitors:e.monitors.map(({name:a,command:l,when:i})=>({name:a,command:l,...i!==null&&{when:i}})),executables:e.executables,skillTools:e.skillTools,skillCommands:e.skillCommands,unreadableDeclarations:[]},r=e.schedules.map(a=>({name:a.name,cron:a.cron,permissionMode:a.permissionMode,startsEnabled:a.startsEnabled}));return[...Bs(t,ma[n]),...Gs({schedules:r})]}const ha={hooks:[],schedules:[],mcpServers:[],lspServers:[],monitors:[],executables:[],skillTools:[],skillCommands:[]},pa=["hooks","skillCommands","mcpServers","lspServers","monitors","executables","skillTools","schedules"];function Ne(e,n){if(!(e==="hooks"||e==="skillCommands"||e==="executables"))return e==="skillTools"?n.source:n.name}function fa(e,n,t){const r=[],a=(l,i)=>We({...ha,[l]:[i]},t)[0];for(const l of pa)for(const i of e[l]){const o=a(l,i);if(!o)continue;const d=xa(l,i,n),u=d==="changed"?n[l].find(h=>Ne(l,h)===Ne(l,i)):void 0,c=u===void 0?void 0:a(l,u);r.push({row:o,change:d,...c&&{previous:c}})}return r}function xa(e,n,t){if(!t)return"unknown";const r=t[e],a=JSON.stringify(n);if(r.some(i=>JSON.stringify(i)===a))return"unchanged";const l=Ne(e,n);return l!==void 0&&r.some(i=>Ne(e,i)===l)?"changed":"new"}const ga={file:Is,puzzle:qe,clock:$n,terminal:ht,key:vt,globe:Ve,check:hs,"alert-triangle":me},we={info:"text-muted-foreground",warning:"text-status-warning-fg",error:"text-destructive"};function ka({items:e,label:n}){return s.jsxs("details",{className:"group/details mt-1.5",children:[s.jsxs("summary",{className:oe("text-muted-foreground hover:text-foreground focus-ring inline-flex cursor-pointer","list-none items-center gap-1 rounded-sm text-xs select-none","[&::-webkit-details-marker]:hidden"),children:[s.jsx(Pe,{className:"size-3 shrink-0 transition-transform duration-200 group-open/details:rotate-90"}),n]}),s.jsx("ul",{className:"bg-muted/40 mt-1.5 max-h-64 space-y-0.5 overflow-y-auto rounded-md p-2",children:e.map((t,r)=>s.jsxs("li",{className:"text-2xs flex items-baseline gap-2 font-mono",children:[t.tag&&s.jsx("span",{className:oe("w-14 shrink-0",t.severity?we[t.severity]:we.info),children:t.tag}),s.jsx("span",{className:"text-foreground min-w-0 break-all","data-testid":"file-change-path",children:t.text})]},r))})]})}function Qs(e){const n=e.split(new RegExp(`(?<=\\/)|(?=["'])`));return n.map((t,r)=>s.jsxs(p.Fragment,{children:[t,r<n.length-1&&s.jsx("wbr",{})]},r))}function ge({item:e}){const n=ga[e.icon]??Is,t=e.severity?we[e.severity]:we.info;return s.jsxs("li",{className:oe("flex items-start gap-2 text-sm",t),children:[s.jsx(n,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[e.mono?s.jsx("code",{className:"bg-muted text-foreground block rounded px-1.5 py-1 font-mono text-xs [overflow-wrap:anywhere] whitespace-pre-wrap",children:Qs(e.label)}):s.jsx("span",{className:"break-words",children:e.label}),e.description&&s.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs break-words",children:e.description}),e.details&&e.details.length>0&&s.jsx(ka,{items:e.details,label:e.detailsLabel??"Show details"})]})]})}function Z({title:e,items:n,tone:t,defaultOpen:r=!1}){const[a,l]=p.useState(r);return n.length===0?null:s.jsx(ps,{open:a,onOpenChange:l,trigger:s.jsx("span",{className:oe("text-xs font-semibold tracking-wider uppercase",t==="warning"?"text-status-warning-fg":"text-muted-foreground"),children:e}),badge:s.jsx(se,{variant:"secondary",className:"text-xs",children:n.length}),children:s.jsx("ul",{className:"space-y-1.5",children:n.map((i,o)=>s.jsx(ge,{item:i},o))})})}function ja(e){return e.isolation!==void 0}function va({extensions:e}){const[n,t]=p.useState(!0),r=e.filter(ja);return r.length===0?null:s.jsx(ps,{open:n,onOpenChange:t,trigger:s.jsx("span",{className:"text-muted-foreground text-xs font-semibold tracking-wider uppercase",children:"What its extensions can reach"}),badge:s.jsx(se,{variant:"secondary",className:"text-xs",children:r.length}),children:s.jsx("ul",{className:"space-y-3","data-testid":"preview-extension-reach",children:r.map(a=>s.jsxs("li",{className:"flex min-w-0 items-start gap-2 text-sm",children:[s.jsx(qe,{className:"text-muted-foreground mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground font-mono text-xs break-all",children:s.jsx("bdi",{children:a.id})}),s.jsx(In,{permissions:{runtime:a.isolation.runtime,net:a.isolation.net,run:a.isolation.run.map(l=>({name:l})),agents:a.isolation.agents,...a.hasServer!==void 0?{hasServer:a.hasServer}:{}},"data-testid":`preview-extension-reach-${a.id}`})]})]},a.id))})})}function Ys({preview:e,installBase:n}){const t=ua(e,{installBase:n}),r=Object.values(t).some(a=>a.length>0);return s.jsxs("div",{className:"space-y-6",children:[r&&s.jsx("p",{className:"text-sm",children:da(e)}),s.jsx(Z,{title:"What this package will do",items:t.effects}),s.jsx(va,{extensions:e.extensions}),s.jsx(Z,{title:"Commands this package declares",items:t.commands,defaultOpen:!0}),s.jsx(Z,{title:"Jobs it will schedule",items:t.schedules,defaultOpen:!0}),s.jsx(Z,{title:"Secrets required",items:t.secrets}),s.jsx(Z,{title:"External hosts",items:t.hosts}),s.jsx(Z,{title:"Dependencies",items:t.dependencies}),s.jsx(Z,{title:"Conflicts",items:t.conflicts,tone:"warning",defaultOpen:!0})]})}function ba(e){if(typeof e=="string")return e;if(e&&typeof e=="object"&&"name"in e)return String(e.name)}function Js(e){return e.scope===void 0||e.scope==="global"}function _e(e){var n;return Js(e)?"All agents (global)":e.agentName??((n=e.agentPath)==null?void 0:n.split("/").filter(Boolean).pop())??"This agent"}function ya(e){if(!e)return null;const n=[];return e.commands>0&&n.push(`${e.commands} command${e.commands===1?"":"s"}`),e.skills>0&&n.push(`${e.skills} skill${e.skills===1?"":"s"}`),e.hooks&&n.push("hooks"),n.length>0?n.join(" · "):null}const Na=3e3;function wa(){return s.jsxs("div",{className:"space-y-4",children:[s.jsx(B,{className:"h-4 w-3/4"}),s.jsx(B,{className:"h-4 w-1/2"}),s.jsx(B,{className:"h-20 w-full rounded-lg"}),s.jsx(B,{className:"h-4 w-2/3"})]})}function Oe({icon:e,children:n}){return s.jsxs("div",{className:"bg-muted/50 flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs",children:[s.jsx(e,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:n})]})}function Ca({installation:e,isRemoving:n,isConfirmingUninstall:t,disabled:r,onReinstall:a,onUninstallClick:l,published:i,onUnlink:o,onInstallPublished:d}){const u=Js(e),c=_e(e),h=u?Ve:ks,f=e.installedAt?new Date(e.installedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null;return e.devLink?s.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx(h,{className:"text-muted-foreground mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:c}),s.jsx(js,{})]}),s.jsx(qs,{installation:e})]})]}),s.jsx("div",{className:"flex flex-wrap items-center justify-end gap-1",children:s.jsx(Hs,{installation:e,published:i,label:c,onUnlink:o,onInstallPublished:d,disabled:r})})]}):s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx(h,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:c}),e.scope==="override"&&s.jsx("span",{className:"text-3xs shrink-0 rounded-full bg-amber-100 px-1.5 py-0.5 font-medium text-amber-700 dark:bg-amber-900 dark:text-amber-300",children:"Overrides global"})]}),s.jsxs("div",{className:"text-muted-foreground text-xs",children:["v",e.version,f&&` · ${f}`]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsxs(C,{size:"sm",variant:"ghost",disabled:r,onClick:a,"aria-label":`Reinstall for ${c}`,children:[s.jsx(He,{className:"mr-1 size-3","aria-hidden":!0}),"Reinstall"]}),s.jsxs(C,{size:"sm",variant:t?"destructive":"ghost",disabled:r,onClick:l,"aria-label":t?`Uninstall ${c} now`:`Uninstall for ${c}`,className:t?"":"text-destructive hover:text-destructive",children:[s.jsx(vs,{className:"mr-1 size-3","aria-hidden":!0}),n?"Removing…":t?"Uninstall now":"Uninstall"]})]})]})}function Pa({installations:e,uninstallPendingFor:n,anyMutationPending:t,onReinstall:r,onUninstall:a,published:l,onUnlink:i,onInstallPublished:o}){var T,v;const[d,u]=p.useState(null);function c(x){d===x.installPath?(u(null),a(x)):(u(x.installPath),setTimeout(()=>{u(N=>N===x.installPath?null:N)},Na))}const h=e.some(x=>x.type==="shape"),f=ya((T=e.find(x=>x.provides))==null?void 0:T.provides)??(h?"a workspace layout, agents, and schedules":null),w=(v=e.find(x=>x.installedFrom))==null?void 0:v.installedFrom;return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{className:"text-status-success-fg flex items-center gap-2 text-sm font-medium",children:[s.jsx(hs,{className:"size-4 shrink-0","aria-hidden":!0}),e.every(x=>x.devLink)?"Dev link":e.length===1?"Installed":`Installed in ${e.length} locations`]}),s.jsx("div",{className:"space-y-2",role:"list","aria-label":"Installations",children:e.map(x=>s.jsx("div",{role:"listitem",children:s.jsx(Ca,{installation:x,isRemoving:n===x.installPath,isConfirmingUninstall:d===x.installPath,disabled:t,onReinstall:()=>r(x),onUninstallClick:()=>c(x),published:l,onUnlink:()=>i(x),onInstallPublished:N=>o(x,N)})},x.installPath))}),s.jsxs("dl",{className:"text-muted-foreground space-y-1.5 text-xs",children:[w&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(gs,{className:"size-3 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:["from ",w]})]}),f&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(qe,{className:"size-3 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:["Provides ",f]})]})]})]})}function Sa(){var b;const{selectedPackageName:e,closeDetail:n}=ke(),t=Ke(),{data:r}=Ce(),a=e?(r??[]).find(y=>y.name===e)??null:null;p.useEffect(()=>{e&&r&&!r.some(y=>y.name===e)&&n()},[e,r,n]);const l=a!==null,i=(a==null?void 0:a.name)??null,{data:o,isLoading:d}=wt(i,{enabled:l}),{data:u,isLoading:c}=je(),h=a!==null?(u??[]).filter(y=>y.name===a.name):[],f=h.length>0,{data:w}=Ct(i,{enabled:f}),{data:T,isLoading:v,error:x}=Cs(i,{enabled:l&&!f&&!c}),{data:N}=fs(),$=Ks(),k=Vs(),L=d||v||l&&c,D=(T==null?void 0:T.preview)??(o==null?void 0:o.preview),E=ba((o==null?void 0:o.manifest.author)??(a==null?void 0:a.author)),M=o==null?void 0:o.manifest.version,H=o==null?void 0:o.manifest.license,U=a==null?void 0:a.homepage,R=a==null?void 0:a.marketplace;function O(y){a&&t(a,y.agentPath?{agentPath:y.agentPath,agentName:_e(y)}:void 0)}function F(y){a&&$.mutate({name:a.name,options:y.agentPath?{projectPath:y.agentPath}:void 0,where:y.agentPath?_e(y):void 0})}const _=$.isPending&&$.variables?((b=h.find(y=>{var V,j;return(y.agentPath??void 0)===((j=(V=$.variables)==null?void 0:V.options)==null?void 0:j.projectPath)}))==null?void 0:b.installPath)??null:null;return s.jsxs(Rn,{open:a!==null,onOpenChange:y=>!y&&n(),children:[s.jsx(Tn,{side:"right",className:"flex w-full flex-col overflow-hidden sm:max-w-xl",children:a&&s.jsxs(s.Fragment,{children:[s.jsxs(Dn,{className:"shrink-0 space-y-4 border-b pb-6",children:[s.jsxs("div",{className:"flex items-start gap-4 pr-8",children:[s.jsx("div",{className:"bg-muted flex size-14 shrink-0 items-center justify-center rounded-xl text-3xl",children:a.icon??"📦"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx(En,{className:"text-lg",children:be(a)}),s.jsx(xs,{type:a.type??"plugin",adapterType:a.adapterType,className:"shrink-0"})]}),a.description&&s.jsx(An,{className:"mt-1.5 line-clamp-3 text-sm",children:a.description})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[M&&s.jsxs(se,{size:"xs",variant:"outline",className:"font-mono",children:["v",M]}),E&&s.jsx(Oe,{icon:Ln,children:E}),R&&s.jsx(Oe,{icon:Ve,children:R}),H&&s.jsx(Oe,{icon:yt,children:H})]}),U&&s.jsxs(Un,{href:U,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 text-xs transition-colors",children:[s.jsx(On,{className:"size-3","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:U})]})]}),s.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto px-4 py-6",children:[L?s.jsx(wa,{}):f?s.jsx(Pa,{installations:w??h,uninstallPendingFor:_,anyMutationPending:$.isPending,onReinstall:O,onUninstall:F,published:a,onUnlink:k.askUnlink,onInstallPublished:k.askInstallPublished}):x?s.jsx(Ps,{error:x}):D?s.jsxs("section",{children:[s.jsx("h3",{className:"mb-3 text-sm font-semibold",children:"What this can do"}),s.jsx(Ys,{preview:D,installBase:N==null?void 0:N.dorkHome})]}):s.jsx("p",{className:"text-muted-foreground text-sm",children:"No special permissions required."}),!L&&(o==null?void 0:o.readme)&&s.jsxs("section",{children:[s.jsx("h3",{className:"mb-3 text-sm font-semibold",children:"About"}),s.jsx(tt,{content:o.readme,className:"text-sm",errorFallback:s.jsx("p",{className:"text-muted-foreground text-sm",children:"This README couldn’t be displayed."})})]})]}),s.jsxs(Fn,{className:"flex-row gap-2 border-t pt-4",children:[s.jsx(C,{variant:"ghost",onClick:n,className:"flex-1",children:"Close"}),f?s.jsx(C,{variant:"outline",disabled:$.isPending,onClick:()=>t(a),className:"flex-1",children:"Install…"}):s.jsx(C,{onClick:()=>t(a),className:"flex-1",children:"Install"})]})]})}),s.jsx(Ss,{target:k.target,onClose:k.close,onUnlinked:k.onUnlinked})]})}function ts(e,n){return e instanceof Error?`Couldn’t install ${n}: ${e.message}`:`Couldn’t install ${n}. Try again.`}function as(e,n,t){var l;const r=e.warnings.length>0?e.warnings.join(" "):void 0;return e.type==="shape"?{id:n,description:r,action:{label:"Apply…",onClick:()=>bs.getState().openShapeSwitcherToShape(e.packageName)}}:zn(e.type,(l=e.manifest)==null?void 0:l.adapterType)?{id:n,description:r,action:{label:"Open Connections",onClick:()=>t()}}:{id:n,description:r}}function $a(){const e=It(),n=Mn(),{mutate:t,mutateAsync:r}=e,a=p.useCallback(i=>{const o=K(i.name),d=S.loading(`Installing ${o}…`);t(i,{onSuccess:u=>{S.success(`Installed ${o}`,as(u,d,n))},onError:u=>{S.error(ts(u,o),{id:d})}})},[t,n]),l=p.useCallback(async i=>{const o=K(i.name),d=S.loading(`Installing ${o}…`);try{const u=await r(i);return S.success(`Installed ${o}`,as(u,d,n)),u}catch(u){throw S.error(ts(u,o),{id:d}),u}},[r,n]);return{...e,mutate:a,mutateAsync:l}}function Ia(e,n){return n==="global"?e===void 0||e==="global":e==="agent-local"||e==="override"}function Ra(e){return e.isPending?e.isReinstall?"Reinstalling…":"Installing…":e.hasBlockingConflicts?"Can’t install: conflicts found":e.isReinstall?"Reinstall":"Install"}function Ta(){var V;const e=Le(j=>j.installConfirmPackage),n=Le(j=>j.installContext),t=Le(j=>j.closeInstallConfirm),r=$a(),{data:a}=ys(),l=(a==null?void 0:a.agents)??[],i=(e==null?void 0:e.type)==="shape",o=n?"agent-local":"global",d=n?(V=l.find(j=>j.projectPath===n.agentPath))==null?void 0:V.id:void 0,[u,c]=p.useState(null),h=u!==null&&u.forContext===n?u:null,f=(h==null?void 0:h.scope)??o,w=h===null?d:h.agentId,T=j=>c({forContext:n,scope:j.scope??f,agentId:"agentId"in j?j.agentId:w}),v=i?"global":f,x=l.find(j=>j.id===w),N=v==="agent-local"?x==null?void 0:x.projectPath:void 0,$=v==="agent-local"&&!w,{data:k,isLoading:I,error:L}=Cs((e==null?void 0:e.name)??null,{enabled:e!==null&&!$,...N?{projectPath:N}:{}}),D=$?null:(k==null?void 0:k.preview)??null,{data:E}=fs(),M=N?`${N}/.dork`:E==null?void 0:E.dorkHome,H=D!==null&&D.conflicts.some(j=>j.level==="error"),{data:U}=je(N),R=!$&&(U??[]).some(j=>j.name===(e==null?void 0:e.name)&&Ia(j.scope,v)),O=!$&&L!==null,F=r.isPending||I||O||H||e===null||$,_=Ra({isPending:r.isPending,isReinstall:R,hasBlockingConflicts:H});async function b(){if(e)try{const j={...N&&{projectPath:N},...(k==null?void 0:k.disclosed)&&{approvedDisclosure:k.disclosed,approvedContentHash:k.contentHash}};await r.mutateAsync({name:e.name,options:Object.keys(j).length>0?j:void 0}),t()}catch{}}function y(j){j||t()}return s.jsx(Se,{open:e!==null,onOpenChange:y,children:s.jsx($e,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:e&&s.jsxs(s.Fragment,{children:[s.jsxs(Ie,{className:"shrink-0",children:[s.jsxs(Re,{children:[R?"Reinstall":"Install"," ",be(e),"?"]}),s.jsx(Te,{children:R?"This replaces the installed copy. Check what it does below.":"Check what this package does before you install it."})]}),s.jsx("div",{className:"shrink-0 space-y-2 px-4 sm:px-6",children:i?s.jsx("p",{className:"text-muted-foreground text-sm",children:"Shapes apply to your whole app."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:"Install for"}),s.jsxs(Ns,{value:f,onValueChange:j=>{const G=j;T(G==="global"?{scope:G,agentId:void 0}:{scope:G})},className:"gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ye,{value:"global",id:"scope-global"}),s.jsx(ee,{htmlFor:"scope-global",className:"text-sm font-normal",children:"All agents (global)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ye,{value:"agent-local",id:"scope-agent"}),s.jsx(ee,{htmlFor:"scope-agent",className:"text-sm font-normal",children:"Specific agent"})]})]}),f==="agent-local"&&s.jsx("div",{className:"pl-6",children:s.jsx(Rs,{agents:l,value:w,onValueChange:j=>T({agentId:j})})})]})}),s.jsxs(De,{className:"mt-4",children:[$&&s.jsx("p",{className:"text-muted-foreground text-sm",children:"Pick an agent to preview this install."}),I&&s.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading preview…"}),O&&s.jsx(Ps,{error:L}),D&&s.jsx(Ys,{preview:D,installBase:M})]}),s.jsxs(Ee,{className:"shrink-0",children:[s.jsx(C,{variant:"ghost",onClick:t,disabled:r.isPending,children:"Cancel"}),s.jsx(C,{onClick:b,disabled:F,children:_})]})]})})})}function Da(e){return new Map((e??[]).map(n=>[n.installPath,n]))}function rs(e){return e.startsWith("v")?e.slice(1):e}function Xs(e,n){const t=n.get(e.installPath);if(t)return t.installedVersionSource!=="package"||rs(t.installedVersion)===rs(e.version)?t:void 0}function Ea(e,n,t){const r=Xs(e,n);return t.applying.has(e.installPath)?{kind:"applying",check:r}:t.isChecking?{kind:"checking"}:r?{kind:r.status,check:r}:{kind:"unchecked"}}function Aa(e,n){const t={available:[],current:0,unknown:0};for(const r of e){if(r.devLink)continue;const a=Xs(r,n);(a==null?void 0:a.status)==="update-available"?t.available.push({installation:r,check:a}):(a==null?void 0:a.status)==="current"?t.current+=1:(a==null?void 0:a.status)==="unknown"&&(t.unknown+=1)}return t}const La=7;function X(e,n){return n==="commit"?e.slice(0,La):e.startsWith("v")?e:`v${e}`}function ce(e){var n;return e.scope!=="agent-local"&&e.scope!=="override"?null:e.agentName??((n=e.agentPath)==null?void 0:n.split("/").filter(Boolean).pop())??"agent"}function Ua(e){var n,t;return((t=(n=e.applied)==null?void 0:n.fileNotices)==null?void 0:t.some(r=>r.outcome==="kept-unproven"))??!1}function Zs({installation:e}){const n=K(e.name),t=ce(e);return t?`${n} on ${t}`:n}function Oa(e,n){if(n!=null&&n.applied){const t=Ms(n),r=X(t.installedVersion,t.installedVersionSource),a=n.applied.warnings??[];return{kind:"success",message:`Updated ${e} to ${r}`,...a.length>0&&{description:a.join(" ")}}}if(n!=null&&n.applyError)return{kind:"error",message:`Couldn’t update ${e}: ${n.applyError}`};if((n==null?void 0:n.status)==="current")return{kind:"success",message:`${e} is already up to date`};if((n==null?void 0:n.status)==="unknown"){const t=n.note?`: ${n.note}`:"";return{kind:"warning",message:`Couldn’t check ${e} for updates${t}`}}return{kind:"warning",message:`${e} wasn’t updated`}}function Fa(e){const n=e.length,t=e.filter(a=>a.applied).length,r=e.filter(a=>a.applyError).length;return t===n?{kind:"success",message:e.some(Ua)?`Updated ${n} packages. Some kept files need sorting; see their rows.`:`Updated ${n} packages`}:t>0?{kind:"warning",message:`Updated ${t} of ${n} packages. Each row shows why.`}:r>0?{kind:"error",message:`Couldn’t update ${r===n?`${n}`:`${r} of ${n}`} packages. Each row shows why.`}:e.every(a=>a.status==="current")?{kind:"success",message:`All ${n} packages are up to date`}:{kind:"warning",message:"Nothing was updated. Each row shows why."}}function Ma(e,n){const t=new Map(n.checks.map(r=>[r.installPath,r]));if(e.length===1){const r=e[0];return Oa(Zs(r),t.get(r.check.installPath))}return Fa(e.map(({check:r})=>t.get(r.installPath)??r))}function za(e,n){S[e.kind](e.message,{id:n,...e.description&&{description:e.description}})}const _a="batch_update_needs_approval",Ka="disclosure_changed";function Va(e,n){const t=e==null?void 0:e.code;return t===Ka?`${n.length===1?"This package":"One of these packages"} changed what it runs since you looked. Review it again.`:t===_a?n.length===1?`It needs your approval. Run \`dorkos marketplace update ${n[0].check.packageName} --apply\` in a terminal.`:"Each needs your approval. Run `dorkos marketplace update <name> --apply` in a terminal.":e instanceof Error?e.message:String(e)}function qa(){const{mutateAsync:e}=Dt(),n=p.useRef(new Set);return{apply:p.useCallback(r=>{const a=r.filter(({check:c})=>!n.current.has(c.installPath)),[l,...i]=a.map(({check:c})=>({installPath:c.installPath,latestVersion:c.latestVersion,disclosed:c.disclosed??null,contentHash:c.contentHash??""}));if(l===void 0)return;const o=a.map(({check:c})=>c.installPath);for(const c of o)n.current.add(c);const d=a.length===1?Zs(a[0]):`${a.length} packages`,u=S.loading(`Updating ${d}…`);e({targets:[l,...i]}).then(c=>za(Ma(a,c),u)).catch(c=>S.error(`Couldn’t update ${d}`,{id:u,description:Va(c,a)})).finally(()=>{for(const c of o)n.current.delete(c)})},[e])}}function Ha(){const e=Tt(),{mutate:n}=e,t=p.useCallback(({where:r,...a})=>{const l=r?`${K(a.name)} on ${r}`:K(a.name),i=S.loading(`Checking the files of ${l}…`);n(a,{onSuccess:o=>{(o.outcome==="rebuilt"||o.outcome==="not-needed"?S.success:S.warning)(o.message,{id:i})},onError:o=>{S.error(`Couldn’t check the files of ${l}: ${o.message}`,{id:i})}})},[n]);return{...e,mutate:t}}function Wa(){const e=Ut(),{mutate:n}=e,t=p.useCallback(r=>{n(r,{onSuccess:a=>{S.success(a.message)},onError:a=>{S.error(a.message)}})},[n]);return{...e,mutate:t}}function en(){const e=ae(),{data:n}=je(),t=((n==null?void 0:n.length)??0)>0,r=$t(void 0,{enabled:t}),{data:a,isFetching:l,error:i,refetch:o}=r,d=p.useRef(n);p.useEffect(()=>{const h=d.current;d.current=n,!(h===void 0||h===n)&&e.invalidateQueries({queryKey:P.updates(),refetchType:"none"})},[n,e]);const u=p.useMemo(()=>Da(i||a==null?void 0:a.checks),[a,i]),c=p.useMemo(()=>Aa(n??[],u),[n,u]);return{checks:u,summary:c,isChecking:l,error:i,recheck:()=>void o()}}function sn(e){const n=p.useRef(null),t=p.useRef(!1);p.useEffect(()=>{var l;if(e||!t.current)return;t.current=!1;const a=document.activeElement;(a===null||a===document.body)&&((l=n.current)==null||l.focus())},[e]);const r=p.useMemo(()=>({onFocus:()=>{t.current=!0},onBlur:a=>{a.relatedTarget!==null&&(t.current=!1)}}),[]);return{targetRef:n,controlProps:r}}function Ba(e){return e===1?"1 package is":`${e} packages are`}function Ga(e){return`${e} ${e===1?"package":"packages"}`}function Qa(e){const n=[];return e.current>0&&n.push(`${Ba(e.current)} up to date.`),e.unknown>0&&n.push(`${Ga(e.unknown)} couldn’t be checked.`),n}function Ya(e){const n=e.available.length;return n>0?{headline:`${n} ${n===1?"update":"updates"} available.`,allCurrent:!1}:e.current>0&&e.unknown===0?{headline:"All packages are up to date.",allCurrent:!0}:e.current===0&&e.unknown===0?{headline:"Not checked for updates yet.",allCurrent:!1}:{headline:"No updates found.",allCurrent:!1}}function Ja({summary:e,isChecking:n,error:t,isApplying:r,onUpdateAll:a,onRecheck:l}){const{headline:i,allCurrent:o}=Ya(e),d=o?[]:Qa(e),u=!n&&!t&&e.available.length>0,{targetRef:c,controlProps:h}=sn(u);return s.jsxs("div",{className:"bg-muted/40 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 rounded-xl px-4 py-3",children:[s.jsx("p",{ref:c,tabIndex:-1,role:"status","aria-live":"polite",className:"focus-visible:ring-ring min-w-0 rounded-sm text-sm outline-none focus-visible:ring-2",children:n?s.jsxs("span",{className:"text-muted-foreground flex items-center gap-2",children:[s.jsx(Fe,{size:"xs"}),"Checking your packages for updates…"]}):t?s.jsxs("span",{children:["Couldn’t check for updates: ",t.message]}):s.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[o&&s.jsx(ws,{className:"text-status-success-fg size-4 shrink-0","aria-hidden":!0}),s.jsx("span",{className:e.available.length>0?"font-medium":void 0,children:i}),d.map(f=>s.jsx("span",{className:"text-muted-foreground",children:f},f))]})}),!n&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(C,{size:"sm",variant:"ghost",onClick:l,disabled:r,children:[s.jsx(He,{className:"mr-1 size-3","aria-hidden":!0}),t?"Try again":"Check again"]}),u&&s.jsx(C,{size:"sm","aria-disabled":r||void 0,className:"aria-disabled:cursor-not-allowed aria-disabled:opacity-50",onClick:r?void 0:a,...h,children:"Update all…"})]})]})}const le="flex items-start gap-1.5 text-xs",ie="mt-0.5 size-3 shrink-0";function ls({text:e}){return s.jsx("p",{className:"text-muted-foreground pl-4.5 text-xs",children:e})}function Xa({state:e}){switch(e.kind){case"checking":return s.jsxs("p",{className:`${le} text-muted-foreground`,children:[s.jsx(Fe,{size:"xs",className:ie}),"Checking for updates…"]});case"applying":return s.jsxs("p",{className:`${le} text-muted-foreground`,children:[s.jsx(Fe,{size:"xs",className:ie}),e.check?`Updating to ${X(e.check.latestVersion,e.check.latestVersionSource)}…`:"Updating…"]});case"update-available":{const{check:n}=e,t=X(n.installedVersion,n.installedVersionSource),r=X(n.latestVersion,n.latestVersionSource);return s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("p",{className:`${le} text-status-info-fg font-medium`,children:[s.jsx(kt,{className:ie,"aria-hidden":!0}),s.jsxs("span",{children:["Update available: ",t," ",s.jsx("span",{"aria-hidden":!0,children:"→"}),s.jsx("span",{className:"sr-only",children:"to"})," ",r]})]}),n.note&&s.jsx(ls,{text:n.note}),n.applyError&&s.jsxs("p",{className:`${le} text-destructive`,children:[s.jsx(me,{className:ie,"aria-hidden":!0}),s.jsxs("span",{children:["Couldn’t update: ",n.applyError]})]})]})}case"current":return s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("p",{className:`${le} text-muted-foreground`,children:[s.jsx(ws,{className:ie,"aria-hidden":!0}),"Up to date"]}),e.check.note&&s.jsx(ls,{text:e.check.note})]});case"unknown":return s.jsxs("p",{className:`${le} text-muted-foreground`,children:[s.jsx(_n,{className:ie,"aria-hidden":!0}),s.jsxs("span",{children:["Couldn’t check for updates",e.check.note?`: ${e.check.note}`:""]})]});case"unchecked":return null}}const Za="Check files so updates keep your edits.";function er(e,n){return e===1?`the file you ${n}`:`the ${e} files you ${n}`}function nn(e){return[e.changed.length>0&&`Updating replaces ${er(e.changed.length,"edited")} and keeps your copies beside them.`,e.added.length>0&&(e.added.length===1?"The file you added stays.":`The ${e.added.length} files you added stay.`),e.missing.length>0&&(e.missing.length===1?"The file you removed comes back.":`The ${e.missing.length} files you removed come back.`)].filter(n=>typeof n=="string")}function sr(e){if(e.changed.length>0)return"Updating replaces your edits; copies are kept.";if(e.missing.length>0)return"Updating puts back files you removed.";if(e.added.length>0)return"Updating keeps the files you added."}function nr(e){const t=[[e.changed.length,"edited"],[e.added.length,"added"],[e.missing.length,"removed"]].filter(([i])=>i>0),r=t.reduce((i,[o])=>i+o,0),a=e.truncated?"+":"",l=`${r}${a} ${r===1?"file":"files"} changed since install`;return t.length>1?`${l} (${t.map(([i,o])=>`${i} ${o}`).join(", ")})`:l}function tn(e){return(e==null?void 0:e.status)==="unknown"&&(e.reason==="no-record"||e.reason==="inferred")}function tr(e){var r,a;const n=tn(e)?e.check:(e==null?void 0:e.status)==="clean"||(e==null?void 0:e.status)==="modified"?(r=e.unproven)==null?void 0:r.check:void 0;if(!n||n.source==="local")return!1;const t=(a=n.last)==null?void 0:a.outcome;return t!=="mismatch"&&t!=="no-source"}function ar(e){var n;return e.check.source==="local"||((n=e.check.last)==null?void 0:n.outcome)==="fetch-failed"}function ne({title:e,paths:n}){return n.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"text-3xs font-medium tracking-wide uppercase",children:e}),s.jsx("ul",{"aria-label":e,className:"mt-0.5 space-y-0.5",children:n.map(t=>s.jsx("li",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:t},t))})]})}function rr({unproven:e,label:n,onKeepFiles:t}){const r=e.files.length,a=e.running,l=a.length>0,i=e.check.source==="local",o=e.files.filter(d=>!a.includes(d));return s.jsxs("details",{"data-testid":"installation-integrity-unproven","data-runs":l?"true":"false",className:"group/kept mt-1 text-xs",children:[s.jsxs("summary",{className:oe("focus-ring flex cursor-pointer list-none items-start gap-1 rounded-sm select-none [&::-webkit-details-marker]:hidden",l?"text-amber-700 hover:text-amber-800 dark:text-amber-400 dark:hover:text-amber-300":"text-muted-foreground hover:text-foreground"),children:[s.jsx(Ts,{className:"mt-0.5 size-3 shrink-0 text-amber-600 dark:text-amber-400","aria-hidden":!0}),s.jsxs("span",{children:["Kept ",r," ",r===1?"file":"files"," an update couldn’t sort.",l&&` ${a.length} of ${r===1?"it":"them"} still ${a.length===1?"runs":"run"}.`]}),s.jsx(Pe,{className:"mt-0.5 size-3 shrink-0 transition-transform duration-200 group-open/kept:rotate-90","aria-hidden":!0})]}),s.jsxs("div",{className:"text-muted-foreground mt-1.5 space-y-1.5 pl-4",children:[s.jsx("p",{children:"Unclear if these are yours or leftovers, so DorkOS kept them."}),s.jsx("p",{children:i?"Keep them as yours, or delete any you don’t need.":"Check files sets aside the leftovers and keeps yours."}),e.check.last&&s.jsx("p",{children:e.check.last.message}),s.jsx(ne,{title:"Still runs",paths:a}),s.jsx(ne,{title:"Kept",paths:o}),t&&ar(e)&&s.jsx(C,{size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:t,"aria-label":`Keep the files ${n??"this package"} kept as mine`,children:"Keep these as mine"})]})]})}function lr(e){const{integrity:n}=e,t=(n==null?void 0:n.status)==="clean"||(n==null?void 0:n.status)==="modified"?n.unproven:void 0;return t?s.jsxs(s.Fragment,{children:[s.jsx(is,{...e}),s.jsx(rr,{unproven:t,label:e.label,onKeepFiles:e.onKeepFiles})]}):s.jsx(is,{...e})}function is({integrity:e,updateAvailable:n,label:t,onCheckFiles:r,isCheckingFiles:a=!1}){var l,i;if((e==null?void 0:e.status)==="modified"){const o=n?nn(e):[],d=n?sr(e):void 0;return s.jsxs("details",{"data-testid":"installation-integrity",className:"group/files mt-1 text-xs",children:[s.jsxs("summary",{className:"text-muted-foreground hover:text-foreground focus-ring flex cursor-pointer list-none items-start gap-1 rounded-sm select-none [&::-webkit-details-marker]:hidden",children:[s.jsx(ft,{className:"text-status-warning-dot mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsxs("span",{className:"flex flex-col",children:[s.jsxs("span",{children:[nr(e),"."]}),d&&s.jsx("span",{"data-testid":"installation-integrity-update",children:d})]}),s.jsx(Pe,{className:"mt-0.5 size-3 shrink-0 transition-transform duration-200 group-open/files:rotate-90","aria-hidden":!0})]}),s.jsxs("div",{className:"text-muted-foreground mt-1.5 space-y-1.5 pl-4",children:[o.map(u=>s.jsx("p",{children:u},u)),s.jsx(ne,{title:"Edited",paths:e.changed}),s.jsx(ne,{title:"Added",paths:e.added}),s.jsx(ne,{title:"Removed",paths:e.missing}),e.truncated&&s.jsx("p",{children:"Showing the first 50 of each."})]})]})}if(tn(e)){const o=((l=e.check)==null?void 0:l.source)==="local",d=(i=e.check)==null?void 0:i.last,u=o?"Installed from a folder by an older DorkOS. Reinstall so updates keep your edits.":d?d.message:`Installed by an older DorkOS. ${Za}`,c=!o&&(d==null?void 0:d.outcome)==="mismatch"&&r;return s.jsxs("p",{"data-testid":"installation-integrity",className:"text-muted-foreground mt-1 flex items-start gap-1 text-xs",children:[s.jsx(Ts,{className:"text-status-warning-dot mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:[u,c&&s.jsxs(s.Fragment,{children:[" ",s.jsx("button",{type:"button",onClick:r,disabled:a,"aria-label":`Check the files of ${t??"this package"} again`,className:"text-foreground focus-ring rounded-sm underline underline-offset-2 disabled:opacity-50",children:a?"Checking…":"Try again"})]})]})]})}return null}function os(e){if(e.length!==1)return`${e.length} packages`;const[{installation:n}]=e,t=ce(n),r=K(n.name);return t?`${r} on ${t}`:r}function an({check:e}){return e.disclosed?fa(e.disclosed,e.installedDisclosed,e.scope==="global"?"global":"project"):[]}function ir(e){const n=e.map(an),t=n.filter(i=>i.length>0).length,r=n.filter(i=>i.some(o=>o.change==="new"||o.change==="changed")).length,a=e.length===1?t===1?"The new version runs things on its own":"The new version runs nothing on its own":`${t} of ${e.length} run things on their own`;if(r===0)return a;const l=e.length===1?"it adds or changes something":`${r} ${r===1?"adds":"add"} or ${r===1?"changes":"change"} something`;return`${a} · ${l}`}function or({change:e}){return e!=="new"&&e!=="changed"?null:s.jsx(se,{variant:"outline",className:"text-3xs shrink-0 border-amber-500/60 text-amber-700 dark:text-amber-300",children:e==="new"?"New":"Changed"})}function cs({row:e,change:n,previous:t}){return s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("ul",{children:s.jsx(ge,{item:e})}),t&&s.jsxs("div",{className:"mt-1 pl-6 opacity-70",children:[s.jsx("p",{className:"text-muted-foreground text-3xs mb-0.5 font-medium tracking-wide uppercase",children:"Installed now"}),s.jsx("ul",{"aria-label":"What the installed version runs instead",children:s.jsx(ge,{item:{...t,description:void 0,details:void 0}})})]})]}),s.jsx(or,{change:n})]})}function cr(e){const n=an(e);if(n.length===0)return s.jsx("p",{className:"text-muted-foreground text-xs",children:"The new version runs nothing on its own."});const t=n.filter(a=>a.change!=="unchanged"),r=n.filter(a=>a.change==="unchanged");return s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("p",{className:"text-muted-foreground text-xs",children:["The new version runs ",n.length===1?"this":`these ${n.length}`," on its own:"]}),s.jsxs("div",{role:"list","aria-label":"What the new version runs",className:"space-y-2",children:[t.map((a,l)=>s.jsx("div",{role:"listitem",children:s.jsx(cs,{...a})},`lead-${l}`)),r.length>0&&s.jsxs("details",{className:"group/unchanged",role:"listitem",children:[s.jsxs("summary",{className:"text-muted-foreground hover:text-foreground focus-ring inline-flex cursor-pointer list-none items-center gap-1 rounded-sm text-xs select-none [&::-webkit-details-marker]:hidden",children:[s.jsx(Pe,{className:"size-3 shrink-0 transition-transform duration-200 group-open/unchanged:rotate-90"}),r.length," unchanged"]}),s.jsx("div",{className:"mt-2 space-y-2",children:r.map((a,l)=>s.jsx(cs,{...a},`same-${l}`))})]})]})]})}function dr({integrity:e,...n}){const{installation:t,check:r}=n,a=ce(t),l=X(r.installedVersion,r.installedVersionSource),i=X(r.latestVersion,r.latestVersionSource);return s.jsxs("li",{className:"bg-muted/40 space-y-2 rounded-lg px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium",children:K(t.name)}),s.jsx("div",{className:"text-muted-foreground text-xs",children:a??"All agents"}),a&&t.agentPath&&s.jsx("div",{className:"text-muted-foreground text-2xs font-mono [overflow-wrap:anywhere]",children:Qs(t.agentPath)})]}),s.jsxs("div",{className:"shrink-0 font-mono text-xs",children:[l," ",s.jsx("span",{"aria-hidden":!0,children:"→"}),s.jsx("span",{className:"sr-only",children:"to"})," ",i]})]}),(e==null?void 0:e.status)==="modified"&&nn(e).map(o=>s.jsx("p",{className:"text-muted-foreground text-xs",children:o},o)),s.jsx(cr,{...n})]})}function ur({stale:e,onCancel:n,onConfirm:t,integrityByPath:r}){return s.jsx(Se,{open:e!==null,onOpenChange:a=>!a&&n(),children:s.jsx($e,{className:"max-h-[85vh] !min-h-0 sm:max-w-xl",children:e&&s.jsxs(s.Fragment,{children:[s.jsxs(Ie,{className:"shrink-0 text-left",children:[s.jsxs(Re,{className:"text-left",children:["Update ",os(e),"?"]}),s.jsx(Te,{className:"text-left",children:e.length===1?"The newest version replaces this one in place. Check what it runs first.":"Each newest version replaces the one installed. Check what each runs first."}),s.jsx("p",{className:"text-foreground text-left text-xs font-medium","data-testid":"update-disclosure-summary",children:ir(e)})]}),s.jsx(De,{children:s.jsx("ul",{"aria-label":"Packages to update",className:"space-y-2",children:e.map(a=>s.jsx(dr,{...a,integrity:r==null?void 0:r.get(a.installation.installPath)},a.check.installPath))})}),s.jsxs(Ee,{className:"shrink-0",children:[s.jsx(C,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsxs(C,{onClick:()=>t(e),children:["Update ",os(e)]})]})]})})})}function mr(e){return e!==null&&e.heldBack!==void 0&&(e.scope===void 0||e.scope==="global")}function hr({installation:e,unproven:n,onCancel:t,onConfirm:r}){var T;const a=mr(e),l=Lt(a),i=a?(T=l.data)==null?void 0:T.find(v=>v.name===(e==null?void 0:e.name)):void 0,o=i!=null&&i.effects&&i.bindsTo?{effects:i.effects,bindsTo:i.bindsTo}:void 0,d=a&&l.isPending,u=e!==null&&n!==void 0,c=e?K(e.name):"",h=(n==null?void 0:n.running)??[],f=(n==null?void 0:n.files.filter(v=>!h.includes(v)))??[],w=o?We(o.effects,"global"):[];return s.jsx(Se,{open:u,onOpenChange:v=>!v&&t(),children:s.jsx($e,{className:"max-h-[85vh] !min-h-0 sm:max-w-lg",children:u&&e&&n&&s.jsxs(s.Fragment,{children:[s.jsxs(Ie,{className:"shrink-0 text-left",children:[s.jsxs(Re,{className:"text-left",children:["Keep these ",c," files as yours?"]}),s.jsx(Te,{className:"text-left",children:"An update couldn’t tell if these are yours or leftovers."})]}),s.jsxs(De,{className:"space-y-3 text-xs",children:[s.jsxs("div",{className:"text-muted-foreground space-y-1",children:[s.jsx("p",{children:n.check.source==="local"?"No earlier version to compare with.":"DorkOS couldn’t download the old version to compare."}),s.jsx("p",{children:"Keeping makes them yours. Updates leave them alone."}),s.jsx("p",{children:"Nothing is moved or deleted."}),h.length>0&&s.jsx("p",{children:"They now run as your own files."})]}),s.jsx(ne,{title:"Still runs",paths:h}),s.jsx(ne,{title:"Kept",paths:f}),a&&s.jsx("div",{"data-testid":"keep-files-activation",className:"space-y-1.5",children:d?s.jsxs("p",{className:"text-muted-foreground",children:["Reading what ",c," runs…"]}):o?s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-foreground font-medium",children:[c," is held back from chats."]}),s.jsx("p",{className:"text-foreground",children:"Keeping also lets it run in every chat, as it is now:"}),s.jsx("ul",{"aria-label":`What ${c} runs`,className:"space-y-1.5",children:w.map((v,x)=>s.jsx(ge,{item:v},x))})]}):s.jsxs("p",{className:"text-muted-foreground",children:[c," stays held back until you review it."]})})]}),s.jsxs(Ee,{className:"shrink-0",children:[s.jsx(C,{variant:"ghost",onClick:t,children:"Cancel"}),s.jsx(C,{disabled:d,onClick:()=>r({installRoot:e.installPath,keepKey:n.keepKey,...e.agentPath&&{projectPath:e.agentPath},...o&&{review:o}}),children:o?"Keep them and let it run":"Keep them as mine"})]})]})})})}const pr="dev_link_changed",fe={card:null,refusal:null,checking:!1};function ds(e){const n=e;return{message:(n==null?void 0:n.message)||"Couldn’t check this folder. Try again.",code:n==null?void 0:n.code}}function fr({open:e,onOpenChange:n}){var z;const[t,r]=p.useState(""),[a,l]=p.useState("global"),[i,o]=p.useState(void 0),[d,u]=p.useState(!1),[c,h]=p.useState(fe),[f,w]=p.useState(!1),[T,v]=p.useState(null),[x,N]=p.useState(null),[$,k]=p.useState(!1),I=p.useRef(0),L=dt(),D=ut(),{data:E}=ys({enabled:e}),M=(E==null?void 0:E.agents)??[],H=a==="agent-local"?(z=M.find(g=>g.id===i))==null?void 0:z.projectPath:void 0,U=a==="agent-local"&&H===void 0;function R(){I.current+=1,n(!1)}async function O(g){const q=(g.path??t).trim(),Q="projectPath"in g?g.projectPath:H,Y=g.replaceInstalled??!1;u(Y),N(null),v(null),g.keepChangedNotice||w(!1);const he=++I.current,rn=!("projectPath"in g)&&U;if(q===""||rn){h(fe);return}h(pe=>({card:g.keepCard?pe.card:null,refusal:null,checking:!0}));try{const pe=await L.mutateAsync({path:q,...Q?{scope:"project",projectPath:Q}:{scope:"global"},...Y&&{replaceInstalled:!0}});if(he!==I.current)return;h({card:{preview:pe,replaceInstalled:Y,projectPath:Q},refusal:null,checking:!1})}catch(pe){if(he!==I.current)return;h({card:null,refusal:ds(pe).message,checking:!1})}}function F(g){c.card&&O({path:c.card.preview.path,projectPath:c.card.projectPath,replaceInstalled:g,keepCard:!0})}async function _(){if(!c.card||c.checking)return;N(null);const{preview:g,replaceInstalled:q,projectPath:Q}=c.card;try{const Y=await D.mutateAsync({path:g.path,...Q?{scope:"project",projectPath:Q}:{scope:"global"},...q&&{replaceInstalled:!0},via:"app",expectedChange:g.change});if(Y.status==="approval_required"){v(Y.approval);return}S.success(`${K(g.name)} runs from your folder.`),R()}catch(Y){const he=ds(Y);if(he.code===pr){w(!0),await O({path:g.path,projectPath:Q,replaceInstalled:q,keepChangedNotice:!0});return}N(he.message)}}const b=c.card,y=(b==null?void 0:b.preview.replaces)??null,V=b?K(b.preview.name):"",j=b!=null&&b.preview.effects?We(b.preview.effects,b.projectPath?"project":"global"):[],G=(b==null?void 0:b.preview.extensions)??[],m=y===null||d&&(b==null?void 0:b.replaceInstalled)===!0,A=b===null||c.checking||!m||D.isPending||T!==null;return s.jsxs(Se,{open:e,onOpenChange:g=>g?n(!0):R(),children:[s.jsxs($e,{className:"max-h-[85vh] !min-h-0 sm:max-w-lg",children:[s.jsxs(Ie,{className:"shrink-0 text-left",children:[s.jsx(Re,{className:"text-left",children:b?`Run ${V} from this folder?`:"Link a folder"}),s.jsx(Te,{className:"text-left",children:"Run a plugin or skill pack from your own folder."})]}),s.jsxs(De,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(ee,{htmlFor:"dev-link-path",children:"Folder"}),s.jsx(xt,{id:"dev-link-path",value:t,placeholder:"/Users/you/code/my-plugin",onChange:g=>{r(g),c!==fe&&(I.current+=1,h(fe),u(!1))},onBlur:()=>void O({}),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),O({}))},onBrowse:()=>k(!0),browseTestId:"dev-link-browse","aria-describedby":c.refusal?"dev-link-refusal":void 0,"aria-invalid":c.refusal?!0:void 0,autoComplete:"off",spellCheck:!1}),c.refusal&&s.jsx("p",{id:"dev-link-refusal",role:"alert",className:"text-status-warning-fg text-xs [overflow-wrap:anywhere]",children:c.refusal}),s.jsx("p",{className:"text-muted-foreground text-xs empty:hidden","aria-live":"polite",children:c.checking?"Checking the folder…":""})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:"Run for"}),s.jsxs(Ns,{value:a,onValueChange:g=>{const q=g;l(q),q==="global"?(o(void 0),O({projectPath:void 0})):(I.current+=1,h(fe),u(!1))},className:"gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ye,{value:"global",id:"dev-link-scope-global"}),s.jsx(ee,{htmlFor:"dev-link-scope-global",className:"text-sm font-normal",children:"All agents (global)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ye,{value:"agent-local",id:"dev-link-scope-agent"}),s.jsx(ee,{htmlFor:"dev-link-scope-agent",className:"text-sm font-normal",children:"Specific agent"})]})]}),a==="agent-local"&&s.jsx("div",{className:"pl-6",children:s.jsx(Rs,{agents:M,value:i,onValueChange:g=>{var q;o(g),O({projectPath:(q=M.find(Q=>Q.id===g))==null?void 0:q.projectPath})}})}),U&&t.trim()!==""&&s.jsx("p",{className:"text-muted-foreground text-xs",children:"Pick an agent to check this folder."})]}),f&&s.jsx(Me,{tone:"info",role:"alert",children:"The folder changed. Check it again."}),b&&s.jsxs("section",{"aria-label":"What linking does",className:"space-y-3 text-sm",children:[s.jsx("code",{className:"bg-muted block rounded px-2 py-1.5 font-mono text-xs [overflow-wrap:anywhere]",children:b.preview.path}),s.jsx("p",{children:"Edits here run in DorkOS right away, without asking."}),y&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{children:["Your installed copy (v",y.version,") is set aside, not deleted."]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Kn,{id:"dev-link-replace",checked:d,onCheckedChange:g=>{c.checking||F(g===!0)},"aria-disabled":c.checking||void 0,className:"aria-disabled:cursor-not-allowed aria-disabled:opacity-50"}),s.jsx(ee,{htmlFor:"dev-link-replace",className:"text-sm leading-snug font-normal",children:"Use my folder instead of the installed copy"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"font-medium",children:"It runs:"}),j.length===0&&G.length===0?s.jsx("p",{className:"text-muted-foreground",children:"Nothing on its own."}):s.jsxs("ul",{"aria-label":`What ${V} runs`,className:"space-y-1.5",children:[G.map(g=>s.jsxs("li",{className:"text-sm [overflow-wrap:anywhere]",children:["Extension ",g]},g)),j.map((g,q)=>s.jsx(ge,{item:g},q))]})]})]}),T&&s.jsx(Me,{tone:"info",role:"status",children:"Approve it where DorkOS asks. This dialog can close."}),x&&s.jsx("p",{role:"alert",className:"text-status-warning-fg text-xs [overflow-wrap:anywhere]",children:x})]}),s.jsxs(Ee,{className:"shrink-0",children:[s.jsx(C,{variant:"ghost",onClick:R,disabled:D.isPending,children:"Cancel"}),s.jsx(C,{onClick:()=>void _(),disabled:A,children:D.isPending?"Linking…":"Link folder"})]})]}),$&&s.jsx(Vn,{open:!0,onOpenChange:k,initialPath:t.trim()||null,onSelect:g=>{r(g),k(!1),O({path:g})}})]})}function xr({heldBack:e,label:n,onReviewClick:t,isRaisingReview:r}){return s.jsxs("div",{className:"text-status-warning-fg mt-1.5 flex flex-col items-start gap-1.5 text-xs sm:flex-row sm:gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(qn,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:e.note})]}),e.reviewable&&s.jsx(C,{size:"sm",variant:"outline",className:"ml-5 h-6 shrink-0 px-2 text-xs sm:ml-0",onClick:t,disabled:r,"aria-label":`Review ${n}`,children:r?"Asking…":"Review"})]})}function gr({state:e,label:n,onClick:t,focusProps:r}){if(e.kind!=="update-available"&&e.kind!=="applying")return null;const a=e.kind==="applying",{check:l}=e,i=l&&X(l.installedVersion,l.installedVersionSource),o=l&&X(l.latestVersion,l.latestVersionSource);return s.jsxs(C,{size:"sm",variant:"outline","aria-disabled":a||void 0,className:"aria-disabled:cursor-not-allowed aria-disabled:opacity-50",onClick:a?void 0:t,"aria-label":a?`Updating ${n}`:`Update ${n} from ${i} to ${o}`,...r,children:[s.jsx(He,{className:`mr-1 size-3 ${a?"animate-spin motion-reduce:animate-none":""}`,"aria-hidden":!0}),a?"Updating…":`Update to ${o}`]})}function kr(e){return(e==null?void 0:e.status)==="clean"||(e==null?void 0:e.status)==="modified"?e.unproven:void 0}function jr({installation:e,isActiveShape:n,isConfirmingUninstall:t,isUninstalling:r,updateState:a,integrity:l,isCheckingFiles:i,onCheckFilesClick:o,onKeepFilesClick:d,onApplyClick:u,onUpdateClick:c,onUninstallClick:h,onReviewClick:f,isRaisingReview:w,published:T,onUnlinkClick:v,onInstallPublishedClick:x}){const{name:N,version:$,type:k,scope:I,installedFrom:L,installedAt:D,adapterType:E}=e,M=e.dependencyWarnings??[],H=k==="shape",U=e.devLink!==void 0,R=K(N),O=D?new Date(D).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):null,F=ce(e),_=F?`${R} on ${F}`:R,{targetRef:b,controlProps:y}=sn(a.kind==="update-available"||a.kind==="applying");return s.jsxs("div",{className:"bg-card flex flex-col gap-3 rounded-xl border p-4 @2xl:flex-row @2xl:items-center @2xl:justify-between @2xl:gap-4 @2xl:p-6",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold",children:R}),s.jsx(xs,{type:k,adapterType:E}),U&&s.jsx(js,{}),e.heldBack&&s.jsx(se,{variant:"outline",className:"border-amber-500/60 text-amber-700 dark:text-amber-300",children:"Held back"}),n&&s.jsx(se,{variant:"secondary",children:"Active"}),s.jsxs(se,{variant:"outline",className:"font-mono",children:["v",$]}),I==="agent-local"&&s.jsx("span",{className:"text-3xs rounded-full bg-blue-100 px-1.5 py-0.5 font-medium text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:"Local"}),I==="override"&&s.jsx("span",{className:"text-3xs rounded-full bg-amber-100 px-1.5 py-0.5 font-medium text-amber-700 dark:bg-amber-900 dark:text-amber-300",children:"Overrides global"})]}),s.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs",children:[F&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(ks,{className:"size-3","aria-hidden":!0}),F]}),L&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(gs,{className:"size-3","aria-hidden":!0}),L]}),O&&s.jsxs("span",{children:["Installed ",O]})]}),U?s.jsx(qs,{installation:e}):s.jsx("div",{ref:b,tabIndex:-1,"data-testid":"installation-update-status",className:"focus-visible:ring-ring mt-1.5 rounded-sm outline-none focus-visible:ring-2",children:s.jsx(Xa,{state:a})}),e.heldBack&&s.jsx(xr,{heldBack:e.heldBack,label:_,onReviewClick:f,isRaisingReview:w}),!U&&s.jsx(lr,{integrity:l,updateAvailable:a.kind==="update-available"||a.kind==="applying",label:_,onCheckFiles:o,isCheckingFiles:i,onKeepFiles:d}),M.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5",children:M.map(V=>s.jsxs("p",{className:"text-status-warning-fg flex items-start gap-1 text-xs",children:[s.jsx(me,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.jsx("span",{children:V})]},V))})]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[H&&!n&&s.jsxs(C,{size:"sm",variant:"outline",onClick:u,"aria-label":`Apply ${R}`,children:[s.jsx(Gn,{className:"mr-1 size-3","aria-hidden":!0}),"Apply…"]}),U&&s.jsx(Hs,{installation:e,published:T,label:_,onUnlink:v,onInstallPublished:x}),!U&&tr(l)&&s.jsxs(C,{size:"sm",variant:"outline",onClick:o,disabled:i,"aria-label":i?`Checking the files of ${_}`:`Check the files of ${_}`,children:[s.jsx(jt,{className:"mr-1 size-3","aria-hidden":!0}),i?"Checking…":"Check files"]}),!U&&s.jsx(gr,{state:a,label:_,onClick:c,focusProps:y}),!U&&s.jsxs(C,{size:"sm",variant:t?"destructive":"ghost",onClick:h,disabled:r,"aria-label":t?`Uninstall ${R}${F?` from ${F}`:""} now`:`Uninstall ${R}${F?` from ${F}`:""}`,className:t?"":"text-destructive hover:text-destructive",children:[s.jsx(vs,{className:"mr-1 size-3","aria-hidden":!0}),r?"Removing…":t?"Uninstall now":"Uninstall"]})]})]})}const vr=3e3;function br(){var G;const{data:e,isLoading:n,error:t,refetch:r}=je(),{data:a}=Hn(),l=(G=a==null?void 0:a.find(m=>m.active))==null?void 0:G.name,i=bs(m=>m.openShapeSwitcherToShape),o=Ks(),d=en(),u=Et(),{apply:c}=qa(),h=At(),{data:f}=Pt(),w=Ha(),T=Wa(),[v,x]=p.useState(null),[N,$]=p.useState(null),[k,I]=p.useState(null),[L,D]=p.useState(!1),E=Vs(),{data:M}=$s(),H=(e??[]).some(m=>m.devLink&&!m.devLink.parked),{data:U}=Ce(void 0,{enabled:H}),R=m=>s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"flex justify-end",children:s.jsxs(C,{size:"sm",variant:"outline",onClick:()=>D(!0),children:[s.jsx(Bn,{className:"mr-1 size-3","aria-hidden":!0}),"Link a folder"]})}),(M==null?void 0:M.registryUnreadable)&&s.jsx(Me,{tone:"error",children:"Dev links can’t be read right now."}),m,L&&s.jsx(fr,{open:!0,onOpenChange:D}),s.jsx(Ss,{target:E.target,onClose:E.close,onUnlinked:E.onUnlinked})]});if(n)return R(s.jsx(zs,{count:3}));if(t)return R(s.jsx(_s,{error:t,onRetry:()=>void r()}));if(!e||e.length===0)return R(s.jsx(xe,{title:"No packages installed",description:"Browse the marketplace to find one."}));function O(m){N===m.installPath?(o.mutate({name:m.name,options:{purge:!1,...m.agentPath&&{projectPath:m.agentPath}},where:ce(m)??void 0}),$(null)):($(m.installPath),setTimeout(()=>{$(A=>A===m.installPath?null:A)},vr))}function F(m){h.mutate(m.name,{onSuccess:()=>S.info(`Review ${K(m.name)} on the approval card`,{description:"It stays held back until you allow it."}),onError:A=>S.error(`Couldn’t ask about ${K(m.name)}`,{description:A.message})})}function _(m){I(null),c(m)}function b(m){w.mutate({name:m.name,options:{installRoot:m.installPath,...m.agentPath&&{projectPath:m.agentPath}},where:ce(m)??void 0})}function y(m){var A,z,g;return w.isPending&&((A=w.variables)==null?void 0:A.name)===m.name&&(((g=(z=w.variables)==null?void 0:z.options)==null?void 0:g.installRoot)??m.installPath)===m.installPath}function V(m){var z;const A=o.variables;return o.isPending&&(A==null?void 0:A.name)===m.name&&(((z=A==null?void 0:A.options)==null?void 0:z.projectPath)??void 0)===(m.agentPath??void 0)}const j={isChecking:d.isChecking,applying:u};return R(s.jsxs(s.Fragment,{children:[s.jsx(Ja,{summary:d.summary,isChecking:d.isChecking,error:d.error,isApplying:u.size>0,onUpdateAll:()=>I(d.summary.available),onRecheck:d.recheck}),s.jsx("div",{className:"@container space-y-3",role:"list","aria-label":"Installed packages",children:e.map(m=>{const A=Ea(m,d.checks,j);return s.jsx("div",{role:"listitem",children:s.jsx(jr,{installation:m,isActiveShape:m.type==="shape"&&m.name===l,isConfirmingUninstall:N===m.installPath,isUninstalling:V(m),updateState:A,integrity:f==null?void 0:f.get(m.installPath),isCheckingFiles:y(m),onCheckFilesClick:()=>b(m),onKeepFilesClick:()=>x(m),onApplyClick:()=>i(m.name),onUpdateClick:()=>{if(A.kind!=="update-available")return;const z={installation:m,check:A.check};Wn(A.check.disclosed)?I([z]):c([z])},onUninstallClick:()=>O(m),onReviewClick:()=>F(m),isRaisingReview:h.isPending&&h.variables===m.name,published:U==null?void 0:U.find(z=>z.name===m.name),onUnlinkClick:()=>E.askUnlink(m),onInstallPublishedClick:z=>E.askInstallPublished(m,z)})},m.installPath)})}),s.jsx(ur,{stale:k,integrityByPath:f,onCancel:()=>I(null),onConfirm:_}),s.jsx(hr,{installation:v,unproven:v?kr(f==null?void 0:f.get(v.installPath)):void 0,onCancel:()=>x(null),onConfirm:m=>{v&&T.mutate({name:v.name,options:m}),x(null)}})]}))}function Fr(){const{view:e,setView:n}=ke(),t=en().summary.available.length;return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx(Qn,{children:"Marketplace"}),s.jsx("p",{className:"text-muted-foreground text-sm",children:e==="installed"?"Everything you’ve installed.":"Packages for your agents and for DorkOS."})]}),s.jsx(Zn,{value:e,onValueChange:r=>n(r),children:s.jsxs(et,{"aria-label":"Marketplace view",children:[s.jsx(Je,{value:"browse",children:"Browse"}),s.jsxs(Je,{value:"installed",children:["Installed",t>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,className:"bg-status-info-bg text-status-info-fg text-2xs ml-1.5 rounded-full px-1.5 font-medium tabular-nums",children:t}),s.jsxs("span",{className:"sr-only",children:[", ",t," ",t===1?"update":"updates"," available"]})]})]})]})})]}),e==="installed"?s.jsx("section",{"aria-label":"Installed packages",children:s.jsx(br,{})}):s.jsxs(s.Fragment,{children:[s.jsx(zt,{}),s.jsx(Yn,{}),s.jsx("section",{"aria-label":"All packages",children:s.jsx(Xt,{})})]}),s.jsx(Sa,{}),s.jsx(Ta,{})]})}export{br as I,Fr as M};
@@ -1 +1 @@
1
- import{a1 as N,a2 as T,aa as g,a3 as S,a4 as $,r as b,j as e,dI as L,B as x,f as R,e as P,er as I,dz as B,es as H,a7 as v,et as V,eu as W,ev as G,ew as J,ex as U,d$ as D,I as F,ey as X}from"./index-DcZPWi_I.js";import{u as Y}from"./use-pending-read-DBOl1ee_.js";function Z(){const s=N();return T({queryKey:g.sources(),queryFn:()=>s.listMarketplaceSources(),staleTime:6e4})}function _(){const s=N(),t=S();return $({mutationFn:n=>s.addMarketplaceSource(n),onSuccess:()=>{t.invalidateQueries({queryKey:g.sources()}),t.invalidateQueries({queryKey:g.packages()})}})}function ee(){const s=N(),t=S();return $({mutationFn:n=>s.removeMarketplaceSource(n),onSuccess:()=>{t.invalidateQueries({queryKey:g.sources()}),t.invalidateQueries({queryKey:g.packages()})}})}function se(){const s=N(),t=S();return $({mutationFn:n=>s.refreshMarketplaceSource(n),meta:{suppressErrorToast:!0},onSettled:()=>{t.invalidateQueries({queryKey:g.sources()}),t.invalidateQueries({queryKey:g.packages()})}})}function M(s){return s===1?"1 package is ready to install.":`${s} packages are ready to install.`}function k(s){return`${s.replace(/\.+$/,"")}.`}function C(s){return new Date(s).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function q(s){return s.startsWith("file://")}function z(s){return q(s)?"Couldn’t read that folder":"Couldn’t reach it"}function ae(s){const t=s.lastFetch;return(t==null?void 0:t.state)==="failed"?{kind:"failed",message:`Its packages didn’t load: ${k(t.reason)}`}:(t==null?void 0:t.state)==="stale"?{kind:"stale",message:`${z(s.source)}: ${k(t.reason)} Still showing the last copy, from ${C(t.copyFetchedAt)}.`}:null}function te(s,t,n){return s?(t==null?void 0:t.kind)==="failed"?"Enabled, but its packages didn’t load":(t==null?void 0:t.kind)==="stale"?"Enabled, showing an older copy":n?"Enabled":"Enabled, not fetched yet":"Disabled"}function ne({name:s,source:t,enabled:n,addedAt:d,listing:u,fetched:i,onRefresh:h,isRefreshing:r,onRemove:p,isRemoving:f}){const c=C(d),j=n?u?"fill-current text-status-warning-dot":i?"fill-current text-status-success":"fill-none text-muted-foreground":"fill-current text-muted-foreground";return e.jsxs("div",{"data-slot":"source-card",className:"bg-card flex items-start justify-between gap-4 rounded-xl border p-5",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(I,{className:`mt-0.5 size-3 shrink-0 ${j}`,"aria-label":te(n,u,i)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold",children:s}),e.jsx("p",{className:"text-muted-foreground truncate text-xs",children:t}),e.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:["Added ",c]}),u&&e.jsxs("p",{className:"text-status-warning-fg mt-2 text-xs",children:[u.message," ",e.jsx(x,{variant:"link",size:"sm",onClick:h,"aria-busy":r,"aria-label":`Try again for ${s}`,className:"text-status-warning-fg h-auto p-0 text-xs underline",children:"Try again"})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs(x,{variant:"ghost",size:"sm",onClick:h,"aria-busy":r,"aria-label":`Refresh ${s}`,children:[e.jsx(B,{className:`size-3.5 ${r?"animate-spin":""}`}),e.jsx("span",{className:"ml-1.5 hidden sm:inline",children:"Refresh"})]}),e.jsxs(x,{variant:"ghost",size:"sm",onClick:p,disabled:f,className:"text-destructive hover:text-destructive","aria-label":`Remove ${s}`,children:[e.jsx(H,{className:"size-3.5"}),e.jsx("span",{className:"ml-1.5 hidden sm:inline",children:"Remove"})]})]})]})}function re({open:s,onOpenChange:t,isPending:n,error:d,onSubmit:u}){const[i,h]=b.useState(""),[r,p]=b.useState(""),f=()=>{u(i.trim(),r.trim())},c=m=>{m||(h(""),p("")),t(m)},j=r.trim().length>0&&i.trim().length>0;return e.jsx(V,{open:s,onOpenChange:c,children:e.jsxs(W,{className:"sm:max-w-md",children:[e.jsxs(G,{children:[e.jsx(J,{children:"Add a marketplace source"}),e.jsx(U,{children:"Paste a git repository link and give it a name."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(D,{htmlFor:"source-url",children:"Repository link"}),e.jsx(F,{id:"source-url",value:r,onChange:m=>p(m.target.value),placeholder:"https://github.com/org/marketplace",autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(D,{htmlFor:"source-name",children:"Name"}),e.jsx(F,{id:"source-name",value:i,onChange:m=>h(m.target.value),placeholder:"e.g. my-registry",autoComplete:"off"})]}),d&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:d})]}),e.jsxs(X,{children:[e.jsx(x,{variant:"ghost",onClick:()=>c(!1),disabled:n,children:"Cancel"}),e.jsx(x,{onClick:f,disabled:!j||n,children:n?"Adding…":"Add source"})]})]})})}function oe(){var w;const{data:s,isLoading:t}=Z(),n=Y(t),d=_(),u=ee(),i=se(),[h,r]=b.useState(!1),[p,f]=b.useState({id:0,text:""}),c=a=>f(o=>({id:o.id+1,text:a})),j=(a,o)=>{d.mutate({name:a,source:o,enabled:!0},{onSuccess:l=>{if(r(!1),l.listing.fetched){const y=M(l.listing.packageCount);c(`${l.name}: ${y}`),v.success(`Added ${l.name}. ${y}`)}else c(`${l.name}: Added, but its packages didn’t load: ${k(l.listing.reason)}`),v.warning(`Added ${l.name}, but its packages didn’t load.`)}})},m=a=>i.isPending&&i.variables===a,E=a=>{m(a)||i.mutate(a,{onSuccess:o=>{var y;if(o.stale){const A=((y=s==null?void 0:s.find(O=>O.name===a))==null?void 0:y.source)??"";c(`${a}: ${z(A)}: ${k(o.reason??"no reason given")} Still showing the last copy, from ${C(o.fetchedAt)}.`),v.warning(`${q(A)?"Couldn’t read":"Couldn’t reach"} ${a}. Still showing the last copy.`);return}const l=M(o.marketplace.plugins.length);c(`${a}: ${l}`),v.success(`Refreshed ${a}. ${l}`)},onError:o=>{c(`${a}: Its packages didn’t load: ${k(o.message)}`),v.warning(`Couldn’t refresh ${a}.`)}})},K=a=>{a||d.reset(),r(a)},Q=!n&&(!s||s.length===0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[e.jsxs("div",{children:[e.jsx(L,{children:"Marketplace sources"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Git registries that publish marketplace packages."})]}),e.jsxs(x,{onClick:()=>r(!0),size:"sm",children:[e.jsx(R,{className:"mr-1.5 size-4"}),"Add marketplace source"]})]}),n&&e.jsx("div",{className:"space-y-3",children:[1,2].map(a=>e.jsx(P,{className:"h-20 rounded-xl border"},a))}),Q&&e.jsxs("div",{className:"rounded-xl border border-dashed p-10 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"No marketplaces added yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Add a source to browse its packages."}),e.jsxs(x,{className:"mt-4",size:"sm",onClick:()=>r(!0),children:[e.jsx(R,{className:"mr-1.5 size-4"}),"Add marketplace source"]})]}),s&&s.length>0&&e.jsx("div",{className:"space-y-3",children:s.map(a=>e.jsx(ne,{name:a.name,source:a.source,enabled:a.enabled,addedAt:a.addedAt,listing:ae(a),fetched:a.lastFetch===void 0||a.lastFetch.state!=="never",onRefresh:()=>E(a.name),isRefreshing:m(a.name),onRemove:()=>u.mutate(a.name),isRemoving:u.isPending},a.name))}),e.jsx("div",{"data-slot":"listing-announcer",role:"status","aria-live":"polite",className:"sr-only",children:e.jsx("span",{children:p.text},p.id)}),e.jsx(re,{open:h,onOpenChange:K,isPending:d.isPending,error:((w=d.error)==null?void 0:w.message)??null,onSubmit:j})]})}export{oe as M};
1
+ import{a1 as N,a2 as T,aa as g,a3 as S,a4 as $,r as b,j as e,dI as L,B as x,f as R,e as P,er as I,dz as B,es as H,a7 as v,et as V,eu as W,ev as G,ew as J,ex as U,d$ as D,I as F,ey as X}from"./index-8-iQ6PnT.js";import{u as Y}from"./use-pending-read-Do0_vZ2I.js";function Z(){const s=N();return T({queryKey:g.sources(),queryFn:()=>s.listMarketplaceSources(),staleTime:6e4})}function _(){const s=N(),t=S();return $({mutationFn:n=>s.addMarketplaceSource(n),onSuccess:()=>{t.invalidateQueries({queryKey:g.sources()}),t.invalidateQueries({queryKey:g.packages()})}})}function ee(){const s=N(),t=S();return $({mutationFn:n=>s.removeMarketplaceSource(n),onSuccess:()=>{t.invalidateQueries({queryKey:g.sources()}),t.invalidateQueries({queryKey:g.packages()})}})}function se(){const s=N(),t=S();return $({mutationFn:n=>s.refreshMarketplaceSource(n),meta:{suppressErrorToast:!0},onSettled:()=>{t.invalidateQueries({queryKey:g.sources()}),t.invalidateQueries({queryKey:g.packages()})}})}function M(s){return s===1?"1 package is ready to install.":`${s} packages are ready to install.`}function k(s){return`${s.replace(/\.+$/,"")}.`}function C(s){return new Date(s).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function q(s){return s.startsWith("file://")}function z(s){return q(s)?"Couldn’t read that folder":"Couldn’t reach it"}function ae(s){const t=s.lastFetch;return(t==null?void 0:t.state)==="failed"?{kind:"failed",message:`Its packages didn’t load: ${k(t.reason)}`}:(t==null?void 0:t.state)==="stale"?{kind:"stale",message:`${z(s.source)}: ${k(t.reason)} Still showing the last copy, from ${C(t.copyFetchedAt)}.`}:null}function te(s,t,n){return s?(t==null?void 0:t.kind)==="failed"?"Enabled, but its packages didn’t load":(t==null?void 0:t.kind)==="stale"?"Enabled, showing an older copy":n?"Enabled":"Enabled, not fetched yet":"Disabled"}function ne({name:s,source:t,enabled:n,addedAt:d,listing:u,fetched:i,onRefresh:h,isRefreshing:r,onRemove:p,isRemoving:f}){const c=C(d),j=n?u?"fill-current text-status-warning-dot":i?"fill-current text-status-success":"fill-none text-muted-foreground":"fill-current text-muted-foreground";return e.jsxs("div",{"data-slot":"source-card",className:"bg-card flex items-start justify-between gap-4 rounded-xl border p-5",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(I,{className:`mt-0.5 size-3 shrink-0 ${j}`,"aria-label":te(n,u,i)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold",children:s}),e.jsx("p",{className:"text-muted-foreground truncate text-xs",children:t}),e.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:["Added ",c]}),u&&e.jsxs("p",{className:"text-status-warning-fg mt-2 text-xs",children:[u.message," ",e.jsx(x,{variant:"link",size:"sm",onClick:h,"aria-busy":r,"aria-label":`Try again for ${s}`,className:"text-status-warning-fg h-auto p-0 text-xs underline",children:"Try again"})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs(x,{variant:"ghost",size:"sm",onClick:h,"aria-busy":r,"aria-label":`Refresh ${s}`,children:[e.jsx(B,{className:`size-3.5 ${r?"animate-spin":""}`}),e.jsx("span",{className:"ml-1.5 hidden sm:inline",children:"Refresh"})]}),e.jsxs(x,{variant:"ghost",size:"sm",onClick:p,disabled:f,className:"text-destructive hover:text-destructive","aria-label":`Remove ${s}`,children:[e.jsx(H,{className:"size-3.5"}),e.jsx("span",{className:"ml-1.5 hidden sm:inline",children:"Remove"})]})]})]})}function re({open:s,onOpenChange:t,isPending:n,error:d,onSubmit:u}){const[i,h]=b.useState(""),[r,p]=b.useState(""),f=()=>{u(i.trim(),r.trim())},c=m=>{m||(h(""),p("")),t(m)},j=r.trim().length>0&&i.trim().length>0;return e.jsx(V,{open:s,onOpenChange:c,children:e.jsxs(W,{className:"sm:max-w-md",children:[e.jsxs(G,{children:[e.jsx(J,{children:"Add a marketplace source"}),e.jsx(U,{children:"Paste a git repository link and give it a name."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(D,{htmlFor:"source-url",children:"Repository link"}),e.jsx(F,{id:"source-url",value:r,onChange:m=>p(m.target.value),placeholder:"https://github.com/org/marketplace",autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(D,{htmlFor:"source-name",children:"Name"}),e.jsx(F,{id:"source-name",value:i,onChange:m=>h(m.target.value),placeholder:"e.g. my-registry",autoComplete:"off"})]}),d&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:d})]}),e.jsxs(X,{children:[e.jsx(x,{variant:"ghost",onClick:()=>c(!1),disabled:n,children:"Cancel"}),e.jsx(x,{onClick:f,disabled:!j||n,children:n?"Adding…":"Add source"})]})]})})}function oe(){var w;const{data:s,isLoading:t}=Z(),n=Y(t),d=_(),u=ee(),i=se(),[h,r]=b.useState(!1),[p,f]=b.useState({id:0,text:""}),c=a=>f(o=>({id:o.id+1,text:a})),j=(a,o)=>{d.mutate({name:a,source:o,enabled:!0},{onSuccess:l=>{if(r(!1),l.listing.fetched){const y=M(l.listing.packageCount);c(`${l.name}: ${y}`),v.success(`Added ${l.name}. ${y}`)}else c(`${l.name}: Added, but its packages didn’t load: ${k(l.listing.reason)}`),v.warning(`Added ${l.name}, but its packages didn’t load.`)}})},m=a=>i.isPending&&i.variables===a,E=a=>{m(a)||i.mutate(a,{onSuccess:o=>{var y;if(o.stale){const A=((y=s==null?void 0:s.find(O=>O.name===a))==null?void 0:y.source)??"";c(`${a}: ${z(A)}: ${k(o.reason??"no reason given")} Still showing the last copy, from ${C(o.fetchedAt)}.`),v.warning(`${q(A)?"Couldn’t read":"Couldn’t reach"} ${a}. Still showing the last copy.`);return}const l=M(o.marketplace.plugins.length);c(`${a}: ${l}`),v.success(`Refreshed ${a}. ${l}`)},onError:o=>{c(`${a}: Its packages didn’t load: ${k(o.message)}`),v.warning(`Couldn’t refresh ${a}.`)}})},K=a=>{a||d.reset(),r(a)},Q=!n&&(!s||s.length===0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[e.jsxs("div",{children:[e.jsx(L,{children:"Marketplace sources"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Git registries that publish marketplace packages."})]}),e.jsxs(x,{onClick:()=>r(!0),size:"sm",children:[e.jsx(R,{className:"mr-1.5 size-4"}),"Add marketplace source"]})]}),n&&e.jsx("div",{className:"space-y-3",children:[1,2].map(a=>e.jsx(P,{className:"h-20 rounded-xl border"},a))}),Q&&e.jsxs("div",{className:"rounded-xl border border-dashed p-10 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"No marketplaces added yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Add a source to browse its packages."}),e.jsxs(x,{className:"mt-4",size:"sm",onClick:()=>r(!0),children:[e.jsx(R,{className:"mr-1.5 size-4"}),"Add marketplace source"]})]}),s&&s.length>0&&e.jsx("div",{className:"space-y-3",children:s.map(a=>e.jsx(ne,{name:a.name,source:a.source,enabled:a.enabled,addedAt:a.addedAt,listing:ae(a),fetched:a.lastFetch===void 0||a.lastFetch.state!=="never",onRefresh:()=>E(a.name),isRefreshing:m(a.name),onRemove:()=>u.mutate(a.name),isRemoving:u.isPending},a.name))}),e.jsx("div",{"data-slot":"listing-announcer",role:"status","aria-live":"polite",className:"sr-only",children:e.jsx("span",{children:p.text},p.id)}),e.jsx(re,{open:h,onOpenChange:K,isPending:d.isPending,error:((w=d.error)==null?void 0:w.message)??null,onSubmit:j})]})}export{oe as M};
@@ -1,4 +1,4 @@
1
- import{W as S,a1 as j,a2 as T,r as h,j as u,G as w,fo as P,fp as C}from"./index-DcZPWi_I.js";import{M as $}from"./more-details-B4lBMpKi.js";/**
1
+ import{W as S,a1 as j,a2 as T,r as h,j as u,G as w,fo as P,fp as C}from"./index-8-iQ6PnT.js";import{M as $}from"./more-details-CadxnGyH.js";/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{a1 as q,a3 as B,r as a,d_ as K,a4 as T,a2 as Q,j as s,d$ as _,I as W,e0 as Y,B as b,x as z,G as S,e1 as H,e2 as V,bc as X}from"./index-DcZPWi_I.js";import{S as J}from"./shield-check-Csnr5rFy.js";const P={SIGNIN_NO_APP_REGISTRATION:"This server doesn’t let DorkOS register itself. Add your own app credentials to try again.",SIGNIN_NO_SIGNIN_SUPPORT:"This server doesn’t offer sign-in the way DorkOS expects.",SIGNIN_UNREACHABLE:"Couldn’t reach the server to start the sign-in."};function Z(e){return e!==void 0&&e in P}function k(e){const{message:t,code:i,detail:o}=e;return Z(i)?{message:P[i],detail:o??t??null,canUseOwnCredentials:i==="SIGNIN_NO_APP_REGISTRATION"}:{message:t??"Sign-in didn’t finish. Try again.",detail:o??null,canUseOwnCredentials:!1}}function ee(e){if(typeof e!="object"||e===null)return{};const{code:t,body:i}=e,o=typeof i=="object"&&i!==null?i.detail:void 0;return{...typeof t=="string"?{code:t}:{},...typeof o=="string"?{detail:o}:{}}}const U=2e3,F=5,se="Couldn’t check the sign-in. Retrying.",te="Couldn’t check if the sign-in finished. Try again in a moment.",j={phase:"idle",disclosure:null,authorizeUrl:null,startFailure:null,credentialsError:null,flowId:null,watching:!1};function ne(e){const t=e==null?void 0:e.toolCount;return typeof t!="number"||!Number.isFinite(t)||t<0?null:t}function re(e,t){return(e==null?void 0:e.status)==="failed"?e.error??"Sign-in didn’t finish. Try again.":t>=F?te:null}function ie(e){return{...j,phase:"failed",startFailure:k({message:e.message,...ee(e)})}}function ae(e){return e===null?null:k({message:e})}function O(e){return e.flowId===null?!1:e.phase==="waiting"||e.phase==="disclosure"&&e.watching}function le(e,t,i){return O(e)?(t==null?void 0:t.status)==="connected"?"connected":(t==null?void 0:t.status)==="failed"?"failed":e.phase!=="waiting"?e.phase:i>=F?"failed":"waiting":e.phase}function pe(e,t){const i=q(),o=B(),[u,r]=a.useState(j),h=a.useRef(0),[x,C]=a.useState(0),g=a.useRef(null),d=a.useCallback(n=>{g.current=n,h.current=0,C(0)},[]),p=a.useCallback((n,c)=>{c===g.current&&(h.current=n==="ok"?0:h.current+1,C(h.current))},[]),f=a.useCallback(()=>{o.invalidateQueries({queryKey:K.mcpServers(e)}),o.invalidateQueries({queryKey:["mcp-config"]})},[o,e]),l=T({mutationFn:()=>i.startMcpSignin(e,t),meta:{suppressErrorToast:!0}}),v=a.useCallback(()=>{d(null),r({...j,phase:"starting"}),l.mutate(void 0,{onSuccess:n=>{if(!n.alreadyConnected&&!n.authorizeUrl){r({...j,phase:"failed",startFailure:k({message:"Couldn’t make a sign-in link for this server."})});return}d(n.flowId),r({phase:n.alreadyConnected?"connected":"disclosure",disclosure:n.disclosure,authorizeUrl:n.authorizeUrl??null,startFailure:null,credentialsError:null,flowId:n.flowId,watching:!1})},onError:n=>r(ie(n))})},[l,d]),I=T({mutationFn:n=>i.setMcpClientCredentials(e,t,n),meta:{suppressErrorToast:!0}}),A=a.useCallback(n=>{r(c=>c.credentialsError===null?c:{...c,credentialsError:null}),I.mutate(n,{onSuccess:()=>{f(),v()},onError:c=>r(N=>({...N,credentialsError:c.message}))})},[I,f,v]),M=a.useCallback(n=>{g.current!==n.flowId&&(f(),d(n.flowId),r({phase:"disclosure",disclosure:n.disclosure,authorizeUrl:n.authorizeUrl,startFailure:null,credentialsError:null,flowId:n.flowId,watching:!0}))},[d]),D=a.useCallback(()=>{r(n=>n.phase==="disclosure"?{...n,phase:"waiting"}:n)},[]),G=a.useCallback(()=>{d(null),r(j)},[d]),E=Q({queryKey:["mcp-signin",e,t,u.flowId??""],queryFn:async()=>{const n=u.flowId??"";try{const c=await i.pollMcpSignin(n);return p("ok",n),c}catch(c){throw p("failed",n),c}},enabled:O(u),refetchInterval:n=>{var R;const c=(R=n.state.data)==null?void 0:R.status;if(c==="connected"||c==="failed")return!1;const N=h.current;return N===0?U:N>=F?!1:U*(N+1)},retry:!1,refetchOnWindowFocus:n=>{var c;return((c=n.state.data)==null?void 0:c.status)==="failed"},refetchOnReconnect:!1,gcTime:0,staleTime:0,meta:{suppressErrorToast:!0}}),w=x,y=le(u,E.data,w);a.useEffect(()=>{y==="connected"&&f()},[y,f]);const m=O(u)?ae(re(E.data,w)):u.startFailure,$=y==="waiting"&&w>0?se:null;return{state:{step:y,disclosure:u.disclosure,authorizeUrl:u.authorizeUrl,error:(m==null?void 0:m.message)??null,errorDetail:(m==null?void 0:m.detail)??null,canUseOwnCredentials:(m==null?void 0:m.canUseOwnCredentials)??!1,savingCredentials:I.isPending,credentialsError:u.credentialsError,retryNotice:$,toolCount:y==="connected"?ne(E.data):null},start:v,adopt:M,authOpened:D,useOwnCredentials:A,reset:G}}function ce({onSave:e,onCancel:t,saving:i=!1,error:o=null,className:u}){const r=a.useId(),h=a.useRef(null),[x,C]=a.useState(""),[g,d]=a.useState(""),p=x.trim(),f=g.trim();return a.useEffect(()=>{var l;(l=h.current)==null||l.focus()},[]),s.jsxs("form",{className:S("space-y-2",u),onSubmit:l=>{l.preventDefault(),!(!p||i)&&e({clientId:p,...f?{clientSecret:f}:{}})},children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(_,{htmlFor:`${r}-client-id`,className:"text-xs",children:"Client ID"}),s.jsx(W,{id:`${r}-client-id`,ref:h,value:x,onChange:l=>C(l.target.value),autoComplete:"off",spellCheck:!1,disabled:i,className:"h-8 text-xs"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs(_,{htmlFor:`${r}-client-secret`,className:"text-xs",children:["Client secret ",s.jsx("span",{className:"text-muted-foreground font-normal",children:"(if you got one)"})]}),s.jsx(Y,{id:`${r}-client-secret`,value:g,onChange:l=>d(l.target.value),autoComplete:"off",disabled:i,className:"h-8 text-xs"})]}),s.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:"From the service’s developer settings. Kept encrypted here; agents never see it."}),o&&s.jsx("p",{role:"alert",className:"text-destructive text-xs leading-relaxed",children:o}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(b,{type:"submit",size:"sm",disabled:!p||i,className:"gap-1.5 focus-visible:ring-2",children:[i&&s.jsx(z,{size:"xs"}),"Save and sign in"]}),s.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:i,className:"focus-visible:ring-2",children:"Cancel"})]})]})}function L({children:e}){return s.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[s.jsx(z,{size:"xs"}),e]})}function oe(e){return e===null?"Signed in. Its tools are available on the next turn.":`Connected · ${e} tool${e===1?"":"s"}.`}function ue(e){return`DorkOS keeps the key from ${e} here, never your agent. Removing the server deletes it.`}function de(e){const{state:t}=e;return t.step==="starting"?s.jsx(L,{children:"Starting sign-in…"}):t.step==="waiting"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(L,{children:"Waiting for you to sign in… Close the tab when done."}),t.retryNotice&&s.jsx("p",{className:"text-muted-foreground text-xs",children:t.retryNotice})]}):t.step==="connected"?s.jsxs("p",{className:"text-status-success-fg flex items-center gap-2 text-xs",children:[s.jsx(X,{className:"size-3.5","aria-hidden":!0}),oe(t.toolCount)]}):null}function me({flow:e,serverName:t,className:i,failedActions:o,connectedActions:u}){const{state:r}=e,h=a.useRef(null),x=r.step==="disclosure",C=a.useRef(null),[g,d]=a.useState(!1),p=g&&r.canUseOwnCredentials;a.useEffect(()=>{var l;x&&((l=h.current)==null||l.focus())},[x]);const f=a.useRef(!1);return a.useEffect(()=>{var l;!f.current||p||(f.current=!1,(l=C.current)==null||l.focus())},[p]),s.jsxs(s.Fragment,{children:[s.jsx("div",{role:"status",className:S("[&:not(:empty)]:mt-1",i),children:de(e)}),x&&s.jsxs("div",{className:S("mt-1 space-y-2",i),children:[s.jsxs("div",{ref:h,tabIndex:-1,className:"border-status-success-border bg-status-success-bg text-status-success-fg flex items-start gap-2 rounded-md border px-3 py-2 focus-visible:ring-2",children:[s.jsx(J,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-xs font-semibold",children:"Your sign-in stays on this computer."}),s.jsx("p",{className:"text-xs leading-relaxed",children:r.disclosure??ue(t)})]})]}),r.authorizeUrl&&s.jsx(b,{asChild:!0,size:"sm",className:"gap-1.5 focus-visible:ring-2",children:s.jsxs(H,{href:r.authorizeUrl,onOpened:()=>e.authOpened(),"aria-label":`Open the sign-in page for ${t}`,children:["Open the sign-in page",s.jsx(V,{className:"size-3.5","aria-hidden":!0})]})})]}),r.step==="failed"&&s.jsxs("div",{className:S("mt-1 space-y-2",i),children:[s.jsx("p",{role:"alert",className:"text-destructive text-xs leading-relaxed",children:r.error??"Sign-in didn’t finish. Try again."}),r.errorDetail&&s.jsxs("details",{className:"text-muted-foreground text-xs",children:[s.jsx("summary",{className:"cursor-pointer focus-visible:ring-2",children:"Details"}),s.jsx("code",{className:"text-2xs mt-1 block font-mono break-all",children:r.errorDetail})]}),p?s.jsx(ce,{onSave:l=>e.useOwnCredentials(l),onCancel:()=>{d(!1),f.current=!0},saving:r.savingCredentials,error:r.credentialsError}):s.jsxs("div",{className:"flex flex-wrap gap-2",children:[o,r.canUseOwnCredentials&&s.jsx(b,{ref:C,variant:"secondary",size:"sm",onClick:()=>d(!0),className:"focus-visible:ring-2",children:"Use your own app credentials"})]})]}),r.step==="connected"&&u&&s.jsx("div",{className:S("mt-1",i),children:u})]})}export{me as M,pe as u};
1
+ import{a1 as q,a3 as B,r as a,d_ as K,a4 as T,a2 as Q,j as s,d$ as _,I as W,e0 as Y,B as b,x as z,G as S,e1 as H,e2 as V,bc as X}from"./index-8-iQ6PnT.js";import{S as J}from"./shield-check-CpUB_Ju1.js";const P={SIGNIN_NO_APP_REGISTRATION:"This server doesn’t let DorkOS register itself. Add your own app credentials to try again.",SIGNIN_NO_SIGNIN_SUPPORT:"This server doesn’t offer sign-in the way DorkOS expects.",SIGNIN_UNREACHABLE:"Couldn’t reach the server to start the sign-in."};function Z(e){return e!==void 0&&e in P}function k(e){const{message:t,code:i,detail:o}=e;return Z(i)?{message:P[i],detail:o??t??null,canUseOwnCredentials:i==="SIGNIN_NO_APP_REGISTRATION"}:{message:t??"Sign-in didn’t finish. Try again.",detail:o??null,canUseOwnCredentials:!1}}function ee(e){if(typeof e!="object"||e===null)return{};const{code:t,body:i}=e,o=typeof i=="object"&&i!==null?i.detail:void 0;return{...typeof t=="string"?{code:t}:{},...typeof o=="string"?{detail:o}:{}}}const U=2e3,F=5,se="Couldn’t check the sign-in. Retrying.",te="Couldn’t check if the sign-in finished. Try again in a moment.",j={phase:"idle",disclosure:null,authorizeUrl:null,startFailure:null,credentialsError:null,flowId:null,watching:!1};function ne(e){const t=e==null?void 0:e.toolCount;return typeof t!="number"||!Number.isFinite(t)||t<0?null:t}function re(e,t){return(e==null?void 0:e.status)==="failed"?e.error??"Sign-in didn’t finish. Try again.":t>=F?te:null}function ie(e){return{...j,phase:"failed",startFailure:k({message:e.message,...ee(e)})}}function ae(e){return e===null?null:k({message:e})}function O(e){return e.flowId===null?!1:e.phase==="waiting"||e.phase==="disclosure"&&e.watching}function le(e,t,i){return O(e)?(t==null?void 0:t.status)==="connected"?"connected":(t==null?void 0:t.status)==="failed"?"failed":e.phase!=="waiting"?e.phase:i>=F?"failed":"waiting":e.phase}function pe(e,t){const i=q(),o=B(),[u,r]=a.useState(j),h=a.useRef(0),[x,C]=a.useState(0),g=a.useRef(null),d=a.useCallback(n=>{g.current=n,h.current=0,C(0)},[]),p=a.useCallback((n,c)=>{c===g.current&&(h.current=n==="ok"?0:h.current+1,C(h.current))},[]),f=a.useCallback(()=>{o.invalidateQueries({queryKey:K.mcpServers(e)}),o.invalidateQueries({queryKey:["mcp-config"]})},[o,e]),l=T({mutationFn:()=>i.startMcpSignin(e,t),meta:{suppressErrorToast:!0}}),v=a.useCallback(()=>{d(null),r({...j,phase:"starting"}),l.mutate(void 0,{onSuccess:n=>{if(!n.alreadyConnected&&!n.authorizeUrl){r({...j,phase:"failed",startFailure:k({message:"Couldn’t make a sign-in link for this server."})});return}d(n.flowId),r({phase:n.alreadyConnected?"connected":"disclosure",disclosure:n.disclosure,authorizeUrl:n.authorizeUrl??null,startFailure:null,credentialsError:null,flowId:n.flowId,watching:!1})},onError:n=>r(ie(n))})},[l,d]),I=T({mutationFn:n=>i.setMcpClientCredentials(e,t,n),meta:{suppressErrorToast:!0}}),A=a.useCallback(n=>{r(c=>c.credentialsError===null?c:{...c,credentialsError:null}),I.mutate(n,{onSuccess:()=>{f(),v()},onError:c=>r(N=>({...N,credentialsError:c.message}))})},[I,f,v]),M=a.useCallback(n=>{g.current!==n.flowId&&(f(),d(n.flowId),r({phase:"disclosure",disclosure:n.disclosure,authorizeUrl:n.authorizeUrl,startFailure:null,credentialsError:null,flowId:n.flowId,watching:!0}))},[d]),D=a.useCallback(()=>{r(n=>n.phase==="disclosure"?{...n,phase:"waiting"}:n)},[]),G=a.useCallback(()=>{d(null),r(j)},[d]),E=Q({queryKey:["mcp-signin",e,t,u.flowId??""],queryFn:async()=>{const n=u.flowId??"";try{const c=await i.pollMcpSignin(n);return p("ok",n),c}catch(c){throw p("failed",n),c}},enabled:O(u),refetchInterval:n=>{var R;const c=(R=n.state.data)==null?void 0:R.status;if(c==="connected"||c==="failed")return!1;const N=h.current;return N===0?U:N>=F?!1:U*(N+1)},retry:!1,refetchOnWindowFocus:n=>{var c;return((c=n.state.data)==null?void 0:c.status)==="failed"},refetchOnReconnect:!1,gcTime:0,staleTime:0,meta:{suppressErrorToast:!0}}),w=x,y=le(u,E.data,w);a.useEffect(()=>{y==="connected"&&f()},[y,f]);const m=O(u)?ae(re(E.data,w)):u.startFailure,$=y==="waiting"&&w>0?se:null;return{state:{step:y,disclosure:u.disclosure,authorizeUrl:u.authorizeUrl,error:(m==null?void 0:m.message)??null,errorDetail:(m==null?void 0:m.detail)??null,canUseOwnCredentials:(m==null?void 0:m.canUseOwnCredentials)??!1,savingCredentials:I.isPending,credentialsError:u.credentialsError,retryNotice:$,toolCount:y==="connected"?ne(E.data):null},start:v,adopt:M,authOpened:D,useOwnCredentials:A,reset:G}}function ce({onSave:e,onCancel:t,saving:i=!1,error:o=null,className:u}){const r=a.useId(),h=a.useRef(null),[x,C]=a.useState(""),[g,d]=a.useState(""),p=x.trim(),f=g.trim();return a.useEffect(()=>{var l;(l=h.current)==null||l.focus()},[]),s.jsxs("form",{className:S("space-y-2",u),onSubmit:l=>{l.preventDefault(),!(!p||i)&&e({clientId:p,...f?{clientSecret:f}:{}})},children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(_,{htmlFor:`${r}-client-id`,className:"text-xs",children:"Client ID"}),s.jsx(W,{id:`${r}-client-id`,ref:h,value:x,onChange:l=>C(l.target.value),autoComplete:"off",spellCheck:!1,disabled:i,className:"h-8 text-xs"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs(_,{htmlFor:`${r}-client-secret`,className:"text-xs",children:["Client secret ",s.jsx("span",{className:"text-muted-foreground font-normal",children:"(if you got one)"})]}),s.jsx(Y,{id:`${r}-client-secret`,value:g,onChange:l=>d(l.target.value),autoComplete:"off",disabled:i,className:"h-8 text-xs"})]}),s.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:"From the service’s developer settings. Kept encrypted here; agents never see it."}),o&&s.jsx("p",{role:"alert",className:"text-destructive text-xs leading-relaxed",children:o}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(b,{type:"submit",size:"sm",disabled:!p||i,className:"gap-1.5 focus-visible:ring-2",children:[i&&s.jsx(z,{size:"xs"}),"Save and sign in"]}),s.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:i,className:"focus-visible:ring-2",children:"Cancel"})]})]})}function L({children:e}){return s.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[s.jsx(z,{size:"xs"}),e]})}function oe(e){return e===null?"Signed in. Its tools are available on the next turn.":`Connected · ${e} tool${e===1?"":"s"}.`}function ue(e){return`DorkOS keeps the key from ${e} here, never your agent. Removing the server deletes it.`}function de(e){const{state:t}=e;return t.step==="starting"?s.jsx(L,{children:"Starting sign-in…"}):t.step==="waiting"?s.jsxs("div",{className:"space-y-1",children:[s.jsx(L,{children:"Waiting for you to sign in… Close the tab when done."}),t.retryNotice&&s.jsx("p",{className:"text-muted-foreground text-xs",children:t.retryNotice})]}):t.step==="connected"?s.jsxs("p",{className:"text-status-success-fg flex items-center gap-2 text-xs",children:[s.jsx(X,{className:"size-3.5","aria-hidden":!0}),oe(t.toolCount)]}):null}function me({flow:e,serverName:t,className:i,failedActions:o,connectedActions:u}){const{state:r}=e,h=a.useRef(null),x=r.step==="disclosure",C=a.useRef(null),[g,d]=a.useState(!1),p=g&&r.canUseOwnCredentials;a.useEffect(()=>{var l;x&&((l=h.current)==null||l.focus())},[x]);const f=a.useRef(!1);return a.useEffect(()=>{var l;!f.current||p||(f.current=!1,(l=C.current)==null||l.focus())},[p]),s.jsxs(s.Fragment,{children:[s.jsx("div",{role:"status",className:S("[&:not(:empty)]:mt-1",i),children:de(e)}),x&&s.jsxs("div",{className:S("mt-1 space-y-2",i),children:[s.jsxs("div",{ref:h,tabIndex:-1,className:"border-status-success-border bg-status-success-bg text-status-success-fg flex items-start gap-2 rounded-md border px-3 py-2 focus-visible:ring-2",children:[s.jsx(J,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-xs font-semibold",children:"Your sign-in stays on this computer."}),s.jsx("p",{className:"text-xs leading-relaxed",children:r.disclosure??ue(t)})]})]}),r.authorizeUrl&&s.jsx(b,{asChild:!0,size:"sm",className:"gap-1.5 focus-visible:ring-2",children:s.jsxs(H,{href:r.authorizeUrl,onOpened:()=>e.authOpened(),"aria-label":`Open the sign-in page for ${t}`,children:["Open the sign-in page",s.jsx(V,{className:"size-3.5","aria-hidden":!0})]})})]}),r.step==="failed"&&s.jsxs("div",{className:S("mt-1 space-y-2",i),children:[s.jsx("p",{role:"alert",className:"text-destructive text-xs leading-relaxed",children:r.error??"Sign-in didn’t finish. Try again."}),r.errorDetail&&s.jsxs("details",{className:"text-muted-foreground text-xs",children:[s.jsx("summary",{className:"cursor-pointer focus-visible:ring-2",children:"Details"}),s.jsx("code",{className:"text-2xs mt-1 block font-mono break-all",children:r.errorDetail})]}),p?s.jsx(ce,{onSave:l=>e.useOwnCredentials(l),onCancel:()=>{d(!1),f.current=!0},saving:r.savingCredentials,error:r.credentialsError}):s.jsxs("div",{className:"flex flex-wrap gap-2",children:[o,r.canUseOwnCredentials&&s.jsx(b,{ref:C,variant:"secondary",size:"sm",onClick:()=>d(!0),className:"focus-visible:ring-2",children:"Use your own app credentials"})]})]}),r.step==="connected"&&u&&s.jsx("div",{className:S("mt-1",i),children:u})]})}export{me as M,pe as u};
@@ -1,4 +1,4 @@
1
- var i_=Object.defineProperty;var s_=(r,e,t)=>e in r?i_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var jt=(r,e,t)=>s_(r,typeof e!="symbol"?e+"":e,t);import{r as Xc,j as Kc}from"./index-DcZPWi_I.js";/**
1
+ var i_=Object.defineProperty;var s_=(r,e,t)=>e in r?i_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var jt=(r,e,t)=>s_(r,typeof e!="symbol"?e+"":e,t);import{r as Xc,j as Kc}from"./index-8-iQ6PnT.js";/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-8-iQ6PnT.js";import{P as m}from"./ProfileFields-Dp68ebW9.js";import"./profile-errors-C1qSJkiG.js";import"./use-mounted-ref-BAO3qunF.js";function a({member:r}){return o.jsx(m,{member:r})}export{a as NamePage};