dorkos 0.124.0 → 0.124.1

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 (311) hide show
  1. package/dist/bin/cli.js +935 -551
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-BH8Ndn3e.js → AboutPage-DHaZvsJE.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-K5Mew9EX.js → ActivityErrorState-BP-qFk2S.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-BB20L5HU.js → ActivityPage-Bme3TzdQ.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-C5O7rnmS.js → ActivityRow-BRZyW9MA.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-Bmybvrzb.js → AdapterIcon-BcfquTja.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-CkdV7Hhh.js → AdapterSetupWizard-B4I23pBg.js} +1 -1
  10. package/dist/client/assets/{AgentOptionRow-BA2cDa7r.js → AgentOptionRow-Cb34LtmH.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-CsIIPGZJ.js → AgentPicker-ouNRFSDh.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-0fOxvaoe.js → AgentRequestCard-B6MHIsxa.js} +2 -2
  13. package/dist/client/assets/{AppearancePage-XOjkkoli.js → AppearancePage-CutehigK.js} +1 -1
  14. package/dist/client/assets/ApplyToOverridesDialog-B-wIUI27.js +1 -0
  15. package/dist/client/assets/{AttentionSignalRow-CjjZobp7.js → AttentionSignalRow-B1aMjgX_.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-9TVHyRPJ.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-CdWF4WLz.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-DLoAQauL.js → BindingDialog-BAdueON5.js} +1 -1
  18. package/dist/client/assets/{BlintzCanvas-CYHsXAcY.js → BlintzCanvas-b30dG4gx.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent--Gr7Fe_U.js → CanvasCsvContent-DGHgSikG.js} +1 -1
  20. package/dist/client/assets/{CanvasFileContent-estXyAbr.js → CanvasFileContent-D1bFaUeh.js} +2 -2
  21. package/dist/client/assets/{CanvasModel3dContent-CkOo930M.js → CanvasModel3dContent-dST7g1v2.js} +2 -2
  22. package/dist/client/assets/{ChatAppsOff-D4L1zJVN.js → ChatAppsOff-DiObvmJS.js} +1 -1
  23. package/dist/client/assets/{CodeMirrorDiff-DY_6ju-z.js → CodeMirrorDiff-BncI1OY1.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorEditor-BUoDBsBv.js → CodeMirrorEditor-DV6psv19.js} +1 -1
  25. package/dist/client/assets/{CommitmentList-wDkcVP9c.js → CommitmentList-Dx_Ek_Gl.js} +1 -1
  26. package/dist/client/assets/{CommitmentsPage-CzSM6b8R.js → CommitmentsPage-Bca8NMUa.js} +1 -1
  27. package/dist/client/assets/{ComputerResourceView-cERD9H2L.js → ComputerResourceView-DNVNFTdn.js} +1 -1
  28. package/dist/client/assets/{ComputerViewer-rMcfbk2_.js → ComputerViewer-D8SxJdMm.js} +1 -1
  29. package/dist/client/assets/{ConnectionAccessLists-f7QeQbQo.js → ConnectionAccessLists-Bhj1YT15.js} +1 -1
  30. package/dist/client/assets/{ConnectionsPage-BmjtA6pw.js → ConnectionsPage-B20JZxoK.js} +1 -1
  31. package/dist/client/assets/{ConventionPage-CH-ah6nI.js → ConventionPage-De645wxU.js} +1 -1
  32. package/dist/client/assets/{ExtensionPageRoute-CJIxa6ST.js → ExtensionPageRoute-nTeiOBRQ.js} +1 -1
  33. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BP7EJ2JL.js → FloatingTanStackRouterDevtools-CqogiFob-DM79UITv.js} +1 -1
  34. package/dist/client/assets/HandlePage-B08V-om7.js +1 -0
  35. package/dist/client/assets/{HeartbeatPage-BUsf-qrU.js → HeartbeatPage-CBoUxz6t.js} +1 -1
  36. package/dist/client/assets/{KeyEntry-C2kWdN8q.js → KeyEntry-Cug8ocpX.js} +1 -1
  37. package/dist/client/assets/{LexicalField-CR8ulsI_.js → LexicalField-Bv_ogmAq.js} +1 -1
  38. package/dist/client/assets/{ManagesPage-DTtsIOGi.js → ManagesPage-DfJBQKK3.js} +1 -1
  39. package/dist/client/assets/{Marketplace-iaV5XAzv.js → Marketplace-swCVUbdY.js} +2 -2
  40. package/dist/client/assets/{MarketplaceSourcesView-6tgzUfFj.js → MarketplaceSourcesView-CDZDChpV.js} +1 -1
  41. package/dist/client/assets/{McpAppFrame-C7eYYdI9.js → McpAppFrame-BM9cNPPd.js} +1 -1
  42. package/dist/client/assets/{McpSigninBody-BDyGbJ7I.js → McpSigninBody-DKyUKrEE.js} +1 -1
  43. package/dist/client/assets/{Model3dViewer-BujDNuVS.js → Model3dViewer-rXSL5y2P.js} +1 -1
  44. package/dist/client/assets/NamePage-JwMDK1JD.js +1 -0
  45. package/dist/client/assets/{NewDirectMessageMenu-D4e-z2Jt.js → NewDirectMessageMenu-GCEMS5oV.js} +1 -1
  46. package/dist/client/assets/{NotificationsPage-CkDeTaJp.js → NotificationsPage-DSWsOVLa.js} +1 -1
  47. package/dist/client/assets/{OpenMeshSwitch-CtbOt3r5.js → OpenMeshSwitch-BTuctDj4.js} +1 -1
  48. package/dist/client/assets/{OperatorIdentityForm-Vr4qZnmM.js → OperatorIdentityForm-ODDMd2YN.js} +1 -1
  49. package/dist/client/assets/PermissionHistory-41a58Se7.js +1 -0
  50. package/dist/client/assets/{PermissionsPage-f4QaX8oM.js → PermissionsPage-DefmymZ6.js} +1 -1
  51. package/dist/client/assets/{PersonalityPopover-BkZruwF-.js → PersonalityPopover-7zPVBI1I.js} +1 -1
  52. package/dist/client/assets/PhotoPage-DlOVhkW9.js +1 -0
  53. package/dist/client/assets/{PreviewRefusedNotice-BXC2K0tx.js → PreviewRefusedNotice-CwGlBJ7U.js} +1 -1
  54. package/dist/client/assets/{ProfileFields-BebX5oiv.js → ProfileFields-DVMkpJSb.js} +1 -1
  55. package/dist/client/assets/{ProfilePanelContainer-DZoL65zQ.js → ProfilePanelContainer-RrhoPD3T.js} +1 -1
  56. package/dist/client/assets/{ProfileRolePicker-D9H7wsuT.js → ProfileRolePicker-CXRVBCAu.js} +1 -1
  57. package/dist/client/assets/{PromptSuggestionChips-B5fDmc-g.js → PromptSuggestionChips-bBroJdTi.js} +1 -1
  58. package/dist/client/assets/{ReportsToPopover-uVYhSqj7.js → ReportsToPopover-CfPatsWM.js} +1 -1
  59. package/dist/client/assets/{RoomSurface-Bg5WV4Ep.js → RoomSurface-CdgCdV6h.js} +11 -11
  60. package/dist/client/assets/{RoomsPage-yflYFulU.js → RoomsPage-C3dDp1Mb.js} +1 -1
  61. package/dist/client/assets/{RunsOnPopover-DtGrX1Vq.js → RunsOnPopover-BcKjfQi-.js} +1 -1
  62. package/dist/client/assets/{RuntimeConnectFlow-DjReuQ-T.js → RuntimeConnectFlow-DCIRnvOH.js} +1 -1
  63. package/dist/client/assets/{RuntimeSetupDialog-Cr4GRi8c.js → RuntimeSetupDialog-Bg-0b-LC.js} +1 -1
  64. package/dist/client/assets/SeenDevices-nMsGUQTv.js +19 -0
  65. package/dist/client/assets/{SessionsPage-BWu-en78.js → SessionsPage-Cqfx4FGW.js} +1 -1
  66. package/dist/client/assets/SettingsDialog-C8r2igJ_.js +12 -0
  67. package/dist/client/assets/{SkillsPage-BdUb9SZy.js → SkillsPage-BleHQavF.js} +1 -1
  68. package/dist/client/assets/{TaskDialogWrapper-qYJPEoSR.js → TaskDialogWrapper-BhTEvf-u.js} +1 -1
  69. package/dist/client/assets/{TasksEmptyState-Bgcg9vxF.js → TasksEmptyState-Bprx1k8M.js} +2 -2
  70. package/dist/client/assets/{TasksPage-Ch5W2WQS.js → TasksPage-Dub39yEJ.js} +1 -1
  71. package/dist/client/assets/{TeamComputerEntry-CPwSIMRw.js → TeamComputerEntry-CJ-NG0u5.js} +1 -1
  72. package/dist/client/assets/ToolsPage-IsD6M-ZW.js +2 -0
  73. package/dist/client/assets/{TopologyGraph-I4_mkMHM.js → TopologyGraph-CwyasvFI.js} +14 -14
  74. package/dist/client/assets/{TourHost-BPaSwh9I.js → TourHost-BYfztuPb.js} +1 -1
  75. package/dist/client/assets/{UnlinkDialog-BUWZUu5P.js → UnlinkDialog-BKhgxVdF.js} +1 -1
  76. package/dist/client/assets/{WidgetErrorCard-cS8yMCxU.js → WidgetErrorCard-1NyzIJBj.js} +6 -6
  77. package/dist/client/assets/_shell-Ct2Bz7D0.js +80 -0
  78. package/dist/client/assets/{_shell._home-DCA5k-jb.js → _shell._home-xWj7wO5z.js} +1 -1
  79. package/dist/client/assets/{_shell._home.activity-BX4nFLna.js → _shell._home.activity-BqcLoaB1.js} +1 -1
  80. package/dist/client/assets/{_shell._home.index-C8t8cw72.js → _shell._home.index-D4sQsKKk.js} +1 -1
  81. package/dist/client/assets/{_shell._home.tasks-BgUeEvhK.js → _shell._home.tasks--UhQB6h3.js} +1 -1
  82. package/dist/client/assets/{_shell._home.workspaces-BPBdnkRt.js → _shell._home.workspaces-BPFD8Of2.js} +1 -1
  83. package/dist/client/assets/{_shell.channels-CX4kki7G.js → _shell.channels-CnFdvRzc.js} +4 -4
  84. package/dist/client/assets/{_shell.connections-0vP7g7E4.js → _shell.connections-Ik01wS5M.js} +1 -1
  85. package/dist/client/assets/{_shell.feedback-requests-TsuaO4eR.js → _shell.feedback-requests-Czu42kzo.js} +1 -1
  86. package/dist/client/assets/_shell.marketplace-Cezv-i16.js +1 -0
  87. package/dist/client/assets/_shell.marketplace_.sources-BTENmr4W.js +1 -0
  88. package/dist/client/assets/_shell.session-BjevHF_O.js +63 -0
  89. package/dist/client/assets/{_shell.team-Bm6cOBhR.js → _shell.team-UfaJqohh.js} +3 -3
  90. package/dist/client/assets/_shell.x._extensionId-0OO_Xr72.js +1 -0
  91. package/dist/client/assets/_shell.x._extensionId_._-0OO_Xr72.js +1 -0
  92. package/dist/client/assets/{abnfDiagram-WEYOIA3C-CrvoN15x.js → abnfDiagram-WEYOIA3C-oxkfGyl6.js} +1 -1
  93. package/dist/client/assets/{access-copy-B3yNZ7Gz.js → access-copy-Dggxx2cX.js} +1 -1
  94. package/dist/client/assets/{arc-CuT6QA_y.js → arc-CqQdP0Qe.js} +1 -1
  95. package/dist/client/assets/{architectureDiagram-ZHVYKT53-CPXCZ9H4.js → architectureDiagram-ZHVYKT53-89xM7zJD.js} +1 -1
  96. package/dist/client/assets/{banner-DRumuw3F.js → banner-DqJ2pM0Y.js} +1 -1
  97. package/dist/client/assets/{blockDiagram-RJAE7QA3-CM0rka9p.js → blockDiagram-RJAE7QA3-CcxwDmZC.js} +1 -1
  98. package/dist/client/assets/{c4Diagram-XDPPPE54-D4j2cXRy.js → c4Diagram-XDPPPE54-DCIhIyXa.js} +1 -1
  99. package/dist/client/assets/{card-B3CtfC3R.js → card-DT-vFAns.js} +1 -1
  100. package/dist/client/assets/channel-Ngk70nQZ.js +1 -0
  101. package/dist/client/assets/{chunk-2E7WHVMD-KGyqhVpO.js → chunk-2E7WHVMD-BfWEXcCj.js} +1 -1
  102. package/dist/client/assets/{chunk-2Q5K7J3B-Dl0BHoqK.js → chunk-2Q5K7J3B-KLXLZXlR.js} +1 -1
  103. package/dist/client/assets/{chunk-4EMNKR2T-Da7vH6Kv.js → chunk-4EMNKR2T-CL5Gttmj.js} +1 -1
  104. package/dist/client/assets/{chunk-55XCU76K-DgBUEROO.js → chunk-55XCU76K-cfAl84Mv.js} +1 -1
  105. package/dist/client/assets/{chunk-5VM5RSS4-BQ4mn-_I.js → chunk-5VM5RSS4-BqUyGgoH.js} +1 -1
  106. package/dist/client/assets/{chunk-JWPE2WC7-8LPR3mXf.js → chunk-JWPE2WC7-BWr2ST9i.js} +1 -1
  107. package/dist/client/assets/{chunk-VQ5W62QI-BkIVXi4W.js → chunk-VQ5W62QI-V5zYx50O.js} +1 -1
  108. package/dist/client/assets/{chunk-XXDRQBXY-DQXJx06h.js → chunk-XXDRQBXY-gnvheN_J.js} +1 -1
  109. package/dist/client/assets/{chunk-ZCHMQSOR-DzCE7qlD.js → chunk-ZCHMQSOR-ClGxxZvV.js} +2 -2
  110. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-C_cZra7c.js → classDiagram-v2-4MYWR3UA-DvmHzDb5.js} +1 -1
  111. package/dist/client/assets/{command-CDKbyppr.js → command-CNx4L11m.js} +1 -1
  112. package/dist/client/assets/{cose-bilkent-JH36ORCC-DlXHdGwT.js → cose-bilkent-JH36ORCC-Df8nXBRj.js} +1 -1
  113. package/dist/client/assets/{cpu-B7xLO7jn.js → cpu-D8KJEkdh.js} +1 -1
  114. package/dist/client/assets/{cynefin-EF2NZ3EQ-HhP4ArLc.js → cynefin-EF2NZ3EQ-CAn6ufHs.js} +1 -1
  115. package/dist/client/assets/{cynefinDiagram-WF24UDRP-D4GgWnZV.js → cynefinDiagram-WF24UDRP-Cep_NrRw.js} +1 -1
  116. package/dist/client/assets/{dagre-NK4GIZVX-SZ_OI2Zi.js → dagre-NK4GIZVX-sWD3z9wf.js} +1 -1
  117. package/dist/client/assets/{diagram-CBK3MWTC-BN-_Ja5m.js → diagram-CBK3MWTC-CUpaBATr.js} +1 -1
  118. package/dist/client/assets/{diagram-I5XIIV2D-t7AK6xnL.js → diagram-I5XIIV2D-BejWB2ry.js} +1 -1
  119. package/dist/client/assets/{diagram-ODIL2UCW-C1V7szSc.js → diagram-ODIL2UCW-BGKJfNk9.js} +1 -1
  120. package/dist/client/assets/{diagram-PFBEJUXE-DPtraQ2g.js → diagram-PFBEJUXE-V0dP8H8k.js} +1 -1
  121. package/dist/client/assets/{diagram-RJA3I4VV-D2XNRB2b.js → diagram-RJA3I4VV-Bf5dVsFX.js} +1 -1
  122. package/dist/client/assets/{diagram-TYUNFSNR-BieaRy38.js → diagram-TYUNFSNR-CLrMSqb4.js} +1 -1
  123. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-Bwki86UY.js → ebnfDiagram-V4P3TTPT-BGG4CWA0.js} +1 -1
  124. package/dist/client/assets/{elk-QONTBCTQ-WEXSAyHB.js → elk-QONTBCTQ-bf9D6f0w.js} +1 -1
  125. package/dist/client/assets/{empty-state-J-UJ0BUU.js → empty-state-CDoXnrKn.js} +1 -1
  126. package/dist/client/assets/{erDiagram-KYQIGQAA-DIKASnoc.js → erDiagram-KYQIGQAA-fEUv-33P.js} +1 -1
  127. package/dist/client/assets/{execution-config-ILQiJAmy.js → execution-config-Ca9MDOtV.js} +1 -1
  128. package/dist/client/assets/{file-D40js1Zx.js → file-CiyVL55_.js} +1 -1
  129. package/dist/client/assets/{file-exclamation-point-Dg3ZpiAe.js → file-exclamation-point-DaFRIKco.js} +1 -1
  130. package/dist/client/assets/{file-text-DgdvRfMk.js → file-text-DsnD-A8g.js} +1 -1
  131. package/dist/client/assets/{find-latest-widget-fence-D4kBWC_1.js → find-latest-widget-fence-CNsnCgbB.js} +1 -1
  132. package/dist/client/assets/{flowDiagram-IUGLLWBU-CoavNw0M.js → flowDiagram-IUGLLWBU-CRbeSDod.js} +1 -1
  133. package/dist/client/assets/{form-DlPwEgQH.js → form-Cru78aT-.js} +1 -1
  134. package/dist/client/assets/{format-cron-BrK8RzgT.js → format-cron-9K38-tn1.js} +1 -1
  135. package/dist/client/assets/{ganttDiagram-R7GPNTJY-DccKAz7f.js → ganttDiagram-R7GPNTJY-Mkk7zgs_.js} +1 -1
  136. package/dist/client/assets/{git-branch-BpxhecMq.js → git-branch-CONwEYiR.js} +1 -1
  137. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-DEbo_dgQ.js → gitGraphDiagram-PDYL7XHY-Drre0vyA.js} +1 -1
  138. package/dist/client/assets/{graph-DROgI3M3.js → graph-BJlnKWgo.js} +1 -1
  139. package/dist/client/assets/{heart-c7u4Ezxt.js → heart-CqwUlIUG.js} +1 -1
  140. package/dist/client/assets/{highlighted-body-KPVGNVTW-CrATNdTR.js → highlighted-body-KPVGNVTW-e4LXC_pS.js} +1 -1
  141. package/dist/client/assets/{image-lightbox-DE_fHkw-.js → image-lightbox-DHDtzoja.js} +1 -1
  142. package/dist/client/assets/{image-off-BExgZjfM.js → image-off-DZuLkaRJ.js} +1 -1
  143. package/dist/client/assets/{index-D0eJtRlK.js → index-1yEXEZiH.js} +1 -1
  144. package/dist/client/assets/{index-Be0OJLWK.js → index-A41zxoWk.js} +1 -1
  145. package/dist/client/assets/{index-DeRDq7bD.js → index-B25gvCK_.js} +1 -1
  146. package/dist/client/assets/index-B9bZYNKR.js +1 -0
  147. package/dist/client/assets/{index-DaZ1I8s-.js → index-BBmkfbXd.js} +1 -1
  148. package/dist/client/assets/{index-DNGNMW3c.js → index-BDD2EyoW.js} +1 -1
  149. package/dist/client/assets/{index-Ccf1XBTs.js → index-BFNy-Yp3.js} +1 -1
  150. package/dist/client/assets/{index-DksjixUS.js → index-BIB-maE5.js} +1 -1
  151. package/dist/client/assets/{index-CbHCZsbE.js → index-BKp2B9JS.js} +1 -1
  152. package/dist/client/assets/{index-DCJQGDZk.js → index-BLP5O7X9.js} +1 -1
  153. package/dist/client/assets/{index-DhHobJd3.js → index-BTjZIgFn.js} +1 -1
  154. package/dist/client/assets/{index-BVqSmajJ.js → index-BV2Ezdxv.js} +1 -1
  155. package/dist/client/assets/{index-C7B3eSOP.js → index-B_0LYi32.js} +1 -1
  156. package/dist/client/assets/{index-DDgOoXP1.js → index-Bd7vUYhr.js} +1 -1
  157. package/dist/client/assets/{index-BlyoyIck.js → index-Bo7x9IkO.js} +1 -1
  158. package/dist/client/assets/{index-D150FXCC.js → index-BtDxwJsM.js} +1 -1
  159. package/dist/client/assets/{index-DswGXheF.js → index-By58MgcZ.js} +1 -1
  160. package/dist/client/assets/index-C3cvP8Fo.js +1033 -0
  161. package/dist/client/assets/{index-C5or4L_3.js → index-CVuEUzi5.js} +1 -1
  162. package/dist/client/assets/{index-BkoMsjtM.js → index-CoWJD3Jg.js} +2 -2
  163. package/dist/client/assets/{index-CqPRAM_6.js → index-CyVH876g.js} +1 -1
  164. package/dist/client/assets/{index-BGqvci3k.js → index-D67Kfy-M.js} +1 -1
  165. package/dist/client/assets/{index-D3YeRrne.js → index-DAlpmAIA.js} +1 -1
  166. package/dist/client/assets/{index-BEkYBuOq.js → index-DDNwNOHF.js} +1 -1
  167. package/dist/client/assets/{index-CD8aw6Jb.js → index-DL8ISRMH.js} +1 -1
  168. package/dist/client/assets/{index-AzyLwYS_.js → index-DabU6r9W.js} +3 -3
  169. package/dist/client/assets/{index-CT_pFeX_.js → index-DdJBZE0H.js} +1 -1
  170. package/dist/client/assets/{index-B3eeEDWj.js → index-DijWcSDZ.js} +1 -1
  171. package/dist/client/assets/index-DyRGZyur.css +1 -0
  172. package/dist/client/assets/{index-DINk1YfD.js → index-DzwZJuO1.js} +1 -1
  173. package/dist/client/assets/{index-CZmqtJWZ.js → index-HR8BYVRQ.js} +1 -1
  174. package/dist/client/assets/{index-J3Hh1MnL.js → index-LEcodwyW.js} +1 -1
  175. package/dist/client/assets/index-UPF8suf2.js +1 -0
  176. package/dist/client/assets/{index-DT7pv2iW.js → index-Vz7VUm9l.js} +1 -1
  177. package/dist/client/assets/index-YW-v746p.js +1 -0
  178. package/dist/client/assets/{index-2wezsLA_.js → index-cI2u8WZS.js} +1 -1
  179. package/dist/client/assets/{index-InEBtYxw.js → index-iTQUa_b2.js} +6 -6
  180. package/dist/client/assets/{index-CYy1cjtq.js → index-mZqojApH.js} +1 -1
  181. package/dist/client/assets/{index-dyAahqKe.js → index-pVFjKNjX.js} +1 -1
  182. package/dist/client/assets/{index-DxiRRZRo.js → index-skAhJyIF.js} +1 -1
  183. package/dist/client/assets/{index-BizvylBV.js → index-vJy88bwb.js} +1 -1
  184. package/dist/client/assets/index-wY5OcS4a.js +43 -0
  185. package/dist/client/assets/{index-mwf7ZNk2.js → index-x1yAu9zJ.js} +1 -1
  186. package/dist/client/assets/{index-F-vqXYqa.js → index-xAgihCJ7.js} +1 -1
  187. package/dist/client/assets/{index.esm-BFJ9SG0n.js → index.esm-BUPoRUaG.js} +1 -1
  188. package/dist/client/assets/{infoDiagram-MVDRKAX5-VL8q5pKx.js → infoDiagram-MVDRKAX5-B_Wyzufh.js} +1 -1
  189. package/dist/client/assets/{inline-code-BE9ckzPs.js → inline-code-BIzGDx6z.js} +1 -1
  190. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-BLKkPYF-.js → ishikawaDiagram-HPEHV2GE-BDk2-6Pd.js} +1 -1
  191. package/dist/client/assets/{journeyDiagram-BOSHW7O7-CSYpRobu.js → journeyDiagram-BOSHW7O7-7qf9KWEQ.js} +1 -1
  192. package/dist/client/assets/{kanban-definition-FNSA4HC5-HilAqtZo.js → kanban-definition-FNSA4HC5-CFYDQmXn.js} +1 -1
  193. package/dist/client/assets/{layers-Cm7coqdo.js → layers-C9tVVcXg.js} +1 -1
  194. package/dist/client/assets/{lightbulb-DqdWS75d.js → lightbulb-f4jtsAh0.js} +1 -1
  195. package/dist/client/assets/{link-2-CDJapTSa.js → link-2-ZNlK1BG1.js} +1 -1
  196. package/dist/client/assets/{list-runtime-types-CP82p1u4.js → list-runtime-types-CqO-QFYD.js} +1 -1
  197. package/dist/client/assets/{markdown-content-m_qereFc.js → markdown-content-DaEVxezf.js} +1 -1
  198. package/dist/client/assets/{mention-pill-DV5HIG5Q.js → mention-pill-BiCPflY-.js} +1 -1
  199. package/dist/client/assets/{mermaid.core-zxW6MBr-.js → mermaid.core-SX8SzrsU.js} +4 -4
  200. package/dist/client/assets/{message-square-off-YVtpbaJ0.js → message-square-off-_qbedNGF.js} +1 -1
  201. package/dist/client/assets/{mindmap-definition-6OY57UG3-IAYemvOg.js → mindmap-definition-6OY57UG3-BloJIArH.js} +1 -1
  202. package/dist/client/assets/{more-details-ReA2ZFBn.js → more-details-CdJT0Ehl.js} +1 -1
  203. package/dist/client/assets/{owner-notice-M4hn_1ep.js → owner-notice-BDafFD_I.js} +1 -1
  204. package/dist/client/assets/{package-CUuTl39E.js → package-Cb7lEm7t.js} +1 -1
  205. package/dist/client/assets/{page-container-BnmNikNZ.js → page-container-DsRgIMAL.js} +1 -1
  206. package/dist/client/assets/{paperclip-C6fYq5Zf.js → paperclip-DNu1VtoX.js} +1 -1
  207. package/dist/client/assets/{path-input-DHn9-XaE.js → path-input-D3O71b-X.js} +1 -1
  208. package/dist/client/assets/{pegDiagram-ECIUJNBX-CojaUwe7.js → pegDiagram-ECIUJNBX-Di48kPNu.js} +1 -1
  209. package/dist/client/assets/{pieDiagram-GNMPY74T-CjP3pw6V.js → pieDiagram-GNMPY74T-DY8B_SPD.js} +1 -1
  210. package/dist/client/assets/{plug-DHQcxt7N.js → plug-IIS_cL9-.js} +1 -1
  211. package/dist/client/assets/{primer-trigger-BmV5wjek.js → primer-trigger-DurKYe8C.js} +2 -2
  212. package/dist/client/assets/{profile-errors-BSCuj3rT.js → profile-errors-BdhZfdvZ.js} +1 -1
  213. package/dist/client/assets/{progress-4FQQfnS6.js → progress-g5kkqvlR.js} +1 -1
  214. package/dist/client/assets/{quadrantDiagram-D57K4MC3-OP0Z8zcR.js → quadrantDiagram-D57K4MC3-Depv_dON.js} +1 -1
  215. package/dist/client/assets/{query-error-state-BkUdxenP.js → query-error-state-PuLGD7Jp.js} +1 -1
  216. package/dist/client/assets/{radio-ta5Bw763.js → radio-QOLZSBz1.js} +1 -1
  217. package/dist/client/assets/{railroadDiagram-Y72NRBL7-CT3NCb9b.js → railroadDiagram-Y72NRBL7-BfD2AiZM.js} +1 -1
  218. package/dist/client/assets/registry-Ck8p6n1T.js +1 -0
  219. package/dist/client/assets/{relay-trace-schemas-DwUuyxao.js → relay-trace-schemas-DF_DfZ7s.js} +1 -1
  220. package/dist/client/assets/{requirementDiagram-EQYSW5RA-tde4lYGp.js → requirementDiagram-EQYSW5RA-B1iTjrkD.js} +1 -1
  221. package/dist/client/assets/{room-files-source-CZWhaaOy.js → room-files-source-g1th8mWs.js} +2 -2
  222. package/dist/client/assets/{rotate-ccw-clock-RfbbgUa4.js → rotate-ccw-clock-BGwYMaGL.js} +1 -1
  223. package/dist/client/assets/{rotate-cw-B3rB_YSw.js → rotate-cw-B4Y0q4GY.js} +1 -1
  224. package/dist/client/assets/{sankeyDiagram-SY24JHO5-sdCzIA7-.js → sankeyDiagram-SY24JHO5-D5TzVJrQ.js} +1 -1
  225. package/dist/client/assets/{scroll-area-B4WB7Q40.js → scroll-area-BvScZKSa.js} +1 -1
  226. package/dist/client/assets/{search-x-DCUmWW2_.js → search-x-CqN5twBj.js} +1 -1
  227. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-DvzTJcKu.js → sequenceDiagram-BLEHNHQU-BhUahaNf.js} +1 -1
  228. package/dist/client/assets/{shield-x-CANziVLc.js → shield-x-DHJrwtKp.js} +1 -1
  229. package/dist/client/assets/signed-in-BmywDpR5.js +1 -0
  230. package/dist/client/assets/{sizeCapture-INFHLROL-DuDA7TKE.js → sizeCapture-INFHLROL-D2Vi1Kq9.js} +1 -1
  231. package/dist/client/assets/{soul-file-Co_8f1qw.js → soul-file-BMpVFN7U.js} +1 -1
  232. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-BJPX5JTC.js → stateDiagram-v2-A6IESKWZ-b9gSbZnF.js} +1 -1
  233. package/dist/client/assets/{swimlanes-B3ENRKFQ-CiLSffGv.js → swimlanes-B3ENRKFQ-i47jxLY6.js} +1 -1
  234. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-CA9gW19w.js +8 -0
  235. package/dist/client/assets/{table-BSAvOYPp.js → table-CN2HCi4p.js} +1 -1
  236. package/dist/client/assets/{terminal-6CdY-T1V.js → terminal-BORQniao.js} +1 -1
  237. package/dist/client/assets/{timeline-definition-JXYKGLGB-5oq8sl82.js → timeline-definition-JXYKGLGB-eY5gj0js.js} +1 -1
  238. package/dist/client/assets/{trust-posture-D-Yjm6ot.js → trust-posture-Bcyy5Fub.js} +1 -1
  239. package/dist/client/assets/{unplug-Bq_1WdV7.js → unplug-lkD35Rwp.js} +1 -1
  240. package/dist/client/assets/{unverified-catalog-notice-CEzu54YH.js → unverified-catalog-notice-DiCIrrhU.js} +1 -1
  241. package/dist/client/assets/{use-adapter-catalog-Tn3ZbPAj.js → use-adapter-catalog-BrqVd-47.js} +1 -1
  242. package/dist/client/assets/{use-bindings-Bz9YRgO7.js → use-bindings-CU2RSXOy.js} +1 -1
  243. package/dist/client/assets/{use-composer-prefs-D9oKJSQN.js → use-composer-prefs-Dy2oTM8Y.js} +1 -1
  244. package/dist/client/assets/{use-connector-management-CLYFraXN.js → use-connector-management-5oRqzydY.js} +1 -1
  245. package/dist/client/assets/{use-deep-link-scroll-DkS713kG.js → use-deep-link-scroll-Bg5nW8qq.js} +1 -1
  246. package/dist/client/assets/{use-delete-binding-CukKpHBK.js → use-delete-binding-qeyRkvR1.js} +1 -1
  247. package/dist/client/assets/{use-dev-links-DQ32IcGe.js → use-dev-links-FY4J_PjA.js} +1 -1
  248. package/dist/client/assets/{use-external-adapter-catalog-D-FO_XW6.js → use-external-adapter-catalog-HiWFZZrW.js} +1 -1
  249. package/dist/client/assets/{use-full-activity-feed-BNxcyb1j.js → use-full-activity-feed-K1uk9Wya.js} +1 -1
  250. package/dist/client/assets/use-is-below-desktop-Cu_jKnft.js +1 -0
  251. package/dist/client/assets/use-is-hub-BX7ypNRJ.js +1 -0
  252. package/dist/client/assets/{use-jump-back-in-Bibj5tVk.js → use-jump-back-in-BjZ8EswV.js} +1 -1
  253. package/dist/client/assets/{use-local-browser-xg7WXAVK.js → use-local-browser-CTFiF0wf.js} +1 -1
  254. package/dist/client/assets/{use-mesh-topology-BgCSFw8s.js → use-mesh-topology-CafidaIH.js} +1 -1
  255. package/dist/client/assets/{use-mounted-ref-qRbdZfOU.js → use-mounted-ref-B38uSLCx.js} +1 -1
  256. package/dist/client/assets/{use-notification-prefs-B-4kZR7I.js → use-notification-prefs-m9XSNB6W.js} +1 -1
  257. package/dist/client/assets/{use-panel-tab-placements-CCq-mZlY.js → use-panel-tab-placements-D9n6rNJ1.js} +1 -1
  258. package/dist/client/assets/use-pending-read-BoV-UI1E.js +1 -0
  259. package/dist/client/assets/{use-personality-commit-DwSisUfF.js → use-personality-commit-ChLQfLrK.js} +1 -1
  260. package/dist/client/assets/{use-promo-activation-Botoso6l.js → use-promo-activation-DbJDgp4_.js} +1 -1
  261. package/dist/client/assets/{use-promo-dismissals-RJXp-r_J.js → use-promo-dismissals-Csw0j0N0.js} +1 -1
  262. package/dist/client/assets/{use-pulse-freshness-B3390hGg.js → use-pulse-freshness-BIZ7daHW.js} +1 -1
  263. package/dist/client/assets/{use-relay-config-BV0xcLwS.js → use-relay-config-hUB3lVFv.js} +1 -1
  264. package/dist/client/assets/{use-room-follow-claim-Du4hKHIJ.js → use-room-follow-claim-BpKzhniV.js} +1 -1
  265. package/dist/client/assets/{use-roving-tab-list-g2hO6Ruz.js → use-roving-tab-list-BtM0bZL7.js} +1 -1
  266. package/dist/client/assets/{use-session-canvas-i30oMO_Q.js → use-session-canvas-DRrkNRcL.js} +3 -3
  267. package/dist/client/assets/use-session-diagnostics-BTNgouum.js +16 -0
  268. package/dist/client/assets/{use-unclaimed-chats-B92om889.js → use-unclaimed-chats-BbMZtNG9.js} +1 -1
  269. package/dist/client/assets/use-update-config-CkWwKNkY.js +1 -0
  270. package/dist/client/assets/{useMutationState-DdOGdpjP.js → useMutationState-CVpvw27W.js} +1 -1
  271. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-Di5pJvcw.js → usecaseDiagram-WPOLBNNX-CHcpeLg4.js} +1 -1
  272. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-K7KAf26T.js → vennDiagram-Q3Y3IDCW-gQbZL_A6.js} +1 -1
  273. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-DVTaxQt9.js → wardleyDiagram-IVAIDKWA-BFH_WHzZ.js} +1 -1
  274. package/dist/client/assets/{xychartDiagram-4URNHDU4-x-lSJm_B.js → xychartDiagram-4URNHDU4-B0QpyqeZ.js} +1 -1
  275. package/dist/client/index.html +2 -2
  276. package/dist/drizzle/20261019185620_dor3037_wifi_holds.sql +8 -0
  277. package/dist/drizzle/meta/20261019185620_snapshot.json +14079 -0
  278. package/dist/drizzle/meta/_journal.json +7 -0
  279. package/dist/server/extension-child.cjs +18 -2
  280. package/dist/server/index.js +55523 -26605
  281. package/dist/server/index.js.map +2 -2
  282. package/package.json +6 -6
  283. package/dist/client/assets/ApplyToOverridesDialog-CoO6V1G4.js +0 -1
  284. package/dist/client/assets/HandlePage-Cg8H3mQS.js +0 -1
  285. package/dist/client/assets/NamePage-Bx8T98OF.js +0 -1
  286. package/dist/client/assets/PermissionHistory-DzU1rf2B.js +0 -1
  287. package/dist/client/assets/PhotoPage-CmrOIRjf.js +0 -1
  288. package/dist/client/assets/SeenDevices-SPWkdzoK.js +0 -19
  289. package/dist/client/assets/SettingsDialog-_dEXUhHe.js +0 -12
  290. package/dist/client/assets/ToolsPage-Idimrn3o.js +0 -2
  291. package/dist/client/assets/_shell-ClVN2pUj.js +0 -80
  292. package/dist/client/assets/_shell.marketplace-CiL6YRbl.js +0 -1
  293. package/dist/client/assets/_shell.marketplace_.sources-C0sI8e21.js +0 -1
  294. package/dist/client/assets/_shell.session-_hhBvFc6.js +0 -63
  295. package/dist/client/assets/_shell.x._extensionId-BWy5v1YE.js +0 -1
  296. package/dist/client/assets/_shell.x._extensionId_._-BWy5v1YE.js +0 -1
  297. package/dist/client/assets/channel-DjBlTcCV.js +0 -1
  298. package/dist/client/assets/index-7jby-RRg.js +0 -1
  299. package/dist/client/assets/index-BqIHtiaE.js +0 -1
  300. package/dist/client/assets/index-Cga0qx1T.js +0 -1033
  301. package/dist/client/assets/index-Ct4At33X.js +0 -1
  302. package/dist/client/assets/index-DITPwUa9.js +0 -38
  303. package/dist/client/assets/index-DUZrTFYD.css +0 -1
  304. package/dist/client/assets/registry-Dc102rws.js +0 -1
  305. package/dist/client/assets/signed-in-DctJ2IWe.js +0 -1
  306. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-Dv1-QS9J.js +0 -8
  307. package/dist/client/assets/use-is-below-desktop-gTvJDvw4.js +0 -1
  308. package/dist/client/assets/use-is-hub-B1vPpkYU.js +0 -1
  309. package/dist/client/assets/use-pending-read-C8L_v4Zw.js +0 -1
  310. package/dist/client/assets/use-session-diagnostics-a4b83F5J.js +0 -16
  311. package/dist/client/assets/use-update-config-Tbn3SodN.js +0 -1
@@ -0,0 +1,63 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CVuEUzi5.js","assets/index-C3cvP8Fo.js","assets/index-DyRGZyur.css","assets/index-BIB-maE5.js"])))=>i.map(i=>d[i]);
2
+ var ai=Object.defineProperty;var ii=(e,t,n)=>t in e?ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Je=(e,t,n)=>ii(e,typeof t!="symbol"?t+"":t,n);import{fC as li,i0 as Xr,q3 as ci,r as c,fz as ui,W as ct,dA as Fe,j as r,ar as W,bx as ce,hQ as Jn,a1 as Ce,lp as Jr,q as at,jq as di,q4 as fi,q5 as Zr,q6 as mi,q7 as pi,gb as hi,B as le,a7 as Ee,fs as gi,G as q,J as Jt,X as it,b7 as xt,q8 as _t,q9 as eo,aW as oe,qa as xi,qb as $n,hO as bi,as as to,d7 as yi,ap as vi,np as ki,qc as As,dU as Fs,a8 as lt,p0 as Ci,qd as Si,p6 as vt,qe as Kt,a2 as Qe,p1 as Zn,a4 as kt,hf as jt,dT as es,c8 as wt,cy as _i,cz as ji,cB as wi,cC as Ni,cD as Ei,dy as Di,e as Rs,jY as Ti,de as Ai,x as Le,jZ as Fi,o_ as ts,dP as Ri,qf as Mi,qg as Oi,jN as ns,qh as no,qi as so,qj as Ii,qk as $i,im as ss,a3 as rs,ct as Nt,dS as os,dw as as,dR as Pi,ql as Li,je as ro,qm as Bi,p3 as zi,hz as qi,d$ as Ui,aR as Ve,ai as Et,a9 as is,qn as Hi,nq as Wi,qo as Gi,ba as Vi,T as Dt,hE as Ue,hF as He,aj as oo,qp as Zt,dz as Tt,jj as Ki,c6 as ut,s as At,gU as Qi,gQ as Ms,hK as ao,gY as Yi,C as ls,da as Xi,db as Ji,qq as Zi,l as el,ne as io,aT as tl,qr as nl,qs as sl,qt as rl,qu as ol,qv as al,qw as Pe,mX as je,n5 as il,mY as en,aN as ll,hs as cl,ce as ul,bK as dl,iP as fl,qx as st,a0 as cs,dB as Os,d9 as lo,f as co,qy as ml,ep as pl,aX as hl,f9 as uo,hU as fo,hj as Ct,jf as mo,dC as gl,qz as xl,qA as bl,o as po,y as tn,aS as ho,qB as go,qC as yl,mg as fn,i_ as vl,l2 as kl,bc as xo,qD as Cl,qE as Sl,eN as _l,eO as Is,qF as Pn,qG as bo,qH as jl,qI as wl,qJ as yo,qK as vo,eu as Nl,lx as El,gc as Dl,gd as Tl,ge as Al,gf as Fl,gg as Rl,gh as Ml,gi as Ol,gj as Il,qL as us,qM as $l,qN as Pl,qO as Ll,iV as Bl,iW as zl,iX as ql,iY as mn,nf as Ul,iZ as $s,ji as Hl,bP as Wl,jk as Gl,bR as Vl,qP as Ps,ch as Kl,g2 as ko,cm as Co,cc as Ql,cl as Yl,hS as Xl,cs as So,cq as Jl,m1 as ds,qQ as Zl,aw as ec,qR as tc,lE as re,qS as nc,qT as sc,_ as rc,fZ as Ls,ij as Ge,qU as pn,mA as bt,qV as Bs,qW as zs,qX as qs,c7 as hn,qY as nt,ek as yt,qZ as oc,q_ as _o,q$ as jo,r0 as ac,r1 as ic,r2 as lc,r3 as wo,m3 as cc,r4 as No,r5 as Ze,ll as Eo,r6 as uc,bO as dc,m2 as fc,r7 as mc,ft as Do,r8 as pc,bW as Us,nM as To,r9 as hc,iD as gc,nO as xc,nP as bc,ak as nn,ra as yc,rb as vc,gw as Ao,gt as fs,ki as kc,rc as Cc,rd as Sc,re as pt,rf as _c,rg as jc,cu as wc,eJ as Nc,m7 as Ec,fp as Dc,ls as Tc,dK as Ac}from"./index-C3cvP8Fo.js";import{P as Fc}from"./PromptSuggestionChips-bBroJdTi.js";import{u as Rc,a as Mc,L as Oc,f as Ic,b as $c,c as Pc,B as Lc,d as Bc}from"./primer-trigger-DurKYe8C.js";import{F as zc,H as qc,e as Uc,h as Hc,q as Fo,f as Wc,P as Gc,g as Vc,d as Kc,r as Qc,j as Yc,b as Xc,G as Jc,D as Zc,I as Ro,B as eu,u as tu,E as nu,w as su,v as ru,p as ou,x as au,z as iu,o as lu,n as cu,k as uu,t as du,M as fu,i as mu,W as pu,S as hu,U as gu,A as xu,J as bu,K as yu,L as Hs,y as vu,R as ku}from"./use-session-diagnostics-BTNgouum.js";import{C as Cu}from"./card-DT-vFAns.js";import{a as Su,u as _u,i as ju}from"./use-notification-prefs-m9XSNB6W.js";import{B as wu}from"./banner-DqJ2pM0Y.js";import{t as Ot,b as Ln,l as Nu,k as Eu,N as Mo,n as Du,g as Tu,C as St,M as et,f as Au,D as Fu,U as Ru,F as Mu}from"./index-iTQUa_b2.js";import{a as Ou,b as Iu}from"./markdown-content-DaEVxezf.js";import{u as $u,b as Pu}from"./WidgetErrorCard-1NyzIJBj.js";import{P as Lu,W as Bu,a as zu,C as qu,b as Uu}from"./find-latest-widget-fence-CNsnCgbB.js";import{a as Oo,b as Hu,R as Wu,K as Gu,c as Vu,g as Ku}from"./RuntimeConnectFlow-DCIRnvOH.js";import{a as Io,u as Qu,I as Yu}from"./image-off-DZuLkaRJ.js";import{a as Xu,c as Ju}from"./composer-insert-BpyATrmR.js";import{u as Zu}from"./use-composer-prefs-Dy2oTM8Y.js";import{A as Bn,M as ed}from"./McpAppFrame-BM9cNPPd.js";import{F as $o}from"./file-CiyVL55_.js";import{S as td}from"./shield-x-DHJrwtKp.js";import{u as nd,M as sd}from"./McpSigninBody-DKyUKrEE.js";import{f as rd}from"./format-duration-BCr6uzby.js";import{l as od}from"./use-connector-management-5oRqzydY.js";import{A as ad}from"./AgentRequestCard-B6MHIsxa.js";import{F as id,i as ld}from"./use-session-canvas-DRrkNRcL.js";import{F as cd}from"./file-text-DsnD-A8g.js";import"./use-is-below-desktop-Cu_jKnft.js";import"./git-branch-CONwEYiR.js";import"./use-update-config-CkWwKNkY.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./RuntimeSetupDialog-Bg-0b-LC.js";import"./inline-code-BIzGDx6z.js";import"./list-runtime-types-CqO-QFYD.js";import"./unverified-catalog-notice-DiCIrrhU.js";import"./layers-C9tVVcXg.js";import"./cpu-D8KJEkdh.js";import"./file-drag-GDx2qhdk.js";import"./paperclip-DNu1VtoX.js";import"./index-pVFjKNjX.js";import"./index-xAgihCJ7.js";import"./progress-g5kkqvlR.js";import"./table-CN2HCi4p.js";import"./terminal-BORQniao.js";import"./package-Cb7lEm7t.js";import"./heart-CqwUlIUG.js";import"./useMutationState-CVpvw27W.js";import"./runtime-connect-Dn0T5YWv.js";import"./more-details-CdJT0Ehl.js";import"./access-copy-Dggxx2cX.js";import"./query-error-state-PuLGD7Jp.js";import"./empty-state-CDoXnrKn.js";import"./use-bindings-CU2RSXOy.js";import"./connection-copy--MA7AN04.js";import"./KeyEntry-Cug8ocpX.js";import"./rotate-cw-B4Y0q4GY.js";import"./query-keys-DeYqUDia.js";import"./index.esm-BUPoRUaG.js";function ud(e,t,n={}){const s=e.get();let o=null,a=s,i;const l=typeof s=="string"?s.replace(/[\d.-]/g,""):void 0,u=()=>{o&&(o.stop(),o=null),e.animation=void 0},d=()=>{const h=Ws(e.get()),m=Ws(a);if(h===m){u();return}const g=o?o.getGeneratorVelocity():e.getVelocity();u(),o=new ci({keyframes:[h,m],velocity:g,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:i})},f=()=>{var h;d(),e.animation=o??void 0,(h=e.events.animationStart)==null||h.notify(),o==null||o.then(()=>{var m;e.animation=void 0,(m=e.events.animationComplete)==null||m.notify()})};if(e.attach((h,m)=>{a=h,i=g=>m(gn(g,l)),li.postRender(f)},u),Xr(t)){let h=n.skipInitialAnimation===!0;const m=t.on("change",x=>{h?(h=!1,e.jump(gn(x,l),!1)):e.set(gn(x,l))}),g=e.on("destroy",m);return()=>{m(),g()}}return u}function gn(e,t){return t?e+t:e}function Ws(e){return typeof e=="number"?e:parseFloat(e)}function dd(e,t={}){const{isStatic:n}=c.useContext(ui),s=()=>Xr(e)?e.get():e;if(n)return Io(s);const o=Qu(s());return c.useInsertionEffect(()=>ud(o,e,t),[o,JSON.stringify(t)]),o}function fd(e,t={}){return dd(e,{type:"spring",...t})}function md(e){const t=Math.floor(e/1e3);if(t<3600){const o=Math.floor(t/60),a=t%60;return`${o}m ${String(a).padStart(2,"0")}s`}const n=Math.floor(t/3600),s=Math.floor(t%3600/60);return`${n}h ${String(s).padStart(2,"0")}m`}function Po(e){const[t,n]=c.useState(()=>Date.now()),s=c.useRef(null);if(c.useEffect(()=>{if(e===null){s.current&&(clearInterval(s.current),s.current=null);return}return n(Date.now()),s.current=setInterval(()=>n(Date.now()),1e3),()=>{s.current&&(clearInterval(s.current),s.current=null)}},[e]),e===null)return{formatted:"0m 00s",ms:0};const o=Math.max(0,t-e);return{formatted:md(o),ms:o}}function pd(e={}){const{timeoutMs:t=3e4,onIdle:n,onReturn:s}=e,o=c.useRef(!1),a=c.useRef(null),i=c.useCallback(()=>{o.current||(o.current=!0,n==null||n())},[n]),l=c.useCallback(()=>{o.current&&(o.current=!1,s==null||s())},[s]),u=c.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(i,t),l()},[t,i,l]);return c.useEffect(()=>{a.current=setTimeout(i,t);const d=["mousemove","keydown","scroll","touchstart"];d.forEach(h=>document.addEventListener(h,u,{passive:!0}));const f=()=>{document.hidden?i():u()};return document.addEventListener("visibilitychange",f),()=>{a.current&&clearTimeout(a.current),d.forEach(h=>document.removeEventListener(h,u)),document.removeEventListener("visibilitychange",f)}},[t,i,u]),{isIdle:o.current}}function hd({activeInteraction:e,onApprove:t,onAlwaysAllow:n,onDeny:s,onToggleOption:o,onNavigateOption:a,onNavigateQuestion:i,onSubmit:l,optionCount:u=0,focusedIndex:d=0}){const f=c.useRef(!1);c.useEffect(()=>{f.current=!1},[e==null?void 0:e.toolCallId]),c.useEffect(()=>{if(!e)return;function h(m){const g=m.target,x=(g.tagName==="TEXTAREA"||g.tagName==="INPUT")&&!g.disabled;if(!f.current&&!(m.metaKey||m.ctrlKey||m.altKey)){if(e.type==="approval"){if(m.key==="Enter"&&x&&g.closest("[data-approval-field]")!==null)return;m.key==="Enter"&&m.shiftKey?(m.preventDefault(),f.current=!0,n==null||n()):m.key==="Enter"?(m.preventDefault(),f.current=!0,t==null||t()):m.key==="Escape"&&(m.preventDefault(),f.current=!0,s==null||s());return}if(e.type==="question"){if(x){if(m.key==="Enter"&&!m.shiftKey){m.preventDefault(),l==null||l();return}if(m.key==="ArrowUp"){m.preventDefault(),a==null||a("up");return}if(m.key==="ArrowDown"){m.preventDefault(),a==null||a("down");return}return}const C=parseInt(m.key,10);if(C>=1&&C<=9){m.preventDefault(),C-1<u&&(o==null||o(C-1));return}switch(m.key){case"ArrowUp":m.preventDefault(),a==null||a("up");break;case"ArrowDown":m.preventDefault(),a==null||a("down");break;case" ":m.preventDefault(),o==null||o(d);break;case"ArrowLeft":case"[":m.preventDefault(),i==null||i("prev");break;case"ArrowRight":case"]":m.preventDefault(),i==null||i("next");break;case"Enter":m.preventDefault(),l==null||l();break}}}}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,t,n,s,o,a,i,l,u,d])}function Lo(){const[e,t]=c.useState(()=>!document.hidden);return c.useEffect(()=>{const n=()=>t(!document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),e}/**
3
+ * @license lucide-react v1.48.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const Bo={name:"brain",size:24,node:[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]};Bo.node;const gd=ct(Bo);/**
8
+ * @license lucide-react v1.48.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const zo={name:"corner-up-left",size:24,node:[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]};zo.node;const xd=ct(zo);/**
13
+ * @license lucide-react v1.48.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const qo={name:"file-image",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]};qo.node;const bd=ct(qo);/**
18
+ * @license lucide-react v1.48.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const Uo={name:"file-spreadsheet",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]};Uo.node;const yd=ct(Uo);/**
23
+ * @license lucide-react v1.48.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const Ho={name:"git-branch-plus",size:24,node:[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]};Ho.node;const vd=ct(Ho);/**
28
+ * @license lucide-react v1.48.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const Wo={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]};Wo.node;const kd=ct(Wo);function Cd({color:e,isTextStreaming:t,fadeEdges:n=!0,edge:s="bottom"}){const o=Fe()===!0,a=t?1.8:2.5,i=n?"linear-gradient(to right, transparent, black 15%, black 85%, transparent)":void 0,l=s==="top"?"pointer-events-none absolute right-0 top-0 left-0":"pointer-events-none absolute right-0 bottom-0 left-0",u="[--scan-highlight:hsl(var(--background))] dark:[--scan-highlight:hsl(var(--foreground))]",d=s==="top"?"top":"bottom";return r.jsxs(W.div,{"aria-hidden":!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},className:`${l} ${u}`,style:{height:n?10:0,overflow:n?"hidden":"visible",maskImage:i,WebkitMaskImage:i},children:[r.jsx("div",{className:"absolute right-0 left-0",style:{[d]:0,height:6,backgroundColor:e,opacity:.6,filter:"blur(3px)"}}),!o&&r.jsx(W.div,{initial:{x:"-100%"},animate:{x:"433%"},transition:{x:{duration:a,repeat:1/0,ease:"linear"}},className:"absolute",style:{[d]:0,width:"30%",height:2,background:`linear-gradient(to right, transparent, ${e}, var(--scan-highlight), transparent)`,willChange:"transform"}}),r.jsx(ce,{children:t&&!o&&r.jsx(W.div,{initial:{opacity:0,x:"-100%"},animate:{opacity:.9,x:"1525%"},exit:{opacity:0},transition:{x:{duration:1.1,repeat:1/0,ease:"linear"},opacity:{duration:.2}},className:"absolute",style:{[d]:0,width:"8%",height:1,background:"linear-gradient(to right, transparent, var(--scan-highlight) 40%, var(--scan-highlight) 60%, transparent)",willChange:"transform"}})})]})}const xn={"word-boundary":3,substring:2,subsequence:1},Sd=new Set(["/",":","-","_","."," "]);function _d(e,t){if(t===0)return!0;const n=e[t-1];if(Sd.has(n))return!0;const s=e[t];return n===n.toLowerCase()&&s!==s.toLowerCase()&&s===s.toUpperCase()}function It(e,t){return Array.from({length:t},(n,s)=>e+s)}function $t(e,t,n){const s=1/(1+t),o=n/e.length;return(s*.6+o*.4)*.999}function jd(e,t){let n=0,s=0,o=0;const a=[];for(let i=0;i<t.length&&n<e.length;i++)t[i]===e[n]?(n++,s++,s>o&&(o=s),a.push(i)):s=0;return n===e.length?{indices:a,maxRun:o}:null}function wd(e,t){const n=t.indices[t.indices.length-1]-t.indices[0]+1,s=t.maxRun/t.indices.length,o=t.indices.length/n,a=t.indices.length/e.length;return(s*.4+o*.3+a*.3)*.999}function Wt(e,t){if(!e)return{match:!0,tier:null,score:0,indices:[]};const n=e.toLowerCase(),s=t.toLowerCase();if(s===n)return{match:!0,tier:"exact",score:5+$t(t,0,n.length),indices:It(0,n.length)};if(s.startsWith(n))return{match:!0,tier:"prefix",score:4+$t(t,0,n.length),indices:It(0,n.length)};for(let i=1;i<=s.length-n.length;i++)if(_d(t,i)&&s.startsWith(n,i))return{match:!0,tier:"word-boundary",score:xn["word-boundary"]+$t(t,i,n.length),indices:It(i,n.length)};const o=s.indexOf(n);if(o>=0)return{match:!0,tier:"substring",score:xn.substring+$t(t,o,n.length),indices:It(o,n.length)};const a=jd(n,s);return a?{match:!0,tier:"subsequence",score:xn.subsequence+wd(t,a),indices:a.indices}:{match:!1,tier:null,score:0,indices:[]}}class Nd{constructor(t){Je(this,"config");Je(this,"recentCompletions",[]);Je(this,"queue",[]);Je(this,"isIdle",!1);Je(this,"debounceTimer",null);this.config=t}onTaskCompleted(t,n){if(!this.config.enabled)return;const s=Date.now();this.recentCompletions.push(s),this.recentCompletions=this.recentCompletions.filter(l=>s-l<this.config.debounceWindowMs);const o=n.length,a=n.filter(l=>l.status==="completed").length;if(o>=this.config.minTasksForMajor&&a===o){this.cancelDebounce();const l={level:"major",taskId:t,timestamp:s};this.emitOrQueue(l);return}if(this.recentCompletions.length>=this.config.debounceThreshold){this.cancelDebounce(),this.debounceTimer=setTimeout(()=>{const l={level:"mini",taskId:t,timestamp:Date.now()};this.emitOrQueue(l),this.recentCompletions=[]},this.config.debounceWindowMs);return}if(Math.random()<this.config.miniProbability){const l={level:"mini",taskId:t,timestamp:s};this.emitOrQueue(l)}}setIdle(t){this.isIdle=t}onUserReturn(){if(this.queue.length>0){const n=this.queue.some(s=>s.level==="major")?this.queue.find(s=>s.level==="major"):this.queue[this.queue.length-1];this.config.onCelebrate(n),this.queue=[]}}destroy(){this.cancelDebounce(),this.queue=[],this.recentCompletions=[]}emitOrQueue(t){this.isIdle?this.queue.push(t):this.config.onCelebrate(t)}cancelDebounce(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}const Ed={background:"radial-gradient(circle, rgba(255,215,0,0.15) 0%, transparent 70%)"},Dd={mode:"blur-in",duration:150,easing:"ease-out",sep:"word"},Td={none:void 0,fade:"fadeIn","blur-in":"blurIn","slide-up":"slideUp"};function Ad(e){const t=Td[e.mode];return t?{animation:t,duration:e.duration??150,easing:e.easing??"ease-out",sep:e.sep??"word"}:!1}function Fd(e,t=40){if(e.length<=t)return e;const n=e.split("/").pop()??e,s=n.length+2,o=Math.max(6,t-s);return`${e.slice(0,o)}…/${n}`}function Rd({onlyFirst:e=!1}={}){const o="(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(o,e?void 0:"g")}const Md=Rd({onlyFirst:!0});function Od(e){if(Md.test(e))return"ansi";const t=e.trimStart();if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}return"plain"}function sn(e){var n;const{sessions:t}=Jn();if(e)return(n=t.find(s=>s.id===e))==null?void 0:n.runtime}const Id=typeof window<"u"&&window.location.pathname===fi;let bn=null,Gs=!Id;function $d(e){return Gs?bn===e?!0:(bn=null,!1):(Gs=!0,bn=e,!0)}function Pd(e){var s;const t=Ce(),n=((s=Jr(e))==null?void 0:s.draft)===!0;c.useEffect(()=>{if(!e||n)return;let o=!1;const a=()=>{o||document.visibilityState!=="visible"||(o=!0,document.removeEventListener("visibilitychange",a),$d(e)||at.getState().recordOpened("session",e),t.markSessionOpened(e).catch(i=>{di(t,i)}))};if(a(),!o)return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[e,n,t])}function Go(){const e=Zr(),t=Jr(e.session);return{cwd:(t==null?void 0:t.cwd)??e.dir??null}}function Vo({agentId:e,agentName:t,onResumed:n}){const s=mi(),{data:o,dataUpdatedAt:a,refetch:i}=pi(),[l]=c.useState(()=>Date.now());c.useEffect(()=>{i()},[e,i]);const u=t??"This agent";return o!=null&&a>=l&&!o.pauses.some(f=>f.agentId===e)?null:r.jsxs("div",{"data-testid":"agent-paused-notice",role:"status",className:"border-border bg-muted/50 my-2 flex items-center gap-3 rounded-lg border px-4 py-3",children:[r.jsx(hi,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("p",{className:"text-sm font-medium",children:[u," is paused"]}),r.jsx("p",{className:"text-muted-foreground text-xs",children:"Resume it, then send your message again."})]}),r.jsx(le,{size:"sm",variant:"outline",disabled:s.isPending,onClick:()=>s.mutate(e,{onSuccess:()=>{Ee(`${u} resumed`),n==null||n()}}),children:"Resume"})]})}function Ld(e){if(!e)return[];const t=e.properties??{};return Object.entries(t).map(([n,s])=>({key:n,label:s.description??n,type:s.type??"string",options:s.enum,defaultValue:s.default}))}function Bd({sessionId:e,interactionId:t,serverName:n,message:s,mode:o="form",url:a,requestedSchema:i,status:l,action:u}){const d=Ce(),[f,h]=c.useState(!1),[m,g]=c.useState(null),[x,C]=c.useState(null),[b,y]=c.useState({}),[k,v]=c.useState(!1),p=c.useMemo(()=>Ld(i),[i]),_=l!=="pending",j=c.useCallback(async(E,N)=>{if(!(f||_)){h(!0),g(null),C(null);try{await d.submitElicitation(e,t,E,N)}catch(R){if(R.code!=="INTERACTION_ALREADY_RESOLVED"){g("Couldn’t send your answer. Try again."),C(R instanceof Error?R.message:null),h(!1);return}}h(!1)}},[d,e,t,f,_]),D=c.useCallback(()=>{const E={};for(const N of p)E[N.key]=b[N.key]??N.defaultValue??"";j("accept",E)},[p,b,j]),T=c.useCallback(()=>{j("accept")},[j]),w=c.useCallback(()=>{j("decline")},[j]),A=c.useCallback((E,N)=>{y(R=>({...R,[E]:N}))},[]),S=c.useCallback(()=>{if(a){if(!gi(a)){g(`Couldn’t open ${a}. Nothing has been authorized.`),C(null);return}g(null),C(null),v(!0)}},[a]);return _?r.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 py-1 text-xs",children:[r.jsx("span",{className:"font-mono",children:n}),r.jsx("span",{children:"·"}),r.jsx("span",{children:u==="accept"?"Authorized":u==="decline"?"Declined":"Cancelled"})]}):r.jsxs(W.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className:q("border-border bg-card my-2 rounded-xl border p-4","shadow-soft"),children:[r.jsxs("div",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-xs",children:[r.jsx("span",{className:"bg-muted text-3xs inline-flex items-center rounded-md px-2 py-0.5 font-mono",children:n}),r.jsx("span",{children:"needs something from you"})]}),r.jsx("p",{className:"mb-3 text-sm",children:s}),m&&r.jsxs("div",{className:"mb-2",children:[r.jsx("p",{className:"text-destructive text-xs break-words",children:m}),x&&r.jsx("p",{className:"text-muted-foreground/70 mt-1 text-xs break-words",children:x})]}),o==="url"&&a&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",variant:"outline",onClick:S,disabled:f,children:"Open authorization page"}),k&&r.jsx(le,{size:"sm",onClick:T,disabled:f,children:f?"Sending…":"Done"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:w,disabled:f,children:"Decline"})]}),o==="form"&&r.jsxs(r.Fragment,{children:[p.length>0?r.jsx("div",{className:"mb-3 space-y-2",children:p.map(E=>r.jsxs("div",{children:[r.jsx("label",{htmlFor:`elicitation-${t}-${E.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:E.label}),E.options?r.jsxs("select",{id:`elicitation-${t}-${E.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:b[E.key]??String(E.defaultValue??""),onChange:N=>A(E.key,N.target.value),disabled:f,children:[r.jsx("option",{value:"",children:"Select…"}),E.options.map(N=>r.jsx("option",{value:N,children:N},N))]}):r.jsx("input",{id:`elicitation-${t}-${E.key}`,type:E.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(E.defaultValue??""),value:b[E.key]??"",onChange:N=>A(E.key,N.target.value),disabled:f})]},E.key))}):r.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:"No additional input required."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",onClick:D,disabled:f,children:f?"Sending…":"Accept"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:w,disabled:f,children:"Decline"})]})]})]})}const zd=8,qd={duration:.3,ease:[.16,1,.3,1]},Ud={duration:0};function Hd(e){const t=Math.round(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}:${String(s).padStart(2,"0")}`:`${s}s`}function Wd(e){return new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function Gd(e){return`${e} action${e===1?"":"s"}`}function Vd({outcome:e,items:t,resolvedAt:n,startedAt:s,reasonGiven:o,className:a}){var C;const i=Fe(),[l,u]=c.useState(!1),d=t.length,f=d>1,h=f?Gd(d):(C=t[0])==null?void 0:C.label,m=n!==void 0&&s!==void 0?Math.max(0,n-s):null,g=e==="allowed"?Jt:e==="denied"?it:xt,x=e==="allowed"?"text-status-success":e==="denied"?"text-status-error":"text-muted-foreground";return r.jsxs(W.div,{"data-testid":"approval-receipt","data-outcome":e,"data-count":d,initial:i?!1:{opacity:0,y:zd},animate:{opacity:1,y:0},transition:i?Ud:qd,className:q("text-muted-foreground my-1 text-xs",a),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(g,{className:q("size-(--size-icon-xs) shrink-0",x),"aria-hidden":"true"}),r.jsx("span",{className:"min-w-0 truncate",children:e==="expired"?r.jsxs(r.Fragment,{children:["Expired · ",f?`${h} `:"","denied",m!==null&&` after ${Hd(m)}`]}):r.jsxs(r.Fragment,{children:["You ",e==="allowed"?"allowed":"denied"," ",f?h:r.jsx("span",{className:"font-mono",children:h}),e==="denied"&&o===!0&&r.jsx(r.Fragment,{children:" · agent was told why"})]})}),n!==void 0&&r.jsx("time",{dateTime:new Date(n).toISOString(),className:"ml-auto shrink-0 tabular-nums opacity-70",children:Wd(n)}),f&&r.jsx("button",{type:"button",onClick:()=>u(b=>!b),"aria-expanded":l,className:q("hover:text-foreground focus-visible:ring-ring shrink-0 rounded underline","underline-offset-2 focus-visible:ring-2 focus-visible:outline-none"),children:l?"Hide":"Show"})]}),f&&l&&r.jsx("ul",{"data-testid":"approval-receipt-items",className:"mt-1 ml-6 space-y-0.5",children:t.map(b=>r.jsx("li",{className:"truncate font-mono",children:b.label},b.toolCallId))})]})}function Kd({outcome:e,reasonGiven:t,members:n,lead:s,children:o}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsx(Vd,{outcome:e,items:n.map(a=>({toolCallId:a.toolCallId,label:a.approvalDisplayName||_t(a.toolName,a.input??"")})),resolvedAt:s.approvalResolvedAt,startedAt:s.approvalStartedAt,reasonGiven:t}),e!=="allowed"&&s.result&&r.jsx(eo,{"data-testid":"approval-receipt-result",content:s.result,className:"text-muted-foreground mt-0.5 ml-6"}),e==="allowed"&&o]})}function Ko(e){return e.endsWith("connectors.request_connection")||e.endsWith("connectors_request_connection")}function Qo(e){if(e)try{return JSON.parse(e)}catch{return}}function Gt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qd(e){const t=Qo(e);if(!Gt(t))return;const{serviceSlug:n,reason:s}=t;if(!(typeof n!="string"||typeof s!="string"))return{serviceSlug:n,reason:s}}function Yo(e){const t=Qo(e);if(Gt(t)&&typeof t.requestId=="string")return t.requestId;if(Gt(t)&&Array.isArray(t.content)){const n=t.content.map(s=>Gt(s)&&typeof s.text=="string"?s.text:"").join("");return Yo(n)}}function Yd(e,t){const n=Yo(t.result);if(n)return e.find(o=>o.requestId===n);const s=Qd(t.input);if(s)return e.filter(o=>o.serviceSlug===s.serviceSlug).sort((o,a)=>a.createdAt.localeCompare(o.createdAt))[0]}function Xd({sessionId:e,input:t,result:n,fallback:s}){const o=od(e),a=o.data?Yd(o.data,{input:t,result:n}):void 0;return a?r.jsx("div",{className:"my-3","data-testid":"chat-agent-request",children:r.jsx(ad,{request:a})}):r.jsx(r.Fragment,{children:s})}const yn={name:{exact:0,prefix:1,"word-boundary":2,substring:6,subsequence:8},alias:{exact:3,prefix:4,"word-boundary":5,substring:7,subsequence:9},description:{exact:10,prefix:11,"word-boundary":12,substring:13,subsequence:14}},Jd={match:!1,bucket:Number.POSITIVE_INFINITY,score:0};function Vs(e){return e.startsWith("/")?e.slice(1):e}function Ks(e,t){return e.bucket<t.bucket||e.bucket===t.bucket&&e.score>t.score}function Zd(e,t){let n=Jd;const s=Wt(e,Vs(t.fullCommand));s.match&&s.tier&&(n={match:!0,bucket:yn.name[s.tier],score:s.score});for(const o of t.aliases??[]){const a=Wt(e,Vs(o));if(!a.match||!a.tier)continue;const i={bucket:yn.alias[a.tier],score:a.score};Ks(i,n)&&(n={match:!0,...i,matchedAlias:o})}if(t.description){const o=Wt(e,t.description);if(o.match&&o.tier){const a={bucket:yn.description[o.tier],score:o.score};Ks(a,n)&&(n={match:!0,...a})}}return n}const Xo="dorkos:mcp-app-consent:";function Jo(e){return`${Xo}${e}`}function ef(e){try{return localStorage.getItem(Jo(e))==="granted"}catch{return!1}}function tf(e){try{localStorage.setItem(Jo(e),"granted")}catch{}nf()}const zn=new Set;function nf(){for(const e of zn)e()}function sf(e){zn.add(e);const t=n=>{var s;(s=n.key)!=null&&s.startsWith(Xo)&&e()};return window.addEventListener("storage",t),()=>{zn.delete(e),window.removeEventListener("storage",t)}}function rf(e){const t=c.useSyncExternalStore(sf,()=>ef(e),()=>!1),n=c.useCallback(()=>tf(e),[e]);return{consented:t,grant:n}}const of="h-80";function af({sessionId:e,serverName:t,uri:n,title:s}){const{consented:o,grant:a}=rf(t),i=oe(d=>d.openPip),l=()=>{const d=oe.getState(),f={type:"mcp_app",serverName:t,uri:n,title:s};d.openCanvasDocument(f),$n(d,"user",f)},u=()=>{i({kind:"mcp_app",sessionId:e,serverName:t,uri:n,title:s??`App · ${t}`})};return o?r.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[r.jsxs("div",{className:"bg-muted/40 flex items-center justify-between border-b px-3 py-1.5",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[r.jsx(Bn,{className:"text-muted-foreground size-3.5 shrink-0"}),r.jsx("span",{className:"truncate",children:s??`App · ${t}`})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:u,"aria-label":"Pop out into a floating window",title:"Pop out",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:r.jsx(Lu,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:l,title:"Open in canvas",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:r.jsx(xi,{className:"size-3.5"})})]})]}),r.jsx(ed,{sessionId:e,serverName:t,uri:n,title:s,onRequestFullscreen:l,onRequestPip:u,className:of})]}):r.jsxs("div",{className:"bg-muted/40 flex flex-col gap-3 rounded-lg border p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r.jsx(Bn,{className:"text-muted-foreground size-4 shrink-0"}),r.jsxs("span",{children:["Interactive app from ",t]})]}),r.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[r.jsxs("p",{children:["It runs code from ",t," in a sealed-off frame."]}),r.jsx("p",{children:"It can’t see your chat, files or credentials."})]}),r.jsx("div",{children:r.jsx("button",{type:"button",onClick:a,className:"bg-foreground text-background hover:bg-foreground/90 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors",children:"Show app"})})]})}function lf(e){return e.replace(/[-_]+/g," ").trim()}function cf({action:e}){const t=$u(),n=lf(e.actionId),s=`Widget interaction${e.title?`, ${e.title}`:""}: ${n}`;return r.jsxs(W.span,{"data-testid":"ui-action-chip",title:e.payload?JSON.stringify(e.payload):void 0,className:q("ml-auto inline-flex w-fit items-center gap-2 rounded-full border py-1 pr-3 pl-1.5","bg-muted/40 shadow-soft text-xs"),initial:t?{opacity:0,y:4,scale:.9}:!1,animate:t?{opacity:1,y:0,scale:1}:!1,transition:t?Pu:void 0,children:[r.jsx("span",{className:"sr-only",children:s}),r.jsx("span",{"aria-hidden":!0,className:"bg-primary/10 text-primary flex size-5 shrink-0 items-center justify-center rounded-full",children:r.jsx(kd,{className:"size-3"})}),r.jsxs("span",{"aria-hidden":!0,className:"text-muted-foreground truncate",children:[e.title&&r.jsx("span",{className:"text-foreground font-medium",children:e.title}),e.title&&r.jsx("span",{className:"px-1 opacity-50",children:"·"}),r.jsx("span",{className:"text-foreground font-medium",children:n})]})]})}const uf=/<ui_action>([\s\S]*?)<\/ui_action>/;function Qs(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:null}catch{return null}}function df(e){const t=e.match(uf);if(!t)return null;const n=t[1].split(`
33
+ `);let s=null,o=null,a=null,i=null;for(let l=0;l<n.length;l++){const u=n[l],d=u.match(/^\s*Widget:\s*(.*)$/);if(d){const g=d[1].trim();s=g&&g!=="(untitled)"?g:null;continue}const f=u.match(/^\s*Action:\s*(.*)$/);if(f){o=f[1].trim();continue}const h=u.match(/^\s*Widget ID:\s*(.*)$/);if(h){a=h[1].trim()||null;continue}const m=u.match(/^\s*Payload:\s*(.*)$/);if(m){const g=m[1].trim();if(g&&g!=="(none)")i=Qs(g);else if(!g){let x="";for(let C=l+1;C<n.length;C++){x+=(x?`
34
+ `:"")+n[C];const b=Qs(x.trim());if(b){i=b;break}}}break}}return o?{title:s,actionId:o,widgetId:a,payload:i}:null}function ff({onAllow:e,onNotNow:t}){return r.jsxs(Cu,{"data-slot":"notification-permission-primer",gap:"none",className:"flex-row flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2",children:[r.jsx(bi,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),r.jsx("p",{className:"text-muted-foreground min-w-0 flex-1 text-xs",children:"Get notified when this needs you, even in another tab."}),r.jsxs("div",{className:"flex w-full shrink-0 flex-wrap items-center justify-end gap-1.5 sm:w-auto",children:[r.jsx(le,{variant:"ghost",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:t,children:"Not now"}),r.jsx(le,{variant:"outline",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:e,children:"Turn on notifications"})]})]})}function mf(e){const t=Rc(),{permission:n,request:s}=Su(),{prefs:o,setPrefs:a}=_u(),{data:i}=to(),l=i!==void 0,[u,d]=c.useState(!1),f=yi()||n==="unsupported";c.useEffect(()=>{if(f||!e)return;const x=setTimeout(Mc,Oc);return()=>clearTimeout(x)},[f,e]);const h=c.useCallback(()=>{d(!0),s().then(()=>{a({browserPermissionPrimerDismissed:!0})})},[s,a]),m=c.useCallback(()=>{d(!0),a({browserPermissionPrimerDismissed:!0})},[a]);return{eligible:!f&&l&&t&&!u&&n==="default"&&!o.browserPermissionPrimerDismissed,allow:h,notNow:m}}const pf="dorkos:chat:last-seen:";function hf(){try{const e=[];for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n!=null&&n.startsWith(pf)&&e.push(n)}for(const t of e)window.localStorage.removeItem(t)}catch{}}function gf(e){let t=0;for(const n of e)n._streaming!==!0&&t++;return t}function xf(e){if(typeof e!="object"||e===null)return!1;const{userId:t,threadKind:n,threadId:s,lastReadSeq:o}=e;return typeof t=="string"&&typeof n=="string"&&typeof s=="string"&&typeof o=="number"&&Number.isInteger(o)}function bf(e,t,n=0){const s=Ce(),[o,a]=c.useState(()=>({sessionId:e,lastReadSeq:null,hydrated:!1}));o.sessionId!==e&&a({sessionId:e,lastReadSeq:null,hydrated:!1});const i=c.useRef(0),l=c.useRef(null),u=c.useRef(!1),d=c.useRef(!1),f=c.useRef(e),h=c.useRef(null),m=n+gf(t);c.useEffect(()=>{hf();let k=!1;return f.current=e,i.current=0,l.current=null,u.current=!1,d.current=!1,(async()=>{let v=null;try{v=await s.getReadCursor("session",e)}catch{}k||(v&&(i.current=v.lastReadSeq,h.current=v.userId),a({sessionId:e,lastReadSeq:(v==null?void 0:v.lastReadSeq)??null,hydrated:!0}))})(),()=>{k=!0}},[s,e]);const g=c.useCallback(async()=>{if(!u.current){u.current=!0;try{for(;;){const k=l.current;if(k===null)break;if(l.current=null,k.sessionId!==f.current)continue;if(d.current)break;const v=i.current;i.current=Math.max(v,k.seq);try{const p=await s.setReadCursor("session",k.sessionId,k.seq);h.current=p.userId??h.current}catch{i.current=v,k.sessionId===f.current&&(d.current=!0);break}}}finally{u.current=!1}}},[s]),x=c.useCallback(()=>{!o.hydrated||d.current||m<=i.current||(l.current={sessionId:e,seq:m},g())},[o.hydrated,e,m,g]);vi("read_cursor",k=>{if(!xf(k)||k.threadKind!=="session"||k.threadId!==e)return;const v=h.current;v!==null&&k.userId!==v||k.lastReadSeq<=i.current||(i.current=k.lastReadSeq,a({sessionId:e,lastReadSeq:k.lastReadSeq,hydrated:!0}))});const C=c.useMemo(()=>t.filter(k=>k._streaming!==!0).map((k,v)=>({id:k.id,seq:n+v+1})),[t,n]),b=o.lastReadSeq,y=ki(C,b===null?null:Math.min(b,m));return{lastSeenMessageId:y.lastSeenId,unreadFromStart:y.fromStart,markSeen:x,isHydrated:o.hydrated}}function Ke(e){return e.notAllowed!==!0&&e.usage.state!=="limited"}function yf(e,t){if(e.id===lt||!e.eligible)return e.reason;const n=Ci(e.usage,"seven_day");if(!n||n.usedPct===null)return"usage unknown";const s=Math.min(100,Math.max(0,Math.round(100-n.usedPct))),o=Si(n.resetsAt,t);return o?`${s}% left · resets ${o}`:`${s}% left`}function rn(e,t){return e.runtime!==void 0&&e.runtime!==t}function vf(e,t){const n=[],s=[];for(const o of e)(rn(o,t)?s:n).push(o);return{same:n,other:s}}function Qt(e,t){return`${e.runtime??t}:${e.id}`}function kf(e,t,n){if(rn(e,t)){const s=e.runtime;return!e.label&&e.id===vt?`${Kt({runtime:s,accountLabel:null,identityGate:!1})} (this computer's sign-in)`:Kt({runtime:s,accountLabel:e.label,identityGate:!0})}return e.label?e.label:e.id===vt&&e.usage.label?e.usage.label:e.usage.path?n(e.usage.path):e.id}function Cf(e,t){const n=e.accounts.find(o=>o.id===e.recommendedId);if(n&&Ke(n))return Qt(n,t);const s=e.accounts.find(Ke);return s?Qt(s,t):null}function Sf(e){return e.length===0?null:e.length===1?`${e[0]} is kept out, so it isn’t listed.`:`${`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`} are kept out, so they aren’t listed.`}function _f(e,t){if(e&&t)return{subtitle:"Picks up in the same folder and branch, from the last checkpoint.",carries:"Carries over: files, branch, checkpoint, task",doesnt:"Doesn’t: the chat itself"};const n="Starts a new chat in the same folder, with a summary of this one.";return{subtitle:e?n:`${n} Sorted by most usage left.`,carries:"Carries over: the folder and a summary of this chat",doesnt:"Doesn’t: the chat itself"}}function jf(e){return e.carryOver===!1}function wf(e,t,n){return e?!0:(t==null?void 0:t.accounts.some(s=>rn(s,n)))??!1}function Nf(e){return{id:lt,runtime:e,label:Fs,color:As,eligible:!0,reason:"paid from your DorkOS account",usage:{runtime:"claude-code",accountId:lt,path:"",label:Fs,color:As,subscriptionType:null,plan:null,credits:null,spend:null,windows:[],state:"unknown",limit:null,updatedAt:null}}}function Zo(e,t){const n=Ce();return Qe({queryKey:Zn.continueOptions(e),queryFn:()=>n.getContinueOptions(e),enabled:t,staleTime:0,retry:!1})}function Ef(e){const t=Ce();return kt({mutationFn:n=>t.continueSession(e,n),retry:!1})}function Df(e){const t=Ce();return kt({mutationFn:()=>t.cancelAutoContinue(e),retry:!1})}const Ys="claude-code",Tf="No other account can take this work right now.";function Af(e){return e instanceof Error&&e.message?e.message:"Couldn’t continue on that account. Try again."}function Ff({row:e,value:t,name:n,status:s,selected:o}){const a=Ke(e);return r.jsxs("label",{"data-slot":"continue-account-row","data-eligible":e.eligible,className:q("flex min-h-11 min-w-0 items-center gap-1.5 rounded-lg border px-2.5 py-2 text-sm transition-colors duration-150","has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-[3px]",o?"border-foreground ring-foreground ring-1 ring-inset":"border-border",a?"hover:bg-muted/50 cursor-pointer":"cursor-not-allowed",!e.eligible&&"opacity-60"),children:[r.jsx(Fi,{value:t,disabled:!a,className:"sr-only"}),r.jsx("span",{"aria-hidden":!0,className:"inline-flex",children:r.jsx(ts,{color:e.color,name:n})}),r.jsx("span",{className:"max-w-[55%] shrink-0 truncate font-medium",children:n}),e.badge==="recommended"&&r.jsx("span",{className:q(Ri.success,"border-status-success-border text-2xs shrink-0 rounded-full border px-1.5"),children:"recommended"}),r.jsx("span",{className:"text-muted-foreground ml-auto min-w-0 pl-1 text-right text-xs",children:s})]})}function ea({open:e,onOpenChange:t,sessionId:n,account:s,cancelAutoFirst:o=!1,now:a,onCloseAutoFocus:i}){var ue;const l=jt(),u=a??new Date(l),d=c.useId(),f=s.runtime??Ys,{accounts:h,nameFor:m}=es(),[,g]=wt(),x=Df(n),C=c.useRef(!1),{mutate:b,reset:y}=x;c.useEffect(()=>{if(!e){C.current=!1,y();return}!o||C.current||(C.current=!0,b())},[e,o,b,y]);const k=e&&(!o||x.isSuccess),v=Zo(n,k),p=Ef(n),[_,j]=c.useState(null),D=()=>{p.isPending||(j(null),p.reset(),t(!1))},T=z=>z?t(!0):D(),w=k?v.data:void 0,A=w==null?void 0:w.ranking,S=w&&!jf(w.plan)?[...w.ranking.accounts,...w.credits?[Nf(f)]:[]]:[],E=S.some(Ke),N=_??(A?Cf(A,f):null),R=S.find(z=>Qt(z,f)===N)??null,M=R!==null&&Ke(R),F=z=>kf(z,f,m),{same:O,other:L}=vf(S,f),G=_f((w==null?void 0:w.advised)===!0,s.trackerItems.some(z=>z.via==="this-chat")),V=s.accountId??((ue=s.limit)==null?void 0:ue.accountId)??null,Q=(w==null?void 0:w.advised)===!0&&f===Ys&&V!==null?Sf(h.filter(z=>z.id&&z.id!==V&&!O.some(X=>X.id===z.id)).map(z=>m(z.path))):null,U=()=>{!R||!Ke(R)||p.mutate(rn(R,f)?{account:R.id,runtime:R.runtime}:{account:R.id},{onSuccess:z=>{D(),z.sessionId&&g(z.sessionId)}})},I=z=>{const X=Qt(z,f);return r.jsx(Ff,{row:z,value:X,name:F(z),status:yf(z,u),selected:X===N},X)},P=x.isError?x.error:v.isError&&k?v.error:p.isError?p.error:null,$=e&&!P&&(!k||v.isPending),K=!$&&w!==void 0;return r.jsx(_i,{open:e,onOpenChange:T,children:r.jsxs(ji,{className:"max-h-[85vh] !min-h-0",desktopProps:{className:"sm:max-w-[380px]"},onCloseAutoFocus:i,"aria-labelledby":d,children:[r.jsxs(wi,{className:"shrink-0 text-left",children:[r.jsx(Ni,{id:d,className:"text-left",children:"Continue on another account"}),r.jsx(Ei,{className:"text-left",children:G.subtitle})]}),r.jsxs(Di,{className:"flex flex-col gap-3",children:[$&&r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx(Rs,{className:"h-11 rounded-lg"}),r.jsx(Rs,{className:"h-11 rounded-lg"})]}),K&&(E?r.jsxs(Ti,{"aria-labelledby":d,value:N??"",onValueChange:j,className:"min-w-0 grid-cols-1 gap-1.5",children:[O.map(I),L.length>0&&r.jsx("div",{className:"text-muted-foreground mt-2 text-xs font-semibold tracking-wide uppercase",children:"Other runtimes"}),L.map(I)]}):r.jsx("p",{className:"text-muted-foreground text-sm",children:Tf})),K&&Q&&r.jsx("p",{className:"text-muted-foreground text-xs",children:Q}),K&&r.jsxs("ul",{className:"text-muted-foreground list-disc pl-4 text-xs",children:[r.jsx("li",{children:G.carries}),r.jsx("li",{children:G.doesnt})]}),P!==null&&r.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Af(P)})]}),r.jsxs(Ai,{className:"shrink-0",children:[r.jsx(le,{variant:"outline",onClick:D,disabled:p.isPending,children:"Cancel"}),r.jsxs(le,{onClick:U,disabled:!K||!E||!M||p.isPending,"aria-busy":p.isPending||void 0,children:[p.isPending&&r.jsx(Le,{}),R&&K&&E?`Continue on ${F(R)}`:"Continue"]})]})]})})}const Rf=1440*60*1e3,Mf="Paused until you continue or the account resets",Of="Paused until the task moves or the account resets",If=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited"]);function $f(e){return If.has(e)?"critical":"neutral"}function ta(e){return e.carryOver===!1}function rt(e,t){return e!==null&&Date.parse(e)<=t.getTime()}function ms(e){return`${e} should have reset by now.`}function Pf(e,t,n,s){if(rt(n,s))return ms(e);const o=Mi(t,n,s);return o==="out"?`${e} is out of usage.`:o.startsWith("back in ")?`${e} is out of usage · ${o}.`:`${e} is out of usage ${o.slice(4)}.`}function na(e){return e.plan.mode==="waiting"&&e.plan.resumeAt?e.plan.resumeAt:e.resetsAt}function Xs(e,t,n){if(t===null)return`Waiting for ${e}`;if(rt(t,n))return ms(e);const s=Date.parse(t)-n.getTime();return s<Rf?`Waiting for ${e} · back in ${Oi(s)}`:`Waiting for ${e} · back ${ns(t,n)}`}function Lf(e,t){return Math.max(0,Math.ceil((Date.parse(e)-t.getTime())/1e3))}const Bf=new Set(["continue-on","move-now","keep-going","resume","open-moved"]);function zf(e,t){return(()=>{switch(e){case"limited":return[t.canPick&&"continue-on","wait"];case"handing-off":return["move-now",t.canPick&&"choose","wait"];case"model-limited":return[t.hasFallback&&"keep-going",t.canPick&&"continue-on","wait"];case"wait-only":case"all-accounts-out":return["wait"];case"reset-ready":return["resume"];case"moved":return["open-moved",!t.continuedHere&&"continue-here"];default:return[]}})().filter(s=>s!==!1)}const qf=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited","waiting-reset"]),vn={canSubmit:!0,placeholder:null};function Uf(e,t,n){if(!e)return vn;const s=no(e);if(s==="moved")return{canSubmit:t,placeholder:null};if(!qf.has(s))return vn;const o=i=>i!==null&&!rt(i,n);return o(na(e))||e.plan.mode==="auto"&&o(e.plan.fireAt)?{canSubmit:!1,placeholder:s==="handing-off"?Of:Mf}:vn}const Hf=300*1e3;function sa(e,t){const n=Date.parse(e)-Date.parse(t);return Number.isFinite(n)&&n>=0&&n<=Hf}function Wf(e,t){let n=null;for(const s of e)sa(s.since,t)&&(n===null||Date.parse(s.since)<Date.parse(n.since))&&(n=s);return n}function qn(e,t){var n;return e?((n=t.find(s=>s.value===e))==null?void 0:n.displayName)??e:null}function Gf(e,t){return{from:qn(e.modelFrom,t)??(e.scope==="model"?so(e.window,t):null),to:qn(e.modelTo,t)}}function ra(){const{accounts:e,nameFor:t,colorFor:n}=es(),s=Ii("claude-code",{accountId:vt,path:null});return o=>{const a=$i({accountId:o,path:null,accounts:e,usage:o===vt?s:null,nameFor:t,colorFor:n});return{name:a.name??o,color:a.color}}}const Js=ss(e=>({episodes:new Set,choose:t=>e(n=>n.episodes.has(t)?n:{episodes:new Set([...n.episodes,t])})}));function Vf(e,t){return`${e}\0${t}`}function oa(e,t){const n=t===null?null:Vf(e,t),s=Js(a=>n!==null&&a.episodes.has(n)),o=Js(a=>a.choose);return{continuedHere:s,continueHere:()=>{n!==null&&o(n)}}}const Zs="claude-code",Kf=new Set(["limited","handing-off","model-limited"]),Qf=new Set(["limited","model-limited","all-accounts-out"]);function Yf(e){return(e==null?void 0:e.runsOn)==="own-sign-in"&&e.chosenBy==="user"}function Xf(e){return e instanceof Error&&e.message?e.message:"Couldn’t do that. Try again."}function Jf(e,t){var V,Q,U;const n=Ce(),s=rs(),[,o]=wt(),a=Nt(e,{fetchUsage:!1}),i=t??a,l=i.limit,u=l?no(l):null,d=i.runtime??Zs,f=i.visible,h=ra(),m=d===Zs&&(l!=null&&l.accountId)?h(l.accountId).name:i.name,g=Kt({runtime:d,accountLabel:m,identityGate:f}),x=os({sessionId:e||void 0,runtime:d}).data??[],C=l?ta(l.plan):!0,b=u!==null&&Kf.has(u)&&!C,{isLoaded:y}=es(),{data:k}=as(),v=y&&k!==void 0,p=u==="model-limited",_=Zo(e,b&&v&&(p?f:!f)),j=b&&(p?f&&(((V=_.data)==null?void 0:V.ranking.accounts.some(Ke))??!1):wf(f,(Q=_.data)==null?void 0:Q.ranking,d)),{continuedHere:D,continueHere:T}=oa(e,(l==null?void 0:l.since)??null),{data:w}=Pi(),A=u!==null&&Qf.has(u)&&!C&&(l==null?void 0:l.accountId)!==lt&&Li(w,d)&&!Yf((U=w==null?void 0:w.defaults)==null?void 0:U[d]),S=(l==null?void 0:l.since)??null,E=`${S}:${u}`,[N,R]=c.useState(null),M=I=>R(I===null?null:{key:E,message:I}),F=I=>M(Xf(I)),O=kt({mutationFn:I=>n.waitForReset(e,I),retry:!1,onError:F}),L=kt({mutationFn:I=>n.continueSession(e,I),retry:!1,onError:F,onSuccess:I=>{I.sessionId&&I.sessionId!==e&&o(I.sessionId)}}),G=c.useRef(S);return c.useEffect(()=>{G.current!==null&&S===null&&s.invalidateQueries({queryKey:Zn.limitHistory(e)}),G.current=S},[S,e,s]),{account:i,limit:l,state:u,runtime:d,subject:g,identityGate:f,canPick:j,creditsOffered:A,nameOf:h,models:x,continuedHere:D,continueHere:T,wait:I=>{M(null),O.mutate(I===void 0?{}:{autoResume:I})},continueOn:I=>{M(null),L.mutate(I)},openSession:I=>o(I),pending:O.isPending||L.isPending,failure:(N==null?void 0:N.key)===E?N.message:null}}function kn({visible:e,spoken:t,spokenKey:n}){const[s,o]=c.useState({key:n,text:t});return s.key!==n&&o({key:n,text:t}),r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:e}),r.jsx("span",{className:"sr-only",children:s.key===n?s.text:t})]})}function Cn({account:e,showDot:t}){return r.jsxs(r.Fragment,{children:[t&&e.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-1 inline-flex align-middle",children:r.jsx(ts,{color:e.color,name:e.name,tooltip:!1})}),e.name]})}function Zf(e,t){switch(e){case"continue-on":return"Continue on another account…";case"move-now":return"Move now";case"choose":return"Choose account…";case"keep-going":return`Keep going on ${t}, same account`;case"resume":return"Continue";case"open-moved":return"Open it →";case"continue-here":return"Continue here anyway";case"wait":return"Wait for reset"}}function em({sessionId:e,onSend:t,account:n,now:s}){const o=Jf(e,n),a=ro(),{limit:i,state:l,subject:u,identityGate:d}=o,f=jt(l==="handing-off"?1e3:6e4),h=s??new Date(f),m=i?i.since:null,[g,x]=c.useState(null),C=o.canPick&&m!==null&&g===m,b=E=>x(E?m:null),y=c.useId();if(!i||!l)return null;const k=o.creditsOffered&&a!==null,v=i.plan,p=qn(i.modelFallback,o.models),_=zf(l,{canPick:o.canPick,hasFallback:p!==null,continuedHere:o.continuedHere}),j=`${l}:${i.since}:${u}`;let D,T=null,w=!1;switch(l){case"all-accounts-out":{D="All accounts are out.";const E=i.allOut;if(E!=null&&E.resetsAt){const N=o.nameOf(E.accountId);T=rt(E.resetsAt,h)?ms(N.name):r.jsxs(r.Fragment,{children:["Soonest back: ",r.jsx(Cn,{account:N,showDot:d}),","," ",ns(E.resetsAt,h)]})}break}case"model-limited":D=`${so(i.window,o.models)} is out on ${u} for this week.`;break;case"waiting-reset":{const E=na(i);D=r.jsx(kn,{visible:Xs(u,E,h),spoken:Xs(u,E,h),spokenKey:`${j}:${rt(E,h)}`});break}case"reset-ready":D=v.mode==="waiting"&&v.unconfirmed?`${u} should have reset by now.`:`${u} has reset.`;break;case"moved":{if(v.mode!=="continued")return null;const E=o.nameOf(v.accountId);D=r.jsxs(r.Fragment,{children:["This task continued on ",r.jsx(Cn,{account:E,showDot:d}),"."]});break}default:{const E=Pf(u,i.window,i.resetsAt,h);if(D=r.jsx(kn,{visible:E,spoken:E,spokenKey:`${j}:${rt(i.resetsAt,h)}`}),l==="handing-off"&&v.mode==="auto"){const N=o.nameOf(v.target),R=Lf(v.fireAt,h);w=R===0,T=r.jsx(kn,{visible:r.jsxs(r.Fragment,{children:["Moving this task to ",r.jsx(Cn,{account:N,showDot:d}),w?"…":` in ${R}s…`]}),spoken:w?`Moving this task to ${N.name}.`:`Moving this task to ${N.name} in ${R} seconds.`,spokenKey:`${j}:${v.fireAt}:${N.name}:${w}`})}}}const A=E=>{switch(E){case"continue-on":case"choose":b(!0);return;case"move-now":v.mode==="auto"&&o.continueOn({account:v.target});return;case"keep-going":i.modelFallback&&o.continueOn({model:i.modelFallback});return;case"resume":t(Bi);return;case"open-moved":v.mode==="continued"&&o.openSession(v.sessionId);return;case"continue-here":o.continueHere();return;case"wait":o.wait();return}},S=l==="waiting-reset"&&v.mode==="waiting"&&!ta(v);return r.jsxs(r.Fragment,{children:[r.jsxs(wu,{variant:$f(l),role:"status",icon:null,"data-slot":"account-limit-banner","data-state":l,className:"mx-4 mb-2 rounded-lg border px-3 py-2",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"font-semibold",children:D}),T&&r.jsxs(r.Fragment,{children:[" ",T]})]}),S&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[r.jsx("input",{id:y,type:"checkbox",className:"size-3.5",checked:v.autoResume,disabled:o.pending,onChange:E=>o.wait(E.target.checked)}),r.jsx("label",{htmlFor:y,children:"Continue automatically when it resets"})]}),k&&a&&r.jsx("div",{className:"mt-1.5",children:a({runtime:o.runtime,origin:`limit:${e}`,intent:"keep-going",confirmAfterLink:{prompt:"Linked. Continue on DorkOS credits?",action:"Continue"},onChoose:()=>o.continueOn({account:lt})})}),_.length>0&&r.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:_.map(E=>r.jsx(le,{size:"sm",variant:Bf.has(E)&&!k?"default":E==="continue-here"?"ghost":"outline",className:"h-auto min-h-11 max-w-full py-1 whitespace-normal md:min-h-8",disabled:o.pending||E==="move-now"&&w,onClick:()=>A(E),children:Zf(E,p)},E))}),o.failure&&r.jsx("p",{role:"alert",className:"text-destructive mt-1.5",children:o.failure})]}),o.canPick&&r.jsx(ea,{open:C,onOpenChange:b,sessionId:e,account:{runtime:o.runtime,accountId:o.account.accountId,limit:i,trackerItems:o.account.trackerItems},cancelAutoFirst:l==="handing-off",now:s})]})}function tm(e){const t=Ce();return Qe({queryKey:Zn.limitHistory(e),queryFn:()=>t.getLimitHistory(e),enabled:e!=="",retry:!1})}const nm={moved:qi,"resumed-reset":xt,"resumed-model":xt,"resumed-early":xt};function sm({entry:e,now:t}){const n=jt(),s=t??new Date(n),o=ra(),a=zi(e.runtime),i=os({runtime:e.runtime}).data??[],[,l]=wt(),u=e.runtime==="claude-code"&&e.accountId?o(e.accountId).name:null,d=Kt({runtime:e.runtime,accountLabel:u,identityGate:a}),f=`at ${ns(e.resolvedAt,s)}`,h=nm[e.resolution];let m;switch(e.resolution){case"moved":{const g=e.toAccountId?o(e.toAccountId):null,x=g?r.jsxs(r.Fragment,{children:[a&&g.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-0.5 inline-flex align-middle",children:r.jsx(ts,{color:g.color,name:g.name,tooltip:!1})}),g.name]}):null;m=r.jsxs(r.Fragment,{children:[d," ran out · moved",x&&r.jsxs(r.Fragment,{children:[" to ",e.toSessionId?r.jsx("button",{type:"button",className:"hover:text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 outline-none focus-visible:ring-2",onClick:()=>l(e.toSessionId),children:x}):x]})," ",f]});break}case"resumed-reset":m=`Resumed after reset ${f}`;break;case"resumed-model":{const{from:g,to:x}=Gf(e,i);m=x?`${g??d} ran out · continued on ${x} ${f}`:`${d} ran out · continued here ${f}`;break}case"resumed-early":m=`${d} ran out · continued here ${f}`;break}return r.jsxs("p",{"data-slot":"account-limit-marker","data-resolution":e.resolution,className:"text-muted-foreground text-2xs my-2 flex items-center gap-1.5",children:[r.jsx(h,{"aria-hidden":!0,className:"size-3 shrink-0"}),r.jsx("span",{className:"min-w-0",children:m})]})}function rm({sessionId:e,at:t,fallback:n,now:s}){const{limit:o}=Nt(e,{fetchUsage:!1}),a=tm(e),[i,l]=c.useState(null),u=o!==null&&(t===""||sa(o.since,t));if(u&&((i==null?void 0:i.data)!==a.dataUpdatedAt||i.error!==a.errorUpdatedAt)&&l({data:a.dataUpdatedAt,error:a.errorUpdatedAt}),u||a.isPending)return null;const d=a.data&&t?Wf(a.data.entries,t):null;return d?r.jsx(sm,{entry:d,now:s}):o===null&&i!==null&&a.dataUpdatedAt===i.data&&a.errorUpdatedAt===i.error?null:r.jsx(r.Fragment,{children:n})}function om(e){const{limit:t}=Nt(e,{fetchUsage:!1}),{continuedHere:n}=oa(e,(t==null?void 0:t.since)??null),s=jt();return Uf(t,n,new Date(s))}function am(e){return Nt(e,{fetchUsage:!1}).limit!==null}function im({text:e,indices:t,startOffset:n=0}){const s=new Set(t.map(o=>o-n));return r.jsx(r.Fragment,{children:e.split("").map((o,a)=>s.has(a)?r.jsx("span",{className:"text-foreground font-semibold",children:o},a):r.jsx("span",{children:o},a))})}function lm({filteredFiles:e,selectedIndex:t,onSelect:n}){return c.useEffect(()=>{const s=document.getElementById(`file-item-${t}`);s&&s.scrollIntoView({block:"nearest"})},[t]),r.jsx(W.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:s=>s.preventDefault(),children:r.jsx("div",{id:"file-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?r.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No files found."}):e.map((s,o)=>{const a=o===t,i=s.isDirectory?Ui:$o;return r.jsxs("div",{id:`file-item-${o}`,role:"option","aria-selected":a,"data-selected":a,tabIndex:a?0:-1,onClick:()=>n(s),onKeyDown:l=>{l.key==="Enter"&&n(s)},className:"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[r.jsx(i,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:r.jsx(im,{text:s.filename,indices:s.indices,startOffset:s.directory.length})}),s.directory&&r.jsx("p",{className:"text-muted-foreground/70 truncate text-xs leading-normal",children:s.directory})]})]},s.path)})})})}function cm(e){const t=Ce();return Qe({queryKey:["files",{cwd:e??null}],queryFn:()=>t.listFiles(e),enabled:!!e,staleTime:Ve.FILES_STALE_TIME_MS,gcTime:Ve.FILES_GC_TIME_MS})}const um="You",dm="human",fm="system",mm="System",pm="agent",hm="Agent",gm="chat-sender:",er="room-author:",xm="Room member",bm="runtime:";function ym(e){return e.messageType==="local_command_output"||e.messageType==="compaction"}function vm(e,t){var a,i,l,u,d,f;if(ym(e)||e._chatStop)return{kind:"system",id:fm,displayName:mm};const n=e.role==="user"?(i=(a=e.chatMessages)==null?void 0:a[0])==null?void 0:i.from:void 0;if(n){const h=n.agentId??n.chatId,m=((l=t.senderAgent)==null?void 0:l.call(t,n))??Et({id:h});return{kind:"agent",id:`${gm}${h}`,displayName:n.agentName,emoji:m.emoji,color:m.color}}const s=e.role==="user"?e.roomMessage:void 0;if(s&&!((u=s.author)!=null&&u.you))return km(s,t);if(e.role==="user")return{kind:"human",id:dm,displayName:((d=t.humanName)==null?void 0:d.trim())||um};if(t.agent){const{id:h,displayName:m,emoji:g,color:x,imageUrl:C}=t.agent;return{kind:"agent",id:h,displayName:m,emoji:g,color:x,imageUrl:C}}const o=(f=t.runtime)==null?void 0:f.trim();return o?{kind:"agent",id:`${bm}${o}`,displayName:is(o),runtime:o}:{kind:"agent",id:pm,displayName:hm}}function km(e,t){var o;const{author:n}=e;if(!n)return{kind:"human",id:`${er}entry:${e.entryId}`,displayName:xm};const s=`${er}${n.id}`;if(n.kind==="agent"){const a=n.agentId??n.id,i=((o=t.senderAgent)==null?void 0:o.call(t,{agentId:a,chatId:a}))??Et({id:a,...n.emoji?{icon:n.emoji}:{},...n.color?{color:n.color}:{}});return{kind:"agent",id:s,displayName:n.displayName,...i}}return{kind:n.kind,id:s,displayName:n.displayName}}function aa(e){return`msg-${e}`}function Cm(){return{last:null}}function Sm(e,t){const{resolveAuthor:n,now:s,cache:o}=t,a=t.lastSeenMessageId??null,i=t.unreadFromStart??!1,l=o==null?void 0:o.last,u=l&&l.resolveAuthor===n&&l.now===s&&l.lastSeenMessageId===a&&l.unreadFromStart===i?l:null;let d=0;if(u){const b=Math.min(e.length,u.messages.length);for(;d<b&&e[d]===u.messages[d];)d++}const f=u?u.authors.slice(0,d):[],h=u?u.items.slice(0,d):[];for(let b=f.length;b<e.length;b++){const y=e[b],k=n(y,b);f.push(k),h.push({id:y.id,authorId:k.id,timestamp:y.timestamp})}const m={now:s,lastSeenId:a,unreadFromStart:i},{rows:g,kept:x}=u?Hi(h,m,u.timeline,d):{rows:Wi(h,m),kept:0},C=u?u.rows.slice(0,x):[];for(let b=x;b<g.length;b++){const y=g[b];C.push(y.kind!=="item"?y:{kind:"message",key:aa(e[y.index].id),messageIndex:y.index,message:e[y.index],grouping:y.grouping,author:f[y.index]})}return o&&(o.last={messages:e,authors:f,items:h,resolveAuthor:n,now:s,lastSeenMessageId:a,unreadFromStart:i,timeline:g,rows:C}),C}function _m(e){const t=[],n=new Set;for(const s of e){const o=s.lastIndexOf("/"),a=o>=0?s.slice(0,o+1):"",i=o>=0?s.slice(o+1):s;t.push({path:s,filename:i,directory:a,isDirectory:!1});const l=s.split("/");for(let u=1;u<l.length;u++){const d=l.slice(0,u).join("/")+"/";n.has(d)||(n.add(d),t.push({path:d,filename:l[u-1]+"/",directory:u>1?l.slice(0,u-1).join("/")+"/":"",isDirectory:!0}))}}return t}function jm(e,t){const n=[...e].reverse().find(s=>s.role==="user");if(n!=null&&n.content)return n.content;if((t==null?void 0:t.kind)==="first-message"&&t.kickoffMessage)return t.kickoffMessage}const ia=Symbol("no-error-part");function wm(e){for(let t=e.length-1;t>=0;t--){const n=e[t].parts;for(let s=n.length-1;s>=0;s--){const o=n[s];if(o.type==="error")return o.category}}return ia}function Nm(e){const{messages:t,status:n,lastErrorCategory:s,queuedCount:o,draft:a}=e;if(a.trim().length>0||n==="streaming"||o>0)return null;let i=-1;for(let d=t.length-1;d>=0;d--)if(t[d].role==="user"){i=d;break}const l=i===-1?"":t[i].content.trim();if(!l)return null;const u=wm(t.slice(i+1));return u!==ia?u==="auth_error"?l:null:n==="error"&&s==="auth_error"?l:null}const Em="dorkos:signin-resume",Dm=1e4;function Tm(){const e=c.useRef(new Map),t=c.useRef(null);return c.useEffect(()=>{const n=Gi(Em);t.current=n;const s=e.current,o=n.onMessage(a=>{s.set(a.sessionId,Date.now())});return()=>{o(),n.close(),t.current=null}},[]),c.useMemo(()=>({claimedElsewhere:n=>{const s=e.current.get(n);return s!==void 0&&Date.now()-s<Dm},claim:n=>{var s;return(s=t.current)==null?void 0:s.postMessage({sessionId:n})}}),[])}function la(e){switch(e){case"pending":case"running":return r.jsx(Le,{size:"xs",className:Ot({status:e})});case"complete":return r.jsx(Jt,{className:q("size-(--size-icon-xs)",Ot({status:e}))});case"error":return r.jsx(it,{className:q("size-(--size-icon-xs)",Ot({status:e}))});case"neutral":return r.jsx(Vi,{className:q("size-(--size-icon-xs)",Ot({status:e}))})}}function tr({type:e,toolName:t,toolInput:n,...s}){const o=e==="approval"?"Waiting for approval":"Answering questions",a=t?_t(t,n??""):null,i=a?`${o} · ${a}`:`${o}…`;return r.jsx("div",{className:"bg-muted/50 rounded-msg-tool text-muted-foreground shadow-msg-tool border px-3 py-1 text-sm transition-colors duration-150",...s,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Le,{className:"shrink-0"}),r.jsx("span",{className:"truncate text-xs",children:i})]})})}function Ft({expanded:e,onToggle:t,header:n,children:s,variant:o="default",dimmed:a=!1,disabled:i=!1,hideChevron:l=!1,extraContent:u,ariaLabel:d,className:f,...h}){const m=l?void 0:e;return r.jsxs("div",{className:q("bg-muted/40 mt-px rounded-md border-l-2 text-sm transition-[opacity,background-color,border-color,box-shadow] duration-200 first:mt-1","hover:bg-muted/60 hover:border-l-muted-foreground/60 hover:shadow-soft",o==="default"&&"border-l-muted-foreground/30",o==="thinking"&&"border-l-muted-foreground/20",o==="memory"&&"border-l-muted-foreground/20",a&&!e&&"opacity-50 hover:opacity-100",f),...h,children:[r.jsxs("button",{onClick:()=>!i&&t(),disabled:i,className:q("focus-ring flex w-full items-center gap-2 rounded-md px-3 py-1",i&&"cursor-default"),"aria-expanded":m,"aria-label":d,children:[n,!l&&!i&&r.jsx(W.div,{animate:{rotate:e?180:0},transition:{type:"spring",stiffness:400,damping:30},className:"ml-auto",children:r.jsx(Dt,{className:"text-muted-foreground size-(--size-icon-xs)"})})]}),u,r.jsx(ce,{initial:!1,children:e&&r.jsx(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"overflow-hidden",children:r.jsx("div",{className:"border-border/50 border-t px-3 pt-1 pb-3",children:s})})})]})}const Am=[0,.2,.4];function ca({className:e}){return r.jsx("div",{className:q("flex gap-1",e),"data-testid":"typing-dots","aria-hidden":"true",children:Am.map(t=>r.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:`${t}s`}},t))})}function Fm({record:e}){const t=Fe(),{color:n,emoji:s}=Et({id:e.agentId,icon:e.icon,color:e.color}),o=e.displayName.trim()||"Your agent";return r.jsxs("div",{className:"flex flex-col items-center gap-5 text-center","data-testid":"first-light",children:[r.jsx(W.div,{animate:t?void 0:{scale:[1,1.05,1],opacity:[.9,1,.9]},transition:t?void 0:{duration:3,repeat:1/0,ease:"easeInOut"},children:r.jsx(oo,{color:n,emoji:s,size:"lg"})}),r.jsxs("div",{className:"flex flex-col items-center gap-3",children:[r.jsxs("p",{className:"text-muted-foreground text-base","aria-live":"polite",children:[o," is waking up…"]}),r.jsx(ca,{})]})]})}function Rm({birthRecord:e,firstLightRecord:t}){return(e==null?void 0:e.greetingFailed)===!0?r.jsxs("div",{className:"text-center","data-testid":"greeting-failed-empty",children:[r.jsxs("p",{className:"text-muted-foreground text-base",children:[e.displayName," couldn’t say hello just now"]}),r.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Send a message to get started."})]}):t?r.jsx(Fm,{record:t}):r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-muted-foreground text-base",children:"Start a chat"}),r.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Type a message below to begin."})]})}function Mm(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function Om({sessionId:e}){const t=Zt(e),n=Fe();if(!t||t.kind==="first-message")return null;const s=Mm(t.bornAt),o=Tt(t.runtime).label;return r.jsxs(W.div,{initial:n?!1:{opacity:0,y:-4},animate:{opacity:1,y:0},transition:{duration:.3},"data-testid":"birth-certificate",className:"text-muted-foreground flex items-center justify-center gap-1.5 px-4 pt-3 pb-1 text-xs",children:[r.jsx(Ki,{className:"text-primary size-3.5 shrink-0 fill-current","aria-hidden":"true"}),r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"text-foreground font-medium",children:t.displayName}),s&&r.jsxs(r.Fragment,{children:[r.jsx(Sn,{}),r.jsxs("span",{children:["born ",s]})]}),r.jsx(Sn,{}),r.jsxs("span",{className:"min-w-0 truncate",children:["lives in ",r.jsx("code",{className:"text-2xs",children:t.path})]}),r.jsx(Sn,{}),r.jsxs("span",{className:"shrink-0",children:["runs on ",o]})]})]})}function Sn(){return r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50 shrink-0",children:"·"})}const Im="another chat";function $m(e,t){const n=t==null?void 0:t.find(s=>s.id===e);return n?Qi(n)?Ms("autonomy"):n.label:ao(e)?Ms("autonomy"):Yi(e)}function Pm({startedBy:e,modes:t}){var a;const n=ut();if(!e)return null;const s=((a=e.reason)==null?void 0:a.trim())||null,o=e.kind==="chat"?e.permission:null;return r.jsxs(r.Fragment,{children:[r.jsx(Lm,{startedBy:e,reason:s,navigate:n}),o&&r.jsxs("p",{"data-testid":"started-level-line",className:"text-muted-foreground mx-auto max-w-prose px-4 pb-1 text-center text-xs",children:["Started at ",$m(o.mode,t),","," ",o.sameAsStarter?"same as":"lower than"," the chat that started it."]})]})}function Lm({startedBy:e,reason:t,navigate:n}){return r.jsxs("p",{"data-testid":"started-by-line",className:"text-muted-foreground mx-auto max-w-prose px-4 pt-3 pb-1 text-center text-xs",children:[e.kind==="extension"?r.jsxs(r.Fragment,{children:["Started by the"," ",r.jsx("span",{className:"text-foreground font-medium",children:e.extensionName})," extension"]}):r.jsxs(r.Fragment,{children:["Started from"," ",r.jsx("button",{type:"button",onClick:()=>void n(At({session:e.sessionId})),className:"text-foreground focus-visible:ring-ring rounded-sm font-medium underline-offset-2 hover:underline focus-visible:ring-2 focus-visible:outline-none",children:e.title??Im})]}),t&&r.jsxs(r.Fragment,{children:[": ",t]})]})}function Bm({content:e}){const[t,n]=c.useState(!1);return r.jsxs("div",{"data-testid":"started-prompt",className:"px-4 py-1",children:[r.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring mx-auto flex items-center gap-1 rounded-sm text-xs focus-visible:ring-2 focus-visible:outline-none",children:["What it was asked",r.jsx(ls,{"aria-hidden":"true",className:q("size-3 transition-transform duration-200",t&&"rotate-90")})]}),t&&r.jsx("div",{className:"bg-muted/40 text-foreground mx-auto mt-2 max-w-prose rounded-md px-3 py-2 text-sm break-words whitespace-pre-wrap",children:e})]})}const zm={a:Ji,img:Iu},ua=c.createContext({isStreaming:!1});function qm(e){const t=c.useContext(ua);return r.jsx(zu,{...e,...t})}const Um={renderers:[{language:Bu,component:qm}]};function ps({content:e,isStreaming:t=!1,textEffect:n=Dd,sessionId:s,isLatestWidgetMessage:o}){const a=Ad(n),i=c.useMemo(()=>({sessionId:s,isLatestMessage:o,isStreaming:t}),[s,o,t]);return r.jsx(ua.Provider,{value:i,children:r.jsx("div",{className:q("relative",t&&"streaming-cursor"),children:r.jsx(Ou,{resetKey:e,fallback:r.jsx("div",{className:"text-sm break-words whitespace-pre-wrap",children:e}),children:r.jsx(Xi,{shikiTheme:["github-light","github-dark"],components:zm,animated:a,isAnimating:t,plugins:Um,children:e})})})})}function Un(e){if(e)try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}function me(e,t){const n=e==null?void 0:e[t];return typeof n=="string"&&n.length>0?n:void 0}function Hm(e){const t=Un(e);if(t){if(Array.isArray(t.content))for(const n of t.content){const s=typeof(n==null?void 0:n.text)=="string"?Un(n.text):void 0;if(s)return s}return t}}function da(e){const t=Zi(e.toolName);if(t!=="chat_send"&&t!=="session_start"&&t!=="chat_stop")return null;const n=Un(e.input),s=Hm(e.result),o=Wm(e,s),a=o===void 0&&(s==null?void 0:s.status)==="approval_required",i=me(n,"delivery");return{tool:t,...me(n,t==="chat_stop"?"chat":"to")!==void 0?{to:me(n,t==="chat_stop"?"chat":"to")}:{},...me(n,t==="session_start"?"prompt":"message")!==void 0?{message:me(n,t==="session_start"?"prompt":"message")}:{},...me(n,"summary")!==void 0?{summary:me(n,"summary")}:{},...i==="queue"||i==="steer"||i==="interrupt"?{delivery:i}:{},...me(n,"reason")!==void 0?{reason:me(n,"reason")}:{},...me(s,"messageId")!==void 0?{messageId:me(s,"messageId")}:{},...(me(s,"chatId")??me(s,"sessionId"))!==void 0?{chatId:me(s,"chatId")??me(s,"sessionId")}:{},...o!==void 0?{error:o}:{},...a?{waiting:a}:{},...t==="chat_stop"&&o===void 0&&(s==null?void 0:s.stopped)===!1?{notRunning:!0}:{},...me(s,"note")!==void 0?{note:me(s,"note")}:{}}}const Pt="It could not be sent.";function Wm(e,t){var n;if((t==null?void 0:t.status)==="denied")return me(t,"message")??Pt;if((t==null?void 0:t.ok)===!1||typeof(t==null?void 0:t.error)=="string")return me(t,"error")??me(t,"message")??Pt;if(e.status==="error")return t?me(t,"error")??me(t,"message")??Pt:((n=e.result)==null?void 0:n.trim())||Pt}function Gm(e,t=60){const n=e.trim().split(new RegExp("(?<=[.!?])\\s"))[0]??"";if(n.length<=t)return n;const s=n.slice(0,t),o=s.lastIndexOf(" ");return`${(o>t/2?s.slice(0,o):s).replace(/[\s,;:.]+$/,"")}…`}function Vm(e,t){if(e){for(let n=t.length-1;n>=0;n--)if(t[n].to.chatId===e)return t[n].to}}function Km(e,t){if(e.messageId)return t.find(n=>n.id===e.messageId);if(e.tool==="session_start"&&e.chatId)return t.find(n=>n.kind==="start"&&n.to.chatId===e.chatId)}function Qm(e,t){if(e&&e.trim())return e.trim();const s=((t??"").split(`
35
+ `).find(o=>o.trim()!=="")??"").replace(/^#+\s*/,"").trim();return s.length>72?`${s.slice(0,71)}…`:s}function Ym(e,t){if(t.error)return{label:"Failed",tone:"error"};if(t.waiting)return{label:"Waiting for approval",tone:"muted"};if(!e)return{label:t.pending?"Sending":"Sent",tone:"muted"};switch(e.status){case"queued":return{label:e.position?`Queued · #${e.position}`:"Queued",tone:"muted"};case"steered":return{label:"Steered in",tone:"done"};case"working":return{label:e.delivery==="interrupt"?"Interrupted, working":"Working",tone:"active"};case"delivered":return{label:e.delivery==="interrupt"?"Interrupted, then delivered":"Delivered",tone:"done"};case"replied":return{label:"Replied",tone:"done"};case"failed":return{label:"Failed",tone:"error"};default:return{label:"Sent",tone:"muted"}}}function Xm(e){const t=[];return e.kind==="report"&&t.push("Report"),e.kind==="start"&&t.push("Started this chat"),e.delivery==="steer"&&t.push("Steered in"),e.delivery==="interrupt"&&t.push("Interrupted"),t}function fa(e,t){var n,s;for(const o of e){if((n=o.chatMessages)!=null&&n.some(i=>i.id===t))return o.id;const a=[...o.toolCalls??[],...(o.parts??[]).filter(i=>i.type==="tool_call")];for(const i of a)if(((s=da(i))==null?void 0:s.messageId)===t)return o.id}}const nr=new WeakMap;function Jm(e,t){if(t.length===0)return e;const n=[];let s=0;const o=a=>{let i=nr.get(a);return i||(i={id:`chat-stop-${a.id}`,role:"user",content:"",parts:[],timestamp:a.at,_chatStop:a},nr.set(a,i)),i};for(const a of e){const i=a.timestamp==="",l=i?Number.NaN:Date.parse(a.timestamp),u=d=>i||!Number.isNaN(l)&&Date.parse(d.at)<l;for(;s<t.length&&u(t[s]);)n.push(o(t[s])),s+=1;n.push(a)}for(;s<t.length;)n.push(o(t[s])),s+=1;return n}function Zm({stamp:e}){const t=Xm(e);return t.length===0?null:r.jsx(r.Fragment,{children:t.map(n=>r.jsx("span",{"data-testid":"chat-message-tag",className:"bg-muted text-muted-foreground text-2xs rounded px-1.5 py-px leading-4 font-medium",children:n},n))})}function ma({stamp:e}){const t=ut(),n=e.from.chatTitle??"another chat";return r.jsxs("span",{"data-testid":"chat-from-mark",className:"inline-flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[r.jsxs("span",{className:"text-muted-foreground inline-flex min-w-0 items-center gap-1",children:[r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{children:"from"}),r.jsx("button",{type:"button",onClick:()=>void t(At({session:e.from.chatId,message:e.id})),className:"focus-ring text-foreground/80 hover:text-foreground max-w-48 truncate underline-offset-4 hover:underline",children:n})]}),r.jsx(Zm,{stamp:e})]})}function ep({sessionId:e,messageId:t}){const n=ut();return r.jsxs("button",{type:"button","data-testid":"chat-reply-to",onClick:()=>void n(At({session:e,message:t})),className:"focus-ring text-muted-foreground hover:text-foreground focus-visible:text-foreground mb-1 inline-flex items-center gap-1 text-xs underline-offset-4 hover:underline",children:[r.jsx(xd,{"aria-hidden":!0,className:"size-3"}),"Reply to your message"]})}function tp({stamps:e,sessionId:t}){return r.jsx("div",{className:"space-y-2","data-testid":"received-chat-messages",children:e.map((n,s)=>r.jsxs("div",{"data-testid":"received-chat-message","data-kind":n.kind,className:"border-status-info-border bg-status-info-bg rounded-r-md border-l-2 py-1.5 pr-2 pl-3",children:[n.replyToId&&t&&r.jsx(ep,{sessionId:t,messageId:n.replyToId}),s>0&&r.jsxs("div",{className:"text-muted-foreground mb-1 flex flex-wrap items-center gap-1.5 text-xs",children:[r.jsx("span",{className:"text-foreground/80 font-medium",children:n.from.agentName}),r.jsx(ma,{stamp:n})]}),r.jsx("div",{className:"msg-prose",children:r.jsx(ps,{content:n.text,isStreaming:!1,...t?{sessionId:t}:{}})})]},n.id))})}function np({stamp:e}){const t=ut(),n=e.roomLabel??"a room";return r.jsxs("span",{"data-testid":"room-post-mark",className:"text-muted-foreground inline-flex min-w-0 items-center gap-1 text-xs",children:[r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{children:"in"}),r.jsx("button",{type:"button","aria-label":`Open ${n}`,onClick:()=>void t({...el.channels(),search:{id:e.roomId}}),className:"focus-ring text-foreground/80 hover:text-foreground max-w-48 truncate underline-offset-4 hover:underline",children:n})]})}const sp={muted:"text-muted-foreground",active:"text-foreground",done:"text-muted-foreground",error:"text-destructive"};function rp(e){return e.charAt(0).toUpperCase()+e.slice(1)}function op(e,t,n){if(e.error)return e.error;if(e.waiting)return"Waiting for a person to approve it.";if(e.tool==="chat_stop")return e.note??(e.notRunning?"Nothing was running there.":"Asked it to stop.");if(!t)return e.note??"Sent.";const s=rp(n);switch(t.status){case"queued":return t.position?`Waiting for ${n} to finish its turn. Number ${t.position} in line.`:`Waiting for ${n} to finish its turn.`;case"steered":return`Joined ${n}’s running turn.`;case"working":return t.delivery==="interrupt"?`Stopped ${n}’s turn. ${s} is on this now.`:`${s} is working on it.`;case"delivered":return`${s} read it and finished its turn.`;case"replied":return`${s} replied.`;case"failed":return t.failureReason??"It was not delivered.";default:return"Sent."}}function ap(e,t){return e.error?{label:"Failed",tone:"error"}:e.waiting?{label:"Waiting for approval",tone:"muted"}:t?{label:"Stopping",tone:"muted"}:e.notRunning?{label:"Not running",tone:"muted"}:{label:"Stopped",tone:"done"}}function ip({part:e,sent:t,at:n,sessionId:s}){const[o,a]=c.useState(!1),i=c.useId(),l=ut(),u=da(e);if(!u)return null;const d=e.status==="pending"||e.status==="running",f=Km(u,t),h=(f==null?void 0:f.to.chatId)??u.chatId??(u.tool==="chat_stop"?u.to:void 0),m=(f==null?void 0:f.to)??Vm(h,t),g=(m==null?void 0:m.agentName)??"the agent",x=m==null?void 0:m.chatTitle,C=Et({id:(m==null?void 0:m.agentId)??u.to??h??"chat"}),b=u.tool==="chat_stop"?ap(u,d):Ym(f,{...u,pending:d}),y=Qm((f==null?void 0:f.summary)??u.summary,(f==null?void 0:f.text)??u.message),k=n?Ln(n):f?Ln(f.sentAt):"",v=u.error??((f==null?void 0:f.status)==="failed"?f.failureReason:void 0),p=v?Gm(v):u.tool==="chat_stop"?u.reason:y!==x?y:"",_=u.tool==="session_start"?vd:u.tool==="chat_stop"?io:tl,j=u.tool==="session_start"?"Started spin-off chat":u.tool==="chat_stop"?u.error||u.notRunning?"Tried to stop":"Stopped":"To",D=u.tool==="session_start"?x??(y||"a new chat"):u.tool==="chat_stop"?x??"a chat":(m==null?void 0:m.agentName)??x??"a chat",T=()=>{h&&l(At({session:h,...f?{message:f.id}:{}}))};return r.jsxs("div",{"data-testid":"sent-chat-card","data-tool":u.tool,"data-state":b.label,className:"border-border/70 bg-background my-1.5 rounded-lg border text-sm",children:[r.jsxs("button",{type:"button",onClick:()=>a(w=>!w),"aria-expanded":o,...o?{"aria-controls":i}:{},className:"focus-ring hover:bg-muted/40 flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors duration-150",children:[r.jsx(oo,{size:"xs",emoji:C.emoji,color:C.color}),r.jsx(_,{"aria-hidden":!0,className:"text-muted-foreground hidden size-3.5 shrink-0 sm:block"}),r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r.jsxs("span",{className:"text-muted-foreground",children:[j," "]}),r.jsx("span",{className:"font-medium",children:D}),u.tool==="chat_send"&&x&&(m==null?void 0:m.agentName)&&r.jsxs("span",{className:"text-muted-foreground",children:[" · ",x]}),p&&(u.tool!=="session_start"||v)&&r.jsxs("span",{"data-testid":"sent-chat-aside",className:q("text-muted-foreground",!v&&"hidden sm:inline"),children:[" ","· ",p]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("span",{className:q("text-xs",sp[b.tone]),"data-testid":"sent-chat-state",children:b.label}),k&&r.jsx("time",{className:"text-muted-foreground hidden text-xs tabular-nums sm:inline",children:k}),r.jsx(Dt,{"aria-hidden":!0,className:q("text-muted-foreground size-3.5 transition-transform duration-200",o&&"rotate-180")})]})]}),o&&r.jsxs("div",{id:i,className:"border-border/60 space-y-2 border-t px-3 py-2",children:[((f==null?void 0:f.text)??u.message??u.reason)&&r.jsx("div",{className:"msg-prose",children:r.jsx(ps,{content:(f==null?void 0:f.text)??u.message??u.reason??"",isStreaming:!1,...s?{sessionId:s}:{}})}),r.jsxs("p",{className:"text-muted-foreground text-xs",children:[op(u,f,g),u.note&&u.tool!=="chat_stop"&&f?` ${u.note}`:""]}),h&&!u.error&&!u.waiting&&r.jsx("button",{type:"button",onClick:T,className:"focus-ring text-foreground text-xs font-medium underline-offset-4 hover:underline",children:"Open chat →"})]})]})}function lp({notice:e}){const t=ut();return r.jsxs("div",{"data-testid":"chat-stop-line",className:"text-muted-foreground flex flex-wrap items-center gap-1.5 text-xs",children:[r.jsx(io,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),r.jsxs("span",{children:["Stopped by ",r.jsx("span",{className:"text-foreground/80 font-medium",children:e.by.agentName})," · ",r.jsx("button",{type:"button",onClick:()=>void t(At({session:e.by.chatId})),className:"focus-ring hover:text-foreground underline-offset-4 hover:underline",children:e.by.chatTitle??"another chat"}),e.reason?`: ${e.reason}`:""]})]})}const cp={sent:[],stops:[]},up=new ol;function pa(e){const t=nl(),n=c.useContext(sl),s=rl(e??""),{data:o}=Qe({queryKey:["chat-activity",e,s],queryFn:()=>t.getChatActivity(e),enabled:!!e&&t!==null&&n!==void 0,placeholderData:(a,i)=>(i==null?void 0:i.queryKey[1])===e?a:void 0,staleTime:3e4},n??up);return o??cp}function hs(e){const t=[],n=[];for(const s of e)s.type==="text"?t.push(s.text):s.type==="tool_call"&&n.push({toolCallId:s.toolCallId,toolName:s.toolName,input:s.input||"",result:s.result,progressOutput:s.progressOutput,status:s.status,interactiveType:s.interactiveType,questions:s.questions,answers:s.answers,timeoutMs:s.timeoutMs,hooks:s.hooks,startedAt:s.startedAt,completedAt:s.completedAt,approvalStartedAt:s.approvalStartedAt,approvalRemainingMs:s.approvalRemainingMs,approvalParked:s.approvalParked,approvalTitle:s.approvalTitle,approvalDisplayName:s.approvalDisplayName,approvalDescription:s.approvalDescription,approvalBlockedPath:s.approvalBlockedPath,approvalDecisionReason:s.approvalDecisionReason,approvalHasSuggestions:s.approvalHasSuggestions,approvalAlwaysAllowScope:s.approvalAlwaysAllowScope});return{content:t.join(`
36
+ `),toolCalls:n}}const sr=new WeakMap;function dp(e){let t=sr.get(e);return t||(t=e.map(ot),sr.set(e,t)),t}function ot(e){const t=e.parts?[...e.parts]:[];if(t.length===0&&(e.content&&t.push({type:"text",text:e.content}),e.toolCalls))for(const s of e.toolCalls)t.push({type:"tool_call",toolCallId:s.toolCallId,toolName:s.toolName,input:s.input,result:s.result,status:s.status,...s.questions||s.questionOutcome?{interactiveType:"question",questions:s.questions,answers:s.answers,questionOutcome:s.questionOutcome}:{},...s.approvalOutcome?{interactiveType:"approval",approvalOutcome:s.approvalOutcome,approvalResolvedAt:s.approvalResolvedAt,approvalStartedAt:s.approvalStartedAt,approvalReasonGiven:s.approvalReasonGiven}:{}});const n=hs(t);return{id:e.id,role:e.role,content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:void 0,parts:t,timestamp:e.timestamp||"",messageType:e.messageType,compactMetadata:e.compactMetadata,commandName:e.commandName,commandArgs:e.commandArgs,...e.chatMessages&&e.chatMessages.length>0?{chatMessages:e.chatMessages}:{},...e.roomMessage?{roomMessage:e.roomMessage}:{}}}function fp(e,t,n){const s=new Set(e.map(d=>d.id)),o=e.filter(d=>d._streaming),a=o.find(d=>d.role==="user"),i=o.find(d=>d.role==="assistant"),l=[];let u=-1;for(let d=0;d<t.length;d++){const f=t[d];if(!s.has(f.id)){if(a&&f.role==="user"&&f.content===a.content){u=d,n(h=>h.map(m=>m.id===a.id?{...ot(f),_streaming:!1}:m));continue}if(i&&u>=0&&d===u+1&&f.role==="assistant"){const h=ot(f),m=new Set(h.parts.filter(C=>C.type==="background_task").map(C=>C.taskId)),g=i.parts.filter(C=>C.type==="background_task"&&!m.has(C.taskId)),x=g.length>0?[...h.parts,...g]:h.parts;n(C=>C.map(b=>b.id===i.id?{...h,parts:x,_streaming:!1}:b));continue}l.push(f)}}l.length>0&&n(d=>[...d,...l.map(ot)])}const mp=20;function pp(e,t){var y;const n=Ce(),s=al(e),o=Pe(k=>k.seeks[e]),[a,i]=c.useState(null),l=c.useRef(null),u=a===e,d=c.useRef({key:"",count:0}),f=s.windowStartId!==null&&((y=t[0])==null?void 0:y.id)===s.windowStartId,h=c.useMemo(()=>f?s.earlier.map(ot):[],[f,s.earlier]),m=c.useMemo(()=>h.length>0?[...h,...t]:t,[h,t]),g=f&&s.remaining>0,x=f?s.remaining:0,C=c.useCallback(()=>{var p;if(l.current===e||!g)return;const{generation:k}=s,v=((p=s.earlier[0])==null?void 0:p.id)??s.windowStartId;v&&(l.current=e,i(e),n.getMessages(e,void 0,{before:v}).then(_=>{Pe.getState().prependPage(e,k,_.messages,_.earlierMessages??0)}).catch(_=>{console.warn("[chat] could not read earlier messages",_),Pe.getState().endSeek(e)}).finally(()=>{l.current===e&&(l.current=null,i(null))}))},[g,e,n,s]),b=o!==void 0&&(m.some(k=>k.id===o)||fa([...s.earlier,...je.getState().getSession(e).messages],o)!==void 0);return c.useEffect(()=>{if(o===void 0){d.current={key:"",count:0};return}const k=`${e}:${o}`;if(d.current.key!==k&&(d.current={key:k,count:0}),!(s.generation===0||u)){if(b||!g||d.current.count>=mp){Pe.getState().endSeek(e);return}d.current.count+=1,C()}},[o,b,g,u,C,e,s.generation]),{messages:m,earlierCount:h.length,messagesBefore:x,canLoadEarlier:g,isLoadingEarlier:u,isSeeking:o!==void 0,loadEarlier:C}}function hp({celebration:e,onComplete:t}){const n=c.useRef(null),s=(e==null?void 0:e.level)==="major",o=c.useCallback(()=>{t()},[t]);return c.useEffect(()=>{if(!s)return;let a=!1;il({kind:"burst"}).then(l=>{if(a){l();return}n.current=l});const i=setTimeout(()=>{o()},en.CELEBRATION_DISPLAY_MS);return()=>{var l;a=!0,(l=n.current)==null||l.call(n),n.current=null,clearTimeout(i)}},[s,o]),r.jsx(ce,{children:s&&r.jsx(W.div,{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-50",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.1},transition:{duration:.6,ease:"easeOut"},style:Ed})})}const gs=c.createContext(null);function gp({children:e,value:t}){const n=c.useMemo(()=>t,[t.sessionId,t.isStreaming,t.isLatestWidgetMessage,t.isFinalMessage,t.activeToolCallId,t.onToolRef,t.focusedOptionIndex,t.onToolDecided,t.onRetry,t.onSigninComplete,t.onChooseModel,t.inputZoneToolCallId,t.textEffect,t.runtimeLabel,t.allowsDenyReason]);return r.jsx(gs,{value:n,children:e})}function xp(){const e=c.useContext(gs);if(!e)throw new Error("useMessageContext must be used within MessageProvider");return e}function bp(){return c.useContext(gs)}function yp(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function vp({text:e,isStreaming:t,elapsedMs:n}){const[s,o]=c.useState(t),a=c.useRef(t),i=c.useRef(null);c.useEffect(()=>{a.current&&!t&&o(!1),a.current=t},[t]),c.useEffect(()=>{t&&s&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t,s]);const l=n?`Thought for ${yp(n)}`:"Thinking…";return r.jsx(Ft,{expanded:s,onToggle:()=>o(!s),variant:"thinking",dimmed:!t,disabled:t,ariaLabel:l,"data-testid":"thinking-block","data-streaming":t?"true":void 0,header:r.jsxs(r.Fragment,{children:[r.jsx(gd,{className:q("text-muted-foreground size-(--size-icon-xs)",t&&"animate-breath")}),r.jsx("span",{className:q("text-3xs text-muted-foreground font-mono",t&&"animate-breath"),children:l})]}),children:r.jsx("div",{ref:i,className:"max-h-32 overflow-y-auto",children:r.jsx("pre",{className:"text-muted-foreground text-xs break-words whitespace-pre-wrap",children:e})})})}function kp({mode:e,memories:t,isStreaming:n}){const[s,o]=c.useState(n),a=c.useRef(n);if(c.useEffect(()=>{a.current&&!n&&o(!1),a.current=n},[n]),t.length===0)return null;const i=t.length,l=n?i<=1?"Consulting memory…":`Consulting ${i} memories…`:i===1?"Recalled 1 memory":`Recalled ${i} memories`,u=e==="synthesize"?ll:cl,d=e==="synthesize"?"sparkles":"bookopen";return r.jsx(Ft,{expanded:s,onToggle:()=>o(!s),variant:"memory",dimmed:!n,disabled:n,ariaLabel:l,"data-testid":"memory-recall-block","data-streaming":n?"true":void 0,header:r.jsxs(r.Fragment,{children:[r.jsx(u,{"aria-hidden":"true","data-testid":"memory-recall-header-icon","data-icon":d,className:q("text-muted-foreground size-(--size-icon-xs)",n&&"animate-breath")}),r.jsx("span",{className:q("text-3xs text-muted-foreground font-mono",n&&"animate-breath"),children:l})]}),children:r.jsx(Cp,{memories:t})})}function Cp({memories:e}){return r.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>r.jsx(Sp,{memory:t},t.path))})}function Sp({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?ul:dl,s=e.scope==="team"?"team":"personal",{copy:o}=fl({toastOnSettle:!0}),a=()=>{const i=t&&e.content?e.content:e.path;o(i)};if(t&&e.content){const i=e.path.replace(/^<synthesis:/,"synthesis:").replace(/>$/,"");return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:a,"aria-label":`Copy synthesized ${s} memory content`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full flex-col items-start gap-1 rounded-md px-2 py-1 text-left transition-colors duration-150",children:[r.jsx("span",{className:"text-sm",children:e.content}),r.jsxs("span",{className:"text-3xs text-muted-foreground flex items-center gap-1 font-mono",children:[r.jsx(n,{"aria-hidden":"true",className:"size-(--size-icon-xs)"}),i]})]})})}return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:a,"aria-label":`Copy ${s} memory path ${e.path}`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full items-center gap-2 rounded-md px-2 py-1 text-left transition-colors duration-150",children:[r.jsx("span",{className:"flex-1 truncate font-mono text-sm",children:Fd(e.path,40)}),r.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function Vt(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ha(e){return e===void 0?"Summarized (asked by the agent)":`Summarized at ${e}% (asked by the agent)`}function _p(e){if((e==null?void 0:e.requestedBy)==="agent")return ha(e.contextPercent);const t=["Context compacted"];return(e==null?void 0:e.preTokens)!==void 0&&t.push(`${Vt(e.preTokens)} tokens`),e!=null&&e.trigger&&t.push(e.trigger),t.join(" · ")}function jp(e,t){return e===void 0?"Compacted context":t===void 0?`Compacted context · ${Vt(e)} tokens summarized`:`Compacted context · ${Vt(e)} → ${Vt(t)} tokens`}function wp({trigger:e,preTokens:t,postTokens:n,failed:s,error:o,requestedBy:a,contextPercent:i}){return s?r.jsx(st,{"data-testid":"compact-boundary-row","data-failed":"true",icon:r.jsx(cs,{"aria-hidden":"true",className:"text-status-warning-dot size-3 shrink-0"}),label:r.jsx("span",{className:"text-status-warning-fg",children:a==="agent"?"Couldn’t compact (asked by the agent)":"Couldn’t compact"}),children:o?r.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:o}):null}):a==="agent"?r.jsx(st,{"data-testid":"compact-boundary-row","data-requested-by":"agent",icon:r.jsx(Os,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:ha(i)})}):r.jsx(st,{"data-testid":"compact-boundary-row",icon:r.jsx(Os,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:jp(t,n)}),trailing:e?r.jsx("span",{"data-testid":"compact-boundary-trigger",className:"text-3xs text-muted-foreground/70 ml-auto font-mono uppercase",children:e}):void 0})}function Np({part:e}){const[t,n]=c.useState(!1);return t?r.jsxs("div",{"data-testid":"message-image-missing",className:q("my-3 flex items-center gap-2 rounded-md border px-3 py-2","text-muted-foreground border-border/60 bg-muted/30 text-sm"),children:[r.jsx(Yu,{"aria-hidden":"true",className:"size-4 shrink-0"}),r.jsx("span",{children:e.alt?`${e.alt}, not available`:"This image is not available."})]}):r.jsx("figure",{className:"my-3","data-testid":"message-image",children:r.jsx(lo,{image:{src:e.url,alt:e.alt??"Image produced by the agent"},className:"block",children:r.jsx("img",{src:e.url,alt:e.alt??"Image produced by the agent",loading:"lazy",decoding:"async",onError:()=>n(!0),className:"border-border/60 bg-muted/20 max-h-[32rem] max-w-full rounded-md border object-contain"})})})}function Ep({content:e}){return r.jsx(st,{"data-testid":"staged-context-note",icon:r.jsx(co,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:"Added context for the next reply"}),children:r.jsx("p",{className:"text-muted-foreground/80 mt-1 text-xs whitespace-pre-wrap",children:e})})}function Dp(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Tp(e){return e==="untracked"?"neutral":e==="stopped"?"complete":e}function Ap(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(Dp(e.durationMs)),t.length>0?t.join(" · "):null}function Fp({part:e}){const[t,n]=c.useState(!1),s=c.useRef(null),o=Ap(e),a=e.subagentText,i=e.status==="untracked",l=!!(o||e.summary||e.lastToolName||a||i);return c.useEffect(()=>{const u=s.current;u&&(u.scrollTop=u.scrollHeight)},[a]),r.jsx(Ft,{expanded:t,onToggle:()=>l&&n(!t),hideChevron:!l,ariaLabel:`Background task: ${e.description}`,"data-testid":"subagent-block","data-task-id":e.taskId,"data-status":e.status,header:r.jsxs(r.Fragment,{children:[la(Tp(e.status)),r.jsx("span",{className:"text-3xs truncate font-mono",children:e.description}),o&&r.jsx("span",{className:"text-3xs text-muted-foreground ml-1 shrink-0",children:o})]}),children:r.jsxs("div",{className:"space-y-1.5",children:[a&&r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-3xs text-muted-foreground/70 tracking-wide uppercase",children:"Helper output"}),r.jsx("pre",{ref:s,className:"text-foreground/90 bg-muted/50 max-h-64 overflow-y-auto rounded-md p-2 text-xs break-words whitespace-pre-wrap","data-testid":"subagent-text",children:a})]}),e.lastToolName&&e.status==="running"&&r.jsxs("p",{className:"text-3xs text-muted-foreground",children:["Last tool: ",r.jsx("span",{className:"font-mono",children:e.lastToolName})]}),e.summary&&r.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:e.summary}),i&&r.jsx("p",{className:"text-3xs text-muted-foreground","data-testid":"subagent-untracked",children:"No longer tracked. It may still be running."})]})})}const Rp=e=>typeof e=="boolean"||e instanceof Boolean,Mp=e=>typeof e=="number"||e instanceof Number,Op=e=>typeof e=="bigint"||e instanceof BigInt,ga=e=>!!e&&e instanceof Date,Ip=e=>typeof e=="string"||e instanceof String,$p=e=>Array.isArray(e),xa=e=>typeof e=="object"&&e!==null,ba=e=>!!e&&e instanceof Object&&typeof e=="function";function Yt(e,t){return t===void 0&&(t=!1),!e||t?`"${e}"`:e}function Pp(e,t,n){return n?JSON.stringify(e):t?`"${e}"`:e}function ya(e){let{field:t,value:n,data:s,lastElement:o,openBracket:a,closeBracket:i,level:l,style:u,shouldExpandNode:d,clickToExpandNode:f,outerRef:h,beforeExpandChange:m}=e;const g=c.useRef(!1),[x,C]=c.useState(()=>d(l,n,t)),b=c.useRef(null);c.useEffect(()=>{g.current?C(d(l,n,t)):g.current=!0},[d]);const y=c.useId();if(s.length===0)return Lp({field:t,openBracket:a,closeBracket:i,lastElement:o,style:u});const k=x?u.collapseIcon:u.expandIcon,v=x?u.ariaLables.collapseJson:u.ariaLables.expandJson,p=l+1,_=s.length-1,j=w=>{x!==w&&(!m||m({level:l,value:n,field:t,newExpandValue:w}))&&C(w)},D=w=>{if(w.key==="ArrowRight"||w.key==="ArrowLeft")w.preventDefault(),j(w.key==="ArrowRight");else if(w.key==="ArrowUp"||w.key==="ArrowDown"){w.preventDefault();const A=w.key==="ArrowUp"?-1:1;if(!h.current)return;const S=h.current.querySelectorAll("[role=button]");let E=-1;for(let R=0;R<S.length;R++)if(S[R].tabIndex===0){E=R;break}if(E<0)return;const N=(E+A+S.length)%S.length;S[E].tabIndex=-1,S[N].tabIndex=0,S[N].focus()}},T=()=>{var w;j(!x);const A=b.current;if(!A)return;const S=(w=h.current)===null||w===void 0?void 0:w.querySelector('[role=button][tabindex="0"]');S&&(S.tabIndex=-1),A.tabIndex=0,A.focus()};return c.createElement("div",{className:u.basicChildStyle,role:"treeitem","aria-expanded":x,"aria-selected":void 0},c.createElement("span",{className:k,onClick:T,onKeyDown:D,role:"button","aria-label":v,"aria-expanded":x,"aria-controls":x?y:void 0,ref:b,tabIndex:l===0?0:-1}),(t||t==="")&&(f?c.createElement("span",{className:u.clickableLabel,onClick:T,onKeyDown:D},Yt(t,u.quotesForFieldNames),":"):c.createElement("span",{className:u.label},Yt(t,u.quotesForFieldNames),":")),c.createElement("span",{className:u.punctuation},a),x?c.createElement("ul",{id:y,role:"group",className:u.childFieldsContainer},s.map((w,A)=>c.createElement(Hn,{key:w[0]||A,field:w[0],value:w[1],style:u,lastElement:A===_,level:p,shouldExpandNode:d,clickToExpandNode:f,beforeExpandChange:m,outerRef:h}))):c.createElement("span",{className:u.collapsedContent,onClick:T,onKeyDown:D}),c.createElement("span",{className:u.punctuation},i),!o&&c.createElement("span",{className:u.punctuation},","))}function Lp(e){let{field:t,openBracket:n,closeBracket:s,lastElement:o,style:a}=e;return c.createElement("div",{className:a.basicChildStyle,role:"treeitem","aria-selected":void 0},(t||t==="")&&c.createElement("span",{className:a.label},Yt(t,a.quotesForFieldNames),":"),c.createElement("span",{className:a.punctuation},n),c.createElement("span",{className:a.punctuation},s),!o&&c.createElement("span",{className:a.punctuation},","))}function Bp(e){let{field:t,value:n,style:s,lastElement:o,shouldExpandNode:a,clickToExpandNode:i,level:l,outerRef:u,beforeExpandChange:d}=e;return ya({field:t,value:n,lastElement:o||!1,level:l,openBracket:"{",closeBracket:"}",style:s,shouldExpandNode:a,clickToExpandNode:i,data:Object.keys(n).map(f=>[f,n[f]]),outerRef:u,beforeExpandChange:d})}function zp(e){let{field:t,value:n,style:s,lastElement:o,level:a,shouldExpandNode:i,clickToExpandNode:l,outerRef:u,beforeExpandChange:d}=e;return ya({field:t,value:n,lastElement:o||!1,level:a,openBracket:"[",closeBracket:"]",style:s,shouldExpandNode:i,clickToExpandNode:l,data:n.map(f=>[void 0,f]),outerRef:u,beforeExpandChange:d})}function qp(e){let{field:t,value:n,style:s,lastElement:o}=e,a,i=s.otherValue;return n===null?(a="null",i=s.nullValue):n===void 0?(a="undefined",i=s.undefinedValue):Ip(n)?(a=Pp(n,!s.noQuotesForStringValues,s.stringifyStringValues),i=s.stringValue):Rp(n)?(a=n?"true":"false",i=s.booleanValue):Mp(n)?(a=n.toString(),i=s.numberValue):Op(n)?(a=`${n.toString()}n`,i=s.numberValue):ga(n)?a=n.toISOString():ba(n)?a="function() { }":a=n.toString(),c.createElement("div",{className:s.basicChildStyle,role:"treeitem","aria-selected":void 0},(t||t==="")&&c.createElement("span",{className:s.label},Yt(t,s.quotesForFieldNames),":"),c.createElement("span",{className:i},a),!o&&c.createElement("span",{className:s.punctuation},","))}function Hn(e){const t=e.value;return $p(t)?c.createElement(zp,Object.assign({},e)):xa(t)&&!ga(t)&&!ba(t)?c.createElement(Bp,Object.assign({},e)):c.createElement(qp,Object.assign({},e))}var te={"container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","child-fields-container":"_1BXBN","label-light":"_1MGIk","clickable-label-light":"_2YKJg _1MGIk _1MFti","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","clickable-label-dark":"_1RQEj _2bSDX _1MFti","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const va={collapseJson:"collapse JSON",expandJson:"expand JSON"},_n={container:te["container-light"],basicChildStyle:te["basic-element-style"],childFieldsContainer:te["child-fields-container"],label:te["label-light"],clickableLabel:te["clickable-label-light"],nullValue:te["value-null-light"],undefinedValue:te["value-undefined-light"],stringValue:te["value-string-light"],booleanValue:te["value-boolean-light"],numberValue:te["value-number-light"],otherValue:te["value-other-light"],punctuation:te["punctuation-light"],collapseIcon:te["collapse-icon-light"],expandIcon:te["expand-icon-light"],collapsedContent:te["collapsed-content-light"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:va,stringifyStringValues:!1},Up={container:te["container-dark"],basicChildStyle:te["basic-element-style"],childFieldsContainer:te["child-fields-container"],label:te["label-dark"],clickableLabel:te["clickable-label-dark"],nullValue:te["value-null-dark"],undefinedValue:te["value-undefined-dark"],stringValue:te["value-string-dark"],booleanValue:te["value-boolean-dark"],numberValue:te["value-number-dark"],otherValue:te["value-other-dark"],punctuation:te["punctuation-dark"],collapseIcon:te["collapse-icon-dark"],expandIcon:te["expand-icon-dark"],collapsedContent:te["collapsed-content-dark"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:va,stringifyStringValues:!1},Hp=()=>!0,Wp=e=>e<1,Gp=e=>{let{data:t,style:n=_n,shouldExpandNode:s=Hp,clickToExpandNode:o=!1,beforeExpandChange:a,compactTopLevel:i,...l}=e;const u=c.useRef(null);return c.createElement("div",Object.assign({"aria-label":"JSON view"},l,{className:n.container,ref:u,role:"tree"}),i&&xa(t)?Object.entries(t).map(d=>{let[f,h]=d;return c.createElement(Hn,{key:f,field:f,value:h,style:{..._n,...n},lastElement:!0,level:1,shouldExpandNode:s,clickToExpandNode:o,beforeExpandChange:a,outerRef:u})}):c.createElement(Hn,{value:t,style:{..._n,...n},lastElement:!0,level:0,shouldExpandNode:s,clickToExpandNode:o,outerRef:u,beforeExpandChange:a}))};var Ne={},jn,rr;function Vp(){if(rr)return jn;rr=1;const e=[[{color:"0, 0, 0",class:"ansi-black"},{color:"187, 0, 0",class:"ansi-red"},{color:"0, 187, 0",class:"ansi-green"},{color:"187, 187, 0",class:"ansi-yellow"},{color:"0, 0, 187",class:"ansi-blue"},{color:"187, 0, 187",class:"ansi-magenta"},{color:"0, 187, 187",class:"ansi-cyan"},{color:"255,255,255",class:"ansi-white"}],[{color:"85, 85, 85",class:"ansi-bright-black"},{color:"255, 85, 85",class:"ansi-bright-red"},{color:"0, 255, 0",class:"ansi-bright-green"},{color:"255, 255, 85",class:"ansi-bright-yellow"},{color:"85, 85, 255",class:"ansi-bright-blue"},{color:"255, 85, 255",class:"ansi-bright-magenta"},{color:"85, 255, 255",class:"ansi-bright-cyan"},{color:"255, 255, 255",class:"ansi-bright-white"}]],t=/(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&amp;|%[A-Fa-f0-9]{2})+)/gm;class n{static escapeForHtml(o){return new n().escapeForHtml(o)}static linkify(o){return new n().linkify(o)}static ansiToHtml(o,a){return new n().ansiToHtml(o,a)}static ansiToJson(o,a){return new n().ansiToJson(o,a)}static ansiToText(o){return new n().ansiToText(o)}constructor(){this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null,this.bright=0,this.decorations=[]}setupPalette(){this.PALETTE_COLORS=[];for(let l=0;l<2;++l)for(let u=0;u<8;++u)this.PALETTE_COLORS.push(e[l][u].color);let o=[0,95,135,175,215,255],a=(l,u,d)=>o[l]+", "+o[u]+", "+o[d];for(let l=0;l<6;++l)for(let u=0;u<6;++u)for(let d=0;d<6;++d)this.PALETTE_COLORS.push(a(l,u,d));let i=8;for(let l=0;l<24;++l,i+=10)this.PALETTE_COLORS.push(i+", "+i+", "+i)}escapeForHtml(o){return o.replace(/[&<>\"]/gm,a=>a=="&"?"&amp;":a=='"'?"&quot;":a=="<"?"&lt;":a==">"?"&gt;":"")}linkify(o){return o.replace(t,a=>`<a href="${a}">${a}</a>`)}ansiToHtml(o,a){return this.process(o,a,!0)}ansiToJson(o,a){return a=a||{},a.json=!0,a.clearLine=!1,this.process(o,a,!0)}ansiToText(o){return this.process(o,{},!1)}process(o,a,i){let l=this,u=o.split(/\033\[/),d=u.shift();a==null&&(a={}),a.clearLine=/\r/.test(o);let f=u.map(h=>this.processChunk(h,a,i));if(a&&a.json){let h=l.processChunkJson("");return h.content=d,h.clearLine=a.clearLine,f.unshift(h),a.remove_empty&&(f=f.filter(m=>!m.isEmpty())),f}else f.unshift(d);return f.join("")}processChunkJson(o,a,i){a=typeof a>"u"?{}:a;let l=a.use_classes=typeof a.use_classes<"u"&&a.use_classes,u=a.key=l?"class":"color",d={content:o,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,isInverted:!1,clearLine:a.clearLine,decoration:null,decorations:[],was_processed:!1,isEmpty:()=>!d.content},f=o.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!f)return d;d.content=f[4];let h=f[2].split(";");if(f[1]!==""||f[3]!=="m"||!i)return d;let m=this;for(;h.length>0;){let g=h.shift(),x=parseInt(g);if(isNaN(x)||x===0)m.fg=m.bg=null,m.decorations=[];else if(x===1)m.decorations.push("bold");else if(x===2)m.decorations.push("dim");else if(x===3)m.decorations.push("italic");else if(x===4)m.decorations.push("underline");else if(x===5)m.decorations.push("blink");else if(x===7)m.decorations.push("reverse");else if(x===8)m.decorations.push("hidden");else if(x===9)m.decorations.push("strikethrough");else if(x===21)m.removeDecoration("bold");else if(x===22)m.removeDecoration("bold"),m.removeDecoration("dim");else if(x===23)m.removeDecoration("italic");else if(x===24)m.removeDecoration("underline");else if(x===25)m.removeDecoration("blink");else if(x===27)m.removeDecoration("reverse");else if(x===28)m.removeDecoration("hidden");else if(x===29)m.removeDecoration("strikethrough");else if(x===39)m.fg=null;else if(x===49)m.bg=null;else if(x>=30&&x<38)m.fg=e[0][x%10][u];else if(x>=90&&x<98)m.fg=e[1][x%10][u];else if(x>=40&&x<48)m.bg=e[0][x%10][u];else if(x>=100&&x<108)m.bg=e[1][x%10][u];else if(x===38||x===48){let C=x===38;if(h.length>=1){let b=h.shift();if(b==="5"&&h.length>=1){let y=parseInt(h.shift());if(y>=0&&y<=255)if(!l)this.PALETTE_COLORS||m.setupPalette(),C?m.fg=this.PALETTE_COLORS[y]:m.bg=this.PALETTE_COLORS[y];else{let k=y>=16?"ansi-palette-"+y:e[y>7?1:0][y%8].class;C?m.fg=k:m.bg=k}}else if(b==="2"&&h.length>=3){let y=parseInt(h.shift()),k=parseInt(h.shift()),v=parseInt(h.shift());if(y>=0&&y<=255&&k>=0&&k<=255&&v>=0&&v<=255){let p=y+", "+k+", "+v;l?C?(m.fg="ansi-truecolor",m.fg_truecolor=p):(m.bg="ansi-truecolor",m.bg_truecolor=p):C?m.fg=p:m.bg=p}}}}}return m.fg===null&&m.bg===null&&m.decorations.length===0||(d.fg=m.fg,d.bg=m.bg,d.fg_truecolor=m.fg_truecolor,d.bg_truecolor=m.bg_truecolor,d.decorations=m.decorations,d.decoration=m.decorations.slice(-1).pop()||null,d.was_processed=!0),d}processChunk(o,a,i){a=a||{};let l=this.processChunkJson(o,a,i),u=a.use_classes;if(l.decorations=l.decorations.filter(x=>{if(x==="reverse"){l.fg||(l.fg=e[0][7][u?"class":"color"]),l.bg||(l.bg=e[0][0][u?"class":"color"]);let C=l.fg;l.fg=l.bg,l.bg=C;let b=l.fg_truecolor;return l.fg_truecolor=l.bg_truecolor,l.bg_truecolor=b,l.isInverted=!0,!1}return!0}),a.json)return l;if(l.isEmpty())return"";if(!l.was_processed)return l.content;let d=[],f=[],h=[],m={},g=x=>{let C=[],b;for(b in x)x.hasOwnProperty(b)&&C.push("data-"+b+'="'+this.escapeForHtml(x[b])+'"');return C.length>0?" "+C.join(" "):""};return l.isInverted&&(m["ansi-is-inverted"]="true"),l.fg&&(u?(d.push(l.fg+"-fg"),l.fg_truecolor!==null&&(m["ansi-truecolor-fg"]=l.fg_truecolor,l.fg_truecolor=null)):d.push("color:rgb("+l.fg+")")),l.bg&&(u?(d.push(l.bg+"-bg"),l.bg_truecolor!==null&&(m["ansi-truecolor-bg"]=l.bg_truecolor,l.bg_truecolor=null)):d.push("background-color:rgb("+l.bg+")")),l.decorations.forEach(x=>{if(u){f.push("ansi-"+x);return}x==="bold"?f.push("font-weight:bold"):x==="dim"?f.push("opacity:0.5"):x==="italic"?f.push("font-style:italic"):x==="hidden"?f.push("visibility:hidden"):x==="strikethrough"?h.push("line-through"):h.push(x)}),h.length&&f.push("text-decoration:"+h.join(" ")),u?'<span class="'+d.concat(f).join(" ")+'"'+g(m)+">"+l.content+"</span>":'<span style="'+d.concat(f).join(";")+'"'+g(m)+">"+l.content+"</span>"}removeDecoration(o){const a=this.decorations.indexOf(o);a>=0&&this.decorations.splice(a,1)}}return jn=n,jn}var ht={exports:{}},or;function Kp(){if(or)return ht.exports;or=1;function e(o){if(!o)return"";if(!/\r/.test(o))return o;for(o=o.replace(/\r+\n/gm,`
37
+ `);/\r./.test(o);)o=o.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm,function(a,i,l){return l+i.slice(l.length)});return o}function t(o){for(var a=0,i=0;i<o.length;i++)o[a].length<=o[i].length&&(a=i);return a}function n(o){if(!/\r/.test(o))return o;for(var a=o.split("\r"),i=[];a.length>0;){var l=t(a);i.push(a[l]),a=a.slice(l+1)}return i.join("\r")}function s(o){if(!o)return"";if(!/\r/.test(o))return o;if(!/\n/.test(o))return n(o);o=o.replace(/\r+\n/gm,`
38
+ `);var a=o.lastIndexOf(`
39
+ `);return e(o.slice(0,a))+`
40
+ `+n(o.slice(a+1))}return ht.exports=e,ht.exports.escapeCarriageReturn=e,ht.exports.escapeCarriageReturnSafe=s,ht.exports}var qe={},ar;function Qp(){if(ar)return qe;ar=1;var e=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,t=/[\0-\x1F\x7F-\x9F]/,n=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,s=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,o=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,a=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;return qe.Any=e,qe.Cc=t,qe.Cf=n,qe.P=s,qe.S=o,qe.Z=a,qe}var wn,ir;function Yp(){if(ir)return wn;ir=1;var e=Qp();function t(v){const p={};v=v||{},p.src_Any=e.Any.source,p.src_Cc=e.Cc.source,p.src_Z=e.Z.source,p.src_P=e.P.source,p.src_ZPCc=[p.src_Z,p.src_P,p.src_Cc].join("|"),p.src_ZCc=[p.src_Z,p.src_Cc].join("|");const _="[><|]";return p.src_pseudo_letter=`(?:(?!${_}|${p.src_ZPCc})${p.src_Any})`,p.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",p.src_auth=`(?:(?:(?!${p.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`,p.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",p.src_host_terminator=`(?=$|${_}|${p.src_ZPCc})(?!${v["---"]?"-(?!--)|":"-|"}_|:\\d|\\.-|\\.(?!$|${p.src_ZPCc}))`,p.src_path=`(?:[/?#](?:(?!${p.src_ZCc}|${_}|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!${p.src_ZCc}|\\]).)*\\]|\\((?:(?!${p.src_ZCc}|[)]).)*\\)|\\{(?:(?!${p.src_ZCc}|[}]).)*\\}|\\"(?:(?!${p.src_ZCc}|["]).)+\\"|\\'(?:(?!${p.src_ZCc}|[']).)+\\'|\\'(?=${p.src_pseudo_letter}|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!${p.src_ZCc}|[.]|$)|`+(v["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+`,(?!${p.src_ZCc}|$)|;(?!${p.src_ZCc}|$)|\\!+(?!${p.src_ZCc}|[!]|$)|\\?(?!${p.src_ZCc}|[?]|$))+|\\/)?`,p.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}',p.src_xn="xn--[a-z0-9\\-]{1,59}",p.src_domain_root="(?:"+p.src_xn+`|${p.src_pseudo_letter}{1,63})`,p.src_domain="(?:"+p.src_xn+`|(?:${p.src_pseudo_letter})|(?:${p.src_pseudo_letter}(?:-|${p.src_pseudo_letter}){0,61}${p.src_pseudo_letter}))`,p.src_host=`(?:(?:(?:(?:${p.src_domain})\\.)*${p.src_domain}))`,p.tpl_host_fuzzy="(?:"+p.src_ip4+`|(?:(?:(?:${p.src_domain})\\.)+(?:%TLDS%)))`,p.tpl_host_no_ip_fuzzy=`(?:(?:(?:${p.src_domain})\\.)+(?:%TLDS%))`,p.src_host_strict=p.src_host+p.src_host_terminator,p.tpl_host_fuzzy_strict=p.tpl_host_fuzzy+p.src_host_terminator,p.src_host_port_strict=p.src_host+p.src_port+p.src_host_terminator,p.tpl_host_port_fuzzy_strict=p.tpl_host_fuzzy+p.src_port+p.src_host_terminator,p.tpl_host_port_no_ip_fuzzy_strict=p.tpl_host_no_ip_fuzzy+p.src_port+p.src_host_terminator,p.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${p.src_ZPCc}|>|$))`,p.tpl_email_fuzzy=`(^|${_}|"|\\(|${p.src_ZCc})(${p.src_email_name}@${p.tpl_host_fuzzy_strict})`,p.tpl_link_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${p.src_ZPCc}))((?![$+<=>^\`||])${p.tpl_host_port_fuzzy_strict}${p.src_path})`,p.tpl_link_no_ip_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${p.src_ZPCc}))((?![$+<=>^\`||])${p.tpl_host_port_no_ip_fuzzy_strict}${p.src_path})`,p}function n(v){return Array.prototype.slice.call(arguments,1).forEach(function(_){_&&Object.keys(_).forEach(function(j){v[j]=_[j]})}),v}function s(v){return Object.prototype.toString.call(v)}function o(v){return s(v)==="[object String]"}function a(v){return s(v)==="[object Object]"}function i(v){return s(v)==="[object RegExp]"}function l(v){return s(v)==="[object Function]"}function u(v){return v.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const d={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function f(v){return Object.keys(v||{}).reduce(function(p,_){return p||d.hasOwnProperty(_)},!1)}const h={"http:":{validate:function(v,p,_){const j=v.slice(p);return _.re.http||(_.re.http=new RegExp(`^\\/\\/${_.re.src_auth}${_.re.src_host_port_strict}${_.re.src_path}`,"i")),_.re.http.test(j)?j.match(_.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(v,p,_){const j=v.slice(p);return _.re.no_http||(_.re.no_http=new RegExp("^"+_.re.src_auth+`(?:localhost|(?:(?:${_.re.src_domain})\\.)+${_.re.src_domain_root})`+_.re.src_port+_.re.src_host_terminator+_.re.src_path,"i")),_.re.no_http.test(j)?p>=3&&v[p-3]===":"||p>=3&&v[p-3]==="/"?0:j.match(_.re.no_http)[0].length:0}},"mailto:":{validate:function(v,p,_){const j=v.slice(p);return _.re.mailto||(_.re.mailto=new RegExp(`^${_.re.src_email_name}@${_.re.src_host_strict}`,"i")),_.re.mailto.test(j)?j.match(_.re.mailto)[0].length:0}}},m="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",g="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function x(v){return function(p,_){const j=p.slice(_);return v.test(j)?j.match(v)[0].length:0}}function C(){return function(v,p){p.normalize(v)}}function b(v){const p=v.re=t(v.__opts__),_=v.__tlds__.slice();v.onCompile(),v.__tlds_replaced__||_.push(m),_.push(p.src_xn),p.src_tlds=_.join("|");function j(A){return A.replace("%TLDS%",p.src_tlds)}p.email_fuzzy=RegExp(j(p.tpl_email_fuzzy),"i"),p.email_fuzzy_global=RegExp(j(p.tpl_email_fuzzy),"ig"),p.link_fuzzy=RegExp(j(p.tpl_link_fuzzy),"i"),p.link_fuzzy_global=RegExp(j(p.tpl_link_fuzzy),"ig"),p.link_no_ip_fuzzy=RegExp(j(p.tpl_link_no_ip_fuzzy),"i"),p.link_no_ip_fuzzy_global=RegExp(j(p.tpl_link_no_ip_fuzzy),"ig"),p.host_fuzzy_test=RegExp(j(p.tpl_host_fuzzy_test),"i");const D=[];v.__compiled__={};function T(A,S){throw new Error(`(LinkifyIt) Invalid schema "${A}": ${S}`)}Object.keys(v.__schemas__).forEach(function(A){const S=v.__schemas__[A];if(S===null)return;const E={validate:null,link:null};if(v.__compiled__[A]=E,a(S)){i(S.validate)?E.validate=x(S.validate):l(S.validate)?E.validate=S.validate:T(A,S),l(S.normalize)?E.normalize=S.normalize:S.normalize?T(A,S):E.normalize=C();return}if(o(S)){D.push(A);return}T(A,S)}),D.forEach(function(A){v.__compiled__[v.__schemas__[A]]&&(v.__compiled__[A].validate=v.__compiled__[v.__schemas__[A]].validate,v.__compiled__[A].normalize=v.__compiled__[v.__schemas__[A]].normalize)}),v.__compiled__[""]={validate:null,normalize:C()};const w=Object.keys(v.__compiled__).filter(function(A){return A.length>0&&v.__compiled__[A]}).map(u).join("|");v.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|${p.src_ZPCc}))(${w})`,"i"),v.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|${p.src_ZPCc}))(${w})`,"ig"),v.re.schema_at_start=RegExp(`^${v.re.schema_search.source}`,"i"),v.re.pretest=RegExp(`(${v.re.schema_test.source})|(${v.re.host_fuzzy_test.source})|@`,"i")}function y(v,p,_,j){const D=v.slice(_,j);this.schema=p.toLowerCase(),this.index=_,this.lastIndex=j,this.raw=D,this.text=D,this.url=D}function k(v,p){if(!(this instanceof k))return new k(v,p);p||f(v)&&(p=v,v={}),this.__opts__=n({},d,p),this.__schemas__=n({},h,v),this.__compiled__={},this.__tlds__=g,this.__tlds_replaced__=!1,this.re={},b(this)}return k.prototype.add=function(p,_){return this.__schemas__[p]=_,b(this),this},k.prototype.set=function(p){return this.__opts__=n(this.__opts__,p),this},k.prototype.test=function(p){if(!p.length)return!1;let _,j;if(this.re.schema_test.test(p)){for(j=this.re.schema_search,j.lastIndex=0;(_=j.exec(p))!==null;)if(this.testSchemaAt(p,_[2],j.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&p.search(this.re.host_fuzzy_test)>=0&&p.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&p.indexOf("@")>=0&&p.match(this.re.email_fuzzy)!==null)},k.prototype.pretest=function(p){return this.re.pretest.test(p)},k.prototype.testSchemaAt=function(p,_,j){return this.__compiled__[_.toLowerCase()]?this.__compiled__[_.toLowerCase()].validate(p,j,this):0},k.prototype.match=function(p){const _=[],j=[],D=[],T=[];let w,A,S;function E(M,F){return M?F?M.index!==F.index?M.index<F.index?M:F:M.lastIndex>=F.lastIndex?M:F:M:F}if(!p.length)return null;if(this.re.schema_test.test(p))for(S=this.re.schema_search,S.lastIndex=0;(w=S.exec(p))!==null;)A=this.testSchemaAt(p,w[2],S.lastIndex),A&&j.push({schema:w[2],index:w.index+w[1].length,lastIndex:w.index+w[0].length+A});if(this.__opts__.fuzzyLink&&this.__compiled__["http:"])for(S=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,S.lastIndex=0;(w=S.exec(p))!==null;)D.push({schema:"",index:w.index+w[1].length,lastIndex:w.index+w[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"])for(S=this.re.email_fuzzy_global,S.lastIndex=0;(w=S.exec(p))!==null;)T.push({schema:"mailto:",index:w.index+w[1].length,lastIndex:w.index+w[0].length});const N=[0,0,0];let R=0;for(;;){const M=[j[N[0]],T[N[1]],D[N[2]]],F=E(E(M[0],M[1]),M[2]);if(!F)break;if(F===M[0]?N[0]++:F===M[1]?N[1]++:N[2]++,F.index<R)continue;const O=new y(p,F.schema,F.index,F.lastIndex);this.__compiled__[O.schema].normalize(O,this),_.push(O),R=F.lastIndex}return _.length?_:null},k.prototype.matchAtStart=function(p){if(!p.length)return null;const _=this.re.schema_at_start.exec(p);if(!_)return null;const j=this.testSchemaAt(p,_[2],_[0].length);if(!j)return null;const D=new y(p,_[2],_.index+_[1].length,_.index+_[0].length+j);return this.__compiled__[D.schema].normalize(D,this),D},k.prototype.tlds=function(p,_){return p=Array.isArray(p)?p:[p],_?(this.__tlds__=this.__tlds__.concat(p).sort().filter(function(j,D,T){return j!==T[D-1]}).reverse(),b(this),this):(this.__tlds__=p.slice(),this.__tlds_replaced__=!0,b(this),this)},k.prototype.normalize=function(p){p.schema||(p.url=`http://${p.url}`),p.schema==="mailto:"&&!/^mailto:/i.test(p.url)&&(p.url=`mailto:${p.url}`)},k.prototype.onCompile=function(){},wn=k,wn}var lr;function Xp(){if(lr)return Ne;lr=1;var e=Ne&&Ne.__createBinding||(Object.create?(function(b,y,k,v){v===void 0&&(v=k);var p=Object.getOwnPropertyDescriptor(y,k);(!p||("get"in p?!y.__esModule:p.writable||p.configurable))&&(p={enumerable:!0,get:function(){return y[k]}}),Object.defineProperty(b,v,p)}):(function(b,y,k,v){v===void 0&&(v=k),b[v]=y[k]})),t=Ne&&Ne.__setModuleDefault||(Object.create?(function(b,y){Object.defineProperty(b,"default",{enumerable:!0,value:y})}):function(b,y){b.default=y}),n=Ne&&Ne.__importStar||(function(){var b=function(y){return b=Object.getOwnPropertyNames||function(k){var v=[];for(var p in k)Object.prototype.hasOwnProperty.call(k,p)&&(v[v.length]=p);return v},b(y)};return function(y){if(y&&y.__esModule)return y;var k={};if(y!=null)for(var v=b(y),p=0;p<v.length;p++)v[p]!=="default"&&e(k,y,v[p]);return t(k,y),k}})(),s=Ne&&Ne.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.default=x;const o=s(Vp()),a=Kp(),i=s(Yp()),l=n(ml());function u(b,y=!1){return b=(0,a.escapeCarriageReturn)(C(b)),o.default.ansiToJson(b,{json:!0,remove_empty:!0,use_classes:y})}function d(b){let y="";return b.bg&&(y+=`${b.bg}-bg `),b.fg&&(y+=`${b.fg}-fg `),b.decoration&&(y+=`ansi-${b.decoration} `),y===""?null:(y=y.substring(0,y.length-1),y)}function f(b){const y={};switch(b.bg&&(y.backgroundColor=`rgb(${b.bg})`),b.fg&&(y.color=`rgb(${b.fg})`),b.decoration){case"bold":y.fontWeight="bold";break;case"dim":y.opacity="0.5";break;case"italic":y.fontStyle="italic";break;case"hidden":y.visibility="hidden";break;case"strikethrough":y.textDecoration="line-through";break;case"underline":y.textDecoration="underline";break;case"blink":y.textDecoration="blink";break}return y}function h(b,y,k,v){const p=y?null:f(k),_=y?d(k):null;return b?b==="fuzzy"?g(k,v,p,_):m(k,v,p,_):l.createElement("span",{style:p,key:v,className:_},k.content)}function m(b,y,k,v){const p=[],_=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let j=0,D;for(;(D=_.exec(b.content))!==null;){const[,T,w]=D,A=D.index+T.length;A>j&&p.push(b.content.substring(j,A));const S=w.startsWith("www.")?`http://${w}`:w;p.push(l.createElement("a",{key:j,href:S,target:"_blank"},`${w}`)),j=_.lastIndex}return j<b.content.length&&p.push(b.content.substring(j)),l.createElement("span",{style:k,key:y,className:v},p)}function g(b,y,k,v){var p;const _=(0,i.default)({fuzzyEmail:!1}).tlds(["io"],!0);if(!_.pretest(b.content))return l.createElement("span",{style:k,key:y,className:v},b.content);const j=_.match(b.content);if(!j)return l.createElement("span",{style:k,key:y,className:v},b.content);const D=[b.content.substring(0,(p=j[0])===null||p===void 0?void 0:p.index)];return j.forEach((T,w)=>{var A;D.push(l.createElement("a",{href:T.url,target:"_blank",key:w},b.content.substring(T.index,T.lastIndex))),j[w+1]&&D.push(b.content.substring(j[w].lastIndex,(A=j[w+1])===null||A===void 0?void 0:A.index))}),j[j.length-1].lastIndex!==b.content.length&&D.push(b.content.substring(j[j.length-1].lastIndex,b.content.length)),l.createElement("span",{style:k,key:y,className:v},D)}function x(b){const{className:y,useClasses:k,children:v,linkify:p}=b;return l.createElement("code",{className:y},u(v??"",k??!1).map(h.bind(null,p??!1,k??!1)))}function C(b){let y=b;do b=y,y=b.replace(/[^\n]\x08/gm,"");while(y.length<b.length);return b}return Ne}var Jp=Xp();const Zp=pl(Jp),eh=c.lazy(()=>hl(()=>import("./index-CVuEUzi5.js"),__vite__mapDeps([0,1,2,3]))),th={...Up,container:"bg-transparent text-xs font-mono leading-relaxed",label:"text-muted-foreground font-medium mr-1",clickableLabel:"text-muted-foreground font-medium mr-1 cursor-pointer",nullValue:"text-muted-foreground italic",undefinedValue:"text-muted-foreground italic",stringValue:"text-foreground",booleanValue:"text-amber-400",numberValue:"text-blue-400",otherValue:"text-muted-foreground",punctuation:"text-muted-foreground",collapseIcon:'text-muted-foreground mr-1 cursor-pointer text-[1.2em] select-none after:content-["▾"]',expandIcon:'text-muted-foreground mr-1 cursor-pointer text-[1.2em] select-none after:content-["▸"]',collapsedContent:'text-muted-foreground mr-1 cursor-pointer after:text-[0.8em] after:content-["…"]'},cr=5120;function nh(e){try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&("old_string"in t||"new_string"in t)?t:null}catch{return null}}function Nn({children:e,rawContent:t,supportsRawToggle:n,isRaw:s,onToggleRaw:o}){const[a,i]=c.useState(!1),l=t.length>cr,u=l&&!a?t.slice(0,cr):t;return r.jsxs("div",{className:"space-y-1",children:[n&&r.jsx("div",{className:"flex justify-end",children:r.jsx("button",{onClick:o,className:"text-muted-foreground hover:text-foreground text-xs underline",children:s?"Formatted":"Raw"})}),s?r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:u}),l&&!a&&r.jsxs("button",{onClick:()=>i(!0),className:"text-muted-foreground hover:text-foreground text-xs underline",children:["Show full output (",(t.length/1024).toFixed(1),"KB)"]})]}):e]})}function sh({oldValue:e,newValue:t,rawContent:n}){return r.jsx(c.Suspense,{fallback:r.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:n}),children:r.jsx(eh,{oldValue:e,newValue:t,splitView:!1,useDarkTheme:!0,hideLineNumbers:!0,showDiffOnly:!0,extraLinesSurroundingDiff:2,styles:{variables:{dark:{diffViewerBackground:"transparent",addedBackground:"rgba(34, 197, 94, 0.1)",addedColor:"rgb(134, 239, 172)",addedGutterBackground:"rgba(34, 197, 94, 0.08)",wordAddedBackground:"rgba(34, 197, 94, 0.2)",removedBackground:"rgba(239, 68, 68, 0.1)",removedColor:"rgb(252, 165, 165)",removedGutterBackground:"rgba(239, 68, 68, 0.08)",wordRemovedBackground:"rgba(239, 68, 68, 0.2)",gutterBackground:"hsl(0 0% 9%)",gutterBackgroundDark:"hsl(0 0% 7%)",gutterColor:"hsl(0 0% 40%)"}}}})})}function ka({content:e,toolName:t,input:n}){const[s,o]=c.useState(!1);if(t==="Edit"&&n){const i=nh(n);if(i)return r.jsx(sh,{oldValue:i.old_string??"",newValue:i.new_string??"",rawContent:e})}const a=Od(e);if(a==="json"){let i;try{i=JSON.parse(e)}catch{i={}}return r.jsx(Nn,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>o(l=>!l),children:r.jsx(Gp,{data:i,style:th,shouldExpandNode:Wp})})}return a==="ansi"?r.jsx(Nn,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>o(i=>!i),children:r.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:r.jsx(Zp,{children:e})})}):r.jsx(Nn,{rawContent:e,supportsRawToggle:!1,isRaw:!0,onToggleRaw:()=>{},children:null})}function rh(e){try{const t=JSON.parse(e);if(!t||typeof t!="object")return e;const n=t;if(n.error&&typeof n.error=="object"){const s=n.error;if(typeof s.message=="string")return s.message}return typeof n.message=="string"?n.message:e}catch{return e}}function oh(e){const t=rh(e),n=t.match(/The ['"`]([^'"`]+)['"`] model requires a newer version of Codex\b/i);if(n)return{message:`The Codex version DorkOS is using is too old for ${n[1]}. Update DorkOS (or your custom Codex installation), then try again. You can also choose another model.`,category:"runtime_update_required",details:e};const s=t.match(/The ['"`]([^'"`]+)['"`] model is not supported when using Codex with a ChatGPT account\b/i);return s?{message:`${s[1]} isn’t available with a ChatGPT account. Choose another model from the model menu.`,category:"model_unavailable",details:e}:null}const Ca="runtimes";function ah({label:e}){const{open:t}=uo();return r.jsx("button",{type:"button",onClick:()=>t(Ca),className:"text-muted-foreground hover:text-foreground mt-2 block text-xs underline decoration-dotted underline-offset-2 transition-colors",children:e})}function ih({runtime:e,sessionId:t,onRetry:n,onSigninComplete:s}){const[o,a]=c.useState(!1),i=Vu(e,{sessionId:t,onCompleted:()=>a((s==null?void 0:s())??!1)}),l=Ku(e);return i.isSuccess?r.jsxs("div",{className:"mt-3","data-testid":"auth-error-signin-success",children:[r.jsxs("p",{className:"text-status-success-fg flex items-center gap-2 text-sm",role:"status",children:[r.jsx(Jt,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),o?"Signed in. Sending your message again…":"Signed in."]}),!o&&n&&r.jsxs(le,{size:"sm",onClick:n,className:"mt-2 gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]})]}):r.jsxs("div",{className:"mt-3","data-testid":"auth-error-signin",children:[r.jsx("p",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-sm",role:"status",children:i.isPending&&r.jsxs(r.Fragment,{children:[r.jsx(Le,{size:"xs",className:"shrink-0"}),l.signInPending]})}),i.isError&&r.jsx("p",{className:"text-destructive mb-2 text-sm",role:"alert",children:i.errorMessage}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(le,{size:"sm",onClick:i.login,disabled:i.isPending,className:"gap-1.5","data-testid":"auth-error-signin-button",children:[r.jsx(fo,{className:"size-3"}),i.isError?"Try again":l.signInLabel]}),n&&r.jsxs(le,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]})]}),r.jsx(ah,{label:"Use an API key instead"})]})}function ur({onRetry:e}){return r.jsx("div",{className:"mt-3","data-testid":"auth-error-remote-guidance",children:r.jsx(Wu,{...e?{onRetry:e}:{}})})}function Sa({onRetry:e}){const{open:t}=uo();return r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r.jsxs(le,{size:"sm",onClick:()=>t(Ca),className:"gap-1.5",children:[r.jsx(fo,{className:"size-3"}),"Fix sign-in"]}),e&&r.jsxs(le,{variant:"outline",size:"sm",onClick:e,className:"gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]})]})}function lh({runtime:e,sessionId:t,onRetry:n,renderOffer:s,lead:o,children:a}){const i=!Oo(),l=mo(),u=oe(m=>m.setRetryAccount),d=Tt(e).label,f=s({runtime:e,origin:`auth-error:${t}`,note:`This makes new ${d} work on this computer run on your DorkOS credits.`,chosen:n?`New ${d} work on this computer now runs on your DorkOS credits. Sending your message again…`:`New ${d} work on this computer now runs on your DorkOS credits.`,...n?{confirmAfterLink:{prompt:"Linked. Send again on DorkOS credits?",action:"Send again"}}:{},onChoose:async()=>{await l.mutateAsync({runtime:e,useCredits:!0}),n&&(u({id:lt,sessionId:t}),n())}}),h=m=>r.jsxs("section",{"aria-label":"Other ways",children:[r.jsx("p",{className:"text-muted-foreground text-2xs font-medium tracking-wide uppercase",children:"Other ways"}),m]});return o?r.jsxs("div",{className:"mt-3 space-y-3","data-testid":"auth-error-credits-first",children:[f,h(a),r.jsx(Gu,{ollama:gl(e)==="provider-picker",remote:i})]}):r.jsxs("div",{"data-testid":"auth-error-credits-other-way",children:[a,r.jsx("div",{className:"mt-3",children:h(f)})]})}function ch({sessionId:e,onRetry:t,onSigninComplete:n}){var h;const{sessions:s,isLoading:o}=Jn(),a=Oo(),i=(h=s.find(m=>m.id===e))==null?void 0:h.runtime,l=Hu(i),u=ro(),d=i!==void 0&&u!==null&&(l==="lead"||l==="other-way");if(!a&&!d)return r.jsx(ur,{onRetry:t});if(o)return null;const f=a?!i||!xl(i)?r.jsx(Sa,{onRetry:t}):r.jsx(ih,{runtime:i,sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(ur,{onRetry:t});return d&&i&&u?r.jsx(lh,{runtime:i,sessionId:e,onRetry:t,renderOffer:u,lead:l==="lead",children:f}):f}function uh({sessionId:e,onRetry:t,onSigninComplete:n}){return e?r.jsx(ch,{sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(Sa,{onRetry:t})}const dh="credits_unavailable",fh="folder-sign-in";function mh({onRetry:e,sessionId:t,runtimeLabel:n,reason:s}){const o=oe(x=>x.setRetryAccount),a=bl(),i=mo(),l=po(),u=sn(t),d=tn(u??null);if(!e)return null;const f=ph(d),h=n?`your ${n}`:"your own",m=()=>{if(d!==void 0){if(f==="pick-for-send"){t&&o({id:vt,sessionId:t}),e();return}i.mutate({runtime:d.type,useCredits:!1},{onSuccess:()=>f==="new-conversation"?l(void 0,{runtime:d.type}):e()})}},g=()=>{t&&a.mutate(t,{onSuccess:({launch:x})=>{x!=null&&x.ok&&o({id:x.accountId,sessionId:t}),e()}})};return r.jsxs("div",{className:"mt-2 flex flex-col gap-2","data-testid":"credits-error-actions",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(le,{size:"sm",variant:"outline",onClick:e,className:"gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]}),t&&r.jsx(le,{size:"sm",variant:"outline",onClick:m,disabled:d===void 0||i.isPending,children:f==="new-conversation"?`Start a new chat on ${h} sign-in`:`Use ${h} sign-in`}),t&&s===fh&&r.jsx(le,{size:"sm",variant:"outline",onClick:g,disabled:a.isPending,children:"Don’t use credits in this project"})]}),t&&f==="whole-runtime"&&r.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"credits-own-sign-in-reach",children:["This moves all ",n??"its"," chats to ",h," sign-in, not just this one."]}),a.error&&r.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:a.error.message}),i.isError&&r.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:"Couldn’t switch to your own sign-in. Try again in a moment."})]})}function ph(e){var t;return e===void 0||e.supportsAccounts?"pick-for-send":((t=e.credits)==null?void 0:t.scope)==="conversation"?"new-conversation":"whole-runtime"}function hh({category:e,onChooseModel:t}){return t?r.jsxs(le,{size:"sm",onClick:t,className:"mt-3 gap-1.5",children:[r.jsx(ho,{className:"size-3"}),e==="runtime_update_required"?"Choose another model":"Choose model"]}):null}const gh="your agent",xh="agent",dr={max_turns:{heading:"Turn limit reached",subtext:"The agent ran for its maximum number of turns.",retryable:!1},execution_error:{heading:"Agent stopped unexpectedly",subtext:"Something went wrong before it finished.",retryable:!0},budget_exceeded:{heading:"Cost limit reached",subtext:"This chat hit its spending limit.",retryable:!1},output_format_error:{heading:"Output format error",subtext:"The agent couldn’t produce the required output format.",retryable:!1},auth_error:{heading:"Sign in again",subtext:"Your login stopped working. Sign in again to continue.",retryable:!0},model_unavailable:{heading:"Model unavailable",subtext:"Choose another model from the model menu.",retryable:!1},runtime_update_required:{heading:"Codex update required",subtext:"Update DorkOS or your Codex install, then try again. Or choose another model.",retryable:!1}},bh=new Set(["max_turns","budget_exceeded","output_format_error","auth_error"]);function yh(e){return`Sign in to ${e??gh} again`}function vh(e){return`Your ${e??xh} login stopped working. Sign in again to continue.`}const kh="rate_limit";function on(e){const{code:t,at:n,sessionId:s,reason:o}=e;return t===go&&o?r.jsx(Vo,{agentId:o}):t===kh&&s?r.jsx(rm,{sessionId:s,at:n??"",fallback:r.jsx(fr,{...e})}):r.jsx(fr,{...e})}function fr({message:e,category:t,details:n,onRetry:s,heading:o,subtext:a,runtimeLabel:i,sessionId:l,onSigninComplete:u,onChooseModel:d,code:f,reason:h}){const[m,g]=c.useState(!1),x=f===dh,C=c.useMemo(()=>oh(e),[e]),b=(C==null?void 0:C.category)??t,y=(C==null?void 0:C.message)??e,k=C?n!=null&&n.includes(C.details??"")?n:[n,C.details].filter(Boolean).join(`
41
+ `):n,v=b==="auth_error",p=b?dr[b]??dr.execution_error:null,_=v?yh(i):b==="runtime_update_required"&&i?`${i} update required`:p==null?void 0:p.heading,j=v?vh(i):p==null?void 0:p.subtext,D=x?"Couldn’t reach DorkOS credits":C?_??"Error":o??_??"Error",T=y.trim(),w=b!==void 0&&bh.has(b),A=x?T:(C&&(a==null?void 0:a.trim())===e.trim()?void 0:a)??(w?j:T||j)??T,S=A.trim(),E=c.useMemo(()=>yl(T),[T]),N=!T||T===S||T===D,R=!N&&(!w||E)?T:null,M=N||R!==null||k!=null&&k.includes(T)?k:[k,T].filter(Boolean).join(`
42
+ `),F=(p==null?void 0:p.retryable)??!!s;return r.jsx("div",{"data-testid":"error-message-block",className:q("my-2 rounded-lg border px-4 py-3","border-destructive/30 bg-destructive/5 text-foreground"),children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(cs,{className:"text-destructive mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium",children:D}),r.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(fn,{text:A})}),R&&r.jsx("p",{className:"text-muted-foreground mt-1 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(fn,{text:R})}),M&&r.jsxs("button",{type:"button",onClick:()=>g(!m),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":m,children:[r.jsx(W.div,{animate:{rotate:m?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:r.jsx(Dt,{className:"size-3"})}),"Details"]}),r.jsx(ce,{initial:!1,children:m&&M&&r.jsx(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"overflow-hidden",children:r.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:r.jsx(fn,{text:M})})})}),x&&r.jsx(mh,{onRetry:s,sessionId:l,runtimeLabel:i,reason:h}),v&&r.jsx(uh,{sessionId:l,onRetry:s,onSigninComplete:u}),(b==="model_unavailable"||b==="runtime_update_required")&&r.jsx(hh,{category:b,onChooseModel:d})]}),!v&&!x&&F&&s&&r.jsxs(le,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]})]})})}const Ch=8;function Sh({toolName:e,reasonType:t,reason:n,message:s,agentId:o}){const a=n||s,i=t==="classifier",l=t==="asyncAgent",u=o!==void 0?`Helper ${o.slice(0,Ch)}`:l?"A background helper":null,f=u!==null?`${u} was blocked from using ${e}${i?" by auto mode":""}: ${a}`:i?`Blocked by auto mode: ${a}`:`Blocked: ${a}`;return r.jsxs("div",{"data-testid":"permission-denied-chip","data-reason-type":t,"data-agent-id":o,className:q("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-amber-500/30 bg-amber-500/5"),children:[r.jsx(td,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-500"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm",children:f}),l?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Background helpers can’t ask for approval, so this was blocked."}),r.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Do it yourself, or ask the agent to run it in the foreground."})]}):null,r.jsx("p",{className:"text-muted-foreground mt-0.5 font-mono text-xs",children:e})]})]})}const _h=50;function jh(e){return e.type==="tool_call"&&e.interactiveType==="approval"&&e.approvalOutcome!==void 0}function wh(e,t){return e.approvalOutcome!==t.approvalOutcome||(e.approvalReasonGiven??!1)!==(t.approvalReasonGiven??!1)||e.approvalResolvedAt===void 0||t.approvalResolvedAt===void 0?!1:Math.abs(e.approvalResolvedAt-t.approvalResolvedAt)<=_h}function Nh(e){const t=new Map;let n=null;for(let s=0;s<e.length;s++){const o=e[s];if(!jh(o)){n=null;continue}if(n&&wh(n.part,o)){n.group.indices.push(s),t.set(s,n.group);continue}const a={leadIndex:s,indices:[s],outcome:o.approvalOutcome,reasonGiven:o.approvalReasonGiven??!1};t.set(s,a),n={group:a,part:o}}return t}function Eh(e){return e.questionOutcome!==void 0?e.questionOutcome==="answered":e.status!=="pending"}function Dh(e){return e.status==="pending"?void 0:e.questionOutcome}function Th({message:e}){return r.jsx(st,{"data-testid":"unreadable-entry-note",icon:r.jsx(vl,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:e})})}function Ah({title:e}){return r.jsxs("div",{"data-testid":"capability-approval-timed-out",className:q("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-border bg-muted/40"),children:[r.jsx(xt,{"aria-hidden":"true",className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm",children:"The agent stopped waiting for your answer."}),r.jsxs("p",{className:"text-muted-foreground mt-0.5 text-xs",children:["“",e,"” is still in Approvals. Answer it, then ask the agent to retry."]})]})]})}function Wn({testId:e,icon:t,children:n}){return r.jsxs("div",{"data-testid":e,className:q("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-border bg-muted/40"),children:[t,r.jsx("div",{className:"min-w-0 flex-1",children:n})]})}function Fh({part:e}){return e.outcome==="failed"?r.jsx(Wn,{testId:"mcp-signin-failed",icon:r.jsx(cs,{"aria-hidden":"true",className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),children:r.jsxs("p",{className:"text-sm",children:["Sign-in to “",e.serverName,"” didn’t finish. Ask your agent to retry."]})}):r.jsx(Wn,{testId:"mcp-signin-receipt",icon:r.jsx(xo,{"aria-hidden":"true",className:"text-status-success mt-0.5 size-4 shrink-0"}),children:r.jsxs("p",{className:"text-sm",children:["Connected to ",e.serverName,e.toolCount===void 0?"":` · ${e.toolCount} tool${e.toolCount===1?"":"s"}`,"."]})})}function Rh({part:e}){const t=nd(e.agentId,e.serverName),{adopt:n}=t,s=e.outcome!==void 0;return c.useEffect(()=>{s||n({flowId:e.flowId,authorizeUrl:e.authorizeUrl,disclosure:e.disclosure})},[s,n,e.flowId,e.authorizeUrl,e.disclosure]),e.outcome!==void 0?r.jsx(Fh,{part:e}):r.jsxs(Wn,{testId:"mcp-signin-card",icon:r.jsx(kl,{"aria-hidden":"true",className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),children:[r.jsxs("p",{className:"text-sm",children:["Sign in to ",e.serverName]}),r.jsx(sd,{flow:t,serverName:e.serverName,failedActions:r.jsx(le,{variant:"secondary",size:"sm",onClick:()=>t.start(),className:"focus-visible:ring-2",children:"Try again"})})]})}function Mh({fromName:e,toName:t}){return r.jsx(st,{"data-testid":"model-substituted-row",icon:r.jsx(ho,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsxs("span",{className:"text-muted-foreground",children:["DorkOS credits don’t cover ",e,", so this ran on ",t,". Switch in the model menu."]})})}const Oh={running:r.jsx(Le,{size:"xs",className:"text-muted-foreground"}),success:r.jsx(Jt,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:r.jsx(it,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:r.jsx(it,{className:"text-muted-foreground size-(--size-icon-xs)"})};function Ih({hook:e}){const t=!!(e.stdout||e.stderr),[n,s]=c.useState(e.status==="error"),o=e.stderr||e.stdout;return r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>t&&s(a=>!a),className:q("flex w-full items-center gap-1.5 py-0.5",!t&&"cursor-default"),"aria-expanded":t?n:void 0,disabled:!t,children:[Oh[e.status],r.jsx("span",{className:q("text-3xs font-mono",e.status==="error"?"text-destructive":"text-muted-foreground"),children:e.hookName}),e.status==="error"&&r.jsx("span",{className:"text-3xs text-destructive",children:"Error"}),e.exitCode!==void 0&&r.jsxs("span",{className:"text-3xs text-muted-foreground ml-auto",children:["exit ",e.exitCode]})]}),r.jsx(ce,{initial:!1,children:n&&t&&o&&r.jsx(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"overflow-hidden",children:r.jsx("pre",{className:"text-muted-foreground max-h-32 overflow-y-auto py-1 text-xs whitespace-pre-wrap",children:o})})})]})}function $h({toolCall:e,defaultExpanded:t=!1}){const[n,s]=c.useState(t),o=!!e.progressOutput;c.useEffect(()=>{o&&!n&&s(!0)},[o]);const a=e.hooks&&e.hooks.length>0?r.jsx("div",{className:"border-border/50 space-y-0.5 border-t px-3 py-1",children:e.hooks.map(u=>r.jsx(Ih,{hook:u},u.hookId))}):void 0,i=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,l=Cl(e.toolName);return r.jsxs(Ft,{expanded:n,onToggle:()=>s(!n),dimmed:e.status==="complete",extraContent:a,"data-testid":"tool-call-card","data-tool-name":e.toolName,"data-status":e.status,header:r.jsxs(r.Fragment,{children:[la(e.status),l&&r.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:l}),r.jsx("span",{className:"text-3xs flex-1 text-left font-mono",children:_t(e.toolName,e.input)}),i!==void 0&&r.jsx("span",{className:"text-muted-foreground text-3xs tabular-nums",children:rd(i)})]}),children:[e.status==="running"&&!e.input?r.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 py-1 text-xs",children:[r.jsx(Le,{size:"xs"}),r.jsx("span",{children:"Preparing…"})]}):e.input!==void 0&&e.input!==""?r.jsx(Sl,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&r.jsx(eo,{content:e.progressOutput,className:"mt-2 border-t pt-2"}),e.result&&r.jsx("div",{className:"mt-2 border-t pt-2",children:r.jsx(ka,{content:e.result,toolName:e.toolName,input:e.input})})]})}function Ph(e){if(e.startsWith("mcp__"))return e.split("__")[1]||void 0}function _a(e,t,n){const s=c.useRef(e),[o,a]=c.useState(!(t&&s.current==="complete"));return c.useEffect(()=>{if(t&&e==="complete"&&s.current!=="complete"&&!n){const i=setTimeout(()=>a(!1),en.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(i)}},[e,t,n]),!t||n?!0:o}function Lh({part:e,autoHide:t,expandToolCalls:n}){var a;const s=((a=e.hooks)==null?void 0:a.some(i=>i.status==="error"))??!1,o=_a(e.status,t,s);return r.jsx(ce,{children:o&&r.jsx(W.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx($h,{toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input||"",result:e.result,progressOutput:e.progressOutput,status:e.status,hooks:e.hooks,startedAt:e.startedAt,completedAt:e.completedAt},defaultExpanded:n})},e.toolCallId)})}function En({part:e,sessionId:t,autoHide:n,expandToolCalls:s}){const o=e.ui?Ph(e.toolName):void 0,a=r.jsx(Lh,{part:e,autoHide:n,expandToolCalls:s});return!e.ui||e.status!=="complete"||!o?a:r.jsxs("div",{className:"flex flex-col gap-2",children:[a,r.jsx(af,{sessionId:t,serverName:o,uri:e.ui.resourceUri})]})}function Bh({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",o=_a(s,t,!1);return r.jsx(ce,{children:o&&r.jsx(W.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx(vp,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const zh=4,mr=2;function qh({children:e}){const[t,n]=c.useState(!1);if(e.length<=zh||t)return r.jsx(r.Fragment,{children:e});const s=e.length-mr;return r.jsxs(r.Fragment,{children:[e.slice(0,mr),r.jsx(Ft,{expanded:!1,onToggle:()=>n(!0),ariaLabel:`Show ${s} more steps`,className:"border-l-muted-foreground/15",header:r.jsxs("span",{className:"text-3xs text-muted-foreground font-mono",children:["and ",s," more steps…"]}),children:r.jsx(r.Fragment,{})})]})}const Uh=/\|\||&&|;|\|/,Hh=/<<|>/,pr=60;function Wh(e){if(!e)return null;try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Ie(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function Gh(e,t){const n=e.split(`
43
+ `),s=t.split(`
44
+ `);let o=0;for(;o<n.length&&o<s.length&&n[o]===s[o];)o++;let a=0;for(;a<n.length-o&&a<s.length-o&&n[n.length-1-a]===s[s.length-1-a];)a++;const i=o+a;return{additions:Math.max(0,s.length-i),deletions:Math.max(0,n.length-i)}}function Gn(e){const t=e.old_string,n=e.new_string;if(!(typeof t!="string"&&typeof n!="string"))return Gh(typeof t=="string"?t:"",typeof n=="string"?n:"")}function Vh(e){const t=e.edits;if(!Array.isArray(t))return Gn(e);let n=0,s=0,o=!1;for(const a of t){if(typeof a!="object"||a===null)continue;const i=Gn(a);i&&(n+=i.additions,s+=i.deletions,o=!0)}return o?{additions:n,deletions:s}:void 0}function Kh(e){return e?` +${e.additions} −${e.deletions}`:""}function Qh(e){return e.length===0?0:e.replace(/\n$/,"").split(`
45
+ `).length}function ja(e){const t=e.replace(/\/+$/,"");if(t.length===0)return e;const n=t.startsWith("/"),s=[];for(const a of t.split("/"))if(!(a===""||a===".")){if(a===".."){const i=s[s.length-1];i!==void 0&&i!==".."?s.pop():n||s.push("..");continue}s.push(a)}const o=s.join("/");return o.length===0?n?"/":e:n?`/${o}`:o}function Yh(e,t){if(e===t)return!0;const n=e.startsWith("/")?e:t,s=e.startsWith("/")?t:e;return!n.startsWith("/")||s.startsWith("/")?!1:n.endsWith(`/${s}`)}function wa(e){const t=ja(e).split("/");return t[t.length-1]||e}function Xh(e){try{const t=new URL(e);return t.hash="",t.toString()}catch{return e}}function Jh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Zh(e){if(!e)return;const t=e.trim();if(t.length===0)return;if(/^no (matches|files)/i.test(t))return 0;const n=/^(\d+)$/.exec(t);if(n)return Number(n[1]);const s=/(\d+)\s+(?:matches?|lines?)/i.exec(t);if(s)return Number(s[1]);if(!/\d+\s+files?/i.test(t))return t.split(`
46
+ `).filter(o=>o.trim().length>0).length}function eg(e){var s;const n=((s=e.split(`
47
+ `).find(o=>o.trim().length>0))==null?void 0:s.trim())??e.trim();return n.length<=pr?n:`${n.slice(0,pr-1).trimEnd()}…`}function tg(e){const t=[];let n="",s=null,o=!1;for(const a of e){if(s){a===s?s=null:n+=a;continue}if(a==='"'||a==="'"){s=a,o=!0;continue}if(/\s/.test(a)){o&&t.push(n),n="",o=!1;continue}n+=a,o=!0}return o&&t.push(n),t}function ng(e){const t=[];for(const n of e.split(`
48
+ `)){for(const s of n.split(Uh)){const o=tg(s.trim());if(o.length===0)continue;let a;if(o[0]==="git"&&o[1]==="rm")a=2;else if(o[0]==="rm")a=1;else continue;for(const i of o.slice(a)){if(i.includes(">")||i.includes("<"))break;i==="--"||i.startsWith("-")||i.length===0||t.push(i)}}if(Hh.test(n))break}return t}const hr={delete:3,create:2,edit:1,read:0,search:0,fetch:0,run:0},sg=new Set(["Task","Agent","TodoWrite"]);function xs(e){return e===1?"1 hit":`${e} hits`}const rg=/[*?[\]~$]/;function gt(e,t,n,s,o){const a=ja(e);return{key:`file:${a}`,kind:"file",label:o===!0?a:wa(a),fullTarget:a,verb:t,entry:n,additions:s==null?void 0:s.additions,deletions:s==null?void 0:s.deletions,pattern:o===!0?!0:void 0}}function og(e){const{toolName:t}=e;if(sg.has(t)||t.startsWith("mcp__"))return[];const n=Wh(e.input);if(!n)return[];switch(t){case"Read":{const s=Ie(n,"file_path");return s?[gt(s,"read","read")]:[]}case"Glob":{const s=Ie(n,"pattern");return s?[{key:`file:${s}`,kind:"file",label:s,fullTarget:s,verb:"read",entry:"globbed",pattern:!0}]:[]}case"Grep":{const s=Ie(n,"pattern");if(!s)return[];const o=e.status==="error"?void 0:Zh(e.result);return[{key:`grep:${s}`,kind:"command",label:`"${s}"`,fullTarget:s,verb:"search",entry:o===void 0?"searched":`searched (${xs(o)})`,hits:o}]}case"Edit":case"MultiEdit":case"NotebookEdit":{const s=Ie(n,"file_path")??Ie(n,"notebook_path");if(!s)return[];const o=t==="MultiEdit"?Vh(n):Gn(n);return[gt(s,"edit",`edited${Kh(o)}`,o)]}case"Write":{const s=Ie(n,"file_path");if(!s)return[];if(!/created/i.test(e.result??""))return[gt(s,"edit","wrote")];const a=Ie(n,"content"),i=a===void 0?void 0:{additions:Qh(a)};return[gt(s,"create",`created${i?` +${i.additions}`:""}`,i)]}case"Bash":{const s=Ie(n,"command");if(!s)return[];const o=[{key:`run:${s}`,kind:"command",label:eg(s),fullTarget:s,verb:"run",entry:"ran"}];for(const a of ng(s))o.push(gt(a,"delete","deleted",void 0,rg.test(a)));return o}case"WebFetch":{const s=Ie(n,"url");return s?[{key:`url:${Xh(s)}`,kind:"url",label:Jh(s),fullTarget:s,verb:"fetch",entry:"fetched"}]:[]}case"WebSearch":{const s=Ie(n,"query");return s?[{key:`websearch:${s}`,kind:"command",label:s,fullTarget:s,verb:"search",entry:"searched the web"}]:[]}default:return[]}}function ag(e,t){if(t.kind!=="file"||t.pattern===!0||e.has(t.key))return t.key;for(const n of e.values())if(!(n.kind!=="file"||n.pattern===!0)&&Yh(n.fullTarget,t.fullTarget))return n.key;return t.key}function ig(e,t,n,s,o){const a=ag(e,t),i=e.get(a);if(!i){e.set(a,{key:a,kind:t.kind,label:t.label,fullTarget:t.fullTarget,verb:t.verb,live:s,error:o,touches:1,additions:t.additions,deletions:t.deletions,hits:t.hits,pattern:t.pattern,firstSeq:n,lastSeq:n,history:[t.entry]});return}i.touches+=1,i.lastSeq=n,i.live=i.live||s,i.error=i.error||o,i.history.push(t.entry),t.additions!==void 0&&(i.additions=(i.additions??0)+t.additions),t.deletions!==void 0&&(i.deletions=(i.deletions??0)+t.deletions),t.hits!==void 0&&(i.hits=(i.hits??0)+t.hits),t.pattern||(i.pattern=void 0),i.kind==="file"&&i.pattern!==!0&&t.fullTarget.startsWith("/")&&!i.fullTarget.startsWith("/")&&(i.fullTarget=t.fullTarget,i.label=wa(t.fullTarget)),i.verb==="read"&&t.verb==="edit"&&(i.upgraded=!0),hr[t.verb]>hr[i.verb]&&(i.verb=t.verb)}const gr=new WeakMap;function lg(e){const t=gr.get(e);if(t&&t.input===e.input&&t.result===e.result&&t.status===e.status)return t.touches;const n=og(e);return gr.set(e,{input:e.input,result:e.result,status:e.status,touches:n}),n}function cg(e){const t=new Map;return e.forEach((n,s)=>{if(n.type!=="tool_call")return;const o=n.status==="pending"||n.status==="running",a=n.status==="error";for(const i of lg(n))ig(t,i,s,o,a)}),[...t.values()]}const Na={expanded:!1,verbFilter:null,order:"grouped"},Dn=ss(e=>({views:{},update:(t,n)=>e(s=>({views:{...s.views,[t]:{...s.views[t]??Na,...n}}}))}));function ug(e,t){const n=t.find(s=>s.type==="tool_call");return`${e}:${(n==null?void 0:n.toolCallId)??""}`}function dg(e){const t=Dn(l=>l.views[e]),n=Dn(l=>l.update),s=t??Na,o=c.useCallback(()=>{var l;return n(e,{expanded:!((l=Dn.getState().views[e])!=null&&l.expanded)})},[e,n]),a=c.useCallback(l=>n(e,{verbFilter:l}),[e,n]),i=c.useCallback(l=>n(e,{order:l}),[e,n]);return c.useMemo(()=>({...s,toggleExpanded:o,setVerbFilter:a,setOrder:i}),[s,o,a,i])}const xr=4,dt=[.4,0,.2,1],fg={type:"spring",stiffness:320,damping:28},mg={duration:.25,ease:dt},pg={x:-16,scale:.45,opacity:0},Xt={duration:.15,ease:dt},br={duration:.3,ease:dt},yr={duration:.15,ease:dt},hg={duration:.3,ease:dt},gg={stiffness:220,damping:30},xg={rotate:[0,-4,3,0],scale:[1,1.08,1,1]},bg={duration:.3,ease:dt};function yg(e,t){return e?t?{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:Xt},transition:Xt}:{initial:{opacity:0,y:7},animate:{opacity:1,y:0},exit:{...pg,transition:mg},transition:fg}:{}}const an={read:"📖",search:"🔍",edit:"✏️",create:"✚",delete:"🗑",fetch:"🌐",run:"▮"},ln={read:"Read",search:"Searched",edit:"Edited",create:"Created",delete:"Deleted",fetch:"Fetched",run:"Ran"},Ea=["read","search","edit","create","delete","fetch","run"];function Da(e){return Ea.map(t=>{const n=e.filter(o=>o.verb===t),s={verb:t,chips:n};for(const o of n)o.additions!==void 0&&(s.additions=(s.additions??0)+o.additions),o.deletions!==void 0&&(s.deletions=(s.deletions??0)+o.deletions);return s}).filter(t=>t.chips.length>0)}const vg=["z-30","-ml-2 z-20 opacity-70","-ml-2 z-10 opacity-45"];function kg({chips:e,expanded:t,controls:n,onExpand:s}){const o=Fe()??!1,a=e.slice(-3).reverse();return r.jsxs("button",{type:"button","data-testid":"chip-pile","aria-expanded":t,"aria-controls":n,"aria-label":`Show everything this turn touched (${e.length} more)`,onClick:s,className:q("flex shrink-0 items-center gap-1.5 rounded-full py-0.5 pr-1.5 pl-0.5","hover:bg-accent focus-visible:ring-ring outline-none focus-visible:ring-2"),children:[r.jsx(W.span,{animate:o?{rotate:0,scale:1}:xg,transition:bg,className:"flex origin-bottom items-center",children:a.map((i,l)=>r.jsx("span",{"aria-hidden":"true",className:q("bg-card border-border text-3xs flex size-5 items-center justify-center rounded-full border leading-none",vg[l]),children:an[i.verb]},i.key))},e.length),r.jsx("span",{"data-testid":"chip-pile-count",className:"bg-primary text-primary-foreground text-3xs rounded-full px-1.5 tabular-nums",children:e.length})]})}function vr({value:e,live:t}){const n=Fe()??!1,s=fd(e,gg),o=Io(s,a=>Math.round(a));return c.useEffect(()=>{s.set(e)},[s,e]),!t||n?r.jsx(r.Fragment,{children:e}):r.jsx(W.span,{children:o})}function Cg(e){return e.kind!=="command"&&e.pattern!==!0}function Sg(e){return[e.fullTarget,e.history.join(", "),e.pattern===!0?"A pattern, not one file. There is nothing to open.":""].filter(Boolean).join(`
49
+ `)}function _g(e){const t=e.pattern===!0&&e.verb==="read"?"Globbed":ln[e.verb],n=e.verb==="run"?e.label:e.fullTarget,s=[`${t} ${n}`];return e.touches>1&&s.push(`${e.touches} times`),e.hits!==void 0&&s.push(xs(e.hits)),e.additions!==void 0&&s.push(`${e.additions} added`),e.deletions!==void 0&&s.push(`${e.deletions} removed`),e.error&&s.push("didn’t work"),s.join(", ")}const kr="bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-3xs leading-[1.4] tabular-nums";function Ta({chip:e,onOpen:t,animated:n=!1,pulseUpgrade:s=!1,onUpgradeSeen:o}){const a=Fe()??!1,i=s&&!a,l=Cg(e),u=e.verb==="delete",d=e.additions!==void 0||e.deletions!==void 0,f=n&&(e.verb==="create"||e.verb==="delete");return r.jsxs(W.button,{...yg(n,a),type:"button","data-testid":"touch-chip","data-verb":e.verb,"data-live":e.live,"data-arriving":f?"true":void 0,title:Sg(e),"aria-label":_g(e),onClick:()=>t(e),className:q("touch-chip relative inline-flex max-w-56 items-center gap-1.5 rounded-full border","px-2 py-0.5 text-xs","bg-card text-foreground border-border","focus-visible:ring-ring outline-none focus-visible:ring-2",l?"hover:bg-accent hover:text-accent-foreground":"cursor-default",u&&"text-muted-foreground line-through opacity-60",e.error&&"border-destructive/40 bg-destructive/10 text-destructive"),children:[r.jsx("span",{"aria-hidden":"true",className:"chip-sweep"}),r.jsxs("span",{className:"chip-icon relative inline-flex w-4 shrink-0 items-center justify-center leading-none",children:[r.jsx("span",{className:"chip-glyph inline-flex items-center justify-center [perspective:400px]",children:r.jsx(ce,{initial:!1,mode:"wait",children:r.jsx(W.span,{"aria-hidden":"true",initial:a?{opacity:0}:{opacity:0,rotateX:-90},animate:a?{opacity:1}:{opacity:1,rotateX:0},exit:a?{opacity:0}:{opacity:0,rotateX:90},transition:yr,children:an[e.verb]},e.verb)})}),i&&r.jsx(W.span,{"aria-hidden":"true","data-testid":"chip-upgrade-pulse",className:"border-primary pointer-events-none absolute -inset-1 rounded-full border",initial:{scale:.6,opacity:.8},animate:{scale:1.8,opacity:0},transition:hg,onAnimationComplete:()=>o==null?void 0:o(e.key)})]}),r.jsx("span",{className:"chip-label truncate",children:e.label}),e.verb==="edit"&&e.live&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-caret",className:"chip-caret"}),e.verb==="run"&&e.live&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-cursor",className:"chip-cursor"}),e.verb==="fetch"&&e.live&&r.jsxs("span",{"aria-hidden":"true","data-testid":"chip-dots",className:"chip-dots",children:[r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{})]}),e.verb==="create"&&f&&r.jsxs(r.Fragment,{children:[r.jsx("svg",{"aria-hidden":"true","data-testid":"chip-pen",className:"chip-pen",children:r.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",rx:"11",ry:"11",pathLength:"100"})}),r.jsx("span",{"aria-hidden":"true",className:"chip-spark"})]}),e.verb==="delete"&&f&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-puff",className:"chip-puff"}),e.touches>1&&r.jsxs("span",{className:kr,children:["×",e.touches]}),e.hits!==void 0&&r.jsx("span",{className:kr,children:xs(e.hits)}),d&&r.jsxs(W.span,{className:"shrink-0 tabular-nums",initial:i?{opacity:0,x:-4}:!1,animate:{opacity:1,x:0},transition:yr,children:[e.additions!==void 0&&r.jsxs("span",{className:"text-status-success-fg",children:["+",r.jsx(vr,{value:e.additions,live:e.live})]}),e.additions!==void 0&&e.deletions!==void 0&&" ",e.deletions!==void 0&&r.jsxs("span",{className:"text-destructive",children:["−",r.jsx(vr,{value:e.deletions,live:e.live})]})]})]})}const Cr=new Map(Ea.map((e,t)=>[e,t]));function jg(e,t){const n=[...e];return t==="chronological"?n.sort((s,o)=>s.lastSeq-o.lastSeq):n.sort((s,o)=>(Cr.get(s.verb)??0)-(Cr.get(o.verb)??0)||s.firstSeq-o.firstSeq)}function wg({id:e,chips:t,onOpen:n,verbFilter:s,onVerbFilterChange:o,order:a,onOrderChange:i}){const l=c.useMemo(()=>Da(t),[t]),u=c.useMemo(()=>{const d=s?t.filter(f=>f.verb===s):t;return jg(d,a)},[t,s,a]);return r.jsxs("div",{id:e,role:"region","aria-label":"Touched files and links","data-testid":"chip-tray",className:"border-border bg-card/50 flex flex-col gap-2 rounded-md border p-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsx("div",{role:"group","aria-label":"Filter by what happened",className:"flex flex-wrap gap-1",children:l.map(d=>{const f=s===d.verb;return r.jsxs(le,{variant:"outline",size:"xs","aria-pressed":f,"data-testid":`chip-filter-${d.verb}`,onClick:()=>o(f?null:d.verb),className:q("rounded-full",f?"border-primary dark:border-primary text-foreground":"text-muted-foreground"),children:[r.jsx("span",{"aria-hidden":"true",children:an[d.verb]}),r.jsx("span",{className:"sr-only",children:ln[d.verb]}),r.jsx("span",{className:"tabular-nums",children:d.chips.length})]},d.verb)})}),r.jsxs(_l,{value:a,onValueChange:d=>i(d),"aria-label":"Order the roster",className:"w-auto",children:[r.jsx(Is,{value:"grouped",children:"Grouped"}),r.jsx(Is,{value:"chronological",children:"Chronological"})]})]}),r.jsx("div",{"data-testid":"chip-tray-roster",className:"flex max-h-60 flex-wrap items-start gap-1.5 overflow-y-auto overscroll-contain",children:u.map(d=>r.jsx(Ta,{chip:d,onOpen:n},d.key))})]})}const Ng=new Set;function Eg(){const[e,t]=c.useState(Ng),n=c.useCallback((o,a)=>a===!0&&!e.has(o),[e]),s=c.useCallback(o=>{t(a=>a.has(o)?a:new Set(a).add(o))},[]);return{shouldPulse:n,acknowledge:s}}function Dg(e){const t=[...e].sort((n,s)=>n.lastSeq-s.lastSeq);return{visible:t.slice(-xr),absorbed:t.slice(0,Math.max(0,t.length-xr))}}function Tg(e){return e.map(t=>{const n=[`${t.chips.length} ${ln[t.verb].toLowerCase()}`];return t.additions!==void 0&&n.push(`${t.additions} added`),t.deletions!==void 0&&n.push(`${t.deletions} removed`),n.join(", ")}).join("; ")}function Ag({verb:e,count:t,additions:n,deletions:s}){return r.jsxs("span",{"data-testid":`chip-summary-${e}`,className:"inline-flex items-center gap-1",children:[r.jsx("span",{"aria-hidden":"true",children:an[e]}),r.jsx("span",{className:"sr-only",children:ln[e]}),r.jsx("span",{className:"tabular-nums",children:t}),(n!==void 0||s!==void 0)&&r.jsxs("span",{className:"tabular-nums",children:[n!==void 0&&r.jsxs("span",{className:"text-status-success-fg",children:["+",n]}),n!==void 0&&s!==void 0&&" ",s!==void 0&&r.jsxs("span",{className:"text-destructive",children:["−",s]})]})]})}function Fg({parts:e,sessionId:t,turnActive:n=!1}){const s=Fe()??!1,o=c.useMemo(()=>cg(e),[e]),a=Eg(),i=c.useId(),l=dg(c.useMemo(()=>ug(t,e),[t,e])),u=c.useCallback(g=>{if(g.pattern===!0)return;const x=oe.getState();if(g.kind==="url"){const C={type:"url",url:g.fullTarget};x.openCanvasDocument(C),$n(x,"user",C);return}if(g.kind==="file"){const C={type:"file",sourcePath:g.fullTarget};x.openCanvasDocument(C),$n(x,"user",C)}},[]),d=c.useMemo(()=>Da(o),[o]),f=n||o.some(g=>g.live),{visible:h,absorbed:m}=c.useMemo(()=>Dg(o),[o]);return o.length===0?null:r.jsxs("div",{"data-testid":"touch-chip-strip",className:"mt-2 flex flex-col gap-2",children:[r.jsx(ce,{initial:!1,mode:"wait",children:f?r.jsxs(W.div,{"data-testid":"chip-live-row",role:"group","aria-label":"Latest activity",exit:s?{opacity:0}:{opacity:0,height:0},transition:s?Xt:br,className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:[m.length>0&&r.jsx(kg,{chips:m,expanded:l.expanded,controls:i,onExpand:l.toggleExpanded}),r.jsx(ce,{initial:!1,children:h.map(g=>r.jsx(Ta,{chip:g,onOpen:u,animated:!0,pulseUpgrade:a.shouldPulse(g.key,g.upgraded),onUpgradeSeen:a.acknowledge},g.key))})]},"live"):r.jsxs(W.div,{"data-testid":"chip-summary-line",role:"group","aria-label":Tg(d),initial:{opacity:0},animate:{opacity:1},transition:s?Xt:br,className:"text-muted-foreground flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs",children:[d.map((g,x)=>r.jsxs(c.Fragment,{children:[x>0&&r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx(Ag,{verb:g.verb,count:g.chips.length,additions:g.additions,deletions:g.deletions})]},g.verb)),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("button",{type:"button","aria-expanded":l.expanded,"aria-controls":i,onClick:l.toggleExpanded,className:q("hover:text-foreground rounded-sm underline underline-offset-2","focus-visible:ring-ring outline-none focus-visible:ring-2"),children:l.expanded?"hide":"show all"})]},"settled")}),l.expanded&&r.jsx(wg,{id:i,chips:o,onOpen:u,verbFilter:l.verbFilter,onVerbFilterChange:l.setVerbFilter,order:l.order,onOrderChange:l.setOrder})]})}function Sr(e){return e.type==="thinking"?!0:e.type==="tool_call"&&!e.interactiveType&&!Ko(e.toolName)&&!Pn(e.toolName)}function Rg({message:e}){const{sessionId:t,isStreaming:n,isLatestWidgetMessage:s,isFinalMessage:o,activeToolCallId:a,onToolRef:i,focusedOptionIndex:l,onToolDecided:u,onRetry:d,onSigninComplete:f,onChooseModel:h,inputZoneToolCallId:m,textEffect:g,runtimeLabel:x,allowsDenyReason:C}=xp(),b=oe(S=>S.expandToolCalls),y=oe(S=>S.autoHideToolCalls),k=e.parts??[],{sent:v}=pa(t),p=c.useCallback(S=>{i==null||i(S)},[i]),_=c.useCallback(S=>{i==null||i(S)},[i]),j=Nh(k.map(S=>S.type==="tool_call"&&Pn(S.toolName)?{...S,interactiveType:void 0}:S));let D=-1;for(let S=k.length-1;S>=0;S--)if(k[S].type==="text"){D=S;break}function T(S,E){if(S.type==="text")return r.jsx("div",{className:"msg-prose",children:r.jsx(ps,{content:S.text,isStreaming:n&&E===D,textEffect:g,sessionId:t,isLatestWidgetMessage:s})},`text-${E}`);if(S.type==="background_task")return r.jsx(Fp,{part:S},S.taskId);if(S.type==="error"&&S.code===bo)return r.jsx(Th,{message:S.message},`unreadable-${E}`);if(S.type==="error")return r.jsx(on,{message:S.message,category:S.category,details:S.details,code:S.code,reason:S.reason,at:e.timestamp,onRetry:o&&S.category!==void 0?d:void 0,onSigninComplete:f,onChooseModel:h,runtimeLabel:x,sessionId:t},`error-${E}`);if(S.type==="thinking")return r.jsx(Bh,{part:S,autoHide:y,index:E},`thinking-${E}`);if(S.type==="elicitation")return r.jsx(Bd,{sessionId:t,interactionId:S.interactionId,serverName:S.serverName,message:S.message,mode:S.mode,url:S.url,requestedSchema:S.requestedSchema,status:S.status,action:S.action},`elicitation-${S.interactionId}`);if(S.type==="memory_recall")return r.jsx(kp,{mode:S.mode,memories:S.memories,isStreaming:S.isStreaming??!1},`memory-recall-${E}`);if(S.type==="permission_denied")return r.jsx(Sh,{toolName:S.toolName,reasonType:S.reasonType,reason:S.reason,message:S.message,agentId:S.agentId},`permission-denied-${S.toolCallId}-${E}`);if(S.type==="model_substituted")return r.jsx(Mh,{fromName:S.fromName,toName:S.toName},`model-substituted-${E}`);if(S.type==="compact_boundary")return r.jsx(wp,{trigger:S.trigger,preTokens:S.preTokens,postTokens:S.postTokens,failed:S.failed,error:S.error,requestedBy:S.requestedBy,contextPercent:S.contextPercent},`compact-boundary-${E}`);if(S.type==="capability_approval")return S.outcome==="timeout"?r.jsx(Ah,{title:jl(S.approval)},`capability-approval-${S.approval.approvalId}`):r.jsx(wl,{approval:S.approval},`capability-approval-${S.approval.approvalId}`);if(S.type==="mcp_signin")return r.jsx(Rh,{part:S},`mcp-signin-${S.agentId}-${S.flowId}`);if(S.type==="image")return r.jsx(Np,{part:S},`image-${S.attachmentId}-${E}`);if(S.type!=="tool_call")return null;const N=S;if(N.interactiveType==="approval"&&N.status==="pending"){if(N.toolCallId===m)return r.jsx(tr,{type:"approval",toolName:N.toolName,toolInput:N.input},N.toolCallId);const M=N.toolCallId===a;return r.jsx(yo,{ref:M?p:void 0,sessionId:t,toolCallId:N.toolCallId,toolName:N.toolName,input:N.input||"",timeoutMs:N.timeoutMs,approvalStartedAt:N.approvalStartedAt,approvalRemainingMs:N.approvalRemainingMs,approvalParked:N.approvalParked,approvalTitle:N.approvalTitle,approvalDisplayName:N.approvalDisplayName,approvalDescription:N.approvalDescription,approvalBlockedPath:N.approvalBlockedPath,approvalDecisionReason:N.approvalDecisionReason,approvalHasSuggestions:N.approvalHasSuggestions,approvalAlwaysAllowScope:N.approvalAlwaysAllowScope,isActive:M,onDecided:u?()=>u(N.toolCallId):void 0,allowsDenyReason:C},N.toolCallId)}const R=j.get(E);if(R){if(R.leadIndex!==E)return null;const M=R.indices.map(F=>k[F]).filter(F=>F.type==="tool_call");return r.jsx(Kd,{outcome:R.outcome,reasonGiven:R.reasonGiven,members:M,lead:N,children:M.map(F=>r.jsx(En,{part:F,sessionId:t,autoHide:y,expandToolCalls:b},F.toolCallId))},`approval-receipt-${N.toolCallId}`)}if(N.interactiveType==="question"){if(N.toolCallId===m)return r.jsx(tr,{type:"question",toolName:N.toolName,toolInput:N.input},N.toolCallId);const M=N.toolCallId===a;return r.jsx(vo,{ref:M?_:void 0,sessionId:t,toolCallId:N.toolCallId,questions:N.questions??[],answers:N.answers??(Eh(N)?{}:void 0),outcome:Dh(N),result:N.result,isActive:M,focusedOptionIndex:M?l:-1,onDecided:u?F=>u(N.toolCallId,F):void 0},N.toolCallId)}return Pn(N.toolName)?r.jsx(ip,{part:N,sent:v,...e.timestamp?{at:e.timestamp}:{},...t?{sessionId:t}:{}},N.toolCallId):Ko(N.toolName)?r.jsx(Xd,{sessionId:t,input:N.input,result:N.result,fallback:r.jsx(En,{part:N,sessionId:t,autoHide:y,expandToolCalls:b})},N.toolCallId):r.jsx(En,{part:N,sessionId:t,autoHide:y,expandToolCalls:b},N.toolCallId)}const w=[];let A=[];for(let S=0;S<k.length;S++){const E=k[S];Sr(E)?A.push(S):(A.length>0&&(w.push(A.length===1?{type:"single",index:A[0]}:{type:"run",indices:[...A]}),A=[]),w.push({type:"single",index:S}))}return A.length>0&&w.push(A.length===1?{type:"single",index:A[0]}:{type:"run",indices:[...A]}),r.jsxs(r.Fragment,{children:[w.map(S=>{if(S.type==="single"){const N=k[S.index];return Sr(N)?r.jsx("div",{className:"my-3",children:T(N,S.index)},`spacer-${S.index}`):T(N,S.index)}const E=S.indices.map(N=>T(k[N],N));return r.jsx("div",{className:"my-3",children:r.jsx(qh,{children:E})},`run-${S.indices[0]}`)}),r.jsx(Fg,{parts:k,sessionId:t,turnActive:e._streaming===!0})]})}const Mg=/^Please read the following uploaded file\(s\):\n((?:- .+\n)+)\n?/,Og=/^[a-f0-9]{8}-/,Ig=new Set(["png","jpg","jpeg","gif","webp","svg"]);function $g(e){const t=e.match(Mg);if(!t)return{files:[],textContent:e};const s=t[1].split(`
50
+ `).filter(a=>a.startsWith("- ")).map(a=>{var f;const i=a.slice(2).trim(),u=(i.split("/").pop()??i).replace(Og,""),d=((f=u.split(".").pop())==null?void 0:f.toLowerCase())??"";return{path:i,displayName:u,isImage:Ig.has(d)}}),o=e.slice(t[0].length).trim();return{files:s,textContent:o}}function Pg(e){var n;switch(((n=e.split(".").pop())==null?void 0:n.toLowerCase())??""){case"txt":case"md":case"log":return cd;case"ts":case"tsx":case"js":case"jsx":case"json":case"py":case"rs":case"go":return id;case"csv":case"xls":case"xlsx":return yd;case"png":case"jpg":case"jpeg":case"gif":case"webp":case"svg":return bd;default:return $o}}function Lg({files:e}){const t=oe(n=>n.selectedCwd);return e.length===0?null:r.jsx("div",{className:"flex flex-wrap gap-1.5 pb-1.5",children:e.map(n=>{const s=n.path.split("/").pop()??n.path;if(n.isImage){const a=`/api/uploads/${encodeURIComponent(s)}?cwd=${encodeURIComponent(t??"")}`;return r.jsx(W.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},children:r.jsx(lo,{image:{src:a,alt:n.displayName,downloadName:n.displayName},className:"block rounded-lg",children:r.jsx("img",{src:a,alt:n.displayName,loading:"lazy",className:"border-border/50 max-h-[120px] max-w-[200px] rounded-lg border object-contain"})})},n.path)}const o=Pg(n.displayName);return r.jsxs(W.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},className:"bg-muted flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[r.jsx(o,{className:"text-muted-foreground size-3 shrink-0"}),r.jsx("span",{className:"max-w-40 truncate",children:n.displayName})]},n.path)})})}function Bg({message:e}){var i;const t=(i=bp())==null?void 0:i.sessionId,[n,s]=c.useState(!1),o=c.useMemo(()=>$g(e.content),[e.content]),a=c.useMemo(()=>df(e.content),[e.content]);if(a)return r.jsx(cf,{action:a});if(e.chatMessages&&e.chatMessages.length>0)return r.jsx(tp,{stamps:e.chatMessages,...t?{sessionId:t}:{}});if(e.messageType==="command")return r.jsx("div",{className:"text-msg-command-fg font-mono text-sm break-words",children:e.content});if(e.messageType==="local_command_output")return r.jsx(ka,{content:e.content,toolName:""});if(e.messageType==="compaction"){const l=_p(e.compactMetadata),u=e.content.trim(),d=r.jsx("div",{className:"bg-border/40 h-px flex-1"});return u.length===0?r.jsxs("div",{"data-testid":"compaction-row",className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[d,r.jsx("span",{children:l}),d]}):r.jsxs("div",{className:"w-full","data-testid":"compaction-row",children:[r.jsxs("button",{onClick:()=>s(!n),className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[d,r.jsx(ls,{className:q("size-3 transition-transform duration-200",n&&"rotate-90")}),r.jsx("span",{children:l}),d]}),n&&r.jsx("div",{className:"text-msg-compaction-fg mt-2 text-xs whitespace-pre-wrap",children:e.content})]})}return r.jsxs("div",{children:[o.files.length>0&&r.jsx(Lg,{files:o.files}),o.textContent&&r.jsx("div",{className:"break-words whitespace-pre-wrap",children:o.textContent})]})}function zg({tasks:e,isCollapsed:t,onToggleCollapse:n}){const s=e.length,o=e.filter(l=>l.status==="completed").length,a=o===s&&s>0,i=s>0?o/s*100:0;return r.jsxs("button",{onClick:n,className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-2 text-xs",children:[t?r.jsx(ls,{className:"size-(--size-icon-xs) shrink-0"}):r.jsx(Dt,{className:"size-(--size-icon-xs) shrink-0"}),r.jsx("div",{className:"bg-muted h-0.5 flex-1 overflow-hidden rounded-full",children:r.jsx("div",{"data-slot":"progress-fill",className:`h-full rounded-full transition-[width,background-color] duration-300 ease-out ${a?"bg-green-500":"bg-blue-500"}`,style:{width:`${i}%`}})}),r.jsxs("span",{className:"shrink-0 tabular-nums",children:[o,"/",s," ",s===1?"task":"tasks"]})]})}function qg({activeForm:e,isCollapsed:t}){return r.jsx(ce,{children:e&&!t&&r.jsxs(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"mb-1 flex items-center gap-2 text-xs text-blue-400",children:[r.jsx(Le,{size:"xs",className:"shrink-0"}),r.jsx("span",{className:"truncate",children:e})]})})}const Ug={in_progress:"",pending:"waiting ",completed:"done "};function _r({tasks:e,onScrollToTask:t}){return r.jsx(r.Fragment,{children:e.map((n,s)=>r.jsxs("span",{children:[r.jsx("button",{onClick:o=>{o.stopPropagation(),t(n.id)},className:"hover:text-foreground underline decoration-dotted",children:n.subject}),s<e.length-1&&", "]},n.id))})}function Hg({task:e,taskMap:t,statusSince:n,onScrollToTask:s}){var d,f;const o=Po(n),a=Ug[e.status]??"",i=((d=e.blockedBy)==null?void 0:d.map(h=>t.get(h)).filter(h=>h!=null))??[],l=((f=e.blocks)==null?void 0:f.map(h=>t.get(h)).filter(h=>h!=null))??[],u=[];return n!==null&&u.push(r.jsxs("span",{children:[a,o.formatted]},"time")),e.owner&&u.push(r.jsx("span",{children:e.owner},"owner")),i.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["← ",r.jsx(_r,{tasks:i,onScrollToTask:s})]},"blocked-by")),l.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["→ ",r.jsx(_r,{tasks:l,onScrollToTask:s})]},"blocks")),r.jsxs(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"mt-0.5 ml-6 space-y-1",children:[e.description&&r.jsx("p",{className:"text-muted-foreground text-xs whitespace-pre-wrap",children:e.description}),u.length>0&&r.jsx("div",{className:"text-muted-foreground text-2xs flex flex-wrap items-center gap-1",children:u.map((h,m)=>r.jsxs("span",{className:"flex items-center gap-1",children:[m>0&&r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h]},m))})]})}const jr={in_progress:r.jsx(Le,{size:"xs",className:"text-status-info shrink-0"}),pending:r.jsx(Nl,{className:"text-muted-foreground size-(--size-icon-xs) shrink-0"}),completed:r.jsx(xo,{className:"text-status-success size-(--size-icon-xs) shrink-0"})};function Wg({task:e,isBlocked:t,isExpanded:n,onToggleExpand:s,onHover:o,isHighlightedAsDep:a,isHighlightedAsDependent:i,taskMap:l,statusSince:u,isCelebrating:d,onCelebrationComplete:f,onScrollToTask:h}){const m=g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),s())};return r.jsxs(W.li,{"data-task-id":e.id,children:[r.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,"data-task-id":e.id,onClick:s,onKeyDown:m,onMouseEnter:()=>o(e.id),onMouseLeave:()=>o(null),className:q("hover:bg-muted/40 focus-visible:bg-muted/40 relative flex items-center gap-2 rounded py-0.5 text-xs transition-colors",e.status==="completed"&&"text-muted-foreground/50 line-through",e.status==="in_progress"&&"text-foreground font-medium",e.status==="pending"&&!t&&"text-muted-foreground",e.status==="pending"&&t&&"text-muted-foreground/50",a&&"border-l-2 border-blue-400 pl-1.5",i&&"border-l-2 border-amber-400 pl-1.5",!a&&!i&&"border-l-2 border-transparent pl-1.5"),children:[d&&r.jsx(W.div,{"aria-hidden":"true",className:"absolute inset-0 rounded",initial:{backgroundPosition:"-200% 0"},animate:{backgroundPosition:"200% 0"},transition:{duration:.4,ease:"easeOut"},style:{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,215,0,0.2) 50%, transparent 100%)",backgroundSize:"200% 100%"}}),d?r.jsx(W.span,{initial:{scale:1},animate:{scale:[1,1.4,1]},transition:{type:"spring",stiffness:400,damping:10},onAnimationComplete:()=>f==null?void 0:f(),children:jr[e.status]}):jr[e.status],r.jsx("span",{className:"truncate",children:e.subject})]}),r.jsx(ce,{children:n&&r.jsx(Hg,{task:e,taskMap:l,statusSince:u,onScrollToTask:h})})]})}function Gg(e,t){var n;return(n=e.blockedBy)!=null&&n.length?e.blockedBy.some(s=>{const o=t.get(s);return o&&o.status!=="completed"}):!1}const Vg=10,Kg="max-h-[30svh] sm:max-h-[40svh]";function Qg({tasks:e,taskMap:t,activeForm:n,isCollapsed:s,onToggleCollapse:o,celebratingTaskId:a,onCelebrationComplete:i,statusTimestamps:l}){const[u,d]=c.useState(null),[f,h]=c.useState(null),m=c.useCallback(b=>{d(y=>y===b?null:b)},[]),g=c.useCallback(b=>{const y=document.querySelector(`[data-task-id="${b}"]`);y&&(y.scrollIntoView({behavior:"smooth",block:"nearest"}),y.classList.add("bg-blue-500/10"),setTimeout(()=>y.classList.remove("bg-blue-500/10"),1e3))},[]);if(e.length===0)return null;const x=e.slice(0,Vg),C=f?t.get(f):null;return r.jsxs("div",{className:"border-t px-4 py-2",children:[r.jsx(qg,{activeForm:n,isCollapsed:s}),r.jsx(zg,{tasks:e,isCollapsed:s,onToggleCollapse:o}),r.jsx(ce,{children:!s&&r.jsx(W.ul,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:q("mt-1 space-y-0.5 overflow-y-auto",Kg),children:x.map(b=>{var j,D;const y=b.id===a&&b.status==="completed",k=Gg(b,t),v=l.get(b.id),p=((j=C==null?void 0:C.blockedBy)==null?void 0:j.includes(b.id))??!1,_=((D=C==null?void 0:C.blocks)==null?void 0:D.includes(b.id))??!1;return r.jsx(Wg,{task:b,isBlocked:k,isExpanded:u===b.id,onToggleExpand:()=>m(b.id),onHover:h,isHighlightedAsDep:p,isHighlightedAsDependent:_,taskMap:t,statusSince:(v==null?void 0:v.since)??null,isCelebrating:y,onCelebrationComplete:i,onScrollToTask:g},b.id)})})})]})}function Yg({color:e}){const t=[{bx:"-8px",by:"-10px",delay:"0s"},{bx:"8px",by:"-8px",delay:"0.03s"},{bx:"-6px",by:"6px",delay:"0.06s"},{bx:"10px",by:"4px",delay:"0.09s"},{bx:"0px",by:"-12px",delay:"0.04s"},{bx:"-10px",by:"0px",delay:"0.07s"},{bx:"6px",by:"10px",delay:"0.05s"},{bx:"-4px",by:"-6px",delay:"0.08s"}];return r.jsx("div",{className:"pointer-events-none absolute inset-0",children:t.map((n,s)=>r.jsx("span",{className:"absolute top-1/2 left-1/2 size-[3px] rounded-full",style:{backgroundColor:e,"--bx":n.bx,"--by":n.by,animation:`burst-particle 0.5s ease-out ${n.delay} forwards`}},s))})}const Xg=350;function Jg({status:e,color:t}){return r.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24","data-status":e,children:[r.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:t,strokeWidth:"1.5",opacity:"0.3"}),e==="error"&&r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"8",y1:"9",x2:"14",y2:"15",stroke:t,strokeWidth:"2",strokeLinecap:"round"}),r.jsx("line",{x1:"14",y1:"9",x2:"8",y2:"15",stroke:t,strokeWidth:"2",strokeLinecap:"round"})]}),e==="untracked"&&r.jsx("line",{x1:"8",y1:"12",x2:"14",y2:"12",stroke:t,strokeWidth:"2",strokeLinecap:"round",opacity:"0.5"}),e!=="error"&&e!=="untracked"&&r.jsx("polyline",{points:"7,12 10,15 15,9",fill:"none",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Zg({agent:e,index:t}){const n=c.useMemo(()=>({animationDelay:`${t*.09}s`}),[t]),[s,o]=c.useState(e.status==="running"?"running":"done"),a=c.useRef(e.status),i=c.useRef(null);return c.useEffect(()=>{const l=a.current;if(a.current=e.status,l==="running"&&e.status!=="running"){o("celebrating"),i.current=setTimeout(()=>o("done"),Xg);return}l!=="running"&&e.status==="running"&&(i.current&&clearTimeout(i.current),i.current=null,o("running"))},[e.status]),c.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),s==="done"?r.jsx("div",{className:"relative inline-flex",children:r.jsx(Jg,{status:e.status,color:e.color})}):r.jsxs("div",{className:"group relative inline-flex",children:[r.jsx("svg",{className:"h-6 w-[22px] shrink-0",style:{"--c":e.color},viewBox:"0 0 22 24","aria-label":e.description,children:r.jsxs("g",{className:"r-all",style:n,children:[r.jsx("circle",{cx:"11",cy:"4.5",r:"2.8",fill:"var(--c)"}),r.jsx("circle",{cx:"12.3",cy:"3.7",r:"0.6",fill:"hsl(0 0% 100% / 0.7)"}),r.jsx("ellipse",{cx:"11",cy:"10.5",rx:"2.5",ry:"3.5",fill:"var(--c)"}),r.jsxs("g",{className:"r-rua",style:n,children:[r.jsx("line",{x1:"12",y1:"9",x2:"14",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-rfa",style:n,children:r.jsx("line",{x1:"14",y1:"11",x2:"14.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-lua",style:n,children:[r.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-lfa",style:n,children:r.jsx("line",{x1:"8",y1:"11",x2:"7.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-rt",style:n,children:[r.jsx("line",{x1:"11",y1:"14",x2:"13",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-rs",style:n,children:r.jsx("line",{x1:"13",y1:"17",x2:"13.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-lt",style:n,children:[r.jsx("line",{x1:"11",y1:"14",x2:"9",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-ls",style:n,children:r.jsx("line",{x1:"9",y1:"17",x2:"8.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]})]})}),s==="celebrating"&&r.jsx(Yg,{color:e.color}),s==="running"&&r.jsxs("div",{"data-testid":"agent-runner-tooltip",className:q("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2 hidden","-translate-x-1/2 translate-y-1 opacity-0 transition-[opacity,translate] duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-2xs shadow-lg md:block"),children:[r.jsxs("div",{className:"mb-0.5 flex items-center gap-1.5 font-semibold",children:[r.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.description]}),r.jsxs("div",{className:"text-muted-foreground text-3xs font-mono",children:[e.toolUses??0," tool calls · ",Math.round((e.durationMs??0)/1e3),"s"]}),e.lastToolName&&r.jsxs("div",{className:"text-muted-foreground/60 text-3xs mt-0.5 font-mono",children:["Last: ",e.lastToolName]}),r.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}function ex({bashTasks:e}){const t=Fe(),n=e.filter(o=>o.taskType==="bash"),s=n.length;return s===0?null:r.jsxs("div",{role:"status","aria-live":"polite","aria-label":`${s} bash task${s!==1?"s":""} running`,className:"flex items-center gap-1.5",children:[r.jsx(ce,{mode:"popLayout",children:n.map(o=>r.jsxs(W.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.25},className:"relative flex size-3 items-center justify-center",children:[o.status==="running"&&!t&&r.jsx("span",{className:"task-dot-tasks absolute inset-0 rounded-full opacity-40",style:{backgroundColor:o.color,animation:"task-dot-tasks 2s ease-in-out infinite"}}),r.jsx("span",{className:"relative size-1.5 rounded-full",style:{backgroundColor:o.color}})]},o.taskId))}),r.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[s," task",s!==1?"s":""]})]})}const tx=3e3;function nx({taskType:e,onConfirm:t}){const[n,s]=c.useState(!1),o=c.useRef(null);c.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),c.useEffect(()=>{if(n)return o.current=setTimeout(()=>{s(!1)},tx),()=>{o.current&&clearTimeout(o.current)}},[n]);const a=c.useCallback(()=>{if(e==="bash"){t();return}n?(o.current&&clearTimeout(o.current),s(!1),t()):s(!0)},[e,n,t]),i=c.useCallback(l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),a())},[a]);return r.jsx("button",{onClick:a,onKeyDown:i,className:q("flex shrink-0 items-center justify-center rounded transition-colors duration-150","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1",n?"bg-destructive/5 text-destructive hover:bg-destructive/10 text-3xs px-1.5 py-0.5 font-medium":"text-muted-foreground/40 hover:text-destructive size-4"),"aria-label":n?"Press again to stop task":"Stop task",tabIndex:0,children:n?"Stop?":r.jsx(it,{className:"size-3"})})}function wr({task:e,onStop:t}){const n=e.taskType==="agent"?e.description??"Background agent":e.command??"Background task",s=e.durationMs?Math.round(e.durationMs/1e3):0,o=e.status==="running";return r.jsxs("div",{className:q("flex items-center gap-2 rounded-md px-2 py-1 text-xs",o?"bg-muted":"bg-muted/50 opacity-60"),children:[r.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:e.color}}),r.jsx("span",{className:"text-muted-foreground/60 text-3xs shrink-0 tracking-wider uppercase",children:e.taskType}),r.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate",children:n}),e.taskType==="agent"&&e.toolUses!==void 0&&e.toolUses>0&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs shrink-0 font-mono",children:[e.toolUses," tools"]}),e.taskType==="agent"&&e.lastToolName&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs hidden max-w-24 shrink-0 truncate font-mono md:inline",children:["Last: ",e.lastToolName]}),s>0&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs shrink-0 font-mono",children:[s,"s"]}),o&&r.jsx(nx,{taskType:e.taskType,onConfirm:t})]})}function sx({tasks:e,ambientTasks:t=[],onStopTask:n}){return r.jsx(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"border-border overflow-hidden border-t px-2 py-1.5",children:r.jsxs("div",{className:"flex flex-col gap-1",children:[e.map(s=>r.jsx(wr,{task:s,onStop:()=>n(s.taskId)},s.taskId)),t.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-muted-foreground/60 text-3xs mt-1 px-2",children:[t.length," housekeeping task",t.length!==1?"s":""," the agent runs for itself"]}),t.map(s=>r.jsx(wr,{task:s,onStop:()=>n(s.taskId)},s.taskId))]})]})})}const Vn=4;function rx(e){return e==="stopped"?"complete":e}const ox="relative after:absolute after:-inset-x-1 after:-inset-y-2.5 md:after:hidden",Aa=[.16,1,.3,1],ax={width:{duration:.4,ease:Aa},opacity:{duration:.25}};function ix({tasks:e,onStopTask:t}){const[n,s]=c.useState(!1),o=Fe(),{shown:a,ambient:i}=zc(e),l=a.filter(b=>b.taskType==="agent"),u=a.filter(b=>b.taskType==="bash"),d=a.length,f=l.slice(0,Vn),h=l.length-Vn,m=l.reduce((b,y)=>b+(y.toolUses??0),0),g=Math.max(0,...a.map(b=>Math.round((b.durationMs??0)/1e3))),x=o?{duration:0}:{duration:.35,ease:Aa},C=d>0;return r.jsx(ce,{children:(d>0||i.length>0)&&r.jsxs(W.div,{...C?{role:"status","aria-live":"polite","aria-label":`${d} background task${d!==1?"s":""} running`}:{role:"group","aria-label":"Background tasks"},initial:{opacity:0,y:6,maxHeight:0},animate:{opacity:1,y:0,maxHeight:n?400:44},exit:{opacity:0,maxHeight:0},transition:x,className:"border-border bg-card overflow-hidden rounded-lg border",children:[r.jsxs("div",{className:"flex min-h-9 items-center gap-2 px-2 py-1.5",children:[l.length>0&&r.jsx(lx,{visibleAgents:f,overflowAgentCount:h,allAgentTasks:l}),l.length>0&&u.length>0&&r.jsx("div",{className:"bg-border h-4 w-px shrink-0"}),u.length>0&&r.jsx(ex,{bashTasks:u}),d>0&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[r.jsx("strong",{className:"text-foreground font-semibold",children:d})," task",d!==1?"s":""," running"]}),r.jsxs("span",{className:"text-muted-foreground/60 text-2xs ml-auto font-mono whitespace-nowrap",children:[m>0&&r.jsxs(r.Fragment,{children:[m," tools · "]}),g,"s"]})]}),r.jsxs("button",{type:"button",onClick:()=>s(b=>!b),className:q("text-muted-foreground hover:text-foreground flex shrink-0 items-center gap-1 transition-colors duration-150",d>0?"ml-1":"ml-auto",ox),"aria-label":n?"Collapse task details":"Expand task details","aria-expanded":n,children:[d>0&&r.jsx("span",{className:"text-3xs tabular-nums",children:d}),r.jsx(Dt,{className:q("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),r.jsx(ce,{children:n&&r.jsx(sx,{tasks:a,ambientTasks:i,onStopTask:t})})]},"background-task-bar")})}function lx({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return r.jsxs("div",{className:"flex items-center gap-0",children:[r.jsx(ce,{mode:"popLayout",children:e.map((s,o)=>r.jsx(W.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:ax,className:"shrink-0",children:r.jsx(Zg,{agent:{taskId:s.taskId,description:s.description??"",status:rx(s.status),color:s.color,toolUses:s.toolUses,lastToolName:s.lastToolName,durationMs:s.durationMs,summary:s.summary},index:o})},s.taskId))}),t>0&&r.jsx(cx,{count:t,overflowTasks:n.slice(Vn)})]})}function cx({count:e,overflowTasks:t}){return r.jsxs("div",{className:"group relative",children:[r.jsxs("div",{className:"text-muted-foreground bg-muted text-3xs flex size-6 shrink-0 items-center justify-center rounded-full font-semibold","aria-label":`${e} more helper${e===1?"":"s"} running`,children:["+",e]}),r.jsxs("div",{"data-testid":"overflow-badge-tooltip",className:q("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2 hidden","-translate-x-1/2 translate-y-1 opacity-0 transition-[opacity,translate] duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-2xs shadow-lg md:block"),children:[t.map(n=>r.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[r.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:n.color}}),r.jsx("span",{className:"text-3xs",children:n.description})]},n.taskId)),r.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}const Tn="after:absolute after:-inset-1 md:after:hidden";function ux({queue:e,editingId:t,onEdit:n,onRemove:s,onSend:o,onMoveUp:a,statusNote:i,onSwitchNow:l}){return e.length===0?null:r.jsxs(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"mb-1.5 overflow-hidden",children:[r.jsxs("div",{className:"text-muted-foreground mb-1 flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:"font-medium",children:["Queued (",e.length,")"]}),r.jsxs("span",{className:"truncate",children:["· ",i]})]}),r.jsx("div",{className:"space-y-0.5",children:r.jsx(ce,{mode:"popLayout",children:e.map((u,d)=>r.jsx(W.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,scale:.95,transition:{duration:.15}},layout:!0,children:r.jsxs("div",{className:q("group flex w-full items-center gap-2 rounded-md border-l-2 border-l-transparent pr-2 transition-colors md:gap-1",t===u.id?"border-l-primary bg-muted":"hover:bg-muted/50"),children:[r.jsxs("button",{type:"button",onClick:()=>n(u.id),"aria-current":t===u.id?!0:void 0,className:"focus-ring flex min-w-0 flex-1 items-center gap-2 rounded-md py-1.5 pl-3 text-left",children:[r.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs font-medium",children:[d+1,"."]}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"text-muted-foreground line-clamp-1 text-sm",children:u.content}),u.notice!==null&&r.jsx("span",{className:"text-muted-foreground/70 line-clamp-1 text-xs",children:u.notice}),u.waiting!==void 0&&r.jsx("span",{className:"text-muted-foreground/70 line-clamp-1 text-xs",children:u.waiting.line})]}),!u.mine&&r.jsxs("span",{className:"text-muted-foreground/60 flex shrink-0 items-center",title:"Queued from another window",children:[r.jsx(Bn,{className:"size-3","aria-hidden":"true"}),r.jsx("span",{className:"sr-only",children:"Queued from another window"})]})]}),u.waiting!==void 0&&l!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:l,title:u.waiting.switchHint,"aria-describedby":`switch-now-${u.id}`,className:"focus-ring text-muted-foreground hover:text-foreground shrink-0 rounded-sm px-1.5 py-1 text-xs font-medium transition-colors",children:"Switch now"}),r.jsx("span",{id:`switch-now-${u.id}`,className:"sr-only",children:u.waiting.switchHint})]}),d>0&&r.jsx("button",{type:"button",onClick:()=>a(u.id),className:q("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100",Tn),"aria-label":`Move queued message ${d+1} earlier`,children:r.jsx(El,{className:"size-3"})}),d>0&&r.jsx("button",{type:"button",onClick:()=>o(u.id),"aria-label":`Send queued message ${d+1} next`,className:q("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm transition-colors",Tn),children:r.jsx(qu,{className:"size-3"})}),r.jsx("button",{type:"button",onClick:()=>s(u.id),className:q("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100",Tn),"aria-label":`Remove queued message ${d+1}`,children:r.jsx(it,{className:"size-3"})})]})},u.id))})})]})}function dx({open:e,onOpenChange:t,queuedCount:n,onConfirm:s}){const o=n===1?"message":"messages";return r.jsx(Dl,{open:e,onOpenChange:t,children:r.jsxs(Tl,{children:[r.jsxs(Al,{children:[r.jsxs(Fl,{children:["Stop, and put ",n," queued ",o," back?"]}),r.jsxs(Rl,{children:["The agent stops. Your ",o," ",n===1?"goes":"go"," back to the composer."]})]}),r.jsxs(Ml,{children:[r.jsx(Ol,{children:"Keep going"}),r.jsx(Il,{onClick:s,children:"Stop"})]})]})})}const fx={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},mx={duration:.3,ease:"easeInOut"};function px({text:e,animationKey:t}){return r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-start overflow-hidden py-0.5",children:r.jsx(ce,{mode:"wait",children:r.jsx(W.span,{variants:fx,initial:"initial",animate:"animate",exit:"exit",transition:mx,className:"text-muted-foreground truncate text-sm",children:e},t)})})}function hx(e){const t=Ce();return Qe({queryKey:["workspace-for-session",e??null],queryFn:()=>t.resolveWorkspace(e),enabled:!!e}).data??null}async function Fa(e,t,n){try{return await e.runCommandIntent(t,"compact",n),!0}catch(s){const o=s.code==="SESSION_LOCKED";return Ee.error(o?"Your agent is busy. Try again in a moment.":"Couldn’t compact the chat."),!1}}const Kn=ss(e=>({open:!1,setOpen:t=>e({open:t}),reveal:()=>e({open:!0})})),gx=200,Qn=[{name:"rename",description:"Rename the current chat",argHint:"<new title>",run:(e,t)=>{const n=e.replace(/\s+/g," ").trim().slice(0,gx).trim();return n?t.sessionId?(t.renameSession(n),!0):(t.notify("No open chat to rename","error"),!1):(t.notify("Usage: /rename <new title>","error"),!1)}},{name:"clear",description:"Start a new chat here",run:(e,t)=>(t.startFreshSession(t.sessionId),!0)},{name:"context",description:"Show context usage and cost",run:(e,t)=>(t.focusUsageSurface(),!0)}],xx=/^\/(\S+)(?:\s+([\s\S]*))?$/;function Ra(e){const t=xx.exec(e);if(!t)return null;const n=t[1],s=(t[2]??"").trim(),o=us(n);if(o&&o.fulfillment==="client-native"){const i=Qn.find(l=>l.name===o.id);if(i)return{command:i,args:s}}const a=Qn.find(i=>i.name===n.toLowerCase());return a?{command:a,args:s}:null}const Nr=Qn.map(e=>({command:e.name,fullCommand:`/${e.name}`,description:e.description,argumentHint:e.argHint}));function Ma(e){const t=/^\/(\S+)([\s\S]*)$/.exec(e.trim());return t?{token:t[1],rest:t[2].trim()}:null}function bx(e){const t=Ma(e);return t?us(t.token)?!0:Ra(e.trim())!==null:!1}function yx(e,t,n={}){const{mutateAsync:s}=$l(e),o=Ce(),{startFreshSession:a,compact:i}=n,[l,u]=c.useState(0),d=c.useCallback(h=>{u(g=>g+1);const m=()=>u(g=>Math.max(0,g-1));h.then(m,m)},[]);return{tryRun:c.useCallback(h=>{const m=Ma(h),g=m?us(m.token):null;if(m&&(g==null?void 0:g.fulfillment)==="runtime"&&i){if(!i.supported)return Ee.error(`Compact isn’t available on ${i.runtimeLabel||"this agent"}`),{handled:!0,ran:!1};if(!t)return Ee.error("No open chat to compact"),{handled:!0,ran:!1};const y=Fa(o,t,m.rest||void 0);return d(y),{handled:!0,ran:!0,confirmed:y}}const x=Ra(h);if(!x)return{handled:!1};let C;return{handled:!0,ran:x.command.run(x.args,{sessionId:t,renameSession:y=>{t&&(C=s({sessionId:t,title:y}).then(()=>(Ee.success(`Renamed chat to “${y}”`),!0),()=>!1),d(C))},notify:(y,k)=>k==="error"?Ee.error(y):Ee.success(y),startFreshSession:y=>a==null?void 0:a(y),focusUsageSurface:()=>Kn.getState().reveal()}),...C?{confirmed:C}:{}}},[s,o,t,a,i,d]),commandPending:l>0}}function Oa(e,t){return{supported:(e==null?void 0:e.compact.supported)!==!1,runtimeLabel:t}}function Er(e){const t=e.trim().toLowerCase();return t.startsWith("/")?t:`/${t}`}function vx(e){return Ll.map(t=>{var s,o;const n=t.fulfillment==="runtime"&&((o=(s=e==null?void 0:e.commandIntents)==null?void 0:s[t.id])==null?void 0:o.supported)===!1;return{command:t.id,fullCommand:t.canonical,description:t.description,argumentHint:t.argumentHint,aliases:[...t.aliases],...n?{disabled:!0,disabledReason:`Not available on ${e.runtimeLabel}`}:{}}})}function kx(e,t){const n=Pl(),s=vx(t),o=Nr.filter(l=>!(l.command!==void 0&&n.has(`/${l.command}`))),a=new Set(Nr.map(l=>l.command)),i=e.filter(l=>{if(l.command!==void 0&&a.has(l.command))return!1;const u=[l.fullCommand,...l.aliases??[]].map(Er);return l.command!==void 0&&u.push(Er(l.command)),!u.some(d=>n.has(d))});return[...s,...o,...i]}const Cx=3e4;function Sx({percent:e,compactSupported:t,isStreaming:n}){return!(e===null||e<qc||!t||n)}function _x({sessionId:e,percent:t,compactSupported:n,isStreaming:s}){const o=Ce(),[a,i]=c.useState(!1),l=c.useRef(!1),u=c.useRef(null),d=c.useCallback(()=>{l.current=!1,i(!1),u.current!==null&&(clearTimeout(u.current),u.current=null)},[]);c.useEffect(()=>{s&&l.current&&d()},[s,d]),c.useEffect(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);const f=c.useCallback(()=>{l.current||!e||(l.current=!0,i(!0),u.current=setTimeout(()=>{u.current=null,l.current=!1,i(!1)},Cx),Fa(o,e).then(h=>{h||d()}))},[e,o,d]);return{visible:Sx({percent:t,compactSupported:n,isStreaming:s}),percent:t??0,pending:a,onCompact:f}}function jx({children:e,onSwitchAgent:t,onViewProfile:n,onNewSession:s}){return r.jsxs(Bl,{children:[r.jsx(zl,{className:"min-w-0",children:e}),r.jsxs(ql,{className:"w-48",children:[r.jsxs(mn,{onClick:t,children:[r.jsx(Ul,{className:"mr-2 size-4"}),"Switch agent"]}),r.jsx($s,{}),r.jsxs(mn,{onClick:n,children:[r.jsx(Hl,{className:"mr-2 size-4"}),"View profile"]}),r.jsx($s,{}),r.jsxs(mn,{onClick:s,children:[r.jsx(co,{className:"mr-2 size-4"}),"New chat"]})]})]})}function wx({agentName:e,agentColor:t,agentEmoji:n,agentPath:s,nameHidden:o}){const a=Wl(s),{open:i}=Gl(),l=c.useCallback(()=>{s&&Vl.getState().openProfileDocked(s)},[s]),u=c.useCallback(()=>{if(a===void 0)return l();i(a)},[a,i,l]),d=c.useCallback(()=>{oe.getState().openGlobalPaletteWithSearch("@")},[]),f=po(),h=c.useCallback(()=>{f(s??void 0)},[f,s]);return!e||!t||!n?null:r.jsx("span",{className:"inline-flex min-w-0 items-center",children:s?r.jsx(jx,{onSwitchAgent:d,onViewProfile:u,onNewSession:h,children:r.jsx(Ps,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,onClick:u,className:"max-w-full"})}):r.jsx(Ps,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,className:"max-w-full"})})}function Nx({sessionId:e,account:t}){const[n,s]=c.useState(!1),[o,a]=c.useState(!1),i=c.useRef(null);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:i,className:"contents",children:r.jsx(Kl,{sessionId:e,account:t,open:n,onOpenChange:s,onContinue:()=>{s(!1),a(!0)}})}),r.jsx(ea,{open:o,onOpenChange:a,sessionId:e,account:t,onCloseAutoFocus:l=>{var d;const u=(d=i.current)==null?void 0:d.querySelector("button");u&&(l.preventDefault(),u.focus())}})]})}function Ex({ctx:e,items:t}){return r.jsx("span",{className:"inline-flex min-w-0 items-center gap-2",children:t.map((n,s)=>{const o=n.component;return r.jsxs(c.Fragment,{children:[s>0&&r.jsx("span",{className:"text-muted-foreground/30 shrink-0","aria-hidden":"true",children:"·"}),r.jsx("span",{role:"group","aria-label":n.label,"data-testid":`extension-status-item-${n.id}`,className:"inline-flex min-w-0 items-center",children:r.jsx(ko,{fallback:null,onError:a=>Ia(n,a),children:r.jsx(o,{...e})})})]},n.id)})})}function Ia(e,t){console.warn(`[extensions] ${e.extensionId}'s status-bar item "${e.id}" failed to draw and is hidden.`,t)}function Dx({ctx:e,items:t}){return r.jsx(r.Fragment,{children:t.map(n=>{const s=n.component;return r.jsxs("div",{role:"group","aria-label":n.label,"data-testid":`session-row-extension-${n.id}`,className:"flex items-center gap-2 px-1 py-1 text-sm",children:[r.jsx("span",{className:"shrink-0",children:n.label}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("span",{className:"text-muted-foreground inline-flex min-w-0 items-center text-xs",children:r.jsx(ko,{fallback:null,onError:o=>Ia(n,o),children:r.jsx(s,{...e})})})]},n.id)})})}function Tx(e){const{costUsd:t,costBasis:n,...s}=e;return s}function Ax(e){var f;const{sessionId:t,agent:n,status:s,runtimeChip:o,onUpdateSession:a}=e,i={},l=e.density!=="full";n.name&&n.color&&n.emoji&&(i.agent=r.jsx(wx,{agentName:n.name,agentColor:n.color,agentEmoji:n.emoji,agentPath:n.path,nameHidden:e.density==="avatar"})),s.cwd&&(i.cwd=r.jsx(Uc,{cwd:s.cwd})),e.gitStatus&&(i.git=r.jsx(Jc,{data:e.gitStatus,workspace:e.workspace,compact:l})),o.runtime!==null&&(i.runtime=r.jsx(Hc,{runtime:o.runtime,model:o.model,onChangeRuntime:o.onChangeRuntime,canSelect:o.canSelect,account:o.account,compact:!0,iconOnly:Fo(e.density)}));const u=Co(e.account);u!==null&&(i.account=r.jsx(Nx,{sessionId:t,account:e.account})),e.extensions.items.length>0&&(i.extensions=r.jsx(Ex,{ctx:e.extensions.ctx,items:e.extensions.items})),i.model=r.jsx(Wc,{model:s.model,onChangeModel:h=>a({model:h}),effort:s.effort,onChangeEffort:h=>a({effort:h??void 0}),fastMode:s.fastMode,onChangeFastMode:h=>a({fastMode:h}),disabled:!t,sessionId:t||void 0,runtime:o.runtime,onCredits:e.account.onCredits,compact:l}),(f=e.plan)!=null&&f.active||(i.permission=r.jsx(Gc,{mode:s.permissionMode,onChangeMode:e.onChangeMode,disabled:!t,pending:!s.permissionModeKnown,runtime:o.runtime,modelSupportsAutoMode:e.modelSupportsAutoMode,compact:l,makeDefault:e.makeDefault,onOpenChange:e.onPermissionPickerOpenChange})),e.plan&&(i.plan=r.jsx(Vc,{descriptor:e.plan.descriptor,active:e.plan.active,onToggle:e.plan.onToggle,disabled:!t})),e.contextPercent!==null&&(i.context=r.jsx(Kc,{percent:e.contextPercent,contextUsage:e.contextUsage,compact:e.compact,reading:e.contextReading}));const d=e.usage&&e.usageSource==="account"&&!e.supportsCostTracking?Tx(e.usage):e.usage;return d&&Ql(d)&&(e.supportsCostTracking||e.usageSource==="account")&&!Qc({account:u})&&(i.usage=r.jsx(Yl,{usage:d,observedAt:e.usageObservedAt,now:e.now})),e.liveSubagentCount>0&&(i.subagents=r.jsx(Yc,{count:e.liveSubagentCount,running:e.runningSubagents,waiting:e.waitingOnSubagents})),i.connection=r.jsx(Xc,{connectionState:e.connectionState,compact:l}),i}const Fx=[],Rx="(max-width: 639px)";function Mx({sessionId:e,sessionStatus:t,isStreaming:n,syncConnectionState:s,agentName:o,agentColor:a,agentEmoji:i,agentPath:l}){var Be,Me;const{ref:u,budget:d}=Zc(),f=Xl(),h=So(e),m=Ro(e,t,n,h.runtime),g=Nt(e||null),{pins:x}=eu(),C=tu(e),b=nu(e,g,C.usage),y=b.usage,k=jt(),v=new Date(k),p=Jl(y,b.observedAt,v),_=C.contextUsage,j=((Be=ds(e))==null?void 0:Be.contextUsage)??null,D=Kn(se=>se.open),T=Kn(se=>se.setOpen),{data:w}=su(m.cwd),A=hx(m.cwd),{project:S}=Zl(m.cwd),E=ec(Rx),N=c.useMemo(()=>({sessionId:e,cwd:m.cwd,project:S,trackerItems:g.trackerItems,compact:E}),[e,m.cwd,S,g.trackerItems,E]),R=ru(N),{data:M}=as(),F=ou(C.activeSubagents).running,O=C.runningSubagentCount??F.length,{data:L}=os({sessionId:e||void 0,runtime:h.runtime??void 0}),G=((Me=L==null?void 0:L.find(se=>se.value===m.model))==null?void 0:Me.supportsAutoMode)??!1,V=tn(h.runtime),Q=(V==null?void 0:V.permissionModes.values)??Fx,U=V==null?void 0:V.permissionModes.default,I=tc(e),P=re(se=>se.recordAutoConfirmed),[$,K]=c.useState(!1),ue=au({sessionId:e,runtime:h.runtime,declaredModes:Q,runtimeDefaultMode:U}),[z,X]=c.useState(!1),J=c.useCallback(se=>m.updateSession({permissionMode:se}),[m]),ae=c.useCallback(se=>{if(se==="auto"&&!I){K(!0);return}J(se).then(Se=>{Se&&ue.offerFor(se)})},[I,J,ue,K]),ve=c.useCallback(()=>{P(e),J("auto"),K(!1)},[P,e,J,K]),H=nc(Q),ie=H!==void 0&&m.permissionMode===H.id,_e=sc(e),be=re(se=>se.recordModeBeforePlan),Y=c.useCallback(se=>{if(!H)return;if(se){be(e,m.permissionMode),J(H.id);return}const Se=_e,ze=Se!==void 0&&Q.some(pe=>pe.id===Se)&&(Se!=="auto"||G)?Se:U;ze&&J(ze)},[H,be,e,m,J,_e,Q,G,U]),De=h.runtime?Tt(h.runtime).label:"",Te=Oa(V==null?void 0:V.commandIntents,De),ke=C.contextPercent,fe=_x({sessionId:e,percent:ke,compactSupported:Te.supported,isStreaming:n}),[ee,Z]=c.useState(!1);iu(()=>Z(se=>!se));const ne={cwd:m.cwd,git:lu(w)?cu(w.branch,w.clean,w.detached):null,contextPercent:ke,connectionState:s,permissionMode:m.permissionMode,permissionDescriptor:(V==null?void 0:V.permissionModes.values.find(se=>se.id===m.permissionMode))??null,permissionPickerOpen:z,onWifi:f,plan:H?{active:ie}:null,runtime:h.runtime===null||M===void 0?null:{type:h.runtime,isDefault:h.runtime===M.defaultRuntime,canSelect:h.canSelect},account:Co(g),usage:y,usageStale:p,subagentsInFlight:O,extensionItems:R.promotion},de=fe.visible&&d.density==="full",he=fe.visible&&!de,ye=Ax({sessionId:e,agent:{name:o,color:a,emoji:i,path:l},status:m,onUpdateSession:m.updateSession,onChangeMode:ae,makeDefault:z?ue.line:null,onPermissionPickerOpenChange:X,modelSupportsAutoMode:G,plan:H?{descriptor:H,active:ie,onToggle:Y}:null,gitStatus:w,workspace:A,runtimeChip:h,account:g,contextPercent:ke,contextUsage:_,contextReading:j,compact:de?{pending:fe.pending,onCompact:fe.onCompact}:null,usage:y,usageSource:b.source,usageObservedAt:b.observedAt,now:v,supportsCostTracking:(V==null?void 0:V.supportsCostTracking)??!0,runningSubagents:F,liveSubagentCount:O,waitingOnSubagents:C.lifecycle==="idle",connectionState:s,density:d.density,extensions:{ctx:N,items:R.visible}}),{items:ge,overflow:Re}=uu(du({ctx:ne,pins:x,nodes:ye,density:d.density}),d);return r.jsxs("div",{ref:u,className:"relative pt-2",children:[!z&&ue.line&&r.jsx(fu,{...ue.line,placement:"overlay"}),r.jsx(mu,{items:ge,nameFirst:Fo(d.density),trailing:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(pu,{compact:d.density!=="full"}),r.jsx(hu,{open:ee,onOpenChange:Z,diagnostics:C,controls:{plan:H?{active:ie,onToggle:Y}:null},promotionContext:ne,overflowCount:Re,addOns:R.visible.length>0?r.jsx(Dx,{ctx:N,items:R.visible}):void 0,urgentAction:he?{label:`Compact chat · ${fe.percent}% full`,onAction:fe.onCompact,pending:fe.pending}:null})]})}),r.jsx(gu,{usage:y??null,accountUsage:b.accountUsage,observedAt:b.observedAt,open:D,onOpenChange:T}),r.jsx(xu,{open:$,onOpenChange:K,onConfirm:ve})]})}const Ox=Object.freeze({completed:"Completed",aborted_tools:"Tool stopped",aborted_streaming:"Reply stopped",max_turns:"Turn limit reached",blocking_limit:"Blocking limit",rapid_refill_breaker:"Rate limit",prompt_too_long:"Prompt too long",image_error:"Image error",model_error:"Model error",stop_hook_prevented:"Stopped by hook",hook_stopped:"Hook stopped",tool_deferred:"Tool deferred"});function Ix(e){return e!==void 0&&e!=="completed"}function $x(e){const t=Ox[e];return t!==void 0?t:Px(e)}function Px(e){if(e.length===0)return"Ended";const t=e.replace(/[_-]+/g," ").trim().split(/\s+/);if(t.length===0)return"Ended";const[n,...s]=t;return[n.charAt(0).toUpperCase()+n.slice(1).toLowerCase(),...s.map(a=>a.toLowerCase())].join(" ")}function Lx({terminalReason:e}){const t=Ix(e),n=t?$x(e):"";return r.jsx(ce,{children:t&&r.jsx(W.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,ease:"easeOut"},className:"flex px-4 py-1","data-testid":"terminal-reason-chip",children:r.jsx(rc,{variant:"secondary","aria-label":`Chat ended: ${n}`,children:n})},e)})}const Bx="The turn ended before completing.";function zx({sessionId:e,onRetry:t,onSigninComplete:n,onChooseModel:s}){var m;const o=sn(e),a=((m=ds(e))==null?void 0:m.lastError)??null,i=(a==null?void 0:a.category)==="auth_error"||(a==null?void 0:a.category)==="model_unavailable"||(a==null?void 0:a.category)==="runtime_update_required",l=!i&&o?`${Tt(o).label} stopped unexpectedly`:void 0,u=(a==null?void 0:a.message)??Bx,d=i?void 0:u,f=o?is(o):void 0,h=a?[a.code,a.details].filter(Boolean).join(`
51
+ `):void 0;return r.jsx(W.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:.3,duration:.2,ease:"easeOut"},className:"mx-4 mb-2","data-testid":"turn-failed-notice",children:r.jsx(on,{category:(a==null?void 0:a.category)??"execution_error",heading:l,message:u,subtext:d,details:h||void 0,onRetry:t,onSigninComplete:n,onChooseModel:s,runtimeLabel:f,sessionId:e,...a!=null&&a.code?{code:a.code}:{},...a!=null&&a.reason?{reason:a.reason}:{}})})}const qx=["Type @ to mention a file","Type / to browse commands","End a line with \\ to keep typing","Drop or paste files to attach"];function Ux(e,t,n){const s=c.useCallback(x=>{var k;if(!e||!t.current)return;const C=re.getState(),b=(k=n.current)==null?void 0:k.get(e);if(b!==void 0&&C.getSession(e).mountGeneration!==b)return;const y=typeof x=="function"?x(C.getSession(e).messages):x;C.updateSession(e,{messages:y})},[e,t,n]),o=c.useCallback(x=>{e&&re.getState().updateSession(e,{input:x})},[e]),a=c.useCallback(x=>{e&&re.getState().updateSession(e,{status:x})},[e]),i=c.useCallback(x=>{e&&re.getState().updateSession(e,{error:x})},[e]),l=c.useCallback(x=>{e&&re.getState().updateSession(e,{sessionStatus:x})},[e]),u=c.useCallback(x=>{e&&re.getState().updateSession(e,{estimatedTokens:x})},[e]),d=c.useCallback(x=>{e&&re.getState().updateSession(e,{streamStartTime:x})},[e]),f=c.useCallback(x=>{e&&re.getState().updateSession(e,{isTextStreaming:x})},[e]),h=c.useCallback(x=>{e&&re.getState().updateSession(e,{systemStatus:x})},[e]),m=c.useCallback(x=>{e&&re.getState().updateSession(e,{operationProgress:x})},[e]),g=c.useCallback(x=>{e&&re.getState().updateSession(e,{promptSuggestions:x})},[e]);return{setMessages:s,setInput:o,setStatus:a,setError:i,setSessionStatus:l,setEstimatedTokens:u,setStreamStartTime:d,setIsTextStreaming:f,setSystemStatus:h,setOperationProgress:m,setPromptSuggestions:g}}function Hx({sessionId:e,sid:t,transport:n,sessionCwd:s,enableMessagePolling:o,isStreaming:a,streamHydrated:i,setMessages:l}){const u=Lo(),d=s.cwd,f=c.useRef(d);c.useEffect(()=>{f.current=d},[d]);const h=c.useRef(i);c.useEffect(()=>{h.current=i},[i]);const m=Qe({queryKey:["messages",e,d],queryFn:()=>n.getMessages(e,d??void 0,{newest:!0}),staleTime:Ve.MESSAGE_STALE_TIME_MS,refetchOnWindowFocus:!1,enabled:e!==null&&!i,refetchInterval:()=>a||!o?!1:u?Ve.ACTIVE_TAB_REFETCH_MS:Ve.BACKGROUND_TAB_REFETCH_MS});return c.useEffect(()=>{const g=re.getState();t&&g.updateSession(t,{historySeeded:!1}),g.getSession(e??"").status!=="streaming"&&l([])},[e,d,t,l]),c.useEffect(()=>{if(!m.data)return;const g=m.data.messages,x=re.getState().getSession(t).historySeeded;if(!x&&g.length>0){if(a)return;if(t&&re.getState().updateSession(t,{historySeeded:!0}),e&&!h.current){const C=m.data.earlierMessages??0;Pe.getState().noteSnapshot(e,g[0].id,C)}l(g.map(ot));return}x&&!a&&fp(re.getState().getSession(t).messages,g,l)},[m.data,a,e,t,l]),{historyQuery:m}}function $a(e,t){if(e===t)return;const{opened:n,counts:s,mergeUsage:o}=at.getState(),a=Ls("session",e),i=Date.parse(n[a]??"");Number.isNaN(i)||o([{key:Ls("session",t),lastUsedAt:i,useCount:s[a]??1}])}function Yn(e,t,n){e&&n.then(s=>{if(!s)return;const o=re.getState();o.getSession(e).input.trim()===t.trim()&&o.updateSession(e,{input:""})},()=>{})}const Lt=new Map;function Wx(e,t){const s=(Lt.get(e)??Promise.resolve()).then(t),o=s.then(()=>{},()=>{});return Lt.set(e,o),o.then(()=>{Lt.get(e)===o&&Lt.delete(e)}),s}const tt=new Set;function Dr(e){var o;const t=e,n=typeof(t==null?void 0:t.code)=="string"?t.code:void 0,s=(o=t==null?void 0:t.body)==null?void 0:o.agentId;return{...n?{code:n}:{},...typeof s=="string"?{agentId:s}:{}}}function Gx({sessionId:e,input:t,status:n,transport:s,queryClient:o,selectedCwd:a,onSessionIdChangeReplace:i,transformContent:l,launchRuntime:u,agentPath:d,agentLookupPending:f,agentLookupFailed:h,launchAccount:m,takeSeedContext:g,setInput:x,setError:C,tryNativeCommand:b}){const y=c.useRef(a);c.useEffect(()=>{y.current=a},[a]);const k=c.useRef(u);c.useEffect(()=>{k.current=u},[u]);const v=c.useRef(m);c.useEffect(()=>{v.current=m},[m]);const{data:p}=as(),_=c.useRef(p==null?void 0:p.defaultRuntime);c.useEffect(()=>{_.current=p==null?void 0:p.defaultRuntime},[p==null?void 0:p.defaultRuntime]);const j=bu(e,u),D=c.useRef(j.mode);c.useEffect(()=>{D.current=j.mode},[j.mode]);const T=c.useRef(l);c.useEffect(()=>{T.current=l});const w=c.useRef(g);c.useEffect(()=>{w.current=g});const A=c.useRef(i);c.useEffect(()=>{A.current=i});const S=c.useCallback(async(U,I,P={})=>{var ie,_e,be;if(!P.kickoff){const Y=b(U);if(Y.handled){I&&Y.ran&&(Y.confirmed?Yn(e,U,Y.confirmed):x(""));return}}const $=e,K=P.cwd??y.current;C(null);const ue=o.getQueryData(Ge.list(K))??[],z=pn($),X=(z==null?void 0:z.draft)??!ue.some(Y=>Y.id===$),J=(z==null?void 0:z.draft)===!1?!1:X||tt.has($);if(J&&(f||h))return;J&&tt.add($),P.kickoff||(at.getState().recordOpened("session",$),K&&at.getState().recordOpened("agent",K)),bt.attachSession($,K);let ae;try{ae=!P.kickoff&&T.current?await T.current(U):U}catch(Y){if(P.kickoff)throw Y;C({heading:"Couldn’t send message",message:Y.message||"The attachment didn’t upload. Try again.",retryable:!1});return}const ve=je.getState();if(X){const Y=new Date().toISOString();Bs(o,K,{id:$,title:`Chat ${$.slice(0,8)}`,createdAt:Y,updatedAt:Y,permissionMode:((ie=o.getQueryData(Ge.detail($,K)))==null?void 0:ie.permissionMode)??D.current??"default",runtime:k.current??_.current??"claude-code"})}const H=crypto.randomUUID();P.kickoff||ve.setOptimisticUserMessage($,{id:H,content:U}),ve.setTriggerPending($,!0),I&&x("");try{const Y=zs(oe.getState(),K??null),{uiState:De,commit:Te}=qs($,Y),fe={clientMessageId:H,context:De?{uiState:De}:void 0};J&&(fe.create=!0),J&&k.current&&(fe.runtime=k.current),J&&d&&(fe.agentPath=d),J&&v.current&&(fe.account=v.current);const ee=oe.getState().retryAccount;(ee==null?void 0:ee.sessionId)===$&&(fe.account=ee.id,oe.getState().setRetryAccount(null));const Z=(_e=w.current)==null?void 0:_e.call(w);Z&&(fe.seedContext=Z);const{sessionId:ne}=await s.postMessage($,ae,K??void 0,fe);if(tt.delete($),z){const he={...z,draft:!1};hn($,he),hn(ne,he)}if(Te(ne),ne!==$){je.getState().migrateSessionContinuity($,ne),oe.getState().carryCanvasWritesAcross($,ne),bt.attachSession(ne,K),$a($,ne),nt.getState().migrate($,ne);const he=o.getQueryData(Ge.list(K))??[],ye=he.find(ge=>ge.id===$);ye&&!he.some(ge=>ge.id===ne)&&Bs(o,K,{...ye,id:ne}),o.setQueryData(Ge.list(K),ge=>ge==null?void 0:ge.filter(Re=>Re.id!==$))}(be=A.current)==null||be.call(A,ne);const de=ne;setTimeout(()=>{var ge;const he=yt.getState().rekeys[de]??de,ye=je.getState().getSession(he);ye.triggerPending&&((ge=ye.status)==null?void 0:ge.lifecycle)!=="streaming"&&je.getState().setTriggerPending(he,!1)},en.TRIGGER_PENDING_TIMEOUT_MS)}catch(Y){if(je.getState().setOptimisticUserMessage($,null),je.getState().setTriggerPending($,!1),P.kickoff)throw Y;C({heading:"Couldn’t send message",message:Y.message||"Couldn’t reach DorkOS. Try again.",retryable:!0,...Dr(Y)})}},[e,s,o,x,C,b,d,f,h]),E=c.useCallback(async(U,I)=>{!U.trim()||n==="streaming"||await S(U.trim(),(I==null?void 0:I.clearInput)===!0,{...I!=null&&I.cwd?{cwd:I.cwd}:{}})},[n,S]),N=c.useCallback(()=>E(t,{clearInput:!0}),[t,E]),R=c.useCallback(async(U,I,P)=>{if(!e)return!1;const $=e,K=y.current;C(null);const ue=(o.getQueryData(Ge.list(K))??[]).some(X=>X.id===$),z=pn($);return((z==null?void 0:z.draft)??!ue)&&tt.add($),Wx($,async()=>{var J;let X;try{X=T.current?await T.current(U):U}catch(ae){return C({heading:P,message:ae.message||"The attachment didn’t upload. Try again.",retryable:!1}),!1}try{const ae=zs(oe.getState(),K??null),{uiState:ve,commit:H}=qs($,ae),ie={...ve?{uiState:ve}:{},...I==="queue"?{queued:!0}:{}},_e=Object.keys(ie).length>0?ie:void 0,be=((J=pn($))==null?void 0:J.draft)===!1?!1:tt.has($);if(be&&(f||h))return!1;const{sessionId:Y}=await s.postMessage($,X,K??void 0,{context:_e,disposition:I,...be?{create:!0,...k.current&&{runtime:k.current},...v.current&&{account:v.current},...d&&{agentPath:d}}:{}});return be&&tt.delete($),z&&hn(Y,{...z,draft:!1}),H(Y),!0}catch(ae){return C({heading:P,message:ae.message||"Couldn’t reach DorkOS. Try again.",retryable:!1,...Dr(ae)}),!1}})},[e,s,o,C,d,f,h]),M=c.useCallback(U=>R(U,"queue","Couldn’t queue message"),[R]),F=c.useCallback(U=>R(U,"steer","Couldn’t steer the agent"),[R]),O=c.useCallback(U=>R(U,"stage","Couldn’t add context"),[R]),L=c.useCallback(async()=>{if(!e)return{receipt:{outcome:"not-running",reason:"no-open-turn",runtime:"unknown"},cancelled:[]};try{const{receipt:U,cancelledQueued:I}=await s.interruptSession(e);return{receipt:U,cancelled:I??[]}}catch{return{receipt:{outcome:"failed",reason:"delivery-failed",runtime:"unknown"},cancelled:[]}}},[e,s]),G=c.useCallback(async U=>{C(null),await S(U,!1)},[S,C]),V=c.useCallback(async(U,I)=>{await S(U,!1,{kickoff:!0,...I?{cwd:I}:{}})},[S]),Q=c.useCallback((U,I)=>{},[]);return{handleSubmit:N,submitContent:E,enqueueContent:M,steerContent:F,addContextContent:O,stop:L,retryMessage:G,submitKickoff:V,markToolCallResponded:Q}}const Bt=new Set,Tr=new Set,zt=new Set;function Vx(e){var t;return e.role==="user"||e.content.trim().length>0||(((t=e.toolCalls)==null?void 0:t.length)??0)>0?!0:e.parts.some(n=>n.type==="tool_call")}function Kx({sessionId:e,cwd:t,status:n,messages:s,hydrated:o,canStart:a=!0,submitKickoff:i,submitContent:l}){const u=Zt(e),d=s.length,f=s.some(Vx);c.useEffect(()=>{if(!e)return;if(!u){t&&d===0&&n==="idle"&&nt.getState().claimByPath(t,e);return}if(u.fired||Bt.has(e)||!a||d>0||n!=="idle")return;Bt.add(e),nt.getState().markFired(e);const h=u.kind==="first-message";(h?l:i)(u.kickoffMessage,u.path||void 0).catch(g=>{console.warn("[chat] first-turn trigger failed for newborn session",e,g),Tr.has(e)?h||nt.getState().markGreetingFailed(e):(Tr.add(e),Bt.delete(e),nt.getState().resetFired(e))})},[e,t,u,n,d,a,i,l]),c.useEffect(()=>{if(!(!e||!u)&&u.kind!=="first-message"&&!(!u.fired&&!Bt.has(e))&&!u.greetingFailed){if(f){zt.delete(e);return}if(n==="streaming"){zt.add(e);return}o&&zt.has(e)&&(zt.delete(e),nt.getState().markGreetingFailed(e))}},[e,u,n,f,o])}function Qx(e,t){return c.useEffect(()=>{oc(),bt.connectList(),e&&bt.attachSession(e,t)},[e,t]),c.useEffect(()=>()=>bt.releaseSession(),[]),_o(e??"")}function Yx(e,t){const n=jo(e),s=c.useRef(t);c.useEffect(()=>{s.current=t}),c.useEffect(()=>{var o;!n||!e||($a(e,n),(o=s.current)==null||o.call(s,n))},[n,e])}const Xx=500;function Jx(e,t,n){const s=c.useRef(new Map),[o,a]=c.useState(null),i=t.length>0?t[0].seq:-1;c.useEffect(()=>{const h=s.current;if(!e||!n){e&&h.delete(e),a(null);return}let m=h.get(e);(!m||m.turnSeq!==i)&&(m={turnSeq:i,anchor:Date.now()},h.set(e,m)),a(m.anchor)},[e,n,i]);const l=c.useMemo(()=>{let h=0;for(const m of t)m.type==="text_delta"&&(h+=m.text.length);return h/4},[t]),[u,d]=c.useState(!1),f=c.useRef({sid:null,tokens:0});return c.useEffect(()=>{const h=f.current,m=e===h.sid&&l>h.tokens;if(f.current={sid:e,tokens:l},m&&!u&&d(!0),!m&&!u)return;const g=setTimeout(()=>d(!1),Xx);return()=>clearTimeout(g)},[e,l,u]),{streamStartTime:o,estimatedTokens:l,isTextStreaming:u}}function Zx(e,t,n,s){const o=c.useRef(new Map),a=c.useRef(s);c.useEffect(()=>{a.current=s}),c.useEffect(()=>{var d;if(!e)return;const i=o.current,l=n??0;let u=i.get(e);(!u||u.floor!==l)&&(u={floor:l,seen:l},i.set(e,u));for(const f of t)f.seq<=u.seen||(f.type==="todo_update"&&((d=a.current)==null||d.call(a,{action:f.action,task:f.task,tasks:f.tasks,previousId:f.previousId})),u.seen=f.seq)},[e,t,n])}function e0(e){let t=null,n=null;for(const s of e){if(s.type==="operation_progress"){t=s.state==="started"?{operation:s.operation,determinate:s.determinate,...s.percent!==void 0?{percent:s.percent}:{},...s.message!==void 0?{message:s.message}:{}}:null;continue}if(s.type==="system_status"){(!s.status||s.status===ac)&&(n={message:s.message});continue}n=null}return{operationProgress:t,systemStatus:n}}function t0(e,t){return e===null||t===null?e===t:e.operation===t.operation&&e.determinate===t.determinate&&e.percent===t.percent&&e.message===t.message}function n0(e,t){return((e==null?void 0:e.message)??null)===((t==null?void 0:t.message)??null)}function s0(e,t,n,s){const o=c.useRef(new Map),a=c.useRef(new Map),i=c.useRef(n),l=c.useRef(s);c.useEffect(()=>{i.current=n,l.current=s}),c.useEffect(()=>{if(!e)return;const{operationProgress:u,systemStatus:d}=e0(t),f=o.current.get(e)??null;t0(f,u)||(i.current(u),o.current.set(e,u));const h=a.current.get(e)??null;n0(h,d)||(l.current(d),a.current.set(e,d))},[e,t])}function r0(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="capability_approval"&&s.approval.approvalId===t)return s}}function o0(e,t){const n=r0(e,t.approval.approvalId);n?n.approval=t.approval:e.push({type:"capability_approval",approval:t.approval})}function a0(e,t){const n=e.findIndex(o=>o.type==="capability_approval"&&o.approval.approvalId===t.approvalId);if(n===-1)return;if(t.outcome!=="timeout"){e.splice(n,1);return}const s=e[n];s.outcome="timeout"}function i0(e,t,n){return e.findIndex(s=>s.type==="mcp_signin"&&s.agentId===t&&s.serverName===n&&s.outcome===void 0)}function l0(e,t){const n={type:"mcp_signin",serverName:t.serverName,agentId:t.agentId,flowId:t.flowId,authorizeUrl:t.authorizeUrl,disclosure:t.disclosure},s=i0(e,t.agentId,t.serverName);s===-1?e.push(n):e[s]=n}function c0(e,t){const n=e.findIndex(o=>o.type==="mcp_signin"&&o.flowId===t.flowId);if(n===-1)return;const s=e[n];s.outcome=t.outcome,t.toolCount!==void 0&&(s.toolCount=t.toolCount)}function u0(e){return e.type==="interaction_resolved"||e.type==="capability_approval_resolved"||e.type==="mcp_signin_resolved"}function d0(e){const t=new Set;for(const n of e)n.type==="interaction_resolved"&&t.add(n.id);return t}const Ar="__in_progress_turn__",f0="__optimistic_user__";function m0(e){return{id:f0,role:"user",content:e,parts:[{type:"text",text:e}],timestamp:"",_streaming:!0}}function p0(e){return{id:`steer-${e.messageId}`,role:"user",content:e.content,parts:[{type:"text",text:e.content}],timestamp:"",_streaming:!0,...e.chatMessages&&e.chatMessages.length>0?{chatMessages:e.chatMessages}:{}}}function h0(e){return{id:`staged-${e.messageId}`,role:"user",content:e.content,parts:[{type:"text",text:e.content}],timestamp:"",_streaming:!0,_stagedContext:!0}}function $e(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="tool_call"&&s.toolCallId===t)return s}}function cn(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="elicitation"&&s.interactionId===t)return s}}function g0(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="background_task"&&s.taskId===t)return s}}function x0(e,t){Pa(e);const n=e[e.length-1];n&&n.type==="text"?n.text+=t.text:e.push({type:"text",text:t.text})}function b0(e,t){const n=e[e.length-1];n&&n.type==="thinking"&&n.isStreaming?n.text+=t.text:e.push({type:"thinking",text:t.text,isStreaming:!0})}function Pa(e){for(const t of e)t.type==="thinking"&&t.isStreaming&&(t.isStreaming=!1)}function y0(e,t,n){const s=$e(e,t.toolCallId);if(s){t.input!==void 0&&(s.input=(s.input??"")+t.input);return}const o=n.get(t.toolCallId);n.delete(t.toolCallId),e.push({type:"tool_call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input??"",status:t.status,...o&&o.length>0?{hooks:o}:{}})}function v0(e,t){const n=$e(e,t.toolCallId);n?(n.result=t.result,n.status=t.status,t.ui!==void 0&&(n.ui=t.ui),t.result!==void 0&&(n.progressOutput=void 0)):e.push({type:"tool_call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input??"",result:t.result,status:t.status,...t.ui!==void 0?{ui:t.ui}:{}})}function k0(e,t){const n=$e(e,t.toolCallId);n&&(n.progressOutput=(n.progressOutput??"")+t.content)}function La(e,t){const n={interactiveType:"approval",input:t.input,status:"pending",timeoutMs:t.timeoutMs,approvalStartedAt:t.startedAt,approvalRemainingMs:t.remainingMs,approvalTitle:t.title,approvalDisplayName:t.displayName,approvalDescription:t.description,approvalBlockedPath:t.blockedPath,approvalDecisionReason:t.decisionReason,approvalHasSuggestions:t.hasSuggestions,approvalAlwaysAllowScope:t.alwaysAllowScope},s=$e(e,t.id);s?Object.assign(s,n):e.push({type:"tool_call",toolCallId:t.id,toolName:t.toolName,...n})}function Ba(e,t){const n=$e(e,t.id),s={timeoutMs:t.timeoutMs,approvalStartedAt:t.startedAt,approvalRemainingMs:t.remainingMs};n?(n.interactiveType="question",n.questions=t.questions,n.status="pending",Object.assign(n,s)):e.push({type:"tool_call",toolCallId:t.id,toolName:"AskUserQuestion",input:"",status:"pending",interactiveType:"question",questions:t.questions,...s})}function za(e,t){const n={serverName:t.serverName,message:t.message,mode:t.mode,url:t.url,elicitationId:t.elicitationId,requestedSchema:t.requestedSchema,status:"pending",startedAt:t.startedAt,remainingMs:t.remainingMs,timeoutMs:t.timeoutMs},s=cn(e,t.id);s?Object.assign(s,n):e.push({type:"elicitation",interactionId:t.id,...n})}function C0(e){return e==="denied"||e==="expired"||e==="cancelled"?"error":e==="answered"?"complete":"running"}function S0(e,t){const n=$e(e,t.id);if(n){n.status==="pending"&&(n.status=C0(t.resolution),n.approvalRemainingMs=void 0);const o=ic(t);o&&(n.interactiveType="approval",n.approvalOutcome=o,n.approvalResolvedAt=t.at,t.reasonGiven===!0&&(n.approvalReasonGiven=!0),n.approvalStartedAt=t.startedAt??n.approvalStartedAt);const a=lc(t);a&&(n.questionOutcome=a)}const s=cn(e,t.id);s&&s.status==="pending"&&(s.status="submitted",s.remainingMs=void 0)}function _0(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="tool_call"&&s.hooks){const o=s.hooks.find(a=>a.hookId===t);if(o)return o}}}function j0(e,t){for(const n of e.values()){const s=n.find(o=>o.hookId===t);if(s)return s}}function w0(e,t,n){const s=_0(e,t.hookId)??j0(n,t.hookId);if(s){s.status=t.status,t.hookName!==void 0&&(s.hookName=t.hookName),t.stdout!==void 0&&(s.stdout=t.stdout),t.stderr!==void 0&&(s.stderr=t.stderr),t.exitCode!==void 0&&(s.exitCode=t.exitCode);return}if(!t.toolCallId)return;const o={hookId:t.hookId,hookName:t.hookName??"",hookEvent:t.hookEvent??"",status:t.status,stdout:t.stdout??"",stderr:t.stderr??"",...t.exitCode!==void 0?{exitCode:t.exitCode}:{}},a=$e(e,t.toolCallId);a?a.hooks=[...a.hooks??[],o]:n.set(t.toolCallId,[...n.get(t.toolCallId)??[],o])}function N0(e,t){const n=e[0];if(n&&n.type==="memory_recall"){const a=new Set(n.memories.map(l=>l.path)),i=t.memories.filter(l=>!a.has(l.path));i.length>0&&(n.memories=[...n.memories,...i]);return}const s=new Set,o=t.memories.filter(a=>s.has(a.path)?!1:(s.add(a.path),!0));e.unshift({type:"memory_recall",mode:t.mode,memories:o,isStreaming:!0})}function E0(e,t){e.push({type:"image",attachmentId:t.attachmentId,url:t.url,mediaType:t.mediaType,size:t.size,...t.alt!==void 0?{alt:t.alt}:{}})}function D0(e,t){e.push({type:"compact_boundary",...t.trigger!==void 0?{trigger:t.trigger}:{},...t.preTokens!==void 0?{preTokens:t.preTokens}:{},...t.postTokens!==void 0?{postTokens:t.postTokens}:{},...t.durationMs!==void 0?{durationMs:t.durationMs}:{},...t.requestedBy!==void 0?{requestedBy:t.requestedBy}:{},...t.contextPercent!==void 0?{contextPercent:t.contextPercent}:{}})}function T0(e,t){e.push({type:"permission_denied",toolCallId:t.toolCallId,toolName:t.toolName,message:t.message,...t.reasonType!==void 0?{reasonType:t.reasonType}:{},...t.reason!==void 0?{reason:t.reason}:{},...t.agentId!==void 0?{agentId:t.agentId}:{}})}function A0(e,t){t.operation!=="compaction"||t.state!=="failed"||e.push({type:"compact_boundary",failed:!0,...t.error!==void 0?{error:t.error}:{},...t.requestedBy!==void 0?{requestedBy:t.requestedBy}:{}})}function F0(e,t){Pa(e);const n=t.code!==void 0?t.details!==void 0?`[${t.code}] ${t.details}`:`[${t.code}]`:t.details;e.push({type:"error",message:t.message,...t.category!==void 0?{category:t.category}:{},...n!==void 0?{details:n}:{},...t.code!==void 0?{code:t.code}:{},...t.reason!==void 0?{reason:t.reason}:{}})}function R0(e,t){const n=g0(e,t.taskId);n?(n.status=t.status,t.description!==void 0&&(n.description=t.description),t.toolUses!==void 0&&(n.toolUses=t.toolUses),t.lastToolName!==void 0&&(n.lastToolName=t.lastToolName),t.summary!==void 0&&(n.summary=t.summary),t.ambient!==void 0&&(n.ambient=t.ambient)):e.push({type:"background_task",taskId:t.taskId,taskType:"agent",status:t.status,startedAt:0,description:t.description,toolUses:t.toolUses,lastToolName:t.lastToolName,summary:t.summary,ambient:t.ambient})}const M0={approval:"approval_required",question:"question_prompt",elicitation:"elicitation_prompt"};function O0(e){const{type:t,...n}=e;return{...n,seq:0,type:M0[t]}}function I0(e,t){const n=$e(e,t);return(n==null?void 0:n.interactiveType)!==void 0?!0:cn(e,t)!==void 0}function $0(e,t){switch(t.type){case"approval_required":La(e,t);break;case"question_prompt":Ba(e,t);break;case"elicitation_prompt":za(e,t);break}}function P0(e,t,n){const s=$e(e,t.id);if(s){!n&&s.result===void 0&&(s.status="pending"),s.approvalStartedAt=t.startedAt,s.approvalRemainingMs=t.remainingMs,t.timeoutMs!==void 0&&(s.timeoutMs=t.timeoutMs),s.approvalParked=t.parked===!0?!0:void 0;return}const o=cn(e,t.id);o&&(o.startedAt=t.startedAt,o.remainingMs=t.remainingMs,t.timeoutMs!==void 0&&(o.timeoutMs=t.timeoutMs))}function L0(e,t,n){for(const s of t){if(I0(e,s.id)){P0(e,s,n.has(s.id));continue}$0(e,O0(s)),B0(e,s)}}function B0(e,t){if(t.parked!==!0)return;const n=$e(e,t.id);n&&(n.approvalParked=!0)}function Xn(e){const t=[],n=new Map;for(const s of e)switch(s.type){case"text_delta":x0(t,s);break;case"thinking_delta":b0(t,s);break;case"tool_call":y0(t,s,n);break;case"tool_result":v0(t,s);break;case"tool_progress":k0(t,s);break;case"approval_required":La(t,s);break;case"question_prompt":Ba(t,s);break;case"elicitation_prompt":za(t,s);break;case"capability_approval_required":o0(t,s);break;case"capability_approval_resolved":a0(t,s);break;case"mcp_signin_required":l0(t,s);break;case"mcp_signin_resolved":c0(t,s);break;case"interaction_resolved":S0(t,s);break;case"subagent_update":R0(t,s);break;case"hook_update":w0(t,s,n);break;case"memory_recall":N0(t,s);break;case"image_attachment":E0(t,s);break;case"compact_boundary":D0(t,s);break;case"permission_denied":T0(t,s);break;case"model_substituted":t.push({type:"model_substituted",from:s.from,fromName:s.fromName,to:s.to,toName:s.toName,reason:s.reason});break;case"operation_progress":A0(t,s);break;case"error":F0(t,s);break}return t}function Fr(e,t){if(e.length===0)return null;const n=hs(e);return{id:t,role:"assistant",content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:[],parts:e,timestamp:"",_streaming:!0}}function z0(e,t){const n=[];let s=[],o=0;for(const[l,u]of e.entries()){if(u.type!=="turn_input"&&u.type!=="context_staged"){s.push(u);continue}const d=Xn([...s,...e.slice(l+1).filter(u0)]),f=Fr(d,`${Ar}-${o}`);f&&n.push(f),o+=1,n.push(u.type==="turn_input"?p0(u):h0(u)),s=[]}const a=Xn(s);L0(a,t,d0(e));const i=Fr(a,Ar);return i&&n.push(i),n}function q0(e){const t=new Set;for(const n of e)for(const s of n.parts)s.type==="tool_call"&&t.add(s.toolCallId);return t}function U0(e){return e.type==="tool_call"&&e.result===void 0&&e.answers===void 0&&e.approvalOutcome===void 0&&(e.questionOutcome===void 0||e.questionOutcome==="unresolved")}function H0(e,t){const n=e.parts.filter(o=>o.type!=="tool_call"||!t.has(o.toolCallId)||!U0(o));if(n.length===e.parts.length)return e;if(n.length===0)return null;const s=hs(n);return{...e,parts:n,content:s.content,toolCalls:s.toolCalls.length>0?s.toolCalls:void 0}}function W0(e){let t=e.length;for(;t>0&&e[t-1].role==="assistant";)t-=1;return t}function G0(e,t,n=[],s=null){const o=z0(t,n),a=q0(o),i=dp(e),l=a.size===0?i.length:W0(i),u=[];for(const[d,f]of i.entries()){const h=d<l?f:H0(f,a);h&&u.push(h)}return s&&u.push(m0(s.content)),u.push(...o),u}function Rr(e){const t=new Map;for(const n of e)n.type!=="tool_call"||n.approvalOutcome===void 0||t.set(n.toolCallId,{outcome:n.approvalOutcome,resolvedAt:n.approvalResolvedAt,startedAt:n.approvalStartedAt,displayName:n.approvalDisplayName,reasonGiven:n.approvalReasonGiven});return t}function V0(e,t){return e.interactiveType==="approval"&&e.approvalOutcome===t.outcome&&e.approvalResolvedAt===t.resolvedAt&&e.approvalStartedAt===t.startedAt&&e.approvalReasonGiven===t.reasonGiven}function K0(e,t){return t.size===0?e:e.map(n=>{if(!n.parts)return n;let s=!1;const o=n.parts.map(a=>{if(a.type!=="tool_call")return a;const i=t.get(a.toolCallId);return!i||V0(a,i)?a:(s=!0,{...a,interactiveType:"approval",approvalOutcome:i.outcome,approvalResolvedAt:i.resolvedAt,approvalStartedAt:i.startedAt,approvalReasonGiven:i.reasonGiven,...i.displayName!==void 0?{approvalDisplayName:i.displayName}:{}})});return s?{...n,parts:o}:n})}function Q0(e,t){var o;if(!t.tail)return t.messages;const n=(o=t.messages[0])==null?void 0:o.id,s=n===void 0?-1:e.findIndex(a=>a.id===n);return s===-1?null:[...e.slice(0,s),...t.messages]}async function Y0(e,t,n,s){const o=X0(s());if(o!==void 0){const a=await e.getMessages(t,n,{since:o}),i=Q0(s(),a);if(i)return i}return(await e.getMessages(t,n)).messages}function X0(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="user")return e[t].id}function J0({sessionId:e,transport:t,sessionCwd:n,streamState:s,queryClient:o,onStreamingDone:a}){var k;const i=n.cwd,l=c.useRef(e),u=c.useRef(i),d=c.useRef(a);c.useEffect(()=>{l.current=e,u.current=i,d.current=a});const f=c.useRef(new Map),h=c.useRef(new Map),m=c.useRef(new Map),g=c.useRef(new Map),x=c.useRef(new Map),C=((k=s.status)==null?void 0:k.lifecycle)??null,b=s.hydrationGeneration,y=s.userTurnCount;c.useEffect(()=>{var A,S,E;if(!e)return;const v=x.current.get(e);x.current.set(e,y),v!==void 0&&y!==v&&g.current.set(e,!1);const p=h.current.get(e);if(h.current.set(e,b),p!==b){f.current.set(e,C),C==="streaming"&&m.current.set(e,((A=je.getState().getSession(e).optimisticUserMessage)==null?void 0:A.id)??null);return}const _=f.current.get(e)??null;if(f.current.set(e,C),C==="streaming"&&_!=="streaming"&&m.current.set(e,((S=je.getState().getSession(e).optimisticUserMessage)==null?void 0:S.id)??null),!(_==="streaming"&&C!=="streaming"&&C!==null))return;const D=e,T=m.current.get(D)??null,w=Rr(Xn(je.getState().getSession(D).inProgressTurn));Y0(t,D,u.current??void 0,()=>je.getState().getSession(D).messages).then(N=>{var G;const R=je.getState(),M=R.getSession(D),F=((G=M.status)==null?void 0:G.lifecycle)==="streaming",O=new Map([...Rr(M.messages.flatMap(V=>V.parts??[])),...w]);R.setHistoryMessages(D,K0(N,O),{preserveInProgressTurn:F});const L=M.optimisticUserMessage;(L===null||L.id===T)&&R.setOptimisticUserMessage(D,null)}).catch(N=>{console.warn("[turn-end-reconcile] history reload failed",{sessionId:D,error:N instanceof Error?N.message:String(N)})}),o.invalidateQueries({queryKey:["tasks",D]}),g.current.get(D)!==!0&&(g.current.set(D,!0),(E=d.current)==null||E.call(d))},[e,C,b,y,t,o])}function Z0(e){return e.streamReadyCursor!==null||e.messages.length>0||e.inProgressTurn.length>0||e.optimisticUserMessage!==null}function qa(e,t){const n=Z0(e),s=n?e.messages:t,o=Mr.get(s);if(o&&o.hydrated===n&&o.inProgressTurn===e.inProgressTurn&&o.pendingInteractions===e.pendingInteractions&&o.optimisticUserMessage===e.optimisticUserMessage&&o.legacyMessages===t)return o.result;const a=n?G0(e.messages,e.inProgressTurn,e.pendingInteractions,e.optimisticUserMessage):t,i=Ic(a);return Mr.set(s,{hydrated:n,inProgressTurn:e.inProgressTurn,pendingInteractions:e.pendingInteractions,optimisticUserMessage:e.optimisticUserMessage,legacyMessages:t,result:i}),i}const Mr=new WeakMap;function eb(e,t={}){const n=Ce(),s=rs(),o=oe(H=>H.selectedCwd),a=oe(H=>H.enableMessagePolling),i=oe(H=>H.pendingAccount),l=Go(),u=e??"",{messages:d,input:f,status:h,error:m,sessionStatus:g,systemStatus:x,operationProgress:C,promptSuggestions:b}=wo(u),y=Qx(e,l.cwd);Yx(e,t.onSessionIdChangeReplace);const k=cc(u),v=c.useMemo(()=>qa(y,d),[y,d]),p=yu(y,h),{streamStartTime:_,estimatedTokens:j,isTextStreaming:D}=Jx(e,y.inProgressTurn,p==="streaming");Zx(e,y.inProgressTurn,y.streamReadyCursor,t.onTaskEvent);const T=c.useRef(!0);c.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]);const w=c.useRef(new Map);c.useLayoutEffect(()=>{u&&(w.current.has(u)||w.current.set(u,re.getState().getSession(u).mountGeneration))},[u]);const{setMessages:A,setInput:S,setError:E,setSystemStatus:N,setOperationProgress:R}=Ux(u,T,w);s0(e,y.inProgressTurn,R,N),u&&re.getState().initSession(u),c.useEffect(()=>{e&&(re.getState().initSession(e),re.getState().touchSession(e),w.current.set(e,re.getState().getSession(e).mountGeneration))},[e]),c.useEffect(()=>{if(e)return yt.getState().clearUnseen(e),yt.subscribe(H=>{H.unseen[e]!==void 0&&yt.getState().clearUnseen(e)})},[e]);const{historyQuery:M}=Hx({sessionId:e,sid:u,transport:n,sessionCwd:l,enableMessagePolling:a,isStreaming:p==="streaming",streamHydrated:y.streamReadyCursor!==null,setMessages:A}),F=yx(o,e,{startFreshSession:t.startFreshSession,compact:t.compactIntent}),{handleSubmit:O,submitContent:L,enqueueContent:G,steerContent:V,addContextContent:Q,stop:U,retryMessage:I,submitKickoff:P,markToolCallResponded:$}=Gx({sessionId:e,input:f,status:p,transport:n,queryClient:s,selectedCwd:o,onSessionIdChangeReplace:t.onSessionIdChangeReplace,transformContent:t.transformContent,launchRuntime:t.launchRuntime,agentPath:t.agentPath,agentLookupPending:t.agentLookupPending,agentLookupFailed:t.agentLookupFailed,launchAccount:(i==null?void 0:i.sessionId)===u?i.id:null,takeSeedContext:t.takeSeedContext,setInput:S,setError:E,tryNativeCommand:F.tryRun}),K=y.streamReadyCursor!==null,ue=c.useCallback((H,ie)=>L(H,ie?{cwd:ie}:void 0),[L]);Kx({sessionId:e,cwd:o,status:p,messages:v,hydrated:K,canStart:!t.agentLookupPending&&!t.agentLookupFailed,submitKickoff:P,submitContent:ue}),J0({sessionId:e,transport:n,sessionCwd:l,streamState:y,queryClient:s,onStreamingDone:t.onStreamingDone});const z=M.isLoading&&v.length===0,X=c.useMemo(()=>v.flatMap(H=>H.toolCalls||[]).filter(H=>H.interactiveType&&H.status==="pending"),[v]),J=X[0]||null,ae=J!==null,ve=(J==null?void 0:J.interactiveType)||null;return{messages:v,input:f,setInput:S,handleSubmit:O,submitContent:L,enqueueContent:G,steerContent:V,addContextContent:Q,status:p,error:m,stop:U,retryMessage:I,isLoadingHistory:z,hydrated:K,sessionStatus:g,streamStartTime:_,estimatedTokens:j,isTextStreaming:D,isWaitingForUser:ae,waitingType:ve,activeInteraction:J,pendingInteractions:X,markToolCallResponded:$,systemStatus:x,operationProgress:C,promptSuggestions:b,syncConnectionState:k,tryNativeCommand:F.tryRun,commandPending:F.commandPending}}function tb(e){switch(e.outcome){case"acked":return{message:"You stopped this reply.",isFailure:!1};case"closed":return{message:"Stopped. Your agent didn’t answer, so DorkOS ended it.",isFailure:!1};case"not-running":return{message:null,isFailure:!1};case"unconfirmed":return{message:`Stop requested. ${sb(e.runtime)} didn’t confirm, so it may still be working.`,isFailure:!1};case"failed":return{message:"Couldn’t stop it. Try again.",isFailure:!0}}}function nb(e,t){return!No(e)||e.outcome==="not-running"&&t}function sb(e){switch(e){case"claude-code":return"Claude Code";case"codex":return"Codex";case"opencode":return"OpenCode";case"doe":return"DorkOS";default:return"Your agent"}}function rb(){const e=oe(d=>d.showTaskCelebrations),[t,n]=c.useState(null),[s,o]=c.useState(null),a=c.useRef(null),i=c.useRef(!1);c.useEffect(()=>{const d=window.matchMedia("(prefers-reduced-motion: reduce)");i.current=d.matches;const f=h=>{i.current=h.matches};return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[]),pd({timeoutMs:Ze.IDLE_TIMEOUT_MS,onIdle:c.useCallback(()=>{var d;(d=a.current)==null||d.setIdle(!0)},[]),onReturn:c.useCallback(()=>{var d,f;(d=a.current)==null||d.setIdle(!1),(f=a.current)==null||f.onUserReturn()},[])}),c.useEffect(()=>{const d=new Nd({enabled:e,miniProbability:Ze.MINI_PROBABILITY,debounceWindowMs:Ze.DEBOUNCE_WINDOW_MS,debounceThreshold:Ze.DEBOUNCE_THRESHOLD,minTasksForMajor:Ze.MIN_TASKS_FOR_MAJOR,idleTimeoutMs:Ze.IDLE_TIMEOUT_MS,onCelebrate:f=>{i.current&&f.level==="major"?n({...f,level:"mini"}):n(f),f.level==="mini"&&o(f.taskId)}});return a.current=d,()=>d.destroy()},[e]);const l=c.useCallback((d,f)=>{var h;d.action==="update"&&d.task.status==="completed"&&d.task.id&&((h=a.current)==null||h.onTaskCompleted(d.task.id,f))},[]),u=c.useCallback(()=>{n(null),o(null)},[]);return{handleTaskEvent:l,activeCelebration:t,celebratingTaskId:s,clearCelebration:u}}function An(){return{tasks:new Map,statusTimestamps:new Map,legacyCreateCount:0}}function ob(e){const t={};for(const[n,s]of Object.entries(e))s!==void 0&&s!==""&&(t[n]=s);return t}function Fn(e,t,n){switch(t.action){case"snapshot":{e.tasks.clear(),e.statusTimestamps.clear();const s=t.tasks??[t.task];for(const o of s)e.tasks.set(o.id,o),e.statusTimestamps.set(o.id,{status:o.status,since:n});return}case"create":{const s=t.task.id||`legacy:${e.legacyCreateCount++}`,o=s===t.task.id?t.task:{...t.task,id:s};e.tasks.set(s,o),e.statusTimestamps.set(s,{status:o.status,since:n});return}case"id_assigned":{const s=t.previousId;if(!s)return;const o=e.tasks.get(s);if(!o)return;const a=t.task.id;e.tasks.delete(s),e.tasks.set(a,{...o,id:a});const i=e.statusTimestamps.get(s);e.statusTimestamps.delete(s),e.statusTimestamps.set(a,i??{status:o.status,since:n});return}case"remove":{e.tasks.delete(t.task.id),e.statusTimestamps.delete(t.task.id);return}case"update":{if(!t.task.id)return;const s=e.tasks.get(t.task.id);if(!s)return;e.tasks.set(t.task.id,{...s,...ob(t.task)}),t.task.status&&t.task.status!==s.status&&e.statusTimestamps.set(t.task.id,{status:t.task.status,since:n});return}}}function Or(e,t){var n;return(n=e.blockedBy)!=null&&n.length?e.blockedBy.some(s=>{const o=t.get(s);return o&&o.status!=="completed"}):!1}function ab(e,t){return[...e].sort((n,s)=>{const o=n.status==="in_progress"?0:n.status==="pending"&&!Or(n,t)?1:n.status==="pending"?2:3,a=s.status==="in_progress"?0:s.status==="pending"&&!Or(s,t)?1:s.status==="pending"?2:3;return o-a})}const ib=10;let Ir=0;function qt(e){return e==="streaming"||e==="blocked"}function lb(e,t=!1){const n=Ce(),o=Go().cwd,a=oe(w=>w.enableMessagePolling),i=Lo(),[l,u]=c.useState(An()),d=Eo(e??""),[f,h]=c.useState(()=>!qt(d)),m=c.useRef([]),g=c.useRef(0),{data:x}=Qe({queryKey:["tasks",e,o],queryFn:async()=>{const w=++Ir;return{...await n.getTasks(e,o??void 0),fetchOrder:w}},staleTime:3e4,refetchOnWindowFocus:!1,enabled:e!==null,refetchInterval:()=>!a||t?!1:i?Ve.ACTIVE_TAB_REFETCH_MS:Ve.BACKGROUND_TAB_REFETCH_MS}),C=c.useRef(null);c.useEffect(()=>{const w=`${e??""}::${o??""}`,A=C.current!==w;if(C.current=w,A&&(m.current=[],g.current=0,u(An())),!x||x.fetchOrder<=g.current)return;g.current=x.fetchOrder;const S=An();x.tasks.length>0&&Fn(S,{action:"snapshot",task:x.tasks[0],tasks:x.tasks},Date.now()),m.current=m.current.filter(({order:E})=>E>x.fetchOrder);for(const{event:E,receivedAt:N}of m.current)Fn(S,E,N);u(S)},[x,e,o]);const b=c.useCallback(w=>{const A=Date.now();w.action==="snapshot"&&(m.current=[]),m.current.push({order:++Ir,event:w,receivedAt:A}),u(S=>{const E={tasks:new Map(S.tasks),statusTimestamps:new Map(S.statusTimestamps),legacyCreateCount:S.legacyCreateCount};return Fn(E,w,A),E})},[]),y=c.useRef(!1),k=c.useCallback(()=>{h(w=>(y.current=!w,!w))},[]),v=c.useRef(qt(d));c.useEffect(()=>{const w=qt(d);w!==v.current&&(v.current=w,w?y.current||h(!1):h(!0))},[d]);const p=c.useRef(null);c.useEffect(()=>{const w=`${e??""}::${o??""}`;if(p.current===w)return;p.current=w;const A=qt(d);v.current=A,y.current=!1,h(!A)},[e,o,d]);const _=Array.from(l.tasks.values()),j=ab(_,l.tasks),D=_.find(w=>w.status==="in_progress"),T=(D==null?void 0:D.activeForm)??null;return{tasks:j.slice(0,ib),taskMap:l.tasks,activeForm:T,isCollapsed:f,toggleCollapse:k,handleTaskEvent:b,statusTimestamps:l.statusTimestamps}}function cb(e){const t=c.useRef(null),[n,s]=c.useState(0),[o,a]=c.useState(!1),[i,l]=c.useState(0),u=c.useCallback(y=>{t.current=y,l(y&&"getOptionCount"in y?y.getOptionCount():0)},[]);c.useEffect(()=>{s(0),l(0),a(!1)},[e==null?void 0:e.toolCallId]);const d=c.useMemo(()=>e!=null&&e.interactiveType?{type:e.interactiveType,toolCallId:e.toolCallId}:null,[e]),f=c.useCallback(()=>{const y=t.current;y&&"approve"in y&&y.approve()},[]),h=c.useCallback(()=>{const y=t.current;y&&"alwaysAllow"in y&&y.alwaysAllow()},[]),m=c.useCallback(()=>{const y=t.current;y&&"deny"in y&&y.deny()},[]),g=c.useCallback(y=>{const k=t.current;k&&"toggleOption"in k&&(k.toggleOption(y),s(y),a(!0))},[]),x=c.useCallback(y=>{if(!o){a(!0);return}s(k=>{const v=t.current,p=v&&"getOptionCount"in v?v.getOptionCount():0;return p===0?k:y==="up"?k<=0?p-1:k-1:k>=p-1?0:k+1})},[o]),C=c.useCallback(y=>{const k=t.current;k&&"navigateQuestion"in k&&(k.navigateQuestion(y),s(0),a(!0),l(k.getOptionCount()))},[]),b=c.useCallback(()=>{const y=t.current;y&&"submit"in y&&y.submit()},[]);return hd({activeInteraction:d,onApprove:f,onAlwaysAllow:h,onDeny:m,onToggleOption:g,onNavigateOption:x,onNavigateQuestion:C,onSubmit:b,optionCount:i,focusedIndex:n}),{handleToolRef:u,focusedOptionIndex:o?n:-1}}function Ut(e,t,n){var a;const s=e.length;if(s===0)return 0;let o=(t%s+s)%s;for(let i=0;i<s;i++){if(!((a=e[o])!=null&&a.disabled))return o;o=(o+n+s)%s}return t}function ub({commands:e,input:t,cursorPos:n}){const[s,o]=c.useState(!1),[a,i]=c.useState(""),[l,u]=c.useState(-1),d=c.useMemo(()=>a?e.map(_=>({cmd:_,rank:Zd(a,_)})).filter(_=>_.rank.match).sort((_,j)=>_.rank.bucket-j.rank.bucket||j.rank.score-_.rank.score).map(({cmd:_,rank:j})=>({..._,matchedAlias:j.matchedAlias})):e,[e,a]),[f,h]=c.useState(null),m=f!==null&&f.query===a&&f.open===s?f.index:Ut(d,0,1),g=d[m],x=d.length===0||g!==void 0&&!g.disabled?m:Ut(d,0,1),C=c.useCallback((_,j)=>{const T=_.slice(0,j).match(/(^|\s)\/([\w:-]*)$/);return T?(o(!0),i(T[2]),u((T.index??0)+T[1].length),!0):(o(!1),!1)},[]),b=c.useCallback(_=>{const j=t.slice(0,l),D=t.slice(l+1+a.length);return o(!1),j+_.fullCommand+(D.startsWith(" ")?"":" ")+D},[t,a,l]),y=c.useCallback(()=>{h({query:a,open:s,index:Ut(d,x+1,1)})},[d,x,a,s]),k=c.useCallback(()=>{h({query:a,open:s,index:Ut(d,x-1,-1)})},[d,x,a,s]),v=c.useCallback(()=>{const _=d[x];return _&&!_.disabled?b(_):(_||o(!1),null)},[d,x,b]),p=c.useCallback(()=>{o(!1),i("")},[]);return{showCommands:s,setShowCommands:o,commandQuery:a,selectedIndex:x,filteredCommands:d,slashTriggerPos:l,detectCommandTrigger:C,handleCommandSelect:b,handleArrowUp:k,handleArrowDown:y,handleKeyboardSelect:v,resetCommand:p}}function db({fileEntries:e,input:t,cursorPos:n}){const[s,o]=c.useState(!1),[a,i]=c.useState(""),[l,u]=c.useState(0),[d,f]=c.useState(-1),h=c.useMemo(()=>s?a?e.map(k=>({...k,...Wt(a,k.path)})).filter(k=>k.match).sort((k,v)=>v.score-k.score).slice(0,50):e.slice(0,50).map(k=>({...k,indices:[]})):[],[e,a,s]);c.useEffect(()=>{u(0)},[a,s]),c.useEffect(()=>{h.length>0&&l>=h.length&&u(h.length-1)},[h.length,l]);const m=c.useCallback((k,v)=>{const _=k.slice(0,v).match(/(^|\s)@([\w./:-]*)$/);return _?(o(!0),i(_[2]),f((_.index??0)+_[1].length),!0):(o(!1),!1)},[]),g=c.useCallback(k=>{const v=t.slice(0,d),p=t.slice(d+1+a.length);if(k.isDirectory){const j=v+"@"+k.path+p,D=v.length+1+k.path.length;return i(k.path),u(0),{newValue:j,newCursorPos:D,keepOpen:!0}}const _=v+"@"+k.path+" "+p;return o(!1),{newValue:_,keepOpen:!1}},[t,d,a]),x=c.useCallback(()=>{u(k=>h.length===0?0:(k+1)%h.length)},[h.length]),C=c.useCallback(()=>{u(k=>h.length===0?0:(k-1+h.length)%h.length)},[h.length]),b=c.useCallback(()=>h.length>0&&l<h.length?g(h[l]):(o(!1),null),[h,l,g]),y=c.useCallback(()=>{o(!1),i("")},[]);return{showFiles:s,setShowFiles:o,fileQuery:a,fileSelectedIndex:l,filteredFiles:h,fileTriggerPos:d,detectFileTrigger:m,handleFileSelect:g,handleArrowUp:C,handleArrowDown:x,handleKeyboardSelect:b,resetFiles:y}}function fb({input:e,setInput:t,commands:n,fileEntries:s}){const[o,a]=c.useState(0),i=ub({commands:n,input:e,cursorPos:o}),l=db({fileEntries:s,input:e,cursorPos:o}),u=c.useCallback((j,D)=>{if(l.detectFileTrigger(j,D)){i.setShowCommands(!1);return}if(i.detectCommandTrigger(j,D)){l.setShowFiles(!1);return}l.setShowFiles(!1),i.setShowCommands(!1)},[l,i]),d=c.useRef({value:e,cursor:0});c.useEffect(()=>{d.current.value=e},[e]);const f=c.useCallback(j=>{t(j),d.current={value:j,cursor:d.current.cursor||j.length},u(j,d.current.cursor)},[t,u]),h=c.useCallback(j=>{a(j),d.current={value:d.current.value,cursor:j},u(d.current.value,j)},[u]),m=c.useCallback(j=>{const D=i.handleCommandSelect(j);t(D)},[i,t]),g=c.useCallback(j=>{const D=l.handleFileSelect(j);t(D.newValue),D.newCursorPos!==void 0&&a(D.newCursorPos)},[l,t]),x=c.useCallback(()=>{l.showFiles?l.handleArrowDown():i.handleArrowDown()},[l,i]),C=c.useCallback(()=>{l.showFiles?l.handleArrowUp():i.handleArrowUp()},[l,i]),b=c.useCallback(()=>{if(l.showFiles){const j=l.handleKeyboardSelect();j&&(t(j.newValue),j.newCursorPos!==void 0&&a(j.newCursorPos))}else if(i.showCommands){const j=i.handleKeyboardSelect();j&&t(j)}},[l,i,t]),y=c.useCallback(()=>{i.setShowCommands(!1),l.setShowFiles(!1)},[i,l]),k=i.showCommands||l.showFiles,v=l.showFiles&&l.filteredFiles.length>0||i.showCommands&&i.filteredCommands.length>0,p=l.showFiles?"file-palette-listbox":i.showCommands?"command-palette-listbox":void 0,_=l.showFiles&&l.filteredFiles.length>0?`file-item-${l.fileSelectedIndex}`:i.showCommands&&i.filteredCommands.length>0?`command-item-${i.selectedIndex}`:void 0;return{commands:{show:i.showCommands,filtered:i.filteredCommands,selectedIndex:i.selectedIndex},files:{show:l.showFiles,filtered:l.filteredFiles,selectedIndex:l.fileSelectedIndex},isPaletteOpen:k,paletteHasResults:v,activeDescendantId:_,paletteListboxId:p,handleInputChange:f,handleCursorChange:h,handleArrowUp:C,handleArrowDown:x,handleKeyboardSelect:b,handleCommandSelect:m,handleFileSelect:g,dismissPalettes:y}}function mb(e,t,n){const s=oe(i=>i.setIsStreaming),o=oe(i=>i.setIsWaitingForUser),a=oe(i=>i.setIsTextStreaming);c.useEffect(()=>(s(e==="streaming"),()=>s(!1)),[e,s]),c.useEffect(()=>(o(t),()=>o(!1)),[t,o]),c.useEffect(()=>(a(n),()=>a(!1)),[n,a])}function pb(){const e=Ce(),t=oe(m=>m.selectedCwd),[n,s]=c.useState([]),o=c.useCallback(m=>{const g=m.map(x=>({id:crypto.randomUUID(),file:x,status:"pending",progress:0}));s(x=>[...x,...g])},[]),a=c.useCallback(m=>{s(g=>g.filter(x=>x.id!==m))},[]),i=c.useCallback(()=>{s([])},[]),l=c.useCallback(m=>{s(g=>g.map(x=>x.id===m&&x.status==="error"?{...x,status:"pending",progress:0,error:void 0}:x))},[]),u=c.useRef(null),d=kt({meta:{suppressErrorToast:!0},mutationFn:async m=>{if(!t)throw new Error("No working directory selected");s(b=>b.map(y=>m.some(k=>k.id===y.id)?{...y,status:"uploading"}:y));const g=b=>{s(y=>y.map(k=>k.status==="uploading"?{...k,progress:b.percentage}:k))},x=new AbortController;u.current=x;const C=m.map(b=>b.file);return e.uploadFiles(C,t,g,x.signal)},onSettled:()=>{u.current=null},onSuccess:(m,g)=>{s(x=>x.map(C=>{const b=g.findIndex(y=>y.id===C.id);return b===-1?C:{...C,status:"uploaded",progress:100,result:m[b]}}))},onError:m=>{s(g=>g.map(x=>x.status==="uploading"?{...x,status:"error",error:m.message}:x))}}),f=c.useCallback(()=>{var m;(m=u.current)==null||m.abort()},[]),h=c.useCallback(async()=>{const m=n.filter(b=>b.status==="error");if(m.length>0)throw new Error(m.length===1?`${m[0].file.name} did not upload. Retry it or remove it, then send again.`:`${m.length} attachments did not upload. Retry them or remove them, then send again.`);const g=n.filter(b=>b.status==="uploaded"&&b.result).map(b=>b.result.savedPath),x=n.filter(b=>b.status==="pending");if(x.length===0)return g;const C=await d.mutateAsync(x);return[...g,...C.map(b=>b.savedPath)]},[n,d]);return{pendingFiles:n,addFiles:o,removeFile:a,retryFile:l,clearFiles:i,cancelUpload:f,uploadAndGetPaths:h,hasPendingFiles:n.length>0,hasFailedUpload:n.some(m=>m.status==="error"),isUploading:d.isPending}}const Rn=new Set,Mn=new Set;function hb(e,t){return`${e}\0${t}`}function gb({sessionId:e,prompt:t,autoSend:n,input:s,setInput:o,messageCount:a,hydrated:i,status:l,submitBlocked:u=!1,submit:d,onSeeded:f,onConsumed:h}){const m=t!=null&&t.trim()?t:void 0,g=e&&m?hb(e,m):null;c.useEffect(()=>{if(!(!g||!m)&&!Rn.has(g)&&i){if(Rn.add(g),s.length>0||a>0){Mn.add(g),h==null||h();return}o(m),f==null||f(),n||h==null||h()}},[g,m,n,s,i,a,o,f,h]),c.useEffect(()=>{!g||!m||!n||Mn.has(g)||Rn.has(g)&&s===m&&(!i||a>0||l==="streaming"||u||(Mn.add(g),h==null||h(),d()))},[g,m,n,s,i,a,l,u,d,h])}const $r=uc-256,Pr=`
52
+ …(context truncated)`,Lr={"/":"the home team room","/activity":"the activity feed","/team":"the team page","/session":"a chat session","/tasks":"the scheduled-work page","/channels":"a channel","/workspaces":"the workspaces page","/connections":"the connections page","/marketplace":"the marketplace","/feedback-requests":"the feedback requests page"};function xb(e){const t=`/${e.split("/").filter(Boolean)[0]??""}`;return Lr[e]??Lr[t]??`the ${e} page`}function bb(e){const t=['The person opened this conversation by pressing "Ask DorkBot" in the DorkOS sidebar, so they are asking for help with DorkOS itself. Greet them with what you can see below and offer the next step; do not repeat this back to them.'];e.originPath!==null&&t.push(`They were on ${xb(e.originPath)} (${e.originPath}).`),t.push(e.agentNames.length===1?"They have 1 agent registered.":`They have ${e.agentNames.length} agents registered.`),e.agentNames.length>0&&t.push(`Their agents: ${e.agentNames.join(", ")}.`),e.version!==null&&t.push(e.updateReady?`They are running DorkOS v${e.version}, and a newer version is ready to install.`:`They are running DorkOS v${e.version}.`),e.erroredSessionIds.length>0&&t.push(`These conversations ended in an error and may be what they want help with: ${e.erroredSessionIds.join(", ")}.`);const n=t.join(`
53
+ `);return n.length<=$r?n:n.slice(0,$r-Pr.length)+Pr}const yb="dorkbot-help",Ht=new Set;function vb({sessionId:e,seed:t,messageCount:n,hydrated:s,onConsumed:o}){const a=t===yb&&e!==null,{data:i}=dc({enabled:a}),{data:l}=to(),u=yt(fc(m=>Object.entries(m.statuses).filter(([,g])=>g.lifecycle==="error").map(([g])=>g))),d=c.useRef({agentNames:[],version:null,updateReady:!1,erroredSessionIds:[]}),f=c.useRef({armed:a,sessionId:e,messageCount:n}),h=c.useRef(o);return c.useEffect(()=>{const m=(l==null?void 0:l.latestVersion)??null,g=(l==null?void 0:l.version)??null;d.current={agentNames:((i==null?void 0:i.agents)??[]).map(x=>x.displayName??x.name),version:g,updateReady:m!==null&&g!==null&&ju(m,g),erroredSessionIds:u}},[i,l,u]),c.useEffect(()=>{f.current={armed:a,sessionId:e,messageCount:n},h.current=o},[a,e,n,o]),c.useEffect(()=>{!a||e===null||!s||n===0||Ht.has(e)||(Ht.add(e),o==null||o())},[a,e,s,n,o]),c.useCallback(()=>{var g;const m=f.current;if(!(!m.armed||m.sessionId===null)&&!(m.messageCount>0)&&!Ht.has(m.sessionId))return Ht.add(m.sessionId),(g=h.current)==null||g.call(h),bb({...d.current,originPath:mc()})},[])}function kb(e,t,n,s=!1){if(e!=="error"||t||s)return!1;let o=-1;for(let i=n.length-1;i>=0;i--)if(n[i].role==="user"){o=i;break}return!n.slice(o+1).some(i=>i.parts.some(l=>l.type==="error"&&l.code!==bo))}const Cb=4e3;function Sb(e){const t=e.approvalDisplayName||_t(e.toolName,e.input??"");return e.approvalOutcome==="allowed"?`Allowed ${t}. Recorded in the chat.`:e.approvalOutcome==="denied"?`Didn’t allow ${t}. Recorded in the chat.`:`${t} wasn’t answered in time, so it didn’t run. Recorded in the chat.`}function _b(e,t){const n=c.useRef(null),s=c.useRef(null),[o,a]=c.useState({text:"",nonce:0});return c.useEffect(()=>{s.current!==t&&(s.current=t,n.current=null);const i=e.filter(d=>d.type==="tool_call"&&d.approvalOutcome!==void 0);if(n.current===null){n.current=new Set(i.map(d=>d.toolCallId));return}const l=i.filter(d=>!n.current.has(d.toolCallId));if(l.length===0)return;for(const d of l)n.current.add(d.toolCallId);const u=l.length===1?Sb(l[0]):`Answered ${l.length} permission requests. Recorded in the chat.`;a(d=>({text:u,nonce:d.nonce+1}))},[e,t]),c.useEffect(()=>{if(o.text==="")return;const i=setTimeout(()=>a(l=>({text:"",nonce:l.nonce})),Cb);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}​`}const Br=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"],zr=5e3,jb=1e3,wb=1500,Nb=new Set;function Eb(e){const t=c.useRef(new Map),n=Do({byTask:new Map,assigned:0}),[s,o]=c.useState(Nb),[,a]=c.useState(0),i=c.useMemo(()=>{const u=new Map;for(const d of e)for(const f of d.parts)f.type==="background_task"&&u.set(f.taskId,f);return u},[e]);c.useEffect(()=>{if(!Array.from(i.values()).some(f=>f.taskType==="bash"&&f.status==="running"&&Date.now()-f.startedAt<zr))return;const d=setInterval(()=>{a(f=>f+1)},jb);return()=>clearInterval(d)},[i]);const l=c.useRef(new Set);return c.useLayoutEffect(()=>{for(const[u,d]of i)t.current.get(u)==="running"&&d.status!=="running"&&!Hs(d)&&o(h=>h.has(u)?h:new Set(h).add(u)),t.current.set(u,d.status)},[i]),c.useEffect(()=>{for(const u of s)l.current.has(u)||(l.current.add(u),setTimeout(()=>{l.current.delete(u),o(d=>{if(!d.has(u))return d;const f=new Set(d);return f.delete(u),f})},wb))},[s]),c.useMemo(()=>{const u=Date.now(),d=[],f=n.read();let h=f.assigned;for(const[m,g]of i){const x=g.status==="running",C=s.has(m);if(!x&&!C||g.taskType==="bash"&&x&&u-g.startedAt<zr)continue;let b=f.byTask.get(m);b===void 0&&(b=Br[h%Br.length],h+=1,f.byTask.set(m,b),n.write({byTask:f.byTask,assigned:h})),d.push({taskId:g.taskId,taskType:g.taskType,status:g.status,color:b,startedAt:g.startedAt,description:g.description,toolUses:g.toolUses,lastToolName:g.lastToolName,durationMs:g.durationMs,summary:g.summary,command:g.command,ambient:Hs(g)})}return d},[i,s,n])}const Db=new Set(["streaming","blocked"]);function Tb(e,t){return e.length===0||e[0].waitingOn!==void 0||t&&Db.has(t)?e:e.slice(1)}function On(e,t,n){return`${e} ${e===1?t:n}`}const qr={"delivery-owed":"a helper’s report","waiting-on-person":"your answer","timer-pending":"a reminder the agent set"},Ab={"timer-pending":"Switching now cancels the reminder."};function Fb(e){const{agents:t,shells:n,other:s}=e.holding,o=[t>0?On(t,"helper","helpers"):void 0,n>0?On(n,"command","commands"):void 0,s>0?On(s,"background job","background jobs"):void 0].filter(d=>d!==void 0),a=o.length===0?void 0:o.length===1?o[0]:`${o.slice(0,-1).join(", ")} and ${o.at(-1)}`,i=e.pins,l=i.includes("cwd")&&e.targetFolderName?`moves to ${e.targetFolderName}`:i.includes("agentIdentity")?"switches agents":i.includes("systemPromptAppend")?"loads new instructions":"applies new settings";return{line:`${a!==void 0?`Held for ${a}.`:e.because!==void 0&&qr[e.because]!==void 0?`Held for ${qr[e.because]}.`:"Held until the agent is free."} Sending it ${l}.`,switchHint:a!==void 0?`Switching now stops ${a}.`:(e.because!==void 0?Ab[e.because]:void 0)??"Switching now stops what the agent is doing."}}const Rb={"session-idle":null,unsupported:"Queued. This agent can’t take a message mid-task.","not-steerable":"Couldn’t cut in. It’s waiting in line.","not-stageable":null,"turn-owned-elsewhere":"Couldn’t cut in: something else is running it. It’s waiting in line.","pending-interaction":"Queued. The agent needs your answer first."};function Mb(e){return e!=null&&e.degradedBecause?Rb[e.degradedBecause]:null}function Ur(e){return(e==null?void 0:e.code)==="QUEUED_MESSAGE_NOT_FOUND"}function Ob({sessionId:e,waiting:t,onEnqueue:n}){const s=Ce(),o=pc(e??""),[a,i]=c.useState(null),l=c.useMemo(()=>t.map(p=>({id:p.id,content:p.content,mine:s.clientId===void 0||p.enqueuedBy===s.clientId,notice:Mb(o[p.id]),...p.waitingOn?{waiting:Fb(p.waitingOn)}:{}})),[t,o,s.clientId]),u=c.useMemo(()=>{if(a===null)return null;const p=l.findIndex(_=>_.id===a);return p===-1?null:p},[a,l]),d=c.useCallback(()=>{var p;if(e)return(p=je.getState().getSession(e).queuedMessages[0])==null?void 0:p.id},[e]),f=c.useCallback((p,_)=>{p().catch(j=>{Ur(j)||Ee.error(_)})},[]),h=c.useCallback(async p=>{const _=p.trim();return!_||!e?!1:n(_)},[e,n]),m=c.useCallback((p,_)=>{e&&f(()=>s.updateQueuedMessage(e,p,{content:_}),"Couldn’t save that change")},[e,s,f]),g=c.useCallback(p=>{i(_=>_===p?null:_),e&&f(()=>s.removeQueuedMessage(e,p),"Couldn’t take that message off the queue")},[e,s,f]),x=c.useCallback((p,_)=>{if(!e)return;const j=D=>s.updateQueuedMessage(e,p,{move:{before:D}});f(async()=>{try{await j(_)}catch(D){if(!Ur(D))throw D;const T=d();if(T===void 0||T===p)return;await j(T)}},"Couldn’t move that message")},[e,s,f,d]),C=c.useCallback(p=>l.findIndex(j=>j.id===p)<=0?!1:(i(j=>j===p?null:j),x(p,l[0].id),!0),[l,x]),b=c.useCallback(p=>{const _=l.findIndex(j=>j.id===p);_<=0||x(p,l[_-1].id)},[l,x]),y=c.useCallback(p=>{const _=l.find(j=>j.id===p);return _?(i(p),_.content):null},[l]),k=c.useCallback(()=>{i(null)},[]),v=c.useCallback(p=>{a!==null&&(m(a,p),i(null))},[a,m]);return{queue:l,editingId:a,editingIndex:u,addToQueue:h,removeFromQueue:g,sendNow:C,moveUp:b,startEditing:y,cancelEditing:k,saveEditing:v,updateQueued:m}}function Ua(e,t){return e===null?null:`${e} ${t??""}`}function Ib({input:e,setInput:t,sessionId:n,selectedCwd:s,waiting:o,onEnqueue:a,onSteer:i,onStage:l,tryNativeCommand:u,chatInputRef:d}){const f=c.useRef(""),h=c.useRef(null),m=Ua(n,s);c.useEffect(()=>{f.current="",h.current=null},[m]);const g=Ob({sessionId:n,waiting:o,onEnqueue:a}),x=g.cancelEditing;c.useEffect(()=>{x()},[m,x]);const C=c.useCallback(()=>{const F=g.editingId;if(F===null)return;const O=e.trim();O&&(g.updateQueued(F,O),bx(O)&&Ee.warning("Saved as a command. It runs instead of sending."))},[e,g]),b=Us(g.editingId),y=Us(g.updateQueued);c.useEffect(()=>{const F=n;return()=>{const O=b.read();if(O===null||!F)return;const L=re.getState(),G=L.getSession(F).input.trim();G&&y.read()(O,G),L.updateSession(F,{input:f.current})}},[m]);const k=c.useCallback(F=>{const O=e.trim();if(!O)return;const L=u(O);if(L.handled){if(!L.ran)return;L.confirmed?Yn(n,O,L.confirmed):t("");return}if(h.current===O)return;h.current=O,at.getState().recordOpened("session",n),s&&at.getState().recordOpened("agent",s);const G=F(O);G.finally(()=>{h.current===O&&(h.current=null)}),Yn(n,O,G)},[e,s,n,t,u]),v=c.useCallback(()=>k(F=>g.addToQueue(F)),[k,g]),p=c.useCallback(()=>{i&&k(i)},[k,i]),_=c.useCallback(()=>{l&&k(l)},[k,l]),j=c.useCallback(F=>{var G,V;if(g.editingId===F){(G=d.current)==null||G.focus();return}const O=g.editingId!==null;O&&C();const L=g.startEditing(F);L!==null&&(O||(f.current=e),t(L),(V=d.current)==null||V.focus())},[e,g,C,t,d]),D=c.useCallback(()=>{if(g.editingId===null)return;const F=e.trim();if(!F)return;const O=u(F);if(O.handled){O.ran&&(g.cancelEditing(),t(f.current));return}g.saveEditing(F),t(f.current)},[e,g,t,u]),T=c.useCallback(()=>{g.cancelEditing(),t(f.current)},[g,t]),w=c.useCallback(F=>{g.editingId===F&&t(f.current),g.removeFromQueue(F)},[g,t]),A=c.useCallback(F=>{const O=g.editingId===F;O&&C(),g.sendNow(F)&&O&&t(f.current)},[g,C,t]),S=c.useCallback(F=>{g.moveUp(F)},[g]),E=c.useCallback(F=>{var G;const O=(G=g.queue[F])==null?void 0:G.id;if(O!==void 0&&O===g.editingId)return;C();const L=O===void 0?null:g.startEditing(O);if(L===null){g.cancelEditing(),t(f.current);return}t(L)},[g,C,t]),N=c.useCallback(()=>{C(),g.cancelEditing(),t(f.current)},[C,g,t]),R=c.useCallback(()=>{const{editingIndex:F,queue:O}=g;if(F===null){if(O.length===0)return;f.current=e,E(O.length-1)}else F>0?E(F-1):N()},[E,e,N,g]),M=c.useCallback(()=>{const{editingIndex:F,queue:O}=g;F!==null&&(F<O.length-1?E(F+1):N())},[E,N,g]);return{queue:g.queue,editingId:g.editingId,editingIndex:g.editingIndex,handleQueue:v,handleSteer:p,handleStage:_,handleQueueEdit:j,handleQueueSaveEdit:D,handleQueueCancelEdit:T,handleQueueRemove:w,handleQueueSend:A,handleQueueMoveUp:S,handleQueueNavigateUp:R,handleQueueNavigateDown:M,leaveQueueForStop:N}}const $b=5e3,Hr=3;function Ha(){try{const e=Number(localStorage.getItem(To.PLACEHOLDER_HINT_CYCLES));return Number.isFinite(e)&&e>0?e:0}catch{return 0}}function Pb(){const e=Ha()+1;try{localStorage.setItem(To.PLACEHOLDER_HINT_CYCLES,String(e))}catch{}return e}function Lb(e){const t=[...e];for(let n=t.length-1;n>0;n--){const s=Math.floor(Math.random()*(n+1));[t[n],t[s]]=[t[s],t[n]]}return t}function Bb({defaultText:e,hints:t,enabled:n,intervalMs:s=$b}){const[o]=c.useState(()=>t.length>0?Lb(t):[]),[a,i]=c.useState(()=>Ha()>=Hr),[l,u]=c.useState({key:0,hintIndex:-1}),d=c.useRef(0),f=c.useRef(0),h=c.useRef(!1);return c.useEffect(()=>{if(a||!n||t.length===0){h.current&&(h.current=!1,d.current+=1,u({key:d.current,hintIndex:-1}));return}const g=setInterval(()=>{if(d.current+=1,h.current=!h.current,!h.current){u({key:d.current,hintIndex:-1});return}const x=f.current%t.length;f.current+=1,f.current%t.length===0&&Pb()>=Hr&&i(!0),u({key:d.current,hintIndex:x})},s);return()=>clearInterval(g)},[n,t.length,s,a]),{text:l.hintIndex>=0?o[l.hintIndex]??e:e,key:l.key}}const In=/[.!?…:](?=\s|$)|\n/g;function Wr(e,t,n){const s=e.startsWith(t)?t.length:0,o=e.slice(0,s),a=e.slice(s);if(a.trim()==="")return{chunk:"",announced:o};if(n)return{chunk:a.trim(),announced:e};In.lastIndex=0;let i=-1;for(let l=In.exec(a);l!==null;l=In.exec(a))i=l.index+l[0].length;return i===-1?{chunk:"",announced:o}:{chunk:a.slice(0,i).trim(),announced:e.slice(0,s+i)}}const zb=1500,qb=4e3,Ub=400;function Hb({messageId:e,text:t,isStreaming:n}){const s=c.useRef(new Map),[o,a]=c.useState({text:"",nonce:0});return c.useEffect(()=>{if(e===void 0)return;if(s.current.get(e)===void 0){if(!n)return;s.current.clear(),s.current.set(e,{announced:t.length<=Ub?"":t})}const l=s.current.get(e),{chunk:u,announced:d}=Wr(t,l.announced,!1);l.announced=d,u!==""&&a(h=>({text:u,nonce:h.nonce+1}));const f=setTimeout(()=>{const h=Wr(t,l.announced,!0);l.announced=h.announced,h.chunk!==""&&a(m=>({text:h.chunk,nonce:m.nonce+1}))},zb);return()=>clearTimeout(f)},[e,t,n]),c.useEffect(()=>{if(o.text==="")return;const i=setTimeout(()=>a(l=>({text:"",nonce:l.nonce})),qb);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}​`}const Wa={reactions:!1,threads:!1,runWith:!0,attachments:!0,mentions:!1,streamHealth:!1,presence:!1,turnStatus:!0,asks:!0};function Wb(e){var t;(t=e==null?void 0:e.querySelector('[data-testid="model-config-trigger"]'))==null||t.click()}const Gr=new WeakMap;function Gb(e,t,n,s,o=!0){const a=new Set(t),i=new Set(n.flatMap(f=>f.roomMessage?[f.roomMessage.entryId]:[]));let l;const u=o?null:Yb(n),d=[];for(const f of e){if(f.kind!=="post"||f.threadRootEntryId||f.sessionId!==null&&a.has(f.sessionId)&&(l??(l=Kb(n)),l.has(f.body.text)||!o&&(u===null||Date.parse(f.createdAt)<u))||i.has(f.id))continue;let h=Gr.get(f);if(!h){const m=f.body.text;h={id:`direct-note-${f.id}`,role:s.has(f.authorId)?"assistant":"user",content:m,parts:[{type:"text",text:m}],timestamp:f.createdAt,_directNote:{roomId:f.roomId,entryId:f.id,seq:f.seq}},Gr.set(f,h)}d.push(h)}return d}const Vb=/(?:^|[_.])(?:post_to_room|relay_notify_user)$/;function Kb(e){const t=new Set;for(const n of e){if(n.role!=="assistant")continue;const s=[];for(const o of n.parts??[])if(o.type==="text")t.add(o.text),t.add(o.text.trim()),s.push(o.text.trim());else if(o.type==="tool_call"&&o.input&&Vb.test(o.toolName))for(const a of Qb(o.input))t.add(a);s.length>1&&t.add(s.filter(Boolean).join(`
54
+
55
+ `).trim())}return t}function Qb(e){try{const t=JSON.parse(e);return t===null||typeof t!="object"?[]:Object.values(t).filter(n=>typeof n=="string")}catch{return[]}}function Yb(e){let t=null;for(const n of e){const s=Date.parse(n.timestamp);!Number.isNaN(s)&&(t===null||s<t)&&(t=s)}return t}function Xb(e,t){if(t.length===0)return e;const n=[];let s=0;for(const o of e){const a=o.timestamp==="",i=Date.parse(o.timestamp);for(;s<t.length&&(a||!Number.isNaN(i)&&Date.parse(t[s].timestamp)<i);)n.push(t[s]),s+=1;n.push(o)}for(;s<t.length;)n.push(t[s++]);return n}function Jb(e,t,n=!0){if(!t||t.entries.length===0)return{messages:e,lastSeenBeforeUnread:null,unreadFromStart:!1};const s=Gb(t.entries,t.sessionIds,e,t.agentAuthorIds,n),o=Xb(e,s),{readSeq:a}=t,i=a===null?-1:o.findIndex(l=>l._directNote!==void 0&&l.role==="assistant"&&l._directNote.seq>a);return{messages:o,lastSeenBeforeUnread:i>0?o[i-1].id:null,unreadFromStart:i===0}}function Zb(e){var f,h,m;const t=hc(e),n=((f=t.data)==null?void 0:f.roomId)??null,s=gc(n),o=xc(n),a=s.data,i=o.data;Nu(n,i!==void 0),bc(a,i??Vr);const l=((h=a==null?void 0:a.members.find(g=>g.author.id===a.viewerAuthorId))==null?void 0:h.lastReadSeq)??null,u=ty(n,l),d=((m=t.data)==null?void 0:m.sessionIds)??ey;return c.useMemo(()=>{const g=s.isError||o.isError,x=n===null||g||i!==void 0&&u!==null;return{roomId:n,entries:i??Vr,sessionIds:d,agentAuthorIds:new Set(((a==null?void 0:a.members)??[]).filter(C=>C.author.kind==="agent").map(C=>C.author.id)),readSeq:u,ready:e===null||t.isError||t.isFetched&&x}},[e,t.isError,t.isFetched,n,a,i,d,u,s.isError,o.isError])}const ey=[],Vr=[];function ty(e,t){const[n,s]=c.useState({key:null,value:null});return n.key===e&&n.value!==null?n.value:e===null||t===null?null:(s({key:e,value:t}),t)}function Kr(e){return e>=1e3?`~${(e/1e3).toFixed(1)}k tokens`:`~${Math.round(e)} tokens`}function ny(e){const{formatted:t}=Po(e.status==="streaming"?e.streamStartTime:null),n=ao(e.permissionMode),s=c.useRef(e.status),o=c.useRef(t),a=c.useRef(e.estimatedTokens),[i,l]=c.useState(!1);return c.useEffect(()=>{e.status==="streaming"&&(o.current=t,a.current=e.estimatedTokens,s.current!=="streaming"&&l(!1))},[e.status,t,e.estimatedTokens]),c.useEffect(()=>{s.current==="streaming"&&e.status==="idle"&&a.current>0&&l(!0),s.current=e.status},[e.status]),c.useEffect(()=>{if(!i)return;const u=setTimeout(()=>l(!1),en.TURN_COMPLETE_DISMISS_MS);return()=>clearTimeout(u)},[i]),Eu({capabilities:Wa,asks:e.asks??Mo,stalled:!1,presence:Du,turn:{status:e.status,isWaitingForUser:e.isWaitingForUser,waitingType:e.waitingType,operationProgress:e.operationProgress==null?null:{message:e.operationProgress.message??null,determinate:e.operationProgress.determinate,percent:e.operationProgress.percent??null},systemStatus:e.systemStatus??null,elapsed:t,activity:e.activity,tokens:Kr(e.estimatedTokens),isBypass:n,showComplete:i,lastElapsed:o.current,lastTokens:Kr(a.current)}})}function sy(e){const{sessionId:t,placeholder:n,files:s}=e,o=c.useRef(e);c.useEffect(()=>{o.current=e});const a=c.useCallback(C=>o.current.files.addFiles(C),[]),i=c.useCallback(C=>o.current.files.removeFile(C),[]),l=c.useCallback(C=>o.current.files.retryFile(C),[]),u=c.useCallback(()=>o.current.files.cancelUpload(),[]),{pendingFiles:d,hasFailedUpload:f,isUploading:h}=s,m=c.useMemo(()=>({staged:d,add:a,remove:i,retry:l,cancel:u,hasFailed:f,isUploading:h,holdsSendWhileUploading:!0}),[d,f,h,a,i,l,u]),g=c.useCallback(async C=>{await o.current.submit(C.text)},[]),x=c.useCallback(async C=>{if(!await o.current.enqueue(C.text))throw new Error("Couldn’t queue that message. Try again.")},[]);return c.useMemo(()=>({kind:"session",id:t,placeholder:n,canSend:t!=="",...t===""?{canSendReason:"Pick a chat, or start a new one."}:{},send:g,queue:x,attachments:m}),[t,n,m,g,x])}function ry({error:e,composerAgent:t,onRetry:n}){return e.code===go&&e.agentId?r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(Vo,{agentId:e.agentId,...(t==null?void 0:t.id)===e.agentId?{agentName:nn(t,"This agent")}:{}})}):r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(on,{message:e.message,heading:e.heading,subtext:e.message,onRetry:e.retryable?n:void 0})})}const oy={duration:.16,delay:.08,ease:[.16,1,.3,1]},ay={duration:0};function iy({sessionId:e,activeInteraction:t,pendingApprovals:n,focusedOptionIndex:s,onToolRef:o,onToolDecided:a,queueDepth:i=0,allowsDenyReason:l=!0}){const u=x=>a(t.toolCallId,x),d=Fe(),{answerAll:f,isAnswering:h,error:m}=yc(),g=c.useMemo(()=>n.map(x=>({sessionId:e,cwd:"",interaction:{type:"approval",id:x.toolCallId,startedAt:x.approvalStartedAt??0,remainingMs:x.timeoutMs??0,toolName:x.toolName,input:x.input??"",hasSuggestions:x.approvalHasSuggestions??!1}})),[n,e]);return r.jsxs(r.Fragment,{children:[n.length>=2&&r.jsx(vc,{className:"mb-1.5",headline:`${n.length} tools are waiting on you`,items:n.map(x=>({id:x.toolCallId,line:_t(x.toolName,x.input??"")})),onAllowAll:()=>void f(g,"allow"),onDenyAll:()=>void f(g,"deny"),isAnswering:h,error:m}),r.jsx(ce,{mode:"wait",initial:!1,children:r.jsx(W.div,{initial:d?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:d?ay:oy,children:t.interactiveType==="approval"?r.jsx(yo,{ref:o,sessionId:e,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input||"",isActive:!0,onDecided:u,timeoutMs:t.timeoutMs,approvalStartedAt:t.approvalStartedAt,approvalRemainingMs:t.approvalRemainingMs,approvalParked:t.approvalParked,approvalTitle:t.approvalTitle,approvalDisplayName:t.approvalDisplayName,approvalDescription:t.approvalDescription,approvalBlockedPath:t.approvalBlockedPath,approvalDecisionReason:t.approvalDecisionReason,approvalHasSuggestions:t.approvalHasSuggestions,approvalAlwaysAllowScope:t.approvalAlwaysAllowScope,allowsDenyReason:l}):t.interactiveType==="question"&&t.questions?r.jsx(vo,{ref:o,sessionId:e,toolCallId:t.toolCallId,questions:t.questions,answers:t.answers,isActive:!0,focusedOptionIndex:s,onDecided:u}):null},t.toolCallId)}),i>0&&r.jsx("p",{className:"text-muted-foreground px-1 pt-2 text-xs",children:i===1?"1 message sends once you answer.":`${i} messages send once you answer.`})]})}function ly({filteredCommands:e,selectedIndex:t,onSelect:n}){const s=c.useMemo(()=>{const o=[],a=new Map;let i=0;for(const l of e){const u=l.namespace??"built-in";a.has(u)||a.set(u,[]),a.get(u).push({cmd:l,index:i++})}for(const[l,u]of a)o.push({namespace:l,items:u});return o},[e]);return c.useEffect(()=>{const o=document.getElementById(`command-item-${t}`);o&&o.scrollIntoView({block:"nearest"})},[t]),r.jsx(W.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:o=>o.preventDefault(),children:r.jsx("div",{id:"command-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?r.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No commands found."}):s.map(({namespace:o,items:a},i)=>r.jsxs("div",{children:[i>0&&r.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),r.jsx("div",{className:"text-muted-foreground/70 text-2xs px-2 pt-1.5 pb-1 font-medium tracking-wide uppercase",children:o}),a.map(({cmd:l,index:u})=>{const d=u===t,f=l.disabled===!0;return r.jsxs("div",{id:`command-item-${u}`,role:"option","aria-selected":d,"aria-disabled":f,"data-selected":d,"data-disabled":f,tabIndex:d?0:-1,onClick:()=>{f||n(l)},onKeyDown:h=>{h.key==="Enter"&&!f&&n(l)},className:f?"cursor-not-allowed rounded-md px-2 py-1.5 opacity-45":"data-[selected=true]:bg-accent hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 transition-colors duration-100",children:[r.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[r.jsx("span",{className:"text-foreground text-control shrink-0 font-mono font-medium",children:l.fullCommand}),l.argumentHint&&r.jsx("span",{className:"text-muted-foreground/50 shrink-0 font-mono text-xs",children:l.argumentHint}),f&&l.disabledReason?r.jsx("span",{className:"text-muted-foreground/70 text-2xs ml-auto shrink-0",children:l.disabledReason}):l.matchedAlias&&r.jsxs("span",{className:"text-muted-foreground/60 text-2xs ml-auto shrink-0 font-mono italic",children:["matched /",l.matchedAlias.replace(/^\//,"")]})]}),l.description&&r.jsx("p",{className:"text-muted-foreground mt-0.5 truncate text-xs leading-normal",children:l.description})]},l.fullCommand)})]},o))})})}function cy(e,t,n,s){return e!==null?`Edit queued message ${e+1} of ${n}. Press Enter to save`:t&&n>0?`Compose another (${n} queued)`:t?"Compose next. It sends when ready":s}function uy({chatInputRef:e,input:t,autocomplete:n,steerContent:s,addContextContent:o,tryNativeCommand:a,commandPending:i,agentLookupPending:l=!1,agentLookupError:u=!1,status:d,stop:f,setInput:h,sessionId:m,sessionStatus:g,waiting:x,interaction:C,sync:b}){var Ye,ze;const{active:y,pendingApprovals:k,focusedOptionIndex:v,onToolRef:p,onToolDecided:_}=C,j=d==="streaming",D=oe(pe=>pe.isTextStreaming),[T]=Ao(),w=Ce(),{data:A}=fs(T),S=kc(A??null,T??""),E=A?nn(A):void 0,{target:N}=Tu(),R=(N==null?void 0:N.placeholder)??"Send a message…",M=Cc(m),F=om(m),O=sn(m),L=tn(O),G=Sc(m),V=((L==null?void 0:L.supportsSteer)??!1)&&(G??!0),Q=(L==null?void 0:L.supportsContextStaging)??!1,U=((Ye=L==null?void 0:L.permissionModes)==null?void 0:Ye.denyReason)??!0,I=c.useCallback(async pe=>{if((N==null?void 0:N.queue)===void 0)return!1;try{return await N.queue({text:pe}),!0}catch{return!1}},[N]),P=Ib({input:t,setInput:h,sessionId:m,selectedCwd:T,waiting:x,onEnqueue:I,onSteer:s,onStage:o,tryNativeCommand:a,chatInputRef:e}),[$,K]=c.useState(null),ue=c.useRef(null),z=c.useCallback(pe=>{const xe=ue.current;if(ue.current=null,pe.length===0)return;const Ae=pe.map(We=>xe&&We.id===xe.id?xe.content:We.content).join(`
56
+
57
+ `),Oe=re.getState().getSession(m).input.trim();h(Oe?`${Oe}
58
+
59
+ ${Ae}`:Ae)},[m,h]),[X,J]=c.useState(null),ae=X===m&&j,ve=c.useRef(null),H=c.useCallback(()=>{ve.current=null,J(null)},[]);c.useEffect(()=>{j||H()},[j,m,H]);const ie=c.useRef(j);c.useEffect(()=>{ie.current=j},[j]);const _e=P.leaveQueueForStop,be=c.useRef(P.editingId);c.useEffect(()=>{be.current=P.editingId},[P.editingId]);const Y=c.useCallback(()=>{const pe=be.current;if(pe!==null){const xe=re.getState().getSession(m).input.trim();xe&&(ue.current={id:pe,content:xe}),_e()}ve.current=m,J(m),f().then(xe=>{z(xe.cancelled),nb(xe.receipt,ie.current)&&H();const Ae=tb(xe.receipt);Ae.message!==null&&!No(xe.receipt)&&(Ae.isFailure?Ee.error(Ae.message):Ee.warning(Ae.message))}).catch(()=>{H()})},[m,f,z,H,_e]),De=c.useCallback(()=>{if(!(ve.current===m||ae)){if(x.length===0){Y();return}K({sessionId:m,queuedCount:x.length})}},[m,ae,x.length,Y]),Te=c.useCallback(()=>{ve.current===m||ae||(K(null),Y())},[m,ae,Y]);c.useEffect(()=>{($==null?void 0:$.sessionId)===m&&x.length===0&&K(null)},[$,m,x.length]);const{messages:ke}=wo(m),fe=_o(m),ee=c.useMemo(()=>qa(fe,ke),[fe,ke]),Z=Eb(ee),ne=c.useCallback(async pe=>{if(m)try{await w.stopTask(m,pe)}catch(xe){console.error("[chat] Failed to stop task:",xe)}},[m,w]),de=c.useCallback(()=>{m&&w.switchSessionProcess(m).catch(()=>{Ee.error("Couldn’t switch. Try again.")})},[m,w]),he=c.useRef(t);c.useEffect(()=>{he.current=t});const ye=c.useCallback(pe=>{var We;const xe=he.current,Ae=xe.length>0&&!/\s$/.test(xe)?" ":"",Oe=`${xe}${Ae}${pe}`;h(Oe),(We=e.current)==null||We.focusAt(Oe.length)},[h,e]);c.useEffect(()=>Xu(ye),[ye]);const ge=!j&&P.editingIndex===null,Re=Bb({defaultText:R,hints:qx,enabled:ge&&t===""}),Be=Zu(),Me=c.useCallback(()=>{n.dismissPalettes(),!(N===null||!N.canSend)&&N.send({text:t})},[n,N,t]),se=c.useCallback(()=>{n.dismissPalettes(),P.handleQueue()},[n,P]),Se=c.useCallback(()=>{n.dismissPalettes(),P.handleSteer()},[n,P]),ft=c.useCallback(()=>{n.dismissPalettes(),P.handleStage()},[n,P]);return r.jsx(St.Composer,{className:"chat-input-container",onPathDropped:pe=>ye(Ju(pe)),inputRef:e,value:t,onChange:n.handleInputChange,onSubmit:Me,head:r.jsx(ce,{children:j&&r.jsx(Cd,{color:S.color,isTextStreaming:D,edge:"top"})}),asks:y?r.jsx(iy,{sessionId:m,activeInteraction:y,pendingApprovals:k,focusedOptionIndex:v,onToolRef:p,onToolDecided:_,queueDepth:P.queue.length,allowsDenyReason:U}):null,overlays:r.jsx(r.Fragment,{children:r.jsxs(ce,{children:[n.commands.show&&r.jsx(ly,{filteredCommands:n.commands.filtered,selectedIndex:n.commands.selectedIndex,onSelect:n.handleCommandSelect}),n.files.show&&r.jsx(lm,{filteredFiles:n.files.filtered,selectedIndex:n.files.selectedIndex,onSelect:n.handleFileSelect})]})}),queue:r.jsx(ce,{children:P.queue.length>0&&r.jsx(ux,{queue:P.queue,editingId:P.editingId,onEdit:P.handleQueueEdit,onRemove:P.handleQueueRemove,onSend:P.handleQueueSend,onMoveUp:P.handleQueueMoveUp,onSwitchNow:de,statusNote:M?"Waiting for your answer above":((ze=P.queue[0])==null?void 0:ze.waiting)!==void 0?"Sending when the agent is free":"Sending one at a time as the agent finishes"})}),aboveInput:r.jsx(ix,{tasks:Z,onStopTask:ne}),footer:r.jsx(St.Footer,{asChild:!0,children:r.jsx(Mx,{sessionId:m,sessionStatus:g,isStreaming:j,syncConnectionState:b.connectionState,agentName:E,agentColor:S.color,agentEmoji:S.emoji,agentPath:T??void 0})}),input:{isStreaming:j,commandPending:i,...l||u?{canSubmit:!1,canSubmitReason:u?"Check this folder again before you start.":"Checking this folder…"}:{},...F.canSubmit?{}:{canSubmit:!1},onStop:De,stopPending:ae,onEscape:n.dismissPalettes,onClear:()=>{h(""),n.dismissPalettes()},isPaletteOpen:n.isPaletteOpen,paletteHasResults:n.paletteHasResults,onArrowUp:n.handleArrowUp,onArrowDown:n.handleArrowDown,onCommandSelect:n.handleKeyboardSelect,activeDescendantId:n.activeDescendantId,paletteListboxId:n.paletteListboxId,onCursorChange:n.handleCursorChange,richText:Be,editingQueueItem:P.editingIndex!==null,...P.editingIndex===null?{}:{editingPosition:P.editingIndex+1},queueDepth:P.queue.length,onQueue:se,...V?{onSteer:Se}:{},...Q?{onStage:ft}:{},onSaveEdit:P.handleQueueSaveEdit,onCancelEdit:P.handleQueueCancelEdit,onQueueNavigateUp:P.handleQueueNavigateUp,onQueueNavigateDown:P.handleQueueNavigateDown,queueHasItems:P.queue.length>0,contextKey:Ua(m,T)??void 0,placeholder:F.placeholder??cy(P.editingIndex,j,P.queue.length,R),placeholderOverlay:ge&&F.canSubmit?r.jsx(px,{text:Re.text,animationKey:Re.key}):null},children:r.jsx(dx,{open:($==null?void 0:$.sessionId)===m,onOpenChange:pe=>{pe||K(null)},queuedCount:($==null?void 0:$.queuedCount)??0,onConfirm:Te})})}const dy=e=>{const t=e;return t.role==="user"?r.jsx(Bg,{message:t}):r.jsx(Rg,{message:t})};function fy(e,t){for(const n of Object.keys({...e,...t}))if(!(n==="grouping"||n==="author"||n==="feedPosition")&&!Object.is(e[n],t[n]))return!1;return e.grouping.position===t.grouping.position&&Qr(e.author,t.author)&&Qr(e.feedPosition,t.feedPosition)}function Qr(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(s=>Object.is(e[s],t[s]))}const my=c.memo(py,fy);function py({message:e,grouping:t,author:n,sessionId:s,isNew:o=!1,isStreaming:a=!1,isLatestWidgetMessage:i=!0,isFinalMessage:l=!0,activeToolCallId:u=null,onToolRef:d,focusedOptionIndex:f=-1,onToolDecided:h,onRetry:m,onSigninComplete:g,onChooseModel:x,inputZoneToolCallId:C=null,textEffect:b,runtimeLabel:y,allowsDenyReason:k,directRoomId:v,feedPosition:p}){var G,V;const _=c.useId(),j=`${_}-author`,D=`${_}-content`,T=c.useRef(null),w=t.position==="first"||t.position==="only",A=e.role==="user",S=A&&e.messageType!=="local_command_output",E=A?(G=e.chatMessages)==null?void 0:G[0]:void 0,N=A&&E===void 0?e.roomMessage:void 0,R=S&&E===void 0&&(N===void 0||((V=N.author)==null?void 0:V.you)===!0)&&e.messageType!=="command"&&e.messageType!=="compaction"&&e.content.trim().length>0,M=e.timestamp?Ln(e.timestamp):"",F=M.length>0,O=F?e.timestamp:void 0,L=c.useCallback(()=>{var Q;return(Q=T.current)==null?void 0:Q.focus()},[]);return r.jsx(gp,{value:{sessionId:s,isStreaming:a,isLatestWidgetMessage:i,isFinalMessage:l,activeToolCallId:u,onToolRef:d,focusedOptionIndex:f,onToolDecided:h,onRetry:m,onSigninComplete:g,onChooseModel:x,inputZoneToolCallId:C,textEffect:b,runtimeLabel:y,allowsDenyReason:k},children:r.jsxs(et.Root,{ref:T,role:S?"user":"assistant",position:t.position,isNew:o,"data-testid":"message-item","data-role":e.role,...w?{"aria-labelledby":j}:{"aria-label":F?`${n.displayName}, ${M}`:n.displayName},"aria-describedby":D,...Au(p),children:[r.jsx(et.Gutter,{author:n,at:O}),r.jsxs(et.Body,{children:[r.jsx(et.Author,{id:j,author:n,at:O,...E?{mark:r.jsx(ma,{stamp:E}),className:"flex-wrap gap-y-0.5"}:N&&N.roomId!==v?{mark:r.jsx(np,{stamp:N}),className:"flex-wrap gap-y-0.5"}:{}}),r.jsx(et.Content,{id:D,children:dy(e,{rowId:e.id})}),R&&r.jsx(et.Actions,{runWith:{prompt:e.content,sessionId:s},onExit:L})]})]})})}function hy({loading:e,onLoad:t}){return r.jsx("div",{className:"flex justify-center px-4 py-3",children:r.jsxs(le,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:e,"data-testid":"session-load-earlier",className:"text-muted-foreground hover:text-foreground h-7 gap-2 text-xs",children:[e&&r.jsx(Le,{size:"xs"}),e?"Loading earlier messages…":"Earlier messages"]})})}const Yr="Conversation",gy={kind:"notice",id:"session-load-earlier",at:"",body:null},xy=[];function by(e){for(let t=e.length-1;t>=0;t--)if(e[t].content.includes(Uu))return t;return-1}function yy({messages:e,sessionId:t,isLoadingHistory:n=!1,hydrated:s=!1,isTextStreaming:o=!1,activeToolCallId:a=null,onToolRef:i,focusedOptionIndex:l=-1,onToolDecided:u,onRetry:d,onSigninComplete:f,onChooseModel:h,inputZoneToolCallId:m=null,textEffect:g,runtimeLabel:x,allowsDenyReason:C,landOnRow:b,foldFirstPrompt:y=!1,directLog:k}){const v=pt(i),p=pt(u),_=pt(d),j=pt(f),D=pt(h),T=pp(t,e),w=T.messages,{stops:A}=pa(t),S=!T.canLoadEarlier,E=c.useMemo(()=>Jb(w,k,S),[w,k,S]),N=c.useMemo(()=>Jm(E.messages,A),[E.messages,A]),R=c.useMemo(()=>{let ee=0;return N.map(Z=>Z._chatStop||Z._directNote?-1:ee++)},[N]),M=Do(null);M.read()===null&&w.length>0&&M.write(T.messagesBefore+w.length);const F=c.useMemo(()=>by(N),[N]),O=c.useMemo(()=>y&&!T.canLoadEarlier?N.findIndex(ee=>ee.role==="user"&&ee.messageType===void 0&&!ee._stagedContext&&!ee._chatStop&&!ee._directNote):-1,[y,T.canLoadEarlier,N]),L=Zt(t),G=oe(ee=>ee.selectedCwd),V=sn(t),{data:Q}=fs(G),U=c.useMemo(()=>({agent:Q?{id:Q.id,displayName:nn(Q),...Et(Q)}:null,runtime:V}),[Q,V]),I=w[w.length-1],P=(I==null?void 0:I.role)==="assistant"?I:void 0,$=Hb({messageId:P==null?void 0:P.id,text:(P==null?void 0:P.content)??"",isStreaming:P!==void 0&&o}),K=_b((I==null?void 0:I.parts)??xy,t),{lastSeenMessageId:ue,unreadFromStart:z,markSeen:X,isHydrated:J}=bf(t,w,T.messagesBefore),[ae,ve]=c.useState(()=>Date.now()),H=c.useRef(null);c.useLayoutEffect(()=>{const ee=Date.now(),Z=new Date(ee).toDateString();if(H.current===null){H.current=Z;return}H.current!==Z&&(H.current=Z,ve(ee))},[N]);const ie=c.useCallback(ee=>vm(ee,U),[U]),[_e]=c.useState(Cm),be=c.useMemo(()=>Sm(N,{resolveAuthor:ie,now:ae,lastSeenMessageId:E.lastSeenBeforeUnread??ue,unreadFromStart:E.unreadFromStart||z,cache:_e}),[N,ie,ae,ue,z,E,_e]),[Y]=c.useState(()=>new WeakMap),De=c.useMemo(()=>{const ee=be.map(Z=>{const ne=Y.get(Z);if(ne)return ne;const de=Z.kind==="day-divider"?{kind:"day-divider",id:Z.key,label:Z.label}:Z.kind==="unread-divider"?{kind:"unread-divider",id:Z.key}:{kind:"message",id:Z.key,payload:Z.message,grouping:Z.grouping,author:Z.author,at:Z.message.timestamp};return Y.set(Z,de),de});return T.canLoadEarlier?[gy,...ee]:ee},[be,Y,T.canLoadEarlier]),Te=T.canLoadEarlier?1:0,ke=c.useCallback((ee,Z)=>{var se,Se;if(Te===1&&Z.index===0)return r.jsx(hy,{loading:T.isLoadingEarlier,onLoad:T.loadEarlier});const ne=be[Z.index-Te];if(ne.kind==="day-divider")return r.jsx(Fu,{label:ne.label});if(ne.kind==="unread-divider")return r.jsx(Ru,{});const{message:de,messageIndex:he}=ne;if(de._stagedContext)return r.jsx(Ep,{content:de.content});if(de._chatStop)return r.jsx("div",{className:"px-4 py-1",children:r.jsx(lp,{notice:de._chatStop})});if(he===O)return r.jsx(Bm,{content:((Se=(se=de.chatMessages)==null?void 0:se[0])==null?void 0:Se.text)??de.content});const ye=R[he]??he,ge=ye>=0&&ye===w.length-1,Re=ge&&de.role==="assistant",Be=F===-1||he>=F,Me=M.read();return r.jsx(my,{message:de,grouping:ne.grouping,author:ne.author,sessionId:t,directRoomId:k==null?void 0:k.roomId,isNew:Me!==null&&T.messagesBefore+ye>=Me,isStreaming:Re&&o,isLatestWidgetMessage:Be,isFinalMessage:ge,activeToolCallId:a,onToolRef:v,focusedOptionIndex:l,onToolDecided:p,onRetry:_,onSigninComplete:j,onChooseModel:D,inputZoneToolCallId:m,textEffect:g,runtimeLabel:x,allowsDenyReason:C,feedPosition:{index:ye+1,total:w.length}})},[be,Te,T.isLoadingEarlier,T.loadEarlier,T.messagesBefore,w.length,R,F,O,t,k==null?void 0:k.roomId,M,o,a,v,l,p,_,j,D,m,g,x,C]),fe=L&&L.kind!=="first-message"&&L.fired&&!L.greetingFailed&&s?L:null;return r.jsx(St.Timeline,{conversationId:t,label:Yr,rows:De,renderRow:ke,landOn:"unread",landingReady:J&&!T.isSeeking&&((k==null?void 0:k.ready)??!0),...b===void 0?{}:{landOnRow:b},onReachedBottom:X,transcriptAnnouncement:$,approvalAnnouncement:K,className:"pt-12 [--conversation-thumb-top:3rem]",loading:n?r.jsx(Mu,{label:Yr,busy:!0,className:"flex h-full items-center justify-center","data-testid":"transcript-feed-loading",children:r.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[r.jsx(ca,{}),"Loading chat…"]})}):void 0,empty:r.jsx("div",{className:"flex h-full items-center justify-center",children:r.jsx(Rm,{birthRecord:L,firstLightRecord:fe})}),"data-testid":"message-list",feedTestId:"transcript-feed"})}function vy({sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s=!1,launchSeed:o,onLaunchConsumed:a,landOnRow:i}){var Ns,Es,Ds;const[,l]=wt(),u=rs(),d=c.useRef(null),f=c.useRef(null),h=c.useCallback(()=>Wb(f.current),[]),m=Zb(e),g=lb(e),x=_c(e??""),C=rb(),{play:b}=$c(),[y]=Ao(),{data:k,isPending:v,isError:p,refetch:_}=fs(y),{sessions:j}=Jn(),D=e!==null&&!j.some(B=>B.id===e),T=jc(e),w=pb(),A=c.useCallback(async B=>{let we=B;if(w.hasPendingFiles){const Xe=await w.uploadAndGetPaths(),Ts=y?Xe.map(Mt=>Mt.startsWith(y)?Mt.slice(y.length).replace(/^\//,""):Mt):Xe;Ts.length>0&&(we=`Please read the following uploaded file(s):
60
+ ${Ts.map(oi=>`- ${oi}`).join(`
61
+ `)}
62
+
63
+ ${we}`),w.clearFiles()}return we},[w,y]),S=c.useCallback(B=>{g.handleTaskEvent(B);const we=g.tasks.map(Xe=>Xe.id===B.task.id?{...Xe,...B.task}:Xe);C.handleTaskEvent(B,we)},[g,C]);c.useCallback(B=>{l(B),u.invalidateQueries({queryKey:Ge.bySession(B)})},[l,u]);const E=c.useCallback(B=>{l(B,{replace:!0}),u.invalidateQueries({queryKey:Ge.bySession(B)})},[l,u]),N=c.useCallback(B=>{l(crypto.randomUUID(),{continuedFrom:B??void 0,draft:!0})},[l]),R=So(e??""),M=tn(R.runtime),F=R.runtime?Tt(R.runtime).label:"",O=((Ns=M==null?void 0:M.permissionModes)==null?void 0:Ns.denyReason)??!0,L=c.useMemo(()=>Oa(M==null?void 0:M.commandIntents,F),[M,F]),G=c.useRef(null),V=c.useCallback(()=>{var B;return(B=G.current)==null?void 0:B.call(G)},[]),{messages:Q,input:U,setInput:I,handleSubmit:P,submitContent:$,enqueueContent:K,steerContent:ue,addContextContent:z,status:X,error:J,stop:ae,isLoadingHistory:ve,hydrated:H,sessionStatus:ie,streamStartTime:_e,estimatedTokens:be,isTextStreaming:Y,isWaitingForUser:De,waitingType:Te,activeInteraction:ke,pendingInteractions:fe,markToolCallResponded:ee,systemStatus:Z,operationProgress:ne,promptSuggestions:de,syncConnectionState:he,retryMessage:ye,tryNativeCommand:ge,commandPending:Re}=eb(e,{transformContent:A,onTaskEvent:S,onSessionIdChangeReplace:E,startFreshSession:N,compactIntent:L,launchRuntime:t,...k&&y?{agentPath:y}:{},agentLookupPending:y!==null&&v,agentLookupFailed:y!==null&&p,takeSeedContext:V,onStreamingDone:c.useCallback(()=>{b("turn-end"),u.invalidateQueries({queryKey:["commands"]})},[b,u])}),Be=c.useCallback(B=>$(B,{clearInput:!0}),[$]),{permissionMode:Me,permissionModeKnown:se}=Ro(e,ie,X==="streaming"),Se=vu(e,R.runtime,se?Me:void 0),ft=wc(B=>B.setOpen);c.useEffect(()=>{ft(!1)},[e,ft]);const{handleToolRef:Ye,focusedOptionIndex:ze}=cb(ke);mb(X,De,Y),c.useEffect(()=>{var B;(B=d.current)==null||B.focusUnlessTouch()},[e]);const pe=c.useCallback(()=>{var B;(B=d.current)==null||B.focusUnlessTouch()},[]);gb({sessionId:e,prompt:n,autoSend:s,input:U,setInput:I,messageCount:Q.length,hydrated:H,status:X,submitBlocked:D&&y!==null&&(v||p),submit:P,onSeeded:pe,onConsumed:a});const xe=vb({sessionId:e,seed:o,messageCount:Q.length,hydrated:H,onConsumed:a});c.useEffect(()=>{G.current=xe},[xe]);const Ae=R.runtime?is(R.runtime):void 0,{data:Oe}=Pc(y,e??void 0,R.runtime??void 0),We=c.useMemo(()=>kx((Oe==null?void 0:Oe.commands)??[],{commandIntents:M==null?void 0:M.commandIntents,runtimeLabel:F}),[Oe,M,F]),{data:mt}=cm(y),Ga=c.useMemo(()=>mt!=null&&mt.files?_m(mt.files):[],[mt]),Va=fb({input:U,setInput:I,commands:We,fileEntries:Ga}),bs=c.useCallback(()=>{const B=[...Q].reverse().find(we=>we.role==="user");B!=null&&B.content&&$(B.content)},[Q,$]),ys=Zt(e??""),Ka=c.useCallback(()=>{const B=jm(Q,ys);B&&ye(B)},[Q,ys,ye]),vs=X==="idle"&&de.length>0&&U.length===0,Qa=Nc("chat.suggestion-chips"),Ya=am(e??""),Xa=kb(X,J,Q,Ya),Ja=c.useMemo(()=>Q.some(B=>B.role==="user"),[Q]),ks=c.useCallback(B=>{var we;I(B),(we=d.current)==null||we.focus()},[I]),Za=Mo,Rt=Ec(e??""),un=Eo(e??""),ei=c.useMemo(()=>Tb(Rt,un),[Rt,un]),Cs=(Ds=(Es=ds(e??""))==null?void 0:Es.lastError)==null?void 0:Ds.category,dn=Tm(),Ss=c.useCallback(()=>{const B=e??"";if(dn.claimedElsewhere(B))return!1;const we=Nm({messages:Q,status:X,lastErrorCategory:Cs,queuedCount:Rt.length,draft:re.getState().getSession(B).input});return we===null?!1:(dn.claim(B),$(we),!0)},[Q,X,Cs,Rt.length,e,$,dn]),ti=k?`Message ${nn(k)}…`:"Send a message…",ni=sy({sessionId:e??"",placeholder:ti,submit:Be,enqueue:K,files:w}),{eligible:_s,allow:js,notNow:ws}=mf(X==="streaming"),si=c.useMemo(()=>[{id:"prompt-suggestions",show:vs,render:()=>r.jsx(Fc,{suggestions:de,onChipClick:ks})},{id:"permission-primer",show:_s,render:()=>r.jsx(ff,{onAllow:js,onNotNow:ws})},{id:"read-only-mode",show:Se.eligible,render:()=>r.jsx(ku,{runtimeLabel:Se.runtimeLabel,onShown:Se.markShown,onDismiss:Se.dismiss})}],[vs,de,ks,_s,js,ws,Se]),ri=ny({asks:Za,status:X,streamStartTime:_e,estimatedTokens:be,permissionMode:Me,isWaitingForUser:De??!1,waitingType:Te??"approval",operationProgress:ne,systemStatus:Z,activity:x});return r.jsx(St.Root,{surface:"session",capabilities:Wa,target:ni,children:r.jsxs("div",{ref:f,"data-testid":"chat-panel","data-turn-status":X,"data-turn-lifecycle":un??void 0,className:"flex h-full w-full flex-col",children:[r.jsx(Om,{sessionId:e}),r.jsx(Pm,{startedBy:T,modes:M==null?void 0:M.permissionModes.values}),r.jsx(yy,{messages:Q,sessionId:e,isLoadingHistory:ve,hydrated:H,isTextStreaming:Y,activeToolCallId:(ke==null?void 0:ke.toolCallId)??null,onToolRef:Ye,focusedOptionIndex:ze,onToolDecided:ee,onRetry:bs,onSigninComplete:Ss,onChooseModel:h,inputZoneToolCallId:(ke==null?void 0:ke.toolCallId)??null,runtimeLabel:Ae,allowsDenyReason:O,...i===void 0?{}:{landOnRow:i},foldFirstPrompt:T!==null,directLog:m}),r.jsx(Lx,{terminalReason:ie==null?void 0:ie.terminalReason}),r.jsx(St.LiveLane,{state:ri,scope:"session"}),r.jsx(Lc,{candidates:si,ready:H,name:"session-bottom-slot",className:"px-4 pb-2"}),X==="idle"&&Qa.map(B=>r.jsx(B.component,{},B.id)),r.jsx(hp,{celebration:C.activeCelebration,onComplete:C.clearCelebration}),r.jsx(Qg,{tasks:g.tasks,taskMap:g.taskMap,activeForm:g.activeForm,isCollapsed:g.isCollapsed,onToggleCollapse:g.toggleCollapse,celebratingTaskId:C.celebratingTaskId,onCelebrationComplete:C.clearCelebration,statusTimestamps:g.statusTimestamps}),Xa&&r.jsx(zx,{sessionId:e,onRetry:Ja?bs:void 0,onSigninComplete:Ss,onChooseModel:h}),J&&r.jsx(ry,{error:J,composerAgent:k,onRetry:Ka}),D&&p&&r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(on,{heading:"Couldn’t check this folder",message:"DorkOS couldn’t tell if an agent owns this folder. Try again.",onRetry:()=>void _()})}),e&&r.jsx(em,{sessionId:e,onSend:B=>void $(B)}),r.jsx(uy,{chatInputRef:d,input:U,autocomplete:Va,steerContent:ue,addContextContent:z,tryNativeCommand:ge,commandPending:Re,agentLookupPending:D&&y!==null&&v,agentLookupError:D&&y!==null&&p,status:X,stop:ae,setInput:I,sessionId:e??"",sessionStatus:ie,waiting:ei,interaction:{active:ke,pendingApprovals:fe.filter(B=>B.interactiveType==="approval"),focusedOptionIndex:ze,onToolRef:Ye,onToolDecided:ee},sync:{connectionState:he}})]})})}function ky(e,t){const n=e===null||t===void 0?null:`${e}:${t}`,s=c.useRef(null);c.useEffect(()=>{if(!(e===null||t===void 0))return s.current=`${e}:${t}`,Pe.getState().seek(e,t),()=>{const i=Pe.getState();i.seeks[e]===t&&i.endSeek(e)}},[e,t]);const o=c.useRef(null),a=c.useCallback(()=>{var d;if(n===null||o.current===n||t===void 0||e===null)return;const i=Pe.getState().seeks[e]===t;if(s.current!==n||i)return;o.current=n;const l=((d=Pe.getState().sessions[e])==null?void 0:d.earlier)??[],u=je.getState().getSession(e).messages;return aa(fa([...l,...u],t)??t)},[n,t,e]);return n===null?void 0:a}function Cy(){const[e]=wt();Pd(e);const{runtime:t,prompt:n,send:s,seed:o,message:a}=Zr(),i=Dc(),l=ky(e,a),{data:u}=Tc(e,{enabled:!1,select:h=>h.title}),d=jo(e);ld(e,{canonical:d===null}),Bc();const f=c.useCallback(()=>{i==null||i({search:h=>({...h,prompt:void 0,send:void 0,seed:void 0}),replace:!0})},[i]);return r.jsxs(r.Fragment,{children:[r.jsx(Ac,{children:u!=null&&u.trim()?u:"Chat"}),r.jsx(vy,{sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s==="1",launchSeed:o,onLaunchConsumed:f,...l===void 0?{}:{landOnRow:l}})]})}const jv=Cy;export{jv as component};