dorkos 0.124.0 → 0.124.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +935 -551
- package/dist/browser/native/package-manifest.json +1 -1
- package/dist/browser/source-manifest.json +1 -1
- package/dist/client/assets/{AboutPage-BH8Ndn3e.js → AboutPage-DHaZvsJE.js} +1 -1
- package/dist/client/assets/{ActivityErrorState-K5Mew9EX.js → ActivityErrorState-BP-qFk2S.js} +1 -1
- package/dist/client/assets/{ActivityPage-BB20L5HU.js → ActivityPage-Bme3TzdQ.js} +1 -1
- package/dist/client/assets/{ActivityRow-C5O7rnmS.js → ActivityRow-BRZyW9MA.js} +1 -1
- package/dist/client/assets/{AdapterIcon-Bmybvrzb.js → AdapterIcon-BcfquTja.js} +1 -1
- package/dist/client/assets/{AdapterSetupWizard-CkdV7Hhh.js → AdapterSetupWizard-B4I23pBg.js} +1 -1
- package/dist/client/assets/{AgentOptionRow-BA2cDa7r.js → AgentOptionRow-Cb34LtmH.js} +1 -1
- package/dist/client/assets/{AgentPicker-CsIIPGZJ.js → AgentPicker-ouNRFSDh.js} +1 -1
- package/dist/client/assets/{AgentRequestCard-0fOxvaoe.js → AgentRequestCard-B6MHIsxa.js} +2 -2
- package/dist/client/assets/{AppearancePage-XOjkkoli.js → AppearancePage-CutehigK.js} +1 -1
- package/dist/client/assets/ApplyToOverridesDialog-B-wIUI27.js +1 -0
- package/dist/client/assets/{AttentionSignalRow-CjjZobp7.js → AttentionSignalRow-B1aMjgX_.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-9TVHyRPJ.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-CdWF4WLz.js} +1 -1
- package/dist/client/assets/{BindingDialog-DLoAQauL.js → BindingDialog-BAdueON5.js} +1 -1
- package/dist/client/assets/{BlintzCanvas-CYHsXAcY.js → BlintzCanvas-b30dG4gx.js} +3 -3
- package/dist/client/assets/{CanvasCsvContent--Gr7Fe_U.js → CanvasCsvContent-DGHgSikG.js} +1 -1
- package/dist/client/assets/{CanvasFileContent-estXyAbr.js → CanvasFileContent-D1bFaUeh.js} +2 -2
- package/dist/client/assets/{CanvasModel3dContent-CkOo930M.js → CanvasModel3dContent-dST7g1v2.js} +2 -2
- package/dist/client/assets/{ChatAppsOff-D4L1zJVN.js → ChatAppsOff-DiObvmJS.js} +1 -1
- package/dist/client/assets/{CodeMirrorDiff-DY_6ju-z.js → CodeMirrorDiff-BncI1OY1.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-BUoDBsBv.js → CodeMirrorEditor-DV6psv19.js} +1 -1
- package/dist/client/assets/{CommitmentList-wDkcVP9c.js → CommitmentList-Dx_Ek_Gl.js} +1 -1
- package/dist/client/assets/{CommitmentsPage-CzSM6b8R.js → CommitmentsPage-Bca8NMUa.js} +1 -1
- package/dist/client/assets/{ComputerResourceView-cERD9H2L.js → ComputerResourceView-DNVNFTdn.js} +1 -1
- package/dist/client/assets/{ComputerViewer-rMcfbk2_.js → ComputerViewer-D8SxJdMm.js} +1 -1
- package/dist/client/assets/{ConnectionAccessLists-f7QeQbQo.js → ConnectionAccessLists-Bhj1YT15.js} +1 -1
- package/dist/client/assets/{ConnectionsPage-BmjtA6pw.js → ConnectionsPage-B20JZxoK.js} +1 -1
- package/dist/client/assets/{ConventionPage-CH-ah6nI.js → ConventionPage-De645wxU.js} +1 -1
- package/dist/client/assets/{ExtensionPageRoute-CJIxa6ST.js → ExtensionPageRoute-nTeiOBRQ.js} +1 -1
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BP7EJ2JL.js → FloatingTanStackRouterDevtools-CqogiFob-DM79UITv.js} +1 -1
- package/dist/client/assets/HandlePage-B08V-om7.js +1 -0
- package/dist/client/assets/{HeartbeatPage-BUsf-qrU.js → HeartbeatPage-CBoUxz6t.js} +1 -1
- package/dist/client/assets/{KeyEntry-C2kWdN8q.js → KeyEntry-Cug8ocpX.js} +1 -1
- package/dist/client/assets/{LexicalField-CR8ulsI_.js → LexicalField-Bv_ogmAq.js} +1 -1
- package/dist/client/assets/{ManagesPage-DTtsIOGi.js → ManagesPage-DfJBQKK3.js} +1 -1
- package/dist/client/assets/{Marketplace-iaV5XAzv.js → Marketplace-swCVUbdY.js} +2 -2
- package/dist/client/assets/{MarketplaceSourcesView-6tgzUfFj.js → MarketplaceSourcesView-CDZDChpV.js} +1 -1
- package/dist/client/assets/{McpAppFrame-C7eYYdI9.js → McpAppFrame-BM9cNPPd.js} +1 -1
- package/dist/client/assets/{McpSigninBody-BDyGbJ7I.js → McpSigninBody-DKyUKrEE.js} +1 -1
- package/dist/client/assets/{Model3dViewer-BujDNuVS.js → Model3dViewer-rXSL5y2P.js} +1 -1
- package/dist/client/assets/NamePage-JwMDK1JD.js +1 -0
- package/dist/client/assets/{NewDirectMessageMenu-D4e-z2Jt.js → NewDirectMessageMenu-GCEMS5oV.js} +1 -1
- package/dist/client/assets/{NotificationsPage-CkDeTaJp.js → NotificationsPage-DSWsOVLa.js} +1 -1
- package/dist/client/assets/{OpenMeshSwitch-CtbOt3r5.js → OpenMeshSwitch-BTuctDj4.js} +1 -1
- package/dist/client/assets/{OperatorIdentityForm-Vr4qZnmM.js → OperatorIdentityForm-ODDMd2YN.js} +1 -1
- package/dist/client/assets/PermissionHistory-41a58Se7.js +1 -0
- package/dist/client/assets/{PermissionsPage-f4QaX8oM.js → PermissionsPage-DefmymZ6.js} +1 -1
- package/dist/client/assets/{PersonalityPopover-BkZruwF-.js → PersonalityPopover-7zPVBI1I.js} +1 -1
- package/dist/client/assets/PhotoPage-DlOVhkW9.js +1 -0
- package/dist/client/assets/{PreviewRefusedNotice-BXC2K0tx.js → PreviewRefusedNotice-CwGlBJ7U.js} +1 -1
- package/dist/client/assets/{ProfileFields-BebX5oiv.js → ProfileFields-DVMkpJSb.js} +1 -1
- package/dist/client/assets/{ProfilePanelContainer-DZoL65zQ.js → ProfilePanelContainer-RrhoPD3T.js} +1 -1
- package/dist/client/assets/{ProfileRolePicker-D9H7wsuT.js → ProfileRolePicker-CXRVBCAu.js} +1 -1
- package/dist/client/assets/{PromptSuggestionChips-B5fDmc-g.js → PromptSuggestionChips-bBroJdTi.js} +1 -1
- package/dist/client/assets/{ReportsToPopover-uVYhSqj7.js → ReportsToPopover-CfPatsWM.js} +1 -1
- package/dist/client/assets/{RoomSurface-Bg5WV4Ep.js → RoomSurface-CdgCdV6h.js} +11 -11
- package/dist/client/assets/{RoomsPage-yflYFulU.js → RoomsPage-C3dDp1Mb.js} +1 -1
- package/dist/client/assets/{RunsOnPopover-DtGrX1Vq.js → RunsOnPopover-BcKjfQi-.js} +1 -1
- package/dist/client/assets/{RuntimeConnectFlow-DjReuQ-T.js → RuntimeConnectFlow-DCIRnvOH.js} +1 -1
- package/dist/client/assets/{RuntimeSetupDialog-Cr4GRi8c.js → RuntimeSetupDialog-Bg-0b-LC.js} +1 -1
- package/dist/client/assets/SeenDevices-nMsGUQTv.js +19 -0
- package/dist/client/assets/{SessionsPage-BWu-en78.js → SessionsPage-Cqfx4FGW.js} +1 -1
- package/dist/client/assets/SettingsDialog-C8r2igJ_.js +12 -0
- package/dist/client/assets/{SkillsPage-BdUb9SZy.js → SkillsPage-BleHQavF.js} +1 -1
- package/dist/client/assets/{TaskDialogWrapper-qYJPEoSR.js → TaskDialogWrapper-BhTEvf-u.js} +1 -1
- package/dist/client/assets/{TasksEmptyState-Bgcg9vxF.js → TasksEmptyState-Bprx1k8M.js} +2 -2
- package/dist/client/assets/{TasksPage-Ch5W2WQS.js → TasksPage-Dub39yEJ.js} +1 -1
- package/dist/client/assets/{TeamComputerEntry-CPwSIMRw.js → TeamComputerEntry-CJ-NG0u5.js} +1 -1
- package/dist/client/assets/ToolsPage-IsD6M-ZW.js +2 -0
- package/dist/client/assets/{TopologyGraph-I4_mkMHM.js → TopologyGraph-CwyasvFI.js} +14 -14
- package/dist/client/assets/{TourHost-BPaSwh9I.js → TourHost-BYfztuPb.js} +1 -1
- package/dist/client/assets/{UnlinkDialog-BUWZUu5P.js → UnlinkDialog-BKhgxVdF.js} +1 -1
- package/dist/client/assets/{WidgetErrorCard-cS8yMCxU.js → WidgetErrorCard-1NyzIJBj.js} +6 -6
- package/dist/client/assets/_shell-Ct2Bz7D0.js +80 -0
- package/dist/client/assets/{_shell._home-DCA5k-jb.js → _shell._home-xWj7wO5z.js} +1 -1
- package/dist/client/assets/{_shell._home.activity-BX4nFLna.js → _shell._home.activity-BqcLoaB1.js} +1 -1
- package/dist/client/assets/{_shell._home.index-C8t8cw72.js → _shell._home.index-D4sQsKKk.js} +1 -1
- package/dist/client/assets/{_shell._home.tasks-BgUeEvhK.js → _shell._home.tasks--UhQB6h3.js} +1 -1
- package/dist/client/assets/{_shell._home.workspaces-BPBdnkRt.js → _shell._home.workspaces-BPFD8Of2.js} +1 -1
- package/dist/client/assets/{_shell.channels-CX4kki7G.js → _shell.channels-CnFdvRzc.js} +4 -4
- package/dist/client/assets/{_shell.connections-0vP7g7E4.js → _shell.connections-Ik01wS5M.js} +1 -1
- package/dist/client/assets/{_shell.feedback-requests-TsuaO4eR.js → _shell.feedback-requests-Czu42kzo.js} +1 -1
- package/dist/client/assets/_shell.marketplace-Cezv-i16.js +1 -0
- package/dist/client/assets/_shell.marketplace_.sources-BTENmr4W.js +1 -0
- package/dist/client/assets/_shell.session-BjevHF_O.js +63 -0
- package/dist/client/assets/{_shell.team-Bm6cOBhR.js → _shell.team-UfaJqohh.js} +3 -3
- package/dist/client/assets/_shell.x._extensionId-0OO_Xr72.js +1 -0
- package/dist/client/assets/_shell.x._extensionId_._-0OO_Xr72.js +1 -0
- package/dist/client/assets/{abnfDiagram-WEYOIA3C-CrvoN15x.js → abnfDiagram-WEYOIA3C-oxkfGyl6.js} +1 -1
- package/dist/client/assets/{access-copy-B3yNZ7Gz.js → access-copy-Dggxx2cX.js} +1 -1
- package/dist/client/assets/{arc-CuT6QA_y.js → arc-CqQdP0Qe.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZHVYKT53-CPXCZ9H4.js → architectureDiagram-ZHVYKT53-89xM7zJD.js} +1 -1
- package/dist/client/assets/{banner-DRumuw3F.js → banner-DqJ2pM0Y.js} +1 -1
- package/dist/client/assets/{blockDiagram-RJAE7QA3-CM0rka9p.js → blockDiagram-RJAE7QA3-CcxwDmZC.js} +1 -1
- package/dist/client/assets/{c4Diagram-XDPPPE54-D4j2cXRy.js → c4Diagram-XDPPPE54-DCIhIyXa.js} +1 -1
- package/dist/client/assets/{card-B3CtfC3R.js → card-DT-vFAns.js} +1 -1
- package/dist/client/assets/channel-Ngk70nQZ.js +1 -0
- package/dist/client/assets/{chunk-2E7WHVMD-KGyqhVpO.js → chunk-2E7WHVMD-BfWEXcCj.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-Dl0BHoqK.js → chunk-2Q5K7J3B-KLXLZXlR.js} +1 -1
- package/dist/client/assets/{chunk-4EMNKR2T-Da7vH6Kv.js → chunk-4EMNKR2T-CL5Gttmj.js} +1 -1
- package/dist/client/assets/{chunk-55XCU76K-DgBUEROO.js → chunk-55XCU76K-cfAl84Mv.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-BQ4mn-_I.js → chunk-5VM5RSS4-BqUyGgoH.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-8LPR3mXf.js → chunk-JWPE2WC7-BWr2ST9i.js} +1 -1
- package/dist/client/assets/{chunk-VQ5W62QI-BkIVXi4W.js → chunk-VQ5W62QI-V5zYx50O.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-DQXJx06h.js → chunk-XXDRQBXY-gnvheN_J.js} +1 -1
- package/dist/client/assets/{chunk-ZCHMQSOR-DzCE7qlD.js → chunk-ZCHMQSOR-ClGxxZvV.js} +2 -2
- package/dist/client/assets/{classDiagram-v2-4MYWR3UA-C_cZra7c.js → classDiagram-v2-4MYWR3UA-DvmHzDb5.js} +1 -1
- package/dist/client/assets/{command-CDKbyppr.js → command-CNx4L11m.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-DlXHdGwT.js → cose-bilkent-JH36ORCC-Df8nXBRj.js} +1 -1
- package/dist/client/assets/{cpu-B7xLO7jn.js → cpu-D8KJEkdh.js} +1 -1
- package/dist/client/assets/{cynefin-EF2NZ3EQ-HhP4ArLc.js → cynefin-EF2NZ3EQ-CAn6ufHs.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-WF24UDRP-D4GgWnZV.js → cynefinDiagram-WF24UDRP-Cep_NrRw.js} +1 -1
- package/dist/client/assets/{dagre-NK4GIZVX-SZ_OI2Zi.js → dagre-NK4GIZVX-sWD3z9wf.js} +1 -1
- package/dist/client/assets/{diagram-CBK3MWTC-BN-_Ja5m.js → diagram-CBK3MWTC-CUpaBATr.js} +1 -1
- package/dist/client/assets/{diagram-I5XIIV2D-t7AK6xnL.js → diagram-I5XIIV2D-BejWB2ry.js} +1 -1
- package/dist/client/assets/{diagram-ODIL2UCW-C1V7szSc.js → diagram-ODIL2UCW-BGKJfNk9.js} +1 -1
- package/dist/client/assets/{diagram-PFBEJUXE-DPtraQ2g.js → diagram-PFBEJUXE-V0dP8H8k.js} +1 -1
- package/dist/client/assets/{diagram-RJA3I4VV-D2XNRB2b.js → diagram-RJA3I4VV-Bf5dVsFX.js} +1 -1
- package/dist/client/assets/{diagram-TYUNFSNR-BieaRy38.js → diagram-TYUNFSNR-CLrMSqb4.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-V4P3TTPT-Bwki86UY.js → ebnfDiagram-V4P3TTPT-BGG4CWA0.js} +1 -1
- package/dist/client/assets/{elk-QONTBCTQ-WEXSAyHB.js → elk-QONTBCTQ-bf9D6f0w.js} +1 -1
- package/dist/client/assets/{empty-state-J-UJ0BUU.js → empty-state-CDoXnrKn.js} +1 -1
- package/dist/client/assets/{erDiagram-KYQIGQAA-DIKASnoc.js → erDiagram-KYQIGQAA-fEUv-33P.js} +1 -1
- package/dist/client/assets/{execution-config-ILQiJAmy.js → execution-config-Ca9MDOtV.js} +1 -1
- package/dist/client/assets/{file-D40js1Zx.js → file-CiyVL55_.js} +1 -1
- package/dist/client/assets/{file-exclamation-point-Dg3ZpiAe.js → file-exclamation-point-DaFRIKco.js} +1 -1
- package/dist/client/assets/{file-text-DgdvRfMk.js → file-text-DsnD-A8g.js} +1 -1
- package/dist/client/assets/{find-latest-widget-fence-D4kBWC_1.js → find-latest-widget-fence-CNsnCgbB.js} +1 -1
- package/dist/client/assets/{flowDiagram-IUGLLWBU-CoavNw0M.js → flowDiagram-IUGLLWBU-CRbeSDod.js} +1 -1
- package/dist/client/assets/{form-DlPwEgQH.js → form-Cru78aT-.js} +1 -1
- package/dist/client/assets/{format-cron-BrK8RzgT.js → format-cron-9K38-tn1.js} +1 -1
- package/dist/client/assets/{ganttDiagram-R7GPNTJY-DccKAz7f.js → ganttDiagram-R7GPNTJY-Mkk7zgs_.js} +1 -1
- package/dist/client/assets/{git-branch-BpxhecMq.js → git-branch-CONwEYiR.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-DEbo_dgQ.js → gitGraphDiagram-PDYL7XHY-Drre0vyA.js} +1 -1
- package/dist/client/assets/{graph-DROgI3M3.js → graph-BJlnKWgo.js} +1 -1
- package/dist/client/assets/{heart-c7u4Ezxt.js → heart-CqwUlIUG.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-CrATNdTR.js → highlighted-body-KPVGNVTW-e4LXC_pS.js} +1 -1
- package/dist/client/assets/{image-lightbox-DE_fHkw-.js → image-lightbox-DHDtzoja.js} +1 -1
- package/dist/client/assets/{image-off-BExgZjfM.js → image-off-DZuLkaRJ.js} +1 -1
- package/dist/client/assets/{index-D0eJtRlK.js → index-1yEXEZiH.js} +1 -1
- package/dist/client/assets/{index-Be0OJLWK.js → index-A41zxoWk.js} +1 -1
- package/dist/client/assets/{index-DeRDq7bD.js → index-B25gvCK_.js} +1 -1
- package/dist/client/assets/index-B9bZYNKR.js +1 -0
- package/dist/client/assets/{index-DaZ1I8s-.js → index-BBmkfbXd.js} +1 -1
- package/dist/client/assets/{index-DNGNMW3c.js → index-BDD2EyoW.js} +1 -1
- package/dist/client/assets/{index-Ccf1XBTs.js → index-BFNy-Yp3.js} +1 -1
- package/dist/client/assets/{index-DksjixUS.js → index-BIB-maE5.js} +1 -1
- package/dist/client/assets/{index-CbHCZsbE.js → index-BKp2B9JS.js} +1 -1
- package/dist/client/assets/{index-DCJQGDZk.js → index-BLP5O7X9.js} +1 -1
- package/dist/client/assets/{index-DhHobJd3.js → index-BTjZIgFn.js} +1 -1
- package/dist/client/assets/{index-BVqSmajJ.js → index-BV2Ezdxv.js} +1 -1
- package/dist/client/assets/{index-C7B3eSOP.js → index-B_0LYi32.js} +1 -1
- package/dist/client/assets/{index-DDgOoXP1.js → index-Bd7vUYhr.js} +1 -1
- package/dist/client/assets/{index-BlyoyIck.js → index-Bo7x9IkO.js} +1 -1
- package/dist/client/assets/{index-D150FXCC.js → index-BtDxwJsM.js} +1 -1
- package/dist/client/assets/{index-DswGXheF.js → index-By58MgcZ.js} +1 -1
- package/dist/client/assets/index-C3cvP8Fo.js +1033 -0
- package/dist/client/assets/{index-C5or4L_3.js → index-CVuEUzi5.js} +1 -1
- package/dist/client/assets/{index-BkoMsjtM.js → index-CoWJD3Jg.js} +2 -2
- package/dist/client/assets/{index-CqPRAM_6.js → index-CyVH876g.js} +1 -1
- package/dist/client/assets/{index-BGqvci3k.js → index-D67Kfy-M.js} +1 -1
- package/dist/client/assets/{index-D3YeRrne.js → index-DAlpmAIA.js} +1 -1
- package/dist/client/assets/{index-BEkYBuOq.js → index-DDNwNOHF.js} +1 -1
- package/dist/client/assets/{index-CD8aw6Jb.js → index-DL8ISRMH.js} +1 -1
- package/dist/client/assets/{index-AzyLwYS_.js → index-DabU6r9W.js} +3 -3
- package/dist/client/assets/{index-CT_pFeX_.js → index-DdJBZE0H.js} +1 -1
- package/dist/client/assets/{index-B3eeEDWj.js → index-DijWcSDZ.js} +1 -1
- package/dist/client/assets/index-DyRGZyur.css +1 -0
- package/dist/client/assets/{index-DINk1YfD.js → index-DzwZJuO1.js} +1 -1
- package/dist/client/assets/{index-CZmqtJWZ.js → index-HR8BYVRQ.js} +1 -1
- package/dist/client/assets/{index-J3Hh1MnL.js → index-LEcodwyW.js} +1 -1
- package/dist/client/assets/index-UPF8suf2.js +1 -0
- package/dist/client/assets/{index-DT7pv2iW.js → index-Vz7VUm9l.js} +1 -1
- package/dist/client/assets/index-YW-v746p.js +1 -0
- package/dist/client/assets/{index-2wezsLA_.js → index-cI2u8WZS.js} +1 -1
- package/dist/client/assets/{index-InEBtYxw.js → index-iTQUa_b2.js} +6 -6
- package/dist/client/assets/{index-CYy1cjtq.js → index-mZqojApH.js} +1 -1
- package/dist/client/assets/{index-dyAahqKe.js → index-pVFjKNjX.js} +1 -1
- package/dist/client/assets/{index-DxiRRZRo.js → index-skAhJyIF.js} +1 -1
- package/dist/client/assets/{index-BizvylBV.js → index-vJy88bwb.js} +1 -1
- package/dist/client/assets/index-wY5OcS4a.js +43 -0
- package/dist/client/assets/{index-mwf7ZNk2.js → index-x1yAu9zJ.js} +1 -1
- package/dist/client/assets/{index-F-vqXYqa.js → index-xAgihCJ7.js} +1 -1
- package/dist/client/assets/{index.esm-BFJ9SG0n.js → index.esm-BUPoRUaG.js} +1 -1
- package/dist/client/assets/{infoDiagram-MVDRKAX5-VL8q5pKx.js → infoDiagram-MVDRKAX5-B_Wyzufh.js} +1 -1
- package/dist/client/assets/{inline-code-BE9ckzPs.js → inline-code-BIzGDx6z.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-BLKkPYF-.js → ishikawaDiagram-HPEHV2GE-BDk2-6Pd.js} +1 -1
- package/dist/client/assets/{journeyDiagram-BOSHW7O7-CSYpRobu.js → journeyDiagram-BOSHW7O7-7qf9KWEQ.js} +1 -1
- package/dist/client/assets/{kanban-definition-FNSA4HC5-HilAqtZo.js → kanban-definition-FNSA4HC5-CFYDQmXn.js} +1 -1
- package/dist/client/assets/{layers-Cm7coqdo.js → layers-C9tVVcXg.js} +1 -1
- package/dist/client/assets/{lightbulb-DqdWS75d.js → lightbulb-f4jtsAh0.js} +1 -1
- package/dist/client/assets/{link-2-CDJapTSa.js → link-2-ZNlK1BG1.js} +1 -1
- package/dist/client/assets/{list-runtime-types-CP82p1u4.js → list-runtime-types-CqO-QFYD.js} +1 -1
- package/dist/client/assets/{markdown-content-m_qereFc.js → markdown-content-DaEVxezf.js} +1 -1
- package/dist/client/assets/{mention-pill-DV5HIG5Q.js → mention-pill-BiCPflY-.js} +1 -1
- package/dist/client/assets/{mermaid.core-zxW6MBr-.js → mermaid.core-SX8SzrsU.js} +4 -4
- package/dist/client/assets/{message-square-off-YVtpbaJ0.js → message-square-off-_qbedNGF.js} +1 -1
- package/dist/client/assets/{mindmap-definition-6OY57UG3-IAYemvOg.js → mindmap-definition-6OY57UG3-BloJIArH.js} +1 -1
- package/dist/client/assets/{more-details-ReA2ZFBn.js → more-details-CdJT0Ehl.js} +1 -1
- package/dist/client/assets/{owner-notice-M4hn_1ep.js → owner-notice-BDafFD_I.js} +1 -1
- package/dist/client/assets/{package-CUuTl39E.js → package-Cb7lEm7t.js} +1 -1
- package/dist/client/assets/{page-container-BnmNikNZ.js → page-container-DsRgIMAL.js} +1 -1
- package/dist/client/assets/{paperclip-C6fYq5Zf.js → paperclip-DNu1VtoX.js} +1 -1
- package/dist/client/assets/{path-input-DHn9-XaE.js → path-input-D3O71b-X.js} +1 -1
- package/dist/client/assets/{pegDiagram-ECIUJNBX-CojaUwe7.js → pegDiagram-ECIUJNBX-Di48kPNu.js} +1 -1
- package/dist/client/assets/{pieDiagram-GNMPY74T-CjP3pw6V.js → pieDiagram-GNMPY74T-DY8B_SPD.js} +1 -1
- package/dist/client/assets/{plug-DHQcxt7N.js → plug-IIS_cL9-.js} +1 -1
- package/dist/client/assets/{primer-trigger-BmV5wjek.js → primer-trigger-DurKYe8C.js} +2 -2
- package/dist/client/assets/{profile-errors-BSCuj3rT.js → profile-errors-BdhZfdvZ.js} +1 -1
- package/dist/client/assets/{progress-4FQQfnS6.js → progress-g5kkqvlR.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-D57K4MC3-OP0Z8zcR.js → quadrantDiagram-D57K4MC3-Depv_dON.js} +1 -1
- package/dist/client/assets/{query-error-state-BkUdxenP.js → query-error-state-PuLGD7Jp.js} +1 -1
- package/dist/client/assets/{radio-ta5Bw763.js → radio-QOLZSBz1.js} +1 -1
- package/dist/client/assets/{railroadDiagram-Y72NRBL7-CT3NCb9b.js → railroadDiagram-Y72NRBL7-BfD2AiZM.js} +1 -1
- package/dist/client/assets/registry-Ck8p6n1T.js +1 -0
- package/dist/client/assets/{relay-trace-schemas-DwUuyxao.js → relay-trace-schemas-DF_DfZ7s.js} +1 -1
- package/dist/client/assets/{requirementDiagram-EQYSW5RA-tde4lYGp.js → requirementDiagram-EQYSW5RA-B1iTjrkD.js} +1 -1
- package/dist/client/assets/{room-files-source-CZWhaaOy.js → room-files-source-g1th8mWs.js} +2 -2
- package/dist/client/assets/{rotate-ccw-clock-RfbbgUa4.js → rotate-ccw-clock-BGwYMaGL.js} +1 -1
- package/dist/client/assets/{rotate-cw-B3rB_YSw.js → rotate-cw-B4Y0q4GY.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-SY24JHO5-sdCzIA7-.js → sankeyDiagram-SY24JHO5-D5TzVJrQ.js} +1 -1
- package/dist/client/assets/{scroll-area-B4WB7Q40.js → scroll-area-BvScZKSa.js} +1 -1
- package/dist/client/assets/{search-x-DCUmWW2_.js → search-x-CqN5twBj.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-BLEHNHQU-DvzTJcKu.js → sequenceDiagram-BLEHNHQU-BhUahaNf.js} +1 -1
- package/dist/client/assets/{shield-x-CANziVLc.js → shield-x-DHJrwtKp.js} +1 -1
- package/dist/client/assets/signed-in-BmywDpR5.js +1 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-DuDA7TKE.js → sizeCapture-INFHLROL-D2Vi1Kq9.js} +1 -1
- package/dist/client/assets/{soul-file-Co_8f1qw.js → soul-file-BMpVFN7U.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-BJPX5JTC.js → stateDiagram-v2-A6IESKWZ-b9gSbZnF.js} +1 -1
- package/dist/client/assets/{swimlanes-B3ENRKFQ-CiLSffGv.js → swimlanes-B3ENRKFQ-i47jxLY6.js} +1 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-CA9gW19w.js +8 -0
- package/dist/client/assets/{table-BSAvOYPp.js → table-CN2HCi4p.js} +1 -1
- package/dist/client/assets/{terminal-6CdY-T1V.js → terminal-BORQniao.js} +1 -1
- package/dist/client/assets/{timeline-definition-JXYKGLGB-5oq8sl82.js → timeline-definition-JXYKGLGB-eY5gj0js.js} +1 -1
- package/dist/client/assets/{trust-posture-D-Yjm6ot.js → trust-posture-Bcyy5Fub.js} +1 -1
- package/dist/client/assets/{unplug-Bq_1WdV7.js → unplug-lkD35Rwp.js} +1 -1
- package/dist/client/assets/{unverified-catalog-notice-CEzu54YH.js → unverified-catalog-notice-DiCIrrhU.js} +1 -1
- package/dist/client/assets/{use-adapter-catalog-Tn3ZbPAj.js → use-adapter-catalog-BrqVd-47.js} +1 -1
- package/dist/client/assets/{use-bindings-Bz9YRgO7.js → use-bindings-CU2RSXOy.js} +1 -1
- package/dist/client/assets/{use-composer-prefs-D9oKJSQN.js → use-composer-prefs-Dy2oTM8Y.js} +1 -1
- package/dist/client/assets/{use-connector-management-CLYFraXN.js → use-connector-management-5oRqzydY.js} +1 -1
- package/dist/client/assets/{use-deep-link-scroll-DkS713kG.js → use-deep-link-scroll-Bg5nW8qq.js} +1 -1
- package/dist/client/assets/{use-delete-binding-CukKpHBK.js → use-delete-binding-qeyRkvR1.js} +1 -1
- package/dist/client/assets/{use-dev-links-DQ32IcGe.js → use-dev-links-FY4J_PjA.js} +1 -1
- package/dist/client/assets/{use-external-adapter-catalog-D-FO_XW6.js → use-external-adapter-catalog-HiWFZZrW.js} +1 -1
- package/dist/client/assets/{use-full-activity-feed-BNxcyb1j.js → use-full-activity-feed-K1uk9Wya.js} +1 -1
- package/dist/client/assets/use-is-below-desktop-Cu_jKnft.js +1 -0
- package/dist/client/assets/use-is-hub-BX7ypNRJ.js +1 -0
- package/dist/client/assets/{use-jump-back-in-Bibj5tVk.js → use-jump-back-in-BjZ8EswV.js} +1 -1
- package/dist/client/assets/{use-local-browser-xg7WXAVK.js → use-local-browser-CTFiF0wf.js} +1 -1
- package/dist/client/assets/{use-mesh-topology-BgCSFw8s.js → use-mesh-topology-CafidaIH.js} +1 -1
- package/dist/client/assets/{use-mounted-ref-qRbdZfOU.js → use-mounted-ref-B38uSLCx.js} +1 -1
- package/dist/client/assets/{use-notification-prefs-B-4kZR7I.js → use-notification-prefs-m9XSNB6W.js} +1 -1
- package/dist/client/assets/{use-panel-tab-placements-CCq-mZlY.js → use-panel-tab-placements-D9n6rNJ1.js} +1 -1
- package/dist/client/assets/use-pending-read-BoV-UI1E.js +1 -0
- package/dist/client/assets/{use-personality-commit-DwSisUfF.js → use-personality-commit-ChLQfLrK.js} +1 -1
- package/dist/client/assets/{use-promo-activation-Botoso6l.js → use-promo-activation-DbJDgp4_.js} +1 -1
- package/dist/client/assets/{use-promo-dismissals-RJXp-r_J.js → use-promo-dismissals-Csw0j0N0.js} +1 -1
- package/dist/client/assets/{use-pulse-freshness-B3390hGg.js → use-pulse-freshness-BIZ7daHW.js} +1 -1
- package/dist/client/assets/{use-relay-config-BV0xcLwS.js → use-relay-config-hUB3lVFv.js} +1 -1
- package/dist/client/assets/{use-room-follow-claim-Du4hKHIJ.js → use-room-follow-claim-BpKzhniV.js} +1 -1
- package/dist/client/assets/{use-roving-tab-list-g2hO6Ruz.js → use-roving-tab-list-BtM0bZL7.js} +1 -1
- package/dist/client/assets/{use-session-canvas-i30oMO_Q.js → use-session-canvas-DRrkNRcL.js} +3 -3
- package/dist/client/assets/use-session-diagnostics-BTNgouum.js +16 -0
- package/dist/client/assets/{use-unclaimed-chats-B92om889.js → use-unclaimed-chats-BbMZtNG9.js} +1 -1
- package/dist/client/assets/use-update-config-CkWwKNkY.js +1 -0
- package/dist/client/assets/{useMutationState-DdOGdpjP.js → useMutationState-CVpvw27W.js} +1 -1
- package/dist/client/assets/{usecaseDiagram-WPOLBNNX-Di5pJvcw.js → usecaseDiagram-WPOLBNNX-CHcpeLg4.js} +1 -1
- package/dist/client/assets/{vennDiagram-Q3Y3IDCW-K7KAf26T.js → vennDiagram-Q3Y3IDCW-gQbZL_A6.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-IVAIDKWA-DVTaxQt9.js → wardleyDiagram-IVAIDKWA-BFH_WHzZ.js} +1 -1
- package/dist/client/assets/{xychartDiagram-4URNHDU4-x-lSJm_B.js → xychartDiagram-4URNHDU4-B0QpyqeZ.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/drizzle/20261019185620_dor3037_wifi_holds.sql +8 -0
- package/dist/drizzle/meta/20261019185620_snapshot.json +14079 -0
- package/dist/drizzle/meta/_journal.json +7 -0
- package/dist/server/extension-child.cjs +18 -2
- package/dist/server/index.js +55523 -26605
- package/dist/server/index.js.map +2 -2
- package/package.json +6 -6
- package/dist/client/assets/ApplyToOverridesDialog-CoO6V1G4.js +0 -1
- package/dist/client/assets/HandlePage-Cg8H3mQS.js +0 -1
- package/dist/client/assets/NamePage-Bx8T98OF.js +0 -1
- package/dist/client/assets/PermissionHistory-DzU1rf2B.js +0 -1
- package/dist/client/assets/PhotoPage-CmrOIRjf.js +0 -1
- package/dist/client/assets/SeenDevices-SPWkdzoK.js +0 -19
- package/dist/client/assets/SettingsDialog-_dEXUhHe.js +0 -12
- package/dist/client/assets/ToolsPage-Idimrn3o.js +0 -2
- package/dist/client/assets/_shell-ClVN2pUj.js +0 -80
- package/dist/client/assets/_shell.marketplace-CiL6YRbl.js +0 -1
- package/dist/client/assets/_shell.marketplace_.sources-C0sI8e21.js +0 -1
- package/dist/client/assets/_shell.session-_hhBvFc6.js +0 -63
- package/dist/client/assets/_shell.x._extensionId-BWy5v1YE.js +0 -1
- package/dist/client/assets/_shell.x._extensionId_._-BWy5v1YE.js +0 -1
- package/dist/client/assets/channel-DjBlTcCV.js +0 -1
- package/dist/client/assets/index-7jby-RRg.js +0 -1
- package/dist/client/assets/index-BqIHtiaE.js +0 -1
- package/dist/client/assets/index-Cga0qx1T.js +0 -1033
- package/dist/client/assets/index-Ct4At33X.js +0 -1
- package/dist/client/assets/index-DITPwUa9.js +0 -38
- package/dist/client/assets/index-DUZrTFYD.css +0 -1
- package/dist/client/assets/registry-Dc102rws.js +0 -1
- package/dist/client/assets/signed-in-DctJ2IWe.js +0 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-Dv1-QS9J.js +0 -8
- package/dist/client/assets/use-is-below-desktop-gTvJDvw4.js +0 -1
- package/dist/client/assets/use-is-hub-B1vPpkYU.js +0 -1
- package/dist/client/assets/use-pending-read-C8L_v4Zw.js +0 -1
- package/dist/client/assets/use-session-diagnostics-a4b83F5J.js +0 -16
- package/dist/client/assets/use-update-config-Tbn3SodN.js +0 -1
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C5or4L_3.js","assets/index-Cga0qx1T.js","assets/index-DUZrTFYD.css","assets/index-DksjixUS.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var oi=Object.defineProperty;var ai=(e,t,n)=>t in e?oi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Je=(e,t,n)=>ai(e,typeof t!="symbol"?t+"":t,n);import{fC as ii,h_ as Yr,pV as li,r as c,fz as ci,W as ct,dA as Me,j as r,ar as W,bx as ce,hP as Jn,a1 as ke,lj as Jr,q as at,jC as ui,pW as di,pX as Zr,pY as fi,pZ as mi,gb as pi,B as le,a7 as De,fs as hi,G as U,J as Jt,X as it,b7 as xt,p_ as _t,p$ as eo,aW as ae,q0 as gi,q1 as $n,hN as xi,as as to,d7 as bi,ap as yi,ng as vi,q2 as As,dU as Fs,a8 as lt,oT as ki,q3 as Ci,oZ as vt,q4 as Kt,a2 as Xe,oV as Zn,a4 as kt,hf as jt,dT as es,c8 as wt,cy as Si,cz as _i,cB as ji,cC as wi,cD as Ni,dy as Ei,e as Rs,k7 as Di,de as Ti,x as Le,k8 as Ai,oR as ts,dP as Fi,q5 as Ri,q6 as Mi,jZ as ns,q7 as no,q8 as so,q9 as Ii,qa as Oi,iG as ss,a3 as rs,ct as Nt,dS as os,dw as as,dR as $i,qb as Pi,jc as ro,qc as Li,oW as Bi,hu as zi,d$ as qi,aR as Ke,ai as Et,a9 as is,qd as Ui,nh as Hi,qe as Wi,ba as Gi,T as Dt,hD as Ue,hE as He,aj as oo,qf as Zt,dz as Tt,jv as Vi,c6 as ut,s as At,gT as Ki,gn as Ms,hJ as ao,gX as Qi,C as ls,da as Xi,db as Yi,qg as Ji,l as Zi,n6 as io,aT as el,qh as tl,qi as nl,qj as sl,qk as rl,ql as ol,qm as Pe,mP as _e,mZ as al,mQ as en,aN as il,hn as ll,ce as cl,bK as ul,iN as dl,qn as st,a0 as cs,dB as Is,d9 as lo,f as co,qo as fl,ep as ml,aX as pl,f9 as uo,hS as fo,hy as Ct,jd as mo,dC as hl,qp as gl,qq as xl,o as po,y as tn,aS as ho,qr as go,qs as bl,m8 as fn,iY as yl,kY as vl,bc as xo,qt as kl,qu as Cl,eN as Sl,eO as Os,qv as Pn,qw as bo,qx as _l,qy as jl,qz as yo,qA as vo,eu as wl,lr as Nl,gc as El,gd as Dl,ge as Tl,gf as Al,gg as Fl,gh as Rl,gi as Ml,gj as Il,qB as us,qC as Ol,qD as $l,qE as Pl,iT as Ll,iU as Bl,iV as zl,iW as mn,qF as ql,iX as $s,ju as Ul,bP as Hl,jw as Wl,bR as Gl,qG as Ps,ch as Vl,g2 as ko,cm as Co,cc as Kl,cl as Ql,cs as So,cq as Xl,lV as ds,qH as Yl,aw as Jl,qI as Zl,lw as se,qJ as ec,qK as tc,_ as nc,fZ as Ls,iD as Ve,qL as pn,ms as bt,qM as Bs,qN as zs,qO as qs,c7 as hn,qP as nt,ek as yt,qQ as sc,qR as _o,qS as jo,qT as rc,qU as oc,qV as ac,qW as wo,lX as ic,qX as No,qY as Ze,lf as Eo,qZ as lc,bO as cc,lW as uc,q_ as dc,ft as Do,q$ as fc,bW as Us,nD as To,r0 as mc,iv as pc,nF as hc,nG as gc,ak as nn,r1 as xc,r2 as bc,gA as Ao,gx as fs,kt as yc,r3 as vc,r4 as kc,r5 as pt,r6 as Cc,r7 as Sc,cu as _c,eJ as jc,l$ as wc,fp as Nc,lm as Ec,dK as Dc}from"./index-Cga0qx1T.js";import{P as Tc}from"./PromptSuggestionChips-B5fDmc-g.js";import{u as Ac,a as Fc,L as Rc,f as Mc,b as Ic,c as Oc,B as $c,d as Pc}from"./primer-trigger-BmV5wjek.js";import{E as Lc,F as Bc,e as zc,h as qc,f as Uc,P as Hc,g as Wc,d as Gc,q as Vc,j as Kc,b as Qc,G as Xc,B as Yc,H as Fo,z as Jc,u as Zc,D as eu,v as tu,t as nu,p as su,w as ru,y as ou,o as au,n as iu,k as lu,s as cu,M as uu,i as du,S as fu,U as mu,A as pu,I as hu,J as gu,K as Hs,x as xu,R as bu}from"./use-session-diagnostics-a4b83F5J.js";import{C as yu}from"./card-B3CtfC3R.js";import{a as vu,u as ku,i as Cu}from"./use-notification-prefs-B-4kZR7I.js";import{B as Su}from"./banner-DRumuw3F.js";import{t as It,b as Ln,l as _u,k as ju,N as Ro,n as wu,g as Nu,C as St,M as et,f as Eu,D as Du,U as Tu,F as Au}from"./index-InEBtYxw.js";import{a as Fu,b as Ru}from"./markdown-content-m_qereFc.js";import{u as Mu,b as Iu}from"./WidgetErrorCard-cS8yMCxU.js";import{P as Ou,W as $u,a as Pu,C as Lu,b as Bu}from"./find-latest-widget-fence-D4kBWC_1.js";import{a as Mo,b as zu,R as qu,K as Uu,c as Hu,g as Wu}from"./RuntimeConnectFlow-DjReuQ-T.js";import{a as Io,u as Gu,I as Vu}from"./image-off-BExgZjfM.js";import{a as Ku,c as Qu}from"./composer-insert-BpyATrmR.js";import{u as Xu}from"./use-composer-prefs-D9oKJSQN.js";import{A as Bn,M as Yu}from"./McpAppFrame-C7eYYdI9.js";import{F as Oo}from"./file-D40js1Zx.js";import{S as Ju}from"./shield-x-CANziVLc.js";import{u as Zu,M as ed}from"./McpSigninBody-BDyGbJ7I.js";import{f as td}from"./format-duration-BCr6uzby.js";import{l as nd}from"./use-connector-management-CLYFraXN.js";import{A as sd}from"./AgentRequestCard-0fOxvaoe.js";import{F as rd,i as od}from"./use-session-canvas-i30oMO_Q.js";import{F as ad}from"./file-text-DgdvRfMk.js";import"./use-is-below-desktop-gTvJDvw4.js";import"./git-branch-BpxhecMq.js";import"./use-update-config-Tbn3SodN.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./RuntimeSetupDialog-Cr4GRi8c.js";import"./inline-code-BE9ckzPs.js";import"./list-runtime-types-CP82p1u4.js";import"./unverified-catalog-notice-CEzu54YH.js";import"./layers-Cm7coqdo.js";import"./cpu-B7xLO7jn.js";import"./file-drag-GDx2qhdk.js";import"./paperclip-C6fYq5Zf.js";import"./index-dyAahqKe.js";import"./index-F-vqXYqa.js";import"./progress-4FQQfnS6.js";import"./table-BSAvOYPp.js";import"./terminal-6CdY-T1V.js";import"./package-CUuTl39E.js";import"./heart-c7u4Ezxt.js";import"./useMutationState-DdOGdpjP.js";import"./runtime-connect-Dn0T5YWv.js";import"./more-details-ReA2ZFBn.js";import"./access-copy-B3yNZ7Gz.js";import"./query-error-state-BkUdxenP.js";import"./empty-state-J-UJ0BUU.js";import"./use-bindings-Bz9YRgO7.js";import"./connection-copy--MA7AN04.js";import"./KeyEntry-C2kWdN8q.js";import"./rotate-cw-B3rB_YSw.js";import"./query-keys-DeYqUDia.js";import"./index.esm-BFJ9SG0n.js";function id(e,t,n={}){const s=e.get();let o=null,a=s,i;const l=typeof s=="string"?s.replace(/[\d.-]/g,""):void 0,u=()=>{o&&(o.stop(),o=null),e.animation=void 0},d=()=>{const h=Ws(e.get()),m=Ws(a);if(h===m){u();return}const x=o?o.getGeneratorVelocity():e.getVelocity();u(),o=new li({keyframes:[h,m],velocity:x,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:i})},f=()=>{var h;d(),e.animation=o??void 0,(h=e.events.animationStart)==null||h.notify(),o==null||o.then(()=>{var m;e.animation=void 0,(m=e.events.animationComplete)==null||m.notify()})};if(e.attach((h,m)=>{a=h,i=x=>m(gn(x,l)),ii.postRender(f)},u),Yr(t)){let h=n.skipInitialAnimation===!0;const m=t.on("change",g=>{h?(h=!1,e.jump(gn(g,l),!1)):e.set(gn(g,l))}),x=e.on("destroy",m);return()=>{m(),x()}}return u}function gn(e,t){return t?e+t:e}function Ws(e){return typeof e=="number"?e:parseFloat(e)}function ld(e,t={}){const{isStatic:n}=c.useContext(ci),s=()=>Yr(e)?e.get():e;if(n)return Io(s);const o=Gu(s());return c.useInsertionEffect(()=>id(o,e,t),[o,JSON.stringify(t)]),o}function cd(e,t={}){return ld(e,{type:"spring",...t})}function ud(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 $o(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:ud(o),ms:o}}function dd(e={}){const{timeoutMs:t=3e4,onIdle:n,onReturn:s}=e,o=c.useRef(!1),a=c.useRef(null),i=c.useCallback(()=>{o.current||(o.current=!0,n==null||n())},[n]),l=c.useCallback(()=>{o.current&&(o.current=!1,s==null||s())},[s]),u=c.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(i,t),l()},[t,i,l]);return c.useEffect(()=>{a.current=setTimeout(i,t);const d=["mousemove","keydown","scroll","touchstart"];d.forEach(h=>document.addEventListener(h,u,{passive:!0}));const f=()=>{document.hidden?i():u()};return document.addEventListener("visibilitychange",f),()=>{a.current&&clearTimeout(a.current),d.forEach(h=>document.removeEventListener(h,u)),document.removeEventListener("visibilitychange",f)}},[t,i,u]),{isIdle:o.current}}function fd({activeInteraction:e,onApprove:t,onAlwaysAllow:n,onDeny:s,onToggleOption:o,onNavigateOption:a,onNavigateQuestion:i,onSubmit:l,optionCount:u=0,focusedIndex:d=0}){const f=c.useRef(!1);c.useEffect(()=>{f.current=!1},[e==null?void 0:e.toolCallId]),c.useEffect(()=>{if(!e)return;function h(m){const x=m.target,g=(x.tagName==="TEXTAREA"||x.tagName==="INPUT")&&!x.disabled;if(!f.current&&!(m.metaKey||m.ctrlKey||m.altKey)){if(e.type==="approval"){if(m.key==="Enter"&&g&&x.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(g){if(m.key==="Enter"&&!m.shiftKey){m.preventDefault(),l==null||l();return}if(m.key==="ArrowUp"){m.preventDefault(),a==null||a("up");return}if(m.key==="ArrowDown"){m.preventDefault(),a==null||a("down");return}return}const C=parseInt(m.key,10);if(C>=1&&C<=9){m.preventDefault(),C-1<u&&(o==null||o(C-1));return}switch(m.key){case"ArrowUp":m.preventDefault(),a==null||a("up");break;case"ArrowDown":m.preventDefault(),a==null||a("down");break;case" ":m.preventDefault(),o==null||o(d);break;case"ArrowLeft":case"[":m.preventDefault(),i==null||i("prev");break;case"ArrowRight":case"]":m.preventDefault(),i==null||i("next");break;case"Enter":m.preventDefault(),l==null||l();break}}}}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,t,n,s,o,a,i,l,u,d])}function Po(){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 Lo={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"}]]};Lo.node;const md=ct(Lo);/**
|
|
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 Bo={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"}]]};Bo.node;const pd=ct(Bo);/**
|
|
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 hd=ct(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 qo={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"}]]};qo.node;const gd=ct(qo);/**
|
|
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 Uo={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"}]]};Uo.node;const xd=ct(Uo);/**
|
|
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 Ho={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"}]]};Ho.node;const bd=ct(Ho);function yd({color:e,isTextStreaming:t,fadeEdges:n=!0,edge:s="bottom"}){const o=Me()===!0,a=t?1.8:2.5,i=n?"linear-gradient(to right, transparent, black 15%, black 85%, transparent)":void 0,l=s==="top"?"pointer-events-none absolute right-0 top-0 left-0":"pointer-events-none absolute right-0 bottom-0 left-0",u="[--scan-highlight:hsl(var(--background))] dark:[--scan-highlight:hsl(var(--foreground))]",d=s==="top"?"top":"bottom";return r.jsxs(W.div,{"aria-hidden":!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},className:`${l} ${u}`,style:{height:n?10:0,overflow:n?"hidden":"visible",maskImage:i,WebkitMaskImage:i},children:[r.jsx("div",{className:"absolute right-0 left-0",style:{[d]:0,height:6,backgroundColor:e,opacity:.6,filter:"blur(3px)"}}),!o&&r.jsx(W.div,{initial:{x:"-100%"},animate:{x:"433%"},transition:{x:{duration:a,repeat:1/0,ease:"linear"}},className:"absolute",style:{[d]:0,width:"30%",height:2,background:`linear-gradient(to right, transparent, ${e}, var(--scan-highlight), transparent)`,willChange:"transform"}}),r.jsx(ce,{children:t&&!o&&r.jsx(W.div,{initial:{opacity:0,x:"-100%"},animate:{opacity:.9,x:"1525%"},exit:{opacity:0},transition:{x:{duration:1.1,repeat:1/0,ease:"linear"},opacity:{duration:.2}},className:"absolute",style:{[d]:0,width:"8%",height:1,background:"linear-gradient(to right, transparent, var(--scan-highlight) 40%, var(--scan-highlight) 60%, transparent)",willChange:"transform"}})})]})}const xn={"word-boundary":3,substring:2,subsequence:1},vd=new Set(["/",":","-","_","."," "]);function kd(e,t){if(t===0)return!0;const n=e[t-1];if(vd.has(n))return!0;const s=e[t];return n===n.toLowerCase()&&s!==s.toLowerCase()&&s===s.toUpperCase()}function Ot(e,t){return Array.from({length:t},(n,s)=>e+s)}function $t(e,t,n){const s=1/(1+t),o=n/e.length;return(s*.6+o*.4)*.999}function Cd(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 Sd(e,t){const n=t.indices[t.indices.length-1]-t.indices[0]+1,s=t.maxRun/t.indices.length,o=t.indices.length/n,a=t.indices.length/e.length;return(s*.4+o*.3+a*.3)*.999}function Wt(e,t){if(!e)return{match:!0,tier:null,score:0,indices:[]};const n=e.toLowerCase(),s=t.toLowerCase();if(s===n)return{match:!0,tier:"exact",score:5+$t(t,0,n.length),indices:Ot(0,n.length)};if(s.startsWith(n))return{match:!0,tier:"prefix",score:4+$t(t,0,n.length),indices:Ot(0,n.length)};for(let i=1;i<=s.length-n.length;i++)if(kd(t,i)&&s.startsWith(n,i))return{match:!0,tier:"word-boundary",score:xn["word-boundary"]+$t(t,i,n.length),indices:Ot(i,n.length)};const o=s.indexOf(n);if(o>=0)return{match:!0,tier:"substring",score:xn.substring+$t(t,o,n.length),indices:Ot(o,n.length)};const a=Cd(n,s);return a?{match:!0,tier:"subsequence",score:xn.subsequence+Sd(t,a),indices:a.indices}:{match:!1,tier:null,score:0,indices:[]}}class _d{constructor(t){Je(this,"config");Je(this,"recentCompletions",[]);Je(this,"queue",[]);Je(this,"isIdle",!1);Je(this,"debounceTimer",null);this.config=t}onTaskCompleted(t,n){if(!this.config.enabled)return;const s=Date.now();this.recentCompletions.push(s),this.recentCompletions=this.recentCompletions.filter(l=>s-l<this.config.debounceWindowMs);const o=n.length,a=n.filter(l=>l.status==="completed").length;if(o>=this.config.minTasksForMajor&&a===o){this.cancelDebounce();const l={level:"major",taskId:t,timestamp:s};this.emitOrQueue(l);return}if(this.recentCompletions.length>=this.config.debounceThreshold){this.cancelDebounce(),this.debounceTimer=setTimeout(()=>{const l={level:"mini",taskId:t,timestamp:Date.now()};this.emitOrQueue(l),this.recentCompletions=[]},this.config.debounceWindowMs);return}if(Math.random()<this.config.miniProbability){const l={level:"mini",taskId:t,timestamp:s};this.emitOrQueue(l)}}setIdle(t){this.isIdle=t}onUserReturn(){if(this.queue.length>0){const n=this.queue.some(s=>s.level==="major")?this.queue.find(s=>s.level==="major"):this.queue[this.queue.length-1];this.config.onCelebrate(n),this.queue=[]}}destroy(){this.cancelDebounce(),this.queue=[],this.recentCompletions=[]}emitOrQueue(t){this.isIdle?this.queue.push(t):this.config.onCelebrate(t)}cancelDebounce(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}const jd={background:"radial-gradient(circle, rgba(255,215,0,0.15) 0%, transparent 70%)"},wd={mode:"blur-in",duration:150,easing:"ease-out",sep:"word"},Nd={none:void 0,fade:"fadeIn","blur-in":"blurIn","slide-up":"slideUp"};function Ed(e){const t=Nd[e.mode];return t?{animation:t,duration:e.duration??150,easing:e.easing??"ease-out",sep:e.sep??"word"}:!1}function Dd(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 Td({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 Ad=Td({onlyFirst:!0});function Fd(e){if(Ad.test(e))return"ansi";const t=e.trimStart();if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}return"plain"}function sn(e){var n;const{sessions:t}=Jn();if(e)return(n=t.find(s=>s.id===e))==null?void 0:n.runtime}const Rd=typeof window<"u"&&window.location.pathname===di;let bn=null,Gs=!Rd;function Md(e){return Gs?bn===e?!0:(bn=null,!1):(Gs=!0,bn=e,!0)}function Id(e){var s;const t=ke(),n=((s=Jr(e))==null?void 0:s.draft)===!0;c.useEffect(()=>{if(!e||n)return;let o=!1;const a=()=>{o||document.visibilityState!=="visible"||(o=!0,document.removeEventListener("visibilitychange",a),Md(e)||at.getState().recordOpened("session",e),t.markSessionOpened(e).catch(i=>{ui(t,i)}))};if(a(),!o)return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[e,n,t])}function Wo(){const e=Zr(),t=Jr(e.session);return{cwd:(t==null?void 0:t.cwd)??e.dir??null}}function Go({agentId:e,agentName:t,onResumed:n}){const s=fi(),{data:o,dataUpdatedAt:a,refetch:i}=mi(),[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(pi,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("p",{className:"text-sm font-medium",children:[u," is paused"]}),r.jsx("p",{className:"text-muted-foreground text-xs",children:"Resume it, then send your message again."})]}),r.jsx(le,{size:"sm",variant:"outline",disabled:s.isPending,onClick:()=>s.mutate(e,{onSuccess:()=>{De(`${u} resumed`),n==null||n()}}),children:"Resume"})]})}function Od(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 $d({sessionId:e,interactionId:t,serverName:n,message:s,mode:o="form",url:a,requestedSchema:i,status:l,action:u}){const d=ke(),[f,h]=c.useState(!1),[m,x]=c.useState(null),[g,C]=c.useState(null),[b,y]=c.useState({}),[k,v]=c.useState(!1),p=c.useMemo(()=>Od(i),[i]),_=l!=="pending",j=c.useCallback(async(E,w)=>{if(!(f||_)){h(!0),x(null),C(null);try{await d.submitElicitation(e,t,E,w)}catch(R){if(R.code!=="INTERACTION_ALREADY_RESOLVED"){x("Couldn’t send your answer. Try again."),C(R instanceof Error?R.message:null),h(!1);return}}h(!1)}},[d,e,t,f,_]),D=c.useCallback(()=>{const E={};for(const w of p)E[w.key]=b[w.key]??w.defaultValue??"";j("accept",E)},[p,b,j]),T=c.useCallback(()=>{j("accept")},[j]),N=c.useCallback(()=>{j("decline")},[j]),A=c.useCallback((E,w)=>{y(R=>({...R,[E]:w}))},[]),S=c.useCallback(()=>{if(a){if(!hi(a)){x(`Couldn’t open ${a}. Nothing has been authorized.`),C(null);return}x(null),C(null),v(!0)}},[a]);return _?r.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 py-1 text-xs",children:[r.jsx("span",{className:"font-mono",children:n}),r.jsx("span",{children:"·"}),r.jsx("span",{children:u==="accept"?"Authorized":u==="decline"?"Declined":"Cancelled"})]}):r.jsxs(W.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className: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}),g&&r.jsx("p",{className:"text-muted-foreground/70 mt-1 text-xs break-words",children:g})]}),o==="url"&&a&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",variant:"outline",onClick:S,disabled:f,children:"Open authorization page"}),k&&r.jsx(le,{size:"sm",onClick:T,disabled:f,children:f?"Sending…":"Done"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:N,disabled:f,children:"Decline"})]}),o==="form"&&r.jsxs(r.Fragment,{children:[p.length>0?r.jsx("div",{className:"mb-3 space-y-2",children:p.map(E=>r.jsxs("div",{children:[r.jsx("label",{htmlFor:`elicitation-${t}-${E.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:E.label}),E.options?r.jsxs("select",{id:`elicitation-${t}-${E.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:b[E.key]??String(E.defaultValue??""),onChange:w=>A(E.key,w.target.value),disabled:f,children:[r.jsx("option",{value:"",children:"Select…"}),E.options.map(w=>r.jsx("option",{value:w,children:w},w))]}):r.jsx("input",{id:`elicitation-${t}-${E.key}`,type:E.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(E.defaultValue??""),value:b[E.key]??"",onChange:w=>A(E.key,w.target.value),disabled:f})]},E.key))}):r.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:"No additional input required."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",onClick:D,disabled:f,children:f?"Sending…":"Accept"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:N,disabled:f,children:"Decline"})]})]})]})}const Pd=8,Ld={duration:.3,ease:[.16,1,.3,1]},Bd={duration:0};function zd(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 qd(e){return new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function Ud(e){return`${e} action${e===1?"":"s"}`}function Hd({outcome:e,items:t,resolvedAt:n,startedAt:s,reasonGiven:o,className:a}){var C;const i=Me(),[l,u]=c.useState(!1),d=t.length,f=d>1,h=f?Ud(d):(C=t[0])==null?void 0:C.label,m=n!==void 0&&s!==void 0?Math.max(0,n-s):null,x=e==="allowed"?Jt:e==="denied"?it:xt,g=e==="allowed"?"text-status-success":e==="denied"?"text-status-error":"text-muted-foreground";return r.jsxs(W.div,{"data-testid":"approval-receipt","data-outcome":e,"data-count":d,initial:i?!1:{opacity:0,y:Pd},animate:{opacity:1,y:0},transition:i?Bd:Ld,className:U("text-muted-foreground my-1 text-xs",a),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(x,{className:U("size-(--size-icon-xs) shrink-0",g),"aria-hidden":"true"}),r.jsx("span",{className:"min-w-0 truncate",children:e==="expired"?r.jsxs(r.Fragment,{children:["Expired · ",f?`${h} `:"","denied",m!==null&&` after ${zd(m)}`]}):r.jsxs(r.Fragment,{children:["You ",e==="allowed"?"allowed":"denied"," ",f?h:r.jsx("span",{className:"font-mono",children:h}),e==="denied"&&o===!0&&r.jsx(r.Fragment,{children:" · agent was told why"})]})}),n!==void 0&&r.jsx("time",{dateTime:new Date(n).toISOString(),className:"ml-auto shrink-0 tabular-nums opacity-70",children:qd(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 Wd({outcome:e,reasonGiven:t,members:n,lead:s,children:o}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsx(Hd,{outcome:e,items:n.map(a=>({toolCallId:a.toolCallId,label:a.approvalDisplayName||_t(a.toolName,a.input??"")})),resolvedAt:s.approvalResolvedAt,startedAt:s.approvalStartedAt,reasonGiven:t}),e!=="allowed"&&s.result&&r.jsx(eo,{"data-testid":"approval-receipt-result",content:s.result,className:"text-muted-foreground mt-0.5 ml-6"}),e==="allowed"&&o]})}function Vo(e){return e.endsWith("connectors.request_connection")||e.endsWith("connectors_request_connection")}function Ko(e){if(e)try{return JSON.parse(e)}catch{return}}function Gt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Gd(e){const t=Ko(e);if(!Gt(t))return;const{serviceSlug:n,reason:s}=t;if(!(typeof n!="string"||typeof s!="string"))return{serviceSlug:n,reason:s}}function Qo(e){const t=Ko(e);if(Gt(t)&&typeof t.requestId=="string")return t.requestId;if(Gt(t)&&Array.isArray(t.content)){const n=t.content.map(s=>Gt(s)&&typeof s.text=="string"?s.text:"").join("");return Qo(n)}}function Vd(e,t){const n=Qo(t.result);if(n)return e.find(o=>o.requestId===n);const s=Gd(t.input);if(s)return e.filter(o=>o.serviceSlug===s.serviceSlug).sort((o,a)=>a.createdAt.localeCompare(o.createdAt))[0]}function Kd({sessionId:e,input:t,result:n,fallback:s}){const o=nd(e),a=o.data?Vd(o.data,{input:t,result:n}):void 0;return a?r.jsx("div",{className:"my-3","data-testid":"chat-agent-request",children:r.jsx(sd,{request:a})}):r.jsx(r.Fragment,{children:s})}const yn={name:{exact:0,prefix:1,"word-boundary":2,substring:6,subsequence:8},alias:{exact:3,prefix:4,"word-boundary":5,substring:7,subsequence:9},description:{exact:10,prefix:11,"word-boundary":12,substring:13,subsequence:14}},Qd={match:!1,bucket:Number.POSITIVE_INFINITY,score:0};function Vs(e){return e.startsWith("/")?e.slice(1):e}function Ks(e,t){return e.bucket<t.bucket||e.bucket===t.bucket&&e.score>t.score}function Xd(e,t){let n=Qd;const s=Wt(e,Vs(t.fullCommand));s.match&&s.tier&&(n={match:!0,bucket:yn.name[s.tier],score:s.score});for(const o of t.aliases??[]){const a=Wt(e,Vs(o));if(!a.match||!a.tier)continue;const i={bucket:yn.alias[a.tier],score:a.score};Ks(i,n)&&(n={match:!0,...i,matchedAlias:o})}if(t.description){const o=Wt(e,t.description);if(o.match&&o.tier){const a={bucket:yn.description[o.tier],score:o.score};Ks(a,n)&&(n={match:!0,...a})}}return n}const Xo="dorkos:mcp-app-consent:";function Yo(e){return`${Xo}${e}`}function Yd(e){try{return localStorage.getItem(Yo(e))==="granted"}catch{return!1}}function Jd(e){try{localStorage.setItem(Yo(e),"granted")}catch{}Zd()}const zn=new Set;function Zd(){for(const e of zn)e()}function ef(e){zn.add(e);const t=n=>{var s;(s=n.key)!=null&&s.startsWith(Xo)&&e()};return window.addEventListener("storage",t),()=>{zn.delete(e),window.removeEventListener("storage",t)}}function tf(e){const t=c.useSyncExternalStore(ef,()=>Yd(e),()=>!1),n=c.useCallback(()=>Jd(e),[e]);return{consented:t,grant:n}}const nf="h-80";function sf({sessionId:e,serverName:t,uri:n,title:s}){const{consented:o,grant:a}=tf(t),i=ae(d=>d.openPip),l=()=>{const d=ae.getState(),f={type:"mcp_app",serverName:t,uri:n,title:s};d.openCanvasDocument(f),$n(d,"user",f)},u=()=>{i({kind:"mcp_app",sessionId:e,serverName:t,uri:n,title:s??`App · ${t}`})};return o?r.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[r.jsxs("div",{className:"bg-muted/40 flex items-center justify-between border-b px-3 py-1.5",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[r.jsx(Bn,{className:"text-muted-foreground size-3.5 shrink-0"}),r.jsx("span",{className:"truncate",children:s??`App · ${t}`})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:u,"aria-label":"Pop out into a floating window",title:"Pop out",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:r.jsx(Ou,{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(gi,{className:"size-3.5"})})]})]}),r.jsx(Yu,{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(Bn,{className:"text-muted-foreground size-4 shrink-0"}),r.jsxs("span",{children:["Interactive app from ",t]})]}),r.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[r.jsxs("p",{children:["It runs code from ",t," in a sealed-off frame."]}),r.jsx("p",{children:"It can’t see your chat, files or credentials."})]}),r.jsx("div",{children:r.jsx("button",{type:"button",onClick:a,className:"bg-foreground text-background hover:bg-foreground/90 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors",children:"Show app"})})]})}function rf(e){return e.replace(/[-_]+/g," ").trim()}function of({action:e}){const t=Mu(),n=rf(e.actionId),s=`Widget interaction${e.title?`, ${e.title}`:""}: ${n}`;return r.jsxs(W.span,{"data-testid":"ui-action-chip",title:e.payload?JSON.stringify(e.payload):void 0,className: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?Iu: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(bd,{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 Qs(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:null}catch{return null}}function lf(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 x=d[1].trim();s=x&&x!=="(untitled)"?x:null;continue}const f=u.match(/^\s*Action:\s*(.*)$/);if(f){o=f[1].trim();continue}const h=u.match(/^\s*Widget ID:\s*(.*)$/);if(h){a=h[1].trim()||null;continue}const m=u.match(/^\s*Payload:\s*(.*)$/);if(m){const x=m[1].trim();if(x&&x!=="(none)")i=Qs(x);else if(!x){let g="";for(let C=l+1;C<n.length;C++){g+=(g?`
|
|
34
|
-
`:"")+n[C];const b=Qs(g.trim());if(b){i=b;break}}}break}}return o?{title:s,actionId:o,widgetId:a,payload:i}:null}function cf({onAllow:e,onNotNow:t}){return r.jsxs(yu,{"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(xi,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),r.jsx("p",{className:"text-muted-foreground min-w-0 flex-1 text-xs",children:"Get notified when this needs you, even in another tab."}),r.jsxs("div",{className:"flex w-full shrink-0 flex-wrap items-center justify-end gap-1.5 sm:w-auto",children:[r.jsx(le,{variant:"ghost",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:t,children:"Not now"}),r.jsx(le,{variant:"outline",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:e,children:"Turn on notifications"})]})]})}function uf(e){const t=Ac(),{permission:n,request:s}=vu(),{prefs:o,setPrefs:a}=ku(),{data:i}=to(),l=i!==void 0,[u,d]=c.useState(!1),f=bi()||n==="unsupported";c.useEffect(()=>{if(f||!e)return;const g=setTimeout(Fc,Rc);return()=>clearTimeout(g)},[f,e]);const h=c.useCallback(()=>{d(!0),s().then(()=>{a({browserPermissionPrimerDismissed:!0})})},[s,a]),m=c.useCallback(()=>{d(!0),a({browserPermissionPrimerDismissed:!0})},[a]);return{eligible:!f&&l&&t&&!u&&n==="default"&&!o.browserPermissionPrimerDismissed,allow:h,notNow:m}}const df="dorkos:chat:last-seen:";function ff(){try{const e=[];for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n!=null&&n.startsWith(df)&&e.push(n)}for(const t of e)window.localStorage.removeItem(t)}catch{}}function mf(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 hf(e,t,n=0){const s=ke(),[o,a]=c.useState(()=>({sessionId:e,lastReadSeq:null,hydrated:!1}));o.sessionId!==e&&a({sessionId:e,lastReadSeq:null,hydrated:!1});const i=c.useRef(0),l=c.useRef(null),u=c.useRef(!1),d=c.useRef(!1),f=c.useRef(e),h=c.useRef(null),m=n+mf(t);c.useEffect(()=>{ff();let k=!1;return f.current=e,i.current=0,l.current=null,u.current=!1,d.current=!1,(async()=>{let v=null;try{v=await s.getReadCursor("session",e)}catch{}k||(v&&(i.current=v.lastReadSeq,h.current=v.userId),a({sessionId:e,lastReadSeq:(v==null?void 0:v.lastReadSeq)??null,hydrated:!0}))})(),()=>{k=!0}},[s,e]);const x=c.useCallback(async()=>{if(!u.current){u.current=!0;try{for(;;){const k=l.current;if(k===null)break;if(l.current=null,k.sessionId!==f.current)continue;if(d.current)break;const v=i.current;i.current=Math.max(v,k.seq);try{const p=await s.setReadCursor("session",k.sessionId,k.seq);h.current=p.userId??h.current}catch{i.current=v,k.sessionId===f.current&&(d.current=!0);break}}}finally{u.current=!1}}},[s]),g=c.useCallback(()=>{!o.hydrated||d.current||m<=i.current||(l.current={sessionId:e,seq:m},x())},[o.hydrated,e,m,x]);yi("read_cursor",k=>{if(!pf(k)||k.threadKind!=="session"||k.threadId!==e)return;const v=h.current;v!==null&&k.userId!==v||k.lastReadSeq<=i.current||(i.current=k.lastReadSeq,a({sessionId:e,lastReadSeq:k.lastReadSeq,hydrated:!0}))});const C=c.useMemo(()=>t.filter(k=>k._streaming!==!0).map((k,v)=>({id:k.id,seq:n+v+1})),[t,n]),b=o.lastReadSeq,y=vi(C,b===null?null:Math.min(b,m));return{lastSeenMessageId:y.lastSeenId,unreadFromStart:y.fromStart,markSeen:g,isHydrated:o.hydrated}}function Qe(e){return e.notAllowed!==!0&&e.usage.state!=="limited"}function gf(e,t){if(e.id===lt||!e.eligible)return e.reason;const n=ki(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=Ci(n.resetsAt,t);return o?`${s}% left · resets ${o}`:`${s}% left`}function rn(e,t){return e.runtime!==void 0&&e.runtime!==t}function xf(e,t){const n=[],s=[];for(const o of e)(rn(o,t)?s:n).push(o);return{same:n,other:s}}function Qt(e,t){return`${e.runtime??t}:${e.id}`}function bf(e,t,n){if(rn(e,t)){const s=e.runtime;return!e.label&&e.id===vt?`${Kt({runtime:s,accountLabel:null,identityGate:!1})} (this computer's sign-in)`:Kt({runtime:s,accountLabel:e.label,identityGate:!0})}return e.label?e.label:e.id===vt&&e.usage.label?e.usage.label:e.usage.path?n(e.usage.path):e.id}function yf(e,t){const n=e.accounts.find(o=>o.id===e.recommendedId);if(n&&Qe(n))return Qt(n,t);const s=e.accounts.find(Qe);return s?Qt(s,t):null}function vf(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 kf(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 Cf(e){return e.carryOver===!1}function Sf(e,t,n){return e?!0:(t==null?void 0:t.accounts.some(s=>rn(s,n)))??!1}function _f(e){return{id:lt,runtime:e,label:Fs,color:As,eligible:!0,reason:"paid from your DorkOS account",usage:{runtime:"claude-code",accountId:lt,path:"",label:Fs,color:As,subscriptionType:null,plan:null,credits:null,spend:null,windows:[],state:"unknown",limit:null,updatedAt:null}}}function Jo(e,t){const n=ke();return Xe({queryKey:Zn.continueOptions(e),queryFn:()=>n.getContinueOptions(e),enabled:t,staleTime:0,retry:!1})}function jf(e){const t=ke();return kt({mutationFn:n=>t.continueSession(e,n),retry:!1})}function wf(e){const t=ke();return kt({mutationFn:()=>t.cancelAutoContinue(e),retry:!1})}const Xs="claude-code",Nf="No other account can take this work right now.";function Ef(e){return e instanceof Error&&e.message?e.message:"Couldn’t continue on that account. Try again."}function Df({row:e,value:t,name:n,status:s,selected:o}){const a=Qe(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(Ai,{value:t,disabled:!a,className:"sr-only"}),r.jsx("span",{"aria-hidden":!0,className:"inline-flex",children:r.jsx(ts,{color:e.color,name:n})}),r.jsx("span",{className:"max-w-[55%] shrink-0 truncate font-medium",children:n}),e.badge==="recommended"&&r.jsx("span",{className:U(Fi.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 Zo({open:e,onOpenChange:t,sessionId:n,account:s,cancelAutoFirst:o=!1,now:a,onCloseAutoFocus:i}){var pe;const l=jt(),u=a??new Date(l),d=c.useId(),f=s.runtime??Xs,{accounts:h,nameFor:m}=es(),[,x]=wt(),g=wf(n),C=c.useRef(!1),{mutate:b,reset:y}=g;c.useEffect(()=>{if(!e){C.current=!1,y();return}!o||C.current||(C.current=!0,b())},[e,o,b,y]);const k=e&&(!o||g.isSuccess),v=Jo(n,k),p=jf(n),[_,j]=c.useState(null),D=()=>{p.isPending||(j(null),p.reset(),t(!1))},T=q=>q?t(!0):D(),N=k?v.data:void 0,A=N==null?void 0:N.ranking,S=N&&!Cf(N.plan)?[...N.ranking.accounts,...N.credits?[_f(f)]:[]]:[],E=S.some(Qe),w=_??(A?yf(A,f):null),R=S.find(q=>Qt(q,f)===w)??null,M=R!==null&&Qe(R),F=q=>bf(q,f,m),{same:O,other:L}=xf(S,f),B=kf((N==null?void 0:N.advised)===!0,s.trackerItems.some(q=>q.via==="this-chat")),ee=s.accountId??((pe=s.limit)==null?void 0:pe.accountId)??null,Q=(N==null?void 0:N.advised)===!0&&f===Xs&&ee!==null?vf(h.filter(q=>q.id&&q.id!==ee&&!O.some(G=>G.id===q.id)).map(q=>m(q.path))):null,H=()=>{!R||!Qe(R)||p.mutate(rn(R,f)?{account:R.id,runtime:R.runtime}:{account:R.id},{onSuccess:q=>{D(),q.sessionId&&x(q.sessionId)}})},$=q=>{const G=Qt(q,f);return r.jsx(Df,{row:q,value:G,name:F(q),status:gf(q,u),selected:G===w},G)},P=g.isError?g.error:v.isError&&k?v.error:p.isError?p.error:null,I=e&&!P&&(!k||v.isPending),V=!I&&N!==void 0;return r.jsx(Si,{open:e,onOpenChange:T,children:r.jsxs(_i,{className:"max-h-[85vh] !min-h-0",desktopProps:{className:"sm:max-w-[380px]"},onCloseAutoFocus:i,"aria-labelledby":d,children:[r.jsxs(ji,{className:"shrink-0 text-left",children:[r.jsx(wi,{id:d,className:"text-left",children:"Continue on another account"}),r.jsx(Ni,{className:"text-left",children:B.subtitle})]}),r.jsxs(Ei,{className:"flex flex-col gap-3",children:[I&&r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx(Rs,{className:"h-11 rounded-lg"}),r.jsx(Rs,{className:"h-11 rounded-lg"})]}),V&&(E?r.jsxs(Di,{"aria-labelledby":d,value:w??"",onValueChange:j,className:"min-w-0 grid-cols-1 gap-1.5",children:[O.map($),L.length>0&&r.jsx("div",{className:"text-muted-foreground mt-2 text-xs font-semibold tracking-wide uppercase",children:"Other runtimes"}),L.map($)]}):r.jsx("p",{className:"text-muted-foreground text-sm",children:Nf})),V&&Q&&r.jsx("p",{className:"text-muted-foreground text-xs",children:Q}),V&&r.jsxs("ul",{className:"text-muted-foreground list-disc pl-4 text-xs",children:[r.jsx("li",{children:B.carries}),r.jsx("li",{children:B.doesnt})]}),P!==null&&r.jsx("p",{role:"alert",className:"text-destructive text-sm",children:Ef(P)})]}),r.jsxs(Ti,{className:"shrink-0",children:[r.jsx(le,{variant:"outline",onClick:D,disabled:p.isPending,children:"Cancel"}),r.jsxs(le,{onClick:H,disabled:!V||!E||!M||p.isPending,"aria-busy":p.isPending||void 0,children:[p.isPending&&r.jsx(Le,{}),R&&V&&E?`Continue on ${F(R)}`:"Continue"]})]})]})})}const Tf=1440*60*1e3,Af="Paused until you continue or the account resets",Ff="Paused until the task moves or the account resets",Rf=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited"]);function Mf(e){return Rf.has(e)?"critical":"neutral"}function ea(e){return e.carryOver===!1}function rt(e,t){return e!==null&&Date.parse(e)<=t.getTime()}function ms(e){return`${e} should have reset by now.`}function If(e,t,n,s){if(rt(n,s))return ms(e);const o=Ri(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 ta(e){return e.plan.mode==="waiting"&&e.plan.resumeAt?e.plan.resumeAt:e.resetsAt}function Ys(e,t,n){if(t===null)return`Waiting for ${e}`;if(rt(t,n))return ms(e);const s=Date.parse(t)-n.getTime();return s<Tf?`Waiting for ${e} · back in ${Mi(s)}`:`Waiting for ${e} · back ${ns(t,n)}`}function Of(e,t){return Math.max(0,Math.ceil((Date.parse(e)-t.getTime())/1e3))}const $f=new Set(["continue-on","move-now","keep-going","resume","open-moved"]);function Pf(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 Lf=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited","waiting-reset"]),vn={canSubmit:!0,placeholder:null};function Bf(e,t,n){if(!e)return vn;const s=no(e);if(s==="moved")return{canSubmit:t,placeholder:null};if(!Lf.has(s))return vn;const o=i=>i!==null&&!rt(i,n);return o(ta(e))||e.plan.mode==="auto"&&o(e.plan.fireAt)?{canSubmit:!1,placeholder:s==="handing-off"?Ff:Af}:vn}const zf=300*1e3;function na(e,t){const n=Date.parse(e)-Date.parse(t);return Number.isFinite(n)&&n>=0&&n<=zf}function qf(e,t){let n=null;for(const s of e)na(s.since,t)&&(n===null||Date.parse(s.since)<Date.parse(n.since))&&(n=s);return n}function qn(e,t){var n;return e?((n=t.find(s=>s.value===e))==null?void 0:n.displayName)??e:null}function Uf(e,t){return{from:qn(e.modelFrom,t)??(e.scope==="model"?so(e.window,t):null),to:qn(e.modelTo,t)}}function sa(){const{accounts:e,nameFor:t,colorFor:n}=es(),s=Ii("claude-code",{accountId:vt,path:null});return o=>{const a=Oi({accountId:o,path:null,accounts:e,usage:o===vt?s:null,nameFor:t,colorFor:n});return{name:a.name??o,color:a.color}}}const Js=ss(e=>({episodes:new Set,choose:t=>e(n=>n.episodes.has(t)?n:{episodes:new Set([...n.episodes,t])})}));function Hf(e,t){return`${e}\0${t}`}function ra(e,t){const n=t===null?null:Hf(e,t),s=Js(a=>n!==null&&a.episodes.has(n)),o=Js(a=>a.choose);return{continuedHere:s,continueHere:()=>{n!==null&&o(n)}}}const Zs="claude-code",Wf=new Set(["limited","handing-off","model-limited"]),Gf=new Set(["limited","model-limited","all-accounts-out"]);function Vf(e){return(e==null?void 0:e.runsOn)==="own-sign-in"&&e.chosenBy==="user"}function Kf(e){return e instanceof Error&&e.message?e.message:"Couldn’t do that. Try again."}function Qf(e,t){var ee,Q,H;const n=ke(),s=rs(),[,o]=wt(),a=Nt(e,{fetchUsage:!1}),i=t??a,l=i.limit,u=l?no(l):null,d=i.runtime??Zs,f=i.visible,h=sa(),m=d===Zs&&(l!=null&&l.accountId)?h(l.accountId).name:i.name,x=Kt({runtime:d,accountLabel:m,identityGate:f}),g=os({sessionId:e||void 0,runtime:d}).data??[],C=l?ea(l.plan):!0,b=u!==null&&Wf.has(u)&&!C,{isLoaded:y}=es(),{data:k}=as(),v=y&&k!==void 0,p=u==="model-limited",_=Jo(e,b&&v&&(p?f:!f)),j=b&&(p?f&&(((ee=_.data)==null?void 0:ee.ranking.accounts.some(Qe))??!1):Sf(f,(Q=_.data)==null?void 0:Q.ranking,d)),{continuedHere:D,continueHere:T}=ra(e,(l==null?void 0:l.since)??null),{data:N}=$i(),A=u!==null&&Gf.has(u)&&!C&&(l==null?void 0:l.accountId)!==lt&&Pi(N,d)&&!Vf((H=N==null?void 0:N.defaults)==null?void 0:H[d]),S=(l==null?void 0:l.since)??null,E=`${S}:${u}`,[w,R]=c.useState(null),M=$=>R($===null?null:{key:E,message:$}),F=$=>M(Kf($)),O=kt({mutationFn:$=>n.waitForReset(e,$),retry:!1,onError:F}),L=kt({mutationFn:$=>n.continueSession(e,$),retry:!1,onError:F,onSuccess:$=>{$.sessionId&&$.sessionId!==e&&o($.sessionId)}}),B=c.useRef(S);return c.useEffect(()=>{B.current!==null&&S===null&&s.invalidateQueries({queryKey:Zn.limitHistory(e)}),B.current=S},[S,e,s]),{account:i,limit:l,state:u,runtime:d,subject:x,identityGate:f,canPick:j,creditsOffered:A,nameOf:h,models:g,continuedHere:D,continueHere:T,wait:$=>{M(null),O.mutate($===void 0?{}:{autoResume:$})},continueOn:$=>{M(null),L.mutate($)},openSession:$=>o($),pending:O.isPending||L.isPending,failure:(w==null?void 0:w.key)===E?w.message:null}}function kn({visible:e,spoken:t,spokenKey:n}){const[s,o]=c.useState({key:n,text:t});return s.key!==n&&o({key:n,text:t}),r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:e}),r.jsx("span",{className:"sr-only",children:s.key===n?s.text:t})]})}function Cn({account:e,showDot:t}){return r.jsxs(r.Fragment,{children:[t&&e.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-1 inline-flex align-middle",children:r.jsx(ts,{color:e.color,name:e.name,tooltip:!1})}),e.name]})}function Xf(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 Yf({sessionId:e,onSend:t,account:n,now:s}){const o=Qf(e,n),a=ro(),{limit:i,state:l,subject:u,identityGate:d}=o,f=jt(l==="handing-off"?1e3:6e4),h=s??new Date(f),m=i?i.since:null,[x,g]=c.useState(null),C=o.canPick&&m!==null&&x===m,b=E=>g(E?m:null),y=c.useId();if(!i||!l)return null;const k=o.creditsOffered&&a!==null,v=i.plan,p=qn(i.modelFallback,o.models),_=Pf(l,{canPick:o.canPick,hasFallback:p!==null,continuedHere:o.continuedHere}),j=`${l}:${i.since}:${u}`;let D,T=null,N=!1;switch(l){case"all-accounts-out":{D="All accounts are out.";const E=i.allOut;if(E!=null&&E.resetsAt){const w=o.nameOf(E.accountId);T=rt(E.resetsAt,h)?ms(w.name):r.jsxs(r.Fragment,{children:["Soonest back: ",r.jsx(Cn,{account:w,showDot:d}),","," ",ns(E.resetsAt,h)]})}break}case"model-limited":D=`${so(i.window,o.models)} is out on ${u} for this week.`;break;case"waiting-reset":{const E=ta(i);D=r.jsx(kn,{visible:Ys(u,E,h),spoken:Ys(u,E,h),spokenKey:`${j}:${rt(E,h)}`});break}case"reset-ready":D=v.mode==="waiting"&&v.unconfirmed?`${u} should have reset by now.`:`${u} has reset.`;break;case"moved":{if(v.mode!=="continued")return null;const E=o.nameOf(v.accountId);D=r.jsxs(r.Fragment,{children:["This task continued on ",r.jsx(Cn,{account:E,showDot:d}),"."]});break}default:{const E=If(u,i.window,i.resetsAt,h);if(D=r.jsx(kn,{visible:E,spoken:E,spokenKey:`${j}:${rt(i.resetsAt,h)}`}),l==="handing-off"&&v.mode==="auto"){const w=o.nameOf(v.target),R=Of(v.fireAt,h);N=R===0,T=r.jsx(kn,{visible:r.jsxs(r.Fragment,{children:["Moving this task to ",r.jsx(Cn,{account:w,showDot:d}),N?"…":` in ${R}s…`]}),spoken:N?`Moving this task to ${w.name}.`:`Moving this task to ${w.name} in ${R} seconds.`,spokenKey:`${j}:${v.fireAt}:${w.name}:${N}`})}}}const A=E=>{switch(E){case"continue-on":case"choose":b(!0);return;case"move-now":v.mode==="auto"&&o.continueOn({account:v.target});return;case"keep-going":i.modelFallback&&o.continueOn({model:i.modelFallback});return;case"resume":t(Li);return;case"open-moved":v.mode==="continued"&&o.openSession(v.sessionId);return;case"continue-here":o.continueHere();return;case"wait":o.wait();return}},S=l==="waiting-reset"&&v.mode==="waiting"&&!ea(v);return r.jsxs(r.Fragment,{children:[r.jsxs(Su,{variant:Mf(l),role:"status",icon:null,"data-slot":"account-limit-banner","data-state":l,className:"mx-4 mb-2 rounded-lg border px-3 py-2",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"font-semibold",children:D}),T&&r.jsxs(r.Fragment,{children:[" ",T]})]}),S&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[r.jsx("input",{id:y,type:"checkbox",className:"size-3.5",checked:v.autoResume,disabled:o.pending,onChange:E=>o.wait(E.target.checked)}),r.jsx("label",{htmlFor:y,children:"Continue automatically when it resets"})]}),k&&a&&r.jsx("div",{className:"mt-1.5",children:a({runtime:o.runtime,origin:`limit:${e}`,intent:"keep-going",confirmAfterLink:{prompt:"Linked. Continue on DorkOS credits?",action:"Continue"},onChoose:()=>o.continueOn({account:lt})})}),_.length>0&&r.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:_.map(E=>r.jsx(le,{size:"sm",variant:$f.has(E)&&!k?"default":E==="continue-here"?"ghost":"outline",className:"h-auto min-h-11 max-w-full py-1 whitespace-normal md:min-h-8",disabled:o.pending||E==="move-now"&&N,onClick:()=>A(E),children:Xf(E,p)},E))}),o.failure&&r.jsx("p",{role:"alert",className:"text-destructive mt-1.5",children:o.failure})]}),o.canPick&&r.jsx(Zo,{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 Jf(e){const t=ke();return Xe({queryKey:Zn.limitHistory(e),queryFn:()=>t.getLimitHistory(e),enabled:e!=="",retry:!1})}const Zf={moved:zi,"resumed-reset":xt,"resumed-model":xt,"resumed-early":xt};function em({entry:e,now:t}){const n=jt(),s=t??new Date(n),o=sa(),a=Bi(e.runtime),i=os({runtime:e.runtime}).data??[],[,l]=wt(),u=e.runtime==="claude-code"&&e.accountId?o(e.accountId).name:null,d=Kt({runtime:e.runtime,accountLabel:u,identityGate:a}),f=`at ${ns(e.resolvedAt,s)}`,h=Zf[e.resolution];let m;switch(e.resolution){case"moved":{const x=e.toAccountId?o(e.toAccountId):null,g=x?r.jsxs(r.Fragment,{children:[a&&x.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-0.5 inline-flex align-middle",children:r.jsx(ts,{color:x.color,name:x.name,tooltip:!1})}),x.name]}):null;m=r.jsxs(r.Fragment,{children:[d," ran out · moved",g&&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:g}):g]})," ",f]});break}case"resumed-reset":m=`Resumed after reset ${f}`;break;case"resumed-model":{const{from:x,to:g}=Uf(e,i);m=g?`${x??d} ran out · continued on ${g} ${f}`:`${d} ran out · continued here ${f}`;break}case"resumed-early":m=`${d} ran out · continued here ${f}`;break}return r.jsxs("p",{"data-slot":"account-limit-marker","data-resolution":e.resolution,className:"text-muted-foreground text-2xs my-2 flex items-center gap-1.5",children:[r.jsx(h,{"aria-hidden":!0,className:"size-3 shrink-0"}),r.jsx("span",{className:"min-w-0",children:m})]})}function tm({sessionId:e,at:t,fallback:n,now:s}){const{limit:o}=Nt(e,{fetchUsage:!1}),a=Jf(e),[i,l]=c.useState(null),u=o!==null&&(t===""||na(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?qf(a.data.entries,t):null;return d?r.jsx(em,{entry:d,now:s}):o===null&&i!==null&&a.dataUpdatedAt===i.data&&a.errorUpdatedAt===i.error?null:r.jsx(r.Fragment,{children:n})}function nm(e){const{limit:t}=Nt(e,{fetchUsage:!1}),{continuedHere:n}=ra(e,(t==null?void 0:t.since)??null),s=jt();return Bf(t,n,new Date(s))}function sm(e){return Nt(e,{fetchUsage:!1}).limit!==null}function rm({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 om({filteredFiles:e,selectedIndex:t,onSelect:n}){return c.useEffect(()=>{const s=document.getElementById(`file-item-${t}`);s&&s.scrollIntoView({block:"nearest"})},[t]),r.jsx(W.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:s=>s.preventDefault(),children:r.jsx("div",{id:"file-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?r.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No files found."}):e.map((s,o)=>{const a=o===t,i=s.isDirectory?qi:Oo;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(rm,{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 am(e){const t=ke();return Xe({queryKey:["files",{cwd:e??null}],queryFn:()=>t.listFiles(e),enabled:!!e,staleTime:Ke.FILES_STALE_TIME_MS,gcTime:Ke.FILES_GC_TIME_MS})}const im="You",lm="human",cm="system",um="System",dm="agent",fm="Agent",mm="chat-sender:",er="room-author:",pm="Room member",hm="runtime:";function gm(e){return e.messageType==="local_command_output"||e.messageType==="compaction"}function xm(e,t){var a,i,l,u,d,f;if(gm(e)||e._chatStop)return{kind:"system",id:cm,displayName:um};const n=e.role==="user"?(i=(a=e.chatMessages)==null?void 0:a[0])==null?void 0:i.from:void 0;if(n){const h=n.agentId??n.chatId,m=((l=t.senderAgent)==null?void 0:l.call(t,n))??Et({id:h});return{kind:"agent",id:`${mm}${h}`,displayName:n.agentName,emoji:m.emoji,color:m.color}}const s=e.role==="user"?e.roomMessage:void 0;if(s&&!((u=s.author)!=null&&u.you))return bm(s,t);if(e.role==="user")return{kind:"human",id:lm,displayName:((d=t.humanName)==null?void 0:d.trim())||im};if(t.agent){const{id:h,displayName:m,emoji:x,color:g,imageUrl:C}=t.agent;return{kind:"agent",id:h,displayName:m,emoji:x,color:g,imageUrl:C}}const o=(f=t.runtime)==null?void 0:f.trim();return o?{kind:"agent",id:`${hm}${o}`,displayName:is(o),runtime:o}:{kind:"agent",id:dm,displayName:fm}}function bm(e,t){var o;const{author:n}=e;if(!n)return{kind:"human",id:`${er}entry:${e.entryId}`,displayName:pm};const s=`${er}${n.id}`;if(n.kind==="agent"){const a=n.agentId??n.id,i=((o=t.senderAgent)==null?void 0:o.call(t,{agentId:a,chatId:a}))??Et({id:a,...n.emoji?{icon:n.emoji}:{},...n.color?{color:n.color}:{}});return{kind:"agent",id:s,displayName:n.displayName,...i}}return{kind:n.kind,id:s,displayName:n.displayName}}function oa(e){return`msg-${e}`}function ym(){return{last:null}}function vm(e,t){const{resolveAuthor:n,now:s,cache:o}=t,a=t.lastSeenMessageId??null,i=t.unreadFromStart??!1,l=o==null?void 0:o.last,u=l&&l.resolveAuthor===n&&l.now===s&&l.lastSeenMessageId===a&&l.unreadFromStart===i?l:null;let d=0;if(u){const b=Math.min(e.length,u.messages.length);for(;d<b&&e[d]===u.messages[d];)d++}const f=u?u.authors.slice(0,d):[],h=u?u.items.slice(0,d):[];for(let b=f.length;b<e.length;b++){const y=e[b],k=n(y,b);f.push(k),h.push({id:y.id,authorId:k.id,timestamp:y.timestamp})}const m={now:s,lastSeenId:a,unreadFromStart:i},{rows:x,kept:g}=u?Ui(h,m,u.timeline,d):{rows:Hi(h,m),kept:0},C=u?u.rows.slice(0,g):[];for(let b=g;b<x.length;b++){const y=x[b];C.push(y.kind!=="item"?y:{kind:"message",key:oa(e[y.index].id),messageIndex:y.index,message:e[y.index],grouping:y.grouping,author:f[y.index]})}return o&&(o.last={messages:e,authors:f,items:h,resolveAuthor:n,now:s,lastSeenMessageId:a,unreadFromStart:i,timeline:x,rows:C}),C}function km(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 Cm(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 aa=Symbol("no-error-part");function Sm(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 aa}function _m(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=Sm(t.slice(i+1));return u!==aa?u==="auth_error"?l:null:n==="error"&&s==="auth_error"?l:null}const jm="dorkos:signin-resume",wm=1e4;function Nm(){const e=c.useRef(new Map),t=c.useRef(null);return c.useEffect(()=>{const n=Wi(jm);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<wm},claim:n=>{var s;return(s=t.current)==null?void 0:s.postMessage({sessionId:n})}}),[])}function ia(e){switch(e){case"pending":case"running":return r.jsx(Le,{size:"xs",className:It({status:e})});case"complete":return r.jsx(Jt,{className:U("size-(--size-icon-xs)",It({status:e}))});case"error":return r.jsx(it,{className:U("size-(--size-icon-xs)",It({status:e}))});case"neutral":return r.jsx(Gi,{className:U("size-(--size-icon-xs)",It({status:e}))})}}function tr({type:e,toolName:t,toolInput:n,...s}){const o=e==="approval"?"Waiting for approval":"Answering questions",a=t?_t(t,n??""):null,i=a?`${o} · ${a}`:`${o}…`;return r.jsx("div",{className:"bg-muted/50 rounded-msg-tool text-muted-foreground shadow-msg-tool border px-3 py-1 text-sm transition-colors duration-150",...s,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Le,{className:"shrink-0"}),r.jsx("span",{className:"truncate text-xs",children:i})]})})}function Ft({expanded:e,onToggle:t,header:n,children:s,variant:o="default",dimmed:a=!1,disabled:i=!1,hideChevron:l=!1,extraContent:u,ariaLabel:d,className:f,...h}){const m=l?void 0:e;return r.jsxs("div",{className: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),...h,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(W.div,{animate:{rotate:e?180:0},transition:{type:"spring",stiffness:400,damping:30},className:"ml-auto",children:r.jsx(Dt,{className:"text-muted-foreground size-(--size-icon-xs)"})})]}),u,r.jsx(ce,{initial:!1,children:e&&r.jsx(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"overflow-hidden",children:r.jsx("div",{className:"border-border/50 border-t px-3 pt-1 pb-3",children:s})})})]})}const Em=[0,.2,.4];function la({className:e}){return r.jsx("div",{className:U("flex gap-1",e),"data-testid":"typing-dots","aria-hidden":"true",children:Em.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 Dm({record:e}){const t=Me(),{color:n,emoji:s}=Et({id:e.agentId,icon:e.icon,color:e.color}),o=e.displayName.trim()||"Your agent";return r.jsxs("div",{className:"flex flex-col items-center gap-5 text-center","data-testid":"first-light",children:[r.jsx(W.div,{animate:t?void 0:{scale:[1,1.05,1],opacity:[.9,1,.9]},transition:t?void 0:{duration:3,repeat:1/0,ease:"easeInOut"},children:r.jsx(oo,{color:n,emoji:s,size:"lg"})}),r.jsxs("div",{className:"flex flex-col items-center gap-3",children:[r.jsxs("p",{className:"text-muted-foreground text-base","aria-live":"polite",children:[o," is waking up…"]}),r.jsx(la,{})]})]})}function Tm({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(Dm,{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 Am(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function Fm({sessionId:e}){const t=Zt(e),n=Me();if(!t||t.kind==="first-message")return null;const s=Am(t.bornAt),o=Tt(t.runtime).label;return r.jsxs(W.div,{initial:n?!1:{opacity:0,y:-4},animate:{opacity:1,y:0},transition:{duration:.3},"data-testid":"birth-certificate",className:"text-muted-foreground flex items-center justify-center gap-1.5 px-4 pt-3 pb-1 text-xs",children:[r.jsx(Vi,{className:"text-primary size-3.5 shrink-0 fill-current","aria-hidden":"true"}),r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"text-foreground font-medium",children:t.displayName}),s&&r.jsxs(r.Fragment,{children:[r.jsx(Sn,{}),r.jsxs("span",{children:["born ",s]})]}),r.jsx(Sn,{}),r.jsxs("span",{className:"min-w-0 truncate",children:["lives in ",r.jsx("code",{className:"text-2xs",children:t.path})]}),r.jsx(Sn,{}),r.jsxs("span",{className:"shrink-0",children:["runs on ",o]})]})]})}function Sn(){return r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50 shrink-0",children:"·"})}const Rm="another chat";function Mm(e,t){const n=t==null?void 0:t.find(s=>s.id===e);return n?Ki(n)?Ms("autonomy"):n.label:ao(e)?Ms("autonomy"):Qi(e)}function Im({startedBy:e,modes:t}){var a;const n=ut();if(!e)return null;const s=((a=e.reason)==null?void 0:a.trim())||null,o=e.kind==="chat"?e.permission:null;return r.jsxs(r.Fragment,{children:[r.jsx(Om,{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 ",Mm(o.mode,t),","," ",o.sameAsStarter?"same as":"lower than"," the chat that started it."]})]})}function Om({startedBy:e,reason:t,navigate:n}){return r.jsxs("p",{"data-testid":"started-by-line",className:"text-muted-foreground mx-auto max-w-prose px-4 pt-3 pb-1 text-center text-xs",children:[e.kind==="extension"?r.jsxs(r.Fragment,{children:["Started by the"," ",r.jsx("span",{className:"text-foreground font-medium",children:e.extensionName})," extension"]}):r.jsxs(r.Fragment,{children:["Started from"," ",r.jsx("button",{type:"button",onClick:()=>void n(At({session:e.sessionId})),className:"text-foreground focus-visible:ring-ring rounded-sm font-medium underline-offset-2 hover:underline focus-visible:ring-2 focus-visible:outline-none",children:e.title??Rm})]}),t&&r.jsxs(r.Fragment,{children:[": ",t]})]})}function $m({content:e}){const[t,n]=c.useState(!1);return r.jsxs("div",{"data-testid":"started-prompt",className:"px-4 py-1",children:[r.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring mx-auto flex items-center gap-1 rounded-sm text-xs focus-visible:ring-2 focus-visible:outline-none",children:["What it was asked",r.jsx(ls,{"aria-hidden":"true",className: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 Pm={a:Yi,img:Ru},ca=c.createContext({isStreaming:!1});function Lm(e){const t=c.useContext(ca);return r.jsx(Pu,{...e,...t})}const Bm={renderers:[{language:$u,component:Lm}]};function ps({content:e,isStreaming:t=!1,textEffect:n=wd,sessionId:s,isLatestWidgetMessage:o}){const a=Ed(n),i=c.useMemo(()=>({sessionId:s,isLatestMessage:o,isStreaming:t}),[s,o,t]);return r.jsx(ca.Provider,{value:i,children:r.jsx("div",{className:U("relative",t&&"streaming-cursor"),children:r.jsx(Fu,{resetKey:e,fallback:r.jsx("div",{className:"text-sm break-words whitespace-pre-wrap",children:e}),children:r.jsx(Xi,{shikiTheme:["github-light","github-dark"],components:Pm,animated:a,isAnimating:t,plugins:Bm,children:e})})})})}function Un(e){if(e)try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}function me(e,t){const n=e==null?void 0:e[t];return typeof n=="string"&&n.length>0?n:void 0}function zm(e){const t=Un(e);if(t){if(Array.isArray(t.content))for(const n of t.content){const s=typeof(n==null?void 0:n.text)=="string"?Un(n.text):void 0;if(s)return s}return t}}function ua(e){const t=Ji(e.toolName);if(t!=="chat_send"&&t!=="session_start"&&t!=="chat_stop")return null;const n=Un(e.input),s=zm(e.result),o=qm(e,s),a=o===void 0&&(s==null?void 0:s.status)==="approval_required",i=me(n,"delivery");return{tool:t,...me(n,t==="chat_stop"?"chat":"to")!==void 0?{to:me(n,t==="chat_stop"?"chat":"to")}:{},...me(n,t==="session_start"?"prompt":"message")!==void 0?{message:me(n,t==="session_start"?"prompt":"message")}:{},...me(n,"summary")!==void 0?{summary:me(n,"summary")}:{},...i==="queue"||i==="steer"||i==="interrupt"?{delivery:i}:{},...me(n,"reason")!==void 0?{reason:me(n,"reason")}:{},...me(s,"messageId")!==void 0?{messageId:me(s,"messageId")}:{},...(me(s,"chatId")??me(s,"sessionId"))!==void 0?{chatId:me(s,"chatId")??me(s,"sessionId")}:{},...o!==void 0?{error:o}:{},...a?{waiting:a}:{},...t==="chat_stop"&&o===void 0&&(s==null?void 0:s.stopped)===!1?{notRunning:!0}:{},...me(s,"note")!==void 0?{note:me(s,"note")}:{}}}const Pt="It could not be sent.";function qm(e,t){var n;if((t==null?void 0:t.status)==="denied")return me(t,"message")??Pt;if((t==null?void 0:t.ok)===!1||typeof(t==null?void 0:t.error)=="string")return me(t,"error")??me(t,"message")??Pt;if(e.status==="error")return t?me(t,"error")??me(t,"message")??Pt:((n=e.result)==null?void 0:n.trim())||Pt}function Um(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 Hm(e,t){if(e){for(let n=t.length-1;n>=0;n--)if(t[n].to.chatId===e)return t[n].to}}function Wm(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 Gm(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 Vm(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 Km(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 da(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=ua(i))==null?void 0:s.messageId)===t)return o.id}}const nr=new WeakMap;function Qm(e,t){if(t.length===0)return e;const n=[];let s=0;const o=a=>{let i=nr.get(a);return i||(i={id:`chat-stop-${a.id}`,role:"user",content:"",parts:[],timestamp:a.at,_chatStop:a},nr.set(a,i)),i};for(const a of e){const i=a.timestamp==="",l=i?Number.NaN:Date.parse(a.timestamp),u=d=>i||!Number.isNaN(l)&&Date.parse(d.at)<l;for(;s<t.length&&u(t[s]);)n.push(o(t[s])),s+=1;n.push(a)}for(;s<t.length;)n.push(o(t[s])),s+=1;return n}function Xm({stamp:e}){const t=Km(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 fa({stamp:e}){const t=ut(),n=e.from.chatTitle??"another chat";return r.jsxs("span",{"data-testid":"chat-from-mark",className:"inline-flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[r.jsxs("span",{className:"text-muted-foreground inline-flex min-w-0 items-center gap-1",children:[r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{children:"from"}),r.jsx("button",{type:"button",onClick:()=>void t(At({session:e.from.chatId,message:e.id})),className:"focus-ring text-foreground/80 hover:text-foreground max-w-48 truncate underline-offset-4 hover:underline",children:n})]}),r.jsx(Xm,{stamp:e})]})}function Ym({sessionId:e,messageId:t}){const n=ut();return r.jsxs("button",{type:"button","data-testid":"chat-reply-to",onClick:()=>void n(At({session:e,message:t})),className:"focus-ring text-muted-foreground hover:text-foreground focus-visible:text-foreground mb-1 inline-flex items-center gap-1 text-xs underline-offset-4 hover:underline",children:[r.jsx(pd,{"aria-hidden":!0,className:"size-3"}),"Reply to your message"]})}function Jm({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(Ym,{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(fa,{stamp:n})]}),r.jsx("div",{className:"msg-prose",children:r.jsx(ps,{content:n.text,isStreaming:!1,...t?{sessionId:t}:{}})})]},n.id))})}function Zm({stamp:e}){const t=ut(),n=e.roomLabel??"a room";return r.jsxs("span",{"data-testid":"room-post-mark",className:"text-muted-foreground inline-flex min-w-0 items-center gap-1 text-xs",children:[r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{children:"in"}),r.jsx("button",{type:"button","aria-label":`Open ${n}`,onClick:()=>void t({...Zi.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 ep={muted:"text-muted-foreground",active:"text-foreground",done:"text-muted-foreground",error:"text-destructive"};function tp(e){return e.charAt(0).toUpperCase()+e.slice(1)}function np(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=tp(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 sp(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 rp({part:e,sent:t,at:n,sessionId:s}){const[o,a]=c.useState(!1),i=c.useId(),l=ut(),u=ua(e);if(!u)return null;const d=e.status==="pending"||e.status==="running",f=Wm(u,t),h=(f==null?void 0:f.to.chatId)??u.chatId??(u.tool==="chat_stop"?u.to:void 0),m=(f==null?void 0:f.to)??Hm(h,t),x=(m==null?void 0:m.agentName)??"the agent",g=m==null?void 0:m.chatTitle,C=Et({id:(m==null?void 0:m.agentId)??u.to??h??"chat"}),b=u.tool==="chat_stop"?sp(u,d):Vm(f,{...u,pending:d}),y=Gm((f==null?void 0:f.summary)??u.summary,(f==null?void 0:f.text)??u.message),k=n?Ln(n):f?Ln(f.sentAt):"",v=u.error??((f==null?void 0:f.status)==="failed"?f.failureReason:void 0),p=v?Um(v):u.tool==="chat_stop"?u.reason:y!==g?y:"",_=u.tool==="session_start"?xd:u.tool==="chat_stop"?io:el,j=u.tool==="session_start"?"Started spin-off chat":u.tool==="chat_stop"?u.error||u.notRunning?"Tried to stop":"Stopped":"To",D=u.tool==="session_start"?g??(y||"a new chat"):u.tool==="chat_stop"?g??"a chat":(m==null?void 0:m.agentName)??g??"a chat",T=()=>{h&&l(At({session:h,...f?{message:f.id}:{}}))};return r.jsxs("div",{"data-testid":"sent-chat-card","data-tool":u.tool,"data-state":b.label,className:"border-border/70 bg-background my-1.5 rounded-lg border text-sm",children:[r.jsxs("button",{type:"button",onClick:()=>a(N=>!N),"aria-expanded":o,...o?{"aria-controls":i}:{},className:"focus-ring hover:bg-muted/40 flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors duration-150",children:[r.jsx(oo,{size:"xs",emoji:C.emoji,color:C.color}),r.jsx(_,{"aria-hidden":!0,className:"text-muted-foreground hidden size-3.5 shrink-0 sm:block"}),r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r.jsxs("span",{className:"text-muted-foreground",children:[j," "]}),r.jsx("span",{className:"font-medium",children:D}),u.tool==="chat_send"&&g&&(m==null?void 0:m.agentName)&&r.jsxs("span",{className:"text-muted-foreground",children:[" · ",g]}),p&&(u.tool!=="session_start"||v)&&r.jsxs("span",{"data-testid":"sent-chat-aside",className:U("text-muted-foreground",!v&&"hidden sm:inline"),children:[" ","· ",p]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("span",{className:U("text-xs",ep[b.tone]),"data-testid":"sent-chat-state",children:b.label}),k&&r.jsx("time",{className:"text-muted-foreground hidden text-xs tabular-nums sm:inline",children:k}),r.jsx(Dt,{"aria-hidden":!0,className: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(ps,{content:(f==null?void 0:f.text)??u.message??u.reason??"",isStreaming:!1,...s?{sessionId:s}:{}})}),r.jsxs("p",{className:"text-muted-foreground text-xs",children:[np(u,f,x),u.note&&u.tool!=="chat_stop"&&f?` ${u.note}`:""]}),h&&!u.error&&!u.waiting&&r.jsx("button",{type:"button",onClick:T,className:"focus-ring text-foreground text-xs font-medium underline-offset-4 hover:underline",children:"Open chat →"})]})]})}function op({notice:e}){const t=ut();return r.jsxs("div",{"data-testid":"chat-stop-line",className:"text-muted-foreground flex flex-wrap items-center gap-1.5 text-xs",children:[r.jsx(io,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),r.jsxs("span",{children:["Stopped by ",r.jsx("span",{className:"text-foreground/80 font-medium",children:e.by.agentName})," · ",r.jsx("button",{type:"button",onClick:()=>void t(At({session:e.by.chatId})),className:"focus-ring hover:text-foreground underline-offset-4 hover:underline",children:e.by.chatTitle??"another chat"}),e.reason?`: ${e.reason}`:""]})]})}const ap={sent:[],stops:[]},ip=new rl;function ma(e){const t=tl(),n=c.useContext(nl),s=sl(e??""),{data:o}=Xe({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??ip);return o??ap}function hs(e){const t=[],n=[];for(const s of e)s.type==="text"?t.push(s.text):s.type==="tool_call"&&n.push({toolCallId:s.toolCallId,toolName:s.toolName,input:s.input||"",result:s.result,progressOutput:s.progressOutput,status:s.status,interactiveType:s.interactiveType,questions:s.questions,answers:s.answers,timeoutMs:s.timeoutMs,hooks:s.hooks,startedAt:s.startedAt,completedAt:s.completedAt,approvalStartedAt:s.approvalStartedAt,approvalRemainingMs:s.approvalRemainingMs,approvalParked:s.approvalParked,approvalTitle:s.approvalTitle,approvalDisplayName:s.approvalDisplayName,approvalDescription:s.approvalDescription,approvalBlockedPath:s.approvalBlockedPath,approvalDecisionReason:s.approvalDecisionReason,approvalHasSuggestions:s.approvalHasSuggestions,approvalAlwaysAllowScope:s.approvalAlwaysAllowScope});return{content:t.join(`
|
|
36
|
-
`),toolCalls:n}}const sr=new WeakMap;function lp(e){let t=sr.get(e);return t||(t=e.map(ot),sr.set(e,t)),t}function ot(e){const t=e.parts?[...e.parts]:[];if(t.length===0&&(e.content&&t.push({type:"text",text:e.content}),e.toolCalls))for(const s of e.toolCalls)t.push({type:"tool_call",toolCallId:s.toolCallId,toolName:s.toolName,input:s.input,result:s.result,status:s.status,...s.questions||s.questionOutcome?{interactiveType:"question",questions:s.questions,answers:s.answers,questionOutcome:s.questionOutcome}:{},...s.approvalOutcome?{interactiveType:"approval",approvalOutcome:s.approvalOutcome,approvalResolvedAt:s.approvalResolvedAt,approvalStartedAt:s.approvalStartedAt,approvalReasonGiven:s.approvalReasonGiven}:{}});const n=hs(t);return{id:e.id,role:e.role,content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:void 0,parts:t,timestamp:e.timestamp||"",messageType:e.messageType,compactMetadata:e.compactMetadata,commandName:e.commandName,commandArgs:e.commandArgs,...e.chatMessages&&e.chatMessages.length>0?{chatMessages:e.chatMessages}:{},...e.roomMessage?{roomMessage:e.roomMessage}:{}}}function cp(e,t,n){const s=new Set(e.map(d=>d.id)),o=e.filter(d=>d._streaming),a=o.find(d=>d.role==="user"),i=o.find(d=>d.role==="assistant"),l=[];let u=-1;for(let d=0;d<t.length;d++){const f=t[d];if(!s.has(f.id)){if(a&&f.role==="user"&&f.content===a.content){u=d,n(h=>h.map(m=>m.id===a.id?{...ot(f),_streaming:!1}:m));continue}if(i&&u>=0&&d===u+1&&f.role==="assistant"){const h=ot(f),m=new Set(h.parts.filter(C=>C.type==="background_task").map(C=>C.taskId)),x=i.parts.filter(C=>C.type==="background_task"&&!m.has(C.taskId)),g=x.length>0?[...h.parts,...x]:h.parts;n(C=>C.map(b=>b.id===i.id?{...h,parts:g,_streaming:!1}:b));continue}l.push(f)}}l.length>0&&n(d=>[...d,...l.map(ot)])}const up=20;function dp(e,t){var y;const n=ke(),s=ol(e),o=Pe(k=>k.seeks[e]),[a,i]=c.useState(null),l=c.useRef(null),u=a===e,d=c.useRef({key:"",count:0}),f=s.windowStartId!==null&&((y=t[0])==null?void 0:y.id)===s.windowStartId,h=c.useMemo(()=>f?s.earlier.map(ot):[],[f,s.earlier]),m=c.useMemo(()=>h.length>0?[...h,...t]:t,[h,t]),x=f&&s.remaining>0,g=f?s.remaining:0,C=c.useCallback(()=>{var p;if(l.current===e||!x)return;const{generation:k}=s,v=((p=s.earlier[0])==null?void 0:p.id)??s.windowStartId;v&&(l.current=e,i(e),n.getMessages(e,void 0,{before:v}).then(_=>{Pe.getState().prependPage(e,k,_.messages,_.earlierMessages??0)}).catch(_=>{console.warn("[chat] could not read earlier messages",_),Pe.getState().endSeek(e)}).finally(()=>{l.current===e&&(l.current=null,i(null))}))},[x,e,n,s]),b=o!==void 0&&(m.some(k=>k.id===o)||da([...s.earlier,..._e.getState().getSession(e).messages],o)!==void 0);return c.useEffect(()=>{if(o===void 0){d.current={key:"",count:0};return}const k=`${e}:${o}`;if(d.current.key!==k&&(d.current={key:k,count:0}),!(s.generation===0||u)){if(b||!x||d.current.count>=up){Pe.getState().endSeek(e);return}d.current.count+=1,C()}},[o,b,x,u,C,e,s.generation]),{messages:m,earlierCount:h.length,messagesBefore:g,canLoadEarlier:x,isLoadingEarlier:u,isSeeking:o!==void 0,loadEarlier:C}}function fp({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;al({kind:"burst"}).then(l=>{if(a){l();return}n.current=l});const i=setTimeout(()=>{o()},en.CELEBRATION_DISPLAY_MS);return()=>{var l;a=!0,(l=n.current)==null||l.call(n),n.current=null,clearTimeout(i)}},[s,o]),r.jsx(ce,{children:s&&r.jsx(W.div,{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-50",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.1},transition:{duration:.6,ease:"easeOut"},style:jd})})}const gs=c.createContext(null);function mp({children:e,value:t}){const n=c.useMemo(()=>t,[t.sessionId,t.isStreaming,t.isLatestWidgetMessage,t.isFinalMessage,t.activeToolCallId,t.onToolRef,t.focusedOptionIndex,t.onToolDecided,t.onRetry,t.onSigninComplete,t.onChooseModel,t.inputZoneToolCallId,t.textEffect,t.runtimeLabel,t.allowsDenyReason]);return r.jsx(gs,{value:n,children:e})}function pp(){const e=c.useContext(gs);if(!e)throw new Error("useMessageContext must be used within MessageProvider");return e}function hp(){return c.useContext(gs)}function gp(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({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 ${gp(n)}`:"Thinking…";return r.jsx(Ft,{expanded:s,onToggle:()=>o(!s),variant:"thinking",dimmed:!t,disabled:t,ariaLabel:l,"data-testid":"thinking-block","data-streaming":t?"true":void 0,header:r.jsxs(r.Fragment,{children:[r.jsx(md,{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 bp({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"?il:ll,d=e==="synthesize"?"sparkles":"bookopen";return r.jsx(Ft,{expanded:s,onToggle:()=>o(!s),variant:"memory",dimmed:!n,disabled:n,ariaLabel:l,"data-testid":"memory-recall-block","data-streaming":n?"true":void 0,header:r.jsxs(r.Fragment,{children:[r.jsx(u,{"aria-hidden":"true","data-testid":"memory-recall-header-icon","data-icon":d,className: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(yp,{memories:t})})}function yp({memories:e}){return r.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>r.jsx(vp,{memory:t},t.path))})}function vp({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?cl:ul,s=e.scope==="team"?"team":"personal",{copy:o}=dl({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:Dd(e.path,40)}),r.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function Vt(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function pa(e){return e===void 0?"Summarized (asked by the agent)":`Summarized at ${e}% (asked by the agent)`}function kp(e){if((e==null?void 0:e.requestedBy)==="agent")return pa(e.contextPercent);const t=["Context compacted"];return(e==null?void 0:e.preTokens)!==void 0&&t.push(`${Vt(e.preTokens)} tokens`),e!=null&&e.trigger&&t.push(e.trigger),t.join(" · ")}function Cp(e,t){return e===void 0?"Compacted context":t===void 0?`Compacted context · ${Vt(e)} tokens summarized`:`Compacted context · ${Vt(e)} → ${Vt(t)} tokens`}function Sp({trigger:e,preTokens:t,postTokens:n,failed:s,error:o,requestedBy:a,contextPercent:i}){return s?r.jsx(st,{"data-testid":"compact-boundary-row","data-failed":"true",icon:r.jsx(cs,{"aria-hidden":"true",className:"text-status-warning-dot size-3 shrink-0"}),label:r.jsx("span",{className:"text-status-warning-fg",children:a==="agent"?"Couldn’t compact (asked by the agent)":"Couldn’t compact"}),children:o?r.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:o}):null}):a==="agent"?r.jsx(st,{"data-testid":"compact-boundary-row","data-requested-by":"agent",icon:r.jsx(Is,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:pa(i)})}):r.jsx(st,{"data-testid":"compact-boundary-row",icon:r.jsx(Is,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:Cp(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 _p({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(Vu,{"aria-hidden":"true",className:"size-4 shrink-0"}),r.jsx("span",{children:e.alt?`${e.alt}, not available`:"This image is not available."})]}):r.jsx("figure",{className:"my-3","data-testid":"message-image",children:r.jsx(lo,{image:{src:e.url,alt:e.alt??"Image produced by the agent"},className:"block",children:r.jsx("img",{src:e.url,alt:e.alt??"Image produced by the agent",loading:"lazy",decoding:"async",onError:()=>n(!0),className:"border-border/60 bg-muted/20 max-h-[32rem] max-w-full rounded-md border object-contain"})})})}function jp({content:e}){return r.jsx(st,{"data-testid":"staged-context-note",icon:r.jsx(co,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:"Added context for the next reply"}),children:r.jsx("p",{className:"text-muted-foreground/80 mt-1 text-xs whitespace-pre-wrap",children:e})})}function wp(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 Np(e){return e==="untracked"?"neutral":e==="stopped"?"complete":e}function Ep(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(wp(e.durationMs)),t.length>0?t.join(" · "):null}function Dp({part:e}){const[t,n]=c.useState(!1),s=c.useRef(null),o=Ep(e),a=e.subagentText,i=e.status==="untracked",l=!!(o||e.summary||e.lastToolName||a||i);return c.useEffect(()=>{const u=s.current;u&&(u.scrollTop=u.scrollHeight)},[a]),r.jsx(Ft,{expanded:t,onToggle:()=>l&&n(!t),hideChevron:!l,ariaLabel:`Background task: ${e.description}`,"data-testid":"subagent-block","data-task-id":e.taskId,"data-status":e.status,header:r.jsxs(r.Fragment,{children:[ia(Np(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 Tp=e=>typeof e=="boolean"||e instanceof Boolean,Ap=e=>typeof e=="number"||e instanceof Number,Fp=e=>typeof e=="bigint"||e instanceof BigInt,ha=e=>!!e&&e instanceof Date,Rp=e=>typeof e=="string"||e instanceof String,Mp=e=>Array.isArray(e),ga=e=>typeof e=="object"&&e!==null,xa=e=>!!e&&e instanceof Object&&typeof e=="function";function Xt(e,t){return t===void 0&&(t=!1),!e||t?`"${e}"`:e}function Ip(e,t,n){return n?JSON.stringify(e):t?`"${e}"`:e}function ba(e){let{field:t,value:n,data:s,lastElement:o,openBracket:a,closeBracket:i,level:l,style:u,shouldExpandNode:d,clickToExpandNode:f,outerRef:h,beforeExpandChange:m}=e;const x=c.useRef(!1),[g,C]=c.useState(()=>d(l,n,t)),b=c.useRef(null);c.useEffect(()=>{x.current?C(d(l,n,t)):x.current=!0},[d]);const y=c.useId();if(s.length===0)return Op({field:t,openBracket:a,closeBracket:i,lastElement:o,style:u});const k=g?u.collapseIcon:u.expandIcon,v=g?u.ariaLables.collapseJson:u.ariaLables.expandJson,p=l+1,_=s.length-1,j=N=>{g!==N&&(!m||m({level:l,value:n,field:t,newExpandValue:N}))&&C(N)},D=N=>{if(N.key==="ArrowRight"||N.key==="ArrowLeft")N.preventDefault(),j(N.key==="ArrowRight");else if(N.key==="ArrowUp"||N.key==="ArrowDown"){N.preventDefault();const A=N.key==="ArrowUp"?-1:1;if(!h.current)return;const S=h.current.querySelectorAll("[role=button]");let E=-1;for(let R=0;R<S.length;R++)if(S[R].tabIndex===0){E=R;break}if(E<0)return;const w=(E+A+S.length)%S.length;S[E].tabIndex=-1,S[w].tabIndex=0,S[w].focus()}},T=()=>{var N;j(!g);const A=b.current;if(!A)return;const S=(N=h.current)===null||N===void 0?void 0:N.querySelector('[role=button][tabindex="0"]');S&&(S.tabIndex=-1),A.tabIndex=0,A.focus()};return c.createElement("div",{className:u.basicChildStyle,role:"treeitem","aria-expanded":g,"aria-selected":void 0},c.createElement("span",{className:k,onClick:T,onKeyDown:D,role:"button","aria-label":v,"aria-expanded":g,"aria-controls":g?y:void 0,ref:b,tabIndex:l===0?0:-1}),(t||t==="")&&(f?c.createElement("span",{className:u.clickableLabel,onClick:T,onKeyDown:D},Xt(t,u.quotesForFieldNames),":"):c.createElement("span",{className:u.label},Xt(t,u.quotesForFieldNames),":")),c.createElement("span",{className:u.punctuation},a),g?c.createElement("ul",{id:y,role:"group",className:u.childFieldsContainer},s.map((N,A)=>c.createElement(Hn,{key:N[0]||A,field:N[0],value:N[1],style:u,lastElement:A===_,level:p,shouldExpandNode:d,clickToExpandNode:f,beforeExpandChange:m,outerRef:h}))):c.createElement("span",{className:u.collapsedContent,onClick:T,onKeyDown:D}),c.createElement("span",{className:u.punctuation},i),!o&&c.createElement("span",{className:u.punctuation},","))}function Op(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},Xt(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 $p(e){let{field:t,value:n,style:s,lastElement:o,shouldExpandNode:a,clickToExpandNode:i,level:l,outerRef:u,beforeExpandChange:d}=e;return ba({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 Pp(e){let{field:t,value:n,style:s,lastElement:o,level:a,shouldExpandNode:i,clickToExpandNode:l,outerRef:u,beforeExpandChange:d}=e;return ba({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 Lp(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):Rp(n)?(a=Ip(n,!s.noQuotesForStringValues,s.stringifyStringValues),i=s.stringValue):Tp(n)?(a=n?"true":"false",i=s.booleanValue):Ap(n)?(a=n.toString(),i=s.numberValue):Fp(n)?(a=`${n.toString()}n`,i=s.numberValue):ha(n)?a=n.toISOString():xa(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},Xt(t,s.quotesForFieldNames),":"),c.createElement("span",{className:i},a),!o&&c.createElement("span",{className:s.punctuation},","))}function Hn(e){const t=e.value;return Mp(t)?c.createElement(Pp,Object.assign({},e)):ga(t)&&!ha(t)&&!xa(t)?c.createElement($p,Object.assign({},e)):c.createElement(Lp,Object.assign({},e))}var Z={"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 ya={collapseJson:"collapse JSON",expandJson:"expand JSON"},_n={container:Z["container-light"],basicChildStyle:Z["basic-element-style"],childFieldsContainer:Z["child-fields-container"],label:Z["label-light"],clickableLabel:Z["clickable-label-light"],nullValue:Z["value-null-light"],undefinedValue:Z["value-undefined-light"],stringValue:Z["value-string-light"],booleanValue:Z["value-boolean-light"],numberValue:Z["value-number-light"],otherValue:Z["value-other-light"],punctuation:Z["punctuation-light"],collapseIcon:Z["collapse-icon-light"],expandIcon:Z["expand-icon-light"],collapsedContent:Z["collapsed-content-light"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:ya,stringifyStringValues:!1},Bp={container:Z["container-dark"],basicChildStyle:Z["basic-element-style"],childFieldsContainer:Z["child-fields-container"],label:Z["label-dark"],clickableLabel:Z["clickable-label-dark"],nullValue:Z["value-null-dark"],undefinedValue:Z["value-undefined-dark"],stringValue:Z["value-string-dark"],booleanValue:Z["value-boolean-dark"],numberValue:Z["value-number-dark"],otherValue:Z["value-other-dark"],punctuation:Z["punctuation-dark"],collapseIcon:Z["collapse-icon-dark"],expandIcon:Z["expand-icon-dark"],collapsedContent:Z["collapsed-content-dark"],noQuotesForStringValues:!1,quotesForFieldNames:!1,ariaLables:ya,stringifyStringValues:!1},zp=()=>!0,qp=e=>e<1,Up=e=>{let{data:t,style:n=_n,shouldExpandNode:s=zp,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&&ga(t)?Object.entries(t).map(d=>{let[f,h]=d;return c.createElement(Hn,{key:f,field:f,value:h,style:{..._n,...n},lastElement:!0,level:1,shouldExpandNode:s,clickToExpandNode:o,beforeExpandChange:a,outerRef:u})}):c.createElement(Hn,{value:t,style:{..._n,...n},lastElement:!0,level:0,shouldExpandNode:s,clickToExpandNode:o,outerRef:u,beforeExpandChange:a}))};var Ee={},jn,rr;function Hp(){if(rr)return jn;rr=1;const e=[[{color:"0, 0, 0",class:"ansi-black"},{color:"187, 0, 0",class:"ansi-red"},{color:"0, 187, 0",class:"ansi-green"},{color:"187, 187, 0",class:"ansi-yellow"},{color:"0, 0, 187",class:"ansi-blue"},{color:"187, 0, 187",class:"ansi-magenta"},{color:"0, 187, 187",class:"ansi-cyan"},{color:"255,255,255",class:"ansi-white"}],[{color:"85, 85, 85",class:"ansi-bright-black"},{color:"255, 85, 85",class:"ansi-bright-red"},{color:"0, 255, 0",class:"ansi-bright-green"},{color:"255, 255, 85",class:"ansi-bright-yellow"},{color:"85, 85, 255",class:"ansi-bright-blue"},{color:"255, 85, 255",class:"ansi-bright-magenta"},{color:"85, 255, 255",class:"ansi-bright-cyan"},{color:"255, 255, 255",class:"ansi-bright-white"}]],t=/(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&|%[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(h=>this.processChunk(h,a,i));if(a&&a.json){let h=l.processChunkJson("");return h.content=d,h.clearLine=a.clearLine,f.unshift(h),a.remove_empty&&(f=f.filter(m=>!m.isEmpty())),f}else f.unshift(d);return f.join("")}processChunkJson(o,a,i){a=typeof a>"u"?{}:a;let l=a.use_classes=typeof a.use_classes<"u"&&a.use_classes,u=a.key=l?"class":"color",d={content:o,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,isInverted:!1,clearLine:a.clearLine,decoration:null,decorations:[],was_processed:!1,isEmpty:()=>!d.content},f=o.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!f)return d;d.content=f[4];let h=f[2].split(";");if(f[1]!==""||f[3]!=="m"||!i)return d;let m=this;for(;h.length>0;){let x=h.shift(),g=parseInt(x);if(isNaN(g)||g===0)m.fg=m.bg=null,m.decorations=[];else if(g===1)m.decorations.push("bold");else if(g===2)m.decorations.push("dim");else if(g===3)m.decorations.push("italic");else if(g===4)m.decorations.push("underline");else if(g===5)m.decorations.push("blink");else if(g===7)m.decorations.push("reverse");else if(g===8)m.decorations.push("hidden");else if(g===9)m.decorations.push("strikethrough");else if(g===21)m.removeDecoration("bold");else if(g===22)m.removeDecoration("bold"),m.removeDecoration("dim");else if(g===23)m.removeDecoration("italic");else if(g===24)m.removeDecoration("underline");else if(g===25)m.removeDecoration("blink");else if(g===27)m.removeDecoration("reverse");else if(g===28)m.removeDecoration("hidden");else if(g===29)m.removeDecoration("strikethrough");else if(g===39)m.fg=null;else if(g===49)m.bg=null;else if(g>=30&&g<38)m.fg=e[0][g%10][u];else if(g>=90&&g<98)m.fg=e[1][g%10][u];else if(g>=40&&g<48)m.bg=e[0][g%10][u];else if(g>=100&&g<108)m.bg=e[1][g%10][u];else if(g===38||g===48){let C=g===38;if(h.length>=1){let b=h.shift();if(b==="5"&&h.length>=1){let y=parseInt(h.shift());if(y>=0&&y<=255)if(!l)this.PALETTE_COLORS||m.setupPalette(),C?m.fg=this.PALETTE_COLORS[y]:m.bg=this.PALETTE_COLORS[y];else{let k=y>=16?"ansi-palette-"+y:e[y>7?1:0][y%8].class;C?m.fg=k:m.bg=k}}else if(b==="2"&&h.length>=3){let y=parseInt(h.shift()),k=parseInt(h.shift()),v=parseInt(h.shift());if(y>=0&&y<=255&&k>=0&&k<=255&&v>=0&&v<=255){let p=y+", "+k+", "+v;l?C?(m.fg="ansi-truecolor",m.fg_truecolor=p):(m.bg="ansi-truecolor",m.bg_truecolor=p):C?m.fg=p:m.bg=p}}}}}return m.fg===null&&m.bg===null&&m.decorations.length===0||(d.fg=m.fg,d.bg=m.bg,d.fg_truecolor=m.fg_truecolor,d.bg_truecolor=m.bg_truecolor,d.decorations=m.decorations,d.decoration=m.decorations.slice(-1).pop()||null,d.was_processed=!0),d}processChunk(o,a,i){a=a||{};let l=this.processChunkJson(o,a,i),u=a.use_classes;if(l.decorations=l.decorations.filter(g=>{if(g==="reverse"){l.fg||(l.fg=e[0][7][u?"class":"color"]),l.bg||(l.bg=e[0][0][u?"class":"color"]);let C=l.fg;l.fg=l.bg,l.bg=C;let b=l.fg_truecolor;return l.fg_truecolor=l.bg_truecolor,l.bg_truecolor=b,l.isInverted=!0,!1}return!0}),a.json)return l;if(l.isEmpty())return"";if(!l.was_processed)return l.content;let d=[],f=[],h=[],m={},x=g=>{let C=[],b;for(b in g)g.hasOwnProperty(b)&&C.push("data-"+b+'="'+this.escapeForHtml(g[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(g=>{if(u){f.push("ansi-"+g);return}g==="bold"?f.push("font-weight:bold"):g==="dim"?f.push("opacity:0.5"):g==="italic"?f.push("font-style:italic"):g==="hidden"?f.push("visibility:hidden"):g==="strikethrough"?h.push("line-through"):h.push(g)}),h.length&&f.push("text-decoration:"+h.join(" ")),u?'<span class="'+d.concat(f).join(" ")+'"'+x(m)+">"+l.content+"</span>":'<span style="'+d.concat(f).join(";")+'"'+x(m)+">"+l.content+"</span>"}removeDecoration(o){const a=this.decorations.indexOf(o);a>=0&&this.decorations.splice(a,1)}}return jn=n,jn}var ht={exports:{}},or;function Wp(){if(or)return ht.exports;or=1;function e(o){if(!o)return"";if(!/\r/.test(o))return o;for(o=o.replace(/\r+\n/gm,`
|
|
37
|
-
`);/\r./.test(o);)o=o.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm,function(a,i,l){return l+i.slice(l.length)});return o}function t(o){for(var a=0,i=0;i<o.length;i++)o[a].length<=o[i].length&&(a=i);return a}function n(o){if(!/\r/.test(o))return o;for(var a=o.split("\r"),i=[];a.length>0;){var l=t(a);i.push(a[l]),a=a.slice(l+1)}return i.join("\r")}function s(o){if(!o)return"";if(!/\r/.test(o))return o;if(!/\n/.test(o))return n(o);o=o.replace(/\r+\n/gm,`
|
|
38
|
-
`);var a=o.lastIndexOf(`
|
|
39
|
-
`);return e(o.slice(0,a))+`
|
|
40
|
-
`+n(o.slice(a+1))}return ht.exports=e,ht.exports.escapeCarriageReturn=e,ht.exports.escapeCarriageReturnSafe=s,ht.exports}var qe={},ar;function Gp(){if(ar)return qe;ar=1;var e=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,t=/[\0-\x1F\x7F-\x9F]/,n=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,s=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,o=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,a=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;return qe.Any=e,qe.Cc=t,qe.Cf=n,qe.P=s,qe.S=o,qe.Z=a,qe}var wn,ir;function Vp(){if(ir)return wn;ir=1;var e=Gp();function t(v){const p={};v=v||{},p.src_Any=e.Any.source,p.src_Cc=e.Cc.source,p.src_Z=e.Z.source,p.src_P=e.P.source,p.src_ZPCc=[p.src_Z,p.src_P,p.src_Cc].join("|"),p.src_ZCc=[p.src_Z,p.src_Cc].join("|");const _="[><|]";return p.src_pseudo_letter=`(?:(?!${_}|${p.src_ZPCc})${p.src_Any})`,p.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",p.src_auth=`(?:(?:(?!${p.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`,p.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",p.src_host_terminator=`(?=$|${_}|${p.src_ZPCc})(?!${v["---"]?"-(?!--)|":"-|"}_|:\\d|\\.-|\\.(?!$|${p.src_ZPCc}))`,p.src_path=`(?:[/?#](?:(?!${p.src_ZCc}|${_}|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!${p.src_ZCc}|\\]).)*\\]|\\((?:(?!${p.src_ZCc}|[)]).)*\\)|\\{(?:(?!${p.src_ZCc}|[}]).)*\\}|\\"(?:(?!${p.src_ZCc}|["]).)+\\"|\\'(?:(?!${p.src_ZCc}|[']).)+\\'|\\'(?=${p.src_pseudo_letter}|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!${p.src_ZCc}|[.]|$)|`+(v["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+`,(?!${p.src_ZCc}|$)|;(?!${p.src_ZCc}|$)|\\!+(?!${p.src_ZCc}|[!]|$)|\\?(?!${p.src_ZCc}|[?]|$))+|\\/)?`,p.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}',p.src_xn="xn--[a-z0-9\\-]{1,59}",p.src_domain_root="(?:"+p.src_xn+`|${p.src_pseudo_letter}{1,63})`,p.src_domain="(?:"+p.src_xn+`|(?:${p.src_pseudo_letter})|(?:${p.src_pseudo_letter}(?:-|${p.src_pseudo_letter}){0,61}${p.src_pseudo_letter}))`,p.src_host=`(?:(?:(?:(?:${p.src_domain})\\.)*${p.src_domain}))`,p.tpl_host_fuzzy="(?:"+p.src_ip4+`|(?:(?:(?:${p.src_domain})\\.)+(?:%TLDS%)))`,p.tpl_host_no_ip_fuzzy=`(?:(?:(?:${p.src_domain})\\.)+(?:%TLDS%))`,p.src_host_strict=p.src_host+p.src_host_terminator,p.tpl_host_fuzzy_strict=p.tpl_host_fuzzy+p.src_host_terminator,p.src_host_port_strict=p.src_host+p.src_port+p.src_host_terminator,p.tpl_host_port_fuzzy_strict=p.tpl_host_fuzzy+p.src_port+p.src_host_terminator,p.tpl_host_port_no_ip_fuzzy_strict=p.tpl_host_no_ip_fuzzy+p.src_port+p.src_host_terminator,p.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${p.src_ZPCc}|>|$))`,p.tpl_email_fuzzy=`(^|${_}|"|\\(|${p.src_ZCc})(${p.src_email_name}@${p.tpl_host_fuzzy_strict})`,p.tpl_link_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${p.src_ZPCc}))((?![$+<=>^\`||])${p.tpl_host_port_fuzzy_strict}${p.src_path})`,p.tpl_link_no_ip_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${p.src_ZPCc}))((?![$+<=>^\`||])${p.tpl_host_port_no_ip_fuzzy_strict}${p.src_path})`,p}function n(v){return Array.prototype.slice.call(arguments,1).forEach(function(_){_&&Object.keys(_).forEach(function(j){v[j]=_[j]})}),v}function s(v){return Object.prototype.toString.call(v)}function o(v){return s(v)==="[object String]"}function a(v){return s(v)==="[object Object]"}function i(v){return s(v)==="[object RegExp]"}function l(v){return s(v)==="[object Function]"}function u(v){return v.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const d={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function f(v){return Object.keys(v||{}).reduce(function(p,_){return p||d.hasOwnProperty(_)},!1)}const h={"http:":{validate:function(v,p,_){const j=v.slice(p);return _.re.http||(_.re.http=new RegExp(`^\\/\\/${_.re.src_auth}${_.re.src_host_port_strict}${_.re.src_path}`,"i")),_.re.http.test(j)?j.match(_.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(v,p,_){const j=v.slice(p);return _.re.no_http||(_.re.no_http=new RegExp("^"+_.re.src_auth+`(?:localhost|(?:(?:${_.re.src_domain})\\.)+${_.re.src_domain_root})`+_.re.src_port+_.re.src_host_terminator+_.re.src_path,"i")),_.re.no_http.test(j)?p>=3&&v[p-3]===":"||p>=3&&v[p-3]==="/"?0:j.match(_.re.no_http)[0].length:0}},"mailto:":{validate:function(v,p,_){const j=v.slice(p);return _.re.mailto||(_.re.mailto=new RegExp(`^${_.re.src_email_name}@${_.re.src_host_strict}`,"i")),_.re.mailto.test(j)?j.match(_.re.mailto)[0].length:0}}},m="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",x="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function g(v){return function(p,_){const j=p.slice(_);return v.test(j)?j.match(v)[0].length:0}}function C(){return function(v,p){p.normalize(v)}}function b(v){const p=v.re=t(v.__opts__),_=v.__tlds__.slice();v.onCompile(),v.__tlds_replaced__||_.push(m),_.push(p.src_xn),p.src_tlds=_.join("|");function j(A){return A.replace("%TLDS%",p.src_tlds)}p.email_fuzzy=RegExp(j(p.tpl_email_fuzzy),"i"),p.email_fuzzy_global=RegExp(j(p.tpl_email_fuzzy),"ig"),p.link_fuzzy=RegExp(j(p.tpl_link_fuzzy),"i"),p.link_fuzzy_global=RegExp(j(p.tpl_link_fuzzy),"ig"),p.link_no_ip_fuzzy=RegExp(j(p.tpl_link_no_ip_fuzzy),"i"),p.link_no_ip_fuzzy_global=RegExp(j(p.tpl_link_no_ip_fuzzy),"ig"),p.host_fuzzy_test=RegExp(j(p.tpl_host_fuzzy_test),"i");const D=[];v.__compiled__={};function T(A,S){throw new Error(`(LinkifyIt) Invalid schema "${A}": ${S}`)}Object.keys(v.__schemas__).forEach(function(A){const S=v.__schemas__[A];if(S===null)return;const E={validate:null,link:null};if(v.__compiled__[A]=E,a(S)){i(S.validate)?E.validate=g(S.validate):l(S.validate)?E.validate=S.validate:T(A,S),l(S.normalize)?E.normalize=S.normalize:S.normalize?T(A,S):E.normalize=C();return}if(o(S)){D.push(A);return}T(A,S)}),D.forEach(function(A){v.__compiled__[v.__schemas__[A]]&&(v.__compiled__[A].validate=v.__compiled__[v.__schemas__[A]].validate,v.__compiled__[A].normalize=v.__compiled__[v.__schemas__[A]].normalize)}),v.__compiled__[""]={validate:null,normalize:C()};const N=Object.keys(v.__compiled__).filter(function(A){return A.length>0&&v.__compiled__[A]}).map(u).join("|");v.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|${p.src_ZPCc}))(${N})`,"i"),v.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|${p.src_ZPCc}))(${N})`,"ig"),v.re.schema_at_start=RegExp(`^${v.re.schema_search.source}`,"i"),v.re.pretest=RegExp(`(${v.re.schema_test.source})|(${v.re.host_fuzzy_test.source})|@`,"i")}function y(v,p,_,j){const D=v.slice(_,j);this.schema=p.toLowerCase(),this.index=_,this.lastIndex=j,this.raw=D,this.text=D,this.url=D}function k(v,p){if(!(this instanceof k))return new k(v,p);p||f(v)&&(p=v,v={}),this.__opts__=n({},d,p),this.__schemas__=n({},h,v),this.__compiled__={},this.__tlds__=x,this.__tlds_replaced__=!1,this.re={},b(this)}return k.prototype.add=function(p,_){return this.__schemas__[p]=_,b(this),this},k.prototype.set=function(p){return this.__opts__=n(this.__opts__,p),this},k.prototype.test=function(p){if(!p.length)return!1;let _,j;if(this.re.schema_test.test(p)){for(j=this.re.schema_search,j.lastIndex=0;(_=j.exec(p))!==null;)if(this.testSchemaAt(p,_[2],j.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&p.search(this.re.host_fuzzy_test)>=0&&p.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&p.indexOf("@")>=0&&p.match(this.re.email_fuzzy)!==null)},k.prototype.pretest=function(p){return this.re.pretest.test(p)},k.prototype.testSchemaAt=function(p,_,j){return this.__compiled__[_.toLowerCase()]?this.__compiled__[_.toLowerCase()].validate(p,j,this):0},k.prototype.match=function(p){const _=[],j=[],D=[],T=[];let N,A,S;function E(M,F){return M?F?M.index!==F.index?M.index<F.index?M:F:M.lastIndex>=F.lastIndex?M:F:M:F}if(!p.length)return null;if(this.re.schema_test.test(p))for(S=this.re.schema_search,S.lastIndex=0;(N=S.exec(p))!==null;)A=this.testSchemaAt(p,N[2],S.lastIndex),A&&j.push({schema:N[2],index:N.index+N[1].length,lastIndex:N.index+N[0].length+A});if(this.__opts__.fuzzyLink&&this.__compiled__["http:"])for(S=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,S.lastIndex=0;(N=S.exec(p))!==null;)D.push({schema:"",index:N.index+N[1].length,lastIndex:N.index+N[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"])for(S=this.re.email_fuzzy_global,S.lastIndex=0;(N=S.exec(p))!==null;)T.push({schema:"mailto:",index:N.index+N[1].length,lastIndex:N.index+N[0].length});const w=[0,0,0];let R=0;for(;;){const M=[j[w[0]],T[w[1]],D[w[2]]],F=E(E(M[0],M[1]),M[2]);if(!F)break;if(F===M[0]?w[0]++:F===M[1]?w[1]++:w[2]++,F.index<R)continue;const O=new y(p,F.schema,F.index,F.lastIndex);this.__compiled__[O.schema].normalize(O,this),_.push(O),R=F.lastIndex}return _.length?_:null},k.prototype.matchAtStart=function(p){if(!p.length)return null;const _=this.re.schema_at_start.exec(p);if(!_)return null;const j=this.testSchemaAt(p,_[2],_[0].length);if(!j)return null;const D=new y(p,_[2],_.index+_[1].length,_.index+_[0].length+j);return this.__compiled__[D.schema].normalize(D,this),D},k.prototype.tlds=function(p,_){return p=Array.isArray(p)?p:[p],_?(this.__tlds__=this.__tlds__.concat(p).sort().filter(function(j,D,T){return j!==T[D-1]}).reverse(),b(this),this):(this.__tlds__=p.slice(),this.__tlds_replaced__=!0,b(this),this)},k.prototype.normalize=function(p){p.schema||(p.url=`http://${p.url}`),p.schema==="mailto:"&&!/^mailto:/i.test(p.url)&&(p.url=`mailto:${p.url}`)},k.prototype.onCompile=function(){},wn=k,wn}var lr;function Kp(){if(lr)return Ee;lr=1;var e=Ee&&Ee.__createBinding||(Object.create?(function(b,y,k,v){v===void 0&&(v=k);var p=Object.getOwnPropertyDescriptor(y,k);(!p||("get"in p?!y.__esModule:p.writable||p.configurable))&&(p={enumerable:!0,get:function(){return y[k]}}),Object.defineProperty(b,v,p)}):(function(b,y,k,v){v===void 0&&(v=k),b[v]=y[k]})),t=Ee&&Ee.__setModuleDefault||(Object.create?(function(b,y){Object.defineProperty(b,"default",{enumerable:!0,value:y})}):function(b,y){b.default=y}),n=Ee&&Ee.__importStar||(function(){var b=function(y){return b=Object.getOwnPropertyNames||function(k){var v=[];for(var p in k)Object.prototype.hasOwnProperty.call(k,p)&&(v[v.length]=p);return v},b(y)};return function(y){if(y&&y.__esModule)return y;var k={};if(y!=null)for(var v=b(y),p=0;p<v.length;p++)v[p]!=="default"&&e(k,y,v[p]);return t(k,y),k}})(),s=Ee&&Ee.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(Ee,"__esModule",{value:!0}),Ee.default=g;const o=s(Hp()),a=Wp(),i=s(Vp()),l=n(fl());function u(b,y=!1){return b=(0,a.escapeCarriageReturn)(C(b)),o.default.ansiToJson(b,{json:!0,remove_empty:!0,use_classes:y})}function d(b){let y="";return b.bg&&(y+=`${b.bg}-bg `),b.fg&&(y+=`${b.fg}-fg `),b.decoration&&(y+=`ansi-${b.decoration} `),y===""?null:(y=y.substring(0,y.length-1),y)}function f(b){const y={};switch(b.bg&&(y.backgroundColor=`rgb(${b.bg})`),b.fg&&(y.color=`rgb(${b.fg})`),b.decoration){case"bold":y.fontWeight="bold";break;case"dim":y.opacity="0.5";break;case"italic":y.fontStyle="italic";break;case"hidden":y.visibility="hidden";break;case"strikethrough":y.textDecoration="line-through";break;case"underline":y.textDecoration="underline";break;case"blink":y.textDecoration="blink";break}return y}function h(b,y,k,v){const p=y?null:f(k),_=y?d(k):null;return b?b==="fuzzy"?x(k,v,p,_):m(k,v,p,_):l.createElement("span",{style:p,key:v,className:_},k.content)}function m(b,y,k,v){const p=[],_=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let j=0,D;for(;(D=_.exec(b.content))!==null;){const[,T,N]=D,A=D.index+T.length;A>j&&p.push(b.content.substring(j,A));const S=N.startsWith("www.")?`http://${N}`:N;p.push(l.createElement("a",{key:j,href:S,target:"_blank"},`${N}`)),j=_.lastIndex}return j<b.content.length&&p.push(b.content.substring(j)),l.createElement("span",{style:k,key:y,className:v},p)}function x(b,y,k,v){var p;const _=(0,i.default)({fuzzyEmail:!1}).tlds(["io"],!0);if(!_.pretest(b.content))return l.createElement("span",{style:k,key:y,className:v},b.content);const j=_.match(b.content);if(!j)return l.createElement("span",{style:k,key:y,className:v},b.content);const D=[b.content.substring(0,(p=j[0])===null||p===void 0?void 0:p.index)];return j.forEach((T,N)=>{var A;D.push(l.createElement("a",{href:T.url,target:"_blank",key:N},b.content.substring(T.index,T.lastIndex))),j[N+1]&&D.push(b.content.substring(j[N].lastIndex,(A=j[N+1])===null||A===void 0?void 0:A.index))}),j[j.length-1].lastIndex!==b.content.length&&D.push(b.content.substring(j[j.length-1].lastIndex,b.content.length)),l.createElement("span",{style:k,key:y,className:v},D)}function g(b){const{className:y,useClasses:k,children:v,linkify:p}=b;return l.createElement("code",{className:y},u(v??"",k??!1).map(h.bind(null,p??!1,k??!1)))}function C(b){let y=b;do b=y,y=b.replace(/[^\n]\x08/gm,"");while(y.length<b.length);return b}return Ee}var Qp=Kp();const Xp=ml(Qp),Yp=c.lazy(()=>pl(()=>import("./index-C5or4L_3.js"),__vite__mapDeps([0,1,2,3]))),Jp={...Bp,container:"bg-transparent text-xs font-mono leading-relaxed",label:"text-muted-foreground font-medium mr-1",clickableLabel:"text-muted-foreground font-medium mr-1 cursor-pointer",nullValue:"text-muted-foreground italic",undefinedValue:"text-muted-foreground italic",stringValue:"text-foreground",booleanValue:"text-amber-400",numberValue:"text-blue-400",otherValue:"text-muted-foreground",punctuation:"text-muted-foreground",collapseIcon:'text-muted-foreground mr-1 cursor-pointer text-[1.2em] select-none after:content-["▾"]',expandIcon:'text-muted-foreground mr-1 cursor-pointer text-[1.2em] select-none after:content-["▸"]',collapsedContent:'text-muted-foreground mr-1 cursor-pointer after:text-[0.8em] after:content-["…"]'},cr=5120;function Zp(e){try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&("old_string"in t||"new_string"in t)?t:null}catch{return null}}function Nn({children:e,rawContent:t,supportsRawToggle:n,isRaw:s,onToggleRaw:o}){const[a,i]=c.useState(!1),l=t.length>cr,u=l&&!a?t.slice(0,cr):t;return r.jsxs("div",{className:"space-y-1",children:[n&&r.jsx("div",{className:"flex justify-end",children:r.jsx("button",{onClick:o,className:"text-muted-foreground hover:text-foreground text-xs underline",children:s?"Formatted":"Raw"})}),s?r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:u}),l&&!a&&r.jsxs("button",{onClick:()=>i(!0),className:"text-muted-foreground hover:text-foreground text-xs underline",children:["Show full output (",(t.length/1024).toFixed(1),"KB)"]})]}):e]})}function eh({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(Yp,{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 va({content:e,toolName:t,input:n}){const[s,o]=c.useState(!1);if(t==="Edit"&&n){const i=Zp(n);if(i)return r.jsx(eh,{oldValue:i.old_string??"",newValue:i.new_string??"",rawContent:e})}const a=Fd(e);if(a==="json"){let i;try{i=JSON.parse(e)}catch{i={}}return r.jsx(Nn,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>o(l=>!l),children:r.jsx(Up,{data:i,style:Jp,shouldExpandNode:qp})})}return a==="ansi"?r.jsx(Nn,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>o(i=>!i),children:r.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:r.jsx(Xp,{children:e})})}):r.jsx(Nn,{rawContent:e,supportsRawToggle:!1,isRaw:!0,onToggleRaw:()=>{},children:null})}function th(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 nh(e){const t=th(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 ka="runtimes";function sh({label:e}){const{open:t}=uo();return r.jsx("button",{type:"button",onClick:()=>t(ka),className:"text-muted-foreground hover:text-foreground mt-2 block text-xs underline decoration-dotted underline-offset-2 transition-colors",children:e})}function rh({runtime:e,sessionId:t,onRetry:n,onSigninComplete:s}){const[o,a]=c.useState(!1),i=Hu(e,{sessionId:t,onCompleted:()=>a((s==null?void 0:s())??!1)}),l=Wu(e);return i.isSuccess?r.jsxs("div",{className:"mt-3","data-testid":"auth-error-signin-success",children:[r.jsxs("p",{className:"text-status-success-fg flex items-center gap-2 text-sm",role:"status",children:[r.jsx(Jt,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),o?"Signed in. Sending your message again…":"Signed in."]}),!o&&n&&r.jsxs(le,{size:"sm",onClick:n,className:"mt-2 gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]})]}):r.jsxs("div",{className:"mt-3","data-testid":"auth-error-signin",children:[r.jsx("p",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-sm",role:"status",children:i.isPending&&r.jsxs(r.Fragment,{children:[r.jsx(Le,{size:"xs",className:"shrink-0"}),l.signInPending]})}),i.isError&&r.jsx("p",{className:"text-destructive mb-2 text-sm",role:"alert",children:i.errorMessage}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(le,{size:"sm",onClick:i.login,disabled:i.isPending,className:"gap-1.5","data-testid":"auth-error-signin-button",children:[r.jsx(fo,{className:"size-3"}),i.isError?"Try again":l.signInLabel]}),n&&r.jsxs(le,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]})]}),r.jsx(sh,{label:"Use an API key instead"})]})}function ur({onRetry:e}){return r.jsx("div",{className:"mt-3","data-testid":"auth-error-remote-guidance",children:r.jsx(qu,{...e?{onRetry:e}:{}})})}function Ca({onRetry:e}){const{open:t}=uo();return r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r.jsxs(le,{size:"sm",onClick:()=>t(ka),className:"gap-1.5",children:[r.jsx(fo,{className:"size-3"}),"Fix sign-in"]}),e&&r.jsxs(le,{variant:"outline",size:"sm",onClick:e,className:"gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]})]})}function oh({runtime:e,sessionId:t,onRetry:n,renderOffer:s,lead:o,children:a}){const i=!Mo(),l=mo(),u=ae(m=>m.setRetryAccount),d=Tt(e).label,f=s({runtime:e,origin:`auth-error:${t}`,note:`This makes new ${d} work on this computer run on your DorkOS credits.`,chosen:n?`New ${d} work on this computer now runs on your DorkOS credits. Sending your message again…`:`New ${d} work on this computer now runs on your DorkOS credits.`,...n?{confirmAfterLink:{prompt:"Linked. Send again on DorkOS credits?",action:"Send again"}}:{},onChoose:async()=>{await l.mutateAsync({runtime:e,useCredits:!0}),n&&(u({id:lt,sessionId:t}),n())}}),h=m=>r.jsxs("section",{"aria-label":"Other ways",children:[r.jsx("p",{className:"text-muted-foreground text-2xs font-medium tracking-wide uppercase",children:"Other ways"}),m]});return o?r.jsxs("div",{className:"mt-3 space-y-3","data-testid":"auth-error-credits-first",children:[f,h(a),r.jsx(Uu,{ollama:hl(e)==="provider-picker",remote:i})]}):r.jsxs("div",{"data-testid":"auth-error-credits-other-way",children:[a,r.jsx("div",{className:"mt-3",children:h(f)})]})}function ah({sessionId:e,onRetry:t,onSigninComplete:n}){var h;const{sessions:s,isLoading:o}=Jn(),a=Mo(),i=(h=s.find(m=>m.id===e))==null?void 0:h.runtime,l=zu(i),u=ro(),d=i!==void 0&&u!==null&&(l==="lead"||l==="other-way");if(!a&&!d)return r.jsx(ur,{onRetry:t});if(o)return null;const f=a?!i||!gl(i)?r.jsx(Ca,{onRetry:t}):r.jsx(rh,{runtime:i,sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(ur,{onRetry:t});return d&&i&&u?r.jsx(oh,{runtime:i,sessionId:e,onRetry:t,renderOffer:u,lead:l==="lead",children:f}):f}function ih({sessionId:e,onRetry:t,onSigninComplete:n}){return e?r.jsx(ah,{sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(Ca,{onRetry:t})}const lh="credits_unavailable",ch="folder-sign-in";function uh({onRetry:e,sessionId:t,runtimeLabel:n,reason:s}){const o=ae(g=>g.setRetryAccount),a=xl(),i=mo(),l=po(),u=sn(t),d=tn(u??null);if(!e)return null;const f=dh(d),h=n?`your ${n}`:"your own",m=()=>{if(d!==void 0){if(f==="pick-for-send"){t&&o({id:vt,sessionId:t}),e();return}i.mutate({runtime:d.type,useCredits:!1},{onSuccess:()=>f==="new-conversation"?l(void 0,{runtime:d.type}):e()})}},x=()=>{t&&a.mutate(t,{onSuccess:({launch:g})=>{g!=null&&g.ok&&o({id:g.accountId,sessionId:t}),e()}})};return r.jsxs("div",{className:"mt-2 flex flex-col gap-2","data-testid":"credits-error-actions",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(le,{size:"sm",variant:"outline",onClick:e,className:"gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]}),t&&r.jsx(le,{size:"sm",variant:"outline",onClick:m,disabled:d===void 0||i.isPending,children:f==="new-conversation"?`Start a new chat on ${h} sign-in`:`Use ${h} sign-in`}),t&&s===ch&&r.jsx(le,{size:"sm",variant:"outline",onClick:x,disabled:a.isPending,children:"Don’t use credits in this project"})]}),t&&f==="whole-runtime"&&r.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"credits-own-sign-in-reach",children:["This moves all ",n??"its"," chats to ",h," sign-in, not just this one."]}),a.error&&r.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:a.error.message}),i.isError&&r.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:"Couldn’t switch to your own sign-in. Try again in a moment."})]})}function dh(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 fh({category:e,onChooseModel:t}){return t?r.jsxs(le,{size:"sm",onClick:t,className:"mt-3 gap-1.5",children:[r.jsx(ho,{className:"size-3"}),e==="runtime_update_required"?"Choose another model":"Choose model"]}):null}const mh="your agent",ph="agent",dr={max_turns:{heading:"Turn limit reached",subtext:"The agent ran for its maximum number of turns.",retryable:!1},execution_error:{heading:"Agent stopped unexpectedly",subtext:"Something went wrong before it finished.",retryable:!0},budget_exceeded:{heading:"Cost limit reached",subtext:"This chat hit its spending limit.",retryable:!1},output_format_error:{heading:"Output format error",subtext:"The agent couldn’t produce the required output format.",retryable:!1},auth_error:{heading:"Sign in again",subtext:"Your login stopped working. Sign in again to continue.",retryable:!0},model_unavailable:{heading:"Model unavailable",subtext:"Choose another model from the model menu.",retryable:!1},runtime_update_required:{heading:"Codex update required",subtext:"Update DorkOS or your Codex install, then try again. Or choose another model.",retryable:!1}},hh=new Set(["max_turns","budget_exceeded","output_format_error","auth_error"]);function gh(e){return`Sign in to ${e??mh} again`}function xh(e){return`Your ${e??ph} login stopped working. Sign in again to continue.`}const bh="rate_limit";function on(e){const{code:t,at:n,sessionId:s,reason:o}=e;return t===go&&o?r.jsx(Go,{agentId:o}):t===bh&&s?r.jsx(tm,{sessionId:s,at:n??"",fallback:r.jsx(fr,{...e})}):r.jsx(fr,{...e})}function fr({message:e,category:t,details:n,onRetry:s,heading:o,subtext:a,runtimeLabel:i,sessionId:l,onSigninComplete:u,onChooseModel:d,code:f,reason:h}){const[m,x]=c.useState(!1),g=f===lh,C=c.useMemo(()=>nh(e),[e]),b=(C==null?void 0:C.category)??t,y=(C==null?void 0:C.message)??e,k=C?n!=null&&n.includes(C.details??"")?n:[n,C.details].filter(Boolean).join(`
|
|
41
|
-
`):n,v=b==="auth_error",p=b?dr[b]??dr.execution_error:null,_=v?gh(i):b==="runtime_update_required"&&i?`${i} update required`:p==null?void 0:p.heading,j=v?xh(i):p==null?void 0:p.subtext,D=g?"Couldn’t reach DorkOS credits":C?_??"Error":o??_??"Error",T=y.trim(),N=b!==void 0&&hh.has(b),A=g?T:(C&&(a==null?void 0:a.trim())===e.trim()?void 0:a)??(N?j:T||j)??T,S=A.trim(),E=c.useMemo(()=>bl(T),[T]),w=!T||T===S||T===D,R=!w&&(!N||E)?T:null,M=w||R!==null||k!=null&&k.includes(T)?k:[k,T].filter(Boolean).join(`
|
|
42
|
-
`),F=(p==null?void 0:p.retryable)??!!s;return r.jsx("div",{"data-testid":"error-message-block",className: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(cs,{className:"text-destructive mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium",children:D}),r.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(fn,{text:A})}),R&&r.jsx("p",{className:"text-muted-foreground mt-1 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(fn,{text:R})}),M&&r.jsxs("button",{type:"button",onClick:()=>x(!m),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":m,children:[r.jsx(W.div,{animate:{rotate:m?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:r.jsx(Dt,{className:"size-3"})}),"Details"]}),r.jsx(ce,{initial:!1,children:m&&M&&r.jsx(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"overflow-hidden",children:r.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:r.jsx(fn,{text:M})})})}),g&&r.jsx(uh,{onRetry:s,sessionId:l,runtimeLabel:i,reason:h}),v&&r.jsx(ih,{sessionId:l,onRetry:s,onSigninComplete:u}),(b==="model_unavailable"||b==="runtime_update_required")&&r.jsx(fh,{category:b,onChooseModel:d})]}),!v&&!g&&F&&s&&r.jsxs(le,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[r.jsx(Ct,{className:"size-3"}),"Retry"]})]})})}const yh=8;function vh({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,yh)}`: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(Ju,{"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 kh=50;function Ch(e){return e.type==="tool_call"&&e.interactiveType==="approval"&&e.approvalOutcome!==void 0}function Sh(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)<=kh}function _h(e){const t=new Map;let n=null;for(let s=0;s<e.length;s++){const o=e[s];if(!Ch(o)){n=null;continue}if(n&&Sh(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 jh(e){return e.questionOutcome!==void 0?e.questionOutcome==="answered":e.status!=="pending"}function wh(e){return e.status==="pending"?void 0:e.questionOutcome}function Nh({message:e}){return r.jsx(st,{"data-testid":"unreadable-entry-note",icon:r.jsx(yl,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:e})})}function Eh({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(xt,{"aria-hidden":"true",className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm",children:"The agent stopped waiting for your answer."}),r.jsxs("p",{className:"text-muted-foreground mt-0.5 text-xs",children:["“",e,"” is still in Approvals. Answer it, then ask the agent to retry."]})]})]})}function Wn({testId:e,icon:t,children:n}){return r.jsxs("div",{"data-testid":e,className: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 Dh({part:e}){return e.outcome==="failed"?r.jsx(Wn,{testId:"mcp-signin-failed",icon:r.jsx(cs,{"aria-hidden":"true",className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),children:r.jsxs("p",{className:"text-sm",children:["Sign-in to “",e.serverName,"” didn’t finish. Ask your agent to retry."]})}):r.jsx(Wn,{testId:"mcp-signin-receipt",icon:r.jsx(xo,{"aria-hidden":"true",className:"text-status-success mt-0.5 size-4 shrink-0"}),children:r.jsxs("p",{className:"text-sm",children:["Connected to ",e.serverName,e.toolCount===void 0?"":` · ${e.toolCount} tool${e.toolCount===1?"":"s"}`,"."]})})}function Th({part:e}){const t=Zu(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(Dh,{part:e}):r.jsxs(Wn,{testId:"mcp-signin-card",icon:r.jsx(vl,{"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(ed,{flow:t,serverName:e.serverName,failedActions:r.jsx(le,{variant:"secondary",size:"sm",onClick:()=>t.start(),className:"focus-visible:ring-2",children:"Try again"})})]})}function Ah({fromName:e,toName:t}){return r.jsx(st,{"data-testid":"model-substituted-row",icon:r.jsx(ho,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsxs("span",{className:"text-muted-foreground",children:["DorkOS credits don’t cover ",e,", so this ran on ",t,". Switch in the model menu."]})})}const Fh={running:r.jsx(Le,{size:"xs",className:"text-muted-foreground"}),success:r.jsx(Jt,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:r.jsx(it,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:r.jsx(it,{className:"text-muted-foreground size-(--size-icon-xs)"})};function Rh({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:[Fh[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(ce,{initial:!1,children:n&&t&&o&&r.jsx(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"overflow-hidden",children:r.jsx("pre",{className:"text-muted-foreground max-h-32 overflow-y-auto py-1 text-xs whitespace-pre-wrap",children:o})})})]})}function Mh({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(Rh,{hook:u},u.hookId))}):void 0,i=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,l=kl(e.toolName);return r.jsxs(Ft,{expanded:n,onToggle:()=>s(!n),dimmed:e.status==="complete",extraContent:a,"data-testid":"tool-call-card","data-tool-name":e.toolName,"data-status":e.status,header:r.jsxs(r.Fragment,{children:[ia(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:td(i)})]}),children:[e.status==="running"&&!e.input?r.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 py-1 text-xs",children:[r.jsx(Le,{size:"xs"}),r.jsx("span",{children:"Preparing…"})]}):e.input!==void 0&&e.input!==""?r.jsx(Cl,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&r.jsx(eo,{content:e.progressOutput,className:"mt-2 border-t pt-2"}),e.result&&r.jsx("div",{className:"mt-2 border-t pt-2",children:r.jsx(va,{content:e.result,toolName:e.toolName,input:e.input})})]})}function Ih(e){if(e.startsWith("mcp__"))return e.split("__")[1]||void 0}function Sa(e,t,n){const s=c.useRef(e),[o,a]=c.useState(!(t&&s.current==="complete"));return c.useEffect(()=>{if(t&&e==="complete"&&s.current!=="complete"&&!n){const i=setTimeout(()=>a(!1),en.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(i)}},[e,t,n]),!t||n?!0:o}function Oh({part:e,autoHide:t,expandToolCalls:n}){var a;const s=((a=e.hooks)==null?void 0:a.some(i=>i.status==="error"))??!1,o=Sa(e.status,t,s);return r.jsx(ce,{children:o&&r.jsx(W.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx(Mh,{toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input||"",result:e.result,progressOutput:e.progressOutput,status:e.status,hooks:e.hooks,startedAt:e.startedAt,completedAt:e.completedAt},defaultExpanded:n})},e.toolCallId)})}function En({part:e,sessionId:t,autoHide:n,expandToolCalls:s}){const o=e.ui?Ih(e.toolName):void 0,a=r.jsx(Oh,{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(sf,{sessionId:t,serverName:o,uri:e.ui.resourceUri})]})}function $h({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",o=Sa(s,t,!1);return r.jsx(ce,{children:o&&r.jsx(W.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx(xp,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const Ph=4,mr=2;function Lh({children:e}){const[t,n]=c.useState(!1);if(e.length<=Ph||t)return r.jsx(r.Fragment,{children:e});const s=e.length-mr;return r.jsxs(r.Fragment,{children:[e.slice(0,mr),r.jsx(Ft,{expanded:!1,onToggle:()=>n(!0),ariaLabel:`Show ${s} more steps`,className:"border-l-muted-foreground/15",header:r.jsxs("span",{className:"text-3xs text-muted-foreground font-mono",children:["and ",s," more steps…"]}),children:r.jsx(r.Fragment,{})})]})}const Bh=/\|\||&&|;|\|/,zh=/<<|>/,pr=60;function qh(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 Oe(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function Uh(e,t){const n=e.split(`
|
|
43
|
-
`),s=t.split(`
|
|
44
|
-
`);let o=0;for(;o<n.length&&o<s.length&&n[o]===s[o];)o++;let a=0;for(;a<n.length-o&&a<s.length-o&&n[n.length-1-a]===s[s.length-1-a];)a++;const i=o+a;return{additions:Math.max(0,s.length-i),deletions:Math.max(0,n.length-i)}}function Gn(e){const t=e.old_string,n=e.new_string;if(!(typeof t!="string"&&typeof n!="string"))return Uh(typeof t=="string"?t:"",typeof n=="string"?n:"")}function Hh(e){const t=e.edits;if(!Array.isArray(t))return Gn(e);let n=0,s=0,o=!1;for(const a of t){if(typeof a!="object"||a===null)continue;const i=Gn(a);i&&(n+=i.additions,s+=i.deletions,o=!0)}return o?{additions:n,deletions:s}:void 0}function Wh(e){return e?` +${e.additions} −${e.deletions}`:""}function Gh(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 Vh(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 ja(e){const t=_a(e).split("/");return t[t.length-1]||e}function Kh(e){try{const t=new URL(e);return t.hash="",t.toString()}catch{return e}}function Qh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Xh(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 Yh(e){var s;const n=((s=e.split(`
|
|
47
|
-
`).find(o=>o.trim().length>0))==null?void 0:s.trim())??e.trim();return n.length<=pr?n:`${n.slice(0,pr-1).trimEnd()}…`}function Jh(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 Zh(e){const t=[];for(const n of e.split(`
|
|
48
|
-
`)){for(const s of n.split(Bh)){const o=Jh(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(zh.test(n))break}return t}const hr={delete:3,create:2,edit:1,read:0,search:0,fetch:0,run:0},eg=new Set(["Task","Agent","TodoWrite"]);function xs(e){return e===1?"1 hit":`${e} hits`}const tg=/[*?[\]~$]/;function gt(e,t,n,s,o){const a=_a(e);return{key:`file:${a}`,kind:"file",label:o===!0?a:ja(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 ng(e){const{toolName:t}=e;if(eg.has(t)||t.startsWith("mcp__"))return[];const n=qh(e.input);if(!n)return[];switch(t){case"Read":{const s=Oe(n,"file_path");return s?[gt(s,"read","read")]:[]}case"Glob":{const s=Oe(n,"pattern");return s?[{key:`file:${s}`,kind:"file",label:s,fullTarget:s,verb:"read",entry:"globbed",pattern:!0}]:[]}case"Grep":{const s=Oe(n,"pattern");if(!s)return[];const o=e.status==="error"?void 0:Xh(e.result);return[{key:`grep:${s}`,kind:"command",label:`"${s}"`,fullTarget:s,verb:"search",entry:o===void 0?"searched":`searched (${xs(o)})`,hits:o}]}case"Edit":case"MultiEdit":case"NotebookEdit":{const s=Oe(n,"file_path")??Oe(n,"notebook_path");if(!s)return[];const o=t==="MultiEdit"?Hh(n):Gn(n);return[gt(s,"edit",`edited${Wh(o)}`,o)]}case"Write":{const s=Oe(n,"file_path");if(!s)return[];if(!/created/i.test(e.result??""))return[gt(s,"edit","wrote")];const a=Oe(n,"content"),i=a===void 0?void 0:{additions:Gh(a)};return[gt(s,"create",`created${i?` +${i.additions}`:""}`,i)]}case"Bash":{const s=Oe(n,"command");if(!s)return[];const o=[{key:`run:${s}`,kind:"command",label:Yh(s),fullTarget:s,verb:"run",entry:"ran"}];for(const a of Zh(s))o.push(gt(a,"delete","deleted",void 0,tg.test(a)));return o}case"WebFetch":{const s=Oe(n,"url");return s?[{key:`url:${Kh(s)}`,kind:"url",label:Qh(s),fullTarget:s,verb:"fetch",entry:"fetched"}]:[]}case"WebSearch":{const s=Oe(n,"query");return s?[{key:`websearch:${s}`,kind:"command",label:s,fullTarget:s,verb:"search",entry:"searched the web"}]:[]}default:return[]}}function sg(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)&&Vh(n.fullTarget,t.fullTarget))return n.key;return t.key}function rg(e,t,n,s,o){const a=sg(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=ja(t.fullTarget)),i.verb==="read"&&t.verb==="edit"&&(i.upgraded=!0),hr[t.verb]>hr[i.verb]&&(i.verb=t.verb)}const gr=new WeakMap;function og(e){const t=gr.get(e);if(t&&t.input===e.input&&t.result===e.result&&t.status===e.status)return t.touches;const n=ng(e);return gr.set(e,{input:e.input,result:e.result,status:e.status,touches:n}),n}function ag(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 og(n))rg(t,i,s,o,a)}),[...t.values()]}const wa={expanded:!1,verbFilter:null,order:"grouped"},Dn=ss(e=>({views:{},update:(t,n)=>e(s=>({views:{...s.views,[t]:{...s.views[t]??wa,...n}}}))}));function ig(e,t){const n=t.find(s=>s.type==="tool_call");return`${e}:${(n==null?void 0:n.toolCallId)??""}`}function lg(e){const t=Dn(l=>l.views[e]),n=Dn(l=>l.update),s=t??wa,o=c.useCallback(()=>{var l;return n(e,{expanded:!((l=Dn.getState().views[e])!=null&&l.expanded)})},[e,n]),a=c.useCallback(l=>n(e,{verbFilter:l}),[e,n]),i=c.useCallback(l=>n(e,{order:l}),[e,n]);return c.useMemo(()=>({...s,toggleExpanded:o,setVerbFilter:a,setOrder:i}),[s,o,a,i])}const xr=4,dt=[.4,0,.2,1],cg={type:"spring",stiffness:320,damping:28},ug={duration:.25,ease:dt},dg={x:-16,scale:.45,opacity:0},Yt={duration:.15,ease:dt},br={duration:.3,ease:dt},yr={duration:.15,ease:dt},fg={duration:.3,ease:dt},mg={stiffness:220,damping:30},pg={rotate:[0,-4,3,0],scale:[1,1.08,1,1]},hg={duration:.3,ease:dt};function gg(e,t){return e?t?{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:Yt},transition:Yt}:{initial:{opacity:0,y:7},animate:{opacity:1,y:0},exit:{...dg,transition:ug},transition:cg}:{}}const an={read:"📖",search:"🔍",edit:"✏️",create:"✚",delete:"🗑",fetch:"🌐",run:"▮"},ln={read:"Read",search:"Searched",edit:"Edited",create:"Created",delete:"Deleted",fetch:"Fetched",run:"Ran"},Na=["read","search","edit","create","delete","fetch","run"];function Ea(e){return Na.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 xg=["z-30","-ml-2 z-20 opacity-70","-ml-2 z-10 opacity-45"];function bg({chips:e,expanded:t,controls:n,onExpand:s}){const o=Me()??!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(W.span,{animate:o?{rotate:0,scale:1}:pg,transition:hg,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",xg[l]),children:an[i.verb]},i.key))},e.length),r.jsx("span",{"data-testid":"chip-pile-count",className:"bg-primary text-primary-foreground text-3xs rounded-full px-1.5 tabular-nums",children:e.length})]})}function vr({value:e,live:t}){const n=Me()??!1,s=cd(e,mg),o=Io(s,a=>Math.round(a));return c.useEffect(()=>{s.set(e)},[s,e]),!t||n?r.jsx(r.Fragment,{children:e}):r.jsx(W.span,{children:o})}function yg(e){return e.kind!=="command"&&e.pattern!==!0}function vg(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 kg(e){const t=e.pattern===!0&&e.verb==="read"?"Globbed":ln[e.verb],n=e.verb==="run"?e.label:e.fullTarget,s=[`${t} ${n}`];return e.touches>1&&s.push(`${e.touches} times`),e.hits!==void 0&&s.push(xs(e.hits)),e.additions!==void 0&&s.push(`${e.additions} added`),e.deletions!==void 0&&s.push(`${e.deletions} removed`),e.error&&s.push("didn’t work"),s.join(", ")}const kr="bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-3xs leading-[1.4] tabular-nums";function Da({chip:e,onOpen:t,animated:n=!1,pulseUpgrade:s=!1,onUpgradeSeen:o}){const a=Me()??!1,i=s&&!a,l=yg(e),u=e.verb==="delete",d=e.additions!==void 0||e.deletions!==void 0,f=n&&(e.verb==="create"||e.verb==="delete");return r.jsxs(W.button,{...gg(n,a),type:"button","data-testid":"touch-chip","data-verb":e.verb,"data-live":e.live,"data-arriving":f?"true":void 0,title:vg(e),"aria-label":kg(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(ce,{initial:!1,mode:"wait",children:r.jsx(W.span,{"aria-hidden":"true",initial:a?{opacity:0}:{opacity:0,rotateX:-90},animate:a?{opacity:1}:{opacity:1,rotateX:0},exit:a?{opacity:0}:{opacity:0,rotateX:90},transition:yr,children:an[e.verb]},e.verb)})}),i&&r.jsx(W.span,{"aria-hidden":"true","data-testid":"chip-upgrade-pulse",className:"border-primary pointer-events-none absolute -inset-1 rounded-full border",initial:{scale:.6,opacity:.8},animate:{scale:1.8,opacity:0},transition:fg,onAnimationComplete:()=>o==null?void 0:o(e.key)})]}),r.jsx("span",{className:"chip-label truncate",children:e.label}),e.verb==="edit"&&e.live&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-caret",className:"chip-caret"}),e.verb==="run"&&e.live&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-cursor",className:"chip-cursor"}),e.verb==="fetch"&&e.live&&r.jsxs("span",{"aria-hidden":"true","data-testid":"chip-dots",className:"chip-dots",children:[r.jsx("span",{}),r.jsx("span",{}),r.jsx("span",{})]}),e.verb==="create"&&f&&r.jsxs(r.Fragment,{children:[r.jsx("svg",{"aria-hidden":"true","data-testid":"chip-pen",className:"chip-pen",children:r.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",rx:"11",ry:"11",pathLength:"100"})}),r.jsx("span",{"aria-hidden":"true",className:"chip-spark"})]}),e.verb==="delete"&&f&&r.jsx("span",{"aria-hidden":"true","data-testid":"chip-puff",className:"chip-puff"}),e.touches>1&&r.jsxs("span",{className:kr,children:["×",e.touches]}),e.hits!==void 0&&r.jsx("span",{className:kr,children:xs(e.hits)}),d&&r.jsxs(W.span,{className:"shrink-0 tabular-nums",initial:i?{opacity:0,x:-4}:!1,animate:{opacity:1,x:0},transition:yr,children:[e.additions!==void 0&&r.jsxs("span",{className:"text-status-success-fg",children:["+",r.jsx(vr,{value:e.additions,live:e.live})]}),e.additions!==void 0&&e.deletions!==void 0&&" ",e.deletions!==void 0&&r.jsxs("span",{className:"text-destructive",children:["−",r.jsx(vr,{value:e.deletions,live:e.live})]})]})]})}const Cr=new Map(Na.map((e,t)=>[e,t]));function Cg(e,t){const n=[...e];return t==="chronological"?n.sort((s,o)=>s.lastSeq-o.lastSeq):n.sort((s,o)=>(Cr.get(s.verb)??0)-(Cr.get(o.verb)??0)||s.firstSeq-o.firstSeq)}function Sg({id:e,chips:t,onOpen:n,verbFilter:s,onVerbFilterChange:o,order:a,onOrderChange:i}){const l=c.useMemo(()=>Ea(t),[t]),u=c.useMemo(()=>{const d=s?t.filter(f=>f.verb===s):t;return Cg(d,a)},[t,s,a]);return r.jsxs("div",{id:e,role:"region","aria-label":"Touched files and links","data-testid":"chip-tray",className:"border-border bg-card/50 flex flex-col gap-2 rounded-md border p-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsx("div",{role:"group","aria-label":"Filter by what happened",className:"flex flex-wrap gap-1",children:l.map(d=>{const f=s===d.verb;return r.jsxs(le,{variant:"outline",size:"xs","aria-pressed":f,"data-testid":`chip-filter-${d.verb}`,onClick:()=>o(f?null:d.verb),className:U("rounded-full",f?"border-primary dark:border-primary text-foreground":"text-muted-foreground"),children:[r.jsx("span",{"aria-hidden":"true",children:an[d.verb]}),r.jsx("span",{className:"sr-only",children:ln[d.verb]}),r.jsx("span",{className:"tabular-nums",children:d.chips.length})]},d.verb)})}),r.jsxs(Sl,{value:a,onValueChange:d=>i(d),"aria-label":"Order the roster",className:"w-auto",children:[r.jsx(Os,{value:"grouped",children:"Grouped"}),r.jsx(Os,{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(Da,{chip:d,onOpen:n},d.key))})]})}const _g=new Set;function jg(){const[e,t]=c.useState(_g),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 wg(e){const t=[...e].sort((n,s)=>n.lastSeq-s.lastSeq);return{visible:t.slice(-xr),absorbed:t.slice(0,Math.max(0,t.length-xr))}}function Ng(e){return e.map(t=>{const n=[`${t.chips.length} ${ln[t.verb].toLowerCase()}`];return t.additions!==void 0&&n.push(`${t.additions} added`),t.deletions!==void 0&&n.push(`${t.deletions} removed`),n.join(", ")}).join("; ")}function Eg({verb:e,count:t,additions:n,deletions:s}){return r.jsxs("span",{"data-testid":`chip-summary-${e}`,className:"inline-flex items-center gap-1",children:[r.jsx("span",{"aria-hidden":"true",children:an[e]}),r.jsx("span",{className:"sr-only",children:ln[e]}),r.jsx("span",{className:"tabular-nums",children:t}),(n!==void 0||s!==void 0)&&r.jsxs("span",{className:"tabular-nums",children:[n!==void 0&&r.jsxs("span",{className:"text-status-success-fg",children:["+",n]}),n!==void 0&&s!==void 0&&" ",s!==void 0&&r.jsxs("span",{className:"text-destructive",children:["−",s]})]})]})}function Dg({parts:e,sessionId:t,turnActive:n=!1}){const s=Me()??!1,o=c.useMemo(()=>ag(e),[e]),a=jg(),i=c.useId(),l=lg(c.useMemo(()=>ig(t,e),[t,e])),u=c.useCallback(x=>{if(x.pattern===!0)return;const g=ae.getState();if(x.kind==="url"){const C={type:"url",url:x.fullTarget};g.openCanvasDocument(C),$n(g,"user",C);return}if(x.kind==="file"){const C={type:"file",sourcePath:x.fullTarget};g.openCanvasDocument(C),$n(g,"user",C)}},[]),d=c.useMemo(()=>Ea(o),[o]),f=n||o.some(x=>x.live),{visible:h,absorbed:m}=c.useMemo(()=>wg(o),[o]);return o.length===0?null:r.jsxs("div",{"data-testid":"touch-chip-strip",className:"mt-2 flex flex-col gap-2",children:[r.jsx(ce,{initial:!1,mode:"wait",children:f?r.jsxs(W.div,{"data-testid":"chip-live-row",role:"group","aria-label":"Latest activity",exit:s?{opacity:0}:{opacity:0,height:0},transition:s?Yt:br,className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:[m.length>0&&r.jsx(bg,{chips:m,expanded:l.expanded,controls:i,onExpand:l.toggleExpanded}),r.jsx(ce,{initial:!1,children:h.map(x=>r.jsx(Da,{chip:x,onOpen:u,animated:!0,pulseUpgrade:a.shouldPulse(x.key,x.upgraded),onUpgradeSeen:a.acknowledge},x.key))})]},"live"):r.jsxs(W.div,{"data-testid":"chip-summary-line",role:"group","aria-label":Ng(d),initial:{opacity:0},animate:{opacity:1},transition:s?Yt:br,className:"text-muted-foreground flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs",children:[d.map((x,g)=>r.jsxs(c.Fragment,{children:[g>0&&r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx(Eg,{verb:x.verb,count:x.chips.length,additions:x.additions,deletions:x.deletions})]},x.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(Sg,{id:i,chips:o,onOpen:u,verbFilter:l.verbFilter,onVerbFilterChange:l.setVerbFilter,order:l.order,onOrderChange:l.setOrder})]})}function Sr(e){return e.type==="thinking"?!0:e.type==="tool_call"&&!e.interactiveType&&!Vo(e.toolName)&&!Pn(e.toolName)}function Tg({message:e}){const{sessionId:t,isStreaming:n,isLatestWidgetMessage:s,isFinalMessage:o,activeToolCallId:a,onToolRef:i,focusedOptionIndex:l,onToolDecided:u,onRetry:d,onSigninComplete:f,onChooseModel:h,inputZoneToolCallId:m,textEffect:x,runtimeLabel:g,allowsDenyReason:C}=pp(),b=ae(S=>S.expandToolCalls),y=ae(S=>S.autoHideToolCalls),k=e.parts??[],{sent:v}=ma(t),p=c.useCallback(S=>{i==null||i(S)},[i]),_=c.useCallback(S=>{i==null||i(S)},[i]),j=_h(k.map(S=>S.type==="tool_call"&&Pn(S.toolName)?{...S,interactiveType:void 0}:S));let D=-1;for(let S=k.length-1;S>=0;S--)if(k[S].type==="text"){D=S;break}function T(S,E){if(S.type==="text")return r.jsx("div",{className:"msg-prose",children:r.jsx(ps,{content:S.text,isStreaming:n&&E===D,textEffect:x,sessionId:t,isLatestWidgetMessage:s})},`text-${E}`);if(S.type==="background_task")return r.jsx(Dp,{part:S},S.taskId);if(S.type==="error"&&S.code===bo)return r.jsx(Nh,{message:S.message},`unreadable-${E}`);if(S.type==="error")return r.jsx(on,{message:S.message,category:S.category,details:S.details,code:S.code,reason:S.reason,at:e.timestamp,onRetry:o&&S.category!==void 0?d:void 0,onSigninComplete:f,onChooseModel:h,runtimeLabel:g,sessionId:t},`error-${E}`);if(S.type==="thinking")return r.jsx($h,{part:S,autoHide:y,index:E},`thinking-${E}`);if(S.type==="elicitation")return r.jsx($d,{sessionId:t,interactionId:S.interactionId,serverName:S.serverName,message:S.message,mode:S.mode,url:S.url,requestedSchema:S.requestedSchema,status:S.status,action:S.action},`elicitation-${S.interactionId}`);if(S.type==="memory_recall")return r.jsx(bp,{mode:S.mode,memories:S.memories,isStreaming:S.isStreaming??!1},`memory-recall-${E}`);if(S.type==="permission_denied")return r.jsx(vh,{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(Ah,{fromName:S.fromName,toName:S.toName},`model-substituted-${E}`);if(S.type==="compact_boundary")return r.jsx(Sp,{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(Eh,{title:_l(S.approval)},`capability-approval-${S.approval.approvalId}`):r.jsx(jl,{approval:S.approval},`capability-approval-${S.approval.approvalId}`);if(S.type==="mcp_signin")return r.jsx(Th,{part:S},`mcp-signin-${S.agentId}-${S.flowId}`);if(S.type==="image")return r.jsx(_p,{part:S},`image-${S.attachmentId}-${E}`);if(S.type!=="tool_call")return null;const w=S;if(w.interactiveType==="approval"&&w.status==="pending"){if(w.toolCallId===m)return r.jsx(tr,{type:"approval",toolName:w.toolName,toolInput:w.input},w.toolCallId);const M=w.toolCallId===a;return r.jsx(yo,{ref:M?p:void 0,sessionId:t,toolCallId:w.toolCallId,toolName:w.toolName,input:w.input||"",timeoutMs:w.timeoutMs,approvalStartedAt:w.approvalStartedAt,approvalRemainingMs:w.approvalRemainingMs,approvalParked:w.approvalParked,approvalTitle:w.approvalTitle,approvalDisplayName:w.approvalDisplayName,approvalDescription:w.approvalDescription,approvalBlockedPath:w.approvalBlockedPath,approvalDecisionReason:w.approvalDecisionReason,approvalHasSuggestions:w.approvalHasSuggestions,approvalAlwaysAllowScope:w.approvalAlwaysAllowScope,isActive:M,onDecided:u?()=>u(w.toolCallId):void 0,allowsDenyReason:C},w.toolCallId)}const R=j.get(E);if(R){if(R.leadIndex!==E)return null;const M=R.indices.map(F=>k[F]).filter(F=>F.type==="tool_call");return r.jsx(Wd,{outcome:R.outcome,reasonGiven:R.reasonGiven,members:M,lead:w,children:M.map(F=>r.jsx(En,{part:F,sessionId:t,autoHide:y,expandToolCalls:b},F.toolCallId))},`approval-receipt-${w.toolCallId}`)}if(w.interactiveType==="question"){if(w.toolCallId===m)return r.jsx(tr,{type:"question",toolName:w.toolName,toolInput:w.input},w.toolCallId);const M=w.toolCallId===a;return r.jsx(vo,{ref:M?_:void 0,sessionId:t,toolCallId:w.toolCallId,questions:w.questions??[],answers:w.answers??(jh(w)?{}:void 0),outcome:wh(w),result:w.result,isActive:M,focusedOptionIndex:M?l:-1,onDecided:u?F=>u(w.toolCallId,F):void 0},w.toolCallId)}return Pn(w.toolName)?r.jsx(rp,{part:w,sent:v,...e.timestamp?{at:e.timestamp}:{},...t?{sessionId:t}:{}},w.toolCallId):Vo(w.toolName)?r.jsx(Kd,{sessionId:t,input:w.input,result:w.result,fallback:r.jsx(En,{part:w,sessionId:t,autoHide:y,expandToolCalls:b})},w.toolCallId):r.jsx(En,{part:w,sessionId:t,autoHide:y,expandToolCalls:b},w.toolCallId)}const N=[];let A=[];for(let S=0;S<k.length;S++){const E=k[S];Sr(E)?A.push(S):(A.length>0&&(N.push(A.length===1?{type:"single",index:A[0]}:{type:"run",indices:[...A]}),A=[]),N.push({type:"single",index:S}))}return A.length>0&&N.push(A.length===1?{type:"single",index:A[0]}:{type:"run",indices:[...A]}),r.jsxs(r.Fragment,{children:[N.map(S=>{if(S.type==="single"){const w=k[S.index];return Sr(w)?r.jsx("div",{className:"my-3",children:T(w,S.index)},`spacer-${S.index}`):T(w,S.index)}const E=S.indices.map(w=>T(k[w],w));return r.jsx("div",{className:"my-3",children:r.jsx(Lh,{children:E})},`run-${S.indices[0]}`)}),r.jsx(Dg,{parts:k,sessionId:t,turnActive:e._streaming===!0})]})}const Ag=/^Please read the following uploaded file\(s\):\n((?:- .+\n)+)\n?/,Fg=/^[a-f0-9]{8}-/,Rg=new Set(["png","jpg","jpeg","gif","webp","svg"]);function Mg(e){const t=e.match(Ag);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(Fg,""),d=((f=u.split(".").pop())==null?void 0:f.toLowerCase())??"";return{path:i,displayName:u,isImage:Rg.has(d)}}),o=e.slice(t[0].length).trim();return{files:s,textContent:o}}function Ig(e){var n;switch(((n=e.split(".").pop())==null?void 0:n.toLowerCase())??""){case"txt":case"md":case"log":return ad;case"ts":case"tsx":case"js":case"jsx":case"json":case"py":case"rs":case"go":return rd;case"csv":case"xls":case"xlsx":return gd;case"png":case"jpg":case"jpeg":case"gif":case"webp":case"svg":return hd;default:return Oo}}function Og({files:e}){const t=ae(n=>n.selectedCwd);return e.length===0?null:r.jsx("div",{className:"flex flex-wrap gap-1.5 pb-1.5",children:e.map(n=>{const s=n.path.split("/").pop()??n.path;if(n.isImage){const a=`/api/uploads/${encodeURIComponent(s)}?cwd=${encodeURIComponent(t??"")}`;return r.jsx(W.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},children:r.jsx(lo,{image:{src:a,alt:n.displayName,downloadName:n.displayName},className:"block rounded-lg",children:r.jsx("img",{src:a,alt:n.displayName,loading:"lazy",className:"border-border/50 max-h-[120px] max-w-[200px] rounded-lg border object-contain"})})},n.path)}const o=Ig(n.displayName);return r.jsxs(W.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},className:"bg-muted flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[r.jsx(o,{className:"text-muted-foreground size-3 shrink-0"}),r.jsx("span",{className:"max-w-40 truncate",children:n.displayName})]},n.path)})})}function $g({message:e}){var i;const t=(i=hp())==null?void 0:i.sessionId,[n,s]=c.useState(!1),o=c.useMemo(()=>Mg(e.content),[e.content]),a=c.useMemo(()=>lf(e.content),[e.content]);if(a)return r.jsx(of,{action:a});if(e.chatMessages&&e.chatMessages.length>0)return r.jsx(Jm,{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(va,{content:e.content,toolName:""});if(e.messageType==="compaction"){const l=kp(e.compactMetadata),u=e.content.trim(),d=r.jsx("div",{className:"bg-border/40 h-px flex-1"});return u.length===0?r.jsxs("div",{"data-testid":"compaction-row",className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[d,r.jsx("span",{children:l}),d]}):r.jsxs("div",{className:"w-full","data-testid":"compaction-row",children:[r.jsxs("button",{onClick:()=>s(!n),className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[d,r.jsx(ls,{className: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(Og,{files:o.files}),o.textContent&&r.jsx("div",{className:"break-words whitespace-pre-wrap",children:o.textContent})]})}function Pg({tasks:e,isCollapsed:t,onToggleCollapse:n}){const s=e.length,o=e.filter(l=>l.status==="completed").length,a=o===s&&s>0,i=s>0?o/s*100:0;return r.jsxs("button",{onClick:n,className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-2 text-xs",children:[t?r.jsx(ls,{className:"size-(--size-icon-xs) shrink-0"}):r.jsx(Dt,{className:"size-(--size-icon-xs) shrink-0"}),r.jsx("div",{className:"bg-muted h-0.5 flex-1 overflow-hidden rounded-full",children:r.jsx("div",{"data-slot":"progress-fill",className:`h-full rounded-full transition-[width,background-color] duration-300 ease-out ${a?"bg-green-500":"bg-blue-500"}`,style:{width:`${i}%`}})}),r.jsxs("span",{className:"shrink-0 tabular-nums",children:[o,"/",s," ",s===1?"task":"tasks"]})]})}function Lg({activeForm:e,isCollapsed:t}){return r.jsx(ce,{children:e&&!t&&r.jsxs(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"mb-1 flex items-center gap-2 text-xs text-blue-400",children:[r.jsx(Le,{size:"xs",className:"shrink-0"}),r.jsx("span",{className:"truncate",children:e})]})})}const Bg={in_progress:"",pending:"waiting ",completed:"done "};function _r({tasks:e,onScrollToTask:t}){return r.jsx(r.Fragment,{children:e.map((n,s)=>r.jsxs("span",{children:[r.jsx("button",{onClick:o=>{o.stopPropagation(),t(n.id)},className:"hover:text-foreground underline decoration-dotted",children:n.subject}),s<e.length-1&&", "]},n.id))})}function zg({task:e,taskMap:t,statusSince:n,onScrollToTask:s}){var d,f;const o=$o(n),a=Bg[e.status]??"",i=((d=e.blockedBy)==null?void 0:d.map(h=>t.get(h)).filter(h=>h!=null))??[],l=((f=e.blocks)==null?void 0:f.map(h=>t.get(h)).filter(h=>h!=null))??[],u=[];return n!==null&&u.push(r.jsxs("span",{children:[a,o.formatted]},"time")),e.owner&&u.push(r.jsx("span",{children:e.owner},"owner")),i.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["← ",r.jsx(_r,{tasks:i,onScrollToTask:s})]},"blocked-by")),l.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["→ ",r.jsx(_r,{tasks:l,onScrollToTask:s})]},"blocks")),r.jsxs(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"mt-0.5 ml-6 space-y-1",children:[e.description&&r.jsx("p",{className:"text-muted-foreground text-xs whitespace-pre-wrap",children:e.description}),u.length>0&&r.jsx("div",{className:"text-muted-foreground text-2xs flex flex-wrap items-center gap-1",children:u.map((h,m)=>r.jsxs("span",{className:"flex items-center gap-1",children:[m>0&&r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h]},m))})]})}const jr={in_progress:r.jsx(Le,{size:"xs",className:"text-status-info shrink-0"}),pending:r.jsx(wl,{className:"text-muted-foreground size-(--size-icon-xs) shrink-0"}),completed:r.jsx(xo,{className:"text-status-success size-(--size-icon-xs) shrink-0"})};function qg({task:e,isBlocked:t,isExpanded:n,onToggleExpand:s,onHover:o,isHighlightedAsDep:a,isHighlightedAsDependent:i,taskMap:l,statusSince:u,isCelebrating:d,onCelebrationComplete:f,onScrollToTask:h}){const m=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),s())};return r.jsxs(W.li,{"data-task-id":e.id,children:[r.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,"data-task-id":e.id,onClick:s,onKeyDown:m,onMouseEnter:()=>o(e.id),onMouseLeave:()=>o(null),className: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(W.div,{"aria-hidden":"true",className:"absolute inset-0 rounded",initial:{backgroundPosition:"-200% 0"},animate:{backgroundPosition:"200% 0"},transition:{duration:.4,ease:"easeOut"},style:{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,215,0,0.2) 50%, transparent 100%)",backgroundSize:"200% 100%"}}),d?r.jsx(W.span,{initial:{scale:1},animate:{scale:[1,1.4,1]},transition:{type:"spring",stiffness:400,damping:10},onAnimationComplete:()=>f==null?void 0:f(),children:jr[e.status]}):jr[e.status],r.jsx("span",{className:"truncate",children:e.subject})]}),r.jsx(ce,{children:n&&r.jsx(zg,{task:e,taskMap:l,statusSince:u,onScrollToTask:h})})]})}function Ug(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 Hg=10,Wg="max-h-[30svh] sm:max-h-[40svh]";function Gg({tasks:e,taskMap:t,activeForm:n,isCollapsed:s,onToggleCollapse:o,celebratingTaskId:a,onCelebrationComplete:i,statusTimestamps:l}){const[u,d]=c.useState(null),[f,h]=c.useState(null),m=c.useCallback(b=>{d(y=>y===b?null:b)},[]),x=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 g=e.slice(0,Hg),C=f?t.get(f):null;return r.jsxs("div",{className:"border-t px-4 py-2",children:[r.jsx(Lg,{activeForm:n,isCollapsed:s}),r.jsx(Pg,{tasks:e,isCollapsed:s,onToggleCollapse:o}),r.jsx(ce,{children:!s&&r.jsx(W.ul,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:U("mt-1 space-y-0.5 overflow-y-auto",Wg),children:g.map(b=>{var j,D;const y=b.id===a&&b.status==="completed",k=Ug(b,t),v=l.get(b.id),p=((j=C==null?void 0:C.blockedBy)==null?void 0:j.includes(b.id))??!1,_=((D=C==null?void 0:C.blocks)==null?void 0:D.includes(b.id))??!1;return r.jsx(qg,{task:b,isBlocked:k,isExpanded:u===b.id,onToggleExpand:()=>m(b.id),onHover:h,isHighlightedAsDep:p,isHighlightedAsDependent:_,taskMap:t,statusSince:(v==null?void 0:v.since)??null,isCelebrating:y,onCelebrationComplete:i,onScrollToTask:x},b.id)})})})]})}function Vg({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 Kg=350;function Qg({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 Xg({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"),Kg);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(Qg,{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(Vg,{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 Yg({bashTasks:e}){const t=Me(),n=e.filter(o=>o.taskType==="bash"),s=n.length;return s===0?null:r.jsxs("div",{role:"status","aria-live":"polite","aria-label":`${s} bash task${s!==1?"s":""} running`,className:"flex items-center gap-1.5",children:[r.jsx(ce,{mode:"popLayout",children:n.map(o=>r.jsxs(W.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.25},className:"relative flex size-3 items-center justify-center",children:[o.status==="running"&&!t&&r.jsx("span",{className:"task-dot-tasks absolute inset-0 rounded-full opacity-40",style:{backgroundColor:o.color,animation:"task-dot-tasks 2s ease-in-out infinite"}}),r.jsx("span",{className:"relative size-1.5 rounded-full",style:{backgroundColor:o.color}})]},o.taskId))}),r.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[s," task",s!==1?"s":""]})]})}const Jg=3e3;function Zg({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)},Jg),()=>{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(it,{className:"size-3"})})}function wr({task:e,onStop:t}){const n=e.taskType==="agent"?e.description??"Background agent":e.command??"Background task",s=e.durationMs?Math.round(e.durationMs/1e3):0,o=e.status==="running";return r.jsxs("div",{className: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(Zg,{taskType:e.taskType,onConfirm:t})]})}function ex({tasks:e,ambientTasks:t=[],onStopTask:n}){return r.jsx(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"border-border overflow-hidden border-t px-2 py-1.5",children:r.jsxs("div",{className:"flex flex-col gap-1",children:[e.map(s=>r.jsx(wr,{task:s,onStop:()=>n(s.taskId)},s.taskId)),t.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-muted-foreground/60 text-3xs mt-1 px-2",children:[t.length," housekeeping task",t.length!==1?"s":""," the agent runs for itself"]}),t.map(s=>r.jsx(wr,{task:s,onStop:()=>n(s.taskId)},s.taskId))]})]})})}const Vn=4;function tx(e){return e==="stopped"?"complete":e}const nx="relative after:absolute after:-inset-x-1 after:-inset-y-2.5 md:after:hidden",Ta=[.16,1,.3,1],sx={width:{duration:.4,ease:Ta},opacity:{duration:.25}};function rx({tasks:e,onStopTask:t}){const[n,s]=c.useState(!1),o=Me(),{shown:a,ambient:i}=Lc(e),l=a.filter(b=>b.taskType==="agent"),u=a.filter(b=>b.taskType==="bash"),d=a.length,f=l.slice(0,Vn),h=l.length-Vn,m=l.reduce((b,y)=>b+(y.toolUses??0),0),x=Math.max(0,...a.map(b=>Math.round((b.durationMs??0)/1e3))),g=o?{duration:0}:{duration:.35,ease:Ta},C=d>0;return r.jsx(ce,{children:(d>0||i.length>0)&&r.jsxs(W.div,{...C?{role:"status","aria-live":"polite","aria-label":`${d} background task${d!==1?"s":""} running`}:{role:"group","aria-label":"Background tasks"},initial:{opacity:0,y:6,maxHeight:0},animate:{opacity:1,y:0,maxHeight:n?400:44},exit:{opacity:0,maxHeight:0},transition:g,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(ox,{visibleAgents:f,overflowAgentCount:h,allAgentTasks:l}),l.length>0&&u.length>0&&r.jsx("div",{className:"bg-border h-4 w-px shrink-0"}),u.length>0&&r.jsx(Yg,{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 · "]}),x,"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",nx),"aria-label":n?"Collapse task details":"Expand task details","aria-expanded":n,children:[d>0&&r.jsx("span",{className:"text-3xs tabular-nums",children:d}),r.jsx(Dt,{className:U("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),r.jsx(ce,{children:n&&r.jsx(ex,{tasks:a,ambientTasks:i,onStopTask:t})})]},"background-task-bar")})}function ox({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return r.jsxs("div",{className:"flex items-center gap-0",children:[r.jsx(ce,{mode:"popLayout",children:e.map((s,o)=>r.jsx(W.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:sx,className:"shrink-0",children:r.jsx(Xg,{agent:{taskId:s.taskId,description:s.description??"",status:tx(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(ax,{count:t,overflowTasks:n.slice(Vn)})]})}function ax({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 Tn="after:absolute after:-inset-1 md:after:hidden";function ix({queue:e,editingId:t,onEdit:n,onRemove:s,onSend:o,onMoveUp:a,statusNote:i,onSwitchNow:l}){return e.length===0?null:r.jsxs(W.div,{variants:He,initial:"initial",animate:"animate",exit:"exit",transition:Ue,className:"mb-1.5 overflow-hidden",children:[r.jsxs("div",{className:"text-muted-foreground mb-1 flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:"font-medium",children:["Queued (",e.length,")"]}),r.jsxs("span",{className:"truncate",children:["· ",i]})]}),r.jsx("div",{className:"space-y-0.5",children:r.jsx(ce,{mode:"popLayout",children:e.map((u,d)=>r.jsx(W.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,scale:.95,transition:{duration:.15}},layout:!0,children:r.jsxs("div",{className: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(Bn,{className:"size-3","aria-hidden":"true"}),r.jsx("span",{className:"sr-only",children:"Queued from another window"})]})]}),u.waiting!==void 0&&l!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:l,title:u.waiting.switchHint,"aria-describedby":`switch-now-${u.id}`,className:"focus-ring text-muted-foreground hover:text-foreground shrink-0 rounded-sm px-1.5 py-1 text-xs font-medium transition-colors",children:"Switch now"}),r.jsx("span",{id:`switch-now-${u.id}`,className:"sr-only",children:u.waiting.switchHint})]}),d>0&&r.jsx("button",{type:"button",onClick:()=>a(u.id),className: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",Tn),"aria-label":`Move queued message ${d+1} earlier`,children:r.jsx(Nl,{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",Tn),children:r.jsx(Lu,{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",Tn),"aria-label":`Remove queued message ${d+1}`,children:r.jsx(it,{className:"size-3"})})]})},u.id))})})]})}function lx({open:e,onOpenChange:t,queuedCount:n,onConfirm:s}){const o=n===1?"message":"messages";return r.jsx(El,{open:e,onOpenChange:t,children:r.jsxs(Dl,{children:[r.jsxs(Tl,{children:[r.jsxs(Al,{children:["Stop, and put ",n," queued ",o," back?"]}),r.jsxs(Fl,{children:["The agent stops. Your ",o," ",n===1?"goes":"go"," back to the composer."]})]}),r.jsxs(Rl,{children:[r.jsx(Ml,{children:"Keep going"}),r.jsx(Il,{onClick:s,children:"Stop"})]})]})})}const cx={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},ux={duration:.3,ease:"easeInOut"};function dx({text:e,animationKey:t}){return r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-start overflow-hidden py-0.5",children:r.jsx(ce,{mode:"wait",children:r.jsx(W.span,{variants:cx,initial:"initial",animate:"animate",exit:"exit",transition:ux,className:"text-muted-foreground truncate text-sm",children:e},t)})})}function fx(e){const t=ke();return Xe({queryKey:["workspace-for-session",e??null],queryFn:()=>t.resolveWorkspace(e),enabled:!!e}).data??null}async function Aa(e,t,n){try{return await e.runCommandIntent(t,"compact",n),!0}catch(s){const o=s.code==="SESSION_LOCKED";return De.error(o?"Your agent is busy. Try again in a moment.":"Couldn’t compact the chat."),!1}}const Kn=ss(e=>({open:!1,setOpen:t=>e({open:t}),reveal:()=>e({open:!0})})),mx=200,Qn=[{name:"rename",description:"Rename the current chat",argHint:"<new title>",run:(e,t)=>{const n=e.replace(/\s+/g," ").trim().slice(0,mx).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)}],px=/^\/(\S+)(?:\s+([\s\S]*))?$/;function Fa(e){const t=px.exec(e);if(!t)return null;const n=t[1],s=(t[2]??"").trim(),o=us(n);if(o&&o.fulfillment==="client-native"){const i=Qn.find(l=>l.name===o.id);if(i)return{command:i,args:s}}const a=Qn.find(i=>i.name===n.toLowerCase());return a?{command:a,args:s}:null}const Nr=Qn.map(e=>({command:e.name,fullCommand:`/${e.name}`,description:e.description,argumentHint:e.argHint}));function Ra(e){const t=/^\/(\S+)([\s\S]*)$/.exec(e.trim());return t?{token:t[1],rest:t[2].trim()}:null}function hx(e){const t=Ra(e);return t?us(t.token)?!0:Fa(e.trim())!==null:!1}function gx(e,t,n={}){const{mutateAsync:s}=Ol(e),o=ke(),{startFreshSession:a,compact:i}=n,[l,u]=c.useState(0),d=c.useCallback(h=>{u(x=>x+1);const m=()=>u(x=>Math.max(0,x-1));h.then(m,m)},[]);return{tryRun:c.useCallback(h=>{const m=Ra(h),x=m?us(m.token):null;if(m&&(x==null?void 0:x.fulfillment)==="runtime"&&i){if(!i.supported)return De.error(`Compact isn’t available on ${i.runtimeLabel||"this agent"}`),{handled:!0,ran:!1};if(!t)return De.error("No open chat to compact"),{handled:!0,ran:!1};const y=Aa(o,t,m.rest||void 0);return d(y),{handled:!0,ran:!0,confirmed:y}}const g=Fa(h);if(!g)return{handled:!1};let C;return{handled:!0,ran:g.command.run(g.args,{sessionId:t,renameSession:y=>{t&&(C=s({sessionId:t,title:y}).then(()=>(De.success(`Renamed chat to “${y}”`),!0),()=>!1),d(C))},notify:(y,k)=>k==="error"?De.error(y):De.success(y),startFreshSession:y=>a==null?void 0:a(y),focusUsageSurface:()=>Kn.getState().reveal()}),...C?{confirmed:C}:{}}},[s,o,t,a,i,d]),commandPending:l>0}}function Ma(e,t){return{supported:(e==null?void 0:e.compact.supported)!==!1,runtimeLabel:t}}function Er(e){const t=e.trim().toLowerCase();return t.startsWith("/")?t:`/${t}`}function xx(e){return Pl.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 bx(e,t){const n=$l(),s=xx(t),o=Nr.filter(l=>!(l.command!==void 0&&n.has(`/${l.command}`))),a=new Set(Nr.map(l=>l.command)),i=e.filter(l=>{if(l.command!==void 0&&a.has(l.command))return!1;const u=[l.fullCommand,...l.aliases??[]].map(Er);return l.command!==void 0&&u.push(Er(l.command)),!u.some(d=>n.has(d))});return[...s,...o,...i]}const yx=3e4;function vx({percent:e,compactSupported:t,isStreaming:n}){return!(e===null||e<Bc||!t||n)}function kx({sessionId:e,percent:t,compactSupported:n,isStreaming:s}){const o=ke(),[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)},yx),Aa(o,e).then(h=>{h||d()}))},[e,o,d]);return{visible:vx({percent:t,compactSupported:n,isStreaming:s}),percent:t??0,pending:a,onCompact:f}}function Cx({children:e,onSwitchAgent:t,onViewProfile:n,onNewSession:s}){return r.jsxs(Ll,{children:[r.jsx(Bl,{className:"min-w-0",children:e}),r.jsxs(zl,{className:"w-48",children:[r.jsxs(mn,{onClick:t,children:[r.jsx(ql,{className:"mr-2 size-4"}),"Switch agent"]}),r.jsx($s,{}),r.jsxs(mn,{onClick:n,children:[r.jsx(Ul,{className:"mr-2 size-4"}),"View profile"]}),r.jsx($s,{}),r.jsxs(mn,{onClick:s,children:[r.jsx(co,{className:"mr-2 size-4"}),"New chat"]})]})]})}function Sx({agentName:e,agentColor:t,agentEmoji:n,agentPath:s,nameHidden:o}){const a=Hl(s),{open:i}=Wl(),l=c.useCallback(()=>{s&&Gl.getState().openProfileDocked(s)},[s]),u=c.useCallback(()=>{if(a===void 0)return l();i(a)},[a,i,l]),d=c.useCallback(()=>{ae.getState().openGlobalPaletteWithSearch("@")},[]),f=po(),h=c.useCallback(()=>{f(s??void 0)},[f,s]);return!e||!t||!n?null:r.jsx("span",{className:"inline-flex min-w-0 items-center",children:s?r.jsx(Cx,{onSwitchAgent:d,onViewProfile:u,onNewSession:h,children:r.jsx(Ps,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,onClick:u,className:"max-w-full"})}):r.jsx(Ps,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,className:"max-w-full"})})}function _x({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(Vl,{sessionId:e,account:t,open:n,onOpenChange:s,onContinue:()=>{s(!1),a(!0)}})}),r.jsx(Zo,{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 jx({ctx:e,items:t}){return r.jsx("span",{className:"inline-flex min-w-0 items-center gap-2",children:t.map((n,s)=>{const o=n.component;return r.jsxs(c.Fragment,{children:[s>0&&r.jsx("span",{className:"text-muted-foreground/30 shrink-0","aria-hidden":"true",children:"·"}),r.jsx("span",{role:"group","aria-label":n.label,"data-testid":`extension-status-item-${n.id}`,className:"inline-flex min-w-0 items-center",children:r.jsx(ko,{fallback:null,onError:a=>Ia(n,a),children:r.jsx(o,{...e})})})]},n.id)})})}function Ia(e,t){console.warn(`[extensions] ${e.extensionId}'s status-bar item "${e.id}" failed to draw and is hidden.`,t)}function wx({ctx:e,items:t}){return r.jsx(r.Fragment,{children:t.map(n=>{const s=n.component;return r.jsxs("div",{role:"group","aria-label":n.label,"data-testid":`session-row-extension-${n.id}`,className:"flex items-center gap-2 px-1 py-1 text-sm",children:[r.jsx("span",{className:"shrink-0",children:n.label}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("span",{className:"text-muted-foreground inline-flex min-w-0 items-center text-xs",children:r.jsx(ko,{fallback:null,onError:o=>Ia(n,o),children:r.jsx(s,{...e})})})]},n.id)})})}function Nx(e){const{costUsd:t,costBasis:n,...s}=e;return s}function Ex(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(Sx,{agentName:n.name,agentColor:n.color,agentEmoji:n.emoji,agentPath:n.path,nameHidden:e.density==="avatar"})),s.cwd&&(i.cwd=r.jsx(zc,{cwd:s.cwd})),e.gitStatus&&(i.git=r.jsx(Xc,{data:e.gitStatus,workspace:e.workspace,compact:l})),o.runtime!==null&&(i.runtime=r.jsx(qc,{runtime:o.runtime,model:o.model,onChangeRuntime:o.onChangeRuntime,canSelect:o.canSelect,account:o.account,compact:!0}));const u=Co(e.account);u!==null&&(i.account=r.jsx(_x,{sessionId:t,account:e.account})),e.extensions.items.length>0&&(i.extensions=r.jsx(jx,{ctx:e.extensions.ctx,items:e.extensions.items})),i.model=r.jsx(Uc,{model:s.model,onChangeModel:h=>a({model:h}),effort:s.effort,onChangeEffort:h=>a({effort:h??void 0}),fastMode:s.fastMode,onChangeFastMode:h=>a({fastMode:h}),disabled:!t,sessionId:t||void 0,runtime:o.runtime,onCredits:e.account.onCredits,compact:l}),(f=e.plan)!=null&&f.active||(i.permission=r.jsx(Hc,{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(Wc,{descriptor:e.plan.descriptor,active:e.plan.active,onToggle:e.plan.onToggle,disabled:!t})),e.contextPercent!==null&&(i.context=r.jsx(Gc,{percent:e.contextPercent,contextUsage:e.contextUsage,compact:e.compact,reading:e.contextReading}));const d=e.usage&&e.usageSource==="account"&&!e.supportsCostTracking?Nx(e.usage):e.usage;return d&&Kl(d)&&(e.supportsCostTracking||e.usageSource==="account")&&!Vc({account:u})&&(i.usage=r.jsx(Ql,{usage:d,observedAt:e.usageObservedAt,now:e.now})),e.liveSubagentCount>0&&(i.subagents=r.jsx(Kc,{count:e.liveSubagentCount,running:e.runningSubagents,waiting:e.waitingOnSubagents})),i.connection=r.jsx(Qc,{connectionState:e.connectionState,compact:l}),i}const Dx=[],Tx="(max-width: 639px)";function Ax({sessionId:e,sessionStatus:t,isStreaming:n,syncConnectionState:s,agentName:o,agentColor:a,agentEmoji:i,agentPath:l}){var Ae,Be;const{ref:u,budget:d}=Yc(),f=So(e),h=Fo(e,t,n,f.runtime),m=Nt(e||null),{pins:x}=Jc(),g=Zc(e),C=eu(e,m,g.usage),b=C.usage,y=jt(),k=new Date(y),v=Xl(b,C.observedAt,k),p=g.contextUsage,_=((Ae=ds(e))==null?void 0:Ae.contextUsage)??null,j=Kn(ne=>ne.open),D=Kn(ne=>ne.setOpen),{data:T}=tu(h.cwd),N=fx(h.cwd),{project:A}=Yl(h.cwd),S=Jl(Tx),E=c.useMemo(()=>({sessionId:e,cwd:h.cwd,project:A,trackerItems:m.trackerItems,compact:S}),[e,h.cwd,A,m.trackerItems,S]),w=nu(E),{data:R}=as(),M=su(g.activeSubagents).running,F=g.runningSubagentCount??M.length,{data:O}=os({sessionId:e||void 0,runtime:f.runtime??void 0}),L=((Be=O==null?void 0:O.find(ne=>ne.value===h.model))==null?void 0:Be.supportsAutoMode)??!1,B=tn(f.runtime),ee=(B==null?void 0:B.permissionModes.values)??Dx,Q=B==null?void 0:B.permissionModes.default,H=Zl(e),$=se(ne=>ne.recordAutoConfirmed),[P,I]=c.useState(!1),V=ru({sessionId:e,runtime:f.runtime,declaredModes:ee,runtimeDefaultMode:Q}),[pe,q]=c.useState(!1),G=c.useCallback(ne=>h.updateSession({permissionMode:ne}),[h]),re=c.useCallback(ne=>{if(ne==="auto"&&!H){I(!0);return}G(ne).then(we=>{we&&V.offerFor(ne)})},[H,G,V,I]),ie=c.useCallback(()=>{$(e),G("auto"),I(!1)},[$,e,G,I]),oe=ec(ee),K=oe!==void 0&&h.permissionMode===oe.id,ue=tc(e),Se=se(ne=>ne.recordModeBeforePlan),be=c.useCallback(ne=>{if(!oe)return;if(ne){Se(e,h.permissionMode),G(oe.id);return}const we=ue,ze=we!==void 0&&ee.some(We=>We.id===we)&&(we!=="auto"||L)?we:Q;ze&&G(ze)},[oe,Se,e,h,G,ue,ee,L,Q]),X=f.runtime?Tt(f.runtime).label:"",Te=Ma(B==null?void 0:B.commandIntents,X),je=g.contextPercent,de=kx({sessionId:e,percent:je,compactSupported:Te.supported,isStreaming:n}),[Ce,J]=c.useState(!1);ou(()=>J(ne=>!ne));const Y={cwd:h.cwd,git:au(T)?iu(T.branch,T.clean,T.detached):null,contextPercent:je,connectionState:s,permissionMode:h.permissionMode,permissionDescriptor:(B==null?void 0:B.permissionModes.values.find(ne=>ne.id===h.permissionMode))??null,permissionPickerOpen:pe,plan:oe?{active:K}:null,runtime:f.runtime===null||R===void 0?null:{type:f.runtime,isDefault:f.runtime===R.defaultRuntime,canSelect:f.canSelect},account:Co(m),usage:b,usageStale:v,subagentsInFlight:F,extensionItems:w.promotion},te=de.visible&&d.density==="full",fe=de.visible&&!te,he=Ex({sessionId:e,agent:{name:o,color:a,emoji:i,path:l},status:h,onUpdateSession:h.updateSession,onChangeMode:re,makeDefault:pe?V.line:null,onPermissionPickerOpenChange:q,modelSupportsAutoMode:L,plan:oe?{descriptor:oe,active:K,onToggle:be}:null,gitStatus:T,workspace:N,runtimeChip:f,account:m,contextPercent:je,contextUsage:p,contextReading:_,compact:te?{pending:de.pending,onCompact:de.onCompact}:null,usage:b,usageSource:C.source,usageObservedAt:C.observedAt,now:k,supportsCostTracking:(B==null?void 0:B.supportsCostTracking)??!0,runningSubagents:M,liveSubagentCount:F,waitingOnSubagents:g.lifecycle==="idle",connectionState:s,density:d.density,extensions:{ctx:E,items:w.visible}}),{items:ye,overflow:ge}=lu(cu({ctx:Y,pins:x,nodes:he}),d);return r.jsxs("div",{ref:u,className:"relative pt-2",children:[!pe&&V.line&&r.jsx(uu,{...V.line,placement:"overlay"}),r.jsx(du,{items:ye,trailing:r.jsx(fu,{open:Ce,onOpenChange:J,diagnostics:g,controls:{plan:oe?{active:K,onToggle:be}:null},promotionContext:Y,overflowCount:ge,addOns:w.visible.length>0?r.jsx(wx,{ctx:E,items:w.visible}):void 0,urgentAction:fe?{label:`Compact chat · ${de.percent}% full`,onAction:de.onCompact,pending:de.pending}:null})}),r.jsx(mu,{usage:b??null,accountUsage:C.accountUsage,observedAt:C.observedAt,open:j,onOpenChange:D}),r.jsx(pu,{open:P,onOpenChange:I,onConfirm:ie})]})}const Fx=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 Rx(e){return e!==void 0&&e!=="completed"}function Mx(e){const t=Fx[e];return t!==void 0?t:Ix(e)}function Ix(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 Ox({terminalReason:e}){const t=Rx(e),n=t?Mx(e):"";return r.jsx(ce,{children:t&&r.jsx(W.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,ease:"easeOut"},className:"flex px-4 py-1","data-testid":"terminal-reason-chip",children:r.jsx(nc,{variant:"secondary","aria-label":`Chat ended: ${n}`,children:n})},e)})}const $x="The turn ended before completing.";function Px({sessionId:e,onRetry:t,onSigninComplete:n,onChooseModel:s}){var m;const o=sn(e),a=((m=ds(e))==null?void 0:m.lastError)??null,i=(a==null?void 0:a.category)==="auth_error"||(a==null?void 0:a.category)==="model_unavailable"||(a==null?void 0:a.category)==="runtime_update_required",l=!i&&o?`${Tt(o).label} stopped unexpectedly`:void 0,u=(a==null?void 0:a.message)??$x,d=i?void 0:u,f=o?is(o):void 0,h=a?[a.code,a.details].filter(Boolean).join(`
|
|
51
|
-
`):void 0;return r.jsx(W.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:.3,duration:.2,ease:"easeOut"},className:"mx-4 mb-2","data-testid":"turn-failed-notice",children:r.jsx(on,{category:(a==null?void 0:a.category)??"execution_error",heading:l,message:u,subtext:d,details:h||void 0,onRetry:t,onSigninComplete:n,onChooseModel:s,runtimeLabel:f,sessionId:e,...a!=null&&a.code?{code:a.code}:{},...a!=null&&a.reason?{reason:a.reason}:{}})})}const Lx=["Type @ to mention a file","Type / to browse commands","End a line with \\ to keep typing","Drop or paste files to attach"];function Bx(e,t,n){const s=c.useCallback(g=>{var k;if(!e||!t.current)return;const C=se.getState(),b=(k=n.current)==null?void 0:k.get(e);if(b!==void 0&&C.getSession(e).mountGeneration!==b)return;const y=typeof g=="function"?g(C.getSession(e).messages):g;C.updateSession(e,{messages:y})},[e,t,n]),o=c.useCallback(g=>{e&&se.getState().updateSession(e,{input:g})},[e]),a=c.useCallback(g=>{e&&se.getState().updateSession(e,{status:g})},[e]),i=c.useCallback(g=>{e&&se.getState().updateSession(e,{error:g})},[e]),l=c.useCallback(g=>{e&&se.getState().updateSession(e,{sessionStatus:g})},[e]),u=c.useCallback(g=>{e&&se.getState().updateSession(e,{estimatedTokens:g})},[e]),d=c.useCallback(g=>{e&&se.getState().updateSession(e,{streamStartTime:g})},[e]),f=c.useCallback(g=>{e&&se.getState().updateSession(e,{isTextStreaming:g})},[e]),h=c.useCallback(g=>{e&&se.getState().updateSession(e,{systemStatus:g})},[e]),m=c.useCallback(g=>{e&&se.getState().updateSession(e,{operationProgress:g})},[e]),x=c.useCallback(g=>{e&&se.getState().updateSession(e,{promptSuggestions:g})},[e]);return{setMessages:s,setInput:o,setStatus:a,setError:i,setSessionStatus:l,setEstimatedTokens:u,setStreamStartTime:d,setIsTextStreaming:f,setSystemStatus:h,setOperationProgress:m,setPromptSuggestions:x}}function zx({sessionId:e,sid:t,transport:n,sessionCwd:s,enableMessagePolling:o,isStreaming:a,streamHydrated:i,setMessages:l}){const u=Po(),d=s.cwd,f=c.useRef(d);c.useEffect(()=>{f.current=d},[d]);const h=c.useRef(i);c.useEffect(()=>{h.current=i},[i]);const m=Xe({queryKey:["messages",e,d],queryFn:()=>n.getMessages(e,d??void 0,{newest:!0}),staleTime:Ke.MESSAGE_STALE_TIME_MS,refetchOnWindowFocus:!1,enabled:e!==null&&!i,refetchInterval:()=>a||!o?!1:u?Ke.ACTIVE_TAB_REFETCH_MS:Ke.BACKGROUND_TAB_REFETCH_MS});return c.useEffect(()=>{const x=se.getState();t&&x.updateSession(t,{historySeeded:!1}),x.getSession(e??"").status!=="streaming"&&l([])},[e,d,t,l]),c.useEffect(()=>{if(!m.data)return;const x=m.data.messages,g=se.getState().getSession(t).historySeeded;if(!g&&x.length>0){if(a)return;if(t&&se.getState().updateSession(t,{historySeeded:!0}),e&&!h.current){const C=m.data.earlierMessages??0;Pe.getState().noteSnapshot(e,x[0].id,C)}l(x.map(ot));return}g&&!a&&cp(se.getState().getSession(t).messages,x,l)},[m.data,a,e,t,l]),{historyQuery:m}}function Oa(e,t){if(e===t)return;const{opened:n,counts:s,mergeUsage:o}=at.getState(),a=Ls("session",e),i=Date.parse(n[a]??"");Number.isNaN(i)||o([{key:Ls("session",t),lastUsedAt:i,useCount:s[a]??1}])}function Xn(e,t,n){e&&n.then(s=>{if(!s)return;const o=se.getState();o.getSession(e).input.trim()===t.trim()&&o.updateSession(e,{input:""})},()=>{})}const Lt=new Map;function qx(e,t){const s=(Lt.get(e)??Promise.resolve()).then(t),o=s.then(()=>{},()=>{});return Lt.set(e,o),o.then(()=>{Lt.get(e)===o&&Lt.delete(e)}),s}const tt=new Set;function Dr(e){var o;const t=e,n=typeof(t==null?void 0:t.code)=="string"?t.code:void 0,s=(o=t==null?void 0:t.body)==null?void 0:o.agentId;return{...n?{code:n}:{},...typeof s=="string"?{agentId:s}:{}}}function Ux({sessionId:e,input:t,status:n,transport:s,queryClient:o,selectedCwd:a,onSessionIdChangeReplace:i,transformContent:l,launchRuntime:u,agentPath:d,agentLookupPending:f,agentLookupFailed:h,launchAccount:m,takeSeedContext:x,setInput:g,setError:C,tryNativeCommand:b}){const y=c.useRef(a);c.useEffect(()=>{y.current=a},[a]);const k=c.useRef(u);c.useEffect(()=>{k.current=u},[u]);const v=c.useRef(m);c.useEffect(()=>{v.current=m},[m]);const{data:p}=as(),_=c.useRef(p==null?void 0:p.defaultRuntime);c.useEffect(()=>{_.current=p==null?void 0:p.defaultRuntime},[p==null?void 0:p.defaultRuntime]);const j=hu(e,u),D=c.useRef(j.mode);c.useEffect(()=>{D.current=j.mode},[j.mode]);const T=c.useRef(l);c.useEffect(()=>{T.current=l});const N=c.useRef(x);c.useEffect(()=>{N.current=x});const A=c.useRef(i);c.useEffect(()=>{A.current=i});const S=c.useCallback(async(H,$,P={})=>{var ue,Se,be;if(!P.kickoff){const X=b(H);if(X.handled){$&&X.ran&&(X.confirmed?Xn(e,H,X.confirmed):g(""));return}}const I=e,V=P.cwd??y.current;C(null);const pe=o.getQueryData(Ve.list(V))??[],q=pn(I),G=(q==null?void 0:q.draft)??!pe.some(X=>X.id===I),re=(q==null?void 0:q.draft)===!1?!1:G||tt.has(I);if(re&&(f||h))return;re&&tt.add(I),P.kickoff||(at.getState().recordOpened("session",I),V&&at.getState().recordOpened("agent",V)),bt.attachSession(I,V);let ie;try{ie=!P.kickoff&&T.current?await T.current(H):H}catch(X){if(P.kickoff)throw X;C({heading:"Couldn’t send message",message:X.message||"The attachment didn’t upload. Try again.",retryable:!1});return}const oe=_e.getState();if(G){const X=new Date().toISOString();Bs(o,V,{id:I,title:`Chat ${I.slice(0,8)}`,createdAt:X,updatedAt:X,permissionMode:((ue=o.getQueryData(Ve.detail(I,V)))==null?void 0:ue.permissionMode)??D.current??"default",runtime:k.current??_.current??"claude-code"})}const K=crypto.randomUUID();P.kickoff||oe.setOptimisticUserMessage(I,{id:K,content:H}),oe.setTriggerPending(I,!0),$&&g("");try{const X=zs(ae.getState(),V??null),{uiState:Te,commit:je}=qs(I,X),Ce={clientMessageId:K,context:Te?{uiState:Te}:void 0};re&&(Ce.create=!0),re&&k.current&&(Ce.runtime=k.current),re&&d&&(Ce.agentPath=d),re&&v.current&&(Ce.account=v.current);const J=ae.getState().retryAccount;(J==null?void 0:J.sessionId)===I&&(Ce.account=J.id,ae.getState().setRetryAccount(null));const Y=(Se=N.current)==null?void 0:Se.call(N);Y&&(Ce.seedContext=Y);const{sessionId:te}=await s.postMessage(I,ie,V??void 0,Ce);if(tt.delete(I),q){const he={...q,draft:!1};hn(I,he),hn(te,he)}if(je(te),te!==I){_e.getState().migrateSessionContinuity(I,te),ae.getState().carryCanvasWritesAcross(I,te),bt.attachSession(te,V),Oa(I,te),nt.getState().migrate(I,te);const he=o.getQueryData(Ve.list(V))??[],ye=he.find(ge=>ge.id===I);ye&&!he.some(ge=>ge.id===te)&&Bs(o,V,{...ye,id:te}),o.setQueryData(Ve.list(V),ge=>ge==null?void 0:ge.filter(Ae=>Ae.id!==I))}(be=A.current)==null||be.call(A,te);const fe=te;setTimeout(()=>{var ge;const he=yt.getState().rekeys[fe]??fe,ye=_e.getState().getSession(he);ye.triggerPending&&((ge=ye.status)==null?void 0:ge.lifecycle)!=="streaming"&&_e.getState().setTriggerPending(he,!1)},en.TRIGGER_PENDING_TIMEOUT_MS)}catch(X){if(_e.getState().setOptimisticUserMessage(I,null),_e.getState().setTriggerPending(I,!1),P.kickoff)throw X;C({heading:"Couldn’t send message",message:X.message||"Couldn’t reach DorkOS. Try again.",retryable:!0,...Dr(X)})}},[e,s,o,g,C,b,d,f,h]),E=c.useCallback(async(H,$)=>{!H.trim()||n==="streaming"||await S(H.trim(),($==null?void 0:$.clearInput)===!0,{...$!=null&&$.cwd?{cwd:$.cwd}:{}})},[n,S]),w=c.useCallback(()=>E(t,{clearInput:!0}),[t,E]),R=c.useCallback(async(H,$,P)=>{if(!e)return!1;const I=e,V=y.current;C(null);const pe=(o.getQueryData(Ve.list(V))??[]).some(G=>G.id===I),q=pn(I);return((q==null?void 0:q.draft)??!pe)&&tt.add(I),qx(I,async()=>{var re;let G;try{G=T.current?await T.current(H):H}catch(ie){return C({heading:P,message:ie.message||"The attachment didn’t upload. Try again.",retryable:!1}),!1}try{const ie=zs(ae.getState(),V??null),{uiState:oe,commit:K}=qs(I,ie),ue={...oe?{uiState:oe}:{},...$==="queue"?{queued:!0}:{}},Se=Object.keys(ue).length>0?ue:void 0,be=((re=pn(I))==null?void 0:re.draft)===!1?!1:tt.has(I);if(be&&(f||h))return!1;const{sessionId:X}=await s.postMessage(I,G,V??void 0,{context:Se,disposition:$,...be?{create:!0,...k.current&&{runtime:k.current},...v.current&&{account:v.current},...d&&{agentPath:d}}:{}});return be&&tt.delete(I),q&&hn(X,{...q,draft:!1}),K(X),!0}catch(ie){return C({heading:P,message:ie.message||"Couldn’t reach DorkOS. Try again.",retryable:!1,...Dr(ie)}),!1}})},[e,s,o,C,d,f,h]),M=c.useCallback(H=>R(H,"queue","Couldn’t queue message"),[R]),F=c.useCallback(H=>R(H,"steer","Couldn’t steer the agent"),[R]),O=c.useCallback(H=>R(H,"stage","Couldn’t add context"),[R]),L=c.useCallback(async()=>{if(!e)return{receipt:{outcome:"not-running",reason:"no-open-turn",runtime:"unknown"},cancelled:[]};try{const{receipt:H,cancelledQueued:$}=await s.interruptSession(e);return{receipt:H,cancelled:$??[]}}catch{return{receipt:{outcome:"failed",reason:"delivery-failed",runtime:"unknown"},cancelled:[]}}},[e,s]),B=c.useCallback(async H=>{C(null),await S(H,!1)},[S,C]),ee=c.useCallback(async(H,$)=>{await S(H,!1,{kickoff:!0,...$?{cwd:$}:{}})},[S]),Q=c.useCallback((H,$)=>{},[]);return{handleSubmit:w,submitContent:E,enqueueContent:M,steerContent:F,addContextContent:O,stop:L,retryMessage:B,submitKickoff:ee,markToolCallResponded:Q}}const Bt=new Set,Tr=new Set,zt=new Set;function Hx(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 Wx({sessionId:e,cwd:t,status:n,messages:s,hydrated:o,canStart:a=!0,submitKickoff:i,submitContent:l}){const u=Zt(e),d=s.length,f=s.some(Hx);c.useEffect(()=>{if(!e)return;if(!u){t&&d===0&&n==="idle"&&nt.getState().claimByPath(t,e);return}if(u.fired||Bt.has(e)||!a||d>0||n!=="idle")return;Bt.add(e),nt.getState().markFired(e);const h=u.kind==="first-message";(h?l:i)(u.kickoffMessage,u.path||void 0).catch(x=>{console.warn("[chat] first-turn trigger failed for newborn session",e,x),Tr.has(e)?h||nt.getState().markGreetingFailed(e):(Tr.add(e),Bt.delete(e),nt.getState().resetFired(e))})},[e,t,u,n,d,a,i,l]),c.useEffect(()=>{if(!(!e||!u)&&u.kind!=="first-message"&&!(!u.fired&&!Bt.has(e))&&!u.greetingFailed){if(f){zt.delete(e);return}if(n==="streaming"){zt.add(e);return}o&&zt.has(e)&&(zt.delete(e),nt.getState().markGreetingFailed(e))}},[e,u,n,f,o])}function Gx(e,t){return c.useEffect(()=>{sc(),bt.connectList(),e&&bt.attachSession(e,t)},[e,t]),c.useEffect(()=>()=>bt.releaseSession(),[]),_o(e??"")}function Vx(e,t){const n=jo(e),s=c.useRef(t);c.useEffect(()=>{s.current=t}),c.useEffect(()=>{var o;!n||!e||(Oa(e,n),(o=s.current)==null||o.call(s,n))},[n,e])}const Kx=500;function Qx(e,t,n){const s=c.useRef(new Map),[o,a]=c.useState(null),i=t.length>0?t[0].seq:-1;c.useEffect(()=>{const h=s.current;if(!e||!n){e&&h.delete(e),a(null);return}let m=h.get(e);(!m||m.turnSeq!==i)&&(m={turnSeq:i,anchor:Date.now()},h.set(e,m)),a(m.anchor)},[e,n,i]);const l=c.useMemo(()=>{let h=0;for(const m of t)m.type==="text_delta"&&(h+=m.text.length);return h/4},[t]),[u,d]=c.useState(!1),f=c.useRef({sid:null,tokens:0});return c.useEffect(()=>{const h=f.current,m=e===h.sid&&l>h.tokens;if(f.current={sid:e,tokens:l},m&&!u&&d(!0),!m&&!u)return;const x=setTimeout(()=>d(!1),Kx);return()=>clearTimeout(x)},[e,l,u]),{streamStartTime:o,estimatedTokens:l,isTextStreaming:u}}function Xx(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 Yx(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===rc)&&(n={message:s.message});continue}n=null}return{operationProgress:t,systemStatus:n}}function Jx(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 Zx(e,t){return((e==null?void 0:e.message)??null)===((t==null?void 0:t.message)??null)}function e0(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}=Yx(t),f=o.current.get(e)??null;Jx(f,u)||(i.current(u),o.current.set(e,u));const h=a.current.get(e)??null;Zx(h,d)||(l.current(d),a.current.set(e,d))},[e,t])}function t0(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 n0(e,t){const n=t0(e,t.approval.approvalId);n?n.approval=t.approval:e.push({type:"capability_approval",approval:t.approval})}function s0(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 r0(e,t,n){return e.findIndex(s=>s.type==="mcp_signin"&&s.agentId===t&&s.serverName===n&&s.outcome===void 0)}function o0(e,t){const n={type:"mcp_signin",serverName:t.serverName,agentId:t.agentId,flowId:t.flowId,authorizeUrl:t.authorizeUrl,disclosure:t.disclosure},s=r0(e,t.agentId,t.serverName);s===-1?e.push(n):e[s]=n}function a0(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 i0(e){return e.type==="interaction_resolved"||e.type==="capability_approval_resolved"||e.type==="mcp_signin_resolved"}function l0(e){const t=new Set;for(const n of e)n.type==="interaction_resolved"&&t.add(n.id);return t}const Ar="__in_progress_turn__",c0="__optimistic_user__";function u0(e){return{id:c0,role:"user",content:e,parts:[{type:"text",text:e}],timestamp:"",_streaming:!0}}function d0(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 f0(e){return{id:`staged-${e.messageId}`,role:"user",content:e.content,parts:[{type:"text",text:e.content}],timestamp:"",_streaming:!0,_stagedContext:!0}}function $e(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="tool_call"&&s.toolCallId===t)return s}}function cn(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="elicitation"&&s.interactionId===t)return s}}function m0(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){$a(e);const n=e[e.length-1];n&&n.type==="text"?n.text+=t.text:e.push({type:"text",text:t.text})}function h0(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 $a(e){for(const t of e)t.type==="thinking"&&t.isStreaming&&(t.isStreaming=!1)}function g0(e,t,n){const s=$e(e,t.toolCallId);if(s){t.input!==void 0&&(s.input=(s.input??"")+t.input);return}const o=n.get(t.toolCallId);n.delete(t.toolCallId),e.push({type:"tool_call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input??"",status:t.status,...o&&o.length>0?{hooks:o}:{}})}function x0(e,t){const n=$e(e,t.toolCallId);n?(n.result=t.result,n.status=t.status,t.ui!==void 0&&(n.ui=t.ui),t.result!==void 0&&(n.progressOutput=void 0)):e.push({type:"tool_call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input??"",result:t.result,status:t.status,...t.ui!==void 0?{ui:t.ui}:{}})}function b0(e,t){const n=$e(e,t.toolCallId);n&&(n.progressOutput=(n.progressOutput??"")+t.content)}function Pa(e,t){const n={interactiveType:"approval",input:t.input,status:"pending",timeoutMs:t.timeoutMs,approvalStartedAt:t.startedAt,approvalRemainingMs:t.remainingMs,approvalTitle:t.title,approvalDisplayName:t.displayName,approvalDescription:t.description,approvalBlockedPath:t.blockedPath,approvalDecisionReason:t.decisionReason,approvalHasSuggestions:t.hasSuggestions,approvalAlwaysAllowScope:t.alwaysAllowScope},s=$e(e,t.id);s?Object.assign(s,n):e.push({type:"tool_call",toolCallId:t.id,toolName:t.toolName,...n})}function La(e,t){const n=$e(e,t.id),s={timeoutMs:t.timeoutMs,approvalStartedAt:t.startedAt,approvalRemainingMs:t.remainingMs};n?(n.interactiveType="question",n.questions=t.questions,n.status="pending",Object.assign(n,s)):e.push({type:"tool_call",toolCallId:t.id,toolName:"AskUserQuestion",input:"",status:"pending",interactiveType:"question",questions:t.questions,...s})}function Ba(e,t){const n={serverName:t.serverName,message:t.message,mode:t.mode,url:t.url,elicitationId:t.elicitationId,requestedSchema:t.requestedSchema,status:"pending",startedAt:t.startedAt,remainingMs:t.remainingMs,timeoutMs:t.timeoutMs},s=cn(e,t.id);s?Object.assign(s,n):e.push({type:"elicitation",interactionId:t.id,...n})}function y0(e){return e==="denied"||e==="expired"||e==="cancelled"?"error":e==="answered"?"complete":"running"}function v0(e,t){const n=$e(e,t.id);if(n){n.status==="pending"&&(n.status=y0(t.resolution),n.approvalRemainingMs=void 0);const o=oc(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=ac(t);a&&(n.questionOutcome=a)}const s=cn(e,t.id);s&&s.status==="pending"&&(s.status="submitted",s.remainingMs=void 0)}function k0(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 C0(e,t){for(const n of e.values()){const s=n.find(o=>o.hookId===t);if(s)return s}}function S0(e,t,n){const s=k0(e,t.hookId)??C0(n,t.hookId);if(s){s.status=t.status,t.hookName!==void 0&&(s.hookName=t.hookName),t.stdout!==void 0&&(s.stdout=t.stdout),t.stderr!==void 0&&(s.stderr=t.stderr),t.exitCode!==void 0&&(s.exitCode=t.exitCode);return}if(!t.toolCallId)return;const o={hookId:t.hookId,hookName:t.hookName??"",hookEvent:t.hookEvent??"",status:t.status,stdout:t.stdout??"",stderr:t.stderr??"",...t.exitCode!==void 0?{exitCode:t.exitCode}:{}},a=$e(e,t.toolCallId);a?a.hooks=[...a.hooks??[],o]:n.set(t.toolCallId,[...n.get(t.toolCallId)??[],o])}function _0(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 j0(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 w0(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 N0(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 E0(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 D0(e,t){$a(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 T0(e,t){const n=m0(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 A0={approval:"approval_required",question:"question_prompt",elicitation:"elicitation_prompt"};function F0(e){const{type:t,...n}=e;return{...n,seq:0,type:A0[t]}}function R0(e,t){const n=$e(e,t);return(n==null?void 0:n.interactiveType)!==void 0?!0:cn(e,t)!==void 0}function M0(e,t){switch(t.type){case"approval_required":Pa(e,t);break;case"question_prompt":La(e,t);break;case"elicitation_prompt":Ba(e,t);break}}function I0(e,t,n){const s=$e(e,t.id);if(s){!n&&s.result===void 0&&(s.status="pending"),s.approvalStartedAt=t.startedAt,s.approvalRemainingMs=t.remainingMs,t.timeoutMs!==void 0&&(s.timeoutMs=t.timeoutMs),s.approvalParked=t.parked===!0?!0:void 0;return}const o=cn(e,t.id);o&&(o.startedAt=t.startedAt,o.remainingMs=t.remainingMs,t.timeoutMs!==void 0&&(o.timeoutMs=t.timeoutMs))}function O0(e,t,n){for(const s of t){if(R0(e,s.id)){I0(e,s,n.has(s.id));continue}M0(e,F0(s)),$0(e,s)}}function $0(e,t){if(t.parked!==!0)return;const n=$e(e,t.id);n&&(n.approvalParked=!0)}function Yn(e){const t=[],n=new Map;for(const s of e)switch(s.type){case"text_delta":p0(t,s);break;case"thinking_delta":h0(t,s);break;case"tool_call":g0(t,s,n);break;case"tool_result":x0(t,s);break;case"tool_progress":b0(t,s);break;case"approval_required":Pa(t,s);break;case"question_prompt":La(t,s);break;case"elicitation_prompt":Ba(t,s);break;case"capability_approval_required":n0(t,s);break;case"capability_approval_resolved":s0(t,s);break;case"mcp_signin_required":o0(t,s);break;case"mcp_signin_resolved":a0(t,s);break;case"interaction_resolved":v0(t,s);break;case"subagent_update":T0(t,s);break;case"hook_update":S0(t,s,n);break;case"memory_recall":_0(t,s);break;case"image_attachment":j0(t,s);break;case"compact_boundary":w0(t,s);break;case"permission_denied":N0(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":E0(t,s);break;case"error":D0(t,s);break}return t}function Fr(e,t){if(e.length===0)return null;const n=hs(e);return{id:t,role:"assistant",content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:[],parts:e,timestamp:"",_streaming:!0}}function P0(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=Yn([...s,...e.slice(l+1).filter(i0)]),f=Fr(d,`${Ar}-${o}`);f&&n.push(f),o+=1,n.push(u.type==="turn_input"?d0(u):f0(u)),s=[]}const a=Yn(s);O0(a,t,l0(e));const i=Fr(a,Ar);return i&&n.push(i),n}function L0(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 B0(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 z0(e,t){const n=e.parts.filter(o=>o.type!=="tool_call"||!t.has(o.toolCallId)||!B0(o));if(n.length===e.parts.length)return e;if(n.length===0)return null;const s=hs(n);return{...e,parts:n,content:s.content,toolCalls:s.toolCalls.length>0?s.toolCalls:void 0}}function q0(e){let t=e.length;for(;t>0&&e[t-1].role==="assistant";)t-=1;return t}function U0(e,t,n=[],s=null){const o=P0(t,n),a=L0(o),i=lp(e),l=a.size===0?i.length:q0(i),u=[];for(const[d,f]of i.entries()){const h=d<l?f:z0(f,a);h&&u.push(h)}return s&&u.push(u0(s.content)),u.push(...o),u}function Rr(e){const t=new Map;for(const n of e)n.type!=="tool_call"||n.approvalOutcome===void 0||t.set(n.toolCallId,{outcome:n.approvalOutcome,resolvedAt:n.approvalResolvedAt,startedAt:n.approvalStartedAt,displayName:n.approvalDisplayName,reasonGiven:n.approvalReasonGiven});return t}function H0(e,t){return e.interactiveType==="approval"&&e.approvalOutcome===t.outcome&&e.approvalResolvedAt===t.resolvedAt&&e.approvalStartedAt===t.startedAt&&e.approvalReasonGiven===t.reasonGiven}function W0(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||H0(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 G0(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 V0(e,t,n,s){const o=K0(s());if(o!==void 0){const a=await e.getMessages(t,n,{since:o}),i=G0(s(),a);if(i)return i}return(await e.getMessages(t,n)).messages}function K0(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="user")return e[t].id}function Q0({sessionId:e,transport:t,sessionCwd:n,streamState:s,queryClient:o,onStreamingDone:a}){var k;const i=n.cwd,l=c.useRef(e),u=c.useRef(i),d=c.useRef(a);c.useEffect(()=>{l.current=e,u.current=i,d.current=a});const f=c.useRef(new Map),h=c.useRef(new Map),m=c.useRef(new Map),x=c.useRef(new Map),g=c.useRef(new Map),C=((k=s.status)==null?void 0:k.lifecycle)??null,b=s.hydrationGeneration,y=s.userTurnCount;c.useEffect(()=>{var A,S,E;if(!e)return;const v=g.current.get(e);g.current.set(e,y),v!==void 0&&y!==v&&x.current.set(e,!1);const p=h.current.get(e);if(h.current.set(e,b),p!==b){f.current.set(e,C),C==="streaming"&&m.current.set(e,((A=_e.getState().getSession(e).optimisticUserMessage)==null?void 0:A.id)??null);return}const _=f.current.get(e)??null;if(f.current.set(e,C),C==="streaming"&&_!=="streaming"&&m.current.set(e,((S=_e.getState().getSession(e).optimisticUserMessage)==null?void 0:S.id)??null),!(_==="streaming"&&C!=="streaming"&&C!==null))return;const D=e,T=m.current.get(D)??null,N=Rr(Yn(_e.getState().getSession(D).inProgressTurn));V0(t,D,u.current??void 0,()=>_e.getState().getSession(D).messages).then(w=>{var B;const R=_e.getState(),M=R.getSession(D),F=((B=M.status)==null?void 0:B.lifecycle)==="streaming",O=new Map([...Rr(M.messages.flatMap(ee=>ee.parts??[])),...N]);R.setHistoryMessages(D,W0(w,O),{preserveInProgressTurn:F});const L=M.optimisticUserMessage;(L===null||L.id===T)&&R.setOptimisticUserMessage(D,null)}).catch(w=>{console.warn("[turn-end-reconcile] history reload failed",{sessionId:D,error:w instanceof Error?w.message:String(w)})}),o.invalidateQueries({queryKey:["tasks",D]}),x.current.get(D)!==!0&&(x.current.set(D,!0),(E=d.current)==null||E.call(d))},[e,C,b,y,t,o])}function X0(e){return e.streamReadyCursor!==null||e.messages.length>0||e.inProgressTurn.length>0||e.optimisticUserMessage!==null}function za(e,t){const n=X0(e),s=n?e.messages:t,o=Mr.get(s);if(o&&o.hydrated===n&&o.inProgressTurn===e.inProgressTurn&&o.pendingInteractions===e.pendingInteractions&&o.optimisticUserMessage===e.optimisticUserMessage&&o.legacyMessages===t)return o.result;const a=n?U0(e.messages,e.inProgressTurn,e.pendingInteractions,e.optimisticUserMessage):t,i=Mc(a);return Mr.set(s,{hydrated:n,inProgressTurn:e.inProgressTurn,pendingInteractions:e.pendingInteractions,optimisticUserMessage:e.optimisticUserMessage,legacyMessages:t,result:i}),i}const Mr=new WeakMap;function Y0(e,t={}){const n=ke(),s=rs(),o=ae(K=>K.selectedCwd),a=ae(K=>K.enableMessagePolling),i=ae(K=>K.pendingAccount),l=Wo(),u=e??"",{messages:d,input:f,status:h,error:m,sessionStatus:x,systemStatus:g,operationProgress:C,promptSuggestions:b}=wo(u),y=Gx(e,l.cwd);Vx(e,t.onSessionIdChangeReplace);const k=ic(u),v=c.useMemo(()=>za(y,d),[y,d]),p=gu(y,h),{streamStartTime:_,estimatedTokens:j,isTextStreaming:D}=Qx(e,y.inProgressTurn,p==="streaming");Xx(e,y.inProgressTurn,y.streamReadyCursor,t.onTaskEvent);const T=c.useRef(!0);c.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]);const N=c.useRef(new Map);c.useLayoutEffect(()=>{u&&(N.current.has(u)||N.current.set(u,se.getState().getSession(u).mountGeneration))},[u]);const{setMessages:A,setInput:S,setError:E,setSystemStatus:w,setOperationProgress:R}=Bx(u,T,N);e0(e,y.inProgressTurn,R,w),u&&se.getState().initSession(u),c.useEffect(()=>{e&&(se.getState().initSession(e),se.getState().touchSession(e),N.current.set(e,se.getState().getSession(e).mountGeneration))},[e]),c.useEffect(()=>{if(e)return yt.getState().clearUnseen(e),yt.subscribe(K=>{K.unseen[e]!==void 0&&yt.getState().clearUnseen(e)})},[e]);const{historyQuery:M}=zx({sessionId:e,sid:u,transport:n,sessionCwd:l,enableMessagePolling:a,isStreaming:p==="streaming",streamHydrated:y.streamReadyCursor!==null,setMessages:A}),F=gx(o,e,{startFreshSession:t.startFreshSession,compact:t.compactIntent}),{handleSubmit:O,submitContent:L,enqueueContent:B,steerContent:ee,addContextContent:Q,stop:H,retryMessage:$,submitKickoff:P,markToolCallResponded:I}=Ux({sessionId:e,input:f,status:p,transport:n,queryClient:s,selectedCwd:o,onSessionIdChangeReplace:t.onSessionIdChangeReplace,transformContent:t.transformContent,launchRuntime:t.launchRuntime,agentPath:t.agentPath,agentLookupPending:t.agentLookupPending,agentLookupFailed:t.agentLookupFailed,launchAccount:(i==null?void 0:i.sessionId)===u?i.id:null,takeSeedContext:t.takeSeedContext,setInput:S,setError:E,tryNativeCommand:F.tryRun}),V=y.streamReadyCursor!==null,pe=c.useCallback((K,ue)=>L(K,ue?{cwd:ue}:void 0),[L]);Wx({sessionId:e,cwd:o,status:p,messages:v,hydrated:V,canStart:!t.agentLookupPending&&!t.agentLookupFailed,submitKickoff:P,submitContent:pe}),Q0({sessionId:e,transport:n,sessionCwd:l,streamState:y,queryClient:s,onStreamingDone:t.onStreamingDone});const q=M.isLoading&&v.length===0,G=c.useMemo(()=>v.flatMap(K=>K.toolCalls||[]).filter(K=>K.interactiveType&&K.status==="pending"),[v]),re=G[0]||null,ie=re!==null,oe=(re==null?void 0:re.interactiveType)||null;return{messages:v,input:f,setInput:S,handleSubmit:O,submitContent:L,enqueueContent:B,steerContent:ee,addContextContent:Q,status:p,error:m,stop:H,retryMessage:$,isLoadingHistory:q,hydrated:V,sessionStatus:x,streamStartTime:_,estimatedTokens:j,isTextStreaming:D,isWaitingForUser:ie,waitingType:oe,activeInteraction:re,pendingInteractions:G,markToolCallResponded:I,systemStatus:g,operationProgress:C,promptSuggestions:b,syncConnectionState:k,tryNativeCommand:F.tryRun,commandPending:F.commandPending}}function J0(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. ${eb(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 Z0(e,t){return!No(e)||e.outcome==="not-running"&&t}function eb(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 tb(){const e=ae(d=>d.showTaskCelebrations),[t,n]=c.useState(null),[s,o]=c.useState(null),a=c.useRef(null),i=c.useRef(!1);c.useEffect(()=>{const d=window.matchMedia("(prefers-reduced-motion: reduce)");i.current=d.matches;const f=h=>{i.current=h.matches};return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[]),dd({timeoutMs:Ze.IDLE_TIMEOUT_MS,onIdle:c.useCallback(()=>{var d;(d=a.current)==null||d.setIdle(!0)},[]),onReturn:c.useCallback(()=>{var d,f;(d=a.current)==null||d.setIdle(!1),(f=a.current)==null||f.onUserReturn()},[])}),c.useEffect(()=>{const d=new _d({enabled:e,miniProbability:Ze.MINI_PROBABILITY,debounceWindowMs:Ze.DEBOUNCE_WINDOW_MS,debounceThreshold:Ze.DEBOUNCE_THRESHOLD,minTasksForMajor:Ze.MIN_TASKS_FOR_MAJOR,idleTimeoutMs:Ze.IDLE_TIMEOUT_MS,onCelebrate:f=>{i.current&&f.level==="major"?n({...f,level:"mini"}):n(f),f.level==="mini"&&o(f.taskId)}});return a.current=d,()=>d.destroy()},[e]);const l=c.useCallback((d,f)=>{var h;d.action==="update"&&d.task.status==="completed"&&d.task.id&&((h=a.current)==null||h.onTaskCompleted(d.task.id,f))},[]),u=c.useCallback(()=>{n(null),o(null)},[]);return{handleTaskEvent:l,activeCelebration:t,celebratingTaskId:s,clearCelebration:u}}function An(){return{tasks:new Map,statusTimestamps:new Map,legacyCreateCount:0}}function nb(e){const t={};for(const[n,s]of Object.entries(e))s!==void 0&&s!==""&&(t[n]=s);return t}function Fn(e,t,n){switch(t.action){case"snapshot":{e.tasks.clear(),e.statusTimestamps.clear();const s=t.tasks??[t.task];for(const o of s)e.tasks.set(o.id,o),e.statusTimestamps.set(o.id,{status:o.status,since:n});return}case"create":{const s=t.task.id||`legacy:${e.legacyCreateCount++}`,o=s===t.task.id?t.task:{...t.task,id:s};e.tasks.set(s,o),e.statusTimestamps.set(s,{status:o.status,since:n});return}case"id_assigned":{const s=t.previousId;if(!s)return;const o=e.tasks.get(s);if(!o)return;const a=t.task.id;e.tasks.delete(s),e.tasks.set(a,{...o,id:a});const i=e.statusTimestamps.get(s);e.statusTimestamps.delete(s),e.statusTimestamps.set(a,i??{status:o.status,since:n});return}case"remove":{e.tasks.delete(t.task.id),e.statusTimestamps.delete(t.task.id);return}case"update":{if(!t.task.id)return;const s=e.tasks.get(t.task.id);if(!s)return;e.tasks.set(t.task.id,{...s,...nb(t.task)}),t.task.status&&t.task.status!==s.status&&e.statusTimestamps.set(t.task.id,{status:t.task.status,since:n});return}}}function Ir(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 sb(e,t){return[...e].sort((n,s)=>{const o=n.status==="in_progress"?0:n.status==="pending"&&!Ir(n,t)?1:n.status==="pending"?2:3,a=s.status==="in_progress"?0:s.status==="pending"&&!Ir(s,t)?1:s.status==="pending"?2:3;return o-a})}const rb=10;let Or=0;function qt(e){return e==="streaming"||e==="blocked"}function ob(e,t=!1){const n=ke(),o=Wo().cwd,a=ae(N=>N.enableMessagePolling),i=Po(),[l,u]=c.useState(An()),d=Eo(e??""),[f,h]=c.useState(()=>!qt(d)),m=c.useRef([]),x=c.useRef(0),{data:g}=Xe({queryKey:["tasks",e,o],queryFn:async()=>{const N=++Or;return{...await n.getTasks(e,o??void 0),fetchOrder:N}},staleTime:3e4,refetchOnWindowFocus:!1,enabled:e!==null,refetchInterval:()=>!a||t?!1:i?Ke.ACTIVE_TAB_REFETCH_MS:Ke.BACKGROUND_TAB_REFETCH_MS}),C=c.useRef(null);c.useEffect(()=>{const N=`${e??""}::${o??""}`,A=C.current!==N;if(C.current=N,A&&(m.current=[],x.current=0,u(An())),!g||g.fetchOrder<=x.current)return;x.current=g.fetchOrder;const S=An();g.tasks.length>0&&Fn(S,{action:"snapshot",task:g.tasks[0],tasks:g.tasks},Date.now()),m.current=m.current.filter(({order:E})=>E>g.fetchOrder);for(const{event:E,receivedAt:w}of m.current)Fn(S,E,w);u(S)},[g,e,o]);const b=c.useCallback(N=>{const A=Date.now();N.action==="snapshot"&&(m.current=[]),m.current.push({order:++Or,event:N,receivedAt:A}),u(S=>{const E={tasks:new Map(S.tasks),statusTimestamps:new Map(S.statusTimestamps),legacyCreateCount:S.legacyCreateCount};return Fn(E,N,A),E})},[]),y=c.useRef(!1),k=c.useCallback(()=>{h(N=>(y.current=!N,!N))},[]),v=c.useRef(qt(d));c.useEffect(()=>{const N=qt(d);N!==v.current&&(v.current=N,N?y.current||h(!1):h(!0))},[d]);const p=c.useRef(null);c.useEffect(()=>{const N=`${e??""}::${o??""}`;if(p.current===N)return;p.current=N;const A=qt(d);v.current=A,y.current=!1,h(!A)},[e,o,d]);const _=Array.from(l.tasks.values()),j=sb(_,l.tasks),D=_.find(N=>N.status==="in_progress"),T=(D==null?void 0:D.activeForm)??null;return{tasks:j.slice(0,rb),taskMap:l.tasks,activeForm:T,isCollapsed:f,toggleCollapse:k,handleTaskEvent:b,statusTimestamps:l.statusTimestamps}}function ab(e){const t=c.useRef(null),[n,s]=c.useState(0),[o,a]=c.useState(!1),[i,l]=c.useState(0),u=c.useCallback(y=>{t.current=y,l(y&&"getOptionCount"in y?y.getOptionCount():0)},[]);c.useEffect(()=>{s(0),l(0),a(!1)},[e==null?void 0:e.toolCallId]);const d=c.useMemo(()=>e!=null&&e.interactiveType?{type:e.interactiveType,toolCallId:e.toolCallId}:null,[e]),f=c.useCallback(()=>{const y=t.current;y&&"approve"in y&&y.approve()},[]),h=c.useCallback(()=>{const y=t.current;y&&"alwaysAllow"in y&&y.alwaysAllow()},[]),m=c.useCallback(()=>{const y=t.current;y&&"deny"in y&&y.deny()},[]),x=c.useCallback(y=>{const k=t.current;k&&"toggleOption"in k&&(k.toggleOption(y),s(y),a(!0))},[]),g=c.useCallback(y=>{if(!o){a(!0);return}s(k=>{const v=t.current,p=v&&"getOptionCount"in v?v.getOptionCount():0;return p===0?k:y==="up"?k<=0?p-1:k-1:k>=p-1?0:k+1})},[o]),C=c.useCallback(y=>{const k=t.current;k&&"navigateQuestion"in k&&(k.navigateQuestion(y),s(0),a(!0),l(k.getOptionCount()))},[]),b=c.useCallback(()=>{const y=t.current;y&&"submit"in y&&y.submit()},[]);return fd({activeInteraction:d,onApprove:f,onAlwaysAllow:h,onDeny:m,onToggleOption:x,onNavigateOption:g,onNavigateQuestion:C,onSubmit:b,optionCount:i,focusedIndex:n}),{handleToolRef:u,focusedOptionIndex:o?n:-1}}function Ut(e,t,n){var a;const s=e.length;if(s===0)return 0;let o=(t%s+s)%s;for(let i=0;i<s;i++){if(!((a=e[o])!=null&&a.disabled))return o;o=(o+n+s)%s}return t}function ib({commands:e,input:t,cursorPos:n}){const[s,o]=c.useState(!1),[a,i]=c.useState(""),[l,u]=c.useState(-1),d=c.useMemo(()=>a?e.map(_=>({cmd:_,rank:Xd(a,_)})).filter(_=>_.rank.match).sort((_,j)=>_.rank.bucket-j.rank.bucket||j.rank.score-_.rank.score).map(({cmd:_,rank:j})=>({..._,matchedAlias:j.matchedAlias})):e,[e,a]),[f,h]=c.useState(null),m=f!==null&&f.query===a&&f.open===s?f.index:Ut(d,0,1),x=d[m],g=d.length===0||x!==void 0&&!x.disabled?m:Ut(d,0,1),C=c.useCallback((_,j)=>{const T=_.slice(0,j).match(/(^|\s)\/([\w:-]*)$/);return T?(o(!0),i(T[2]),u((T.index??0)+T[1].length),!0):(o(!1),!1)},[]),b=c.useCallback(_=>{const j=t.slice(0,l),D=t.slice(l+1+a.length);return o(!1),j+_.fullCommand+(D.startsWith(" ")?"":" ")+D},[t,a,l]),y=c.useCallback(()=>{h({query:a,open:s,index:Ut(d,g+1,1)})},[d,g,a,s]),k=c.useCallback(()=>{h({query:a,open:s,index:Ut(d,g-1,-1)})},[d,g,a,s]),v=c.useCallback(()=>{const _=d[g];return _&&!_.disabled?b(_):(_||o(!1),null)},[d,g,b]),p=c.useCallback(()=>{o(!1),i("")},[]);return{showCommands:s,setShowCommands:o,commandQuery:a,selectedIndex:g,filteredCommands:d,slashTriggerPos:l,detectCommandTrigger:C,handleCommandSelect:b,handleArrowUp:k,handleArrowDown:y,handleKeyboardSelect:v,resetCommand:p}}function lb({fileEntries:e,input:t,cursorPos:n}){const[s,o]=c.useState(!1),[a,i]=c.useState(""),[l,u]=c.useState(0),[d,f]=c.useState(-1),h=c.useMemo(()=>s?a?e.map(k=>({...k,...Wt(a,k.path)})).filter(k=>k.match).sort((k,v)=>v.score-k.score).slice(0,50):e.slice(0,50).map(k=>({...k,indices:[]})):[],[e,a,s]);c.useEffect(()=>{u(0)},[a,s]),c.useEffect(()=>{h.length>0&&l>=h.length&&u(h.length-1)},[h.length,l]);const m=c.useCallback((k,v)=>{const _=k.slice(0,v).match(/(^|\s)@([\w./:-]*)$/);return _?(o(!0),i(_[2]),f((_.index??0)+_[1].length),!0):(o(!1),!1)},[]),x=c.useCallback(k=>{const v=t.slice(0,d),p=t.slice(d+1+a.length);if(k.isDirectory){const j=v+"@"+k.path+p,D=v.length+1+k.path.length;return i(k.path),u(0),{newValue:j,newCursorPos:D,keepOpen:!0}}const _=v+"@"+k.path+" "+p;return o(!1),{newValue:_,keepOpen:!1}},[t,d,a]),g=c.useCallback(()=>{u(k=>h.length===0?0:(k+1)%h.length)},[h.length]),C=c.useCallback(()=>{u(k=>h.length===0?0:(k-1+h.length)%h.length)},[h.length]),b=c.useCallback(()=>h.length>0&&l<h.length?x(h[l]):(o(!1),null),[h,l,x]),y=c.useCallback(()=>{o(!1),i("")},[]);return{showFiles:s,setShowFiles:o,fileQuery:a,fileSelectedIndex:l,filteredFiles:h,fileTriggerPos:d,detectFileTrigger:m,handleFileSelect:x,handleArrowUp:C,handleArrowDown:g,handleKeyboardSelect:b,resetFiles:y}}function cb({input:e,setInput:t,commands:n,fileEntries:s}){const[o,a]=c.useState(0),i=ib({commands:n,input:e,cursorPos:o}),l=lb({fileEntries:s,input:e,cursorPos:o}),u=c.useCallback((j,D)=>{if(l.detectFileTrigger(j,D)){i.setShowCommands(!1);return}if(i.detectCommandTrigger(j,D)){l.setShowFiles(!1);return}l.setShowFiles(!1),i.setShowCommands(!1)},[l,i]),d=c.useRef({value:e,cursor:0});c.useEffect(()=>{d.current.value=e},[e]);const f=c.useCallback(j=>{t(j),d.current={value:j,cursor:d.current.cursor||j.length},u(j,d.current.cursor)},[t,u]),h=c.useCallback(j=>{a(j),d.current={value:d.current.value,cursor:j},u(d.current.value,j)},[u]),m=c.useCallback(j=>{const D=i.handleCommandSelect(j);t(D)},[i,t]),x=c.useCallback(j=>{const D=l.handleFileSelect(j);t(D.newValue),D.newCursorPos!==void 0&&a(D.newCursorPos)},[l,t]),g=c.useCallback(()=>{l.showFiles?l.handleArrowDown():i.handleArrowDown()},[l,i]),C=c.useCallback(()=>{l.showFiles?l.handleArrowUp():i.handleArrowUp()},[l,i]),b=c.useCallback(()=>{if(l.showFiles){const j=l.handleKeyboardSelect();j&&(t(j.newValue),j.newCursorPos!==void 0&&a(j.newCursorPos))}else if(i.showCommands){const j=i.handleKeyboardSelect();j&&t(j)}},[l,i,t]),y=c.useCallback(()=>{i.setShowCommands(!1),l.setShowFiles(!1)},[i,l]),k=i.showCommands||l.showFiles,v=l.showFiles&&l.filteredFiles.length>0||i.showCommands&&i.filteredCommands.length>0,p=l.showFiles?"file-palette-listbox":i.showCommands?"command-palette-listbox":void 0,_=l.showFiles&&l.filteredFiles.length>0?`file-item-${l.fileSelectedIndex}`:i.showCommands&&i.filteredCommands.length>0?`command-item-${i.selectedIndex}`:void 0;return{commands:{show:i.showCommands,filtered:i.filteredCommands,selectedIndex:i.selectedIndex},files:{show:l.showFiles,filtered:l.filteredFiles,selectedIndex:l.fileSelectedIndex},isPaletteOpen:k,paletteHasResults:v,activeDescendantId:_,paletteListboxId:p,handleInputChange:f,handleCursorChange:h,handleArrowUp:C,handleArrowDown:g,handleKeyboardSelect:b,handleCommandSelect:m,handleFileSelect:x,dismissPalettes:y}}function ub(e,t,n){const s=ae(i=>i.setIsStreaming),o=ae(i=>i.setIsWaitingForUser),a=ae(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 db(){const e=ke(),t=ae(m=>m.selectedCwd),[n,s]=c.useState([]),o=c.useCallback(m=>{const x=m.map(g=>({id:crypto.randomUUID(),file:g,status:"pending",progress:0}));s(g=>[...g,...x])},[]),a=c.useCallback(m=>{s(x=>x.filter(g=>g.id!==m))},[]),i=c.useCallback(()=>{s([])},[]),l=c.useCallback(m=>{s(x=>x.map(g=>g.id===m&&g.status==="error"?{...g,status:"pending",progress:0,error:void 0}:g))},[]),u=c.useRef(null),d=kt({meta:{suppressErrorToast:!0},mutationFn:async m=>{if(!t)throw new Error("No working directory selected");s(b=>b.map(y=>m.some(k=>k.id===y.id)?{...y,status:"uploading"}:y));const x=b=>{s(y=>y.map(k=>k.status==="uploading"?{...k,progress:b.percentage}:k))},g=new AbortController;u.current=g;const C=m.map(b=>b.file);return e.uploadFiles(C,t,x,g.signal)},onSettled:()=>{u.current=null},onSuccess:(m,x)=>{s(g=>g.map(C=>{const b=x.findIndex(y=>y.id===C.id);return b===-1?C:{...C,status:"uploaded",progress:100,result:m[b]}}))},onError:m=>{s(x=>x.map(g=>g.status==="uploading"?{...g,status:"error",error:m.message}:g))}}),f=c.useCallback(()=>{var m;(m=u.current)==null||m.abort()},[]),h=c.useCallback(async()=>{const m=n.filter(b=>b.status==="error");if(m.length>0)throw new Error(m.length===1?`${m[0].file.name} did not upload. Retry it or remove it, then send again.`:`${m.length} attachments did not upload. Retry them or remove them, then send again.`);const x=n.filter(b=>b.status==="uploaded"&&b.result).map(b=>b.result.savedPath),g=n.filter(b=>b.status==="pending");if(g.length===0)return x;const C=await d.mutateAsync(g);return[...x,...C.map(b=>b.savedPath)]},[n,d]);return{pendingFiles:n,addFiles:o,removeFile:a,retryFile:l,clearFiles:i,cancelUpload:f,uploadAndGetPaths:h,hasPendingFiles:n.length>0,hasFailedUpload:n.some(m=>m.status==="error"),isUploading:d.isPending}}const Rn=new Set,Mn=new Set;function fb(e,t){return`${e}\0${t}`}function mb({sessionId:e,prompt:t,autoSend:n,input:s,setInput:o,messageCount:a,hydrated:i,status:l,submitBlocked:u=!1,submit:d,onSeeded:f,onConsumed:h}){const m=t!=null&&t.trim()?t:void 0,x=e&&m?fb(e,m):null;c.useEffect(()=>{if(!(!x||!m)&&!Rn.has(x)&&i){if(Rn.add(x),s.length>0||a>0){Mn.add(x),h==null||h();return}o(m),f==null||f(),n||h==null||h()}},[x,m,n,s,i,a,o,f,h]),c.useEffect(()=>{!x||!m||!n||Mn.has(x)||Rn.has(x)&&s===m&&(!i||a>0||l==="streaming"||u||(Mn.add(x),h==null||h(),d()))},[x,m,n,s,i,a,l,u,d,h])}const $r=lc-256,Pr=`
|
|
52
|
-
…(context truncated)`,Lr={"/":"the home team room","/activity":"the activity feed","/team":"the team page","/session":"a chat session","/tasks":"the scheduled-work page","/channels":"a channel","/workspaces":"the workspaces page","/connections":"the connections page","/marketplace":"the marketplace","/feedback-requests":"the feedback requests page"};function pb(e){const t=`/${e.split("/").filter(Boolean)[0]??""}`;return Lr[e]??Lr[t]??`the ${e} page`}function hb(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<=$r?n:n.slice(0,$r-Pr.length)+Pr}const gb="dorkbot-help",Ht=new Set;function xb({sessionId:e,seed:t,messageCount:n,hydrated:s,onConsumed:o}){const a=t===gb&&e!==null,{data:i}=cc({enabled:a}),{data:l}=to(),u=yt(uc(m=>Object.entries(m.statuses).filter(([,x])=>x.lifecycle==="error").map(([x])=>x))),d=c.useRef({agentNames:[],version:null,updateReady:!1,erroredSessionIds:[]}),f=c.useRef({armed:a,sessionId:e,messageCount:n}),h=c.useRef(o);return c.useEffect(()=>{const m=(l==null?void 0:l.latestVersion)??null,x=(l==null?void 0:l.version)??null;d.current={agentNames:((i==null?void 0:i.agents)??[]).map(g=>g.displayName??g.name),version:x,updateReady:m!==null&&x!==null&&Cu(m,x),erroredSessionIds:u}},[i,l,u]),c.useEffect(()=>{f.current={armed:a,sessionId:e,messageCount:n},h.current=o},[a,e,n,o]),c.useEffect(()=>{!a||e===null||!s||n===0||Ht.has(e)||(Ht.add(e),o==null||o())},[a,e,s,n,o]),c.useCallback(()=>{var x;const m=f.current;if(!(!m.armed||m.sessionId===null)&&!(m.messageCount>0)&&!Ht.has(m.sessionId))return Ht.add(m.sessionId),(x=h.current)==null||x.call(h),hb({...d.current,originPath:dc()})},[])}function bb(e,t,n,s=!1){if(e!=="error"||t||s)return!1;let o=-1;for(let i=n.length-1;i>=0;i--)if(n[i].role==="user"){o=i;break}return!n.slice(o+1).some(i=>i.parts.some(l=>l.type==="error"&&l.code!==bo))}const yb=4e3;function vb(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 kb(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?vb(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})),yb);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}`}const Br=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"],zr=5e3,Cb=1e3,Sb=1500,_b=new Set;function jb(e){const t=c.useRef(new Map),n=Do({byTask:new Map,assigned:0}),[s,o]=c.useState(_b),[,a]=c.useState(0),i=c.useMemo(()=>{const u=new Map;for(const d of e)for(const f of d.parts)f.type==="background_task"&&u.set(f.taskId,f);return u},[e]);c.useEffect(()=>{if(!Array.from(i.values()).some(f=>f.taskType==="bash"&&f.status==="running"&&Date.now()-f.startedAt<zr))return;const d=setInterval(()=>{a(f=>f+1)},Cb);return()=>clearInterval(d)},[i]);const l=c.useRef(new Set);return c.useLayoutEffect(()=>{for(const[u,d]of i)t.current.get(u)==="running"&&d.status!=="running"&&!Hs(d)&&o(h=>h.has(u)?h:new Set(h).add(u)),t.current.set(u,d.status)},[i]),c.useEffect(()=>{for(const u of s)l.current.has(u)||(l.current.add(u),setTimeout(()=>{l.current.delete(u),o(d=>{if(!d.has(u))return d;const f=new Set(d);return f.delete(u),f})},Sb))},[s]),c.useMemo(()=>{const u=Date.now(),d=[],f=n.read();let h=f.assigned;for(const[m,x]of i){const g=x.status==="running",C=s.has(m);if(!g&&!C||x.taskType==="bash"&&g&&u-x.startedAt<zr)continue;let b=f.byTask.get(m);b===void 0&&(b=Br[h%Br.length],h+=1,f.byTask.set(m,b),n.write({byTask:f.byTask,assigned:h})),d.push({taskId:x.taskId,taskType:x.taskType,status:x.status,color:b,startedAt:x.startedAt,description:x.description,toolUses:x.toolUses,lastToolName:x.lastToolName,durationMs:x.durationMs,summary:x.summary,command:x.command,ambient:Hs(x)})}return d},[i,s,n])}const wb=new Set(["streaming","blocked"]);function Nb(e,t){return e.length===0||e[0].waitingOn!==void 0||t&&wb.has(t)?e:e.slice(1)}function In(e,t,n){return`${e} ${e===1?t:n}`}const qr={"delivery-owed":"a helper’s report","waiting-on-person":"your answer","timer-pending":"a reminder the agent set"},Eb={"timer-pending":"Switching now cancels the reminder."};function Db(e){const{agents:t,shells:n,other:s}=e.holding,o=[t>0?In(t,"helper","helpers"):void 0,n>0?In(n,"command","commands"):void 0,s>0?In(s,"background job","background jobs"):void 0].filter(d=>d!==void 0),a=o.length===0?void 0:o.length===1?o[0]:`${o.slice(0,-1).join(", ")} and ${o.at(-1)}`,i=e.pins,l=i.includes("cwd")&&e.targetFolderName?`moves to ${e.targetFolderName}`:i.includes("agentIdentity")?"switches agents":i.includes("systemPromptAppend")?"loads new instructions":"applies new settings";return{line:`${a!==void 0?`Held for ${a}.`:e.because!==void 0&&qr[e.because]!==void 0?`Held for ${qr[e.because]}.`:"Held until the agent is free."} Sending it ${l}.`,switchHint:a!==void 0?`Switching now stops ${a}.`:(e.because!==void 0?Eb[e.because]:void 0)??"Switching now stops what the agent is doing."}}const Tb={"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 Ab(e){return e!=null&&e.degradedBecause?Tb[e.degradedBecause]:null}function Ur(e){return(e==null?void 0:e.code)==="QUEUED_MESSAGE_NOT_FOUND"}function Fb({sessionId:e,waiting:t,onEnqueue:n}){const s=ke(),o=fc(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:Ab(o[p.id]),...p.waitingOn?{waiting:Db(p.waitingOn)}:{}})),[t,o,s.clientId]),u=c.useMemo(()=>{if(a===null)return null;const p=l.findIndex(_=>_.id===a);return p===-1?null:p},[a,l]),d=c.useCallback(()=>{var p;if(e)return(p=_e.getState().getSession(e).queuedMessages[0])==null?void 0:p.id},[e]),f=c.useCallback((p,_)=>{p().catch(j=>{Ur(j)||De.error(_)})},[]),h=c.useCallback(async p=>{const _=p.trim();return!_||!e?!1:n(_)},[e,n]),m=c.useCallback((p,_)=>{e&&f(()=>s.updateQueuedMessage(e,p,{content:_}),"Couldn’t save that change")},[e,s,f]),x=c.useCallback(p=>{i(_=>_===p?null:_),e&&f(()=>s.removeQueuedMessage(e,p),"Couldn’t take that message off the queue")},[e,s,f]),g=c.useCallback((p,_)=>{if(!e)return;const j=D=>s.updateQueuedMessage(e,p,{move:{before:D}});f(async()=>{try{await j(_)}catch(D){if(!Ur(D))throw D;const T=d();if(T===void 0||T===p)return;await j(T)}},"Couldn’t move that message")},[e,s,f,d]),C=c.useCallback(p=>l.findIndex(j=>j.id===p)<=0?!1:(i(j=>j===p?null:j),g(p,l[0].id),!0),[l,g]),b=c.useCallback(p=>{const _=l.findIndex(j=>j.id===p);_<=0||g(p,l[_-1].id)},[l,g]),y=c.useCallback(p=>{const _=l.find(j=>j.id===p);return _?(i(p),_.content):null},[l]),k=c.useCallback(()=>{i(null)},[]),v=c.useCallback(p=>{a!==null&&(m(a,p),i(null))},[a,m]);return{queue:l,editingId:a,editingIndex:u,addToQueue:h,removeFromQueue:x,sendNow:C,moveUp:b,startEditing:y,cancelEditing:k,saveEditing:v,updateQueued:m}}function qa(e,t){return e===null?null:`${e} ${t??""}`}function Rb({input:e,setInput:t,sessionId:n,selectedCwd:s,waiting:o,onEnqueue:a,onSteer:i,onStage:l,tryNativeCommand:u,chatInputRef:d}){const f=c.useRef(""),h=c.useRef(null),m=qa(n,s);c.useEffect(()=>{f.current="",h.current=null},[m]);const x=Fb({sessionId:n,waiting:o,onEnqueue:a}),g=x.cancelEditing;c.useEffect(()=>{g()},[m,g]);const C=c.useCallback(()=>{const F=x.editingId;if(F===null)return;const O=e.trim();O&&(x.updateQueued(F,O),hx(O)&&De.warning("Saved as a command. It runs instead of sending."))},[e,x]),b=Us(x.editingId),y=Us(x.updateQueued);c.useEffect(()=>{const F=n;return()=>{const O=b.read();if(O===null||!F)return;const L=se.getState(),B=L.getSession(F).input.trim();B&&y.read()(O,B),L.updateSession(F,{input:f.current})}},[m]);const k=c.useCallback(F=>{const O=e.trim();if(!O)return;const L=u(O);if(L.handled){if(!L.ran)return;L.confirmed?Xn(n,O,L.confirmed):t("");return}if(h.current===O)return;h.current=O,at.getState().recordOpened("session",n),s&&at.getState().recordOpened("agent",s);const B=F(O);B.finally(()=>{h.current===O&&(h.current=null)}),Xn(n,O,B)},[e,s,n,t,u]),v=c.useCallback(()=>k(F=>x.addToQueue(F)),[k,x]),p=c.useCallback(()=>{i&&k(i)},[k,i]),_=c.useCallback(()=>{l&&k(l)},[k,l]),j=c.useCallback(F=>{var B,ee;if(x.editingId===F){(B=d.current)==null||B.focus();return}const O=x.editingId!==null;O&&C();const L=x.startEditing(F);L!==null&&(O||(f.current=e),t(L),(ee=d.current)==null||ee.focus())},[e,x,C,t,d]),D=c.useCallback(()=>{if(x.editingId===null)return;const F=e.trim();if(!F)return;const O=u(F);if(O.handled){O.ran&&(x.cancelEditing(),t(f.current));return}x.saveEditing(F),t(f.current)},[e,x,t,u]),T=c.useCallback(()=>{x.cancelEditing(),t(f.current)},[x,t]),N=c.useCallback(F=>{x.editingId===F&&t(f.current),x.removeFromQueue(F)},[x,t]),A=c.useCallback(F=>{const O=x.editingId===F;O&&C(),x.sendNow(F)&&O&&t(f.current)},[x,C,t]),S=c.useCallback(F=>{x.moveUp(F)},[x]),E=c.useCallback(F=>{var B;const O=(B=x.queue[F])==null?void 0:B.id;if(O!==void 0&&O===x.editingId)return;C();const L=O===void 0?null:x.startEditing(O);if(L===null){x.cancelEditing(),t(f.current);return}t(L)},[x,C,t]),w=c.useCallback(()=>{C(),x.cancelEditing(),t(f.current)},[C,x,t]),R=c.useCallback(()=>{const{editingIndex:F,queue:O}=x;if(F===null){if(O.length===0)return;f.current=e,E(O.length-1)}else F>0?E(F-1):w()},[E,e,w,x]),M=c.useCallback(()=>{const{editingIndex:F,queue:O}=x;F!==null&&(F<O.length-1?E(F+1):w())},[E,w,x]);return{queue:x.queue,editingId:x.editingId,editingIndex:x.editingIndex,handleQueue:v,handleSteer:p,handleStage:_,handleQueueEdit:j,handleQueueSaveEdit:D,handleQueueCancelEdit:T,handleQueueRemove:N,handleQueueSend:A,handleQueueMoveUp:S,handleQueueNavigateUp:R,handleQueueNavigateDown:M,leaveQueueForStop:w}}const Mb=5e3,Hr=3;function Ua(){try{const e=Number(localStorage.getItem(To.PLACEHOLDER_HINT_CYCLES));return Number.isFinite(e)&&e>0?e:0}catch{return 0}}function Ib(){const e=Ua()+1;try{localStorage.setItem(To.PLACEHOLDER_HINT_CYCLES,String(e))}catch{}return e}function Ob(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 $b({defaultText:e,hints:t,enabled:n,intervalMs:s=Mb}){const[o]=c.useState(()=>t.length>0?Ob(t):[]),[a,i]=c.useState(()=>Ua()>=Hr),[l,u]=c.useState({key:0,hintIndex:-1}),d=c.useRef(0),f=c.useRef(0),h=c.useRef(!1);return c.useEffect(()=>{if(a||!n||t.length===0){h.current&&(h.current=!1,d.current+=1,u({key:d.current,hintIndex:-1}));return}const x=setInterval(()=>{if(d.current+=1,h.current=!h.current,!h.current){u({key:d.current,hintIndex:-1});return}const g=f.current%t.length;f.current+=1,f.current%t.length===0&&Ib()>=Hr&&i(!0),u({key:d.current,hintIndex:g})},s);return()=>clearInterval(x)},[n,t.length,s,a]),{text:l.hintIndex>=0?o[l.hintIndex]??e:e,key:l.key}}const On=/[.!?…:](?=\s|$)|\n/g;function Wr(e,t,n){const s=e.startsWith(t)?t.length:0,o=e.slice(0,s),a=e.slice(s);if(a.trim()==="")return{chunk:"",announced:o};if(n)return{chunk:a.trim(),announced:e};On.lastIndex=0;let i=-1;for(let l=On.exec(a);l!==null;l=On.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 Pb=1500,Lb=4e3,Bb=400;function zb({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<=Bb?"":t})}const l=s.current.get(e),{chunk:u,announced:d}=Wr(t,l.announced,!1);l.announced=d,u!==""&&a(h=>({text:u,nonce:h.nonce+1}));const f=setTimeout(()=>{const h=Wr(t,l.announced,!0);l.announced=h.announced,h.chunk!==""&&a(m=>({text:h.chunk,nonce:m.nonce+1}))},Pb);return()=>clearTimeout(f)},[e,t,n]),c.useEffect(()=>{if(o.text==="")return;const i=setTimeout(()=>a(l=>({text:"",nonce:l.nonce})),Lb);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}`}const Ha={reactions:!1,threads:!1,runWith:!0,attachments:!0,mentions:!1,streamHealth:!1,presence:!1,turnStatus:!0,asks:!0};function qb(e){var t;(t=e==null?void 0:e.querySelector('[data-testid="model-config-trigger"]'))==null||t.click()}const Gr=new WeakMap;function Ub(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:Vb(n),d=[];for(const f of e){if(f.kind!=="post"||f.threadRootEntryId||f.sessionId!==null&&a.has(f.sessionId)&&(l??(l=Wb(n)),l.has(f.body.text)||!o&&(u===null||Date.parse(f.createdAt)<u))||i.has(f.id))continue;let h=Gr.get(f);if(!h){const m=f.body.text;h={id:`direct-note-${f.id}`,role:s.has(f.authorId)?"assistant":"user",content:m,parts:[{type:"text",text:m}],timestamp:f.createdAt,_directNote:{roomId:f.roomId,entryId:f.id,seq:f.seq}},Gr.set(f,h)}d.push(h)}return d}const Hb=/(?:^|[_.])(?:post_to_room|relay_notify_user)$/;function Wb(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&&Hb.test(o.toolName))for(const a of Gb(o.input))t.add(a);s.length>1&&t.add(s.filter(Boolean).join(`
|
|
54
|
-
|
|
55
|
-
`).trim())}return t}function Gb(e){try{const t=JSON.parse(e);return t===null||typeof t!="object"?[]:Object.values(t).filter(n=>typeof n=="string")}catch{return[]}}function Vb(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 Kb(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 Qb(e,t,n=!0){if(!t||t.entries.length===0)return{messages:e,lastSeenBeforeUnread:null,unreadFromStart:!1};const s=Ub(t.entries,t.sessionIds,e,t.agentAuthorIds,n),o=Kb(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 Xb(e){var f,h,m;const t=mc(e),n=((f=t.data)==null?void 0:f.roomId)??null,s=pc(n),o=hc(n),a=s.data,i=o.data;_u(n,i!==void 0),gc(a,i??Vr);const l=((h=a==null?void 0:a.members.find(x=>x.author.id===a.viewerAuthorId))==null?void 0:h.lastReadSeq)??null,u=Jb(n,l),d=((m=t.data)==null?void 0:m.sessionIds)??Yb;return c.useMemo(()=>{const x=s.isError||o.isError,g=n===null||x||i!==void 0&&u!==null;return{roomId:n,entries:i??Vr,sessionIds:d,agentAuthorIds:new Set(((a==null?void 0:a.members)??[]).filter(C=>C.author.kind==="agent").map(C=>C.author.id)),readSeq:u,ready:e===null||t.isError||t.isFetched&&g}},[e,t.isError,t.isFetched,n,a,i,d,u,s.isError,o.isError])}const Yb=[],Vr=[];function Jb(e,t){const[n,s]=c.useState({key:null,value:null});return n.key===e&&n.value!==null?n.value:e===null||t===null?null:(s({key:e,value:t}),t)}function Kr(e){return e>=1e3?`~${(e/1e3).toFixed(1)}k tokens`:`~${Math.round(e)} tokens`}function Zb(e){const{formatted:t}=$o(e.status==="streaming"?e.streamStartTime:null),n=ao(e.permissionMode),s=c.useRef(e.status),o=c.useRef(t),a=c.useRef(e.estimatedTokens),[i,l]=c.useState(!1);return c.useEffect(()=>{e.status==="streaming"&&(o.current=t,a.current=e.estimatedTokens,s.current!=="streaming"&&l(!1))},[e.status,t,e.estimatedTokens]),c.useEffect(()=>{s.current==="streaming"&&e.status==="idle"&&a.current>0&&l(!0),s.current=e.status},[e.status]),c.useEffect(()=>{if(!i)return;const u=setTimeout(()=>l(!1),en.TURN_COMPLETE_DISMISS_MS);return()=>clearTimeout(u)},[i]),ju({capabilities:Ha,asks:e.asks??Ro,stalled:!1,presence:wu,turn:{status:e.status,isWaitingForUser:e.isWaitingForUser,waitingType:e.waitingType,operationProgress:e.operationProgress==null?null:{message:e.operationProgress.message??null,determinate:e.operationProgress.determinate,percent:e.operationProgress.percent??null},systemStatus:e.systemStatus??null,elapsed:t,activity:e.activity,tokens:Kr(e.estimatedTokens),isBypass:n,showComplete:i,lastElapsed:o.current,lastTokens:Kr(a.current)}})}function ey(e){const{sessionId:t,placeholder:n,files:s}=e,o=c.useRef(e);c.useEffect(()=>{o.current=e});const a=c.useCallback(C=>o.current.files.addFiles(C),[]),i=c.useCallback(C=>o.current.files.removeFile(C),[]),l=c.useCallback(C=>o.current.files.retryFile(C),[]),u=c.useCallback(()=>o.current.files.cancelUpload(),[]),{pendingFiles:d,hasFailedUpload:f,isUploading:h}=s,m=c.useMemo(()=>({staged:d,add:a,remove:i,retry:l,cancel:u,hasFailed:f,isUploading:h,holdsSendWhileUploading:!0}),[d,f,h,a,i,l,u]),x=c.useCallback(async C=>{await o.current.submit(C.text)},[]),g=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:x,queue:g,attachments:m}),[t,n,m,x,g])}function ty({error:e,composerAgent:t,onRetry:n}){return e.code===go&&e.agentId?r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(Go,{agentId:e.agentId,...(t==null?void 0:t.id)===e.agentId?{agentName:nn(t,"This agent")}:{}})}):r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(on,{message:e.message,heading:e.heading,subtext:e.message,onRetry:e.retryable?n:void 0})})}const ny={duration:.16,delay:.08,ease:[.16,1,.3,1]},sy={duration:0};function ry({sessionId:e,activeInteraction:t,pendingApprovals:n,focusedOptionIndex:s,onToolRef:o,onToolDecided:a,queueDepth:i=0,allowsDenyReason:l=!0}){const u=g=>a(t.toolCallId,g),d=Me(),{answerAll:f,isAnswering:h,error:m}=xc(),x=c.useMemo(()=>n.map(g=>({sessionId:e,cwd:"",interaction:{type:"approval",id:g.toolCallId,startedAt:g.approvalStartedAt??0,remainingMs:g.timeoutMs??0,toolName:g.toolName,input:g.input??"",hasSuggestions:g.approvalHasSuggestions??!1}})),[n,e]);return r.jsxs(r.Fragment,{children:[n.length>=2&&r.jsx(bc,{className:"mb-1.5",headline:`${n.length} tools are waiting on you`,items:n.map(g=>({id:g.toolCallId,line:_t(g.toolName,g.input??"")})),onAllowAll:()=>void f(x,"allow"),onDenyAll:()=>void f(x,"deny"),isAnswering:h,error:m}),r.jsx(ce,{mode:"wait",initial:!1,children:r.jsx(W.div,{initial:d?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:d?sy:ny,children:t.interactiveType==="approval"?r.jsx(yo,{ref:o,sessionId:e,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input||"",isActive:!0,onDecided:u,timeoutMs:t.timeoutMs,approvalStartedAt:t.approvalStartedAt,approvalRemainingMs:t.approvalRemainingMs,approvalParked:t.approvalParked,approvalTitle:t.approvalTitle,approvalDisplayName:t.approvalDisplayName,approvalDescription:t.approvalDescription,approvalBlockedPath:t.approvalBlockedPath,approvalDecisionReason:t.approvalDecisionReason,approvalHasSuggestions:t.approvalHasSuggestions,approvalAlwaysAllowScope:t.approvalAlwaysAllowScope,allowsDenyReason:l}):t.interactiveType==="question"&&t.questions?r.jsx(vo,{ref:o,sessionId:e,toolCallId:t.toolCallId,questions:t.questions,answers:t.answers,isActive:!0,focusedOptionIndex:s,onDecided:u}):null},t.toolCallId)}),i>0&&r.jsx("p",{className:"text-muted-foreground px-1 pt-2 text-xs",children:i===1?"1 message sends once you answer.":`${i} messages send once you answer.`})]})}function 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(W.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:o=>o.preventDefault(),children:r.jsx("div",{id:"command-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?r.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No commands found."}):s.map(({namespace:o,items:a},i)=>r.jsxs("div",{children:[i>0&&r.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),r.jsx("div",{className:"text-muted-foreground/70 text-2xs px-2 pt-1.5 pb-1 font-medium tracking-wide uppercase",children:o}),a.map(({cmd:l,index:u})=>{const d=u===t,f=l.disabled===!0;return r.jsxs("div",{id:`command-item-${u}`,role:"option","aria-selected":d,"aria-disabled":f,"data-selected":d,"data-disabled":f,tabIndex:d?0:-1,onClick:()=>{f||n(l)},onKeyDown:h=>{h.key==="Enter"&&!f&&n(l)},className:f?"cursor-not-allowed rounded-md px-2 py-1.5 opacity-45":"data-[selected=true]:bg-accent hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 transition-colors duration-100",children:[r.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[r.jsx("span",{className:"text-foreground text-control shrink-0 font-mono font-medium",children:l.fullCommand}),l.argumentHint&&r.jsx("span",{className:"text-muted-foreground/50 shrink-0 font-mono text-xs",children:l.argumentHint}),f&&l.disabledReason?r.jsx("span",{className:"text-muted-foreground/70 text-2xs ml-auto shrink-0",children:l.disabledReason}):l.matchedAlias&&r.jsxs("span",{className:"text-muted-foreground/60 text-2xs ml-auto shrink-0 font-mono italic",children:["matched /",l.matchedAlias.replace(/^\//,"")]})]}),l.description&&r.jsx("p",{className:"text-muted-foreground mt-0.5 truncate text-xs leading-normal",children:l.description})]},l.fullCommand)})]},o))})})}function ay(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 iy({chatInputRef:e,input:t,autocomplete:n,steerContent:s,addContextContent:o,tryNativeCommand:a,commandPending:i,agentLookupPending:l=!1,agentLookupError:u=!1,status:d,stop:f,setInput:h,sessionId:m,sessionStatus:x,waiting:g,interaction:C,sync:b}){var ze,We;const{active:y,pendingApprovals:k,focusedOptionIndex:v,onToolRef:p,onToolDecided:_}=C,j=d==="streaming",D=ae(ve=>ve.isTextStreaming),[T]=Ao(),N=ke(),{data:A}=fs(T),S=yc(A??null,T??""),E=A?nn(A):void 0,{target:w}=Nu(),R=(w==null?void 0:w.placeholder)??"Send a message…",M=vc(m),F=nm(m),O=sn(m),L=tn(O),B=kc(m),ee=((L==null?void 0:L.supportsSteer)??!1)&&(B??!0),Q=(L==null?void 0:L.supportsContextStaging)??!1,H=((ze=L==null?void 0:L.permissionModes)==null?void 0:ze.denyReason)??!0,$=c.useCallback(async ve=>{if((w==null?void 0:w.queue)===void 0)return!1;try{return await w.queue({text:ve}),!0}catch{return!1}},[w]),P=Rb({input:t,setInput:h,sessionId:m,selectedCwd:T,waiting:g,onEnqueue:$,onSteer:s,onStage:o,tryNativeCommand:a,chatInputRef:e}),[I,V]=c.useState(null),pe=c.useRef(null),q=c.useCallback(ve=>{const xe=pe.current;if(pe.current=null,ve.length===0)return;const Re=ve.map(Ge=>xe&&Ge.id===xe.id?xe.content:Ge.content).join(`
|
|
56
|
-
|
|
57
|
-
`),Ie=se.getState().getSession(m).input.trim();h(Ie?`${Ie}
|
|
58
|
-
|
|
59
|
-
${Re}`:Re)},[m,h]),[G,re]=c.useState(null),ie=G===m&&j,oe=c.useRef(null),K=c.useCallback(()=>{oe.current=null,re(null)},[]);c.useEffect(()=>{j||K()},[j,m,K]);const ue=c.useRef(j);c.useEffect(()=>{ue.current=j},[j]);const Se=P.leaveQueueForStop,be=c.useRef(P.editingId);c.useEffect(()=>{be.current=P.editingId},[P.editingId]);const X=c.useCallback(()=>{const ve=be.current;if(ve!==null){const xe=se.getState().getSession(m).input.trim();xe&&(pe.current={id:ve,content:xe}),Se()}oe.current=m,re(m),f().then(xe=>{q(xe.cancelled),Z0(xe.receipt,ue.current)&&K();const Re=J0(xe.receipt);Re.message!==null&&!No(xe.receipt)&&(Re.isFailure?De.error(Re.message):De.warning(Re.message))}).catch(()=>{K()})},[m,f,q,K,Se]),Te=c.useCallback(()=>{if(!(oe.current===m||ie)){if(g.length===0){X();return}V({sessionId:m,queuedCount:g.length})}},[m,ie,g.length,X]),je=c.useCallback(()=>{oe.current===m||ie||(V(null),X())},[m,ie,X]);c.useEffect(()=>{(I==null?void 0:I.sessionId)===m&&g.length===0&&V(null)},[I,m,g.length]);const{messages:de}=wo(m),Ce=_o(m),J=c.useMemo(()=>za(Ce,de),[Ce,de]),Y=jb(J),te=c.useCallback(async ve=>{if(m)try{await N.stopTask(m,ve)}catch(xe){console.error("[chat] Failed to stop task:",xe)}},[m,N]),fe=c.useCallback(()=>{m&&N.switchSessionProcess(m).catch(()=>{De.error("Couldn’t switch. Try again.")})},[m,N]),he=c.useRef(t);c.useEffect(()=>{he.current=t});const ye=c.useCallback(ve=>{var Ge;const xe=he.current,Re=xe.length>0&&!/\s$/.test(xe)?" ":"",Ie=`${xe}${Re}${ve}`;h(Ie),(Ge=e.current)==null||Ge.focusAt(Ie.length)},[h,e]);c.useEffect(()=>Ku(ye),[ye]);const ge=!j&&P.editingIndex===null,Ae=$b({defaultText:R,hints:Lx,enabled:ge&&t===""}),Be=Xu(),ne=c.useCallback(()=>{n.dismissPalettes(),!(w===null||!w.canSend)&&w.send({text:t})},[n,w,t]),we=c.useCallback(()=>{n.dismissPalettes(),P.handleQueue()},[n,P]),Fe=c.useCallback(()=>{n.dismissPalettes(),P.handleSteer()},[n,P]),ft=c.useCallback(()=>{n.dismissPalettes(),P.handleStage()},[n,P]);return r.jsx(St.Composer,{className:"chat-input-container",onPathDropped:ve=>ye(Qu(ve)),inputRef:e,value:t,onChange:n.handleInputChange,onSubmit:ne,head:r.jsx(ce,{children:j&&r.jsx(yd,{color:S.color,isTextStreaming:D,edge:"top"})}),asks:y?r.jsx(ry,{sessionId:m,activeInteraction:y,pendingApprovals:k,focusedOptionIndex:v,onToolRef:p,onToolDecided:_,queueDepth:P.queue.length,allowsDenyReason:H}):null,overlays:r.jsx(r.Fragment,{children:r.jsxs(ce,{children:[n.commands.show&&r.jsx(oy,{filteredCommands:n.commands.filtered,selectedIndex:n.commands.selectedIndex,onSelect:n.handleCommandSelect}),n.files.show&&r.jsx(om,{filteredFiles:n.files.filtered,selectedIndex:n.files.selectedIndex,onSelect:n.handleFileSelect})]})}),queue:r.jsx(ce,{children:P.queue.length>0&&r.jsx(ix,{queue:P.queue,editingId:P.editingId,onEdit:P.handleQueueEdit,onRemove:P.handleQueueRemove,onSend:P.handleQueueSend,onMoveUp:P.handleQueueMoveUp,onSwitchNow:fe,statusNote:M?"Waiting for your answer above":((We=P.queue[0])==null?void 0:We.waiting)!==void 0?"Sending when the agent is free":"Sending one at a time as the agent finishes"})}),aboveInput:r.jsx(rx,{tasks:Y,onStopTask:te}),footer:r.jsx(St.Footer,{asChild:!0,children:r.jsx(Ax,{sessionId:m,sessionStatus:x,isStreaming:j,syncConnectionState:b.connectionState,agentName:E,agentColor:S.color,agentEmoji:S.emoji,agentPath:T??void 0})}),input:{isStreaming:j,commandPending:i,...l||u?{canSubmit:!1,canSubmitReason:u?"Check this folder again before you start.":"Checking this folder…"}:{},...F.canSubmit?{}:{canSubmit:!1},onStop:Te,stopPending:ie,onEscape:n.dismissPalettes,onClear:()=>{h(""),n.dismissPalettes()},isPaletteOpen:n.isPaletteOpen,paletteHasResults:n.paletteHasResults,onArrowUp:n.handleArrowUp,onArrowDown:n.handleArrowDown,onCommandSelect:n.handleKeyboardSelect,activeDescendantId:n.activeDescendantId,paletteListboxId:n.paletteListboxId,onCursorChange:n.handleCursorChange,richText:Be,editingQueueItem:P.editingIndex!==null,...P.editingIndex===null?{}:{editingPosition:P.editingIndex+1},queueDepth:P.queue.length,onQueue:we,...ee?{onSteer:Fe}:{},...Q?{onStage:ft}:{},onSaveEdit:P.handleQueueSaveEdit,onCancelEdit:P.handleQueueCancelEdit,onQueueNavigateUp:P.handleQueueNavigateUp,onQueueNavigateDown:P.handleQueueNavigateDown,queueHasItems:P.queue.length>0,contextKey:qa(m,T)??void 0,placeholder:F.placeholder??ay(P.editingIndex,j,P.queue.length,R),placeholderOverlay:ge&&F.canSubmit?r.jsx(dx,{text:Ae.text,animationKey:Ae.key}):null},children:r.jsx(lx,{open:(I==null?void 0:I.sessionId)===m,onOpenChange:ve=>{ve||V(null)},queuedCount:(I==null?void 0:I.queuedCount)??0,onConfirm:je})})}const ly=e=>{const t=e;return t.role==="user"?r.jsx($g,{message:t}):r.jsx(Tg,{message:t})};function cy(e,t){for(const n of Object.keys({...e,...t}))if(!(n==="grouping"||n==="author"||n==="feedPosition")&&!Object.is(e[n],t[n]))return!1;return e.grouping.position===t.grouping.position&&Qr(e.author,t.author)&&Qr(e.feedPosition,t.feedPosition)}function Qr(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(s=>Object.is(e[s],t[s]))}const uy=c.memo(dy,cy);function dy({message:e,grouping:t,author:n,sessionId:s,isNew:o=!1,isStreaming:a=!1,isLatestWidgetMessage:i=!0,isFinalMessage:l=!0,activeToolCallId:u=null,onToolRef:d,focusedOptionIndex:f=-1,onToolDecided:h,onRetry:m,onSigninComplete:x,onChooseModel:g,inputZoneToolCallId:C=null,textEffect:b,runtimeLabel:y,allowsDenyReason:k,directRoomId:v,feedPosition:p}){var B,ee;const _=c.useId(),j=`${_}-author`,D=`${_}-content`,T=c.useRef(null),N=t.position==="first"||t.position==="only",A=e.role==="user",S=A&&e.messageType!=="local_command_output",E=A?(B=e.chatMessages)==null?void 0:B[0]:void 0,w=A&&E===void 0?e.roomMessage:void 0,R=S&&E===void 0&&(w===void 0||((ee=w.author)==null?void 0:ee.you)===!0)&&e.messageType!=="command"&&e.messageType!=="compaction"&&e.content.trim().length>0,M=e.timestamp?Ln(e.timestamp):"",F=M.length>0,O=F?e.timestamp:void 0,L=c.useCallback(()=>{var Q;return(Q=T.current)==null?void 0:Q.focus()},[]);return r.jsx(mp,{value:{sessionId:s,isStreaming:a,isLatestWidgetMessage:i,isFinalMessage:l,activeToolCallId:u,onToolRef:d,focusedOptionIndex:f,onToolDecided:h,onRetry:m,onSigninComplete:x,onChooseModel:g,inputZoneToolCallId:C,textEffect:b,runtimeLabel:y,allowsDenyReason:k},children:r.jsxs(et.Root,{ref:T,role:S?"user":"assistant",position:t.position,isNew:o,"data-testid":"message-item","data-role":e.role,...N?{"aria-labelledby":j}:{"aria-label":F?`${n.displayName}, ${M}`:n.displayName},"aria-describedby":D,...Eu(p),children:[r.jsx(et.Gutter,{author:n,at:O}),r.jsxs(et.Body,{children:[r.jsx(et.Author,{id:j,author:n,at:O,...E?{mark:r.jsx(fa,{stamp:E}),className:"flex-wrap gap-y-0.5"}:w&&w.roomId!==v?{mark:r.jsx(Zm,{stamp:w}),className:"flex-wrap gap-y-0.5"}:{}}),r.jsx(et.Content,{id:D,children:ly(e,{rowId:e.id})}),R&&r.jsx(et.Actions,{runWith:{prompt:e.content,sessionId:s},onExit:L})]})]})})}function fy({loading:e,onLoad:t}){return r.jsx("div",{className:"flex justify-center px-4 py-3",children:r.jsxs(le,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:e,"data-testid":"session-load-earlier",className:"text-muted-foreground hover:text-foreground h-7 gap-2 text-xs",children:[e&&r.jsx(Le,{size:"xs"}),e?"Loading earlier messages…":"Earlier messages"]})})}const Xr="Conversation",my={kind:"notice",id:"session-load-earlier",at:"",body:null},py=[];function hy(e){for(let t=e.length-1;t>=0;t--)if(e[t].content.includes(Bu))return t;return-1}function gy({messages:e,sessionId:t,isLoadingHistory:n=!1,hydrated:s=!1,isTextStreaming:o=!1,activeToolCallId:a=null,onToolRef:i,focusedOptionIndex:l=-1,onToolDecided:u,onRetry:d,onSigninComplete:f,onChooseModel:h,inputZoneToolCallId:m=null,textEffect:x,runtimeLabel:g,allowsDenyReason:C,landOnRow:b,foldFirstPrompt:y=!1,directLog:k}){const v=pt(i),p=pt(u),_=pt(d),j=pt(f),D=pt(h),T=dp(t,e),N=T.messages,{stops:A}=ma(t),S=!T.canLoadEarlier,E=c.useMemo(()=>Qb(N,k,S),[N,k,S]),w=c.useMemo(()=>Qm(E.messages,A),[E.messages,A]),R=c.useMemo(()=>{let J=0;return w.map(Y=>Y._chatStop||Y._directNote?-1:J++)},[w]),M=Do(null);M.read()===null&&N.length>0&&M.write(T.messagesBefore+N.length);const F=c.useMemo(()=>hy(w),[w]),O=c.useMemo(()=>y&&!T.canLoadEarlier?w.findIndex(J=>J.role==="user"&&J.messageType===void 0&&!J._stagedContext&&!J._chatStop&&!J._directNote):-1,[y,T.canLoadEarlier,w]),L=Zt(t),B=ae(J=>J.selectedCwd),ee=sn(t),{data:Q}=fs(B),H=c.useMemo(()=>({agent:Q?{id:Q.id,displayName:nn(Q),...Et(Q)}:null,runtime:ee}),[Q,ee]),$=N[N.length-1],P=($==null?void 0:$.role)==="assistant"?$:void 0,I=zb({messageId:P==null?void 0:P.id,text:(P==null?void 0:P.content)??"",isStreaming:P!==void 0&&o}),V=kb(($==null?void 0:$.parts)??py,t),{lastSeenMessageId:pe,unreadFromStart:q,markSeen:G,isHydrated:re}=hf(t,N,T.messagesBefore),[ie,oe]=c.useState(()=>Date.now()),K=c.useRef(null);c.useLayoutEffect(()=>{const J=Date.now(),Y=new Date(J).toDateString();if(K.current===null){K.current=Y;return}K.current!==Y&&(K.current=Y,oe(J))},[w]);const ue=c.useCallback(J=>xm(J,H),[H]),[Se]=c.useState(ym),be=c.useMemo(()=>vm(w,{resolveAuthor:ue,now:ie,lastSeenMessageId:E.lastSeenBeforeUnread??pe,unreadFromStart:E.unreadFromStart||q,cache:Se}),[w,ue,ie,pe,q,E,Se]),[X]=c.useState(()=>new WeakMap),Te=c.useMemo(()=>{const J=be.map(Y=>{const te=X.get(Y);if(te)return te;const fe=Y.kind==="day-divider"?{kind:"day-divider",id:Y.key,label:Y.label}:Y.kind==="unread-divider"?{kind:"unread-divider",id:Y.key}:{kind:"message",id:Y.key,payload:Y.message,grouping:Y.grouping,author:Y.author,at:Y.message.timestamp};return X.set(Y,fe),fe});return T.canLoadEarlier?[my,...J]:J},[be,X,T.canLoadEarlier]),je=T.canLoadEarlier?1:0,de=c.useCallback((J,Y)=>{var we,Fe;if(je===1&&Y.index===0)return r.jsx(fy,{loading:T.isLoadingEarlier,onLoad:T.loadEarlier});const te=be[Y.index-je];if(te.kind==="day-divider")return r.jsx(Du,{label:te.label});if(te.kind==="unread-divider")return r.jsx(Tu,{});const{message:fe,messageIndex:he}=te;if(fe._stagedContext)return r.jsx(jp,{content:fe.content});if(fe._chatStop)return r.jsx("div",{className:"px-4 py-1",children:r.jsx(op,{notice:fe._chatStop})});if(he===O)return r.jsx($m,{content:((Fe=(we=fe.chatMessages)==null?void 0:we[0])==null?void 0:Fe.text)??fe.content});const ye=R[he]??he,ge=ye>=0&&ye===N.length-1,Ae=ge&&fe.role==="assistant",Be=F===-1||he>=F,ne=M.read();return r.jsx(uy,{message:fe,grouping:te.grouping,author:te.author,sessionId:t,directRoomId:k==null?void 0:k.roomId,isNew:ne!==null&&T.messagesBefore+ye>=ne,isStreaming:Ae&&o,isLatestWidgetMessage:Be,isFinalMessage:ge,activeToolCallId:a,onToolRef:v,focusedOptionIndex:l,onToolDecided:p,onRetry:_,onSigninComplete:j,onChooseModel:D,inputZoneToolCallId:m,textEffect:x,runtimeLabel:g,allowsDenyReason:C,feedPosition:{index:ye+1,total:N.length}})},[be,je,T.isLoadingEarlier,T.loadEarlier,T.messagesBefore,N.length,R,F,O,t,k==null?void 0:k.roomId,M,o,a,v,l,p,_,j,D,m,x,g,C]),Ce=L&&L.kind!=="first-message"&&L.fired&&!L.greetingFailed&&s?L:null;return r.jsx(St.Timeline,{conversationId:t,label:Xr,rows:Te,renderRow:de,landOn:"unread",landingReady:re&&!T.isSeeking&&((k==null?void 0:k.ready)??!0),...b===void 0?{}:{landOnRow:b},onReachedBottom:G,transcriptAnnouncement:I,approvalAnnouncement:V,className:"pt-12 [--conversation-thumb-top:3rem]",loading:n?r.jsx(Au,{label:Xr,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(la,{}),"Loading chat…"]})}):void 0,empty:r.jsx("div",{className:"flex h-full items-center justify-center",children:r.jsx(Tm,{birthRecord:L,firstLightRecord:Ce})}),"data-testid":"message-list",feedTestId:"transcript-feed"})}function xy({sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s=!1,launchSeed:o,onLaunchConsumed:a,landOnRow:i}){var Ns,Es,Ds;const[,l]=wt(),u=rs(),d=c.useRef(null),f=c.useRef(null),h=c.useCallback(()=>qb(f.current),[]),m=Xb(e),x=ob(e),g=Cc(e??""),C=tb(),{play:b}=Ic(),[y]=Ao(),{data:k,isPending:v,isError:p,refetch:_}=fs(y),{sessions:j}=Jn(),D=e!==null&&!j.some(z=>z.id===e),T=Sc(e),N=db(),A=c.useCallback(async z=>{let Ne=z;if(N.hasPendingFiles){const Ye=await N.uploadAndGetPaths(),Ts=y?Ye.map(Mt=>Mt.startsWith(y)?Mt.slice(y.length).replace(/^\//,""):Mt):Ye;Ts.length>0&&(Ne=`Please read the following uploaded file(s):
|
|
60
|
-
${Ts.map(ri=>`- ${ri}`).join(`
|
|
61
|
-
`)}
|
|
62
|
-
|
|
63
|
-
${Ne}`),N.clearFiles()}return Ne},[N,y]),S=c.useCallback(z=>{x.handleTaskEvent(z);const Ne=x.tasks.map(Ye=>Ye.id===z.task.id?{...Ye,...z.task}:Ye);C.handleTaskEvent(z,Ne)},[x,C]);c.useCallback(z=>{l(z),u.invalidateQueries({queryKey:Ve.bySession(z)})},[l,u]);const E=c.useCallback(z=>{l(z,{replace:!0}),u.invalidateQueries({queryKey:Ve.bySession(z)})},[l,u]),w=c.useCallback(z=>{l(crypto.randomUUID(),{continuedFrom:z??void 0,draft:!0})},[l]),R=So(e??""),M=tn(R.runtime),F=R.runtime?Tt(R.runtime).label:"",O=((Ns=M==null?void 0:M.permissionModes)==null?void 0:Ns.denyReason)??!0,L=c.useMemo(()=>Ma(M==null?void 0:M.commandIntents,F),[M,F]),B=c.useRef(null),ee=c.useCallback(()=>{var z;return(z=B.current)==null?void 0:z.call(B)},[]),{messages:Q,input:H,setInput:$,handleSubmit:P,submitContent:I,enqueueContent:V,steerContent:pe,addContextContent:q,status:G,error:re,stop:ie,isLoadingHistory:oe,hydrated:K,sessionStatus:ue,streamStartTime:Se,estimatedTokens:be,isTextStreaming:X,isWaitingForUser:Te,waitingType:je,activeInteraction:de,pendingInteractions:Ce,markToolCallResponded:J,systemStatus:Y,operationProgress:te,promptSuggestions:fe,syncConnectionState:he,retryMessage:ye,tryNativeCommand:ge,commandPending:Ae}=Y0(e,{transformContent:A,onTaskEvent:S,onSessionIdChangeReplace:E,startFreshSession:w,compactIntent:L,launchRuntime:t,...k&&y?{agentPath:y}:{},agentLookupPending:y!==null&&v,agentLookupFailed:y!==null&&p,takeSeedContext:ee,onStreamingDone:c.useCallback(()=>{b("turn-end"),u.invalidateQueries({queryKey:["commands"]})},[b,u])}),Be=c.useCallback(z=>I(z,{clearInput:!0}),[I]),{permissionMode:ne,permissionModeKnown:we}=Fo(e,ue,G==="streaming"),Fe=xu(e,R.runtime,we?ne:void 0),ft=_c(z=>z.setOpen);c.useEffect(()=>{ft(!1)},[e,ft]);const{handleToolRef:ze,focusedOptionIndex:We}=ab(de);ub(G,Te,X),c.useEffect(()=>{var z;(z=d.current)==null||z.focusUnlessTouch()},[e]);const ve=c.useCallback(()=>{var z;(z=d.current)==null||z.focusUnlessTouch()},[]);mb({sessionId:e,prompt:n,autoSend:s,input:H,setInput:$,messageCount:Q.length,hydrated:K,status:G,submitBlocked:D&&y!==null&&(v||p),submit:P,onSeeded:ve,onConsumed:a});const xe=xb({sessionId:e,seed:o,messageCount:Q.length,hydrated:K,onConsumed:a});c.useEffect(()=>{B.current=xe},[xe]);const Re=R.runtime?is(R.runtime):void 0,{data:Ie}=Oc(y,e??void 0,R.runtime??void 0),Ge=c.useMemo(()=>bx((Ie==null?void 0:Ie.commands)??[],{commandIntents:M==null?void 0:M.commandIntents,runtimeLabel:F}),[Ie,M,F]),{data:mt}=am(y),Wa=c.useMemo(()=>mt!=null&&mt.files?km(mt.files):[],[mt]),Ga=cb({input:H,setInput:$,commands:Ge,fileEntries:Wa}),bs=c.useCallback(()=>{const z=[...Q].reverse().find(Ne=>Ne.role==="user");z!=null&&z.content&&I(z.content)},[Q,I]),ys=Zt(e??""),Va=c.useCallback(()=>{const z=Cm(Q,ys);z&&ye(z)},[Q,ys,ye]),vs=G==="idle"&&fe.length>0&&H.length===0,Ka=jc("chat.suggestion-chips"),Qa=sm(e??""),Xa=bb(G,re,Q,Qa),Ya=c.useMemo(()=>Q.some(z=>z.role==="user"),[Q]),ks=c.useCallback(z=>{var Ne;$(z),(Ne=d.current)==null||Ne.focus()},[$]),Ja=Ro,Rt=wc(e??""),un=Eo(e??""),Za=c.useMemo(()=>Nb(Rt,un),[Rt,un]),Cs=(Ds=(Es=ds(e??""))==null?void 0:Es.lastError)==null?void 0:Ds.category,dn=Nm(),Ss=c.useCallback(()=>{const z=e??"";if(dn.claimedElsewhere(z))return!1;const Ne=_m({messages:Q,status:G,lastErrorCategory:Cs,queuedCount:Rt.length,draft:se.getState().getSession(z).input});return Ne===null?!1:(dn.claim(z),I(Ne),!0)},[Q,G,Cs,Rt.length,e,I,dn]),ei=k?`Message ${nn(k)}…`:"Send a message…",ti=ey({sessionId:e??"",placeholder:ei,submit:Be,enqueue:V,files:N}),{eligible:_s,allow:js,notNow:ws}=uf(G==="streaming"),ni=c.useMemo(()=>[{id:"prompt-suggestions",show:vs,render:()=>r.jsx(Tc,{suggestions:fe,onChipClick:ks})},{id:"permission-primer",show:_s,render:()=>r.jsx(cf,{onAllow:js,onNotNow:ws})},{id:"read-only-mode",show:Fe.eligible,render:()=>r.jsx(bu,{runtimeLabel:Fe.runtimeLabel,onShown:Fe.markShown,onDismiss:Fe.dismiss})}],[vs,fe,ks,_s,js,ws,Fe]),si=Zb({asks:Ja,status:G,streamStartTime:Se,estimatedTokens:be,permissionMode:ne,isWaitingForUser:Te??!1,waitingType:je??"approval",operationProgress:te,systemStatus:Y,activity:g});return r.jsx(St.Root,{surface:"session",capabilities:Ha,target:ti,children:r.jsxs("div",{ref:f,"data-testid":"chat-panel","data-turn-status":G,"data-turn-lifecycle":un??void 0,className:"flex h-full w-full flex-col",children:[r.jsx(Fm,{sessionId:e}),r.jsx(Im,{startedBy:T,modes:M==null?void 0:M.permissionModes.values}),r.jsx(gy,{messages:Q,sessionId:e,isLoadingHistory:oe,hydrated:K,isTextStreaming:X,activeToolCallId:(de==null?void 0:de.toolCallId)??null,onToolRef:ze,focusedOptionIndex:We,onToolDecided:J,onRetry:bs,onSigninComplete:Ss,onChooseModel:h,inputZoneToolCallId:(de==null?void 0:de.toolCallId)??null,runtimeLabel:Re,allowsDenyReason:O,...i===void 0?{}:{landOnRow:i},foldFirstPrompt:T!==null,directLog:m}),r.jsx(Ox,{terminalReason:ue==null?void 0:ue.terminalReason}),r.jsx(St.LiveLane,{state:si,scope:"session"}),r.jsx($c,{candidates:ni,ready:K,name:"session-bottom-slot",className:"px-4 pb-2"}),G==="idle"&&Ka.map(z=>r.jsx(z.component,{},z.id)),r.jsx(fp,{celebration:C.activeCelebration,onComplete:C.clearCelebration}),r.jsx(Gg,{tasks:x.tasks,taskMap:x.taskMap,activeForm:x.activeForm,isCollapsed:x.isCollapsed,onToggleCollapse:x.toggleCollapse,celebratingTaskId:C.celebratingTaskId,onCelebrationComplete:C.clearCelebration,statusTimestamps:x.statusTimestamps}),Xa&&r.jsx(Px,{sessionId:e,onRetry:Ya?bs:void 0,onSigninComplete:Ss,onChooseModel:h}),re&&r.jsx(ty,{error:re,composerAgent:k,onRetry:Va}),D&&p&&r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(on,{heading:"Couldn’t check this folder",message:"DorkOS couldn’t tell if an agent owns this folder. Try again.",onRetry:()=>void _()})}),e&&r.jsx(Yf,{sessionId:e,onSend:z=>void I(z)}),r.jsx(iy,{chatInputRef:d,input:H,autocomplete:Ga,steerContent:pe,addContextContent:q,tryNativeCommand:ge,commandPending:Ae,agentLookupPending:D&&y!==null&&v,agentLookupError:D&&y!==null&&p,status:G,stop:ie,setInput:$,sessionId:e??"",sessionStatus:ue,waiting:Za,interaction:{active:de,pendingApprovals:Ce.filter(z=>z.interactiveType==="approval"),focusedOptionIndex:We,onToolRef:ze,onToolDecided:J},sync:{connectionState:he}})]})})}function by(e,t){const n=e===null||t===void 0?null:`${e}:${t}`,s=c.useRef(null);c.useEffect(()=>{if(!(e===null||t===void 0))return s.current=`${e}:${t}`,Pe.getState().seek(e,t),()=>{const i=Pe.getState();i.seeks[e]===t&&i.endSeek(e)}},[e,t]);const o=c.useRef(null),a=c.useCallback(()=>{var d;if(n===null||o.current===n||t===void 0||e===null)return;const i=Pe.getState().seeks[e]===t;if(s.current!==n||i)return;o.current=n;const l=((d=Pe.getState().sessions[e])==null?void 0:d.earlier)??[],u=_e.getState().getSession(e).messages;return oa(da([...l,...u],t)??t)},[n,t,e]);return n===null?void 0:a}function yy(){const[e]=wt();Id(e);const{runtime:t,prompt:n,send:s,seed:o,message:a}=Zr(),i=Nc(),l=by(e,a),{data:u}=Ec(e,{enabled:!1,select:h=>h.title}),d=jo(e);od(e,{canonical:d===null}),Pc();const f=c.useCallback(()=>{i==null||i({search:h=>({...h,prompt:void 0,send:void 0,seed:void 0}),replace:!0})},[i]);return r.jsxs(r.Fragment,{children:[r.jsx(Dc,{children:u!=null&&u.trim()?u:"Chat"}),r.jsx(xy,{sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s==="1",launchSeed:o,onLaunchConsumed:f,...l===void 0?{}:{landOnRow:l}})]})}const Cv=yy;export{Cv as component};
|