dorkos 0.110.0 → 0.114.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 (194) hide show
  1. package/core-extensions/hello-world/index.ts +2 -2
  2. package/dist/bin/cli.js +13592 -1701
  3. package/dist/browser/native/package-manifest.json +1 -1
  4. package/dist/browser/source-manifest.json +1 -1
  5. package/dist/client/assets/{AboutPage-C4kqKgU6.js → AboutPage-mErbIY0l.js} +1 -1
  6. package/dist/client/assets/{ActivityErrorState-DiSxgHLa.js → ActivityErrorState-AlI4F82u.js} +1 -1
  7. package/dist/client/assets/{ActivityPage-BQneQ83b.js → ActivityPage-CHUqb-8c.js} +1 -1
  8. package/dist/client/assets/{ActivityRow-BEKcGUIZ.js → ActivityRow-Baqdr6cP.js} +1 -1
  9. package/dist/client/assets/AdapterIcon-C_fBZXHQ.js +1 -0
  10. package/dist/client/assets/{AdapterSetupWizard-DpnW23lt.js → AdapterSetupWizard-BL70qy2J.js} +2 -2
  11. package/dist/client/assets/{AgentRequestCard-DosR0AYu.js → AgentRequestCard-CcMh6JyE.js} +3 -3
  12. package/dist/client/assets/{AppearancePage-DIeNtC-G.js → AppearancePage-t9SnSRs-.js} +1 -1
  13. package/dist/client/assets/{AttentionSignalRow-B0nSHLwZ.js → AttentionSignalRow-jlgWaSSd.js} +1 -1
  14. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-BXMeIZyY.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-DHr_AhUv.js} +3 -3
  15. package/dist/client/assets/{BlintzCanvas-D-7b_-SG.js → BlintzCanvas-Bq4e7n__.js} +1 -1
  16. package/dist/client/assets/{CanvasCsvContent-iBvH55TS.js → CanvasCsvContent-OR226CLS.js} +2 -2
  17. package/dist/client/assets/CanvasFileContent-BejM-9Wg.js +2 -0
  18. package/dist/client/assets/CanvasModel3dContent-BD-eCVsX.js +2 -0
  19. package/dist/client/assets/{CodeMirrorDiff-BfF4jWmG.js → CodeMirrorDiff-D7BWMOim.js} +1 -1
  20. package/dist/client/assets/{CodeMirrorEditor-gShkyo4u.js → CodeMirrorEditor-BodwsIG7.js} +1 -1
  21. package/dist/client/assets/{CommitmentList-Bz1qfyAm.js → CommitmentList-YVb3yTvO.js} +1 -1
  22. package/dist/client/assets/{CommitmentsPage-BFnrzM5F.js → CommitmentsPage-DL_jJQbw.js} +1 -1
  23. package/dist/client/assets/{ConnectionAccessLists-C5dmaUUD.js → ConnectionAccessLists-BPsgToSR.js} +1 -1
  24. package/dist/client/assets/{ConnectionsPage-BX_hUzvu.js → ConnectionsPage-D7vlYnjf.js} +2 -2
  25. package/dist/client/assets/{ConventionPage-DHtiOJYZ.js → ConventionPage-BR7I3AdE.js} +3 -3
  26. package/dist/client/assets/{ExtensionPageRoute-DluAWT6h.js → ExtensionPageRoute-CzXGvVRm.js} +2 -2
  27. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-IBBeJf7u.js → FloatingTanStackRouterDevtools-CqogiFob-BV3h0rFa.js} +1 -1
  28. package/dist/client/assets/HandlePage-B33P0oh0.js +1 -0
  29. package/dist/client/assets/{HeartbeatPage-DcispKV9.js → HeartbeatPage-CfjZuvtQ.js} +1 -1
  30. package/dist/client/assets/{LexicalField-CvW19ipK.js → LexicalField-Cc6wFZAZ.js} +2 -2
  31. package/dist/client/assets/{ManagesPage-Dru8_kTd.js → ManagesPage-BxHSb65X.js} +1 -1
  32. package/dist/client/assets/{Marketplace-UEST-d72.js → Marketplace-EgG6JmBG.js} +4 -4
  33. package/dist/client/assets/{MarketplaceSourcesView-2XwWS0fF.js → MarketplaceSourcesView-D9kq9hl6.js} +1 -1
  34. package/dist/client/assets/{McpAppFrame-DcPNmy1o.js → McpAppFrame-6zxszx9A.js} +2 -2
  35. package/dist/client/assets/{McpSigninBody-YXQtYFSW.js → McpSigninBody-DBWSc6bm.js} +1 -1
  36. package/dist/client/assets/{Model3dViewer-D9HznL8w.js → Model3dViewer-CgeJ2v-F.js} +1 -1
  37. package/dist/client/assets/NamePage-MfybpnwN.js +1 -0
  38. package/dist/client/assets/NewDirectMessageMenu-BnBO4aGI.js +1 -0
  39. package/dist/client/assets/{NotificationsPage-Dg7_d0Fo.js → NotificationsPage-C5aRITCd.js} +1 -1
  40. package/dist/client/assets/{OpenMeshSwitch-Dw8ylRP7.js → OpenMeshSwitch-UKMQeS7-.js} +2 -2
  41. package/dist/client/assets/{OperatorIdentityForm-DtA4qIAR.js → OperatorIdentityForm-DH2au7QU.js} +1 -1
  42. package/dist/client/assets/{PermissionsPage-ZEO9Crz4.js → PermissionsPage-BgLLmdg2.js} +1 -1
  43. package/dist/client/assets/{PersonalityPopover-Cv26YoDX.js → PersonalityPopover-vLDfndfo.js} +1 -1
  44. package/dist/client/assets/PhotoPage-BgyB3B2_.js +1 -0
  45. package/dist/client/assets/{PreviewRefusedNotice-CLOum_3D.js → PreviewRefusedNotice-Dh3SCC_A.js} +1 -1
  46. package/dist/client/assets/{PromptSuggestionChips-BMFNtxGR.js → PromptSuggestionChips-EO_0zbzq.js} +1 -1
  47. package/dist/client/assets/{ReportsToPopover-CR7Exvh7.js → ReportsToPopover-C9Ceg1AW.js} +1 -1
  48. package/dist/client/assets/{RoomSurface-Bq7667r4.js → RoomSurface-B8ec3_at.js} +8 -8
  49. package/dist/client/assets/{RoomsPage-DGOvUZFv.js → RoomsPage-pPw8vrsB.js} +1 -1
  50. package/dist/client/assets/{RunsOnPopover-CpS43xkI.js → RunsOnPopover-CJoSj8w7.js} +1 -1
  51. package/dist/client/assets/RuntimeSetupDialog-Cqn_Grel.js +1 -0
  52. package/dist/client/assets/SessionsPage-BASybh9v.js +1 -0
  53. package/dist/client/assets/{SkillsPage-cjkbMED1.js → SkillsPage-DL0909et.js} +1 -1
  54. package/dist/client/assets/{TasksPage-HQqmMSc-.js → TasksPage-BwUW6dia.js} +1 -1
  55. package/dist/client/assets/{ToolsPage-Bo2_xjXO.js → ToolsPage-C3xfGWdb.js} +2 -2
  56. package/dist/client/assets/{TopologyGraph-Is22VGxs.js → TopologyGraph-D7Ik1Xt6.js} +1 -1
  57. package/dist/client/assets/{TourHost-DxBh58jt.js → TourHost-Db0fxAXo.js} +1 -1
  58. package/dist/client/assets/{UnlinkDialog-B70UThXm.js → UnlinkDialog-TTK5Z_QD.js} +1 -1
  59. package/dist/client/assets/{WidgetErrorCard-l8cP9oJc.js → WidgetErrorCard-D--KcgW1.js} +24 -29
  60. package/dist/client/assets/_shell-CGWsN6Gs.js +88 -0
  61. package/dist/client/assets/{_shell._home-9g2nykRD.js → _shell._home-CzpVyTzo.js} +1 -1
  62. package/dist/client/assets/{_shell._home.activity-M0V2vwFy.js → _shell._home.activity-BbWquOK0.js} +1 -1
  63. package/dist/client/assets/_shell._home.index-Cg0nRFMN.js +3 -0
  64. package/dist/client/assets/_shell._home.tasks-BpoOVihw.js +1 -0
  65. package/dist/client/assets/{_shell._home.workspaces-BSeaYQDz.js → _shell._home.workspaces-DVF1rM3t.js} +1 -1
  66. package/dist/client/assets/_shell.channels-CCGSs0Bn.js +10 -0
  67. package/dist/client/assets/_shell.connections-0_34lXIQ.js +1 -0
  68. package/dist/client/assets/{_shell.feedback-requests-BPwtAQNY.js → _shell.feedback-requests-C6alx2ox.js} +1 -1
  69. package/dist/client/assets/_shell.marketplace-Dp-p8E3V.js +1 -0
  70. package/dist/client/assets/_shell.marketplace_.sources-SN2Fb1eb.js +1 -0
  71. package/dist/client/assets/_shell.session-Bt3jdQdD.js +66 -0
  72. package/dist/client/assets/_shell.team-BIwJNdkd.js +28 -0
  73. package/dist/client/assets/_shell.x._extensionId-Bjn-MKsP.js +1 -0
  74. package/dist/client/assets/_shell.x._extensionId_._-Bjn-MKsP.js +1 -0
  75. package/dist/client/assets/{agent-browser-CSBlgMiw.js → agent-browser-CO5haI5Y.js} +1 -1
  76. package/dist/client/assets/{banner-D26eekSD.js → banner-Dh5mO27l.js} +2 -2
  77. package/dist/client/assets/{card-CTGm0Blo.js → card-CKZCX8ol.js} +1 -1
  78. package/dist/client/assets/{file-B6neiwXF.js → file-CMPbZedq.js} +1 -1
  79. package/dist/client/assets/{file-exclamation-point-B-iziRzy.js → file-exclamation-point-emLeXvmw.js} +1 -1
  80. package/dist/client/assets/file-text-9a0DChCq.js +6 -0
  81. package/dist/client/assets/{find-latest-widget-fence-Dw4BJ_cR.js → find-latest-widget-fence--3kWMT1F.js} +3 -3
  82. package/dist/client/assets/{git-branch-D9jctpSd.js → git-branch-hfu8isLA.js} +1 -1
  83. package/dist/client/assets/{heart-cgLUdSV5.js → heart-SRafwnSd.js} +1 -1
  84. package/dist/client/assets/{highlighted-body-KPVGNVTW-CEOricmN.js → highlighted-body-KPVGNVTW-Dxwd3mxT.js} +1 -1
  85. package/dist/client/assets/index-3GDQSKet.js +1 -0
  86. package/dist/client/assets/{index-bHlg-Jp8.js → index-BB18IeC2.js} +1 -1
  87. package/dist/client/assets/index-BBQMqcO_.js +1 -0
  88. package/dist/client/assets/{index-D4em25Xt.js → index-BDfoFNcA.js} +1 -1
  89. package/dist/client/assets/{index-CBQqdBKL.js → index-BNn3-chz.js} +1 -1
  90. package/dist/client/assets/{index-_nhqr_iZ.js → index-BRGOMmOM.js} +1 -1
  91. package/dist/client/assets/{index-CVzwL_3n.js → index-BTXBESRm.js} +1 -1
  92. package/dist/client/assets/{index-1flHw44u.js → index-BTreBsWa.js} +2 -2
  93. package/dist/client/assets/{index-BfDqp5Sv.js → index-BUVKya1M.js} +8 -8
  94. package/dist/client/assets/{index-BkYvXnXR.js → index-BYp9xcmS.js} +1 -1
  95. package/dist/client/assets/{index-DckajKF2.js → index-BokDvdOG.js} +1 -1
  96. package/dist/client/assets/{index-CLuxURdA.js → index-C3xuhmPa.js} +2 -2
  97. package/dist/client/assets/{index-ZNJbhnlq.js → index-C4nEz6I-.js} +1 -1
  98. package/dist/client/assets/{index-BZKMWkth.js → index-C63bLSO4.js} +271 -261
  99. package/dist/client/assets/{index-CupP-VJi.js → index-C7BTAdSc.js} +1 -1
  100. package/dist/client/assets/{index-CSQHKTvU.js → index-CAlXjm0N.js} +1 -1
  101. package/dist/client/assets/index-CTxEG5rD.js +1 -0
  102. package/dist/client/assets/{index-C3tcDwG6.js → index-CbFo-7kM.js} +1 -1
  103. package/dist/client/assets/{index-BfgOj4sK.js → index-Ch41JOI2.js} +1 -1
  104. package/dist/client/assets/{index-CqHifKay.js → index-CkknQ52Q.js} +5 -5
  105. package/dist/client/assets/{index-vkTtWH-G.js → index-Cow815Qa.js} +1 -1
  106. package/dist/client/assets/{index-CbDB1su1.js → index-Cp7oifSs.js} +1 -1
  107. package/dist/client/assets/{index-DcqBUr0N.js → index-CpYs0Lli.js} +1 -1
  108. package/dist/client/assets/{index-ClIP6HHR.js → index-D0Nd2LA-.js} +1 -1
  109. package/dist/client/assets/{index-BO2LMWbR.js → index-D67aFWxz.js} +1 -1
  110. package/dist/client/assets/index-DFEF2MFy.css +1 -0
  111. package/dist/client/assets/{index-DKjP63zN.js → index-DIlV08Vw.js} +1 -1
  112. package/dist/client/assets/{index-CiIZQZuK.js → index-DLNwEM2Q.js} +1 -1
  113. package/dist/client/assets/{index-lKqCjbqn.js → index-DLZi_nae.js} +1 -1
  114. package/dist/client/assets/{index-B38pxhxw.js → index-DRqEM5Wb.js} +1 -1
  115. package/dist/client/assets/{index-CUu6WsiU.js → index-DX-j3Ul0.js} +1 -1
  116. package/dist/client/assets/{index-tf4Y0hYZ.js → index-DX7V94qe.js} +1 -1
  117. package/dist/client/assets/{index-K2hqr6x6.js → index-D_Wc_qTa.js} +3 -3
  118. package/dist/client/assets/{index-DMmU6ZLq.js → index-DdsKmfEH.js} +1 -1
  119. package/dist/client/assets/{index-Bkfi8Myj.js → index-DmTI5Hye.js} +1 -1
  120. package/dist/client/assets/{index-LP8S5WuT.js → index-YswfjpmW.js} +1 -1
  121. package/dist/client/assets/{index-CsjcT6BA.js → index-g_5oOlG6.js} +1 -1
  122. package/dist/client/assets/{index-DQDCxGNh.js → index-iD0epmn3.js} +1 -1
  123. package/dist/client/assets/{index-CeCuaX5y.js → index-lJc8v0Z3.js} +1 -1
  124. package/dist/client/assets/index-t7gsOfUI.js +1 -0
  125. package/dist/client/assets/kickoff-xkt4LpIP.js +3 -0
  126. package/dist/client/assets/{layers-BpMm7sp6.js → layers-Cy8Tme6i.js} +1 -1
  127. package/dist/client/assets/{lightbulb-CxP8HLlU.js → lightbulb-tNm7gLYi.js} +1 -1
  128. package/dist/client/assets/{markdown-content-plNIomQc.js → markdown-content-CoK3F0c0.js} +1 -1
  129. package/dist/client/assets/{mention-pill-B9c_KFvY.js → mention-pill-Bgs_yujj.js} +1 -1
  130. package/dist/client/assets/{message-square-off-8wAP6cRG.js → message-square-off-CF2Bzen3.js} +1 -1
  131. package/dist/client/assets/{owner-notice-CopwUeso.js → owner-notice-cgCWG4hG.js} +1 -1
  132. package/dist/client/assets/{package-B7amjGSw.js → package-DE8sQpId.js} +1 -1
  133. package/dist/client/assets/{page-container-DMx2f-Ca.js → page-container-BoXmmBSs.js} +1 -1
  134. package/dist/client/assets/{paperclip-CA9pcNn6.js → paperclip-IgDeVFea.js} +1 -1
  135. package/dist/client/assets/{radio-B4GY45ie.js → radio-BzTkFBDD.js} +1 -1
  136. package/dist/client/assets/{room-files-source-91oNy8mM.js → room-files-source-CIIDTSTA.js} +2 -2
  137. package/dist/client/assets/{rotate-ccw-clock-C-ftj_rU.js → rotate-ccw-clock-CGcSqHnk.js} +1 -1
  138. package/dist/client/assets/{rotate-cw-TrlUqVdq.js → rotate-cw-DaduzRfP.js} +1 -1
  139. package/dist/client/assets/{scroll-area-DKse0rZa.js → scroll-area-DW0-Liri.js} +1 -1
  140. package/dist/client/assets/{search-x-DvMuhABO.js → search-x-Sme5ElYi.js} +1 -1
  141. package/dist/client/assets/{shield-x-ZcQ8NB0Z.js → shield-x-Bh5xap8N.js} +1 -1
  142. package/dist/client/assets/{soul-file-B_MwZHvh.js → soul-file-NcuTUIiB.js} +1 -1
  143. package/dist/client/assets/{table-BJDpTBxJ.js → table-BEtvgYmW.js} +1 -1
  144. package/dist/client/assets/{use-connector-management-BZ-sfu8O.js → use-connector-management-Cohvs7jD.js} +1 -1
  145. package/dist/client/assets/{use-delete-binding-XWrr4lIB.js → use-delete-binding-C19umm_i.js} +1 -1
  146. package/dist/client/assets/{use-dev-links-daERqZ4e.js → use-dev-links-DRnLdl--.js} +1 -1
  147. package/dist/client/assets/{use-external-adapter-catalog-DE5zmChu.js → use-external-adapter-catalog-BOn9aj72.js} +1 -1
  148. package/dist/client/assets/use-full-activity-feed-BpQANbns.js +1 -0
  149. package/dist/client/assets/use-is-below-desktop-5LlietdR.js +1 -0
  150. package/dist/client/assets/{use-jump-back-in-Dm-2B4la.js → use-jump-back-in-CkFErfWY.js} +3 -3
  151. package/dist/client/assets/{use-mesh-topology-DXFAk9hJ.js → use-mesh-topology-CIsDeAY0.js} +1 -1
  152. package/dist/client/assets/use-panel-tab-placements-AFrWTQ0a.js +1 -0
  153. package/dist/client/assets/use-pending-read-Dol8yvIx.js +1 -0
  154. package/dist/client/assets/{use-personality-commit-CgQm9Y7m.js → use-personality-commit-fUtuc2lC.js} +1 -1
  155. package/dist/client/assets/{use-promo-activation-CZMwcIvl.js → use-promo-activation-Dxt-1yuT.js} +3 -3
  156. package/dist/client/assets/{use-pulse-freshness-CKzRoyfz.js → use-pulse-freshness-DRRM5Hza.js} +1 -1
  157. package/dist/client/assets/{use-room-follow-claim-TvE0bgPq.js → use-room-follow-claim-huRfaa4e.js} +1 -1
  158. package/dist/client/assets/{use-roving-tab-list-DlrB639e.js → use-roving-tab-list-BZIBAGgJ.js} +1 -1
  159. package/dist/client/assets/{use-session-canvas-8hTR83y8.js → use-session-canvas-CZIsr9qL.js} +4 -4
  160. package/dist/client/assets/{use-session-diagnostics-DAd4CfKM.js → use-session-diagnostics-C41hV7rK.js} +4 -4
  161. package/dist/client/assets/{use-unclaimed-chats-DKLFamqB.js → use-unclaimed-chats-BMlFQ2v1.js} +1 -1
  162. package/dist/client/index.html +2 -2
  163. package/dist/server/index.js +121995 -116004
  164. package/dist/server/index.js.map +2 -2
  165. package/package.json +8 -9
  166. package/dist/client/assets/AdapterIcon-CyEZ9jER.js +0 -1
  167. package/dist/client/assets/CanvasFileContent-C4LA1NRl.js +0 -2
  168. package/dist/client/assets/CanvasModel3dContent-BqLPKItZ.js +0 -2
  169. package/dist/client/assets/HandlePage-CjinTYw3.js +0 -1
  170. package/dist/client/assets/NamePage-D5q8YN0G.js +0 -1
  171. package/dist/client/assets/NewDirectMessageMenu-DNd6s2qQ.js +0 -1
  172. package/dist/client/assets/PhotoPage-BYtfMHJD.js +0 -1
  173. package/dist/client/assets/RuntimeSetupDialog-Bh0jopL-.js +0 -1
  174. package/dist/client/assets/SessionsPage-Zfpi_q-8.js +0 -1
  175. package/dist/client/assets/_shell-pedi36wq.js +0 -88
  176. package/dist/client/assets/_shell._home.index-8qVMuOhT.js +0 -3
  177. package/dist/client/assets/_shell._home.tasks-fGzbxCP4.js +0 -1
  178. package/dist/client/assets/_shell.channels-DwyPOJGL.js +0 -10
  179. package/dist/client/assets/_shell.connections-DQ8AztAx.js +0 -6
  180. package/dist/client/assets/_shell.marketplace-CiM3PSqV.js +0 -1
  181. package/dist/client/assets/_shell.marketplace_.sources-C5u-WJmL.js +0 -1
  182. package/dist/client/assets/_shell.session-DYCz4inz.js +0 -66
  183. package/dist/client/assets/_shell.team-DKZ4y6kn.js +0 -28
  184. package/dist/client/assets/_shell.x._extensionId-C1fzIfH4.js +0 -1
  185. package/dist/client/assets/_shell.x._extensionId_._-C1fzIfH4.js +0 -1
  186. package/dist/client/assets/index-AYHwV9IU.js +0 -1
  187. package/dist/client/assets/index-BWnfydnq.js +0 -1
  188. package/dist/client/assets/index-CGLE5zMG.js +0 -1
  189. package/dist/client/assets/index-ExcAk4pE.css +0 -1
  190. package/dist/client/assets/index-jD4A_p4E.js +0 -1
  191. package/dist/client/assets/kickoff-D-oHin9P.js +0 -3
  192. package/dist/client/assets/use-full-activity-feed-DkDB2i0G.js +0 -1
  193. package/dist/client/assets/use-is-below-desktop-B-Dt4c9S.js +0 -1
  194. package/dist/client/assets/use-pending-read-CH_0XPYp.js +0 -1
@@ -1,88 +0,0 @@
1
- var pu=Object.defineProperty;var gu=(e,t,s)=>t in e?pu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var en=(e,t,s)=>gu(e,typeof t!="symbol"?t+"":t,s);import{q9 as xu,r as l,oB as Bo,qa as bu,oA as zr,j as n,qb as yu,qc as Mi,oC as vu,ae as se,aj as ge,hE as ke,eT as ve,ef as gn,qd as _s,he as wu,qe as ju,qf as ku,af as oe,an as ce,o$ as Su,qg as Cu,a4 as Se,e8 as ms,a3 as Y,B as M,X as Te,Z as z,ic as _i,qh as Nu,F as we,at as Pi,bk as Li,b7 as hs,h2 as Re,aQ as Au,qi as zo,qj as Eu,br as Iu,kD as Fi,bV as Ce,dK as De,x as vt,iJ as Ru,iK as $i,cQ as ae,qk as Cn,hJ as rt,ql as Bi,ag as Ct,hF as zi,fe as Ur,ci as Kr,ar as Bt,qm as Uo,qn as Tu,qo as Ui,qp as Du,qq as Hr,i3 as Nn,$ as Nt,mq as Wr,e7 as _t,l as ue,k$ as An,dj as Ki,d7 as Hi,d8 as Wi,dL as qi,d9 as Ou,qr as Mu,db as Ke,dE as En,dF as In,df as At,dG as Rn,dH as Tn,C as zt,e3 as Ie,e4 as _u,qs as Gi,a9 as Ko,qt as Pu,ki as Yi,qu as Vi,qv as qr,aN as B,pS as Lu,eN as ot,kr as es,hy as Ut,qw as Fu,eJ as Ae,qx as $u,qy as Bu,bs as zu,qz as fs,V as Gr,dc as ze,h9 as We,g4 as ps,fp as gs,iA as Yr,f as Kt,b2 as Qi,nZ as Xi,qA as Ji,eM as xs,qB as Vr,e1 as Uu,aa as xn,cr as Ht,cs as Wt,ct as qt,g7 as Ne,ii as bs,l$ as Zi,qC as Ku,qD as Hu,dw as Wu,iY as ts,bl as Le,iP as bn,cV as Ze,cW as et,cX as Ve,cY as Fe,cZ as Qe,da as at,c_ as Ot,cT as qu,ah as Gu,qE as Yu,qF as ys,qG as Vu,hv as Qu,qH as Xu,dJ as je,hz as vs,gL as Ju,kf as Zu,gN as em,gO as tm,gP as nm,mS as ec,fd as ws,eG as sm,qI as rm,qJ as tc,qK as pe,qL as om,qM as nc,qN as ur,qO as sc,qP as Qr,qQ as Xr,b1 as js,qR as Jr,qS as am,qT as im,qU as cm,qV as lm,qW as dm,qX as um,qY as tn,hf as mm,hg as hm,n$ as fm,qZ as pm,b6 as gm,q_ as xm,fo as rc,bH as Mt,q$ as oc,r0 as ns,r1 as ac,r2 as bm,r3 as ym,r4 as Pt,r5 as ic,r6 as cc,r7 as yn,r8 as vm,r9 as wm,gU as lc,gV as dc,fI as uc,fJ as mc,fL as hc,ra as wt,fM as jm,eC as km,rb as vn,rc as Sm,aS as fc,rd as Cm,re as Nm,rf as Am,rg as Em,rh as Im,ri as pc,rj as ft,rk as Ue,fn as it,rl as gc,rm as Rm,Q as me,nK as Tm,L as re,R as Gt,_ as Yt,O as de,N as gt,rn as Dm,ro as xc,I as Je,nX as Om,rp as bc,rq as yc,rr as Mm,rs as _m,rt as Pm,fA as jt,fz as Lt,fB as ks,jt as Lm,fx as vc,eO as wc,ly as jc,m$ as Fm,fw as $m,ru as Bm,rv as Ho,rw as zm,rx as Ft,ry as kc,bz as Ss,h0 as Sc,rz as Um,rA as Cc,rB as Nc,rC as Km,rD as Hm,fy as Wm,aR as Zr,fC as eo,rE as qm,gf as Dn,rF as ln,rG as to,w as ss,v as Ac,rH as Gm,iL as Wo,l1 as Ym,nh as Vm,rI as Qm,rJ as Xm,bN as Jm,iC as no,iB as so,mD as Ec,mC as Ic,rK as Zm,dB as Rc,rL as Pe,kc as he,rM as qo,cR as Cs,rN as eh,j7 as Tc,rO as th,rP as nh,rQ as sh,rR as rh,rS as oh,rT as ah,rU as ih,gB as ro,rV as ch,rW as Dc,m2 as lh,g$ as Oc,rX as Mc,j8 as _c,p$ as oo,rY as dh,rZ as On,my as ao,r_ as Vt,r$ as uh,s0 as mh,s1 as hh,s2 as fh,s3 as ph,s4 as gh,s5 as xh,fD as bh,s6 as yh,jv as io,s7 as vh,mz as Pc,mB as wh,s8 as jh,s9 as Lc,sa as Fc,sb as Go,sc as Yo,sd as kh,se as Sh,sf as Ch,sg as Nh,sh as Ah,si as Eh,sj as Vo,sk as Ih,sl as Rh,sm as Th,sn as Ps,hV as Ns,hW as Dh,so as Oh,jL as Mh,e as xt,sp as _h,sq as Ph,sr as Lh,a$ as Fh,ir as $h,ss as Bh,st as zh,a_ as Uh,su as Kh,sv as Hh,ge as Qt,a0 as Wh,sw as qh,sx as rs,i4 as $c,sy as Gh,sz as Bc,sA as Yh,sB as Vh,sC as Qh,sD as zc,sE as zn,sF as Xh,sG as Jh,sH as Zh,sI as Uc,sJ as mr,sK as ef,c0 as nn,H as co,aJ as tf,oP as Kc,dd as Qo,ls as Hc,iE as lo,fa as nf,t as sf,g as rf,sL as hr,h5 as fr,gK as of,aL as uo,sM as af,kS as cf,ke as lf,mj as df,sN as uf,sO as mf,sP as hf,sQ as ff,sR as Xo,i0 as Wc,fR as pf,fS as gf,fT as xf,fU as bf,fV as yf,fW as vf,fX as wf,sS as jf,sT as pr,sU as kf,sV as Ls,sW as Sf,sX as Cf,sY as wn,sZ as Nf,s_ as Jo,kl as Af,hX as Ef,s$ as If,hi as Rf,hj as Tf,hl as Df,hm as Zo,lb as ea,l9 as Of,la as ta,t0 as Mf,t1 as _f,t2 as Pf,t3 as Lf,eU as Ff,t4 as $f,t5 as Bf,t6 as zf,k8 as qc,k9 as Gc,ka as Yc,kb as Uf,bC as Kf,t7 as Hf,t8 as Wf,t9 as Vc,ta as Qc,cA as mo,cB as ho,cC as fo,tb as qf,tc as Gf,bw as Yf,fG as Vf,td as Fs,aO as Qf,te as Xf,tf as Jf,tg as Zf,th as ep,ti as tp,tj as np,tk as sp,tl as rp,tm as op,tn as na,b3 as Xc,hk as ap,bv as ip,to as Jc,tp as cp,fq as lp,tq as sa,gJ as dp,tr as up,ts as mp,tt as hp,tu as fp,tv as pp,oT as gp,gi as xp,h as po,tw as bp,tx as yp,ty as vp,eA as wp,ho as jp,tz as kp,tA as ra,tB as Sp,tC as Cp,lc as Np,tD as Ap,tE as Ep,tF as Ip,p8 as Rp,dk as Zc,pm as Tp,tG as Dp,tH as Op,tI as Mp,pq as _p,g_ as $t,j9 as Pp,e_ as gr,e$ as xr,f0 as br,tJ as Lp,tK as Fp,f1 as yr,tL as $p,k_ as Bp,eY as zp,eZ as Up,je as Kp,jf as Hp,jg as Wp,jj as qp,jh as Gp,tM as Yp,tN as Vp,jd as Qp,jb as Xp,jc as Jp,hc as Zp,tO as el,hD as eg,tP as tg,tQ as ng,tR as tl,tS as sg,tT as As,tU as nl,ad as sl,tV as rl,tW as rg,cw as og,cx as ag,eR as oa,tX as aa,tY as ig,b8 as cg,g2 as lg,tZ as dg,kT as $s,kU as Bs,t_ as ug,t$ as mg,u0 as hg,e5 as fg,u1 as go,n as pg,lr as gg,u2 as xg,lw as bg,u3 as ol,u4 as al,u5 as il,u6 as cl,u7 as ll,u8 as yg,u9 as vg,ua as ia,ub as wg,uc as jg,ud as kg,ue as Dt,cD as Sg,uf as ca,lG as Cg,lI as dl,cU as Ng,iy as Ag,ng as Eg,l_ as Ig,ug as vr,uh as Rg,ec as Tg,h4 as Dg,lT as Ge,lV as Og,pR as Mg,nT as la,pT as _g,ui as Pg,bW as Lg,gg as Fg,uj as $g,uk as Bg,ul as zg,um as Ug,un as Kg,uo as Hg,up as Wg,kN as qg,i_ as Gg,k5 as Yg,uq as Vg,ur as Qg,us as Xg,ut as Jg,uu as Zg,uv as ex,bX as tx,uw as nx,ux as sx,mR as rx,ch as ox}from"./index-BZKMWkth.js";import{f as ax,g as ix}from"./use-connector-management-BZ-sfu8O.js";import{D as He,a as cx}from"./TourHost-DxBh58jt.js";import{O as lx,B as xo}from"./banner-D26eekSD.js";import{u as dx}from"./use-dev-links-daERqZ4e.js";import{d as ux}from"./untrusted-text-pHjcUwfI.js";import{S as mn}from"./scroll-area-DKse0rZa.js";import{T as ul,a as ml,b as Vn,c as zs,u as mx,i as hx,d as fx,P as hl}from"./PreviewRefusedNotice-CLOum_3D.js";import{P as px}from"./paperclip-CA9pcNn6.js";import{L as gx}from"./lightbulb-CxP8HLlU.js";import{i as xx,O as fl,b as bx,u as yx,a as vx}from"./OperatorIdentityForm-DtA4qIAR.js";import{b as wx,u as jx,c as kx,O as Sx,d as Cx}from"./OpenMeshSwitch-Dw8ylRP7.js";import{a as Nx}from"./use-pulse-freshness-CKzRoyfz.js";import{c as Ax,B as Ex,b as Ix,a as Rx,w as Tx,e as Dx}from"./kickoff-D-oHin9P.js";import{M as Ox,u as Mx,s as _x,P as Px,a as Lx}from"./use-promo-activation-CZMwcIvl.js";import{u as pl}from"./use-pending-read-CH_0XPYp.js";import{a as Xe}from"./dorkbot-templates-8Yu9POWJ.js";import{A as gl,P as Fx,u as $x,a as Bx}from"./use-jump-back-in-Dm-2B4la.js";import{R as zx}from"./rotate-cw-TrlUqVdq.js";import{u as Ux,a as Kx,C as Hx,N as Wx}from"./NewDirectMessageMenu-DNd6s2qQ.js";import{P as qx,C as Gx,f as Yx,a as Vx}from"./find-latest-widget-fence-Dw4BJ_cR.js";import{o as Qx}from"./owner-notice-CopwUeso.js";import{c as Xx,H as xl,a as bl,b as yl}from"./RuntimeSetupDialog-Bh0jopL-.js";import{P as Us}from"./page-container-DMx2f-Ca.js";import{u as Jx}from"./use-roving-tab-list-DlrB639e.js";import{R as Zx}from"./rotate-ccw-clock-C-ftj_rU.js";import{A as eb,M as tb}from"./McpAppFrame-DcPNmy1o.js";import{L as nb}from"./layers-BpMm7sp6.js";import{R as sb}from"./radio-B4GY45ie.js";import{a as rb}from"./sound-D3r8dGFH.js";import"./WidgetErrorCard-l8cP9oJc.js";import{u as ob}from"./use-is-below-desktop-B-Dt4c9S.js";import"./use-external-adapter-catalog-DE5zmChu.js";import"./shield-x-ZcQ8NB0Z.js";import"./use-mesh-topology-DXFAk9hJ.js";import"./use-full-activity-feed-DkDB2i0G.js";import"./card-CTGm0Blo.js";import"./markdown-content-plNIomQc.js";import"./table-BJDpTBxJ.js";import"./package-B7amjGSw.js";import"./heart-cgLUdSV5.js";import"./git-branch-D9jctpSd.js";import"./file-B6neiwXF.js";function ab({children:e,isValidProp:t,...s}){t&&xu(t);const r=l.useContext(Bo);s={...r,...s},s.transition=bu(s.transition,r.transition),s.isStatic=zr(()=>s.isStatic);const o=l.useMemo(()=>s,[JSON.stringify(s.transition),s.transformPagePoint,s.reducedMotion,s.skipAnimations]);return n.jsx(Bo.Provider,{value:o,children:e})}function ib(e){e.values.forEach(t=>t.stop())}function wr(e,t){[...t].reverse().forEach(r=>{const o=e.getVariant(r);o&&Mi(e,o),e.variantChildren&&e.variantChildren.forEach(a=>{wr(a,t)})})}function cb(e,t){if(Array.isArray(t))return wr(e,t);if(typeof t=="string")return wr(e,[t]);Mi(e,t)}function lb(){const e=new Set,t={subscribe(s){return e.add(s),()=>void e.delete(s)},start(s,r){const o=[];return e.forEach(a=>{o.push(yu(a,s,{transitionOverride:r}))}),Promise.all(o)},set(s){return e.forEach(r=>{cb(r,s)})},stop(){e.forEach(s=>{ib(s)})},mount(){return()=>{t.stop()}}};return t}function db(){const e=zr(lb);return vu(e.mount,[]),e}class ub{constructor(){this.componentControls=new Set}subscribe(t){return this.componentControls.add(t),()=>this.componentControls.delete(t)}start(t,s){this.componentControls.forEach(r=>{r.start(t.nativeEvent||t,s)})}cancel(){this.componentControls.forEach(t=>{t.cancel()})}stop(){this.componentControls.forEach(t=>{t.stop()})}}const mb=()=>new ub;function hb(){return zr(mb)}const fb="dork-labs/dorkos",pb=`https://github.com/${fb}/issues/new`,gb={"tunnel.enabled":"boolean","tasks.enabled":"boolean","relay.enabled":"boolean","scheduler.enabled":"boolean","mesh.enabled":"boolean","mcp.enabled":"boolean","telemetry.install":"boolean","telemetry.heartbeat":"boolean","telemetry.errorReporting":"boolean","auth.enabled":"boolean","workspace.enabled":"boolean","harness.autoSync":"boolean","harness.autoAdopt":"boolean","runtimes.codex.enabled":"boolean","runtimes.opencode.enabled":"boolean","runtimes.default":"enum","logging.level":"enum","ui.theme":"enum"},xb={"runtimes.default":["claude-code","codex","opencode","doe"],"logging.level":["fatal","error","warn","info","debug","trace"],"ui.theme":["light","dark","system"]},bb=/^[a-z0-9][a-z0-9._-]{0,31}$/,yb={bug:["bug"],feature:["enhancement"],runtime:["bug"]},vb={bug:"Bug: (describe what went wrong)",feature:"Feature: (describe what you want)",runtime:"Runtime issue: (describe what went wrong)"};function wb(e){return e.replace(/\b(?:sk-|pk-|rk-|ghp_|gho_|ghu_|ghs_|github_pat_|glpat-|npm_|xox[baprsc]-)[A-Za-z0-9._-]+/g,"[redacted]").replace(/\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16}\b/g,"[redacted]").replace(/\bBearer\s+[A-Za-z0-9._-]+/gi,"[redacted]")}function bo(e){return wb(e).replace(/[^\s/@]+@[^\s/@]+\.[^\s/@]+/g,"[email]").replace(/\b\d{1,3}(?:\.\d{1,3}){3}\b/g,"[ip]").replace(/\b(?:[A-Fa-f0-9]{1,4}:){2,7}[A-Fa-f0-9]{1,4}\b/g,"[ip]").replace(new RegExp("(?<![\\w:.])(?:[A-Fa-f0-9]{1,4})?(?::[A-Fa-f0-9]{0,4}){2,}(?![\\w:.])","g"),"[ip]").replace(/\\\\[^\s\\]+(?:\\[^\s\\]+)+/g,"[path]").replace(/(^|[\s"'`(<[{])\/\/[^\s"'`)>\]}/]+\/[^\s"'`)>\]}]+/g,"$1[path]").replace(/\b[A-Za-z]:\\[^\r\n]*/g,"[path]").replace(/(^|[\s"'`(<[{/:])(~|\/(?:Users|home))\/[^\s"'`)>\]}]+/g,"$1[home]").replace(/(^|[\s"'`(<[{])\/[\w.-]+(?:\/[\w.-]*)+/g,"$1[path]").replace(/\b(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{24,}\b/g,"[redacted]")}function jb(e,t){const s=xb[e];return s?s.includes(t):bb.test(t)&&bo(t)===t}function kb(e){const t={};for(const[s,r]of Object.entries(gb)){const o=e[s];o!=null&&(r==="boolean"&&typeof o=="boolean"||r==="number"&&typeof o=="number"&&Number.isFinite(o)||r==="enum"&&typeof o=="string"&&jb(s,o))&&(t[s]=o)}return t}const Sb=["details","summary"];function yo(e){return ux(bo(e),Sb)}function Cb(e){const t=e.runtimes.length>0?e.runtimes.join(", "):"none configured",s=Object.entries(e.flags).map(([o,a])=>`- ${o}: ${String(a)}`).join(`
2
- `),r=[`- DorkOS version: ${e.version}`,`- OS / arch: ${e.platform}`,`- Runtimes configured: ${t}`,`- Reported from: ${e.surface}`,"","Settings (on/off values only, no secrets or file paths):",s.length>0?s:"- (none available)"];return bo(r.join(`
3
- `))}function Nb(e){var s;const t=(s=e.body)==null?void 0:s.trim();return t?[yo(t)]:e.kind==="feature"?["## What do you want DorkOS to do?","","","## Why would it help?","",""]:["## What happened?","","","## What did you expect?","","","## Steps to reproduce","","1. ","2. ","3. "]}function Ab(e){return["<details><summary>Environment</summary>","",Cb(e),"","</details>","","DorkOS filled in the details above. Please check them and remove anything you do not want to share.","","---","",...Nb(e)].join(`
4
- `)}function Ks(e){var r;const t=(r=e.title)==null?void 0:r.trim(),s=new URLSearchParams({title:yo(t||vb[e.kind]),body:Ab(e),labels:yb[e.kind].join(",")});return`${pb}?${s.toString()}`}const Eb=6e3,da=`
5
-
6
- … (shortened to fit the link; paste the rest yourself)`;function ua(e){return new TextEncoder().encode(e).length}function ma(e,t){return Array.from(e).slice(0,t).join("")}function Ib(e,t=Eb){var d;const s=Ks(e);if(ua(s)<=t)return{url:s,truncated:!1};const r=((d=e.body)==null?void 0:d.trim())??"";if(!r)return{url:s,truncated:!1};const o=Array.from(r).length;let a=0,i=o;for(;a<i;){const m=Math.ceil((a+i)/2),u={...e,body:ma(r,m)+da};ua(Ks(u))<=t?a=m:i=m-1}const c={...e,body:ma(r,a)+da};return{url:Ks(c),truncated:!0,fullBody:yo(r)}}function Rb(e){return Ib(e).url}function Tb(e){var t,s,r,o,a,i,c,d,m,u;return{"tunnel.enabled":(t=e.tunnel)==null?void 0:t.enabled,"tasks.enabled":(s=e.tasks)==null?void 0:s.enabled,"relay.enabled":(r=e.relay)==null?void 0:r.enabled,"mesh.enabled":(o=e.mesh)==null?void 0:o.enabled,"mcp.enabled":(a=e.mcp)==null?void 0:a.enabled,"telemetry.install":(i=e.telemetry)==null?void 0:i.install,"telemetry.heartbeat":(c=e.telemetry)==null?void 0:c.heartbeat,"telemetry.errorReporting":(d=e.telemetry)==null?void 0:d.errorReporting,"auth.enabled":(m=e.auth)==null?void 0:m.enabled,"logging.level":(u=e.logging)==null?void 0:u.level}}function vl(e,t,s){return{kind:e,version:(t==null?void 0:t.version)??"unknown",platform:(t==null?void 0:t.platform)??"unknown",runtimes:(t==null?void 0:t.runtimes)??[],surface:`web ${s}`.trim(),flags:t?kb(Tb(t)):{}}}function Db(){const e=se(),{data:t}=ge({queryKey:ke.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=ve({select:r=>r.location.pathname});return l.useCallback(r=>{const o=Rb(vl(r,t,s));gn(o)},[t,s])}const Ob=100;function Mb({cwd:e,isStreaming:t,color:s}){const r=l.useRef(""),o=l.useRef([]),a=l.useRef(null),i=l.useRef(0),c=l.useRef(t);l.useEffect(()=>{c.current=t},[t]);const d=l.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),o.current.length!==0&&(i.current=0,a.current=window.setInterval(()=>{const u=o.current;u.length!==0&&(_s(u[i.current]),i.current=(i.current+1)%u.length)},Ob))},[]),m=l.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),r.current&&_s(r.current)},[]);l.useEffect(()=>{if(!e)return;const u=s??wu(e),f=ju(u);r.current=f,o.current=[],_s(f);let p=!1;return ku(f).then(h=>{p||(o.current=h,c.current&&d())}).catch(()=>{}),()=>{p=!0}},[e,s,d]),l.useEffect(()=>(t?d():m(),m),[t,d,m])}function _b(e,t){const[s,r]=l.useState(()=>document.hidden),[o,a]=l.useState(!1);l.useEffect(()=>{const d=()=>{r(document.hidden),document.hidden||a(!1)};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[]);const i=l.useRef(t);l.useEffect(()=>{i.current&&!t&&document.hidden&&a(!0),i.current=t},[t]);const c=e({hidden:s,unseenReply:o});l.useEffect(()=>{document.title=c},[c])}function Pb(){const e=oe();ce("account_usage",t=>{const s=t;!s||typeof s.runtime!="string"||e.getQueryData(Su.usage(s.runtime))!==void 0&&Cu(e,s.runtime,[s])})}function Lb(e,t,s,r){let o;switch(e){case"ArrowRight":o=t+1;break;case"ArrowLeft":o=t-1;break;case"ArrowDown":o=t+s;break;case"ArrowUp":o=t-s;break;case"Home":o=0;break;case"End":o=r-1;break;default:return null}return Math.max(0,Math.min(r-1,o))}function Fb(e){const[t,s]=l.useState(0),r=l.useRef([]);function o(){const m=r.current.slice(0,e).filter(Boolean);if(m.length===0)return 1;const u=m[0].offsetTop;return Math.max(1,m.filter(f=>f.offsetTop===u).length)}function a(m){var f;const u=Math.max(0,Math.min(e-1,m));s(u),(f=r.current[u])==null||f.focus()}function i(m){return u=>{r.current[m]=u}}function c(m){return t===m?0:-1}function d(m,u){const f=Lb(m.key,u,o(),e);f!==null&&(m.preventDefault(),a(f))}return{focusIndex:t,setRef:i,tabIndexFor:c,handleKeyDown:d,moveFocus:a}}/**
7
- * @license lucide-react v1.48.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const wl={name:"building-complex",size:24,node:[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],aliases:["building-2"]};wl.node;const $b=Se(wl);/**
12
- * @license lucide-react v1.48.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const jl={name:"camera",size:24,node:[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]};jl.node;const Bb=Se(jl);/**
17
- * @license lucide-react v1.48.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const kl={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};kl.node;const zb=Se(kl);/**
22
- * @license lucide-react v1.48.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Sl={name:"circle-plus",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],aliases:["plus-circle"]};Sl.node;const Ub=Se(Sl);/**
27
- * @license lucide-react v1.48.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Cl={name:"coffee",size:24,node:[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]};Cl.node;const Nl=Se(Cl);/**
32
- * @license lucide-react v1.48.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const Al={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]};Al.node;const Kb=Se(Al);/**
37
- * @license lucide-react v1.48.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const El={name:"copy-plus",size:24,node:[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};El.node;const Hb=Se(El);/**
42
- * @license lucide-react v1.48.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const Il={name:"crosshair",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]};Il.node;const os=Se(Il);/**
47
- * @license lucide-react v1.48.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const Rl={name:"folder-search",size:24,node:[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]};Rl.node;const Wb=Se(Rl);/**
52
- * @license lucide-react v1.48.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const Tl={name:"hard-drive",size:24,node:[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]]};Tl.node;const ha=Se(Tl);/**
57
- * @license lucide-react v1.48.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const Dl={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};Dl.node;const qb=Se(Dl);/**
62
- * @license lucide-react v1.48.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const Ol={name:"minus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}]]};Ol.node;const Gb=Se(Ol);/**
67
- * @license lucide-react v1.48.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const Ml={name:"plug",size:24,node:[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]};Ml.node;const Yb=Se(Ml);/**
72
- * @license lucide-react v1.48.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const _l={name:"square-arrow-out-up-right",size:24,node:[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],aliases:["arrow-up-right-from-square"]};_l.node;const Vb=Se(_l);/**
77
- * @license lucide-react v1.48.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */const Pl={name:"venetian-mask",size:24,node:[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]};Pl.node;const Qb=Se(Pl),fa=16,Xb=280,Jb=180;function pa(e,t,s){const r=Math.max(t,window.innerWidth-fa),o=Math.max(s,window.innerHeight-fa),a=Math.min(Math.max(e.width,t),r),i=Math.min(Math.max(e.height,s),o),c=Math.min(Math.max(e.x,0),Math.max(0,window.innerWidth-a)),d=Math.min(Math.max(e.y,0),Math.max(0,window.innerHeight-i));return{x:c,y:d,width:a,height:i}}function Zb(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function ey(e){const{title:t,geometry:s,onGeometryChange:r,onClose:o,onRestore:a,minWidth:i,minHeight:c,children:d,className:m}=e,u=l.useRef(null),f=i??Xb,p=c??Jb;l.useEffect(()=>{const y=()=>{const k=pa(s,f,p);Zb(k,s)&&r(k)};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[s,f,p,r]);const h=l.useRef(null);l.useEffect(()=>()=>{var y;return(y=h.current)==null?void 0:y.call(h)},[]);const g=l.useCallback((y,k)=>{var T;y.preventDefault();const j=u.current;if(!j)return;const A=j;(T=h.current)==null||T.call(h);const v=y.clientX,S=y.clientY,I=s;let D=I,O=0;function E(){O=0,A.style.left=`${D.x}px`,A.style.top=`${D.y}px`,A.style.width=`${D.width}px`,A.style.height=`${D.height}px`}function w(R){D=k(R.clientX-v,R.clientY-S,I),O||(O=requestAnimationFrame(E))}function C(){O&&cancelAnimationFrame(O),O=0,document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",N),document.removeEventListener("pointercancel",N),h.current=null}function N(){C(),r(pa(D,f,p))}document.addEventListener("pointermove",w),document.addEventListener("pointerup",N),document.addEventListener("pointercancel",N),h.current=C},[s,f,p,r]),x=l.useCallback(y=>{y.target.closest("button")||g(y,(k,j,A)=>({...A,x:A.x+k,y:A.y+j}))},[g]),b=l.useCallback(y=>{y.stopPropagation(),g(y,(k,j,A)=>({...A,width:Math.max(f,A.width+k),height:Math.max(p,A.height+j)}))},[g,f,p]);return ms.createPortal(n.jsxs(Y.div,{ref:u,"data-slot":"floating-panel",role:"complementary","aria-label":t,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15,ease:[0,0,.2,1]},style:{left:s.x,top:s.y,width:s.width,height:s.height},className:z("bg-card border-border shadow-floating fixed z-40 flex flex-col overflow-hidden rounded-lg border",m),children:[n.jsxs("div",{onPointerDown:x,className:"border-border flex cursor-grab items-center gap-1 border-b px-3 py-2 select-none active:cursor-grabbing",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:t}),a?n.jsx(M,{variant:"ghost",size:"icon-sm","aria-label":"Restore",onClick:a,className:"text-muted-foreground hover:text-foreground",children:n.jsx(qx,{})}):null,n.jsx(M,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:o,className:"text-muted-foreground hover:text-foreground",children:n.jsx(Te,{})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d}),n.jsx("div",{"aria-hidden":!0,onPointerDown:b,className:"absolute right-0 bottom-0 size-4 cursor-nwse-resize"})]}),document.body)}function ty({...e}){const{theme:t}=_i();return n.jsx(Nu,{theme:t,className:"toaster group",icons:{success:n.jsx(hs,{className:"size-4"}),info:n.jsx(Li,{className:"size-4"}),warning:n.jsx(Pi,{className:"size-4"}),error:n.jsx(lx,{className:"size-4"}),loading:n.jsx(we,{})},style:{"--normal-bg":"var(--color-popover)","--normal-text":"var(--color-popover-foreground)","--normal-border":"var(--color-border)","--border-radius":"var(--radius)"},...e})}async function ny(){var t;if(!Re())return;const e=(t=window.electronAPI)==null?void 0:t.getShellLogExcerpt;if(typeof e=="function")try{const s=await e();return s&&s.length>0?s:void 0}catch{return}}const Ll="root";function Fl(){return document.getElementById(Ll)??document.body}const ga=2e4;class $e extends Error{constructor(s,r){super(r);en(this,"reason");this.name="AppCaptureError",this.reason=s}}function sy(){const e=typeof window<"u"?window.electronAPI:void 0;if(typeof(e==null?void 0:e.captureAppView)!="function")return null;const{captureAppView:t}=e;return()=>t()}function ry(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function oy(){const e=[];for(const t of Array.from(document.body.children)){if(!(t instanceof HTMLElement)||t.id===Ll)continue;const s=t.style.opacity;t.style.opacity="0",e.push(()=>{t.style.opacity=s})}return()=>{for(const t of e)t()}}async function ay(e){const t=await e().catch(s=>{throw new $e("failed",`The desktop bridge threw: ${String(s)}`)});if(!t.ok)throw new $e("failed",t.message);return{dataUrl:t.dataUrl,region:{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}}async function iy(){let e;try{({snapdom:e}=await Au(()=>import("./snapdom-SRLjr6oU.js"),[]))}catch(r){const o=r instanceof Error?r.message:String(r);throw new $e("unsupported",`Loading the screenshot library failed: ${o}`)}const t=Fl(),s=getComputedStyle(document.body).backgroundColor;try{const r=t.getBoundingClientRect();return{dataUrl:(await e.toPng(t,{backgroundColor:s})).src,region:{left:r.left,top:r.top,width:r.width,height:r.height}}}catch(r){const o=r instanceof Error?r.message:String(r);throw new $e("failed",`Rendering the app to an image failed: ${o}`)}}async function cy(e){let t;const s=new Promise((r,o)=>{t=setTimeout(()=>{o(new $e("failed",`The capture did not finish in ${ga}ms.`))},ga)});try{return await Promise.race([e,s])}finally{clearTimeout(t),e.catch(()=>{})}}async function ly(){const e=sy(),t=oy();try{return await ry(),await cy(e?ay(e):iy())}finally{t()}}let sn=null;function $l(){if(sn)return sn;const e=ly();sn=e;const t=()=>{sn===e&&(sn=null)};return e.then(t,t),e}function dy(){return $l().then(e=>e.dataUrl)}function uy(){if(typeof window>"u")return;const{innerWidth:e,innerHeight:t,devicePixelRatio:s}=window;if(!(typeof e!="number"||typeof t!="number"))return{width:Math.round(e),height:Math.round(t),devicePixelRatio:typeof s=="number"?s:1}}function my(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function hy(e){const t=uy(),s=typeof navigator<"u"?navigator.userAgent:void 0,r=typeof navigator<"u"?navigator.language:void 0,o=my();return{theme:e,shell:Re()?"desktop-app":"browser",...t?{viewport:t}:{},...s?{browser:s.slice(0,Eu)}:{},...r?{locale:r.slice(0,zo)}:{},...o?{timezone:o.slice(0,zo)}:{}}}function Es(e){return t=>()=>{e(),t()}}const fy=2e3,py=.8,gy=1400,xy=.6,Qn=6e5,as=1e4,by=["image/webp","image/jpeg","image/png"],yy=/^data:image\/(webp|png|jpeg);base64,/;class kt extends Error{constructor(s,r){super(r);en(this,"reason");this.name="ImageCompressError",this.reason=s}}function vy(e){return yy.test(e)&&e.length<=Qn}function wy(e){return new Promise((t,s)=>{const r=new Image,o=setTimeout(()=>{s(new kt("unreadable",`Decoding timed out after ${as}ms.`))},as);r.onload=()=>{clearTimeout(o),t(r)},r.onerror=()=>{clearTimeout(o),s(new kt("unreadable",`Could not decode the image at ${e.slice(0,32)}…`))},r.src=e})}function jy(e,t){for(const s of by){const r=e.toDataURL(s,t);if(r.startsWith(`data:${s};base64,`))return r}throw new kt("unsupported","This canvas produced no usable image encoding.")}function xa(e,t,s=fy){const r=Math.min(1,s/Math.max(e,t));return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}function ba(e,t,s){const r=document.createElement("canvas");r.width=t.width,r.height=t.height;const o=r.getContext("2d");if(!o)throw new kt("unsupported","This browser gave no 2d canvas context.");return o.drawImage(e,0,0,t.width,t.height),jy(r,s)}async function jr(e){const t=typeof e=="string"?null:URL.createObjectURL(e);let s;try{s=await wy(t??e)}finally{t&&URL.revokeObjectURL(t)}const r=s.naturalWidth||s.width,o=s.naturalHeight||s.height;if(r<=0||o<=0)throw new kt("unreadable","The image decoded to zero pixels.");let a=ba(s,xa(r,o),py);if(a.length>Qn&&(a=ba(s,xa(r,o,gy),xy)),a.length>Qn)throw new kt("too-large",`Compressed to ${a.length} characters, over the ${Qn} cap.`);return a}const ky=500;function Sy(e=ky){const t=oe(),s=Iu({coalesceMs:e,shouldFlush:()=>t.isMutating({mutationKey:Fi})===0});ce("config_changed",()=>{const r={queryKey:ke.current()};s([r])})}const Bl="dorkbot",Cy=["mesh","agent-paths"];function Ny(e){var r,o;const t=(r=e==null?void 0:e.agents)==null?void 0:r.defaultDirectory;if(!t)return"";const s=((o=e==null?void 0:e.agents)==null?void 0:o.defaultAgent)||Bl;return`${t}/${s}`}function Ay(){var d;const e=Ce(),t=se(),{data:s}=De(),{data:r}=ge({queryKey:[...Cy],queryFn:()=>t.listMeshAgentPaths(),staleTime:3e4}),o=((d=s==null?void 0:s.agents)==null?void 0:d.defaultAgent)||Bl,a=r==null?void 0:r.agents.find(m=>m.name===o),i=(a==null?void 0:a.projectPath)??Ny(s);return{startSession:l.useCallback(()=>{a?e(vt({agentId:a.id})):i&&Ru(t,i).then(m=>e(m)).catch(m=>{$i(t,m),ae.error("Couldn’t open the chat. Try again.")})},[e,i,a,t]),defaultAgentDir:i}}function Ey(e){var t,s;return{pinned:e.pinned??[],groups:e.groups??[],muted:e.muted??[],sections:e.sections??{},gettingStarted:{retired:((t=e.gettingStarted)==null?void 0:t.retired)??[]},digest:{lastShownDate:(s=e.digest)==null?void 0:s.lastShownDate}}}function Iy(){const e=oe(),t=Cn();ce("community_connections_changed",()=>{t&&e.invalidateQueries({queryKey:rt.connections(t),exact:!0})})}function zl(e){const t=se(),s=e!==null&&e.status!=="pending",r=Cn(s),o=(e==null?void 0:e.ref)??"";return ge({queryKey:r?rt.disconnectImpact(r,o):[...rt.all,"owner","unresolved",o,"disconnect-impact"],queryFn:()=>Bi(r,()=>t.getCommunityDisconnectImpact(o)),enabled:s&&r!==null,staleTime:0,refetchOnMount:"always"})}function Ul(e){const t=e.flatMap(r=>r.displayName?[r.displayName]:[]),s=e.length-t.length;return s>0&&t.push(s===1?"an unnamed agent":`${s} unnamed agents`),t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Kl(e,t){return t.length===0?null:t.length===1?t[0].displayName?`The agent you added from here, ${t[0].displayName}, will be removed from ${e}.`:`The agent you added from here will be removed from ${e}.`:`The ${t.length} agents you added from here will be removed from ${e}: ${Ul(t)}.`}function Hl(e){return`Any agents you added from here will be removed from ${e}.`}function Wl(e,{remoteRevoked:t,agentsNotRemoved:s}){const r=Ul(s);return s.length===0?t?{tone:"success",message:`${e} is disconnected.`}:{tone:"warning",message:Ry(e)}:t?{tone:"warning",message:`Disconnected, but ${r} couldn’t be removed. Remove ${s.length===1?"it":"them"} under Agents on ${e}.`}:{tone:"warning",message:`Disconnected here, but ${e} couldn’t be reached. Remove ${r} and this DorkOS there.`}}function Ry(e){return`Disconnected here, but ${e} couldn’t be reached. Finish under Connected installations on ${e}.`}function Xt(){const e=se(),t=oe(),{data:s,isLoading:r}=ge({queryKey:ke.current(),queryFn:()=>e.getConfig(),staleTime:zi}),o=pl(r),a={completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null,completedAt:null,runtimeDefaultSetAt:null,firstRunPath:null,welcomeEntryId:null,priorRuntime:null},i=s!=null&&s.onboarding?{completedSteps:s.onboarding.completedSteps,skippedSteps:s.onboarding.skippedSteps,startedAt:s.onboarding.startedAt,dismissedAt:s.onboarding.dismissedAt,completedAt:s.onboarding.completedAt??null,runtimeDefaultSetAt:s.onboarding.runtimeDefaultSetAt,firstRunPath:s.onboarding.firstRunPath??null,welcomeEntryId:s.onboarding.welcomeEntryId??null,priorRuntime:s.onboarding.priorRuntime??null}:a,c=i.completedAt!==null,d=i.dismissedAt!==null,u=!o&&s!==void 0&&!c&&!d,f=!o&&c&&!d,p=Ct({mutationFn:b=>e.updateConfig({onboarding:b}),onSuccess:()=>{t.invalidateQueries({queryKey:ke.all})},onError:(b,y)=>{console.error("[onboarding] could not save progress",{fields:Object.keys(y),error:b}),ae.error("Couldn’t save your setup progress",{description:"Keep going. DorkOS tries again."})},meta:{suppressErrorToast:!0}});function h(){return p.mutateAsync({dismissedAt:new Date().toISOString()})}function g(){i.completedAt||p.mutate({completedAt:new Date().toISOString()})}function x(){i.startedAt||p.mutate({startedAt:new Date().toISOString()})}return{state:i,config:s,isLoading:o,isOnboardingComplete:c,isOnboardingDismissed:d,shouldShowOnboarding:u,shouldShowGettingStarted:f,dismiss:h,completeOnboarding:g,startOnboarding:x}}function Ty(e){const{shouldShowOnboarding:t,onboardingHiddenForSession:s}=e,r=t&&!s,[o,a]=l.useState(!1);return r&&!o&&a(!0),o&&!s}function Dy(){const e=Ur(),t=Bt(),s=Kr({strict:!1}).onboarding,r=Uo(s)?s:"welcome",o=l.useRef(!1),a=ve({select:m=>m.status==="idle"}),i=l.useRef(!1);l.useEffect(()=>{if(i.current||!a||(i.current=!0,Uo(s)))return;const m=u=>({...u,onboarding:"welcome"});e==null||e({search:m,replace:!0})},[a,s,e]);const c=l.useCallback(m=>{const u=f=>({...f,onboarding:m});o.current=!0,e==null||e({search:u})},[e]),d=l.useCallback(m=>{if(o.current){t.history.back();return}const u=f=>({...f,onboarding:m});e==null||e({search:u})},[t,e]);return{stage:r,goToStage:c,goBack:d}}function Oy(e){const{done:t,overlayVisible:s}=e,r=Ur(),o=Kr({strict:!1}).onboarding;l.useEffect(()=>{if(!o||!t||s)return;const a=i=>({...i,onboarding:void 0});r==null||r({search:a,replace:!0})},[o,t,s,r])}function ql(e){try{if(e.verificationUriComplete){const s=new URL(e.verificationUriComplete);if(s.protocol==="https:"||s.protocol==="http:")return s.href}const t=new URL(e.verificationUri);return t.protocol!=="https:"&&t.protocol!=="http:"?null:(t.searchParams.set("code",e.userCode),t.href)}catch{return null}}const My=2500,_y="Couldn’t finish setup. Try again.";function jn(e){return e instanceof Error&&e.message&&!/^HTTP \d+$/.test(e.message)?e.message:_y}function vo(){const e=se(),t=oe();return Ct({mutationFn:s=>e.chooseFirstRunPath(s),onSettled:()=>{for(const s of[ke.all,Tu,Ui.status()])t.invalidateQueries({queryKey:s});t.invalidateQueries({queryKey:Du})},meta:{suppressErrorToast:!0}})}function Py(e){const t=se(),{data:s}=ge({queryKey:Ui.status(),queryFn:()=>t.getCloudCredits(),enabled:e,refetchInterval:e?My:!1,refetchIntervalInBackground:e,staleTime:0});if(s)return s.readiness??(s.linked?"linked":"unlinked")}function Ly(){const e=se(),t=oe();return Ct({mutationFn:()=>e.postOnboardingWelcome(),onSettled:()=>void t.invalidateQueries({queryKey:ke.all}),meta:{suppressErrorToast:!0}})}function Fy({link:e,waitingWindowRef:t,onReady:s}){const r=vo(),[o,a]=l.useState(null),[i,c]=l.useState(!1),d=Py(i),m=i?d:void 0,u=l.useRef(e),f=l.useRef(r.mutateAsync),p=l.useRef(s);l.useEffect(()=>{u.current=e,f.current=r.mutateAsync,p.current=s});const h=l.useCallback(()=>{var j;(j=t.current)==null||j.close(),t.current=null},[t]),g=l.useCallback(async()=>{a(null);try{await f.current({path:"dorkos"})}catch(v){h(),a(jn(v));return}c(!0);const j=u.current;if(j.state==="linked"){h();return}if(j.state==="pending")return;await j.start()===null&&(h(),a(u.current.startError??"Couldn’t reach DorkOS. Try again."))},[h]),x=l.useRef(!1);l.useEffect(()=>{x.current||e.state==="loading"||(x.current=!0,g())},[e.state,g]);const b=e.state==="pending"?e.pending:null;l.useEffect(()=>{if(!b||!t.current)return;const j=ql(b);j?t.current.go(j):t.current.close(),t.current=null},[b,t]);const y=l.useRef(!1);l.useEffect(()=>{m!=="ready"||y.current||(y.current=!0,p.current())},[m]);const k=l.useCallback(()=>{var j;if((j=t.current)==null||j.close(),t.current=Hr(),u.current.state==="expired"||u.current.state==="denied"){a(null),u.current.start();return}g()},[g,t]);return{phase:$y(o,i,e,b,m),retry:k}}function $y(e,t,s,r,o){return e!==null?{kind:"failed",message:e}:o==="refused"?{kind:"refused"}:o==="needs-card"?{kind:"needs-card"}:s.state==="expired"||s.state==="denied"?{kind:"expired"}:s.state==="linked"&&t?{kind:"finishing"}:r?{kind:"waiting",pending:r}:{kind:"starting"}}function wo(){const e=l.useRef(null);return l.useEffect(()=>{var t;(t=e.current)==null||t.focus({preventScroll:!0})},[]),e}function Gl({phase:e,link:t,onRetry:s,onCancel:r,onUseOwnAi:o}){const a=wo();return n.jsxs("div",{ref:a,tabIndex:-1,className:"mx-auto flex w-full max-w-sm flex-col items-center px-4 text-center outline-none",role:"region","aria-labelledby":"onboarding-connecting-heading","data-testid":"onboarding-connecting","data-phase":e.kind,children:[n.jsx(He,{size:72,className:"mb-6 opacity-90 dark:hidden"}),n.jsx(He,{variant:"white",size:72,className:"mb-6 hidden opacity-90 dark:block"}),n.jsx(By,{phase:e,link:t,onRetry:s,onUseOwnAi:o}),n.jsx(M,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-8",onClick:r,children:"Cancel"})]})}function By({phase:e,link:t,onRetry:s,onUseOwnAi:r}){switch(e.kind){case"starting":return n.jsx(ya,{heading:"Finish in your browser.",line:"Opening the DorkOS page…"});case"waiting":return n.jsxs(n.Fragment,{children:[n.jsx(Tt,{children:"Finish in your browser."}),n.jsx(Un,{children:"Sign in, then come back. This screen moves on by itself."}),n.jsx(zy,{pending:e.pending})]});case"finishing":return n.jsx(ya,{heading:"Signed in.",line:"Getting your account ready…"});case"needs-card":return n.jsxs(n.Fragment,{children:[n.jsx(Tt,{children:"Add a card to finish."}),n.jsx(Un,{children:"Your agents start once a card is saved."}),n.jsxs(M,{className:"mt-6",onClick:()=>t==null?void 0:t.openBilling(),disabled:!t||t.billingPending,children:[(t==null?void 0:t.billingPending)&&n.jsx(we,{size:"xs"}),"Add a card"]}),(t==null?void 0:t.billingNotice)&&n.jsx(kr,{children:t.billingNotice})]});case"refused":return n.jsxs(n.Fragment,{children:[n.jsx(Tt,{children:"Paid plans are US only."}),n.jsx(Un,{children:"Use your own AI instead."}),n.jsx(M,{className:"mt-6",onClick:r,children:"Use my own AI"})]});case"expired":return n.jsxs(n.Fragment,{children:[n.jsx(Tt,{children:"Your code expired."}),n.jsx(Un,{children:"Get a new one to finish signing in."}),n.jsx(M,{className:"mt-6",onClick:s,children:"Get a new code"})]});case"failed":return n.jsxs(n.Fragment,{children:[n.jsx(Tt,{children:"Couldn’t start signing in."}),n.jsx(kr,{children:e.message}),n.jsx(M,{className:"mt-6",onClick:s,children:"Try again"})]})}}function ya({heading:e,line:t}){return n.jsxs(n.Fragment,{children:[n.jsx(Tt,{children:e}),n.jsxs("p",{className:"text-muted-foreground mt-3 flex items-center gap-2 text-sm",role:"status",children:[n.jsx(we,{size:"xs"}),t]})]})}function Tt({children:e}){return n.jsx("h1",{id:"onboarding-connecting-heading",className:"text-2xl font-semibold tracking-tight text-balance",children:e})}function Un({children:e}){return n.jsx("p",{className:"text-muted-foreground mt-3 text-sm text-balance",children:e})}function kr({children:e}){return n.jsx("p",{className:"text-destructive mt-3 text-sm text-balance",role:"alert",children:e})}function zy({pending:e}){const{copied:t,failed:s,copy:r}=Nn(),[o,a]=l.useState(!1),i=ql(e);return n.jsxs("div",{className:"mt-8 w-full space-y-4","data-testid":"onboarding-link-code",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"bg-muted min-w-0 flex-1 rounded-md px-3 py-3 text-center font-mono text-lg font-semibold tracking-[0.15em] whitespace-nowrap tabular-nums sm:text-xl",children:e.userCode}),n.jsx(M,{variant:"ghost",size:"icon-md",onClick:()=>void r(e.userCode),"aria-label":s?"Couldn’t copy code. Try again":"Copy code",children:t?n.jsx(Nt,{className:"text-status-success size-4"}):s?n.jsx(Te,{className:"text-destructive size-4"}):n.jsx(Wr,{className:"size-4"})})]}),n.jsxs(M,{variant:"outline",className:"w-full",disabled:i===null,onClick:()=>a(i===null||!gn(i)),children:[n.jsx(_t,{className:"size-4"}),"Open the page again"]}),n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:e.verificationUri}),o&&n.jsx(kr,{children:"Couldn’t open the page. Copy the code instead."}),n.jsxs("p",{className:"text-muted-foreground flex items-center justify-center gap-2 text-sm",children:[n.jsx(we,{size:"xs"}),n.jsx("span",{role:"status",children:"Waiting for you to approve."})]})]})}function Uy({onComplete:e}){const t=Ly(),{completeOnboarding:s}=Xt(),r=Ce(),[o,a]=l.useState(null),i=l.useCallback(()=>{s(),r({...ue.home(),search:{}}),e()},[s,r,e]),c=l.useCallback(async()=>{a(null);try{await t.mutateAsync()}catch(m){a(jn(m));return}i()},[t,i]),d=l.useRef(!1);return l.useEffect(()=>{d.current||(d.current=!0,c())},[c]),n.jsx("div",{className:"mx-auto flex w-full max-w-sm flex-col items-center px-4 text-center","data-testid":"onboarding-landing",children:o?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:o}),n.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[n.jsx(M,{onClick:()=>void c(),children:"Try again"}),n.jsx(M,{variant:"outline",onClick:i,children:"Go to #team"})]})]}):n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(we,{size:"xs"}),"Opening #team…"]})})}const Ky="claude-code";function Yl(e,t){return e.length===0?null:e.includes(t)?t:Ki.find(r=>e.includes(r))??e[0]}function Hy({readyTypes:e,settled:t,settleToken:s}){var b,y;const{data:r}=De(),o=An(),a=oe(),[i,c]=l.useState(null),[d,m]=l.useState(null),u=l.useRef(null),f=((b=r==null?void 0:r.executionDefaults)==null?void 0:b.runtime)??Ky,p=!!((y=r==null?void 0:r.onboarding)!=null&&y.runtimeDefaultSetAt),h=l.useCallback((k,j)=>{c(null),m(j),o.mutate(k,{onSuccess:()=>void a.invalidateQueries({queryKey:ke.all}),onError:A=>{m(null),c(A.message||"Couldn’t save that. Try again.")}})},[o,a]);l.useEffect(()=>{if(!t||e.length===0||!r||p)return;const k=Yl(e,f);k&&u.current!==s&&(u.current=s,h({onboarding:{runtimeDefaultSetAt:new Date().toISOString()},...k===f?{}:{runtimes:{default:k}}},k))},[t,s,e,r,p,f,h]);const g=l.useCallback(k=>{k!==(d??f)&&h({runtimes:{default:k},...p?{}:{onboarding:{runtimeDefaultSetAt:new Date().toISOString()}}},k)},[h,d,f,p]);return{runtime:d??((p||d!==null)&&r?f:null),current:d??f,choose:g,error:i}}function Wy({onContinue:e,renderConnect:t,simulated:s}){const r=Hi(),{data:o}=Wi(),{data:a}=qi(),i=(s==null?void 0:s.requirements)??r.data,c=s!==void 0||r.isSuccess,d=o?Object.keys(o.capabilities):void 0,m=l.useMemo(()=>Ki.filter(b=>(i==null?void 0:i.runtimes[b])!==void 0),[i]),u=l.useMemo(()=>i?m.filter(b=>Ou(i,b,!0).state==="ready"||s===void 0&&Mu(a,b)):[],[m,i,a,s]),f=Hy({readyTypes:u,settled:c&&s===void 0,settleToken:r.dataUpdatedAt}),[p,h]=l.useState(null),g=s!=null&&s.defaultRuntime?{runtime:p??s.defaultRuntime,current:p??s.defaultRuntime,choose:h,error:null}:f;if(!c)return n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(we,{size:"xs"}),"Looking for AI apps…"]});if(s===void 0&&r.isError)return n.jsxs("div",{className:"space-y-2",role:"alert",children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t check for AI apps."}),n.jsx(M,{variant:"outline",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]});const x=u.length>0;return n.jsxs("div",{className:"space-y-4","data-testid":"onboarding-ai-apps",children:[x&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm",children:Gy(u,g.runtime)}),n.jsx(qy,{chosen:g.current,readyTypes:u,otherTypes:m.filter(b=>!u.includes(b)),onChoose:g.choose}),g.error&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"default-runtime-error",children:g.error})]}),n.jsx(Xx,{types:m,requirements:i,registeredTypes:d,renderConnect:t,onRecheck:s?void 0:()=>void r.refetch(),isRechecking:r.isFetching}),x&&n.jsx(M,{className:"w-full",onClick:e,"data-testid":"onboarding-ai-app-continue",children:"Continue"})]})}function qy({chosen:e,readyTypes:t,otherTypes:s,onChoose:r}){const[o,a]=l.useState(!1),i=[...t,...s];return i.includes(e)||i.unshift(e),n.jsxs(En,{open:o,onOpenChange:a,children:[n.jsxs(In,{className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs underline-offset-2 transition-colors hover:underline","data-testid":"default-runtime-change",children:["Change",n.jsx(At,{className:"size-3"})]}),n.jsxs(Rn,{align:"start",className:"p-1",children:[n.jsx(Tn,{children:"Start new chats with"}),n.jsx("div",{className:"flex flex-col",role:"listbox","aria-label":"Start new chats with",children:i.map(c=>{const d=c===e;return n.jsxs("button",{type:"button",role:"option","aria-selected":d,onClick:()=>{r(c),a(!1)},className:"hover:bg-accent flex items-center justify-between gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors","data-testid":`default-runtime-option-${c}`,children:[n.jsxs("span",{className:"flex flex-col",children:[n.jsx("span",{children:Ke(c).label}),!t.includes(c)&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Not signed in yet"})]}),d&&n.jsx(Nt,{className:"size-3.5 shrink-0","aria-hidden":!0})]},c)})})]})]})}function Gy(e,t){const s=e.map(c=>Ke(c).label),r=s.length===1?`${s[0]} is signed in.`:s.length===2?`${s[0]} and ${s[1]} are signed in.`:`${s.slice(0,-1).join(", ")}, and ${s[s.length-1]} are signed in.`;if(!t)return r;if(e.length===1&&e[0]===t)return`${r} New chats start with it.`;const o=Ke(t).label;if(e.includes(t))return`${r} New chats start with ${o}.`;const a=Yl(e,t),i=a?Ke(a).label:null;return i?`${r} New chats use ${i} until ${o} is signed in.`:`${r} New chats start with ${o} once it’s signed in.`}const Yy=[{id:"openai",title:"An OpenAI API key",line:"Paste a key. DorkOS picks the model."},{id:"anthropic",title:"An Anthropic API key",line:"Paste a key. DorkOS picks the model."},{id:"openrouter",title:"An OpenRouter key",line:"Paste a key. DorkOS picks the model."},{id:"local",title:"A model on this computer",line:"Uses Ollama on this computer. No key."},{id:"agent-app",title:"An AI app you sign in to",line:"Claude Code, Codex or OpenCode, on your own sign-in."},{id:"custom",title:"Other service",line:"Set the address, format, model and key."}],Vy={openai:"OpenAI API key",anthropic:"Anthropic API key",openrouter:"OpenRouter key"};function Qy({onSaved:e,beforePick:t,slots:s,initialRow:r,simulatedApps:o}){const[a,i]=l.useState(r??null),c=vo(),[d,m]=l.useState(null),u=async(p,h=!1)=>{m(null);try{return await(t==null?void 0:t()),(await c.mutateAsync({path:"own",choice:p})).modelListed===!1&&ae("Using a default model. Change it in Settings."),!0}catch(g){if(h)throw new Error(jn(g),{cause:g});return m(jn(g)),!1}},f=p=>{m(null);const h=a===p?null:p;i(h),h==="agent-app"&&!o&&u({kind:"agent-app"})};return n.jsx("div",{className:"divide-border border-border w-full divide-y rounded-lg border text-left",children:Yy.map(p=>n.jsxs("section",{"data-testid":`own-ai-row-${p.id}`,children:[n.jsxs("button",{type:"button","aria-expanded":a===p.id,onClick:()=>f(p.id),className:"hover:bg-muted/60 focus-visible:ring-ring flex w-full items-center gap-3 px-4 py-3 text-left transition-colors focus-visible:ring-2 focus-visible:outline-none",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block text-sm font-medium",children:p.title}),n.jsx("span",{className:"text-muted-foreground block text-xs",children:p.line})]}),n.jsx(zt,{"aria-hidden":!0,className:z("text-muted-foreground size-4 shrink-0 transition-transform",a===p.id&&"rotate-90")})]}),a===p.id&&n.jsxs("div",{className:"px-4 pt-1 pb-4",children:[n.jsx(Xy,{row:p.id,busy:c.isPending,save:u,onSaved:e,slots:s,simulatedApps:o}),d&&n.jsx("p",{className:"text-destructive mt-3 text-sm",role:"alert",children:d})]})]},p.id))})}function Xy({row:e,busy:t,save:s,onSaved:r,slots:o,simulatedApps:a}){switch(e){case"local":return n.jsxs(M,{onClick:async()=>{await s({kind:"local"})&&r()},disabled:t,children:[t&&n.jsx(we,{size:"xs"}),"Use this computer’s model"]});case"agent-app":return n.jsx(Wy,{onContinue:r,renderConnect:o==null?void 0:o.renderRuntimeConnect,simulated:a});case"custom":return o!=null&&o.renderOtherService?o.renderOtherService({onSave:async(i,c)=>{await s({kind:"custom",inference:i,...c?{apiKey:c}:{}},!0),r()}}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"Set this up later in Settings."});default:return n.jsx(Jy,{service:e,busy:t,save:s,onSaved:r})}}function Jy({service:e,busy:t,save:s,onSaved:r}){const o=l.useId(),[a,i]=l.useState(""),[c,d]=l.useState(null),m=async u=>{u.preventDefault();const f=a.trim();if(d(null),!f){d("Enter a key.");return}if(e==="anthropic"&&f.startsWith("sk-ant-oat")){d("Subscription tokens can’t run agents. Use an API key.");return}await s({kind:e,apiKey:f})&&(i(""),r())};return n.jsxs("form",{onSubmit:u=>void m(u),className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ie,{htmlFor:`${o}-key`,children:Vy[e]}),n.jsx(_u,{id:`${o}-key`,value:a,onChange:u=>i(u.target.value),autoComplete:"off"})]}),c&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:c}),n.jsxs(M,{type:"submit",disabled:t,children:[t&&n.jsx(we,{size:"xs"}),"Save"]})]})}function Zy({onBack:e,...t}){const s=wo();return n.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col px-4","data-testid":"onboarding-own-ai",children:[n.jsx("h1",{ref:s,tabIndex:-1,className:"text-2xl font-semibold tracking-tight outline-none",children:"Use my own AI"}),n.jsx("p",{className:"text-muted-foreground mt-2 mb-6 text-sm",children:"Your agents run on a key, a local model or an AI app."}),n.jsx(Qy,{...t}),n.jsx(M,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-6 self-start",onClick:e,children:"Back"})]})}function ev({agentName:e,className:t}){var c;const s=Gi(),r=e.trim()||"This agent";if(s.isPending)return n.jsx("p",{className:z("text-muted-foreground text-center text-xs",t),"data-testid":"every-agent-access-checking",children:"Checking apps every agent can use…"});if(s.isError)return n.jsxs("p",{className:z("text-muted-foreground text-xs",t),"data-testid":"every-agent-access-unknown",children:["Couldn’t check apps shared with every agent. ",r," gets them too."]});const o=((c=s.data)==null?void 0:c.connections)??[];if(o.length===0)return null;const a=new Map;for(const d of o)a.set(d.toolkit,(a.get(d.toolkit)??0)+1);const i=o.map(d=>{const m=(a.get(d.toolkit)??0)>1?`${Ko(d.toolkit)} · ${d.label}`:Ko(d.toolkit),u=Pu(d.access.classifications);return`${m} (${d.lifecycle==="paused"?`${u}, paused`:u})`});return n.jsxs("div",{className:z("bg-muted/40 flex items-start gap-3 rounded-xl px-4 py-3 text-sm",t),"data-testid":"every-agent-access-notice",children:[n.jsx(Yi,{className:"text-muted-foreground mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("p",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"font-medium",children:[r," will get:"]})," ",i.join(", "),"."," ",n.jsx("span",{className:"text-muted-foreground",children:"You can change this in Connections."})]})]})}function tv({onContinueWithDorkos:e,onUseOwnAi:t,onContinueWithout:s,busy:r=null,error:o=null}){const a=Vi(),i=wo();return n.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center","data-testid":"onboarding-welcome",children:[n.jsx(He,{size:120,className:"mb-8 opacity-90 dark:hidden"}),n.jsx(He,{variant:"white",size:120,className:"mb-8 hidden opacity-90 dark:block"}),n.jsx("h1",{ref:i,tabIndex:-1,className:"text-3xl font-semibold tracking-tight text-balance outline-none sm:text-4xl",children:"You, Multiplied."}),n.jsx("p",{className:"text-muted-foreground mt-3 text-balance",children:"Build and run your business with an agent team."}),n.jsxs("div",{className:"mt-10 flex w-full max-w-xs flex-col items-center gap-3",children:[n.jsxs(M,{size:"lg",className:"w-full",onClick:e,disabled:r!==null,"data-testid":"onboarding-continue-dorkos",children:[r==="dorkos"&&n.jsx(we,{size:"xs"}),"Continue with DorkOS"]}),n.jsx(qr,{withSpaces:a,className:"text-balance"}),o&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:o})]}),n.jsxs("div",{className:"mt-8 flex flex-col items-center gap-1 sm:flex-row sm:gap-2",children:[n.jsx(M,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:t,disabled:r!==null,children:"Use my own AI"}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/50 hidden sm:inline",children:"·"}),n.jsxs(M,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:s,disabled:r!==null,children:[r==="none"&&n.jsx(we,{size:"xs"}),"Continue without an account"]})]})]})}function nv({onComplete:e,slots:t}){const s=t==null?void 0:t.renderAccountLink,r=o=>n.jsx(sv,{link:o,slots:t,onComplete:e});return n.jsx("div",{className:"bg-background h-full w-full overflow-y-auto",children:n.jsx("div",{className:"flex min-h-full w-full items-center justify-center p-4 py-10",children:s?s(r):r(null)})})}function sv({link:e,slots:t,onComplete:s}){var A;const{stage:r,goToStage:o,goBack:a}=Dy(),{startOnboarding:i}=Xt(),c=vo(),[d,m]=l.useState(null),u=l.useRef(null),f=l.useRef(!1);l.useEffect(()=>{f.current||(f.current=!0,i())},[i]),l.useEffect(()=>{var v;r!=="connecting"&&((v=u.current)==null||v.close(),u.current=null)},[r]);const p=l.useRef(e);l.useEffect(()=>{p.current=e});const h=l.useCallback(async()=>{var v;((v=p.current)==null?void 0:v.state)==="pending"&&await p.current.cancel()},[]),g=l.useCallback(()=>{u.current!==null||r==="connecting"||(m(null),u.current=e&&e.state!=="linked"?Hr():null,o("connecting"))},[o,e,r]),x=l.useCallback(async()=>{m(null);try{await h(),await c.mutateAsync({path:"none"}),o("landing")}catch(v){m(jn(v))}},[c,o,h]),b=l.useCallback(()=>o("landing"),[o]),y=l.useCallback(()=>o("own-ai"),[o]),k=l.useCallback(()=>a("welcome"),[a]);let j;return r==="connecting"?j=e?n.jsx(rv,{link:e,waitingWindowRef:u,onReady:b,onCancel:()=>{h(),k()},onUseOwnAi:()=>{h(),y()}}):n.jsx(Gl,{phase:{kind:"failed",message:"Signing in isn’t available here."},link:null,onRetry:k,onCancel:k,onUseOwnAi:y}):r==="own-ai"?j=n.jsx(Zy,{onBack:k,onSaved:b,beforePick:h,slots:t}):r==="landing"?j=n.jsx(Uy,{onComplete:s}):j=n.jsx(tv,{onContinueWithDorkos:g,onUseOwnAi:y,onContinueWithout:()=>void x(),busy:c.isPending&&((A=c.variables)==null?void 0:A.path)==="none"?"none":null,error:d}),j}function rv({link:e,waitingWindowRef:t,onReady:s,onCancel:r,onUseOwnAi:o}){const{phase:a,retry:i}=Fy({link:e,waitingWindowRef:t,onReady:s});return n.jsx(Gl,{phase:a,link:e,onRetry:i,onCancel:r,onUseOwnAi:o})}function ov(){const e=se(),t=B(o=>o.selectedCwd),s=B(o=>o.setSelectedCwd),{data:r}=ge({queryKey:["defaultCwd"],queryFn:()=>e.getDefaultCwd(),enabled:t===null,staleTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,networkMode:"always"});l.useEffect(()=>{r!=null&&r.path&&B.getState().selectedCwd===null&&s(r.path)},[r,t,s])}function va(e){e.invalidateQueries({queryKey:Ut.recentRoot})}function wa(e){e.invalidateQueries({queryKey:Ut.dailyCountsRoot})}function av(e,t){const s=Object.keys(e);return s.length!==Object.keys(t).length?!0:s.some(r=>!(r in t))}function iv(e,t){e.setQueryData(Ut.list(t.cwd??null),s=>{const r=s??[];return(r.some(a=>a.id===t.id)?r.map(a=>a.id===t.id?t:a):[t,...r]).sort((a,i)=>i.updatedAt.localeCompare(a.updatedAt))})}function cv(e,t,s){e.setQueryData(Ut.list(s),r=>r&&r.filter(o=>o.id!==t))}function ja(e,t,s){const r=new Set(Object.keys(t).filter(o=>!(o in s)));r.size!==0&&e.setQueriesData({queryKey:Ut.listRoot},o=>o!=null&&o.some(a=>r.has(a.id))?o.flatMap(a=>{if(!r.has(a.id))return[a];const i=t[a.id];return o.some(d=>d.id===i)?[]:[{...a,id:i}]}):o)}function ka(e,t,s){const r=Date.now(),o=[];for(const[a,i]of Object.entries(t))s[a]!==i&&(iv(e,i),o.push(i));Fu(e,o,r);for(const[a,i]of Object.entries(s))t[a]||cv(e,a,i.cwd??null)}function lv(){const e=oe();l.useEffect(()=>{Lu();let t={},s={};const r=ot.subscribe(i=>{i.sessions!==t&&(ka(e,i.sessions,t),va(e),av(i.sessions,t)&&wa(e),t=i.sessions),i.rekeys!==s&&(ja(e,i.rekeys,s),s=i.rekeys)}),o=es.subscribeEvent("session_list_invalidated",()=>{ot.getState().dropSessions(),e.invalidateQueries({queryKey:Ut.listRoot}),va(e),wa(e)}),a=ot.getState();return Object.keys(a.sessions).length>0&&(ka(e,a.sessions,t),t=a.sessions),Object.keys(a.rekeys).length>0&&(ja(e,a.rekeys,s),s=a.rekeys),es.connectList(),()=>{r(),o()}},[e])}function dv(){var m;const e=se(),t=oe(),{data:s}=ge({queryKey:ke.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),r=((m=s==null?void 0:s.mesh)==null?void 0:m.scanRoots)??[],o=(s==null?void 0:s.boundary)??"",a=r.length>0?r:o?[o]:[],{mutate:i,isPending:c}=Ct({mutationKey:Fi,mutationFn:async u=>{await e.updateConfig({mesh:{scanRoots:u}})},onSuccess:()=>{t.invalidateQueries({queryKey:ke.all})}}),d=l.useCallback(u=>i(u),[i]);return{roots:a,boundary:o,isSaving:c,setScanRoots:d}}const uv=50,rn=["room_created","room_updated","room_member_added","room_member_removed","room_activity"];function Sa(e){if(typeof e!="object"||e===null)return!1;const{roomId:t}=e;return typeof t=="string"&&t.length>0}function mv(e){if(typeof e!="object"||e===null)return!1;const{userId:t,threadKind:s,threadId:r,lastReadSeq:o,unreadCount:a}=e;return s==="room"&&typeof t=="string"&&t.length>0&&typeof r=="string"&&r.length>0&&typeof o=="number"&&typeof a=="number"}function hv(e,t){const s=e.getQueryData(Ae.detail(t.threadId));return s===void 0||s.viewerAuthorId===t.userId}function fv(e,t){const s=e.isFetching({queryKey:Ae.lists()})>0;e.cancelQueries({queryKey:Ae.lists()}),e.setQueriesData({queryKey:Ae.lists()},o=>Array.isArray(o)?o.map(a=>a.id===t.threadId&&a.unreadCount!==null?{...a,unreadCount:Math.min(a.unreadCount,t.unreadCount)}:a):o),e.setQueryData(Ae.detail(t.threadId),o=>o&&{...o,members:o.members.map(a=>a.authorId===t.userId?{...a,lastReadSeq:Math.max(a.lastReadSeq,t.lastReadSeq)}:a)});const r=e.getQueryData(Ae.threads());r!=null&&r.some(o=>o.roomId===t.threadId&&o.unreadCount>0)&&e.invalidateQueries({queryKey:Ae.threads()}),s&&e.invalidateQueries({queryKey:Ae.lists()})}function pv(){const e=oe(),t=()=>{e.invalidateQueries({queryKey:Ae.lists()}),e.invalidateQueries({queryKey:Ae.wellKnowns()}),e.invalidateQueries({queryKey:Ae.threads()})};ce(rn[0],t),ce(rn[1],t),ce(rn[2],t),ce(rn[3],t),ce(rn[4],t),ce("room_updated",o=>{Sa(o)&&e.invalidateQueries({queryKey:Ae.detail(o.roomId)})});const s=l.useRef(new Set),r=o=>{if(!Sa(o))return;const a=s.current;if(a.has(o.roomId))return;a.add(o.roomId);const i=o.roomId;setTimeout(()=>{a.delete(i),e.invalidateQueries({queryKey:Ae.detail(i)})},uv)};ce("room_member_added",r),ce("room_member_removed",r),ce("room_presence",o=>$u.getState().observe(o)),ce("read_cursor",o=>{!mv(o)||!hv(e,o)||fv(e,o)})}function gv(){const e=oe();ce("tasks_changed",()=>{e.invalidateQueries({queryKey:[...Bu],exact:!0})});const t=()=>{e.invalidateQueries({queryKey:[...zu]})};ce("task_run_failed",t),ce("task_run_updated",t)}function xv(e){const t=new Set,s=[],r=[];for(const o of e){if(o.status==="running"){s.includes(o.scheduleId)||s.push(o.scheduleId),t.add(o.scheduleId);continue}t.has(o.scheduleId)||(t.add(o.scheduleId),(o.status==="failed"||o.status==="blocked")&&r.push(o.scheduleId))}return{running:s,failed:r}}const bv=4e3;function Vl(){var o;const e=Gr(),{identityPromptDismissedAt:t,isLoading:s}=fs();if(s||e.isPending)return"pending";if(t!==null)return"settled";const r=(o=e.data)==null?void 0:o.members.find(a=>a.isSelf);return r&&xx(r)?"ask":"settled"}function yv(){const{state:e,isLoading:t,shouldShowGettingStarted:s}=Xt(),r=Vl(),{dismissIdentityPrompt:o}=fs(),[a,i]=l.useState("ask");l.useEffect(()=>{if(a!=="saved")return;const u=setTimeout(()=>i("done"),bv);return()=>clearTimeout(u)},[a]);const c=e.completedAt!==null||e.dismissedAt!==null,d=!t&&c&&r==="ask"&&!s,m=()=>{o().catch(()=>{})};return{visible:a!=="done"&&(d||a==="saved"),phase:a,markSaved:()=>{i("saved"),m()},skip:()=>{i("done"),m()}}}const vv=4e3,Hs="Tell DorkBot your name",Ca="Tell DorkBot about your work";function wv({onDismiss:e}){const t=ze(),s=Ce(),{open:r}=We(),o=ps(),a=B(D=>D.requestTour),{startSession:i}=Ay(),{roles:c,rolePromptDismissedAt:d,isLoading:m,saveRoles:u,dismissIdentityPrompt:f}=fs(),p=Vl(),[h,g]=l.useState("closed"),[x,b]=l.useState("closed"),[y,k]=l.useState([]),j=!m&&c.length===0&&d===null;l.useEffect(()=>{if(h!=="saved")return;const D=setTimeout(()=>g("closed"),vv);return()=>clearTimeout(D)},[h]);const A=()=>{g("saved"),f().catch(()=>{})},v=()=>{b("saving"),u(y).then(()=>b("closed")).catch(()=>b("error"))};let S="Save";x==="saving"?S="Saving…":x==="error"&&(S="Try again");const I=[{icon:gs,label:"Talk to DorkBot",onClick:i},...p==="ask"||h==="saved"?[{icon:gl,label:Hs,onClick:()=>g(D=>D==="saved"?D:D==="closed"?"open":"closed"),expanded:h!=="closed"}]:[],...j?[{icon:Yr,label:Ca,onClick:()=>b(D=>D==="closed"?"open":"closed"),expanded:x!=="closed"}]:[],{icon:Kb,label:"Show me around",onClick:()=>a("general")},{icon:Kt,label:"Create an agent",onClick:()=>xs.getState().open("new")},{icon:Qi,label:"Schedule a task",onClick:()=>s({...ue.tasks()})},{icon:Xi,label:"Connect more runtimes",onClick:()=>r("runtimes")},{icon:Yb,label:"Connect a service",onClick:()=>o()}];return n.jsxs(Y.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"border-border bg-card relative rounded-lg border p-3",children:[n.jsx("button",{onClick:e,className:"text-muted-foreground/50 hover:text-muted-foreground absolute top-1.5 right-1.5 rounded-md p-0.5 transition-colors duration-150","aria-label":"Dismiss getting started",children:n.jsx(Te,{className:"size-3.5"})}),n.jsx("h3",{className:"mb-2 text-xs font-medium",children:"Getting started"}),n.jsx("ul",{className:"space-y-0.5",children:I.map(({icon:D,label:O,onClick:E,expanded:w})=>n.jsxs("li",{children:[n.jsxs("button",{onClick:E,className:"hover:bg-accent group flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-left transition-colors duration-150","aria-expanded":w,children:[n.jsx(D,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("span",{className:"text-foreground flex-1 text-xs",children:O}),n.jsx(zt,{className:"text-muted-foreground/40 group-hover:text-muted-foreground size-3.5 shrink-0 transition-colors"})]}),O===Hs&&h==="open"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-identity-form",children:n.jsx(fl,{onSaved:A})}),O===Hs&&h==="saved"&&n.jsx("p",{role:"status",className:"text-muted-foreground px-1.5 py-2 text-xs",children:Xe.identityCardSaved}),O===Ca&&x!=="closed"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-profile-picker",children:n.jsx(Ji,{selected:y,onChange:k,onConfirm:v,confirmLabel:S,busy:x==="saving",error:x==="error"?Xe.saveError:null})})]},O))})]})}const jv="pl-12";function kv({prompt:e}){const t=ze(),{open:s}=We(),{phase:r,selected:o,setSelected:a,confirmLabel:i,errorMessage:c}=e;return n.jsxs(Y.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},role:"group","aria-label":"DorkBot suggestion","data-testid":"profile-prompt-card",className:"bg-secondary/60 flex flex-col gap-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("span",{className:"mt-0.5 shrink-0",children:[n.jsx(He,{size:40,className:"dark:hidden"}),n.jsx(He,{variant:"white",size:40,className:"hidden dark:block"})]}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("p",{className:"text-sm leading-relaxed",children:r==="saved"?Xe.profileSaved:Xe.profileCardPrompt[0]}),n.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:[Xe.profileCardPrompt[1]," ",n.jsx("button",{type:"button",onClick:()=>s("profile"),className:"focus-visible:ring-ring hover:text-foreground rounded-sm underline underline-offset-2 focus-visible:ring-2 focus-visible:outline-none",children:"Change it in Settings"}),"."]})]})]}),r!=="saved"&&n.jsx("div",{className:jv,children:n.jsx(Ji,{selected:o,onChange:a,onConfirm:e.save,confirmLabel:i,onSkip:e.skip,skipLabel:"Don’t ask again",busy:r==="saving",error:c})})]})}const Sv=4e3;function Cv(){const{state:e,isLoading:t,shouldShowGettingStarted:s}=Xt(),{roles:r,rolePromptDismissedAt:o,isLoading:a,saveRoles:i,dismissRolePrompt:c}=fs(),[d,m]=l.useState([]),[u,f]=l.useState("ask");l.useEffect(()=>{if(u!=="saved")return;const b=setTimeout(()=>f("done"),Sv);return()=>clearTimeout(b)},[u]);const p=e.completedAt!==null||e.dismissedAt!==null,h=!e.completedSteps.includes("profile")&&!e.skippedSteps.includes("profile"),g=!t&&!a&&p&&r.length===0&&h&&o===null&&!s;let x="Save";return u==="saving"?x="Saving…":u==="error"&&(x="Try again"),{visible:u!=="done"&&(g||u==="saved"),phase:u,selected:d,setSelected:m,confirmLabel:x,errorMessage:u==="error"?Xe.saveError:null,save:()=>{f("saving"),i(d).then(()=>f("saved")).catch(()=>f("error"))},skip:()=>{f("done"),c().catch(()=>{})}}}function Nv({prompt:e}){const t=ze(),s=e.phase==="saved";return n.jsxs(Y.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},role:"group","aria-label":"DorkBot suggestion","data-testid":"identity-prompt-card",className:"bg-secondary/60 flex flex-col gap-3 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("span",{className:"mt-0.5 shrink-0",children:[n.jsx(He,{size:40,className:"dark:hidden"}),n.jsx(He,{variant:"white",size:40,className:"hidden dark:block"})]}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("p",{className:"text-sm leading-relaxed",role:s?"status":void 0,children:s?Xe.identityCardSaved:Xe.identityCardPrompt[0]}),!s&&n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:Xe.identityCardPrompt[1]})]})]}),!s&&n.jsx(fl,{onSaved:e.markSaved,onSkip:e.skip,skipLabel:"Don’t ask again"})]})}function Av(){const e=se(),t=l.useRef(null),{startScan:s,addCandidate:r,addExistingAgent:o,setProgress:a,completeScan:i,setError:c}=Vr(),d=l.useCallback((u={roots:[]})=>{var p;(p=t.current)==null||p.abort();const f=new AbortController;t.current=f,s(),e.scan(u,h=>{switch(h.type){case"candidate":r(h.data);break;case"existing-agent":o(h.data);break;case"progress":a(h.data);break;case"complete":i(h.data);break;case"error":c(h.data.error);break}},f.signal).catch(h=>{h instanceof Error&&h.name!=="AbortError"&&c(h.message)})},[e,s,r,o,a,i,c]),m=l.useCallback(()=>{var u;(u=t.current)==null||u.abort(),t.current=null},[]);return{startScan:d,stopScan:m}}function Ev(){const[e,t]=l.useState(new Set),s=l.useCallback(o=>{t(a=>new Set(a).add(o))},[]),r=l.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:s,resetActed:r}}function Iv({register:e,onSuccess:t}){const s=l.useRef(new Set),[r,o]=l.useState(new Set),[a,i]=l.useState(new Set),c=l.useCallback(async m=>{if(!s.current.has(m.path)){s.current.add(m.path),o(u=>new Set(u).add(m.path)),i(u=>{const f=new Set(u);return f.delete(m.path),f});try{await e(m),t(m)}catch{i(u=>new Set(u).add(m.path))}finally{s.current.delete(m.path),o(u=>{const f=new Set(u);return f.delete(m.path),f})}}},[t,e]),d=l.useCallback(()=>i(new Set),[]);return{failedPaths:a,pendingPaths:r,registerCandidate:c,resetFailures:d}}function Rv(e){return{name:e.hints.suggestedName,runtime:e.hints.detectedRuntime,...e.hints.inferredCapabilities?{capabilities:e.hints.inferredCapabilities}:{},...e.hints.description?{description:e.hints.description}:{}}}function Tv(e){return[...e].sort((t,s)=>{const r=t.strategy==="dork-manifest",o=s.strategy==="dork-manifest";return r!==o?r?-1:1:t.path.localeCompare(s.path)})}const Dv={"claude-code":"Has an AGENTS.md file, so it’s a Claude Code project.",cursor:"Has a .cursor folder, so it’s a Cursor project.",codex:"Has a .codex folder, so it’s a Codex project.","dork-manifest":"Has a .dork/agent.json file, so it’s already a DorkOS agent."};function Ov(e){return Dv[e]??`Found by the “${e}” check.`}const Mv={"code-review":"Reviews code for bugs, style issues, and correctness.",summarize:"Summarizes documents, chats, or code.","file-ops":"Reads and writes files on the filesystem.",test:"Generates and runs tests for a codebase.",search:"Searches code, files, or the web for relevant information.",refactor:"Refactors code while preserving existing behavior.",analyze:"Analyzes data, logs, or codebases for patterns and insights.",generate:"Generates code, content, or structured output.",debug:"Diagnoses and fixes bugs in code.",deploy:"Manages deployment pipelines and infrastructure changes."};function _v(e){return Mv[e]??"Found in the project’s files."}function Pv({candidate:e,onApprove:t,onDeny:s,onSkip:r,registrationFailed:o=!1,registrationPending:a=!1,className:i,ref:c}){const{path:d,strategy:m,hints:u}=e;return n.jsxs(Y.div,{ref:c,"data-slot":"candidate-card","aria-busy":a,layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:z("flex items-start justify-between rounded-xl border p-4",i),children:[n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("p",{className:"truncate text-sm leading-tight font-semibold",title:u.suggestedName||d.split("/").pop()||d,children:u.suggestedName||d.split("/").pop()||d}),n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(Uu,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",title:d,children:d})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(xl,{openDelay:300,children:[n.jsx(bl,{asChild:!0,children:n.jsx(xn,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default",children:u.detectedRuntime})}),n.jsxs(yl,{className:"w-56 space-y-1.5 p-3",side:"top",align:"start",children:[n.jsx("p",{className:"text-xs font-medium",children:"How DorkOS knows"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:Ov(m)})]})]}),u.inferredCapabilities&&u.inferredCapabilities.length>0&&u.inferredCapabilities.map(f=>n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:n.jsx(xn,{size:"xs",variant:"outline",className:"cursor-default",children:f})}),n.jsx(qt,{side:"top",className:"max-w-48 text-center",children:_v(f)})]},f))]}),o&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t add this project. Try again."})]}),n.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[n.jsx("button",{type:"button",onClick:()=>t(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-green-400",children:a?"Adding…":o?"Try again":"Add"}),r&&n.jsx("button",{type:"button",onClick:()=>r(e),disabled:a,className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:"Skip"}),s&&n.jsx("button",{type:"button",onClick:()=>s(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-red-400",children:"Deny"})]})]})}function Lv({agent:e}){return n.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border px-4 py-3",children:[n.jsx(hs,{className:"text-muted-foreground size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:Ne(e)}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:e.path})]}),n.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:"Imported"})]})}const Fv=2;function $v({agents:e}){const[t,s]=l.useState(e.length<=Fv);return e.length===0?null:n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>s(r=>!r),className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1.5 py-1.5 text-xs transition-colors",children:[n.jsx(zt,{className:z("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&n.jsx("div",{className:"mt-2 space-y-2",children:e.map(r=>n.jsx(Lv,{agent:r},r.path))})]})}function Bv({count:e,onAddAll:t,disabled:s}){return e===0?null:n.jsxs("div",{className:"flex items-center justify-between py-1",children:[n.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),n.jsx(M,{variant:"outline",size:"sm",onClick:t,disabled:s,children:"Add all"})]})}function zv({roots:e,onChange:t}){const[s,r]=l.useState(""),[o,a]=l.useState(!1),i=l.useCallback(u=>{const f=u.trim();f&&!e.includes(f)&&t([...e,f])},[e,t]),c=l.useCallback(u=>{t(e.filter(f=>f!==u))},[e,t]),d=l.useCallback(u=>{(u.key==="Enter"||u.key===",")&&(u.preventDefault(),s.trim()&&(i(s),r(""))),u.key==="Backspace"&&s===""&&e.length>0&&c(e[e.length-1])},[s,e,i,c]),m=l.useCallback(u=>{i(u)},[i]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"focus-within:ring-ring flex min-h-[40px] flex-wrap items-center gap-1.5 rounded-md border bg-transparent px-3 py-1.5 focus-within:ring-2",children:[e.map(u=>n.jsxs(xn,{variant:"secondary",className:"gap-1 py-0.5 font-mono",children:[u,n.jsx("button",{type:"button",onClick:()=>c(u),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${u}`,children:n.jsx(Te,{className:"size-3"})})]},u)),n.jsx("input",{type:"text",value:s,onChange:u=>r(u.target.value),onKeyDown:d,placeholder:e.length===0?"Type a folder, then press Enter":"Add more…",className:"placeholder:text-muted-foreground min-w-[120px] flex-1 bg-transparent text-sm focus-visible:outline-none"}),n.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-muted-foreground hover:bg-accent hover:text-foreground shrink-0 rounded p-1","aria-label":"Browse for a folder",children:n.jsx(bs,{className:"size-4"})})]}),n.jsx(Zi,{open:o,onOpenChange:a,onSelect:m})]})}function Uv(e,t){let s;for(const r of t){const o=r.endsWith("/")?r.slice(0,-1):r;(e===o||e.startsWith(o+"/"))&&(!s||o.length>s.length)&&(s=o)}return s}function Kv(){return n.jsxs("svg",{viewBox:"0 0 240 120",className:"mx-auto h-24 w-48","aria-hidden":"true",children:[n.jsx("path",{d:"M15 25 L33 25 L37 33 L60 33 L60 77 L15 77 Z",className:"fill-none stroke-current",strokeWidth:"1.5"}),n.jsx("rect",{x:"23",y:"44",width:"16",height:"2",rx:"1",className:"fill-current opacity-40"}),n.jsx("rect",{x:"23",y:"50",width:"26",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("rect",{x:"23",y:"56",width:"20",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("path",{d:"M180 25 L198 25 L202 33 L225 33 L225 77 L180 77 Z",className:"fill-none stroke-current",strokeWidth:"1.5"}),n.jsx("rect",{x:"188",y:"44",width:"20",height:"2",rx:"1",className:"fill-current opacity-40"}),n.jsx("rect",{x:"188",y:"50",width:"14",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("rect",{x:"188",y:"56",width:"24",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("circle",{cx:"120",cy:"48",r:"18",className:"fill-none stroke-current",strokeWidth:"2"}),n.jsx("line",{x1:"133",y1:"61",x2:"148",y2:"76",className:"stroke-current",strokeWidth:"3",strokeLinecap:"round"}),n.jsx("path",{d:"M110 38 Q114 33 120 32",className:"fill-none stroke-current opacity-30",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("line",{x1:"63",y1:"55",x2:"102",y2:"50",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"}),n.jsx("line",{x1:"138",y1:"50",x2:"177",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"})]})}const Hv=[{name:"claude-code",signal:"AGENTS.md",label:"Claude Code project"},{name:"cursor",signal:".cursor/",label:"Cursor project"},{name:"codex",signal:".codex/",label:"Codex project"},{name:"dork",signal:".dork/agent.json",label:"DorkOS agent (auto-imported)"}];function Wv({fullBleed:e=!1,onRegistered:t}){var F;const{roots:s,setScanRoots:r}=dv(),[o,a]=l.useState(null),[i,c]=l.useState(!1),[d,m]=l.useState(3),{startScan:u}=Av(),{candidates:f,existingAgents:p,isScanning:h,progress:g,error:x,lastScanAt:b}=Vr(),{mutateAsync:y}=Ku(),{mutate:k}=Hu(),{data:j}=Wu(),{actedPaths:A,markActed:v,resetActed:S}=Ev(),I=o??s,D=l.useCallback(L=>y({path:L.path,overrides:Rv(L),scanRoot:Uv(L.path,I)}),[I,y]),O=l.useCallback(L=>{v(L.path),t==null||t()},[v,t]),{failedPaths:E,pendingPaths:w,registerCandidate:C,resetFailures:N}=Iv({register:D,onSuccess:O});function T(L){a(L),r(L)}function R(){I.length>0&&(S(),N(),u({roots:I,maxDepth:d}))}const P=l.useMemo(()=>h?f:Tv(f),[f,h]).filter(L=>!A.has(L.path)),U=(((F=j==null?void 0:j.agents)==null?void 0:F.length)??0)>0,H=p.length>0,ne=f.length>0,te=H||ne,q=!h&&b!==null,G=!h&&b===null;function ee(){for(const L of P)C(L)}const V=n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>c(!i),className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs",children:[n.jsx(At,{className:`size-3 transition-transform ${i?"":"-rotate-90"}`}),"Advanced"]}),i&&n.jsxs("div",{className:"bg-muted/30 mt-2 space-y-3 rounded-lg border p-3",children:[n.jsx(zv,{roots:I,onChange:T}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{htmlFor:"scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),n.jsx("input",{id:"scan-depth",type:"range",min:1,max:5,value:d,onChange:L=>m(Number(L.target.value)),className:"flex-1"}),n.jsx("span",{className:"min-w-[1.5rem] text-center text-xs font-medium",children:d})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("p",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[n.jsx(Wb,{className:"size-3"}),"What it looks for"]}),n.jsx("ul",{className:"space-y-1 pl-4",children:Hv.map(L=>n.jsxs("li",{className:"flex items-baseline gap-1.5",children:[n.jsx("code",{className:"text-foreground/70 text-3xs",children:L.signal}),n.jsxs("span",{className:"text-muted-foreground text-3xs",children:["→ ",L.label]})]},L.name))})]})]})]});return n.jsx("div",{className:e?"flex h-full flex-col p-6":"space-y-4 p-4",children:G?n.jsx("div",{className:e?"flex flex-1 items-center justify-center":"",children:n.jsxs("div",{className:e?"w-full max-w-sm space-y-5":"space-y-5",children:[n.jsx(Kv,{}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-foreground text-sm font-medium",children:"Find your existing projects"}),n.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[300px] text-xs leading-relaxed",children:"Find Claude Code, Cursor, Codex and other AI projects on this computer."})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive rounded-lg border px-4 py-3 text-sm",children:x}),n.jsxs(M,{onClick:R,disabled:I.length===0,className:"w-full",children:[n.jsx(ts,{className:"size-4"}),"Search for projects"]}),n.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Read-only scan. Nothing changes until you approve"}),V]})}):n.jsxs(n.Fragment,{children:[e&&n.jsxs("div",{className:"mb-4 space-y-1",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Bring in existing projects"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Search for existing projects to bring into DorkOS."})]}),n.jsxs("div",{className:"space-y-3",children:[V,n.jsxs(M,{onClick:R,disabled:h||I.length===0,children:[h?n.jsx(we,{}):n.jsx(ts,{className:"size-4"}),"Search for projects"]})]}),n.jsxs("div",{className:e?"mt-4 flex-1 overflow-y-auto":"",children:[h&&n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[n.jsx(we,{size:"md",className:"text-muted-foreground",label:"Searching for projects"}),g&&n.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-center text-xs",children:[n.jsxs("p",{children:["Scanned ",g.scannedDirs," directories"]}),n.jsxs("p",{children:["Found ",g.foundAgents," project",g.foundAgents===1?"":"s"]})]})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mb-3 rounded-lg border px-4 py-3 text-sm",children:x}),q&&!ne&&H&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:"All projects already added"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"See them on the Agents tab."})]}),q&&!te&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:U?"No new projects found":"No projects found"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:U?"They’re already added. See the Agents tab.":"Try a deeper scan or other folders."})]}),q&&P.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Bv,{count:P.length,onAddAll:ee,disabled:w.size>0}),n.jsx(Le,{mode:"popLayout",children:P.map(L=>n.jsx(Pv,{candidate:L,className:"mb-2",registrationFailed:E.has(L.path),registrationPending:w.has(L.path),onApprove:J=>void C(J),onSkip:J=>v(J.path),onDeny:J=>k({path:J.path},{onSuccess:()=>v(J.path)})},L.path))})]}),q&&H&&n.jsx("div",{className:"mt-3",children:n.jsx($v,{agents:p})})]})]})})}function qv(){const e=bn(p=>p.isOpen),t=bn(p=>p.close),s=Ce(),[r,o]=l.useState(0),[a,i]=l.useState(!1),[c,d]=l.useState(!1);e!==c&&(d(e),e&&(o(0),i(!1)));function m(p){p||t()}function u(){if(r>0&&!a){i(!0);return}t(),r>0&&s({...ue.team()})}const f=`${r} project${r===1?"":"s"} joined`;return n.jsx(Ze,{open:e,onOpenChange:m,children:n.jsxs(et,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:[n.jsxs(Ve,{className:"shrink-0",children:[n.jsx(Fe,{children:"Bring in existing projects"}),n.jsx(Qe,{children:a?"Your projects are ready in DorkOS.":"Find projects on this computer to add."})]}),a?n.jsx(at,{className:"mt-2",children:n.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-10 text-center","data-testid":"import-complete",children:[n.jsx(hs,{className:"text-primary size-12","aria-hidden":!0}),n.jsx("p",{className:"text-lg font-semibold","data-testid":"import-joined-summary",children:f}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage agents, tasks and chat apps from the Team page."})]})}):n.jsx(at,{className:"mt-2 overflow-y-auto",children:n.jsx(Wv,{onRegistered:()=>o(p=>p+1)})}),n.jsxs(Ot,{className:"shrink-0 sm:justify-between",children:[!a&&r>0?n.jsx("span",{className:"text-muted-foreground text-sm","data-testid":"import-joined-count",children:f}):n.jsx("span",{}),n.jsx(M,{onClick:u,"data-testid":"import-done",children:"Done"})]})]})})}function Gv(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.name=="string"&&(t.scope==="global"||t.scope==="project")&&typeof t.at=="string"&&Array.isArray(t.actions)&&(t.errors===void 0||Array.isArray(t.errors)&&t.errors.every(s=>typeof s=="string"))}function Yv(){const e=qu(s=>s.record),t=dx();ce("marketplace_dev_link_reloaded",s=>{Gv(s)&&(e(s),t())})}function Vv(){const e=oe();ce("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...Gu]})})}class Qv extends l.Component{constructor(){super(...arguments);en(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(s,r){console.error("[RightPanel] Tab component error:",s,r)}componentDidUpdate(s){s.tabId!==this.props.tabId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?n.jsx("div",{className:"flex h-full items-center justify-center p-4",children:n.jsx("p",{className:"text-muted-foreground text-sm",children:"This panel stopped working. Switch tabs to try again."})}):this.props.children}}const Xv={canvas:"canvas",browser:"browser"};function Jv(e,t){return t==="attention"?`${e}, something needs you`:e}function Zv({contributionId:e}){const t=Xv[e],s=B(o=>{var i;const a=o.roomCanvasLiveRoomId;return a===null||t===void 0?!1:(((i=o.roomCanvasUnread[a])==null?void 0:i[t].length)??0)>0});return Yu(e)==="attention"?n.jsx("span",{"data-slot":"right-panel-tab-marker","aria-hidden":!0,className:"bg-status-warning-dot size-1.5 shrink-0 rounded-full"}):s?n.jsx("span",{"data-slot":"right-panel-tab-unread","aria-hidden":!0,className:"bg-primary size-1.5 shrink-0 rounded-full"}):null}const Ql="right-panel-content";function Sr(e){return`right-panel-tab-${e}`}function ew({contributions:e,actions:t}){const s=B(a=>a.setRightPanelOpen),r=B(a=>a.activeRightPanelTab),o=B(a=>a.setActiveRightPanelTab);return n.jsxs("div",{className:"flex w-full items-center justify-between border-b px-3 py-2","data-slot":"right-panel-header",children:[e.length>1?n.jsx(tw,{contributions:e,activeTab:r,onActivate:o}):e.length===1?n.jsxs("div",{className:"text-foreground flex items-center gap-1.5 px-1 text-xs font-medium",children:[n.jsx(ys,{icon:e[0].icon,className:"text-muted-foreground size-3.5"}),n.jsx("span",{children:e[0].title})]}):n.jsx("div",{}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:[t,n.jsx(M,{variant:"ghost",size:"icon-md","aria-label":"Close panel",className:"size-7 shrink-0",onClick:()=>s(!1),children:n.jsx(Te,{className:"size-3.5"})})]})]})}function tw({contributions:e,activeTab:t,onActivate:s}){const r=l.useRef(null),o=l.useRef(null),a=Vu(u=>u.tabMarkers),i=Qu(r,"horizontal"),c=l.useCallback(()=>{const u=r.current;return!u||!t?null:u.querySelector(`#${CSS.escape(Sr(t))}`)},[t]),d=l.useCallback(()=>{const u=r.current,f=c();!u||!f||Xu(u,f)},[c]),m=e.map(u=>u.id).join(",");return l.useEffect(()=>{if(d(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(d);for(const f of[r.current,o.current,c()])f&&u.observe(f);return()=>u.disconnect()},[d,c,m]),n.jsx(ul,{asChild:!0,value:t??"",onValueChange:s,children:n.jsxs("div",{className:"relative min-w-0 flex-1",children:[n.jsx("div",{ref:r,onScroll:i.onScroll,className:"-my-1 overflow-x-auto overflow-y-hidden py-1",children:n.jsx(ml,{ref:o,responsive:!1,"aria-label":"Right panel tabs",className:"bg-accent/60 h-auto justify-start gap-0.5 rounded-lg p-0.5",children:e.map(u=>{const f=u.id===t;return n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:n.jsxs(Vn,{value:u.id,"aria-label":Jv(u.title,a[u.id]??null),id:Sr(u.id),"aria-controls":f?Ql:void 0,className:z("text-muted-foreground hover:text-foreground text-3xs shrink-0 gap-1.5 rounded-md px-2.5 py-1",f&&"bg-background text-foreground shadow-sm"),children:[n.jsx(ys,{icon:u.icon,className:"size-3.5"}),n.jsx("span",{children:u.title}),n.jsx(Zv,{contributionId:u.id})]})}),n.jsx(qt,{side:"bottom",children:u.title})]},u.id)})})}),i.start&&n.jsx("div",{"aria-hidden":!0,"data-testid":"right-panel-tabs-fade-start",className:"from-sidebar via-sidebar/70 pointer-events-none absolute inset-y-0 left-0 w-6 bg-gradient-to-r to-transparent"}),i.end&&n.jsx("div",{"aria-hidden":!0,"data-testid":"right-panel-tabs-fade-end",className:"from-sidebar via-sidebar/70 pointer-events-none absolute inset-y-0 right-0 w-6 bg-gradient-to-l to-transparent"})]})})}const Cr="app-shell-right-panel",nw=40,sw=320,Xl=20,rw=50;function ow(e){if(e<=0)return Xl;const t=sw/e*100;return Math.min(Math.round(t*10)/10,rw)}function aw(){const[e,t]=l.useState(Xl);return l.useLayoutEffect(()=>{const s=document.querySelector(`[data-panel-group-id="${Cr}"]`);if(!(s instanceof HTMLElement))return;const r=()=>t(ow(s.offsetWidth));r();const o=new ResizeObserver(r);return o.observe(s),()=>o.disconnect()},[]),{minPct:e,defaultPct:Math.max(nw,e)}}const iw="cubic-bezier(0, 0, 0.2, 1)",cw="cubic-bezier(0.4, 0, 1, 1)";function Na(e,t){return`${e} 300ms ${t?iw:cw}`}const lw=new Set(["pulse","files"]);function dw({pathname:e,isRemoteCommunityRoom:t=!1}){const s=B(w=>w.rightPanelOpen),r=B(w=>w.setRightPanelOpen),o=B(w=>w.activeRightPanelTab),a=B(w=>w.setActiveRightPanelTabView),i=ob(),c=je(),d=l.useRef(null),[m,u]=l.useState(!1),[f,p]=l.useState(!1);l.useEffect(()=>{const w=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(w)},[]);const h=se(),g=B(w=>w.currentAgentId),x=B(w=>w.selectedCwd),b=B(w=>w.explicitAgentPath),y=vs("right-panel"),k=l.useMemo(()=>y.filter(w=>!w.visibleWhen||w.visibleWhen({pathname:e,transport:h,agentId:g,cwd:x,explicitAgentPath:b,isRemoteCommunityRoom:t})),[y,e,h,g,x,b,t]);l.useEffect(()=>{if(k.length>0&&!k.some(C=>C.id===o)){const C=k.find(N=>!N.isGlobal);a((C??k[0]).id)}},[k,o,a]);const j=s,{minPct:A,defaultPct:v}=aw();l.useEffect(()=>{const w=d.current;w&&(j&&w.isCollapsed()?w.expand(v):!j&&w.isExpanded()&&w.collapse())},[j,v]);const S=k.find(w=>w.id===o),I=S==null?void 0:S.component,D=S==null?void 0:S.headerActions,O=n.jsxs(n.Fragment,{children:[n.jsx(ew,{contributions:k,actions:D?n.jsx(l.Suspense,{fallback:null,children:n.jsx(D,{})}):void 0}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",...k.length>1&&o&&k.some(w=>w.id===o)?{id:Ql,role:"tabpanel","aria-labelledby":Sr(o)}:{},children:n.jsx(Qv,{tabId:o,children:n.jsx(l.Suspense,{fallback:null,children:I?n.jsx(I,{}):null})})})]});if(i)return j?n.jsx(Ju,{open:!0,onOpenChange:w=>!w&&r(!1),children:n.jsxs(Zu,{showCloseButton:!1,className:z("bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 p-0",c&&"sm:max-w-full",c&&o&&lw.has(o)&&"!bottom-auto !h-auto max-h-dvh overflow-y-auto"),children:[n.jsxs(em,{className:"sr-only",children:[n.jsx(tm,{children:"Panel"}),n.jsx(nm,{children:"Right panel content."})]}),O]})}):null;const E=f&&!m;return n.jsxs(n.Fragment,{children:[n.jsx(Fx,{"aria-label":"Resize right panel",disabled:!j,onDragging:u,gripStyle:{opacity:j?1:0,pointerEvents:j?"auto":"none",...E&&{transition:Na("opacity",j)}}}),n.jsx(ec,{ref:d,id:"right-panel",order:2,defaultSize:j?v:0,minSize:A,collapsible:!0,collapsedSize:0,onCollapse:()=>{f&&r(!1)},onExpand:()=>{s||r(!0)},style:E?{transition:Na("flex-grow",j)}:void 0,children:n.jsx("div",{className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:O})})]})}const Aa="inbox",uw="open";function mw({blocked:e=!1}={}){const t=ws()[Aa],s=Ur(),r=t!==void 0,o=t==null?"":String(t).trim();l.useEffect(()=>{!r||!s||(o&&!e&&sm(void 0,o===uw?void 0:{focus:o}),s({search:a=>({...a,[Aa]:void 0}),replace:!0}))},[r,o,e,s]),l.useEffect(()=>{e&&rm()},[e])}function hw(){const e=B(t=>t.toggleRightPanel);l.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.key==="."&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function fw(){const e=oe();ce("capabilities_changed",()=>{e.invalidateQueries({queryKey:tc.all})})}function pw(){const e=se(),t=oe();return Ct({mutationFn:({agentId:s,key:r,surface:o})=>e.patchAgentPermissions(s,{...r.kind==="area"?{areas:{[r.area]:null}}:{},...r.kind==="action"?{actions:{[r.action]:null}}:{},...r.kind==="files"?{filesAndCommands:null}:{},surface:o}),onSettled:()=>{t.invalidateQueries({queryKey:tc.all}),t.invalidateQueries({queryKey:["mesh","agents"]})}})}const Ea=new WeakMap;let gw=0;function xw(e){const t=Ea.get(e);if(t!==void 0)return t;const s=`bar-${gw++}`;return Ea.set(e,s),s}function bw(e){var t;for(let s=e.length-1;s>=0;s--){const r=(t=e[s].staticData)==null?void 0:t.header;if(r)return{key:xw(r),Header:r}}return null}function yw(e){const t=e.startsWith("/")?e:`/${e}`;if(Re()){const s=t.slice(1);if(s.length>0&&!s.startsWith("?")&&!s.startsWith("#"))return`dorkos://${s}`}return`${window.location.origin}${t}`}const vw="/";function jo(){const e=Bt();return l.useMemo(()=>{const t=()=>nc(e),s=o=>{pe.getState().selectTab(o),t()},r=o=>{const{tabs:a}=pe.getState(),i=a[o];i&&s(i.id)};return{activate:s,activateIndex:r,activateLast:()=>r(pe.getState().tabs.length-1),activateRelative:o=>{const{tabs:a,activeTabId:i}=pe.getState();if(a.length<2)return;const c=a.findIndex(u=>u.id===i),m=(((c===-1?0:c)+o)%a.length+a.length)%a.length;s(a[m].id)},close:o=>{pe.getState().closeTab(o),t()},closeActive:()=>{const{tabs:o,activeTabId:a}=pe.getState();if(!a)return!1;const i=o.length;pe.getState().closeTab(a);const c=pe.getState().tabs.length<i;if(c)try{t()}catch(d){console.error("[dorkos:tabs] could not follow a closed tab",d)}return c},create:()=>om(e,vw),togglePin:o=>{const a=pe.getState().tabs.find(i=>i.id===o);a&&pe.getState().setTabPinned(o,!a.pinned)},duplicate:o=>{pe.getState().duplicateTab(o),t()},closeOthers:o=>{pe.getState().closeOtherTabs(o),t()},reorder:(o,a)=>pe.getState().moveTab(o,a)}},[e])}const ww={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]},jw=4,kw={draggable:"Press Space to move this tab. Arrows move it, Space drops it, Escape cancels."};function Sw(e){return t=>{const s=e(String(t.active.id));return sc({...t,droppableContainers:t.droppableContainers.filter(r=>e(String(r.id))===s)})}}class Cw extends Map{getEnabled(){return[...this.values()].filter(t=>!t.disabled)}toArray(){return[...this.values()]}}function Nw(e){return(t,s)=>{const{context:r}=s;if(!r.active)return ur(t,s);const o=e(String(r.active.id)),a=new Cw;for(const i of r.droppableContainers.toArray())e(String(i.id))===o&&a.set(i.id,i);return ur(t,{...s,context:{...r,droppableContainers:a}})}}function Aw(e){return e.length===0?null:{left:Math.min(...e.map(t=>t.left)),right:Math.max(...e.map(t=>t.right))}}function Ew(e){return({transform:t,activeNodeRect:s})=>{const r=e();if(!r||!s)return t;const o=r.left-s.left,a=r.right-s.right;return{...t,x:Math.min(Math.max(t.x,o),a)}}}function Iw(e,t,s){if(s==null)return null;const r=e.indexOf(String(t)),o=e.indexOf(String(s));return r===-1||o===-1||r===o?null:[r,o]}function Rw(e){const{nameOf:t,indexOf:s,count:r}=e,o=a=>`position ${s(a)+1} of ${r()}`;return{onDragStart:({active:a})=>`Picked up ${t(String(a.id))}.`,onDragOver:({active:a,over:i})=>i?`${t(String(a.id))} is over ${o(String(i.id))}.`:void 0,onDragEnd:({active:a,over:i})=>i?`${t(String(a.id))} dropped at ${o(String(i.id))}.`:`${t(String(a.id))} put back.`,onDragCancel:({active:a})=>`Move cancelled. ${t(String(a.id))} put back.`}}const Tw=500;function Dw(e){const t=js(new Date(e).toISOString());return`Last active ${t==="Just now"?"just now":t}`}function Ow({identity:e,className:t}){return n.jsxs("div",{className:z("flex min-w-0 flex-col gap-1.5 text-xs",t),children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Qr,{icon:e.icon,className:"mt-px"}),n.jsxs("p",{className:"min-w-0 font-medium break-words",children:[e.primary,e.secondary&&n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" · ",e.secondary]})]})]}),e.origin&&n.jsx("p",{className:"text-muted-foreground",children:e.origin}),e.statusSentence&&n.jsxs("p",{className:"flex items-center gap-1.5",children:[n.jsx(Xr,{identity:e}),n.jsx("span",{children:e.statusSentence})]}),e.lastActiveAt!==void 0&&!Number.isNaN(e.lastActiveAt)&&n.jsx("p",{className:"text-muted-foreground",children:Dw(e.lastActiveAt)})]})}function Mw({identity:e,children:t}){return n.jsxs(xl,{openDelay:Tw,closeDelay:0,children:[n.jsx(bl,{asChild:!0,children:t}),n.jsx(yl,{side:"bottom",align:"start",sideOffset:6,className:"w-64 p-3",children:n.jsx(Ow,{identity:e})})]})}const Jl="app-tab-panel";function _w({identity:e,isActive:t,canClose:s,collapseAgent:r=!1,pinned:o=!1,tabProps:a,onClose:i}){const c=im(e,{collapseAgent:r}),d=l.useRef(null);l.useEffect(()=>{var u,f;t&&((f=(u=d.current)==null?void 0:u.scrollIntoView)==null||f.call(u,{block:"nearest",inline:"nearest"}))},[t]);const m=s&&!o;return n.jsxs("div",{ref:d,role:"presentation",className:"group relative flex shrink-0",children:[n.jsx(Mw,{identity:e,children:n.jsxs("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":t?Jl:void 0,"aria-label":cm(e,{collapseAgent:r}),...a,className:z("focus-ring flex min-w-0 items-center gap-1.5 rounded-md py-1 text-xs transition-colors",o?"px-2":t?"max-w-72 pl-2":"max-w-52 pl-2",!o&&(m?"pr-7":"pr-2"),t?"bg-background text-foreground shadow-soft":"text-muted-foreground hover:bg-background/60 hover:text-foreground"),children:[n.jsx(Qr,{icon:e.icon}),!o&&n.jsxs("span",{className:"min-w-0 truncate",children:[n.jsx("span",{className:"font-medium",children:c.lead}),c.trail&&n.jsxs("span",{className:"opacity-70",children:[" · ",c.trail]})]}),n.jsx(Xr,{identity:e})]})}),m&&i&&n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>i("pointer"),"aria-label":`Close ${e.primary}`,className:z("focus-ring hover:bg-muted absolute top-1/2 right-1 -translate-y-1/2 rounded-sm p-0.5","opacity-0 transition-opacity group-hover:opacity-70 hover:opacity-100",t&&"opacity-70"),children:n.jsx(Te,{className:"size-3"})})]})}function Pw({tab:e,isActive:t,canClose:s,pinned:r,tabProps:o,onClose:a}){const i=Jr(e.href),c=am(i.agentKey);return n.jsx(_w,{identity:i,isActive:t,canClose:s,collapseAgent:c,pinned:r??e.pinned??!1,tabProps:o,onClose:d=>a(e.id,d)})}function Lw({tabId:e,pinned:t,hasOthersToClose:s,canClose:r,actions:o,onClosed:a,children:i}){return n.jsxs(lm,{children:[n.jsx(dm,{asChild:!0,children:i}),n.jsxs(um,{className:"w-44",onCloseAutoFocus:a?c=>{c.preventDefault(),a()}:void 0,children:[n.jsxs(tn,{onSelect:()=>o.togglePin(e),children:[t?n.jsx(mm,{className:"mr-2 size-4"}):n.jsx(hm,{className:"mr-2 size-4"}),t?"Unpin":"Pin"]}),n.jsxs(tn,{onSelect:()=>o.duplicate(e),children:[n.jsx(Hb,{className:"mr-2 size-4"}),"Duplicate"]}),n.jsxs(tn,{onSelect:()=>o.copyLink(e),children:[n.jsx(fm,{className:"mr-2 size-4"}),"Copy link"]}),n.jsx(pm,{}),n.jsxs(tn,{disabled:!s,onSelect:()=>o.closeOthers(e),children:[n.jsx(gm,{className:"mr-2 size-4"}),"Close others"]}),n.jsxs(tn,{disabled:!r,onSelect:()=>o.close(e),children:[n.jsx(Te,{className:"mr-2 size-4"}),"Close"]})]})]})}const dn="data-app-tab-id";function Fw({tab:e,isActive:t,canClose:s,tabProps:r,onClose:o,sortable:a,dragActive:i,menu:c,hasOthersToClose:d,onMenuClosed:m}){const u=e.pinned??!1,{setNodeRef:f,setActivatorNodeRef:p,attributes:h,listeners:g,transform:x,transition:b,isDragging:y}=xm({id:e.id,disabled:!a}),k=g==null?void 0:g.onPointerDown,j=g==null?void 0:g.onKeyDown,A={transform:x?`translate3d(${Math.round(x.x)}px, 0, 0)`:void 0,transition:b??void 0},{ref:v,onKeyDown:S}=r,I=l.useCallback(w=>{v(w),p(w)},[v,p]),D=l.useCallback(w=>{if(c&&(w.key==="ContextMenu"||w.shiftKey&&w.key==="F10")){w.preventDefault();const C=w.currentTarget,N=C.getBoundingClientRect();C.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:N.left,clientY:N.bottom}));return}j==null||j(w),!(w.defaultPrevented||i)&&S(w)},[c,j,i,S]),O=l.useMemo(()=>({...r,ref:I,onKeyDown:D,...a?{"aria-describedby":h["aria-describedby"]}:{}}),[r,I,D,a,h]),E=n.jsx("div",{ref:f,role:"presentation",[dn]:e.id,style:A,onPointerDown:k,className:z("flex shrink-0",y&&"bg-background shadow-soft relative z-10 rounded-md"),children:n.jsx(Pw,{tab:e,isActive:t,canClose:s,tabProps:O,onClose:o,pinned:u})});return c?n.jsx(Lw,{tabId:e.id,pinned:u,hasOthersToClose:d,canClose:s,actions:c,onClosed:m,children:E}):E}function $w({tabs:e,activeId:t,onActivate:s,onClose:r,onCreate:o,menu:a,onReorder:i,className:c}){const d=l.useRef(null),m=l.useRef(null),u=rc(null),f=e.length>1,[p,h]=l.useState(!1),g=l.useMemo(()=>e.map(E=>E.id),[e]),x=Mt(e),{collisionDetection:b,coordinateGetter:y,modifiers:k,announcements:j}=l.useMemo(()=>{const E=C=>x.read().findIndex(N=>N.id===C),w=C=>{var N;return((N=x.read().find(T=>T.id===C))==null?void 0:N.pinned)??!1};return{collisionDetection:Sw(w),coordinateGetter:Nw(w),modifiers:[Ew(u.read)],announcements:Rw({nameOf:C=>{var N,T,R;return((R=(T=(N=Array.from(document.querySelectorAll(`[${dn}]`)).find(_=>_.getAttribute(dn)===C))==null?void 0:N.querySelector('[role="tab"]'))==null?void 0:T.textContent)==null?void 0:R.trim())||"Tab"},indexOf:E,count:()=>x.read().length})}},[x,u]),A=oc(ns(cc,{activationConstraint:{distance:jw}}),ns(ic,{coordinateGetter:y,keyboardCodes:ww})),v=({active:E})=>{var N,T;h(!0);const w=((N=e.find(R=>R.id===E.id))==null?void 0:N.pinned)??!1,C=Array.from(((T=m.current)==null?void 0:T.querySelectorAll(`[${dn}]`))??[]).filter(R=>{var P;const _=R.getAttribute(dn);return(((P=e.find(U=>U.id===_))==null?void 0:P.pinned)??!1)===w}).map(R=>R.getBoundingClientRect());u.write(Aw(C))},S=()=>{h(!1),u.write(null)},I=({active:E,over:w})=>{S();const C=Iw(g,E.id,w==null?void 0:w.id);C&&i&&i(...C)},D=()=>{setTimeout(()=>{var E,w;(w=(E=m.current)==null?void 0:E.querySelector('[role="tab"][aria-selected="true"]'))==null||w.focus()},0)},{getTabProps:O}=Jx({orderedIds:e.map(E=>E.id),activeId:t,onActivate:s,onClose:f?r:void 0,getFallbackFocus:()=>d.current});return n.jsxs("div",{className:z("bg-muted/40 flex shrink-0 items-stretch border-b px-2 py-1",c),children:[n.jsx("div",{className:"flex min-w-0 flex-1 items-stretch overflow-x-auto",children:n.jsx(ac,{sensors:A,collisionDetection:b,modifiers:k,accessibility:{announcements:j,screenReaderInstructions:kw},onDragStart:v,onDragEnd:I,onDragCancel:S,children:n.jsx(bm,{items:g,strategy:ym,children:n.jsx("div",{ref:m,role:"tablist","aria-label":"Open tabs",className:"flex items-stretch gap-1",children:e.map(E=>n.jsx(Fw,{tab:E,isActive:E.id===t,canClose:f,tabProps:O(E.id),onClose:r,sortable:i!==void 0,dragActive:p,menu:a,onMenuClosed:D,hasOthersToClose:e.some(w=>w.id!==E.id&&!w.pinned)},E.id))})})})}),n.jsx("button",{ref:d,type:"button",onClick:o,"aria-label":"New tab",title:`New tab (${Pt(yn.NEW_TAB)})`,className:"focus-ring text-muted-foreground hover:bg-background/60 hover:text-foreground ml-1 flex shrink-0 items-center rounded-md px-1.5 transition-colors",children:n.jsx(Kt,{className:"size-3.5"})})]})}function Bw({className:e}){const t=vm(),s=pe(p=>p.activeTabId),{activate:r,close:o,create:a,togglePin:i,duplicate:c,closeOthers:d,reorder:m}=jo(),{copy:u}=Nn({toastOnSettle:!0}),f=l.useMemo(()=>({togglePin:i,duplicate:c,closeOthers:d,close:o,copyLink:p=>{const h=pe.getState().tabs.find(g=>g.id===p);h&&u(yw(h.href))}}),[i,c,d,o,u]);return n.jsx($w,{tabs:t,activeId:s,onActivate:r,onClose:o,onCreate:a,menu:f,onReorder:m,className:e})}function is(){var s;const{tabs:e,activeTabId:t}=pe.getState();return((s=e.find(r=>r.id===t))==null?void 0:s.cursor)??null}function ko(e,t){const s=is();s!==null&&(pe.getState().goToHistoryIndex(t),is()!==s&&nc(e))}function Zl(e){const t=is();t!==null&&ko(e,t-1)}function ed(e){const t=is();t!==null&&ko(e,t+1)}function zw(e,t){ko(e,t)}function Ia(e,t){const s=Pt(e);return wt?s:`${s} or ${Pt(`alt+${t}`)}`}const Ws="size-7";function Uw({href:e,isCurrent:t,onSelect:s}){const r=Jr(e);return n.jsxs(jm,{disabled:t,"aria-current":t?"page":void 0,onSelect:s,"aria-label":r.accessibleName,className:"data-[disabled]:opacity-100",children:[n.jsx(Qr,{icon:r.icon}),n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r.primary,r.secondary&&n.jsxs("span",{className:"text-muted-foreground",children:[" · ",r.secondary]})]}),n.jsx(Xr,{identity:r}),n.jsx(Nt,{className:z("size-3.5 shrink-0",!t&&"invisible")})]})}function qs({label:e,keys:t,children:s}){return n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:s}),n.jsx(qt,{side:"bottom",className:"text-xs",children:t?`${e} (${t})`:e})]})}function Kw(){const e=Bt(),{entries:t,cursor:s,canGoBack:r,canGoForward:o}=wm();if(!Re())return null;const a=t.map((i,c)=>({href:i,index:c})).reverse();return n.jsxs("div",{className:"flex items-center",children:[n.jsx(qs,{label:"Back",keys:Ia(yn.HISTORY_BACK.key,"←"),children:n.jsx(M,{variant:"ghost",size:"icon-md",className:Ws,"aria-label":"Back",disabled:!r,onClick:()=>Zl(e),children:n.jsx(lc,{})})}),n.jsx(qs,{label:"Forward",keys:Ia(yn.HISTORY_FORWARD.key,"→"),children:n.jsx(M,{variant:"ghost",size:"icon-md",className:Ws,"aria-label":"Forward",disabled:!o,onClick:()=>ed(e),children:n.jsx(dc,{})})}),n.jsxs(uc,{children:[n.jsx(qs,{label:"History",children:n.jsx(mc,{asChild:!0,children:n.jsx(M,{variant:"ghost",size:"icon-md",className:Ws,"aria-label":"History",children:n.jsx(Zx,{})})})}),n.jsx(hc,{align:"start",className:"max-w-72 min-w-48",children:a.map(({href:i,index:c})=>n.jsx(Uw,{href:i,isCurrent:c===s,onSelect:()=>zw(e,c)},c))})]})]})}function Hw(){const e=Bt(),t=ve({select:o=>o.location.href}),s=l.useRef(!1),r=l.useRef(!0);l.useEffect(()=>{if(Re())return e.history.subscribe(({action:o})=>{s.current=o.type!=="PUSH"&&o.type!=="REPLACE",r.current=o.type==="REPLACE"})},[e]),l.useEffect(()=>{if(!Re())return;const o=s.current,a=r.current;s.current=!1,r.current=!1,pe.getState().syncLocation(t,{traversal:o,replace:a})},[t])}const Ra=9;function Ww(){const e=jo();l.useEffect(()=>{if(!Re())return;const t=s=>{if(!(s.metaKey||s.ctrlKey)||s.altKey)return;if(s.shiftKey){s.code==="BracketLeft"?(s.preventDefault(),e.activateRelative(-1)):s.code==="BracketRight"&&(s.preventDefault(),e.activateRelative(1));return}if(s.key==="t"||s.key==="T"){s.preventDefault(),e.create();return}if(!s.code.startsWith("Digit"))return;const r=Number(s.code.slice(5));!Number.isInteger(r)||r<1||r>Ra||(s.preventDefault(),r===Ra?e.activateLast():e.activateIndex(r-1))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const Ta=3,qw=4;function Gw(e){return e instanceof Element?e.closest("input, textarea, select")?!0:e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function Da(e){return e instanceof Element&&e.closest('[role="dialog"], [role="alertdialog"], [role="menu"]')!==null}function Yw(e){if(e.shiftKey)return null;if((wt?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey)return e.code==="BracketLeft"?"back":e.code==="BracketRight"?"forward":null;if(!wt&&e.altKey&&!e.ctrlKey&&!e.metaKey){if(Gw(e.target))return null;if(e.key==="ArrowLeft")return"back";if(e.key==="ArrowRight")return"forward"}return null}function Vw(){const e=Bt();l.useEffect(()=>{if(!Re())return;const t=i=>i==="back"?Zl(e):ed(e),s=i=>{if(i.defaultPrevented||i.isComposing||Da(i.target))return;const c=Yw(i);c&&(i.preventDefault(),t(c))},r=i=>i.button===Ta||i.button===qw,o=i=>{r(i)&&i.preventDefault()},a=i=>{r(i)&&(i.preventDefault(),!Da(i.target)&&t(i.button===Ta?"back":"forward"))};return document.addEventListener("keydown",s),document.addEventListener("mousedown",o),document.addEventListener("mouseup",a),()=>{document.removeEventListener("keydown",s),document.removeEventListener("mousedown",o),document.removeEventListener("mouseup",a)}},[e])}function Qw(e){return e.displayName||e.name}function So(e,t){const s=vn(r=>r.setRouteBadge);l.useEffect(()=>{s(e,t)},[e,t,s])}const Xw=5*6e4;function Jw(e){return e.status==="active"&&e.enabled}function Zw(e){const{enabled:t}=Sm(),{data:s}=fc(t),{data:r}=Cm(t),o=vn(c=>c.setSchedulesWaitingCount),a=l.useMemo(()=>{const c=xv(t?r??[]:[]),d=new Map((s??[]).filter(Jw).map(m=>[m.id,m]));return{waiting:e,failed:c.failed.filter(m=>d.has(m)).length,running:c.running.flatMap(m=>{const u=d.get(m);return u?[Qw(u)]:[]})}},[t,r,s,e]),i=l.useMemo(()=>Nm(a),[a]);So("/tasks",i),l.useEffect(()=>{o(e)},[e,o])}function ej(){const{count:e,more:t}=Am(),s=l.useMemo(()=>Em(e,t),[e,t]);So("/activity",s)}function tj(){const{data:e,isSuccess:t}=ax("pending"),{data:s}=ix("pending",{enabled:t,refetchInterval:Xw}),r=((e==null?void 0:e.length)??0)+((s==null?void 0:s.length)??0),o=l.useMemo(()=>Im(r),[r]);So("/connections",o)}function nj(){const{items:e,schedules:t}=km(),s=vn(r=>r.setNeedsYouCount);l.useEffect(()=>{s(e.length)},[e.length,s]),Zw(t.length),ej(),tj()}function bt(e){return"problem"in e?{problem:e.problem}:{message:e.message}}const yt={message:"Couldn’t reach your DorkOS account. Try again."},sj={message:"Finish signing in in your browser, then try again."},rj={message:"Your browser blocked the window. Allow pop-ups, then try again."},Gs={message:"Couldn’t connect this DorkOS to the space. Try again."},oj={message:"The approval ran out. Connect again."};function Co(e,t,s){var O,E;const r=se(),o=oe(),a=Cn(e!==null),{signsInWithAccount:i,linkFor:c}=pc(e!==null),[d,m]=l.useState({opened:!1,busy:!1,notice:null}),[u,f]=l.useState(null),p=l.useRef(null),h=ge({queryKey:Ue.list(),queryFn:()=>r.listHostedCommunities(),enabled:e!==null&&u===null,refetchInterval:w=>{const C=w.state.data,N=(C==null?void 0:C.available)===!0?C.communities.find(T=>T.communityId===(e==null?void 0:e.communityId)):void 0;return(N==null?void 0:N.state)==="provisioning"?2e3:!1}}),g=((O=h.data)==null?void 0:O.available)===!0?h.data.communities.find(w=>w.communityId===(e==null?void 0:e.communityId)):void 0,x=(g==null?void 0:g.state)==="provisioning",b=l.useCallback(()=>{if(!e||d.busy)return;const w=Hr();if(w===null){m(C=>({...C,notice:rj}));return}m(C=>({...C,busy:!0,notice:null})),r.getHostedCommunityClaimLink(e.communityId).then(C=>{if(!C.ok){w.close(),m(T=>({...T,busy:!1,notice:bt(C)}));return}const N=w.go(c(C.claimUrl));m(T=>({opened:T.opened||N,busy:!1,notice:null}))}).catch(()=>{w.close(),m(C=>({...C,busy:!1,notice:yt}))})},[e,d.busy,r,c]),y=l.useCallback(async()=>{if(e){if(!a||!ft(a)){f({ref:null,approvalUrl:null,busy:!1,notice:Gs});return}f({ref:null,approvalUrl:null,busy:!0,notice:null});try{const w=await r.startCommunityConnection({url:e.communityUrl,installName:t});f({ref:w.connection.ref,approvalUrl:w.approvalUrl,busy:!1,notice:null}),await o.invalidateQueries({queryKey:rt.connections(a)})}catch{f({ref:null,approvalUrl:null,busy:!1,notice:Gs})}}},[e,a,r,t,o]),k=l.useCallback(()=>{!e||d.busy||(m(w=>({...w,busy:!0,notice:null})),r.listHostedCommunities().then(w=>{o.setQueryData(Ue.list(),w);const C=w.available===!0?w.communities.find(N=>N.communityId===e.communityId):void 0;if(!C||C.state==="pending_owner"||C.state==="provisioning"){m(N=>({...N,busy:!1,notice:sj}));return}m(N=>({...N,busy:!1})),y()}).catch(()=>m(w=>({...w,busy:!1,notice:yt}))))},[e,d.busy,r,o,y]),j=(u==null?void 0:u.ref)??null,A=ge({queryKey:a&&j?rt.approval(a,j):["cloud","no-approval"],queryFn:()=>Bi(a,()=>r.pollCommunityConnection(j)),enabled:a!==null&&j!==null,retry:!1,refetchInterval:w=>!w.state.error&&(!w.state.data||w.state.data.status==="pending")?2e3:!1}),v=j!==null?((E=A.data)==null?void 0:E.status)??"pending":"pending",S=v==="connected"?j:null;l.useEffect(()=>{S===null||p.current===S||(p.current=S,a&&o.invalidateQueries({queryKey:rt.connections(a)}),o.invalidateQueries({queryKey:Ue.all}),s(S))},[S,a,o,s]);const I=v==="expired"||v==="cancelled";return{state:S!==null?{kind:"done",ref:S}:u!==null?{kind:"connecting",approvalUrl:u.approvalUrl,busy:u.busy,notice:u.notice??(I?oj:A.error?Gs:null)}:x?{kind:"preparing"}:{kind:"claim",...d,withAccount:e!==null&&i(e.communityUrl)},openClaim:b,confirmClaimed:k,openApproval:()=>{u!=null&&u.approvalUrl&&it(c(u.approvalUrl))},retryConnect:()=>void y()}}const st=Rm({offset:!0}).describe("An ISO-8601 instant with an explicit UTC offset."),Be=me().min(1).describe("An opaque server-issued identifier. Clients never parse or enumerate it.");me().regex(/^-?(0|[1-9][0-9]*)$/,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units, carried as a string so no value goes through a JavaScript number. A micro-unit is a millionth of the major unit of the currency the response names.");const aj=me().regex(/^[1-9][0-9]*$/,"must be a positive base-10 integer count of micro-units carried as a string").describe("A strictly positive exact integer count of micro-units, carried as a string so no amount goes through a JavaScript number."),No="amountKind";Yt(["money","credit"]).describe("What an amount counts: money paid, refunded, offered or capped, or credits held, spent or priced.");const td=/^-?(0|[1-9][0-9]*)$/,ij=/^[1-9][0-9]*$/;me().regex(td,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units of the response's currency: money paid, refunded, offered or capped.").meta({[No]:"money"});me().regex(ij,"must be a positive base-10 integer count of micro-units carried as a string").describe("A strictly positive exact integer count of micro-units of money to be paid, in the currency the service names.").meta({[No]:"money"});me().regex(td,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units of the response's currency, counted as credits: divide by the response's denomination.microPerCredit to get credits.").meta({[No]:"credit"});re({currency:me().regex(/^[A-Z]{3}$/,"must be an ISO 4217 currency code").describe("An ISO 4217 code. Rendered, never enumerated."),microPerCredit:aj.describe("How many micro-units of currency one credit is. Served by the service; a client never hard-codes it.")}).describe("The unit these amounts are in: the currency their micro-units are millionths of, and how many micro-units one credit is.");const cj=me().min(1).describe("A credential returned exactly once. Store it as a credential reference; never log it or persist it as configuration."),nd=me().min(1).describe("An opaque pagination cursor, passed back verbatim from a previous page.");re({cursor:nd.optional(),limit:de().int().min(1).max(200).optional().describe("Maximum items in the page. The server may return fewer, and clamps anything larger.")}).describe("Cursor pagination parameters, shared by every collection in this contract.");function sd(e,t){return re({items:Gt(e),nextCursor:nd.nullable().describe("The cursor for the next page, or null when this is the last page.")}).describe(t)}const lj=gc({protocol:/^https$/}).regex(/^https:\/\//,"must be an https: link").describe("An absolute https: link. Any other scheme is refused."),Mn=gc({protocol:/^https?$/}).regex(/^(https:\/\/|http:\/\/(localhost|127\.0\.0\.1|\[::1\])(:[0-9]+)?([/?#]|$))/,"must be an https: link, or http: to a loopback address").describe("An absolute https: link, or an http: link to a loopback address only."),rd="x-dorkos-one-time-credential",dj="unrecognised";function cs(e){return Tm([e,me().transform(()=>dj).describe("A value this release does not know. It reads as unrecognised.")])}const Jt=me().regex(/^[a-z](?:[a-z0-9]|-(?=[a-z0-9])){2,31}$/,"must be lower-case letters, digits and single hyphens, start with a letter, and not end with a hyphen").describe("A community short name: lower case, 3 to 32 characters, letters, digits and single hyphens, starting with a letter and not ending with a hyphen."),od=me().trim().min(1).max(80).describe("The community`s display name. Trimmed, 1 to 80 characters."),ad=me().min(1).max(200).describe("A key the caller chooses, scoped to the caller. Sending it again returns the same community or move instead of making a second one.");function uj(e){return Mn.meta({description:e,[rd]:!0})}const mj=Yt(["provisioning","pending_owner","active","archived","held","suspended","deletion_pending"]).describe("Where a hosted community is in its lifecycle. The Community server`s own lifecycle names, plus provisioning while the server confirms a start."),hj=Yt(["over_limit","inactive","host"]).describe("Why a hosted community is on hold: the account holds more than its allowance covers, nobody has posted in a long time, or the host placed the hold itself."),fj=re({title:me().min(1).max(120).describe("A short summary, safe to show a person."),detail:me().max(2e3).describe("The explanation, safe to show a person."),actionUrl:lj.optional().catch(void 0).describe("A page where the owner can act on the notice. Open it as given. A malformed value is dropped."),actionLabel:me().min(1).max(60).optional().catch(void 0).describe("The text for a button that opens `actionUrl`. A malformed value is dropped.")}).describe("What the service wants the owner to read about this community, in its own words."),pj=re({allowed:gt().describe("The owner may choose this community as one to keep open."),wouldHold:Gt(Be).describe("The caller`s other communities that keeping this one would put on hold.")}).describe("Whether the owner may keep this community open, and which others it would hold."),Ao=re({communityId:Be.describe("The community`s permanent identifier on its Community server. Never changes, even across a rename."),orgId:Be.describe("The organization whose account this community belongs to."),name:me().min(1).max(80).describe("The community`s display name."),shortName:Jt.nullable().describe("The community`s current short name, or null when it has none."),communityUrl:Mn.describe("The community`s canonical link on its Community server, built on its permanent identifier. A runtime value; pair a DorkOS installation with this."),state:cs(mj).describe("Where the community is in its lifecycle. A state this release does not know reads as unrecognised."),hold:re({reason:cs(hj).describe("Why the community is on hold. A reason this release does not know reads as unrecognised."),since:st,deletionNoticeAt:st.nullable().describe("When the host may delete the community if the hold is not lifted, or null when no deletion is planned. The owner can export until then.")}).nullable().describe("Why and since when the community is on hold. Always set when the state is held."),deletionAt:st.nullable().describe("When the Community server will delete the community for good. Always set when the state is deletion_pending."),notice:fj.nullable().describe("What the service wants the owner to read about this community, or null when there is nothing."),kept:gt().describe("True when the owner chose this community to stay open while the account holds more communities than its allowance covers."),moveId:Be.nullable().describe("The move filling this community from an owner export, while that move is unfinished. Null otherwise. Lets the app pick up a move after a restart."),limits:re({maxActiveMembers:de().int().positive().nullable().describe("The most people who may be active members at once. Null means no limit."),maxStorageBytes:de().int().nonnegative().nullable().describe("The most bytes of files the community may store. Null means no per-community limit.")}).describe("The limits the host enforces on this community. Agents and history never count."),usage:re({activeMembers:de().int().nonnegative(),storageBytes:de().int().nonnegative().describe("The bytes that count against the storage limit. Owner exports never count."),measuredAt:st}).nullable().describe("The community`s last measured usage, or null before the first measurement."),actions:re({claimLink:gt().describe("The service will issue a fresh owner-claim link for this community."),keep:pj,restore:gt().describe("The owner may ask for this held community to reopen.")}).describe("What the caller may do next. Render an action only when it is allowed; the service applies the rule, the app never re-derives it."),createdAt:st}).superRefine((e,t)=>{e.state==="held"&&e.hold===null&&t.addIssue({code:"custom",path:["hold"],message:"a held community says why"}),e.state==="deletion_pending"&&e.deletionAt===null&&t.addIssue({code:"custom",path:["deletionAt"],message:"a community pending deletion says when"})}).describe("One community the caller has hosted, with its state, limits and usage. Numbers only.");sd(Ao,"A page of the communities the caller has hosted.");re({name:Jt}).describe("The short name to check.");const gj=Yt(["taken","reserved"]).describe("Why a short name cannot be used: another community has it, or the host reserves it.");re({name:Jt,available:gt(),reason:gj.nullable().describe("Why the name cannot be used. Null exactly when it is available.")}).superRefine((e,t)=>{e.available!==(e.reason===null)&&t.addIssue({code:"custom",path:["reason"],message:"reason is null exactly when the name is available"})}).describe("Whether a short name is free right now. Advisory; starting a community checks again.");re({idempotencyKey:ad,name:od,shortName:Jt.optional().describe("The short name to give the community. Omitted means none."),orgId:Be.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one.")}).describe("Start a hosted community. Idempotent on the caller`s key.");const xj=re({communityId:Be,claimUrl:uj("The owner-claim link. A single-use credential: open it in the person`s own browser and never log it."),expiresAt:st.describe("When the link stops working.")}).describe("A one-time link that makes a person the owner of a new community. Returned once.");re({community:Ao,claim:xj.nullable().describe("The owner-claim link, or null when this answer repeats an earlier request or the community is still provisioning."),replayed:gt().describe("True when this answer repeats an earlier request with the same key.")}).superRefine((e,t)=>{e.claim!==null&&(e.replayed||e.community.state!=="pending_owner")&&t.addIssue({code:"custom",path:["claim"],message:"a claim link comes only on the first answer, for a pending_owner community"})}).describe("The started community and, the first time only, its owner-claim link.");re({expectedHeldCommunityIds:Gt(Be).describe("The communities the owner was told this choice would hold, in any order.")}).describe("Keep this community open, confirming which others the owner agreed to hold.");re({community:Ao,heldCommunityIds:Gt(Be).describe("Other communities of the caller`s that this choice put on hold. Often empty.")}).describe("The kept community, and every other community the choice put on hold.");const bj=Yt(["awaiting_upload","importing","ready","failed","cancelled","claimed"]).describe("Where a move is: waiting for the export, importing it, ready to claim, or finished."),yj=Yt(["not_owner_export","archive_invalid","checksum_mismatch","version_unsupported","too_large","storage_limit_reached","upload_expired","storage_unavailable"]).describe("Why a move failed, in terms a person can act on."),vj=re({channels:de().int().nonnegative(),entries:de().int().nonnegative().describe("Messages and replies."),attachments:de().int().nonnegative(),historicalMembers:de().int().nonnegative().describe("People whose messages move. They join again by invitation."),historicalAgents:de().int().nonnegative().describe("Agents whose messages move. Their owners pair them again."),attachmentBytes:de().int().nonnegative(),countedBytes:de().int().nonnegative().describe("The bytes that will count against the community`s storage limit.")}).describe("What an owner export holds, in counts and sizes only."),id=re({moveId:Be,communityId:Be.describe("The new community the export fills. It no longer exists once a move has failed or been cancelled."),communityUrl:Mn.describe("The new community`s canonical link. A runtime value."),name:me().min(1).max(80).describe("The name the new community was given."),state:cs(bj).describe("Where the move is. A state this release does not know reads as unrecognised."),failureCode:cs(yj).nullable().describe("Why the move failed. Always set when the state is failed. A code this release does not know reads as unrecognised."),report:vj.nullable().describe("What the export holds, once it has been read. Null before then."),pollAfterMs:de().int().nonnegative().nullable().describe("How long to wait before reading the move again. Null once it has finished."),updatedAt:st}).superRefine((e,t)=>{e.state==="failed"&&e.failureCode===null&&t.addIssue({code:"custom",path:["failureCode"],message:"a failed move says why"})}).describe("One move of a community into hosting, from an owner export.");sd(id,"A page of the caller`s moves: every unfinished one, and those that finished within the last 7 days, newest first.");re({idempotencyKey:ad,name:od,shortName:Jt.optional().describe("The short name to give the new community. Omitted means none."),orgId:Be.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one."),archiveBytes:de().int().positive().describe("The size of the export file, in bytes."),archiveSha256:me().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest").describe("The SHA-256 of the export file, as lower-case hex.")}).describe("Start moving a community in from an owner export. Idempotent on the caller`s key.");const wj=re({url:Mn.describe("Where to send the export. A runtime value."),token:cj.meta({description:"The upload bearer credential. Returned once; never log it.",[rd]:!0}),expiresAt:st.describe("When the upload window closes."),maxBytes:de().int().positive().describe("The largest file the upload accepts."),parts:re({partBytes:de().int().positive().describe("The largest part the upload accepts."),maxBytes:de().int().positive().describe("The largest file a parted upload accepts.")}).optional().describe("Present when the Community server accepts the file in parts.")}).describe("Where and how to send the export file. The token is returned once."),cd=me().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest"),Eo=1e4,jj=re({partNumber:de().int().positive().max(Eo).describe("The number of the part, counting up from one."),byteSize:de().int().positive().describe("The size of the part, in bytes."),sha256:cd.describe("The SHA-256 of the part, as lower-case hex.")}).describe("One part the Community server has received.");re({parts:Gt(jj).max(Eo).describe("The parts received, in part order."),maxPartBytes:de().int().positive().describe("The largest part the upload accepts."),maxArchiveBytes:de().int().positive().describe("The largest file a parted upload accepts.")}).describe("The parts of a parted upload received so far.");re({parts:de().int().positive().max(Eo).describe("How many parts make up the file."),archiveBytes:de().int().positive().describe("The size of the whole file, in bytes."),archiveSha256:cd.describe("The SHA-256 of the whole file, as lower-case hex.")}).describe("Put the uploaded parts together into the declared file.");re({move:id,upload:wj.nullable().describe("Where to send the export, or null when this answer repeats an earlier request."),replayed:gt().describe("True when this answer repeats an earlier request with the same key.")}).superRefine((e,t)=>{e.replayed!==(e.upload===null)&&t.addIssue({code:"custom",path:["upload"],message:"upload is null exactly when the answer is replayed"})}).describe("The started move and, the first time only, where to send the export.");const kj=Mn.regex(/^https?:\/\/[^/?#]+$/,"must be an origin: no path, query or fragment").refine(e=>new URL(e).origin===e,{message:"must be written as the URL standard writes an origin"}).describe("A Community server`s origin: scheme, host and port, written as the URL standard writes it. A runtime value."),Sj=re({origin:kj}).describe("A Community server whose single sign-on is this account.");re({servers:Gt(Sj).max(100).describe("Every Community server whose single sign-on is this account. Often one.")}).describe("The Community servers where this account signs a person in.");function ld(e){switch(e){case"not_owner_export":return{title:"This is a personal export, not an owner export.",next:"Sign in to the old space as its owner, export it from Settings, then try again."};case"archive_invalid":return{title:"This file is damaged, or it isn’t a space export.",next:"Export the old space again, then try again."};case"checksum_mismatch":return{title:"Part of this export is damaged.",next:"Export the old space again, then try again."};case"version_unsupported":return{title:"This export comes from a version DorkOS can’t read yet.",next:"Update the old space, export it again, then try again."};case"too_large":return{title:"This export is too large to move.",next:"Delete some large files in the old space, export it again, then try again."};case"storage_limit_reached":return{title:"The files don’t fit in the new space’s storage.",next:"Delete some files in the old space, export it again, then try again."};case"upload_expired":return{title:"The file didn’t arrive in time.",next:"Start the move again."};case"storage_unavailable":return{title:"DorkOS couldn’t store the files just now.",next:"Wait a little while, then start the move again."};default:return{title:"The move stopped for an unknown reason.",next:"Update DorkOS to see more, or start the move again."}}}function Cj(e){switch(e){case"provisioning":return"Being set up";case"pending_owner":return"Waiting for its owner";case"active":return"Open";case"archived":return"Archived";case"held":return"On hold";case"suspended":return"Suspended";case"deletion_pending":return"Being deleted";default:return"Unknown state"}}function Nj(e){switch(e){case"over_limit":return"Your account has more spaces than it allows. Choose which ones stay open.";case"inactive":return"Nobody has posted here in a long time. You can reopen it.";case"host":return"DorkOS put this space on hold. People can still read it.";default:return"This space is on hold. Update DorkOS to see why."}}function Ys(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"})}function kn(e){const t=["bytes","KB","MB","GB","TB"];let s=e,r=0;for(;s>=1e3&&r<t.length-1;)s/=1e3,r++;return`${r===0||s>=10?Math.round(s):Math.round(s*10)/10} ${t[r]}`}function dd(e){if((e==null?void 0:e.maxCommunities)==null||e.usedCommunities==null)return null;const t=e.maxCommunities-e.usedCommunities;return t<=0?"Your account has no room for another space right now.":`You can start ${t} more ${t===1?"space":"spaces"}.`}const ud="Lower-case letters, numbers and single hyphens. 3 to 32 characters, starting with a letter.";function _n(e){const t=e.trim().toLowerCase();return t===""?{value:t,valid:!0}:{value:t,valid:Jt.safeParse(t).success}}const Aj=80,md="That web address is taken.",hd="That web address can’t be used.";function fd(e){const t=se(),{value:s,valid:r}=_n(e),[o,a]=l.useState(s);l.useEffect(()=>{const d=setTimeout(()=>a(s),400);return()=>clearTimeout(d)},[s]);const i=ge({queryKey:Ue.name(o),queryFn:()=>t.checkHostedCommunityName(o),enabled:r&&o!==""&&o===s,staleTime:1e4,retry:!1});if(s==="")return{kind:"none"};if(!r)return{kind:"invalid"};if(o!==s||i.isPending)return{kind:"checking"};const c=i.data;return!c||c.available===!1?{kind:"none"}:c.check.available?{kind:"available"}:{kind:c.check.reason==="reserved"?"reserved":"taken"}}function Ej(){const e=l.useRef(null);return t=>{var r;const s=JSON.stringify(t);return((r=e.current)==null?void 0:r.body)!==s&&(e.current={body:s,key:crypto.randomUUID()}),e.current.key}}function Ij(){const e=se(),t=oe(),s=Ej(),[r,o]=l.useState(!1),[a,i]=l.useState({field:null,notice:null});async function c(d){const m={name:d.name.trim(),...d.shortName?{shortName:d.shortName}:{}};o(!0),i({field:null,notice:null});try{const u=await e.startHostedCommunity({...m,idempotencyKey:s(m)});return u.ok?(t.invalidateQueries({queryKey:Ue.list()}),{community:u.community}):("problem"in u&&u.problem.code==="community_name_taken"?i({field:md,notice:null}):"problem"in u&&u.problem.code==="community_name_reserved"?i({field:hd,notice:null}):i({field:null,notice:bt(u)}),null)}catch{return i({field:null,notice:yt}),null}finally{o(!1)}}return{submitting:r,failure:a,clearFieldFailure:()=>i(d=>({...d,field:null})),submit:c}}function Rj(e){switch(e.state){case"awaiting_upload":{const t=e.upload;if((t==null?void 0:t.state)==="sending")return{kind:"uploading",move:e};if((t==null?void 0:t.state)==="sent")return{kind:"importing",move:e};const s=t===null?"restarted":t.failure==="interrupted"?"interrupted":t.failure==="rejected"?"refused":"expired";return{kind:"upload-failed",move:e,why:s}}case"importing":return{kind:"importing",move:e};case"ready":case"claimed":return{kind:"ready",move:e};case"failed":return{kind:"failed",move:e};case"cancelled":return{kind:"cancelled",move:e};default:return{kind:"unrecognised",move:e}}}function Tj(e){return e.state==="awaiting_upload"||e.state==="importing"||e.state==="ready"}function Dj(e){var A;const t=se(),s=oe(),[r,o]=l.useState(e),[a,i]=l.useState(null),[c,d]=l.useState({field:null,notice:null}),[m,u]=l.useState(!1),f=l.useRef(null),p=l.useRef(null),h=ge({queryKey:Ue.move(r??""),queryFn:()=>t.getHostedCommunityMove(r),enabled:r!==null,refetchInterval:v=>{var I;const S=v.state.data;return(S==null?void 0:S.available)!==!0?!1:((I=S.move.upload)==null?void 0:I.state)==="sending"?1e3:S.move.pollAfterMs===null?!1:Math.max(1e3,S.move.pollAfterMs)}}),g=((A=h.data)==null?void 0:A.available)===!0?h.data.move:null,x=g?Rj(g):null,b=l.useCallback(v=>{s.setQueryData(Ue.move(v.moveId),{available:!0,move:v})},[s]);async function y(v){var E;const S={name:v.name.trim(),...v.shortName?{shortName:v.shortName}:{},file:[v.file.name,v.file.size,v.file.lastModified]},I=JSON.stringify(S);((E=p.current)==null?void 0:E.body)!==I&&(p.current={body:I,key:crypto.randomUUID()});const D=p.current.key,O=new AbortController;f.current=O,d({field:null,notice:null}),i({loaded:0,total:v.file.size});try{const w=await t.checkHostedCommunityMoveRoom(v.file.size,O.signal);if(O.signal.aborted)return;const C=w.ok?await t.startHostedCommunityMove(v.file,{idempotencyKey:D,name:S.name,...v.shortName?{shortName:v.shortName}:{}},N=>i(N),O.signal):w;(C.ok||C.mayExist!==!0)&&(p.current=null),C.ok?(b(C.move),o(C.move.moveId),s.invalidateQueries({queryKey:Ue.list()})):"problem"in C&&C.problem.code==="community_name_taken"?d({field:md,notice:null}):"problem"in C&&C.problem.code==="community_name_reserved"?d({field:hd,notice:null}):d({field:null,notice:bt(C)})}catch{O.signal.aborted?p.current=null:d({field:null,notice:yt})}finally{f.current=null,i(null)}}async function k(){if(f.current){f.current.abort();return}if(r){u(!0);try{const v=await t.cancelHostedCommunityMove(r);v.ok?b(v.move):d({field:null,notice:bt(v)}),s.invalidateQueries({queryKey:Ue.list()})}catch{d({field:null,notice:yt})}finally{u(!1)}}}async function j(){if(r){u(!0),d({field:null,notice:null});try{const v=await t.retryHostedCommunityMoveUpload(r);v.ok?b(v.move):d({field:null,notice:bt(v)})}catch{d({field:null,notice:yt})}finally{u(!1)}}}return{step:x,sending:a,failure:c,clearFieldFailure:()=>d(v=>({...v,field:null})),busy:m,start:y,cancel:k,sendAgain:j,startOver:()=>{o(null),d({field:null,notice:null})}}}function Oj(){var a,i,c;const e=Vi(),t=Dm(),s=xc(t);if(!e||!t||s.isPending||((a=s.data)==null?void 0:a.available)===!1)return null;const r=((i=s.data)==null?void 0:i.available)===!0?s.data:null,o=(r==null?void 0:r.moves)??[];return{allowance:(r==null?void 0:r.allowance)??null,unfinishedMoveId:((c=o.find(Tj))==null?void 0:c.moveId)??null}}const Mj={message:"Your spaces changed. Check the list again."};function _j(){const e=se(),t=oe(),[s,r]=l.useState(null),[o,a]=l.useState(null),[i,c]=l.useState({});function d(u,f){c(p=>{const h={...p};return f?h[u]=f:delete h[u],h})}async function m(u,f){a(u),d(u,null);try{d(u,await f())}catch{d(u,yt)}finally{a(null),await t.invalidateQueries({queryKey:Ue.list()})}}return{confirmingKeep:s,busyId:o,notices:i,askKeep:r,cancelKeep:()=>r(null),keep:u=>m(u.communityId,async()=>{r(null);const f=await e.keepHostedCommunity(u.communityId,u.actions.keep.wouldHold);return f.ok?null:"problem"in f&&f.problem.code==="conflict"?Mj:bt(f)}),restore:u=>m(u.communityId,async()=>{const f=await e.restoreHostedCommunity(u.communityId);return f.ok?null:bt(f)})}}function Io({open:e,onOpenChange:t,step:s,locked:r}){return n.jsx(Ze,{open:e,onOpenChange:o=>r&&!o?void 0:t(o),children:n.jsxs(et,{className:"!min-h-0 sm:max-w-lg",children:[n.jsxs(Ve,{children:[n.jsx(Fe,{children:s.title}),s.description!==void 0&&n.jsx(Qe,{children:s.description})]}),s.body!==void 0&&n.jsx(at,{className:"space-y-4 py-2",children:s.body}),n.jsx(Ot,{className:"gap-2 sm:gap-2",children:s.actions})]})})}function St({notice:e}){if("message"in e)return n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:e.message});const{title:t,detail:s,actionUrl:r,actionLabel:o}=e.problem;return n.jsxs("div",{role:"alert",className:"border-status-warning-border bg-status-warning-bg text-status-warning-fg space-y-2 rounded-md border p-3 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:t}),s&&n.jsx("p",{className:"break-words",children:s}),r&&n.jsxs(M,{type:"button",size:"sm",variant:"outline",onClick:()=>it(r),children:[o??"Open your account",n.jsx(_t,{className:"size-3.5","aria-hidden":!0})]})]})}function Ro(e){const{state:t,name:s}=e;switch(t.kind){case"preparing":return{title:`Setting up ${s}`,description:"Keep this open, or come back later.",body:n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(we,{className:"size-4"})," Setting up…"]}),actions:n.jsx(M,{variant:"outline",onClick:e.onClose,children:"Close"})};case"claim":return{title:`Make ${s} yours`,description:t.withAccount?"Sign in with your DorkOS account in your browser, then come back.":"Sign in or create an account in your browser, then come back.",body:t.notice?n.jsx(St,{notice:t.notice}):void 0,actions:n.jsxs(n.Fragment,{children:[n.jsxs(M,{variant:t.opened?"outline":"default",disabled:t.busy,onClick:e.onOpenClaim,children:[t.opened?"Open it again":"Open in your browser",n.jsx(_t,{className:"size-3.5","aria-hidden":!0})]}),n.jsx(M,{variant:t.opened?"default":"outline",disabled:t.busy,onClick:e.onConfirmClaimed,children:t.busy?"Checking…":"I’ve finished"})]})};case"connecting":return{title:`Connect this DorkOS to ${s}`,description:t.approvalUrl?`Approve this DorkOS on ${s}. This page then moves on.`:"Getting the approval page ready…",body:n.jsxs(n.Fragment,{children:[t.approvalUrl&&!t.notice&&n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(we,{className:"size-4"})," Waiting for your approval"]}),t.notice&&n.jsx(St,{notice:t.notice})]}),actions:t.notice?n.jsx(M,{disabled:t.busy,onClick:e.onRetryConnect,children:"Connect again"}):n.jsxs(M,{disabled:t.busy||!t.approvalUrl,onClick:e.onOpenApproval,children:["Open approval page",n.jsx(_t,{className:"size-3.5","aria-hidden":!0})]})};case"done":return{title:`${s} is ready`,description:e.doneDetail,body:n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(hs,{className:"text-status-success-fg size-4","aria-hidden":!0}),"It’s selected in your spaces."]}),actions:n.jsx(M,{onClick:e.onClose,children:"Done"})}}}function Pj(e){const t=e.usage;if(!t)return null;const{maxActiveMembers:s,maxStorageBytes:r}=e.limits,o=`${t.activeMembers.toLocaleString()}${s!==null?` of ${s.toLocaleString()}`:""} ${t.activeMembers===1&&s===null?"person":"people"}`,a=`${kn(t.storageBytes)}${r!==null?` of ${kn(r)}`:""} of files`;return`${o} · ${a}`}function Lj({community:e,names:t,actions:s,onFinishSetup:r,onOpenMove:o}){const a=s.busyId===e.communityId,i=s.confirmingKeep===e.communityId,c=s.notices[e.communityId],d=Pj(e),m=e.actions.keep.wouldHold.map(f=>t.get(f)??"another space"),u=e.state==="held"||e.state==="deletion_pending"||e.state==="suspended";return n.jsxs("li",{className:"space-y-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:e.name}),e.shortName&&n.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",children:e.shortName})]}),n.jsx(xn,{variant:u?"outline":"secondary",className:u?"border-status-warning-border text-status-warning-fg shrink-0":"shrink-0",children:Cj(e.state)})]}),e.state==="unrecognised"&&n.jsx("p",{className:"text-muted-foreground text-sm",children:"Update DorkOS to see this space’s state."}),e.hold&&n.jsxs("div",{className:"space-y-1 text-sm",children:[n.jsx("p",{children:Nj(e.hold.reason)}),n.jsxs("p",{className:"text-muted-foreground",children:["On hold since ",Ys(e.hold.since),"."]}),e.hold.deletionNoticeAt&&n.jsxs("p",{className:"text-destructive",children:["DorkOS may delete it after ",Ys(e.hold.deletionNoticeAt),". You can export it until then."]})]}),e.deletionAt&&n.jsxs("p",{className:"text-destructive text-sm",children:["It will be deleted for good on ",Ys(e.deletionAt),"."]}),e.notice&&n.jsxs("div",{className:"bg-muted/50 space-y-1 rounded-md p-2 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:e.notice.title}),e.notice.detail&&n.jsx("p",{className:"break-words",children:e.notice.detail}),e.notice.actionUrl&&n.jsxs(M,{size:"sm",variant:"outline",onClick:()=>it(e.notice.actionUrl),children:[e.notice.actionLabel??"Learn more",n.jsx(_t,{className:"size-3.5","aria-hidden":!0})]})]}),d&&n.jsx("p",{className:"text-muted-foreground text-xs tabular-nums",children:d}),i&&n.jsxs("div",{role:"group","aria-label":`Keep ${e.name} open`,className:"space-y-2 text-sm",children:[n.jsx("p",{children:m.length===0?`Keep ${e.name} open? Nothing else changes.`:`Keeping ${e.name} open puts ${m.length===1?"this one":"these"} on hold: ${m.join(", ")}. People can still read ${m.length===1?"it":"them"}.`}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(M,{size:"sm",variant:"outline",onClick:s.cancelKeep,children:"Cancel"}),n.jsx(M,{size:"sm",disabled:a,onClick:()=>void s.keep(e),children:"Keep it open"})]})]}),c&&n.jsx(St,{notice:c}),!i&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.actions.claimLink&&n.jsx(M,{size:"sm",onClick:()=>r(e),children:"Finish setting up"}),e.moveId&&n.jsx(M,{size:"sm",variant:"outline",onClick:()=>o(e.moveId),children:"See the move"}),e.actions.keep.allowed&&n.jsx(M,{size:"sm",variant:"outline",disabled:a,onClick:()=>s.askKeep(e.communityId),children:"Keep this one open"}),e.actions.restore&&n.jsx(M,{size:"sm",variant:"outline",disabled:a,onClick:()=>void s.restore(e),children:a?"Reopening…":"Reopen"})]})]})}function Fj(e){switch(e.state){case"awaiting_upload":return{text:"Uploading the export"};case"importing":return{text:"Moving the history"};case"ready":return{text:"Ready to make yours"};case"claimed":return{text:"Moved"};case"cancelled":return{text:"Cancelled"};case"failed":{const t=ld(e.failureCode??"unrecognised");return{text:t.title,next:t.next}}default:return{text:"Unknown state. Update DorkOS to see more."}}}function $j(e){const t=new Map(e.communities.map(s=>[s.communityId,s.name]));return n.jsxs("div",{className:"space-y-4",children:[e.allowanceText&&n.jsx("p",{className:"text-muted-foreground text-sm",children:e.allowanceText}),e.communities.length>0?n.jsx("ul",{className:"space-y-2",children:e.communities.map(s=>n.jsx(Lj,{community:s,names:t,actions:e.actions,onFinishSetup:e.onFinishSetup,onOpenMove:e.onOpenMove},s.communityId))}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"No spaces yet."}),e.moves.length>0&&n.jsxs("section",{"aria-labelledby":"hosted-moves",className:"space-y-2",children:[n.jsx("h4",{id:"hosted-moves",className:"text-sm font-medium",children:"Recent moves"}),n.jsx("ul",{className:"space-y-2",children:e.moves.map(s=>{const r=Fj(s),o=s.state==="awaiting_upload"||s.state==="importing"||s.state==="ready";return n.jsxs("li",{className:"flex flex-wrap items-start justify-between gap-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"min-w-0 space-y-0.5 text-sm",children:[n.jsx("p",{className:"truncate font-medium",children:s.name}),n.jsx("p",{className:s.state==="failed"?"text-destructive":"text-muted-foreground",children:r.text}),r.next&&n.jsx("p",{className:"text-muted-foreground",children:r.next})]}),o&&n.jsx(M,{size:"sm",variant:"outline",onClick:()=>e.onOpenMove(s.moveId),children:"Continue"})]},s.moveId)})})]})]})}function Bj(e){return e.open?n.jsx(zj,{...e}):null}function zj({open:e,onOpenChange:t,installName:s,onOpenMove:r,onMoveHere:o,onConnected:a}){var h;const i=xc(!0),c=_j(),[d,m]=l.useState(null),u=Co(d,s,a),f=()=>t(!1);let p;if(d)p=Ro({state:u.state,name:d.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:u.openClaim,onConfirmClaimed:u.confirmClaimed,onOpenApproval:u.openApproval,onRetryConnect:u.retryConnect,onClose:f});else{const g=((h=i.data)==null?void 0:h.available)===!0?i.data:null;p={title:"Your spaces",description:"Spaces hosted under your DorkOS account.",body:i.isPending?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading…"}):g?n.jsx($j,{communities:g.communities,moves:g.moves,allowanceText:dd(g.allowance),actions:c,onFinishSetup:m,onOpenMove:x=>{f(),r(x)}}):n.jsx(St,{notice:{message:"Couldn’t reach your DorkOS account. Try again."}}),actions:n.jsxs(n.Fragment,{children:[n.jsx(M,{variant:"outline",onClick:f,children:"Close"}),n.jsx(M,{variant:"outline",onClick:()=>{f(),o()},children:"Move one here"})]})}}return n.jsx(Io,{open:e,onOpenChange:t,step:p})}function Uj(e){switch(e.kind){case"invalid":return{text:ud,error:!0};case"checking":return{text:"Checking…",error:!1};case"available":return{text:"That web address is free.",error:!1};case"taken":return{text:"That web address is taken.",error:!0};case"reserved":return{text:"That web address can’t be used.",error:!0};default:return null}}function pd(e){const t=l.useId(),s=e.webAddressError?{text:e.webAddressError,error:!0}:Uj(e.webAddressStatus);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ie,{htmlFor:`${t}-name`,children:"Space name"}),n.jsx(Je,{id:`${t}-name`,required:!0,maxLength:Aj,autoComplete:"off",value:e.name,disabled:e.disabled,onChange:r=>e.onNameChange(r.target.value)})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs(Ie,{htmlFor:`${t}-address`,children:["Web address ",n.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),n.jsx(Je,{id:`${t}-address`,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,maxLength:32,placeholder:"book-club",value:e.webAddress,disabled:e.disabled,"aria-invalid":(s==null?void 0:s.error)||void 0,"aria-describedby":`${t}-address-hint`,onChange:r=>e.onWebAddressChange(r.target.value)}),n.jsx("p",{id:`${t}-address-hint`,"aria-live":"polite",className:s!=null&&s.error?"text-destructive text-sm":"text-muted-foreground text-sm",children:(s==null?void 0:s.text)??ud})]})]})}const Kj="Your history is here. Send invitations so people can join again.";function Hj(e,t){return{title:"Move a space here",description:"This copies your space’s history and files to DorkOS.",body:n.jsxs("div",{className:"space-y-2 text-sm",children:[n.jsx("p",{children:"Everyone joins again and reconnects their DorkOS."}),n.jsx("p",{className:"text-muted-foreground",children:"Your old space keeps running until you delete it."}),n.jsx("p",{className:"font-medium",children:"First, export the old space:"}),n.jsxs("ol",{className:"text-muted-foreground list-decimal space-y-1 pl-5",children:[n.jsx("li",{children:"Sign in to the old space as its owner."}),n.jsx("li",{children:"Open its Settings."}),n.jsx("li",{children:"Choose Export."}),n.jsx("li",{children:"Enter your password."}),n.jsx("li",{children:"Save the .zip file."})]})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(M,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(M,{onClick:e,children:"I have the file"})]})}}function Wj({file:e,onFileChange:t}){const s=l.useId();return n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ie,{htmlFor:s,children:"Export file"}),n.jsx(Je,{id:s,type:"file",accept:".zip,application/zip",onChange:r=>{var o;return t(((o=r.target.files)==null?void 0:o[0])??null)},className:"cursor-pointer"}),e&&n.jsxs("p",{className:"text-muted-foreground text-sm break-all",children:[e.name,", ",kn(e.size)]})]})}function qj(e){const t=_n(e.webAddress),s=e.file===null||e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved";return{title:"Choose the export",description:"Pick the .zip file, then name the space.",body:n.jsxs("form",{id:e.formId,onSubmit:e.onSubmit,className:"space-y-4",noValidate:!0,children:[n.jsx(Wj,{file:e.file,onFileChange:e.onFileChange}),n.jsx(pd,{name:e.name,onNameChange:e.onNameChange,webAddress:e.webAddress,onWebAddressChange:e.onWebAddressChange,webAddressStatus:e.webAddressStatus,webAddressError:e.failure.field,disabled:!1}),e.failure.notice&&n.jsx(St,{notice:e.failure.notice}),n.jsx(qr,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(M,{type:"button",variant:"outline",onClick:e.onBack,children:"Back"}),n.jsx(M,{type:"submit",form:e.formId,disabled:s,children:"Start moving"})]})}}function gd({label:e,loaded:t,total:s}){const r=s>0?Math.round(t/s*100):0;return n.jsxs("div",{className:"space-y-2",children:[n.jsx(Om,{value:r,"aria-label":e}),n.jsxs("p",{className:"text-muted-foreground text-sm tabular-nums",children:[kn(t)," of ",kn(s)]})]})}function Gj(e,t){return{title:"Getting the file ready",description:"Keep this open. The upload then starts on its own.",body:n.jsx(gd,{label:"Getting the file ready",...e}),actions:n.jsx(M,{variant:"outline",onClick:t,children:"Cancel"})}}function Yj(e){const t=e.report;if(!t)return null;const s=r=>r.toLocaleString();return`${s(t.channels)} ${t.channels===1?"channel":"channels"}, ${s(t.entries)} ${t.entries===1?"message":"messages"} and ${s(t.attachments)} ${t.attachments===1?"file":"files"}.`}function Vj(e,t){const{move:s}=e,r=t.notice?n.jsx(St,{notice:t.notice}):null,o=n.jsx(M,{variant:"outline",disabled:t.busy,onClick:t.onCancelMove,children:"Cancel move"}),a=n.jsx(M,{onClick:t.onStartOver,children:"Start again"}),i=n.jsx(M,{variant:"outline",onClick:t.onClose,children:"Close"});switch(e.kind){case"uploading":{const c=s.upload;return{title:`Uploading ${s.name}`,description:"You can close this window. Keep DorkOS running until it finishes.",body:n.jsxs(n.Fragment,{children:[n.jsx(gd,{label:`Uploading ${s.name}`,loaded:c.sentBytes,total:c.totalBytes}),r]}),actions:o}}case"upload-failed":return e.why==="interrupted"?{title:"The upload didn’t finish",description:"DorkOS still has the file. Send it again to continue.",body:r,actions:n.jsxs(n.Fragment,{children:[o,n.jsx(M,{disabled:t.busy,onClick:t.onSendAgain,children:"Send again"})]})}:e.why==="refused"?{title:"DorkOS didn’t accept the file",description:"The file arrived changed or incomplete.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move, export the old space again, then start again."}),r]}),actions:o}:e.why==="restarted"?{title:"This move has to start again",description:"DorkOS restarted, or the move began on another computer.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move and start again with the same export."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Or finish it on the computer that started it."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"For safety, uploads only work while DorkOS stays running."}),r]}),actions:o}:{title:"The time to upload ran out",description:"Cancel the move, then start again with the same export.",body:r,actions:o};case"importing":{const c=Yj(s);return{title:`Moving ${s.name}`,description:"You can close this window or quit. The move keeps going.",body:n.jsxs(n.Fragment,{children:[n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(we,{className:"size-4"})," Moving your history…"]}),c&&n.jsx("p",{className:"text-sm",children:c}),r]}),actions:n.jsxs(n.Fragment,{children:[o,n.jsx(M,{onClick:t.onClose,children:"Close"})]})}}case"failed":{const c=ld(s.failureCode??"unrecognised");return{title:c.title,description:c.next,body:n.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing was kept. Your old space is unchanged."}),actions:n.jsxs(n.Fragment,{children:[i,a]})}}case"cancelled":return{title:"Move cancelled",description:"Nothing was kept. Your old space is unchanged.",actions:n.jsxs(n.Fragment,{children:[i,a]})};case"unrecognised":return{title:`Moving ${s.name}`,description:"Update DorkOS to see where this move is.",body:r,actions:i}}}function Qj(e){return e.open?n.jsx(Xj,{...e}):null}function Xj({open:e,onOpenChange:t,installName:s,resumeMoveId:r,onConnected:o}){var A,v;const[a,i]=l.useState("explain"),[c,d]=l.useState(null),[m,u]=l.useState(""),[f,p]=l.useState(""),h=Dj(r),g=fd(a==="choose"&&!h.step?f:""),x=((A=h.step)==null?void 0:A.kind)==="ready"?h.step.move:null,b=Co(x?{communityId:x.communityId,name:x.name,communityUrl:x.communityUrl}:null,s,o),y=()=>t(!1);function k(S){S.preventDefault();const I=_n(f);!c||m.trim()===""||!I.valid||h.start({file:c,name:m,shortName:I.value})}let j;return h.sending?j=Gj(h.sending,()=>void h.cancel()):((v=h.step)==null?void 0:v.kind)==="ready"?j=Ro({state:b.state,name:h.step.move.name,doneDetail:Kj,onOpenClaim:b.openClaim,onConfirmClaimed:b.confirmClaimed,onOpenApproval:b.openApproval,onRetryConnect:b.retryConnect,onClose:y}):h.step?j=Vj(h.step,{busy:h.busy,notice:h.failure.notice,onCancelMove:()=>void h.cancel(),onSendAgain:()=>void h.sendAgain(),onStartOver:()=>{h.startOver(),i("choose")},onClose:y}):a==="explain"?j=Hj(()=>i("choose"),y):j=qj({file:c,onFileChange:d,name:m,onNameChange:u,webAddress:f,onWebAddressChange:S=>{p(S),h.clearFieldFailure()},webAddressStatus:g,failure:h.failure,formId:"move-community-form",onSubmit:k,onBack:()=>i("explain")}),n.jsx(Io,{open:e,onOpenChange:t,step:j,locked:h.sending!==null})}function Jj(e){const t=_n(e.webAddress),s=e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved",r=dd(e.allowance);return{title:"Start a space",description:"Share channels with people and agents. You own it.",body:n.jsxs("form",{id:e.formId,onSubmit:e.onSubmit,className:"space-y-4",noValidate:!0,children:[n.jsx(pd,{name:e.name,onNameChange:e.onNameChange,webAddress:e.webAddress,onWebAddressChange:e.onWebAddressChange,webAddressStatus:e.webAddressStatus,webAddressError:e.failure.field,disabled:e.submitting}),r&&n.jsx("p",{className:"text-muted-foreground text-sm",children:r}),e.failure.notice&&n.jsx(St,{notice:e.failure.notice}),n.jsx(qr,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(M,{type:"button",variant:"outline",onClick:e.onCancel,children:"Cancel"}),n.jsx(M,{type:"submit",form:e.formId,disabled:s||e.submitting,children:e.submitting?"Starting…":"Start space"})]})}}function Zj(e){return e.open?n.jsx(ek,{...e}):null}function ek({open:e,onOpenChange:t,installName:s,allowance:r,onConnected:o}){const[a,i]=l.useState(""),[c,d]=l.useState(""),[m,u]=l.useState(null),f=Ij(),p=fd(m?"":c),h=Co(m,s,o),g=()=>t(!1);async function x(y){y.preventDefault();const k=_n(c);if(a.trim()===""||!k.valid||f.submitting)return;const j=await f.submit({name:a,shortName:k.value});j&&u({communityId:j.community.communityId,name:j.community.name,communityUrl:j.community.communityUrl})}const b=m?Ro({state:h.state,name:m.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:h.openClaim,onConfirmClaimed:h.confirmClaimed,onOpenApproval:h.openApproval,onRetryConnect:h.retryConnect,onClose:g}):Jj({name:a,webAddress:c,onNameChange:i,onWebAddressChange:y=>{d(y),f.clearFieldFailure()},webAddressStatus:p,submitting:f.submitting,failure:f.failure,allowance:r,formId:"start-community-form",onSubmit:y=>void x(y),onCancel:g});return n.jsx(Io,{open:e,onOpenChange:t,step:b,locked:f.submitting})}function tk({entry:e,dialog:t,onDialogChange:s,installName:r,onConnected:o}){if(e===null)return null;const a=i=>{i||s(null)};return n.jsxs(n.Fragment,{children:[n.jsx(Zj,{open:(t==null?void 0:t.kind)==="start",onOpenChange:a,installName:r,allowance:e.allowance,onConnected:o}),n.jsx(Qj,{open:(t==null?void 0:t.kind)==="move",onOpenChange:a,installName:r,resumeMoveId:(t==null?void 0:t.kind)==="move"?t.moveId:null,onConnected:o},(t==null?void 0:t.kind)==="move"?t.moveId??"new":"closed"),n.jsx(Bj,{open:(t==null?void 0:t.kind)==="hosted",onOpenChange:a,installName:r,onOpenMove:i=>s({kind:"move",moveId:i}),onMoveHere:()=>s({kind:"move",moveId:e.unfinishedMoveId}),onConnected:o})]})}const nk=.1;function sk(e){if(!(e!=null&&e.available)||e.balance===null)return null;const{allowance:t,purchased:s,denomination:r}=e.balance,o=Mm(t.remainingMicro,t.grantedMicro);if(o===null||o>=nk||!/^\d+$/.test(t.remainingMicro)||!/^\d+$/.test(s.remainingMicro)||BigInt(s.remainingMicro)>0n)return null;const a=_m(Pm(t.remainingMicro,r));return a===null?null:`${a} left`}function rk(e){if(e.state!=="loading")return e.state==="signed-out"?"Not signed in":["Signed in",e.label,e.lowCredits].filter(Boolean).join(" · ")}function ok(){var r;const e=bc(),t=((r=e.data)==null?void 0:r.linked)===!0,s=yc({enabled:t});return e.data===void 0?{state:"loading"}:t?{state:"signed-in",label:e.data.accountLabel,lowCredits:sk(s.data)}:{state:"signed-out"}}function ak(){const e=oe();ce("commands_changed",()=>{e.invalidateQueries({queryKey:["commands"]})})}function xd(e){return e.kind==="agent"?jt("agent",e.agent.projectPath):jt("room",e.room.id)}function Nr(e){return e.kind==="agent"?Ne(e.agent):e.room.kind==="channel"&&e.room.slug?`#${e.room.slug}`:e.room.title}function Oa(e){return`Chats ${e.kind==="agent"?"with":"in"} ${Nr(e)}`}function ik(e){return e.kind==="agent"?`No chats with ${Nr(e)} yet.`:`No chats came from ${Nr(e)}.`}function ck(e){return e.kind==="channel"&&e.slug?`#${e.slug}`:e.title}function lk(e){const t=new Map,s=[...e].sort((r,o)=>{const a=+(r.kind==="dm")-+(o.kind==="dm");return a!==0?a:Number(r.archived)-Number(o.archived)});for(const r of s){const o=ck(r);t.has(o)||t.set(o,r.id)}return t}function dk(e,t){const s=[];e.cwd!==null&&s.push(jt("agent",e.cwd));const r=uk(e,t);return r!==void 0&&s.push(jt("room",r)),s}function uk(e,t){if(e.origin==="room"){if(e.originRoomId!==void 0)return e.originRoomId;if(e.originLabel!==void 0)return t.get(e.originLabel)}}function mk(e,t){const s=Number(e.archived)-Number(t.archived);if(s!==0)return s;const r=Number(Lt(t))-Number(Lt(e));return r!==0?r:t.lastActivityAt.localeCompare(e.lastActivityAt)||t.id.localeCompare(e.id)}function Vs(e){return[...e].sort(mk)}function Ar(e){const t=[e.title];e.slug&&t.push(e.slug);for(const s of e.participants??[])t.push(s.displayName);return t}function hk(){const{data:e,isLoading:t,isError:s}=ks({includeArchived:!0});return l.useMemo(()=>{const r=e??[],o=Vs(r.filter(i=>i.kind==="channel")),a=Vs(r.filter(i=>i.kind==="dm"));return{channels:o,dms:a,unread:Vs([...o,...a].filter(i=>!i.archived&&Lt(i))),isLoading:t,isError:s}},[e,t,s])}const fk=8;function pk(e,t){const s=new Set(Lm(Object.keys(e),t)),r=[];for(const[o,a]of Object.entries(e))a&&s.has(o)&&(a.lifecycle!=="streaming"&&a.lifecycle!=="blocked"||r.push({sessionId:o,lifecycle:a.lifecycle,activity:a.activity??null}));return r.sort((o,a)=>o.lifecycle!==a.lifecycle?o.lifecycle==="blocked"?-1:1:o.sessionId.localeCompare(a.sessionId))}function Ma(e){const t=Date.parse(e.lastActivityAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function gk(e){return!(e.unreadCount===null||e.archived||e.lastActivityAt===e.createdAt)}function xk({sessions:e,rooms:t,unreadRoomIds:s,agents:r,agentActivity:o,excludeSessionIds:a=new Set,limit:i=fk}){const c=e.filter(g=>!a.has(g.id)).map(g=>({kind:"session",key:`session:${g.id}`,lastActivityAt:g.lastActivityAt,session:g})),d=new Set(e.flatMap(g=>g.cwd?[g.cwd]:[])),m=t.filter(gk).map(g=>({kind:"room",key:`room:${g.id}`,lastActivityAt:g.lastActivityAt,room:g})),u=r.flatMap(g=>{if(d.has(g.projectPath))return[];const x=o[g.projectPath];return x?[{kind:"agent",key:`agent:${g.projectPath}`,lastActivityAt:x,agent:g}]:[]}),f=[],p=[];for(const g of[...c,...m,...u])g.kind==="room"&&s.has(g.room.id)?f.push(g):p.push(g);const h=(g,x)=>Ma(x)-Ma(g)||x.key.localeCompare(g.key);return[...f.sort(h),...p.sort(h)].slice(0,i)}const bk=50;function bd(e){const t=[e.id];return e.who&&t.push(e.who),e.cwd&&t.push(e.cwd),t}function yk(e){return e?e.split("/").filter(Boolean).pop()??null:null}function _a(e,t,s){const r=new Map(t.map(o=>[o.projectPath,o]));return e.map(o=>{const a=o.cwd??null,i=a?r.get(a)??null:null,c=Date.parse(o.updatedAt);return{id:o.id,who:i?Ne(i):yk(a),title:vc(o.title),cwd:a,agent:i,origin:o.origin,originLabel:o.originLabel,originRoomId:o.originRoomId,lastActivityAt:o.updatedAt,archived:!Number.isNaN(c)&&c<s}})}function vk(e,t,s,r){const{data:o}=wc(bk),a=ot(p=>p.statuses),i=ot(jc(p=>Object.values(p.sessions))),c=l.useMemo(()=>_a((o==null?void 0:o.sessions)??[],e,r),[o==null?void 0:o.sessions,e,r]),d=l.useMemo(()=>_a(i,e,r),[i,e,r]),m=l.useMemo(()=>[...i,...(o==null?void 0:o.sessions)??[]],[i,o]),u=l.useMemo(()=>{const p=new Map;for(const h of d)p.set(h.id,h);for(const h of c)p.has(h.id)||p.set(h.id,h);return pk(a,m).flatMap(h=>{const g=p.get(h.sessionId);return g?[{session:g,verb:Fm(h.lifecycle,h.activity),signal:h.lifecycle==="blocked"?"needs-you":"working"}]:[]})},[a,d,c,m]),f=l.useMemo(()=>{const p=new Set($m((o==null?void 0:o.sessions)??[]).yours.map(h=>h.id));return xk({sessions:c.filter(h=>p.has(h.id)),rooms:t,unreadRoomIds:s,agents:e,agentActivity:(o==null?void 0:o.agentActivity)??{},excludeSessionIds:new Set(u.map(h=>h.session.id))})},[o,c,t,s,e,u]);return{sessions:c,continueRows:u,recent:f,agentActivity:(o==null?void 0:o.agentActivity)??wk}}const wk=Object.freeze({});function jk(){const{data:e,dataUpdatedAt:t}=De(),s=e!==void 0&&t>Ft,{status:r,url:o}=Bm(e==null?void 0:e.tunnel),a=l.useRef(void 0);l.useEffect(()=>{if(!s)return;const i=a.current;a.current=r,!(i===void 0||i===r)&&(Ho.getState().consumeSuppression()||zm(Ho.getState().report)||(r==="reconnecting"?ae.warning("Remote access is reconnecting",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS until then."}):r==="off"?ae.error("Remote access turned off",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS now."}):o&&ae.success("Remote access is on",{id:"tunnel-status",description:o})))},[s,r,o])}const Ye={copyLink:"copyRemoteLink",showQr:"showRemoteQr",turnOn:"turnRemoteAccessOn",turnOff:"turnRemoteAccessOff"},on={copyLink:11,showQr:12,turnOff:13,turnOn:11};function kk(e,t,s){return(e==="connected"||e==="reconnecting"||e==="asleep")&&t?[{id:"remote-access-copy",label:"Copy remote link",icon:"Copy",action:Ye.copyLink,category:"quick-action",priority:on.copyLink,keywords:["remote","tunnel","url","address","phone","share"]},{id:"remote-access-qr",label:"Show QR code",icon:"QrCode",action:Ye.showQr,category:"quick-action",priority:on.showQr,keywords:["remote","tunnel","scan","phone"]},{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:Ye.turnOff,category:"quick-action",priority:on.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:e==="asleep"||e==="blocked"?[{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:Ye.turnOff,category:"quick-action",priority:on.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:s&&(e==="off"||e==="error")?[{id:"remote-access-on",label:"Turn remote access on",icon:"Globe",action:Ye.turnOn,category:"quick-action",priority:on.turnOn,keywords:["remote","tunnel","ngrok","phone","start"]}]:[]}function Sk(){const{state:e,url:t,isSetUp:s}=kc();return l.useMemo(()=>kk(e,t,s),[e,t,s])}const Kn={usageKey:null,lastActivityAt:null,waiting:!1,demoted:!1,scopes:[]};function Pa(e){return{usageKey:jt("room",e.id),lastActivityAt:e.lastActivityAt,waiting:Lt(e),demoted:e.archived,scopes:[]}}function Ck(e,t){const{data:s,isLoading:r}=Ss(),o=hk(),{sessions:a}=Sc(),i=l.useMemo(()=>!a||!e?null:Um(a,e)[0]??null,[a,e]),{data:c}=Ax(e,i==null?void 0:i.id,i==null?void 0:i.runtime),d=vs("command-palette.items"),m=Cc(),u=l.useMemo(()=>m.map(E=>({id:E.id,label:E.title,href:Nc(E.extensionId,E.path),icon:E.icon})),[m]),f=l.useMemo(()=>d.filter(E=>E.category==="feature"),[d]),p=Sk(),h=l.useMemo(()=>[...d.filter(E=>E.category==="quick-action"),...p],[d,p]),g=l.useMemo(()=>Km.flatMap(E=>{const w=h.find(C=>C.id===E);return w?[w]:[]}),[h]),x=l.useMemo(()=>(s==null?void 0:s.agents)??[],[s]),b=l.useMemo(()=>new Set(o.unread.map(E=>E.id)),[o.unread]),y=l.useMemo(()=>[...o.channels,...o.dms],[o.channels,o.dms]),k=l.useMemo(()=>Hm(t),[t]),{sessions:j,continueRows:A,recent:v,agentActivity:S}=vk(x,y,b,k),I=l.useMemo(()=>lk(y),[y]),D=l.useMemo(()=>c?c.commands.map(E=>({name:E.fullCommand,description:E.description})):[],[c]),O=l.useMemo(()=>{const E=[];for(const w of x)E.push({id:w.id,name:w.name,type:"agent",keywords:[w.projectPath,w.id],usageKey:jt("agent",w.projectPath),lastActivityAt:S[w.projectPath]??null,waiting:!1,demoted:!1,scopes:[],data:w});for(const w of j)E.push({id:w.id,name:w.title,type:"session",keywords:bd(w),usageKey:jt("session",w.id),lastActivityAt:w.lastActivityAt,waiting:!1,demoted:!1,scopes:dk(w,I),data:w});for(const w of f)E.push({id:w.id,name:w.label,type:"feature",keywords:w.keywords,...Kn,data:w});for(const w of D)E.push({id:`cmd-${w.name}`,name:w.name,type:"command",keywords:w.description?[w.description]:void 0,...Kn,data:w});for(const w of h)E.push({id:w.id,name:w.label,type:"quick-action",keywords:w.keywords,...Kn,data:w});for(const w of o.channels)E.push({id:w.id,name:Wm(w),type:"room",keywords:Ar(w),...Pa(w),data:w});for(const w of o.dms)E.push({id:w.id,name:w.title,type:"dm",keywords:Ar(w),...Pa(w),data:w});for(const w of u)E.push({id:w.id,name:w.label,type:"page",keywords:["add-on","extension"],...Kn,data:w});return E},[x,S,j,D,f,h,o.channels,o.dms,I,u]);return{allAgents:x,newActions:g,rooms:o,sessions:j,continueRows:A,recent:v,searchableItems:O,isLoading:r}}function Nk(){const e=B(a=>a.toggleGlobalPalette),t=B(a=>a.setGlobalPaletteOpen),s=B(a=>a.globalPaletteOpen),{close:r}=We(),{close:o}=Zr();return l.useEffect(()=>{const a=i=>{(i.metaKey||i.ctrlKey)&&i.key==="k"&&(i.preventDefault(),s||(r(),o()),e())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,r,o,s]),{globalPaletteOpen:s,setGlobalPaletteOpen:t,toggleGlobalPalette:e}}function ct(e){return Array.isArray?Array.isArray(e):vd(e)==="[object Array]"}function Ak(e){if(typeof e=="string")return e;if(typeof e=="bigint")return e.toString();const t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Er(e){return e==null?"":Ak(e)}function ye(e){return typeof e=="string"}function Xn(e){return typeof e=="number"}function Ek(e){return e===!0||e===!1||Ik(e)&&vd(e)=="[object Boolean]"}function yd(e){return typeof e=="object"}function Ik(e){return yd(e)&&e!==null}function Ee(e){return e!=null}function Hn(e){return!e.trim().length}function vd(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Rk="Incorrect 'index' type",Ir="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Tk=e=>`Invalid value for key ${e}`,Dk=e=>`Pattern length exceeds max of ${e}.`,Ok=e=>`Missing ${e} property in key`,Mk=e=>`Property 'weight' in key '${e}' must be a positive integer`,_k="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",La=Object.prototype.hasOwnProperty;var Pk=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{const r=wd(s);this._keys.push(r),this._keyMap[r.id]=r,t+=r.weight}),this._keys.forEach(s=>{s.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function wd(e){let t=null,s=null,r=null,o=1,a=null;if(ye(e)||ct(e))r=e,t=Fa(e),s=Jn(e);else{if(!La.call(e,"name"))throw new Error(Ok("name"));const i=e.name;if(r=i,La.call(e,"weight")&&e.weight!==void 0&&(o=e.weight,o<=0))throw new Error(Mk(Jn(i)));t=Fa(i),s=Jn(i),a=e.getFn??null}return{path:t,id:s,weight:o,src:r,getFn:a}}function Fa(e){return ct(e)?e:e.split(".")}function Jn(e){return ct(e)?e.join("."):e}function Lk(e,t){const s=[];let r=!1;const o=(a,i,c,d)=>{if(Ee(a))if(!i[c])s.push(d!==void 0?{v:a,i:d}:a);else{const m=a[i[c]];if(!Ee(m))return;if(c===i.length-1&&(ye(m)||Xn(m)||Ek(m)||typeof m=="bigint"))s.push(d!==void 0?{v:Er(m),i:d}:Er(m));else if(ct(m)){r=!0;for(let u=0,f=m.length;u<f;u+=1)o(m[u],i,c+1,u)}else i.length&&o(m,i,c+1,d)}};return o(e,ye(t)?t.split("."):t,0),r?s:s[0]}const Fk={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},$k={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Bk={location:0,threshold:.6,distance:100},zk={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:Lk,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},W=Object.freeze({...$k,...Fk,...Bk,...zk});function Uk(e){return e>=9&&e<=13||e===32||e===160}function Kk(e=1,t=3){const s=new Map,r=Math.pow(10,t);return{get(o){let a=0,i=!1;for(let d=0;d<o.length;d++)Uk(o.charCodeAt(d))?i=!1:i||(a++,i=!0);if(a===0&&(a=1),s.has(a))return s.get(a);const c=Math.round(r/Math.pow(a,.5*e))/r;return s.set(a,c),c},clear(){s.clear()}}}var To=class{constructor({getFn:e=W.getFn,fieldNormWeight:t=W.fieldNormWeight}={}){this.norm=Kk(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,s)=>{this._keysMap[t.id]=s})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const e=this.docs.length;this.records=new Array(e);let t=0;if(ye(this.docs[0]))for(let s=0;s<e;s++){const r=this._createStringRecord(this.docs[s],s);r&&(this.records[t++]=r)}else for(let s=0;s<e;s++)this.records[t++]=this._createObjectRecord(this.docs[s],s);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw new Error(Ir);if(ye(e)){const r=this._createStringRecord(e,t);return r&&this.records.push(r),r}const s=this._createObjectRecord(e,t);return this.records.push(s),s}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error(Ir);for(let t=0,s=this.records.length;t<s;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,s=this.records.length;t<s;t+=1)this.records[t].i>e&&(this.records[t].i-=1)}removeAll(e){const t=new Set;for(const r of e)Number.isInteger(r)&&r>=0&&t.add(r);if(t.size===0)return;this.records=this.records.filter(r=>!t.has(r.i));const s=Array.from(t).sort((r,o)=>r-o);for(const r of this.records){let o=0,a=s.length;for(;o<a;){const i=o+a>>>1;s[i]<r.i?o=i+1:a=i}r.i-=o}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!Ee(e)||Hn(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){const s={i:t,$:{}};for(let r=0,o=this.keys.length;r<o;r++){const a=this.keys[r],i=a.getFn?a.getFn(e):this.getFn(e,a.path);if(Ee(i)){if(ct(i)){const c=[];for(let d=0,m=i.length;d<m;d+=1){const u=i[d];if(Ee(u)){if(ye(u)){if(!Hn(u)){const f={v:u,i:d,n:this.norm.get(u)};c.push(f)}}else if(Ee(u.v)){const f=ye(u.v)?u.v:Er(u.v);if(!Hn(f)){const p={v:f,i:u.i,n:this.norm.get(f)};c.push(p)}}}}s.$[r]=c}else if(ye(i)&&!Hn(i)){const c={v:i,n:this.norm.get(i)};s.$[r]=c}}}return s}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function jd(e,t,{getFn:s=W.getFn,fieldNormWeight:r=W.fieldNormWeight}={}){const o=new To({getFn:s,fieldNormWeight:r});return o.setKeys(e.map(wd)),o.setSources(t),o.create(),o}function Hk(e,{getFn:t=W.getFn,fieldNormWeight:s=W.fieldNormWeight}={}){const{keys:r,records:o}=e,a=new To({getFn:t,fieldNormWeight:s});return a.setKeys(r),a.setIndexRecords(o),a}function Wk(e=[],t=W.minMatchCharLength){const s=[];let r=-1,o=-1,a=0;for(let i=e.length;a<i;a+=1){const c=e[a];c&&r===-1?r=a:!c&&r!==-1&&(o=a-1,o-r+1>=t&&s.push([r,o]),r=-1)}return e[a-1]&&a-r>=t&&s.push([r,a-1]),s}function qk(e,t,s,{location:r=W.location,distance:o=W.distance,threshold:a=W.threshold,findAllMatches:i=W.findAllMatches,minMatchCharLength:c=W.minMatchCharLength,includeMatches:d=W.includeMatches,ignoreLocation:m=W.ignoreLocation}={}){if(t.length>32)throw new Error(Dk(32));const u=t.length,f=e.length,p=Math.max(0,Math.min(r,f));let h=a,g=p;const x=(O,E)=>{const w=O/u;if(m)return w;const C=Math.abs(p-E);return o?w+C/o:C?1:w},b=c>1||d,y=b?Array(f):[];let k;for(;(k=e.indexOf(t,g))>-1;){const O=x(0,k);if(h=Math.min(O,h),g=k+u,b){let E=0;for(;E<u;)y[k+E]=1,E+=1}}g=-1;let j=[],A=1,v=0,S=u+f;const I=1<<u-1;for(let O=0;O<u;O+=1){let E=0,w=S;for(;E<w;)x(O,p+w)<=h?E=w:S=w,w=Math.floor((S-E)/2+E);S=w;let C=Math.max(1,p-w+1);const N=i?f:Math.min(p+w,f)+u,T=Array(N+2);T[N+1]=(1<<O)-1;for(let R=N;R>=C;R-=1){const _=R-1,P=s[e[_]];if(T[R]=(T[R+1]<<1|1)&P,O&&(T[R]|=(j[R+1]|j[R])<<1|1|j[R+1]),T[R]&I&&(A=x(O,_),A<=h)){if(h=A,g=_,v=O,g<=p)break;C=Math.max(1,2*p-g)}}if(x(O+1,p)>h)break;j=T}if(b&&g>=0){const O=Math.min(f-1,g+u-1+v);for(let E=g;E<=O;E+=1)s[e[E]]&&(y[E]=1)}const D={isMatch:g>=0,score:Math.max(.001,A)};if(b){const O=Wk(y,c);O.length?d&&(D.indices=O):D.isMatch=!1}return D}function Gk(e){const t={};for(let s=0,r=e.length;s<r;s+=1){const o=e.charAt(s);t[o]=(t[o]||0)|1<<r-s-1}return t}function Do(e){if(e.length<=1)return e;e.sort((s,r)=>s[0]-r[0]||s[1]-r[1]);const t=[e[0]];for(let s=1,r=e.length;s<r;s+=1){const o=t[t.length-1],a=e[s];a[0]<=o[1]+1?o[1]=Math.max(o[1],a[1]):t.push(a)}return t}const kd={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},Yk=new RegExp("["+Object.keys(kd).join("")+"]","g"),Sn=typeof String.prototype.normalize=="function"?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(Yk,t=>kd[t]):e=>e;var Oo=class{constructor(e,{location:t=W.location,threshold:s=W.threshold,distance:r=W.distance,includeMatches:o=W.includeMatches,findAllMatches:a=W.findAllMatches,minMatchCharLength:i=W.minMatchCharLength,isCaseSensitive:c=W.isCaseSensitive,ignoreDiacritics:d=W.ignoreDiacritics,ignoreLocation:m=W.ignoreLocation}={}){if(this.options={location:t,threshold:s,distance:r,includeMatches:o,findAllMatches:a,minMatchCharLength:i,isCaseSensitive:c,ignoreDiacritics:d,ignoreLocation:m},e=c?e:e.toLowerCase(),e=d?Sn(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const u=(p,h)=>{this.chunks.push({pattern:p,alphabet:Gk(p),startIndex:h})},f=this.pattern.length;if(f>32){let p=0;const h=f%32,g=f-h;for(;p<g;)u(this.pattern.substr(p,32),p),p+=32;if(h){const x=f-32;u(this.pattern.substr(x),x)}}else u(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=s?Sn(e):e,this.pattern===e){if(e.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const g={isMatch:!0,score:0};return r&&(g.indices=[[0,e.length-1]]),g}const{location:o,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,ignoreLocation:m}=this.options,u=[];let f=0,p=!1;this.chunks.forEach(({pattern:g,alphabet:x,startIndex:b})=>{const{isMatch:y,score:k,indices:j}=qk(e,g,x,{location:o+b,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,includeMatches:r,ignoreLocation:m});y&&(p=!0),f+=k,y&&j&&u.push(...j)});const h={isMatch:p,score:p?f/this.chunks.length:1};return p&&r&&(h.indices=Do(u)),h}};const Vk=new Set(["fuzzy","include"]);function Qk(e){return e.startsWith("inverse")}const Rr=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:"exact",search(t){const s=t===e;return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:"include",search(t){let s=0,r;const o=[],a=e.length;for(;(r=t.indexOf(e,s))>-1;)s=r+a,o.push([r,s-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:"prefix-exact",search(t){const s=t.startsWith(e);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:"inverse-prefix-exact",search(t){const s=!t.startsWith(e);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:"inverse-suffix-exact",search(t){const s=!t.endsWith(e);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:"suffix-exact",search(t){const s=t.endsWith(e);return{isMatch:s,score:s?0:1,indices:[t.length-e.length,t.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:"inverse-exact",search(t){const s=t.indexOf(e)===-1;return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{const s=new Oo(e,{location:t.location??W.location,threshold:t.threshold??W.threshold,distance:t.distance??W.distance,includeMatches:t.includeMatches??W.includeMatches,findAllMatches:t.findAllMatches??W.findAllMatches,minMatchCharLength:t.minMatchCharLength??W.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??W.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??W.ignoreDiacritics,ignoreLocation:t.ignoreLocation??W.ignoreLocation});return{type:"fuzzy",search(r){return s.searchIn(r)}}}}],$a=Rr.length,Xk="\0",Jk="|";function Zk(e){const t=[],s=e.length;let r=0;for(;r<s;){for(;r<s&&e[r]===" ";)r++;if(r>=s)break;let o=r;for(;o<s&&e[o]!==" "&&e[o]!=='"';)o++;if(o<s&&e[o]==='"'){for(o++;o<s;){if(e[o]==='"'){const a=o+1;if(a>=s||e[a]===" "){o++;break}if(e[a]==="$"&&(a+1>=s||e[a+1]===" ")){o+=2;break}}o++}t.push(e.substring(r,o)),r=o}else{for(;o<s&&e[o]!==" ";)o++;t.push(e.substring(r,o)),r=o}}return t}function Ba(e,t){const s=e.match(t);return s?s[1]:null}function e0(e,t={}){return e.replace(/\\\|/g,Xk).split(Jk).map(s=>{const r=Zk(s.replace(/\u0000/g,"|").trim()).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=r.length;a<i;a+=1){const c=r[a];let d=!1,m=-1;for(;!d&&++m<$a;){const u=Rr[m],f=Ba(c,u.multiRegex);f&&(o.push(u.create(f,t)),d=!0)}if(!d)for(m=-1;++m<$a;){const u=Rr[m],f=Ba(c,u.singleRegex);if(f){o.push(u.create(f,t));break}}}return o})}var t0=class{constructor(e,{isCaseSensitive:t=W.isCaseSensitive,ignoreDiacritics:s=W.ignoreDiacritics,includeMatches:r=W.includeMatches,minMatchCharLength:o=W.minMatchCharLength,ignoreLocation:a=W.ignoreLocation,findAllMatches:i=W.findAllMatches,location:c=W.location,threshold:d=W.threshold,distance:m=W.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r,minMatchCharLength:o,findAllMatches:i,ignoreLocation:a,location:c,threshold:d,distance:m},e=t?e:e.toLowerCase(),e=s?Sn(e):e,this.pattern=e,this.query=e0(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:r,ignoreDiacritics:o}=this.options;e=r?e:e.toLowerCase(),e=o?Sn(e):e;let a=0;const i=[];let c=0,d=!1;for(let m=0,u=t.length;m<u;m+=1){const f=t[m];i.length=0,a=0,d=!1;for(let p=0,h=f.length;p<h;p+=1){const g=f[p],{isMatch:x,indices:b,score:y}=g.search(e);if(x)a+=1,c+=y,Qk(g.type)&&(d=!0),s&&(Vk.has(g.type)?i.push(...b):i.push(b));else{c=0,a=0,i.length=0,d=!1;break}}if(a){const p={isMatch:!0,score:c/a};return d&&(p.hasInverse=!0),s&&(p.indices=Do(i)),p}}return{isMatch:!1,score:1}}};const Tr=[];function Mo(...e){Tr.push(...e)}function ls(e,t){for(let s=0,r=Tr.length;s<r;s+=1){const o=Tr[s];if(o.condition(e,t))return new o(e,t)}return new Oo(e,t)}const ds={AND:"$and",OR:"$or"},Dr={PATH:"$path",PATTERN:"$val"},Or=e=>!!(e[ds.AND]||e[ds.OR]),n0=e=>!!e[Dr.PATH],s0=e=>!ct(e)&&yd(e)&&!Or(e),za=e=>({[ds.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Sd(e,t,{auto:s=!0}={}){const r=o=>{if(ye(o)){const d={keyId:null,pattern:o};return s&&(d.searcher=ls(o,t)),d}const a=Object.keys(o),i=n0(o);if(!i&&a.length>1&&!Or(o))return r(za(o));if(s0(o)){const d=i?o[Dr.PATH]:a[0],m=i?o[Dr.PATTERN]:o[d];if(!ye(m))throw new Error(Tk(d));const u={keyId:Jn(d),pattern:m};return s&&(u.searcher=ls(m,t)),u}const c={children:[],operator:a[0]};return a.forEach(d=>{const m=o[d];ct(m)&&m.forEach(u=>{c.children.push(r(u))})}),c};return Or(e)||(e=za(e)),r(e)}function Mr(e,{ignoreFieldNorm:t=W.ignoreFieldNorm}){let s=1;return e.forEach(({key:r,norm:o,score:a})=>{const i=r?r.weight:null;s*=Math.pow(a===0&&i?Number.EPSILON:a,(i||1)*(t?1:o))}),s}function r0(e,{ignoreFieldNorm:t=W.ignoreFieldNorm}){e.forEach(s=>{s.score=Mr(s.matches,{ignoreFieldNorm:t})})}var o0=class{constructor(e,t){this.limit=e,this.heap=[],this.comparator=t}get size(){return this.heap.length}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):this.comparator(e,this.heap[0])<0&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(e){const t=this.heap;for(;e>0;){const s=e-1>>1;if(this.comparator(t[e],t[s])<=0)break;const r=t[e];t[e]=t[s],t[s]=r,e=s}}_sinkDown(e){const t=this.heap,s=t.length;let r=e;do{e=r;const o=2*e+1,a=2*e+2;if(o<s&&this.comparator(t[o],t[r])>0&&(r=o),a<s&&this.comparator(t[a],t[r])>0&&(r=a),r!==e){const i=t[e];t[e]=t[r],t[r]=i}}while(r!==e)}};function a0(e){const t=[];return e.matches.forEach(s=>{if(!Ee(s.indices)||!s.indices.length)return;const r={indices:s.indices,value:s.value};s.key&&(r.key=s.key.id),s.idx>-1&&(r.refIndex=s.idx),t.push(r)}),t}function i0(e,t,{includeMatches:s=W.includeMatches,includeScore:r=W.includeScore}={}){return e.map(o=>{const{idx:a}=o,i={item:t[a],refIndex:a};return s&&(i.matches=a0(o)),r&&(i.score=o.score),i})}const c0=/[\p{L}\p{M}\p{N}_]+/gu,Ua=new WeakSet;function l0(e){Ua.has(e)||(Ua.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function d0(e){if(typeof e=="function"){let t=!1;return s=>{const r=e(s);if(!t&&(t=!0,!Array.isArray(r)||r.some(o=>typeof o!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(r)?"array containing non-strings":typeof r}.`);return r}}return e instanceof RegExp?(e.global||l0(e),t=>t.match(e)||[]):t=>t.match(c0)||[]}function _r({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const r=d0(s);return{tokenize(o){return e||(o=o.toLowerCase()),t&&(o=Sn(o)),r(o)}}}var u0=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=_r({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});const s=this.analyzer.tokenize(e),{df:r,fieldCount:o}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const a of s){this.termSearchers.push(new Oo(a,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));const i=r.get(a)||0,c=Math.log(1+(o-i+.5)/(i+.5));this.idfWeights.push(c)}this.combineAll=t.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};const t=[];let s=0,r=0,o=0,a=0;const i=this.combineAll&&!this.useMask?new Set:null;for(let m=0;m<this.termSearchers.length;m++){const u=this.termSearchers[m].searchIn(e),f=this.idfWeights[m];r+=f,u.isMatch&&(o++,s+=f*(1-u.score),u.indices&&t.push(...u.indices),this.combineAll&&(this.useMask?a|=1<<m:i.add(m)))}if(o===0)return{isMatch:!1,score:1};const c=r>0?1-s/r:0,d={isMatch:!0,score:Math.max(.001,c)};return this.options.includeMatches&&t.length&&(d.indices=Do(t)),this.combineAll&&(this.useMask?d.matchedMask=a:d.matchedTerms=i,d.termCount=this.numTerms),d}};function Qs(e,t,s,r){const o=r.tokenize(t);if(!o.length)return;e.fieldCount++,e.docFieldCount.set(s,(e.docFieldCount.get(s)||0)+1);const a=new Set(o);let i=e.docTermFieldHits.get(s);i||(i=new Map,e.docTermFieldHits.set(s,i));for(const c of a)i.set(c,(i.get(c)||0)+1),e.df.set(c,(e.df.get(c)||0)+1)}function Cd(e,t,s,r){const{i:o,v:a,$:i}=t;if(a!==void 0){Qs(e,a,o,r);return}if(i)for(let c=0;c<s;c++){const d=i[c];if(d)if(Array.isArray(d))for(const m of d)Qs(e,m.v,o,r);else Qs(e,d.v,o,r)}}function m0(e,t,s){const r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const o of e)Cd(r,o,t,s);return r}function h0(e,t,s,r){Cd(e,t,s,r)}function f0(e,t){const s=e.docFieldCount.get(t);if(s===void 0)return;e.fieldCount-=s,e.docFieldCount.delete(t);const r=e.docTermFieldHits.get(t);if(r){for(const[o,a]of r){const i=(e.df.get(o)||0)-a;i<=0?e.df.delete(o):e.df.set(o,i)}e.docTermFieldHits.delete(t)}}function Ka(e,t){if(t.length===0)return;const s=Array.from(new Set(t)).sort((c,d)=>c-d);for(const c of s)f0(e,c);const r=c=>{let d=0,m=s.length;for(;d<m;){const u=d+m>>>1;s[u]<c?d=u+1:m=u}return c-d},o=s[0],a=new Map;for(const[c,d]of e.docFieldCount)a.set(c>o?r(c):c,d);e.docFieldCount=a;const i=new Map;for(const[c,d]of e.docTermFieldHits)i.set(c>o?r(c):c,d);e.docTermFieldHits=i}var lt=class{constructor(e,t,s){this.options={...W,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Pk(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,s),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=ls(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof To))throw new Error(Rk);if(this._myIndex=t||jd(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const s=_r({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=m0(this._myIndex.records,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}add(e){if(!Ee(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const s=_r({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});h0(this._invertedIndex,t,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}remove(e=()=>!1){const t=[],s=[];for(let r=0,o=this._docs.length;r<o;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),s.push(r));if(s.length){this._invertedIndex&&Ka(this._invertedIndex,s);const r=new Set(s);this._docs=this._docs.filter((o,a)=>!r.has(a)),this._myIndex.removeAll(s),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw new Error(Ir);this._invertedIndex&&Ka(this._invertedIndex,[e]);const t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(e=>this._keyStore.get(e.id)||e)}search(e,t){const{limit:s=-1}=t||{},{includeMatches:r,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;if(ye(e)&&!e.trim()){let p=this._docs.map((h,g)=>({item:h,refIndex:g}));return Xn(s)&&s>-1&&(p=p.slice(0,s)),p}const d=a&&Xn(s)&&s>0&&ye(e),m=i,u=(p,h)=>m(p,h)||p.idx-h.idx;let f;if(d){const p=new o0(s,u);ye(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:c}),f=p.extractSorted()}else f=ye(e)?ye(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),r0(f,{ignoreFieldNorm:c}),a&&f.sort(ye(e)?u:m),Xn(s)&&s>-1&&(f=f.slice(0,s));return i0(f,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=t?null:[];return a.forEach(({v:c,i:d,n:m})=>{if(!Ee(c))return;const u=r.searchIn(c);if(u.isMatch){const f={score:u.score,value:c,norm:m,indices:u.indices};o&&(f.matchedMask=u.matchedMask,f.matchedTerms=u.matchedTerms,f.termCount=u.termCount);const p=[f];if(!o||this._coversAllTokens(p)){const h={item:c,idx:d,matches:p};t?(h.score=Mr(h.matches,{ignoreFieldNorm:s}),t.insert(h)):i.push(h)}}}),i}_searchLogical(e){const t=Sd(e,this.options),s=this._normalizedKeys(),r=(c,d,m)=>{if(!("children"in c)){const{keyId:h,searcher:g}=c;let x;return h===null?(x=[],s.forEach((b,y)=>{x.push(...this._findMatches({key:b,value:d[y],searcher:g}))})):x=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(d,h),searcher:g}),x&&x.length?[{idx:m,item:d,matches:x}]:[]}const{children:u,operator:f}=c,p=[];for(let h=0,g=u.length;h<g;h+=1){const x=u[h],b=r(x,d,m);if(b.length)p.push(...b);else if(f===ds.AND)return[]}return p},o=this._myIndex.records,a=new Map,i=[];return o.forEach(({$:c,i:d})=>{if(Ee(c)){const m=r(t,c,d);m.length&&(a.has(d)||(a.set(d,{idx:d,item:c,matches:[]}),i.push(a.get(d))),m.forEach(({matches:u})=>{a.get(d).matches.push(...u)}))}}),i}_searchObjectList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=this._normalizedKeys(),c=t?null:[];return a.forEach(({$:d,i:m})=>{if(!Ee(d))return;const u=[];let f=!1,p=!1;if(i.forEach((h,g)=>{const x=this._findMatches({key:h,value:d[g],searcher:r});x.length?(u.push(...x),x[0].hasInverse&&(p=!0)):f=!0}),!(p&&f)&&u.length&&(!o||this._coversAllTokens(u))){const h={idx:m,item:d,matches:u};t?(h.score=Mr(h.matches,{ignoreFieldNorm:s}),t.insert(h)):c.push(h)}}),c}_findMatches({key:e,value:t,searcher:s}){if(!Ee(t))return[];const r=[];if(ct(t))t.forEach(({v:o,i:a,n:i})=>{if(!Ee(o))return;const c=s.searchIn(o);if(c.isMatch){const d={score:c.score,key:e,value:o,idx:a,norm:i,indices:c.indices,hasInverse:c.hasInverse};c.termCount!==void 0&&(d.matchedMask=c.matchedMask,d.matchedTerms=c.matchedTerms,d.termCount=c.termCount),r.push(d)}});else{const{v:o,n:a}=t,i=s.searchIn(o);if(i.isMatch){const c={score:i.score,key:e,value:o,norm:a,indices:i.indices,hasInverse:i.hasInverse};i.termCount!==void 0&&(c.matchedMask=i.matchedMask,c.matchedTerms=i.matchedTerms,c.termCount=i.termCount),r.push(c)}}return r}_coversAllTokens(e){const t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let r=0;for(let o=0;o<e.length;o++)r|=e[o].matchedMask||0;return r===2**t-1}const s=new Set;for(let r=0;r<e.length;r++){const o=e[r].matchedTerms;if(o)for(const a of o)s.add(a)}return s.size===t}};lt.version="7.5.0";lt.createIndex=jd;lt.parseIndex=Hk;lt.config=W;lt.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error(_k);return ls(e,{...W,...s}).searchIn(t)};lt.parseQuery=Sd;Mo(t0);Mo(u0);lt.use=function(...e){e.forEach(t=>Mo(t))};var p0=lt;const g0=.02,Nd=.5,Ad=.35,Ed=.15,x0=1+Nd+Ad+Ed,b0=4320*60*1e3,y0=3,v0=1440*60*1e3,w0=.15,j0={lastUsedAt:null,useCount:0};function _o(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function Id(e,t){return!Number.isFinite(e)||e<=0?1:_o(Math.pow(2,-e/t))}function k0(e,t){const s=e.lastUsedAt===null?0:Id(t-e.lastUsedAt,b0),r=Math.max(0,e.useCount),o=r===0?0:r/(r+y0);return _o((s+o)/2)}function S0(e,t){const s=e.distance===null?1:_o(Math.pow(2,-Math.max(0,e.distance)/g0)),r=k0(e.usage,t),o=e.lastActivityAt===null?0:Id(t-e.lastActivityAt,v0),a=1+(e.waiting?Nd:0)+Ad*r+Ed*o;return{score:s*a/x0,signals:{relevance:s,frecency:r,recency:o}}}function C0(e,t){return e.map(s=>{const{score:r,signals:o}=S0(s,t);return{key:s.key,item:s.item,score:r,signals:o,demoted:s.demoted}}).sort((s,r)=>Number(s.demoted)-Number(r.demoted)||r.score-s.score||s.key.localeCompare(r.key))}function N0(e,t){const s=[...e],r=e[0],o=e[1];return t.queried?!r||!o?{best:null,rest:s}:r.demoted||r.score<=0?{best:null,rest:s}:(r.score-o.score)/r.score<w0?{best:null,rest:s}:{best:r,rest:s.slice(1)}:{best:null,rest:s}}function A0(e,t){const s=[];for(const r of e){const o=t(r),a=s[s.length-1];a&&a.label===o?a.rows.push(r):s.push({label:o,rows:[r]})}return s}const E0={keys:["name","keywords"],includeMatches:!0,includeScore:!0,threshold:.3,distance:100,minMatchCharLength:1};function I0(e,t,s){const{usage:r,now:o,scope:a}=s,{prefix:i,term:c}=l.useMemo(()=>a===null?R0(t):{prefix:null,term:t},[t,a]),d=l.useMemo(()=>{if(a===null)return e;const x=xd(a);return e.filter(b=>b.scopes.includes(x))},[e,a]),m=l.useMemo(()=>i==="#"?d.filter(x=>x.type==="room"):i==="@"?d.filter(x=>x.type==="agent"||x.type==="dm"):i===">"?d.filter(x=>x.type==="command"):d,[d,i]),u=l.useMemo(()=>new p0(m,E0),[m]),f=l.useMemo(()=>{const x=(b,y,k)=>{const j=b.lastActivityAt===null?NaN:Date.parse(b.lastActivityAt);return{key:`${b.type}:${b.id}`,item:{item:b,matches:y},distance:k,usage:(b.usageKey===null?void 0:r[b.usageKey])??j0,lastActivityAt:Number.isNaN(j)?null:j,waiting:b.waiting,demoted:b.demoted}};return c?u.search(c).map(b=>x(b.item,b.matches,b.score??0)):m.map(b=>x(b,void 0,null))},[u,c,m,r]),p=l.useMemo(()=>C0(f,o),[f,o]),{best:h,rest:g}=l.useMemo(()=>N0(p,{queried:c.length>0}),[p,c]);return{bestMatch:h,rows:g,prefix:i,term:c}}function R0(e){return e.startsWith("#")?{prefix:"#",term:e.slice(1)}:e.startsWith("@")?{prefix:"@",term:e.slice(1)}:e.startsWith(">")?{prefix:">",term:e.slice(1)}:{prefix:null,term:e}}function T0(){const e=eo(),t=qm();return l.useMemo(()=>{const s={};for(const[r,o]of Object.entries(e)){const a=Date.parse(o);s[r]={lastUsedAt:Number.isNaN(a)?null:a,useCount:t[r]??0}}return s},[e,t])}const D0=/^\/([A-Za-z0-9][\w.-]*(?::[\w.-]+)*)(?=\s|$)\s*/;function O0(e,t){const s=t.trim().replace(D0,"").trim();return s?`${e} ${s}`:`${e} `}function M0(e){const[t,s]=Dn(),{setTheme:r,theme:o}=_i(),a=Ce(),i=oe(),c=se(),d=ln(N=>N.openFeedback),m=to(),{url:u}=kc(),{copy:f}=Nn({toastOnSettle:!0}),{open:p}=We(),{open:h}=Zr(),g=ps(),x=B(N=>N.setPickerOpen),b=B(N=>N.setCanvasOpen),y=B(N=>N.setRightPanelOpen),k=B(N=>N.setActiveRightPanelTab),j=l.useCallback(N=>{ss.getState().recordOpened("agent",N)},[]),A=l.useCallback(N=>{s(N.projectPath,{onOpened:()=>{j(N.projectPath)}}),e()},[j,s,e]),v=Ac(),S=l.useCallback(N=>{ss.getState().recordOpened("room",N.id),e(),a({...ue.channels(),search:{id:N.id}})},[e,a]),I=l.useCallback((N,T)=>{T&&j(T),e(),a(vt({session:N,dir:T??void 0}))},[e,a,j]),D=l.useCallback(N=>{e(),Gm({queryClient:i,transport:c},t).then(async T=>{if(T===null){Wo(t);return}t&&j(t);const R=Ym.getState(),_=R.getSession(T.sessionId).input;R.updateSession(T.sessionId,{input:O0(N,_)}),a(T.isNew?await Vm(c,{session:T.sessionId,dir:t??void 0}):vt({session:T.sessionId}))}).catch(T=>{$i(c,T),Wo(t)})},[e,a,i,c,t,j]),O=l.useCallback(N=>{e(),a({href:N})},[e,a]),E=l.useCallback(N=>{Qm(N)||console.warn(`[command-palette] no handler registered for action "${N}"`)},[]),w=l.useCallback(N=>{switch(e(),N){case"openTasks":h();return;case"openRelay":g();return;case"openMesh":a({...ue.team()});return;case"openSettings":p();return;case"discoverAgents":bn.getState().open();return;case"browseFilesystem":x(!0);return;case"openAgentProfile":k(Jm),y(!0);return;default:{const T=Xm(N);if(T){p(T);return}E(N);return}}},[e,a,h,g,p,x,k,y,E]),C=l.useCallback(N=>{switch(e(),N){case"navigateDashboard":a({...ue.home()});return;case"newSession":v();return;case"openDevPlayground":gn("/dev");return;case"toggleDevtools":B.getState().toggleDevtools();return;case"toggleRouterDevtools":B.getState().toggleRouterDevtools();return;case"createAgent":xs.getState().open();return;case"switchShape":B.getState().setShapeSwitcherOpen(!0);return;case"openControlCenter":B.getState().setControlCenterOpen(!0);return;case"toggleCanvas":b(!B.getState().canvasOpen);return;case"toggleTheme":r(o==="dark"?"light":"dark");return;case"openFeedback":d();return;case"openYourReports":a({...ue.feedbackRequests()});return;case"openTasks":h();return;case"openRelay":g();return;case"openMesh":a({...ue.team()});return;case"discoverAgents":bn.getState().open();return;case"openSettings":p();return;case"browseFilesystem":x(!0);return;case Ye.copyLink:u&&f(u);return;case Ye.showQr:B.getState().setRemoteAccessBeaconOpen(!0);return;case Ye.turnOn:m.start();return;case Ye.turnOff:m.stop();return;default:E(N);return}},[e,a,E,r,o,b,x,h,g,p,d,f,m,u,v]);return{handleAgentSelect:A,startNewSession:v,handleFeatureAction:w,handleQuickAction:C,handleRoomSelect:S,handleSessionSelect:I,handleCommandSelect:D,handlePageSelect:O,recordAgentOpened:j,setDir:s,selectedCwd:t}}const Ha='[cmdk-item=""]:not([aria-disabled="true"])',_0=new Set(["ArrowUp","ArrowDown","Home","End"]),P0=new Set(["n","p","j","k"]);function L0({rootRef:e,activePage:t,onPin:s,resetKey:r}){const o=l.useRef(!1);l.useLayoutEffect(()=>{o.current=!1},[r]),l.useLayoutEffect(()=>{var m;if(o.current)return;const c=(m=e.current)==null?void 0:m.querySelector(`[data-palette-page="${CSS.escape(t)}"] ${Ha}`);if(!c||c.getAttribute("aria-selected")==="true")return;const d=c.getAttribute("data-value");d&&s(d)});const a=l.useCallback(c=>{c.nativeEvent.isComposing||c.keyCode===229||(_0.has(c.key)||c.ctrlKey&&P0.has(c.key))&&(o.current=!0)},[]),i=l.useCallback(c=>{c.target instanceof Element&&c.target.closest(Ha)&&(o.current=!0)},[]);return{onKeyDown:a,onPointerMove:i}}function F0({scope:e,className:t}){return n.jsx("span",{"data-testid":"palette-scope-chip",className:z("bg-accent text-accent-foreground inline-flex shrink-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs font-medium",t),children:e.kind==="agent"?n.jsxs(n.Fragment,{children:[n.jsx(no,{...so(e.agent),size:"xs",badge:null}),Ne(e.agent)]}):n.jsxs(n.Fragment,{children:[n.jsx(Ec,{room:e.room,participants:e.room.participants,size:"xs"}),n.jsx(Ic,{room:e.room})]})})}function $0(e){const t=e.trim();return t.length===0?null:t}function Rd(e,t){const s=l.useDeferredValue(e),{sessions:r}=Zm(t),{data:o}=wx(s||null),a=l.useMemo(()=>r.slice(0,3).map(i=>({id:i.id,title:vc(i.title),lastActive:i.updatedAt})),[r]);return{sessionCount:r.length,recentSessions:a,health:o??null}}function B0({agent:e}){const{sessionCount:t,recentSessions:s,health:r}=Rd(e.id,e.projectPath),{color:o,emoji:a}=so(e);return n.jsx(Y.div,{initial:{opacity:0,width:0},animate:{opacity:1,width:240},exit:{opacity:0,width:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"flex-shrink-0 overflow-hidden border-l will-change-[width]",children:n.jsxs("div",{className:"w-[240px] space-y-3 p-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(no,{color:o,emoji:a,size:"sm",className:"shrink-0"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:Ne(e)})]}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:Rc(e.projectPath)}),n.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[r&&n.jsx(xn,{size:"xs",variant:r.status==="active"?"default":"secondary",children:r.status}),n.jsxs("span",{className:"text-muted-foreground",children:[t," ",t===1?"chat":"chats"]})]}),s.length>0&&n.jsxs("div",{className:"space-y-1 pt-1",children:[n.jsx("p",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:"Recent"}),n.jsx("ul",{className:"space-y-0.5",children:s.map(i=>n.jsx("li",{className:"text-muted-foreground truncate text-xs",children:i.title},i.id))})]})]})})}function z0({agent:e,onOpenHere:t,onOpenNewTab:s,onOpenNewWindow:r,onNewSession:o,onBrowseSessions:a,onEditSettings:i,recentSessions:c,onSelectSession:d}){const m=wt?"⌘":"Ctrl+";return n.jsxs(n.Fragment,{children:[n.jsxs(Pe,{heading:`${Ne(e)} actions`,children:[n.jsxs(he,{value:"open-here",onSelect:t,children:[n.jsx(bs,{className:"size-4"}),n.jsx("span",{children:"Open here"}),n.jsx(qo,{children:"Enter"})]}),n.jsxs(he,{value:"open-new-tab",onSelect:s,children:[n.jsx(eb,{className:"size-4"}),n.jsx("span",{children:"Open in a new tab"}),n.jsxs(qo,{children:[m,"Enter"]})]}),r&&n.jsxs(he,{value:"open-new-window",onSelect:r,children:[n.jsx(Vb,{className:"size-4"}),n.jsx("span",{children:"Open in a new window"})]}),n.jsxs(he,{value:"new-session",onSelect:o,children:[n.jsx(Kt,{className:"size-4"}),n.jsx("span",{children:"New chat"})]}),a&&n.jsxs(he,{value:"browse-sessions",onSelect:a,children:[n.jsx(nb,{className:"size-4"}),n.jsx("span",{children:"Browse chats…"})]}),n.jsxs(he,{value:"edit-settings",onSelect:i,children:[n.jsx(Cs,{className:"size-4"}),n.jsxs("span",{children:["Edit ",Ne(e)," settings"]})]})]}),c.length>0&&n.jsx(Pe,{heading:"Recent chats",children:c.map(u=>n.jsxs(he,{value:u.id,onSelect:()=>d(u.id),children:[n.jsx(gs,{className:"size-4"}),n.jsx("span",{className:"truncate",children:u.title}),n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:U0(u.lastActive)})]},u.id))})]})}function U0(e){const t=Date.now(),s=new Date(e).getTime(),r=t-s,o=Math.floor(r/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const a=Math.floor(o/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<7?`${i}d ago`:`${Math.floor(i/7)}w ago`}const nt="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function K0({page:e,hasAgentSelected:t,canScope:s,isScoped:r}){const o=wt?"⌘":"Ctrl";return n.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:nt,children:"↑↓"}),"Navigate"]}),!e&&t&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:nt,children:"Enter"}),"Open"]}),(!e&&t||e==="agent-actions")&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsxs("kbd",{className:nt,children:[o,"Enter"]}),"New tab"]}),e==="agent-actions"&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:nt,children:"Enter"}),"Select"]}),e&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:nt,children:"Backspace"}),"Back"]}),s&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:nt,children:"Tab"}),"Search inside"]}),r&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:nt,children:"Backspace"}),"Clear scope, at the start"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:nt,children:"esc"}),"Close"]})]})}const H0=[{key:"#",means:"channels"},{key:"@",means:"agents and DMs"},{key:">",means:"commands"}];function Td({className:e}){return n.jsx("div",{className:z("text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-xs",e),children:H0.map(({key:t,means:s})=>n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:"bg-muted text-3xs rounded px-1 py-0.5 font-mono",children:t}),s]},t))})}function W0({text:e,indices:t,className:s}){if(!t||t.length===0)return n.jsx("span",{className:s,children:e});const r=[];let o=0;for(let a=0;a<t.length;a++){const[i,c]=t[a],d=c+1;o<i&&r.push(n.jsx("span",{children:e.slice(o,i)},`p-${a}`)),r.push(n.jsx("mark",{className:"text-foreground bg-transparent font-semibold",children:e.slice(i,d)},`m-${a}`)),o=d}return o<e.length&&r.push(n.jsx("span",{children:e.slice(o)},"tail")),n.jsx("span",{className:s,children:r})}function Dd({agent:e,isActive:t,onSelect:s,nameIndices:r,isSelected:o}){return n.jsxs(he,{value:Ne(e),keywords:[e.name,e.projectPath,e.id],onSelect:()=>s(),className:"relative py-2",forceMount:t?!0:void 0,children:[o&&n.jsx(Y.div,{layoutId:"cmd-palette-selection",className:"bg-accent absolute inset-0 rounded-sm",transition:{duration:.15,ease:[0,0,.2,1]}}),n.jsx("div",{className:"relative z-10 w-full",children:n.jsx(eh,{agent:e,name:r?n.jsx(W0,{text:Ne(e),indices:r,className:"truncate text-sm font-semibold"}):n.jsx("span",{className:"truncate text-sm font-semibold",children:Ne(e)}),secondary:Rc(e.projectPath),selected:t})})]})}function Od(){return n.jsx("span",{"data-testid":"palette-archived-mark",className:"text-muted-foreground border-border text-3xs shrink-0 rounded-full border px-1.5 py-0.5 font-medium",children:"Archived"})}function Md({room:e,onSelect:t}){const s=Lt(e);return n.jsxs(he,{value:e.id,keywords:Ar(e),onSelect:t,className:"flex items-center gap-2 py-2",children:[n.jsx(Ec,{room:e,participants:e.participants,className:"shrink-0"}),e.kind==="dm"?n.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm",children:["Open DM with ",e.title]}):n.jsx(Ic,{room:e,className:"min-w-0 flex-1 text-sm"}),e.archived&&n.jsx(Od,{}),s&&n.jsx("span",{className:"bg-brand/15 text-brand text-3xs shrink-0 rounded-full px-1.5 py-0.5 font-medium tabular-nums","aria-label":`${e.unreadCount} unread`,children:e.unreadCount})]})}const q0=6e4;function G0({lastActivityAt:e}){const t=ro(q0),s=l.useMemo(()=>Number.isNaN(Date.parse(e))?null:js(e),[e,t]);return s===null?null:n.jsx("span",{className:"text-muted-foreground text-2xs font-normal",children:s})}function Pr({item:e,live:t,isSelected:s=!1,onSelect:r}){const o=Tc(e.agent,e.cwd??e.id),a=th(e.who,e.title),i=(t==null?void 0:t.verb)??null;return n.jsxs(he,{value:e.id,keywords:bd(e),onSelect:r,title:a,className:z("flex gap-2 py-1.5",i!==null?"items-start":"items-center"),children:[n.jsx(no,{color:o.color,emoji:o.emoji,size:"xs",className:z("shrink-0",i!==null&&"mt-px")}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("span",{"data-slot":"palette-session-line",className:"flex w-full items-center gap-1.5 text-sm",children:[e.who?n.jsxs(n.Fragment,{children:[n.jsx("span",{"data-slot":"palette-session-who",className:nh,children:e.who}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 flex-none",children:sh})]}):null,n.jsx("span",{"data-slot":"palette-session-title",className:rh,children:e.title}),n.jsxs("span",{className:z("flex items-center gap-1.5",ah),children:[e.archived&&t===void 0&&n.jsx(Od,{}),n.jsx(oh,{origin:e.origin,label:e.originLabel,className:"text-muted-foreground"}),n.jsx(G0,{lastActivityAt:e.lastActivityAt}),s&&n.jsx(Y0,{canStartNewSession:e.cwd!==null})]})]}),i!==null&&n.jsxs("span",{className:"text-muted-foreground text-2xs flex items-center gap-1.5 font-normal",children:[t!==void 0&&n.jsx("span",{"aria-hidden":!0,className:z("size-1.5 shrink-0 rounded-full",ih(t.signal))}),i]})]})]})}function Y0({canStartNewSession:e}){return n.jsxs("span",{"aria-hidden":!0,className:"text-muted-foreground flex items-center gap-1",children:[n.jsx("kbd",{className:"bg-accent text-3xs rounded px-1 py-0.5 font-mono",children:"↵"}),e&&n.jsx("kbd",{className:"bg-accent text-3xs rounded px-1 py-0.5 font-mono",children:"⌘↵"})]})}const V0={session:"Conversations",agent:"Agents",room:"Channels",dm:"Direct messages",command:"Commands",feature:"Actions","quick-action":"Actions",page:"Add-ons"},Q0="Best match",Lr={Clock:Qi,Radio:sb,Globe:Oc,Settings:Cs,Plus:Kt,Search:ts,FolderOpen:bs,Moon:Ox,Shapes:lh,MessageSquarePlus:Dc,Inbox:ch},pt=[0,0,.2,1],X0=[.4,0,1,1],_d={hidden:{opacity:0,scale:.96,y:-8},visible:{opacity:1,scale:1,y:0,transition:{duration:.2,ease:pt}},exit:{opacity:0,scale:.96,y:-8,transition:{duration:.12,ease:X0}}},J0={hidden:{},visible:{transition:{staggerChildren:.035,delayChildren:.04}}},hn={hidden:{opacity:0,y:-4},visible:{opacity:1,y:0,transition:{duration:.15,ease:pt}}},Xs=8;function Z0({continueRows:e,recent:t,newActions:s,selectedCwd:r,selectedValue:o,onSessionSelect:a,onRoomSelect:i,onGoToAgentActions:c,onQuickAction:d}){return n.jsxs(n.Fragment,{children:[e.length>0&&n.jsx(Pe,{heading:"Continue",children:e.map((m,u)=>n.jsx(Y.div,{variants:u<Xs?hn:void 0,children:n.jsx(Pr,{item:m.session,live:{verb:m.verb,signal:m.signal},isSelected:o===m.session.id,onSelect:()=>a(m.session)})},m.session.id))}),t.length>0&&n.jsx(Pe,{heading:"Recent",children:t.map((m,u)=>n.jsxs(Y.div,{variants:u<Xs?hn:void 0,children:[m.kind==="session"&&n.jsx(Pr,{item:m.session,isSelected:o===m.session.id,onSelect:()=>a(m.session)}),m.kind==="room"&&n.jsx(Md,{room:m.room,onSelect:()=>i(m.room)}),m.kind==="agent"&&n.jsx(Dd,{agent:m.agent,isActive:m.agent.projectPath===r,isSelected:o===Ne(m.agent),onSelect:()=>c(m.agent)})]},m.key))}),s.length>0&&n.jsxs(n.Fragment,{children:[(e.length>0||t.length>0)&&n.jsx(Mc,{}),n.jsx(Pe,{heading:"New",children:s.map((m,u)=>{const f=Lr[m.icon];return n.jsx(Y.div,{variants:u<Xs?hn:void 0,children:n.jsx(he,{value:m.label,onSelect:()=>d(m.action),children:n.jsxs(Y.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:m.label})]})})},m.id)})})]})]})}function Wa({row:e,selectedCwd:t,selectedValue:s,onFeatureAction:r,onQuickAction:o,onGoToAgentActions:a,onRoomSelect:i,onSessionSelect:c,onCommandSelect:d,onPageSelect:m}){var p;const{item:u,matches:f}=e.item;switch(u.type){case"session":return n.jsx(Pr,{item:u.data,isSelected:s===u.data.id,onSelect:()=>c(u.data)});case"agent":return n.jsx(Dd,{agent:u.data,isActive:u.data.projectPath===t,isSelected:s===Ne(u.data),onSelect:()=>a(u.data),nameIndices:(p=f==null?void 0:f.find(h=>h.key==="name"))==null?void 0:p.indices});case"room":case"dm":return n.jsx(Md,{room:u.data,onSelect:()=>i(u.data)});case"command":return n.jsx(he,{value:u.data.name,onSelect:()=>d(u.data.name),children:n.jsxs(Y.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[n.jsx("span",{className:"font-mono text-xs",children:u.data.name}),u.data.description&&n.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:u.data.description})]})});case"feature":{const h=Lr[u.data.icon];return n.jsx(he,{value:u.data.label,onSelect:()=>r(u.data.action),children:n.jsxs(Y.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:u.data.label}),u.data.shortcut&&n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:u.data.shortcut})]})})}case"page":return n.jsx(he,{value:u.data.id,onSelect:()=>m(u.data.href),children:n.jsxs(Y.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[n.jsx(ys,{icon:u.data.icon,className:"size-4"}),n.jsx("span",{children:u.data.label})]})});case"quick-action":{const h=Lr[u.data.icon];return n.jsx(he,{value:u.data.label,onSelect:()=>o(u.data.action),children:n.jsxs(Y.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:u.data.label})]})})}}}function eS({term:e,isScoped:t=!1,onSelect:s}){return n.jsxs(he,{value:"search-messages-handoff",onSelect:s,className:"flex items-center gap-2 py-2",children:[n.jsx(gs,{className:"text-muted-foreground size-4 shrink-0"}),n.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm",children:["Search ",t?"all messages":"messages"," for"," ",n.jsxs("mark",{className:"text-foreground bg-transparent font-semibold",children:["“",e,"”"]}),"…"]}),n.jsx("kbd",{className:"bg-muted text-muted-foreground text-3xs shrink-0 rounded px-1 py-0.5 font-mono",children:wt?"⌘⇧F":"Ctrl⇧F"})]})}const qa=8;function tS({staggerKey:e,isZeroQuery:t,isRoomMode:s,scope:r,hasQuery:o,selectedCwd:a,selectedValue:i,continueRows:c,recent:d,newActions:m,bestMatch:u,rows:f,rooms:p,searchHandoff:h,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:k,onCommandSelect:j,onPageSelect:A}){const v=s?p.isError?"Couldn’t load your channels.":p.isLoading?"Loading channels…":p.channels.length===0?"No channels yet.":null:null,S=A0(f,E=>r?Oa(r):V0[E.item.item.type]),I=r&&!o&&f.length===0&&!u?ik(r):null,D=new Set(f.slice(0,u?qa-1:qa).map(E=>E.key)),O={selectedCwd:a,selectedValue:i,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:k,onCommandSelect:j,onPageSelect:A};return n.jsxs(Y.div,{variants:J0,initial:"hidden",animate:"visible",children:[t&&n.jsx(Z0,{continueRows:c,recent:d,newActions:m,selectedCwd:a,selectedValue:i,onSessionSelect:k,onRoomSelect:y,onGoToAgentActions:b,onQuickAction:x}),!t&&u&&n.jsx(Pe,{heading:Q0,children:n.jsx(Y.div,{variants:hn,children:n.jsx(Wa,{row:u,...O})})}),!t&&S.map((E,w)=>n.jsx(Pe,{heading:E.label,children:E.rows.map(C=>n.jsx(Y.div,{variants:D.has(C.key)?hn:void 0,children:n.jsx(Wa,{row:C,...O})},C.key))},`${E.label}-${w}`)),I&&n.jsx(Pe,{heading:r?Oa(r):void 0,children:n.jsx(he,{disabled:!0,value:"scope-status",className:"text-muted-foreground text-sm",children:I})}),v&&n.jsx(Pe,{heading:"Channels",children:n.jsx(he,{disabled:!0,value:"rooms-status",className:"text-muted-foreground text-sm",children:v})}),h&&n.jsx(Pe,{children:n.jsx(eS,{term:h.term,isScoped:h.isScoped,onSelect:h.onSelect})}),t&&n.jsxs(n.Fragment,{children:[n.jsx(Mc,{}),n.jsx(Td,{})]})]},e)}function nS(e,t){const s=Mx(),{dismissedIds:r}=_c(),o=B(a=>a.promoEnabled);return l.useMemo(()=>o?_x(Px.filter(a=>a.placements.includes(e)),s,r,t):[],[e,t,s,r,o])}const sS={initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95,transition:{duration:.15}}};function rS({promo:e}){const{activate:t,dialog:s}=Lx(e),{dismissPromo:r}=_c(),o=ze(),a=e.content.icon;return n.jsxs(Y.div,{variants:o?void 0:sS,layout:!o,className:"group/promo relative",children:[n.jsxs("button",{"data-slot":"promo-card-compact",onClick:t,className:"bg-sidebar-accent/40 text-sidebar-foreground/70 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring flex w-full items-center gap-2 rounded-md py-1.5 pr-7 pl-2 text-left outline-hidden transition-colors duration-150 focus-visible:ring-2",children:[n.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center",children:n.jsx(a,{className:"size-4"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"text-sidebar-foreground/90 block truncate text-[13px] font-medium",children:e.content.title}),n.jsx("span",{className:"text-2xs block truncate",children:e.content.shortDescription})]}),n.jsx(dc,{className:"size-3.5 shrink-0 opacity-60"})]}),n.jsx("button",{type:"button",onClick:()=>r(e.id),"aria-label":"Dismiss",className:"text-sidebar-foreground/40 hover:text-sidebar-foreground focus-ring absolute top-1/2 right-1.5 -translate-y-1/2 rounded-md p-0.5 opacity-70 transition-[color,opacity] duration-150 group-hover/promo:opacity-100",children:n.jsx(Te,{className:"size-3.5"})}),s]})}const oS=1;function aS(e){const[t]=nS(e,oS);return l.useMemo(()=>t===void 0?{id:"promo",show:!1,render:()=>null}:{id:`promo:${t.id}`,show:!0,render:()=>n.jsx(rS,{promo:t})},[t])}const iS=new Set(["downloading","downloaded","install-failed"]);function Ga(e,t){return(e==null?void 0:e.state)==="install-failed"?t.state==="downloaded"&&oo(t.version,e.version)?t:e:iS.has(t.state)||t.state==="error"?t:e&&(e.state==="downloading"||e.state==="downloaded")?e:t}function cS(){var o;const e=typeof window<"u"&&!!((o=window.electronAPI)!=null&&o.onUpdateStatus),[t,s]=l.useState(null);l.useEffect(()=>{var c;const a=window.electronAPI;if(!(a!=null&&a.onUpdateStatus))return;const i=a.onUpdateStatus(d=>{s(m=>Ga(m,d))});return(c=a.getUpdateStatus)==null||c.call(a).then(d=>{d&&s(m=>Ga(m,d))}),i},[]);const r=l.useCallback(()=>{var a,i;(i=(a=window.electronAPI)==null?void 0:a.restartToUpdate)==null||i.call(a)},[]);return{isDesktop:e,status:t,restart:r}}const lS={darwin:"https://dorkos.ai/download/mac",win32:"https://dorkos.ai/download/windows"},dS="https://dorkos.ai";function uS(){var t;const e=typeof window>"u"||(t=window.electronAPI)==null?void 0:t.platform;it((e&&lS[e])??dS)}function mS(){const{data:e}=De(),{isDesktop:t,status:s,restart:r}=cS(),o=An(),a=e==null?void 0:e.version,i=(e==null?void 0:e.latestVersion)??null,c=l.useMemo(()=>(e==null?void 0:e.dismissedUpgradeVersions)??[],[e==null?void 0:e.dismissedUpgradeVersions]),d=l.useCallback(m=>{o.mutate({ui:{dismissedUpgradeVersions:[...c,m]}})},[c,o]);return l.useMemo(()=>t?(s==null?void 0:s.state)==="install-failed"?{kind:"desktop-install-failed",downloadFresh:uS}:(s==null?void 0:s.state)!=="downloaded"?{kind:"none"}:{kind:"desktop-restart",restart:r}:i!==null&&a!==void 0&&oo(i,a)&&!c.includes(i)?{kind:"command",latestVersion:i,dismiss:()=>d(i)}:{kind:"none"},[t,s,r,i,a,c,d])}const hS="npm update -g dorkos",fS="The update couldn’t install itself. Download a fresh copy. Your settings and agents stay put.",Js="focus-ring inline-flex items-center gap-1 rounded-full bg-amber-500/15 px-2 py-0.5 text-2xs font-medium text-amber-700 transition-colors duration-150 hover:bg-amber-500/25 dark:text-amber-300";function pS(e,t,s){return t?"Command copied":s?"Couldn’t copy":`Update ready: v${e}`}function gS({update:e}){const{copied:t,failed:s,copy:r}=Nn(),o=l.useCallback(()=>{r(hS)},[r]);return e.kind==="none"?null:e.kind==="desktop-restart"?n.jsx("div",{className:"flex items-center px-0.5",children:n.jsxs("button",{type:"button",onClick:e.restart,"aria-label":"Restart to install the update",className:Js,children:[n.jsx(zx,{className:"size-3"}),"Restart to update"]})}):e.kind==="desktop-install-failed"?n.jsxs("div",{role:"group","aria-label":"Update didn’t install",className:"flex flex-col gap-1.5 px-0.5",children:[n.jsx("p",{className:"text-sidebar-foreground/70 text-2xs leading-snug",children:fS}),n.jsxs("button",{type:"button",onClick:e.downloadFresh,"aria-label":"Download a fresh copy of DorkOS",className:z(Js,"self-start"),children:[n.jsx(dh,{className:"size-3"}),"Download fresh copy"]})]}):n.jsxs("div",{className:"flex items-center gap-1 px-0.5",children:[n.jsxs("button",{type:"button",onClick:o,"aria-label":`Copy the update command for v${e.latestVersion}`,className:Js,children:[t?n.jsx(Nt,{className:"size-3"}):n.jsx(Wr,{className:"size-3"}),pS(e.latestVersion,t,s)]}),n.jsx("button",{type:"button",onClick:e.dismiss,"aria-label":"Dismiss update notification",className:"text-sidebar-foreground/50 hover:text-sidebar-foreground focus-ring rounded-md p-0.5 transition-colors duration-150",children:n.jsx(Te,{className:"size-3"})})]})}function Pd(){const{shouldShowGettingStarted:e,dismiss:t}=Xt(),s=mS(),r=yv(),o=Cv(),a=aS("dashboard-sidebar"),i=On(),c=[{id:"getting-started",show:e,render:()=>n.jsx(wv,{onDismiss:t})},{id:"update",show:s.kind!=="none",render:()=>n.jsx(gS,{update:s})},{id:"identity-prompt",show:r.visible,render:()=>n.jsx(Nv,{prompt:r})},{id:"profile-prompt",show:o.visible,render:()=>n.jsx(kv,{prompt:o})},a];return n.jsx(Ex,{candidates:c,ready:i.settled})}const Ya="dorkos-pinned-agents";function Ld(){const{data:e}=De(),t=ao(),{update:s}=Vt(),r=t.pinned.length,o=l.useRef(!1);l.useEffect(()=>{if(o.current||e===void 0)return;const a=localStorage.getItem(Ya);if(a===null){o.current=!0;return}o.current=!0;let i=[];try{const c=JSON.parse(a);Array.isArray(c)&&(i=c.filter(d=>typeof d=="string"))}catch{i=[]}r===0&&i.length>0&&s(c=>({...c,pinned:i.map(d=>({kind:"agent",path:d}))})),localStorage.removeItem(Ya)},[e,r,s])}function Fd(e){return l.useMemo(()=>uh(e),[e])}const xS=1800*1e3,an={finishedWhileAwayCount:0,idleWhileAwayCount:0};function Va(e){let t=null;for(const s of Object.values(e)){const r=Date.parse(s);Number.isNaN(r)||(t===null||r>t)&&(t=r)}return t}function bS(e,t,s,r){const o=new Set(t);let a=0;for(const i of e){if(o.has(i.id))continue;const c=Date.parse(i.updatedAt);Number.isNaN(c)||c>s&&c<=r&&(a+=1)}return a}function yS(e,t,s,r,o){const a=new Set(t);let i=0;for(const c of e){if(a.has(c.id))continue;const d=s[c.id];if(d==="streaming"||d==="blocked"||d==="error")continue;const m=Date.parse(c.updatedAt);Number.isNaN(m)||m<=r||m>o||o-m<xS||(i+=1)}return i}function vS(e){const{now:t,sessions:s,workingSessionIds:r,sessionStatuses:o,interactions:a,storedLastShownDate:i,settled:c}=e,d=mh(),{update:m}=Vt(),[u,f]=l.useState(null),p=l.useRef(!1);l.useEffect(()=>{!c||p.current||(p.current=!0,f({value:i}))},[c,i]);const h=u==null?void 0:u.value,[g]=l.useState(()=>Va(a)),x=Va(a),b=x!==null&&(g===null||x>g),y=l.useMemo(()=>b||!d.isAvailable||!d.enabled||d.maxPosts<=0||x===null||t-x<d.absenceThresholdMinutes*6e4?an:{finishedWhileAwayCount:bS(s,r,x,t),idleWhileAwayCount:yS(s,r,o,x,t)},[b,d.isAvailable,d.enabled,d.absenceThresholdMinutes,d.maxPosts,x,t,s,r,o]),k=hh(t),j=u!==null&&y.finishedWhileAwayCount>0&&h!==k,A=l.useRef(!1);return l.useEffect(()=>{!j||A.current||(A.current=!0,m(v=>fh(v,k)))},[j,k,m]),{digest:y,lastShownDate:h}}function wS(e,t){const{update:s}=Vt(),r=l.useMemo(()=>t?ph(e).map(a=>a.target.kind==="suggestion"?a.target.suggestionId:null).filter(a=>a!==null):null,[e,t]),o=l.useRef(null);l.useEffect(()=>{const a=o.current;if(o.current=r,a===null||r===null)return;const i=a.filter(c=>!r.includes(c));i.length!==0&&s(c=>i.reduce((d,m)=>gh(d,m),c))},[r,s])}const jS={discoveredUnregisteredPaths:[],nonSystemAgentCount:1,hasEverStartedSession:!0,hasPostedInTeam:!0,hasDorkBotSession:!0};function kS(e){const{agents:t,agentActivity:s,sessionCount:r,rooms:o,rosterResolved:a}=e,i=Vr(c=>c.candidates);return l.useMemo(()=>{if(!a)return{facts:jS,isResolved:!1};const c=new Set(t.map(f=>f.path)),d=i.map(f=>f.path).filter(f=>!c.has(f)),m=t.find(f=>f.isSystem)??null,u=o.find(f=>f.wellKnown===xh);return{facts:{discoveredUnregisteredPaths:d,nonSystemAgentCount:t.filter(f=>!f.isSystem).length,hasEverStartedSession:r>0||Object.keys(s).length>0,hasPostedInTeam:(u==null?void 0:u.viewerHasPosted)??!0,hasDorkBotSession:m!==null&&s[m.path]!==void 0},isResolved:!0}},[t,s,r,o,a,i])}const SS=6e4,CS=[],NS={};function $d(e,t){const s=rc(e),r=s.read();return r!==e&&!t(r,e)?(s.write(e),e):r}function AS(e,t){const s=Object.keys(e),r=Object.keys(t);return s.length===r.length&&r.every(o=>Object.is(e[o],t[o]))}function ES(e,t){return e.length===t.length&&t.every((s,r)=>e[r]===s)}function Wn(e){return $d(e,AS)}function IS(e){return $d(e,ES)}function RS(e){const t=ve({select:d=>d.location.pathname}),s=Kr({strict:!1}),r=t==="/session"?s.session??null:null,o=t==="/session"?s.dir??null:null,a=t==="/channels"?s.id??null:null,i=t==="/channels"||t==="/"?s.thread??null:null,c=a===null?null:e(a);return l.useMemo(()=>r!==null?{kind:"session",sessionId:r,agentPath:o??"",cwd:o}:a===null||c===null?null:i!==null?{kind:"room",roomId:a,roomKind:"thread",rootEntryId:i}:{kind:"room",roomId:a,roomKind:c},[r,o,a,c,i])}function Bd(e={}){const{coveredSignalIds:t}=e,s=ro(SS),r=On(),o=wc(bh),a=l.useMemo(()=>{var F;return((F=o.data)==null?void 0:F.sessions)??[]},[o.data]),i=ot(jc(F=>{const L={};for(const[J,le]of Object.entries(F.statuses))L[J]=le.lifecycle;return L})),c=l.useMemo(()=>Object.entries(i).filter(([,F])=>F==="streaming").map(([F])=>F),[i]),d=ot(l.useCallback(F=>F.statusCwds,[])),m=ks(),u=l.useMemo(()=>{const F=m.data??[];return r.fleetKnown?F:F.filter(L=>L.kind!=="dm")},[m.data,r.fleetKnown]),f=yh(),p=l.useMemo(()=>f.data??[],[f.data]),h=eo(),g=Wn(l.useMemo(()=>{const F={};for(const[L,J]of Object.entries(h)){if(!L.startsWith("agent:"))continue;const le=Date.parse(J);Number.isNaN(le)||(F[L.slice(6)]=le)}return F},[h])),b=Ss().data,y=IS(l.useMemo(()=>((b==null?void 0:b.agents)??[]).map(F=>F.projectPath),[b])),j=io(y).data,{brokenPaths:A}=vh(),v=Wn(jx(y,A,g)),S=l.useMemo(()=>{var F;return((F=o.data)==null?void 0:F.agentActivity)??{}},[o.data]),I=r.fleetKnown?y:CS,D=l.useMemo(()=>I.map(F=>{const L=(j==null?void 0:j[F])??null,J=S[F],le=J===void 0?NaN:Date.parse(J);return{path:F,runtime:(L==null?void 0:L.runtime)??"claude-code",namespace:(L==null?void 0:L.namespace)??null,isSystem:(L==null?void 0:L.isSystem)??!1,lastActivityAt:Number.isNaN(le)?null:le,lastInteractionAt:g[F]??null,attention:v[F]??"inactive"}}),[I,j,S,v,g]),O=l.useMemo(()=>Pc(I,j??{}),[I,j]),E=Wn(l.useMemo(()=>{const F={};for(const L of a){const J=L.userLastMessageAt;J!==void 0&&(F[`session:${L.id}`]=J)}return F},[a])),w=Wn(l.useMemo(()=>{const F={};for(const L of a){const J=L.lastTouchedByYouAt;J!==void 0&&(F[`session:${L.id}`]=J)}return F},[a])),C=ao(),N=l.useMemo(()=>Ey(C),[C]),T=vS({now:s,sessions:a,workingSessionIds:c,sessionStatuses:i,interactions:h,storedLastShownDate:N.digest.lastShownDate,settled:r.settled}),R=l.useMemo(()=>({...N,digest:{lastShownDate:T.lastShownDate}}),[N,T.lastShownDate]),_=l.useMemo(()=>wh(C.muted),[C.muted]),P=$x({mutedRoomIds:_}),U=l.useMemo(()=>({items:P.items,automated:P.automated}),[P.items,P.automated]),H=l.useMemo(()=>{const F=new Map;for(const L of u)F.set(L.id,L.kind==="dm"?"dm":"channel");return F},[u]),ne=l.useMemo(()=>F=>H.get(F)??"channel",[H]),te=RS(ne),q=jh(F=>F.automatedExpanded),G=Lc(),ee=kS({agents:D,agentActivity:S,sessionCount:a.length,rooms:u,rosterResolved:r.phase!=="cold"}),V=l.useMemo(()=>({now:s,sessions:a,workingSessionIds:c,liveSessionCwds:d,sessionStatuses:i,rooms:u,threads:p,agents:D,displayNames:O,attention:G,recents:U,prefs:R,interactions:h,userLastMessageAt:E,lastTouchedByYouAt:w,mentions:NS,...t===void 0?{}:{coveredSignalIds:t},todayAutomatedExpanded:q,activeTarget:te,journey:ee.facts,digest:T.digest}),[t,s,a,c,d,i,u,p,D,O,G,U,R,h,E,w,q,te,ee.facts,T.digest]);return wS(V,ee.isResolved),V}const zd="Heads up and Today fill themselves. Pin it to Library to keep it in place.",Ud={channels:"Channels",dms:"Direct messages",agents:"Agents"};function Qa(e){if(typeof e!="object"||e===null)return!1;const t=e.kind;if(t==="pinned")return!0;if(t==="ungrouped"){const s=e.section;return s===void 0||typeof s=="string"&&s in Ud}if(t==="computed"){const s=e.zone;return s==="now"||s==="today"||s==="getting-started"}return t==="group"&&typeof e.groupId=="string"}function TS(e){if(typeof e!="object"||e===null)return!1;const t=e.kind;return t==="agent"?typeof e.path=="string":t==="room"&&typeof e.roomId=="string"}function fn(e){if(typeof e!="object"||e===null)return null;const t=e.type;if(t==="item"){const s=e.ref,r=e.container;return TS(s)&&Qa(r)?{type:"item",ref:s,container:r}:null}if(t==="group"){const s=e.groupId;return typeof s=="string"?{type:"group",groupId:s}:null}if(t==="container"){const s=e.container;return Qa(s)?{type:"container",container:s}:null}return null}function Kd(e){return e===null?null:e.type==="item"?{type:"item",ref:e.ref,from:e.container}:e.type==="group"?{type:"group",groupId:e.groupId}:null}function Hd(e){if(e===null)return null;switch(e.type){case"item":return{type:"item",ref:e.ref,container:e.container};case"group":return{type:"group-header",groupId:e.groupId};case"container":return{type:"container",container:e.container}}}function Wd(e){switch(e.type){case"container":return{container:e.container};case"item":return{container:e.container,overRef:e.ref};case"group-header":return{container:{kind:"group",groupId:e.groupId}}}}function un(e,t){return e.findIndex(s=>Fc(s,t))}function Xa(e,t,s,r){const o=e.groups.find(i=>i.id===s);if(!o)return{kind:"none"};if(o.kind==="smart")return{kind:"reject-smart-group",groupId:s,ref:t};let a=null;if(o.sortMode==="manual"&&r!==void 0){const i=un(o.items,r);i>=0&&(a=i)}return{kind:"move-to-group",ref:t,groupId:s,toIndex:a}}function Po(e,t,s){if(s===null)return{kind:"none"};if(t.type==="group"){if(s.type!=="group-header")return{kind:"none"};const c=e.groups.findIndex(m=>m.id===t.groupId),d=e.groups.findIndex(m=>m.id===s.groupId);return c<0||d<0||c===d?{kind:"none"}:{kind:"reorder-group",groupId:t.groupId,from:c,to:d}}const{ref:r,from:o}=t,{container:a,overRef:i}=Wd(s);if(a.kind==="computed")return{kind:"reject-computed-zone",ref:r};if(o.kind==="pinned"){if(a.kind!=="pinned")return{kind:"unpin",ref:r};if(i===void 0)return{kind:"none"};const c=un(e.pinned,r),d=un(e.pinned,i);return c<0||d<0||c===d?{kind:"none"}:{kind:"reorder-pinned",ref:r,from:c,to:d}}if(o.kind==="group"){if(a.kind==="pinned")return{kind:"pin",ref:r};if(a.kind==="ungrouped")return{kind:"remove-from-group",ref:r};if(a.groupId!==o.groupId)return Xa(e,r,a.groupId,i);const c=e.groups.find(u=>u.id===o.groupId);if(!c||c.sortMode!=="manual"||i===void 0)return{kind:"none"};const d=un(c.items,r),m=un(c.items,i);return d<0||m<0||d===m?{kind:"none"}:{kind:"reorder-within-group",groupId:o.groupId,ref:r,from:d,to:m}}return a.kind==="pinned"?{kind:"pin",ref:r}:a.kind==="group"?Xa(e,r,a.groupId,i):{kind:"none"}}function DS(e,t){switch(t.kind){case"none":case"reject-smart-group":case"reject-computed-zone":return e;case"reorder-group":return Nh(e,t.from,t.to);case"pin":return Ch(e,t.ref);case"unpin":return Sh(e,t.ref);case"remove-from-group":return Go(e,t.ref,null);case"reorder-within-group":return Yo(e,t.groupId,t.from,t.to);case"reorder-pinned":return kh(e,t.from,t.to);case"move-to-group":{const s=Go(e,t.ref,t.groupId);if(t.toIndex===null)return s;const r=s.groups.find(o=>o.id===t.groupId);return r?Yo(s,t.groupId,r.items.length-1,t.toIndex):s}}}function OS(e,t,s){return DS(e,Po(e,t,s))}function MS(e,t){return e.type==="group"?`Picked up section ${t.groupName(e.groupId)}.`:`Picked up ${t.itemName(e.ref)}.`}function _S(e,t){switch(e.kind){case"reorder-group":return`Moved section ${t.groupName(e.groupId)}.`;case"move-to-group":return`Moved ${t.itemName(e.ref)} to ${t.groupName(e.groupId)}.`;case"pin":return`Pinned ${t.itemName(e.ref)}.`;case"unpin":return`Unpinned ${t.itemName(e.ref)}.`;case"remove-from-group":return`Moved ${t.itemName(e.ref)} out of its section.`;case"reorder-within-group":return`Reordered ${t.itemName(e.ref)} in ${t.groupName(e.groupId)}.`;case"reorder-pinned":return`Reordered ${t.itemName(e.ref)} in Pinned.`;case"reject-smart-group":return`Can’t move ${t.itemName(e.ref)} into ${t.groupName(e.groupId)}. Membership is rule-based. Edit rules instead.`;case"reject-computed-zone":return`Can’t move ${t.itemName(e.ref)} there. ${zd}`;case"none":return""}}function PS(e,t){if(e===null)return"";const{container:s}=Wd(e);switch(s.kind){case"pinned":return"Over Pinned.";case"ungrouped":return`Over ${s.section===void 0?"Agents":Ud[s.section]}.`;case"computed":return s.zone==="today"?"Over Today.":"Over Heads up.";case"group":return`Over ${t.groupName(s.groupId)}.`}}function LS(e){const t=r=>Kd(fn(r.active.data.current)),s=r=>{var o;return Hd(fn((o=r.over)==null?void 0:o.data.current))};return{onDragStart:r=>{const o=t(r);return o?MS(o,e()):void 0},onDragOver:r=>{if(t(r))return PS(s(r),e())||void 0},onDragEnd:r=>{const o=t(r);if(!o)return;const a=e(),i=Po(a.prefs,o,s(r));return i.kind==="none"?"Movement cancelled. Item returned to its place.":_S(i,a)},onDragCancel:r=>{const o=t(r);if(!o)return;const a=e();return`Movement cancelled. ${o.type==="group"?a.groupName(o.groupId):a.itemName(o.ref)} returned to its place.`}}}function FS({label:e}){const t=ze();return n.jsx(Y.div,{initial:{scale:1},animate:{scale:t===!0?1:Eh},transition:{duration:t===!0?0:Ah},className:"bg-sidebar border-sidebar-border text-sidebar-foreground shadow-floating flex items-center rounded-md border px-2.5 py-1.5 text-xs font-medium",children:e})}const $S=60;function BS(e){const t=document.querySelectorAll(`[${Vo}]`);for(const s of t)if(s.getAttribute(Vo)===e)return s.querySelector(`[${Ih}]`);return null}function zS(e,t=$S){let s=t;const r=()=>{const o=BS(e);if(o!==null){o.focus();return}s-- >0&&requestAnimationFrame(r)};requestAnimationFrame(r)}const US={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]};function KS(e,t){switch(t.kind){case"move-to-group":return Ps(t.groupId,t.ref);case"remove-from-group":return Ps("ungrouped",t.ref);case"unpin":{const s=e.groups.find(r=>r.items.some(o=>Fc(o,t.ref)));return Ps((s==null?void 0:s.id)??"ungrouped",t.ref)}default:return null}}function HS({data:e,itemName:t,groupName:s}){const r=e.type==="group"?s(e.groupId):e.type==="item"?t(e.ref):"";return n.jsx(FS,{label:r})}function WS({children:e,displayNames:t,rooms:s}){const r=je(),o=ao(),{update:a}=Vt(),[i,c]=l.useState(null),d=Mt(o),m=Mt(t),u=l.useMemo(()=>Object.fromEntries(s.map(k=>[k.id,k.slug??k.title])),[s]),f=Mt(u),p=oc(ns(cc,{activationConstraint:{distance:8}}),ns(ic,{coordinateGetter:ur,keyboardCodes:US}));if(r)return n.jsx(n.Fragment,{children:e});const h=k=>{var j;return((j=d.read().groups.find(A=>A.id===k))==null?void 0:j.name)??"group"},g=k=>k.kind==="agent"?m.read()[k.path]??k.path.split("/").pop()??"Agent":f.read()[k.roomId]??"room",x=LS(()=>({prefs:d.read(),itemName:g,groupName:h})),b=k=>{c(fn(k.active.data.current))},y=k=>{var I;c(null);const j=Kd(fn(k.active.data.current));if(j===null)return;const A=Hd(fn((I=k.over)==null?void 0:I.data.current)),v=Po(d.read(),j,A);if(v.kind==="reject-smart-group"){ae.info("Membership is rule-based. Edit rules instead.",{description:h(v.groupId)});return}if(v.kind==="reject-computed-zone"){ae.info(zd,{description:g(v.ref)});return}if(v.kind==="none"||(a(D=>OS(D,j,A)),!(k.activatorEvent instanceof KeyboardEvent)))return;const S=KS(d.read(),v);S!==null&&zS(S)};return n.jsx(Rh,{value:!0,children:n.jsxs(ac,{sensors:p,collisionDetection:sc,accessibility:{announcements:x},onDragStart:b,onDragEnd:y,onDragCancel:()=>c(null),children:[e,n.jsx(Th,{children:i?n.jsx(HS,{data:i,itemName:g,groupName:h}):null})]})})}function qS(){var r;const e=Ns(!0),t=ws();if(!t.community)return null;if(e.isPending)return n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"Loading space…"});if(e.isError)return n.jsxs("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:["Spaces could not be loaded."," ",n.jsx(M,{variant:"ghost",size:"sm",onClick:()=>void e.refetch(),children:"Retry"})]});const s=(r=e.data)==null?void 0:r.find(({ref:o})=>o===t.community);return s?s.status!=="connected"?n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"Reconnect this space to open its channels."}):n.jsx(GS,{connection:s}):n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"This space is no longer connected."})}function GS({connection:e}){var o,a,i;const t=Dh(e.access),s=Oh(e.ref,t.capabilities.read,t.fingerprint),r=ws();return n.jsxs("section",{"aria-label":e.label,className:"px-2 py-2",children:[n.jsx("h3",{className:"text-muted-foreground px-2 text-xs font-medium",children:e.label}),!t.cacheReadable&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:e.status==="reconnect-required"?"Reconnect to view channels.":"Channels aren’t available."}),t.cacheReadable&&!t.verified&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Saved channels"}),t.verified&&s.isPending&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Loading channels…"}),t.verified&&s.isError&&n.jsxs("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:["Space unavailable."," ",n.jsx(M,{variant:"ghost",size:"sm",onClick:()=>void s.refetch(),children:"Retry"})]}),((o=s.data)==null?void 0:o.stale)&&n.jsx("p",{className:"text-muted-foreground px-2 text-xs",children:"Saved channels · offline"}),(a=s.data)==null?void 0:a.rooms.filter(c=>!c.archived).map(c=>n.jsxs(Mh,{...ue.channels(),search:{community:e.ref,id:c.roomId},"aria-current":r.community===e.ref&&r.id===c.roomId?"page":void 0,className:"hover:bg-accent aria-[current=page]:bg-accent flex min-h-9 items-center justify-between gap-2 rounded-md px-2 py-1 text-sm",children:[n.jsxs("span",{className:"truncate",children:["#",c.slug??c.title]}),c.unreadCount!==null&&c.unreadCount>0&&n.jsx("span",{className:"text-muted-foreground text-xs","aria-label":`${c.unreadCount} unread messages`,children:c.unreadCount})]},c.roomId)),((i=s.data)==null?void 0:i.rooms.length)===0&&n.jsx("p",{className:"text-muted-foreground px-2 py-1 text-xs",children:"No channels available."})]})}const YS=[2,3,3],Ja=["w-14","w-10","w-16"];function VS(){return n.jsx("div",{className:"flex flex-col gap-1","data-testid":"sidebar-skeleton","aria-hidden":!0,children:YS.map((e,t)=>n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:z("flex h-7 items-center",_h),children:n.jsx(xt,{className:z("h-2.5 rounded-sm",Ja[t])})}),Array.from({length:e},(s,r)=>n.jsx(Ph,{showIcon:!0},r))]},Ja[t]))})}const QS=.16,XS=4,JS=.03,ZS={hidden:{},shown:{transition:{staggerChildren:JS}}},eC={hidden:{opacity:0,y:XS},shown:{opacity:1,y:0}};function Za(e){return{duration:e===!0?0:QS}}const tC=2500;function ei(e){var t;return((t=e.zones.find(s=>s.id==="now"))==null?void 0:t.needsYouCount)??0}function nC(e){const t=ze(),[s,r]=l.useState(!1),o=l.useRef(ei(e)),a=ei(e),i=e.zones.some(c=>c.id==="now");return l.useEffect(()=>{const c=o.current;if(o.current=a,!(t!==!0&&c>0&&a===0&&!i)){r(!1);return}r(!0);const m=setTimeout(()=>r(!1),tC);return()=>clearTimeout(m)},[a,i,t]),s}function qd(){const[e,t]=l.useState(!1),[s,r]=l.useState(!1),o=l.useCallback(()=>t(!0),[]),a=l.useCallback(()=>t(!1),[]),i=l.useCallback(()=>r(!0),[]),c=l.useCallback(()=>r(!1),[]);return{inside:e||s,handlers:{onPointerEnter:o,onPointerLeave:a,onFocus:i,onBlur:c}}}const ti=5e3;function sC(e){const{inside:t,handlers:s}=qd(),r=e.zones.some(m=>m.id==="getting-started"),[o,a]=l.useState(r),i=l.useRef(null),c=l.useRef(!r);return l.useEffect(()=>{if(!r){c.current||(c.current=!0,i.current=Date.now(),a(!1));return}if(o||t)return;const m=i.current===null?Number.POSITIVE_INFINITY:Date.now()-i.current;if(m>=ti){c.current=!1,a(!0);return}const u=setTimeout(()=>{c.current=!1,a(!0)},ti-m);return()=>clearTimeout(u)},[r,o,t]),{model:l.useMemo(()=>!r||o?e:{...e,zones:e.zones.filter(m=>m.id!=="getting-started")},[e,r,o]),handlers:s}}const rC=1e3;function Gd(e){const[t,s]=l.useState(""),r=l.useRef(t);return l.useEffect(()=>{const o=e??"";if(o===r.current)return;const a=setTimeout(()=>{r.current=o,s(o)},rC);return()=>clearTimeout(a)},[e]),t}function oC(){return n.jsxs("p",{"data-slot":"sidebar-all-clear",className:"text-sidebar-foreground/70 flex min-h-7 items-center gap-1.5 px-2 text-[13px]",children:[n.jsx(Nt,{className:"text-status-success size-3.5 shrink-0","aria-hidden":!0}),"All clear"]})}const aC=1,ni=40;function iC({onCommit:e,onCancel:t}){const[s,r]=l.useState(""),o=l.useRef(null),a=l.useRef(!1),i=Lh(o);l.useEffect(()=>{var m;(m=o.current)==null||m.focus()},[]);const c=()=>{if(a.current)return;a.current=!0;const m=s.trim();if(m.length<aC||m.length>ni){t();return}e(m)},d=m=>{m.key==="Enter"?(m.preventDefault(),c()):m.key==="Escape"&&(m.preventDefault(),a.current=!0,t())};return n.jsx(Fh,{children:n.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5",children:[n.jsx($h,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("input",{ref:o,value:s,maxLength:ni,placeholder:"Section name","aria-label":"New section name",onChange:m=>r(m.target.value),onKeyDown:d,onBlur:m=>{i.shouldHandleBlur(m)&&(a.current||t())},className:z("bg-background text-foreground placeholder:text-muted-foreground/50","focus-visible:ring-ring min-w-0 flex-1 rounded border px-1.5 py-0.5 text-xs outline-none focus-visible:ring-1")})]})})}function Zn({zone:e,onToggleAll:t,allClear:s=!1,lead:r,silenceLiveRegion:o=!1}){const a=Gd(e.liveRegionText);return n.jsxs("section",{"aria-label":e.label,"data-sidebar-zone":e.id,className:z("rounded-lg py-1",e.id==="now"||e.id==="getting-started"?"bg-sidebar-accent/40":void 0),children:[!o&&n.jsx("span",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:a}),r,s?n.jsx(oC,{}):n.jsxs(n.Fragment,{children:[e.id==="library"&&e.sections.length>0&&n.jsx(cC,{}),e.sections.map(i=>n.jsx(Bh,{section:i,onToggleAll:t},i.id))]})]})}function cC(){const e=zh();return e.groupCreation===null?null:n.jsx(Uh,{children:n.jsx(iC,{onCommit:e.commitNewGroup,onCancel:e.cancelNewGroup})})}const lC='[aria-current="page"]';function dC(e,t,s){const r=ze(),o=l.useRef(null);l.useLayoutEffect(()=>{var m,u;if(!s)return;const a=o.current===null,i=((m=o.current)==null?void 0:m.key)??null;if(o.current={key:t},!a&&(i===t||t===null)||t===null)return;const c=(u=e.current)==null?void 0:u.querySelector(lC);if(!(c instanceof HTMLElement))return;const d=!a&&r!==!0;c.scrollIntoView({block:"nearest",behavior:d?"smooth":"auto"})},[t,e,s])}function uC(e,t){const s=new Map(t.map((a,i)=>[a,i])),r=[],o=[];for(const a of e){const i=s.get(a.key);i===void 0?o.push(a):r.push({row:a,at:i})}return r.sort((a,i)=>a.at-i.at),[...r.map(a=>a.row),...o]}function mC(e,t){const{inside:s,handlers:r}=qd(),[o,a]=l.useState(null),[i,c]=l.useState(s);i!==s&&(c(s),a(s?e.map(f=>f.key):null));const[d,m]=l.useState(t);return d!==t&&(m(t),a(s?e.map(f=>f.key):null)),{rows:o===null?[...e]:uC(e,o),handlers:r}}const hC="anchor:active-session";function fC({zone:e,onToggleAll:t,silenceLiveRegion:s=!1}){var f;const r=l.useRef(null),o=e.sections.find(p=>p.id==="today"),a=l.useMemo(()=>(o==null?void 0:o.rows)??[],[o]),i=((f=a.find(p=>p.reason===hC))==null?void 0:f.key)??null,c=mC(a,i),d=On();dC(r,i,d.settled);const m=l.useMemo(()=>pC(a),[a]),u=l.useMemo(()=>({...e,sections:e.sections.map(p=>p.id==="today"?{...p,rows:c.rows}:p)}),[e,c.rows]);return n.jsx("div",{ref:r,...c.handlers,children:n.jsx(Zn,{zone:u,onToggleAll:t,silenceLiveRegion:s,lead:n.jsx(gC,{roomIds:m})})})}function pC(e){const t=new Set;for(const s of e)s.unread.tier!=="none"&&s.target.kind==="room"&&t.add(s.target.roomId);return[...t]}function gC({roomIds:e}){const t=je(),s=Kh();return!t||e.length===0?null:n.jsx(xC,{count:e.length,onCatchUp:()=>s(e)})}function xC({count:e,onCatchUp:t}){return n.jsx("div",{className:"px-2 pt-0.5 pb-1",children:n.jsxs("button",{type:"button","data-testid":"today-catch-up",onClick:t,"aria-label":`Catch up: mark ${e} unread ${e===1?"item":"items"} in Today as read`,className:z("text-sidebar-foreground/80 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-ring","flex w-full items-center gap-2 rounded-md px-2 text-[13px] font-medium",Wh,Qt),children:[n.jsx(Hh,{className:"size-4 shrink-0","aria-hidden":!0}),"Catch up",n.jsx("span",{"data-slot":"catch-up-count",className:"text-sidebar-foreground/70 text-2xs ml-auto tabular-nums",children:e})]})})}const si={id:"now",label:Vh.now,sections:[],reason:"zone:now"};function bC(e){return e.collapsible?e.id.startsWith("group:")||Bc(e.id)!==null:!1}function Fr({model:e,zoneIds:t,nowSlot:s=null,silenceLiveRegion:r=!1}){const{update:o}=Vt(),a=qh(),i=rs(a.destination),d=$c(i??void 0).visible?i:null,m=On(),u=ze(),{model:f,handlers:p}=sC(e),h=e.zones.flatMap(v=>v.sections).filter(bC),g=l.useCallback(v=>t===void 0||t.includes(v),[t]),x=l.useCallback(()=>{if(h.length===0)return;const v=h.some(S=>!S.collapsed);o(S=>{let I=S;for(const D of h){if(D.id.startsWith("group:")){I=Gh(I,D.id.slice(6),v);continue}const O=Bc(D.id);O!==null&&(I=Yh(I,O,v))}return I})},[h,o]),b=nC(e),y=e.zones.some(v=>v.id==="now"),k=y||e.zones.some(v=>v.id==="getting-started"),j=s!==null&&!y&&g("now"),A={variants:eC,transition:Za(u)};return d?n.jsx("div",{className:"flex min-h-0 flex-col","data-community-context":d,children:n.jsx(qS,{})}):n.jsx("div",{className:"flex flex-col gap-1",...p,children:n.jsx(Le,{mode:"wait",initial:!1,children:m.phase==="cold"?n.jsx(Y.div,{exit:{opacity:0},transition:Za(u),children:n.jsx(VS,{})},"skeleton"):n.jsxs(Y.div,{className:"flex flex-col gap-1",variants:ZS,initial:m.startedWarm?!1:"hidden",animate:"shown",children:[j&&n.jsx(Y.div,{...A,children:n.jsx(Zn,{zone:si,onToggleAll:x,lead:s,silenceLiveRegion:r})}),b&&!k&&!j&&g("now")&&n.jsx(Y.div,{...A,children:n.jsx(Zn,{zone:si,onToggleAll:x,allClear:!0,silenceLiveRegion:r})}),f.zones.filter(v=>g(v.id)).map(v=>n.jsx(Y.div,{...A,children:v.id==="today"?n.jsx(fC,{zone:v,onToggleAll:x,silenceLiveRegion:r}):n.jsx(Zn,{zone:v,onToggleAll:x,silenceLiveRegion:r,...v.id==="now"?{lead:s}:{}})},v.id))]},"zones")})})}function yC(){Ld();const e=Bd(),t=Fd(e),s=On();return n.jsxs("nav",{"aria-label":"Sidebar","aria-busy":s.phase==="cold"?!0:void 0,className:"flex min-h-0 flex-1 flex-col",children:[n.jsx(Qh,{className:"sidebar-scroll-edges px-2 py-3",children:n.jsx(zc,{activeTarget:e.activeTarget,children:n.jsx(WS,{displayNames:e.displayNames,rooms:e.rooms,children:n.jsx(Fr,{model:t})})})}),n.jsx(Pd,{})]})}const vC=2;function wC(){return{label:"Active now",rules:{statuses:["needs-attention","active"]}}}function jC(e){const t=new Map;for(const s of e)t.set(s.runtime,(t.get(s.runtime)??0)+1);return Array.from(t.entries()).filter(([,s])=>s>=vC).map(([s,r])=>({runtime:s,count:r,label:Ke(s).label})).sort((s,r)=>r.count-s.count||s.label.localeCompare(r.label)).map(({runtime:s,label:r})=>({label:`Runs on ${r}`,rules:{runtimes:[s]}}))}const ri="agent:";function kC(){const[e]=Dn(),t=eo(),{data:s}=Ss(),r=l.useMemo(()=>((s==null?void 0:s.agents)??[]).map(i=>i.projectPath),[s]),{data:o}=io(r),a=l.useMemo(()=>Pc(r,o??{}),[r,o]);return l.useMemo(()=>{const i=new Set(r);let c=null,d=-1/0;for(const[u,f]of Object.entries(t)){if(!u.startsWith(ri))continue;const p=u.slice(ri.length);if(!i.has(p))continue;const h=Date.parse(f);Number.isNaN(h)||h<=d||(d=h,c=p)}const m=e!==null&&i.has(e)?e:c;return m===null?null:{path:m,displayName:a[m]??m}},[a,t,r,e])}function SC(e){l.useEffect(()=>{if(!Re())return;const t=s=>{!(s.metaKey||s.ctrlKey)||s.shiftKey||s.altKey||s.key.toLowerCase()==="n"&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function CC(e){const t=e.smartGroupPresets.length===0?[]:[{kind:"separator",id:"sep-smart"},...e.smartGroupPresets.map(r=>({kind:"action",id:`new-group-preset:${r.label}`,label:r.label,icon:nn,opensInput:!1,run:()=>e.onCreatePresetSmartGroup(r)})),{kind:"action",id:"new-group-custom",label:"Custom rules",icon:nn,opensInput:!0,run:e.onOpenSmartGroupDialog}],s=[t.length===0?{kind:"action",id:"new-group",label:"Section",icon:nn,opensInput:!0,run:e.onNewGroup}:{kind:"submenu",id:"new-group",label:"Section",icon:nn,items:[{kind:"action",id:"new-group-empty",label:"Empty section",icon:nn,opensInput:!0,run:e.onNewGroup},...t]}];return[{kind:"action",id:"new-session",label:"Chat",icon:Dc,opensInput:!1,...e.showSessionShortcut?{hint:Pt(yn.NEW_SESSION)}:{},run:e.onNewSession},...e.lastUsedAgentName===null?[]:[{kind:"note",id:"new-session-note",icon:Gx,text:`Starts with ${e.lastUsedAgentName} (last used)`}],{kind:"separator",id:"sep-rooms"},{kind:"action",id:"new-channel",label:"Channel",icon:co,opensInput:!0,run:e.onNewChannel},{kind:"action",id:"new-message",label:"Group message",icon:gl,opensInput:!0,run:e.onNewMessage},{kind:"separator",id:"sep-agents"},{kind:"action",id:"new-agent",label:"Agent",icon:tf,opensInput:!0,run:e.onNewAgent},...s]}function NC(){const e=je(),t=zn(_=>_.menuOpen),s=zn(_=>_.preselect),r=zn(_=>_.setMenuOpen),o=zn(_=>_.requestNewGroup),a=Ce(),i=Ac(),[,c]=Dn(),d=Ux(),m=kC(),{update:u}=Vt(),[f,p]=l.useState(!1),[h,g]=l.useState(!1),[x,b]=l.useState(!1),{data:y}=Ss(),k=l.useMemo(()=>((y==null?void 0:y.agents)??[]).map(_=>_.projectPath),[y]),{data:j}=io(k),A=l.useMemo(()=>k.map(_=>{var P,U;return{projectPath:_,runtime:((P=j==null?void 0:j[_])==null?void 0:P.runtime)??"claude-code",namespace:((U=j==null?void 0:j[_])==null?void 0:U.namespace)??null,attention:"inactive",lastActivityAt:null}}),[k,j]),v=Xh(A),S=l.useMemo(()=>v?[wC(),...jC(A)]:[],[A,v]),I=l.useMemo(()=>{const _=new Map;for(const P of A)_.has(P.runtime)||_.set(P.runtime,Ke(P.runtime).label);return Array.from(_,([P,U])=>({value:P,label:U})).sort((P,U)=>P.label.localeCompare(U.label))},[A]),D=l.useMemo(()=>{const _=new Set;for(const P of A)P.namespace&&_.add(P.namespace);return Array.from(_).sort()},[A]),O=l.useCallback((_,P)=>u(U=>Jh(U,_,P).next),[u]),E=l.useCallback(_=>{ss.getState().recordOpened("room",_.id),a({...ue.channels(),search:{id:_.id}})},[a]),w=l.useCallback(()=>i(m==null?void 0:m.path),[m,i]);SC(w);const C=l.useCallback(_=>{const[P]=_;if(P!==void 0&&Kx(_)){c(P.agentPath,{onOpened:()=>ss.getState().recordOpened("agent",P.agentPath)});return}const U=Zh(_.map(H=>H.displayName));d.mutate({agentPaths:_.map(H=>H.agentPath),title:U},{onSuccess:E})},[E,c,d]),N=CC({onNewSession:w,lastUsedAgentName:(m==null?void 0:m.displayName)??null,onNewChannel:()=>p(!0),onNewMessage:()=>g(!0),onNewAgent:()=>xs.getState().open(),onNewGroup:()=>o(),smartGroupPresets:S,onCreatePresetSmartGroup:_=>O(_.label,_.rules),onOpenSmartGroupDialog:()=>b(!0),showSessionShortcut:Re()}),T=Uc(N),R=l.useRef(null);return l.useEffect(()=>{if(!t||s===null)return;const _=requestAnimationFrame(()=>{var P,U;(U=(P=R.current)==null?void 0:P.querySelector(`[data-menu-item-id="${s}"]`))==null||U.focus()});return()=>cancelAnimationFrame(_)},[t,s]),n.jsxs(n.Fragment,{children:[n.jsxs(uc,{open:t,onOpenChange:r,children:[n.jsx(mc,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"sidebar-new-button",className:z("bg-sidebar-accent text-sidebar-accent-foreground hover:bg-sidebar-accent/70 focus-visible:ring-sidebar-ring flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium outline-hidden transition-colors duration-150 focus-visible:ring-2",e&&z(Qt,"px-3")),children:[n.jsx(Kt,{className:"size-3.5"}),"New"]})}),n.jsx(hc,{ref:R,align:"end",className:"w-56",onCloseAutoFocus:T.onCloseAutoFocus,children:n.jsx(mr,{variant:"dropdown",nodes:T.nodes})})]}),f&&n.jsx(Hx,{open:!0,onOpenChange:_=>!_&&p(!1),onCreated:E}),n.jsx(Wx,{open:h,onOpenChange:g,onStart:C,hideTrigger:!0}),n.jsx(ef,{open:x,onOpenChange:b,mode:"create",runtimeOptions:I,namespaceOptions:D,onSubmit:({name:_,rules:P})=>O(_,P)})]})}function AC(){const e=B(s=>s.setGlobalPaletteOpen),t=je();return n.jsxs("button",{type:"button","data-testid":"sidebar-search-pill",onClick:()=>e(!0),className:z("bg-sidebar-accent/40 text-sidebar-foreground/60 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-[13px] outline-hidden transition-colors duration-150 focus-visible:ring-2",t&&Qt),children:[n.jsx(ts,{className:"size-(--size-icon-sm) shrink-0"}),n.jsx("span",{className:"truncate",children:"Jump to anything…"}),n.jsx(Kc,{className:"bg-sidebar-accent text-sidebar-foreground/70 ml-auto shrink-0 border-transparent",children:Pt(yn.COMMAND_PALETTE)})]})}function EC(e){const t=[];return e.you!==null&&t.push({kind:"action",id:"you",label:e.you.name,description:"View profile",icon:Yr,leading:e.you.face,guardsFocus:!0,run:e.you.onOpen}),t.push({kind:"action",id:"dorkos-account",label:"DorkOS account",description:e.accountStatus,icon:Hc,guardsFocus:!0,run:e.onOpenAccount},{kind:"action",id:"settings",label:"Settings",icon:Cs,guardsFocus:!0,run:e.onOpenSettings}),t}function IC(e){return e.isDevMode?[{kind:"separator",id:"sep-version"},{kind:"note",id:"version",icon:Qo,text:"Development build"}]:e.version===null?[]:[{kind:"separator",id:"sep-version"},{kind:"action",id:"version",label:`v${e.version} beta`,icon:Qo,opensInput:!1,hint:"Check for updates",run:e.onCheckForUpdates}]}function RC(e){const t=(e==null?void 0:e.trim())??"";return t.length===0||t===nf?"Your team":t.endsWith("s")?`${t}’ team`:`${t}’s team`}function TC(e,t){const s=sf(e);return l.createElement(rf,{size:t,kind:s.kind,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,fallback:s.fallback,origin:s.origin})}function Yd(e="xs"){var i;const t=Gr(),{open:s}=We(),{open:r}=lo(),o=ok(),a=((i=t.data)==null?void 0:i.members.find(c=>c.isSelf))??null;return{you:a===null?null:{name:a.displayName,face:TC(a,e),onOpen:()=>r(a.id)},accountStatus:rk(o),onOpenAccount:()=>s("account"),onOpenSettings:()=>s()}}function DC(e=[]){var m;const t=Gr(),s=se(),r=oe(),o=Yd(),a=((m=t.data)==null?void 0:m.members.find(u=>u.isSelf))??null,{data:i,refetch:c}=ge({queryKey:ke.current(),queryFn:()=>s.getConfig(),staleTime:zi}),d=l.useCallback(async()=>{var h,g;await r.invalidateQueries({queryKey:ke.all});const u=await c(),f=(h=u.data)==null?void 0:h.version,p=((g=u.data)==null?void 0:g.latestVersion)??null;if(f===void 0){ae.error("Couldn’t check for updates");return}if(p!==null&&oo(p,f)){ae.success(`Version ${p} is available`);return}ae.success("You’re up to date")},[r,c]);return{teamName:RC((a==null?void 0:a.displayName)??null),nameUnknown:t.isPending,identityNodes:EC(o),nodes:[...e,...IC({version:(i==null?void 0:i.version)??null,isDevMode:(i==null?void 0:i.isDevMode)??!1,onCheckForUpdates:()=>void d()})]}}const OC="https://dorkos.ai/docs/self-hosting/space-server";function MC(e){const t=[];for(const s of e)s.hostOperator===!0&&!t.includes(s.pinnedOrigin)&&t.push(s.pinnedOrigin);return t}function _C(e){var o,a,i;const t=e.status!=="pending"&&((o=e.access)==null?void 0:o.state)!=="unverified",s=((i=(a=e.access)==null?void 0:a.lastKnown)==null?void 0:i.lifecycle)??null,r=e.status==="connected";return{hostReachable:t,canInvite:t&&r&&s==="active",canOpenSettings:t,canLeave:t&&r}}function qn(e){try{return new URL(e).host}catch{return e}}function PC(e){const t=[],s=e.selected;if(s){const{connection:i,availability:c}=s,d=[],m={host:qn(i.pinnedOrigin)};c.canInvite&&d.push({kind:"action",id:"community-invite",label:"Invite people",icon:af,external:m,run:e.onInvite}),c.canOpenSettings&&d.push({kind:"action",id:"community-settings",label:"Space settings",icon:Cs,external:m,run:e.onOpenSettings}),s.canMoveUp&&d.push({kind:"action",id:"community-move-up",label:"Move up",icon:cf,run:()=>e.onMove("up")}),s.canMoveDown&&d.push({kind:"action",id:"community-move-down",label:"Move down",icon:lf,run:()=>e.onMove("down")}),d.push({kind:"separator",id:"community-sep-end"}),d.push({kind:"action",id:"community-disconnect",label:"Disconnect",icon:df,opensInput:!0,destructive:!0,run:e.onDisconnect}),c.canLeave&&d.push({kind:"action",id:"community-leave",label:"Leave space",icon:uf,opensInput:!0,external:m,run:e.onLeave}),t.push({kind:"submenu",id:"community-actions",label:`Manage ${i.label}`,icon:hr,items:d})}e.onJoinOfficial&&t.push({kind:"action",id:"join-official-space",label:"Join the DorkOS community",icon:fr,opensInput:!0,run:e.onJoinOfficial});const r=e.onJoin;if(!r)return t;const o=[...e.creationOrigins.map(i=>({kind:"action",id:e.creationOrigins.length===1?"add-community-create":`add-community-create-${qn(i)}`,label:e.creationOrigins.length===1?"Create a space on your server":`Create a space on ${qn(i)}`,icon:Ub,opensInput:!0,external:{host:qn(i)},run:()=>e.onCreate(i)})),{kind:"action",id:"add-community-deploy",label:"Run your own space server",icon:of,run:e.onDeploy}],a=[];return e.hosting&&a.push({kind:"action",id:"add-community-start",label:"Start a space",icon:uo,opensInput:!0,run:e.hosting.onStart}),a.push({kind:"action",id:"add-community-join",label:"Join a space",icon:fr,opensInput:!0,run:r}),e.hosting&&a.push({kind:"action",id:"add-community-yours",label:"Your spaces",icon:$b,guardsFocus:!0,run:e.hosting.onOpenYourSpaces}),a.push({kind:"separator",id:"add-community-sep-advanced"},{kind:"submenu",id:"add-community-advanced",label:"Advanced",icon:Xi,items:o}),t.push({kind:"submenu",id:"add-community",label:"Add a space",icon:Kt,items:a}),t}function Vd(e){var s,r,o,a,i,c;const t=(r=(s=e.access)==null?void 0:s.lastKnown)==null?void 0:r.lifecycle;return{kind:"community",key:`community:${e.ref}`,ref:e.ref,remoteCommunityId:e.remoteCommunityId,label:e.label,icon:{kind:"community",ref:e.ref},pinnedOrigin:e.pinnedOrigin,membershipState:t==="deletion_pending"?"deletion-pending":t==="taken_down"?"taken-down":t??(e.status==="pending"?"pending":"active"),connectionState:e.status,availability:((o=e.access)==null?void 0:o.state)==="verified"?"online":((a=e.access)==null?void 0:a.state)==="unverified"?"offline":"unknown",unreadCount:((i=e.attention)==null?void 0:i.unreadCount)??null,mentionCount:((c=e.attention)==null?void 0:c.mentionCount)??null}}function LC(e){var r,o;if(e.status==="reconnect-required")return"Reconnect required";const t=(o=(r=e.access)==null?void 0:r.lastKnown)==null?void 0:o.lifecycle;if(e.seemsGoneSince&&t!=="deleted"&&t!=="taken_down")return"Seems to be gone";const s=Vd(e);if(s.membershipState!=="active")return s.membershipState.replace("-"," ");if(s.availability!=="online")return s.availability}function FC(e,t){const s=new Map(t.map((r,o)=>[r,o]));return[...e].sort((r,o)=>{const a=s.get(r.ref)??Number.MAX_SAFE_INTEGER,i=s.get(o.ref)??Number.MAX_SAFE_INTEGER;return a-i||r.label.localeCompare(o.label)||r.ref.localeCompare(o.ref)})}function $C(e){return e.charAt(0).toLowerCase()+e.slice(1)}function BC(e,t){const s=mf(),r=$c(e),o=hf();return{spaces:s.enabled,anySpace:s.anySpace,selectedRef:r.visible?e:void 0,visible:(t??[]).filter(a=>ff(a,s.enabled)),joinOfficial:o.link!==null&&!o.joined?o.join:null}}function zC(e){const t=Xo(r=>r.url),s=Xo(r=>r.take);l.useEffect(()=>{if(t===null)return;const r=s();r!==null&&e(r)},[t,s])}function UC({connection:e,onOpenChange:t,onDisconnected:s}){var p;const r=Wc(),o=zl(e),[a,i]=l.useState(e);e!==null&&e!==a&&i(e);const c=(a==null?void 0:a.label)??"this space",d=(a==null?void 0:a.status)==="pending"?[]:(p=o.data)==null?void 0:p.agents,m=d===void 0&&o.fetchStatus==="fetching",u=d?Kl(c,d):m?null:Hl(c);function f(){e&&r.mutate(e,{onSuccess:h=>{t(!1);const g=Wl(e.label,h);g.tone==="success"?ae.success(g.message):ae.warning(g.message,{duration:15e3}),s(e)}})}return n.jsx(pf,{open:e!==null,onOpenChange:h=>{h||r.reset(),t(h)},children:n.jsxs(gf,{children:[n.jsxs(xf,{children:[n.jsxs(bf,{children:["Disconnect this DorkOS from ",c,"?"]}),n.jsx(yf,{asChild:!0,children:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("p",{children:["Its channels leave this app. You stay a member of ",c,"."]}),n.jsx("p",{children:"You can connect again later."}),u&&n.jsx("p",{className:"text-foreground",children:u}),m&&n.jsx("p",{children:"Checking for agents you added from here…"})]})})]}),o.isError&&d===void 0&&!m&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",c,"."]}),n.jsx(M,{size:"sm",variant:"outline",onClick:()=>void o.refetch(),children:"Check again"})]}),r.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."}),n.jsxs(vf,{children:[n.jsx(wf,{disabled:r.isPending,children:"Keep connected"}),n.jsx(M,{variant:"destructive",disabled:r.isPending||m,onClick:f,children:r.isPending?"Disconnecting…":"Disconnect"})]})]})})}function KC(e,t){var r;const s=typeof e=="object"&&e!==null?e:{};switch(s.code){case"COMMUNITY_SELECTION_REQUIRED":return`That address has several spaces. Use one space’s own link, like ${WC(t)}.`;case"COMMUNITY_NAME_NOT_FOUND":return"No space uses that address. Check the spelling, or ask for its full link.";case"COMMUNITY_RATE_LIMITED":return`Too many tries. Your address may be fine. Wait ${jf((r=s.body)==null?void 0:r.retryAfterSeconds)}, then try again.`;case"COMMUNITY_UPGRADE_REQUIRED":return"This space’s server is too old for this DorkOS. Ask its owner to update it.";default:return"Couldn’t connect. Check the space’s address and try again."}}function HC(e){const t=typeof e=="object"&&e!==null?e.code:"";return t!=="COMMUNITY_RATE_LIMITED"&&t!=="COMMUNITY_UPGRADE_REQUIRED"}function WC(e){try{return`${new URL(e??"").origin}/your-space`}catch{return"https://example.com/acme"}}const qC="That invitation link is incomplete or isn’t secure. Copy the whole link again.";function GC(e){let t;try{t=new URL(e.trim())}catch{return!1}return/^\/(?:c\/[^/]+\/)?join\/?$/u.test(t.pathname)&&!pr(e)}function YC(e){const t=new URL(e.trim()),s=/^(\/c\/[^/]+)\/join\/?$/u.exec(t.pathname);return s?`${t.origin}${s[1]}`:t.origin}function VC({request:e,onOpenChange:t,installName:s,onConnected:r}){var P;const o=Cn(!0),a=Ns(!0),i=kf(o),c=e!==null,d=Ls(U=>U.links),m=Ls(U=>U.rememberLink),u=Ls(U=>U.ending),f=(o==null?void 0:o.ownerKey)??null,[p,h]=l.useState(null),g=U=>h(U===null?null:{owner:f,ref:U}),[x,b]=l.useState(null),[y,k]=l.useState(null),[j,A]=l.useState((u==null?void 0:u.id)??0),[v,S]=l.useState(null),[I,D]=l.useState(null);e!==I&&(D(e),e&&(g(e.ref),b(null))),p!==null&&f!==null&&p.owner!==f&&(p.owner===null?h({owner:f,ref:p.ref}):(h(null),b(null),S(null)));const O=p!==null&&p.owner===f?p.ref:null,E=O===null||(P=a.data)==null?void 0:P.find(U=>U.ref===O),w=!E&&y!==null&&!y.settled&&y.address===i&&y.connection.ref===O?y.connection:null,C=E??w;if(C&&f!==null&&((v==null?void 0:v.owner)!==f||v.ref!==C.ref||v.label!==C.label)&&S({owner:f,ref:C.ref,label:C.label}),u&&u.id!==j)A(u.id),u.ref===O&&u.outcome!=="connected"&&(g(null),b({address:i,value:u.outcome==="expired"?`Approval for ${u.label} expired. Connect again to continue.`:`Approval for ${u.label} was cancelled.`}));else if(c&&O!==null&&!C&&a.isSuccess){const U=(v==null?void 0:v.owner)===f&&v.ref===O?v.label:"this space";g(null),b({address:i,value:`Approval for ${U} ended somewhere else. Connect again to continue.`})}Sf(c&&(C==null?void 0:C.status)==="pending"?C.ref:null);const N=Cf((C==null?void 0:C.status)==="pending"?C:null),T=c&&(C==null?void 0:C.status)==="connected"?C.ref:null,R=l.useRef(r),_=l.useRef(t);return l.useEffect(()=>{R.current=r,_.current=t}),l.useEffect(()=>{T===null||!C||(ae.success(`${C.label} is connected.`,{id:`community-approval-${T}`}),_.current(!1),R.current(T))},[T]),n.jsx(Ze,{open:c,onOpenChange:t,children:n.jsx(et,{className:"!min-h-0 sm:max-w-md",children:n.jsx(QC,{authority:o,connection:C,check:N,approvalUrl:C&&(d==null?void 0:d.address)===i?d.urls[C.ref]:void 0,notice:(x==null?void 0:x.address)===i?x.value:"",installName:s,initialUrl:I==null?void 0:I.url,onStarted:U=>{m(i,U.connection.ref,U.approvalUrl),k({address:i,connection:U.connection,settled:!1}),g(U.connection.ref),b({address:i,value:`Next, approve this DorkOS on ${U.connection.label}.`})},onStartSettled:U=>k(H=>(H==null?void 0:H.connection.ref)===U?{...H,settled:!0}:H),onEnded:U=>{g(null),b({address:i,value:U})},onCancelled:U=>{t(!1),ae.success(`Approval for ${U} was cancelled.`)},onClose:()=>t(!1)})})})}function QC({authority:e,connection:t,check:s,approvalUrl:r,notice:o,installName:a,initialUrl:i,onStarted:c,onStartSettled:d,onEnded:m,onCancelled:u,onClose:f}){const p=se(),h=oe(),g=pc(),x=l.useId(),[b,y]=l.useState(i??""),[k,j]=l.useState(null),[A,v]=l.useState(!1),[S,I]=l.useState(a),D=l.useRef(null),O=l.useRef(null),E=t===null?"form":t.status,w=l.useRef(E);l.useEffect(()=>{var G,ee;const q=w.current;w.current=E,q!==E&&(E==="form"?(G=D.current)==null||G.focus():E==="pending"&&((ee=O.current)==null||ee.focus()))},[E]);const C=Ct({mutationFn:async q=>{if(!e||!ft(e))throw new Error("Community owner is still loading.");const G=await p.startCommunityConnection({url:q,installName:S.trim()});if(!ft(e))throw new Error("Community owner changed.");return G},onSuccess:async q=>{y(""),c(q),e&&await h.invalidateQueries({queryKey:rt.connections(e)}),d(q.connection.ref)}}),N=Wc(),T=zl((t==null?void 0:t.status)==="reconnect-required"?t:null),R=C.error;l.useEffect(()=>{var q;(R||A)&&((q=D.current)==null||q.focus())},[R,A]);const _=pr(b),P=A?qC:C.error?KC(C.error,C.variables):null;function U(q){if(q.preventDefault(),!(!b.trim()||C.isPending)){if(GC(b)){C.reset(),v(!0);return}if(pr(b)){if(!it(g.linkFor(b.trim())))return;y(YC(b)),j({host:new URL(b.trim()).host,withAccount:g.signsInWithAccount(b)}),C.reset();return}S.trim()&&C.mutate(b.trim())}}function H(q){N.mutate(q,{onSuccess:G=>{if(q.status==="pending")u(q.label);else{const ee=Wl(q.label,G);m(ee.tone==="success"?`${q.label} is disconnected. Connect again to continue.`:ee.message)}},onSettled:()=>{e&&h.invalidateQueries({queryKey:rt.connections(e)})}})}const ne=n.jsx("p",{role:"status","aria-live":"polite",className:o?"text-muted-foreground text-sm":"sr-only",children:o});if(t===null)return n.jsxs("form",{onSubmit:U,children:[n.jsxs(Ve,{children:[n.jsx(Fe,{children:"Join a space"}),n.jsx(Qe,{children:"Bring a space’s channels here. You approve it on the space’s site."})]}),n.jsxs(at,{className:"space-y-4 py-4",children:[ne,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ie,{htmlFor:`${x}-url`,children:"Space address or invitation link"}),n.jsx(Je,{ref:D,id:`${x}-url`,type:"url",inputMode:"url",placeholder:"https://example.com/acme","aria-describedby":P?`${x}-url-hint ${x}-url-error`:`${x}-url-hint`,"aria-invalid":A||C.error&&HC(C.error)?!0:void 0,required:!0,autoComplete:"off",value:b,onChange:q=>{y(q.target.value),j(null),v(!1)},disabled:C.isPending||!e}),n.jsx("p",{id:`${x}-url-hint`,"aria-live":"polite",className:"text-muted-foreground text-xs",children:k?k.withAccount?`Join on ${k.host} with your DorkOS account in the new tab, then connect.`:`Finish joining on ${k.host} in the new tab, then connect.`:"Its link, short address or an invitation link."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ie,{htmlFor:`${x}-name`,children:"Name for this installation"}),n.jsx(Je,{id:`${x}-name`,required:!0,maxLength:120,"aria-describedby":`${x}-name-hint`,value:S,onChange:q=>I(q.target.value),disabled:C.isPending||!e}),n.jsx("p",{id:`${x}-name-hint`,className:"text-muted-foreground text-xs",children:"What the space calls this DorkOS."})]}),P&&n.jsx("p",{id:`${x}-url-error`,role:"alert",className:"text-destructive text-sm",children:P})]}),n.jsxs(Ot,{children:[n.jsx(M,{type:"button",variant:"outline",onClick:f,children:"Cancel"}),n.jsx(M,{type:"submit",disabled:C.isPending||!b.trim()||!_&&(!e||!S.trim()),children:C.isPending?"Connecting…":_?"Open invitation":"Connect"})]})]});const te=n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:t.pinnedOrigin});if(t.status==="reconnect-required"){const q=!T.data&&T.fetchStatus==="fetching",G=T.data?Kl(t.label,T.data.agents):q?null:Hl(t.label);return n.jsxs(n.Fragment,{children:[n.jsxs(Ve,{children:[n.jsxs(Fe,{children:["Reconnect ",t.label]}),n.jsxs(Qe,{children:["DorkOS can’t reach ",t.label,"’s channels. Disconnect, then connect again."]})]}),n.jsxs(at,{className:"space-y-3 py-4",children:[te,G&&n.jsx("p",{className:"text-sm",children:G}),T.isError&&!T.data&&!q&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",t.label,"."]}),n.jsx(M,{size:"sm",variant:"outline",onClick:()=>void T.refetch(),children:"Check again"})]}),N.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."})]}),n.jsxs(Ot,{children:[n.jsx(M,{type:"button",variant:"outline",onClick:f,children:"Close"}),n.jsx(M,{disabled:N.isPending||q,onClick:()=>H(t),children:N.isPending?"Disconnecting…":"Disconnect"})]})]})}return n.jsxs(n.Fragment,{children:[n.jsxs(Ve,{children:[n.jsxs(Fe,{children:["Approve on ",t.label]}),n.jsx(Qe,{asChild:!0,children:n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{children:["Approve this DorkOS on ",t.label,"’s site."]}),r&&g.signsInWithAccount(r)&&n.jsx("p",{children:"Sign in there with your DorkOS account."}),n.jsx("p",{children:"This screen moves on once you do."})]})})]}),n.jsxs(at,{className:"space-y-3 py-4",children:[te,ne,n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(we,{})," Waiting for your approval"]}),r?n.jsx(M,{asChild:!0,children:n.jsxs("a",{ref:O,href:g.linkFor(r),target:"_blank",rel:"noopener noreferrer",children:["Open ",t.label," to approve",n.jsx(_t,{className:"size-3.5","aria-hidden":!0})]})}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"Approve in the tab that opened. Closed it? Cancel and connect again."}),(N.isError||!!s.error)&&n.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[n.jsx("p",{children:N.isError?"Couldn’t confirm it was cancelled. Refresh to check.":"Couldn’t check approval. Try again."}),!N.isError&&n.jsx(M,{size:"sm",variant:"outline",onClick:s.retry,disabled:s.isFetching,children:"Check approval"})]})]}),n.jsxs(Ot,{children:[n.jsx(M,{type:"button",variant:"outline",onClick:f,children:"Close"}),n.jsx(M,{variant:"outline",disabled:N.isPending,onClick:()=>H(t),children:N.isPending?"Cancelling…":"Cancel approval"})]})]})}function XC(e){if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;const t=[...e.currentTarget.querySelectorAll('[role^="menuitem"]:not(:disabled):not([aria-disabled="true"])')];if(t.length===0)return;e.preventDefault();const s=t.indexOf(document.activeElement),r=t.length-1;let o;e.key==="Home"?o=0:e.key==="End"?o=r:e.key==="ArrowDown"?o=s<0||s===r?0:s+1:o=s<=0?r:s-1,t[o].focus()}function oi({sheet:e,label:t="Actions",children:s}){return e?n.jsx("div",{role:"menu","aria-label":t,tabIndex:-1,onKeyDown:XC,children:s}):n.jsx(n.Fragment,{children:s})}function Zs(){let e=!1;const t=()=>{e=!0};return document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",t,!0),{acted:()=>e,stop:()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",t,!0)}}}function JC({trigger:e,selectedRef:t}){const s=se(),r=je(),o=Ce(),a=ve({select:h=>h.location}),i=l.useRef(!1),c=l.useRef(!1),[d,m]=l.useState(null);function u(h,g){var b;if(!r||(h||(c.current=!1),g))return;if(h){const y=Zs();Af({cancelled:y.acted}).finally(y.stop);return}const x=document.activeElement;(x===null||x===document.body)&&((b=e.current)==null||b.focus())}async function f(h){if(h.ref===t||i.current||h.status!=="connected")return;const g=Jo();if(g.ownerKey===null)return;const x={epoch:g.epoch,ownerKey:g.ownerKey},b={pathname:a.pathname,search:a.search};c.current=r;const y=Zs();i.current=!0,m(h.ref);let k=!1,j=null;try{await o({...ue.channels(),search:{community:h.ref}}),k=!0,j=wn();const A=await s.resolveCommunityNavigation(h.ref),v=A?null:(await s.listRemoteCommunityRooms(h.ref)).rooms.find(I=>I.readable&&!I.archived)??null,S=(A==null?void 0:A.roomId)??(v==null?void 0:v.roomId);if(!ft(x)||!j.isCurrent()){u(!1,y.acted());return}S&&await o({...ue.channels(),search:{community:h.ref,...S?{id:S}:{},...A!=null&&A.threadId?{thread:A.threadId}:{}}}),u(!0,y.acted())}catch{u(!1,y.acted()),k&&(j==null?void 0:j.isCurrent())===!0&&ft(x)&&await o({to:b.pathname,search:b.search,replace:!0}).then(()=>!0,()=>!1)&&ae.error(`Couldn’t open ${h.label}.`,{description:"You’re still where you were. Try again in a moment."})}finally{y.stop(),i.current=!1,m(null)}}async function p(){if(t===void 0||i.current)return;const h=Jo();if(h.ownerKey===null)return;const g={epoch:h.epoch,ownerKey:h.ownerKey},x=wn();c.current=r;const b=Zs();i.current=!0;try{const y=await s.getCommunityNavigation();if(y.ownerKey!==g.ownerKey||!ft(g)||!x.isCurrent()){u(!1,b.acted());return}const k=Nf.safeParse(y.installationDestination);await o(k.success?{to:k.data.path,search:k.data.search}:{...ue.home()}),u(!0,b.acted())}catch{const y=ft(g)&&x.isCurrent();y&&await o({...ue.home()}),u(y,b.acted())}finally{b.stop(),i.current=!1}}return{pendingRef:d,isSelecting:()=>i.current,holdCloseFocus:()=>{c.current=!0},takeCloseFocusHold:()=>{const h=c.current;return c.current=!1,h},selectCommunity:f,selectInstallation:p}}function ZC(e){const t=l.useRef(e);l.useEffect(()=>{t.current=e},[e]),l.useEffect(()=>{const s=r=>{if(r.isComposing||!(r.metaKey||r.ctrlKey)||!r.shiftKey||r.altKey||r.key.toLowerCase()!=="k")return;r.preventDefault();const o=document.activeElement;t.current(o instanceof HTMLElement&&o!==document.body?o:null)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}function Qd({triggerClassName:e,compact:t=!1}){var It;const s=je(),r=Ce(),o=ve({select:K=>K.location.search.community}),a=Ef(),i=If(),c=Ns(),{spaces:d,anySpace:m,selectedRef:u,visible:f,joinOfficial:p}=BC(o,c.data),h=l.useMemo(()=>{var K;return FC(f,((K=a.data)==null?void 0:K.order)??[])},[f,(It=a.data)==null?void 0:It.order]),g=h.find(K=>K.ref===u)??null,x=l.useRef(null),b=l.useRef(null),y=l.useRef(null),{pendingRef:k,isSelecting:j,holdCloseFocus:A,takeCloseFocusHold:v,selectCommunity:S,selectInstallation:I}=JC({trigger:y,selectedRef:u}),[D,O]=l.useState(""),[E,w]=l.useState(!1),[C,N]=l.useState(null),[T,R]=l.useState(null),_=Oj(),[P,U]=l.useState(null),H=u?h.findIndex(K=>K.ref===u):-1;function ne(K,ie){it(new URL(_f(K.remoteCommunityId,ie),K.pinnedOrigin).toString())}const te=PC({selected:g?{connection:g,availability:_C(g),canMoveUp:H>0,canMoveDown:H>=0&&H<h.length-1}:null,onMove:K=>{g&&i.mutate({ref:g.ref,direction:K})},onInvite:()=>g&&ne(g,"community"),onOpenSettings:()=>g&&ne(g),onLeave:()=>g&&ne(g,"account"),onDisconnect:()=>R(g),onJoin:d?()=>N({ref:null}):null,onJoinOfficial:p,creationOrigins:d?MC(h):[],onCreate:K=>it(new URL(Mf,K).toString()),onDeploy:()=>it(OC),hosting:d&&_?{onStart:()=>U({kind:"start"}),onOpenYourSpaces:()=>U({kind:"hosted"})}:null}),q=m?te:[];zC(K=>N({ref:null,url:K}));const G=DC(q),ee=Uc([...G.identityNodes,...G.nodes]),V=ee.nodes.slice(0,G.identityNodes.length),F=ee.nodes.slice(G.identityNodes.length),L=G.teamName,J=G.nameUnknown,le=u!==void 0&&c.data===void 0,Z=u===void 0?J:le,dt=u===void 0?L:(g==null?void 0:g.label)??"Space",Et=s&&h.length>=8&&D.trim().length>0?h.filter(K=>K.label.toLocaleLowerCase().includes(D.trim().toLocaleLowerCase())):h;ZC(K=>{b.current=K,w(!0)});function ut(K){if(j())return;if(b.current=null,K==="installation"){I();return}const ie=h.find(xe=>`community:${xe.ref}`===K);if(ie){if(ie.status==="connected"){S(ie);return}A(),N({ref:ie.ref})}}function tt(K){w(K),K||O("")}function X(K){if(ee.onCloseAutoFocus(K),v()){K.preventDefault();return}const ie=b.current;b.current=null,!(K.defaultPrevented||!(ie!=null&&ie.isConnected))&&(K.preventDefault(),ie.focus())}l.useEffect(()=>{if(!E)return;const K=requestAnimationFrame(()=>{var ie;return(ie=x.current)==null?void 0:ie.focus()});return()=>cancelAnimationFrame(K)},[E]);async function qe(K){var be;const xe=(be=(await c.refetch()).data)==null?void 0:be.find(Oe=>Oe.ref===K&&Oe.status==="connected");xe&&await S(xe)}function mt(K){rs(wn().destination)===K.ref&&r({...ue.home(),replace:!0})}return n.jsxs(n.Fragment,{children:[n.jsxs(Rf,{open:E,onOpenChange:tt,children:[n.jsx(Tf,{asChild:!0,children:n.jsxs("button",{ref:y,type:"button","data-testid":"sidebar-header-block","aria-label":Z?"Context menu":`${dt} menu`,"aria-busy":k!==null||void 0,className:e,children:[t?u===void 0?n.jsx(ha,{className:"size-4 shrink-0","aria-hidden":!0}):n.jsx(hr,{className:"size-4 shrink-0","aria-hidden":!0}):Z?n.jsx(xt,{className:"my-[3px] h-3.5 w-24 rounded-sm","data-testid":"sidebar-team-name-skeleton"}):n.jsx("span",{className:"truncate",children:dt}),n.jsx(At,{className:t?"size-3 shrink-0 opacity-50":"size-3.5 shrink-0 opacity-50","aria-hidden":!0}),n.jsx("span",{className:"sr-only",children:"Choose context"})]})}),n.jsxs(Df,{align:"start",className:"max-h-(--radix-dropdown-menu-content-available-height) w-64 overflow-y-auto",onCloseAutoFocus:X,children:[s&&n.jsx(Zo,{children:m?"Switch context":"Menu"}),n.jsx(oi,{sheet:s,label:"You",children:n.jsx(mr,{variant:s?"sheet":"dropdown",nodes:V,onSheetClose:()=>tt(!1)})}),m&&n.jsx(ea,{}),m&&!s&&n.jsx(Zo,{children:"Switch context"}),m&&s&&h.length>=8&&n.jsx("div",{className:"px-4 pb-2",children:n.jsx(Je,{type:"search",value:D,onChange:K=>O(K.target.value),placeholder:"Find a space","aria-label":"Find a space"})}),m&&n.jsxs(Of,{value:u?`community:${u}`:"installation",onValueChange:ut,children:[n.jsx(ta,{value:"installation",icon:ha,disabled:k!==null,itemRef:u===void 0?x:void 0,className:k!==null?"opacity-50":void 0,children:n.jsx("span",{className:"min-w-0 flex-1 truncate",children:L})}),Et.map(K=>{var ht;const ie=Vd(K),xe=ie.mentionCount??0,be=Math.max(0,(ie.unreadCount??0)-xe),Oe=[xe>0?`${xe} ${xe===1?"mention":"mentions"}`:null,be>0?`${be} other unread`:null,((ht=K.attention)==null?void 0:ht.state)==="stale"?`last checked ${$C(js(K.attention.verifiedAt))}`:null].filter(Boolean).join(", ");return n.jsx(ta,{value:`community:${K.ref}`,icon:hr,disabled:k!==null,itemRef:K.ref===u?x:void 0,description:[LC(K),Oe].filter(Boolean).join(" · ")||void 0,className:k!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate",children:K.label}),Qx(K)&&n.jsx("span",{role:"img",className:"bg-status-warning-dot size-2 shrink-0 rounded-full","aria-label":"Someone asked to take over this space",title:"Someone asked to take over this space"}),xe>0&&n.jsxs("span",{className:"bg-primary text-primary-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${xe} ${xe===1?"mention":"mentions"}`,children:["@",xe]}),be>0&&n.jsx("span",{className:"bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${be} other unread`,children:be})]})},K.ref)})]}),F.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(ea,{}),n.jsx(oi,{sheet:s,children:n.jsx(mr,{variant:s?"sheet":"dropdown",nodes:F,onSheetClose:()=>tt(!1)})})]})]})]}),n.jsx(VC,{request:C,onOpenChange:K=>{K||N(null)},installName:J?"My DorkOS":L,onConnected:K=>void qe(K)}),n.jsx(tk,{entry:_,dialog:P,onDialogChange:U,installName:J?"My DorkOS":L,onConnected:K=>void qe(K)}),n.jsx(UC,{connection:T,onOpenChange:K=>{K||R(null)},onDisconnected:mt})]})}function eN(){return n.jsx(Qd,{compact:!0,triggerClassName:z("hover:bg-accent focus-visible:ring-ring text-foreground flex shrink-0 items-center rounded-md px-1 py-1.5 outline-hidden focus-visible:ring-2",Qt)})}function Xd(){const e=je();return n.jsxs(Pf,{className:"gap-2 px-2 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[!e&&n.jsx(Qd,{triggerClassName:"text-sidebar-foreground hover:bg-sidebar-accent/70 focus-visible:ring-sidebar-ring flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left text-[13px] font-semibold outline-hidden transition-colors duration-150 focus-visible:ring-2"}),n.jsx(NC,{})]}),n.jsx(AC,{})]})}function tN(){const e=Yd("sm");return n.jsxs("div",{className:"space-y-1 pb-2",children:[e.you!==null&&n.jsx(ai,{leading:e.you.face,label:e.you.name,description:"View profile",onClick:e.you.onOpen}),n.jsx(ai,{leading:n.jsx(Hc,{className:"text-muted-foreground size-7 p-0.5","aria-hidden":!0}),label:"DorkOS account",description:e.accountStatus,onClick:e.onOpenAccount})]})}function ai({leading:e,label:t,description:s,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,className:z("hover:bg-accent focus-visible:ring-ring flex w-full items-center gap-3 rounded-md px-2 py-2 text-left outline-hidden focus-visible:ring-2",Qt),children:[n.jsx("span",{className:"flex shrink-0",children:e}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"text-foreground block truncate text-sm font-medium",children:t}),s!==void 0&&n.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:s})]}),n.jsx(zt,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0})]})}const nN=6e4;function sN(e){return e===null?!0:(e.selectionStart??0)===0&&(e.selectionEnd??0)===0}function rN(e,t,s){if(!e)return null;const r=t===null?s:[t,...s];for(const o of r){const{item:a}=o.item;if(a.type==="agent"&&Ne(a.data)===e)return{kind:"agent",agent:a.data};if((a.type==="room"||a.type==="dm")&&a.id===e)return{kind:"room",room:a.data}}return null}function oN(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=Nk(),s=B($=>$.openMessageSearch),[r,o]=l.useState(""),a=l.useRef(null),[i,c]=l.useState(""),d=l.useRef(null),[m,u]=l.useState([]),[f,p]=l.useState(null),[h,g]=l.useState(null),[x,b]=l.useState(null),y=m[m.length-1],[k,j]=l.useState(0),A=je(),v=B($=>$.globalPaletteInitialSearch),S=B($=>$.clearGlobalPaletteInitialSearch),I=l.useCallback(()=>{t(!1),S(),o(""),c(""),u([]),p(null),b(null)},[t,S]),{handleAgentSelect:D,startNewSession:O,handleFeatureAction:E,handleQuickAction:w,handleRoomSelect:C,handleSessionSelect:N,handleCommandSelect:T,handlePageSelect:R,recordAgentOpened:_,selectedCwd:P}=M0(I),U=oe(),H=l.useCallback($=>{const fe=Lf(U,$.projectPath);return Ff(fe?{session:fe}:{agentId:$.id})},[U]),ne=l.useCallback($=>{if(!$f()){D($);return}gn(H($),{target:"tab"}),_($.projectPath),I()},[H,D,_,I]),te=l.useCallback($=>{gn(H($),{target:"window"}),_($.projectPath),I()},[H,_,I]),q=Bf(),G=T0(),ee=ro(nN),{allAgents:V,newActions:F,rooms:L,sessions:J,continueRows:le,recent:Z,searchableItems:dt}=Ck(P,ee);zf(V);const{bestMatch:Et,rows:ut,prefix:tt,term:X}=I0(dt,r,{usage:G,now:ee,scope:x}),qe=tt==="#",mt=$0(X),It=mt?{term:mt,isScoped:x!==null,onSelect:()=>{I(),s(mt)}}:null,K=l.useMemo(()=>i?V.find($=>$.name===i)??null:null,[i,V]),ie=rN(i,Et,ut),xe=l.useCallback($=>{b($),o(""),c("")},[]),be=!A&&K!==null,Oe=l.useMemo(()=>{var $;return i?J.find(fe=>fe.id===i)??(($=le.find(fe=>fe.session.id===i))==null?void 0:$.session)??null:null},[i,J,le]),ht=Rd((f==null?void 0:f.id)??"",(f==null?void 0:f.projectPath)??""),Pn=l.useCallback(()=>{u($=>$.slice(0,-1)),p($=>m.length<=1?null:$),c("")},[m.length]),Ln=l.useCallback($=>{p($),u(fe=>[...fe,"agent-actions"]),o(""),c(""),j(fe=>fe+1)},[]);l.useEffect(()=>{e&&v!=null&&(o(v),S(),requestAnimationFrame(()=>{const $=a.current;if($){const fe=v.length;$.setSelectionRange(fe,fe)}}))},[e,v,S]);const Fn=l.useCallback($=>{t($),$?j(fe=>fe+1):(o(""),c(""),u([]),p(null),b(null))},[t]),Zt=L0({rootRef:d,activePage:y??"root",onPin:c,resetKey:JSON.stringify([e,y??null,r,x&&xd(x)])}),Is=!r&&x===null,Rs=l.useId(),Ts=n.jsx(Ze,{open:e,onOpenChange:Fn,children:n.jsx(et,{className:z("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",be?"max-w-[640px]":"max-w-[480px]",A&&"h-[85vh]"),children:n.jsxs(Y.div,{variants:_d,initial:"hidden",animate:"visible",exit:"exit",className:z("flex overflow-hidden",A&&"h-full flex-col"),children:[n.jsxs(qc,{ref:d,loop:!0,shouldFilter:!1,value:i,onValueChange:c,onPointerMove:Zt.onPointerMove,className:z("min-w-0 flex-1",A&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:$=>{if(Zt.onKeyDown($),$.key==="Enter"&&($.metaKey||$.ctrlKey)&&!y&&(Oe==null?void 0:Oe.cwd)!=null){$.preventDefault(),O(Oe.cwd),I();return}if($.key==="Enter"&&($.metaKey||$.ctrlKey)&&!y&&K){$.preventDefault(),ne(K);return}if($.key==="Enter"&&($.metaKey||$.ctrlKey)&&y==="agent-actions"&&f){$.preventDefault(),ne(f);return}if($.key==="Tab"&&!$.shiftKey&&!y&&ie){$.preventDefault(),$.stopPropagation(),xe(ie);return}if($.key==="Backspace"&&x&&!y&&sN(a.current)){$.preventDefault(),b(null);return}$.key==="Backspace"&&!r&&m.length>0&&($.preventDefault(),Pn()),$.key==="Escape"&&m.length>0&&($.preventDefault(),$.stopPropagation(),Pn())},children:[m.length>0&&n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 border-b px-3 py-1.5 text-xs",children:[n.jsx("button",{onClick:()=>{u([]),p(null),j($=>$+1)},className:"hover:text-foreground transition-colors",children:"All"}),n.jsx("span",{children:"/"}),n.jsxs("span",{children:["Agent: ",f==null?void 0:f.name]})]}),n.jsx(Gc,{ref:a,"data-testid":"command-palette-input",leading:x&&!y?n.jsx(F0,{scope:x}):void 0,placeholder:y==="agent-actions"?`${(f==null?void 0:f.name)??"Agent"} actions…`:x&&!y?"Search within…":"Search rooms, agents, commands…",value:r,onValueChange:o}),n.jsx(Yc,{children:n.jsxs(mn,{className:"h-full",children:[n.jsxs(Uf,{children:[n.jsx("p",{children:"No results found."}),n.jsx(Td,{className:"justify-center pb-0"})]}),n.jsx(Le,{mode:"wait",initial:!1,children:n.jsxs(Y.div,{"data-palette-page":y??"root",initial:{opacity:0,x:y?16:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:y?-16:16},transition:{duration:.15,ease:"easeOut"},children:[!y&&n.jsx(tS,{staggerKey:k,isZeroQuery:Is,isRoomMode:qe,scope:x,hasQuery:X.length>0,selectedCwd:P,selectedValue:i,continueRows:le,recent:Z,newActions:F,bestMatch:Et,rows:ut,rooms:L,searchHandoff:It,onFeatureAction:E,onQuickAction:w,onGoToAgentActions:Ln,onRoomSelect:C,onSessionSelect:$=>N($.id,$.cwd),onCommandSelect:T,onPageSelect:R}),y==="agent-actions"&&f&&n.jsx(z0,{agent:f,onOpenHere:()=>D(f),onOpenNewTab:()=>ne(f),onOpenNewWindow:q?()=>te(f):void 0,onNewSession:()=>{O(f.projectPath),_(f.projectPath),I()},onEditSettings:()=>{Kf.getState().openProfileDocked(f.projectPath),I()},onBrowseSessions:ht.sessionCount>0?()=>{g(f),_(f.projectPath),I()}:void 0,recentSessions:ht.recentSessions,onSelectSession:$=>N($,f.projectPath)})]},y??"root")})]})}),n.jsx(K0,{page:y,hasAgentSelected:be,canScope:!y&&ie!==null,isScoped:x!==null})]}),n.jsx(Le,{children:be&&K&&n.jsx(B0,{agent:K},K.id)})]})})});return n.jsxs(n.Fragment,{children:[n.jsx(Hf,{id:Rs,children:Ts}),h!==null&&n.jsx(Wf,{agentPath:h.projectPath,agentName:h.displayName??h.name,agentVisual:so(h),open:!0,onOpenChange:$=>{$||g(null)},onSelectSession:$=>N($,h.projectPath),onNewSession:()=>O(h.projectPath)})]})}const aN="",iN="";function cN(e){const t=[];let s=e,r=!1;for(;s.length>0;){const o=r?iN:aN,a=s.indexOf(o);if(a===-1){t.push({text:s,matched:r});break}a>0&&t.push({text:s.slice(0,a),matched:r}),s=s.slice(a+o.length),r=!r}return t}function lN({excerpt:e,className:t}){const s=cN(e);return n.jsx("span",{className:t,children:s.map((r,o)=>r.matched?n.jsx("mark",{className:"text-foreground bg-transparent font-semibold",children:r.text},o):n.jsx("span",{children:r.text},o))})}const Jd="rooms",dN=["claude-code","opencode"];function uN(e){if(e.source===Jd)return{kind:"room",...ue.channels(),search:{id:e.container,entry:e.ordinal}};if(e.sessionId===void 0)return{kind:"unopenable"};const t=e.messageId!==void 0&&dN.includes(e.source);return{kind:"session",...vt({session:e.sessionId,dir:e.containerPath??void 0,...t?{message:e.messageId}:{}})}}function mN(e,t){return e.source===Jd?t.get(e.container)??"Channel":e.containerPath===null?"Conversation":Vc(e.containerPath)}function hN(e){return e==="user"?"You":"Agent"}function fN({hit:e,containerLabel:t,value:s,onSelect:r,openable:o}){const a=e.source==="rooms"?co:qb;return n.jsxs(he,{value:s,onSelect:r,className:"flex flex-col items-start gap-1 py-2",children:[n.jsxs("div",{className:"text-muted-foreground flex w-full min-w-0 items-center gap-1.5 text-xs",children:[n.jsx(a,{className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 truncate",children:t}),n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"shrink-0",children:hN(e.role)}),!o&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"shrink-0",children:"Ran outside DorkOS"})]}),e.createdAt!==null&&n.jsx("span",{className:"ml-auto shrink-0 tabular-nums",children:js(e.createdAt)})]}),n.jsx(lN,{excerpt:e.excerpt,className:"text-foreground line-clamp-2 w-full text-sm break-words"}),e.containerPath!==null&&n.jsx("span",{dir:"rtl",className:"text-muted-foreground/70 text-3xs w-full truncate text-left",children:n.jsx("bdi",{dir:"ltr",children:e.containerPath})})]})}const pN=["Your channels and direct messages, as soon as they’re posted.","DorkOS chats can lag five minutes.","Claude Code, Codex and OpenCode chats, even outside DorkOS. These can lag five minutes."],gN=["Tool output is never searched: no errors, stack traces, file contents or diffs.","Matches whole words: “ogs” won’t find “dogs”. Type “dog*” to match word starts."],xN="Searches channels, direct messages, and DorkOS, Claude Code, Codex and OpenCode chats. Not tool output.",bN=`Type at least ${Qc} letters to search.`,yN="Search what was said…";function vN({detailOpen:e=!1,className:t}){const[s,r]=l.useState(null),o=s??e,a=gN;return n.jsxs(mo,{open:o,onOpenChange:r,className:z("px-3 py-2",t),children:[n.jsxs(ho,{className:z("text-muted-foreground/80 hover:text-foreground focus-ring text-2xs","flex w-full items-start gap-2 rounded-sm py-1 text-left leading-relaxed transition-colors"),children:[n.jsx("span",{className:"min-w-0 flex-1",children:xN}),n.jsx(At,{className:z("mt-0.5 size-3 shrink-0 transition-transform",!o&&"-rotate-90"),"aria-hidden":"true"})]}),n.jsx(fo,{children:n.jsxs("ul",{className:"mt-2 space-y-1.5",children:[pN.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Nt,{className:"text-brand mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:i})]},i)),a.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Gb,{className:"mt-0.5 size-3.5 shrink-0 opacity-60","aria-hidden":"true"}),n.jsx("span",{children:i})]},i))]})})]})}const wN=3e4,jN=e=>["message-search",e];function er(e){return qf(e).some(t=>t.length>=Qc)}function kN(e,t){const s=se(),r=SN(e,Gf),o=t&&er(e)&&er(r),{data:a,isFetching:i,error:c}=ge({queryKey:jN(r),queryFn:()=>s.search({q:r}),enabled:o,staleTime:wN,placeholderData:m=>m,retry:!1});return{submitted:o?r:"",tooShort:t&&r.trim().length>0&&!er(r),results:o?(a==null?void 0:a.results)??[]:[],warnings:o?(a==null?void 0:a.warnings)??[]:[],isSearching:o&&i,error:o&&c instanceof Error?c:null}}function SN(e,t){const[s,r]=l.useState(e);return l.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),s}function CN(){const e=B(t=>t.toggleMessageSearch);l.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&s.code==="KeyF"&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const tr="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function NN(){CN();const e=B(v=>v.messageSearchOpen),t=B(v=>v.messageSearchQuery),s=B(v=>v.setMessageSearchOpen),r=je(),o=Ce(),a=se(),[i,c]=l.useState("");l.useEffect(()=>{e&&c(t??"")},[e,t]);const{results:d,warnings:m,tooShort:u,isSearching:f,error:p,submitted:h}=kN(i,e),{data:g}=ks({includeArchived:!0}),x=l.useMemo(()=>{const v=new Map;for(const S of g??[])v.set(S.id,S.kind==="channel"&&S.slug?`#${S.slug}`:S.title);return v},[g]),b=l.useCallback(()=>s(!1),[s]),y=l.useCallback((v,S)=>{if(S.kind!=="unopenable"&&(b(),o({to:S.to,search:S.search}),S.kind==="session"&&v.containerPath!==null)){const I=v.containerPath;a.browseDirectory(I).catch(D=>{if((D==null?void 0:D.status)===404){ae.info("That folder is gone",{description:`${I} is gone, so nothing new can run there. You can still read it.`});return}ae.info("Couldn’t open that folder",{description:`DorkOS couldn’t read ${I}. The chat may not open.`})})}},[b,o,a]),k=d.length>0,j=!k&&!u&&!f&&h.trim().length>0&&p===null,A=!k&&!u&&h.trim().length>0&&p===null;return n.jsx(Ze,{open:e,onOpenChange:s,children:n.jsxs(et,{"data-testid":"message-search-dialog",className:z("!min-h-0 max-w-[560px] overflow-hidden p-0","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",r&&"h-[85vh]"),children:[n.jsx(Fe,{className:"sr-only",children:"Search your messages"}),n.jsx(Y.div,{variants:_d,initial:"hidden",animate:"visible",exit:"exit",className:z("flex overflow-hidden",r&&"h-full flex-col"),children:n.jsxs(qc,{loop:!0,shouldFilter:!1,className:z("min-w-0 flex-1",r&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),children:[n.jsx(Gc,{"data-testid":"message-search-input",placeholder:yN,value:i,onValueChange:c}),p!==null&&n.jsxs("p",{className:"text-destructive flex items-start gap-2 px-3 py-3 text-xs leading-relaxed",children:[n.jsx(Yf,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:p.message})]}),m.map(v=>n.jsxs("p",{role:"status",className:"text-muted-foreground text-2xs flex items-start gap-2 px-3 pt-2 leading-relaxed",children:[n.jsx(Li,{className:"mt-0.5 size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:v.message})]},v.source)),n.jsx(Yc,{children:n.jsx(mn,{className:"h-full",children:k&&n.jsx(Pe,{className:z("transition-opacity duration-150",f&&"opacity-60"),children:d.map(v=>{const S=`${v.source}:${v.container}:${v.ordinal}`,I=uN(v);return n.jsx(fN,{value:S,hit:v,containerLabel:mN(v,x),openable:I.kind!=="unopenable",onSelect:()=>y(v,I)},S)})})})}),p===null&&n.jsxs("div",{className:"max-h-[45vh] min-h-0 shrink-0 overflow-y-auto",children:[u&&n.jsx("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:bN}),j&&n.jsxs("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:["No messages match “",h.trim(),"”."]}),n.jsx(vN,{detailOpen:A})]}),n.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:tr,children:"↑↓"}),"Navigate"]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:tr,children:"Enter"}),"Open"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:tr,children:"esc"}),"Close"]})]})]})})]})})}function AN(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function EN(e){const t=We(),s=Zr(),r=lo();switch(e){case"settings":return{isOpen:t.isOpen,close:t.close};case"tasks":return{isOpen:s.isOpen,close:s.close};case"profile":return{isOpen:r.isOpen,close:r.close};default:return{isOpen:!1,close:()=>{}}}}function IN({contribution:e,openStateKey:t}){const s=B(u=>u[t]),r=B(u=>u[AN(t)]),o=EN(e.urlParam),a=o.isOpen,i=o.close,c=s||a,d=l.useCallback(u=>{r(u),!u&&a&&i()},[r,a,i]),m=e.component;return n.jsx(m,{open:c,onOpenChange:d})}function RN({contribution:e,openState:t}){const s=l.useSyncExternalStore(t.subscribe,t.getSnapshot),r=e.component;return s?n.jsx(Vf,{fallback:null,onError:o=>{console.error(`[extensions] Dialog ${e.id} crashed and was closed:`,o),t.set(!1)},children:n.jsx(r,{open:!0,onOpenChange:t.set})}):null}function TN({contribution:e}){return e.openState?n.jsx(RN,{contribution:e,openState:e.openState}):n.jsx(IN,{contribution:e,openStateKey:e.openStateKey})}function DN(){const e=vs("dialog");return n.jsx(n.Fragment,{children:e.map(t=>n.jsx(TN,{contribution:t},t.id))})}const ON=["session","id","thread","entry","itemId","agent","profile","continuedFrom","pkg","view","region","detail","panel"];function MN(e,t){if(e.length>=Fs)return e.slice(0,Fs);const s=new URLSearchParams(t);let r="";for(const o of ON)for(const a of s.getAll(o)){const i=new URLSearchParams([[o,a]]).toString(),c=r?`${r}&${i}`:i;e.length+1+c.length<=Fs&&(r=c)}return r?`${e}?${r}`:e}const _N=6e4,PN={bug:"when it’s fixed",idea:"when it ships",feedback:"when the team acts on it"};function LN(e,t){var s;return JSON.stringify([e.kind,t,e.screenshotDataUrl??null,((s=e.element)==null?void 0:s.selector)??null])}function ii(e,t,s,r){const o=vl("bug",e,t),a=[...Zf()];r&&a.push({at:new Date().toISOString(),kind:"console_error",message:Xf(r).slice(0,Jf)});const i=a.slice(-ep);return{clientReport:{version:o.version,platform:o.platform,runtimes:o.runtimes,flags:Object.fromEntries(Object.entries(o.flags).map(([c,d])=>[c,typeof d=="number"?String(d):d])),...hy(s)},...i.length>0?{breadcrumbs:i}:{}}}function FN(){const e=se(),t=ve({select:h=>h.location.pathname}),s=ve({select:h=>h.location.searchStr}),r=Qf(),o=MN(t,s),a=ve({select:h=>{const g=h.location.search;return typeof(g==null?void 0:g.session)=="string"?g.session:void 0}}),{data:i}=ge({queryKey:ke.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),[c,d]=l.useState(!1),m=Ce(),u=l.useRef(null),f=l.useCallback(h=>i?ii(i,t,r,h==null?void 0:h.crashStack):void 0,[i,t,r]),p=l.useCallback(async h=>{var v;const g=h.message.trim();if(!g)return!1;const x=(v=h.contact)==null?void 0:v.trim(),b=LN(h,g),y=u.current;if(y&&y.fingerprint===b&&Date.now()-y.at<_N)return ae.info("Already sent a moment ago."),!0;const k=h.includeDiagnostics?ii(i,t,r,h.crashStack):void 0,j=h.includeDiagnostics&&h.kind==="bug",A=!!(h.includeConversation&&a);d(!0);try{const S=k&&j?await ny():void 0,{ok:I}=await e.sendFeedback({kind:h.kind,message:g,...x?{contact:x}:{},...o?{route:o}:{},...k?{diagnostics:{...k,...S?{shellLogExcerpt:S}:{}}}:{},...j?{includeServerLogs:!0}:{},...A?{sessionId:a,includeTranscript:!0}:{},...h.screenshotDataUrl?{screenshot:{dataUrl:h.screenshotDataUrl}}:{},...h.anonymous?{anonymous:!0}:{},...h.element?{element:h.element}:{}});return I?(u.current={fingerprint:b,at:Date.now()},ae.success("Sent. Thank you.",{...h.notifyEmail?{description:`DorkOS emails ${h.notifyEmail} ${PN[h.kind]}.`}:{},action:{label:"Your reports",onClick:()=>m(ue.feedbackRequests())}})):ae.error("Couldn’t send. Your words are still here. Try again or open a GitHub issue."),I}finally{d(!1)}},[e,t,o,a,i,r,m]);return{isSubmitting:c,sessionId:a,route:o,buildDiagnostics:f,send:p}}const $N=24;function ci(e,t){const s=Math.max(e.left,t.left),r=Math.max(e.top,t.top),o=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height);return o<=s||a<=r?null:{left:s,top:r,width:o-s,height:a-r}}function BN(e){const{element:t,viewport:s,region:r,image:o}=e,a=e.padding??$N;if(o.width<=0||o.height<=0)return null;const i={left:t.left-a,top:t.top-a,width:t.width+a*2,height:t.height+a*2},c=ci(i,{left:0,top:0,width:s.width,height:s.height});if(!c)return null;const d=ci(c,r);if(!d)return null;const m=o.width/r.width,u=o.height/r.height,f=Math.round((d.left-r.left)*m),p=Math.round((d.top-r.top)*u),h=Math.round((d.left+d.width-r.left)*m),g=Math.round((d.top+d.height-r.top)*u),x=Math.min(Math.max(0,f),Math.max(0,o.width-1)),b=Math.min(Math.max(0,p),Math.max(0,o.height-1));return{sx:x,sy:b,sw:Math.max(1,h-x),sh:Math.max(1,g-b)}}function zN(e){return new Promise((t,s)=>{const r=new Image,o=i=>{clearTimeout(a),s(new $e("failed",i))},a=setTimeout(()=>o(`The capture did not decode within ${as}ms.`),as);r.onload=()=>{clearTimeout(a),t(r)},r.onerror=()=>o("The capture did not decode, so it cannot be cropped."),r.src=e})}function UN(e,t){const s=document.createElement("canvas");s.width=t.sw,s.height=t.sh;const r=s.getContext("2d");if(!r)throw new $e("failed","This browser gave no 2d canvas context to crop with.");return r.drawImage(e,t.sx,t.sy,t.sw,t.sh,0,0,t.sw,t.sh),s.toDataURL("image/png")}async function KN(e,t){const s=t.getBoundingClientRect();if(s.width===0&&s.height===0)throw new $e("failed","That element has no size to crop to.");if(!Fl().contains(t))throw new $e("failed","That element is not part of the app that was captured.");const r=await zN(e.dataUrl),o=BN({element:{left:s.left,top:s.top,width:s.width,height:s.height},viewport:{width:window.innerWidth,height:window.innerHeight},region:e.region,image:{width:r.naturalWidth||r.width,height:r.naturalHeight||r.height}});if(!o)throw new $e("failed","That element is no longer inside the captured picture.");return jr(UN(r,o))}const li={"too-large":"That image is too big to send. Crop it to the part that matters.",unreadable:"Couldn’t read that image. Try a PNG or JPEG.",unsupported:"This browser can’t prepare images to send."},HN={failed:"Couldn’t capture the app view. You can still add a screenshot yourself.",unsupported:"Couldn’t start the app capture. Reload, or add a screenshot yourself."};function WN(e){return e instanceof $e?HN[e.reason]:e instanceof kt?li[e.reason]:li.unreadable}const nr="Only images can be attached.",qN="Files";function cn(e){return e?Array.from(e.types).includes(qN):!1}function di(e){return e.find(t=>t.type.startsWith("image/"))}function GN(e={}){const{enabled:t=!1}=e,[s,r]=l.useState(null),[o,a]=l.useState(!1),[i,c]=l.useState(!1),d=l.useRef(0),m=l.useRef(0),u=l.useCallback(async v=>{const S=++m.current;a(!0);try{const I=await v();return S!==m.current?null:(r(I),I)}catch(I){return S!==m.current||ae.error(WN(I)),null}finally{S===m.current&&a(!1)}},[]),f=l.useCallback(async v=>{if(!v.type.startsWith("image/")){ae.error(nr);return}await u(()=>jr(v))},[u]),p=l.useCallback(async()=>{await u(async()=>jr(await dy()))},[u]),h=l.useCallback(v=>u(async()=>KN(await $l(),v)),[u]),g=l.useCallback(()=>{m.current+=1,r(null),a(!1)},[]),x=l.useCallback(v=>{m.current+=1,d.current=0,v!==void 0&&!vy(v)?(console.warn("[feedback] Ignoring an initial screenshot that is not a bounded image data URL."),r(null)):r(v??null),a(!1),c(!1)},[]);l.useEffect(()=>{if(!t)return;const v=S=>{cn(S.dataTransfer)&&S.preventDefault()};return window.addEventListener("dragover",v),window.addEventListener("drop",v),()=>{window.removeEventListener("dragover",v),window.removeEventListener("drop",v)}},[t]);const b=l.useCallback(v=>{var D;const S=Array.from(((D=v.clipboardData)==null?void 0:D.items)??[]).map(O=>O.getAsFile()).filter(O=>O!==null);if(S.length===0)return;const I=di(S);if(!I){ae.error(nr);return}v.preventDefault(),f(I)},[f]),y=l.useCallback(v=>{cn(v.dataTransfer)&&(v.preventDefault(),d.current+=1,c(!0))},[]),k=l.useCallback(v=>{cn(v.dataTransfer)&&(v.preventDefault(),v.dataTransfer.dropEffect="copy")},[]),j=l.useCallback(v=>{cn(v.dataTransfer)&&(d.current=Math.max(0,d.current-1),d.current===0&&c(!1))},[]),A=l.useCallback(v=>{if(!cn(v.dataTransfer))return;v.preventDefault(),d.current=0,c(!1);const S=di(Array.from(v.dataTransfer.files));if(!S){ae.error(nr);return}f(S)},[f]);return{dataUrl:s,isPreparing:o,isDraggingOver:i,attach:f,capture:p,captureElement:h,clear:g,reset:x,handlers:{onPaste:b,onDragEnter:y,onDragOver:k,onDragLeave:j,onDrop:A}}}const ui=sp,YN="root";function Zd(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["'\\[\]]/g,t=>`\\${t}`)}function mi(e,t){try{const s=t.ownerDocument.querySelectorAll(e);return s.length===1&&s[0]===t}catch{return!1}}function eu(e){return e.id?`#${Zd(e.id)}`:null}function $r(e,t){const s=e.getAttribute(t);return s?`[${t}="${Zd(s)}"]`:null}function VN(e){const t=e.tagName;let s=1,r=e.previousElementSibling;for(;r;)r.tagName===t&&(s+=1),r=r.previousElementSibling;return s}function QN(e){const t=e.tagName.toLowerCase(),s=eu(e);if(s)return s;const r=$r(e,"data-testid")??$r(e,"data-slot"),o=`:nth-of-type(${VN(e)})`;if(!r)return`${t}${o}`;const a=`${t}${r}`;return(e.parentElement?Array.from(e.parentElement.children).filter(c=>c.matches(a)):[e]).length===1?a:`${a}${o}`}function XN(e){for(const r of[eu(e),$r(e,"data-testid")])if(r&&r.length<=ui&&mi(r,e))return r;const t=[];let s=e;for(;s&&s.id!==YN&&s.tagName!=="BODY";){t.unshift(QN(s));const r=t.join(" > ");if(r.length>ui){t.shift();break}if(mi(r,e))return r;s=s.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function hi(e,t){var r;const s=(r=e.closest(`[${t}]`))==null?void 0:r.getAttribute(t);if(!(!s||s.length>tp))return s}const JN=8;function tu(e,t){const s=(t==null?void 0:t.closest("[data-testid]"))??null;if(!s||s===e)return s;const r=e.getBoundingClientRect().height;return r<=0||s.getBoundingClientRect().height<=r*JN?s:null}function ZN(e){const t=hi(e,"data-slot"),s=tu(e,e),r=s?hi(s,"data-testid"):void 0,o=nu(e);return{selector:XN(e),...t?{slot:t}:{},...r?{testId:r}:{},...o?{label:o}:{}}}const sr=40,eA=["button","a[href]","summary","input","select","textarea",'[role="button"]','[role="link"]','[role="menuitem"]','[role="tab"]','[role="option"]','[role="checkbox"]','[role="switch"]'].join(", "),tA=new Set(["INPUT","SELECT","TEXTAREA"]),nA=['[contenteditable]:not([contenteditable="false"])','[role="textbox"]','[role="searchbox"]','[role="combobox"]'].join(", "),sA=["h1","h2","h3","h4","h5","h6",'[role="heading"]',"label","legend","th","dt"].join(", ");function rA(e){if(typeof Intl<"u"&&"Segmenter"in Intl){const t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e),s=>s.segment)}return Array.from(e)}function pn(e){const t=(e??"").replace(/\s+/g," ").trim();if(!t)return;const s=rA(t);if(s.length<=sr)return t;const r=s.slice(0,sr-1),o=r.lastIndexOf(" ");return`${(o>sr/2?r.slice(0,o):r).join("").trimEnd()}…`}function oA(e){var r;const s=(((r=e.getAttribute("aria-labelledby"))==null?void 0:r.split(/\s+/).filter(Boolean))??[]).map(o=>{var a;return((a=e.ownerDocument.getElementById(o))==null?void 0:a.textContent)??""}).join(" ");return pn(s)}function Gn(e){return pn(e.getAttribute("aria-label"))??oA(e)}function nu(e){const t=aA(e);return t&&t.length<=np?t:void 0}function aA(e){var a,i;const t=e.closest(nA);if(t)return Gn(t);const s=e.closest(eA);if(s){if(tA.has(s.tagName)){const c=s;return Gn(s)??pn((i=(a=c.labels)==null?void 0:a[0])==null?void 0:i.textContent)}return Gn(s)??pn(s.textContent)}const r=Gn(e);if(r)return r;const o=e.closest(sA);return o?pn(o.textContent):void 0}function fi(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(r=>r.toLowerCase());if(t.length===0)return null;const s=t.join(" ");return s.charAt(0).toUpperCase()+s.slice(1)}function iA(e){var d;const t=nu(e);if(t)return{text:t,onScreen:!0};const s=e.getAttribute("data-testid")??e.getAttribute("data-slot"),r=s?fi(s):null;if(r)return{text:r,onScreen:!1};const o=(d=e.parentElement)==null?void 0:d.closest("[data-testid], [data-slot]"),i=(o&&tu(e,o)===o?o.getAttribute("data-testid"):null)??(o==null?void 0:o.getAttribute("data-slot")),c=i?fi(i):null;return c?{text:c,onScreen:!1}:null}const cA="This part";function su(e){return(e==null?void 0:e.text)??cA}function lA(e){return e?e.onScreen?`What’s wrong with “${e.text}”?`:`What’s wrong with the ${e.text.toLowerCase()}?`:"What’s wrong with this part?"}function dA(e){return e!=null&&e.onScreen?`Remove “${e.text}”`:`Remove ${su(e).toLowerCase()}`}const pi=500;function gi(e){const t=e.trim();return t.length>pi?`${t.slice(0,pi)}… [trimmed]`:t}function uA(e){const t=[`${e.role}: ${e.content.trim()}`.trim()];for(const s of e.toolCalls??[])t.push(` [tool: ${s.toolName}]`),s.input&&t.push(` input: ${gi(s.input)}`),s.result&&t.push(` result: ${gi(s.result)}`);return t.join(`
82
- `)}function mA(e){const t=e.slice(-20),s=rp(op(t.map(uA).join(`
83
-
84
- `))).trim();return s.length>na?`${s.slice(0,na-1)}…`:s}function hA(e,t){const s=se(),[r]=Dn(),{data:o,isLoading:a,isError:i}=ge({queryKey:["feedback-transcript-preview",e,r],queryFn:async()=>{const{messages:c}=await s.getMessages(e,r??void 0);return mA(c)},enabled:t&&!!e,staleTime:30*1e3});return{text:o??"",isLoading:a,isError:i}}function fA(){return n.jsx("div",{"data-slot":"feedback-preview-footer",className:"bg-background relative -mx-4 -mb-4 shrink-0 border-t px-4 py-3 sm:mx-0 sm:px-0",children:n.jsxs("p",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(Xc,{className:"size-3 shrink-0","aria-hidden":!0}),"Private. Only the DorkOS core team sees these. Never public."]})})}function _e({label:e,value:t}){return n.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1",children:[n.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:e}),n.jsx("span",{className:"text-foreground text-right font-mono text-xs break-all",children:t})]})}function pA({diagnostics:e,kind:t,route:s}){if(!e)return n.jsx("p",{className:"text-muted-foreground text-xs",children:"Gathering diagnostics…"});const{clientReport:r,breadcrumbs:o}=e,{viewport:a,browser:i,shell:c,theme:d,locale:m,timezone:u}=r;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"rounded-md border p-3",children:[n.jsx(_e,{label:"Page",value:s}),n.jsx(_e,{label:"Version",value:r.version}),n.jsx(_e,{label:"Platform",value:r.platform}),n.jsx(_e,{label:"Runtimes",value:r.runtimes.length?r.runtimes.join(", "):"none"}),a&&n.jsx(_e,{label:"Window",value:`${a.width}×${a.height}${a.devicePixelRatio&&a.devicePixelRatio!==1?` @${a.devicePixelRatio}x`:""}`}),c&&n.jsx(_e,{label:"Shell",value:c}),d&&n.jsx(_e,{label:"Theme",value:d}),m&&n.jsx(_e,{label:"Locale",value:m}),u&&n.jsx(_e,{label:"Timezone",value:u}),i&&n.jsx(_e,{label:"Browser",value:i}),Object.entries(r.flags).map(([f,p])=>n.jsx(_e,{label:f,value:String(p)},f))]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("span",{className:"text-muted-foreground text-xs font-medium",children:["Recent events (",(o==null?void 0:o.length)??0,")"]}),o&&o.length>0?n.jsx("ul",{className:"flex flex-col gap-1",children:o.map((f,p)=>n.jsxs("li",{className:"text-foreground font-mono text-xs break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:f.kind})," ",f.message]},p))}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent errors or warnings."})]}),t==="bug"&&n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:Re()?"Recent server and app log excerpts are added when you send.":"An excerpt of recent server logs is added when you send."}),n.jsx("p",{children:"Scrubbed first: home paths shown as ~, tokens removed, web addresses cut to the page."})]})]})}function gA({sessionId:e,active:t}){const{text:s,isLoading:r,isError:o}=hA(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(xt,{className:"h-4 w-3/4"}),n.jsx(xt,{className:"h-4 w-full"}),n.jsx(xt,{className:"h-4 w-2/3"})]}):o?n.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t load the chat preview."}):s?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:"The last ~10 turns, gathered and scrubbed when you send."}),n.jsx("p",{children:"Home paths shown as ~, tokens removed, long tool output trimmed."})]}),n.jsx("pre",{className:"text-foreground bg-muted/40 rounded-md p-3 font-mono text-xs break-words whitespace-pre-wrap",children:s})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent chat to attach."})}function xA({dataUrl:e}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Sent exactly as shown, shrunk to keep the message small."}),n.jsx("img",{src:e,alt:"The screenshot you attached",className:"bg-muted/30 w-full rounded-md border object-contain"})]})}function bA({open:e,onOpenChange:t,initialTab:s,diagnostics:r,kind:o,route:a,showConversation:i,sessionId:c,screenshotDataUrl:d}){const m=!je(),u=["diagnostics",...i?["conversation"]:[],...d?["screenshot"]:[]],f=u.includes(s)?s:"diagnostics";return n.jsx(Ze,{open:e,onOpenChange:t,children:n.jsxs(et,{className:z("max-h-[85vh]",m&&"max-w-lg"),children:[n.jsxs(Ve,{children:[n.jsx(Fe,{className:"text-sm font-medium",children:"What will be sent"}),n.jsx(Qe,{className:"text-muted-foreground text-xs",children:"Each part is sent only if its toggle is on."})]}),n.jsxs(ul,{defaultValue:f,className:"flex min-h-0 flex-col gap-3 px-4 pb-4 sm:px-0",children:[n.jsxs(ml,{className:z("grid shrink-0",u.length===3&&"grid-cols-3",u.length===2&&"grid-cols-2",u.length===1&&"grid-cols-1"),children:[n.jsx(Vn,{value:"diagnostics",children:"Diagnostics"}),i&&n.jsx(Vn,{value:"conversation",children:"Chat"}),d&&n.jsx(Vn,{value:"screenshot",children:"Screenshot"})]}),n.jsx(zs,{value:"diagnostics",className:"min-h-0",children:n.jsx(mn,{className:"max-h-[45vh]",children:n.jsx(pA,{diagnostics:r,kind:o,route:a})})}),i&&n.jsx(zs,{value:"conversation",className:"min-h-0",children:n.jsx(mn,{className:"max-h-[45vh]",children:n.jsx(gA,{sessionId:c,active:e})})}),d&&n.jsx(zs,{value:"screenshot",className:"min-h-0",children:n.jsx(mn,{className:"max-h-[45vh]",children:n.jsx(xA,{dataUrl:d})})}),n.jsx(fA,{})]},f)]})})}const yA="0 0 0 9999px rgb(0 0 0 / 0.5)";function vA(e){var r,o;const t=(r=e.closest("[data-slot]"))==null?void 0:r.getAttribute("data-slot");return((o=e.closest("[data-testid]"))==null?void 0:o.getAttribute("data-testid"))??t??e.tagName.toLowerCase()}function wA(e){let t=e;for(;t;){if(/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function jA({phase:e,onSelect:t,onCancel:s}){const r=l.useRef(null),o=l.useRef(null),[a,i]=l.useState(null),c=e==="picking",d=l.useCallback((x,b)=>{const y=r.current;if(!y)return null;const k=y.style.pointerEvents;y.style.pointerEvents="none";try{return document.elementFromPoint(x,b)}finally{y.style.pointerEvents=k}},[]),m=l.useCallback(x=>{var b;return x instanceof Node&&!!((b=o.current)!=null&&b.contains(x))},[]),u=l.useCallback(x=>{if(!c)return;if(m(x.target)){i(null);return}const b=d(x.clientX,x.clientY);if(!b){i(null);return}const y=b.getBoundingClientRect();i({element:b,box:{left:y.left,top:y.top,width:y.width,height:y.height},label:vA(b)})},[c,d,m]),f=l.useCallback(x=>{if(!c||m(x.target))return;const b=d(x.clientX,x.clientY)??(a==null?void 0:a.element);b&&t(b)},[c,d,m,t,a]),p=l.useCallback(x=>{if(!c)return;const b=wA(d(x.clientX,x.clientY));b==null||b.scrollBy({left:x.deltaX,top:x.deltaY})},[c,d]);l.useEffect(()=>{if(!c)return;const x=b=>{b.preventDefault(),b.stopImmediatePropagation(),b.key==="Escape"&&s()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[c,s]),l.useEffect(()=>{var b;const x=document.activeElement;return(b=r.current)==null||b.focus(),()=>{x instanceof HTMLElement&&x.focus()}},[]),l.useEffect(()=>{if(!c)return;const x=()=>{i(b=>{if(!b)return b;const y=b.element.getBoundingClientRect();return{...b,box:{left:y.left,top:y.top,width:y.width,height:y.height}}})};return window.addEventListener("scroll",x,!0),()=>window.removeEventListener("scroll",x,!0)},[c]);const h=c?a:null,g=h!==null&&h.box.top<28;return ms.createPortal(n.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":"Point at the part of the app that looks wrong",tabIndex:-1,className:z("fixed inset-0 z-50 focus:outline-none",c?"cursor-crosshair":"cursor-wait"),onPointerMove:u,onPointerLeave:()=>i(null),onClick:f,onWheel:p,onContextMenu:x=>{x.preventDefault(),c&&s()},children:[c&&(h?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-primary pointer-events-none absolute rounded-sm border-2",style:{left:h.box.left,top:h.box.top,width:h.box.width,height:h.box.height,boxShadow:yA}}),n.jsx("div",{className:"bg-primary text-primary-foreground pointer-events-none absolute max-w-[60vw] truncate rounded-sm px-1.5 py-0.5 font-mono text-[11px] leading-tight",style:{left:Math.max(4,h.box.left),top:g?h.box.top+h.box.height+4:h.box.top-22},children:h.label})]}):n.jsx("div",{className:"absolute inset-0 bg-black/50"})),c&&n.jsxs("div",{ref:o,className:"bg-popover text-popover-foreground absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3 rounded-lg border px-3 py-2 shadow-lg",children:[n.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[n.jsx(os,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Click the part that looks wrong. Esc to cancel."]}),n.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring rounded-sm text-xs underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Cancel"})]})]}),document.body)}const xi="text-muted-foreground hover:text-foreground h-8 px-2 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50";function rr({tip:e,children:t}){return n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:t}),n.jsx(qt,{className:"max-w-60 text-center",children:e})]})}function kA({showPictureTools:e,isPreparing:t,hasPointed:s,hasWords:r,isMobile:o,onCapture:a,onPointAtElement:i,onPick:c}){const d=l.useId(),m=l.useId(),u=l.useId(),f=l.useId();function p(k){var A;const j=(A=k.target.files)==null?void 0:A[0];k.target.value="",j&&c(j)}const h=r&&!o;if(!e&&!h)return null;const g=o?"Add a photo":"Add an image",x=o?"Add a photo from your library.":"Add an image from your files, or paste or drop one here.",b="Take a picture of this app. Never the rest of your screen.",y="Click the part that looks wrong. DorkOS crops the picture to it.";return n.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-t px-1.5 py-1.5",children:[e&&n.jsxs(n.Fragment,{children:[n.jsx("span",{id:m,className:"sr-only",children:b}),n.jsx(rr,{tip:b,children:n.jsxs(M,{"aria-describedby":m,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||a()},"aria-disabled":t||void 0,className:xi,children:[n.jsx(Bb,{className:"size-3.5","aria-hidden":!0}),"Capture app"]})}),!o&&n.jsx(rr,{tip:y,children:n.jsxs(M,{"aria-describedby":u,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||i()},"aria-disabled":t||void 0,className:xi,children:[n.jsx(os,{className:"size-3.5","aria-hidden":!0}),s?"Point again":"Point at it"]})}),!o&&n.jsx("span",{id:u,className:"sr-only",children:y}),n.jsx("span",{id:f,className:"sr-only",children:x}),n.jsx(rr,{tip:x,children:n.jsxs("label",{htmlFor:d,"aria-disabled":t||void 0,className:"text-muted-foreground hover:text-foreground hover:bg-accent focus-within:ring-ring flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors duration-150 focus-within:ring-2 aria-disabled:pointer-events-none aria-disabled:opacity-50",children:[n.jsx(px,{className:"size-3.5","aria-hidden":!0}),n.jsx("input",{id:d,type:"file",accept:"image/*","aria-label":g,"aria-describedby":f,disabled:t,className:"sr-only",onChange:p})]})})]}),h&&n.jsxs("span",{className:"text-muted-foreground ml-auto pr-1.5 text-xs","aria-hidden":!0,children:[wt?"⌘↵":"Ctrl+↵"," to send"]})]})}function bi({imageUrl:e,alt:t,caption:s,pointed:r=!1,detail:o,onOpen:a,onRemove:i,removeLabel:c}){const d=n.jsxs(n.Fragment,{children:[e?n.jsx("img",{src:e,alt:t,className:"size-full object-cover"}):n.jsx("span",{className:"text-muted-foreground flex size-full items-center justify-center",children:n.jsx(os,{className:"size-4","aria-hidden":!0})}),s&&n.jsxs("span",{className:"bg-background/85 absolute inset-x-0 bottom-0 flex items-center gap-1 truncate px-1.5 py-0.5 text-left text-[11px] leading-tight",children:[r&&n.jsx(os,{className:"size-3 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:s})]})]}),m=a?n.jsx("button",{type:"button",onClick:a,"aria-label":`Open ${t.charAt(0).toLowerCase()}${t.slice(1)}`,className:"focus-visible:ring-ring relative block size-full overflow-hidden rounded-[inherit] focus-visible:ring-2 focus-visible:outline-none",children:d}):n.jsx("div",{role:"img","aria-label":t,className:"relative size-full overflow-hidden rounded-[inherit]",children:d});return n.jsxs("div",{className:"bg-muted/40 relative h-16 w-28 shrink-0 rounded-md border",children:[o&&a?n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:m}),n.jsx(qt,{className:"max-w-72 font-mono text-[11px] break-all",children:o})]}):m,n.jsx("button",{type:"button",onClick:i,"aria-label":c,className:"bg-background/90 text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute top-1 right-1 flex size-5 items-center justify-center rounded-full border transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:n.jsx(Te,{className:"size-3","aria-hidden":!0})})]})}function yi({label:e,summary:t,pressed:s,onPressedChange:r,onPreview:o}){return n.jsxs("span",{className:z("inline-flex items-center rounded-full border text-xs transition-colors duration-150",s?"bg-muted/60 text-foreground":"text-muted-foreground"),children:[n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:n.jsxs("button",{type:"button","aria-pressed":s,onClick:()=>r(!s),className:"hover:text-foreground focus-visible:ring-ring flex items-center gap-1.5 rounded-full py-1 pr-1.5 pl-2.5 focus-visible:ring-2 focus-visible:outline-none",children:[n.jsx("span",{"aria-hidden":!0,className:z("size-1.5 rounded-full transition-colors duration-150",s?"bg-primary":"bg-muted-foreground/40")}),e]})}),n.jsx(qt,{className:"max-w-60",children:t})]}),n.jsx("button",{type:"button",onClick:o,"aria-label":`Preview ${e.toLowerCase()}`,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring flex items-center rounded-full py-1 pr-2.5 pl-1 focus-visible:ring-2 focus-visible:outline-none",children:n.jsx(ap,{className:"size-3.5","aria-hidden":!0})})]})}function SA({currentUser:e,anonymous:t,onToggleAnonymous:s,contact:r,onContactChange:o}){const a=l.useId(),i=l.useId();if(e)return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[t?n.jsx(Qb,{className:"size-3.5 shrink-0","aria-hidden":!0}):n.jsx(ip,{className:"size-3.5 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t?"Sending anonymously":`Replying to ${e.email}`}),n.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring shrink-0 rounded-sm underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:t?"Use my account":"Send anonymously"})]}),t&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Without your name or email, the team can’t reply. Track it in Your reports."})]});const c=r.trim().length>0&&!Jc(r);return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(Ie,{htmlFor:a,className:"text-xs",children:"Your email"}),n.jsx(Je,{id:a,type:"email",inputMode:"email",autoComplete:"email",value:r,onChange:d=>o(d.target.value),placeholder:"you@example.com",maxLength:cp,"aria-describedby":i,onKeyDown:d=>{d.key==="Enter"&&!d.metaKey&&!d.ctrlKey&&d.preventDefault()},"aria-invalid":c||void 0}),n.jsx("p",{id:i,className:"text-muted-foreground text-xs",children:c?"Not an email yet, so no reply can reach you.":"Get a note when it’s fixed. DorkOS remembers it."})]})}const CA=[{value:"feedback",label:"Feedback",icon:gs},{value:"bug",label:"Bug",icon:lp},{value:"idea",label:"Idea",icon:gx}];function NA({kind:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"What kind of feedback",className:"flex gap-1.5",children:CA.map(({value:s,label:r,icon:o})=>{const a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:z("focus-visible:ring-ring flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",a?"border-foreground/60 text-foreground bg-muted/60":"text-muted-foreground hover:text-foreground"),children:[n.jsx(o,{className:"size-3.5","aria-hidden":!0}),r]},s)})})}function AA({needsWords:e,canSend:t,isSubmitting:s,onOpenGitHubIssue:r}){const o=l.useId();return n.jsxs(Ot,{className:"shrink-0 flex-col gap-2 sm:flex-col sm:justify-start sm:space-x-0",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[e?n.jsx("p",{id:o,"aria-live":"polite",className:"text-status-warning min-w-0 flex-1 text-xs",children:"Add a few words about what to look for."}):n.jsxs("p",{className:"text-muted-foreground flex min-w-0 flex-1 items-center gap-1.5 text-xs",children:[n.jsx(Xc,{className:"size-3 shrink-0","aria-hidden":!0}),"Only the DorkOS team sees this"]}),n.jsx(M,{type:"submit",disabled:!t,"aria-keyshortcuts":"Meta+Enter Control+Enter","aria-describedby":e?o:void 0,className:"shrink-0",children:s?"Sending…":"Send"})]}),n.jsxs("p",{className:"text-muted-foreground text-center text-xs",children:["Prefer a public GitHub issue?"," ",n.jsx("button",{type:"button",onClick:r,className:"hover:text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Open one instead"})]})]})}const EA={feedback:"What works, what does not, what you wish it did…",bug:"What happened, and what did you expect instead?",idea:"What would you like DorkOS to do?"};function vi(e,t,s){return{diagnostics:e==="bug"||s,conversation:e==="bug"&&t}}function IA({open:e,onOpenChange:t,initialKind:s,prefillMessage:r,crashStack:o,currentUser:a,initialScreenshotDataUrl:i}){const c=!je(),{isSubmitting:d,sessionId:m,route:u,buildDiagnostics:f,send:p}=FN(),h=Db(),g=!!m,x=!!a,b=l.useId(),[y,k]=l.useState(s??"feedback"),[j,A]=l.useState(r??""),[v,S]=l.useState(sa),[I,D]=l.useState(!1),[O,E]=l.useState(!1),[w,C]=l.useState(!1),[N,T]=l.useState(!1),[R,_]=l.useState("diagnostics"),[P,U]=l.useState(null),[H,ne]=l.useState(null),[te,q]=l.useState(null),[G,ee]=l.useState(null),[V,F]=l.useState(0),L=l.useRef(V);l.useEffect(()=>{L.current=V},[V]);const[J,le]=l.useState(!1),[Z,dt]=l.useState(o),[Et,ut]=l.useState(m),tt=l.useRef(null),X=GN({enabled:e}),qe=j.trim().length>0,mt=qe||X.dataUrl!==null||P!==null,[It,K]=l.useState(e);if(e!==It&&(K(e),e)){T(!1),ee(null);const Q=i;if(!!(r||o||Q)||!mt){const $n=s??"feedback",Bn=vi($n,g,!!o);k($n),A(r??""),S(sa()),D(!1),E(Bn.diagnostics),C(Bn.conversation),le(!1),U(null),ne(null),dt(o),ut(m),X.reset(Q),F(Ms=>Ms+1)}else m!==Et&&(C(!1),ut(m))}function ie(Q){const Me=vi(Q,g,!!Z);E(Me.diagnostics),C(Me.conversation)}function xe(Q){k(Q),ie(Q)}function be(Q){_(Q),T(!0)}async function Oe(Q){const Me=L.current,$n=ZN(Q),Bn=iA(Q);H&&X.dataUrl===H&&X.clear(),ne(null),ee("capturing");const Ms=await X.captureElement(Q);Me===L.current&&(ee(null),U($n),q(Bn),ne(Ms),k("bug"),J||ie("bug"))}function ht(){H&&X.dataUrl===H&&X.clear(),U(null),ne(null)}function Pn(){A(""),U(null),ne(null),le(!1),dt(void 0),X.clear()}const Ln=qe&&!d&&!X.isPreparing,Fn=x?I||a==null?void 0:a.email:Jc(v)?v.trim():void 0;async function Zt(){!Ln||!await p({kind:y,message:j,...x?{}:{contact:v},includeDiagnostics:O,includeConversation:w,anonymous:I,...Z?{crashStack:Z}:{},...X.dataUrl?{screenshotDataUrl:X.dataUrl}:{},...P?{element:P}:{},...Fn?{notifyEmail:Fn}:{}})||(x||mp(v),Pn(),t(!1))}function Is(Q){Q.preventDefault(),Zt()}function Rs(Q){const Me=tt.current;Me&&(Q.preventDefault(),Me.focus(),Me.setSelectionRange(Me.value.length,Me.value.length))}function Ts(Q){Q.key!=="Enter"||!(Q.metaKey||Q.ctrlKey)||Q.nativeEvent.isComposing||N||(Q.preventDefault(),Zt())}const $=X.handlers,fe=G!==null,Ds=P?te:null,Fo=su(Ds),Os=!!(P&&H&&X.dataUrl===H),$o=!!X.dataUrl&&!Os,fu=!qe&&(!!X.dataUrl||P!==null);return n.jsxs(n.Fragment,{children:[fe&&n.jsx(jA,{phase:G,onSelect:Q=>void Oe(Q),onCancel:()=>ee(null)}),n.jsx(Ze,{open:e&&!fe,onOpenChange:t,children:n.jsxs(et,{...$,onKeyDown:Ts,desktopProps:{className:"max-w-md",onOpenAutoFocus:Rs},className:z("max-h-[85vh] !min-h-0",X.isDraggingOver&&"ring-primary ring-2"),children:[n.jsxs(Ve,{children:[n.jsx(Fe,{className:"text-sm font-medium",children:"Send feedback"}),n.jsx(Qe,{className:"text-muted-foreground text-xs",children:"Straight to the DorkOS team. Private."})]}),n.jsxs("form",{onSubmit:Is,noValidate:!0,className:"flex min-h-0 flex-1 flex-col gap-4",children:[n.jsxs(at,{alignWithHeader:!0,className:"flex flex-col gap-4",children:[n.jsx(NA,{kind:y,onChange:xe}),n.jsxs("div",{className:z("dark:bg-input/30 flex flex-col rounded-lg border transition-[border-color,box-shadow] duration-150","focus-within:border-ring focus-within:ring-ring focus-within:ring-[3px]",X.isDraggingOver&&"border-primary"),children:[n.jsx(Ie,{htmlFor:b,className:"sr-only",children:"Your message"}),n.jsx(dp,{ref:tt,id:b,value:j,onChange:Q=>A(Q.target.value),placeholder:P?lA(Ds):EA[y],rows:4,maxLength:up,className:"min-h-24 resize-none rounded-lg border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent"}),(P||$o||X.isPreparing||X.isDraggingOver)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-2.5",children:[P&&n.jsx(bi,{imageUrl:Os?H??void 0:void 0,alt:`The part you pointed at: ${Fo}`,caption:Fo,pointed:!0,detail:P.selector,...Os?{onOpen:()=>be("screenshot")}:{},onRemove:ht,removeLabel:dA(Ds)}),$o&&X.dataUrl&&n.jsx(bi,{imageUrl:X.dataUrl,alt:"The screenshot you attached",onOpen:()=>be("screenshot"),onRemove:X.clear,removeLabel:"Remove screenshot"}),(X.isPreparing||X.isDraggingOver)&&n.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-xs",children:X.isDraggingOver?"Drop to attach":"Getting it ready…"})]}),n.jsx(kA,{showPictureTools:!0,isPreparing:X.isPreparing,hasPointed:P!==null,hasWords:qe,isMobile:!c,onCapture:()=>void X.capture(),onPointAtElement:()=>ee("picking"),onPick:Q=>void X.attach(Q)})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-muted-foreground mr-0.5 text-xs",children:"Also send"}),n.jsx(yi,{label:"Diagnostics",summary:"Version, window size, browser, and recent errors.",pressed:O,onPressedChange:Q=>{le(!0),E(Q)},onPreview:()=>be("diagnostics")}),g&&n.jsx(yi,{label:"This chat",summary:"Shows what led to the bug.",pressed:w,onPressedChange:Q=>{le(!0),C(Q)},onPreview:()=>be("conversation")})]}),n.jsx(SA,{currentUser:a??null,anonymous:I,onToggleAnonymous:()=>D(Q=>!Q),contact:v,onContactChange:S})]}),n.jsx(AA,{needsWords:fu,canSend:Ln,isSubmitting:d,onOpenGitHubIssue:()=>h(y==="idea"?"feature":"bug")})]}),n.jsx(bA,{open:N,onOpenChange:T,initialTab:R,diagnostics:f(Z?{crashStack:Z}:void 0),kind:y,route:u,showConversation:g,sessionId:m,...X.dataUrl?{screenshotDataUrl:X.dataUrl}:{}})]})})]})}function RA(){const e=ln(a=>a.open),t=ln(a=>a.prefill),s=ln(a=>a.openFeedback),r=ln(a=>a.setOpen),o=hp();return l.useEffect(()=>{const a=fp();a&&s(a)},[s]),n.jsx(IA,{open:e,onOpenChange:r,initialKind:t.kind,prefillMessage:t.message,crashStack:t.crashStack,currentUser:o?{email:o.email,name:o.name}:null})}const TA=new Set(["permission-prompt","question","schedule-approval"]),DA={"permission-prompt":"Needs your approval to go on.",question:"Has a question for you.","schedule-approval":"Wants to run on a timer."};function ru(e){const t=Lc(),s=pp(),r=Mt(e),o=l.useRef(null);l.useEffect(()=>{var m,u,f,p;if(s)return;const a=new Map;for(const h of t)TA.has(h.kind)&&a.set(h.id,{id:h.id,who:h.primary,summary:DA[h.kind],deepLink:h.deepLink});const i=o.current;if(o.current=new Set(a.keys()),i===null)return;const c=[...a.values()].filter(h=>!i.has(h.id)),d=[...i].filter(h=>!a.has(h));c.length>0&&((u=(m=r.read()).onArrive)==null||u.call(m,c)),d.length>0&&((p=(f=r.read()).onDepart)==null||p.call(f,d,a.size))},[s,t,r])}function OA(){const{permission:e}=gp(),{prefs:t}=xp(),s=po(),r=Re(),o=l.useRef(new Map),a=Mt(s),i=l.useCallback(()=>r||e!=="granted"||typeof document>"u"||!document.hidden?!1:typeof window<"u"&&typeof window.Notification<"u",[r,e]),c=l.useCallback((f,p,h,g)=>{let x;try{x=new Notification(p,{body:h,tag:f,silent:!0})}catch{return}x.onclick=()=>{var b;window.focus(),x.close(),o.current.delete(f),g!==null&&((b=a.read())==null||b({href:g}))},x.onclose=()=>{o.current.delete(f)},o.current.set(f,{notification:x,href:g})},[a]),d=l.useCallback(f=>{if(i())for(const p of f)c(p.id,`${p.who} needs you`,p.summary,p.deepLink)},[i,c]),m=l.useCallback(f=>{for(const p of f){const h=o.current.get(p);h!==void 0&&(h.notification.close(),o.current.delete(p))}},[]);ru({onArrive:d,onDepart:m});const u=t.notifyOnTurnCompleteWhileAway;ce("notification",f=>{const p=bp.safeParse(f);if(!p.success)return;const h=p.data.notification;if(h.tier!=="notable"||!u||!i())return;const g=yp(h),x=g===null?null:MA(g.to,g.search);c(h.id,h.title,h.body??"",x)}),l.useEffect(()=>{const f=o.current;return()=>{for(const{notification:p}of f.values())p.close();f.clear()}},[])}function MA(e,t){const s=new URLSearchParams;for(const[o,a]of Object.entries(t))a!=null&&s.set(o,String(a));const r=s.toString();return r===""?e:`${e}?${r}`}function _A(){const{play:e}=Ix(),t=l.useCallback(()=>{e("knock"),Rx()},[e]),s=l.useCallback((r,o)=>{o===0&&e("settle")},[e]);return ru({onArrive:t,onDepart:s}),OA(),null}function PA(){const e=Ce();l.useEffect(()=>{var s,r,o;if(!((s=window.electronAPI)!=null&&s.onNavigate))return;const t=window.electronAPI.onNavigate(a=>{e({href:a})});return(o=(r=window.electronAPI).getPendingNavigate)==null||o.call(r).then(a=>{a&&e({href:a})}),t},[e])}function LA(){const{closeActive:e}=jo();l.useEffect(()=>{const t=window.electronAPI;if(t!=null&&t.onCloseTab)return t.onCloseTab(()=>e())},[e])}function FA(){const[e,t]=l.useState(!1);return l.useEffect(()=>{var a,i,c;if(!((a=window.electronAPI)!=null&&a.onFullscreenChange))return;let s=!0,r=!1;const o=window.electronAPI.onFullscreenChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFullscreenState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o()}},[]),e}const wi="window-blurred";function $A(){l.useEffect(()=>{var a,i,c;if(!vp||!((a=window.electronAPI)!=null&&a.onFocusChange))return;const e=document.documentElement,t=d=>{e.classList.toggle(wi,!d)};let s=!0,r=!1;const o=window.electronAPI.onFocusChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFocusState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o(),e.classList.remove(wi)}},[])}const BA="/channels";function zA(){pv();const e=wp(),t=ws(),s=e===BA&&!t.community?t.id??null:null,{data:r}=jp(s),{data:o}=ks(),a=l.useMemo(()=>(o??[]).filter(Lt).length,[o]);return{room:s&&r?r:null,unreadRoomCount:a}}function UA({unreadRoomCount:e}){nj();const t=B(c=>c.isStreaming),s=B(c=>c.isWaitingForUser),r=vn(c=>c.schedulesWaitingCount),o=vn(c=>c.needsYouCount),a=ve({select:c=>c.location.href}),i=Jr(a);return _b(c=>kp(i,{...c,badgeCount:e+r,needsYou:s||o>0}),t),null}function KA(){const e=Cn(),t=Ns(),s=oe(),r=Ce(),o=l.useRef(null);l.useEffect(()=>{var d;if(!e||!t.data)return;const a=JSON.stringify([e.ownerKey,e.epoch]),i=((d=o.current)==null?void 0:d.owner)===a?o.current.rows:null,c=new Map(t.data.map(m=>[m.ref,{status:m.status,label:m.label,generation:ra(m.ref)}]));if(o.current={owner:a,rows:c},!!i)for(const[m,u]of i){if(u.status!=="connected")continue;const f=c.get(m);if((f==null?void 0:f.status)==="connected")continue;const p=rs(wn().destination)===m,h=ra(m)>u.generation,g=f===void 0?"removed":"revoked";(h?Promise.resolve():Sp(s,e,m,g)).then(()=>{p&&rs(wn().destination)===m&&r({...ue.home(),replace:!0})}),g==="revoked"&&ae(`This DorkOS can no longer reach ${u.label}.`,{description:"Still a member? Pick it in the sidebar switcher to reconnect."})}},[e,t.data,r,s])}function HA(){KA(),Iy(),Cp()}function WA({isFullscreen:e}){return n.jsx("div",{className:z("desktop-darwin:block app-drag-region hidden shrink-0",!e&&"desktop-darwin:h-11"),"aria-hidden":"true"})}class qA extends l.Component{constructor(){super(...arguments);en(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(s,r){console.error("[Sidebar] Body contribution error:",s,r)}componentDidUpdate(s){s.contributionId!==this.props.contributionId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?n.jsx("div",{"data-testid":"sidebar-body-error",className:"flex h-full items-center justify-center p-4",children:n.jsx("p",{className:"text-muted-foreground text-center text-sm",children:"This panel couldn’t load. Reload the page."})}):this.props.children}}const GA=5e3;function ou({testId:e,headline:t,detail:s}){const{isFetching:r,refetch:o}=De({refetchInterval:GA});return n.jsx("div",{"data-testid":e,className:"bg-background text-foreground flex h-dvh flex-col items-center justify-center px-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center text-center",children:[n.jsx(He,{size:120,className:"mb-8 opacity-80 dark:hidden"}),n.jsx(He,{variant:"white",size:120,className:"mb-8 hidden opacity-80 dark:block"}),n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:t}),n.jsx("p",{className:"text-muted-foreground mt-3 text-sm",children:s}),n.jsx(M,{variant:"outline",className:"mt-6",onClick:()=>void o(),disabled:r,children:r?"Trying…":"Try again"})]})})}function YA(){return n.jsx(ou,{testId:"server-unreachable",headline:"DorkOS can’t reach its server",detail:"It may still be starting up. DorkOS keeps checking."})}const VA="onboarding";function QA({render:e}){const t=Ep(),s=Ip(),{view:r}=t,o=s.notice;return e({state:r.kind,pending:r.kind==="pending"?{userCode:r.userCode,verificationUri:r.verificationUri,...r.verificationUriComplete?{verificationUriComplete:r.verificationUriComplete}:{}}:null,starting:t.starting,startError:t.startError,start:()=>t.start({origin:VA}),cancel:t.cancel,openBilling:()=>s.open({page:"portal"}),billingPending:s.pending!==null,billingNotice:o===null?null:"message"in o?o.message:o.problem.detail??o.problem.title})}const XA={renderAccountLink:e=>n.jsx(QA,{render:e}),renderRuntimeConnect:Np,renderOtherService:({onSave:e})=>n.jsx(Ap,{onSave:e})},JA="HOST_NOT_ALLOWED",ji=240;function ZA({status:e,message:t,code:s}){const r=s===JA&&t?t:void 0,o=r===void 0?`Your settings didn’t load (HTTP ${e}). DorkOS keeps trying.`:r.length>ji?`${r.slice(0,ji).trimEnd()}…`:r;return n.jsx(ou,{testId:"server-error",headline:"The server answered with an error",detail:o})}function e1(e){const t=e;return{...typeof(t==null?void 0:t.status)=="number"?{status:t.status}:{},...typeof(t==null?void 0:t.message)=="string"&&t.message.length>0?{message:t.message}:{},...typeof(t==null?void 0:t.code)=="string"&&t.code.length>0?{code:t.code}:{}}}let or={at:0};function t1(e,t){return e>or.at&&(or=t==null?{at:e}:{at:e,...e1(t)}),e>Ft?or:void 0}function n1(e){return e.state.dataUpdatedAt>Ft?!0:"always"}const au=["unattended-autonomy"],s1=6e4;function iu(){const e=se(),{data:t}=ge({queryKey:[...au],queryFn:()=>e.getUnattendedAutonomy(),staleTime:s1});return t}function r1(){const e=oe(),t=()=>{e.invalidateQueries({queryKey:[...au]})};ce("relay_bindings_changed",t),ce("tasks_changed",t),ce("relay_adapters_changed",t)}function o1(e){return!e}function a1(e){var t;return((t=e.at(-1))==null?void 0:t.pathname)??""}function i1({descriptors:e}){const t=e.reduce((s,r)=>s===null||r.priority>s.priority?r:s,null);return n.jsx(Le,{mode:"wait",initial:!1,children:t&&n.jsx(Y.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"shrink-0 overflow-hidden",children:t.render()},t.id)})}const c1=["memory-provider-status"],l1=6e4;function d1(){const e=se(),{data:t}=ge({queryKey:[...c1],queryFn:()=>e.getMemoryProviderStatus(),staleTime:l1});return t}function u1(e){const t=new Map;for(const s of e){if(s.kind!=="signin.required")continue;const r=t.get(s.subject.id);(r===void 0||m1(s,r))&&t.set(s.subject.id,s)}return[...t.entries()].filter(([,s])=>s.outcome!=="cleared").map(([s])=>s)}function m1(e,t){return e.createdAt!==t.createdAt?e.createdAt>t.createdAt:e.id>t.id}function h1({configuredId:e,benched:t}){return n.jsxs(xo,{variant:"warning",children:["The ",n.jsx("span",{className:"font-medium",children:e})," memory"," ",t?"stopped answering":"isn’t set up",". DorkOS uses its own memory until you restart."]})}const f1="runtimes",p1=3;function g1({runtimes:e}){const{open:t}=We(),s=Rp();if(e.length===0)return null;const r=e.slice(0,p1).map(Zc),o=e.length-r.length,a=e.length===1?`${r[0]} sign-in`:`${b1(r)} sign-ins`,i=o>0?`, and ${o} more`:"";return n.jsxs(xo,{variant:"critical",icon:fr,actions:n.jsxs(n.Fragment,{children:[s&&n.jsx(x1,{runtimes:e,renderCreditsOffer:s}),n.jsx(M,{variant:"outline",size:"sm",onClick:()=>t(f1),children:"Sign in"})]}),children:["Your ",n.jsx("span",{className:"font-medium",children:a})," stopped working",i,". Agents and tasks wait until you sign in again."]})}function x1({runtimes:e,renderCreditsOffer:t}){var d;const s=Hi(),{data:r}=qi(),o=!Tp(),a=((d=bc().data)==null?void 0:d.linked)===!0,i=Dp(a,yc({enabled:a}).data),c=e.find(m=>Op(Mp(s.data,m),r,m)==="lead");return c?n.jsxs(En,{children:[n.jsx(In,{asChild:!0,children:n.jsx(M,{size:"sm","data-testid":"signin-banner-credits",disabled:i===null,children:i===null?"DorkOS credits":`${i} DorkOS credits`})}),n.jsxs(Rn,{align:"end",className:"w-80 p-4",children:[n.jsxs(Tn,{children:["Run ",Zc(c)," on DorkOS credits"]}),n.jsxs("div",{className:"space-y-3",children:[t({runtime:c,origin:`signin-banner:${c}`,fullWidth:!0}),n.jsx(_p,{remote:o})]})]})]}):null}function b1(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const y1=2,v1={binding:"connection",task:"scheduled task"};function w1(e){return e.map((t,s)=>n.jsxs(l.Fragment,{children:[s>0&&(s===e.length-1?" and ":", "),t]},s))}function j1({drivers:e}){const t=po(),s=ps();if(e.length===0)return null;const r=e.slice(0,y1),o=e.length-r.length,a=r.map(c=>n.jsxs(n.Fragment,{children:["the ",n.jsx("span",{className:"font-medium",children:c.name})," ",v1[c.kind]]}));o>0&&a.push(n.jsxs(n.Fragment,{children:[o," more"]}));const i=new Set(e.map(c=>c.kind));return n.jsxs(xo,{variant:"info",icon:$t,actions:t?n.jsxs(n.Fragment,{children:[i.has("binding")&&n.jsx(M,{variant:"outline",size:"sm",onClick:()=>s(),children:"Connections"}),i.has("task")&&n.jsx(M,{variant:"outline",size:"sm",onClick:()=>t({...ue.tasks()}),children:"Schedules"})]}):void 0,children:["Running unattended at full power: ",w1(a),"."]})}const Lo={critical:40,warning:30,info:20};function k1(){const e=iu();return!e||e.drivers.length===0?null:{id:"unattended-autonomy",variant:"info",priority:Lo.info,render:()=>n.jsx(j1,{drivers:e.drivers})}}function S1(){const e=d1();return!e||e.configuredId===e.activeId?null:{id:"memory-provider-benched",variant:"warning",priority:Lo.warning,render:()=>n.jsx(h1,{configuredId:e.configuredId,benched:e.benched})}}const C1={kinds:["signin.required"]};function N1(){const{notifications:e}=Pp(C1),t=l.useMemo(()=>u1(e),[e]);return t.length===0?null:{id:"runtime-signin",variant:"critical",priority:Lo.critical,render:()=>n.jsx(g1,{runtimes:t})}}function A1(e){const t=k1(),s=S1(),r=N1();return[t,s,r].filter(o=>o!==null)}function E1(){const e=An(),[t,s]=l.useState(!1),r=()=>{e.mutate({telemetry:{install:!1,heartbeat:!1,usage:!1,userHasDecided:!0}})},o=()=>{e.mutate({telemetry:{install:!0,heartbeat:!0,usage:!0,userHasDecided:!0}})};return n.jsxs(n.Fragment,{children:[n.jsxs(gr,{children:[n.jsx(xr,{children:"Share anonymous usage data?"}),n.jsx(br,{children:"A daily ping, package installs and feature use. Never your prompts, code or files."})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[n.jsx(Lp,{open:t,onToggle:()=>s(a=>!a)}),n.jsx("a",{href:"https://dorkos.ai/telemetry",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2",children:"Full contract"})]}),t&&n.jsx(Fp,{})]}),n.jsxs(yr,{className:"items-center gap-2 sm:justify-between",children:[e.isError?n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t save your choice. Try again."}):n.jsx("span",{"aria-hidden":!0}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(M,{variant:"outline",size:"sm",onClick:r,disabled:e.isPending,children:"Don’t share"}),n.jsx(M,{size:"sm",onClick:o,disabled:e.isPending,children:"Share anonymously"})]})]})]})}function ki(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}const I1=[{lead:"Edits and commands run without asking.",rest:"Agents still ask when something needs your call."},{lead:"Your instructions still hold.",rest:"If you told an agent to check first, it does."},{lead:"Agents reach across projects.",rest:"They can message agents in your other projects too."},{lead:"Approvals can stick.",rest:"Always allow remembers your yes for that agent and action."},{lead:"Scheduled runs use your power level.",rest:"Timed runs get the same freedom."}];function R1({heading:e,onClose:t,onCustomize:s}){const r=An(),o=kx(),a=$p({kind:"default"}),i=oe(),[c,d]=l.useState(!1),[m,u]=l.useState(null),[f,p]=l.useState(!1),h=c||r.isPending||o.isPending||a.isPending,g=l.useCallback(()=>{i.invalidateQueries({queryKey:ke.all})},[i]),x=l.useCallback(async()=>{u(null),p(!1),d(!0);const A=new Date().toISOString();try{await r.mutateAsync({ui:{fullPowerDecidedAt:A,fullPowerChoice:"full"},runtimes:{defaultTrustStop:"autonomy"}}),await a.mutateAsync({kind:"preset",preset:"full",surface:"first-run"})}catch(v){u(ki(v)),d(!1);return}g();try{await o.mutateAsync(!0)}catch{p(!0),d(!1);return}d(!1),t()},[r,a,o,g,t]),b=l.useCallback(async()=>{u(null),d(!0);try{await r.mutateAsync({ui:{fullPowerDecidedAt:new Date().toISOString(),fullPowerChoice:"supervised"}}),await a.mutateAsync({kind:"preset",preset:"careful",surface:"first-run"})}catch(A){return u(ki(A)),d(!1),!1}return g(),d(!1),!0},[r,a,g]),y=l.useCallback(async()=>{await b()&&t()},[b,t]),k=l.useCallback(async()=>{await b()&&(s==null||s(),t())},[b,s,t]),j=l.useCallback(async()=>{d(!0);try{await o.mutateAsync(!0)}catch{d(!1);return}p(!1),d(!1),t()},[o,t]);return f?n.jsxs(n.Fragment,{children:[n.jsxs(gr,{children:[n.jsx(xr,{children:"Full power is on"}),n.jsx(br,{children:"One step didn’t finish."})]}),n.jsx("p",{role:"alert",className:"text-muted-foreground text-sm",children:"Agents can’t message other projects yet. Full power stays on."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Try again now, or later from Settings."}),n.jsxs(yr,{className:"items-center gap-2 sm:justify-end",children:[n.jsx(M,{variant:"outline",size:"sm",onClick:t,disabled:h,children:"Close"}),n.jsx(M,{size:"sm",onClick:j,disabled:h,children:"Try again"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs(gr,{children:[n.jsx(xr,{"data-testid":"full-power-door",children:e}),n.jsx(br,{children:"Agents stop asking before each action. Here’s what changes:"})]}),n.jsx("ul",{className:"space-y-2 text-sm",children:I1.map(A=>n.jsxs("li",{className:"flex items-start gap-2",children:[n.jsx($t,{className:"text-status-success mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:[n.jsx("span",{className:"font-medium",children:A.lead})," ",n.jsx("span",{children:A.rest})]})]},A.lead))}),n.jsx(Bp,{mode:"bypassPermissions"}),s&&n.jsx("div",{children:n.jsx(M,{variant:"link",size:"sm",className:"text-muted-foreground h-auto p-0 text-left whitespace-normal",onClick:k,disabled:h,children:"Pick the pieces yourself"})}),n.jsxs(yr,{className:"items-center gap-2 sm:justify-between",children:[m?n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:m}):n.jsx("span",{"aria-hidden":!0}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(M,{variant:"outline",size:"sm",onClick:y,disabled:h,children:"Keep asking me first"}),n.jsxs(M,{size:"sm",onClick:x,disabled:h,className:z("bg-status-success dark:text-status-success-bg text-white","hover:bg-status-success/90 focus-visible:ring-status-success","focus-visible:ring-offset-background focus-visible:ring-offset-2"),children:[n.jsx($t,{"aria-hidden":!0}),"Unlock full power"]})]})]})]})}function T1({onClose:e}){const t=B(s=>s.setControlCenterOpen);return n.jsx(R1,{heading:"DorkOS runs at full power",onClose:e,onCustomize:()=>t(!0)})}const cu={high:30,low:10};function D1(){var t;const{data:e}=De();return(t=e==null?void 0:e.telemetry)!=null&&t.userHasDecided?null:{id:"telemetry-consent",priority:cu.low,render:()=>n.jsx(E1,{})}}function O1(){var s,r,o;const{data:e}=De();return!e||!(((s=e.onboarding)==null?void 0:s.completedAt)!=null||((r=e.onboarding)==null?void 0:r.dismissedAt)!=null)||((o=e.ui)==null?void 0:o.fullPowerDecidedAt)!=null?null:{id:"full-power-door",priority:cu.high,render:({onClose:a})=>n.jsx(T1,{onClose:a})}}function M1(){const e=O1(),t=D1();return B(r=>r.onboardingHiddenForSession)?[]:[e,t].filter(r=>r!==null)}function _1(e){return e.reduce((t,s)=>t===null||s.priority>t.priority?s:t,null)}function P1({onboardingOverlayVisible:e=!1}){const t=M1(),{data:s,dataUpdatedAt:r}=De(),o=B(y=>y.momentShownThisLaunch),a=B(y=>y.markMomentShown),[i,c]=l.useState(null),[d,m]=l.useState(null),u=l.useRef(null),f=(s==null?void 0:s.onboarding)!=null&&(s.onboarding.completedAt!=null||s.onboarding.dismissedAt!=null),p=r>Ft,h=e||!p||!f,g=h?null:_1(t);i===null&&g!==null&&!o&&(c(g.id),m(g)),l.useEffect(()=>{i!==null&&a()},[i,a]);const x=!h&&i!==null&&t.some(y=>y.id===i),b=()=>c(null);return n.jsx(zp,{open:x,onOpenChange:y=>{y||b()},children:d!==null&&n.jsx(Up,{ref:u,onOpenAutoFocus:y=>{var k;y.preventDefault(),(k=u.current)==null||k.focus()},children:d.render({onClose:b})},d.id)})}const L1=[];function F1(){const{approvals:e,isError:t,retry:s}=Kp(),{interactions:r}=Hp(),o=Wp(),a=qp(e),i=Gp(r),c=Ce(),d=l.useMemo(()=>[...e.map(u=>Yp(u.approvalId)),...r.map(u=>Vp(u.interaction.id))],[e,r]);return!t&&a.length===0&&r.length===0&&o.length===0?{slot:null,coveredSignalIds:L1}:{coveredSignalIds:d,slot:n.jsxs("div",{"data-testid":"mobile-now-attention",className:"flex flex-col gap-2 px-2 pt-0.5 pb-1",children:[t&&n.jsx(Qp,{onRetry:s}),(r.length>0||o.length>0)&&n.jsx(Xp,{asks:r,agentNames:i,onOpenSession:u=>{c(vt({session:u}))}}),a.length>0&&n.jsx(Jp,{approvals:a})]})}}const lu=[{id:"home",label:"Home",icon:Zp,badged:!0,kind:"panel"},{id:"library",label:"All",icon:co,badged:!1,kind:"panel"},{id:"dorkbot",label:"DorkBot",icon:uo,badged:!1,kind:"action"},{id:"you",label:"You",icon:Yr,badged:!1,kind:"panel"}],$1=el.filter(e=>e==="library"),B1=el.filter(e=>e!=="library"),Br="calc(3.5rem + env(safe-area-inset-bottom))",us=eg(e=>({panelUp:!1,raise:()=>e({panelUp:!0}),lower:()=>e({panelUp:!1})}));function Si(){us.getState().lower()}function z1({current:e,needsYouCount:t,dorkBotReady:s,onSelect:r,label:o="Main"}){return n.jsx("nav",{"aria-label":o,"data-testid":"mobile-tab-bar",className:"bg-sidebar border-border/60 flex shrink-0 items-stretch border-t",style:{height:Br,paddingBottom:"env(safe-area-inset-bottom)"},children:lu.map(a=>{const i=a.icon,c=a.id===e,d=a.badged&&t>0?t:null,m=a.kind==="action"&&!s;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),disabled:m,"aria-current":c?"page":void 0,"data-testid":`mobile-tab-${a.id}`,"data-mobile-tab":"",className:z("focus-ring text-2xs relative flex flex-1 flex-col items-center justify-center gap-0.5 transition-[color,background-color,scale] duration-150","active:bg-sidebar-accent motion-safe:active:scale-[0.96]",c?"text-sidebar-foreground font-semibold":"text-sidebar-foreground/70 hover:text-sidebar-foreground font-medium","disabled:pointer-events-none disabled:opacity-50"),children:[n.jsxs("span",{className:"relative",children:[n.jsx(i,{className:"size-5","aria-hidden":!0}),d!==null&&n.jsx("span",{"data-testid":`mobile-tab-badge-${a.id}`,"aria-hidden":!0,className:"text-3xs absolute -top-1.5 -right-2.5 min-w-4 rounded-full bg-amber-500 px-1 text-center leading-4 font-semibold text-amber-950 tabular-nums",children:d})]}),a.label]},a.id)})})}function U1(){const e=Cc(),t=Ce(),s=ve({select:r=>r.location.pathname});return e.length===0?null:n.jsxs("section",{"aria-labelledby":"mobile-add-ons-heading",className:"mt-4",children:[n.jsx("h2",{id:"mobile-add-ons-heading",className:"text-muted-foreground px-2 pb-1.5 text-xs font-medium",children:"Add-ons"}),n.jsx("ul",{className:"bg-sidebar-accent/60 flex flex-col gap-0.5 rounded-lg p-1",children:e.map(r=>{const o=Nc(r.extensionId,r.path),a=s===o;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>void t({href:o}),"aria-current":a?"page":void 0,className:z("flex w-full items-center gap-2.5 rounded-md px-2.5 text-[13px]",Qt,a?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/80 hover:bg-sidebar-accent"),children:[n.jsx(ys,{icon:r.icon,className:"size-4 shrink-0"}),n.jsx("span",{className:"truncate",children:r.title})]})},r.id)})})]})}function ar({id:e,active:t,children:s}){return n.jsx("div",{id:`mobile-tab-panel-${e}`,"data-testid":`mobile-tab-panel-${e}`,"data-active":t?"":void 0,inert:!t,className:z("absolute inset-0",!t&&"invisible"),children:s})}function K1({takeover:e}){Ld();const t=F1(),s=Bd({coveredSignalIds:t.coveredSignalIds}),r=Fd(s),{ask:o,ready:a}=tg(),[i,c]=l.useState("home"),d=us(x=>x.panelUp),m=us(x=>x.raise),u=Bt();l.useEffect(()=>u.subscribe("onBeforeLoad",Si),[u]),l.useEffect(()=>Si,[]),l.useEffect(()=>(document.documentElement.style.setProperty("--mobile-tab-dock",Br),()=>{document.documentElement.style.removeProperty("--mobile-tab-dock")}),[]);const f=l.useCallback(x=>{const b=lu.find(y=>y.id===x);if(b!==void 0){if(b.kind==="action"){if(!a)return;c(x),o();return}c(x),m()}},[o,a,m]),p=r.zones.find(x=>x.id==="now"),h=(p==null?void 0:p.needsYouCount)??s.attention.length,g=Gd((p==null?void 0:p.liveRegionText)??ng(h));return n.jsxs(zc,{activeTarget:s.activeTarget,children:[n.jsxs("div",{"data-testid":"mobile-tab-panels",inert:!d,className:z("bg-background fixed inset-x-0 top-0 z-30",!d&&"pointer-events-none invisible"),style:{bottom:`calc(${Br} + var(--pip-dock, 0px))`},children:[n.jsx(ar,{id:"home",active:i==="home",children:n.jsxs(Us,{width:"full",className:"px-3 py-2",children:[n.jsx(Xd,{}),n.jsx(Fr,{model:r,zoneIds:B1,nowSlot:t.slot,silenceLiveRegion:!0}),n.jsx(Pd,{})]})}),n.jsx(ar,{id:"library",active:i==="library",children:n.jsx(Us,{width:"full",className:"px-3 py-2",children:e??n.jsx(Fr,{model:r,zoneIds:$1,silenceLiveRegion:!0})})}),n.jsx(ar,{id:"you",active:i==="you",children:n.jsxs(Us,{width:"full",className:"px-3 py-4",children:[n.jsx("h1",{className:"text-foreground px-2 pb-2 text-sm font-semibold",children:"You"}),n.jsx(tN,{}),n.jsx(tl,{}),n.jsx(U1,{})]})})]}),n.jsx("span",{"data-testid":"mobile-needs-you-live-region","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:g}),n.jsx(z1,{current:d?i:null,needsYouCount:h,dorkBotReady:a,onSelect:f})]})}function H1(){const{open:e}=We(),t=B(r=>r.setControlCenterOpen),s=Es(()=>t(!1));return n.jsxs("section",{className:"@container flex flex-col gap-2","data-testid":"control-center-dial",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Power"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"What agents may do without asking you."})]}),n.jsx(sg,{surface:"control-center"}),n.jsxs(M,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 self-start px-2 text-xs",onClick:s(()=>e("permissions")),children:["Edit permissions",n.jsx(zt,{className:"size-3.5","aria-hidden":!0})]})]})}const Rt={unconfigured:"Use DorkOS from your phone. One-time setup.",off:"Use DorkOS from your phone or another computer.",starting:"Connecting…",stopping:"Turning off…",draining:"Closing…"};function W1(){var u,f;const e=As(),t=to(),s=B(p=>p.setRemoteAccessOpen),r=B(p=>p.setControlCenterOpen),a=Es(()=>r(!1))(()=>s(!0)),i=e.isSetUp,c=e.state==="starting"||e.state==="stopping",d=e.hasServerReport;let m;return d?i?e.error!==null?m=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-destructive truncate",children:rl(e.error)}),n.jsx("button",{type:"button",onClick:a,className:"focus-ring text-foreground shrink-0 rounded-sm underline underline-offset-2",children:"Fix…"})]}):e.state==="blocked"?m=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-status-warning-fg truncate",children:((u=e.managed)==null?void 0:u.reason)??"Needs attention"}),n.jsx("button",{type:"button",onClick:a,className:"focus-ring text-foreground shrink-0 rounded-sm underline underline-offset-2",children:"Fix…"})]}):e.state==="connected"?m=`On · ${e.host??"connected"}`:e.state==="asleep"?m=e.host?`Closed for now · ${e.host}`:"Closed for now":e.state==="draining"?m=Rt.draining:e.state==="reconnecting"?m=e.host?`On · ${e.host} · reconnecting…`:"Reconnecting…":e.state==="starting"?m=Rt.starting:e.state==="stopping"?m=Rt.stopping:m=Rt.off:m=Rt.unconfigured:m=Rt.off,d&&((f=e.managed)!=null&&f.cloudStale)&&typeof m=="string"&&(m=`${m} · Can’t reach DorkOS Cloud`),n.jsx(nl,{label:"Remote access",description:n.jsx("span",{"data-testid":"remote-access-row-description",className:z("block min-w-0",c&&"motion-safe:animate-breath"),children:m}),children:n.jsx(sl,{checked:i&&e.isChecked,disabled:!d||i&&e.isTransitioning,"aria-label":"Remote access",onCheckedChange:p=>{if(!i){a();return}t.toggle(p)}})})}const q1=1,G1=10,Y1=4;function V1(){var d,m;const{data:e}=De(),t=An(),s=oe(),{limits:r,setLimits:o}=rg(),a=()=>void s.invalidateQueries({queryKey:ke.all}),i=((d=e==null?void 0:e.claudeCode)==null?void 0:d.persistentSession)??!0,c=((m=e==null?void 0:e.scheduler)==null?void 0:m.maxConcurrentRuns)??Y1;return n.jsx(og,{children:n.jsxs(ag,{children:[n.jsx(W1,{}),n.jsx(Sx,{}),n.jsx(oa,{label:"Limit automatic replies",description:(r==null?void 0:r.turnLimitsEnabled)===!1?"Agents reply to each other without limit until you press Stop.":n.jsxs(n.Fragment,{children:["Agents pause after a long back-and-forth."," ",n.jsxs(aa,{label:"About reply limits",children:[n.jsx("p",{children:"Your next message starts the count over."}),n.jsx("p",{children:"Set the numbers in Settings → Advanced → Room limits."})]})]}),checked:(r==null?void 0:r.turnLimitsEnabled)??!0,disabled:r===null,onCheckedChange:u=>o({turnLimitsEnabled:u})}),n.jsx(oa,{label:"Warm agents",description:n.jsxs(n.Fragment,{children:["Replies start about 4× faster. Each warm agent uses up to about 1 GB."," ",n.jsxs(aa,{label:"About warm agents",children:[n.jsx("p",{children:"Your agent stays running between messages."}),n.jsx("p",{children:"At most twelve agents stay warm at once."})]})]}),checked:i,disabled:t.isPending,onCheckedChange:u=>t.mutate({runtimes:{claudeCode:{persistentSession:u}}},{onSuccess:a})}),n.jsx(nl,{label:"Scheduled runs at once",description:"How many scheduled tasks run together.",children:n.jsx(ig,{value:c,min:q1,max:G1,"aria-label":"Scheduled runs at once",onCommit:u=>t.mutate({scheduler:{maxConcurrentRuns:u}},{onSuccess:a})})})]})})}const Ci="claude-code";function Q1(){var I,D,O,E,w;const{data:e}=De(),{data:t}=Wi(),{sessions:s}=Sc(),r=cg(),{data:o}=fc(r),{data:a}=lg(),i=dg(),c=i.data,d=pw(),m=po(),{open:u}=We(),{open:f}=lo(),p=ps(),h=B(C=>C.setControlCenterOpen),g=Es(()=>h(!1)),x=i.isError,b=t===void 0||e===void 0||c===void 0&&!x,y=e==null?void 0:e.executionDefaults,k=(y==null?void 0:y.runtime)??Ci,j=(I=t==null?void 0:t.capabilities[k])==null?void 0:I.permissionModes,A=((D=j==null?void 0:j.values.find(C=>C.id===j.default))==null?void 0:D.stop)??"ask",v=(y==null?void 0:y.trustStop)??A,S=[];if(!b){for(const N of(y==null?void 0:y.perRuntime)??[])N.trustStop===null||N.trustStop===v||S.push({key:`runtime:${N.runtime}`,kind:"runtime",name:Ke(N.runtime).label,detail:$s(N.trustStop),onOpen:m?g(()=>u("runtimes")):null});for(const N of s){const T=(O=t==null?void 0:t.capabilities[N.runtime])==null?void 0:O.permissionModes,R=T==null?void 0:T.values.find(P=>P.id===N.permissionMode),_=R==null?void 0:R.stop;!_||_===v||S.push({key:`session:${N.id}`,kind:"session",name:N.title||"Untitled chat",detail:(R==null?void 0:R.label)??Bs(N.permissionMode),onOpen:m?g(()=>m(vt({session:N.id,dir:N.cwd}))):null})}const C=((w=(E=t==null?void 0:t.capabilities[Ci])==null?void 0:E.permissionModes)==null?void 0:w.values)??[];for(const N of o??[]){const T=C.find(_=>_.id===N.permissionMode),R=T==null?void 0:T.stop;!R||R===v||S.push({key:`task:${N.id}`,kind:"task",name:N.displayName??N.name,detail:(T==null?void 0:T.label)??Bs(N.permissionMode),onOpen:m?g(()=>m({...ue.tasks()})):null})}for(const N of a??[]){const T=C.find(_=>_.id===N.permissionMode),R=T==null?void 0:T.stop;!R||R===v||S.push({key:`binding:${N.id}`,kind:"binding",name:N.label||N.adapterId,detail:(T==null?void 0:T.label)??Bs(N.permissionMode),onOpen:m?g(()=>p({app:N.adapterId})):null})}}if(c){const C=new Map(c.areas.map(R=>[R.id,R.label])),N=new Map(c.areas.flatMap(R=>R.actions.map(_=>[_.id,_.title]))),T=R=>g(()=>f(R,"permissions"));for(const R of c.exceptions){const _=R.action?N.get(R.action)??R.action:C.get(R.area),P=ug[R.state];S.push({key:`agent-permission:${R.agentId}:${R.action??R.area}`,kind:"agent-permission",name:R.agentName,detail:`${_??R.area} ${P}`,why:{question:`Why is ${_??R.area} set to ${P} for ${R.agentName}?`,sentence:mg({state:R.state,source:R.action?"agent-action":"agent-area",preset:c.preset,agentName:R.agentName}),...R.lastChange?{lastChange:R.lastChange}:{}},onOpen:T(R.agentId),onReset:()=>d.mutate({agentId:R.agentId,key:R.action?{kind:"action",action:R.action}:{kind:"area",area:R.area},surface:"control-center"}),resetting:d.isPending})}for(const R of c.filesAndCommands.exceptions)S.push({key:`agent-permission:${R.agentId}:files`,kind:"agent-permission",name:R.agentName,detail:`Files & commands ${$s(R.stop)}`,why:{question:`Why is Files & commands set to ${$s(R.stop)} for ${R.agentName}?`,sentence:hg(R.stop,"agent",R.agentName),...R.lastChange?{lastChange:R.lastChange}:{}},onOpen:T(R.agentId),onReset:()=>d.mutate({agentId:R.agentId,key:{kind:"files"},surface:"control-center"}),resetting:d.isPending})}return{rows:S,isEmpty:!b&&!x&&S.length===0,isResolving:b,permissionsUnreadable:x}}const X1={runtime:gg,session:pg,task:go,binding:Yi,"agent-permission":fg};function J1(){const{rows:e,isEmpty:t,isResolving:s,permissionsUnreadable:r}=Q1();return n.jsxs("section",{className:"flex flex-col gap-2","data-testid":"control-center-overrides",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Exceptions"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"These skip the preset. Changing the preset leaves them alone."})]}),s?n.jsx("p",{className:"text-muted-foreground px-1 text-xs",children:"Checking…"}):t?n.jsx("p",{"data-testid":"overrides-ledger-empty",className:"text-muted-foreground px-1 text-xs",children:"Everything follows your preset. Chats open in other projects aren’t counted."}):n.jsx("ul",{className:"flex flex-col gap-0.5",children:e.map(o=>{const a=X1[o.kind];return n.jsxs("li",{className:"flex items-center gap-1",children:[n.jsxs("button",{type:"button","data-testid":`override-row-${o.kind}`,onClick:()=>{var i;return(i=o.onOpen)==null?void 0:i.call(o)},disabled:!o.onOpen,"aria-label":`${o.name}: ${o.detail}. Open.`,className:"focus-ring hover:bg-accent/60 flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs transition-colors disabled:pointer-events-none disabled:opacity-60",children:[n.jsx(a,{className:"text-muted-foreground size-3.5 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"min-w-16 flex-1 truncate",children:o.name}),n.jsx("span",{className:"text-muted-foreground min-w-0 truncate",children:o.detail}),n.jsx(zt,{className:"text-muted-foreground/60 size-3.5 shrink-0","aria-hidden":!0})]}),o.why?n.jsx(xg,{question:o.why.question,sentence:o.why.sentence,...o.why.lastChange?{lastChange:o.why.lastChange}:{},className:"shrink-0 px-1"}):null,o.onReset?n.jsxs(M,{variant:"ghost",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:o.resetting,"aria-label":`Reset ${o.name}: ${o.detail}`,onClick:o.onReset,children:[n.jsx(bg,{className:"size-3.5","aria-hidden":!0}),"Reset"]}):null]},o.key)})}),r?n.jsx("p",{"data-testid":"overrides-ledger-permissions-error",className:"text-muted-foreground px-1 text-xs",children:"Couldn’t load agents with their own permissions. See Settings → Permissions."}):null]})}const Z1=2;function eE(){const e=iu();if(!e||e.drivers.length===0)return null;const t=e.drivers.slice(0,Z1).map(o=>o.name),s=e.drivers.length-t.length,r=s>0?[...t,`${s} more`]:t;return n.jsxs("p",{"data-testid":"control-center-unattended",className:"text-status-success flex items-start gap-1.5 px-1 text-xs",children:[n.jsx($t,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Running unattended at full power: ",r.join(", "),"."]})]})}function tE(){const e=ol();return al(e)?n.jsxs("p",{"data-testid":"control-center-keep-awake",className:"text-muted-foreground flex items-start gap-1.5 px-1 text-xs",children:[n.jsx(Nl,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Keeping this computer awake: ",il(e.working),"."]})]}):null}function nE(){return n.jsxs("div",{className:"flex flex-col gap-4","data-testid":"control-center-body",children:[n.jsx(H1,{}),n.jsx(V1,{}),n.jsx(J1,{}),n.jsx(eE,{}),n.jsx(tE,{})]})}function sE(){const e=B(r=>r.controlCenterOpen),t=B(r=>r.setControlCenterOpen),s=je();return n.jsxs(En,{open:e,onOpenChange:t,modal:!0,autoFocus:!0,children:[n.jsx(In,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"control-center-trigger","aria-label":"Control Center",className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx($t,{className:"size-4","aria-hidden":!0})})}),n.jsxs(Rn,{side:"bottom",align:"end","aria-label":"Control Center",className:"w-96 max-w-[calc(100vw-1.5rem)] p-3",children:[!s&&n.jsxs("header",{className:"mb-3 flex items-center gap-2",children:[n.jsx($t,{className:"text-status-success size-4 shrink-0","aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:"Control Center"})]}),n.jsx(Tn,{children:"Control Center"}),n.jsx(nE,{})]})]})}function rE(){const e=B(t=>t.toggleControlCenter);l.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.key==="l"||s.key==="L")&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function oE(e,t){const s=l.useRef(null),[r,o]=l.useState(0);return l.useEffect(()=>{if(!t)return;const a=s.current;s.current=e,a!==null&&a!=="connected"&&e==="connected"&&o(i=>i+1)},[e,t]),r}function aE({url:e}){const t=ze();return n.jsxs("div",{"data-testid":"remote-access-qr",children:[n.jsx(Y.div,{initial:t?!1:{clipPath:"inset(0 100% 0 0)"},animate:{clipPath:"inset(0 0% 0 0)"},transition:{duration:.2,ease:[0,0,.2,1]},children:n.jsx(yg,{url:e,size:168})}),n.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan with your phone"})]})}function iE({url:e}){const{copied:t,failed:s,copy:r}=Nn();let o,a;return t?(o=n.jsx(Nt,{className:"size-3.5"}),a="Copied"):s?(o=n.jsx(Te,{className:"text-destructive size-3.5"}),a="Couldn’t copy"):(o=n.jsx(Wr,{className:"size-3.5"}),a="Copy link"),n.jsxs("div",{className:"bg-muted/40 rounded-lg border p-2.5","data-testid":"remote-access-link",children:[n.jsx("p",{className:"text-foreground truncate font-mono text-xs",title:e,children:e}),n.jsxs(M,{variant:"outline",size:"sm",className:"mt-2 w-full gap-1.5",onClick:()=>void r(e),children:[o,a]})]})}function cE(){const e=As(),t=e.managed;if(!t)return null;const s=[];return t.alwaysAvailable&&s.push("Always available"),e.state==="asleep"&&s.push("Your address stays the same."),t.reason&&s.push(t.reason),t.cloudStale&&s.push("Couldn’t reach DorkOS Cloud. Showing the last known state."),s.length===0?null:n.jsx("div",{className:"text-muted-foreground space-y-1 text-xs","data-testid":"remote-access-managed-note",children:s.map(r=>n.jsx("p",{children:r},r))})}function lE({onClose:e}){const t=As(),s=to(),r=je(),o=B(f=>f.setRemoteAccessOpen),a=Es(e),i=t.url,c=t.mode==="managed",d=i?n.jsx(iE,{url:i},"link"):null,m=i?n.jsx(aE,{url:i},"qr"):null,u=r?[d,m]:[m,d];return n.jsxs("div",{className:"flex flex-col gap-3","data-testid":"remote-access-panel",children:[!r&&n.jsxs("header",{className:"flex items-center gap-2",children:[n.jsx("span",{className:z("inline-block size-2 shrink-0 rounded-full",cl(t.state)),"aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:ll(t.state)})]}),t.error!==null&&n.jsx("p",{role:"alert","data-testid":"remote-access-panel-error",className:"text-destructive text-xs",children:rl(t.error)}),c&&n.jsx(cE,{}),i===null&&t.state!=="asleep"&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Your link appears here when it’s ready."}),u,n.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[n.jsx("span",{className:"text-muted-foreground text-sm",children:"Remote access"}),n.jsx(sl,{checked:t.isChecked,disabled:t.isTransitioning,"aria-label":"Remote access",onCheckedChange:f=>void s.toggle(f)})]}),n.jsx(M,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground -mx-1 justify-start",onClick:a(()=>o(!0)),children:"Manage…"})]})}function du(e,t){return e==="starting"?"Remote access is connecting":e==="reconnecting"?"Remote access is reconnecting":e==="stopping"?"Remote access is turning off":e==="draining"?"Remote access is closing":e==="asleep"?t?`Remote access is closed for now at ${t}`:"Remote access is closed for now":t?`Remote access is on at ${t}`:"Remote access is on"}function dE(e,t){const s=e==="starting"||e==="asleep"&&!t?"Open remote access":"Show link and QR code";return`${du(e,t)}. ${s}`}function uE(){const e=As(),t=B(i=>i.remoteAccessBeaconOpen),s=B(i=>i.setRemoteAccessBeaconOpen),r=ze(),o=oE(e.state,e.hasServerReport);l.useEffect(()=>{!e.isLive&&t&&s(!1)},[e.isLive,t,s]);const a=e.isLive?du(e.state,e.host):"";return n.jsxs(n.Fragment,{children:[n.jsx("span",{role:"status",className:"sr-only","data-testid":"remote-access-announcement",children:a}),e.isLive&&n.jsxs(En,{open:t,onOpenChange:s,modal:!0,children:[n.jsx(In,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"remote-access-beacon","data-state-name":e.state,"aria-label":dE(e.state,e.host),className:z("focus-ring text-muted-foreground hover:text-foreground relative inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",e.state==="reconnecting"&&"opacity-70"),children:[n.jsx(Oc,{className:z("size-4",e.state==="starting"&&"motion-safe:animate-breath"),"aria-hidden":!0}),n.jsx("span",{"aria-hidden":!0,"data-testid":"remote-access-beacon-dot",className:z("border-background absolute right-0.5 bottom-0.5 size-1.5 rounded-full border",cl(e.state))}),o>0&&!r&&n.jsx("span",{"aria-hidden":!0,"data-testid":"remote-access-beacon-ripple",className:"animate-beacon-ripple border-status-success pointer-events-none absolute inset-0 rounded-full border"},o)]})}),n.jsxs(Rn,{side:"bottom",align:"end","aria-label":"Remote access",className:"w-72 max-w-[calc(100vw-1.5rem)] p-3",children:[n.jsx(Tn,{children:ll(e.state)}),n.jsx(lE,{onClose:()=>s(!1)})]})]})]})}function mE({work:e}){const{isDesktop:t}=wg();return t?n.jsxs("p",{className:"text-sm font-medium",children:["Keeping awake: ",e]}):n.jsxs(Tn,{className:"text-sm font-medium",children:["Keeping awake: ",e]})}function hE(){const e=ol(),{open:t}=We(),[s,r]=l.useState(!1);if(!al(e))return null;const o=il(e.working);return n.jsxs(En,{open:s,onOpenChange:r,children:[n.jsx(In,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"keep-awake-beacon","aria-label":`Keeping this computer awake: ${o}. Show details`,className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Nl,{className:"size-4","aria-hidden":!0})})}),n.jsxs(Rn,{side:"bottom",align:"end","aria-label":"Keeping awake",className:"w-72 max-w-[calc(100vw-1.5rem)] space-y-2 p-3",children:[n.jsx(mE,{work:o}),n.jsx("p",{className:"text-muted-foreground text-xs",children:vg}),n.jsx(M,{variant:"outline",size:"sm",onClick:()=>{r(!1),t(ia.tab,ia.section)},children:"Sleep settings"})]})]})}function fE(){const e=se(),t=oe();return Ct({mutationFn:s=>e.createAgent(s),onSuccess:()=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["mesh","agents"]}),t.invalidateQueries({queryKey:["mesh","agent-paths"]}),t.invalidateQueries({queryKey:["team"]})},meta:{errorLabel:"Couldn’t create that agent",isShownInline:s=>{var r;return((r=s.body)==null?void 0:r.code)==="template_needs_review"}}})}async function pE(e,t){try{return(await e.browseDirectory(t)).entries.some(r=>r.name===".dork")?"exists-has-dork":"exists-no-dork"}catch(s){const r=s instanceof Error?s.message:"";return r.includes("EACCES")||r.includes("permission")?"error":"no-path"}}function gE({step:e,templateName:t,seedDisplayName:s=null,faceSeed:r=null,runtimeSeed:o="claude-code"}){var V;const a=se(),{data:i}=ge({queryKey:ke.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),c=((V=i==null?void 0:i.agents)==null?void 0:V.defaultDirectory)??"",[d,m]=l.useState(""),[u,f]=l.useState(!1),[p,h]=l.useState(""),[g,x]=l.useState(!1),[b,y]=l.useState(!1),[k,j]=l.useState(null),[A,v]=l.useState(""),[S,I]=l.useState(!1),[D,O]=l.useState(o),[E,w]=l.useState(s);s!==E&&(w(s),s&&(m(s),f(!1)));const[C,N]=l.useState(o);o!==C&&(N(o),O(o));const T=l.useMemo(()=>d?jg(d):"",[d]),R=l.useMemo(()=>T?kg(T):{valid:!1,error:void 0},[T]),_=d.length>0&&T.length>0&&!R.valid,P=p||(c&&T?`${c}/${T}`:""),U=e!=="naming"||!P?"idle":k!==null&&k.directory===P?k.status:"checking",H=d.length>0&&R.valid&&U!=="error",ne=l.useRef(null);l.useEffect(()=>{if(e!=="naming")return;const F=t?!d||u?t.replace(/^@[^/]+\//,""):null:u?"":null;if(F===null)return;const L=`${e}|${t??""}`;ne.current!==L&&(ne.current=L,m(F),f(!!t))},[e,t]);const te=l.useRef(null);l.useEffect(()=>{if(e!=="naming"||S||!r)return;const F=`${e}|${r}`;te.current!==F&&(te.current=F,v(r))},[e,r]),l.useEffect(()=>{if(e!=="naming"||!P)return;const F=P,L=setTimeout(()=>{pE(a,F).then(J=>{j({directory:F,status:J})})},500);return()=>clearTimeout(L)},[e,P,a]);function q(F){m(F),u&&f(!1)}function G(F){v(F),I(!0)}function ee(){ne.current=null,te.current=null,m(""),f(!1),h(""),x(!1),y(!1),j(null),v(""),I(!1),O(o)}return{displayName:d,slug:T,handleNameChange:q,nameAutoFilled:u,slugValidation:R,showSlugError:_,defaultDirectory:c,resolvedDirectory:P,directoryOverride:p,setDirectoryOverride:h,directoryOpen:g,setDirectoryOpen:x,directoryPickerOpen:b,setDirectoryPickerOpen:y,conflictStatus:U,canSubmit:H,icon:A,setIcon:G,runtime:D,setRuntime:O,reset:ee}}function xE(e){var a;const t=(e==null?void 0:e.packageName)??null,{data:s,isError:r,error:o}=mx(t,e!=null&&e.marketplace?{marketplace:e.marketplace}:void 0);return{schedules:((a=s==null?void 0:s.preview)==null?void 0:a.schedules)??[],isChecking:t!==null&&s===void 0&&!r,failed:t!==null&&r,...t!==null&&r&&hx(o)&&{refusal:o},...s!=null&&s.disclosed&&s.contentHash?{approval:{approvedDisclosure:s.disclosed,approvedContentHash:s.contentHash},packageAgentName:s.manifest.name}:{}}}const bE={gallery:{title:"New agent",description:"What will your agent do?"},naming:{title:"Name your agent",description:"Give it a name and a face."},arrival:{description:"Add a ready-made agent."}},ir={keeper:["Keeper","Warden","Steward","Curator","Archivist","Ledger","Tally","Sorter"],scout:["Scout","Ranger","Pathfinder","Lookout","Recon","Probe","Tracer","Radar"],guardian:["Sentinel","Guardian","Aegis","Bastion","Vigil","Auditor","Gatekeep","Warden"],builder:["Forge","Smith","Builder","Mason","Wright","Maker","Anvil","Crafter"],scribe:["Scribe","Quill","Muse","Author","Penn","Bard","Editor","Note"],default:["Scout","Sage","Pilot","Beacon","Atlas","Nova","Ranger","Echo","Vera","Onyx"]},yE=[["keeper",["board","organize","tidy","manage","linear","jira","project","backlog","task"]],["scout",["research","search","monitor","watch","discover","scan","find","intel","inbox","email","mail"]],["guardian",["review","security","audit","qa","test","lint","guard","protect","compliance"]],["builder",["build","code","scaffold","deploy","engineer","refactor","ci","release"]],["scribe",["doc","write","content","blog","summar","note","changelog","copy"]]];function vE(e){if(!e)return ir.default;const t=[e.name,e.description,e.category,...e.tags??[]].filter(Boolean).join(" ").toLowerCase();for(const[s,r]of yE)if(r.some(o=>t.includes(o)))return ir[s];return ir.default}function wE(e,t,s){if(e.length===0)return[];const r=Math.min(s,e.length),o=(t%e.length+e.length)%e.length;return Array.from({length:r},(a,i)=>e[(o+i)%e.length])}const jE=64,kE=16,Ni=3;function SE(e){return e.map(t=>t.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,jE)).filter(t=>t.length>0).slice(0,kE)}function CE(e){const t=SE(e.capabilities??[]),s=t.length>0?`
85
-
86
- Your declared abilities include: ${t.join(", ")}. Draw your first-action offer from these when it fits.`:"";return["You have just been created. This is your first moment awake — greet the person who made you.","",`Read your ${Dt.soul} to recall who you are, then, in 2 to 4 short sentences:`,"- Introduce yourself in your own voice, drawn from that persona.","- State plainly what your job is.","- Propose one concrete first action you could take — as an offer, and wait for their go-ahead.","",`Do NOT start any work yet — do not act on the project or change any files. (Reading your own ${Dt.soul} so you can introduce yourself is fine; anything beyond that waits for their go-ahead.) Just make the offer and let them decide. Speak warmly and directly to the person.`+s].join(`
87
- `)}function NE(e){return[`You have just been created${e.displayName?` and named ${e.displayName}`:""}, and you do not have a job yet — the person who made you will define it with you, right now, in this conversation. This is your first moment awake, and by the end of it you will have written your own ${Dt.soul}.`,"","Run a short interview to discover who you should be, then capture it:","","1. Say a brief, warm hello (1 to 2 sentences) and ask them what they would like you to take care of. Do not assume a role yet.","",`2. Hold a SHORT interview. Ask AT MOST ${Ni} questions in total across this whole conversation — this is a hard limit. Only ask what you genuinely need to write a good soul (typically the scope of the work, how often you should do it, and anything you must never touch). If their first answer already tells you enough, ask fewer. For a one-word or vague answer, ask a single clarifying question and then proceed with a reasonable role rather than interrogating them. If they say something like "just figure it out," do not push — propose a sensible role from what you have and move on. Never trap them in endless back-and-forth: once you have asked ${Ni} questions, stop asking and write your best soul from what you learned.`,"","3. Before you write, tell them in one line what you understood and that you are about to capture it as your soul — so they see it coming. Then write it.","",`4. Write your ${Dt.soul} now, using your file-editing tools. It lives at \`.dork/${Dt.soul}\` in your working directory and already contains a "Personality Traits" block fenced by \`${Sg}\` and \`${ca}\` — leave that fenced block exactly as it is. Replace only the prose BELOW the \`${ca}\` marker with your persona: who you are in your own voice, what you take care of, how you go about it, and the boundaries you keep. Keep it concise.`,"","5. After the file is written, confirm it in one or two sentences and propose ONE concrete first action you could take — as an offer, and wait for their go-ahead.","",`Do not start the actual job yet — your own ${Dt.soul} is the only file you touch now. Do not act on their project or run their work until they say go. Speak warmly and directly to the person throughout.`].join(`
88
- `)}const AE={template:CE,"design-your-own":NE};function EE(e,t){return AE[e](t)}function IE(e,t){return Tx(EE(e,t))}const uu="🤖",RE=["🤖","🦾","🧭","🛰️","📡","🔭","🗺️","🧠","🦉","🦊","🐝","🐙","🚀","⚡","🌟","🔮","🛠️","🔧","📊","📋","✅","🗂️","🔔","🛡️"];function Ai({face:e,title:t,subtitle:s,chips:r,variant:o,tabIndex:a,onSelect:i,onKeyDown:c,ref:d,"data-testid":m}){return n.jsxs("button",{ref:d,type:"button",tabIndex:a,onClick:i,onKeyDown:c,"data-gallery-card":"","data-testid":m,className:z("card-interactive group flex h-full flex-col gap-2 rounded-xl border p-4 text-left","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",o==="design"?"border-primary/40 bg-primary/5 hover:border-primary/60 border-dashed":"bg-card hover:border-border/80 hover:shadow-md"),children:[n.jsx("span",{className:"text-3xl leading-none","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx("p",{className:"text-sm font-semibold",children:t}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:s})]}),r&&r.length>0&&n.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:r.map(u=>n.jsx("span",{className:"bg-muted text-muted-foreground text-2xs rounded-full px-2 py-0.5",children:u},u))})]})}function TE(e){return{source:e.source,name:e.name,displayName:dl(e),description:e.description,icon:e.icon,tags:e.tags,category:e.category,packageName:e.name,...e.marketplace?{marketplace:e.marketplace}:{}}}function DE(e){return e.tags&&e.tags.length>0?e.tags.slice(0,2):e.category?[e.category]:[]}function OE(e){const t=e.replace(/\/+$/,"");return t.split("/").pop()??t}function ME({onDesignYourOwn:e,onSelectTemplate:t,onImport:s}){const{data:r,error:o,isLoading:a}=Cg(),i=pl(a),[c,d]=l.useState(""),[m,u]=l.useState(!1),f=l.useMemo(()=>(r??[]).filter(h=>h.type==="agent"),[r]),p=Fb(f.length+1);return n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{role:"group","aria-label":"Choose what your agent will do",className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"agent-gallery",children:[n.jsx(Ai,{ref:p.setRef(0),variant:"design",face:n.jsx(uo,{className:"text-primary size-7"}),title:"Design your own",subtitle:"Describe the job in your own words.",tabIndex:p.tabIndexFor(0),onSelect:e,onKeyDown:h=>p.handleKeyDown(h,0),"data-testid":"gallery-design-your-own"}),f.map((h,g)=>{const x=g+1;return n.jsx(Ai,{ref:p.setRef(x),variant:"template",face:h.icon??uu,title:dl(h),subtitle:h.description??"A ready-made agent.",chips:DE(h),tabIndex:p.tabIndexFor(x),onSelect:()=>t(TE(h)),onKeyDown:b=>p.handleKeyDown(b,x),"data-testid":`gallery-template-${h.name}`},h.name)}),i&&f.length===0&&Array.from({length:2}).map((h,g)=>n.jsx(xt,{className:"h-28 rounded-xl","data-testid":"gallery-skeleton"},g))]}),!i&&f.length===0&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"gallery-templates-note",children:o?"Couldn’t load ready-made agents. Check marketplace sources in Settings.":"No ready-made agents yet. Add a marketplace source in Settings."}),n.jsxs(mo,{open:m,onOpenChange:u,children:[n.jsx(ho,{asChild:!0,children:n.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs transition-colors","data-testid":"advanced-toggle",children:[n.jsx(At,{className:z("size-3.5 transition-transform",m&&"rotate-180")}),"Build from a template URL"]})}),n.jsx(fo,{children:n.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[n.jsx(Je,{value:c,onChange:h=>d(h.target.value),placeholder:"github.com/org/repo","data-testid":"custom-url-input",className:"flex-1"}),n.jsx(M,{size:"sm",disabled:!c,onClick:()=>{const h=OE(c);t({source:c,name:h,displayName:Ng(h)}),d("")},"data-testid":"custom-url-go",children:"Continue"})]})})]}),n.jsx("div",{className:"border-t pt-3",children:n.jsxs("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 text-sm transition-colors","data-testid":"gallery-import-link",children:[n.jsx(Ag,{className:"size-4"}),"Bring in an existing project folder",n.jsx("span",{"aria-hidden":!0,children:"→"})]})})]})}function _E({value:e,onChange:t}){return n.jsx("div",{role:"group","aria-label":"Choose a face",className:"flex flex-wrap gap-1.5","data-testid":"face-picker",children:RE.map(s=>{const r=s===e;return n.jsx("button",{type:"button","aria-label":`Face ${s}`,"aria-pressed":r,onClick:()=>t(s),className:z("flex size-9 items-center justify-center rounded-md border text-lg transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",r?"border-primary bg-primary/10":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`face-${s}`,children:n.jsx("span",{"aria-hidden":!0,children:s})},s)})})}function PE({value:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"Runs on",className:"flex gap-1.5","data-testid":"runtime-picker",children:Eg.map(s=>{const r=Ke(s),o=r.icon,a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:z("flex flex-1 items-center justify-center gap-1.5 rounded-md border px-2 py-1.5 text-xs transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",a?"border-primary bg-primary/10 font-medium":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`runtime-${s}`,children:[n.jsx(o,{size:14}),r.label]},s)})})}function LE({face:e,name:t,jobLine:s,capabilities:r,className:o}){const a=t.trim()||"Your agent",i=t.trim().length===0;return n.jsxs("div",{className:z("bg-card shadow-soft flex flex-col items-center gap-3 rounded-lg border p-5",o),"data-testid":"agent-preview",children:[n.jsx("span",{className:"bg-primary/10 flex size-16 items-center justify-center rounded-full text-3xl","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-1 text-center",children:[n.jsx("p",{className:z("text-lg font-semibold",i&&"text-muted-foreground"),"data-testid":"preview-name",children:a}),n.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:s})]}),r.length>0&&n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5","data-testid":"preview-capabilities",children:r.map(c=>n.jsx("span",{className:"bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs",children:c},c))})]})}function mu({schedules:e,checkFailed:t,testIdPrefix:s}){return n.jsxs(n.Fragment,{children:[e.length>0&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-package-schedules`,children:[n.jsx(go,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Brings a schedule"}),n.jsx("dd",{className:"min-w-0 space-y-1",children:e.map((r,o)=>n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:r.name}),": ",fx(r)]},`${r.name}-${o}`))})]}),t&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-offer-check-failed`,children:[n.jsx(Pi,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Not checked"}),n.jsx("dd",{className:"min-w-0",children:"Couldn’t check for scheduled work. Anything it brings still needs your approval."})]})]})}const Ei=4;function FE({form:e,suggestionPool:t,jobLine:s,previewCapabilities:r,onBack:o,onImportInstead:a,onCreate:i,isCreating:c,packageSchedules:d=[],offerCheckFailed:m=!1,isCheckingOffer:u=!1,offerRefusal:f,packageDirectory:p,templateReview:h,inheritance:g,isCheckingInheritance:x=!1}){const b=l.useRef(null),[y,k]=l.useState(0),j=e.displayName.trim().toLowerCase(),A=t.filter(D=>D.toLowerCase()!==j),v=wE(A,y,Ei);l.useEffect(()=>{const D=setTimeout(()=>{var O;return(O=b.current)==null?void 0:O.focus()},160);return()=>clearTimeout(D)},[]);const S=e.displayName.trim(),I=c?`Creating ${S||"your agent"}…`:`Create ${S||"agent"}`;return n.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[n.jsxs("div",{className:"space-y-5",children:[n.jsxs("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground -ml-1 inline-flex items-center gap-1 text-xs transition-colors","data-testid":"naming-back",children:[n.jsx(lc,{className:"size-3.5"}),"Choose a different agent"]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ie,{htmlFor:"agent-name",className:"text-sm",children:"Name"}),n.jsx(Je,{ref:b,id:"agent-name",placeholder:"Name your agent",value:e.displayName,onChange:D=>e.handleNameChange(D.target.value),"aria-invalid":e.showSlugError,"aria-describedby":e.showSlugError?"agent-name-error":void 0,className:"h-11 text-base"}),e.showSlugError&&n.jsx("p",{id:"agent-name-error",className:"text-destructive text-xs",role:"alert",children:e.slugValidation.error}),e.conflictStatus==="exists-has-dork"&&n.jsxs("div",{"data-testid":"conflict-status",children:[n.jsx("p",{className:"text-status-warning-fg text-xs font-medium",children:"This folder has a project"}),n.jsx("button",{type:"button",className:"text-primary text-xs hover:underline",onClick:a,"data-testid":"import-instead-link",children:"Import it instead"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-muted-foreground text-xs",children:"Need a name?"}),n.jsx("button",{type:"button",onClick:()=>k(D=>D+Ei),"aria-label":"Show other names",className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring rounded text-sm transition-colors focus-visible:ring-2 focus-visible:outline-none","data-testid":"suggestion-reroll",children:n.jsx("span",{"aria-hidden":!0,children:"🎲"})})]}),n.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"name-suggestions",children:v.map(D=>n.jsx("button",{type:"button",onClick:()=>e.handleNameChange(D),className:"bg-muted hover:bg-accent focus-visible:ring-ring rounded-full px-2.5 py-1 text-xs transition-colors focus-visible:ring-2 focus-visible:outline-none","data-testid":`suggestion-${D}`,children:D},D))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx(Ie,{className:"text-sm",children:"Face"}),!e.icon&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Picked for you if skipped"})]}),n.jsx(_E,{value:e.icon,onChange:e.setIcon})]}),n.jsxs(mo,{open:e.directoryOpen,onOpenChange:e.setDirectoryOpen,children:[n.jsx(ho,{asChild:!0,children:n.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1 text-sm transition-colors","data-testid":"details-toggle",children:[n.jsx(At,{className:z("size-4 transition-transform",e.directoryOpen&&"rotate-180")}),"Details",e.directoryOverride&&n.jsx("span",{className:"bg-primary/10 text-primary ml-1 rounded px-1.5 py-0.5 text-xs",children:"Custom"})]})}),n.jsx(fo,{children:n.jsxs("div",{className:"space-y-4 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ie,{className:"text-muted-foreground text-xs",children:"Runs on"}),n.jsx(PE,{value:e.runtime,onChange:e.setRuntime})]}),p?n.jsxs("div",{className:"space-y-1.5","data-testid":"package-directory",children:[n.jsx(Ie,{className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx("p",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:p}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Kept in its package’s folder so updates reach it."})]}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ie,{htmlFor:"agent-directory",className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx(Ig,{id:"agent-directory",placeholder:e.resolvedDirectory||(e.defaultDirectory?`${e.defaultDirectory}/…`:""),value:e.directoryOverride,onChange:e.setDirectoryOverride,onBrowse:()=>e.setDirectoryPickerOpen(!0),browseTestId:"browse-directory-button","data-testid":"directory-preview"}),e.conflictStatus==="no-path"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"Creates a new folder"}),e.conflictStatus==="exists-no-dork"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"That folder is already there. The project goes inside it."}),e.conflictStatus==="error"&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"conflict-status",children:"Can’t open this folder. Pick another."})]}),!p&&e.slug&&!e.showSlugError&&n.jsxs("p",{className:"text-muted-foreground text-xs",children:["Folder name:"," ",n.jsx("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:e.slug})]})]})})]})]}),n.jsxs("div",{className:"flex flex-col gap-4 self-start",children:[n.jsx(LE,{face:e.icon||uu,name:e.displayName,jobLine:s,capabilities:r}),(d.length>0||m)&&n.jsx("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:n.jsx(mu,{schedules:d,checkFailed:m,testIdPrefix:"naming"})}),f!==void 0&&n.jsx(hl,{error:f}),h,u&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"naming-checking-offer",children:"Checking for scheduled work…"}),g,n.jsx(M,{size:"lg",onClick:i,disabled:!e.canSubmit||c||u||x||f!==void 0,"data-testid":"create-button",children:I})]})]})}function $E({seed:e,packageSchedules:t,isCheckingOffer:s,offerCheckFailed:r,offerRefusal:o,resolvedDirectory:a,canSubmit:i,isCreating:c,inheritance:d,isCheckingInheritance:m=!1,onCreate:u,onCustomize:f,onNotNow:p}){const{displayName:h,persona:g,runtime:x,capabilities:b,skills:y,schedule:k,icon:j}=e.template,A=Ke(x??"claude-code").label,v=h.trim().charAt(0).toUpperCase()||"?",S=j&&vr(j)?j:v,I=e.sourceLabel?`Offered by ${e.sourceLabel}.`:"A ready-made agent.";return n.jsxs("div",{className:"mx-auto max-w-md space-y-6","data-testid":"arrival-confirm",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("span",{className:"bg-primary/10 text-primary flex size-20 items-center justify-center rounded-full text-4xl font-semibold","aria-hidden":"true",children:S}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs(Fe,{className:"text-xl",children:["Meet ",h]}),n.jsx(Qe,{children:I})]})]}),g&&n.jsx("p",{className:"text-foreground text-sm leading-relaxed whitespace-pre-line",children:g}),n.jsxs("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(BE,{runtime:x}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on"}),n.jsx("dd",{children:A})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(bs,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Lives in"}),n.jsx("dd",{className:"min-w-0",children:a?n.jsx("code",{className:"text-xs break-all",children:a}):n.jsx(xt,{className:"h-3.5 w-48 max-w-full rounded"})})]}),k&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":"arrival-schedule",children:[n.jsx(go,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on a schedule"}),n.jsx("dd",{children:k})]}),n.jsx(mu,{schedules:t,checkFailed:r,testIdPrefix:"arrival"}),b&&b.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Rg,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Can"}),n.jsx("dd",{children:b.join(", ")})]}),y&&y.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Tg,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Uses skills"}),n.jsx("dd",{children:y.join(", ")})]})]}),o!==void 0&&n.jsx(hl,{error:o}),n.jsxs("div",{className:"flex flex-col gap-2",children:[!i&&n.jsx("p",{className:"text-status-warning-fg text-center text-xs","data-testid":"arrival-needs-name",children:"Needs a name. Choose “Customize first” to add one."}),s&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"arrival-checking-offer",children:"Checking for scheduled work…"}),d,n.jsx(M,{size:"lg",onClick:u,disabled:c||!i||s||m||o!==void 0,"data-testid":"arrival-create",children:c?"Creating…":`Create ${h}`}),n.jsxs("div",{className:"flex items-center justify-center gap-4",children:[n.jsx(M,{variant:"ghost",size:"sm",onClick:f,className:"text-muted-foreground","data-testid":"arrival-customize",children:"Customize first"}),n.jsx(M,{variant:"ghost",size:"sm",onClick:p,className:"text-muted-foreground","data-testid":"arrival-not-now",children:"Not now"})]})]})]})}function BE({runtime:e}){const t=Ke(e??"claude-code").icon;return n.jsx(t,{size:16,className:"text-muted-foreground shrink-0"})}function zE(e){const t=e==null?void 0:e.body;return(t==null?void 0:t.code)==="template_needs_review"?t.template:void 0}function UE(e,t){const s=e.replace(/\/*$/,"/");return t.filter(r=>r.path===e||r.path.startsWith(s))}function KE(e){return e.omitted==="link"?"A link. It isn’t copied into the agent.":e.omitted==="not-text"?`Not text (${e.bytes} bytes).`:`Too long to show (${e.bytes} bytes). Read it in the template first.`}function HE(e){const t=(e.settings??[]).filter(s=>s.omitted==="too-long"||s.omitted==="not-text");return t.length===0?"Create with these":t.length===1?`Create without seeing ${t[0].path}`:`Create without seeing ${t.length} files`}function WE(e){const{disclosed:t}=e;return[...e.findings.map(s=>({key:`finding:${s.path}`,label:s.path,detail:"Settings the agent loads: hooks, permission rules or servers.",files:UE(s.path,e.settings??[])})),...t.hooks.map((s,r)=>({key:`hook:${r}`,label:Ge(s.command),detail:`Runs on ${s.event}${s.source?`, while ${Ge(s.source)} is in use`:""}.`})),...(t.skillCommands??[]).map((s,r)=>({key:`command:${s.source}:${r}`,label:Ge(s.command),detail:`Runs when skill “${Ge(s.skill)}” is used (${Ge(s.source)})`+(s.usesArguments?". Reads the text typed after it.":".")})),...t.mcpServers.map(s=>({key:`mcp:${s.name}`,label:s.command?Og(s.command,s.args):Ge(s.url??s.name),detail:`Starts the MCP server “${Ge(s.name)}”.`})),...t.skillTools.map(s=>({key:`tools:${s.source}`,label:s.tools.map(Ge).join(", "),detail:`Skill “${Ge(s.skill)}” may use these without asking you.`}))]}function qE({template:e,onCreateAnyway:t,onCancel:s,isCreating:r}){return n.jsxs("div",{role:"alert",className:"space-y-3 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-sm","data-testid":"template-review",children:[n.jsxs("p",{className:"flex items-center gap-2 font-medium text-amber-700 dark:text-amber-300",children:[n.jsx(Dg,{className:"size-4 shrink-0","aria-hidden":!0}),"This template brings things that run in your agent’s chats"]}),n.jsxs("p",{className:"text-muted-foreground text-xs [overflow-wrap:anywhere]",children:["From ",e.source,". Check each before you create the agent."]}),n.jsx("ul",{className:"space-y-2",children:WE(e).map(o=>{var a;return n.jsxs("li",{className:"text-xs",children:[n.jsx("code",{className:"bg-muted text-foreground block rounded px-1.5 py-1 font-mono [overflow-wrap:anywhere] whitespace-pre-wrap",children:o.label}),n.jsx("span",{className:"text-muted-foreground",children:o.detail}),(a=o.files)==null?void 0:a.map(i=>n.jsxs("details",{className:"mt-1","data-testid":"template-settings-file",children:[n.jsx("summary",{className:"text-muted-foreground hover:text-foreground cursor-pointer",children:i.path===o.label?"Show what it contains":`Show ${i.path}`}),i.content!==void 0?n.jsx("pre",{className:"border-border/60 bg-muted/40 mt-1 max-h-[50dvh] overflow-auto rounded border p-2 font-mono text-xs break-words whitespace-pre-wrap md:max-h-56",children:i.content}):n.jsx("p",{className:"text-muted-foreground mt-1",children:KE(i)})]},i.path))]},o.key)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(M,{variant:"ghost",size:"sm",onClick:s,disabled:r,children:"Don’t create it"}),n.jsx(M,{size:"sm",onClick:t,disabled:r,className:"h-auto max-w-full py-1.5 text-left [overflow-wrap:anywhere] whitespace-normal",children:r?"Creating…":HE(e)})]})]})}function GE(){const{isOpen:e,seed:t,onCreated:s,close:r}=xs(),o=bn(te=>te.open),a=fE(),i=Ce(),[c,d]=l.useState("gallery"),[m,u]=l.useState(null),[f,p]=l.useState(!1);e!==f&&(p(e),e&&(u(null),d(t?"arrival":"gallery")));const h=t!=null&&t.template.icon&&vr(t.template.icon)?t.template.icon:void 0,g=m!=null&&m.icon&&vr(m.icon)?m.icon:h??null,x=(t==null?void 0:t.template.runtime)??"claude-code",b=(t==null?void 0:t.packageName)!==void 0?t:(m==null?void 0:m.packageName)!==void 0?{packageName:m.packageName,marketplace:m.marketplace}:null,y=xE(b),{data:k}=De(),j=b&&y.packageAgentName&&(k!=null&&k.dorkHome)?`${k.dorkHome}/agents/${y.packageAgentName}`:void 0,[A,v]=l.useState(null),S=gE({step:c,templateName:(m==null?void 0:m.displayName)??null,seedDisplayName:(t==null?void 0:t.template.displayName)??null,faceSeed:g,runtimeSeed:x}),I=vE(m?{name:m.name,description:m.description,category:m.category,tags:m.tags}:t?{name:t.template.displayName,description:t.template.persona}:void 0),D=m?m.description??"A ready-made agent.":t!=null&&t.template.persona?t.template.persona:"You’ll define the job together in your first chat.",O=m?m.tags??[]:(t==null?void 0:t.template.capabilities)??[];function E(){S.reset(),v(null),u(null),d("gallery")}const w=l.useCallback(te=>{u(te),d("naming")},[]),C=l.useCallback(()=>{u(null),d("naming")},[]);function N(){d(t?"arrival":"gallery")}function T(){r(),E(),o()}function R(te){var ee;if(!S.canSubmit||a.isPending)return;const q=(b==null?void 0:b.packageName)!==void 0&&y.approval?{package:{name:b.packageName,...b.marketplace?{marketplace:b.marketplace}:{},...y.approval}}:void 0,G=q?void 0:(m==null?void 0:m.source)??(t==null?void 0:t.template.source);a.mutate({name:S.slug,displayName:S.displayName.trim()||void 0,runtime:S.runtime,...!q&&S.directoryOverride?{directory:S.directoryOverride}:{},...S.icon?{icon:S.icon}:{},...q??{},...G?{template:G}:{},...te?{approvedTemplateHash:te}:{},...t!=null&&t.template.persona?{persona:t.template.persona}:{},...(ee=t==null?void 0:t.template.capabilities)!=null&&ee.length?{capabilities:t.template.capabilities}:{}},{onSuccess:V=>{const F=crypto.randomUUID(),L=V.displayName??V.name,J=m||t?"template":"design-your-own";Mg.getState().register(F,{name:V.name,displayName:L,agentId:V.id,icon:V.icon,color:V.color,bornAt:V.registeredAt,path:V._path,runtime:V.runtime,kickoffMessage:IE(J,{displayName:L,capabilities:V.capabilities})}),rb();const le=s;if(r(),E(),le){le();return}i(vt({agentId:V.id,draft:"1",session:F,runtime:V.runtime}))},onError:V=>{const F=zE(V);F&&v(F)}})}function _(te){te||(r(),E())}const P=Gi(e),U=n.jsx(ev,{agentName:S.displayName||(t==null?void 0:t.template.displayName)||""}),H=bE[c],ne=c==="gallery"?"max-w-6xl":c==="naming"?"max-w-5xl":"max-w-2xl";return n.jsx(Ze,{open:e,onOpenChange:_,defaultFullscreen:!0,children:n.jsxs(et,{className:"flex flex-col gap-0 p-0",children:["title"in H&&n.jsxs(Ve,{className:"shrink-0 border-b px-5 py-4",children:[n.jsx(Fe,{children:H.title}),n.jsx(Qe,{children:H.description})]}),n.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:H.description}),n.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-6 sm:px-8",children:n.jsxs("div",{className:`mx-auto my-auto w-full ${ne}`,children:[n.jsx(Le,{mode:"wait",children:n.jsxs(Y.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[c==="gallery"&&n.jsx(ME,{onDesignYourOwn:C,onSelectTemplate:w,onImport:T}),c==="arrival"&&t&&n.jsx($E,{seed:t,packageSchedules:y.schedules,isCheckingOffer:y.isChecking,offerCheckFailed:y.failed,offerRefusal:y.refusal,resolvedDirectory:j??S.resolvedDirectory,canSubmit:S.canSubmit,isCreating:a.isPending,inheritance:U,isCheckingInheritance:P.isPending,onCreate:()=>R(),onCustomize:()=>d("naming"),onNotNow:()=>_(!1)}),c==="naming"&&n.jsx(FE,{form:S,suggestionPool:I,jobLine:D,previewCapabilities:O,onBack:N,onImportInstead:T,onCreate:()=>R(),isCreating:a.isPending,packageSchedules:y.schedules,offerCheckFailed:y.failed,offerRefusal:y.refusal,isCheckingOffer:y.isChecking,packageDirectory:j,inheritance:U,isCheckingInheritance:P.isPending,templateReview:A?n.jsx(qE,{template:A,isCreating:a.isPending,onCreateAnyway:()=>R(A.contentHash),onCancel:()=>v(null)}):void 0})]},c)}),c!=="gallery"&&n.jsx(Cx,{className:"mt-6"})]})}),n.jsx(Zi,{open:S.directoryPickerOpen,onOpenChange:S.setDirectoryPickerOpen,initialPath:S.directoryOverride||S.defaultDirectory,onSelect:te=>{S.setDirectoryOverride(te),S.directoryOpen||S.setDirectoryOpen(!0)}})]})})}function YE({sessionId:e}){l.useEffect(()=>{var a;const r=ot.getState(),o=((a=r.sessions[e])==null?void 0:a.cwd)??r.statusCwds[e]??null;return es.pinSession(e,o),la.getState().setPinnedSession(e),()=>{es.unpinSession(),la.getState().setPinnedSession(null)}},[e]);const t=_g(e),s=l.useMemo(()=>Yx(t),[t]);return s===null?n.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-center text-sm",children:"No live widget in this chat"}):n.jsx(Vx,{code:s.code,isIncomplete:s.isIncomplete,sessionId:e,isLatestMessage:s.isLatest,isStreaming:s.isStreaming},s.sourceMessageKey)}function VE({content:e}){return n.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-center text-sm",children:e.title})}const cr=64,QE={type:"spring",stiffness:480,damping:44};function XE({content:e,onRestore:t,onClose:s}){l.useEffect(()=>(document.documentElement.style.setProperty("--pip-dock",`${cr}px`),()=>{document.documentElement.style.removeProperty("--pip-dock")}),[]);const r=Bx();return ms.createPortal(n.jsxs(Y.div,{"data-slot":"pip-minibar",role:"complementary","aria-label":e.title,initial:{y:cr},animate:{y:0},exit:{y:cr},transition:QE,style:{bottom:`max(var(--mobile-tab-dock, 0px), ${r}px)`},className:"bg-background border-border shadow-elevated fixed inset-x-0 z-40 flex h-16 items-center border-t",children:[n.jsxs("button",{type:"button",onClick:t,className:"focus-ring flex h-full min-w-0 flex-1 items-center gap-3 px-4 text-left",children:[n.jsx("span",{className:"bg-primary size-2 shrink-0 animate-pulse rounded-full"}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),n.jsx(zb,{className:"text-muted-foreground size-4 shrink-0"})]}),n.jsx("button",{type:"button","aria-label":"Close",onClick:s,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring mr-3 shrink-0 rounded-md p-2 transition-colors",children:n.jsx(Te,{className:"size-4"})})]}),document.body)}const Yn={peek:.5,expanded:.94},JE=.4,ZE=800,Ii=500,lr={type:"spring",stiffness:480,damping:44};function eI({content:e,onClose:t,onMinimize:s,children:r}){const o=hb(),a=db(),[i,c]=l.useState("peek"),[d,m]=l.useState(()=>window.innerHeight);l.useEffect(()=>{const x=()=>m(window.innerHeight);return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const u=Yn.expanded*d,f=(Yn.expanded-Yn.peek)*d,p=i==="expanded"?0:f;l.useEffect(()=>{a.start({y:p,transition:lr})},[a,p]);const h=(x,b)=>{const y=p+b.offset.y,k=b.velocity.y,j=y-f,A=Yn.peek*d;if(j>JE*A||j>0&&k>ZE){s();return}let v;k<-Ii?v="expanded":k>Ii?v="peek":v=y<f/2?"expanded":"peek",v===i?a.start({y:p,transition:lr}):c(v)},g=x=>{x.target.closest("button")||o.start(x)};return ms.createPortal(n.jsxs(Y.div,{"data-slot":"pip-sheet",role:"complementary","aria-label":e.title,initial:{y:u},animate:a,exit:{y:u},transition:lr,drag:"y",dragListener:!1,dragControls:o,dragConstraints:{top:0,bottom:u},dragElastic:.1,dragMomentum:!1,onDragEnd:h,style:{height:u},className:"bg-background border-border shadow-modal fixed inset-x-0 bottom-0 z-40 flex flex-col rounded-t-lg border-t",children:[n.jsxs("div",{onPointerDown:g,className:"cursor-grab touch-none select-none active:cursor-grabbing",children:[n.jsx("div",{className:"bg-muted mx-auto mt-4 h-2 w-[100px] rounded-full"}),n.jsxs("div",{className:"flex items-center justify-between gap-2 border-b px-4 pt-1 pb-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),n.jsx("button",{type:"button","aria-label":"Minimize",onClick:s,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring shrink-0 rounded-md p-1 transition-colors",children:n.jsx(At,{className:"size-4"})}),n.jsx("button",{type:"button","aria-label":"Close",onClick:t,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring shrink-0 rounded-md p-1 transition-colors",children:n.jsx(Te,{className:"size-4"})})]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:r})]}),document.body)}const Ri=360,Ti=240,Di=16,dr={demo:VE,mcp_app:tI,widget:nI};function tI({content:e}){return n.jsx(tb,{sessionId:e.sessionId,serverName:e.serverName,uri:e.uri,title:e.title,className:"h-full"})}function nI({content:e}){return n.jsx(YE,{sessionId:e.sessionId})}function sI(e){l.useEffect(()=>{},[e])}function Oi(){return{x:window.innerWidth-Ri-Di,y:window.innerHeight-Ti-Di,width:Ri,height:Ti}}function rI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function hu(e){switch(e.kind){case"demo":{const t=dr.demo;return n.jsx(t,{content:e})}case"mcp_app":{const t=dr.mcp_app;return n.jsx(t,{content:e})}case"widget":{const t=dr.widget;return n.jsx(t,{content:e})}default:return e}}function oI({content:e,onClose:t}){const s=B(c=>c.pipGeometry),r=B(c=>c.setPipGeometry),[o,a]=l.useState(Oi);l.useEffect(()=>{if(s!==null)return;const c=()=>a(d=>{const m=Oi();return rI(d,m)?d:m});return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[s]);const i=s??o;return n.jsx(Le,{children:e!==null&&n.jsx(ey,{title:e.title,geometry:i,onGeometryChange:r,onClose:t,children:hu(e)},"pip-panel")})}function aI(){const e=B(d=>d.pipContent),t=B(d=>d.pipMinimized),s=B(d=>d.closePip),r=B(d=>d.minimizePip),o=B(d=>d.restorePip),a=B(d=>d.openPip),i=je();sI(a);const c=l.useRef(i);return l.useEffect(()=>{i&&!c.current&&e!==null&&r(),c.current=i},[i,e,r]),i?n.jsx(Le,{children:e!==null&&(t?n.jsx(XE,{content:e,onRestore:o,onClose:s},"pip-minibar"):n.jsx(eI,{content:e,onClose:s,onMinimize:r,children:hu(e)},"pip-sheet"))}):n.jsx(oI,{content:e,onClose:s})}function iI(){const e=B(r=>r.shortcutsPanelOpen),t=B(r=>r.setShortcutsPanelOpen),s=Pg();return n.jsx(Ze,{open:e,onOpenChange:t,children:n.jsxs(et,{className:"sm:max-w-md",children:[n.jsx(Ve,{children:n.jsx(Fe,{children:"Keyboard shortcuts"})}),n.jsx(at,{className:"space-y-6",children:s.map(({group:r,label:o,shortcuts:a})=>n.jsxs("div",{children:[n.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-medium tracking-wider uppercase",children:o}),n.jsx("div",{className:"space-y-1",children:a.map(i=>n.jsxs("div",{className:"flex items-center justify-between py-1.5 text-sm",children:[n.jsx("span",{children:i.label}),n.jsx(Kc,{className:"inline-flex",children:Pt(i)})]},i.id))})]},r))})]})})}function cI(){const e=B(t=>t.toggleShortcutsPanel);l.useEffect(()=>{const t=s=>{const r=s.target,o=r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable;s.key==="?"&&!o&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const lI=15e3;function dI(){const e=ve({select:r=>r.location.pathname}),s=vs("sidebar.body").find(r=>{var o;return(o=r.visibleWhen)==null?void 0:o.call(r,{pathname:e})});if(s){const r=s.component;return{key:`body:${s.id}`,body:n.jsx(qA,{contributionId:s.id,children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(r,{})})}),direction:1,isTakeover:!0}}return{key:"dashboard",body:n.jsx(yC,{}),direction:-1,isTakeover:!1}}function uI(){const e=ve({select:t=>t.matches});return bw(e)}function mI(){const{sidebarOpen:e,setSidebarOpen:t}=B(),s=je(),r=us(Z=>Z.panelUp),[o]=Lg(),a=ve({select:Z=>Z.location.pathname}),i=ve({select:Z=>Z.location.searchStr}),c=new URLSearchParams(i),d=a==="/channels"&&!!c.get("community")&&!!c.get("id"),m=o1(ze()??!1),u=ve({select:Z=>a1(Z.matches)});ov();const[f]=Dn(),p=B(Z=>Z.isStreaming),{data:h}=Fg(f),g=Tc(h??null,f??""),{room:x,unreadRoomCount:b}=zA();HA(),Mb({cwd:f,isStreaming:p,color:h?g.color:void 0}),cI(),hw(),bx(),rE(),yx(),vx(),Dx(),Hw(),Ww(),Vw(),PA(),LA();const y=FA();$A(),lv(),ak(),Yv(),Vv(),$g(),r1(),Bg(),gv(),zg(),Sy(),Ug(),Pb(),Kg(),fw(),Hg(),jk(),Nx();const k=B(Z=>Z.onboardingHiddenForSession),j=B(Z=>Z.setOnboardingHiddenForSession),{shouldShowOnboarding:A,isLoading:v,isOnboardingComplete:S,isOnboardingDismissed:I}=Xt(),D=Ty({shouldShowOnboarding:A,onboardingHiddenForSession:k});Oy({done:S||I,overlayVisible:D}),mw({blocked:D});const{dataUpdatedAt:O,errorUpdatedAt:E,error:w}=De({refetchOnMount:n1}),C=O>Ft,N=E>Ft,T=t1(E,w),[R,_]=l.useState(!1);l.useEffect(()=>{if(C)return;const Z=setTimeout(()=>_(!0),lI);return()=>clearTimeout(Z)},[C]);const P=(T==null?void 0:T.status)===void 0,U=!C&&P&&(N||R),H=C||(T==null?void 0:T.status)===void 0?void 0:T,[ne,te]=l.useState(!1);l.useEffect(()=>{if(!v)return;const Z=setTimeout(()=>te(!0),3e3);return()=>clearTimeout(Z)},[v]);const q=l.useCallback(()=>j(!0),[j]),G=dI(),{origin:ee,originLabel:V}=Wg(o),{data:F}=qg(o,{enabled:!1,select:Z=>Z.title}),L=uI(),J=l.useMemo(()=>({sessionId:o??void 0,agentName:h?Ne(h):void 0,agentVisual:h?g:void 0,origin:ee,originLabel:V,sessionTitle:F,sessionDirectoryName:f?Vc(f):void 0,room:x,teamViewMode:Gg(new URLSearchParams(i).get("view")??void 0)}),[o,h,g,ee,V,F,f,x,i]),le=A1();return U?n.jsx(YA,{}):(H==null?void 0:H.status)!==void 0?n.jsx(ZA,{status:H.status,message:H.message,code:H.code}):v&&!ne?n.jsx("div",{className:"bg-background h-dvh"}):n.jsxs(Yg,{children:[n.jsx(UA,{unreadRoomCount:b}),n.jsxs(ab,{reducedMotion:"user",children:[n.jsx(Le,{mode:"wait",children:D?n.jsx(Y.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-50",children:n.jsx(nv,{onComplete:q,slots:XA})},"onboarding"):n.jsx(Y.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"h-dvh",children:n.jsxs("div",{"data-testid":"app-shell",className:"bg-background text-foreground flex h-dvh flex-col",children:[n.jsxs(Vg,{open:e,onOpenChange:t,className:z("flex-1 overflow-hidden",s&&"min-h-0"),style:{"--sidebar-width":"calc(272px + 1rem)"},children:[!s&&n.jsxs(Qg,{variant:"inset",children:[n.jsx(WA,{isFullscreen:y}),n.jsx(Xd,{}),n.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx(Le,{mode:"wait",initial:!1,custom:G.direction,children:n.jsx(Y.div,{"data-testid":"sidebar-body-swap",custom:G.direction,initial:"enter",animate:"center",exit:"exit",variants:{enter:Z=>({x:`${Z*100}%`,opacity:0}),center:{x:0,opacity:1},exit:Z=>({x:`${Z*-100}%`,opacity:0})},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:G.body},G.key)})}),n.jsx(Xg,{className:"px-2 py-3",children:n.jsx(tl,{})}),n.jsx(Jg,{})]}),n.jsxs(Zg,{className:"overflow-hidden",inert:s&&r,children:[Re()&&n.jsx(Bw,{className:z("app-drag-region",!e&&!y&&"desktop-darwin:pl-20")}),n.jsxs("header",{className:"app-drag-region @container/bar relative flex h-9 shrink-0 items-center gap-1 border-b px-2 transition-[border-color] duration-300 lg:gap-2",children:[!s&&n.jsxs(n.Fragment,{children:[n.jsx(ex,{className:"-ml-0.5"}),n.jsx(Kw,{}),n.jsx(tx,{orientation:"vertical",className:"mr-1 h-4"})]}),s&&n.jsx(eN,{}),n.jsx(Le,{mode:"wait",initial:!1,children:L&&n.jsx(Y.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},className:"flex min-w-0 flex-1 items-center gap-1 self-stretch lg:gap-2",children:n.jsx(nx,{value:J,children:n.jsx(L.Header,{})})},L.key)}),n.jsx(sE,{}),n.jsx(uE,{}),n.jsx(hE,{}),n.jsx(sx,{})]}),n.jsx(i1,{descriptors:le}),n.jsx("main",{id:Jl,className:"flex-1 overflow-hidden pb-[var(--pip-dock,0px)]",children:n.jsxs(rx,{direction:"horizontal",id:Cr,autoSaveId:Cr,children:[n.jsx(ec,{id:"main-content",order:1,minSize:30,defaultSize:100,children:n.jsx(Y.div,{initial:m?{opacity:0}:!1,animate:{opacity:1},transition:m?{duration:.12,ease:"easeOut"}:{duration:0},"data-route-fade":m,className:"h-full",children:n.jsx(ox,{})},u)}),n.jsx(dw,{pathname:a,isRemoteCommunityRoom:d})]})})]})]}),s&&n.jsx(K1,{takeover:G.isTakeover?G.body:null})]})},"main-app")}),n.jsx(DN,{}),n.jsx(P1,{onboardingOverlayVisible:D}),n.jsx(RA,{}),n.jsx(oN,{}),n.jsx(NN,{}),n.jsx(GE,{}),n.jsx(qv,{}),n.jsx(iI,{}),n.jsx(ty,{}),n.jsx(aI,{}),n.jsx(cx,{}),n.jsx(_A,{})]})]})}const sR=mI;export{sR as component};