@vantran-se/openchamber-web 1.23.0 → 1.24.3
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/bin/cli.test.js +29 -6
- package/bin/lib/cli-http.js +5 -1
- package/bin/lib/commands-status.js +5 -0
- package/dist/assets/{CodeMirrorCommentWidgets-DFg2wnpo.js → CodeMirrorCommentWidgets-BjJHrzmU.js} +1 -1
- package/dist/assets/DiffView-COVQhWGd.js +4 -0
- package/dist/assets/FilesView-B1V5JxFX.js +13 -0
- package/dist/assets/GitView-CDOJy5Ay.js +6 -0
- package/dist/assets/GuestAttachDialog-D3S0Rjic.js +1 -0
- package/dist/assets/{JsonTreeView-BKdsjg5B.js → JsonTreeView-D0C9nU7K.js} +1 -1
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/LinearIssuesView-D7FKg1XJ.js +1 -0
- package/dist/assets/{MarkdownImageGallery-_5gEVr0X.js → MarkdownImageGallery-BrFjAVEf.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-DWepTafh.js +12 -0
- package/dist/assets/{OnboardingScreen-DdP4_nuc.js → OnboardingScreen-Dyxxiqdt.js} +1 -1
- package/dist/assets/{PatchDiff-am3SAss2.js → PatchDiff-DnEhjXcC.js} +1 -1
- package/dist/assets/PierreDiffViewer-DyxZVVVR.js +210 -0
- package/dist/assets/{PlanView-BoJxdRZe.js → PlanView-LW2z_EAP.js} +4 -4
- package/dist/assets/PluginPane-B4tKno2h.js +3 -0
- package/dist/assets/SettingsView-DEaMulN9.js +29 -0
- package/dist/assets/{SettingsWindow-DVTdDSol.js → SettingsWindow-FLDJXOgQ.js} +1 -1
- package/dist/assets/SubmoduleDiffSummary-CvVwD-Vi.js +1 -0
- package/dist/assets/ToolOutputDialog-BiP0x2Rw.js +15 -0
- package/dist/assets/{ToolPartDiffPreview-C7WLk5i9.js → ToolPartDiffPreview-CkR4msKP.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-DcdgkH-x.js → VirtualizedFileDiff-0pyr_mHY.js} +4 -4
- package/dist/assets/WalkthroughView-yNj4nOP5.js +4 -0
- package/dist/assets/appThemeRegistry-BuUKhbYQ.js +1 -0
- package/dist/assets/commitAndPush-DvJKa3Ks.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-C8byMnRh.js → computeVirtualFileMetrics-DxTBMuu-.js} +2 -2
- package/dist/assets/de-DgxgFyGG.js +10 -0
- package/dist/assets/es-BFsZj5F_.js +16 -0
- package/dist/assets/fr-jdZ5KKQi.js +14 -0
- package/dist/assets/{index-BB7ryz8y.js → index-CKHjPKbq.js} +1 -1
- package/dist/assets/index-Cbci4i1W.js +40 -0
- package/dist/assets/index-DqaMWNrC.css +1 -0
- package/dist/assets/{isDiffPlainText-45ujMPGb.js → isDiffPlainText-D7FkBMP6.js} +1 -1
- package/dist/assets/{isFilePlainText-Cc4KFSYi.js → isFilePlainText-CL2vsrIZ.js} +1 -1
- package/dist/assets/ja-C5kKrhO4.js +16 -0
- package/dist/assets/ko-DXDTT_0O.js +16 -0
- package/dist/assets/main-CZALtVek.js +896 -0
- package/dist/assets/main-CgXMBNvG.js +2 -0
- package/dist/assets/{markdown-shiki.worker-D5fBU-lw.js → markdown-shiki.worker-CahLvHIq.js} +5 -5
- package/dist/assets/markdownCore-Dh7WEsdM.js +5 -0
- package/dist/assets/miniChat-CwTmDixi.js +2 -0
- package/dist/assets/mobile-CLf2vCtO.js +2 -0
- package/dist/assets/patchFileDiff-Bsba8KFp.js +13 -0
- package/dist/assets/pl-D-7x4Y8Q.js +16 -0
- package/dist/assets/pt-BR-CSBZrHa8.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-C5gAFBk0.js +2 -0
- package/dist/assets/renderMobileApp-V4hYd32H.js +25 -0
- package/dist/assets/runtimeEndpointReset-DhlHCn-2.js +25 -0
- package/dist/assets/scheduledTasksApi-DzjbLd8P.js +1 -0
- package/dist/assets/shikiHighlight-8_3csmr6.js +1 -0
- package/dist/assets/surface-B6n7wJtt.js +1 -0
- package/dist/assets/textMateThemeFromAppTheme-CHo2fCgW.js +1 -0
- package/dist/assets/tr-Dr-oJ22L.js +7 -0
- package/dist/assets/uk-9Nx83UcI.js +16 -0
- package/dist/assets/useAppFontEffects-khZXpFL_.js +7333 -0
- package/dist/assets/useInlineCommentController-DkQ_gqpn.js +2 -0
- package/dist/assets/useRootScrollLock-DdvHf9Pt.js +2 -0
- package/dist/assets/{vendor-base-ui-DdV8vhHn.js → vendor-base-ui-CsXYnR5c.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DzlSIu_W.js → vendor-codemirror-language-data-CdzUmUyZ.js} +2 -2
- package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +1 -0
- package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
- package/dist/assets/{vendor-motion-dom-D_o3BTI3.js → vendor-motion-dom-DcCgeG69.js} +1 -1
- package/dist/assets/{vendor-remixicon-react-Dil0zKKT.js → vendor-remixicon-react-BDmGmFCA.js} +1 -1
- package/dist/assets/vendor-strip-json-comments-5dJlOkP1.js +4 -0
- package/dist/assets/{vendor-tanstack-react-virtual-g05Cx3z9.js → vendor-tanstack-react-virtual-ClYN8CzB.js} +1 -1
- package/dist/assets/{vendor-tanstack-virtual-core-Dubg10g5.js → vendor-tanstack-virtual-core-BewVQryB.js} +1 -1
- package/dist/assets/vendor-zod-CgAdXWZO.js +39 -0
- package/dist/assets/{web-components-CdGfR2XJ.js → web-components-B8IcVQAA.js} +2 -2
- package/dist/assets/zh-CN-Bxy_Hj3r.js +16 -0
- package/dist/assets/zh-TW-0BB4gpHM.js +16 -0
- package/dist/index.html +6 -4
- package/dist/mini-chat.html +6 -4
- package/dist/mobile.html +6 -4
- package/package.json +12 -9
- package/server/built-in-extensions/registry.json +4 -0
- package/server/index.d.ts +2 -0
- package/server/index.js +47 -23
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/agent-memory/runtime.test.js +22 -0
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -4
- package/server/lib/agent-tool/runtime.js +62 -15
- package/server/lib/agent-tool/runtime.test.js +88 -2
- package/server/lib/changelog/update-notes.js +2 -1
- package/server/lib/changelog/update-notes.test.js +19 -0
- package/server/lib/event-stream/DOCUMENTATION.md +26 -0
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +292 -0
- package/server/lib/event-stream/global-hub.js +68 -13
- package/server/lib/event-stream/global-hub.test.js +182 -0
- package/server/lib/event-stream/global-ws-bridge.js +16 -18
- package/server/lib/event-stream/index.js +4 -0
- package/server/lib/event-stream/protocol.js +21 -7
- package/server/lib/event-stream/runtime.js +9 -6
- package/server/lib/event-stream/runtime.test.js +60 -0
- package/server/lib/fs/DOCUMENTATION.md +10 -1
- package/server/lib/fs/git-process.test.js +77 -0
- package/server/lib/fs/routes.js +58 -5
- package/server/lib/fs/routes.test.js +116 -0
- package/server/lib/fs/search.js +2 -1
- package/server/lib/git/DOCUMENTATION.md +30 -6
- package/server/lib/git/routes.js +37 -11
- package/server/lib/git/routes.test.js +78 -0
- package/server/lib/git/serial-refresh.js +93 -0
- package/server/lib/git/serial-refresh.test.js +112 -0
- package/server/lib/git/service.js +588 -74
- package/server/lib/git/service.test.js +492 -0
- package/server/lib/github/DOCUMENTATION.md +5 -0
- package/server/lib/github/pr-status.js +5 -5
- package/server/lib/github/pr-status.test.js +1 -1
- package/server/lib/github/routes.js +6 -6
- package/server/lib/guests/DOCUMENTATION.md +68 -0
- package/server/lib/guests/auth-store.js +184 -0
- package/server/lib/guests/auth-store.test.js +112 -0
- package/server/lib/guests/background.test.js +83 -0
- package/server/lib/guests/builtins.js +34 -0
- package/server/lib/guests/builtins.test.js +174 -0
- package/server/lib/guests/catalog.js +477 -0
- package/server/lib/guests/catalog.test.js +390 -0
- package/server/lib/guests/clone.js +297 -0
- package/server/lib/guests/extract-zip.js +136 -0
- package/server/lib/guests/extract-zip.test.js +109 -0
- package/server/lib/guests/files.js +308 -0
- package/server/lib/guests/files.test.js +262 -0
- package/server/lib/guests/grant-scope.js +81 -0
- package/server/lib/guests/grant-scope.test.js +75 -0
- package/server/lib/guests/host-session.js +73 -0
- package/server/lib/guests/host-session.test.js +30 -0
- package/server/lib/guests/html-styles.js +6 -0
- package/server/lib/guests/html-styles.test.js +45 -0
- package/server/lib/guests/html-tokens.js +73 -0
- package/server/lib/guests/html-tokens.test.js +53 -0
- package/server/lib/guests/install.js +406 -0
- package/server/lib/guests/install.test.js +338 -0
- package/server/lib/guests/oauth.js +501 -0
- package/server/lib/guests/oauth.test.js +481 -0
- package/server/lib/guests/persist.js +336 -0
- package/server/lib/guests/persist.test.js +288 -0
- package/server/lib/guests/request.js +112 -0
- package/server/lib/guests/request.test.js +206 -0
- package/server/lib/guests/routes.js +838 -0
- package/server/lib/guests/service.js +538 -0
- package/server/lib/guests/service.test.js +277 -0
- package/server/lib/guests/sockets.js +129 -0
- package/server/lib/guests/sockets.test.js +110 -0
- package/server/lib/guests/ssh-install.test.js +188 -0
- package/server/lib/guests/storage.js +68 -0
- package/server/lib/guests/storage.test.js +59 -0
- package/server/lib/guests/updates.js +294 -0
- package/server/lib/guests/updates.test.js +334 -0
- package/server/lib/guests/upload.js +50 -0
- package/server/lib/guests/upload.test.js +131 -0
- package/server/lib/linear/DOCUMENTATION.md +1 -1
- package/server/lib/message-queue/DOCUMENTATION.md +17 -1
- package/server/lib/message-queue/runtime.js +34 -1
- package/server/lib/message-queue/runtime.test.js +83 -6
- package/server/lib/notifications/DOCUMENTATION.md +1 -1
- package/server/lib/notifications/emitter-runtime.js +4 -3
- package/server/lib/notifications/routes.js +5 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -0
- package/server/lib/openchamber-sessions/routes.js +62 -29
- package/server/lib/openchamber-sessions/routes.test.js +96 -0
- package/server/lib/opencode/DOCUMENTATION.md +73 -5
- package/server/lib/opencode/bootstrap-runtime.js +1 -0
- package/server/lib/opencode/core-routes.js +39 -1
- package/server/lib/opencode/env-runtime.js +5 -1
- package/server/lib/opencode/env-runtime.test.js +72 -0
- package/server/lib/opencode/feature-routes-runtime.js +30 -1
- package/server/lib/opencode/lifecycle-process.test.js +84 -0
- package/server/lib/opencode/lifecycle.js +58 -70
- package/server/lib/opencode/lifecycle.test.js +29 -0
- package/server/lib/opencode/managed-plugin-config.js +1 -1
- package/server/lib/opencode/openchamber-routes.js +72 -14
- package/server/lib/opencode/openchamber-routes.test.js +71 -3
- package/server/lib/opencode/proxy.js +33 -0
- package/server/lib/opencode/session-runtime.js +68 -0
- package/server/lib/opencode/session-runtime.test.js +43 -0
- package/server/lib/opencode/settings-helpers.js +11 -0
- package/server/lib/opencode/settings-helpers.test.js +24 -2
- package/server/lib/opencode/settings-normalization-runtime.js +2 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +13 -0
- package/server/lib/opencode/settings-registry.json +18 -0
- package/server/lib/opencode/settings-runtime.js +36 -9
- package/server/lib/opencode/settings-runtime.test.js +158 -2
- package/server/lib/opencode/shutdown-runtime.js +3 -0
- package/server/lib/opencode/shutdown-runtime.test.js +24 -0
- package/server/lib/opencode/theme-archive.js +53 -0
- package/server/lib/opencode/theme-catalog.js +171 -0
- package/server/lib/opencode/theme-catalog.test.js +125 -0
- package/server/lib/opencode/theme-import.test.js +144 -0
- package/server/lib/opencode/theme-runtime.js +100 -28
- package/server/lib/opencode/theme-runtime.test.js +15 -0
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +8 -0
- package/server/lib/permission-auto-accept/runtime.js +13 -0
- package/server/lib/permission-auto-accept/runtime.test.js +37 -1
- package/server/lib/project-context/DOCUMENTATION.md +13 -3
- package/server/lib/project-context/runtime.js +8 -2
- package/server/lib/project-context/runtime.test.js +54 -0
- package/server/lib/projects/DOCUMENTATION.md +2 -1
- package/server/lib/projects/project-config.js +40 -11
- package/server/lib/projects/project-config.test.js +97 -0
- package/server/lib/projects/project-id.js +26 -0
- package/server/lib/quota/DOCUMENTATION.md +0 -1
- package/server/lib/quota/providers/index.js +0 -7
- package/server/lib/realtime-proxy-terminal.test.js +150 -0
- package/server/lib/realtime-proxy.js +2 -0
- package/server/lib/relay/DOCUMENTATION.md +20 -0
- package/server/lib/relay/host-client.js +7 -0
- package/server/lib/relay/host-client.test.js +14 -0
- package/server/lib/routing/DOCUMENTATION.md +83 -0
- package/server/lib/routing/defaults.js +98 -0
- package/server/lib/routing/feature-flag.js +11 -0
- package/server/lib/routing/history.js +34 -0
- package/server/lib/routing/jev.js +98 -0
- package/server/lib/routing/routes.http.test.js +100 -0
- package/server/lib/routing/routes.js +81 -0
- package/server/lib/routing/runtime.js +217 -0
- package/server/lib/routing/runtime.test.js +188 -0
- package/server/lib/routing/store.js +249 -0
- package/server/lib/routing/store.test.js +96 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +9 -1
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +28 -0
- package/server/lib/scheduled-tasks/runtime.js +14 -4
- package/server/lib/scheduled-tasks/runtime.test.js +67 -0
- package/server/lib/security/request-security.js +9 -5
- package/server/lib/security/request-security.test.js +37 -0
- package/server/lib/session-assist/DOCUMENTATION.md +131 -66
- package/server/lib/session-assist/context.js +127 -0
- package/server/lib/session-assist/context.test.js +132 -0
- package/server/lib/session-assist/prompt.js +54 -0
- package/server/lib/session-assist/runtime.js +111 -257
- package/server/lib/session-assist/runtime.test.js +203 -0
- package/server/lib/small-model/DOCUMENTATION.md +14 -2
- package/server/lib/small-model/call.js +37 -6
- package/server/lib/small-model/call.test.js +182 -0
- package/server/lib/terminal/DOCUMENTATION.md +23 -2
- package/server/lib/terminal/runtime.js +27 -5
- package/server/lib/terminal/runtime.test.js +67 -0
- package/server/lib/terminal/shutdown.js +106 -0
- package/server/lib/terminal/shutdown.test.js +84 -0
- package/server/lib/tts/service.test.js +78 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
- package/server/lib/ui-auth/session-cookie.js +51 -0
- package/server/lib/ui-auth/session-cookie.test.js +46 -0
- package/server/lib/ui-auth/ui-auth.js +56 -17
- package/server/lib/ui-auth/ui-auth.test.js +96 -0
- package/server/lib/walkthrough/DOCUMENTATION.md +15 -5
- package/server/lib/walkthrough/pr-source.test.js +21 -0
- package/server/lib/walkthrough/pull-request.js +7 -4
- package/server/lib/walkthrough/pull-request.test.js +16 -0
- package/server/lib/walkthrough/routes.js +19 -0
- package/server/lib/walkthrough/routes.test.js +26 -0
- package/server/lib/walkthrough/sources.js +13 -2
- package/server/opencode-worktree-readiness.test.js +130 -0
- package/dist/assets/DiffView-3Dn4QHbu.js +0 -4
- package/dist/assets/DirtyBranchSwitchDialog-CwOerqVi.js +0 -1
- package/dist/assets/FilesView-BdTOpew9.js +0 -17
- package/dist/assets/GitView-Dqf9vHJh.js +0 -6
- package/dist/assets/LinearIssuesView-CmbeL7I6.js +0 -1
- package/dist/assets/MarkdownRendererImpl-wVZlx4dd.js +0 -12
- package/dist/assets/PierreDiffViewer-DCsydlKs.js +0 -161
- package/dist/assets/SettingsView-CcM8pF5O.js +0 -28
- package/dist/assets/ToolOutputDialog-BgfTbDZ4.js +0 -15
- package/dist/assets/WalkthroughView-BEVUDxuw.js +0 -4
- package/dist/assets/appThemeRegistry-BK0dHKa6.js +0 -1
- package/dist/assets/de-C8jV7J9y.js +0 -10
- package/dist/assets/es-BI6J1M5R.js +0 -16
- package/dist/assets/fr-D6oDFt7E.js +0 -14
- package/dist/assets/index-BqhiCmYS.js +0 -39
- package/dist/assets/index-FqSOBz0J.css +0 -1
- package/dist/assets/ja-C_4i5EQu.js +0 -16
- package/dist/assets/ko-BFbOTpbq.js +0 -16
- package/dist/assets/main-C9ETLKFc.js +0 -2
- package/dist/assets/main-CJmb2dF8.js +0 -930
- package/dist/assets/markdownCore-DVuZpnli.js +0 -5
- package/dist/assets/miniChat-B4Ytoq2n.js +0 -2
- package/dist/assets/mobile-BUT6-lo1.js +0 -2
- package/dist/assets/patchFileDiff-8j1apICU.js +0 -13
- package/dist/assets/pl-COFvT56l.js +0 -16
- package/dist/assets/pt-BR-DtVOO2Lj.js +0 -16
- package/dist/assets/registerCustomTheme-BBXUCRnG.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-B6vUG-vF.js +0 -2
- package/dist/assets/renderMobileApp-BNgHraq6.js +0 -25
- package/dist/assets/runtimeEndpointReset-B8LYpWvr.js +0 -17
- package/dist/assets/scheduledTasksApi-GC4epIYA.js +0 -1
- package/dist/assets/shikiHighlight-BJISeZsQ.js +0 -1
- package/dist/assets/surface-BvRzS58U.js +0 -1
- package/dist/assets/tr-B8Q0Go2l.js +0 -7
- package/dist/assets/uk-Dk4a-Fn-.js +0 -16
- package/dist/assets/useAppFontEffects-DpFNefUA.js +0 -7284
- package/dist/assets/useGitComparison-Dfxaqd0s.js +0 -1
- package/dist/assets/useInlineCommentController-CscsE4t-.js +0 -2
- package/dist/assets/useRootScrollLock-BaCvuRlT.js +0 -1
- package/dist/assets/vendor-framer-motion-livSKyyV.js +0 -1
- package/dist/assets/vendor-zod-BPAANqvH.js +0 -39
- package/dist/assets/zh-CN-B_BXxG1Q.js +0 -16
- package/dist/assets/zh-TW-DLrl1SPZ.js +0 -16
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +0 -55
- package/server/lib/mcp-reconnect/runtime.js +0 -122
- package/server/lib/mcp-reconnect/runtime.test.js +0 -140
- package/server/lib/quota/providers/crof.js +0 -96
- package/server/lib/quota/providers/crof.test.js +0 -98
- /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
|
@@ -1,930 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-BEVUDxuw.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-DpFNefUA.js","assets/index-BqhiCmYS.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-BPAANqvH.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-FqSOBz0J.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-DdV8vhHn.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DzlSIu_W.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-8j1apICU.js","assets/runtimeEndpointReset-B8LYpWvr.js","assets/VirtualizedFileDiff-DcdgkH-x.js","assets/web-components-CdGfR2XJ.js","assets/computeVirtualFileMetrics-C8byMnRh.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isDiffPlainText-45ujMPGb.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-DCsydlKs.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CscsE4t-.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/useRootScrollLock-BaCvuRlT.js","assets/scheduledTasksApi-GC4epIYA.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-3Dn4QHbu.js","assets/useGitComparison-Dfxaqd0s.js","assets/FilesView-BdTOpew9.js","assets/shikiHighlight-BJISeZsQ.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-BKdsjg5B.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-Cc4KFSYi.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-DFg2wnpo.js","assets/GitView-Dqf9vHJh.js","assets/DirtyBranchSwitchDialog-CwOerqVi.js","assets/LinearIssuesView-CmbeL7I6.js","assets/PlanView-BoJxdRZe.js","assets/SettingsWindow-DVTdDSol.js","assets/SettingsView-CcM8pF5O.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/OnboardingScreen-DdP4_nuc.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as tt,R as c,j as s,r as ht,h as _m}from"./vendor-react-BUCujlKS.js";import{D as xn,E as $o,F as Lm,G as rd,h as ds,v as Wo,u as Pe,H as Mt,I as Ua,J as $m,K as Pn,L as Wm,N as yt,O as Gs,P as zo,Q as od,R as zm,S as Vm,T as Um,U as Km,V as id,z as ma,n as ts,W as Rn,X as Lr,e as Nn,Y as Hm,a as ps,Z as Gm,_ as qm,$ as Qm,a0 as ad,t as fn,A as qs,a1 as Ym,a2 as Xm,a3 as Ka,a4 as Jm,a5 as ld,a6 as Zm,a7 as cd,f as ef,a8 as tf,a9 as rr,aa as fa,d as No,q as Tr,o as ls,ab as dd,ac as sf,ad as wi,ae as nf,af as rf,i as of,ag as mo,ah as fo,ai as af,aj as Ha,ak as lf,al as cf,am as df,an as uf,ao as Ga,ap as qa,aq as Qa,ar as Ya,as as mf,y as Xa,at as ff,au as hf,av as pf,B as gf,C as xf}from"./index-BqhiCmYS.js";import{_ as Fn}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as At,h as De,b9 as Ut,I as R,g as pn,t as Me,ap as Qs,ba as Os,ar as Ys,ao as Xs,N as Zn,W as wn,ac as br,bb as _n,o as Vo,bc as Ja,bd as bf,be as yf,a7 as Pt,a8 as Dt,a9 as It,b as Kt,y as Je,G as wf,bf as ud,bg as Jr,u as Ds,A as ha,C as md,bh as Si,bi as Sf,bj as fd,bk as hd,r as $s,bl as pd,bm as pa,bn as Uo,bo as gd,bp as xd,bq as vf,br as Za,bs as jf,bt as kf,bu as ga,bv as vi,bw as Cf,bx as Nf,L as bd,by as Af,l as Gt,bz as Pf,n as ir,bA as yd,p as Df,bB as wd,bC as If,bD as Tf,bE as Ef,bF as Sd,bG as vd,bH as Rf,aD as xa,bI as qn,bJ as qr,bK as Mf,bL as ws,bM as Ss,bN as Ws,bO as Is,bP as Ts,bQ as bn,B as pt,bR as ln,ax as Hs,bS as Of,bT as Bf,aB as An,bU as ho,bV as Ks,bW as Ko,bX as jd,bY as ji,bZ as Ff,b_ as Bs,b$ as Fs,c0 as Cs,c1 as _s,c2 as ss,T as Cn,c3 as ar,c4 as el,c5 as dr,M as Ho,ad as _f,ae as ba,af as kd,ag as Cd,ai as On,c6 as Go,a2 as ya,c7 as Lf,c8 as $f,av as Wf,c9 as zf,ca as Vf,cb as Uf,aw as wa,cc as Sa,cd as ur,ce as Nd,cf as Kf,cg as Hf,ch as Qr,ci as Gf,cj as Yr,ck as qf,cl as or,O as Ad,cm as Qf,cn as Yf,co as Ln,cp as Xf,cq as Jf,cr as ei,cs as Pd,ct as Dd,cu as Zf,aC as ki,cv as Ci,cw as eh,cx as tl,cy as Er,c as $r,d as va,_ as th,cz as Id,cA as vr,cB as Rr,cC as sh,cD as nh,cE as rh,X as Td,ay as oh,cF as ih,cG as ah,cH as lh,cI as ch,cJ as Ed,cK as gn,cL as dh,cM as Rd,cN as uh,cO as Ni,cP as mh,cQ as fh,cR as Md,cS as hh,cT as Od,a0 as Ao,cU as Ai,R as ja,Q as ka,S as Ca,cV as Na,a as Aa,$ as ph,cW as sl,cX as Pi,cY as Bd,cZ as gh,aq as Fd,c_ as xh,P as Di,H as bh,c$ as nl,d0 as yh,d1 as rl,d2 as wh,d3 as cs,d4 as Sh,d5 as Bn,d6 as Pa,d7 as _d,d8 as vh,d9 as Ld,da as $d,db as jh,D as kh,dc as Ch,dd as Nh,de as Ah,df as ol,dg as Ph,dh as Dh,di as Wd,E as Ih,dj as po,dk as zd,dl as Th,dm as Eh,dn as Rh,dp as Mh,e as Vd,dq as Da,dr as Oh,ds as Wr,dt as Bh,du as il,dv as Fh,dw as _h,Z as Lh,dx as $h,aP as Ii,a3 as al,aU as ll,a4 as cl,dy as Wh,J as zh,K as ti,dz as Vh,dA as Uh,dB as Ud,dC as Kd,dD as Hd,dE as Kh,F as Ia,dF as Hh,a1 as Gh,dG as qh,dH as Qh,dI as Yh,dJ as Xh,dK as Jh,dL as Zh,dM as ep,dN as tp,dO as Po,ah as sp,dP as np,dQ as dl,dR as rp,dS as op,dT as ip,dU as ap,dV as Do,dW as lp,dX as ul,dY as cp,dZ as dp,d_ as up,d$ as mp,e0 as fp,e1 as hp,e2 as go,e3 as pp,i as gp,e4 as xp,e5 as bp,e6 as yp,e7 as wp,a5 as Sp,e8 as vp,e9 as jp,ea as kp,eb as Cp,ec as ml,ed as Np,aJ as Ap,aK as Pp,aL as Dp,aN as fl,aO as hl,aR as pl,aS as gl,aQ as Gd,aT as qd,ee as Ip,b4 as Tp,b5 as Ep,b6 as Rp,b7 as Mp,b8 as Op,a_ as Bp,b0 as Fp,b1 as _p,b2 as Lp,b3 as $p}from"./useAppFontEffects-DpFNefUA.js";import{u as Qd,S as xl,C as Wp,W as Yd,f as zp,a as Vp}from"./useRootScrollLock-BaCvuRlT.js";import{l as bl,n as si,t as dn,o as Ti,m as yl,q as Up,v as Kp,w as Hp,x as Gp,y as qp,z as Qp,A as Yp,E as Xp,U as Xd,F as Ei,G as Ri,e as Jd,H as Zd,I as Jp,d as Zp,c as eg,J as eu,K as Mi,L as Un,M as tu,Q as su,P as tg,T as sg,R as ng,V as rg,W as og,X as ig,S as wl,Y as ag,Z as lg,_ as cg,u as Or,s as dg,N as ug,D as mg,$ as fg,a0 as Sl,a1 as hg,i as pg,g as gg,j as nu,k as xg,a2 as bg,a3 as yg,a4 as wg,f as Sg,h as vg,O as ru,C as jg}from"./runtimeEndpointReset-B8LYpWvr.js";import{u as Wn,O as vl,D as kg,n as Cg,f as Ng,a as jl,s as Ag,d as Pg,b as Dg,r as Ig}from"./scheduledTasksApi-GC4epIYA.js";import{f as zr,h as Mn,T as ou,M as iu,D as Vr,j as Ur,d as Tg,P as Oi,b as Eg,k as Bi,i as Rg}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as qo,S as Io,h as Mg,a as au,v as Fi,s as Og}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Qo}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as lu,M as cu,C as du,a as _i,b as Li,c as $i,d as uu,e as Bg,f as Fg}from"./vendor-base-ui-DdV8vhHn.js";import{c as er,u as Jn,d as mu,p as _g}from"./vendor-zustand-BAGL70zf.js";import{g as Lg,a as $g,E as fu,b as Wg,c as zg,d as Vg,e as Ug,i as Kg}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{c as Ta,s as xr,r as hu}from"./vendor-zod-BPAANqvH.js";import{u as Hg}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{d as pu}from"./vendor-cron-parser-CUcP7OfX.js";const Gg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",qg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",ni=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Gg:t.id==="terminal"?qg:void 0}),kl=t=>{const e=tt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const u=a,d=r||i;if(d&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let g;return e[3]!==d?(g=s.jsx("img",{src:d,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=d,e[4]=g):g=e[4],g}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=De("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==u?(f=s.jsx("span",{className:h,children:u}),e[6]=u,e[7]=f):f=e[7],f},Qg=t=>{const e=tt.c(75),{directory:n,className:r}=t,{t:i}=At(),o=Wn(Yg),l=Wn(Xg),a=Wn(Jg),u=Wn(Zg),d=Wn(ex),h=Wn(tx),f=Wn(sx);let p,g;e[0]!==d?(p=()=>{d()},g=[d],e[0]=d,e[1]=p,e[2]=g):(p=e[1],g=e[2]),c.useEffect(p,g);const w=xn()&&$o();let v;e:{let _;e[3]!==l||e[4]!==o?(_=l.find(ce=>ce.id===o)??l.find(nx)??l[0]??vl[0],e[3]=l,e[4]=o,e[5]=_):_=e[5];const ne=_;if(ne){let ce;e[6]!==ne?(ce=ni(ne),e[6]=ne,e[7]=ce):ce=e[7],v=ce;break e}let ye;e[8]===Symbol.for("react.memo_cache_sentinel")?(ye=ni(vl[0]),e[8]=ye):ye=e[8],v=ye}const x=v;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async _=>{await Lm(n,_.id,_.appName)||await rd(n,_.appName)},e[9]=n,e[10]=m):m=e[10];const b=m;let y;e[11]!==b||e[12]!==f?(y=async _=>{await f(_.id),await b(_)},e[11]=b,e[12]=f,e[13]=y):y=e[13];const S=y;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await pn(n)).ok&&Me.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const C=N;let j;e[17]!==r?(j=De("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=j):j=e[18];let A;e[19]!==b||e[20]!==x?(A=()=>{b(x)},e[19]=b,e[20]=x,e[21]=A):A=e[21];const D=u&&"animate-pulse";let I;e[22]!==D?(I=De("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",D),e[22]=D,e[23]=I):I=e[23];let M;e[24]!==x.label||e[25]!==i?(M=i("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=i,e[26]=M):M=e[26];let z;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(z=s.jsx(kl,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=z):z=e[30];let E;e[31]!==I||e[32]!==M||e[33]!==z||e[34]!==A?(E=s.jsx("button",{type:"button",onClick:A,className:I,"aria-label":M,children:z}),e[31]=I,e[32]=M,e[33]=z,e[34]=A,e[35]=E):E=e[35];let H;e[36]===Symbol.for("react.memo_cache_sentinel")?(H=De("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=H):H=e[36];let B;e[37]!==i?(B=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=B):B=e[38];let O;e[39]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=O):O=e[39];let T;e[40]!==B?(T=s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:H,"aria-label":B,children:O})}),e[40]=B,e[41]=T):T=e[41];let k;e[42]!==C?(k=()=>{C()},e[42]=C,e[43]=k):k=e[43];let P;e[44]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(R,{name:"file-copy",className:"h-4 w-4"}),e[44]=P):P=e[44];let L;e[45]!==i?(L=i("openInApp.actions.copyPath"),e[45]=i,e[46]=L):L=e[46];let Q;e[47]!==L?(Q=s.jsx("span",{className:"typography-ui-label text-foreground",children:L}),e[47]=L,e[48]=Q):Q=e[48];let q;e[49]!==k||e[50]!==Q?(q=s.jsxs(Ut,{className:"flex items-center gap-2",onClick:k,children:[P,Q]}),e[49]=k,e[50]=Q,e[51]=q):q=e[51];let te;e[52]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(Os,{}),e[52]=te):te=e[52];let ae;if(e[53]!==l||e[54]!==S||e[55]!==x.id){let _;e[57]!==S||e[58]!==x.id?(_=ne=>{const ye=ni(ne);return s.jsxs(Ut,{className:"flex items-center gap-2",onClick:()=>{S(ne)},children:[s.jsx(kl,{label:ne.label,iconDataUrl:ne.iconDataUrl,fallbackIconDataUrl:ye.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:ne.label}),x.id===ne.id?s.jsx(R,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},ne.id)},e[57]=S,e[58]=x.id,e[59]=_):_=e[59],ae=l.map(_),e[53]=l,e[54]=S,e[55]=x.id,e[56]=ae}else ae=e[56];let X;e[60]!==a||e[61]!==h||e[62]!==i?(X=a?s.jsxs(Ut,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(R,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=X):X=e[63];let Z;e[64]!==q||e[65]!==ae||e[66]!==X?(Z=s.jsxs(Ys,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[q,te,ae,X]}),e[64]=q,e[65]=ae,e[66]=X,e[67]=Z):Z=e[67];let se;e[68]!==T||e[69]!==Z?(se=s.jsxs(Xs,{children:[T,Z]}),e[68]=T,e[69]=Z,e[70]=se):se=e[70];let me;return e[71]!==E||e[72]!==se||e[73]!==j?(me=s.jsxs("div",{className:j,children:[E,se]}),e[71]=E,e[72]=se,e[73]=j,e[74]=me):me=e[74],me};function Yg(t){return t.selectedAppId}function Xg(t){return t.availableApps}function Jg(t){return t.isCacheStale}function Zg(t){return t.isScanning}function ex(t){return t.initialize}function tx(t){return t.loadInstalledApps}function sx(t){return t.selectApp}function nx(t){return t.id===kg}const To=new Map,Wi=new Set,gu=()=>{for(const t of Wi)t()},ri=(t,e)=>{const n=t.trim();n&&(e.length===0?To.delete(n):To.set(n,[...e]),gu())},rx=t=>{To.delete(t.trim())&&gu()},xu=[],ox=t=>To.get(t.trim())??xu,ix=t=>(Wi.add(t),()=>{Wi.delete(t)}),ax=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=()=>ox(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(ix,n,lx)};function lx(){return xu}const cx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],dx=["dev","start","preview","serve"];async function ux(t,e,n){if(!t)return null;const r=hx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=px(n);if(i){const o=await gx(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await mx(t)){const i=await fx(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function mx(t){const e=`${t}/index.html`,n=await Eo(e,t);return typeof n=="string"&&n.trim().length>0}async function fx(){try{const t=await ds("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function hx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(dx.some(i=>n.includes(i)))return e}return null}function px(t){for(const{pattern:e}of cx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function gx(t){const e=await Eo(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Eo(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Eo(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Wo()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ds(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function xx(t){try{const e=await Eo(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const mn="__openchamber_auto_discover_preview__",bx=15e3,yx=3e3,oi=t=>t.id===mn?"scan-2":Xp.find(n=>n.key===t.icon)?.Icon??"play",wx=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Sx=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=At(),{currentTheme:l}=Zn(),{terminal:a,runtime:u}=wn(),d=br(),{isMobile:h}=_n(),f=c.useMemo(()=>xn(),[]),p=bl(ie=>ie.instances),g=bl(ie=>ie.load),w=Pe(ie=>ie.terminalShell),v=Pe(ie=>ie.terminalLoginShells.includes(ie.terminalShell)),x=Pe(ie=>ie.setSettingsPage),m=Pe(ie=>ie.setSettingsDialogOpen),b=Pe(ie=>ie.setSettingsProjectsSelectedId),y=Pe(ie=>ie.openContextPreview),S=Mt(ie=>ie.ensureDirectory),N=Mt(ie=>ie.reconcileServerSessions),C=Mt(ie=>ie.setTabLabel),j=Mt(ie=>ie.setTabIconKey),A=Mt(ie=>ie.setActiveTab),D=Mt(ie=>ie.setConnecting),I=Mt(ie=>ie.setTabSessionId),M=Mt(ie=>ie.setTabPurpose),z=Mt(ie=>ie.allocateActionExecution),E=Mt(ie=>ie.setTabLifecycle),H=Mt(ie=>ie.setTabPreviewUrl),B=Mt(ie=>ie.matchesActionExecution),O=Mt(ie=>ie.captureStartedActionMutationRevisions),[T,k]=c.useState([]),P=c.useRef(null),[L,Q]=c.useState(null),[q,te]=c.useState(!1),ae=c.useRef({}),X=c.useRef({}),Z=c.useRef({}),se=c.useRef(new Set),me=c.useRef(0),[_,ne]=c.useState({}),ye=t?.id??null,ce=t?.path??"",F=c.useMemo(()=>ye?{id:ye,path:ce}:null,[ye,ce]);c.useEffect(()=>{f&&g().catch(()=>{})},[f,g]);const re=c.useCallback(async ie=>{await Vo(ie)},[]),fe=c.useCallback(async()=>{if(!F)return;const ie=me.current+1;me.current=ie,te(!0);try{const pe=await Ja(F);if(me.current!==ie)return;P.current=pe;const Ve=pe.projectActions;k(Ve),Q(ze=>ze===mn||ze&&Ve.some(He=>He.id===ze)?ze:null)}catch{if(me.current!==ie)return}finally{me.current===ie&&te(!1)}},[F]),de=c.useMemo(()=>si(e||F?.path||""),[e,F?.path]),ge=c.useMemo(()=>si(F?.path||""),[F?.path]),Te=c.useMemo(()=>si(d||"")||de,[d,de]),be=c.useRef(Te);c.useEffect(()=>{be.current=Te},[Te]);const Ee=Mt(ie=>de?ie.getDirectoryState(de):void 0),we=Mt(ie=>ge&&ge!==de?ie.getDirectoryState(ge):void 0),Y=c.useMemo(()=>{const ie=de?[{directory:de,state:Ee}]:[];return ge&&ge!==de&&ie.push({directory:ge,state:we}),ie},[Ee,de,ge,we]),ve=c.useMemo(()=>{const ie=de?[de]:[];return ge&&ge!==de&&ie.push(ge),ie},[de,ge]),xe=c.useCallback(ie=>ie.id!==mn&&ie.runIn==="parent"&&ge||de,[de,ge]),je=c.useCallback((ie,pe,Ve)=>`${ie}::${pe}::${Ve}`,[]),oe=c.useCallback((ie,pe,Ve=Mt.getState())=>ie?Ve.getDirectoryState(ie)?.tabs.find(ze=>ze.purpose.type==="project-action"&&ze.purpose.actionId===pe)??null:null,[]),J=c.useMemo(()=>{const ie={};for(const{directory:pe,state:Ve}of Y)for(const ze of Ve?.tabs??[]){if(ze.purpose.type!=="project-action"||!ze.purpose.executionId||!ze.terminalSessionId||ze.lifecycle==="idle"||ze.lifecycle==="exited")continue;const He=dn(pe,ze.purpose.actionId),ot=je(pe,ze.purpose.actionId,ze.purpose.executionId);ie[He]={directory:pe,actionId:ze.purpose.actionId,tabId:ze.id,sessionId:ze.terminalSessionId,executionId:ze.purpose.executionId,status:ze.lifecycle==="stopping"?"stopping":_[ot]?"waiting-for-preview":"running"}}return ie},[je,_,Y]),K=c.useCallback((ie,pe,Ve)=>{const ze=dn(ie,pe),He=je(ie,pe,Ve),at=ae.current[ze]?.executionId===Ve,et=globalThis.window,Xe=dt=>{et?.clearTimeout(Z.current[dt]),delete Z.current[dt]};at&&(delete ae.current[ze],Xe(ze)),X.current[He]?.(),delete X.current[He],Xe(He),ne(dt=>{if(!dt[He])return dt;const Be={...dt};return delete Be[He],Be})},[je]),$=c.useCallback(ie=>{X.current[ie]?.(),delete X.current[ie]},[]),le=c.useCallback(ie=>{window.clearTimeout(Z.current[ie]),delete Z.current[ie]},[]);c.useEffect(()=>{const ie=X.current,pe=Z.current;return()=>{for(const Ve of Object.keys(ie))$(Ve);for(const Ve of Object.keys(pe))le(Ve)}},[le,$]),c.useEffect(()=>{const ie=new Set(ve);for(const pe of Object.values(ae.current))ie.has(pe.directory)||K(pe.directory,pe.actionId,pe.executionId);for(const pe of Object.keys(X.current)){const Ve=pe.split("::",1)[0]??"";ie.has(Ve)||$(pe)}},[K,$,ve]);const V=c.useCallback((ie,pe)=>{Pe.getState().openContextPanelTab(ie,{mode:"terminal",targetDirectory:pe===ie?null:pe})},[]),Ce=c.useMemo(()=>L?T.find(ie=>ie.id===L)??null:null,[T,L]),_e=c.useMemo(()=>({id:mn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),ke=!h,Ne=c.useMemo(()=>ke?[_e,...T]:T,[T,_e,ke]);c.useEffect(()=>{fe()},[fe]),c.useEffect(()=>{const ie=ve.map(pe=>Ti(a,pe,O,Ve=>N(pe,Ve.sessions,{startedActionMutationRevisions:Ve.startedActionMutationRevisions})));return()=>{for(const pe of ie)pe()}},[O,N,a,ve]),c.useEffect(()=>{for(const{directory:ie,state:pe}of Y)if(ie)for(const Ve of pe?.tabs??[]){if(Ve.purpose.type!=="project-action")continue;const ze=Ve.purpose.actionId,He=Ne.find(et=>et.id===ze),ot=He?.name??ze,at=He?.icon||"play";Ve.label!==ot&&C(ie,Ve.id,ot),Ve.iconKey!==at&&j(ie,Ve.id,at)}},[Ne,j,C,Y]),c.useEffect(()=>{const ie=globalThis.window;if(!ie)return;const pe=Ve=>{const ze=Ve.detail;ye&&(ze?.projectId&&ze.projectId!==ye||fe())};return ie.addEventListener(yl,pe),()=>{ie.removeEventListener(yl,pe)}},[fe,ye]),c.useEffect(()=>{L&&(L===mn&&ke||T.some(ie=>ie.id===L)||Q(null))},[T,ke,L]),c.useEffect(()=>{const ie=Ve=>{delete Z.current[Ve];const ze=ae.current[Ve];if(!ze||ze.openedUrl)return;const He=je(ze.directory,ze.actionId,ze.executionId),ot=ze.announced;if(ot.length!==0){if(window.clearTimeout(Z.current[He]),delete Z.current[He],ze.openedUrl=!0,ne(at=>{if(!at[He])return at;const et={...at};return delete et[He],et}),ot.length===1){ri(ze.directory,[]),H(ze.directory,ze.tabId,ot[0],{locked:!1,autoOpened:!0}),y(ze.directory,ot[0]);return}ze.offering=!0,ri(ze.directory,ot),Pe.getState().openContextSurface(ze.directory,"browser"),Me.info(o("projectActions.toast.multipleServers"))}},pe=()=>{const Ve=Mt.getState(),ze=Ve.sessions,He=J;for(const[ot,at]of Object.entries(He)){const Xe=ze.get(at.directory)?.tabs.find(xt=>xt.id===at.tabId);if(!Xe||Xe.terminalSessionId!==at.sessionId){K(at.directory,at.actionId,at.executionId);continue}const dt=ae.current[ot],Be=dt?.executionId===at.executionId?dt:{hostDirectory:be.current||at.directory,directory:at.directory,tabId:at.tabId,actionId:at.actionId,executionId:at.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ae.current[ot]=Be;const Se=Ne.find(xt=>xt.id===at.actionId),St=Ve.getBuffer(at.directory,at.tabId).chunks;if(!Se||St.length===0)continue;const vt=St.filter(xt=>Be.lastSeenChunkId===null||xt.id>Be.lastSeenChunkId);if(vt.length===0)continue;const Et=vt.map(xt=>xt.data).join(""),Ze=`${Be.tail}${Et}`;if(Be.openInPreview&&(!Be.openedUrl||Be.offering)){const xt=Qp(Ze),Rt=Be.announced.length;for(const Tt of xt)Be.announced.includes(Tt)||Be.announced.push(Tt);const kt=Be.announced.length-Rt;Be.offering&&kt>0?ri(at.directory,Be.announced):!Be.openedUrl&&Rt===0&&Be.announced.length>0&&(window.clearTimeout(Z.current[ot]),Z.current[ot]=window.setTimeout(()=>ie(ot),yx))}const it=!Be.openedUrl&&Se.autoOpenUrl===!0&&!Be.openInPreview?Yp(Ze):null,gt=vt[vt.length-1]?.id??Be.lastSeenChunkId;if(Be.lastSeenChunkId=gt,Be.tail=Ze.slice(-512),it)if(Be.openedUrl=!0,Be.openInPreview){const xt=He[ot];xt&&(H(xt.directory,xt.tabId,it,{locked:!1,autoOpened:!1,expectedExecutionId:xt.executionId}),xt.status==="waiting-for-preview"&&ne(Rt=>{const kt=je(xt.directory,xt.actionId,xt.executionId);if(!Rt[kt])return Rt;const Tt={...Rt};return delete Tt[kt],Tt}),window.clearTimeout(Z.current[ot]),delete Z.current[ot],y(xt.directory,it))}else re(it),Me.success(o("projectActions.toast.openedUrlFromOutput"));ae.current[ot]=Be}for(const ot of Object.keys(ae.current))if(!He[ot]){const at=ae.current[ot],et=at?ze.get(at.directory)?.tabs.find(dt=>dt.id===at.tabId):void 0;if(et?.purpose.type==="project-action"&&et.purpose.executionId===at?.executionId&&!!et.terminalSessionId&&et.lifecycle!=="idle"&&et.lifecycle!=="exited")continue;delete ae.current[ot],window.clearTimeout(Z.current[ot]),delete Z.current[ot]}};return pe(),Mt.subscribe((Ve,ze)=>{(Ve.sessions!==ze.sessions||Ve.buffers!==ze.buffers)&&pe()})},[K,be,Ne,je,y,re,J,H,o]),c.useEffect(()=>{for(const{directory:ie,state:pe}of Y)for(const Ve of pe?.tabs??[]){if(Ve.purpose.type!=="project-action"||!Ve.purpose.executionId||!Ve.terminalSessionId||Ve.lifecycle!=="running")continue;const ze=Ve.purpose.actionId,He=Ve.purpose.executionId,ot=je(ie,ze,He);if(X.current[ot])continue;const at=a.connect(Ve.terminalSessionId,{onEvent:et=>{if(!B(ie,Ve.id,He))return;et.type==="snapshot"&&(Mt.getState().replaceBuffer(ie,Ve.id,et.data??"",et.sequence??0,Ua(et)),et.status==="running"&&Mt.getState().setTabLifecycle(ie,Ve.id,"running",{expectedExecutionId:He}),et.status==="exited"&&(Mt.getState().setTabLifecycle(ie,Ve.id,"exited",{expectedExecutionId:He}),Mt.getState().setTabPurpose(ie,Ve.id,{type:"project-action",actionId:ze,executionId:null}),K(ie,ze,He)));const Xe=et.type==="data"?et.data??"":"";Xe&&Mt.getState().appendToBuffer(ie,Ve.id,Xe,et.sequence,et.replayData),et.type==="exit"&&(Mt.getState().setTabLifecycle(ie,Ve.id,"exited",{expectedExecutionId:He}),Mt.getState().setTabPurpose(ie,Ve.id,{type:"project-action",actionId:ze,executionId:null}),K(ie,ze,He))},onError:(et,Xe)=>{!Xe||!B(ie,Ve.id,He)||(Mt.getState().setTabLifecycle(ie,Ve.id,"exited",{expectedExecutionId:He}),Mt.getState().setTabSessionId(ie,Ve.id,null,{expectedExecutionId:He}),Mt.getState().setTabPurpose(ie,Ve.id,{type:"project-action",actionId:ze,executionId:null}),K(ie,ze,He))}});X.current[ot]=at.close}},[K,je,B,a,Y]);const Qe=c.useCallback(async ie=>{const pe=xe(ie);if(!pe)throw new Error(o("projectActions.error.noActiveDirectory"));const Ve=dn(pe,ie.id);S(pe);const ze=Mt.getState(),He=oe(pe,ie.id,ze),ot=He?.id??ze.createTab(pe);C(pe,ot,ie.name),j(pe,ot,ie.icon||"play"),He||M(pe,ot,{type:"project-action",actionId:ie.id,executionId:null}),A(pe,ot);const et=Mt.getState().getDirectoryState(pe)?.tabs.find(Xe=>Xe.id===ot);return{executionDirectory:pe,key:Ve,tabId:ot,sessionId:et?.terminalSessionId??null,executionId:et?.purpose.type==="project-action"?et.purpose.executionId:null}},[S,xe,oe,A,j,C,M,o]),We=c.useCallback(async ie=>{if(u.isVSCode||!i&&h)return;if(!de){Me.error(o("projectActions.error.noActiveDirectoryForAction"));return}const pe=dn(xe(ie),ie.id),Ve=J[pe];if(Ve&&Ve.status==="running"||se.current.has(pe))return;se.current.add(pe);let ze=null;try{const He=ie.id===mn?await(async()=>{const[kt,Tt]=await Promise.all([bf({id:F?.id??"",path:de}),xx(de)]),Ot=await ux(de,kt.actions,Tt);if(!Ot)throw new Error(o("contextPanel.preview.noDevServer"));return{id:mn,name:o("projectActions.actions.autoDiscover"),command:Ot.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Ot.previewUrlHint||""}})():ie,ot=He.autoOpenUrl===!0&&(He.openUrl||"").trim().length>0,at=!ot&&ie.id!==mn,et=be.current||de,{executionDirectory:Xe,key:dt,tabId:Be}=await Qe(He),Se=Up(He.command);if(!Se)throw new Error(o("projectActions.error.failedToRunAction"));const St=He.autoOpenUrl===!0&&f&&(He.desktopOpenSshForward||"").trim().length>0,vt=He.autoOpenUrl?wx(He.openUrl):null,Et=He.autoOpenUrl&&f?Kp(He.desktopOpenSshForward,p):null;if(a.listSessions){const kt=oe(Xe,He.id);if(kt?.purpose.type==="project-action"&&kt.purpose.executionId===null){const Tt=await Hp(a,Xe,{captureStartedActionMutationRevisions:O});Tt&&N(Xe,Tt.sessions,{startedActionMutationRevisions:Tt.startedActionMutationRevisions})}}const Ze=oe(Xe,He.id);let it,gt;if(Ze?.lifecycle==="running"&&Ze.terminalSessionId&&Ze.purpose.type==="project-action"&&Ze.purpose.executionId)it=Ze.terminalSessionId,gt=Ze.purpose.executionId;else{const kt=Ze?.purpose.type==="project-action"?Ze.purpose.executionId:null;kt&&K(Xe,He.id,kt);const Tt=z(Xe,Be,He.id);if(!Tt)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));ze={directory:Xe,tabId:Be,id:Tt},D(Xe,Be,!0,{expectedExecutionId:Tt});const Ot=await Gp({terminal:a,createOptions:{cwd:Xe,shell:w,loginShell:v,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Se,isRunStillExpected:()=>B(Xe,Be,Tt),purpose:{type:"project-action",actionId:He.id,executionId:Tt}});if(!B(Xe,Be,Tt)){Ot.sessionId===Tt&&await a.close(Ot.sessionId).catch(()=>{});return}gt=Ot.purpose?.type==="project-action"?Ot.purpose.executionId:Tt,it=Ot.sessionId,M(Xe,Be,{type:"project-action",actionId:He.id,executionId:gt}),I(Xe,Be,it,{expectedExecutionId:gt}),D(Xe,Be,!1,{expectedExecutionId:gt})}at&&et&&V(et,Xe),ae.current[dt]={hostDirectory:et,directory:Xe,tabId:Be,actionId:He.id,executionId:gt,lastSeenChunkId:null,openedUrl:!!Et||!!vt||ot,tail:"",openInPreview:He.id===mn,announced:[],offering:!1};const xt=je(Xe,He.id,gt);D(Xe,Be,!0,{expectedExecutionId:gt});const Rt=a.connect(it,{onEvent:kt=>{if(!B(Xe,Be,gt)||kt.purpose?.type==="project-action"&&kt.purpose.executionId!==gt)return;kt.type==="snapshot"&&(Mt.getState().replaceBuffer(Xe,Be,kt.data??"",kt.sequence??0,Ua(kt)),Mt.getState().setConnecting(Xe,Be,!1,{expectedExecutionId:gt}),kt.purpose?.type==="project-action"&&Mt.getState().setTabPurpose(Xe,Be,{type:"project-action",actionId:kt.purpose.actionId,executionId:kt.purpose.executionId}),kt.status==="running"&&Mt.getState().setTabLifecycle(Xe,Be,"running",{expectedExecutionId:gt}),kt.status==="exited"&&(Mt.getState().setTabLifecycle(Xe,Be,"exited",{expectedExecutionId:gt}),Mt.getState().setTabPurpose(Xe,Be,{type:"project-action",actionId:He.id,executionId:null}),K(Xe,He.id,gt)));const Tt=kt.type==="data"?kt.data??"":"";Tt&&Mt.getState().appendToBuffer(Xe,Be,Tt,kt.sequence,kt.replayData),kt.type==="exit"&&(Mt.getState().setTabLifecycle(Xe,Be,"exited",{expectedExecutionId:gt}),Mt.getState().setConnecting(Xe,Be,!1,{expectedExecutionId:gt}),Mt.getState().setTabPurpose(Xe,Be,{type:"project-action",actionId:He.id,executionId:null}),K(Xe,He.id,gt))},onError:(kt,Tt)=>{B(Xe,Be,gt)&&(Mt.getState().setConnecting(Xe,Be,!1,{expectedExecutionId:gt}),Tt&&(Mt.getState().setTabLifecycle(Xe,Be,"exited",{expectedExecutionId:gt}),Mt.getState().setTabSessionId(Xe,Be,null,{expectedExecutionId:gt}),Mt.getState().setTabPurpose(Xe,Be,{type:"project-action",actionId:He.id,executionId:null}),K(Xe,He.id,gt)))}});if(!B(Xe,Be,gt)){Rt.close();return}X.current[xt]?.(),X.current[xt]=Rt.close,window.clearTimeout(Z.current[xt]),delete Z.current[xt],He.id===mn&&!vt&&(ne(kt=>({...kt,[xt]:!0})),Z.current[xt]=window.setTimeout(()=>{delete Z.current[xt];const kt=ae.current[dt];!kt||kt.executionId!==gt||kt.openedUrl||kt.offering||B(Xe,Be,gt)&&(ne(Tt=>{if(!Tt[xt])return Tt;const Ot={...Tt};return delete Ot[xt],Ot}),Mt.getState().setActiveTab(Xe,Be),V(kt.hostDirectory,Xe))},bx)),Et?(H(Xe,Be,null,{locked:!0,expectedExecutionId:gt}),re(Et),Me.success(o("projectActions.toast.openedForwardedUrl"))):vt?(H(Xe,Be,vt,{locked:!0,autoOpened:!0,expectedExecutionId:gt}),y(et,vt),Me.success(o("projectActions.toast.openedActionUrl"))):ot?(H(Xe,Be,null,{locked:!0,expectedExecutionId:gt}),Me.error(o("projectActions.error.invalidCustomUrlFormat"))):St?(H(Xe,Be,null,{locked:!0,expectedExecutionId:gt}),Me.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):H(Xe,Be,null,{locked:!1,autoOpened:!1,expectedExecutionId:gt})}catch(He){if(ze&&B(ze.directory,ze.tabId,ze.id)){const{directory:ot,tabId:at,id:et}=ze;K(ot,ie.id,et),E(ot,at,"exited",{expectedExecutionId:et}),M(ot,at,{type:"project-action",actionId:ie.id,executionId:null})}if(He instanceof Error&&He.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(He instanceof Error&&(He.message==="COMMAND_MODE_UNSUPPORTED"||He.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Me.error(o("projectActions.error.failedToCreateTerminalSession"));return}Me.error(He instanceof Error?He.message:o("projectActions.error.failedToRunAction"))}finally{se.current.delete(pe)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,be,p,Qe,i,h,f,de,v,w,re,y,J,V,u.isVSCode,xe,B,K,je,oe,N,z,O,D,E,M,H,I,F?.id,o,a]),U=c.useCallback(async ie=>{const pe=dn(xe(ie),ie.id),Ve=J[pe];Ve&&await qp({terminal:a,sessionId:Ve.sessionId,isExecutionStillCurrent:()=>B(Ve.directory,Ve.tabId,Ve.executionId),markStopping:()=>{E(Ve.directory,Ve.tabId,"stopping",{expectedExecutionId:Ve.executionId})},restoreRunning:()=>{E(Ve.directory,Ve.tabId,"running",{expectedExecutionId:Ve.executionId})},clearSession:()=>{I(Ve.directory,Ve.tabId,null,{expectedExecutionId:Ve.executionId})},finalizeExit:()=>{E(Ve.directory,Ve.tabId,"exited",{expectedExecutionId:Ve.executionId}),M(Ve.directory,Ve.tabId,{type:"project-action",actionId:Ve.actionId,executionId:null}),K(Ve.directory,Ve.actionId,Ve.executionId)}})},[K,xe,B,J,E,M,I,a]),he=c.useCallback(()=>{const ie=Ce??Ne[0];if(!ie)return;const pe=dn(xe(ie),ie.id),Ve=J[pe];if(Ve?.status!=="stopping"){if(Ve){U(ie);return}We(ie)}},[Ne,xe,We,J,Ce,U]),Re=c.useCallback(async ie=>{if(ie.source==="shared"&&F){const pe=P.current?.trust.trusted?P.current:await Ja(F);if(P.current=pe,!await yf(F,pe))return;P.current={...pe,trust:{...pe.trust,trusted:!0}}}await We(ie)},[We,F]),Ie=c.useCallback((ie,pe=!1)=>{if(Q(ie.id),!pe){Re(ie);return}const Ve=dn(xe(ie),ie.id),ze=J[Ve];if(ze?.status!=="stopping"){if(ze){U(ie);return}Re(ie)}},[xe,Re,J,U]),rt=c.useCallback(()=>{F?.id&&(b(F.id),x("projects"),m(!0))},[m,x,b,F?.id]),Ge=Ce??Ne[0]??null,ut=Ge?J[dn(xe(Ge),Ge.id)]:null,ct=Mt(ie=>ut?ie.getDirectoryState(ut.directory)?.tabs.find(pe=>pe.id===ut.tabId)?.previewUrl??null:null);if(u.isVSCode||!i&&h||!F||!de)return null;const ue=Ce??Ne[0]??null;if(!ue)return null;const G=oi(ue),Le=dn(xe(ue),ue.id),Oe=J[Le],qe=Oe?.status==="stopping",Ue=Oe?.status==="waiting-for-preview",st=!!(Oe&&ct),wt=()=>{!Oe||!ct||y(Oe.directory,ct)},Nt=ue.id===mn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:q||qe,className:De("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","disabled:cursor-not-allowed",n),onClick:he,"aria-label":Oe?o("projectActions.actions.stopNamedAria",{name:ue.name}):o("projectActions.actions.runNamedAria",{name:ue.name}),children:qe||Ue?s.jsx(R,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Oe?s.jsx(R,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(R,{name:G,className:"h-5 w-5"})})}),Nt?s.jsx(It,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),st?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("projectActions.actions.openPreview"),onClick:wt,children:s.jsx(R,{name:"global",className:"h-4 w-4"})})}),s.jsx(It,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ys,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ut,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(R,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ne.map(ie=>{const pe=oi(ie),Ve=dn(xe(ie),ie.id),ze=J[Ve],He=!!ze,ot=ze?.status==="stopping";return s.jsxs(Ut,{className:"flex items-center gap-2",onClick:()=>{Ie(ie,!0)},children:[s.jsx(R,{name:pe,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ie.name}),ie.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,ot||ze?.status==="waiting-for-preview"?s.jsx(R,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):He?s.jsx(R,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},ie.id)})]})]})]}):s.jsxs("div",{className:De("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:he,disabled:q||qe,className:De("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed"),"aria-label":Oe?o("projectActions.actions.stopNamedAria",{name:ue.name}):o("projectActions.actions.runNamedAria",{name:ue.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:qe||Ue?s.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Oe?s.jsx(R,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(R,{name:G,className:"h-4 w-4"})})})}),Nt?s.jsx(It,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),st?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:wt,className:De(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(R,{name:"global",className:"h-4 w-4"})})}),s.jsx(It,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:De(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ys,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ut,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(R,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ne.map(ie=>{const pe=oi(ie),Ve=dn(xe(ie),ie.id),ze=J[Ve],He=!!ze,ot=ze?.status==="stopping";return s.jsxs(Ut,{className:"flex items-center gap-2",onClick:()=>{Ie(ie,!0)},children:[s.jsx(R,{name:pe,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ie.name}),ie.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,ot||ze?.status==="waiting-for-preview"?s.jsx(R,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):He?s.jsx(R,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},ie.id)})]})]})]})},Mr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},vx=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Mr(n??"");if(i){const o=ud(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function jx(){const t=Kt(w=>w.projects),e=Kt(w=>w.activeProjectId),n=Je(w=>w.availableWorktreesByProject),r=Je(w=>w.currentSessionId),i=wf(r??null),o=Je(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=Je(w=>w.newSessionDraft?.open?Mr(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Mr(o||""),[o]),u=c.useMemo(()=>{const w=typeof i?.directory=="string"?i.directory:"";return Mr(w||"")},[i?.directory]),d=a||u||l,h=c.useMemo(()=>vx({projects:t,worktreesByProject:n,directory:d,activeProjectId:e}),[e,d,t,n]),f=c.useMemo(()=>Mr(d||h?.path||""),[d,h?.path]),p=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),g=c.useRef(null);return c.useEffect(()=>{p&&f&&(g.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:g.current,[p,f])}const kx=({transform:t})=>({...t,y:0}),Cx={Item:Ut,Separator:Os},Nx={Item:({className:t,...e})=>s.jsx(cu,{className:De(hd,t),...e}),Separator:({className:t,...e})=>s.jsx(lu,{className:De(fd,t),...e})},Ax=t=>{const e=tt.c(62),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:u,onMenuOpenChangeComplete:d,children:h}=t,{t:f}=At(),[p,g]=c.useState(!1),[w,v]=c.useState(!1),[x,m]=c.useState(!1);let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:y,listeners:S,setNodeRef:N,transform:C,transition:j,isDragging:A}=qo(b);let D;e[2]!==f||e[3]!==n.session.title?(D=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=D):D=e[4];const I=D,M=!i&&(p||w),z=ha(n.id),E=z?.type==="busy"||z?.type==="retry",B=md(n.id)>0&&!r&&!E,O=E||B;let T;e[5]!==E||e[6]!==f?(T=f(E?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[5]=E,e[6]=f,e[7]=T):T=e[7];const k=T;let P;e[8]!==u||e[9]!==r||e[10]!==o||e[11]!==n?(P=fe=>({session:n.session,isActive:r,select:()=>o(n),closeOtherTabs:()=>u(n.id),components:fe}),e[8]=u,e[9]=r,e[10]=o,e[11]=n,e[12]=P):P=e[12];const L=P;let Q;e[13]!==C?(Q=Qo.Translate.toString(C),e[13]=C,e[14]=Q):Q=e[14];let q;e[15]!==Q||e[16]!==j?(q={transform:Q,transition:j},e[15]=Q,e[16]=j,e[17]=q):q=e[17];const te=A&&"z-10 opacity-60";let ae;e[18]!==te?(ae=De("session-tab-slot flex h-7 w-44 shrink-0 touch-none",te),e[18]=te,e[19]=ae):ae=e[19];const X=r?"true":"false";let Z;e[20]!==r?(Z=r?{"data-active-session-tab":!0}:{},e[20]=r,e[21]=Z):Z=e[21];let se;e[22]!==d?(se=fe=>d?.(fe),e[22]=d,e[23]=se):se=e[23];let me;e[24]!==h||e[25]!==k||e[26]!==r||e[27]!==E||e[28]!==L||e[29]!==p||e[30]!==l||e[31]!==d||e[32]!==o||e[33]!==M||e[34]!==a||e[35]!==O||e[36]!==i||e[37]!==f||e[38]!==n||e[39]!==I?(me=s.jsx(du,{render:fe=>s.jsxs("div",{...fe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:de=>{(de.key==="Enter"||de.key===" ")&&(de.preventDefault(),o(n))},onAuxClick:de=>{de.button===1&&(de.preventDefault(),l(n.id))},"data-controls-open":M?"true":"false",className:De("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection":De("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",M&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:De("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",M&&"pr-10"),children:[s.jsx("div",{className:De("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:I})})}),O?s.jsx("span",{className:De("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",E?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",M&&"opacity-0"),"aria-label":k}):null]}),i?null:s.jsxs("div",{onClick:Dx,onPointerDown:Ix,className:De("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",M&&"flex opacity-100"),children:[s.jsxs(Xs,{open:p,onOpenChange:de=>{g(de),de&&v(!0)},onOpenChangeComplete:de=>{de||v(!1),d?.(de)},children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"more",className:"size-4"})})}),s.jsx(Ys,{align:"start",className:"min-w-[190px]",children:a(L(Cx))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]})]})}),e[24]=h,e[25]=k,e[26]=r,e[27]=E,e[28]=L,e[29]=p,e[30]=l,e[31]=d,e[32]=o,e[33]=M,e[34]=a,e[35]=O,e[36]=i,e[37]=f,e[38]=n,e[39]=I,e[40]=me):me=e[40];let _,ne;e[41]===Symbol.for("react.memo_cache_sentinel")?(_={color:"var(--surface-elevated-foreground)"},ne=De(Si,"min-w-[190px]"),e[41]=_,e[42]=ne):(_=e[41],ne=e[42]);let ye;e[43]!==L||e[44]!==a?(ye=a(L(Nx)),e[43]=L,e[44]=a,e[45]=ye):ye=e[45];let ce;e[46]!==ye?(ce=s.jsx(_i,{children:s.jsx(Li,{className:"app-region-no-drag z-50",children:s.jsx($i,{"data-slot":"dropdown-menu-content",style:_,className:ne,children:ye})})}),e[46]=ye,e[47]=ce):ce=e[47];let F;e[48]!==x||e[49]!==se||e[50]!==me||e[51]!==ce?(F=s.jsxs(uu,{open:x,onOpenChange:m,onOpenChangeComplete:se,children:[me,ce]}),e[48]=x,e[49]=se,e[50]=me,e[51]=ce,e[52]=F):F=e[52];let re;return e[53]!==y||e[54]!==S||e[55]!==N||e[56]!==Z||e[57]!==F||e[58]!==q||e[59]!==ae||e[60]!==X?(re=s.jsx("div",{ref:N,style:q,className:ae,"data-active":X,...Z,...y,...S,children:F}),e[53]=y,e[54]=S,e[55]=N,e[56]=Z,e[57]=F,e[58]=q,e[59]=ae,e[60]=X,e[61]=re):re=e[61],re},Px=t=>{const e=tt.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=At(),u=Jr(Tx),d=Jr(Ex),h=Jr(Rx),f=Jr(Mx),p=Je(Ox),g=Je(Bx),w=Ds(Fx);let v,x;e[0]!==p||e[1]!==d?(v=()=>{p&&d(p)},x=[p,d],e[0]=p,e[1]=d,e[2]=v,e[3]=x):(v=e[2],x=e[3]),c.useEffect(v,x);let m;if(e[4]!==w){m=new Map;for(const be of w)m.set(be.id,be);e[4]=w,e[5]=m}else m=e[5];const b=m;let y;if(e[6]!==b||e[7]!==u){y=[];for(const be of u){const Ee=b.get(be);Ee&&y.push({id:be,session:Ee})}e[6]=b,e[7]=u,e[8]=y}else y=e[8];const S=y;let N;e[9]!==g?(N=be=>{g(be.id,$s(be.session))},e[9]=g,e[10]=N):N=e[10];const C=N,j=_x;let A;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==S?(A=be=>{if(h(be),p&&p!==be){const Ee=S.find(we=>we.id===be);Ee&&C(Ee)}},e[11]=h,e[12]=p,e[13]=C,e[14]=S,e[15]=A):A=e[15];const D=A;let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{distance:8}},e[16]=I):I=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{delay:200,tolerance:6}},e[17]=M):M=e[17];const z=zr(Mn(iu,I),Mn(ou,M));let E;e[18]!==f?(E=be=>{const{active:Ee,over:we}=be;we&&Ee.id!==we.id&&f(String(Ee.id),String(we.id))},e[18]=f,e[19]=E):E=e[19];const H=E,B=c.useRef(null);let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O={left:!1,right:!1},e[20]=O):O=e[20];const[T,k]=c.useState(O);let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const be=B.current;if(!be)return;const Ee=be.scrollLeft>2,we=be.scrollLeft+be.clientWidth<be.scrollWidth-2;k(Y=>Y.left===Ee&&Y.right===we?Y:{left:Ee,right:we})},e[21]=P):P=e[21];const L=P;let Q;e[22]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{L();const be=B.current;if(!be||!globalThis.ResizeObserver)return;const Ee=new ResizeObserver(L);return Ee.observe(be),()=>Ee.disconnect()},e[22]=Q):Q=e[22];let q;e[23]!==S.length?(q=[L,S.length],e[23]=S.length,e[24]=q):q=e[24],c.useEffect(Q,q);let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{B.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=te):te=e[25];let ae;e[26]!==p?(ae=[p],e[26]=p,e[27]=ae):ae=e[27],c.useEffect(te,ae);const X=T.left&&T.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":T.left?"linear-gradient(to right, transparent, black 24px)":T.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let Z;e[28]!==S?(Z=S.map(Lx),e[28]=S,e[29]=Z):Z=e[29];const se=Z;let me;e[30]!==p||e[31]!==S?(me=!p||!S.some(be=>be.id===p),e[30]=p,e[31]=S,e[32]=me):me=e[32];const _=me;let ne;e[33]!==a?(ne=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=ne):ne=e[34];let ye;e[35]!==X?(ye=X?{maskImage:X,WebkitMaskImage:X}:void 0,e[35]=X,e[36]=ye):ye=e[36];let ce;e[37]===Symbol.for("react.memo_cache_sentinel")?(ce=[kx],e[37]=ce):ce=e[37];let F;e[38]!==o||e[39]!==p||e[40]!==D||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==S?(F=S.map(be=>s.jsx(Ax,{tab:be,isActive:be.id===p,suppressControls:be.id===p&&l,onSelect:C,onClose:j,renderMenu:n,closeOtherTabs:D,onMenuOpenChangeComplete:r,children:be.id===p?o:null},be.id)),e[38]=o,e[39]=p,e[40]=D,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=S,e[46]=F):F=e[46];let re;e[47]!==F||e[48]!==se?(re=s.jsx(Io,{items:se,strategy:Mg,children:F}),e[47]=F,e[48]=se,e[49]=re):re=e[49];let fe;e[50]!==H||e[51]!==z||e[52]!==re?(fe=s.jsx(Vr,{sensors:z,collisionDetection:Ur,modifiers:ce,onDragEnd:H,children:re}),e[50]=H,e[51]=z,e[52]=re,e[53]=fe):fe=e[53];let de;e[54]!==o||e[55]!==_?(de=_?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=_,e[56]=de):de=e[56];let ge;e[57]!==ye||e[58]!==fe||e[59]!==de?(ge=s.jsxs("div",{ref:B,onScroll:L,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:ye,children:[fe,de]}),e[57]=ye,e[58]=fe,e[59]=de,e[60]=ge):ge=e[60];let Te;return e[61]!==ne||e[62]!==ge?(Te=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ne,children:ge}),e[61]=ne,e[62]=ge,e[63]=Te):Te=e[63],Te};function Dx(t){return t.stopPropagation()}function Ix(t){return t.stopPropagation()}function Tx(t){return t.tabIds}function Ex(t){return t.ensureTab}function Rx(t){return t.closeOtherTabs}function Mx(t){return t.reorderTabs}function Ox(t){return t.currentSessionId}function Bx(t){return t.setCurrentSession}function Fx(t){return t.activeSessions}function _x(t){Sf(t)}function Lx(t){return t.id}function $x(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(pa(),{month:"short"}),r=e.getDate(),i=e.getFullYear(),o=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0");return`${n} ${r}, ${i}, ${o}:${l}`}function Wx(t){if(t.info.role==="user")return"";const e=typeof t.info.providerID=="string"?t.info.providerID.trim():"",n=typeof t.info.modelID=="string"?t.info.modelID.trim():"";return e&&n?`${e}/${n}`:n||e}function zx(t){const e=t.info.role==="user"?"User":"Assistant",n=$x(t.info.time?.created),r=Wx(t),i=n&&r?`${n} (${r})`:n||r;return i?`**${e}**
|
|
3
|
-
|
|
4
|
-
*${i}*`:`**${e}**`}function Vx(t){return t.filter(e=>e.type==="text"&&typeof e.text=="string").map(e=>e.text).join("")}function bu(t){const e=zx(t),n=Vx(t.parts).trim();return n?`${e}
|
|
5
|
-
|
|
6
|
-
${n}`:""}function yu(t,e){const n="#".repeat(Math.min(e+1,6)),r=t.agent?` — ${t.agent}`:"",i=`${n} Sub-agent: ${t.title}${r}
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
`,o=t.records.map(bu).filter(Boolean).join(`
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
`),l=[i+o];for(const a of t.children)l.push(yu(a,e+1));return l.join(`
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
`)}function wu(t,e,n){const r=e?.trim()||"Session",i=new Date().toISOString().split("T")[0],o=`# ${r}
|
|
19
|
-
|
|
20
|
-
*Exported on ${i}*
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
`,l=t.map(bu).filter(Boolean).join(`
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
`);let a=o+l;if(n&&n.length>0){const u=n.map(d=>yu(d,1)).join(`
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
`);a+=`
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
`+u}return a}function Su(t,e){const n=new Blob([t],{type:"text/markdown;charset=utf-8"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function vu(t,e){const n=await $m(e,t);if(n)return n;if(!Pn())return null;try{const r=await Wo()?.vscode?.saveMarkdown?.({fileName:e,content:t});if(!r||r.saved!==!0)return null;const i=typeof r.path=="string"?r.path.trim():"";return i.length>0?i:null}catch{return null}}async function Ux(t){const e=Wo()?.files;if(e?.revealPath)try{return!!(await e.revealPath(t))?.success}catch{return!1}return await Wm(t)?!0:rd(t)}function Kx(){return pd()}function ju(t){const r=(t?.trim()||"session").normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)||"session",i=new Date().toISOString().split("T")[0];return`${r}-${i}.md`}const zi=(t,e)=>({success:t(e.success),failure:t(e.failure),sourceVerificationFailed:t("sessions.sidebar.session.moveToWorktree.sourceVerificationFailed"),applyChangesFailed:t("sessions.sidebar.session.moveToWorktree.applyChangesFailed"),changesMayBeInDestination:t("sessions.sidebar.session.moveToWorktree.changesMayBeInDestination")}),$n=er(()=>({pendingSessionIds:new Set,requestingSessionIds:new Set,confirmation:null})),ku=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t)||r.requestingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],$n(n)},Hx=()=>$n(sb),Cu=()=>$n.getState().confirmation,Ea=t=>{$n.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Cl=(t,e)=>{$n.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},lr=(t,e)=>{$n.setState(n=>{if(n.requestingSessionIds.has(t)===e)return n;const r=new Set(n.requestingSessionIds);return e?r.add(t):r.delete(t),{...n,requestingSessionIds:r}})},Gx="Unable to apply your changes in the destination directory",qx=t=>t.status===400&&t.message.includes(Gx),Qx=async(t,e)=>{try{const u=(await gd(t,{mode:"light"})).current?.trim();if(u)return u}catch{}const n=yt(t),r=yt(e)??e,i=Je.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>yt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},Nl=t=>{for(const e of t){const n=jf(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class Nu extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const Yx=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new Nu(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},Xx=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(kf(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await xd(o,n,e,!1),Je.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i};class Au extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Al=async(t,e,n)=>{try{await bd(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Pl=async(t,e)=>{const n=e?[t,e]:[t];try{await ga(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},Pu=async(t,e)=>{if($n.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Cl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,Je.getState().getWorktreeMetadata(a.id)]));Nl(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,u]of n.entries()){Nl(n.slice(a));const d=u.id===t.root.id&&t.moveChanges;try{await xd(u,t.sourceDirectory,i.directory,d)}catch(h){throw d&&vf(h)&&(l=!0),h}o.push(u),u.id!==t.root.id&&Je.getState().setWorktreeMetadata(u.id,Za(i.metadata))}}catch(a){const u=a instanceof Error?a:new Error(String(a)),d=await Xx(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Pl(t.sourceDirectory,i?.directory),d.length>0)throw Yx(u,d,l);if(l)throw new Au(u);if(i?.onMoveFailure)return i.onMoveFailure(u);throw u}return Je.getState().setWorktreeMetadata(t.root.id,Za(i.metadata)),await Pl(t.sourceDirectory,i.directory),i.directory}finally{Cl(t.root.id,!1)}},Jx=async t=>{const e=yt(t.sourceDirectory)??t.sourceDirectory,n=yt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return Pu(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Zx=async t=>Pu(t,async()=>{const e=vi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await Uo(t.sourceDirectory)?await Qx(t.sourceDirectory,e.path):null,r=await Cf(e,n?{startRef:n}:{});try{await Nf(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Al(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Al(e,r,i)}}),eb=(t,e,n)=>e instanceof Au?t.changesMayBeInDestination:e instanceof Nu&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&qx(e)?t.applyChangesFailed:e.message,Vi=(t,e)=>{(t.kind==="existing"?Jx({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):Zx({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>Me.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));Me.error(t.messages.failure,{description:eb(t.messages,i,e)})})},tb=()=>{const t=Cu();t&&(lr(t.intent.root.id,!1),Ea(null))},Du=t=>{const e=Cu();if(!e)return;const{intent:n}=e;Ea(null),lr(n.root.id,!1),Vi(n,t)},Ui=t=>{const e=$n.getState();e.confirmation||e.pendingSessionIds.has(t.root.id)||e.requestingSessionIds.has(t.root.id)||(lr(t.root.id,!0),(async()=>{try{if(!await Uo(t.sourceDirectory)){lr(t.root.id,!1),Vi(t,!1);return}const r=await gd(t.sourceDirectory);if(r.isClean){lr(t.root.id,!1),Vi(t,!1);return}const i=r.files.filter(o=>{const l=o.index.trim();return l!==""&&l!=="?"}).length;Ea({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{Me.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),lr(t.root.id,!1)}})())};function sb(t){return t.confirmation}const Ro="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",nb=c.memo(function(e){const n=tt.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:u,iconClassName:d,pressed:h}=e,f=r===void 0?!0:r,p=h===void 0?!1:h;if(!f)return null;const g=a??Ro,w=p&&"bg-interactive-selection text-interactive-selection-foreground";let v;n[0]!==g||n[1]!==w?(v=De(g,w),n[0]=g,n[1]=w,n[2]=v):v=n[2];const x=d??"h-[18px] w-[18px]";let m;n[3]!==u||n[4]!==x?(m=s.jsx(R,{name:u,className:x}),n[3]=u,n[4]=x,n[5]=m):m=n[5];let b;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==v||n[10]!==m?(b=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:v,children:m})}),n[6]=o,n[7]=l,n[8]=p,n[9]=v,n[10]=m,n[11]=b):b=n[11];let y;n[12]!==i?(y=s.jsx(It,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=y):y=n[13];let S;return n[14]!==b||n[15]!==y?(S=s.jsxs(Pt,{children:[b,y]}),n[14]=b,n[15]=y,n[16]=S):S=n[16],S}),rb=c.memo(function(e){const n=tt.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:u,shortcutLabel:d,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:g}=e,{t:w}=At();let v;n[0]!==u||n[1]!==a?(v=z=>{a(z),z&&u()},n[0]=u,n[1]=a,n[2]=v):v=n[2];let x;n[3]!==i||n[4]!==r||n[5]!==w?(x=r?w("header.services.openWithCurrent",{current:i}):w("header.services.open"),n[3]=i,n[4]=r,n[5]=w,n[6]=x):x=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let b;n[7]!==m?(b=De(Ro,m),n[7]=m,n[8]=b):b=n[8];let y;n[9]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(R,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=y):y=n[9];let S;n[10]!==i||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=S):S=n[12];let N;n[13]!==x||n[14]!==b||n[15]!==S?(N=s.jsx(Dt,{asChild:!0,children:s.jsx(Qs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":x,className:b,children:[y,S]})})}),n[13]=x,n[14]=b,n[15]=S,n[16]=N):N=n[16];let C;n[17]!==i||n[18]!==d||n[19]!==w?(C=w("header.services.tooltip.currentInstance",{current:i,toggle:d("toggle_services_menu")}),n[17]=i,n[18]=d,n[19]=w,n[20]=C):C=n[20];let j;n[21]!==C?(j=s.jsx(It,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=j):j=n[22];let A;n[23]!==N||n[24]!==j?(A=s.jsxs(Pt,{children:[N,j]}),n[23]=N,n[24]=j,n[25]=A):A=n[25];let D;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==g||n[30]!==f||n[31]!==p||n[32]!==h||n[33]!==a||n[34]!==w?(D=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:w("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?w("header.services.remoteUpdate.available",{version:h.version||""}):f?w("header.services.remoteUpdate.checking"):p||w("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:g,children:w("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Af,{embedded:!0,open:l,onOpenChange:ab,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=g,n[30]=f,n[31]=p,n[32]=h,n[33]=a,n[34]=w,n[35]=D):D=n[35];let I;n[36]!==D?(I=s.jsx(Ys,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:D}),n[36]=D,n[37]=I):I=n[37];let M;return n[38]!==l||n[39]!==v||n[40]!==A||n[41]!==I?(M=s.jsxs(Xs,{open:l,onOpenChange:v,children:[A,I]}),n[38]=l,n[39]=v,n[40]=A,n[41]=I,n[42]=M):M=n[42],M}),ob=(t,e)=>t===e?!0:!t||!e?!1:t.totalTokens===e.totalTokens&&t.percentage===e.percentage&&t.contextLimit===e.contextLimit&&(t.outputLimit??0)===(e.outputLimit??0)&&(t.normalizedOutput??0)===(e.normalizedOutput??0)&&t.thresholdLimit===e.thresholdLimit&&(t.lastMessageId??"")===(e.lastMessageId??""),vn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Dl=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,ib=()=>{Gs("ui.header.render");const{t}=At(),e=Pe(W=>W.isSidebarOpen),n=Pe(W=>W.openContextOverview),r=Pe(W=>W.closeContextPanel),i=Pe(W=>W.shortcutOverrides),o=Pe(W=>W.sessionTabsEnabled),l=Gt(W=>W.getCurrentModel),a=Je(W=>W.getContextUsage),u=Je(W=>!!W.newSessionDraft?.open),d=Je(W=>W.currentSessionId),h=Pf(d??""),f=ha(d??""),p=ku(d??""),g=Ds(Jn(c.useCallback(W=>{if(!d)return null;const $e=[...W.activeSessions,...W.archivedSessions].find(jt=>jt.id===d);if(!$e)return null;const nt=$e;return{title:$e.title??null,directory:nt.directory??null,created:$e.time?.created??null,slug:nt.slug??null,shareUrl:$e.share?.url??null,parentId:$e.parentID??null}},[d]))),w=Kt(Jn(W=>{if(!W.activeProjectId)return null;const $e=W.projects.find(nt=>nt.id===W.activeProjectId);return $e?{id:$e.id,path:$e.path,label:$e.label}:null})),v=c.useMemo(()=>{if(!w)return null;const W=w.label?.trim();if(W)return W;const $e=w.path.split(/[\\/]/).filter(Boolean);return $e[$e.length-1]??null},[w]),x=ir(W=>W.loadSettings),{isMobile:m}=_n(),b=c.useRef(null),[y,S]=c.useState(()=>typeof window>"u"?!1:xn()),N=c.useMemo(()=>zo(),[]),C=yd(),[j,A]=c.useState(!1),D=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:I,side:M}=Qd(),z=c.useMemo(()=>{if(typeof window>"u")return null;const W=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof W=="number"&&Number.isFinite(W)&&W>0)return W;if(typeof navigator>"u")return null;const $e=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!$e)return null;const nt=Number.parseInt($e[1],10),jt=Number.parseInt($e[2],10);return Number.isNaN(nt)?null:nt===10?jt:nt},[]);ht.useEffect(()=>{typeof window>"u"||S(xn())},[]);const E=l(),H=E&&typeof E.limit=="object"&&E.limit!==null?E.limit:null,B=H&&typeof H.context=="number"?H.context:0,O=H&&typeof H.output=="number"?H.output:0,T=a(B,O),[k,P]=c.useState(null),L=!d||h;ht.useEffect(()=>{if(!d){P(W=>W===null?W:null);return}if(T&&T.totalTokens>0){P(W=>ob(W,T)?W:T);return}L&&P(W=>W===null?W:null)},[T,d,L]);const[Q,q]=c.useState(!1),[te,ae]=c.useState("Local"),[X,Z]=c.useState(!0),[se,me]=c.useState(!1),[_,ne]=c.useState(null),[ye,ce]=c.useState(!1),[F,re]=c.useState(null),fe=c.useMemo(()=>Pn(),[]),de=Pe(W=>W.workStatusPanelVisible),ge=Pe(W=>W.workStatusPanelEnabled),Te=Pe(W=>W.setWorkStatusPanelEnabled),be=Pe(W=>W.workStatusPanelFits),Ee=Pe(W=>W.workStatusOverlayOpen),we=Pe(W=>W.setWorkStatusOverlayOpen),ve=ge&&be||Ee,xe=c.useCallback(()=>{if(ge&&!be){we(!Ee);return}Te(!ge)},[we,Te,Ee,ge,be]),je=!fe&&!de&&!!k&&k.totalTokens>0,oe=k&&k.contextLimit>0?Math.min(999,k.totalTokens/k.contextLimit*100):0,J=c.useCallback(async()=>{if(!(typeof window>"u"||!y))try{if($o()){ae("Local"),Z(!0);return}Z(!1);const W=await od(),$e=zm(),nt=Vm([Um($e),...W.hosts]);if(nt.id===Km){ae("Local"),Z(!0);return}ae(id(nt.label.trim()||"Instance"))}catch{ae("Local"),Z(!0)}},[y]);ht.useEffect(()=>(J(),ma(()=>{J()})),[J]);const K=c.useCallback(async()=>{if(X){ne(null),re(null);return}ce(!0),re(null);try{const W=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),$e=await ds(`/api/openchamber/update-check?${W.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!$e.ok)throw new Error(`Server responded with ${$e.status}`);const nt=await $e.json();ne({available:nt.available??!1,version:nt.version,currentVersion:nt.currentVersion??"unknown",body:nt.body,nextSuggestedCheckInSec:typeof nt.nextSuggestedCheckInSec=="number"?nt.nextSuggestedCheckInSec:void 0,packageManager:nt.packageManager,updateCommand:nt.updateCommand})}catch(W){ne(null),re(W instanceof Error?W.message:t("header.services.remoteUpdate.error"))}finally{ce(!1)}},[X,t]);c.useEffect(()=>{ne(null),re(null),me(!1)},[X,te]),c.useEffect(()=>{if(!y||X)return;const W=3e3,$e=3600*1e3;let nt=!1,jt=null;const Ct=_t=>{jt=window.setTimeout(()=>{if(nt||typeof document<"u"&&document.visibilityState!=="visible"){Ct($e);return}K().finally(()=>{nt||Ct($e)})},_t)};return Ct(W),()=>{nt=!0,jt!==null&&window.clearTimeout(jt)}},[K,X,te,y]);const $=c.useCallback(()=>{if(_?.available){me(!0);return}K()},[K,_?.available]);Df(),c.useEffect(()=>{x()},[x]);const le=d?g??null:null,V=c.useRef(null),[Ce,_e]=c.useState(0);c.useEffect(()=>{if(!d){V.current&&(V.current=null,_e(jt=>jt+1));return}if(le){V.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const W=V.current;if(!W||W.sessionId!==d)return;const $e=W.expiresAt-Date.now();if($e<=0){V.current=null,_e(jt=>jt+1);return}const nt=window.setTimeout(()=>{V.current?.sessionId===d&&(V.current=null),_e(jt=>jt+1)},$e);return()=>{window.clearTimeout(nt)}},[d,le]);const ke=(()=>{if(le)return le;if(!d)return null;const W=V.current;return W&&W.sessionId===d&&W.expiresAt>Date.now()?W.session:null})(),Ne=Je(W=>d?W.worktreeMetadata.get(d)?.path??"":""),Qe=Je(W=>d?W.worktreeMetadata.get(d)?.branch?.trim()??null:null),We=wd(W=>d?W.getAttachment(d):void 0),U=c.useMemo(()=>We?If(We,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,We]),he=c.useMemo(()=>We?We.legacy?"legacy":We.degraded?"degraded":We.worktreeStatus==="pending"?"pending":We.worktreeStatus==="missing"?"missing":We.worktreeStatus==="invalid"?"invalid":We.attentionReason?"attention":null:null,[We]),Re=c.useMemo(()=>vn(Ne||""),[Ne]),Ie=c.useMemo(()=>{const W=typeof ke?.directory=="string"?ke.directory:"";return vn(W||"")},[ke?.directory]),rt=Je(W=>W.newSessionDraft?.open?vn(W.newSessionDraft.bootstrapPendingDirectory??W.newSessionDraft.directoryOverride??""):""),Ge=Je(W=>W.newSessionDraft.target),ut=Je(W=>W.newSessionDraft.selectedProjectId),ct=Je(W=>W.currentSessionDirectory),ue=ts(W=>W.homeDirectory),G=c.useMemo(()=>Re||Ie||rt,[rt,Ie,Re]),Le=Pe(c.useCallback(W=>{const $e=vn(G||"");return $e?Dl(W.contextPanelByDirectory[$e]):null},[G])),Oe=Je(W=>{const $e=vn(Re||Ie||"");if(!$e)return null;for(const nt of W.availableWorktreesByProject.values()){const Ct=nt.find(_t=>vn(_t.path)===$e)?.branch?.trim();if(Ct)return Ct}return null}),Ue=Tf(G||null)||Qe||Oe,st=u?Ge==="chat":Ef(Ie||ct,ue),wt=!st&&!de&&!!(v||Ue||!u&&he),Nt=c.useMemo(()=>{if(!d)return v??"OpenChamber";const W=ke?.title?.trim();return W&&W.length>0?W:"Untitled Session"},[v,ke?.title,d]),ie=Sd(G||void 0,{bootstrap:!1}),pe=vd(),Ve=Je(W=>W.updateSessionTitle),ze=Je(W=>W.shareSession),He=Je(W=>W.unshareSession),ot=Je(W=>W.archiveSessions),at=Je(W=>W.deleteSessions),[et,Xe]=c.useState(!1),[dt,Be]=c.useState(!1),Se=c.useRef(null),[St,vt]=c.useState(""),[Et,Ze]=c.useState(null),it=c.useRef(null),gt=c.useCallback(()=>{d&&(vt(ke?.title?.trim()||Nt),Xe(!0))},[ke?.title,d,Nt]),xt=c.useRef(gt);xt.current=gt;const Rt=c.useCallback(W=>{W&&(W.focus(),W.select())},[]);c.useEffect(()=>{if(Be(!1),Ze(null),d&&Se.current===d){Se.current=null,xt.current();return}Xe(!1),vt("")},[d]);const kt=c.useCallback(async()=>{if(!d)return;const W=St.trim();W&&W!==ke?.title?.trim()&&await Ve(d,W),Xe(!1)},[ke?.title,d,St,Ve]);c.useEffect(()=>{if(!et)return;const W=$e=>{const nt=$e.target;(!nt||!it.current?.contains(nt))&&kt()};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[et,kt]);const Tt=c.useCallback(W=>{W&&pn(W).then($e=>{Me[$e.ok?"success":"error"](t($e.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Me.error(t("sessions.sidebar.session.copyId.error")))},[t]),Ot=c.useCallback(async W=>{if(!W)return;const $e=await ze(W);if($e?.share?.url){const nt=await pn($e.share.url);Me[nt.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(nt.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Me.error(t("sessions.sidebar.session.share.error"))},[ze,t]),Vt=c.useCallback(W=>{W&&pn(W).then($e=>{Me[$e.ok?"success":"error"](t($e.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Me.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),Yt=c.useCallback(async W=>{if(!W)return;const $e=await He(W);Me[$e?"success":"error"](t($e?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,He]),Ht=c.useCallback(async()=>{if(!d||!G){Me.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await pe.loadCompleteHistory(d,G)}catch{Me.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const W=Rf(ie.getState(),d).list;if(W.length===0){Me.error(t("sessions.sidebar.session.export.nothingToExport"));return}const $e=wu(W,ke?.title??null),nt=ju(ke?.title??null);await vu($e,nt)||Su($e,nt),Me.success(t("sessions.sidebar.session.export.success"))},[ke?.title,d,ie,G,pe,t]),Lt=f?.type==="busy"||f?.type==="retry",zt=c.useCallback(()=>{if(!d||!Ie||Lt||p)return;const W=Ds.getState().activeSessions,$e=W.find(Ct=>Ct.id===d);if(!$e)return;const nt=[],jt=[d];for(let Ct=0;Ct<jt.length;Ct+=1){const _t=jt[Ct];for(const os of W)os.parentID===_t&&(nt.push(os),jt.push(os.id))}Ui({kind:"quick",root:$e,descendants:nt,sourceDirectory:Ie,messages:zi(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Lt,p,Ie,t]),Fe=c.useCallback(async()=>{if(!Et)return;const W=Ds.getState().activeSessions,$e=[Et.sessionId];for(let _t=0;_t<$e.length;_t+=1){const os=$e[_t];for(const qt of W)qt.parentID===os&&!$e.includes(qt.id)&&$e.push(qt.id)}const nt=Et.action;if(Ze(null),(nt==="archive"?await ot($e):await at($e)).failedIds.length>0){Me.error(t(nt==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Me.success(t(nt==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ot,at,Et,t]),Ye=Pe(W=>W.isScheduledTasksDialogOpen),mt=Pe(W=>W.isArchivePageOpen),bt=Pe(W=>W.worktreesPageProjectId),ft=Pe(W=>W.isMultiRunLauncherOpen),lt=Kt(W=>{if(!bt)return null;const $e=W.projects.find(nt=>nt.id===bt);return $e?.label?.trim()||$e?.path?.split("/").pop()||null}),$t=c.useMemo(()=>Ye?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:mt?{title:t("sessions.archivePage.title"),subtitle:null}:bt?{title:t("sessions.worktreesPage.title",{project:lt??""}),subtitle:null}:ft?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[mt,ft,Ye,t,bt,lt]),Zt=c.useMemo(()=>vn(G||w?.path||""),[w?.path,G]),Xt=jx(),Ns=xa(W=>W.planModeEnabled),Jt=Je(W=>W.isSessionPlanAvailable),zs=Ns&&d?Jt(d):!1,Js=c.useRef("");c.useEffect(()=>{if(!Ns||!d)return;const W=`${d||"none"}:${Ie||"none"}:${ke?.created||0}:${ke?.slug||"none"}`;Js.current!==W&&(Js.current=W)},[Ns,zs,ke?.slug,ke?.created,d,Ie]);const rs=c.useCallback(()=>{Rn("desktop_open_draft_mini_chat_window",{directory:st?"":rt,projectId:st?null:ut,apiBaseUrl:Nn(),clientToken:Lr()}).catch(W=>{console.warn("[header] failed to open draft mini chat window",W)})},[rt,ut,st]),Vs=c.useCallback(()=>{if(u){rs();return}d&&Rn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ie||vn(ct||"")||Re,apiBaseUrl:Nn(),clientToken:Lr()}).catch(W=>{console.warn("[header] failed to open session mini chat window",W)})},[d,rs,u,ct,Ie,Re]),Es=c.useCallback(()=>{const W=vn(G||"");if(!W)return;const $e=Pe.getState().contextPanelByDirectory[W];if(Dl($e)==="context"){r(W);return}n(W)},[r,n,G]),cn=Le==="context",gs=Ro,vs=c.useMemo(()=>y&&D&&!j?"88px":C?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!y||I)&&!fe?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[y,j,D,C,fe,I]);ht.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",vs)},[vs]);const Zs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Rs=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ht.useEffect(()=>{if(!y||!D){A(!1);return}let W=!1;const $e=async()=>{try{const jt=await Rn("desktop_is_window_fullscreen");W||A(jt===!0)}catch{W||A(!1)}},nt=()=>{$e()};return $e(),window.addEventListener("openchamber:window-resized",nt),()=>{W=!0,window.removeEventListener("openchamber:window-resized",nt)}},[y,D]);const As=c.useMemo(()=>!y||!D||z===null?"":z>=26?"h-12":z<=15?"h-14":"",[y,D,z]),Ps=c.useMemo(()=>{if(!(y&&!I||fe)&&!(I&&M==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[y,fe,I,M]),js=c.useCallback(()=>{if(typeof document>"u")return;const W=b.current?.getBoundingClientRect().height;W&&document.documentElement.style.setProperty("--oc-header-height",`${W}px`)},[]);ht.useEffect(()=>{if(typeof window>"u")return;js();const W=b.current;if(!W||typeof ResizeObserver>"u")return()=>{};let $e=0;const nt=()=>{$e||($e=requestAnimationFrame(()=>{$e=0,js()}))},jt=new ResizeObserver(nt);return jt.observe(W),window.addEventListener("resize",nt),window.addEventListener("orientationchange",nt),()=>{$e&&cancelAnimationFrame($e),jt.disconnect(),window.removeEventListener("resize",nt),window.removeEventListener("orientationchange",nt)}},[js]),ht.useEffect(()=>{js()},[js,m,As]);const Bt=c.useCallback(async W=>{const $e=W.target;$e.closest(".app-region-no-drag")||$e.closest("button, a, input, select, textarea")||W.button===0&&y&&await Hm()},[y]),Wt=c.useCallback(W=>qn(qr(W,i)),[i]);Mf({rename_current_session:()=>{if(!d||m)return!1;gt()},toggle_services_menu:()=>{if(Q){q(!1);return}q(!0),J()}});const ns=s.jsxs(s.Fragment,{children:[Xt?s.jsx(Sx,{projectRef:Xt.projectRef,directory:Xt.directory,className:"mr-2"}):null,s.jsx(Qg,{directory:Zt,className:"mr-1"}),y?s.jsx(rb,{isDesktopApp:y,currentInstanceLabel:te,currentInstanceIsLocal:X,isDesktopServicesOpen:Q,setIsDesktopServicesOpen:q,refreshCurrentInstanceLabel:J,shortcutLabel:Wt,remoteUpdateInfo:_,remoteUpdateChecking:ye,remoteUpdateError:F,onOpenRemoteUpdate:$}):null]}),us=N&&(u||!!d),xs=c.useCallback(({session:W,isActive:$e,select:nt,closeOtherTabs:jt,components:Ct})=>{const{Item:_t,Separator:os}=Ct,qt=W.share?.url??null,en=$e&&!fe&&!st&&ke&&!ke.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(_t,{onClick:()=>{$e||nt(),Se.current=W.id},children:[s.jsx(R,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsxs(_t,{onClick:()=>Tt(W.id),children:[s.jsx(R,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(os,{}),qt?s.jsxs(s.Fragment,{children:[s.jsxs(_t,{onClick:()=>Vt(qt),children:[s.jsx(R,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(_t,{onClick:()=>{Yt(W.id)},children:[s.jsx(R,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(_t,{onClick:()=>{Ot(W.id)},children:[s.jsx(R,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),$e?s.jsxs(_t,{onClick:()=>{Ht()},children:[s.jsx(R,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,en?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(_t,{disabled:!Ie||Lt||p,onClick:zt,className:"w-full",children:[s.jsx(R,{name:"folder-shared",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(It,{side:"right",className:"max-w-72",children:t(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Lt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(os,{}),s.jsxs(_t,{onClick:jt,children:[s.jsx(R,{name:"close-circle",className:"mr-2 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(os,{}),s.jsxs(_t,{onClick:()=>Ze({action:"archive",sessionId:W.id}),children:[s.jsx(R,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(_t,{className:"text-destructive focus:text-destructive",onClick:()=>Ze({action:"delete",sessionId:W.id}),children:[s.jsx(R,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Tt,Vt,ke,Ht,st,Lt,p,fe,zt,Ie,Ot,t,Yt]),ee=()=>s.jsxs("div",{onMouseDown:Bt,className:De("app-region-drag relative flex h-12 select-none items-center",I&&M==="right"?"pr-0":"pr-3",As),style:Ps,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Zs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Rs}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[$t?s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:$t.title}),$t.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:$t.subtitle}):null]}):fe||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[e?null:s.jsx(xl,{align:"start",children:s.jsx("button",{type:"button",className:gs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(R,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[et?s.jsxs("form",{ref:it,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:W=>W.stopPropagation(),onSubmit:W=>{W.preventDefault(),kt()},children:[s.jsx("input",{ref:Rt,value:St,onChange:W=>vt(W.target.value),onKeyDown:W=>{W.stopPropagation(),W.key==="Escape"&&Xe(!1)},placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Xe(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:u?t("sessions.switcher.draftTitle"):Nt}),wt?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[v?s.jsx("span",{className:"truncate",children:v}):null,Ue?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(R,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Ue})]}):null,!u&&he?s.jsxs("span",{className:De("inline-flex min-w-0 items-center gap-0.5",he==="attention"||he==="invalid"||he==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(R,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:U})]}):null]}):null]}),s.jsx("div",{className:De("flex h-[18px] shrink-0 items-center justify-center",wt?"self-start":"self-center"),children:d&&!u&&!et?s.jsxs(Xs,{open:dt,onOpenChange:Be,onOpenChangeComplete:W=>{!W&&Se.current&&Se.current===d&&(Se.current=null,gt())},children:[s.jsx(Qs,{asChild:!0,children:s.jsx(pt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(R,{name:"more",className:"size-4"})})}),s.jsxs(Ys,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Ut,{onClick:()=>{Se.current=d},children:[s.jsx(R,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsxs(Ut,{onClick:()=>d&&Tt(d),children:[s.jsx(R,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Os,{}),ke?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Ut,{onClick:()=>Vt(ke?.shareUrl),children:[s.jsx(R,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Ut,{onClick:()=>{d&&Yt(d)},children:[s.jsx(R,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ut,{onClick:()=>{d&&Ot(d)},children:[s.jsx(R,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Ut,{onClick:()=>{Ht()},children:[s.jsx(R,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),!fe&&!st&&ke&&!ke.parentId?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ut,{disabled:!Ie||Lt||p,onClick:zt,className:"w-full",children:[s.jsx(R,{name:"folder-shared",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(It,{side:"right",className:"max-w-72",children:t(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Lt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Os,{}),s.jsxs(Ut,{onClick:()=>{d&&Ze({action:"archive",sessionId:d})},children:[s.jsx(R,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Ut,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&Ze({action:"delete",sessionId:d})},children:[s.jsx(R,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(xl,{align:"start",children:s.jsx("button",{type:"button",className:gs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(R,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Px,{renderMenu:xs,suppressActiveTabControls:et,onMenuOpenChangeComplete:W=>{!W&&Se.current&&Se.current===d&&(Se.current=null,gt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:et?s.jsxs("form",{ref:it,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:W=>W.stopPropagation(),onSubmit:W=>{W.preventDefault(),kt()},children:[s.jsx("input",{ref:Rt,value:St,onChange:W=>vt(W.target.value),onKeyDown:W=>{W.stopPropagation(),W.key==="Escape"&&Xe(!1)},placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Xe(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:u?t("sessions.switcher.draftTitle"):Nt})})})]}),$t||fe||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[je&&k?s.jsx(Wp,{totalTokens:k.totalTokens,percentage:oe,colorPercentage:k.percentage,contextLimit:k.contextLimit,outputLimit:k.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Es,pressed:cn,className:us?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(nb,{visible:us,title:t(u?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(u?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Vs,className:De(gs,"mr-1"),Icon:"picture-in-picture-2"}),fe?null:s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ve,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:xe,className:De(Ro,"mr-1",ve?"text-foreground":"text-muted-foreground/50"),children:s.jsx(R,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(It,{side:"bottom",children:t(ge&&!be?Ee?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ge?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ns,s.jsx(Yd,{visible:I&&M==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:b,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:ee()}),s.jsx(ws,{open:Et!==null,onOpenChange:W=>{W||Ze(null)},children:s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:Et?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Ts,{children:Et?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Nt}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Nt})})]}),s.jsxs(bn,{children:[s.jsx(pt,{variant:"outline",size:"sm",onClick:()=>Ze(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(pt,{variant:"destructive",size:"sm",onClick:()=>{Fe()},children:Et?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Xd,{open:se,onOpenChange:me,info:_,downloading:!1,downloaded:!1,progress:null,error:F,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function ab(){}const Il=280,Tl=168,El=500,lb=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=At(),l=Pe(j=>j.sidebarWidth),a=Pe(j=>j.setSidebarWidth),[u,d]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||Il),p=c.useRef(null),g=c.useRef(null),w=c.useRef(null),v=c.useCallback(j=>Math.min(El,Math.max(Tl,j)),[]),x=c.useCallback(j=>{const A=w.current;A&&(A.style.width=`${j}px`,A.style.minWidth=`${j}px`,A.style.maxWidth=`${j}px`,A.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);if(c.useEffect(()=>{e&&u&&d(!1)},[e,u]),c.useEffect(()=>{u||(p.current=null,g.current=null)},[u]),e)return null;const m=Math.min(El,Math.max(Tl,l||Il)),b=t?m:0,y=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}g.current=j.pointerId,d(!0),h.current=j.clientX,f.current=b,p.current=b,x(b),j.preventDefault()}},S=j=>{if(e||!u||g.current!==j.pointerId)return;const A=j.clientX-h.current,D=v(f.current+A);p.current!==D&&(p.current=D,x(D))},N=j=>{if(g.current!==j.pointerId||e)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const A=v(p.current??b);g.current=null,p.current=null,d(!1),a(A)},C=u?p.current??b:b;return s.jsxs("aside",{ref:w,className:De("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${u?C:m}px`,overflowX:"clip",transitionProperty:u?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||b===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:De("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",u&&"bg-[var(--interactive-border)]"),onPointerDown:y,onPointerMove:S,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:De("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(ln,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Hs,{children:n})})]})]})},cb=()=>{const t=tt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},Rl="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors",db=()=>{const t=tt.c(32),{t:e}=At(),n=Pe(ub),r=Pe(mb),i=c.useRef(null),o=qn(qr("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=Qd(),u=hb;let d,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{if(typeof document>"u")return;const z=i.current;if(!z)return;const E=()=>{const B=Math.max(z.getBoundingClientRect().width,z.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(B)}px`)};if(E(),typeof ResizeObserver>"u")return;const H=new ResizeObserver(E);return H.observe(z),()=>{H.disconnect()}},h=[],t[0]=d,t[1]=h):(d=t[0],h=t[1]),c.useEffect(d,h);const f="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let p;t[2]===Symbol.for("react.memo_cache_sentinel")?(p={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=p):p=t[2];const g="flex items-center gap-2";let w;t[3]!==l||t[4]!==a?(w=l&&a==="left"?s.jsx(Yd,{visible:!0,position:"left"}):null,t[3]=l,t[4]=a,t[5]=w):w=t[5];let v;t[6]!==e||t[7]!==l?(v=l?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,"aria-label":e("header.actions.openAppMenuAria"),className:De(Rl,"shrink-0"),children:s.jsx(R,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(It,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=l,t[8]=v):v=t[8];const x=Pt;let m;t[9]!==e?(m=e("header.actions.openSessionsAria"),t[9]=e,t[10]=m):m=t[10];let b,y;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=De(Rl,"shrink-0"),y=s.jsx(R,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=b,t[12]=y):(b=t[11],y=t[12]);let S;t[13]!==m||t[14]!==n?(S=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":m,className:b,children:y})}),t[13]=m,t[14]=n,t[15]=S):S=t[15];const N=It,C=e("header.actions.openSessionsWithShortcut",{shortcut:o});let j;t[16]!==C?(j=s.jsx("p",{children:C}),t[16]=C,t[17]=j):j=t[17];let A;t[18]!==N||t[19]!==j?(A=s.jsx(N,{children:j}),t[18]=N,t[19]=j,t[20]=A):A=t[20];let D;t[21]!==x||t[22]!==S||t[23]!==A?(D=s.jsxs(x,{children:[S,A]}),t[21]=x,t[22]=S,t[23]=A,t[24]=D):D=t[24];let I;t[25]!==D||t[26]!==w||t[27]!==v?(I=s.jsxs("div",{ref:i,className:g,children:[w,v,D]}),t[25]=D,t[26]=w,t[27]=v,t[28]=I):I=t[28];let M;return t[29]!==I||t[30]!==p?(M=s.jsx("div",{className:f,style:p,children:I}),t[29]=I,t[30]=p,t[31]=M):M=t[31],M};function ub(t){return t.toggleSidebar}function mb(t){return t.shortcutOverrides}function fb(t){console.warn("[titlebar] failed to open app menu",t)}function hb(t){const e=t.currentTarget.getBoundingClientRect();Rn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(fb)}function Iu(t){const e=tt.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(R,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let u;return e[3]!==i?(u=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=u):u=e[4],u}const Ml=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function pb(t,e,n){const r=tt.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let u=!1;return(async()=>{const[d,h]=await Promise.all([Of(t),Bf(t)]).catch(gb);if(u)return;const f=Ml(d),p=Ml(h);if(!f||!p||p===f)return;const g=n||"",w=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:g,label:g||w,name:w,worktreeRoot:p,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function gb(){return["",""]}const Ol="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",xb=async(t,e)=>{if(t)return t.authActivate(e);const n=await ds("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},Bl=({className:t})=>{const{t:e}=At(),{github:n}=wn(),r=An(g=>g.status),i=An(g=>g.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async g=>{if(!(!g||o)){l(!0);try{i(await xb(n,g))}catch(w){console.error("Failed to switch GitHub account:",w)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const u=r.user?.login??null,d=r.user?.avatarUrl??null,h=r.accounts??[],f=u?e("header.github.connectedWithLogin",{login:u}):e("header.github.connected"),p=d?s.jsx("img",{src:d,alt:u?e("header.github.avatarWithLogin",{login:u}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(R,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:De(Ol,t),title:f,children:p}):s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:De(Ol,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(Ys,{align:"end",className:"w-64",children:[s.jsx(ho,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Os,{}),h.map(g=>{const w=g.user,v=!!g.current,x=g.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Ut,{className:"gap-2",disabled:o,onSelect:()=>{v||a(g.id)},children:[w?.avatarUrl?s.jsx("img",{src:w.avatarUrl,alt:w.login?e("header.github.avatarWithLogin",{login:w.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(R,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:w?.name?.trim()||w?.login||"GitHub"}),w?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:w.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:x})]}):null]}),v?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},g.id)})]})]})};class Yo extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const Xo="/api/walkthrough",Tu=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),Eu=()=>new Yo("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),bb=t=>!Tu(t)&&(t.ok||t.status===404),Ra=async(t,e)=>{if(bb(t))throw Eu();const n=await t.json().catch(()=>null);throw new Yo(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},Ru=async t=>{if(!Tu(t))throw Eu();try{return await t.json()}catch{throw new Yo("The server returned a malformed walkthrough response")}};async function yb(t,e,n={}){const r=await ds(Xo,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?Ru(r):Ra(r,"Failed to load walkthrough")}async function wb(t,e,n={}){const r=await ds(`${Xo}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?Ru(r):Ra(r,"Failed to generate walkthrough")}async function Sb(t,e){const n=await ds(`${Xo}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ra(n,"Failed to cancel walkthrough generation")}async function vb(t,e,n){const r=await ds(`${Xo}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const jr={status:"idle",stage:null,result:null,readiness:null,error:null},jb=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:`pr:${t.number}`,Dn=(t,e)=>`${ps()}\0${t}\0${jb(e)}`,Fl=t=>t instanceof Yo?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},nn=new Map,kr=new Map,kb=1e3,Cb=er()(mu((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Dn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Dn(n,r)],selectModel:(n,r,i)=>{const o=Dn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Dn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Dn(n,r)]??jr,load:async(n,r,i={})=>{if(!n)return;const o=Dn(n,r);if(e().entries[o]?.status==="generating")return;nn.get(o)?.abort();const a=new AbortController;nn.set(o,a),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??jr,status:"loading",error:null}}}));try{const u=await yb(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:u.readiness??null,error:null}}})),u.generating&&e().generate(n,r,{language:i.language})}catch(u){if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??jr,status:"error",stage:null,error:Fl(u)}}}))}finally{nn.get(o)===a&&nn.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Dn(n,r);nn.get(o)?.abort();const l=new AbortController;nn.set(o,l),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??jr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const u=kr.get(o);u!==void 0&&(clearInterval(u),kr.delete(o))};a(),kr.set(o,setInterval(()=>{vb(n,r).then(u=>{!u||l.signal.aborted||t(d=>{const h=d.entries[o];return!h||h.status!=="generating"||h.stage===u?d:{entries:{...d.entries,[o]:{...h,stage:u}}}})}).catch(()=>{})},kb));try{const u=await wb(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:d.entries[o]?.readiness??null,error:null}}}))}catch(u){if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??jr,status:"error",stage:null,error:Fl(u)}}}))}finally{a(),nn.get(o)===l&&nn.delete(o)}},cancel:(n,r)=>{const i=Dn(n,r);Sb(n,r).catch(()=>{}),nn.get(i)?.abort(),nn.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of nn.values())n.abort();nn.clear();for(const n of kr.values())clearInterval(n);kr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Nb="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",Ab=3e4,_l=20,Mu=(t,e)=>JSON.stringify([ps(),t,e]),Pb=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},Ll=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),Zr=new Map,Db=t=>{const e=Object.entries(t);return e.length<=_l?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,_l))},$l=er()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=Mu(r,i),a=o?.includeCheckDetails??!1,u=e().entries[l],d=u&&u.result&&Date.now()-u.fetchedAt<Ab&&(u.hasCheckDetails||!a);if(!o?.force&&d)return u.result;const h=`${l}::${a?"details":"plain"}`,p=Zr.get(`${l}::details`)??(a?null:Zr.get(h));if(p&&!o?.force)return p;const g=(async()=>{t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??Ll(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(v=>({entries:Db({...v.entries,[l]:{result:w,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),w}catch(w){const v=w instanceof Error?w.message:"Failed to load pull request context";return t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??Ll(),isLoading:!1,error:v}}})),null}finally{Zr.delete(h)}})();return Zr.set(h,g),g},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const u=Pb(l);u&&u.directory===n&&(r==null||u.number===r)||(o[l]=a)}return{entries:o}})}})),Ib=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},Tb=35e3,ii=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},ai=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},Wl=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},Eb=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},Rb=[2e3,5e3],Mb=600,zl=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Tn=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},Ob=(t,e)=>{const n=Tn(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Bb=(t,e)=>`${t}::${e}`,Ma=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},li=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=Ma(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},Fb=t=>t.startsWith("pr-"),_b=(t,e)=>{const n=Ma(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!Fb(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Cr=new Map,eo=Vo;function Lb(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const u=await e.repoUpstream(t);if(a||!u?.isFork||!u.upstream||(r(u.upstream),!e.repoBranches))return;try{const d=await e.repoBranches(u.upstream.owner,u.upstream.repo);a||o(d)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const $b=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=At(),u=Pe(ee=>ee.timeFormatPreference),{github:d}=wn(),h=An(ee=>ee.status),f=An(ee=>ee.hasChecked),p=Pe(ee=>ee.setSettingsDialogOpen),g=Pe(ee=>ee.setSettingsPage),w=Je(ee=>ee.currentSessionId),v=Je(ee=>!!ee.newSessionDraft?.open),{isMobile:x,hasTouchInput:m,screenWidth:b}=_n(),y=Pe(ee=>ee.openContextSurface),S=Cb(ee=>ee.requestSource),N=!x&&b>=768&&!Pn(),C=c.useCallback(()=>{g("integrations"),p(!0)},[p,g]),j=c.useMemo(()=>Bb(t,e),[t,e]),A=c.useMemo(()=>Cr.get(j)??null,[j]),D=Ks(ee=>ee.ensureEntry),I=Ks(ee=>ee.setParams),M=Ks(ee=>ee.startWatching),z=Ks(ee=>ee.stopWatching),E=Ks(ee=>ee.refresh),H=Ks(ee=>ee.updateStatus),[B,O]=c.useState(()=>A?.title??zl(e)),[T,k]=c.useState(()=>A?.body??""),[P,L]=c.useState(()=>A?.draft??!1),[Q,q]=c.useState(()=>A?.additionalContext??""),[te,ae]=c.useState(()=>{const ee=typeof A?.targetBaseBranch=="string"?Tn(A.targetBaseBranch):"";return ee||Tn(n)}),[X,Z]=c.useState("squash"),[se,me]=c.useState(!1),[_,ne]=c.useState(!1),[ye,ce]=c.useState(!1),[F,re]=c.useState(!1),[fe,de]=c.useState(!1),[ge,Te]=c.useState(!1),[be,Ee]=c.useState(null),[we,Y]=c.useState(""),[ve,xe]=c.useState(""),[je,oe]=c.useState(!1),[J,K]=c.useState(!1),[$,le]=c.useState(()=>li(i,{selectedRemoteName:A?.selectedRemoteName,trackingBranch:r})),[V,Ce]=c.useState(!1),{detectedUpstream:_e,upstreamBranches:ke}=Lb(t,d);c.useEffect(()=>{Ce(!1)},[t]);const Ne=i.some(ee=>ee.name==="upstream"),We=!!(t&&e&&n&&(e!==n||(Ne||_e!==null))),U=c.useMemo(()=>Ko(t,e,$?.name??null),[t,e,$?.name]),he=Ks(ee=>ee.entries[U]),Re=he?.isLoading??!1,Ie=he?.status??null,rt=he?.error??null,Ge=he?.isInitialStatusResolved??!1,ut=c.useMemo(()=>{const ee=V?null:$?.name?.trim()||null,Ke=new Set;for(const nt of o){const jt=Ob(nt,ee);!jt||jt==="HEAD"||Ke.add(jt)}if(V)for(const nt of ke)nt&&nt!=="HEAD"&&Ke.add(nt);const W=Tn(n);W&&W!=="HEAD"&&Ke.add(W);const $e=Tn(te);return $e&&$e!=="HEAD"&&Ke.add($e),Array.from(Ke).sort((nt,jt)=>nt.localeCompare(jt))},[n,o,$?.name,te,ke,V]);c.useEffect(()=>{if(i.length===0){$&&le(null);return}(!$||!i.some(ee=>ee.name===$.name))&&le(li(i,{selectedRemoteName:A?.selectedRemoteName,trackingBranch:r}))},[A?.selectedRemoteName,i,$,r]),c.useEffect(()=>{const ee=Tn(n);if(!te&&ee){ae(ee);return}if(ut.length!==0&&!ut.includes(te)){const Ke=ut.includes(ee)?ee:ut[0];Ke&&ae(Ke)}},[ut,n,te]);const[ct,ue]=c.useState(()=>A?.activeSegment??"overview"),[G,Le]=c.useState(new Set),[Oe,qe]=c.useState(new Set),Ue=c.useRef(new Set),st=c.useRef(null),wt=c.useRef(!1),Nt=c.useRef(new Set),ie=c.useRef([]);c.useEffect(()=>{_e&&!Ne&&Ce(!0)},[_e,Ne]),c.useEffect(()=>{V&&_e?.defaultBranch&&ae(_e.defaultBranch)},[V,_e?.defaultBranch]);const pe=Ie?.pr??null,Ve=pe?.state==="merged"||pe?.state==="closed",ze=Ve?null:pe,He=ze?Mu(t,ze.number):null,ot=$l(ee=>He?ee.entries[He]:void 0),at=$l(ee=>ee.ensure),et=ot?.result??null,Xe=ot?.isLoading??!1,dt=c.useCallback(ee=>{ue(ee);const Ke=Cr.get(j);Ke&&Cr.set(j,{...Ke,activeSegment:ee})},[j]);c.useEffect(()=>{!ze||!d?.prContext||ct==="overview"||at(d,t,ze.number,{includeCheckDetails:ct==="checks",sourceRepo:Ie?.repo??null})},[ct,t,at,d,ze,Ie?.repo]);const Be=Ie?.checks??null,Se=(Be?.pending??0)>0,St=et?.checkRuns??null,vt=et?.fetchedAt;c.useEffect(()=>{if(!St||St.length===0)return;const ee=Ib(St);H(U,Ke=>{if(!Ke?.pr||typeof vt=="number"&&typeof Ke.fetchedAt=="number"&&vt<Ke.fetchedAt)return Ke;const W=Ke.checks;return W&&W.state===ee.state&&W.total===ee.total&&W.success===ee.success&&W.failure===ee.failure&&W.pending===ee.pending&&W.inProgress===ee.inProgress&&W.queued===ee.queued&&W.startedAt===ee.startedAt?Ke:{...Ke,checks:ee,...typeof vt=="number"?{fetchedAt:vt}:{}}})},[St,vt,U,H]),c.useEffect(()=>{if(ct!=="checks"||!Se||!pe||!d?.prContext)return;const ee=window.setInterval(()=>{at(d,t,pe.number,{includeCheckDetails:!0,sourceRepo:Ie?.repo??null,force:!0})},Tb);return()=>window.clearInterval(ee)},[ct,Se,t,at,d,pe,Ie?.repo]);const[Et,Ze]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Se)return;Ze(Date.now());const ee=window.setInterval(()=>Ze(Date.now()),3e4);return()=>window.clearInterval(ee)},[Se]);const it=pe?`${t}#${pe.number}`:null,gt=!!(it&&be===it);c.useEffect(()=>{if(!d?.prContext||!pe||typeof pe.body=="string"&&pe.body.length>0)return;const ee=`${t}#${pe.number}`;if(Ue.current.has(ee))return;Ue.current.add(ee),Ee(ee);let Ke=!1;return at(d,t,pe.number,{sourceRepo:Ie?.repo??null}).then(W=>{if(Ke)return;const $e=W?.pr;$e&&H(U,nt=>!nt?.pr||nt.pr.number!==pe.number?nt:{...nt,pr:{...nt.pr,body:$e.body||""}})}).catch(()=>{}).finally(()=>{Ke||Ee(W=>W===ee?null:W)}),()=>{Ke=!0}},[t,at,d,pe,U,Ie?.repo,H]),c.useEffect(()=>{if(!pe){Te(!1),Y(""),xe(""),st.current=null;return}const ee=st.current!==null&&st.current!==pe.number;ee&&Te(!1),(!ge||ee)&&(Y(pe.title||""),xe(pe.body||"")),st.current=pe.number},[ge,pe]);const xt=c.useCallback(ee=>{if(!ee)return"";const Ke=Date.parse(ee);return Number.isFinite(Ke)?jd(Ke,u,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):ee},[u]),Rt=c.useMemo(()=>{const ee=h?.user?.login;return typeof ee=="string"?ee.trim():""},[h]),kt=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),Tt=c.useCallback(ee=>{const Ke=Rt.toLowerCase(),W=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return ee.replace(W,($e,nt,jt)=>{const Ct=`@${jt}`,_t=jt.toLowerCase();return`${nt}[${Ct}](https://github.com/${_t}${Ke&&_t===Ke?"?oc-self-mention=1":""})`})},[Rt]),Ot=c.useMemo(()=>{const ee=(et?.issueComments??[]).map($e=>({id:`issue-${$e.id}`,body:$e.body||"",authorName:$e.author?.name||$e.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:$e.author?.login||null,avatarUrl:$e.author?.avatarUrl||null,createdAt:$e.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),Ke=(et?.reviewComments??[]).map($e=>({id:`review-${$e.id}`,body:$e.body||"",authorName:$e.author?.name||$e.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:$e.author?.login||null,avatarUrl:$e.author?.avatarUrl||null,createdAt:$e.createdAt,context:a("gitView.pr.comments.reviewContext"),path:$e.path||null,line:$e.line??null})),W=[...ee,...Ke];return W.sort(($e,nt)=>{const jt=$e.createdAt?Date.parse($e.createdAt):0,Ct=nt.createdAt?Date.parse(nt.createdAt):0,_t=Number.isFinite(jt)?jt:0,os=Number.isFinite(Ct)?Ct:0;return _t-os}),W},[et,a]),Vt=c.useCallback(()=>{const ee=w??(v?"draft":null);return ee?{directory:t,sessionKey:ee}:(Me.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,v,a]),Yt=c.useCallback((ee,Ke)=>{const W=Ke.authorLogin?`@${Ke.authorLogin}`:Ke.authorName,$e=Ke.path?` · ${Ke.path}${Ke.line?`:${Ke.line}`:""}`:"";ji.getState().addDraft(ee,{source:"pr-comment",fileLabel:`PR #${pe?.number??""} ${W}${$e}`,startLine:Ke.line??0,endLine:Ke.line??0,code:Ke.body,language:"markdown",text:""})},[pe?.number]),Ht=c.useCallback((ee,Ke)=>{const W=ee.status||"unknown",$e=ee.conclusion??void 0,nt=$e?`${W} / ${$e}`:W,jt=ee.app?.name||ee.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:Ke?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[Ke?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:ee.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:jt?`${jt} · ${nt}`:nt})]}),ee.detailsUrl?s.jsx(pt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:ee.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(R,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),ee.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:ee.output.title}):null,ee.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:ee.output.summary}):null,ee.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:ee.output.text}):null,Array.isArray(ee.annotations)&&ee.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",ee.annotations.length>20?` (showing 20/${ee.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:ee.annotations.slice(0,20).map((Ct,_t)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[Ct.title||Ct.level||"Issue",Ct.path?` · ${Ct.path}`:"",typeof Ct.startLine=="number"?`:${Ct.startLine}`:"",typeof Ct.endLine=="number"&&Ct.endLine!==Ct.startLine?`-${Ct.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Ct.message}),Ct.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Ct.rawDetails}):null]},`${Ct.path||"file"}:${Ct.startLine||_t}:${_t}`))})]}):null,ee.job?.steps&&ee.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:ee.job.steps.map((Ct,_t)=>{const os=(Ct.conclusion||"").toLowerCase(),qt=os&&!["success","neutral","skipped"].includes(os),en=`${ee.id??"run"}:${ee.job?.jobId??"job"}:${Ct.number??_t}:${Ct.name}`,Sn=G.has(en);return qt?s.jsxs(Ei,{open:Sn,children:[s.jsxs("button",{type:"button",onClick:()=>{Le(Zo=>{const tr=new Set(Zo);return tr.has(en)?tr.delete(en):tr.add(en),tr})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(qt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Sn?s.jsx(R,{name:"arrow-down-s",className:"size-4"}):s.jsx(R,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:Ct.name}),Ct.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Ct.conclusion}):null]}),s.jsx(Ri,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof Ct.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Ct.number]}):null,Ct.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Ct.status]}):null,Ct.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Ct.conclusion]}):null,Ct.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",xt(Ct.startedAt)]}):null,Ct.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",xt(Ct.completedAt)]}):null]})})]},en):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Ct.name}),Ct.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Ct.conclusion}):null]},en)})})]}):null]})},[G,xt,a]),[Lt,zt]=c.useState(!1),[Fe,Ye]=c.useState(!1),mt=c.useCallback(async()=>{if(!d?.prContext){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!pe)return;const ee=Vt();if(ee){zt(!0);try{const Ke=await at(d,t,pe.number,{includeCheckDetails:!0,sourceRepo:Ie?.repo??null});if(!Ke){Me.error(a("gitView.pr.toast.loadChecksFailed"));return}const $e=(Ke.checkRuns??[]).filter(jt=>ai(jt.conclusion));if($e.length===0){Me.message(a("gitView.pr.toast.noFailedChecks"));return}const nt=ji.getState();for(const jt of $e){const Ct=(jt.annotations??[]).map(qt=>[[qt.level,qt.title].filter(Boolean).join(" "),qt.path?`${qt.path}${typeof qt.startLine=="number"?`:${qt.startLine}`:""}`:null,qt.message,qt.rawDetails].filter(Boolean).join(`
|
|
37
|
-
`)),_t=(jt.job?.steps??[]).filter(qt=>ai(qt.conclusion)).map(qt=>`step ${qt.number??"?"}: ${qt.name} → ${qt.conclusion}`),os=[`check: ${jt.job?.workflowName?`${jt.job.workflowName} / ${jt.name}`:jt.name}`,`status: ${jt.status??"unknown"} / ${jt.conclusion??"unknown"}`,jt.detailsUrl?`url: ${jt.detailsUrl}`:null,jt.output?.title?`title: ${jt.output.title}`:null,jt.output?.summary?`summary:
|
|
38
|
-
${jt.output.summary}`:null,_t.length>0?`failed steps:
|
|
39
|
-
${_t.join(`
|
|
40
|
-
`)}`:null,Ct.length>0?`annotations:
|
|
41
|
-
${Ct.join(`
|
|
42
|
-
---
|
|
43
|
-
`)}`:null].filter(Boolean).join(`
|
|
44
|
-
|
|
45
|
-
`);nt.addDraft(ee,{source:"pr-check",fileLabel:`PR #${pe.number} · ${jt.name}`,startLine:0,endLine:0,code:os,language:"text",text:""})}}catch(Ke){const W=Ke instanceof Error?Ke.message:String(Ke);Me.error(a("gitView.pr.toast.loadChecksFailed"),{description:W})}finally{zt(!1)}}},[t,at,d,pe,Vt,Ie?.repo,a]),bt=c.useCallback(async()=>{if(!d?.prContext){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!pe)return;const ee=Vt();if(ee){Ye(!0);try{if(!await at(d,t,pe.number,{sourceRepo:Ie?.repo??null})){Me.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(Ot.length===0){Me.message(a("gitView.pr.toast.noPrComments"));return}for(const W of Ot)Yt(ee,W)}catch(Ke){const W=Ke instanceof Error?Ke.message:String(Ke);Me.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:W})}finally{Ye(!1)}}},[Yt,t,at,d,pe,Vt,Ie?.repo,a,Ot]),ft=c.useCallback(async ee=>{const Ke=Vt();Ke&&Yt(Ke,ee)},[Yt,Vt]),lt=c.useCallback(async ee=>{await E(U,ee)},[U,E]),[$t,Zt]=c.useState(!1),Xt=c.useRef(!0);c.useEffect(()=>(Xt.current=!0,()=>{Xt.current=!1}),[]);const Ns=c.useCallback(async()=>{if($t)return;Zt(!0);const ee=Date.now();try{await lt({force:!0})}finally{const Ke=Mb-(Date.now()-ee);Ke>0&&await new Promise(W=>window.setTimeout(W,Ke)),Xt.current&&Zt(!1)}},[$t,lt]),Jt=c.useCallback(()=>{ie.current.forEach(ee=>{window.clearTimeout(ee)}),ie.current=Rb.map(ee=>window.setTimeout(()=>{lt({force:!0,silent:!0,markInitialResolved:!0})},ee))},[lt]);c.useEffect(()=>{if(!d?.prStatus||!We||i.length<=1||wt.current||Ie?.pr)return;const ee=`${j}::${$?.name??""}`;if(Nt.current.has(ee))return;Nt.current.add(ee);const Ke=_b(i,r).filter(nt=>nt.name!==$?.name);if(Ke.length===0)return;let W=!1;return(async()=>{for(const nt of Ke){if(W)return;try{if(!(await d.prStatus(t,e,nt.name))?.pr)continue;if(W)return;le(Ct=>Ct?.name===nt.name?Ct:nt);return}catch{}}})(),()=>{W=!0}},[e,We,t,d,i,$?.name,j,Ie?.pr,r]),c.useEffect(()=>{D(U),I(U,{directory:t,branch:e,remoteName:$?.name??null,canShow:We,github:d,githubAuthChecked:f,githubConnected:h?.connected??null})},[e,We,t,D,d,f,h?.connected,U,$?.name,I]),c.useEffect(()=>(M(U),()=>{z(U)}),[U,M,z]),c.useEffect(()=>{const ee=Cr.get(j)??null;O(ee?.title??zl(e)),k(ee?.body??""),L(ee?.draft??!1),ae(ee?.targetBaseBranch?Tn(ee.targetBaseBranch):Tn(n));const Ke=li(i,{selectedRemoteName:ee?.selectedRemoteName,trackingBranch:r});le(W=>W?.name===Ke?.name?W:Ke)},[n,e,i,j,r]),c.useEffect(()=>{lt({markInitialResolved:!0})},[U,lt]),c.useEffect(()=>{!We||!$?.name||lt({force:!0,silent:!0,markInitialResolved:!0})},[We,lt,$?.name]),c.useEffect(()=>{const ee=Ie?.resolvedRemoteName?.trim();if(!ee||wt.current)return;const Ke=i.find(W=>W.name===ee);Ke&&le(W=>W?.name===Ke.name?W:Ke)},[i,Ie?.resolvedRemoteName]),c.useEffect(()=>{const ee=()=>{const W=Ks.getState().entries[U]?.lastRefreshAt??0;Date.now()-W>6e4&<({force:!0,silent:!0})},Ke=()=>{document.visibilityState==="visible"&&ee()};return window.addEventListener("focus",ee),document.addEventListener("visibilitychange",Ke),()=>{window.removeEventListener("focus",ee),document.removeEventListener("visibilitychange",Ke)}},[U,lt]),c.useEffect(()=>{f&&h?.connected===!1&<({force:!0,silent:!0,markInitialResolved:!0})},[f,h,lt]),c.useEffect(()=>{!t||!e||Cr.set(j,{title:B,body:T,draft:P,additionalContext:Q,targetBaseBranch:te,selectedRemoteName:$?.name,activeSegment:ct})},[j,B,T,P,Q,te,$?.name,t,e,ct]),c.useEffect(()=>{const ee=ie.current;return()=>{ee.forEach(Ke=>{window.clearTimeout(Ke)}),ie.current=[]}},[]);const zs=c.useCallback(async()=>{if(!se&&t){me(!0);try{const Ke={base:V&&_e?.defaultBranchSha?_e.defaultBranchSha:te,head:e};Q&&(Ke.context=Q);const W=await Ff(t,Ke);W.title?.trim()&&O(W.title.trim()),W.body?.trim()&&k(W.body.trim()),l?.()}catch(ee){const Ke=ee instanceof Error?ee.message:String(ee);Me.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:Ke})}finally{me(!1)}}},[Q,e,_e?.defaultBranchSha,t,se,l,te,a,V]),Js=c.useCallback(async()=>{if(!d?.prCreate){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}const ee=B.trim();if(!ee){Me.error(a("gitView.pr.toast.titleRequired"));return}const Ke=te.trim();if(!Ke){Me.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!V&&Ke===e){Me.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}ne(!0);try{const W=Ma(r),$e=V&&_e,nt=await d.prCreate({directory:t,title:ee,head:e,base:Ke,...T.trim()?{body:T}:{},draft:P,...$e?{targetRepo:{owner:_e.owner,repo:_e.repo},headRemote:"origin"}:{...$?{remote:$.name}:{},...W&&W!==$?.name?{headRemote:W}:{}}});Me.success(a("gitView.pr.toast.prCreated")),H(U,jt=>jt&&{...jt,pr:nt}),await lt({force:!0}),Jt()}catch(W){const $e=W instanceof Error?W.message:String(W);Me.error(a("gitView.pr.toast.createPrFailed"),{description:$e})}finally{ne(!1)}},[T,e,_e,t,P,d,U,lt,Jt,$,te,B,r,H,V,a]),rs=c.useCallback(async ee=>{if(!d?.prMerge){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}re(!0);try{const Ke=await d.prMerge({directory:t,number:ee.number,method:X});Ke.merged?Me.success(a("gitView.pr.toast.prMerged")):Me.message(a("gitView.pr.toast.prNotMerged"),{description:Ke.message||a("gitView.pr.notMergeable")}),await lt({force:!0}),Jt()}catch(Ke){const W=Ke instanceof Error?Ke.message:String(Ke);Me.error(a("gitView.pr.toast.mergeFailed"),{description:W}),ee.url&&eo(ee.url)}finally{re(!1)}},[t,d,X,lt,Jt,a]),Vs=c.useCallback(async ee=>{if(!d?.prReady){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}de(!0);try{await d.prReady({directory:t,number:ee.number}),Me.success(a("gitView.pr.toast.markedReady")),await lt({force:!0}),Jt()}catch(Ke){const W=Ke instanceof Error?Ke.message:String(Ke);Me.error(a("gitView.pr.toast.markReadyFailed"),{description:W}),ee.url&&eo(ee.url)}finally{de(!1)}},[t,d,lt,Jt,a]),Es=c.useCallback(async ee=>{if(!d?.prUpdate){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}const Ke=we.trim();if(!Ke){Me.error(a("gitView.pr.toast.titleRequired"));return}ce(!0);try{const W=await d.prUpdate({directory:t,number:ee.number,title:Ke,body:ve});H(U,$e=>$e&&{...$e,pr:{...$e.pr??ee,...W}}),Te(!1),Me.success(a("gitView.pr.toast.prUpdated")),await lt({force:!0}),Jt()}catch(W){const $e=W instanceof Error?W.message:String(W);Me.error(a("gitView.pr.toast.updatePrFailed"),{description:$e})}finally{ce(!1)}},[t,ve,we,d,U,lt,Jt,H,a]);if(!We)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx(Bl,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const cn=Ie?.repo?.url||null,gs=V&&_e?.url?_e.url:cn,vs=!!Ie?.canMerge,Zs=!!Ie?.connected,Rs=f&&Ie?.connected===!1,As=Eb(Ie),Ps=As?`var(--pr-${As})`:"var(--status-info)",js=As==="draft"?"git-pr-draft":As==="merged"?"git-merge":As==="closed"?"git-close-pull-request":"git-pull-request",Bt=pe?[`${pe.state}${pe.draft?" (draft)":""}`,pe.mergeable===!1?a("gitView.pr.notMergeable"):null,pe.state==="open"&&typeof pe.mergeableState=="string"&&pe.mergeableState&&pe.mergeableState!=="unknown"?pe.mergeableState:null].filter(Boolean).join(" · "):"",Wt=Be?Be.total>0?`${Be.success}/${Be.total} ${a("gitView.pr.checks.label")}`:`${Be.state} ${a("gitView.pr.checks.label")}`:"";return s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[s.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[s.jsxs("div",{className:"@container/pr-actions flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[pe?s.jsxs(pt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{eo(pe.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(R,{name:js,className:"size-4 shrink-0",style:{color:Ps}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(R,{name:js,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),pe?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",pe.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[pe&&N?s.jsxs(pt,{variant:"outline",size:"sm",className:De("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Nb),onClick:()=>{S(t,{kind:"pr",number:pe.number}),y(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(R,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Re||$t,onClick:()=>{Ns()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Re||$t?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(R,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(Bl,{className:"h-7 w-7"})]})]}),pe?s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:Ps},children:Bt}),Be?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${Wl(Be.state)}`}),Wt]}):null,r&&$&&r.split("/")[0]!==$.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",$.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[vs&&pe.draft&&pe.state==="open"?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Vs(pe),disabled:fe||F||ye||ge,"aria-label":a("gitView.pr.actions.markReadyAria"),children:fe?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,vs?s.jsxs(s.Fragment,{children:[s.jsxs(Bs,{value:X,onValueChange:ee=>Z(ee),disabled:F||pe.state!=="open",children:[s.jsx(Fs,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Cs,{})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(ss,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(ss,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>rs(pe),disabled:F||fe||pe.state!=="open"||pe.draft||ye||ge,"aria-label":a("gitView.pr.actions.mergePrAria"),children:F?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"git-merge",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[Rs?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(pt,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,rt?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:rt}),gs?s.jsx(pt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:gs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(R,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!pe&&!Ge&&!rt&&!Rs?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):pe&&!Ve?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(Jd,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Be&&Be.total>0?`${a("gitView.pr.segment.checks")} ${Be.success}/${Be.total}`:a("gitView.pr.segment.checks"),icon:Be?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Wl(Be.state)}`}):void 0},{id:"comments",label:et?`${a("gitView.pr.segment.comments")} ${(et.issueComments?.length??0)+(et.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:ct,onSelect:ee=>dt(ee),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),ct==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[vs&&pe.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,vs?null:s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:ge?s.jsx(Cn,{value:we,onChange:ee=>Y(ee.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:pe.title})}),pe.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:ge?s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Te(!1),Y(pe.title||""),xe(pe.body||"")},disabled:ye,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(R,{name:"close",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>Es(pe),disabled:ye||!we.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:ye?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"check",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Te(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(R,{name:"edit",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),ge?s.jsx(ar,{value:ve,onChange:ee=>xe(ee.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):null,ge?null:pe.body?.trim()?s.jsx(el,{content:pe.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(gt?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,ct==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Be&&Be.total>0?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[Be.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Be.success/Be.total*100}%`}}):null,Be.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Be.failure/Be.total*100}%`}}):null,Be.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Be.pending/Be.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Be.success,"/",Be.total," ",a("gitView.pr.checks.label")]}),(Be.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}),ii(Be.startedAt,void 0,Et)]}):null]}):null,Be?.failure?s.jsxs(pt,{variant:"outline",size:"sm",className:"w-fit gap-1.5 border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",onClick:mt,disabled:Lt,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Lt?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(et?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(et?.checkRuns??[]).map((ee,Ke)=>{const W=`${ee.id??"run"}:${ee.name}:${Ke}`,$e=ee.status==="in_progress",nt=ee.status==="queued",jt=ai(ee.conclusion),Ct=Oe.has(W),_t=!!(ee.output?.title||ee.output?.summary||ee.output?.text||(ee.annotations?.length??0)>0||(ee.job?.steps?.length??0)>0||ee.detailsUrl),os=ee.job?.workflowName,qt=$e?ii(ee.startedAt,void 0,Et):ii(ee.startedAt,ee.completedAt);return s.jsxs("div",{className:De("rounded-md border border-border/40",jt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!_t,onClick:()=>{qe(en=>{const Sn=new Set(en);return Sn.has(W)?Sn.delete(W):Sn.add(W),Sn})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[$e?s.jsx(R,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):nt?s.jsx(R,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):jt?s.jsx(R,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(R,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:os&&os!==ee.name?`${os} / ${ee.name}`:ee.name}),qt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:qt}):null,_t?s.jsx(R,{name:"arrow-down-s",className:De("size-4 shrink-0 text-muted-foreground transition-transform",Ct&&"rotate-180")}):null]}),Ct&&_t?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Ht(ee,{hideHeader:!0})}):null]},W)})}):Xe?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,ct==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Ot.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(pt,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)]",onClick:bt,disabled:Fe,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Fe?s.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(R,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,Ot.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:Ot.map((ee,Ke)=>{const W=(ee.authorName||"?").charAt(0).toUpperCase(),$e=Ke===Ot.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[$e?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:ee.avatarUrl?s.jsx("img",{src:ee.avatarUrl,alt:ee.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:W})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1 typography-micro text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-1 sm:gap-y-1",children:[s.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[ee.authorName,ee.authorLogin&&ee.authorLogin!==ee.authorName?` · @${ee.authorLogin}`:""]}),ee.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:xt(ee.createdAt)}):null,s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs(pt,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{ft(ee)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(R,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[ee.context,ee.path?` · ${ee.path}`:"",ee.line?`:${ee.line}`:""]}),s.jsx(el,{content:Tt(ee.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",kt].filter(Boolean).join(" "),enableFileReferences:!1})]})]},ee.id)})})}):Xe&&!et?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[pe&&Ve?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[s.jsx(R,{name:pe.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Ps}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:pe.state==="merged"?a("gitView.pr.history.merged",{number:pe.number,base:pe.base||te}):a("gitView.pr.history.closed",{number:pe.number})}),s.jsx(pt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{eo(pe.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(R,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",te," ",s.jsxs("span",{className:"opacity-60",children:["(",V&&_e?"upstream":"remote",")"]})]})]}),gs?s.jsx(pt,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:gs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(R,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),s.jsx(Cn,{value:B,onChange:ee=>O(ee.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),ut.length>0?s.jsxs(Bs,{value:te,onValueChange:ae,children:[s.jsx(Fs,{size:"lg",children:s.jsx(Cs,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(_s,{children:ut.map(ee=>s.jsx(ss,{value:ee,children:ee},ee))})]}):s.jsx(Cn,{value:te,onChange:ee=>ae(ee.target.value),placeholder:a("gitView.pr.placeholder.main")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),s.jsx(ar,{value:T,onChange:ee=>k(ee.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":P,onClick:()=>L(ee=>!ee),onKeyDown:ee=>{(ee.key===" "||ee.key==="Enter")&&(ee.preventDefault(),L(Ke=>!Ke))},children:[s.jsx(dr,{size:"sm",checked:P,onChange:ee=>L(ee),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),x?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx(pt,{variant:"outline",size:"sm",onClick:()=>K(!0),children:Q.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),Q.trim()&&s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):s.jsxs(Ei,{open:je,onOpenChange:oe,children:[s.jsxs(Zd,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:je?a("gitView.pr.actions.hide"):Q.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(Ri,{children:s.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[s.jsx(ar,{value:Q,onChange:ee=>q(ee.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(Ho,{open:J,onClose:()=>K(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(pt,{size:"sm",onClick:()=>K(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(ar,{value:Q,onChange:ee=>q(ee.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(pt,{variant:"outline",size:"sm",onClick:zs,disabled:se||_,children:[se?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(pt,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:Js,disabled:_||!Zs||!te.trim()||!V&&te.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:_?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},ci=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),to=new Map,so=new Map,In=t=>`${ps()}::${t}`,Wb=()=>{const t=tt.c(115),{t:e}=At(),{git:n}=wn(),r=br(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=_f(r??null),a=ba(o??null),u=kd(o??null),d=Cd(o??null),{ensureAll:h,ensureNestedRepos:f,selectNestedRepo:p}=On(Jn(zb)),g=Je(Vb),w=Je(Ub),v=Je(Kb),x=Je(Hb);let m;t[0]!==r?(m=ci(r),t[0]=r,t[1]=m):m=t[1];const b=m;let y;if(t[2]!==x||t[3]!==b||t[4]!==v){e:{if(!b){y=void 0;break e}let $;if(t[6]!==x||t[7]!==b){let V;t[9]!==b?(V=Ce=>ci(Ce.path)===b,t[9]=b,t[10]=V):V=t[10],$=x.find(V),t[6]=x,t[7]=b,t[8]=$}else $=t[8];const le=$;if(le){y=le;break e}for(const V of v.values())if(ci(V.path)===b){y=V;break e}y=void 0}t[2]=x,t[3]=b,t[4]=v,t[5]=y}else y=t[5];const S=y;let N;t[11]!==g||t[12]!==S||t[13]!==w?.open||t[14]!==v?(N=()=>{if(g)return v.get(g)??S;if(w?.open)return S},t[11]=g,t[12]=S,t[13]=w?.open,t[14]=v,t[15]=N):N=t[15],w?.open;let C;t[16]!==N?(C=N(),t[16]=N,t[17]=C):C=t[17];const j=C;let A;t[18]!==g?(A=$=>g?$.getAttachment(g):void 0,t[18]=g,t[19]=A):A=t[19];const D=wd(A),I=D&&!D.degraded&&!D.legacy?D.worktreeRoot??void 0:void 0,M=pb(r,j,a?.current??void 0);let z,E;t[20]!==h||t[21]!==n||t[22]!==o?(z=()=>{!o||!n||h(o,n)},E=[o,h,n],t[20]=h,t[21]=n,t[22]=o,t[23]=z,t[24]=E):(z=t[23],E=t[24]),c.useEffect(z,E);const[H,B]=c.useState(null);let O;t[25]!==I||t[26]!==M?.projectDirectory?(O=()=>{const $=I||M?.projectDirectory;if(!$){B(null);return}let le=!1;return Go($).then(V=>{if(le)return;const Ce=V.trim();B(Ce&&Ce!=="HEAD"?Ce:null)}).catch(()=>{le||B(null)}),()=>{le=!0}},t[25]=I,t[26]=M?.projectDirectory,t[27]=O):O=t[27];const T=M?.projectDirectory;let k;t[28]!==I||t[29]!==T?(k=[I,T],t[28]=I,t[29]=T,t[30]=k):k=t[30],c.useEffect(O,k);let P;t[31]!==o?(P=()=>(o?to.get(In(o)):void 0)??[],t[31]=o,t[32]=P):P=t[32];const[L,Q]=c.useState(P);let q;t[33]!==o?(q=()=>(o?so.get(In(o)):void 0)??null,t[33]=o,t[34]=q):q=t[34];const[te,ae]=c.useState(q);let X,Z;t[35]!==n||t[36]!==o?(X=()=>{if(!o||!n?.getRemotes){Q([]);return}Q(to.get(In(o))??[]);let $=!1;return n.getRemotes(o).then(le=>{$||(to.set(In(o),le??[]),Q(le??[]))}).catch(()=>{$||Q(to.get(In(o))??[])}),()=>{$=!0}},Z=[o,n],t[35]=n,t[36]=o,t[37]=X,t[38]=Z):(X=t[37],Z=t[38]),c.useEffect(X,Z);let se,me;t[39]!==n||t[40]!==o?(se=()=>{if(!o||!n?.getRemoteUrl){ae(null);return}ae(so.get(In(o))??null);let $=!1;return n.getRemoteUrl(o).then(le=>{$||(so.set(In(o),le),ae(le))}).catch(()=>{$||ae(so.get(In(o))??null)}),()=>{$=!0}},me=[o,n],t[39]=n,t[40]=o,t[41]=se,t[42]=me):(se=t[41],me=t[42]),c.useEffect(se,me);let _;e:{if(!u?.all){let le;t[43]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[43]=le):le=t[43],_=le;break e}let $;t[44]!==u.all?($=u.all.filter(Gb).sort(),t[44]=u.all,t[45]=$):$=t[45],_=$}const ne=_;let ye;e:{if(!u?.all){let le;t[46]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[46]=le):le=t[46],ye=le;break e}let $;t[47]!==u.all?($=u.all.filter(qb).map(Qb).sort(),t[47]=u.all,t[48]=$):$=t[48],ye=$}const ce=ye;let F;t[49]!==ce||t[50]!==te||t[51]!==L||t[52]!==a?.tracking?(F=()=>{if(L.length>0)return L;const $=new Set,le=a?.tracking?.trim();le&&le.includes("/")&&$.add(le.split("/")[0]);for(const V of ce){const Ce=V.indexOf("/");Ce>0&&$.add(V.slice(0,Ce))}return $.size===0&&te&&$.add("origin"),Array.from($).map(V=>({name:V,fetchUrl:te??"",pushUrl:te??""}))},t[49]=ce,t[50]=te,t[51]=L,t[52]=a?.tracking,t[53]=F):F=t[53],a?.tracking;let re;t[54]!==F?(re=F(),t[54]=F,t[55]=re):re=t[55];const fe=re,de=a?.current??null;a?.tracking;let ge;t[56]!==a?.tracking?(ge=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=ge):ge=t[57];const Te=ge,be=(Te&&u?.defaultBranches?.[Te])??u?.defaultBranches?.origin;let Ee;t[58]!==de||t[59]!==be||t[60]!==fe||t[61]!==ne||t[62]!==H||t[63]!==M?.createdFromBranch?(Ee=()=>Jp({remoteNames:new Set(fe.map(Yb)),localBranches:ne,worktreeCreatedFromBranch:M?.createdFromBranch,rootBranchHint:H,defaultBranch:be,headBranch:de}),t[58]=de,t[59]=be,t[60]=fe,t[61]=ne,t[62]=H,t[63]=M?.createdFromBranch,t[64]=Ee):Ee=t[64],M?.createdFromBranch;let we;t[65]!==Ee?(we=Ee(),t[65]=Ee,t[66]=we):we=t[66];const Y=we;if(!r){let $;t[67]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(R,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=$):$=t[67];let le;t[68]!==e?(le=e("gitView.pullRequest.title"),t[68]=e,t[69]=le):le=t[69];let V;t[70]!==le?(V=s.jsx("div",{className:"typography-ui-header text-foreground",children:le}),t[70]=le,t[71]=V):V=t[71];let Ce;t[72]!==e?(Ce=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=Ce):Ce=t[73];let _e;t[74]!==Ce?(_e=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ce}),t[74]=Ce,t[75]=_e):_e=t[75];let ke;return t[76]!==V||t[77]!==_e?(ke=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[$,V,_e]}),t[76]=V,t[77]=_e,t[78]=ke):ke=t[78],ke}if(i===!1&&d!==!0){let $;t[79]!==r||t[80]!==f?($=()=>{f(r,{force:!0})},t[79]=r,t[80]=f,t[81]=$):$=t[81];let le;return t[82]!==d||t[83]!==l||t[84]!==i||t[85]!==$?(le=s.jsx(Zp,{rootIsGitRepo:i,resolvedIsGitRepo:d,nestedRepos:l,onRetryDiscovery:$}),t[82]=d,t[83]=l,t[84]=i,t[85]=$,t[86]=le):le=t[86],le}if(!de){let $;t[87]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(R,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=$):$=t[87];let le;t[88]!==e?(le=e("gitView.pullRequest.title"),t[88]=e,t[89]=le):le=t[89];let V;t[90]!==le?(V=s.jsx("div",{className:"typography-ui-header text-foreground",children:le}),t[90]=le,t[91]=V):V=t[91];let Ce;t[92]!==e?(Ce=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=Ce):Ce=t[93];let _e;t[94]!==Ce?(_e=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ce}),t[94]=Ce,t[95]=_e):_e=t[95];let ke;return t[96]!==V||t[97]!==_e?(ke=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[$,V,_e]}),t[96]=V,t[97]=_e,t[98]=ke):ke=t[98],ke}const ve=i===!1&&Array.isArray(l)&&l.length>0;let xe;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==p||t[103]!==ve?(xe=ve?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(eg,{repositories:l,selectedRepository:o??null,onSelectRepository:$=>{r&&p(r,$)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=p,t[103]=ve,t[104]=xe):xe=t[104];const je=o??r,oe=a?.tracking??void 0;let J;t[105]!==Y||t[106]!==de||t[107]!==ce||t[108]!==L||t[109]!==je||t[110]!==oe?(J=s.jsx(ln,{as:ya,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx($b,{directory:je,branch:de,baseBranch:Y,trackingBranch:oe,remotes:L,remoteBranches:ce})}),t[105]=Y,t[106]=de,t[107]=ce,t[108]=L,t[109]=je,t[110]=oe,t[111]=J):J=t[111];let K;return t[112]!==xe||t[113]!==J?(K=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[xe,J]}),t[112]=xe,t[113]=J,t[114]=K):K=t[114],K};function zb(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function Vb(t){return t.currentSessionId}function Ub(t){return t.newSessionDraft}function Kb(t){return t.worktreeMetadata}function Hb(t){return t.availableWorktrees}function Gb(t){return!t.startsWith("remotes/")}function qb(t){return t.startsWith("remotes/")}function Qb(t){return t.replace(/^remotes\//,"")}function Yb(t){return t.name}const Ki=2e4,Xb=(t,e)=>{if(!t)return 1;let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(n+=1,n>e))return n;return n},no=(t,e)=>Vf(Uf.getState().dictionary,t,e),Jb=t=>{const n=(t instanceof Error?t.message:String(t??"")).toLowerCase();return n.includes("file not found")||n.includes("not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")?"missing":"unreadable"},Zb=async(t,e,n)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});n?.directory&&r.set("directory",n.directory);const i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},Ou=async(t,e,n)=>{if(Lf(e)||$f(e)||Wf(e))return{ok:!0};try{const r=await Zb(t,e,n);return zf(r)?{ok:!1,reason:"binary"}:Xb(r,Ki)>Ki?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:Jb(r)}}},Bu=t=>{if(t==="too-large"){const e=Ki.toLocaleString(pa());return no("contextFileOpen.failure.tooLarge",{count:e})}return no(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Vl=8;let Hi=null;const Fu=t=>{Hi={x:t.clientX,y:t.clientY}},_u=t=>{const e=Hi;return Hi=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=Vl&&Math.abs(t.clientY-e.y)<=Vl},Ul=3,mr=t=>Array.from(t.types).includes("Files"),ey=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},Kl=t=>{const e=t.name;return!e||e==="."||e===".."||e.includes("/")||e.includes("\\")?null:e},ty=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),as=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Oa=(t,e)=>{const n=as(e),r=as(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},sy=(t,e)=>{const n=Oa(t,e);if(n!==".")return n;const r=as(t);return r.split("/").filter(Boolean).pop()??r},ny=t=>{const e=as(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},ry=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),oy=new Set(["node_modules"]),iy=t=>oy.has(t),ay=t=>{const e=as(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},ly=8,hn=new Map,Ba=t=>JSON.stringify([ps(),t]),cy=t=>{const e=Ba(t),n=hn.get(e);return n?(n.touchedAt=Date.now(),hn.delete(e),hn.set(e,n),n):null},di=t=>{const e=Ba(t),n=hn.get(e);if(n)return n.touchedAt=Date.now(),n;if(hn.size>=ly){const i=hn.keys().next().value;i!==void 0&&hn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return hn.set(e,r),r},dy=t=>{hn.delete(Ba(t))},Lu=(t,e)=>s.jsx(wa,{filePath:t,extension:e}),uy=t=>{const e=tt.c(3),{status:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const i=r[n];let o;return e[1]!==i?(o=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},my=t=>{const e=tt.c(87),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:u,isDropTarget:d,canUpload:h,permissions:f,downloadFile:p,onSelect:g,onToggle:w,onRevealPath:v,onOpenDialog:x,onSetDropTarget:m,onDropFiles:b}=t,{t:y}=At(),S=n.type==="directory";let N;e[0]!==S||e[1]!==n.path?(N=S?n.path:ny(n.path),e[0]=S,e[1]=n.path,e[2]=N):N=e[2];const C=N,{canRename:j,canCreateFile:A,canCreateFolder:D,canDelete:I,canReveal:M}=f,z=!S&&!!p,E=M&&!l,H=j||A||D||I||z||E,[B,O]=c.useState(!1),[T,k]=c.useState(!1);let P;e[3]!==H?(P=$=>{H&&($?.preventDefault(),k(!0))},e[3]=H,e[4]=P):P=e[4];const L=P;let Q;e[5]!==S||e[6]!==n||e[7]!==g||e[8]!==w?(Q=()=>{S?w(n.path):g(n)},e[5]=S,e[6]=n,e[7]=g,e[8]=w,e[9]=Q):Q=e[9];const q=Q;let te;e[10]===Symbol.for("react.memo_cache_sentinel")?(te=$=>{$.stopPropagation(),k(!1),O(!0)},e[10]=te):te=e[10];const ae=te;let X;e[11]!==A||e[12]!==D||e[13]!==I||e[14]!==j||e[15]!==E||e[16]!==p||e[17]!==l||e[18]!==S||e[19]!==n||e[20]!==x||e[21]!==v||e[22]!==y?(X=$=>{const{Item:le,Separator:V}=$;return s.jsxs(s.Fragment,{children:[j&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),x("rename",n)},children:[s.jsx(R,{name:"edit",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.rename")]}),s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),pn(n.path).then(_e=>{if(_e.ok){Me.success(y("sidebarFilesTree.toast.pathCopied"));return}Me.error(y("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(R,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.copyPath")]}),!S&&p&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),p(n.path).catch(_e=>{console.error("Download failed:",_e),Me.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(R,{name:"download",className:"mr-2 h-4 w-4"})," ",y(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),E&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),v(n.path)},children:[s.jsx(R,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",y(pd())]}),S&&(A||D)&&s.jsxs(s.Fragment,{children:[s.jsx(V,{}),A&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),x("createFile",n)},children:[s.jsx(R,{name:"file-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFile")]}),D&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),x("createFolder",n)},children:[s.jsx(R,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFolder")]})]}),I&&s.jsxs(s.Fragment,{children:[s.jsx(V,{}),s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),x("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.delete")]})]})]})},e[11]=A,e[12]=D,e[13]=I,e[14]=j,e[15]=E,e[16]=p,e[17]=l,e[18]=S,e[19]=n,e[20]=x,e[21]=v,e[22]=y,e[23]=X):X=e[23];const Z=X;let se;e[24]!==n.path||e[25]!==r?(se=$=>{Fu($);const le=Oa(r,n.path);!le||le==="."||($.dataTransfer.setData("application/x-openchamber-file-path",le),$.dataTransfer.effectAllowed="copy")},e[24]=n.path,e[25]=r,e[26]=se):se=e[26];const me=se;let _;e[27]!==q?(_=$=>{_u($)&&q()},e[27]=q,e[28]=_):_=e[28];const ne=_;let ye;e[29]!==h||e[30]!==m||e[31]!==C?(ye=$=>{!h||!C||!mr($.dataTransfer)||($.preventDefault(),$.stopPropagation(),$.dataTransfer.dropEffect="copy",m(C))},e[29]=h,e[30]=m,e[31]=C,e[32]=ye):ye=e[32];const ce=ye;let F;e[33]!==h||e[34]!==m||e[35]!==C?(F=$=>{!h||!C||!mr($.dataTransfer)||$.relatedTarget instanceof Node&&$.currentTarget.contains($.relatedTarget)||($.stopPropagation(),m(null))},e[33]=h,e[34]=m,e[35]=C,e[36]=F):F=e[36];const re=F;let fe;e[37]!==h||e[38]!==b||e[39]!==C?(fe=$=>{!h||!C||!mr($.dataTransfer)||($.preventDefault(),$.stopPropagation(),b(C,$.dataTransfer))},e[37]=h,e[38]=b,e[39]=C,e[40]=fe):fe=e[40];const de=fe;let ge;e[41]!==L||e[42]!==re||e[43]!==ce||e[44]!==de?(ge=s.jsx("div",{className:"group relative flex items-center",onContextMenu:L,onDragEnter:ce,onDragOver:ce,onDragLeave:re,onDrop:de}),e[41]=L,e[42]=re,e[43]=ce,e[44]=de,e[45]=ge):ge=e[45];const Te=d?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let be;e[46]!==Te?(be=De("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",Te),e[46]=Te,e[47]=be):be=e[47];let Ee;e[48]!==S||e[49]!==i||e[50]!==n.extension||e[51]!==n.path?(Ee=S?i?s.jsx(R,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(R,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):Lu(n.path,n.extension),e[48]=S,e[49]=i,e[50]=n.extension,e[51]=n.path,e[52]=Ee):Ee=e[52];let we;e[53]!==n.name||e[54]!==n.path?(we=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[53]=n.name,e[54]=n.path,e[55]=we):we=e[55];let Y;e[56]!==S||e[57]!==a?(Y=!S&&a&&s.jsx(uy,{status:a}),e[56]=S,e[57]=a,e[58]=Y):Y=e[58];let ve;e[59]!==u||e[60]!==S?(ve=S&&u&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[u.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",u.modified]}),u.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",u.added]})]}),e[59]=u,e[60]=S,e[61]=ve):ve=e[61];let xe;e[62]!==L||e[63]!==ne||e[64]!==me||e[65]!==q||e[66]!==be||e[67]!==Ee||e[68]!==we||e[69]!==Y||e[70]!==ve?(xe=s.jsxs("button",{type:"button",onClick:q,onContextMenu:L,draggable:!0,onDragStart:me,onDragEnd:ne,className:be,children:[Ee,we,Y,ve]}),e[62]=L,e[63]=ne,e[64]=me,e[65]=q,e[66]=be,e[67]=Ee,e[68]=we,e[69]=Y,e[70]=ve,e[71]=xe):xe=e[71];let je;e[72]!==B||e[73]!==H||e[74]!==Z||e[75]!==y?(je=H&&s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:s.jsxs(Xs,{open:B,onOpenChange:O,children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Qs,{asChild:!0,children:s.jsx(pt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ae,title:y("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":y("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(R,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:y("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Ys,{align:"end",side:"bottom",onCloseAutoFocus:()=>O(!1),children:Z({Item:Ut,Separator:Os})})]})}),e[72]=B,e[73]=H,e[74]=Z,e[75]=y,e[76]=je):je=e[76];let oe;e[77]!==ge||e[78]!==xe||e[79]!==je?(oe=s.jsxs(tu,{render:ge,children:[xe,je]}),e[77]=ge,e[78]=xe,e[79]=je,e[80]=oe):oe=e[80];let J;e[81]!==Z?(J=s.jsx(eu,{className:"min-w-[180px]",children:Z({Item:Un,Separator:Mi})}),e[81]=Z,e[82]=J):J=e[82];let K;return e[83]!==T||e[84]!==oe||e[85]!==J?(K=s.jsxs(su,{open:T,onOpenChange:k,children:[oe,J]}),e[83]=T,e[84]=oe,e[85]=J,e[86]=K):K=e[86],K},fy=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles,hy=c.memo(my,fy),py=()=>{const{t}=At(),{files:e,runtime:n}=wn(),r=Gm(n.platform),i=br()??"",o=as(i.trim()),l=qm(),a=Qm(),u=ad(ue=>ue.searchFiles),d=Pe(ue=>ue.openContextFile),h=ba(i),[f,p]=c.useState(""),g=Sa(f,200),w=c.useRef(null),[v,x]=c.useState([]),[m,b]=c.useState(!1),[y,S]=c.useState(null),[N,C]=c.useState(!1),[j,A]=c.useState(null),D=c.useRef(!1),I=c.useRef(o);I.current=o;const[M,z]=c.useState({}),[E,H]=c.useState({}),B=c.useRef(new Set),O=c.useRef(new Set),T=c.useRef(null);c.useEffect(()=>{if(S(null),A(null),!o){z({}),H({}),B.current=new Set;return}const ue=cy(o);ue?(z({...ue.childrenByDir}),H({...ue.loadErrorsByDir}),B.current=new Set(ue.loadedDirs)):(z({}),H({}),B.current=new Set)},[o]),c.useEffect(()=>{if(!o)return;const ue=di(o);ue.childrenByDir=M},[o,M]),c.useEffect(()=>{if(!o)return;const ue=di(o);ue.loadErrorsByDir=E},[o,E]),c.useEffect(()=>{if(!o)return;const ue=di(o);ue.loadedDirs=new Set(B.current)},[o,M,E]),c.useEffect(()=>()=>{if(!o)return;const ue=hn.get(o);ue&&ue.loadedDirs.size===0&&Object.keys(ue.childrenByDir).length===0&&dy(o)},[o]);const k=c.useMemo(()=>[],[]),P=c.useMemo(()=>[],[]),L=fn(ue=>o?ue.byRoot[o]?.expandedPaths??k:k),Q=fn(ue=>o?ue.byRoot[o]?.selectedPath??null:null),q=fn(ue=>ue.setSelectedPath),te=fn(ue=>ue.addOpenPath),ae=fn(ue=>ue.removeOpenPathsByPrefix),X=fn(ue=>ue.toggleExpandedPath),Z=fn(ue=>ue.collapseAllExpandedPaths),se=Pe(ue=>o?ue.contextPanelByDirectory[o]?.tabs??P:P),me=c.useMemo(()=>new Set(se.map(ue=>ue.mode==="file"?ue.targetPath:null).filter(ue=>typeof ue=="string"&&ue.length>0).map(ue=>as(ue))),[se]),[_,ne]=c.useState(null),[ye,ce]=c.useState(null),[F,re]=c.useState(""),[fe,de]=c.useState(!1),ge=!!e.writeFile,Te=!!e.createDirectory,be=!!e.rename,Ee=!!e.delete,we=!!e.revealPath,Y=!!e.uploadFile,ve=c.useMemo(()=>({canRename:be,canCreateFile:ge,canCreateFolder:Te,canDelete:Ee,canReveal:we}),[be,ge,Te,Ee,we]),xe=c.useCallback(ue=>{e.revealPath&&e.revealPath(ue).catch(()=>{Me.error(t("sidebarFilesTree.toast.revealFailed"))})},[e,t]),je=c.useCallback((ue,G)=>{ne(ue),ce(G),re(ue==="rename"&&G.name||""),de(!1)},[]),oe=c.useCallback((ue,G)=>{const Le=G.filter(Oe=>Oe&&typeof Oe.name=="string"&&Oe.name.length>0).filter(Oe=>l||!Oe.name.startsWith(".")).filter(Oe=>a||!iy(Oe.name)).map(Oe=>{const qe=Oe.name,Ue=as(Oe.path||""),st=Ue?ry(Ue)?Ue:as(`${ue}/${Ue}`):as(`${ue}/${qe}`),wt=Oe.isDirectory?"directory":"file",Nt=wt==="file"&&qe.includes(".")?qe.split(".").pop()?.toLowerCase():void 0;return{name:qe,path:st,type:wt,extension:Nt}});return ty(Le)},[a,l]),J=c.useCallback(async(ue,G)=>{const Le=as(ue.trim());if(!Le||B.current.has(Le)||O.current.has(Le))return;O.current=new Set(O.current),O.current.add(Le);const Oe=e.listDirectory?e.listDirectory(Le).then(qe=>qe.entries.map(Ue=>({name:Ue.name,path:Ue.path,isDirectory:Ue.isDirectory}))):qs.listLocalDirectory(Le).then(qe=>qe.map(Ue=>({name:Ue.name,path:Ue.path,isDirectory:Ue.isDirectory})));try{const qe=await Oe;if(G?.())return;const Ue=oe(Le,qe);B.current=new Set(B.current),B.current.add(Le),H(st=>{if(!st[Le])return st;const wt={...st};return delete wt[Le],wt}),z(st=>({...st,[Le]:Ue}))}catch(qe){if(G?.())return;const Ue=qe instanceof Error?qe.message:String(qe??"");console.error("Failed to load sidebar directory:",qe),H(st=>({...st,[Le]:Ue}))}finally{O.current=new Set(O.current),O.current.delete(Le)}},[e,oe]),K=c.useCallback(async()=>{if(!o)return;T.current?.abort();const ue=new AbortController;T.current=ue;try{const Le=(fn.getState().byRoot[o]?.expandedPaths??[]).map(Ue=>as(Ue)).filter(Ue=>!!Ue&&Ue!==o&&Ue.startsWith(`${o}/`)),Oe=[o,...Le];B.current=new Set(B.current);for(const Ue of Oe)B.current.delete(Ue);H(Ue=>{if(Object.keys(Ue).length===0)return Ue;const st={...Ue};let wt=!1;for(const Nt of Oe)Nt in st&&(delete st[Nt],wt=!0);return wt?st:Ue});const qe=()=>ue.signal.aborted;await J(o,qe);for(let Ue=0;Ue<Le.length&&!ue.signal.aborted;Ue+=3){const st=Le.slice(Ue,Ue+3);await Promise.all(st.map(wt=>J(wt,qe)))}}catch(G){if(ue.signal.aborted)return;console.error("Failed to refresh sidebar tree:",G)}finally{T.current===ue&&(T.current=null)}},[J,o]),$=c.useCallback(async ue=>{if(!ue){await K();return}const G=as(ue);B.current=new Set(B.current),B.current.delete(G),O.current=new Set(O.current),O.current.delete(G),await J(G)},[J,K]);c.useEffect(()=>{o&&(T.current?.abort(),B.current=new Set,O.current=new Set,H({}),z(ue=>Object.keys(ue).length===0?ue:{}),J(o))},[J,o,l,a]),c.useEffect(()=>{if(!o||L.length===0)return;const ue=L.map(Oe=>as(Oe)).filter(Oe=>!!Oe&&Oe!==o&&Oe.startsWith(`${o}/`)&&!B.current.has(Oe)&&!O.current.has(Oe)).sort((Oe,qe)=>Oe.split("/").length-qe.split("/").length);if(ue.length===0)return;let G=!1;const Le=()=>G;return(async()=>{for(let Oe=0;Oe<ue.length&&!G;Oe+=3){const qe=ue.slice(Oe,Oe+3);await Promise.all(qe.map(Ue=>J(Ue,Le)))}})(),()=>{G=!0}},[L,J,o]),c.useEffect(()=>{if(!i){x([]),b(!1);return}const ue=g.trim();if(!ue){x([]),b(!1);return}let G=!1;return b(!0),u(i,ue,150,{includeHidden:l,respectGitignore:!a,type:"file"}).then(Le=>{if(G)return;const qe=Le.filter(Ue=>a||!ay(Ue.path)).map(Ue=>({name:Ue.name,path:as(Ue.path),type:"file",extension:Ue.extension,relativePath:Ue.relativePath}));x(qe)}).catch(()=>{G||x([])}).finally(()=>{G||b(!1)}),()=>{G=!0}},[i,g,u,l,a]);const le=c.useMemo(()=>{const ue=new Map;if(!h?.files)return ue;for(const G of h.files)G.index==="A"||G.working_dir==="?"?ue.set(G.path,"git-added"):G.index==="D"?ue.set(G.path,"git-deleted"):(G.index==="M"||G.working_dir==="M")&&ue.set(G.path,"git-modified");return ue},[h]),V=c.useMemo(()=>{const ue=new Map;if(!h?.files||!o)return ue;for(const G of h.files){const Le=G.index==="M"||G.working_dir==="M",Oe=G.index==="A"||G.working_dir==="?";if(!Le&&!Oe)continue;const qe=G.path.split("/");if(qe.length<=1)continue;let Ue=o;for(let st=0;st<qe.length-1;st++){Ue=`${Ue}/${qe[st]}`;let wt=ue.get(Ue);wt||(wt={modified:0,added:0},ue.set(Ue,wt)),Le&&wt.modified++,Oe&&wt.added++}}return ue},[h,o]),Ce=c.useCallback(ue=>{if(me.has(ue))return"open";if(le.size===0)return null;const G=ue.startsWith(o+"/")?ue.slice(o.length+1):ue;return le.get(G)??null},[me,le,o]),_e=c.useCallback(ue=>{if(V.size===0)return null;const G=V.get(ue);return G&&G.modified+G.added>0?G:null},[V]),ke=c.useCallback(async ue=>{if(!o)return;const G=await Ou(e,ue.path,{directory:o});if(!G.ok){Me.error(Bu(G.reason));return}q(o,ue.path),te(o,ue.path),d(o,ue.path)},[te,e,d,o,q]),Ne=c.useCallback(async ue=>{const G=as(ue);o&&(X(o,G),B.current.has(G)||await J(G))},[J,o,X]),Qe=c.useCallback(async(ue,G,Le=!1)=>{const Oe=e.uploadFile;if(!Oe||G.length===0||D.current||!o)return;const qe=o,Ue=ps();D.current=!0,C(!0),S(ue),Le&&A(null);const st=[];for(let ze=0;ze<G.length;ze+=Ul){const He=G.slice(ze,ze+Ul),ot=await Promise.all(He.map(async at=>{const et=Kl(at);if(!et||ps()!==Ue)return"failed";try{return(await Oe(as(`${ue}/${et}`),at,{directory:qe,overwrite:Le})).success?"uploaded":"failed"}catch(Xe){return!Le&&Ym(Xe)&&Xe.reason==="already-exists"?"conflict":"failed"}}));st.push(...ot)}const wt=st.filter(ze=>ze==="uploaded").length,Nt=st.filter(ze=>ze==="failed").length,ie=G.filter((ze,He)=>st[He]==="conflict"),pe=G.flatMap((ze,He)=>{const ot=Kl(ze);return st[He]==="uploaded"&&ot?[as(`${ue}/${ot}`)]:[]}),Ve=I.current===qe&&ps()===Ue;try{pe.length>0&&Cg({runtimeKey:Ue,paths:pe}),wt>0&&Ve&&await $(ue),wt>0&&Me.success(t(ie.length>0?"sidebarFilesTree.toast.uploadedWithoutConflicts":"sidebarFilesTree.toast.uploaded")),Nt>0&&Me.error(t("sidebarFilesTree.toast.uploadFailed")),ie.length>0&&Ve&&A({directory:ue,files:ie,runtimeKey:Ue,workspaceRoot:qe})}finally{D.current=!1,C(!1),S(null)}},[e.uploadFile,$,o,t]),We=c.useCallback((ue,G)=>{const Le=ey(G);Le.length!==0&&Qe(ue,Le)},[Qe]),U=c.useCallback(ue=>{!Y||D.current||!o||!mr(ue.dataTransfer)||(ue.preventDefault(),ue.dataTransfer.dropEffect="copy",S(o))},[Y,o]),he=c.useCallback(ue=>{mr(ue.dataTransfer)&&(ue.relatedTarget instanceof Node&&ue.currentTarget.contains(ue.relatedTarget)||S(null))},[]),Re=c.useCallback(ue=>{!Y||D.current||!o||!mr(ue.dataTransfer)||(ue.preventDefault(),We(o,ue.dataTransfer))},[Y,We,o]),Ie=c.useCallback(async ue=>{if(ue?.preventDefault(),!ye||!_)return;de(!0);const G=()=>de(!1),Le=()=>ne(null);if(_==="createFile"){if(!F.trim()){Me.error(t("sidebarFilesTree.toast.filenameRequired")),G();return}if(!e.writeFile){Me.error(t("sidebarFilesTree.toast.writeNotSupported")),G();return}const Oe=ye.path,qe=Oe?`${Oe}/`:"",Ue=as(`${qe}${F.trim()}`);await e.writeFile(Ue,"").then(async st=>{st.success&&(Me.success(t("sidebarFilesTree.toast.fileCreated")),await $(Oe)),Le()}).catch(()=>Me.error(t("sidebarFilesTree.toast.operationFailed"))).finally(G);return}if(_==="createFolder"){if(!F.trim()){Me.error(t("sidebarFilesTree.toast.folderNameRequired")),G();return}const Oe=ye.path,qe=Oe?`${Oe}/`:"",Ue=as(`${qe}${F.trim()}`);await e.createDirectory(Ue).then(async st=>{st.success&&(Me.success(t("sidebarFilesTree.toast.folderCreated")),await $(Oe)),Le()}).catch(()=>Me.error(t("sidebarFilesTree.toast.operationFailed"))).finally(G);return}if(_==="rename"){if(!F.trim()){Me.error(t("sidebarFilesTree.toast.nameRequired")),G();return}if(!e.rename){Me.error(t("sidebarFilesTree.toast.renameNotSupported")),G();return}const Oe=ye.path,qe=Oe.split("/").slice(0,-1).join("/"),Ue=qe?`${qe}/`:"",st=as(`${Ue}${F.trim()}`);await e.rename(Oe,st).then(async wt=>{wt.success&&(Me.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await $(qe),o&&ae(o,Oe),(Q===Oe||Q&&Q.startsWith(`${Oe}/`))&&q(o,null)),Le()}).catch(()=>Me.error(t("sidebarFilesTree.toast.operationFailed"))).finally(G);return}if(_==="delete"){if(!e.delete){Me.error(t("sidebarFilesTree.toast.deleteNotSupported")),G();return}const Oe=ye.path,qe=Oe.split("/").slice(0,-1).join("/");await e.delete(Oe).then(async Ue=>{Ue.success&&(Me.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await $(qe),o&&ae(o,Oe),(Q===Oe||Q&&Q.startsWith(Oe+"/"))&&q(o,null)),Le()}).catch(()=>Me.error(t("sidebarFilesTree.toast.operationFailed"))).finally(G);return}G()},[_,ye,F,e,$,ae,o,Q,q,t]);function rt(ue,G){const Le=M[ue]??[];return Le.map((Oe,qe)=>{const Ue=Oe.type==="directory",st=Ue&&L.includes(Oe.path),wt=Q===Oe.path,Nt=qe===Le.length-1;return s.jsxs("li",{className:"relative",children:[G>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Nt&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(hy,{node:Oe,root:o,isExpanded:st,isActive:wt,isBrowserClient:r,status:Ue?void 0:Ce(Oe.path),badge:Ue?_e(Oe.path):void 0,isDropTarget:Ue&&y===Oe.path,canUpload:Y&&!N,permissions:ve,downloadFile:e.downloadFile,onSelect:ke,onToggle:Ne,onRevealPath:xe,onOpenDialog:je,onSetDropTarget:S,onDropFiles:We}),Ue&&st&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[E[Oe.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:E[Oe.path],children:E[Oe.path]}),s.jsxs(pt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{$(Oe.path)},children:[s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):null,rt(Oe.path,G+1)]})]},Oe.path)})}const Ge=!!(o&&M[o]),ut=o?E[o]:null,ct=y?sy(o,y):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[ge&&s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(pt,{variant:"ghost",size:"sm",onClick:()=>je("createFile",{path:i,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.newFileTitle"),"aria-label":t("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(R,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFileTitle")})]}),Te&&s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(pt,{variant:"ghost",size:"sm",onClick:()=>je("createFolder",{path:i,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.newFolderTitle"),"aria-label":t("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(R,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFolderTitle")})]}),s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(pt,{variant:"ghost",size:"sm",onClick:()=>{K()},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.refreshTitle"),"aria-label":t("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(R,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(pt,{variant:"ghost",size:"sm",onClick:()=>{o&&Z(o)},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":t("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(R,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(Cn,{ref:w,value:f,onChange:ue=>p(ue.target.value),placeholder:t("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),f.trim().length>0?s.jsx("button",{type:"button","aria-label":t("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{p(""),w.current?.focus()},children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(ln,{outerClassName:"h-full min-h-0",className:De("p-2",y===o&&"bg-interactive-selection/10"),onDragEnter:U,onDragOver:U,onDragLeave:he,onDrop:Re,children:s.jsx("ul",{className:"flex flex-col",children:m?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("sidebarFilesTree.state.searching")]}):v.length>0?v.map(ue=>{const G=Q===ue.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>ke(ue),draggable:!0,onDragStart:Le=>{Fu(Le);const Oe=ue.relativePath||Oa(o??"",ue.path);!Oe||Oe==="."||(Le.dataTransfer.setData("application/x-openchamber-file-path",Oe),Le.dataTransfer.effectAllowed="copy")},onDragEnd:Le=>{_u(Le)&&ke(ue)},className:De("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",G?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:ue.path,children:[Lu(ue.path,ue.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:ue.relativePath??ue.path})]})},ue.path)}):ut?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:ut}),s.jsxs(pt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{K()},children:[s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):Ge&&o?rt(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("sidebarFilesTree.state.loading")})})}),y?s.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(R,{name:N?"loader-4":"folder-received",className:De("size-4 flex-shrink-0",N&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:ct,children:t(N?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:ct})})]}):null]}),s.jsx(ws,{open:!!j,onOpenChange:ue=>!ue&&A(null),children:s.jsxs(Ss,{children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:t("sidebarFilesTree.dialog.uploadConflicts.title")}),s.jsx(Ts,{children:t("sidebarFilesTree.dialog.uploadConflicts.description",{path:j?.directory??""})})]}),s.jsx(ln,{outerClassName:"max-h-52",className:"flex flex-col gap-1 pr-2",children:j?.files.map((ue,G)=>s.jsx("div",{className:"truncate rounded-md bg-muted px-2 py-1 typography-meta",title:ue.name,children:ue.name},`${ue.name}-${ue.size}-${G}`))}),s.jsxs(bn,{children:[s.jsx(pt,{variant:"outline",onClick:()=>A(null),disabled:N,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(pt,{onClick:()=>{if(j){if(j.runtimeKey!==ps()||j.workspaceRoot!==o){A(null);return}Qe(j.directory,j.files,!0)}},disabled:N,children:t("sidebarFilesTree.dialog.uploadConflicts.replace")})]})]})}),s.jsx(ws,{open:!!_,onOpenChange:ue=>!ue&&ne(null),children:s.jsxs(Ss,{children:[s.jsxs(Ws,{children:[s.jsxs(Is,{children:[_==="createFile"&&t("sidebarFilesTree.dialog.createFile.title"),_==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.title"),_==="rename"&&t("sidebarFilesTree.dialog.rename.title"),_==="delete"&&t("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Ts,{children:[_==="createFile"&&t("sidebarFilesTree.dialog.createFile.description",{path:ye?.path??t("sidebarFilesTree.dialog.rootFallback")}),_==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.description",{path:ye?.path??t("sidebarFilesTree.dialog.rootFallback")}),_==="rename"&&t("sidebarFilesTree.dialog.rename.description",{name:ye?.name??""}),_==="delete"&&t("sidebarFilesTree.dialog.delete.description",{name:ye?.name??""})]})]}),_!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Cn,{value:F,onChange:ue=>re(ue.target.value),placeholder:t(_==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:ue=>{ue.key==="Enter"&&Ie()},autoFocus:!0})}),s.jsxs(bn,{children:[s.jsx(pt,{variant:"outline",onClick:()=>ne(null),disabled:fe,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(pt,{variant:_==="delete"?"destructive":"default",onClick:()=>{Ie()},disabled:fe||_!=="delete"&&!F.trim(),children:fe?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t(_==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})},Hl=60,gy=t=>{try{return new URL(t).origin}catch{return""}},ui=new Set,$u=er()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=gy(n);!i||!r||e().byOrigin[i]||ui.has(i)||(ui.add(i),ur("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const u={...a.byOrigin,[i]:l},d=Object.keys(u);if(d.length<=Hl)return{byOrigin:u};for(const h of d.slice(0,d.length-Hl))delete u[h];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{ui.delete(i)}))}})),Fa=t=>t,Gi=t=>{const e=Fa(t).type;return typeof e=="string"?e:""},xy=t=>{const e=Fa(t).tool;return typeof e=="string"?e:""},by=t=>{const e=Fa(t).text;return typeof e=="string"?e:""},yy=t=>{const e=Gi(t);return e==="tool"?xy(t).trim().toLowerCase()||"tool":e||"unknown"},wy=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=yy(n);e.includes(r)||e.push(r)}return e.join(" + ")},Sy=t=>t.replace(/\s+/g," ").trim(),vy=t=>{for(const n of t)if(Gi(n)==="text"){const r=Sy(by(n));if(r.length===0)continue;return r}const e=t.filter(n=>Gi(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},jy=(t,e,n)=>`${n(t)} / ${n(e)}`,ky=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Cy=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=ky(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},qi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},xo={user:0,assistant:0,tool:0,other:0},En=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,mi=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(h=>h.tokens!==void 0)?.tokens;if(typeof n=="number")return{...qi,total:En(n)};if(!n||typeof n!="object")return qi;const r=n,i=En(r.input),o=En(r.output),l=En(r.reasoning),a=En(r.cache?.read),u=En(r.cache?.write),d=En(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:u,total:d>0?d:i+o+l+a+u}},Ny=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Us=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Us(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Us(n),0):0,Ay=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...xo,assistant:Us(n.text)+Us(n.content)};const i=Ny(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Us(n.input)+Us(n.output)+Us(n.error)+Us(n.call?.input)+Us(n.call?.output)+Us(n.call?.error)+Us(n.raw)+Math.round(Us(n.metadata)*.25)+Math.round(Us(n.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},Gl=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Py=t=>{const e=Qr(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},Dy=(t,e)=>{if(t.length===0)return{...xo};const n=t.reduce((r,i)=>{const o=Py(i);let l={...xo};for(const a of i.parts)l=Gl(l,Ay(a,o));return Gl(r,l)},{...xo});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},Vn=t=>t.toLocaleString(pa()),Iy=(t,e)=>!t||!Number.isFinite(t)?"-":jd(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Ty=(t,e,n)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===n);return{providerName:r?.name||e||"-",modelName:i?.name||n||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},Ey=()=>{const t=tt.c(203),{t:e}=At(),n=Pe(Ry);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),u=c.useRef(null),d=Je(My),h=Je(Oy),f=Nd(h??void 0),p=Kf(d??"",h??void 0),g=Gt(By);let w;t[1]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),o(Fy),a(null)},t[1]=w):w=t[1];let v;t[2]!==h||t[3]!==d?(v=[h,d],t[2]=h,t[3]=d,t[4]=v):v=t[4],c.useEffect(w,v);let x,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},m=[],t[5]=x,t[6]=m):(x=t[5],m=t[6]),c.useEffect(x,m);let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=async(dt,Be)=>{(await pn(Be)).ok?(a(dt),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{a(St=>St===dt?null:St),u.current=null},2e3)):a(null)},t[7]=b):b=t[7];const y=b;let S;t[8]!==d||t[9]!==f?(S=d?f.find(dt=>dt.id===d)??null:null,t[8]=d,t[9]=f,t[10]=S):S=t[10];const N=S;let C,j,A,D,I,M;if(t[11]!==g||t[12]!==p){C=p.filter(_y);let dt;t[19]!==p?(dt=p.filter(Ly),t[19]=p,t[20]=dt):dt=t[20],M=dt;let Be=null;for(let St=C.length-1;St>=0;St=St-1,St){const vt=C[St];if(mi(vt).total>0){Be=vt;break}}D=Be?mi(Be):qi,j=Hf({input:D.input,cache:{read:D.cacheRead,write:D.cacheWrite}}),I=C.reduce($y,0);const Se=Be?.info??null;A=Ty(g,Se?.providerID||"",Se?.modelID||""),t[11]=g,t[12]=p,t[13]=C,t[14]=j,t[15]=A,t[16]=D,t[17]=I,t[18]=M}else C=t[13],j=t[14],A=t[15],D=t[16],I=t[17],M=t[18];const z=A,E=z.contextLimit,H=E&&E>0?Math.min(999,D.total/E*100):0;let B;if(t[21]!==p){const dt=[...p].reverse().find(Wy)?.info?.system||"";B=Dy(p,dt),t[21]=p,t[22]=B}else B=t[22];const O=B,T=O.user,k=O.assistant,P=O.tool,L=Math.max(0,D.input-T-k-P),Q=T+k+P+L,q=p[0]?.info?.time?.created,te=p.length>0?p[p.length-1]?.info?.time?.created:null;let ae;t[23]!==N?.title||t[24]!==e?(ae=N?.title||e("contextSidebar.session.untitled"),t[23]=N?.title,t[24]=e,t[25]=ae):ae=t[25];const X=N?.time?.created??q??null,Z=te??N?.time?.created??null;let se;t[26]!==k||t[27]!==L||t[28]!==P||t[29]!==T?(se={user:T,assistant:k,tool:P,other:L},t[26]=k,t[27]=L,t[28]=P,t[29]=T,t[30]=se):se=t[30];let me;t[31]!==C.length||t[32]!==Q||t[33]!==j||t[34]!==E||t[35]!==z||t[36]!==p.length||t[37]!==X||t[38]!==Z||t[39]!==se||t[40]!==ae||t[41]!==D||t[42]!==I||t[43]!==H||t[44]!==M.length?(me={sessionTitle:ae,messagesCount:p.length,userMessagesCount:M.length,assistantMessagesCount:C.length,createdAt:X,lastActivityAt:Z,providerModel:z,tokenBreakdown:D,usagePercent:H,cacheHitRate:j,totalAssistantCost:I,contextLimit:E,breakdown:se,breakdownTotal:Q},t[31]=C.length,t[32]=Q,t[33]=j,t[34]=E,t[35]=z,t[36]=p.length,t[37]=X,t[38]=Z,t[39]=se,t[40]=ae,t[41]=D,t[42]=I,t[43]=H,t[44]=M.length,t[45]=me):me=t[45];const _=me;if(!d){let dt;t[46]!==e?(dt=e("contextSidebar.empty.openSession"),t[46]=e,t[47]=dt):dt=t[47];let Be;return t[48]!==dt?(Be=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:dt}),t[48]=dt,t[49]=Be):Be=t[49],Be}let ne;t[50]!==e?(ne=e("contextSidebar.breakdown.user"),t[50]=e,t[51]=ne):ne=t[51];let ye;t[52]!==ne||t[53]!==_.breakdown.user?(ye={key:"user",label:ne,value:_.breakdown.user,color:"var(--status-success)"},t[52]=ne,t[53]=_.breakdown.user,t[54]=ye):ye=t[54];let ce;t[55]!==e?(ce=e("contextSidebar.breakdown.assistant"),t[55]=e,t[56]=ce):ce=t[56];let F;t[57]!==ce||t[58]!==_.breakdown.assistant?(F={key:"assistant",label:ce,value:_.breakdown.assistant,color:"var(--primary-base)"},t[57]=ce,t[58]=_.breakdown.assistant,t[59]=F):F=t[59];let re;t[60]!==e?(re=e("contextSidebar.breakdown.toolCalls"),t[60]=e,t[61]=re):re=t[61];let fe;t[62]!==re||t[63]!==_.breakdown.tool?(fe={key:"tool",label:re,value:_.breakdown.tool,color:"var(--status-warning)"},t[62]=re,t[63]=_.breakdown.tool,t[64]=fe):fe=t[64];let de;t[65]!==e?(de=e("contextSidebar.breakdown.other"),t[65]=e,t[66]=de):de=t[66];let ge;t[67]!==de||t[68]!==_.breakdown.other?(ge={key:"other",label:de,value:_.breakdown.other,color:"var(--surface-muted-foreground)"},t[67]=de,t[68]=_.breakdown.other,t[69]=ge):ge=t[69];let Te;t[70]!==ye||t[71]!==F||t[72]!==fe||t[73]!==ge?(Te=[ye,F,fe,ge],t[70]=ye,t[71]=F,t[72]=fe,t[73]=ge,t[74]=Te):Te=t[74];const be=Te;let Ee;t[75]!==_.sessionTitle?(Ee=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:_.sessionTitle}),t[75]=_.sessionTitle,t[76]=Ee):Ee=t[76];let we;t[77]!==_.providerModel.modelName||t[78]!==_.providerModel.providerName?(we=s.jsxs("span",{children:[_.providerModel.providerName," / ",_.providerModel.modelName]}),t[77]=_.providerModel.modelName,t[78]=_.providerModel.providerName,t[79]=we):we=t[79];let Y;t[80]!==n||t[81]!==_.createdAt?(Y=_.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Iy(_.createdAt,n)})]}),t[80]=n,t[81]=_.createdAt,t[82]=Y):Y=t[82];let ve;t[83]!==we||t[84]!==Y?(ve=s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[we,Y]}),t[83]=we,t[84]=Y,t[85]=ve):ve=t[85];let xe;t[86]!==Ee||t[87]!==ve?(xe=s.jsxs("div",{className:"mb-6",children:[Ee,ve]}),t[86]=Ee,t[87]=ve,t[88]=xe):xe=t[88];let je;t[89]!==e?(je=e("contextSidebar.section.context"),t[89]=e,t[90]=je):je=t[90];let oe;t[91]!==je?(oe=s.jsx("span",{className:"typography-micro text-muted-foreground",children:je}),t[91]=je,t[92]=oe):oe=t[92];let J;t[93]!==_.tokenBreakdown.total?(J=Vn(_.tokenBreakdown.total),t[93]=_.tokenBreakdown.total,t[94]=J):J=t[94];let K;t[95]!==_.contextLimit?(K=_.contextLimit?` / ${Vn(_.contextLimit)}`:"",t[95]=_.contextLimit,t[96]=K):K=t[96];let $;t[97]!==J||t[98]!==K?($=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[J,K]}),t[97]=J,t[98]=K,t[99]=$):$=t[99];let le;t[100]!==oe||t[101]!==$?(le=s.jsxs("div",{className:"flex items-baseline justify-between",children:[oe,$]}),t[100]=oe,t[101]=$,t[102]=le):le=t[102];let V;t[103]!==_.usagePercent?(V=_.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,_.usagePercent)}%`,backgroundColor:_.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[103]=_.usagePercent,t[104]=V):V=t[104];let Ce;t[105]!==V?(Ce=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:V}),t[105]=V,t[106]=Ce):Ce=t[106];let _e;t[107]!==e||t[108]!==_.usagePercent?(_e=e("contextSidebar.context.percentUsed",{percent:_.usagePercent.toFixed(1)}),t[107]=e,t[108]=_.usagePercent,t[109]=_e):_e=t[109];let ke;t[110]!==_e?(ke=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:_e}),t[110]=_e,t[111]=ke):ke=t[111];let Ne;t[112]!==le||t[113]!==Ce||t[114]!==ke?(Ne=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[le,Ce,ke]}),t[112]=le,t[113]=Ce,t[114]=ke,t[115]=Ne):Ne=t[115];let Qe;t[116]!==e?(Qe=e("contextSidebar.stats.messages"),t[116]=e,t[117]=Qe):Qe=t[117];let We;t[118]!==_.messagesCount?(We=Vn(_.messagesCount),t[118]=_.messagesCount,t[119]=We):We=t[119];let U;t[120]!==Qe||t[121]!==We?(U={label:Qe,value:We},t[120]=Qe,t[121]=We,t[122]=U):U=t[122];let he;t[123]!==e?(he=e("contextSidebar.stats.user"),t[123]=e,t[124]=he):he=t[124];let Re;t[125]!==_.userMessagesCount?(Re=Vn(_.userMessagesCount),t[125]=_.userMessagesCount,t[126]=Re):Re=t[126];let Ie;t[127]!==he||t[128]!==Re?(Ie={label:he,value:Re},t[127]=he,t[128]=Re,t[129]=Ie):Ie=t[129];let rt;t[130]!==e?(rt=e("contextSidebar.stats.assistant"),t[130]=e,t[131]=rt):rt=t[131];let Ge;t[132]!==_.assistantMessagesCount?(Ge=Vn(_.assistantMessagesCount),t[132]=_.assistantMessagesCount,t[133]=Ge):Ge=t[133];let ut;t[134]!==rt||t[135]!==Ge?(ut={label:rt,value:Ge},t[134]=rt,t[135]=Ge,t[136]=ut):ut=t[136];let ct;t[137]!==e?(ct=e("contextSidebar.stats.cost"),t[137]=e,t[138]=ct):ct=t[138];let ue;t[139]!==_.totalAssistantCost?(ue=zp(_.totalAssistantCost),t[139]=_.totalAssistantCost,t[140]=ue):ue=t[140];let G;t[141]!==ct||t[142]!==ue?(G={label:ct,value:ue},t[141]=ct,t[142]=ue,t[143]=G):G=t[143];let Le;t[144]!==U||t[145]!==Ie||t[146]!==ut||t[147]!==G?(Le=[U,Ie,ut,G],t[144]=U,t[145]=Ie,t[146]=ut,t[147]=G,t[148]=Le):Le=t[148];const Oe=Le;let qe;t[149]!==Oe?(qe=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Oe.map(zy)}),t[149]=Oe,t[150]=qe):qe=t[150];let Ue;t[151]!==e?(Ue=e("contextSidebar.section.lastAssistantMessage"),t[151]=e,t[152]=Ue):Ue=t[152];let st;t[153]!==Ue?(st=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:Ue}),t[153]=Ue,t[154]=st):st=t[154];let wt;t[155]!==e||t[156]!==_.cacheHitRate.hasInput||t[157]!==_.cacheHitRate.percent||t[158]!==_.tokenBreakdown.cacheRead||t[159]!==_.tokenBreakdown.cacheWrite||t[160]!==_.tokenBreakdown.input||t[161]!==_.tokenBreakdown.output||t[162]!==_.tokenBreakdown.reasoning?(wt=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:_.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:_.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:_.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:_.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:_.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:_.cacheHitRate.hasInput?_.cacheHitRate.percent:null,format:"percent"}].map(Vy)}),t[155]=e,t[156]=_.cacheHitRate.hasInput,t[157]=_.cacheHitRate.percent,t[158]=_.tokenBreakdown.cacheRead,t[159]=_.tokenBreakdown.cacheWrite,t[160]=_.tokenBreakdown.input,t[161]=_.tokenBreakdown.output,t[162]=_.tokenBreakdown.reasoning,t[163]=wt):wt=t[163];let Nt;t[164]!==st||t[165]!==wt?(Nt=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[st,wt]}),t[164]=st,t[165]=wt,t[166]=Nt):Nt=t[166];let ie;t[167]!==be||t[168]!==_.breakdownTotal?(ie=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:be.map(dt=>dt.value<=0||_.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${dt.value/_.breakdownTotal*100}%`,backgroundColor:dt.color}},dt.key))}),t[167]=be,t[168]=_.breakdownTotal,t[169]=ie):ie=t[169];let pe;t[170]!==be||t[171]!==_.breakdownTotal?(pe=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:be.map(dt=>{const Be=_.breakdownTotal>0?dt.value/_.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:dt.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[dt.label," ",s.jsxs("span",{className:"tabular-nums",children:[Be.toFixed(0),"%"]})]})]},dt.key)})}),t[170]=be,t[171]=_.breakdownTotal,t[172]=pe):pe=t[172];let Ve;t[173]!==ie||t[174]!==pe?(Ve=s.jsxs("div",{className:"mb-6",children:[ie,pe]}),t[173]=ie,t[174]=pe,t[175]=Ve):Ve=t[175];let ze;t[176]!==e?(ze=e("contextSidebar.section.rawMessages"),t[176]=e,t[177]=ze):ze=t[177];let He;t[178]!==ze?(He=s.jsx("div",{className:"typography-micro text-muted-foreground",children:ze}),t[178]=ze,t[179]=He):He=t[179];let ot;if(t[180]!==l||t[181]!==i||t[182]!==p||t[183]!==e||t[184]!==n){let dt;t[186]!==l||t[187]!==i||t[188]!==e||t[189]!==n?(dt=Be=>{const St=Qr(Be.info).role,vt=St==="assistant",Et=St==="user",Ze=i[Be.info.id]===!0,it=l===Be.info.id,gt=Be.info.time?.created??null,xt=wy(Be.parts),Rt=vt?mi({info:Be.info,parts:Be.parts}):null,kt=Et?vy(Be.parts):"",Tt=Cy(gt,n),Ot=xt||"—",Vt=Rt?jy(Rt.input,Rt.output,Vn):"",Yt=St||"unknown",Ht=xt?`${Yt}: ${xt}`:Yt,Lt=Ze?JSON.stringify({info:Be.info,parts:Be.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":Ze,onClick:()=>{o(zt=>({...zt,[Be.info.id]:zt[Be.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:vt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Et?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",kt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:vt?Ot:Ht}),vt&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Vt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Tt})]})}),Ze&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[s.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:zt=>{zt.stopPropagation(),y(Be.info.id,Lt)},"aria-label":e(it?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(it?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:it?s.jsx(R,{name:"check",className:"size-3.5"}):s.jsx(R,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Gf,{language:"json",code:Lt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Be.info.id)},t[186]=l,t[187]=i,t[188]=e,t[189]=n,t[190]=dt):dt=t[190],ot=[...p].reverse().map(dt),t[180]=l,t[181]=i,t[182]=p,t[183]=e,t[184]=n,t[185]=ot}else ot=t[185];let at;t[191]!==ot?(at=s.jsx("div",{className:"mt-2.5 space-y-1",children:ot}),t[191]=ot,t[192]=at):at=t[192];let et;t[193]!==He||t[194]!==at?(et=s.jsxs("div",{children:[He,at]}),t[193]=He,t[194]=at,t[195]=et):et=t[195];let Xe;return t[196]!==xe||t[197]!==Ne||t[198]!==qe||t[199]!==Nt||t[200]!==Ve||t[201]!==et?(Xe=s.jsx(ln,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[xe,Ne,qe,Nt,Ve,et]})}),t[196]=xe,t[197]=Ne,t[198]=qe,t[199]=Nt,t[200]=Ve,t[201]=et,t[202]=Xe):Xe=t[202],Xe};function Ry(t){return t.timeFormatPreference}function My(t){return t.currentSessionId}function Oy(t){return t.currentSessionDirectory}function By(t){return t.providers}function Fy(t){return Object.keys(t).length>0?{}:t}function _y(t){return Qr(t.info).role==="assistant"}function Ly(t){return Qr(t.info).isUser}function $y(t,e){const n=En(e.info.cost);return t+n}function Wy(t){return Qr(t.info).isUser&&typeof t.info.system=="string"}function zy(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function Vy(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:Vn(t.value):"—"})]},t.label)}const Wu=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),Uy=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Wu.has(n.toLowerCase())},an="about:blank",fr=t=>{const e=t.trim();if(!e)return an;const n=e.includes("://")?e:`${Uy(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?an:r.toString()}catch{return an}},yr=t=>{try{return Wu.has(new URL(t).hostname.toLowerCase())}catch{return!1}},_a=t=>{if(!t||t===an)return"";try{return new URL(t).host||t}catch{return t}},Ky=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),Hy=(t,e)=>Ky.has(t)&&yr(e),Gy=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.port=="number"&&Number.isFinite(e.port)&&typeof e.url=="string"&&e.url.length>0&&typeof e.command=="string"},qy=async t=>{try{const e=await ds("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const n=await e.json();if(!n||typeof n!="object")return{kind:"unavailable"};const r=n.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(Gy)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Qy=async t=>{try{const e=await ds("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},Yy=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},Xy=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=Yy(r);i!==null&&!n.has(i)&&n.set(i,r)}return e?e.map(r=>{const i=n.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...n.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},Qi="__openchamberBrowserAnnotationActive",Jy=`(() => {
|
|
46
|
-
try {
|
|
47
|
-
var host = document.querySelector('[data-openchamber-annotation]');
|
|
48
|
-
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
49
|
-
} catch (error) { /* page navigated away */ }
|
|
50
|
-
try {
|
|
51
|
-
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
52
|
-
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
53
|
-
} catch (error) { /* page navigated away */ }
|
|
54
|
-
try { delete window['${Qi}']; } catch (error) { /* non-configurable */ }
|
|
55
|
-
})();`,Zy=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
56
|
-
var CONFIG = ${n};
|
|
57
|
-
var THEME = CONFIG.theme;
|
|
58
|
-
var LABELS = CONFIG.labels;
|
|
59
|
-
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
60
|
-
var Z_OVERLAY = 2147483646;
|
|
61
|
-
var MAX_TEXT = 400;
|
|
62
|
-
var MIN_RECT = 3;
|
|
63
|
-
var EDITOR_GAP = 10;
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
67
|
-
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
68
|
-
} catch (error) { /* nothing to clean */ }
|
|
69
|
-
|
|
70
|
-
window['${Qi}'] = true;
|
|
71
|
-
|
|
72
|
-
var counter = 0;
|
|
73
|
-
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
74
|
-
|
|
75
|
-
var selected = null;
|
|
76
|
-
var regions = [];
|
|
77
|
-
var strokes = [];
|
|
78
|
-
var tool = 'select';
|
|
79
|
-
var settled = false;
|
|
80
|
-
|
|
81
|
-
// ---------------------------------------------------------------- geometry
|
|
82
|
-
|
|
83
|
-
var rectFrom = function (domRect) {
|
|
84
|
-
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
85
|
-
};
|
|
86
|
-
var normalizeRect = function (ax, ay, bx, by) {
|
|
87
|
-
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
88
|
-
};
|
|
89
|
-
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
90
|
-
|
|
91
|
-
// ------------------------------------------------------------- description
|
|
92
|
-
|
|
93
|
-
var isOverlayNode = function (element) {
|
|
94
|
-
var node = element;
|
|
95
|
-
while (node) {
|
|
96
|
-
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
97
|
-
node = node.parentNode || (node.host || null);
|
|
98
|
-
}
|
|
99
|
-
return false;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
var elementFromPoint = function (x, y) {
|
|
103
|
-
var found = document.elementFromPoint(x, y);
|
|
104
|
-
if (!found || isOverlayNode(found)) return null;
|
|
105
|
-
return found;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
var selectorPart = function (element) {
|
|
109
|
-
var part = element.tagName.toLowerCase();
|
|
110
|
-
if (element.id) return part + '#' + element.id;
|
|
111
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
112
|
-
if (className) {
|
|
113
|
-
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
114
|
-
if (first) part += '.' + first;
|
|
115
|
-
}
|
|
116
|
-
return part;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
var buildSelector = function (element) {
|
|
120
|
-
if (element.id) return '#' + element.id;
|
|
121
|
-
var parts = [];
|
|
122
|
-
var node = element;
|
|
123
|
-
var depth = 0;
|
|
124
|
-
while (node && node.nodeType === 1 && depth < 5) {
|
|
125
|
-
var part = selectorPart(node);
|
|
126
|
-
var parent = node.parentElement;
|
|
127
|
-
if (parent) {
|
|
128
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
129
|
-
return child.tagName === node.tagName;
|
|
130
|
-
});
|
|
131
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
132
|
-
}
|
|
133
|
-
parts.unshift(part);
|
|
134
|
-
if (node.id) break;
|
|
135
|
-
node = parent;
|
|
136
|
-
depth += 1;
|
|
137
|
-
}
|
|
138
|
-
return parts.join(' > ');
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
142
|
-
var STYLE_PROPS = [
|
|
143
|
-
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
144
|
-
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
145
|
-
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
146
|
-
];
|
|
147
|
-
|
|
148
|
-
var describe = function (element) {
|
|
149
|
-
var computed = window.getComputedStyle(element);
|
|
150
|
-
var attributes = {};
|
|
151
|
-
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
152
|
-
var name = INTERESTING_ATTRS[i];
|
|
153
|
-
var value = element.getAttribute(name);
|
|
154
|
-
if (value) attributes[name] = String(value).slice(0, 200);
|
|
155
|
-
}
|
|
156
|
-
var computedStyle = {};
|
|
157
|
-
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
158
|
-
var prop = STYLE_PROPS[j];
|
|
159
|
-
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
160
|
-
}
|
|
161
|
-
var ancestry = [];
|
|
162
|
-
var node = element.parentElement;
|
|
163
|
-
var depth = 0;
|
|
164
|
-
while (node && node.nodeType === 1 && depth < 4) {
|
|
165
|
-
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
166
|
-
if (node.id) entry.id = node.id;
|
|
167
|
-
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
168
|
-
if (cls) entry.className = cls.slice(0, 200);
|
|
169
|
-
ancestry.unshift(entry);
|
|
170
|
-
node = node.parentElement;
|
|
171
|
-
depth += 1;
|
|
172
|
-
}
|
|
173
|
-
var box = element.getBoundingClientRect();
|
|
174
|
-
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
175
|
-
return {
|
|
176
|
-
tag: element.tagName.toLowerCase(),
|
|
177
|
-
text: text.slice(0, MAX_TEXT),
|
|
178
|
-
selector: buildSelector(element),
|
|
179
|
-
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
180
|
-
bounds: rectFrom(box),
|
|
181
|
-
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
182
|
-
attributes: attributes,
|
|
183
|
-
computedStyle: computedStyle,
|
|
184
|
-
ancestry: ancestry
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// ------------------------------------------------------------------ chrome
|
|
189
|
-
|
|
190
|
-
var host = document.createElement('div');
|
|
191
|
-
host.setAttribute(OVERLAY_ATTR, '');
|
|
192
|
-
host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
|
|
193
|
-
var shadow = host.attachShadow({ mode: 'closed' });
|
|
194
|
-
|
|
195
|
-
var style = document.createElement('style');
|
|
196
|
-
style.textContent = [
|
|
197
|
-
':host{all:initial}',
|
|
198
|
-
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
199
|
-
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
200
|
-
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
201
|
-
'.label{position:fixed;left:0;top:0;display:none;pointer-events:none;padding:1px 6px;border-radius:4px;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';font-size:11px;line-height:17px;white-space:nowrap;font-weight:600}',
|
|
202
|
-
'.tools{position:fixed;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:2px;padding:4px;border-radius:999px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 6px 20px rgba(0,0,0,.24);pointer-events:auto}',
|
|
203
|
-
'.tools button{appearance:none;border:none;background:transparent;color:' + THEME.mutedText + ';border-radius:999px;padding:5px 14px;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap}',
|
|
204
|
-
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
205
|
-
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
206
|
-
'.editor{position:fixed;left:0;top:0;display:none;align-items:center;gap:8px;width:min(420px,calc(100vw - 24px));padding:6px;padding-left:16px;border-radius:22px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 8px 28px rgba(0,0,0,.3);pointer-events:auto}',
|
|
207
|
-
'.editor textarea{flex:1;min-width:0;resize:none;border:none;background:transparent;color:' + THEME.text + ';font-size:13px;line-height:20px;outline:none;padding:6px 0;min-height:32px;max-height:104px;display:block}',
|
|
208
|
-
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
209
|
-
'.editor button{appearance:none;border:none;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';border-radius:999px;width:32px;height:32px;padding:0;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer}',
|
|
210
|
-
'.editor button svg{width:16px;height:16px;display:block}',
|
|
211
|
-
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
212
|
-
].join('');
|
|
213
|
-
shadow.appendChild(style);
|
|
214
|
-
|
|
215
|
-
var cursorStyle = document.createElement('style');
|
|
216
|
-
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
217
|
-
document.head.appendChild(cursorStyle);
|
|
218
|
-
var setCursor = function (value) {
|
|
219
|
-
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
223
|
-
var svg = document.createElementNS(svgNS, 'svg');
|
|
224
|
-
svg.setAttribute('class', 'layer');
|
|
225
|
-
svg.style.overflow = 'visible';
|
|
226
|
-
shadow.appendChild(svg);
|
|
227
|
-
|
|
228
|
-
var hoverBox = document.createElement('div');
|
|
229
|
-
hoverBox.className = 'box';
|
|
230
|
-
var hoverLabel = document.createElement('div');
|
|
231
|
-
hoverLabel.className = 'label';
|
|
232
|
-
var marqueeBox = document.createElement('div');
|
|
233
|
-
marqueeBox.className = 'box';
|
|
234
|
-
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
235
|
-
|
|
236
|
-
var positionBox = function (node, rect) {
|
|
237
|
-
node.style.display = 'block';
|
|
238
|
-
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
239
|
-
node.style.width = rect.width + 'px';
|
|
240
|
-
node.style.height = rect.height + 'px';
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
var tools = document.createElement('div');
|
|
244
|
-
tools.className = 'tools';
|
|
245
|
-
shadow.appendChild(tools);
|
|
246
|
-
|
|
247
|
-
var toolButtons = {};
|
|
248
|
-
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
249
|
-
var button = document.createElement('button');
|
|
250
|
-
button.type = 'button';
|
|
251
|
-
button.textContent = entry[1];
|
|
252
|
-
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
253
|
-
toolButtons[entry[0]] = button;
|
|
254
|
-
tools.appendChild(button);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
var editor = document.createElement('div');
|
|
258
|
-
editor.className = 'editor';
|
|
259
|
-
shadow.appendChild(editor);
|
|
260
|
-
|
|
261
|
-
var comment = document.createElement('textarea');
|
|
262
|
-
comment.rows = 1;
|
|
263
|
-
comment.placeholder = LABELS.commentPlaceholder;
|
|
264
|
-
var submit = document.createElement('button');
|
|
265
|
-
submit.type = 'button';
|
|
266
|
-
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
267
|
-
// input; the localized label stays available to assistive tech.
|
|
268
|
-
submit.setAttribute('aria-label', LABELS.submit);
|
|
269
|
-
submit.title = LABELS.submit;
|
|
270
|
-
submit.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/></svg>';
|
|
271
|
-
editor.append(comment, submit);
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Grows the box with its content.
|
|
275
|
-
*
|
|
276
|
-
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
277
|
-
* field to nothing — which is what left a sliver of a click target and an
|
|
278
|
-
* invisible caret. Measuring only while visible, and never below the CSS
|
|
279
|
-
* min-height, keeps it usable.
|
|
280
|
-
*/
|
|
281
|
-
var resizeComment = function () {
|
|
282
|
-
if (editor.style.display === 'none') return;
|
|
283
|
-
comment.style.height = 'auto';
|
|
284
|
-
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
285
|
-
};
|
|
286
|
-
comment.addEventListener('input', resizeComment);
|
|
287
|
-
|
|
288
|
-
// -------------------------------------------------------------- selection
|
|
289
|
-
|
|
290
|
-
var lastTargetRect = null;
|
|
291
|
-
|
|
292
|
-
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
293
|
-
var positionEditor = function () {
|
|
294
|
-
if (!lastTargetRect) {
|
|
295
|
-
editor.style.display = 'none';
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
var wasHidden = editor.style.display === 'none';
|
|
299
|
-
editor.style.display = 'flex';
|
|
300
|
-
// Measured now that it is laid out, not while it was still hidden.
|
|
301
|
-
if (wasHidden) resizeComment();
|
|
302
|
-
var box = editor.getBoundingClientRect();
|
|
303
|
-
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
304
|
-
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
305
|
-
// Above the target when there is no room below, so the box is never left
|
|
306
|
-
// half off the bottom of the page.
|
|
307
|
-
if (top + box.height > window.innerHeight - 8) {
|
|
308
|
-
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
309
|
-
}
|
|
310
|
-
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
311
|
-
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
315
|
-
var focusComment = function () {
|
|
316
|
-
requestAnimationFrame(function () {
|
|
317
|
-
try {
|
|
318
|
-
comment.focus({ preventScroll: true });
|
|
319
|
-
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
320
|
-
} catch (error) { /* field went away */ }
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
var hasTargets = function () {
|
|
325
|
-
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
var syncChrome = function () {
|
|
329
|
-
submit.disabled = !hasTargets();
|
|
330
|
-
if (!hasTargets()) {
|
|
331
|
-
lastTargetRect = null;
|
|
332
|
-
editor.style.display = 'none';
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
positionEditor();
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
var syncSelectionVisuals = function () {
|
|
339
|
-
if (!selected) return;
|
|
340
|
-
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
341
|
-
if (!usableRect(rect)) {
|
|
342
|
-
selected.outline.style.display = 'none';
|
|
343
|
-
selected.badge.style.display = 'none';
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
positionBox(selected.outline, rect);
|
|
347
|
-
selected.badge.style.display = 'block';
|
|
348
|
-
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
349
|
-
lastTargetRect = rect;
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
var dropSelection = function () {
|
|
353
|
-
if (!selected) return;
|
|
354
|
-
selected.outline.remove();
|
|
355
|
-
selected.badge.remove();
|
|
356
|
-
selected = null;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
var selectElement = function (element) {
|
|
360
|
-
var wasSelected = selected && selected.element === element;
|
|
361
|
-
dropSelection();
|
|
362
|
-
if (wasSelected) {
|
|
363
|
-
// Clicking the chosen element again clears it, so a misclick costs one
|
|
364
|
-
// click rather than starting over.
|
|
365
|
-
lastTargetRect = null;
|
|
366
|
-
syncChrome();
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
var outline = document.createElement('div');
|
|
370
|
-
outline.className = 'box';
|
|
371
|
-
var badge = document.createElement('div');
|
|
372
|
-
badge.className = 'label';
|
|
373
|
-
badge.textContent = selectorPart(element);
|
|
374
|
-
shadow.append(outline, badge);
|
|
375
|
-
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
376
|
-
syncSelectionVisuals();
|
|
377
|
-
syncChrome();
|
|
378
|
-
focusComment();
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
var setTool = function (next) {
|
|
382
|
-
tool = next;
|
|
383
|
-
hoverBox.style.display = 'none';
|
|
384
|
-
hoverLabel.style.display = 'none';
|
|
385
|
-
marqueeBox.style.display = 'none';
|
|
386
|
-
setCursor(next === 'select' ? '' : 'crosshair');
|
|
387
|
-
for (var key in toolButtons) {
|
|
388
|
-
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
389
|
-
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
// ------------------------------------------------------------- interaction
|
|
395
|
-
|
|
396
|
-
var drag = null;
|
|
397
|
-
|
|
398
|
-
var onPointerMove = function (event) {
|
|
399
|
-
if (drag) {
|
|
400
|
-
if (drag.kind === 'marquee') {
|
|
401
|
-
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
402
|
-
positionBox(marqueeBox, drag.rect);
|
|
403
|
-
} else if (drag.kind === 'draw') {
|
|
404
|
-
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
405
|
-
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
406
|
-
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
407
|
-
}).join(' '));
|
|
408
|
-
}
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if (tool !== 'select') return;
|
|
413
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
414
|
-
if (!element) {
|
|
415
|
-
hoverBox.style.display = 'none';
|
|
416
|
-
hoverLabel.style.display = 'none';
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
var rect = rectFrom(element.getBoundingClientRect());
|
|
420
|
-
positionBox(hoverBox, rect);
|
|
421
|
-
hoverLabel.textContent = selectorPart(element);
|
|
422
|
-
hoverLabel.style.display = 'block';
|
|
423
|
-
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
var onPointerDown = function (event) {
|
|
427
|
-
if (event.button !== 0) return;
|
|
428
|
-
if (isOverlayNode(event.target)) return;
|
|
429
|
-
event.preventDefault();
|
|
430
|
-
event.stopPropagation();
|
|
431
|
-
|
|
432
|
-
if (tool === 'select') {
|
|
433
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
434
|
-
if (element) selectElement(element);
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
if (tool === 'marquee') {
|
|
439
|
-
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
444
|
-
path.setAttribute('fill', 'none');
|
|
445
|
-
path.setAttribute('stroke', THEME.primary);
|
|
446
|
-
path.setAttribute('stroke-width', '2.5');
|
|
447
|
-
path.setAttribute('stroke-linecap', 'round');
|
|
448
|
-
path.setAttribute('stroke-linejoin', 'round');
|
|
449
|
-
svg.appendChild(path);
|
|
450
|
-
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
var onPointerUp = function () {
|
|
454
|
-
if (!drag) return;
|
|
455
|
-
var finished = drag;
|
|
456
|
-
drag = null;
|
|
457
|
-
|
|
458
|
-
if (finished.kind === 'marquee') {
|
|
459
|
-
marqueeBox.style.display = 'none';
|
|
460
|
-
var rect = finished.rect;
|
|
461
|
-
if (!rect || !usableRect(rect)) return;
|
|
462
|
-
// A region marks an area, not the elements inside it: expanding it into a
|
|
463
|
-
// selection made the result depend on the page's markup rather than on
|
|
464
|
-
// what was drawn.
|
|
465
|
-
regions.push({ id: nextId('region'), rect: rect });
|
|
466
|
-
var outline = document.createElementNS(svgNS, 'rect');
|
|
467
|
-
outline.setAttribute('x', String(rect.x));
|
|
468
|
-
outline.setAttribute('y', String(rect.y));
|
|
469
|
-
outline.setAttribute('width', String(rect.width));
|
|
470
|
-
outline.setAttribute('height', String(rect.height));
|
|
471
|
-
outline.style.fill = THEME.primarySoft;
|
|
472
|
-
outline.setAttribute('stroke', THEME.primary);
|
|
473
|
-
outline.setAttribute('stroke-width', '1.5');
|
|
474
|
-
outline.setAttribute('rx', '2');
|
|
475
|
-
svg.appendChild(outline);
|
|
476
|
-
lastTargetRect = rect;
|
|
477
|
-
syncChrome();
|
|
478
|
-
focusComment();
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
var points = finished.points;
|
|
483
|
-
if (points.length < 2) {
|
|
484
|
-
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
488
|
-
for (var p = 1; p < points.length; p += 1) {
|
|
489
|
-
minX = Math.min(minX, points[p].x);
|
|
490
|
-
minY = Math.min(minY, points[p].y);
|
|
491
|
-
maxX = Math.max(maxX, points[p].x);
|
|
492
|
-
maxY = Math.max(maxY, points[p].y);
|
|
493
|
-
}
|
|
494
|
-
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
495
|
-
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
496
|
-
lastTargetRect = bounds;
|
|
497
|
-
syncChrome();
|
|
498
|
-
focusComment();
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Swallows the page's own mouse handling while annotating.
|
|
503
|
-
*
|
|
504
|
-
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
505
|
-
* button pressed that button and marking a link navigated away from the page
|
|
506
|
-
* being annotated. These are the events that reach page code, so these are
|
|
507
|
-
* the ones that have to stop.
|
|
508
|
-
*/
|
|
509
|
-
var blockPageInteraction = function (event) {
|
|
510
|
-
if (isOverlayNode(event.target)) return;
|
|
511
|
-
event.preventDefault();
|
|
512
|
-
event.stopPropagation();
|
|
513
|
-
};
|
|
514
|
-
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
515
|
-
|
|
516
|
-
var onScrollOrResize = function () {
|
|
517
|
-
syncSelectionVisuals();
|
|
518
|
-
positionEditor();
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
var onKeyDown = function (event) {
|
|
522
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
523
|
-
if (event.key === 'Escape') {
|
|
524
|
-
event.preventDefault();
|
|
525
|
-
event.stopImmediatePropagation();
|
|
526
|
-
finish(null);
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
var onCommentKeyDown = function (event) {
|
|
531
|
-
// Do not let the annotated page treat typed letters as its own shortcuts.
|
|
532
|
-
event.stopPropagation();
|
|
533
|
-
// WebKit can report the composition-confirming Enter as keyCode 229.
|
|
534
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
535
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
|
536
|
-
event.preventDefault();
|
|
537
|
-
attach();
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
document.addEventListener('pointermove', onPointerMove, true);
|
|
542
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
543
|
-
document.addEventListener('pointerup', onPointerUp, true);
|
|
544
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
545
|
-
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
546
|
-
});
|
|
547
|
-
window.addEventListener('scroll', onScrollOrResize, true);
|
|
548
|
-
window.addEventListener('resize', onScrollOrResize, true);
|
|
549
|
-
window.addEventListener('keydown', onKeyDown, true);
|
|
550
|
-
comment.addEventListener('keydown', onCommentKeyDown);
|
|
551
|
-
|
|
552
|
-
// ------------------------------------------------------------------ finish
|
|
553
|
-
|
|
554
|
-
var teardown = function () {
|
|
555
|
-
document.removeEventListener('pointermove', onPointerMove, true);
|
|
556
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
557
|
-
document.removeEventListener('pointerup', onPointerUp, true);
|
|
558
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
559
|
-
window.removeEventListener(name, blockPageInteraction, true);
|
|
560
|
-
});
|
|
561
|
-
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
562
|
-
window.removeEventListener('resize', onScrollOrResize, true);
|
|
563
|
-
window.removeEventListener('keydown', onKeyDown, true);
|
|
564
|
-
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
565
|
-
setCursor('');
|
|
566
|
-
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
567
|
-
if (host.parentNode) host.parentNode.removeChild(host);
|
|
568
|
-
try { delete window['${Qi}']; } catch (error) { /* non-configurable */ }
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
var finish = function (payload) {
|
|
572
|
-
if (settled) return;
|
|
573
|
-
settled = true;
|
|
574
|
-
teardown();
|
|
575
|
-
// Removing the chrome is not enough: the host screenshots this page right
|
|
576
|
-
// after we resolve, and the compositor can still hold a frame containing
|
|
577
|
-
// our outlines. Yield two frames so the page has actually repainted.
|
|
578
|
-
requestAnimationFrame(function () {
|
|
579
|
-
requestAnimationFrame(function () { resolve(payload); });
|
|
580
|
-
});
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
var attach = function () {
|
|
584
|
-
if (!hasTargets()) return;
|
|
585
|
-
finish({
|
|
586
|
-
id: 'annotation-' + Date.now(),
|
|
587
|
-
pageUrl: String(location.href),
|
|
588
|
-
pageTitle: String(document.title || ''),
|
|
589
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
590
|
-
devicePixelRatio: window.devicePixelRatio || 1,
|
|
591
|
-
comment: comment.value,
|
|
592
|
-
// Zero or one element, never more. Kept as a list so elements, regions
|
|
593
|
-
// and strokes stay one uniform shape for everything downstream.
|
|
594
|
-
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
595
|
-
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
596
|
-
strokes: strokes.map(function (entry) {
|
|
597
|
-
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
598
|
-
})
|
|
599
|
-
});
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
submit.addEventListener('click', attach);
|
|
603
|
-
|
|
604
|
-
(document.body || document.documentElement).appendChild(host);
|
|
605
|
-
setTool('select');
|
|
606
|
-
syncChrome();
|
|
607
|
-
});`},e1={kind:"idle"},yn=t=>typeof t=="object"&&t!==null,kn=t=>typeof t=="number"&&Number.isFinite(t),ql=t=>yn(t)&&Object.values(t).every(e=>typeof e=="string"),La=t=>yn(t)&&kn(t.x)&&kn(t.y)&&kn(t.width)&&kn(t.height),zu=t=>yn(t)&&kn(t.x)&&kn(t.y),t1=t=>yn(t)&&typeof t.tag=="string"&&typeof t.selectorPart=="string"&&(t.id===void 0||typeof t.id=="string")&&(t.className===void 0||typeof t.className=="string"),s1=t=>yn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&La(t.bounds)&&zu(t.center)&&ql(t.attributes)&&ql(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(t1),n1=t=>yn(t)&&typeof t.id=="string"&&s1(t.element),r1=t=>yn(t)&&typeof t.id=="string"&&La(t.rect),o1=t=>yn(t)&&typeof t.id=="string"&&La(t.bounds)&&Array.isArray(t.points)&&t.points.every(zu),i1=t=>yn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&yn(t.viewport)&&kn(t.viewport.width)&&kn(t.viewport.height)&&kn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(n1)&&Array.isArray(t.regions)&&t.regions.every(r1)&&Array.isArray(t.strokes)&&t.strokes.every(o1),a1=1600,l1=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Failed to decode browser page capture")),r.src=t}),c1=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:u})=>{if(!t)return null;try{const d=await l1(`data:${e};base64,${t}`),h=Math.max(1,d.naturalWidth||n),f=Math.max(1,d.naturalHeight||r),p=h/Math.max(1,i||h),g=f/Math.max(1,o||f),w=Math.min(1,a1/h),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(h*w)),v.height=Math.max(1,Math.floor(f*w));const x=v.getContext("2d");if(!x)return null;x.scale(w,w),x.drawImage(d,0,0,h,f);const m=N=>({x:N.x*p,y:N.y*g,width:N.width*p,height:N.height*g}),b=Math.max(2,2.5*p/Math.max(w,.2));x.strokeStyle=a,x.fillStyle=u;const y=N=>{const C=m(N);x.lineWidth=b,x.fillRect(C.x,C.y,C.width,C.height),x.strokeRect(C.x,C.y,C.width,C.height)};for(const N of l.elements)y(N.element.bounds);for(const N of l.regions)y(N.rect);for(const N of l.strokes)N.points.length<2||(x.beginPath(),N.points.forEach((C,j)=>{const A=C.x*p,D=C.y*g;j===0?x.moveTo(A,D):x.lineTo(A,D)}),x.lineCap="round",x.lineJoin="round",x.lineWidth=b*1.4,x.stroke());const S=await new Promise(N=>v.toBlob(N,"image/jpeg",.85));return S?new File([S],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},d1="({ width: window.innerWidth, height: window.innerHeight })",u1=async t=>{try{const e=await t.executeJavaScript(d1,!0);if(!e||typeof e!="object")return null;const n=e;return typeof n.width!="number"||typeof n.height!="number"||!Number.isFinite(n.width)||!Number.isFinite(n.height)?null:{width:n.width,height:n.height}}catch{return null}},bo=async t=>{try{await t.executeJavaScript(Jy,!1)}catch{}},m1=async({host:t,theme:e,labels:n})=>{const r=Zy(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!i1(i))return await bo(t),null;const o=i;try{const l=await u1(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const u=await c1({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:u}}catch{return{payload:o,screenshot:null}}},rn={colorScheme:"dark",primary:"rgb(59, 130, 246)",primarySoft:"rgba(59, 130, 246, 0.16)",primaryFaint:"rgba(59, 130, 246, 0.10)",primaryContrast:"rgb(255, 255, 255)",surface:"rgb(24, 24, 27)",surfaceElevated:"rgb(32, 32, 36)",glassSurface:"rgba(32, 32, 36, 0.64)",glassFilter:"blur(26px) saturate(1.16)",border:"rgba(255, 255, 255, 0.14)",text:"rgb(244, 244, 245)",mutedText:"rgba(244, 244, 245, 0.62)"},f1=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const n=window.getComputedStyle(t).backgroundColor;return n&&n!=="rgba(0, 0, 0, 0)"?n:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},h1=t=>{const e=f1();if(!e)return{...rn,colorScheme:t};try{const n=(a,u)=>e.read(`var(${a})`)||u,r=(a,u,d)=>e.read(`color-mix(in srgb, var(${a}) ${u}%, transparent)`)||d,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||rn.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",rn.primary),primarySoft:r("--primary",16,rn.primarySoft),primaryFaint:r("--primary",10,rn.primaryFaint),primaryContrast:n("--primary-foreground",rn.primaryContrast),surface:n("--surface-background",rn.surface),surfaceElevated:n("--surface-elevated",rn.surfaceElevated),border:n("--border",rn.border),text:n("--foreground",rn.text),mutedText:n("--muted-foreground",rn.mutedText)}}catch{return{...rn,colorScheme:t}}finally{e.dispose()}},p1=2e3,g1=50;let Qn=null,hr=null,Br=null;const x1=async t=>{try{const e=await ds("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},nr=async(t,e)=>{try{const n=await ds("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},b1=async(t=p1)=>{const e=Date.now()+t;for(;!Qn&&Date.now()<e;)await new Promise(n=>setTimeout(n,g1));return Qn},y1=async t=>{const e=t.action==="browser.open",n=Qn;if(!(!n&&!(e&&hr))&&await x1(t.requestId))try{if(e&&!n){const i=typeof t.parameters.url=="string"?t.parameters.url:"";if(!i){await nr(t.requestId,{ok:!1,error:"url is required"});return}hr?.(i);const o=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!o||o==="fill"){await nr(t.requestId,{ok:!0,data:{url:i,opened:!0}});return}const l=await b1();if(!l){await nr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const a=await l.run("browser.resize",{viewport:o}),u=a&&typeof a=="object"?a.viewport??null:null;await nr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!0,viewport:u}});return}const r=await n.run(t.action,t.parameters);await nr(t.requestId,{ok:!0,data:r})}catch(r){await nr(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},Vu=()=>{Br||(Br=Yr(t=>{t.type==="browser-control-request"&&y1({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Uu=()=>{Qn||hr||!Br||(Br(),Br=null)},w1=t=>(Qn=t,Vu(),()=>{Qn===t&&(Qn=null),Uu()}),S1=t=>(hr=t,Vu(),()=>{hr===t&&(hr=null),Uu()}),v1=50,j1=6,k1=2048,C1=200,Ku=t=>{const e=fr(String(t??"").trim());if(!e||e.length>k1)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},N1=(t,e)=>{const n=Ku(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,C1)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,v1)},A1=(t,e)=>{const n=Ku(e);return t.filter(r=>r.url!==n)},P1=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Hu=(t,e,n=j1)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,n);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=P1(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},Ql=20,yo=t=>{const e=yt((t||"").trim());return e?JSON.stringify([ps(),e]):""},D1=t=>{const e=Object.keys(t);if(e.length<=Ql)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Ql);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},pr=er()(_g(t=>({byProject:{},recordVisit:(e,n)=>{const r=yo(e);r&&t(i=>{const o=i.byProject[r]??[],l=N1(o,{...n,at:Date.now()});return l===o?i:{byProject:D1({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=yo(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:A1(o,n)}}:i})},clear:e=>{const n=yo(e);n&&t(r=>{if(!(n in r.byProject))return r;const i={...r.byProject};return delete i[n],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:Xm(),partialize:t=>({byProject:t.byProject})})),I1=[],Gu=t=>e=>{const n=yo(t);return(n?e.byProject[n]:void 0)??I1},Yi=new Map,Jo=new Map,Yn=new Map,Xn=new Set,T1=async(t,e)=>{if(!Ka()){Xn.delete(t),or(t,{type:"close"});return}if(await Jm(Nn()),!Xn.has(t)||!Ka())return;const n=ld().websocket(`/api/dev-tunnel?port=${e}`),r=Zm(n);Yn.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>or(t,{type:"ready"}),r.onmessage=i=>or(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>or(t,{type:"close"}),r.onclose=()=>{Xn.delete(t),Yn.delete(t),or(t,{type:"close"})}};qf(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=Yn.get(t);r&&n.data&&r.send(n.data);return}case"close":Xn.delete(t),Yn.get(t)?.close(),Yn.delete(t);return;case"connect":Xn.add(t),T1(t,e).catch(()=>{Xn.delete(t),or(t,{type:"close"})})}});const qu=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Qu=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!yr(e.toString())}catch{return!1}},Yu=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:0}catch{return 0}},Yl=(t,e)=>{try{const n=new URL(t);return n.protocol="http:",n.hostname="127.0.0.1",n.port=String(e),n.toString()}catch{return t}},Xl=(t,e)=>{try{Jo.set(e,new URL(t).origin)}catch{}};class Fr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const Jl=async t=>{if(!t||!qu()||!yr(t))return t;const e=Nn();if(!Qu(e))return t;const n=Yu(t);if(!n)return t;const r=`${e}|${n}`,i=Yi.get(r);if(i)return Xl(t,i),Yl(t,i);try{const o=await ur("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:ef(),targetKey:ps(),clientToken:Lr(),requestHeaders:cd()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new Fr(t);return Yi.set(r,o.localPort),Xl(t,o.localPort),Yl(t,o.localPort)}catch(o){throw o instanceof Fr?o:new Fr(t)}},Zl=t=>{if(!t||!qu()||!yr(t)||!Qu(Nn()))return!1;const e=Yu(t);return e>0&&!Jo.has(e)},Nr=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=Jo.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},E1=()=>{Yi.clear(),Jo.clear(),Xn.clear();for(const t of Yn.values())t.close();Yn.clear(),ur("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&ma(E1);const ec=6e3,R1=120,M1=80,O1=`
|
|
608
|
-
var MAX_ELEMENTS = ${R1};
|
|
609
|
-
var MAX_LABEL_CHARS = ${M1};
|
|
610
|
-
var visible = function (element) {
|
|
611
|
-
var rect = element.getBoundingClientRect();
|
|
612
|
-
if (rect.width < 1 || rect.height < 1) return false;
|
|
613
|
-
var style = window.getComputedStyle(element);
|
|
614
|
-
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
615
|
-
};
|
|
616
|
-
var label = function (element) {
|
|
617
|
-
var aria = element.getAttribute('aria-label');
|
|
618
|
-
if (aria) return aria.trim();
|
|
619
|
-
var value = element.getAttribute('value');
|
|
620
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
621
|
-
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
622
|
-
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
623
|
-
var placeholder = element.getAttribute('placeholder');
|
|
624
|
-
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
625
|
-
};
|
|
626
|
-
var isUnique = function (selector) {
|
|
627
|
-
try {
|
|
628
|
-
return document.querySelectorAll(selector).length === 1;
|
|
629
|
-
} catch (error) {
|
|
630
|
-
return false;
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Names an element by what it is, falling back to where it sits.
|
|
636
|
-
*
|
|
637
|
-
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
638
|
-
* only until the markup shifts, and says nothing about what it points at.
|
|
639
|
-
* Anything the page states about identity — an id, a test id, an accessible
|
|
640
|
-
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
641
|
-
* as the last resort, because something always has to work.
|
|
642
|
-
*/
|
|
643
|
-
var cssPath = function (element) {
|
|
644
|
-
var tag = element.tagName.toLowerCase();
|
|
645
|
-
|
|
646
|
-
if (element.id) {
|
|
647
|
-
var byId = '#' + CSS.escape(element.id);
|
|
648
|
-
if (isUnique(byId)) return byId;
|
|
649
|
-
}
|
|
650
|
-
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
651
|
-
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
652
|
-
var value = element.getAttribute(stableAttrs[a]);
|
|
653
|
-
if (!value) continue;
|
|
654
|
-
var raw = String(value);
|
|
655
|
-
// A value containing a quote would need escaping for no real gain: such
|
|
656
|
-
// attributes are rare, and the positional chain still covers them.
|
|
657
|
-
if (raw.indexOf('"') !== -1) continue;
|
|
658
|
-
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
659
|
-
if (isUnique(byAttr)) return byAttr;
|
|
660
|
-
}
|
|
661
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
662
|
-
if (className) {
|
|
663
|
-
var classes = className.split(/\\s+/).filter(Boolean);
|
|
664
|
-
for (var c = 0; c < classes.length; c += 1) {
|
|
665
|
-
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
666
|
-
if (isUnique(byClass)) return byClass;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
var parts = [];
|
|
671
|
-
var node = element;
|
|
672
|
-
var depth = 0;
|
|
673
|
-
while (node && node.nodeType === 1 && depth < 6) {
|
|
674
|
-
var part = node.tagName.toLowerCase();
|
|
675
|
-
var parent = node.parentElement;
|
|
676
|
-
if (!parent) { parts.unshift(part); break; }
|
|
677
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
678
|
-
return child.tagName === node.tagName;
|
|
679
|
-
});
|
|
680
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
681
|
-
parts.unshift(part);
|
|
682
|
-
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
683
|
-
node = parent;
|
|
684
|
-
depth += 1;
|
|
685
|
-
}
|
|
686
|
-
return parts.join(' > ');
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
690
|
-
var accessibleName = function (element) {
|
|
691
|
-
var aria = element.getAttribute('aria-label');
|
|
692
|
-
if (aria && aria.trim()) return aria.trim();
|
|
693
|
-
var labelled = element.getAttribute('aria-labelledby');
|
|
694
|
-
if (labelled) {
|
|
695
|
-
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
696
|
-
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
697
|
-
}
|
|
698
|
-
var title = element.getAttribute('title');
|
|
699
|
-
if (title && title.trim()) return title.trim();
|
|
700
|
-
var alt = element.getAttribute('alt');
|
|
701
|
-
if (alt && alt.trim()) return alt.trim();
|
|
702
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
703
|
-
if (text) return text;
|
|
704
|
-
var value = element.getAttribute('value');
|
|
705
|
-
return value && String(value).trim() ? String(value).trim() : '';
|
|
706
|
-
};
|
|
707
|
-
var findByText = function (needle) {
|
|
708
|
-
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
709
|
-
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
710
|
-
var exact = null;
|
|
711
|
-
var partial = null;
|
|
712
|
-
for (var i = 0; i < candidates.length; i += 1) {
|
|
713
|
-
var element = candidates[i];
|
|
714
|
-
if (!visible(element)) continue;
|
|
715
|
-
var text = label(element).toLowerCase();
|
|
716
|
-
if (!text) continue;
|
|
717
|
-
if (text === wanted) { exact = element; break; }
|
|
718
|
-
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
719
|
-
}
|
|
720
|
-
return exact || partial;
|
|
721
|
-
};
|
|
722
|
-
`,Xr=t=>`(() => {
|
|
723
|
-
${O1}
|
|
724
|
-
${t}
|
|
725
|
-
})()`,B1=({selector:t}={})=>Xr(`
|
|
726
|
-
var scopeSelector = ${JSON.stringify(t??"")};
|
|
727
|
-
var root = document;
|
|
728
|
-
if (scopeSelector) {
|
|
729
|
-
try { root = document.querySelector(scopeSelector); }
|
|
730
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
731
|
-
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
732
|
-
}
|
|
733
|
-
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
734
|
-
var elements = [];
|
|
735
|
-
var visibleTotal = 0;
|
|
736
|
-
for (var i = 0; i < interactive.length; i += 1) {
|
|
737
|
-
var element = interactive[i];
|
|
738
|
-
if (!visible(element)) continue;
|
|
739
|
-
visibleTotal += 1;
|
|
740
|
-
if (elements.length >= MAX_ELEMENTS) continue;
|
|
741
|
-
|
|
742
|
-
var rect = element.getBoundingClientRect();
|
|
743
|
-
// Empty and default-valued fields are left out rather than serialized as
|
|
744
|
-
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
745
|
-
// the information it carried.
|
|
746
|
-
var entry = {
|
|
747
|
-
selector: cssPath(element),
|
|
748
|
-
tag: element.tagName.toLowerCase(),
|
|
749
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
750
|
-
};
|
|
751
|
-
// The list covers the whole document so anything can be clicked without
|
|
752
|
-
// scrolling to it first, which means bounds alone do not say what is on
|
|
753
|
-
// screen — a negative y reads as a bug otherwise.
|
|
754
|
-
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
755
|
-
var type = element.getAttribute('type');
|
|
756
|
-
if (type) entry.type = type;
|
|
757
|
-
var role = element.getAttribute('role');
|
|
758
|
-
if (role) entry.role = role;
|
|
759
|
-
var labelText = label(element);
|
|
760
|
-
if (labelText) entry.label = labelText;
|
|
761
|
-
if (element.disabled === true) entry.disabled = true;
|
|
762
|
-
// Flagged rather than described: reporting the accessible name of every
|
|
763
|
-
// element would cost more than it tells, while its absence on something
|
|
764
|
-
// clickable is a defect worth naming.
|
|
765
|
-
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
766
|
-
elements.push(entry);
|
|
767
|
-
}
|
|
768
|
-
var body = document.body ? (document.body.innerText || '') : '';
|
|
769
|
-
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
770
|
-
var docEl = document.documentElement;
|
|
771
|
-
var result = {
|
|
772
|
-
ok: true,
|
|
773
|
-
url: String(location.href),
|
|
774
|
-
title: String(document.title || ''),
|
|
775
|
-
scope: scopeSelector || 'document',
|
|
776
|
-
scrollY: Math.round(window.scrollY),
|
|
777
|
-
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
778
|
-
text: text.slice(0, ${ec}),
|
|
779
|
-
elements: elements
|
|
780
|
-
};
|
|
781
|
-
// State what was dropped. A capped list that reports only its own length
|
|
782
|
-
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
783
|
-
if (text.length > ${ec}) {
|
|
784
|
-
result.textTruncated = true;
|
|
785
|
-
result.textTotalChars = text.length;
|
|
786
|
-
}
|
|
787
|
-
if (visibleTotal > elements.length) {
|
|
788
|
-
result.elementsTruncated = true;
|
|
789
|
-
result.interactiveElementsOnPage = visibleTotal;
|
|
790
|
-
}
|
|
791
|
-
return result;
|
|
792
|
-
`),F1=({selector:t,text:e})=>Xr(`
|
|
793
|
-
var selector = ${JSON.stringify(t??"")};
|
|
794
|
-
var text = ${JSON.stringify(e??"")};
|
|
795
|
-
var target = null;
|
|
796
|
-
if (selector) {
|
|
797
|
-
try { target = document.querySelector(selector); }
|
|
798
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
799
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
800
|
-
} else {
|
|
801
|
-
target = findByText(text);
|
|
802
|
-
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
803
|
-
}
|
|
804
|
-
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
805
|
-
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
806
|
-
target.click();
|
|
807
|
-
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
808
|
-
`),_1=({selector:t,value:e,submit:n})=>Xr(`
|
|
809
|
-
var selector = ${JSON.stringify(t)};
|
|
810
|
-
var value = ${JSON.stringify(e)};
|
|
811
|
-
var target = null;
|
|
812
|
-
try { target = document.querySelector(selector); }
|
|
813
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
814
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
815
|
-
|
|
816
|
-
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
817
|
-
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
818
|
-
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
819
|
-
|
|
820
|
-
target.scrollIntoView({ block: 'center' });
|
|
821
|
-
target.focus();
|
|
822
|
-
if (target.isContentEditable) {
|
|
823
|
-
target.textContent = value;
|
|
824
|
-
} else {
|
|
825
|
-
// Frameworks track the value through the native setter; assigning the
|
|
826
|
-
// property directly leaves React and friends unaware of the change.
|
|
827
|
-
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
828
|
-
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
829
|
-
if (setter && setter.set) setter.set.call(target, value);
|
|
830
|
-
else target.value = value;
|
|
831
|
-
}
|
|
832
|
-
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
833
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
834
|
-
|
|
835
|
-
if (${n?"true":"false"}) {
|
|
836
|
-
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
837
|
-
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
838
|
-
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
839
|
-
var form = target.form;
|
|
840
|
-
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
841
|
-
}
|
|
842
|
-
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
843
|
-
`),L1=({selector:t,direction:e})=>Xr(`
|
|
844
|
-
var selector = ${JSON.stringify(t??"")};
|
|
845
|
-
var direction = ${JSON.stringify(e??"")};
|
|
846
|
-
|
|
847
|
-
var settle = function (extra) {
|
|
848
|
-
return new Promise(function (resolve) {
|
|
849
|
-
requestAnimationFrame(function () {
|
|
850
|
-
requestAnimationFrame(function () {
|
|
851
|
-
var doc = document.documentElement;
|
|
852
|
-
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
853
|
-
var scrollY = Math.round(window.scrollY);
|
|
854
|
-
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
855
|
-
result.atTop = scrollY <= 1;
|
|
856
|
-
result.atBottom = scrollY >= maxScrollY - 1;
|
|
857
|
-
for (var key in extra) {
|
|
858
|
-
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
859
|
-
}
|
|
860
|
-
resolve(result);
|
|
861
|
-
});
|
|
862
|
-
});
|
|
863
|
-
});
|
|
864
|
-
};
|
|
865
|
-
|
|
866
|
-
if (selector) {
|
|
867
|
-
var target = null;
|
|
868
|
-
try { target = document.querySelector(selector); }
|
|
869
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
870
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
871
|
-
// Instant on purpose: the page's own smooth scrolling would still be
|
|
872
|
-
// animating when the next action runs against it.
|
|
873
|
-
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
874
|
-
return settle({ scrolledTo: cssPath(target) });
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
var doc = document.documentElement;
|
|
878
|
-
var page = Math.round(window.innerHeight * 0.85);
|
|
879
|
-
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
880
|
-
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
881
|
-
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
882
|
-
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
883
|
-
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
884
|
-
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
885
|
-
return settle({ direction: direction });
|
|
886
|
-
`),$1=["color","background-color","background-image","opacity","font-family","font-size","font-weight","line-height","letter-spacing","text-align","border-radius","border-width","border-style","border-color","box-shadow","display","position","width","height","padding","margin","gap","flex-direction","justify-content","align-items","z-index","overflow","visibility"],W1=({selector:t})=>Xr(`
|
|
887
|
-
var selector = ${JSON.stringify(t)};
|
|
888
|
-
var target = null;
|
|
889
|
-
try { target = document.querySelector(selector); }
|
|
890
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
891
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
892
|
-
|
|
893
|
-
var computed = window.getComputedStyle(target);
|
|
894
|
-
var styles = {};
|
|
895
|
-
var props = ${JSON.stringify($1)};
|
|
896
|
-
for (var i = 0; i < props.length; i += 1) {
|
|
897
|
-
var value = computed.getPropertyValue(props[i]);
|
|
898
|
-
if (value) styles[props[i]] = String(value).trim();
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
var rect = target.getBoundingClientRect();
|
|
902
|
-
return {
|
|
903
|
-
ok: true,
|
|
904
|
-
selector: cssPath(target),
|
|
905
|
-
tag: target.tagName.toLowerCase(),
|
|
906
|
-
label: label(target),
|
|
907
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
908
|
-
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
909
|
-
styles: styles
|
|
910
|
-
};
|
|
911
|
-
`),z1=t=>{const e=tt.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=At();if(n.length===0)return null;let u;e[0]!==a?(u=a("contextPanel.browser.history.label"),e[0]=a,e[1]=u):u=e[1];let d;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(p,g)=>s.jsxs("div",{role:"option","aria-selected":g===r,className:De("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:w=>{w.preventDefault(),i(p.url)},onPointerEnter:()=>l(g),children:[s.jsx(R,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||_a(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:De("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:w=>{w.preventDefault(),w.stopPropagation(),o(p.url)},children:s.jsx(R,{name:"close",className:"size-3","aria-hidden":"true"})})]},p.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],d=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=d}else d=e[8];let h;return e[15]!==u||e[16]!==d?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":u,children:d}),e[15]=u,e[16]=d,e[17]=h):h=e[17],h},on=t=>{const e=tt.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",u=l&&"text-foreground";let d;e[0]!==u?(d=De("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",u),e[0]=u,e[1]=d):d=e[1];let h;e[2]!==n?(h=s.jsx(R,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==d||e[10]!==h?(f=s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{type:"button",variant:a,size:"xs",className:d,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:h})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=d,e[10]=h,e[11]=f):f=e[11];let p;e[12]!==r?(p=s.jsx(It,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let g;return e[14]!==f||e[15]!==p?(g=s.jsxs(Pt,{children:[f,p]}),e[14]=f,e[15]=p,e[16]=g):g=e[16],g},Xu=t=>{const e=tt.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:u,onReload:d,onOpenExternal:h,canGoBack:f,canGoForward:p,isLoading:g,onAnnotate:w,onOpenDevTools:v,isAnnotating:x,onHardReload:m,onZoomIn:b,onZoomOut:y,onZoomReset:S,zoomPercent:N,onClearCookies:C,onClearCache:j,onToggleDeviceBar:A,isDeviceBarOpen:D}=t;let I;e[0]!==r?(I=r===void 0?[]:r,e[0]=r,e[1]=I):I=e[1];const M=I,z=N===void 0?100:N,{t:E}=At(),[H,B]=c.useState(!1),[O,T]=c.useState(-1);let k;e[2]!==H||e[3]!==M?(k=H?M:[],e[2]=H,e[3]=M,e[4]=k):k=e[4];const P=k;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{T(-1)},e[5]=L):L=e[5];let Q;e[6]!==n||e[7]!==H?(Q=[n,H],e[6]=n,e[7]=H,e[8]=Q):Q=e[8],c.useEffect(L,Q);let q;e[9]!==l?(q=Ne=>{B(!1),T(-1),l(Ne)},e[9]=l,e[10]=q):q=e[10];const te=q;let ae;e[11]!==O||e[12]!==te||e[13]!==P?(ae=Ne=>{if(P.length!==0){if(Ne.key==="ArrowDown"||Ne.key==="ArrowUp"){Ne.preventDefault();const Qe=Ne.key==="ArrowDown"?1:-1,We=P.length;T(U=>{const he=U+Qe;return he<-1?We-1:he>=We?-1:he});return}if(Ne.key==="Escape"&&O>=0){Ne.preventDefault(),T(-1);return}if(Ne.key==="Enter"&&O>=0){Ne.preventDefault();const Qe=P[O];Qe&&te(Qe.url)}}},e[11]=O,e[12]=te,e[13]=P,e[14]=ae):ae=e[14];const X=ae;let Z;e[15]!==E?(Z=E("contextPanel.browser.back"),e[15]=E,e[16]=Z):Z=e[16];const se=!f;let me;e[17]!==a||e[18]!==se||e[19]!==Z?(me=s.jsx(on,{icon:"arrow-left",label:Z,onClick:a,disabled:se}),e[17]=a,e[18]=se,e[19]=Z,e[20]=me):me=e[20];let _;e[21]!==E?(_=E("contextPanel.browser.forward"),e[21]=E,e[22]=_):_=e[22];const ne=!p;let ye;e[23]!==u||e[24]!==_||e[25]!==ne?(ye=s.jsx(on,{icon:"arrow-right",label:_,onClick:u,disabled:ne}),e[23]=u,e[24]=_,e[25]=ne,e[26]=ye):ye=e[26];let ce;e[27]!==g||e[28]!==E?(ce=E(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=E,e[29]=ce):ce=e[29];let F;e[30]!==d||e[31]!==ce?(F=s.jsx(on,{icon:"refresh",label:ce,onClick:d}),e[30]=d,e[31]=ce,e[32]=F):F=e[32];let re;e[33]!==m||e[34]!==E?(re=m?s.jsx(on,{icon:"restart",label:E("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=E,e[35]=re):re=e[35];let fe;e[36]!==n||e[37]!==te?(fe=Ne=>{Ne.preventDefault(),te(n)},e[36]=n,e[37]=te,e[38]=fe):fe=e[38];let de;e[39]!==o?(de=Ne=>o(Ne.target.value),e[39]=o,e[40]=de):de=e[40];let ge,Te;e[41]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>B(!0),Te=()=>B(!1),e[41]=ge,e[42]=Te):(ge=e[41],Te=e[42]);const be=P.length>0;let Ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ee=De("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=Ee):Ee=e[43];let we;e[44]!==E?(we=E("contextPanel.browser.addressAria"),e[44]=E,e[45]=we):we=e[45];let Y;e[46]!==n||e[47]!==X||e[48]!==de||e[49]!==be||e[50]!==we?(Y=s.jsx("input",{value:n,onChange:de,onFocus:ge,onBlur:Te,onKeyDown:X,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":be,"aria-controls":"openchamber-browser-address-suggestions",className:Ee,"aria-label":we}),e[46]=n,e[47]=X,e[48]=de,e[49]=be,e[50]=we,e[51]=Y):Y=e[51];let ve;e[52]!==i?(ve=Ne=>i?.(Ne),e[52]=i,e[53]=ve):ve=e[53];let xe;e[54]!==O||e[55]!==te||e[56]!==ve||e[57]!==P?(xe=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(z1,{entries:P,activeIndex:O,onSelect:te,onForget:ve,onHighlight:T})}),e[54]=O,e[55]=te,e[56]=ve,e[57]=P,e[58]=xe):xe=e[58];let je;e[59]!==fe||e[60]!==Y||e[61]!==xe?(je=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:fe,children:[Y,xe]}),e[59]=fe,e[60]=Y,e[61]=xe,e[62]=je):je=e[62];let oe;e[63]!==b||e[64]!==y||e[65]!==S||e[66]!==E||e[67]!==z?(oe=y&&b?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(on,{icon:"subtract",label:E("contextPanel.browser.zoomOut"),onClick:y}),z!==100&&S?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs(pt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:S,"aria-label":E("contextPanel.browser.zoomReset"),children:[z,"%"]})}),s.jsx(It,{sideOffset:6,children:E("contextPanel.browser.zoomReset")})]}):null,s.jsx(on,{icon:"add",label:E("contextPanel.browser.zoomIn"),onClick:b})]}):null,e[63]=b,e[64]=y,e[65]=S,e[66]=E,e[67]=z,e[68]=oe):oe=e[68];let J;e[69]!==C||e[70]!==E?(J=C?s.jsx(on,{icon:"delete-bin",label:E("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=E,e[71]=J):J=e[71];let K;e[72]!==j||e[73]!==E?(K=j?s.jsx(on,{icon:"database-2",label:E("contextPanel.browser.clearCache"),onClick:j}):null,e[72]=j,e[73]=E,e[74]=K):K=e[74];let $;e[75]!==D||e[76]!==A||e[77]!==E?($=A?s.jsx(on,{icon:"smartphone",label:E("contextPanel.browser.deviceToolbar"),onClick:A,pressed:D}):null,e[75]=D,e[76]=A,e[77]=E,e[78]=$):$=e[78];let le;e[79]!==x||e[80]!==w||e[81]!==E?(le=w?s.jsx(on,{icon:"markup",label:E("contextPanel.browser.annotate.toggle"),onClick:w,pressed:x}):null,e[79]=x,e[80]=w,e[81]=E,e[82]=le):le=e[82];let V;e[83]!==v||e[84]!==E?(V=v?s.jsx(on,{icon:"terminal-box",label:E("contextPanel.browser.devTools"),onClick:v}):null,e[83]=v,e[84]=E,e[85]=V):V=e[85];let Ce;e[86]!==E?(Ce=E("contextPanel.browser.openExternal"),e[86]=E,e[87]=Ce):Ce=e[87];let _e;e[88]!==h||e[89]!==Ce?(_e=s.jsx(on,{icon:"external-link",label:Ce,onClick:h}),e[88]=h,e[89]=Ce,e[90]=_e):_e=e[90];let ke;return e[91]!==me||e[92]!==ye||e[93]!==F||e[94]!==re||e[95]!==je||e[96]!==oe||e[97]!==J||e[98]!==K||e[99]!==$||e[100]!==le||e[101]!==V||e[102]!==_e?(ke=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[me,ye,F,re,je,oe,J,K,$,le,V,_e]}),e[91]=me,e[92]=ye,e[93]=F,e[94]=re,e[95]=je,e[96]=oe,e[97]=J,e[98]=K,e[99]=$,e[100]=le,e[101]=V,e[102]=_e,e[103]=ke):ke=e[103],ke},Mo={kind:"fill"},tc=240,V1=3840,Ju=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],sc=t=>Number.isFinite(t)?Math.round(Math.min(V1,Math.max(tc,t))):tc,Oo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Zu=t=>{const e=Ju.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},U1=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},K1=(t,e)=>{const n=Oo(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},H1=["mobile","tablet","desktop","fill"],G1={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},nc=t=>typeof t=="string"&&H1.includes(t),Xi=t=>t==="fill"?Mo:Zu(G1[t])??Mo,ro=t=>{const e=Oo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Xi(n),i=Oo(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},q1=t=>{const e=tt.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=At();let u;e[0]!==n?(u=Oo(n),e[0]=n,e[1]=u):u=e[1];const d=u,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==d?(f=(se,me)=>{const _=Number.parseInt(me,10);if(!Number.isFinite(_))return;const ne=d??{width:1280,height:800};r({kind:"custom",width:sc(se==="width"?_:ne.width),height:sc(se==="height"?_:ne.height)})},e[2]=r,e[3]=d,e[4]=f):f=e[4];const p=f;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=De("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=g):g=e[5];const w=g;let v;e[6]!==r?(v=se=>{const me=Zu(se.target.value);r(me??Mo)},e[6]=r,e[7]=v):v=e[7];let x;e[8]!==a?(x=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=x):x=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=De("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=m):m=e[10];let b;e[11]!==a?(b=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=b):b=e[12];let y;e[13]!==b?(y=s.jsx("option",{value:"",children:b}),e[13]=b,e[14]=y):y=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=Ju.map(Q1),e[15]=S):S=e[15];let N;e[16]!==h||e[17]!==v||e[18]!==x||e[19]!==y?(N=s.jsxs("select",{value:h,onChange:v,"aria-label":x,className:m,children:[y,S]}),e[16]=h,e[17]=v,e[18]=x,e[19]=y,e[20]=N):N=e[20];const C=d?String(d.width):"";let j;e[21]!==p?(j=se=>p("width",se.target.value),e[21]=p,e[22]=j):j=e[22];let A;e[23]!==a?(A=a("contextPanel.browser.device.width"),e[23]=a,e[24]=A):A=e[24];let D;e[25]!==C||e[26]!==j||e[27]!==A?(D=s.jsx("input",{value:C,onChange:j,placeholder:"—",inputMode:"numeric","aria-label":A,className:w}),e[25]=C,e[26]=j,e[27]=A,e[28]=D):D=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=I):I=e[29];const M=d?String(d.height):"";let z;e[30]!==p?(z=se=>p("height",se.target.value),e[30]=p,e[31]=z):z=e[31];let E;e[32]!==a?(E=a("contextPanel.browser.device.height"),e[32]=a,e[33]=E):E=e[33];let H;e[34]!==M||e[35]!==z||e[36]!==E?(H=s.jsx("input",{value:M,onChange:z,placeholder:"—",inputMode:"numeric","aria-label":E,className:w}),e[34]=M,e[35]=z,e[36]=E,e[37]=H):H=e[37];let B;e[38]!==r||e[39]!==n?(B=()=>r(U1(n)),e[38]=r,e[39]=n,e[40]=B):B=e[40];const O=!d;let T;e[41]!==a?(T=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=T):T=e[42];let k;e[43]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(R,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=k):k=e[43];let P;e[44]!==B||e[45]!==O||e[46]!==T?(P=s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:B,disabled:O,"aria-label":T,children:k})}),e[44]=B,e[45]=O,e[46]=T,e[47]=P):P=e[47];let L;e[48]!==a?(L=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=L):L=e[49];let Q;e[50]!==L?(Q=s.jsx(It,{sideOffset:6,children:L}),e[50]=L,e[51]=Q):Q=e[51];let q;e[52]!==P||e[53]!==Q?(q=s.jsxs(Pt,{children:[P,Q]}),e[52]=P,e[53]=Q,e[54]=q):q=e[54];let te;e[55]!==l||e[56]!==d?(te=d&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=d,e[57]=te):te=e[57];let ae;e[58]===Symbol.for("react.memo_cache_sentinel")?(ae=["system","light","dark"],e[58]=ae):ae=e[58];let X;e[59]!==i||e[60]!==o||e[61]!==a?(X=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ae.map(se=>s.jsx(pt,{type:"button",variant:i===se?"secondary":"ghost",size:"xs",className:De("shrink-0 rounded-full px-2.5 typography-micro",i===se?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(se),"aria-pressed":i===se,children:a(se==="system"?"contextPanel.browser.device.schemeSystem":se==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},se))}),e[59]=i,e[60]=o,e[61]=a,e[62]=X):X=e[62];let Z;return e[63]!==N||e[64]!==D||e[65]!==H||e[66]!==q||e[67]!==te||e[68]!==X?(Z=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,D,I,H,q,te,X]}),e[63]=N,e[64]=D,e[65]=H,e[66]=q,e[67]=te,e[68]=X,e[69]=Z):Z=e[69],Z};function Q1(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Y1=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},X1=2e3,J1=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=Nn();if(!t)return!1;try{return!yr(new URL(t,window.location.href).toString())}catch{return!1}},em=t=>{const e=tt.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=At();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,u]=c.useState(l),d=ax(i),[h]=c.useState(J1);let f,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let D=!0,I=null;const M=new AbortController,z=()=>{qy(M.signal).then(E=>{D&&(u(E),I=setTimeout(z,X1))})};return z(),()=>{D=!1,I&&clearTimeout(I),M.abort()}},p=[],e[1]=f,e[2]=p):(f=e[1],p=e[2]),c.useEffect(f,p);const g=a.kind==="ready"?a.servers:null;let w;e[3]!==d||e[4]!==g?(w=Xy({announced:d,discovered:g}),e[3]=d,e[4]=g,e[5]=w):w=e[5];const v=w;let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Ad,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=x):x=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let b;e[9]!==m?(b=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=b):b=e[10];let y;e[11]!==o?(y=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=y):y=e[12];let S;e[13]!==y?(S=s.jsx("span",{className:"typography-micro text-muted-foreground",children:y}),e[13]=y,e[14]=S):S=e[14];let N;e[15]!==S||e[16]!==b?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[b,S]}),e[15]=S,e[16]=b,e[17]=N):N=e[17];let C;e[18]!==d||e[19]!==v||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(C=v.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:d.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:v.map(D=>s.jsxs(pt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{rx(i),n(D.url)},children:[s.jsx(R,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:_a(D.url)||D.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Y1(D.url)})]},D.port))})]}):null,e[18]=d,e[19]=v,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=C):C=e[24];let j;e[25]!==v.length||e[26]!==a.kind||e[27]!==o?(j=v.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=v.length,e[26]=a.kind,e[27]=o,e[28]=j):j=e[28];let A;return e[29]!==N||e[30]!==C||e[31]!==j?(A=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[x,N,C,j]}),e[29]=N,e[30]=C,e[31]=j,e[32]=A):A=e[32],A},Ls=t=>Math.round(t),Z1=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,u])=>`${a}="${u}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Ls(l.x)}, y=${Ls(l.y)}, width=${Ls(l.width)}, height=${Ls(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},ew=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},tw=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},sw=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Ls(t.viewport.width)}x${Ls(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...Z1(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(ew(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(tw(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
912
|
-
`)},nw=t=>{const e=tt.c(7),{t:n}=At(),r=Je(ow),i=Je(iw),o=ji(aw),l=Qf(lw);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async u=>{const d=r??(i?"draft":null);if(!d){Me.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(u.screenshot)try{await l(u.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:d},{source:"preview-annotation",fileLabel:u.payload.pageUrl||"browser",startLine:1,endLine:1,code:sw({payload:u.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Me.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},rw=()=>{const t=tt.c(16),{t:e}=At();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function ow(t){return t.currentSessionId}function iw(t){return t.newSessionDraft?.open}function aw(t){return t.addDraft}function lw(t){return t.addAttachedFile}const cw=3e4,dw=3,uw=250,mw={attempts:0,windowStartedAt:null},fw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=cw,r=n?0:t.attempts;return r>=dw?null:{delayMs:uw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},hw=-3,oo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",cr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},pw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:e1),[o,l]=c.useState(e),[a,u]=c.useState(""),[d,h]=c.useState(!1),[f,p]=c.useState(!1),g=c.useRef(n);g.current=n;const w=c.useRef(mw);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const I=t.getURL();return oo(I)?I:""}catch{return""}},x=()=>{try{h(t.canGoBack()),p(t.canGoForward())}catch{}},m=I=>{oo(I)&&(l(I),g.current(I))},b=()=>{const I=v();i({kind:"loading",url:I})},y=()=>{const I=v();let M="";try{M=t.getTitle()||""}catch{M=""}u(M),m(I),x(),i(z=>z.kind==="failed"&&z.url===I?z:{kind:"ready",url:I,title:M})},S=I=>{const M=cr(I);oo(M.url)&&(m(M.url),x())},N=I=>{const M=cr(I),z=Array.isArray(M.favicons)?M.favicons.find(Boolean):"",E=v();z&&E&&$u.getState().resolve(E,z)},C=I=>{const M=cr(I);typeof M.title=="string"&&u(M.title)},j=I=>{const M=cr(I);if(M.isMainFrame===!1)return;const z=typeof M.errorCode=="number"?M.errorCode:0;z!==hw&&i({kind:"failed",url:oo(M.validatedURL)?M.validatedURL:v(),code:z,description:typeof M.errorDescription=="string"?M.errorDescription:""})};let A=null;const D=()=>{const I=v(),M=fw(w.current,Date.now());if(!M){i({kind:"failed",url:I,code:0,description:"",crashed:!0});return}w.current=M.state,i({kind:"loading",url:I}),A=setTimeout(()=>{A=null;try{t.reload()}catch{i({kind:"failed",url:I,code:0,description:"",crashed:!0})}},M.delayMs)};t.addEventListener("did-start-loading",b),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",j),t.addEventListener("render-process-gone",D),t.addEventListener("crashed",D);try{!t.isLoading()&&v()&&y()}catch{}return()=>{A!==null&&clearTimeout(A),t.removeEventListener("render-process-gone",D),t.removeEventListener("crashed",D),t.removeEventListener("did-start-loading",b),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",j)}},[t]),{status:r,url:o,title:a,canGoBack:d,canGoForward:f}},gw=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,xw=4e4,io=.5,bw=-3,yw=4,ww="persist:openchamber-browser",rc=20,Sw=600,vw=2e4,jw=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=At(),{currentTheme:i}=Zn(),o=c.useRef(null),[l,a]=c.useState(null),u=c.useCallback(oe=>{o.current=oe,a(oe)},[]),d=Pe(oe=>oe.setContextPanelTabTargetPath),h=c.useRef(fr(t)),f=h.current!==an?h.current:"",[p,g]=c.useState(f?null:an),[w,v]=c.useState(f),[x,m]=c.useState(!1),[b,y]=c.useState(!1),[S,N]=c.useState(0),C=c.useRef(0),[j,A]=c.useState(!1),[D,I]=c.useState(Mo),M=c.useRef(D);M.current=D;const z=c.useRef([]),[E,H]=c.useState("system"),[B,O]=c.useState({width:0,height:0}),T=c.useRef(null),k=c.useRef(null),P=c.useRef(!1),L=c.useRef(Date.now()),Q=c.useCallback(oe=>{!oe||oe===an||!e||!n||d(e,n,oe)},[e,n,d]),q=pw(l,{initialUrl:f,onUrlChange:c.useCallback(oe=>{const J=Nr(oe);v(J),Q(J)},[Q])}),[te,ae]=c.useState(null),X=nw(e),Z=rw(),se=q.status.kind==="loading",me=pr(Gu(e)),_=pr(oe=>oe.recordVisit),ne=pr(oe=>oe.forget);c.useEffect(()=>{q.status.kind==="ready"&&_(e,{url:Nr(q.status.url),title:q.status.title})},[e,q.status,_]);const ye=c.useMemo(()=>Hu(me,w),[me,w]),ce=c.useCallback(oe=>{const J=fr(oe);J!==an&&(v(J),ae(null),Jl(J).then(K=>{const $=o.current;if(!$){g(K);return}try{$.loadURL(K)}catch{g(K)}}).catch(K=>{K instanceof Fr&&ae(J)}))},[]);c.useEffect(()=>{if(!f)return;let oe=!0;return Jl(f).then(J=>{oe&&g(J)}).catch(J=>{if(oe){if(J instanceof Fr){ae(f),g(an);return}g(f)}}),()=>{oe=!1}},[]);const F=c.useMemo(()=>({executeJavaScript:async(oe,J)=>{const K=o.current;if(!K)throw new Error("Browser view is not available");return K.executeJavaScript(oe,J)},capturePage:async()=>{const oe=o.current;if(!oe)return null;const J=oe.getWebContentsId();return Number.isFinite(J)?await ur("desktop_browser_capture_page",{webContentsId:J}):null}}),[]),re=c.useCallback(()=>{if(x){m(!1),bo(F);return}if(!q.url){Me.error(r("contextPanel.browser.annotate.noPage"));return}const oe=h1(i.metadata.variant==="light"?"light":"dark");m(!0),m1({host:F,theme:oe,labels:Z}).then(async J=>{m(!1),J&&await X(J)}).catch(()=>{m(!1),Me.error(r("contextPanel.browser.annotate.failed"))})},[F,X,i,x,q.url,Z,r]);c.useEffect(()=>{if(!x)return;const oe=J=>{Yf(J)||J.key!=="Escape"||(J.preventDefault(),J.stopImmediatePropagation(),m(!1),bo(F))};return window.addEventListener("keydown",oe,!0),()=>window.removeEventListener("keydown",oe,!0)},[F,x]);const fe=c.useCallback(async(oe=8e3)=>{const J=Date.now();for(;;){const K=o.current;if(!K)return!1;let $=!1;try{$=K.isLoading()}catch{return!1}if(!$)return!0;if(Date.now()-J>oe)return!1;await new Promise(le=>setTimeout(le,120))}},[]),de=c.useCallback(async(oe,J)=>{const K=o.current;if(!K)throw new Error("The browser panel is not ready");const $=()=>{nc(J.viewport)&&(I(Xi(J.viewport)),A(!0))};if(oe==="browser.back"||oe==="browser.forward"){const Ne=oe==="browser.back";if(!(Ne?K.canGoBack():K.canGoForward()))throw new Error(Ne?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Ne?K.goBack():K.goForward(),await new Promise(U=>setTimeout(U,150)),await fe();let We="";try{We=K.getTitle()||""}catch{We=""}return{url:Nr(K.getURL()),title:We}}if(oe==="browser.capture"){Pe.getState().openContextBrowser(e,K.getURL());const Ne=Date.now()+1200;let Qe=0,We=0;for(;We<2&&Date.now()<Ne;){const Re=K.getBoundingClientRect().width;We=Re>=2&&Math.abs(Re-Qe)<.5?We+1:0,Qe=Re,await new Promise(Ie=>setTimeout(Ie,50))}await new Promise(Re=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Re()))}),await fe();const U=await F.capturePage();if(!U)throw new Error("The page could not be captured");let he="";try{he=K.getTitle()||""}catch{he=""}return{...U,url:Nr(K.getURL()),title:he,viewport:ro(M.current)}}if(oe==="browser.resize"){if(!nc(J.viewport))throw new Error("viewport is required");return $(),await new Promise(Ne=>setTimeout(Ne,200)),await fe(),{viewport:ro(Xi(J.viewport))}}if(oe==="browser.open"){const Ne=typeof J.url=="string"?J.url:"";if(!Ne)throw new Error("url is required");$(),ce(Ne),await new Promise(U=>setTimeout(U,150));const Qe=await fe(25e3);let We="";try{We=K.getTitle()||""}catch{We=""}return{url:fr(Ne),title:We,opened:!0,settled:Qe,viewport:ro(M.current)}}await fe();const le=Ne=>typeof Ne=="string"&&Ne?Ne:void 0,Ce=(()=>{switch(oe){case"browser.snapshot":return B1({selector:le(J.selector)});case"browser.click":return F1({selector:le(J.selector),text:le(J.text)});case"browser.type":return _1({selector:String(J.selector??""),value:String(J.value??""),submit:J.submit===!0});case"browser.inspect":return W1({selector:String(J.selector??"")});case"browser.scroll":return L1({selector:le(J.selector),direction:le(J.direction)});default:return null}})();if(!Ce)throw new Error(`Unsupported browser action: ${oe}`);const _e=await K.executeJavaScript(Ce,!0);if(!_e||typeof _e!="object")throw new Error("The page returned no result");const ke=_e;if(ke.ok!==!0)throw new Error(typeof ke.error=="string"&&ke.error?ke.error:"Browser action failed");if(oe==="browser.snapshot"){const Ne=z.current;return{...ke,viewport:ro(M.current),...Ne.length>0?{consoleProblems:[...Ne]}:{}}}return(oe==="browser.click"||oe==="browser.type"&&J.submit===!0)&&(await new Promise(Ne=>setTimeout(Ne,150)),await fe()),_e},[F,e,ce,fe]);c.useEffect(()=>w1({run:de}),[de]),c.useEffect(()=>{const oe=F;return()=>{bo(oe)}},[F]),c.useEffect(()=>{if(!l)return;const oe=K=>{const $=K;if(typeof $.level!="number"||$.level<2)return;const le=$.sourceId?`${$.sourceId}${$.line?`:${$.line}`:""}`:"";z.current.push({level:$.level>=3?"error":"warning",message:String($.message??"").slice(0,400),source:le}),z.current.length>rc&&z.current.splice(0,z.current.length-rc)},J=()=>{z.current=[]};return l.addEventListener("console-message",oe),l.addEventListener("did-start-loading",J),()=>{l.removeEventListener("console-message",oe),l.removeEventListener("did-start-loading",J)}},[l]);const ge=c.useRef(new Set),Te=c.useCallback(oe=>{ge.current.clear(),ce(oe)},[ce]);c.useEffect(()=>{if(!l)return;const oe=K=>{const $=cr(K),le=typeof $.url=="string"?$.url:"";!le||!Zl(le)||(K.preventDefault(),ce(le))},J=K=>{const $=cr(K);if($.isMainFrame===!1||$.errorCode===-3)return;const le=typeof $.validatedURL=="string"?$.validatedURL:"";!le||!Zl(le)||ge.current.has(le)||(ge.current.add(le),ce(le))};return l.addEventListener("will-navigate",oe),l.addEventListener("did-fail-load",J),()=>{l.removeEventListener("will-navigate",oe),l.removeEventListener("did-fail-load",J)}},[ce,l]),c.useEffect(()=>{if(!l)return;const oe=J=>{const K=J.detail;J.preventDefault(),K?.url&&ce(K.url)};return l.addEventListener("new-window",oe),()=>l.removeEventListener("new-window",oe)},[ce,l]);const be=c.useCallback(oe=>{const J=Math.min(yw,Math.max(bw,oe));C.current=J,N(J);try{o.current?.setZoomLevel(J)}catch{}},[]);c.useEffect(()=>{const oe=J=>{if(!(J instanceof CustomEvent))return;const K=J.detail,$=o.current;!$||document.activeElement!==$||(K==="zoom-in"?be(C.current+io):K==="zoom-out"?be(C.current-io):K==="zoom-reset"&&be(0))};return window.addEventListener("openchamber:zoom",oe),()=>window.removeEventListener("openchamber:zoom",oe)},[be]);const Ee=c.useCallback(oe=>{ur("desktop_browser_clear_data",{partition:ww,cookies:oe==="cookies",cache:oe==="cache"}).then(()=>{Me.success(r(oe==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Me.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const oe=T.current;if(!oe||typeof ResizeObserver>"u")return;const J=new ResizeObserver(K=>{const $=K[0]?.contentRect;$&&O({width:$.width,height:$.height})});return J.observe(oe),()=>J.disconnect()},[]);const we=c.useCallback(oe=>{H(oe);const J=o.current;if(!J)return;let K=-1;try{K=J.getWebContentsId()}catch{return}ur("desktop_browser_set_color_scheme",{webContentsId:K,scheme:oe}).catch($=>{H("system"),Me.error($ instanceof Error?$.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),Y=c.useCallback(()=>{try{se?o.current?.stop():o.current?.reload()}catch{}},[se]),ve=q.status;c.useEffect(()=>{const oe=()=>{y(!0);const $=setTimeout(()=>{try{o.current?.reload()}catch{}},Sw);return()=>clearTimeout($)};if(ve.kind==="failed"){if(!Hy(ve.code,ve.url)){y(!1);return}const $=Date.now(),le=k.current?.url===ve.url?k.current:{url:ve.url,startedAt:$};if(k.current=le,$-le.startedAt>xw){y(!1);return}return oe()}if(ve.kind==="loading")return;if(k.current=null,ve.kind!=="ready"||!ve.url||!yr(ve.url)){P.current=!0,y(!1);return}if(P.current||Date.now()-L.current>vw){P.current=!0,y(!1);return}let J=!1,K=null;return Qy(Nr(ve.url)).then($=>{if(!J){if($===null||$<500){P.current=!0,y(!1);return}K=oe()}}),()=>{J=!0,K?.()}},[ve]);const xe=q.status.kind==="failed"&&!b?q.status:null,je=K1(D,B);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Xu,{address:w,onAddressChange:v,onSubmit:Te,suggestions:ye,onForgetSuggestion:oe=>ne(e,oe),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:Y,onOpenExternal:()=>{Vo(q.url||w)},canGoBack:q.canGoBack,canGoForward:q.canGoForward,isLoading:se,onAnnotate:re,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>be(S+io),onZoomOut:()=>be(S-io),onZoomReset:()=>be(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>Ee("cookies"),onClearCache:()=>Ee("cache"),onToggleDeviceBar:()=>A(oe=>!oe),isDeviceBarOpen:j}),j?s.jsx(q1,{viewport:D,onViewportChange:I,colorScheme:E,onColorSchemeChange:we,scale:je?.scale??1}):null,s.jsxs("div",{ref:T,className:De("relative min-h-0 flex-1 bg-background",je&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:u,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:je?{width:`${je.width}px`,height:`${je.height}px`,transform:`scale(${je.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!q.url&&!se?s.jsx(em,{onOpen:Te,directory:e}):null,b?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:te})})]}):null,xe&&!te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:xe.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:xe.crashed?r("contextPanel.browser.crashedHint"):xe.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,se?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},kw=t=>{const e=tt.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=At(),l=Pe(Nw);let a;e[0]!==n?(a=fr(n),e[0]=n,e[1]=a):a=e[1];const u=a,d=u!==an?u:"",[h,f]=c.useState(d),[p,g]=c.useState(d);let w;e[2]!==d?(w=d?[d]:[],e[2]=d,e[3]=w):w=e[3];const[v,x]=c.useState(w),[m,b]=c.useState(d?0:-1),[y,S]=c.useReducer(Aw,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=Z=>{!Z||Z===an||!r||!i||l(r,i,Z)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let j;e[8]!==r?(j=Gu(r),e[8]=r,e[9]=j):j=e[9];const A=pr(j),D=pr(Pw),I=pr(Dw);let M;e[10]!==h||e[11]!==A?(M=Hu(A,h),e[10]=h,e[11]=A,e[12]=M):M=e[12];const z=M;let E;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==D?(E=Z=>{const se=fr(Z);se!==an&&(f(se),g(se),C(se),D(r,{url:se}),x(me=>{const _=m>=0?me.slice(0,m+1):[];return _[_.length-1]===se?(b(_.length-1),_):(b(_.length),[..._,se])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=D,e[17]=E):E=e[17];const H=E;let B;e[18]!==v||e[19]!==C?(B=Z=>{const se=v[Z];se&&(b(Z),f(se),g(se),C(se))},e[18]=v,e[19]=C,e[20]=B):B=e[20];const O=B;let T;e[21]!==r||e[22]!==I?(T=Z=>I(r,Z),e[21]=r,e[22]=I,e[23]=T):T=e[23];let k,P;e[24]!==O||e[25]!==m?(P=()=>O(m-1),k=()=>O(m+1),e[24]=O,e[25]=m,e[26]=k,e[27]=P):(k=e[26],P=e[27]);let L;e[28]!==h||e[29]!==p?(L=()=>{Vo(p||h)},e[28]=h,e[29]=p,e[30]=L):L=e[30];const Q=m>0,q=m>=0&&m<v.length-1;let te;e[31]!==h||e[32]!==H||e[33]!==z||e[34]!==k||e[35]!==L||e[36]!==Q||e[37]!==q||e[38]!==T||e[39]!==P?(te=s.jsx(Xu,{address:h,onAddressChange:f,onSubmit:H,suggestions:z,onForgetSuggestion:T,onBack:P,onForward:k,onReload:S,onOpenExternal:L,canGoBack:Q,canGoForward:q,isLoading:!1}),e[31]=h,e[32]=H,e[33]=z,e[34]=k,e[35]=L,e[36]=Q,e[37]=q,e[38]=T,e[39]=P,e[40]=te):te=e[40];let ae;e[41]!==p||e[42]!==H||e[43]!==y||e[44]!==o?(ae=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:p?s.jsx("iframe",{src:p,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${p}|${y}`):s.jsx(em,{onOpen:H})}),e[41]=p,e[42]=H,e[43]=y,e[44]=o,e[45]=ae):ae=e[45];let X;return e[46]!==te||e[47]!==ae?(X=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[te,ae]}),e[46]=te,e[47]=ae,e[48]=X):X=e[48],X},Cw=t=>{const e=tt.c(3),[n]=c.useState(gw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(jw,{...t}):s.jsx(kw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Nw(t){return t.setContextPanelTabTargetPath}function Aw(t){return t+1}function Pw(t){return t.recordVisit}function Dw(t){return t.forget}const Iw=Ln(()=>Fn(()=>import("./WalkthroughView-BEVUDxuw.js"),__vite__mapDeps([0,1,2,3,4,5,6,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.WalkthroughView}))),Tw=Ln(()=>Fn(()=>import("./DiffView-3Dn4QHbu.js"),__vite__mapDeps([124,1,2,4,5,6,7,8,9,83,3,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,125,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.DiffView}))),Ew=Ln(()=>Fn(()=>import("./FilesView-BdTOpew9.js"),__vite__mapDeps([126,1,2,4,5,6,7,8,9,3,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,127,128,129,130,131,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,132,133,118,119,116,121,134,117,135])).then(t=>({default:t.FilesView}))),Rw=Ln(()=>Fn(()=>import("./GitView-Dqf9vHJh.js"),__vite__mapDeps([136,1,2,3,4,5,6,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,137,115,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,85,113,114,116,117,118,119,120,121,122,123])).then(t=>({default:t.GitView}))),Mw=Ln(()=>Fn(()=>import("./LinearIssuesView-CmbeL7I6.js"),__vite__mapDeps([138,1,2,3,4,5,6,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.LinearIssuesView}))),Ow=Ln(()=>Fn(()=>import("./PlanView-BoJxdRZe.js"),__vite__mapDeps([139,1,2,4,5,6,7,8,9,127,57,58,59,60,61,62,79,55,56,63,128,129,130,3,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,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,117,84,135,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102])).then(t=>({default:t.PlanView}))),Bw=320,Fw=1400,tm=600,_w=100,Lw=24,Bo=new Map,$w=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},oc=t=>Number.isFinite(t)?Math.min(Fw,Math.max(Bw,Math.round(t))):tm,Ww=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},zw=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},sm=(t,e)=>e(t==="chat"?"contextPanel.mode.chat":t==="file"?"contextPanel.mode.files":t==="diff"?"contextPanel.mode.diff":t==="walkthrough"?"contextPanel.mode.walkthrough":t==="plan"?"contextPanel.mode.plan":t==="browser"?"contextPanel.mode.browser":t==="git"?"layout.rightSidebar.git":t==="pr"?"contextPanel.mode.pr":t==="linear"?"contextPanel.mode.linear":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),Vw=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},Uw=(t,e,n)=>{if(t.mode==="chat"){const r=Ji(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?_a(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Vw(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):sm(t.mode,n)},ic=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(wa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Iu,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(R,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(R,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(R,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(R,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(R,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(R,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(R,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(R,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=Kw(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(R,{name:"global",className:"h-3.5 w-3.5"})}},Kw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Hw=200,Gw=480,qw=({visible:t})=>{const{t:e}=At(),n=Pe(m=>m.contextEditorTreeWidth),r=Pe(m=>m.setContextEditorTreeWidth),[i,o]=c.useState(!1),l=c.useRef(0),a=c.useRef(n),u=c.useRef(null),d=c.useRef(null),h=c.useRef(null),f=c.useCallback(m=>Math.min(Gw,Math.max(Hw,Math.round(m))),[]),p=c.useCallback(m=>{const b=h.current;b&&(b.style.width=`${m}px`,b.style.setProperty("--oc-editor-tree-width",`${m}px`))},[]),g=m=>{if(t){try{m.currentTarget.setPointerCapture(m.pointerId)}catch{}d.current=m.pointerId,o(!0),l.current=m.clientX,a.current=n,u.current=n,m.preventDefault()}},w=m=>{if(!i||d.current!==m.pointerId)return;const b=l.current-m.clientX,y=f(a.current+b);u.current!==y&&(u.current=y,p(y))},v=m=>{if(d.current!==m.pointerId)return;try{m.currentTarget.releasePointerCapture(m.pointerId)}catch{}const b=f(u.current??n);d.current=null,u.current=null,o(!1),r(b)},x=t?n:0;return s.jsxs("div",{ref:h,className:De("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${i?u.current??x:x}px`,"--oc-editor-tree-width":`${i?u.current??n:n}px`,overflowX:"clip",transitionProperty:i?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:De("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",i&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:w,onPointerUp:v,onPointerCancel:v,role:"separator","aria-orientation":"vertical","aria-label":e("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:De("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",i&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(py,{})})]})},Ji=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Qw=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Yw=(t,e)=>{if(e.length===0)return Bo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Bo:r},Xw=(t,e)=>{const n=Sd(t),r=c.useRef(Bo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=Yw(n.getState().session,i.current);return Qw(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Bo)},Jw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Zw=()=>{const{t}=At(),e=br()??"",n=c.useMemo(()=>$w(e),[e]),r=Pe(G=>n?G.contextPanelByDirectory[n]:void 0),i=Pe(G=>G.closeContextPanel),o=Pe(G=>G.closeContextPanelTab),l=Pe(G=>G.openContextPanelTab),a=Pe(G=>G.toggleContextPanelExpanded),u=Pe(G=>G.setContextPanelWidth),d=Pe(G=>G.setActiveContextPanelTab),h=Pe(G=>G.openContextBrowser);c.useEffect(()=>{if(e)return S1(G=>h(e,G))},[e,h]);const f=Pe(G=>G.reorderContextPanelTabs),p=fn(G=>G.setSelectedPath),g=Pe(G=>G.contextEditorTreeVisible),w=Pe(G=>G.toggleContextEditorTree),v=Pe(G=>G.openNewContextBrowserTab),x=$u(G=>G.byOrigin),m=Pe(G=>G.allowPromptingSubagentSessions),{themeMode:b,setThemeMode:y,lightThemeId:S,darkThemeId:N,currentTheme:C}=Zn(),j=c.useMemo(()=>r?.tabs??[],[r?.tabs]),A=j.find(G=>G.id===r?.activeTabId)??j[j.length-1]??null,D=!!(r?.isOpen&&A),I=!!(D&&r?.expanded),[M,z]=c.useState(null),E=A?.mode??null,H=E?r?.widthByMode?.[E]:void 0,B=E?r?.widthFractionByMode?.[E]:void 0,O=E?Xf(E):.5,T=M??(typeof window<"u"?window.innerWidth:tm*2),k=B!=null&&M!=null?Math.round(B*M):H,P=oc(k??Math.round(O*T));c.useEffect(()=>{!n||!E||B!=null||H==null||M==null||u(n,E,H,M)},[E,M,n,H,B,u]);const L=c.useMemo(()=>{const G=[];for(const Le of j){if(Le.mode!=="chat")continue;const Oe=Ji(Le.dedupeKey);Oe&&!G.includes(Oe)&&G.push(Oe)}return G},[j]),Q=Xw(n||void 0,L),[q,te]=c.useState(!1),ae=c.useRef(0),X=c.useRef(P),Z=c.useRef(null),se=c.useRef(null),me=c.useRef(null),_=c.useRef(new Map),ne=c.useRef(new Map),ye=c.useRef(!1);c.useLayoutEffect(()=>{const G=me.current?.parentElement;if(!G||typeof ResizeObserver>"u")return;const Le=new ResizeObserver(()=>{z(G.clientWidth||null)});return Le.observe(G),z(G.clientWidth||null),()=>Le.disconnect()},[]),c.useEffect(()=>{if(!D||ye.current){ye.current=D;return}const G=window.requestAnimationFrame(()=>{me.current?.focus({preventScroll:!0})});return ye.current=!0,()=>window.cancelAnimationFrame(G)},[D]);const ce=c.useRef(null),F=c.useRef(null),re=c.useCallback(()=>{F.current=null;const G=me.current,Le=Z.current;!G||Le===null||G.style.setProperty("--oc-context-panel-width",`${Le}px`)},[]);c.useEffect(()=>()=>{F.current!==null&&clearTimeout(F.current)},[]);const fe=c.useCallback(G=>{const Le=oc(G),Oe=ce.current;return Oe===null?Le:Math.min(Le,Math.max(1,Oe))},[]),de=c.useCallback(G=>{!D||I||!n||(se.current=G.pointerId,te(!0),ae.current=G.clientX,X.current=P,Z.current=P,ce.current=Ww(me.current),document.documentElement.style.cursor="col-resize",G.preventDefault())},[n,I,D,P]),ge=c.useCallback(()=>{const G=fe(Z.current??P),Le=ce.current;Z.current=null,ce.current=null,F.current!==null&&(clearTimeout(F.current),F.current=null),document.documentElement.style.cursor="",n&&E&&u(n,E,G,Le??void 0),te(!1),se.current=null},[E,fe,n,u,P]);c.useEffect(()=>{if(!q)return;const G=qe=>{if(se.current!==qe.pointerId)return;const Ue=ae.current-qe.clientX,st=fe(X.current+Ue);Z.current!==st&&(Z.current=st,F.current===null&&(F.current=setTimeout(re,_w)))},Le=qe=>{se.current===qe.pointerId&&ge()},Oe=()=>{ge()};return window.addEventListener("pointermove",G),window.addEventListener("pointerup",Le),window.addEventListener("pointercancel",Le),window.addEventListener("blur",Oe),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("pointerup",Le),window.removeEventListener("pointercancel",Le),window.removeEventListener("blur",Oe)}},[re,fe,ge,q]),c.useEffect(()=>{q||(Z.current=null,document.documentElement.style.cursor="")},[q]);const Te=c.useCallback(()=>{n&&i(n)},[i,n]),be=c.useCallback(()=>{n&&a(n)},[n,a]),Ee=c.useCallback(G=>{G.key==="Escape"&&(Jf(G.target)||(G.preventDefault(),G.stopPropagation(),Te()))},[Te]);c.useEffect(()=>{if(!(!n||!A)&&A.mode==="file"&&A.targetPath){p(n,A.targetPath,{allowOutsideRoot:!0});return}},[A,n,p]);const we=c.useMemo(()=>j.filter(G=>G.mode==="chat"),[j]),Y=D&&A?.mode==="chat"?A.id:null,ve=D&&A?.mode==="chat"?Ji(A.dedupeKey):null,xe=Lg(we,Y);c.useEffect(()=>{if(!D||!n||!ve||typeof window>"u")return;const G=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ei(n,ve,!1);return}Pd(ve),ei(n,ve,!0)};G();const Le=window.setInterval(G,1e4);return window.addEventListener("focus",G),window.addEventListener("blur",G),document.addEventListener("visibilitychange",G),()=>{window.clearInterval(Le),window.removeEventListener("focus",G),window.removeEventListener("blur",G),document.removeEventListener("visibilitychange",G),ei(n,ve,!1)}},[ve,n,D]);const je=c.useCallback((G,Le,Oe)=>$g(ne.current,G,Le,n||null,Oe,{mode:b,lightThemeId:S,darkThemeId:N,currentTheme:C},{allowPromptingSubagentSessions:m}),[m,C,N,n,S,b]),oe=xe&&ve?je(xe.id,ve,xe.readOnly):null;c.useEffect(()=>{const G=new Set(j.map(Le=>Le.id));for(const Le of ne.current.keys())G.has(Le)||ne.current.delete(Le)},[j]);const J=c.useCallback(G=>{!n||A?.mode!=="diff"||l(n,{mode:"diff",targetPath:A.targetPath,stagedDiff:G==="staged",diffScope:G})},[A,n,l]),K=c.useCallback(()=>{if(typeof window>"u")return;const G={themeMode:b,lightThemeId:S,darkThemeId:N,currentTheme:C};for(const Le of _.current.values()){const Oe=Le.contentWindow;Oe&&Oe.postMessage({type:"openchamber:theme-sync",payload:G},window.location.origin)}},[C,N,S,b]),$=c.useCallback(()=>{if(typeof window>"u")return;const G={allowPromptingSubagentSessions:m};for(const Le of _.current.values()){const Oe=Le.contentWindow;Oe&&Oe.postMessage({type:"openchamber:chat-settings-sync",payload:G},window.location.origin)}},[m]),le=c.useCallback((G,Le,Oe)=>{const qe=Le.contentWindow;qe&&qe.postMessage({type:fu,payload:{visible:Y===G}},Oe)},[Y]),V=c.useCallback(()=>{if(!(typeof window>"u"))for(const[G,Le]of _.current.entries())le(G,Le,window.location.origin)},[le]);c.useEffect(()=>{if(typeof window>"u")return;const G=Le=>{if(Le.origin!==window.location.origin)return;const Oe=Array.from(_.current.entries()).find(([,Nt])=>Nt.contentWindow===Le.source);if(!Oe)return;const qe=Le.data;if(qe?.type===Wg){const[Nt,ie]=Oe;le(Nt,ie,Le.origin);return}if(qe?.type===zg){if(typeof qe.requestId!="string"||!qe.requestId)return;const Nt=ps(),ie={apiBaseUrl:Nn(),clientToken:Lr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:cd(),relayHostId:Nt.startsWith("host:")?Nt.slice(5):"",relay:tf()??void 0};Le.source?.postMessage({type:Vg,requestId:qe.requestId,payload:ie},Le.origin);return}if(qe?.type==="openchamber:theme-sync-request"){K();return}if(qe?.type==="openchamber:chat-settings-request"){$();return}if(qe?.type!=="openchamber:cycle-theme-request")return;const Ue=["light","dark","system"],wt=(Ue.indexOf(b)+1)%Ue.length;y(Ue[wt])};return window.addEventListener("message",G),()=>window.removeEventListener("message",G)},[$,le,K,y,b]),c.useLayoutEffect(()=>{j.some(Le=>Le.mode==="chat")&&(K(),$(),V())},[N,S,$,V,K,j,b]);const Ce=A?.mode==="file"||A?.mode==="chat"||A?.mode==="browser",_e=c.useMemo(()=>A?j.filter(G=>G.mode===A.mode):[],[A,j]),ke=c.useMemo(()=>_e.map(G=>{const Le=Uw(G,Q,t),Oe=Jw(Le,Lw),qe=zw(G.targetPath,e);return{id:G.id,label:Oe,icon:ic(G,x),title:qe?`${Le}: ${qe}`:Le,closeLabel:t("contextPanel.tab.closeTabAria",{label:Oe})}}),[_e,e,x,Q,t]),Ne=A?.mode==="context"?s.jsx(Ey,{}):A?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Rw,{isActive:D})}):A?.mode==="pr"?s.jsx(Wb,{}):A?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Mw,{})}):A?.mode==="notes"?s.jsx(tg,{}):A?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Ow,{targetPath:A.targetPath,savedProjectPlan:A.projectPlanId&&A.projectPlanRef?{projectRef:A.projectPlanRef,planId:A.projectPlanId}:null})}):null,Qe=c.useMemo(()=>j.filter(G=>G.mode==="browser"),[j]),We=c.useMemo(()=>j.filter(G=>G.mode==="diff"),[j]),U=c.useMemo(()=>j.find(G=>G.mode==="terminal")??null,[j]),he=c.useMemo(()=>j.some(G=>G.mode==="walkthrough"),[j]),Re=c.useMemo(()=>j.some(G=>G.mode==="file"),[j]),Ie=c.useMemo(()=>j.some(G=>G.mode==="file"&&G.targetPath),[j]),rt=A?.mode==="file",Ge=Pe(G=>G.closeContextPanelTabs),ut=c.useCallback(G=>{if(!n)return null;const{id:Le,index:Oe,allIds:qe,close:Ue}=G,st=()=>Ge(n,qe.filter(He=>He!==Le)),wt=()=>Ge(n,qe.slice(0,Oe)),Nt=()=>Ge(n,qe.slice(Oe+1)),ie=()=>Ge(n,qe),pe=qe.length>1,Ve=Oe===0,ze=Oe===qe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Un,{onClick:Ue,children:[s.jsx(R,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Mi,{}),s.jsxs(Un,{onClick:st,disabled:!pe,children:[s.jsx(R,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Un,{onClick:wt,disabled:Ve,children:[s.jsx(R,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Un,{onClick:Nt,disabled:ze,children:[s.jsx(R,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Mi,{}),s.jsxs(Un,{onClick:ie,disabled:!pe,children:[s.jsx(R,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Ge,n,t]),ct=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Ce?s.jsx(Jd,{items:ke,activeId:A?.id??null,onSelect:G=>{n&&d(n,G)},onClose:G=>{n&&o(n,G)},onReorder:(G,Le)=>{n&&f(n,G,Le)},layoutMode:"scrollable",variant:"default",tabContextMenu:ut}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[A?ic(A,x):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:A?sm(A.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[A?.mode==="browser"?s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&v(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null,rt?s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":g,children:s.jsx(R,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:be,className:"h-7 w-7 p-0",title:t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:I?s.jsx(R,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:Te,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]})]}),ue=D?I?{"--oc-context-panel-width":M!==null?`${M}px`:"100%",width:M!==null?`${M}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${P}px`}:{"--oc-context-panel-width":`${P}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:me,"data-context-panel":"true",tabIndex:-1,inert:!D||void 0,className:De("flex min-h-0 flex-col overflow-hidden bg-background",I?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!D&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Ee,style:ue,children:[D&&!I&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),D&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!I&&s.jsx("div",{className:De("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",q&&"bg-[var(--interactive-border)]"),onPointerDown:de,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:De("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!D&&"pointer-events-none select-none opacity-0"),style:{width:I?M!==null?`${M}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!D,children:[ct,s.jsxs("div",{className:De("relative min-h-0 flex-1 overflow-hidden",q&&"pointer-events-none"),children:[Re?s.jsxs("div",{className:De("absolute inset-0 flex",rt?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:Ie?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Ew,{mode:"editor-only"})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(R,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}),s.jsx(qw,{visible:g})]}):null,xe&&ve&&oe?s.jsx("iframe",{ref:G=>{if(!G){_.current.delete(xe.id);return}_.current.set(xe.id,G)},src:oe,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ve}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{K(),$(),V()}},xe.id):null,Qe.map(G=>s.jsx("div",{className:De("absolute inset-0",A?.id!==G.id&&"hidden"),children:s.jsx(Cw,{initialUrl:G.targetPath??"",directory:n,tabID:G.id})},G.id)),We.map(G=>s.jsx("div",{className:De("absolute inset-0",A?.id!==G.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Tw,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:G.diffScope??(G.stagedDiff?"staged":"working"),onDiffScopeChange:J,targetFilePath:G.targetPath,flushContent:!0})})},G.id)),U?s.jsx("div",{className:De("absolute inset-0",A?.mode==="terminal"?"block":"hidden"),children:s.jsx(sg,{visible:D&&A?.mode==="terminal",directory:U.targetDirectory})}):null,he?s.jsx("div",{className:De("absolute inset-0",A?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Iw,{directory:e,visible:A?.mode==="walkthrough"})})}):null,A?.mode!=="chat"&&!rt&&A?.mode!=="browser"&&A?.mode!=="diff"&&A?.mode!=="terminal"&&A?.mode!=="walkthrough"?Ne:null]})]})]})},eS=t=>{const e=tt.c(42),{open:n,onOpenChange:r}=t,{t:i}=At(),o=Pe(tS),l=Pe(sS),a=Pe(nS),u=Pe(rS);let d;e[0]!==o?(d=Dd(o),e[0]=o,e[1]=d):d=e[1];const h=d,f=l.length===0;let p;if(e[2]!==l||e[3]!==h){let A;e[5]!==l?(A=D=>l.includes(D.id),e[5]=l,e[6]=A):A=e[6],p=h.every(A),e[2]=l,e[3]=h,e[4]=p}else p=e[4];const g=p;let w;e[7]!==i?(w=i("contextRail.configure.dialogTitle"),e[7]=i,e[8]=w):w=e[8];let v;e[9]!==w?(v=s.jsx(Is,{children:w}),e[9]=w,e[10]=v):v=e[10];let x;e[11]!==i?(x=i("contextRail.configure.dialogDescription"),e[11]=i,e[12]=x):x=e[12];let m;e[13]!==x?(m=s.jsx(Ts,{children:x}),e[13]=x,e[14]=m):m=e[14];let b;e[15]!==v||e[16]!==m?(b=s.jsxs(Ws,{children:[v,m]}),e[15]=v,e[16]=m,e[17]=b):b=e[17];let y;if(e[18]!==l||e[19]!==a||e[20]!==h||e[21]!==i){let A;e[23]!==l||e[24]!==a||e[25]!==i?(A=D=>s.jsx(Zf,{settingsItem:`layout.context-rail.surface.${D.id}`,checked:!l.includes(D.id),onChange:I=>a(D.id,I),label:i(D.labelKey),ariaLabel:i(D.labelKey)},D.id),e[23]=l,e[24]=a,e[25]=i,e[26]=A):A=e[26],y=h.map(A),e[18]=l,e[19]=a,e[20]=h,e[21]=i,e[22]=y}else y=e[22];let S;e[27]!==y?(S=s.jsx("div",{className:"flex flex-col",children:y}),e[27]=y,e[28]=S):S=e[28];let N;e[29]!==f||e[30]!==g||e[31]!==u||e[32]!==i?(N=f?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[g?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(pt,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[29]=f,e[30]=g,e[31]=u,e[32]=i,e[33]=N):N=e[33];let C;e[34]!==N||e[35]!==b||e[36]!==S?(C=s.jsxs(Ss,{className:"max-w-md",children:[b,S,N]}),e[34]=N,e[35]=b,e[36]=S,e[37]=C):C=e[37];let j;return e[38]!==r||e[39]!==n||e[40]!==C?(j=s.jsx(ws,{open:n,onOpenChange:r,children:C}),e[38]=r,e[39]=n,e[40]=C,e[41]=j):j=e[41],j};function tS(t){return t.contextRailOrder}function sS(t){return t.contextRailHiddenSurfaces}function nS(t){return t.setContextRailSurfaceVisible}function rS(t){return t.setContextRailHiddenSurfaces}const nm=150,oS=500,iS=[],aS=t=>t>99?"99+":String(t),lS=t=>{const e=tt.c(51),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:u,badgeDescription:d,orderNumber:h,showOrderNumber:f,onSelect:p}=t;let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:w,listeners:v,setNodeRef:x,transform:m,transition:b,isDragging:y}=qo(g);let S;e[2]!==a?(S=a!=null&&a>0?aS(a):null,e[2]=a,e[3]=S):S=e[3];const N=S;let C;e[4]!==m?(C=Qo.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let j;e[6]!==C||e[7]!==b?(j={transform:C,transition:b},e[6]=C,e[7]=b,e[8]=j):j=e[8];const A=y&&"z-10 opacity-70";let D;e[9]!==A?(D=De("relative",A),e[9]=A,e[10]=D):D=e[10];let I;e[11]!==p||e[12]!==n?(I=()=>p(n),e[11]=p,e[12]=n,e[13]=I):I=e[13];const M=u??o,z=r?"text-primary":"text-muted-foreground hover:text-foreground";let E;e[14]!==z?(E=De("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",z),e[14]=z,e[15]=E):E=e[15];let H;e[16]!==n.icon||e[17]!==n.id?(H=n.id==="diff"?s.jsx(Iu,{}):s.jsx(R,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=H):H=e[18];let B;e[19]!==N||e[20]!==h||e[21]!==i||e[22]!==f?(B=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):N?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:N}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[19]=N,e[20]=h,e[21]=i,e[22]=f,e[23]=B):B=e[23];let O;e[24]!==w||e[25]!==r||e[26]!==v||e[27]!==E||e[28]!==H||e[29]!==B||e[30]!==I||e[31]!==M?(O=s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...v,onClick:I,"aria-label":M,"aria-pressed":r,className:E,children:[H,B]})}),e[24]=w,e[25]=r,e[26]=v,e[27]=E,e[28]=H,e[29]=B,e[30]=I,e[31]=M,e[32]=O):O=e[32];let T;e[33]!==o?(T=s.jsx("span",{children:o}),e[33]=o,e[34]=T):T=e[34];let k;e[35]!==l?(k=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[35]=l,e[36]=k):k=e[36];let P;e[37]!==d?(P=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[37]=d,e[38]=P):P=e[38];let L;e[39]!==T||e[40]!==k||e[41]!==P?(L=s.jsx(It,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[T,k,P]})}),e[39]=T,e[40]=k,e[41]=P,e[42]=L):L=e[42];let Q;e[43]!==O||e[44]!==L?(Q=s.jsxs(Pt,{delayDuration:nm,children:[O,L]}),e[43]=O,e[44]=L,e[45]=Q):Q=e[45];let q;return e[46]!==x||e[47]!==Q||e[48]!==j||e[49]!==D?(q=s.jsx("div",{ref:x,style:j,className:D,children:Q}),e[46]=x,e[47]=Q,e[48]=j,e[49]=D,e[50]=q):q=e[50],q},cS=()=>{const t=tt.c(86),{t:e}=At(),n=br();let r;t[0]!==n?(r=n?rr(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=ve=>i?ve.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Pe(o),a=Pe(dS),u=Pe(uS),d=Pe(mS),h=Pe(fS),f=Pe(hS),p=Pe(pS),g=Pe(gS),w=xa(xS),v=ki(bS),x=ki(yS),m=An(wS),b=An(SS),{screenWidth:y}=_n(),S=ba(i||null);let N;t[4]!==g?(N=Ci("switch_context_surface",g),t[4]=g,t[5]=N):N=t[5];const C=N,[j,A]=c.useState(!1);let D,I;t[6]!==C?(D=()=>{const ve=new Set;let xe=null,je=!1;const oe=vS,J=()=>{tl(C,ve)?!je&&xe===null&&(xe=setTimeout(()=>A(!0),oS)):(je=!1,xe!==null&&(clearTimeout(xe),xe=null),A(!1))},K=V=>{if(ve.add(V.key.toLowerCase()),oe(V.key)&&tl(C,ve)){je=!0,xe!==null&&(clearTimeout(xe),xe=null),A(!1);return}J()},$=V=>{ve.delete(V.key.toLowerCase()),J()},le=()=>{ve.clear(),je=!1,xe!==null&&(clearTimeout(xe),xe=null),A(!1)};return window.addEventListener("keydown",K,!0),window.addEventListener("keyup",$,!0),window.addEventListener("blur",le),()=>{window.removeEventListener("keydown",K,!0),window.removeEventListener("keyup",$,!0),window.removeEventListener("blur",le),xe!==null&&clearTimeout(xe)}},I=[C],t[6]=C,t[7]=D,t[8]=I):(D=t[7],I=t[8]),c.useEffect(D,I);let M;t[9]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{distance:8}},t[9]=M):M=t[9];let z;t[10]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{delay:200,tolerance:6}},t[10]=z):z=t[10];const E=zr(Mn(iu,M),Mn(ou,z)),H=l?.tabs??iS;let B;t[11]!==l?.activeTabId||t[12]!==H?(B=H.find(ve=>ve.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=H,t[13]=B):B=t[13];const O=B,T=l?.isOpen?O?.mode??null:null,k=S?.files.length??0;let P;t[14]!==d||t[15]!==u||t[16]!==b||t[17]!==x||t[18]!==w||t[19]!==y||t[20]!==H?(P=eh({railOrder:u,hiddenSurfaces:d,planModeEnabled:w,isVSCode:Pn(),screenWidth:y,tabs:H,linearConnected:x,githubConnected:b}),t[14]=d,t[15]=u,t[16]=b,t[17]=x,t[18]=w,t[19]=y,t[20]=H,t[21]=P):P=t[21];const L=P;let Q,q;t[22]!==T||t[23]!==p||t[24]!==i||t[25]!==v||t[26]!==x?(q=()=>{!i||!v||x||T!=="linear"||p(i)},Q=[T,p,i,v,x],t[22]=T,t[23]=p,t[24]=i,t[25]=v,t[26]=x,t[27]=Q,t[28]=q):(Q=t[27],q=t[28]),c.useEffect(q,Q);let te,ae;t[29]!==T||t[30]!==p||t[31]!==i||t[32]!==m||t[33]!==b?(te=()=>{!i||!m||b||T!=="pr"||p(i)},ae=[T,p,i,m,b],t[29]=T,t[30]=p,t[31]=i,t[32]=m,t[33]=b,t[34]=te,t[35]=ae):(te=t[34],ae=t[35]),c.useEffect(te,ae);const[X,Z]=c.useState(!1);let se;t[36]!==h?(se=ve=>{const{active:xe,over:je}=ve;if(!je||xe.id===je.id)return;const oe=Dd(Pe.getState().contextRailOrder).map(jS),J=oe.indexOf(xe.id),K=oe.indexOf(je.id);J===-1||K===-1||h(au(oe,J,K))},t[36]=h,t[37]=se):se=t[37];const me=se;if(!i)return null;let _;t[38]!==e?(_=e("contextRail.aria.rail"),t[38]=e,t[39]=_):_=t[39];let ne;t[40]!==L?(ne=L.map(kS),t[40]=L,t[41]=ne):ne=t[41];let ye;if(t[42]!==T||t[43]!==k||t[44]!==i||t[45]!==f||t[46]!==j||t[47]!==L||t[48]!==e||t[49]!==a){let ve;t[51]!==T||t[52]!==k||t[53]!==i||t[54]!==f||t[55]!==j||t[56]!==e||t[57]!==a?(ve=(xe,je)=>{const oe=e(xe.labelKey),J=xe.id==="git"&&!a?k:0,K=J>0?J:null;return s.jsx(lS,{surface:xe,isActive:T===xe.mode,showActivityDot:!1,label:oe,description:e(xe.descriptionKey),badgeCount:K,badgeAriaLabel:K!==null?e(K===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:oe,count:K}):null,badgeDescription:K!==null?e(K===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:K}):null,orderNumber:je+1,showOrderNumber:j,onSelect:$=>f(i,$.mode)},xe.id)},t[51]=T,t[52]=k,t[53]=i,t[54]=f,t[55]=j,t[56]=e,t[57]=a,t[58]=ve):ve=t[58],ye=L.map(ve),t[42]=T,t[43]=k,t[44]=i,t[45]=f,t[46]=j,t[47]=L,t[48]=e,t[49]=a,t[50]=ye}else ye=t[50];let ce;t[59]!==ne||t[60]!==ye?(ce=s.jsx(Io,{items:ne,strategy:Fi,children:ye}),t[59]=ne,t[60]=ye,t[61]=ce):ce=t[61];let F;t[62]!==me||t[63]!==E||t[64]!==ce?(F=s.jsx(Vr,{sensors:E,collisionDetection:Ur,onDragEnd:me,children:ce}),t[62]=me,t[63]=E,t[64]=ce,t[65]=F):F=t[65];let re;t[66]!==e?(re=e("contextRail.configure.open"),t[66]=e,t[67]=re):re=t[67];let fe;t[68]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>Z(!0),t[68]=fe):fe=t[68];let de;t[69]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(R,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[69]=de):de=t[69];let ge;t[70]!==re?(ge=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":re,onClick:fe,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:de})}),t[70]=re,t[71]=ge):ge=t[71];let Te;t[72]!==e?(Te=e("contextRail.configure.open"),t[72]=e,t[73]=Te):Te=t[73];let be;t[74]!==Te?(be=s.jsx(It,{side:"left",sideOffset:8,children:Te}),t[74]=Te,t[75]=be):be=t[75];let Ee;t[76]!==ge||t[77]!==be?(Ee=s.jsxs(Pt,{delayDuration:nm,children:[ge,be]}),t[76]=ge,t[77]=be,t[78]=Ee):Ee=t[78];let we;t[79]!==X?(we=s.jsx(eS,{open:X,onOpenChange:Z}),t[79]=X,t[80]=we):we=t[80];let Y;return t[81]!==_||t[82]!==F||t[83]!==Ee||t[84]!==we?(Y=s.jsxs("nav",{"aria-label":_,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[F,Ee,we]}),t[81]=_,t[82]=F,t[83]=Ee,t[84]=we,t[85]=Y):Y=t[85],Y};function dS(t){return t.workStatusPanelVisible}function uS(t){return t.contextRailOrder}function mS(t){return t.contextRailHiddenSurfaces}function fS(t){return t.setContextRailOrder}function hS(t){return t.openContextSurface}function pS(t){return t.closeContextPanel}function gS(t){return t.shortcutOverrides}function xS(t){return t.planModeEnabled}function bS(t){return t.hasChecked}function yS(t){return t.status?.connected===!0}function wS(t){return t.hasChecked}function SS(t){return t.status?.connected===!0}function vS(t){return t.length===1&&t>="0"&&t<="9"}function jS(t){return t.id}function kS(t){return t.id}const CS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),NS=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Er(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),AS=new Set,PS=[],Zi=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},DS=()=>{const t=tt.c(182),{t:e}=At(),n=Pe(IS),r=Pe(TS),i=Pe(ES),o=Pe(RS),l=Pe(MS),a=Pe(OS),u=Pe(BS),d=Pe(FS),h=Pe(_S),f=Pe(LS),p=Pe($S),g=Pe(WS),w=Pe(zS),v=Je(VS),x=Je(US),m=Je(KS),b=$r(HS);let y;t[0]!==n?(y=Ze=>n?Ze.activeSessions:PS,t[0]=n,t[1]=y):y=t[1];const S=Ds(y);let N;t[2]!==n?(N=Ze=>n?Ze.ids:AS,t[2]=n,t[3]=N):N=t[3];const C=$r(N);let j;t[4]!==n?(j=Ze=>n?Ze.rankById:Td,t[4]=n,t[5]=j):j=t[5];const A=va(j),D=ts(GS),I=Kt(qS),M=Kt(QS),z=br(),E=ad(YS),{files:H,git:B}=wn(),O=On(XS),{isMobile:T}=_n();let k;t[6]!==z?(k=z?Zi(z):null,t[6]=z,t[7]=k):k=t[7];const P=k,[L,Q]=c.useState(""),te=Sa(L,200).trim();let ae;t[8]!==L?(ae=L.trim(),t[8]=L,t[9]=ae):ae=t[9];const X=ae;let Z,se;t[10]!==n?(Z=()=>{n&&Q("")},se=[n],t[10]=n,t[11]=Z,t[12]=se):(Z=t[11],se=t[12]),c.useEffect(Z,se);let me,_;t[13]!==S||t[14]!==O||t[15]!==B||t[16]!==n?(me=()=>{if(!n||!B)return;const Ze=setTimeout(()=>{const it=new Set;for(const gt of S){const xt=$s(gt);!xt||it.has(xt)||(it.add(xt),O(xt,B))}},0);return()=>clearTimeout(Ze)},_=[n,S,B,O],t[13]=S,t[14]=O,t[15]=B,t[16]=n,t[17]=me,t[18]=_):(me=t[17],_=t[18]),c.useEffect(me,_);let ne;t[19]!==r?(ne=()=>r(!1),t[19]=r,t[20]=ne):ne=t[20];const ye=ne;let ce;t[21]!==ye?(ce=Ze=>()=>{ye(),Ze()},t[21]=ye,t[22]=ce):ce=t[22];const F=ce;let re;t[23]!==I?.id||t[24]!==I?.path||t[25]!==D||t[26]!==m||t[27]!==T||t[28]!==u||t[29]!==d||t[30]!==p||t[31]!==v||t[32]!==F||t[33]!==g||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==b||t[39]!==a?(re=()=>{const Ze=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(R,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:F(()=>{l(!1),v()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(R,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:F(JS)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(R,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:F(ZS)},{id:"toggle-sidebar",title:e(T?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(R,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(T?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:F(()=>{if(T){const{isSessionSwitcherOpen:it}=Pe.getState();l(!it)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(R,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:F(()=>{D&&d(D,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(R,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:F(()=>{D&&u(D)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(R,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:F(ev)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(R,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:F(tv)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(R,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:F(()=>i(!0))}];return Ze.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(R,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:F(()=>{m&&D&&b({directory:D,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(R,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:F(()=>{m&&pn(m).then(it=>{if(it.ok){Me.success(e("sessions.sidebar.session.copyId.success"));return}Me.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Me.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(R,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:F(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(R,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:F(()=>{l(!1),g(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(R,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:F(()=>{D&&(w("notes"),d(D,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(R,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:F(()=>{D&&(w("todos"),d(D,"notes"))})}),Ze.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(R,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:F(sv)}),zo()&&Ze.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(R,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:F(()=>{Rn("desktop_open_draft_mini_chat_window",{directory:Zi(D||I?.path||""),projectId:I?.id??null}).catch(nv)})}),Ze},t[23]=I?.id,t[24]=I?.path,t[25]=D,t[26]=m,t[27]=T,t[28]=u,t[29]=d,t[30]=p,t[31]=v,t[32]=F,t[33]=g,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=b,t[39]=a,t[40]=re):re=t[40],I?.id,I?.path;let fe;t[41]!==re?(fe=re(),t[41]=re,t[42]=fe):fe=t[42];const de=fe;let ge;t[43]===Symbol.for("react.memo_cache_sentinel")?(ge=xn(),t[43]=ge):ge=t[43];const Te=ge;let be,Ee;t[44]===Symbol.for("react.memo_cache_sentinel")?(be=Pn(),Ee=!Te&&fa(),t[44]=be,t[45]=Ee):(be=t[44],Ee=t[45]);let we;t[46]!==T?(we={isVSCode:be,isWeb:Ee,isDesktop:Te,isMobile:T},t[46]=T,t[47]=we):we=t[47];const Y=we;let ve;if(t[48]!==F||t[49]!==i||t[50]!==o||t[51]!==Y){let Ze;t[53]!==Y?(Ze=gt=>gt.isAvailable?gt.isAvailable(Y):!0,t[53]=Y,t[54]=Ze):Ze=t[54];let it;t[55]!==F||t[56]!==i||t[57]!==o?(it=gt=>{const xt=rg(gt.slug)??"settings-3",Rt=(gt.keywords??[]).join(" ");return{id:`settings:${gt.slug}`,title:gt.title,icon:gt.slug==="mcp"?s.jsx(oh,{className:"mr-2 h-4 w-4"}):s.jsx(R,{name:xt,className:"mr-2 h-4 w-4"}),searchText:`${gt.title} ${gt.group} ${Rt}`,onSelect:F(()=>{o(gt.slug),i(!0)})}},t[55]=F,t[56]=i,t[57]=o,t[58]=it):it=t[58],ve=ng.filter(rv).filter(Ze).map(it),t[48]=F,t[49]=i,t[50]=o,t[51]=Y,t[52]=ve}else ve=t[52];const xe=ve;let je;if(t[59]!==S||t[60]!==C||t[61]!==A){const Ze=S.filter(ov);je=th(Ze,C,A),t[59]=S,t[60]=C,t[61]=A,t[62]=je}else je=t[62];const oe=je,J=Id(),K=Je(iv);let $;t[63]!==J||t[64]!==K?($=(Ze,it)=>{const gt=K.get(Ze);return gt?.branch?gt.branch.trim()||null:it&&J.get(it)?.trim()||null},t[63]=J,t[64]=K,t[65]=$):$=t[65];const le=$;let V;t[66]===Symbol.for("react.memo_cache_sentinel")?(V=[],t[66]=V):V=t[66];const[Ce,_e]=c.useState(V),[ke,Ne]=c.useState(""),Qe=CS(P,te);let We;t[67]!==P||t[68]!==Qe||t[69]!==n||t[70]!==E||t[71]!==_e||t[72]!==Ne||t[73]!==te?(We=()=>{if(!n){_e([]),Ne("");return}if(!Qe){_e([]),Ne("");return}if(!P){_e([]),Ne("");return}let Ze=!1;return E(P,te,40,{type:"file"}).then(it=>{Ze||(_e(it.map(av)),Ne(Qe))}).catch(()=>{Ze||(_e([]),Ne(Qe))}),()=>{Ze=!0}},t[67]=P,t[68]=Qe,t[69]=n,t[70]=E,t[71]=_e,t[72]=Ne,t[73]=te,t[74]=We):We=t[74];let U;t[75]!==P||t[76]!==Qe||t[77]!==n||t[78]!==E||t[79]!==te?(U=[n,P,te,Qe,E],t[75]=P,t[76]=Qe,t[77]=n,t[78]=E,t[79]=te,t[80]=U):U=t[80],c.useEffect(We,U);const he=X.length>0;let Re;e:{if(!he){let it;t[81]!==de?(it=de.filter(lv).map(cv),t[81]=de,t[82]=it):it=t[82],Re=it;break e}let Ze;t[83]!==de||t[84]!==X?(Ze=Er(de,X,dv,{limit:7,noFuzzy:!0}),t[83]=de,t[84]=X,t[85]=Ze):Ze=t[85],Re=Ze}const Ie=Re;let rt;e:{if(!he){let it;t[86]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[86]=it):it=t[86],rt=it;break e}let Ze;t[87]!==X||t[88]!==xe?(Ze=Er(xe,X,uv,{limit:7,noFuzzy:!0}),t[87]=X,t[88]=xe,t[89]=Ze):Ze=t[89],rt=Ze}const Ge=rt;let ut;e:{if(!he){let it;t[90]!==oe?(it=oe.slice(0,5).map(mv),t[90]=oe,t[91]=it):it=t[91],ut=it;break e}let Ze;t[92]!==X||t[93]!==oe?(Ze=Er(oe,X,fv,{limit:7,threshold:.2}),t[92]=X,t[93]=oe,t[94]=Ze):Ze=t[94],ut=Ze}const ct=ut;let ue;e:{if(!n){let it;t[95]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[95]=it):it=t[95],ue=it;break e}let Ze;t[96]!==Ce||t[97]!==ke||t[98]!==Qe||t[99]!==te?(Ze=NS(Ce,te,Qe,ke),t[96]=Ce,t[97]=ke,t[98]=Qe,t[99]=te,t[100]=Ze):Ze=t[100],ue=Ze}const G=ue,Le=n&&Qe.length>0&&ke!==Qe;let Oe;e:{if(!he){let it;t[101]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[101]=it):it=t[101],Oe=it;break e}let Ze;if(t[102]!==X||t[103]!==M){const it=M.map(hv);Ze=Er(it,X,pv,{limit:7,threshold:.4}),t[102]=X,t[103]=M,t[104]=Ze}else Ze=t[104];Oe=Ze}const qe=Oe;let Ue,st,wt,Nt,ie,pe,Ve,ze,He,ot,at,et,Xe,dt;if(t[105]!==le||t[106]!==ye||t[107]!==P||t[108]!==H||t[109]!==he||t[110]!==n||t[111]!==h||t[112]!==v||t[113]!==L||t[114]!==Ie||t[115]!==G||t[116]!==qe||t[117]!==ct||t[118]!==Ge||t[119]!==r||t[120]!==x||t[121]!==f||t[122]!==e){const Ze=Ie.map(gv),it=Ge.map(xv),gt=ct.map(bv),xt=he?G.map(yv):[],Rt=he?qe.map(wv):[];let kt;e:{if(!he){kt=["commands","sessions"];break e}const ft=Sv,lt=[{key:"commands",score:ft(Ie)},{key:"settings",score:ft(Ge)},{key:"sessions",score:ft(ct)},{key:"files",score:ft(G)},{key:"projects",score:ft(qe)}];lt.sort(vv),kt=lt.map(jv)}const Tt=kt,Ot=ft=>{ye(),x(ft.id,$s(ft))},Vt=async ft=>{if(!P)return;const lt=await Ou(H,ft,{directory:P});if(!lt.ok){Me.error(Bu(lt.reason));return}h(P,ft),ye()},Yt=(ft,lt)=>{ye(),v({selectedProjectId:ft,directoryOverride:lt})},Ht=ft=>qn(qr(ft,f));Nt=ws,et=n,Xe=r;let Lt;t[137]!==e?(Lt=e("commandPalette.title"),t[137]=e,t[138]=Lt):Lt=t[138];let zt;t[139]!==Lt?(zt=s.jsx(Is,{children:Lt}),t[139]=Lt,t[140]=zt):zt=t[140];let Fe;t[141]!==e?(Fe=e("commandPalette.description"),t[141]=e,t[142]=Fe):Fe=t[142];let Ye;t[143]!==Fe?(Ye=s.jsx(Ts,{children:Fe}),t[143]=Fe,t[144]=Ye):Ye=t[144],t[145]!==zt||t[146]!==Ye?(dt=s.jsxs(Ws,{className:"sr-only",children:[zt,Ye]}),t[145]=zt,t[146]=Ye,t[147]=dt):dt=t[147],wt=Ss,ot="overflow-hidden p-0",at=!0,st=ih,Ve=!1,ze="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let mt;t[148]!==e?(mt=e("commandPalette.input.placeholder"),t[148]=e,t[149]=mt):mt=t[149],t[150]!==L||t[151]!==mt?(He=s.jsx(ah,{value:L,onValueChange:Q,placeholder:mt}),t[150]=L,t[151]=mt,t[152]=He):He=t[152],Ue=lh;let bt;t[153]!==e?(bt=e("commandPalette.empty.noResults"),t[153]=e,t[154]=bt):bt=t[154],t[155]!==bt?(ie=s.jsx(ch,{children:bt}),t[155]=bt,t[156]=ie):ie=t[156],pe=Tt.map(ft=>ft==="commands"&&Ze.length>0?s.jsx(vr,{children:Ze.map(lt=>s.jsxs(Rr,{value:lt.id,onSelect:lt.onSelect,children:[lt.icon,s.jsx("span",{children:lt.title}),lt.shortcutId?s.jsx(sh,{children:Ht(lt.shortcutId)}):null]},lt.id))},"commands"):ft==="settings"&&it.length>0?s.jsx(vr,{children:it.map(kv)},"settings"):ft==="sessions"&>.length>0?s.jsx(vr,{children:gt.map(lt=>{const $t=lt.title||e("commandPalette.session.untitled"),Zt=$s(lt),Xt=le(lt.id,Zt);return s.jsxs(Rr,{value:`session:${lt.id}`,onSelect:()=>Ot(lt),children:[s.jsx(R,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:$t}),Xt?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(R,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:Xt})]}):null]},lt.id)})},"sessions"):ft==="files"&&xt.length>0?s.jsx(vr,{children:xt.map(lt=>{const $t=nh(lt.relativePath||lt.name,{maxLength:80});return s.jsxs(Rr,{value:`file:${lt.path}`,onSelect:()=>{Vt(lt.path)},children:[s.jsx(wa,{filePath:lt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":lt.relativePath,children:$t})]},`file:${lt.path}`)})},"files"):ft==="projects"&&Rt.length>0?s.jsx(vr,{children:Rt.map(lt=>{const $t=lt.displayName;return s.jsxs(Rr,{value:`project:${lt.id}`,onSelect:()=>Yt(lt.id,lt.path),children:[s.jsx(R,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:$t}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:lt.path})]},`project:${lt.id}`)})},"projects"):null),t[105]=le,t[106]=ye,t[107]=P,t[108]=H,t[109]=he,t[110]=n,t[111]=h,t[112]=v,t[113]=L,t[114]=Ie,t[115]=G,t[116]=qe,t[117]=ct,t[118]=Ge,t[119]=r,t[120]=x,t[121]=f,t[122]=e,t[123]=Ue,t[124]=st,t[125]=wt,t[126]=Nt,t[127]=ie,t[128]=pe,t[129]=Ve,t[130]=ze,t[131]=He,t[132]=ot,t[133]=at,t[134]=et,t[135]=Xe,t[136]=dt}else Ue=t[123],st=t[124],wt=t[125],Nt=t[126],ie=t[127],pe=t[128],Ve=t[129],ze=t[130],He=t[131],ot=t[132],at=t[133],et=t[134],Xe=t[135],dt=t[136];let Be;t[157]!==Le||t[158]!==e?(Be=Le?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=Le,t[158]=e,t[159]=Be):Be=t[159];let Se;t[160]!==Ue||t[161]!==ie||t[162]!==pe||t[163]!==Be?(Se=s.jsxs(Ue,{children:[ie,pe,Be]}),t[160]=Ue,t[161]=ie,t[162]=pe,t[163]=Be,t[164]=Se):Se=t[164];let St;t[165]!==st||t[166]!==Ve||t[167]!==ze||t[168]!==He||t[169]!==Se?(St=s.jsxs(st,{shouldFilter:Ve,className:ze,children:[He,Se]}),t[165]=st,t[166]=Ve,t[167]=ze,t[168]=He,t[169]=Se,t[170]=St):St=t[170];let vt;t[171]!==wt||t[172]!==ot||t[173]!==at||t[174]!==St?(vt=s.jsx(wt,{className:ot,showCloseButton:at,children:St}),t[171]=wt,t[172]=ot,t[173]=at,t[174]=St,t[175]=vt):vt=t[175];let Et;return t[176]!==Nt||t[177]!==et||t[178]!==Xe||t[179]!==dt||t[180]!==vt?(Et=s.jsxs(Nt,{open:et,onOpenChange:Xe,children:[dt,vt]}),t[176]=Nt,t[177]=et,t[178]=Xe,t[179]=dt,t[180]=vt,t[181]=Et):Et=t[181],Et};function IS(t){return t.isCommandPaletteOpen}function TS(t){return t.setCommandPaletteOpen}function ES(t){return t.setSettingsDialogOpen}function RS(t){return t.setSettingsPage}function MS(t){return t.setSessionSwitcherOpen}function OS(t){return t.toggleSidebar}function BS(t){return t.openContextOverview}function FS(t){return t.openContextSurface}function _S(t){return t.openContextFile}function LS(t){return t.shortcutOverrides}function $S(t){return t.openMultiRunLauncher}function WS(t){return t.setArchivePageOpen}function zS(t){return t.setProjectContextTab}function VS(t){return t.openNewSessionDraft}function US(t){return t.setCurrentSession}function KS(t){return t.currentSessionId}function HS(t){return t.toggle}function GS(t){return t.currentDirectory}function qS(t){return t.getActiveProject()}function QS(t){return t.projects}function YS(t){return t.searchFiles}function XS(t){return t.ensureStatus}function JS(){Ed()}function ZS(){gn.requestDirectoryDialog()}function ev(){dh.invoke("cycle_theme")}function tv(){Rd()}function sv(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function nv(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function rv(t){return t.slug!=="home"}function ov(t){return!rh(t)}function iv(t){return t.worktreeMetadata}function av(t){return{path:Zi(t.path),name:t.name,relativePath:t.relativePath}}function lv(t){return!t.secondary}function cv(t){return{item:t,score:0}}function dv(t){return t.searchText}function uv(t){return t.searchText}function mv(t){return{item:t,score:0}}function fv(t){return t.title||""}function hv(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function pv(t){return t.searchText}function gv(t){return t.item}function xv(t){return t.item}function bv(t){return t.item}function yv(t){return t.item}function wv(t){return t.item}function Sv(t){return t.length?t[0].score:1/0}function vv(t,e){return t.score-e.score}function jv(t){return t.key}function kv(t){return s.jsxs(Rr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const ac=(t,e,n)=>qn(qr(t,e),n),Cv=()=>{const t=tt.c(74),{t:e}=At(),n=Pe(Nv),r=Pe(Av),i=Pe(Pv);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=Pn(),t[0]=o):o=t[0];const l=o;let a,u,d,h,f,p,g,w,v,x,m,b;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const k=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[qn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${qn(Ci("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${qn(Ci("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];d=ws,m=n,b=r,u=Ss,v="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let P;t[17]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(R,{name:"command",className:"h-5 w-5"}),t[17]=P):P=t[17];let L;t[18]!==e?(L=e("helpDialog.title"),t[18]=e,t[19]=L):L=t[19];let Q;t[20]!==L?(Q=s.jsxs(Is,{className:"flex items-center gap-2",children:[P,L]}),t[20]=L,t[21]=Q):Q=t[21];let q;t[22]!==e?(q=e("helpDialog.description"),t[22]=e,t[23]=q):q=t[23];let te;t[24]!==q?(te=s.jsx(Ts,{children:q}),t[24]=q,t[25]=te):te=t[25],t[26]!==Q||t[27]!==te?(x=s.jsxs(Ws,{children:[Q,te]}),t[26]=Q,t[27]=te,t[28]=x):x=t[28],a=ln,p="flex-1 min-h-0 mt-3",g="pr-1",w=!0,h="space-y-4",f=k.map(ae=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ae.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ae.items.filter(X=>!(l&&X.id==="toggle_prompt_navigator")).map(X=>{const Z=X.id?uh(X.id):void 0,se=X.descriptionKey??(Z?.customizable?Z.settingsLabelKey:void 0);if(!se||X.id&&!qr(X.id,i))return null;const me=X.id?ac(X.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(X.keys)?X.keys:X.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[X.icon&&s.jsx(R,{name:X.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(se)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(me)?me:[me]).map((_,ne)=>s.jsxs(c.Fragment,{children:[ne>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:_})]},`${_}-${ne}`))})]},X.id||se)})})]},ae.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=u,t[7]=d,t[8]=h,t[9]=f,t[10]=p,t[11]=g,t[12]=w,t[13]=v,t[14]=x,t[15]=m,t[16]=b}else a=t[5],u=t[6],d=t[7],h=t[8],f=t[9],p=t[10],g=t[11],w=t[12],v=t[13],x=t[14],m=t[15],b=t[16];let y;t[29]!==h||t[30]!==f?(y=s.jsx("div",{className:h,children:f}),t[29]=h,t[30]=f,t[31]=y):y=t[31];let S;t[32]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(R,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=S):S=t[32];let N;t[33]!==e?(N=e("helpDialog.proTips.title"),t[33]=e,t[34]=N):N=t[34];let C;t[35]!==N?(C=s.jsx("p",{className:"font-medium mb-1",children:N}),t[35]=N,t[36]=C):C=t[36];let j;t[37]!==i||t[38]!==e?(j=e("helpDialog.proTips.commandPalette",{shortcut:ac("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=j):j=t[39];let A;t[40]!==j?(A=s.jsxs("li",{children:["• ",j]}),t[40]=j,t[41]=A):A=t[41];let D;t[42]!==e?(D=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=D):D=t[43];let I;t[44]!==D?(I=s.jsxs("li",{children:["• ",D]}),t[44]=D,t[45]=I):I=t[45];let M;t[46]!==e?(M=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=M):M=t[47];let z;t[48]!==M?(z=s.jsxs("li",{children:["• ",M]}),t[48]=M,t[49]=z):z=t[49];let E;t[50]!==A||t[51]!==I||t[52]!==z?(E=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[A,I,z]}),t[50]=A,t[51]=I,t[52]=z,t[53]=E):E=t[53];let H;t[54]!==C||t[55]!==E?(H=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[S,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,E]})]})}),t[54]=C,t[55]=E,t[56]=H):H=t[56];let B;t[57]!==a||t[58]!==y||t[59]!==H||t[60]!==p||t[61]!==g||t[62]!==w?(B=s.jsxs(a,{outerClassName:p,className:g,disableHorizontal:w,children:[y,H]}),t[57]=a,t[58]=y,t[59]=H,t[60]=p,t[61]=g,t[62]=w,t[63]=B):B=t[63];let O;t[64]!==u||t[65]!==B||t[66]!==v||t[67]!==x?(O=s.jsxs(u,{className:v,children:[x,B]}),t[64]=u,t[65]=B,t[66]=v,t[67]=x,t[68]=O):O=t[68];let T;return t[69]!==d||t[70]!==O||t[71]!==m||t[72]!==b?(T=s.jsx(d,{open:m,onOpenChange:b,children:O}),t[69]=d,t[70]=O,t[71]=m,t[72]=b,t[73]=T):T=t[73],T};function Nv(t){return t.isHelpDialogOpen}function Av(t){return t.setHelpDialogOpen}function Pv(t){return t.shortcutOverrides}const Dv=()=>{const t=tt.c(32),{t:e}=At(),n=Pe(Iv),r=Pe(Tv),i=Pe(Ev);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await pn(i)).ok){Me.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Me.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let u;t[5]!==a?(u=s.jsx(Is,{children:a}),t[5]=a,t[6]=u):u=t[6];let d;t[7]!==e?(d=e("openCodeStatusDialog.description"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==d?(h=s.jsx(Ts,{children:d}),t[9]=d,t[10]=h):h=t[10];let f;t[11]!==u||t[12]!==h?(f=s.jsxs(Ws,{children:[u,h]}),t[11]=u,t[12]=h,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let g;t[16]!==l||t[17]!==p?(g=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:p})}),t[16]=l,t[17]=p,t[18]=g):g=t[18];let w;t[19]!==i||t[20]!==e?(w=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:w}),t[22]=w,t[23]=v):v=t[23];let x;t[24]!==f||t[25]!==g||t[26]!==v?(x=s.jsxs(Ss,{className:"max-w-2xl",children:[f,g,v]}),t[24]=f,t[25]=g,t[26]=v,t[27]=x):x=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==x?(m=s.jsx(ws,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=m):m=t[31],m};function Iv(t){return t.isOpenCodeStatusDialogOpen}function Tv(t){return t.setOpenCodeStatusDialogOpen}function Ev(t){return t.openCodeStatusText}const Rv=t=>{const e=tt.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let u,d;e[0]!==a||e[1]!==r||e[2]!==o?(u=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},d=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=u,e[4]=d):(u=e[3],d=e[4]),c.useEffect(u,d);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",w),()=>window.removeEventListener("openchamber:sidebar-session-search",w)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=f):(h=e[8],f=e[9]),c.useEffect(h,f);let p,g;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const w=v=>{l.current&&(l.current.contains(v.target)||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},g=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=g):(p=e[14],g=e[15]),c.useEffect(p,g)},Mv=t=>{const e=tt.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const u=new Map(l.map(Ov)),d=[];a.forEach(p=>{const g=u.get(p);g&&(d.push(g),u.delete(p))});const h=[],f=[];return l.forEach(p=>{u.has(p.id)&&(p.isArchivedBucket?f.push(p):h.push(p))}),[...h,...d,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function Ov(t){return[t.id,t]}const ao="oc.sessions.projectCollapse",lc="oc.sessions.groupOrder",cc="oc.sessions.groupCollapse",dc=t=>{if(!t)return new Set;try{const e=Ta(xr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},Bv=t=>{if(!t)return new Map;try{const e=hu(xr(),Ta(xr())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},Fv=t=>{const e=tt.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=No(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>dc(o.getItem(ao)),e[1]=l):l=e[1];const[a,u]=c.useState(l);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>dc(o.getItem(cc)),e[2]=d):d=e[2];const[h,f]=c.useState(d);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>Bv(o.getItem(lc)),e[3]=p):p=e[3];const[g,w]=c.useState(p),v=c.useRef(0),x=c.useRef(!1),m=c.useRef(!1),b=c.useRef(null),y=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const ne=y.current;if(y.current=null,b.current=null,!ne)return;const{projects:ye}=Kt.getState(),ce=ye.map(F=>({...F,sidebarCollapsed:ne.has(F.id)}));Tr({projects:ce}).catch(_v)},e[4]=n,e[5]=S):S=e[5];const N=S;let C;e[6]!==N||e[7]!==n?(C=ne=>{!globalThis.window||n||(y.current=ne,b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=C):C=e[8];const j=C;let A,D;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>()=>{globalThis.window&&b.current!==null&&window.clearTimeout(b.current),b.current=null,y.current=null},D=[],e[9]=A,e[10]=D):(A=e[9],D=e[10]),c.useEffect(A,D);let I,M;e[11]!==g?(M=()=>{if(m.current)try{o.setItem(lc,JSON.stringify(Object.fromEntries(g.entries())))}catch{}},I=[g,o],e[11]=g,e[12]=I,e[13]=M):(I=e[12],M=e[13]),c.useEffect(M,I);let z,E;e[14]!==h?(z=()=>{if(x.current)try{o.setItem(cc,JSON.stringify(Array.from(h)))}catch{}},E=[h,o],e[14]=h,e[15]=z,e[16]=E):(z=e[15],E=e[16]),c.useEffect(z,E);let H;e[17]!==r||e[18]!==j?(H=()=>{v.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const ne=new Set(r.map(Lv));try{o.setItem(ao,JSON.stringify(Array.from(ne)))}catch{}return j(ne),ne})},e[17]=r,e[18]=j,e[19]=H):H=e[19];const B=H;let O;e[20]!==j?(O=()=>{v.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const ne=new Set;try{o.setItem(ao,JSON.stringify([]))}catch{}return j(ne),ne})},e[20]=j,e[21]=O):O=e[21];const T=O;let k;e[22]!==j?(k=ne=>{v.current=Date.now()+150,u(ye=>{const ce=new Set(ye);ce.has(ne)?ce.delete(ne):ce.add(ne);try{o.setItem(ao,JSON.stringify(Array.from(ce)))}catch{}return j(ce),ce})},e[22]=j,e[23]=k):k=e[23];const P=k;let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=ne=>{x.current=!0,f(ye=>{const ce=new Set(ye);return ce.has(ne)?ce.delete(ne):ce.add(ne),ce})},e[24]=L):L=e[24];const Q=L;let q;e[25]===Symbol.for("react.memo_cache_sentinel")?(q=ne=>{m.current=!0,w(ne)},e[25]=q):q=e[25];const te=q,{getOrderedGroups:ae}=Mv(g);let X;e[26]!==h||e[27]!==a||e[28]!==g?(X={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:g},e[26]=h,e[27]=a,e[28]=g,e[29]=X):X=e[29];const Z=X;let se;e[30]!==B||e[31]!==T||e[32]!==ae||e[33]!==j||e[34]!==P?(se={setCollapsedProjects:u,toggleProject:P,collapseAllProjects:B,expandAllProjects:T,scheduleCollapsedProjectsPersist:j,setCollapsedGroups:f,toggleGroup:Q,setGroupOrderByProject:te,getOrderedGroups:ae},e[30]=B,e[31]=T,e[32]=ae,e[33]=j,e[34]=P,e[35]=se):se=e[35];const me=se;let _;return e[36]!==me||e[37]!==Z?(_={state:Z,actions:me},e[36]=me,e[37]=Z,e[38]=_):_=e[38],_};function _v(){}function Lv(t){return t.id}const $v=5*6e4,Wv=t=>{const e=tt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:u}=wn(),d=On(zv);let h,f;e[0]!==a||e[1]!==d||e[2]!==u||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!u||n.length===0){o(new Map);return}n.forEach(C=>{Ni(()=>d(C.normalizedPath,u))})},f=[a,n,u,d,o],e[0]=a,e[1]=d,e[2]=u,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let p,g;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(j=>{C.set(j.id,i.get(j.normalizedPath)?.isGitRepo??null)}),o(C)},g=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=g):(p=e[11],g=e[12]),c.useEffect(p,g);let w;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=j=>{const A=i.get(j.normalizedPath)?.branch??"";return`${j.id}:${A}`},e[16]=i,e[17]=C):C=e[17],w=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const v=w;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[18]=x):x=e[18];const m=c.useRef(x);let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=new Map,e[19]=b):b=e[19];const y=c.useRef(b);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let C=!1;const j=setTimeout(()=>{(async()=>{const D=new Set(n.map(Vv));for(const B of m.current.keys())D.has(B)||(m.current.delete(B),y.current.delete(B));const I=Date.now(),M=n.filter(B=>{const O=i.get(B.normalizedPath);if(O?.isGitRepo===!1)return m.current.delete(B.id),y.current.delete(B.id),!1;if(O?.isGitRepo!==!0||O.branch===null)return!1;const T=O.branch.trim(),k=`${B.normalizedPath}\0${T}`,P=m.current.get(B.id);if(P===k){const L=y.current.get(B.id);return L&&(L.at=I),!1}return!(P!==void 0&&I-(y.current.get(B.id)?.at??0)<$v)});if(M.length===0)return;const z=await mh(M,2,async B=>{const O=i.get(B.normalizedPath)?.branch?.trim()??"",T=`${B.normalizedPath}\0${O}`,k=await Ni(()=>Go(B.normalizedPath,O?{knownBranch:O}:void 0)).catch(Uv);return{id:B.id,inputKey:T,branch:k}});if(C)return;const E=z.filter(Kv);if(E.length===0)return;const H=Date.now();l(B=>{const O=new Map(B);return E.forEach(T=>{const{id:k,branch:P}=T;P&&O.set(k,P)}),O}),E.forEach(B=>{const{id:O,inputKey:T,branch:k}=B;m.current.set(O,T),k&&y.current.set(O,{branch:k,at:H})})})()},150);return()=>{C=!0,clearTimeout(j)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==v||e[29]!==l?(N=[a,n,v,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=v,e[29]=l,e[30]=N):N=e[30],c.useEffect(S,N)};function zv(t){return t.ensureStatus}function Vv(t){return t.id}function Uv(){return null}function Kv(t){return t.branch}const Hv=t=>{const e=tt.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(og,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(Ss,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(ln,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-background",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==a?(u=s.jsx(ws,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=u):u=e[9],u},Gv=(t,e)=>{if(!e)return Array.from(t);const n=[],r=new Set;for(const i of t){r.has(i)||(r.add(i),n.push(i));const o=e.get(i);if(o)for(const l of o)r.has(l)||(r.add(l),n.push(l))}return n},hs=er()((t,e)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{e().enabled||t({enabled:!0})},disable:()=>{t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{e().enabled?t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):t({enabled:!0})},toggleSelected:(n,r,i)=>{const o=e(),l=new Set(o.selectedIds);let a=o.scopeKey,u=o.anchorId;r!==null&&o.scopeKey!==null&&r!==o.scopeKey?(l.clear(),a=r,u=null):a===null&&r!==null&&(a=r);const h=i&&i.length>0?[n,...i]:[n];if(l.has(n)){for(const p of h)l.delete(p);u===n&&(u=null)}else{for(const p of h)l.add(p);u=n}l.size===0?t({selectedIds:l,scopeKey:null,anchorId:null}):t({selectedIds:l,scopeKey:a,anchorId:u})},setRange:(n,r,i,o,l)=>{const a=e();if(i.length===0)return;const u=n&&i.includes(n)?n:i[0],d=i.indexOf(u),h=i.indexOf(r);if(d<0||h<0)return;const[f,p]=d<=h?[d,h]:[h,d],g=i.slice(f,p+1),w=Gv(g,l),x=o!==null&&a.scopeKey!==null&&o!==a.scopeKey?new Set:new Set(a.selectedIds);for(const m of w)x.add(m);t({selectedIds:x,scopeKey:o??a.scopeKey,anchorId:u})},replaceAll:(n,r)=>{if(n.length===0){t({selectedIds:new Set,scopeKey:null,anchorId:null});return}t({selectedIds:new Set(n),scopeKey:r,anchorId:n[0]??null})},clear:()=>{t({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{const r=e();if(r.selectedIds.size===0||n.length===0)return;const i=new Set(r.selectedIds);for(const o of n)i.delete(o);i.size!==r.selectedIds.size&&(i.size===0?t({selectedIds:i,scopeKey:null,anchorId:null}):t({selectedIds:i}))}}));function qv(t){const e=tt.c(213),{t:n}=At(),{hideDirectoryControls:r,showProjectDisplayControls:i,showRecentControls:o,handleOpenDirectoryDialog:l,onOpenScheduled:a,onOpenMultiRun:u,canOpenMultiRun:d,onOpenArchive:h,headerActionIconClass:f,headerActionButtonClass:p,isSessionSearchOpen:g,setIsSessionSearchOpen:w,sessionSearchInputRef:v,sessionSearchQuery:x,setSessionSearchQuery:m,hasSessionSearchQuery:b,searchMatchCount:y,collapseAllProjects:S,expandAllProjects:N}=t,C=hs(a0),j=hs(i0),A=ls(o0),D=ls(r0),I=ls(n0),M=ls(s0),z=ls(t0),E=ls(e0),H=ls(Zv),B=ls(Jv),O=ls(Xv),T=ls(Yv),k=i&&O==="single";if(r)return null;let P;e[0]!==p?(P=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=p,e[1]=P):P=e[1];let L;e[2]!==n?(L=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=L):L=e[3];let Q;e[4]!==f?(Q=s.jsx(R,{name:"folder-add",className:f}),e[4]=f,e[5]=Q):Q=e[5];let q;e[6]!==l||e[7]!==P||e[8]!==L||e[9]!==Q?(q=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,className:P,"aria-label":L,children:Q})}),e[6]=l,e[7]=P,e[8]=L,e[9]=Q,e[10]=q):q=e[10];let te;e[11]!==n?(te=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=te):te=e[12];let ae;e[13]!==te?(ae=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:te})}),e[13]=te,e[14]=ae):ae=e[14];let X;e[15]!==q||e[16]!==ae?(X=s.jsxs(Pt,{children:[q,ae]}),e[15]=q,e[16]=ae,e[17]=X):X=e[17];let Z;e[18]!==p?(Z=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=p,e[19]=Z):Z=e[19];let se;e[20]!==n?(se=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=se):se=e[21];let me;e[22]!==f?(me=s.jsx(R,{name:"calendar-schedule",className:f}),e[22]=f,e[23]=me):me=e[23];let _;e[24]!==a||e[25]!==Z||e[26]!==se||e[27]!==me?(_=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:Z,"aria-label":se,children:me})}),e[24]=a,e[25]=Z,e[26]=se,e[27]=me,e[28]=_):_=e[28];let ne;e[29]!==n?(ne=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=ne):ne=e[30];let ye;e[31]!==ne?(ye=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[31]=ne,e[32]=ye):ye=e[32];let ce;e[33]!==_||e[34]!==ye?(ce=s.jsxs(Pt,{children:[_,ye]}),e[33]=_,e[34]=ye,e[35]=ce):ce=e[35];let F;e[36]!==p?(F=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=p,e[37]=F):F=e[37];let re;e[38]!==n?(re=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=re):re=e[39];const fe=!d;let de;e[40]!==f?(de=s.jsx(fh,{className:f}),e[40]=f,e[41]=de):de=e[41];let ge;e[42]!==u||e[43]!==F||e[44]!==re||e[45]!==fe||e[46]!==de?(ge=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:F,"aria-label":re,disabled:fe,children:de})}),e[42]=u,e[43]=F,e[44]=re,e[45]=fe,e[46]=de,e[47]=ge):ge=e[47];let Te;e[48]!==n?(Te=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Te):Te=e[49];let be;e[50]!==Te?(be=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Te})}),e[50]=Te,e[51]=be):be=e[51];let Ee;e[52]!==ge||e[53]!==be?(Ee=s.jsxs(Pt,{children:[ge,be]}),e[52]=ge,e[53]=be,e[54]=Ee):Ee=e[54];let we;e[55]!==p?(we=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=p,e[56]=we):we=e[56];let Y;e[57]!==n?(Y=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=Y):Y=e[58];let ve;e[59]!==f?(ve=s.jsx(R,{name:"archive",className:f}),e[59]=f,e[60]=ve):ve=e[60];let xe;e[61]!==h||e[62]!==we||e[63]!==Y||e[64]!==ve?(xe=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:we,"aria-label":Y,children:ve})}),e[61]=h,e[62]=we,e[63]=Y,e[64]=ve,e[65]=xe):xe=e[65];let je;e[66]!==n?(je=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=je):je=e[67];let oe;e[68]!==je?(oe=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:je})}),e[68]=je,e[69]=oe):oe=e[69];let J;e[70]!==xe||e[71]!==oe?(J=s.jsxs(Pt,{children:[xe,oe]}),e[70]=xe,e[71]=oe,e[72]=J):J=e[72];let K;e[73]!==ce||e[74]!==Ee||e[75]!==J||e[76]!==X?(K=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[X,ce,Ee,J]}),e[73]=ce,e[74]=Ee,e[75]=J,e[76]=X,e[77]=K):K=e[77];let $;e[78]!==w?($=()=>w(Qv),e[78]=w,e[79]=$):$=e[79];let le;e[80]!==p?(le=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=p,e[81]=le):le=e[81];let V;e[82]!==n?(V=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=V):V=e[83];let Ce;e[84]!==f?(Ce=s.jsx(R,{name:"search",className:f}),e[84]=f,e[85]=Ce):Ce=e[85];let _e;e[86]!==g||e[87]!==$||e[88]!==le||e[89]!==V||e[90]!==Ce?(_e=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:$,className:le,"aria-label":V,"aria-expanded":g,children:Ce})}),e[86]=g,e[87]=$,e[88]=le,e[89]=V,e[90]=Ce,e[91]=_e):_e=e[91];let ke;e[92]!==n?(ke=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=ke):ke=e[93];let Ne;e[94]!==ke?(Ne=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ke})}),e[94]=ke,e[95]=Ne):Ne=e[95];let Qe;e[96]!==_e||e[97]!==Ne?(Qe=s.jsxs(Pt,{children:[_e,Ne]}),e[96]=_e,e[97]=Ne,e[98]=Qe):Qe=e[98];const We=C&&"bg-interactive-hover text-primary";let U;e[99]!==p||e[100]!==We?(U=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent",We),e[99]=p,e[100]=We,e[101]=U):U=e[101];let he;e[102]!==C||e[103]!==n?(he=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=C,e[103]=n,e[104]=he):he=e[104];let Re;e[105]!==f?(Re=s.jsx(R,{name:"checkbox-multiple",className:f}),e[105]=f,e[106]=Re):Re=e[106];let Ie;e[107]!==C||e[108]!==U||e[109]!==he||e[110]!==Re||e[111]!==j?(Ie=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:j,className:U,"aria-label":he,"aria-pressed":C,children:Re})}),e[107]=C,e[108]=U,e[109]=he,e[110]=Re,e[111]=j,e[112]=Ie):Ie=e[112];let rt;e[113]!==C||e[114]!==n?(rt=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=C,e[114]=n,e[115]=rt):rt=e[115];let Ge;e[116]!==rt?(Ge=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:rt})}),e[116]=rt,e[117]=Ge):Ge=e[117];let ut;e[118]!==Ie||e[119]!==Ge?(ut=s.jsxs(Pt,{children:[Ie,Ge]}),e[118]=Ie,e[119]=Ge,e[120]=ut):ut=e[120];let ct;e[121]!==p?(ct=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=p,e[122]=ct):ct=e[122];let ue;e[123]!==n?(ue=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=ue):ue=e[124];let G;e[125]!==f?(G=s.jsx(R,{name:"equalizer-2",className:f}),e[125]=f,e[126]=G):G=e[126];let Le;e[127]!==ct||e[128]!==ue||e[129]!==G?(Le=s.jsx(Dt,{asChild:!0,children:s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:ct,"aria-label":ue,children:G})})}),e[127]=ct,e[128]=ue,e[129]=G,e[130]=Le):Le=e[130];let Oe;e[131]!==n?(Oe=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=Oe):Oe=e[132];let qe;e[133]!==Oe?(qe=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[133]=Oe,e[134]=qe):qe=e[134];let Ue;e[135]!==Le||e[136]!==qe?(Ue=s.jsxs(Pt,{children:[Le,qe]}),e[135]=Le,e[136]=qe,e[137]=Ue):Ue=e[137];let st;e[138]!==n?(st=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=st):st=e[139];let wt;e[140]!==st?(wt=s.jsx(ho,{children:st}),e[140]=st,e[141]=wt):wt=e[141];let Nt;e[142]!==I||e[143]!==M||e[144]!==n?(Nt=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(xt=>{const[Rt,kt]=xt;return s.jsxs(Ut,{onClick:()=>{M(Rt),Tr({sidebarProjectSortOrder:Rt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),I===Rt?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},Rt)}),e[142]=I,e[143]=M,e[144]=n,e[145]=Nt):Nt=e[145];let ie;e[146]===Symbol.for("react.memo_cache_sentinel")?(ie=s.jsx(Os,{}),e[146]=ie):ie=e[146];let pe;e[147]!==O||e[148]!==T||e[149]!==i||e[150]!==n?(pe=i?s.jsxs(s.Fragment,{children:[s.jsx(ho,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(xt=>{const[Rt,kt]=xt;return s.jsxs(Ut,{onClick:()=>{T(Rt),Tr({sidebarProjectDisplayMode:Rt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),O===Rt?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},Rt)}),s.jsx(Os,{})]}):null,e[147]=O,e[148]=T,e[149]=i,e[150]=n,e[151]=pe):pe=e[151];let Ve;e[152]!==n?(Ve=n("sessions.sidebar.header.grouping.label"),e[152]=n,e[153]=Ve):Ve=e[153];let ze;e[154]!==Ve?(ze=s.jsx(ho,{children:Ve}),e[154]=Ve,e[155]=ze):ze=e[155];let He;e[156]!==z||e[157]!==E||e[158]!==n?(He=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(xt=>{const[Rt,kt]=xt;return s.jsxs(Ut,{onClick:()=>{E(Rt),Tr({sidebarSessionGroupingMode:Rt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),z===Rt?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},Rt)}),e[156]=z,e[157]=E,e[158]=n,e[159]=He):He=e[159];let ot;e[160]===Symbol.for("react.memo_cache_sentinel")?(ot=s.jsx(Os,{}),e[160]=ot):ot=e[160];let at;e[161]!==k||e[162]!==o||e[163]!==A||e[164]!==n||e[165]!==D?(at=o&&!k?s.jsxs(Ut,{onClick:()=>{D(),Tr({sidebarShowRecentSection:!A})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),A?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[161]=k,e[162]=o,e[163]=A,e[164]=n,e[165]=D,e[166]=at):at=e[166];let et;e[167]!==n?(et=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[167]=n,e[168]=et):et=e[168];let Xe;e[169]!==et?(Xe=s.jsx("span",{children:et}),e[169]=et,e[170]=Xe):Xe=e[170];let dt;e[171]!==H?(dt=H?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null,e[171]=H,e[172]=dt):dt=e[172];let Be;e[173]!==Xe||e[174]!==dt||e[175]!==B?(Be=s.jsxs(Ut,{onClick:B,className:"flex items-center justify-between",children:[Xe,dt]}),e[173]=Xe,e[174]=dt,e[175]=B,e[176]=Be):Be=e[176];let Se;e[177]!==S||e[178]!==N||e[179]!==k||e[180]!==n?(Se=k?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Ut,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(R,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Ut,{onClick:N,className:"flex items-center gap-2",children:[s.jsx(R,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[177]=S,e[178]=N,e[179]=k,e[180]=n,e[181]=Se):Se=e[181];let St;e[182]!==wt||e[183]!==Nt||e[184]!==pe||e[185]!==ze||e[186]!==He||e[187]!==at||e[188]!==Be||e[189]!==Se?(St=s.jsxs(Ys,{align:"end",className:"min-w-[180px]",children:[wt,Nt,ie,pe,ze,He,ot,at,Be,Se]}),e[182]=wt,e[183]=Nt,e[184]=pe,e[185]=ze,e[186]=He,e[187]=at,e[188]=Be,e[189]=Se,e[190]=St):St=e[190];let vt;e[191]!==Ue||e[192]!==St?(vt=s.jsxs(Xs,{children:[Ue,St]}),e[191]=Ue,e[192]=St,e[193]=vt):vt=e[193];let Et;e[194]!==Qe||e[195]!==ut||e[196]!==vt?(Et=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Qe,ut,vt]}),e[194]=Qe,e[195]=ut,e[196]=vt,e[197]=Et):Et=e[197];let Ze;e[198]!==K||e[199]!==Et?(Ze=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[K,Et]}),e[198]=K,e[199]=Et,e[200]=Ze):Ze=e[200];let it;e[201]!==b||e[202]!==g||e[203]!==y||e[204]!==v||e[205]!==x||e[206]!==w||e[207]!==m||e[208]!==n?(it=g?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[b?s.jsx("span",{children:y===1?n("sessions.sidebar.header.search.matchCountSingle",{count:y}):n("sessions.sidebar.header.search.matchCountPlural",{count:y})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsxs("div",{className:"relative",children:[s.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:v,value:x,onChange:xt=>m(xt.target.value),placeholder:n("sessions.sidebar.header.search.placeholder"),className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50",onKeyDown:xt=>{xt.key==="Escape"&&(xt.stopPropagation(),b?m(""):w(!1))}}),x.length>0?s.jsx("button",{type:"button",onClick:()=>m(""),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":n("sessions.sidebar.header.search.clear"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[201]=b,e[202]=g,e[203]=y,e[204]=v,e[205]=x,e[206]=w,e[207]=m,e[208]=n,e[209]=it):it=e[209];let gt;return e[210]!==Ze||e[211]!==it?(gt=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Ze,it]})}),e[210]=Ze,e[211]=it,e[212]=gt):gt=e[212],gt}function Qv(t){return!t}function Yv(t){return t.setProjectDisplayMode}function Xv(t){return t.projectDisplayMode}function Jv(t){return t.toggleStickyZoneHeaders}function Zv(t){return t.stickyZoneHeaders}function e0(t){return t.setSessionGroupingMode}function t0(t){return t.sessionGroupingMode}function s0(t){return t.setProjectSortOrder}function n0(t){return t.projectSortOrder}function r0(t){return t.toggleRecentSection}function o0(t){return t.showRecentSection}function i0(t){return t.toggleMode}function a0(t){return t.enabled}function l0(t){const e=tt.c(8),{t:n}=At(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(R,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const fi="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50";function c0(t){const e=tt.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,u=l===void 0?!0:l,d=a===void 0?!0:a,{t:h}=At();if(!u&&!d)return null;let f;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==u||e[4]!==h?(f=u?s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:fi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(R,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:fi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(R,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:fi,"aria-label":h("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(R,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=h,e[5]=f):f=e[5];let p;e[6]!==o||e[7]!==d||e[8]!==h?(p=d?s.jsx(pt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:o,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=d,e[8]=h,e[9]=p):p=e[9];let g;return e[10]!==f||e[11]!==p?(g=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,p]}),e[10]=f,e[11]=p,e[12]=g):g=e[12],g}const d0=t=>{for(const e of t.sessions.values())if(e.tabs.some(dd))return!0;return!1},u0=()=>{const t=tt.c(4),{terminal:e}=wn(),n=Mt(d0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=m0,l=f0;if(n)return Ti(e,"",l,o);let a=h0;return a=Ti(e,"",l,u=>{o(u),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function m0(t){const e=Mt.getState(),n=ig(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function f0(){return new Map(Mt.getState().actionMutationRevisions)}function h0(){}const p0=t=>{const e=tt.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:u,foldersMap:d,createFolder:h,addSessionToFolder:f}=t,p=r===void 0?!0:r;let g,w;e[0]!==f||e[1]!==h||e[2]!==p||e[3]!==d||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==u?(g=()=>{!p||o||!l||a||n.forEach(v=>{if(u.has(v.normalizedPath))return;const x=Md(v.normalizedPath),m=i.archivedSessionsByProject.get(v.id)??[],b=d[x]??[],y=new Map(b.map(g0));m.forEach(S=>{const N=hh(S,v.normalizedPath),C=N.toLowerCase();let j=y.get(C);j||(j=h(x,N),y.set(C,j)),j.sessionIds.includes(S.id)||f(x,j.id,S.id)})})},w=[n,p,i,o,l,a,u,d,h,f],e[0]=f,e[1]=h,e[2]=p,e[3]=d,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=u,e[10]=g,e[11]=w):(g=e[10],w=e[11]),c.useEffect(g,w)};function g0(t){return[t.name.toLowerCase(),t]}function x0({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const d=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!d)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const u=(o&&r.has(o)?o:null)??l;return!u||u===e?{kind:"none"}:{kind:"select-session",sessionId:u}}const b0=t=>{const e=tt.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:u,newSessionDraftOpen:d,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let g,w;if(e[0]!==n){w=new Map,g=new Map;const C=(j,A,D,I)=>{w.has(j)||w.set(j,new Map);const M=w.get(j);I.forEach(z=>{const E=yt(z.worktree?.path??z.session.directory??D??A);M.set(z.session.id,{directory:E}),g.has(j)||g.set(j,{id:z.session.id,directory:E}),z.children.length>0&&C(j,A,E,z.children)})};n.forEach(j=>{j.groups.forEach(A=>{C(j.project.id,j.project.normalizedPath,A.directory,A.sessions)})}),e[0]=n,e[1]=g,e[2]=w}else g=e[1],w=e[2];let v;e[3]!==g||e[4]!==w?(v={metaByProject:w,firstSessionByProject:g},e[3]=g,e[4]=w,e[5]=v):v=e[5];const x=v,m=c.useRef(null);let b,y;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==u||e[11]!==h||e[12]!==d||e[13]!==f||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==p?(b=()=>{if(!r||d||Pe.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(I=>I.project.id===r);if(!C)return;const j=x.metaByProject.get(r);if(l&&j&&j.has(l)){m.current=r,o(I=>{if(I.get(r)===l)return I;const M=new Map(I);return M.set(r,l),M});return}const A=x0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:j,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(A.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,A.kind==="open-draft"){h&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(A.kind!=="select-session")return;const D=j?.get(A.sessionId)?.directory??null;u(A.sessionId,D)},y=[r,i,l,a,u,d,h,f,n,x,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=u,e[11]=h,e[12]=d,e[13]=f,e[14]=n,e[15]=x,e[16]=o,e[17]=p,e[18]=b,e[19]=y):(b=e[18],y=e[19]),c.useLayoutEffect(b,y);let S,N;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==o?(S=()=>{if(!r||!l)return;const C=x.metaByProject.get(r);!C||!C.has(l)||o(j=>{if(j.get(r)===l)return j;const A=new Map(j);return A.set(r,l),A})},N=[r,l,x,o],e[20]=r,e[21]=l,e[22]=x,e[23]=o,e[24]=S,e[25]=N):(S=e[24],N=e[25]),c.useEffect(S,N)},y0=t=>{const e=tt.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=Je(w0),a=Je(S0);let u;e[5]!==l||e[6]!==o?(u=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=u):u=e[7];const d=u;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,p]=c.useState(h);let g;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==d||e[14]!==a?(g={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:d,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=d,e[14]=a,e[15]=g):g=e[15],b0(g);let w,v;return e[16]!==f||e[17]!==i?(w=()=>{i(f)},v=[f,i],e[16]=f,e[17]=i,e[18]=w,e[19]=v):(w=e[18],v=e[19]),c.useEffect(w,v),null};function w0(t){return t.currentSessionId}function S0(t){return!!t.newSessionDraft?.open}const uc={selected:0,"active-project":1,expanded:2,visible:3,background:4};function rm(t){const e=new Map,n=(r,i,o)=>{const l=yt(r??null);if(!l)return;const a=e.get(l);a&&uc[a.priority]<=uc[i]||e.set(l,{directory:l,priority:i,reason:o})};for(const r of t.knownDirectories??[])n(r,"background","known-project");n(t.activeProjectDirectory,"active-project","project-expanded");for(const r of t.projectSections??[]){const i=!t.collapsedProjects.has(r.project.id);let o="background";r.project.id===t.activeProjectId?o="active-project":i&&(o="expanded"),n(r.project.normalizedPath,o,i?"project-expanded":"known-project");for(const l of r.groups){if(!l.directory||l.isArchivedBucket||l.isMain)continue;const a=i&&!t.collapsedGroups.has(`${r.project.id}:${l.id}`);let u="background";a?u="expanded":i&&(u="visible"),n(l.directory,u,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const v0=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,mc=(t,e,n)=>{v0(t.get(e),n)&&t.set(e,n)},j0=t=>{const e=t;return yt(e.directory)??yt(e.project?.worktree)},k0=t=>{if(t==="/"||/^[A-Z]:$/.test(t))return null;const e=t.lastIndexOf("/");return e<0?null:e===0?"/":e===2&&/^[A-Z]:\//.test(t)?t.slice(0,2):t.slice(0,e)},C0=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const v=yt(w.normalizedPath);if(!v)continue;const x=l.get(v);(!x||w.id.localeCompare(x.id)<0)&&l.set(v,w),mc(o,v,{projectId:w.id,projectRoot:v,scopeDirectory:v,kind:"project"})}if(!r)for(const[w,v]of n){const x=yt(w),m=x?l.get(x):void 0;if(!(!m||!x))for(const b of v){const y=yt(b.path);y&&mc(o,y,{projectId:m.id,projectRoot:x,scopeDirectory:y,kind:"worktree"})}}const a=new Map,u=new Map,d=new Map,h=new Map,f=new Map,p=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const b=o.get(w)??null;return a.set(w,b),b}const v=[];let x=w,m=null;for(;x;){if(a.has(x)){m=a.get(x)??null;break}if(v.push(x),m=o.get(x)??null,m)break;x=k0(x)}for(const b of v)a.set(b,m);return m},g=(w,v,x)=>{for(const m of w){const b=p(j0(m));if(!b)continue;u.set(m.id,b);const y=v.get(b.projectId);if(y?y.push(m):v.set(b.projectId,[m]),!x)continue;const S=x.get(b.scopeDirectory);S?S.add(m.id):x.set(b.scopeDirectory,new Set([m.id]))}};return g(t,d,f),g(i,h),{bySessionId:u,sessionsByProject:d,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},N0=t=>{const e=tt.c(7),{ownership:n}=t;let r;e[0]!==n?(r=u=>n.sessionsByProject.get(u)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=u=>n.archivedSessionsByProject.get(u)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},A0=(t,e)=>t.map(n=>{const r=yt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
913
|
-
`),P0=[],D0=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:u,buildGroupedSessions:d,hasSessionSearchQuery:h,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:p,buildGroupSearchText:g,foldersMap:w,standaloneGroups:v}=t,x=c.useRef(new Map),m=c.useMemo(()=>{const D=x.current,I=new Map;let M=0,z=0;const E=(B,O)=>B.length===O.length&&B.every((T,k)=>T===O[k]),H=e.map(B=>{const O=n(B.id),T=r(B.id),k=i.get(B.normalizedPath)??P0,P=o.has(B.id)?!!o.get(B.id):u,L=l.get(B.id)??null,Q=A0(k,a),q=D.get(B.id);if(q&&q.project===B&&E(q.activeSessions,O)&&E(q.archivedSessions,T)&&q.availableWorktrees===k&&q.rootBranch===L&&q.worktreeBranchesKey===Q&&q.isRepo===P&&q.buildGroupedSessions===d)return M+=1,I.set(B.id,q),q.section;if(z+=1,q){const Z=q.project!==B?"project":E(q.activeSessions,O)?E(q.archivedSessions,T)?q.availableWorktrees!==k?"worktrees":q.rootBranch!==L?"branch":q.worktreeBranchesKey!==Q?"worktreeBranches":q.isRepo!==P?"repo":"builder":"archived":"sessions";Gs(`ui.sidebar.project_section.rebuilt_reason.${Z}`)}const te=Od([...O,...T]),ae=d(te,B.normalizedPath,k,L,P),X={project:B,groups:ae};return I.set(B.id,{project:B,activeSessions:O,archivedSessions:T,availableWorktrees:k,rootBranch:L,worktreeBranchesKey:Q,isRepo:P,buildGroupedSessions:d,section:X}),X});return x.current=I,M>0&&Gs("ui.sidebar.project_section.reused",M),z>0&&Gs("ui.sidebar.project_section.rebuilt",z),H},[e,n,r,i,o,u,d,l,a]),b=c.useMemo(()=>m,[m]),y=c.useMemo(()=>{const D=new WeakMap;if(!h)return D;const I=f.trim().toLowerCase(),M=I.startsWith("ses_"),z=H=>H.reduce((B,O)=>B+(!M||O.session.id.toLowerCase()===I?1:0)+z(O.children),0),E=H=>{const B=p(H.sessions,f),O=z(B),T=!M&&Ao([g(H)],f),k=yt(H.directory??null),P=k?w[k]??[]:[],L=M?0:P.filter(Q=>Ao([Q.name],f)).length;D.set(H,{filteredNodes:B,matchedSessionCount:O,folderNameMatchCount:L,groupMatches:T,hasMatch:T||O>0||L>0})};return b.forEach(H=>{H.groups.forEach(E)}),v.forEach(E),D},[h,b,v,p,f,g,w]),S=c.useMemo(()=>h?b.map(D=>({...D,groups:D.groups.filter(I=>y.get(I)?.hasMatch===!0)})).filter(D=>D.groups.length>0):b,[h,b,y]),N=h?S:b,C=c.useRef(new WeakMap),j=c.useMemo(()=>{const D=C.current;return N.map(I=>{const M=D.get(I);if(M&&M.query===f)return M.section;const z=I.groups.filter(P=>!P.isArchivedBucket),E=I.groups.filter(P=>P.isArchivedBucket),H=z.flatMap(P=>h?y.get(P)?.filteredNodes??[]:P.sessions),B=z.map(P=>({scopeKey:P.folderScopeKey??yt(P.directory??null),directory:P.directory??null})).filter(P=>!!P.scopeKey),O=z.find(P=>P.isMain)??null,T={id:"flat",label:O?.label??"",branch:O?.branch??null,description:O?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:O?.directory??I.project.normalizedPath,folderScopeKey:O?.folderScopeKey??I.project.normalizedPath,folderScopes:B,sessions:H};if(h){const P=z.map(L=>y.get(L)).filter(L=>!!L);y.set(T,{filteredNodes:H,matchedSessionCount:P.reduce((L,Q)=>L+Q.matchedSessionCount,0),folderNameMatchCount:P.reduce((L,Q)=>L+Q.folderNameMatchCount,0),groupMatches:P.some(L=>L.groupMatches),hasMatch:P.some(L=>L.hasMatch)})}const k={project:I.project,groups:[T,...E]};return D.set(I,{query:f,section:k}),k})},[y,h,f,N]),A=c.useMemo(()=>{if(!h)return 0;const D=(M,z)=>{const E=y.get(z);if(!E)return M;const H=E.folderNameMatchCount+(E.groupMatches?1:0);return M+E.matchedSessionCount+H},I=N.reduce((M,z)=>z.groups.reduce(D,M),0);return v.reduce(D,I)},[h,N,v,y]);return{projectSections:m,visibleProjectSections:b,groupSearchDataByGroup:y,searchableProjectSections:S,sectionsForRender:N,flatSectionsForRender:j,searchMatchCount:A}},I0=180,fc=150,T0=2,E0=8,hc=[-1,1,-2,2],hi=t=>`${t.directory}
|
|
914
|
-
${t.sessionId}`,R0=t=>t?.directory?.trim()||null,M0=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),u=c.useRef(0),d=c.useMemo(()=>Pn(),[]),h=c.useCallback(()=>{u.current+=1,l.current=[],o.current.forEach(g=>window.clearTimeout(g)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||d))for(;a.current.size<T0&&l.current.length>0;){const g=l.current.shift();if(!g)break;if(g.generation!==u.current||Je.getState().currentSessionId===g.sessionId||Ai(g.sessionId,g.directory).renderable)continue;const v=hi(g);a.current.add(v),i({directory:g.directory,sessionID:g.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(v),f()})}},[t,d,i]),p=c.useCallback(g=>{const w=g?.id,v=R0(g);if(!t||d||!w||!v||w===e)return;const x={sessionId:w,directory:v,generation:u.current},m=hi(x);if(Ai(w,v).renderable||a.current.has(m)||l.current.some(S=>hi(S)===m))return;const b=o.current.get(m);b!==void 0&&window.clearTimeout(b);const y=window.setTimeout(()=>{if(o.current.delete(m),x.generation!==u.current)return;const S=l.current;S.length>=E0&&S.shift(),S.push(x),f()},I0);o.current.set(m,y)},[e,t,d,f]);c.useEffect(()=>{h()},[h,e,t,d]),c.useEffect(()=>{if(!t||d||!e||n.length===0)return;const g=window.setTimeout(()=>{const w=n.findIndex(v=>v.id===e);if(!(w<0))for(const v of hc)p(n[w+v])},fc);return()=>window.clearTimeout(g)},[e,t,d,p,n]),c.useEffect(()=>{if(!t||d||!e||r.length===0)return;const g=window.setTimeout(()=>{const w=r.findIndex(v=>v.id===e);if(!(w<0))for(const v of hc)p(r[w+v])},fc);return()=>window.clearTimeout(g)},[e,t,d,r,p]),c.useEffect(()=>h,[h])},O0=t=>{const e=tt.c(3),n=Je(B0);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],M0(r),null};function B0(t){return t.currentSessionId}const Kr=t=>{const e=tt.c(13),{directory:n,className:r}=t,{t:i}=At();let o;e[0]!==n?(o=sf(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=v=>v.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Mt(a)?.tabs.some(dd))return null;let h;e[4]!==i?(h=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=h):h=e[5];const f=h;let p;e[6]!==r?(p=De("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(R,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let w;return e[9]!==l||e[10]!==f||e[11]!==p?(w=s.jsx("span",{className:p,role:"img","aria-label":f,title:f,"data-action-directory":l,children:g}),e[9]=l,e[10]=f,e[11]=p,e[12]=w):w=e[12],w},wo=t=>{const e=tt.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:u,alwaysShowActions:d}=t,h=d===void 0?!1:d,{currentTheme:f}=Zn(),p=i?ja[i]:null,g=o?ka[o]??null:null,w=u!==void 0,v=w?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let x;e[0]!==h||e[1]!==w||e[2]!==u?(x=w?s.jsx("span",{className:De("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(R,{name:u?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=w,e[2]=u,e[3]=x):x=e[3];let m;e[4]!==h||e[5]!==f||e[6]!==w||e[7]!==g||e[8]!==v||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==p?(m=l?s.jsx("span",{className:De("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",w&&h?"hidden":"inline-flex",v),style:a?{backgroundColor:a}:void 0,children:s.jsx(Ca,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:p?s.jsx(R,{name:p,className:"h-3.5 w-3.5",style:g?{color:g}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:g?{color:g}:void 0})})}):p?s.jsx(R,{name:p,className:De("h-3.5 w-3.5",v),style:g?{color:g}:void 0}):s.jsx(R,{name:"folder",className:De("h-3.5 w-3.5 text-muted-foreground/80",v),style:g?{color:g}:void 0}),e[4]=h,e[5]=f,e[6]=w,e[7]=g,e[8]=v,e[9]=n,e[10]=a,e[11]=l,e[12]=p,e[13]=m):m=e[13];let b;e[14]!==x||e[15]!==m?(b=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[x,m]}),e[14]=x,e[15]=m,e[16]=b):b=e[16];let y;e[17]!==r?(y=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=y):y=e[18];let S;return e[19]!==b||e[20]!==y?(S=s.jsxs(s.Fragment,{children:[b,y]}),e[19]=b,e[20]=y,e[21]=S):S=e[21],S},F0=t=>{const e=tt.c(63),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:f,isRepo:p,isDesktopShell:g,hideDirectoryControls:w,alwaysShowActions:v,onToggle:x,onNewSession:m,onNewWorktreeSession:b,onManageWorktrees:y,onRenameStart:S,onClose:N,sentinelRef:C,children:j,showCreateButtons:A,hideHeader:D,statusIndicator:I,openSidebarMenuKey:M,setOpenSidebarMenuKey:z,projectPickerOptions:E,onProjectSelect:H}=t,B=r===void 0?!1:r,O=A===void 0?!0:A,T=D===void 0?!1:D,k=I===void 0?null:I,{t:P}=At(),L=ls($0);let Q;e[0]!==B||e[1]!==n?(Q={id:n,disabled:B},e[0]=B,e[1]=n,e[2]=Q):Q=e[2];const{attributes:q,listeners:te,setNodeRef:ae,transform:X,transition:Z,isDragging:se}=qo(Q),me=c.useRef(!1),_=`project:${n}`,ne=M===_,[ye,ce]=c.useState(!1),F=!!(E&&H);let re;e[3]!==_||e[4]!==z?(re=V=>{V&&ce(!1),z(V?_:null)},e[3]=_,e[4]=z,e[5]=re):re=e[5];const fe=re;let de;e[6]!==w||e[7]!==p||e[8]!==N||e[9]!==y||e[10]!==m||e[11]!==S||e[12]!==O||e[13]!==P?(de=V=>s.jsxs(s.Fragment,{children:[O&&!p&&!w&&m&&s.jsxs(V,{onClick:m,children:[s.jsx(R,{name:"add",className:"mr-1.5 h-4 w-4"}),P("sessions.sidebar.project.actions.newSession")]}),p&&!w&&y&&s.jsxs(V,{onClick:y,children:[s.jsx(R,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),P("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(V,{onClick:S,children:[s.jsx(R,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),P("sessions.sidebar.project.actions.edit")]}),s.jsxs(V,{onClick:N,className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"close",className:"mr-1.5 h-4 w-4"}),P("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=w,e[7]=p,e[8]=N,e[9]=y,e[10]=m,e[11]=S,e[12]=O,e[13]=P,e[14]=de):de=e[14];const ge=de,Te=W0,be=z0,Ee=V0;let we;e[15]===Symbol.for("react.memo_cache_sentinel")?(we=V=>{(V.button===2||V.button===0&&V.ctrlKey)&&(me.current=!0)},e[15]=we):we=e[15];const Y=we;let ve;e[16]!==x?(ve=V=>{if(V.currentTarget.blur(),me.current){me.current=!1;return}x()},e[16]=x,e[17]=ve):ve=e[17];const xe=ve;let je;e[18]!==X?(je=Qo.Transform.toString(X),e[18]=X,e[19]=je):je=e[19];let oe;e[20]!==je||e[21]!==Z?(oe={transform:je,transition:Z},e[20]=je,e[21]=Z,e[22]=oe):oe=e[22];const J=se&&"opacity-30";let K;e[23]!==J?(K=De("relative",J),e[23]=J,e[24]=K):K=e[24];let $;e[25]!==v||e[26]!==q||e[27]!==fe||e[28]!==xe||e[29]!==w||e[30]!==T||e[31]!==n||e[32]!==f||e[33]!==ye||e[34]!==g||e[35]!==ne||e[36]!==F||e[37]!==p||e[38]!==te||e[39]!==m||e[40]!==b||e[41]!==H||e[42]!==u||e[43]!==o||e[44]!==l||e[45]!==a||e[46]!==h||e[47]!==d||e[48]!==i||e[49]!==E||e[50]!==ge||e[51]!==C||e[52]!==O||e[53]!==k||e[54]!==L||e[55]!==P?($=T?null:s.jsxs(s.Fragment,{children:[g&&s.jsx("div",{ref:C,"data-project-id":n,className:"absolute top-0 h-px w-full pointer-events-none","aria-hidden":"true"}),s.jsxs(su,{open:ye,onOpenChange:ce,children:[s.jsx(tu,{render:s.jsx("div",{className:De("-ml-2.5 -mr-2 text-left group/project select-none",L&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":L?"true":void 0,onContextMenu:V=>{w||(V.preventDefault(),ce(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...q,children:[F?s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsxs("button",{type:"button",className:De("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-[padding]",p&&!w?v||ne?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":v||ne?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":P("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(wo,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h}),s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(Kr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Ys,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:E?.map(V=>s.jsxs(Ut,{onClick:()=>H?.(V.id),className:"flex items-center justify-between gap-3",title:V.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(wo,{...V})}),V.id===n?s.jsx(R,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},V.id))})]}):s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:Y,onClick:xe,...te,className:De("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 rounded-md cursor-grab active:cursor-grabbing transition-[padding]",p&&!w?v||ne?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":v||ne?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(wo,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:f,alwaysShowActions:v}),k?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:k}):null,l?s.jsx(Kr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(It,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:De("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",O?"right-7":"right-0.5"),children:[O&&p&&!w&&b?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:V=>{V.stopPropagation(),b()},className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground transition-opacity",v?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":P("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(R,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:P("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,w?null:s.jsxs(Xs,{open:ne,onOpenChange:fe,children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground",ne?"opacity-100 pointer-events-auto":v?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":P("sessions.sidebar.project.actions.projectMenu"),onPointerDown:be,onMouseDown:Ee,onClick:Te,children:s.jsx(R,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Ys,{align:"end",className:"min-w-[180px]",children:ge(Ut)})]})]}),O&&m?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:V=>{V.stopPropagation(),m()},className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",v?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":P(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(R,{name:"add",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:P(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(eu,{className:"min-w-[180px]",children:ge(Un)})]})]}),e[25]=v,e[26]=q,e[27]=fe,e[28]=xe,e[29]=w,e[30]=T,e[31]=n,e[32]=f,e[33]=ye,e[34]=g,e[35]=ne,e[36]=F,e[37]=p,e[38]=te,e[39]=m,e[40]=b,e[41]=H,e[42]=u,e[43]=o,e[44]=l,e[45]=a,e[46]=h,e[47]=d,e[48]=i,e[49]=E,e[50]=ge,e[51]=C,e[52]=O,e[53]=k,e[54]=L,e[55]=P,e[56]=$):$=e[56];let le;return e[57]!==j||e[58]!==ae||e[59]!==oe||e[60]!==K||e[61]!==$?(le=s.jsxs("div",{ref:ae,style:oe,className:K,children:[$,j]}),e[57]=j,e[58]=ae,e[59]=oe,e[60]=K,e[61]=$,e[62]=le):le=e[62],le},_0=t=>{const e=tt.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:u,setActivatorNodeRef:d,transform:h,transition:f,isDragging:p}=qo(l);let g;e[3]!==a||e[4]!==d?(g={listeners:a,setActivatorNodeRef:d},e[3]=a,e[4]=d,e[5]=g):g=e[5];const w=g;let v;e[6]!==h?(v=Qo.Transform.toString(h),e[6]=h,e[7]=v):v=e[7];let x;e[8]!==v||e[9]!==f?(x={transform:v,transition:f},e[8]=v,e[9]=f,e[10]=x):x=e[10];const m=p&&"opacity-50";let b;e[11]!==m?(b=De("space-y-0.5 rounded-md",m),e[11]=m,e[12]=b):b=e[12];let y;e[13]!==i||e[14]!==w?(y=i(w),e[13]=i,e[14]=w,e[15]=y):y=e[15];let S;return e[16]!==u||e[17]!==x||e[18]!==b||e[19]!==y?(S=s.jsx("div",{ref:u,style:x,className:b,children:y}),e[16]=u,e[17]=x,e[18]=b,e[19]=y,e[20]=S):S=e[20],S},L0=c.memo(_0);function $0(t){return t.stickyZoneHeaders}function W0(t){t.stopPropagation()}function z0(t){t.stopPropagation()}function V0(t){t.stopPropagation()}const U0=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},om=t=>{const e=tt.c(9),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==r||e[1]!==n?(l=U0(n,r),e[0]=r,e[1]=n,e[2]=l):l=e[2];const a=l;let u;e[3]!==o||e[4]!==a.active?(u=p=>{if(!o)return null;for(const g of a.active){const w=p.statusById.get(g)?.status.type;if(w==="busy"||w==="retry")return"active"}return null},e[3]=o,e[4]=a.active,e[5]=u):u=e[5];const d=Na(u);let h;e[6]!==o||e[7]!==a.unread?(h=p=>{if(!o)return null;for(const g of a.unread)if((p.index.session.unseenCount[g]??0)>0)return"unread";return null},e[6]=o,e[7]=a.unread,e[8]=h):h=e[8];const f=Aa(h);return d??f};function im(t){const e=tt.c(6),{state:n,activeLabel:r,unreadLabel:i,className:o}=t,l=n==="active"?r:i,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let u;e[0]!==o||e[1]!==a?(u=De("h-1.5 w-1.5 shrink-0 rounded-full",a,o),e[0]=o,e[1]=a,e[2]=u):u=e[2];let d;return e[3]!==l||e[4]!==u?(d=s.jsx("span",{className:u,"aria-label":l,title:l}),e[3]=l,e[4]=u,e[5]=d):d=e[5],d}const K0=t=>{const e=tt.c(11),{nodes:n,includeUnreadSubtasks:r}=t,{t:i}=At();let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=om(o);if(!l)return null;let a;e[3]!==i?(a=i("sessions.sidebar.session.status.active"),e[3]=i,e[4]=a):a=e[4];let u;e[5]!==i?(u=i("sessions.sidebar.session.status.unread"),e[5]=i,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==u?(d=s.jsx(im,{state:l,activeLabel:a,unreadLabel:u}),e[7]=l,e[8]=a,e[9]=u,e[10]=d):d=e[10],d},H0=t=>{const e=tt.c(82),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:u,onRename:d,onDelete:h,children:f,mobileVariant:p,alwaysShowActions:g,isRenaming:w,renameDraft:v,onRenameDraftChange:x,onRenameSave:m,onRenameCancel:b,droppableRef:y,isDropTarget:S,onNewSession:N,depth:C,hideActions:j,archivedBucket:A}=t,D=a===void 0?null:a,M=g===void 0?p===void 0?!1:p:g,z=w===void 0?!1:w,E=v===void 0?"":v,H=S===void 0?!1:S,B=j===void 0?!1:j,O=A===void 0?!1:A,{t:T}=At(),[k,P]=c.useState(!1),[L,Q]=c.useState(""),q=c.useRef(null),te=z||k,ae=z?E:L;let X;e[0]!==n.name?(X=()=>{Q(n.name),P(!0)},e[0]=n.name,e[1]=X):X=e[1];const Z=X;let se;e[2]!==ae||e[3]!==n.name||e[4]!==z||e[5]!==d||e[6]!==m?(se=()=>{const ke=ae.trim();ke&&ke!==n.name&&d(ke),z&&m&&m(),P(!1),Q("")},e[2]=ae,e[3]=n.name,e[4]=z,e[5]=d,e[6]=m,e[7]=se):se=e[7];const me=se;let _;e[8]!==z||e[9]!==b?(_=()=>{z&&b&&b(),P(!1),Q("")},e[8]=z,e[9]=b,e[10]=_):_=e[10];const ne=_;let ye;e[11]!==z||e[12]!==x?(ye=ke=>{z&&x?x(ke):Q(ke)},e[11]=z,e[12]=x,e[13]=ye):ye=e[13];const ce=ye;let F,re;e[14]!==z?(F=()=>{if(!z)return;const ke=()=>{const We=q.current;We&&(We.focus(),We.select())},Ne=requestAnimationFrame(ke),Qe=window.setTimeout(ke,0);return()=>{cancelAnimationFrame(Ne),window.clearTimeout(Qe)}},re=[z],e[14]=z,e[15]=F,e[16]=re):(F=e[15],re=e[16]),c.useEffect(F,re);const fe=l?"folder":"folder-open",de=H&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ge;e[17]!==de?(ge=De("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",de),e[17]=de,e[18]=ge):ge=e[18];let Te;e[19]!==u||e[20]!==te?(Te=te?void 0:ke=>{ke.currentTarget.blur(),u()},e[19]=u,e[20]=te,e[21]=Te):Te=e[21];const be=te?void 0:"button",Ee=te?void 0:0;let we;e[22]!==u||e[23]!==te?(we=te?void 0:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),u())},e[22]=u,e[23]=te,e[24]=we):we=e[24];let Y;e[25]!==n.name||e[26]!==l||e[27]!==T?(Y=l?T("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):T("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=T,e[28]=Y):Y=e[28];const ve=O?M?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":M?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let xe;e[29]!==ve?(xe=De("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",ve),e[29]=ve,e[30]=xe):xe=e[30];const je=H?"text-primary":"text-muted-foreground";let oe;e[31]!==je?(oe=De("h-3.5 w-3.5 flex-shrink-0",je),e[31]=je,e[32]=oe):oe=e[32];let J;e[33]!==fe||e[34]!==oe?(J=s.jsx(R,{name:fe,className:oe}),e[33]=fe,e[34]=oe,e[35]=J):J=e[35];let K;e[36]!==D||e[37]!==r||e[38]!==ae||e[39]!==n.name||e[40]!==ne||e[41]!==ce||e[42]!==me||e[43]!==l||e[44]!==H||e[45]!==te||e[46]!==i||e[47]!==T?(K=te?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:q0,onMouseDown:Q0,onSubmit:ke=>{ke.preventDefault(),me()},children:[s.jsx("input",{ref:q,value:ae,onChange:ke=>ce(ke.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:T("sessions.sidebar.folderItem.namePlaceholder"),onClick:Y0,onPointerDown:X0,onMouseDown:J0,onKeyDown:ke=>{if(ke.key==="Escape"){ke.stopPropagation(),ne();return}(ke.key===" "||ke.key==="Enter")&&ke.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:Z0,onPointerDown:ej,onMouseDown:tj,children:s.jsx(R,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),ne()},onPointerDown:sj,onMouseDown:nj,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:De("typography-ui-label font-semibold truncate",H?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(It,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),D?s.jsx(im,{state:D,activeLabel:T("sessions.sidebar.session.status.active"),unreadLabel:T("sessions.sidebar.session.status.unread")}):null,l?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=D,e[37]=r,e[38]=ae,e[39]=n.name,e[40]=ne,e[41]=ce,e[42]=me,e[43]=l,e[44]=H,e[45]=te,e[46]=i,e[47]=T,e[48]=K):K=e[48];let $;e[49]!==xe||e[50]!==J||e[51]!==K?($=s.jsxs("div",{className:xe,children:[J,K]}),e[49]=xe,e[50]=J,e[51]=K,e[52]=$):$=e[52];let le;e[53]!==M||e[54]!==O||e[55]!==n.name||e[56]!==Z||e[57]!==B||e[58]!==h||e[59]!==N||e[60]!==te||e[61]!==T?(le=!te&&(!B||O)?s.jsx("div",{className:De("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",M?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!O&&N?s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),N()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":T("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:T("sessions.sidebar.project.actions.newSession"),children:s.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null,O?null:s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),Z()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":T("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(R,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),h()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":O?T("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):T("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=M,e[54]=O,e[55]=n.name,e[56]=Z,e[57]=B,e[58]=h,e[59]=N,e[60]=te,e[61]=T,e[62]=le):le=e[62];let V;e[63]!==y||e[64]!==ge||e[65]!==Te||e[66]!==be||e[67]!==Ee||e[68]!==we||e[69]!==Y||e[70]!==$||e[71]!==le?(V=s.jsxs("div",{ref:y,className:ge,onClick:Te,role:be,tabIndex:Ee,onKeyDown:we,"aria-label":Y,children:[$,le]}),e[63]=y,e[64]=ge,e[65]=Te,e[66]=be,e[67]=Ee,e[68]=we,e[69]=Y,e[70]=$,e[71]=le,e[72]=V):V=e[72];let Ce;e[73]!==f||e[74]!==l||e[75]!==i||e[76]!==o||e[77]!==T?(Ce=l?null:s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:T("sessions.sidebar.folderItem.emptyFolder")})]}),e[73]=f,e[74]=l,e[75]=i,e[76]=o,e[77]=T,e[78]=Ce):Ce=e[78];let _e;return e[79]!==V||e[80]!==Ce?(_e=s.jsxs("div",{className:"oc-folder",children:[V,Ce]}),e[79]=V,e[80]=Ce,e[81]=_e):_e=e[81],_e},G0=c.memo(H0);function q0(t){return t.stopPropagation()}function Q0(t){return t.stopPropagation()}function Y0(t){return t.stopPropagation()}function X0(t){return t.stopPropagation()}function J0(t){return t.stopPropagation()}function Z0(t){return t.stopPropagation()}function ej(t){return t.stopPropagation()}function tj(t){return t.stopPropagation()}function sj(t){return t.stopPropagation()}function nj(t){return t.stopPropagation()}const rj=t=>{const e=tt.c(15),{sessionId:n,sessionDirectory:r,sessionTitle:i,children:o}=t,l=`session-drag:${n}`;let a;e[0]!==r||e[1]!==n||e[2]!==i?(a={type:"session",sessionId:n,sessionDirectory:r,sessionTitle:i},e[0]=r,e[1]=n,e[2]=i,e[3]=a):a=e[3];let u;e[4]!==l||e[5]!==a?(u={id:l,data:a},e[4]=l,e[5]=a,e[6]=u):u=e[6];const{attributes:d,listeners:h,setNodeRef:f,isDragging:p}=Tg(u);let g;e[7]!==h?(g=m=>{m.stopPropagation(),h?.onPointerDown&&h.onPointerDown(m)},e[7]=h,e[8]=g):g=e[8];const w=g,v=p?"opacity-30":void 0;let x;return e[9]!==d||e[10]!==o||e[11]!==w||e[12]!==f||e[13]!==v?(x=s.jsx("div",{ref:f,...d,onPointerDown:w,className:v,children:o}),e[9]=d,e[10]=o,e[11]=w,e[12]=f,e[13]=v,e[14]=x):x=e[14],x},oj=t=>{const e=tt.c(11),{folderId:n,children:r}=t,i=`folder-drop:${n}`;let o;e[0]!==n?(o={type:"folder",folderId:n},e[0]=n,e[1]=o):o=e[1];let l;e[2]!==i||e[3]!==o?(l={id:i,data:o},e[2]=i,e[3]=o,e[4]=l):l=e[4];const{setNodeRef:a,isOver:u}=Eg(l);let d;e[5]!==r||e[6]!==u||e[7]!==a?(d=r(a,u),e[5]=r,e[6]=u,e[7]=a,e[8]=d):d=e[8];let h;return e[9]!==d?(h=s.jsx(s.Fragment,{children:d}),e[9]=d,e[10]=h):h=e[10],h},ij=t=>{const e=tt.c(20),{scopeKey:n,hasFolders:r,onSessionDroppedOnFolder:i,children:o}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={activationConstraint:{distance:8}},e[0]=l):l=e[0];const a=zr(Mn(Oi,l)),[u,d]=c.useState(null),[h,f]=c.useState("Session"),[p,g]=c.useState(null),[w,v]=c.useState(null);if(!n){let j;return e[1]!==o?(j=s.jsx(s.Fragment,{children:o}),e[1]=o,e[2]=j):j=e[2],j}let x;e[3]!==i?(x=j=>{d(null),g(null),v(null);const{active:A,over:D}=j;if(!D)return;const I=A.data.current,M=D.data.current;I?.type==="session"&&I.sessionId&&M?.type==="folder"&&M.folderId&&i(I.sessionId,M.folderId)},e[3]=i,e[4]=x):x=e[4];const m=x;let b,y;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=j=>{const A=j.active.data.current;if(A?.type==="session"&&A.sessionId){d(A.sessionId),f(A.sessionTitle??"Session");const D=j.active.rect.current.initial?.width,I=j.active.rect.current.initial?.height;g(typeof D=="number"?D:null),v(typeof I=="number"?I:null)}},y=()=>{d(null),g(null),v(null)},e[5]=b,e[6]=y):(b=e[5],y=e[6]);let S;e[7]!==w||e[8]!==u||e[9]!==h||e[10]!==p||e[11]!==r?(S=u&&r?s.jsxs("div",{style:{width:p?`${p}px`:"auto",height:w?`${w}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(R,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:h})]}):null,e[7]=w,e[8]=u,e[9]=h,e[10]=p,e[11]=r,e[12]=S):S=e[12];let N;e[13]!==S?(N=s.jsx(Bi,{children:S}),e[13]=S,e[14]=N):N=e[14];let C;return e[15]!==o||e[16]!==m||e[17]!==a||e[18]!==N?(C=s.jsxs(Vr,{sensors:a,collisionDetection:Ur,onDragStart:b,onDragCancel:y,onDragEnd:m,children:[o,N]}),e[15]=o,e[16]=m,e[17]=a,e[18]=N,e[19]=C):C=e[19],C},ea=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},Hn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Hn(n,e))return!0;return!1},aj=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!ph(r),lj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,cj=(t,e,n)=>{const r=new Map,i=o=>{const l=$s(o.session)??yt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},dj=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},uj=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const u=a.pop();if(!(!u||r.has(u))){r.add(u);for(const d of n.get(u)??[])a.push(d.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},mj=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(d=>[d.id,d])),i=new Map,o=new Set;for(const d of t){if(d.parentId&&!r.has(d.parentId)){o.add(d.id);continue}if(d.parentId){const p=i.get(d.parentId)??[];p.push(d.id),i.set(d.parentId,p)}const h=new Set;let f=d.id;for(;f;){if(h.has(f)){o.add(d.id);break}h.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,u=d=>{if(l.has(d))return!0;if(a.has(d))return!1;const h=r.get(d);if(!h)return!1;a.add(d);let f=o.has(d);return!f&&e.archivedBucket&&h.nodeCount===0?f=(i.get(d)??[]).some(u):(!f&&!e.searchQuery&&(f=!0),!f&&(h.nodeCount>0||!n&&Ao([h.name],e.searchQuery))&&(f=!0),f||(f=(i.get(d)??[]).some(u))),a.delete(d),f&&l.add(d),f};return t.forEach(d=>u(d.id)),new Set(t.filter(d=>l.has(d.id)).map(d=>d.id))},pc=new WeakMap;let gc=1;const fj=t=>{const e=pc.get(t);if(e!==void 0)return e;const n=gc;return gc+=1,pc.set(t,n),n},Fo=t=>t.children.length===0?"":t.children.map(n=>{const r=fj(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Fo(n)}`}).join("|"),am=(t,e,n,r,i,o)=>{const l=ps(),a=(u,d)=>{if(u.session.id!==d.session.id||u.children.length!==d.children.length)return!0;const h=u.session.directory??i,f=d.session.directory??o,p=sl(l,h??"",u.session.id),g=sl(l,f??"",d.session.id);return(p?n.has(p):!1)!==(g?r.has(g):!1)?!0:u.children.some((w,v)=>a(w,d.children[v]))};return a(t,e)},hj=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,Hr=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const d of a.children)if(l(d))return!0;return!1};return t.forEach(a=>l(a)),o};let ta=!1;const sa=new Set;let xc=!1;function pj(){for(const t of sa)t()}function $a(t){ta!==t&&(ta=t,pj())}function gj(t){t.key==="Shift"&&$a(!0)}function xj(t){t.key==="Shift"&&$a(!1)}function bj(){$a(!1)}function yj(){xc||typeof window>"u"||(xc=!0,window.addEventListener("keydown",gj),window.addEventListener("keyup",xj),window.addEventListener("blur",bj))}function wj(t){return yj(),sa.add(t),()=>{sa.delete(t)}}function Sj(){return ta}function vj(){return!1}function jj(){return ht.useSyncExternalStore(wj,Sj,vj)}const kj=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,lm=/^g[1-9]\d*$/,Ar=(t,e,n,r,i)=>{if(!kj.test(t)||e!==void 0&&!lm.test(e)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!1};if(i==="fusion")return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;const o=Number.parseInt(i,10);return!Number.isSafeInteger(o)||o<=0?null:{groupSlug:t,runGroup:e,providerID:n,modelID:r,index:o,fusion:!1}},So=t=>{if(!t)return null;const e=t.split("/");if(e.length<3||e.length>5)return null;const[n]=e;if(e.length===3)return Ar(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,u,d]=e;return lm.test(a)?Ar(n,a,u,d,void 0):Ar(n,void 0,a,u,d)}const[,r,i,o,l]=e;return r===""?Ar(n,void 0,i,o,l):Ar(n,r,i,o,l)},Cj=t=>{const e=[t.groupSlug];return t.runGroup&&e.push(t.runGroup),e.push(t.providerID,t.modelID),t.index!==void 0&&e.push(String(t.index)),e.join("/")},Nj=(t,e,n,r)=>{const i=[t];return r&&i.push(r),i.push(e,n,"fusion"),i.join("/")},cm=t=>{const e=tt.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:u}=At(),d=Gt(Aj),h=Gt(Pj),f=Gt(Dj);let p;e[0]!==d?(p=d(),e[0]=d,e[1]=p):p=e[1];const g=p;let w;e[2]!==g?(w=g.filter(Ij),e[2]=g,e[3]=w):w=e[3];const v=w;let x,m;e[4]!==g.length||e[5]!==h?(x=()=>{g.length===0&&h()},m=[g.length,h],e[4]=g.length,e[5]=h,e[6]=x,e[7]=m):(x=e[6],m=e[7]),c.useEffect(x,m);let b,y;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==v||e[12]!==n?(b=()=>{if(o)return;const z=n.trim();if(z.length>0&&v.some(B=>B.name===z))return;const E=typeof f=="string"&&f.trim().length>0?f.trim():null;if(E&&v.some(B=>B.name===E)){r(E);return}const H=v[0]?.name;H&&r(H)},y=[f,o,r,v,n],e[8]=f,e[9]=o,e[10]=r,e[11]=v,e[12]=n,e[13]=b,e[14]=y):(b=e[13],y=e[14]),c.useEffect(b,y);const S=n.trim().length>0?n:void 0;let N;e[15]!==i?(N=De("max-w-full",i),e[15]=i,e[16]=N):N=e[16];let C;e[17]!==u?(C=u("multirun.agentSelector.placeholder"),e[17]=u,e[18]=C):C=e[18];let j;e[19]!==C?(j=s.jsx(Cs,{placeholder:C}),e[19]=C,e[20]=j):j=e[20];let A;e[21]!==l||e[22]!==N||e[23]!==j?(A=s.jsx(Fs,{id:l,size:"lg",className:N,children:j}),e[21]=l,e[22]=N,e[23]=j,e[24]=A):A=e[24];let D;e[25]!==v?(D=v.length>0&&s.jsx(Pi,{children:v.map(Tj)}),e[25]=v,e[26]=D):D=e[26];let I;e[27]!==a||e[28]!==D?(I=s.jsx(_s,{fitContent:!0,portalToBody:a,children:D}),e[27]=a,e[28]=D,e[29]=I):I=e[29];let M;return e[30]!==o||e[31]!==r||e[32]!==S||e[33]!==A||e[34]!==I?(M=s.jsxs(Bs,{value:S,onValueChange:r,disabled:o,children:[A,I]}),e[30]=o,e[31]=r,e[32]=S,e[33]=A,e[34]=I,e[35]=M):M=e[35],M};function Aj(t){return t.getVisibleAgents}function Pj(t){return t.loadAgents}function Dj(t){return t.currentAgentName}function Ij(t){return Bd(t.mode)}function Tj(t){return s.jsx(ss,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Ej="h-7",_r=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Rj=t=>{const e=tt.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=De("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Ej),e[0]=u):u=e[0];let d;e[1]!==n.providerID?(d=s.jsx(Di,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=d):d=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(R,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let p;e[6]!==o?(p=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=p):p=e[7];let g;return e[8]!==d||e[9]!==h||e[10]!==p?(g=s.jsxs("div",{className:u,children:[d,h,p]}),e[8]=d,e[9]=h,e[10]=p,e[11]=g):g=e[11],g},dm=t=>{const e=tt.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:u,maxModels:d,addButtonClassName:h,dropdownSide:f,dropdownClassName:p,containerClassName:g,triggerIcon:w}=t,v=u===void 0?!0:u,x=f===void 0?"top":f,{t:m}=At(),b=Gt(Mj),y=Gt(Oj),S=Pe(Bj),N=Pe(Fj),{favoriteModelsList:C,recentModelsList:j}=gh(),A=Pe(_j),D=Pe(Lj),[I,M]=c.useState(!1),[z,E]=c.useState(""),[H,B]=c.useState(null),O=c.useRef(null),T=c.useRef(null),k=d===1,P=d===void 0||n.length<d||k;let L;if(e[0]!==n){L=new Map;for(const Ie of n){const rt=`${Ie.providerID}:${Ie.modelID}`;L.set(rt,(L.get(rt)||0)+1)}e[0]=n,e[1]=L}else L=e[1];const Q=L;let q;e[2]!==n?(q=Ie=>n.filter(Ge=>Ge.providerID===Ie.providerID&&Ge.modelID===Ie.modelID).findIndex(Ge=>Ge.instanceId===Ie.instanceId)+1,e[2]=n,e[3]=q):q=e[3];const te=q;let ae,X;e[4]!==x||e[5]!==I?(ae=()=>{if(!I||!T.current)return;const Ie=T.current.getBoundingClientRect();if(x==="bottom"){const G=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Ie.bottom-16-112;B(Math.max(160,Math.min(320,G)));return}let rt=T.current.parentElement;for(;rt&&!rt.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const ct=getComputedStyle(rt);if(ct.overflow==="auto"||ct.overflow==="hidden"||ct.overflowY==="auto"||ct.overflowY==="hidden")break;rt=rt.parentElement}const Ge=rt?rt.getBoundingClientRect().top:0,ut=Ie.top-Ge-16;B(Math.max(150,Math.min(300,ut)))},X=[x,I],e[4]=x,e[5]=I,e[6]=ae,e[7]=X):(ae=e[6],X=e[7]),c.useEffect(ae,X);let Z,se;e[8]!==P||e[9]!==I?(Z=()=>{!P&&I&&(M(!1),E(""))},se=[P,I],e[8]=P,e[9]=I,e[10]=Z,e[11]=se):(Z=e[10],se=e[11]),c.useEffect(Z,se);let me,_;e[12]!==I?(me=()=>{if(!I)return;const Ie=rt=>{O.current&&!O.current.contains(rt.target)&&(M(!1),E(""))};return document.addEventListener("mousedown",Ie),()=>document.removeEventListener("mousedown",Ie)},_=[I],e[12]=I,e[13]=me,e[14]=_):(me=e[13],_=e[14]),c.useEffect(me,_);let ne;e[15]!==k||e[16]!==r||e[17]!==o||e[18]!==n.length?(ne=Ie=>{const rt={providerID:Ie.providerID,modelID:Ie.modelID,displayName:Ie.model.name||Ie.modelID,instanceId:_r()};k&&n.length>0&&o?o(0,rt):r(rt),k&&(M(!1),E(""))},e[15]=k,e[16]=r,e[17]=o,e[18]=n.length,e[19]=ne):ne=e[19];const ye=ne;let ce;e[20]!==m?(ce=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=ce):ce=e[21];let F;e[22]!==m?(F=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=F):F=e[23];let re;e[24]!==m?(re=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=re):re=e[25];let fe;e[26]!==m?(fe=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=fe):fe=e[27];let de;e[28]!==m?(de=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=de):de=e[29];let ge;e[30]!==m?(ge=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=ge):ge=e[31];let Te;e[32]!==m?(Te=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=Te):Te=e[33];let be;e[34]!==m?(be=m("chat.modelControls.capabilities"),e[34]=m,e[35]=be):be=e[35];let Ee;e[36]!==m?(Ee=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=Ee):Ee=e[37];let we;e[38]!==m?(we=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=we):we=e[39];let Y;e[40]!==m?(Y=m("chat.modelControls.input"),e[40]=m,e[41]=Y):Y=e[41];let ve;e[42]!==m?(ve=m("chat.modelControls.output"),e[42]=m,e[43]=ve):ve=e[43];let xe;e[44]!==m?(xe=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=xe):xe=e[45];let je;e[46]!==ce||e[47]!==F||e[48]!==re||e[49]!==fe||e[50]!==de||e[51]!==ge||e[52]!==Te||e[53]!==be||e[54]!==Ee||e[55]!==we||e[56]!==Y||e[57]!==ve||e[58]!==xe?(je={searchPlaceholder:ce,noResults:F,favorites:re,recent:fe,keyboardHint:de,favorite:ge,unfavorite:Te,capabilities:be,capabilityToolCalling:Ee,capabilityReasoning:we,input:Y,output:ve,costPerMillion:xe},e[46]=ce,e[47]=F,e[48]=re,e[49]=fe,e[50]=de,e[51]=ge,e[52]=Te,e[53]=be,e[54]=Ee,e[55]=we,e[56]=Y,e[57]=ve,e[58]=xe,e[59]=je):je=e[59];const oe=je;let J;e[60]!==g?(J=De("relative",g),e[60]=g,e[61]=J):J=e[61];const K=I?"":void 0;let $;e[62]!==h?($=De(Fd({size:"default"}),"w-fit",h),e[62]=h,e[63]=$):$=e[63];const le=!P;let V;e[64]!==I?(V=()=>{M(!I)},e[64]=I,e[65]=V):V=e[65];let Ce;e[66]!==w?(Ce=w??s.jsx(R,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=Ce):Ce=e[67];let _e;e[68]!==a||e[69]!==m?(_e=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=_e):_e=e[70];let ke;e[71]!==K||e[72]!==$||e[73]!==le||e[74]!==V||e[75]!==Ce||e[76]!==_e?(ke=s.jsxs("button",{ref:T,type:"button","data-popup-open":K,className:$,disabled:le,onClick:V,children:[Ce,_e]}),e[71]=K,e[72]=$,e[73]=le,e[74]=V,e[75]=Ce,e[76]=_e,e[77]=ke):ke=e[77];let Ne;e[78]!==H||e[79]!==P||e[80]!==p||e[81]!==x||e[82]!==C||e[83]!==ye||e[84]!==A||e[85]!==N||e[86]!==I||e[87]!==oe||e[88]!==Q||e[89]!==y||e[90]!==D||e[91]!==b||e[92]!==j||e[93]!==z||e[94]!==S?(Ne=I?s.jsx("div",{className:De("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",x==="top"?"bottom-full mb-1":"top-full mt-1",p),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(xh,{providers:b,providerOrder:D,favoriteModels:C,recentModels:j,modelsMetadata:y,hiddenModels:A,searchQuery:z,onSearchQueryChange:E,onSelect:ye,labels:oe,selectionCount:Ie=>Q.get(`${Ie.providerID}:${Ie.modelID}`)||0,disabled:!P,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:H?`${H}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:I,isFavorite:Ie=>N(Ie.providerID,Ie.modelID),onToggleFavorite:Ie=>S(Ie.providerID,Ie.modelID),onEscape:()=>{M(!1),E("")}})}):null,e[78]=H,e[79]=P,e[80]=p,e[81]=x,e[82]=C,e[83]=ye,e[84]=A,e[85]=N,e[86]=I,e[87]=oe,e[88]=Q,e[89]=y,e[90]=D,e[91]=b,e[92]=j,e[93]=z,e[94]=S,e[95]=Ne):Ne=e[95];let Qe;e[96]!==J||e[97]!==ke||e[98]!==Ne?(Qe=s.jsxs("div",{className:J,ref:O,children:[ke,Ne]}),e[96]=J,e[97]=ke,e[98]=Ne,e[99]=Qe):Qe=e[99];let We;e[100]!==te||e[101]!==Q||e[102]!==i||e[103]!==o||e[104]!==b||e[105]!==n||e[106]!==v||e[107]!==m?(We=v&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Ie,rt)=>{const Ge=`${Ie.providerID}:${Ie.modelID}`,ut=Q.get(Ge)||1,ct=te(Ie),G=b.find(Ue=>Ue.id===Ie.providerID)?.models?.find(Ue=>Ue.id===Ie.modelID),Le=G?.variants?Object.keys(G.variants):[],Oe=Le.length>0,qe=Ie.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Rj,{model:Ie,instanceIndex:ct,totalSameModel:ut,onRemove:()=>i(rt)}),Oe&&s.jsxs(Bs,{value:qe,onValueChange:Ue=>{if(!o)return;o(rt,{...Ie,variant:Ue==="__default__"?void 0:Ue})},children:[s.jsxs(Fs,{size:"sm",className:"gap-1.5",children:[s.jsx(R,{name:"brain-ai-3",className:De("h-3.5 w-3.5 flex-shrink-0",qe==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(Cs,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:Ue=>Ue==="__default__"?m("multirun.modelMultiSelect.variant.default"):Ue})]}),s.jsxs(_s,{fitContent:!0,children:[s.jsx(ss,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),Le.map($j)]})]})]},Ie.instanceId)})}),e[100]=te,e[101]=Q,e[102]=i,e[103]=o,e[104]=b,e[105]=n,e[106]=v,e[107]=m,e[108]=We):We=e[108];let U;e[109]!==Qe||e[110]!==We?(U=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[Qe,We]}),e[109]=Qe,e[110]=We,e[111]=U):U=e[111];let he;e[112]!==d||e[113]!==l||e[114]!==n.length||e[115]!==m?(he=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:d!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:d}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=d,e[113]=l,e[114]=n.length,e[115]=m,e[116]=he):he=e[116];let Re;return e[117]!==U||e[118]!==he?(Re=s.jsxs("div",{className:"space-y-2",children:[U,he]}),e[117]=U,e[118]=he,e[119]=Re):Re=e[119],Re};function Mj(t){return t.providers}function Oj(t){return t.modelsMetadata}function Bj(t){return t.toggleFavoriteModel}function Fj(t){return t.isFavoriteModel}function _j(t){return t.hiddenModels}function Lj(t){return t.providerOrder}function $j(t){return s.jsx(ss,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Wj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
915
|
-
|
|
916
|
-
--- RESULT ${n+1}: ${r} ---
|
|
917
|
-
${e.trim()}
|
|
918
|
-
--- END RESULT ${n+1} ---`},bc=(t,e)=>Je.getState().getWorktreeMetadata(t)?.projectDirectory??e,zj=async t=>{const e=t.directory??void 0,n=yh(t.session.id,e);if(n.length===0&&t.directory){const i=(await qs.withDirectory(t.directory,()=>qs.getSdkClient().session.messages({sessionID:t.session.id,directory:t.directory??void 0,limit:50}))).data??[];for(let o=i.length-1;o>=0;o-=1){const l=i[o];if(l.info?.role==="assistant")return rl(l.parts??[]).trim()}return""}for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.role==="assistant")return rl(wh(i.id,e)).trim()}return""};function Vj({session:t,open:e,onOpenChange:n}){const{t:r}=At(),i=bh(),o=Ds(k=>k.activeSessions),l=Ds(k=>k.archivedSessions),a=Gt(k=>k.providers),u=Gt(k=>k.currentProviderId),d=Gt(k=>k.currentModelId),h=Gt(k=>k.currentAgentName),[f,p]=c.useState(u??""),[g,w]=c.useState(d??""),[v,x]=c.useState(()=>u&&d?[{providerID:u,modelID:d,instanceId:_r()}]:[]),[m,b]=c.useState(""),[y,S]=c.useState(h??""),[N,C]=c.useState([]),[j,A]=c.useState(!1),D=c.useMemo(()=>So(t.title),[t.title]),I=c.useMemo(()=>{const k=new Map;for(const P of i)k.set(P.id,P);for(const P of o)k.set(P.id,P);for(const P of l)k.set(P.id,P);return t.id&&k.set(t.id,t),Array.from(k.values())},[o,l,i,t]);c.useEffect(()=>{if(!e||!D)return;const k=Je.getState().getDirectoryForSession(t.id),P=bc(t.id,k),L=I.map(Q=>{const q=So(Q.title);if(!q||q.groupSlug!==D.groupSlug||q.fusion||(q.runGroup??null)!==(D.runGroup??null))return null;const te=Je.getState().getDirectoryForSession(Q.id)??$s(Q),ae=bc(Q.id,te);return P&&ae&&P!==ae?null:{session:Q,directory:te,projectDirectory:ae}}).filter(Q=>Q!==null).sort((Q,q)=>(Q.session.time?.created??0)-(q.session.time?.created??0));C(L)},[I,e,D,t.id]);const z=a.find(k=>k.id===f)?.models.find(k=>k.id===g),E=z?.variants?Object.keys(z.variants):[],H=!!(D&&f&&g&&N.length>0&&!j),B=c.useCallback(k=>{x([k]),p(k.providerID),w(k.modelID),b("")},[]),O=v[0]?.displayName||v[0]?.modelID||r("multirun.fusion.model.placeholder"),T=async()=>{if(!(!D||!f||!g)){A(!0);try{const k=await Promise.all(N.map(X=>zj(X))),P=N.map((X,Z)=>({source:X,text:k[Z]??""})).filter(X=>X.text.trim().length>0);if(P.length===0){Me.error(r("multirun.fusion.toast.noOutputs"));return}const L=N[0]?.projectDirectory??N[0]?.directory??null,Q=Nj(D.groupSlug,f,g,D.runGroup),[q,te]=await Promise.all([nl("session.fusion.visible"),nl("session.fusion.instructions")]),ae=await Je.getState().createSession(Q,L,null);if(!ae)throw new Error("Failed to create fusion session");Je.getState().setCurrentSession(ae.id,L),n(!1),await qs.sendMessage({id:ae.id,providerID:f,modelID:g,variant:m||void 0,agent:y||void 0,text:q,additionalParts:[{text:te,synthetic:!0},...P.map((X,Z)=>({text:Wj(X.source,X.text,Z),synthetic:!0})),{text:`
|
|
919
|
-
|
|
920
|
-
--- FUSION INPUTS END ---
|
|
921
|
-
Now write the final fused answer.`,synthetic:!0}],directory:L??qs.getDirectory()})}catch(k){console.error("[MultiRunFusion] Failed to start fusion",k),Me.error(r("multirun.fusion.toast.failed"))}finally{A(!1)}}};return s.jsx(ws,{open:e,onOpenChange:n,children:s.jsxs(Ss,{className:"max-w-xl overflow-visible",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:r("multirun.fusion.title")}),s.jsx(Ts,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(dm,{selectedModels:v,onAdd:B,onUpdate:(k,P)=>B(P),onRemove:()=>{x([]),p(""),w(""),b("")},maxModels:1,addButtonLabel:O,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:f?s.jsx(Di,{providerId:f,className:"h-3.5 w-3.5 mr-1"}):void 0})}),E.length>0?s.jsxs(Bs,{value:m||"__default__",onValueChange:k=>b(k==="__default__"?"":k),children:[s.jsxs(Fs,{size:"lg",className:"w-fit",children:[s.jsx(R,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Cs,{children:k=>k==="__default__"?r("multirun.modelMultiSelect.variant.default"):k})]}),s.jsxs(_s,{fitContent:!0,portalToBody:!0,children:[s.jsx(ss,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),E.map(k=>s.jsx(ss,{value:k,children:k},k))]})]}):null,s.jsx(cm,{value:y,onChange:S,portalToBody:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:N.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:N.map(k=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Di,{providerId:So(k.session.title)?.providerID??"",className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:k.session.title||k.session.id}),s.jsx("button",{type:"button",onClick:()=>C(P=>P.filter(L=>L.session.id!==k.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"h-4 w-4"})})]},k.session.id))})]}),s.jsxs(bn,{children:[s.jsx(pt,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(pt,{onClick:T,disabled:!H,children:r(j?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function Uj(t){const e=tt.c(7);let n,r,i,o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),i=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),o=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),l=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=i,e[3]=o,e[4]=l):(n=e[0],r=e[1],i=e[2],o=e[3],l=e[4]);let a;return e[5]!==t?(a=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,i,o,l]}),e[5]=t,e[6]=a):a=e[6],a}const Kj=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),um=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>Gr(r))])),na=t=>((t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey||t.rawWorktreesByProjectRef.current.worktreesByProject.size===0&&t.publishedWorktreesByProject.size>0)&&(t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.rawWorktreesByProjectRef.current.runtimeKey===t.runtimeKey?t.rawWorktreesByProjectRef.current.revision:0,worktreesByProject:um(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),mm=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},yc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Gr=t=>({...t,path:yt(t.path)??t.path,projectDirectory:yt(t.projectDirectory)??t.projectDirectory,worktreeRoot:yt(t.worktreeRoot??t.path)??t.worktreeRoot}),wc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=yt(e?.path??null)===n,a=l?e?.branch??"":i??"",u={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||yc(n):i||yc(n),name:l?e?.name:void 0,worktreeRoot:l?yt(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...u}:u},Sc=t=>{const e=yt(t.projectPath??null),n=yt(t.sourceDirectory??null)??yt(t.currentWorktree?.path??null),r=yt(t.discoveredWorktrees.find(h=>yt(h.projectDirectory??null))?.projectDirectory??null),i=yt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=h=>{const f=yt(h.metadata.path??null);!f||l.has(f)||l.set(f,{...h,metadata:Gr({...h.metadata,path:f})})};for(const h of t.discoveredWorktrees){const f=yt(h.path??null);f&&a({metadata:Gr({...h,path:f,projectDirectory:yt(h.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:wc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:wc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const u=[],d=[];for(const h of l.values()){if(h.isPrimary){u.push(h);continue}d.push(h)}return u.sort((h,f)=>h.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),d.sort(mm),[...u,...d]},Hj=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=na({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),l=(t.projectId?e.projects.find(d=>d.id===t.projectId)??null:null)??(t.sourceDirectory?e.resolveProject(t.sourceDirectory):null),a=yt(l?.path??null);return{cachedTargets:Sc({projectPath:a,discoveredWorktrees:a?i.worktreesByProject.get(a)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!l||!a)throw new Error("Unable to resolve worktree project");const d=await e.listProjectWorktrees(l,{force:!0});if(e.getRuntimeKey()!==n)throw new Error("Runtime changed during worktree refresh");const h=e.getCurrentProjects(),f=h.find(S=>S.id===l.id)??null;if(!f||yt(f.path??null)!==a)throw new Error("Project removed during worktree refresh");const p=na({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:e.getPublishedWorktreesByProject(),runtimeKey:n}),g=um(p.worktreesByProject),w=[...d].map(S=>Gr(S)).sort((S,N)=>mm({metadata:S},{metadata:N})),v=yt(w.find(S=>yt(S.projectDirectory??null))?.projectDirectory??t.currentWorktree?.projectDirectory??l.path),x=new Set([a]);for(const[S,N]of g.entries()){const C=yt(N.find(j=>yt(j.projectDirectory??null))?.projectDirectory??S);C&&C===v&&x.add(S)}for(const S of x){if(w.length===0){g.delete(S);continue}g.set(S,w.map(N=>Gr(N)))}Kj(e.rawWorktreesByProjectRef,n),e.rawWorktreesByProjectRef.current={runtimeKey:n,revision:e.rawWorktreesByProjectRef.current.revision,worktreesByProject:g};const m=e.partitionWorktreesByRegisteredProject(h,g),b=[...m.values()].flat();e.recordWorktreesSeen(b.map(S=>S.path),e.now());const y=e.getPublishedWorktreesByProject();return e.worktreeMapsEqual(m,y)||e.publishTopology({availableWorktrees:b,availableWorktreesByProject:m}),Sc({projectPath:a,discoveredWorktrees:w,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},Gj=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},qj=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),Qj=(t,e)=>yt(t.worktree?.path??null)===yt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,ra=6,lo=14,vc=ra+14+6,pi=new WeakMap,Yj=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;pi.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,pi.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},u=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const d=e.getBoundingClientRect().top-r;if(Math.abs(d)>.5&&(n.scrollTop+=d,Gs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(u)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),pi.set(n,a),l=window.requestAnimationFrame(u)},Xj=c.memo(function(e){const n=tt.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:u,onArchive:d,onDelete:h}=e,f=jj(),p=f?i:r;let g;n[0]!==d||n[1]!==h||n[2]!==f?(g=C=>{if(f||C.shiftKey){h(C);return}d(C)},n[0]=d,n[1]=h,n[2]=f,n[3]=g):g=n[3];const w=g,v=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;n[4]!==o||n[5]!==v?(x=De("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",v,o),n[4]=o,n[5]=v,n[6]=x):x=n[6];const m=f?"delete-bin":"archive";let b;n[7]!==l||n[8]!==m?(b=s.jsx(R,{name:m,className:l}),n[7]=l,n[8]=m,n[9]=b):b=n[9];let y;n[10]!==w||n[11]!==p||n[12]!==u||n[13]!==a||n[14]!==x||n[15]!==b?(y=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:x,"aria-label":p,onPointerDown:a,onMouseDown:u,onClick:w,onKeyDown:i2,children:b})}),n[10]=w,n[11]=p,n[12]=u,n[13]=a,n[14]=x,n[15]=b,n[16]=y):y=n[16];let S;n[17]!==p?(S=s.jsx(It,{side:"left",sideOffset:8,children:p}),n[17]=p,n[18]=S):S=n[18];let N;return n[19]!==y||n[20]!==S?(N=s.jsxs(Pt,{children:[y,S]}),n[19]=y,n[20]=S,n[21]=N):N=n[21],N});function Jj(t){Gs("ui.sidebar_session_node.render");const{t:e}=At(),{node:n,depth:r=0,groupDirectory:i,projectId:o,archivedBucket:l=!1,pinnedSessionIds:a,expandedParents:u,hasSessionSearchQuery:d,normalizedSessionSearchQuery:h,notifyOnSubtasks:f,editingId:p,setEditingId:g,editTitle:w,setEditTitle:v,handleSaveEdit:x,handleCancelEdit:m,toggleParent:b,handleSessionSelect:y,handleSessionDoubleClick:S,handleShareSession:N,copiedSessionId:C,handleCopyShareUrl:j,handleCopySessionId:A,handleUnshareSession:D,openSidebarMenuKey:I,setOpenSidebarMenuKey:M,createFolderAndStartRename:z,handleDeleteSession:E,handleRestoreSession:H,startSessionWorktreeMenuLoad:B,mobileVariant:O,alwaysShowActions:T,secondaryMeta:k,renderContext:P="project",children:L}=t,Q=$r(Ae=>Ae.toggle),q=cs(Ae=>Ae.getFoldersForScope),te=cs(Ae=>Ae.getSessionFolderId),ae=cs(Ae=>Ae.removeSessionFromFolder),X=cs(Ae=>Ae.addSessionToFolder),Z=Pe(Ae=>Ae.openContextPanelTab),se=c.useMemo(()=>Pn(),[]),me=c.useMemo(()=>zo(),[]),_=c.useContext(Sh),ne=se?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto",ye=se?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",ce=se,F=!l&&!O,re=se?F&&ce?"group-hover:pr-18":F||ce?"group-hover:pr-14":"group-hover:pr-8":F?"group-hover:pr-7 group-focus-within:pr-7":"group-hover:pr-3 group-focus-within:pr-3",fe=F?"pr-13":"pr-7",de=se?F?"pr-18":"pr-14":F?"pr-7":"pr-3",ge=c.useRef(!1),[Te,be]=c.useState(!1),Ee=c.useRef(p);Ee.current=p;const we=c.useRef(null),Y=c.useRef(!1),ve=c.useRef(x);ve.current=x;const[xe,je]=c.useState(w),oe=c.useRef(xe);oe.current=xe;const J=c.useRef(null),K=c.useRef(!1),$=c.useRef(null),le=c.useRef(null),V=n.session,Ce=V,_e=Kt(c.useCallback(Ae=>{if(k?.projectLabel||!o)return null;const Ft=Ae.projects.find(Qt=>Qt.id===o);return Ft?Ft.label?.trim()||Bn(yt(Ft.path)??Ft.path,null)||Ft.path:null},[o,k?.projectLabel])),ke=k?.projectLabel??(_e?Pa(_e):null),Ne=k?.branchLabel??n.worktree?.branch??null,Qe=c.useMemo(()=>{if(se)return null;const Ae=n.worktree?.branch?.trim(),Ft=yt(n.worktree?.path??null);return Ae&&Ft?Ko(Ft,Ae):null},[se,n.worktree]),We=_d(Qe),U=We?`var(--pr-${We.visualState})`:void 0,he=ls(Ae=>Ae.sessionGroupingMode),Re=!!Ne&&(P==="recent"||he==="flat"),Ie=c.useMemo(()=>{if(!We)return null;switch(We.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return We.canMerge===!0||We.mergeableState==="clean"||We.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return We.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[We,e]),rt=Je(Ae=>Ae.currentSessionId===V.id),Ge=yt(V.directory??null)??yt(i??null),ut=o??Ge??null,ct=vh(),ue=Ld(),G=se,Le=hs(Ae=>Ae.enabled),Oe=hs(c.useCallback(Ae=>Ae.selectedIds.has(V.id),[V.id])),qe=hs(Ae=>Ae.toggleSelected),Ue=hs(Ae=>Ae.setRange),st=c.useCallback(Ae=>{const Ft=[],Qt=is=>{is.children.forEach(bs=>{Ft.push(bs.session.id),Qt(bs)})};return Qt(Ae),Ft},[]),wt=c.useCallback(Ae=>{const Ft=[],Qt=is=>{is.children.forEach(bs=>{Ft.push(bs.session),Qt(bs)})};return Qt(Ae),Ft},[]),[Nt,ie]=c.useState(!1),[pe,Ve]=c.useState(!0),ze=`${P}:${l?"archived":"active"}:${V.id}`,He=$d(c.useCallback(Ae=>!!Ae.sessionMemoryState.get(jh(V.id))?.isZombie,[V.id])),at=ha(V.id)?.type??"idle",et=at==="busy"||at==="retry",Xe=kh(V.id,et),dt=ku(V.id),Be=n.worktree??Je.getState().getWorktreeMetadata(V.id)??null,[Se,St]=c.useState([]),[vt,Et]=c.useState(!1),[Ze,it]=c.useState(!1),gt=c.useRef(!1),xt=c.useRef(0),Rt=Ch(V.id,Ge??void 0,{bootstrap:!1}),kt=Nh(Ce),Tt=kt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(ol[kt.status]),"aria-label":e(ol[kt.status]),children:s.jsx(R,{name:"target",className:"h-3 w-3",style:{color:Ah[kt.status]}})}):null,Ot=Ce.title||e("sessions.sidebar.session.untitled"),Vt=n.children.length>0,Yt=Ph(a,Ge,V.id),Ht=ze,Lt=d?!0:u.has(Ht),zt=c.useMemo(()=>cj(n,Lt,Ge),[Lt,n,Ge]),Fe=Dh(zt),Ye=!!Ce.parentID,bt=md(V.id)>0&&(!Ye||f),ft=Ce.time?.updated||Ce.time?.created||Date.now(),lt=Wd(ft),$t=Ih(ft),Zt=I===ze,[Xt,Ns]=c.useState(!1),Jt=Zt||Xt,zs=c.useMemo(()=>So(Ce.title)!==null,[Ce.title]),[Js,rs]=c.useState(!1),Vs=c.useMemo(()=>st(n).length,[st,n]),Es=c.useCallback(async Ae=>{const Ft=[];let Qt=0;for(const is of Ae)try{if(!Ge)throw new Error("Session directory is required for export");const bs=await ct({directory:Ge,sessionID:is.session.id});if(!bs)throw new Error("Session runtime changed during export");const ms=is.session.title||e("sessions.sidebar.session.export.untitledSubagent"),tn=is.session.agent,es=await Es(is.children);Qt+=es.skipped,Ft.push({title:ms,agent:tn,records:bs,children:es.children})}catch{Qt+=st(is).length+1}return{children:Ft,skipped:Qt}},[st,ct,Ge,e]),cn=c.useCallback(Ae=>{Ae<=0||Me.warning(Ae===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Ae}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Ae}))},[e]),gs=c.useCallback(async Ae=>{if(!Ge){Me.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Ft=await ct({directory:Ge,sessionID:V.id}).catch(()=>null);if(!Ft){Me.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Ft.length===0){Me.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Qt,is=0;if(Ae&&n.children.length>0){const es=await Es(n.children);Qt=es.children,is=es.skipped}const bs=wu(Ft,Ce.title??null,Qt),ms=ju(Ce.title??null),tn=await vu(bs,ms);if(tn){Me.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Kx()),onClick:()=>{Ux(tn).then(es=>{es||Me.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),cn(is);return}Su(bs,ms),Me.success(e("sessions.sidebar.session.export.success")),cn(is)},[Es,ct,n.children,Ce.title,V.id,Ge,cn,e]),vs=c.useCallback(async()=>{if(n.children.length>0){Ve(!0),ie(!0);return}await gs(!1)},[gs,n.children.length]),Zs=c.useCallback(()=>{Ge&&Rn("desktop_open_session_mini_chat_window",{sessionId:V.id,directory:Ge,apiBaseUrl:Nn(),clientToken:Lr()}).catch(Ae=>{console.warn("[session-sidebar] failed to open mini chat window",Ae)})},[V.id,Ge]);if(c.useEffect(()=>{if(p!==V.id)return;const Ae=Ft=>{const is=(Ft.target instanceof HTMLElement?Ft.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(V.id)}"]`);le.current&&!is&&ve.current(oe.current)};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},[p,V.id]),c.useLayoutEffect(()=>{if(p!==V.id){J.current===V.id&&(J.current=null);return}J.current!==V.id&&(J.current=V.id,K.current=!0,je(w))},[p,w,V.id]),c.useLayoutEffect(()=>{if(p!==V.id||!K.current)return;const Ae=$.current;!Ae||Ae.value!==w||(K.current=!1,Ae.focus(),Ae.select())},[p,w,xe,V.id]),p===V.id)return s.jsx("div",{style:{paddingLeft:vc+r*lo},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:s.jsxs("form",{ref:le,"data-session-rename-form":V.id,className:"flex w-full items-center gap-2",onSubmit:Ae=>{Ae.preventDefault(),x(xe)},children:[s.jsx("input",{ref:$,value:xe,onChange:Ae=>je(Ae.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:Ae=>{if(Ae.stopPropagation(),Ae.key==="Escape"){m();return}}}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:m,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]})})},V.id);const Rs=Rt.length,As=Fe===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:Fe}),Ps=hj({actionsAlwaysVisible:T&&!se,menuOpen:Jt,hideOnHoverClass:ye}),js=!dt&&!et&&bt&&!rt,Bt=et||js,Wt=e(et?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),ns=s.jsx("span",{className:De("h-1.5 w-1.5 rounded-full",et?"bg-primary":"bg-[var(--status-info)]"),"aria-label":Wt,title:Wt}),us=(et||js)&&Xe,xs=!T&&Vt&&(dt||Bt||Yt),ee=Yt&&!dt&&!Bt,Ke=s.jsx(R,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),W=dt||Bt||ee?s.jsx("span",{style:{left:ra+r*lo},className:De("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",xs?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:dt?s.jsx(R,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e("sessions.sidebar.session.status.movingToWorktree")}):Bt?ns:ee?Ke:null}):null,$e=Vt&&!T&&(dt||Bt||Yt),nt=Vt?s.jsx("span",{role:"button",tabIndex:0,onClick:Ae=>{Ae.stopPropagation(),Ae.currentTarget.blur(),b(Ht)},onKeyDown:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),Ae.stopPropagation(),b(Ht))},style:{minWidth:14,minHeight:14,left:ra+r*lo},className:De("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",$e?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""),"aria-label":e(Lt?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:Lt?s.jsx(R,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(R,{name:"arrow-right-s",className:"h-3 w-3"})}):null,jt=He?s.jsx(R,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Ct=Ae=>{Ae&&Ns(!1),M(Ae?ze:null)},_t=Ae=>{if(!Ae&&we.current){const{id:Ft,title:Qt}=we.current;we.current=null,g(Ft),v(Qt)}},os=Ae=>{Ns(Ae)},qt=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(Zt?null:ze)},en=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Sn=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Zo=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},tr=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Am=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(null),E(V,{archivedBucket:l})},Pm=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(null),E(V,{archivedBucket:l,hardDelete:!0,skipConfirm:!0})},Dm=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Im=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Tm=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),_?.vscode?.executeCommand("openchamber.openSessionInEditor",V.id,Ot)},Wa=Ae=>{if(ge.current){ge.current=!1;return}if(Le){if(Ae?.preventDefault(),Ae?.stopPropagation(),Ae?.shiftKey){const Qt=Array.from(document.querySelectorAll("[data-session-row]")).map(ms=>ms.getAttribute("data-session-row")).filter(ms=>ms!==null&&ms.length>0),is=hs.getState().anchorId,bs=new Map;bs.set(V.id,st(n)),Ue(is,V.id,Qt,ut,bs);return}qe(V.id,ut,st(n));return}Ae?.currentTarget&&Yj(Ae.currentTarget),y(V.id,Ge)},Em=Ae=>{Ae.defaultPrevented||(Ae.target instanceof HTMLElement?Ae.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||Wa(Ae)},Rm=Ae=>{(Ae.button===2||Ae.button===0&&Ae.ctrlKey&&!Le)&&(ge.current=!0)},Mm=Ae=>{O&&Ae.pointerType==="touch"&&be(!0),Ae.button===0&&!rt&&!Le&&!G&&Ge&&!Ai(V.id,Ge).renderable&&ue({directory:Ge,sessionID:V.id}).catch(()=>{})},za=Ae=>{O&&Ae.pointerType==="touch"&&be(!1)},Om=Ae=>{gt.current=Ae,xt.current+=1;const Ft=xt.current;if(!Ae){Et(!1),it(!1);return}const Qt=B({projectId:o??null,sourceDirectory:Ge,currentWorktree:Be});St(Qt.cachedTargets),Et(!0),it(!1),Qt.refreshTargets.then(is=>{!gt.current||xt.current!==Ft||(St(is),Et(!1),it(!1))}).catch(()=>{!gt.current||xt.current!==Ft||(Et(!1),it(!0))})},Va=({Item:Ae,Separator:Ft,Sub:Qt,SubTrigger:is,SubContent:bs})=>s.jsxs(s.Fragment,{children:[s.jsxs(Ae,{onClick:()=>{we.current={id:V.id,title:Ot}},className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsxs(Ae,{onClick:()=>A(V.id),className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Ae,{onClick:()=>Ge&&Q({directory:Ge,sessionId:V.id}),className:"[&>svg]:mr-1",children:[Yt?s.jsx(R,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(R,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(Yt?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),Ce.share?s.jsxs(s.Fragment,{children:[s.jsx(Ae,{onClick:()=>{Ce.share?.url&&j(Ce.share.url,V.id)},className:"[&>svg]:mr-1",children:C===V.id?s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"check",className:"mr-1 h-4 w-4",style:{color:"var(--status-success)"}}),e("sessions.sidebar.session.menu.copied")]}):s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(Ae,{onClick:()=>D(V.id),className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ae,{onClick:()=>N(Ce),className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(Ae,{onClick:()=>{vs()},className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),aj({isSubtaskSession:Ye,archivedBucket:!!l,isVSCode:se,sessionDirectory:Ge})?(()=>{const ms=lj({sessionDirectory:Ge,isStreaming:et,isMovingToWorktree:dt}),tn=qj({targets:Se,isRefreshing:vt,loadFailed:Ze});return s.jsxs(Qt,{onOpenChange:Om,children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs(is,{disabled:ms,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":V.id,children:[s.jsx(R,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(It,{side:"right",className:"max-w-72",children:e(dt?"sessions.sidebar.session.moveToWorktree.tooltipMoving":et?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(bs,{className:"min-w-[220px]","data-session-worktree-submenu":V.id,children:[Se.map(es=>{const sn=yt(es.metadata.path??null)??es.metadata.path,Sr=es.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):es.metadata.label||es.metadata.branch||es.metadata.name||es.metadata.path,fs=es.isCurrent||es.metadata.worktreeStatus!=="ready";return s.jsxs(Ae,{disabled:fs,title:es.metadata.path,"data-session-worktree-target":sn,onClick:()=>{fs||!Ge||Ui({kind:"existing",root:Ce,descendants:wt(n),sourceDirectory:Ge,destination:es.metadata,messages:zi(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:Sr}),es.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),es.isCurrent?s.jsx(R,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},sn)}),tn.refreshState==="loading"?s.jsx(Ae,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,tn.refreshState==="error"?s.jsx(Ae,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(Ft,{}),s.jsxs(Ae,{disabled:ms,"data-session-worktree-new-action":"true",onClick:()=>{ms||!Ge||Ui({kind:"quick",root:Ce,descendants:wt(n),sourceDirectory:Ge,messages:zi(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,zs?s.jsxs(Ae,{onClick:()=>rs(!0),className:"[&>svg]:mr-1",children:[s.jsx(Uj,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,Ge&&!l?(()=>{const ms=[],tn=fs=>{const ks=yt(fs??null);ks&&!ms.includes(ks)&&ms.push(ks)};if(o&&!se){const fs=Kt.getState().projects.find(sr=>sr.id===o),ks=yt(fs?.path??null);tn(ks),ks&&(Je.getState().availableWorktreesByProject.get(ks)??[]).forEach(sr=>tn(sr.path))}tn(zd(Ge)),tn(Ge);const es=ms.flatMap(fs=>q(fs).map(ks=>({scope:fs,folder:ks}))),sn=es.find(({scope:fs,folder:ks})=>te(fs,V.id)===ks.id)??null,Sr=ms[0]??Ge;return s.jsxs(s.Fragment,{children:[s.jsx(Ft,{}),s.jsxs(Qt,{children:[s.jsxs(is,{className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(bs,{className:"min-w-[180px]",children:[es.length===0?s.jsx(Ae,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):es.map(({scope:fs,folder:ks})=>{const sr=sn?.folder.id===ks.id;return s.jsxs(Ae,{onClick:()=>{if(sr){ae(fs,V.id);return}sn&&sn.scope!==fs&&ae(sn.scope,V.id),X(fs,ks.id,V.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:ks.name}),sr?s.jsx(R,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ks.id)}),s.jsx(Ft,{}),s.jsxs(Ae,{onClick:()=>{const fs=z(Sr);fs&&(Y.current=!0,sn&&sn.scope!==Sr&&ae(sn.scope,V.id),X(Sr,fs.id,V.id))},children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),sn?s.jsxs(Ae,{onClick:()=>{ae(sn.scope,V.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,se?null:s.jsxs(Ae,{disabled:!Ge,onClick:()=>{Ge&&Z(Ge,{mode:"chat",dedupeKey:`session:${V.id}`,label:Ot,sessionTitleFallback:Ot})},className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),me?s.jsxs(Ae,{disabled:!Ge,onClick:Zs,className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Ft,{}),l?null:s.jsxs(Ae,{className:"[&>svg]:mr-1",onClick:()=>E(V,{archivedBucket:l}),children:[s.jsx(R,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),l?s.jsxs(Ae,{className:"[&>svg]:mr-1",onClick:()=>H(V),children:[s.jsx(R,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Ae,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>E(V,{archivedBucket:l,hardDelete:!0}),children:[s.jsx(R,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Bm=s.jsx(Ys,{align:"end",className:"min-w-[180px]",finalFocus:()=>Y.current?(Y.current=!1,!1):!Ee.current,children:Va({Item:Ut,Separator:Os,Sub:Eh,SubTrigger:Rh,SubContent:Mh})}),Fm=s.jsx(_i,{children:s.jsx(Li,{className:"app-region-no-drag z-50",children:s.jsx($i,{"data-slot":"dropdown-menu-content",finalFocus:()=>Y.current?(Y.current=!1,!1):!Ee.current,style:{color:"var(--surface-elevated-foreground)"},className:De(Si,"min-w-[180px]"),children:Va({Item:({className:Ae,...Ft})=>s.jsx(cu,{className:De(hd,Ae),...Ft}),Separator:({className:Ae,...Ft})=>s.jsx(lu,{className:De(fd,Ae),...Ft}),Sub:Bg,SubTrigger:({className:Ae,children:Ft,...Qt})=>s.jsxs(Fg,{className:De(Th,Ae),...Qt,children:[Ft,s.jsx(R,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Ae,children:Ft,...Qt})=>s.jsx(_i,{children:s.jsx(Li,{className:"app-region-no-drag z-50",children:s.jsx($i,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:De(Si,Ae),...Qt,children:Ft})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(rj,{sessionId:V.id,sessionDirectory:Ge??null,sessionTitle:Ot,children:s.jsxs(uu,{open:Xt,onOpenChange:os,onOpenChangeComplete:_t,children:[s.jsxs(du,{render:s.jsx("div",{"data-session-row":V.id,"data-session-scope":ut??"","data-session-archived":l?"1":"0","aria-current":rt?"page":void 0,onClick:Em,style:{paddingLeft:vc+r*lo},className:De("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",rt&&!Oe&&"bg-primary/10",Oe&&"bg-interactive-selection")}),children:[W,nt,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onPointerDown:Mm,onPointerUp:za,onPointerCancel:za,onMouseDown:Rm,onClick:Ae=>Wa(Ae),onDoubleClick:Ae=>{Ae.stopPropagation(),S(V.id,Ot)},className:De("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none transition-[padding]",Te&&"bg-interactive-hover/70",T?se?re:fe:Jt?de:re),children:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:De("block min-w-0 flex-1 truncate typography-ui-label font-normal",rt?"text-primary":bt?"text-foreground":"text-foreground/80"),children:po(Ot,h)}),!l&&Ge&&(P==="recent"||he==="flat"&&n.worktree&&yt(n.worktree.path)!==yt(n.worktree.projectDirectory))?s.jsx(Kr,{directory:Ge,className:T?void 0:Jt?"mr-1":se?"group-hover:mr-1":"group-hover:mr-1 group-focus-within:mr-1"}):null,T?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:us?s.jsx(wl,{sessionId:V.id,running:et}):s.jsxs(s.Fragment,{children:[Tt,Re?s.jsx(R,{name:"git-branch",className:De("h-3 w-3",!U&&"text-muted-foreground/60"),style:U?{color:U}:void 0}):null,$t]})}):us||Tt||Re||P==="recent"?s.jsx("div",{className:De("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",Jt?"hidden":se?"group-hover:hidden":"group-hover:hidden group-focus-within:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:us?s.jsx(wl,{sessionId:V.id,running:et,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[Tt,Re?s.jsx(R,{name:"git-branch",className:De("h-3 w-3",!U&&"text-muted-foreground/60"),style:U?{color:U}:void 0}):null,P==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:$t}):null]})})}):null,Rs>0?s.jsxs("span",{className:De("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",Ps),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(R,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Rs})]}):null,Fe>0?s.jsxs("span",{className:De("inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",Ps),title:As,"aria-label":As,children:[s.jsx(R,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Fe})]}):null]})})}),se?null:s.jsx(It,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:Ot}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:lt,children:$t})]}),ke?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(R,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:ke})]}):null,Ne?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(R,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:U?{color:U}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:Ne})]}):null,We&&Ie?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(R,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:U?{color:U}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:U?{color:U}:void 0,children:["#",We.number," · ",Ie]})]}):null]})})]})}),jt&&!O?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:jt}):null,s.jsxs("div",{className:De("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",Jt||T&&!se?"opacity-100":De("opacity-0",ne)),children:[F?s.jsx(Xj,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:T?"h-6 w-6":"h-4 w-4",iconSizeClass:T?"h-3.5 w-3.5":"h-2.5 w-2.5",onPointerDown:Zo,onMouseDown:tr,onArchive:Am,onDelete:Pm}):null,ce?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",T?"h-6 w-6":"h-4 w-4"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Dm,onMouseDown:Im,onClick:Tm,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(R,{name:"external-link",className:De(T?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),s.jsx(It,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(Xs,{open:Zt,onOpenChange:Ct,onOpenChangeComplete:_t,children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",T?"h-6 w-6 opacity-100":Jt?"h-4 w-4 opacity-100":De("h-4 w-4 opacity-0",ne)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:en,onMouseDown:Sn,onClick:qt,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(R,{name:"more-2",className:De(T?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),Bm]})]})]}),Fm]})}),Vt&&Lt?L:null,s.jsx(ws,{open:Nt,onOpenChange:ie,children:s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Ts,{children:Vs===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:Vs}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:Vs})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:pe,onChange:Ae=>Ve(Ae.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(bn,{children:[s.jsx(pt,{type:"button",onClick:()=>ie(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(pt,{type:"button",onClick:()=>{ie(!1),gs(pe)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),zs?s.jsx(Vj,{session:Ce,open:Js,onOpenChange:rs}):null]},V.id)}const jc=t=>yt(t.session.directory??null),Zj=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),e2=t=>{if(!t.openSidebarMenuKey)return null;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},kc=t=>t.menuOpenSessionId??e2(t),co=(t,e,n)=>e?n.has(t.node.session.id)?!0:Hn(t.node,e):!1,oa=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(oa(t.children[l],e.children[l],n,r,i))return!0;return!1},t2=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return oa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||oa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},s2=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.share?.url===e.share?.url&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived,n2=(t,e)=>{if(t.node.session.id!==e.node.session.id||!s2(t.node.session,e.node.session)||!Qj(t.node,e.node))return"node";if(t.depth!==e.depth)return"depth";if(t.groupDirectory!==e.groupDirectory)return"groupDirectory";if(t.projectId!==e.projectId)return"projectId";if(t.archivedBucket!==e.archivedBucket)return"archivedBucket";if((t.renderContext??"project")!==(e.renderContext??"project"))return"renderContext";if(t.mobileVariant!==e.mobileVariant)return"mobileVariant";if(t.alwaysShowActions!==e.alwaysShowActions)return"alwaysShowActions";if(t.hasSessionSearchQuery!==e.hasSessionSearchQuery)return"hasSessionSearchQuery";if(t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery)return"normalizedSessionSearchQuery";if(t.notifyOnSubtasks!==e.notifyOnSubtasks)return"notifyOnSubtasks";if(t.nodeStructureKey!==e.nodeStructureKey)return"nodeStructureKey";if(t.relativeTimeTick!==e.relativeTimeTick)return"relativeTimeTick";if(jc(t.node)!==jc(e.node))return"nodeDirectory";if(!Zj(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&am(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&t2(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(co(t,t.editingId,t.subtreeContainsEditing)||co(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editTitle!==e.editTitle&&(co(t,t.editingId,t.subtreeContainsEditing)||co(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.copiedSessionId!==e.copiedSessionId&&(Hn(t.node,t.copiedSessionId)||Hn(e.node,e.copiedSessionId)))return"copiedSessionId";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=kc(t),i=kc(e);if(Hn(t.node,r)||Hn(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleShareSession===e.handleShareSession&&t.handleCopyShareUrl===e.handleCopyShareUrl&&t.handleCopySessionId===e.handleCopySessionId&&t.handleUnshareSession===e.handleUnshareSession&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.children===e.children?null:"callbacks"},r2=(t,e)=>{const n=n2(t,e);return n===null?!0:(Gs(`ui.sidebar_session_node.props_changed.${n}`),!1)},o2=c.memo(Jj,r2);function i2(t){return t.stopPropagation()}const a2=t=>{const{t:e}=At(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=Pe(Z=>Z.setSessionSwitcherOpen),a=Je(Z=>Z.setCurrentSession),u=Je(Z=>Z.updateSessionTitle),d=Je(Z=>Z.shareSession),h=Je(Z=>Z.unshareSession),f=Je(Z=>Z.deleteSession),p=Je(Z=>Z.deleteSessions),g=Je(Z=>Z.archiveSession),w=Je(Z=>Z.archiveSessions),v=Je(Z=>Z.unarchiveSession),{mobileVariant:x,allowReselect:m,onSessionSelected:b,isSessionSearchOpen:y,sessionSearchQuery:S,setSessionSearchQuery:N,setIsSessionSearchOpen:C,descendantIds:j,showDeletionDialog:A,setDeleteSessionConfirm:D,setEditingId:I,setEditTitle:M,setCopiedSessionId:z}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const E=c.useCallback((Z,se)=>{wi("navigation.session_select"),Pe.getState().closeMainSurfaces();const me=()=>{!y&&S.length===0||(N(""),C(!1))};if(x&&l(!1),Z===Je.getState().currentSessionId){m&&b?.(Z),me();return}wi("navigation.session_state_set"),a(Z,se??null),b?.(Z),me()},[m,y,x,b,S,a,C,N,l]),H=c.useCallback((Z,se)=>{I(Z),M(se)},[M,I]),B=c.useCallback(async Z=>{const se=r.current;if(!se)return;const me=(Z??i.current).trim();me&&await u(se,me),I(null),M("")},[M,I,u]),O=c.useCallback(()=>{I(null),M("")},[M,I]),T=c.useCallback(async(Z,se)=>{try{return(await pn(Z)).ok?(z(se),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{z(null),n.current=null},2e3),!0):!1}catch{return!1}},[z]),k=c.useCallback(async Z=>{const se=await d(Z.id);if(!se?.share?.url){Me.error(e("sessions.sidebar.session.share.error"));return}const me=await T(se.share.url,Z.id);Me[me?"success":"warning"](e("sessions.sidebar.session.share.successTitle"),{description:e(me?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},[T,d,e]),P=c.useCallback((Z,se)=>{T(Z,se).then(me=>{me||Me.error(e("sessions.sidebar.session.share.copyUrlError"))})},[T,e]),L=c.useCallback(Z=>{pn(Z).then(se=>{if(se.ok){Me.success(e("sessions.sidebar.session.copyId.success"));return}Me.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Me.error(e("sessions.sidebar.session.copyId.error")))},[e]),Q=c.useCallback(async Z=>{await h(Z)?Me.success(e("sessions.sidebar.session.unshare.success")):Me.error(e("sessions.sidebar.session.unshare.error"))},[e,h]),q=c.useCallback(async(Z,se,me)=>{const _=se?.archivedBucket===!0||se?.hardDelete===!0,ne=me?.descendantIds??j;if(ne.length===0){(_?await f(Z.id):await g(Z.id))?Me.success(e(_?"sessions.sidebar.session.delete.success":"sessions.sidebar.session.archive.success")):Me.error(e(_?"sessions.sidebar.session.delete.error":"sessions.sidebar.session.archive.error"));return}const ye=[Z.id,...ne];if(_){const{deletedIds:re,failedIds:fe}=await p(ye);if(fe.length===0){const de=re.length;Me.success(de===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:de}):e("sessions.sidebar.bulkActions.deletedPlural",{count:de}))}else Me.error(e("sessions.sidebar.session.delete.error"));return}const{archivedIds:ce,failedIds:F}=await w(ye);ce.length>0&&Me.success(ce.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:ce.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:ce.length})),F.length>0&&Me.error(F.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:F.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:F.length}))},[g,w,f,p,j,e]),te=c.useCallback((Z,se)=>{const me=se?.archivedBucket===!0||se?.hardDelete===!0,_=[...j];if(!A||se?.skipConfirm===!0){q(Z,se,{descendantIds:_});return}D({session:Z,descendantCount:_.length,descendantIds:_,archivedBucket:me})},[j,q,D,A]),ae=c.useCallback(async()=>{const Z=o.current;if(!Z)return;const{session:se,archivedBucket:me,descendantIds:_}=Z;D(null),await q(se,{archivedBucket:me},{descendantIds:_})},[q,D]),X=c.useCallback(async Z=>{await v(Z.id)?Me.success(e("sessions.sidebar.session.restore.success")):Me.error(e("sessions.sidebar.session.restore.error"))},[e,v]);return c.useMemo(()=>({handleSessionSelect:E,handleSessionDoubleClick:H,handleSaveEdit:B,handleCancelEdit:O,handleShareSession:k,handleCopyShareUrl:P,handleCopySessionId:L,handleUnshareSession:Q,handleDeleteSession:te,handleRestoreSession:X,confirmDeleteSession:ae}),[O,L,P,te,X,B,H,E,k,Q,ae])};function l2(t){const e=tt.c(71),{t:n}=At(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let u,d,h,f,p,g,w,v,x,m;if(e[0]!==i||e[1]!==n||e[2]!==r){const P=n("sessions.sidebar.session.untitled");f=ws,x=!!r,e[13]!==i?(m=Q=>{Q||i(null)},e[13]=i,e[14]=m):m=e[14],h=Ss,w=!1,v="max-w-sm gap-5",d=Ws;let L;e[15]!==n||e[16]!==r?.archivedBucket?(L=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=L):L=e[17],e[18]!==L?(g=s.jsx(Is,{children:L}),e[18]=L,e[19]=g):g=e[19],u=Ts,p=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||P,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||P,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||P,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||P,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||P}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||P}),e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=d,e[5]=h,e[6]=f,e[7]=p,e[8]=g,e[9]=w,e[10]=v,e[11]=x,e[12]=m}else u=e[3],d=e[4],h=e[5],f=e[6],p=e[7],g=e[8],w=e[9],v=e[10],x=e[11],m=e[12];let b;e[20]!==u||e[21]!==p?(b=s.jsx(u,{children:p}),e[20]=u,e[21]=p,e[22]=b):b=e[22];let y;e[23]!==d||e[24]!==g||e[25]!==b?(y=s.jsxs(d,{children:[g,b]}),e[23]=d,e[24]=g,e[25]=b,e[26]=y):y=e[26];let S;e[27]!==l||e[28]!==o?(S=()=>l(!o),e[27]=l,e[28]=o,e[29]=S):S=e[29];const N=!o;let C;e[30]!==o?(C=o?s.jsx(R,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(R,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=C):C=e[31];let j;e[32]!==n?(j=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=j):j=e[33];let A;e[34]!==C||e[35]!==j||e[36]!==S||e[37]!==N?(A=s.jsxs("button",{type:"button",onClick:S,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":N,children:[C,j]}),e[34]=C,e[35]=j,e[36]=S,e[37]=N,e[38]=A):A=e[38];let D;e[39]!==i?(D=()=>i(null),e[39]=i,e[40]=D):D=e[40];let I;e[41]!==n?(I=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=I):I=e[42];let M;e[43]!==D||e[44]!==I?(M=s.jsx("button",{type:"button",onClick:D,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:I}),e[43]=D,e[44]=I,e[45]=M):M=e[45];let z;e[46]!==a?(z=()=>{a()},e[46]=a,e[47]=z):z=e[47];let E;e[48]!==n||e[49]!==r?.archivedBucket?(E=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=E):E=e[50];let H;e[51]!==z||e[52]!==E?(H=s.jsx("button",{type:"button",onClick:z,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:E}),e[51]=z,e[52]=E,e[53]=H):H=e[53];let B;e[54]!==M||e[55]!==H?(B=s.jsxs("div",{className:"flex items-center gap-2",children:[M,H]}),e[54]=M,e[55]=H,e[56]=B):B=e[56];let O;e[57]!==A||e[58]!==B?(O=s.jsxs(bn,{className:"w-full sm:items-center sm:justify-between",children:[A,B]}),e[57]=A,e[58]=B,e[59]=O):O=e[59];let T;e[60]!==h||e[61]!==w||e[62]!==O||e[63]!==v||e[64]!==y?(T=s.jsxs(h,{showCloseButton:w,className:v,children:[y,O]}),e[60]=h,e[61]=w,e[62]=O,e[63]=v,e[64]=y,e[65]=T):T=e[65];let k;return e[66]!==f||e[67]!==T||e[68]!==x||e[69]!==m?(k=s.jsx(f,{open:x,onOpenChange:m,children:T}),e[66]=f,e[67]=T,e[68]=x,e[69]=m,e[70]=k):k=e[70],k}function c2(t){const e=tt.c(57),{t:n}=At(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,u=r?.archivedBucket===!0,d=r?.sessionCount??0;let h;e[0]!==u||e[1]!==d||e[2]!==n?(h=n(u?d===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":d===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=u,e[1]=d,e[2]=n,e[3]=h):h=e[3];const f=h;let p;e[4]!==u||e[5]!==d||e[6]!==n?(p=u?d===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:d}):d===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:d}),e[4]=u,e[5]=d,e[6]=n,e[7]=p):p=e[7];const g=p,w=!!r;let v;e[8]!==i?(v=k=>{k||i(null)},e[8]=i,e[9]=v):v=e[9];let x;e[10]!==f?(x=s.jsx(Is,{children:f}),e[10]=f,e[11]=x):x=e[11];let m;e[12]!==g?(m=s.jsx(Ts,{children:g}),e[12]=g,e[13]=m):m=e[13];let b;e[14]!==x||e[15]!==m?(b=s.jsxs(Ws,{children:[x,m]}),e[14]=x,e[15]=m,e[16]=b):b=e[16];let y;e[17]!==l||e[18]!==o?(y=()=>l(!o),e[17]=l,e[18]=o,e[19]=y):y=e[19];const S=!o;let N;e[20]!==o?(N=o?s.jsx(R,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(R,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=N):N=e[21];let C;e[22]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=C):C=e[23];let j;e[24]!==C||e[25]!==y||e[26]!==S||e[27]!==N?(j=s.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":S,children:[N,C]}),e[24]=C,e[25]=y,e[26]=S,e[27]=N,e[28]=j):j=e[28];let A;e[29]!==i?(A=()=>i(null),e[29]=i,e[30]=A):A=e[30];let D;e[31]!==n?(D=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=D):D=e[32];let I;e[33]!==A||e[34]!==D?(I=s.jsx("button",{type:"button",onClick:A,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:D}),e[33]=A,e[34]=D,e[35]=I):I=e[35];let M;e[36]!==a?(M=()=>{a()},e[36]=a,e[37]=M):M=e[37];let z;e[38]!==u||e[39]!==n?(z=n(u?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=u,e[39]=n,e[40]=z):z=e[40];let E;e[41]!==M||e[42]!==z?(E=s.jsx("button",{type:"button",onClick:M,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:z}),e[41]=M,e[42]=z,e[43]=E):E=e[43];let H;e[44]!==I||e[45]!==E?(H=s.jsxs("div",{className:"flex items-center gap-2",children:[I,E]}),e[44]=I,e[45]=E,e[46]=H):H=e[46];let B;e[47]!==j||e[48]!==H?(B=s.jsxs(bn,{className:"w-full sm:items-center sm:justify-between",children:[j,H]}),e[47]=j,e[48]=H,e[49]=B):B=e[49];let O;e[50]!==B||e[51]!==b?(O=s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[b,B]}),e[50]=B,e[51]=b,e[52]=O):O=e[52];let T;return e[53]!==w||e[54]!==O||e[55]!==v?(T=s.jsx(ws,{open:w,onOpenChange:v,children:O}),e[53]=w,e[54]=O,e[55]=v,e[56]=T):T=e[56],T}function d2(t){const e=tt.c(36),{t:n}=At(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=N=>{N||i(null)},e[0]=i,e[1]=a):a=e[1];let u;e[2]!==n?(u=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=u):u=e[3];let d;e[4]!==u?(d=s.jsx(Is,{children:u}),e[4]=u,e[5]=d):d=e[5];let h;e[6]!==n||e[7]!==r?(h=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=h):h=e[8];let f;e[9]!==h?(f=s.jsx(Ts,{children:h}),e[9]=h,e[10]=f):f=e[10];let p;e[11]!==d||e[12]!==f?(p=s.jsxs(Ws,{children:[d,f]}),e[11]=d,e[12]=f,e[13]=p):p=e[13];let g;e[14]!==i?(g=()=>i(null),e[14]=i,e[15]=g):g=e[15];let w;e[16]!==n?(w=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=w):w=e[17];let v;e[18]!==g||e[19]!==w?(v=s.jsx("button",{type:"button",onClick:g,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:w}),e[18]=g,e[19]=w,e[20]=v):v=e[20];let x;e[21]!==n?(x=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=x):x=e[22];let m;e[23]!==o||e[24]!==x?(m=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:x}),e[23]=o,e[24]=x,e[25]=m):m=e[25];let b;e[26]!==m||e[27]!==v?(b=s.jsxs(bn,{children:[v,m]}),e[26]=m,e[27]=v,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==p?(y=s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,b]}),e[29]=b,e[30]=p,e[31]=y):y=e[31];let S;return e[32]!==l||e[33]!==a||e[34]!==y?(S=s.jsx(ws,{open:l,onOpenChange:a,children:y}),e[32]=l,e[33]=a,e[34]=y,e[35]=S):S=e[35],S}const u2=new Set;function _o(t){const e=tt.c(142),{node:n,depth:r,groupDirectory:i,projectId:o,archivedBucket:l,secondaryMeta:a,renderContext:u,renderExtras:d,pinnedSessionIds:h,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:m,setEditTitle:b,toggleParent:y,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:j,isSessionSearchOpen:A,sessionSearchQuery:D,setSessionSearchQuery:I,setIsSessionSearchOpen:M,deleteSessionConfirm:z,setDeleteSessionConfirm:E,startFolderRename:H,copiedSessionId:B,setCopiedSessionId:O,startSessionWorktreeMenuLoad:T,mobileVariant:k,alwaysShowActions:P}=t,L=r===void 0?0:r,Q=l===void 0?!1:l,q=u===void 0?"project":u,te=cs(p2),ae=cs(h2),X=Pe(f2),Z=Pe(m2);let se;if(e[0]!==n){se=[];const We=U=>U.children.forEach(he=>{se.push(he.session.id),We(he)});We(n),e[0]=n,e[1]=se}else se=e[1];const me=se.join(`
|
|
922
|
-
`);let _;e[2]!==me?(_=me?me.split(`
|
|
923
|
-
`):[],e[2]=me,e[3]=_):_=e[3];const ne=_;let ye;e[4]!==te||e[5]!==H||e[6]!==ae?(ye=(We,U)=>{if(!We)return null;U&&cs.getState().collapsedFolderIds.has(U)&&ae(U);const he=te(We,"New folder",U);return H(We,he),he},e[4]=te,e[5]=H,e[6]=ae,e[7]=ye):ye=e[7];const ce=ye;let F;e[8]!==C||e[9]!==B||e[10]!==z||e[11]!==ne||e[12]!==m||e[13]!==v||e[14]!==A||e[15]!==k||e[16]!==j||e[17]!==D||e[18]!==O||e[19]!==E||e[20]!==b||e[21]!==x||e[22]!==M||e[23]!==I||e[24]!==X?(F={mobileVariant:k,allowReselect:C,onSessionSelected:j,isSessionSearchOpen:A,sessionSearchQuery:D,setSessionSearchQuery:I,setIsSessionSearchOpen:M,descendantIds:ne,showDeletionDialog:X,setDeleteSessionConfirm:E,deleteSessionConfirm:z,editingId:v,setEditingId:x,editTitle:m,setEditTitle:b,copiedSessionId:B,setCopiedSessionId:O},e[8]=C,e[9]=B,e[10]=z,e[11]=ne,e[12]=m,e[13]=v,e[14]=A,e[15]=k,e[16]=j,e[17]=D,e[18]=O,e[19]=E,e[20]=b,e[21]=x,e[22]=M,e[23]=I,e[24]=X,e[25]=F):F=e[25];const re=a2(F),fe=d?.childRenderExtrasFor,de=n.session.directory??i;let ge;e[26]!==Q||e[27]!==o||e[28]!==q||e[29]!==de?(ge={groupDirectory:de,projectId:o,archivedBucket:Q,renderContext:q},e[26]=Q,e[27]=o,e[28]=q,e[29]=de,e[30]=ge):ge=e[30];const Te=ge,be=re.handleSaveEdit,Ee=re.handleCancelEdit,we=re.handleSessionSelect,Y=re.handleSessionDoubleClick,ve=re.handleShareSession,xe=re.handleCopyShareUrl,je=re.handleCopySessionId,oe=re.handleUnshareSession,J=re.handleDeleteSession,K=re.handleRestoreSession,$=d?.subtreeContainsEditing??u2,le=d?.menuOpenSessionId??null,V=d?.nodeStructureKey??"",Ce=d?.relativeTimeTick;let _e;if(e[31]!==C||e[32]!==P||e[33]!==Te||e[34]!==fe||e[35]!==B||e[36]!==z||e[37]!==L||e[38]!==m||e[39]!==v||e[40]!==f||e[41]!==p||e[42]!==A||e[43]!==k||e[44]!==n.children||e[45]!==g||e[46]!==w||e[47]!==j||e[48]!==S||e[49]!==h||e[50]!==D||e[51]!==O||e[52]!==E||e[53]!==b||e[54]!==x||e[55]!==M||e[56]!==N||e[57]!==I||e[58]!==H||e[59]!==T||e[60]!==y){let We;e[62]!==C||e[63]!==P||e[64]!==Te||e[65]!==fe||e[66]!==B||e[67]!==z||e[68]!==L||e[69]!==m||e[70]!==v||e[71]!==f||e[72]!==p||e[73]!==A||e[74]!==k||e[75]!==g||e[76]!==w||e[77]!==j||e[78]!==S||e[79]!==h||e[80]!==D||e[81]!==O||e[82]!==E||e[83]!==b||e[84]!==x||e[85]!==M||e[86]!==N||e[87]!==I||e[88]!==H||e[89]!==T||e[90]!==y?(We=U=>s.jsx(_o,{node:U,pinnedSessionIds:h,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:m,copiedSessionId:B,setEditTitle:b,toggleParent:y,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:j,isSessionSearchOpen:A,sessionSearchQuery:D,setSessionSearchQuery:I,setIsSessionSearchOpen:M,deleteSessionConfirm:z,setDeleteSessionConfirm:E,startFolderRename:H,setCopiedSessionId:O,startSessionWorktreeMenuLoad:T,mobileVariant:k,alwaysShowActions:P,depth:L+1,...Te,renderExtras:fe?.(U)},U.session.id),e[62]=C,e[63]=P,e[64]=Te,e[65]=fe,e[66]=B,e[67]=z,e[68]=L,e[69]=m,e[70]=v,e[71]=f,e[72]=p,e[73]=A,e[74]=k,e[75]=g,e[76]=w,e[77]=j,e[78]=S,e[79]=h,e[80]=D,e[81]=O,e[82]=E,e[83]=b,e[84]=x,e[85]=M,e[86]=N,e[87]=I,e[88]=H,e[89]=T,e[90]=y,e[91]=We):We=e[91],_e=n.children.map(We),e[31]=C,e[32]=P,e[33]=Te,e[34]=fe,e[35]=B,e[36]=z,e[37]=L,e[38]=m,e[39]=v,e[40]=f,e[41]=p,e[42]=A,e[43]=k,e[44]=n.children,e[45]=g,e[46]=w,e[47]=j,e[48]=S,e[49]=h,e[50]=D,e[51]=O,e[52]=E,e[53]=b,e[54]=x,e[55]=M,e[56]=N,e[57]=I,e[58]=H,e[59]=T,e[60]=y,e[61]=_e}else _e=e[61];let ke;e[92]!==P||e[93]!==Q||e[94]!==B||e[95]!==ce||e[96]!==L||e[97]!==m||e[98]!==v||e[99]!==f||e[100]!==i||e[101]!==p||e[102]!==k||e[103]!==n||e[104]!==g||e[105]!==w||e[106]!==S||e[107]!==h||e[108]!==o||e[109]!==q||e[110]!==a||e[111]!==re.handleCancelEdit||e[112]!==re.handleCopySessionId||e[113]!==re.handleCopyShareUrl||e[114]!==re.handleDeleteSession||e[115]!==re.handleRestoreSession||e[116]!==re.handleSaveEdit||e[117]!==re.handleSessionDoubleClick||e[118]!==re.handleSessionSelect||e[119]!==re.handleShareSession||e[120]!==re.handleUnshareSession||e[121]!==b||e[122]!==x||e[123]!==N||e[124]!==T||e[125]!==$||e[126]!==le||e[127]!==V||e[128]!==Ce||e[129]!==_e||e[130]!==y?(ke=s.jsx(o2,{expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:m,setEditTitle:b,handleSaveEdit:be,handleCancelEdit:Ee,toggleParent:y,handleSessionSelect:we,handleSessionDoubleClick:Y,handleShareSession:ve,copiedSessionId:B,handleCopyShareUrl:xe,handleCopySessionId:je,handleUnshareSession:oe,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,createFolderAndStartRename:ce,handleDeleteSession:J,handleRestoreSession:K,startSessionWorktreeMenuLoad:T,mobileVariant:k,alwaysShowActions:P,pinnedSessionIds:h,node:n,depth:L,groupDirectory:i,projectId:o,archivedBucket:Q,secondaryMeta:a,renderContext:q,subtreeContainsEditing:$,menuOpenSessionId:le,nodeStructureKey:V,relativeTimeTick:Ce,children:_e}),e[92]=P,e[93]=Q,e[94]=B,e[95]=ce,e[96]=L,e[97]=m,e[98]=v,e[99]=f,e[100]=i,e[101]=p,e[102]=k,e[103]=n,e[104]=g,e[105]=w,e[106]=S,e[107]=h,e[108]=o,e[109]=q,e[110]=a,e[111]=re.handleCancelEdit,e[112]=re.handleCopySessionId,e[113]=re.handleCopyShareUrl,e[114]=re.handleDeleteSession,e[115]=re.handleRestoreSession,e[116]=re.handleSaveEdit,e[117]=re.handleSessionDoubleClick,e[118]=re.handleSessionSelect,e[119]=re.handleShareSession,e[120]=re.handleUnshareSession,e[121]=b,e[122]=x,e[123]=N,e[124]=T,e[125]=$,e[126]=le,e[127]=V,e[128]=Ce,e[129]=_e,e[130]=y,e[131]=ke):ke=e[131];let Ne;e[132]!==z||e[133]!==n.session.id||e[134]!==re.confirmDeleteSession||e[135]!==E||e[136]!==Z||e[137]!==X?(Ne=z?.session.id===n.session.id?s.jsx(l2,{value:z,setValue:E,showDeletionDialog:X,setShowDeletionDialog:Z,onConfirm:re.confirmDeleteSession}):null,e[132]=z,e[133]=n.session.id,e[134]=re.confirmDeleteSession,e[135]=E,e[136]=Z,e[137]=X,e[138]=Ne):Ne=e[138];let Qe;return e[139]!==ke||e[140]!==Ne?(Qe=s.jsxs(s.Fragment,{children:[ke,Ne]}),e[139]=ke,e[140]=Ne,e[141]=Qe):Qe=e[141],Qe}function m2(t){return t.setShowDeletionDialog}function f2(t){return t.showDeletionDialog}function h2(t){return t.toggleFolderCollapse}function p2(t){return t.createFolder}const g2=50,x2=28,Cc=[],b2=t=>{const e=tt.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=om(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Pr=(t,e)=>e?t.sessions.some(n=>Hn(n,e)):!1,y2=(t,e,n)=>t.sessions.some(r=>am(r,r,e,n,t.directory,t.directory)),w2=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},S2=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},v2=(t,e)=>{if(t.group!==e.group||t.groupKey!==e.groupKey||t.projectId!==e.projectId||t.hideGroupLabel!==e.hideGroupLabel||t.compactBodyPadding!==e.compactBodyPadding||t.groupSearchDataByGroup!==e.groupSearchDataByGroup||t.visibleSessionCount!==e.visibleSessionCount||t.sessionBatchSize!==e.sessionBatchSize||t.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&y2(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&w2(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&S2(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Pr(e.group,t.editingId)||Pr(e.group,e.editingId))||t.editTitle!==e.editTitle&&Pr(e.group,e.editingId)||t.copiedSessionId!==e.copiedSessionId&&(Pr(e.group,t.copiedSessionId)||Pr(e.group,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Hr(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Hr(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??yt(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.scrollContainerRef===e.scrollContainerRef&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.isSessionSearchOpen===e.isSessionSearchOpen&&t.sessionSearchQuery===e.sessionSearchQuery&&t.setSessionSearchQuery===e.setSessionSearchQuery&&t.setIsSessionSearchOpen===e.setIsSessionSearchOpen&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.setCopiedSessionId===e.setCopiedSessionId&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function j2(t){const{t:e}=At(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,groupSearchDataByGroup:u,visibleSessionCount:d,sessionBatchSize:h,collapsedGroups:f,hideDirectoryControls:p,showMoreGroupSessions:g,resetGroupSessionLimit:w,mobileVariant:v,alwaysShowActions:x,activeProjectId:m,setActiveProjectIdOnly:b,setSessionSwitcherOpen:y,openNewSessionDraft:S,pinnedSessionIds:N,sessionOrderIndex:C,notifyOnSubtasks:j,onToggleCollapsedGroup:A,dragHandleProps:D,compactBodyPadding:I=!1,scrollContainerRef:M,expandedParents:z,editingId:E,openSidebarMenuKey:H,editTitle:B,copiedSessionId:O,folderRename:T,setFolderRenameDraft:k,clearFolderRename:P}=t,L=cs(Fe=>Fe.toggleFolderCollapse),Q=cs(Fe=>Fe.renameFolder),q=cs(Fe=>Fe.deleteFolder),te=cs(Fe=>Fe.addSessionToFolder),ae=Pe(Fe=>Fe.showDeletionDialog),[X,Z]=c.useState(null),se=c.useCallback((Fe,Ye)=>{const mt=C.get(Fe.session.id),bt=C.get(Ye.session.id);if(mt!==void 0||bt!==void 0){if(mt===void 0)return 1;if(bt===void 0)return-1;if(mt!==bt)return mt-bt}return Vd(Fe.session,Ye.session,N,Td)},[N,C]),me=l?u.get(n):null,_=l?!1:f.has(r),ne=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const Fe=yt(n.directory??null),Ye=n.branch?.trim();return Fe&&Ye?Ko(Fe,Ye):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),ye=_d(ne),ce=ye?`var(--pr-${ye.visualState})`:void 0,F=Da(),re=c.useMemo(()=>{const Fe=n.folderScopes?.map(Ye=>yt(Ye.directory))??[yt(n.directory??null)];return[...new Set(Fe.filter(Ye=>!!Ye))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(Fe=>re.length>0?F.subscribeBootstrap(Fe):()=>{},[re.length,F]),c.useCallback(()=>re.map(Fe=>`${Fe}\0${F.getBootstrapState(Fe)??""}\0${F.getBootstrapFailure(Fe)??""}`).join(""),[re,F]),c.useCallback(()=>"",[]));const fe=re.some(Fe=>{const Ye=F.getBootstrapState(Fe);return Ye==="queued"||Ye==="running"}),de=re.find(Fe=>F.getBootstrapState(Fe)==="failed")??null,ge=de?F.getBootstrapFailure(de):void 0,Te=ge==="os-permission"&&nf(),[be,Ee]=c.useState(!1),we=c.useCallback(()=>{de&&F.requestBootstrap({directory:de,priority:_?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[F,de,n.isMain,_]),Y=c.useCallback(async()=>{if(!(!de||!Te||be)){Ee(!0);try{(await rf(de)).success&&we()}finally{Ee(!1)}}},[Te,de,be,we]),ve=h??(p?10:5),xe=Math.max(ve,d??ve),je=l?me?.groupMatches===!0:!1,oe=l,J=c.useMemo(()=>[...oe?me?.filteredNodes??[]:n.sessions].sort(se),[se,n.sessions,me?.filteredNodes,oe]),K=n.folderScopeKey??yt(n.directory??null),$=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:K?[{scopeKey:K,directory:n.directory??null}]:[],[K,n.directory,n.folderScopes]),le=cs(Jn(c.useCallback(Fe=>$.map(({scopeKey:Ye})=>Fe.foldersMap[Ye]??Cc),[$]))),V=c.useMemo(()=>$.flatMap(({scopeKey:Fe,directory:Ye},mt)=>(le[mt]??Cc).map(ft=>({folder:ft,scopeKey:Fe,scopeDirectory:Ye}))),[le,$]),Ce=cs(Jn(c.useCallback(Fe=>new Set(le.flatMap(Ye=>Ye.filter(mt=>Fe.collapsedFolderIds.has(mt.id)).map(mt=>mt.id))),[le]))),_e=c.useMemo(()=>{const Fe=new Map,Ye=mt=>{mt.forEach(bt=>{Fe.set(bt.session.id,bt),bt.children.length>0&&Ye(bt.children)})};return Ye(J),Fe},[J]),ke=c.useMemo(()=>V.map(({folder:Fe,scopeKey:Ye,scopeDirectory:mt})=>{const bt=dj(Fe.sessionIds,_e).sort(se);return{folder:Fe,scopeKey:Ye,scopeDirectory:mt,nodes:bt}}),[V,_e,se]),Ne=c.useMemo(()=>{const Fe=mj(ke.map(({folder:Ye,nodes:mt})=>({id:Ye.id,name:Ye.name,parentId:Ye.parentId,nodeCount:mt.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:l?a:""});return ke.filter(({folder:Ye})=>Fe.has(Ye.id))},[ke,n.isArchivedBucket,l,a]),Qe=E,We=H,U=z,he=c.useMemo(()=>new Set(Ne.flatMap(Fe=>Fe.folder.sessionIds)),[Ne]),Re=c.useMemo(()=>J.filter(Fe=>!he.has(Fe.session.id)),[J,he]),Ie=c.useMemo(()=>{const Fe=new Map(Ne.map(Ye=>[Ye.folder.id,Ye]));return uj(Ne.map(Ye=>Ye.folder)).map(Ye=>Fe.get(Ye.id)).filter(Ye=>!!Ye)},[Ne]),rt=c.useMemo(()=>{const Fe=new Map;return Ne.forEach(Ye=>{if(!Ye.folder.parentId)return;const mt=Fe.get(Ye.folder.parentId)??[];mt.push(Ye),Fe.set(Ye.folder.parentId,mt)}),Fe},[Ne]),Ge=c.useMemo(()=>{const Fe=new Map(Ne.map(bt=>[bt.folder.id,bt])),Ye=new Map,mt=(bt,ft)=>{const lt=Ye.get(bt);if(lt!==void 0)return lt;if(ft.has(bt))return[];ft.add(bt);const $t=Fe.get(bt),Zt=$t?[...$t.nodes]:[];for(const Xt of rt.get(bt)??[])Zt.push(...mt(Xt.folder.id,ft));return Ye.set(bt,Zt),Zt};return Ne.forEach(({folder:bt})=>mt(bt.id,new Set)),Ye},[Ne,rt]),ut="project",ct=c.useMemo(()=>{const Fe=new Set;return ea(J,Qe,Fe),Ne.forEach(({nodes:Ye})=>{ea(Ye,Qe,Fe)}),Fe},[J,Ne,Qe]),ue=c.useMemo(()=>{if(!We)return null;const Fe=Hr(J,We,ut,!!n.isArchivedBucket);if(Fe)return Fe;for(const{nodes:Ye}of Ne){const mt=Hr(Ye,We,ut,!!n.isArchivedBucket);if(mt)return mt}return null},[We,J,Ne,n.isArchivedBucket]),G=c.useCallback(Fe=>{const Ye=new WeakMap,mt=bt=>{Ye.set(bt,Fo(bt));for(const ft of bt.children)mt(ft)};return Fe.forEach(mt),Ye},[]),Le=c.useMemo(()=>G(J),[G,J]),Oe=c.useMemo(()=>{const Fe=new WeakMap;return Ne.forEach(({nodes:Ye})=>{Ye.forEach(mt=>Fe.set(mt,Fo(mt)))}),Fe},[Ne]),qe=c.useCallback(Fe=>Le.get(Fe)??Oe.get(Fe)??"",[Le,Oe]),Ue=c.useCallback(Fe=>({subtreeContainsEditing:ct,menuOpenSessionId:ue,nodeStructureKey:qe(Fe)}),[ct,ue,qe]),st=Re.length,wt=n.isArchivedBucket||l?Re:Re.slice(0,xe),Nt=st-wt.length,ie=!n.isArchivedBucket&&!l&&st>ve&&Nt===0,pe=n.isArchivedBucket===!0&&!l&&wt.length>=g2,Ve=n.isArchivedBucket?"archived":"active",ze=pe&&wt.some(Fe=>{if(Fe.children.length===0)return!1;const Ye=`project:${Ve}:${Fe.session.id}`;return U.has(Ye)}),He=c.useRef(null),[ot,at]=c.useState(null),[et,Xe]=c.useState(0),[,dt]=c.useState(0);c.useEffect(()=>{if(!pe)return;const Fe=He.current;if(!Fe||!globalThis.ResizeObserver)return;const Ye=new ResizeObserver(()=>dt(mt=>mt+1));return Ye.observe(Fe),()=>Ye.disconnect()},[pe]),c.useLayoutEffect(()=>{if(!pe){ot!==null&&at(null),et!==0&&Xe(0);return}const Fe=He.current;if(!Fe)return;let Ye=ot;const mt=M?.current??null;if(mt&&mt.contains(Fe)){if(Ye=mt,Ye!==ot){at(Ye);return}}else if(!Ye||!Ye.contains(Fe)){let ft=Fe.parentElement;for(;ft;){const lt=window.getComputedStyle(ft);if(lt.overflowY==="auto"||lt.overflowY==="scroll"){Ye=ft;break}ft=ft.parentElement}if(Ye!==ot){at(Ye);return}}if(!Ye)return;const bt=Fe.getBoundingClientRect().top-Ye.getBoundingClientRect().top+Ye.scrollTop;Xe(ft=>Math.abs(ft-bt)<1?ft:bt)});const Be=pe&&ot!==null,Se=Hg({count:wt.length,enabled:Be,getScrollElement:()=>ot,initialOffset:()=>ot?.scrollTop??0,estimateSize:()=>x2,overscan:ze?20:8,scrollMargin:et,getItemKey:Fe=>wt[Fe]?.session.id??Fe}),St=c.useCallback(Fe=>{const Ye=[],mt=bt=>{bt.forEach(ft=>{Ye.push(ft.session),ft.children.length>0&&mt(ft.children)})};return mt(Fe),Ye},[]),vt=c.useMemo(()=>St(J),[St,J]),Et=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Fe=new Map,Ye=new Map;for(const{folder:bt}of Ne){if(!bt.parentId)continue;const ft=Ye.get(bt.parentId)??[];ft.push(bt.id),Ye.set(bt.parentId,ft)}const mt=(bt,ft)=>{if(ft.has(bt))return[];ft.add(bt);const lt=Ne.find(({folder:Xt})=>Xt.id===bt),$t=lt?St(lt.nodes):[],Zt=Ye.get(bt)??[];for(const Xt of Zt)$t.push(...mt(Xt,ft));return $t};for(const{folder:bt}of Ne)Fe.set(bt.id,mt(bt.id,new Set));return Fe},[Ne,St,n.isArchivedBucket]);if(l&&!je&&Ie.length===0&&Re.length===0)return null;const Ze=!n.isMain&&!!n.branch,it=n.branch&&Oh(n.branch,n.label)?{label:n.branch}:null,gt=_?s.jsx(K0,{nodes:J,includeUnreadSubtasks:j}):null,xt=(Fe,Ye)=>{const{folder:mt,scopeKey:bt,scopeDirectory:ft,nodes:lt}=Fe,$t=Et.get(mt.id)??[],Zt=T?.folderId===mt.id&&T?.scopeKey===bt,Xt=l?!1:Ce.has(mt.id),Ns=Jt=>s.jsx(oj,{folderId:mt.id,children:(zs,Js)=>s.jsx(G0,{folder:mt,displayName:Ye,sessions:lt,isCollapsed:Xt,collapsedActivityState:Jt,onToggle:()=>L(mt.id),onRename:rs=>{Q(bt,mt.id,rs)},onDelete:()=>{if(n.isArchivedBucket){gn.requestDelete({sessions:$t,mode:"session"});return}if(!ae){q(bt,mt.id);return}const rs=Ne.filter(({folder:Es})=>Es.parentId===mt.id).length,Vs=lt.length;Z({scopeKey:bt,folderId:mt.id,folderName:mt.name,subFolderCount:rs,sessionCount:Vs})},groupDirectory:ft??n.directory,projectId:i,mobileVariant:v,alwaysShowActions:x,isRenaming:Zt,renameDraft:Zt?T?.draft:void 0,onRenameDraftChange:k,onRenameSave:()=>{const rs=T?.draft.trim()??"";rs&&Q(bt,mt.id,rs),P()},onRenameCancel:P,droppableRef:zs,isDropTarget:Js,depth:0,onNewSession:()=>{i&&i!==m&&b(i),v&&y(!1),S({selectedProjectId:i,directoryOverride:ft??n.directory,targetFolderId:mt.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:lt.map(rs=>s.jsx(_o,{node:rs,pinnedSessionIds:N,expandedParents:z,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:j,editingId:E,editTitle:B,copiedSessionId:O,openSidebarMenuKey:H,mobileVariant:v,alwaysShowActions:x,groupDirectory:ft??n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ct,menuOpenSessionId:ue,nodeStructureKey:qe(rs),childRenderExtrasFor:Ue},setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},rs.session.id))})},mt.id);return Xt?s.jsx(b2,{nodes:Ge.get(mt.id)??lt,includeUnreadSubtasks:j,children:Ns},mt.id):Ns(null)},Rt=()=>{const Fe=new Map;for(const ft of Ne){const lt=ft.folder.parentId;if(!lt)continue;const $t=Fe.get(lt);$t?$t.push(ft):Fe.set(lt,[ft])}const Ye=[],mt=new Set,bt=(ft,lt)=>{if(mt.has(ft.folder.id))return;mt.add(ft.folder.id);const $t=lt?`${lt} / ${ft.folder.name}`:ft.folder.name;Ye.push(xt(ft,$t)),!(!l&&Ce.has(ft.folder.id))&&(Fe.get(ft.folder.id)??[]).forEach(Xt=>bt(Xt,$t))};return Ie.forEach(ft=>bt(ft,"")),Ye},kt=!!(!n.isMain&&n.worktree),Tt=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(R,{name:"alert",className:"h-3 w-3"})}):null,Ot=x?kt?"pr-14":"pr-7":kt?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",Vt=de?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(ge==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":"sessions.sidebar.group.empty.loadFailed"),Te?s.jsx(pt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:be,onClick:()=>{Y()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(pt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:we,children:e("sessions.sidebar.group.empty.retry")})]}):null,Yt=Fe=>s.jsx(_o,{node:Fe,pinnedSessionIds:N,expandedParents:z,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:j,editingId:E,editTitle:B,copiedSessionId:O,openSidebarMenuKey:H,mobileVariant:v,alwaysShowActions:x,groupDirectory:n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ct,menuOpenSessionId:ue,nodeStructureKey:qe(Fe),childRenderExtrasFor:Ue},setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},Fe.session.id),Ht=s.jsxs(ij,{scopeKey:$[0]?.scopeKey??K,hasFolders:Ne.length>0,onSessionDroppedOnFolder:(Fe,Ye)=>{const mt=Ne.find(({folder:ft})=>ft.id===Ye);if(!mt)return;const bt=cs.getState();for(const{scopeKey:ft}of $)ft!==mt.scopeKey&&bt.getSessionFolderId(ft,Fe)&&bt.removeSessionFromFolder(ft,Fe);te(mt.scopeKey,Ye,Fe)},children:[Rt(),pe?s.jsx("div",{ref:He,children:Be?s.jsx("div",{style:{height:Se.getTotalSize(),position:"relative"},children:Se.getVirtualItems().map(Fe=>{const Ye=wt[Fe.index];return Ye?s.jsx("div",{"data-index":Fe.index,ref:Se.measureElement,className:"[&_[data-session-row]]:my-px",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${Fe.start-et}px)`},children:Yt(Ye)},Ye.session.id):null})}):wt.map(Yt)}):wt.map(Yt),st===0&&Ne.length===0?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):fe?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Vt||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,st>0&&Vt?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Vt}):null,Nt>0?s.jsx("button",{type:"button",onClick:()=>g(r,wt.length,h??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,ie?s.jsx("button",{type:"button",onClick:()=>w(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),Lt="pb-2",zt=s.jsx(d2,{value:X,setValue:Z,onConfirm:()=>{const Fe=X;Fe&&(q(Fe.scopeKey,Fe.folderId),Z(null))}});return o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:De("oc-group-body",Lt),children:Ht})}),zt]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:De("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>A(r),role:"button",tabIndex:0,onKeyDown:Fe=>{(Fe.key==="Enter"||Fe.key===" ")&&(Fe.preventDefault(),A(r))},"aria-label":_?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!_,children:[s.jsxs("div",{ref:D?.setActivatorNodeRef,className:De("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Ot),...D?.listeners??{},children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(R,{name:"archive",className:De("h-3.5 w-3.5 shrink-0 text-muted-foreground",x?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:De("text-muted-foreground h-3.5 w-3.5 items-center justify-center",x?"inline-flex":"hidden group-hover/gh:inline-flex"),children:_?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:po(n.label,a)}),Tt,gt]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(R,{name:"git-branch",className:De("h-3.5 w-3.5 shrink-0",!ce&&"text-muted-foreground",x?"hidden":"group-hover/gh:hidden"),style:ce?{color:ce}:void 0}),s.jsx("span",{className:De("text-muted-foreground h-3.5 w-3.5 items-center justify-center",x?"inline-flex":"hidden group-hover/gh:inline-flex"),children:_?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:po(n.label,a)}),Tt,gt,ye?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:ce?{color:ce}:void 0,children:["#",ye.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:po(n.label,a)}),gt]})}),Ze&&it?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(R,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:it.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(Kr,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&vt.length>0?s.jsx("div",{className:De("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Fe=>{Fe.stopPropagation(),gn.requestDelete({sessions:vt,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:De("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Fe=>{Fe.stopPropagation(),gn.requestDelete({sessions:vt,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:De("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Fe=>{Fe.stopPropagation(),i&&i!==m&&b(i),v&&y(!1),S({selectedProjectId:i,directoryOverride:n.directory})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(R,{name:"add",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),_?null:s.jsx("div",{className:De("oc-group-body",Lt),children:Ht})]}),zt]})}const vo=c.memo(j2,v2),k2=(t,e,n)=>e?t.filter(r=>r.project.id===n):t,C2=t=>t?"top-content":"empty-state",N2=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return[n,...r?[r]:[]].map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:o.id===n.id}))},A2=48,P2=32,D2=24,gi=(t,e)=>Pa(t.label?.trim()||Bn(t.normalizedPath,e)||t.normalizedPath);function I2(t){const e=tt.c(42);Gs("ui.sidebar_projects_list.render");const{t:n}=At(),{model:r,view:i,actions:o}=t,l=r.state.editingId!==null,a=i.isDesktopShellRuntime&&i.stickyZoneHeaders&&!r.singleProjectMode;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{distance:8}},e[0]=u):u=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={coordinateGetter:Og},e[1]=d):d=e[1];const h=zr(Mn(Oi,u),Mn(Rg,d));let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={activationConstraint:{distance:8}},e[2]=f):f=e[2];const p=zr(Mn(Oi,f)),g=c.useRef(null),w=c.useRef(0);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=me=>{const ne=me.scrollTop>1?Math.min(P2+me.scrollTop,A2):0;w.current=ne;const ye=me.closest(".oc-sticky-fade-root");ye?.style.setProperty("--scroll-shadow-top-size",`${ne}px`),ye?.style.setProperty("--scroll-shadow-top-clear-size",`${Math.min(Math.max(ne-8,0),D2)}px`)},e[3]=v):v=e[3];const x=v;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=me=>{me.target.closest("[data-overlay-scrollbar-thumb], [data-sidebar-sticky-header]")||me.clientY-me.currentTarget.getBoundingClientRect().top>=w.current||(me.preventDefault(),me.stopPropagation())},e[4]=m):m=e[4];const b=m,y=k2(r.sectionsForRender,r.singleProjectMode,r.singleProjectId),S=r.projectSections.length>0&&y.length>0;let N,C;e[5]!==a||e[6]!==S?(N=()=>{a&&S&&g.current&&x(g.current)},C=[a,S,x],e[5]=a,e[6]=S,e[7]=N,e[8]=C):(N=e[7],C=e[8]),c.useLayoutEffect(N,C);let j=null;for(const me of r.projectSections)r.stuckProjectHeaders.has(me.project.id)&&(j=me.project);const A=j??(r.hasSharedSessions?null:y[0]?.project??null),D=A?gi(A,i.homeDirectory):null;let I;if(e[9]!==r.projectSections||e[10]!==i.homeDirectory){let me;e[12]!==i.homeDirectory?(me=_=>({id:_.project.id,projectLabel:gi(_.project,i.homeDirectory),projectDescription:Wr(_.project.normalizedPath,i.homeDirectory),projectIcon:_.project.icon,projectColor:_.project.color,projectIconImage:_.project.iconImage,projectIconBackground:_.project.iconBackground}),e[12]=i.homeDirectory,e[13]=me):me=e[13],I=r.projectSections.map(me),e[9]=r.projectSections,e[10]=i.homeDirectory,e[11]=I}else I=e[11];const M=I;if(r.projectSections.length===0){let me;return e[14]!==r.emptyState||e[15]!==r.topContent?(me=s.jsxs(ln,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:[r.topContent,r.emptyState]}),e[14]=r.emptyState,e[15]=r.topContent,e[16]=me):me=e[16],me}if(r.sectionsForRender.length===0){const _=C2(r.topContentHasSearchMatches===!0)==="top-content"?r.topContent:r.searchEmptyState;let ne;return e[17]!==_?(ne=s.jsx(ln,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:_}),e[17]=_,e[18]=ne):ne=e[18],ne}const z="oc-sticky-fade-root relative flex min-h-0 flex-1";let E;e[19]!==a?(E=a?{"--scroll-shadow-top-size":"0px"}:void 0,e[19]=a,e[20]=E):E=e[20];const H=a?b:void 0,B=a?b:void 0,O=a?b:void 0,T=ln,k=!0,P=!a,L=96,Q="flex-1 min-h-0",q="oc-sidebar-scroller oc-sticky-fade-scroller space-y-1.5 pb-1 pl-2.5 pr-2 [overflow-anchor:none]";let te;e[21]!==a?(te=a?me=>x(me.currentTarget):void 0,e[21]=a,e[22]=te):te=e[22];const ae=i.showOnlyMainWorkspace?s.jsx("div",{className:"space-y-[0.6rem] py-1",children:(()=>{const me=y.find(ne=>ne.project.id===r.activeProjectId)??y[0];if(!me)return i.hasSessionSearchQuery?r.searchEmptyState:r.emptyState;const _=N2(me);return _.length?_.map(ne=>{const{group:ye,groupKey:ce,projectId:F,hideGroupLabel:re}=ne;return s.jsx(c.Fragment,{children:s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:ye,groupKey:ce,projectId:F,hideGroupLabel:re,visibleSessionCount:r.state.visibleSessionCountByGroup.get(ce),compactBodyPadding:!0,scrollContainerRef:g})},ce)}):s.jsx("div",{className:"py-1 text-left typography-micro text-muted-foreground",children:n("sessions.sidebar.empty.noSessions.title")})})()}):s.jsxs(Vr,{sensors:h,collisionDetection:Ur,onDragEnd:me=>{if(l||i.projectSortOrder!=="manual")return;const{active:_,over:ne}=me;if(!ne||_.id===ne.id)return;const ye=r.sectionsForRender.findIndex(F=>F.project.id===_.id),ce=r.sectionsForRender.findIndex(F=>F.project.id===ne.id);ye===-1||ce===-1||ye===ce||o.reorderProjects(ye,ce)},children:[s.jsx(Io,{items:y.map(M2),strategy:Fi,children:y.map(me=>{const _=me.project,ne=_.id,ye=gi(_,i.homeDirectory),ce=Wr(_.normalizedPath,i.homeDirectory),F=r.singleProjectMode?!1:i.collapsedProjects.has(ne),re=r.projectRepoStatus.get(ne);return s.jsx(F0,{id:ne,disabled:r.singleProjectMode||i.projectSortOrder!=="manual",projectLabel:ye,projectDescription:ce,projectDirectory:_.normalizedPath,projectIcon:_.icon,projectColor:_.color,projectIconImage:_.iconImage,projectIconBackground:_.iconBackground,isCollapsed:F,isRepo:!!re,isDesktopShell:i.isDesktopShellRuntime,hideDirectoryControls:i.hideDirectoryControls,mobileVariant:i.mobileVariant,alwaysShowActions:i.alwaysShowActions,statusIndicator:F?o.renderProjectStatusIndicator?.(ne,me.groups):null,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,projectPickerOptions:r.singleProjectMode?M:void 0,onProjectSelect:r.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{r.singleProjectMode||o.toggleProject(ne)},onNewSession:()=>{ne!==r.activeProjectId&&o.setActiveProjectIdOnly(ne),i.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:ne,directoryOverride:_.normalizedPath})},onNewWorktreeSession:()=>{ne!==r.activeProjectId&&o.setActiveProjectIdOnly(ne),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(ne),onRenameStart:()=>o.openProjectEditDialog(ne),onClose:()=>o.removeProject(ne),sentinelRef:fe=>{r.projectHeaderSentinelRefs.current.set(ne,fe)},showCreateButtons:!0,children:F?null:s.jsx("div",{className:"space-y-0 pt-0.5 pb-0.5",children:(()=>{const fe=me.groups,de=fe.find(R2)??null,ge=de?fe.filter(Te=>Te.id!==de.id):fe;return s.jsxs(Vr,{sensors:p,collisionDetection:Ur,onDragEnd:Te=>{if(l)return;const{active:be,over:Ee}=Te;if(!Ee||be.id===Ee.id)return;const we=ge.findIndex(je=>je.id===be.id),Y=ge.findIndex(je=>je.id===Ee.id);if(we===-1||Y===-1||we===Y)return;const ve=au(ge,we,Y).map(E2),xe=de?[de.id,...ve]:ve;o.setGroupOrderByProject(je=>{const oe=new Map(je);return oe.set(ne,xe),oe})},children:[de?s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:de,groupKey:`${ne}:${de.id}`,projectId:ne,hideGroupLabel:!0,visibleSessionCount:r.state.visibleSessionCountByGroup.get(`${ne}:${de.id}`),scrollContainerRef:g}):null,s.jsx(Io,{items:ge.map(T2),strategy:Fi,children:ge.map(Te=>{const be=`${ne}:${Te.id}`;return s.jsx(L0,{id:Te.id,disabled:l,children:Ee=>s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:Te,groupKey:be,projectId:ne,visibleSessionCount:r.state.visibleSessionCountByGroup.get(be),dragHandleProps:Ee,scrollContainerRef:g})},Te.id)})}),s.jsx(Bi,{dropAnimation:null})]})})()})},ne)})}),s.jsx(Bi,{dropAnimation:null})]});let X;e[23]!==T||e[24]!==r.topContent||e[25]!==P||e[26]!==te||e[27]!==ae?(X=s.jsxs(T,{ref:g,useScrollShadow:k,hideTopScrollShadow:P,scrollShadowSize:L,outerClassName:Q,className:q,onScroll:te,children:[r.topContent,ae]}),e[23]=T,e[24]=r.topContent,e[25]=P,e[26]=te,e[27]=ae,e[28]=X):X=e[28];let Z;e[29]!==a||e[30]!==A||e[31]!==D||e[32]!==r.hasSharedSessions||e[33]!==n?(Z=a&&(A||r.hasSharedSessions)?s.jsx("div",{className:"oc-sticky-fade-overlay pointer-events-none absolute inset-x-0 top-0 z-30 flex items-center gap-1.5 py-1 pl-4 pr-5","aria-hidden":"true",children:A&&D?s.jsxs(s.Fragment,{children:[s.jsx(wo,{id:A.id,projectLabel:D,projectIcon:A.icon,projectColor:A.color,projectIconImage:A.iconImage,projectIconBackground:A.iconBackground}),s.jsx(Kr,{directory:A.normalizedPath,className:"ml-auto"})]}):s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"history",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:n("sessions.sidebar.activity.recentTitle")})]})}):null,e[29]=a,e[30]=A,e[31]=D,e[32]=r.hasSharedSessions,e[33]=n,e[34]=Z):Z=e[34];let se;return e[35]!==H||e[36]!==B||e[37]!==O||e[38]!==X||e[39]!==Z||e[40]!==E?(se=s.jsxs("div",{className:z,style:E,onPointerDownCapture:H,onClickCapture:B,onContextMenuCapture:O,children:[X,Z]}),e[35]=H,e[36]=B,e[37]=O,e[38]=X,e[39]=Z,e[40]=E,e[41]=se):se=e[41],se}function T2(t){return t.id}function E2(t){return t.id}function R2(t){return t.isMain}function M2(t){return t.project.id}const O2=c.memo(I2),ia=new Map,Nc=(t,e)=>{for(const n of t){const r=yt(n??null);r&&!ia.has(r)&&ia.set(r,e)}},Ac=t=>{const e=yt(t??null);return e?ia.get(e)??0:0},Dr=t=>!!t.time?.archived,B2=t=>{const{t:e}=At(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const u=yt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${u}`.toLowerCase()},[e]),o=c.useCallback((a,u)=>{if(!u)return a;const d=u.trim().toLowerCase(),h=d.startsWith("ses_");return a.flatMap(f=>{if(h&&Dr(f.session))return[];if(h?f.session.id.toLowerCase()===d:Ao([i(f.session)],u))return[f];const g=o(f.children,u);return g.length===0?[]:[{...f,children:g}]})},[i]),l=c.useCallback((a,u,d,h,f)=>{const p=yt(u??null),g=Od(a),w=new Map(g.map(O=>[O.id,O])),v=new Map;g.forEach(O=>{const T=O.parentID;if(!T)return;const k=w.get(T);if(!k||Dr(k)!==Dr(O))return;const P=v.get(T)??[];P.push(O),v.set(T,P)});const x=new Map;d.forEach(O=>{if(O.path){const T=yt(O.path)??O.path;x.set(T,O)}});const m=O=>{const T=yt(O.directory??null),k=t.worktreeMetadata.get(O.id)??null;if(k)return k;if(T){const P=x.get(T)??null;if(P&&T!==p)return P}return null},b=new Set,y=O=>{b.add(O.id);const T=v.get(O.id)??[],k=[];for(const P of T)b.has(P.id)||k.push(y(P));return{session:O,children:k,worktree:m(O)}},S=g.filter(O=>{const T=O.parentID;if(!T)return!0;const k=w.get(T);return k?Dr(k)!==Dr(O):!0}),N=[],C=O=>{b.has(O.id)||N.push(y(O))};S.forEach(C),g.forEach(C);const j=new Map,A="__archived__",D=O=>{if(O.time?.archived)return A;if(t.isVSCode)return p??"__project_root__";const k=yt(t.worktreeMetadata.get(O.id)?.path??null)??$s(O);return k?k!==p&&x.has(k)?k:k===p?p??"__project_root__":A:A};N.forEach(O=>{const T=D(O.session);j.has(T)||j.set(T,[]),j.get(T)?.push(O)});const I=p??"__project_root__",M=[{id:"root",label:f&&h&&h!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:h}):e("sessions.sidebar.grouping.projectRoot"),branch:h??null,description:p?Wr(p,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:p,folderScopeKey:p,sessions:j.get(I)??[]}],z=new Map;d.forEach(O=>{const T=yt(O.path)??O.path,k=j.get(T)??[],P=k.length>0,L=k.reduce((Q,q)=>{const te=Bh(q.session,t.sessionOrderRanks);return Number.isFinite(te)?Math.max(Q,te):Q},0);z.set(T,{hasActiveSession:P,lastUpdatedAt:L})});const E=[...d].sort((O,T)=>{const k=yt(O.path)??O.path,P=yt(T.path)??T.path,L=z.get(k)??{hasActiveSession:!1,lastUpdatedAt:0},Q=z.get(P)??{hasActiveSession:!1,lastUpdatedAt:0};if(L.hasActiveSession!==Q.hasActiveSession)return L.hasActiveSession?-1:1;if(L.hasActiveSession&&Q.hasActiveSession)return Q.lastUpdatedAt-L.lastUpdatedAt;const q=Ac(O.path),te=Ac(T.path);if(q!==te)return te-q;const ae=(O.label||O.branch||O.name||O.path||"").toLowerCase(),X=(T.label||T.branch||T.name||T.path||"").toLowerCase();return ae.localeCompare(X)});(t.isVSCode?[]:E).forEach(O=>{const T=yt(O.path)??O.path,k=n.current.get(T)?.trim()||null,P=O.branch?.trim()||null,Q=!!(k&&P&&O.label&&il(O.label)===il(P))?k:O.label||O.name||Bn(T,t.homeDirectory)||T;M.push({id:`worktree:${T}`,label:Q,branch:k||P,description:Wr(T,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:O,directory:T,folderScopeKey:T,sessions:j.get(T)??[]})});const B=j.get(A)??[];return B.length>0&&M.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&p?Md(p):null,sessions:B}),M},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},F2=t=>{const e=tt.c(10),{enabled:n,isDesktopShellRuntime:r,projectSections:i,projectHeaderSentinelRefs:o}=t,l=n===void 0?!0:n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,e[0]=a):a=e[0];const[u,d]=c.useState(a);let h;e[1]!==l||e[2]!==r||e[3]!==o?(h=()=>{if(!l||!r){d(_2);return}const g=Array.from(o.current.values()).find(L2)?.closest(".oc-sidebar-scroller")??null;if(!g)return;const w=new IntersectionObserver(v=>{d(x=>{const m=new Set(x);let b=!1;for(const y of v){const S=y.target.dataset.projectId;if(!S)continue;const N=y.rootBounds?.top??g.getBoundingClientRect().top,C=!y.isIntersecting&&y.boundingClientRect.top<N;m.has(S)!==C&&(b=!0,C?m.add(S):m.delete(S))}return b?m:x})},{root:g,threshold:0});return o.current.forEach(v=>{v&&w.observe(v)}),()=>w.disconnect()},e[1]=l,e[2]=r,e[3]=o,e[4]=h):h=e[4];let f;return e[5]!==l||e[6]!==r||e[7]!==o||e[8]!==i?(f=[l,r,o,i],e[5]=l,e[6]=r,e[7]=o,e[8]=i,e[9]=f):f=e[9],c.useEffect(h,f),u};function _2(t){return t.size===0?t:new Set}function L2(t){return t!==null}const $2=t=>{const e=tt.c(51),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:u,canRemoveFromFolder:d,onRestore:h,onDelete:f,onDone:p}=t,{t:g}=At(),w=!!r&&!o;let v;e[0]!==o||e[1]!==g?(v=g(o?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=o,e[1]=g,e[2]=v):v=e[2];const x=v;let m;e[3]!==n||e[4]!==g?(m=g("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=g,e[5]=m):m=e[5];let b;e[6]!==m?(b=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:m}),e[6]=m,e[7]=b):b=e[7];let y;e[8]!==w||e[9]!==d||e[10]!==a||e[11]!==l||e[12]!==u||e[13]!==i||e[14]!==g?(y=w?s.jsxs(Xs,{children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":g("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(R,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:g("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Ys,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Ut,{disabled:!0,className:"text-muted-foreground",children:g("sessions.sidebar.folders.none")}):i.map(k=>s.jsx(Ut,{onClick:()=>l(k.id),children:s.jsx("span",{className:"flex-1 truncate",children:k.name})},k.id)),s.jsx(Os,{}),s.jsxs(Ut,{onClick:a,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.newFolderEllipsis")]}),d?s.jsxs(Ut,{onClick:u,className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"close",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=w,e[9]=d,e[10]=a,e[11]=l,e[12]=u,e[13]=i,e[14]=g,e[15]=y):y=e[15];let S;e[16]!==o||e[17]!==h||e[18]!==g?(S=o?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":g("sessions.sidebar.bulkActions.restore"),children:s.jsx(R,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:g("sessions.sidebar.bulkActions.restore")})})]}):null,e[16]=o,e[17]=h,e[18]=g,e[19]=S):S=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=De("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50"),e[20]=N):N=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(R,{name:"delete-bin",className:"h-4 w-4"}),e[21]=C):C=e[21];let j;e[22]!==x||e[23]!==f?(j=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:N,"aria-label":x,children:C})}),e[22]=x,e[23]=f,e[24]=j):j=e[24];let A;e[25]!==x?(A=s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:x})}),e[25]=x,e[26]=A):A=e[26];let D;e[27]!==j||e[28]!==A?(D=s.jsxs(Pt,{children:[j,A]}),e[27]=j,e[28]=A,e[29]=D):D=e[29];let I;e[30]!==g?(I=g("sessions.sidebar.header.actions.exitSelection"),e[30]=g,e[31]=I):I=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(R,{name:"close",className:"h-4 w-4"}),e[32]=M):M=e[32];let z;e[33]!==p||e[34]!==I?(z=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:p,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":I,children:M})}),e[33]=p,e[34]=I,e[35]=z):z=e[35];let E;e[36]!==g?(E=g("sessions.sidebar.header.actions.exitSelection"),e[36]=g,e[37]=E):E=e[37];let H;e[38]!==E?(H=s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:E})}),e[38]=E,e[39]=H):H=e[39];let B;e[40]!==z||e[41]!==H?(B=s.jsxs(Pt,{children:[z,H]}),e[40]=z,e[41]=H,e[42]=B):B=e[42];let O;e[43]!==D||e[44]!==B||e[45]!==y||e[46]!==S?(O=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[y,S,D,B]}),e[43]=D,e[44]=B,e[45]=y,e[46]=S,e[47]=O):O=e[47];let T;return e[48]!==O||e[49]!==b?(T=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[b,O]}),e[48]=O,e[49]=b,e[50]=T):T=e[50],T},W2=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},z2=t=>{const{t:e}=At(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,getFolderScopesForProject:o,addSessionsToFolder:l,removeSessionsFromFolders:a,createFolderAndStartRename:u,archiveSessions:d,unarchiveSessions:h,deleteSessions:f,setBulkDeleteConfirm:p}=t,g=hs(k=>k.enabled),w=hs(k=>k.selectedIds.size),v=w>0,x=hs(k=>k.selectedIds),m=hs(k=>k.scopeKey),b=c.useCallback(()=>{hs.getState().toggleMode()},[]),y=c.useCallback(()=>{hs.getState().disable()},[]),S=c.useMemo(()=>{if(!v||typeof document>"u")return!1;let k=!1,P=!1;for(const L of x){const Q=document.querySelectorAll(`[data-session-row="${CSS.escape(L)}"]`);for(const q of Q)q.getAttribute("data-session-archived")==="1"?P=!0:k=!0}return P&&!k},[v,x]),N=c.useMemo(()=>{if(m)return m;if(!v||typeof document>"u")return null;for(const k of x){const L=document.querySelector(`[data-session-row="${CSS.escape(k)}"]`)?.getAttribute("data-session-scope");if(L&&L.length>0)return L}return null},[v,x,m]),C=c.useMemo(()=>W2(N,o),[N,o]),j=c.useMemo(()=>C.flatMap(k=>i[k]??[]),[i,C]),A=c.useCallback(k=>{for(const P of C)if((i[P]??[]).some(L=>L.id===k))return P;return null},[i,C]),D=c.useMemo(()=>{if(!v)return!1;for(const k of C)for(const P of i[k]??[])for(const L of P.sessionIds)if(x.has(L))return!0;return!1},[i,C,v,x]),I=c.useCallback((k,P)=>{const L=Array.from(x);for(const Q of C)Q!==k&&a(Q,L);l(k,P,L)},[l,a,x,C]),M=c.useCallback(k=>{if(!v)return;const P=A(k);P&&I(P,k)},[v,I,A]),z=c.useCallback(()=>{const k=C[0];if(!k||!v)return;const P=u(k);P&&I(k,P.id)},[u,v,I,C]),E=c.useCallback(()=>{if(!v)return;const k=Array.from(x);for(const P of C)a(P,k)},[a,x,C,v]),H=c.useCallback(async()=>{const k=Array.from(x);if(k.length!==0){if(S){const{deletedIds:P,failedIds:L}=await f(k);P.length>0&&Me.success(P.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:P.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:P.length})),L.length>0&&Me.error(L.length===1?e("sessions.sidebar.bulkActions.failedDeleteSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedDeletePlural",{count:L.length}))}else{const{archivedIds:P,failedIds:L}=await d(k);P.length>0&&Me.success(P.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:P.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:P.length})),L.length>0&&Me.error(L.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:L.length}))}hs.getState().clear()}},[d,S,f,x,e]),B=c.useCallback(()=>{if(!v)return;const k=x.size;if(!r){H();return}p({sessionCount:k,archivedBucket:S})},[S,H,x,r,p,v]),O=c.useCallback(async()=>{if(!v||!S)return;const k=Array.from(x),{restoredIds:P,failedIds:L}=await h(k);P.length>0&&Me.success(P.length===1?e("sessions.sidebar.bulkActions.restoredSingle",{count:P.length}):e("sessions.sidebar.bulkActions.restoredPlural",{count:P.length})),L.length>0&&Me.error(L.length===1?e("sessions.sidebar.bulkActions.failedRestoreSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedRestorePlural",{count:L.length})),hs.getState().clear()},[S,v,x,e,h]),T=c.useCallback(async()=>{p(null),await H()},[H]);return c.useEffect(()=>{if(!g)return;const k=typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""),P=L=>{if(n)return;const Q=L.target;if(Q&&(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.isContentEditable))return;const q=k?L.metaKey:L.ctrlKey;if(L.key==="Escape"){L.preventDefault(),hs.getState().disable();return}if(q&&L.key==="Backspace"){L.preventDefault(),B();return}if(q&&(L.key==="a"||L.key==="A")){const te=typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[];if(te.length===0)return;L.preventDefault();const X=hs.getState().scopeKey??te[0]?.getAttribute("data-session-scope")??null,Z=me=>X?me.getAttribute("data-session-scope")===X:!0,se=te.filter(Z).map(me=>me.getAttribute("data-session-row")).filter(me=>typeof me=="string"&&me.length>0);if(se.length===0)return;hs.getState().replaceAll(se,X||null)}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[B,n,g]),{selectionModeEnabled:g,hasSelection:v,selectedIdsSize:w,bulkScopeIsArchived:S,derivedSelectionScope:N,bulkScopeFolders:j,bulkCanRemoveFromFolder:D,handleToggleSelectionMode:b,handleExitSelectionMode:y,handleBulkMoveToFolder:M,handleBulkCreateFolderAndMove:z,handleBulkRemoveFromFolder:E,handleBulkDelete:B,handleBulkRestore:O,confirmBulkDelete:T}};function V2(t){const e=tt.c(36),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Pe(J2),u=Pe(X2),d=cs(Y2),h=cs(Q2),f=cs(q2),p=cs(G2),g=Je(H2),w=Je(K2),v=Je(U2);let x;e[0]!==h||e[1]!==i?(x=C=>{const j=h(C,"New folder");return i(C,j),j},e[0]=h,e[1]=i,e[2]=x):x=e[2];let m;e[3]!==f||e[4]!==g||e[5]!==v||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p||e[10]!==a||e[11]!==x||e[12]!==w?(m={isInlineEditing:r,showDeletionDialog:a,foldersMap:d,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:p,createFolderAndStartRename:x,archiveSessions:g,unarchiveSessions:w,deleteSessions:v,setBulkDeleteConfirm:l},e[3]=f,e[4]=g,e[5]=v,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=a,e[11]=x,e[12]=w,e[13]=m):m=e[13];const b=z2(m);let y;e[14]!==b.bulkCanRemoveFromFolder||e[15]!==b.bulkScopeFolders||e[16]!==b.bulkScopeIsArchived||e[17]!==b.derivedSelectionScope||e[18]!==b.handleBulkCreateFolderAndMove||e[19]!==b.handleBulkDelete||e[20]!==b.handleBulkMoveToFolder||e[21]!==b.handleBulkRemoveFromFolder||e[22]!==b.handleBulkRestore||e[23]!==b.handleExitSelectionMode||e[24]!==b.hasSelection||e[25]!==b.selectedIdsSize||e[26]!==b.selectionModeEnabled?(y=b.selectionModeEnabled&&b.hasSelection?s.jsx($2,{selectedCount:b.selectedIdsSize,scopeKey:b.derivedSelectionScope,scopeFolders:b.bulkScopeFolders,archivedBucket:b.bulkScopeIsArchived,onMoveToFolder:b.handleBulkMoveToFolder,onCreateFolderAndMove:b.handleBulkCreateFolderAndMove,onRemoveFromFolder:b.handleBulkRemoveFromFolder,canRemoveFromFolder:b.bulkCanRemoveFromFolder,onRestore:b.handleBulkRestore,onDelete:b.handleBulkDelete,onDone:b.handleExitSelectionMode}):null,e[14]=b.bulkCanRemoveFromFolder,e[15]=b.bulkScopeFolders,e[16]=b.bulkScopeIsArchived,e[17]=b.derivedSelectionScope,e[18]=b.handleBulkCreateFolderAndMove,e[19]=b.handleBulkDelete,e[20]=b.handleBulkMoveToFolder,e[21]=b.handleBulkRemoveFromFolder,e[22]=b.handleBulkRestore,e[23]=b.handleExitSelectionMode,e[24]=b.hasSelection,e[25]=b.selectedIdsSize,e[26]=b.selectionModeEnabled,e[27]=y):y=e[27];let S;e[28]!==b.confirmBulkDelete||e[29]!==o||e[30]!==u||e[31]!==a?(S=s.jsx(c2,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:u,onConfirm:b.confirmBulkDelete}),e[28]=b.confirmBulkDelete,e[29]=o,e[30]=u,e[31]=a,e[32]=S):S=e[32];let N;return e[33]!==y||e[34]!==S?(N=s.jsxs(s.Fragment,{children:[y,S]}),e[33]=y,e[34]=S,e[35]=N):N=e[35],N}function U2(t){return t.deleteSessions}function K2(t){return t.unarchiveSessions}function H2(t){return t.archiveSessions}function G2(t){return t.removeSessionsFromFolders}function q2(t){return t.addSessionsToFolder}function Q2(t){return t.createFolder}function Y2(t){return t.foldersMap}function X2(t){return t.setShowDeletionDialog}function J2(t){return t.showDeletionDialog}const Pc=7,Z2=6e4,ek=()=>{const t=tt.c(2),[e,n]=c.useState(0);let r,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const o=setInterval(()=>{n(sk)},Z2);return()=>clearInterval(o)},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),c.useEffect(r,i),e};function tk(t){const{sections:e,variant:n="section",initialVisibleCount:r=Pc,batchSize:i=Pc}=t,{t:o}=At(),{pinnedSessionIds:l}=t,a=ls(y=>y.stickyZoneHeaders),[u,d]=c.useState(new Set),[h,f]=c.useState(new Map),p=n==="flat",g=c.useCallback(y=>{f(S=>{if(!S.has(y))return S;const N=new Map(S);return N.delete(y),N})},[]),w=c.useCallback(y=>{g(y),d(S=>{const N=new Set(S);return N.has(y)?N.delete(y):N.add(y),N})},[g]),v=c.useCallback((y,S,N)=>{f(C=>{const j=Math.min(N,S+i),A=new Map(C);return A.set(y,j),A})},[i]),x=ek(),m=c.useCallback(y=>{const S=new Set;ea(y,t.editingId,S);const N=Hr(y,t.openSidebarMenuKey,"recent",!1),C=new WeakMap,j=D=>{C.set(D,Fo(D)),D.children.forEach(j)};y.forEach(j);const A=D=>({subtreeContainsEditing:S,menuOpenSessionId:N,nodeStructureKey:C.get(D)??"",relativeTimeTick:x,childRenderExtrasFor:A});return D=>({subtreeContainsEditing:S,menuOpenSessionId:N,nodeStructureKey:C.get(D)??"",relativeTimeTick:x,childRenderExtrasFor:A})},[t.editingId,t.openSidebarMenuKey,x]),b=e.filter(y=>y.items.length>0||y.key==="chats");return b.length===0?null:s.jsx("div",{className:De(p?"space-y-0.5 pb-2":"space-y-2 pb-2"),children:b.map(y=>{const S=u.has(y.key),N=Math.max(r,h.get(y.key)??r),C=y.items.slice(0,N),j=y.items.length-C.length,A=y.key==="chats"&&!!t.renderChatsSection,D=!A&&!p&&y.items.length>r&&j===0,I=m(C.map(z=>z.node)),M=z=>s.jsx(_o,{node:z.node,pinnedSessionIds:l,expandedParents:t.expandedParents,hasSessionSearchQuery:t.hasSessionSearchQuery,normalizedSessionSearchQuery:t.normalizedSessionSearchQuery,notifyOnSubtasks:t.notifyOnSubtasks,editingId:t.editingId,editTitle:t.editTitle,copiedSessionId:t.copiedSessionId,openSidebarMenuKey:t.openSidebarMenuKey,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,groupDirectory:z.groupDirectory,projectId:z.projectId,secondaryMeta:z.secondaryMeta,renderContext:"recent",renderExtras:I(z.node),setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},z.node.session.id);return p?s.jsxs("div",{className:"space-y-0.5",children:[C.map(M),j>0?s.jsx("button",{type:"button",onClick:()=>v(y.key,C.length,y.items.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:o("sessions.sidebar.group.showMore")}):null]},y.key):s.jsxs("div",{className:"relative space-y-1",children:[s.jsxs("div",{className:De("relative group/chats","-ml-2.5 -mr-2",a&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":a?"true":void 0,children:[s.jsxs("button",{type:"button",onClick:()=>w(y.key),className:De("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",y.key==="chats"?"pr-10":"pr-3.5"),"aria-expanded":!S,children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[s.jsx(R,{name:y.key==="chats"?"chat-4":"history",className:De("h-3.5 w-3.5 text-muted-foreground/80","group-hover:hidden")}),s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:S?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:y.title})]}),y.key==="chats"&&t.onNewChat?s.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),t.onNewChat?.()},className:De("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",t.alwaysShowActions?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":o("sessions.sidebar.header.actions.newSession"),children:s.jsx(R,{name:"add",className:"h-4 w-4"})}):null]}),S?null:s.jsxs("div",{className:De("space-y-0.5"),children:[A?t.renderChatsSection?.(y.items):C.map(M),!A&&j>0?s.jsx("button",{type:"button",onClick:()=>v(y.key,C.length,y.items.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:o("sessions.sidebar.group.showMore")}):null,D?s.jsx("button",{type:"button",onClick:()=>g(y.key),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:o("sessions.sidebar.group.showFewer")}):null]})]},y.key)})})}function sk(t){return t+1}const nk=t=>{const e=tt.c(61),{projects:n,availableWorktreesByProject:r,gitBranches:i,homeDirectory:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,isDesktopShellRuntime:u,sessions:d,childrenMap:h,pinnedSessionIds:f,recentSessions:p,chatSessions:g,showRecentSection:w}=t,{t:v}=At();let x;if(e[0]!==r||e[1]!==i||e[2]!==o||e[3]!==n||e[4]!==d){x=new Map;for(const B of d){const O=yt(B.directory??null);if(!O)continue;let T=null,k=-1;for(const q of n){const te=yt(q.normalizedPath);te&&(O===te||O.startsWith(`${te}/`))&&te.length>k&&(T=q,k=te.length)}if(!T)continue;const P=r.get(T.normalizedPath)?.find(q=>yt(q.path)===O),L=Pa(T.label?.trim()||Bn(T.normalizedPath,o)||T.normalizedPath),Q=P?.branch?.trim()||i.get(O)?.trim()||null;x.set(B.id,{projectId:T.id,groupDirectory:O,projectLabel:L,branchLabel:Q&&Q!=="HEAD"&&Q!==L?Q:null})}e[0]=r,e[1]=i,e[2]=o,e[3]=n,e[4]=d,e[5]=x}else x=e[5];const m=x;let b;e[6]!==m?(b=B=>m.get(B)??null,e[6]=m,e[7]=b):b=e[7];const y=b;let S;e[8]!==h?(S=B=>({session:B,children:(h.get(B.id)??[]).filter(rk).map(ok),worktree:null}),e[8]=h,e[9]=S):S=e[9];const N=S,C=l?a:"";let j;e[10]!==y||e[11]!==N||e[12]!==p||e[13]!==C?(j=ag({sessions:p,getSessionLocation:y,getSessionNode:N,query:C}),e[10]=y,e[11]=N,e[12]=p,e[13]=C,e[14]=j):j=e[14];const A=j;let D;e[15]!==v?(D=v("sessions.sidebar.activity.chatsTitle"),e[15]=v,e[16]=D):D=e[16];let I;if(e[17]!==g||e[18]!==N){let B;e[20]!==N?(B=O=>({node:N(O),projectId:null,groupDirectory:O.directory??null,secondaryMeta:null}),e[20]=N,e[21]=B):B=e[21],I=g.map(B),e[17]=g,e[18]=N,e[19]=I}else I=e[19];let M;e[22]!==D||e[23]!==I?(M={key:"chats",title:D,items:I},e[22]=D,e[23]=I,e[24]=M):M=e[24];let z;e[25]!==A||e[26]!==w||e[27]!==v||e[28]!==M?(z=[M,...w?A.map(B=>({...B,title:v("sessions.sidebar.activity.recentTitle")})):[]],e[25]=A,e[26]=w,e[27]=v,e[28]=M,e[29]=z):z=e[29];const E=z;let H;return e[30]!==u||e[31]!==f||e[32]!==t.allowReselect||e[33]!==t.alwaysShowActions||e[34]!==t.copiedSessionId||e[35]!==t.deleteSessionConfirm||e[36]!==t.editTitle||e[37]!==t.editingId||e[38]!==t.expandedParents||e[39]!==t.hasSessionSearchQuery||e[40]!==t.isSessionSearchOpen||e[41]!==t.mobileVariant||e[42]!==t.normalizedSessionSearchQuery||e[43]!==t.notifyOnSubtasks||e[44]!==t.onNewChat||e[45]!==t.onSessionSelected||e[46]!==t.openSidebarMenuKey||e[47]!==t.renderChatsSection||e[48]!==t.sessionSearchQuery||e[49]!==t.setCopiedSessionId||e[50]!==t.setDeleteSessionConfirm||e[51]!==t.setEditTitle||e[52]!==t.setEditingId||e[53]!==t.setIsSessionSearchOpen||e[54]!==t.setOpenSidebarMenuKey||e[55]!==t.setSessionSearchQuery||e[56]!==t.startFolderRename||e[57]!==t.startSessionWorktreeMenuLoad||e[58]!==t.toggleParent||e[59]!==E?(H=s.jsx(tk,{sections:E,variant:"section",isDesktopShellRuntime:u,pinnedSessionIds:f,expandedParents:t.expandedParents,hasSessionSearchQuery:t.hasSessionSearchQuery,normalizedSessionSearchQuery:t.normalizedSessionSearchQuery,notifyOnSubtasks:t.notifyOnSubtasks,editingId:t.editingId,editTitle:t.editTitle,copiedSessionId:t.copiedSessionId,openSidebarMenuKey:t.openSidebarMenuKey,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,onNewChat:t.onNewChat,renderChatsSection:t.renderChatsSection,setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad}),e[30]=u,e[31]=f,e[32]=t.allowReselect,e[33]=t.alwaysShowActions,e[34]=t.copiedSessionId,e[35]=t.deleteSessionConfirm,e[36]=t.editTitle,e[37]=t.editingId,e[38]=t.expandedParents,e[39]=t.hasSessionSearchQuery,e[40]=t.isSessionSearchOpen,e[41]=t.mobileVariant,e[42]=t.normalizedSessionSearchQuery,e[43]=t.notifyOnSubtasks,e[44]=t.onNewChat,e[45]=t.onSessionSelected,e[46]=t.openSidebarMenuKey,e[47]=t.renderChatsSection,e[48]=t.sessionSearchQuery,e[49]=t.setCopiedSessionId,e[50]=t.setDeleteSessionConfirm,e[51]=t.setEditTitle,e[52]=t.setEditingId,e[53]=t.setIsSessionSearchOpen,e[54]=t.setOpenSidebarMenuKey,e[55]=t.setSessionSearchQuery,e[56]=t.startFolderRename,e[57]=t.startSessionWorktreeMenuLoad,e[58]=t.toggleParent,e[59]=E,e[60]=H):H=e[60],H};function rk(t){return!t.time?.archived}function ok(t){return{session:t,children:[],worktree:null}}const fm="oc.sessions.expandedParents.v3",ik=Ta(xr()),ak=()=>{try{const t=globalThis.localStorage.getItem(fm);if(t===null)return new Set;const e=ik.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},lk=()=>{const[t,e]=c.useState(ak),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=Fh(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(fm,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},ck=5*6e4,dk=[],uk=t=>!t.parentID,mk=t=>{const e=tt.c(293),{topology:n,view:r,actions:i}=t;let o,l,a,u,d;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:u,...d}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=u,e[5]=d):(o=e[1],l=e[2],a=e[3],u=e[4],d=e[5]);const h=cs(hk),f=cs(pk),p=cs(gk),g=r.projectView,{getOrderedGroups:w,setGroupOrderByProject:v,toggleGroup:x,toggleProject:m}=a;let b;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(b={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=b):b=e[8];const y=lg(b);let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=new Map,e[9]=S):S=e[9];const[N,C]=c.useState(S);let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=(Bt,Wt)=>{C(ns=>new Map(ns).set(Bt,Wt+7))},e[10]=j):j=e[10];const A=j;let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D=Bt=>{C(Wt=>{if(!Wt.has(Bt))return Wt;const ns=new Map(Wt);return ns.delete(Bt),ns})},e[11]=D):D=e[11];const I=D,M=ls(xk),z=ls(bk),E=ls(yk),H=ls(wk);let B;e[12]!==n.isVSCode?(B=!n.isVSCode&&!of(),e[12]=n.isVSCode,e[13]=B):B=e[13];const T=B&&z==="single",k=M&&!T;let P;e[14]!==y.pinnedSessionIds||e[15]!==y.rootSessions||e[16]!==y.sessionOrderRanks||e[17]!==k||e[18]!==n.isVSCode?(P={enabled:k,isVSCode:n.isVSCode,pinnedSessionIds:y.pinnedSessionIds,sessionOrderRanks:y.sessionOrderRanks,sessions:y.rootSessions},e[14]=y.pinnedSessionIds,e[15]=y.rootSessions,e[16]=y.sessionOrderRanks,e[17]=k,e[18]=n.isVSCode,e[19]=P):P=e[19];const L=cg(P),[Q,q]=c.useState(null),[te,ae]=c.useState(""),[X,Z]=c.useState(null),[se,me]=c.useState(null),[_,ne]=c.useState(null),[ye,ce]=c.useState(null);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F=(Bt,Wt)=>{ce({scopeKey:Bt,folderId:Wt.id,draft:Wt.name})},e[20]=F):F=e[20];const re=F;let fe;e[21]===Symbol.for("react.memo_cache_sentinel")?(fe=Bt=>{ce(Wt=>Wt?{...Wt,draft:Bt}:null)},e[21]=fe):fe=e[21];const de=fe;let ge;e[22]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>ce(null),e[22]=ge):ge=e[22];const Te=ge,{expandedParents:be,toggleParent:Ee}=lk(),we=Je(Sk);let Y;e[23]!==we?(Y=(Bt,Wt)=>{Bt!==Je.getState().currentSessionId&&we(Bt,Wt)},e[23]=we,e[24]=Y):Y=e[24];const ve=Y,xe=Ld();let je;e[25]!==y.pinnedSessionIds||e[26]!==y.sessionOrderRanks||e[27]!==n.gitBranches||e[28]!==n.isVSCode||e[29]!==n.worktreeMetadata||e[30]!==r.homeDirectory?(je={homeDirectory:r.homeDirectory,worktreeMetadata:n.worktreeMetadata,pinnedSessionIds:y.pinnedSessionIds,sessionOrderRanks:y.sessionOrderRanks,gitBranches:n.gitBranches,isVSCode:n.isVSCode},e[25]=y.pinnedSessionIds,e[26]=y.sessionOrderRanks,e[27]=n.gitBranches,e[28]=n.isVSCode,e[29]=n.worktreeMetadata,e[30]=r.homeDirectory,e[31]=je):je=e[31];const{buildGroupedSessions:oe,filterSessionNodesForSearch:J,buildGroupSearchText:K}=B2(je);let $;e[32]!==y.archivedSessions||e[33]!==y.sessions||e[34]!==n.availableWorktreesByProject||e[35]!==n.isVSCode||e[36]!==n.projects?($=C0(y.sessions,n.projects,n.availableWorktreesByProject,n.isVSCode,y.archivedSessions),e[32]=y.archivedSessions,e[33]=y.sessions,e[34]=n.availableWorktreesByProject,e[35]=n.isVSCode,e[36]=n.projects,e[37]=$):$=e[37];const le=$;let V;e[38]!==le?(V={ownership:le},e[38]=le,e[39]=V):V=e[39];const{getSessionsForProject:Ce,getArchivedSessionsForProject:_e}=N0(V);let ke;e:{if(n.isVSCode){ke=null;break e}let Bt;e[40]!==y.chatSessions||e[41]!==r.homeDirectory?(Bt=_h(r.homeDirectory)??y.chatSessions.map(vk).find(Boolean)??null,e[40]=y.chatSessions,e[41]=r.homeDirectory,e[42]=Bt):Bt=e[42];const Wt=Bt;if(!Wt){ke=null;break e}let ns;if(e[43]!==Wt||e[44]!==y.chatSessions){const Ke=[Wt,...y.chatSessions.map(jk).filter(Boolean)];let W;e[46]!==Ke?(W=new Set(Ke),e[46]=Ke,e[47]=W):W=e[47],ns=Array.from(W).filter(kk).map(Ck),e[43]=Wt,e[44]=y.chatSessions,e[45]=ns}else ns=e[45];const us=ns;let xs;if(e[48]!==y.chatSessions||e[49]!==y.childrenMap){let Ke;e[51]!==y.childrenMap?(Ke=W=>({session:W,children:(y.childrenMap.get(W.id)??[]).filter(Ak).map(Pk),worktree:null}),e[51]=y.childrenMap,e[52]=Ke):Ke=e[52],xs=y.chatSessions.filter(Nk).map(Ke),e[48]=y.chatSessions,e[49]=y.childrenMap,e[50]=xs}else xs=e[50];let ee;e[53]!==Wt||e[54]!==us||e[55]!==xs?(ee={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Wt,folderScopeKey:Wt,folderScopes:us,draftTarget:"chat",sessions:xs},e[53]=Wt,e[54]=us,e[55]=xs,e[56]=ee):ee=e[56],ke=ee}const Ne=ke;let Qe;e[57]!==Ne?(Qe=Ne?[Ne]:dk,e[57]=Ne,e[58]=Qe):Qe=e[58];const We=Qe;let U;e[59]!==K||e[60]!==oe||e[61]!==J||e[62]!==h||e[63]!==_e||e[64]!==Ce||e[65]!==We||e[66]!==n.availableWorktreesByProject||e[67]!==n.gitBranches||e[68]!==n.lastRepoStatus||e[69]!==n.projectRepoStatus||e[70]!==n.projectRootBranches||e[71]!==n.projects||e[72]!==r.hasSessionSearchQuery||e[73]!==r.normalizedSessionSearchQuery?(U={normalizedProjects:n.projects,getSessionsForProject:Ce,getArchivedSessionsForProject:_e,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:oe,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:J,buildGroupSearchText:K,foldersMap:h,standaloneGroups:We},e[59]=K,e[60]=oe,e[61]=J,e[62]=h,e[63]=_e,e[64]=Ce,e[65]=We,e[66]=n.availableWorktreesByProject,e[67]=n.gitBranches,e[68]=n.lastRepoStatus,e[69]=n.projectRepoStatus,e[70]=n.projectRootBranches,e[71]=n.projects,e[72]=r.hasSessionSearchQuery,e[73]=r.normalizedSessionSearchQuery,e[74]=U):U=e[74];const{projectSections:he,groupSearchDataByGroup:Re,sectionsForRender:Ie,flatSectionsForRender:rt,searchMatchCount:Ge}=D0(U),ut=r.onSearchMatchCountChange;let ct,ue;e[75]!==ut||e[76]!==Ge?(ct=()=>{ut(Ge)},ue=[ut,Ge],e[75]=ut,e[76]=Ge,e[77]=ct,e[78]=ue):(ct=e[77],ue=e[78]),c.useEffect(ct,ue);let G,Le;e[79]!==ut?(G=()=>()=>ut(0),Le=[ut],e[79]=ut,e[80]=G,e[81]=Le):(G=e[80],Le=e[81]),c.useEffect(G,Le);const Oe=Da(),qe=`session-collection-expansion:${c.useId()}`;let Ue,st;e[82]!==Oe||e[83]!==qe||e[84]!==he||e[85]!==g.collapsedGroups||e[86]!==g.collapsedProjects||e[87]!==r.activeProjectId?(Ue=()=>(Oe.setBootstrapDemand(qe,rm({projectSections:he,activeProjectId:r.activeProjectId,collapsedProjects:g.collapsedProjects,collapsedGroups:g.collapsedGroups,currentDirectory:null,currentSessionDirectory:null})),()=>Oe.clearBootstrapDemand(qe)),st=[Oe,qe,he,g.collapsedProjects,g.collapsedGroups,r.activeProjectId],e[82]=Oe,e[83]=qe,e[84]=he,e[85]=g.collapsedGroups,e[86]=g.collapsedProjects,e[87]=r.activeProjectId,e[88]=Ue,e[89]=st):(Ue=e[88],st=e[89]),c.useEffect(Ue,st);const wt=r.useGroupedSections?Ie:rt;let Nt;e[90]!==wt||e[91]!==r.showInlineArchived?(Nt=r.showInlineArchived?wt:wt.map(Tk),e[90]=wt,e[91]=r.showInlineArchived,e[92]=Nt):Nt=e[92];const ie=Nt;let pe;e[93]!==rt?(pe=Bt=>rt.find(ns=>ns.project.id===Bt)?.groups.find(Ek)?.folderScopes??[],e[93]=rt,e[94]=pe):pe=e[94];const Ve=pe;let ze;e[95]===Symbol.for("react.memo_cache_sentinel")?(ze=new Map,e[95]=ze):ze=e[95];const He=c.useRef(ze);let ot;e[96]!==he||e[97]!==r.isDesktopShellRuntime||e[98]!==r.stickyZoneHeaders?(ot={enabled:r.stickyZoneHeaders,isDesktopShellRuntime:r.isDesktopShellRuntime,projectSections:he,projectHeaderSentinelRefs:He},e[96]=he,e[97]=r.isDesktopShellRuntime,e[98]=r.stickyZoneHeaders,e[99]=ot):ot=e[99];const at=F2(ot);let et;e[100]!==p||e[101]!==y.hasAuthoritativeGlobalSessions||e[102]!==f||e[103]!==h||e[104]!==le||e[105]!==n.projects||e[106]!==r.isSessionsLoading||e[107]!==r.isWorktreeTopologyLoading||e[108]!==r.unresolvedWorktreeProjectPaths?(et={enabled:!0,normalizedProjects:n.projects,ownership:le,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:y.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:h,createFolder:f,addSessionToFolder:p},e[100]=p,e[101]=y.hasAuthoritativeGlobalSessions,e[102]=f,e[103]=h,e[104]=le,e[105]=n.projects,e[106]=r.isSessionsLoading,e[107]=r.isWorktreeTopologyLoading,e[108]=r.unresolvedWorktreeProjectPaths,e[109]=et):et=e[109],p0(et);const{github:Xe}=wn(),dt=An(Rk),Be=An(Mk),Se=Ks(Ok),St=Ks(Bk),vt=Ks(Fk);let Et;e[110]===Symbol.for("react.memo_cache_sentinel")?(Et=new Set,e[110]=Et):Et=e[110];const Ze=c.useRef(Et);let it;e[111]!==Se||e[112]!==Xe||e[113]!==Be||e[114]!==dt||e[115]!==he||e[116]!==g.collapsedProjects||e[117]!==vt||e[118]!==St||e[119]!==n.gitBranches?(it=()=>{if(!Xe||!Be||!dt?.connected)return;const Bt=new Map,Wt=Date.now();he.forEach(ns=>{g.collapsedProjects.has(ns.project.id)||ns.groups.forEach(us=>{if(us.isArchivedBucket||us.isMain)return;const xs=yt(us.directory??null),ee=us.branch?.trim()||n.gitBranches.get(xs||"")?.trim();if(!xs||!ee)return;const Ke=Ko(xs,ee),W=Ks.getState().entries[Ke],$e=W?.status?.pr?.state==="closed"||W?.status?.pr?.state==="merged",nt=`${xs}::${ee}`,jt=Math.max(W?.lastRefreshAt??0,W?.lastDiscoveryPollAt??0),Ct=!!(W?.isInitialStatusResolved&&(!W.status?.pr||$e)&&(!Ze.current.has(nt)||Wt-jt>=ck));(!W||!W.isInitialStatusResolved||Ct)&&(Ct&&Ze.current.add(nt),Bt.set(Ke,{directory:xs,branch:ee}))})}),Bt.forEach((ns,us)=>{Se(us),St(us,{...ns,remoteName:null,canShow:!0,github:Xe,githubAuthChecked:Be,githubConnected:dt.connected})}),Bt.size&&vt([...Bt.values()],{silent:!0,markInitialResolved:!0})},e[111]=Se,e[112]=Xe,e[113]=Be,e[114]=dt,e[115]=he,e[116]=g.collapsedProjects,e[117]=vt,e[118]=St,e[119]=n.gitBranches,e[120]=it):it=e[120];const gt=dt?.connected;let xt;e[121]!==Se||e[122]!==Xe||e[123]!==Be||e[124]!==he||e[125]!==g.collapsedProjects||e[126]!==vt||e[127]!==St||e[128]!==gt||e[129]!==n.gitBranches?(xt=[Se,Xe,Be,gt,he,g.collapsedProjects,vt,St,n.gitBranches],e[121]=Se,e[122]=Xe,e[123]=Be,e[124]=he,e[125]=g.collapsedProjects,e[126]=vt,e[127]=St,e[128]=gt,e[129]=n.gitBranches,e[130]=xt):xt=e[130],c.useEffect(it,xt);let Rt;e[131]!==y.orderedSessions?(Rt=new Map(y.orderedSessions.map(_k)),e[131]=y.orderedSessions,e[132]=Rt):Rt=e[132];const kt=Rt;let Tt;if(e[133]!==w||e[134]!==ie){let Bt;e[136]!==w?(Bt=Wt=>{const ns=w(Wt.project.id,Wt.groups);return ns===Wt.groups?Wt:{...Wt,groups:ns}},e[136]=w,e[137]=Bt):Bt=e[137],Tt=ie.map(Bt),e[133]=w,e[134]=ie,e[135]=Tt}else Tt=e[135];const Ot=Tt;let Vt;e[138]!==he||e[139]!==E||e[140]!==T||e[141]!==r.activeProjectId?(Vt=null,T&&(he.some(Bt=>Bt.project.id===E)?Vt=E:he.some(Bt=>Bt.project.id===r.activeProjectId)?Vt=r.activeProjectId:Vt=he[0]?.project.id??null),e[138]=he,e[139]=E,e[140]=T,e[141]=r.activeProjectId,e[142]=Vt):Vt=e[142];const Yt=T&&!r.useGroupedSections?20:void 0;let Ht;e[143]!==i.startSessionWorktreeMenuLoad||e[144]!==o||e[145]!==y.pinnedSessionIds||e[146]!==_||e[147]!==se||e[148]!==te||e[149]!==Q||e[150]!==be||e[151]!==ye||e[152]!==Re||e[153]!==l||e[154]!==g.collapsedGroups||e[155]!==u.allowReselect||e[156]!==u.isSessionSearchOpen||e[157]!==u.onSessionSelected||e[158]!==u.sessionSearchQuery||e[159]!==u.setIsSessionSearchOpen||e[160]!==u.setSessionSearchQuery||e[161]!==kt||e[162]!==Yt||e[163]!==Ee||e[164]!==r.activeProjectId||e[165]!==r.hasSessionSearchQuery||e[166]!==r.hideDirectoryControls||e[167]!==r.mobileVariant||e[168]!==r.normalizedSessionSearchQuery?(Ht={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:Re,collapsedGroups:g.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:y.pinnedSessionIds,sessionOrderIndex:kt,expandedParents:be,editingId:Q,editTitle:te,copiedSessionId:_,sessionBatchSize:Yt,setEditingId:q,setEditTitle:ae,toggleParent:Ee,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:se,setDeleteSessionConfirm:me,startFolderRename:re,setCopiedSessionId:ne,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,folderRename:ye,setFolderRenameDraft:de,clearFolderRename:Te},e[143]=i.startSessionWorktreeMenuLoad,e[144]=o,e[145]=y.pinnedSessionIds,e[146]=_,e[147]=se,e[148]=te,e[149]=Q,e[150]=be,e[151]=ye,e[152]=Re,e[153]=l,e[154]=g.collapsedGroups,e[155]=u.allowReselect,e[156]=u.isSessionSearchOpen,e[157]=u.onSessionSelected,e[158]=u.sessionSearchQuery,e[159]=u.setIsSessionSearchOpen,e[160]=u.setSessionSearchQuery,e[161]=kt,e[162]=Yt,e[163]=Ee,e[164]=r.activeProjectId,e[165]=r.hasSessionSearchQuery,e[166]=r.hideDirectoryControls,e[167]=r.mobileVariant,e[168]=r.normalizedSessionSearchQuery,e[169]=Ht):Ht=e[169];const Lt=Ht;let zt;e[170]!==d.openNewSessionDraft||e[171]!==d.setActiveProjectIdOnly||e[172]!==d.setSessionSwitcherOpen||e[173]!==x?(zt={showMoreGroupSessions:A,resetGroupSessionLimit:I,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,onToggleCollapsedGroup:x},e[170]=d.openNewSessionDraft,e[171]=d.setActiveProjectIdOnly,e[172]=d.setSessionSwitcherOpen,e[173]=x,e[174]=zt):zt=e[174];const Fe=zt;let Ye;e[175]!==Ne||e[176]!==Fe||e[177]!==Lt||e[178]!==X?(Ye=()=>Ne?s.jsx(vo,{...Lt,...Fe,group:Ne,groupKey:"managed-chats",projectId:null,hideGroupLabel:!0,sessionBatchSize:20,scrollContainerRef:void 0,openSidebarMenuKey:X,setOpenSidebarMenuKey:Z}):null,e[175]=Ne,e[176]=Fe,e[177]=Lt,e[178]=X,e[179]=Ye):Ye=e[179];const mt=Ye;let bt;e[180]!==d||e[181]!==r.mobileVariant?(bt=()=>{Pe.getState().closeMainSurfaces(),r.mobileVariant&&d.setSessionSwitcherOpen(!1),d.openNewSessionDraft({selectedProjectId:Lh,directoryOverride:null})},e[180]=d,e[181]=r.mobileVariant,e[182]=bt):bt=e[182];const ft=bt;let lt;e[183]!==i.startSessionWorktreeMenuLoad||e[184]!==o||e[185]!==y.chatSessions||e[186]!==y.childrenMap||e[187]!==y.pinnedSessionIds||e[188]!==_||e[189]!==se||e[190]!==te||e[191]!==Q||e[192]!==be||e[193]!==ft||e[194]!==l||e[195]!==X||e[196]!==L||e[197]!==mt||e[198]!==u.allowReselect||e[199]!==u.isSessionSearchOpen||e[200]!==u.onSessionSelected||e[201]!==u.sessionSearchQuery||e[202]!==u.setIsSessionSearchOpen||e[203]!==u.setSessionSearchQuery||e[204]!==M||e[205]!==T||e[206]!==Ee||e[207]!==n.availableWorktreesByProject||e[208]!==n.gitBranches||e[209]!==n.isVSCode||e[210]!==n.projects||e[211]!==r.hasSessionSearchQuery||e[212]!==r.homeDirectory||e[213]!==r.isDesktopShellRuntime||e[214]!==r.mobileVariant||e[215]!==r.normalizedSessionSearchQuery?(lt=n.isVSCode?null:s.jsx(nk,{projects:n.projects,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,isDesktopShellRuntime:r.isDesktopShellRuntime,sessions:L,childrenMap:y.childrenMap,pinnedSessionIds:y.pinnedSessionIds,recentSessions:L,expandedParents:be,notifyOnSubtasks:l,editingId:Q,editTitle:te,copiedSessionId:_,openSidebarMenuKey:X,mobileVariant:r.mobileVariant,alwaysShowActions:o,setEditingId:q,setEditTitle:ae,toggleParent:Ee,setOpenSidebarMenuKey:Z,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:se,setDeleteSessionConfirm:me,startFolderRename:re,setCopiedSessionId:ne,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,chatSessions:y.chatSessions,renderChatsSection:mt,onNewChat:ft,showRecentSection:M&&!T}),e[183]=i.startSessionWorktreeMenuLoad,e[184]=o,e[185]=y.chatSessions,e[186]=y.childrenMap,e[187]=y.pinnedSessionIds,e[188]=_,e[189]=se,e[190]=te,e[191]=Q,e[192]=be,e[193]=ft,e[194]=l,e[195]=X,e[196]=L,e[197]=mt,e[198]=u.allowReselect,e[199]=u.isSessionSearchOpen,e[200]=u.onSessionSelected,e[201]=u.sessionSearchQuery,e[202]=u.setIsSessionSearchOpen,e[203]=u.setSessionSearchQuery,e[204]=M,e[205]=T,e[206]=Ee,e[207]=n.availableWorktreesByProject,e[208]=n.gitBranches,e[209]=n.isVSCode,e[210]=n.projects,e[211]=r.hasSessionSearchQuery,e[212]=r.homeDirectory,e[213]=r.isDesktopShellRuntime,e[214]=r.mobileVariant,e[215]=r.normalizedSessionSearchQuery,e[216]=lt):lt=e[216];const $t=lt;let Zt;e[217]!==Re||e[218]!==We||e[219]!==r.hasSessionSearchQuery?(Zt=r.hasSessionSearchQuery&&We.some(Bt=>Re.get(Bt)?.hasMatch===!0),e[217]=Re,e[218]=We,e[219]=r.hasSessionSearchQuery,e[220]=Zt):Zt=e[220];const Xt=Zt,Ns=!!$t;let Jt;e[221]!==Q||e[222]!==X||e[223]!==N?(Jt={editingId:Q,openSidebarMenuKey:X,setOpenSidebarMenuKey:Z,visibleSessionCountByGroup:N},e[221]=Q,e[222]=X,e[223]=N,e[224]=Jt):Jt=e[224];let zs;e[225]!==Lt||e[226]!==Ot||e[227]!==he||e[228]!==$t||e[229]!==Vt||e[230]!==T||e[231]!==at||e[232]!==Ns||e[233]!==Jt||e[234]!==Xt||e[235]!==n.projectRepoStatus||e[236]!==r.activeProjectId||e[237]!==r.emptyState||e[238]!==r.searchEmptyState?(zs={topContent:$t,topContentHasSearchMatches:Xt,hasSharedSessions:Ns,sectionsForRender:Ot,projectSections:he,activeProjectId:r.activeProjectId,singleProjectMode:T,singleProjectId:Vt,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,stuckProjectHeaders:at,projectHeaderSentinelRefs:He,state:Jt,groupProps:Lt},e[225]=Lt,e[226]=Ot,e[227]=he,e[228]=$t,e[229]=Vt,e[230]=T,e[231]=at,e[232]=Ns,e[233]=Jt,e[234]=Xt,e[235]=n.projectRepoStatus,e[236]=r.activeProjectId,e[237]=r.emptyState,e[238]=r.searchEmptyState,e[239]=zs):zs=e[239];const Js=zs;let rs;e[240]!==o||e[241]!==g.collapsedProjects||e[242]!==r.hasSessionSearchQuery||e[243]!==r.hideDirectoryControls||e[244]!==r.homeDirectory||e[245]!==r.isDesktopShellRuntime||e[246]!==r.mobileVariant||e[247]!==r.normalizedSessionSearchQuery||e[248]!==r.projectSortOrder||e[249]!==r.showOnlyMainWorkspace||e[250]!==r.stickyZoneHeaders?(rs={homeDirectory:r.homeDirectory,collapsedProjects:g.collapsedProjects,showOnlyMainWorkspace:r.showOnlyMainWorkspace,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,hideDirectoryControls:r.hideDirectoryControls,isDesktopShellRuntime:r.isDesktopShellRuntime,stickyZoneHeaders:r.stickyZoneHeaders,mobileVariant:r.mobileVariant,alwaysShowActions:o,projectSortOrder:r.projectSortOrder},e[240]=o,e[241]=g.collapsedProjects,e[242]=r.hasSessionSearchQuery,e[243]=r.hideDirectoryControls,e[244]=r.homeDirectory,e[245]=r.isDesktopShellRuntime,e[246]=r.mobileVariant,e[247]=r.normalizedSessionSearchQuery,e[248]=r.projectSortOrder,e[249]=r.showOnlyMainWorkspace,e[250]=r.stickyZoneHeaders,e[251]=rs):rs=e[251];const Vs=rs;let Es;e[252]!==Fe||e[253]!==d.openNewSessionDraft||e[254]!==d.openNewWorktreeDialog||e[255]!==d.openProjectEditDialog||e[256]!==d.openWorktreesPage||e[257]!==d.removeProject||e[258]!==d.renderProjectStatusIndicator||e[259]!==d.reorderProjects||e[260]!==d.setActiveProjectIdOnly||e[261]!==d.setSessionSwitcherOpen||e[262]!==v||e[263]!==H||e[264]!==m?(Es={group:Fe,toggleProject:m,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,openNewWorktreeDialog:d.openNewWorktreeDialog,openWorktreesPage:d.openWorktreesPage,openProjectEditDialog:d.openProjectEditDialog,removeProject:d.removeProject,reorderProjects:d.reorderProjects,setGroupOrderByProject:v,renderProjectStatusIndicator:d.renderProjectStatusIndicator,setSingleProjectId:H},e[252]=Fe,e[253]=d.openNewSessionDraft,e[254]=d.openNewWorktreeDialog,e[255]=d.openProjectEditDialog,e[256]=d.openWorktreesPage,e[257]=d.removeProject,e[258]=d.renderProjectStatusIndicator,e[259]=d.reorderProjects,e[260]=d.setActiveProjectIdOnly,e[261]=d.setSessionSwitcherOpen,e[262]=v,e[263]=H,e[264]=m,e[265]=Es):Es=e[265];const cn=Es;let gs;e[266]===Symbol.for("react.memo_cache_sentinel")?(gs=s.jsx(u0,{}),e[266]=gs):gs=e[266];let vs;e[267]!==i.initialActiveSessionByProject||e[268]!==i.openNewSessionDraft||e[269]!==i.persistActiveSessionByProject||e[270]!==i.setSessionSwitcherOpen||e[271]!==le.bySessionId||e[272]!==he||e[273]!==ve||e[274]!==r.activeProjectId||e[275]!==r.mobileVariant?(vs=s.jsx(y0,{projectSections:he,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:le.bySessionId,handleSessionSelect:ve}),e[267]=i.initialActiveSessionByProject,e[268]=i.openNewSessionDraft,e[269]=i.persistActiveSessionByProject,e[270]=i.setSessionSwitcherOpen,e[271]=le.bySessionId,e[272]=he,e[273]=ve,e[274]=r.activeProjectId,e[275]=r.mobileVariant,e[276]=vs):vs=e[276];let Zs;e[277]!==y.orderedSessions||e[278]!==xe||e[279]!==L?(Zs=s.jsx(O0,{sortedSessions:y.orderedSessions,recentSessions:L,prefetchSession:xe}),e[277]=y.orderedSessions,e[278]=xe,e[279]=L,e[280]=Zs):Zs=e[280];let Rs;e[281]!==cn||e[282]!==Js||e[283]!==Vs?(Rs=s.jsx(O2,{model:Js,view:Vs,actions:cn}),e[281]=cn,e[282]=Js,e[283]=Vs,e[284]=Rs):Rs=e[284];const As=Q!==null;let Ps;e[285]!==Ve||e[286]!==As?(Ps=s.jsx(V2,{getFolderScopesForProject:Ve,isInlineEditing:As,startFolderRename:re}),e[285]=Ve,e[286]=As,e[287]=Ps):Ps=e[287];let js;return e[288]!==vs||e[289]!==Zs||e[290]!==Rs||e[291]!==Ps?(js=s.jsxs(s.Fragment,{children:[gs,vs,Zs,Rs,Ps]}),e[288]=vs,e[289]=Zs,e[290]=Rs,e[291]=Ps,e[292]=js):js=e[292],js},fk=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(mk,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function hk(t){return t.foldersMap}function pk(t){return t.createFolder}function gk(t){return t.addSessionToFolder}function xk(t){return t.showRecentSection}function bk(t){return t.projectDisplayMode}function yk(t){return t.singleProjectId}function wk(t){return t.setSingleProjectId}function Sk(t){return t.setCurrentSession}function vk(t){return zd(t.directory)}function jk(t){return yt(t.directory??null)}function kk(t){return!!t}function Ck(t){return{scopeKey:t,directory:t}}function Nk(t){return!t.time?.archived&&uk(t)}function Ak(t){return!t.time?.archived}function Pk(t){return{session:t,children:[],worktree:null}}function Dk(t){return t.isArchivedBucket}function Ik(t){return!t.isArchivedBucket}function Tk(t){return t.groups.some(Dk)?{...t,groups:t.groups.filter(Ik)}:t}function Ek(t){return!t.isArchivedBucket}function Rk(t){return t.status}function Mk(t){return t.hasChecked}function Ok(t){return t.ensureEntry}function Bk(t){return t.setParams}function Fk(t){return t.refreshTargets}function _k(t,e){return[t.id,e]}const hm=(t,e,n)=>{const r=new Set;for(const i of t){const o=yt(i.path)?.toLowerCase();o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=yt(o.path)?.toLowerCase();l&&r.add(l)}return r},Dc="oc.sessions.activeSessionByProject",Lk=[],$k=hu(xr(),xr().min(1).catch("")),Wk=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{wi("react.session_sidebar_render"),Gs("ui.session_sidebar.render"),Gs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Gs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=At(),[a,u]=c.useState(!1),[d,h]=c.useState(""),[f,p]=c.useState(0),g=c.useRef(null),w=c.useRef(null),[v,x]=c.useState(null),m=c.useMemo(()=>No(),[]),[b,y]=c.useState(new Map),S=Pe(Se=>Se.isNewWorktreeDialogOpen),N=Pe(Se=>Se.setNewWorktreeDialogOpen),[C,j]=c.useState(!1),A=c.useMemo(()=>{try{const Se=m.getItem(Dc);if(!Se)return new Map;const St=$k.safeParse(JSON.parse(Se));if(!St.success)return new Map;const vt=new Map;return Object.entries(St.data).forEach(([Et,Ze])=>{Ze&&vt.set(Et,Ze)}),vt}catch{return new Map}},[m]),D=c.useCallback(Se=>{try{m.setItem(Dc,JSON.stringify(Object.fromEntries(Se.entries())))}catch{}},[m]),[I,M]=c.useState(new Map),z=ts(Se=>Se.homeDirectory),E=Kt(Se=>Se.projects),H=Kt(Se=>Se.activeProjectId),B=Kt(Se=>Se.removeProject),O=Kt(Se=>Se.setActiveProjectIdOnly),T=Kt(Se=>Se.updateProjectMeta),k=Kt(Se=>Se.reorderProjects),P=Pe(Se=>Se.setSettingsDialogOpen),L=Pe(Se=>Se.toggleHelpDialog),Q=Pe(Se=>Se.setAboutDialogOpen),q=Pe(Se=>Se.setSessionSwitcherOpen),te=Pe(Se=>Se.setScheduledTasksDialogOpen),ae=Pe(Se=>Se.setArchivePageOpen),X=Pe(Se=>Se.setWorktreesPageProjectId),Z=Pe(Se=>Se.openMultiRunLauncher),se=Pe(Se=>Se.notifyOnSubtasks),me=Sa(d,120),_=c.useMemo(()=>me.trim().toLowerCase(),[me]),ne=_.length>0;Rv({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchContainerRef:g});const ye=Id(t),ce=c.useMemo(()=>Pn(),[]),F=Je(Se=>Se.setCurrentSession),re=Je(Se=>Se.worktreeMetadata),fe=Je(Se=>Se.availableWorktreesByProject),de=Je(Se=>Se.openNewSessionDraft),ge=c.useMemo(()=>hm(E,fe,{includeWorktrees:!ce}),[fe,ce,E]),Te=c.useCallback(Se=>{Pe.getState().closeMainSurfaces(),de(Se),ce&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[ce,de]),be=Or(Jn(Se=>({checkForUpdates:Se.checkForUpdates,available:Se.available,runtimeType:Se.runtimeType,info:Se.info,downloading:Se.downloading,downloaded:Se.downloaded,progress:Se.progress,error:Se.error,downloadUpdate:Se.downloadUpdate,restartToUpdate:Se.restartToUpdate}))),Ee=ps(),we=c.useMemo(()=>`${Ee}|${E.map(Se=>`${Se.id}:${yt(Se.path)??""}`).join("|")}`,[E,Ee]),[Y,ve]=c.useState(ce?we:null),[xe,je]=c.useReducer(Se=>Se+1,0),oe=!ce&&Y!==we,[J,K]=c.useState(new Set),$=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let Se=!1;return(async()=>{const vt=Ee,Et=Kt.getState().projects;if(Et.length===0||ce){Se||($.current={runtimeKey:null,revision:0,worktreesByProject:new Map},K(new Set),ve(we));return}const Ze=Je.getState().availableWorktreesByProject,it=na({rawWorktreesByProjectRef:$,publishedWorktreesByProject:Ze,runtimeKey:vt}),gt=it.revision,xt=new Map(it.worktreesByProject),Rt=new Set,kt=3;let Tt=0;const Ot=Array.from({length:kt},async()=>{for(;;){const Ht=Tt;if(Tt+=1,Ht>=Et.length)return;const Lt=Et[Ht],zt=yt(Lt.path);if(zt)try{const Fe=await Ni(async()=>On.getState().directories.get(zt)?.isGitRepo??await Uo(zt)?al({id:Lt.id,path:zt}):null);if(Fe===null){xt.delete(zt);continue}if(Se)return;Fe.length===0?xt.delete(zt):xt.set(zt,Fe)}catch{Rt.add(zt)}}});if(await Promise.all(Ot),Se||ps()!==vt)return;const Vt=new Set(Et.map(Ht=>yt(Ht.path)).filter(Boolean));for(const Ht of xt.keys())Vt.has(Ht)||xt.delete(Ht);Gj({rawWorktreesByProjectRef:$,runtimeKey:vt,capturedRevision:gt,nextRawWorktreesByProject:xt,publishedWorktreesByProject:Ze,partitionWorktreesByRegisteredProject:cl,projects:Et,worktreeMapsEqual:ll,recordWorktreesSeen:Nc,publishTopology:Ht=>{Je.setState(Ht)},requestRediscovery:()=>{je()},now:()=>Date.now()})&&(K(Rt),ve(we))})(),()=>{Se=!0}},[ce,we,Ee,xe]),c.useEffect(()=>{if(!ce)return Yr(Se=>{Se.type==="session-created"&&je()})},[ce]);const le=c.useMemo(()=>xn(),[]),{isTablet:V}=_n(),Ce=e||V,_e=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),ke=c.useMemo(()=>E.find(Se=>Se.id===v)??null,[E,v]),Ne=c.useCallback(Se=>{v&&T(v,{label:Se.label,icon:Se.icon,color:Se.color,iconBackground:Se.iconBackground,defaultModel:Se.defaultModel??null})},[v,T]),Qe=c.useCallback(()=>{N(!0)},[N]),We=c.useCallback(()=>{const Se=Or.getState();if(Se.available&&Se.info){j(!0);return}be.checkForUpdates().then(()=>{const{available:St,error:vt}=Or.getState();if(vt){Me.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:vt});return}if(!St){Me.success(l("sessions.sidebar.updateCheck.latestVersion"));return}j(!0)})},[l,be]),U=c.useCallback(()=>{e&&q(!1),P(!0)},[e,q,P]),he=be.available&&(be.runtimeType==="desktop"||be.runtimeType==="web"),Re=c.useCallback(()=>{gn.requestDirectoryDialog()},[]),Ie=c.useMemo(()=>E.flatMap(Se=>{const St=yt(Se.path);return St?[{id:Se.id,path:Se.path,label:Se.label,normalizedPath:St,icon:Se.icon??void 0,color:Se.color??void 0,iconImage:Se.iconImage??void 0,iconBackground:Se.iconBackground??void 0,addedAt:Se.addedAt,lastOpenedAt:Se.lastOpenedAt,sidebarCollapsed:Se.sidebarCollapsed}]:[]}),[E]),rt=c.useMemo(()=>Ie.map(Se=>Se.normalizedPath),[Ie]),Ge=$h(t?rt:Lk);Wv({enabled:t,normalizedProjects:Ie,gitRepoStatus:Ge,setProjectRepoStatus:y,setProjectRootBranches:M});const ut=Je(Se=>Se.isLoading),ct=c.useRef(!1);H&&b.has(H)&&(ct.current=!!b.get(H));const ue=ls(Se=>Se.showArchivedSessions),G=ls(Se=>Se.projectSortOrder),Le=ls(Se=>Se.stickyZoneHeaders),Oe=Kt(Se=>Se.manualProjectOrder),qe={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:V,projects:E,activeProjectId:H,manualProjectOrder:Oe,worktreeMetadata:re,availableWorktreesByProject:fe,gitBranches:ye,gitRepoStatus:Ge,updateStore:be,showArchivedSessions:ue,projectSortOrder:G,projectRepoStatus:b,projectRootBranches:I,resolvedWorktreeTopologyKey:Y,unresolvedWorktreeProjectPaths:J,isSessionSearchOpen:a,sessionSearchQuery:d,editingProjectDialogId:v,updateDialogOpen:C},Ue=c.useRef(null),st=Ue.current;if(st){let Se=!1;for(const St of Object.keys(qe))Object.is(st[St],qe[St])||(Gs(`ui.session_sidebar.source.${St}`),Se=!0);Se||Gs("ui.session_sidebar.source.parent_or_context")}Ue.current=qe;const wt=c.useMemo(()=>dg(Ie,G,Oe),[Ie,G,Oe]),Nt=Fv({isVSCode:ce,projects:wt}),ie=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),pe=ce&&ue,ze=ls(Se=>Se.sessionGroupingMode)==="by-worktree"&&!ce,at=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed",et="h-4.5 w-4.5",Xe=c.useCallback(()=>{e&&q(!1),Z()},[e,Z,q]),dt=c.useCallback(Se=>{const St=Se.projectId?E.find(vt=>vt.id===Se.projectId)??null:Se.sourceDirectory?vi(Se.sourceDirectory):null;return Hj(Se,{projects:E,getCurrentProjects:()=>Kt.getState().projects,rawWorktreesByProjectRef:$,getPublishedWorktreesByProject:()=>Je.getState().availableWorktreesByProject,resolveProject:vt=>vi(vt),listProjectWorktrees:al,partitionWorktreesByRegisteredProject:cl,worktreeMapsEqual:ll,recordWorktreesSeen:Nc,publishTopology:vt=>{Je.setState(vt)},getRuntimeKey:ps,now:()=>Date.now(),projectRootBranch:St?I.get(St.id)??null:null})},[I,E]),Be=c.useCallback(()=>{Pe.getState().closeMainSurfaces(),e&&q(!1),de()},[e,de,q]);return s.jsx(Ii,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:g,className:De("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[!i&&!ce?s.jsx(l0,{onNewSession:Be}):null,s.jsx(qv,{hideDirectoryControls:i,showProjectDisplayControls:!ce,showRecentControls:!ce,handleOpenDirectoryDialog:Re,onOpenScheduled:()=>{e&&q(!1),te(!0)},onOpenMultiRun:Xe,canOpenMultiRun:E.length>0,onOpenArchive:()=>{e&&q(!1),ae(!0)},headerActionIconClass:et,headerActionButtonClass:at,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchQuery:d,setSessionSearchQuery:h,hasSessionSearchQuery:ne,searchMatchCount:f,collapseAllProjects:Nt.actions.collapseAllProjects,expandAllProjects:Nt.actions.expandAllProjects}),s.jsx(fk,{topology:{projects:wt,availableWorktreesByProject:fe,knownDirectories:ge,isVSCode:ce,worktreeMetadata:re,gitBranches:ye,projectRepoStatus:b,projectRootBranches:I,lastRepoStatus:ct.current},view:{isVisible:t,hasSessionSearchQuery:ne,normalizedSessionSearchQuery:_,activeProjectId:H,showInlineArchived:pe,useGroupedSections:ze,homeDirectory:z,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:le,stickyZoneHeaders:Le,projectSortOrder:G,emptyState:_e,searchEmptyState:ie,isSessionsLoading:ut,isWorktreeTopologyLoading:oe,unresolvedWorktreeProjectPaths:J,projectView:Nt.state,onSearchMatchCountChange:p},actions:{rowActions:{allowReselect:r,onSessionSelected:n,isSessionSearchOpen:a,sessionSearchQuery:d,setSessionSearchQuery:h,setIsSessionSearchOpen:u},alwaysShowActions:Ce,notifyOnSubtasks:se,setActiveProjectIdOnly:O,setSessionSwitcherOpen:q,openNewSessionDraft:Te,openNewWorktreeDialog:Qe,openWorktreesPage:Se=>{e&&q(!1),X(Se)},openProjectEditDialog:x,removeProject:B,reorderProjects:k,startSessionWorktreeMenuLoad:dt,initialActiveSessionByProject:A,persistActiveSessionByProject:D,projectViewActions:Nt.actions}}),s.jsx(c0,{onOpenSettings:U,onOpenShortcuts:L,onOpenAbout:()=>Q(!0),onOpenUpdate:We,showRuntimeButtons:!ce,showUpdateButton:he}),s.jsx(Xd,{open:C,onOpenChange:j,info:be.info,downloading:be.downloading,downloaded:be.downloaded,progress:be.progress,error:be.error,onDownload:be.downloadUpdate,onRestart:be.restartToUpdate,runtimeType:be.runtimeType}),s.jsx(Hv,{open:!!ke,onOpenChange:Se=>{Se||x(null)},project:ke,onSave:Ne}),s.jsx(ug,{open:S,onOpenChange:N,onWorktreeCreated:(Se,St)=>{if(Pe.getState().closeMainSurfaces(),e&&q(!1),St?.sessionId){F(St.sessionId,Se);return}de({directoryOverride:Se,preserveDirectoryOverride:!0})}})]})})},zk=c.memo(Wk),jn=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,un=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Vk=()=>{const{t}=At(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,u]=c.useState([]),[d,h]=c.useState(!1),[f,p]=c.useState(!1),[g,w]=c.useState(!1),[v,x]=c.useState(!1),[m,b]=c.useState(new Set),y=Je(Y=>Y.getWorktreeMetadata),S=Je(Y=>Y.newSessionDraft),N=Je(Y=>Y.setNewSessionDraftTarget),C=Je(Y=>Y.setDraftBootstrapPendingDirectory),j=Wh,A=Je(Y=>Y.deleteSessions),D=Je(Y=>Y.archiveSessions),I=Pe(Y=>Y.showDeletionDialog),M=Pe(Y=>Y.setShowDeletionDialog),z=ts(Y=>Y.currentDirectory),E=ts(Y=>Y.homeDirectory),H=ts(Y=>Y.isHomeReady),B=Kt(Y=>Y.projects),O=Kt(Y=>Y.activeProjectId),{isMobile:T,isTablet:k,hasTouchInput:P}=_n(),L=T||k||P,Q=c.useMemo(()=>{const ve=(O?B.find(xe=>xe.id===O)??null:null)?.path??z;return un(ve)},[O,z,B]),q=c.useCallback(Y=>{const xe=un(Y.projectDirectory)||Q;return{id:(B.find(oe=>un(oe.path)===xe)??null)?.id??`path:${xe}`,path:xe}},[Q,B]),te=v&&m.size>0,ae=c.useMemo(()=>{const Y=o?.worktree;return Y&&typeof Y.branch=="string"&&Y.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:ve})=>typeof ve.branch=="string"&&ve.branch.trim().length>0)},[o?.worktree,a]),X=o?.mode==="worktree",Z=X,se=g||!X||!ae,me=g||!X;c.useEffect(()=>{r||!H||B.length>0||(i(!0),n(!0))},[r,H,B.length]);const _=c.useCallback(Y=>{l({sessions:Y.sessions,dateLabel:Y.dateLabel,mode:Y.mode??"session",worktree:Y.worktree??null})},[]),ne=c.useCallback(()=>{l(null),u([]),h(!1),p(!1),w(!1),x(!1),b(new Set)},[]),ye=c.useCallback(async Y=>{if(Y.sessions.length===0)return;if(Y.sessions.length===1){const oe=Y.sessions[0];await j(oe.id)?Me.success(t("sessions.sidebar.session.delete.success")):Me.error(t("sessions.sidebar.session.delete.error"));return}const ve=Y.sessions.map(oe=>oe.id),{deletedIds:xe,failedIds:je}=await A(ve);if(xe.length>0){const oe=je.length>0?je.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:je.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:je.length}):Y.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:Y.dateLabel}):void 0;Me.success(xe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:xe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:xe.length}),{description:jn(oe)})}je.length>0&&Me.error(je.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:je.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:je.length}),{description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[j,A,t]);c.useEffect(()=>gn.onDeleteRequest(Y=>{if(!I&&(Y.mode??"session")==="session"){ye(Y);return}_(Y)}),[_,I,ye]),c.useEffect(()=>gn.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){u([]),h(!1),p(!1),x(!1),b(new Set);return}const Y=o.sessions.map(je=>{const oe=y(je.id);return oe?{session:je,metadata:oe}:null}).filter(je=>!!je);u(Y),h(!1),x(!1),b(new Set);const ve=new Map;if(o.worktree?.path&&ve.set(un(o.worktree.path),o.worktree),Y.forEach(({metadata:je})=>{je.path&&ve.set(un(je.path),je)}),ve.size===0){x(!0);return}let xe=!1;return(async()=>{const je=new Map,oe=new Set;await Promise.all(Array.from(ve.entries()).map(async([J,K])=>{try{const $=await zh(K.path);je.set(J,$),$?.isDirty&&oe.add(J)}catch{K.status&&(je.set(J,K.status),K.status.isDirty&&oe.add(J))}})).catch(J=>{console.warn("Failed to inspect worktree status before deletion:",J)}),!xe&&(b(oe),x(!0),l(J=>{if(!J?.worktree?.path)return J;const K=un(J.worktree.path),$=je.get(K);if(!$)return J;const le=J.worktree.status;return le?.isDirty===$.isDirty&&le?.ahead===$.ahead&&le?.behind===$.behind&&le?.upstream===$.upstream?J:{...J,worktree:{...J.worktree,status:$}}}),u(J=>J.map(K=>{const $=un(K.metadata.path),le=je.get($);return le?{session:K.session,metadata:{...K.metadata,status:le}}:K})))})(),()=>{xe=!0}},[o,y]),c.useEffect(()=>{ae||h(!1)},[ae]);const ce=c.useCallback(async(Y,ve,xe)=>{const je=d&&ae,oe=q(Y),J=un(Y.path),K=un(oe.path);try{await bd(oe,Y,{deleteRemoteBranch:je,deleteLocalBranch:ve});const $=un(S?.directoryOverride);return S?.open&&J&&$===J&&K&&(C(null),N({projectId:oe.id,directoryOverride:K},{force:!0})),un(z)===J&&K&&ts.getState().setDirectory(K,{showOverlay:!1}),!0}catch($){return Me.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:ti(Y)}),{id:xe,description:jn($ instanceof Error?$.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ae,z,d,q,S?.directoryOverride,S?.open,C,N,t]),F=c.useCallback((Y,ve,xe)=>{const je=d&&ae,oe=Me.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:ti(Y)}));(async()=>{try{if(ve.length>0){const{failedIds:$}=await D(ve);if($.length>0){Me.error($.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:$.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:$.length}),{id:oe,description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await ce(Y,xe,oe))return;const K=t(je?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Me.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:ti(Y)}),{id:oe,description:jn(K)})}catch(J){Me.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:oe,description:jn(J instanceof Error?J.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[D,ae,d,ce,t]),re=c.useCallback(async()=>{if(o){w(!0);try{const Y=Z,ve=Y&&d,xe=Y&&f;if(X&&o.worktree){F(o.worktree,o.sessions.map(je=>je.id),xe),ne();return}if(o.sessions.length===1){const je=o.sessions[0];if(!await j(je.id)){Me.error(t("sessions.sidebar.session.delete.error")),w(!1);return}const J=!X&&Y?t(ve?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Me.success(t("sessions.sidebar.session.delete.success"),{description:jn(J),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const je=o.sessions.map($=>$.id);let oe=[],J=[];const K=await A(je);if(oe=K.deletedIds,J=K.failedIds,oe.length>0){const $=!X&&Y?t(ve?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,V=[J.length>0?J.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:J.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:J.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,$].filter(Boolean).join(" ");Me.success(oe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:oe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:oe.length}),{description:jn(V||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(J.length>0&&(Me.error(J.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:J.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:J.length}),{description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),oe.length===0)){w(!1);return}}ne()}finally{w(!1)}}},[o,d,f,j,A,ne,Z,X,F,t]),fe=o?.worktree??a[0]?.metadata??null,de=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",ge=o?s.jsxs("div",{className:De(X?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:De(X?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[X&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:De(X?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(Y=>s.jsxs("li",{className:De(X?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:De(!X&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:Y.title||t("sessions.sidebar.session.untitled")})]},Y.id)),o.sessions.length>5&&s.jsx("li",{className:De(X?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),X?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(R,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),fe?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:fe.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:fe?Wr(fe.path,E):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),te&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Te=X?ae?s.jsxs("button",{type:"button",onClick:()=>{se||h(Y=>!Y)},disabled:se,className:De("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",se?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[d?s.jsx(R,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(R,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,be=X?s.jsxs("button",{type:"button",onClick:()=>{me||p(Y=>!Y)},disabled:me,className:De("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",me?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[f?s.jsx(R,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(R,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Ee=X?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[be,Te]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pt,{variant:"ghost",onClick:ne,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(pt,{variant:"destructive",onClick:re,disabled:g,children:t(g?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>M(!I),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":!I,children:[I?s.jsx(R,{name:"checkbox-blank",className:"size-4"}):s.jsx(R,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pt,{variant:"ghost",onClick:ne,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(pt,{variant:"destructive",onClick:re,disabled:g,children:g?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),we=X?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[L?s.jsx(Ho,{open:!!o,onClose:()=>{g||ne()},title:we,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Ee}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[de&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:de}),ge]})}):s.jsx(ws,{open:!!o,onOpenChange:Y=>{if(!Y){if(g)return;ne()}},children:s.jsxs(Ss,{className:De(X?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Ws,{children:[s.jsxs(Is,{className:De(X&&"flex items-center gap-2"),children:[X&&s.jsx(R,{name:"delete-bin",className:"h-5 w-5"}),we]}),de&&s.jsx(Ts,{children:de})]}),s.jsx("div",{className:De(X&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:ge}),s.jsx(bn,{className:"mt-2 gap-2 pt-1 pb-1",children:Ee})]})}),s.jsx(mg,{open:e,onOpenChange:n})]})};function Uk(t){const e=tt.c(64),{t:n}=At(),{value:r,onMoveSessionOnly:i,onMoveAllChanges:o,onCancel:l}=t,a=!!r;let u;e[0]!==l?(u=T=>{T||l()},e[0]=l,e[1]=u):u=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.session.moveToWorktree.confirm.title"),e[2]=n,e[3]=d):d=e[3];let h;e[4]!==d?(h=s.jsx(Is,{children:d}),e[4]=d,e[5]=h):h=e[5];const f=r?.dirtyFileCount??0;let p;e[6]!==n||e[7]!==f?(p=n("sessions.sidebar.session.moveToWorktree.confirm.changedFiles",{count:f}),e[6]=n,e[7]=f,e[8]=p):p=e[8];let g;e[9]!==n?(g=n("sessions.sidebar.session.moveToWorktree.confirm.ownership"),e[9]=n,e[10]=g):g=e[10];let w;e[11]!==p||e[12]!==g?(w=s.jsxs(Ts,{children:[p," ",g]}),e[11]=p,e[12]=g,e[13]=w):w=e[13];let v;e[14]!==h||e[15]!==w?(v=s.jsxs(Ws,{children:[h,w]}),e[14]=h,e[15]=w,e[16]=v):v=e[16];let x;e[17]!==n?(x=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnlyHelp"),e[17]=n,e[18]=x):x=e[18];let m;e[19]!==x?(m=s.jsx("p",{children:x}),e[19]=x,e[20]=m):m=e[20];let b;e[21]!==n?(b=n("sessions.sidebar.session.moveToWorktree.confirm.allChangesHelp"),e[21]=n,e[22]=b):b=e[22];let y;e[23]!==b?(y=s.jsx("p",{children:b}),e[23]=b,e[24]=y):y=e[24];let S;e[25]!==n||e[26]!==r?(S=r&&r.stagedFileCount>0?s.jsx("p",{"data-session-worktree-move-staged-warning":"true",children:n("sessions.sidebar.session.moveToWorktree.confirm.stagedWarning")}):null,e[25]=n,e[26]=r,e[27]=S):S=e[27];let N;e[28]!==n?(N=n("sessions.sidebar.session.moveToWorktree.confirm.baseWarning"),e[28]=n,e[29]=N):N=e[29];let C;e[30]!==N?(C=s.jsx("p",{children:N}),e[30]=N,e[31]=C):C=e[31];let j;e[32]!==m||e[33]!==y||e[34]!==S||e[35]!==C?(j=s.jsxs("div",{className:"space-y-2 typography-ui-label text-muted-foreground",children:[m,y,S,C]}),e[32]=m,e[33]=y,e[34]=S,e[35]=C,e[36]=j):j=e[36];let A;e[37]!==n?(A=n("sessions.sidebar.session.moveToWorktree.confirm.cancel"),e[37]=n,e[38]=A):A=e[38];let D;e[39]!==l||e[40]!==A?(D=s.jsx(pt,{type:"button",variant:"neutral","data-session-worktree-move-action":"cancel",onClick:l,children:A}),e[39]=l,e[40]=A,e[41]=D):D=e[41];let I;e[42]!==n?(I=n("sessions.sidebar.session.moveToWorktree.confirm.allChanges"),e[42]=n,e[43]=I):I=e[43];let M;e[44]!==o||e[45]!==I?(M=s.jsx(pt,{type:"button",variant:"outline","data-session-worktree-move-action":"all-changes",onClick:o,children:I}),e[44]=o,e[45]=I,e[46]=M):M=e[46];let z;e[47]!==n?(z=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnly"),e[47]=n,e[48]=z):z=e[48];let E;e[49]!==i||e[50]!==z?(E=s.jsx(pt,{type:"button",autoFocus:!0,"data-session-worktree-move-action":"session-only",onClick:i,children:z}),e[49]=i,e[50]=z,e[51]=E):E=e[51];let H;e[52]!==D||e[53]!==M||e[54]!==E?(H=s.jsxs(bn,{className:"gap-2 sm:justify-end",children:[D,M,E]}),e[52]=D,e[53]=M,e[54]=E,e[55]=H):H=e[55];let B;e[56]!==j||e[57]!==H||e[58]!==v?(B=s.jsxs(Ss,{id:"session-worktree-move-confirm-dialog",showCloseButton:!1,className:"max-w-md gap-5",children:[v,j,H]}),e[56]=j,e[57]=H,e[58]=v,e[59]=B):B=e[59];let O;return e[60]!==a||e[61]!==u||e[62]!==B?(O=s.jsx(ws,{open:a,onOpenChange:u,children:B}),e[60]=a,e[61]=u,e[62]=B,e[63]=O):O=e[63],O}function pm(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return pu.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function Kk(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=pu.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const Hk=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],Gk={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},Gn=t=>Gk[t]??t,gm=[0,1,2,3,4,5,6],Ic="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",aa=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(Gn))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],Tc=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},jo=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},Ec=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},qk=(t,e,n)=>{const r=jo(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},Rc=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),Qk=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),u=new Date(n,r,0).getDate(),d=[];for(let h=0;h<42;h+=1){const f=h-l+1;if(f<=0){const p=u+f;d.push({date:new Date(n,r-1,p),inCurrentMonth:!1});continue}if(f>a){d.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}d.push({date:new Date(n,r,f),inCurrentMonth:!0})}return d},Yk=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},zn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},wr=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},Mc=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:wr(t,{min:1,max:12}),uo=t=>/^[0-5][0-9]$/.test(t)?t:wr(t,{max:59}),Xk=(t,e)=>wr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),Oc=(t,e)=>wr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),Jk=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},Zk=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},e3=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return gm.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},t3=(t,e)=>[...t.slice(e),...t.slice(0,e)],Ms=t=>{const e=tt.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},Bc=t=>{const e=tt.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:u,pmLabel:d}=t;let h;e[0]!==n?(h=Yk(n),e[0]=n,e[1]=h):h=e[1];const f=h,p=ht.useRef(null),g=ht.useRef(null),[w,v]=ht.useState(null),[x,m]=ht.useState(null),b=ht.useRef(null),y=ht.useRef(null);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=Y=>{b.current=Y,v(Y)},e[2]=S):S=e[2];const N=S;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=Y=>{y.current=Y,m(Y)},e[3]=C):C=e[3];const j=C,A=l3,D=c3,I=d3;let M;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(M=Y=>{const ve=Y.replace(/\D/g,"").slice(0,2);N(ve),ve.length===2&&(r(i?I(A(ve),f.minute):zn(Mc(ve),f.minute,f.meridiem)),N(null),g.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=i,e[8]=M):M=e[8];const z=M;let E;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(E=()=>{const Y=b.current;if(Y!==null&&(N(null),Y.length!==0)){if(i){r(I(A(Y.padStart(2,"0")),f.minute));return}r(zn(Mc(Y.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=E):E=e[13];const H=E;let B;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(B=Y=>{const ve=Y.replace(/\D/g,"").slice(0,2);j(ve),ve.length===2&&(r(i?I(f.hour24,uo(ve)):zn(f.hour12,uo(ve),f.meridiem)),j(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=B):B=e[19];const O=B;let T;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?(T=()=>{const Y=y.current;Y!==null&&(j(null),Y.length!==0&&r(i?I(f.hour24,uo(Y.padStart(2,"0"))):zn(f.hour12,uo(Y.padStart(2,"0")),f.meridiem)))},e[20]=r,e[21]=f.hour12,e[22]=f.hour24,e[23]=f.meridiem,e[24]=i,e[25]=T):T=e[25];const k=T;let P;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(P=Y=>r(i?I(D(f.hour24,Y),f.minute):zn(Xk(f.hour12,Y),f.minute,f.meridiem)),e[26]=r,e[27]=f.hour12,e[28]=f.hour24,e[29]=f.meridiem,e[30]=f.minute,e[31]=i,e[32]=P):P=e[32];const L=P;let Q;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(Q=Y=>r(i?I(f.hour24,Oc(f.minute,Y)):zn(f.hour12,Oc(f.minute,Y),f.meridiem)),e[33]=r,e[34]=f.hour12,e[35]=f.hour24,e[36]=f.meridiem,e[37]=f.minute,e[38]=i,e[39]=Q):Q=e[39];const q=Q;let te;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(te=Y=>{Y!==f.meridiem&&r(zn(f.hour12,f.minute,Y))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=te):te=e[44];const ae=te;let X;e[45]!==H||e[46]!==L?(X=Y=>{if(Y.key==="ArrowRight"){Y.preventDefault(),H(),g.current?.focus();return}(Y.key==="ArrowUp"||Y.key==="ArrowDown")&&(Y.preventDefault(),N(null),L(Y.key==="ArrowUp"?1:-1))},e[45]=H,e[46]=L,e[47]=X):X=e[47];const Z=X;let se;e[48]!==k||e[49]!==q?(se=Y=>{if(Y.key==="ArrowLeft"&&(Y.currentTarget.selectionStart??0)===0){Y.preventDefault(),k(),p.current?.focus();return}(Y.key==="ArrowUp"||Y.key==="ArrowDown")&&(Y.preventDefault(),j(null),q(Y.key==="ArrowUp"?1:-1))},e[48]=k,e[49]=q,e[50]=se):se=e[50];const me=se,_=i?"px-2":"pl-2 pr-1";let ne;e[51]!==_?(ne=De("inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-background focus-within:ring-1 focus-within:ring-interactive-focusRing focus-within:border-interactive-focusRing",_),e[51]=_,e[52]=ne):ne=e[52];const ye=w??(i?f.hour24:f.hour12);let ce;e[53]!==z?(ce=Y=>z(Y.target.value),e[53]=z,e[54]=ce):ce=e[54];let F;e[55]===Symbol.for("react.memo_cache_sentinel")?(F=()=>N(""),e[55]=F):F=e[55];let re;e[56]!==H||e[57]!==o||e[58]!==Z||e[59]!==ye||e[60]!==ce?(re=s.jsx("input",{ref:p,inputMode:"numeric",value:ye,onChange:ce,onKeyDown:Z,onFocus:F,onBlur:H,maxLength:2,"aria-label":o,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=H,e[57]=o,e[58]=Z,e[59]=ye,e[60]=ce,e[61]=re):re=e[61];let fe;e[62]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=fe):fe=e[62];const de=x??f.minute;let ge;e[63]!==O?(ge=Y=>O(Y.target.value),e[63]=O,e[64]=ge):ge=e[64];let Te;e[65]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>j(""),e[65]=Te):Te=e[65];let be;e[66]!==k||e[67]!==l||e[68]!==me||e[69]!==de||e[70]!==ge?(be=s.jsx("input",{ref:g,inputMode:"numeric",value:de,onChange:ge,onKeyDown:me,onFocus:Te,onBlur:k,maxLength:2,"aria-label":l,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=k,e[67]=l,e[68]=me,e[69]=de,e[70]=ge,e[71]=be):be=e[71];let Ee;e[72]!==u||e[73]!==f.meridiem||e[74]!==a||e[75]!==d||e[76]!==ae||e[77]!==i?(Ee=i?null:s.jsxs(Bs,{value:f.meridiem,onValueChange:Y=>ae(Y),children:[s.jsx(Fs,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(Cs,{})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"AM",children:u}),s.jsx(ss,{value:"PM",children:d})]})]}),e[72]=u,e[73]=f.meridiem,e[74]=a,e[75]=d,e[76]=ae,e[77]=i,e[78]=Ee):Ee=e[78];let we;return e[79]!==ne||e[80]!==re||e[81]!==be||e[82]!==Ee?(we=s.jsxs("div",{className:ne,children:[re,fe,be,Ee]}),e[79]=ne,e[80]=re,e[81]=be,e[82]=Ee,e[83]=we):we=e[83],we},Fc=t=>new Date(t.getFullYear(),t.getMonth(),1),s3=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},_c=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),n3=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},Lc=(t,e)=>{const n=Gn(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:n3(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:Tc(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:Gn(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:Tc(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},r3=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!pm(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},o3=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},i3=t=>{const e=tt.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?pm(l):null,e[0]=l,e[1]=a):a=e[1];const u=a;let d;e:{if(!u?.valid||!l.trim()){let P;e[2]===Symbol.for("react.memo_cache_sentinel")?(P=[],e[2]=P):P=e[2],d=P;break e}let k;e[3]!==l||e[4]!==n.schedule.timezone?(k=Kk(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=k):k=e[5],d=k}const h=d;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=k=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(k),e[6]=n.schedule.timezone,e[7]=i,e[8]=f):f=e[8];const p=f;let g;e[9]!==o?(g=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=g):g=e[10];let w;e[11]!==g?(w=s.jsx(Ms,{htmlFor:"sched-cron",required:!0,children:g}),e[11]=g,e[12]=w):w=e[12];let v;e[13]!==r?(v=k=>r(P=>({...P,schedule:{...P.schedule,cronExpression:k.target.value}})),e[13]=r,e[14]=v):v=e[14];let x;e[15]!==o?(x=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=x):x=e[16];let m;e[17]!==l||e[18]!==v||e[19]!==x?(m=s.jsx(Cn,{id:"sched-cron",value:l,onChange:v,placeholder:x,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=v,e[19]=x,e[20]=m):m=e[20];let b;e[21]!==l||e[22]!==u||e[23]!==o?(b=u&&!u.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=u,e[23]=o,e[24]=b):b=e[24];let y;e[25]!==w||e[26]!==m||e[27]!==b?(y=s.jsxs("div",{className:"flex flex-col gap-1",children:[w,m,b]}),e[25]=w,e[26]=m,e[27]=b,e[28]=y):y=e[28];let S;e[29]!==p||e[30]!==h||e[31]!==o?(S=h.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:h.map(p).join(", ")})]}):null,e[29]=p,e[30]=h,e[31]=o,e[32]=S):S=e[32];let N;e[33]!==o?(N=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=N):N=e[34];let C;e[35]!==N?(C=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[35]=N,e[36]=C):C=e[36];let j;e[37]!==r||e[38]!==o?(j=Hk.map(k=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(P=>({...P,schedule:{...P.schedule,cronExpression:k.expression}})),children:[s.jsx("span",{className:"font-mono",children:k.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(k.labelKey)})]},k.expression)),e[37]=r,e[38]=o,e[39]=j):j=e[39];let A;e[40]!==j?(A=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:j}),e[40]=j,e[41]=A):A=e[41];let D;e[42]!==C||e[43]!==A?(D=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,A]}),e[42]=C,e[43]=A,e[44]=D):D=e[44];let I;e[45]!==o?(I=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=I):I=e[46];let M;e[47]!==I?(M=s.jsx(Ms,{children:I}),e[47]=I,e[48]=M):M=e[48];let z;e[49]!==r?(z=k=>{r(P=>({...P,schedule:{...P.schedule,timezone:k}}))},e[49]=r,e[50]=z):z=e[50];let E;e[51]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),e[51]=E):E=e[51];let H;e[52]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(_s,{children:aa.map(u3)}),e[52]=H):H=e[52];let B;e[53]!==n.schedule.timezone||e[54]!==z?(B=s.jsxs(Bs,{value:n.schedule.timezone,onValueChange:z,children:[E,H]}),e[53]=n.schedule.timezone,e[54]=z,e[55]=B):B=e[55];let O;e[56]!==M||e[57]!==B?(O=s.jsxs("div",{className:"flex flex-col gap-1",children:[M,B]}),e[56]=M,e[57]=B,e[58]=O):O=e[58];let T;return e[59]!==y||e[60]!==S||e[61]!==D||e[62]!==O?(T=s.jsxs("div",{className:"flex flex-col gap-3",children:[y,S,D,O]}),e[59]=y,e[60]=S,e[61]=D,e[62]=O,e[63]=T):T=e[63],T};function a3(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=At(),a=Gt(U=>U.loadProviders),u=Gt(U=>U.loadAgents),d=Gt(U=>U.providers),h=Gt(U=>U.currentProviderId),f=Gt(U=>U.currentModelId),p=Gt(U=>U.currentVariant||""),g=Gt(U=>U.currentAgentName||""),w=Pe(U=>U.timeFormatPreference),v=Pe(U=>U.weekStartPreference),x=Pe(U=>U.isMobile),[m,b]=ht.useState(()=>Lc(n,{providerID:h,modelID:f,variant:p,agent:g})),[y,S]=ht.useState(!1),[N,C]=ht.useState(!1),[j,A]=ht.useState(!1),[D,I]=ht.useState(""),[M,z]=ht.useState(!1),[E,H]=ht.useState(""),[B,O]=ht.useState(!1),[T,k]=ht.useState(""),[P,L]=ht.useState(()=>{const U=jo(n?.schedule?.date||"")||new Date;return new Date(U.getFullYear(),U.getMonth(),1)}),Q=ht.useRef(null),q=ht.useRef(null),te=ht.useRef(null),ae=ht.useRef(null),X=ht.useRef(null),Z=ht.useMemo(()=>Zk(l),[l]),se=ht.useMemo(()=>Jk(l),[l]),me=ht.useMemo(()=>w==="24h"?!0:w==="12h"?!1:Z,[w,Z]),_=ht.useMemo(()=>v==="sunday"?0:v==="monday"?1:se,[v,se]),ne=ht.useMemo(()=>{const U=e3(l);return t3(gm.map(he=>({value:he,label:U[he]||""})),_)},[l,_]);ht.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),u({source:"scheduledTaskEditor"}))},[e,a,u]),ht.useEffect(()=>{if(!e)return;b(Lc(n,{providerID:h,modelID:f,variant:p,agent:g}));const U=jo(n?.schedule?.date||"")||new Date;L(new Date(U.getFullYear(),U.getMonth(),1)),C(!1),z(!1),A(!1),H(""),I("")},[e,n,h,f,p,g]),ht.useEffect(()=>{if(!N)return;const U=he=>{Q.current&&!Q.current.contains(he.target)&&C(!1)};return document.addEventListener("mousedown",U),()=>{document.removeEventListener("mousedown",U)}},[N]);const ye=ht.useMemo(()=>{const he=d.find(Re=>Re.id===m.execution.providerID)?.models?.find(Re=>Re.id===m.execution.modelID);return he?.variants?Object.keys(he.variants):[]},[d,m.execution.providerID,m.execution.modelID]),ce=ye.length>0,F=ht.useMemo(()=>!ce||!m.execution.variant?"__default":ye.includes(m.execution.variant)?m.execution.variant:"__default",[m.execution.variant,ce,ye]);ht.useEffect(()=>{ce||!m.execution.variant||b(U=>({...U,execution:{...U.execution,variant:""}}))},[ce,m.execution.variant]);const re=ht.useCallback((U,he)=>{b(Re=>{const Ie=new Set(Re.schedule.weekdays);return he?Ie.add(U):Ie.delete(U),{...Re,schedule:{...Re.schedule,weekdays:Array.from(Ie).sort((rt,Ge)=>rt-Ge)}}})},[]),fe=ht.useCallback((U,he)=>{b(Re=>{const Ie=Re.schedule.times.slice();return Ie[U]=he,{...Re,schedule:{...Re.schedule,times:Ie}}})},[]),de=ht.useCallback(U=>{b(he=>{const Re=he.schedule.times.filter((Ie,rt)=>rt!==U);return{...he,schedule:{...he.schedule,times:Re.length>0?Re:["09:00"]}}})},[]),ge=ht.useCallback(()=>{b(U=>({...U,schedule:{...U.schedule,times:[...U.schedule.times,"12:00"]}}))},[]),Te=ht.useMemo(()=>s3(),[]),be=ht.useMemo(()=>Fc(Te),[Te]),Ee=ht.useMemo(()=>{const U=jo(m.schedule.onceDate);return U?_c(U,Te)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(U):null},[m.schedule.onceDate,l,o,Te]),we=ht.useMemo(()=>Fc(P).getTime()<=be.getTime(),[P,be]),Y=ht.useMemo(()=>ne.map(U=>U.label),[ne]),ve=ht.useCallback(U=>{b(he=>({...he,schedule:{...he.schedule,onceDate:U}}))},[]),xe=ht.useCallback((U,he)=>{if(U.startsWith("/")){const Ge=U.indexOf(" "),ut=U.indexOf(`
|
|
924
|
-
`),ct=Math.min(Ge===-1?U.length:Ge,ut===-1?U.length:ut);if(he<=ct&&Ge===-1){H(U.substring(1,ct)),z(!0),A(!1),O(!1);return}}z(!1);const Re=U.substring(0,he),Ie=Re.lastIndexOf("#");if(Ie!==-1){const Ge=Ie>0?Re[Ie-1]:null,ut=Re.substring(Ie+1);if((!Ge||/\s/.test(Ge))&&!ut.includes(" ")&&!ut.includes(`
|
|
925
|
-
`)){k(ut),O(!0),A(!1);return}}O(!1);const rt=Re.lastIndexOf("@");if(rt!==-1){const Ge=rt>0?Re[rt-1]:null,ut=Re.substring(rt+1);(!Ge||/\s/.test(Ge))&&!ut.includes(" ")&&!ut.includes(`
|
|
926
|
-
`)?(I(ut),A(!0)):A(!1);return}A(!1)},[]),je=ht.useCallback(U=>{b(he=>({...he,execution:{...he.execution,prompt:U}}))},[]),oe=ht.useCallback(U=>{const he=m.execution.prompt,Ie=q.current?.selectionStart??he.length,Ge=he.substring(0,Ie).lastIndexOf("@"),ut=U.relativePath&&U.relativePath.trim().length>0?U.relativePath.trim():U.path||U.name,ct=Ge!==-1?Ge:Ie,ue=`${he.substring(0,ct)}@${ut} ${he.substring(Ie)}`,G=ct+ut.length+2;je(ue),A(!1),I(""),requestAnimationFrame(()=>{const Le=q.current;Le&&(Le.selectionStart=G,Le.selectionEnd=G,Le.focus()),xe(ue,G)})},[m.execution.prompt,je,xe]),J=ht.useCallback(U=>{const he=m.execution.prompt,Ie=q.current?.selectionStart??he.length,Ge=he.substring(0,Ie).lastIndexOf("@"),ut=Ge!==-1?Ge:Ie,ct=`${he.substring(0,ut)}@${U} ${he.substring(Ie)}`,ue=ut+U.length+2;je(ct),A(!1),I(""),requestAnimationFrame(()=>{const G=q.current;G&&(G.selectionStart=ue,G.selectionEnd=ue,G.focus()),xe(ct,ue)})},[m.execution.prompt,je,xe]),K=ht.useCallback(U=>{const he=`/${U.name} `;je(he),z(!1),H(""),O(!1),requestAnimationFrame(()=>{const Re=q.current;Re&&(Re.focus(),Re.selectionStart=Re.value.length,Re.selectionEnd=Re.value.length),xe(he,he.length)})},[je,xe]),$=ht.useCallback((U,he)=>{const Re=m.execution.prompt,rt=q.current?.selectionStart??Re.length,ut=Re.substring(0,rt).lastIndexOf("#"),ct=ut!==-1?ut:rt,ue=`${Re.substring(0,ct)}#${he} ${Re.substring(rt)}`,G=ct+he.length+2;je(ue),O(!1),k(""),requestAnimationFrame(()=>{const Le=q.current;Le&&(Le.selectionStart=G,Le.selectionEnd=G,Le.focus()),xe(ue,G)})},[m.execution.prompt,je,xe]),le=ht.useCallback(U=>{if(M&&ae.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")){U.preventDefault(),ae.current.handleKeyDown(U.key);return}j&&te.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")&&(U.preventDefault(),te.current.handleKeyDown(U.key)),B&&X.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")&&(U.preventDefault(),X.current.handleKeyDown(U.key))},[M,j,B]),V=ht.useCallback(async()=>{const U=r3(m,o);if(U){Me.error(U);return}const he={...m.id?{id:m.id}:{},name:m.name.trim(),enabled:m.enabled,schedule:{kind:m.schedule.kind,timezone:m.schedule.timezone.trim(),...m.schedule.kind==="cron"?{cron:m.schedule.cronExpression.trim()}:m.schedule.kind==="once"?{date:m.schedule.onceDate,time:m.schedule.onceTime}:{times:o3(m.schedule.times),...m.schedule.kind==="weekly"?{weekdays:m.schedule.weekdays}:{}}},execution:{prompt:m.execution.prompt,providerID:m.execution.providerID,modelID:m.execution.modelID,...m.execution.variant.trim()?{variant:m.execution.variant.trim()}:{},...m.execution.agent.trim()?{agent:m.execution.agent.trim()}:{},...m.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...m.execution.goalEnabled?{goalEnabled:!0}:{},...m.execution.goalEnabled&&m.execution.goalTokenBudget?{goalTokenBudget:m.execution.goalTokenBudget}:{}},...m.state?{state:m.state}:{}};S(!0);try{await i(he),r(!1)}catch(Re){Me.error(Re instanceof Error?Re.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{S(!1)}},[m,r,i,o]),Ce=ht.useId(),_e=ht.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),ke=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),Ne=o("sessions.scheduledTasks.editor.description"),Qe=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Cn,{id:"sched-name",value:m.name,onChange:U=>b(he=>({...he,name:U.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Bs,{value:m.schedule.kind,onValueChange:U=>{b(he=>({...he,schedule:{...he.schedule,kind:U,...U==="cron"&&!he.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{children:U=>o(U==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":U==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":U==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ss,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ss,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ss,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(i3,{draft:m,setDraft:b,locale:l,t:o}):m.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:Q,children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:De(Fd({size:"default"}),"w-fit max-w-full"),onClick:()=>C(U=>!U),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(R,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:qk(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-background p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>L(U=>Rc(U,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:we,children:s.jsx(R,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(P)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>L(U=>Rc(U,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(R,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:Y.map((U,he)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:U},`${U}-${he}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:Qk(P,_).map(({date:U,inCurrentMonth:he})=>{const Re=Ec(U),Ie=Re===m.schedule.onceDate,rt=_c(U,Te),Ge=U.getTime()<Te.getTime(),ut=Ie?"bg-interactive-selection text-interactive-selection-foreground":Ge?"text-muted-foreground/40":he?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{Ge||(ve(Re),C(!1))},disabled:Ge,className:["h-8 rounded-md typography-ui-label",ut,rt&&!Ie?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",Ge?"cursor-not-allowed opacity-45":""].join(" "),children:U.getDate()},Re)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:Ee||""}),s.jsx(pt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{ve(Ec(Te)),L(new Date(Te.getFullYear(),Te.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(Bc,{value:m.schedule.onceTime,use24Hour:me,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:U=>b(he=>({...he,schedule:{...he.schedule,onceTime:U}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Bs,{value:m.schedule.timezone,onValueChange:U=>{b(he=>({...he,schedule:{...he.schedule,timezone:U}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),s.jsx(_s,{children:aa.map(U=>s.jsx(ss,{value:U,children:U},U))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[m.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:ne.map(U=>{const he=m.schedule.weekdays.includes(U.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",he?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(dr,{checked:he,onChange:Re=>re(U.value,Re),ariaLabel:U.label}),s.jsx("button",{type:"button",onClick:()=>re(U.value,!he),className:"group-hover:text-foreground",children:U.label})]},U.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((U,he)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Bc,{value:U,use24Hour:me,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Re=>fe(he,Re)}),m.schedule.times.length>1?s.jsx(pt,{type:"button",size:"icon",variant:"ghost",onClick:()=>de(he),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null]},he))}),s.jsx("div",{children:s.jsxs(pt,{type:"button",size:"sm",variant:"outline",onClick:ge,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Bs,{value:m.schedule.timezone,onValueChange:U=>{b(he=>({...he,schedule:{...he.schedule,timezone:U}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),s.jsx(_s,{children:aa.map(U=>s.jsx(ss,{value:U,children:U},U))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Vh,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(U,he)=>{b(Re=>({...Re,execution:{...Re.execution,providerID:U,modelID:he,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Bs,{value:F,disabled:!ce,onValueChange:U=>{b(he=>({...he,execution:{...he.execution,variant:U==="__default"?"":U}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{children:U=>U==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):U})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),ye.map(U=>s.jsx(ss,{value:U,children:U},U))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Uh,{agentName:m.execution.agent,filter:U=>Bd(U.mode),onChange:U=>b(he=>({...he,execution:{...he.execution,agent:U}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(ar,{id:"sched-prompt",ref:q,value:m.execution.prompt,onChange:U=>{const he=U.target.value;je(he);const Re=U.target.selectionStart??he.length;xe(he,Re)},onKeyDown:le,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),M?s.jsx(Ud,{ref:ae,searchQuery:E,onCommandSelect:K,onClose:()=>z(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,j?s.jsx(Kd,{ref:te,searchQuery:D,onFileSelect:oe,onAgentSelect:J,onClose:()=>A(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,B?s.jsx(Hd,{ref:X,searchQuery:T,onSnippetSelect:$,onClose:()=>O(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),m.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(dr,{checked:m.execution.goalTokenBudget!==null,onChange:U=>b(he=>({...he,execution:{...he.execution,goalTokenBudget:U?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),m.execution.goalTokenBudget!==null?s.jsx(Kh,{value:m.execution.goalTokenBudget,onValueChange:U=>{typeof U=="number"&&Number.isFinite(U)&&U>0&&b(he=>({...he,execution:{...he.execution,goalTokenBudget:Math.floor(U)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),We=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(dr,{checked:m.enabled,onChange:U=>b(he=>({...he,enabled:U})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:De(Ic),onClick:()=>b(U=>({...U,execution:{...U.execution,permissionAutoAccept:!U.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(R,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(R,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(It,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:De(Ic,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>b(U=>({...U,execution:{...U.execution,goalEnabled:!U.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(R,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(R,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(It,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(pt,{type:"button",size:"sm",onClick:V,disabled:y,children:o(y?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return x?s.jsx(Ho,{open:e,title:ke,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:U=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:ke}),U]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:Ne})]}),footer:We,children:Qe}):s.jsx(ws,{open:e,onOpenChange:U=>{!U&&_e()||r(U)},children:s.jsxs(Ss,{"aria-describedby":Ce,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Ts,{id:Ce,className:"sr-only",children:Ne}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Is,{className:"typography-ui-label font-medium text-foreground",children:ke}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:Ne})]})}),s.jsx(ya,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:Qe})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:We})})]})})}function l3(t){return wr(t,{min:0,max:23})}function c3(t,e){return wr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function d3(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function u3(t){return s.jsx(ss,{value:t,children:t},t)}const m3=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},f3=(t,e)=>{const n=m3(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},h3=(t,e)=>!t||!Number.isFinite(t)?"":Hh(t,e),$c=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),p=Math.round(r%o/i),g=p>0?`${f}h ${p}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:g}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:g})}const u=Math.floor(r/l),d=Math.round(r%l/o),h=d>0?`${u}d ${d}h`:`${u}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},p3={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},g3=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function x3(){const{t}=At(),e=Pe(k=>k.isScheduledTasksDialogOpen),n=Pe(k=>k.setScheduledTasksDialogOpen),r=Pe(k=>k.isMobile),i=Pe(k=>k.timeFormatPreference),o=Kt(k=>k.projects),l=Kt(k=>k.getActiveProject()),a=ts(k=>k.homeDirectory),{currentTheme:u}=Zn(),[d,h]=ht.useState(""),[f,p]=ht.useState([]),[g,w]=ht.useState(!0),[v,x]=ht.useState(!1),[m,b]=ht.useState(null),[y,S]=ht.useState(null),N=ht.useMemo(()=>o.find(k=>k.id===d)||null,[o,d]),C=ht.useCallback(k=>{const P=k.label?.trim()||Bn(k.path,a||void 0),L=k.icon?ja[k.icon]:null,Q=k.color?ka[k.color]:void 0,q=L?s.jsx(R,{name:L,className:"h-3.5 w-3.5 shrink-0",style:Q?{color:Q}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:Q?{color:Q}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[k.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:k.iconBackground?{backgroundColor:k.iconBackground}:void 0,children:s.jsx(Ca,{project:{id:k.id,iconImage:k.iconImage??null},options:{themeVariant:u.metadata.variant,iconColor:u.colors.surface.foreground},className:"h-full w-full object-contain",fallback:q})}):q,s.jsx("span",{className:"truncate",children:P})]})},[a,u.metadata.variant,u.colors.surface.foreground]),j=ht.useCallback(async(k,P)=>{if(!k){p([]);return}P?.silent||w(!0);try{const L=await Ng(k);L.sort((Q,q)=>{if(Q.enabled!==q.enabled)return Q.enabled?-1:1;const te=Q.name.localeCompare(q.name);return te!==0?te:(Q.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(q.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(L)}catch(L){Me.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),P?.silent||p([])}finally{P?.silent||w(!1)}},[t]);ht.useEffect(()=>{if(!e)return;const k=l?.id||o[0]?.id||"";h(k),k?j(k):(p([]),w(!1))},[e,l,o,j]),ht.useEffect(()=>{if(!e)return;let k=null;const P=Yr(L=>{L.type==="scheduled-task-ran"&&L.projectId===d&&(k&&clearTimeout(k),k=setTimeout(()=>{j(d,{silent:!0})},400))});return()=>{k&&clearTimeout(k),P()}},[e,d,j]);const A=ht.useCallback(async k=>{if(!d)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await jl(d,k),await j(d),Me.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[d,j,t]),D=ht.useCallback(async(k,P)=>{if(d){S(k.id),p(L=>L.map(Q=>Q.id===k.id?{...Q,enabled:P}:Q));try{k.loopFile?await Ag(d,k.id,P):await jl(d,{...k,enabled:P}),await j(d,{silent:!0})}catch(L){Me.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await j(d,{silent:!0})}finally{S(null)}}},[d,j,t]),I=ht.useCallback(async k=>{if(!(!d||!window.confirm(k.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:k.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:k.name})))){S(k.id);try{k.loopFile?await Pg(d,k.id):await Dg(d,k.id),await j(d,{silent:!0}),Me.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(L){Me.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{S(null)}}},[d,j,t]),M=ht.useCallback(k=>{if(!k.loopFile){b(k),x(!0);return}N?.path&&(n(!1),fn.getState().setSelectedPath(N.path,k.loopFile,{allowOutsideRoot:!0}),Pe.getState().openContextFile(N.path,k.loopFile))},[N?.path,n]),z=ht.useCallback(async k=>{if(d){S(k.id);try{const{sessionId:P,persistError:L}=await Ig(d,k.id);if(await Promise.all([j(d,{silent:!0}),Ia()]),L?Me.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Me.success(t("sessions.scheduledTasks.dialog.toast.started")),P){const Q=o.find(q=>q.id===d);Je.getState().setCurrentSession(P,Q?.path??null)}}catch(P){Me.error(P instanceof Error?P.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{S(null)}}},[d,o,j,t]),E=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(Bs,{value:d||"__none",onValueChange:k=>{const P=k==="__none"?"":k;h(P),P?j(P):p([])},children:[s.jsx(Fs,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Cs,{children:C(N)}):s.jsx(Cs,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(_s,{children:[o.length===0?s.jsx(ss,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(k=>s.jsx(ss,{value:k.id,children:C(k)},k.id))]})]})]}),H=()=>{b(null),x(!0)},B=k=>{h(k),k?j(k):p([])},O=s.jsx("div",{className:"min-h-[280px]",children:g?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(d?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(k=>{const P=y===k.id,L=k.state?.lastStatus||"idle",Q=p3[L],q=t(L==="success"?"sessions.scheduledTasks.dialog.status.success":L==="error"?"sessions.scheduledTasks.dialog.status.error":L==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),te=k.state?.nextRunAt,ae=k.state?.lastRunAt;return s.jsxs("div",{className:De("rounded-lg border border-border p-4 transition-opacity",!k.enabled&&"opacity-60"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:k.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:f3(k,t)}),k.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:k.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:k.loopFile})}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),te?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:$c(te,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:h3(te,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),L==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ae?s.jsxs(s.Fragment,{children:[Q.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${Q.tone})`},children:[s.jsx(R,{name:Q.Icon,className:"h-3.5 w-3.5"}),q]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:$c(ae,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),k.state?.lastError?s.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",style:g3("error"),children:[s.jsx(R,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:k.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:De("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",k.enabled?"text-foreground":"text-muted-foreground",P&&"cursor-not-allowed opacity-50"),children:[s.jsx(dr,{checked:k.enabled,onChange:X=>{D(k,X)},ariaLabel:k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:k.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:k.name}),disabled:P}),k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(pt,{variant:"outline",size:"sm",onClick:()=>{z(k)},disabled:P,children:[s.jsx(R,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(pt,{variant:"outline",size:"sm",onClick:()=>M(k),disabled:P,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:k.name}),children:[s.jsx(R,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(pt,{variant:"destructive",size:"sm",onClick:()=>{I(k)},disabled:P,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:k.name}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},k.id)})})}),T=s.jsxs("div",{className:"space-y-4",children:[E,O]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Ho,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:k=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),k]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(pt,{className:"w-full",onClick:H,disabled:!d,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:T}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(k=>s.jsx("button",{type:"button",onClick:()=>B(k.id),className:De("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",d===k.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(k)},k.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(pt,{size:"sm",onClick:H,disabled:!d,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:O})})]})]})}):null,s.jsx(a3,{open:v,task:m,onOpenChange:x,onSave:A})]})}const ko=100;function b3(){const t=tt.c(106),{t:e}=At(),n=Pe(A3),r=Pe(N3),i=Je(C3),o=Je(k3),l=ts(j3);let a;t[0]!==n?(a=te=>n?te.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const u=Ds(Jn(a)),[d,h]=c.useState(""),[f,p]=c.useState(null),[g,w]=c.useState(ko);let v;t[2]!==d?(v=d.trim().toLowerCase(),t[2]=d,t[3]=v):v=t[3];const x=v;let m;e:{if(!n){let ae;t[4]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[4]=ae):ae=t[4],m=ae;break e}let te;t[5]!==u?(te=[...u].sort(v3),t[5]=u,t[6]=te):te=t[6],m=te}const b=m;let y;if(t[7]!==l||t[8]!==b||t[9]!==e){const te=new Map;for(const ae of b){const X=yt($s(ae))??"",Z=te.get(X);if(Z){Z.sessions.push(ae);continue}te.set(X,{directory:X,label:X?Bn(X,l)||X:e("sessions.archivePage.otherProjects"),sessions:[ae]})}y=[...te.values()].sort(S3),t[7]=l,t[8]=b,t[9]=e,t[10]=y}else y=t[10];const S=y;let N;e:{if(x){if(x.startsWith("ses_")){let X;if(t[11]!==x||t[12]!==b){let Z;t[14]!==x?(Z=se=>se.id.toLowerCase()===x,t[14]=x,t[15]=Z):Z=t[15],X=b.filter(Z),t[11]=x,t[12]=b,t[13]=X}else X=t[13];N=X;break e}let ae;t[16]!==x||t[17]!==b?(ae=Gh(b,x,w3),t[16]=x,t[17]=b,t[18]=ae):ae=t[18],N=ae;break e}if(f===null){N=b;break e}let te;t[19]!==S||t[20]!==f?(te=S.find(ae=>ae.directory===f)?.sessions??[],t[19]=S,t[20]=f,t[21]=te):te=t[21],N=te}const C=N;let j,A,D,I,M,z,E,H,B,O;if(t[22]!==u.length||t[23]!==S||t[24]!==C||t[25]!==l||t[26]!==x||t[27]!==n||t[28]!==d||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==g){M=Symbol.for("react.early_return_sentinel");e:{const te=C.slice(0,g);j=C.length-te.length;const ae=u.length;let X;t[45]===Symbol.for("react.memo_cache_sentinel")?(X=we=>{p(we),w(ko)},t[45]=X):X=t[45];const Z=X;let se;t[46]!==i||t[47]!==r?(se=we=>{const Y=yt($s(we));i(we.id,Y??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=se):se=t[48];const me=se;let _;t[49]!==e||t[50]!==o?(_=we=>{o(we.id).then(Y=>{Y?Me.success(e("sessions.sidebar.session.restore.success")):Me.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=_):_=t[51];const ne=_;if(!n){M=null;break e}let ye;t[52]!==e?(ye=(we,Y,ve,xe,je,oe,J)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:je,title:oe,className:De("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",J?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",xe?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Y}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:ve})]}),J?s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>gn.requestDelete({sessions:J,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.deleteProjectAria",{label:Y}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},we),t[52]=e,t[53]=ye):ye=t[53];const ce=ye;I="absolute inset-0 z-10 flex flex-col bg-background",A="flex min-h-0 flex-1";let F;if(t[54]!==ce||t[55]!==f||t[56]!==e||t[57]!==ae){let we;t[59]===Symbol.for("react.memo_cache_sentinel")?(we=()=>Z(null),t[59]=we):we=t[59],F=ce("__all__",e("sessions.archivePage.allDirectories"),ae,f===null,we),t[54]=ce,t[55]=f,t[56]=e,t[57]=ae,t[58]=F}else F=t[58];let re;if(t[60]!==S||t[61]!==ce||t[62]!==f){let we;t[64]!==ce||t[65]!==f?(we=Y=>ce(Y.directory||"__none__",Y.label,Y.sessions.length,f===Y.directory,()=>Z(Y.directory),Y.directory||void 0,Y.sessions),t[64]=ce,t[65]=f,t[66]=we):we=t[66],re=S.map(we),t[60]=S,t[61]=ce,t[62]=f,t[63]=re}else re=t[63];t[67]!==F||t[68]!==re?(D=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[F,re]})}),t[67]=F,t[68]=re,t[69]=D):D=t[69],B="flex min-w-0 flex-1 flex-col";let fe;t[70]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t[70]=fe):fe=t[70];let de;t[71]===Symbol.for("react.memo_cache_sentinel")?(de=we=>{h(we.target.value),w(ko)},t[71]=de):de=t[71];let ge;t[72]!==e?(ge=e("sessions.archivePage.searchPlaceholder"),t[72]=e,t[73]=ge):ge=t[73];let Te;t[74]!==d||t[75]!==ge?(Te=s.jsxs("div",{className:"relative min-w-0 flex-1",children:[fe,s.jsx("input",{value:d,onChange:de,placeholder:ge,className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-3 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50"})]}),t[74]=d,t[75]=ge,t[76]=Te):Te=t[76];let be;t[77]!==C.length||t[78]!==e?(be=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[77]=C.length,t[78]=e,t[79]=be):be=t[79];let Ee;t[80]!==be?(Ee=s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:be}),t[80]=be,t[81]=Ee):Ee=t[81],t[82]!==Te||t[83]!==Ee?(O=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Te,Ee]}),t[82]=Te,t[83]=Ee,t[84]=O):O=t[84],H="min-h-0 flex-1 overflow-y-auto px-6 py-3",z="mx-auto w-full max-w-3xl space-y-0.5",E=te.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(x?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):te.map(we=>{const Y=yt($s(we))??"",ve=Y?Bn(Y,l)||Y:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>me(we),role:"button",tabIndex:0,onKeyDown:xe=>{(xe.key==="Enter"||xe.key===" ")&&(xe.preventDefault(),me(we))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:we.title||e("sessions.sidebar.session.untitled")}),x&&ve?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:Y,children:ve}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Wd(we.time?.archived??we.time?.updated??we.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),ne(we)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.restoreSessionAria",{title:we.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(R,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),gn.requestDelete({sessions:[we],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.deleteSessionAria",{title:we.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},we.id)})}t[22]=u.length,t[23]=S,t[24]=C,t[25]=l,t[26]=x,t[27]=n,t[28]=d,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=g,t[35]=j,t[36]=A,t[37]=D,t[38]=I,t[39]=M,t[40]=z,t[41]=E,t[42]=H,t[43]=B,t[44]=O}else j=t[35],A=t[36],D=t[37],I=t[38],M=t[39],z=t[40],E=t[41],H=t[42],B=t[43],O=t[44];if(M!==Symbol.for("react.early_return_sentinel"))return M;let T;t[85]!==j||t[86]!==e?(T=j>0?s.jsx("button",{type:"button",onClick:()=>w(y3),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[85]=j,t[86]=e,t[87]=T):T=t[87];let k;t[88]!==T||t[89]!==z||t[90]!==E?(k=s.jsxs("div",{className:z,children:[E,T]}),t[88]=T,t[89]=z,t[90]=E,t[91]=k):k=t[91];let P;t[92]!==k||t[93]!==H?(P=s.jsx("div",{className:H,children:k}),t[92]=k,t[93]=H,t[94]=P):P=t[94];let L;t[95]!==P||t[96]!==B||t[97]!==O?(L=s.jsxs("div",{className:B,children:[O,P]}),t[95]=P,t[96]=B,t[97]=O,t[98]=L):L=t[98];let Q;t[99]!==A||t[100]!==D||t[101]!==L?(Q=s.jsxs("div",{className:A,children:[D,L]}),t[99]=A,t[100]=D,t[101]=L,t[102]=Q):Q=t[102];let q;return t[103]!==I||t[104]!==Q?(q=s.jsx("div",{className:I,children:Q}),t[103]=I,t[104]=Q,t[105]=q):q=t[105],q}function y3(t){return t+ko}function w3(t){return[t.title]}function S3(t,e){return e.sessions.length-t.sessions.length}function v3(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function j3(t){return t.homeDirectory}function k3(t){return t.unarchiveSession}function C3(t){return t.setCurrentSession}function N3(t){return t.setArchivePageOpen}function A3(t){return t.isArchivePageOpen}function P3(){const t=tt.c(18),{t:e}=At(),n=Pe(T3),r=Pe(I3),i=Kt(D3);let o;t[0]!==n?(o=g=>g.projects.find(w=>w.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Kt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(R,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=u):u=t[6];let d;t[7]!==e?(d=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==a||t[10]!==d?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(pt,{size:"sm",onClick:a,children:[u,d]})}),t[9]=a,t[10]=d,t[11]=h):h=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(fg,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let p;return t[15]!==h||t[16]!==f?(p=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,f]})})}),t[15]=h,t[16]=f,t[17]=p):p=t[17],p}function D3(t){return t.setActiveProjectIdOnly}function I3(t){return t.setNewWorktreeDialogOpen}function T3(t){return t.worktreesPageProjectId}const la=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),E3=(t,e)=>{const n=la(t),r=la(e);return`${n}-${r}`.substring(0,60)},Wc=(t,e)=>`${t}/${e}`,R3=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},zc=(t,e)=>{const n=R3(e),r=t.directory,i=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};tp(t.id,n),Je.getState().markSessionAsOpenChamberCreated(t.id),Ds.getState().upsertSession(i);try{Po().ensureChild(n,{bootstrap:!1}).setState(l=>{const a=l.session.findIndex(d=>d.id===t.id);if(a>=0&&l.session[a]===i)return l;const u=a>=0?l.session.map((d,h)=>h===a?i:d):[...l.session,i].sort((d,h)=>d.id.localeCompare(h.id));return{session:u,sessionTotal:Math.max(l.sessionTotal,u.length),limit:Math.max(l.limit,u.length)}})}catch{}return i},M3=()=>{const t=Kt.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(i=>i.id===e);if(n?.path)return{id:n.id,path:n.path};const r=ts.getState().currentDirectory??null;if(r&&r.trim().length>0){const i=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${i}`,path:i}}return null},xi=er()(mu(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:i,files:o,setupCommands:l}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let a=0;a<r.length;a++){if(!r[a].prompt.trim())return t({error:`Group ${a+1}: prompt is required`}),null;if(r[a].models.length<1)return t({error:`Group ${a+1}: select at least 1 model`}),null}t({isLoading:!0,error:null});try{const a=M3();if(!a)return t({error:"Select a project",isLoading:!1}),null;const u=a.path,h=await Uo(u)&&e.isolateRuns!==!1,f=la(n),p=h?await Go(u):void 0,g=h?await qh(u):null,w=[],v=l?.filter(S=>S.trim().length>0)??[];for(let S=0;S<r.length;S++){const N=r[S],C=N.prompt,j=new Map;for(const D of N.models){const I=`${D.providerID}:${D.modelID}`;j.set(I,(j.get(I)||0)+1)}const A=new Map;for(const D of N.models){const I=`${D.providerID}:${D.modelID}`,M=j.get(I)||1,z=(A.get(I)||0)+1;A.set(I,z);const E=E3(D.providerID,D.modelID),H=r.length>1?`g${S+1}`:void 0,B=M>1?Wc(f,`${E}/${z}`):Wc(f,E),O=H?`${H}/${B}`:B,T=Cj({groupSlug:f,runGroup:H,providerID:D.providerID,modelID:D.modelID,index:M>1?z:void 0});try{if(!h){const Q=await qs.withDirectory(u,()=>qs.createSession({title:T}));zc(Q,u),w.push({sessionId:Q.id,worktreePath:u,providerID:D.providerID,modelID:D.modelID,variant:D.variant,prompt:C});continue}const k=await Qh(a,{preferredName:O,mode:"new",branchName:O,worktreeName:O,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:v,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:g}),P={...k,createdFromBranch:p,kind:"standard"};await Yh(a)&&await Xh(k.path);const L=await qs.withDirectory(k.path,()=>qs.createSession({title:T}));zc(L,k.path),Je.getState().setWorktreeMetadata(L.id,P),w.push({sessionId:L.id,worktreePath:k.path,providerID:D.providerID,modelID:D.modelID,variant:D.variant,prompt:C})}catch(k){console.warn("[MultiRun] Failed to create session:",k)}}}const x=l?.filter(S=>S.trim().length>0)??[];x.length>0&&Jh(a,x).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const m=w.map(S=>S.sessionId),b=w[0]?.sessionId??null;if(m.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const y=o?.map(S=>({type:"file",mime:S.mime,filename:S.filename,url:S.url}));return(async()=>{try{const S=Zh.getState().expandText;await Promise.allSettled(w.map(async N=>{try{const C=await S(N.prompt).catch(()=>N.prompt);await ep({sessionId:N.sessionId,directory:N.worktreePath,content:C,providerID:N.providerID,modelID:N.modelID,variant:N.variant,agent:i,files:y})}catch(C){console.warn("[MultiRun] Failed to start run:",C)}}))}catch(S){console.warn("[MultiRun] Failed to start runs:",S)}})(),t({isLoading:!1}),{groupSlug:f,sessionIds:m,firstSessionId:b}}catch(a){return t({error:a instanceof Error?a.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"}));function xm(t){const e=tt.c(30),{git:n}=wn(),r=kd(t),i=Cd(t),o=sp(t),l=np(t),a=On(L3),u=On(_3);let d,h;e[0]!==t||e[1]!==u||e[2]!==n||e[3]!==i||e[4]!==o?(d=()=>{!t||!n||i!==null||o||u(t,n,{silent:!0})},h=[t,n,u,i,o],e[0]=t,e[1]=u,e[2]=n,e[3]=i,e[4]=o,e[5]=d,e[6]=h):(d=e[5],h=e[6]),c.useEffect(d,h);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=f):f=e[12];const p=r?.all;let g;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(g=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=g):g=e[18],c.useEffect(f,g);const w=o||i===!0&&l;let v;e:{if(!r?.all){let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[19]=j):j=e[19],v=j;break e}let C;e[20]!==r.all?(C=r.all.filter(F3).sort(),e[20]=r.all,e[21]=C):C=e[21],v=C}const x=v;let m;e:{if(!r?.all){let j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[22]=j):j=e[22],m=j;break e}let C;e[23]!==r.all?(C=r.all.filter(B3).map(O3).sort(),e[23]=r.all,e[24]=C):C=e[24],m=C}const b=m;let y;e:{if(!t){y=null;break e}if(i!==null){y=i;break e}if(w){y=null;break e}y=r?.all?!0:null}const S=y;let N;return e[25]!==S||e[26]!==w||e[27]!==x||e[28]!==b?(N={localBranches:x,remoteBranches:b,isLoading:w,isGitRepository:S},e[25]=S,e[26]=w,e[27]=x,e[28]=b,e[29]=N):N=e[29],N}function O3(t){return t.replace(/^remotes\//,"")}function B3(t){return t.startsWith("remotes/")}function F3(t){return!t.startsWith("remotes/")}function _3(t){return t.fetchStatus}function L3(t){return t.fetchBranches}const $3=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=At(),{localBranches:a,remoteBranches:u,isLoading:d,isGitRepository:h}=xm(t),f=c.useMemo(()=>[...a,...u.map(g=>`remotes/${g}`)],[a,u]);c.useEffect(()=>{if(i||d||f.length===0||e&&f.includes(e))return;const g=e;let w=!1;return(async()=>{try{const x=t?await Go(t).catch(()=>null):null;if(w)return;const m=localStorage.getItem(Sl),{sourceBranch:b,shouldClearSavedSourceBranch:y}=hg({branches:f,savedSourceBranch:m,rootBranch:x});if(y&&localStorage.removeItem(Sl),w||g&&f.includes(g))return;b&&n(b)}catch{}})(),()=>{w=!0}},[f,t,i,d,n,e]);const p=i||!h||d;return s.jsxs("div",{children:[s.jsxs(Bs,{value:e,onValueChange:n,disabled:p,children:[s.jsx(Fs,{id:o,size:"lg",className:De("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(Cs,{placeholder:l(d?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(_s,{className:"max-h-[280px] max-w-[320px]",children:d?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&u.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(Pi,{children:[s.jsx(dl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(g=>s.jsx(ss,{value:g,className:"whitespace-normal break-all",children:g},g))]}),a.length>0&&u.length>0&&s.jsx(rp,{}),u.length>0&&s.jsxs(Pi,{children:[s.jsx(dl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),u.map(g=>s.jsx(ss,{value:`remotes/${g}`,className:"whitespace-normal break-all",children:g},`remotes/${g}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},W3=10*1024*1024,Co=t=>{const e=tt.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(R,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(Pt,{children:[r,s.jsx(It,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Kn=t=>{const e=tt.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const u=o&&o;let d;return e[6]!==a||e[7]!==u?(d=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,u]}),e[6]=a,e[7]=u,e[8]=d):d=e[8],d},z3=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=At(),[o,l]=c.useState(""),[a,u]=c.useState(()=>[{id:_r(),prompt:"",models:[]}]),[d,h]=c.useState(""),[f,p]=c.useState([]),[g,w]=c.useState(!1),[v,x]=c.useState([]),[m,b]=c.useState(!1),[y,S]=c.useState(!1),[N,C]=c.useState(!0),j=c.useRef(null),A=ts(K=>K.currentDirectory??null),D=ts(K=>K.homeDirectory??null),I=c.useMemo(()=>{if(typeof window>"u")return null;const K=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof K=="string"&&K.trim().length>0?K.trim():null},[]),M=Kt(K=>K.activeProjectId),z=Kt(K=>K.setActiveProjectIdOnly),E=Kt(K=>K.projects),[H,B]=c.useState(()=>M??null);c.useEffect(()=>{if(M){B(M);return}!H&&E.length>0&&B(E[0].id)},[M,E,H]);const O=c.useMemo(()=>H?E.find(K=>K.id===H)??null:null,[E,H]),T=O?.path??A,k=c.useCallback(K=>{B(K),K!==M&&z(K)},[M,z]),{currentTheme:P}=Zn(),L=c.useCallback(K=>{const $=K.label?.trim()||Bn(K.path,D),le=K.icon?ja[K.icon]:null,V=K.color?ka[K.color]:void 0,Ce=le?s.jsx(R,{name:le,className:"h-3.5 w-3.5 shrink-0",style:V?{color:V}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:V?{color:V}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[K.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:K.iconBackground?{backgroundColor:K.iconBackground}:void 0,children:s.jsx(Ca,{project:{id:K.id,iconImage:K.iconImage??null},options:{themeVariant:P.metadata.variant,iconColor:P.colors.surface.foreground},className:"h-full w-full object-contain",fallback:Ce})}):Ce,s.jsx("span",{className:"truncate",children:$})]})},[D,P.metadata.variant,P.colors.surface.foreground]),Q=c.useMemo(()=>{if(O?.path)return{id:O.id,path:O.path};const K=A??I;return K?{id:`path:${K}`,path:K}:null},[O,A,I]),[q]=c.useState(()=>typeof window<"u"?xn():!1),te=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ae=yd(),X=c.useMemo(()=>{if(typeof window>"u")return null;const K=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof K=="number"&&Number.isFinite(K)&&K>0)return K;if(typeof navigator>"u")return null;const $=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!$)return null;const le=Number.parseInt($[1],10),V=Number.parseInt($[2],10);return Number.isNaN(le)?null:le===10?V:le},[]),Z=c.useMemo(()=>q&&te||ae?"pl-[88px]":"pl-3",[q,te,ae]),se=c.useMemo(()=>!q||!te||X===null?"":X>=26?"h-12":X<=15?"h-14":"",[q,te,X]),me=c.useCallback(async K=>{K.target.closest("button, a, input, select, textarea")||K.button===0&&q&&await op()},[q]);c.useEffect(()=>{if(!n)return;const K=$=>{$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),n())};return window.addEventListener("keydown",K,!0),()=>window.removeEventListener("keydown",K,!0)},[n]);const[_,ne]=c.useState(""),{isLoading:ye,isGitRepository:ce}=xm(T),F=c.useRef(!1),re=ce===!0,fe=re&&N;c.useEffect(()=>{if(ce===!1){F.current=!0,C(!1);return}ce===!0&&F.current&&(F.current=!1,C(!0))},[ce]);const de=xi(K=>K.createMultiRun),ge=xi(K=>K.error),Te=xi(K=>K.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&u(K=>{const $=[...K];return $.length>0&&!$[0].prompt.trim()&&($[0]={...$[0],prompt:t}),$})},[t]),c.useEffect(()=>{if(!Q)return;let K=!1;return S(!0),(async()=>{try{const $=await ip(Q);K||x($)}catch{}finally{K||S(!1)}})(),()=>{K=!0}},[Q]);const be=c.useCallback((K,$)=>{u(le=>le.map(V=>V.id===K?{...V,...$}:V))},[]),Ee=c.useCallback(K=>{u($=>$.filter(le=>le.id!==K))},[]),we=c.useCallback(()=>{u(K=>[...K,{id:_r(),prompt:"",models:[]}])},[]),Y=async K=>{const $=K.target.files;if(!$)return;let le=0;for(let V=0;V<$.length;V++){const Ce=$[V];if(Ce.size>W3){Me.error(i("multirun.launcher.toast.fileTooLarge",{fileName:Ce.name}));continue}try{const _e=await new Promise((ke,Ne)=>{const Qe=new FileReader;Qe.onload=()=>ke(Qe.result),Qe.onerror=Ne,Qe.readAsDataURL(Ce)});p(ke=>[...ke,{id:_r(),filename:Ce.name,mimeType:Ce.type||"application/octet-stream",size:Ce.size,dataUrl:_e}]),le++}catch(_e){console.error("File attach failed",_e),Me.error(i("multirun.launcher.toast.attachFailed",{fileName:Ce.name}))}}le>0&&Me.success(le===1?i("multirun.launcher.toast.attachedSingle",{count:le}):i("multirun.launcher.toast.attachedPlural",{count:le})),j.current&&(j.current.value="")},ve=K=>{p($=>$.filter(le=>le.id!==K))},xe=c.useMemo(()=>a.reduce((K,$)=>K+$.models.length,0),[a]),je=async K=>{K.preventDefault();const $=a.filter(le=>le.prompt.trim()&&le.models.length>=1);if($.length!==0&&!(xe<1)){w(!0),Te();try{H&&H!==M&&z(H);const le=f.map(Ne=>({mime:Ne.mimeType,filename:Ne.filename,url:Ne.dataUrl})),V=v.filter(Ne=>Ne.trim().length>0),Ce=$.map(Ne=>({prompt:Ne.prompt.trim(),models:Ne.models.map(Qe=>({providerID:Qe.providerID,modelID:Qe.modelID,displayName:Qe.displayName,variant:Qe.variant}))})),_e={name:o.trim(),groups:Ce,agent:d||void 0,worktreeBaseBranch:fe?_:void 0,isolateRuns:fe,files:le.length>0?le:void 0,setupCommands:V.length>0?V:void 0},ke=await de(_e);ke&&(ke.firstSessionId&&Je.getState().setCurrentSession(ke.firstSessionId),e?.())}finally{w(!1)}}},oe=!!(o.trim()&&a.some(K=>K.prompt.trim()&&K.models.length>=1)&&xe>=1&&T&&!ye&&(ce===!1||!fe||_)),J=v.filter(K=>K.trim()).length;return s.jsxs("form",{onSubmit:je,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:me,className:De("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",Z,se),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag",children:s.jsx(R,{name:"close",className:"h-5 w-5"})})}),s.jsx(It,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(ya,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),E.length>0?s.jsxs(Bs,{value:H??void 0,onValueChange:k,children:[s.jsx(Fs,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:O?s.jsx(Cs,{children:L(O)}):s.jsx(Cs,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(_s,{fitContent:!0,children:E.map(K=>s.jsx(ss,{value:K.id,className:"max-w-[24rem]",children:L(K)},K.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"group-name",required:!0,info:s.jsx(Co,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(Cn,{id:"group-name",value:o,onChange:K=>l(K.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Co,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx($3,{directory:T,value:_,onChange:ne,disabled:!fe,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(dr,{checked:N,onChange:C,disabled:!re,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"multirun-agent",info:s.jsx(Co,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(cm,{value:d,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(Ei,{open:m,onOpenChange:b,children:[s.jsxs(Zd,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(R,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),J>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:J}),s.jsx(R,{name:"arrow-down-s",className:De("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(Ri,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:y?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[v.map((K,$)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(Cn,{value:K,onChange:le=>{const V=[...v];V[$]=le.target.value,x(V)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>x(v.filter((le,V)=>V!==$)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]},`${K}-${$}`)),s.jsxs("button",{type:"button",onClick:()=>x([...v,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(R,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Kn,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:j,type:"file",multiple:!0,className:"hidden",onChange:Y,accept:"*/*"}),s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>j.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(R,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(It,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(K=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[K.mimeType.startsWith("image/")?s.jsx(R,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(R,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:K.filename,children:K.filename}),s.jsx("button",{type:"button",onClick:()=>ve(K.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(R,{name:"close",className:"h-3 w-3"})})]},K.id))]})]}),a.map((K,$)=>s.jsx(V3,{group:K,groupIndex:$,canRemove:a.length>1,onUpdate:be,onRemove:Ee},K.id)),s.jsxs("button",{type:"button",onClick:we,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(R,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),ge&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:ge})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!fe&&ce!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(pt,{type:"submit",size:"sm",disabled:!oe||g,children:g?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:xe})})})]})})]})},V3=t=>{const e=tt.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=At(),[u,d]=c.useState(!1),[h,f]=c.useState(""),[p,g]=c.useState(!1),[w,v]=c.useState(""),[x,m]=c.useState(!1),[b,y]=c.useState(""),S=c.useRef(null),N=c.useRef(null),C=c.useRef(null),j=c.useRef(null);let A;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(A=V=>{o(n.id,{models:[...n.models,V]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=A):A=e[3];const D=A;let I;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(I=V=>{o(n.id,{models:n.models.filter((Ce,_e)=>_e!==V)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=I):I=e[7];const M=I;let z;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(z=(V,Ce)=>{o(n.id,{models:n.models.map((_e,ke)=>ke===V?Ce:_e)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=z):z=e[11];const E=z;let H;e[12]===Symbol.for("react.memo_cache_sentinel")?(H=(V,Ce)=>{if(V.startsWith("/")){const Qe=V.indexOf(" "),We=V.indexOf(`
|
|
927
|
-
`),U=Math.min(Qe===-1?V.length:Qe,We===-1?V.length:We);if(Ce<=U&&Qe===-1){v(V.substring(1,U)),g(!0),d(!1),m(!1);return}}g(!1);const _e=V.substring(0,Ce),ke=_e.lastIndexOf("#");if(ke!==-1){const Qe=ke>0?_e[ke-1]:null,We=_e.substring(ke+1);if((!Qe||/\s/.test(Qe))&&!We.includes(" ")&&!We.includes(`
|
|
928
|
-
`)){y(We),m(!0),d(!1);return}}m(!1);const Ne=_e.lastIndexOf("@");if(Ne!==-1){const Qe=Ne>0?_e[Ne-1]:null,We=_e.substring(Ne+1);(!Qe||/\s/.test(Qe))&&!We.includes(" ")&&!We.includes(`
|
|
929
|
-
`)?(f(We),d(!0)):d(!1);return}d(!1)},e[12]=H):H=e[12];const B=H;let O;e[13]!==n.id||e[14]!==o?(O=V=>{o(n.id,{prompt:V})},e[13]=n.id,e[14]=o,e[15]=O):O=e[15];const T=O;let k;e[16]!==n.prompt||e[17]!==T?(k=V=>{const Ce=n.prompt,ke=S.current?.selectionStart??Ce.length,Qe=Ce.substring(0,ke).lastIndexOf("@"),We=V.relativePath&&V.relativePath.trim().length>0?V.relativePath.trim():V.path||V.name,U=Qe!==-1?Qe:ke,he=`${Ce.substring(0,U)}@${We} ${Ce.substring(ke)}`,Re=U+We.length+2;T(he),d(!1),f(""),requestAnimationFrame(()=>{const Ie=S.current;Ie&&(Ie.selectionStart=Re,Ie.selectionEnd=Re,Ie.focus()),B(he,Re)})},e[16]=n.prompt,e[17]=T,e[18]=k):k=e[18];const P=k;let L;e[19]!==n.prompt||e[20]!==T?(L=V=>{const Ce=n.prompt,ke=S.current?.selectionStart??Ce.length,Qe=Ce.substring(0,ke).lastIndexOf("@"),We=Qe!==-1?Qe:ke,U=`${Ce.substring(0,We)}@${V} ${Ce.substring(ke)}`,he=We+V.length+2;T(U),d(!1),f(""),requestAnimationFrame(()=>{const Re=S.current;Re&&(Re.selectionStart=he,Re.selectionEnd=he,Re.focus()),B(U,he)})},e[19]=n.prompt,e[20]=T,e[21]=L):L=e[21];const Q=L;let q;e[22]!==T?(q=V=>{const Ce=`/${V.name} `;T(Ce),g(!1),v(""),m(!1),requestAnimationFrame(()=>{const _e=S.current;_e&&(_e.focus(),_e.selectionStart=_e.value.length,_e.selectionEnd=_e.value.length),B(Ce,Ce.length)})},e[22]=T,e[23]=q):q=e[23];const te=q;let ae;e[24]!==n.prompt||e[25]!==T?(ae=(V,Ce)=>{const _e=n.prompt,Ne=S.current?.selectionStart??_e.length,We=_e.substring(0,Ne).lastIndexOf("#"),U=We!==-1?We:Ne,he=`${_e.substring(0,U)}#${Ce} ${_e.substring(Ne)}`,Re=U+Ce.length+2;T(he),m(!1),y(""),requestAnimationFrame(()=>{const Ie=S.current;Ie&&(Ie.selectionStart=Re,Ie.selectionEnd=Re,Ie.focus()),B(he,Re)})},e[24]=n.prompt,e[25]=T,e[26]=ae):ae=e[26];const X=ae;let Z;e[27]!==p||e[28]!==u||e[29]!==x?(Z=V=>{if(p&&C.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")){V.preventDefault(),C.current.handleKeyDown(V.key);return}u&&N.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),N.current.handleKeyDown(V.key)),x&&j.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),j.current.handleKeyDown(V.key))},e[27]=p,e[28]=u,e[29]=x,e[30]=Z):Z=e[30];const se=Z,me=r+1;let _;e[31]!==a||e[32]!==me?(_=a("multirun.launcher.groups.groupLabel",{index:me}),e[31]=a,e[32]=me,e[33]=_):_=e[33];let ne;e[34]!==_?(ne=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:_}),e[34]=_,e[35]=ne):ne=e[35];let ye;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(ye=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=ye):ye=e[40];let ce;e[41]!==ne||e[42]!==ye?(ce=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ne,ye]}),e[41]=ne,e[42]=ye,e[43]=ce):ce=e[43];let F;e[44]!==a?(F=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=F):F=e[45];let re;e[46]!==F?(re=s.jsx(Kn,{required:!0,children:F}),e[46]=F,e[47]=re):re=e[47];const fe=n.prompt;let de;e[48]!==T?(de=V=>{const Ce=V.target.value;T(Ce);const _e=V.target.selectionStart??Ce.length;B(Ce,_e)},e[48]=T,e[49]=de):de=e[49];let ge;e[50]!==a?(ge=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=ge):ge=e[51];let Te;e[52]!==n.prompt||e[53]!==se||e[54]!==de||e[55]!==ge?(Te=s.jsx(ar,{ref:S,value:fe,onChange:de,onKeyDown:se,placeholder:ge,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=se,e[54]=de,e[55]=ge,e[56]=Te):Te=e[56];let be;e[57]!==w||e[58]!==te||e[59]!==p?(be=p?s.jsx(Ud,{ref:C,searchQuery:w,onCommandSelect:te,onClose:()=>g(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=te,e[59]=p,e[60]=be):be=e[60];let Ee;e[61]!==Q||e[62]!==P||e[63]!==h||e[64]!==u?(Ee=u?s.jsx(Kd,{ref:N,searchQuery:h,onFileSelect:P,onAgentSelect:Q,onClose:()=>d(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=Q,e[62]=P,e[63]=h,e[64]=u,e[65]=Ee):Ee=e[65];let we;e[66]!==X||e[67]!==x||e[68]!==b?(we=x?s.jsx(Hd,{ref:j,searchQuery:b,onSnippetSelect:X,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=X,e[67]=x,e[68]=b,e[69]=we):we=e[69];let Y;e[70]!==Te||e[71]!==be||e[72]!==Ee||e[73]!==we?(Y=s.jsxs("div",{className:"relative",children:[Te,be,Ee,we]}),e[70]=Te,e[71]=be,e[72]=Ee,e[73]=we,e[74]=Y):Y=e[74];let ve;e[75]!==re||e[76]!==Y?(ve=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[re,Y]}),e[75]=re,e[76]=Y,e[77]=ve):ve=e[77];let xe;e[78]!==a?(xe=a("multirun.launcher.models.info"),e[78]=a,e[79]=xe):xe=e[79];let je;e[80]!==xe?(je=s.jsx(Co,{children:xe}),e[80]=xe,e[81]=je):je=e[81];let oe;e[82]!==a?(oe=a("multirun.launcher.models.label"),e[82]=a,e[83]=oe):oe=e[83];let J;e[84]!==je||e[85]!==oe?(J=s.jsx(Kn,{required:!0,info:je,children:oe}),e[84]=je,e[85]=oe,e[86]=J):J=e[86];let K;e[87]!==n.models||e[88]!==D||e[89]!==M||e[90]!==E?(K=s.jsx(dm,{selectedModels:n.models,onAdd:D,onRemove:M,onUpdate:E,minModels:1}),e[87]=n.models,e[88]=D,e[89]=M,e[90]=E,e[91]=K):K=e[91];let $;e[92]!==J||e[93]!==K?($=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[J,K]}),e[92]=J,e[93]=K,e[94]=$):$=e[94];let le;return e[95]!==ce||e[96]!==ve||e[97]!==$?(le=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[ce,ve,$]}),e[95]=ce,e[96]=ve,e[97]=$,e[98]=le):le=e[98],le},U3=t=>{const e=new Map;for(const n of t){const r=$s(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},K3=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},H3=t=>{const e=tt.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,u;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const d=ps(),h=U3(i),f=l.current?.runtimeKey===d?l.current.identities:null;for(const p of K3(f,h))ap({runtimeKey:d,...p});l.current={runtimeKey:d,identities:h}},u=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=u):(a=e[3],u=e[4]),c.useEffect(a,u)},G3=new Map,q3=t=>{const e=tt.c(26),{isVSCode:n}=t,r=Da(),i=Kt(Q3),o=Kt(Y3),l=ts(X3),a=Je(J3);let u;e[0]!==n?(u=I=>n?G3:I.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const d=Je(u),h=!n;let f;e[2]!==d||e[3]!==i||e[4]!==h?(f=hm(i,d,{includeWorktrees:h}),e[2]=d,e[3]=i,e[4]=h,e[5]=f):f=e[5];const p=f,g=Ds(Z3),w=Ds(e4),v=Ds(t4),x=`session-list-sync:${c.useId()}`;let m,b;e[6]!==o||e[7]!==x||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==p||e[12]!==i?(m=()=>(r.setBootstrapDemand(x,rm({knownDirectories:p,activeProjectDirectory:yt(i.find(I=>I.id===o)?.path??null),activeProjectId:o,collapsedProjects:new Set,collapsedGroups:new Set,currentDirectory:l,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(x)),b=[o,x,r,l,a,p,i],e[6]=o,e[7]=x,e[8]=r,e[9]=l,e[10]=a,e[11]=p,e[12]=i,e[13]=m,e[14]=b):(m=e[13],b=e[14]),c.useEffect(m,b);const y=c.useRef(null);let S,N;e[15]!==n||e[16]!==p?(S=()=>{const I=new Set(p),M=y.current;y.current=I;const z=M?[...I].filter(E=>!M.has(E)):n?[...I]:[];z.length&&ga(z,Do())},N=[n,p],e[15]=n,e[16]=p,e[17]=S,e[18]=N):(S=e[17],N=e[18]),c.useEffect(S,N);let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[19]=C):C=e[19],c.useEffect(s4,C);let j;e[20]!==w||e[21]!==g?(j=[...g,...w],e[20]=w,e[21]=g,e[22]=j):j=e[22];const A=j;let D;e[23]!==A||e[24]!==v?(D={enabled:!0,hasAuthoritativeGlobalSessions:v,sessions:A},e[23]=A,e[24]=v,e[25]=D):D=e[25],H3(D)};function Q3(t){return t.projects}function Y3(t){return t.activeProjectId}function X3(t){return t.currentDirectory}function J3(t){return t.currentSessionDirectory}function Z3(t){return t.activeSessions}function e4(t){return t.archivedSessions}function t4(t){return t.status==="ready"}function s4(){let t=null,e=!1;const n=new Set,r=Yr(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Ia(Do());return}const o=[...n];n.clear(),o.length&&ga(o,Do())},500)});return()=>{t&&clearTimeout(t),r()}}const n4=Ln(()=>Fn(()=>import("./SettingsWindow-DVTdDSol.js"),__vite__mapDeps([140,1,2,3,4,5,6,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,141,84,142,127,128,129,130,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102,143,144])).then(t=>({default:t.SettingsWindow}))),r4=()=>{const t=tt.c(58);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],q3(e),pg();const n=Pe(o4),r=Pe(i4),i=Pe(a4),o=Pe(l4),[l,a]=c.useState(!1);let u,d;t[1]!==i?(u=()=>{i&&a(!0)},d=[i],t[1]=i,t[2]=u,t[3]=d):(u=t[2],d=t[3]),c.useEffect(u,d);const h=Pe(c4),f=Pe(d4),p=Pe(u4),g=Pe(m4),w=Pe(f4),v=Pe(h4),x=g||w||!!v||h;let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[4]=m):m=t[4],c.useEffect(g4,m);const{isMobile:b}=_n();gg();const y=Hx();let S,N;t[5]!==b||t[6]!==r?(S=()=>{Pe.getState().isMobile!==b&&r(b)},N=[b,r],t[5]=b,t[6]=r,t[7]=S,t[8]=N):(S=t[7],N=t[8]),c.useEffect(S,N);let C,j,A,D;t[9]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(DS,{}),j=s.jsx(Cv,{}),A=s.jsx(Dv,{}),D=s.jsx(Vk,{}),t[9]=C,t[10]=j,t[11]=A,t[12]=D):(C=t[9],j=t[10],A=t[11],D=t[12]);let I;t[13]!==y?(I=s.jsx(Uk,{value:y,onMoveSessionOnly:x4,onMoveAllChanges:b4,onCancel:tb}),t[13]=y,t[14]=I):I=t[14];let M;t[15]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(db,{}),t[15]=M):M=t[15];let z;t[16]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(cb,{}),t[16]=z):z=t[16];let E;t[17]!==n?(E=s.jsx(zk,{isVisible:n}),t[17]=n,t[18]=E):E=t[18];let H;t[19]!==b||t[20]!==n||t[21]!==E?(H=s.jsx(lb,{isOpen:n,isMobile:b,className:"border-border",topBar:z,children:E}),t[19]=b,t[20]=n,t[21]=E,t[22]=H):H=t[22];let B;t[23]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(ib,{}),t[23]=B):B=t[23];const O=x&&"invisible";let T;t[24]!==O?(T=De("absolute inset-0",O),t[24]=O,t[25]=T):T=t[25];const k=!i&&!x;let P;t[26]!==k?(P=s.jsx(Hs,{children:s.jsx(nu,{active:k})}),t[26]=k,t[27]=P):P=t[27];let L;t[28]!==T||t[29]!==P?(L=s.jsx("div",{className:T,children:P}),t[28]=T,t[29]=P,t[30]=L):L=t[30];let Q;t[31]!==h||t[32]!==p||t[33]!==f?(Q=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Hs,{children:s.jsx(z3,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[31]=h,t[32]=p,t[33]=f,t[34]=Q):Q=t[34];let q;t[35]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(Hs,{children:s.jsx(x3,{})}),t[35]=q):q=t[35];let te;t[36]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(Hs,{children:s.jsx(b3,{})}),t[36]=te):te=t[36];let ae;t[37]===Symbol.for("react.memo_cache_sentinel")?(ae=s.jsx(Hs,{children:s.jsx(P3,{})}),t[37]=ae):ae=t[37];let X;t[38]!==L||t[39]!==Q?(X=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[L,Q,q,te,ae]}),t[38]=L,t[39]=Q,t[40]=X):X=t[40];let Z;t[41]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Zw,{}),t[41]=Z):Z=t[41];let se;t[42]!==X?(se=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[X,Z]})})}),t[42]=X,t[43]=se):se=t[43];let me;t[44]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Hs,{children:s.jsx(cS,{})})}),t[44]=me):me=t[44];let _;t[45]!==se?(_=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[B,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[se,me]})]}),t[45]=se,t[46]=_):_=t[46];let ne;t[47]!==H||t[48]!==_?(ne=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[H,_]}),t[47]=H,t[48]=_,t[49]=ne):ne=t[49];let ye;t[50]!==i||t[51]!==o||t[52]!==l?(ye=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(n4,{open:i,onOpenChange:o})}):null,t[50]=i,t[51]=o,t[52]=l,t[53]=ye):ye=t[53];let ce;return t[54]!==I||t[55]!==ne||t[56]!==ye?(ce=s.jsx(xg,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[C,j,A,D,I,M,ne,ye]})}),t[54]=I,t[55]=ne,t[56]=ye,t[57]=ce):ce=t[57],ce};function o4(t){return t.isSidebarOpen}function i4(t){return t.setIsMobile}function a4(t){return t.isSettingsDialogOpen}function l4(t){return t.setSettingsDialogOpen}function c4(t){return t.isMultiRunLauncherOpen}function d4(t){return t.setMultiRunLauncherOpen}function u4(t){return t.multiRunLauncherPrefillPrompt}function m4(t){return t.isScheduledTasksDialogOpen}function f4(t){return t.isArchivePageOpen}function h4(t){return t.worktreesPageProjectId}function p4(){return Pe.getState().closeMainSurfaces()}function g4(){const t=p4,e=Je.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function x4(){return Du(!1)}function b4(){return Du(!0)}const bm=12,y4=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],w4=t=>{const e=tt.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,u=r===void 0?0:r,d=o===void 0?900:o,h=l===void 0?y4:l,f=ht.useRef(!1);let p,g;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},g=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=g):(p=e[2],g=e[3]),ht.useEffect(p,g);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:bm},S4),e[4]=w):w=e[4];const v=w;if(!n)return null;let x;e[5]!==i?(x=De("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let m;if(e[7]!==u||e[8]!==h||e[9]!==d){let y;e[11]!==u||e[12]!==d?(y=S=>{const N={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${d}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:v.map((C,j)=>{const A=C.x*S.radius,D=C.y*S.radius,I={"--translate-x":`${A}px`,"--translate-y":`${D}px`,"--particle-delay":`${C.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:I},`${S.id}-${j}-${u}`)})},`${S.id}-${u}`)},e[11]=u,e[12]=d,e[13]=y):y=e[13],m=h.map(y),e[7]=u,e[8]=h,e[9]=d,e[10]=m}else m=e[10];let b;return e[14]!==u||e[15]!==x||e[16]!==m?(b=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":u,children:m}),e[14]=u,e[15]=x,e[16]=m,e[17]=b):b=e[17],b};function S4(t,e){const n=Math.PI*2*e/bm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const v4=t=>{const e=tt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ht.useState(o),u=ht.useRef(null);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},e[3]=d):d=e[3];const h=d;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(j4)},e[4]=f):f=e[4];const p=f;let g;e[5]!==i?(g=()=>{h(),a(k4),u.current=window.setTimeout(()=>{a(C4),u.current=null},i)},e[5]=i,e[6]=g):g=e[6];const w=g;let v,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),x=[h],e[7]=v,e[8]=x):(v=e[7],x=e[8]),ht.useEffect(v,x);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function j4(t){return t.isActive?{...t,isActive:!1}:t}function k4(t){return{isActive:!0,cycle:t.cycle+1}}function C4(t){return t.isActive?{...t,isActive:!1}:t}const ym=c.createContext(void 0),N4=t=>{const e=tt.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=v4();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const u=a;let d;e[3]!==i||e[4]!==r?(d=s.jsx(w4,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let h;return e[6]!==n||e[7]!==d||e[8]!==u?(h=s.jsxs(ym.Provider,{value:u,children:[n,d]}),e[6]=n,e[7]=d,e[8]=u,e[9]=h):h=e[9],h},c5=()=>{const t=c.useContext(ym);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ca="openchamber_requests_in_flight",wm=1e3,A4=300*1e3,Lo=Math.ceil(A4/wm),P4=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ca)==="1"}catch{return!1}},Sm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let D4=1;const I4=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},T4=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},vm=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},gr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},E4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=D4++;I4(o,Date.now());try{return await e(r,i)}finally{T4(o)}};window.fetch=n},Vc=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Ir=t=>{t.length>Lo&&t.splice(0,t.length-Lo)},R4=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=vm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(gr(e,50)),t.p90Samples.push(gr(e,90)),t.p99Samples.push(gr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Ir(t.samples),Ir(t.p50Samples),Ir(t.p90Samples),Ir(t.p99Samples),Ir(t.maxSamples),t.lastSampleAt=Date.now()},M4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(R4,wm))},Uc=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Kc=t=>{if(!(typeof window>"u"))try{if(t){Uc(),Vc(),window.localStorage.setItem(ca,"1"),window.__openchamberRequestsInFlight__=Sm(),E4(),M4();return}window.localStorage.removeItem(ca),Uc(),Vc(),delete window.__openchamberRequestsInFlight__}catch{}},O4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Sm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},da=()=>{if(typeof window>"u")return Hc();const t=window.__openchamberRequestsInFlight__;if(!P4()||!t)return Hc();const e=vm(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:gr(e,50),ageP90:gr(e,90),ageP99:gr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Lo}},Hc=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Lo});function B4(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const jm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},ua=t=>`${(t/1e3).toFixed(2)} s`,ys=t=>{const e=tt.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Gc=t=>{const e=tt.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=At();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let u;e[8]!==r.entries?(u=r.entries.reduce(L4,0),e[8]=r.entries,e[9]=u):u=e[9];const d=u;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?jm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==h||e[19]!==p?(g=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,p]}),e[18]=h,e[19]=p,e[20]=g):g=e[20];let w;e[21]!==o?(w=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=w):w=e[22];let v;e[23]!==r.entries.length||e[24]!==w?(v=s.jsx(ys,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=v):v=e[25];let x;e[26]!==o?(x=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=x):x=e[27];let m;e[28]!==x||e[29]!==d?(m=s.jsx(ys,{label:x,value:d}),e[28]=x,e[29]=d,e[30]=m):m=e[30];let b;e[31]!==o?(b=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=b):b=e[32];let y;e[33]!==r.lastUpdatedAt||e[34]!==o?(y=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=y):y=e[35];let S;e[36]!==b||e[37]!==y?(S=s.jsx(ys,{label:b,value:y}),e[36]=b,e[37]=y,e[38]=S):S=e[38];let N;e[39]!==m||e[40]!==S||e[41]!==v?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,m,S]}),e[39]=m,e[40]=S,e[41]=v,e[42]=N):N=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[g,N,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(ln,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},qc=t=>{const e=tt.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,u=n.reduce($4,0),d=r>0?52/r:0;let h;e[0]!==u||e[1]!==a?(h=S=>a-u+S,e[0]=u,e[1]=a,e[2]=h):h=e[2];const f=h;let p;e[3]!==d?(p=S=>56-S*d,e[3]=d,e[4]=p):p=e[4];const g=p;let w;e[5]!==l?(w=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=w):w=e[6];const v=`0 0 ${a} 56`;let x;e[7]!==a?(x=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=x):x=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==g){let S;e[13]!==f||e[14]!==g?(S=(N,C)=>{const j=N.samples.length;if(j===0)return null;const A=N.samples.map((I,M)=>`${f(M)},${g(I).toFixed(2)}`),D=`M ${A.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${f(0)},56 L ${A.join(" L ")} L ${f(j-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:D,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=g,e[15]=S):S=e[15],m=n.map(S),e[9]=n,e[10]=f,e[11]=g,e[12]=m}else m=e[12];let b;e[16]!==o||e[17]!==v||e[18]!==x||e[19]!==m?(b=s.jsxs("svg",{viewBox:v,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,m]}),e[16]=o,e[17]=v,e[18]=x,e[19]=m,e[20]=b):b=e[20];let y;return e[21]!==w||e[22]!==b?(y=s.jsxs("div",{className:"relative w-full",children:[w,b]}),e[21]=w,e[22]=b,e[23]=y):y=e[23],y},F4=t=>{const e=tt.c(100),{onClose:n}=t,{t:r}=At(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),u=Je(W4),d=$d(z4),h=Nd(),f=lp(V4),p=Ks(U4),[g,w]=c.useState(K4),[v,x]=c.useState(H4),[m,b]=c.useState(G4),y=[{label:"p50",current:m.ageP50,samples:m.p50Samples,color:"var(--status-success)"},{label:"p90",current:m.ageP90,samples:m.p90Samples,color:"var(--status-info)"},{label:"p99",current:m.ageP99,samples:m.p99Samples,color:"var(--status-warning)"},{label:"max",current:m.ageMax,samples:m.maxSamples,color:"var(--status-error)"}];let S;e[0]!==m.samples?(S=m.samples.reduce(q4,0),e[0]=m.samples,e[1]=S):S=e[1];const N=S,C=y.reduce(Y4,0);let j;e[2]!==g.entries?(j=new Map,g.entries.forEach(Re=>{j.set(Re.metric,Re.count)}),e[2]=g.entries,e[3]=j):j=e[3];let A;e[4]!==j?(A=j.get("ui.message_list.render")??0,e[4]=j,e[5]=A):A=e[5];let D;e[6]!==j?(D=j.get("ui.message_list.render.streaming")??0,e[6]=j,e[7]=D):D=e[7];let I;e[8]!==j?(I=j.get("ui.chat_message.render")??0,e[8]=j,e[9]=I):I=e[9];let M;e[10]!==j?(M=j.get("ui.chat_message.render.streaming")??0,e[10]=j,e[11]=M):M=e[11];let z;e[12]!==j?(z=j.get("ui.chat_message.render.static_during_stream")??0,e[12]=j,e[13]=z):z=e[13];let E;e[14]!==j?(E=j.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=j,e[15]=E):E=e[15];let H;e[16]!==A||e[17]!==D||e[18]!==I||e[19]!==M||e[20]!==z||e[21]!==E?(H={messageListRender:A,messageListRenderStreaming:D,chatMessageRender:I,chatMessageRenderStreaming:M,chatMessageRenderStaticDuringStream:z,chatMessageRenderStaticOutsideActiveTurnDuringStream:E},e[16]=A,e[17]=D,e[18]=I,e[19]=M,e[20]=z,e[21]=E,e[22]=H):H=e[22];const B=H;let O,T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const Re=()=>{w(mo()),x(fo()),b(da())};Re();const Ie=window.setInterval(Re,500);return()=>window.clearInterval(Ie)},O=[],e[23]=O,e[24]=T):(O=e[23],T=e[24]),c.useEffect(T,O);let k,P;e[25]!==l?(k=()=>{if(l==="idle")return;const Re=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Re)},P=[l],e[25]=l,e[26]=k,e[27]=P):(k=e[26],P=e[27]),c.useEffect(k,P);let L=0,Q=0,q=0;for(const Re of Object.keys(f)){const Ie=f[Re]??[];Q=Q+Ie.length;for(const rt of Ie)rt.role==="user"?q=q+1:rt.role==="assistant"&&(L=L+1)}let te;e[28]!==L||e[29]!==Q||e[30]!==q?(te={assistant:L,total:Q,user:q},e[28]=L,e[29]=Q,e[30]=q,e[31]=te):te=e[31];const ae=te;let X;if(e[32]!==u||e[33]!==f||e[34]!==d||e[35]!==h||e[36]!==r){let Re;e[38]!==u||e[39]!==f||e[40]!==d||e[41]!==r?(Re=Ie=>{const rt=f[Ie.id]??[];let Ge=0,ut=0;for(const ue of rt)ue.role==="user"?ut=ut+1:ue.role==="assistant"&&(Ge=Ge+1);const ct=d.get(Ie.id);return{id:Ie.id,title:Ie.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:Ge,messageCount:rt.length,userMessageCount:ut,isStreaming:ct?.isStreaming||!1,isZombie:ct?.isZombie||!1,backgroundCount:ct?.backgroundMessageCount||0,lastAccessed:ct?.lastAccessedAt||0,isCurrent:Ie.id===u}},e[38]=u,e[39]=f,e[40]=d,e[41]=r,e[42]=Re):Re=e[42],X=h.map(Re).sort(X4),e[32]=u,e[33]=f,e[34]=d,e[35]=h,e[36]=r,e[37]=X}else X=e[37];const Z=X;let se;e[43]!==f?(se=Object.keys(f),e[43]=f,e[44]=se):se=e[44];const me=se.length;let _;e[45]===Symbol.for("react.memo_cache_sentinel")?(_=async()=>{try{const Re={generatedAt:new Date().toISOString(),ui:mo(),vscode:fo()};await navigator.clipboard.writeText(JSON.stringify(Re,null,2)),a("copied")}catch{a("error")}},e[45]=_):_=e[45];const ne=_,ye=dp,ce="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let F;e[46]===Symbol.for("react.memo_cache_sentinel")?(F={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=F):F=e[46];let re;e[47]!==i?(re=B4(i),e[47]=i,e[48]=re):re=e[48];let fe;e[49]!==re?(fe=s.jsx(R,{name:re,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=re,e[50]=fe):fe=e[50];let de;e[51]!==r?(de=r("memoryDebugPanel.title"),e[51]=r,e[52]=de):de=e[52];let ge;e[53]!==de?(ge=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:de}),e[53]=de,e[54]=ge):ge=e[54];let Te;e[55]!==fe||e[56]!==ge?(Te=s.jsxs("div",{className:"flex items-center gap-2",children:[fe,ge]}),e[55]=fe,e[56]=ge,e[57]=Te):Te=e[57];let be;e[58]!==i?(be=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(pt,{size:"xs",variant:"ghost",onClick:ne,children:s.jsx(R,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(pt,{size:"xs",variant:"ghost",onClick:()=>{af(),w(mo()),x(fo())},children:s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=be):be=e[59];let Ee;e[60]!==i?(Ee=i==="requests"?s.jsx(pt,{size:"xs",variant:"ghost",onClick:()=>{O4(),b(da())},children:s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=Ee):Ee=e[61];let we;e[62]!==n?(we=n?s.jsx(pt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=we):we=e[63];let Y;e[64]!==be||e[65]!==Ee||e[66]!==we?(Y=s.jsxs("div",{className:"flex items-center gap-1",children:[be,Ee,we]}),e[64]=be,e[65]=Ee,e[66]=we,e[67]=Y):Y=e[67];let ve;e[68]!==Te||e[69]!==Y?(ve=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Te,Y]}),e[68]=Te,e[69]=Y,e[70]=ve):ve=e[70];let xe;e[71]===Symbol.for("react.memo_cache_sentinel")?(xe={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=xe):xe=e[71];const je=i==="memory"?"secondary":"ghost";let oe;e[72]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>o("memory"),e[72]=oe):oe=e[72];let J;e[73]!==r?(J=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=J):J=e[74];let K;e[75]!==je||e[76]!==J?(K=s.jsx(pt,{size:"sm",variant:je,className:"flex-1",onClick:oe,children:J}),e[75]=je,e[76]=J,e[77]=K):K=e[77];const $=i==="streaming"?"secondary":"ghost";let le;e[78]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("streaming"),e[78]=le):le=e[78];let V;e[79]!==r?(V=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=V):V=e[80];let Ce;e[81]!==$||e[82]!==V?(Ce=s.jsx(pt,{size:"sm",variant:$,className:"flex-1",onClick:le,children:V}),e[81]=$,e[82]=V,e[83]=Ce):Ce=e[83];const _e=i==="requests"?"secondary":"ghost";let ke;e[84]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>o("requests"),e[84]=ke):ke=e[84];let Ne;e[85]!==r?(Ne=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Ne):Ne=e[86];let Qe;e[87]!==_e||e[88]!==Ne?(Qe=s.jsx(pt,{size:"sm",variant:_e,className:"flex-1",onClick:ke,children:Ne}),e[87]=_e,e[88]=Ne,e[89]=Qe):Qe=e[89];let We;e[90]!==K||e[91]!==Ce||e[92]!==Qe?(We=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:xe,children:[K,Ce,Qe]}),e[90]=K,e[91]=Ce,e[92]=Qe,e[93]=We):We=e[93];const U=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ys,{label:r("memoryDebugPanel.metric.totalMessages"),value:ae.total}),s.jsx(ys,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${me} / ${ul.MAX_SESSIONS}`}),s.jsx(ys,{label:r("memoryDebugPanel.metric.userMessages"),value:ae.user}),s.jsx(ys,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ae.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:cp()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:ul.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(ln,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:Z.map(Re=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Re.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Re.title}),Re.isStreaming?s.jsx(R,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Re.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Re.assistantMessageCount,user:Re.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Re.messageCount})}),Re.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Re.backgroundCount]}):null]})]},Re.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Pt,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(pt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(J4),currentSessionId:u,cachedSessions:Object.keys(f),messageRoleCounts:ae,sessionMessageRoleCounts:Z.map(Z4),memoryStates:Object.fromEntries(d)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(It,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(pt,{size:"xs",variant:"outline",onClick:ne,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ys,{label:r("memoryDebugPanel.metric.uiMetrics"),value:g.entries.length}),s.jsx(ys,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(ys,{label:r("memoryDebugPanel.metric.messageListRenders"),value:B.messageListRender}),s.jsx(ys,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:B.messageListRenderStreaming}),s.jsx(ys,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:B.chatMessageRender}),s.jsx(ys,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:B.chatMessageRenderStreaming}),s.jsx(ys,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:B.chatMessageRenderStaticDuringStream}),s.jsx(ys,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:B.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Gc,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:g,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(Gc,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ys,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(ys,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?jm(m.durationMs):r("memoryDebugPanel.common.idle")})]}),m.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.peak})]})]}),s.jsx(qc,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${N}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ua(m.peakAgeMs)})]}),s.jsx(qc,{series:y.map(eC),peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:ua(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:y.map(tC)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:m.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let he;return e[94]!==ye||e[95]!==F||e[96]!==ve||e[97]!==We||e[98]!==U?(he=s.jsxs(ye,{className:ce,style:F,children:[ve,We,U]}),e[94]=ye,e[95]=F,e[96]=ve,e[97]=We,e[98]=U,e[99]=he):he=e[99],he},_4=F4;function L4(t,e){return t+e.count}function $4(t,e){return Math.max(t,e.samples.length)}function W4(t){return t.currentSessionId}function z4(t){return t.sessionMemoryState}function V4(t){return t.message}function U4(t){return t.totalRequestCount}function K4(){return mo()}function H4(){return fo()}function G4(){return da()}function q4(t,e){return Math.max(t,e)}function Q4(t,e){return Math.max(t,e)}function Y4(t,e){return e.samples.reduce(Q4,t)}function X4(t,e){return e.lastAccessed-t.lastAccessed}function J4(t){return{id:t.id,title:t.title}}function Z4(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function eC(t){return{samples:t.samples,color:t.color}}function tC(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ua(t.current)})]},t.label)}const sC=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},nC=async()=>{const t=sC()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Qc="openchamber:menu-action",bi="openchamber:check-for-updates",rC=t=>{const e=Je(m=>m.openNewSessionDraft),n=Pe(m=>m.toggleCommandPalette),r=Pe(m=>m.setCommandPaletteOpen),i=Pe(m=>m.toggleHelpDialog),o=Pe(m=>m.toggleSidebar),l=Pe(m=>m.setSessionSwitcherOpen),a=Pe(m=>m.setSettingsDialogOpen),u=Pe(m=>m.setAboutDialogOpen),d=Or(m=>m.checkForUpdates),{setThemeMode:h}=Zn(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,d().then(()=>{const{available:m,error:b}=Or.getState();if(b){Me.error("Failed to check for updates",{description:b});return}m||Me.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[d]),g=c.useCallback(()=>{gn.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const b=up();if(b.length===0)return;const y=Je.getState().currentSessionId,S=b.findIndex(j=>j.id===y);let N=m>0?0:b.length-1;S>=0&&(N=(S+m+b.length)%b.length);const C=b[N];C&&(l(!1),Je.getState().setCurrentSession(C.id))},[l]),v=c.useCallback(m=>{const{activeProjectId:b,projects:y,setActiveProject:S}=Kt.getState();if(y.length===0)return;const N=y.findIndex(A=>A.id===b);let C=m>0?0:y.length-1;N>=0&&(C=(N+m+y.length)%y.length);const j=y[C];j&&S(j.id)},[]),x=c.useCallback(m=>{switch(m){case"about":u(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const b=Je.getState(),y=ts.getState().currentDirectory;e(b.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Ed();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const b=ts.getState().currentDirectory;if(!b)break;const y=Pe.getState(),S=rr(b),N=y.contextPanelByDirectory[S];N?.isOpen?y.closeContextPanel(S):N?.activeTabId?y.setActiveContextPanelTab(S,N.activeTabId):y.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const b=ts.getState().currentDirectory;if(!b)break;Pe.getState().openContextSurface(rr(b),"git");break}case"open-right-sidebar-files":{const b=ts.getState().currentDirectory;if(!b)break;Pe.getState().openContextSurface(rr(b),"file");break}case"toggle-terminal":{const b=ts.getState().currentDirectory;if(!b)break;Pe.getState().openContextSurface(rr(b),"terminal");break}case"toggle-terminal-expanded":{const b=ts.getState().currentDirectory;if(!b)break;const y=rr(b),S=Pe.getState(),N=S.contextPanelByDirectory[y];(N?.isOpen?N.tabs.find(j=>j.id===N.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(y,"terminal"),S.toggleContextPanelExpanded(y);break}case"copy":{const b=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(b)||nC();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":mp();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ts.getState().goBack();break;case"go-forward":ts.getState().goForward();break;case"previous-session":w(-1);break;case"next-session":w(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":i();break;case"download-logs":{Rd().catch(()=>{Me.error("Failed to collect OpenCode status")});break}}},[g,v,w,t,e,u,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=y=>{const S=y.detail;S&&x(S)},b=()=>{p()};return window.addEventListener(Qc,m),window.addEventListener(bi,b),()=>{window.removeEventListener(Qc,m),window.removeEventListener(bi,b)}},[x,p]),c.useEffect(()=>{if(typeof window>"u")return;const b=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof b!="function")return;let y=null,S=null;return b("openchamber:menu-action",N=>{const C=N?.payload;typeof C=="string"&&x(C)}).then(N=>{y=N}).catch(()=>{}),b("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(bi))}).then(N=>{S=N}).catch(()=>{}),()=>{(async()=>{try{const C=y?.();C instanceof Promise&&await C}catch{}try{const C=S?.();C instanceof Promise&&await C}catch{}})()}},[x])},oC="openchamber:tray-action",Yc=5e3,iC=500,km=20,Xc=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Jc=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,aC=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},lC=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Cm=(t,e)=>Vd(t,e,$r.getState().ids,va.getState().rankById),cC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},dC=(t,e,n,r,i)=>{if(!t)return"";const o=ud(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||cC(t),u=go(t);let d=u&&i.get(u)||"";if(!d){for(const[h,f]of On.getState().directories)if(go(h)===u){d=f.status?.current??"";break}}if(!d)for(const h of r.values()){const f=h.find(p=>go(p.path)===u);if(f?.branch){d=f.branch;break}}return d?`${a} · ${d}`:a},uC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ir.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of pp){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const u=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;u.push({label:xp(h),value:gp(f.valueLabel,p)})}const d=!a.ok&&a.error?a.error:u.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:u,status:d})}return{mode:r,groups:o}},mC=async()=>{try{if($o())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Nn();if(e&&Ha(e,t))return"Local OpenChamber";const r=(await od()).hosts.find(i=>e?Ha(e,lf(i)):!1);return r?.label?.trim()?id(r.label.trim()):"Instance"}catch{return""}},fC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Po()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(go(o)??o,a.vcs.branch);for(const u of a.session)u?.id&&r.set(u.id,u.title);for(const[u,d]of Object.entries(a.session_status??{})){const h=d?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(u);(!p||p==="idle")&&t.set(u,f)}for(const[u,d]of Object.entries(a.permission??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:aC(h),directory:o})}for(const[u,d]of Object.entries(a.question??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:lC(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},hC=()=>{const t=Ds.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Cm).slice(0,km).forEach(r=>{const i=$s(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=$s(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},pC=t=>{const e=fC(),n=Aa.getState().index.session,r=Ds.getState().activeSessions,i=new Map(e.titleById),o=new Map;for(const x of r)if(x?.id&&(x.title&&i.set(x.id,x.title),x.parentID)){const m=o.get(x.parentID)??[];m.push(x.id),o.set(x.parentID,m)}const l=x=>{const m=[],b=[...o.get(x)??[]],y=new Set;for(;b.length;){const S=b.pop();y.has(S)||(y.add(S),m.push(S),b.push(...o.get(S)??[]))}return m},a=Na.getState().statusById,u=x=>{const m=e.statusById.get(x);return m&&m!=="idle"?m:a.get(x)?.status.type??m??"idle"},d=x=>{const m=x.map(b=>u(b));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},h=Kt.getState().projects,f=Je.getState().availableWorktreesByProject,p=r.filter(x=>x?.id&&!x.parentID).slice().sort(Cm).slice(0,km).map(x=>{const m=[x.id,...l(x.id)],b=$s(x)??"";return{id:x.id,title:x.title||"Untitled session",status:d(m),branch:b?e.branchByDirectory.get(b)??"":"",unseen:m.reduce((y,S)=>y+(n.unseenCount[S]??0),0),hasError:m.some(y=>n.unseenHasError[y]??!1),directory:b,subtitle:dC(b,x,h,f,e.branchByDirectory)}}),g=e.approvals.map(x=>({...x,sessionTitle:i.get(x.sessionId)||""})),w=Pe.getState();let v=0;if(w.dockBadgeEnabled)for(const x of r){if(!x?.id||x.parentID)continue;let m=n.unseenCount[x.id]??0;m===0&&w.notifyOnSubtasks&&(m=l(x.id).reduce((b,y)=>b+(n.unseenCount[y]??0),0)),m>0&&(v+=1)}return{sessions:p,approvals:g,instanceName:t,usage:uC(),dockBadgeCount:v}},gC=()=>{c.useEffect(()=>{if(!Xc()||!Jc()||!zo())return;let t=!1,e="",n=null,r="";const i=()=>{if(t)return;const C=pC(r),j=JSON.stringify(C);j!==e&&(e=j,Rn("desktop_tray_update",C))};mC().then(C=>{t||(r=C,i())});const o=async()=>{const C=hC();await Promise.all([...C.entries()].map(async([j,A])=>{const D=await qs.getSessionStatusForDirectory(j).catch(()=>null);t||D===null||fp(j,D,A)}))},l=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,i()},iC))},a=new Map,u=()=>{if(t)return;let C;try{C=Po()}catch{return}const j=new Set;for(const[A,D]of C.children.entries())j.add(A),a.has(A)||a.set(A,D.subscribe(()=>l()));for(const[A,D]of a)j.has(A)||(D(),a.delete(A))};let d=null;try{d=Po().subscribeRegistry(()=>{u(),l()})}catch{}u();const h=Aa.subscribe(()=>l()),f=Ds.subscribe(()=>l()),p=Kt.subscribe(()=>l()),g=Je.subscribe(()=>l()),w=On.subscribe(()=>l()),v=Pe.subscribe(()=>l()),x=Na.subscribe(()=>l()),m=va.subscribe(()=>l()),b=$r.subscribe(()=>l());o();const y=window.setInterval(()=>{o()},Yc),S=ir.subscribe(()=>l());ir.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:C,results:j}=ir.getState();C.length>0&&C.some(D=>!j.some(I=>I.providerId===D))&&ir.getState().fetchQuotas(C)});const N=window.setInterval(()=>{u(),i()},Yc);return i(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(N),window.clearInterval(y),h(),f(),p(),g(),w(),v(),x(),m(),b(),S(),d?.();for(const C of a.values())C();a.clear()}},[]),c.useEffect(()=>{if(!Xc()||!Jc()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&hp(i.sessionId,i.id,i.response).catch(()=>{Me.error("Failed to respond to permission request")})};let r=null;return e(oC,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},xC=45e3,bC=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,xC);return()=>r(i)},yC=t=>{const e=tt.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return bC(wC,SC)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function wC(){bp(Do())}function SC(){Ia()}const vC="/api/notifications/stream",jC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),kC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},CC=t=>{const e=tt.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||xn()||!fa()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ld().sse(vC));return o.onmessage=NC,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function NC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Pe.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&jC())return;const r=kC(e);if(!r)return;Wo()?.notifications?.notifyAgentCompletion(r)}const AC=6e4,PC=t=>{const e=tt.c(10),n=Pe(DC),r=yp(IC),o=bg(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:AC})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let u,d;e[5]!==n||e[6]!==r||e[7]!==o?(u=()=>{if(n)return Yr(h=>{h.type==="agent-memory-changed"&&r(o)})},d=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=u,e[9]=d):(u=e[8],d=e[9]),c.useEffect(u,d)};function DC(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function IC(t){return t.load}const Zc="pwa-install-toast-shown",ed="pwa-install-toast-dismissed",TC=()=>{const t=tt.c(6),{browserTab:e}=yg(),{t:n}=At(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!fa()||!e)return;let u=null,d=null;const h=()=>{d!==null&&(Me.dismiss(d),d=null)},f=async()=>{if(!u)return;const w=u;u=null,h(),await w.prompt();const{outcome:v}=await w.userChoice;v==="accepted"&&Me.success(r.current("pwa.installPrompt.started"))},p=w=>{const v=w;if(typeof v.prompt!="function")return;v.preventDefault(),u=v;const x=No(),m=cf();wg({dismissed:x.getItem(ed),sessionShown:m.getItem(Zc),hasActiveToast:d!==null})&&(m.setItem(Zc,"true"),d=Me.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{No().setItem(ed,"true"),h()}}}))},g=()=>{u=null,h(),Me.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",g),()=>{h(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",g)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},EC=({open:t,onOpenChange:e})=>{const{t:n}=At(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[u,d]=c.useState(!1),[h,f]=c.useState(!1),[p,g]=c.useState(null),[w,v]=c.useState(!1);c.useCallback(async()=>{},[p,u,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const b=await ds("/api/system/info");if(b.ok){const y=await b.json();if(typeof y.openchamberVersion=="string"&&y.openchamberVersion.trim()){o(y.openchamberVersion);return}}}catch{}o(await wp())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const y=await ds("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!y.ok)return;const S=await y.json().catch(()=>null),N=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!m&&N&&a(N)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{g(null),v(!1);return}},[t,r]);const x=i;return s.jsx(ws,{open:t,onOpenChange:e,children:s.jsx(Ss,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Ad,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(R,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(R,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(R,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},td=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},yi=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},RC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},MC=()=>{const t=Sp(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),u=yi(a,"code"),d=vp(a),h=jp(a),f=yi(a,"error"),p=yi(a,"error_description");if(f){h&&ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(p??f);return}(async()=>{try{if(!u)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let g=d,w=!1;if(h){const v=await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const x=await v.json().catch(()=>null);w=x?.origin===kp,i(w),!g&&x?.name?.trim()&&(g={name:x.name.trim(),directory:typeof x.directory=="string"&&x.directory.trim()?x.directory.trim():null})}}if(!g?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(g.name,u,g.directory),h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&td(!0),l("Authorization completed. You can close this tab and return to OpenChamber.")}catch(g){h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(RC(g,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:Cp,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:De("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(pt,{type:"button",onClick:()=>td(r),children:"Return to OpenChamber"})})]})})},sd=Ln(()=>Fn(()=>import("./OnboardingScreen-DdP4_nuc.js"),__vite__mapDeps([145,1,2,4,5,6,7,8,9,3,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),OC=()=>{const t=tt.c(3),e=Pe(WC),n=Pe(zC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(EC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},BC=t=>{const e=tt.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=At();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,e[5]=a):a=e[5];let u;e[6]!==a?(u=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==u?(d=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,u]}),e[8]=l,e[9]=u,e[10]=d):d=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(pt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let p;return e[18]!==d||e[19]!==f?(p=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[d,f]})}),e[18]=d,e[19]=f,e[20]=p):p=e[20],p},nd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",FC=()=>{if(typeof window>"u"||!Kg())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},_C=()=>typeof window>"u"?!1:window.location.pathname===Ip,LC=t=>{const e=tt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ts(VC),l=Je(UC),a=Je(KC),u=vd(),d=c.useRef(null);let h;e[0]!==n.directory?(h=nd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let p;e[2]!==o?(p=nd(o),e[2]=o,e[3]=p):p=e[3];const g=p;let w,v;if(e[4]!==g||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==u?(w=()=>{if(r||f&&g!==f)return;const N=`${f}
|
|
930
|
-
${n.sessionId}`;d.current===N&&l||(d.current=N,a(n.sessionId,n.directory),u.ensureSessionRenderable(n.sessionId,!0))},v=[g,l,n.directory,n.sessionId,f,r,a,u],e[4]=g,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=u,e[12]=w,e[13]=v):(w=e[12],v=e[13]),c.useEffect(w,v),f&&g!==f)return null;let x;e[14]!==i?(x=s.jsx(Gd,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=x):x=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(ru,{}),e[16]=m):m=e[16];let b;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(b=s.jsx(nu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=b):b=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(qd,{}),e[21]=y):y=e[21];let S;return e[22]!==x||e[23]!==b?(S=s.jsxs(s.Fragment,{children:[x,m,b,y]}),e[22]=x,e[23]=b,e[24]=S):S=e[24],S};function $C({apis:t}){c.useEffect(()=>{df("App:mounted"),uf()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Gt(F=>F.initializeApp),n=Gt(F=>F.isInitialized),r=Gt(F=>F.isConnected),i=Gt(F=>F.providers.length),o=Gt(F=>F.agents.length),l=Gt(F=>F.loadProviders),a=Gt(F=>F.loadAgents),u=Je(F=>F.error),d=Je(F=>F.clearError),h=ts(F=>F.currentDirectory),f=ts(F=>F.setDirectory),p=ts(F=>F.isSwitchingDirectory),[g,w]=c.useState(!1),v=An(F=>F.refreshStatus),x=ki(F=>F.refreshStatus),[m,b]=c.useState(()=>t.runtime.isVSCode),[y,S]=c.useState(!1),[N,C]=c.useState(!1),[j,A]=c.useState(0),[D,I]=c.useState(0),[M,z]=c.useState(!1),E=Pe(F=>F.wideChatLayoutEnabled),H=Pe(F=>F.mobileKeyboardMode),B=c.useMemo(()=>xn(),[]),O=xa(F=>F.setPlanModeEnabled),[T,k]=c.useState(()=>Ga()),[P,L]=c.useState(()=>{const F=qa();return F!==null?Qa({isDesktopShell:!0,bootOutcome:F}):null}),Q=c.useRef(!1),q=c.useMemo(()=>FC(),[]),te=!q||y,ae=c.useMemo(()=>_C(),[]);c.useEffect(()=>(Ya(g),()=>{Ya(!1)}),[g]),c.useEffect(()=>(Kc(g),()=>{Kc(!1)}),[g]),c.useEffect(()=>{mf(H)},[H]),c.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>ma(F=>{Sg(F),I(re=>re+1),C(!1),A(re=>re+1)}),[]);const X=ml(F=>{const re=ps();return Object.values(F.runsByOriginalSessionID).filter(fe=>fe.status==="running"&&fe.runtimeKey===re).map(fe=>`${fe.originalSessionID}:${fe.phase}:${fe.lastForwardedMessageID??""}:${fe.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(q)return;const F=ps(),re=Object.values(ml.getState().runsByOriginalSessionID).filter(fe=>fe.status==="running"&&fe.runtimeKey===F);for(const fe of re)Np(fe.originalSessionID)},[X,q,D]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",E),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[E]),c.useEffect(()=>(Xa(t),()=>Xa(null)),[t]),c.useEffect(()=>{q||(v(t.github,{force:!0}),x(t.linear,{force:!0}))},[t.github,t.linear,q,r,v,x,D]),Ap();const Z=T==="valid",se=P?.screen==="main";c.useEffect(()=>{if(!ff({isDesktopShell:B,isInitialized:n,bootOutcomeKnown:Z,bootViewIsMain:se}))return;const F=setTimeout(()=>{const re=document.getElementById("initial-loading");re&&(re.classList.add("fade-out"),setTimeout(()=>{re.remove()},300))},150);return()=>clearTimeout(F)},[B,n,Z,se]),c.useEffect(()=>{if(!B||T!=="malformed")return;const F=document.getElementById("initial-loading");F&&(F.textContent="Desktop startup failed — please restart the app.")},[B,T]),c.useEffect(()=>{if(B)return;const F=setTimeout(()=>{const re=document.getElementById("initial-loading");re&&!n&&(re.classList.add("fade-out"),setTimeout(()=>{re.remove()},300))},5e3);return()=>clearTimeout(F)},[B,n]),c.useEffect(()=>{let F=!1;return(async()=>{const fe=await ds("/health",{method:"GET"}).catch(()=>null);if(!fe||!fe.ok||F)return;const de=await fe.json().catch(()=>null);if(!de||F)return;const ge=de.planModeExperimentalEnabled;O(ge===!0||ge===1||ge==="1"||ge==="true")})(),()=>{F=!0}},[O]),c.useEffect(()=>{m||e()},[e,m]),c.useEffect(()=>{if(m||n)return;let F=!0,re,fe=0;const de=10,ge=1e3,Te=async()=>{if(!F)return;if(fe>=de){C(!0);return}const be=Gt.getState();if(be.isInitialized){C(!1);return}fe+=1,await be.initializeApp();const Ee=Gt.getState();if(!F)return;if(Ee.isInitialized){C(!1);return}if(fe>=de){C(!0);return}const we=Math.min(ge*Math.pow(2,fe-1),16e3);re=setTimeout(Te,we)};return re=setTimeout(Te,ge),()=>{F=!1,re&&clearTimeout(re)}},[j,n,m]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!N)return;const F=document.getElementById("initial-loading");F&&(F.classList.add("fade-out"),setTimeout(()=>{F.remove()},300))},[N]),c.useEffect(()=>{if(m||!r||i>0&&o>0)return;let F=!0,re=0;const fe=15,de=async()=>{const Te=Gt.getState();if(!(Te.providers.length>0&&Te.agents.length>0))try{Te.providers.length===0&&await l({source:"startupRecovery"}),Gt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};de();const ge=setInterval(()=>{if(F){if(++re>=fe){clearInterval(ge);return}de()}},2e3);return()=>{F=!1,clearInterval(ge)}},[r,m,a,l,i,o]),c.useEffect(()=>{p||m||r&&qs.setDirectory(h)},[h,p,r,m]),c.useEffect(()=>{if(!q||typeof window>"u")return;const F=de=>{S(de?.visible===!0)},re=de=>{if(de.origin!==window.location.origin||de.source!==window.parent)return;const ge=de.data;ge?.type===fu&&F(ge.payload)},fe=window;return fe.__openchamberSetEmbeddedVisibility=F,window.addEventListener("message",re),Ug(),()=>{window.removeEventListener("message",re),fe.__openchamberSetEmbeddedVisibility===F&&delete fe.__openchamberSetEmbeddedVisibility}},[q]),c.useEffect(()=>{!q?.directory||m||h!==q.directory&&f(q.directory,{showOverlay:!1})},[h,q,m,f]),c.useEffect(()=>{if(!q||typeof window>"u")return;const F=re=>{re.storageArea===window.localStorage&&re.key==="ui-store"&&Pe.persist.rehydrate()};return window.addEventListener("storage",F),()=>{window.removeEventListener("storage",F)}},[q]),c.useEffect(()=>{if(typeof window>"u")return;const F=re=>{const fe=re.detail,de=typeof fe?.sessionId=="string"?fe.sessionId.trim():"";if(!de)return;const ge=typeof fe?.directory=="string"&&fe.directory.trim().length>0?fe.directory.trim():null;Je.getState().setCurrentSession(de,ge)};return window.addEventListener("openchamber:open-session",F),()=>window.removeEventListener("openchamber:open-session",F)},[]),c.useEffect(()=>{if(typeof window>"u")return;const F=()=>{Rn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",F),()=>window.removeEventListener("openchamber:open-mini-chat",F)},[]),c.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const re=Je.getState().currentSessionId;re&&Pd(re)};return window.addEventListener("focus",F),()=>window.removeEventListener("focus",F)},[]),c.useEffect(()=>{if(typeof window>"u")return;const F=re=>{const fe=re.detail,de=typeof fe?.directory=="string"&&fe.directory.trim().length>0?fe.directory.trim():null,ge=typeof fe?.projectId=="string"&&fe.projectId.trim().length>0?fe.projectId.trim():null,Te=!!(de||ge);Pe.getState().setSessionSwitcherOpen(!1),Je.getState().openNewSessionDraft({target:Te?"project":"chat",selectedProjectId:Te?ge:null,directoryOverride:Te?de:null,preserveDirectoryOverride:!!de})};return window.addEventListener("openchamber:open-draft-session",F),()=>window.removeEventListener("openchamber:open-draft-session",F)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||Q.current||(Q.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),Pp({enabled:te}),CC({enabled:te}),PC(h||null),TC(),Dp(),Vp(),vg();const me=c.useCallback(()=>{w(F=>!F)},[]);rC(me),gC(),yC(!q),c.useEffect(()=>{if(q)return;const F=()=>w(re=>!re);return window.addEventListener("openchamber:memory-debug-toggle",F),()=>window.removeEventListener("openchamber:memory-debug-toggle",F)},[q]),c.useEffect(()=>{q||u&&setTimeout(()=>d(),5e3)},[d,q,u]),c.useEffect(()=>{if(!B||T!=="not-injected")return;let F=!1,re=0;const fe=200,de=2e3,ge=50,Te=()=>{if(F)return;re++;const be=Ga();if(be!=="not-injected"){if(F=!0,k(be),be==="valid"){const we=qa();we&&L(Qa({isDesktopShell:!0,bootOutcome:we}))}return}const Ee=Math.min(fe*Math.pow(1.1,re),de);if(re>=ge){const we=document.getElementById("initial-loading");we&&!we.textContent?.includes("taking longer")&&(we.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Te,Ee)};return window.setTimeout(Te,fe),()=>{F=!0}},[B,T]);const _=c.useCallback(async()=>{if(hf({isDesktopShell:xn(),isDesktopLocalOriginActive:$o()})){await pf();return}window.location.reload()},[]),ne=c.useCallback(async()=>{if(!M){C(!1),z(!0);try{await Gt.getState().initializeApp()}finally{z(!1)}Gt.getState().isInitialized||A(F=>F+1)}},[M]),ye=F=>{if(F.screen==="recovery")return F.variant};if(B&&P&&P.screen!=="main"){if(P.screen==="chooser")return s.jsx(Hs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(sd,{mode:"first-launch",localAvailable:P.localAvailable!==!1,onCliAvailable:_,onChooseRemote:()=>{}})})})});const F=ye(P),re=P.screen==="recovery"&&"url"in P?P.url:void 0;return s.jsx(Hs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(sd,{mode:"recovery",recoveryVariant:F,recoveryHostUrl:re,recoveryHostLabel:void 0,localAvailable:P.localAvailable!==!1,onCliAvailable:_})})})})}if(q)return s.jsx(Hs,{children:s.jsx(fl,{sdk:qs.getSdkClient(),directory:h||"",children:s.jsx(hl,{apis:t,children:s.jsx(Ii,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(LC,{embeddedSessionChat:q,isVSCodeRuntime:m,embeddedBackgroundWorkEnabled:te}),s.jsx(pl,{}),s.jsx(gl,{})]})})})},D)});if(ae)return s.jsx(Hs,{children:s.jsx(MC,{})});if(N&&!n&&!m&&!q)return s.jsx(Hs,{children:s.jsx(BC,{onRetry:()=>{ne()},isRetrying:M})});const ce=!n&&!B;return s.jsx(Hs,{children:s.jsx(fl,{sdk:qs.getSdkClient(),directory:h||"",children:s.jsx(hl,{apis:t,children:s.jsx(N4,{children:s.jsx(Ii,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:B?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Gd,{embeddedBackgroundWorkEnabled:te}),s.jsx(ru,{}),s.jsx(r4,{}),s.jsx(qd,{}),s.jsx(pl,{}),s.jsx(gl,{}),!ce&&s.jsxs(s.Fragment,{children:[s.jsx(jg,{}),s.jsx(OC,{}),g&&s.jsx(_4,{onClose:()=>w(!1)})]})]})})})})},D)})}function WC(t){return t.isAboutDialogOpen}function zC(t){return t.setAboutDialogOpen}function VC(t){return t.currentDirectory}function UC(t){return t.currentSessionId}function KC(t){return t.setCurrentSession}const HC=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Tp();gf().then(()=>{Promise.all([xf(),Ep()]).catch(t=>{console.error("[main] settings init failed:",t)}),Rp(),Mp(),Op()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Nm=document.getElementById("root");if(!Nm)throw new Error("Root element not found");Bp();_m.createRoot(Nm).render(s.jsx(ht.StrictMode,{children:s.jsx(Fp,{children:s.jsx(_p,{children:s.jsx(Lp,{children:s.jsx($p,{children:s.jsx($C,{apis:HC})})})})})}));const d5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Nb as W,pb as a,c5 as b,Bu as g,d5 as m,Cb as u,Ou as v};
|