@hienlh/ppm 0.23.0 → 0.23.2
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/CHANGELOG.md +15 -0
- package/CLAUDE.md +1 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/accounts-settings-section-Cs7BC5O1.js +1 -0
- package/dist/web/assets/accounts-settings-section-Cs7BC5O1.js.br +0 -0
- package/dist/web/assets/accounts-settings-section-Cs7BC5O1.js.gz +0 -0
- package/dist/web/assets/{ai-resource-editor-DoCiQDKY.js → ai-resource-editor-TCREp5Ml.js} +1 -1
- package/dist/web/assets/ai-resource-editor-TCREp5Ml.js.br +0 -0
- package/dist/web/assets/ai-resource-editor-TCREp5Ml.js.gz +0 -0
- package/dist/web/assets/{ai-settings-section-0x6GFJ56.js → ai-settings-section-B7Un4KiW.js} +1 -1
- package/dist/web/assets/ai-settings-section-B7Un4KiW.js.br +0 -0
- package/dist/web/assets/ai-settings-section-B7Un4KiW.js.gz +0 -0
- package/dist/web/assets/{ai-settings-section-Cp6jcnTn.js → ai-settings-section-BlKlcihJ.js} +1 -1
- package/dist/web/assets/{appearance-settings-section-mRiGj3_g.js → appearance-settings-section-DACtiDor.js} +1 -1
- package/dist/web/assets/appearance-settings-section-DACtiDor.js.br +0 -0
- package/dist/web/assets/appearance-settings-section-DACtiDor.js.gz +0 -0
- package/dist/web/assets/{audio-preview-CO7Ia2N5.js → audio-preview-DXtE1Lpz.js} +1 -1
- package/dist/web/assets/audio-preview-DXtE1Lpz.js.br +0 -0
- package/dist/web/assets/audio-preview-DXtE1Lpz.js.gz +0 -0
- package/dist/web/assets/{branch-review-tab-F3CALiEa.js → branch-review-tab-vHJuFXtB.js} +1 -1
- package/dist/web/assets/branch-review-tab-vHJuFXtB.js.br +0 -0
- package/dist/web/assets/branch-review-tab-vHJuFXtB.js.gz +0 -0
- package/dist/web/assets/chat-tab-Ba3NvUgt.js +1 -0
- package/dist/web/assets/chat-tab-Ba3NvUgt.js.br +0 -0
- package/dist/web/assets/chat-tab-Ba3NvUgt.js.gz +0 -0
- package/dist/web/assets/chat-tab-DeISufm0.js +15 -0
- package/dist/web/assets/chat-tab-DeISufm0.js.br +0 -0
- package/dist/web/assets/chat-tab-DeISufm0.js.gz +0 -0
- package/dist/web/assets/{code-editor-FsR6KpZa.js → code-editor-BCwiLVyc.js} +3 -3
- package/dist/web/assets/code-editor-BCwiLVyc.js.br +0 -0
- package/dist/web/assets/code-editor-BCwiLVyc.js.gz +0 -0
- package/dist/web/assets/codex-sign-in-again-dialog-DcIOYhAe.js +1 -0
- package/dist/web/assets/codex-sign-in-again-dialog-DcIOYhAe.js.br +0 -0
- package/dist/web/assets/codex-sign-in-again-dialog-DcIOYhAe.js.gz +0 -0
- package/dist/web/assets/{conflict-editor-GGqIz6tt.js → conflict-editor-0YEDQ--c.js} +1 -1
- package/dist/web/assets/conflict-editor-0YEDQ--c.js.br +0 -0
- package/dist/web/assets/conflict-editor-0YEDQ--c.js.gz +0 -0
- package/dist/web/assets/{context-menu-CVO3HtIt.js → context-menu-CjYTq8DI.js} +1 -1
- package/dist/web/assets/context-menu-CjYTq8DI.js.br +0 -0
- package/dist/web/assets/context-menu-CjYTq8DI.js.gz +0 -0
- package/dist/web/assets/{csv-preview-ycnxJ_6J.js → csv-preview-CYxznB1I.js} +1 -1
- package/dist/web/assets/csv-preview-CYxznB1I.js.br +0 -0
- package/dist/web/assets/csv-preview-CYxznB1I.js.gz +0 -0
- package/dist/web/assets/{database-viewer-y6URJv8N.js → database-viewer-eP3gCxGb.js} +1 -1
- package/dist/web/assets/database-viewer-eP3gCxGb.js.br +0 -0
- package/dist/web/assets/database-viewer-eP3gCxGb.js.gz +0 -0
- package/dist/web/assets/{design-responsive-dialog-D0QYfX7v.js → design-responsive-dialog-CcJETHO2.js} +1 -1
- package/dist/web/assets/design-responsive-dialog-CcJETHO2.js.br +0 -0
- package/dist/web/assets/design-responsive-dialog-CcJETHO2.js.gz +0 -0
- package/dist/web/assets/{design-tab-DgCTcwot.js → design-tab-B7aVMMfj.js} +1 -1
- package/dist/web/assets/design-tab-B7aVMMfj.js.br +0 -0
- package/dist/web/assets/design-tab-B7aVMMfj.js.gz +0 -0
- package/dist/web/assets/{designs-sidebar-panel-Dtuph5jh.js → designs-sidebar-panel-8KI79o1u.js} +1 -1
- package/dist/web/assets/designs-sidebar-panel-8KI79o1u.js.br +0 -0
- package/dist/web/assets/designs-sidebar-panel-8KI79o1u.js.gz +0 -0
- package/dist/web/assets/{dialog-CaShS4f5.js → dialog-tzBRkGeW.js} +1 -1
- package/dist/web/assets/dialog-tzBRkGeW.js.br +0 -0
- package/dist/web/assets/dialog-tzBRkGeW.js.gz +0 -0
- package/dist/web/assets/{diff-viewer-ciBkExM7.js → diff-viewer-B_K7VQup.js} +1 -1
- package/dist/web/assets/diff-viewer-B_K7VQup.js.br +0 -0
- package/dist/web/assets/diff-viewer-B_K7VQup.js.gz +0 -0
- package/dist/web/assets/{docx-preview-C8K6QzOW.js → docx-preview-C-UKGMXR.js} +1 -1
- package/dist/web/assets/docx-preview-C-UKGMXR.js.br +0 -0
- package/dist/web/assets/docx-preview-C-UKGMXR.js.gz +0 -0
- package/dist/web/assets/{editor-language-service-CkoaAHjF.js → editor-language-service-DYBxZX66.js} +1 -1
- package/dist/web/assets/editor-language-service-DYBxZX66.js.br +0 -0
- package/dist/web/assets/editor-language-service-DYBxZX66.js.gz +0 -0
- package/dist/web/assets/{explorer-body-C5gXPGOl.js → explorer-body-C0syNltJ.js} +1 -1
- package/dist/web/assets/explorer-body-C0syNltJ.js.br +0 -0
- package/dist/web/assets/explorer-body-C0syNltJ.js.gz +0 -0
- package/dist/web/assets/{explorer-window-content-8EBl9Vkx.js → explorer-window-content-CfIomwTq.js} +1 -1
- package/dist/web/assets/explorer-window-content-CfIomwTq.js.br +0 -0
- package/dist/web/assets/explorer-window-content-CfIomwTq.js.gz +0 -0
- package/dist/web/assets/{extension-manager-section-DOwZYx8O.js → extension-manager-section-CL7pl3re.js} +1 -1
- package/dist/web/assets/extension-manager-section-CL7pl3re.js.br +0 -0
- package/dist/web/assets/extension-manager-section-CL7pl3re.js.gz +0 -0
- package/dist/web/assets/{extension-webview-CdEva8pD.js → extension-webview-FHTB0jh1.js} +1 -1
- package/dist/web/assets/extension-webview-FHTB0jh1.js.br +0 -0
- package/dist/web/assets/extension-webview-FHTB0jh1.js.gz +0 -0
- package/dist/web/assets/{files-settings-section-DVemQIZ2.js → files-settings-section-C574RfCl.js} +1 -1
- package/dist/web/assets/files-settings-section-C574RfCl.js.br +0 -0
- package/dist/web/assets/files-settings-section-C574RfCl.js.gz +0 -0
- package/dist/web/assets/{general-settings-section-DiY_5C93.js → general-settings-section--DSUTrEP.js} +1 -1
- package/dist/web/assets/general-settings-section--DSUTrEP.js.br +0 -0
- package/dist/web/assets/general-settings-section--DSUTrEP.js.gz +0 -0
- package/dist/web/assets/{git-log-panel-Cq0WohOO.js → git-log-panel-BzwEbRwN.js} +1 -1
- package/dist/web/assets/git-log-panel-BzwEbRwN.js.br +0 -0
- package/dist/web/assets/git-log-panel-BzwEbRwN.js.gz +0 -0
- package/dist/web/assets/{glide-data-grid-DG9AnCmP.js → glide-data-grid-CUNWBFfN.js} +1 -1
- package/dist/web/assets/glide-data-grid-CUNWBFfN.js.br +0 -0
- package/dist/web/assets/glide-data-grid-CUNWBFfN.js.gz +0 -0
- package/dist/web/assets/{group-chat-tab-DxbDrFJl.js → group-chat-tab-Dp1p4Jdu.js} +1 -1
- package/dist/web/assets/group-chat-tab-Dp1p4Jdu.js.br +0 -0
- package/dist/web/assets/group-chat-tab-Dp1p4Jdu.js.gz +0 -0
- package/dist/web/assets/icons-CO_II6D-.js +1 -0
- package/dist/web/assets/icons-CO_II6D-.js.br +0 -0
- package/dist/web/assets/icons-CO_II6D-.js.gz +0 -0
- package/dist/web/assets/{image-preview-eAv91-an.js → image-preview-78Fguk1f.js} +1 -1
- package/dist/web/assets/{index-BVKT5UCu.js → index-CvUGUp7d.js} +6 -6
- package/dist/web/assets/index-CvUGUp7d.js.br +0 -0
- package/dist/web/assets/index-CvUGUp7d.js.gz +0 -0
- package/dist/web/assets/index-DMA-So69.css +1 -0
- package/dist/web/assets/index-DMA-So69.css.br +0 -0
- package/dist/web/assets/index-DMA-So69.css.gz +0 -0
- package/dist/web/assets/{jira-watcher-section-Cr8gSVGY.js → jira-watcher-section-DoXl0GAq.js} +1 -1
- package/dist/web/assets/jira-watcher-section-DoXl0GAq.js.br +0 -0
- package/dist/web/assets/jira-watcher-section-DoXl0GAq.js.gz +0 -0
- package/dist/web/assets/{keybindings-store-Ch1mWz0q.js → keybindings-store-BqGm9AgI.js} +1 -1
- package/dist/web/assets/{keyboard-shortcuts-section-BvC6m_C2.js → keyboard-shortcuts-section-BogwnAdr.js} +1 -1
- package/dist/web/assets/keyboard-shortcuts-section-BogwnAdr.js.br +0 -0
- package/dist/web/assets/keyboard-shortcuts-section-BogwnAdr.js.gz +0 -0
- package/dist/web/assets/{markdown-renderer-56wMzGkr.js → markdown-renderer-C33dsNJ_.js} +1 -1
- package/dist/web/assets/{markdown-renderer-8JlfrfnD.js → markdown-renderer-CZiECUJp.js} +1 -1
- package/dist/web/assets/markdown-renderer-CZiECUJp.js.br +0 -0
- package/dist/web/assets/markdown-renderer-CZiECUJp.js.gz +0 -0
- package/dist/web/assets/{mobile-explorer-sheet-cJfocgE7.js → mobile-explorer-sheet-BOgo9tbK.js} +1 -1
- package/dist/web/assets/mobile-explorer-sheet-BOgo9tbK.js.br +0 -0
- package/dist/web/assets/mobile-explorer-sheet-BOgo9tbK.js.gz +0 -0
- package/dist/web/assets/{new-design-dialog-BO_D3nex.js → new-design-dialog-DcoejI1s.js} +1 -1
- package/dist/web/assets/new-design-dialog-DcoejI1s.js.br +0 -0
- package/dist/web/assets/new-design-dialog-DcoejI1s.js.gz +0 -0
- package/dist/web/assets/{notification-store-DNWazI7j.js → notification-store-D88Y9kF_.js} +1 -1
- package/dist/web/assets/{notifications-settings-section-DaMh3khs.js → notifications-settings-section-Bfxqz65i.js} +1 -1
- package/dist/web/assets/notifications-settings-section-Bfxqz65i.js.br +0 -0
- package/dist/web/assets/notifications-settings-section-Bfxqz65i.js.gz +0 -0
- package/dist/web/assets/{onboarding-entry-CwkNJ69U.js → onboarding-entry-CcvySZ_l.js} +1 -1
- package/dist/web/assets/onboarding-entry-CcvySZ_l.js.br +0 -0
- package/dist/web/assets/onboarding-entry-CcvySZ_l.js.gz +0 -0
- package/dist/web/assets/{onboarding-quick-orientation-u7yM68d3.js → onboarding-quick-orientation-CT4PylG0.js} +1 -1
- package/dist/web/assets/onboarding-quick-orientation-CT4PylG0.js.br +0 -0
- package/dist/web/assets/onboarding-quick-orientation-CT4PylG0.js.gz +0 -0
- package/dist/web/assets/{pdf-preview-CaxTidh0.js → pdf-preview-BWim6mu1.js} +1 -1
- package/dist/web/assets/pdf-preview-BWim6mu1.js.br +0 -0
- package/dist/web/assets/pdf-preview-BWim6mu1.js.gz +0 -0
- package/dist/web/assets/{postgres-viewer-CJOOLdgO.js → postgres-viewer-HwlL1UTJ.js} +1 -1
- package/dist/web/assets/postgres-viewer-HwlL1UTJ.js.br +0 -0
- package/dist/web/assets/postgres-viewer-HwlL1UTJ.js.gz +0 -0
- package/dist/web/assets/{ppmbot-settings-section-rNBdWG7F.js → ppmbot-settings-section-DF0kqdyO.js} +1 -1
- package/dist/web/assets/ppmbot-settings-section-DF0kqdyO.js.br +0 -0
- package/dist/web/assets/ppmbot-settings-section-DF0kqdyO.js.gz +0 -0
- package/dist/web/assets/{problems-panel-BTmOGMcL.js → problems-panel-DRcq5ChN.js} +1 -1
- package/dist/web/assets/problems-panel-DRcq5ChN.js.br +0 -0
- package/dist/web/assets/problems-panel-DRcq5ChN.js.gz +0 -0
- package/dist/web/assets/{process-table-Bc9WEBsS.js → process-table-Ds0S_YK-.js} +1 -1
- package/dist/web/assets/process-table-Ds0S_YK-.js.br +0 -0
- package/dist/web/assets/process-table-Ds0S_YK-.js.gz +0 -0
- package/dist/web/assets/{proxy-settings-section-Bo-FPk6Y.js → proxy-settings-section-Q-ttqVOa.js} +1 -1
- package/dist/web/assets/proxy-settings-section-Q-ttqVOa.js.br +0 -0
- package/dist/web/assets/proxy-settings-section-Q-ttqVOa.js.gz +0 -0
- package/dist/web/assets/{query-audit-section-CQfzKAf9.js → query-audit-section-Cn11xqgz.js} +1 -1
- package/dist/web/assets/query-audit-section-Cn11xqgz.js.br +0 -0
- package/dist/web/assets/query-audit-section-Cn11xqgz.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-clipboard-notice-DgeuoZ4n.js → remote-desktop-clipboard-notice-CvPPtrRq.js} +1 -1
- package/dist/web/assets/remote-desktop-clipboard-notice-CvPPtrRq.js.br +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-CvPPtrRq.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-mobile-sheet-BpP7jI0p.js → remote-desktop-mobile-sheet-B-TT9Fdt.js} +2 -2
- package/dist/web/assets/remote-desktop-mobile-sheet-B-TT9Fdt.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-B-TT9Fdt.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-mobile-view-Byn0lFCF.js → remote-desktop-mobile-view-hUnYxXDk.js} +1 -1
- package/dist/web/assets/remote-desktop-mobile-view-hUnYxXDk.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-hUnYxXDk.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-readiness-gate-B2mXZ9vo.js → remote-desktop-readiness-gate-CUmaeiX9.js} +1 -1
- package/dist/web/assets/remote-desktop-readiness-gate-CUmaeiX9.js.br +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-CUmaeiX9.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-window-content-CWt3VVjm.js → remote-desktop-window-content-DEPUOOGw.js} +1 -1
- package/dist/web/assets/remote-desktop-window-content-DEPUOOGw.js.br +0 -0
- package/dist/web/assets/remote-desktop-window-content-DEPUOOGw.js.gz +0 -0
- package/dist/web/assets/{schedules-settings-section-Bx9Rm-NB.js → schedules-settings-section-Bv_wrzDp.js} +1 -1
- package/dist/web/assets/schedules-settings-section-Bv_wrzDp.js.br +0 -0
- package/dist/web/assets/schedules-settings-section-Bv_wrzDp.js.gz +0 -0
- package/dist/web/assets/{settings-body-DU3LZkOy.js → settings-body-C5_chEpq.js} +2 -2
- package/dist/web/assets/settings-body-C5_chEpq.js.br +0 -0
- package/dist/web/assets/settings-body-C5_chEpq.js.gz +0 -0
- package/dist/web/assets/{settings-tab-Q5Ai_XB7.js → settings-tab-CogpEbq5.js} +1 -1
- package/dist/web/assets/{settings-window-content-DNg-jjm4.js → settings-window-content-BNRirQDZ.js} +1 -1
- package/dist/web/assets/{sql-query-editor-BMNsmnfi.js → sql-query-editor-Bg3lOrmt.js} +1 -1
- package/dist/web/assets/sql-query-editor-Bg3lOrmt.js.br +0 -0
- package/dist/web/assets/sql-query-editor-Bg3lOrmt.js.gz +0 -0
- package/dist/web/assets/{sqlite-viewer-DBdxQgCD.js → sqlite-viewer-DMKtDkI6.js} +1 -1
- package/dist/web/assets/sqlite-viewer-DMKtDkI6.js.br +0 -0
- package/dist/web/assets/sqlite-viewer-DMKtDkI6.js.gz +0 -0
- package/dist/web/assets/{system-monitor-body-BEuqhoiF.js → system-monitor-body-Dst39LA7.js} +2 -2
- package/dist/web/assets/system-monitor-body-Dst39LA7.js.br +0 -0
- package/dist/web/assets/system-monitor-body-Dst39LA7.js.gz +0 -0
- package/dist/web/assets/system-monitor-tab-CEwME1_C.js +1 -0
- package/dist/web/assets/{system-monitor-window-content-Dr6EgqpJ.js → system-monitor-window-content-DQRBjn9z.js} +1 -1
- package/dist/web/assets/{tab-host-window-content-BhS39QWy.js → tab-host-window-content-Dlunzrfh.js} +1 -1
- package/dist/web/assets/tab-host-window-content-Dlunzrfh.js.br +0 -0
- package/dist/web/assets/tab-host-window-content-Dlunzrfh.js.gz +0 -0
- package/dist/web/assets/{team-member-sheet-C5-PeHDb.js → team-member-sheet-CPZGU9j5.js} +2 -2
- package/dist/web/assets/team-member-sheet-CPZGU9j5.js.br +0 -0
- package/dist/web/assets/team-member-sheet-CPZGU9j5.js.gz +0 -0
- package/dist/web/assets/{team-member-window-content-CZjHuvdw.js → team-member-window-content-CwI9JD_H.js} +1 -1
- package/dist/web/assets/{team-member-window-content-CZjHuvdw.js.br → team-member-window-content-CwI9JD_H.js.br} +0 -0
- package/dist/web/assets/team-member-window-content-CwI9JD_H.js.gz +0 -0
- package/dist/web/assets/{terminal-tab-B0w7Jsbs.js → terminal-tab-BcQXleSa.js} +1 -1
- package/dist/web/assets/terminal-tab-BcQXleSa.js.br +0 -0
- package/dist/web/assets/terminal-tab-BcQXleSa.js.gz +0 -0
- package/dist/web/assets/{tool-cards-CmdjXi2c.js → tool-cards-DsQdMorI.js} +2 -2
- package/dist/web/assets/tool-cards-DsQdMorI.js.br +0 -0
- package/dist/web/assets/tool-cards-DsQdMorI.js.gz +0 -0
- package/dist/web/assets/{use-inline-blame-BSb807l9.js → use-inline-blame--fS-pzzX.js} +1 -1
- package/dist/web/assets/use-inline-blame--fS-pzzX.js.br +0 -0
- package/dist/web/assets/use-inline-blame--fS-pzzX.js.gz +0 -0
- package/dist/web/assets/{use-lsp-DhBjkGWr.js → use-lsp-DK26Eter.js} +1 -1
- package/dist/web/assets/use-lsp-DK26Eter.js.br +0 -0
- package/dist/web/assets/use-lsp-DK26Eter.js.gz +0 -0
- package/dist/web/assets/{use-monaco-theme-CNEk66US.js → use-monaco-theme-BVatH9yZ.js} +1 -1
- package/dist/web/assets/{use-websocket-Bki-B4fj.js → use-websocket-C1mloX0R.js} +1 -1
- package/dist/web/assets/{video-preview-T1SMFp03.js → video-preview-C48Go7JZ.js} +1 -1
- package/dist/web/assets/video-preview-C48Go7JZ.js.br +0 -0
- package/dist/web/assets/video-preview-C48Go7JZ.js.gz +0 -0
- package/dist/web/index.html +6 -6
- package/dist/web/index.html.br +0 -0
- package/dist/web/index.html.gz +0 -0
- package/dist/web/sw.js +1 -1
- package/dist/web/sw.js.br +0 -0
- package/dist/web/sw.js.gz +0 -0
- package/package.json +1 -1
- package/src/providers/codex-app-server/codex-auth-failure.ts +51 -0
- package/src/providers/codex-app-server/codex-event-mapper.ts +8 -0
- package/src/providers/codex-app-server/codex-provider.ts +97 -19
- package/src/providers/codex-app-server/codex-usage-source.ts +14 -1
- package/src/server/routes/codex-accounts.ts +18 -6
- package/src/services/codex-account-auth-state.ts +58 -0
- package/src/services/codex-account-login.ts +42 -9
- package/src/services/codex-account.service.ts +42 -7
- package/src/services/proxy-agent-anthropic-bridge.ts +2 -2
- package/src/services/proxy-agent-bridge.ts +2 -2
- package/src/services/proxy-agent-turn.ts +80 -20
- package/src/services/proxy-image-bridge.ts +3 -3
- package/src/services/proxy.service.ts +1 -1
- package/src/web/components/chat/codex-usage-panel.tsx +13 -1
- package/src/web/components/chat/usage-badge.tsx +14 -0
- package/src/web/components/settings/accounts/account-add-dialog.tsx +10 -3
- package/src/web/components/settings/accounts/account-card.tsx +15 -4
- package/src/web/components/settings/accounts/account-hint.tsx +19 -2
- package/src/web/components/settings/accounts/claude-accounts-section.tsx +10 -2
- package/src/web/components/settings/accounts/codex-accounts-section.tsx +18 -2
- package/src/web/components/settings/accounts/codex-add-account-dialog.tsx +50 -33
- package/src/web/components/settings/accounts/codex-sign-in-again-dialog.tsx +47 -0
- package/src/web/components/settings/accounts/use-codex-accounts.ts +18 -4
- package/src/web/lib/fluent-icon.tsx +38 -2
- package/dist/web/assets/accounts-settings-section-CVJ7hQom.js +0 -1
- package/dist/web/assets/accounts-settings-section-CVJ7hQom.js.br +0 -0
- package/dist/web/assets/accounts-settings-section-CVJ7hQom.js.gz +0 -0
- package/dist/web/assets/ai-resource-editor-DoCiQDKY.js.br +0 -0
- package/dist/web/assets/ai-resource-editor-DoCiQDKY.js.gz +0 -0
- package/dist/web/assets/ai-settings-section-0x6GFJ56.js.br +0 -0
- package/dist/web/assets/ai-settings-section-0x6GFJ56.js.gz +0 -0
- package/dist/web/assets/appearance-settings-section-mRiGj3_g.js.br +0 -0
- package/dist/web/assets/appearance-settings-section-mRiGj3_g.js.gz +0 -0
- package/dist/web/assets/audio-preview-CO7Ia2N5.js.br +0 -0
- package/dist/web/assets/audio-preview-CO7Ia2N5.js.gz +0 -0
- package/dist/web/assets/branch-review-tab-F3CALiEa.js.br +0 -0
- package/dist/web/assets/branch-review-tab-F3CALiEa.js.gz +0 -0
- package/dist/web/assets/chat-tab-D6BFnkCj.js +0 -1
- package/dist/web/assets/chat-tab-D6BFnkCj.js.br +0 -0
- package/dist/web/assets/chat-tab-D6BFnkCj.js.gz +0 -0
- package/dist/web/assets/chat-tab-IXHMUKMW.js +0 -15
- package/dist/web/assets/chat-tab-IXHMUKMW.js.br +0 -0
- package/dist/web/assets/chat-tab-IXHMUKMW.js.gz +0 -0
- package/dist/web/assets/code-editor-FsR6KpZa.js.br +0 -0
- package/dist/web/assets/code-editor-FsR6KpZa.js.gz +0 -0
- package/dist/web/assets/codex-daily-guard-Bn8jfcei.js +0 -1
- package/dist/web/assets/codex-daily-guard-Bn8jfcei.js.br +0 -0
- package/dist/web/assets/codex-daily-guard-Bn8jfcei.js.gz +0 -0
- package/dist/web/assets/conflict-editor-GGqIz6tt.js.br +0 -0
- package/dist/web/assets/conflict-editor-GGqIz6tt.js.gz +0 -0
- package/dist/web/assets/context-menu-CVO3HtIt.js.br +0 -0
- package/dist/web/assets/context-menu-CVO3HtIt.js.gz +0 -0
- package/dist/web/assets/csv-preview-ycnxJ_6J.js.br +0 -0
- package/dist/web/assets/csv-preview-ycnxJ_6J.js.gz +0 -0
- package/dist/web/assets/database-viewer-y6URJv8N.js.br +0 -0
- package/dist/web/assets/database-viewer-y6URJv8N.js.gz +0 -0
- package/dist/web/assets/design-responsive-dialog-D0QYfX7v.js.br +0 -0
- package/dist/web/assets/design-responsive-dialog-D0QYfX7v.js.gz +0 -0
- package/dist/web/assets/design-tab-DgCTcwot.js.br +0 -0
- package/dist/web/assets/design-tab-DgCTcwot.js.gz +0 -0
- package/dist/web/assets/designs-sidebar-panel-Dtuph5jh.js.br +0 -0
- package/dist/web/assets/designs-sidebar-panel-Dtuph5jh.js.gz +0 -0
- package/dist/web/assets/dialog-CaShS4f5.js.br +0 -0
- package/dist/web/assets/dialog-CaShS4f5.js.gz +0 -0
- package/dist/web/assets/diff-viewer-ciBkExM7.js.br +0 -0
- package/dist/web/assets/diff-viewer-ciBkExM7.js.gz +0 -0
- package/dist/web/assets/docx-preview-C8K6QzOW.js.br +0 -0
- package/dist/web/assets/docx-preview-C8K6QzOW.js.gz +0 -0
- package/dist/web/assets/editor-language-service-CkoaAHjF.js.br +0 -0
- package/dist/web/assets/editor-language-service-CkoaAHjF.js.gz +0 -0
- package/dist/web/assets/explorer-body-C5gXPGOl.js.br +0 -0
- package/dist/web/assets/explorer-body-C5gXPGOl.js.gz +0 -0
- package/dist/web/assets/explorer-window-content-8EBl9Vkx.js.br +0 -0
- package/dist/web/assets/explorer-window-content-8EBl9Vkx.js.gz +0 -0
- package/dist/web/assets/extension-manager-section-DOwZYx8O.js.br +0 -0
- package/dist/web/assets/extension-manager-section-DOwZYx8O.js.gz +0 -0
- package/dist/web/assets/extension-webview-CdEva8pD.js.br +0 -0
- package/dist/web/assets/extension-webview-CdEva8pD.js.gz +0 -0
- package/dist/web/assets/files-settings-section-DVemQIZ2.js.br +0 -0
- package/dist/web/assets/files-settings-section-DVemQIZ2.js.gz +0 -0
- package/dist/web/assets/general-settings-section-DiY_5C93.js.br +0 -0
- package/dist/web/assets/general-settings-section-DiY_5C93.js.gz +0 -0
- package/dist/web/assets/git-log-panel-Cq0WohOO.js.br +0 -0
- package/dist/web/assets/git-log-panel-Cq0WohOO.js.gz +0 -0
- package/dist/web/assets/glide-data-grid-DG9AnCmP.js.br +0 -0
- package/dist/web/assets/glide-data-grid-DG9AnCmP.js.gz +0 -0
- package/dist/web/assets/group-chat-tab-DxbDrFJl.js.br +0 -0
- package/dist/web/assets/group-chat-tab-DxbDrFJl.js.gz +0 -0
- package/dist/web/assets/icons-C9ZwXgel.js +0 -1
- package/dist/web/assets/icons-C9ZwXgel.js.br +0 -0
- package/dist/web/assets/icons-C9ZwXgel.js.gz +0 -0
- package/dist/web/assets/index-BVKT5UCu.js.br +0 -0
- package/dist/web/assets/index-BVKT5UCu.js.gz +0 -0
- package/dist/web/assets/index-CzYrKDUF.css +0 -1
- package/dist/web/assets/index-CzYrKDUF.css.br +0 -0
- package/dist/web/assets/index-CzYrKDUF.css.gz +0 -0
- package/dist/web/assets/jira-watcher-section-Cr8gSVGY.js.br +0 -0
- package/dist/web/assets/jira-watcher-section-Cr8gSVGY.js.gz +0 -0
- package/dist/web/assets/keyboard-shortcuts-section-BvC6m_C2.js.br +0 -0
- package/dist/web/assets/keyboard-shortcuts-section-BvC6m_C2.js.gz +0 -0
- package/dist/web/assets/markdown-renderer-8JlfrfnD.js.br +0 -0
- package/dist/web/assets/markdown-renderer-8JlfrfnD.js.gz +0 -0
- package/dist/web/assets/mobile-explorer-sheet-cJfocgE7.js.br +0 -0
- package/dist/web/assets/mobile-explorer-sheet-cJfocgE7.js.gz +0 -0
- package/dist/web/assets/new-design-dialog-BO_D3nex.js.br +0 -0
- package/dist/web/assets/new-design-dialog-BO_D3nex.js.gz +0 -0
- package/dist/web/assets/notifications-settings-section-DaMh3khs.js.br +0 -0
- package/dist/web/assets/notifications-settings-section-DaMh3khs.js.gz +0 -0
- package/dist/web/assets/onboarding-entry-CwkNJ69U.js.br +0 -0
- package/dist/web/assets/onboarding-entry-CwkNJ69U.js.gz +0 -0
- package/dist/web/assets/onboarding-quick-orientation-u7yM68d3.js.br +0 -0
- package/dist/web/assets/onboarding-quick-orientation-u7yM68d3.js.gz +0 -0
- package/dist/web/assets/pdf-preview-CaxTidh0.js.br +0 -0
- package/dist/web/assets/pdf-preview-CaxTidh0.js.gz +0 -0
- package/dist/web/assets/postgres-viewer-CJOOLdgO.js.br +0 -0
- package/dist/web/assets/postgres-viewer-CJOOLdgO.js.gz +0 -0
- package/dist/web/assets/ppmbot-settings-section-rNBdWG7F.js.br +0 -0
- package/dist/web/assets/ppmbot-settings-section-rNBdWG7F.js.gz +0 -0
- package/dist/web/assets/problems-panel-BTmOGMcL.js.br +0 -0
- package/dist/web/assets/problems-panel-BTmOGMcL.js.gz +0 -0
- package/dist/web/assets/process-table-Bc9WEBsS.js.br +0 -0
- package/dist/web/assets/process-table-Bc9WEBsS.js.gz +0 -0
- package/dist/web/assets/proxy-settings-section-Bo-FPk6Y.js.br +0 -0
- package/dist/web/assets/proxy-settings-section-Bo-FPk6Y.js.gz +0 -0
- package/dist/web/assets/query-audit-section-CQfzKAf9.js.br +0 -0
- package/dist/web/assets/query-audit-section-CQfzKAf9.js.gz +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-DgeuoZ4n.js.br +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-DgeuoZ4n.js.gz +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-BpP7jI0p.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-BpP7jI0p.js.gz +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-Byn0lFCF.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-Byn0lFCF.js.gz +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-B2mXZ9vo.js.br +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-B2mXZ9vo.js.gz +0 -0
- package/dist/web/assets/remote-desktop-window-content-CWt3VVjm.js.br +0 -0
- package/dist/web/assets/remote-desktop-window-content-CWt3VVjm.js.gz +0 -0
- package/dist/web/assets/schedules-settings-section-Bx9Rm-NB.js.br +0 -0
- package/dist/web/assets/schedules-settings-section-Bx9Rm-NB.js.gz +0 -0
- package/dist/web/assets/settings-body-DU3LZkOy.js.br +0 -0
- package/dist/web/assets/settings-body-DU3LZkOy.js.gz +0 -0
- package/dist/web/assets/sql-query-editor-BMNsmnfi.js.br +0 -0
- package/dist/web/assets/sql-query-editor-BMNsmnfi.js.gz +0 -0
- package/dist/web/assets/sqlite-viewer-DBdxQgCD.js.br +0 -0
- package/dist/web/assets/sqlite-viewer-DBdxQgCD.js.gz +0 -0
- package/dist/web/assets/system-monitor-body-BEuqhoiF.js.br +0 -0
- package/dist/web/assets/system-monitor-body-BEuqhoiF.js.gz +0 -0
- package/dist/web/assets/system-monitor-tab-BAU1kzbY.js +0 -1
- package/dist/web/assets/tab-host-window-content-BhS39QWy.js.br +0 -0
- package/dist/web/assets/tab-host-window-content-BhS39QWy.js.gz +0 -0
- package/dist/web/assets/team-member-sheet-C5-PeHDb.js.br +0 -0
- package/dist/web/assets/team-member-sheet-C5-PeHDb.js.gz +0 -0
- package/dist/web/assets/team-member-window-content-CZjHuvdw.js.gz +0 -0
- package/dist/web/assets/terminal-tab-B0w7Jsbs.js.br +0 -0
- package/dist/web/assets/terminal-tab-B0w7Jsbs.js.gz +0 -0
- package/dist/web/assets/tool-cards-CmdjXi2c.js.br +0 -0
- package/dist/web/assets/tool-cards-CmdjXi2c.js.gz +0 -0
- package/dist/web/assets/use-inline-blame-BSb807l9.js.br +0 -0
- package/dist/web/assets/use-inline-blame-BSb807l9.js.gz +0 -0
- package/dist/web/assets/use-lsp-DhBjkGWr.js.br +0 -0
- package/dist/web/assets/use-lsp-DhBjkGWr.js.gz +0 -0
- package/dist/web/assets/video-preview-T1SMFp03.js.br +0 -0
- package/dist/web/assets/video-preview-T1SMFp03.js.gz +0 -0
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/edit-diff-preview-8nIct7kS.js","assets/rolldown-runtime-C5c2KzVm.js","assets/vendor-markdown-QKPNiWEd.js","assets/libesm-DMnQ3WlF.js","assets/markdown-renderer-56wMzGkr.js","assets/vendor-mermaid-eg2XWIjK.js","assets/vendor-ui-BHh12_0v.js","assets/markdown-renderer-8JlfrfnD.js","assets/index-BVKT5UCu.js","assets/button-CBehaXpV.js","assets/utils-btZ8C8-R.js","assets/createLucideIcon-DBXq3G0e.js","assets/api-client-c8YOpTlT.js","assets/react-CzUPVyyG.js","assets/settings-store-DXmQug0m.js","assets/file-store-CTlJqj2m.js","assets/window-store-B4cbZ5rr.js","assets/window-pip-registry-DH07f_8k.js","assets/panel-store-BUQ-CPsd.js","assets/onboarding-quick-orientation-u7yM68d3.js","assets/dialog-CaShS4f5.js","assets/portal-container-context-NFSuymMu.js","assets/icons-C9ZwXgel.js","assets/use-is-mobile-CkO33jqU.js","assets/format-file-meta-DLaHgkdx.js","assets/fs-api-RVc5RtTA.js","assets/context-menu-CVO3HtIt.js","assets/input-CP31LZnN.js","assets/mobile-bottom-sheet-Cf4kV1hS.js","assets/use-visual-viewport-C307OVeV.js","assets/scroll-area-xAtds1T-.js","assets/file-icons-BlOxPo3P.js","assets/project-framework-store-XxFXcUpb.js","assets/format-date-BMtvCeb9.js","assets/git-repo-store-DFTJ5ngK.js","assets/project-store-C5gJXkvb.js","assets/ws-auth-B_y5rMfZ.js","assets/tab-store-DqeaGhhE.js","assets/apply-theme-aVoqSG0I.js","assets/resolve-theme-B87m6l4i.js","assets/index-CzYrKDUF.css","assets/image-gallery-DvAgPQ3L.js","assets/run-in-terminal-SU9cwoZ4.js","assets/api-client-BgedDTvo.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{A as r,An as i,Ar as a,C as o,Dr as s,Dt as c,E as l,F as u,G as d,Gt as f,Hn as p,J as m,Jn as h,Jr as g,K as _,Kt as v,Lr as y,Mr as b,N as ee,Nr as x,O as S,Or as te,Qr as C,R as w,Sn as ne,Ut as re,Vr as T,Wn as ie,Yr as E,Z as ae,Zt as D,_r as oe,ar as se,b as O,br as ce,cn as le,ct as k,d as A,dt as ue,g as j,gn as M,hr as N,ir as de,j as P,kr as fe,ln as pe,lt as me,n as he,nt as F,pr as I,qn as L,t as ge,un as R,ur as z,v as B,vt as V,w as H,wn as _e,x as U,xn as ve,xr as ye,z as W,zt as be}from"./icons-C9ZwXgel.js";import{t as xe}from"./createLucideIcon-DBXq3G0e.js";import{i as G,n as K,r as Se,s as Ce}from"./api-client-c8YOpTlT.js";import{t as we}from"./settings-store-DXmQug0m.js";import{q as Te}from"./vendor-mermaid-eg2XWIjK.js";import{n as q,r as Ee,t as De}from"./utils-btZ8C8-R.js";import{n as Oe,t as ke}from"./panel-store-BUQ-CPsd.js";import{i as Ae}from"./project-store-C5gJXkvb.js";import{t as J}from"./tab-store-DqeaGhhE.js";import{t as je}from"./format-date-BMtvCeb9.js";import{o as Me}from"./file-store-CTlJqj2m.js";import{n as Y}from"./use-is-mobile-CkO33jqU.js";import{u as Ne}from"./onboarding-quick-orientation-u7yM68d3.js";import{t as X}from"./button-CBehaXpV.js";import{n as Z,o as Pe,t as Fe}from"./dialog-CaShS4f5.js";import{t as Ie}from"./mobile-bottom-sheet-Cf4kV1hS.js";import{Dn as Le,Fn as Re,Gn as ze,In as Be,It as Ve,Kn as He,Ln as Ue,Q as We,Qn as Ge,R as Ke,Rn as qe,Vn as Je,Xn as Ye,Zn as Xe,_n as Ze,an as Qe,et as $e,gn as et,mn as tt,on as nt,r as rt,rn as it,t as at,vn as ot,xn as st,zn as ct}from"./index-BVKT5UCu.js";import{t as lt}from"./use-websocket-Bki-B4fj.js";import{a as ut,g as dt}from"./api-settings-0s1Rfgcu.js";import{n as ft,r as pt}from"./tool-cards-CmdjXi2c.js";import{n as mt,r as ht,t as gt}from"./image-gallery-DvAgPQ3L.js";import{t as _t}from"./libesm-DMnQ3WlF.js";import{t as vt}from"./onboarding-entry-CwkNJ69U.js";import{t as yt}from"./use-open-team-member-DHzZiJZw.js";import{n as bt,t as xt}from"./send-to-chat-TSKk3fI9.js";import{t as St}from"./ai-settings-section-0x6GFJ56.js";import{d as Ct,f as wt,i as Tt,l as Et,n as Dt,o as Ot,r as kt,t as At}from"./codex-daily-guard-Bn8jfcei.js";import{t as jt}from"./new-chat-provider-CJx_waY3.js";var Mt=xe(`slash`,[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]),Nt={maxImages:4,maxBase64PerImage:5e6,maxBase64Total:1e7};function Pt(e){let t=[],n=0;for(let r of e)if(r.imageData){if(t.length>=Nt.maxImages)break;r.imageData.data.length>Nt.maxBase64PerImage||n+r.imageData.data.length>Nt.maxBase64Total||(n+=r.imageData.data.length,t.push(r.imageData))}return t}function Ft(e,t){let n=new Set(t),r=[],i=[];for(let t of e)t.serverPath&&(t.imageData&&n.has(t.imageData)?r.push(t.serverPath):i.push(t.serverPath));return{inlineImagePaths:r,pathOnlyPaths:i}}var It=class{attempt=null;constructor(e){this.emit=e}start(e,t,n){this.fail(),!(!t||!n)&&(this.attempt={sessionId:e,attemptId:crypto.randomUUID()},this.emit({type:`started`,...this.attempt}))}migrate(e){if(!this.attempt||this.attempt.sessionId===e)return;let t=this.attempt.sessionId;this.attempt.sessionId=e,this.emit({type:`session`,...this.attempt,previousSessionId:t})}select(e){this.attempt&&this.attempt.sessionId!==e&&this.fail()}fail(){if(!this.attempt)return;let e=this.attempt;this.attempt=null,this.emit({type:`failed`,...e})}finish(e){if(!this.attempt)return;let t=this.attempt;this.attempt=null,this.emit({type:e?`succeeded`:`failed`,...t,hasContent:e})}};function Lt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t).toString(36)}function Rt(e,t){let n=`pc-${Lt(t)}-`;return e.map(e=>e.id?{...e,id:`${n}${e.id}`}:e)}function zt(e,t){if(t.size===0)return e;let n=[],r=new Set,i=e=>{for(let a of e){let e=a.id?t.get(a.id):void 0;e&&e.length>0&&a.id&&!r.has(a.id)&&(r.add(a.id),i(e)),n.push(a)}};return i(e),n}var Bt=null;function Vt(){return Bt||=new AudioContext,Bt}function Ht(e,t,n,r,i=`sine`){let a=Vt(),o=a.createOscillator(),s=a.createGain();o.type=i,o.frequency.value=e,s.gain.setValueAtTime(r,n),s.gain.exponentialRampToValueAtTime(.001,n+t),o.connect(s),s.connect(a.destination),o.start(n),o.stop(n+t)}function Ut(){let e=Vt().currentTime;Ht(523,.15,e,.15),Ht(659,.2,e+.12,.15)}function Wt(){let e=Vt().currentTime;Ht(880,.12,e,.18,`square`),Ht(698,.12,e+.15,.18,`square`),Ht(880,.15,e+.3,.15,`square`)}function Gt(){let e=Vt().currentTime;Ht(440,.12,e,.12),Ht(523,.12,e+.1,.12),Ht(659,.18,e+.2,.12)}var Kt={done:Ut,approval_request:Wt,question:Gt};function qt(e){try{Kt[e]?.()}catch{}}var Q=e(t(),1),Jt={hasTeams:!1,teamNames:[],messageCount:0,unreadCount:0};function Yt(e){if(document.hidden)return!1;let{panels:t}=ke.getState();for(let n of Object.values(t))if(Oe(n.tabs.find(e=>e.id===n.activeTabId))===e)return!0;return!1}function Xt(e,t=`claude`,n=``,r,i){let a=(0,Q.useRef)(i);a.current=i;let o=(0,Q.useRef)(null);o.current||=new It(e=>a.current?.(e));let[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)(new Map),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)({}),[h,g]=(0,Q.useState)(`idle`),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(0),[ee,x]=(0,Q.useState)(null),[S,te]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)([]),[T,ie]=(0,Q.useState)([]),E=(0,Q.useRef)([]),[ae,D]=(0,Q.useState)(null),[oe,se]=(0,Q.useState)(null),[O,ce]=(0,Q.useState)(!1),[le,k]=(0,Q.useState)(null),[A,ue]=(0,Q.useState)(null),j=(0,Q.useRef)(null),M=(0,Q.useRef)(null),[N,de]=(0,Q.useState)(null),P=(0,Q.useRef)(null),[fe,pe]=(0,Q.useState)(!0),me=(0,Q.useRef)(null),he=(0,Q.useRef)(null),F=(0,Q.useRef)(``),I=(0,Q.useRef)([]),L=(0,Q.useRef)(new Map),ge=(0,Q.useRef)(null),[R,z]=(0,Q.useState)(null),B=(0,Q.useRef)(`idle`),V=(0,Q.useRef)(null),H=(0,Q.useRef)(()=>{}),_e=(0,Q.useRef)(null),U=(0,Q.useRef)(0),ve=(0,Q.useRef)(0),ye=(0,Q.useRef)(!1),W=(0,Q.useRef)(null),be=(0,Q.useRef)([]),xe=(0,Q.useRef)(0),Se=(0,Q.useRef)(!1),we=(0,Q.useRef)(!1),Te=(0,Q.useRef)(null),q=(0,Q.useRef)(!1),Ee=(0,Q.useRef)(new Set),De=(0,Q.useRef)(0),Oe=(0,Q.useRef)(null),Ae=(0,Q.useRef)(0),J=(0,Q.useRef)(e);J.current=e;let je=(0,Q.useRef)(r);je.current=r;let Me=(0,Q.useRef)([]);Me.current=s;let Y=(0,Q.useRef)(n);Y.current=n;let X=(0,Q.useRef)(null),Z=(0,Q.useRef)(0),Pe=(0,Q.useRef)({teamNames:new Set,messages:[]}),Fe=(0,Q.useRef)(0),[Ie,Le]=(0,Q.useState)(Jt),[Re,ze]=(0,Q.useState)([]),Be=(0,Q.useCallback)(()=>{let e=Pe.current;Le({hasTeams:e.teamNames.size>0,teamNames:Array.from(e.teamNames),messageCount:e.messages.length,unreadCount:Fe.current}),ze([...e.messages])},[]),Ve=(0,Q.useCallback)(()=>{Fe.current=0,Be()},[Be]),He=(0,Q.useCallback)(async e=>{try{let t=await K.get(`/api/teams/${encodeURIComponent(e)}`);if(!t?.messages)return;let n=Pe.current.messages,r=t.messages.filter(e=>!n.some(t=>t.timestamp===e.timestamp&&t.from===e.from));n.push(...r),n.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),n.length>500&&n.splice(0,n.length-500),Be()}catch{}},[Be]),Ue=h!==`idle`;(0,Q.useEffect)(()=>{if(e)return Ne.getState().setStreaming(e,h!==`idle`,n),()=>{Ne.getState().setStreaming(e,!1)}},[e,h,n]);let We=(0,Q.useCallback)((e,t)=>{let n=r=>{for(let i=0;i<r.length;i++){let a=r[i];if(a.type===`tool_use`){if((a.tool===`Agent`||a.tool===`Task`)&&a.toolUseId===t){let t=[...a.children??[]],n=e.toolUseId,o=n?t.findIndex(t=>t.type===e.type&&t.toolUseId===n):-1;return o===-1?t.push(e):t[o]=e,[[...r.slice(0,i),{...a,children:t},...r.slice(i+1)],!0]}if(a.children?.length){let[e,t]=n(a.children);if(t)return[[...r.slice(0,i),{...a,children:e},...r.slice(i+1)],!0]}}}return[r,!1]},[r,i]=n(I.current);return i&&(I.current=r),i},[]),Ge=(0,Q.useCallback)((e,t)=>{let n=e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t,r=Me.current,i=-1;for(let e=r.length-1;e>=0;e--)if(r[e].events?.some(n)){i=e;break}return i===-1?!1:(c(t=>{let r=-1;for(let e=t.length-1;e>=0;e--)if(t[e].events?.some(n)){r=e;break}if(r===-1)return t;let i=t[r],a=i.events.map(t=>{if(!n(t)||t.type!==`tool_use`)return t;let r=[...t.children??[]],i=e.toolUseId,a=i?r.findIndex(t=>t.type===e.type&&t.toolUseId===i):-1;return a===-1?r.push(e):r[a]=e,{...t,children:r}});return[...t.slice(0,r),{...i,events:a},...t.slice(r+1)]}),!0)},[]),Ke=(0,Q.useCallback)(()=>{Z.current=0;let e=F.current,t=[...I.current],n=ge.current;(0,Q.startTransition)(()=>{c(r=>{let i=r[r.length-1];return i?.role===`assistant`&&!i.id.startsWith(`final-`)?[...r.slice(0,-1),{...i,content:e,events:t,...n}]:[...r,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:t,timestamp:new Date().toISOString(),...n}]})})},[]),qe=(0,Q.useCallback)(()=>{Z.current||=window.setTimeout(Ke,100)},[Ke]),Je=(0,Q.useCallback)((e,t)=>{let n=t=>t.type===`tool_use`&&(t.tool===`Agent`||t.tool===`Task`)&&t.toolUseId===e,r=I.current.findIndex(n);if(r!==-1){I.current[r]={...I.current[r],bgStatus:t},qe();return}c(e=>{let r=-1;for(let t=e.length-1;t>=0;t--)if(e[t].events?.some(n)){r=t;break}if(r===-1)return e;let i=e[r],a=i.events.map(e=>n(e)?{...e,bgStatus:t}:e);return[...e.slice(0,r),{...i,events:a},...e.slice(r+1)]})},[qe]),Ye=(0,Q.useCallback)(e=>{let t=e,n=t?.type;if(!n)return;let r=e=>{let n=I.current,r=n.findIndex(e);r===-1?n.push(t):n[r]=t};switch(n){case`account_info`:ge.current={accountId:t.accountId,accountLabel:t.accountLabel},z({id:t.accountId,label:t.accountLabel??null}),D(null);break;case`account_retry`:t.accountId&&t.accountLabel&&(ge.current={accountId:t.accountId,accountLabel:t.accountLabel},z({id:t.accountId,label:t.accountLabel})),I.current.push(t),qe();break;case`status_update`:{let e=t.accountLabel?` (${t.accountLabel})`:``;D(`${t.message}${e}`);break}case`text`:{let e=t.parentToolUseId;if(e&&We(t,e)){qe();break}if(e){Ge(t,e);break}F.current+=t.content,I.current.push(t),qe();break}case`thinking`:{let e=t.parentToolUseId;if(e&&We(t,e)){qe();break}if(e){Ge(t,e);break}I.current.push(t),qe();break}case`tool_use`:{if(t.tool===`AskUserQuestion`){t.toolUseId&&Ee.current.add(t.toolUseId);break}let e=t.parentToolUseId;if(e&&We(t,e)){qe();break}if(e){Ge(t,e);break}let n=t.toolUseId;r(e=>!!n&&e.type===`tool_use`&&e.toolUseId===n),qe();break}case`tool_result`:{let e=t.toolUseId;if(e&&L.current.delete(e),e&&Ee.current.has(e))break;let n=t.parentToolUseId;if(n&&We(t,n)){qe();break}if(n){Ge(t,n);break}r(t=>!!e&&t.type===`tool_result`&&t.toolUseId===e),qe();break}case`approval_resolved`:{let e=t.requestId;if(t.approved&&t.answers){let n=I.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`),r=n&&n.input;r&&typeof r==`object`&&(r.answers=t.answers,c(e=>[...e]))}x(t=>t&&t.requestId===e?null:t),X.current!=null&&(Ce.dismiss(X.current),X.current=null);break}case`approval_request`:if(r(e=>e.type===`approval_request`&&e.requestId===t.requestId),q.current)break;if(x({requestId:t.requestId,tool:t.tool,input:t.input}),J.current&&!Yt(J.current)){qt(t.tool===`AskUserQuestion`?`question`:`approval_request`);let e=J.current,n=t.tool===`AskUserQuestion`;X.current=Ce[n?`info`:`warning`](n?`AI has a question`:`${t.tool} needs permission`,{description:Y.current||`Session ${e.slice(0,8)}`,duration:1/0,action:{label:`Go to session`,onClick:()=>{let{panels:t}=ke.getState();for(let[n,r]of Object.entries(t)){let t=r.tabs.find(t=>t.metadata?.sessionId===e);if(t){ke.getState().setActiveTab(t.id,n);break}}}}})}break;case`error`:q.current||o.current?.fail(),c(e=>{let n=e[e.length-1];if(n?.role===`assistant`){let r=I.current,i=r[r.length-1],a=i?.type===`error`&&i.message===t.message?r:[...r,t];return I.current=a,[...e.slice(0,-1),{...n,events:a}]}return n?.role===`system`&&n.content===t.message?e:[...e,{id:`error-${Date.now()}`,role:`system`,content:t.message,events:[t],timestamp:new Date().toISOString()}]});break;case`team_detected`:{let e=t.teamName;e&&(Pe.current.teamNames.add(e),Be(),He(e));break}case`team_inbox`:{let e=t.messages;if(Array.isArray(e)){let t=Pe.current.messages;t.push(...e),t.length>500&&t.splice(0,t.length-500),Fe.current+=e.length,Be()}break}case`team_updated`:Be();break;case`bash_output`:{let e=t.toolUseId;if(e){let n=L.current.get(e);n?(n.content+=t.content,n.content.length>5e5&&(n.content=n.content.slice(-5e5)),n.lineCount=t.lineCount):L.current.set(e,{content:t.content,lineCount:t.lineCount}),qe()}break}case`subagent_status`:{let e=t.toolUseId,n=t.status;e&&n&&Je(e,n);break}case`background_registry`:{let e=t.shells??[];E.current=e,ie(e);break}case`done`:{if(q.current||o.current?.finish(!!F.current.trim()),B.current===`idle`)break;t.contextWindowPct!=null&&te(t.contextWindowPct),J.current&&!Yt(J.current)&&qt(`done`),Z.current&&=(clearTimeout(Z.current),0);let e=F.current,n=[...I.current],r=ge.current;ye.current=!!e||n.length>0;let i=t.lastMessageUuid,a=t.usage;c(t=>{let o=t[t.length-1];return o?.role===`assistant`?[...t.slice(0,-1),{...o,id:`final-${Date.now()}`,content:e||o.content,events:n.length>0?n:o.events,...i&&{sdkUuid:i},...a&&{usage:a}}]:e||n.length>0?[...t,{id:`final-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString(),...i&&{sdkUuid:i},...a&&{usage:a},...r}]:t}),F.current=``,I.current=[],ge.current=null,Oe.current=null,L.current.clear(),D(null);break}}},[We,Ge,qe,Je,Be,He]),Xe=(0,Q.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(q.current){be.current.push(e);return}if(t.type===`ping`){let e=t.streamSeq;typeof e==`number`&&e>xe.current&&!Se.current&&!we.current&&(Se.current=!0,H.current(JSON.stringify({type:`resync`})));return}let n=t.streamSeq;if(typeof n==`number`&&(we.current?xe.current=Math.max(xe.current,n):n===xe.current+1?xe.current=n:n>xe.current&&!Se.current&&(Se.current=!0,H.current(JSON.stringify({type:`resync`})))),t.type===`user_message`){U.current++;let e=t.content;c(n=>{let r=n[n.length-1];return r?.role===`user`&&r.content===e?n:[...n,{id:`user-remote-${Date.now()}`,role:`user`,content:e,timestamp:t.timestamp??new Date().toISOString()}]});return}if(t.type===`title_updated`){se(t.title??null);return}if(t.type===`session_migrated`){let e=t.newSessionId;e&&e!==J.current&&(o.current?.migrate(e),je.current?.(e));return}if(t.type===`mcp_status`){let e=t.needsAuth;re(Array.isArray(e)?e:[]);return}if(t.type===`compact_status`){let e=t.status;e===`compacting`?w(`compacting`):e===`done`&&w(null);return}if(t.type===`phase_changed`){let e=t.phase,n=B.current!==`idle`;if(!n&&e!==`idle`&&(ye.current=!1),e!==`idle`&&U.current++,g(e),B.current=e,b(e===`connecting`?t.elapsed??0:0),e===`idle`){let e=we.current;Se.current=!1,we.current=!1,w(null),D(null),(e||n&&!ye.current)&&_e.current?.()}return}if(t.type===`session_state`){ce(!0),v(!1),k(t.sessionId??J.current);let e=t,n=e.phase;n!==`idle`&&U.current++;let r=B.current===`idle`;if(r&&n!==`idle`&&(ye.current=!1),g(n),B.current=n,e.sessionTitle&&se(e.sessionTitle),e.model&&(M.current&&e.model!==M.current||(e.model===M.current&&(M.current=null),ue(e.model),j.current=e.model)),typeof e.effort==`string`&&(de(e.effort),P.current=e.effort),typeof e.thinking==`boolean`&&pe(e.thinking),e.pendingApproval&&x({requestId:e.pendingApproval.requestId,tool:e.pendingApproval.tool,input:e.pendingApproval.input}),w(e.compactStatus===`compacting`?`compacting`:null),re(Array.isArray(e.mcpNeedsAuth)?e.mcpNeedsAuth:[]),n===`idle`){let e=we.current;Se.current=!1,we.current=!1;let t=Date.now()-Ae.current<5e3;(e||!(r&&t))&&_e.current?.(),v(!1)}return}if(t.type===`turn_events`){U.current++;let e=t.events,n=t.userMessage;if(!e?.length&&!n){v(!1);return}De.current&&=(cancelAnimationFrame(De.current),0),Oe.current=n,c(e=>{let t=[...e],r=t.length;for(;r>0&&t[r-1].role===`assistant`;)r--;if(n!=null&&r>0&&t[r-1].role===`user`&&t[r-1].content===n)t=t.slice(0,r-1);else{let e=t[t.length-1];e?.role===`assistant`&&e.id.startsWith(`streaming-`)&&(t=t.slice(0,-1))}if(n){let e=t[t.length-1];(e?.role!==`user`||e.content!==n)&&(t=[...t,{id:`user-replay-${Date.now()}`,role:`user`,content:n,timestamp:new Date().toISOString()}])}return t}),F.current=``,I.current=[],ge.current=null,q.current=!0;let r=0,i=()=>{let n=Math.min(r+100,e.length);for(let t=r;t<n;t++)Ye(e[t]);if(r=n,r<e.length)De.current=requestAnimationFrame(i);else{De.current=0,q.current=!1;let e=t.streamSeq,n=t.truncated===!0;we.current=n,!n&&typeof e==`number`&&(xe.current=e),Se.current=!1,v(!1);let r=be.current.splice(0);for(let e of r)Te.current?.(e)}};De.current=requestAnimationFrame(i);return}Ye(t)},[Ye]);Te.current=Xe;let{send:Ze,connect:Qe}=lt({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:Xe,autoConnect:!!e&&!!n,idleTimeoutMs:45e3,onConnectionChange:e=>{e||(o.current?.fail(),ce(!1),v(!0))}});H.current=Ze,(0,Q.useEffect)(()=>{let r=!1;o.current?.select(e);let i=ve.current;ye.current=!1,U.current++,xe.current=0,Se.current=!1,we.current=!1,he.current&&he.current!==e&&(M.current=null,me.current=null,z(null)),he.current=e??null,g(`idle`),B.current=`idle`,x(null),X.current!=null&&(Ce.dismiss(X.current),X.current=null),w(null),re([]),u(new Map),m({}),F.current=``,I.current=[],Oe.current=null,Ae.current=0,L.current.clear(),Z.current&&=(clearTimeout(Z.current),0),ce(!1),k(null),v(!1),Pe.current={teamNames:new Set,messages:[]},Fe.current=0,Le(Jt),ze([]),e&&K.get(`/api/teams`).then(t=>{r||!Array.isArray(t)||t.filter(t=>(t?.name??t?.team_name)===e).length!==0&&(Pe.current.teamNames.add(e),Be(),He(e))}).catch(()=>{});let a=new Set(Me.current.map(e=>e.id));return e&&n?(f(!0),K.get(`${G(n)}/chat/sessions/${e}/messages?providerId=${t}`).then(e=>{if(r||ve.current!==i)return;let t=Array.isArray(e)?{messages:e,versionMap:{}}:e,n=Array.isArray(t?.messages)?t.messages:[];t?.versionMap&&m(t.versionMap),t?.canonicalSessionId&&t.canonicalSessionId!==J.current&&je.current?.(t.canonicalSessionId);let o=Oe.current;if(o!=null){for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`&&n[e].content===o){n=n.slice(0,e);break}}c(e=>{let t=e.filter(e=>!a.has(e.id));return[...n,...t]}),Ae.current=Date.now()}).catch(()=>{!r&&ve.current===i&&c(e=>e.filter(e=>!a.has(e.id)))}).finally(()=>{r||f(!1)})):c([]),()=>{r=!0,W.current?.abort(),W.current=null,Z.current&&clearTimeout(Z.current),Z.current=0,De.current&&cancelAnimationFrame(De.current),De.current=0,q.current=!1,be.current=[]}},[e,t,n,Be,He]);let $e=(0,Q.useCallback)((e,t)=>{if(!e.trim()&&!t?.images?.length)return;U.current++;let n=B.current!==`idle`;if(J.current&&o.current?.start(J.current,!n,O&&le===J.current),ye.current=!1,n){Z.current&&=(clearTimeout(Z.current),0);let e=F.current,t=[...I.current];c(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n})}c(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),F.current=``,I.current=[],V.current=null,n?(g(`thinking`),B.current=`thinking`):(g(`initializing`),B.current=`initializing`),x(null),X.current!=null&&(Ce.dismiss(X.current),X.current=null),Ze(JSON.stringify({type:`message`,content:e,permissionMode:t?.permissionMode,priority:t?.priority,images:t?.images,imagePaths:t?.imagePaths,...j.current&&{model:j.current},...P.current&&{effort:P.current},...me.current!==null&&{thinking:me.current}}))},[Ze,O,le]),et=(0,Q.useCallback)(e=>{ue(e),j.current=e,M.current=e,Ze(JSON.stringify({type:`set_model`,model:e}))},[Ze]),tt=(0,Q.useCallback)(e=>{de(e),P.current=e,Ze(JSON.stringify({type:`set_effort`,effort:e}))},[Ze]),nt=(0,Q.useCallback)(e=>{pe(e),me.current=e,Ze(JSON.stringify({type:`set_thinking`,enabled:e}))},[Ze]),rt=(0,Q.useCallback)((e,t,n)=>{if(Ze(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=I.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`);if(t){let e=t.input;e&&typeof e==`object`&&(e.answers=n)}c(e=>[...e])}x(null),X.current!=null&&(Ce.dismiss(X.current),X.current=null)},[Ze]),it=(0,Q.useCallback)(()=>{if(o.current?.fail(),B.current===`idle`)return;Ze(JSON.stringify({type:`cancel`}));let e=F.current,t=[...I.current];c(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),F.current=``,I.current=[],L.current.clear(),V.current=null,g(`idle`),B.current=`idle`,x(null),X.current!=null&&(Ce.dismiss(X.current),X.current=null)},[Ze]),ot=(0,Q.useCallback)(e=>{e&&Ze(JSON.stringify({type:`kill_background_shell`,shellId:e}))},[Ze]),st=(0,Q.useCallback)(e=>{if(!e)return;let t=e.replace(/\.output$/,``);return E.current.find(n=>n.shellId===t||n.outputPath.endsWith(e)||n.outputPath.endsWith(`${t}.output`))},[]);(0,Q.useEffect)(()=>{e&&at.getState().setSessionShells(e,T)},[e,T]),(0,Q.useEffect)(()=>{if(e)return at.getState().retainSession(e),()=>{at.getState().releaseSession(e)}},[e]);let ct=(0,Q.useCallback)(()=>{ce(!1),v(!0),Qe()},[Qe]),ut=(0,Q.useCallback)(()=>{if(!e||!n||B.current!==`idle`)return;W.current?.abort();let r=new AbortController;W.current=r;let i=U.current;K.get(`${G(n)}/chat/sessions/${e}/messages?providerId=${t}`,{signal:r.signal}).then(t=>{if(r.signal.aborted||W.current!==r||U.current!==i||B.current!==`idle`||J.current!==e||Y.current!==n||q.current)return;let a=Array.isArray(t)?{messages:t,versionMap:void 0}:t;a?.versionMap&&m(a.versionMap),Array.isArray(a?.messages)&&a.messages.length>0&&(ve.current++,Z.current&&=(clearTimeout(Z.current),0),c(a.messages),F.current=``,I.current=[]),Ae.current=Date.now()}).catch(()=>{})},[e,t,n]);_e.current=ut;let dt=(0,Q.useCallback)(async(e,t)=>{if(!n)throw Error(`No project context available`);let r=e.replace(/^pc-[^-]+-/,``),i=`${G(n)}/chat/pre-compact-messages?jsonlPath=${encodeURIComponent(t)}&before=${encodeURIComponent(r)}`,a=Rt(await K.get(i),t);return u(t=>{let n=new Map(t);return n.set(e,a),n}),a.length},[n]),ft=(0,Q.useCallback)(e=>l.has(e),[l]),pt=(0,Q.useCallback)(e=>{c(t=>t.filter(t=>t.id!==e))},[]),mt=(0,Q.useCallback)(()=>{c(e=>e.filter(e=>e.role!==`system`))},[]);return{messages:s,renderedMessages:(0,Q.useMemo)(()=>zt(s,l),[s,l]),expandCompact:dt,isCompactExpanded:ft,dismissMessage:pt,clearErrors:mt,messagesLoading:d,versionMap:p,isStreaming:Ue,phase:h,isReconnecting:_,connectingElapsed:y,pendingApproval:ee,contextWindowPct:S,compactStatus:C,mcpNeedsAuth:ne,statusMessage:ae,sessionTitle:oe,liveAccount:R,model:A,setModel:et,effort:N,setEffort:tt,thinking:fe,setThinking:nt,teamActivity:Ie,teamMessages:Re,markTeamRead:Ve,bashPartialOutput:L,backgroundShells:T,killBackgroundShell:ot,findBackgroundShellByOutput:st,sendMessage:$e,respondToApproval:rt,cancelStreaming:it,reconnect:ct,refetchMessages:ut,isConnected:O&&le===e}}var Zt=12e4;function Qt(e,t=`claude`,n,r){let i=t===`codex`&&!n?r:void 0,a=JSON.stringify([e,t,n,i]),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(!1),u=(0,Q.useRef)(null),d=(0,Q.useRef)(0),f=(0,Q.useCallback)((r=!1)=>{if(!e)return Promise.resolve();let o=++d.current;l(!0);let c=r?`&refresh=1`:``,u=n?`&session=${encodeURIComponent(n)}`:``,f=i?`&accountId=${encodeURIComponent(i)}`:``;return K.get(`${G(e)}/chat/usage?providerId=${t}${u}${f}${c}`).then(e=>{o===d.current&&s({scope:a,usage:e??{},fetchedAt:e?.lastFetchedAt??null})}).catch(()=>{}).finally(()=>{o===d.current&&l(!1)})},[e,t,n,i,a]);(0,Q.useEffect)(()=>(s(null),l(!1),f(),u.current=setInterval(()=>f(),Zt),()=>{++d.current,u.current&&clearInterval(u.current)}),[f]);let p=(0,Q.useCallback)(()=>f(!0),[f]),m=(0,Q.useCallback)(()=>f(),[f]),h=o?.scope===a?o:null;return{usageInfo:h?.usage??{},usageLoading:c,lastFetchedAt:h?.fetchedAt??null,refreshUsage:p,reloadUsage:m}}function $t(e){let{tabId:t,sessionId:n,designSlug:r,projectName:i,providerId:a}=e;(0,Q.useEffect)(()=>{if(!t||!n||r||!i||ke.getState().getPanelForTab(t)?.tabs.find(e=>e.id===t)?.type!==`chat`)return;let e=!1;return K.get(`${G(i)}/chat/sessions/${encodeURIComponent(n)}/design`).then(({designSlug:r})=>{if(e||!r)return;let o=ke.getState().getPanelForTab(t)?.id;et({projectName:i,slug:r,sessionId:n,providerId:a,panelId:o}),ke.getState().closeTab(t,o)}).catch(()=>{}),()=>{e=!0}},[t,n,r,i,a])}function en(e){let t=Array(e.length),n=0;for(let r=0;r<e.length;r++){let i=e[r].role===`user`;i&&n++,t[r]=i?n:0}return t}var tn={damping:.7,stiffness:.05,mass:1.25},nn=70,rn=1e3/60,an=350,on=!1;globalThis.document?.addEventListener(`mousedown`,()=>{on=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{on=!1}),globalThis.document?.addEventListener(`click`,()=>{on=!1});var sn=(e={})=>{let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(e.initial!==!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);s.current=e;let c=(0,Q.useCallback)(()=>{if(!on)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,Q.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,Q.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,Q.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=nn}}},[]),f=(0,Q.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=un(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/rn;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:un(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,Q.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,Q.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,Q.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=cn(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=cn(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=un(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:an})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function cn(e,t){let n=(0,Q.useCallback)(t=>(n.current=t,e(t)),t);return n}var ln=new Map;function un(...e){let t={...tn},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return ln.has(r)||ln.set(r,Object.freeze(t)),n?`instant`:ln.get(r)}var dn=60,fn=8,pn=1400;function mn(e){if(e.scrollHeight<=e.clientHeight)return!1;let t=getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`}function hn(e,t){let n=[],r=e.parentElement;for(;r&&r!==t;)mn(r)&&n.push(r),r=r.parentElement;return n}function gn(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function _n(e,t){let n=e.querySelector(`[data-edit-ref="${CSS.escape(t)}"]`);if(n)return{el:n,level:`edit`};let r=t.replace(/-\d+$/,``),i=e.querySelector(`[data-tool-ref="${CSS.escape(r)}"]`);return i?{el:i,level:`card`}:null}function vn(e,t,n,r){let i=e.scrollTop+t.getBoundingClientRect().top-e.getBoundingClientRect().top-n;e.scrollTo({top:i,behavior:r?`smooth`:`auto`})}function yn(e,t){let n=_n(e,t);if(!n)return()=>{};let{el:r,level:i}=n;for(let t of hn(r,e))vn(t,r,fn,!1);vn(e,r,dn,!gn()),r.dataset.flash=i;let a=setTimeout(()=>{delete r.dataset.flash},pn);return()=>{clearTimeout(a),delete r.dataset.flash}}var bn=new Set([`Write`,`Edit`,`MultiEdit`,`NotebookEdit`]),xn={create:3,write:2,notebook:2,edit:1};function Sn(e){return typeof e==`string`?e:``}function Cn(e,t){let n=0,r=0;for(let i of _t(e,t))i.added?n+=i.count??0:i.removed&&(r+=i.count??0);return{added:n,removed:r}}function wn(e){return e&&/created successfully/i.test(e)?`create`:`write`}function Tn(e,t,n){switch(e){case`Write`:{let e=Sn(t.file_path);return e?{filePath:e,op:wn(n),fragments:[{oldStr:``,newStr:Sn(t.content)}]}:null}case`Edit`:{let e=Sn(t.file_path);return e?{filePath:e,op:`edit`,fragments:[{oldStr:Sn(t.old_string),newStr:Sn(t.new_string)}]}:null}case`MultiEdit`:{let e=Sn(t.file_path);if(!e||!Array.isArray(t.edits))return null;let n=t.edits.filter(e=>!!e&&typeof e==`object`).map(e=>({oldStr:Sn(e.old_string),newStr:Sn(e.new_string)}));return n.length===0?null:{filePath:e,op:`edit`,fragments:n}}case`NotebookEdit`:{let e=Sn(t.notebook_path)||Sn(t.file_path);return e?{filePath:e,op:`notebook`,fragments:[{oldStr:``,newStr:Sn(t.new_source)}]}:null}default:return null}}function En(e,t){if(e){for(let n of e)if(n.type===`tool_result`&&n.toolUseId&&t.set(n.toolUseId,n.output??``),n.type===`tool_use`){let e=n.result;n.toolUseId&&e?.output!=null&&!t.has(n.toolUseId)&&t.set(n.toolUseId,e.output),En(n.children,t)}}}function Dn(e,t,n,r){if(e)for(let i of e){if(i.type!==`tool_use`||(i.children?.length&&Dn(i.children,!0,n,r),!bn.has(i.tool)))continue;let e=i.input&&typeof i.input==`object`?i.input:null;if(!e)continue;let a=Tn(i.tool,e,i.toolUseId?r.get(i.toolUseId):void 0);if(!a)continue;let o=n.get(a.filePath);o||(o={filePath:a.filePath,op:a.op,editCount:0,linesAdded:0,linesRemoved:0,edits:[],viaSubagent:!1},n.set(a.filePath,o)),xn[a.op]>xn[o.op]&&(o.op=a.op),t&&(o.viaSubagent=!0),a.fragments.forEach((e,n)=>{let{added:r,removed:a}=Cn(e.oldStr,e.newStr);o.linesAdded+=r,o.linesRemoved+=a,o.editCount+=1,o.edits.push({...e,toolUseId:i.toolUseId,editIndex:n,editRef:i.toolUseId?`${i.toolUseId}-${n}`:void 0,viaSubagent:t})})}}function On(e){let t=new Map;for(let n of e)En(n.events,t);let n=new Map;for(let r of e)Dn(r.events,!1,n,t);return[...n.values()]}function kn(e,t){let n=[];for(let r=t;r>=0&&e[r]?.role===`assistant`;r--)n.unshift(e[r]);return n}var $=n();function An(e){try{return new Date(e).toLocaleString()}catch{return``}}function jn({icon:e,label:t,title:n,onClick:r}){return(0,$.jsxs)(`button`,{type:`button`,onClick:r,title:n,"aria-label":t,className:`inline-flex items-center justify-center gap-1 rounded-md px-1.5 py-1 text-text-subtle hover:text-text-primary hover:bg-surface transition-colors`,children:[e,(0,$.jsx)(`span`,{children:t})]})}function Mn({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsx)(jn,{icon:t?(0,$.jsx)(H,{className:`size-3.5`}):(0,$.jsx)(F,{className:`size-3.5`}),label:t?`Copied`:`Copy`,title:`Copy message to clipboard`,onClick:()=>{st(e),n(!0),setTimeout(()=>n(!1),1500)}})}function Nn({timestamp:e,content:t,className:n,children:r}){return(0,$.jsxs)(`div`,{className:q(`flex items-center gap-0.5 flex-wrap text-xs text-text-subtle select-none`,n),children:[(0,$.jsx)(`time`,{title:An(e),className:`pr-1 tabular-nums`,children:je(e)}),(0,$.jsx)(Mn,{content:t}),r]})}function Pn(e){let t=0,n=0;for(let r of e)t+=r.linesAdded,n+=r.linesRemoved;return{added:t,removed:n}}function Fn({count:e,totals:t,open:n,onToggle:r,ref:i}){let a=`${e} file${e===1?``:`s`}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`mx-1.5 h-3.5 w-px bg-border-soft`}),(0,$.jsxs)(`button`,{ref:i,type:`button`,onClick:r,"aria-expanded":n,"aria-label":`${a} changed this turn, ${t.added} added, ${t.removed} removed`,className:q(`inline-flex items-center gap-[7px] rounded-full font-mono text-[11.5px]`,`px-3 min-h-11 md:min-h-0 md:px-[9px] md:py-[5px]`,`text-text-secondary transition-colors hover:bg-surface hover:text-text-primary`),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-[5px] shrink-0 rounded-full bg-primary`}),(0,$.jsx)(`span`,{children:a}),(0,$.jsxs)(`span`,{className:`flex items-center gap-[5px] tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,t.added]}),(0,$.jsxs)(`span`,{className:`text-error`,children:[`−`,t.removed]})]})]})]})}function In(e){if(!e)return!1;let t=e.closest(`[data-tab-pool-id]`)?.dataset.tabPoolId;if(!t)return e.offsetParent!==null;let{panels:n,focusedPanelId:r}=ke.getState();return n[r]?.activeTabId===t}var Ln={create:{glyph:`A`,cls:`text-success`,label:`created`},write:{glyph:`W`,cls:`text-warning`,label:`overwritten`},notebook:{glyph:`N`,cls:`text-accent-2`,label:`notebook edited`},edit:{glyph:`·`,cls:`text-text-subtle`,label:`edited`}};function Rn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t)}}function zn({added:e,removed:t,editCount:n,className:r}){return(0,$.jsxs)(`span`,{className:q(`flex items-center gap-[5px] tabular-nums`,r),children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}),(0,$.jsxs)(`span`,{className:`text-error`,children:[`−`,t]}),n!=null&&n>1&&(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[`×`,n]})]})}function Bn({change:e,dense:t,selected:n,onClick:r}){let i=Ln[e.op],{base:a,dir:o}=Rn(e.filePath),s=e.viaSubagent?`${i.label} · changed by a sub-agent`:i.label;return(0,$.jsxs)(`button`,{type:`button`,onClick:r,title:e.filePath,className:q(`grid w-full grid-cols-[16px_1fr_auto_10px] items-center gap-[10px] text-left font-mono`,`border-b border-border-soft hover:bg-surface transition-colors`,t?`min-h-[38px] px-2.5 py-[5px] text-xs`:`min-h-[52px] px-3 py-[7px] text-[12.5px]`,n&&`bg-surface shadow-[inset_2px_0_0_var(--accent)]`),children:[(0,$.jsx)(`span`,{"aria-label":s,title:s,className:q(`inline-flex size-4 items-center justify-center rounded bg-white/5 text-[9px] font-semibold`,i.cls,e.viaSubagent&&`bg-accent-2/20 ring-1 ring-inset ring-accent-2/35`),children:i.glyph}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate text-text-primary`,children:a}),o&&(0,$.jsx)(`span`,{className:`block overflow-hidden text-ellipsis whitespace-nowrap text-[10px] text-text-subtle [direction:rtl] text-left`,children:o})]}),(0,$.jsx)(zn,{added:e.linesAdded,removed:e.linesRemoved,editCount:e.editCount,className:`text-[11px]`}),(0,$.jsx)(P,{className:`size-[11px] text-text-subtle`})]})}var Vn=(0,Q.lazy)(()=>Te(()=>import(`./edit-diff-preview-8nIct7kS.js`),__vite__mapDeps([0,1,2,3])));function Hn({change:e,onJump:t}){return(0,$.jsx)(`div`,{children:e.edits.map((n,r)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,disabled:!n.editRef,onClick:()=>n.editRef&&t(n.editRef),className:`group flex min-h-11 w-full items-center gap-2 px-3 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface disabled:hover:bg-transparent`,children:[(0,$.jsxs)(`span`,{children:[`edit `,r+1,` of `,e.editCount]}),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border-soft`}),n.editRef&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 group-hover:text-primary`,children:[(0,$.jsx)(A,{className:`size-3`}),`jump`]})]}),(0,$.jsx)(`div`,{className:`mx-3 mb-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-4`}),children:(0,$.jsx)(Vn,{oldStr:n.oldStr,newStr:n.newStr,filePath:e.filePath})})})]},n.editRef??r))})}function Un(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t)}}var Wn=null;function Gn(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}function Kn({changes:e,onJump:t,onClose:n}){let[r,i]=(0,Q.useState)(0),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useId)();(0,Q.useEffect)(()=>(Wn=s,o.current?.querySelector(`button`)?.focus(),()=>{Wn===s&&(Wn=null)}),[s]),(0,Q.useEffect)(()=>{let o=o=>{if(Wn===s&&In(a.current)&&!Gn(document.activeElement)){if(o.key===`Escape`)o.preventDefault(),n();else if(o.key===`j`)o.preventDefault(),i(t=>Math.min(t+1,e.length-1));else if(o.key===`k`)o.preventDefault(),i(e=>Math.max(e-1,0));else if(o.key===`Enter`){let n=e[r]?.edits[0]?.editRef;n&&(o.preventDefault(),t(n))}}};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[s,e,r,t,n]);let c=e[Math.min(r,e.length-1)];if(!c)return null;let{base:l,dir:u}=Un(c.filePath);return(0,$.jsx)(`div`,{ref:a,className:`mt-0.5 overflow-hidden rounded-[10px] border border-border-soft bg-bg`,children:(0,$.jsxs)(`div`,{className:`grid h-[356px] grid-cols-[294px_1fr] grid-rows-[minmax(0,1fr)] bg-surface-elevated`,children:[(0,$.jsxs)(`div`,{ref:o,className:`min-h-0 overflow-y-auto border-r border-border-soft`,children:[e.map((e,t)=>(0,$.jsx)(Bn,{change:e,dense:!0,selected:t===r,onClick:()=>i(t)},e.filePath)),(0,$.jsx)(`p`,{className:`px-2.5 pt-2 pb-2.5 font-mono text-[10px] text-text-subtle`,children:`j / k to move · enter to jump`})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border-soft bg-surface-elevated py-[5px] pl-2.5 pr-2`,children:[(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-medium text-text-primary`,children:l}),u&&(0,$.jsx)(`span`,{title:c.filePath,className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[10.5px] text-text-subtle [direction:rtl] text-left`,children:u}),(0,$.jsx)(zn,{added:c.linesAdded,removed:c.linesRemoved,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void st(c.filePath),className:`shrink-0 rounded-md px-1.5 py-1 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:`copy path`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close change tray`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:(0,$.jsx)(g,{className:`size-3.5`})})]}),(0,$.jsx)(Hn,{change:c,onJump:t})]})]})})}function qn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?e:e.slice(t+1)}function Jn({label:e,onClick:t,children:n}){return(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:n})}function Yn({changes:e,totals:t,open:n,onClose:i,onJump:a}){let[o,s]=(0,Q.useState)(null),c=o==null?null:e[o],l=(0,Q.useRef)(null),u=()=>{s(null),i()},d=e=>{u(),a(e)};return(0,Q.useEffect)(()=>{if(!n)return;let e=l.current,t=()=>Array.from(e?.querySelectorAll(`button:not([disabled])`)??[]);t()[0]?.focus();let r=e=>{if(e.key===`Escape`){e.preventDefault(),u();return}if(e.key!==`Tab`)return;let n=t();if(n.length===0)return;let r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[n,o]),(0,$.jsx)(Ie,{open:n,onClose:u,className:`flex max-h-[85%] flex-col rounded-t-[14px] motion-reduce:animate-none`,children:(0,$.jsx)(`div`,{ref:l,className:`flex min-h-0 flex-1 flex-col`,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-soft px-1 pb-1`,children:[(0,$.jsx)(Jn,{label:`Back to file list`,onClick:()=>s(null),children:(0,$.jsx)(r,{className:`size-4`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-text-primary`,children:qn(c.filePath)}),(0,$.jsx)(zn,{added:c.linesAdded,removed:c.linesRemoved,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(Jn,{label:`Close`,onClick:u,children:(0,$.jsx)(g,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-soft py-1.5 pl-3 pr-2`,children:[(0,$.jsx)(`span`,{title:c.filePath,className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[10.5px] text-text-subtle [direction:rtl] text-left`,children:c.filePath}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void st(c.filePath),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-2.5 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:`copy`}),c.edits[0]?.editRef&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(c.edits[0].editRef),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-md px-2.5 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-primary`,children:[(0,$.jsx)(A,{className:`size-3`}),`card`]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(Hn,{change:c,onJump:d})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border-soft px-3 pb-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-text-primary`,children:[`Changed this turn · `,e.length,` file`,e.length===1?``:`s`]}),(0,$.jsx)(zn,{added:t.added,removed:t.removed,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(Jn,{label:`Close`,onClick:u,children:(0,$.jsx)(g,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.map((e,t)=>(0,$.jsx)(Bn,{change:e,onClick:()=>s(t)},e.filePath))})]})})})}function Xn({timestamp:e,content:t,changes:n,onJumpToEdit:r}){let[i,a]=(0,Q.useState)(!1),o=Y(),s=(0,Q.useRef)(null),c=()=>{a(!1),s.current?.focus()},l=(0,$.jsx)(Nn,{timestamp:e,content:t,className:`-mt-1.5`,children:n&&n.length>0&&(0,$.jsx)(Fn,{ref:s,count:n.length,totals:Pn(n),open:i,onToggle:()=>i?c():a(!0)})});return!n||n.length===0?l:(0,$.jsxs)($.Fragment,{children:[l,o?(0,$.jsx)(Yn,{changes:n,totals:Pn(n),open:i,onClose:c,onJump:r??(()=>{})}):i&&(0,$.jsx)(Kn,{changes:n,onJump:e=>{a(!1),r?.(e)},onClose:c})]})}function Zn(e){return e.inputTokens+e.cacheReadTokens+e.cacheWriteTokens}function Qn(e){return e.inputTokens+e.cacheWriteTokens}var $n=.5,er=.9,tr={cache_expired:`the session's prompt cache had already lapsed, so PPM released its subprocess`,idle_timeout:`the session sat idle with no tab open long enough for PPM to release its subprocess`,warm_idle_cap:`too many idle sessions were holding a subprocess, so this one was released early`,tab_closed:`PPM shut the session's subprocess down when the last tab disconnected`,set_model:`the model was changed, which restarts the session`,stream_ended:`the session's subprocess had already exited`,resume:`the session was resumed on a new subprocess`};function nr(e){let t=Qn(e),n=Zn(e);if(!e.coldStart||n<2e4)return{level:`ok`,wastedTokens:t,reason:``};let r=e.cacheHitRate<$n?`bad`:e.cacheHitRate<er?`warn`:`ok`;if(r===`ok`)return{level:r,wastedTokens:t,reason:``};let i=e.coldReason?tr[e.coldReason]??`the session restarted (${e.coldReason})`:null;return{level:r,wastedTokens:t,reason:i?`${or(t)} of this session's transcript was re-sent uncached because ${i}.`:`${or(t)} of this session's transcript was re-sent uncached.`}}var rr=.1,ir=1.25;function ar(e){let t=Zn(e);if(t===0)return 1;let n=e.inputTokens+e.cacheWriteTokens*ir+e.cacheReadTokens*rr,r=t*rr;return r>0?Math.max(1,n/r):1}function or(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function sr({usage:e}){let[t,n]=(0,Q.useState)(!1),r=nr(e);if(r.level===`ok`)return null;let i=ar(e),a=Zn(e),o=Math.round(e.cacheHitRate*100),s=r.level===`bad`;return(0,$.jsxs)(`div`,{className:`rounded-md border px-2.5 py-2 text-[11px] ${s?`border-warning/40 bg-warning/10`:`border-border bg-surface`}`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(e=>!e),"aria-expanded":t,className:`flex w-full items-start gap-2 py-1 text-left text-text-secondary transition-colors hover:text-text-primary`,children:[(0,$.jsx)(x,{className:`mt-px size-3.5 shrink-0 ${s?`text-warning`:`text-text-subtle`}`}),(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Costly turn — `,o,`% of a `,or(a),`-token transcript came from cache, so it cost about`,` `,(0,$.jsxs)(`strong`,{className:`font-semibold`,children:[i.toFixed(1),`x`]}),` a fully cached turn.`]}),(0,$.jsx)(S,{className:`mt-px size-3.5 shrink-0 transition-transform ${t?`rotate-180`:``}`})]}),t&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 border-t border-border pt-2`,children:[r.reason&&(0,$.jsx)(`p`,{className:`text-text-secondary`,children:r.reason}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 font-mono text-[10.5px] text-text-subtle`,children:[(0,$.jsx)(cr,{label:`From cache`,value:`${or(e.cacheReadTokens)} (${o}%)`}),(0,$.jsx)(cr,{label:`Written to cache`,value:or(e.cacheWriteTokens)}),(0,$.jsx)(cr,{label:`Fresh input`,value:or(e.inputTokens)}),(0,$.jsx)(cr,{label:`Output`,value:or(e.outputTokens)}),(0,$.jsx)(cr,{label:`Model`,value:e.model||`unknown`}),(0,$.jsx)(cr,{label:`Cost`,value:`$${e.costUsd.toFixed(4)}`})]}),(0,$.jsx)(`p`,{className:`text-text-subtle`,children:`A turn stays cached while the session keeps running. Closing the last tab of an idle session, switching model, or a retry all restart it, and the next turn re-sends the transcript at full price.`})]})]})}function cr({label:e,value:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`truncate`,children:e}),(0,$.jsx)(`dd`,{className:`truncate text-right text-text-secondary`,children:t})]})}function lr(e,t,n,r){let[i,a]=(0,Q.useState)([]),o=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!n||!e||!t){a([]);return}let r=!1;return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{K.get(`/api/project/${encodeURIComponent(e)}/chat/sessions/${encodeURIComponent(t)}/tasks`).then(e=>{r||a(e)}).catch(()=>{})},300),()=>{r=!0,o.current&&clearTimeout(o.current)}},[e,t,n,r]),i}var ur=new Set([`TaskCreate`,`TaskUpdate`,`TaskStop`]);function dr(e){let t=0;for(let n of e)if(n.events)for(let e of n.events)e.type===`tool_use`&&ur.has(e.tool)&&t++;return t}var fr={completed:{icon:`✓`,cls:`text-success`},in_progress:{icon:`▶`,cls:`text-warning`},stopped:{icon:`■`,cls:`text-text-subtle`},pending:{icon:`○`,cls:`text-text-subtle`}};function pr({projectName:e,sessionId:t,messages:n}){let r=(0,Q.useMemo)(()=>dr(n),[n]),i=lr(e,t,r>0,r),[a,o]=(0,Q.useState)(!0);if(i.length===0||i.every(e=>e.status===`completed`||e.status===`stopped`))return null;let s=i.filter(e=>e.status===`completed`).length,c=i.length,l=c?Math.round(s/c*100):0;return(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-border bg-surface/60 backdrop-blur-sm`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex items-center gap-2 w-full px-3 min-h-11 text-left text-xs hover:bg-surface transition-colors`,children:[a?(0,$.jsx)(P,{className:`size-3.5 shrink-0`}):(0,$.jsx)(S,{className:`size-3.5 shrink-0`}),(0,$.jsx)(pe,{className:`size-3.5 shrink-0 text-text-secondary`}),(0,$.jsx)(`span`,{className:`text-text-primary font-medium`,children:`Tasks`}),(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[s,`/`,c,` done`]}),(0,$.jsx)(`span`,{className:`ml-auto h-1 w-16 rounded-full bg-border overflow-hidden shrink-0`,children:(0,$.jsx)(`span`,{className:`block h-full bg-success/70`,style:{width:`${l}%`}})})]}),!a&&(0,$.jsx)(`ul`,{className:`px-3 pb-2 space-y-0.5 max-h-48 overflow-y-auto`,children:i.map(e=>(0,$.jsx)(mr,{task:e},e.id))})]})}function mr({task:e}){let t=fr[e.status]??fr.pending,n=e.status===`in_progress`;return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-xs rounded px-1 ${n?`bg-warning/10`:``}`,children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5 ${t.cls}`,children:t.icon}),(0,$.jsx)(`span`,{className:e.status===`completed`?`line-through text-text-subtle`:n?`text-text-primary font-medium`:`text-text-secondary`,children:e.subject||(0,$.jsxs)(`span`,{className:`text-text-subtle italic`,children:[`#`,e.id,` (no title)`]})})]})}var hr=/read the full transcript at:\s*(\S+\.jsonl)/i;function gr(e){return e.match(hr)?.[1]?.trim()??null}var _r=class extends Q.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:this.props.fallbackContent?(0,$.jsx)(`div`,{className:`text-sm whitespace-pre-wrap break-words text-text-primary opacity-80`,children:this.props.fallbackContent}):null:this.props.children}},vr=Te(()=>import(`./markdown-renderer-56wMzGkr.js`),__vite__mapDeps([4,5,1,6,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42])),yr=(0,Q.lazy)(()=>vr.then(e=>({default:e.MarkdownRenderer}))),br=/<teammate-message[^>]*>[\s\S]*?<\/teammate-message>/g;function xr(e){return e.replace(br,``).replace(/\n{3,}/g,`
|
|
3
|
-
|
|
4
|
-
`).trim()}function Sr({content:e,projectName:t,isStreaming:n}){let r=xr(e);return r?(0,$.jsx)(_r,{fallbackContent:r,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded`}),children:(0,$.jsx)(yr,{content:r,projectName:t,codeActions:!0,isStreaming:n})})}):null}function Cr({group:e,onNavigate:t,disabled:n}){if(!e||e.ids.length<2)return null;let{ids:i,currentIndex:a}=e,o=e=>{let r=i[e];r&&!n&&t(r)};return(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-xs text-text-subtle select-none`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(a-1),disabled:n||a<=0,"aria-label":`Previous version`,className:`flex items-center justify-center rounded p-0.5 hover:text-text-primary disabled:opacity-30 disabled:cursor-default`,children:(0,$.jsx)(r,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[a+1,`/`,i.length]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(a+1),disabled:n||a>=i.length-1,"aria-label":`Next version`,className:`flex items-center justify-center rounded p-0.5 hover:text-text-primary disabled:opacity-30 disabled:cursor-default`,children:(0,$.jsx)(P,{className:`size-3.5`})})]})}var wr={"system-reminder":`Context`,claudeMd:`CLAUDE.md`,gitStatus:`Git Status`,currentDate:`Date`,fast_mode_info:`Fast Mode`,"available-deferred-tools":`Tools`,"task-notification":`Task Result`,environment_details:`Environment`,"local-command-caveat":`System`};function Tr(e){let t=[],n=/<(system-reminder|available-deferred-tools|antml:[\w-]+|fast_mode_info|claudeMd|gitStatus|currentDate|task-notification|environment_details|local-command-caveat)[^>]*>([\s\S]*?)<\/\1>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1];t.push({name:e,label:wr[e]??e.replace(/^antml:/,``).replace(/-/g,` `),content:r[2].trim()})}return{cleanText:e.replace(n,``).trim(),tags:t}}function Er(e){let t=e.match(/<command-name>([\s\S]*?)<\/command-name>/);if(!t)return{command:null,cleanText:e};let n=t[1].trim(),r=e.match(/<command-args>([\s\S]*?)<\/command-args>/)?.[1]?.trim()||void 0,i=e.replace(/<command-name>[\s\S]*?<\/command-name>/g,``).replace(/<command-message>[\s\S]*?<\/command-message>/g,``).replace(/<command-args>[\s\S]*?<\/command-args>/g,``).trim();return{command:{name:n,args:r},cleanText:i}}function Dr(e){let t=e.match(/^Use the (\S+) agent to\s?/);return t?{agent:t[1],cleanText:e.slice(t[0].length)}:{agent:null,cleanText:e}}function Or(e){let t=/<ide_opened_file>([\s\S]*?)<\/ide_opened_file>/g.exec(e);return t?{idePath:t[1].match(/opened the file (.+?) in the IDE/)?.[1]?.trim()??null,cleanText:e.replace(/<ide_opened_file>[\s\S]*?<\/ide_opened_file>/g,``).trim()}:{idePath:null,cleanText:e}}function kr(e){let t=[],n=e;for(;;){let e=n.match(/^\[Attached image \(contents included in this message\): (.+?)\]\n*/);if(e){t.push(e[1]),n=n.slice(e[0].length);continue}break}if(t.length>0){let e=kr(n);return{files:[...t,...e.files],text:e.text}}let r=n.match(/^\[Attached file: (.+?)\]\n*/);if(r)return{files:[r[1]],text:n.slice(r[0].length)};let i=n.match(/^\[Attached files:\n([\s\S]+?)\]\n*/);return i?{files:i[1].split(`
|
|
5
|
-
`).map(e=>e.trim()).filter(Boolean),text:n.slice(i[0].length)}:{files:[],text:n}}function Ar(e){let t=[],n=e,r=/^```(?:bash|sh|shell|zsh)\n([\s\S]*?)\n```\s*(?:\n\n?)?/,i;for(;(i=n.match(r))!==null;)t.push(i[1]),n=n.slice(i[0].length);return{blocks:t,remainingText:n.trim()}}function jr(e){let{idePath:t,cleanText:n}=Or(e),{blocks:r,remainingText:i}=Ar(n),a=kr(i),{cleanText:o,tags:s}=Tr(a.text.replace(/<local-command-(?:stdout|stderr)>([\s\S]*?)<\/local-command-(?:stdout|stderr)>/g,`$1`)),{command:c,cleanText:l}=Er(o),{agent:u,cleanText:d}=Dr(l),f=c?.args?d?`${c.args}\n\n${d}`:c.args:d;return{files:a.files,text:f,body:d,tags:s,command:c,terminalBlocks:r,idePath:t,agent:u}}function Mr(e){let{agent:t,body:n,command:r}=jr(e);if(!r)return{agent:t,text:n};let i=`/${r.name.replace(/^\/+/,``)}${r.args?` ${r.args}`:``}`;return{agent:t,text:n?`${i}\n\n${n}`:i}}var Nr=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`]);function Pr(e,t){let n=De(e);return`/api/project/${encodeURIComponent(t??`_`)}/chat/uploads/${encodeURIComponent(n)}`}function Fr(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Nr.has(e.slice(t).toLowerCase())}var Ir=new Map;function Lr(e){let[t,n]=(0,Q.useState)(()=>Ir.get(e)?.url??null),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let t=Ir.get(e);if(t){n(t.url);return}let r=!1,a=Se();return fetch(e,{headers:a?{Authorization:`Bearer ${a}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(t=>{if(r)return;let i=URL.createObjectURL(t);Ir.set(e,{url:i}),n(i)}).catch(()=>{r||i(!0)}),()=>{r=!0}},[e]),{blobUrl:t,error:r}}function Rr({filePath:e,projectName:t}){let{blobUrl:n,error:r}=Lr(Pr(e,t)),i=rt(e=>e.open),a=De(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>n&&i(n,a,ht(e.currentTarget)),className:`flex items-center gap-1 rounded-md border border-border/60 bg-background/40 px-1.5 py-0.5 text-[11px] text-text-secondary hover:bg-surface transition-colors cursor-pointer`,children:[n?(0,$.jsx)(`img`,{src:n,alt:a,[gt]:``,className:`size-4 rounded-sm object-cover shrink-0`}):r?(0,$.jsx)(f,{className:`size-3 shrink-0`}):(0,$.jsx)(`div`,{className:`size-4 rounded-sm bg-surface animate-pulse shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:a})]})}var zr=new Set([`task-notification`,`environment_details`,`local-command-caveat`]);function Br({content:e,messageId:t,timestamp:n,projectName:r,onFork:i,onEdit:a,isEditing:o,sessionId:s,providerId:c,versionGroup:l,onNavigateVersion:u,versionNavDisabled:d}){let{files:f,text:p,tags:m,command:h,terminalBlocks:g,idePath:_,agent:v}=(0,Q.useMemo)(()=>jr(e),[e]),y=m.some(e=>zr.has(e.name)),[b,x]=(0,Q.useState)(!1),[te,C]=(0,Q.useState)(!1),w=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=w.current;if(!e)return;let t=()=>C(e.scrollHeight>e.clientHeight+2);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[p]),(0,$.jsxs)(`div`,{className:q(`flex flex-col gap-1`,!y&&`items-end`),children:[(0,$.jsxs)(`div`,{"data-user-message":y?void 0:`true`,style:y?void 0:{borderRadius:`var(--rad) var(--rad) 4px var(--rad)`},className:q(`group/user relative px-3 py-2 text-sm border shadow-sm transition-all`,y?`rounded-lg bg-surface/40 border-border/40 text-text-secondary`:`max-w-[80%] bg-accent-wash border-accent-wash-border text-text`,o&&`ring-2 ring-primary/60 border-primary/40`),children:[m.length>0&&(0,$.jsx)(Hr,{tags:m}),v&&(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-sky-500/15 border border-sky-500/25 px-2 py-0.5 text-xs font-medium text-sky-600 dark:text-sky-400`,children:[(0,$.jsx)(B,{className:`size-3 shrink-0`}),v]})}),h&&(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/15 border border-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:[(0,$.jsx)(Mt,{className:`size-3 shrink-0`}),h.name]})}),_&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1 text-[11px] text-text-subtle`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:`Opened in IDE:`}),(0,$.jsx)(Kr,{path:_,projectName:r})]}),f.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>Fr(e)?(0,$.jsx)(Rr,{filePath:e,projectName:r},t):(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-background/40 px-1.5 py-0.5 text-[11px] text-text-secondary`,children:[(0,$.jsx)(V,{className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:De(e)})]},t))}),g.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g.map((e,t)=>(0,$.jsx)(Vr,{content:e},t))}),p&&(0,$.jsx)(`div`,{ref:w,className:q(`whitespace-pre-wrap break-words transition-all duration-200 select-text`,!b&&`line-clamp-2`,b&&`max-h-[50vh] overflow-y-auto`),children:y?(0,$.jsx)(Jr,{text:p,projectName:r}):(0,$.jsx)(qr,{text:p})}),(te||b)&&(0,$.jsx)(`button`,{onClick:()=>x(!b),className:q(`flex items-center gap-1 text-xs mt-1 transition-colors`,y?`text-text-subtle hover:text-text-secondary`:`text-primary/70 hover:text-primary`),children:b?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ee,{className:`size-3`}),`Show less`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S,{className:`size-3`}),`Show more`]})}),!y&&u&&(0,$.jsx)(Cr,{group:l,onNavigate:u,disabled:d})]}),!y&&(0,$.jsxs)(Nn,{timestamp:n,content:e,children:[a&&(0,$.jsx)(jn,{icon:(0,$.jsx)(ie,{className:`size-3.5`}),label:`Edit`,title:`Edit this message (continue in the same tab)`,onClick:a}),i&&(0,$.jsx)(jn,{icon:(0,$.jsx)(se,{className:`size-3.5`}),label:`Fork`,title:`Retry from this message (fork into a new tab)`,onClick:i})]})]})}function Vr({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:q(`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary/50 bg-surface-elevated text-text-primary`:`border-border/60 bg-background/40 text-text-secondary hover:bg-surface`),children:[(0,$.jsx)(a,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:`Terminal output`}),(0,$.jsx)(S,{className:q(`size-3 shrink-0 transition-transform`,t&&`rotate-180`)})]}),t&&(0,$.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto rounded-md border border-border bg-background p-2 text-xs text-text-primary font-mono whitespace-pre-wrap break-words`,children:e})]})}function Hr({tags:e}){return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,$.jsx)(Ur,{tag:e},t))})}function Ur({tag:e}){let[t,n]=(0,Q.useState)(!1);return e.name===`task-notification`?(0,$.jsx)(Gr,{content:e.content}):(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1 rounded-full border border-border/60 bg-surface/50 px-2 py-0.5 text-text-subtle hover:text-text-secondary hover:bg-surface transition-colors`,children:[(0,$.jsx)(s,{className:`size-2.5`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(P,{className:q(`size-2.5 transition-transform`,t&&`rotate-90`)})]}),t&&(0,$.jsx)(`div`,{className:`mt-1 rounded border border-border/40 bg-surface/30 px-2 py-1.5 text-[11px] text-text-subtle/80 whitespace-pre-wrap max-h-40 overflow-y-auto leading-relaxed`,children:e.content})]})}function Wr(e,t){return e.match(RegExp(`<${t}>([\\s\\S]*?)</${t}>`))?.[1]?.trim()||void 0}function Gr({content:e}){let[t,n]=(0,Q.useState)(!1),r=Wr(e,`status`),i=Wr(e,`summary`),a=Wr(e,`output-file`),o=Wr(e,`result`);return(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/50 px-2 py-0.5 text-text-subtle hover:text-text-secondary hover:bg-surface transition-colors`,children:[r===`completed`?(0,$.jsx)(l,{className:`size-2.5 text-success`}):(0,$.jsx)(E,{className:`size-2.5 text-warning`}),(0,$.jsx)(`span`,{className:`truncate max-w-80`,children:i??`Task notification`}),(0,$.jsx)(P,{className:q(`size-2.5 transition-transform shrink-0`,t&&`rotate-90`)})]}),t&&(0,$.jsxs)(`div`,{className:`mt-1 rounded border border-border/40 bg-surface/30 px-2 py-1.5 space-y-1.5`,children:[i&&(0,$.jsx)(`p`,{className:`text-[11px] text-text-secondary`,children:i}),a&&(0,$.jsx)(Kr,{path:a}),o&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-subtle/80 max-h-60 overflow-y-auto leading-relaxed`,children:(0,$.jsx)(Sr,{content:o})})]})]})}function Kr({path:e,projectName:t}){return(0,$.jsxs)(`button`,{type:`button`,onClick:(0,Q.useCallback)(()=>{let n=J.getState().openTab,r=t??Ae.getState().activeProject?.name,i=De(e),a={filePath:e};r&&(a.projectName=r),K.get(`/api/fs/read?path=${encodeURIComponent(e)}`).then(()=>{n({type:`editor`,title:i,metadata:a,projectId:null,closable:!0})}).catch(()=>{n({type:`editor`,title:i,metadata:a,projectId:null,closable:!0})})},[e,t]),className:`inline-flex items-center gap-1 rounded border border-border/50 bg-surface/50 px-1.5 py-0.5 font-mono text-[10px] text-text-secondary hover:text-text-primary hover:bg-surface transition-colors cursor-pointer`,children:[(0,$.jsx)(V,{className:`size-2.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-60`,children:De(e)}),(0,$.jsx)(k,{className:`size-2 shrink-0 opacity-50`})]})}function qr({text:e}){let t=(0,Q.useMemo)(()=>{let t=/(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/g,n=[],r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push({kind:`text`,value:e.slice(r,i.index)}),n.push({kind:`url`,value:i[1]}),r=i.index+i[0].length;return r<e.length&&n.push({kind:`text`,value:e.slice(r)}),n},[e]);return t.every(e=>e.kind===`text`)?(0,$.jsx)($.Fragment,{children:e}):(0,$.jsx)($.Fragment,{children:t.map((e,t)=>e.kind===`url`?(0,$.jsx)(`a`,{href:e.value,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline underline-offset-2 hover:text-primary/80 break-all`,onClick:e=>e.stopPropagation(),children:e.value},t):(0,$.jsx)(`span`,{children:e.value},t))})}function Jr({text:e,projectName:t}){return(0,$.jsx)($.Fragment,{children:(0,Q.useMemo)(()=>{let t=/(\/(?:[\w.\-]+\/)+[\w.\-]+)/g,n=[],r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push({kind:`text`,value:e.slice(r,i.index)}),n.push({kind:`path`,value:i[1]}),r=i.index+i[0].length;return r<e.length&&n.push({kind:`text`,value:e.slice(r)}),n},[e]).map((e,n)=>e.kind===`path`?(0,$.jsx)(Kr,{path:e.value,projectName:t},n):(0,$.jsx)(`span`,{children:e.value},n))})}function Yr({events:e,isStreaming:t,projectName:n,bashPartialOutput:r}){let i=[],a=``,o=``;for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`thinking`){a&&=(i.push({kind:`text`,content:a}),``),o+=n.content;continue}if(o&&=(i.push({kind:`thinking`,content:o}),``),n.type===`account_retry`){a&&=(i.push({kind:`text`,content:a}),``);let e=n.accountLabel??`another account`,t=n.reason??`Auth failed`;i.push({kind:`text`,content:`\n\n> ↻ ${t} — retrying with **${e}**...\n\n`});continue}if(n.type===`text`)a+=n.content;else if(n.type===`tool_use`){let e=n.toolUseId,t=e?i.find(t=>t.kind===`tool`&&t.tool.type===`tool_use`&&t.tool.toolUseId===e):void 0;if(t){t.tool=n;continue}a&&=(i.push({kind:`text`,content:a}),``),i.push({kind:`tool`,tool:n})}else n.type===`tool_result`||(a&&=(i.push({kind:`text`,content:a}),``),i.push({kind:`tool`,tool:n}))}o&&i.push({kind:`thinking`,content:o}),a&&i.push({kind:`text`,content:a});let s=e.filter(e=>e.type===`tool_result`);for(let e of s){let t=e.toolUseId;if(t){let n=i.find(e=>e.kind===`tool`&&e.tool.type===`tool_use`&&e.tool.toolUseId===t);if(n){n.result=e;continue}}let n=i.find(e=>e.kind===`tool`&&!e.result);n&&(n.result=e)}for(let e of i)if(e.kind===`tool`&&!e.result&&e.tool.type===`tool_use`){let t=e.tool.result;t&&(e.result={type:`tool_result`,output:t.output,isError:t.isError,exitCode:t.exitCode})}for(let e=0;e<i.length;e++){let n=i[e];if(n.kind===`tool`&&!n.result){let r=!1;if(n.tool.type===`tool_use`&&n.tool.tool===`Read`){let t=n.tool.input?.file_path;t&&(r=i.slice(e+1).some(e=>e.kind===`tool`&&e.result&&e.tool.type===`tool_use`&&e.tool.tool===`Edit`&&e.tool.input?.file_path===t))}n.completed=r||!t}}return(0,$.jsx)($.Fragment,{children:i.map((e,a)=>{if(e.kind===`thinking`)return(0,$.jsx)(Xr,{content:e.content,projectName:n,isStreaming:t&&a===i.length-1},`think-${a}`);if(e.kind===`text`){let r=t&&a===i.length-1;return(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:(0,$.jsx)(Zr,{content:e.content,animate:r,projectName:n})},`text-${a}`)}return(0,$.jsx)(ft,{tool:e.tool,result:e.result,completed:e.completed,projectName:n,bashPartialOutput:r},`tool-${a}`)})})}function Xr({content:e,projectName:t,isStreaming:n}){let[r,i]=(0,Q.useState)(n),a=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{!n&&e.length>0&&i(!1)},[n,e.length]),(0,Q.useEffect)(()=>{n&&r&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[e,n,r]),(0,$.jsxs)(`div`,{className:`rounded border border-border/50 bg-surface/30 text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>i(!r),className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-surface transition-colors text-text-subtle`,children:[n?(0,$.jsx)(R,{className:`size-3 animate-spin`}):(0,$.jsx)(P,{className:`size-3 transition-transform ${r?`rotate-90`:``}`}),(0,$.jsxs)(`span`,{children:[`Thinking`,n?`...`:``]}),!n&&(0,$.jsx)(`span`,{className:`text-text-subtle/50 ml-auto`,children:e.length>100?`${Math.round(e.length/4)} tokens`:``})]}),r&&(0,$.jsx)(`div`,{ref:a,className:`max-h-60 overflow-y-auto`,children:(0,$.jsx)(`div`,{className:`px-2 pb-2 text-text-subtle/80 text-[11px] leading-relaxed`,children:(0,$.jsx)(Sr,{content:e,projectName:t,isStreaming:n})})})]})}function Zr({content:e,animate:t,projectName:n}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Sr,{content:e,projectName:n,isStreaming:t}),t&&(0,$.jsx)(`span`,{className:`text-text-subtle text-sm animate-pulse`,children:`Thinking...`})]})}function Qr({lastMessage:e,phase:t,elapsed:n,statusMessage:r}){let i=!e||e.role!==`assistant`,a=e?.events?.length?e.events[e.events.length-1].type===`tool_result`:!1;return!r&&!i&&!a?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-text-subtle`,children:[(0,$.jsx)(R,{className:`size-3 animate-spin`}),(0,$.jsxs)(`span`,{children:[r||(t===`initializing`?`Initializing`:t===`connecting`?`Connecting`:t===`thinking`?`Thinking`:`Processing`),i&&(n??0)>0&&(0,$.jsxs)(`span`,{className:`text-text-subtle/60`,children:[`... (`,n,`s)`]})]})]}),t===`connecting`&&(n??0)>=30&&(0,$.jsx)(`p`,{className:`text-xs text-warning/80 ml-5`,children:`Taking longer than usual — may be rate-limited or API slow. Try sending a new message to retry.`})]})}function $r({projectName:e,onSelectSession:t}){return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-6 text-text-secondary overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 px-4 w-full`,children:[(0,$.jsx)(B,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Send a message to start a new conversation`}),(0,$.jsx)(vt,{compact:!0})]}),(0,$.jsx)(Re,{projectName:e,onSelectSession:t,className:`w-full px-4`})]})}var ei=3200,ti=1e3,ni={hasAbove:!1,atBottom:!0,idx:0,total:0};function ri({scrollElement:e,userIndices:t,scrollToBottom:n}){let r=Y(),[i,a]=(0,Q.useState)(ni),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(0),d=(0,Q.useRef)(ei),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(!1),h=(0,Q.useRef)(!1),g=(e,t,n)=>t.getBoundingClientRect().top-n+e.scrollTop,_=(0,Q.useCallback)(e=>Array.from(e.querySelectorAll(`[data-msg-index]`)).filter(e=>t.includes(Number(e.dataset.msgIndex))),[t]);(0,Q.useEffect)(()=>{let t=e;if(!t)return;let n=0,r=()=>{let e=t.scrollTop,n=t.getBoundingClientRect().top,r=_(t).map(e=>g(t,e,n)),i=0;for(let t=0;t<r.length;t++)r[t]<=e+12&&(i=t+1);let o={hasAbove:r.some(t=>t<e-4),atBottom:t.scrollHeight-e-t.clientHeight<8,idx:i,total:r.length};a(e=>e.hasAbove===o.hasAbove&&e.atBottom===o.atBottom&&e.idx===o.idx&&e.total===o.total?e:o)},i=()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(r)};r(),t.addEventListener(`scroll`,i,{passive:!0});let o=new ResizeObserver(i);return o.observe(t),()=>{n&&cancelAnimationFrame(n),t.removeEventListener(`scroll`,i),o.disconnect()}},[e,_]),(0,Q.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>s(!1),d.current);return()=>clearTimeout(e)},[o,i.idx,c]),(0,Q.useEffect)(()=>{if(!o||!h.current)return;h.current=!1;let e=f.current;(e?.querySelector(`button:not(:disabled)`)??e)?.focus()},[o]),(0,Q.useEffect)(()=>{o||!m.current||(m.current=!1,p.current?.focus())},[o]);let v=(0,Q.useCallback)(()=>{d.current=ei,l(e=>e+1)},[]),y=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let n=t.scrollTop,r=t.getBoundingClientRect().top,i;for(let e of _(t)){let a=g(t,e,r);if(a<n-4)i=a;else break}i!=null&&t.scrollTo({top:i,behavior:`auto`}),v()},[e,_,v]),b=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let r=t.scrollTop,i=t.getBoundingClientRect().top,a=_(t).map(e=>g(t,e,i)).find(e=>e>r+4);a==null?n({animation:`instant`}):t.scrollTo({top:a,behavior:`auto`}),v()},[e,_,n,v]),x=(0,Q.useCallback)(()=>{n({animation:`instant`}),v()},[n,v]);(0,Q.useEffect)(()=>{let t=e;if(!t)return;let n=e=>()=>{In(t)&&(e(),d.current=ti,s(!0))},r=n(y),i=n(b);return window.addEventListener(`chat-nav-prev`,r),window.addEventListener(`chat-nav-next`,i),()=>{window.removeEventListener(`chat-nav-prev`,r),window.removeEventListener(`chat-nav-next`,i)}},[e,y,b]);let te=q(`w-[34px] flex items-center justify-center rounded-[9px] text-text-secondary`,`motion-safe:transition-colors hover:bg-surface-elevated hover:text-foreground`,`disabled:opacity-30 disabled:cursor-default disabled:hover:bg-transparent disabled:hover:text-text-secondary`,r?`h-9`:`h-[30px]`);return(0,$.jsx)(`div`,{className:`absolute bottom-3 right-2.5 z-10 flex flex-col items-end gap-1.5`,children:o?(0,$.jsxs)(`div`,{ref:f,tabIndex:-1,className:`flex flex-col p-[3px] rounded-xl border border-border bg-surface-elevated/95 backdrop-blur-[8px] shadow-lg outline-none`,onFocus:()=>{m.current=!0},onKeyDown:e=>{e.key===`Escape`&&s(!1)},children:[(0,$.jsx)(`button`,{type:`button`,onClick:y,disabled:!i.hasAbove,"aria-label":`Jump to previous message`,className:te,children:(0,$.jsx)(ee,{className:`size-[15px]`})}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] font-medium text-text-subtle text-center py-px`,"aria-label":`Message ${i.idx||1} of ${i.total}`,children:i.total?`${i.idx||1}/${i.total}`:`0/0`}),(0,$.jsx)(`button`,{type:`button`,onClick:b,disabled:i.atBottom,"aria-label":`Jump to next message`,className:te,children:(0,$.jsx)(S,{className:`size-[15px]`})}),(0,$.jsx)(`button`,{type:`button`,onClick:x,disabled:i.atBottom,"aria-label":`Jump to latest`,className:te,children:(0,$.jsx)(u,{className:`size-[13px]`})})]}):(0,$.jsx)(`button`,{ref:p,type:`button`,onClick:()=>{d.current=ei,h.current=!0,s(!0)},"aria-label":`Navigate messages`,"aria-expanded":!1,title:`Navigate messages`,className:q(`group flex items-center justify-center`,r?`size-11`:`size-[30px]`),children:(0,$.jsx)(`span`,{className:q(`flex items-center justify-center rounded-full border border-border bg-surface-elevated/55 backdrop-blur-[6px] text-text-subtle`,`motion-safe:transition-colors group-hover:bg-surface-elevated group-hover:text-foreground`,r?`size-9`:`size-[30px]`),children:(0,$.jsx)(w,{className:`size-[15px]`})})})})}function ii(e){let[t,n]=(0,Q.useState)({}),[r,i]=(0,Q.useState)({}),[a,o]=(0,Q.useState)(0),s=(0,Q.useCallback)((e,t)=>{n(n=>({...n,[e]:[t]})),i(t=>({...t,[e]:``}))},[]),c=(0,Q.useCallback)((e,t)=>{n(n=>{let r=n[e]||[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),l=(0,Q.useCallback)((e,t)=>{i(n=>({...n,[e]:t})),t&&n(t=>({...t,[e]:[]}))},[]),u=(0,Q.useCallback)(e=>(t[e]?.length??0)>0||(r[e]?.trim().length??0)>0,[t,r]);return{answers:t,customInputs:r,activeTab:a,setActiveTab:o,handleSingleSelect:s,handleMultiSelect:c,handleCustomInput:l,hasAnswer:u,allAnswered:(0,Q.useMemo)(()=>e.every((e,t)=>u(t)),[e,u]),getFinalAnswer:(0,Q.useCallback)(e=>r[e]?.trim()||(t[e]??[]).join(`, `),[t,r]),goToNextTab:(0,Q.useCallback)(()=>o(t=>Math.min(t+1,e.length-1)),[e.length]),goToPrevTab:(0,Q.useCallback)(()=>o(e=>Math.max(e-1,0)),[])}}function ai(e){let[t,n]=(0,Q.useState)(0),r=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>n(0),[e.activeTab]),(0,Q.useEffect)(()=>{if(!e.enabled)return;let i=r=>{let i=e.customInputRef.current,a=!!i&&i.ownerDocument.activeElement===i;if(!a&&r.key>=`1`&&r.key<=`9`){r.preventDefault();let t=parseInt(r.key)-1;t<e.totalOptions-1&&(n(t),e.onSelectOption(t));return}if(!a&&(r.key===`o`||r.key===`O`||r.key===`0`)){r.preventDefault(),e.customInputRef.current?.focus(),n(e.totalOptions-1);return}if(r.key===`Tab`&&e.questions.length>1){r.preventDefault(),r.shiftKey?e.goToPrevTab():e.goToNextTab();return}if(!a){if(r.key===`ArrowLeft`){r.preventDefault(),e.goToPrevTab();return}if(r.key===`ArrowRight`){r.preventDefault(),e.goToNextTab();return}if(r.key===`ArrowUp`){r.preventDefault(),n(e=>Math.max(0,e-1));return}if(r.key===`ArrowDown`){r.preventDefault(),n(t=>Math.min(e.totalOptions-1,t+1));return}if(r.key===` `){r.preventDefault(),e.onSelectOption(t);return}}if(r.key===`Enter`){r.preventDefault(),e.allAnswered?e.onSubmit():e.hasAnswer(e.activeTab)&&e.goToNextTab();return}r.key===`Escape`&&a&&e.customInputRef.current?.blur()},a=r.current;return a&&(a.addEventListener(`keydown`,i),a.setAttribute(`tabindex`,`0`),a.contains(a.ownerDocument.activeElement)||a.focus()),()=>{a?.removeEventListener(`keydown`,i)}},[e,t]),{focusedOption:t,setFocusedOption:n,containerRef:r}}function oi({questions:e,onSubmit:t,onSkip:n}){let r=(0,Q.useRef)(null),i=ii(e),a=e[i.activeTab],o=a?a.options.length+1:0,s=e.length>1,c=(0,Q.useCallback)(()=>{if(!i.allAnswered)return;let n={};e.forEach((e,t)=>{n[e.question]=i.getFinalAnswer(t)}),t(n)},[i.allAnswered,i.getFinalAnswer,e,t]),l=(0,Q.useCallback)(e=>{if(!(!a||e<0))if(e<a.options.length){let t=a.options[e]?.label;if(!t)return;a.multiSelect?i.handleMultiSelect(i.activeTab,t):i.handleSingleSelect(i.activeTab,t)}else e===a.options.length&&r.current?.focus()},[a,i]),u=ai({questions:e,activeTab:i.activeTab,totalOptions:o,allAnswered:i.allAnswered,hasAnswer:i.hasAnswer,onSelectOption:l,goToNextTab:i.goToNextTab,goToPrevTab:i.goToPrevTab,onSubmit:c,customInputRef:r,enabled:!0}),d=(0,Q.useCallback)(e=>{l(e),u.setFocusedOption(e)},[l,u.setFocusedOption]);return(0,$.jsxs)(`div`,{ref:u.containerRef,className:`rounded-lg border-2 border-primary/30 bg-primary/5 p-3 space-y-3 outline-none animate-in slide-in-from-bottom-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm font-medium text-text-primary`,children:[(0,$.jsxs)(`span`,{children:[`AI has `,s?`${e.length} questions`:`a question`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-text-secondary font-normal`,children:[s?`←→ tabs · `:``,`↑↓ options · 1-`,Math.min(o-1,9),` select · Enter submit`]})]}),s&&(0,$.jsx)(`div`,{className:`flex gap-1 p-1 bg-background rounded-md overflow-x-auto border border-border`,children:e.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs whitespace-nowrap transition-all ${i.activeTab===t?`bg-primary text-primary-foreground`:i.hasAnswer(t)?`text-primary bg-transparent`:`text-text-secondary hover:bg-surface-elevated`}`,onClick:()=>{i.setActiveTab(t),u.setFocusedOption(0)},tabIndex:-1,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold ${i.activeTab===t?`bg-white/20`:i.hasAnswer(t)?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:i.hasAnswer(t)?`✓`:t+1}),(0,$.jsx)(`span`,{className:`max-w-[100px] overflow-hidden text-ellipsis`,children:e.header||`Q${t+1}`})]},t))}),a&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[!s&&a.header&&(0,$.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-text-secondary`,children:a.header}),(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:a.question}),a.multiSelect&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-secondary`,children:`Select multiple`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a.options.map((e,t)=>{let n=(i.answers[i.activeTab]||[]).includes(e.label),r=u.focusedOption===t;return(0,$.jsxs)(`div`,{role:`button`,onClick:()=>d(t),className:`text-left flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border transition-all cursor-pointer select-text ${n?`border-primary bg-primary/10 text-text-primary`:`border-border bg-background text-text-secondary hover:border-primary/40 hover:bg-primary/5`} ${r?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded text-[10px] font-semibold shrink-0 mt-px ${n?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:t+1}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.label}),e.description&&(0,$.jsx)(`span`,{className:`text-[11px] text-text-secondary`,children:e.description})]})]},t)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border border-dashed transition-all border-border bg-transparent ${u.focusedOption===o-1?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded bg-surface-elevated text-text-secondary text-[10px] font-semibold shrink-0 mt-px`,children:`O`}),(0,$.jsx)(`input`,{ref:r,type:`text`,className:`flex-1 px-2 py-1 text-xs bg-surface border border-border rounded text-text-primary outline-none placeholder:text-text-subtle focus:border-primary`,placeholder:`Other (press O to type)...`,value:i.customInputs[i.activeTab]||``,onChange:e=>i.handleCustomInput(i.activeTab,e.target.value),onFocus:()=>u.setFocusedOption(o-1)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToPrevTab,disabled:i.activeTab===0,tabIndex:-1,children:`← Prev`}),(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToNextTab,disabled:i.activeTab===e.length-1,tabIndex:-1,children:`Next →`})]}),(0,$.jsx)(`button`,{onClick:n,className:`px-4 py-1.5 rounded border border-border bg-background text-text-secondary text-xs hover:bg-surface-elevated transition-colors`,tabIndex:-1,children:`Skip`}),(0,$.jsxs)(`button`,{onClick:c,disabled:!i.allAnswered,className:`px-4 py-1.5 rounded bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,tabIndex:-1,children:[`Submit `,i.allAnswered?`✓`:`(${e.filter((e,t)=>i.hasAnswer(t)).length}/${e.length})`]})]})]})}function si(){return(0,$.jsxs)(`div`,{className:`px-4 pt-4 space-y-4`,"aria-busy":`true`,"aria-label":`Loading previous conversation`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 text-xs text-text-secondary`,children:[(0,$.jsx)(R,{className:`size-3 animate-spin`}),`Loading previous conversation…`]}),[0,1,2].map(e=>(0,$.jsx)(`div`,{className:e%2==0?`flex justify-end`:`flex justify-start`,children:(0,$.jsxs)(`div`,{className:`animate-pulse space-y-2 rounded-lg bg-surface p-3 ${e%2==0?`w-1/2`:`w-3/4`}`,children:[(0,$.jsx)(`div`,{className:`h-3 rounded bg-border`}),(0,$.jsx)(`div`,{className:`h-3 w-5/6 rounded bg-border`}),e%2==1&&(0,$.jsx)(`div`,{className:`h-3 w-2/3 rounded bg-border`})]})},e))]})}function ci({messages:e,messagesLoading:t,keepStaleWhileLoading:n,pendingApproval:r,onApprovalResponse:i,isStreaming:a,phase:o,onSelectSession:s,connectingElapsed:c,statusMessage:l,compactStatus:u,projectName:d,onFork:f,onEdit:p,editingMsgId:m,sessionId:h,providerId:g,onNavigateVersion:_,versionMap:v,bashPartialOutput:y,onExpandCompact:b,isCompactExpanded:ee,onDismissMessage:x,onClearErrors:S}){let{scrollRef:te,contentRef:C,scrollToBottom:w,stopScroll:ne,isAtBottom:re}=sn({initial:`instant`,resize:`instant`}),T=(0,Q.useMemo)(()=>e.filter(e=>{let t=e.content&&e.content.trim().length>0,n=e.events&&e.events.length>0;return e.role===`user`?t:t||n}),[e]),ie=(0,Q.useMemo)(()=>en(T),[T]),ae=!!r||a,[D,oe]=(0,Q.useState)(null),se=(0,Q.useCallback)(e=>{te(e),oe(e)},[te]),O=(0,Q.useRef)(new Map),ce=(0,Q.useMemo)(()=>{let e=O.current,t=new Map;for(let n=0;n<T.length;n++){let r=T[n];if(r.role!==`assistant`||T[n+1]?.role===`assistant`)continue;let i=`${r.id}:${r.events?.length??0}`,a=e.get(i);a||(a=On(kn(T,n)),e.set(i,a)),a.length>0&&t.set(n,a)}return t},[T]),le=(0,Q.useRef)(null),k=(0,Q.useCallback)(e=>{D&&(le.current?.(),le.current=yn(D,e))},[D]);(0,Q.useEffect)(()=>()=>le.current?.(),[]);let[A,ue]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),N=(0,Q.useRef)(null);(0,Q.useLayoutEffect)(()=>{let e=D;e&&N.current!=null&&(e.scrollTop=e.scrollHeight-N.current,A||(N.current=null))},[T.length,D,A]),(0,Q.useLayoutEffect)(()=>{D&&w({animation:`instant`})},[h,D]);let de=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{D&&D.clientHeight>0&&(de.current=re)},[re,D]),(0,Q.useEffect)(()=>{let e=D;if(!e)return;let t=e.clientHeight,n=new ResizeObserver(()=>{let n=e.clientHeight,r=t===0&&n>0;t=n,r&&!de.current&&ne()});return n.observe(e),()=>n.disconnect()},[D,ne]);let P=(0,Q.useCallback)((e,t)=>{f?.(e,t)},[f]),fe=(0,Q.useCallback)((e,t,n)=>{p?.(e,t,n)},[p]),pe=(0,Q.useCallback)(e=>{x?.(e)},[x]),me=(0,Q.useMemo)(()=>T.reduce((e,t)=>t.role===`system`?e+1:e,0),[T]),F=(0,Q.useMemo)(()=>T.reduce((e,t,n)=>(t.role===`user`&&e.push(n),e),[]),[T]),I=(0,Q.useCallback)(()=>{if(!b||!ee)return null;for(let e of T){if(ee(e.id))continue;let t=gr(e.content||``);if(t)return{id:e.id,jsonlPath:t};if(e.events){for(let t of e.events)if(t.type===`text`){let n=gr(t.content||``);if(n)return{id:e.id,jsonlPath:n}}}}return null},[T,b,ee])(),L=!!I,ge=I?.id??null,R=I?.jsonlPath??null,z=(0,Q.useCallback)(async()=>{if(!ge||!R||!b||A)return;let e=D;N.current=e?e.scrollHeight-e.scrollTop:null,ue(!0),M(null);try{await b(ge,R)}catch(e){M(e instanceof Error?e.message:`Could not load previous conversation`)}finally{ue(!1)}},[ge,R,b,A,D]),V=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=D,t=V.current;if(!e||!t||!L||j)return;let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&z()},{root:e,rootMargin:`400px 0px 0px 0px`});return n.observe(t),()=>n.disconnect()},[D,L,j,z]),t&&(!n||e.length===0)?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(B,{className:`size-10 text-text-subtle animate-pulse`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Loading messages...`})]}):e.length===0&&!a?(0,$.jsx)($r,{projectName:d||``,onSelectSession:s||(()=>{})}):(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,$.jsx)(pr,{projectName:d,sessionId:h,messages:e}),me>1&&S&&(0,$.jsx)(`div`,{className:`absolute top-2 left-0 right-0 z-20 flex justify-center pointer-events-none`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:S,className:`pointer-events-auto flex items-center gap-1.5 rounded-full bg-error/15 border border-error/25 px-3 py-1 text-xs text-error hover:bg-error/25 shadow-md backdrop-blur-sm`,children:[(0,$.jsx)(E,{className:`size-3.5`}),`Clear all errors (`,me,`)`]})}),!A&&j&&(0,$.jsx)(`div`,{className:`absolute top-2 left-0 right-0 z-10 flex justify-center`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{M(null),z()},className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-3 py-2 text-xs text-text-primary hover:bg-surface-hover min-h-[44px] md:min-h-0`,children:[(0,$.jsx)(he,{className:`size-3.5 text-destructive`}),(0,$.jsxs)(`span`,{children:[`Could not load previous conversation: `,j]}),(0,$.jsx)(`span`,{className:`underline`,children:`Retry`})]})}),(0,$.jsx)(`div`,{ref:se,[mt]:``,className:`flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none]`,style:{WebkitOverflowScrolling:`touch`,overscrollBehavior:`contain`},children:(0,$.jsxs)(`div`,{ref:C,className:`w-full`,children:[L&&(0,$.jsx)(`div`,{ref:V,"aria-hidden":!0,className:`h-px`}),A&&(0,$.jsx)(si,{}),T.map((e,t)=>{let n=t>0?T[t-1]:void 0,r=ie[t]??0,i=r?v?.[r]:void 0,o=e.role===`user`&&m!=null&&e.id===m,s=T[t+1],c=e.role===`assistant`&&s?.role!==`assistant`,l;if(c){let e=[];for(let n=t;n>=0&&T[n].role===`assistant`;n--){let t=li(T[n]);t&&e.unshift(t)}l=e.join(`
|
|
6
|
-
|
|
7
|
-
`)}return(0,$.jsx)(`div`,{"data-msg-index":t,className:`px-4 pt-4 select-none`,children:(0,$.jsx)(_r,{fallbackContent:e.content,children:(0,$.jsx)(ui,{message:e,isStreaming:a&&e.id.startsWith(`streaming-`),isLastAssistantInTurn:c,turnCopyText:l,turnChanges:c?ce.get(t):void 0,onJumpToEdit:k,projectName:d,onFork:e.role===`user`&&f?P:void 0,onEdit:e.role===`user`&&p?fe:void 0,isEditing:o,onDismiss:e.role===`system`&&x?pe:void 0,prevMsgId:n?.sdkUuid??n?.id,sessionId:h,providerId:g,versionGroup:i,onNavigateVersion:_,versionNavDisabled:a,bashPartialOutput:y})})},e.id)}),ae&&(0,$.jsxs)(`div`,{className:`px-4 pt-4 pb-4 space-y-4 select-none`,children:[r&&(r.tool===`AskUserQuestion`?(0,$.jsx)(fi,{approval:r,onRespond:i}):(0,$.jsx)(di,{approval:r,onRespond:i})),a&&(0,$.jsx)(Qr,{lastMessage:e[e.length-1],phase:o,elapsed:c,statusMessage:u===`compacting`?`Compacting messages...`:l})]})]})}),(0,$.jsx)(ri,{scrollElement:D,userIndices:F,scrollToBottom:w})]})}function li(e){return e.events?.length?e.events.filter(e=>e.type===`text`).map(e=>e.content).join(``):e.content}var ui=(0,Q.memo)(function({message:e,isStreaming:t,isLastAssistantInTurn:n,turnCopyText:r,turnChanges:i,onJumpToEdit:a,projectName:o,onFork:s,onEdit:c,isEditing:l,onDismiss:u,prevMsgId:d,sessionId:f,providerId:p,versionGroup:m,onNavigateVersion:h,versionNavDisabled:g,bashPartialOutput:_}){if(e.role===`user`){let t=s?()=>s(e.content,d):void 0,n=c?()=>c(e.content,d,e.id):void 0;return(0,$.jsx)(Br,{content:e.content,messageId:e.id,timestamp:e.timestamp,projectName:o,onFork:t,onEdit:n,isEditing:l,sessionId:f,providerId:p,versionGroup:m,onNavigateVersion:h,versionNavDisabled:g})}return e.role===`system`?(0,$.jsxs)(`div`,{className:`group flex items-center gap-2 rounded-lg bg-error/10 border border-error/20 px-3 py-2 text-sm text-error`,children:[(0,$.jsx)(he,{className:`size-4 shrink-0`}),(0,$.jsx)(`p`,{className:`flex-1`,children:e.content}),u&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(e.id),"aria-label":`Dismiss`,title:`Dismiss`,className:`shrink-0 rounded p-1 text-error/70 hover:text-error hover:bg-error/15 md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(E,{className:`size-4`})})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.events&&e.events.length>0?(0,$.jsx)(Yr,{events:e.events,isStreaming:t,projectName:o,bashPartialOutput:_}):e.content&&(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:(0,$.jsx)(Sr,{content:e.content,projectName:o})}),!t&&n&&e.usage&&(0,$.jsx)(sr,{usage:e.usage}),!t&&n&&(0,$.jsx)(Xn,{timestamp:e.timestamp,content:r??li(e),changes:i,onJumpToEdit:a})]})});function di({approval:e,onRespond:t}){return(0,$.jsxs)(`div`,{className:`rounded-lg border-2 border-warning/40 bg-warning/10 p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-warning text-sm font-medium`,children:[(0,$.jsx)(N,{className:`size-4`}),(0,$.jsx)(`span`,{children:`Tool Approval Required`})]}),(0,$.jsx)(`div`,{className:`text-xs text-text-primary`,children:(0,$.jsx)(`span`,{className:`font-medium`,children:e.tool})}),(0,$.jsx)(`pre`,{className:`text-xs font-mono text-text-secondary overflow-x-auto bg-background rounded p-2 border border-border`,children:JSON.stringify(e.input,null,2)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>t(e.requestId,!0),className:`px-4 py-1.5 rounded bg-success text-white text-xs font-medium hover:bg-success/80 transition-colors`,children:`Allow`}),(0,$.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-error text-white text-xs font-medium hover:bg-error/80 transition-colors`,children:`Deny`})]})]})}function fi({approval:e,onRespond:t}){return(0,$.jsx)(oi,{questions:e.input.questions??[],onSubmit:n=>t(e.requestId,!0,n),onSkip:()=>t(e.requestId,!1)})}function pi({shells:e,onKill:t}){let n=at(e=>e.openPanel),r=e.filter(e=>e.status!==`stopped`);return r.length===0?null:(0,$.jsx)(`div`,{className:`shrink-0 border-b border-border bg-surface-elevated/60 px-2 py-1.5 space-y-1`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[e.status===`stopping`?(0,$.jsx)(R,{className:`size-3.5 shrink-0 animate-spin text-warning`}):(0,$.jsxs)(`span`,{className:`relative flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-emerald-500`})]}),(0,$.jsx)(a,{className:`size-3.5 shrink-0 text-text-secondary`}),(0,$.jsx)(`span`,{className:`flex-1 truncate font-mono text-text-primary`,title:e.command,children:e.command}),e.status===`stopping`&&(0,$.jsx)(`span`,{className:`text-[11px] text-warning shrink-0`,children:`stopping…`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>n(e.shellId),className:`flex items-center justify-center size-8 rounded hover:bg-surface text-text-secondary hover:text-text-primary transition-colors`,"aria-label":`View output`,title:`View output`,children:(0,$.jsx)(me,{className:`size-4`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(e.shellId),disabled:e.status===`stopping`,className:`flex items-center justify-center size-8 rounded hover:bg-surface text-text-secondary hover:text-error transition-colors disabled:opacity-40`,"aria-label":`Stop command`,title:`Stop command`,children:(0,$.jsx)(ye,{className:`size-3.5`})})]},e.shellId))})}function mi(e){if(!e)return;let t=e.split(`:`).pop();return t&&t!==`general-purpose`?t:e}function hi(e,t){if(!e)return;let n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return;let i=Math.floor((r-n)/1e3),a=Math.floor(i/3600),o=Math.floor(i%3600/60);return a>0?`${a}h ${o}m`:o>0?`${o}m`:`${i}s`}function gi(e){return e.lastTool?e.lastToolArg?`${e.lastTool}: ${e.lastToolArg}`:e.lastTool:e.lastNarrative??e.description}function _i({teamName:e,members:t,projectName:n}){let r=yt(),i=t.filter(e=>e.workState===`working`);return!e||i.length===0?null:(0,$.jsx)(`div`,{className:`shrink-0 border-t border-border bg-surface-elevated/60 px-2 py-1.5 space-y-1`,children:i.map(t=>{let i=gi(t),a=hi(t.startedAt),o=mi(t.agentType);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r({teamName:e,memberName:t.name,projectName:n}),className:`flex w-full items-center gap-2 rounded px-1 py-1.5 min-h-[36px] text-left text-xs hover:bg-surface transition-colors`,title:`Open ${t.name}'s work session`,children:[(0,$.jsxs)(`span`,{className:`relative flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-emerald-500`})]}),(0,$.jsx)(T,{className:`size-3.5 shrink-0 text-accent-2`}),(0,$.jsx)(`span`,{className:`font-medium text-text-primary shrink-0`,children:t.name}),!!o&&(0,$.jsx)(`span`,{className:`text-text-3 shrink-0 hidden sm:inline`,children:o}),!!i&&(0,$.jsx)(`span`,{className:`flex-1 truncate text-text-subtle`,title:i,children:i}),!!a&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-text-3 font-mono`,children:a})]},t.name)})})}function vi(e){return e.startsWith(`plugin:`)&&e.slice(e.lastIndexOf(`:`)+1)||e}function yi({needsAuth:e,projectName:t}){let[n,r]=(0,Q.useState)(null),i=we(e=>e.mcpSignInDismissed),a=we(e=>e.dismissMcpSignIn),o=e.filter(e=>!i.includes(e));return(0,$.jsxs)($.Fragment,{children:[o.length>0&&(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-border bg-surface-elevated/60 px-2 py-1.5 text-xs`,children:[(0,$.jsx)(D,{className:`size-3.5 shrink-0 text-warning`}),(0,$.jsx)(`span`,{className:`shrink-0 text-text-secondary`,children:o.length===1?`MCP server needs sign-in:`:`MCP servers need sign-in:`}),(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 gap-1.5 overflow-x-auto`,children:o.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`shrink-0 rounded border border-border bg-background px-2.5 py-1.5 font-medium text-text-primary transition-colors hover:bg-surface max-md:min-h-9`,title:`Sign in to ${e}`,children:vi(e)},e))}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a(o),Ce.info(`Sign-in bar hidden`,{description:`You can still sign in to these MCP servers from AI Resources → MCP. The bar comes back only for a server that is not on this list.`})},className:`flex size-8 shrink-0 items-center justify-center rounded text-text-secondary transition-colors hover:bg-surface hover:text-text-primary max-md:size-10`,"aria-label":`Hide these servers`,title:`Hide these servers`,children:(0,$.jsx)(g,{className:`size-3.5`})})]}),(0,$.jsx)($e,{serverName:n,project:t,onClose:()=>r(null)})]})}var bi=5e3;function xi(e,t){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useCallback)(async e=>{if(e){s(!0);try{let t=await K.get(`/api/teams/${encodeURIComponent(e)}/activity`);if(c.current)return;r(t?.members??[]),a(t?.outbound??[])}catch{}finally{c.current||s(!1)}}},[]);return(0,Q.useEffect)(()=>{if(c.current=!1,!t||!e)return r([]),a([]),()=>{c.current=!0};l(e);let n=setInterval(()=>void l(e),bi);return()=>{c.current=!0,clearInterval(n)}},[e,t,l]),{members:n,outbound:i,loading:o,refresh:(0,Q.useCallback)(()=>void l(e),[l,e])}}function Si(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function Ci(e){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),a=(0,Q.useRef)(null),o=(0,Q.useRef)(``),s=typeof window<`u`&&Si()!==null;return{isListening:t,interimText:r,start:(0,Q.useCallback)(t=>{let r=Si();if(!r)return;a.current?.abort();let s=new r;s.lang=e?.lang??`vi-VN`,s.continuous=!0,s.interimResults=!0,o.current=``,s.onresult=e=>{let n=``,r=``;for(let t=0;t<e.results.length;t++){let i=e.results[t];i.isFinal?r+=i[0].transcript:n+=i[0].transcript}r&&(o.current=r);let a=(o.current+` `+n).trim();i(n),t(a,n.length===0&&o.current.length>0)},s.onend=()=>{n(!1),i(``),o.current&&t(o.current.trim(),!0)},s.onerror=e=>{e.error!==`no-speech`&&e.error!==`aborted`&&console.warn(`[voice-input] error:`,e.error),n(!1),i(``)},a.current=s,s.start(),n(!0)},[e?.lang]),stop:(0,Q.useCallback)(()=>{a.current?.stop(),a.current=null,n(!1),i(``)},[]),supported:s}}var wi=2e3;function Ti(e,t,n=wi){if(!(e>0)||!(t>0))return null;let r=Math.max(e,t);if(r<n)return null;let i=n-1,a=i/r;return{width:e>=t?i:Math.max(1,Math.round(e*a)),height:t>e?i:Math.max(1,Math.round(t*a))}}var Ei=4096;function Di(e,t){let n=new TextEncoder().encode(t);outer:for(let t=0;t+n.length<=e.length;t++){for(let r=0;r<n.length;r++)if(e[t+r]!==n[r])continue outer;return!0}return!1}function Oi(e,t){return e===`image/gif`?!0:e===`image/webp`?Di(t,`ANIM`):e===`image/png`||e===`image/apng`?Di(t,`acTL`):!1}async function ki(e){if(e.type===`image/gif`)return!0;if(e.type!==`image/webp`&&e.type!==`image/png`&&e.type!==`image/apng`)return!1;try{let t=new Uint8Array(await e.slice(0,Ei).arrayBuffer());return Oi(e.type,t)}catch{return!0}}var Ai=1600,ji=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function Mi(e){return e===`image/jpeg`||e===`image/webp`?e:`image/png`}async function Ni(e,t=Ai){let n={kind:`asis`,file:e};if(!e.type.startsWith(`image/`)||e.type===`image/svg+xml`||typeof createImageBitmap!=`function`||typeof document>`u`)return n;let r;try{r=await createImageBitmap(e)}catch{return n}let i={width:r.width,height:r.height},a=Ti(i.width,i.height,t+1);if(a&&await ki(e))return r.close?.(),Math.max(i.width,i.height)<2e3&&ji.has(e.type)?{kind:`inlineable`,file:e,from:i}:{kind:`asis`,file:e,from:i};if(!a)return r.close?.(),ji.has(e.type)?{kind:`inlineable`,file:e,from:i}:{kind:`asis`,file:e,from:i};let o=r;try{try{o=await createImageBitmap(e,{resizeWidth:a.width,resizeHeight:a.height,resizeQuality:`high`}),r.close?.()}catch{o=r}let t=document.createElement(`canvas`);t.width=a.width,t.height=a.height;let n=t.getContext(`2d`);if(!n)return{kind:`asis`,file:e,from:i};n.imageSmoothingEnabled=!0,n.imageSmoothingQuality=`high`,n.drawImage(o,0,0,a.width,a.height);let s=Mi(e.type),c=await new Promise(e=>t.toBlob(e,s,.92));if(!c||c.size===0)return{kind:`asis`,file:e,from:i};let l=s===e.type?e.name:e.name.replace(/\.[^.]+$/,``)+`.png`;return{kind:`scaled`,file:new File([c],l,{type:s}),from:i,to:a}}catch{return{kind:`asis`,file:e,from:i}}finally{o.close?.()}}var Pi=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function Fi(e){return Pi.has(e.type)}function Ii(e){return e.textContent?`expand`:e.previewUrl?`preview`:`none`}function Li({attachments:e,onRemove:t}){let[n,r]=(0,Q.useState)(null),i=Ve(),o=(0,Q.useRef)(new Map),s=rt(e=>e.open),c=rt(e=>e.close),l=rt(e=>e.src);if((0,Q.useEffect)(()=>{if(!l)return;let t=o.current.get(l);if(!t)return;let n=e.find(e=>e.id===t);if(!n?.previewUrl)return c();n.previewUrl!==l&&(o.current.set(n.previewUrl,n.id),s(n.previewUrl,n.name))},[e,l,s,c]),e.length===0)return null;let u=n?e.find(e=>e.id===n):null;function d(t,n){if(t.previewUrl){for(let t of e)t.previewUrl&&o.current.set(t.previewUrl,t.id);s(t.previewUrl,t.name,ht(n))}}return(0,$.jsxs)(`div`,{className:`px-2 md:px-4 pt-2`,children:[(0,$.jsx)(`div`,{className:q(`flex flex-wrap gap-1.5`,i&&`gap-y-5`),[mt]:``,children:e.map(e=>(0,$.jsxs)(`div`,{className:q(`flex items-center gap-1.5 rounded-md border border-border bg-surface px-2 py-1 text-xs text-text-secondary max-w-48`,Ii(e)!==`none`&&`cursor-pointer hover:border-primary/50`,n===e.id&&`border-primary/50 bg-surface-elevated`),onClick:t=>{let i=Ii(e);i===`expand`?r(n===e.id?null:e.id):i===`preview`&&d(e,t.currentTarget)},children:[e.previewUrl?(0,$.jsx)(`button`,{type:`button`,title:`Preview ${e.name}`,"aria-label":`Preview ${e.name}`,onClick:t=>{t.stopPropagation(),d(e,t.currentTarget)},className:q(`relative shrink-0 rounded`,`can-hover:hover:ring-2 can-hover:hover:ring-primary/60 transition-shadow`,i&&`before:absolute before:-inset-y-3 before:-inset-x-1.5 before:content-['']`),children:(0,$.jsx)(`img`,{src:e.previewUrl,alt:e.name,[gt]:``,className:`size-5 rounded object-cover`})}):e.textContent?(0,$.jsx)(a,{className:`size-3.5 shrink-0 text-text-subtle`}):e.isImage?(0,$.jsx)(f,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,$.jsx)(V,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.textContent&&(0,$.jsx)(S,{className:q(`size-3 shrink-0 text-text-subtle transition-transform`,n===e.id&&`rotate-180`)}),e.status===`uploading`?(0,$.jsx)(R,{className:`size-3 shrink-0 animate-spin text-text-subtle`}):e.status===`error`?(0,$.jsx)(`span`,{className:`text-error shrink-0`,title:`Upload failed`,children:`!`}):e.resized?(0,$.jsxs)(`span`,{className:`shrink-0 text-[10px] text-text-subtle`,title:`Shrunk from ${e.resized.from.width}x${e.resized.from.height} to ${e.resized.to.width}x${e.resized.to.height}`,children:[e.resized.to.width,`×`,e.resized.to.height]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:i=>{i.stopPropagation(),t(e.id),n===e.id&&r(null)},className:q(`relative shrink-0 rounded-sm p-0.5 hover:bg-border/50 transition-colors`,i&&`before:absolute before:-inset-y-3.5 before:-inset-x-1.5 before:content-['']`),"aria-label":`Remove ${e.name}`,children:(0,$.jsx)(g,{className:`size-3`})})]},e.id))}),u?.textContent&&(0,$.jsx)(`pre`,{className:`mt-1.5 max-h-40 overflow-auto rounded-md border border-border bg-background p-2 text-xs text-text-primary font-mono whitespace-pre-wrap break-words`,children:Ri(u.textContent)})]})}function Ri(e){let t=e.trim(),n=t.match(/^```\w*\n([\s\S]*?)\n```$/);return n?n[1]:t}function zi(e,t,n){if(e.length===0)return null;let r=t+n;return r<-1||r>=e.length?null:{index:r,text:r===-1?``:e[e.length-1-r]}}var Bi=[{id:`default`,label:`Ask before edits`,icon:be,description:`Claude will ask for approval before making each edit`},{id:`acceptEdits`,label:`Edit automatically`,icon:ae,description:`Claude will edit files without asking first`},{id:`plan`,label:`Plan mode`,icon:_,description:`Claude will present a plan before editing`},{id:`bypassPermissions`,label:`Bypass permissions`,icon:oe,description:`Claude will not ask before running commands`}];function Vi(e){return Bi.find(t=>t.id===e)?.label??`Unknown`}function Hi(e){return Bi.find(t=>t.id===e)?.icon??be}function Ui({value:e,onChange:t,open:n,onOpenChange:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)},t=i.current?.ownerDocument??document;return t.addEventListener(`mousedown`,e),()=>t.removeEventListener(`mousedown`,e)},[n,r]),(0,Q.useEffect)(()=>{n&&(a.current=Bi.findIndex(t=>t.id===e),a.current<0&&(a.current=0))},[n,e]);let o=(0,Q.useCallback)(e=>{if(e.key===`Escape`){r(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;a.current=(a.current+t+Bi.length)%Bi.length,(i.current?.querySelector(`[data-idx="${a.current}"]`))?.focus()}if(e.key===`Enter`){e.preventDefault();let n=Bi[a.current];n&&(t(n.id),r(!1))}},[t,r]);return n?(0,$.jsxs)(`div`,{ref:i,role:`listbox`,"aria-label":`Permission modes`,onKeyDown:o,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-72 md:w-80 rounded-lg border border-border popover-solid shadow-[var(--shadow-panel)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-text-secondary`,children:`Modes`}),(0,$.jsx)(`kbd`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-surface-elevated text-text-subtle border border-border`,children:`Shift + Tab`})]}),(0,$.jsx)(`div`,{className:`py-1`,children:Bi.map((n,i)=>{let a=n.icon,o=n.id===e;return(0,$.jsxs)(`button`,{"data-idx":i,role:`option`,"aria-selected":o,tabIndex:0,onClick:()=>{t(n.id),r(!1)},className:`w-full flex items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-surface-elevated focus:bg-surface-elevated focus:outline-none ${o?`bg-surface-elevated`:``}`,children:[(0,$.jsx)(a,{className:`size-4 mt-0.5 shrink-0 text-text-secondary`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-text-primary`,children:n.label}),(0,$.jsx)(`div`,{className:`text-xs text-text-subtle leading-snug`,children:n.description})]}),o&&(0,$.jsx)(H,{className:`size-4 mt-0.5 shrink-0 text-primary`})]},n.id)})})]}):null}var Wi=[{label:`Low`,value:`low`},{label:`Medium`,value:`medium`},{label:`High`,value:`high`,default:!0},{label:`Extra`,value:`xhigh`},{label:`Max`,value:`max`}];function Gi(e){return e?Wi.find(t=>t.value===e)?.label??e:``}function Ki(e,t){let n=Gi(t);return n?`${e} · ${n}`:e}var qi=new Map,Ji=300*1e3;function Yi(e){return e.replace(/^Claude\s+/i,``)}var Xi=Wi.find(e=>e.default).value;function Zi({model:e,effort:t,thinking:n,onModelChange:r,onEffortChange:i,onThinkingChange:a,projectName:o,providerId:s,disabled:c}){let l=JSON.stringify([o,s]),u=qi.get(l),[d,f]=(0,Q.useState)(null),p=d?.projectName===o&&d.providerId===s?d:u?{...u,error:!1}:null,m=p?.models??[],h=!!(o&&s&&!p),g=h?`Loading models...`:p?.error?`Unable to load models`:m.length===0?`No models available`:null,[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=Y();(0,Q.useEffect)(()=>{let e=!0;if(f(null),!o||!s)return;let t=qi.get(l);if(!(t&&Date.now()<t.expiry))return K.get(`${G(o)}/chat/providers/${s}/models`).then(n=>{let r=n.length>0?n:t?.models??n;e&&n.length>0&&qi.set(l,{models:n,expiry:Date.now()+Ji}),e&&f({projectName:o,providerId:s,models:r})}).catch(()=>{e&&f({projectName:o,providerId:s,models:t?.models??[],error:!t})}),()=>{e=!1}},[o,s,l]),(0,Q.useEffect)(()=>{c&&v(!1)},[c]),(0,Q.useEffect)(()=>{if(!_||b)return;let e=e=>{y.current&&!y.current.contains(e.target)&&v(!1)},t=y.current?.ownerDocument??document;return t.addEventListener(`mousedown`,e),()=>t.removeEventListener(`mousedown`,e)},[_,b]);let ee=m.find(t=>t.value===e),x=h?`Loading models...`:ee?Yi(ee.label):`Model`,S=t??Xi,te=m.length>0||!!g,C=Ki(x,S),w=e=>{e(),b||v(!1)},ne=(0,$.jsxs)(`div`,{className:`flex divide-x divide-border`,children:[te&&(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 py-1`,children:[(0,$.jsx)(Qi,{children:`Model`}),g&&(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-2 text-xs text-text-secondary`,children:g}),m.map(t=>(0,$.jsxs)(ea,{active:t.value===e,onClick:()=>w(()=>r(t.value)),children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:Yi(t.label)}),t.value===e&&(0,$.jsx)(H,{className:`size-4 shrink-0 text-primary`})]},t.value))]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 py-1`,children:[(0,$.jsx)(Qi,{children:`Effort`}),Wi.map(e=>(0,$.jsxs)(ea,{active:e.value===S,onClick:()=>w(()=>i(e.value)),children:[(0,$.jsxs)(`span`,{className:`flex-1 truncate`,children:[e.label,e.default&&(0,$.jsx)(`span`,{className:`ml-2 text-xs text-text-subtle`,children:`Default`})]}),e.value===S&&(0,$.jsx)(H,{className:`size-4 shrink-0 text-primary`})]},e.value)),(0,$.jsx)($i,{}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(!n),className:`w-full flex items-center gap-3 px-3 min-h-[44px] text-left text-sm hover:bg-surface-elevated`,role:`switch`,"aria-checked":n,children:[(0,$.jsx)(O,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:`Thinking`}),(0,$.jsx)(`span`,{className:`inline-flex h-5 w-9 items-center rounded-full transition-colors ${n?`bg-primary`:`bg-border`}`,children:(0,$.jsx)(`span`,{className:`h-4 w-4 rounded-full bg-white transition-transform ${n?`translate-x-4`:`translate-x-0.5`}`})})]})]})]});return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:c,onClick:e=>{e.stopPropagation(),c||v(e=>!e)},className:`inline-flex items-center gap-1.5 px-[9px] py-1 rounded-full text-[11.5px] text-primary bg-accent-wash border border-accent-wash-border hover:brightness-110 transition-[filter] disabled:opacity-50 disabled:cursor-default`,"aria-label":`Model ${x}, effort ${S}${n?`, thinking on`:``}`,title:c?`Can't change while running`:C,children:[(0,$.jsx)(ce,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate`,children:C}),n&&(0,$.jsx)(O,{className:`h-3 w-3 shrink-0`})]}),_&&!c&&(b?(0,$.jsx)(Ie,{open:_,onClose:()=>v(!1),children:(0,$.jsx)(`div`,{className:`px-1 pb-2`,children:ne})}):(0,$.jsx)(`div`,{ref:y,role:`listbox`,"aria-label":`Model and thinking`,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute bottom-full left-0 mb-1 z-50 w-80 rounded-lg border border-border popover-solid shadow-[var(--shadow-panel)] max-h-[70vh] overflow-y-auto`,children:ne}))]})}function Qi({children:e}){return(0,$.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-text-secondary`,children:e})}function $i(){return(0,$.jsx)(`div`,{className:`my-1 border-t border-border`})}function ea({active:e,onClick:t,children:n}){return(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`w-full flex items-center gap-3 px-3 min-h-[44px] text-left text-sm text-text-primary transition-colors hover:bg-surface-elevated ${e?`bg-surface-elevated`:``}`,children:n})}var ta=6e4,na=new Map;function ra(e,t,n){let r=`${e}\0${t??``}\0${n??``}`,i=na.get(r);if(i&&Date.now()<i.expiresAt)return i.promise;let a=new URLSearchParams;t&&a.set(`providerId`,t),n&&a.set(`sessionId`,n);let o=a.size>0?`?${a}`:``,s=K.get(`${G(e)}/chat/slash-items${o}`).then(e=>({items:e.items??[],recentNames:e.recentNames??[]})).catch(e=>{throw na.get(r)?.promise===s&&na.delete(r),e});return na.set(r,{promise:s,expiresAt:Date.now()+ta}),s}function ia(e){if(!e){na.clear();return}let t=`${e}\0`;for(let e of na.keys())e.startsWith(t)&&na.delete(e)}async function aa(e){try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``)),r.onerror=()=>n(r.error),r.readAsDataURL(e)}),n=t.indexOf(`,`),r=n>=0?t.slice(n+1):``;return r?{data:r,mediaType:e.type||`image/png`}:void 0}catch{return}}var oa=(0,Q.memo)(function({tabId:e,draftReady:t=!0,onSend:n,isStreaming:r,onCancel:i,disabled:a,projectName:o,onSlashStateChange:s,onSlashItemsLoaded:c,slashSelected:l,onFileStateChange:u,onFileItemsLoaded:d,fileSelected:f,externalFiles:m,externalPaths:h,onExternalPathsConsumed:_,initialValue:v,clearSignal:y,restore:b,onContentChange:ee,getUserHistory:x,autoFocus:S,permissionMode:te,onModeChange:C,providerId:w,sessionId:re,onProviderChange:T,model:ie,onModelChange:E,effort:ae,onEffortChange:D,thinking:oe,onThinkingChange:se}){let O=(0,Q.useRef)(v??``),[ce,le]=(0,Q.useState)(()=>(v??``).trim().length>0),[k,ue]=(0,Q.useState)([]),[j,M]=(0,Q.useState)(null),[N,de]=(0,Q.useState)(!1),[P,fe]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)(`next`),he=(0,Q.useRef)(null),F=(0,Q.useRef)(null),I=(0,Q.useRef)(null),L=(0,Q.useRef)([]),ge=(0,Q.useRef)([]),z=(0,Q.useRef)(0),V=(0,Q.useRef)(!1),H=(0,Q.useRef)(!1),_e=(0,Q.useRef)(typeof CSS>`u`||!CSS.supports(`field-sizing`,`content`)),U=(0,Q.useCallback)(e=>{O.current=e,he.current&&(he.current.value=e),F.current&&(F.current.value=e),le(e.trim().length>0)},[]),W=(0,Q.useCallback)(()=>window.matchMedia(`(min-width: 768px)`).matches?he.current:F.current,[]),be=(0,Q.useRef)(-1),xe=(0,Q.useCallback)(e=>{let t=zi(x?.()??[],be.current,e);if(!t)return!1;be.current=t.index;let{agent:n,text:r}=Mr(t.text);M(n),U(r);let i=W();return i?(i.focus(),requestAnimationFrame(()=>{i.selectionStart=i.selectionEnd=r.length}),_e.current&&(i.style.height=`auto`,i.style.height=Math.min(i.scrollHeight,i===F.current?80:160)+`px`),!0):!0},[x,U,W]),K=Ci(),Ce=(0,Q.useRef)(``),we=(0,Q.useCallback)(e=>{let t=Ce.current;U(t?t+` `+e:e),_e.current&&requestAnimationFrame(()=>{let e=W();e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,160)+`px`)})},[U,W]),Te=(0,Q.useCallback)(()=>{K.isListening?K.stop():(Ce.current=O.current.trim(),K.start(we))},[K.isListening,K.start,K.stop,we]);(0,Q.useEffect)(()=>{let e=()=>{K.supported&&In(W())&&Te()};return window.addEventListener(`toggle-voice-input`,e),()=>window.removeEventListener(`toggle-voice-input`,e)},[K.supported,Te,W]),(0,Q.useEffect)(()=>{let t=t=>{let{text:i,label:o,targetTabId:s,autoSend:c}=t.detail??{};if(!i||(s?s!==e:!In(W())))return;let l=!!c&&!!s&&!a&&!r&&!O.current.trim()&&k.length===0;if(window.dispatchEvent(new CustomEvent(xt,{detail:{sent:l}})),l){n(i,[]);return}let u={id:Ee(),name:o??`Terminal output`,file:new File([],`terminal-output.txt`),isImage:!1,textContent:i,status:`ready`};ue(e=>[...e,u]),W()?.focus()};return window.addEventListener(bt,t),()=>window.removeEventListener(bt,t)},[W,e,a,r,k.length,n]),(0,Q.useEffect)(()=>{v&&!O.current&&(U(v),setTimeout(()=>{let e=he.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)},50))},[v]),(0,Q.useEffect)(()=>{let n=n=>{let i=n.detail;if(!t||a||r||O.current||k.length||j||!e||i?.projectName!==o||i.tabId&&i.tabId!==e||typeof i.text!=`string`)return;let s=ke.getState();!(i.tabId?Object.values(s.panels).some(t=>t.activeTabId===e):s.panels[s.focusedPanelId]?.activeTabId===e)||document.hidden||(U(i.text),ee?.(i.text),W()?.focus())};return window.addEventListener(`ppm:onboarding-prompt`,n),()=>window.removeEventListener(`ppm:onboarding-prompt`,n)},[t,a,r,k.length,j,e,o,ee,U,W]),(0,Q.useEffect)(()=>{y&&U(``)},[y]),(0,Q.useEffect)(()=>{if(!b?.nonce||!b.text)return;let e=O.current,t=e.trim()?`${e}\n\n${b.text}`:b.text;U(t),ee?.(t,k.filter(e=>e.status===`ready`&&e.serverPath).map(e=>({name:e.name,path:e.serverPath}))),setTimeout(()=>{let e=W();e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)},50)},[b?.nonce]),(0,Q.useEffect)(()=>{S&&setTimeout(()=>{W()?.focus()},100)},[]);let q=(0,Q.useCallback)(()=>{if(!o){L.current=[],c?.([],[]);return}ra(o,w,re).then(e=>{L.current=e.items,c?.(e.items,e.recentNames)}).catch(()=>{L.current=[],c?.([],[])})},[o,w,re,c]);(0,Q.useEffect)(()=>{q()},[q]),(0,Q.useEffect)(()=>{let e=()=>{ia(o),q()};return window.addEventListener(`ppm:slash-items-refresh`,e),()=>window.removeEventListener(`ppm:slash-items-refresh`,e)},[q,o]),(0,Q.useEffect)(()=>{let e=()=>{if(!o){ge.current=[],d?.([]);return}let e=Me.getState().fileIndex;ge.current=e,d?.(e)};e();let t=Me.getState().fileIndex,n=Me.getState().indexStatus;return Me.subscribe(r=>{(r.fileIndex!==t||r.indexStatus!==n)&&(t=r.fileIndex,n=r.indexStatus,e())})},[o]),(0,Q.useEffect)(()=>{if(!l)return;let e=W();if(!e)return;let t=e.value,n=e.selectionStart,r=t.slice(0,n),i=t.slice(n),a=e=>e.startsWith(`/`)?``:e[0];if(l.type===`agent`){let t=r.replace(/(?:^|\s)\/\S*$/,a);M(l.name),U(t+i),s?.(!1,``),V.current=!1,e.focus(),setTimeout(()=>{e.selectionStart=e.selectionEnd=t.length},0);return}let o=r.replace(/(?:^|\s)\/\S*$/,e=>`${a(e)}${l.invokeSigil??`/`}${l.name} `);U(o+i),s?.(!1,``),V.current=!1,u?.(!1,``),H.current=!1,e.focus(),setTimeout(()=>{e.selectionStart=e.selectionEnd=o.length},0)},[l]),(0,Q.useEffect)(()=>{if(!f)return;let e=W();if(!e)return;let t=e.value,n=e.selectionStart,r=t.slice(0,n),i=t.slice(n),a=r.match(/@(\S*)$/);if(a){let t=r.length-a[0].length;U(r.slice(0,t)+`@${f.path} `+i);let n=t+f.path.length+2;setTimeout(()=>{e.selectionStart=e.selectionEnd=n,e.focus()},0)}else{let n=t+`@${f.path} `;U(n),setTimeout(()=>{e.selectionStart=e.selectionEnd=n.length,e.focus()},0)}u?.(!1,``),H.current=!1},[f]),(0,Q.useEffect)(()=>{!m||m.length===0||Ae(m)},[m]),(0,Q.useEffect)(()=>{if(!h||h.length===0)return;let e=h.map(e=>`@${e}`).join(` `),t=O.current;U(t+(t.length>0&&!t.endsWith(` `)?` `:``)+e+` `),W()?.focus(),_?.()},[h]);let De=(0,Q.useCallback)(async e=>{if(!o)return;let t=e.split(/[\\/]/).pop();if(t)try{let e={},n=Se();n&&(e.Authorization=`Bearer ${n}`),await fetch(`${G(o)}/chat/uploads/${encodeURIComponent(t)}`,{method:`DELETE`,headers:e})}catch{}},[o]),Oe=(0,Q.useCallback)(async e=>{if(!o)return null;try{let t=new FormData;t.append(`files`,e);let n={},r=Se();r&&(n.Authorization=`Bearer ${r}`);let i=await(await fetch(`${G(o)}/chat/upload`,{method:`POST`,headers:n,body:t})).json();return i.ok&&Array.isArray(i.data)&&i.data.length>0?i.data[0].path:null}catch{return null}},[o]),Ae=(0,Q.useCallback)(async e=>{for(let t of e){let e=Ee(),n=Fi(t),r={id:e,name:t.name,file:t,isImage:n,previewUrl:n?URL.createObjectURL(t):void 0,status:`uploading`};ue(e=>[...e,r]);try{let i=n?await Ni(t):null,a=i?.file??t,o=n&&a!==t?URL.createObjectURL(a):void 0,s=await Oe(a),c=i&&i.kind!==`asis`?await aa(a):void 0,l=!!c&&c.data.length<=Nt.maxBase64PerImage;o&&r.previewUrl&&URL.revokeObjectURL(r.previewUrl),ue(t=>t.map(t=>t.id===e?{...t,file:a,...o&&{previewUrl:o},serverPath:s??void 0,imageData:l?c:void 0,resized:i?.to?{from:i.from,to:i.to}:void 0,status:s||l?`ready`:`error`}:t))}catch{ue(t=>t.map(t=>t.id===e?{...t,status:`error`}:t))}}(F.current??he.current)?.focus()},[Oe]),J=(0,Q.useCallback)(e=>{ue(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),n?.serverPath&&De(n.serverPath),t.filter(t=>t.id!==e)})},[De]),je=(0,Q.useCallback)(()=>{let e=O.current.trim(),t=k.filter(e=>e.status===`ready`);if(!e&&t.length===0&&!j){fe(!1);return}let i=j?`Use the ${j} agent to ${e}`.trimEnd():e;s?.(!1,``),V.current=!1,u?.(!1,``),H.current=!1,K.isListening&&K.stop(),n(i,t,r?pe:void 0),U(``);for(let e of k)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);ue([]),M(null),fe(!1),me(`next`),be.current=-1,_e.current&&(he.current&&(he.current.style.height=`auto`),F.current&&(F.current.style.height=`auto`))},[k,j,n,s,u,r,pe,U]),Y=(0,Q.useCallback)(()=>{if(!a){if(k.some(e=>e.status===`uploading`)){(O.current.trim()||k.some(e=>e.status!==`error`))&&fe(!0);return}je()}},[k,a,je]);(0,Q.useEffect)(()=>{P&&(k.some(e=>e.status===`uploading`)||je())},[P,k,je]);let Ne=(0,Q.useCallback)(e=>{if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),Y();return}if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey){if(!(be.current>=0)&&(e.key===`ArrowDown`||O.current!==``||j))return;xe(e.key===`ArrowUp`?1:-1)&&e.preventDefault();return}if(e.shiftKey&&e.key===`Tab`){e.preventDefault();let t=[`default`,`acceptEdits`,`plan`,`bypassPermissions`],n=t[(t.indexOf(te??`bypassPermissions`)+1)%t.length];C?.(n)}},[Y,te,C,xe,j]),X=(0,Q.useCallback)((e,t)=>{let n=e.slice(0,t),r=n.includes(`/`),i=n.includes(`@`);if(!r&&!i){V.current&&=(s?.(!1,``),!1),H.current&&=(u?.(!1,``),!1);return}if(r){let e=n.match(/(?:^|\s)\/(\S*)$/);if(e&&L.current.length>0){V.current||q();let t=e[1]??``;s?.(!0,t),V.current=!0,H.current&&=(u?.(!1,``),!1);return}}if(i){let e=n.match(/@(\S*)$/);if(e&&ge.current.length>0){u?.(!0,e[1]??``),H.current=!0,V.current&&=(s?.(!1,``),!1);return}}V.current&&=(s?.(!1,``),!1),H.current&&=(u?.(!1,``),!1)},[s,u,q]),Z=(0,Q.useCallback)(e=>{let t=e.target,n=t.value;O.current=n,be.current=-1;let r=t===he.current?F.current:he.current;r&&(r.value=n),le(n.trim().length>0),X(n,t.selectionStart),ee?.(n,k.filter(e=>e.status===`ready`&&e.serverPath).map(e=>({name:e.name,path:e.serverPath}))),_e.current&&(z.current&&cancelAnimationFrame(z.current),z.current=requestAnimationFrame(()=>{z.current=0,t.style.height=`auto`,t.style.height=Math.min(t.scrollHeight,t===F.current?80:160)+`px`}))},[X,ee,k]),Pe=(0,Q.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),Ae(n))},[Ae]),Fe=(0,Q.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/x-ppm-path`);if(t){let e=O.current;U(e+(e.length>0&&!e.endsWith(` `)?` `:``)+`@${t} `),W()?.focus();return}let n=Array.from(e.dataTransfer.files);n.length>0&&Ae(n)},[Ae,U,W]),Ie=(0,Q.useCallback)(e=>{e.preventDefault()},[]),Le=(0,Q.useCallback)(()=>{I.current?.click()},[]),Re=(0,Q.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&Ae(t),e.target.value=``},[Ae]),ze=ce||k.some(e=>e.status!==`error`)||!!j,Be=r&&!ze;return(0,$.jsxs)(`div`,{"data-onboarding":`chat-input`,className:`p-2 md:p-3`,children:[(0,$.jsxs)(`div`,{className:`border border-border rounded-[var(--rad)] bg-panel shadow-[var(--shadow-float)] cursor-text`,onClick:e=>{a||e.target instanceof HTMLTextAreaElement||W()?.focus()},children:[j&&(0,$.jsx)(`div`,{className:`px-2 md:px-4 pt-2`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-sky-500/30 bg-sky-500/10 px-2 py-1 text-xs font-medium text-sky-600 dark:text-sky-400`,children:[(0,$.jsx)(B,{className:`size-3.5 shrink-0`}),j,(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),M(null),W()?.focus()},className:`shrink-0 rounded-sm p-0.5 hover:bg-sky-500/20 transition-colors`,"aria-label":`Remove ${j} agent`,children:(0,$.jsx)(g,{className:`size-3`})})]})}),(0,$.jsx)(Li,{attachments:k,onRemove:J}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-2 md:hidden relative`,children:[(0,$.jsx)(sa,{mode:te??`bypassPermissions`,onClick:()=>de(e=>!e)}),(0,$.jsx)(Ui,{value:te??`bypassPermissions`,onChange:e=>C?.(e),open:N,onOpenChange:de}),T&&o&&(0,$.jsx)(qe,{value:w??`claude`,onChange:T,projectName:o}),E&&o&&(0,$.jsx)(Zi,{model:ie??null,effort:ae??null,thinking:oe??!1,onModelChange:E,onEffortChange:D??(()=>{}),onThinkingChange:se??(()=>{}),projectName:o,providerId:w??`claude`,disabled:r}),r&&(0,$.jsx)(la,{value:pe,onChange:me})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-1 md:hidden px-2 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Le()},disabled:a,className:`flex items-center justify-center size-8 shrink-0 rounded-[10px] text-text-3 hover:text-text-primary transition-colors disabled:opacity-50`,"aria-label":`Attach file`,children:(0,$.jsx)(p,{className:`size-4`})}),(0,$.jsx)(`textarea`,{ref:F,defaultValue:v??``,onChange:Z,onKeyDown:Ne,onPaste:Pe,onDrop:Fe,onDragOver:Ie,placeholder:r?`Follow-up...`:`Ask anything...`,disabled:a,rows:1,className:`flex-1 resize-none bg-transparent py-1.5 text-sm text-foreground placeholder:text-text-subtle focus:outline-none disabled:opacity-50 max-h-20 [field-sizing:content]`}),K.supported&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Te()},disabled:a,className:`flex items-center justify-center size-8 shrink-0 rounded-[10px] transition-colors disabled:opacity-50 ${K.isListening?`bg-error text-white animate-pulse`:`text-text-3 hover:text-text-primary`}`,"aria-label":K.isListening?`Stop voice input`:`Start voice input`,children:K.isListening?(0,$.jsx)(ne,{className:`size-4`}):(0,$.jsx)(ve,{className:`size-4`})}),Be?(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i?.()},className:`flex items-center justify-center size-9 shrink-0 rounded-[11px] bg-error text-white hover:bg-error/80 shadow-[var(--shadow-float)] transition-colors`,"aria-label":`Stop`,children:(0,$.jsx)(ye,{className:`size-3.5`})}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),P?fe(!1):Y()},disabled:a||!ze,className:`flex items-center justify-center size-9 shrink-0 rounded-[11px] bg-primary text-primary-foreground hover:bg-primary/90 shadow-[var(--shadow-float)] disabled:opacity-30 disabled:shadow-none transition-colors`,"aria-label":P?`Cancel queued send`:`Send`,children:P?(0,$.jsx)(R,{className:`size-4 animate-spin`}):(0,$.jsx)(A,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`hidden md:block`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-2.5`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(sa,{mode:te??`bypassPermissions`,onClick:()=>de(e=>!e)}),(0,$.jsx)(Ui,{value:te??`bypassPermissions`,onChange:e=>C?.(e),open:N,onOpenChange:de})]}),T&&o&&(0,$.jsx)(qe,{value:w??`claude`,onChange:T,projectName:o}),E&&o&&(0,$.jsx)(Zi,{model:ie??null,effort:ae??null,thinking:oe??!1,onModelChange:E,onEffortChange:D??(()=>{}),onThinkingChange:se??(()=>{}),projectName:o,providerId:w??`claude`,disabled:r}),r&&(0,$.jsx)(la,{value:pe,onChange:me})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2 px-2.5 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Le()},disabled:a,className:`flex items-center justify-center size-[34px] shrink-0 rounded-[10px] text-text-3 hover:text-text-primary hover:bg-surface-elevated transition-colors disabled:opacity-50`,"aria-label":`Attach file`,children:(0,$.jsx)(p,{className:`size-[17px]`})}),(0,$.jsx)(`textarea`,{ref:he,defaultValue:v??``,onChange:Z,onKeyDown:Ne,onPaste:Pe,onDrop:Fe,onDragOver:Ie,placeholder:r?`Follow-up or Stop...`:`Ask anything...`,disabled:a,rows:1,className:`flex-1 resize-none bg-transparent py-2 text-sm text-foreground placeholder:text-text-subtle focus:outline-none disabled:opacity-50 max-h-[90px] leading-relaxed [field-sizing:content]`}),K.supported&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Te()},disabled:a,className:`flex items-center justify-center size-[34px] shrink-0 rounded-[10px] transition-colors disabled:opacity-50 ${K.isListening?`bg-error text-white animate-pulse`:`text-text-3 hover:text-text-primary hover:bg-surface-elevated`}`,"aria-label":K.isListening?`Stop voice input`:`Start voice input`,children:K.isListening?(0,$.jsx)(ne,{className:`size-[17px]`}):(0,$.jsx)(ve,{className:`size-[17px]`})}),Be?(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i?.()},className:`flex items-center justify-center size-9 shrink-0 rounded-[11px] bg-error text-white hover:bg-error/80 shadow-[var(--shadow-float)] transition-colors`,"aria-label":`Stop response`,children:(0,$.jsx)(ye,{className:`size-4`})}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),P?fe(!1):Y()},disabled:a||!ze,className:`flex items-center justify-center size-9 shrink-0 rounded-[11px] bg-primary text-primary-foreground hover:bg-primary/90 shadow-[var(--shadow-float)] disabled:opacity-30 disabled:cursor-not-allowed disabled:shadow-none transition-colors`,"aria-label":P?`Cancel queued send`:`Send message`,children:P?(0,$.jsx)(R,{className:`size-4 animate-spin`}):(0,$.jsx)(A,{className:`size-[17px]`})})]})]})]}),(0,$.jsx)(`input`,{ref:I,type:`file`,multiple:!0,className:`hidden`,onChange:Re})]})});function sa({mode:e,onClick:t}){let n=Hi(e),r=Vi(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t()},className:`inline-flex items-center gap-1.5 px-[9px] py-1 rounded-full text-[11.5px] text-text-2 bg-panel-2 border border-border-soft hover:text-text-primary hover:border-border transition-colors`,"aria-label":`Permission mode: ${r}`,children:[(0,$.jsx)(n,{className:`size-3`}),(0,$.jsx)(`span`,{className:`max-w-[100px] truncate`,children:r})]})}var ca=[{value:`now`,label:`Interrupt`,Icon:C},{value:`next`,label:`Queue`,Icon:le},{value:`later`,label:`Later`,Icon:m}];function la({value:e,onChange:t}){let n=(0,Q.useCallback)(()=>{let n=[`next`,`later`,`now`];t(n[(n.indexOf(e)+1)%n.length])},[e,t]),r=ca.find(t=>t.value===e)??ca[1],i=r.Icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`inline-flex items-center gap-1.5 px-[9px] py-1 rounded-full text-[11.5px] text-text-2 bg-panel-2 border border-border-soft hover:text-text-primary hover:border-border transition-colors`,"aria-label":`Message priority: ${r.label}`,title:`Priority: ${r.label} (click to cycle)`,children:[(0,$.jsx)(i,{className:`size-3`}),(0,$.jsx)(`span`,{children:r.label})]})}function ua(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:t.length+1},(e,t)=>t),r=Array(t.length+1);for(let i=1;i<=e.length;i++){r[0]=i;for(let a=1;a<=t.length;a++){let o=e[i-1]===t[a-1]?0:1;r[a]=Math.min(r[a-1]+1,n[a]+1,n[a-1]+o)}[n,r]=[r,n]}return n[t.length]}function da(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(r.startsWith(n))return{rank:0,distance:0};if(r.includes(n))return{rank:1,distance:r.indexOf(n)};let i=Math.max(Math.floor(n.length*.4),2),a=ua(n,r.slice(0,n.length+i));return a<=i?{rank:2,distance:a}:null}var fa=1;function pa(e,t,n=20,r=[]){if(!t)return e;t=t.slice(0,50);let i=new Map(r.map((e,t)=>[e,t])),a=[];for(let n of e){let e=da(t,n.name),o=[e,da(t,n.description)].filter(e=>e!==null).sort((e,t)=>e.rank-t.rank||e.distance-t.distance)[0];if(o){let t=i.get(n.name),s=t!==void 0&&e?.rank===o.rank;a.push({item:n,rank:o.rank-(s?fa:0),distance:o.distance,recency:t??r.length})}}return a.sort((e,t)=>e.rank-t.rank||e.recency-t.recency||e.distance-t.distance||e.item.name.localeCompare(t.item.name)),a.slice(0,n).map(e=>e.item)}function ma({items:e,filter:t,onSelect:n,onClose:r,visible:i,recentNames:a=[],projectName:o}){let[s,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=(0,Q.useMemo)(()=>new Set(a),[a]),p=(0,Q.useMemo)(()=>{if(t)return{items:pa(e,t,20,a),recentCount:0};if(a.length>0){let t=[],n=[];for(let r of e)f.has(r.name)?t.push(r):n.push(r);return t.sort((e,t)=>a.indexOf(e.name)-a.indexOf(t.name)),{items:[...t,...n],recentCount:t.length}}return{items:e,recentCount:0}},[e,t,a,f]),h=p.items,g=p.recentCount;(0,Q.useEffect)(()=>{c(0)},[t]),(0,Q.useEffect)(()=>{let e=d.current;e&&e.children[s]?.scrollIntoView({block:`nearest`})},[s]);let _=(0,Q.useCallback)(e=>{if(!i||h.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),c(e=>e>0?e-1:h.length-1),!0;case`ArrowDown`:return e.preventDefault(),c(e=>e<h.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),h[s]&&n(h[s]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,h,s,n,r]);(0,Q.useEffect)(()=>{if(!i)return;let e=e=>{_(e)&&e.stopPropagation()},t=d.current?.ownerDocument??document;return t.addEventListener(`keydown`,e,!0),()=>t.removeEventListener(`keydown`,e,!0)},[i,_]);let v=(0,Q.useCallback)(()=>{!o||l||(u(!0),K.del(`${G(o)}/chat/slash-items/cache`).then(()=>{window.dispatchEvent(new CustomEvent(`ppm:slash-items-refresh`))}).finally(()=>u(!1)))},[o,l]);return!i||h.length===0?null:(0,$.jsx)(`div`,{className:`max-h-52 overflow-y-auto overflow-x-hidden border-b border-border bg-surface`,children:(0,$.jsx)(`div`,{ref:d,className:`py-1`,children:h.map((e,t)=>{let r=g>0&&t===0,i=g>0&&t===g;return(0,$.jsxs)(`div`,{children:[r&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pt-1 pb-0.5`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-medium text-text-subtle uppercase tracking-wider flex items-center gap-1`,children:[(0,$.jsx)(m,{className:`size-3`}),`Recent`]}),o&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v()},className:`text-text-subtle hover:text-text-primary transition-colors p-0.5 rounded`,title:`Refresh skill list`,"aria-label":`Refresh skill list`,children:(0,$.jsx)(de,{className:`size-3 ${l?`animate-spin`:``}`})})]}),i&&(0,$.jsx)(`div`,{className:`px-3 pt-1.5 pb-0.5`,children:(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle uppercase tracking-wider`,children:`All`})}),(0,$.jsxs)(`button`,{className:`flex items-start gap-3 w-full px-3 py-2 text-left transition-colors ${t===s?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>c(t),onClick:()=>n(e),children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5`,children:e.iconDataUri?(0,$.jsx)(`img`,{src:e.iconDataUri,alt:``,className:`size-4 object-contain`}):e.type===`builtin`?(0,$.jsx)(C,{className:`size-4 text-emerald-500`}):e.type===`skill`?(0,$.jsx)(ce,{className:`size-4 text-warning`}):e.type===`agent`?(0,$.jsx)(B,{className:`size-4 text-sky-500`}):(0,$.jsx)(fe,{className:`size-4 text-primary`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-sm truncate`,children:[e.invokeSigil??`/`,e.name]}),e.displayName&&e.displayName!==e.name&&(0,$.jsx)(`span`,{className:`text-xs text-text-2 truncate`,children:e.displayName}),e.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-text-subtle truncate`,children:e.argumentHint}),(0,$.jsx)(`span`,{className:`text-xs text-text-subtle capitalize ml-auto shrink-0 whitespace-nowrap`,children:e.invokeSigil===`$`?`Codex`:e.scope===`bundled`?`PPM`:e.scope===`user`?`global`:e.type})]}),e.description&&(0,$.jsx)(`p`,{className:`text-xs text-text-subtle mt-0.5 line-clamp-2 break-words`,children:e.description})]})]})]},`${e.type}-${e.name}`)})})})}function ha({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,Q.useState)(0),s=(0,Q.useRef)(null),l=(()=>{if(!t)return e.slice(0,50);let n=t.toLowerCase();return e.filter(e=>e.path.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)).slice(0,50)})();(0,Q.useEffect)(()=>{o(0)},[t]),(0,Q.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let u=(0,Q.useCallback)(e=>{if(!i||l.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:l.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<l.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),l[a]&&n(l[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,l,a,n,r]);return(0,Q.useEffect)(()=>{if(!i)return;let e=e=>{u(e)&&e.stopPropagation()},t=s.current?.ownerDocument??document;return t.addEventListener(`keydown`,e,!0),()=>t.removeEventListener(`keydown`,e,!0)},[i,u]),!i||l.length===0?null:(0,$.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,$.jsx)(`div`,{ref:s,className:`py-1`,children:l.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:e.type===`directory`?(0,$.jsx)(c,{className:`size-4 text-warning`}):(0,$.jsx)(ue,{className:`size-4 text-primary`})}),(0,$.jsx)(`span`,{className:`text-sm truncate`,children:e.path})]},e.path))})})}var ga=e=>`${(e/1048576).toFixed(2)} MB`;function _a(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function va(){let e=null;for(let t of document.querySelectorAll(`.overflow-y-auto`))t.clientHeight<100||!t.querySelector(`[data-msg-index]`)||(!e||t.scrollHeight>e.scrollHeight)&&(e=t);let t=[];e&&(t.push(`Rendered messages: ${e.querySelectorAll(`[data-msg-index]`).length}`),t.push(`Transcript DOM nodes: ${e.querySelectorAll(`*`).length}`),t.push(`Transcript height: ${Math.round(e.scrollHeight)}px`));let n=performance.memory;return n&&t.push(`JS heap (page): ${(n.usedJSHeapSize/1048576).toFixed(1)} MB`),t}function ya({sessionId:e,projectName:t}){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let n=!0;return K.get(`${G(t)}/chat/sessions/${e}/images?project=${encodeURIComponent(t)}`).then(e=>{n&&r(e)}).catch(e=>{n&&a(e.message)}),()=>{n=!1}},[e,t]);let u=(n,i=!1)=>{s(n),a(null),K.post(`${G(t)}/chat/sessions/${e}/images/strip?project=${encodeURIComponent(t)}`,{mode:n,includeAttachments:i}).then(e=>{r(e.remaining),l({removed:e.removed,bytes:e.bytesFreed})}).catch(e=>a(e.message)).finally(()=>s(null))};return i&&!n?(0,$.jsx)(`p`,{className:`text-[11px] text-error`,children:i}):n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:`Transcript images`}),n.total===0?(0,$.jsxs)(`p`,{className:`text-[11px] text-text-subtle`,children:[`No images in this transcript`,c?` — it is clean.`:`.`]}):(0,$.jsxs)(`p`,{className:`text-[11px] text-text-secondary`,children:[n.total,` image`,n.total===1?``:`s`,` · `,_a(n.bytes),` of base64, replayed on every turn`,n.attachments>0&&` · ${n.attachments} attached by you`,`.`]}),n.oversized>0&&(0,$.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-warning/40 bg-warning/10 p-2 text-[11px] text-text-secondary`,children:[(0,$.jsx)(x,{className:`mt-px size-3.5 shrink-0 text-warning`}),(0,$.jsxs)(`span`,{children:[n.oversized,` image`,n.oversized===1?` reaches`:`s reach`,` the `,n.limit,`px limit (largest `,n.largestSide,`px). Once a request carries several images the API rejects those outright, which fails the whole turn — removing them loses no context.`]})]}),n.oversizedAttachments>0&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-error/40 bg-error/10 p-2 text-[11px] text-text-secondary`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(x,{className:`mt-px size-3.5 shrink-0 text-error`}),(0,$.jsxs)(`span`,{children:[n.oversizedAttachments,` of those `,n.oversizedAttachments===1?`is an image you`:`are images you`,` `,`attached yourself, so the buttons below leave `,n.oversizedAttachments===1?`it`:`them`,` in place. While `,n.oversizedAttachments===1?`it stays`:`they stay`,`, every turn in this session keeps failing. Removing `,n.oversizedAttachments===1?`it`:`them`,` cannot be undone: an attachment PPM sent keeps a copy on disk with its path still in the message, but one from another client does not.`]})]}),(0,$.jsxs)(X,{size:`sm`,variant:`destructive`,disabled:o!==null,onClick:()=>u(`oversized`,!0),children:[o===`oversized`?(0,$.jsx)(R,{className:`size-3.5 animate-spin`}):(0,$.jsx)(v,{className:`size-3.5`}),`Remove oversized, attachments included`]})]}),c&&(0,$.jsxs)(`p`,{className:`text-[11px] text-success`,children:[`Removed `,c.removed,` image`,c.removed===1?``:`s`,`, freed `,_a(c.bytes),`.`]}),i&&(0,$.jsx)(`p`,{className:`text-[11px] text-error`,children:i}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:flex-row`,children:[(0,$.jsxs)(X,{size:`sm`,variant:`outline`,className:`flex-1`,disabled:o!==null||n.oversized===0,onClick:()=>u(`oversized`),children:[o===`oversized`?(0,$.jsx)(R,{className:`size-3.5 animate-spin`}):(0,$.jsx)(v,{className:`size-3.5`}),`Remove oversized`,n.oversized>0?` (${n.oversized} · ${_a(n.oversizedBytes)})`:``]}),(0,$.jsxs)(X,{size:`sm`,variant:`destructive`,className:`flex-1`,disabled:o!==null||n.total===0,onClick:()=>u(`all`),children:[o===`all`?(0,$.jsx)(R,{className:`size-3.5 animate-spin`}):(0,$.jsx)(v,{className:`size-3.5`}),`Remove all`,n.total>0?` (${n.total} · ${_a(n.bytes)})`:``]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`These two buttons cover tool images only, and leave anything you attached alone. A removed tool image is replaced by its placeholder text; the chat still shows the file, re-read from disk.`})]}):(0,$.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Scanning transcript for images...`})}function ba({sessionId:e,projectName:t}){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null);if((0,Q.useEffect)(()=>{let n=!0;return K.get(`${G(t)}/chat/sessions/${e}/usage?project=${encodeURIComponent(t)}`).then(e=>{n&&r(e.turns)}).catch(e=>{n&&a(e.message)}),()=>{n=!1}},[e,t]),i)return(0,$.jsx)(`p`,{className:`text-[11px] text-error`,children:i});if(!n)return(0,$.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Loading token history...`});if(n.length===0)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:`Token & cache`}),(0,$.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`No turns recorded yet. Send a message and the token split for each turn shows up here.`})]});let o=n.filter(e=>e.usage.coldStart).length,s=n.reduce((e,t)=>e+t.usage.costUsd,0),c=n.reduce((e,t)=>e+Qn(t.usage),0),l=new Set(n.map(e=>e.usage.accountId).filter(Boolean)).size;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:`Token & cache`}),(0,$.jsxs)(`p`,{className:`text-[11px] text-text-secondary`,children:[`Last `,n.length,` turn`,n.length===1?``:`s`,` · `,o,` restarted the session ·`,` `,or(c),` of transcript re-sent uncached · $`,s.toFixed(2),l>1&&` · spread over ${l} accounts`]}),(0,$.jsx)(`div`,{className:`max-h-[30vh] overflow-y-auto rounded-md border border-border`,children:(0,$.jsxs)(`table`,{className:`w-full font-mono text-[10.5px]`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 bg-surface text-text-subtle`,children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-normal`,children:`When`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-normal`,children:`Account`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:`Prefix`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:`Cached`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:`Cost`}),(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-normal`,children:`Start`})]})}),(0,$.jsx)(`tbody`,{children:n.map(e=>{let t=Math.round(e.usage.cacheHitRate*100),n=nr(e.usage).level;return(0,$.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,$.jsx)(`td`,{className:`px-2 py-1 text-text-subtle`,children:e.recordedAt.slice(11,16)||e.recordedAt.slice(0,10)}),(0,$.jsx)(`td`,{className:`max-w-24 truncate px-2 py-1 text-text-subtle`,title:e.usage.accountLabel??e.usage.accountId??``,children:e.usage.accountLabel??e.usage.accountId?.slice(0,8)??`—`}),(0,$.jsx)(`td`,{className:`px-2 py-1 text-right text-text-secondary`,children:or(Zn(e.usage))}),(0,$.jsxs)(`td`,{className:`px-2 py-1 text-right ${n===`bad`?`text-warning`:n===`warn`?`text-text-primary`:`text-success`}`,children:[t,`%`]}),(0,$.jsxs)(`td`,{className:`px-2 py-1 text-right text-text-secondary`,children:[`$`,e.usage.costUsd.toFixed(3)]}),(0,$.jsx)(`td`,{className:`px-2 py-1 text-text-subtle`,children:e.usage.coldStart?e.usage.coldReason??`cold`:`warm`})]},e.id)})})]})}),(0,$.jsxs)(`p`,{className:`text-[11px] text-text-subtle`,children:[`A high "Cached" share is the cheap case. A turn marked `,(0,$.jsx)(`code`,{children:`idle_timeout`}),` paid for the whole transcript again because the session sat idle with no tab open long enough for PPM to release its subprocess. The cache is scoped per account, so a turn on a different account starts cold no matter how the session was resumed.`]})]})}function xa({sessionId:e,projectName:t,open:n,onOpenChange:r}){let[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),c=Y();(0,Q.useEffect)(()=>{n&&(s(!1),a(null),K.get(`${G(t)}/chat/sessions/${e}/debug?project=${encodeURIComponent(t)}`).then(e=>{let t=e.jsonlSizeBytes==null?``:` (${ga(e.jsonlSizeBytes)}${e.jsonlLines==null?``:`, ${e.jsonlLines} records`})`;a([`PPM Session: ${e.ppmSessionId}`,`SDK Session: ${e.sdkSessionId}`,e.jsonlPath?`JSONL: ${e.jsonlPath}${t}`:`JSONL: not found`,e.projectPath?`Project: ${e.projectPath}`:null,...va()].filter(Boolean).join(`
|
|
8
|
-
`))}).catch(()=>a(`Failed to load debug info`)))},[n,e,t]);let l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,$.jsx)(U,{className:`size-4 text-primary`}),`Session debug info`]}),(0,$.jsx)(`pre`,{className:`max-h-[35vh] overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-border bg-surface p-2.5 font-mono text-[11px] leading-relaxed text-text-secondary select-text`,children:i??`Loading...`}),(0,$.jsx)(X,{size:`sm`,onClick:()=>{i&&st(i).then(e=>{e&&(s(!0),setTimeout(()=>s(!1),1500))})},disabled:!i,className:`w-full`,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(d,{className:`size-3.5`}),` Copied!`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{className:`size-3.5`}),` Copy`]})}),(0,$.jsx)(`div`,{className:`border-t border-border pt-3`,children:n&&(0,$.jsx)(ba,{sessionId:e,projectName:t})}),(0,$.jsx)(`div`,{className:`border-t border-border pt-3`,children:n&&(0,$.jsx)(ya,{sessionId:e,projectName:t})})]});return c?(0,$.jsx)(Ie,{open:n,onClose:()=>r(!1),className:`popover-solid`,children:(0,$.jsx)(`div`,{className:`max-h-[85vh] overflow-y-auto px-4 pb-4 pt-1`,children:l})}):(0,$.jsx)(Fe,{open:n,onOpenChange:r,children:(0,$.jsxs)(Z,{className:`sm:max-w-lg`,children:[(0,$.jsx)(Pe,{className:`sr-only`,children:`Session debug info`}),l]})})}function Sa({hasUnread:e,onToggleUnread:t,onOpenDebug:n}){return(0,$.jsxs)(it,{children:[(0,$.jsx)(tt,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-5 rounded text-text-subtle hover:text-text-secondary hover:bg-surface-elevated transition-colors`,title:`More actions`,"aria-label":`More actions`,children:(0,$.jsx)(i,{className:`size-3.5`})})}),(0,$.jsxs)(Qe,{align:`end`,side:`top`,className:`min-w-[190px]`,children:[(0,$.jsx)(nt,{onClick:t,className:`max-md:py-3`,children:e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(j,{className:`size-3.5 text-warning`}),` Mark as read`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(W,{className:`size-3.5 fill-current text-primary`}),` Mark as unread`]})}),(0,$.jsxs)(nt,{onClick:n,className:`max-md:py-3`,children:[(0,$.jsx)(U,{className:`size-3.5`}),` Session debug info`]})]})]})}function Ca({title:e,meta:t,onClose:n,onReload:r,reloading:i,error:a,onDismissError:o,cardCount:s,children:c,fallback:l,footer:u}){let[d,f]=(0,Q.useState)(!1),p=s||1,m=Math.ceil(Math.sqrt(p)),h=Math.ceil(p/m);return(0,$.jsxs)(`div`,{className:`relative border-b border-border bg-surface px-3 py-2.5 ${d?`fixed inset-0 z-50 flex flex-col gap-2.5 overflow-hidden`:`space-y-2.5 max-h-[350px] overflow-y-auto`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-semibold text-text-primary`,children:e}),t]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(Ye,{children:[(0,$.jsx)(Ge,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:()=>Le(`accounts`),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-primary px-1 cursor-pointer`,children:[`Manage accounts `,(0,$.jsx)(k,{className:`size-3`})]})}),(0,$.jsx)(Xe,{side:`top`,children:`Add, remove or rotate accounts`})]}),s>0&&(0,$.jsxs)(Ye,{children:[(0,$.jsx)(Ge,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:()=>f(e=>!e),className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,"aria-label":d?`Exit fullscreen`:`Fullscreen view`,children:d?(0,$.jsx)(_e,{className:`size-3`}):(0,$.jsx)(M,{className:`size-3`})})}),(0,$.jsx)(Xe,{side:`top`,children:d?`Exit fullscreen`:`Fullscreen view`})]}),r&&(0,$.jsxs)(Ye,{children:[(0,$.jsx)(Ge,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:r,disabled:i,className:`text-xs text-text-subtle hover:text-text-primary px-1 disabled:opacity-50 cursor-pointer`,"aria-label":`Refresh usage`,children:(0,$.jsx)(de,{className:`size-3 ${i?`animate-spin`:``}`})})}),(0,$.jsx)(Xe,{side:`top`,children:`Refresh`})]}),(0,$.jsx)(`button`,{onClick:()=>{f(!1),n()},className:`text-xs text-text-subtle hover:text-text-primary px-1 cursor-pointer`,"aria-label":`Close usage panel`,children:(0,$.jsx)(g,{className:`size-3`})})]})]}),a&&(0,$.jsxs)(`div`,{className:`shrink-0 flex items-start gap-2 rounded border border-error/40 bg-error/10 px-2 py-1.5 text-[11px] text-error`,children:[(0,$.jsx)(`span`,{className:`flex-1`,children:a}),o&&(0,$.jsx)(`button`,{onClick:o,className:`shrink-0 text-error/70 hover:text-error cursor-pointer`,"aria-label":`Dismiss`,children:(0,$.jsx)(g,{className:`size-3`})})]}),s>0?(0,$.jsx)(`div`,{className:d?`flex-1 min-h-0 grid gap-2 overflow-hidden`:`flex gap-2 overflow-x-auto pb-1 -mx-3 px-3 snap-x snap-mandatory scrollbar-thin`,style:d?{gridTemplateColumns:`repeat(${m}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${h}, minmax(0, 1fr))`}:void 0,children:c(d?`grid`:`strip`)}):l,u&&!d&&u]})}function wa(e){return Math.round((e??0)*100)>=100}function Ta({usage:e,visible:t,onClose:n,onReload:r,loading:i,lastFetchedAt:a,onSelectAccount:o,selectedAccountId:s}){let[c,l]=(0,Q.useState)(null),{usages:u,accounts:d,activeAccountId:f,initialLoading:p,refreshing:m,flashIds:h,reload:g,toggle:_,togglingId:v}=kt(t),[y,b]=(0,Q.useState)(null);if(!t)return null;let ee=new Map(d.map(e=>[e.id,e]));function x(e,t){if(e){if(e.status===`disabled`)return`Disabled`;if(e.reauthRequired)return`Sign in again to use this account`;if(!e.hasRefreshToken&&e.expiresAt&&e.expiresAt<Math.floor(Date.now()/1e3))return`Token expired — sign in again`}let n=t?.usage.session;if(wa(n?.utilization))return`5-hour limit reached${n?.resetsAt?` — resets ${wt(n)}`:``}`;let r=t?.usage.weekly;return wa(r?.utilization)?`Weekly limit reached${r?.resetsAt?` — resets ${wt(r)}`:``}`:null}async function S(e,t){b(await _(e,t))}async function te(e){if(!o)return;let t=x(ee.get(e),u.find(t=>t.accountId===e));if(t){b(`Cannot switch to this account — ${t.toLowerCase()}.`);return}l(e),b(null);try{b(await o(e,u.find(t=>t.accountId===e)?.accountLabel??null)??null)}finally{l(null)}}let C=e.queryCostUsd!=null||e.totalCostUsd!=null;return(0,$.jsx)(Ca,{title:`Usage`,meta:a&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:Ct(new Date(a).getTime())}),onClose:n,onReload:r?()=>{r(),g()}:void 0,reloading:i||m,error:y,onDismissError:()=>b(null),cardCount:u.length,fallback:p?(0,$.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Loading...`}):e.session||e.weekly||e.weeklyOpus||e.weeklySonnet?(0,$.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,$.jsx)(Et,{label:`5-Hour Session`,bucket:e.session}),(0,$.jsx)(Et,{label:`Weekly`,bucket:e.weekly}),(0,$.jsx)(Et,{label:`Weekly (Opus)`,bucket:e.weeklyOpus}),(0,$.jsx)(Et,{label:`Weekly (Sonnet)`,bucket:e.weeklySonnet})]}):(0,$.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No usage data available`}),footer:C?(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[e.queryCostUsd!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Last query`}),(0,$.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.queryCostUsd.toFixed(4)]})]}),e.totalCostUsd!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`Session total`}),(0,$.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]}):void 0,children:t=>u.map(n=>{let r=ee.get(n.accountId);return(0,$.jsx)(Tt,{entry:n,isActive:n.accountId===(s??e.activeAccountId??f),accountInfo:r,flash:h.has(n.accountId),layout:t,onSelect:o?te:void 0,unselectableReason:x(r,n),selecting:c===n.accountId,onToggle:S,toggling:v===n.accountId},n.accountId)})})}function Ea(e){return Math.round((e??0)*100)>=100}function Da(e,t){return{accountId:e.id,accountLabel:e.label,accountStatus:e.status??`active`,isOAuth:e.type!==`apiKey`,usage:{session:t.session,weekly:t.weekly}}}function Oa({onClose:e,usage:t,onReload:n,onSelectAccount:r,selectedAccountId:i}){let[a,o]=(0,Q.useState)([]),[s,c]=(0,Q.useState)({}),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),_=(0,Q.useCallback)(async()=>{u(!0);try{o((await K.get(`/api/codex-accounts`)).accounts),c(await K.get(`/api/codex-accounts/usage`))}catch{}finally{u(!1)}},[]);(0,Q.useEffect)(()=>{_()},[_]);let v=(0,Q.useCallback)(async()=>{u(!0);try{await n?.(),c(await K.get(`/api/codex-accounts/usage`))}catch{}finally{u(!1)}},[n]),y=(0,Q.useCallback)((e,t)=>e.status===`disabled`?`Disabled`:Ea(t.fiveHour)?`5-hour limit reached${t.session?.resetsAt?` — resets ${wt(t.session)}`:``}`:Ea(t.sevenDay)?`Weekly limit reached${t.weekly?.resetsAt?` — resets ${wt(t.weekly)}`:``}`:null,[]),b=(0,Q.useCallback)(async e=>{if(!r)return;let t=a.find(t=>t.id===e);if(!t)return;let n=y(t,s[e]??{});if(n){g(`Cannot switch to this account — ${n.toLowerCase()}.`);return}f(e),g(null);try{g(await r(e,t.label)??null)}finally{f(null)}},[r,a,s,y]),ee=(0,Q.useCallback)(async(e,t)=>{m(e),g(null);try{await K.patch(`/api/codex-accounts/${e}`,{status:t===`disabled`?`active`:`disabled`}),o((await K.get(`/api/codex-accounts`)).accounts)}catch(e){g(e.message||`Could not change the account`)}finally{m(null)}},[]),x=(0,Q.useCallback)(async(e,t)=>{m(e),g(null);try{await K.patch(`/api/codex-accounts/${e}`,{dailyGuardEnabled:!t}),o((await K.get(`/api/codex-accounts`)).accounts)}catch(e){g(e.message||`Could not change Daily guard`)}finally{m(null)}},[]),S=l&&a.length===0?(0,$.jsxs)(`div`,{className:`text-xs text-text-subtle flex items-center gap-2`,children:[(0,$.jsx)(R,{className:`size-3 animate-spin`}),` Loading…`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Ot,{active:!1,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-text-primary truncate flex-1 min-w-0`,children:t.activeAccountLabel||`Default login`}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:`~/.codex`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Et,{label:`5-Hour Session`,bucket:t.session}),(0,$.jsx)(Et,{label:`Weekly`,bucket:t.weekly}),!t.session&&!t.weekly&&(0,$.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No usage data yet`})]})]}),(0,$.jsxs)(`p`,{className:`text-[11px] text-text-subtle`,children:[`Using your default `,(0,$.jsx)(`code`,{children:`~/.codex`}),` login. Add managed accounts in Settings → AI Provider → Codex.`]})]});return(0,$.jsx)(Ca,{title:`Codex Usage`,onClose:e,onReload:n?()=>void v():void 0,reloading:l,error:h,onDismissError:()=>g(null),cardCount:a.length,fallback:S,children:e=>a.map(n=>{let a=s[n.id]??{},o=a.session==null?At(a.weekly):null;return(0,$.jsx)(Tt,{entry:Da(n,a),isActive:n.id===(i??t.activeAccountId),layout:e,planLabel:Dt(n.planType),onSelect:r?b:void 0,unselectableReason:y(n,a),selecting:d===n.id,onToggle:ee,toggling:p===n.id,dailyGuard:o?{enabled:!!n.dailyGuardEnabled,state:o}:void 0,onDailyGuardToggle:o?()=>void x(n.id,!!n.dailyGuardEnabled):void 0,dailyGuardToggling:p===n.id},n.id)})})}var ka={working:`working`,paused:`paused`,"no-transcript":`no session`};function Aa({member:e,onOpen:t}){let n=e.workState===`working`,r=gi(e),i=hi(e.startedAt,n?void 0:e.lastEventAt),a=mi(e.agentType);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>t(e.name),className:`w-full text-left min-h-[44px] px-1.5 py-1 rounded-md hover:bg-surface-elevated transition-colors group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[n?(0,$.jsx)(R,{className:`size-3 shrink-0 animate-spin text-success`}):(0,$.jsx)(`span`,{className:q(`size-1.5 rounded-full shrink-0`,e.workState===`paused`?`bg-warning`:`bg-text-3`)}),(0,$.jsx)(`span`,{className:`font-medium truncate`,children:e.name}),a&&(0,$.jsx)(`span`,{className:`text-text-subtle text-[10px] truncate`,children:a}),e.model&&(0,$.jsxs)(`span`,{className:`text-text-subtle text-[10px]`,children:[`(`,e.model,`)`]}),(0,$.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 shrink-0 text-[10px] text-text-subtle`,children:[i&&(0,$.jsx)(`span`,{children:i}),(0,$.jsx)(`span`,{className:q(n&&`text-success`),children:ka[e.workState]}),(0,$.jsx)(P,{className:`size-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})]}),r&&(0,$.jsx)(`div`,{className:`mt-0.5 pl-5 text-[11px] text-text-subtle truncate font-mono`,children:r})]})}function ja({members:e,loading:t,onOpenMember:n,className:r}){return e.length===0?(0,$.jsx)(`div`,{className:q(`flex items-center justify-center gap-2 text-xs text-text-subtle py-4`,r),children:t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{className:`size-3 animate-spin`}),`Reading member sessions…`]}):`No member sessions recorded`}):(0,$.jsx)(`div`,{className:q(`overflow-y-auto space-y-0.5`,r),children:e.map(e=>(0,$.jsx)(Aa,{member:e,onOpen:n},e.name))})}var Ma=[`subject`,`summary`,`text`,`message`,`content`,`description`,`reason`,`feedback`],Na=[`description`,`message`,`content`,`reason`,`feedback`],Pa=new Set([`type`,`taskId`,`task_id`,`assignedBy`,`assigned_by`,`timestamp`,`request_id`,`requestId`]),Fa=e=>typeof e==`string`?e.trim():e==null?``:String(e);function Ia(e,t,n){for(let r of t){if(r===n)continue;let t=Fa(e[r]);if(t)return{key:r,value:t}}return null}function La(e){return Object.entries(e).filter(([e,t])=>!Pa.has(e)&&Fa(t)).map(([e,t])=>`${e}: ${Fa(t)}`).join(` · `)}function Ra(e,t){let n=Fa(t),r=Fa(e);if(!r)return{title:n};let i;try{i=JSON.parse(r)}catch{let[e,...t]=r.split(`
|
|
9
|
-
`),i=t.join(`
|
|
10
|
-
`).trim();return{title:n||Fa(e),...i?{detail:i}:{}}}if(!i||typeof i!=`object`||Array.isArray(i))return{title:n||r};let a=i,o=Fa(a.taskId)||Fa(a.task_id),s=Ia(a,Ma),c=Ia(a,Na,s?.key);return{title:n||s?.value||La(a)||Fa(a.type)||r,...c?{detail:c.value}:{},...o?{taskId:o}:{}}}function za({messages:e,className:t}){let n=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{n.current?.scrollIntoView({behavior:`smooth`})},[e.length]),e.length===0?(0,$.jsx)(`p`,{className:q(`text-xs text-text-subtle text-center py-4`,t),children:`No messages yet`}):(0,$.jsx)(`div`,{className:q(`overflow-y-auto`,t),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[e.map((e,t)=>{let n=e.parsedType?pt[e.parsedType]:null,{title:r,detail:i,taskId:a}=Ra(e.text,e.summary);return(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-text-subtle`,children:[(0,$.jsx)(`span`,{className:`font-medium`,style:Va(e.color),children:e.from}),(0,$.jsx)(`span`,{children:`→`}),(0,$.jsx)(`span`,{children:e.to}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px]`,children:Ba(e.timestamp)})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-foreground/90 break-words`,children:[n&&(0,$.jsx)(`span`,{className:q(`inline-block px-1 py-0 rounded text-[9px] mr-1`,n.className),children:n.label}),a&&(0,$.jsxs)(`span`,{className:`inline-block px-1 py-0 rounded text-[9px] mr-1 bg-surface-elevated text-text-subtle`,children:[`#`,a]}),r]}),i&&(0,$.jsx)(`div`,{className:`mt-0.5 text-[11px] text-text-subtle break-words line-clamp-2`,children:i})]},`${e.timestamp}-${t}`)}),(0,$.jsx)(`div`,{ref:n})]})})}function Ba(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function Va(e){if(e&&(/^#[0-9a-fA-F]{3,8}$/.test(e)||/^[a-zA-Z]{3,20}$/.test(e)))return{color:e}}function Ha(e,t){return e===t?`Team (current session)`:e}function Ua({teamNames:e,messages:t,sessionId:n,projectName:r}){let[i,a]=(0,Q.useState)(e[0]??``),[o,s]=(0,Q.useState)(`members`),c=yt(),l=Ve();(0,Q.useEffect)(()=>{e.length>0&&!e.includes(i)&&a(e[0])},[e,i]);let{members:u,outbound:d,loading:f,refresh:p}=xi(i,!!i),m=(0,Q.useCallback)(e=>{c({teamName:i,memberName:e,projectName:r})},[c,i,r]),h=(0,Q.useMemo)(()=>{let e=d.map(e=>({from:e.from,to:e.to,text:e.text,timestamp:e.timestamp,...e.summary?{summary:e.summary}:{}}));return[...t,...e].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()).slice(-200)},[t,d]),g=u.filter(e=>e.workState===`working`).length,_=e=>q(`flex items-center gap-1.5 px-2.5 rounded-md text-[11px] whitespace-nowrap transition-colors`,l?`min-h-[44px]`:`py-1`,e?`bg-primary/10 text-primary font-medium`:`text-text-subtle hover:text-text-primary`);return(0,$.jsxs)(`div`,{className:`flex flex-col min-h-0`,children:[e.length>1&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto min-w-0 mb-1.5`,children:e.map(e=>(0,$.jsx)(`button`,{onClick:()=>a(e),className:q(`px-2 py-0.5 text-[11px] rounded-md whitespace-nowrap transition-colors`,i===e?`bg-primary/10 text-primary font-medium`:`text-text-subtle hover:text-text-primary`),children:Ha(e,n)},e))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mb-1.5 shrink-0`,role:`tablist`,children:[(0,$.jsxs)(`button`,{role:`tab`,"aria-selected":o===`members`,onClick:()=>s(`members`),className:_(o===`members`),children:[(0,$.jsx)(`span`,{children:`Members`}),(0,$.jsx)(`span`,{className:`text-text-subtle`,children:u.length}),g>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-success`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-success animate-pulse`}),g]})]}),(0,$.jsxs)(`button`,{role:`tab`,"aria-selected":o===`messages`,onClick:()=>s(`messages`),className:_(o===`messages`),children:[(0,$.jsx)(`span`,{children:`Messages`}),(0,$.jsx)(`span`,{className:`text-text-subtle`,children:h.length})]}),(0,$.jsx)(`button`,{onClick:p,className:q(`ml-auto text-text-subtle hover:text-foreground shrink-0`,l?`p-3`:`p-1`),"aria-label":`Refresh`,children:(0,$.jsx)(de,{className:q(`size-3`,f&&`animate-spin`)})})]}),o===`members`?(0,$.jsx)(ja,{members:u,loading:f,onOpenMember:m,className:`max-h-56`}):(0,$.jsx)(za,{messages:h,className:`max-h-56`})]})}function Wa(e){return e>=90?`text-error`:e>=70?`text-warning`:`text-success`}function Ga({tabId:e,projectName:t,usageInfo:n,usageLoading:r,refreshUsage:i,lastFetchedAt:a,sessionId:s,providerId:c,pickedAccountLabel:l,pickedAccountId:u,onSelectAccount:d,onSelectSession:f,historyFilter:p,onBugReport:m,isConnected:_,onReload:v,teamActivity:y,teamMessages:ee,onTeamOpen:x}){let[S,C]=(0,Q.useState)(null),[w,ne]=(0,Q.useState)([]),[E,ae]=(0,Q.useState)(!1),D=ze(e=>e.notifications),oe=ze(e=>s?e.notifications.has(s):!1),se=ze(e=>e.clearForSession),O=ze(e=>e.markUnread),[ce,le]=(0,Q.useState)(``),k=He(ce,300),[A,ue]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(!1),[me,he]=(0,Q.useState)([]),[F,V]=(0,Q.useState)(null),[_e,U]=(0,Q.useState)({}),[ve,ye]=(0,Q.useState)(!1),[W,be]=(0,Q.useState)(!1),xe=(0,Q.useRef)(null),Se=e=>{C(t=>t===e?null:e)},Ce=(0,Q.useCallback)(async e=>{if(t){ae(!0);try{let n=new URLSearchParams({limit:`50`,offset:`0`});e&&n.set(`q`,e);let r=await K.get(`${G(t)}/chat/sessions?${n}`);ne(r.sessions),P(r.hasMore)}catch{}finally{ae(!1)}}},[t]),we=(0,Q.useCallback)(async()=>{if(!(!t||fe||!N)){pe(!0);try{let e=w.filter(e=>!e.pinned).length,n=new URLSearchParams({limit:`50`,offset:String(e)});k&&n.set(`q`,k);let r=await K.get(`${G(t)}/chat/sessions?${n}`);ne(e=>{let t=new Set(e.map(e=>e.id)),n=r.sessions.filter(e=>!t.has(e.id));return[...e,...n]}),P(r.hasMore)}catch{}finally{pe(!1)}}},[t,fe,N,w,k]);(0,Q.useEffect)(()=>{S===`history`&&w.length===0&&Ce()},[S]),(0,Q.useEffect)(()=>{S===`history`&&Ce(k||void 0)},[k]);let Te=(0,Q.useCallback)(async()=>{if(t)try{let e=await K.get(`${G(t)}/tags`);he(e.tags),U(e.counts)}catch{}},[t]);(0,Q.useEffect)(()=>{S===`history`&&t&&Te()},[S,t,Te]);function Ee(n){e&&window.dispatchEvent(new CustomEvent(`ppm:onboarding-evidence`,{detail:{type:`history-opened`,projectName:t,tabId:e,sessionId:n.id,visible:!document.hidden&&Object.values(ke.getState().panels).some(t=>t.activeTabId===e)}}));let r=p?n.designSlug===p:!n.designSlug;f&&r?(f(n),C(null)):(Ze(n,t),C(null))}let De=(0,Q.useCallback)((e,t)=>{t.stopPropagation(),ue(e.id),M(e.title||``),setTimeout(()=>xe.current?.select(),0)},[]),Oe=(0,Q.useCallback)(async()=>{if(!A||!j.trim()||!t){ue(null);return}try{await K.patch(`${G(t)}/chat/sessions/${A}`,{title:j.trim()}),ne(e=>e.map(e=>e.id===A?{...e,title:j.trim()}:e))}catch{}ue(null)},[A,j,t]),Ae=(0,Q.useCallback)(()=>ue(null),[]),J=(0,Q.useCallback)(async(e,n)=>{if(e.stopPropagation(),!t)return;let r=`${G(t)}/chat/sessions/${n.id}/pin`;try{n.pinned?await K.del(r):await K.put(r),ne(e=>e.map(e=>e.id===n.id?{...e,pinned:!e.pinned}:e).sort(Be))}catch{}},[t]),Me=(0,Q.useCallback)(async(e,n)=>{if(e.stopPropagation(),t&&window.confirm(`Delete this session? This cannot be undone.`))try{await K.del(`${G(t)}/chat/sessions/${n.id}?providerId=${n.providerId}`),ne(e=>e.filter(e=>e.id!==n.id))}catch{}},[t]),Y=(0,Q.useCallback)((e,t)=>{ne(n=>n.map(n=>n.id===e?{...n,tag:t}:n)),Te()},[Te]),Ne=(0,Q.useCallback)(async()=>{if(!t)return;let e=window.prompt(`Delete sessions older than how many days? (pinned sessions are kept)`,`30`);if(!e)return;let n=parseInt(e,10);if(!(!n||n<1)&&window.confirm(`Delete all unpinned sessions older than ${n} days? This cannot be undone.`)){ae(!0);try{await K.del(`${G(t)}/chat/sessions?olderThanDays=${n}`),Ce(k||void 0)}catch{}}},[t,Ce,k]);(0,Q.useEffect)(()=>{if(S!==`history`)return;let e=e=>{if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;let n=parseInt(e.key);if(n>=1&&n<=me.length&&s){let e=me[n-1];e&&(K.patch(`${G(t)}/chat/sessions/${s}/tag`,{tagId:e.id}).catch(()=>{}),Y(s,{id:e.id,name:e.name,color:e.color}))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,me,s,t,Y]);let X=p?w.filter(e=>e.designSlug===p):w,Z=F===null?X:X.filter(e=>e.tag?.id===F),Pe=!c||c===`claude`,Fe=c===`codex`,Ie=!u||u===n.activeAccountId,Le=Ie&&n.fiveHour!=null?Math.round(n.fiveHour*100):null,Re=Ie&&n.sevenDay!=null?Math.round(n.sevenDay*100):null,Ve=Le!=null||Re!=null?Wa(Math.max(Le??0,Re??0)):`text-text-subtle`,Ge=l??(Ie?n.activeAccountLabel:null)??null;return(0,$.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto scrollbar-none`,children:[(0,$.jsxs)(`button`,{"data-onboarding":`chat-history`,onClick:()=>Se(`history`),className:`shrink-0 flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${S===`history`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,children:[(0,$.jsx)(re,{className:`size-3`}),(0,$.jsx)(`span`,{children:`History`})]}),s&&c&&c!==`mock`?(0,$.jsxs)(`button`,{onClick:()=>Se(`config`),className:`shrink-0 flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${S===`config`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,title:`AI Settings`,children:[(0,$.jsx)(Ue,{providerId:c}),(0,$.jsx)(`span`,{className:`capitalize`,children:c})]}):(0,$.jsx)(`button`,{onClick:()=>Se(`config`),className:`shrink-0 p-1 rounded transition-colors ${S===`config`?`text-primary bg-primary/10`:`text-text-subtle hover:text-text-secondary hover:bg-surface-elevated`}`,title:`AI Settings`,children:(0,$.jsx)(I,{className:`size-3`})}),Pe||Fe?(0,$.jsxs)(`button`,{onClick:()=>Se(`usage`),className:`shrink-0 flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-medium tabular-nums transition-colors hover:bg-surface-elevated ${S===`usage`?`bg-primary/10`:``} ${Ve}`,title:`Usage limits`,children:[(0,$.jsx)(ge,{className:`size-3`}),Ge&&(0,$.jsxs)(`span`,{className:`text-text-secondary font-normal truncate max-w-[110px]`,title:Ge,children:[`[`,Ge,`]`]}),(0,$.jsxs)(`span`,{children:[`5h:`,Le==null?`--%`:`${Le}%`]}),(0,$.jsx)(`span`,{className:`text-text-subtle`,children:`·`}),(0,$.jsxs)(`span`,{children:[`Wk:`,Re==null?`--%`:`${Re}%`]})]}):null,y?.hasTeams&&(0,$.jsxs)(`button`,{onClick:()=>{Se(`team`),x?.()},className:`shrink-0 relative flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-colors ${S===`team`?`text-primary bg-primary/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`}`,title:`Team activity`,children:[(0,$.jsx)(T,{className:`size-3`}),(0,$.jsx)(`span`,{children:`Team`}),(y.unreadCount??0)>0&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-2 bg-primary rounded-full animate-pulse`})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 pl-1`,children:[v&&(0,$.jsxs)(`button`,{onClick:e=>{let t=e.currentTarget.querySelector(`svg`);t&&(t.classList.add(`animate-spin`),setTimeout(()=>t.classList.remove(`animate-spin`),600)),v()},className:`relative size-4 flex items-center justify-center`,title:_?`Reload messages`:`Disconnected — click to reload`,children:[(0,$.jsx)(de,{className:`size-3 ${_?`text-muted-foreground/60`:`text-error`}`,strokeWidth:2.5}),(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full ${_?`bg-success`:`bg-error animate-pulse`}`})]}),s&&(0,$.jsx)(Sa,{hasUnread:oe,onToggleUnread:()=>oe?se(s):O(s,t),onOpenDebug:()=>be(!0)})]})]}),s&&(0,$.jsx)(xa,{sessionId:s,projectName:t,open:W,onOpenChange:be}),S===`history`&&(0,$.jsxs)(`div`,{className:`border-t border-border/30 bg-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 border-b border-border/30`,children:[(0,$.jsx)(z,{className:`size-3 text-text-subtle shrink-0`}),(0,$.jsx)(`input`,{type:`text`,value:ce,onChange:e=>le(e.target.value),placeholder:`Search sessions...`,className:`flex-1 bg-transparent text-[11px] text-text-primary outline-none placeholder:text-text-subtle`}),(0,$.jsx)(`button`,{onClick:Ne,className:`p-0.5 rounded text-text-subtle hover:text-error transition-colors`,title:`Delete old sessions...`,children:(0,$.jsx)(o,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:()=>Ce(k||void 0),disabled:E,className:`p-0.5 rounded text-text-subtle hover:text-text-secondary transition-colors disabled:opacity-50`,title:`Refresh`,children:(0,$.jsx)(de,{className:`size-3 ${E?`animate-spin`:``}`})})]}),me.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 overflow-x-auto border-b border-border/30 scrollbar-none`,children:[(0,$.jsxs)(`button`,{onClick:()=>V(null),className:`shrink-0 rounded-md border px-2 py-1 text-[10px] transition-colors ${F===null?`bg-primary/20 border-primary text-primary`:`border-border bg-surface text-text-secondary`}`,children:[`All (`,X.length,`)`]}),me.map(e=>(0,$.jsxs)(`button`,{onClick:()=>V(F===e.id?null:e.id),className:`shrink-0 flex items-center gap-1 rounded-md border px-2 py-1 text-[10px] transition-colors ${F===e.id?`border-current`:`border-border bg-surface`}`,style:F===e.id?{backgroundColor:e.color+`20`,color:e.color,borderColor:e.color}:void 0,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full shrink-0`,style:{backgroundColor:e.color}}),e.name,` (`,_e[e.id]??0,`)`]},e.id)),(0,$.jsx)(`button`,{onClick:()=>ye(!ve),className:`shrink-0 p-1 rounded transition-colors ${ve?`text-primary bg-primary/10`:`text-text-subtle hover:text-text-secondary`}`,title:`Manage tags`,children:(0,$.jsx)(te,{className:`size-3`})})]}),ve&&(0,$.jsx)(`div`,{className:`border-b border-border/30 px-2 py-2 max-h-[180px] overflow-y-auto bg-surface-elevated/50`,children:(0,$.jsx)(We,{projectName:t,onTagsChanged:Te})}),(0,$.jsx)(`div`,{className:`max-h-[200px] overflow-y-auto`,children:E&&X.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(R,{className:`size-3.5 animate-spin text-text-subtle`})}):Z.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3 text-[11px] text-text-subtle`,children:ce?`No matching sessions`:`No sessions yet`}):(0,$.jsxs)($.Fragment,{children:[Z.map(e=>{let n=D.get(e.id),r=!!n;return(0,$.jsx)(ct,{session:e,projectName:t,projectTags:me,onTogglePin:J,onStartEditing:De,onDeleteSession:Me,onTagChanged:Y,children:(0,$.jsxs)(`div`,{"data-onboarding":`chat-history-session`,className:q(`flex items-center gap-2 w-full px-3 py-1.5 text-left hover:bg-surface-elevated transition-colors group`,r&&`font-medium text-foreground`,r&&Je(n.type),!r&&`text-text-secondary`),children:[(0,$.jsx)(Ue,{providerId:e.providerId}),e.tag&&(0,$.jsx)(`span`,{className:`size-2 rounded-full shrink-0`,style:{backgroundColor:e.tag.color},title:e.tag.name}),A===e.id?(0,$.jsxs)(`form`,{className:`flex items-center gap-1 flex-1 min-w-0`,onSubmit:e=>{e.preventDefault(),Oe()},children:[(0,$.jsx)(`input`,{ref:xe,value:j,onChange:e=>M(e.target.value),onBlur:Oe,onKeyDown:e=>{e.key===`Escape`&&Ae()},className:`flex-1 min-w-0 bg-surface-elevated text-[11px] text-text-primary px-1 py-0.5 rounded border border-border outline-none focus:border-primary`,autoFocus:!0}),(0,$.jsx)(`button`,{type:`submit`,className:`p-0.5 text-success hover:text-success/80`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(H,{className:`size-3`})}),(0,$.jsx)(`button`,{type:`button`,className:`p-0.5 text-text-subtle hover:text-text-secondary`,onClick:e=>{e.stopPropagation(),Ae()},children:(0,$.jsx)(g,{className:`size-3`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:()=>Ee(e),className:`text-[11px] truncate flex-1 text-left flex items-center gap-1`,children:[e.title?.startsWith(`[PPM]`)&&(0,$.jsx)(B,{className:`size-3 text-muted-foreground shrink-0`}),e.title?.startsWith(`[PPM]`)?e.title.slice(7):e.title||`Untitled`]}),(0,$.jsx)(`button`,{onClick:t=>J(t,e),className:`p-0.5 rounded transition-all ${e.pinned?`text-primary hover:text-primary/70`:`text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100`}`,title:e.pinned?`Unpin session`:`Pin session`,children:e.pinned?(0,$.jsx)(h,{className:`size-3`}):(0,$.jsx)(L,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:t=>De(e,t),className:`p-0.5 rounded text-text-subtle hover:text-text-secondary can-hover:opacity-0 can-hover:group-hover:opacity-100 transition-opacity`,title:`Rename session`,children:(0,$.jsx)(ie,{className:`size-3`})}),(0,$.jsx)(`button`,{onClick:t=>Me(t,e),className:`p-0.5 rounded text-text-subtle hover:text-error hover:bg-error/20 can-hover:opacity-0 can-hover:group-hover:opacity-100 transition-opacity`,title:`Delete session`,children:(0,$.jsx)(b,{className:`size-3`})})]}),A!==e.id&&e.updatedAt&&(0,$.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0 w-16 text-right`,children:je(e.updatedAt)})]})},e.id)}),N&&(0,$.jsxs)(`button`,{onClick:we,disabled:fe,className:`flex items-center justify-center gap-1 w-full py-1.5 text-[11px] text-text-subtle hover:text-text-secondary hover:bg-surface-elevated transition-colors`,children:[fe?(0,$.jsx)(R,{className:`size-3 animate-spin`}):null,fe?`Loading...`:`Load more`]})]})})]}),S===`config`&&(0,$.jsx)(`div`,{className:`border-t border-border/30 bg-surface px-3 py-2 max-h-[280px] overflow-y-auto`,children:(0,$.jsx)(St,{compact:!0})}),S===`team`&&y?.hasTeams&&(0,$.jsx)(`div`,{className:`border-t border-border/30 bg-surface px-3 py-2`,children:(0,$.jsx)(Ua,{teamNames:y.teamNames,messages:ee??[],sessionId:s,projectName:t})}),S===`usage`&&Pe&&(0,$.jsx)(Ta,{usage:n,onSelectAccount:d,selectedAccountId:u??n.activeAccountId??null,visible:!0,onClose:()=>C(null),onReload:i,loading:r,lastFetchedAt:a}),S===`usage`&&Fe&&(0,$.jsx)(Oa,{usage:n,onClose:()=>C(null),onReload:i,onSelectAccount:d,selectedAccountId:u??n.activeAccountId??null})]})}function Ka({tabId:e,metadata:t,children:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(null),l=t.providerPending===!0,u=t.focusedProviderOnOpen,d=t.projectName;function f(t,n){let r=ke.getState(),i=r.getPanelForTab(e)?.tabs.find(t=>t.id===e);i?.metadata?.providerPending&&r.updateTab(e,{metadata:{...i.metadata,providerId:t,providerPending:void 0,focusedProviderOnOpen:void 0,permissionMode:i.metadata.permissionMode??n.providers[t]?.permission_mode??`bypassPermissions`}})}return(0,Q.useEffect)(()=>{if(!l)return;let e=!1;return i(!1),c(null),Promise.all([ut(),d?K.get(`${G(d)}/chat/providers`):Promise.resolve(null)]).then(([t,n])=>{if(e)return;let r=jt(t,u);if(n&&!n.some(e=>e.id===r)){c({provider:r,settings:t,alternatives:n});return}f(r,t)}).catch(()=>{e||i(!0)}),()=>{e=!0}},[l,u,d,e,a]),l?s?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-4 text-sm text-muted-foreground`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[s.provider,` is not available. Choose a provider for this chat.`]}),s.alternatives.map(e=>(0,$.jsxs)(`button`,{className:`text-primary underline`,onClick:()=>f(e.id,s.settings),children:[`Use `,e.name]},e.id)),(0,$.jsx)(`button`,{className:`text-primary underline`,onClick:()=>o(e=>e+1),children:`Check again`})]}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,role:`status`,children:r?(0,$.jsxs)($.Fragment,{children:[`Could not load chat settings.`,(0,$.jsx)(`button`,{className:`text-primary underline`,onClick:()=>o(e=>e+1),children:`Retry`})]}):`Preparing chat…`}):n}var qa=3e3;function Ja(e,t){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!0),o=(0,Q.useRef)(void 0),s=(0,Q.useRef)(t);s.current=t;let c=t??`__new__`;(0,Q.useEffect)(()=>{if(!e){a(!1);return}let t=!1;a(!0);let n=setTimeout(()=>{t||a(!1)},qa);return K.get(`${G(e)}/chat/drafts/${encodeURIComponent(c)}`).then(e=>{if(!t)if(e){let t=[];try{t=JSON.parse(e.attachments)}catch{}r({content:e.content,attachments:t})}else r(null)}).catch(()=>{t||r(null)}).finally(()=>{clearTimeout(n),t||a(!1)}),()=>{t=!0,clearTimeout(n)}},[e,c]);let l=(0,Q.useCallback)((t,n)=>{e&&(o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{let r=s.current??`__new__`;K.put(`${G(e)}/chat/drafts/${encodeURIComponent(r)}`,{content:t,attachments:JSON.stringify(n??[])}).catch(()=>{})},1e3))},[e]),u=(0,Q.useCallback)(()=>{o.current&&clearTimeout(o.current),o.current=void 0},[]),d=(0,Q.useCallback)(t=>{if(!e)return;o.current&&clearTimeout(o.current);let n=t??s.current??`__new__`;K.del(`${G(e)}/chat/drafts/${encodeURIComponent(n)}`).catch(()=>{}),r(null)},[e]);return(0,Q.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]),{draft:n,draftLoading:i,saveDraft:l,clearDraft:d,cancelPendingSave:u}}var Ya=3e4,Xa=45e3;function Za(e){let{metadata:t,tabId:n}=e;return n&&t?(0,$.jsx)(Ka,{tabId:n,metadata:t,children:(0,$.jsx)(Qa,{...e})}):(0,$.jsx)(Qa,{...e})}function Qa({metadata:e,tabId:t,onNewSession:n,onFork:r,historyFilter:i}){let a=typeof e?.designSlug==`string`&&e.designSlug?e.designSlug:void 0,[o,s]=(0,Q.useState)(e?.sessionId??null),c=(0,Q.useCallback)(e=>{s(e)},[]),[l,u]=(0,Q.useState)(e?.providerId??`claude`),[d,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(null),[ee,x]=(0,Q.useState)([]),[S,te]=(0,Q.useState)([]),[C,w]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(``),[T,ie]=(0,Q.useState)(null),[E,ae]=(0,Q.useState)(e?.permissionMode??void 0),D=(0,Q.useRef)(null),oe=(0,Q.useRef)(null),[se,O]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[ue,j]=(0,Q.useState)(null),M=(0,Q.useRef)(0),N=e?.projectName??``;$t({tabId:t,sessionId:o,designSlug:a,projectName:N,providerId:l});let de=J(e=>e.updateTab),P=we(e=>e.version),{usageInfo:fe,usageLoading:pe,lastFetchedAt:me,refreshUsage:he,reloadUsage:F}=Qt(N,l,o??void 0,e?.pickedAccountProvider===l?e?.pickedAccountId:void 0),{draft:I,draftLoading:L,saveDraft:ge,clearDraft:z,cancelPendingSave:B}=Ja(N,o);(0,Q.useEffect)(()=>{E||ut().then(e=>{let t=e.providers[l];ae(t?.permission_mode??`bypassPermissions`)}).catch(()=>{})},[]),(0,Q.useEffect)(()=>{!t||!o||ot(t,{sessionId:o,providerId:l,permissionMode:E,pickedAccountId:void 0,pickedAccountLabel:void 0,pickedAccountProvider:void 0})},[o,l,E]);let V=(0,Q.useCallback)(e=>{u(e),t&&ot(t,{providerId:e})},[t]),H=e?.pickedAccountId,_e=e?.pickedAccountLabel,U=e?.pickedAccountProvider,ve=!!H&&U===l;(0,Q.useEffect)(()=>{if(!t||o||ve)return;let e=!1;return dt(l).then(n=>{e||!n||ot(t,{pickedAccountId:n.id,pickedAccountLabel:n.label,pickedAccountProvider:l})}).catch(()=>{}),()=>{e=!0}},[t,o,l,ve]);let ye=(0,Q.useCallback)(async(e,n)=>{if(o){try{await K.put(`${G(N)}/chat/sessions/${o}/account`,{accountId:e}),be({id:e,label:n}),F(),Ce.success(`This chat will use the selected account from the next message.`)}catch(e){return e.message||`Could not switch account`}return null}return t&&ot(t,{pickedAccountId:e,pickedAccountLabel:n,pickedAccountProvider:l}),null},[o,N,t,e,l,de,F]),[W,be]=(0,Q.useState)(null),xe=ke(e=>Object.values(e.panels).some(e=>e.activeTabId===t)),{messages:Se,renderedMessages:q,expandCompact:Ee,isCompactExpanded:De,dismissMessage:Oe,clearErrors:Ae,messagesLoading:je,versionMap:Me,isStreaming:Y,phase:Ne,isReconnecting:X,connectingElapsed:Z,pendingApproval:Pe,contextWindowPct:Fe,compactStatus:Ie,mcpNeedsAuth:Le,statusMessage:Re,sessionTitle:Be,liveAccount:Ve,model:He,setModel:Ue,effort:We,setEffort:Ge,thinking:qe,setThinking:Je,sendMessage:Ye,respondToApproval:Xe,cancelStreaming:Ze,reconnect:Qe,refetchMessages:$e,isConnected:et,teamActivity:tt,teamMessages:nt,markTeamRead:rt,bashPartialOutput:it,backgroundShells:at,killBackgroundShell:st}=Xt(o,l,N,c,(0,Q.useCallback)(e=>{if(!t)return;let n=!document.hidden&&Object.values(ke.getState().panels).some(e=>e.activeTabId===t),r={started:`chat-started`,succeeded:`chat-succeeded`,failed:`chat-failed`,session:`chat-session`};window.dispatchEvent(new CustomEvent(`ppm:onboarding-evidence`,{detail:{...e,type:r[e.type],projectName:N,tabId:t,visible:n}}))},[N,t]));(0,Q.useEffect)(()=>{if(!t||!xe||L||Y)return;let e=()=>window.dispatchEvent(new CustomEvent(`ppm:onboarding-evidence`,{detail:{type:`chat-opened`,projectName:N,tabId:t,sessionId:o,visible:!document.hidden}}));return e(),window.addEventListener(`ppm:onboarding-refresh`,e),()=>window.removeEventListener(`ppm:onboarding-refresh`,e)},[t,N,o,xe,L,Y]),(0,Q.useEffect)(()=>{Ve&&be(Ve)},[Ve]);let ct=Ve?.id;(0,Q.useEffect)(()=>{ct&&F()},[ct,F]),(0,Q.useEffect)(()=>{be(null)},[o]);let lt=tt?.teamNames?.[0]??``,{members:ft}=xi(lt,!!lt);(0,Q.useEffect)(()=>{if(!o||!t)return;let e=()=>{if(document.hidden)return;let{panels:e}=ke.getState();Object.values(e).some(e=>e.activeTabId===t)&&(ze.getState().notifications.get(o)?.manual||ze.getState().clearForSession(o))};e(),document.addEventListener(`visibilitychange`,e);let n=ke.subscribe(e),r=ze.subscribe(e);return()=>{document.removeEventListener(`visibilitychange`,e),n(),r()}},[o,t]),(0,Q.useEffect)(()=>{t&&Be&&!a&&de(t,{title:Be})},[Be]);let[pt,mt]=(0,Q.useState)(e?.pendingMessage),[ht,gt]=(0,Q.useState)(!1),[_t,vt]=(0,Q.useState)(null),yt=(0,Q.useCallback)((e,t)=>{vt({text:e,nonce:Date.now()}),Ce.error(`Message not sent`,{description:`${t} Your text is back in the input.`})},[]),bt=(0,Q.useCallback)(e=>{oe.current&&=(clearTimeout(oe.current),null),gt(!1);let t=D.current;t&&(D.current=null,z(t.draftId),yt(t.content,e))},[yt,z]),xt=(0,Q.useCallback)(e=>{D.current=e,oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>bt(`The chat did not connect in time.`),Xa)},[bt]);(0,Q.useEffect)(()=>{if(et&&D.current){let{content:e,draftId:t,permissionMode:n,images:r,imagePaths:i}=D.current;D.current=null,oe.current&&=(clearTimeout(oe.current),null),Ye(e,{permissionMode:n,...r?.length&&{images:r},...i?.length&&{imagePaths:i}}),z(t)}},[et,Ye,z]),(0,Q.useEffect)(()=>()=>{oe.current&&clearTimeout(oe.current)},[]);let[St,Ct]=(0,Q.useState)(null),[wt,Tt]=(0,Q.useState)(0),[Et,Dt]=(0,Q.useState)(!1),Ot=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{Ot.current&&!je&&Dt(!1),Ot.current=!!je},[je]);let[kt,At]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{L||At(!0)},[L]),(0,Q.useEffect)(()=>{pt&&et&&o&&t&&ot(t,{pendingMessage:void 0})},[et,o]),(0,Q.useEffect)(()=>{ht&&Y&>(!1)},[ht,Y]),(0,Q.useEffect)(()=>{if(!ht)return;let e=setTimeout(()=>gt(!1),6e4);return()=>clearTimeout(e)},[ht]);let jt=(0,Q.useCallback)((e,t)=>{if(n){n(t);return}J.getState().openTab({type:`chat`,title:e||`AI Chat`,metadata:{projectName:N,providerId:l,...t&&{clearedFrom:t}},projectId:N||null,closable:!0})},[N,l,n]),Mt=(0,Q.useCallback)(e=>{bt(`You switched to another chat before it connected.`),s(e.id),u(e.providerId),t&&!a&&de(t,{title:e.title||`Chat`}),ze.getState().clearForSession(e.id)},[t,de,bt,a]),Nt=(0,Q.useCallback)(async(e,t)=>{if(!(!o||!N))try{let{api:n,projectUrl:i}=await Te(async()=>{let{api:e,projectUrl:t}=await import(`./api-client-BgedDTvo.js`);return{api:e,projectUrl:t}},__vite__mapDeps([43,6,1,2,12])),a=await n.post(`${i(N)}/chat/sessions/${o}/fork?providerId=${l}`,{messageId:t});if(r){r({sessionId:a.id,providerId:l,pendingMessage:e});return}J.getState().openTab({type:`chat`,title:`Fork: ${e.slice(0,30)}`,metadata:{projectName:N,sessionId:a.id,providerId:l,pendingMessage:e},projectId:N||null,closable:!0})}catch(e){console.error(`Fork failed:`,e);let t=e?.message||`Unknown error`;Ce.error(`Cannot fork from this message`,{description:t.includes(`not found`)||t.includes(`Invalid upToMessageId`)?`The original message is no longer available in the session transcript. Try forking from a different message.`:t})}},[o,N,l,r]),It=(0,Q.useCallback)((e,t,n)=>{mt(e),Ct({anchorMsgId:t,ownMsgId:n})},[]),Lt=(0,Q.useCallback)(()=>{Ct(null),mt(void 0),gt(!1),z(),Tt(e=>e+1)},[z]),Rt=(0,Q.useCallback)(async(e,n)=>{if(!(!e.trim()||!o||!N)){gt(!0);try{let r=await K.post(`${G(N)}/chat/sessions/${o}/fork?providerId=${l}&mode=edit`,{messageId:n},{signal:AbortSignal.timeout(Ya)});xt({content:e,draftId:o,permissionMode:E}),Dt(!0),t&&ot(t,{sessionId:r.id}),s(r.id)}catch(t){gt(!1);let n=t?.name===`TimeoutError`?`The server did not answer in time.`:t?.message||`Unknown error`;Ce.error(`Cannot edit from this message`,{description:n.includes(`not found`)||n.includes(`Invalid upToMessageId`)?`The original message is no longer available in the session transcript.`:n}),vt({text:e,nonce:Date.now()})}}},[o,N,l,E,t,xt]),zt=(0,Q.useCallback)(e=>{!e||e===o||(bt(`You switched to another version before it connected.`),Dt(!0),t&&ot(t,{sessionId:e}),s(e))},[o,t,bt]),Bt=(0,Q.useCallback)((e,t,n=[])=>{if(t.length===0)return e;let r=[];for(let e of t)e.textContent&&r.push(e.textContent);let{inlineImagePaths:i,pathOnlyPaths:a}=Ft(t,n);for(let e of i)r.push(`[Attached image (contents included in this message): ${e}]`);if(a.length>0){let e=a.join(`
|
|
11
|
-
`);r.push(a.length===1?`[Attached file: ${e}]`:`[Attached files:\n${e}\n]`)}return r.length===0?e:r.join(`
|
|
12
|
-
|
|
13
|
-
`)+`
|
|
14
|
-
|
|
15
|
-
`+e},[]),Vt=(0,Q.useCallback)(async(t,n=[],r)=>{let i=Pt(n),c=Bt(t,n,i),d=n.filter(e=>e.isImage&&e.serverPath).map(e=>e.serverPath);if(!(!c.trim()&&i.length===0)){if(!o)try{let n=N,r=await K.post(`${G(n)}/chat/sessions`,{providerId:l,title:t.slice(0,50),clearedFrom:e?.clearedFrom,accountId:H,...a&&{designSlug:a}},{signal:AbortSignal.timeout(Ya)});s(r.id),u(r.providerId),xt({content:c,draftId:`__new__`,permissionMode:E,images:i,imagePaths:d});return}catch(e){console.error(`Failed to create session:`,e),yt(c,e?.name===`TimeoutError`?`The server did not answer in time.`:`Could not start the chat: ${e?.message||`unknown error`}.`);return}Ye(c,{permissionMode:E,priority:r,...i.length>0&&{images:i},...d.length>0&&{imagePaths:d}}),z()}},[o,l,N,Ye,Bt,E,e,H,xt,yt,z,a]),Ht=(0,Q.useRef)(d);Ht.current=d;let Ut=(0,Q.useCallback)((e,t,n)=>{let r=e.trim().match(/^\/(\S+)(?:\s+([\s\S]+))?$/);if(r&&Ht.current.find(e=>e.handler===`client`&&(e.name===r[1]||e.aliases?.includes(r[1])))?.name===`clear`){z(),jt(r[2]?.trim(),o??void 0);return}if(mt(void 0),B(),St&&o&&N){let n=St.anchorMsgId;Ct(null),Rt(Bt(e,t),n);return}Vt(e,t,n)},[Vt,z,B,St,o,N,Rt,Bt,jt]),Wt=(0,Q.useRef)(Se);Wt.current=Se;let Gt=(0,Q.useCallback)(()=>Wt.current.filter(e=>e.role===`user`&&e.content.trim()).map(e=>e.content),[]),Kt=(0,Q.useCallback)((e,t)=>{ge(e,t)},[ge]),qt=(0,Q.useCallback)((e,t)=>{f(e),t&&x(t)},[]),Jt=(0,Q.useCallback)((e,t)=>{m(e),_(t)},[]),Yt=(0,Q.useCallback)(e=>{b(e),m(!1),_(``),setTimeout(()=>b(null),50),N&&(K.post(`${G(N)}/chat/slash-recents`,{name:e.name,type:e.type}).catch(()=>{}),x(t=>[e.name,...t.filter(t=>t!==e.name)].slice(0,5)))},[N]),Zt=(0,Q.useCallback)(()=>{m(!1),_(``)},[]),en=(0,Q.useCallback)(()=>A(null),[]),tn=(0,Q.useCallback)(e=>{j(e)},[]),nn=(0,Q.useCallback)(e=>{A([e.path]),j(null)},[]),rn=(0,Q.useCallback)((e,t)=>{w(e),re(t)},[]),an=(0,Q.useCallback)(e=>{ie(e),w(!1),re(``),setTimeout(()=>ie(null),50)},[]),on=(0,Q.useCallback)(()=>{w(!1),re(``)},[]),sn=(0,Q.useCallback)(e=>{e.preventDefault(),M.current++,(e.dataTransfer.types.includes(`application/x-ppm-path`)||e.dataTransfer.types.includes(`Files`))&&O(!0)},[]),cn=(0,Q.useCallback)(e=>{e.preventDefault(),M.current--,M.current===0&&O(!1)},[]),ln=(0,Q.useCallback)(e=>{e.preventDefault()},[]),un=(0,Q.useCallback)(e=>{e.preventDefault(),M.current=0,O(!1);let t=e.dataTransfer.getData(`application/x-ppm-path`);if(t){A([t]);return}let n=Array.from(e.dataTransfer.files);n.length>0&&(le(n),setTimeout(()=>le(null),100))},[]);return(0,$.jsxs)(`div`,{"data-onboarding":`chat`,className:`flex flex-col h-full relative`,onDragEnter:sn,onDragLeave:cn,onDragOver:ln,onDrop:un,children:[se&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary rounded-lg pointer-events-none`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-primary`,children:[(0,$.jsx)(y,{className:`size-8`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop files to attach`})]})}),X&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/60 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(R,{className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Reconnecting...`})]})}),ht&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/70 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(R,{className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Creating edited version…`})]})}),(0,$.jsx)(pi,{shells:at,onKill:st}),(0,$.jsx)(ci,{messages:q,onExpandCompact:Ee,isCompactExpanded:De,messagesLoading:je,keepStaleWhileLoading:Et,pendingApproval:Pe,onApprovalResponse:Xe,isStreaming:Y,phase:Ne,connectingElapsed:Z,statusMessage:Re,compactStatus:Ie,projectName:N,onFork:Y?void 0:Nt,onEdit:Y?void 0:It,editingMsgId:St?.ownMsgId,sessionId:o??void 0,providerId:l,onNavigateVersion:zt,versionMap:Me,onSelectSession:Mt,onDismissMessage:Oe,onClearErrors:Ae,bashPartialOutput:it}),(0,$.jsx)(_i,{teamName:lt,members:ft,projectName:N}),(0,$.jsx)(yi,{needsAuth:Le,projectName:N||void 0},o??`draft`),(0,$.jsxs)(`div`,{className:`border-t border-border bg-panel shrink-0`,children:[(0,$.jsx)(Ga,{tabId:t,projectName:N,usageInfo:fe,usageLoading:pe,refreshUsage:he,lastFetchedAt:me,sessionId:o,providerId:l,pickedAccountLabel:W?.label??(ve?_e:null),pickedAccountId:W?.id??(ve?H??null:null),onSelectAccount:ye,onSelectSession:Mt,historyFilter:i,onBugReport:o?()=>Ke(P,{sessionId:o,projectName:N}):void 0,isConnected:et,onReload:()=>{et||Qe(),$e()},teamActivity:tt,teamMessages:nt,onTeamOpen:rt}),(0,$.jsx)(ma,{items:d,filter:h,onSelect:Yt,onClose:Zt,visible:p,recentNames:ee,projectName:N}),(0,$.jsx)(ha,{items:S,filter:ne,onSelect:an,onClose:on,visible:C}),ue&&(0,$.jsx)(ha,{items:ue,filter:``,onSelect:nn,onClose:()=>j(null),visible:!0}),St&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5 text-xs text-muted-foreground border-t border-border bg-muted/40`,children:[(0,$.jsx)(`span`,{children:`Editing message — your next send replaces it`}),(0,$.jsxs)(`button`,{type:`button`,onClick:Lt,className:`flex items-center gap-1 rounded px-2 py-1 min-h-[28px] hover:bg-accent hover:text-accent-foreground transition-colors`,title:`Cancel edit (send as a new message instead)`,children:[(0,$.jsx)(g,{className:`h-3.5 w-3.5`}),`Cancel`]})]}),(kt||!L)&&(0,$.jsx)(oa,{draftReady:!L,tabId:t,onSend:Ut,isStreaming:Y,onCancel:Ze,autoFocus:!e?.sessionId||!!pt,initialValue:pt??I?.content,clearSignal:wt,restore:_t,projectName:N,onSlashStateChange:Jt,onSlashItemsLoaded:qt,slashSelected:v,onFileStateChange:rn,onFileItemsLoaded:te,fileSelected:T,externalFiles:ce,externalPaths:k,onExternalPathsConsumed:en,onDisambiguate:tn,onContentChange:Kt,getUserHistory:Gt,permissionMode:E,onModeChange:ae,providerId:l,sessionId:o??void 0,onProviderChange:!o&&!a?V:void 0,model:He,onModelChange:Ue,effort:We,onEffortChange:Ge,thinking:qe,onThinkingChange:Je})]})]})}export{Za as t};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{Jr as r,Mr as i,V as a,Zt as o,ir as s,lt as c,st as l}from"./icons-C9ZwXgel.js";import{t as u}from"./button-CBehaXpV.js";import{Qn as d,Xn as f,Zn as p,dt as m}from"./index-BVKT5UCu.js";import{c as h,h as g,l as _,s as v}from"./api-settings-0s1Rfgcu.js";function y(e){return e>=90?`text-error`:e>=70?`text-warning`:`text-success`}function b(e){return e>=90?`bg-error`:e>=70?`bg-warning`:`bg-success`}function x(e){if(!e)return null;let t=null;if(e.resetsInMinutes!=null)t=e.resetsInMinutes;else if(e.resetsInHours!=null)t=Math.round(e.resetsInHours*60);else if(e.resetsAt){let n=new Date(e.resetsAt).getTime()-Date.now();t=n>0?Math.ceil(n/6e4):0}if(t==null)return null;if(t<=0)return`now`;let n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?i>0?`${n}d ${r}h ${i}m`:r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:`${i}m`}function S(e){if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):null}function C(e){let t=e-Date.now();if(t<=0)return`expired`;let n=Math.ceil(t/6e4),r=Math.floor(n/60),i=Math.floor(r/24);return i>0?`${i}d ${r%24}h`:r>0?`${r}h ${n%60}m`:`${n}m`}function w(e){if(!e)return{label:`unknown`,tip:`No account info available`,color:`text-text-subtle`};if(!e.expiresAt)return{label:`key`,tip:`API key (no expiry)`,color:`text-text-subtle`};if(e.reauthRequired)return{label:`sign in again`,tip:`Anthropic rejected this account's refresh token. Sign in again to restore it.`,color:`text-error`};let t=e.expiresAt*1e3<Date.now();return t&&e.hasRefreshToken?{label:`expired`,tip:`Token expired but has refresh token — will auto-renew`,color:`text-warning`}:t?{label:`expired`,tip:`Token expired, no refresh token`,color:`text-error`}:e.hasRefreshToken?{label:`long-lived`,tip:`OAuth token with refresh — long-lived`,color:`text-success`}:{label:`temp`,tip:`Temporary token without refresh — will expire`,color:`text-warning`}}function T(e){if(!e)return null;let t=Math.round((Date.now()-e)/1e3);if(t<5)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60),i=n%60;return r<24?i>0?`${r}h ${i}m ago`:`${r}h ago`:`${Math.floor(r/24)}d ago`}var E=n();function D({label:e,pct:t,reset:n,resetsAt:r}){let i=S(r);return(0,E.jsxs)(`div`,{className:`space-y-1`,"data-testid":`account-usage-bar`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:e}),n&&(0,E.jsxs)(f,{children:[(0,E.jsx)(d,{asChild:!0,children:(0,E.jsxs)(`span`,{className:`text-[10px] text-text-subtle cursor-default`,children:[`↻ `,n]})}),(0,E.jsx)(p,{side:`top`,children:i?`Resets ${i}`:`Resets in`})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`flex-1 h-2 rounded-full bg-border overflow-hidden`,children:t!=null&&(0,E.jsx)(`div`,{className:`h-full rounded-full transition-all ${b(t)}`,style:{width:`${Math.min(t,100)}%`}})}),(0,E.jsx)(`span`,{className:`text-xs font-medium tabular-nums w-10 text-right ${t==null?`text-text-subtle`:y(t)}`,children:t==null?`—`:`${t}%`})]})]})}function O({label:e,bucket:t}){return t?(0,E.jsx)(D,{label:e,pct:Math.round(t.utilization*100),reset:x(t),resetsAt:t.resetsAt}):null}function k({hint:e,className:t,children:n}){return(0,E.jsxs)(f,{children:[(0,E.jsx)(d,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,className:[`cursor-help text-left`,t].filter(Boolean).join(` `),children:n})}),(0,E.jsx)(p,{side:`top`,className:`max-w-[260px] text-xs leading-relaxed`,children:e})]})}function A({description:e,onRefresh:t,refreshing:n,disabled:r,actions:i}){return(0,E.jsxs)(`section`,{className:`space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),(0,E.jsx)(u,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0 cursor-pointer`,onClick:t,disabled:r||n,title:`Refresh`,"aria-label":`Refresh accounts`,children:(0,E.jsx)(s,{className:`size-4 ${n?`animate-spin`:``}`})})]}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i})]})}function j({message:e,onDismiss:t}){return e?(0,E.jsxs)(`div`,{className:`flex items-start gap-2 text-xs p-2 rounded bg-muted`,role:`status`,children:[(0,E.jsx)(`span`,{className:`flex-1`,children:e}),(0,E.jsx)(`button`,{onClick:t,className:`shrink-0 text-muted-foreground hover:text-foreground cursor-pointer`,"aria-label":`Dismiss message`,children:(0,E.jsx)(r,{className:`size-3.5`})})]}):null}function M({children:e}){return(0,E.jsx)(`div`,{className:`flex gap-2 overflow-x-auto pb-1 -mx-1 px-1 snap-x snap-mandatory scrollbar-thin`,children:e})}function N({active:e,flash:t,dense:n,children:r,...i}){return(0,E.jsx)(`div`,{...i,className:[`rounded-md border transition-colors duration-500`,n?`p-2.5 space-y-1.5`:`p-3 space-y-2`,t?`bg-primary/10 border-primary/40`:``,e?`border-primary/30 bg-primary/5`:`border-border/50`,i.className??``].filter(Boolean).join(` `),children:r})}var P={readOnly:`min-w-[220px]`,withActions:`min-w-[300px]`};function F({entry:e,isActive:t,accountInfo:n,onToggle:r,toggling:u,onDelete:h,onExport:g,onViewProfile:_,flash:v,onSelect:y,unselectableReason:b,selecting:x,planLabel:S,dailyGuard:D,onDailyGuardToggle:A,dailyGuardToggling:j,layout:M=`list`}){let{usage:F}=e,I=F.session||F.weekly||F.weeklyOpus||F.weeklySonnet,L=n?.status??e.accountStatus,R=!!(n&&!n.hasRefreshToken&&n.expiresAt&&n.expiresAt<Math.floor(Date.now()/1e3)),z=w(n),B=!!n?.reauthRequired,V=n?.grantExpiresAt?n.grantExpiresAt*1e3:null,H=!!V&&V-Date.now()<5*864e5,U=!!n&&(z.label===`temp`||z.label===`unknown`||z.label===`expired`&&!R&&!B),W=V?new Date(V).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):null,G=!!(r||h||g||_),K=R?`Token expired — sign in again`:B?`Sign in again to use this account`:b??null,q=M===`list`?``:M===`grid`?`flex flex-col justify-evenly overflow-hidden min-h-0`:`shrink-0 snap-start ${G?P.withActions:P.readOnly}`;return(0,E.jsxs)(N,{active:t,flash:v,dense:M!==`list`,className:[q,R||B?`opacity-50`:``].filter(Boolean).join(` `)||void 0,"data-testid":`account-card`,"data-account-id":e.accountId,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.accountLabel??e.accountId.slice(0,8)}),t&&(0,E.jsx)(k,{className:`text-[10px] text-primary shrink-0 font-medium`,hint:`The next turn will run on this account.`,children:`Active`}),y&&!t&&(0,E.jsxs)(f,{children:[(0,E.jsx)(d,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>y(e.accountId),disabled:x,className:[`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors cursor-pointer disabled:cursor-wait`,K?`text-text-subtle hover:text-error hover:bg-error/10`:`text-text-secondary hover:text-foreground hover:bg-surface-elevated`].join(` `),children:x?`Switching…`:`Use`})}),(0,E.jsx)(p,{side:`top`,children:K??`Use this account for this chat`})]}),R&&(0,E.jsx)(k,{className:`text-[10px] text-error shrink-0 font-medium`,hint:`This token has expired and carries no refresh token, so nothing can renew it. Add the account again.`,children:`Expired`}),B&&!R&&(0,E.jsx)(k,{className:`text-[10px] text-error shrink-0 font-medium`,hint:`Anthropic rejected this account's refresh token, so no turn can run on it. Signing in again is the only thing that restores it.`,children:`Sign in again`}),!e.isOAuth&&!R&&(0,E.jsx)(k,{className:`text-[10px] text-text-subtle shrink-0`,hint:`A static API key rather than a sign-in: nothing to expire and nothing to renew.`,children:`API key`}),S&&(0,E.jsx)(k,{className:`text-[10px] uppercase tracking-wide text-text-subtle shrink-0`,hint:`The subscription this account is on. It decides which quota windows the account has — some plans have a weekly limit and no shorter one.`,children:S}),(0,E.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!R&&_&&n?.profileData&&(0,E.jsxs)(f,{children:[(0,E.jsx)(d,{asChild:!0,children:(0,E.jsx)(`button`,{className:`p-2 rounded cursor-pointer text-text-subtle hover:text-foreground hover:bg-surface-elevated transition-colors`,onClick:()=>_(n.profileData,e.accountId),"aria-label":`View profile`,children:(0,E.jsx)(c,{className:`size-4`})})}),(0,E.jsx)(p,{side:`top`,children:`View profile`})]}),!R&&g&&e.isOAuth&&(0,E.jsxs)(f,{children:[(0,E.jsx)(d,{asChild:!0,children:(0,E.jsx)(`button`,{className:`p-2 rounded cursor-pointer text-text-subtle hover:text-primary hover:bg-surface-elevated transition-colors`,onClick:()=>g(e.accountId),"aria-label":`Export this account`,children:(0,E.jsx)(l,{className:`size-4`})})}),(0,E.jsx)(p,{side:`top`,children:`Export this account`})]}),!R&&r&&(0,E.jsx)(m,{checked:L!==`disabled`,onCheckedChange:()=>r(e.accountId,L),disabled:u||L===`cooldown`,"aria-label":L===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer`}),h&&(0,E.jsxs)(f,{children:[(0,E.jsx)(d,{asChild:!0,children:(0,E.jsx)(`button`,{className:`p-2 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors`,onClick:()=>h(e.accountId,e.accountLabel??e.accountId.slice(0,8)),"aria-label":`Remove account`,children:(0,E.jsx)(i,{className:`size-4`})})}),(0,E.jsx)(p,{side:`top`,children:`Remove account`})]})]})]}),I?(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(O,{label:`5-Hour Session`,bucket:F.session}),(0,E.jsx)(O,{label:`Weekly`,bucket:F.weekly}),(0,E.jsx)(O,{label:`Weekly (Opus)`,bucket:F.weeklyOpus}),(0,E.jsx)(O,{label:`Weekly (Sonnet)`,bucket:F.weeklySonnet})]}):(0,E.jsx)(`p`,{className:`text-xs text-text-subtle`,children:e.isOAuth?`No usage data yet`:`Usage tracking not available for API keys`}),D&&(0,E.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-2.5 py-1.5 ${D.enabled&&D.state.blocked?`border-error/40 bg-error/5`:`border-border/50 bg-surface/40`}`,children:[(0,E.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${D.enabled&&D.state.blocked?`text-error`:`text-text-secondary`}`,children:[(0,E.jsx)(`span`,{children:`Daily guard`}),(0,E.jsxs)(f,{children:[(0,E.jsx)(d,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,E.jsx)(a,{className:`size-3.5`})})}),(0,E.jsx)(p,{side:`top`,className:`max-w-64 text-xs leading-relaxed`,children:`Spreads the weekly quota across five weekdays, adding 20% per weekday. Weekend slots keep the previous cap; unused allowance carries forward. Daily slots start at the reset time and use UTC weekdays.`})]})]}),(0,E.jsx)(`p`,{className:`text-[10px] tabular-nums ${D.enabled&&D.state.blocked?`text-error`:`text-text-subtle`}`,children:D.enabled&&D.state.blocked?`${Math.round(D.state.used*100)}% used / ${Math.round(D.state.cap*100)}% daily cap. New turns paused.`:`Weekday ${D.state.day}/5, ${Math.round(D.state.cap*100)}% daily cap`})]}),A&&(0,E.jsx)(m,{checked:D.enabled,onCheckedChange:A,disabled:j,"aria-label":D.enabled?`Disable Daily guard`:`Enable Daily guard`,className:`cursor-pointer shrink-0`})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-text-subtle flex-wrap`,children:[F.lastFetchedAt&&(0,E.jsxs)(k,{className:`inline-flex items-center gap-1`,hint:`Usage last read from Anthropic on ${new Date(F.lastFetchedAt).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}. The bars above are only as current as this.`,children:[(0,E.jsx)(s,{className:`size-3 shrink-0`,"aria-hidden":!0}),T(new Date(F.lastFetchedAt).getTime())]}),V&&!B&&(0,E.jsxs)(k,{className:[`inline-flex items-center gap-1`,H?`text-warning`:``].filter(Boolean).join(` `),hint:`Sign-in stops working on ${W}. Anthropic ends every sign-in on a fixed schedule from the day it was made, whether or not the account gets used — refreshing does not extend it. After that the account fails until you sign in again.`,children:[(0,E.jsx)(o,{className:`size-3 shrink-0`,"aria-hidden":!0}),`sign-in `,C(V)]}),U&&(0,E.jsxs)(k,{className:z.color,hint:z.tip,children:[`© `,z.label]})]})]})}var I=e(t(),1);function L(e){let t=e.usage;return[t.session?.utilization,t.weekly?.utilization,t.weeklyOpus?.utilization,t.weeklySonnet?.utilization].join(`|`)}function R(e=!0){let[t,n]=(0,I.useState)([]),[r,i]=(0,I.useState)([]),[a,o]=(0,I.useState)(null),[s,c]=(0,I.useState)(!0),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(new Set),[p,m]=(0,I.useState)(null),y=(0,I.useRef)([]),b=(0,I.useRef)(void 0),x=(0,I.useCallback)(async()=>{let e=y.current.length>0;e?u(!0):c(!0);let[t,r,a]=await Promise.allSettled([_(),v(),h()]);if(t.status===`fulfilled`){let r=t.value;if(e){let e=new Map(y.current.map(e=>[e.accountId,L(e)])),t=new Set(r.filter(t=>e.get(t.accountId)!==L(t)).map(e=>e.accountId));t.size>0&&(f(t),clearTimeout(b.current),b.current=setTimeout(()=>f(new Set),1500))}y.current=r,n(r)}r.status===`fulfilled`&&i(r.value),a.status===`fulfilled`&&o(a.value?.id??null),c(!1),u(!1)},[]),S=(0,I.useCallback)(async(e,t)=>{m(e);let n=null;try{await g(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){n=e.message}return m(null),await x(),n},[x]);return(0,I.useEffect)(()=>(e&&x(),()=>clearTimeout(b.current)),[e,x]),{usages:t,accounts:r,activeAccountId:a,initialLoading:s,refreshing:l,flashIds:d,reload:x,toggle:S,togglingId:p}}function z(e){return e?.trim()?{free:`ChatGPT Free`,go:`ChatGPT Go`,plus:`ChatGPT Plus`,pro:`ChatGPT Pro`,team:`ChatGPT Team`,business:`ChatGPT Business`,self_serve_business_prolite:`ChatGPT Business`,enterprise:`ChatGPT Enterprise`,edu:`ChatGPT Edu`}[e.trim().toLowerCase()]??e:null}var B=1440*60*1e3,V=7,H=5;function U(e,t=Date.now()){if(!e||e.windowHours!==168)return null;let n=new Date(e.resetsAt).getTime();if(!Number.isFinite(t)||!Number.isFinite(n)||n<=t)return null;let r=n-V*B;if(t<r)return null;let i=Math.min(V-1,Math.floor((t-r)/B)),a=0;for(let e=0;e<=i;e++){let t=new Date(r+e*B).getUTCDay();t!==0&&t!==6&&a++}let o=a/H;return{day:a,cap:o,used:e.utilization,blocked:e.utilization>=o}}export{M as a,j as c,T as d,x as f,F as i,O as l,z as n,N as o,R as r,A as s,U as t,D as u};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|