dorkos 0.125.3 → 0.126.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +87749 -87287
- package/dist/browser/native/package-manifest.json +1 -1
- package/dist/browser/source-manifest.json +1 -1
- package/dist/client/assets/{AboutPage-DSSx1Gzx.js → AboutPage-2c9n8B32.js} +1 -1
- package/dist/client/assets/{ActivityErrorState-C-mLOmJm.js → ActivityErrorState-muwC_jif.js} +1 -1
- package/dist/client/assets/{ActivityPage-DsOjjulF.js → ActivityPage-2aUz3zv0.js} +1 -1
- package/dist/client/assets/{ActivityRow-ylgCMe7Y.js → ActivityRow-nQBqDCak.js} +1 -1
- package/dist/client/assets/{AdapterIcon-DT5OdFbe.js → AdapterIcon-ChpyilnO.js} +1 -1
- package/dist/client/assets/{AdapterSetupWizard-C6jxF55P.js → AdapterSetupWizard-DRKQp5Gh.js} +2 -2
- package/dist/client/assets/{AgentOptionRow-CtdBmX9G.js → AgentOptionRow-CeVPhvTq.js} +1 -1
- package/dist/client/assets/{AgentPicker--wr93sVO.js → AgentPicker-D8YX1P_q.js} +1 -1
- package/dist/client/assets/{AgentRequestCard-DVoE2cnk.js → AgentRequestCard-refCLvuV.js} +3 -3
- package/dist/client/assets/{AppearancePage-DR_g6BJO.js → AppearancePage-BDTIp3j0.js} +1 -1
- package/dist/client/assets/{ApplyToOverridesDialog-BqaoB6AS.js → ApplyToOverridesDialog-C-XL9N4W.js} +1 -1
- package/dist/client/assets/{AttentionSignalRow-CM0TrrbJ.js → AttentionSignalRow-Dn4rP542.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-DJ54CELa.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-B0sy0nRk.js} +1 -1
- package/dist/client/assets/{BindingDialog-JAPULq7H.js → BindingDialog-DMYB-vWm.js} +1 -1
- package/dist/client/assets/{BlintzCanvas-B3-FjszN.js → BlintzCanvas-D9ZLEDXc.js} +28 -28
- package/dist/client/assets/{CanvasCsvContent-Cmqry1BS.js → CanvasCsvContent-DMqGpNWm.js} +1 -1
- package/dist/client/assets/{CanvasFileContent-BMkxUF1r.js → CanvasFileContent-Bxhc86lv.js} +2 -2
- package/dist/client/assets/{CanvasModel3dContent-DBhuNbFD.js → CanvasModel3dContent-D783Ql7m.js} +2 -2
- package/dist/client/assets/ChannelComposer-BNlD-d2W.js +44 -0
- package/dist/client/assets/{ChatAppsOff-CY5_0lQH.js → ChatAppsOff-eRAfqzJR.js} +2 -2
- package/dist/client/assets/{CodeMirrorDiff-_EI44zW6.js → CodeMirrorDiff-CqEUAG6G.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-x1lTuDQH.js → CodeMirrorEditor-BM1ANude.js} +1 -1
- package/dist/client/assets/{CommitmentList-D-CvccnF.js → CommitmentList-C3QvbbGF.js} +1 -1
- package/dist/client/assets/{CommitmentsPage-CLw1FRLv.js → CommitmentsPage-bmqKNd-Z.js} +1 -1
- package/dist/client/assets/{ComputerResourceView-QJnXivV4.js → ComputerResourceView-78falOZG.js} +1 -1
- package/dist/client/assets/{ComputerViewer-DbTGz3OL.js → ComputerViewer-DZ2RiDbn.js} +1 -1
- package/dist/client/assets/{ConnectionAccessLists-CB5UY0f0.js → ConnectionAccessLists-CXsNyR4U.js} +1 -1
- package/dist/client/assets/{ConnectionsPage-SpEJxCeF.js → ConnectionsPage-bpkRfRRK.js} +2 -2
- package/dist/client/assets/{ConventionPage-C2NIZjG3.js → ConventionPage-rYtICYjS.js} +3 -3
- package/dist/client/assets/{ExtensionPageRoute-Drr5uceG.js → ExtensionPageRoute-DXTqUrR4.js} +2 -2
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-kKteNmsx.js → FloatingTanStackRouterDevtools-CqogiFob-CCNB3_Gb.js} +1 -1
- package/dist/client/assets/ForwardConsentHost-BfVnJ6oD.js +1 -0
- package/dist/client/assets/HandlePage-BH_G4sMV.js +1 -0
- package/dist/client/assets/{HeartbeatPage-BLGTx_57.js → HeartbeatPage-DdAfcR81.js} +1 -1
- package/dist/client/assets/{KeyEntry-DgN8iewR.js → KeyEntry-CR7GBqXf.js} +1 -1
- package/dist/client/assets/{LexicalField-Bfj72GvX.js → LexicalField-RAoub3wq.js} +2 -2
- package/dist/client/assets/{ManagesPage-C3G1-Mep.js → ManagesPage-CEhYj9ov.js} +1 -1
- package/dist/client/assets/{Marketplace-Dg0bIo7_.js → Marketplace-DtxHDbF4.js} +2 -2
- package/dist/client/assets/{MarketplaceSourcesView-KPw8YYXi.js → MarketplaceSourcesView-CSFvFtV_.js} +1 -1
- package/dist/client/assets/{McpAppFrame-DjJ4EM39.js → McpAppFrame-1mPdRK9p.js} +2 -2
- package/dist/client/assets/{McpSigninBody-V6RSsDqe.js → McpSigninBody--HfjMnE1.js} +1 -1
- package/dist/client/assets/{Model3dViewer-woNPO5OC.js → Model3dViewer-BT2SY67i.js} +1 -1
- package/dist/client/assets/NamePage-CaJsVRhh.js +1 -0
- package/dist/client/assets/NewDirectMessageMenu-QUtJTzKI.js +1 -0
- package/dist/client/assets/{NotificationsPage-kUtiVsFS.js → NotificationsPage-D3fleW0i.js} +1 -1
- package/dist/client/assets/OpenMeshSwitch-8WEn0WrA.js +5 -0
- package/dist/client/assets/{OperatorIdentityForm-B29T-N9x.js → OperatorIdentityForm-BRKAQS0D.js} +1 -1
- package/dist/client/assets/{PermissionHistory-CV8cFJr3.js → PermissionHistory-5stLHBu8.js} +1 -1
- package/dist/client/assets/{PermissionsPage-_PKlbWde.js → PermissionsPage-C2pB1TCJ.js} +1 -1
- package/dist/client/assets/{PersonalityPopover-BOXTCA6E.js → PersonalityPopover-DIbsJ6HP.js} +1 -1
- package/dist/client/assets/PhotoPage-33Xh8sq1.js +1 -0
- package/dist/client/assets/{PreviewRefusedNotice-CdHja8fU.js → PreviewRefusedNotice-CjT7jQ45.js} +1 -1
- package/dist/client/assets/{ProfileFields-C48alR3i.js → ProfileFields-gZNaFBow.js} +1 -1
- package/dist/client/assets/{ProfilePanelContainer-BpJVbdUL.js → ProfilePanelContainer-DYf7L8xJ.js} +1 -1
- package/dist/client/assets/{ProfileRolePicker-DtuSZNaw.js → ProfileRolePicker-DclYXFSP.js} +1 -1
- package/dist/client/assets/{PromptSuggestionChips-DT-JdGeO.js → PromptSuggestionChips-k9HolS90.js} +1 -1
- package/dist/client/assets/{ReportsToPopover-BP2nxz2E.js → ReportsToPopover-Bh5KrFbJ.js} +1 -1
- package/dist/client/assets/RoomSurface-32U7Wl6Z.js +1 -0
- package/dist/client/assets/{RoomsPage-gDIy73MQ.js → RoomsPage-sdMZgHla.js} +1 -1
- package/dist/client/assets/{RunsOnPopover-DhXG88Uj.js → RunsOnPopover-B5_Jz7ir.js} +1 -1
- package/dist/client/assets/RuntimeConnectFlow-C_6ozpAK.js +1 -0
- package/dist/client/assets/RuntimeSetupDialog-BDvzruM4.js +1 -0
- package/dist/client/assets/SeenDevices-CZ--8ljN.js +19 -0
- package/dist/client/assets/{SessionsPage-C6nmCWVM.js → SessionsPage-BKyrJh1O.js} +1 -1
- package/dist/client/assets/SettingsDialog-E5hPag3F.js +12 -0
- package/dist/client/assets/{SkillsPage-DSIKEsHr.js → SkillsPage-BeL6zfgw.js} +1 -1
- package/dist/client/assets/{TaskDialogWrapper-Cst7UxoY.js → TaskDialogWrapper-B-IP5hYv.js} +1 -1
- package/dist/client/assets/TasksEmptyState-BcftWVbk.js +3 -0
- package/dist/client/assets/TasksPage-CmroTI1v.js +1 -0
- package/dist/client/assets/{TeamComputerEntry-uj1GcPP_.js → TeamComputerEntry-DbfoZrZz.js} +1 -1
- package/dist/client/assets/{ToolsPage-Qm6x37SO.js → ToolsPage-h-PS45fZ.js} +1 -1
- package/dist/client/assets/{TopologyGraph-2C3Ij6tO.js → TopologyGraph-Bk_0y0Yy.js} +15 -15
- package/dist/client/assets/{TourHost-BsV8lcXT.js → TourHost-D4La-1-E.js} +1 -1
- package/dist/client/assets/{UnlinkDialog-ClNn0nv6.js → UnlinkDialog-CWd4fhT4.js} +1 -1
- package/dist/client/assets/UnreadDivider-Bvg9QLn9.js +1 -0
- package/dist/client/assets/{WidgetErrorCard-oq5MKUX_.js → WidgetErrorCard-DictdlWO.js} +2 -2
- package/dist/client/assets/WorkView-DxThzZ0w.js +51 -0
- package/dist/client/assets/{_shell-D4V8GQqV.js → _shell-CX_gaQPE.js} +22 -22
- package/dist/client/assets/{_shell._home-DoaHLKk8.js → _shell._home-CBNsPEH4.js} +1 -1
- package/dist/client/assets/{_shell._home.activity-BP1byb8g.js → _shell._home.activity-DpSGWVSW.js} +1 -1
- package/dist/client/assets/_shell._home.index-BWH93iWg.js +3 -0
- package/dist/client/assets/_shell._home.tasks-Ive4UW8c.js +1 -0
- package/dist/client/assets/{_shell._home.workspaces-BcOiklL5.js → _shell._home.workspaces-3R3VtH7x.js} +1 -1
- package/dist/client/assets/{_shell.channels-DxSDnd-3.js → _shell.channels-DRslcaiA.js} +4 -4
- package/dist/client/assets/{_shell.connections-YKOm7ap5.js → _shell.connections-BPQxNUPD.js} +1 -1
- package/dist/client/assets/{_shell.feedback-requests-DC2Jw1EF.js → _shell.feedback-requests-DkXEk3qm.js} +2 -2
- package/dist/client/assets/_shell.marketplace-D8deZF5L.js +1 -0
- package/dist/client/assets/_shell.marketplace_.sources-BHG9MqWR.js +1 -0
- package/dist/client/assets/_shell.session-CkdA2hgF.js +1 -0
- package/dist/client/assets/{_shell.team-C9QJNwaK.js → _shell.team-CZu-l34d.js} +3 -3
- package/dist/client/assets/_shell.threads-Cz-EZQXr.js +1 -0
- package/dist/client/assets/_shell.x._extensionId-Cry6E5KK.js +1 -0
- package/dist/client/assets/_shell.x._extensionId_._-Cry6E5KK.js +1 -0
- package/dist/client/assets/{abnfDiagram-WEYOIA3C-sjxf16g2.js → abnfDiagram-WEYOIA3C-4hI8_uRi.js} +1 -1
- package/dist/client/assets/{access-copy-_81ChCG3.js → access-copy-BegDAoeR.js} +1 -1
- package/dist/client/assets/{arc-B-c5OGeX.js → arc-DgydwPM5.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZHVYKT53-CExq4B1X.js → architectureDiagram-ZHVYKT53-4kexDkbn.js} +1 -1
- package/dist/client/assets/{banner-BhzLIs7u.js → banner-CYV5jQI0.js} +2 -2
- package/dist/client/assets/{blockDiagram-RJAE7QA3-C1D5MR7Z.js → blockDiagram-RJAE7QA3-BUP4L5_m.js} +1 -1
- package/dist/client/assets/{c4Diagram-XDPPPE54-DMtF_wcg.js → c4Diagram-XDPPPE54-B4HK3S3o.js} +1 -1
- package/dist/client/assets/{card-Dsy8PPN6.js → card-6VNSI3kT.js} +1 -1
- package/dist/client/assets/channel-Bf4e4rlX.js +1 -0
- package/dist/client/assets/{chunk-2E7WHVMD-DCmxZwyD.js → chunk-2E7WHVMD-Bhw5hCVI.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-BXvjhtJ3.js → chunk-2Q5K7J3B-CeUgfCvO.js} +1 -1
- package/dist/client/assets/{chunk-4EMNKR2T-CR6qWjas.js → chunk-4EMNKR2T-DqSZunXx.js} +1 -1
- package/dist/client/assets/{chunk-55XCU76K-Bny7RY06.js → chunk-55XCU76K-Bigp9-bU.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-B9aD4Uib.js → chunk-5VM5RSS4-DF1L8DrH.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-D28Xa5gr.js → chunk-JWPE2WC7-lcFap_43.js} +1 -1
- package/dist/client/assets/{chunk-VQ5W62QI-CLgnUSgl.js → chunk-VQ5W62QI-Bgmsy9NF.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-vMTRVR5A.js → chunk-XXDRQBXY-DFFzLm_u.js} +1 -1
- package/dist/client/assets/{chunk-ZCHMQSOR-Ck0VFEtd.js → chunk-ZCHMQSOR-B4aJwBdo.js} +2 -2
- package/dist/client/assets/{classDiagram-v2-4MYWR3UA-Dh4gPh4M.js → classDiagram-v2-4MYWR3UA-BdUAMGnS.js} +1 -1
- package/dist/client/assets/{command-CxjTPW0z.js → command-Dz2pZLle.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-BA-tF0x7.js → cose-bilkent-JH36ORCC-BdJxQmWe.js} +1 -1
- package/dist/client/assets/{cpu-SRODWAA1.js → cpu-CjKJ8pVl.js} +1 -1
- package/dist/client/assets/{cynefin-EF2NZ3EQ-B_kxrTf4.js → cynefin-EF2NZ3EQ-BvnDWKe0.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-WF24UDRP-Be0brpVq.js → cynefinDiagram-WF24UDRP-DKL8UyvS.js} +1 -1
- package/dist/client/assets/{dagre-NK4GIZVX-zI9I0fUC.js → dagre-NK4GIZVX-CCuJpxlY.js} +1 -1
- package/dist/client/assets/{diagram-CBK3MWTC-jN0pUEKR.js → diagram-CBK3MWTC-C1jeuv8r.js} +1 -1
- package/dist/client/assets/{diagram-I5XIIV2D-BjRZmmQf.js → diagram-I5XIIV2D-CSnTyOU0.js} +1 -1
- package/dist/client/assets/{diagram-ODIL2UCW-BtnkiX3a.js → diagram-ODIL2UCW-9w6q1YKi.js} +1 -1
- package/dist/client/assets/{diagram-PFBEJUXE-Bteh9wpL.js → diagram-PFBEJUXE-BMFBmD0P.js} +1 -1
- package/dist/client/assets/{diagram-RJA3I4VV-hRmqKbOC.js → diagram-RJA3I4VV-D9Utl6qX.js} +1 -1
- package/dist/client/assets/{diagram-TYUNFSNR-NKdthGes.js → diagram-TYUNFSNR-u_ogc51l.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-V4P3TTPT-CpkD13ID.js → ebnfDiagram-V4P3TTPT-Bg_smbFH.js} +1 -1
- package/dist/client/assets/{elk-QONTBCTQ-Dw4bdkn4.js → elk-QONTBCTQ-CtuwbIK2.js} +1 -1
- package/dist/client/assets/{empty-state-Xw8KQdod.js → empty-state-CbFKhqwB.js} +1 -1
- package/dist/client/assets/{erDiagram-KYQIGQAA-fiThyiH_.js → erDiagram-KYQIGQAA-MlvYHdZ7.js} +1 -1
- package/dist/client/assets/{execution-config-ryHuiBdx.js → execution-config-BjNjQoBp.js} +1 -1
- package/dist/client/assets/{file-CbZILJJL.js → file-JokR8lB2.js} +1 -1
- package/dist/client/assets/{file-exclamation-point-rCHuN_aY.js → file-exclamation-point-sl45DZYe.js} +1 -1
- package/dist/client/assets/{file-text-DGtefNvG.js → file-text-C4PxLfBm.js} +1 -1
- package/dist/client/assets/{find-latest-widget-fence-DJDfJAaN.js → find-latest-widget-fence-Bc1LICCy.js} +5 -5
- package/dist/client/assets/{flowDiagram-IUGLLWBU-ORyRd0wW.js → flowDiagram-IUGLLWBU-BlrKbUnh.js} +1 -1
- package/dist/client/assets/{form-USBlP2n_.js → form-1NlezfMg.js} +1 -1
- package/dist/client/assets/{format-cron-u8efK62G.js → format-cron-C57sE3sK.js} +1 -1
- package/dist/client/assets/{ganttDiagram-R7GPNTJY-BC-M9_Wi.js → ganttDiagram-R7GPNTJY-BhCCQ-d7.js} +3 -3
- package/dist/client/assets/{git-branch-jQqbJAvp.js → git-branch-BXEb1Sqq.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-NIdjLN38.js → gitGraphDiagram-PDYL7XHY-Chl1aqHg.js} +1 -1
- package/dist/client/assets/{graph-CBIOKOiw.js → graph-DIIpUxLd.js} +1 -1
- package/dist/client/assets/{heart-CSbB9K4Q.js → heart-CUs7jdhV.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-OC8sqXXy.js → highlighted-body-KPVGNVTW-DlDHGjld.js} +1 -1
- package/dist/client/assets/image-lightbox-BczXKBTZ.js +1 -0
- package/dist/client/assets/image-off-Ch98GGBJ.js +6 -0
- package/dist/client/assets/{index-CiAb-mD4.js → index-0MDZSAdr.js} +1 -1
- package/dist/client/assets/{index-C5gtuueN.js → index-37h1E-65.js} +1 -1
- package/dist/client/assets/{index-CeJVF9AD.js → index-8FrM4Unx.js} +1 -1
- package/dist/client/assets/{index-CRPh-508.js → index-B0p2_o3r.js} +1 -1
- package/dist/client/assets/{index-BU_bmsP2.js → index-B0q1o1JU.js} +1 -1
- package/dist/client/assets/{index-Yr72qWri.js → index-BAnl5kwm.js} +1 -1
- package/dist/client/assets/{index-w4wyJU8q.js → index-BC41bN42.js} +1 -1
- package/dist/client/assets/{index-DfYJ-zxk.js → index-BNJa5z6K.js} +7 -7
- package/dist/client/assets/{index-DJyLZL6w.js → index-BQlnEL5t.js} +1 -1
- package/dist/client/assets/{index-DkcRrH0O.js → index-BRyEtRBO.js} +1 -1
- package/dist/client/assets/index-BThp0Av1.js +1 -0
- package/dist/client/assets/{index-LFeqJL-v.js → index-BVjrgWDa.js} +1 -1
- package/dist/client/assets/{index-D9Ej8fsx.js → index-BiyMpL0z.js} +1 -1
- package/dist/client/assets/{index-DeDh_2c1.js → index-BwHCH3tE.js} +1 -1
- package/dist/client/assets/index-ByIDaFWv.js +1 -0
- package/dist/client/assets/{index-RXFhiamo.js → index-BzqkXlms.js} +1 -1
- package/dist/client/assets/index-CFJcOzPD.js +1 -0
- package/dist/client/assets/{index-B5eM1_q1.js → index-CQTeDD0B.js} +1 -1
- package/dist/client/assets/{index-BOaou3k5.js → index-CSOhBvPV.js} +1 -1
- package/dist/client/assets/{index-Dk33a8Wz.js → index-CYhf-E_N.js} +1 -1
- package/dist/client/assets/{index-CWhDGAYM.js → index-CaVP52c1.js} +1 -1
- package/dist/client/assets/{index-CRTzTiNF.js → index-Cn1ZEy3S.js} +1 -1
- package/dist/client/assets/{index-C9UgTEuh.js → index-CnNGTb8f.js} +1 -1
- package/dist/client/assets/{index-BGGnQdij.js → index-Cnjpi7ar.js} +3 -3
- package/dist/client/assets/{index-BYxDsLTQ.js → index-CoHeCySh.js} +1 -1
- package/dist/client/assets/index-CujX3mpY.css +1 -0
- package/dist/client/assets/{index-C49AWTah.js → index-Cw0QRsnv.js} +1 -1
- package/dist/client/assets/{index-CuT_aCM-.js → index-Czar7aPT.js} +2 -2
- package/dist/client/assets/{index-Bz9CgPjs.js → index-D1Be28yK.js} +1 -1
- package/dist/client/assets/{index-j5szQcqb.js → index-D6NjBiAq.js} +1 -1
- package/dist/client/assets/{index-fAHI5hei.js → index-DMfV6rUz.js} +1 -1
- package/dist/client/assets/index-D_9H4FdK.js +1 -0
- package/dist/client/assets/{index-B9utW3HE.js → index-DaZdDh7o.js} +1 -1
- package/dist/client/assets/{index-CDslENFz.js → index-DlZ77Qfj.js} +1 -1
- package/dist/client/assets/index-Dv6HjbCS.js +1 -0
- package/dist/client/assets/index-DwrBsA10.js +1053 -0
- package/dist/client/assets/{index-CCohVfmo.js → index-DzLIbXMR.js} +1 -1
- package/dist/client/assets/{index-n6f9pLtt.js → index-Ev7FZl9a.js} +1 -1
- package/dist/client/assets/{index-DJlq_kd_.js → index-HnW-eS5i.js} +1 -1
- package/dist/client/assets/{index-DnyoNFRt.js → index-hyqRnlFg.js} +1 -1
- package/dist/client/assets/{index-jJbbnV9q.js → index-pQstFziR.js} +3 -3
- package/dist/client/assets/{index-BN02EVKP.js → index-rKEUwjq8.js} +1 -1
- package/dist/client/assets/{index-BAaqQW-m.js → index-slBSiB-H.js} +1 -1
- package/dist/client/assets/{index-DgnJZ7RZ.js → index-vU7itvE8.js} +1 -1
- package/dist/client/assets/{index.esm-Dyd3JXuK.js → index.esm-DM8Bqi3n.js} +1 -1
- package/dist/client/assets/{infoDiagram-MVDRKAX5-CPcm-36U.js → infoDiagram-MVDRKAX5-C0p1eP9j.js} +1 -1
- package/dist/client/assets/{inline-code-BjkmgK0M.js → inline-code-CNmpgW3O.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-B8eVNEDQ.js → ishikawaDiagram-HPEHV2GE-COdxgYUT.js} +1 -1
- package/dist/client/assets/{journeyDiagram-BOSHW7O7-CGkIGaMV.js → journeyDiagram-BOSHW7O7-C84Ny9n9.js} +1 -1
- package/dist/client/assets/{kanban-definition-FNSA4HC5-BTDbT6UJ.js → kanban-definition-FNSA4HC5-ECSXhFX0.js} +1 -1
- package/dist/client/assets/{layers-DyShcAgn.js → layers-JgRwJGyf.js} +1 -1
- package/dist/client/assets/{lightbulb-QljDqLq7.js → lightbulb-BhQB8sFP.js} +1 -1
- package/dist/client/assets/{link-2-7SoeCkEs.js → link-2-B4byjdgg.js} +1 -1
- package/dist/client/assets/{list-runtime-types-DvfLx6v2.js → list-runtime-types-M5_gxIg1.js} +1 -1
- package/dist/client/assets/{markdown-content-D7t62wwm.js → markdown-content-C3qWcii6.js} +1 -1
- package/dist/client/assets/{mention-pill-DNQ2ICCW.js → mention-pill-DUbgdKmA.js} +1 -1
- package/dist/client/assets/{mermaid.core-NAyHAvFm.js → mermaid.core-BQiwaVjZ.js} +4 -4
- package/dist/client/assets/{message-square-off-D6K1M95g.js → message-square-off-AjtFFe_u.js} +1 -1
- package/dist/client/assets/{mindmap-definition-6OY57UG3-26dEepZx.js → mindmap-definition-6OY57UG3-BfA6EqgP.js} +1 -1
- package/dist/client/assets/{more-details-BJ_2FYn8.js → more-details-itSF4Fah.js} +1 -1
- package/dist/client/assets/{owner-notice-CIfb2Yr7.js → owner-notice-B6JRjE_c.js} +1 -1
- package/dist/client/assets/{package-CeRLwc1u.js → package-5YQSitlR.js} +1 -1
- package/dist/client/assets/{page-container-D2J6eon9.js → page-container-DBPUOYYM.js} +1 -1
- package/dist/client/assets/{pane-resize-handle-CXxva43c.js → pane-resize-handle-Kwb3zKa6.js} +1 -1
- package/dist/client/assets/{paperclip-DFuuQSWM.js → paperclip-IRKZTEQw.js} +1 -1
- package/dist/client/assets/{path-input-DhGxbEsh.js → path-input-BHkA4fFw.js} +1 -1
- package/dist/client/assets/{pegDiagram-ECIUJNBX-BJu6g9eg.js → pegDiagram-ECIUJNBX-CqIy9WDe.js} +1 -1
- package/dist/client/assets/{pieDiagram-GNMPY74T-CMf8TQF7.js → pieDiagram-GNMPY74T-C5yI3cvV.js} +1 -1
- package/dist/client/assets/{plug-Bqwk5g66.js → plug-CupdBXaG.js} +1 -1
- package/dist/client/assets/{primer-trigger-NAz78FSN.js → primer-trigger-Ci_XRRfX.js} +2 -2
- package/dist/client/assets/{profile-errors--0_JG2R0.js → profile-errors-aEsWNifs.js} +1 -1
- package/dist/client/assets/{progress-cQRXQehb.js → progress-Bpmb837n.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-D57K4MC3-Bb92PcA9.js → quadrantDiagram-D57K4MC3-DyCDNvk7.js} +1 -1
- package/dist/client/assets/{query-error-state-C2QLFCgp.js → query-error-state-s6AJaHa3.js} +1 -1
- package/dist/client/assets/{radio-CBD2fSSB.js → radio-Ci6Ghks8.js} +1 -1
- package/dist/client/assets/{railroadDiagram-Y72NRBL7-YN2siyto.js → railroadDiagram-Y72NRBL7-B3u1B937.js} +1 -1
- package/dist/client/assets/registry-DatwH4jj.js +1 -0
- package/dist/client/assets/registry-NGfn1R2_.js +34 -0
- package/dist/client/assets/{relay-trace-schemas-yWn__06J.js → relay-trace-schemas-hOFIzdY-.js} +2 -2
- package/dist/client/assets/{repeat-CtIEyxm4.js → repeat-B1S2ceC2.js} +1 -1
- package/dist/client/assets/{requirementDiagram-EQYSW5RA-DJBQviv-.js → requirementDiagram-EQYSW5RA-CdG-unip.js} +1 -1
- package/dist/client/assets/{room-files-source-nnbGMKus.js → room-files-source-J7gnN1gx.js} +2 -2
- package/dist/client/assets/{rotate-ccw-clock-C2jXtg-P.js → rotate-ccw-clock-7Q2akPFi.js} +1 -1
- package/dist/client/assets/{rotate-cw-34X3Kx8Z.js → rotate-cw-DK3Rzmlh.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-SY24JHO5-DH2qnwVI.js → sankeyDiagram-SY24JHO5-D3Z4Qk2b.js} +1 -1
- package/dist/client/assets/{scroll-area-DYTbXWMY.js → scroll-area-6Gelypei.js} +1 -1
- package/dist/client/assets/{search-x-DeFOvp_5.js → search-x-Be8VetKs.js} +2 -2
- package/dist/client/assets/{sequenceDiagram-BLEHNHQU-CkHcuOw2.js → sequenceDiagram-BLEHNHQU-RXPgeLr6.js} +1 -1
- package/dist/client/assets/{shield-x-bloGLifl.js → shield-x-D8lJ0Op0.js} +1 -1
- package/dist/client/assets/signed-in-NOeTLLso.js +1 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-BXK-Cxjs.js → sizeCapture-INFHLROL-q7qki1pK.js} +1 -1
- package/dist/client/assets/{soul-file-DFPctfHR.js → soul-file-DTEcjDxP.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-DP_cqXJO.js → stateDiagram-v2-A6IESKWZ-DFs6IVbj.js} +1 -1
- package/dist/client/assets/{swimlanes-B3ENRKFQ-BZxkK7Fr.js → swimlanes-B3ENRKFQ-D1A-3JE-.js} +1 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-hZFkkqUb.js +8 -0
- package/dist/client/assets/{table-B8zvHC0J.js → table-CuBPM_bg.js} +1 -1
- package/dist/client/assets/{timeline-definition-JXYKGLGB-BPZ64ADa.js → timeline-definition-JXYKGLGB-CLHy0rAb.js} +1 -1
- package/dist/client/assets/{trust-posture-C9r0jGhc.js → trust-posture-BXXe8F8n.js} +1 -1
- package/dist/client/assets/{unplug-DYZEcvkR.js → unplug-Cuej6sM6.js} +1 -1
- package/dist/client/assets/{unverified-catalog-notice-DAhwNpy_.js → unverified-catalog-notice-BbK4SCJp.js} +1 -1
- package/dist/client/assets/{use-adapter-catalog-DrDMqxhZ.js → use-adapter-catalog-Cy7ENVZN.js} +1 -1
- package/dist/client/assets/{use-bindings-Ci7hpEO4.js → use-bindings-Tj0BcF4m.js} +1 -1
- package/dist/client/assets/{use-composer-prefs-FpUdi_wE.js → use-composer-prefs-BrQVpwRi.js} +1 -1
- package/dist/client/assets/{use-connector-management-CinfkPZI.js → use-connector-management-CLZQXgln.js} +1 -1
- package/dist/client/assets/{use-deep-link-scroll-DZnA4iYZ.js → use-deep-link-scroll-BeqtUhj2.js} +1 -1
- package/dist/client/assets/{use-delete-binding-DDtaCc3v.js → use-delete-binding-d7ii9iFQ.js} +1 -1
- package/dist/client/assets/{use-dev-links-CtHwhTBj.js → use-dev-links-MYOV3h2q.js} +1 -1
- package/dist/client/assets/{use-direct-message-panel-Da9rkfA3.js → use-direct-message-panel-C_lXDYnB.js} +1 -1
- package/dist/client/assets/{use-external-adapter-catalog-CikM-LiV.js → use-external-adapter-catalog-kMFSEJGV.js} +1 -1
- package/dist/client/assets/use-full-activity-feed-MFSkvnza.js +1 -0
- package/dist/client/assets/use-is-below-desktop-CJJ4zMQO.js +1 -0
- package/dist/client/assets/{use-local-browser-ABoWOGv1.js → use-local-browser-1oVtlmXD.js} +1 -1
- package/dist/client/assets/{use-mesh-topology-C5njB0KY.js → use-mesh-topology-BJs6M6kh.js} +1 -1
- package/dist/client/assets/{use-mounted-ref-Bp9Wp7zY.js → use-mounted-ref-DitdlmSI.js} +1 -1
- package/dist/client/assets/{use-notification-prefs-DXww4pVV.js → use-notification-prefs-CXbRTRLF.js} +1 -1
- package/dist/client/assets/use-pending-read-CvX1lOb8.js +1 -0
- package/dist/client/assets/{use-personality-commit-DYQ3KVxd.js → use-personality-commit-DQrWyVGT.js} +1 -1
- package/dist/client/assets/{use-promo-activation-nURLgFxH.js → use-promo-activation-CgdBHk2f.js} +3 -3
- package/dist/client/assets/{use-promo-dismissals-BQkeHMCS.js → use-promo-dismissals-DprcDmfs.js} +1 -1
- package/dist/client/assets/{use-pulse-freshness-B8VeNnHj.js → use-pulse-freshness-BtMzHCs3.js} +1 -1
- package/dist/client/assets/{use-relay-config-D0BknsXK.js → use-relay-config-CGBlgXC2.js} +1 -1
- package/dist/client/assets/{use-room-follow-claim-BruRRf3z.js → use-room-follow-claim-Db5U7kWT.js} +1 -1
- package/dist/client/assets/{use-room-sessions-DGcrmZvE.js → use-room-sessions-K6mdH-Tb.js} +1 -1
- package/dist/client/assets/{use-roving-tab-list-YQ4MgIBO.js → use-roving-tab-list-B2zxa_F_.js} +1 -1
- package/dist/client/assets/{use-session-canvas-BaGypLR6.js → use-session-canvas-D4G5fO_a.js} +7 -7
- package/dist/client/assets/{use-status-budget-Q1ltHI80.js → use-status-budget-UccdTZ7o.js} +4 -4
- package/dist/client/assets/use-transform-BBj2pwbo.js +1 -0
- package/dist/client/assets/{use-unclaimed-chats-Bext8Aim.js → use-unclaimed-chats-BidDnyt8.js} +1 -1
- package/dist/client/assets/use-update-config-D8g4P42J.js +1 -0
- package/dist/client/assets/{useMutationState-C3WVn0hu.js → useMutationState-RYxTf1aD.js} +1 -1
- package/dist/client/assets/{usecaseDiagram-WPOLBNNX-Dg4P8nSr.js → usecaseDiagram-WPOLBNNX-Bjmcc2gK.js} +1 -1
- package/dist/client/assets/{vennDiagram-Q3Y3IDCW-B8Txoqsz.js → vennDiagram-Q3Y3IDCW-Cd6C9CxW.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-IVAIDKWA-lgQBspKc.js → wardleyDiagram-IVAIDKWA-CzWWmwUL.js} +1 -1
- package/dist/client/assets/{xychartDiagram-4URNHDU4-Ct9-Lgo9.js → xychartDiagram-4URNHDU4-DSUn9rhA.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/drizzle/20261025175042_dor3123_needs_attention.sql +7 -0
- package/dist/drizzle/meta/20261025175042_snapshot.json +14093 -0
- package/dist/drizzle/meta/_journal.json +7 -0
- package/dist/server/extension-child.cjs +188 -107
- package/dist/server/index.js +11572 -8338
- package/dist/server/index.js.map +2 -2
- package/package.json +7 -7
- package/dist/client/assets/ChannelComposer-WR3_Vvta.js +0 -44
- package/dist/client/assets/HandlePage-A1OCw0nr.js +0 -1
- package/dist/client/assets/NamePage-Du9m4rGe.js +0 -1
- package/dist/client/assets/NewDirectMessageMenu-CmCOFmXQ.js +0 -1
- package/dist/client/assets/OpenMeshSwitch-r6HJBjR6.js +0 -5
- package/dist/client/assets/PhotoPage-Dx-3Lhm5.js +0 -1
- package/dist/client/assets/RoomSurface-C_mTmn8g.js +0 -1
- package/dist/client/assets/RuntimeConnectFlow-BsZsQZS9.js +0 -1
- package/dist/client/assets/RuntimeSetupDialog-BSb5iK2A.js +0 -1
- package/dist/client/assets/SeenDevices-dzzlSeB2.js +0 -19
- package/dist/client/assets/SettingsDialog-5aEZ-DG6.js +0 -12
- package/dist/client/assets/TasksEmptyState-DityFi7P.js +0 -3
- package/dist/client/assets/TasksPage-BZx_Ku0k.js +0 -1
- package/dist/client/assets/UnreadDivider-CGKnJcx7.js +0 -1
- package/dist/client/assets/WorkView-wVnGvWAz.js +0 -63
- package/dist/client/assets/_shell._home.index-BB5pgiqt.js +0 -3
- package/dist/client/assets/_shell._home.tasks-B3w6mqyb.js +0 -1
- package/dist/client/assets/_shell.marketplace-BUh4boaf.js +0 -1
- package/dist/client/assets/_shell.marketplace_.sources-CnOFcGv1.js +0 -1
- package/dist/client/assets/_shell.session-BUP7x_Ra.js +0 -1
- package/dist/client/assets/_shell.threads-gs_o48eZ.js +0 -1
- package/dist/client/assets/_shell.x._extensionId-B-X7HuaQ.js +0 -1
- package/dist/client/assets/_shell.x._extensionId_._-B-X7HuaQ.js +0 -1
- package/dist/client/assets/channel-C6IoQ0kc.js +0 -1
- package/dist/client/assets/image-lightbox-DgWS2xlv.js +0 -1
- package/dist/client/assets/image-off-DziiNcIl.js +0 -6
- package/dist/client/assets/index-B-KhOLHd.js +0 -1
- package/dist/client/assets/index-BpsATTKn.js +0 -1
- package/dist/client/assets/index-CP7hD01s.js +0 -1
- package/dist/client/assets/index-CUKvspHB.js +0 -1
- package/dist/client/assets/index-DSYz85aL.js +0 -1053
- package/dist/client/assets/index-DYF1ER90.js +0 -23
- package/dist/client/assets/index-DtlBeLQB.css +0 -1
- package/dist/client/assets/index-YtJ82pkp.js +0 -1
- package/dist/client/assets/registry-CsiY3fnM.js +0 -1
- package/dist/client/assets/signed-in-DD2qV0PJ.js +0 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-DXRZtHKX.js +0 -8
- package/dist/client/assets/use-full-activity-feed-B6TQc-xB.js +0 -1
- package/dist/client/assets/use-is-below-desktop-DJQVU5CF.js +0 -1
- package/dist/client/assets/use-panel-tab-placements-DLQeHI7w.js +0 -1
- package/dist/client/assets/use-pending-read-CgR0BnSW.js +0 -1
- package/dist/client/assets/use-update-config-BJEw2LjV.js +0 -1
- /package/dist/client/assets/{WorkView-DIs3GY4I.css → registry-DIs3GY4I.css} +0 -0
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B9utW3HE.js","assets/index-DSYz85aL.js","assets/index-DtlBeLQB.css","assets/index-CiAb-mD4.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var ki=Object.defineProperty;var vi=(e,t,n)=>t in e?ki(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var et=(e,t,n)=>vi(e,typeof t!="symbol"?t+"":t,n);import{fo as Ci,iu as ao,qi as Si,r as c,fl as ji,W as dt,dW as Oe,j as r,ar as H,by as me,ih as rs,a1 as ve,qj as io,q as lt,ke as _i,ch as wi,qk as lo,ql as Ni,qm as Ei,fW as Di,B as fe,a7 as Fe,fe as Ti,G as U,J as tn,X as ct,b9 as bt,qn as _t,qo as co,aY as le,qp as Ai,qq as qn,ie as Fi,as as os,du as Ri,ap as Mi,iW as Oi,qr as Bs,el as zs,a8 as ut,pe as Ii,qs as $i,pk as vt,qt as Qt,a2 as Je,pf as as,a4 as Ct,hI as wt,ek as is,cb as Nt,cT as Pi,cU as Li,cW as Bi,cX as zi,cY as qi,dU as Ui,e as qs,lb as Wi,dB as Hi,x as He,lc as Gi,pc as ls,eg as Vi,qu as Ki,qv as Qi,lp as cs,qw as uo,qx as fo,qy as Xi,qz as Yi,iP as nn,a3 as us,cJ as Et,ej as sn,dS as ds,ei as Ji,qA as Zi,jN as mo,qB as el,ph as tl,h$ as nl,es as sl,aU as Xe,ai as Dt,a9 as fs,qC as rl,iX as ol,qD as al,bc as il,T as Tt,i4 as Ve,i5 as Ke,aj as po,qE as rn,dV as At,k7 as ll,cj as ft,s as Ft,hh as cl,hd as Us,ia as ho,hl as ul,C as ms,dx as dl,dy as fl,qF as ml,l as pl,mM as go,aW as hl,qG as gl,qH as xl,qI as bl,qJ as yl,qK as kl,qL as We,n_ as De,o7 as vl,n$ as on,aQ as Cl,hU as Sl,cs as jl,bL as _l,ji as wl,qM as ot,a0 as ps,dX as Ws,dw as xo,f as bo,qN as Nl,eR as El,aZ as Dl,gB as yo,il as ko,hM as St,jO as vo,dY as Tl,qO as Al,qP as Fl,o as Co,y as an,aV as So,qQ as jo,qR as Rl,nj as xn,qS as Xt,jv as Ml,lg as Ol,be as _o,qT as Il,qU as $l,gi as Pl,gj as Hs,qV as wo,qW as Ll,qX as Bl,qY as No,qZ as Eo,eW as zl,q_ as ql,lW as Ul,fX as Wl,fY as Hl,fZ as Gl,f_ as Vl,f$ as Kl,g0 as Ql,g1 as Xl,g2 as Yl,q$ as hs,r0 as Jl,r1 as Zl,r2 as ec,mm as tc,jp as nc,jq as sc,jr as rc,js as bn,mG as oc,jt as Gs,k6 as ac,bQ as ic,k8 as lc,bS as cc,r3 as Vs,cv as uc,fM as Do,cA as To,cp as dc,cz as fc,ij as mc,cI as Ao,r4 as Fo,cl as Ro,cF as pc,r5 as gs,cG as hc,r6 as gc,aw as xc,cr as bc,r7 as yc,m3 as ae,r8 as kc,r9 as vc,cE as Cc,_ as Sc,m_ as Ks,ra as jc,iM as Qe,rb as yn,dZ as yt,rc as Qs,rd as Xs,re as Ys,ck as kn,rf as rt,eM as kt,rg as _c,cL as Mo,rh as Oo,ri as wc,rj as Nc,rk as Ec,cM as Io,rl as Dc,rm as Tc,rn as $o,ro as tt,rp as Po,rq as Ac,bP as Fc,rr as Rc,rs as Mc,ff as Lo,rt as Js,ru as Oc,bX as Un,j9 as Bo,cP as Ic,rv as $c,gX as Pc,gW as Lc,jb as Bc,cc as zc,cO as qc,c9 as Uc,ak as ln,rw as Wc,rx as Hc,gR as zo,gO as xs,kR as Gc,ry as Vc,rz as Kc,rA as Qc,rB as qo,ob as Xc,ju as Yc,rC as ht,rD as Jc,cK as Zc,ge as eu,rE as tu,fb as nu,rF as su,eb as ru,jG as ou,Y as au}from"./index-DSYz85aL.js";import{P as iu}from"./PromptSuggestionChips-DT-JdGeO.js";import{u as lu,a as cu,L as uu,f as du,b as fu,c as mu,B as pu,d as hu}from"./primer-trigger-NAz78FSN.js";import{C as gu}from"./card-Dsy8PPN6.js";import{a as xu,u as bu,i as yu}from"./use-notification-prefs-DXww4pVV.js";import{e as ku,h as vu,o as Uo,f as Cu,P as Su,g as ju,d as _u,p as wu,j as Nu,b as Eu,G as Du,W as Wo,y as Tu,x as Au,z as Fu,u as Ru,t as Mu,w as Ou,n as Iu,k as $u,s as Pu,M as Lu,i as Bu,S as zu,U as qu,A as Uu,v as Wu,R as Hu,q as Gu}from"./use-status-budget-Q1ltHI80.js";import{B as Vu}from"./banner-BhzLIs7u.js";import{t as It,f as Yt,d as Ku,N as Ho,l as Qu,u as Xu,C as jt,c as nt,h as Yu,F as Ju}from"./index-DYF1ER90.js";import{u as Zu,b as ed}from"./WidgetErrorCard-oq5MKUX_.js";import{u as td,D as nd,U as sd}from"./UnreadDivider-CGKnJcx7.js";import{a as rd,c as od}from"./composer-insert-BpyATrmR.js";import{u as ad}from"./use-composer-prefs-FpUdi_wE.js";import{A as Wn,M as id}from"./McpAppFrame-DjJ4EM39.js";import{P as ld,W as cd,a as ud,C as dd,b as fd}from"./find-latest-widget-fence-DJDfJAaN.js";import{F as Go}from"./file-CbZILJJL.js";import{F as md,i as pd}from"./use-session-canvas-BaGypLR6.js";import{F as hd}from"./file-text-DGtefNvG.js";import{a as gd,b as xd}from"./markdown-content-D7t62wwm.js";import{a as Vo,c as bd,R as yd,K as kd,e as vd,g as Cd}from"./RuntimeConnectFlow-BsZsQZS9.js";import{S as Sd}from"./shield-x-bloGLifl.js";import{u as jd,M as _d}from"./McpSigninBody-V6RSsDqe.js";import{a as Ko,u as wd,I as Nd}from"./image-off-DziiNcIl.js";import{f as Ed}from"./format-duration-BCr6uzby.js";import{l as Dd}from"./use-connector-management-CinfkPZI.js";import{A as Td}from"./AgentRequestCard-DVoE2cnk.js";function Ad(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 g=Zs(e.get()),m=Zs(a);if(g===m){u();return}const h=o?o.getGeneratorVelocity():e.getVelocity();u(),o=new Si({keyframes:[g,m],velocity:h,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:i})},f=()=>{var g;d(),e.animation=o??void 0,(g=e.events.animationStart)==null||g.notify(),o==null||o.then(()=>{var m;e.animation=void 0,(m=e.events.animationComplete)==null||m.notify()})};if(e.attach((g,m)=>{a=g,i=h=>m(vn(h,l)),Ci.postRender(f)},u),ao(t)){let g=n.skipInitialAnimation===!0;const m=t.on("change",x=>{g?(g=!1,e.jump(vn(x,l),!1)):e.set(vn(x,l))}),h=e.on("destroy",m);return()=>{m(),h()}}return u}function vn(e,t){return t?e+t:e}function Zs(e){return typeof e=="number"?e:parseFloat(e)}function Fd(e,t={}){const{isStatic:n}=c.useContext(ji),s=()=>ao(e)?e.get():e;if(n)return Ko(s);const o=wd(s());return c.useInsertionEffect(()=>Ad(o,e,t),[o,JSON.stringify(t)]),o}function Rd(e,t={}){return Fd(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 Qo(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 Od(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(g=>document.addEventListener(g,u,{passive:!0}));const f=()=>{document.hidden?i():u()};return document.addEventListener("visibilitychange",f),()=>{a.current&&clearTimeout(a.current),d.forEach(g=>document.removeEventListener(g,u)),document.removeEventListener("visibilitychange",f)}},[t,i,u]),{isIdle:o.current}}function Id({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 g(m){const h=m.target,x=(h.tagName==="TEXTAREA"||h.tagName==="INPUT")&&!h.disabled;if(!f.current&&!(m.metaKey||m.ctrlKey||m.altKey)){if(e.type==="approval"){if(m.key==="Enter"&&x&&h.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",g),()=>document.removeEventListener("keydown",g)},[e,t,n,s,o,a,i,l,u,d])}function Xo(){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 Yo={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"}]]};Yo.node;const $d=dt(Yo);/**
|
|
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 Jo={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"}]]};Jo.node;const Pd=dt(Jo);/**
|
|
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 Zo={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"}]]};Zo.node;const Ld=dt(Zo);/**
|
|
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 ea={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"}]]};ea.node;const Bd=dt(ea);/**
|
|
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 ta={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"}]]};ta.node;const zd=dt(ta);/**
|
|
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 na={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"}]]};na.node;const qd=dt(na);function Ud({color:e,isTextStreaming:t,fadeEdges:n=!0,edge:s="bottom"}){const o=Oe()===!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(H.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(H.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(me,{children:t&&!o&&r.jsx(H.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 Cn={"word-boundary":3,substring:2,subsequence:1},Wd=new Set(["/",":","-","_","."," "]);function Hd(e,t){if(t===0)return!0;const n=e[t-1];if(Wd.has(n))return!0;const s=e[t];return n===n.toLowerCase()&&s!==s.toLowerCase()&&s===s.toUpperCase()}function $t(e,t){return Array.from({length:t},(n,s)=>e+s)}function Pt(e,t,n){const s=1/(1+t),o=n/e.length;return(s*.6+o*.4)*.999}function Gd(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 Vd(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 Gt(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+Pt(t,0,n.length),indices:$t(0,n.length)};if(s.startsWith(n))return{match:!0,tier:"prefix",score:4+Pt(t,0,n.length),indices:$t(0,n.length)};for(let i=1;i<=s.length-n.length;i++)if(Hd(t,i)&&s.startsWith(n,i))return{match:!0,tier:"word-boundary",score:Cn["word-boundary"]+Pt(t,i,n.length),indices:$t(i,n.length)};const o=s.indexOf(n);if(o>=0)return{match:!0,tier:"substring",score:Cn.substring+Pt(t,o,n.length),indices:$t(o,n.length)};const a=Gd(n,s);return a?{match:!0,tier:"subsequence",score:Cn.subsequence+Vd(t,a),indices:a.indices}:{match:!1,tier:null,score:0,indices:[]}}class Kd{constructor(t){et(this,"config");et(this,"recentCompletions",[]);et(this,"queue",[]);et(this,"isIdle",!1);et(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 Qd={background:"radial-gradient(circle, rgba(255,215,0,0.15) 0%, transparent 70%)"},Xd={mode:"blur-in",duration:150,easing:"ease-out",sep:"word"},Yd={none:void 0,fade:"fadeIn","blur-in":"blurIn","slide-up":"slideUp"};function Jd(e){const t=Yd[e.mode];return t?{animation:t,duration:e.duration??150,easing:e.easing??"ease-out",sep:e.sep??"word"}:!1}function Zd(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 ef({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 tf=ef({onlyFirst:!0});function nf(e){if(tf.test(e))return"ansi";const t=e.trimStart();if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}return"plain"}function cn(e){var n;const{sessions:t}=rs();if(e)return(n=t.find(s=>s.id===e))==null?void 0:n.runtime}const sf=typeof window<"u"&&window.location.pathname===wi;let Sn=null,er=!sf;function rf(e){return er?Sn===e?!0:(Sn=null,!1):(er=!0,Sn=e,!0)}function of(e){var s;const t=ve(),n=((s=io(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),rf(e)||lt.getState().recordOpened("session",e),t.markSessionOpened(e).catch(i=>{_i(t,i)}))};if(a(),!o)return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[e,n,t])}function sa(){const e=lo(),t=io(e.session);return{cwd:(t==null?void 0:t.cwd)??e.dir??null}}function ra({agentId:e,agentName:t,onResumed:n}){const s=Ni(),{data:o,dataUpdatedAt:a,refetch:i}=Ei(),[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(Di,{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(fe,{size:"sm",variant:"outline",disabled:s.isPending,onClick:()=>s.mutate(e,{onSuccess:()=>{Fe(`${u} resumed`),n==null||n()}}),children:"Resume"})]})}function af(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 lf({sessionId:e,interactionId:t,serverName:n,message:s,mode:o="form",url:a,requestedSchema:i,status:l,action:u}){const d=ve(),[f,g]=c.useState(!1),[m,h]=c.useState(null),[x,C]=c.useState(null),[b,y]=c.useState({}),[v,k]=c.useState(!1),p=c.useMemo(()=>af(i),[i]),j=l!=="pending",_=c.useCallback(async(D,S)=>{if(!(f||j)){g(!0),h(null),C(null);try{await d.submitElicitation(e,t,D,S)}catch(E){if(E.code!=="INTERACTION_ALREADY_RESOLVED"){h("Couldn’t send your answer. Try again."),C(E instanceof Error?E.message:null),g(!1);return}}g(!1)}},[d,e,t,f,j]),N=c.useCallback(()=>{const D={};for(const S of p)D[S.key]=b[S.key]??S.defaultValue??"";_("accept",D)},[p,b,_]),R=c.useCallback(()=>{_("accept")},[_]),w=c.useCallback(()=>{_("decline")},[_]),A=c.useCallback((D,S)=>{y(E=>({...E,[D]:S}))},[]),F=c.useCallback(()=>{if(a){if(!Ti(a)){h(`Couldn’t open ${a}. Nothing has been authorized.`),C(null);return}h(null),C(null),k(!0)}},[a]);return j?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(H.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className:U("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(fe,{size:"sm",variant:"outline",onClick:F,disabled:f,children:"Open authorization page"}),v&&r.jsx(fe,{size:"sm",onClick:R,disabled:f,children:f?"Sending…":"Done"}),r.jsx(fe,{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(D=>r.jsxs("div",{children:[r.jsx("label",{htmlFor:`elicitation-${t}-${D.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:D.label}),D.options?r.jsxs("select",{id:`elicitation-${t}-${D.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:b[D.key]??String(D.defaultValue??""),onChange:S=>A(D.key,S.target.value),disabled:f,children:[r.jsx("option",{value:"",children:"Select…"}),D.options.map(S=>r.jsx("option",{value:S,children:S},S))]}):r.jsx("input",{id:`elicitation-${t}-${D.key}`,type:D.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(D.defaultValue??""),value:b[D.key]??"",onChange:S=>A(D.key,S.target.value),disabled:f})]},D.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(fe,{size:"sm",onClick:N,disabled:f,children:f?"Sending…":"Accept"}),r.jsx(fe,{size:"sm",variant:"ghost",onClick:w,disabled:f,children:"Decline"})]})]})]})}const cf=8,uf={duration:.3,ease:[.16,1,.3,1]},df={duration:0};function ff(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 mf(e){return new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function pf(e){return`${e} action${e===1?"":"s"}`}function hf({outcome:e,items:t,resolvedAt:n,startedAt:s,reasonGiven:o,className:a}){var C;const i=Oe(),[l,u]=c.useState(!1),d=t.length,f=d>1,g=f?pf(d):(C=t[0])==null?void 0:C.label,m=n!==void 0&&s!==void 0?Math.max(0,n-s):null,h=e==="allowed"?tn:e==="denied"?ct:bt,x=e==="allowed"?"text-status-success":e==="denied"?"text-status-error":"text-muted-foreground";return r.jsxs(H.div,{"data-testid":"approval-receipt","data-outcome":e,"data-count":d,initial:i?!1:{opacity:0,y:cf},animate:{opacity:1,y:0},transition:i?df:uf,className:U("text-muted-foreground my-1 text-xs",a),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(h,{className:U("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?`${g} `:"","denied",m!==null&&` after ${ff(m)}`]}):r.jsxs(r.Fragment,{children:["You ",e==="allowed"?"allowed":"denied"," ",f?g:r.jsx("span",{className:"font-mono",children:g}),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:mf(n)}),f&&r.jsx("button",{type:"button",onClick:()=>u(b=>!b),"aria-expanded":l,className:U("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 gf({outcome:e,reasonGiven:t,members:n,lead:s,children:o}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsx(hf,{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(co,{"data-testid":"approval-receipt-result",content:s.result,className:"text-muted-foreground mt-0.5 ml-6"}),e==="allowed"&&o]})}function bs(e){return e.endsWith("connectors.request_connection")||e.endsWith("connectors_request_connection")}function oa(e){if(e)try{return JSON.parse(e)}catch{return}}function Vt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xf(e){const t=oa(e);if(!Vt(t))return;const{serviceSlug:n,reason:s}=t;if(!(typeof n!="string"||typeof s!="string"))return{serviceSlug:n,reason:s}}function aa(e){const t=oa(e);if(Vt(t)&&typeof t.requestId=="string")return t.requestId;if(Vt(t)&&Array.isArray(t.content)){const n=t.content.map(s=>Vt(s)&&typeof s.text=="string"?s.text:"").join("");return aa(n)}}function bf(e,t){const n=aa(t.result);if(n)return e.find(o=>o.requestId===n);const s=xf(t.input);if(s)return e.filter(o=>o.serviceSlug===s.serviceSlug).sort((o,a)=>a.createdAt.localeCompare(o.createdAt))[0]}function yf({sessionId:e,input:t,result:n,fallback:s}){const o=Dd(e),a=o.data?bf(o.data,{input:t,result:n}):void 0;return a?r.jsx("div",{className:"my-3","data-testid":"chat-agent-request",children:r.jsx(Td,{request:a})}):r.jsx(r.Fragment,{children:s})}const jn={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}},kf={match:!1,bucket:Number.POSITIVE_INFINITY,score:0};function tr(e){return e.startsWith("/")?e.slice(1):e}function nr(e,t){return e.bucket<t.bucket||e.bucket===t.bucket&&e.score>t.score}function vf(e,t){let n=kf;const s=Gt(e,tr(t.fullCommand));s.match&&s.tier&&(n={match:!0,bucket:jn.name[s.tier],score:s.score});for(const o of t.aliases??[]){const a=Gt(e,tr(o));if(!a.match||!a.tier)continue;const i={bucket:jn.alias[a.tier],score:a.score};nr(i,n)&&(n={match:!0,...i,matchedAlias:o})}if(t.description){const o=Gt(e,t.description);if(o.match&&o.tier){const a={bucket:jn.description[o.tier],score:o.score};nr(a,n)&&(n={match:!0,...a})}}return n}const ia="dorkos:mcp-app-consent:";function la(e){return`${ia}${e}`}function Cf(e){try{return localStorage.getItem(la(e))==="granted"}catch{return!1}}function Sf(e){try{localStorage.setItem(la(e),"granted")}catch{}jf()}const Hn=new Set;function jf(){for(const e of Hn)e()}function _f(e){Hn.add(e);const t=n=>{var s;(s=n.key)!=null&&s.startsWith(ia)&&e()};return window.addEventListener("storage",t),()=>{Hn.delete(e),window.removeEventListener("storage",t)}}function wf(e){const t=c.useSyncExternalStore(_f,()=>Cf(e),()=>!1),n=c.useCallback(()=>Sf(e),[e]);return{consented:t,grant:n}}const Nf="h-80";function Ef({sessionId:e,serverName:t,uri:n,title:s}){const{consented:o,grant:a}=wf(t),i=le(d=>d.openPip),l=()=>{const d=le.getState(),f={type:"mcp_app",serverName:t,uri:n,title:s};d.openCanvasDocument(f),qn(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(Wn,{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(ld,{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(Ai,{className:"size-3.5"})})]})]}),r.jsx(id,{sessionId:e,serverName:t,uri:n,title:s,onRequestFullscreen:l,onRequestPip:u,className:Nf})]}):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(Wn,{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 Df(e){return e.replace(/[-_]+/g," ").trim()}function Tf({action:e}){const t=Zu(),n=Df(e.actionId),s=`Widget interaction${e.title?`, ${e.title}`:""}: ${n}`;return r.jsxs(H.span,{"data-testid":"ui-action-chip",title:e.payload?JSON.stringify(e.payload):void 0,className:U("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?ed: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(qd,{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 Af=/<ui_action>([\s\S]*?)<\/ui_action>/;function sr(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:null}catch{return null}}function Ff(e){const t=e.match(Af);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 h=d[1].trim();s=h&&h!=="(untitled)"?h:null;continue}const f=u.match(/^\s*Action:\s*(.*)$/);if(f){o=f[1].trim();continue}const g=u.match(/^\s*Widget ID:\s*(.*)$/);if(g){a=g[1].trim()||null;continue}const m=u.match(/^\s*Payload:\s*(.*)$/);if(m){const h=m[1].trim();if(h&&h!=="(none)")i=sr(h);else if(!h){let x="";for(let C=l+1;C<n.length;C++){x+=(x?`
|
|
34
|
-
`:"")+n[C];const b=sr(x.trim());if(b){i=b;break}}}break}}return o?{title:s,actionId:o,widgetId:a,payload:i}:null}function Rf({onAllow:e,onNotNow:t}){return r.jsxs(gu,{"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(Fi,{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(fe,{variant:"ghost",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:t,children:"Not now"}),r.jsx(fe,{variant:"outline",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:e,children:"Turn on notifications"})]})]})}function Mf(e){const t=lu(),{permission:n,request:s}=xu(),{prefs:o,setPrefs:a}=bu(),{data:i}=os(),l=i!==void 0,[u,d]=c.useState(!1),f=Ri()||n==="unsupported";c.useEffect(()=>{if(f||!e)return;const x=setTimeout(cu,uu);return()=>clearTimeout(x)},[f,e]);const g=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:g,notNow:m}}const Of="dorkos:chat:last-seen:";function If(){try{const e=[];for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n!=null&&n.startsWith(Of)&&e.push(n)}for(const t of e)window.localStorage.removeItem(t)}catch{}}function $f(e){let t=0;for(const n of e)n._streaming!==!0&&t++;return t}function Pf(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 Lf(e,t,n=0){const s=ve(),[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),g=c.useRef(null),m=n+$f(t);c.useEffect(()=>{If();let v=!1;return f.current=e,i.current=0,l.current=null,u.current=!1,d.current=!1,(async()=>{let k=null;try{k=await s.getReadCursor("session",e)}catch{}v||(k&&(i.current=k.lastReadSeq,g.current=k.userId),a({sessionId:e,lastReadSeq:(k==null?void 0:k.lastReadSeq)??null,hydrated:!0}))})(),()=>{v=!0}},[s,e]);const h=c.useCallback(async()=>{if(!u.current){u.current=!0;try{for(;;){const v=l.current;if(v===null)break;if(l.current=null,v.sessionId!==f.current)continue;if(d.current)break;const k=i.current;i.current=Math.max(k,v.seq);try{const p=await s.setReadCursor("session",v.sessionId,v.seq);g.current=p.userId??g.current}catch{i.current=k,v.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},h())},[o.hydrated,e,m,h]);Mi("read_cursor",v=>{if(!Pf(v)||v.threadKind!=="session"||v.threadId!==e)return;const k=g.current;k!==null&&v.userId!==k||v.lastReadSeq<=i.current||(i.current=v.lastReadSeq,a({sessionId:e,lastReadSeq:v.lastReadSeq,hydrated:!0}))});const C=c.useMemo(()=>t.filter(v=>v._streaming!==!0).map((v,k)=>({id:v.id,seq:n+k+1})),[t,n]),b=o.lastReadSeq,y=Oi(C,b===null?null:Math.min(b,m));return{lastSeenMessageId:y.lastSeenId,unreadFromStart:y.fromStart,markSeen:x,isHydrated:o.hydrated}}function Ye(e){return e.notAllowed!==!0&&e.usage.state!=="limited"}function Bf(e,t){if(e.id===ut||!e.eligible)return e.reason;const n=Ii(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=$i(n.resetsAt,t);return o?`${s}% left · resets ${o}`:`${s}% left`}function un(e,t){return e.runtime!==void 0&&e.runtime!==t}function zf(e,t){const n=[],s=[];for(const o of e)(un(o,t)?s:n).push(o);return{same:n,other:s}}function Jt(e,t){return`${e.runtime??t}:${e.id}`}function qf(e,t,n){if(un(e,t)){const s=e.runtime;return!e.label&&e.id===vt?`${Qt({runtime:s,accountLabel:null,identityGate:!1})} (this computer's sign-in)`:Qt({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 Uf(e,t){const n=e.accounts.find(o=>o.id===e.recommendedId);if(n&&Ye(n))return Jt(n,t);const s=e.accounts.find(Ye);return s?Jt(s,t):null}function Wf(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 Hf(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 Gf(e){return e.carryOver===!1}function Vf(e,t,n){return e?!0:(t==null?void 0:t.accounts.some(s=>un(s,n)))??!1}function Kf(e){return{id:ut,runtime:e,label:zs,color:Bs,eligible:!0,reason:"paid from your DorkOS account",usage:{runtime:"claude-code",accountId:ut,path:"",label:zs,color:Bs,subscriptionType:null,plan:null,credits:null,spend:null,windows:[],state:"unknown",limit:null,updatedAt:null}}}function ca(e,t){const n=ve();return Je({queryKey:as.continueOptions(e),queryFn:()=>n.getContinueOptions(e),enabled:t,staleTime:0,retry:!1})}function Qf(e){const t=ve();return Ct({mutationFn:n=>t.continueSession(e,n),retry:!1})}function Xf(e){const t=ve();return Ct({mutationFn:()=>t.cancelAutoContinue(e),retry:!1})}const rr="claude-code",Yf="No other account can take this work right now.";function Jf(e){return e instanceof Error&&e.message?e.message:"Couldn’t continue on that account. Try again."}function Zf({row:e,value:t,name:n,status:s,selected:o}){const a=Ye(e);return r.jsxs("label",{"data-slot":"continue-account-row","data-eligible":e.eligible,className:U("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(Gi,{value:t,disabled:!a,className:"sr-only"}),r.jsx("span",{"aria-hidden":!0,className:"inline-flex",children:r.jsx(ls,{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:U(Vi.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 ua({open:e,onOpenChange:t,sessionId:n,account:s,cancelAutoFirst:o=!1,now:a,onCloseAutoFocus:i}){var ne;const l=wt(),u=a??new Date(l),d=c.useId(),f=s.runtime??rr,{accounts:g,nameFor:m}=is(),[,h]=Nt(),x=Xf(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 v=e&&(!o||x.isSuccess),k=ca(n,v),p=Qf(n),[j,_]=c.useState(null),N=()=>{p.isPending||(_(null),p.reset(),t(!1))},R=$=>$?t(!0):N(),w=v?k.data:void 0,A=w==null?void 0:w.ranking,F=w&&!Gf(w.plan)?[...w.ranking.accounts,...w.credits?[Kf(f)]:[]]:[],D=F.some(Ye),S=j??(A?Uf(A,f):null),E=F.find($=>Jt($,f)===S)??null,T=E!==null&&Ye(E),M=$=>qf($,f,m),{same:I,other:L}=zf(F,f),z=Hf((w==null?void 0:w.advised)===!0,s.trackerItems.some($=>$.via==="this-chat")),Q=s.accountId??((ne=s.limit)==null?void 0:ne.accountId)??null,X=(w==null?void 0:w.advised)===!0&&f===rr&&Q!==null?Wf(g.filter($=>$.id&&$.id!==Q&&!I.some(Z=>Z.id===$.id)).map($=>m($.path))):null,B=()=>{!E||!Ye(E)||p.mutate(un(E,f)?{account:E.id,runtime:E.runtime}:{account:E.id},{onSuccess:$=>{N(),$.sessionId&&h($.sessionId)}})},P=$=>{const Z=Jt($,f);return r.jsx(Zf,{row:$,value:Z,name:M($),status:Bf($,u),selected:Z===S},Z)},Y=x.isError?x.error:k.isError&&v?k.error:p.isError?p.error:null,O=e&&!Y&&(!v||k.isPending),W=!O&&w!==void 0;return r.jsx(Pi,{open:e,onOpenChange:R,children:r.jsxs(Li,{className:"max-h-[85vh] !min-h-0",desktopProps:{className:"sm:max-w-[380px]"},onCloseAutoFocus:i,"aria-labelledby":d,children:[r.jsxs(Bi,{className:"shrink-0 text-left",children:[r.jsx(zi,{id:d,className:"text-left",children:"Continue on another account"}),r.jsx(qi,{className:"text-left",children:z.subtitle})]}),r.jsxs(Ui,{className:"flex flex-col gap-3",children:[O&&r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx(qs,{className:"h-11 rounded-lg"}),r.jsx(qs,{className:"h-11 rounded-lg"})]}),W&&(D?r.jsxs(Wi,{"aria-labelledby":d,value:S??"",onValueChange:_,className:"min-w-0 grid-cols-1 gap-1.5",children:[I.map(P),L.length>0&&r.jsx("div",{className:"text-muted-foreground mt-2 text-xs font-semibold tracking-wide uppercase",children:"Other runtimes"}),L.map(P)]}):r.jsx("p",{className:"text-muted-foreground text-sm",children:Yf})),W&&X&&r.jsx("p",{className:"text-muted-foreground text-xs",children:X}),W&&r.jsxs("ul",{className:"text-muted-foreground list-disc pl-4 text-xs",children:[r.jsx("li",{children:z.carries}),r.jsx("li",{children:z.doesnt})]}),Y!==null&&r.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Jf(Y)})]}),r.jsxs(Hi,{className:"shrink-0",children:[r.jsx(fe,{variant:"outline",onClick:N,disabled:p.isPending,children:"Cancel"}),r.jsxs(fe,{onClick:B,disabled:!W||!D||!T||p.isPending,"aria-busy":p.isPending||void 0,children:[p.isPending&&r.jsx(He,{}),E&&W&&D?`Continue on ${M(E)}`:"Continue"]})]})]})})}const em=1440*60*1e3,tm="Paused until you continue or the account resets",nm="Paused until the task moves or the account resets",sm=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited"]);function rm(e){return sm.has(e)?"critical":"neutral"}function da(e){return e.carryOver===!1}function at(e,t){return e!==null&&Date.parse(e)<=t.getTime()}function ys(e){return`${e} should have reset by now.`}function om(e,t,n,s){if(at(n,s))return ys(e);const o=Ki(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 fa(e){return e.plan.mode==="waiting"&&e.plan.resumeAt?e.plan.resumeAt:e.resetsAt}function or(e,t,n){if(t===null)return`Waiting for ${e}`;if(at(t,n))return ys(e);const s=Date.parse(t)-n.getTime();return s<em?`Waiting for ${e} · back in ${Qi(s)}`:`Waiting for ${e} · back ${cs(t,n)}`}function am(e,t){return Math.max(0,Math.ceil((Date.parse(e)-t.getTime())/1e3))}const im=new Set(["continue-on","move-now","keep-going","resume","open-moved"]);function lm(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 cm=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited","waiting-reset"]),_n={canSubmit:!0,placeholder:null};function um(e,t,n){if(!e)return _n;const s=uo(e);if(s==="moved")return{canSubmit:t,placeholder:null};if(!cm.has(s))return _n;const o=i=>i!==null&&!at(i,n);return o(fa(e))||e.plan.mode==="auto"&&o(e.plan.fireAt)?{canSubmit:!1,placeholder:s==="handing-off"?nm:tm}:_n}const dm=300*1e3;function ma(e,t){const n=Date.parse(e)-Date.parse(t);return Number.isFinite(n)&&n>=0&&n<=dm}function fm(e,t){let n=null;for(const s of e)ma(s.since,t)&&(n===null||Date.parse(s.since)<Date.parse(n.since))&&(n=s);return n}function Gn(e,t){var n;return e?((n=t.find(s=>s.value===e))==null?void 0:n.displayName)??e:null}function mm(e,t){return{from:Gn(e.modelFrom,t)??(e.scope==="model"?fo(e.window,t):null),to:Gn(e.modelTo,t)}}function pa(){const{accounts:e,nameFor:t,colorFor:n}=is(),s=Xi("claude-code",{accountId:vt,path:null});return o=>{const a=Yi({accountId:o,path:null,accounts:e,usage:o===vt?s:null,nameFor:t,colorFor:n});return{name:a.name??o,color:a.color}}}const ar=nn(e=>({episodes:new Set,choose:t=>e(n=>n.episodes.has(t)?n:{episodes:new Set([...n.episodes,t])})}));function pm(e,t){return`${e}\0${t}`}function ha(e,t){const n=t===null?null:pm(e,t),s=ar(a=>n!==null&&a.episodes.has(n)),o=ar(a=>a.choose);return{continuedHere:s,continueHere:()=>{n!==null&&o(n)}}}const ir="claude-code",hm=new Set(["limited","handing-off","model-limited"]),gm=new Set(["limited","model-limited","all-accounts-out"]);function xm(e){return(e==null?void 0:e.runsOn)==="own-sign-in"&&e.chosenBy==="user"}function bm(e){return e instanceof Error&&e.message?e.message:"Couldn’t do that. Try again."}function ym(e,t){var Q,X,B;const n=ve(),s=us(),[,o]=Nt(),a=Et(e,{fetchUsage:!1}),i=t??a,l=i.limit,u=l?uo(l):null,d=i.runtime??ir,f=i.visible,g=pa(),m=d===ir&&(l!=null&&l.accountId)?g(l.accountId).name:i.name,h=Qt({runtime:d,accountLabel:m,identityGate:f}),x=sn({sessionId:e||void 0,runtime:d}).data??[],C=l?da(l.plan):!0,b=u!==null&&hm.has(u)&&!C,{isLoaded:y}=is(),{data:v}=ds(),k=y&&v!==void 0,p=u==="model-limited",j=ca(e,b&&k&&(p?f:!f)),_=b&&(p?f&&(((Q=j.data)==null?void 0:Q.ranking.accounts.some(Ye))??!1):Vf(f,(X=j.data)==null?void 0:X.ranking,d)),{continuedHere:N,continueHere:R}=ha(e,(l==null?void 0:l.since)??null),{data:w}=Ji(),A=u!==null&&gm.has(u)&&!C&&(l==null?void 0:l.accountId)!==ut&&Zi(w,d)&&!xm((B=w==null?void 0:w.defaults)==null?void 0:B[d]),F=(l==null?void 0:l.since)??null,D=`${F}:${u}`,[S,E]=c.useState(null),T=P=>E(P===null?null:{key:D,message:P}),M=P=>T(bm(P)),I=Ct({mutationFn:P=>n.waitForReset(e,P),retry:!1,onError:M}),L=Ct({mutationFn:P=>n.continueSession(e,P),retry:!1,onError:M,onSuccess:P=>{P.sessionId&&P.sessionId!==e&&o(P.sessionId)}}),z=c.useRef(F);return c.useEffect(()=>{z.current!==null&&F===null&&s.invalidateQueries({queryKey:as.limitHistory(e)}),z.current=F},[F,e,s]),{account:i,limit:l,state:u,runtime:d,subject:h,identityGate:f,canPick:_,creditsOffered:A,nameOf:g,models:x,continuedHere:N,continueHere:R,wait:P=>{T(null),I.mutate(P===void 0?{}:{autoResume:P})},continueOn:P=>{T(null),L.mutate(P)},openSession:P=>o(P),pending:I.isPending||L.isPending,failure:(S==null?void 0:S.key)===D?S.message:null}}function wn({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 Nn({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(ls,{color:e.color,name:e.name,tooltip:!1})}),e.name]})}function km(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 vm({sessionId:e,onSend:t,account:n,now:s}){const o=ym(e,n),a=mo(),{limit:i,state:l,subject:u,identityGate:d}=o,f=wt(l==="handing-off"?1e3:6e4),g=s??new Date(f),m=i?i.since:null,[h,x]=c.useState(null),C=o.canPick&&m!==null&&h===m,b=D=>x(D?m:null),y=c.useId();if(!i||!l)return null;const v=o.creditsOffered&&a!==null,k=i.plan,p=Gn(i.modelFallback,o.models),j=lm(l,{canPick:o.canPick,hasFallback:p!==null,continuedHere:o.continuedHere}),_=`${l}:${i.since}:${u}`;let N,R=null,w=!1;switch(l){case"all-accounts-out":{N="All accounts are out.";const D=i.allOut;if(D!=null&&D.resetsAt){const S=o.nameOf(D.accountId);R=at(D.resetsAt,g)?ys(S.name):r.jsxs(r.Fragment,{children:["Soonest back: ",r.jsx(Nn,{account:S,showDot:d}),","," ",cs(D.resetsAt,g)]})}break}case"model-limited":N=`${fo(i.window,o.models)} is out on ${u} for this week.`;break;case"waiting-reset":{const D=fa(i);N=r.jsx(wn,{visible:or(u,D,g),spoken:or(u,D,g),spokenKey:`${_}:${at(D,g)}`});break}case"reset-ready":N=k.mode==="waiting"&&k.unconfirmed?`${u} should have reset by now.`:`${u} has reset.`;break;case"moved":{if(k.mode!=="continued")return null;const D=o.nameOf(k.accountId);N=r.jsxs(r.Fragment,{children:["This task continued on ",r.jsx(Nn,{account:D,showDot:d}),"."]});break}default:{const D=om(u,i.window,i.resetsAt,g);if(N=r.jsx(wn,{visible:D,spoken:D,spokenKey:`${_}:${at(i.resetsAt,g)}`}),l==="handing-off"&&k.mode==="auto"){const S=o.nameOf(k.target),E=am(k.fireAt,g);w=E===0,R=r.jsx(wn,{visible:r.jsxs(r.Fragment,{children:["Moving this task to ",r.jsx(Nn,{account:S,showDot:d}),w?"…":` in ${E}s…`]}),spoken:w?`Moving this task to ${S.name}.`:`Moving this task to ${S.name} in ${E} seconds.`,spokenKey:`${_}:${k.fireAt}:${S.name}:${w}`})}}}const A=D=>{switch(D){case"continue-on":case"choose":b(!0);return;case"move-now":k.mode==="auto"&&o.continueOn({account:k.target});return;case"keep-going":i.modelFallback&&o.continueOn({model:i.modelFallback});return;case"resume":t(el);return;case"open-moved":k.mode==="continued"&&o.openSession(k.sessionId);return;case"continue-here":o.continueHere();return;case"wait":o.wait();return}},F=l==="waiting-reset"&&k.mode==="waiting"&&!da(k);return r.jsxs(r.Fragment,{children:[r.jsxs(Vu,{variant:rm(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:N}),R&&r.jsxs(r.Fragment,{children:[" ",R]})]}),F&&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:k.autoResume,disabled:o.pending,onChange:D=>o.wait(D.target.checked)}),r.jsx("label",{htmlFor:y,children:"Continue automatically when it resets"})]}),v&&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:ut})})}),j.length>0&&r.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:j.map(D=>r.jsx(fe,{size:"sm",variant:im.has(D)&&!v?"default":D==="continue-here"?"ghost":"outline",className:"h-auto min-h-11 max-w-full py-1 whitespace-normal md:min-h-8",disabled:o.pending||D==="move-now"&&w,onClick:()=>A(D),children:km(D,p)},D))}),o.failure&&r.jsx("p",{role:"alert",className:"text-destructive mt-1.5",children:o.failure})]}),o.canPick&&r.jsx(ua,{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 Cm(e){const t=ve();return Je({queryKey:as.limitHistory(e),queryFn:()=>t.getLimitHistory(e),enabled:e!=="",retry:!1})}const Sm={moved:nl,"resumed-reset":bt,"resumed-model":bt,"resumed-early":bt};function jm({entry:e,now:t}){const n=wt(),s=t??new Date(n),o=pa(),a=tl(e.runtime),i=sn({runtime:e.runtime}).data??[],[,l]=Nt(),u=e.runtime==="claude-code"&&e.accountId?o(e.accountId).name:null,d=Qt({runtime:e.runtime,accountLabel:u,identityGate:a}),f=`at ${cs(e.resolvedAt,s)}`,g=Sm[e.resolution];let m;switch(e.resolution){case"moved":{const h=e.toAccountId?o(e.toAccountId):null,x=h?r.jsxs(r.Fragment,{children:[a&&h.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-0.5 inline-flex align-middle",children:r.jsx(ls,{color:h.color,name:h.name,tooltip:!1})}),h.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:h,to:x}=mm(e,i);m=x?`${h??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(g,{"aria-hidden":!0,className:"size-3 shrink-0"}),r.jsx("span",{className:"min-w-0",children:m})]})}function _m({sessionId:e,at:t,fallback:n,now:s}){const{limit:o}=Et(e,{fetchUsage:!1}),a=Cm(e),[i,l]=c.useState(null),u=o!==null&&(t===""||ma(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?fm(a.data.entries,t):null;return d?r.jsx(jm,{entry:d,now:s}):o===null&&i!==null&&a.dataUpdatedAt===i.data&&a.errorUpdatedAt===i.error?null:r.jsx(r.Fragment,{children:n})}function wm(e){const{limit:t}=Et(e,{fetchUsage:!1}),{continuedHere:n}=ha(e,(t==null?void 0:t.since)??null),s=wt();return um(t,n,new Date(s))}function Nm(e){return Et(e,{fetchUsage:!1}).limit!==null}function Em({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 Dm({filteredFiles:e,selectedIndex:t,onSelect:n}){return c.useEffect(()=>{const s=document.getElementById(`file-item-${t}`);s&&s.scrollIntoView({block:"nearest"})},[t]),r.jsx(H.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?sl:Go;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(Em,{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 Tm(e){const t=ve();return Je({queryKey:["files",{cwd:e??null}],queryFn:()=>t.listFiles(e),enabled:!!e,staleTime:Xe.FILES_STALE_TIME_MS,gcTime:Xe.FILES_GC_TIME_MS})}const Am="You",Fm="human",Rm="system",Mm="System",Om="agent",Im="Agent",$m="chat-sender:",lr="room-author:",Pm="Room member",Lm="runtime:";function Bm(e){return e.messageType==="local_command_output"||e.messageType==="compaction"}function zm(e,t){var a,i,l,u,d,f;if(Bm(e)||e._chatStop)return{kind:"system",id:Rm,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 g=n.agentId??n.chatId,m=((l=t.senderAgent)==null?void 0:l.call(t,n))??Dt({id:g});return{kind:"agent",id:`${$m}${g}`,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 qm(s,t);if(e.role==="user")return{kind:"human",id:Fm,displayName:((d=t.humanName)==null?void 0:d.trim())||Am};if(t.agent){const{id:g,displayName:m,emoji:h,color:x,imageUrl:C}=t.agent;return{kind:"agent",id:g,displayName:m,emoji:h,color:x,imageUrl:C}}const o=(f=t.runtime)==null?void 0:f.trim();return o?{kind:"agent",id:`${Lm}${o}`,displayName:fs(o),runtime:o}:{kind:"agent",id:Om,displayName:Im}}function qm(e,t){var o;const{author:n}=e;if(!n)return{kind:"human",id:`${lr}entry:${e.entryId}`,displayName:Pm};const s=`${lr}${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}))??Dt({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 ga(e){return`msg-${e}`}function Um(){return{last:null}}function Wm(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):[],g=u?u.items.slice(0,d):[];for(let b=f.length;b<e.length;b++){const y=e[b],v=n(y,b);f.push(v),g.push({id:y.id,authorId:v.id,timestamp:y.timestamp})}const m={now:s,lastSeenId:a,unreadFromStart:i},{rows:h,kept:x}=u?rl(g,m,u.timeline,d):{rows:ol(g,m),kept:0},C=u?u.rows.slice(0,x):[];for(let b=x;b<h.length;b++){const y=h[b];C.push(y.kind!=="item"?y:{kind:"message",key:ga(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:g,resolveAuthor:n,now:s,lastSeenMessageId:a,unreadFromStart:i,timeline:h,rows:C}),C}function Hm(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 Gm(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 xa=Symbol("no-error-part");function Vm(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 xa}function Km(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=Vm(t.slice(i+1));return u!==xa?u==="auth_error"?l:null:n==="error"&&s==="auth_error"?l:null}const Qm="dorkos:signin-resume",Xm=1e4;function Ym(){const e=c.useRef(new Map),t=c.useRef(null);return c.useEffect(()=>{const n=al(Qm);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<Xm},claim:n=>{var s;return(s=t.current)==null?void 0:s.postMessage({sessionId:n})}}),[])}function ba(e){switch(e){case"pending":case"running":return r.jsx(He,{size:"xs",className:It({status:e})});case"complete":return r.jsx(tn,{className:U("size-(--size-icon-xs)",It({status:e}))});case"error":return r.jsx(ct,{className:U("size-(--size-icon-xs)",It({status:e}))});case"neutral":return r.jsx(il,{className:U("size-(--size-icon-xs)",It({status:e}))})}}function cr({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(He,{className:"shrink-0"}),r.jsx("span",{className:"truncate text-xs",children:i})]})})}function Rt({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,...g}){const m=l?void 0:e;return r.jsxs("div",{className:U("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),...g,children:[r.jsxs("button",{onClick:()=>!i&&t(),disabled:i,className:U("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(H.div,{animate:{rotate:e?180:0},transition:{type:"spring",stiffness:400,damping:30},className:"ml-auto",children:r.jsx(Tt,{className:"text-muted-foreground size-(--size-icon-xs)"})})]}),u,r.jsx(me,{initial:!1,children:e&&r.jsx(H.div,{variants:Ke,initial:"initial",animate:"animate",exit:"exit",transition:Ve,className:"overflow-hidden",children:r.jsx("div",{className:"border-border/50 border-t px-3 pt-1 pb-3",children:s})})})]})}const Jm=[0,.2,.4];function ya({className:e}){return r.jsx("div",{className:U("flex gap-1",e),"data-testid":"typing-dots","aria-hidden":"true",children:Jm.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 Zm({record:e}){const t=Oe(),{color:n,emoji:s}=Dt({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(H.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(po,{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(ya,{})]})]})}function ep({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(Zm,{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 tp(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function np({sessionId:e}){const t=rn(e),n=Oe();if(!t||t.kind==="first-message")return null;const s=tp(t.bornAt),o=At(t.runtime).label;return r.jsxs(H.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(ll,{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(En,{}),r.jsxs("span",{children:["born ",s]})]}),r.jsx(En,{}),r.jsxs("span",{className:"min-w-0 truncate",children:["lives in ",r.jsx("code",{className:"text-2xs",children:t.path})]}),r.jsx(En,{}),r.jsxs("span",{className:"shrink-0",children:["runs on ",o]})]})]})}function En(){return r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50 shrink-0",children:"·"})}const sp="another chat";function rp(e,t){const n=t==null?void 0:t.find(s=>s.id===e);return n?cl(n)?Us("autonomy"):n.label:ho(e)?Us("autonomy"):ul(e)}function op({startedBy:e,modes:t}){var a;const n=ft();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(ap,{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 ",rp(o.mode,t),","," ",o.sameAsStarter?"same as":"lower than"," the chat that started it."]})]})}function ap({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(Ft({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??sp})]}),t&&r.jsxs(r.Fragment,{children:[": ",t]})]})}function ip({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(ms,{"aria-hidden":"true",className:U("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 lp={a:fl,img:xd},ka=c.createContext({isStreaming:!1});function cp(e){const t=c.useContext(ka);return r.jsx(ud,{...e,...t})}const up={renderers:[{language:cd,component:cp}]};function ks({content:e,isStreaming:t=!1,textEffect:n=Xd,sessionId:s,isLatestWidgetMessage:o}){const a=Jd(n),i=c.useMemo(()=>({sessionId:s,isLatestMessage:o,isStreaming:t}),[s,o,t]);return r.jsx(ka.Provider,{value:i,children:r.jsx("div",{className:U("relative",t&&"streaming-cursor"),children:r.jsx(gd,{resetKey:e,fallback:r.jsx("div",{className:"text-sm break-words whitespace-pre-wrap",children:e}),children:r.jsx(dl,{shikiTheme:["github-light","github-dark"],components:lp,animated:a,isAnimating:t,plugins:up,children:e})})})})}function Vn(e){if(e)try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}function xe(e,t){const n=e==null?void 0:e[t];return typeof n=="string"&&n.length>0?n:void 0}function dp(e){const t=Vn(e);if(t){if(Array.isArray(t.content))for(const n of t.content){const s=typeof(n==null?void 0:n.text)=="string"?Vn(n.text):void 0;if(s)return s}return t}}function va(e){const t=ml(e.toolName);if(t!=="chat_send"&&t!=="session_start"&&t!=="chat_stop")return null;const n=Vn(e.input),s=dp(e.result),o=fp(e,s),a=o===void 0&&(s==null?void 0:s.status)==="approval_required",i=xe(n,"delivery");return{tool:t,...xe(n,t==="chat_stop"?"chat":"to")!==void 0?{to:xe(n,t==="chat_stop"?"chat":"to")}:{},...xe(n,t==="session_start"?"prompt":"message")!==void 0?{message:xe(n,t==="session_start"?"prompt":"message")}:{},...xe(n,"summary")!==void 0?{summary:xe(n,"summary")}:{},...i==="queue"||i==="steer"||i==="interrupt"?{delivery:i}:{},...xe(n,"reason")!==void 0?{reason:xe(n,"reason")}:{},...xe(s,"messageId")!==void 0?{messageId:xe(s,"messageId")}:{},...(xe(s,"chatId")??xe(s,"sessionId"))!==void 0?{chatId:xe(s,"chatId")??xe(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}:{},...xe(s,"note")!==void 0?{note:xe(s,"note")}:{}}}const Lt="It could not be sent.";function fp(e,t){var n;if((t==null?void 0:t.status)==="denied")return xe(t,"message")??Lt;if((t==null?void 0:t.ok)===!1||typeof(t==null?void 0:t.error)=="string")return xe(t,"error")??xe(t,"message")??Lt;if(e.status==="error")return t?xe(t,"error")??xe(t,"message")??Lt:((n=e.result)==null?void 0:n.trim())||Lt}function mp(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 pp(e,t){if(e){for(let n=t.length-1;n>=0;n--)if(t[n].to.chatId===e)return t[n].to}}function hp(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 gp(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 xp(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 bp(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 Ca(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=va(i))==null?void 0:s.messageId)===t)return o.id}}const ur=new WeakMap;function yp(e,t){if(t.length===0)return e;const n=[];let s=0;const o=a=>{let i=ur.get(a);return i||(i={id:`chat-stop-${a.id}`,role:"user",content:"",parts:[],timestamp:a.at,_chatStop:a},ur.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 kp({stamp:e}){const t=bp(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 Sa({stamp:e}){const t=ft(),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(Ft({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(kp,{stamp:e})]})}function vp({sessionId:e,messageId:t}){const n=ft();return r.jsxs("button",{type:"button","data-testid":"chat-reply-to",onClick:()=>void n(Ft({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(Pd,{"aria-hidden":!0,className:"size-3"}),"Reply to your message"]})}function Cp({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(vp,{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(Sa,{stamp:n})]}),r.jsx("div",{className:"msg-prose",children:r.jsx(ks,{content:n.text,isStreaming:!1,...t?{sessionId:t}:{}})})]},n.id))})}function Sp({stamp:e}){const t=ft(),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({...pl.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 jp={muted:"text-muted-foreground",active:"text-foreground",done:"text-muted-foreground",error:"text-destructive"};function _p(e){return e.charAt(0).toUpperCase()+e.slice(1)}function wp(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=_p(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 Np(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 Ep({part:e,sent:t,at:n,sessionId:s}){const[o,a]=c.useState(!1),i=c.useId(),l=ft(),u=va(e);if(!u)return null;const d=e.status==="pending"||e.status==="running",f=hp(u,t),g=(f==null?void 0:f.to.chatId)??u.chatId??(u.tool==="chat_stop"?u.to:void 0),m=(f==null?void 0:f.to)??pp(g,t),h=(m==null?void 0:m.agentName)??"the agent",x=m==null?void 0:m.chatTitle,C=Dt({id:(m==null?void 0:m.agentId)??u.to??g??"chat"}),b=u.tool==="chat_stop"?Np(u,d):xp(f,{...u,pending:d}),y=gp((f==null?void 0:f.summary)??u.summary,(f==null?void 0:f.text)??u.message),v=n?Yt(n):f?Yt(f.sentAt):"",k=u.error??((f==null?void 0:f.status)==="failed"?f.failureReason:void 0),p=k?mp(k):u.tool==="chat_stop"?u.reason:y!==x?y:"",j=u.tool==="session_start"?zd:u.tool==="chat_stop"?go:hl,_=u.tool==="session_start"?"Started spin-off chat":u.tool==="chat_stop"?u.error||u.notRunning?"Tried to stop":"Stopped":"To",N=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",R=()=>{g&&l(Ft({session:g,...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(po,{size:"xs",emoji:C.emoji,color:C.color}),r.jsx(j,{"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:[_," "]}),r.jsx("span",{className:"font-medium",children:N}),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"||k)&&r.jsxs("span",{"data-testid":"sent-chat-aside",className:U("text-muted-foreground",!k&&"hidden sm:inline"),children:[" ","· ",p]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("span",{className:U("text-xs",jp[b.tone]),"data-testid":"sent-chat-state",children:b.label}),v&&r.jsx("time",{className:"text-muted-foreground hidden text-xs tabular-nums sm:inline",children:v}),r.jsx(Tt,{"aria-hidden":!0,className:U("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(ks,{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:[wp(u,f,h),u.note&&u.tool!=="chat_stop"&&f?` ${u.note}`:""]}),g&&!u.error&&!u.waiting&&r.jsx("button",{type:"button",onClick:R,className:"focus-ring text-foreground text-xs font-medium underline-offset-4 hover:underline",children:"Open chat →"})]})]})}function Dp({notice:e}){const t=ft();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(go,{"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(Ft({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 Tp={sent:[],stops:[]},Ap=new yl;function ja(e){const t=gl(),n=c.useContext(xl),s=bl(e??""),{data:o}=Je({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??Ap);return o??Tp}function vs(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 dr=new WeakMap;function Fp(e){let t=dr.get(e);return t||(t=e.map(it),dr.set(e,t)),t}function it(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=vs(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 Rp(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(g=>g.map(m=>m.id===a.id?{...it(f),_streaming:!1}:m));continue}if(i&&u>=0&&d===u+1&&f.role==="assistant"){const g=it(f),m=new Set(g.parts.filter(C=>C.type==="background_task").map(C=>C.taskId)),h=i.parts.filter(C=>C.type==="background_task"&&!m.has(C.taskId)),x=h.length>0?[...g.parts,...h]:g.parts;n(C=>C.map(b=>b.id===i.id?{...g,parts:x,_streaming:!1}:b));continue}l.push(f)}}l.length>0&&n(d=>[...d,...l.map(it)])}const Mp=20;function Op(e,t){var y;const n=ve(),s=kl(e),o=We(v=>v.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,g=c.useMemo(()=>f?s.earlier.map(it):[],[f,s.earlier]),m=c.useMemo(()=>g.length>0?[...g,...t]:t,[g,t]),h=f&&s.remaining>0,x=f?s.remaining:0,C=c.useCallback(()=>{var p;if(l.current===e||!h)return;const{generation:v}=s,k=((p=s.earlier[0])==null?void 0:p.id)??s.windowStartId;k&&(l.current=e,i(e),n.getMessages(e,void 0,{before:k}).then(j=>{We.getState().prependPage(e,v,j.messages,j.earlierMessages??0)}).catch(j=>{console.warn("[chat] could not read earlier messages",j),We.getState().endSeek(e)}).finally(()=>{l.current===e&&(l.current=null,i(null))}))},[h,e,n,s]),b=o!==void 0&&(m.some(v=>v.id===o)||Ca([...s.earlier,...De.getState().getSession(e).messages],o)!==void 0);return c.useEffect(()=>{if(o===void 0){d.current={key:"",count:0};return}const v=`${e}:${o}`;if(d.current.key!==v&&(d.current={key:v,count:0}),!(s.generation===0||u)){if(b||!h||d.current.count>=Mp){We.getState().endSeek(e);return}d.current.count+=1,C()}},[o,b,h,u,C,e,s.generation]),{messages:m,earlierCount:g.length,messagesBefore:x,canLoadEarlier:h,isLoadingEarlier:u,isSeeking:o!==void 0,loadEarlier:C}}function Ip({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;vl({kind:"burst"}).then(l=>{if(a){l();return}n.current=l});const i=setTimeout(()=>{o()},on.CELEBRATION_DISPLAY_MS);return()=>{var l;a=!0,(l=n.current)==null||l.call(n),n.current=null,clearTimeout(i)}},[s,o]),r.jsx(me,{children:s&&r.jsx(H.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:Qd})})}const Cs=c.createContext(null);function _a({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(Cs,{value:n,children:e})}function $p(){const e=c.useContext(Cs);if(!e)throw new Error("useMessageContext must be used within MessageProvider");return e}function Pp(){return c.useContext(Cs)}function Lp(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 Bp({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 ${Lp(n)}`:"Thinking…";return r.jsx(Rt,{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($d,{className:U("text-muted-foreground size-(--size-icon-xs)",t&&"animate-breath")}),r.jsx("span",{className:U("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 zp({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"?Cl:Sl,d=e==="synthesize"?"sparkles":"bookopen";return r.jsx(Rt,{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:U("text-muted-foreground size-(--size-icon-xs)",n&&"animate-breath")}),r.jsx("span",{className:U("text-3xs text-muted-foreground font-mono",n&&"animate-breath"),children:l})]}),children:r.jsx(qp,{memories:t})})}function qp({memories:e}){return r.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>r.jsx(Up,{memory:t},t.path))})}function Up({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?jl:_l,s=e.scope==="team"?"team":"personal",{copy:o}=wl({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:Zd(e.path,40)}),r.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function Kt(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function wa(e){return e===void 0?"Summarized (asked by the agent)":`Summarized at ${e}% (asked by the agent)`}function Wp(e){if((e==null?void 0:e.requestedBy)==="agent")return wa(e.contextPercent);const t=["Context compacted"];return(e==null?void 0:e.preTokens)!==void 0&&t.push(`${Kt(e.preTokens)} tokens`),e!=null&&e.trigger&&t.push(e.trigger),t.join(" · ")}function Hp(e,t){return e===void 0?"Compacted context":t===void 0?`Compacted context · ${Kt(e)} tokens summarized`:`Compacted context · ${Kt(e)} → ${Kt(t)} tokens`}function Gp({trigger:e,preTokens:t,postTokens:n,failed:s,error:o,requestedBy:a,contextPercent:i}){return s?r.jsx(ot,{"data-testid":"compact-boundary-row","data-failed":"true",icon:r.jsx(ps,{"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(ot,{"data-testid":"compact-boundary-row","data-requested-by":"agent",icon:r.jsx(Ws,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:wa(i)})}):r.jsx(ot,{"data-testid":"compact-boundary-row",icon:r.jsx(Ws,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:Hp(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 Vp({part:e}){const[t,n]=c.useState(!1);return t?r.jsxs("div",{"data-testid":"message-image-missing",className:U("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(Nd,{"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(xo,{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 Kp({content:e}){return r.jsx(ot,{"data-testid":"staged-context-note",icon:r.jsx(bo,{"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 Qp(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 Xp(e){return e==="untracked"?"neutral":e==="stopped"?"complete":e}function Yp(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(Qp(e.durationMs)),t.length>0?t.join(" · "):null}function Jp({part:e}){const[t,n]=c.useState(!1),s=c.useRef(null),o=Yp(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(Rt,{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:[ba(Xp(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 Zp=e=>typeof e=="boolean"||e instanceof Boolean,eh=e=>typeof e=="number"||e instanceof Number,th=e=>typeof e=="bigint"||e instanceof BigInt,Na=e=>!!e&&e instanceof Date,nh=e=>typeof e=="string"||e instanceof String,sh=e=>Array.isArray(e),Ea=e=>typeof e=="object"&&e!==null,Da=e=>!!e&&e instanceof Object&&typeof e=="function";function Zt(e,t){return t===void 0&&(t=!1),!e||t?`"${e}"`:e}function rh(e,t,n){return n?JSON.stringify(e):t?`"${e}"`:e}function Ta(e){let{field:t,value:n,data:s,lastElement:o,openBracket:a,closeBracket:i,level:l,style:u,shouldExpandNode:d,clickToExpandNode:f,outerRef:g,beforeExpandChange:m}=e;const h=c.useRef(!1),[x,C]=c.useState(()=>d(l,n,t)),b=c.useRef(null);c.useEffect(()=>{h.current?C(d(l,n,t)):h.current=!0},[d]);const y=c.useId();if(s.length===0)return oh({field:t,openBracket:a,closeBracket:i,lastElement:o,style:u});const v=x?u.collapseIcon:u.expandIcon,k=x?u.ariaLables.collapseJson:u.ariaLables.expandJson,p=l+1,j=s.length-1,_=w=>{x!==w&&(!m||m({level:l,value:n,field:t,newExpandValue:w}))&&C(w)},N=w=>{if(w.key==="ArrowRight"||w.key==="ArrowLeft")w.preventDefault(),_(w.key==="ArrowRight");else if(w.key==="ArrowUp"||w.key==="ArrowDown"){w.preventDefault();const A=w.key==="ArrowUp"?-1:1;if(!g.current)return;const F=g.current.querySelectorAll("[role=button]");let D=-1;for(let E=0;E<F.length;E++)if(F[E].tabIndex===0){D=E;break}if(D<0)return;const S=(D+A+F.length)%F.length;F[D].tabIndex=-1,F[S].tabIndex=0,F[S].focus()}},R=()=>{var w;_(!x);const A=b.current;if(!A)return;const F=(w=g.current)===null||w===void 0?void 0:w.querySelector('[role=button][tabindex="0"]');F&&(F.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:v,onClick:R,onKeyDown:N,role:"button","aria-label":k,"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:R,onKeyDown:N},Zt(t,u.quotesForFieldNames),":"):c.createElement("span",{className:u.label},Zt(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(Kn,{key:w[0]||A,field:w[0],value:w[1],style:u,lastElement:A===j,level:p,shouldExpandNode:d,clickToExpandNode:f,beforeExpandChange:m,outerRef:g}))):c.createElement("span",{className:u.collapsedContent,onClick:R,onKeyDown:N}),c.createElement("span",{className:u.punctuation},i),!o&&c.createElement("span",{className:u.punctuation},","))}function oh(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},Zt(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 ah(e){let{field:t,value:n,style:s,lastElement:o,shouldExpandNode:a,clickToExpandNode:i,level:l,outerRef:u,beforeExpandChange:d}=e;return Ta({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 ih(e){let{field:t,value:n,style:s,lastElement:o,level:a,shouldExpandNode:i,clickToExpandNode:l,outerRef:u,beforeExpandChange:d}=e;return Ta({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 lh(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):nh(n)?(a=rh(n,!s.noQuotesForStringValues,s.stringifyStringValues),i=s.stringValue):Zp(n)?(a=n?"true":"false",i=s.booleanValue):eh(n)?(a=n.toString(),i=s.numberValue):th(n)?(a=`${n.toString()}n`,i=s.numberValue):Na(n)?a=n.toISOString():Da(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},Zt(t,s.quotesForFieldNames),":"),c.createElement("span",{className:i},a),!o&&c.createElement("span",{className:s.punctuation},","))}function Kn(e){const t=e.value;return sh(t)?c.createElement(ih,Object.assign({},e)):Ea(t)&&!Na(t)&&!Da(t)?c.createElement(ah,Object.assign({},e)):c.createElement(lh,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 Aa={collapseJson:"collapse JSON",expandJson:"expand JSON"},Dn={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:Aa,stringifyStringValues:!1},ch={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:Aa,stringifyStringValues:!1},uh=()=>!0,dh=e=>e<1,fh=e=>{let{data:t,style:n=Dn,shouldExpandNode:s=uh,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&&Ea(t)?Object.entries(t).map(d=>{let[f,g]=d;return c.createElement(Kn,{key:f,field:f,value:g,style:{...Dn,...n},lastElement:!0,level:1,shouldExpandNode:s,clickToExpandNode:o,beforeExpandChange:a,outerRef:u})}):c.createElement(Kn,{value:t,style:{...Dn,...n},lastElement:!0,level:0,shouldExpandNode:s,clickToExpandNode:o,outerRef:u,beforeExpandChange:a}))};var Ae={},Tn,fr;function mh(){if(fr)return Tn;fr=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#;/?:@=+$',_.!~*()[\]-]|&|%[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=="&"?"&":a=='"'?""":a=="<"?"<":a==">"?">":"")}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(g=>this.processChunk(g,a,i));if(a&&a.json){let g=l.processChunkJson("");return g.content=d,g.clearLine=a.clearLine,f.unshift(g),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 g=f[2].split(";");if(f[1]!==""||f[3]!=="m"||!i)return d;let m=this;for(;g.length>0;){let h=g.shift(),x=parseInt(h);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(g.length>=1){let b=g.shift();if(b==="5"&&g.length>=1){let y=parseInt(g.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 v=y>=16?"ansi-palette-"+y:e[y>7?1:0][y%8].class;C?m.fg=v:m.bg=v}}else if(b==="2"&&g.length>=3){let y=parseInt(g.shift()),v=parseInt(g.shift()),k=parseInt(g.shift());if(y>=0&&y<=255&&v>=0&&v<=255&&k>=0&&k<=255){let p=y+", "+v+", "+k;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=[],g=[],m={},h=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"?g.push("line-through"):g.push(x)}),g.length&&f.push("text-decoration:"+g.join(" ")),u?'<span class="'+d.concat(f).join(" ")+'"'+h(m)+">"+l.content+"</span>":'<span style="'+d.concat(f).join(";")+'"'+h(m)+">"+l.content+"</span>"}removeDecoration(o){const a=this.decorations.indexOf(o);a>=0&&this.decorations.splice(a,1)}}return Tn=n,Tn}var gt={exports:{}},mr;function ph(){if(mr)return gt.exports;mr=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 gt.exports=e,gt.exports.escapeCarriageReturn=e,gt.exports.escapeCarriageReturnSafe=s,gt.exports}var Ge={},pr;function hh(){if(pr)return Ge;pr=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 Ge.Any=e,Ge.Cc=t,Ge.Cf=n,Ge.P=s,Ge.S=o,Ge.Z=a,Ge}var An,hr;function gh(){if(hr)return An;hr=1;var e=hh();function t(k){const p={};k=k||{},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 j="[><|]";return p.src_pseudo_letter=`(?:(?!${j}|${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=`(?=$|${j}|${p.src_ZPCc})(?!${k["---"]?"-(?!--)|":"-|"}_|:\\d|\\.-|\\.(?!$|${p.src_ZPCc}))`,p.src_path=`(?:[/?#](?:(?!${p.src_ZCc}|${j}|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!${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}|[.]|$)|`+(k["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+`,(?!${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=`(^|${j}|"|\\(|${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(k){return Array.prototype.slice.call(arguments,1).forEach(function(j){j&&Object.keys(j).forEach(function(_){k[_]=j[_]})}),k}function s(k){return Object.prototype.toString.call(k)}function o(k){return s(k)==="[object String]"}function a(k){return s(k)==="[object Object]"}function i(k){return s(k)==="[object RegExp]"}function l(k){return s(k)==="[object Function]"}function u(k){return k.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const d={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function f(k){return Object.keys(k||{}).reduce(function(p,j){return p||d.hasOwnProperty(j)},!1)}const g={"http:":{validate:function(k,p,j){const _=k.slice(p);return j.re.http||(j.re.http=new RegExp(`^\\/\\/${j.re.src_auth}${j.re.src_host_port_strict}${j.re.src_path}`,"i")),j.re.http.test(_)?_.match(j.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(k,p,j){const _=k.slice(p);return j.re.no_http||(j.re.no_http=new RegExp("^"+j.re.src_auth+`(?:localhost|(?:(?:${j.re.src_domain})\\.)+${j.re.src_domain_root})`+j.re.src_port+j.re.src_host_terminator+j.re.src_path,"i")),j.re.no_http.test(_)?p>=3&&k[p-3]===":"||p>=3&&k[p-3]==="/"?0:_.match(j.re.no_http)[0].length:0}},"mailto:":{validate:function(k,p,j){const _=k.slice(p);return j.re.mailto||(j.re.mailto=new RegExp(`^${j.re.src_email_name}@${j.re.src_host_strict}`,"i")),j.re.mailto.test(_)?_.match(j.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]",h="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function x(k){return function(p,j){const _=p.slice(j);return k.test(_)?_.match(k)[0].length:0}}function C(){return function(k,p){p.normalize(k)}}function b(k){const p=k.re=t(k.__opts__),j=k.__tlds__.slice();k.onCompile(),k.__tlds_replaced__||j.push(m),j.push(p.src_xn),p.src_tlds=j.join("|");function _(A){return A.replace("%TLDS%",p.src_tlds)}p.email_fuzzy=RegExp(_(p.tpl_email_fuzzy),"i"),p.email_fuzzy_global=RegExp(_(p.tpl_email_fuzzy),"ig"),p.link_fuzzy=RegExp(_(p.tpl_link_fuzzy),"i"),p.link_fuzzy_global=RegExp(_(p.tpl_link_fuzzy),"ig"),p.link_no_ip_fuzzy=RegExp(_(p.tpl_link_no_ip_fuzzy),"i"),p.link_no_ip_fuzzy_global=RegExp(_(p.tpl_link_no_ip_fuzzy),"ig"),p.host_fuzzy_test=RegExp(_(p.tpl_host_fuzzy_test),"i");const N=[];k.__compiled__={};function R(A,F){throw new Error(`(LinkifyIt) Invalid schema "${A}": ${F}`)}Object.keys(k.__schemas__).forEach(function(A){const F=k.__schemas__[A];if(F===null)return;const D={validate:null,link:null};if(k.__compiled__[A]=D,a(F)){i(F.validate)?D.validate=x(F.validate):l(F.validate)?D.validate=F.validate:R(A,F),l(F.normalize)?D.normalize=F.normalize:F.normalize?R(A,F):D.normalize=C();return}if(o(F)){N.push(A);return}R(A,F)}),N.forEach(function(A){k.__compiled__[k.__schemas__[A]]&&(k.__compiled__[A].validate=k.__compiled__[k.__schemas__[A]].validate,k.__compiled__[A].normalize=k.__compiled__[k.__schemas__[A]].normalize)}),k.__compiled__[""]={validate:null,normalize:C()};const w=Object.keys(k.__compiled__).filter(function(A){return A.length>0&&k.__compiled__[A]}).map(u).join("|");k.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|${p.src_ZPCc}))(${w})`,"i"),k.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|${p.src_ZPCc}))(${w})`,"ig"),k.re.schema_at_start=RegExp(`^${k.re.schema_search.source}`,"i"),k.re.pretest=RegExp(`(${k.re.schema_test.source})|(${k.re.host_fuzzy_test.source})|@`,"i")}function y(k,p,j,_){const N=k.slice(j,_);this.schema=p.toLowerCase(),this.index=j,this.lastIndex=_,this.raw=N,this.text=N,this.url=N}function v(k,p){if(!(this instanceof v))return new v(k,p);p||f(k)&&(p=k,k={}),this.__opts__=n({},d,p),this.__schemas__=n({},g,k),this.__compiled__={},this.__tlds__=h,this.__tlds_replaced__=!1,this.re={},b(this)}return v.prototype.add=function(p,j){return this.__schemas__[p]=j,b(this),this},v.prototype.set=function(p){return this.__opts__=n(this.__opts__,p),this},v.prototype.test=function(p){if(!p.length)return!1;let j,_;if(this.re.schema_test.test(p)){for(_=this.re.schema_search,_.lastIndex=0;(j=_.exec(p))!==null;)if(this.testSchemaAt(p,j[2],_.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)},v.prototype.pretest=function(p){return this.re.pretest.test(p)},v.prototype.testSchemaAt=function(p,j,_){return this.__compiled__[j.toLowerCase()]?this.__compiled__[j.toLowerCase()].validate(p,_,this):0},v.prototype.match=function(p){const j=[],_=[],N=[],R=[];let w,A,F;function D(T,M){return T?M?T.index!==M.index?T.index<M.index?T:M:T.lastIndex>=M.lastIndex?T:M:T:M}if(!p.length)return null;if(this.re.schema_test.test(p))for(F=this.re.schema_search,F.lastIndex=0;(w=F.exec(p))!==null;)A=this.testSchemaAt(p,w[2],F.lastIndex),A&&_.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(F=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,F.lastIndex=0;(w=F.exec(p))!==null;)N.push({schema:"",index:w.index+w[1].length,lastIndex:w.index+w[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"])for(F=this.re.email_fuzzy_global,F.lastIndex=0;(w=F.exec(p))!==null;)R.push({schema:"mailto:",index:w.index+w[1].length,lastIndex:w.index+w[0].length});const S=[0,0,0];let E=0;for(;;){const T=[_[S[0]],R[S[1]],N[S[2]]],M=D(D(T[0],T[1]),T[2]);if(!M)break;if(M===T[0]?S[0]++:M===T[1]?S[1]++:S[2]++,M.index<E)continue;const I=new y(p,M.schema,M.index,M.lastIndex);this.__compiled__[I.schema].normalize(I,this),j.push(I),E=M.lastIndex}return j.length?j:null},v.prototype.matchAtStart=function(p){if(!p.length)return null;const j=this.re.schema_at_start.exec(p);if(!j)return null;const _=this.testSchemaAt(p,j[2],j[0].length);if(!_)return null;const N=new y(p,j[2],j.index+j[1].length,j.index+j[0].length+_);return this.__compiled__[N.schema].normalize(N,this),N},v.prototype.tlds=function(p,j){return p=Array.isArray(p)?p:[p],j?(this.__tlds__=this.__tlds__.concat(p).sort().filter(function(_,N,R){return _!==R[N-1]}).reverse(),b(this),this):(this.__tlds__=p.slice(),this.__tlds_replaced__=!0,b(this),this)},v.prototype.normalize=function(p){p.schema||(p.url=`http://${p.url}`),p.schema==="mailto:"&&!/^mailto:/i.test(p.url)&&(p.url=`mailto:${p.url}`)},v.prototype.onCompile=function(){},An=v,An}var gr;function xh(){if(gr)return Ae;gr=1;var e=Ae&&Ae.__createBinding||(Object.create?(function(b,y,v,k){k===void 0&&(k=v);var p=Object.getOwnPropertyDescriptor(y,v);(!p||("get"in p?!y.__esModule:p.writable||p.configurable))&&(p={enumerable:!0,get:function(){return y[v]}}),Object.defineProperty(b,k,p)}):(function(b,y,v,k){k===void 0&&(k=v),b[k]=y[v]})),t=Ae&&Ae.__setModuleDefault||(Object.create?(function(b,y){Object.defineProperty(b,"default",{enumerable:!0,value:y})}):function(b,y){b.default=y}),n=Ae&&Ae.__importStar||(function(){var b=function(y){return b=Object.getOwnPropertyNames||function(v){var k=[];for(var p in v)Object.prototype.hasOwnProperty.call(v,p)&&(k[k.length]=p);return k},b(y)};return function(y){if(y&&y.__esModule)return y;var v={};if(y!=null)for(var k=b(y),p=0;p<k.length;p++)k[p]!=="default"&&e(v,y,k[p]);return t(v,y),v}})(),s=Ae&&Ae.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.default=x;const o=s(mh()),a=ph(),i=s(gh()),l=n(Nl());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 g(b,y,v,k){const p=y?null:f(v),j=y?d(v):null;return b?b==="fuzzy"?h(v,k,p,j):m(v,k,p,j):l.createElement("span",{style:p,key:k,className:j},v.content)}function m(b,y,v,k){const p=[],j=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let _=0,N;for(;(N=j.exec(b.content))!==null;){const[,R,w]=N,A=N.index+R.length;A>_&&p.push(b.content.substring(_,A));const F=w.startsWith("www.")?`http://${w}`:w;p.push(l.createElement("a",{key:_,href:F,target:"_blank"},`${w}`)),_=j.lastIndex}return _<b.content.length&&p.push(b.content.substring(_)),l.createElement("span",{style:v,key:y,className:k},p)}function h(b,y,v,k){var p;const j=(0,i.default)({fuzzyEmail:!1}).tlds(["io"],!0);if(!j.pretest(b.content))return l.createElement("span",{style:v,key:y,className:k},b.content);const _=j.match(b.content);if(!_)return l.createElement("span",{style:v,key:y,className:k},b.content);const N=[b.content.substring(0,(p=_[0])===null||p===void 0?void 0:p.index)];return _.forEach((R,w)=>{var A;N.push(l.createElement("a",{href:R.url,target:"_blank",key:w},b.content.substring(R.index,R.lastIndex))),_[w+1]&&N.push(b.content.substring(_[w].lastIndex,(A=_[w+1])===null||A===void 0?void 0:A.index))}),_[_.length-1].lastIndex!==b.content.length&&N.push(b.content.substring(_[_.length-1].lastIndex,b.content.length)),l.createElement("span",{style:v,key:y,className:k},N)}function x(b){const{className:y,useClasses:v,children:k,linkify:p}=b;return l.createElement("code",{className:y},u(k??"",v??!1).map(g.bind(null,p??!1,v??!1)))}function C(b){let y=b;do b=y,y=b.replace(/[^\n]\x08/gm,"");while(y.length<b.length);return b}return Ae}var bh=xh();const yh=El(bh),kh=c.lazy(()=>Dl(()=>import("./index-B9utW3HE.js"),__vite__mapDeps([0,1,2,3]))),vh={...ch,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-["…"]'},xr=5120;function Ch(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 Fn({children:e,rawContent:t,supportsRawToggle:n,isRaw:s,onToggleRaw:o}){const[a,i]=c.useState(!1),l=t.length>xr,u=l&&!a?t.slice(0,xr):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(kh,{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 Fa({content:e,toolName:t,input:n}){const[s,o]=c.useState(!1);if(t==="Edit"&&n){const i=Ch(n);if(i)return r.jsx(Sh,{oldValue:i.old_string??"",newValue:i.new_string??"",rawContent:e})}const a=nf(e);if(a==="json"){let i;try{i=JSON.parse(e)}catch{i={}}return r.jsx(Fn,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>o(l=>!l),children:r.jsx(fh,{data:i,style:vh,shouldExpandNode:dh})})}return a==="ansi"?r.jsx(Fn,{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(yh,{children:e})})}):r.jsx(Fn,{rawContent:e,supportsRawToggle:!1,isRaw:!0,onToggleRaw:()=>{},children:null})}function jh(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 _h(e){const t=jh(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 Ra="runtimes";function wh({label:e}){const{open:t}=yo();return r.jsx("button",{type:"button",onClick:()=>t(Ra),className:"text-muted-foreground hover:text-foreground mt-2 block text-xs underline decoration-dotted underline-offset-2 transition-colors",children:e})}function Nh({runtime:e,sessionId:t,onRetry:n,onSigninComplete:s}){const[o,a]=c.useState(!1),i=vd(e,{sessionId:t,onCompleted:()=>a((s==null?void 0:s())??!1)}),l=Cd(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(tn,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),o?"Signed in. Sending your message again…":"Signed in."]}),!o&&n&&r.jsxs(fe,{size:"sm",onClick:n,className:"mt-2 gap-1.5",children:[r.jsx(St,{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(He,{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(fe,{size:"sm",onClick:i.login,disabled:i.isPending,className:"gap-1.5","data-testid":"auth-error-signin-button",children:[r.jsx(ko,{className:"size-3"}),i.isError?"Try again":l.signInLabel]}),n&&r.jsxs(fe,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[r.jsx(St,{className:"size-3"}),"Retry"]})]}),r.jsx(wh,{label:"Use an API key instead"})]})}function br({onRetry:e}){return r.jsx("div",{className:"mt-3","data-testid":"auth-error-remote-guidance",children:r.jsx(yd,{...e?{onRetry:e}:{}})})}function Ma({onRetry:e}){const{open:t}=yo();return r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r.jsxs(fe,{size:"sm",onClick:()=>t(Ra),className:"gap-1.5",children:[r.jsx(ko,{className:"size-3"}),"Fix sign-in"]}),e&&r.jsxs(fe,{variant:"outline",size:"sm",onClick:e,className:"gap-1.5",children:[r.jsx(St,{className:"size-3"}),"Retry"]})]})}function Eh({runtime:e,sessionId:t,onRetry:n,renderOffer:s,lead:o,children:a}){const i=!Vo(),l=vo(),u=le(m=>m.setRetryAccount),d=At(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:ut,sessionId:t}),n())}}),g=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,g(a),r.jsx(kd,{ollama:Tl(e)==="provider-picker",remote:i})]}):r.jsxs("div",{"data-testid":"auth-error-credits-other-way",children:[a,r.jsx("div",{className:"mt-3",children:g(f)})]})}function Dh({sessionId:e,onRetry:t,onSigninComplete:n}){var g;const{sessions:s,isLoading:o}=rs(),a=Vo(),i=(g=s.find(m=>m.id===e))==null?void 0:g.runtime,l=bd(i),u=mo(),d=i!==void 0&&u!==null&&(l==="lead"||l==="other-way");if(!a&&!d)return r.jsx(br,{onRetry:t});if(o)return null;const f=a?!i||!Al(i)?r.jsx(Ma,{onRetry:t}):r.jsx(Nh,{runtime:i,sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(br,{onRetry:t});return d&&i&&u?r.jsx(Eh,{runtime:i,sessionId:e,onRetry:t,renderOffer:u,lead:l==="lead",children:f}):f}function Th({sessionId:e,onRetry:t,onSigninComplete:n}){return e?r.jsx(Dh,{sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(Ma,{onRetry:t})}const Ah="credits_unavailable",Fh="folder-sign-in";function Rh({onRetry:e,sessionId:t,runtimeLabel:n,reason:s}){const o=le(x=>x.setRetryAccount),a=Fl(),i=vo(),l=Co(),u=cn(t),d=an(u??null);if(!e)return null;const f=Mh(d),g=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()})}},h=()=>{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(fe,{size:"sm",variant:"outline",onClick:e,className:"gap-1.5",children:[r.jsx(St,{className:"size-3"}),"Retry"]}),t&&r.jsx(fe,{size:"sm",variant:"outline",onClick:m,disabled:d===void 0||i.isPending,children:f==="new-conversation"?`Start a new chat on ${g} sign-in`:`Use ${g} sign-in`}),t&&s===Fh&&r.jsx(fe,{size:"sm",variant:"outline",onClick:h,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 ",g," 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 Mh(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 Oh({category:e,onChooseModel:t}){return t?r.jsxs(fe,{size:"sm",onClick:t,className:"mt-3 gap-1.5",children:[r.jsx(So,{className:"size-3"}),e==="runtime_update_required"?"Choose another model":"Choose model"]}):null}const Ih="your agent",$h="agent",yr={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}},Ph=new Set(["max_turns","budget_exceeded","output_format_error","auth_error"]);function Lh(e){return`Sign in to ${e??Ih} again`}function Bh(e){return`Your ${e??$h} login stopped working. Sign in again to continue.`}const zh="rate_limit";function dn(e){const{code:t,at:n,sessionId:s,reason:o}=e;return t===jo&&o?r.jsx(ra,{agentId:o}):t===zh&&s?r.jsx(_m,{sessionId:s,at:n??"",fallback:r.jsx(kr,{...e})}):r.jsx(kr,{...e})}function kr({message:e,category:t,details:n,onRetry:s,heading:o,subtext:a,runtimeLabel:i,sessionId:l,onSigninComplete:u,onChooseModel:d,code:f,reason:g}){const[m,h]=c.useState(!1),x=f===Ah,C=c.useMemo(()=>_h(e),[e]),b=(C==null?void 0:C.category)??t,y=(C==null?void 0:C.message)??e,v=C?n!=null&&n.includes(C.details??"")?n:[n,C.details].filter(Boolean).join(`
|
|
41
|
-
`):n,k=b==="auth_error",p=b?yr[b]??yr.execution_error:null,j=k?Lh(i):b==="runtime_update_required"&&i?`${i} update required`:p==null?void 0:p.heading,_=k?Bh(i):p==null?void 0:p.subtext,N=x?"Couldn’t reach DorkOS credits":C?j??"Error":o??j??"Error",R=y.trim(),w=b!==void 0&&Ph.has(b),A=x?R:(C&&(a==null?void 0:a.trim())===e.trim()?void 0:a)??(w?_:R||_)??R,F=A.trim(),D=c.useMemo(()=>Rl(R),[R]),S=!R||R===F||R===N,E=!S&&(!w||D)?R:null,T=S||E!==null||v!=null&&v.includes(R)?v:[v,R].filter(Boolean).join(`
|
|
42
|
-
`),M=(p==null?void 0:p.retryable)??!!s;return r.jsx("div",{"data-testid":"error-message-block",className:U("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(ps,{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:N}),r.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(xn,{text:A})}),E&&r.jsx("p",{className:"text-muted-foreground mt-1 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(xn,{text:E})}),T&&r.jsxs("button",{type:"button",onClick:()=>h(!m),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":m,children:[r.jsx(H.div,{animate:{rotate:m?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:r.jsx(Tt,{className:"size-3"})}),"Details"]}),r.jsx(me,{initial:!1,children:m&&T&&r.jsx(H.div,{variants:Ke,initial:"initial",animate:"animate",exit:"exit",transition:Ve,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(xn,{text:T})})})}),x&&r.jsx(Rh,{onRetry:s,sessionId:l,runtimeLabel:i,reason:g}),k&&r.jsx(Th,{sessionId:l,onRetry:s,onSigninComplete:u}),(b==="model_unavailable"||b==="runtime_update_required")&&r.jsx(Oh,{category:b,onChooseModel:d})]}),!k&&!x&&M&&s&&r.jsxs(fe,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[r.jsx(St,{className:"size-3"}),"Retry"]})]})})}const qh=8;function Uh({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,qh)}`: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:U("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(Sd,{"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 Wh=50;function Hh(e){return e.type==="tool_call"&&e.interactiveType==="approval"&&e.approvalOutcome!==void 0}function Gh(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)<=Wh}function Vh(e){const t=new Map;let n=null;for(let s=0;s<e.length;s++){const o=e[s];if(!Hh(o)){n=null;continue}if(n&&Gh(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 Ss(e){return e.type==="thinking"||e.type==="memory_recall"||e.type==="background_task"?!0:e.type==="tool_call"&&!e.interactiveType&&!e.ui&&!bs(e.toolName)&&!Xt(e.toolName)}function Kh(e){let t=0;for(const n of e)(n.type==="background_task"||n.type==="tool_call"&&Ss(n))&&t++;return t}function Oa(e){return e.some(Ss)}function Qh(e){return e.questionOutcome!==void 0?e.questionOutcome==="answered":e.status!=="pending"}function Xh(e){return e.status==="pending"?void 0:e.questionOutcome}function Yh({message:e}){return r.jsx(ot,{"data-testid":"unreadable-entry-note",icon:r.jsx(Ml,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:e})})}function Jh({title:e}){return r.jsxs("div",{"data-testid":"capability-approval-timed-out",className:U("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-border bg-muted/40"),children:[r.jsx(bt,{"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 Qn({testId:e,icon:t,children:n}){return r.jsxs("div",{"data-testid":e,className:U("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 Zh({part:e}){return e.outcome==="failed"?r.jsx(Qn,{testId:"mcp-signin-failed",icon:r.jsx(ps,{"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(Qn,{testId:"mcp-signin-receipt",icon:r.jsx(_o,{"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 eg({part:e}){const t=jd(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(Zh,{part:e}):r.jsxs(Qn,{testId:"mcp-signin-card",icon:r.jsx(Ol,{"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(_d,{flow:t,serverName:e.serverName,failedActions:r.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>t.start(),className:"focus-visible:ring-2",children:"Try again"})})]})}function tg({fromName:e,toName:t}){return r.jsx(ot,{"data-testid":"model-substituted-row",icon:r.jsx(So,{"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 ng={running:r.jsx(He,{size:"xs",className:"text-muted-foreground"}),success:r.jsx(tn,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:r.jsx(ct,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:r.jsx(ct,{className:"text-muted-foreground size-(--size-icon-xs)"})};function sg({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:U("flex w-full items-center gap-1.5 py-0.5",!t&&"cursor-default"),"aria-expanded":t?n:void 0,disabled:!t,children:[ng[e.status],r.jsx("span",{className:U("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(me,{initial:!1,children:n&&t&&o&&r.jsx(H.div,{variants:Ke,initial:"initial",animate:"animate",exit:"exit",transition:Ve,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 rg({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(sg,{hook:u},u.hookId))}):void 0,i=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,l=Il(e.toolName);return r.jsxs(Rt,{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:[ba(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:Ed(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(He,{size:"xs"}),r.jsx("span",{children:"Preparing…"})]}):e.input!==void 0&&e.input!==""?r.jsx($l,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&r.jsx(co,{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(Fa,{content:e.result,toolName:e.toolName,input:e.input})})]})}function og(e){if(e.startsWith("mcp__"))return e.split("__")[1]||void 0}function Ia(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),on.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(i)}},[e,t,n]),!t||n?!0:o}function ag({part:e,autoHide:t,expandToolCalls:n}){var a;const s=((a=e.hooks)==null?void 0:a.some(i=>i.status==="error"))??!1,o=Ia(e.status,t,s);return r.jsx(me,{children:o&&r.jsx(H.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx(rg,{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 Rn({part:e,sessionId:t,autoHide:n,expandToolCalls:s}){const o=e.ui?og(e.toolName):void 0,a=r.jsx(ag,{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(Ef,{sessionId:t,serverName:o,uri:e.ui.resourceUri})]})}function ig({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",o=Ia(s,t,!1);return r.jsx(me,{children:o&&r.jsx(H.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx(Bp,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const lg=4,vr=2;function cg({children:e}){const[t,n]=c.useState(!1);if(e.length<=lg||t)return r.jsx(r.Fragment,{children:e});const s=e.length-vr;return r.jsxs(r.Fragment,{children:[e.slice(0,vr),r.jsx(Rt,{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 ug=/\|\||&&|;|\|/,dg=/<<|>/,Cr=60;function fg(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 Be(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function mg(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 Xn(e){const t=e.old_string,n=e.new_string;if(!(typeof t!="string"&&typeof n!="string"))return mg(typeof t=="string"?t:"",typeof n=="string"?n:"")}function pg(e){const t=e.edits;if(!Array.isArray(t))return Xn(e);let n=0,s=0,o=!1;for(const a of t){if(typeof a!="object"||a===null)continue;const i=Xn(a);i&&(n+=i.additions,s+=i.deletions,o=!0)}return o?{additions:n,deletions:s}:void 0}function hg(e){return e?` +${e.additions} −${e.deletions}`:""}function gg(e){return e.length===0?0:e.replace(/\n$/,"").split(`
|
|
45
|
-
`).length}function $a(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 xg(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 Pa(e){const t=$a(e).split("/");return t[t.length-1]||e}function bg(e){try{const t=new URL(e);return t.hash="",t.toString()}catch{return e}}function yg(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function kg(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 vg(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<=Cr?n:`${n.slice(0,Cr-1).trimEnd()}…`}function Cg(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 Sg(e){const t=[];for(const n of e.split(`
|
|
48
|
-
`)){for(const s of n.split(ug)){const o=Cg(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(dg.test(n))break}return t}const Sr={delete:3,create:2,edit:1,read:0,search:0,fetch:0,run:0},jg=new Set(["Task","Agent","TodoWrite"]);function js(e){return e===1?"1 hit":`${e} hits`}const _g=/[*?[\]~$]/;function xt(e,t,n,s,o){const a=$a(e);return{key:`file:${a}`,kind:"file",label:o===!0?a:Pa(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 wg(e){const{toolName:t}=e;if(jg.has(t)||t.startsWith("mcp__"))return[];const n=fg(e.input);if(!n)return[];switch(t){case"Read":{const s=Be(n,"file_path");return s?[xt(s,"read","read")]:[]}case"Glob":{const s=Be(n,"pattern");return s?[{key:`file:${s}`,kind:"file",label:s,fullTarget:s,verb:"read",entry:"globbed",pattern:!0}]:[]}case"Grep":{const s=Be(n,"pattern");if(!s)return[];const o=e.status==="error"?void 0:kg(e.result);return[{key:`grep:${s}`,kind:"command",label:`"${s}"`,fullTarget:s,verb:"search",entry:o===void 0?"searched":`searched (${js(o)})`,hits:o}]}case"Edit":case"MultiEdit":case"NotebookEdit":{const s=Be(n,"file_path")??Be(n,"notebook_path");if(!s)return[];const o=t==="MultiEdit"?pg(n):Xn(n);return[xt(s,"edit",`edited${hg(o)}`,o)]}case"Write":{const s=Be(n,"file_path");if(!s)return[];if(!/created/i.test(e.result??""))return[xt(s,"edit","wrote")];const a=Be(n,"content"),i=a===void 0?void 0:{additions:gg(a)};return[xt(s,"create",`created${i?` +${i.additions}`:""}`,i)]}case"Bash":{const s=Be(n,"command");if(!s)return[];const o=[{key:`run:${s}`,kind:"command",label:vg(s),fullTarget:s,verb:"run",entry:"ran"}];for(const a of Sg(s))o.push(xt(a,"delete","deleted",void 0,_g.test(a)));return o}case"WebFetch":{const s=Be(n,"url");return s?[{key:`url:${bg(s)}`,kind:"url",label:yg(s),fullTarget:s,verb:"fetch",entry:"fetched"}]:[]}case"WebSearch":{const s=Be(n,"query");return s?[{key:`websearch:${s}`,kind:"command",label:s,fullTarget:s,verb:"search",entry:"searched the web"}]:[]}default:return[]}}function Ng(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)&&xg(n.fullTarget,t.fullTarget))return n.key;return t.key}function Eg(e,t,n,s,o){const a=Ng(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=Pa(t.fullTarget)),i.verb==="read"&&t.verb==="edit"&&(i.upgraded=!0),Sr[t.verb]>Sr[i.verb]&&(i.verb=t.verb)}const jr=new WeakMap;function Dg(e){const t=jr.get(e);if(t&&t.input===e.input&&t.result===e.result&&t.status===e.status)return t.touches;const n=wg(e);return jr.set(e,{input:e.input,result:e.result,status:e.status,touches:n}),n}function Tg(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 Dg(n))Eg(t,i,s,o,a)}),[...t.values()]}const La={expanded:!1,verbFilter:null,order:"grouped"},Mn=nn(e=>({views:{},update:(t,n)=>e(s=>({views:{...s.views,[t]:{...s.views[t]??La,...n}}}))}));function Ag(e,t){const n=t.find(s=>s.type==="tool_call");return`${e}:${(n==null?void 0:n.toolCallId)??""}`}function Fg(e){const t=Mn(l=>l.views[e]),n=Mn(l=>l.update),s=t??La,o=c.useCallback(()=>{var l;return n(e,{expanded:!((l=Mn.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 _r=4,mt=[.4,0,.2,1],Rg={type:"spring",stiffness:320,damping:28},Mg={duration:.25,ease:mt},Og={x:-16,scale:.45,opacity:0},en={duration:.15,ease:mt},wr={duration:.3,ease:mt},Nr={duration:.15,ease:mt},Ig={duration:.3,ease:mt},$g={stiffness:220,damping:30},Pg={rotate:[0,-4,3,0],scale:[1,1.08,1,1]},Lg={duration:.3,ease:mt};function Bg(e,t){return e?t?{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:en},transition:en}:{initial:{opacity:0,y:7},animate:{opacity:1,y:0},exit:{...Og,transition:Mg},transition:Rg}:{}}const fn={read:"📖",search:"🔍",edit:"✏️",create:"✚",delete:"🗑",fetch:"🌐",run:"▮"},mn={read:"Read",search:"Searched",edit:"Edited",create:"Created",delete:"Deleted",fetch:"Fetched",run:"Ran"},Ba=["read","search","edit","create","delete","fetch","run"];function za(e){return Ba.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 zg=["z-30","-ml-2 z-20 opacity-70","-ml-2 z-10 opacity-45"];function qg({chips:e,expanded:t,controls:n,onExpand:s}){const o=Oe()??!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:U("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(H.span,{animate:o?{rotate:0,scale:1}:Pg,transition:Lg,className:"flex origin-bottom items-center",children:a.map((i,l)=>r.jsx("span",{"aria-hidden":"true",className:U("bg-card border-border text-3xs flex size-5 items-center justify-center rounded-full border leading-none",zg[l]),children:fn[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 Er({value:e,live:t}){const n=Oe()??!1,s=Rd(e,$g),o=Ko(s,a=>Math.round(a));return c.useEffect(()=>{s.set(e)},[s,e]),!t||n?r.jsx(r.Fragment,{children:e}):r.jsx(H.span,{children:o})}function Ug(e){return e.kind!=="command"&&e.pattern!==!0}function Wg(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 Hg(e){const t=e.pattern===!0&&e.verb==="read"?"Globbed":mn[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(js(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 Dr="bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-3xs leading-[1.4] tabular-nums";function qa({chip:e,onOpen:t,animated:n=!1,pulseUpgrade:s=!1,onUpgradeSeen:o}){const a=Oe()??!1,i=s&&!a,l=Ug(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(H.button,{...Bg(n,a),type:"button","data-testid":"touch-chip","data-verb":e.verb,"data-live":e.live,"data-arriving":f?"true":void 0,title:Wg(e),"aria-label":Hg(e),onClick:()=>t(e),className:U("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(me,{initial:!1,mode:"wait",children:r.jsx(H.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:Nr,children:fn[e.verb]},e.verb)})}),i&&r.jsx(H.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:Ig,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:Dr,children:["×",e.touches]}),e.hits!==void 0&&r.jsx("span",{className:Dr,children:js(e.hits)}),d&&r.jsxs(H.span,{className:"shrink-0 tabular-nums",initial:i?{opacity:0,x:-4}:!1,animate:{opacity:1,x:0},transition:Nr,children:[e.additions!==void 0&&r.jsxs("span",{className:"text-status-success-fg",children:["+",r.jsx(Er,{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(Er,{value:e.deletions,live:e.live})]})]})]})}const Tr=new Map(Ba.map((e,t)=>[e,t]));function Gg(e,t){const n=[...e];return t==="chronological"?n.sort((s,o)=>s.lastSeq-o.lastSeq):n.sort((s,o)=>(Tr.get(s.verb)??0)-(Tr.get(o.verb)??0)||s.firstSeq-o.firstSeq)}function Vg({id:e,chips:t,onOpen:n,verbFilter:s,onVerbFilterChange:o,order:a,onOrderChange:i}){const l=c.useMemo(()=>za(t),[t]),u=c.useMemo(()=>{const d=s?t.filter(f=>f.verb===s):t;return Gg(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(fe,{variant:"outline",size:"xs","aria-pressed":f,"data-testid":`chip-filter-${d.verb}`,onClick:()=>o(f?null:d.verb),className:U("rounded-full",f?"border-primary dark:border-primary text-foreground":"text-muted-foreground"),children:[r.jsx("span",{"aria-hidden":"true",children:fn[d.verb]}),r.jsx("span",{className:"sr-only",children:mn[d.verb]}),r.jsx("span",{className:"tabular-nums",children:d.chips.length})]},d.verb)})}),r.jsxs(Pl,{value:a,onValueChange:d=>i(d),"aria-label":"Order the roster",className:"w-auto",children:[r.jsx(Hs,{value:"grouped",children:"Grouped"}),r.jsx(Hs,{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(qa,{chip:d,onOpen:n},d.key))})]})}const Kg=new Set;function Qg(){const[e,t]=c.useState(Kg),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 Xg(e){const t=[...e].sort((n,s)=>n.lastSeq-s.lastSeq);return{visible:t.slice(-_r),absorbed:t.slice(0,Math.max(0,t.length-_r))}}function Yg(e){return e.map(t=>{const n=[`${t.chips.length} ${mn[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 Jg({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:fn[e]}),r.jsx("span",{className:"sr-only",children:mn[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 Zg({parts:e,sessionId:t,turnActive:n=!1}){const s=Oe()??!1,o=c.useMemo(()=>Tg(e),[e]),a=Qg(),i=c.useId(),l=Fg(c.useMemo(()=>Ag(t,e),[t,e])),u=c.useCallback(h=>{if(h.pattern===!0)return;const x=le.getState();if(h.kind==="url"){const C={type:"url",url:h.fullTarget};x.openCanvasDocument(C),qn(x,"user",C);return}if(h.kind==="file"){const C={type:"file",sourcePath:h.fullTarget};x.openCanvasDocument(C),qn(x,"user",C)}},[]),d=c.useMemo(()=>za(o),[o]),f=n||o.some(h=>h.live),{visible:g,absorbed:m}=c.useMemo(()=>Xg(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(me,{initial:!1,mode:"wait",children:f?r.jsxs(H.div,{"data-testid":"chip-live-row",role:"group","aria-label":"Latest activity",exit:s?{opacity:0}:{opacity:0,height:0},transition:s?en:wr,className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:[m.length>0&&r.jsx(qg,{chips:m,expanded:l.expanded,controls:i,onExpand:l.toggleExpanded}),r.jsx(me,{initial:!1,children:g.map(h=>r.jsx(qa,{chip:h,onOpen:u,animated:!0,pulseUpgrade:a.shouldPulse(h.key,h.upgraded),onUpgradeSeen:a.acknowledge},h.key))})]},"live"):r.jsxs(H.div,{"data-testid":"chip-summary-line",role:"group","aria-label":Yg(d),initial:{opacity:0},animate:{opacity:1},transition:s?en:wr,className:"text-muted-foreground flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs",children:[d.map((h,x)=>r.jsxs(c.Fragment,{children:[x>0&&r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx(Jg,{verb:h.verb,count:h.chips.length,additions:h.additions,deletions:h.deletions})]},h.verb)),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("button",{type:"button","aria-expanded":l.expanded,"aria-controls":i,onClick:l.toggleExpanded,className:U("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(Vg,{id:i,chips:o,onOpen:u,verbFilter:l.verbFilter,onVerbFilterChange:l.setVerbFilter,order:l.order,onOrderChange:l.setOrder})]})}function Ar(e){return e.type==="thinking"?!0:e.type==="tool_call"&&!e.interactiveType&&!bs(e.toolName)&&!Xt(e.toolName)}function _s({message:e,show:t="all"}){const{sessionId:n,isStreaming:s,isLatestWidgetMessage:o,isFinalMessage:a,activeToolCallId:i,onToolRef:l,focusedOptionIndex:u,onToolDecided:d,onRetry:f,onSigninComplete:g,onChooseModel:m,inputZoneToolCallId:h,textEffect:x,runtimeLabel:C,allowsDenyReason:b}=$p(),y=le(S=>S.expandToolCalls),v=le(S=>S.autoHideToolCalls)&&t!=="work",k=e.parts,p=c.useMemo(()=>{const S=k??[];return t==="all"?S:S.filter(E=>Ss(E)===(t==="work"))},[k,t]),{sent:j}=ja(n),_=c.useCallback(S=>{l==null||l(S)},[l]),N=c.useCallback(S=>{l==null||l(S)},[l]),R=Vh(p.map(S=>S.type==="tool_call"&&Xt(S.toolName)?{...S,interactiveType:void 0}:S));let w=-1;for(let S=p.length-1;S>=0;S--)if(p[S].type==="text"){w=S;break}function A(S,E){if(S.type==="text")return r.jsx("div",{className:"msg-prose",children:r.jsx(ks,{content:S.text,isStreaming:s&&E===w,textEffect:x,sessionId:n,isLatestWidgetMessage:o})},`text-${E}`);if(S.type==="background_task")return r.jsx(Jp,{part:S},S.taskId);if(S.type==="error"&&S.code===wo)return r.jsx(Yh,{message:S.message},`unreadable-${E}`);if(S.type==="error")return r.jsx(dn,{message:S.message,category:S.category,details:S.details,code:S.code,reason:S.reason,at:e.timestamp,onRetry:a&&S.category!==void 0?f:void 0,onSigninComplete:g,onChooseModel:m,runtimeLabel:C,sessionId:n},`error-${E}`);if(S.type==="thinking")return r.jsx(ig,{part:S,autoHide:v,index:E},`thinking-${E}`);if(S.type==="elicitation")return r.jsx(lf,{sessionId:n,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(zp,{mode:S.mode,memories:S.memories,isStreaming:S.isStreaming??!1},`memory-recall-${E}`);if(S.type==="permission_denied")return r.jsx(Uh,{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(tg,{fromName:S.fromName,toName:S.toName},`model-substituted-${E}`);if(S.type==="compact_boundary")return r.jsx(Gp,{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(Jh,{title:Ll(S.approval)},`capability-approval-${S.approval.approvalId}`):r.jsx(Bl,{approval:S.approval},`capability-approval-${S.approval.approvalId}`);if(S.type==="mcp_signin")return r.jsx(eg,{part:S},`mcp-signin-${S.agentId}-${S.flowId}`);if(S.type==="image")return r.jsx(Vp,{part:S},`image-${S.attachmentId}-${E}`);if(S.type!=="tool_call")return null;const T=S;if(T.interactiveType==="approval"&&T.status==="pending"){if(T.toolCallId===h)return r.jsx(cr,{type:"approval",toolName:T.toolName,toolInput:T.input},T.toolCallId);const I=T.toolCallId===i;return r.jsx(No,{ref:I?_:void 0,sessionId:n,toolCallId:T.toolCallId,toolName:T.toolName,input:T.input||"",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,isActive:I,onDecided:d?()=>d(T.toolCallId):void 0,allowsDenyReason:b},T.toolCallId)}const M=R.get(E);if(M){if(M.leadIndex!==E)return null;const I=M.indices.map(L=>p[L]).filter(L=>L.type==="tool_call");return r.jsx(gf,{outcome:M.outcome,reasonGiven:M.reasonGiven,members:I,lead:T,children:I.map(L=>r.jsx(Rn,{part:L,sessionId:n,autoHide:v,expandToolCalls:y},L.toolCallId))},`approval-receipt-${T.toolCallId}`)}if(T.interactiveType==="question"){if(T.toolCallId===h)return r.jsx(cr,{type:"question",toolName:T.toolName,toolInput:T.input},T.toolCallId);const I=T.toolCallId===i;return r.jsx(Eo,{ref:I?N:void 0,sessionId:n,toolCallId:T.toolCallId,questions:T.questions??[],answers:T.answers??(Qh(T)?{}:void 0),outcome:Xh(T),result:T.result,isActive:I,focusedOptionIndex:I?u:-1,onDecided:d?L=>d(T.toolCallId,L):void 0},T.toolCallId)}return Xt(T.toolName)?r.jsx(Ep,{part:T,sent:j,...e.timestamp?{at:e.timestamp}:{},...n?{sessionId:n}:{}},T.toolCallId):bs(T.toolName)?r.jsx(yf,{sessionId:n,input:T.input,result:T.result,fallback:r.jsx(Rn,{part:T,sessionId:n,autoHide:v,expandToolCalls:y})},T.toolCallId):r.jsx(Rn,{part:T,sessionId:n,autoHide:v,expandToolCalls:y},T.toolCallId)}const F=[];let D=[];for(let S=0;S<p.length;S++){const E=p[S];Ar(E)?D.push(S):(D.length>0&&(F.push(D.length===1?{type:"single",index:D[0]}:{type:"run",indices:[...D]}),D=[]),F.push({type:"single",index:S}))}return D.length>0&&F.push(D.length===1?{type:"single",index:D[0]}:{type:"run",indices:[...D]}),r.jsxs(r.Fragment,{children:[F.map(S=>{if(S.type==="single"){const T=p[S.index];return Ar(T)?r.jsx("div",{className:"my-3",children:A(T,S.index)},`spacer-${S.index}`):A(T,S.index)}const E=S.indices.map(T=>A(p[T],T));return r.jsx("div",{className:"my-3",children:t==="work"?E:r.jsx(cg,{children:E})},`run-${S.indices[0]}`)}),t==="all"&&r.jsx(Zg,{parts:p,sessionId:n,turnActive:e._streaming===!0})]})}const ex=/^Please read the following uploaded file\(s\):\n((?:- .+\n)+)\n?/,tx=/^[a-f0-9]{8}-/,nx=new Set(["png","jpg","jpeg","gif","webp","svg"]);function sx(e){const t=e.match(ex);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(tx,""),d=((f=u.split(".").pop())==null?void 0:f.toLowerCase())??"";return{path:i,displayName:u,isImage:nx.has(d)}}),o=e.slice(t[0].length).trim();return{files:s,textContent:o}}function rx(e){var n;switch(((n=e.split(".").pop())==null?void 0:n.toLowerCase())??""){case"txt":case"md":case"log":return hd;case"ts":case"tsx":case"js":case"jsx":case"json":case"py":case"rs":case"go":return md;case"csv":case"xls":case"xlsx":return Bd;case"png":case"jpg":case"jpeg":case"gif":case"webp":case"svg":return Ld;default:return Go}}function ox({files:e}){const t=le(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(H.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},children:r.jsx(xo,{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=rx(n.displayName);return r.jsxs(H.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 ax({message:e}){var i;const t=(i=Pp())==null?void 0:i.sessionId,[n,s]=c.useState(!1),o=c.useMemo(()=>sx(e.content),[e.content]),a=c.useMemo(()=>Ff(e.content),[e.content]);if(a)return r.jsx(Tf,{action:a});if(e.chatMessages&&e.chatMessages.length>0)return r.jsx(Cp,{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(Fa,{content:e.content,toolName:""});if(e.messageType==="compaction"){const l=Wp(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(ms,{className:U("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(ox,{files:o.files}),o.textContent&&r.jsx("div",{className:"break-words whitespace-pre-wrap",children:o.textContent})]})}function ix({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(ms,{className:"size-(--size-icon-xs) shrink-0"}):r.jsx(Tt,{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 lx({activeForm:e,isCollapsed:t}){return r.jsx(me,{children:e&&!t&&r.jsxs(H.div,{variants:Ke,initial:"initial",animate:"animate",exit:"exit",transition:Ve,className:"mb-1 flex items-center gap-2 text-xs text-blue-400",children:[r.jsx(He,{size:"xs",className:"shrink-0"}),r.jsx("span",{className:"truncate",children:e})]})})}const cx={in_progress:"",pending:"waiting ",completed:"done "};function Fr({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 ux({task:e,taskMap:t,statusSince:n,onScrollToTask:s}){var d,f;const o=Qo(n),a=cx[e.status]??"",i=((d=e.blockedBy)==null?void 0:d.map(g=>t.get(g)).filter(g=>g!=null))??[],l=((f=e.blocks)==null?void 0:f.map(g=>t.get(g)).filter(g=>g!=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(Fr,{tasks:i,onScrollToTask:s})]},"blocked-by")),l.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["→ ",r.jsx(Fr,{tasks:l,onScrollToTask:s})]},"blocks")),r.jsxs(H.div,{variants:Ke,initial:"initial",animate:"animate",exit:"exit",transition:Ve,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((g,m)=>r.jsxs("span",{className:"flex items-center gap-1",children:[m>0&&r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),g]},m))})]})}const Rr={in_progress:r.jsx(He,{size:"xs",className:"text-status-info shrink-0"}),pending:r.jsx(zl,{className:"text-muted-foreground size-(--size-icon-xs) shrink-0"}),completed:r.jsx(_o,{className:"text-status-success size-(--size-icon-xs) shrink-0"})};function dx({task:e,isBlocked:t,isExpanded:n,onToggleExpand:s,onHover:o,isHighlightedAsDep:a,isHighlightedAsDependent:i,taskMap:l,statusSince:u,isCelebrating:d,onCelebrationComplete:f,onScrollToTask:g}){const m=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),s())};return r.jsxs(H.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:U("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(H.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(H.span,{initial:{scale:1},animate:{scale:[1,1.4,1]},transition:{type:"spring",stiffness:400,damping:10},onAnimationComplete:()=>f==null?void 0:f(),children:Rr[e.status]}):Rr[e.status],r.jsx("span",{className:"truncate",children:e.subject})]}),r.jsx(me,{children:n&&r.jsx(ux,{task:e,taskMap:l,statusSince:u,onScrollToTask:g})})]})}function fx(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 mx=10,px="max-h-[30svh] sm:max-h-[40svh]";function hx({tasks:e,taskMap:t,activeForm:n,isCollapsed:s,onToggleCollapse:o,celebratingTaskId:a,onCelebrationComplete:i,statusTimestamps:l}){const[u,d]=c.useState(null),[f,g]=c.useState(null),m=c.useCallback(b=>{d(y=>y===b?null:b)},[]),h=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,mx),C=f?t.get(f):null;return r.jsxs("div",{className:"border-t px-4 py-2",children:[r.jsx(lx,{activeForm:n,isCollapsed:s}),r.jsx(ix,{tasks:e,isCollapsed:s,onToggleCollapse:o}),r.jsx(me,{children:!s&&r.jsx(H.ul,{variants:Ke,initial:"initial",animate:"animate",exit:"exit",transition:Ve,className:U("mt-1 space-y-0.5 overflow-y-auto",px),children:x.map(b=>{var _,N;const y=b.id===a&&b.status==="completed",v=fx(b,t),k=l.get(b.id),p=((_=C==null?void 0:C.blockedBy)==null?void 0:_.includes(b.id))??!1,j=((N=C==null?void 0:C.blocks)==null?void 0:N.includes(b.id))??!1;return r.jsx(dx,{task:b,isBlocked:v,isExpanded:u===b.id,onToggleExpand:()=>m(b.id),onHover:g,isHighlightedAsDep:p,isHighlightedAsDependent:j,taskMap:t,statusSince:(k==null?void 0:k.since)??null,isCelebrating:y,onCelebrationComplete:i,onScrollToTask:h},b.id)})})})]})}function gx({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 xx=350;function bx({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 yx({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"),xx);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(bx,{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(gx,{color:e.color}),s==="running"&&r.jsxs("div",{"data-testid":"agent-runner-tooltip",className:U("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 kx({bashTasks:e}){const t=Oe(),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(me,{mode:"popLayout",children:n.map(o=>r.jsxs(H.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 vx=3e3;function Cx({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)},vx),()=>{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:U("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(ct,{className:"size-3"})})}function Mr({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:U("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(Cx,{taskType:e.taskType,onConfirm:t})]})}function Sx({tasks:e,ambientTasks:t=[],onStopTask:n}){return r.jsx(H.div,{variants:Ke,initial:"initial",animate:"animate",exit:"exit",transition:Ve,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(Mr,{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(Mr,{task:s,onStop:()=>n(s.taskId)},s.taskId))]})]})})}const Yn=4;function jx(e){return e==="stopped"?"complete":e}const _x="relative after:absolute after:-inset-x-1 after:-inset-y-2.5 md:after:hidden",Ua=[.16,1,.3,1],wx={width:{duration:.4,ease:Ua},opacity:{duration:.25}};function Nx({tasks:e,onStopTask:t}){const[n,s]=c.useState(!1),o=Oe(),{shown:a,ambient:i}=ql(e),l=a.filter(b=>b.taskType==="agent"),u=a.filter(b=>b.taskType==="bash"),d=a.length,f=l.slice(0,Yn),g=l.length-Yn,m=l.reduce((b,y)=>b+(y.toolUses??0),0),h=Math.max(0,...a.map(b=>Math.round((b.durationMs??0)/1e3))),x=o?{duration:0}:{duration:.35,ease:Ua},C=d>0;return r.jsx(me,{children:(d>0||i.length>0)&&r.jsxs(H.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(Ex,{visibleAgents:f,overflowAgentCount:g,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(kx,{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 · "]}),h,"s"]})]}),r.jsxs("button",{type:"button",onClick:()=>s(b=>!b),className:U("text-muted-foreground hover:text-foreground flex shrink-0 items-center gap-1 transition-colors duration-150",d>0?"ml-1":"ml-auto",_x),"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(Tt,{className:U("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),r.jsx(me,{children:n&&r.jsx(Sx,{tasks:a,ambientTasks:i,onStopTask:t})})]},"background-task-bar")})}function Ex({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return r.jsxs("div",{className:"flex items-center gap-0",children:[r.jsx(me,{mode:"popLayout",children:e.map((s,o)=>r.jsx(H.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:wx,className:"shrink-0",children:r.jsx(yx,{agent:{taskId:s.taskId,description:s.description??"",status:jx(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(Dx,{count:t,overflowTasks:n.slice(Yn)})]})}function Dx({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:U("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 On="after:absolute after:-inset-1 md:after:hidden";function Tx({queue:e,editingId:t,onEdit:n,onRemove:s,onSend:o,onMoveUp:a,statusNote:i,onSwitchNow:l}){return e.length===0?null:r.jsxs(H.div,{variants:Ke,initial:"initial",animate:"animate",exit:"exit",transition:Ve,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(me,{mode:"popLayout",children:e.map((u,d)=>r.jsx(H.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:U("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(Wn,{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:U("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",On),"aria-label":`Move queued message ${d+1} earlier`,children:r.jsx(Ul,{className:"size-3"})}),d>0&&r.jsx("button",{type:"button",onClick:()=>o(u.id),"aria-label":`Send queued message ${d+1} next`,className:U("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm transition-colors",On),children:r.jsx(dd,{className:"size-3"})}),r.jsx("button",{type:"button",onClick:()=>s(u.id),className:U("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",On),"aria-label":`Remove queued message ${d+1}`,children:r.jsx(ct,{className:"size-3"})})]})},u.id))})})]})}function Ax({open:e,onOpenChange:t,queuedCount:n,onConfirm:s}){const o=n===1?"message":"messages";return r.jsx(Wl,{open:e,onOpenChange:t,children:r.jsxs(Hl,{children:[r.jsxs(Gl,{children:[r.jsxs(Vl,{children:["Stop, and put ",n," queued ",o," back?"]}),r.jsxs(Kl,{children:["The agent stops. Your ",o," ",n===1?"goes":"go"," back to the composer."]})]}),r.jsxs(Ql,{children:[r.jsx(Xl,{children:"Keep going"}),r.jsx(Yl,{onClick:s,children:"Stop"})]})]})})}const Fx={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},Rx={duration:.3,ease:"easeInOut"};function Mx({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(me,{mode:"wait",children:r.jsx(H.span,{variants:Fx,initial:"initial",animate:"animate",exit:"exit",transition:Rx,className:"text-muted-foreground truncate text-sm",children:e},t)})})}function Ox(e){const t=ve();return Je({queryKey:["workspace-for-session",e??null],queryFn:()=>t.resolveWorkspace(e),enabled:!!e}).data??null}async function Wa(e,t,n){try{return await e.runCommandIntent(t,"compact",n),!0}catch(s){const o=s.code==="SESSION_LOCKED";return Fe.error(o?"Your agent is busy. Try again in a moment.":"Couldn’t compact the chat."),!1}}const Jn=nn(e=>({open:!1,setOpen:t=>e({open:t}),reveal:()=>e({open:!0})})),Ix=200,Zn=[{name:"rename",description:"Rename the current chat",argHint:"<new title>",run:(e,t)=>{const n=e.replace(/\s+/g," ").trim().slice(0,Ix).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)}],$x=/^\/(\S+)(?:\s+([\s\S]*))?$/;function Ha(e){const t=$x.exec(e);if(!t)return null;const n=t[1],s=(t[2]??"").trim(),o=hs(n);if(o&&o.fulfillment==="client-native"){const i=Zn.find(l=>l.name===o.id);if(i)return{command:i,args:s}}const a=Zn.find(i=>i.name===n.toLowerCase());return a?{command:a,args:s}:null}const Or=Zn.map(e=>({command:e.name,fullCommand:`/${e.name}`,description:e.description,argumentHint:e.argHint}));function Ga(e){const t=/^\/(\S+)([\s\S]*)$/.exec(e.trim());return t?{token:t[1],rest:t[2].trim()}:null}function Px(e){const t=Ga(e);return t?hs(t.token)?!0:Ha(e.trim())!==null:!1}function Lx(e,t,n={}){const{mutateAsync:s}=Jl(e),o=ve(),{startFreshSession:a,compact:i}=n,[l,u]=c.useState(0),d=c.useCallback(g=>{u(h=>h+1);const m=()=>u(h=>Math.max(0,h-1));g.then(m,m)},[]);return{tryRun:c.useCallback(g=>{const m=Ga(g),h=m?hs(m.token):null;if(m&&(h==null?void 0:h.fulfillment)==="runtime"&&i){if(!i.supported)return Fe.error(`Compact isn’t available on ${i.runtimeLabel||"this agent"}`),{handled:!0,ran:!1};if(!t)return Fe.error("No open chat to compact"),{handled:!0,ran:!1};const y=Wa(o,t,m.rest||void 0);return d(y),{handled:!0,ran:!0,confirmed:y}}const x=Ha(g);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(()=>(Fe.success(`Renamed chat to “${y}”`),!0),()=>!1),d(C))},notify:(y,v)=>v==="error"?Fe.error(y):Fe.success(y),startFreshSession:y=>a==null?void 0:a(y),focusUsageSurface:()=>Jn.getState().reveal()}),...C?{confirmed:C}:{}}},[s,o,t,a,i,d]),commandPending:l>0}}function Va(e,t){return{supported:(e==null?void 0:e.compact.supported)!==!1,runtimeLabel:t}}function Ir(e){const t=e.trim().toLowerCase();return t.startsWith("/")?t:`/${t}`}function Bx(e){return ec.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 zx(e,t){const n=Zl(),s=Bx(t),o=Or.filter(l=>!(l.command!==void 0&&n.has(`/${l.command}`))),a=new Set(Or.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(Ir);return l.command!==void 0&&u.push(Ir(l.command)),!u.some(d=>n.has(d))});return[...s,...o,...i]}const qx=3e4;function Ux({percent:e,compactSupported:t,isStreaming:n}){return!(e===null||e<tc||!t||n)}function Wx({sessionId:e,percent:t,compactSupported:n,isStreaming:s}){const o=ve(),[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)},qx),Wa(o,e).then(g=>{g||d()}))},[e,o,d]);return{visible:Ux({percent:t,compactSupported:n,isStreaming:s}),percent:t??0,pending:a,onCompact:f}}function Hx({children:e,onSwitchAgent:t,onViewProfile:n,onNewSession:s}){return r.jsxs(nc,{children:[r.jsx(sc,{className:"min-w-0",children:e}),r.jsxs(rc,{className:"w-48",children:[r.jsxs(bn,{onClick:t,children:[r.jsx(oc,{className:"mr-2 size-4"}),"Switch agent"]}),r.jsx(Gs,{}),r.jsxs(bn,{onClick:n,children:[r.jsx(ac,{className:"mr-2 size-4"}),"View profile"]}),r.jsx(Gs,{}),r.jsxs(bn,{onClick:s,children:[r.jsx(bo,{className:"mr-2 size-4"}),"New chat"]})]})]})}function Gx({agentName:e,agentColor:t,agentEmoji:n,agentPath:s,nameHidden:o}){const a=ic(s),{open:i}=lc(),l=c.useCallback(()=>{s&&cc.getState().openProfileDocked(s)},[s]),u=c.useCallback(()=>{if(a===void 0)return l();i(a)},[a,i,l]),d=c.useCallback(()=>{le.getState().openGlobalPaletteWithSearch("@")},[]),f=Co(),g=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(Hx,{onSwitchAgent:d,onViewProfile:u,onNewSession:g,children:r.jsx(Vs,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,onClick:u,className:"max-w-full"})}):r.jsx(Vs,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,className:"max-w-full"})})}function Vx({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(uc,{sessionId:e,account:t,open:n,onOpenChange:s,onContinue:()=>{s(!1),a(!0)}})}),r.jsx(ua,{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 Kx({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(Do,{fallback:null,onError:a=>Ka(n,a),children:r.jsx(o,{...e})})})]},n.id)})})}function Ka(e,t){console.warn(`[extensions] ${e.extensionId}'s status-bar item "${e.id}" failed to draw and is hidden.`,t)}function Qx({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(Do,{fallback:null,onError:o=>Ka(n,o),children:r.jsx(s,{...e})})})]},n.id)})})}function Xx(e){const{costUsd:t,costBasis:n,...s}=e;return s}function Yx(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(Gx,{agentName:n.name,agentColor:n.color,agentEmoji:n.emoji,agentPath:n.path,nameHidden:e.density==="avatar"})),s.cwd&&(i.cwd=r.jsx(ku,{cwd:s.cwd})),e.gitStatus&&(i.git=r.jsx(Du,{data:e.gitStatus,workspace:e.workspace,compact:l})),o.runtime!==null&&(i.runtime=r.jsx(vu,{runtime:o.runtime,model:o.model,onChangeRuntime:o.onChangeRuntime,canSelect:o.canSelect,account:o.account,compact:!0,iconOnly:Uo(e.density)}));const u=To(e.account);u!==null&&(i.account=r.jsx(Vx,{sessionId:t,account:e.account})),e.extensions.items.length>0&&(i.extensions=r.jsx(Kx,{ctx:e.extensions.ctx,items:e.extensions.items})),i.model=r.jsx(Cu,{model:s.model,onChangeModel:g=>a({model:g}),effort:s.effort,onChangeEffort:g=>a({effort:g??void 0}),fastMode:s.fastMode,onChangeFastMode:g=>a({fastMode:g}),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(Su,{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(ju,{descriptor:e.plan.descriptor,active:e.plan.active,onToggle:e.plan.onToggle,disabled:!t})),e.contextPercent!==null&&(i.context=r.jsx(_u,{percent:e.contextPercent,contextUsage:e.contextUsage,compact:e.compact,reading:e.contextReading}));const d=e.usage&&e.usageSource==="account"&&!e.supportsCostTracking?Xx(e.usage):e.usage;return d&&dc(d)&&(e.supportsCostTracking||e.usageSource==="account")&&!wu({account:u})&&(i.usage=r.jsx(fc,{usage:d,observedAt:e.usageObservedAt,now:e.now})),e.liveSubagentCount>0&&(i.subagents=r.jsx(Nu,{count:e.liveSubagentCount,running:e.runningSubagents,waiting:e.waitingOnSubagents})),i.connection=r.jsx(Eu,{connectionState:e.connectionState,compact:l}),i}function Jx({compaction:e}){return r.jsxs("div",{"data-testid":"dm-safety-line",className:"text-muted-foreground flex items-center gap-2 pt-2 text-xs empty:hidden empty:p-0",children:[r.jsx(Wo,{compact:!1}),e.visible&&r.jsxs("span",{className:"flex items-center gap-1.5","data-testid":"dm-compact-warning",children:[r.jsxs("span",{className:"text-status-warning-fg",children:["Context ",e.percent,"% full"]}),r.jsx("button",{type:"button",onClick:e.onCompact,disabled:e.pending,className:"focus-ring text-foreground/80 hover:text-foreground rounded-sm underline-offset-4 hover:underline disabled:opacity-50",children:e.pending?"Compacting…":"Compact chat"})]})]})}const Zx=[],e0="(max-width: 639px)";function t0({sessionId:e,sessionStatus:t,isStreaming:n,syncConnectionState:s,agentName:o,agentColor:a,agentEmoji:i,agentPath:l,lineHidden:u=!1}){var ee,G;const{ref:d,budget:f}=Tu(),g=mc(),m=Ao(e),h=Fo(e,t,n,m.runtime),x=Et(e||null),{pins:C}=Au(),b=Ro(e),y=Fu(e,x,b.usage),v=y.usage,k=wt(),p=new Date(k),j=pc(v,y.observedAt,p),_=b.contextUsage,N=((ee=gs(e))==null?void 0:ee.contextUsage)??null,R=Jn(K=>K.open),w=Jn(K=>K.setOpen),{data:A}=hc(h.cwd),F=Ox(h.cwd),{project:D}=gc(h.cwd),S=xc(e0),E=c.useMemo(()=>({sessionId:e,cwd:h.cwd,project:D,trackerItems:x.trackerItems,compact:S}),[e,h.cwd,D,x.trackerItems,S]),T=Ru(E),{data:M}=ds(),I=bc(b.activeSubagents).running,L=b.runningSubagentCount??I.length,{data:z}=sn({sessionId:e||void 0,runtime:m.runtime??void 0}),Q=((G=z==null?void 0:z.find(K=>K.value===h.model))==null?void 0:G.supportsAutoMode)??!1,X=an(m.runtime),B=(X==null?void 0:X.permissionModes.values)??Zx,P=X==null?void 0:X.permissionModes.default,Y=yc(e),O=ae(K=>K.recordAutoConfirmed),[W,ne]=c.useState(!1),$=Mu({sessionId:e,runtime:m.runtime,declaredModes:B,runtimeDefaultMode:P}),[Z,ce]=c.useState(!1),oe=c.useCallback(K=>h.updateSession({permissionMode:K}),[h]),se=c.useCallback(K=>{if(K==="auto"&&!Y){ne(!0);return}oe(K).then(ie=>{ie&&$.offerFor(K)})},[Y,oe,$,ne]),V=c.useCallback(()=>{O(e),oe("auto"),ne(!1)},[O,e,oe,ne]),re=kc(B),Se=re!==void 0&&h.permissionMode===re.id,ke=vc(e),J=ae(K=>K.recordModeBeforePlan),je=c.useCallback(K=>{if(!re)return;if(K){J(e,h.permissionMode),oe(re.id);return}const ie=ke,Me=ie!==void 0&&B.some(he=>he.id===ie)&&(ie!=="auto"||Q)?ie:P;Me&&oe(Me)},[re,J,e,h,oe,ke,B,Q,P]),Ce=m.runtime?At(m.runtime).label:"",qe=Va(X==null?void 0:X.commandIntents,Ce),ye=b.contextPercent,pe=Wx({sessionId:e,percent:ye,compactSupported:qe.supported,isStreaming:n}),[Re,ue]=c.useState(!1);Ou(()=>!u&&ue(K=>!K));const _e={cwd:h.cwd,git:Cc(A)?Iu(A.branch,A.clean,A.detached):null,contextPercent:ye,connectionState:s,permissionMode:h.permissionMode,permissionDescriptor:(X==null?void 0:X.permissionModes.values.find(K=>K.id===h.permissionMode))??null,permissionPickerOpen:Z,onWifi:g,plan:re?{active:Se}:null,runtime:m.runtime===null||M===void 0?null:{type:m.runtime,isDefault:m.runtime===M.defaultRuntime,canSelect:m.canSelect},account:To(x),usage:v,usageStale:j,subagentsInFlight:L,extensionItems:T.promotion},be=pe.visible&&f.density==="full",we=pe.visible&&!be,ge=Yx({sessionId:e,agent:{name:o,color:a,emoji:i,path:l},status:h,onUpdateSession:h.updateSession,onChangeMode:se,makeDefault:Z?$.line:null,onPermissionPickerOpenChange:ce,modelSupportsAutoMode:Q,plan:re?{descriptor:re,active:Se,onToggle:je}:null,gitStatus:A,workspace:F,runtimeChip:m,account:x,contextPercent:ye,contextUsage:_,contextReading:N,compact:be?{pending:pe.pending,onCompact:pe.onCompact}:null,usage:v,usageSource:y.source,usageObservedAt:y.observedAt,now:p,supportsCostTracking:(X==null?void 0:X.supportsCostTracking)??!0,runningSubagents:I,liveSubagentCount:L,waitingOnSubagents:b.lifecycle==="idle",connectionState:s,density:f.density,extensions:{ctx:E,items:T.visible}}),{items:Ie,overflow:Ue}=$u(Pu({ctx:_e,pins:C,nodes:ge,density:f.density}),f);return r.jsxs("div",{ref:d,className:u?"relative":"relative pt-2",children:[!u&&!Z&&$.line&&r.jsx(Lu,{...$.line,placement:"overlay"}),u&&r.jsx(Jx,{compaction:pe}),!u&&r.jsx(Bu,{items:Ie,nameFirst:Uo(f.density),trailing:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Wo,{compact:f.density!=="full"}),r.jsx(zu,{open:Re,onOpenChange:ue,diagnostics:b,controls:{plan:re?{active:Se,onToggle:je}:null},promotionContext:_e,overflowCount:Ue,addOns:T.visible.length>0?r.jsx(Qx,{ctx:E,items:T.visible}):void 0,urgentAction:we?{label:`Compact chat · ${pe.percent}% full`,onAction:pe.onCompact,pending:pe.pending}:null})]})}),r.jsx(qu,{usage:v??null,accountUsage:y.accountUsage,observedAt:y.observedAt,open:R,onOpenChange:w}),r.jsx(Uu,{open:W,onOpenChange:ne,onConfirm:V})]})}const n0=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 s0(e){return e!==void 0&&e!=="completed"}function r0(e){const t=n0[e];return t!==void 0?t:o0(e)}function o0(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 a0({terminalReason:e}){const t=s0(e),n=t?r0(e):"";return r.jsx(me,{children:t&&r.jsx(H.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(Sc,{variant:"secondary","aria-label":`Chat ended: ${n}`,children:n})},e)})}const i0="The turn ended before completing.";function l0({sessionId:e,onRetry:t,onSigninComplete:n,onChooseModel:s}){var m;const o=cn(e),a=((m=gs(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?`${At(o).label} stopped unexpectedly`:void 0,u=(a==null?void 0:a.message)??i0,d=i?void 0:u,f=o?fs(o):void 0,g=a?[a.code,a.details].filter(Boolean).join(`
|
|
51
|
-
`):void 0;return r.jsx(H.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(dn,{category:(a==null?void 0:a.category)??"execution_error",heading:l,message:u,subtext:d,details:g||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 c0=["Type @ to mention a file","Type / to browse commands","End a line with \\ to keep typing","Drop or paste files to attach"];function u0(e,t,n){const s=c.useCallback(x=>{var v;if(!e||!t.current)return;const C=ae.getState(),b=(v=n.current)==null?void 0:v.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&&ae.getState().updateSession(e,{input:x})},[e]),a=c.useCallback(x=>{e&&ae.getState().updateSession(e,{status:x})},[e]),i=c.useCallback(x=>{e&&ae.getState().updateSession(e,{error:x})},[e]),l=c.useCallback(x=>{e&&ae.getState().updateSession(e,{sessionStatus:x})},[e]),u=c.useCallback(x=>{e&&ae.getState().updateSession(e,{estimatedTokens:x})},[e]),d=c.useCallback(x=>{e&&ae.getState().updateSession(e,{streamStartTime:x})},[e]),f=c.useCallback(x=>{e&&ae.getState().updateSession(e,{isTextStreaming:x})},[e]),g=c.useCallback(x=>{e&&ae.getState().updateSession(e,{systemStatus:x})},[e]),m=c.useCallback(x=>{e&&ae.getState().updateSession(e,{operationProgress:x})},[e]),h=c.useCallback(x=>{e&&ae.getState().updateSession(e,{promptSuggestions:x})},[e]);return{setMessages:s,setInput:o,setStatus:a,setError:i,setSessionStatus:l,setEstimatedTokens:u,setStreamStartTime:d,setIsTextStreaming:f,setSystemStatus:g,setOperationProgress:m,setPromptSuggestions:h}}function d0({sessionId:e,sid:t,transport:n,sessionCwd:s,enableMessagePolling:o,isStreaming:a,streamHydrated:i,setMessages:l}){const u=Xo(),d=s.cwd,f=c.useRef(d);c.useEffect(()=>{f.current=d},[d]);const g=c.useRef(i);c.useEffect(()=>{g.current=i},[i]);const m=Je({queryKey:["messages",e,d],queryFn:()=>n.getMessages(e,d??void 0,{newest:!0}),staleTime:Xe.MESSAGE_STALE_TIME_MS,refetchOnWindowFocus:!1,enabled:e!==null&&!i,refetchInterval:()=>a||!o?!1:u?Xe.ACTIVE_TAB_REFETCH_MS:Xe.BACKGROUND_TAB_REFETCH_MS});return c.useEffect(()=>{const h=ae.getState();t&&h.updateSession(t,{historySeeded:!1}),h.getSession(e??"").status!=="streaming"&&l([])},[e,d,t,l]),c.useEffect(()=>{if(!m.data)return;const h=m.data.messages,x=ae.getState().getSession(t).historySeeded;if(!x&&h.length>0){if(a)return;if(t&&ae.getState().updateSession(t,{historySeeded:!0}),e&&!g.current){const C=m.data.earlierMessages??0;We.getState().noteSnapshot(e,h[0].id,C)}l(h.map(it));return}x&&!a&&Rp(ae.getState().getSession(t).messages,h,l)},[m.data,a,e,t,l]),{historyQuery:m}}function Qa(e,t){if(e===t)return;const{opened:n,counts:s,mergeUsage:o}=lt.getState(),a=Ks("session",e),i=Date.parse(n[a]??"");Number.isNaN(i)||o([{key:Ks("session",t),lastUsedAt:i,useCount:s[a]??1}])}function es(e,t,n){e&&n.then(s=>{if(!s)return;const o=ae.getState();o.getSession(e).input.trim()===t.trim()&&o.updateSession(e,{input:""})},()=>{})}const Bt=new Map;function f0(e,t){const s=(Bt.get(e)??Promise.resolve()).then(t),o=s.then(()=>{},()=>{});return Bt.set(e,o),o.then(()=>{Bt.get(e)===o&&Bt.delete(e)}),s}const st=new Set;function $r(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 m0({sessionId:e,input:t,status:n,transport:s,queryClient:o,selectedCwd:a,onSessionIdChangeReplace:i,transformContent:l,launchRuntime:u,agentPath:d,agentLookupPending:f,agentLookupFailed:g,launchAccount:m,takeSeedContext:h,setInput:x,setError:C,tryNativeCommand:b}){const y=c.useRef(a);c.useEffect(()=>{y.current=a},[a]);const v=c.useRef(u);c.useEffect(()=>{v.current=u},[u]);const k=c.useRef(m);c.useEffect(()=>{k.current=m},[m]);const{data:p}=ds(),j=c.useRef(p==null?void 0:p.defaultRuntime);c.useEffect(()=>{j.current=p==null?void 0:p.defaultRuntime},[p==null?void 0:p.defaultRuntime]);const _=jc(e,u),N=c.useRef(_.mode);c.useEffect(()=>{N.current=_.mode},[_.mode]);const R=c.useRef(l);c.useEffect(()=>{R.current=l});const w=c.useRef(h);c.useEffect(()=>{w.current=h});const A=c.useRef(i);c.useEffect(()=>{A.current=i});const F=c.useCallback(async(B,P,Y={})=>{var re,Se,ke;if(!Y.kickoff){const J=b(B);if(J.handled){P&&J.ran&&(J.confirmed?es(e,B,J.confirmed):x(""));return}}const O=e,W=Y.cwd??y.current;C(null);const ne=o.getQueryData(Qe.list(W))??[],$=yn(O),Z=($==null?void 0:$.draft)??!ne.some(J=>J.id===O),ce=($==null?void 0:$.draft)===!1?!1:Z||st.has(O);if(ce&&(f||g))return;ce&&st.add(O),Y.kickoff||(lt.getState().recordOpened("session",O),W&<.getState().recordOpened("agent",W)),yt.attachSession(O,W);let oe;try{oe=!Y.kickoff&&R.current?await R.current(B):B}catch(J){if(Y.kickoff)throw J;C({heading:"Couldn’t send message",message:J.message||"The attachment didn’t upload. Try again.",retryable:!1});return}const se=De.getState();if(Z){const J=new Date().toISOString();Qs(o,W,{id:O,title:`Chat ${O.slice(0,8)}`,createdAt:J,updatedAt:J,permissionMode:((re=o.getQueryData(Qe.detail(O,W)))==null?void 0:re.permissionMode)??N.current??"default",runtime:v.current??j.current??"claude-code"})}const V=crypto.randomUUID();Y.kickoff||se.setOptimisticUserMessage(O,{id:V,content:B}),se.setTriggerPending(O,!0),P&&x("");try{const J=Xs(le.getState(),W??null),{uiState:je,commit:Ce}=Ys(O,J),ye={clientMessageId:V,context:je?{uiState:je}:void 0};ce&&(ye.create=!0),ce&&v.current&&(ye.runtime=v.current),ce&&d&&(ye.agentPath=d),ce&&k.current&&(ye.account=k.current);const pe=le.getState().retryAccount;(pe==null?void 0:pe.sessionId)===O&&(ye.account=pe.id,le.getState().setRetryAccount(null));const Re=(Se=w.current)==null?void 0:Se.call(w);Re&&(ye.seedContext=Re);const{sessionId:ue}=await s.postMessage(O,oe,W??void 0,ye);if(st.delete(O),$){const be={...$,draft:!1};kn(O,be),kn(ue,be)}if(Ce(ue),ue!==O){De.getState().migrateSessionContinuity(O,ue),le.getState().carryCanvasWritesAcross(O,ue),yt.attachSession(ue,W),Qa(O,ue),rt.getState().migrate(O,ue);const be=o.getQueryData(Qe.list(W))??[],we=be.find(ge=>ge.id===O);we&&!be.some(ge=>ge.id===ue)&&Qs(o,W,{...we,id:ue}),o.setQueryData(Qe.list(W),ge=>ge==null?void 0:ge.filter(Ie=>Ie.id!==O))}(ke=A.current)==null||ke.call(A,ue);const _e=ue;setTimeout(()=>{var ge;const be=kt.getState().rekeys[_e]??_e,we=De.getState().getSession(be);we.triggerPending&&((ge=we.status)==null?void 0:ge.lifecycle)!=="streaming"&&De.getState().setTriggerPending(be,!1)},on.TRIGGER_PENDING_TIMEOUT_MS)}catch(J){if(De.getState().setOptimisticUserMessage(O,null),De.getState().setTriggerPending(O,!1),Y.kickoff)throw J;C({heading:"Couldn’t send message",message:J.message||"Couldn’t reach DorkOS. Try again.",retryable:!0,...$r(J)})}},[e,s,o,x,C,b,d,f,g]),D=c.useCallback(async(B,P)=>{!B.trim()||n==="streaming"||await F(B.trim(),(P==null?void 0:P.clearInput)===!0,{...P!=null&&P.cwd?{cwd:P.cwd}:{}})},[n,F]),S=c.useCallback(()=>D(t,{clearInput:!0}),[t,D]),E=c.useCallback(async(B,P,Y)=>{if(!e)return!1;const O=e,W=y.current;C(null);const ne=(o.getQueryData(Qe.list(W))??[]).some(Z=>Z.id===O),$=yn(O);return(($==null?void 0:$.draft)??!ne)&&st.add(O),f0(O,async()=>{var ce;let Z;try{Z=R.current?await R.current(B):B}catch(oe){return C({heading:Y,message:oe.message||"The attachment didn’t upload. Try again.",retryable:!1}),!1}try{const oe=Xs(le.getState(),W??null),{uiState:se,commit:V}=Ys(O,oe),re={...se?{uiState:se}:{},...P==="queue"?{queued:!0}:{}},Se=Object.keys(re).length>0?re:void 0,ke=((ce=yn(O))==null?void 0:ce.draft)===!1?!1:st.has(O);if(ke&&(f||g))return!1;const{sessionId:J}=await s.postMessage(O,Z,W??void 0,{context:Se,disposition:P,...ke?{create:!0,...v.current&&{runtime:v.current},...k.current&&{account:k.current},...d&&{agentPath:d}}:{}});return ke&&st.delete(O),$&&kn(J,{...$,draft:!1}),V(J),!0}catch(oe){return C({heading:Y,message:oe.message||"Couldn’t reach DorkOS. Try again.",retryable:!1,...$r(oe)}),!1}})},[e,s,o,C,d,f,g]),T=c.useCallback(B=>E(B,"queue","Couldn’t queue message"),[E]),M=c.useCallback(B=>E(B,"steer","Couldn’t steer the agent"),[E]),I=c.useCallback(B=>E(B,"stage","Couldn’t add context"),[E]),L=c.useCallback(async()=>{if(!e)return{receipt:{outcome:"not-running",reason:"no-open-turn",runtime:"unknown"},cancelled:[]};try{const{receipt:B,cancelledQueued:P}=await s.interruptSession(e);return{receipt:B,cancelled:P??[]}}catch{return{receipt:{outcome:"failed",reason:"delivery-failed",runtime:"unknown"},cancelled:[]}}},[e,s]),z=c.useCallback(async B=>{C(null),await F(B,!1)},[F,C]),Q=c.useCallback(async(B,P)=>{await F(B,!1,{kickoff:!0,...P?{cwd:P}:{}})},[F]),X=c.useCallback((B,P)=>{},[]);return{handleSubmit:S,submitContent:D,enqueueContent:T,steerContent:M,addContextContent:I,stop:L,retryMessage:z,submitKickoff:Q,markToolCallResponded:X}}const zt=new Set,Pr=new Set,qt=new Set;function p0(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 h0({sessionId:e,cwd:t,status:n,messages:s,hydrated:o,canStart:a=!0,submitKickoff:i,submitContent:l}){const u=rn(e),d=s.length,f=s.some(p0);c.useEffect(()=>{if(!e)return;if(!u){t&&d===0&&n==="idle"&&rt.getState().claimByPath(t,e);return}if(u.fired||zt.has(e)||!a||d>0||n!=="idle")return;zt.add(e),rt.getState().markFired(e);const g=u.kind==="first-message";(g?l:i)(u.kickoffMessage,u.path||void 0).catch(h=>{console.warn("[chat] first-turn trigger failed for newborn session",e,h),Pr.has(e)?g||rt.getState().markGreetingFailed(e):(Pr.add(e),zt.delete(e),rt.getState().resetFired(e))})},[e,t,u,n,d,a,i,l]),c.useEffect(()=>{if(!(!e||!u)&&u.kind!=="first-message"&&!(!u.fired&&!zt.has(e))&&!u.greetingFailed){if(f){qt.delete(e);return}if(n==="streaming"){qt.add(e);return}o&&qt.has(e)&&(qt.delete(e),rt.getState().markGreetingFailed(e))}},[e,u,n,f,o])}function g0(e,t){return c.useEffect(()=>{_c(),yt.connectList(),e&&yt.attachSession(e,t)},[e,t]),c.useEffect(()=>()=>yt.releaseSession(),[]),Mo(e??"")}function x0(e,t){const n=Oo(e),s=c.useRef(t);c.useEffect(()=>{s.current=t}),c.useEffect(()=>{var o;!n||!e||(Qa(e,n),(o=s.current)==null||o.call(s,n))},[n,e])}const b0=500;function y0(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 g=s.current;if(!e||!n){e&&g.delete(e),a(null);return}let m=g.get(e);(!m||m.turnSeq!==i)&&(m={turnSeq:i,anchor:Date.now()},g.set(e,m)),a(m.anchor)},[e,n,i]);const l=c.useMemo(()=>{let g=0;for(const m of t)m.type==="text_delta"&&(g+=m.text.length);return g/4},[t]),[u,d]=c.useState(!1),f=c.useRef({sid:null,tokens:0});return c.useEffect(()=>{const g=f.current,m=e===g.sid&&l>g.tokens;if(f.current={sid:e,tokens:l},m&&!u&&d(!0),!m&&!u)return;const h=setTimeout(()=>d(!1),b0);return()=>clearTimeout(h)},[e,l,u]),{streamStartTime:o,estimatedTokens:l,isTextStreaming:u}}function k0(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 v0(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===wc)&&(n={message:s.message});continue}n=null}return{operationProgress:t,systemStatus:n}}function C0(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 S0(e,t){return((e==null?void 0:e.message)??null)===((t==null?void 0:t.message)??null)}function j0(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}=v0(t),f=o.current.get(e)??null;C0(f,u)||(i.current(u),o.current.set(e,u));const g=a.current.get(e)??null;S0(g,d)||(l.current(d),a.current.set(e,d))},[e,t])}function _0(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 w0(e,t){const n=_0(e,t.approval.approvalId);n?n.approval=t.approval:e.push({type:"capability_approval",approval:t.approval})}function N0(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 E0(e,t,n){return e.findIndex(s=>s.type==="mcp_signin"&&s.agentId===t&&s.serverName===n&&s.outcome===void 0)}function D0(e,t){const n={type:"mcp_signin",serverName:t.serverName,agentId:t.agentId,flowId:t.flowId,authorizeUrl:t.authorizeUrl,disclosure:t.disclosure},s=E0(e,t.agentId,t.serverName);s===-1?e.push(n):e[s]=n}function T0(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 A0(e){return e.type==="interaction_resolved"||e.type==="capability_approval_resolved"||e.type==="mcp_signin_resolved"}function F0(e){const t=new Set;for(const n of e)n.type==="interaction_resolved"&&t.add(n.id);return t}const Lr="__in_progress_turn__",R0="__optimistic_user__";function M0(e){return{id:R0,role:"user",content:e,parts:[{type:"text",text:e}],timestamp:"",_streaming:!0}}function O0(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 I0(e){return{id:`staged-${e.messageId}`,role:"user",content:e.content,parts:[{type:"text",text:e.content}],timestamp:"",_streaming:!0,_stagedContext:!0}}function ze(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 pn(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 $0(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 P0(e,t){Xa(e);const n=e[e.length-1];n&&n.type==="text"?n.text+=t.text:e.push({type:"text",text:t.text})}function L0(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 Xa(e){for(const t of e)t.type==="thinking"&&t.isStreaming&&(t.isStreaming=!1)}function B0(e,t,n){const s=ze(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 z0(e,t){const n=ze(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 q0(e,t){const n=ze(e,t.toolCallId);n&&(n.progressOutput=(n.progressOutput??"")+t.content)}function Ya(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=ze(e,t.id);s?Object.assign(s,n):e.push({type:"tool_call",toolCallId:t.id,toolName:t.toolName,...n})}function Ja(e,t){const n=ze(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=pn(e,t.id);s?Object.assign(s,n):e.push({type:"elicitation",interactionId:t.id,...n})}function U0(e){return e==="denied"||e==="expired"||e==="cancelled"?"error":e==="answered"?"complete":"running"}function W0(e,t){const n=ze(e,t.id);if(n){n.status==="pending"&&(n.status=U0(t.resolution),n.approvalRemainingMs=void 0);const o=Nc(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=Ec(t);a&&(n.questionOutcome=a)}const s=pn(e,t.id);s&&s.status==="pending"&&(s.status="submitted",s.remainingMs=void 0)}function H0(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 G0(e,t){for(const n of e.values()){const s=n.find(o=>o.hookId===t);if(s)return s}}function V0(e,t,n){const s=H0(e,t.hookId)??G0(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=ze(e,t.toolCallId);a?a.hooks=[...a.hooks??[],o]:n.set(t.toolCallId,[...n.get(t.toolCallId)??[],o])}function K0(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 Q0(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 X0(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 Y0(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 J0(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 Z0(e,t){Xa(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 eb(e,t){const n=$0(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 tb={approval:"approval_required",question:"question_prompt",elicitation:"elicitation_prompt"};function nb(e){const{type:t,...n}=e;return{...n,seq:0,type:tb[t]}}function sb(e,t){const n=ze(e,t);return(n==null?void 0:n.interactiveType)!==void 0?!0:pn(e,t)!==void 0}function rb(e,t){switch(t.type){case"approval_required":Ya(e,t);break;case"question_prompt":Ja(e,t);break;case"elicitation_prompt":Za(e,t);break}}function ob(e,t,n){const s=ze(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=pn(e,t.id);o&&(o.startedAt=t.startedAt,o.remainingMs=t.remainingMs,t.timeoutMs!==void 0&&(o.timeoutMs=t.timeoutMs))}function ab(e,t,n){for(const s of t){if(sb(e,s.id)){ob(e,s,n.has(s.id));continue}rb(e,nb(s)),ib(e,s)}}function ib(e,t){if(t.parked!==!0)return;const n=ze(e,t.id);n&&(n.approvalParked=!0)}function ts(e){const t=[],n=new Map;for(const s of e)switch(s.type){case"text_delta":P0(t,s);break;case"thinking_delta":L0(t,s);break;case"tool_call":B0(t,s,n);break;case"tool_result":z0(t,s);break;case"tool_progress":q0(t,s);break;case"approval_required":Ya(t,s);break;case"question_prompt":Ja(t,s);break;case"elicitation_prompt":Za(t,s);break;case"capability_approval_required":w0(t,s);break;case"capability_approval_resolved":N0(t,s);break;case"mcp_signin_required":D0(t,s);break;case"mcp_signin_resolved":T0(t,s);break;case"interaction_resolved":W0(t,s);break;case"subagent_update":eb(t,s);break;case"hook_update":V0(t,s,n);break;case"memory_recall":K0(t,s);break;case"image_attachment":Q0(t,s);break;case"compact_boundary":X0(t,s);break;case"permission_denied":Y0(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":J0(t,s);break;case"error":Z0(t,s);break}return t}function Br(e,t){if(e.length===0)return null;const n=vs(e);return{id:t,role:"assistant",content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:[],parts:e,timestamp:"",_streaming:!0}}function lb(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=ts([...s,...e.slice(l+1).filter(A0)]),f=Br(d,`${Lr}-${o}`);f&&n.push(f),o+=1,n.push(u.type==="turn_input"?O0(u):I0(u)),s=[]}const a=ts(s);ab(a,t,F0(e));const i=Br(a,Lr);return i&&n.push(i),n}function cb(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 ub(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 db(e,t){const n=e.parts.filter(o=>o.type!=="tool_call"||!t.has(o.toolCallId)||!ub(o));if(n.length===e.parts.length)return e;if(n.length===0)return null;const s=vs(n);return{...e,parts:n,content:s.content,toolCalls:s.toolCalls.length>0?s.toolCalls:void 0}}function fb(e){let t=e.length;for(;t>0&&e[t-1].role==="assistant";)t-=1;return t}function mb(e,t,n=[],s=null){const o=lb(t,n),a=cb(o),i=Fp(e),l=a.size===0?i.length:fb(i),u=[];for(const[d,f]of i.entries()){const g=d<l?f:db(f,a);g&&u.push(g)}return s&&u.push(M0(s.content)),u.push(...o),u}function zr(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 pb(e,t){return e.interactiveType==="approval"&&e.approvalOutcome===t.outcome&&e.approvalResolvedAt===t.resolvedAt&&e.approvalStartedAt===t.startedAt&&e.approvalReasonGiven===t.reasonGiven}function hb(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||pb(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 gb(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 xb(e,t,n,s){const o=bb(s());if(o!==void 0){const a=await e.getMessages(t,n,{since:o}),i=gb(s(),a);if(i)return i}return(await e.getMessages(t,n)).messages}function bb(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="user")return e[t].id}function yb({sessionId:e,transport:t,sessionCwd:n,streamState:s,queryClient:o,onStreamingDone:a}){var v;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),g=c.useRef(new Map),m=c.useRef(new Map),h=c.useRef(new Map),x=c.useRef(new Map),C=((v=s.status)==null?void 0:v.lifecycle)??null,b=s.hydrationGeneration,y=s.userTurnCount;c.useEffect(()=>{var A,F,D;if(!e)return;const k=x.current.get(e);x.current.set(e,y),k!==void 0&&y!==k&&h.current.set(e,!1);const p=g.current.get(e);if(g.current.set(e,b),p!==b){f.current.set(e,C),C==="streaming"&&m.current.set(e,((A=De.getState().getSession(e).optimisticUserMessage)==null?void 0:A.id)??null);return}const j=f.current.get(e)??null;if(f.current.set(e,C),C==="streaming"&&j!=="streaming"&&m.current.set(e,((F=De.getState().getSession(e).optimisticUserMessage)==null?void 0:F.id)??null),!(j==="streaming"&&C!=="streaming"&&C!==null))return;const N=e,R=m.current.get(N)??null,w=zr(ts(De.getState().getSession(N).inProgressTurn));xb(t,N,u.current??void 0,()=>De.getState().getSession(N).messages).then(S=>{var z;const E=De.getState(),T=E.getSession(N),M=((z=T.status)==null?void 0:z.lifecycle)==="streaming",I=new Map([...zr(T.messages.flatMap(Q=>Q.parts??[])),...w]);E.setHistoryMessages(N,hb(S,I),{preserveInProgressTurn:M});const L=T.optimisticUserMessage;(L===null||L.id===R)&&E.setOptimisticUserMessage(N,null)}).catch(S=>{console.warn("[turn-end-reconcile] history reload failed",{sessionId:N,error:S instanceof Error?S.message:String(S)})}),o.invalidateQueries({queryKey:["tasks",N]}),h.current.get(N)!==!0&&(h.current.set(N,!0),(D=d.current)==null||D.call(d))},[e,C,b,y,t,o])}function kb(e){return e.streamReadyCursor!==null||e.messages.length>0||e.inProgressTurn.length>0||e.optimisticUserMessage!==null}function ei(e,t){const n=kb(e),s=n?e.messages:t,o=qr.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?mb(e.messages,e.inProgressTurn,e.pendingInteractions,e.optimisticUserMessage):t,i=du(a);return qr.set(s,{hydrated:n,inProgressTurn:e.inProgressTurn,pendingInteractions:e.pendingInteractions,optimisticUserMessage:e.optimisticUserMessage,legacyMessages:t,result:i}),i}const qr=new WeakMap;function vb(e,t={}){const n=ve(),s=us(),o=le(V=>V.selectedCwd),a=le(V=>V.enableMessagePolling),i=le(V=>V.pendingAccount),l=sa(),u=e??"",{messages:d,input:f,status:g,error:m,sessionStatus:h,systemStatus:x,operationProgress:C,promptSuggestions:b}=Io(u),y=g0(e,l.cwd);x0(e,t.onSessionIdChangeReplace);const v=Dc(u),k=c.useMemo(()=>ei(y,d),[y,d]),p=Tc(y,g),{streamStartTime:j,estimatedTokens:_,isTextStreaming:N}=y0(e,y.inProgressTurn,p==="streaming");k0(e,y.inProgressTurn,y.streamReadyCursor,t.onTaskEvent);const R=c.useRef(!0);c.useEffect(()=>(R.current=!0,()=>{R.current=!1}),[]);const w=c.useRef(new Map);c.useLayoutEffect(()=>{u&&(w.current.has(u)||w.current.set(u,ae.getState().getSession(u).mountGeneration))},[u]);const{setMessages:A,setInput:F,setError:D,setSystemStatus:S,setOperationProgress:E}=u0(u,R,w);j0(e,y.inProgressTurn,E,S),u&&ae.getState().initSession(u),c.useEffect(()=>{e&&(ae.getState().initSession(e),ae.getState().touchSession(e),w.current.set(e,ae.getState().getSession(e).mountGeneration))},[e]),c.useEffect(()=>{if(e)return kt.getState().clearUnseen(e),kt.subscribe(V=>{V.unseen[e]!==void 0&&kt.getState().clearUnseen(e)})},[e]);const{historyQuery:T}=d0({sessionId:e,sid:u,transport:n,sessionCwd:l,enableMessagePolling:a,isStreaming:p==="streaming",streamHydrated:y.streamReadyCursor!==null,setMessages:A}),M=Lx(o,e,{startFreshSession:t.startFreshSession,compact:t.compactIntent}),{handleSubmit:I,submitContent:L,enqueueContent:z,steerContent:Q,addContextContent:X,stop:B,retryMessage:P,submitKickoff:Y,markToolCallResponded:O}=m0({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:F,setError:D,tryNativeCommand:M.tryRun}),W=y.streamReadyCursor!==null,ne=c.useCallback((V,re)=>L(V,re?{cwd:re}:void 0),[L]);h0({sessionId:e,cwd:o,status:p,messages:k,hydrated:W,canStart:!t.agentLookupPending&&!t.agentLookupFailed,submitKickoff:Y,submitContent:ne}),yb({sessionId:e,transport:n,sessionCwd:l,streamState:y,queryClient:s,onStreamingDone:t.onStreamingDone});const $=T.isLoading&&k.length===0,Z=c.useMemo(()=>k.flatMap(V=>V.toolCalls||[]).filter(V=>V.interactiveType&&V.status==="pending"),[k]),ce=Z[0]||null,oe=ce!==null,se=(ce==null?void 0:ce.interactiveType)||null;return{messages:k,input:f,setInput:F,handleSubmit:I,submitContent:L,enqueueContent:z,steerContent:Q,addContextContent:X,status:p,error:m,stop:B,retryMessage:P,isLoadingHistory:$,hydrated:W,sessionStatus:h,streamStartTime:j,estimatedTokens:_,isTextStreaming:N,isWaitingForUser:oe,waitingType:se,activeInteraction:ce,pendingInteractions:Z,markToolCallResponded:O,systemStatus:x,operationProgress:C,promptSuggestions:b,syncConnectionState:v,tryNativeCommand:M.tryRun,commandPending:M.commandPending}}function Cb(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. ${jb(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 Sb(e,t){return!$o(e)||e.outcome==="not-running"&&t}function jb(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 _b(){const e=le(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=g=>{i.current=g.matches};return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[]),Od({timeoutMs:tt.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 Kd({enabled:e,miniProbability:tt.MINI_PROBABILITY,debounceWindowMs:tt.DEBOUNCE_WINDOW_MS,debounceThreshold:tt.DEBOUNCE_THRESHOLD,minTasksForMajor:tt.MIN_TASKS_FOR_MAJOR,idleTimeoutMs:tt.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 g;d.action==="update"&&d.task.status==="completed"&&d.task.id&&((g=a.current)==null||g.onTaskCompleted(d.task.id,f))},[]),u=c.useCallback(()=>{n(null),o(null)},[]);return{handleTaskEvent:l,activeCelebration:t,celebratingTaskId:s,clearCelebration:u}}function In(){return{tasks:new Map,statusTimestamps:new Map,legacyCreateCount:0}}function wb(e){const t={};for(const[n,s]of Object.entries(e))s!==void 0&&s!==""&&(t[n]=s);return t}function $n(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,...wb(t.task)}),t.task.status&&t.task.status!==s.status&&e.statusTimestamps.set(t.task.id,{status:t.task.status,since:n});return}}}function Ur(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 Nb(e,t){return[...e].sort((n,s)=>{const o=n.status==="in_progress"?0:n.status==="pending"&&!Ur(n,t)?1:n.status==="pending"?2:3,a=s.status==="in_progress"?0:s.status==="pending"&&!Ur(s,t)?1:s.status==="pending"?2:3;return o-a})}const Eb=10;let Wr=0;function Ut(e){return e==="streaming"||e==="blocked"}function Db(e,t=!1){const n=ve(),o=sa().cwd,a=le(w=>w.enableMessagePolling),i=Xo(),[l,u]=c.useState(In()),d=Po(e??""),[f,g]=c.useState(()=>!Ut(d)),m=c.useRef([]),h=c.useRef(0),{data:x}=Je({queryKey:["tasks",e,o],queryFn:async()=>{const w=++Wr;return{...await n.getTasks(e,o??void 0),fetchOrder:w}},staleTime:3e4,refetchOnWindowFocus:!1,enabled:e!==null,refetchInterval:()=>!a||t?!1:i?Xe.ACTIVE_TAB_REFETCH_MS:Xe.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=[],h.current=0,u(In())),!x||x.fetchOrder<=h.current)return;h.current=x.fetchOrder;const F=In();x.tasks.length>0&&$n(F,{action:"snapshot",task:x.tasks[0],tasks:x.tasks},Date.now()),m.current=m.current.filter(({order:D})=>D>x.fetchOrder);for(const{event:D,receivedAt:S}of m.current)$n(F,D,S);u(F)},[x,e,o]);const b=c.useCallback(w=>{const A=Date.now();w.action==="snapshot"&&(m.current=[]),m.current.push({order:++Wr,event:w,receivedAt:A}),u(F=>{const D={tasks:new Map(F.tasks),statusTimestamps:new Map(F.statusTimestamps),legacyCreateCount:F.legacyCreateCount};return $n(D,w,A),D})},[]),y=c.useRef(!1),v=c.useCallback(()=>{g(w=>(y.current=!w,!w))},[]),k=c.useRef(Ut(d));c.useEffect(()=>{const w=Ut(d);w!==k.current&&(k.current=w,w?y.current||g(!1):g(!0))},[d]);const p=c.useRef(null);c.useEffect(()=>{const w=`${e??""}::${o??""}`;if(p.current===w)return;p.current=w;const A=Ut(d);k.current=A,y.current=!1,g(!A)},[e,o,d]);const j=Array.from(l.tasks.values()),_=Nb(j,l.tasks),N=j.find(w=>w.status==="in_progress"),R=(N==null?void 0:N.activeForm)??null;return{tasks:_.slice(0,Eb),taskMap:l.tasks,activeForm:R,isCollapsed:f,toggleCollapse:v,handleTaskEvent:b,statusTimestamps:l.statusTimestamps}}function Tb(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()},[]),g=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()},[]),h=c.useCallback(y=>{const v=t.current;v&&"toggleOption"in v&&(v.toggleOption(y),s(y),a(!0))},[]),x=c.useCallback(y=>{if(!o){a(!0);return}s(v=>{const k=t.current,p=k&&"getOptionCount"in k?k.getOptionCount():0;return p===0?v:y==="up"?v<=0?p-1:v-1:v>=p-1?0:v+1})},[o]),C=c.useCallback(y=>{const v=t.current;v&&"navigateQuestion"in v&&(v.navigateQuestion(y),s(0),a(!0),l(v.getOptionCount()))},[]),b=c.useCallback(()=>{const y=t.current;y&&"submit"in y&&y.submit()},[]);return Id({activeInteraction:d,onApprove:f,onAlwaysAllow:g,onDeny:m,onToggleOption:h,onNavigateOption:x,onNavigateQuestion:C,onSubmit:b,optionCount:i,focusedIndex:n}),{handleToolRef:u,focusedOptionIndex:o?n:-1}}function Wt(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 Ab({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(j=>({cmd:j,rank:vf(a,j)})).filter(j=>j.rank.match).sort((j,_)=>j.rank.bucket-_.rank.bucket||_.rank.score-j.rank.score).map(({cmd:j,rank:_})=>({...j,matchedAlias:_.matchedAlias})):e,[e,a]),[f,g]=c.useState(null),m=f!==null&&f.query===a&&f.open===s?f.index:Wt(d,0,1),h=d[m],x=d.length===0||h!==void 0&&!h.disabled?m:Wt(d,0,1),C=c.useCallback((j,_)=>{const R=j.slice(0,_).match(/(^|\s)\/([\w:-]*)$/);return R?(o(!0),i(R[2]),u((R.index??0)+R[1].length),!0):(o(!1),!1)},[]),b=c.useCallback(j=>{const _=t.slice(0,l),N=t.slice(l+1+a.length);return o(!1),_+j.fullCommand+(N.startsWith(" ")?"":" ")+N},[t,a,l]),y=c.useCallback(()=>{g({query:a,open:s,index:Wt(d,x+1,1)})},[d,x,a,s]),v=c.useCallback(()=>{g({query:a,open:s,index:Wt(d,x-1,-1)})},[d,x,a,s]),k=c.useCallback(()=>{const j=d[x];return j&&!j.disabled?b(j):(j||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:v,handleArrowDown:y,handleKeyboardSelect:k,resetCommand:p}}function Fb({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),g=c.useMemo(()=>s?a?e.map(v=>({...v,...Gt(a,v.path)})).filter(v=>v.match).sort((v,k)=>k.score-v.score).slice(0,50):e.slice(0,50).map(v=>({...v,indices:[]})):[],[e,a,s]);c.useEffect(()=>{u(0)},[a,s]),c.useEffect(()=>{g.length>0&&l>=g.length&&u(g.length-1)},[g.length,l]);const m=c.useCallback((v,k)=>{const j=v.slice(0,k).match(/(^|\s)@([\w./:-]*)$/);return j?(o(!0),i(j[2]),f((j.index??0)+j[1].length),!0):(o(!1),!1)},[]),h=c.useCallback(v=>{const k=t.slice(0,d),p=t.slice(d+1+a.length);if(v.isDirectory){const _=k+"@"+v.path+p,N=k.length+1+v.path.length;return i(v.path),u(0),{newValue:_,newCursorPos:N,keepOpen:!0}}const j=k+"@"+v.path+" "+p;return o(!1),{newValue:j,keepOpen:!1}},[t,d,a]),x=c.useCallback(()=>{u(v=>g.length===0?0:(v+1)%g.length)},[g.length]),C=c.useCallback(()=>{u(v=>g.length===0?0:(v-1+g.length)%g.length)},[g.length]),b=c.useCallback(()=>g.length>0&&l<g.length?h(g[l]):(o(!1),null),[g,l,h]),y=c.useCallback(()=>{o(!1),i("")},[]);return{showFiles:s,setShowFiles:o,fileQuery:a,fileSelectedIndex:l,filteredFiles:g,fileTriggerPos:d,detectFileTrigger:m,handleFileSelect:h,handleArrowUp:C,handleArrowDown:x,handleKeyboardSelect:b,resetFiles:y}}function Rb({input:e,setInput:t,commands:n,fileEntries:s}){const[o,a]=c.useState(0),i=Ab({commands:n,input:e,cursorPos:o}),l=Fb({fileEntries:s,input:e,cursorPos:o}),u=c.useCallback((_,N)=>{if(l.detectFileTrigger(_,N)){i.setShowCommands(!1);return}if(i.detectCommandTrigger(_,N)){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(_=>{t(_),d.current={value:_,cursor:d.current.cursor||_.length},u(_,d.current.cursor)},[t,u]),g=c.useCallback(_=>{a(_),d.current={value:d.current.value,cursor:_},u(d.current.value,_)},[u]),m=c.useCallback(_=>{const N=i.handleCommandSelect(_);t(N)},[i,t]),h=c.useCallback(_=>{const N=l.handleFileSelect(_);t(N.newValue),N.newCursorPos!==void 0&&a(N.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 _=l.handleKeyboardSelect();_&&(t(_.newValue),_.newCursorPos!==void 0&&a(_.newCursorPos))}else if(i.showCommands){const _=i.handleKeyboardSelect();_&&t(_)}},[l,i,t]),y=c.useCallback(()=>{i.setShowCommands(!1),l.setShowFiles(!1)},[i,l]),v=i.showCommands||l.showFiles,k=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,j=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:v,paletteHasResults:k,activeDescendantId:j,paletteListboxId:p,handleInputChange:f,handleCursorChange:g,handleArrowUp:C,handleArrowDown:x,handleKeyboardSelect:b,handleCommandSelect:m,handleFileSelect:h,dismissPalettes:y}}function Mb(e,t,n){const s=le(i=>i.setIsStreaming),o=le(i=>i.setIsWaitingForUser),a=le(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 Ob(){const e=ve(),t=le(m=>m.selectedCwd),[n,s]=c.useState([]),o=c.useCallback(m=>{const h=m.map(x=>({id:crypto.randomUUID(),file:x,status:"pending",progress:0}));s(x=>[...x,...h])},[]),a=c.useCallback(m=>{s(h=>h.filter(x=>x.id!==m))},[]),i=c.useCallback(()=>{s([])},[]),l=c.useCallback(m=>{s(h=>h.map(x=>x.id===m&&x.status==="error"?{...x,status:"pending",progress:0,error:void 0}:x))},[]),u=c.useRef(null),d=Ct({meta:{suppressErrorToast:!0},mutationFn:async m=>{if(!t)throw new Error("No working directory selected");s(b=>b.map(y=>m.some(v=>v.id===y.id)?{...y,status:"uploading"}:y));const h=b=>{s(y=>y.map(v=>v.status==="uploading"?{...v,progress:b.percentage}:v))},x=new AbortController;u.current=x;const C=m.map(b=>b.file);return e.uploadFiles(C,t,h,x.signal)},onSettled:()=>{u.current=null},onSuccess:(m,h)=>{s(x=>x.map(C=>{const b=h.findIndex(y=>y.id===C.id);return b===-1?C:{...C,status:"uploaded",progress:100,result:m[b]}}))},onError:m=>{s(h=>h.map(x=>x.status==="uploading"?{...x,status:"error",error:m.message}:x))}}),f=c.useCallback(()=>{var m;(m=u.current)==null||m.abort()},[]),g=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 h=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 h;const C=await d.mutateAsync(x);return[...h,...C.map(b=>b.savedPath)]},[n,d]);return{pendingFiles:n,addFiles:o,removeFile:a,retryFile:l,clearFiles:i,cancelUpload:f,uploadAndGetPaths:g,hasPendingFiles:n.length>0,hasFailedUpload:n.some(m=>m.status==="error"),isUploading:d.isPending}}const Pn=new Set,Ln=new Set;function Ib(e,t){return`${e}\0${t}`}function $b({sessionId:e,prompt:t,autoSend:n,input:s,setInput:o,messageCount:a,hydrated:i,status:l,submitBlocked:u=!1,submit:d,onSeeded:f,onConsumed:g}){const m=t!=null&&t.trim()?t:void 0,h=e&&m?Ib(e,m):null;c.useEffect(()=>{if(!(!h||!m)&&!Pn.has(h)&&i){if(Pn.add(h),s.length>0||a>0){Ln.add(h),g==null||g();return}o(m),f==null||f(),n||g==null||g()}},[h,m,n,s,i,a,o,f,g]),c.useEffect(()=>{!h||!m||!n||Ln.has(h)||Pn.has(h)&&s===m&&(!i||a>0||l==="streaming"||u||(Ln.add(h),g==null||g(),d()))},[h,m,n,s,i,a,l,u,d,g])}const Hr=Ac-256,Gr=`
|
|
52
|
-
…(context truncated)`,Vr={"/":"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","/threads":"the threads page"};function Pb(e){const t=`/${e.split("/").filter(Boolean)[0]??""}`;return Vr[e]??Vr[t]??`the ${e} page`}function Lb(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 ${Pb(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<=Hr?n:n.slice(0,Hr-Gr.length)+Gr}const Bb="dorkbot-help",Ht=new Set;function zb({sessionId:e,seed:t,messageCount:n,hydrated:s,onConsumed:o}){const a=t===Bb&&e!==null,{data:i}=Fc({enabled:a}),{data:l}=os(),u=kt(Rc(m=>Object.entries(m.statuses).filter(([,h])=>h.lifecycle==="error").map(([h])=>h))),d=c.useRef({agentNames:[],version:null,updateReady:!1,erroredSessionIds:[]}),f=c.useRef({armed:a,sessionId:e,messageCount:n}),g=c.useRef(o);return c.useEffect(()=>{const m=(l==null?void 0:l.latestVersion)??null,h=(l==null?void 0:l.version)??null;d.current={agentNames:((i==null?void 0:i.agents)??[]).map(x=>x.displayName??x.name),version:h,updateReady:m!==null&&h!==null&&yu(m,h),erroredSessionIds:u}},[i,l,u]),c.useEffect(()=>{f.current={armed:a,sessionId:e,messageCount:n},g.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 h;const m=f.current;if(!(!m.armed||m.sessionId===null)&&!(m.messageCount>0)&&!Ht.has(m.sessionId))return Ht.add(m.sessionId),(h=g.current)==null||h.call(g),Lb({...d.current,originPath:Mc()})},[])}function qb(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!==wo))}const Ub=4e3;function Wb(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 Hb(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?Wb(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})),Ub);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}`}const Kr=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"],Qr=5e3,Gb=1e3,Vb=1500,Kb=new Set;function Qb(e){const t=c.useRef(new Map),n=Lo({byTask:new Map,assigned:0}),[s,o]=c.useState(Kb),[,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<Qr))return;const d=setInterval(()=>{a(f=>f+1)},Gb);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"&&!Js(d)&&o(g=>g.has(u)?g:new Set(g).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})},Vb))},[s]),c.useMemo(()=>{const u=Date.now(),d=[],f=n.read();let g=f.assigned;for(const[m,h]of i){const x=h.status==="running",C=s.has(m);if(!x&&!C||h.taskType==="bash"&&x&&u-h.startedAt<Qr)continue;let b=f.byTask.get(m);b===void 0&&(b=Kr[g%Kr.length],g+=1,f.byTask.set(m,b),n.write({byTask:f.byTask,assigned:g})),d.push({taskId:h.taskId,taskType:h.taskType,status:h.status,color:b,startedAt:h.startedAt,description:h.description,toolUses:h.toolUses,lastToolName:h.lastToolName,durationMs:h.durationMs,summary:h.summary,command:h.command,ambient:Js(h)})}return d},[i,s,n])}const Xb=new Set(["streaming","blocked"]);function Yb(e,t){return e.length===0||e[0].waitingOn!==void 0||t&&Xb.has(t)?e:e.slice(1)}function Bn(e,t,n){return`${e} ${e===1?t:n}`}const Xr={"delivery-owed":"a helper’s report","waiting-on-person":"your answer","timer-pending":"a reminder the agent set"},Jb={"timer-pending":"Switching now cancels the reminder."};function Zb(e){const{agents:t,shells:n,other:s}=e.holding,o=[t>0?Bn(t,"helper","helpers"):void 0,n>0?Bn(n,"command","commands"):void 0,s>0?Bn(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&&Xr[e.because]!==void 0?`Held for ${Xr[e.because]}.`:"Held until the agent is free."} Sending it ${l}.`,switchHint:a!==void 0?`Switching now stops ${a}.`:(e.because!==void 0?Jb[e.because]:void 0)??"Switching now stops what the agent is doing."}}const ey={"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 ty(e){return e!=null&&e.degradedBecause?ey[e.degradedBecause]:null}function Yr(e){return(e==null?void 0:e.code)==="QUEUED_MESSAGE_NOT_FOUND"}function ny({sessionId:e,waiting:t,onEnqueue:n}){const s=ve(),o=Oc(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:ty(o[p.id]),...p.waitingOn?{waiting:Zb(p.waitingOn)}:{}})),[t,o,s.clientId]),u=c.useMemo(()=>{if(a===null)return null;const p=l.findIndex(j=>j.id===a);return p===-1?null:p},[a,l]),d=c.useCallback(()=>{var p;if(e)return(p=De.getState().getSession(e).queuedMessages[0])==null?void 0:p.id},[e]),f=c.useCallback((p,j)=>{p().catch(_=>{Yr(_)||Fe.error(j)})},[]),g=c.useCallback(async p=>{const j=p.trim();return!j||!e?!1:n(j)},[e,n]),m=c.useCallback((p,j)=>{e&&f(()=>s.updateQueuedMessage(e,p,{content:j}),"Couldn’t save that change")},[e,s,f]),h=c.useCallback(p=>{i(j=>j===p?null:j),e&&f(()=>s.removeQueuedMessage(e,p),"Couldn’t take that message off the queue")},[e,s,f]),x=c.useCallback((p,j)=>{if(!e)return;const _=N=>s.updateQueuedMessage(e,p,{move:{before:N}});f(async()=>{try{await _(j)}catch(N){if(!Yr(N))throw N;const R=d();if(R===void 0||R===p)return;await _(R)}},"Couldn’t move that message")},[e,s,f,d]),C=c.useCallback(p=>l.findIndex(_=>_.id===p)<=0?!1:(i(_=>_===p?null:_),x(p,l[0].id),!0),[l,x]),b=c.useCallback(p=>{const j=l.findIndex(_=>_.id===p);j<=0||x(p,l[j-1].id)},[l,x]),y=c.useCallback(p=>{const j=l.find(_=>_.id===p);return j?(i(p),j.content):null},[l]),v=c.useCallback(()=>{i(null)},[]),k=c.useCallback(p=>{a!==null&&(m(a,p),i(null))},[a,m]);return{queue:l,editingId:a,editingIndex:u,addToQueue:g,removeFromQueue:h,sendNow:C,moveUp:b,startEditing:y,cancelEditing:v,saveEditing:k,updateQueued:m}}function ti(e,t){return e===null?null:`${e} ${t??""}`}function sy({input:e,setInput:t,sessionId:n,selectedCwd:s,waiting:o,onEnqueue:a,onSteer:i,onStage:l,tryNativeCommand:u,chatInputRef:d}){const f=c.useRef(""),g=c.useRef(null),m=ti(n,s);c.useEffect(()=>{f.current="",g.current=null},[m]);const h=ny({sessionId:n,waiting:o,onEnqueue:a}),x=h.cancelEditing;c.useEffect(()=>{x()},[m,x]);const C=c.useCallback(()=>{const M=h.editingId;if(M===null)return;const I=e.trim();I&&(h.updateQueued(M,I),Px(I)&&Fe.warning("Saved as a command. It runs instead of sending."))},[e,h]),b=Un(h.editingId),y=Un(h.updateQueued);c.useEffect(()=>{const M=n;return()=>{const I=b.read();if(I===null||!M)return;const L=ae.getState(),z=L.getSession(M).input.trim();z&&y.read()(I,z),L.updateSession(M,{input:f.current})}},[m]);const v=c.useCallback(M=>{const I=e.trim();if(!I)return;const L=u(I);if(L.handled){if(!L.ran)return;L.confirmed?es(n,I,L.confirmed):t("");return}if(g.current===I)return;g.current=I,lt.getState().recordOpened("session",n),s&<.getState().recordOpened("agent",s);const z=M(I);z.finally(()=>{g.current===I&&(g.current=null)}),es(n,I,z)},[e,s,n,t,u]),k=c.useCallback(()=>v(M=>h.addToQueue(M)),[v,h]),p=c.useCallback(()=>{i&&v(i)},[v,i]),j=c.useCallback(()=>{l&&v(l)},[v,l]),_=c.useCallback(M=>{var z,Q;if(h.editingId===M){(z=d.current)==null||z.focus();return}const I=h.editingId!==null;I&&C();const L=h.startEditing(M);L!==null&&(I||(f.current=e),t(L),(Q=d.current)==null||Q.focus())},[e,h,C,t,d]),N=c.useCallback(()=>{if(h.editingId===null)return;const M=e.trim();if(!M)return;const I=u(M);if(I.handled){I.ran&&(h.cancelEditing(),t(f.current));return}h.saveEditing(M),t(f.current)},[e,h,t,u]),R=c.useCallback(()=>{h.cancelEditing(),t(f.current)},[h,t]),w=c.useCallback(M=>{h.editingId===M&&t(f.current),h.removeFromQueue(M)},[h,t]),A=c.useCallback(M=>{const I=h.editingId===M;I&&C(),h.sendNow(M)&&I&&t(f.current)},[h,C,t]),F=c.useCallback(M=>{h.moveUp(M)},[h]),D=c.useCallback(M=>{var z;const I=(z=h.queue[M])==null?void 0:z.id;if(I!==void 0&&I===h.editingId)return;C();const L=I===void 0?null:h.startEditing(I);if(L===null){h.cancelEditing(),t(f.current);return}t(L)},[h,C,t]),S=c.useCallback(()=>{C(),h.cancelEditing(),t(f.current)},[C,h,t]),E=c.useCallback(()=>{const{editingIndex:M,queue:I}=h;if(M===null){if(I.length===0)return;f.current=e,D(I.length-1)}else M>0?D(M-1):S()},[D,e,S,h]),T=c.useCallback(()=>{const{editingIndex:M,queue:I}=h;M!==null&&(M<I.length-1?D(M+1):S())},[D,S,h]);return{queue:h.queue,editingId:h.editingId,editingIndex:h.editingIndex,handleQueue:k,handleSteer:p,handleStage:j,handleQueueEdit:_,handleQueueSaveEdit:N,handleQueueCancelEdit:R,handleQueueRemove:w,handleQueueSend:A,handleQueueMoveUp:F,handleQueueNavigateUp:E,handleQueueNavigateDown:T,leaveQueueForStop:S}}const ry=5e3,Jr=3;function ni(){try{const e=Number(localStorage.getItem(Bo.PLACEHOLDER_HINT_CYCLES));return Number.isFinite(e)&&e>0?e:0}catch{return 0}}function oy(){const e=ni()+1;try{localStorage.setItem(Bo.PLACEHOLDER_HINT_CYCLES,String(e))}catch{}return e}function ay(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 iy({defaultText:e,hints:t,enabled:n,intervalMs:s=ry}){const[o]=c.useState(()=>t.length>0?ay(t):[]),[a,i]=c.useState(()=>ni()>=Jr),[l,u]=c.useState({key:0,hintIndex:-1}),d=c.useRef(0),f=c.useRef(0),g=c.useRef(!1);return c.useEffect(()=>{if(a||!n||t.length===0){g.current&&(g.current=!1,d.current+=1,u({key:d.current,hintIndex:-1}));return}const h=setInterval(()=>{if(d.current+=1,g.current=!g.current,!g.current){u({key:d.current,hintIndex:-1});return}const x=f.current%t.length;f.current+=1,f.current%t.length===0&&oy()>=Jr&&i(!0),u({key:d.current,hintIndex:x})},s);return()=>clearInterval(h)},[n,t.length,s,a]),{text:l.hintIndex>=0?o[l.hintIndex]??e:e,key:l.key}}const zn=/[.!?…:](?=\s|$)|\n/g;function Zr(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};zn.lastIndex=0;let i=-1;for(let l=zn.exec(a);l!==null;l=zn.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 ly=1500,cy=4e3,uy=400;function dy({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<=uy?"":t})}const l=s.current.get(e),{chunk:u,announced:d}=Zr(t,l.announced,!1);l.announced=d,u!==""&&a(g=>({text:u,nonce:g.nonce+1}));const f=setTimeout(()=>{const g=Zr(t,l.announced,!0);l.announced=g.announced,g.chunk!==""&&a(m=>({text:g.chunk,nonce:m.nonce+1}))},ly);return()=>clearTimeout(f)},[e,t,n]),c.useEffect(()=>{if(o.text==="")return;const i=setTimeout(()=>a(l=>({text:"",nonce:l.nonce})),cy);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}`}const si={reactions:!1,threads:!1,runWith:!0,attachments:!0,mentions:!1,streamHealth:!1,presence:!1,turnStatus:!0,asks:!0},ri='[data-testid="model-config-trigger"]',fy=3e3;function my(e){var t;(t=e==null?void 0:e.querySelector(ri))==null||t.click()}function py(e,t=fy){const n=Date.now()+t,s=()=>{var a;const o=(a=e())==null?void 0:a.querySelector(ri);if(o)return o.click();Date.now()<n&&setTimeout(s,50)};s()}function hy(e,t){const{openSessionView:n}=Ic();return c.useCallback(()=>{if(!t)return my(e.current);n(),py(()=>e.current)},[t,n,e])}const eo=new WeakMap;function gy(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:ky(n),d=[];for(const f of e){if(f.kind!=="post"||f.threadRootEntryId||f.sessionId!==null&&a.has(f.sessionId)&&(l??(l=by(n)),l.has(f.body.text)||!o&&(u===null||Date.parse(f.createdAt)<u))||i.has(f.id))continue;let g=eo.get(f);if(!g){const m=f.body.text;g={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}},eo.set(f,g)}d.push(g)}return d}const xy=/(?:^|[_.])(?:post_to_room|relay_notify_user)$/;function by(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&&xy.test(o.toolName))for(const a of yy(o.input))t.add(a);s.length>1&&t.add(s.filter(Boolean).join(`
|
|
54
|
-
|
|
55
|
-
`).trim())}return t}function yy(e){try{const t=JSON.parse(e);return t===null||typeof t!="object"?[]:Object.values(t).filter(n=>typeof n=="string")}catch{return[]}}function ky(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 vy(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 Cy(e,t,n=!0){if(!t||t.entries.length===0)return{messages:e,lastSeenBeforeUnread:null,unreadFromStart:!1};const s=gy(t.entries,t.sessionIds,e,t.agentAuthorIds,n),o=vy(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 Sy(e){var f,g,m;const t=$c(e),n=((f=t.data)==null?void 0:f.roomId)??null,s=Pc(n),o=Lc(n),a=s.data,i=o.data;td(n,i!==void 0),Bc(a,i??to);const l=((g=a==null?void 0:a.members.find(h=>h.author.id===a.viewerAuthorId))==null?void 0:g.lastReadSeq)??null,u=_y(n,l),d=((m=t.data)==null?void 0:m.sessionIds)??jy;return c.useMemo(()=>{const h=s.isError||o.isError,x=n===null||h||i!==void 0&&u!==null;return{roomId:n,entries:i??to,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 jy=[],to=[];function _y(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 no(e){return e>=1e3?`~${(e/1e3).toFixed(1)}k tokens`:`~${Math.round(e)} tokens`}function wy(e){const{formatted:t}=Qo(e.status==="streaming"?e.streamStartTime:null),n=ho(e.permissionMode),s=c.useRef(e.status),o=c.useRef(t),a=c.useRef(e.estimatedTokens),[i,l]=c.useState(!1);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 d=setTimeout(()=>l(!1),on.TURN_COMPLETE_DISMISS_MS);return()=>clearTimeout(d)},[i]);const u=Ku({capabilities:si,asks:e.asks??Ho,stalled:!1,presence:Qu,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:no(e.estimatedTokens),isBypass:n,showComplete:i,lastElapsed:o.current,lastTokens:no(a.current)}});return e.quietNumbers?Ey(u):u}const Ny={kind:"empty"};function Ey(e){return e.kind==="turn-streaming"?{...e,elapsed:"",tokens:""}:e.kind==="turn-complete"?Ny:e}function Dy(e,t){var b,y,v,k;const n=zc(e),s=n.mode==="dm"&&n.chat!==null,o=n.mode==="pending",a=qc(s?n.chat.agentPath:null),{data:i}=os(),l=Uc(),u=((y=(b=i==null?void 0:i.profile)==null?void 0:b.displayName)==null?void 0:y.trim())||null,d=t?ln(t):null,{id:f,name:g}=a,m=((v=a.visual)==null?void 0:v.emoji)??null,h=((k=a.visual)==null?void 0:k.color)??null,x=c.useMemo(()=>o?{agent:null,humanName:null,settled:!1}:s?{agent:f!==null&&g!==null&&m!==null&&h!==null?{id:f,displayName:g,emoji:m,color:h}:null,humanName:u,settled:!0}:null,[o,s,f,g,m,h,u]);if(x===null)return{directMessage:null,placeholder:d?`Message ${d}…`:"Send a message…",quietTurnNumbers:!1};const C=g??d;return{directMessage:x,placeholder:C?`Message ${C}`:"Send a message",quietTurnNumbers:!l}}function Ty(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:g}=s,m=c.useMemo(()=>({staged:d,add:a,remove:i,retry:l,cancel:u,hasFailed:f,isUploading:g,holdsSendWhileUploading:!0}),[d,f,g,a,i,l,u]),h=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:h,queue:x,attachments:m}),[t,n,m,h,x])}function Ay({error:e,composerAgent:t,onRetry:n}){return e.code===jo&&e.agentId?r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(ra,{agentId:e.agentId,...(t==null?void 0:t.id)===e.agentId?{agentName:ln(t,"This agent")}:{}})}):r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(dn,{message:e.message,heading:e.heading,subtext:e.message,onRetry:e.retryable?n:void 0})})}const Fy={duration:.16,delay:.08,ease:[.16,1,.3,1]},Ry={duration:0};function My({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=Oe(),{answerAll:f,isAnswering:g,error:m}=Wc(),h=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(Hc,{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(h,"allow"),onDenyAll:()=>void f(h,"deny"),isAnswering:g,error:m}),r.jsx(me,{mode:"wait",initial:!1,children:r.jsx(H.div,{initial:d?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:d?Ry:Fy,children:t.interactiveType==="approval"?r.jsx(No,{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(Eo,{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 Oy({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(H.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:g=>{g.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 Iy(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 $y({asDirectMessage:e=!1,chatInputRef:t,input:n,autocomplete:s,steerContent:o,addContextContent:a,tryNativeCommand:i,commandPending:l,agentLookupPending:u=!1,agentLookupError:d=!1,status:f,stop:g,setInput:m,sessionId:h,sessionStatus:x,waiting:C,interaction:b,sync:y}){var Pe,Me;const{active:v,pendingApprovals:k,focusedOptionIndex:p,onToolRef:j,onToolDecided:_}=b,N=f==="streaming",R=le(he=>he.isTextStreaming),[w]=zo(),A=ve(),{data:F}=xs(w),D=Gc(F??null,w??""),S=F?ln(F):void 0,{target:E}=Xu(),T=(E==null?void 0:E.placeholder)??"Send a message…",M=Vc(h),I=wm(h),L=cn(h),z=an(L),Q=Kc(h),X=((z==null?void 0:z.supportsSteer)??!1)&&(Q??!0),B=(z==null?void 0:z.supportsContextStaging)??!1,P=((Pe=z==null?void 0:z.permissionModes)==null?void 0:Pe.denyReason)??!0,Y=c.useCallback(async he=>{if((E==null?void 0:E.queue)===void 0)return!1;try{return await E.queue({text:he}),!0}catch{return!1}},[E]),O=sy({input:n,setInput:m,sessionId:h,selectedCwd:w,waiting:C,onEnqueue:Y,onSteer:o,onStage:a,tryNativeCommand:i,chatInputRef:t}),[W,ne]=c.useState(null),$=c.useRef(null),Z=c.useCallback(he=>{const de=$.current;if($.current=null,he.length===0)return;const Ne=he.map(Le=>de&&Le.id===de.id?de.content:Le.content).join(`
|
|
56
|
-
|
|
57
|
-
`),Ee=ae.getState().getSession(h).input.trim();m(Ee?`${Ee}
|
|
58
|
-
|
|
59
|
-
${Ne}`:Ne)},[h,m]),[ce,oe]=c.useState(null),se=ce===h&&N,V=c.useRef(null),re=c.useCallback(()=>{V.current=null,oe(null)},[]);c.useEffect(()=>{N||re()},[N,h,re]);const Se=c.useRef(N);c.useEffect(()=>{Se.current=N},[N]);const ke=O.leaveQueueForStop,J=c.useRef(O.editingId);c.useEffect(()=>{J.current=O.editingId},[O.editingId]);const je=c.useCallback(()=>{const he=J.current;if(he!==null){const de=ae.getState().getSession(h).input.trim();de&&($.current={id:he,content:de}),ke()}V.current=h,oe(h),g().then(de=>{Z(de.cancelled),Sb(de.receipt,Se.current)&&re();const Ne=Cb(de.receipt);Ne.message!==null&&!$o(de.receipt)&&(Ne.isFailure?Fe.error(Ne.message):Fe.warning(Ne.message))}).catch(()=>{re()})},[h,g,Z,re,ke]),Ce=c.useCallback(()=>{if(!(V.current===h||se)){if(C.length===0){je();return}ne({sessionId:h,queuedCount:C.length})}},[h,se,C.length,je]),qe=c.useCallback(()=>{V.current===h||se||(ne(null),je())},[h,se,je]);c.useEffect(()=>{(W==null?void 0:W.sessionId)===h&&C.length===0&&ne(null)},[W,h,C.length]);const{messages:ye}=Io(h),pe=Mo(h),Re=c.useMemo(()=>ei(pe,ye),[pe,ye]),ue=Qb(Re),_e=c.useCallback(async he=>{if(h)try{await A.stopTask(h,he)}catch(de){console.error("[chat] Failed to stop task:",de)}},[h,A]),be=c.useCallback(()=>{h&&A.switchSessionProcess(h).catch(()=>{Fe.error("Couldn’t switch. Try again.")})},[h,A]),we=c.useRef(n);c.useEffect(()=>{we.current=n});const ge=c.useCallback(he=>{var Le;const de=we.current,Ne=de.length>0&&!/\s$/.test(de)?" ":"",Ee=`${de}${Ne}${he}`;m(Ee),(Le=t.current)==null||Le.focusAt(Ee.length)},[m,t]);c.useEffect(()=>rd(ge),[ge]);const Ie=!N&&O.editingIndex===null,Ue=iy({defaultText:T,hints:c0,enabled:!e&&Ie&&n===""}),ee=ad(),G=c.useCallback(()=>{s.dismissPalettes(),!(E===null||!E.canSend)&&E.send({text:n})},[s,E,n]),K=c.useCallback(()=>{s.dismissPalettes(),O.handleQueue()},[s,O]),ie=c.useCallback(()=>{s.dismissPalettes(),O.handleSteer()},[s,O]),$e=c.useCallback(()=>{s.dismissPalettes(),O.handleStage()},[s,O]);return r.jsx(jt.Composer,{className:"chat-input-container",onPathDropped:he=>ge(od(he)),inputRef:t,value:n,onChange:s.handleInputChange,onSubmit:G,head:r.jsx(me,{children:N&&r.jsx(Ud,{color:D.color,isTextStreaming:R,edge:"top"})}),asks:v?r.jsx(My,{sessionId:h,activeInteraction:v,pendingApprovals:k,focusedOptionIndex:p,onToolRef:j,onToolDecided:_,queueDepth:O.queue.length,allowsDenyReason:P}):null,overlays:r.jsx(r.Fragment,{children:r.jsxs(me,{children:[s.commands.show&&r.jsx(Oy,{filteredCommands:s.commands.filtered,selectedIndex:s.commands.selectedIndex,onSelect:s.handleCommandSelect}),s.files.show&&r.jsx(Dm,{filteredFiles:s.files.filtered,selectedIndex:s.files.selectedIndex,onSelect:s.handleFileSelect})]})}),queue:r.jsx(me,{children:O.queue.length>0&&r.jsx(Tx,{queue:O.queue,editingId:O.editingId,onEdit:O.handleQueueEdit,onRemove:O.handleQueueRemove,onSend:O.handleQueueSend,onMoveUp:O.handleQueueMoveUp,onSwitchNow:be,statusNote:M?"Waiting for your answer above":((Me=O.queue[0])==null?void 0:Me.waiting)!==void 0?"Sending when the agent is free":"Sending one at a time as the agent finishes"})}),aboveInput:r.jsx(Nx,{tasks:ue,onStopTask:_e}),footer:r.jsx(jt.Footer,{asChild:!0,children:r.jsx(t0,{sessionId:h,sessionStatus:x,isStreaming:N,syncConnectionState:y.connectionState,agentName:S,agentColor:D.color,agentEmoji:D.emoji,agentPath:w??void 0,lineHidden:e})}),input:{isStreaming:N,commandPending:l,...u||d?{canSubmit:!1,canSubmitReason:d?"Check this folder again before you start.":"Checking this folder…"}:{},...I.canSubmit?{}:{canSubmit:!1},onStop:Ce,stopPending:se,onEscape:s.dismissPalettes,onClear:()=>{m(""),s.dismissPalettes()},isPaletteOpen:s.isPaletteOpen,paletteHasResults:s.paletteHasResults,onArrowUp:s.handleArrowUp,onArrowDown:s.handleArrowDown,onCommandSelect:s.handleKeyboardSelect,activeDescendantId:s.activeDescendantId,paletteListboxId:s.paletteListboxId,onCursorChange:s.handleCursorChange,richText:ee,editingQueueItem:O.editingIndex!==null,...O.editingIndex===null?{}:{editingPosition:O.editingIndex+1},queueDepth:O.queue.length,onQueue:K,...X?{onSteer:ie}:{},...B?{onStage:$e}:{},onSaveEdit:O.handleQueueSaveEdit,onCancelEdit:O.handleQueueCancelEdit,onQueueNavigateUp:O.handleQueueNavigateUp,onQueueNavigateDown:O.handleQueueNavigateDown,queueHasItems:O.queue.length>0,contextKey:ti(h,w)??void 0,placeholder:I.placeholder??Iy(O.editingIndex,N,O.queue.length,T),placeholderOverlay:!e&&Ie&&I.canSubmit?r.jsx(Mx,{text:Ue.text,animationKey:Ue.key}):null},children:r.jsx(Ax,{open:(W==null?void 0:W.sessionId)===h,onOpenChange:he=>{he||ne(null)},queuedCount:(W==null?void 0:W.queuedCount)??0,onConfirm:qe})})}const Py=e=>{const t=e;return t.role==="user"?r.jsx(ax,{message:t}):r.jsx(_s,{message:t})};function Ly(e){return r.jsx(_s,{message:e,show:"reply"})}function oi(e){return e.role==="user"&&!e._stagedContext&&!e._chatStop&&!e._directNote&&e.messageType!=="compaction"&&e.messageType!=="local_command_output"}function By(e){const t=[];let n=null,s=null,o=null;for(const a of e){if(oi(a)){n=a.content.trim()||null,s=a.timestamp||null,o=null;continue}a.role!=="assistant"||!Oa(a.parts??[])||(o===null&&(o={key:a.id,prompt:n,startedAt:s,replies:[],live:!1},t.push(o)),o.replies.push(a),a._streaming&&(o.live=!0))}return t}function zy(e){const t=new Map;let n=null;for(const s of e)oi(s)?n=s.timestamp||null:s.role==="assistant"&&n&&t.set(s.id,n);return t}function qy(e,t){if(!e||!t)return null;const n=Date.parse(t)-Date.parse(e);if(!Number.isFinite(n)||n<1e3)return null;const s=Math.floor(n/1e3);if(s<60)return`${s}s`;const o=s%60;return o===0?`${s/60}m`:`${Math.floor(s/60)}m ${o}s`}function Uy(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!n._streaming)return null;if(n.role==="assistant")return n.id}return null}const ns=nn()(e=>({request:null,ask:t=>e({request:{...t}}),consume:()=>e({request:null})}));function ai(e,t){const n=le.getState();n.setActiveRightPanelTab(Qc),n.setRightPanelOpen(!0),ns.getState().ask({sessionId:e,turn:t})}const ii="text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs",li="focus-ring hover:text-foreground inline-flex items-center gap-1 rounded-sm font-medium transition-colors";function Wy({sessionId:e,messageId:t,steps:n,duration:s,describedBy:o}){const a=["Worked"];return n>0&&a.push(`${n} ${n===1?"step":"steps"}`),s&&a.push(s),r.jsxs("div",{className:ii,"data-testid":"dm-worked-line",children:[r.jsx("span",{children:a.join(" · ")}),r.jsxs("button",{type:"button",className:li,"aria-describedby":o,onClick:()=>ai(e,t),children:[r.jsx(Yc,{className:"size-3.5","aria-hidden":!0}),"Show work"]})]})}function Hy({sessionId:e}){const t=qo(e);return r.jsxs("div",{className:ii,"data-testid":"dm-working-line",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"bg-primary size-1.5 shrink-0 rounded-full motion-safe:animate-pulse"}),Xc("streaming",t)]}),r.jsx("button",{type:"button",className:li,onClick:()=>ai(e,"live"),children:"Watch"})]})}function Gy(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&&so(e.author,t.author)&&so(e.feedPosition,t.feedPosition)}function so(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 Vy=c.memo(Ky,Gy);function Ky({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:g,onRetry:m,onSigninComplete:h,onChooseModel:x,inputZoneToolCallId:C=null,textEffect:b,runtimeLabel:y,allowsDenyReason:v,directRoomId:k,fallbackAt:p,foldWork:j=!1,turnStartedAt:_,liveReply:N=!1,feedPosition:R}){var O,W;const w=c.useId(),A=`${w}-author`,F=`${w}-content`,D=c.useRef(null),S=t.position==="first"||t.position==="only",E=e.role==="user",T=E&&e.messageType!=="local_command_output",M=E?(O=e.chatMessages)==null?void 0:O[0]:void 0,I=E&&M===void 0?e.roomMessage:void 0,L=T&&M===void 0&&(I===void 0||((W=I.author)==null?void 0:W.you)===!0)&&e.messageType!=="command"&&e.messageType!=="compaction"&&e.content.trim().length>0,z=e.timestamp||p||"",Q=z?Yt(z):"",X=Q.length>0,B=X?z:void 0,P=c.useCallback(()=>{var ne;return(ne=D.current)==null?void 0:ne.focus()},[]),Y=j&&e.role==="assistant";return r.jsx(_a,{value:{sessionId:s,isStreaming:a,isLatestWidgetMessage:i,isFinalMessage:l,activeToolCallId:u,onToolRef:d,focusedOptionIndex:f,onToolDecided:g,onRetry:m,onSigninComplete:h,onChooseModel:x,inputZoneToolCallId:C,textEffect:b,runtimeLabel:y,allowsDenyReason:v},children:r.jsxs(nt.Root,{ref:D,role:T?"user":"assistant",position:t.position,isNew:o,"data-testid":"message-item","data-role":e.role,...S?{"aria-labelledby":A}:{"aria-label":X?`${n.displayName}, ${Q}`:n.displayName},"aria-describedby":F,...Yu(R),children:[r.jsx(nt.Gutter,{author:n,at:B}),r.jsxs(nt.Body,{children:[r.jsx(nt.Author,{id:A,author:n,at:B,...M?{mark:r.jsx(Sa,{stamp:M}),className:"flex-wrap gap-y-0.5"}:I&&I.roomId!==k?{mark:r.jsx(Sp,{stamp:I}),className:"flex-wrap gap-y-0.5"}:{}}),r.jsx(nt.Content,{id:F,children:Y?Ly(e):Py(e,{rowId:e.id})}),Y&&N&&r.jsx(Hy,{sessionId:s}),Y&&!N&&Oa(e.parts??[])&&r.jsx(Wy,{sessionId:s,messageId:e.id,steps:Kh(e.parts??[]),duration:qy(_,e.timestamp),describedBy:F}),L&&r.jsx(nt.Actions,{runWith:{prompt:e.content,sessionId:s},onExit:P})]})]})})}function Qy({loading:e,onLoad:t}){return r.jsx("div",{className:"flex justify-center px-4 py-3",children:r.jsxs(fe,{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(He,{size:"xs"}),e?"Loading earlier messages…":"Earlier messages"]})})}const ro="Conversation",Xy={kind:"notice",id:"session-load-earlier",at:"",body:null},Yy=[];function Jy(e){for(let t=e.length-1;t>=0;t--)if(e[t].content.includes(fd))return t;return-1}function Zy({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:g,inputZoneToolCallId:m=null,textEffect:h,runtimeLabel:x,allowsDenyReason:C,landOnRow:b,foldFirstPrompt:y=!1,directLog:v,directMessage:k=null}){const p=ht(i),j=ht(u),_=ht(d),N=ht(f),R=ht(g),w=Op(t,e),A=w.messages,{stops:F}=ja(t),D=!w.canLoadEarlier,S=c.useMemo(()=>Cy(A,v,D),[A,v,D]),E=c.useMemo(()=>yp(S.messages,F),[S.messages,F]),T=c.useMemo(()=>{let ee=0;return E.map(G=>G._chatStop||G._directNote?-1:ee++)},[E]),M=Lo(null);M.read()===null&&A.length>0&&M.write(w.messagesBefore+A.length);const I=c.useMemo(()=>Jy(E),[E]),L=c.useMemo(()=>y&&!w.canLoadEarlier?E.findIndex(ee=>ee.role==="user"&&ee.messageType===void 0&&!ee._stagedContext&&!ee._chatStop&&!ee._directNote):-1,[y,w.canLoadEarlier,E]),z=rn(t),Q=le(ee=>ee.selectedCwd),X=cn(t),{data:B}=xs(Q),P=(k==null?void 0:k.agent)??null,Y=(k==null?void 0:k.settled)===!0,[O]=c.useState(()=>new Map),W=c.useCallback(ee=>{if(!Y||ee.timestamp||!ee._streaming)return;const G=O.get(ee.id);if(G)return G;const K=new Date().toISOString();return O.set(ee.id,K),K},[Y,O]);c.useEffect(()=>{const ee=new Set(E.map(G=>G.id));for(const G of O.keys())ee.has(G)||O.delete(G)},[E,O]);const ne=(k==null?void 0:k.humanName)??null,$=(k==null?void 0:k.settled)===!0,Z=c.useMemo(()=>$?zy(E):null,[$,E]),ce=c.useMemo(()=>$?Uy(E):null,[$,E]),oe=c.useMemo(()=>({agent:P??(B?{id:B.id,displayName:ln(B),...Dt(B)}:null),runtime:X,...ne?{humanName:ne}:{}}),[B,X,P,ne]),se=A[A.length-1],V=(se==null?void 0:se.role)==="assistant"?se:void 0,re=dy({messageId:V==null?void 0:V.id,text:(V==null?void 0:V.content)??"",isStreaming:V!==void 0&&o}),Se=Hb((se==null?void 0:se.parts)??Yy,t),{lastSeenMessageId:ke,unreadFromStart:J,markSeen:je,isHydrated:Ce}=Lf(t,A,w.messagesBefore),[qe,ye]=c.useState(()=>Date.now()),pe=c.useRef(null);c.useLayoutEffect(()=>{const ee=Date.now(),G=new Date(ee).toDateString();if(pe.current===null){pe.current=G;return}pe.current!==G&&(pe.current=G,ye(ee))},[E]);const Re=c.useCallback(ee=>zm(ee,oe),[oe]),[ue]=c.useState(Um),_e=c.useMemo(()=>Wm(E,{resolveAuthor:Re,now:qe,lastSeenMessageId:S.lastSeenBeforeUnread??ke,unreadFromStart:S.unreadFromStart||J,cache:ue}),[E,Re,qe,ke,J,S,ue]),[be]=c.useState(()=>new WeakMap),we=c.useMemo(()=>{const ee=_e.map(G=>{const K=be.get(G);if(K)return K;const ie=G.kind==="day-divider"?{kind:"day-divider",id:G.key,label:G.label}:G.kind==="unread-divider"?{kind:"unread-divider",id:G.key}:{kind:"message",id:G.key,payload:G.message,grouping:G.grouping,author:G.author,at:G.message.timestamp};return be.set(G,ie),ie});return w.canLoadEarlier?[Xy,...ee]:ee},[_e,be,w.canLoadEarlier]),ge=w.canLoadEarlier?1:0,Ie=c.useCallback((ee,G)=>{var Ee,Le;if(ge===1&&G.index===0)return r.jsx(Qy,{loading:w.isLoadingEarlier,onLoad:w.loadEarlier});const K=_e[G.index-ge];if(K.kind==="day-divider")return r.jsx(nd,{label:K.label});if(K.kind==="unread-divider")return r.jsx(sd,{});const{message:ie,messageIndex:$e}=K;if(ie._stagedContext)return r.jsx(Kp,{content:ie.content});if(ie._chatStop)return r.jsx("div",{className:"px-4 py-1",children:r.jsx(Dp,{notice:ie._chatStop})});if($e===L)return r.jsx(ip,{content:((Le=(Ee=ie.chatMessages)==null?void 0:Ee[0])==null?void 0:Le.text)??ie.content});const Pe=T[$e]??$e,Me=Pe>=0&&Pe===A.length-1,he=Me&&ie.role==="assistant",de=I===-1||$e>=I,Ne=M.read();return r.jsx(Vy,{message:ie,grouping:K.grouping,author:K.author,sessionId:t,directRoomId:v==null?void 0:v.roomId,fallbackAt:W(ie),foldWork:$,turnStartedAt:Z==null?void 0:Z.get(ie.id),liveReply:ce===ie.id,isNew:Ne!==null&&w.messagesBefore+Pe>=Ne,isStreaming:he&&o,isLatestWidgetMessage:de,isFinalMessage:Me,activeToolCallId:a,onToolRef:p,focusedOptionIndex:l,onToolDecided:j,onRetry:_,onSigninComplete:N,onChooseModel:R,inputZoneToolCallId:m,textEffect:h,runtimeLabel:x,allowsDenyReason:C,feedPosition:{index:Pe+1,total:A.length}})},[_e,ge,w.isLoadingEarlier,w.loadEarlier,w.messagesBefore,A.length,T,I,L,t,v==null?void 0:v.roomId,W,$,Z,ce,M,o,a,p,l,j,_,N,R,m,h,x,C]),Ue=z&&z.kind!=="first-message"&&z.fired&&!z.greetingFailed&&s?z:null;return r.jsx(jt.Timeline,{conversationId:t,label:ro,rows:we,renderRow:Ie,landOn:"unread",landingReady:Ce&&!w.isSeeking&&((v==null?void 0:v.ready)??!0),...b===void 0?{}:{landOnRow:b},onReachedBottom:je,transcriptAnnouncement:re,approvalAnnouncement:Se,className:"pt-12 [--conversation-thumb-top:3rem]",loading:n?r.jsx(Ju,{label:ro,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(ya,{}),"Loading chat…"]})}):void 0,empty:r.jsx("div",{className:"flex h-full items-center justify-center",children:r.jsx(ep,{birthRecord:z,firstLightRecord:Ue})}),"data-testid":"message-list",feedTestId:"transcript-feed"})}function ek({sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s=!1,launchSeed:o,onLaunchConsumed:a,landOnRow:i}){var Is,$s,Ps;const[,l]=Nt(),u=us(),d=c.useRef(null),f=c.useRef(null),g=Sy(e),m=Db(e),h=qo(e??""),x=_b(),{play:C}=fu(),[b]=zo(),{data:y,isPending:v,isError:k,refetch:p}=xs(b),{sessions:j}=rs(),_=e!==null&&!j.some(q=>q.id===e),N=Jc(e),R=Ob(),w=c.useCallback(async q=>{let Te=q;if(R.hasPendingFiles){const Ze=await R.uploadAndGetPaths(),Ls=b?Ze.map(Ot=>Ot.startsWith(b)?Ot.slice(b.length).replace(/^\//,""):Ot):Ze;Ls.length>0&&(Te=`Please read the following uploaded file(s):
|
|
60
|
-
${Ls.map(yi=>`- ${yi}`).join(`
|
|
61
|
-
`)}
|
|
62
|
-
|
|
63
|
-
${Te}`),R.clearFiles()}return Te},[R,b]),A=c.useCallback(q=>{m.handleTaskEvent(q);const Te=m.tasks.map(Ze=>Ze.id===q.task.id?{...Ze,...q.task}:Ze);x.handleTaskEvent(q,Te)},[m,x]);c.useCallback(q=>{l(q),u.invalidateQueries({queryKey:Qe.bySession(q)})},[l,u]);const F=c.useCallback(q=>{l(q,{replace:!0}),u.invalidateQueries({queryKey:Qe.bySession(q)})},[l,u]),D=c.useCallback(q=>{l(crypto.randomUUID(),{continuedFrom:q??void 0,draft:!0})},[l]),S=Ao(e??""),E=an(S.runtime),T=S.runtime?At(S.runtime).label:"",M=((Is=E==null?void 0:E.permissionModes)==null?void 0:Is.denyReason)??!0,I=c.useMemo(()=>Va(E==null?void 0:E.commandIntents,T),[E,T]),L=c.useRef(null),z=c.useCallback(()=>{var q;return(q=L.current)==null?void 0:q.call(L)},[]),{messages:Q,input:X,setInput:B,handleSubmit:P,submitContent:Y,enqueueContent:O,steerContent:W,addContextContent:ne,status:$,error:Z,stop:ce,isLoadingHistory:oe,hydrated:se,sessionStatus:V,streamStartTime:re,estimatedTokens:Se,isTextStreaming:ke,isWaitingForUser:J,waitingType:je,activeInteraction:Ce,pendingInteractions:qe,markToolCallResponded:ye,systemStatus:pe,operationProgress:Re,promptSuggestions:ue,syncConnectionState:_e,retryMessage:be,tryNativeCommand:we,commandPending:ge}=vb(e,{transformContent:w,onTaskEvent:A,onSessionIdChangeReplace:F,startFreshSession:D,compactIntent:I,launchRuntime:t,...y&&b?{agentPath:b}:{},agentLookupPending:b!==null&&v,agentLookupFailed:b!==null&&k,takeSeedContext:z,onStreamingDone:c.useCallback(()=>{C("turn-end"),u.invalidateQueries({queryKey:["commands"]})},[C,u])}),Ie=c.useCallback(q=>Y(q,{clearInput:!0}),[Y]),{permissionMode:Ue,permissionModeKnown:ee}=Fo(e,V,$==="streaming"),G=Wu(e,S.runtime,ee?Ue:void 0),K=Zc(q=>q.setOpen);c.useEffect(()=>{K(!1)},[e,K]);const{handleToolRef:ie,focusedOptionIndex:$e}=Tb(Ce);Mb($,J,ke),c.useEffect(()=>{var q;(q=d.current)==null||q.focusUnlessTouch()},[e]);const Pe=c.useCallback(()=>{var q;(q=d.current)==null||q.focusUnlessTouch()},[]);$b({sessionId:e,prompt:n,autoSend:s,input:X,setInput:B,messageCount:Q.length,hydrated:se,status:$,submitBlocked:_&&b!==null&&(v||k),submit:P,onSeeded:Pe,onConsumed:a});const Me=zb({sessionId:e,seed:o,messageCount:Q.length,hydrated:se,onConsumed:a});c.useEffect(()=>{L.current=Me},[Me]);const he=S.runtime?fs(S.runtime):void 0,{data:de}=mu(b,e??void 0,S.runtime??void 0),Ne=c.useMemo(()=>zx((de==null?void 0:de.commands)??[],{commandIntents:E==null?void 0:E.commandIntents,runtimeLabel:T}),[de,E,T]),{data:Ee}=Tm(b),Le=c.useMemo(()=>Ee!=null&&Ee.files?Hm(Ee.files):[],[Ee]),ci=Rb({input:X,setInput:B,commands:Ne,fileEntries:Le}),ws=c.useCallback(()=>{const q=[...Q].reverse().find(Te=>Te.role==="user");q!=null&&q.content&&Y(q.content)},[Q,Y]),Ns=rn(e??""),ui=c.useCallback(()=>{const q=Gm(Q,Ns);q&&be(q)},[Q,Ns,be]),Es=$==="idle"&&ue.length>0&&X.length===0,di=eu("chat.suggestion-chips"),fi=Nm(e??""),mi=qb($,Z,Q,fi),pi=c.useMemo(()=>Q.some(q=>q.role==="user"),[Q]),Ds=c.useCallback(q=>{var Te;B(q),(Te=d.current)==null||Te.focus()},[B]),Mt=tu(e??""),hn=Po(e??""),hi=c.useMemo(()=>Yb(Mt,hn),[Mt,hn]),Ts=(Ps=($s=gs(e??""))==null?void 0:$s.lastError)==null?void 0:Ps.category,gn=Ym(),As=c.useCallback(()=>{const q=e??"";if(gn.claimedElsewhere(q))return!1;const Te=Km({messages:Q,status:$,lastErrorCategory:Ts,queuedCount:Mt.length,draft:ae.getState().getSession(q).input});return Te===null?!1:(gn.claim(q),Y(Te),!0)},[Q,$,Ts,Mt.length,e,Y,gn]),pt=Dy(e,y),Fs=hy(f,pt.directMessage!==null),gi=Ty({sessionId:e??"",placeholder:pt.placeholder,submit:Ie,enqueue:O,files:R}),{eligible:Rs,allow:Ms,notNow:Os}=Mf($==="streaming"),xi=c.useMemo(()=>[{id:"prompt-suggestions",show:Es,render:()=>r.jsx(iu,{suggestions:ue,onChipClick:Ds})},{id:"permission-primer",show:Rs,render:()=>r.jsx(Rf,{onAllow:Ms,onNotNow:Os})},{id:"read-only-mode",show:G.eligible,render:()=>r.jsx(Hu,{runtimeLabel:G.runtimeLabel,onShown:G.markShown,onDismiss:G.dismiss})}],[Es,ue,Ds,Rs,Ms,Os,G]),bi=wy({asks:Ho,status:$,streamStartTime:re,estimatedTokens:Se,permissionMode:Ue,isWaitingForUser:J??!1,waitingType:je??"approval",operationProgress:Re,systemStatus:pe,activity:h,quietNumbers:pt.quietTurnNumbers});return r.jsx(jt.Root,{surface:"session",capabilities:si,target:gi,children:r.jsxs("div",{ref:f,"data-testid":"chat-panel","data-turn-status":$,"data-turn-lifecycle":hn??void 0,className:"flex h-full w-full flex-col",children:[r.jsx(np,{sessionId:e}),r.jsx(op,{startedBy:N,modes:E==null?void 0:E.permissionModes.values}),r.jsx(Zy,{messages:Q,sessionId:e,isLoadingHistory:oe,hydrated:se,isTextStreaming:ke,activeToolCallId:(Ce==null?void 0:Ce.toolCallId)??null,onToolRef:ie,focusedOptionIndex:$e,onToolDecided:ye,onRetry:ws,onSigninComplete:As,onChooseModel:Fs,inputZoneToolCallId:(Ce==null?void 0:Ce.toolCallId)??null,runtimeLabel:he,allowsDenyReason:M,...i===void 0?{}:{landOnRow:i},foldFirstPrompt:N!==null,directLog:g,directMessage:pt.directMessage}),r.jsx(a0,{terminalReason:V==null?void 0:V.terminalReason}),r.jsx(jt.LiveLane,{state:bi,scope:"session"}),r.jsx(pu,{candidates:xi,ready:se,name:"session-bottom-slot",className:"px-4 pb-2"}),$==="idle"&&di.map(q=>r.jsx(q.component,{},q.id)),r.jsx(Ip,{celebration:x.activeCelebration,onComplete:x.clearCelebration}),r.jsx(hx,{tasks:m.tasks,taskMap:m.taskMap,activeForm:m.activeForm,isCollapsed:m.isCollapsed,onToggleCollapse:m.toggleCollapse,celebratingTaskId:x.celebratingTaskId,onCelebrationComplete:x.clearCelebration,statusTimestamps:m.statusTimestamps}),mi&&r.jsx(l0,{sessionId:e,onRetry:pi?ws:void 0,onSigninComplete:As,onChooseModel:Fs}),Z&&r.jsx(Ay,{error:Z,composerAgent:y,onRetry:ui}),_&&k&&r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(dn,{heading:"Couldn’t check this folder",message:"DorkOS couldn’t tell if an agent owns this folder. Try again.",onRetry:()=>void p()})}),e&&r.jsx(vm,{sessionId:e,onSend:q=>void Y(q)}),r.jsx($y,{asDirectMessage:pt.directMessage!==null,chatInputRef:d,input:X,autocomplete:ci,steerContent:W,addContextContent:ne,tryNativeCommand:we,commandPending:ge,agentLookupPending:_&&b!==null&&v,agentLookupError:_&&b!==null&&k,status:$,stop:ce,setInput:B,sessionId:e??"",sessionStatus:V,waiting:hi,interaction:{active:Ce,pendingApprovals:qe.filter(q=>q.interactiveType==="approval"),focusedOptionIndex:$e,onToolRef:ie,onToolDecided:ye},sync:{connectionState:_e}})]})})}function tk(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}`,We.getState().seek(e,t),()=>{const i=We.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=We.getState().seeks[e]===t;if(s.current!==n||i)return;o.current=n;const l=((d=We.getState().sessions[e])==null?void 0:d.earlier)??[],u=De.getState().getSession(e).messages;return ga(Ca([...l,...u],t)??t)},[n,t,e]);return n===null?void 0:a}function Ok(){const[e]=Nt();of(e);const{runtime:t,prompt:n,send:s,seed:o,message:a}=lo(),i=nu(),l=tk(e,a),{data:u}=su(e,{enabled:!1,select:g=>g.title}),d=Oo(e);pd(e,{canonical:d===null}),hu();const f=c.useCallback(()=>{i==null||i({search:g=>({...g,prompt:void 0,send:void 0,seed:void 0}),replace:!0})},[i]);return r.jsxs(r.Fragment,{children:[r.jsx(ru,{children:u!=null&&u.trim()?u:"Chat"}),r.jsx(ek,{sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s==="1",launchSeed:o,onLaunchConsumed:f,...l===void 0?{}:{landOnRow:l}})]})}const nk=48,sk="[&_[data-testid=tool-call-card]]:opacity-100 [&_[data-testid=tool-call-card]_.font-mono]:text-muted-foreground",ss="Now · working";function Ik({sessionId:e,messages:t,agentName:n,showSessions:s,onOpenSession:o,working:a=!1,notice:i=null}){const l=c.useMemo(()=>By(t),[t]),u=c.useRef(null),d=ns(y=>y.request),f=ns(y=>y.consume),g=l.some(y=>y.live),m=Un(l),h=c.useRef(!0),x=c.useCallback(()=>{const y=u.current;y&&(h.current=y.scrollHeight-y.scrollTop-y.clientHeight<=nk)},[]),C=c.useRef(e);c.useLayoutEffect(()=>{C.current!==e&&(C.current=e,h.current=!0);const y=u.current;y&&h.current&&(y.scrollTop=y.scrollHeight)});const b=`${l.length}|${g}`;return c.useEffect(()=>{var j,_,N;const y=u.current;if(!y||!d)return;if(d.sessionId!==e){f();return}const v=m.read(),k=d.turn==="live"?((j=v.find(R=>R.live))==null?void 0:j.key)??"live":(_=v.find(R=>R.replies.some(w=>w.id===d.turn)))==null?void 0:_.key,p=Array.from(y.querySelectorAll("[data-work-turn]")).find(R=>R.dataset.workTurn===k);!p&&v.length===0&&d.turn!=="live"||(p?((N=p.scrollIntoView)==null||N.call(p,{block:"start"}),p.focus({preventScroll:!0})):y.focus({preventScroll:!0}),h.current=d.turn==="live"||!p,h.current&&(y.scrollTop=y.scrollHeight),f())},[d,e,b,m,f]),r.jsxs("div",{ref:u,onScroll:x,tabIndex:-1,"data-testid":"work-panel",className:"flex h-full min-w-0 flex-col gap-3 overflow-y-auto p-3 outline-none",children:[r.jsx(rk,{sessionId:e,agentName:n,showSessions:s,onOpenSession:o}),i!==null?r.jsx(oo,{children:i}):r.jsxs(r.Fragment,{children:[l.length===0&&!a&&r.jsx(oo,{children:"No steps yet."}),l.map(y=>r.jsx(ak,{turn:y,sessionId:e},y.key)),a&&!g&&e!==null&&r.jsx(lk,{})]})]})}function rk({sessionId:e,agentName:t,showSessions:n,onOpenSession:s}){return!n||e===null?r.jsxs("div",{className:"bg-muted/50 text-muted-foreground rounded-md px-3 py-2 text-xs",children:["Every step ",t??"the agent"," took, turn by turn."]}):r.jsx(ok,{sessionId:e,onOpenSession:s})}function ok({sessionId:e,onOpenSession:t}){const{model:n,contextPercent:s,runtime:o}=Ro(e),{data:a}=sn({sessionId:e,runtime:o??void 0}),i=["Session"];return n&&i.push(Gu(n,a??[])),typeof s=="number"&&i.push(`${Math.round(s)}% context`),r.jsxs("div",{"data-testid":"work-session-line",className:"bg-muted/50 text-muted-foreground flex items-center gap-2 rounded-md px-3 py-2 text-xs",children:[r.jsx(ou,{className:"size-3.5 shrink-0","aria-hidden":!0}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:i.join(" · ")}),r.jsxs("button",{type:"button",onClick:t,className:"focus-ring hover:text-foreground inline-flex shrink-0 items-center gap-0.5 rounded-sm font-medium transition-colors",children:["Open session",r.jsx(au,{className:"size-3.5","aria-hidden":!0})]})]})}function ak({turn:e,sessionId:t}){const n=e.startedAt?Yt(e.startedAt):"",s=e.live?ss:[n,e.prompt?`“${e.prompt}”`:""].filter(Boolean).join(" · ")||"A turn";return r.jsxs("section",{"data-work-turn":e.key,"data-live":e.live||void 0,"aria-label":s,tabIndex:-1,className:"focus-ring rounded-lg border px-3 py-2",children:[r.jsx("h3",{className:"text-foreground line-clamp-2 text-xs font-medium",children:s}),r.jsx("div",{"data-slot":"work-steps",className:sk,children:e.replies.map(o=>r.jsx(ik,{reply:o,sessionId:t},o.id))})]})}const ik=c.memo(function({reply:t,sessionId:n}){const s=t._streaming===!0,o=c.useMemo(()=>({sessionId:n,isStreaming:s,isLatestWidgetMessage:!0,isFinalMessage:!1,activeToolCallId:null,onToolRef:void 0,focusedOptionIndex:-1,onToolDecided:void 0,inputZoneToolCallId:null}),[n,s]);return r.jsx(_a,{value:o,children:r.jsx(_s,{message:t,show:"work"})})});function lk(){return r.jsxs("section",{"data-work-turn":"live","data-live":!0,"aria-label":ss,tabIndex:-1,className:"focus-ring rounded-lg border px-3 py-2",children:[r.jsx("h3",{className:"text-foreground text-xs font-medium",children:ss}),r.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Waiting for the first step"})]})}function oo({children:e}){return r.jsx("p",{className:"text-muted-foreground px-1 text-xs",children:e})}export{Ok as S,Ik as W,si as a,$y as b,Vy as c,Zy as d,Fp as m,ei as s,Ty as u};
|