@openchamber/web 2.3.2 → 2.3.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.
Files changed (213) hide show
  1. package/dist/assets/{AboutDialog-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
  2. package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
  3. package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
  4. package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
  5. package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
  6. package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
  7. package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
  8. package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
  9. package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
  10. package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
  11. package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
  12. package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
  13. package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
  14. package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
  15. package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
  16. package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
  17. package/dist/assets/PlanView-BxRCMuGe.js +5 -0
  18. package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
  19. package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
  20. package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
  21. package/dist/assets/SettingsView-CVpfbdob.js +30 -0
  22. package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
  23. package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
  24. package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
  25. package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
  26. package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
  27. package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
  28. package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
  29. package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
  30. package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
  31. package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
  32. package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
  33. package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
  34. package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
  35. package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
  36. package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
  37. package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
  38. package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
  39. package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
  40. package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
  41. package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
  42. package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
  43. package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
  44. package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
  45. package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
  46. package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
  47. package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
  48. package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
  49. package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
  50. package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
  51. package/dist/assets/katex-BZNCT55U.css +1 -0
  52. package/dist/assets/katex.min-EZjpSwGK.js +65 -0
  53. package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
  54. package/dist/assets/main-BUetg9hg.js +1048 -0
  55. package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
  56. package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
  57. package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
  58. package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
  59. package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
  60. package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
  61. package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
  62. package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
  63. package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
  64. package/dist/assets/pl-4LdEMgWI.js +20 -0
  65. package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
  66. package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
  67. package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
  68. package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
  69. package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
  70. package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
  71. package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
  72. package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
  73. package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
  74. package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
  75. package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
  76. package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
  77. package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
  78. package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
  79. package/dist/assets/tr-Bg0Qt-mG.js +11 -0
  80. package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
  81. package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
  82. package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
  83. package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
  84. package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
  85. package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
  86. package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
  87. package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
  88. package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
  89. package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
  90. package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
  91. package/dist/index.html +3 -3
  92. package/dist/mini-chat.html +3 -3
  93. package/dist/mobile.html +3 -3
  94. package/package.json +5 -5
  95. package/server/index.js +13 -1
  96. package/server/lib/agent-memory/actions.js +22 -9
  97. package/server/lib/agent-memory/actions.test.js +57 -0
  98. package/server/lib/agent-memory/runtime.js +8 -5
  99. package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
  100. package/server/lib/agent-tool/runtime.js +41 -7
  101. package/server/lib/agent-tool/runtime.test.js +11 -0
  102. package/server/lib/git/DOCUMENTATION.md +17 -5
  103. package/server/lib/git/lfs-discovery.js +7 -4
  104. package/server/lib/git/lfs-discovery.test.js +60 -0
  105. package/server/lib/git/network-operations.js +9 -3
  106. package/server/lib/git/network-operations.test.js +31 -2
  107. package/server/lib/git/service.js +72 -12
  108. package/server/lib/git/service.test.js +65 -0
  109. package/server/lib/github/DOCUMENTATION.md +1 -0
  110. package/server/lib/github/reference-search.js +49 -18
  111. package/server/lib/github/reference-search.test.js +28 -6
  112. package/server/lib/github/routes.js +87 -1
  113. package/server/lib/github/routes.mutations.test.js +38 -0
  114. package/server/lib/github/routes.test.js +1 -0
  115. package/server/lib/gitlab/DOCUMENTATION.md +4 -0
  116. package/server/lib/gitlab/client.js +23 -0
  117. package/server/lib/gitlab/client.test.js +28 -1
  118. package/server/lib/gitlab/mappers.js +9 -0
  119. package/server/lib/gitlab/resources.js +153 -4
  120. package/server/lib/gitlab/resources.test.js +107 -0
  121. package/server/lib/gitlab/routes.js +120 -1
  122. package/server/lib/gitlab/routes.test.js +59 -0
  123. package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
  124. package/server/lib/markdown-image-grants/routes.js +14 -2
  125. package/server/lib/markdown-image-grants/routes.test.js +23 -0
  126. package/server/lib/notifications/APNS.md +24 -23
  127. package/server/lib/notifications/DOCUMENTATION.md +2 -2
  128. package/server/lib/notifications/apns-runtime.js +8 -5
  129. package/server/lib/notifications/apns-runtime.test.js +26 -0
  130. package/server/lib/notifications/message.js +5 -3
  131. package/server/lib/notifications/message.test.js +9 -0
  132. package/server/lib/notifications/runtime.js +44 -9
  133. package/server/lib/notifications/trigger-runtime.test.js +84 -0
  134. package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
  135. package/server/lib/openchamber-control/actions.js +18 -2
  136. package/server/lib/openchamber-control/project-knowledge.js +17 -3
  137. package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
  138. package/server/lib/openchamber-control/render-page.js +58 -0
  139. package/server/lib/openchamber-control/service.js +9 -0
  140. package/server/lib/openchamber-control/service.test.js +43 -0
  141. package/server/lib/openchamber-sessions/routes.js +1 -0
  142. package/server/lib/openchamber-sessions/worktree-move.js +26 -10
  143. package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
  144. package/server/lib/opencode/DOCUMENTATION.md +1 -1
  145. package/server/lib/opencode/managed-config-file.js +3 -2
  146. package/server/lib/opencode/managed-config-file.test.js +20 -6
  147. package/server/lib/opencode/settings-helpers.js +3 -0
  148. package/server/lib/opencode/settings-helpers.test.js +1 -1
  149. package/server/lib/opencode/settings-registry.json +3 -0
  150. package/server/lib/opencode/settings-runtime.js +1 -0
  151. package/server/lib/project-context/DOCUMENTATION.md +25 -1
  152. package/server/lib/project-context/plan-progress.js +69 -0
  153. package/server/lib/project-context/plan-progress.test.js +58 -0
  154. package/server/lib/project-context/routes.http.test.js +22 -0
  155. package/server/lib/project-context/routes.js +20 -0
  156. package/server/lib/project-context/runtime.js +132 -18
  157. package/server/lib/project-context/runtime.test.js +58 -0
  158. package/server/lib/provider-read-cache/index.js +7 -1
  159. package/server/lib/provider-read-cache/index.test.js +12 -0
  160. package/server/lib/relay/DOCUMENTATION.md +17 -1
  161. package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
  162. package/server/lib/session-knowledge/runtime.js +29 -6
  163. package/server/lib/session-knowledge/runtime.test.js +26 -1
  164. package/server/lib/source-control/audit-storage.js +1 -0
  165. package/server/lib/source-control/mutation-storage.js +3 -0
  166. package/server/lib/spaces/DOCUMENTATION.md +14 -9
  167. package/server/lib/spaces/code-out.js +13 -4
  168. package/server/lib/spaces/code-out.test.js +5 -3
  169. package/server/lib/spaces/dispatcher.js +12 -5
  170. package/server/lib/spaces/dispatcher.test.js +19 -1
  171. package/server/lib/spaces/gatekeeper-channel.js +8 -7
  172. package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
  173. package/server/lib/spaces/gatekeeper-program.cjs +38 -3
  174. package/server/lib/spaces/gatekeeper-program.test.js +20 -0
  175. package/server/lib/spaces/hardening.js +14 -1
  176. package/server/lib/spaces/hardening.test.js +5 -0
  177. package/server/lib/spaces/host-providers.js +165 -0
  178. package/server/lib/spaces/host-providers.test.js +100 -0
  179. package/server/lib/spaces/host.js +16 -4
  180. package/server/lib/spaces/journey.js +87 -17
  181. package/server/lib/spaces/journey.test.js +90 -2
  182. package/server/lib/spaces/layout.js +15 -5
  183. package/server/lib/spaces/places/docker-live-support.js +2 -0
  184. package/server/lib/spaces/places/docker.test.js +2 -0
  185. package/server/lib/spaces/places/fake-docker.js +3 -0
  186. package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
  187. package/server/lib/spaces/routes.js +9 -0
  188. package/server/lib/spaces/routes.test.js +4 -2
  189. package/server/lib/spaces/space-opencode.js +31 -14
  190. package/server/lib/spaces/space-opencode.test.js +15 -2
  191. package/server/lib/spaces/space-records.js +8 -0
  192. package/server/lib/spaces/space-records.test.js +7 -3
  193. package/server/lib/spaces/websocket.test.js +13 -1
  194. package/server/lib/ui-auth/ui-auth.js +28 -3
  195. package/server/lib/ui-auth/ui-auth.test.js +31 -0
  196. package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
  197. package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
  198. package/dist/assets/SettingsView-BolP_tuu.js +0 -30
  199. package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
  200. package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
  201. package/dist/assets/katex-rNcbfUj4.css +0 -1
  202. package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
  203. package/dist/assets/main-CVHM3_8W.js +0 -1048
  204. package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
  205. package/dist/assets/pl-Bj-Hy0X5.js +0 -20
  206. package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
  207. package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
  208. package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
  209. package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
  210. package/dist/assets/tr-qMRMBQ8r.js +0 -11
  211. package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
  212. package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
  213. package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
@@ -1,1048 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-HXttTpUw.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Bih1DxXi.js","assets/katex.min-DQ8qF6NR.js","assets/vendor-zod-CVhJ1Zpv.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DgOf1DP0.js","assets/katex-rNcbfUj4.css","assets/vendor-base-ui-CXFyogip.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.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-tanstack-react-virtual-CvuLsk7D.js","assets/vendor-tanstack-virtual-core-DPaNcJcT.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-dar6chwA.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DyL0aCoH.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-Cem6LjJ8.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-CIqXJolH.js","assets/vendor-codemirror-lang-json-C9rLLO0q.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-9qjxcVkg.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-D7VQUxeE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-Cikh4w2I.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-BYGweLoh.js","assets/vendor-codemirror-lang-python-DVl8-2Op.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.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-legendapp-list-BCBzRcfK.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-CIpvn8QG.js","assets/InProgressOperationBanner-DzGIwGH2.js","assets/changesTree-CePHbFcj.js","assets/PierreDiffViewer-DPa08AmN.js","assets/parseDiffFromFile-OHXXXyzL.js","assets/computeVirtualFileMetrics-CUof18z3.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-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.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/vendor-diff-C3JhlQdm.js","assets/isDiffPlainText-DSCjvV0m.js","assets/pierreDiffTint-DHf2xvyt.js","assets/Virtualizer-CnU8pYMb.js","assets/useInlineCommentController-AuUrVz9U.js","assets/appThemeRegistry-BUY7Ge9i.js","assets/textMateThemeFromAppTheme-DcAZmUlv.js","assets/useRootScrollLock-Cpk7NmBa.js","assets/moveWorkspacePath-CyZJ-2aD.js","assets/sessionOwnership-BZoGed9N.js","assets/WalkthroughView-r0Ho9F4Z.js","assets/patchFileDiff-BZrb6h2u.js","assets/useCallableModelProviders-BU_455MN.js","assets/DiffView-DaXjHTAq.js","assets/SubmoduleDiffSummary-CyMwDeoP.js","assets/FilesView-DMNYEydF.js","assets/flexokiTheme-BArobfXV.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-CKWqK1yR.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/fileContentPoller-BJWgy1fX.js","assets/JsonTreeView-D9rP8jM8.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-C7g4UPox.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/shikiHighlight-DJAESrna.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-ClJplEhR.js","assets/GuestSurfacePane-KzguENQG.js","assets/SettingsWindow-Cx6TrtY0.js","assets/SettingsView-BolP_tuu.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/restartOpenCode-DwBaMPJK.js","assets/CommandPalette-CtKzNzwW.js","assets/HelpDialog-9YZGhBgT.js","assets/ProjectActionsDialog-DATu0aBc.js","assets/OpenCodeStatusDialog-CXBWWRh8.js","assets/RunOverview-D6xy_vME.js","assets/ScheduledTasksDialog-BWXVnfrf.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/ArchiveView-CkeSWPcI.js","assets/UsageStatsView-D7WrDBTC.js","assets/SourceBoardView-yca1qvgB.js","assets/WorktreesView-C-t7uxq1.js","assets/SpacesView-DvoOh4sM.js","assets/SpaceRow-MXqvd-dr.js","assets/SpaceAccessDialog-CZ-u75py.js","assets/spaceNetwork-DHrhfbKM.js","assets/SpaceApplyDialog-BtuwtlaG.js","assets/space-apply-DWFLwXbI.js","assets/SpaceSetupOutput-Uo5LS7Jy.js","assets/OnboardingScreen-B5Zzb1Mp.js","assets/AboutDialog-MZbHWRua.js","assets/MemoryDebugPanel-Ct0h3RWh.js"])))=>i.map(i=>d[i]);
2
- import{f as Je,j as n,R as a,r as fs,c as Oa,h as vm}from"./vendor-react-BUCujlKS.js";import{u as de,cr as Hs,b as Vs,m as Pn,e as xs,cG as au,ae as Vo,_ as Gt,a0 as Uo,n as vt,aW as js,ao as cn,al as vo,am as xn,an as Sr,aE as wm,ar as lu,cH as km,b7 as Cs,cI as Ba,cJ as wo,cK as Go,cL as jm,cM as vr,cN as Gi,cO as qo,cP as tr,a5 as ko,l as Us,cQ as qn,aS as Cm,cR as Yo,cS as Pm,cT as Em,cU as yn,cV as Im,cW as cu,cX as Tm,cY as Dm,cx as du,cZ as Rm,q as Nm,t as Mm,bb as Am,a_ as Xo,a$ as Om,b1 as Bm,b2 as Fm,ag as Lm,ak as _m,af as Ws,v as jo,aP as Co,c_ as $m,aq as Fa,cq as La,bd as Po,aG as nn,bo as Zt,a4 as uu,ax as Zo,c$ as zm,d0 as Km,d1 as Wm,aH as fu,co as At,d2 as pu,cB as Hm,d3 as qi,d4 as Vm,bL as hu,bM as mu,$ as Um,bp as Gm,be as qm,bq as gu,cD as Vl,d5 as Ym,aZ as Xm,d6 as Ul,bA as bu,ap as yu,bg as Zm,d7 as Qm,d8 as Jm,aC as eg,aA as tg,d9 as sg,aI as ng,bf as rg,bD as og,da as ig,db as ag,dc as Gl,dd as Si,de as ql,df as Yl,dg as lg,at as Xl,dh as cg,di as dg,dj as ug,aB as fg,dk as pg,i as hg,a as mg}from"./katex.min-DQ8qF6NR.js";import{_ as ss}from"./vendor-vite-runtime-DD1OZmLC.js";import{bb as gg,bc as _a,a8 as bg,aj as xu,bd as yg,a3 as xg,a4 as Sg,a6 as Yi,g as vg,l as wg,h as kg,f as jg,j as Cg,k as Pg,m as Eg,Q as Ig,R as Tg,L as Dg,X as Rg,Y as Ng,U as Mg,H as Ag,x as Og,u as Bg,C as Fg,be as Yn,ar as Lg,bf as Su,bg as vu,bh as _g,bi as wu,bj as zn,bk as Zl,bl as Ql,bm as vi,bn as Jl,E as ku,B as Ar,F as ju,A as $a,a0 as $g,a1 as zg,ao as Kg,ap as Wg,_ as Hg,aG as Vg,aH as Cu,bo as Ug,aq as Gg,aZ as qg,S as ec,bp as Yg,aL as za,aK as Xg,bq as Xi,br as Zg,a9 as Qg,a7 as Pu,bs as On,bt as Eu,ai as Jg,bu as Iu,bv as eb,bw as tc,aa as tb,ab as sb,b as nb,a as rb,bx as ob,by as fr,af as ib,bz as ab,ag as sc,a2 as wr,ac as lb,a5 as cb,ah as db,a_ as nc,bA as ub,bB as fb,bC as pb,bD as hb,bE as mb,bF as gb,bG as rc,bH as bb,as as yb,aF as xb,aw as Sb,bI as vb,aC as wb,aD as kb,aJ as jb,bJ as Cb,bK as Pb,b3 as Eb,bL as Ib,aM as Tb,aI as Db,bM as Rb,au as Nb,bN as Mb,bO as Ab,ay as Ob,ax as Bb,az as Fb,aB as Lb,aA as _b,aE as $b,bP as zb,bQ as Kb}from"./runtimeEndpointReset-CIpvn8QG.js";import{u as Ct,jZ as Wb,I as Z,U as Bt,V as Ot,T as Ft,aB as cr,a3 as Jt,F as xt,ch as Tu,L as Te,cz as Ka,cA as Wa,cB as Ha,lm as Yr,G as Ps,J as sr,ei as Du,eh as Ru,bb as Zi,ln as Hb,lo as Nu,bc as Mu,dB as Au,aL as Is,aM as Ts,aN as Ds,b$ as wn,aO as qt,l as Zs,E as Qs,D as Js,Q as Qo,_ as nr,q as Gs,t as qs,z as ze,lp as Vb,lq as Ub,lr as oc,ls as ic,a2 as Ou,lt as Gb,lu as ac,lv as qb,lw as Bu,lx as Va,ly as Qi,bG as Fu,lz as Yb,lA as Xb,lB as Zb,gw as Lu,lC as Jo,lD as Qb,gn as Hn,aA as En,lE as Jb,go as ey,d5 as _u,lF as ty,d6 as sy,lG as $u,av as ei,lH as zu,lI as Ku,lJ as Wu,lK as Hu,lL as Vu,lM as Uu,im as dr,bf as Ua,da as Gu,o as kn,B as It,lN as qu,f7 as Ga,lO as Eo,n as Or,aP as vs,lP as ny,ah as Yu,ak as Xu,lQ as ry,lR as oy,bS as _s,iz as Zu,iy as Qu,eA as Sn,b_ as Ji,ij as iy,dS as ay,az as fn,lS as ly,lT as cy,cc as dy,cb as uy,fu as fy,f1 as py,fK as hy,ez as Ju,dT as an,e1 as my,ad as ds,e0 as ef,eC as ea,eB as Vn,eD as tf,lU as sf,lV as nf,lW as gy,lX as by,jW as yy,eF as qa,bR as xy,bP as Sy,bO as vy,bQ as wy,bJ as ky,y as Io,ct as lc,bV as jy,bX as cc,lY as Cy,lZ as Py,jX as Ey,cg as ti,d$ as Iy,e3 as Ya,eN as Ty,e2 as Dy,ay as vn,fB as rf,cy as Ry,l0 as Wn,ab as Ny,l_ as My,$ as ns,gq as of,l$ as Ay,bL as Oy,x as af,by as By,m0 as Fy,m1 as Ly,f6 as lf,m2 as Br,m3 as cf,m4 as ta,m5 as sa,m6 as wi,gc as Bn,gb as co,cl as _y,m7 as $y,m8 as Fr,c$ as Xa,m9 as Za,ma as zy,cC as jn,mb as Ky,a8 as Wy,bm as Hy,eP as Vy,bp as Uy,bl as Gy,fV as qy,fY as Yy,e6 as Xy,fZ as Zy,f5 as Qy,ga as Qa,gd as df,mc as si,ge as Ja,gf as el,cN as Jy,C as ex,aC as tx,md as ki,me as sx,mf as nx,mg as uf,mh as rx,mi as ff,hv as ox,mj as ix,mk as ax,ml as lx,mm as cx,ai as dx,mn as dc,mo as ux,mp as uc,mq as fc,gL as To,gk as tl,cM as pf,mr as fx,gJ as ni,gM as kr,ms as hf,le as us,il as mf,io as gf,g7 as bf,g8 as yf,g9 as xf,mt as px,mu as Sf,mv as hx,mw as vf,mx as na,bN as wf,my as sl,mz as mx,mA as gx,mB as bx,cK as kf,ll as Xt,mC as yx,kt as jf,mD as Cf,mE as Pf,mF as Ir,mG as pc,mH as xx,mI as Tr,mJ as Sx,mK as vx,mL as nl,mM as Do,mN as rl,mO as Ef,mP as If,mQ as Tf,mR as Df,aa as wx,mS as kx,gs as jx,gA as Cx,gE as ol,gN as Px,gB as Ex,gC as Ix,mT as Tx,ej as Dx,N as Rx,ek as Rf,kc as Nx,mU as Mx,mV as Ax,mW as Xn,mX as Ox,gt as Bx,mY as uo,dh as ri,gD as ra,mZ as Fx,gO as Lx,m_ as _x,m$ as Nf,O as Cn,gH as $x,n0 as zx,e8 as Kx,cn as Mf,n1 as Wx,n2 as Hx,n3 as hc,kr as Vx,n4 as Ux,a4 as Gx,gK as qx,ke as Yx,f2 as In,n5 as Xx,n6 as Zx,n7 as Qx,cX as Jx,n8 as eS,ds as mc,dr as gc,bI as bc,n9 as tS,na as sS,ck as nS,nb as rS,gv as yc,gx as ji,gy as oS,nc as iS,gz as aS,nd as lS,k as cS,ne as xc,nf as Ci,ng as Tn,nh as Kn,jR as Sc,ni as dS,nj as uS,jM as fS,nk as pS,nl as hS,nm as mS,er as oa,fR as gS,nn as Af,no as bS,cQ as yS,np as vc,nq as xS,cO as SS,dD as Of,nr as ia,W as Bf,dC as Ff,cL as Lf,ns as vS,nt as _f,c4 as fo,i2 as wS,gl as kS,i3 as jS,gp as CS,bZ as PS,la as wc,nu as ES,dd as IS,nv as TS,cZ as kc,de as DS,dg as RS,df as NS,dm as MS,dl as AS,h3 as OS,dk as BS,di as FS,dj as LS,a as _S,s as $S,b as zS,c as KS,ha as WS,dt as HS,du as VS,dv as US,dw as GS}from"./useAppFontEffects-Bih1DxXi.js";import{u as $f,S as qS,W as zf,f as Kf,a as YS,G as XS,b as ZS,c as QS}from"./useRootScrollLock-Cpk7NmBa.js";import{f as Lr,h as Fs,T as _r,M as $r,D as zr,j as Kr,i as Wf,d as JS,b as e1,k as t1}from"./vendor-dnd-kit-core-BZknOX2w.js";import{r as s1,h as n1,u as Wr,S as oi,s as Hf,a as il,v as al}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Hr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Vf,M as Uf,k as Gf,l as aa,m as la,n as ca,o as qf,p as r1,q as o1}from"./vendor-base-ui-CXFyogip.js";import{c as Vr,u as rr,p as i1}from"./vendor-zustand-BAGL70zf.js";import{r as Dr,a as ii,n as a1,s as Ls,o as da,b as jc}from"./vendor-zod-CVhJ1Zpv.js";import{D as l1,a as c1,m as Cc,G as d1}from"./moveWorkspacePath-CyZJ-2aD.js";import{c as u1}from"./sessionOwnership-BZoGed9N.js";import{u as f1}from"./vendor-tanstack-react-virtual-CvuLsk7D.js";import{m as p1,d as h1}from"./vendor-tanstack-virtual-core-DPaNcJcT.js";const m1=t=>{const e=Je.c(23),{directory:s,className:r,iconClassName:o}=t,{t:i}=Ct(),c=de(g1);let l;e[0]!==s?(l=Hs(s),e[0]=s,e[1]=l):l=e[1];const d=l;let u;e[2]!==d?(u=w=>Wb(d?w.journey?.get(d):void 0),e[2]=d,e[3]=u):u=e[3];const f=Vs(u);let p;e[4]!==d?(p=w=>d?w.actions.get(d)?.kind==="running":!1,e[4]=d,e[5]=p):p=e[5];const m=Vs(p);if(!c||!d||!f||Pn())return null;let g;e[6]!==i?(g=i("spaces.header.apply"),e[6]=i,e[7]=g):g=e[7];const b=g;let v;e[8]!==d?(v=()=>Vs.getState().openApplyDialog(d),e[8]=d,e[9]=v):v=e[9];let x;e[10]!==o?(x=n.jsx(Z,{name:"git-merge",className:o}),e[10]=o,e[11]=x):x=e[11];let y;e[12]!==m||e[13]!==r||e[14]!==b||e[15]!==v||e[16]!==x?(y=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":b,disabled:m,onClick:v,className:r,children:x})}),e[12]=m,e[13]=r,e[14]=b,e[15]=v,e[16]=x,e[17]=y):y=e[17];let h;e[18]!==b?(h=n.jsx(Ot,{side:"bottom",children:b}),e[18]=b,e[19]=h):h=e[19];let S;return e[20]!==y||e[21]!==h?(S=n.jsxs(Ft,{children:[y,h]}),e[20]=y,e[21]=h,e[22]=S):S=e[22],S};function g1(t){return t.isolatedSpacesEnabled}function b1(t){const e=Je.c(36),{directory:s,className:r}=t,{currentTheme:o}=cr(),i=Jt(S1),c=xt(x1),l=xs(y1);let d;e[0]!==s||e[1]!==l?(d=au(s,l),e[0]=s,e[1]=l,e[2]=d):d=e[2];const u=d;let f;e[3]!==s||e[4]!==u||e[5]!==i||e[6]!==c?(f=u||!s?null:Tu(i,c,s),e[3]=s,e[4]=u,e[5]=i,e[6]=c,e[7]=f):f=e[7];const p=f;if(u){let T;e[8]!==r?(T=Te("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),e[8]=r,e[9]=T):T=e[9];let O;return e[10]!==T?(O=n.jsx(Z,{name:"chat-4",className:T}),e[10]=T,e[11]=O):O=e[11],O}if(!p)return null;const m=p.icon?Ka[p.icon]:null;let g;e[12]!==p.color?(g=Wa(p.color)??void 0,e[12]=p.color,e[13]=g):g=e[13];const b=g;let v;e[14]!==r||e[15]!==b||e[16]!==m?(v=m?n.jsx(Z,{name:m,className:Te("h-3.5 w-3.5 shrink-0",r),style:b?{color:b}:void 0}):n.jsx(Z,{name:"folder",className:Te("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),style:b?{color:b}:void 0}),e[14]=r,e[15]=b,e[16]=m,e[17]=v):v=e[17];const x=v;if(!p.iconImage)return x;let y;e[18]!==r?(y=Te("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[18]=r,e[19]=y):y=e[19];let h;e[20]!==p.iconBackground?(h=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[20]=p.iconBackground,e[21]=h):h=e[21];let S;e[22]!==p.iconImage||e[23]!==p.id?(S={id:p.id,iconImage:p.iconImage},e[22]=p.iconImage,e[23]=p.id,e[24]=S):S=e[24];let w;e[25]!==o.colors.surface.foreground||e[26]!==o.metadata.variant?(w={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[25]=o.colors.surface.foreground,e[26]=o.metadata.variant,e[27]=w):w=e[27];let C;e[28]!==x||e[29]!==S||e[30]!==w?(C=n.jsx(Ha,{project:S,options:w,className:"h-full w-full object-contain",fallback:x}),e[28]=x,e[29]=S,e[30]=w,e[31]=C):C=e[31];let k;return e[32]!==y||e[33]!==h||e[34]!==C?(k=n.jsx("span",{className:y,style:h,children:C}),e[32]=y,e[33]=h,e[34]=C,e[35]=k):k=e[35],k}function y1(t){return t.homeDirectory}function x1(t){return t.availableWorktreesByProject}function S1(t){return t.projects}const xr=24,v1=(t,e,s=xr)=>{const r=e.right-(t.right-s);if(r>0)return r;const o=e.left-(t.left+s);return o<0?o:0},w1=({transform:t})=>({...t,y:0}),k1=16,j1=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*k1:t.deltaY;t.currentTarget.scrollLeft+=Vo(t.currentTarget)?-e:e},C1={Item:qt,Separator:wn},P1={Item:({className:t,...e})=>n.jsx(Uf,{className:Te(Mu,t),...e}),Separator:({className:t,...e})=>n.jsx(Vf,{className:Te(Nu,t),...e})},E1=t=>{const e=Je.c(63),{tab:s,isActive:r,suppressControls:o,onSelect:i,onClose:c,renderMenu:l,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:f}=t,{t:p}=Ct(),[m,g]=a.useState(!1),[b,v]=a.useState(!1),[x,y]=a.useState(!1);let h;e[0]!==s.id?(h={id:s.id},e[0]=s.id,e[1]=h):h=e[1];const{attributes:S,listeners:w,setNodeRef:C,transform:k,transition:T,isDragging:O}=Wr(h);let K;e[2]!==p||e[3]!==s.session.title?(K=s.session.title?.trim()||p("sessions.sidebar.session.untitled"),e[2]=p,e[3]=s.session.title,e[4]=K):K=e[4];const R=K,I=!o&&(m||b),N=s.id;let W;e[5]!==s.session?(W=sr(s.session),e[5]=s.session,e[6]=W):W=e[6];const z=_a(N,W),H=Du(s.id),M=H!==null,j=Ru(s.id)>0&&!r&&!M,P=M||j;let D;e[7]!==d||e[8]!==x||e[9]!==r||e[10]!==m||e[11]!==i||e[12]!==s?(D=ie=>({session:s.session,open:m||x,isActive:r,select:()=>i(s),closeOtherTabs:()=>d(s.id),components:ie}),e[7]=d,e[8]=x,e[9]=r,e[10]=m,e[11]=i,e[12]=s,e[13]=D):D=e[13];const V=D;let B;e[14]!==k?(B=Hr.Translate.toString(k),e[14]=k,e[15]=B):B=e[15];let _;e[16]!==B||e[17]!==T?(_={transform:B,transition:T},e[16]=B,e[17]=T,e[18]=_):_=e[18];const F=O&&"z-10 opacity-60";let X;e[19]!==F?(X=Te("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",F),e[19]=F,e[20]=X):X=e[20];const oe=r?"true":"false";let ne;e[21]!==r?(ne=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=ne):ne=e[22];let A;e[23]!==u?(A=ie=>u?.(ie),e[23]=u,e[24]=A):A=e[24];let te;e[25]!==f||e[26]!==r||e[27]!==z||e[28]!==V||e[29]!==m||e[30]!==c||e[31]!==u||e[32]!==i||e[33]!==I||e[34]!==l||e[35]!==P||e[36]!==o||e[37]!==p||e[38]!==s||e[39]!==R||e[40]!==H?(te=n.jsx(Gf,{render:ie=>n.jsxs("div",{...ie,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>i(s),onKeyDown:r?void 0:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),i(s))},onAuxClick:q=>{q.button===1&&(q.preventDefault(),c(s.id))},"data-controls-open":I?"true":"false",className:Te("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 text-interactive-selection-foreground":Te("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",I&&"bg-interactive-hover text-foreground")),children:[n.jsxs("div",{className:Te("flex min-w-0 flex-1 items-center",!o&&"group-hover/session-tab:pe-10",I&&"pe-10"),children:[n.jsx(b1,{directory:sr(s.session),className:"me-1.5"}),n.jsx("div",{className:Te("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!o&&"session-tab-title"),children:r?f:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4",children:R})})}),z?n.jsx(Z,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":p("sessions.aiRename.generating")}):P?n.jsx(Au,{state:H??"unread",className:Te("ms-1.5 shrink-0",!o&&"group-hover/session-tab:opacity-0",I&&"opacity-0")}):null]}),o?null:n.jsxs("div",{onClick:T1,onPointerDown:D1,className:Te("absolute inset-e-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",I&&"flex opacity-100"),children:[n.jsxs(Is,{open:m,onOpenChange:q=>{g(q),q&&v(!0)},onOpenChangeComplete:q=>{q||v(!1),u?.(q)},children:[n.jsx(Ts,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":p("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"more",className:"size-4"})})}),n.jsx(Ds,{align:"start",className:"min-w-[190px]",children:l(V(C1))})]}),n.jsx("button",{type:"button","aria-label":p("header.sessionTabs.closeTab"),onClick:()=>c(s.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]})]})}),e[25]=f,e[26]=r,e[27]=z,e[28]=V,e[29]=m,e[30]=c,e[31]=u,e[32]=i,e[33]=I,e[34]=l,e[35]=P,e[36]=o,e[37]=p,e[38]=s,e[39]=R,e[40]=H,e[41]=te):te=e[41];let U,Pe;e[42]===Symbol.for("react.memo_cache_sentinel")?(U={color:"var(--surface-elevated-foreground)"},Pe=Te(Zi,"min-w-[190px]"),e[42]=U,e[43]=Pe):(U=e[42],Pe=e[43]);let xe;e[44]!==V||e[45]!==l?(xe=l(V(P1)),e[44]=V,e[45]=l,e[46]=xe):xe=e[46];let ce;e[47]!==xe?(ce=n.jsx(aa,{children:n.jsx(la,{className:"app-region-no-drag z-50",children:n.jsx(ca,{"data-slot":"dropdown-menu-content",style:U,className:Pe,children:xe})})}),e[47]=xe,e[48]=ce):ce=e[48];let Oe;e[49]!==x||e[50]!==A||e[51]!==te||e[52]!==ce?(Oe=n.jsxs(qf,{open:x,onOpenChange:y,onOpenChangeComplete:A,children:[te,ce]}),e[49]=x,e[50]=A,e[51]=te,e[52]=ce,e[53]=Oe):Oe=e[53];let me;return e[54]!==S||e[55]!==w||e[56]!==C||e[57]!==oe||e[58]!==ne||e[59]!==Oe||e[60]!==_||e[61]!==X?(me=n.jsx("div",{ref:C,style:_,className:X,"data-active":oe,...ne,...S,...w,children:Oe}),e[54]=S,e[55]=w,e[56]=C,e[57]=oe,e[58]=ne,e[59]=Oe,e[60]=_,e[61]=X,e[62]=me):me=e[62],me},I1=t=>{const e=Je.c(66),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,c=o===void 0?!1:o,{t:l,direction:d}=Ct(),u=d==="rtl",f=Yr(R1),p=Yr(N1),m=Yr(M1),g=Yr(A1),b=xt(O1),v=xt(B1),x=Ps(F1),y=gg(b);let h,S;e[0]!==y||e[1]!==b||e[2]!==p?(h=()=>{b&&p(b,y)},S=[b,y,p],e[0]=y,e[1]=b,e[2]=p,e[3]=h,e[4]=S):(h=e[3],S=e[4]),a.useEffect(h,S);let w;if(e[5]!==x){w=new Map;for(const G of x)w.set(G.id,G);e[5]=x,e[6]=w}else w=e[6];const C=w;let k;if(e[7]!==C||e[8]!==f){k=[];for(const G of f){const se=C.get(G);se&&k.push({id:G,session:se})}e[7]=C,e[8]=f,e[9]=k}else k=e[9];const T=k;let O;e[10]!==v?(O=G=>{v(G.id,sr(G.session))},e[10]=v,e[11]=O):O=e[11];const K=O,R=L1;let I;e[12]!==m||e[13]!==b||e[14]!==K||e[15]!==T?(I=G=>{if(m(G),b&&b!==G){const se=T.find(je=>je.id===G);se&&K(se)}},e[12]=m,e[13]=b,e[14]=K,e[15]=T,e[16]=I):I=e[16];const N=I;let W;e[17]===Symbol.for("react.memo_cache_sentinel")?(W={activationConstraint:{distance:8}},e[17]=W):W=e[17];let z;e[18]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{delay:200,tolerance:6}},e[18]=z):z=e[18];const H=Lr(Fs($r,W),Fs(_r,z));let M;e[19]!==g?(M=G=>{const{active:se,over:je}=G;je&&se.id!==je.id&&g(String(se.id),String(je.id))},e[19]=g,e[20]=M):M=e[20];const Y=M,j=a.useRef(null);let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P={left:!1,right:!1},e[21]=P):P=e[21];const[D,V]=a.useState(P);let B;e[22]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{const G=j.current;if(!G)return;const se=G.scrollWidth-G.clientWidth,je=Vo(G)?se+G.scrollLeft:G.scrollLeft,he=je>2,ge=je<se-2;V(ke=>ke.left===he&&ke.right===ge?ke:{left:he,right:ge})},e[22]=B):B=e[22];const _=B;let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{_();const G=j.current;if(!G||!globalThis.ResizeObserver)return;const se=new ResizeObserver(_);return se.observe(G),()=>se.disconnect()},e[23]=F):F=e[23];let X;e[24]!==T.length?(X=[_,T.length],e[24]=T.length,e[25]=X):X=e[25],a.useEffect(F,X);let oe;e[26]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>{const G=j.current,se=G?.querySelector("[data-active-session-tab]");if(!G||!se)return;const je=v1(G.getBoundingClientRect(),se.getBoundingClientRect());je!==0&&(G.scrollLeft=G.scrollLeft+je,_())},e[26]=oe):oe=e[26];let ne;e[27]!==b?(ne=[b,_],e[27]=b,e[28]=ne):ne=e[28],a.useEffect(oe,ne);const A=D.left&&D.right?`linear-gradient(to right, transparent, black ${xr}px, black calc(100% - ${xr}px), transparent)`:D.left?`linear-gradient(to right, transparent, black ${xr}px)`:D.right?`linear-gradient(to right, black calc(100% - ${xr}px), transparent)`:void 0;let te;e[29]!==T?(te=T.map(_1),e[29]=T,e[30]=te):te=e[30];const U=te;let Pe;e[31]!==b||e[32]!==T?(Pe=!!b&&!T.some(G=>G.id===b),e[31]=b,e[32]=T,e[33]=Pe):Pe=e[33];const xe=Pe;let ce;e[34]!==l?(ce=l("header.sessionTabs.stripAria"),e[34]=l,e[35]=ce):ce=e[35];let Oe;e[36]!==A?(Oe=A?{maskImage:A,WebkitMaskImage:A}:void 0,e[36]=A,e[37]=Oe):Oe=e[37];let me;e[38]===Symbol.for("react.memo_cache_sentinel")?(me=[w1],e[38]=me):me=e[38];const ie=u?s1:n1;let q;e[39]!==i||e[40]!==b||e[41]!==N||e[42]!==K||e[43]!==r||e[44]!==s||e[45]!==c||e[46]!==T?(q=T.map(G=>n.jsx(E1,{tab:G,isActive:G.id===b,suppressControls:G.id===b&&c,onSelect:K,onClose:R,renderMenu:s,closeOtherTabs:N,onMenuOpenChangeComplete:r,children:G.id===b?i:null},G.id)),e[39]=i,e[40]=b,e[41]=N,e[42]=K,e[43]=r,e[44]=s,e[45]=c,e[46]=T,e[47]=q):q=e[47];let ue;e[48]!==ie||e[49]!==q||e[50]!==U?(ue=n.jsx(oi,{items:U,strategy:ie,children:q}),e[48]=ie,e[49]=q,e[50]=U,e[51]=ue):ue=e[51];let ve;e[52]!==Y||e[53]!==H||e[54]!==ue?(ve=n.jsx(zr,{sensors:H,collisionDetection:Kr,modifiers:me,onDragEnd:Y,children:ue}),e[52]=Y,e[53]=H,e[54]=ue,e[55]=ve):ve=e[55];let Ee;e[56]!==i||e[57]!==xe?(Ee=xe?n.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:n.jsx("div",{className:"min-w-0 flex-1",children:i})}):null,e[56]=i,e[57]=xe,e[58]=Ee):Ee=e[58];let L;e[59]!==Oe||e[60]!==ve||e[61]!==Ee?(L=n.jsxs("div",{ref:j,onScroll:_,onWheel:j1,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Oe,children:[ve,Ee]}),e[59]=Oe,e[60]=ve,e[61]=Ee,e[62]=L):L=e[62];let le;return e[63]!==ce||e[64]!==L?(le=n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ce,children:L}),e[63]=ce,e[64]=L,e[65]=le):le=e[65],le};function T1(t){return t.stopPropagation()}function D1(t){return t.stopPropagation()}function R1(t){return t.tabIds}function N1(t){return t.ensureTab}function M1(t){return t.closeOtherTabs}function A1(t){return t.reorderTabs}function O1(t){return t.currentSessionId}function B1(t){return t.setCurrentSession}function F1(t){return t.activeSessions}function L1(t){Hb(t)}function _1(t){return t.id}const $1=500;function Qt(t){const e=Je.c(9),{hint:s,children:r}=t,[o,i]=a.useState(!1);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(f,p)=>{f&&p.reason==="trigger-focus"||i(f)},e[0]=c):c=e[0];let l;e[1]!==r?(l=n.jsx(Bt,{asChild:!0,children:r}),e[1]=r,e[2]=l):l=e[2];let d;e[3]!==s?(d=n.jsx(Ot,{side:"right",sideOffset:8,className:"max-w-64",children:s}),e[3]=s,e[4]=d):d=e[4];let u;return e[5]!==o||e[6]!==l||e[7]!==d?(u=n.jsxs(Ft,{delayDuration:$1,open:o,onOpenChange:c,children:[l,d]}),e[5]=o,e[6]=l,e[7]=d,e[8]=u):u=e[8],u}const z1=t=>{const e=Je.c(29),{open:s,onOpenChange:r,onPick:o}=t,{t:i}=Ct(),c=Jt(K1),l=xs(W1);let d;e[0]!==i?(d=i("sessions.moveChatToProject.title"),e[0]=i,e[1]=d):d=e[1];let u;e[2]!==d?(u=n.jsx(Zs,{children:d}),e[2]=d,e[3]=u):u=e[3];let f;e[4]!==i?(f=i("sessions.moveChatToProject.description"),e[4]=i,e[5]=f):f=e[5];let p;e[6]!==f?(p=n.jsx(Qs,{children:f}),e[6]=f,e[7]=p):p=e[7];let m;e[8]!==u||e[9]!==p?(m=n.jsxs(Js,{children:[u,p]}),e[8]=u,e[9]=p,e[10]=m):m=e[10];let g;if(e[11]!==l||e[12]!==r||e[13]!==o||e[14]!==c){let y;e[16]!==l||e[17]!==r||e[18]!==o?(y=h=>n.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-start hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] focus-visible:outline-none",onClick:()=>{r(!1),o(h.path)},children:[n.jsx(Z,{name:"folder",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:h.label?.trim()||Qo(h.path)}),n.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:nr(h.path,l)})]},h.id),e[16]=l,e[17]=r,e[18]=o,e[19]=y):y=e[19],g=c.map(y),e[11]=l,e[12]=r,e[13]=o,e[14]=c,e[15]=g}else g=e[15];let b;e[20]!==g?(b=n.jsx("div",{className:"flex max-h-[50vh] flex-col gap-0.5 overflow-y-auto",children:g}),e[20]=g,e[21]=b):b=e[21];let v;e[22]!==m||e[23]!==b?(v=n.jsxs(Gs,{className:"max-w-md",children:[m,b]}),e[22]=m,e[23]=b,e[24]=v):v=e[24];let x;return e[25]!==r||e[26]!==s||e[27]!==v?(x=n.jsx(qs,{open:s,onOpenChange:r,children:v}),e[25]=r,e[26]=s,e[27]=v,e[28]=x):x=e[28],x};function K1(t){return t.projects}function W1(t){return t.homeDirectory}function Pc(t){const e=Je.c(28),{sessionId:s,onArchive:r,Item:o}=t,{t:i}=Ct();let c;e[0]!==s?(c=k=>!!k.entityById.get(s)?.time.archived,e[0]=s,e[1]=c):c=e[1];const l=Ps(c);let d;e[2]!==s?(d=k=>!!k.entityById.get(s)?.parentID,e[2]=s,e[3]=d):d=e[3];const u=Ps(d),f=xt(H1);let p;e[4]!==s||e[5]!==i||e[6]!==f?(p=async()=>{await f(s)?ze.success(i("sessions.sidebar.session.restore.success")):ze.error(i("sessions.sidebar.session.restore.error"))},e[4]=s,e[5]=i,e[6]=f,e[7]=p):p=e[7];const m=p;if(l&&u)return null;const g=l?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let b;e[8]!==i||e[9]!==g?(b=i(g),e[8]=i,e[9]=g,e[10]=b):b=e[10];let v;e[11]!==l||e[12]!==r||e[13]!==m?(v=l?()=>{m()}:r,e[11]=l,e[12]=r,e[13]=m,e[14]=v):v=e[14];const x=l?"inbox-unarchive":"inbox-archive";let y;e[15]!==x?(y=n.jsx(Z,{name:x,className:"me-1 size-4"}),e[15]=x,e[16]=y):y=e[16];const h=l?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let S;e[17]!==i||e[18]!==h?(S=i(h),e[17]=i,e[18]=h,e[19]=S):S=e[19];let w;e[20]!==o||e[21]!==S||e[22]!==v||e[23]!==y?(w=n.jsxs(o,{onClick:v,children:[y,S]}),e[20]=o,e[21]=S,e[22]=v,e[23]=y,e[24]=w):w=e[24];let C;return e[25]!==w||e[26]!==b?(C=n.jsx(Qt,{hint:b,children:w}),e[25]=w,e[26]=b,e[27]=C):C=e[27],C}function H1(t){return t.unarchiveSession}const Yf=async t=>{const{entry:e,session:s}=t,r=Gt(),o={sessionId:s.id,sessionTitle:s.title,directory:s.directory};if(!(Vb(e.action)&&Ub(e.guest,"conversation"))){await oc(e,ic(e.action.id,o),t.t,r);return}let c=!1;const l=Uo(()=>{c=!0});let d;try{d=await t.loadRecords()}finally{l()}if(!c){if(!d){t.onLoadFailed();return}await oc(e,ic(e.action.id,o,d),t.t,r)}};function ua(t){const e=Je.c(14),{sessionID:s,directory:r,open:o,Item:i}=t,{t:c}=Ct(),{pending:l,disabled:d,hint:u,run:f}=bg(s,r,o),p=l?"loader-4":"ai-generate-2",m=l?"me-1 size-4 animate-spin":"me-1 size-[15px]";let g;e[0]!==p||e[1]!==m?(g=n.jsx(Z,{name:p,className:m}),e[0]=p,e[1]=m,e[2]=g):g=e[2];let b;e[3]!==c?(b=c("sessions.aiRename.action"),e[3]=c,e[4]=b):b=e[4];let v;e[5]!==i||e[6]!==d||e[7]!==f||e[8]!==g||e[9]!==b?(v=n.jsx("span",{className:"block",children:n.jsxs(i,{disabled:d,onClick:f,className:"w-full",children:[g,b]})}),e[5]=i,e[6]=d,e[7]=f,e[8]=g,e[9]=b,e[10]=v):v=e[10];let x;return e[11]!==u||e[12]!==v?(x=n.jsx(Qt,{hint:u,children:v}),e[11]=u,e[12]=v,e[13]=x):x=e[13],x}const Ro=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class Xf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const ai=Vr(()=>({pendingSessionIds:new Set})),Zf=t=>{const e=Je.c(2);let s;return e[0]!==t?(s=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=s):s=e[1],ai(s)},Ec=(t,e)=>{ai.setState(s=>{if(s.pendingSessionIds.has(t)===e)return s;const r=new Set(s.pendingSessionIds);return e?r.add(t):r.delete(t),{...s,pendingSessionIds:r}})},V1=async(t,e)=>{try{const d=(await Zb(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const s=vt(t),r=vt(e)??e,o=xt.getState().availableWorktreesByProject,c=(o.get(r)??o.get(e)??[]).find(l=>vt(l.path)===s)?.branch?.trim();if(c)return c;throw new Error("Unable to determine the current branch")},Ic=t=>{for(const e of t){const s=qb(e.id);if(s==="unknown")throw new Error("Session status is unavailable");if(s==="active")throw new Error("Session is not idle")}};class U1 extends Error{constructor(e,s){super(e,{cause:s}),this.name="IncompleteRollbackError"}}const G1=(t,e)=>{const s=e.map(({sessionId:r,error:o})=>`${r}: ${o.message}`).join(", ");return new U1(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${s}`,{moveError:t,rollbackFailures:e})},q1=async(t,e,s,r)=>{const o=[];for(const i of[...t].reverse()){if(Bu(i.id)){o.push({sessionId:i.id,error:new Error("Session is not idle")});continue}try{await Ou(i,s,e),xt.getState().setWorktreeMetadata(i.id,r.get(i.id)??null)}catch(c){o.push({sessionId:i.id,error:c instanceof Error?c:new Error(String(c))})}}return o},Tc=async(t,e,s)=>{try{await Lu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${s.message}`)}throw s},Dc=async(t,e)=>{const s=e?[t,e]:[t];try{await Va(s)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},ll=async(t,e)=>{if(ai.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Ec(t.root.id,!0);try{const s=[...t.descendants,t.root],r=new Map(s.map(l=>[l.id,xt.getState().getWorktreeMetadata(l.id)]));Ic(s);let o=null;const i=[];let c=!1;try{o=await e();for(const[l,d]of s.entries()){Ic(s.slice(l));try{await Ou(d,t.sourceDirectory,o.directory)}catch(u){throw Gb(u)&&(c=!0),u}i.push(d),d.id!==t.root.id&&xt.getState().setWorktreeMetadata(d.id,o.metadata?ac(o.metadata):null)}}catch(l){const d=l instanceof Error?l:new Error(String(l)),u=await q1(i,t.sourceDirectory,o?.directory??t.sourceDirectory,r);if(c&&await Dc(t.sourceDirectory,o?.directory),u.length>0)throw G1(d,u);if(o?.onMoveFailure&&!c)return o.onMoveFailure(d);throw o?.onMoveFailure&&c?new Xf(d):d}return xt.getState().setWorktreeMetadata(t.root.id,o.metadata?ac(o.metadata):null),await Dc(t.sourceDirectory,o.directory),o.directory}finally{Ec(t.root.id,!1)}},Y1=async t=>{const e=vt(t.sourceDirectory)??t.sourceDirectory,s=vt(t.destination.path)??t.destination.path;if(e===s)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return ll(t,async()=>({directory:t.destination.path,metadata:t.destination}))},X1=async t=>{if((vt(t.sourceDirectory)??t.sourceDirectory)===(vt(t.projectDirectory)??t.projectDirectory))throw new Error("Source and destination are the same");return ll(t,async()=>({directory:t.projectDirectory,metadata:null}))},Z1=async t=>ll(t,async()=>{const e=Qi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const s=await Fu(t.sourceDirectory)?await V1(t.sourceDirectory,e.path):null,r=await Yb(e,s?{startRef:s}:{});try{await Xb(r.path)}catch(o){const i=o instanceof Error?o:new Error(String(o));return Tc(e,r,i)}return{directory:r.path,metadata:r,onMoveFailure:async o=>Tc(e,r,o)}}),Q1=t=>{(t.kind==="existing"?Y1({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):t.kind==="project"?X1({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,projectDirectory:t.projectDirectory}):Z1({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>ze.success(t.messages.success)).catch(s=>{const r=s instanceof Error?s:new Error(String(s));ze.error(t.messages.failure,{description:r instanceof Xf?t.messages.outcomeUnknown:r.message})})},No=t=>{ai.getState().pendingSessionIds.has(t.root.id)||Q1(t)},Pi="--oc-titlebar-controls-width",fa=new Set;let jr=null;const Qf=t=>{jr===null?t.style.removeProperty(Pi):t.style.getPropertyValue(Pi)!==jr&&t.style.setProperty(Pi,jr)},J1=t=>{const e=`${Math.round(t)}px`;e!==jr&&(jr=e,fa.forEach(Qf))},Jf=t=>{if(t)return fa.add(t),Qf(t),()=>{fa.delete(t)}},pr="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground data-[popup-open]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 transition-colors",Dn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ev=()=>{js("ui.header.render");const{t,direction:e}=Ct(),s=de(re=>re.isSidebarOpen),r=Jo(),o=de(re=>re.sessionTabsEnabled),i=xt(re=>!!re.newSessionDraft?.open),c=xt(re=>re.currentSessionId),l=Qb(c??""),d=Zf(c??""),u=Ps(rr(a.useCallback(re=>{if(!c)return null;const Ze=[...re.activeSessions,...re.archivedSessions].find(ae=>ae.id===c);if(!Ze)return null;const Qe=Ze;return{title:Ze.title??null,directory:Qe.directory??null,created:Ze.time?.created??null,slug:Qe.slug??null,parentId:Ze.parentID??null}},[c]))),f=Jt(rr(re=>{if(!re.activeProjectId)return null;const Ze=re.projects.find(Qe=>Qe.id===re.activeProjectId);return Ze?{id:Ze.id,path:Ze.path,label:Ze.label}:null})),p=a.useMemo(()=>{if(!f)return null;const re=f.label?.trim();if(re)return re;const Ze=f.path.split(/[\\/]/).filter(Boolean);return Ze[Ze.length-1]??null},[f]),m=Hn(re=>re.loadSettings),{isMobile:g}=En(),b=a.useRef(null),[v,x]=a.useState(()=>typeof window>"u"?!1:cn()),y=a.useMemo(()=>vo(),[]),h=Jb(),[S,w]=a.useState(!1),C=a.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:k,side:T}=$f(),O=a.useMemo(()=>{if(typeof window>"u")return null;const re=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof re=="number"&&Number.isFinite(re)&&re>0)return re;if(typeof navigator>"u")return null;const Ze=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ze)return null;const Qe=Number.parseInt(Ze[1],10),ae=Number.parseInt(Ze[2],10);return Number.isNaN(Qe)?null:Qe===10?ae:Qe},[]);fs.useEffect(()=>{typeof window>"u"||x(cn())},[]);const K=a.useMemo(()=>Pn(),[]),R=de(re=>re.workStatusPanelVisible),I=de(re=>re.workStatusPanelEnabled),N=de(re=>re.setWorkStatusPanelEnabled),W=de(re=>re.workStatusPanelFits),z=de(re=>re.workStatusOverlayOpen),H=de(re=>re.setWorkStatusOverlayOpen),Y=I&&W||z,j=a.useCallback(()=>{if(I&&!W){H(!z);return}N(!I)},[H,N,z,I,W]);ey(),a.useEffect(()=>{m()},[m]);const P=c?u??null:null,D=a.useRef(null),[V,B]=a.useState(0);a.useEffect(()=>{if(!c){D.current&&(D.current=null,B(ae=>ae+1));return}if(P){D.current={sessionId:c,session:P,expiresAt:Date.now()+2e3};return}const re=D.current;if(!re||re.sessionId!==c)return;const Ze=re.expiresAt-Date.now();if(Ze<=0){D.current=null,B(ae=>ae+1);return}const Qe=window.setTimeout(()=>{D.current?.sessionId===c&&(D.current=null),B(ae=>ae+1)},Ze);return()=>{window.clearTimeout(Qe)}},[c,P]);const _=(()=>{if(P)return P;if(!c)return null;const re=D.current;return re&&re.sessionId===c&&re.expiresAt>Date.now()?re.session:null})(),F=xt(re=>c?re.worktreeMetadata.get(c)?.path??"":""),X=xt(re=>c?re.worktreeMetadata.get(c)?.branch?.trim()??null:null),oe=_u(re=>c?re.getAttachment(c):void 0),ne=a.useMemo(()=>oe?ty(oe,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,oe]),A=a.useMemo(()=>oe?oe.legacy?"legacy":oe.degraded?"degraded":oe.worktreeStatus==="pending"?"pending":oe.worktreeStatus==="missing"?"missing":oe.worktreeStatus==="invalid"?"invalid":oe.attentionReason?"attention":null:null,[oe]),te=a.useMemo(()=>Dn(F||""),[F]),U=a.useMemo(()=>{const re=typeof _?.directory=="string"?_.directory:"";return Dn(re||"")},[_?.directory]),Pe=_a(c??"",U),xe=xt(re=>re.newSessionDraft?.open?Dn(re.newSessionDraft.bootstrapPendingDirectory??re.newSessionDraft.directoryOverride??""):""),ce=xt(re=>re.newSessionDraft.target),Oe=xt(re=>re.newSessionDraft.selectedProjectId),me=xt(re=>re.currentSessionDirectory),ie=xs(re=>re.homeDirectory),q=a.useMemo(()=>te||U||xe,[xe,U,te]),ue=xt(re=>{const Ze=Dn(te||U||"");if(!Ze)return null;for(const Qe of re.availableWorktreesByProject.values()){const He=Qe.find(ut=>Dn(ut.path)===Ze)?.branch?.trim();if(He)return He}return null}),Ee=sy(q||null)||X||ue,L=i?ce==="chat":au(U||me,ie),le=!L&&!R&&!!(p||Ee||!i&&A),G=a.useMemo(()=>{if(!c)return p??"OpenChamber";const re=_?.title?.trim();return re&&re.length>0?re:"Untitled Session"},[p,_?.title,c]),se=$u(),je=xt(re=>re.updateSessionTitle),he=xt(re=>re.archiveSessions),ge=xt(re=>re.deleteSessions),[ke,Ae]=a.useState(!1),[$,fe]=a.useState(!1),be=a.useRef(null),[Ie,Ye]=a.useState(""),[nt,Ue]=a.useState(!1),Ve=Jt(re=>re.projects.length>0),[Se,ye]=a.useState(null),Ge=a.useRef(null),qe=a.useCallback(()=>{c&&(Ye(_?.title?.trim()||G),Ae(!0))},[_?.title,c,G]),ft=a.useRef(qe);ft.current=qe;const et=a.useCallback(re=>{re&&(re.focus(),re.select())},[]);a.useEffect(()=>{if(fe(!1),ye(null),c&&be.current===c){be.current=null,ft.current();return}Ae(!1),Ye("")},[c]);const St=a.useCallback(async()=>{if(!c)return;const re=Ie.trim();re&&re!==_?.title?.trim()&&await je(c,re),Ae(!1)},[_?.title,c,Ie,je]);a.useEffect(()=>{if(!ke)return;const re=Ze=>{const Qe=Ze.target;(!Qe||!Ge.current?.contains(Qe))&&St()};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[ke,St]);const we=a.useCallback(re=>{re&&ei(re).then(Ze=>{ze[Ze.ok?"success":"error"](t(Ze.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(t("sessions.sidebar.session.copyId.error")))},[t]),De=a.useCallback(async()=>{if(!c||!q){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const re=await se({sessionID:c,directory:q}).catch(()=>null);if(!re){ze.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(re.length===0){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ze=zu(re,_?.title??null),Qe=Ku(_?.title??null);await Wu(Ze,Qe)||Hu(Ze,Qe),ze.success(t("sessions.sidebar.session.export.success"))},[_?.title,c,se,q,t]),ot=Vu(),rt=a.useMemo(()=>Uu(ot),[ot]),Xe=a.useCallback(re=>{c&&Yf({entry:re,t,session:{id:c,title:_?.title,directory:U??q},loadRecords:async()=>{if(!q)return null;try{return await se({sessionID:c,directory:q})}catch{return null}},onLoadFailed:()=>ze.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[_?.title,c,se,q,U,t]),ht=a.useCallback(re=>rt.map(Ze=>n.jsxs(re,{onClick:()=>Xe(Ze),children:[n.jsx(dr,{icon:Ze.icon,iconSrc:Ze.iconSrc,className:"me-1 size-4"}),Ze.action.label]},`${Ze.guest.id}:${Ze.action.id}`)),[rt,Xe]),ee=l?.type==="busy"||l?.type==="retry",_e=a.useCallback(()=>{if(!c||!U||ee||d)return;const re=Ps.getState().activeSessions,Ze=re.find(He=>He.id===c);if(!Ze)return;const Qe=[],ae=[c];for(let He=0;He<ae.length;He+=1){const ut=ae[He];for(const gt of re)gt.parentID===ut&&(Qe.push(gt),ae.push(gt.id))}No({kind:"quick",root:Ze,descendants:Qe,sourceDirectory:U,messages:Ro(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[c,ee,d,U,t]),Be=a.useCallback(re=>{if(!c||!U||ee||d)return;const Ze=Ps.getState().activeSessions,Qe=Ze.find(ut=>ut.id===c);if(!Qe)return;const ae=[],He=[c];for(let ut=0;ut<He.length;ut+=1)for(const gt of Ze)gt.parentID===He[ut]&&(ae.push(gt),He.push(gt.id));No({kind:"project",root:Qe,descendants:ae,sourceDirectory:U,projectDirectory:re,messages:Ro(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[c,ee,d,U,t]),Ke=a.useCallback(async(re,Ze)=>{const Qe=[Ze,...xu(Ze,[],re==="delete")],ae=xt.getState().currentSessionId===Ze?Ze:null;if(re==="delete"){const{failedIds:gt}=await ge(Qe);gt.length>0?ze.error(t("sessions.sidebar.session.delete.error")):ze.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:He,failedIds:ut}=await he(Qe);if(ut.length>0){ze.error(t("sessions.sidebar.session.archive.error"));return}ze.success(t("sessions.sidebar.session.archive.success"),yg(He,ae,t))},[he,ge,t]),Fe=a.useCallback(async()=>{if(!Se)return;const{action:re,sessionId:Ze}=Se;ye(null),await Ke(re,Ze)},[Se,Ke]),tt=de(re=>re.openGuestPageId),bt=Ua(re=>re.guests.find(Ze=>Ze.id===tt)),mt=de(re=>re.isScheduledTasksDialogOpen),it=de(re=>re.isArchivePageOpen),Tt=de(re=>re.isUsageStatsPageOpen),at=de(re=>re.isSourceBoardOpen),$t=de(re=>re.worktreesPageProjectId),zt=de(re=>re.isolatedSpacesEnabled?re.spacesPageProjectId:null),Mt=de(re=>re.runOverviewKey),Re=xg(Mt),ct=$t??zt,lt=Jt(re=>{if(!ct)return null;const Ze=re.projects.find(Qe=>Qe.id===ct);return Ze?.label?.trim()||Ze?.path?.split("/").pop()||null}),dt=a.useMemo(()=>bt?{title:bt.pageTitle??bt.name,subtitle:null}:mt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:it?{title:t("sessions.archivePage.title"),subtitle:null}:Tt?{title:t("usageStats.title"),subtitle:null}:at?{title:t("sourceBoard.title"),subtitle:null}:$t?{title:t("sessions.worktreesPage.title",{project:lt??""}),subtitle:null}:zt?{title:t("spaces.page.title",{project:lt??""}),subtitle:null}:Mt?{title:Re??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[bt,it,Re,Mt,mt,at,Tt,zt,lt,t,$t]),st=U||Dn(me||"")||te,wt=a.useCallback(()=>{xn("desktop_open_draft_mini_chat_window",{directory:L?"":xe,projectId:L?null:Oe,...Sr()}).catch(re=>{console.warn("[header] failed to open draft mini chat window",re)})},[xe,Oe,L]),pt=a.useCallback(()=>{if(i){wt();return}c&&xn("desktop_open_session_mini_chat_window",{sessionId:c,directory:U||Dn(me||"")||te,...Sr()}).catch(re=>{console.warn("[header] failed to open session mini chat window",re)})},[c,wt,i,me,U,te]),E=y&&(i||!!c),Q=a.useCallback((re,Ze)=>{xn("desktop_open_session_mini_chat_window",{sessionId:re,directory:Ze,...Sr()}).catch(Qe=>{console.warn("[header] failed to open session mini chat window",Qe)})},[]),Ne=pr,Ce=a.useMemo(()=>v&&C&&!S?"88px":h?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!v||k)&&!K?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[v,S,C,h,K,k]),We=(!v||k)&&!K?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",$e=e==="rtl",kt=$e?We:Ce,jt=$e?Ce:We,Et=k&&T!==lu(e);fs.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",kt)},[kt]);const Lt=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",Yt=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";fs.useEffect(()=>{if(!v||!C){w(!1);return}let re=!1;const Ze=async()=>{try{const ae=await xn("desktop_is_window_fullscreen");re||w(ae===!0)}catch{re||w(!1)}},Qe=()=>{Ze()};return Ze(),window.addEventListener("openchamber:window-resized",Qe),()=>{re=!0,window.removeEventListener("openchamber:window-resized",Qe)}},[v,C]);const is=a.useMemo(()=>!v||!C||O===null?"":O>=26?"h-11":O<=15?"h-14":"",[v,C,O]),Wt=a.useMemo(()=>v&&C&&!S?O!==null&&O<=15?"56px":"44px":"0px",[v,S,C,O]),rs=a.useMemo(()=>{const Ze=`max(${v&&C?"2.75rem":"3rem"}, ${Wt}, var(--oc-wco-titlebar-height, 0px))`,Qe=v&&!k||K;if(Qe&&Wt==="0px")return{};const ae={minHeight:Ze,height:Ze};return!Et&&(!Qe||$e)&&(ae.paddingInlineEnd=jt),ae},[Et,v,C,$e,K,jt,Wt,k]),as=a.useRef(null),Ss=a.useCallback(re=>{!re||re===as.current||(as.current=re,document.documentElement.style.setProperty("--oc-header-height",`${re}px`))},[]),Me=a.useCallback(()=>{typeof document>"u"||Ss(b.current?.getBoundingClientRect().height)},[Ss]);fs.useEffect(()=>{if(typeof window>"u")return;Me();const re=b.current;if(!re||typeof ResizeObserver>"u")return()=>{};let Ze=0;const Qe=()=>{Ze||(Ze=requestAnimationFrame(()=>{Ze=0,Me()}))},ae=new ResizeObserver(He=>{const ut=He[He.length-1];Ss(ut?.borderBoxSize?.[0]?.blockSize??ut?.target.getBoundingClientRect().height)});return ae.observe(re),window.addEventListener("resize",Qe),window.addEventListener("orientationchange",Qe),()=>{Ze&&cancelAnimationFrame(Ze),ae.disconnect(),window.removeEventListener("resize",Qe),window.removeEventListener("orientationchange",Qe)}},[Ss,Me]),fs.useEffect(()=>{Me()},[Me,g,is]);const pe=a.useCallback(async re=>{const Ze=re.target;Ze.closest(".app-region-no-drag")||Ze.closest("button, a, input, select, textarea")||re.button===0&&v&&await wm()},[v]);Gu({rename_current_session:()=>{if(!c||g)return!1;qe()},archive_current_session:()=>{if(!c||g||Ps.getState().entityById.get(c)?.time.archived)return!1;if(de.getState().showDeletionDialog){ye({action:"archive",sessionId:c});return}Ke("archive",c)}});const Le=n.jsxs(n.Fragment,{children:[n.jsx(m1,{directory:q,className:Te(pr,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"}),n.jsx(Sg,{directory:q,className:Te(pr,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"})]}),yt=a.useCallback(({session:re,open:Ze,isActive:Qe,select:ae,closeOtherTabs:He,components:ut})=>{const{Item:gt,Separator:Pt}=ut,Kt=Qe&&!K&&!L&&_&&!_.parentId,es=Qe&&!K&&L&&_&&!_.parentId&&Ve;return n.jsxs(n.Fragment,{children:[n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(gt,{onClick:()=>{Qe||ae(),be.current=re.id},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(ua,{sessionID:re.id,directory:re.directory,open:Ze,Item:gt}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(gt,{onClick:()=>we(re.id),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(Pt,{}),Qe?n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(gt,{onClick:()=>{De()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,y?n.jsxs(gt,{onClick:()=>Q(re.id,Qe?st:re.directory??""),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,Qe?ht(gt):null,Kt?n.jsx(Qt,{hint:t(d?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ee?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(gt,{disabled:!U||ee||d,onClick:_e,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,es?n.jsx(Qt,{hint:t(ee?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:n.jsx("span",{className:"block",children:n.jsxs(gt,{disabled:!U||ee||d,onClick:()=>Ue(!0),className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,n.jsx(Pt,{}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(gt,{onClick:He,children:[n.jsx(Z,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(Pt,{}),n.jsx(Pc,{sessionId:re.id,Item:gt,onArchive:()=>ye({action:"archive",sessionId:re.id})}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(gt,{className:"text-destructive focus:text-destructive",onClick:()=>ye({action:"delete",sessionId:re.id}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[we,_,st,De,y,Ve,L,ee,d,K,_e,Q,ht,U,t]),Rt=()=>n.jsxs("div",{onMouseDown:pe,className:Te("app-region-drag relative flex h-12 select-none items-center",Et?"pe-0":"pe-2.5",is),style:rs,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] ease-out motion-reduce:transition-none",style:{width:Lt,transitionDuration:`${r}ms`}}),n.jsx("div",{ref:Jf,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] ease-out motion-reduce:transition-none",style:{width:Yt,transitionDuration:`${r}ms`}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[dt?n.jsxs(n.Fragment,{children:[n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>de.getState().closeMainSurfaces(),children:n.jsx(Z,{name:"arrow-left",className:"size-4"})})}),n.jsx(Ot,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:dt.title}),dt.subtitle?n.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:dt.subtitle}):null]})]}):K||!o?n.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[Pe?n.jsx(Z,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,s?null:n.jsx(qS,{align:"start",children:n.jsx("button",{type:"button",className:Ne,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(Z,{name:"history",className:"h-4 w-4"})})}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[ke?n.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:re=>re.stopPropagation(),onSubmit:re=>{re.preventDefault(),St()},children:[n.jsx("input",{ref:et,value:Ie,onChange:re=>Ye(re.target.value),onKeyDown:re=>Yi(re,()=>Ae(!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"}),n.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:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Ae(!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:n.jsx(Z,{name:"close",className:"size-4"})})]}):i?null:n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:G}),le?n.jsxs("span",{className:Te("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",i?"typography-ui-label text-[14px] text-foreground":"typography-micro text-[10.5px] text-muted-foreground/75"),children:[p?n.jsx("span",{className:"truncate",children:p}):null,Ee?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(Z,{name:"git-branch",className:Te("flex-shrink-0 text-muted-foreground/70",i?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{className:Te("truncate",i&&"text-muted-foreground"),children:Ee})]}):null,!i&&A?n.jsxs("span",{className:Te("inline-flex min-w-0 items-center gap-0.5",A==="attention"||A==="invalid"||A==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[n.jsx(Z,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:ne})]}):null]}):null]}),n.jsx("div",{className:Te("flex h-[18px] shrink-0 items-center justify-center",le?"self-start":"self-center"),children:c&&!i&&!ke?n.jsxs(Is,{open:$,onOpenChange:fe,onOpenChangeComplete:re=>{!re&&be.current&&be.current===c&&(be.current=null,qe())},children:[n.jsx(Ts,{asChild:!0,children:n.jsx(It,{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:n.jsx(Z,{name:"more",className:"size-4"})})}),n.jsxs(Ds,{align:"end",className:"min-w-[190px]",children:[n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(qt,{onClick:()=>{be.current=c},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(ua,{sessionID:c,directory:U,open:$,Item:qt}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(qt,{onClick:()=>c&&we(c),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(wn,{}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(qt,{onClick:()=>{De()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),y?n.jsxs(qt,{onClick:()=>Q(c,st),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ht(qt),!K&&!L&&_&&!_.parentId?n.jsx(Qt,{hint:t(d?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ee?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(qt,{disabled:!U||ee||d,onClick:_e,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,n.jsx(wn,{}),n.jsx(Pc,{sessionId:c,Item:qt,onArchive:()=>ye({action:"archive",sessionId:c})}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(qt,{className:"text-destructive focus:text-destructive",onClick:()=>{c&&ye({action:"delete",sessionId:c})},children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:n.jsx(I1,{renderMenu:yt,suppressActiveTabControls:ke,onMenuOpenChangeComplete:re=>{!re&&be.current&&be.current===c&&(be.current=null,qe())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:ke?n.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:re=>re.stopPropagation(),onSubmit:re=>{re.preventDefault(),St()},children:[n.jsx("input",{ref:et,value:Ie,onChange:re=>Ye(re.target.value),onKeyDown:re=>Yi(re,()=>Ae(!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"}),n.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:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Ae(!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:n.jsx(Z,{name:"close",className:"size-4"})})]}):n.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):G})})})}),dt||K||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[E?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:pt,className:pr,children:n.jsx(Z,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"bottom",children:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat")})]}):null,K?null:n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":Y,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:j,className:Te(pr,Y&&"text-foreground"),children:n.jsx(Z,{name:"list-indefinite",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"bottom",children:t(I&&!W?z?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":I?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),Le,n.jsx(zf,{visible:Et,position:T})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:b,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Rt()}),n.jsx(z1,{open:nt,onOpenChange:Ue,onPick:Be}),n.jsx(qs,{open:Se!==null,onOpenChange:re=>{re||ye(null)},children:n.jsxs(Gs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Js,{children:[n.jsx(Zs,{children:Se?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),n.jsx(Qs,{children:Se?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:G}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:G})})]}),n.jsxs(kn,{children:[n.jsx(It,{variant:"outline",size:"sm",onClick:()=>ye(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(It,{variant:"destructive",size:"sm",onClick:()=>{Fe()},children:Se?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})})]})},Rc=280,Nc=264,Mc=500,tv=({isOpen:t,isMobile:e,children:s,className:r,topBar:o,peek:i})=>{const{t:c,direction:l}=Ct(),d=de(j=>j.sidebarWidth),u=de(j=>j.setSidebarWidth),[f,p]=a.useState(!1),m=a.useRef(0),g=a.useRef(d||Rc),b=a.useRef(null),v=a.useRef(null),x=a.useRef(null),y=a.useCallback(j=>Math.min(Mc,Math.max(Nc,j)),[]),h=a.useCallback(j=>{const P=x.current;P&&(P.style.width=`${j}px`,P.style.minWidth=`${j}px`,P.style.maxWidth=`${j}px`,P.style.setProperty("--oc-left-sidebar-width",`${j}px`),document.documentElement.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);a.useEffect(()=>{e&&f&&p(!1)},[e,f]),a.useEffect(()=>{f||(b.current=null,v.current=null)},[f]);const S=Math.min(Mc,Math.max(Nc,d||Rc)),w=t?S:0,C=f?b.current??w:w,k=f?C:S;a.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${k}px`)},[k]);const[T,O]=a.useState(!t);t&&T&&O(!1);const K=Jo(),R=a.useRef(t),I=a.useRef(t);if(a.useLayoutEffect(()=>{R.current=t,I.current!==t&&(I.current=t,qu(K),t||Ga(()=>{R.current||O(!0)}))},[t,K]),e)return null;const N=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}v.current=j.pointerId,p(!0),m.current=j.clientX,g.current=w,b.current=w,h(w),j.preventDefault()}},W=j=>{if(e||!f||v.current!==j.pointerId)return;const P=(j.clientX-m.current)*(l==="rtl"?-1:1),D=y(g.current+P);b.current!==D&&(b.current=D,h(D))},z=j=>{if(v.current!==j.pointerId||e)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const P=y(b.current??w);v.current=null,b.current=null,p(!1),u(P)},H=!t&&i?i.state:!1,M=H!==!1,Y=M&&i&&i.animationMs>0?`${H==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${Eo} forwards`:void 0;return n.jsxs("div",{ref:x,"data-left-sidebar":"",className:Te("relative flex h-full border-e border-border",!M&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",!t&&"border-e-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${k}px`,overflowX:M?void 0:"clip",transitionDuration:`${K}ms`,transitionTimingFunction:Eo},children:[t&&n.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)] rtl:shadow-[inset_2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&n.jsx("div",{className:Te("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",f&&"bg-[var(--interactive-border)]"),onPointerDown:N,onPointerMove:W,onPointerUp:z,onPointerCancel:z,role:"separator","aria-orientation":"vertical","aria-label":c("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":M?H:void 0,className:Te("flex h-full shrink-0 flex-col",M?"absolute inset-s-0 top-0 z-[25] border-e border-border bg-sidebar shadow-xl":"relative z-10 transition-opacity ease-out motion-reduce:transition-none",f&&"pointer-events-none",!t&&!M&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${K}ms`,overflowX:"hidden",contentVisibility:T&&!M?"hidden":void 0,animation:Y,"--oc-peek-offset":l==="rtl"?"100%":"-100%"},inert:!t&&!M||void 0,onPointerEnter:M?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:M?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:M?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,n.jsx(Or,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(vs,{children:s})})]})]})},sv=()=>{const t=Je.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 s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),t[1]=s):s=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[s,n.jsx("div",{ref:Jf,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),n.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},nv=50,rv=18,ov=300,iv='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',ep=t=>!document.getElementById("root")?.contains(t),av=t=>{if((Vo(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>rv)return!1;const s=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=s},Ac=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(iv)).some(s=>ep(s)&&s.getClientRects().length>0)},lv=({enabled:t,layoutAnimationMs:e})=>{const[s,r]=a.useState(!1),o=ny()?0:e,i=o>0,c=a.useRef(null),l=a.useRef(null),d=a.useRef(null),u=a.useCallback(()=>{l.current!==null&&clearTimeout(l.current),d.current!==null&&clearTimeout(d.current),l.current=null,d.current=null},[]),f=a.useCallback(()=>{u(),r(b=>b==="in"&&i?"out":!1)},[i,u]),p=a.useCallback(()=>{d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{if(d.current=null,Ac(c.current)){p();return}f()},ov)},[f]),m=a.useCallback(()=>{d.current!==null&&clearTimeout(d.current),d.current=null},[]);a.useEffect(()=>{t||(u(),r(!1))},[u,t]),a.useEffect(()=>u,[u]),a.useEffect(()=>{if(s!=="in")return;const b=y=>{const h=y.target;h instanceof Element&&(c.current?.contains(h)||ep(h)||f())},v=y=>{y.key!=="Escape"||y.defaultPrevented||Ac(c.current)||f()},x=y=>{y.relatedTarget===null&&p()};return document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",v),document.addEventListener("pointerout",x),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",v),document.removeEventListener("pointerout",x)}},[f,p,s]),a.useEffect(()=>{if(!t||s!==!1)return;const b=()=>{l.current!==null&&clearTimeout(l.current),l.current=null},v=y=>{if(y.pointerType!=="mouse"||y.buttons!==0||!av(y)){b();return}l.current===null&&(l.current=setTimeout(()=>{l.current=null,r("in")},nv))},x=y=>{y.relatedTarget===null&&b()};return document.addEventListener("pointermove",v,{passive:!0}),document.addEventListener("pointerout",x),()=>{document.removeEventListener("pointermove",v),document.removeEventListener("pointerout",x),b()}},[t,s]);const g=a.useMemo(()=>({onPointerEnter:()=>{m(),r(b=>b==="out"?"in":b)},onPointerLeave:()=>{s==="in"&&p()},onAnimationEnd:b=>{b.target===b.currentTarget&&r(v=>v==="out"?!1:v)}}),[m,p,s]);return{state:t?s:!1,animationMs:o,overlayRef:c,overlayHandlers:g}},Xr="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",cv=()=>{const t=Je.c(45),{t:e,locale:s,direction:r}=Ct(),o=de(dv),i=de(uv),c=de(fv),l=a.useRef(null),d=Yu(Xu("toggle_sidebar",c)),u=pv,{usesFramelessChrome:f,side:p}=$f();let m;t[0]!==s?(m=D=>{const V=D.currentTarget.getBoundingClientRect();xn("desktop_show_app_menu",{x:V.left,y:V.bottom,locale:s}).catch(hv)},t[0]=s,t[1]=m):m=t[1];const g=m;let b,v;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{if(typeof document>"u")return;const D=l.current;if(!D)return;const V=()=>{const _=Math.max(D.getBoundingClientRect().width,D.scrollWidth);J1(_)};if(V(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(V);return B.observe(D),()=>{B.disconnect()}},v=[],t[2]=b,t[3]=v):(b=t[2],v=t[3]),a.useEffect(b,v);const x="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",y=i?"var(--oc-left-sidebar-width, 100%)":void 0;let h;t[4]!==y?(h={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:y},t[4]=y,t[5]=h):h=t[5];const S="flex min-w-0 items-center gap-2";let w;t[6]!==r||t[7]!==f||t[8]!==p?(w=f&&p===lu(r)?n.jsx(zf,{visible:!0,position:p}):null,t[6]=r,t[7]=f,t[8]=p,t[9]=w):w=t[9];let C;t[10]!==g||t[11]!==e||t[12]!==f?(C=f?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,"aria-label":e("header.actions.openAppMenuAria"),className:Te(Xr,"shrink-0"),children:n.jsx(Z,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(Ot,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=g,t[11]=e,t[12]=f,t[13]=C):C=t[13];const k=Ft;let T;t[14]!==e?(T=e("header.actions.openSessionsAria"),t[14]=e,t[15]=T):T=t[15];const O=i&&"text-foreground";let K;t[16]!==O?(K=Te(Xr,"shrink-0",O),t[16]=O,t[17]=K):K=t[17];let R;t[18]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Z,{name:"layout-left",className:"h-4 w-4"}),t[18]=R):R=t[18];let I;t[19]!==i||t[20]!==K||t[21]!==T||t[22]!==o?(I=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":T,"aria-pressed":i,className:K,children:R})}),t[19]=i,t[20]=K,t[21]=T,t[22]=o,t[23]=I):I=t[23];const N=Ot,W=e("header.actions.openSessionsWithShortcut",{shortcut:d});let z;t[24]!==W?(z=n.jsx("p",{children:W}),t[24]=W,t[25]=z):z=t[25];let H;t[26]!==N||t[27]!==z?(H=n.jsx(N,{children:z}),t[26]=N,t[27]=z,t[28]=H):H=t[28];let M;t[29]!==k||t[30]!==I||t[31]!==H?(M=n.jsxs(k,{children:[I,H]}),t[29]=k,t[30]=I,t[31]=H,t[32]=M):M=t[32];let Y;t[33]!==u||t[34]!==i||t[35]!==e?(Y=i?n.jsxs("button",{type:"button",onClick:u,className:Te(Xr,"-ms-1 w-auto min-w-0 px-1.5 font-normal"),children:[n.jsx(Z,{name:"chat-new",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:u,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Te(Xr,"-ms-1 shrink-0"),children:n.jsx(Z,{name:"chat-new",className:"h-4 w-4"})})}),n.jsx(Ot,{children:n.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[33]=u,t[34]=i,t[35]=e,t[36]=Y):Y=t[36];let j;t[37]!==M||t[38]!==Y||t[39]!==w||t[40]!==C?(j=n.jsxs("div",{ref:l,className:S,children:[w,C,M,Y]}),t[37]=M,t[38]=Y,t[39]=w,t[40]=C,t[41]=j):j=t[41];let P;return t[42]!==j||t[43]!==h?(P=n.jsx("div",{className:x,style:h,children:j}),t[42]=j,t[43]=h,t[44]=P):P=t[44],P};function dv(t){return t.toggleSidebar}function uv(t){return t.isSidebarOpen}function fv(t){return t.shortcutOverrides}function pv(){de.getState().closeMainSurfaces(),xt.getState().openNewSessionDraft()}function hv(t){console.warn("[titlebar] failed to open app menu",t)}function mv(t,e,s){const r=Je.c(5),[o,i]=a.useState();let c,l;return r[0]!==s||r[1]!==t||r[2]!==e?(c=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let d=!1;return(async()=>{const[u,f]=await Promise.all([ry(t),oy(t)]).catch(gv);if(d)return;const p=vt(u),m=vt(f);if(!p||!m||m===p)return;const g=s||"",b=m.split("/").filter(Boolean).pop()||m;i({source:"sdk",path:m,projectDirectory:p,branch:g,label:g||b,name:b,worktreeRoot:m,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},l=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=c,r[4]=l):(c=r[3],l=r[4]),a.useEffect(c,l),e??o}function gv(){return["",""]}const bv=()=>{const t=Je.c(3),e=de(yv),s=de(xv);let r;return t[0]!==e||t[1]!==s?(r=()=>{s("integrations"),e(!0)},t[0]=e,t[1]=s,t[2]=r):r=t[2],r};function yv(t){return t.setSettingsDialogOpen}function xv(t){return t.setSettingsPage}const Sv="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)]",Oc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",vv=({className:t,identity:e=Qu})=>{const{t:s}=Ct(),{sourceControl:r}=_s(),o=Zu(e),i=e.provider==="gitlab",c=i?"gitlab":"github-fill",l=o?.status??null,d=Sn(y=>y.setStatus),[u,f]=a.useState(!1),p=a.useCallback(async y=>{if(!(!y||u)){f(!0);try{d(e,await r.authActivate(e,y))}catch(h){console.error("Failed to switch source control account:",h)}finally{f(!1)}}},[e,u,d,r]);if(l?.status!=="connected")return null;const m=l.user.username||null,g=l.user.avatarUrl??null,b=l.accounts,v=i?m?s("header.gitlab.connectedWithLogin",{login:m}):s("header.gitlab.connected"):m?s("header.github.connectedWithLogin",{login:m}):s("header.github.connected"),x=g?n.jsx("img",{src:g,alt:m?s("header.github.avatarWithLogin",{login:m}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(Z,{name:c,className:"h-3.5 w-3.5 text-foreground"});return b.length<=1?n.jsx("div",{className:Te(Oc,t),title:v,children:x}):n.jsxs(Is,{children:[n.jsx(Ts,{asChild:!0,children:n.jsx("button",{type:"button",className:Te(Oc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:v,disabled:u,children:x})}),n.jsxs(Ds,{align:"end",className:"w-64",children:[n.jsx(Ji,{className:"typography-ui-header font-semibold text-foreground",children:s(i?"header.gitlab.accountsTitle":"header.github.accountsTitle")}),n.jsx(wn,{}),b.map(y=>{const h=y.user,S=!!y.current,w=s(iy(y.source??"oauth"));return n.jsxs(qt,{className:"gap-2",disabled:u,onSelect:()=>{S||p(y.id)},children:[h?.avatarUrl?n.jsx("img",{src:h.avatarUrl,alt:h.username?s("header.github.avatarWithLogin",{login:h.username}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:n.jsx(Z,{name:c,className:"h-3 w-3 text-muted-foreground"})}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:h?.name?.trim()||h.username||(i?"GitLab":"GitHub")}),h.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:h.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:w})]}):null]}),S?n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})},wv=t=>JSON.stringify(ay(t)),kv=async(t,e)=>{const s=await t.projectUpstream(e);if(!s?.isFork||!s.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,s.upstream.owner,s.upstream.name);return{upstream:s.upstream,branches:r}},tp=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function jv(t){if(!tp(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function Cv(t,e,s){const r=Je.c(16),{sourceControl:o}=_s(),[i,c]=fs.useState(null);let l;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(l=JSON.stringify([t.provider,t.repositoryId,t.bindingRevision,e]),r[0]=t.bindingRevision,r[1]=t.provider,r[2]=t.repositoryId,r[3]=e,r[4]=l):l=r[4];const d=l;let u;r[5]!==t||r[6]!==d||r[7]!==e||r[8]!==o?(u=()=>{if(t.provider!=="github")return;let p=!1;return o.githubReferences(t,{kind:"pull",query:`#${e}`}).then(m=>{if(p||!m.connected)return;const g=m.items.find(b=>b.kind==="pull"&&b.number===e);g&&c({key:d,pull:g})}).catch(Pv),()=>{p=!0}},r[5]=t,r[6]=d,r[7]=e,r[8]=o,r[9]=u):u=r[9];let f;return r[10]!==t||r[11]!==d||r[12]!==e||r[13]!==s||r[14]!==o?(f=[t,d,e,s,o],r[10]=t,r[11]=d,r[12]=e,r[13]=s,r[14]=o,r[15]=f):f=r[15],fs.useEffect(u,f),i?.key===d?i.pull:null}function Pv(){}const Ev=t=>{const e=Je.c(58),{directory:s,context:r,changeRequest:o,onChanged:i}=t,c=fn(),l=Jt(Iv),[d,u]=fs.useState(0),[f,p]=fs.useState(!1),[m]=fs.useState(Tv),g=Cv(r,o.number,d);let b;e[0]!==o?(b=ly(o),e[0]=o,e[1]=b):b=e[1];const v=b;let x;e[2]!==g||e[3]!==v?(x=g?{...v,labels:g.labels,commentCount:g.commentCount}:v,e[2]=g,e[3]=v,e[4]=x):x=e[4];const y=x,{detail:h,refresh:S}=cy(s,y,!0),w=vg(y);let C;e[5]!==i||e[6]!==S?(C=()=>{S(),u(Dv),i()},e[5]=i,e[6]=S,e[7]=C):C=e[7];const k=C;let T;e[8]!==y?(T={source:"github",reference:y},e[8]=y,e[9]=T):T=e[9];const O=T,K=c??s;let R;e[10]===Symbol.for("react.memo_cache_sentinel")?(R={status:"idle"},e[10]=R):R=e[10];let I;e[11]!==r||e[12]!==O||e[13]!==k?(I=n.jsx(jg,{item:O,project:null,context:r,onStartWorktree:Nv,onChanged:k}),e[11]=r,e[12]=O,e[13]=k,e[14]=I):I=e[14];let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=()=>p(!0),e[15]=N):N=e[15];let W;e[16]!==w.attachComment||e[17]!==w.attachComments?(W={onAttach:w.attachComment,onAttachAll:w.attachComments},e[16]=w.attachComment,e[17]=w.attachComments,e[18]=W):W=e[18];let z;e[19]!==r||e[20]!==y||e[21]!==k?(z=n.jsx(Cg,{reference:y,context:r,onChanged:k}),e[19]=r,e[20]=y,e[21]=k,e[22]=z):z=e[22];let H;e[23]!==r||e[24]!==h||e[25]!==y||e[26]!==k?(H=n.jsx(Pg,{pull:y,detail:h,context:r,onChanged:k}),e[23]=r,e[24]=h,e[25]=y,e[26]=k,e[27]=H):H=e[27];let M;e[28]!==r||e[29]!==y||e[30]!==k?(M=n.jsx(wg,{reference:y,context:r,onRefresh:k},y.number),e[28]=r,e[29]=y,e[30]=k,e[31]=M):M=e[31];const Y=l??"";let j;e[32]!==K||e[33]!==Y?(j={id:Y,path:K},e[32]=K,e[33]=Y,e[34]=j):j=e[34];let P;e[35]!==r||e[36]!==K||e[37]!==y||e[38]!==j?(P=n.jsx(Eg,{pull:y,project:j,context:r,projectOwnsDirectory:Mv,currentDirectory:K}),e[35]=r,e[36]=K,e[37]=y,e[38]=j,e[39]=P):P=e[39];let D;e[40]!==h||e[41]!==O||e[42]!==m||e[43]!==H||e[44]!==M||e[45]!==P||e[46]!==I||e[47]!==W||e[48]!==z?(D=n.jsx(dy,{item:O,pullStatus:uy,linearDetail:R,githubDetail:h,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Rv,now:m,footer:I,onOpenChecks:N,commentAttachments:W,labelsControl:z,reviewersControl:H,reply:M,pullLinks:P}),e[40]=h,e[41]=O,e[42]=m,e[43]=H,e[44]=M,e[45]=P,e[46]=I,e[47]=W,e[48]=z,e[49]=D):D=e[49];let V;e[50]!==w.attachFailedChecks||e[51]!==f||e[52]!==r||e[53]!==y?(V=n.jsx(kg,{pull:y,context:r,open:f,onOpenChange:p,onAttachFailed:w.attachFailedChecks}),e[50]=w.attachFailedChecks,e[51]=f,e[52]=r,e[53]=y,e[54]=V):V=e[54];let B;return e[55]!==D||e[56]!==V?(B=n.jsxs(n.Fragment,{children:[D,V]}),e[55]=D,e[56]=V,e[57]=B):B=e[57],B};function Iv(t){return t.activeProjectId}function Tv(){return Date.now()}function Dv(t){return t+1}function Rv(){}function Nv(){}function Mv(){return!0}function Av(t,e){const{git:s,sourceControl:r}=_s(),{t:o}=Ct(),i=Ig(),c=Tg({directory:t,branch:e,chooseContributor:i.choose}),l=Dg(t,s,r),d=async()=>{const f=l.start();if(!f)return ze.info(o("gitView.pr.toast.gitBusy")),!1;const p=o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")});try{return await(await c.prepare("push",{onOperation:f.onOperation}))(),f.isCurrent()}catch(m){if(m instanceof fy){if(m.code==="stale-runtime")return!1;const g=c.errorMessage(m);return g?ze.info(g):ze.error(p),!1}return m instanceof py||m instanceof hy?(ze.error(p,{description:m.message||void 0}),!1):(ze.error(p,{description:m instanceof Error?m.message:String(m)}),!1)}finally{f.finish()}},u=n.jsxs(n.Fragment,{children:[c.context?n.jsx(Rg,{context:c.context,onSelect:c.settle}):null,c.confirmDialog,n.jsx(Ng,{candidates:i.candidates,onSelect:i.settle})]});return{push:d,dialogs:u}}const Ov=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"}},Bv=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=xt.getState(),o=s?r(s):null;!s||!o||vt(o)!==vt(t)||Cy(s,o,Py({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},Fv=t=>{const e=t?.changeRequest??t?.pr;return e?Ey({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},Lv=[2e3,5e3];let Bc=0;const _v=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(Bc+=1,`source-control-${Date.now().toString(36)}-${Bc.toString(36)}`)},$v=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),sp="openchamber:pr-create-as-draft:v1",Fc=()=>{try{return localStorage.getItem(sp)==="true"}catch{return!1}},zv=t=>{try{localStorage.setItem(sp,String(t))}catch{}},Ei=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),gn=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):""},Kv=(t,e)=>{const s=gn(t);if(!s||s.includes("->"))return"";if(e){const o=`${e}/`;return s.startsWith(o)?s.slice(o.length).trim():""}const r=s.indexOf("/");return r>0?s.slice(r+1).trim():s},Wv=(t,e)=>`${t}::${e}`,Ii=new Map,Lc=ti;function Hv(t,e,s){const r=Je.c(14);let o;r[0]!==s?(o=s?wv(s):null,r[0]=s,r[1]=o):o=r[1];const i=o;let c;r[2]===Symbol.for("react.memo_cache_sentinel")?(c={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=c):c=r[2];const[l,d]=a.useState(c);let u,f;r[3]!==i||r[4]!==t||r[5]!==s||r[6]!==e?(u=()=>{if(!t||!s||!i)return;let m=!1;return(async()=>{try{const g=await kv(e,s);m||d({contextKey:i,detectedUpstream:g.upstream,upstreamBranches:g.branches})}catch{}})(),()=>{m=!0}},f=[i,t,s,e],r[3]=i,r[4]=t,r[5]=s,r[6]=e,r[7]=u,r[8]=f):(u=r[7],f=r[8]),a.useEffect(u,f);let p;return r[9]!==i||r[10]!==l.contextKey||r[11]!==l.detectedUpstream||r[12]!==l.upstreamBranches?(p=l.contextKey===i?{detectedUpstream:l.detectedUpstream,upstreamBranches:l.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=l.contextKey,r[11]=l.detectedUpstream,r[12]=l.upstreamBranches,r[13]=p):p=r[13],p}const Vv=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:c})=>{const{t:l}=Ct(),d=Ju(t),u=a.useCallback((pe,Le)=>l(an(pe,d?.provider),Le),[d?.provider,l]),f=bv(),{sourceControl:p}=_s(),m=Sn(pe=>pe.entries),{isMobile:g,hasTouchInput:b,screenWidth:v}=En(),x=de(pe=>pe.openContextSurface),y=my(pe=>pe.requestTarget),h=!g&&v>=768&&!Pn(),S=a.useMemo(()=>Wv(t,e),[t,e]),w=a.useMemo(()=>Ii.get(S)??null,[S]),C=ds(pe=>pe.ensureEntry),k=ds(pe=>pe.setParams),T=ds(pe=>pe.beginActiveContextsLoad),O=ds(pe=>pe.commitActiveContexts),K=ds(pe=>pe.releaseActiveContexts),R=a.useId(),I=ds(pe=>pe.startWatching),N=ds(pe=>pe.stopWatching),W=ds(pe=>pe.refresh),[z,H]=a.useState(()=>w?.title??Ei(e)),[M,Y]=a.useState(()=>w?.body??""),[j,P]=a.useState(()=>w?.draft??Fc()),[D,V]=a.useState(()=>w?.additionalContext??""),[B,_]=a.useState(()=>{const pe=typeof w?.targetBaseBranch=="string"?gn(w.targetBaseBranch):"";return pe||gn(s)}),[F,X]=a.useState(!1),[oe,ne]=a.useState(!1),[A,te]=a.useState(!1),U=ef(t,p),Pe=U.scope.runtimeKey;a.useEffect(()=>{if(!t)return;const pe=U.scope.runtimeKey,Le=T(pe,t,R),yt=U.contexts.filter(Rt=>ea(m[Vn(Rt)],Rt).connected);return O(pe,t,R,Le,yt),()=>{K(pe,t,R)}},[T,U.contexts,U.scope.runtimeKey,O,t,K,m,R]);const ce=U.contexts[0]??null,Oe=Sn(pe=>d?pe.entries[Vn(d)]?.hasChecked===!0:!1),me=ce?.primaryRemote??null,ie=a.useMemo(()=>ce?Vn(ce):"",[ce]),q=Sn(pe=>pe.entries[ie]),ue=ce?ea(q,ce):{authChecked:q?.hasChecked??!1,connected:!1},ve=ue.authChecked,[Ee,L]=a.useState(0),[le,G]=a.useState({key:"",status:"loading",capabilities:null}),[se,je]=a.useState(!1),{detectedUpstream:he,upstreamBranches:ge}=Hv(t,p,ce);a.useEffect(()=>{if(!ce)return;let pe=!1;const Le=Vn(ce);return G({key:Le,status:"loading",capabilities:null}),p.capabilities(ce).then(yt=>{pe||G({key:Le,status:"ready",capabilities:yt})}).catch(()=>{pe||G({key:Le,status:"error",capabilities:null})}),()=>{pe=!0}},[Ee,ce,p]);const ke=le.key===ie?le:null,Ae=ke?.status==="ready"?ke.capabilities:null;a.useEffect(()=>{je(!1)},[t]);const fe=!!(t&&e&&s&&(e!==s||he!==null)),be=a.useMemo(()=>ce?tf(ce,e):"",[e,ce]),Ie=a.useRef(be);Ie.current=be;const Ye=a.useCallback((pe,Le)=>pe===Gt()&&Le===Ie.current,[]),nt=ds(pe=>pe.entries[be]),Ue=a.useMemo(()=>be?[be]:[],[be]);sf(nf(Ue));const Ve=nt?.isLoading??!1,Se=ue.connected?nt?.status??null:null,ye=U.error?u("settings.gitlab.status.operationFailed"):nt?.error??null,Ge=nt?.isInitialStatusResolved??!1,qe=a.useMemo(()=>{const pe=se?null:me,Le=new Set;for(const Nt of i){const re=Kv(Nt,pe);!re||re==="HEAD"||Le.add(re)}if(se)for(const Nt of ge)Nt&&Nt!=="HEAD"&&Le.add(Nt);const yt=gn(s);yt&&yt!=="HEAD"&&Le.add(yt);const Rt=gn(B);return Rt&&Rt!=="HEAD"&&Le.add(Rt),Array.from(Le).sort((Nt,re)=>Nt.localeCompare(re))},[s,i,me,B,ge,se]);a.useEffect(()=>{const pe=gn(s);if(!B&&pe){_(pe);return}if(qe.length!==0&&!qe.includes(B)){const Le=qe.includes(pe)?pe:qe[0];Le&&_(Le)}},[qe,s,B]);const ft=a.useRef([]),et=a.useRef(new Map),St=a.useCallback(pe=>{const Le=et.current.get(pe);if(Le?.inFlight)return null;if(Le)return Le.inFlight=!0,Le.key;const yt=_v();return et.current.set(pe,{key:yt,inFlight:!0}),yt},[]),we=a.useCallback((pe,Le,yt)=>{const Rt=et.current.get(pe);!Rt||Rt.key!==Le||(yt?Rt.inFlight=!1:et.current.delete(pe))},[]);a.useEffect(()=>{he&&je(!0)},[he]),a.useEffect(()=>{se&&he?.defaultBranch&&_(he.defaultBranch)},[se,he?.defaultBranch]);const De=Se?.changeRequest??Se?.pr??null,ot=Se?.identity??ce,rt=a.useMemo(()=>Se?.project??(Se?.repo&&ot?{...Se.repo,...ot,id:`${Se.repo.owner}/${Se.repo.repo}`,name:Se.repo.repo}:null),[Se?.project,Se?.repo,ot]),Xe=De?.state==="merged"||De?.state==="closed",ht=Xe?null:De,ee=Se?.ci?.summary??Se?.checks??null,[_e,Be]=a.useState(!1),Ke=a.useRef(!0);a.useEffect(()=>(Ke.current=!0,()=>{Ke.current=!1}),[]);const Fe=a.useCallback(async pe=>{await W(be,pe)},[be,W]),tt=a.useCallback((pe,Le)=>{ft.current.forEach(yt=>{window.clearTimeout(yt)}),ft.current=Lv.map(yt=>window.setTimeout(()=>{Ye(pe,Le)&&W(Le,{force:!0,silent:!0,markInitialResolved:!0})},yt))},[Ye,W]),bt=a.useCallback(async(pe,Le,yt)=>{await jv({error:pe,isCurrent:()=>Ye(Le,yt),refresh:()=>W(yt,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>tt(Le,yt)})},[Ye,W,tt]);a.useEffect(()=>{!ce||!be||(C(be),k(be,{directory:t,branch:e,remoteName:ce.primaryRemote,canShow:fe,identity:ce,readContext:ce,sourceControl:p,authChecked:ue.authChecked,connected:ue.connected}))},[e,fe,t,C,be,ce,p,ue.authChecked,ue.connected,k]);const mt=600,it=a.useCallback(async()=>{if(_e)return;Be(!0);const pe=Date.now();try{await Fe({force:!0})}finally{const Le=mt-(Date.now()-pe);Le>0&&await new Promise(yt=>window.setTimeout(yt,Le)),Ke.current&&Be(!1)}},[_e,Fe]);a.useEffect(()=>{if(!(!ce||!be))return I(be),()=>{N(be)}},[be,ce,I,N]),a.useEffect(()=>{const pe=Ii.get(S)??null;H(pe?.title??Ei(e)),Y(pe?.body??""),P(pe?.draft??Fc()),_(pe?.targetBaseBranch?gn(pe.targetBaseBranch):gn(s))},[s,e,S]),a.useEffect(()=>{!ce||!be||!ue.connected||Fe({markInitialResolved:!0})},[be,ce,Fe,ue.connected]),a.useEffect(()=>{!fe||!ce||!ue.connected||Fe({force:!0,silent:!0,markInitialResolved:!0})},[fe,ce,Fe,ue.connected]),a.useEffect(()=>{const pe=()=>{const yt=ds.getState().entries[be]?.lastRefreshAt??0;Date.now()-yt>6e4&&Fe({force:!0,silent:!0})},Le=()=>{document.visibilityState==="visible"&&pe()};return window.addEventListener("focus",pe),document.addEventListener("visibilitychange",Le),()=>{window.removeEventListener("focus",pe),document.removeEventListener("visibilitychange",Le)}},[be,Fe]),a.useEffect(()=>{ve&&!ue.connected&&Fe({force:!0,silent:!0,markInitialResolved:!0})},[Fe,ue.connected,ve]),a.useEffect(()=>{!t||!e||Ii.set(S,{title:z,body:M,draft:j,additionalContext:D,targetBaseBranch:B})},[S,z,M,j,D,B,t,e]),a.useEffect(()=>()=>{ft.current.forEach(pe=>{window.clearTimeout(pe)}),ft.current=[]},[be,Pe]),a.useEffect(()=>()=>{et.current.clear()},[]);const Tt=se&&he?.defaultBranchSha?he.defaultBranchSha:ce?`${ce.primaryRemote}/${B}`:B;a.useEffect(()=>{if(!t||!e||!Tt)return;let pe=!1;return gy(t,{from:Tt,to:e,maxCount:2}).then(Le=>{const yt=Le.all.length===1?Le.all[0]?.message.trim():"";pe||!yt||H(Rt=>Rt===Ei(e)?yt:Rt)}).catch(()=>{}),()=>{pe=!0}},[e,Tt,t]);const at=!r||o>0,$t=Av(t,e),zt=a.useId(),Mt=pe=>{P(pe),zv(pe)},Re=a.useCallback(async()=>{if(!F&&t){X(!0);try{const Le={base:Tt,head:e,...ce?.provider?{changeRequestProvider:ce.provider}:{}};D&&(Le.context=D);const yt=await by(t,Le);yt.title?.trim()&&H(yt.title.trim()),yt.body?.trim()&&Y(yt.body.trim()),c?.()}catch(pe){const Le=pe instanceof Error?pe.message:String(pe);ze.error(u("gitView.pr.toast.generateDescriptionFailed"),{description:Le})}finally{X(!1)}}},[D,e,Tt,t,F,c,ce,u]),ct=a.useCallback(async()=>{if(Ae?.changeRequests!==!0){ze.error(u("gitView.pr.toast.createPrFailed"),{description:u("gitView.pr.capabilitiesUnavailable")});return}const pe=z.trim();if(!pe){ze.error(u("gitView.pr.toast.titleRequired"));return}const Le=B.trim();if(!Le){ze.error(u("gitView.pr.toast.baseBranchRequired"));return}if(!se&&Le===e){ze.error(u("gitView.pr.toast.baseMustDifferFromHead"));return}const yt=se?he:rt;if(!ce||!yt){ze.error(u("gitView.pr.toast.createPrFailed"),{description:ye??u("gitView.pr.statusUnavailable")});return}if(at&&(ne(!0),!await $t.push())){ne(!1);return}const Rt=Gt(),Nt=be,re={owner:yt.owner,name:yt.name},Ze=M.trim()?M:void 0,Qe=se?void 0:ce.primaryRemote,ae=se?ce.primaryRemote:void 0,He=$v(Rt,ce,[re.owner,re.name,e,Le,pe,Ze,j,Qe,ae]),ut=St(He);if(!ut){ne(!1);return}ne(!0);let gt=!1,Pt=!1;try{const Kt={...ce,idempotencyKey:ut,target:{project:re,head:e,base:Le},title:pe,draft:j};Ze!==void 0&&(Kt.body=Ze),Qe&&(Kt.remote=Qe),ae&&(Kt.headRemote=ae);const es=await p.changeRequestCreate(Kt);if(Pt=!0,we(He,ut,!1),!Ye(Rt,Nt)||(ze.success(u("gitView.pr.toast.prCreated")),await Fe({force:!0}),!Ye(Rt,Nt)))return;const os=ds.getState().entries[Nt]?.status,ps=os?.changeRequest??os?.pr;ps&&ps.number===es.target.number&&Bv(t,ps),tt(Rt,Nt)}catch(Kt){const es=Kt instanceof Error?Kt:new Error(String(Kt));gt=tp(es);const os=es.message;ze.error(u("gitView.pr.toast.createPrFailed"),{description:os}),gt&&await bt(es,Rt,Nt)}finally{Pt||we(He,ut,gt),ne(!1)}},[St,M,e,$t,he,t,j,ye,we,Ye,at,be,ce,bt,Fe,tt,p,Ae?.changeRequests,rt,B,z,se,u]),lt="border-0 bg-transparent rounded-none px-4 py-3";if(!fe)return n.jsx("section",{className:lt,children:n.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[n.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:u("gitView.pullRequest.availableOnFeatureBranches")}),n.jsx(vv,{identity:d??void 0})]})});const dt=Se?.changeRequest&&Se.changeRequest.state==="open"?Se.changeRequest:ht&&rt&&ot?{...ot,id:`${rt.owner}/${rt.name}#${ht.number}`,number:ht.number,project:{...ot,id:rt.id,owner:rt.owner,name:rt.name,url:rt.url??""},title:ht.title,body:ht.body,url:ht.url,state:ht.state,draft:ht.draft,base:ht.base,head:ht.head,headSha:ht.headSha,mergeable:ht.mergeable,mergeableState:ht.mergeableState}:null;if(dt&&ce)return n.jsx("div",{className:"h-full min-h-0",children:n.jsx(Ev,{directory:t,context:ce,changeRequest:dt,onChanged:()=>{Fe({force:!0,silent:!0,markInitialResolved:!0})}})});const st=rt?.url||null,wt=se&&he?.url?he.url:st,pt=ke?.status==="error",E=!!Se?.connected,Q=!!(!ce&&d&&U.status==="ready"&&Oe),Ne=!!(ot&&ve&&Se?.connected===!1)||Q,Ce=ot??d,We=Ce?yy(Ce.provider):null,$e=Fv(Se),kt=$e?`var(--pr-${$e})`:"var(--status-info)",jt=$e==="draft"?"git-pr-draft":$e==="merged"?"git-merge":$e==="closed"?"git-close-pull-request":"git-pull-request",Et=De?[`${De.state}${De.draft?" (draft)":""}`,De.state==="open"&&De.mergeable===!1?u("gitView.pr.notMergeable"):null,De.state==="open"&&typeof De.mergeableState=="string"&&De.mergeableState&&De.mergeableState!=="unknown"?De.mergeableState:null].filter(Boolean).join(" · "):"",Lt=ee?ee.total>0?`${ee.success}/${ee.total} ${u("gitView.pr.checks.label")}`:`${ee.state} ${u("gitView.pr.checks.label")}`:"",Yt="px-0 py-3 border-b border-border/40 flex flex-col gap-1",is="flex flex-col gap-3 py-3",Wt=n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Ve||_e,onClick:()=>{it()},"aria-label":u("gitView.pr.actions.refreshAria"),children:n.jsx(Z,{name:Ve||_e?"loader-4":"refresh",className:Te("size-4 text-muted-foreground",(Ve||_e)&&"animate-spin")})})}),n.jsx(Ot,{children:n.jsx("p",{children:u("gitView.pr.actions.refresh")})})]}),rs=A||D.trim().length>0,as=at?r?o===1?u("gitView.pr.unpushed.one"):u("gitView.pr.unpushed.many",{count:o}):u("gitView.pr.unpushed.unpublished"):null,Ss=u(at?j?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":j?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),Me=oe||!E||Ae?.changeRequests!==!0||!B.trim()||!se&&B.trim()===e;return n.jsxs("section",{className:lt,children:[De?n.jsxs("div",{className:Yt,children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs(It,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Lc(De.url)},"aria-label":We?u("gitView.pr.actions.openOnProviderAria",{provider:We}):u("gitView.header.openPullRequest"),children:[n.jsx(Z,{name:jt,className:"size-4 shrink-0",style:{color:kt}}),We?u("gitView.pr.actions.openOnProvider",{provider:We}):u("gitView.header.openPullRequest")]}),n.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:u("gitView.pullRequest.title")}),n.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:qa(ot?.provider,De.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Wt})]}),n.jsxs("div",{className:"@container/pr-actions flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[n.jsx("span",{style:{color:kt},children:Et}),ee?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${Ov(ee.state)}`}),Lt]}):null,r&&me&&r.split("/")[0]!==me?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",me]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:h&&(ce?.provider==="github"||ce?.provider==="gitlab")?n.jsxs(It,{variant:"outline",size:"sm",className:Te("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Sv),onClick:()=>{y(t,{source:{kind:"pr",number:De.number,...rt?{sourceRepo:{owner:rt.owner,repo:rt.name}}:{}},context:ce}),x(t,"walkthrough")},"aria-label":u("walkthrough.action.open"),children:[n.jsx(Z,{name:"route",className:"size-4"}),n.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}):null})]})]}):null,n.jsxs("div",{className:is,children:[pt?n.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3",children:[n.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:u("gitView.pr.capabilitiesUnavailable")}),n.jsx(It,{variant:"outline",size:"sm",onClick:()=>L(pe=>pe+1),children:u("settings.sourceControl.transport.retry")})]}):null,Ne&&We?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:u("gitView.pr.providerNotConnected",{provider:We})}),n.jsx(It,{variant:"outline",size:"sm",onClick:f,className:"w-fit",children:u("gitView.pr.actions.openSettings")})]}):null,ye?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-ui-label text-foreground",children:u("gitView.pr.statusUnavailable")}),n.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:ye}),U.error?n.jsx(It,{variant:"outline",size:"sm",onClick:()=>{U.retry()},disabled:U.status==="loading",children:u("settings.sourceControl.transport.retry")}):null,wt?n.jsx(It,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:wt,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(Z,{name:"external-link",className:"size-4"}),u("gitView.pr.actions.repo")]})}):null]}):null,(ht||!De&&!Ge)&&!ye&&!Ne&&(U.status==="loading"||ce)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}),u("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[De&&Xe?n.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:[n.jsx(Z,{name:De.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:kt}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:De.state==="merged"?u("gitView.pr.history.merged",{number:De.number,base:De.base||B}):u("gitView.pr.history.closed",{number:De.number})}),n.jsx(It,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Lc(De.url)},"aria-label":u("gitView.pr.actions.openOnProviderAria",{provider:We}),children:n.jsx(Z,{name:"external-link",className:"size-3.5"})})]}):null,n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(Z,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),n.jsx(Z,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),se&&he?n.jsxs("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:[he.owner,"/",he.name]}):null,qe.length>0?n.jsxs(xy,{value:B,onValueChange:_,children:[n.jsx(Sy,{className:"w-auto min-w-0","aria-label":u("gitView.pr.field.baseBranch"),children:n.jsx(vy,{placeholder:u("gitView.pr.placeholder.selectBaseBranch")})}),n.jsx(wy,{children:qe.map(pe=>n.jsx(ky,{value:pe,children:pe},pe))})]}):n.jsx(Io,{value:B,onChange:pe=>_(pe.target.value),placeholder:u("gitView.pr.placeholder.main"),"aria-label":u("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),n.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[wt?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:n.jsx("a",{href:wt,target:"_blank",rel:"noopener noreferrer","aria-label":u("gitView.pr.actions.repo"),children:n.jsx(Z,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),n.jsx(Ot,{children:n.jsx("p",{children:u("gitView.pr.actions.repo")})})]}):null,Wt]})]}),n.jsxs("label",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.title")}),n.jsx(Io,{value:z,onChange:pe=>H(pe.target.value),placeholder:u("gitView.pr.placeholder.title"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("label",{htmlFor:zt,className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsxs(It,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:Re,disabled:F||oe,children:[F?n.jsx(Z,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(Z,{name:"ai-generate-2",className:"size-3.5 text-primary"}),u("gitView.commit.generate")]}),n.jsxs(Is,{children:[n.jsx(Ts,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:F||oe,"aria-label":u("gitView.pr.generate.optionsAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-3.5"})})}),n.jsx(Ds,{align:"end",className:"w-60",children:n.jsxs(qt,{onSelect:()=>te(!0),children:[n.jsx(Z,{name:"sticky-note",className:"size-4 shrink-0"}),u("gitView.pr.generate.withNotes")]})})]})]})]}),rs?n.jsxs("div",{className:"relative",children:[n.jsx(lc,{value:D,onChange:pe=>V(pe.target.value),className:"min-h-[72px] pe-9",placeholder:u("gitView.pr.placeholder.additionalContext"),"aria-label":u("gitView.pr.generate.notesAria"),autoFocus:A&&!D}),n.jsx(It,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{V(""),te(!1)},"aria-label":u("gitView.pr.generate.removeNotesAria"),children:n.jsx(Z,{name:"close",className:"size-3.5"})})]}):null,n.jsx(lc,{id:zt,value:M,onChange:pe=>Y(pe.target.value),className:"min-h-[140px]",placeholder:u("gitView.pr.placeholder.whatChanged"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),as?n.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[n.jsx(Z,{name:"arrow-up",className:"size-3.5 shrink-0"}),as]}):null,n.jsx("div",{className:"flex justify-end",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs(It,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:ct,disabled:Me,children:[oe?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(Z,{name:j?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:Ss})]}),n.jsxs(Is,{children:[n.jsx(Ts,{asChild:!0,children:n.jsx(It,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:oe,"aria-label":u("gitView.pr.createKindAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-4"})})}),n.jsx(Ds,{align:"end",className:"w-56",children:n.jsxs(jy,{value:j?"draft":"ready",onValueChange:pe=>Mt(pe==="draft"),children:[n.jsx(cc,{value:"ready",children:u("gitView.pr.actions.createPr")}),n.jsx(cc,{value:"draft",children:u("gitView.pr.actions.createDraftPr")})]})})]})]})}),$t.dialogs]})]})]})},Uv=()=>{const t=Je.c(100),{t:e}=Ct(),{git:s,sourceControl:r}=_s(),o=fn(),{rootIsGitRepo:i,gitDirectory:c,nestedRepos:l}=Iy(o??null),d=Ya(c??null),u=Ty(c??null),f=Dy(c??null),p=ef(c,r),{ensureAll:m,ensureNestedRepos:g,selectNestedRepo:b}=vn(rr(Gv)),v=xt(qv),x=xt(Yv),y=xt(Xv),h=xt(Zv);let S;t[0]!==o?(S=vt(o),t[0]=o,t[1]=S):S=t[1];const w=S;let C;if(t[2]!==h||t[3]!==w||t[4]!==y){e:{if(!w){C=void 0;break e}let ve;if(t[6]!==h||t[7]!==w){let L;t[9]!==w?(L=le=>vt(le.path)===w,t[9]=w,t[10]=L):L=t[10],ve=h.find(L),t[6]=h,t[7]=w,t[8]=ve}else ve=t[8];const Ee=ve;if(Ee){C=Ee;break e}for(const L of y.values())if(vt(L.path)===w){C=L;break e}C=void 0}t[2]=h,t[3]=w,t[4]=y,t[5]=C}else C=t[5];const k=C;let T;t[11]!==v||t[12]!==k||t[13]!==x?.open||t[14]!==y?(T=()=>{if(v)return y.get(v)??k;if(x?.open)return k},t[11]=v,t[12]=k,t[13]=x?.open,t[14]=y,t[15]=T):T=t[15],x?.open;let O;t[16]!==T?(O=T(),t[16]=T,t[17]=O):O=t[17];const K=O;let R;t[18]!==v?(R=ve=>v?ve.getAttachment(v):void 0,t[18]=v,t[19]=R):R=t[19];const I=_u(R),N=I&&!I.degraded&&!I.legacy?I.worktreeRoot??void 0:void 0,W=mv(o,K,d?.current??void 0);let z,H;t[20]!==m||t[21]!==s||t[22]!==c?(z=()=>{!c||!s||m(c,s)},H=[c,m,s],t[20]=m,t[21]=s,t[22]=c,t[23]=z,t[24]=H):(z=t[23],H=t[24]),a.useEffect(z,H);const[M,Y]=a.useState(null);let j;t[25]!==N||t[26]!==W?.projectDirectory?(j=()=>{const ve=N||W?.projectDirectory;if(!ve){Y(null);return}let Ee=!1;return rf(ve).then(L=>{if(Ee)return;const le=L.trim();Y(le&&le!=="HEAD"?le:null)}).catch(()=>{Ee||Y(null)}),()=>{Ee=!0}},t[25]=N,t[26]=W?.projectDirectory,t[27]=j):j=t[27];const P=W?.projectDirectory;let D;t[28]!==N||t[29]!==P?(D=[N,P],t[28]=N,t[29]=P,t[30]=D):D=t[30],a.useEffect(j,D);let V;e:{if(!u?.all){let Ee;t[31]===Symbol.for("react.memo_cache_sentinel")?(Ee=[],t[31]=Ee):Ee=t[31],V=Ee;break e}let ve;t[32]!==u.all?(ve=u.all.filter(Qv).sort(),t[32]=u.all,t[33]=ve):ve=t[33],V=ve}const B=V;let _;e:{if(!u?.all){let Ee;t[34]===Symbol.for("react.memo_cache_sentinel")?(Ee=[],t[34]=Ee):Ee=t[34],_=Ee;break e}let ve;t[35]!==u.all?(ve=u.all.filter(Jv).map(ew).sort(),t[35]=u.all,t[36]=ve):ve=t[36],_=ve}const F=_,X=d?.current??null,oe=p.contexts[0]?.primaryRemote,ne=oe?u?.defaultBranches?.[oe]:void 0;let A;t[37]!==p.contexts[0]||t[38]!==p.read?.repository.remotes||t[39]!==X||t[40]!==ne||t[41]!==B||t[42]!==M||t[43]!==W?.createdFromBranch?(A=()=>Mg({remoteNames:new Set(p.contexts[0]?.primaryRemote?[p.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(p.read?.repository.remotes.map(tw)??[]),localBranches:B,worktreeCreatedFromBranch:W?.createdFromBranch,rootBranchHint:M,defaultBranch:ne,headBranch:X,fallbackToConventional:!1}),t[37]=p.contexts[0],t[38]=p.read?.repository.remotes,t[39]=X,t[40]=ne,t[41]=B,t[42]=M,t[43]=W?.createdFromBranch,t[44]=A):A=t[44],W?.createdFromBranch;let te;t[45]!==A?(te=A(),t[45]=A,t[46]=te):te=t[46];const U=te,Pe=Ju(o??null)?.provider;if(!o){let ve;t[47]===Symbol.for("react.memo_cache_sentinel")?(ve=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[47]=ve):ve=t[47];let Ee;t[48]!==Pe||t[49]!==e?(Ee=e(an("gitView.pullRequest.title",Pe)),t[48]=Pe,t[49]=e,t[50]=Ee):Ee=t[50];let L;t[51]!==Ee?(L=n.jsx("div",{className:"typography-ui-header text-foreground",children:Ee}),t[51]=Ee,t[52]=L):L=t[52];let le;t[53]!==Pe||t[54]!==e?(le=e(an("gitView.pullRequest.createHint",Pe)),t[53]=Pe,t[54]=e,t[55]=le):le=t[55];let G;t[56]!==le?(G=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:le}),t[56]=le,t[57]=G):G=t[57];let se;return t[58]!==L||t[59]!==G?(se=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[ve,L,G]}),t[58]=L,t[59]=G,t[60]=se):se=t[60],se}if(i===!1&&f!==!0){let ve;t[61]!==o||t[62]!==g?(ve=()=>{g(o,{force:!0})},t[61]=o,t[62]=g,t[63]=ve):ve=t[63];let Ee;return t[64]!==o||t[65]!==f||t[66]!==l||t[67]!==i||t[68]!==ve?(Ee=n.jsx(Ag,{root:o,rootIsGitRepo:i,resolvedIsGitRepo:f,nestedRepos:l,onRetryDiscovery:ve}),t[64]=o,t[65]=f,t[66]=l,t[67]=i,t[68]=ve,t[69]=Ee):Ee=t[69],Ee}if(!X){let ve;t[70]===Symbol.for("react.memo_cache_sentinel")?(ve=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[70]=ve):ve=t[70];let Ee;t[71]!==Pe||t[72]!==e?(Ee=e(an("gitView.pullRequest.title",Pe)),t[71]=Pe,t[72]=e,t[73]=Ee):Ee=t[73];let L;t[74]!==Ee?(L=n.jsx("div",{className:"typography-ui-header text-foreground",children:Ee}),t[74]=Ee,t[75]=L):L=t[75];let le;t[76]!==Pe||t[77]!==e?(le=e(an("gitView.pullRequest.createHint",Pe)),t[76]=Pe,t[77]=e,t[78]=le):le=t[78];let G;t[79]!==le?(G=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:le}),t[79]=le,t[80]=G):G=t[80];let se;return t[81]!==L||t[82]!==G?(se=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[ve,L,G]}),t[81]=L,t[82]=G,t[83]=se):se=t[83],se}const xe=i===!1&&Array.isArray(l)&&l.length>0;let ce;t[84]!==o||t[85]!==c||t[86]!==l||t[87]!==b||t[88]!==xe?(ce=xe?n.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:n.jsx(Og,{repositories:l,selectedRepository:c??null,onSelectRepository:ve=>{o&&b(o,ve)},repositoryRoot:o??void 0})}):null,t[84]=o,t[85]=c,t[86]=l,t[87]=b,t[88]=xe,t[89]=ce):ce=t[89];const Oe=c??o,me=d?.tracking??void 0,ie=d?.ahead??0;let q;t[90]!==U||t[91]!==X||t[92]!==F||t[93]!==Oe||t[94]!==me||t[95]!==ie?(q=n.jsx(Or,{as:Ry,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx(Vv,{directory:Oe,branch:X,baseBranch:U,trackingBranch:me,ahead:ie,remoteBranches:F})}),t[90]=U,t[91]=X,t[92]=F,t[93]=Oe,t[94]=me,t[95]=ie,t[96]=q):q=t[96];let ue;return t[97]!==ce||t[98]!==q?(ue=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ce,q]}),t[97]=ce,t[98]=q,t[99]=ue):ue=t[99],ue};function Gv(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function qv(t){return t.currentSessionId}function Yv(t){return t.newSessionDraft}function Xv(t){return t.worktreeMetadata}function Zv(t){return t.availableWorktrees}function Qv(t){return!t.startsWith("remotes/")}function Jv(t){return t.startsWith("remotes/")}function ew(t){return t.replace(/^remotes\//,"")}function tw(t){return t.name}const Mo=new Map,sw=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},nw=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},rw=(t,e)=>{if(e.length===0)return Mo;const s=new Set(e),r=new Map,o=new Map;for(const i of t)for(const c of i.session){if(!s.has(c.id))continue;const l=c.title?.trim();if(!l)continue;const d=nw(c),u=r.get(c.id);u!==void 0&&u>d||(r.set(c.id,d),o.set(c.id,l))}return o.size===0?Mo:o},cl=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,_c=60,ow=t=>{try{return new URL(t).origin}catch{return""}},Ti=new Set,np=Vr()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const i=ow(s);!i||!r||e().byOrigin[i]||Ti.has(i)||(Ti.add(i),Wn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(c=>{const l=typeof c?.dataUrl=="string"?c.dataUrl:"";l&&t(d=>{const u={...d.byOrigin,[i]:l},f=Object.keys(u);if(f.length<=_c)return{byOrigin:u};for(const p of f.slice(0,f.length-_c))delete u[p];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{Ti.delete(i)}))}})),dl=t=>t,pa=t=>{const e=dl(t).type;return typeof e=="string"?e:""},iw=t=>{const e=dl(t).tool;return typeof e=="string"?e:""},aw=t=>{const e=dl(t).text;return typeof e=="string"?e:""},lw=t=>{const e=pa(t);return e==="tool"?iw(t).trim().toLowerCase()||"tool":e||"unknown"},cw=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=lw(s);e.includes(r)||e.push(r)}return e.join(" + ")},dw=t=>t.replace(/\s+/g," ").trim(),uw=t=>{for(const s of t)if(pa(s)==="text"){const r=dw(aw(s));if(r.length===0)continue;return r}const e=t.filter(s=>pa(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},fw=(t,e,s)=>`${s(t)} / ${s(e)}`,pw=t=>{if(t==="12h")return!0;if(t==="24h")return!1},hw=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=pw(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===!1?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},ha={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},po={user:0,assistant:0,tool:0,other:0},bn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,$c=t=>{const e=t.info.tokens,s=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof s=="number")return{...ha,total:bn(s)};if(!s||typeof s!="object")return ha;const r=s,o=bn(r.input),i=bn(r.output),c=bn(r.reasoning),l=bn(r.cache?.read),d=bn(r.cache?.write),u=bn(r.total);return{input:o,output:i,reasoning:c,cacheRead:l,cacheWrite:d,total:u>0?u:o+i+c+l+d}},mw=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Rs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+Rs(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+Rs(s),0):0,gw=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...po,assistant:Rs(s.text)+Rs(s.content)};const o=mw(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Rs(s.input)+Rs(s.output)+Rs(s.error)+Rs(s.call?.input)+Rs(s.call?.output)+Rs(s.call?.error)+Rs(s.raw)+Math.round(Rs(s.metadata)*.25)+Math.round(Rs(s.state)*.1)+Math.round((km(t)??0)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},zc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),bw=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",yw=(t,e)=>{if(t.length===0)return{...po};const s=t.reduce((r,o)=>{const i=bw(o);let c={...po};for(const l of o.parts)c=zc(c,gw(l,i));return zc(r,c)},{...po});return s.user+=e.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},Mn=t=>t.toLocaleString(af()),xw=(t,e)=>!t||!Number.isFinite(t)?"-":Oy(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Sw=(t,e,s)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===s);return{providerName:r?.name||e||"-",modelName:o?.name||s||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},vw=()=>{const t=Je.c(219),{t:e}=Ct(),s=Bg(),r=de(ww);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,c]=a.useState(o),[l,d]=a.useState(null),u=a.useRef(null),f=xt(kw),p=xt(jw),m=Ny(p??void 0),g=My(f??"",p??void 0),b=ns(Cw);let v;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),c(Pw),d(null)},t[1]=v):v=t[1];let x;t[2]!==p||t[3]!==f?(x=[p,f],t[2]=p,t[3]=f,t[4]=x):x=t[4],a.useEffect(v,x);let y,h;t[5]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},h=[],t[5]=y,t[6]=h):(y=t[5],h=t[6]),a.useEffect(y,h);let S;t[7]===Symbol.for("react.memo_cache_sentinel")?(S=async(We,$e)=>{(await ei($e)).ok?(d(We),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(jt=>jt===We?null:jt),u.current=null},2e3)):d(null)},t[7]=S):S=t[7];const w=S;let C;t[8]!==f||t[9]!==m?(C=f?m.find(We=>We.id===f)??null:null,t[8]=f,t[9]=m,t[10]=C):C=t[10];const k=C;let T,O,K,R,I,N,W;if(t[11]!==g){T=g.filter(Ew),W=g.filter(Iw);const We=of(g.map(Tw));K=We?g[We.index]??null:null,R=We?.state==="compacted";let $e;t[19]!==K?(N=K?$c(K):ha,$e=Ay({input:N.input,cache:{read:N.cacheRead,write:N.cacheWrite}}),t[19]=K,t[20]=$e,t[21]=N):($e=t[20],N=t[21]),O=$e,I=T.reduce(Dw,0),t[11]=g,t[12]=T,t[13]=O,t[14]=K,t[15]=R,t[16]=I,t[17]=N,t[18]=W}else T=t[12],O=t[13],K=t[14],R=t[15],I=t[16],N=t[17],W=t[18];const z=I,H=K?.info??null,M=b,Y=H?.providerID||"",j=H?.modelID||"";let P;t[22]!==j||t[23]!==M||t[24]!==Y?(P=Sw(M,Y,j),t[22]=j,t[23]=M,t[24]=Y,t[25]=P):P=t[25];const D=P,V=D.contextLimit,B=R?null:V&&V>0?Math.min(999,N.total/V*100):0;let _;if(t[26]!==g){const We=[...g].reverse().find(Rw),$e=We?.info.role==="system"?We.info.text:"";_=yw(g,$e),t[26]=g,t[27]=_}else _=t[27];const F=_,X=F.user,oe=F.assistant,ne=F.tool,A=Math.max(0,N.input-X-oe-ne),te=X+oe+ne+A,U=g[0]?.info?.time?.created,Pe=g.length>0?g[g.length-1]?.info?.time?.created:null;let xe;t[28]!==k?.title||t[29]!==e?(xe=k?.title||e("contextSidebar.session.untitled"),t[28]=k?.title,t[29]=e,t[30]=xe):xe=t[30];const ce=k?.time?.created??U??null,Oe=Pe??k?.time?.created??null;let me;t[31]!==oe||t[32]!==A||t[33]!==ne||t[34]!==X?(me={user:X,assistant:oe,tool:ne,other:A},t[31]=oe,t[32]=A,t[33]=ne,t[34]=X,t[35]=me):me=t[35];let ie;t[36]!==T.length||t[37]!==te||t[38]!==O||t[39]!==V||t[40]!==D||t[41]!==g.length||t[42]!==xe||t[43]!==ce||t[44]!==Oe||t[45]!==me||t[46]!==N||t[47]!==z||t[48]!==B||t[49]!==W.length?(ie={sessionTitle:xe,messagesCount:g.length,userMessagesCount:W.length,assistantMessagesCount:T.length,createdAt:ce,lastActivityAt:Oe,providerModel:D,tokenBreakdown:N,usagePercent:B,cacheHitRate:O,totalAssistantCost:z,contextLimit:V,breakdown:me,breakdownTotal:te},t[36]=T.length,t[37]=te,t[38]=O,t[39]=V,t[40]=D,t[41]=g.length,t[42]=xe,t[43]=ce,t[44]=Oe,t[45]=me,t[46]=N,t[47]=z,t[48]=B,t[49]=W.length,t[50]=ie):ie=t[50];const q=ie;if(!f){let We;t[51]!==e?(We=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=We):We=t[52];let $e;return t[53]!==We?($e=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:We}),t[53]=We,t[54]=$e):$e=t[54],$e}let ue;t[55]!==e?(ue=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=ue):ue=t[56];let ve;t[57]!==ue||t[58]!==q.breakdown.user?(ve={key:"user",label:ue,value:q.breakdown.user,color:"var(--status-success)"},t[57]=ue,t[58]=q.breakdown.user,t[59]=ve):ve=t[59];let Ee;t[60]!==e?(Ee=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=Ee):Ee=t[61];let L;t[62]!==Ee||t[63]!==q.breakdown.assistant?(L={key:"assistant",label:Ee,value:q.breakdown.assistant,color:"var(--primary-base)"},t[62]=Ee,t[63]=q.breakdown.assistant,t[64]=L):L=t[64];let le;t[65]!==e?(le=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=le):le=t[66];let G;t[67]!==le||t[68]!==q.breakdown.tool?(G={key:"tool",label:le,value:q.breakdown.tool,color:"var(--status-warning)"},t[67]=le,t[68]=q.breakdown.tool,t[69]=G):G=t[69];let se;t[70]!==e?(se=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=se):se=t[71];let je;t[72]!==se||t[73]!==q.breakdown.other?(je={key:"other",label:se,value:q.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=se,t[73]=q.breakdown.other,t[74]=je):je=t[74];let he;t[75]!==ve||t[76]!==L||t[77]!==G||t[78]!==je?(he=[ve,L,G,je],t[75]=ve,t[76]=L,t[77]=G,t[78]=je,t[79]=he):he=t[79];const ge=he;let ke;t[80]!==s||t[81]!==q.sessionTitle?(ke=s?n.jsx(Fg,{children:n.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:q.sessionTitle,children:q.sessionTitle})})}):null,t[80]=s,t[81]=q.sessionTitle,t[82]=ke):ke=t[82];let Ae;t[83]!==s||t[84]!==q.sessionTitle?(Ae=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:q.sessionTitle}),t[83]=s,t[84]=q.sessionTitle,t[85]=Ae):Ae=t[85];const $=!s&&"mt-1";let fe;t[86]!==$?(fe=Te($,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70"),t[86]=$,t[87]=fe):fe=t[87];let be;t[88]!==q.providerModel.modelName||t[89]!==q.providerModel.providerName?(be=n.jsxs("span",{children:[q.providerModel.providerName," / ",q.providerModel.modelName]}),t[88]=q.providerModel.modelName,t[89]=q.providerModel.providerName,t[90]=be):be=t[90];let Ie;t[91]!==r||t[92]!==q.createdAt?(Ie=q.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:xw(q.createdAt,r)})]}),t[91]=r,t[92]=q.createdAt,t[93]=Ie):Ie=t[93];let Ye;t[94]!==fe||t[95]!==be||t[96]!==Ie?(Ye=n.jsxs("div",{className:fe,children:[be,Ie]}),t[94]=fe,t[95]=be,t[96]=Ie,t[97]=Ye):Ye=t[97];let nt;t[98]!==Ae||t[99]!==Ye?(nt=n.jsxs("div",{className:"mb-6",children:[Ae,Ye]}),t[98]=Ae,t[99]=Ye,t[100]=nt):nt=t[100];let Ue;t[101]!==e?(Ue=e("contextSidebar.section.context"),t[101]=e,t[102]=Ue):Ue=t[102];let Ve;t[103]!==Ue?(Ve=n.jsx("span",{className:"typography-micro text-muted-foreground",children:Ue}),t[103]=Ue,t[104]=Ve):Ve=t[104];let Se;t[105]!==q.tokenBreakdown.total||t[106]!==q.usagePercent?(Se=q.usagePercent===null?"—":Mn(q.tokenBreakdown.total),t[105]=q.tokenBreakdown.total,t[106]=q.usagePercent,t[107]=Se):Se=t[107];let ye;t[108]!==q.contextLimit?(ye=q.contextLimit?` / ${Mn(q.contextLimit)}`:"",t[108]=q.contextLimit,t[109]=ye):ye=t[109];let Ge;t[110]!==Se||t[111]!==ye?(Ge=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Se,ye]}),t[110]=Se,t[111]=ye,t[112]=Ge):Ge=t[112];let qe;t[113]!==Ve||t[114]!==Ge?(qe=n.jsxs("div",{className:"flex items-baseline justify-between",children:[Ve,Ge]}),t[113]=Ve,t[114]=Ge,t[115]=qe):qe=t[115];let ft;t[116]!==q.usagePercent?(ft=q.usagePercent!==null&&q.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,q.usagePercent)}%`,backgroundColor:q.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=q.usagePercent,t[117]=ft):ft=t[117];let et;t[118]!==ft?(et=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ft}),t[118]=ft,t[119]=et):et=t[119];let St;t[120]!==e||t[121]!==q.usagePercent?(St=q.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:q.usagePercent.toFixed(1)}),t[120]=e,t[121]=q.usagePercent,t[122]=St):St=t[122];let we;t[123]!==St?(we=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:St}),t[123]=St,t[124]=we):we=t[124];let De;t[125]!==qe||t[126]!==et||t[127]!==we?(De=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[qe,et,we]}),t[125]=qe,t[126]=et,t[127]=we,t[128]=De):De=t[128];let ot;t[129]!==e?(ot=e("contextSidebar.stats.messages"),t[129]=e,t[130]=ot):ot=t[130];let rt;t[131]!==q.messagesCount?(rt=Mn(q.messagesCount),t[131]=q.messagesCount,t[132]=rt):rt=t[132];let Xe;t[133]!==ot||t[134]!==rt?(Xe={label:ot,value:rt},t[133]=ot,t[134]=rt,t[135]=Xe):Xe=t[135];let ht;t[136]!==e?(ht=e("contextSidebar.stats.user"),t[136]=e,t[137]=ht):ht=t[137];let ee;t[138]!==q.userMessagesCount?(ee=Mn(q.userMessagesCount),t[138]=q.userMessagesCount,t[139]=ee):ee=t[139];let _e;t[140]!==ht||t[141]!==ee?(_e={label:ht,value:ee},t[140]=ht,t[141]=ee,t[142]=_e):_e=t[142];let Be;t[143]!==e?(Be=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=Be):Be=t[144];let Ke;t[145]!==q.assistantMessagesCount?(Ke=Mn(q.assistantMessagesCount),t[145]=q.assistantMessagesCount,t[146]=Ke):Ke=t[146];let Fe;t[147]!==Be||t[148]!==Ke?(Fe={label:Be,value:Ke},t[147]=Be,t[148]=Ke,t[149]=Fe):Fe=t[149];let tt;t[150]!==e?(tt=e("contextSidebar.stats.cost"),t[150]=e,t[151]=tt):tt=t[151];let bt;t[152]!==q.totalAssistantCost?(bt=Kf(q.totalAssistantCost),t[152]=q.totalAssistantCost,t[153]=bt):bt=t[153];let mt;t[154]!==tt||t[155]!==bt?(mt={label:tt,value:bt},t[154]=tt,t[155]=bt,t[156]=mt):mt=t[156];let it;t[157]!==Xe||t[158]!==_e||t[159]!==Fe||t[160]!==mt?(it=[Xe,_e,Fe,mt],t[157]=Xe,t[158]=_e,t[159]=Fe,t[160]=mt,t[161]=it):it=t[161];const Tt=it;let at;t[162]!==Tt?(at=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Tt.map(Nw)}),t[162]=Tt,t[163]=at):at=t[163];let $t;t[164]!==e?($t=e("contextSidebar.section.lastAssistantMessage"),t[164]=e,t[165]=$t):$t=t[165];let zt;t[166]!==$t?(zt=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:$t}),t[166]=$t,t[167]=zt):zt=t[167];let Mt;t[168]!==e||t[169]!==q.cacheHitRate.hasInput||t[170]!==q.cacheHitRate.percent||t[171]!==q.tokenBreakdown.cacheRead||t[172]!==q.tokenBreakdown.cacheWrite||t[173]!==q.tokenBreakdown.input||t[174]!==q.tokenBreakdown.output||t[175]!==q.tokenBreakdown.reasoning?(Mt=n.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:q.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:q.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:q.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:q.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:q.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:q.cacheHitRate.hasInput?q.cacheHitRate.percent:null,format:"percent"}].map(Mw)}),t[168]=e,t[169]=q.cacheHitRate.hasInput,t[170]=q.cacheHitRate.percent,t[171]=q.tokenBreakdown.cacheRead,t[172]=q.tokenBreakdown.cacheWrite,t[173]=q.tokenBreakdown.input,t[174]=q.tokenBreakdown.output,t[175]=q.tokenBreakdown.reasoning,t[176]=Mt):Mt=t[176];let Re;t[177]!==zt||t[178]!==Mt?(Re=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[zt,Mt]}),t[177]=zt,t[178]=Mt,t[179]=Re):Re=t[179];let ct;t[180]!==ge||t[181]!==q.breakdownTotal?(ct=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ge.map(We=>We.value<=0||q.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${We.value/q.breakdownTotal*100}%`,backgroundColor:We.color}},We.key))}),t[180]=ge,t[181]=q.breakdownTotal,t[182]=ct):ct=t[182];let lt;t[183]!==ge||t[184]!==q.breakdownTotal?(lt=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:ge.map(We=>{const $e=q.breakdownTotal>0?We.value/q.breakdownTotal*100:0;return n.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:We.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[We.label," ",n.jsxs("span",{className:"tabular-nums",children:[$e.toFixed(0),"%"]})]})]},We.key)})}),t[183]=ge,t[184]=q.breakdownTotal,t[185]=lt):lt=t[185];let dt;t[186]!==ct||t[187]!==lt?(dt=n.jsxs("div",{className:"mb-6",children:[ct,lt]}),t[186]=ct,t[187]=lt,t[188]=dt):dt=t[188];let st;t[189]!==e?(st=e("contextSidebar.section.rawMessages"),t[189]=e,t[190]=st):st=t[190];let wt;t[191]!==st?(wt=n.jsx("div",{className:"typography-micro text-muted-foreground",children:st}),t[191]=st,t[192]=wt):wt=t[192];let pt;if(t[193]!==l||t[194]!==i||t[195]!==g||t[196]!==e||t[197]!==r){let We;t[199]!==l||t[200]!==i||t[201]!==e||t[202]!==r?(We=$e=>{const kt=$e.info.role,jt=kt==="assistant",Et=kt==="user",Lt=i[$e.info.id]===!0,Yt=l===$e.info.id,is=$e.info.time?.created??null,Wt=cw($e.parts),rs=jt?$c({info:$e.info,parts:$e.parts}):null,as=Et?uw($e.parts):"",Ss=hw(is,r),Me=Wt||"—",pe=rs?fw(rs.input,rs.output,Mn):"",Le=kt||"unknown",yt=Wt?`${Le}: ${Wt}`:Le,Rt=Lt?JSON.stringify({info:$e.info,parts:$e.parts},null,2):"";return n.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[n.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":Lt,onClick:()=>{c(Nt=>({...Nt,[$e.info.id]:Nt[$e.info.id]!==!0}))},children:n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:jt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Et?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",as]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:jt?Me:yt}),jt&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:pe})]}),n.jsx("span",{className:"text-end text-muted-foreground",children:Ss})]})}),Lt&&n.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:n.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[n.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:Nt=>{Nt.stopPropagation(),w($e.info.id,Rt)},"aria-label":e(Yt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(Yt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:Yt?n.jsx(Z,{name:"check",className:"size-3.5"}):n.jsx(Z,{name:"file-copy",className:"size-3.5"})})}),n.jsx(By,{language:"json",code:Rt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},$e.info.id)},t[199]=l,t[200]=i,t[201]=e,t[202]=r,t[203]=We):We=t[203],pt=[...g].reverse().map(We),t[193]=l,t[194]=i,t[195]=g,t[196]=e,t[197]=r,t[198]=pt}else pt=t[198];let E;t[204]!==pt?(E=n.jsx("div",{className:"mt-2.5 space-y-1",children:pt}),t[204]=pt,t[205]=E):E=t[205];let Q;t[206]!==wt||t[207]!==E?(Q=n.jsxs("div",{children:[wt,E]}),t[206]=wt,t[207]=E,t[208]=Q):Q=t[208];let Ne;t[209]!==nt||t[210]!==De||t[211]!==at||t[212]!==Re||t[213]!==dt||t[214]!==Q?(Ne=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[nt,De,at,Re,dt,Q]}),t[209]=nt,t[210]=De,t[211]=at,t[212]=Re,t[213]=dt,t[214]=Q,t[215]=Ne):Ne=t[215];let Ce;return t[216]!==ke||t[217]!==Ne?(Ce=n.jsxs(Or,{outerClassName:"h-full",className:"bg-background",children:[ke,Ne]}),t[216]=ke,t[217]=Ne,t[218]=Ce):Ce=t[218],Ce};function ww(t){return t.timeFormatPreference}function kw(t){return t.currentSessionId}function jw(t){return t.currentSessionDirectory}function Cw(t){return t.providers}function Pw(t){return Object.keys(t).length>0?{}:t}function Ew(t){return t.info.role==="assistant"}function Iw(t){return t.info.role==="user"}function Tw(t){return t.info}function Dw(t,e){const s=bn(e.info.cost);return t+s}function Rw(t){return t.info.role==="system"}function Nw(t){return n.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[n.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function Mw(t){return n.jsxs("div",{children:[n.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),n.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)}%`:Mn(t.value):"—"})]},t.label)}const rp=(t,e,s,r=t.currentTarget)=>{t.key!=="Escape"||!e||t.target instanceof Node&&!(r??t.currentTarget).contains(t.target)||Fy(t.target)||Ly(t.target)||t.defaultPrevented||(t.preventDefault(),t.stopPropagation(),s())},Aw=280,Ow=.28,Bw=240,Fw=.35,Lw=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,c=s?s.top:i-Math.min(Bw,e.height*Fw),l=Math.min(Aw,t.width*Ow,e.width/4),d=e.left-t.left>=1,u=r-o>=1,f=Math.max(0,c-t.top),p=d?e.left:t.left+l,m=u?o:r-l;return{left:{left:t.left,top:t.top,width:p-t.left,height:d?t.height:f},right:{left:m,top:t.top,width:r-m,height:u?t.height:f},bottom:{left:e.left,top:c,width:e.width,height:Math.max(0,i-c)}}},Di=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,_w=(t,e)=>Di(t.bottom,e)?"bottom":Di(t.left,e)?"left":Di(t.right,e)?"right":null,un=Vr(()=>({drag:null,hovered:null})),ho=t=>{if(!t)return null;const{left:e,top:s,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:s,width:r,height:o}:null},Ri=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),Ni=t=>ho(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),op=t=>{const e=ho(document.querySelector("[data-workspace-row]")),s=ho(document.querySelector("[data-workspace-chat]"));if(!e||!s)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=Lw(e,s,ho(r)),i={left:Ni("left")??Ri(o.left),right:Ni("right")??Ri(o.right),bottom:Ni("bottom")??Ri(o.bottom)};return un.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},ip=t=>{const{drag:e,hovered:s}=un.getState();if(!e)return;const r=_w(e.targets,t);r!==s&&un.setState({hovered:r})},ma=()=>{un.getState().drag&&un.setState({drag:null,hovered:null})},ap=t=>{const{drag:e,hovered:s}=un.getState();if(un.setState({drag:null,hovered:null}),!e||!s)return!1;const r=de.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?Cs(t):"";if(o){const i=de.getState();Ba(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},ul=(t,e)=>{let s=!1;const r=i=>{const c={x:i.clientX,y:i.clientY};e(c)?(s||(s=op(t)),s&&ip(c)):s&&(ma(),s=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),s?(ap(i),!0):!1),cancel:()=>{o(),s&&ma()}}},Kc={left:null,right:null,bottom:null},Rr=Vr(()=>({body:Kc,headerSlot:Kc})),lp=(t,e,s)=>{const r=Rr.getState()[t];r[e]!==s&&Rr.setState({[t]:{...r,[e]:s}})},$w=(t,e)=>lp("body",t,e),zw=(t,e)=>lp("headerSlot",t,e),Cr=t=>{const e=a.useRef(t);e.current=t;const[s,r]=a.useState(t),o=a.useCallback(()=>r(e.current),[]);return a.useLayoutEffect(()=>{Ga(o)},[t,o]),a.useEffect(()=>()=>lf(o),[o]),t||s},Kw=Br(()=>ss(()=>import("./GitView-HXttTpUw.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,124])).then(t=>({default:t.GitView}))),cp=320,dp=600,up=400,Ww=100,Hw=24,Vw=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Wc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(cp,Math.round(t))):dp,Uw=t=>t===null?Number.POSITIVE_INFINITY:Math.max(cp,t-up),Gw=(t,e)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&s.startsWith(r+"/")?s.slice(r.length+1):s},mo=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):tr(t)?Ua.getState().guests.find(r=>r.id===ko(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),qw=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const s=e.split("/").filter(Boolean);return s.length===0?e:s[s.length-1]||null},Yw=(t,e,s)=>{if(t.mode==="chat"){const r=cl(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||s("contextPanel.mode.chat")}return t.mode==="browser"?qo(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?qw(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):mo(t.mode,s)},Xw=t=>{const e=Je.c(8),{mode:s}=t,r=Za();let o;if(e[0]!==s||e[1]!==r){let u;e[3]!==s?(u=f=>f.mode===s,e[3]=s,e[4]=u):u=e[4],o=r.find(u),e[0]=s,e[1]=r,e[2]=o}else o=e[2];const i=o,c=i?.icon??zy,l=i?.iconSrc;let d;return e[5]!==c||e[6]!==l?(d=n.jsx(dr,{icon:c,iconSrc:l,className:"h-3.5 w-3.5"}),e[5]=c,e[6]=l,e[7]=d):d=e[7],d},Hc=(t,e={})=>{if(t.mode==="file")return t.targetPath?n.jsx(Xa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(vu,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(Z,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(Z,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(Z,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="notes")return n.jsx(Z,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(Z,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(Z,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return n.jsx(Z,{name:"chat-4",className:"h-3.5 w-3.5"});if(tr(t.mode))return n.jsx(Xw,{mode:t.mode});if(t.mode==="browser"){const s=Zw(t.targetPath??"",e);return s?n.jsx("img",{src:s,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):n.jsx(Z,{name:"global",className:"h-3.5 w-3.5"})}},Zw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Qw=t=>{const e=Fr(),s=a.useRef(Mo),r=a.useRef(t);r.current=t;const o=t.length>0;return a.useSyncExternalStore(a.useCallback(i=>o?e.subscribeAllSelected(c=>c.session,i):()=>{},[e,o]),a.useCallback(()=>{const i=Array.from(e.children.values(),l=>l.getState()),c=rw(i,r.current);return sw(s.current,c)?s.current:(s.current=c,c)},[e]),()=>Mo)},Jw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,e0=8,t0='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',s0=t=>t==="context"||t==="git"||t==="pr"||t==="notes",fp=320,pp=160,hp=200,n0={right:{axis:"x",gutter:"mb-2 ms-2 me-1.5",gutterSize:"0.875rem",expanded:"absolute inset-y-0 inset-e-0 z-20 min-w-0",handle:"absolute bottom-2 inset-s-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},left:{axis:"x",gutter:"mb-2 ms-1.5 me-2",gutterSize:"0.875rem",expanded:"absolute inset-y-0 inset-s-0 z-20 min-w-0",handle:"absolute bottom-2 inset-e-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},bottom:{axis:"y",gutter:"mb-2 mt-2",gutterSize:"1rem",expanded:"absolute inset-x-0 bottom-0 z-20 min-h-0",handle:"absolute inset-x-0 top-1 z-50 h-2 cursor-row-resize",sizeVariable:"--oc-context-panel-height"}},Vc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(pp,Math.round(t))):fp,r0=t=>t===null?Number.POSITIVE_INFINITY:Math.max(pp,t-hp),Mi=({zone:t="right"})=>{const e=n0[t],s=Jo(),r=e.axis==="y",{t:o,direction:i}=Ct(),c=i==="rtl",l=fn()??"",d=cf(l||null),u=a.useCallback((E,Q)=>o(an(E,d),Q),[d,o]),f=a.useMemo(()=>Vw(l),[l]),p=de(E=>f?E.contextPanelByDirectory[f]:void 0),m=de(E=>E.contextSurfaceZones),g=de(E=>E.closeContextZone),b=de(E=>E.closeContextPanelTab),v=de(E=>E.pinContextPanelTab),x=de(E=>E.toggleContextPanelExpanded),y=de(E=>E.setContextPanelWidth),h=de(E=>E.setContextPanelHeight),S=de(E=>E.setActiveContextPanelTab),w=de(E=>E.reorderContextPanelTabs),C=de(E=>E.contextEditorTreeVisible),k=de(E=>E.contextEditorTreeWidth),T=de(E=>E.setContextEditorTreeWidth),O=de(E=>E.toggleContextEditorTree),K=de(E=>E.contextEditorVisible),R=de(E=>E.toggleContextEditor),I=de(E=>E.fileTreeSide),N=de(E=>E.openNewContextBrowserTab),W=np(E=>E.byOrigin),[z,H]=a.useState(null),M=a.useCallback(E=>{H(E),zw(t,E)},[t]),Y=a.useCallback(E=>{$w(t,E)},[t]),j=a.useMemo(()=>p?.tabs??[],[p?.tabs]),P=p?wo(p,m,t):null,D=p?Go(p,t):jm,V=ta(E=>E.workStatusReserved),B=ta(E=>E.chatCovered),_=t==="bottom"&&B,F=!!(D.isOpen&&P)&&!_,X=a.useMemo(()=>j.some(E=>E.mode==="file"&&E.targetPath),[j]),oe=X&&(K||!C),ne=P?.mode??null,A=!r&&ne==="file"&&!oe,te=!!(F&&D.expanded&&!A),U=ne?r?p?.heightByMode?.[ne]:p?.widthByMode?.[ne]:void 0,Pe=A?k:r?Vc(U??fp,Number.POSITIVE_INFINITY):Wc(U??(ne?sa(ne):dp),Number.POSITIVE_INFINITY),xe=a.useCallback((E,Q)=>r?Vc(E,r0(Q)):Wc(E,Uw(Q)),[r]),ce=r?hp:up,Oe=t==="right"?"left":t==="left"?"right":null,me=de(E=>{if(!Oe||!f)return 0;const Q=E.contextPanelByDirectory[f],Ne=Q&&vr(Q,E.contextSurfaceZones,Oe)?wo(Q,E.contextSurfaceZones,Oe):null;if(!Q||!Ne)return 0;const Ce=Q.tabs.some(We=>We.mode==="file"&&We.targetPath)&&(E.contextEditorVisible||!E.contextEditorTreeVisible);return Ne.mode==="file"&&!Ce?E.contextEditorTreeWidth:Q.widthByMode[Ne.mode]??sa(Ne.mode)}),ie=Oe==="right"&&V&&!B&&me===0?wi:me,[q,ue]=a.useState(null),ve=a.useRef(null),Ee=a.useRef(ie);Ee.current=ie;const L=a.useRef(()=>!1);L.current=E=>te||!A&&E-Ee.current-ce<Pe;const le=a.useCallback(()=>{const E=ve.current;ue(E!==null&&L.current(E)?E:null)},[]),G=q!==null?q-ie:null,se=t==="left"?q:G,je=A?Pe:xe(Pe,G),he=F&&P?.mode==="chat",ge=a.useMemo(()=>{const E=[];if(!he)return E;for(const Q of j){if(Q.mode!=="chat")continue;const Ne=cl(Q.dedupeKey);Ne&&!E.includes(Ne)&&E.push(Ne)}return E},[he,j]),ke=Qw(ge),[Ae,$]=a.useState(!1),fe=a.useRef(0),be=a.useRef(je),Ie=a.useRef(null),Ye=a.useRef(null),nt=a.useRef(null),Ue=a.useRef(!1);a.useLayoutEffect(()=>{const E=r?nt.current?.parentElement:nt.current?.closest("[data-workspace-row]");if(!E||typeof ResizeObserver>"u")return;const Q=new ResizeObserver(Ne=>{const Ce=Ne[Ne.length-1]?.contentRect,We=r?Ce?.height:Ce?.width;ve.current=We?Math.round(We):null,Ga(le)});return Q.observe(E),ve.current=(r?E.clientHeight:E.clientWidth)||null,le(),()=>{Q.disconnect(),lf(le)}},[le,r]),a.useLayoutEffect(()=>{le()},[le,Pe,te,ie]),a.useEffect(()=>{if(!F||Ue.current){Ue.current=F;return}const E=window.requestAnimationFrame(()=>{nt.current?.focus({preventScroll:!0})});return Ue.current=!0,()=>window.cancelAnimationFrame(E)},[F]);const Ve=a.useRef(null),Se=a.useRef(null),ye=a.useCallback(()=>{Se.current=null;const E=nt.current,Q=Ie.current;!E||Q===null||E.style.setProperty(e.sizeVariable,`${Q}px`)},[e.sizeVariable]);a.useEffect(()=>()=>{Se.current!==null&&clearTimeout(Se.current)},[]);const Ge=a.useCallback(E=>{const Q=Ve.current,Ne=A?Gi(E):xe(E,Q);return Q===null?Ne:Math.min(Ne,Math.max(1,Q))},[xe,A]),qe=a.useCallback(E=>{if(!F||te||!f)return;Ye.current=E.pointerId,$(!0),fe.current=r?E.clientY:E.clientX,be.current=je,Ie.current=je;const Q=r?nt.current?.parentElement?.clientHeight:(nt.current?.closest("[data-workspace-row]")?.clientWidth??0)-Ee.current;Ve.current=Q&&Q>0?Q:null,document.documentElement.style.cursor=r?"row-resize":"col-resize",E.preventDefault()},[f,te,F,r,je]),ft=a.useCallback(()=>{const E=Ge(Ie.current??je);Ie.current=null,Ve.current=null,Se.current!==null&&(clearTimeout(Se.current),Se.current=null),document.documentElement.style.cursor="",A?T(E):f&&ne&&(r?h(f,ne,E):y(f,ne,E)),$(!1),Ye.current=null},[ne,Ge,f,A,r,T,h,y,je]);a.useEffect(()=>{if(!Ae)return;const E=Ce=>{if(Ye.current!==Ce.pointerId)return;const We=r?Ce.clientY:Ce.clientX,$e=t==="left"?We-fe.current:fe.current-We,kt=!r&&c?-$e:$e,jt=Ge(be.current+kt);Ie.current!==jt&&(Ie.current=jt,Se.current===null&&(Se.current=setTimeout(ye,Ww)))},Q=Ce=>{Ye.current===Ce.pointerId&&ft()},Ne=()=>{ft()};return window.addEventListener("pointermove",E),window.addEventListener("pointerup",Q),window.addEventListener("pointercancel",Q),window.addEventListener("blur",Ne),()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q),window.removeEventListener("blur",Ne)}},[ye,Ge,ft,Ae,c,r,t]),a.useEffect(()=>{Ae||(Ie.current=null,document.documentElement.style.cursor="")},[Ae]);const et=a.useCallback(()=>{f&&g(f,t)},[g,f,t]),St=a.useCallback(()=>{f&&x(f,t)},[f,x,t]),we=a.useCallback(E=>{rp(E,F,et)},[et,F]),De=P?.mode==="file"||P?.mode==="chat"||P?.mode==="browser",ot=a.useMemo(()=>P?j.filter(E=>E.mode===P.mode):[],[P,j]),rt=a.useMemo(()=>ot.map(E=>{const Q=Yw(E,ke,u),Ne=Jw(Q,Hw),Ce=Gw(E.targetPath,l);return{id:E.id,label:Ne,icon:Hc(E,W),title:Ce?`${Q}: ${Ce}`:Q,closeLabel:o("contextPanel.tab.closeTabAria",{label:Ne}),preview:E.preview}}),[ot,l,W,ke,o,u]),Xe=P?.mode==="context"?n.jsx(Yn,{value:z,children:n.jsx(vw,{})}):P?.mode==="git"?n.jsx(a.Suspense,{fallback:null,children:n.jsx(Yn,{value:z,children:n.jsx(Kw,{isActive:F})})}):P?.mode==="pr"?n.jsx(Uv,{}):P?.mode==="notes"?n.jsx(Yn,{value:z,children:n.jsx(Lg,{visible:F})}):null,ht=P?.mode==="file",ee=de(E=>E.closeContextPanelTabs),_e=a.useCallback(E=>{if(!f)return null;const{id:Q,index:Ne,allIds:Ce,close:We}=E,$e=()=>ee(f,Ce.filter(as=>as!==Q)),kt=Ce.slice(0,Ne),jt=Ce.slice(Ne+1),Et=()=>ee(f,c?jt:kt),Lt=()=>ee(f,c?kt:jt),Yt=()=>ee(f,Ce),is=Ce.length>1,Wt=c?Ne===Ce.length-1:Ne===0,rs=c?Ne===0:Ne===Ce.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(Bn,{onClick:We,children:[n.jsx(Z,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(co,{}),n.jsxs(Bn,{onClick:$e,disabled:!is,children:[n.jsx(Z,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs(Bn,{onClick:Et,disabled:Wt,children:[n.jsx(Z,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(Bn,{onClick:Lt,disabled:rs,children:[n.jsx(Z,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(co,{}),n.jsxs(Bn,{onClick:Yt,disabled:!is,children:[n.jsx(Z,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),P?n.jsxs(n.Fragment,{children:[n.jsx(co,{}),n.jsx(Su,{mode:P.mode})]}):null]})},[P,ee,f,c,o]),Be=a.useCallback((E,Q)=>{const Ne=j.find(We=>We.id===E);if(!Ne)return null;const Ce=ul({mode:Ne.mode,label:mo(Ne.mode,u),from:t},Q);return{finish:()=>Ce.finish(f),cancel:Ce.cancel}},[f,u,j,t]),[Ke,Fe]=a.useState(null),tt=a.useCallback(E=>{if(!P||E.button!==0||E.pointerType==="touch"||E.target instanceof Element&&E.target.closest(t0))return;const Q=P.mode,Ne=mo(Q,u),Ce={x:E.clientX,y:E.clientY};let We=!1;const $e=Lt=>{const Yt={x:Lt.clientX,y:Lt.clientY};!We&&(Math.hypot(Yt.x-Ce.x,Yt.y-Ce.y)<e0||(We=op({mode:Q,label:Ne,from:t}),!We))||ip(Yt)},kt=()=>{window.removeEventListener("pointermove",$e),window.removeEventListener("pointerup",jt),window.removeEventListener("pointercancel",Et),window.removeEventListener("blur",Et)},jt=()=>{kt(),We&&ap(f)},Et=()=>{kt(),We&&ma()};window.addEventListener("pointermove",$e),window.addEventListener("pointerup",jt),window.addEventListener("pointercancel",Et),window.addEventListener("blur",Et)},[P,f,u,t]);a.useEffect(()=>{if(Ke)return Ke.addEventListener("pointerdown",tt),()=>Ke.removeEventListener("pointerdown",tt)},[tt,Ke]);const bt=n.jsxs("header",{ref:Fe,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[De?n.jsx(_y,{items:rt,activeId:P?.id??null,onSelect:E=>{f&&S(f,E)},onClose:E=>{f&&b(f,E)},onReorder:(E,Q)=>{f&&w(f,E,Q)},onDoubleClickTab:E=>{f&&v(f,E)},layoutMode:"scrollable",variant:"default",tabContextMenu:_e,onTabDragOut:Be}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[P?.mode==="pr"&&d==="gitlab"?n.jsx(Z,{name:"gitlab",className:"h-3.5 w-3.5"}):P?Hc(P,W):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:P?.mode==="pr"&&d==="gitlab"?o("contextPanel.mode.mr"):P?mo(P.mode,u):null})]}),n.jsx("div",{ref:M,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[P?.mode==="browser"?n.jsx(It,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&N(f)},className:"h-7 w-7 p-0",title:o("contextPanel.browser.newTab"),"aria-label":o("contextPanel.browser.newTab"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,ht?["left","right"].map(E=>{const Q=E===I;if(!Q&&!X)return null;const Ne=o(Q?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return n.jsx(It,{type:"button",variant:"ghost",size:"sm",onClick:Q?O:R,className:"h-7 w-7 p-0",title:Ne,"aria-label":Ne,"aria-pressed":Q?C:oe,children:n.jsx(Z,{name:E==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},E)}):null,A?null:n.jsx(It,{type:"button",variant:"ghost",size:"sm",onClick:St,className:"h-7 w-7 p-0",title:o(te?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":o(te?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:te?n.jsx(Z,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(Z,{name:"fullscreen",className:"h-3.5 w-3.5"})}),n.jsx(It,{type:"button",variant:"ghost",size:"sm",onClick:et,className:"h-7 w-7 p-0",title:o("contextPanel.actions.closePanel"),"aria-label":o("contextPanel.actions.closePanel"),children:n.jsx(Z,{name:"close",className:"h-3.5 w-3.5"})})]})]}),mt=t==="right"&&V&&!B,it=se!==null?`${se}px`:"100%",Tt=F?te?it:`min(var(${e.sizeVariable}), 100%)`:mt?`${wi}px`:"0px",at=t==="bottom"&&vr(p,m,"left"),$t=t==="bottom"&&(V&&!B||vr(p,m,"right")),zt=`${F}|${te}|${mt}|${F?Pe:""}`,Mt=a.useRef(zt),Re=a.useRef(B),ct=Re.current!==B;a.useLayoutEffect(()=>{Re.current=B},[B]),a.useLayoutEffect(()=>{Mt.current!==zt&&(Mt.current=zt,ct||qu(s))},[zt,ct,s]);const lt=!Cr(F),dt=Cr(te),st=F?`${je}px`:mt?`${wi}px`:"0px",wt={[e.sizeVariable]:F&&te?it:`${je}px`,...r?{height:Tt,maxHeight:"100%"}:{width:Tt,maxWidth:"100%"},transitionDuration:ct?"0ms":`${s}ms`,transitionTimingFunction:Eo},pt=te?se!==null?`calc(${se}px - ${e.gutterSize})`:"100%":`calc(var(${e.sizeVariable}) - ${e.gutterSize})`;return n.jsxs(n.Fragment,{children:[dt?n.jsx("div",{"aria-hidden":"true",className:"flex-shrink-0",style:r?{height:st,maxHeight:"100%"}:{width:st,maxWidth:"100%"}}):null,n.jsxs("aside",{ref:nt,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":F?"true":"false",tabIndex:-1,className:Te("flex min-h-0 flex-col overflow-clip bg-background","isolate",dt?e.expanded:r?"relative w-full flex-shrink-0":"relative h-full flex-shrink-0",r?"transition-[height]":"transition-[width]","motion-reduce:transition-none"),onKeyDownCapture:we,style:wt,children:[t==="right"?n.jsx("div",{ref:$y,className:Te("absolute inset-y-0 inset-e-0 z-0 flex",B&&"invisible")}):null,F&&!te&&n.jsx("div",{className:e.handle,onPointerDown:qe,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsxs("div",{"data-zone-card":"",className:Te("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(at?"ms-0":"ms-2"),t==="bottom"&&($t?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity]",!F&&"pointer-events-none select-none opacity-0"),style:{...r?{height:pt,width:`calc(100% - ${(at?0:.5)+($t?0:.375)}rem)`}:{width:pt},transitionDuration:`${s}ms`,transitionTimingFunction:Eo},inert:lt||void 0,children:[bt,n.jsx("div",{ref:Y,className:Te("relative min-h-0 flex-1 overflow-hidden",Ae&&"pointer-events-none"),children:P&&s0(P.mode)?Xe:null})]})]})]})},o0=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"},i0=async(t,e)=>{try{const s=await Us("/api/dev-servers",{signal:t,directory:e});if(!s.ok)return{kind:"unavailable"};const r=await s.json();if(!r||typeof r!="object")return{kind:"unavailable"};const o=r.servers;return Array.isArray(o)?{kind:"ready",servers:o.filter(o0)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},a0=async t=>{try{const e=await Us("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const s=await e.json();if(!s||typeof s!="object")return null;const r=s.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},l0=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:null}catch{return null}},c0=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=l0(r);o!==null&&!s.has(o)&&s.set(o,r)}return e?e.map(r=>{const o=s.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...s.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},ga="__openchamberBrowserAnnotationActive",d0=`(() => {
3
- try {
4
- var host = document.querySelector('[data-openchamber-annotation]');
5
- if (host && host.parentNode) host.parentNode.removeChild(host);
6
- } catch (error) { /* page navigated away */ }
7
- try {
8
- var cursor = document.getElementById('openchamber-annotation-cursor');
9
- if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
10
- } catch (error) { /* page navigated away */ }
11
- try { delete window['${ga}']; } catch (error) { /* non-configurable */ }
12
- })();`,u0=(t,e)=>{const s=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
13
- var CONFIG = ${s};
14
- var THEME = CONFIG.theme;
15
- var LABELS = CONFIG.labels;
16
- var OVERLAY_ATTR = 'data-openchamber-annotation';
17
- var Z_OVERLAY = 2147483646;
18
- var MAX_TEXT = 400;
19
- var MIN_RECT = 3;
20
- var EDITOR_GAP = 10;
21
-
22
- try {
23
- var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
24
- if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
25
- } catch (error) { /* nothing to clean */ }
26
-
27
- window['${ga}'] = true;
28
-
29
- var counter = 0;
30
- var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
31
-
32
- var selected = null;
33
- var regions = [];
34
- var strokes = [];
35
- var tool = 'select';
36
- var settled = false;
37
-
38
- // ---------------------------------------------------------------- geometry
39
-
40
- var rectFrom = function (domRect) {
41
- return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
42
- };
43
- var normalizeRect = function (ax, ay, bx, by) {
44
- return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
45
- };
46
- var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
47
-
48
- // ------------------------------------------------------------- description
49
-
50
- var isOverlayNode = function (element) {
51
- var node = element;
52
- while (node) {
53
- if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
54
- node = node.parentNode || (node.host || null);
55
- }
56
- return false;
57
- };
58
-
59
- var elementFromPoint = function (x, y) {
60
- var found = document.elementFromPoint(x, y);
61
- if (!found || isOverlayNode(found)) return null;
62
- return found;
63
- };
64
-
65
- var selectorPart = function (element) {
66
- var part = element.tagName.toLowerCase();
67
- if (element.id) return part + '#' + element.id;
68
- var className = typeof element.className === 'string' ? element.className.trim() : '';
69
- if (className) {
70
- var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
71
- if (first) part += '.' + first;
72
- }
73
- return part;
74
- };
75
-
76
- var buildSelector = function (element) {
77
- if (element.id) return '#' + element.id;
78
- var parts = [];
79
- var node = element;
80
- var depth = 0;
81
- while (node && node.nodeType === 1 && depth < 5) {
82
- var part = selectorPart(node);
83
- var parent = node.parentElement;
84
- if (parent) {
85
- var siblings = Array.prototype.filter.call(parent.children, function (child) {
86
- return child.tagName === node.tagName;
87
- });
88
- if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
89
- }
90
- parts.unshift(part);
91
- if (node.id) break;
92
- node = parent;
93
- depth += 1;
94
- }
95
- return parts.join(' > ');
96
- };
97
-
98
- var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
99
- var STYLE_PROPS = [
100
- 'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
101
- 'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
102
- 'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
103
- ];
104
-
105
- var describe = function (element) {
106
- var computed = window.getComputedStyle(element);
107
- var attributes = {};
108
- for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
109
- var name = INTERESTING_ATTRS[i];
110
- var value = element.getAttribute(name);
111
- if (value) attributes[name] = String(value).slice(0, 200);
112
- }
113
- var computedStyle = {};
114
- for (var j = 0; j < STYLE_PROPS.length; j += 1) {
115
- var prop = STYLE_PROPS[j];
116
- computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
117
- }
118
- var ancestry = [];
119
- var node = element.parentElement;
120
- var depth = 0;
121
- while (node && node.nodeType === 1 && depth < 4) {
122
- var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
123
- if (node.id) entry.id = node.id;
124
- var cls = typeof node.className === 'string' ? node.className.trim() : '';
125
- if (cls) entry.className = cls.slice(0, 200);
126
- ancestry.unshift(entry);
127
- node = node.parentElement;
128
- depth += 1;
129
- }
130
- var box = element.getBoundingClientRect();
131
- var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
132
- return {
133
- tag: element.tagName.toLowerCase(),
134
- text: text.slice(0, MAX_TEXT),
135
- selector: buildSelector(element),
136
- path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
137
- bounds: rectFrom(box),
138
- center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
139
- attributes: attributes,
140
- computedStyle: computedStyle,
141
- ancestry: ancestry
142
- };
143
- };
144
-
145
- // ------------------------------------------------------------------ chrome
146
-
147
- var host = document.createElement('div');
148
- host.setAttribute(OVERLAY_ATTR, '');
149
- // A manual popover: shown, it joins the browser's top layer without making
150
- // the rest of the page inert. See "top layer" below.
151
- host.setAttribute('popover', 'manual');
152
- // Every declaration is !important: as a popover, and later inside a page
153
- // dialog, the host matches page rules such as [popover]{background:...},
154
- // which would otherwise paint a sheet over the whole page.
155
- host.style.cssText = [
156
- 'all:initial', 'display:block', 'position:fixed', 'inset:0', 'width:auto', 'height:auto',
157
- 'max-width:none', 'max-height:none', 'margin:0', 'padding:0', 'border:0', 'background:transparent',
158
- 'overflow:visible', 'opacity:1', 'transform:none', 'z-index:' + Z_OVERLAY, 'pointer-events:none'
159
- ].join(' !important;') + ' !important';
160
- var shadow = host.attachShadow({ mode: 'closed' });
161
-
162
- var style = document.createElement('style');
163
- style.textContent = [
164
- ':host{all:initial}',
165
- '*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
166
- '.layer{position:fixed;inset:0;pointer-events:none}',
167
- '.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
168
- '.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}',
169
- '.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}',
170
- '.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}',
171
- '.tools button:hover{background:' + THEME.primaryFaint + '}',
172
- '.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
173
- '.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}',
174
- '.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}',
175
- '.editor textarea::placeholder{color:' + THEME.mutedText + '}',
176
- '.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}',
177
- '.editor button svg{width:16px;height:16px;display:block}',
178
- '.editor button[disabled]{opacity:.5;cursor:default}'
179
- ].join('');
180
- shadow.appendChild(style);
181
-
182
- var cursorStyle = document.createElement('style');
183
- cursorStyle.id = 'openchamber-annotation-cursor';
184
- document.head.appendChild(cursorStyle);
185
- var setCursor = function (value) {
186
- cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
187
- };
188
-
189
- var svgNS = 'http://www.w3.org/2000/svg';
190
- var svg = document.createElementNS(svgNS, 'svg');
191
- svg.setAttribute('class', 'layer');
192
- svg.style.overflow = 'visible';
193
- shadow.appendChild(svg);
194
-
195
- var hoverBox = document.createElement('div');
196
- hoverBox.className = 'box';
197
- var hoverLabel = document.createElement('div');
198
- hoverLabel.className = 'label';
199
- var marqueeBox = document.createElement('div');
200
- marqueeBox.className = 'box';
201
- shadow.append(hoverBox, hoverLabel, marqueeBox);
202
-
203
- var positionBox = function (node, rect) {
204
- node.style.display = 'block';
205
- node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
206
- node.style.width = rect.width + 'px';
207
- node.style.height = rect.height + 'px';
208
- };
209
-
210
- var tools = document.createElement('div');
211
- tools.className = 'tools';
212
- shadow.appendChild(tools);
213
-
214
- var toolButtons = {};
215
- [['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
216
- var button = document.createElement('button');
217
- button.type = 'button';
218
- button.textContent = entry[1];
219
- button.addEventListener('click', function () { setTool(entry[0]); });
220
- toolButtons[entry[0]] = button;
221
- tools.appendChild(button);
222
- });
223
-
224
- var editor = document.createElement('div');
225
- editor.className = 'editor';
226
- shadow.appendChild(editor);
227
-
228
- var comment = document.createElement('textarea');
229
- comment.rows = 1;
230
- comment.placeholder = LABELS.commentPlaceholder;
231
- var submit = document.createElement('button');
232
- submit.type = 'button';
233
- // Icon-only attach button (Remix attachment-2), matching the chat comment
234
- // input; the localized label stays available to assistive tech.
235
- submit.setAttribute('aria-label', LABELS.submit);
236
- submit.title = LABELS.submit;
237
- 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>';
238
- editor.append(comment, submit);
239
-
240
- /**
241
- * Grows the box with its content.
242
- *
243
- * A hidden element reports scrollHeight 0, so measuring one collapses the
244
- * field to nothing — which is what left a sliver of a click target and an
245
- * invisible caret. Measuring only while visible, and never below the CSS
246
- * min-height, keeps it usable.
247
- */
248
- var resizeComment = function () {
249
- if (editor.style.display === 'none') return;
250
- comment.style.height = 'auto';
251
- comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
252
- };
253
- comment.addEventListener('input', resizeComment);
254
-
255
- // -------------------------------------------------------------- selection
256
-
257
- var lastTargetRect = null;
258
-
259
- /** Places the comment box under whatever was just marked, kept on screen. */
260
- var positionEditor = function () {
261
- if (!lastTargetRect) {
262
- editor.style.display = 'none';
263
- return;
264
- }
265
- var wasHidden = editor.style.display === 'none';
266
- editor.style.display = 'flex';
267
- // Measured now that it is laid out, not while it was still hidden.
268
- if (wasHidden) resizeComment();
269
- var box = editor.getBoundingClientRect();
270
- var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
271
- var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
272
- // Above the target when there is no room below, so the box is never left
273
- // half off the bottom of the page.
274
- if (top + box.height > window.innerHeight - 8) {
275
- top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
276
- }
277
- left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
278
- editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
279
- };
280
-
281
- /** Focus after layout: focusing a zero-height field puts the caret nowhere. */
282
- var focusComment = function () {
283
- requestAnimationFrame(function () {
284
- try {
285
- comment.focus({ preventScroll: true });
286
- comment.setSelectionRange(comment.value.length, comment.value.length);
287
- } catch (error) { /* field went away */ }
288
- });
289
- };
290
-
291
- var hasTargets = function () {
292
- return Boolean(selected) || regions.length > 0 || strokes.length > 0;
293
- };
294
-
295
- var syncChrome = function () {
296
- submit.disabled = !hasTargets();
297
- if (!hasTargets()) {
298
- lastTargetRect = null;
299
- editor.style.display = 'none';
300
- return;
301
- }
302
- positionEditor();
303
- };
304
-
305
- var syncSelectionVisuals = function () {
306
- if (!selected) return;
307
- var rect = rectFrom(selected.element.getBoundingClientRect());
308
- if (!usableRect(rect)) {
309
- selected.outline.style.display = 'none';
310
- selected.badge.style.display = 'none';
311
- return;
312
- }
313
- positionBox(selected.outline, rect);
314
- selected.badge.style.display = 'block';
315
- selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
316
- lastTargetRect = rect;
317
- };
318
-
319
- var dropSelection = function () {
320
- if (!selected) return;
321
- selected.outline.remove();
322
- selected.badge.remove();
323
- selected = null;
324
- };
325
-
326
- var selectElement = function (element) {
327
- var wasSelected = selected && selected.element === element;
328
- dropSelection();
329
- if (wasSelected) {
330
- // Clicking the chosen element again clears it, so a misclick costs one
331
- // click rather than starting over.
332
- lastTargetRect = null;
333
- syncChrome();
334
- return;
335
- }
336
- var outline = document.createElement('div');
337
- outline.className = 'box';
338
- var badge = document.createElement('div');
339
- badge.className = 'label';
340
- badge.textContent = selectorPart(element);
341
- shadow.append(outline, badge);
342
- selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
343
- syncSelectionVisuals();
344
- syncChrome();
345
- focusComment();
346
- };
347
-
348
- var setTool = function (next) {
349
- tool = next;
350
- hoverBox.style.display = 'none';
351
- hoverLabel.style.display = 'none';
352
- marqueeBox.style.display = 'none';
353
- setCursor(next === 'select' ? '' : 'crosshair');
354
- for (var key in toolButtons) {
355
- if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
356
- toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
357
- }
358
- }
359
- };
360
-
361
- // ------------------------------------------------------------- interaction
362
-
363
- var drag = null;
364
-
365
- var onPointerMove = function (event) {
366
- if (drag) {
367
- if (drag.kind === 'marquee') {
368
- drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
369
- positionBox(marqueeBox, drag.rect);
370
- } else if (drag.kind === 'draw') {
371
- drag.points.push({ x: event.clientX, y: event.clientY });
372
- drag.path.setAttribute('d', drag.points.map(function (point, index) {
373
- return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
374
- }).join(' '));
375
- }
376
- return;
377
- }
378
-
379
- if (tool !== 'select') return;
380
- var element = elementFromPoint(event.clientX, event.clientY);
381
- if (!element) {
382
- hoverBox.style.display = 'none';
383
- hoverLabel.style.display = 'none';
384
- return;
385
- }
386
- var rect = rectFrom(element.getBoundingClientRect());
387
- positionBox(hoverBox, rect);
388
- hoverLabel.textContent = selectorPart(element);
389
- hoverLabel.style.display = 'block';
390
- hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
391
- };
392
-
393
- var onPointerDown = function (event) {
394
- if (event.button !== 0) return;
395
- if (isOverlayNode(event.target)) return;
396
- event.preventDefault();
397
- event.stopPropagation();
398
-
399
- if (tool === 'select') {
400
- var element = elementFromPoint(event.clientX, event.clientY);
401
- if (element) selectElement(element);
402
- return;
403
- }
404
-
405
- if (tool === 'marquee') {
406
- drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
407
- return;
408
- }
409
-
410
- var path = document.createElementNS(svgNS, 'path');
411
- path.setAttribute('fill', 'none');
412
- path.setAttribute('stroke', THEME.primary);
413
- path.setAttribute('stroke-width', '2.5');
414
- path.setAttribute('stroke-linecap', 'round');
415
- path.setAttribute('stroke-linejoin', 'round');
416
- svg.appendChild(path);
417
- drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
418
- };
419
-
420
- var onPointerUp = function () {
421
- if (!drag) return;
422
- var finished = drag;
423
- drag = null;
424
-
425
- if (finished.kind === 'marquee') {
426
- marqueeBox.style.display = 'none';
427
- var rect = finished.rect;
428
- if (!rect || !usableRect(rect)) return;
429
- // A region marks an area, not the elements inside it: expanding it into a
430
- // selection made the result depend on the page's markup rather than on
431
- // what was drawn.
432
- regions.push({ id: nextId('region'), rect: rect });
433
- var outline = document.createElementNS(svgNS, 'rect');
434
- outline.setAttribute('x', String(rect.x));
435
- outline.setAttribute('y', String(rect.y));
436
- outline.setAttribute('width', String(rect.width));
437
- outline.setAttribute('height', String(rect.height));
438
- outline.style.fill = THEME.primarySoft;
439
- outline.setAttribute('stroke', THEME.primary);
440
- outline.setAttribute('stroke-width', '1.5');
441
- outline.setAttribute('rx', '2');
442
- svg.appendChild(outline);
443
- lastTargetRect = rect;
444
- syncChrome();
445
- focusComment();
446
- return;
447
- }
448
-
449
- var points = finished.points;
450
- if (points.length < 2) {
451
- if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
452
- return;
453
- }
454
- var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
455
- for (var p = 1; p < points.length; p += 1) {
456
- minX = Math.min(minX, points[p].x);
457
- minY = Math.min(minY, points[p].y);
458
- maxX = Math.max(maxX, points[p].x);
459
- maxY = Math.max(maxY, points[p].y);
460
- }
461
- var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
462
- strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
463
- lastTargetRect = bounds;
464
- syncChrome();
465
- focusComment();
466
- };
467
-
468
- /**
469
- * Swallows the page's own mouse handling while annotating.
470
- *
471
- * Blocking pointerdown is not enough: a click still follows it, so marking a
472
- * button pressed that button and marking a link navigated away from the page
473
- * being annotated. These are the events that reach page code, so these are
474
- * the ones that have to stop.
475
- */
476
- var blockPageInteraction = function (event) {
477
- if (isOverlayNode(event.target)) return;
478
- event.preventDefault();
479
- event.stopPropagation();
480
- };
481
- var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
482
-
483
- var onScrollOrResize = function () {
484
- syncSelectionVisuals();
485
- positionEditor();
486
- };
487
-
488
- var onKeyDown = function (event) {
489
- if (event.isComposing || event.keyCode === 229) return;
490
- if (event.key === 'Escape') {
491
- event.preventDefault();
492
- event.stopImmediatePropagation();
493
- finish(null);
494
- }
495
- };
496
-
497
- var onCommentKeyDown = function (event) {
498
- // Do not let the annotated page treat typed letters as its own shortcuts.
499
- event.stopPropagation();
500
- // WebKit can report the composition-confirming Enter as keyCode 229.
501
- if (event.isComposing || event.keyCode === 229) return;
502
- if (event.key === 'Enter' && !event.shiftKey) {
503
- event.preventDefault();
504
- attach();
505
- }
506
- };
507
-
508
- document.addEventListener('pointermove', onPointerMove, true);
509
- document.addEventListener('pointerdown', onPointerDown, true);
510
- document.addEventListener('pointerup', onPointerUp, true);
511
- BLOCKED_EVENTS.forEach(function (name) {
512
- window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
513
- });
514
- window.addEventListener('scroll', onScrollOrResize, true);
515
- window.addEventListener('resize', onScrollOrResize, true);
516
- window.addEventListener('keydown', onKeyDown, true);
517
- comment.addEventListener('keydown', onCommentKeyDown);
518
-
519
- // --------------------------------------------------------------- top layer
520
-
521
- /**
522
- * Keeps the chrome above a modal dialog or popover the page opens.
523
- *
524
- * Those render in the browser's top layer, which no z-index reaches, and a
525
- * modal dialog also makes everything outside itself inert: the outlines drew
526
- * under the dialog and the comment box took no typing. So the host is shown
527
- * as a popover, which puts it in the top layer too, and it lives inside the
528
- * page's topmost modal dialog, where that inertness does not reach. Showing it
529
- * again whenever the page puts something new on top keeps it last, so above.
530
- *
531
- * Opening our own modal dialog instead would make the page's dialog inert,
532
- * which is the thing being annotated.
533
- */
534
- var modals = [];
535
-
536
- var isModalDialog = function (element) {
537
- if (element.tagName !== 'DIALOG') return false;
538
- try { return element.matches(':modal'); } catch (error) { return false; }
539
- };
540
-
541
- var trackDialog = function (dialog) {
542
- var index = modals.indexOf(dialog);
543
- if (index !== -1) modals.splice(index, 1);
544
- // Opened last, so on top. Dialogs already open when annotation starts are
545
- // taken in document order, which is the usual order of nesting.
546
- if (isModalDialog(dialog)) modals.push(dialog);
547
- };
548
-
549
- var topModal = function () {
550
- for (var i = modals.length - 1; i >= 0; i -= 1) {
551
- if (modals[i].isConnected && isModalDialog(modals[i])) return modals[i];
552
- }
553
- return null;
554
- };
555
-
556
- var placeHost = function () {
557
- var parent = topModal() || document.body || document.documentElement;
558
- var hadFocus = shadow.activeElement === comment;
559
- if (host.parentNode !== parent) parent.appendChild(host);
560
- try {
561
- if (host.matches(':popover-open')) host.hidePopover();
562
- host.showPopover();
563
- } catch (error) { /* no popover support: the z-index still covers ordinary pages */ }
564
- // Moving the host blurs the comment box mid-sentence.
565
- if (hadFocus) comment.focus({ preventScroll: true });
566
- };
567
-
568
- var topLayerObserver = new window.MutationObserver(function (records) {
569
- var changed = false;
570
- for (var i = 0; i < records.length; i += 1) {
571
- if (records[i].type === 'attributes' && records[i].target.tagName === 'DIALOG') {
572
- trackDialog(records[i].target);
573
- changed = true;
574
- }
575
- }
576
- if (!host.isConnected) {
577
- // Removed on purpose, not along with a dialog: the session was cancelled
578
- // from the app or replaced by a new one. End it, so its listeners stop
579
- // swallowing the page's clicks and nothing brings the host back.
580
- for (var j = 0; j < records.length; j += 1) {
581
- if (Array.prototype.indexOf.call(records[j].removedNodes, host) !== -1) {
582
- finish(null);
583
- return;
584
- }
585
- }
586
- changed = true;
587
- }
588
- if (!changed) return;
589
- placeHost();
590
- // Our own move is not a page change.
591
- topLayerObserver.takeRecords();
592
- });
593
-
594
- var onToggle = function (event) {
595
- if (event.target === host || event.newState !== 'open') return;
596
- placeHost();
597
- topLayerObserver.takeRecords();
598
- };
599
-
600
- // With the host inside the page's dialog, clicks on our chrome would reach
601
- // the dialog's own handlers, and a click outside its box commonly closes it.
602
- // Typing in the comment box would reach its key handlers the same way.
603
- var CHROME_EVENTS = BLOCKED_EVENTS.concat([
604
- 'pointerdown', 'pointerup', 'keydown', 'keyup', 'keypress', 'beforeinput', 'input'
605
- ]);
606
- var keepChromeEvent = function (event) { event.stopPropagation(); };
607
- CHROME_EVENTS.forEach(function (name) {
608
- host.addEventListener(name, keepChromeEvent);
609
- });
610
-
611
- var startTopLayer = function () {
612
- Array.prototype.forEach.call(document.querySelectorAll('dialog'), trackDialog);
613
- placeHost();
614
- topLayerObserver.observe(document.documentElement, {
615
- subtree: true,
616
- childList: true,
617
- attributes: true,
618
- attributeFilter: ['open']
619
- });
620
- document.addEventListener('toggle', onToggle, true);
621
- };
622
-
623
- // ------------------------------------------------------------------ finish
624
-
625
- var teardown = function () {
626
- document.removeEventListener('pointermove', onPointerMove, true);
627
- document.removeEventListener('pointerdown', onPointerDown, true);
628
- document.removeEventListener('pointerup', onPointerUp, true);
629
- BLOCKED_EVENTS.forEach(function (name) {
630
- window.removeEventListener(name, blockPageInteraction, true);
631
- });
632
- window.removeEventListener('scroll', onScrollOrResize, true);
633
- window.removeEventListener('resize', onScrollOrResize, true);
634
- window.removeEventListener('keydown', onKeyDown, true);
635
- comment.removeEventListener('keydown', onCommentKeyDown);
636
- topLayerObserver.disconnect();
637
- document.removeEventListener('toggle', onToggle, true);
638
- setCursor('');
639
- if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
640
- if (host.parentNode) host.parentNode.removeChild(host);
641
- try { delete window['${ga}']; } catch (error) { /* non-configurable */ }
642
- };
643
-
644
- var finish = function (payload) {
645
- if (settled) return;
646
- settled = true;
647
- teardown();
648
- // Removing the chrome is not enough: the host screenshots this page right
649
- // after we resolve, and the compositor can still hold a frame containing
650
- // our outlines. Yield two frames so the page has actually repainted.
651
- requestAnimationFrame(function () {
652
- requestAnimationFrame(function () { resolve(payload); });
653
- });
654
- };
655
-
656
- var attach = function () {
657
- if (!hasTargets()) return;
658
- finish({
659
- id: 'annotation-' + Date.now(),
660
- pageUrl: String(location.href),
661
- pageTitle: String(document.title || ''),
662
- viewport: { width: window.innerWidth, height: window.innerHeight },
663
- devicePixelRatio: window.devicePixelRatio || 1,
664
- comment: comment.value,
665
- // Zero or one element, never more. Kept as a list so elements, regions
666
- // and strokes stay one uniform shape for everything downstream.
667
- elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
668
- regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
669
- strokes: strokes.map(function (entry) {
670
- return { id: entry.id, points: entry.points, bounds: entry.bounds };
671
- })
672
- });
673
- };
674
-
675
- submit.addEventListener('click', attach);
676
-
677
- startTopLayer();
678
- setTool('select');
679
- syncChrome();
680
- });`},f0={kind:"idle"},en=t=>typeof t=="object"&&t!==null,ln=t=>typeof t=="number"&&Number.isFinite(t),Uc=t=>en(t)&&Object.values(t).every(e=>typeof e=="string"),fl=t=>en(t)&&ln(t.x)&&ln(t.y)&&ln(t.width)&&ln(t.height),mp=t=>en(t)&&ln(t.x)&&ln(t.y),p0=t=>en(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"),h0=t=>en(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&fl(t.bounds)&&mp(t.center)&&Uc(t.attributes)&&Uc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(p0),m0=t=>en(t)&&typeof t.id=="string"&&h0(t.element),g0=t=>en(t)&&typeof t.id=="string"&&fl(t.rect),b0=t=>en(t)&&typeof t.id=="string"&&fl(t.bounds)&&Array.isArray(t.points)&&t.points.every(mp),y0=t=>en(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&en(t.viewport)&&ln(t.viewport.width)&&ln(t.viewport.height)&&ln(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(m0)&&Array.isArray(t.regions)&&t.regions.every(g0)&&Array.isArray(t.strokes)&&t.strokes.every(b0),x0=1600,S0=t=>new Promise((e,s)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>s(new Error("Failed to decode browser page capture")),r.src=t}),v0=async({base64:t,mime:e,captureWidth:s,captureHeight:r,cssWidth:o,cssHeight:i,payload:c,accentColor:l,accentFill:d})=>{if(!t)return null;try{const u=await S0(`data:${e};base64,${t}`),f=Math.max(1,u.naturalWidth||s),p=Math.max(1,u.naturalHeight||r),m=f/Math.max(1,o||f),g=p/Math.max(1,i||p),b=Math.min(1,x0/f),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(f*b)),v.height=Math.max(1,Math.floor(p*b));const x=v.getContext("2d");if(!x)return null;x.scale(b,b),x.drawImage(u,0,0,f,p);const y=C=>({x:C.x*m,y:C.y*g,width:C.width*m,height:C.height*g}),h=Math.max(2,2.5*m/Math.max(b,.2));x.strokeStyle=l,x.fillStyle=d;const S=C=>{const k=y(C);x.lineWidth=h,x.fillRect(k.x,k.y,k.width,k.height),x.strokeRect(k.x,k.y,k.width,k.height)};for(const C of c.elements)S(C.element.bounds);for(const C of c.regions)S(C.rect);for(const C of c.strokes)C.points.length<2||(x.beginPath(),C.points.forEach((k,T)=>{const O=k.x*m,K=k.y*g;T===0?x.moveTo(O,K):x.lineTo(O,K)}),x.lineCap="round",x.lineJoin="round",x.lineWidth=h*1.4,x.stroke());const w=await new Promise(C=>v.toBlob(C,"image/jpeg",.85));return w?new File([w],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},w0="({ width: window.innerWidth, height: window.innerHeight })",k0=async t=>{try{const e=await t.executeJavaScript(w0,!0);if(!e||typeof e!="object")return null;const s=e;return typeof s.width!="number"||typeof s.height!="number"||!Number.isFinite(s.width)||!Number.isFinite(s.height)?null:{width:s.width,height:s.height}}catch{return null}},go=async t=>{try{await t.executeJavaScript(d0,!1)}catch{}},j0=async({host:t,theme:e,labels:s})=>{const r=u0(e,s),o=await t.executeJavaScript(r,!0);if(o==null)return null;if(!y0(o))return await go(t),null;const i=o;try{const c=await k0(t)??i.viewport,l=await t.capturePage();if(!l||!l.base64)return{payload:i,screenshot:null};const d=await v0({base64:l.base64,mime:l.mime||"image/jpeg",captureWidth:l.width,captureHeight:l.height,cssWidth:c.width,cssHeight:c.height,payload:i,accentColor:e.primary,accentFill:e.primarySoft});return{payload:i,screenshot:d}}catch{return{payload:i,screenshot:null}}},As={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)"},C0=()=>{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 s=window.getComputedStyle(t).backgroundColor;return s&&s!=="rgba(0, 0, 0, 0)"?s:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},P0=t=>{const e=C0();if(!e)return{...As,colorScheme:t};try{const s=(l,d)=>e.read(`var(${l})`)||d,r=(l,d,u)=>e.read(`color-mix(in srgb, var(${l}) ${d}%, transparent)`)||u,o=e.readVariable("--oc-glass-tooltip-opacity")||"62%",i=e.readVariable("--oc-glass-blur")||"26px",c=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${o}, transparent)`)||As.glassSurface,glassFilter:`blur(${i}) saturate(${c})`,primary:s("--primary",As.primary),primarySoft:r("--primary",16,As.primarySoft),primaryFaint:r("--primary",10,As.primaryFaint),primaryContrast:s("--primary-foreground",As.primaryContrast),surface:s("--surface-background",As.surface),surfaceElevated:s("--surface-elevated",As.surfaceElevated),border:s("--border",As.border),text:s("--foreground",As.text),mutedText:s("--muted-foreground",As.mutedText)}}catch{return{...As,colorScheme:t}}finally{e.dispose()}},E0=t=>({sessionId:t.sessionId,directory:t.directory?Cs(t.directory):null}),I0=2e3,T0=50,Ai=400,Ns=new Map,dn=new Map;let ba=null,ya=null;const pl=new Map;let on=null,Pr=null;const bo=async t=>{try{const e=await Us("/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}},D0=async(t,e)=>{try{const s=await Us("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});s.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${s.status}); the agent will see this action time out`)}catch(s){console.warn(`[browser-control] could not deliver the result for ${t}:`,s)}},gp=async(t,e=I0)=>{const s=Date.now()+e;for(;!Ns.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,T0));return Ns.get(t)??null},Gc=t=>Ns.has(t)||dn.has(t),Ao=t=>Ns.get(t)??dn.get(t)??null,xa=()=>[...Ns.values(),...[...dn.values()].filter(t=>!Ns.has(t.tabId))],bp=t=>{const e=ya?Ao(ya):null,s=e?.directory===ba?e:null;if(!t.sessionId){if(s)return s.tabId;const i=xa().filter(d=>d.directory===ba),c=i.filter(d=>Ns.has(d.tabId)),l=c.length>0?c:i;return l.length>0?l[l.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=pl.get(t.sessionId);if(r&&Ao(r)?.ownerSessionId===t.sessionId)return r;const o=xa().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},R0=(t,e)=>{t.sessionId&&Ao(e)?.ownerSessionId===t.sessionId&&pl.set(t.sessionId,e)},yp=async t=>{const e=Ns.get(t);if(e)return e;const s=dn.get(t);return s?(s.wake(),gp(t)):null},xp=t=>{const e=bp(t);return xa().filter(s=>!t.sessionId||!t.directory||s.ownerSessionId===t.sessionId||s.directory===t.directory).map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}const o=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:o,active:s.tabId===e}})},Sp=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,N0=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use this session's own tab.`,M0=t=>{const e=xp(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
681
- ${e.map(r=>`- ${r.id}: ${r.title||r.url||"blank"} (opened by ${r.owner})`).join(`
682
- `)}`:"")},Ys=(t,e)=>D0(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:Ky()})}:e),A0=async t=>{const e=t.action==="browser.open",s=E0(t.context),{tabId:r,...o}=t.parameters,i=r===void 0?null:String(r);if(i!==null){if(!Gc(i)){if(Ns.size===0&&dn.size===0&&!on)return;if(await new Promise(d=>setTimeout(d,Ai)),Gc(i)){await qc(t,s,i,o);return}if(!await bo(t.requestId))return;await Ys(t,{ok:!1,error:N0(i)});return}await qc(t,s,i,o);return}const c=bp(s);if(!c&&!(e&&on)){if(!s.sessionId||(await new Promise(d=>setTimeout(d,Ai)),!await bo(t.requestId)))return;await Ys(t,{ok:!1,error:M0(s)});return}if(!(e&&on!==null)&&s.sessionId&&Ao(c)?.ownerSessionId!==s.sessionId&&await new Promise(d=>setTimeout(d,Ai)),!!await bo(t.requestId))try{const d=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!d){await Ys(t,{ok:!1,error:"url is required"});return}const u=e&&on?on(d,t.context):null;if(e&&!u&&!c){await Ys(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(u){s.sessionId&&pl.set(s.sessionId,u);const p=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!p||p==="fill"){await Ys(t,{ok:!0,data:{url:d,opened:!0,tabId:u}});return}const m=await gp(u);if(!m){await Ys(t,{ok:!0,data:{url:d,opened:!0,tabId:u,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 g=await m.run("browser.resize",{viewport:p}),b=g&&typeof g=="object"?g.viewport??null:null;await Ys(t,{ok:!0,data:{url:d,opened:!0,tabId:u,viewportApplied:!0,viewport:b}});return}const f=await yp(c);await Ys(t,f?await vp(f,s,t.action,o):{ok:!1,error:Sp(c)})}catch(d){await Ys(t,{ok:!1,error:d instanceof Error?d.message:String(d)})}},qc=async(t,e,s,r)=>{if(!await bo(t.requestId))return;R0(e,s);const o=await yp(s);await Ys(t,o?await vp(o,e,t.action,r):{ok:!1,error:Sp(s)})},vp=async(t,e,s,r)=>{try{const o=await t.run(s,r);return s==="browser.snapshot"&&Object(o)===o?{ok:!0,data:{...Object(o),tabs:xp(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},hl=()=>{Pr||(Pr=jn(t=>{t.type==="browser-control-request"&&A0({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},ml=()=>{Ns.size>0||dn.size>0||on||!Pr||(Pr(),Pr=null)},O0=t=>(Ns.set(t.tabId,t),hl(),()=>{Ns.get(t.tabId)===t&&Ns.delete(t.tabId),ml()}),B0=t=>(dn.set(t.tabId,t),hl(),()=>{dn.get(t.tabId)===t&&dn.delete(t.tabId),ml()}),F0=(t,e)=>{ba=t,e&&(ya=e)},L0=t=>(on=t,hl(),()=>{on===t&&(on=null),ml()}),_0=50,$0=6,z0=2048,K0=200,wp=t=>{const e=qn(String(t??"").trim());if(!e||e.length>z0)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},W0=(t,e)=>{const s=wp(e.url);if(!s)return t;const r=t.find(c=>c.url===s),o=String(e.title??"").trim().slice(0,K0)||r?.title||"";return[{url:s,title:o,lastVisitedAt:e.at},...t.filter(c=>c.url!==s)].slice(0,_0)},H0=(t,e)=>{const s=wp(e);return t.filter(r=>r.url!==s)},V0=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),kp=(t,e,s=$0)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((c,l)=>l.lastVisitedAt-c.lastVisitedAt);if(!r)return o.slice(0,s);const i=r.replace(/^https?:\/\//,"");return o.filter(c=>{const l=V0(c);return c.url===r||l===i?!1:l.includes(i)}).slice(0,s)},Yc=20,yo=t=>{const e=vt((t||"").trim());return e?JSON.stringify([Gt(),e]):""},U0=t=>{const e=Object.keys(t);if(e.length<=Yc)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Yc);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},Zn=Vr()(i1(t=>({byProject:{},recordVisit:(e,s)=>{const r=yo(e);r&&t(o=>{const i=o.byProject[r]??[],c=W0(i,{...s,at:Date.now()});return c===i?o:{byProject:U0({...o.byProject,[r]:c})}})},forget:(e,s)=>{const r=yo(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:H0(i,s)}}:o})},clear:e=>{const s=yo(e);s&&t(r=>{if(!(s in r.byProject))return r;const o={...r.byProject};return delete o[s],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Cm(),partialize:t=>({byProject:t.byProject})})),G0=[],jp=t=>e=>{const s=yo(t);return(s?e.byProject[s]:void 0)??G0},gl=t=>{const e=Je.c(10),{t:s}=Ct();let r;e[0]!==t?(r=Hs(t),e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o?(i=u=>o?u.journey?.get(o):void 0,e[2]=o,e[3]=i):i=e[3];const c=Vs(i);if(o===null)return null;if(!c){let u;return e[4]!==s?(u=s("contextPanel.browser.spaceAddress"),e[4]=s,e[5]=u):u=e[5],u}let l;e[6]!==c.machine||e[7]!==c.placeId||e[8]!==s?(l=c.machine??(c.placeId==="docker"?s("spaces.create.place.localDocker"):c.placeId),e[6]=c.machine,e[7]=c.placeId,e[8]=s,e[9]=l):l=e[9];const d=l;return`${c.name} · ${d}`},Xc=6e3,q0=120,Y0=80,X0=100,Z0=`
683
- var MAX_ELEMENTS = ${q0};
684
- var MAX_LABEL_CHARS = ${Y0};
685
- var visible = function (element) {
686
- var rect = element.getBoundingClientRect();
687
- if (rect.width < 1 || rect.height < 1) return false;
688
- var style = window.getComputedStyle(element);
689
- return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
690
- };
691
- var label = function (element) {
692
- var aria = element.getAttribute('aria-label');
693
- if (aria) return aria.trim();
694
- var value = element.getAttribute('value');
695
- var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
696
- if (text) return text.slice(0, MAX_LABEL_CHARS);
697
- if (value) return String(value).slice(0, MAX_LABEL_CHARS);
698
- var placeholder = element.getAttribute('placeholder');
699
- return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
700
- };
701
- var isUnique = function (selector) {
702
- try {
703
- return document.querySelectorAll(selector).length === 1;
704
- } catch (error) {
705
- return false;
706
- }
707
- };
708
-
709
- /**
710
- * Names an element by what it is, falling back to where it sits.
711
- *
712
- * A positional chain like 'main > section:nth-of-type(3) > div > a' survives
713
- * only until the markup shifts, and says nothing about what it points at.
714
- * Anything the page states about identity — an id, a test id, an accessible
715
- * name — outlives edits and reads as the thing it selects. The chain remains
716
- * as the last resort, because something always has to work.
717
- */
718
- var cssPath = function (element) {
719
- var tag = element.tagName.toLowerCase();
720
-
721
- if (element.id) {
722
- var byId = '#' + CSS.escape(element.id);
723
- if (isUnique(byId)) return byId;
724
- }
725
- var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
726
- for (var a = 0; a < stableAttrs.length; a += 1) {
727
- var value = element.getAttribute(stableAttrs[a]);
728
- if (!value) continue;
729
- var raw = String(value);
730
- // A value containing a quote would need escaping for no real gain: such
731
- // attributes are rare, and the positional chain still covers them.
732
- if (raw.indexOf('"') !== -1) continue;
733
- var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
734
- if (isUnique(byAttr)) return byAttr;
735
- }
736
- var className = typeof element.className === 'string' ? element.className.trim() : '';
737
- if (className) {
738
- var classes = className.split(/\\s+/).filter(Boolean);
739
- for (var c = 0; c < classes.length; c += 1) {
740
- var byClass = tag + '.' + CSS.escape(classes[c]);
741
- if (isUnique(byClass)) return byClass;
742
- }
743
- }
744
-
745
- var parts = [];
746
- var node = element;
747
- var depth = 0;
748
- while (node && node.nodeType === 1 && depth < 6) {
749
- var part = node.tagName.toLowerCase();
750
- var parent = node.parentElement;
751
- if (!parent) { parts.unshift(part); break; }
752
- var siblings = Array.prototype.filter.call(parent.children, function (child) {
753
- return child.tagName === node.tagName;
754
- });
755
- if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
756
- parts.unshift(part);
757
- if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
758
- node = parent;
759
- depth += 1;
760
- }
761
- return parts.join(' > ');
762
- };
763
-
764
- /** What a screen reader would announce, or '' when there is nothing to say. */
765
- var accessibleName = function (element) {
766
- var aria = element.getAttribute('aria-label');
767
- if (aria && aria.trim()) return aria.trim();
768
- var labelled = element.getAttribute('aria-labelledby');
769
- if (labelled) {
770
- var source = document.getElementById(labelled.split(/\\s+/)[0]);
771
- if (source && (source.innerText || '').trim()) return source.innerText.trim();
772
- }
773
- var title = element.getAttribute('title');
774
- if (title && title.trim()) return title.trim();
775
- var alt = element.getAttribute('alt');
776
- if (alt && alt.trim()) return alt.trim();
777
- var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
778
- if (text) return text;
779
- var value = element.getAttribute('value');
780
- return value && String(value).trim() ? String(value).trim() : '';
781
- };
782
- var findByText = function (needle) {
783
- var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
784
- var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
785
- var exact = null;
786
- var partial = null;
787
- for (var i = 0; i < candidates.length; i += 1) {
788
- var element = candidates[i];
789
- if (!visible(element)) continue;
790
- var text = label(element).toLowerCase();
791
- if (!text) continue;
792
- if (text === wanted) { exact = element; break; }
793
- if (!partial && text.indexOf(wanted) !== -1) partial = element;
794
- }
795
- return exact || partial;
796
- };
797
- `,Ur=t=>`(() => {
798
- ${Z0}
799
- ${t}
800
- })()`,Q0=({selector:t}={})=>Ur(`
801
- var scopeSelector = ${JSON.stringify(t??"")};
802
- var root = document;
803
- if (scopeSelector) {
804
- try { root = document.querySelector(scopeSelector); }
805
- catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
806
- if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
807
- }
808
- var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
809
- var elements = [];
810
- var visibleTotal = 0;
811
- for (var i = 0; i < interactive.length; i += 1) {
812
- var element = interactive[i];
813
- if (!visible(element)) continue;
814
- visibleTotal += 1;
815
- if (elements.length >= MAX_ELEMENTS) continue;
816
-
817
- var rect = element.getBoundingClientRect();
818
- // Empty and default-valued fields are left out rather than serialized as
819
- // "" and false. Repeated across a hundred entries that overhead dwarfed
820
- // the information it carried.
821
- var entry = {
822
- selector: cssPath(element),
823
- tag: element.tagName.toLowerCase(),
824
- bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
825
- };
826
- // The list covers the whole document so anything can be clicked without
827
- // scrolling to it first, which means bounds alone do not say what is on
828
- // screen — a negative y reads as a bug otherwise.
829
- if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
830
- var type = element.getAttribute('type');
831
- if (type) entry.type = type;
832
- var role = element.getAttribute('role');
833
- if (role) entry.role = role;
834
- var labelText = label(element);
835
- if (labelText) entry.label = labelText;
836
- if (element.disabled === true) entry.disabled = true;
837
- // Flagged rather than described: reporting the accessible name of every
838
- // element would cost more than it tells, while its absence on something
839
- // clickable is a defect worth naming.
840
- if (!accessibleName(element)) entry.missingAccessibleName = true;
841
- elements.push(entry);
842
- }
843
- var body = document.body ? (document.body.innerText || '') : '';
844
- var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
845
- var docEl = document.documentElement;
846
- var result = {
847
- ok: true,
848
- url: String(location.href),
849
- title: String(document.title || ''),
850
- scope: scopeSelector || 'document',
851
- scrollY: Math.round(window.scrollY),
852
- maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
853
- text: text.slice(0, ${Xc}),
854
- elements: elements
855
- };
856
- // State what was dropped. A capped list that reports only its own length
857
- // reads as the whole page, and the agent acts as if it had seen everything.
858
- if (text.length > ${Xc}) {
859
- result.textTruncated = true;
860
- result.textTotalChars = text.length;
861
- }
862
- if (visibleTotal > elements.length) {
863
- result.elementsTruncated = true;
864
- result.interactiveElementsOnPage = visibleTotal;
865
- }
866
- return result;
867
- `),J0=({selector:t,text:e})=>Ur(`
868
- var selector = ${JSON.stringify(t??"")};
869
- var text = ${JSON.stringify(e??"")};
870
- var target = null;
871
- if (selector) {
872
- try { target = document.querySelector(selector); }
873
- catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
874
- if (!target) return { ok: false, error: 'No element matches ' + selector };
875
- } else {
876
- target = findByText(text);
877
- if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
878
- }
879
- if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
880
- target.scrollIntoView({ block: 'center', inline: 'center' });
881
-
882
- // A real click is a sequence, and many widgets act on its first half:
883
- // custom selects open on mousedown or focus and ignore the click itself.
884
- // Replay what the mouse would send to the middle of the element. The event
885
- // goes to whatever is drawn there when that sits inside the target, as it
886
- // would under a real pointer; anything else keeps the target the agent named.
887
- var rect = target.getBoundingClientRect();
888
- var x = rect.left + rect.width / 2;
889
- var y = rect.top + rect.height / 2;
890
- var drawn = document.elementFromPoint(x, y);
891
- var hit = drawn && target.contains(drawn) ? drawn : target;
892
- var fire = function (element, Type, type, extra) {
893
- var init = {
894
- bubbles: true, cancelable: true, composed: true, view: window,
895
- clientX: x, clientY: y, button: 0, buttons: 0, detail: 1,
896
- pointerId: 1, pointerType: 'mouse', isPrimary: true
897
- };
898
- for (var key in extra) init[key] = extra[key];
899
- return element.dispatchEvent(new Type(type, init));
900
- };
901
- var Pointer = window.PointerEvent || window.MouseEvent;
902
- var Mouse = window.MouseEvent;
903
- var notBubbling = { bubbles: false, cancelable: false };
904
-
905
- fire(hit, Pointer, 'pointerover', {});
906
- fire(hit, Pointer, 'pointerenter', notBubbling);
907
- fire(hit, Mouse, 'mouseover', {});
908
- fire(hit, Mouse, 'mouseenter', notBubbling);
909
- var pointerDown = fire(hit, Pointer, 'pointerdown', { buttons: 1 });
910
- // A cancelled pointerdown suppresses the mouse events, as in a browser.
911
- var mouseDown = pointerDown ? fire(hit, Mouse, 'mousedown', { buttons: 1 }) : true;
912
- // Focus moves on mousedown unless the page prevented it, to the nearest
913
- // focusable element under the pointer; with none, the old focus is lost.
914
- if (mouseDown) {
915
- var focusable = hit.closest('a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]:not([contenteditable="false"])');
916
- if (focusable && focusable.disabled !== true) focusable.focus({ preventScroll: true });
917
- else if (document.activeElement && document.activeElement !== document.body) document.activeElement.blur();
918
- }
919
- // The mousedown may have redrawn the widget; the release lands on what is
920
- // under the pointer now, and the click on what both halves share.
921
- var redrawn = document.elementFromPoint(x, y);
922
- var up = redrawn && target.contains(redrawn) ? redrawn : (target.isConnected ? target : hit);
923
- fire(up, Pointer, 'pointerup', {});
924
- if (pointerDown) fire(up, Mouse, 'mouseup', {});
925
- var clicked = up;
926
- if (hit.isConnected) {
927
- while (clicked && !clicked.contains(hit)) clicked = clicked.parentElement;
928
- }
929
- fire(clicked || up, Mouse, 'click', {});
930
- return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
931
- `),ek=({selector:t,value:e,submit:s})=>Ur(`
932
- var selector = ${JSON.stringify(t)};
933
- var value = ${JSON.stringify(e)};
934
- var target = null;
935
- try { target = document.querySelector(selector); }
936
- catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
937
- if (!target) return { ok: false, error: 'No element matches ' + selector };
938
-
939
- var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
940
- if (!editable) return { ok: false, error: selector + ' is not a text field' };
941
- if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
942
-
943
- target.scrollIntoView({ block: 'center' });
944
- target.focus();
945
- if (target.isContentEditable) {
946
- target.textContent = value;
947
- } else {
948
- // Frameworks track the value through the native setter; assigning the
949
- // property directly leaves React and friends unaware of the change.
950
- var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
951
- var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
952
- if (setter && setter.set) setter.set.call(target, value);
953
- else target.value = value;
954
- }
955
- target.dispatchEvent(new Event('input', { bubbles: true }));
956
- target.dispatchEvent(new Event('change', { bubbles: true }));
957
-
958
- if (${s?"true":"false"}) {
959
- var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
960
- target.dispatchEvent(new KeyboardEvent('keydown', enter));
961
- target.dispatchEvent(new KeyboardEvent('keyup', enter));
962
- var form = target.form;
963
- if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
964
- }
965
- return { ok: true, selector: cssPath(target), url: String(location.href) };
966
- `),tk=({selector:t,direction:e})=>Ur(`
967
- var selector = ${JSON.stringify(t??"")};
968
- var direction = ${JSON.stringify(e??"")};
969
-
970
- // Two frames let the layout catch up, but a page in a hidden background tab
971
- // is not composited and gets no frames at all while still reporting itself
972
- // visible, so the wait is capped by a timer. The scroll
973
- // itself is instant, so the position read then is already the final one.
974
- var settle = function (extra) {
975
- return new Promise(function (resolve) {
976
- var done = false;
977
- var finish = function () {
978
- if (done) return;
979
- done = true;
980
- var doc = document.documentElement;
981
- var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
982
- var scrollY = Math.round(window.scrollY);
983
- var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
984
- result.atTop = scrollY <= 1;
985
- result.atBottom = scrollY >= maxScrollY - 1;
986
- for (var key in extra) {
987
- if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
988
- }
989
- resolve(result);
990
- };
991
- requestAnimationFrame(function () {
992
- requestAnimationFrame(finish);
993
- });
994
- setTimeout(finish, ${X0});
995
- });
996
- };
997
-
998
- if (selector) {
999
- var target = null;
1000
- try { target = document.querySelector(selector); }
1001
- catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
1002
- if (!target) return { ok: false, error: 'No element matches ' + selector };
1003
- // Instant on purpose: the page's own smooth scrolling would still be
1004
- // animating when the next action runs against it.
1005
- target.scrollIntoView({ block: 'center', behavior: 'instant' });
1006
- return settle({ scrolledTo: cssPath(target) });
1007
- }
1008
-
1009
- var doc = document.documentElement;
1010
- var page = Math.round(window.innerHeight * 0.85);
1011
- var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
1012
- if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
1013
- else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
1014
- else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
1015
- else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
1016
- else return { ok: false, error: 'Unknown scroll direction: ' + direction };
1017
- return settle({ direction: direction });
1018
- `),sk=["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"],nk=({selector:t})=>Ur(`
1019
- var selector = ${JSON.stringify(t)};
1020
- var target = null;
1021
- try { target = document.querySelector(selector); }
1022
- catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
1023
- if (!target) return { ok: false, error: 'No element matches ' + selector };
1024
-
1025
- var computed = window.getComputedStyle(target);
1026
- var styles = {};
1027
- var props = ${JSON.stringify(sk)};
1028
- for (var i = 0; i < props.length; i += 1) {
1029
- var value = computed.getPropertyValue(props[i]);
1030
- if (value) styles[props[i]] = String(value).trim();
1031
- }
1032
-
1033
- var rect = target.getBoundingClientRect();
1034
- return {
1035
- ok: true,
1036
- selector: cssPath(target),
1037
- tag: target.tagName.toLowerCase(),
1038
- label: label(target),
1039
- bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
1040
- inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
1041
- styles: styles
1042
- };
1043
- `),rk=t=>{const e=Je.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:i,onHighlight:c}=t,{t:l}=Ct();if(s.length===0)return null;let d;e[0]!==l?(d=l("contextPanel.browser.history.label"),e[0]=l,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==s||e[4]!==i||e[5]!==c||e[6]!==o||e[7]!==l){let p;e[9]!==r||e[10]!==i||e[11]!==c||e[12]!==o||e[13]!==l?(p=(m,g)=>n.jsxs("div",{role:"option","aria-selected":g===r,className:Te("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),o(m.url)},onPointerEnter:()=>c(g),children:[n.jsx(Z,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:m.title||qo(m.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),n.jsx("button",{type:"button",className:Te("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":l("contextPanel.browser.history.forget"),title:l("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),i(m.url)},children:n.jsx(Z,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=i,e[11]=c,e[12]=o,e[13]=l,e[14]=p):p=e[14],u=s.map(p),e[2]=r,e[3]=s,e[4]=i,e[5]=c,e[6]=o,e[7]=l,e[8]=u}else u=e[8];let f;return e[15]!==d||e[16]!==u?(f=n.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":d,children:u}),e[15]=d,e[16]=u,e[17]=f):f=e[17],f},Os=t=>{const e=Je.c(17),{icon:s,label:r,onClick:o,disabled:i,pressed:c}=t,l=c?"secondary":"ghost",d=c&&"text-foreground";let u;e[0]!==d?(u=Te("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let f;e[2]!==s?(f=n.jsx(Z,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let p;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==l||e[9]!==u||e[10]!==f?(p=n.jsx(Bt,{asChild:!0,children:n.jsx(It,{type:"button",variant:l,size:"xs",className:u,onClick:o,disabled:i,"aria-label":r,"aria-pressed":c,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=c,e[8]=l,e[9]=u,e[10]=f,e[11]=p):p=e[11];let m;e[12]!==r?(m=n.jsx(Ot,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let g;return e[14]!==p||e[15]!==m?(g=n.jsxs(Ft,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=g):g=e[16],g},Cp=t=>{const e=Je.c(110),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:c,onSubmit:l,onBack:d,onForward:u,onReload:f,onOpenExternal:p,canOpenExternal:m,canGoBack:g,canGoForward:b,isLoading:v,onAnnotate:x,onOpenDevTools:y,isAnnotating:h,onHardReload:S,onZoomIn:w,onZoomOut:C,onZoomReset:k,zoomPercent:T,onClearCookies:O,onClearCache:K,onToggleDeviceBar:R,isDeviceBarOpen:I}=t;let N;e[0]!==o?(N=o===void 0?[]:o,e[0]=o,e[1]=N):N=e[1];const W=N,z=m===void 0?!0:m,H=T===void 0?100:T,{t:M}=Ct(),[Y,j]=a.useState(!1),[P,D]=a.useState(-1);let V;e[2]!==Y||e[3]!==W?(V=Y?W:[],e[2]=Y,e[3]=W,e[4]=V):V=e[4];const B=V;let _;e[5]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{D(-1)},e[5]=_):_=e[5];let F;e[6]!==s||e[7]!==Y?(F=[s,Y],e[6]=s,e[7]=Y,e[8]=F):F=e[8],a.useEffect(_,F);let X;e[9]!==l?(X=qe=>{j(!1),D(-1),l(qe)},e[9]=l,e[10]=X):X=e[10];const oe=X;let ne;e[11]!==P||e[12]!==oe||e[13]!==B?(ne=qe=>{if(B.length!==0){if(qe.key==="ArrowDown"||qe.key==="ArrowUp"){qe.preventDefault();const ft=qe.key==="ArrowDown"?1:-1,et=B.length;D(St=>{const we=St+ft;return we<-1?et-1:we>=et?-1:we});return}if(qe.key==="Escape"&&P>=0){qe.preventDefault(),D(-1);return}if(qe.key==="Enter"&&P>=0){qe.preventDefault();const ft=B[P];ft&&oe(ft.url)}}},e[11]=P,e[12]=oe,e[13]=B,e[14]=ne):ne=e[14];const A=ne;let te;e[15]!==M?(te=M("contextPanel.browser.back"),e[15]=M,e[16]=te):te=e[16];const U=!g;let Pe;e[17]!==d||e[18]!==te||e[19]!==U?(Pe=n.jsx(Os,{icon:"arrow-left",label:te,onClick:d,disabled:U}),e[17]=d,e[18]=te,e[19]=U,e[20]=Pe):Pe=e[20];let xe;e[21]!==M?(xe=M("contextPanel.browser.forward"),e[21]=M,e[22]=xe):xe=e[22];const ce=!b;let Oe;e[23]!==u||e[24]!==xe||e[25]!==ce?(Oe=n.jsx(Os,{icon:"arrow-right",label:xe,onClick:u,disabled:ce}),e[23]=u,e[24]=xe,e[25]=ce,e[26]=Oe):Oe=e[26];let me;e[27]!==v||e[28]!==M?(me=M(v?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=v,e[28]=M,e[29]=me):me=e[29];let ie;e[30]!==f||e[31]!==me?(ie=n.jsx(Os,{icon:"refresh",label:me,onClick:f}),e[30]=f,e[31]=me,e[32]=ie):ie=e[32];let q;e[33]!==S||e[34]!==M?(q=S?n.jsx(Os,{icon:"restart",label:M("contextPanel.browser.hardReload"),onClick:S}):null,e[33]=S,e[34]=M,e[35]=q):q=e[35];let ue;e[36]!==s||e[37]!==oe?(ue=qe=>{qe.preventDefault(),oe(s)},e[36]=s,e[37]=oe,e[38]=ue):ue=e[38];let ve;e[39]!==r?(ve=r?n.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:n.jsx(Z,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=ve):ve=e[40];let Ee;e[41]!==c?(Ee=qe=>c(qe.target.value),e[41]=c,e[42]=Ee):Ee=e[42];let L,le;e[43]===Symbol.for("react.memo_cache_sentinel")?(L=()=>j(!0),le=()=>j(!1),e[43]=L,e[44]=le):(L=e[43],le=e[44]);const G=B.length>0,se=r&&"ps-8";let je;e[45]!==se?(je=Te("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3",se,"typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[45]=se,e[46]=je):je=e[46];let he;e[47]!==M?(he=M("contextPanel.browser.addressAria"),e[47]=M,e[48]=he):he=e[48];let ge;e[49]!==s||e[50]!==A||e[51]!==Ee||e[52]!==G||e[53]!==je||e[54]!==he?(ge=n.jsx("input",{value:s,onChange:Ee,onFocus:L,onBlur:le,onKeyDown:A,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":G,"aria-controls":"openchamber-browser-address-suggestions",className:je,"aria-label":he}),e[49]=s,e[50]=A,e[51]=Ee,e[52]=G,e[53]=je,e[54]=he,e[55]=ge):ge=e[55];let ke;e[56]!==i?(ke=qe=>i?.(qe),e[56]=i,e[57]=ke):ke=e[57];let Ae;e[58]!==P||e[59]!==oe||e[60]!==ke||e[61]!==B?(Ae=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(rk,{entries:B,activeIndex:P,onSelect:oe,onForget:ke,onHighlight:D})}),e[58]=P,e[59]=oe,e[60]=ke,e[61]=B,e[62]=Ae):Ae=e[62];let $;e[63]!==ue||e[64]!==ve||e[65]!==ge||e[66]!==Ae?($=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:ue,children:[ve,ge,Ae]}),e[63]=ue,e[64]=ve,e[65]=ge,e[66]=Ae,e[67]=$):$=e[67];let fe;e[68]!==w||e[69]!==C||e[70]!==k||e[71]!==M||e[72]!==H?(fe=C&&w?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(Os,{icon:"subtract",label:M("contextPanel.browser.zoomOut"),onClick:C}),H!==100&&k?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsxs(It,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:k,"aria-label":M("contextPanel.browser.zoomReset"),children:[H,"%"]})}),n.jsx(Ot,{sideOffset:6,children:M("contextPanel.browser.zoomReset")})]}):null,n.jsx(Os,{icon:"add",label:M("contextPanel.browser.zoomIn"),onClick:w})]}):null,e[68]=w,e[69]=C,e[70]=k,e[71]=M,e[72]=H,e[73]=fe):fe=e[73];let be;e[74]!==O||e[75]!==M?(be=O?n.jsx(Os,{icon:"delete-bin",label:M("contextPanel.browser.clearCookies"),onClick:O}):null,e[74]=O,e[75]=M,e[76]=be):be=e[76];let Ie;e[77]!==K||e[78]!==M?(Ie=K?n.jsx(Os,{icon:"database-2",label:M("contextPanel.browser.clearCache"),onClick:K}):null,e[77]=K,e[78]=M,e[79]=Ie):Ie=e[79];let Ye;e[80]!==I||e[81]!==R||e[82]!==M?(Ye=R?n.jsx(Os,{icon:"smartphone",label:M("contextPanel.browser.deviceToolbar"),onClick:R,pressed:I}):null,e[80]=I,e[81]=R,e[82]=M,e[83]=Ye):Ye=e[83];let nt;e[84]!==h||e[85]!==x||e[86]!==M?(nt=x?n.jsx(Os,{icon:"markup",label:M("contextPanel.browser.annotate.toggle"),onClick:x,pressed:h}):null,e[84]=h,e[85]=x,e[86]=M,e[87]=nt):nt=e[87];let Ue;e[88]!==y||e[89]!==M?(Ue=y?n.jsx(Os,{icon:"terminal-box",label:M("contextPanel.browser.devTools"),onClick:y}):null,e[88]=y,e[89]=M,e[90]=Ue):Ue=e[90];let Ve;e[91]!==M?(Ve=M("contextPanel.browser.openExternal"),e[91]=M,e[92]=Ve):Ve=e[92];const Se=!z;let ye;e[93]!==p||e[94]!==Ve||e[95]!==Se?(ye=n.jsx(Os,{icon:"external-link",label:Ve,onClick:p,disabled:Se}),e[93]=p,e[94]=Ve,e[95]=Se,e[96]=ye):ye=e[96];let Ge;return e[97]!==Pe||e[98]!==Oe||e[99]!==ie||e[100]!==q||e[101]!==$||e[102]!==fe||e[103]!==be||e[104]!==Ie||e[105]!==Ye||e[106]!==nt||e[107]!==Ue||e[108]!==ye?(Ge=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Pe,Oe,ie,q,$,fe,be,Ie,Ye,nt,Ue,ye]}),e[97]=Pe,e[98]=Oe,e[99]=ie,e[100]=q,e[101]=$,e[102]=fe,e[103]=be,e[104]=Ie,e[105]=Ye,e[106]=nt,e[107]=Ue,e[108]=ye,e[109]=Ge):Ge=e[109],Ge},Oo={kind:"fill"},Zc=240,ok=3840,Pp=[{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}],Qc=t=>Number.isFinite(t)?Math.round(Math.min(ok,Math.max(Zc,t))):Zc,Bo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Ep=t=>{const e=Pp.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},ik=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},ak=(t,e)=>{const s=Bo(t);if(!s)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/s.width,o/s.height);return{width:s.width,height:s.height,scale:i}},lk=["mobile","tablet","desktop","fill"],ck={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Jc=t=>typeof t=="string"&&lk.includes(t),Sa=t=>t==="fill"?Oo:Ep(ck[t])??Oo,Zr=t=>{const e=Bo(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=Sa(s),o=Bo(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},dk=t=>{const e=Je.c(70),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:c}=t,{t:l}=Ct();let d;e[0]!==s?(d=Bo(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=s.kind==="preset"?s.id:"";let p;e[2]!==r||e[3]!==u?(p=(ne,A)=>{const te=Number.parseInt(A,10);if(!Number.isFinite(te))return;const U=u??{width:1280,height:800};r({kind:"custom",width:Qc(ne==="width"?te:U.width),height:Qc(ne==="height"?te:U.height)})},e[2]=r,e[3]=u,e[4]=p):p=e[4];const m=p;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=Te("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 b=g;let v;e[6]!==r?(v=ne=>{const A=Ep(ne.target.value);r(A??Oo)},e[6]=r,e[7]=v):v=e[7];let x;e[8]!==l?(x=l("contextPanel.browser.device.preset"),e[8]=l,e[9]=x):x=e[9];let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=Te("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]=y):y=e[10];let h;e[11]!==l?(h=l("contextPanel.browser.device.responsive"),e[11]=l,e[12]=h):h=e[12];let S;e[13]!==h?(S=n.jsx("option",{value:"",children:h}),e[13]=h,e[14]=S):S=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=Pp.map(uk),e[15]=w):w=e[15];let C;e[16]!==f||e[17]!==v||e[18]!==x||e[19]!==S?(C=n.jsxs("select",{value:f,onChange:v,"aria-label":x,className:y,children:[S,w]}),e[16]=f,e[17]=v,e[18]=x,e[19]=S,e[20]=C):C=e[20];const k=u?String(u.width):"";let T;e[21]!==m?(T=ne=>m("width",ne.target.value),e[21]=m,e[22]=T):T=e[22];let O;e[23]!==l?(O=l("contextPanel.browser.device.width"),e[23]=l,e[24]=O):O=e[24];let K;e[25]!==k||e[26]!==T||e[27]!==O?(K=n.jsx("input",{value:k,onChange:T,placeholder:"—",inputMode:"numeric","aria-label":O,className:b}),e[25]=k,e[26]=T,e[27]=O,e[28]=K):K=e[28];let R;e[29]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=R):R=e[29];const I=u?String(u.height):"";let N;e[30]!==m?(N=ne=>m("height",ne.target.value),e[30]=m,e[31]=N):N=e[31];let W;e[32]!==l?(W=l("contextPanel.browser.device.height"),e[32]=l,e[33]=W):W=e[33];let z;e[34]!==I||e[35]!==N||e[36]!==W?(z=n.jsx("input",{value:I,onChange:N,placeholder:"—",inputMode:"numeric","aria-label":W,className:b}),e[34]=I,e[35]=N,e[36]=W,e[37]=z):z=e[37];let H;e[38]!==r||e[39]!==s?(H=()=>r(ik(s)),e[38]=r,e[39]=s,e[40]=H):H=e[40];const M=!u;let Y;e[41]!==l?(Y=l("contextPanel.browser.device.rotate"),e[41]=l,e[42]=Y):Y=e[42];let j;e[43]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(Z,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=j):j=e[43];let P;e[44]!==H||e[45]!==M||e[46]!==Y?(P=n.jsx(Bt,{asChild:!0,children:n.jsx(It,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:H,disabled:M,"aria-label":Y,children:j})}),e[44]=H,e[45]=M,e[46]=Y,e[47]=P):P=e[47];let D;e[48]!==l?(D=l("contextPanel.browser.device.rotate"),e[48]=l,e[49]=D):D=e[49];let V;e[50]!==D?(V=n.jsx(Ot,{sideOffset:6,children:D}),e[50]=D,e[51]=V):V=e[51];let B;e[52]!==P||e[53]!==V?(B=n.jsxs(Ft,{children:[P,V]}),e[52]=P,e[53]=V,e[54]=B):B=e[54];let _;e[55]!==c||e[56]!==u?(_=u&&c<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(c*100),"%"]}):null,e[55]=c,e[56]=u,e[57]=_):_=e[57];let F;e[58]===Symbol.for("react.memo_cache_sentinel")?(F=["system","light","dark"],e[58]=F):F=e[58];let X;e[59]!==o||e[60]!==i||e[61]!==l?(X=n.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:F.map(ne=>n.jsx(It,{type:"button",variant:o===ne?"secondary":"ghost",size:"xs",className:Te("shrink-0 rounded-full px-2.5 typography-micro",o===ne?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(ne),"aria-pressed":o===ne,children:l(ne==="system"?"contextPanel.browser.device.schemeSystem":ne==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ne))}),e[59]=o,e[60]=i,e[61]=l,e[62]=X):X=e[62];let oe;return e[63]!==C||e[64]!==K||e[65]!==z||e[66]!==B||e[67]!==_||e[68]!==X?(oe=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[C,K,R,z,B,_,X]}),e[63]=C,e[64]=K,e[65]=z,e[66]=B,e[67]=_,e[68]=X,e[69]=oe):oe=e[69],oe};function uk(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const Fo=new Map,va=new Set,Ip=()=>{for(const t of va)t()},Oi=(t,e)=>{const s=t.trim();s&&(e.length===0?Fo.delete(s):Fo.set(s,[...e]),Ip())},fk=t=>{Fo.delete(t.trim())&&Ip()},Tp=[],pk=t=>Fo.get(t.trim())??Tp,hk=t=>(va.add(t),()=>{va.delete(t)}),mk=t=>{const e=Je.c(2);let s;return e[0]!==t?(s=()=>pk(t),e[0]=t,e[1]=s):s=e[1],a.useSyncExternalStore(hk,s,gk)};function gk(){return Tp}const Dp="oc.browser.hiddenDevServerPorts.v1",bk=Dr(Ls(),ii(a1().int().positive())),wa=new Set,Rp=[];let Qr=null;const bl=()=>{const t=Yo().getItem(Dp);if(Qr&&Qr.raw===t)return Qr.value;let e={};if(t!==null)try{const s=bk.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return Qr={raw:t,value:e},e},Np=t=>{Yo().setItem(Dp,JSON.stringify(t));for(const e of wa)e()},yk=(t=Gt())=>bl()[t]??Rp,xk=t=>{const e=Gt(),s=bl(),r=s[e]??[];r.includes(t)||Np({...s,[e]:[...r,t].sort((o,i)=>o-i)})},Sk=()=>{const t=Gt(),e=bl();if(!e[t])return;const s={...e};delete s[t],Np(s)},vk=t=>(wa.add(t),()=>{wa.delete(t)}),wk=()=>a.useSyncExternalStore(vk,kk,jk);function kk(){return yk()}function jk(){return Rp}const Ck=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Pk=2e3,Ek=t=>wu("http://localhost",t),Mp=t=>{const e=Je.c(51),{onOpen:s,directory:r}=t,o=r===void 0?"":r,{t:i}=Ct();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"loading"},e[0]=c):c=e[0];const[l,d]=a.useState(c),u=mk(o);let f;e[1]!==o?(f=()=>Ek(o),e[1]=o,e[2]=f):f=e[2];const[p]=a.useState(f);let m;e[3]!==o?(m=()=>_g(o),e[3]=o,e[4]=m):m=e[4];const[g]=a.useState(m);let b;e[5]!==o?(b=Pm(o),e[5]=o,e[6]=b):b=e[6];const v=b,x=gl(o),y=Em(o);let h,S;e[7]!==o||e[8]!==y?(h=()=>{if(y){d({kind:"ready",servers:[]});return}let D=!0,V=null;const B=new AbortController,_=()=>{i0(B.signal,o).then(F=>{D&&(d(F),V=setTimeout(_,Pk))})};return _(),()=>{D=!1,V&&clearTimeout(V),B.abort()}},S=[o,y],e[7]=o,e[8]=y,e[9]=h,e[10]=S):(h=e[9],S=e[10]),a.useEffect(h,S);const w=l.kind==="ready"?l.servers:null;let C;e[11]!==u||e[12]!==w?(C=c0({announced:u,discovered:w}),e[11]=u,e[12]=w,e[13]=C):C=e[13];const k=C,T=wk();let O;if(e[14]!==k||e[15]!==T){let D;e[17]!==T?(D=V=>V.announced||!T.includes(V.port),e[17]=T,e[18]=D):D=e[18],O=k.filter(D),e[14]=k,e[15]=T,e[16]=O}else O=e[16];const K=O,R=k.length-K.length;let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(Wy,{width:110,height:110,className:"shrink-0 opacity-20"}),e[19]=I):I=e[19];let N;e[20]!==i?(N=i("contextPanel.browser.empty"),e[20]=i,e[21]=N):N=e[21];let W;e[22]!==N?(W=n.jsx("span",{className:"typography-ui-header text-foreground",children:N}),e[22]=N,e[23]=W):W=e[23];let z;e[24]!==i?(z=i("contextPanel.browser.emptyHint"),e[24]=i,e[25]=z):z=e[25];let H;e[26]!==z?(H=n.jsx("span",{className:"typography-micro text-muted-foreground",children:z}),e[26]=z,e[27]=H):H=e[27];let M;e[28]!==W||e[29]!==H?(M=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[W,H]}),e[28]=W,e[29]=H,e[30]=M):M=e[30];let Y;e[31]!==u||e[32]!==k.length||e[33]!==o||e[34]!==R||e[35]!==v||e[36]!==s||e[37]!==p||e[38]!==x||e[39]!==g||e[40]!==i||e[41]!==K?(Y=k.length>0?n.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[n.jsx("span",{className:"shrink-0 typography-micro text-start text-muted-foreground",children:u.length>0?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),p&&!g?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pe-0.5",children:K.map(D=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(It,{type:"button",variant:"outline",size:"sm",className:Te("min-w-0 flex-1 justify-start gap-2",p&&"cursor-default opacity-60"),"aria-disabled":p||void 0,onClick:()=>{p||(fk(o),s(D.url))},children:[v?n.jsx("span",{className:"shrink-0",role:"img","aria-label":x??i("contextPanel.browser.spaceAddress"),title:x??i("contextPanel.browser.spaceAddress"),children:n.jsx(Z,{name:"box-3",className:"size-3.5","aria-hidden":"true"})}):n.jsx(Z,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",children:qo(D.url)||D.url}),g?n.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":i("contextPanel.browser.devServers.spaceOnlyDesktop"),title:i("contextPanel.browser.devServers.spaceOnlyDesktop"),children:n.jsx(Z,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):n.jsx("span",{className:"ms-auto truncate typography-micro text-muted-foreground",children:Ck(D.url)})]}),D.announced?null:n.jsx(It,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>xk(D.port),"aria-label":i("contextPanel.browser.devServers.hide",{port:D.port}),title:i("contextPanel.browser.devServers.hide",{port:D.port}),children:n.jsx(Z,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},D.port))}),R>0?n.jsx(It,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:Sk,children:R===1?i("contextPanel.browser.devServers.showHiddenSingle",{count:R}):i("contextPanel.browser.devServers.showHiddenPlural",{count:R})}):null]}):null,e[31]=u,e[32]=k.length,e[33]=o,e[34]=R,e[35]=v,e[36]=s,e[37]=p,e[38]=x,e[39]=g,e[40]=i,e[41]=K,e[42]=Y):Y=e[42];let j;e[43]!==k.length||e[44]!==l.kind||e[45]!==i?(j=k.length===0&&l.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[43]=k.length,e[44]=l.kind,e[45]=i,e[46]=j):j=e[46];let P;return e[47]!==M||e[48]!==Y||e[49]!==j?(P=n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[I,M,Y,j]}),e[47]=M,e[48]=Y,e[49]=j,e[50]=P):P=e[50],P},Es=t=>Math.round(t),Ik=(t,e)=>{const s=t.text.trim(),r=Object.entries(t.attributes).map(([l,d])=>`${l}="${d}"`).join(" "),o=t.ancestry.map(l=>l.selectorPart).join(" > "),i=t.computedStyle,c=t.bounds;return[`Element ${e+1}: ${t.tag}`,s?`- Text: ${s}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,o?`- Ancestry: ${o}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Es(c.x)}, y=${Es(c.y)}, width=${Es(c.width)}, height=${Es(c.height)}`,`- Styles: display=${i.display??""}; position=${i.position??""}; font=${i.fontWeight??""} ${i.fontSize??""} / ${i.lineHeight??""} ${i.fontFamily??""}; color=${i.color??""}; background=${i.backgroundColor??""}`].filter(l=>typeof l=="string")},Tk=(t,e)=>{const s=t.rect;return`Region ${e+1}: x=${Es(s.x)}, y=${Es(s.y)}, width=${Es(s.width)}, height=${Es(s.height)}`},Dk=(t,e)=>{const s=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Es(s.x)}, y=${Es(s.y)}, width=${Es(s.width)}, height=${Es(s.height)}`},Rk=({payload:t,screenshotAttached:e,intro:s})=>{const r=s.replace(/[.:]+$/g,""),o=t.comment.trim(),i=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Es(t.viewport.width)}x${Es(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,o?`Comment: ${o}`:null];for(const[c,l]of t.elements.entries())i.push("",...Ik(l.element,c));return t.regions.length>0&&(i.push(""),t.regions.forEach((c,l)=>i.push(Tk(c,l)))),t.strokes.length>0&&(i.push(""),t.strokes.forEach((c,l)=>i.push(Dk(c,l)))),i.filter(c=>typeof c=="string").join(`
1044
- `)},Nk=t=>{const e=Je.c(7),{t:s}=Ct(),r=xt(Ak),o=xt(Ok),i=Hy(Bk),c=Vy(Fk);let l;return e[0]!==c||e[1]!==i||e[2]!==r||e[3]!==t||e[4]!==o||e[5]!==s?(l=async d=>{const u=r??(o?"draft":null);if(!u){ze.error(s("contextPanel.browser.annotate.noSession"));return}let f=!1;if(d.screenshot)try{await c(d.screenshot),f=!0}catch{f=!1}i({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:Rk({payload:d.payload,screenshotAttached:f,intro:s("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),ze.success(s("contextPanel.browser.annotate.attached")),requestAnimationFrame(Uy)},e[0]=c,e[1]=i,e[2]=r,e[3]=t,e[4]=o,e[5]=s,e[6]=l):l=e[6],l},Mk=()=>{const t=Je.c(16),{t:e}=Ct();let s;t[0]!==e?(s=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=s):s=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=i):i=t[7];let c;t[8]!==e?(c=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=c):c=t[9];let l;return t[10]!==s||t[11]!==r||t[12]!==o||t[13]!==i||t[14]!==c?(l={select:s,marquee:r,draw:o,commentPlaceholder:i,submit:c},t[10]=s,t[11]=r,t[12]=o,t[13]=i,t[14]=c,t[15]=l):l=t[15],l};function Ak(t){return t.currentSessionId}function Ok(t){return t.newSessionDraft?.open}function Bk(t){return t.addDraft}function Fk(t){return t.addAttachedFile}const Lk=3e4,_k=3,$k=250,zk={attempts:0,windowStartedAt:null},Kk=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=Lk,r=s?0:t.attempts;return r>=_k?null:{delayMs:$k*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},Wk=-3,Jr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Un=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Hk=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=a.useState(e?{kind:"loading",url:e}:f0),[i,c]=a.useState(e),[l,d]=a.useState(""),[u,f]=a.useState(!1),[p,m]=a.useState(!1),g=a.useRef(s);g.current=s;const b=a.useRef(zk);return a.useEffect(()=>{if(!t)return;const v=()=>{try{const R=t.getURL();return Jr(R)?R:""}catch{return""}},x=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},y=R=>{Jr(R)&&(c(R),g.current(R))},h=()=>{const R=v();o({kind:"loading",url:R})},S=()=>{const R=v();let I="";try{I=t.getTitle()||""}catch{I=""}d(I),y(R),x(),o(N=>N.kind==="failed"?N:{kind:"ready",url:R,title:I})},w=R=>{const I=Un(R);Jr(I.url)&&(y(I.url),x())},C=R=>{const I=Un(R),N=Array.isArray(I.favicons)?I.favicons.find(Boolean):"",W=v();if(!N||!W)return;let z=-1;try{z=t.getWebContentsId()}catch{return}!Number.isFinite(z)||z<0||np.getState().resolve(W,N,z)},k=R=>{const I=Un(R);typeof I.title=="string"&&d(I.title)},T=R=>{const I=Un(R);if(I.isMainFrame===!1)return;const N=typeof I.errorCode=="number"?I.errorCode:0;N!==Wk&&o({kind:"failed",url:Jr(I.validatedURL)?I.validatedURL:v(),code:N,description:typeof I.errorDescription=="string"?I.errorDescription:""})};let O=null;const K=()=>{const R=v(),I=Kk(b.current,Date.now());if(!I){o({kind:"failed",url:R,code:0,description:"",crashed:!0});return}b.current=I.state,o({kind:"loading",url:R}),O=setTimeout(()=>{O=null;try{t.reload()}catch{o({kind:"failed",url:R,code:0,description:"",crashed:!0})}},I.delayMs)};t.addEventListener("did-start-loading",h),t.addEventListener("did-stop-loading",S),t.addEventListener("did-navigate",w),t.addEventListener("did-navigate-in-page",w),t.addEventListener("page-title-updated",k),t.addEventListener("page-favicon-updated",C),t.addEventListener("did-fail-load",T),t.addEventListener("render-process-gone",K),t.addEventListener("crashed",K);try{!t.isLoading()&&v()&&S()}catch{}return()=>{O!==null&&clearTimeout(O),t.removeEventListener("render-process-gone",K),t.removeEventListener("crashed",K),t.removeEventListener("did-start-loading",h),t.removeEventListener("did-stop-loading",S),t.removeEventListener("did-navigate",w),t.removeEventListener("did-navigate-in-page",w),t.removeEventListener("page-title-updated",k),t.removeEventListener("page-favicon-updated",C),t.removeEventListener("did-fail-load",T)}},[t]),{status:r,url:i,title:l,canGoBack:u,canGoForward:p}},ed=1e3,Ap=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},Vk=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},Uk=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},Gk=(t,e)=>{const s=a.useRef(0),r=a.useRef(0),o=a.useRef(0),i=a.useRef(null),c=a.useCallback(()=>{if(!t||document.activeElement!==t)return;const l=i.current;l&&l.isConnected&&l!==document.body?l.focus({preventScroll:!0}):t.blur()},[t]);return a.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=Uk());const l=d=>{if(document.activeElement!==t){i.current=Vk(d);return}const u=e.current,f=s.current>r.current||Date.now()<o.current;u&&Ap(u)&&!f||r.current>0||c()};return document.addEventListener("focusin",l,!0),()=>document.removeEventListener("focusin",l,!0)},[c,e,t]),a.useCallback(async l=>{const d=t!==null&&document.activeElement===t;let u=!1;const f=()=>{u&&(u=!1,r.current-=1,o.current=Date.now()+ed,!d&&r.current===0&&c())},p=()=>(u||(u=!0,r.current+=1),f);s.current+=1;try{return await l(p)}finally{s.current-=1,o.current=Date.now()+ed,f()}},[c,t])},qk=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),Yk=()=>document.visibilityState==="visible",Xk=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,eo=.5,Zk=-3,Qk=4,Jk="persist:openchamber-browser",Op=(t,e,s)=>Hs(t)!==null&&du(e)?{icon:"box-3",label:s}:void 0,td=t=>{const e=Hs(t);return e?`openchamber-space-preview:${e}`:Jk},sd=20,ej=600,tj=2e4,sj=15e3,nj=t=>{if(!t||Ap(t))return()=>{};const e=t.getBoundingClientRect(),s=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=s}},rj=({initialUrl:t,directory:e,tabID:s,ownerSessionId:r,visible:o})=>{const{t:i}=Ct(),{currentTheme:c}=cr(),l=a.useRef(null),[d,u]=a.useState(null),f=a.useCallback(we=>{l.current=we,u(we)},[]),p=de(we=>we.setContextPanelTabTargetPath),m=a.useRef(qn(t)),g=m.current!==yn?m.current:"",[b,v]=a.useState(g?null:yn),x=gl(e),[y,h]=a.useState(g),[S,w]=a.useState(!1),[C,k]=a.useState(!1),[T,O]=a.useState(0),K=a.useRef(0),[R,I]=a.useState(!1),[N,W]=a.useState(Oo),z=a.useRef(N);z.current=N;const H=a.useRef([]),[M,Y]=a.useState("system"),[j,P]=a.useState({width:0,height:0}),D=a.useRef(null),V=a.useRef(null),B=Cs(e),_=a.useRef(!!g&&!Im(B,s)),F=a.useRef(null);a.useEffect(()=>{cu(B,s)},[B,s]);const X=a.useRef(!1),oe=a.useRef(Date.now()),ne=a.useCallback(we=>{!we||we===yn||!e||!s||p(e,s,we)},[e,s,p]),A=Hk(d,{initialUrl:g,onUrlChange:a.useCallback(we=>{const De=zn(we);h(De),ne(De)},[ne])}),[te,U]=a.useState(null),[Pe,xe]=a.useState(Hs(e)===null);a.useEffect(()=>{const we=Hs(e);if(we===null){xe(!0);return}let De=!0;return xe(!1),Wn("desktop_space_preview_prepare",{spaceId:we}).then(()=>{De&&xe(!0)}).catch(()=>{De&&U(g||"http://localhost/")}),()=>{De=!1}},[e,g]);const ce=Nk(e),Oe=Mk(),me=A.status.kind==="loading",ie=Zn(jp(e)),q=Zn(we=>we.recordVisit),ue=Zn(we=>we.forget);a.useEffect(()=>{A.status.kind==="ready"&&q(e,{url:zn(A.status.url),title:A.status.title})},[e,A.status,q]);const ve=a.useMemo(()=>kp(ie,y),[ie,y]),Ee=a.useCallback(we=>{const De=qn(we);De!==yn&&(_.current=!1,h(De),U(null),Zl(De,e).then(ot=>{const rt=l.current;if(!rt){v(ot);return}try{rt.loadURL(ot)}catch{v(ot)}}).catch(ot=>{ot instanceof Ql&&U(De)}))},[e]);a.useEffect(()=>{if(!g)return;let we=!0;return Zl(g,e).then(De=>{we&&v(De)}).catch(De=>{if(we){if(De instanceof Ql){U(g),_.current=!1,v(yn);return}v(g)}}),()=>{we=!1}},[]);const L=a.useMemo(()=>({executeJavaScript:async(we,De)=>{const ot=l.current;if(!ot)throw new Error("Browser view is not available");return ot.executeJavaScript(we,De)},capturePage:async()=>{const we=l.current;if(!we)return null;const De=we.getWebContentsId();return Number.isFinite(De)?await Wn("desktop_browser_capture_page",{webContentsId:De}):null}}),[]),le=a.useCallback(()=>{if(S){w(!1),go(L);return}if(!A.url){ze.error(i("contextPanel.browser.annotate.noPage"));return}const we=P0(c.metadata.variant==="light"?"light":"dark");w(!0),j0({host:L,theme:we,labels:Oe}).then(async De=>{w(!1),De&&await ce(De)}).catch(()=>{w(!1),ze.error(i("contextPanel.browser.annotate.failed"))})},[L,ce,c,S,A.url,Oe,i]);a.useEffect(()=>{if(!S)return;const we=De=>{Gy(De)||De.key!=="Escape"||(De.preventDefault(),De.stopImmediatePropagation(),w(!1),go(L))};return window.addEventListener("keydown",we,!0),()=>window.removeEventListener("keydown",we,!0)},[L,S]);const G=a.useRef(!1);a.useEffect(()=>{if(!d)return;const we=()=>{G.current=!0};return d.addEventListener("dom-ready",we),d.addEventListener("did-fail-load",we),()=>{d.removeEventListener("dom-ready",we),d.removeEventListener("did-fail-load",we)}},[d]);const se=a.useCallback(async()=>{const we=Date.now()+sj;for(;!(l.current&&G.current)&&Date.now()<we;)await new Promise(De=>setTimeout(De,100));return l.current},[]),je=a.useCallback(async(we=8e3)=>{const De=Date.now();for(;;){const ot=l.current;if(!ot)return!1;let rt=!1;try{rt=ot.isLoading()}catch{return!1}if(!rt)return!0;if(Date.now()-De>we)return!1;await new Promise(Xe=>setTimeout(Xe,120))}},[]),he=a.useCallback(async(we,De,ot)=>{const rt=await se();if(!rt)throw new Error("The browser panel is not ready");const Xe=()=>{Jc(De.viewport)&&(W(Sa(De.viewport)),I(!0))};if(we==="browser.back"||we==="browser.forward"){const tt=we==="browser.back";if(!(tt?rt.canGoBack():rt.canGoForward()))throw new Error(tt?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");tt?rt.goBack():rt.goForward(),await new Promise(it=>setTimeout(it,150)),await je();let mt="";try{mt=rt.getTitle()||""}catch{mt=""}return{url:zn(rt.getURL()),title:mt}}if(we==="browser.capture"){const tt=nj(D.current);try{await new Promise(it=>{requestAnimationFrame(()=>requestAnimationFrame(()=>it()))}),await je();const bt=await L.capturePage();if(!bt)throw new Error("The page could not be captured");let mt="";try{mt=rt.getTitle()||""}catch{mt=""}return{...bt,url:zn(rt.getURL()),title:mt,viewport:Zr(z.current)}}finally{tt()}}if(we==="browser.resize"){if(!Jc(De.viewport))throw new Error("viewport is required");return Xe(),await new Promise(tt=>setTimeout(tt,200)),await je(),{viewport:Zr(Sa(De.viewport))}}if(we==="browser.open"){const tt=typeof De.url=="string"?De.url:"";if(!tt)throw new Error("url is required");Xe(),Ee(tt),await new Promise(it=>setTimeout(it,150));const bt=await je(25e3);let mt="";try{mt=rt.getTitle()||""}catch{mt=""}return{url:qn(tt),title:mt,opened:!0,settled:bt,viewport:Zr(z.current)}}await je();const ht=tt=>typeof tt=="string"&&tt?tt:void 0,_e=(()=>{switch(we){case"browser.snapshot":return Q0({selector:ht(De.selector)});case"browser.click":return J0({selector:ht(De.selector),text:ht(De.text)});case"browser.type":return ek({selector:String(De.selector??""),value:String(De.value??""),submit:De.submit===!0});case"browser.inspect":return nk({selector:String(De.selector??"")});case"browser.scroll":return tk({selector:ht(De.selector),direction:ht(De.direction)});default:return null}})();if(!_e)throw new Error(`Unsupported browser action: ${we}`);let Be=()=>{};(we==="browser.click"||we==="browser.type")&&(await Wn("desktop_browser_keep_page_focused",{webContentsId:rt.getWebContentsId()}).then(bt=>bt.focused===!0).catch(()=>!1)||(Be=ot(),rt.focus({preventScroll:!0})));let Ke;try{Ke=await rt.executeJavaScript(_e,!0)}finally{Be()}if(!Ke||typeof Ke!="object")throw new Error("The page returned no result");const Fe=Ke;if(Fe.ok!==!0)throw new Error(typeof Fe.error=="string"&&Fe.error?Fe.error:"Browser action failed");if(we==="browser.snapshot"){const tt=H.current;return{...Fe,viewport:Zr(z.current),...tt.length>0?{consoleProblems:[...tt]}:{}}}return(we==="browser.click"||we==="browser.type"&&De.submit===!0)&&(await new Promise(tt=>setTimeout(tt,150)),await je()),Ke},[L,Ee,je,se]),ge=Gk(d,D),[ke,Ae]=a.useState(!1),$=a.useCallback((we,De)=>(Ae(!0),ge(ot=>he(we,De,ot))),[ge,he]),fe=a.useCallback(()=>{const we=l.current;if(!we)return{title:"",url:""};let De="",ot="";try{De=we.getTitle()||""}catch{De=""}try{ot=zn(we.getURL())}catch{ot=""}return{title:De,url:ot}},[]);a.useEffect(()=>O0({tabId:s,directory:B,ownerSessionId:r,describe:fe,run:$}),[fe,r,$,B,s]),a.useEffect(()=>{const we=L;return()=>{go(we)}},[L]),a.useEffect(()=>{if(!d)return;const we=ot=>{const rt=ot;if(typeof rt.level!="number"||rt.level<2)return;const Xe=rt.sourceId?`${rt.sourceId}${rt.line?`:${rt.line}`:""}`:"";H.current.push({level:rt.level>=3?"error":"warning",message:String(rt.message??"").slice(0,400),source:Xe}),H.current.length>sd&&H.current.splice(0,H.current.length-sd)},De=()=>{H.current=[]};return d.addEventListener("console-message",we),d.addEventListener("did-start-loading",De),()=>{d.removeEventListener("console-message",we),d.removeEventListener("did-start-loading",De)}},[d]);const be=a.useRef(new Set),Ie=a.useCallback(we=>{be.current.clear(),Ee(we)},[Ee]),Ye=a.useRef(A.status);Ye.current=A.status;const nt=a.useRef(!1);A.status.kind==="ready"&&A.status.url&&(nt.current=!0),a.useEffect(()=>Tm(B,s,we=>{Rm(Ye.current,nt.current)&&Ie(we)}),[Ie,B,s]),a.useEffect(()=>{if(!d)return;const we=ot=>{const rt=Un(ot),Xe=typeof rt.url=="string"?rt.url:"";!Xe||!Jl(Xe,e)||(ot.preventDefault(),Ee(Xe))},De=ot=>{const rt=Un(ot);if(rt.isMainFrame===!1||rt.errorCode===-3)return;const Xe=typeof rt.validatedURL=="string"?rt.validatedURL:"";!Xe||!Jl(Xe,e)||be.current.has(Xe)||(be.current.add(Xe),Ee(Xe))};return d.addEventListener("will-navigate",we),d.addEventListener("did-fail-load",De),()=>{d.removeEventListener("will-navigate",we),d.removeEventListener("did-fail-load",De)}},[e,Ee,d]),a.useEffect(()=>{if(!d)return;const we=De=>{const ot=De.detail;De.preventDefault(),ot?.url&&Ee(ot.url)};return d.addEventListener("new-window",we),()=>d.removeEventListener("new-window",we)},[Ee,d]);const Ue=a.useCallback(we=>{const De=Math.min(Qk,Math.max(Zk,we));K.current=De,O(De);try{l.current?.setZoomLevel(De)}catch{}},[]);a.useEffect(()=>{const we=De=>{if(!(De instanceof CustomEvent))return;const ot=De.detail,rt=l.current;!rt||document.activeElement!==rt||(ot==="zoom-in"?Ue(K.current+eo):ot==="zoom-out"?Ue(K.current-eo):ot==="zoom-reset"&&Ue(0))};return window.addEventListener("openchamber:zoom",we),()=>window.removeEventListener("openchamber:zoom",we)},[Ue]);const Ve=a.useCallback(we=>{Wn("desktop_browser_clear_data",{partition:td(e),cookies:we==="cookies",cache:we==="cache"}).then(()=>{ze.success(i(we==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{l.current?.reloadIgnoringCache()}catch{}}).catch(()=>ze.error(i("contextPanel.browser.clearFailed")))},[e,i]);a.useEffect(()=>{const we=D.current;if(!we||typeof ResizeObserver>"u")return;const De=new ResizeObserver(ot=>{const rt=ot[0]?.contentRect;rt&&P({width:rt.width,height:rt.height})});return De.observe(we),()=>De.disconnect()},[]);const Se=a.useCallback(we=>{Y(we);const De=l.current;if(!De)return;let ot=-1;try{ot=De.getWebContentsId()}catch{return}Wn("desktop_browser_set_color_scheme",{webContentsId:ot,scheme:we}).catch(rt=>{Y("system"),ze.error(rt instanceof Error?rt.message:i("contextPanel.browser.device.schemeFailed"))})},[i]),ye=a.useCallback(()=>{try{me?l.current?.stop():l.current?.reload()}catch{}},[me]),Ge=A.status,qe=a.useSyncExternalStore(qk,Yk),ft=o&&qe||r!==null||ke;a.useEffect(()=>{const we=ht=>{k(!0);const ee=setTimeout(()=>{try{l.current?.reload()}catch{}},ht);return()=>clearTimeout(ee)};if(Ge.kind==="loading")return;const De=_.current||F.current===Ge;if(_.current&&(Ge.kind==="failed"||Ge.kind==="ready"&&Ge.url)&&(_.current=!1,F.current=Ge),Ge.kind==="failed"){const ht=Dm(Ge,{run:V.current,restored:De,watched:ft,now:Date.now()});if(V.current=ht.run,ht.next==="retry")return we(ht.delayMs);k(ht.next==="pause");return}if(V.current=null,Ge.kind!=="ready"||!Ge.url||!du(Ge.url)){X.current=!0,k(!1);return}if(De||X.current||Date.now()-oe.current>tj){X.current=!0,k(!1);return}let ot=!1,rt=null;return(Hs(e)?Promise.resolve(null):a0(zn(Ge.url))).then(ht=>{if(!ot){if(ht===null||ht<500){X.current=!0,k(!1);return}rt=we(ej)}}),()=>{ot=!0,rt?.()}},[e,Ge,ft]);const et=A.status.kind==="failed"&&!C?A.status:null,St=ak(N,j);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(Cp,{address:y,onAddressChange:h,onSubmit:Ie,suggestions:ve,onForgetSuggestion:we=>ue(e,we),onBack:()=>{try{l.current?.goBack()}catch{}},onForward:()=>{try{l.current?.goForward()}catch{}},onReload:ye,onOpenExternal:()=>{ti(A.url||y)},addressMark:Op(e,y,x??i("contextPanel.browser.spaceAddress")),canOpenExternal:Hs(e)===null,canGoBack:A.canGoBack,canGoForward:A.canGoForward,isLoading:me,onAnnotate:le,isAnnotating:S,onOpenDevTools:()=>{try{l.current?.openDevTools()}catch{}},onHardReload:()=>{try{l.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ue(T+eo),onZoomOut:()=>Ue(T-eo),onZoomReset:()=>Ue(0),zoomPercent:Math.round(Math.pow(1.2,T)*100),onClearCookies:()=>Ve("cookies"),onClearCache:()=>Ve("cache"),onToggleDeviceBar:()=>I(we=>!we),isDeviceBarOpen:R}),R?n.jsx(dk,{viewport:N,onViewportChange:W,colorScheme:M,onColorSchemeChange:Se,scale:St?.scale??1}):null,n.jsxs("div",{ref:D,className:Te("relative min-h-0 flex-1 bg-background",St&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[b!==null&&Pe?n.jsx("webview",{ref:f,src:b,partition:td(e),allowpopups:!0,style:St?{width:`${St.width}px`,height:`${St.height}px`,transform:`scale(${St.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,b!==null&&!g&&!A.url&&!me?n.jsx(Mp,{onOpen:Ie,directory:e}):null,C?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:i("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.waitingForServerHint")})]}):null,te?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[Hs(e)!==null?n.jsx(Z,{name:"box-3",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:i("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i(Hs(e)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:te})})]}):null,et&&!te?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:et.crashed?i("contextPanel.browser.crashed"):i("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:et.crashed?i("contextPanel.browser.crashedHint"):et.description||i("contextPanel.browser.loadFailedUnknown")})]}):null,me?n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:n.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},oj=t=>{const e=Je.c(74),{initialUrl:s,directory:r,tabID:o}=t,{t:i}=Ct(),c=de(aj);let l;e[0]!==s?(l=qn(s),e[0]=s,e[1]=l):l=e[1];const d=l,u=d!==yn?d:"",[f,p]=a.useState(u);let m;e[2]!==r||e[3]!==u?(m=vi(u,r),e[2]=r,e[3]=u,e[4]=m):m=e[4];const[g,b]=a.useState(m);let v;e[5]!==r||e[6]!==u?(v=wu(u,r)?u:"",e[5]=r,e[6]=u,e[7]=v):v=e[7];const[x,y]=a.useState(v);let h;e[8]!==r?(h=Hs(r),e[8]=r,e[9]=h):h=e[9];const S=h!==null,w=gl(r);let C;e[10]!==u?(C=u?[u]:[],e[10]=u,e[11]=C):C=e[11];const[k,T]=a.useState(C),[O,K]=a.useState(u?0:-1),[R,I]=a.useReducer(lj,0);let N,W;e[12]!==r||e[13]!==o?(N=()=>{cu(Cs(r),o)},W=[r,o],e[12]=r,e[13]=o,e[14]=N,e[15]=W):(N=e[14],W=e[15]),a.useEffect(N,W);let z;e[16]!==r||e[17]!==c||e[18]!==o?(z=ue=>{!ue||ue===yn||!r||!o||c(r,o,ue)},e[16]=r,e[17]=c,e[18]=o,e[19]=z):z=e[19];const H=z;let M;e[20]!==r?(M=jp(r),e[20]=r,e[21]=M):M=e[21];const Y=Zn(M),j=Zn(cj),P=Zn(dj);let D;e[22]!==f||e[23]!==Y?(D=kp(Y,f),e[22]=f,e[23]=Y,e[24]=D):D=e[24];const V=D;let B;e[25]!==r||e[26]!==O||e[27]!==H||e[28]!==j?(B=ue=>{const ve=qn(ue);if(ve===yn)return;p(ve);const Ee=vi(ve,r);b(Ee),y(Ee?"":ve),H(ve),j(r,{url:ve}),T(L=>{const le=O>=0?L.slice(0,O+1):[];return le[le.length-1]===ve?(K(le.length-1),le):(K(le.length),[...le,ve])})},e[25]=r,e[26]=O,e[27]=H,e[28]=j,e[29]=B):B=e[29];const _=B;let F;e[30]!==r||e[31]!==k||e[32]!==H?(F=ue=>{const ve=k[ue];if(!ve)return;K(ue),p(ve);const Ee=vi(ve,r);b(Ee),y(Ee?"":ve),H(ve)},e[30]=r,e[31]=k,e[32]=H,e[33]=F):F=e[33];const X=F;let oe;e[34]!==r||e[35]!==P?(oe=ue=>P(r,ue),e[34]=r,e[35]=P,e[36]=oe):oe=e[36];let ne,A;e[37]!==X||e[38]!==O?(ne=()=>X(O-1),A=()=>X(O+1),e[37]=X,e[38]=O,e[39]=ne,e[40]=A):(ne=e[39],A=e[40]);let te;e[41]!==f||e[42]!==g?(te=()=>{ti(g||f)},e[41]=f,e[42]=g,e[43]=te):te=e[43];let U;e[44]!==w||e[45]!==i?(U=w??i("contextPanel.browser.spaceAddress"),e[44]=w,e[45]=i,e[46]=U):U=e[46];let Pe;e[47]!==f||e[48]!==r||e[49]!==U?(Pe=Op(r,f,U),e[47]=f,e[48]=r,e[49]=U,e[50]=Pe):Pe=e[50];const xe=!x,ce=O>0,Oe=O>=0&&O<k.length-1;let me;e[51]!==f||e[52]!==_||e[53]!==V||e[54]!==oe||e[55]!==ne||e[56]!==A||e[57]!==te||e[58]!==Pe||e[59]!==xe||e[60]!==ce||e[61]!==Oe?(me=n.jsx(Cp,{address:f,onAddressChange:p,onSubmit:_,suggestions:V,onForgetSuggestion:oe,onBack:ne,onForward:A,onReload:I,onOpenExternal:te,addressMark:Pe,canOpenExternal:xe,canGoBack:ce,canGoForward:Oe,isLoading:!1}),e[51]=f,e[52]=_,e[53]=V,e[54]=oe,e[55]=ne,e[56]=A,e[57]=te,e[58]=Pe,e[59]=xe,e[60]=ce,e[61]=Oe,e[62]=me):me=e[62];let ie;e[63]!==r||e[64]!==S||e[65]!==g||e[66]!==_||e[67]!==R||e[68]!==i||e[69]!==x?(ie=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:x?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[S?n.jsx(Z,{name:"box-3",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:i(S?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:qo(x)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.remoteLoopback.hint")})]}):g?n.jsx("iframe",{src:g,title:i("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${R}`):n.jsx(Mp,{onOpen:_,directory:r})}),e[63]=r,e[64]=S,e[65]=g,e[66]=_,e[67]=R,e[68]=i,e[69]=x,e[70]=ie):ie=e[70];let q;return e[71]!==me||e[72]!==ie?(q=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[me,ie]}),e[71]=me,e[72]=ie,e[73]=q):q=e[73],q},ij=t=>{const e=Je.c(3),[s]=a.useState(Xk);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(rj,{...t}):n.jsx(oj,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function aj(t){return t.setContextPanelTabTargetPath}function lj(t){return t+1}function cj(t){return t.recordVisit}function dj(t){return t.forget}const uj=t=>{const e=Je.c(13),{zone:s,children:r}=t,[o]=a.useState(fj);let i;e[0]!==s?(i=m=>m.body[s],e[0]=s,e[1]=i):i=e[1];const c=Rr(i);let l,d;e[2]!==c||e[3]!==o||e[4]!==s?(l=()=>{const m=c??Rr.getState().body[s];if(!m){o.remove();return}if(o.parentElement===m)return;const g=document.activeElement;m.moveBefore&&o.isConnected?m.moveBefore(o,null):m.append(o),g instanceof HTMLElement&&o.contains(g)&&document.activeElement!==g&&g.focus({preventScroll:!0})},d=[c,o,s],e[2]=c,e[3]=o,e[4]=s,e[5]=l,e[6]=d):(l=e[5],d=e[6]),a.useLayoutEffect(l,d);let u,f;e[7]!==o?(u=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=u,e[9]=f):(u=e[8],f=e[9]),a.useLayoutEffect(u,f);let p;return e[10]!==r||e[11]!==o?(p=Oa.createPortal(r,o),e[10]=r,e[11]=o,e[12]=p):p=e[12],p};function fj(){const t=document.createElement("div");return t.style.display="contents",t}const ka=2e4,pj=(t,e)=>{if(!t)return 1;let s=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(s+=1,s>e))return s;return s},to=(t,e)=>Nm(Mm.getState().dictionary,t,e),hj=t=>{const s=(t instanceof Error?t.message:String(t??"")).toLowerCase();return s.includes("file not found")||s.includes("not found")||s.includes("enoent")||s.includes("no such file")||s.includes("does not exist")?"missing":"unreadable"},mj=async(t,e,s)=>{const r=!!(s?.directory&&!Qy(e,s.directory));if(t.readFile)return(await t.readFile(e,{optional:!0,directory:s?.directory,allowOutsideWorkspace:r})).content??"";const o=new URLSearchParams({path:e,optional:"true"});s?.directory&&o.set("directory",s.directory),r&&o.set("allowOutsideWorkspace","true");const i=await Us(`/api/fs/read?${o.toString()}`,{cache:"no-store",headers:s?.directory?{"x-opencode-directory":s.directory}:void 0});if(!i.ok){const c=await i.json().catch(()=>({error:i.statusText}));throw new Error(c.error||"Failed to read file")}return i.text()},gj=async(t,e,s)=>{if(qy(e)||Yy(e)||Xy(e))return{ok:!0};try{const r=await mj(t,e,s);return Zy(r)?{ok:!1,reason:"binary"}:pj(r,ka)>ka?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:hj(r)}}},bj=t=>{if(t==="too-large"){const e=ka.toLocaleString(af());return to("contextFileOpen.failure.tooLarge",{count:e})}return to(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},nd=8;let Nr=null;const Bp=(t,e)=>Math.abs(e.clientX-t.x)<=nd&&Math.abs(e.clientY-t.y)<=nd,Fp=t=>{Nr={x:t.clientX,y:t.clientY}},Lp=t=>{const e=Nr;return Nr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Bp(e,t)},_p=t=>Nr!==null&&Bp(Nr,t);let $p=null;const rd=t=>{$p=t},zp=()=>$p,od=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},Kp=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:od(e.path);return!r||od(t.path)===r||t.type==="directory"&&Am(r,t.path,t.path)!==null?null:r},yj=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},Qn=t=>Array.from(t.types).includes("Files"),Er=t=>Array.from(t.types).includes(si)?zp():null,Wp=(t,e,s)=>t.getData(si)===li(e,s.path),xj=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(s=>{if(s.kind!=="file"||s.webkitGetAsEntry()?.isDirectory)return[];const r=s.getAsFile();return r?[r]:[]})},Sj=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),ls=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},li=(t,e)=>{const s=ls(e),r=ls(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},hr=(t,e)=>{const s=li(t,e);if(s!==".")return s;const r=ls(t);return r.split("/").filter(Boolean).pop()??r},xo=t=>{const e=ls(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},vj=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),wj=new Set(["node_modules"]),kj=t=>wj.has(t),jj=t=>{const e=ls(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Cj=8,Xs=new Map,yl=t=>JSON.stringify([Gt(),t]),Pj=t=>{const e=yl(t),s=Xs.get(e);return s?(s.touchedAt=Date.now(),Xs.delete(e),Xs.set(e,s),s):null},Bi=t=>{const e=yl(t),s=Xs.get(e);if(s)return s.touchedAt=Date.now(),s;if(Xs.size>=Cj){const o=Xs.keys().next().value;o!==void 0&&Xs.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Xs.set(e,r),r},Ej=t=>{const e=Je.c(127),{node:s,root:r,isExpanded:o,isActive:i,isBrowserClient:c,depth:l,isOpen:d,status:u,badge:f,isDropTarget:p,isDragSource:m,canUpload:g,canMove:b,permissions:v,downloadFile:x,onSelect:y,onToggle:h,onRevealPath:S,onOpenDialog:w,onSetDropTarget:C,onDropFiles:k,onPickFiles:T,onMoveDragChange:O,onSetMoveDropTarget:K,onMoveDrop:R}=t,{t:I}=Ct(),N=s.type==="directory";let W;e[0]!==N||e[1]!==s.path?(W=N?s.path:xo(s.path),e[0]=N,e[1]=s.path,e[2]=W):W=e[2];const z=W,{canRename:H,canCreateFile:M,canCreateFolder:Y,canDelete:j,canReveal:P}=v,D=!N&&!!x,V=P&&!c,B=N&&g,_=H||M||Y||B||j||D||V,[F,X]=a.useState(!1),[oe,ne]=a.useState(!1);let A;e[3]!==_?(A=Xe=>{_&&(Xe?.preventDefault(),ne(!0))},e[3]=_,e[4]=A):A=e[4];const te=A;let U;e[5]!==N||e[6]!==s||e[7]!==y||e[8]!==h?(U=()=>{N?h(s.path):y(s)},e[5]=N,e[6]=s,e[7]=y,e[8]=h,e[9]=U):U=e[9];const Pe=U;let xe;e[10]!==N||e[11]!==s||e[12]!==y?(xe=()=>{N||y(s,{pin:!0})},e[10]=N,e[11]=s,e[12]=y,e[13]=xe):xe=e[13];const ce=xe;let Oe;e[14]===Symbol.for("react.memo_cache_sentinel")?(Oe=Xe=>{Xe.stopPropagation(),ne(!1),X(!0)},e[14]=Oe):Oe=e[14];const me=Oe;let ie;e[15]!==M||e[16]!==Y||e[17]!==j||e[18]!==H||e[19]!==V||e[20]!==B||e[21]!==x||e[22]!==c||e[23]!==N||e[24]!==s||e[25]!==w||e[26]!==T||e[27]!==S||e[28]!==I?(ie=Xe=>{const{Item:ht,Separator:ee}=Xe;return n.jsxs(n.Fragment,{children:[H&&n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),w("rename",s)},children:[n.jsx(Z,{name:"edit",className:"me-2 h-4 w-4"})," ",I("sidebarFilesTree.menu.rename")]}),n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),ei(s.path).then(Be=>{if(Be.ok){ze.success(I("sidebarFilesTree.toast.pathCopied"));return}ze.error(I("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(Z,{name:"file-copy",className:"me-2 h-4 w-4"})," ",I("sidebarFilesTree.menu.copyPath")]}),!N&&x&&n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),x(s.path).catch(Be=>{console.error("Download failed:",Be),ze.error(I("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"download",className:"me-2 h-4 w-4"})," ",I(c?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),V&&n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),S(s.path)},children:[n.jsx(Z,{name:"folder-received",className:"me-2 h-4 w-4"})," ",I(df())]}),!N&&V&&Xo()&&n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),Om(s.path).then(Be=>{Be||ze.error(I("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"external-link",className:"me-2 h-4 w-4"})," ",I("sidebarFilesTree.menu.openInDefaultApp")]}),N&&(M||Y||B)&&n.jsxs(n.Fragment,{children:[n.jsx(ee,{}),M&&n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),w("createFile",s)},children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",I("sidebarFilesTree.menu.newFile")]}),Y&&n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),w("createFolder",s)},children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",I("sidebarFilesTree.menu.newFolder")]}),B&&n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),T(s.path)},children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",I("sidebarFilesTree.menu.uploadFiles")]})]}),j&&n.jsxs(n.Fragment,{children:[n.jsx(ee,{}),n.jsxs(ht,{onClick:_e=>{_e.stopPropagation(),w("delete",s)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",I("sidebarFilesTree.menu.delete")]})]})]})},e[15]=M,e[16]=Y,e[17]=j,e[18]=H,e[19]=V,e[20]=B,e[21]=x,e[22]=c,e[23]=N,e[24]=s,e[25]=w,e[26]=T,e[27]=S,e[28]=I,e[29]=ie):ie=e[29];const q=ie;let ue;e[30]!==b||e[31]!==s.path||e[32]!==s.type||e[33]!==O||e[34]!==r?(ue=Xe=>{Fp(Xe);const ht=li(r,s.path);!ht||ht==="."||(Xe.dataTransfer.setData(si,ht),Xe.dataTransfer.effectAllowed=b?"copyMove":"copy",b&&O({path:s.path,type:s.type}))},e[30]=b,e[31]=s.path,e[32]=s.type,e[33]=O,e[34]=r,e[35]=ue):ue=e[35];const ve=ue;let Ee;e[36]!==b||e[37]!==Pe||e[38]!==O?(Ee=Xe=>{b&&O(null),Lp(Xe)&&Pe()},e[36]=b,e[37]=Pe,e[38]=O,e[39]=Ee):Ee=e[39];const L=Ee;let le;e[40]!==g||e[41]!==C||e[42]!==z?(le=Xe=>{!g||!z||!Qn(Xe.dataTransfer)||(Xe.preventDefault(),Xe.stopPropagation(),Xe.dataTransfer.dropEffect="copy",C(z))},e[40]=g,e[41]=C,e[42]=z,e[43]=le):le=e[43];const G=le;let se;e[44]!==g||e[45]!==C||e[46]!==z?(se=Xe=>{!g||!z||!Qn(Xe.dataTransfer)||Xe.relatedTarget instanceof Node&&Xe.currentTarget.contains(Xe.relatedTarget)||(Xe.stopPropagation(),C(null))},e[44]=g,e[45]=C,e[46]=z,e[47]=se):se=e[47];const je=se;let he;e[48]!==g||e[49]!==k||e[50]!==z?(he=Xe=>{!g||!z||!Qn(Xe.dataTransfer)||(Xe.preventDefault(),Xe.stopPropagation(),k(z,Xe.dataTransfer))},e[48]=g,e[49]=k,e[50]=z,e[51]=he):he=e[51];const ge=he;let ke;e[52]!==s.path||e[53]!==s.type||e[54]!==r?(ke=(Xe,ht)=>_p(Xe)?null:Kp(ht,{path:s.path,type:s.type},r),e[52]=s.path,e[53]=s.type,e[54]=r,e[55]=ke):ke=e[55];const Ae=ke;let $;e[56]!==b||e[57]!==Ae||e[58]!==G||e[59]!==K?($=Xe=>{const ht=b?Er(Xe.dataTransfer):null;if(!ht){G(Xe);return}Xe.stopPropagation();const ee=Ae(Xe,ht);K(ee),ee&&(Xe.preventDefault(),Xe.dataTransfer.dropEffect="move")},e[56]=b,e[57]=Ae,e[58]=G,e[59]=K,e[60]=$):$=e[60];const fe=$;let be;e[61]!==b||e[62]!==Ae||e[63]!==ge||e[64]!==R||e[65]!==K||e[66]!==r?(be=Xe=>{const ht=b?Er(Xe.dataTransfer):null;if(!ht){ge(Xe);return}Xe.stopPropagation(),Xe.preventDefault(),K(null);const ee=Ae(Xe,ht);ee&&Wp(Xe.dataTransfer,r,ht)&&R(ht,ee)},e[61]=b,e[62]=Ae,e[63]=ge,e[64]=R,e[65]=K,e[66]=r,e[67]=be):be=e[67];const Ie=be;let Ye;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ye={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ye):Ye=e[68];let nt;e[69]!==te||e[70]!==je||e[71]!==fe||e[72]!==Ie?(nt=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Ye,onContextMenu:te,onDragEnter:fe,onDragOver:fe,onDragLeave:je,onDrop:Ie}),e[69]=te,e[70]=je,e[71]=fe,e[72]=Ie,e[73]=nt):nt=e[73];let Ue;e[74]!==l?(Ue=n.jsx(ju,{depth:l}),e[74]=l,e[75]=Ue):Ue=e[75];let Ve;e[76]!==i||e[77]!==m||e[78]!==p?(Ve=Te("flex w-full items-center gap-1.5 rounded-md py-1 pe-8 text-start transition-colors select-none",p?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary":ku(i),m&&"opacity-50"),e[76]=i,e[77]=m,e[78]=p,e[79]=Ve):Ve=e[79];let Se;e[80]!==l?(Se=$a(l),e[80]=l,e[81]=Se):Se=e[81];let ye;e[82]!==Se?(ye={paddingInlineStart:Se},e[82]=Se,e[83]=ye):ye=e[83];let Ge;e[84]!==N||e[85]!==o||e[86]!==s.extension||e[87]!==s.path?(Ge=N?n.jsx(Ar,{expanded:o}):n.jsx(Xa,{filePath:s.path,extension:s.extension,className:"ms-0.5 size-3.5"}),e[84]=N,e[85]=o,e[86]=s.extension,e[87]=s.path,e[88]=Ge):Ge=e[88];let qe;e[89]!==s.name||e[90]!==s.path?(qe=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:s.path,children:s.name}),e[89]=s.name,e[90]=s.path,e[91]=qe):qe=e[91];let ft;e[92]!==N||e[93]!==d||e[94]!==u?(ft=!N&&n.jsx($g,{isOpen:d,status:u}),e[92]=N,e[93]=d,e[94]=u,e[95]=ft):ft=e[95];let et;e[96]!==f||e[97]!==N?(et=N&&f&&n.jsx(zg,{badge:f}),e[96]=f,e[97]=N,e[98]=et):et=e[98];let St;e[99]!==te||e[100]!==ce||e[101]!==L||e[102]!==ve||e[103]!==Pe||e[104]!==Ve||e[105]!==ye||e[106]!==Ge||e[107]!==qe||e[108]!==ft||e[109]!==et?(St=n.jsxs("button",{type:"button",onClick:Pe,onDoubleClick:ce,onContextMenu:te,draggable:!0,onDragStart:ve,onDragEnd:L,className:Ve,style:ye,children:[Ge,qe,ft,et]}),e[99]=te,e[100]=ce,e[101]=L,e[102]=ve,e[103]=Pe,e[104]=Ve,e[105]=ye,e[106]=Ge,e[107]=qe,e[108]=ft,e[109]=et,e[110]=St):St=e[110];let we;e[111]!==F||e[112]!==_||e[113]!==q||e[114]!==I?(we=_&&n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:n.jsxs(Is,{open:F,onOpenChange:X,children:[n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Ts,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:me,title:I("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":I("sidebarFilesTree.actions.fileMenuTitle"),children:n.jsx(Z,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Ot,{side:"bottom",sideOffset:6,children:I("sidebarFilesTree.actions.fileMenuTitle")})]}),n.jsx(Ds,{align:"end",side:"bottom",onCloseAutoFocus:()=>X(!1),children:q({Item:qt,Separator:wn})})]})}),e[111]=F,e[112]=_,e[113]=q,e[114]=I,e[115]=we):we=e[115];let De;e[116]!==nt||e[117]!==Ue||e[118]!==St||e[119]!==we?(De=n.jsxs(Ja,{render:nt,children:[Ue,St,we]}),e[116]=nt,e[117]=Ue,e[118]=St,e[119]=we,e[120]=De):De=e[120];let ot;e[121]!==q?(ot=n.jsx(Qa,{className:"min-w-[180px]",children:q({Item:Bn,Separator:co})}),e[121]=q,e[122]=ot):ot=e[122];let rt;return e[123]!==oe||e[124]!==De||e[125]!==ot?(rt=n.jsxs(el,{open:oe,onOpenChange:ne,children:[De,ot]}),e[123]=oe,e[124]=De,e[125]=ot,e[126]=rt):rt=e[126],rt},Ij=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.depth===e.depth&&t.isOpen===e.isOpen&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.isDragSource===e.isDragSource&&t.canUpload===e.canUpload&&t.canMove===e.canMove&&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&&t.onPickFiles===e.onPickFiles&&t.onMoveDragChange===e.onMoveDragChange&&t.onSetMoveDropTarget===e.onSetMoveDropTarget&&t.onMoveDrop===e.onMoveDrop,Tj=a.memo(Ej,Ij),Dj=t=>{const e=Je.c(6),{visible:s}=t,r=s===void 0?!0:s,o=vn(Nj),i=fn();let c;e[0]!==i||e[1]!==o?(c=JSON.stringify([o,i]),e[0]=i,e[1]=o,e[2]=c):c=e[2];let l;return e[3]!==c||e[4]!==r?(l=n.jsx(Rj,{visible:r},c),e[3]=c,e[4]=r,e[5]=l):l=e[5],l},Rj=({visible:t})=>{const e=a.useRef(t);e.current=t;const{t:s}=Ct(),{files:r,runtime:o}=_s(),i=Bm(o.platform),c=fn()??"",l=ls(c.trim()),d=yl(l),u=Fm(),f=Lm(),p=_m(E=>E.searchFiles),m=de(E=>E.openContextFile),g=Ya(t?c:null),[b,v]=a.useState(""),x=Jy(b,200),y=a.useRef(null),[h,S]=a.useState([]),[w,C]=a.useState(!1),[k,T]=a.useState(null),[O,K]=a.useState(null),[R,I]=a.useState(null),[N,W]=a.useState(null),{hasTouchOnlyPointer:z}=En(),H=!!(r.rename&&l)&&!z,M=de(E=>E.confirmFileTreeMove),Y=de(E=>E.setConfirmFileTreeMove),[j,P]=a.useState({}),[D,V]=a.useState({}),B=a.useRef(new Set),_=a.useRef(new Map),F=a.useMemo(()=>new l1,[]);a.useEffect(()=>()=>F.clear(),[F]);const X=a.useRef(null);a.useEffect(()=>{if(T(null),I(null),W(null),!l){P({}),V({}),B.current=new Set;return}const E=Pj(l);E?(P({...E.childrenByDir}),V({...E.loadErrorsByDir}),B.current=new Set(E.loadedDirs)):(P({}),V({}),B.current=new Set)},[l]),a.useEffect(()=>{if(!l)return;const E=Bi(l);E.childrenByDir=j},[l,j]),a.useEffect(()=>{if(!l)return;const E=Bi(l);E.loadErrorsByDir=D},[l,D]),a.useEffect(()=>{if(!l)return;const E=Bi(l);E.loadedDirs=new Set(B.current)},[l,j,D]),a.useEffect(()=>()=>{if(!l)return;const E=Xs.get(d);E&&E.loadedDirs.size===0&&Object.keys(E.childrenByDir).length===0&&Xs.delete(d)},[d,l]);const oe=a.useMemo(()=>[],[]),ne=a.useMemo(()=>[],[]),A=Ws(E=>l?E.byRoot[l]?.expandedPaths??oe:oe),te=a.useMemo(()=>new Set(A),[A]),U=Ws(E=>l?E.byRoot[l]?.selectedPath??null:null),Pe=Ws(E=>E.setSelectedPath),xe=a.useRef(null),ce=a.useRef(null);a.useEffect(()=>{ce.current=U},[U]);const Oe=Ws(E=>E.addOpenPath),me=Ws(E=>E.removeOpenPathsByPrefix),ie=Ws(E=>E.toggleExpandedPath),q=Ws(E=>E.expandPath),ue=Ws(E=>E.collapseAllExpandedPaths),ve=de(E=>l?E.contextPanelByDirectory[l]?.tabs??ne:ne),Ee=a.useMemo(()=>new Set(ve.map(E=>E.mode==="file"?E.targetPath:null).filter(E=>typeof E=="string"&&E.length>0).map(E=>ls(E))),[ve]),[L,le]=a.useState(null),[G,se]=a.useState(null),[je,he]=a.useState(""),[ge,ke]=a.useState(!1),Ae=!!r.writeFile,$=!!r.createDirectory,fe=!!r.rename,be=!!r.delete,Ie=!!r.revealPath,Ye=a.useMemo(()=>({canRename:fe,canCreateFile:Ae,canCreateFolder:$,canDelete:be,canReveal:Ie}),[fe,Ae,$,be,Ie]),nt=a.useCallback(E=>{r.revealPath&&r.revealPath(E).catch(()=>{ze.error(s("sidebarFilesTree.toast.revealFailed"))})},[r,s]),Ue=a.useCallback((E,Q)=>{le(E),se(Q),he(E==="rename"&&Q.name||""),ke(!1)},[]),Ve=a.useCallback((E,Q)=>{const Ne=Q.filter(Ce=>Ce&&typeof Ce.name=="string"&&Ce.name.length>0).filter(Ce=>u||!Ce.name.startsWith(".")).filter(Ce=>f||!kj(Ce.name)).map(Ce=>{const We=Ce.name,$e=ls(Ce.path||""),kt=$e?vj($e)?$e:ls(`${E}/${$e}`):ls(`${E}/${We}`),jt=Ce.isDirectory?"directory":"file",Et=jt==="file"&&We.includes(".")?We.split(".").pop()?.toLowerCase():void 0;return{name:We,path:kt,type:jt,extension:Et}});return Sj(Ne)},[f,u]),Se=a.useCallback(async(E,Q,Ne=!1)=>{if(!e.current||Q?.())return;const Ce=ls(E.trim());if(!Ce||!Ne&&B.current.has(Ce))return;const We=Gt();return F.run(Ce,async $e=>{const kt=()=>!$e()||Gt()!==We;try{const jt=!f,Et=r.listDirectory?(await r.listDirectory(Ce,{respectGitignore:jt})).entries:await jo.listLocalDirectory(Ce,{respectGitignore:jt});if(kt())return;_.current.set(Ce,Et.length);const Lt=Ve(Ce,Et);B.current=new Set(B.current),B.current.add(Ce),V(Yt=>{if(!Yt[Ce])return Yt;const is={...Yt};return delete is[Ce],is}),P(Yt=>Yt[Ce]&&c1(Yt[Ce],Lt)?Yt:{...Yt,[Ce]:Lt})}catch(jt){if(kt())return;const Et=jt instanceof Error?jt.message:String(jt??"");console.error("Failed to load sidebar directory:",jt),V(Lt=>({...Lt,[Ce]:Et}))}},Ne)},[F,r,Ve,f]),ye=a.useCallback(async()=>{if(!l)return;X.current?.abort();const E=new AbortController;X.current=E,F.clear();try{const Ne=(Ws.getState().byRoot[l]?.expandedPaths??[]).map($e=>ls($e)).filter($e=>!!$e&&$e!==l&&$e.startsWith(`${l}/`)),Ce=[l,...Ne];B.current=new Set(B.current);for(const $e of Ce)B.current.delete($e);V($e=>{if(Object.keys($e).length===0)return $e;const kt={...$e};let jt=!1;for(const Et of Ce)Et in kt&&(delete kt[Et],jt=!0);return jt?kt:$e});const We=()=>E.signal.aborted;await Se(l,We);for(let $e=0;$e<Ne.length&&!E.signal.aborted;$e+=3){const kt=Ne.slice($e,$e+3);await Promise.all(kt.map(jt=>Se(jt,We)))}}catch(Q){if(E.signal.aborted)return;console.error("Failed to refresh sidebar tree:",Q)}finally{X.current===E&&(X.current=null)}},[F,Se,l]),Ge=a.useCallback(async E=>{if(!E){await ye();return}const Q=ls(E);B.current=new Set(B.current),B.current.delete(Q),await Se(Q,void 0,!0)},[Se,ye]);a.useEffect(()=>{l&&(X.current?.abort(),B.current=new Set,F.clear(),V({}),P(E=>Object.keys(E).length===0?E:{}),Se(l))},[F,Se,l,u,f]),a.useEffect(()=>{if(!t||!l||A.length===0)return;const E=A.map(Ce=>ls(Ce)).filter(Ce=>!!Ce&&Ce!==l&&Ce.startsWith(`${l}/`)&&!B.current.has(Ce)&&!F.has(Ce)).sort((Ce,We)=>Ce.split("/").length-We.split("/").length);if(E.length===0)return;let Q=!1;const Ne=()=>Q;return(async()=>{for(let Ce=0;Ce<E.length&&!Q;Ce+=3){const We=E.slice(Ce,Ce+3);await Promise.all(We.map($e=>Se($e,Ne)))}})(),()=>{Q=!0}},[F,A,Se,l,t]);const qe=a.useRef(t);a.useEffect(()=>{const E=t&&!qe.current;qe.current=t,E&&ye()},[ye,t]);const ft=a.useCallback(({directories:E})=>{if(!l)return;const Q=new Set((Ws.getState().byRoot[l]?.expandedPaths??[]).map(Et=>ls(Et))),Ne=l==="/"?"/":`${l}/`,Ce=Et=>{for(let Lt=Et;Lt!==l;Lt=xo(Lt))if(!Lt.startsWith(Ne)||!Q.has(Lt))return!1;return!0},We=Et=>{for(let Lt=Et;Lt===l||Lt.startsWith(Ne);Lt=xo(Lt)){if(B.current.has(Lt))return Lt;if(Lt===l)break}return null},$e=new Set,kt=new Set;for(const Et of E??B.current){const Lt=We(ls(Et));Lt&&(Ce(Lt)?$e:kt).add(Lt)}kt.size>0&&(B.current=new Set([...B.current].filter(Et=>!kt.has(Et))));const jt=[...$e].filter(Et=>(_.current.get(Et)??0)<=Kg);(async()=>{for(let Et=0;Et<jt.length;Et+=3)await Promise.all(jt.slice(Et,Et+3).map(Lt=>Se(Lt,void 0,!0)))})()},[Se,l]);Wg({root:l,active:t,whileInactive:"drop",onChanges:ft}),a.useEffect(()=>{if(!t)return;if(!c){S([]),C(!1);return}const E=x.trim();if(!E){S([]),C(!1);return}let Q=!1;return C(!0),p(c,E,150,{includeHidden:u,respectGitignore:!f,type:"file"}).then(Ne=>{if(Q)return;const We=Ne.filter($e=>f||!jj($e.path)).map($e=>({name:$e.name,path:ls($e.path),type:"file",extension:$e.extension,relativePath:$e.relativePath}));S(We)}).catch(()=>{Q||S([])}).finally(()=>{Q||C(!1)}),()=>{Q=!0}},[c,x,p,u,f,t]);const et=a.useMemo(()=>{const E=new Map;if(!g?.files)return E;for(const Q of g.files)Q.index==="A"||Q.working_dir==="?"?E.set(Q.path,"git-added"):Q.index==="D"?E.set(Q.path,"git-deleted"):(Q.index==="M"||Q.working_dir==="M")&&E.set(Q.path,"git-modified");return E},[g]),St=a.useMemo(()=>{const E=new Map;if(!g?.files||!l)return E;for(const Q of g.files){const Ne=Q.index==="M"||Q.working_dir==="M",Ce=Q.index==="A"||Q.working_dir==="?";if(!Ne&&!Ce)continue;const We=Q.path.split("/");if(We.length<=1)continue;let $e=l;for(let kt=0;kt<We.length-1;kt++){$e=`${$e}/${We[kt]}`;let jt=E.get($e);jt||(jt={modified:0,added:0},E.set($e,jt)),Ne&&jt.modified++,Ce&&jt.added++}}return E},[g,l]),we=a.useCallback(E=>{if(et.size===0)return null;const Q=E.startsWith(l+"/")?E.slice(l.length+1):E;return et.get(Q)??null},[et,l]),De=a.useCallback(E=>{if(St.size===0)return null;const Q=St.get(E);return Q&&Q.modified+Q.added>0?Q:null},[St]),ot=a.useCallback(async(E,Q)=>{if(!l)return;const Ne=await gj(r,E.path,{directory:l});if(!Ne.ok){ze.error(bj(Ne.reason));return}Pe(l,E.path),Oe(l,E.path),m(l,E.path,{preview:!Q?.pin&&!de.getState().isMobile})},[Oe,r,m,l,Pe]),rt=a.useCallback(async E=>{const Q=ls(E);l&&(ie(l,Q),B.current.has(Q)||await Se(Q))},[Se,l,ie]),{canUpload:Xe,uploadingDirectory:ht,uploadFiles:ee,pickFiles:_e,uploadElements:Be}=Hg({root:l,refreshDirectory:Ge}),Ke=ht!==null,Fe=ht??k,tt=a.useCallback((E,Q)=>{const Ne=xj(Q);Ne.length!==0&&(T(null),ee(E,Ne))},[ee]),bt=a.useCallback(E=>{if(rd(E),!E){K(null),I(null);return}requestAnimationFrame(()=>{zp()?.path===E.path&&K(E.path)})},[]),mt=a.useCallback(async(E,Q)=>{const Ne=yj(E,Q),Ce=await Cc(r,l,E.path,Ne);if(Ce==="conflict"){ze.error(s("sidebarFilesTree.toast.nameTaken",{name:Ne.slice(Ne.lastIndexOf("/")+1),folder:hr(l,Q)}));return}if(Ce==="failed"){ze.error(s("sidebarFilesTree.toast.operationFailed"));return}Q!==l&&q(l,Q),await Promise.all([Ge(xo(E.path)),Ge(Q)]).catch(()=>{})},[q,r,Ge,l,s]),it=a.useCallback((E,Q)=>{if(de.getState().confirmFileTreeMove){W({source:E,targetDirectory:Q});return}mt(E,Q)},[mt]),Tt=a.useCallback(()=>{N&&(W(null),mt(N.source,N.targetDirectory))},[mt,N]),at=a.useCallback((E,Q)=>!H||_p(E)?null:Kp(Q,null,l),[H,l]),$t=a.useCallback(E=>{const Q=Er(E.dataTransfer);if(Q){const Ne=at(E,Q);if(I(Ne),!Ne)return;E.preventDefault(),E.dataTransfer.dropEffect="move";return}!Xe||Ke||!l||!Qn(E.dataTransfer)||(E.preventDefault(),E.dataTransfer.dropEffect="copy",T(l))},[Xe,at,Ke,l]),zt=a.useCallback(E=>{if(!(E.relatedTarget instanceof Node&&E.currentTarget.contains(E.relatedTarget))){if(Er(E.dataTransfer)){I(null);return}Qn(E.dataTransfer)&&T(null)}},[]),Mt=a.useCallback(E=>{const Q=Er(E.dataTransfer);if(Q){E.preventDefault(),I(null);const Ne=at(E,Q);Ne&&Wp(E.dataTransfer,l,Q)&&it(Q,Ne);return}!Xe||Ke||!l||!Qn(E.dataTransfer)||(E.preventDefault(),tt(l,E.dataTransfer))},[Xe,at,tt,it,Ke,l]),Re=a.useCallback(async E=>{if(E?.preventDefault(),!G||!L)return;ke(!0);const Q=()=>ke(!1),Ne=()=>le(null);if(L==="createFile"){if(!je.trim()){ze.error(s("sidebarFilesTree.toast.filenameRequired")),Q();return}if(!r.writeFile){ze.error(s("sidebarFilesTree.toast.writeNotSupported")),Q();return}const Ce=G.path,We=Ce?`${Ce}/`:"",$e=ls(`${We}${je.trim()}`);await r.writeFile($e,"").then(async kt=>{kt.success&&(ze.success(s("sidebarFilesTree.toast.fileCreated")),await Ge(Ce)),Ne()}).catch(()=>ze.error(s("sidebarFilesTree.toast.operationFailed"))).finally(Q);return}if(L==="createFolder"){if(!je.trim()){ze.error(s("sidebarFilesTree.toast.folderNameRequired")),Q();return}const Ce=G.path,We=Ce?`${Ce}/`:"",$e=ls(`${We}${je.trim()}`);await r.createDirectory($e).then(async kt=>{kt.success&&(ze.success(s("sidebarFilesTree.toast.folderCreated")),await Ge(Ce)),Ne()}).catch(()=>ze.error(s("sidebarFilesTree.toast.operationFailed"))).finally(Q);return}if(L==="rename"){if(!je.trim()){ze.error(s("sidebarFilesTree.toast.nameRequired")),Q();return}if(!r.rename){ze.error(s("sidebarFilesTree.toast.renameNotSupported")),Q();return}const Ce=G.path,We=Ce.split("/").slice(0,-1).join("/"),$e=We?`${We}/`:"",kt=je.trim(),jt=ls(`${$e}${kt}`);try{const Et=await Cc(r,l,Ce,jt);Et==="moved"?(ze.success(s("sidebarFilesTree.toast.renamedSuccessfully")),await Ge(We),Ne()):Et==="conflict"?ze.error(s("sidebarFilesTree.toast.nameTaken",{name:kt,folder:hr(l,We)})):ze.error(s("sidebarFilesTree.toast.operationFailed"))}catch{ze.error(s("sidebarFilesTree.toast.operationFailed"))}finally{Q()}return}if(L==="delete"){if(!r.delete){ze.error(s("sidebarFilesTree.toast.deleteNotSupported")),Q();return}const Ce=G.path,We=Ce.split("/").slice(0,-1).join("/");await r.delete(Ce).then(async $e=>{$e.success&&(ze.success(s("sidebarFilesTree.toast.deletedSuccessfully")),await Ge(We),l&&me(l,Ce),(U===Ce||U&&U.startsWith(Ce+"/"))&&Pe(l,null)),Ne()}).catch(()=>ze.error(s("sidebarFilesTree.toast.operationFailed"))).finally(Q);return}Q()},[L,G,je,r,Ge,me,l,U,Pe,s]);function ct(E,Q){return(j[E]??[]).map(Ce=>{const We=Ce.type==="directory",$e=We&&te.has(Ce.path),kt=U===Ce.path;return n.jsxs("li",{"data-file-tree-path":We?void 0:Ce.path,children:[n.jsx(Tj,{node:Ce,root:l,isExpanded:$e,isActive:kt,isBrowserClient:i,depth:Q,isOpen:!We&&Ee.has(Ce.path),status:We?void 0:we(Ce.path),badge:We?De(Ce.path):void 0,isDropTarget:We&&(Fe===Ce.path||R===Ce.path),isDragSource:O===Ce.path,canUpload:Xe&&!Ke,canMove:H,permissions:Ye,downloadFile:r.downloadFile,onSelect:ot,onToggle:rt,onRevealPath:nt,onOpenDialog:Ue,onSetDropTarget:T,onDropFiles:tt,onPickFiles:_e,onMoveDragChange:bt,onSetMoveDropTarget:I,onMoveDrop:it}),We&&$e&&n.jsxs("ul",{className:"flex flex-col",children:[D[Ce.path]?n.jsxs("li",{className:"relative flex items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:$a(Q+1)},children:[n.jsx(ju,{depth:Q+1}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:D[Ce.path],children:D[Ce.path]}),n.jsxs(It,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ge(Ce.path)},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):null,ct(Ce.path,Q+1)]})]},Ce.path)})}a.useEffect(()=>{const E=ce.current,Q=xe.current;if(!E||!Q)return;const Ne=Q.querySelector(`[data-file-tree-path="${CSS.escape(E)}"]`);!Ne||Ne.offsetParent===null||(ce.current=null,Ne.scrollIntoView({block:"nearest"}))});const lt=!!(l&&j[l]),dt=l?D[l]:null,st=Fe?hr(l,Fe):"",wt=R?hr(l,R):"",pt=N?N.source.path.slice(N.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{ref:xe,className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex flex-col border-b border-border/40",children:[n.jsxs("div",{className:"flex h-8 shrink-0 items-center justify-end gap-1 border-t border-border/40 px-2",children:[Ae||$||Xe?n.jsxs(Is,{children:[n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Ts,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"sm",className:"size-6 p-0 flex-shrink-0","aria-label":s("sidebarFilesTree.actions.addMenuTitle"),children:n.jsx(Z,{name:Ke?"loader-4":"add",className:Te("h-4 w-4",Ke&&"animate-spin")})})})})}),n.jsx(Ot,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.addMenuTitle")})]}),n.jsxs(Ds,{align:"end",className:"min-w-[180px]",children:[Ae?n.jsxs(qt,{onClick:()=>Ue("createFile",{path:c,type:"directory"}),children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.newFile")]}):null,$?n.jsxs(qt,{onClick:()=>Ue("createFolder",{path:c,type:"directory"}),children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.newFolder")]}):null,Xe?n.jsxs(qt,{disabled:!l||Ke,onClick:()=>_e(l),children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.uploadFiles")]}):null]})]}):null,n.jsx(d1,{className:"size-6"}),n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(It,{variant:"ghost",size:"sm",onClick:()=>{ye()},className:"size-6 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.refreshTitle"),"aria-label":s("sidebarFilesTree.actions.refreshTitle"),children:n.jsx(Z,{name:"refresh",className:"h-4 w-4"})})})}),n.jsx(Ot,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.refreshTitle")})]}),n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(It,{variant:"ghost",size:"sm",onClick:()=>{l&&ue(l)},className:"size-6 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":s("sidebarFilesTree.actions.collapseAllTitle"),children:n.jsx(Z,{name:"collapse-vertical",className:"h-4 w-4"})})})}),n.jsx(Ot,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.collapseAllTitle")})]})]}),n.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[n.jsx(Z,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),n.jsx(Io,{ref:y,value:b,onChange:E=>v(E.target.value),placeholder:s("sidebarFilesTree.search.placeholder"),className:"h-8 ps-8 pe-8 typography-meta"}),b.trim().length>0?n.jsx("button",{type:"button","aria-label":s("sidebarFilesTree.search.clearAria"),className:"absolute inset-e-4 top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{v(""),y.current?.focus()},children:n.jsx(Z,{name:"close",className:"h-4 w-4"})}):null]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsx(Or,{outerClassName:"h-full min-h-0",className:Te("px-1.5 py-1.5",(Fe===l||R===l)&&"bg-interactive-selection/10"),onDragEnter:$t,onDragOver:$t,onDragLeave:zt,onDrop:Mt,children:n.jsx("ul",{className:"flex flex-col",children:w?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(Z,{name:"loader-4",className:"h-4 w-4 animate-spin"}),s("sidebarFilesTree.state.searching")]}):h.length>0?h.map(E=>{const Q=U===E.path;return n.jsx("li",{"data-file-tree-path":E.path,children:n.jsxs("button",{type:"button",onClick:()=>ot(E),onDoubleClick:()=>ot(E,{pin:!0}),draggable:!0,onDragStart:Ne=>{Fp(Ne),rd(null);const Ce=E.relativePath||li(l??"",E.path);!Ce||Ce==="."||(Ne.dataTransfer.setData(si,Ce),Ne.dataTransfer.effectAllowed="copy")},onDragEnd:Ne=>{Lp(Ne)&&ot(E)},className:Te("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",ku(Q)),title:E.path,children:[n.jsx(Xa,{filePath:E.path,extension:E.extension,className:"size-3.5"}),n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`‎${E.relativePath??E.path}‎`})]})},E.path)}):dt?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:dt}),n.jsxs(It,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ye()},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):lt&&l?ct(l,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:s("sidebarFilesTree.state.loading")})})}),Fe?n.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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:[n.jsx(Z,{name:Ke?"loader-4":"folder-received",className:Te("size-4 flex-shrink-0",Ke&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:st,children:s(Ke?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:st})})]}):R?n.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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:[n.jsx(Z,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:wt,children:s("sidebarFilesTree.drop.moveTarget",{path:wt})})]}):null]}),Be,n.jsx(qs,{open:!!L,onOpenChange:E=>!E&&le(null),children:n.jsxs(Gs,{children:[n.jsxs(Js,{children:[n.jsxs(Zs,{children:[L==="createFile"&&s("sidebarFilesTree.dialog.createFile.title"),L==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.title"),L==="rename"&&s("sidebarFilesTree.dialog.rename.title"),L==="delete"&&s("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(Qs,{children:[L==="createFile"&&s("sidebarFilesTree.dialog.createFile.description",{path:G?.path??s("sidebarFilesTree.dialog.rootFallback")}),L==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.description",{path:G?.path??s("sidebarFilesTree.dialog.rootFallback")}),L==="rename"&&s("sidebarFilesTree.dialog.rename.description",{name:G?.name??""}),L==="delete"&&s("sidebarFilesTree.dialog.delete.description",{name:G?.name??""})]})]}),L!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Io,{value:je,onChange:E=>he(E.target.value),placeholder:s(L==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:E=>{E.key==="Enter"&&Re()},autoFocus:!0})}),n.jsxs(kn,{children:[n.jsx(It,{variant:"outline",onClick:()=>le(null),disabled:ge,children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(It,{variant:L==="delete"?"destructive":"default",onClick:()=>{Re()},disabled:ge||L!=="delete"&&!je.trim(),children:ge?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):s(L==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(qs,{open:N!==null,onOpenChange:E=>{E||W(null)},children:n.jsxs(Gs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Js,{children:[n.jsx(Zs,{children:s("sidebarFilesTree.dialog.move.title")}),n.jsx(Qs,{children:N?s("sidebarFilesTree.dialog.move.description",{name:pt,folder:hr(l,N.targetDirectory)}):null})]}),n.jsxs(kn,{className:"w-full sm:items-center sm:justify-between",children:[n.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>Y(!M),children:[n.jsx(ex,{checked:!M,onChange:E=>Y(!E),ariaLabel:s("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:s("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(It,{variant:"ghost",onClick:()=>W(null),children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(It,{onClick:Tt,children:s("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function Nj(t){return t.runtimeKey}const Mj=Br(()=>ss(()=>import("./WalkthroughView-r0Ho9F4Z.js"),__vite__mapDeps([125,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,126,84,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,127,87,116,117,118,119,120,121,122,123,124])).then(t=>({default:t.WalkthroughView}))),Aj=Br(()=>ss(()=>import("./DiffView-DaXjHTAq.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,126,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,83,84,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,129,87,116,117,118,119,120,121,86,122,123,124])).then(t=>({default:t.DiffView}))),Oj=Br(()=>ss(()=>import("./FilesView-DMNYEydF.js"),__vite__mapDeps([130,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,83,131,132,133,134,123,135,119,84,136,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,137,138,139,140,120,121,118,141,142])).then(t=>({default:t.FilesView}))),Hp=a.lazy(()=>ss(()=>import("./useAppFontEffects-Bih1DxXi.js").then(t=>t.ny),__vite__mapDeps([3,1,2,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])).then(t=>({default:t.PluginPane}))),id=a.lazy(()=>ss(()=>import("./GuestSurfacePane-KzguENQG.js"),__vite__mapDeps([143,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])).then(t=>({default:t.GuestSurfacePane}))),Vp={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},Bj=t=>{const e=Je.c(12),{mode:s,docking:r}=t,[o,i]=a.useState(null),c=Vp[r.dock],l=Math.max(rx,o??r.size),d=c.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==c.page||e[1]!==d?(u=Te("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,c.page),e[0]=c.page,e[1]=d,e[2]=u):u=e[2];let f;e[3]!==c.vertical||e[4]!==l?(f=c.vertical?{height:l}:{width:l},e[3]=c.vertical,e[4]=l,e[5]=f):f=e[5];let p;e[6]!==s?(p=n.jsx(Hp,{mode:s,onResize:i}),e[6]=s,e[7]=p):p=e[7];let m;return e[8]!==u||e[9]!==f||e[10]!==p?(m=n.jsx("div",{className:u,style:f,children:p}),e[8]=u,e[9]=f,e[10]=p,e[11]=m):m=e[11],m},Fj=({visible:t,active:e,fill:s=!1,side:r})=>{const{t:o}=Ct(),i=de(S=>S.contextEditorTreeWidth),c=de(S=>S.setContextEditorTreeWidth),[l,d]=a.useState(!1),u=a.useRef(0),f=a.useRef(i),p=a.useRef(null),m=a.useRef(null),g=a.useRef(null),b=a.useCallback(S=>{const w=g.current;w&&(w.style.width=`${S}px`,w.style.setProperty("--oc-editor-tree-width",`${S}px`))},[]),v=S=>{if(t){try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}m.current=S.pointerId,d(!0),u.current=S.clientX,f.current=i,p.current=i,S.preventDefault()}},x=S=>{if(!l||m.current!==S.pointerId)return;const w=r==="left"?S.clientX-u.current:u.current-S.clientX,C=Vo(S.currentTarget)?-w:w,k=Gi(f.current+C);p.current!==k&&(p.current=k,b(k))},y=S=>{if(m.current!==S.pointerId)return;try{S.currentTarget.releasePointerCapture(S.pointerId)}catch{}const w=Gi(p.current??i);m.current=null,p.current=null,d(!1),c(w)},h=t?i:0;return n.jsxs("div",{ref:g,className:Te("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${l?p.current??h:h}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${l?p.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!s&&n.jsx("div",{"aria-hidden":"true",className:Te("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!s&&n.jsx("div",{className:Te("absolute top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",r==="left"?"inset-e-0":"inset-s-0",l&&"bg-[var(--interactive-border)]"),onPointerDown:v,onPointerMove:x,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:Te("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(Dj,{visible:t&&e})})]})},Rn=t=>{const e=Je.c(12),{zone:s,isOpen:r,directoryKey:o,className:i,children:c}=t,l=de(_j);let d;e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==s?(d=m=>{rp(m,r,()=>{o&&l(o,s)},m.currentTarget.closest("[data-context-zone]"))},e[0]=l,e[1]=o,e[2]=r,e[3]=s,e[4]=d):d=e[4];const u=d;let f;e[5]!==c||e[6]!==i||e[7]!==u?(f=n.jsx("div",{className:i,onKeyDownCapture:u,children:c}),e[5]=c,e[6]=i,e[7]=u,e[8]=f):f=e[8];let p;return e[9]!==f||e[10]!==s?(p=n.jsx(uj,{zone:s,children:f}),e[9]=f,e[10]=s,e[11]=p):p=e[11],p},Lj=()=>{const{t}=Ct(),e=fn()??"",s=a.useMemo(()=>e?Cs(e):"",[e]),r=de(L=>s?L.contextPanelByDirectory[s]:void 0),o=de(L=>L.contextSurfaceZones),i=de(L=>L.contextPanelByDirectory),c=de(L=>L.closeContextPanelTab),l=de(L=>L.closeContextFile),d=de(L=>L.openContextPanelTab),u=de(L=>L.openAgentBrowserTab),f=de(L=>L.openContextFile),p=de(L=>L.contextEditorTreeVisible),m=de(L=>L.contextEditorVisible),g=de(L=>L.fileTreeSide),b=Ws(L=>L.setSelectedPath),v=Rr(L=>L.headerSlot),x=a.useMemo(()=>r?.tabs??[],[r?.tabs]),y=ta(L=>L.chatCovered),h=a.useMemo(()=>{const L=le=>{const G=r?wo(r,o,le):null,se=le==="bottom"&&y;return{activeTab:G,isOpen:!!(r&&Go(r,le).isOpen&&G)&&!se}};return{left:L("left"),right:L("right"),bottom:L("bottom")}},[y,r,o]),S={left:Cr(h.left.isOpen),right:Cr(h.right.isOpen),bottom:Cr(h.bottom.isOpen)},w=L=>!S[L],C=L=>{const le=Co(o,L);return{zone:le,...h[le]}},k=C("file"),T=C("chat"),O=C("browser"),K=C("diff"),R=C("terminal"),I=C("walkthrough"),[N,W]=a.useState(()=>new Set),z=a.useCallback(L=>{W(le=>le.has(L)?le:new Set(le).add(L))},[]);a.useEffect(()=>L0((L,le)=>{const G=le.directory?Cs(le.directory):s;if(!G)return null;const se=u(G,L,le.sessionId);return se&&z(se),se}),[s,u,z]),a.useEffect(()=>jn(L=>{if(L.type!=="file-open-request")return;const le=L.directory??e;le&&f(le,L.path)}),[e,f]),a.useEffect(()=>jn(L=>{if(L.type!=="plan-open-request")return;const le=L.directory??e,G=Vg(le,L.projectId);!le||!G||de.getState().openProjectKnowledgePlan(le,tx(G),L.planId)}),[e]);const H=O.activeTab?.mode==="browser"?O.activeTab.id:null;a.useEffect(()=>{F0(s,H)},[s,H]);const M=k.activeTab;a.useEffect(()=>{!s||M?.mode!=="file"||!M.targetPath||b(s,M.targetPath,{allowOutsideRoot:!0})},[s,M,b]);const Y=a.useMemo(()=>x.some(L=>L.mode==="file"&&L.targetPath),[x]),j=a.useMemo(()=>x.some(L=>L.mode==="file"),[x]),P=Y&&(m||!p),D=k.activeTab?.mode==="file",V=a.useCallback(L=>{s&&l(s,L)},[l,s]),B=T.isOpen&&T.activeTab?.mode==="chat"?T.activeTab:null,_=B?cl(B.dedupeKey):null,F=a.useMemo(()=>(B?.targetDirectory?Cs(B.targetDirectory):"")||s||null,[B?.targetDirectory,s]),X=a.useMemo(()=>_?{sessionId:_,directory:F}:null,[_,F]);a.useEffect(()=>{if(!F||!_||typeof window>"u")return;const L=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ki(F,_,!1);return}uf(_),ki(F,_,!0)};L();const le=window.setInterval(L,1e4);return window.addEventListener("focus",L),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),()=>{window.clearInterval(le),window.removeEventListener("focus",L),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L),ki(F,_,!1)}},[F,_]);const oe=K.activeTab,ne=a.useCallback(L=>{!s||oe?.mode!=="diff"||d(s,{mode:"diff",targetPath:oe.targetPath,stagedDiff:L==="staged",diffScope:L})},[oe,s,d]),A=O.isOpen&&O.activeTab?.mode==="browser"?O.activeTab.id:null;a.useEffect(()=>{A&&z(A)},[A,z]);const{loadedBrowserTabs:te,sleepingBrowserTabs:U}=a.useMemo(()=>{const L=[],le=[];for(const[se,je]of Object.entries(i)){const he=se===s;for(const ge of je.tabs){if(ge.mode!=="browser"||!he&&ge.ownerSessionId===null)continue;const ke={directory:se,id:ge.id,targetPath:ge.targetPath,ownerSessionId:ge.ownerSessionId};(N.has(ge.id)||he&&ge.id===A?L:le).push(ke)}}const G=se=>`${se.directory}\0${se.id}`;return L.sort((se,je)=>G(se)<G(je)?-1:1),{loadedBrowserTabs:L,sleepingBrowserTabs:le}},[i,s,A,N]);a.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const L=U.map(le=>B0({tabId:le.id,directory:le.directory,ownerSessionId:le.ownerSessionId,describe:()=>({title:"",url:le.targetPath??""}),wake:()=>z(le.id)}));return()=>L.forEach(le=>le())},[U,z]);const Pe=a.useMemo(()=>x.filter(L=>L.mode==="diff"),[x]),xe=a.useMemo(()=>x.find(L=>L.mode==="terminal")??null,[x]),ce=a.useMemo(()=>x.some(L=>L.mode==="walkthrough"),[x]),Oe=a.useMemo(()=>x.filter(L=>tr(L.mode)),[x]),me=Ua(L=>L.guests),ie=a.useMemo(()=>new Set(me.filter(sx).map(L=>L.id)),[me]),q=a.useMemo(()=>{const L=new Map;for(const le of me){const G=nx(le);G&&L.set(le.id,G)}return L},[me]),ue=R.zone,ve=a.useCallback(L=>{const le=ul({mode:"terminal",label:t("layout.mainTab.terminal"),from:ue},L);return{finish:()=>le.finish(s),cancel:le.cancel}},[s,t,ue]),Ee=(L,le)=>le?v[L]:null;return n.jsxs(n.Fragment,{children:[j?n.jsxs(Rn,{zone:k.zone,isOpen:k.isOpen,directoryKey:s,className:Te("absolute inset-0 flex",g==="left"&&"flex-row-reverse",D?"flex":"hidden"),children:[Y||!p?n.jsx("div",{className:Te("h-full min-w-0 flex-1",Y&&!P&&"hidden"),children:Y?n.jsx(a.Suspense,{fallback:null,children:n.jsx(Oj,{mode:"editor-only",visible:!w(k.zone)&&D&&P,onCloseFile:V})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(Z,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),n.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,n.jsx(Fj,{visible:p,active:k.isOpen&&D,fill:!P,side:g})]}):null,B&&_&&X?n.jsx(Rn,{zone:T.zone,isOpen:T.isOpen,directoryKey:s,className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:_}),className:"h-full",children:n.jsx(Cu,{pinnedSession:X,readOnly:B.readOnly})})},B.id):null,te.map(L=>{const le=L.directory===s&&O.activeTab?.id===L.id;return n.jsx(Rn,{zone:O.zone,isOpen:O.isOpen,directoryKey:s,className:Te("absolute inset-0",!le&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!le||void 0,children:n.jsx(ij,{initialUrl:L.targetPath??"",directory:L.directory,tabID:L.id,ownerSessionId:L.ownerSessionId,visible:le&&O.isOpen})})},`${L.directory}\0${L.id}`)}),Pe.map(L=>{const le=K.activeTab?.id===L.id;return n.jsx(Rn,{zone:K.zone,isOpen:K.isOpen,directoryKey:s,className:Te("absolute inset-0",!le&&"hidden"),children:n.jsx(a.Suspense,{fallback:null,children:n.jsx(Yn,{value:Ee(K.zone,le),children:n.jsx(Aj,{visible:K.isOpen&&le,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:L.diffScope??(L.stagedDiff?"staged":null),onDiffScopeChange:ne,targetFilePath:L.targetPath,flushContent:!0})})})},L.id)}),xe?n.jsx(Rn,{zone:R.zone,isOpen:R.isOpen,directoryKey:s,className:Te("absolute inset-0",R.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(Yn,{value:Ee(R.zone,R.activeTab?.mode==="terminal"),children:n.jsx(Ug.Provider,{value:ve,children:n.jsx(Gg,{visible:R.isOpen&&R.activeTab?.mode==="terminal",directory:xe.targetDirectory,onLastTabClosed:()=>{s&&c(s,xe.id)}})})})}):null,ce?n.jsx(Rn,{zone:I.zone,isOpen:I.isOpen,directoryKey:s,className:Te("absolute inset-0",I.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(a.Suspense,{fallback:null,children:n.jsx(Yn,{value:Ee(I.zone,I.activeTab?.mode==="walkthrough"),children:n.jsx(Mj,{directory:e,visible:I.isOpen&&I.activeTab?.mode==="walkthrough"})})})}):null,Oe.map(L=>{if(!tr(L.mode))return null;const le=C(L.mode),G=ko(L.mode),se=ie.has(G),je=q.get(G),he=le.activeTab?.id===L.id,ge=he&&le.isOpen;return se&&!je&&!ge?null:n.jsx(Rn,{zone:le.zone,isOpen:le.isOpen,directoryKey:s,className:Te("absolute inset-0",he?"block":"hidden"),children:n.jsx(a.Suspense,{fallback:null,children:se?je?n.jsxs("div",{className:Te("flex h-full",Vp[je.dock].container),children:[n.jsx(Bj,{mode:L.mode,docking:je}),n.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:ge?n.jsx(id,{mode:L.mode}):null})]}):n.jsx(id,{mode:L.mode}):n.jsx(Hp,{mode:L.mode})})},L.id)})]})};function _j(t){return t.closeContextZone}const $j={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},zj=()=>{const t=Je.c(20),{t:e}=Ct(),s=un(Kj),r=un(Wj),o=a.useRef(null),[i,c]=a.useState(!1);let l,d;t[0]!==s?(l=()=>{if(!s){c(!1);return}const y=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(y)},d=[s],t[0]=s,t[1]=l,t[2]=d):(l=t[1],d=t[2]),a.useEffect(l,d);let u,f;if(t[3]!==s?(u=()=>{if(!s)return;const y=h=>{const S=o.current;S&&(S.style.transform=`translate(${h.clientX+12}px, ${h.clientY+12}px)`)};return window.addEventListener("pointermove",y),()=>window.removeEventListener("pointermove",y)},f=[s],t[3]=s,t[4]=u,t[5]=f):(u=t[4],f=t[5]),a.useEffect(u,f),!s)return null;const p=i?"opacity-100":"opacity-0";let m;t[6]!==p?(m=Te("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",p),t[6]=p,t[7]=m):m=t[7];let g;t[8]!==m?(g=n.jsx("div",{className:m}),t[8]=m,t[9]=g):g=t[9];let b;t[10]!==s.frames||t[11]!==r||t[12]!==e?(b=$m.map(y=>{const h=s.frames[y];if(h.width<=0||h.height<=0)return null;const S=r===y;return n.jsx("div",{className:Te("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",S?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:h.left,top:h.top,width:h.width,height:h.height},children:n.jsx("span",{className:"typography-ui-label",children:e($j[y])})},y)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=b):b=t[13];let v;t[14]!==s.label?(v=n.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:s.label}),t[14]=s.label,t[15]=v):v=t[15];let x;return t[16]!==g||t[17]!==b||t[18]!==v?(x=Oa.createPortal(n.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[g,b,v]}),document.body),t[16]=g,t[17]=b,t[18]=v,t[19]=x):x=t[19],x};function Kj(t){return t.drag}function Wj(t){return t.hovered}const ad=400,Hj=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let i=t-e-s;if(i>=ad)return{collapseSidebar:!1,displace:null};const c=r!==null;if(c&&(i+=r),i>=ad)return{collapseSidebar:c,displace:null};const l=o==="left"?"right":"left";return{collapseSidebar:c,displace:(l==="left"?e:s)>0?l:null}},Vj=()=>{const t=Je.c(5),e=fn();let s;t[0]!==e?(s=e?Cs(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=a.useRef(null);let i,c;return t[2]!==r?(i=()=>{if(!r)return;const l=x=>{const y=x.contextPanelByDirectory[r];return{left:vr(y,x.contextSurfaceZones,"left"),right:vr(y,x.contextSurfaceZones,"right")}},d=(x,y,h)=>{const S=x.contextPanelByDirectory[r],w=h&&S?wo(S,x.contextSurfaceZones,y):null;return w?S?.widthByMode[w.mode]??sa(w.mode):0};let u=null,f=!1,p=l(de.getState());const m=x=>{f=!0,de.getState().setSidebarOpen(x),f=!1},g=o.current;g&&!p[g]&&(o.current=null,de.getState().isSidebarOpen||m(!0));const b=(x,y,h)=>{const S=document.querySelector("[data-workspace-row]")?.clientWidth;if(!S)return;const w=Hj({rowWidth:S,leftWidth:d(x,"left",h.left),rightWidth:d(x,"right",h.right),sidebarWidth:x.isSidebarOpen?x.sidebarWidth:null,opening:y});if(w.displace){const C=Go(x.contextPanelByDirectory[r],w.displace).activeTabId;C&&(u={side:w.displace,by:y,tabId:C})}w.collapseSidebar&&(o.current=y,m(!1)),w.displace&&x.closeContextZone(r,w.displace)},v=x=>{if(u?.side===x){o.current===x&&(o.current=u.by);return}const y=u?.by===x?u:null;y&&(u=null),o.current===x&&(y?o.current=y.side:(o.current=null,de.getState().isSidebarOpen||m(!0))),y&&de.getState().setActiveContextPanelTab(r,y.tabId)};return de.subscribe((x,y)=>{x.isSidebarOpen!==y.isSidebarOpen&&!f&&(o.current=null);const h=l(x),S=p;p=h;const w=["left","right"],C=w.filter(T=>h[T]&&!S[T]),k=w.filter(T=>!h[T]&&S[T]);for(const T of k){const O=T==="left"?"right":"left";C.includes(O)&&(o.current===T&&(o.current=O),u?.by===T&&(u=null))}for(const T of k)v(T);for(const T of C)b(x,T,h)})},c=[r],t[2]=r,t[3]=i,t[4]=c):(i=t[3],c=t[4]),a.useEffect(i,c),null},Uj=t=>{const e=Je.c(29),{surfaceId:s,label:r,checked:o,onChange:i}=t,{t:c}=Ct();let l;e[0]!==s?(l={id:s},e[0]=s,e[1]=l):l=e[1];const{attributes:d,listeners:u,setNodeRef:f,setActivatorNodeRef:p,transform:m,transition:g,isDragging:b}=Wr(l);let v;e[2]!==m?(v=Hr.Translate.toString(m),e[2]=m,e[3]=v):v=e[3];let x;e[4]!==v||e[5]!==g?(x={transform:v,transition:g},e[4]=v,e[5]=g,e[6]=x):x=e[6];const y=b&&"z-10 opacity-60";let h;e[7]!==y?(h=Te("relative flex items-center gap-2",y),e[7]=y,e[8]=h):h=e[8];let S;e[9]!==r||e[10]!==c?(S=c("contextRail.configure.reorder",{label:r}),e[9]=r,e[10]=c,e[11]=S):S=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Z,{name:"draggable",className:"size-4"}),e[12]=w):w=e[12];let C;e[13]!==d||e[14]!==u||e[15]!==p||e[16]!==S?(C=n.jsx(It,{ref:p,variant:"ghost",size:"icon",...d,...u,"aria-label":S,className:"shrink-0 touch-none select-none cursor-grab text-muted-foreground hover:bg-transparent active:cursor-grabbing",children:w}),e[13]=d,e[14]=u,e[15]=p,e[16]=S,e[17]=C):C=e[17];const k=`layout.context-rail.surface.${s}`;let T;e[18]!==o||e[19]!==r||e[20]!==i||e[21]!==k?(T=n.jsx(ox,{settingsItem:k,checked:o,onChange:i,label:r,ariaLabel:r,className:"min-w-0 flex-1"}),e[18]=o,e[19]=r,e[20]=i,e[21]=k,e[22]=T):T=e[22];let O;return e[23]!==f||e[24]!==T||e[25]!==x||e[26]!==h||e[27]!==C?(O=n.jsxs("div",{ref:f,style:x,className:h,children:[C,T]}),e[23]=f,e[24]=T,e[25]=x,e[26]=h,e[27]=C,e[28]=O):O=e[28],O},Gj=t=>{const e=Je.c(86),{open:s,onOpenChange:r}=t,{t:o}=Ct(),i=de(qj),c=de(Yj),l=de(Xj),d=de(Zj),u=de(Qj),f=Za();let p;e[0]!==i||e[1]!==f?(p=ff(i,f),e[0]=i,e[1]=f,e[2]=p):p=e[2];const m=p,g=l.length===0;let b;if(e[3]!==l||e[4]!==m){let me;e[6]!==l?(me=ie=>l.includes(ie.id),e[6]=l,e[7]=me):me=e[7],b=m.every(me),e[3]=l,e[4]=m,e[5]=b}else b=e[5];const v=b,x=a.useRef(!1);let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y={activationConstraint:{distance:8}},e[8]=y):y=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={activationConstraint:{delay:200,tolerance:6}},e[9]=h):h=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S={coordinateGetter:Hf},e[10]=S):S=e[10];const w=Lr(Fs($r,y),Fs(_r,h),Fs(Wf,S));let C;e[11]!==i||e[12]!==c||e[13]!==m?(C=me=>{const{active:ie,over:q}=me;if(x.current=!1,!q||ie.id===q.id)return;const ue=m.findIndex(le=>le.id===ie.id),ve=m.findIndex(le=>le.id===q.id);if(ue<0||ve<0)return;const Ee=il(m,ue,ve).map(Jj),L=new Set(Ee);c([...Ee,...i.filter(le=>!L.has(le))])},e[11]=i,e[12]=c,e[13]=m,e[14]=C):C=e[14];const k=C;let T;e[15]!==m||e[16]!==o?(T=(me,ie)=>{const q=ie===void 0?me:ie,ue=m.find(ve=>ve.id===me);if(ue)return o("contextRail.configure.position",{label:ue.label??o(ue.labelKey),position:m.findIndex(ve=>ve.id===q)+1,count:m.length})},e[15]=m,e[16]=o,e[17]=T):T=e[17];const O=T;let K,R;e[18]!==O?(K=me=>{const{active:ie}=me;return O(ie.id)},R=me=>{const{active:ie,over:q}=me;return q?O(ie.id,q.id):void 0},e[18]=O,e[19]=K,e[20]=R):(K=e[19],R=e[20]);let I;e[21]!==O||e[22]!==o?(I=me=>{const{active:ie,over:q}=me;return q?O(ie.id,q.id):o("contextRail.configure.dragCancelled")},e[21]=O,e[22]=o,e[23]=I):I=e[23];let N;e[24]!==o?(N=()=>o("contextRail.configure.dragCancelled"),e[24]=o,e[25]=N):N=e[25];let W;e[26]!==I||e[27]!==N||e[28]!==K||e[29]!==R?(W={onDragStart:K,onDragOver:R,onDragEnd:I,onDragCancel:N},e[26]=I,e[27]=N,e[28]=K,e[29]=R,e[30]=W):W=e[30];const z=W;let H;e[31]!==o?(H=o("contextRail.configure.dragInstructions"),e[31]=o,e[32]=H):H=e[32];let M;e[33]!==H?(M={draggable:H},e[33]=H,e[34]=M):M=e[34];let Y;e[35]!==z||e[36]!==M?(Y={screenReaderInstructions:M,announcements:z},e[35]=z,e[36]=M,e[37]=Y):Y=e[37];const j=Y;let P;e[38]!==r?(P=(me,ie)=>{if(!me&&ie.reason==="escape-key"&&x.current){ie.cancel(),ie.allowPropagation();return}x.current=!1,r(me)},e[38]=r,e[39]=P):P=e[39];let D;e[40]===Symbol.for("react.memo_cache_sentinel")?(D=me=>{x.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(me.key)&&me.preventBaseUIHandler()},e[40]=D):D=e[40];let V;e[41]!==o?(V=o("contextRail.configure.dialogTitle"),e[41]=o,e[42]=V):V=e[42];let B;e[43]!==V?(B=n.jsx(Zs,{children:V}),e[43]=V,e[44]=B):B=e[44];let _;e[45]!==o?(_=o("contextRail.configure.dialogDescription"),e[45]=o,e[46]=_):_=e[46];let F;e[47]!==_?(F=n.jsx(Qs,{children:_}),e[47]=_,e[48]=F):F=e[48];let X;e[49]!==B||e[50]!==F?(X=n.jsxs(Js,{children:[B,F]}),e[49]=B,e[50]=F,e[51]=X):X=e[51];let oe,ne;e[52]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>{x.current=!0},ne=()=>{x.current=!1},e[52]=oe,e[53]=ne):(oe=e[52],ne=e[53]);let A;if(e[54]!==l||e[55]!==d||e[56]!==m||e[57]!==o){let me;e[59]!==l||e[60]!==d||e[61]!==o?(me=ie=>n.jsx(Uj,{surfaceId:ie.id,checked:!l.includes(ie.id),onChange:q=>d(ie.id,q),label:ie.label??o(ie.labelKey)},ie.id),e[59]=l,e[60]=d,e[61]=o,e[62]=me):me=e[62],A=m.map(me),e[54]=l,e[55]=d,e[56]=m,e[57]=o,e[58]=A}else A=e[58];let te;e[63]!==A?(te=n.jsx("div",{className:"flex flex-col",children:A}),e[63]=A,e[64]=te):te=e[64];let U;e[65]!==m||e[66]!==te?(U=n.jsx(oi,{items:m,strategy:al,children:te}),e[65]=m,e[66]=te,e[67]=U):U=e[67];let Pe;e[68]!==j||e[69]!==k||e[70]!==w||e[71]!==U?(Pe=n.jsx(zr,{sensors:w,collisionDetection:Kr,onDragStart:oe,onDragCancel:ne,onDragEnd:k,accessibility:j,children:U}),e[68]=j,e[69]=k,e[70]=w,e[71]=U,e[72]=Pe):Pe=e[72];let xe;e[73]!==g||e[74]!==v||e[75]!==u||e[76]!==o?(xe=g?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[v?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(It,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[73]=g,e[74]=v,e[75]=u,e[76]=o,e[77]=xe):xe=e[77];let ce;e[78]!==X||e[79]!==Pe||e[80]!==xe?(ce=n.jsxs(Gs,{className:"max-w-md",onKeyDown:D,children:[X,Pe,xe]}),e[78]=X,e[79]=Pe,e[80]=xe,e[81]=ce):ce=e[81];let Oe;return e[82]!==s||e[83]!==P||e[84]!==ce?(Oe=n.jsx(qs,{open:s,onOpenChange:P,children:ce}),e[82]=s,e[83]=P,e[84]=ce,e[85]=Oe):Oe=e[85],Oe};function qj(t){return t.contextRailOrder}function Yj(t){return t.setContextRailOrder}function Xj(t){return t.contextRailHiddenSurfaces}function Zj(t){return t.setContextRailSurfaceVisible}function Qj(t){return t.setContextRailHiddenSurfaces}function Jj(t){return t.id}const e2=t=>{const e=of(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},t2=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,Up=()=>{const t=Je.c(4),e=xt(r2),s=xt(o2)??void 0,r=ax(e??"",s,e2,t2),{context:o}=lx(e,s),i=o>0?o:cx;let c;return t[0]!==r||t[1]!==i||t[2]!==e?(c={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=c):c=t[3],c},ld=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),rn=18,ja=2,Ca=(rn-ja)/2,cd=2*Math.PI*Ca,s2=t=>{const e=Je.c(8),{className:s}=t,{fill:r,limit:o}=Up(),i=r?.state==="measured"?Math.min(100,r.totalTokens/o*100):0;let c;e[0]!==s?(c=Te("shrink-0",s),e[0]=s,e[1]=c):c=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("circle",{cx:rn/2,cy:rn/2,r:Ca,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ja}),e[2]=l):l=e[2];let d;e[3]!==i?(d=i>0?n.jsx("circle",{cx:rn/2,cy:rn/2,r:Ca,fill:"none",stroke:"currentColor",strokeWidth:ja,strokeLinecap:"round",strokeDasharray:cd,strokeDashoffset:cd*(1-i/100),transform:`rotate(-90 ${rn/2} ${rn/2})`}):null,e[3]=i,e[4]=d):d=e[4];let u;return e[5]!==c||e[6]!==d?(u=n.jsxs("svg",{viewBox:`0 0 ${rn} ${rn}`,className:c,"aria-hidden":"true",children:[l,d]}),e[5]=c,e[6]=d,e[7]=u):u=e[7],u},n2=()=>{const t=Je.c(16),{t:e}=Ct(),{sessionId:s,fill:r,limit:o}=Up(),{totalCost:i}=ix(s);if(!s||!r)return null;let c;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(c=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:ld(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==e?(l=e("contextUsage.tooltip.contextLimit",{tokens:ld(o)}),t[4]=o,t[5]=e,t[6]=l):l=t[6];let d;t[7]!==e||t[8]!==i?(d=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:Kf(i)})]:[],t[7]=e,t[8]=i,t[9]=d):d=t[9];let u;t[10]!==c||t[11]!==l||t[12]!==d?(u=[c,l,...d],t[10]=c,t[11]=l,t[12]=d,t[13]=u):u=t[13];const f=u;let p;return t[14]!==f?(p=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-border/60 pt-1 tabular-nums",children:f.map(i2)}),t[14]=f,t[15]=p):p=t[15],p};function r2(t){return t.currentSessionId}function o2(t){return t.currentSessionDirectory}function i2(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const Gp=150,a2=500,l2=[],c2=t=>t>99?"99+":String(t),d2=t=>{const e=Je.c(62),{surface:s,isActive:r,showActivityDot:o,label:i,description:c,badgeCount:l,badgeAriaLabel:d,badgeDescription:u,orderNumber:f,showOrderNumber:p,onSelect:m}=t;let g;e[0]!==s.id?(g={id:s.id},e[0]=s.id,e[1]=g):g=e[1];const{attributes:b,listeners:v,setNodeRef:x,transform:y,transition:h,isDragging:S}=Wr(g);let w;e[2]!==l?(w=l!=null&&l>0?c2(l):null,e[2]=l,e[3]=w):w=e[3];const C=w;let k;e[4]!==y?(k=Hr.Translate.toString(y),e[4]=y,e[5]=k):k=e[5];let T;e[6]!==k||e[7]!==h?(T={transform:k,transition:h},e[6]=k,e[7]=h,e[8]=T):T=e[8];const O=S&&"z-10 opacity-70";let K;e[9]!==O?(K=Te("relative",O),e[9]=O,e[10]=K):K=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{}),e[11]=R):R=e[11];let I;e[12]!==m||e[13]!==s?(I=()=>m(s),e[12]=m,e[13]=s,e[14]=I):I=e[14];const N=d??i,W=s.id,z=r?"text-primary":"text-muted-foreground hover:text-foreground";let H;e[15]!==z?(H=Te("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",z),e[15]=z,e[16]=H):H=e[16];let M;e[17]!==s.icon||e[18]!==s.iconSrc||e[19]!==s.id?(M=s.id==="diff"?n.jsx(vu,{className:"h-[18px] w-[18px]"}):s.id==="context"?n.jsx(s2,{className:"h-[18px] w-[18px]"}):n.jsx(dr,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[18px] w-[18px]"}),e[17]=s.icon,e[18]=s.iconSrc,e[19]=s.id,e[20]=M):M=e[20];let Y;e[21]!==C||e[22]!==f||e[23]!==o||e[24]!==p?(Y=p&&f!=null?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-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:f===10?"0":f}):C?n.jsx("span",{"aria-hidden":"true",className:"absolute -inset-e-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:C}):o?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[21]=C,e[22]=f,e[23]=o,e[24]=p,e[25]=Y):Y=e[25];let j;e[26]!==b||e[27]!==r||e[28]!==v||e[29]!==s.id||e[30]!==H||e[31]!==M||e[32]!==Y||e[33]!==I||e[34]!==N?(j=n.jsx(Bt,{asChild:!0,children:n.jsxs("button",{type:"button",...b,...v,onClick:I,"aria-label":N,"aria-pressed":r,"data-context-surface":W,className:H,children:[M,Y]})}),e[26]=b,e[27]=r,e[28]=v,e[29]=s.id,e[30]=H,e[31]=M,e[32]=Y,e[33]=I,e[34]=N,e[35]=j):j=e[35];let P;e[36]!==i?(P=n.jsx("span",{children:i}),e[36]=i,e[37]=P):P=e[37];let D;e[38]!==c?(D=n.jsx("span",{className:"typography-micro text-muted-foreground",children:c}),e[38]=c,e[39]=D):D=e[39];let V;e[40]!==u?(V=u?n.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[40]=u,e[41]=V):V=e[41];let B;e[42]!==s.id?(B=s.id==="context"?n.jsx(n2,{}):null,e[42]=s.id,e[43]=B):B=e[43];let _;e[44]!==P||e[45]!==D||e[46]!==V||e[47]!==B?(_=n.jsx(Ot,{side:"left",sideOffset:8,children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[P,D,V,B]})}),e[44]=P,e[45]=D,e[46]=V,e[47]=B,e[48]=_):_=e[48];let F;e[49]!==j||e[50]!==_?(F=n.jsx(Ja,{render:R,children:n.jsxs(Ft,{delayDuration:Gp,children:[j,_]})}),e[49]=j,e[50]=_,e[51]=F):F=e[51];let X;e[52]!==s.mode?(X=n.jsx(Qa,{children:n.jsx(Su,{mode:s.mode})}),e[52]=s.mode,e[53]=X):X=e[53];let oe;e[54]!==F||e[55]!==X?(oe=n.jsxs(el,{children:[F,X]}),e[54]=F,e[55]=X,e[56]=oe):oe=e[56];let ne;return e[57]!==x||e[58]!==oe||e[59]!==T||e[60]!==K?(ne=n.jsx("div",{ref:x,style:T,className:K,children:oe}),e[57]=x,e[58]=oe,e[59]=T,e[60]=K,e[61]=ne):ne=e[61],ne},u2=()=>{const t=Je.c(98),{t:e}=Ct(),s=fn();let r;t[0]!==s?(r=s?Cs(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=$=>o?$.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const c=de(i),l=de(f2),d=de(p2),u=de(h2),f=de(m2),p=de(g2),m=de(b2),g=de(y2),b=de(x2),v=Zu(Qu)?.hasChecked??!1,x=Sn(v2),y=cf(o||null),{screenWidth:h}=En(),S=Ya(o||null);let w;t[4]!==b?(w=dx("switch_context_surface",b),t[4]=b,t[5]=w):w=t[5];const C=w,[k,T]=a.useState(!1);let O,K;t[6]!==C?(O=()=>{const $=new Set;let fe=null,be=!1;const Ie=w2,Ye=()=>{uc(C,$)?!be&&fe===null&&(fe=setTimeout(()=>T(!0),a2)):(be=!1,fe!==null&&(clearTimeout(fe),fe=null),T(!1))},nt=Se=>{if($.add(Se.key.toLowerCase()),Ie(Se.key)&&uc(C,$)){be=!0,fe!==null&&(clearTimeout(fe),fe=null),T(!1);return}Ye()},Ue=Se=>{$.delete(Se.key.toLowerCase()),Ye()},Ve=()=>{$.clear(),be=!1,fe!==null&&(clearTimeout(fe),fe=null),T(!1)};return window.addEventListener("keydown",nt,!0),window.addEventListener("keyup",Ue,!0),window.addEventListener("blur",Ve),()=>{window.removeEventListener("keydown",nt,!0),window.removeEventListener("keyup",Ue,!0),window.removeEventListener("blur",Ve),fe!==null&&clearTimeout(fe)}},K=[C],t[6]=C,t[7]=O,t[8]=K):(O=t[7],K=t[8]),a.useEffect(O,K);let R;t[9]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{distance:8}},t[9]=R):R=t[9];let I;t[10]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{delay:200,tolerance:6}},t[10]=I):I=t[10];const N=Lr(Fs($r,R),Fs(_r,I)),W=Za(),z=dc(k2),H=dc(j2),M=c?.tabs??l2;let Y;t[11]!==g||t[12]!==c?(Y=Ba(c,g),t[11]=g,t[12]=c,t[13]=Y):Y=t[13];const j=Y,P=S?.files.length??0;let D;if(t[14]!==u||t[15]!==d||t[16]!==W||t[17]!==y||t[18]!==h||t[19]!==x||t[20]!==M){let $;t[22]!==y?($=fe=>fe.id==="pr"&&y==="gitlab"?{...fe,icon:"gitlab"}:fe,t[22]=y,t[23]=$):$=t[23],D=ux({railOrder:d,hiddenSurfaces:u,isVSCode:Pn(),screenWidth:h,tabs:M,sourceControlConnected:x,extras:W}).map($),t[14]=u,t[15]=d,t[16]=W,t[17]=y,t[18]=h,t[19]=x,t[20]=M,t[21]=D}else D=t[21];const V=D;let B,_;t[24]!==m||t[25]!==g||t[26]!==o||t[27]!==v||t[28]!==j||t[29]!==x?(_=()=>{!o||!v||x||!j.has("pr")||m(o,Co(g,"pr"))},B=[m,g,o,v,j,x],t[24]=m,t[25]=g,t[26]=o,t[27]=v,t[28]=j,t[29]=x,t[30]=B,t[31]=_):(B=t[30],_=t[31]),a.useEffect(_,B);const[F,X]=a.useState(!1),oe=a.useRef(null),ne=a.useRef(null);let A;t[32]!==y||t[33]!==V||t[34]!==e?(A=$=>{const fe=V.find(Ie=>Ie.id===$.active.id),be=oe.current?.getBoundingClientRect().left;!fe||be===void 0||(ne.current?.cancel(),ne.current=ul({mode:fe.mode,label:fe.label??e(an(fe.labelKey,y)),from:Co(de.getState().contextSurfaceZones,fe.mode)},Ie=>Ie.x<be-16))},t[32]=y,t[33]=V,t[34]=e,t[35]=A):A=t[35];const te=A;let U;t[36]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{ne.current?.cancel(),ne.current=null},t[36]=U):U=t[36];const Pe=U;let xe,ce;t[37]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>()=>ne.current?.cancel(),ce=[],t[37]=xe,t[38]=ce):(xe=t[37],ce=t[38]),a.useEffect(xe,ce);let Oe;t[39]!==o||t[40]!==W||t[41]!==f?(Oe=$=>{const fe=ne.current;if(ne.current=null,fe?.finish(o))return;const{active:be,over:Ie}=$;if(!Ie||be.id===Ie.id)return;const Ye=ff(de.getState().contextRailOrder,W).map(C2),nt=Ye.indexOf(be.id),Ue=Ye.indexOf(Ie.id);nt===-1||Ue===-1||f(il(Ye,nt,Ue))},t[39]=o,t[40]=W,t[41]=f,t[42]=Oe):Oe=t[42];const me=Oe;if(!o)return null;let ie;t[43]!==e?(ie=e("contextRail.aria.rail"),t[43]=e,t[44]=ie):ie=t[44];let q;t[45]!==V?(q=V.map(P2),t[45]=V,t[46]=q):q=t[46];let ue;if(t[47]!==P||t[48]!==H||t[49]!==o||t[50]!==z||t[51]!==p||t[52]!==y||t[53]!==k||t[54]!==j||t[55]!==V||t[56]!==e||t[57]!==l){let $;t[59]!==P||t[60]!==H||t[61]!==o||t[62]!==z||t[63]!==p||t[64]!==y||t[65]!==k||t[66]!==j||t[67]!==e||t[68]!==l?($=(fe,be)=>{const Ie=fe.label??e(an(fe.labelKey,y)),Ye=fe.id==="git"&&!l?P:0,nt=tr(fe.mode)&&!j.has(fe.mode)?z[ko(fe.mode)]??0:0,Ue=Ye>0?Ye:nt>0?nt:null,Ve=Ue!==null&&Ye===0;return n.jsx(d2,{surface:fe,isActive:j.has(fe.mode),showActivityDot:!1,label:Ie,description:e(an(fe.descriptionKey,y)),badgeCount:Ue,badgeAriaLabel:Ue!==null?e(Ve?Ue===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":Ue===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:Ie,count:Ue}):null,badgeDescription:Ue!==null?e(Ve?Ue===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":Ue===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:Ue}):null,orderNumber:be+1,showOrderNumber:k,onSelect:Se=>{tr(Se.mode)&&H(ko(Se.mode)),p(o,Se.mode)}},fe.id)},t[59]=P,t[60]=H,t[61]=o,t[62]=z,t[63]=p,t[64]=y,t[65]=k,t[66]=j,t[67]=e,t[68]=l,t[69]=$):$=t[69],ue=V.map($),t[47]=P,t[48]=H,t[49]=o,t[50]=z,t[51]=p,t[52]=y,t[53]=k,t[54]=j,t[55]=V,t[56]=e,t[57]=l,t[58]=ue}else ue=t[58];let ve;t[70]!==q||t[71]!==ue?(ve=n.jsx(oi,{items:q,strategy:al,children:ue}),t[70]=q,t[71]=ue,t[72]=ve):ve=t[72];let Ee;t[73]!==me||t[74]!==te||t[75]!==N||t[76]!==ve?(Ee=n.jsx(zr,{sensors:N,collisionDetection:Kr,onDragStart:te,onDragCancel:Pe,onDragEnd:me,children:ve}),t[73]=me,t[74]=te,t[75]=N,t[76]=ve,t[77]=Ee):Ee=t[77];let L;t[78]!==e?(L=e("contextRail.configure.open"),t[78]=e,t[79]=L):L=t[79];let le;t[80]===Symbol.for("react.memo_cache_sentinel")?(le=()=>X(!0),t[80]=le):le=t[80];let G;t[81]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Z,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[81]=G):G=t[81];let se;t[82]!==L?(se=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":L,onClick:le,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:G})}),t[82]=L,t[83]=se):se=t[83];let je;t[84]!==e?(je=e("contextRail.configure.open"),t[84]=e,t[85]=je):je=t[85];let he;t[86]!==je?(he=n.jsx(Ot,{side:"left",sideOffset:8,children:je}),t[86]=je,t[87]=he):he=t[87];let ge;t[88]!==se||t[89]!==he?(ge=n.jsxs(Ft,{delayDuration:Gp,children:[se,he]}),t[88]=se,t[89]=he,t[90]=ge):ge=t[90];let ke;t[91]!==F?(ke=n.jsx(Gj,{open:F,onOpenChange:X}),t[91]=F,t[92]=ke):ke=t[92];let Ae;return t[93]!==ie||t[94]!==Ee||t[95]!==ge||t[96]!==ke?(Ae=n.jsxs("nav",{ref:oe,"aria-label":ie,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",children:[Ee,ge,ke]}),t[93]=ie,t[94]=Ee,t[95]=ge,t[96]=ke,t[97]=Ae):Ae=t[97],Ae};function f2(t){return t.workStatusPanelVisible}function p2(t){return t.contextRailOrder}function h2(t){return t.contextRailHiddenSurfaces}function m2(t){return t.setContextRailOrder}function g2(t){return t.openContextSurface}function b2(t){return t.closeContextZone}function y2(t){return t.contextSurfaceZones}function x2(t){return t.shortcutOverrides}function S2(t){return t.status?.status==="connected"}function v2(t){return Object.values(t.entries).some(S2)}function w2(t){return t.length===1&&t>="0"&&t<="9"}function k2(t){return t.countByGuest}function j2(t){return t.clearBadge}function C2(t){return t.id}function P2(t){return t.id}const E2=t=>{const e=Je.c(16),{enabled:s,isSessionSearchOpen:r,openSessionSearch:o,closeSessionSearch:i,sessionSearchInputRef:c,sessionSearchContainerRef:l}=t,d=s===void 0?!0:s;let u,f;e[0]!==d||e[1]!==r||e[2]!==c?(u=()=>{if(!d||!r||typeof window>"u")return;const v=window.requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>window.cancelAnimationFrame(v)},f=[d,r,c],e[0]=d,e[1]=r,e[2]=c,e[3]=u,e[4]=f):(u=e[3],f=e[4]),a.useEffect(u,f);let p,m;e[5]!==d||e[6]!==o||e[7]!==c?(p=()=>{if(!d||typeof window>"u")return;const v=()=>{o(),c.current?.focus(),c.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",v),()=>window.removeEventListener("openchamber:sidebar-session-search",v)},m=[d,o,c],e[5]=d,e[6]=o,e[7]=c,e[8]=p,e[9]=m):(p=e[8],m=e[9]),a.useEffect(p,m);let g,b;e[10]!==i||e[11]!==d||e[12]!==r||e[13]!==l?(g=()=>{if(!d||!r||typeof document>"u")return;const v=x=>{l.current&&(l.current.contains(x.target)||i())};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},b=[d,r,i,l],e[10]=i,e[11]=d,e[12]=r,e[13]=l,e[14]=g,e[15]=b):(g=e[14],b=e[15]),a.useEffect(g,b)},I2=t=>{const e=Je.c(4);let s;e[0]!==t?(s=(i,c)=>{const l=t.get(i);if(!l||l.length===0)return c;const d=new Map(c.map(T2)),u=[];l.forEach(m=>{const g=d.get(m);g&&(u.push(g),d.delete(m))});const f=[],p=[];return c.forEach(m=>{d.has(m.id)&&(m.isArchivedBucket?p.push(m):f.push(m))}),[...f,...u,...p]},e[0]=t,e[1]=s):s=e[1];const r=s;let o;return e[2]!==r?(o={getOrderedGroups:r},e[2]=r,e[3]=o):o=e[3],o};function T2(t){return[t.id,t]}const D2=(t,e)=>{const s=t.groups.find(i=>i.isMain&&i.sessions.length>0)??t.groups.find(i=>i.sessions.length>0)??t.groups.find(i=>i.isMain)??t.groups[0];if(!s)return[];const r=t.groups.find(i=>i.isArchivedBucket&&i.id!==s.id);return(e.mainWorkspaceOnly?[s,...r?[r]:[]]:[...t.groups.find(i=>i.isMain)?[t.groups.find(i=>i.isMain)]:[],...t.groups.filter(i=>!i.isMain)]).map(i=>({group:i,groupKey:`${t.project.id}:${i.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?i.id===s.id:i.isMain}))},dd=(t,e,s)=>{if(!e)return;const r=o=>{let i=o.session.id===e;for(const c of o.children)i=r(c)||i;return i&&s.add(o.session.id),i};for(const o of t)r(o)},or=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const s of t.children)if(or(s,e))return!0;return!1},R2=({isSubtaskSession:t,archivedBucket:e,isVSCode:s,sessionDirectory:r})=>!t&&!e&&!s&&!Fa(r),N2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:s})=>!t||e||s,Pa=(t,e,s)=>{const r=new Map,o=i=>{const c=sr(i.session)??vt(i.worktree?.path)??s;if(c){const l=r.get(c)??[];l.push(i.session.id),r.set(c,l)}if(!(i===t&&e))for(const l of i.children)o(l)};return o(t),[...r].map(([i,c])=>({directory:i,sessionIDs:c}))},Ea=(t,e)=>{const s=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const o=new Set;let i=r.session.parentID??null;for(;i&&!o.has(i);){if(s.has(i)&&e.has(i))return!1;o.add(i),i=e.get(i)?.session?.parentID??null}return!0})},qp=t=>{const e=new Map(t.map(c=>[c.id,c])),s=new Map;for(const c of t){if(!c.parentId||!e.has(c.parentId))continue;const l=s.get(c.parentId)??[];l.push(c),s.set(c.parentId,l)}const r=new Set,o=[],i=c=>{if(r.has(c.id))return;o.push(c);const l=[c.id];for(;l.length>0;){const d=l.pop();if(!(!d||r.has(d))){r.add(d);for(const u of s.get(d)??[])l.push(u.id)}}};return t.forEach(c=>{(!c.parentId||!e.has(c.parentId))&&i(c)}),t.forEach(i),o},Yp=(t,e)=>{const s=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),o=new Map,i=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){i.add(u.id);continue}if(u.parentId){const m=o.get(u.parentId)??[];m.push(u.id),o.set(u.parentId,m)}const f=new Set;let p=u.id;for(;p;){if(f.has(p)){i.add(u.id);break}f.add(p),p=r.get(p)?.parentId}}const c=new Set,l=new Set,d=u=>{if(c.has(u))return!0;if(l.has(u))return!1;const f=r.get(u);if(!f)return!1;l.add(u);let p=i.has(u);return!p&&e.archivedBucket&&f.nodeCount===0?p=(o.get(u)??[]).some(d):(!p&&!e.searchQuery&&(p=!0),!p&&(f.nodeCount>0||!s&&To([f.name],e.searchQuery))&&(p=!0),p||(p=(o.get(u)??[]).some(d))),l.delete(u),p&&c.add(u),p};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>c.has(u.id)).map(u=>u.id))},ud=new WeakMap;let fd=1;const M2=t=>{const e=ud.get(t);if(e!==void 0)return e;const s=fd;return fd+=1,ud.set(t,s),s},Mr=t=>t.children.length===0?"":t.children.map(s=>{const r=M2(s.session);return s.children.length===0?`${s.session.id}@${r}`:`${s.session.id}@${r}:${Mr(s)}`}).join("|"),Xp=(t,e,s,r,o,i)=>{const c=Gt(),l=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const f=d.session.directory??o,p=u.session.directory??i,m=fc(c,f??"",d.session.id),g=fc(c,p??"",u.session.id);return(m?s.has(m):!1)!==(g?r.has(g):!1)?!0:d.children.some((b,v)=>l(b,u.children[v]))};return l(t,e)},A2=(t,e)=>t?t.branchLabel??null:e??null,O2=(t,e)=>{if(e)return null;const s=t?.branch?.trim(),r=vt(t?.path??null);return s&&r?{directory:r,branch:s}:null},Lo=(t,e,s,r)=>{if(!e)return null;const o=r?"archived":"active";let i=null;const c=l=>{if(`${s}:${o}:${l.session.id}`===e)return i=l.session.id,!0;for(const u of l.children)if(c(u))return!0;return!1};return t.forEach(l=>c(l)),i},An=(t,e)=>`${t}\0${e}`,Jn=(t,e)=>t??La(e)??vt(e??null),ir=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??vt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},xl=t=>t.startsWith("__archived__:"),Sl=(t,e)=>{const s=e.trim().toLowerCase();return s?s.startsWith("ses_")?t.id.toLowerCase()===s:(typeof t.title=="string"?t.title.toLowerCase():"").includes(e):!0},Zp=(t,e)=>Sl(t.session,e)||t.children.some(s=>Zp(s,e)),Qp=(t,e)=>(Sl(t.session,e)?1:0)+t.children.reduce((s,r)=>s+Qp(r,e),0),pd=({sessions:t,getSessionLocation:e,getSessionNode:s,query:r})=>t.flatMap(o=>{if(!Sl(o,r))return[];const i=e(o.id);return[{node:s(o),projectId:i?.projectId??null,groupDirectory:i?.groupDirectory??o.directory??null,secondaryMeta:{projectLabel:i?.projectLabel??null,branchLabel:i?.branchLabel??null,inSpace:i?.inSpace??!1}}]}),Jp=["chats","pinned","work"],ar=t=>t==="timeline"||t==="timeline-mixed",B2=t=>ar(t)||t==="mixed-compact",so=t=>"run"in t,F2=(t,e)=>`${t}:active:run:${e}`,Fi=(t,e,s)=>{if(s||e.runKeyBySessionId.size===0)return[...t];const r=[],o=new Map;for(const i of t){const c=e.runKeyBySessionId.get(i.session.id),l=c?e.runs.get(c):void 0;if(!l){r.push(i);continue}const d=o.get(l.key);if(d){d.lanes.push(i);continue}const u={run:l,lanes:[i]};o.set(l.key,u),r.push(u)}for(const i of o.values()){const c=new Map(i.run.memberIds.map((l,d)=>[l,d]));i.lanes.sort((l,d)=>(c.get(l.session.id)??0)-(c.get(d.session.id)??0))}return r},eh=(t,e)=>{const s=e.trim().toLowerCase(),r=s.startsWith("ses_"),o=i=>i.reduce((c,l)=>c+(!r||l.session.id.toLowerCase()===s?1:0)+o(l.children),0);return o(t)},hd=[],L2=new Set,md=32,gd=52,_2=3,$2=7,bd=7,yd=7,th=t=>`timeline-project:${t}`,mr=32,mn=28,xd=(t,e,s,r)=>{const o=r.get(t.session.id),i=r.get(e.session.id);if(o!==void 0||i!==void 0){if(o===void 0)return 1;if(i===void 0)return-1;if(o!==i)return o-i}return tl(t.session,e.session,s,pf)},Li=t=>{const e=new Map,s=new Map,r=[],o=new WeakMap,i=t.map(c=>({node:c,visited:!1})).reverse();for(;i.length>0;){const c=i.pop();if(!c)continue;if(!c.visited){e.set(c.node.session.id,c.node),s.set(c.node.session.id,c.node.session);const d=r.length;r.push(c.node.session.id),o.set(c.node,[d,d+1]),i.push({node:c.node,visited:!0});for(let u=c.node.children.length-1;u>=0;u-=1){const f=c.node.children[u];f&&i.push({node:f,visited:!1})}continue}const l=o.get(c.node);l&&o.set(c.node,Object.freeze([l[0],r.length]))}return{byId:e,sessionsById:s,preorderIds:Object.freeze(r),subtreeRangeByNode:o}},z2=(t,e,s)=>`${t}:${e?"archived":"active"}:${s}`,K2=(t,e)=>{let s=null;for(const r of t){if(r.rowIndex>e)break;s=r}return s},W2=t=>{const e=[],s=[],r=[],o=[],i=[],c=new Map,l=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),f=t.zoneSessionIds??L2,p=j=>d&&f.has(j);let m=0;const b=[...[...t.authoritativeSections.flatMap(j=>j.groups.flatMap(P=>P.sessions)),...t.chatGroup?.sessions??[]]];for(;b.length>0;){const j=b.pop();j&&(c.set(j.session.id,j.session),b.push(...j.children))}const v=j=>{const P=l.get(j)??0;return l.set(j,P+1),P===0?j:`${j}:${P}`},x=j=>{e.push(Object.freeze(j))},y=t.runIndex??fx,h=(j,P)=>{const D=F2(P.renderContext,j.run.key),V=!B2(P.renderContext)&&(d||t.expandedParents.has(D)),B=j.lanes[0]?.session.id,_=B&&P.getSecondaryMeta?P.getSecondaryMeta(B):P.secondaryMeta,F=Object.freeze([...new Set(j.lanes.flatMap(X=>(P.getBlockingBadgeSessionScopes?.(X.session.id)??[]).flatMap(oe=>oe.sessionIDs)))]);x({kind:"run",key:v(`${P.containerKey}:run:${j.run.key}`),estimateSize:ar(P.renderContext)?gd:md,run:j.run,depth:P.baseDepth??0,laneNodes:Object.freeze([...j.lanes]),blockingSessionIds:F,projectId:P.projectId,projectLabel:_?.projectLabel??null,groupDirectory:P.groupDirectory,renderContext:P.renderContext,expansionKey:D,expanded:V,forceExpanded:d}),V&&w(j.lanes,(P.baseDepth??0)+1,P)},S=j=>{for(const P of Fi(j.nodes,y,j.archived))so(P)?h(P,j):w([P],j.baseDepth??0,j)},w=(j,P,D)=>{const V=[...j].reverse().map(B=>({node:B,depth:P,directory:D.groupDirectory}));for(;V.length>0;){const B=V.pop();if(!B)continue;const _=v(`${D.containerKey}:session:${B.node.session.id}`),F=B.node.session.directory??B.directory;c.set(B.node.session.id,B.node.session),x({kind:"session",key:_,estimateSize:ar(D.renderContext)?gd:md,node:B.node,blockingBadgeSessionScopes:B.depth===P?D.getBlockingBadgeSessionScopes?.(B.node.session.id)??D.blockingBadgeSessionScopes:void 0,depth:B.depth,projectId:D.projectId,groupDirectory:B.directory,ownerKey:D.ownerKey,selectionScopeKey:D.selectionScopeKey,archived:D.archived,renderContext:D.renderContext,secondaryMeta:D.getSecondaryMeta?D.getSecondaryMeta(B.node.session.id):D.secondaryMeta??null});const X=D.indexedNodes?.subtreeRangeByNode.get(B.node),oe=X&&X[1]>X[0]+1?Object.freeze([(D.selectionPoolOffset??0)+X[0]+1,(D.selectionPoolOffset??0)+X[1]]):void 0;if(s.push(Object.freeze({id:B.node.session.id,rowKey:_,scopeKey:D.selectionScopeKey,archived:D.archived,descendantRange:oe})),!(!d&&!t.expandedParents.has(z2(D.renderContext,D.archived,B.node.session.id))))for(let ne=B.node.children.length-1;ne>=0;ne-=1){const A=B.node.children[ne];A&&V.push({node:A,depth:B.depth+1,directory:F})}}},C=j=>{const P=t.groupSearchDataByGroup.get(j);if(P?.hasMatch!==!0)return 0;const D=f.size>0?P.filteredNodes.filter(B=>p(B.session.id)):[];return Math.max(0,P.matchedSessionCount-eh(D,t.normalizedQuery))+P.folderNameMatchCount+(P.groupMatches?1:0)},k=(j,P,D,V,B)=>{const _=t.groupSearchDataByGroup.get(j);if(d){const ye=C(j);if(ye===0)return;m+=ye}const F=(d?_?.filteredNodes??[]:j.sessions).filter(ye=>!p(ye.session.id)).sort((ye,Ge)=>xd(ye,Ge,u,t.sessionOrderIndex)),X=Li(F),oe=r.length;r.push(...X.preorderIds);for(const[ye,Ge]of X.sessionsById)c.set(ye,Ge);const ne=Jn(D,j.directory),A=!d&&t.collapsedGroups.has(P),te=V?0:1,U=B!==void 0&&B.renderContext!=="project",Pe=t.groupStatusByKey.get(P),xe=!Pe||Pe.state==="ready",ce=F.length===0&&xe&&ir(j).every(({scopeKey:ye})=>(t.foldersMap[ye]??hd).length===0);if(!V){const ye=X.preorderIds.flatMap(Ge=>X.sessionsById.get(Ge)??[]);x({kind:"group-header",key:`${P}:header`,estimateSize:mr,group:j,groupKey:P,projectId:D,collapsed:A&&!ce,forceExpanded:d,empty:ce,allSessions:Object.freeze(ye)})}if(A&&!ce)return;const Oe=ir(j).flatMap(({scopeKey:ye,directory:Ge})=>(t.foldersMap[ye]??hd).map(qe=>({folder:qe,scopeKey:ye,scopeDirectory:Ge,ownerKey:ne,nodes:Ea(qe.sessionIds,X.byId).sort((ft,et)=>xd(ft,et,u,t.sessionOrderIndex))}))),me=Yp(Oe.map(ye=>({id:ye.folder.id,name:ye.folder.name,parentId:ye.folder.parentId,nodeCount:ye.nodes.length})),{archivedBucket:j.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),ie=Oe.filter(ye=>me.has(ye.folder.id)),q=new Map(ie.map(ye=>[An(ye.scopeKey,ye.folder.id),ye])),ue=new Map;for(const ye of ie){if(!ye.folder.parentId)continue;const Ge=An(ye.scopeKey,ye.folder.parentId),qe=ue.get(Ge)??[];qe.push(ye),ue.set(Ge,qe)}const ve=qp(ie.map(ye=>({...ye.folder,scopeKey:ye.scopeKey}))).map(ye=>q.get(An(ye.scopeKey??"",ye.id))).filter(ye=>!!ye),Ee=new Set(ie.flatMap(ye=>ye.folder.sessionIds)),L=F.filter(ye=>!Ee.has(ye.session.id)),le=new Map,G=ve.map(ye=>({folder:ye,visited:!1})),se=new Set;for(;G.length>0;){const ye=G.pop();if(!ye)continue;const Ge=An(ye.folder.scopeKey,ye.folder.folder.id);if(!ye.visited){if(se.has(Ge))continue;se.add(Ge),G.push({folder:ye.folder,visited:!0});for(const ft of ue.get(Ge)??[])G.push({folder:ft,visited:!1});continue}const qe=ye.folder.nodes.flatMap(ft=>{const et=X.subtreeRangeByNode.get(ft);return et?X.preorderIds.slice(et[0],et[1]).flatMap(St=>X.sessionsById.get(St)??[]):[ft.session]});for(const ft of ue.get(Ge)??[])qe.push(...le.get(An(ft.scopeKey,ft.folder.id))??[]);le.set(Ge,Object.freeze(qe))}const je=new Set,he=(ye,Ge)=>{const qe=An(ye.scopeKey,ye.folder.id);if(je.has(qe))return;je.add(qe);const ft=Ge?`${Ge} / ${ye.folder.name}`:ye.folder.name,et=`${P}:folder:${qe}`,St=xe&&ye.nodes.length===0&&(ue.get(qe)?.length??0)===0,we=!d&&!St&&t.collapsedFolders.has(ye.folder.id),De=le.get(qe)??[],ot=we&&!j.isArchivedBucket?Ea([...new Set(De.map(ht=>ht.id))],X.byId):[],rt=ne?t.folderAuthorityByOwner.get(ne):void 0,Xe=!!ne&&!j.isArchivedBucket&&!xl(ye.scopeKey)&&rt?.complete===!0&&rt.scopeKeys.includes(ye.scopeKey);if(x({kind:"folder-header",key:et,estimateSize:mr,depth:te,group:j,folder:ye.folder,displayName:ft,scopeKey:ye.scopeKey,scopeDirectory:ye.scopeDirectory,ownerKey:ne,nodes:ye.nodes,activityNodes:ot,projectId:D,archived:j.isArchivedBucket===!0,collapsed:we,forceExpanded:d,empty:St,deleteSessions:De,subFolderCount:ue.get(qe)?.length??0,dropEnabled:Xe}),ne&&i.push(Object.freeze({rowKey:et,scopeKey:ye.scopeKey,folderId:ye.folder.id,ownerKey:ne,enabled:Xe})),!we){S({nodes:ye.nodes,containerKey:et,projectId:D,groupDirectory:ye.scopeDirectory??j.directory,ownerKey:ne,selectionScopeKey:ne,archived:j.isArchivedBucket===!0,renderContext:"project",indexedNodes:X,selectionPoolOffset:oe,baseDepth:te+1});for(const ht of ue.get(qe)??[])he(ht,ft)}};for(const ye of ve)he(ye,"");const ge=D?t.sessionBatchSize:void 0,ke=B?.initial??ge??(t.hideDirectoryControls?10:bd),Ae=B?.increment??ge??yd,$=Math.max(ke,t.visibleCountByContainer.get(P)??ke),fe=ye=>!so(ye)&&B?.pinnedAlwaysVisible===!0&&ni(u,ye.session.directory??j.directory,ye.session.id),be=Fi(L,y,j.isArchivedBucket===!0),Ie=be.filter(ye=>!fe(ye));let Ye=$;const nt=j.isArchivedBucket||d?be:be.filter(ye=>fe(ye)?!0:Ye<=0?!1:(Ye-=1,!0)),Ue=nt.flatMap(ye=>so(ye)?ye.lanes:[ye]);S({nodes:Ue,containerKey:P,projectId:D,groupDirectory:j.directory,ownerKey:ne,selectionScopeKey:ne,archived:j.isArchivedBucket===!0,renderContext:B?.renderContext??"project",indexedNodes:X,selectionPoolOffset:oe,baseDepth:te});const Ve=be.length-nt.length,Se=$-Ye;!d&&!j.isArchivedBucket&&Ve>0?x({kind:"show-control",key:`${P}:more`,estimateSize:mn,control:"more",containerKey:P,currentCount:Se,increment:Ae,depth:te,flat:U}):!d&&!j.isArchivedBucket&&Ie.length>ke&&Ve===0&&x({kind:"show-control",key:`${P}:fewer`,estimateSize:mn,control:"fewer",containerKey:P,currentCount:Se,increment:Ae,depth:te,flat:U}),F.length===0&&ie.length===0?Pe&&Pe.state!=="ready"?x({kind:"status",key:`${P}:status`,estimateSize:mn,status:Pe,group:j,groupKey:P,depth:te,flat:U}):j.isArchivedBucket&&x({kind:"empty",key:`${P}:empty`,estimateSize:mn,emptyKind:"archived",depth:te}):Pe&&Pe.state!=="ready"&&Pe.state!=="loading"&&x({kind:"status",key:`${P}:status`,estimateSize:mn,status:Pe,group:j,groupKey:P,depth:te,flat:U})},T=j=>{const P=!d&&t.collapsedActivities.has(j),D=e.length;return x({kind:"activity-header",key:`activity:${j}:header`,estimateSize:mr,activityKey:j,collapsed:P,forceExpanded:d}),o.push(Object.freeze({rowIndex:D,kind:"activity",id:j})),P},O=t.viewMode==="timeline",K=j=>"run"in j,R=j=>{const P=Fi(j.map(V=>V.node),y,!1),D=new Map(j.map(V=>[V.node,V]));return P.flatMap(V=>{if(!so(V)){const B=D.get(V);return B?[B]:[]}return[{run:V.run,items:V.lanes.flatMap(B=>D.get(B)??[])}]})},I=(j,P,D)=>{const V=j.items[0];if(!V)return;const B=j.items.map(A=>A.node),_=Li(B),F=r.length;r.push(..._.preorderIds);const X=Jn(V.projectId,V.groupDirectory),oe=new Map(j.items.map(A=>[A.node.session.id,A.getSecondaryMeta?A.getSecondaryMeta(A.node.session.id):A.secondaryMeta])),ne=new Map(j.items.map(A=>[A.node.session.id,A.blockingBadgeSessionScopes]));h({run:j.run,lanes:B},{nodes:B,containerKey:P,projectId:V.projectId,groupDirectory:V.groupDirectory,ownerKey:X,selectionScopeKey:null,archived:!1,renderContext:D,getSecondaryMeta:A=>oe.get(A)??null,getBlockingBadgeSessionScopes:A=>ne.get(A),indexedNodes:_,selectionPoolOffset:F})},N=(j,P,D,V=()=>1)=>{for(const B of R(j)){if(K(B)){I(B,P,D),d&&(m+=B.items.reduce((ne,A)=>ne+V(A),0));continue}const _=B,F=Li([_.node]),X=r.length;r.push(...F.preorderIds);const oe=Jn(_.projectId,_.groupDirectory);S({nodes:[_.node],containerKey:P,projectId:_.projectId,groupDirectory:_.groupDirectory,ownerKey:oe,selectionScopeKey:null,archived:!1,renderContext:D,blockingBadgeSessionScopes:_.blockingBadgeSessionScopes,secondaryMeta:_.secondaryMeta,getSecondaryMeta:_.getSecondaryMeta,indexedNodes:F,selectionPoolOffset:X}),d&&(m+=V(_))}};t.chatGroup&&(!d||C(t.chatGroup)>0)&&(T("chats")||k(t.chatGroup,"activity:chats",null,!0,{initial:_2,increment:$2,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}));const W=O||t.detailedZoneRows?"timeline-mixed":"mixed-compact",z=(j,P,D,V,B)=>{const _=Math.max(V,t.visibleCountByContainer.get(P)??V),F=R(j),X=d?F:F.slice(0,_);N(X.flatMap(oe=>K(oe)?oe.items:[oe]),P,D),!d&&(F.length>X.length?x({kind:"show-control",key:`${P}:more`,estimateSize:mn,control:"more",containerKey:P,currentCount:X.length,increment:B,flat:!0}):F.length>V&&x({kind:"show-control",key:`${P}:fewer`,estimateSize:mn,control:"fewer",containerKey:P,currentCount:X.length,increment:B,flat:!0}))},H=(j,P)=>{if(P.length===0)return;T(j)||N(P,`activity:${j}`,W,V=>Qp(V.node,t.normalizedQuery))};if(H("pinned",t.pinnedItems??[]),H("work",t.workItems??[]),O){const j=new Map;for(const P of t.timelineItems??[]){if(!P.projectId||p(P.node.session.id))continue;const D=j.get(P.projectId);D?D.push(P):j.set(P.projectId,[P])}for(const P of t.sections){const D=P.project.id,V=j.get(D)??[];if(d&&V.length===0)continue;const B=!d&&t.collapsedProjects.has(D),_=e.length;if(x({kind:"project-header",key:`project:${D}:header`,estimateSize:mr,section:P,collapsed:B,forceExpanded:d}),o.push(Object.freeze({rowIndex:_,kind:"project",id:D})),B)continue;if(V.length>0){z(V,th(D),"timeline",bd,yd);continue}const F=P.groups.find(ne=>ne.isMain);if(!F)continue;const X=`${D}:${F.id}`,oe=t.groupStatusByKey.get(X);oe&&oe.state!=="ready"&&x({kind:"status",key:`${X}:status`,estimateSize:mn,status:oe,group:F,groupKey:X,flat:!0})}}let M=O?[]:t.singleProjectMode?t.sections.filter(j=>j.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const j=M.find(P=>P.project.id===t.activeProjectId)??M[0];M=j?[j]:[]}for(const j of M){const P=D2(j,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!P.some(V=>C(V.group)>0))continue;const D=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(j.project.id);if(!t.showOnlyMainWorkspace){const V=e.length;x({kind:"project-header",key:`project:${j.project.id}:header`,estimateSize:mr,section:j,collapsed:D,forceExpanded:d}),o.push(Object.freeze({rowIndex:V,kind:"project",id:j.project.id}))}if(!D)for(const V of P)k(V.group,V.groupKey,V.projectId,V.hideGroupLabel)}e.length===0&&x({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const Y=new Map;return e.forEach((j,P)=>Y.set(j.key,P)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(s),selectionDescendantIds:Object.freeze(r),rowIndexByKey:Y,stickyHeaders:Object.freeze(o),folderDropTargets:Object.freeze(i),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:c,searchMatchCount:d?m:0})},no="oc.sessions.projectCollapse",Sd="oc.sessions.groupOrder",vd="oc.sessions.groupCollapse",wd="oc.sessions.activityCollapse",_i=t=>{if(!t)return new Set;try{const e=ii(Ls()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},H2=t=>{if(!t)return new Map;try{const e=Dr(Ls(),ii(Ls())).safeParse(JSON.parse(t));if(!e.success)return new Map;const s=new Map;for(const[r,o]of Object.entries(e.data))s.set(r,o);return s}catch{return new Map}},V2=t=>{const e=Je.c(45),{isVSCode:s,projects:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Po(),e[0]=o):o=e[0];const i=o;let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=()=>_i(i.getItem(no)),e[1]=c):c=e[1];const[l,d]=a.useState(c);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>_i(i.getItem(vd)),e[2]=u):u=e[2];const[f,p]=a.useState(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=()=>_i(i.getItem(wd)),e[3]=m):m=e[3];const[g,b]=a.useState(m);let v;e[4]===Symbol.for("react.memo_cache_sentinel")?(v=()=>H2(i.getItem(Sd)),e[4]=v):v=e[4];const[x,y]=a.useState(v),h=a.useRef(0),S=a.useRef(!1),w=a.useRef(!1),C=a.useRef(!1),k=a.useRef(null),T=a.useRef(null);let O;e[5]!==s?(O=()=>{if(s)return;const ue=T.current;if(T.current=null,k.current=null,!ue)return;const{projects:ve}=Jt.getState(),Ee=ve.map(L=>({...L,sidebarCollapsed:ue.has(L.id)}));nn({projects:Ee}).catch(U2)},e[5]=s,e[6]=O):O=e[6];const K=O;let R;e[7]!==K||e[8]!==s?(R=ue=>{!globalThis.window||s||(T.current=ue,k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{K()},700))},e[7]=K,e[8]=s,e[9]=R):R=e[9];const I=R;let N,W;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=()=>()=>{globalThis.window&&k.current!==null&&window.clearTimeout(k.current),k.current=null,T.current=null},W=[],e[10]=N,e[11]=W):(N=e[10],W=e[11]),a.useEffect(N,W);let z,H;e[12]!==x?(z=()=>{if(C.current)try{i.setItem(Sd,JSON.stringify(Object.fromEntries(x.entries())))}catch{}},H=[x,i],e[12]=x,e[13]=z,e[14]=H):(z=e[13],H=e[14]),a.useEffect(z,H);let M,Y;e[15]!==f?(M=()=>{if(S.current)try{i.setItem(vd,JSON.stringify(Array.from(f)))}catch{}},Y=[f,i],e[15]=f,e[16]=M,e[17]=Y):(M=e[16],Y=e[17]),a.useEffect(M,Y);let j,P;e[18]!==g?(j=()=>{if(w.current)try{i.setItem(wd,JSON.stringify(Array.from(g)))}catch{}},P=[g,i],e[18]=g,e[19]=j,e[20]=P):(j=e[19],P=e[20]),a.useEffect(j,P);let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=ue=>{w.current=!0,b(ue)},e[21]=D):D=e[21];const V=D;let B;e[22]!==r||e[23]!==I?(B=()=>{h.current=Date.now()+150,S.current=!0,w.current=!0,p(new Set),b(G2),d(()=>{const ue=new Set(r.map(q2));try{i.setItem(no,JSON.stringify(Array.from(ue)))}catch{}return I(ue),ue})},e[22]=r,e[23]=I,e[24]=B):B=e[24];const _=B;let F;e[25]!==I?(F=()=>{h.current=Date.now()+150,S.current=!0,w.current=!0,p(new Set),b(Y2),d(()=>{const ue=new Set;try{i.setItem(no,JSON.stringify([]))}catch{}return I(ue),ue})},e[25]=I,e[26]=F):F=e[26];const X=F;let oe;e[27]!==I?(oe=ue=>{h.current=Date.now()+150,d(ve=>{const Ee=new Set(ve);Ee.has(ue)?Ee.delete(ue):Ee.add(ue);try{i.setItem(no,JSON.stringify(Array.from(Ee)))}catch{}return I(Ee),Ee})},e[27]=I,e[28]=oe):oe=e[28];const ne=oe;let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=ue=>{S.current=!0,p(ve=>{const Ee=new Set(ve);return Ee.has(ue)?Ee.delete(ue):Ee.add(ue),Ee})},e[29]=A):A=e[29];const te=A;let U;e[30]===Symbol.for("react.memo_cache_sentinel")?(U=ue=>{C.current=!0,y(ue)},e[30]=U):U=e[30];const Pe=U,{getOrderedGroups:xe}=I2(x);let ce;e[31]!==g||e[32]!==f||e[33]!==l||e[34]!==x?(ce={collapsedProjects:l,collapsedGroups:f,collapsedActivities:g,groupOrderByProject:x},e[31]=g,e[32]=f,e[33]=l,e[34]=x,e[35]=ce):ce=e[35];const Oe=ce;let me;e[36]!==_||e[37]!==X||e[38]!==xe||e[39]!==I||e[40]!==ne?(me={setCollapsedProjects:d,toggleProject:ne,collapseAll:_,expandAll:X,scheduleCollapsedProjectsPersist:I,setCollapsedGroups:p,setCollapsedActivities:V,toggleGroup:te,setGroupOrderByProject:Pe,getOrderedGroups:xe},e[36]=_,e[37]=X,e[38]=xe,e[39]=I,e[40]=ne,e[41]=me):me=e[41];const ie=me;let q;return e[42]!==ie||e[43]!==Oe?(q={state:Oe,actions:ie},e[42]=ie,e[43]=Oe,e[44]=q):q=e[44],q};function U2(){}function G2(t){return new Set([...t,...Jp])}function q2(t){return t.id}function Y2(t){const e=new Set(t);for(const s of Jp)e.delete(s);return e}const X2=5*6e4,Z2=t=>{const e=Je.c(38),{normalizedProjects:s,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:c}=t,l=r===void 0?!0:r,{git:d}=_s(),u=vn(Q2),f=vn(J2),p=a.useRef(null),m=a.useRef(l);let g,b;e[0]!==l||e[1]!==u||e[2]!==d||e[3]!==f?(g=()=>{const I=l&&!m.current;m.current=l;const N=p.current;if(!(!I||!d||!N||N.git!==d||N.runtimeKey!==f))for(const W of N.paths)kr(()=>u(W,d))},b=[l,u,d,f],e[0]=l,e[1]=u,e[2]=d,e[3]=f,e[4]=g,e[5]=b):(g=e[4],b=e[5]),a.useEffect(g,b);let v,x;e[6]!==l||e[7]!==u||e[8]!==d||e[9]!==f||e[10]!==s||e[11]!==i?(v=()=>{if(!l)return;if(!d||s.length===0){p.current=null,i(new Map);return}let I=p.current;(!I||I.runtimeKey!==f||I.git!==d)&&(I={runtimeKey:f,git:d,paths:new Set},p.current=I);const{paths:N}=I,W=new Set(s.map(eC));for(const M of N)W.has(M)||N.delete(M);const z=[...W].filter(M=>!N.has(M));if(z.length===0)return;for(const M of z)N.add(M);const H=M=>{const Y=vn.getState().directories.get(M);Y?.isGitRepo!==!1&&!Y?.status&&N.delete(M)};kr(async()=>{await d.prefetchProjectStatuses?.(z),await Promise.all(z.map(M=>u(M,d).then(()=>H(M),()=>H(M))))})},x=[l,s,d,f,u,i],e[6]=l,e[7]=u,e[8]=d,e[9]=f,e[10]=s,e[11]=i,e[12]=v,e[13]=x):(v=e[12],x=e[13]),a.useEffect(v,x);let y,h;e[14]!==l||e[15]!==o||e[16]!==s||e[17]!==i?(y=()=>{if(!l)return;const I=new Map;s.forEach(N=>{I.set(N.id,o.get(N.normalizedPath)?.isGitRepo??null)}),i(I)},h=[l,s,o,i],e[14]=l,e[15]=o,e[16]=s,e[17]=i,e[18]=y,e[19]=h):(y=e[18],h=e[19]),a.useEffect(y,h);let S;if(e[20]!==o||e[21]!==s){let I;e[23]!==o?(I=N=>{const W=o.get(N.normalizedPath)?.branch??"";return`${N.id}:${W}`},e[23]=o,e[24]=I):I=e[24],S=s.map(I).join("|"),e[20]=o,e[21]=s,e[22]=S}else S=e[22];const w=S;let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[25]=C):C=e[25];const k=a.useRef(C);let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=new Map,e[26]=T):T=e[26];const O=a.useRef(T);let K;e[27]!==l||e[28]!==o||e[29]!==s||e[30]!==c?(K=()=>{if(!l)return;let I=!1;const N=setTimeout(()=>{(async()=>{const z=new Set(s.map(tC));for(const D of k.current.keys())z.has(D)||(k.current.delete(D),O.current.delete(D));const H=Date.now(),M=s.filter(D=>{const V=o.get(D.normalizedPath);if(V?.isGitRepo===!1)return k.current.delete(D.id),O.current.delete(D.id),!1;if(V?.isGitRepo!==!0||V.branch===null)return!1;const B=V.branch.trim(),_=`${D.normalizedPath}\0${B}`,F=k.current.get(D.id);if(F===_){const X=O.current.get(D.id);return X&&(X.at=H),!1}return!(F!==void 0&&H-(O.current.get(D.id)?.at??0)<X2)});if(M.length===0)return;const Y=await kr(()=>Promise.all(M.map(async D=>{const V=o.get(D.normalizedPath)?.branch?.trim()??"",B=`${D.normalizedPath}\0${V}`,_=await rf(D.normalizedPath,V?{knownBranch:V}:void 0).catch(sC);return{id:D.id,inputKey:B,branch:_}})));if(I)return;const j=Y.filter(nC);if(j.length===0)return;const P=Date.now();c(D=>{const V=new Map(D);return j.forEach(B=>{const{id:_,branch:F}=B;F&&V.set(_,F)}),V}),j.forEach(D=>{const{id:V,inputKey:B,branch:_}=D;k.current.set(V,B),_&&O.current.set(V,{branch:_,at:P})})})()},150);return()=>{I=!0,clearTimeout(N)}},e[27]=l,e[28]=o,e[29]=s,e[30]=c,e[31]=K):K=e[31];let R;e[32]!==l||e[33]!==o||e[34]!==s||e[35]!==w||e[36]!==c?(R=[l,s,w,o,c],e[32]=l,e[33]=o,e[34]=s,e[35]=w,e[36]=c,e[37]=R):R=e[37],a.useEffect(K,R)};function Q2(t){return t.ensureStatus}function J2(t){return t.runtimeKey}function eC(t){return t.normalizedPath}function tC(t){return t.id}function sC(){return null}function nC(t){return t.branch}const rC=t=>{const e=Je.c(19),{open:s,onOpenChange:r,project:o,onSave:i}=t,c=de(oC),[l,d]=a.useState("general");let u,f;e[0]!==s?(u=()=>{s&&d("general")},f=[s],e[0]=s,e[1]=u,e[2]=f):(u=e[1],f=e[2]),a.useEffect(u,f);const p=o?.id??null;let m;e:{if(!p){m=void 0;break e}let y;e[3]!==r||e[4]!==p||e[5]!==c?(y=()=>{r(!1),c(p)},e[3]=r,e[4]=p,e[5]=c,e[6]=y):y=e[6],m=y}const g=m;let b;e[7]!==g||e[8]!==i||e[9]!==s||e[10]!==o||e[11]!==l?(b=s&&o?n.jsx(qg,{frame:"dialog",project:o,onIdentitySave:i,tab:l,onTabChange:d,onOpenWorktrees:g}):null,e[7]=g,e[8]=i,e[9]=s,e[10]=o,e[11]=l,e[12]=b):b=e[12];let v;e[13]!==b?(v=n.jsx(Gs,{className:"flex h-[min(85vh,40rem)] w-full max-w-2xl flex-col gap-0 overflow-hidden p-0",children:b}),e[13]=b,e[14]=v):v=e[14];let x;return e[15]!==r||e[16]!==s||e[17]!==v?(x=n.jsx(qs,{open:s,onOpenChange:r,children:v}),e[15]=r,e[16]=s,e[17]=v,e[18]=x):x=e[18],x};function oC(t){return t.setWorktreesPageProjectId}function iC(t,e,s,r){const o=Je.c(6),[i,c]=a.useState(!0);let l,d;return o[0]!==e||o[1]!==r||o[2]!==s||o[3]!==t?(l=()=>{const u=t.current,f=e.current,p=s.current;if(!u||!f||!p||r===0)return;const m=()=>{const b=f.lastElementChild,v=b?b.getBoundingClientRect().width:0,x=Number.parseFloat(getComputedStyle(f).columnGap)||0,y=Number.parseFloat(getComputedStyle(u).columnGap)||0,h=f.getBoundingClientRect().width+r*(x+v),S=u.getBoundingClientRect().right-f.getBoundingClientRect().left-p.getBoundingClientRect().width-y;c(h<=S)};m();const g=new ResizeObserver(m);return g.observe(u),g.observe(f),g.observe(p),()=>g.disconnect()},d=[t,e,s,r],o[0]=e,o[1]=r,o[2]=s,o[3]=t,o[4]=l,o[5]=d):(l=o[4],d=o[5]),a.useLayoutEffect(l,d),i}const sh="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground",nh="text-muted-foreground hover:text-foreground hover:bg-transparent";function ro(t){const e=Je.c(14),{label:s,pressed:r,onClick:o,className:i,children:c}=t,l=r?sh:nh;let d;e[0]!==i||e[1]!==l?(d=Te(i,l),e[0]=i,e[1]=l,e[2]=d):d=e[2];let u;e[3]!==c||e[4]!==s||e[5]!==o||e[6]!==r||e[7]!==d?(u=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:d,"aria-label":s,"aria-pressed":r,children:c})}),e[3]=c,e[4]=s,e[5]=o,e[6]=r,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==s?(f=n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:s})}),e[9]=s,e[10]=f):f=e[10];let p;return e[11]!==u||e[12]!==f?(p=n.jsxs(Ft,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13],p}function aC(t){const e=Je.c(263),{t:s}=Ct(),r=hf(),{hideDirectoryControls:o,showProjectDisplayControls:i,showSectionControls:c,handleOpenDirectoryDialog:l,showSourceBoard:d,headerActionIconClass:u,headerActionButtonClass:f,isSessionSearchOpen:p,openSessionSearch:m,closeSessionSearch:g,sessionSearchInputRef:b,sessionSearchQuery:v,setSessionSearchQuery:x,hasSessionSearchQuery:y,searchMatchCount:h,collapseAll:S,expandAll:w}=t,C=a.useRef(null),k=a.useRef(null),T=a.useRef(null),O=iC(C,k,T,r.length),K=us(NC),R=us(RC),I=de(DC),N=de(TC),W=de(IC),z=de(EC),H=Zt(PC),M=Zt(CC),Y=Zt(jC),j=Zt(kC),P=Zt(wC),D=Zt(vC),V=Zt(SC),B=Zt(xC),_=de(yC),F=Zt(bC),X=Zt(gC),oe=Zt(mC),ne=Zt(hC),A=Zt(pC),te=Zt(fC),U=Zt(uC),Pe=Zt(dC),xe=i&&A==="timeline",ce=i&&!xe&&U==="single";let Oe;e[0]===Symbol.for("react.memo_cache_sentinel")?(Oe=n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}),e[0]=Oe):Oe=e[0];const me=Oe;let ie;e[1]!==s?(ie=(ct,lt,dt,st)=>{const wt=lt.find(pt=>{const[E]=pt;return E===dt})?.[1];return n.jsxs(bf,{children:[n.jsxs(yf,{children:[n.jsx("span",{className:"flex-1",children:s(ct)}),wt?n.jsx("span",{className:"ms-4 text-muted-foreground",children:s(wt)}):null]}),n.jsx(xf,{className:"min-w-[160px]",children:lt.map(pt=>{const[E,Q]=pt;return n.jsxs(qt,{onClick:()=>st(E),className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Q)}),dt===E?me:null]},E)})})]})},e[1]=s,e[2]=ie):ie=e[2];const q=ie;let ue;e[3]!==s?(ue=(ct,lt,dt)=>n.jsxs(qt,{onClick:dt,className:"flex items-center justify-between",children:[n.jsx("span",{children:s(ct)}),lt?me:null]}),e[3]=s,e[4]=ue):ue=e[4];const ve=ue;let Ee;e[5]===Symbol.for("react.memo_cache_sentinel")?(Ee=n.jsx(Z,{name:"checkbox-multiple",className:"h-4 w-4"}),e[5]=Ee):Ee=e[5];let L;e[6]!==K||e[7]!==s?(L=s(K?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[6]=K,e[7]=s,e[8]=L):L=e[8];let le;e[9]!==L?(le=n.jsx("span",{children:L}),e[9]=L,e[10]=le):le=e[10];let G;e[11]!==le||e[12]!==R?(G=n.jsxs(qt,{onClick:R,className:"flex items-center gap-2",children:[Ee,le]},"select"),e[11]=le,e[12]=R,e[13]=G):G=e[13];let se;if(e[14]!==q||e[15]!==S||e[16]!==V||e[17]!==w||e[18]!==ce||e[19]!==U||e[20]!==F||e[21]!==_||e[22]!==B||e[23]!==Pe||e[24]!==X||e[25]!==M||e[26]!==D||e[27]!==j||e[28]!==te||e[29]!==ne||e[30]!==H||e[31]!==P||e[32]!==i||e[33]!==c||e[34]!==Y||e[35]!==A||e[36]!==s||e[37]!==G||e[38]!==xe||e[39]!==ve||e[40]!==oe){if(se=[G],i){let ct;e[42]!==s?(ct=s("sessions.sidebar.header.viewMode.label"),e[42]=s,e[43]=ct):ct=e[43];let lt;e[44]!==ct?(lt=n.jsx(Ji,{children:ct}),e[44]=ct,e[45]=lt):lt=e[45];let dt;e[46]!==te||e[47]!==A||e[48]!==s?(dt=[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(wt=>{const[pt,E]=wt;return n.jsxs(qt,{onClick:()=>{te(pt),nn({sidebarViewMode:pt})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(E)}),A===pt?me:null]},pt)}),e[46]=te,e[47]=A,e[48]=s,e[49]=dt):dt=e[49];let st;e[50]!==lt||e[51]!==dt?(st=n.jsxs(n.Fragment,{children:[lt,dt]}),e[50]=lt,e[51]=dt,e[52]=st):st=e[52],se.push(st)}if(!xe){let ct;if(e[53]!==q||e[54]!==F||e[55]!==X){let wt;e[57]!==X?(wt=pt=>{X(pt),nn({sidebarProjectSortOrder:pt})},e[57]=X,e[58]=wt):wt=e[58],ct=q("sessions.sidebar.header.actions.sortProjects",[["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"]],F,wt),e[53]=q,e[54]=F,e[55]=X,e[56]=ct}else ct=e[56];let lt;e[59]!==q||e[60]!==ne||e[61]!==i||e[62]!==oe?(lt=i?q("sessions.sidebar.header.actions.sortWorktrees",[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]],oe,wt=>{ne(wt),nn({sidebarWorktreeSortOrder:wt})}):null,e[59]=q,e[60]=ne,e[61]=i,e[62]=oe,e[63]=lt):lt=e[63];let dt;e[64]!==q||e[65]!==U||e[66]!==Pe||e[67]!==i?(dt=i?q("sessions.sidebar.header.projectDisplay.label",[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]],U,wt=>{Pe(wt),nn({sidebarProjectDisplayMode:wt})}):null,e[64]=q,e[65]=U,e[66]=Pe,e[67]=i,e[68]=dt):dt=e[68];let st;e[69]!==ct||e[70]!==lt||e[71]!==dt?(st=n.jsxs(n.Fragment,{children:[ct,lt,dt]}),e[69]=ct,e[70]=lt,e[71]=dt,e[72]=st):st=e[72],se.push(st)}if(c){let ct;e[73]!==M||e[74]!==H?(ct=()=>{M(!H),nn({sidebarShowChatsSection:!H})},e[73]=M,e[74]=H,e[75]=ct):ct=e[75];let lt;e[76]!==H||e[77]!==ct||e[78]!==ve?(lt=ve("sessions.sidebar.header.displayMode.showChats",H,ct),e[76]=H,e[77]=ct,e[78]=ve,e[79]=lt):lt=e[79];let dt;e[80]!==D||e[81]!==P?(dt=()=>{D(!P),nn({sidebarShowPinnedSection:!P})},e[80]=D,e[81]=P,e[82]=dt):dt=e[82];let st;e[83]!==P||e[84]!==dt||e[85]!==ve?(st=ve("sessions.sidebar.header.displayMode.showPinned",P,dt),e[83]=P,e[84]=dt,e[85]=ve,e[86]=st):st=e[86];let wt;e[87]!==_||e[88]!==j||e[89]!==Y||e[90]!==ve?(wt=_?ve("sessions.sidebar.header.displayMode.showWork",Y,()=>{j(!Y),nn({sidebarShowWorkSection:!Y})}):null,e[87]=_,e[88]=j,e[89]=Y,e[90]=ve,e[91]=wt):wt=e[91];let pt;e[92]!==V||e[93]!==B||e[94]!==xe||e[95]!==ve?(pt=xe?null:ve("sessions.sidebar.header.displayMode.detailedZoneRows",V,()=>{B(!V),nn({sidebarDetailedZoneRows:!V})}),e[92]=V,e[93]=B,e[94]=xe,e[95]=ve,e[96]=pt):pt=e[96];let E;e[97]!==st||e[98]!==wt||e[99]!==pt||e[100]!==lt?(E=n.jsxs(n.Fragment,{children:[lt,st,wt,pt]}),e[97]=st,e[98]=wt,e[99]=pt,e[100]=lt,e[101]=E):E=e[101],se.push(E)}if(!ce){let ct;e[102]===Symbol.for("react.memo_cache_sentinel")?(ct=n.jsx(Z,{name:"contract-up-down",className:"h-4 w-4"}),e[102]=ct):ct=e[102];let lt;e[103]!==s?(lt=s("sessions.sidebar.header.displayMode.collapseAll"),e[103]=s,e[104]=lt):lt=e[104];let dt;e[105]!==lt?(dt=n.jsx("span",{children:lt}),e[105]=lt,e[106]=dt):dt=e[106];let st;e[107]!==S||e[108]!==dt?(st=n.jsxs(qt,{onClick:S,className:"flex items-center gap-2",children:[ct,dt]}),e[107]=S,e[108]=dt,e[109]=st):st=e[109];let wt;e[110]===Symbol.for("react.memo_cache_sentinel")?(wt=n.jsx(Z,{name:"expand-up-down",className:"h-4 w-4"}),e[110]=wt):wt=e[110];let pt;e[111]!==s?(pt=s("sessions.sidebar.header.displayMode.expandAll"),e[111]=s,e[112]=pt):pt=e[112];let E;e[113]!==pt?(E=n.jsx("span",{children:pt}),e[113]=pt,e[114]=E):E=e[114];let Q;e[115]!==w||e[116]!==E?(Q=n.jsxs(qt,{onClick:w,className:"flex items-center gap-2",children:[wt,E]}),e[115]=w,e[116]=E,e[117]=Q):Q=e[117];let Ne;e[118]!==st||e[119]!==Q?(Ne=n.jsxs(n.Fragment,{children:[st,Q]}),e[118]=st,e[119]=Q,e[120]=Ne):Ne=e[120],se.push(Ne)}e[14]=q,e[15]=S,e[16]=V,e[17]=w,e[18]=ce,e[19]=U,e[20]=F,e[21]=_,e[22]=B,e[23]=Pe,e[24]=X,e[25]=M,e[26]=D,e[27]=j,e[28]=te,e[29]=ne,e[30]=H,e[31]=P,e[32]=i,e[33]=c,e[34]=Y,e[35]=A,e[36]=s,e[37]=G,e[38]=xe,e[39]=ve,e[40]=oe,e[41]=se}else se=e[41];if(o){let ct;e[121]!==s?(ct=s("sessions.sidebar.header.search.placeholder"),e[121]=s,e[122]=ct):ct=e[122];let lt;e[123]!==s?(lt=s("sessions.sidebar.header.search.clear"),e[123]=s,e[124]=lt):lt=e[124];let dt;e[125]!==y||e[126]!==h||e[127]!==s?(dt=y?h===1?s("sessions.sidebar.header.search.matchCountSingle",{count:h}):s("sessions.sidebar.header.search.matchCountPlural",{count:h}):void 0,e[125]=y,e[126]=h,e[127]=s,e[128]=dt):dt=e[128];let st;e[129]!==s?(st=s("sessions.sidebar.header.search.escapeHint"),e[129]=s,e[130]=st):st=e[130];let wt;return e[131]!==g||e[132]!==b||e[133]!==v||e[134]!==x||e[135]!==st||e[136]!==ct||e[137]!==lt||e[138]!==dt?(wt=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1.5",children:n.jsx(ec,{inputRef:b,value:v,onSearch:x,onClose:g,placeholder:ct,clearLabel:lt,leadingHint:dt,trailingHint:st})}),e[131]=g,e[132]=b,e[133]=v,e[134]=x,e[135]=st,e[136]=ct,e[137]=lt,e[138]=dt,e[139]=wt):wt=e[139],wt}let je;e[140]!==f||e[141]!==u||e[142]!==I||e[143]!==d||e[144]!==s?(je=d?n.jsx(ro,{label:s("sourceBoard.title"),pressed:I,onClick:()=>de.getState().setSourceBoardOpen(!I),className:f,children:n.jsx(Z,{name:"todo",className:u})}):null,e[140]=f,e[141]=u,e[142]=I,e[143]=d,e[144]=s,e[145]=je):je=e[145];let he;e[146]!==s?(he=s("sessions.sidebar.header.actions.scheduledTasks"),e[146]=s,e[147]=he):he=e[147];let ge;e[148]!==N?(ge=()=>de.getState().setScheduledTasksDialogOpen(!N),e[148]=N,e[149]=ge):ge=e[149];let ke;e[150]!==u?(ke=n.jsx(Z,{name:"calendar-schedule",className:u}),e[150]=u,e[151]=ke):ke=e[151];let Ae;e[152]!==f||e[153]!==N||e[154]!==ke||e[155]!==he||e[156]!==ge?(Ae=n.jsx(ro,{label:he,pressed:N,onClick:ge,className:f,children:ke}),e[152]=f,e[153]=N,e[154]=ke,e[155]=he,e[156]=ge,e[157]=Ae):Ae=e[157];let $;e[158]!==s?($=s("sessions.sidebar.nav.archive"),e[158]=s,e[159]=$):$=e[159];let fe;e[160]!==W?(fe=()=>de.getState().setArchivePageOpen(!W),e[160]=W,e[161]=fe):fe=e[161];let be;e[162]!==u?(be=n.jsx(Z,{name:"archive",className:u}),e[162]=u,e[163]=be):be=e[163];let Ie;e[164]!==f||e[165]!==W||e[166]!==$||e[167]!==fe||e[168]!==be?(Ie=n.jsx(ro,{label:$,pressed:W,onClick:fe,className:f,children:be}),e[164]=f,e[165]=W,e[166]=$,e[167]=fe,e[168]=be,e[169]=Ie):Ie=e[169];let Ye;e[170]!==Ae||e[171]!==Ie||e[172]!==je?(Ye=n.jsxs("div",{ref:k,className:"flex items-center gap-1.5",children:[je,Ae,Ie]}),e[170]=Ae,e[171]=Ie,e[172]=je,e[173]=Ye):Ye=e[173];let nt;e[174]!==r||e[175]!==O||e[176]!==f||e[177]!==u||e[178]!==z||e[179]!==s?(nt=O?r.map(ct=>{const lt=z===ct.id;return n.jsx(ro,{label:ct.pageTitle??ct.name,pressed:lt,onClick:()=>de.getState().setOpenGuestPage(lt?null:ct.id),className:f,children:n.jsx(dr,{icon:gf(ct.icon),iconSrc:mf(ct.id,ct.icon,uu().authenticatedAsset),className:u})},ct.id)}):r.length>0&&n.jsxs(Is,{children:[n.jsx(Ts,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":s("sessions.sidebar.header.actions.extensionPages"),children:n.jsx(Z,{name:"puzzle",className:u})})}),n.jsxs(Ds,{align:"start",children:[n.jsx(Ji,{children:s("sessions.sidebar.header.actions.extensionPages")}),r.map(cC)]})]}),e[174]=r,e[175]=O,e[176]=f,e[177]=u,e[178]=z,e[179]=s,e[180]=nt):nt=e[180];let Ue;e[181]!==Ye||e[182]!==nt?(Ue=n.jsxs("div",{className:"ms-[3px] flex min-w-0 items-center gap-1.5",children:[Ye,nt]}),e[181]=Ye,e[182]=nt,e[183]=Ue):Ue=e[183];const Ve=p?g:m,Se=p?sh:nh;let ye;e[184]!==f||e[185]!==Se?(ye=Te(f,Se),e[184]=f,e[185]=Se,e[186]=ye):ye=e[186];let Ge;e[187]!==s?(Ge=s("sessions.sidebar.header.actions.searchSessions"),e[187]=s,e[188]=Ge):Ge=e[188];let qe;e[189]!==u?(qe=n.jsx(Z,{name:"search",className:u}),e[189]=u,e[190]=qe):qe=e[190];let ft;e[191]!==p||e[192]!==Ve||e[193]!==ye||e[194]!==Ge||e[195]!==qe?(ft=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ve,className:ye,"aria-label":Ge,"aria-expanded":p,children:qe})}),e[191]=p,e[192]=Ve,e[193]=ye,e[194]=Ge,e[195]=qe,e[196]=ft):ft=e[196];let et;e[197]!==s?(et=s("sessions.sidebar.header.actions.searchSessions"),e[197]=s,e[198]=et):et=e[198];let St;e[199]!==et?(St=n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:et})}),e[199]=et,e[200]=St):St=e[200];let we;e[201]!==ft||e[202]!==St?(we=n.jsxs(Ft,{children:[ft,St]}),e[201]=ft,e[202]=St,e[203]=we):we=e[203];let De;e[204]!==f?(De=Te(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[204]=f,e[205]=De):De=e[205];let ot;e[206]!==s?(ot=s("sessions.sidebar.header.actions.addProject"),e[206]=s,e[207]=ot):ot=e[207];let rt;e[208]!==u?(rt=n.jsx(Z,{name:"folder-add",className:u}),e[208]=u,e[209]=rt):rt=e[209];let Xe;e[210]!==l||e[211]!==De||e[212]!==ot||e[213]!==rt?(Xe=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:l,className:De,"aria-label":ot,children:rt})}),e[210]=l,e[211]=De,e[212]=ot,e[213]=rt,e[214]=Xe):Xe=e[214];let ht;e[215]!==s?(ht=s("sessions.sidebar.header.actions.addProject"),e[215]=s,e[216]=ht):ht=e[216];let ee;e[217]!==ht?(ee=n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:ht})}),e[217]=ht,e[218]=ee):ee=e[218];let _e;e[219]!==Xe||e[220]!==ee?(_e=n.jsxs(Ft,{children:[Xe,ee]}),e[219]=Xe,e[220]=ee,e[221]=_e):_e=e[221];let Be;e[222]!==f?(Be=Te(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[222]=f,e[223]=Be):Be=e[223];let Ke;e[224]!==s?(Ke=s("sessions.sidebar.header.displayMode.label"),e[224]=s,e[225]=Ke):Ke=e[225];let Fe;e[226]!==u?(Fe=n.jsx(Z,{name:"equalizer-2",className:u}),e[226]=u,e[227]=Fe):Fe=e[227];let tt;e[228]!==Be||e[229]!==Ke||e[230]!==Fe?(tt=n.jsx(Bt,{asChild:!0,children:n.jsx(Ts,{asChild:!0,children:n.jsx("button",{type:"button",className:Be,"aria-label":Ke,children:Fe})})}),e[228]=Be,e[229]=Ke,e[230]=Fe,e[231]=tt):tt=e[231];let bt;e[232]!==s?(bt=s("sessions.sidebar.header.displayMode.label"),e[232]=s,e[233]=bt):bt=e[233];let mt;e[234]!==bt?(mt=n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:bt})}),e[234]=bt,e[235]=mt):mt=e[235];let it;e[236]!==tt||e[237]!==mt?(it=n.jsxs(Ft,{children:[tt,mt]}),e[236]=tt,e[237]=mt,e[238]=it):it=e[238];let Tt;e[239]!==se?(Tt=n.jsx(Ds,{align:"end",className:"min-w-[200px]",children:se.map(lC)}),e[239]=se,e[240]=Tt):Tt=e[240];let at;e[241]!==it||e[242]!==Tt?(at=n.jsxs(Is,{children:[it,Tt]}),e[241]=it,e[242]=Tt,e[243]=at):at=e[243];let $t;e[244]!==we||e[245]!==_e||e[246]!==at?($t=n.jsxs("div",{ref:T,className:"flex min-w-0 items-center gap-1.5",children:[we,_e,at]}),e[244]=we,e[245]=_e,e[246]=at,e[247]=$t):$t=e[247];let zt;e[248]!==Ue||e[249]!==$t?(zt=n.jsxs("div",{ref:C,className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[Ue,$t]}),e[248]=Ue,e[249]=$t,e[250]=zt):zt=e[250];let Mt;e[251]!==g||e[252]!==y||e[253]!==p||e[254]!==h||e[255]!==b||e[256]!==v||e[257]!==x||e[258]!==s?(Mt=p?n.jsx("div",{className:"pb-1",children:n.jsx(ec,{inputRef:b,value:v,onSearch:x,onClose:g,placeholder:s("sessions.sidebar.header.search.placeholder"),clearLabel:s("sessions.sidebar.header.search.clear"),leadingHint:y?h===1?s("sessions.sidebar.header.search.matchCountSingle",{count:h}):s("sessions.sidebar.header.search.matchCountPlural",{count:h}):void 0,trailingHint:s("sessions.sidebar.header.search.escapeHint")})}):null,e[251]=g,e[252]=y,e[253]=p,e[254]=h,e[255]=b,e[256]=v,e[257]=x,e[258]=s,e[259]=Mt):Mt=e[259];let Re;return e[260]!==zt||e[261]!==Mt?(Re=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:n.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[zt,Mt]})}),e[260]=zt,e[261]=Mt,e[262]=Re):Re=e[262],Re}function lC(t,e){return n.jsxs(a.Fragment,{children:[e>0?n.jsx(wn,{}):null,t]},e)}function cC(t){return n.jsxs(qt,{onSelect:()=>de.getState().setOpenGuestPage(t.id),children:[n.jsx(dr,{icon:gf(t.icon),iconSrc:mf(t.id,t.icon,uu().authenticatedAsset),className:"size-4"}),n.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function dC(t){return t.setProjectDisplayMode}function uC(t){return t.projectDisplayMode}function fC(t){return t.setSidebarViewMode}function pC(t){return t.sidebarViewMode}function hC(t){return t.setWorktreeSortOrder}function mC(t){return t.worktreeSortOrder}function gC(t){return t.setProjectSortOrder}function bC(t){return t.projectSortOrder}function yC(t){return t.sessionWorkEnabled}function xC(t){return t.setDetailedZoneRows}function SC(t){return t.detailedZoneRows}function vC(t){return t.setShowPinnedSection}function wC(t){return t.showPinnedSection}function kC(t){return t.setShowWorkSection}function jC(t){return t.showWorkSection}function CC(t){return t.setShowChatsSection}function PC(t){return t.showChatsSection}function EC(t){return t.openGuestPageId}function IC(t){return t.isArchivePageOpen}function TC(t){return t.isScheduledTasksDialogOpen}function DC(t){return t.isSourceBoardOpen}function RC(t){return t.toggleMode}function NC(t){return t.enabled}function MC(t){const e=Je.c(2),{className:s}=t,[r]=a.useState(AC);if(!r)return null;let o;return e[0]!==s?(o=n.jsx(OC,{className:s}),e[0]=s,e[1]=o):o=e[1],o}function AC(){return cn()}function OC({className:t}){const{t:e}=Ct(),s=de(k=>k.shortcutOverrides),[r,o]=a.useState(!1),[i,c]=a.useState("Local"),[l,d]=a.useState(!0),[u,f]=a.useState(!1),[p,m]=a.useState(null),[g,b]=a.useState(!1),[v,x]=a.useState(null),y=a.useCallback(async()=>{try{if(Xo()){c("Local"),d(!0);return}d(!1);const k=await Zo(),T=zm(Km(k.hosts,k.localOrigin));if(T.id===Wm){c("Local"),d(!0);return}c(fu(T.label.trim()||"Instance"))}catch{c("Local"),d(!0)}},[]);a.useEffect(()=>(y(),Uo(()=>{y()})),[y]);const h=a.useCallback(async()=>{if(l){m(null),x(null);return}b(!0),x(null);try{const k=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),T=await Us(`/api/openchamber/update-check?${k.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!T.ok)throw new Error(`Server responded with ${T.status}`);m(Yg(await T.json()))}catch(k){m(null),x(k instanceof Error?k.message:e("header.services.remoteUpdate.error"))}finally{b(!1)}},[l,e]);a.useEffect(()=>{m(null),x(null),f(!1)},[l,i]),a.useEffect(()=>{if(l)return;const k=3e3,T=3600*1e3;let O=!1,K=null;const R=I=>{K=window.setTimeout(()=>{if(O||typeof document<"u"&&document.visibilityState!=="visible"){R(T);return}h().finally(()=>{O||R(T)})},I)};return R(k),()=>{O=!0,K!==null&&window.clearTimeout(K)}},[h,l,i]);const S=a.useCallback(()=>{if(p?.available){f(!0);return}h()},[h,p?.available]),w=a.useCallback(k=>{o(k),k&&y()},[y]);Gu({toggle_services_menu:()=>{if(r){o(!1);return}const k=de.getState();k.isSidebarOpen||k.setSidebarOpen(!0),w(!0)}});const C=Yu(Xu("toggle_services_menu",s));return n.jsxs(n.Fragment,{children:[n.jsxs(Is,{open:r,onOpenChange:w,children:[n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx(Ts,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":e("header.services.openWithCurrent",{current:i}),className:t,children:[n.jsx(Z,{name:"server",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate typography-ui-label",children:i})]})})}),n.jsx(Ot,{side:"top",sideOffset:4,children:n.jsx("p",{children:e("header.services.tooltip.currentInstance",{current:i,toggle:C})})})]}),n.jsxs(Ds,{side:"top",align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:[l?null:n.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:e("header.services.remoteUpdate.title")}),n.jsx("div",{className:"typography-micro text-muted-foreground",children:p?.available?e("header.services.remoteUpdate.available",{version:p.version||""}):g?e("header.services.remoteUpdate.checking"):v||e("header.services.remoteUpdate.upToDate")})]}),p?.available?n.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:S,children:e("header.services.remoteUpdate.actions.open")}):null]})}),n.jsx(px,{embedded:!0,open:r,onOpenChange:()=>{},onHostSwitched:()=>o(!1)})]})]}),n.jsx(za,{open:u,onOpenChange:f,info:p,downloading:!1,downloaded:!1,progress:null,error:v,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const gr="inline-flex h-6 w-6 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-ring",BC="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground";function FC(t){const e=Je.c(28),{onOpenSettings:s,onOpenShortcuts:r,onOpenAbout:o,onOpenUpdate:i,showRuntimeButtons:c,showUpdateButton:l}=t,d=c===void 0?!0:c,u=l===void 0?!0:l,{t:f}=Ct(),p=Xg(),m=de(LC);if(!d&&!u)return null;let g;e[0]!==p||e[1]!==f?(g=f(p?"sessions.sidebar.footer.actions.updateApp":"sessions.sidebar.footer.actions.update"),e[0]=p,e[1]=f,e[2]=g):g=e[2];const b=g;let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=Te(gr,"text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]"),e[3]=v):v=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Z,{name:"download",className:"h-4 w-4"}),e[4]=x):x=e[4];let y;e[5]!==i||e[6]!==b?(y=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,className:v,"aria-label":b,children:x})}),e[5]=i,e[6]=b,e[7]=y):y=e[7];let h;e[8]!==b?(h=n.jsx(Ot,{side:"top",sideOffset:4,children:n.jsx("p",{children:b})}),e[8]=b,e[9]=h):h=e[9];let S;e[10]!==y||e[11]!==h?(S=n.jsxs(Ft,{children:[y,h]}),e[10]=y,e[11]=h,e[12]=S):S=e[12];const w=S;let C;e[13]!==m||e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==d||e[18]!==u||e[19]!==f||e[20]!==w?(C=d?n.jsxs(n.Fragment,{children:[n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:s,className:gr,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:n.jsx(Z,{name:"settings-3",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>de.getState().setUsageStatsPageOpen(!m),className:Te(gr,m&&BC),"aria-label":f("usageStats.openAction"),"aria-pressed":m,children:n.jsx(Z,{name:"bar-chart",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("usageStats.openAction")})})]}),n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,className:gr,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:n.jsx(Z,{name:"command",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),u?w:n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:gr,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:n.jsx(Z,{name:"information",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[13]=m,e[14]=o,e[15]=s,e[16]=r,e[17]=d,e[18]=u,e[19]=f,e[20]=w,e[21]=C):C=e[21];const k=!d&&u?w:null;let T;e[22]!==d?(T=d?n.jsx(MC,{className:"ms-auto inline-flex h-6 min-w-0 max-w-[12rem] items-center gap-1.5 rounded-md px-2 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}):null,e[22]=d,e[23]=T):T=e[23];let O;return e[24]!==k||e[25]!==T||e[26]!==C?(O=n.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[C,k,T]}),e[24]=k,e[25]=T,e[26]=C,e[27]=O):O=e[27],O}function LC(t){return t.isUsageStatsPageOpen}function _C(t){const e=Je.c(19),{query:s,showArchive:r,resetSessionSearch:o}=t,{t:i}=Ct();let c;e[0]!==s||e[1]!==o?(c=()=>{de.getState().setArchivePageOpen(!0,s),o()},e[0]=s,e[1]=o,e[2]=c):c=e[2];const l=c;let d;e[3]!==i?(d=i("sessions.sidebar.empty.noMatches.title"),e[3]=i,e[4]=d):d=e[4];let u;e[5]!==d?(u=n.jsx("p",{className:"typography-ui-label font-semibold",children:d}),e[5]=d,e[6]=u):u=e[6];let f;e[7]!==i?(f=i("sessions.sidebar.empty.noMatches.description"),e[7]=i,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx("p",{className:"typography-meta mt-1",children:f}),e[9]=f,e[10]=p):p=e[10];let m;e[11]!==l||e[12]!==r||e[13]!==i?(m=r?n.jsx(It,{variant:"link",size:"xs",className:"mt-2 h-auto p-0 typography-meta",onClick:l,children:i("sessions.sidebar.empty.noMatches.searchArchive")}):null,e[11]=l,e[12]=r,e[13]=i,e[14]=m):m=e[14];let g;return e[15]!==u||e[16]!==p||e[17]!==m?(g=n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[u,p,m]}),e[15]=u,e[16]=p,e[17]=m,e[18]=g):g=e[18],g}const $C=t=>{for(const e of t.sessions.values())if(e.tabs.some(pu))return!0;return!1},zC=()=>{const t=Je.c(4),{terminal:e}=_s(),s=At($C);let r,o;return t[0]!==s||t[1]!==e?(r=()=>{const i=KC,c=WC;if(s)return Xi(e,"",c,i);let l=HC;return l=Xi(e,"",c,d=>{i(d),l()}),()=>l()},o=[e,s],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),a.useEffect(r,o),null};function KC(t){const e=At.getState(),s=Zg(t.sessions),r=new Set([...e.sessions.keys(),...s.keys()]);for(const o of r)e.reconcileServerSessions(o,s.get(o)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function WC(){return new Map(At.getState().actionMutationRevisions)}function HC(){}const VC=50,UC=t=>{const e=new Map;for(const s of t){const r=vt(s.directory),o=s.branch.trim();if(!(!r||!o||e.has(r))&&(e.set(r,{directory:r,branch:o}),e.size===VC))break}return[...e.values()]},GC=t=>{const e=Je.c(12),{normalizedProjects:s,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:c,isWorktreeTopologyLoading:l,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:f,addSessionToFolder:p}=t,m=r===void 0?!0:r;let g,b;e[0]!==p||e[1]!==f||e[2]!==m||e[3]!==u||e[4]!==c||e[5]!==i||e[6]!==l||e[7]!==s||e[8]!==o||e[9]!==d?(g=()=>{!m||i||!c||l||s.forEach(v=>{if(d.has(v.normalizedPath))return;const x=Sf(v.normalizedPath),y=o.archivedSessionsByProject.get(v.id)??[],h=u[x]??[],S=new Map(h.map(qC));y.forEach(w=>{const C=hx(w,v.normalizedPath),k=C.toLowerCase();let T=S.get(k);T||(T=f(x,C),S.set(k,T)),T.sessionIds.includes(w.id)||p(x,T.id,w.id)})})},b=[s,m,o,i,c,l,d,u,f,p],e[0]=p,e[1]=f,e[2]=m,e[3]=u,e[4]=c,e[5]=i,e[6]=l,e[7]=s,e[8]=o,e[9]=d,e[10]=g,e[11]=b):(g=e[10],b=e[11]),a.useEffect(g,b)};function qC(t){return[t.name.toLowerCase(),t]}function YC({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:s,projectMap:r,metaByProject:o,rememberedSessionId:i,fallbackSessionId:c}){if(e&&s===t)return{kind:"preserve-current"};if(s==null){const u=!!(e&&Array.from(o.entries()).some(([f,p])=>f!==t&&p.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(i&&r.has(i)?i:null)??c;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const XC=t=>{const e=Je.c(26),{projectSections:s,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:c,currentSessionOwnerProjectId:l,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:p,setSessionSwitcherOpen:m}=t;let g,b;if(e[0]!==s){b=new Map,g=new Map;const k=(T,O,K,R)=>{b.has(T)||b.set(T,new Map);const I=b.get(T);R.forEach(N=>{const W=vt(N.worktree?.path??N.session.directory??K??O);I.set(N.session.id,{directory:W}),g.has(T)||g.set(T,{id:N.session.id,directory:W}),N.children.length>0&&k(T,O,W,N.children)})};s.forEach(T=>{T.groups.forEach(O=>{k(T.project.id,T.project.normalizedPath,O.directory,O.sessions)})}),e[0]=s,e[1]=g,e[2]=b}else g=e[1],b=e[2];let v;e[3]!==g||e[4]!==b?(v={metaByProject:b,firstSessionByProject:g},e[3]=g,e[4]=b,e[5]=v):v=e[5];const x=v,y=a.useRef(null);let h,S;e[6]!==r||e[7]!==o||e[8]!==c||e[9]!==l||e[10]!==d||e[11]!==f||e[12]!==u||e[13]!==p||e[14]!==s||e[15]!==x||e[16]!==i||e[17]!==m?(h=()=>{if(!r||u||de.getState().isNewWorktreeDialogOpen||y.current===r)return;const k=s.find(R=>R.project.id===r);if(!k)return;if(y.current===null){y.current=r;return}const T=x.metaByProject.get(r);if(c&&T&&T.has(c)){y.current=r,i(R=>{if(R.get(r)===c)return R;const I=new Map(R);return I.set(r,c),I});return}const O=YC({activeProjectId:r,currentSessionId:c,currentSessionOwnerProjectId:l,projectMap:T,metaByProject:x.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(O.kind==="preserve-current"){l===r&&(y.current=r);return}if(y.current=r,O.kind==="open-draft"){f&&m(!1),p({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(O.kind!=="select-session")return;const K=T?.get(O.sessionId)?.directory??null;d(O.sessionId,K)},S=[r,o,c,l,d,u,f,p,s,x,m,i],e[6]=r,e[7]=o,e[8]=c,e[9]=l,e[10]=d,e[11]=f,e[12]=u,e[13]=p,e[14]=s,e[15]=x,e[16]=i,e[17]=m,e[18]=h,e[19]=S):(h=e[18],S=e[19]),a.useLayoutEffect(h,S);let w,C;e[20]!==r||e[21]!==c||e[22]!==x||e[23]!==i?(w=()=>{if(!r||!c)return;const k=x.metaByProject.get(r);!k||!k.has(c)||i(T=>{if(T.get(r)===c)return T;const O=new Map(T);return O.set(r,c),O})},C=[r,c,x,i],e[20]=r,e[21]=c,e[22]=x,e[23]=i,e[24]=w,e[25]=C):(w=e[24],C=e[25]),a.useEffect(w,C)},ZC=t=>{const e=Je.c(20);let s,r,o,i;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:o,sessionOwnerBySessionId:i,...s}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i):(s=e[1],r=e[2],o=e[3],i=e[4]);const c=xt(QC),l=xt(JC);let d;e[5]!==c||e[6]!==i?(d=c?i?.get(c)?.projectId??null:null,e[5]=c,e[6]=i,e[7]=d):d=e[7];const u=d;let f;e[8]!==r?(f=()=>new Map(r),e[8]=r,e[9]=f):f=e[9];const[p,m]=a.useState(f);let g;e[10]!==p||e[11]!==s||e[12]!==c||e[13]!==u||e[14]!==l?(g={...s,activeSessionByProject:p,setActiveSessionByProject:m,currentSessionId:c,currentSessionOwnerProjectId:u,newSessionDraftOpen:l},e[10]=p,e[11]=s,e[12]=c,e[13]=u,e[14]=l,e[15]=g):g=e[15],XC(g);let b,v;return e[16]!==p||e[17]!==o?(b=()=>{o(p)},v=[p,o],e[16]=p,e[17]=o,e[18]=b,e[19]=v):(b=e[18],v=e[19]),a.useEffect(b,v),null};function QC(t){return t.currentSessionId}function JC(t){return!!t.newSessionDraft?.open}const e3=t=>{const e=Je.c(7),{ownership:s}=t;let r;e[0]!==s?(r=d=>s.sessionsByProject.get(d)??[],e[0]=s,e[1]=r):r=e[1];const o=r;let i;e[2]!==s?(i=d=>s.archivedSessionsByProject.get(d)??[],e[2]=s,e[3]=i):i=e[3];const c=i;let l;return e[4]!==c||e[5]!==o?(l={getSessionsForProject:o,getArchivedSessionsForProject:c},e[4]=c,e[5]=o,e[6]=l):l=e[6],l},t3=(t,e)=>t.map(s=>{const r=vt(s.path)??s.path;return`${r}=${e.get(r)??""}`}).join(`
1045
- `),s3=(t,e,s)=>e.length===0?"":t.map(r=>s.get(r.id)??"").join(","),n3=[],r3=new WeakMap,o3=t=>{const{normalizedProjects:e,getSessionsForProject:s,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:c,gitBranches:l,sessionOrderRanks:d,lastRepoStatus:u,buildGroupedSessions:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,filterSessionNodesForSearch:g,buildGroupSearchText:b,foldersMap:v,standaloneGroups:x}=t,y=a.useRef(new Map),h=a.useMemo(()=>{const R=y.current,I=new Map;let N=0,W=0;const z=(M,Y)=>M.length===Y.length&&M.every((j,P)=>j===Y[P]),H=e.map(M=>{const Y=s(M.id),j=r(M.id),P=o.get(M.normalizedPath)??n3,D=i.has(M.id)?!!i.get(M.id):u,V=c.get(M.id)??null,B=t3(P,l),_=s3(Y,P,d),F=R.get(M.id);if(F&&F.project===M&&z(F.activeSessions,Y)&&z(F.archivedSessions,j)&&F.availableWorktrees===P&&F.rootBranch===V&&F.worktreeBranchesKey===B&&F.worktreeRanksKey===_&&F.isRepo===D&&F.buildGroupedSessions===f)return N+=1,I.set(M.id,F),F.section;if(W+=1,F){const A=F.project!==M?"project":z(F.activeSessions,Y)?z(F.archivedSessions,j)?F.availableWorktrees!==P?"worktrees":F.rootBranch!==V?"branch":F.worktreeBranchesKey!==B?"worktreeBranches":F.worktreeRanksKey!==_?"worktreeRanks":F.isRepo!==D?"repo":"builder":"archived":"sessions";js(`ui.sidebar.project_section.rebuilt_reason.${A}`)}const X=vf([...Y,...j]),oe=f(X,M.normalizedPath,P,V,D),ne={project:M,groups:oe};return I.set(M.id,{project:M,activeSessions:Y,archivedSessions:j,availableWorktrees:P,rootBranch:V,worktreeBranchesKey:B,worktreeRanksKey:_,isRepo:D,buildGroupedSessions:f,section:ne}),ne});return y.current=I,N>0&&js("ui.sidebar.project_section.reused",N),W>0&&js("ui.sidebar.project_section.rebuilt",W),H},[e,s,r,o,i,u,f,c,l,d]),S=a.useMemo(()=>h,[h]),w=a.useMemo(()=>{if(!p)return r3;const R=new WeakMap,N=m.trim().toLowerCase().startsWith("ses_"),W=z=>{const H=g(z.sessions,m),M=eh(H,m),Y=!N&&To([b(z)],m),j=ir(z).flatMap(({scopeKey:D})=>v[D]??[]),P=N?0:j.filter(D=>To([D.name],m)).length;R.set(z,{filteredNodes:H,matchedSessionCount:M,folderNameMatchCount:P,groupMatches:Y,hasMatch:Y||M>0||P>0})};return S.forEach(z=>{z.groups.forEach(W)}),x.forEach(W),R},[p,S,x,g,m,b,v]),C=a.useMemo(()=>p?S.map(R=>({...R,groups:R.groups.filter(I=>w.get(I)?.hasMatch===!0)})).filter(R=>R.groups.length>0):S,[p,S,w]),k=p?C:S,T=a.useRef(new WeakMap),O=a.useMemo(()=>{const R=T.current;return k.map(I=>{const N=R.get(I);if(N&&N.query===m)return N.section;const W=I.groups.filter(D=>!D.isArchivedBucket),z=I.groups.filter(D=>D.isArchivedBucket),H=W.flatMap(D=>p?w.get(D)?.filteredNodes??[]:D.sessions),M=W.map(D=>({scopeKey:D.folderScopeKey??vt(D.directory??null),directory:D.directory??null})).filter(D=>!!D.scopeKey),Y=W.find(D=>D.isMain)??null,j={id:"flat",label:Y?.label??"",branch:Y?.branch??null,description:Y?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:Y?.directory??I.project.normalizedPath,folderScopeKey:Y?.folderScopeKey??I.project.normalizedPath,folderScopes:M,sessions:H};if(p){const D=W.map(V=>w.get(V)).filter(V=>!!V);w.set(j,{filteredNodes:H,matchedSessionCount:D.reduce((V,B)=>V+B.matchedSessionCount,0),folderNameMatchCount:D.reduce((V,B)=>V+B.folderNameMatchCount,0),groupMatches:D.some(V=>V.groupMatches),hasMatch:D.some(V=>V.hasMatch)})}const P={project:I.project,groups:[j,...z]};return R.set(I,{query:m,section:P}),P})},[w,p,m,k]),K=a.useMemo(()=>{if(!p)return 0;const R=(N,W)=>{const z=w.get(W);if(!z)return N;const H=z.folderNameMatchCount+(z.groupMatches?1:0);return N+z.matchedSessionCount+H},I=k.reduce((N,W)=>W.groups.reduce(R,N),0);return x.reduce(R,I)},[p,k,x,w]);return{projectSections:h,visibleProjectSections:S,groupSearchDataByGroup:w,searchableProjectSections:C,sectionsForRender:k,flatSectionsForRender:O,searchMatchCount:K}},i3=180,kd=150,a3=2,l3=8,jd=[-1,1],oo=t=>`${t.directory}
1046
- ${t.sessionId}`,Cd=t=>t?.directory?.trim()||null,rh=a.createContext(null),c3=()=>a.useContext(rh),d3=({enabled:t=!0,currentSessionId:e,sortedSessions:s,workSessions:r=[],prefetchSession:o})=>{const i=a.useRef(new Map),c=a.useRef(new Set),l=a.useRef([]),d=a.useRef(new Set),u=a.useRef(0),f=a.useMemo(()=>Pn(),[]),p=a.useCallback(()=>{u.current+=1,l.current=[],i.current.forEach(y=>window.clearTimeout(y)),i.current.clear(),c.current.clear()},[]),m=a.useCallback(()=>{if(!(!t||f))for(;d.current.size<a3&&l.current.length>0;){const y=l.current.shift();if(!y)break;if(y.generation!==u.current||xt.getState().currentSessionId===y.sessionId||na(y.sessionId,y.directory).renderable)continue;const S=oo(y);d.current.add(S),o({directory:y.directory,sessionID:y.sessionId}).catch(()=>{}).finally(()=>{d.current.delete(S),m()})}},[t,f,o]),g=a.useCallback((y,h="neighbor")=>{const S=y?.id,w=Cd(y);if(!t||f||!S||!w||S===e)return;const C={sessionId:S,directory:w,generation:u.current},k=oo(C);if(na(S,w).renderable||d.current.has(k)||l.current.some(K=>oo(K)===k))return;const T=i.current.get(k);if(T!==void 0){if(h==="hover"&&!c.current.has(k))return;window.clearTimeout(T)}h==="hover"?c.current.add(k):c.current.delete(k);const O=window.setTimeout(()=>{if(i.current.delete(k),c.current.delete(k),C.generation!==u.current)return;const K=l.current;K.length>=l3&&K.shift(),K.push(C),m()},i3);i.current.set(k,O)},[e,t,f,m]),b=a.useCallback(y=>{const h=Cd(y);if(!h)return;const S=oo({sessionId:y.id,directory:h}),w=i.current.get(S);w===void 0||!c.current.has(S)||(window.clearTimeout(w),i.current.delete(S),c.current.delete(S))},[]),v=a.useRef(g);v.current=g;const[x]=a.useState(()=>({schedule:y=>v.current(y,"hover"),cancel:b}));return a.useEffect(()=>{p()},[p,e,t,f]),a.useEffect(()=>{if(!t||f||!e||s.length===0)return;const y=window.setTimeout(()=>{const h=s.findIndex(S=>S.id===e);if(!(h<0))for(const S of jd)g(s[h+S])},kd);return()=>window.clearTimeout(y)},[e,t,f,g,s]),a.useEffect(()=>{if(!t||f||!e||r.length===0)return;const y=window.setTimeout(()=>{const h=r.findIndex(S=>S.id===e);if(!(h<0))for(const S of jd)g(r[h+S])},kd);return()=>window.clearTimeout(y)},[e,t,f,r,g]),a.useEffect(()=>p,[p]),x},u3=t=>{const e=Je.c(11);let s,r;e[0]!==t?({children:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=xt(f3);let i;e[3]!==s||e[4]!==o?(i={...s,currentSessionId:o},e[3]=s,e[4]=o,e[5]=i):i=e[5];const c=d3(i);let l;if(e[6]!==r||e[7]!==c){let d;e[9]!==c?(d={value:c},e[9]=c,e[10]=d):d=e[10],l=a.createElement(rh.Provider,d,r),e[6]=r,e[7]=c,e[8]=l}else l=e[8];return l};function f3(t){return t.currentSessionId}const p3=6,lr=t=>$a(t,p3),Pd=t=>`calc(${lr(t)} + 20px)`,h3=t=>{const e=Je.c(92),{folder:s,displayName:r,sessions:o,subFolderItems:i,isCollapsed:c,collapsedActivityState:l,onToggle:d,onRename:u,onDelete:f,children:p,renderBody:m,mobileVariant:g,alwaysShowActions:b,isRenaming:v,renameDraft:x,onRenameDraftChange:y,onRenameSave:h,onRenameCancel:S,droppableRef:w,isDropTarget:C,onNewSession:k,depth:T,canExpand:O,hideActions:K,archivedBucket:R}=t,I=l===void 0?null:l,N=m===void 0?!0:m,z=b===void 0?g===void 0?!1:g:b,H=v===void 0?!1:v,M=x===void 0?"":x,Y=C===void 0?!1:C,j=T===void 0?0:T,P=O===void 0?!0:O,D=K===void 0?!1:K,V=R===void 0?!1:R,{t:B}=Ct(),[_,F]=a.useState(!1),[X,oe]=a.useState(""),ne=a.useRef(null),A=H||_,te=H?M:X;let U;e[0]!==s.name?(U=()=>{oe(s.name),F(!0)},e[0]=s.name,e[1]=U):U=e[1];const Pe=U;let xe;e[2]!==te||e[3]!==s.name||e[4]!==H||e[5]!==u||e[6]!==h?(xe=()=>{const et=te.trim();et&&et!==s.name&&u(et),H&&h&&h(),F(!1),oe("")},e[2]=te,e[3]=s.name,e[4]=H,e[5]=u,e[6]=h,e[7]=xe):xe=e[7];const ce=xe;let Oe;e[8]!==H||e[9]!==S?(Oe=()=>{H&&S&&S(),F(!1),oe("")},e[8]=H,e[9]=S,e[10]=Oe):Oe=e[10];const me=Oe;let ie;e[11]!==H||e[12]!==y?(ie=et=>{H&&y?y(et):oe(et)},e[11]=H,e[12]=y,e[13]=ie):ie=e[13];const q=ie;let ue,ve;e[14]!==H?(ue=()=>{if(!H)return;const et=()=>{const De=ne.current;De&&(De.focus(),De.select())},St=requestAnimationFrame(et),we=window.setTimeout(et,0);return()=>{cancelAnimationFrame(St),window.clearTimeout(we)}},ve=[H],e[14]=H,e[15]=ue,e[16]=ve):(ue=e[15],ve=e[16]),a.useEffect(ue,ve);const Ee=c?"folder":"folder-open",L=!A&&P;let le;e[17]!==j?(le=lr(j),e[17]=j,e[18]=le):le=e[18];let G;e[19]!==le?(G={paddingInlineStart:le},e[19]=le,e[20]=G):G=e[20];const se=Y?"bg-primary/10 ring-1 ring-inset ring-primary/30":"hover:bg-interactive-hover/60";let je;e[21]!==se?(je=Te("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",se),e[21]=se,e[22]=je):je=e[22];let he;e[23]!==d||e[24]!==L?(he=L?et=>{et.currentTarget.blur(),d()}:void 0,e[23]=d,e[24]=L,e[25]=he):he=e[25];const ge=L?"button":void 0,ke=L?0:void 0;let Ae;e[26]!==d||e[27]!==L?(Ae=L?et=>{(et.key==="Enter"||et.key===" ")&&(et.preventDefault(),d())}:void 0,e[26]=d,e[27]=L,e[28]=Ae):Ae=e[28];let $;e[29]!==s.name||e[30]!==c||e[31]!==B||e[32]!==L?($=L?c?B("sessions.sidebar.folderItem.expandAria",{folderName:s.name}):B("sessions.sidebar.folderItem.collapseAria",{folderName:s.name}):void 0,e[29]=s.name,e[30]=c,e[31]=B,e[32]=L,e[33]=$):$=e[33];const fe=V?z?"pe-7":"group-hover/folder:pe-7 group-focus-within/folder:pe-7":z?"pe-20":"group-hover/folder:pe-20 group-focus-within/folder:pe-20";let be;e[34]!==fe?(be=Te("min-w-0 flex items-center gap-0.5 flex-1",fe),e[34]=fe,e[35]=be):be=e[35];let Ie;e[36]!==P||e[37]!==c?(Ie=P?n.jsx(Ar,{expanded:!c}):n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}),e[36]=P,e[37]=c,e[38]=Ie):Ie=e[38];const Ye=Y?"text-primary":"text-muted-foreground";let nt;e[39]!==Ye?(nt=Te("mx-px h-3 w-3 flex-shrink-0",Ye),e[39]=Ye,e[40]=nt):nt=e[40];let Ue;e[41]!==Ee||e[42]!==nt?(Ue=n.jsx(Z,{name:Ee,className:nt}),e[41]=Ee,e[42]=nt,e[43]=Ue):Ue=e[43];let Ve;e[44]!==I||e[45]!==r||e[46]!==te||e[47]!==s.name||e[48]!==me||e[49]!==q||e[50]!==ce||e[51]!==Y||e[52]!==A||e[53]!==o||e[54]!==B?(Ve=A?n.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:m3,onMouseDown:g3,onSubmit:et=>{et.preventDefault(),ce()},children:[n.jsx("input",{ref:ne,value:te,onChange:et=>q(et.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:B("sessions.sidebar.folderItem.namePlaceholder"),onClick:b3,onPointerDown:y3,onMouseDown:x3,onKeyDown:et=>{if(et.key==="Escape"){et.stopPropagation(),me();return}(et.key===" "||et.key==="Enter")&&et.stopPropagation()}}),n.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:S3,onPointerDown:v3,onMouseDown:w3,children:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),me()},onPointerDown:k3,onMouseDown:j3,className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]}):n.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("span",{className:Te("typography-ui-label font-medium truncate",Y?"text-primary":"text-foreground"),children:r??s.name})}),n.jsx(Ot,{side:"top",sideOffset:6,className:"max-w-xs",children:r??s.name})]}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",o.length]}),I?n.jsx(Qg,{state:I}):null]}),e[44]=I,e[45]=r,e[46]=te,e[47]=s.name,e[48]=me,e[49]=q,e[50]=ce,e[51]=Y,e[52]=A,e[53]=o,e[54]=B,e[55]=Ve):Ve=e[55];let Se;e[56]!==be||e[57]!==Ie||e[58]!==Ue||e[59]!==Ve?(Se=n.jsxs("div",{className:be,children:[Ie,Ue,Ve]}),e[56]=be,e[57]=Ie,e[58]=Ue,e[59]=Ve,e[60]=Se):Se=e[60];let ye;e[61]!==z||e[62]!==V||e[63]!==s.name||e[64]!==Pe||e[65]!==D||e[66]!==f||e[67]!==k||e[68]!==A||e[69]!==B?(ye=!A&&(!D||V)?n.jsx("div",{className:Te("absolute inset-e-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",z?"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:n.jsxs("div",{className:"flex items-center gap-0.5",children:[!V&&k?n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),k()},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-ring","aria-label":B("sessions.sidebar.folderItem.newSessionAria",{folderName:s.name}),title:B("sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,V?null:n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),Pe()},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-ring","aria-label":B("sessions.sidebar.folderItem.renameAria",{folderName:s.name}),children:n.jsx(Z,{name:"pencil-ai",className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),f()},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-ring","aria-label":V?B("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:s.name}):B("sessions.sidebar.folderItem.deleteFolderAria",{folderName:s.name}),children:n.jsx(Z,{name:"delete-bin",className:"h-3 w-3"})})]})}):null,e[61]=z,e[62]=V,e[63]=s.name,e[64]=Pe,e[65]=D,e[66]=f,e[67]=k,e[68]=A,e[69]=B,e[70]=ye):ye=e[70];let Ge;e[71]!==w||e[72]!==G||e[73]!==je||e[74]!==he||e[75]!==ge||e[76]!==ke||e[77]!==Ae||e[78]!==$||e[79]!==Se||e[80]!==ye?(Ge=n.jsxs("div",{ref:w,style:G,className:je,onClick:he,role:ge,tabIndex:ke,onKeyDown:Ae,"aria-label":$,children:[Se,ye]}),e[71]=w,e[72]=G,e[73]=je,e[74]=he,e[75]=ge,e[76]=ke,e[77]=Ae,e[78]=$,e[79]=Se,e[80]=ye,e[81]=Ge):Ge=e[81];let qe;e[82]!==p||e[83]!==c||e[84]!==N||e[85]!==o||e[86]!==i||e[87]!==B?(qe=!c&&N?n.jsxs("div",{className:"pb-1",children:[i,o.length>0?p:i?null:n.jsx("div",{className:"py-1 ps-1.5 text-start typography-micro text-muted-foreground/70",children:B("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[82]=p,e[83]=c,e[84]=N,e[85]=o,e[86]=i,e[87]=B,e[88]=qe):qe=e[88];let ft;return e[89]!==Ge||e[90]!==qe?(ft=n.jsxs("div",{className:"oc-folder",children:[Ge,qe]}),e[89]=Ge,e[90]=qe,e[91]=ft):ft=e[91],ft},oh=a.memo(h3);function m3(t){return t.stopPropagation()}function g3(t){return t.stopPropagation()}function b3(t){return t.stopPropagation()}function y3(t){return t.stopPropagation()}function x3(t){return t.stopPropagation()}function S3(t){return t.stopPropagation()}function v3(t){return t.stopPropagation()}function w3(t){return t.stopPropagation()}function k3(t){return t.stopPropagation()}function j3(t){return t.stopPropagation()}function C3(t){const e=Je.c(11);let s,r,o;e[0]!==t?({notifyOnSubtasks:r,activityNodes:s,...o}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o):(s=e[1],r=e[2],o=e[3]);const i=o.isCollapsed&&!o.archivedBucket;let c;e[4]!==s||e[5]!==r||e[6]!==i?(c={nodes:s,includeUnreadSubtasks:r,enabled:i},e[4]=s,e[5]=r,e[6]=i,e[7]=c):c=e[7];const l=Pu(c);let d;return e[8]!==l||e[9]!==o?(d=n.jsx(oh,{...o,collapsedActivityState:l}),e[8]=l,e[9]=o,e[10]=d):d=e[10],d}const _o=t=>{const e=Je.c(16),{directory:s,className:r}=t,{t:o}=Ct();let i;e[0]!==s?(i=Hm(s),e[0]=s,e[1]=i):i=e[1];const c=i;let l;if(e[2]!==c?(l=x=>x.sessions.get(c),e[2]=c,e[3]=l):l=e[3],!At(l)?.tabs.some(pu))return null;let f;e[4]!==o?(f=o("sessions.sidebar.projectAction.active"),e[4]=o,e[5]=f):f=e[5];const p=f;let m;e[6]!==r?(m=Te("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=m):m=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Z,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let b;e[9]!==c||e[10]!==p||e[11]!==m?(b=n.jsx("span",{className:m,role:"img","aria-label":p,"data-action-directory":c,children:g}),e[9]=c,e[10]=p,e[11]=m,e[12]=b):b=e[12];let v;return e[13]!==p||e[14]!==b?(v=n.jsx(On,{label:p,children:b}),e[13]=p,e[14]=b,e[15]=v):v=e[15],v},P3=t=>{const e=Je.c(19),{sessionId:s,dragKey:r,ownerKey:o,sessionDirectory:i,sessionTitle:c,archivedBucket:l,children:d}=t,u=o===void 0?null:o,f=l===void 0?!1:l,p=`session-drag:${r??s}`;let m;e[0]!==f||e[1]!==u||e[2]!==i||e[3]!==s||e[4]!==c?(m={type:"session",sessionId:s,ownerKey:u,sessionDirectory:i,sessionTitle:c,archivedBucket:f},e[0]=f,e[1]=u,e[2]=i,e[3]=s,e[4]=c,e[5]=m):m=e[5];let g;e[6]!==f||e[7]!==p||e[8]!==m?(g={id:p,disabled:f,data:m},e[6]=f,e[7]=p,e[8]=m,e[9]=g):g=e[9];const{attributes:b,listeners:v,setNodeRef:x,isDragging:y}=JS(g);let h;e[10]!==v?(h=k=>{k.stopPropagation(),v?.onPointerDown&&v.onPointerDown(k)},e[10]=v,e[11]=h):h=e[11];const S=h,w=`touch-pan-y select-none${y?" opacity-30":""}`;let C;return e[12]!==b||e[13]!==d||e[14]!==S||e[15]!==v||e[16]!==x||e[17]!==w?(C=n.jsx("div",{ref:x,...b,...v,onPointerDown:S,className:w,children:d}),e[12]=b,e[13]=d,e[14]=S,e[15]=v,e[16]=x,e[17]=w,e[18]=C):C=e[18],C},ih=t=>{const e=Je.c(20),{folderId:s,scopeKey:r,ownerKey:o,disabled:i,children:c}=t,l=i===void 0?!1:i;let d;e[0]!==s||e[1]!==r?(d=An(r,s),e[0]=s,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let f;e[3]!==l||e[4]!==r?(f=l||xl(r),e[3]=l,e[4]=r,e[5]=f):f=e[5];let p;e[6]!==s||e[7]!==o||e[8]!==r?(p={type:"folder",folderId:s,scopeKey:r,ownerKey:o},e[6]=s,e[7]=o,e[8]=r,e[9]=p):p=e[9];let m;e[10]!==u||e[11]!==f||e[12]!==p?(m={id:u,disabled:f,data:p},e[10]=u,e[11]=f,e[12]=p,e[13]=m):m=e[13];const{setNodeRef:g,isOver:b}=e1(m);let v;e[14]!==c||e[15]!==b||e[16]!==g?(v=c(g,b),e[14]=c,e[15]=b,e[16]=g,e[17]=v):v=e[17];let x;return e[18]!==v?(x=n.jsx(n.Fragment,{children:v}),e[18]=v,e[19]=x):x=e[19],x},E3=t=>{const e=Je.c(22),{scopeKey:s,ownerKey:r,hasFolders:o,onSessionDroppedOnFolder:i,children:c}=t,l=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const f=Lr(Fs($r,d),Fs(_r,u)),[p,m]=a.useState(null),[g,b]=a.useState("Session"),[v,x]=a.useState(null),[y,h]=a.useState(null);if(!s){let R;return e[2]!==c?(R=n.jsx(n.Fragment,{children:c}),e[2]=c,e[3]=R):R=e[3],R}let S;e[4]!==i||e[5]!==l?(S=R=>{m(null),x(null),h(null);const{active:I,over:N}=R;if(!N)return;const W=I.data.current,z=N.data.current;W?.type!=="session"||!W.sessionId||!W.ownerKey||W.archivedBucket===!0||l&&W.ownerKey!==l||z?.type!=="folder"||!z.folderId||!z.scopeKey||!z.ownerKey||xl(z.scopeKey)||z.ownerKey!==W.ownerKey||i(W.sessionId,{folderId:z.folderId,scopeKey:z.scopeKey,ownerKey:z.ownerKey},W.ownerKey)},e[4]=i,e[5]=l,e[6]=S):S=e[6];const w=S;let C,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{const I=R.active.data.current;if(I?.type==="session"&&I.sessionId){m(I.sessionId),b(I.sessionTitle??"Session");const N=R.active.rect.current.initial?.width,W=R.active.rect.current.initial?.height;x(N??null),h(W??null)}},k=()=>{m(null),x(null),h(null)},e[7]=C,e[8]=k):(C=e[7],k=e[8]);let T;e[9]!==y||e[10]!==p||e[11]!==g||e[12]!==v||e[13]!==o?(T=p&&o?n.jsxs("div",{style:{width:v?`${v}px`:"auto",height:y?`${y}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:[n.jsx(Z,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground me-2 flex-shrink-0"}),n.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:g})]}):null,e[9]=y,e[10]=p,e[11]=g,e[12]=v,e[13]=o,e[14]=T):T=e[14];let O;e[15]!==T?(O=n.jsx(t1,{children:T}),e[15]=T,e[16]=O):O=e[16];let K;return e[17]!==c||e[18]!==w||e[19]!==f||e[20]!==O?(K=n.jsxs(zr,{sensors:f,collisionDetection:Kr,onDragStart:C,onDragCancel:k,onDragEnd:w,children:[c,O]}),e[17]=c,e[18]=w,e[19]=f,e[20]=O,e[21]=K):K=e[21],K},ah=a.createContext(null),I3=({entries:t,descendantIds:e,sessionsById:s,children:r})=>{const o=a.useRef(t),i=a.useRef(e),c=a.useRef(s);o.current=t,i.current=e,c.current=s;const l=a.useRef(null);return l.current===null&&(l.current={getEntries:()=>o.current,getDescendantIds:()=>i.current,getSessionsById:()=>c.current}),n.jsx(ah.Provider,{value:l.current,children:r})},lh=()=>a.useContext(ah),T3=(t,e,s)=>{const r=t[0];if(!r)return null;const o=s??r.scopeKey,i=[],c=new Set;for(const l of t){if(o&&l.scopeKey!==o)continue;const d=l.descendantRange,u=d?[l.id,...e.slice(d[0],d[1])]:[l.id];for(const f of u)c.has(f)||(c.add(f),i.push(f))}return i.length>0?{ids:i,scopeKey:o}:null},ch=(t,e)=>{if(t.size===0)return!1;for(const s of t)if(!e.get(s)?.time?.archived)return!1;return!0},D3=({menuInstanceKey:t,contextMenuInstanceKey:e,openSidebarMenuKey:s,setOpenSidebarMenuKey:r,hasDeferredCloseWork:o,onCloseComplete:i})=>{const[c,l]=a.useState(!1),[d,u]=a.useState(!1),f=s===t&&!d,p=e?s===e&&!d:c,m=h=>{if(s===h){if(o()){u(!0);return}r(null)}},g=h=>{if(h){l(!1),u(!1),r(t);return}m(t)},b=h=>{if(!e){l(h);return}if(h){u(!1),r(e);return}m(e)},v=h=>{h||(i(),u(!1),(s===t||s===e)&&r(null))},x=()=>{u(!1),r(f?null:t)},y=a.useRef({menu:g,contextMenu:b});return y.current={menu:g,contextMenu:b},a.useEffect(()=>{if(!f&&!p)return;const h=()=>{p&&y.current.contextMenu(!1),f&&y.current.menu(!1)};return window.addEventListener("blur",h),()=>window.removeEventListener("blur",h)},[f,p]),{isMenuOpen:f,isContextMenuOpen:p,handleMenuOpenChange:g,handleContextMenuOpenChange:b,handleMenuOpenChangeComplete:v,toggleMenu:x}},R3=t=>{const e=Je.c(10),{project:s,fallback:r}=t,{currentTheme:o}=cr(),i=s.iconImage??null;let c;e[0]!==s.id||e[1]!==i?(c={id:s.id,iconImage:i},e[0]=s.id,e[1]=i,e[2]=c):c=e[2];let l;e[3]!==o.colors.surface.foreground||e[4]!==o.metadata.variant?(l={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[3]=o.colors.surface.foreground,e[4]=o.metadata.variant,e[5]=l):l=e[5];let d;return e[6]!==r||e[7]!==c||e[8]!==l?(d=n.jsx(Ha,{project:c,options:l,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=c,e[8]=l,e[9]=d):d=e[9],d},N3=t=>{const e=Je.c(14),{project:s,label:r}=t,o=s.icon?Ka[s.icon]:null;let i;e[0]!==s.color?(i=Wa(s.color),e[0]=s.color,e[1]=i):i=e[1];const c=i;let l;e[2]!==c||e[3]!==o?(l=o?n.jsx(Z,{name:o,className:Te("h-3 w-3",!c&&"text-muted-foreground/75"),style:c?{color:c}:void 0}):n.jsx(Z,{name:"folder",className:"h-3 w-3 text-muted-foreground/75",style:c?{color:c}:void 0}),e[2]=c,e[3]=o,e[4]=l):l=e[4];const d=l;let u;e[5]!==r?(u=r?{role:"img","aria-label":r}:{},e[5]=r,e[6]=u):u=e[6];const f=u;let p;e[7]!==d||e[8]!==f||e[9]!==s?(p=s.iconImage?n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:s.iconBackground?{backgroundColor:s.iconBackground}:void 0,...f,children:n.jsx(R3,{project:s,fallback:d})}):n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center",...f,children:d}),e[7]=d,e[8]=f,e[9]=s,e[10]=p):p=e[10];const m=p;let g;return e[11]!==r||e[12]!==m?(g=r?n.jsx(On,{label:r,children:m}):m,e[11]=r,e[12]=m,e[13]=g):g=e[13],g},Ia=t=>{const e=Je.c(54),{compact:s,project:r,projectLabel:o,title:i,titleClassName:c,branchLabel:l,spaceMark:d,metaLineLead:u,statusDot:f,pinnedMarker:p,timeSlot:m,directoryIndicator:g,prBadge:b,zombieIndicator:v,goal:x,badges:y,doneHint:h,providerId:S,metaPaddingClass:w,hideMetaOnHoverClass:C,actionsReserveClass:k,actionsMaskClass:T}=t,O=s===void 0?!1:s,K=d===void 0?null:d,R=u===void 0?null:u,I=x===void 0?null:x,N=h===void 0?null:h;let W;e[0]!==C||e[1]!==w?(W=Te("ms-auto flex flex-shrink-0 items-center gap-1 transition-opacity",w,C),e[0]=C,e[1]=w,e[2]=W):W=e[2];const z=O?I:null,H=O?v??b:null,M=O?y:null;let Y;e[3]!==m?(Y=n.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:m}),e[3]=m,e[4]=Y):Y=e[4];let j;e[5]!==g||e[6]!==N||e[7]!==p||e[8]!==f||e[9]!==Y||e[10]!==W||e[11]!==z||e[12]!==H||e[13]!==M?(j=n.jsxs("span",{className:W,children:[z,H,M,g,p,N,f,Y]}),e[5]=g,e[6]=N,e[7]=p,e[8]=f,e[9]=Y,e[10]=W,e[11]=z,e[12]=H,e[13]=M,e[14]=j):j=e[14];const P=j;let D;e[15]!==T||e[16]!==c?(D=Te("oc-ui-start-align min-w-0 flex-1 truncate typography-ui-label font-normal",T,c),e[15]=T,e[16]=c,e[17]=D):D=e[17];let V;e[18]!==D||e[19]!==i?(V=n.jsx("div",{dir:"auto",className:D,children:i}),e[18]=D,e[19]=i,e[20]=V):V=e[20];const B=V;if(O){let xe;e[21]!==k?(xe=Te("@container relative flex w-full min-w-0 items-center gap-1",k),e[21]=k,e[22]=xe):xe=e[22];let ce;return e[23]!==P||e[24]!==xe||e[25]!==B?(ce=n.jsxs("div",{className:xe,children:[B,P]}),e[23]=P,e[24]=xe,e[25]=B,e[26]=ce):ce=e[26],ce}let _;e[27]!==k?(_=Te("@container relative flex h-5 w-full min-w-0 items-center gap-1",k),e[27]=k,e[28]=_):_=e[28];let F;e[29]!==P||e[30]!==_||e[31]!==B?(F=n.jsxs("div",{className:_,children:[B,P]}),e[29]=P,e[30]=_,e[31]=B,e[32]=F):F=e[32];let X;e[33]!==r||e[34]!==o?(X=r?n.jsx(N3,{project:r,label:o}):null,e[33]=r,e[34]=o,e[35]=X):X=e[35];let oe;e[36]!==l||e[37]!==R||e[38]!==K?(oe=R??(l?n.jsxs(n.Fragment,{children:[K?n.jsx(Z,{name:"box-3",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":!1,role:"img","aria-label":K}):n.jsx(Z,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:l})]}):null),e[36]=l,e[37]=R,e[38]=K,e[39]=oe):oe=e[39];const ne=v??b;let A;e[40]!==S?(A=S?n.jsx(wf,{providerId:S,className:"h-3 w-3 flex-shrink-0 opacity-45"}):null,e[40]=S,e[41]=A):A=e[41];let te;e[42]!==y||e[43]!==I||e[44]!==ne||e[45]!==A?(te=n.jsxs("span",{className:"ms-auto flex flex-shrink-0 items-center gap-1",children:[I,ne,y,A]}),e[42]=y,e[43]=I,e[44]=ne,e[45]=A,e[46]=te):te=e[46];let U;e[47]!==X||e[48]!==oe||e[49]!==te?(U=n.jsxs("div",{className:"flex h-4 w-full min-w-0 items-center gap-1",children:[X,oe,te]}),e[47]=X,e[48]=oe,e[49]=te,e[50]=U):U=e[50];let Pe;return e[51]!==F||e[52]!==U?(Pe=n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[F,U]}),e[51]=F,e[52]=U,e[53]=Pe):Pe=e[53],Pe},dh=750,$o=t=>{const e=Je.c(9),{items:s,directory:r}=t,o=sl();let i;if(e[0]!==r||e[1]!==s||e[2]!==o){let l;e[4]!==r||e[5]!==o?(l=d=>n.jsxs("button",{type:"button",className:Te("group/ref flex min-w-0 flex-col rounded text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default",!d.color&&"text-muted-foreground"),style:d.color?{color:d.color}:void 0,disabled:!d.url,onPointerDown:M3,onMouseDown:A3,onKeyDown:O3,onClick:u=>{u.stopPropagation(),d.url&&o(d.url,r,u)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 group-hover/ref:underline group-disabled/ref:no-underline",children:[n.jsx(Z,{name:d.icon,className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:d.text})]}),d.title?n.jsx("span",{className:"min-w-0 truncate ps-[18px] text-muted-foreground",children:d.title}):null]},d.key),e[4]=r,e[5]=o,e[6]=l):l=e[6],i=s.map(l),e[0]=r,e[1]=s,e[2]=o,e[3]=i}else i=e[3];let c;return e[7]!==i?(c=n.jsx("div",{className:"flex min-w-0 flex-col gap-1",children:i}),e[7]=i,e[8]=c):c=e[8],c};function M3(t){return t.stopPropagation()}function A3(t){return t.stopPropagation()}function O3(t){return t.stopPropagation()}const B3=150,$i={capture:!0,passive:!0};let So=null;const Ed=new WeakSet,F3=t=>{So={target:t.target,at:performance.now()}},Id=(t,e)=>t instanceof Node&&t.contains(e);function L3(){const t=Je.c(4),e=a.useRef(null),s=a.useRef(null);let r,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>(Ed.has(document)||(Ed.add(document),document.addEventListener("scroll",F3,$i)),()=>s.current?.()),o=[],t[0]=r,t[1]=o):(r=t[0],o=t[1]),a.useEffect(r,o);let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(d,u)=>{s.current?.(),s.current=null;const f=u.trigger;if(!d||!f)return;if(So&&performance.now()-So.at<B3&&Id(So.target,f)){u.cancel();return}const p=m=>{Id(m.target,f)&&e.current?.close()};document.addEventListener("scroll",p,$i),s.current=()=>document.removeEventListener("scroll",p,$i)},t[2]=i):i=t[2];const c=i;let l;return t[3]===Symbol.for("react.memo_cache_sentinel")?(l={actionsRef:e,onOpenChange:c},t[3]=l):l=t[3],l}let Ta=!1;const Da=new Set;let Td=!1;function _3(){for(const t of Da)t()}function uh(t){Ta!==t&&(Ta=t,_3())}function io(t){uh(t.shiftKey)}function $3(){uh(!1)}function z3(){if(Td||typeof window>"u")return;Td=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",io,t),window.addEventListener("keyup",io,t),window.addEventListener("pointermove",io,t),window.addEventListener("pointerdown",io,t),window.addEventListener("blur",$3)}function K3(t){return z3(),Da.add(t),()=>{Da.delete(t)}}function W3(){return Ta}function H3(){return!1}function fh(){return fs.useSyncExternalStore(K3,W3,H3)}const ph=async(t,e,s)=>{const r=s.getRuntimeKey(),o=vt(t.path);if(!o)throw new Error("Unable to resolve worktree project");const i=await s.listProjectWorktrees(t,{force:!0});if(s.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const c=s.getCurrentProjects(),l=c.find(b=>b.id===t.id)??null;if(!l||vt(l.path??null)!==o)throw new Error("Project removed during worktree refresh");const d=vl({rawWorktreesByProjectRef:s.rawWorktreesByProjectRef,publishedWorktreesByProject:s.getPublishedWorktreesByProject(),runtimeKey:r}),u=i.map(b=>zo(b));u.sort((b,v)=>hh({metadata:b},{metadata:v}));const f=mx(d.worktreesByProject,o,u,e?.projectDirectory);V3(s.rawWorktreesByProjectRef,r),s.rawWorktreesByProjectRef.current={runtimeKey:r,revision:s.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const p=s.getPublishedWorktreesByProject(),m=gx(s.partitionWorktreesByRegisteredProject(c,f),p),g=[...m.values()].flat();return s.recordWorktreesSeen(g.map(b=>b.path),s.now()),s.worktreeMapsEqual(m,p)||s.publishTopology({availableWorktrees:g,availableWorktreesByProject:m}),u},V3=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),U3=t=>new Map([...t.entries()].map(([e,s])=>[e,s.map(r=>zo(r))])),vl=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:U3(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),hh=(t,e)=>{const s=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,o=s.localeCompare(r,void 0,{sensitivity:"base"});return o!==0?o:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},Dd=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},zo=t=>({...t,path:vt(t.path)??t.path,projectDirectory:vt(t.projectDirectory)??t.projectDirectory,worktreeRoot:vt(t.worktreeRoot??t.path)??t.worktreeRoot}),Rd=t=>{const{currentWorktree:e,path:s,projectDirectory:r,projectRootBranch:o}=t,c=vt(e?.path??null)===s,l=c?e?.branch??"":o??"",d={path:s,projectDirectory:r,branch:l,label:c?e?.label||e?.branch||e?.name||Dd(s):o||Dd(s),name:c?e?.name:void 0,worktreeRoot:c?vt(e?.worktreeRoot??s)??s:s,worktreeStatus:c?e?.worktreeStatus??"ready":"ready",worktreeSource:c?e?.worktreeSource??"existing":"existing",headState:c?e?.headState:o?"branch":void 0};return c&&e?{...e,...d}:d},Nd=t=>{const e=vt(t.projectPath??null),s=vt(t.sourceDirectory??null)??vt(t.currentWorktree?.path??null),r=vt(t.discoveredWorktrees.find(f=>vt(f.projectDirectory??null))?.projectDirectory??null),o=vt(t.currentWorktree?.projectDirectory??null),i=r??o??e,c=new Map,l=f=>{const p=vt(f.metadata.path??null);!p||c.has(p)||e&&p!==s&&bx(p,e)||c.set(p,{...f,metadata:zo({...f.metadata,path:p})})};for(const f of t.discoveredWorktrees){const p=vt(f.path??null);p&&l({metadata:zo({...f,path:p,projectDirectory:vt(f.projectDirectory??null)??i??e??p}),isPrimary:i===p,isCurrent:s===p})}i&&!c.has(i)&&l({metadata:Rd({path:i,projectDirectory:i,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:s===i}),s&&!c.has(s)&&l({metadata:Rd({path:s,projectDirectory:i??e??s,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:i===s,isCurrent:!0});const d=[],u=[];for(const f of c.values()){if(f.isPrimary){d.push(f);continue}u.push(f)}return d.sort((f,p)=>f.metadata.path.localeCompare(p.metadata.path,void 0,{sensitivity:"base"})),u.sort(hh),[...d,...u]},mh=(t,e)=>{const s=t.projectId?e.projects.find(i=>i.id===t.projectId)??null:null;if(s)return s;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const o=t.currentWorktree?.projectDirectory??null;return o?e.resolveProject(o):null},G3=(t,e)=>{const s=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),o=vl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:s}),i=mh(t,e),c=vt(i?.path??null);return{cachedTargets:Nd({projectPath:c,discoveredWorktrees:c?o.worktreesByProject.get(c)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!i||!c)throw new Error("Unable to resolve worktree project");const d=await ph(i,t.currentWorktree,e);return Nd({projectPath:c,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},q3=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),s=[...e.values()].flat();return t.recordWorktreesSeen(s.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:s,availableWorktreesByProject:e}),!0},Y3=t=>({refreshState:t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),X3=(t,e)=>vt(t.worktree?.path??null)===vt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,Z3=[],Q3=[],J3=[],Md=10,zi=new WeakMap,e4=t=>{const e=t.closest("[data-session-row]"),s=e?.closest(".overlay-scrollbar-container");if(!e||!s)return;zi.get(s)?.();const r=e.getBoundingClientRect().top;let o=3,i=!1,c=null;const l=()=>{i=!0,c!==null&&window.cancelAnimationFrame(c),c=null,zi.delete(s),s.removeEventListener("wheel",l),s.removeEventListener("touchstart",l)},d=()=>{if(i||!e.isConnected||!s.isConnected){l();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(s.scrollTop+=u,js("ui.sidebar.selection_scroll_anchor_adjustment")),o-=1,o<=0){l();return}c=window.requestAnimationFrame(d)};s.addEventListener("wheel",l,{passive:!0}),s.addEventListener("touchstart",l,{passive:!0}),zi.set(s,l),c=window.requestAnimationFrame(d)},t4=a.memo(function(e){const s=Je.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:i,iconSizeClass:c,onPointerDown:l,onMouseDown:d,onArchive:u,onDelete:f}=e,p=fh(),m=p?o:r;let g;s[0]!==u||s[1]!==f||s[2]!==p?(g=k=>{if(p||k.shiftKey){f(k);return}u(k)},s[0]=u,s[1]=f,s[2]=p,s[3]=g):g=s[3];const b=g,v=p?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;s[4]!==i||s[5]!==v?(x=Te("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",v,i),s[4]=i,s[5]=v,s[6]=x):x=s[6];const y=p?"delete-bin":"archive";let h;s[7]!==c||s[8]!==y?(h=n.jsx(Z,{name:y,className:c}),s[7]=c,s[8]=y,s[9]=h):h=s[9];let S;s[10]!==b||s[11]!==m||s[12]!==d||s[13]!==l||s[14]!==x||s[15]!==h?(S=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",className:x,"aria-label":m,onPointerDown:l,onMouseDown:d,onClick:b,onKeyDown:d4,children:h})}),s[10]=b,s[11]=m,s[12]=d,s[13]=l,s[14]=x,s[15]=h,s[16]=S):S=s[16];let w;s[17]!==m?(w=n.jsx(Ot,{side:"top",sideOffset:6,children:m}),s[17]=m,s[18]=w):w=s[18];let C;return s[19]!==S||s[20]!==w?(C=n.jsxs(Ft,{children:[S,w]}),s[19]=S,s[20]=w,s[21]=C):C=s[21],C});function s4(t){js("ui.sidebar_session_node.render");const{t:e}=Ct(),{node:s,depth:r=0,groupDirectory:o,projectId:i,folderOwnerKey:c,selectionScopeKey:l,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,notifyOnSubtasks:g,editingId:b,editingRowKey:v,setEditingId:x,setEditingRowKey:y,editTitle:h,setEditTitle:S,handleSaveEdit:w,handleCancelEdit:C,toggleParent:k,handleSessionSelect:T,handleSessionDoubleClick:O,handleCopySessionId:K,openSidebarMenuKey:R,setOpenSidebarMenuKey:I,createFolderAndStartRename:N,handleDeleteSession:W,handleRestoreSession:z,startSessionWorktreeMenuLoad:H,mobileVariant:M,alwaysShowActions:Y,secondaryMeta:j,renderContext:P="project",blockingBadgeSessionScopes:D,rowKey:V,dragKey:B,children:_}=t,F=kf(J=>J.toggle),X=Xt(J=>J.getFoldersForScope),oe=Xt(J=>J.getSessionFolderId),ne=Xt(J=>J.removeSessionFromFolder),A=Xt(J=>J.addSessionToFolder),te=de(J=>J.openContextPanelTab),U=a.useMemo(()=>Pn(),[]),Pe=a.useMemo(()=>vo(),[]),xe=a.useContext(yx),ce=U?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto",Oe=U?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",me=U,ie=!d&&!M,q=de(J=>J.sessionWorkEnabled),ue=de(J=>J.sessionRecapEnabled),ve=q&&!d&&!s.session.parentID&&!Fa(s.session.directory),Ee=ve&&!Y,L=(Ee?1:0)+(ie?1:0)+(me?1:0),le=["group-hover:pe-8","group-hover:pe-14","group-hover:pe-18","group-hover:pe-22"][L],G=ie?"pe-13":"pe-7",se=a.useRef(!1),[je,he]=a.useState(!1),ge=a.useRef(b);ge.current=b;const ke=a.useRef(null),Ae=a.useRef(!1),$=a.useRef(w);$.current=w;const fe=h,be=a.useRef(fe);be.current=fe;const Ie=a.useRef(null),Ye=a.useRef(!1),nt=a.useRef(null),Ue=a.useRef(null),Ve=L3(),Se=s.session,ye=Se,Ge=Jt(a.useCallback(J=>{if(j?.projectLabel||!i)return null;const Dt=J.projects.find(Vt=>Vt.id===i);return Dt?Dt.label?.trim()||Qo(vt(Dt.path)??Dt.path,null)||Dt.path:null},[i,j?.projectLabel])),qe=P==="timeline-chat"||P==="mixed-compact",ft=ar(P)||qe,et=Jt(a.useCallback(J=>P!=="timeline-mixed"||!i?null:J.projects.find(Dt=>Dt.id===i)??null,[P,i])),St=j?.projectLabel??(Ge?jf(Ge):null),we=A2(j,s.worktree?.branch??null),De=j?.inSpace===!0,ot=a.useMemo(()=>O2(s.worktree,U),[U,s.worktree]),rt=Cf(ot?.directory??null,ot?.branch??null),Xe=a.useMemo(()=>U?Z3:Pf(Se),[U,Se]),ht=a.useMemo(()=>Xe.map(J=>({item:Ir("pull",J),url:J.url,title:J.title})),[Xe]),ee=pc(ht),_e=a.useMemo(()=>ee.filter(J=>J!==null),[ee]),Be=a.useMemo(()=>U?J3:xx(Se),[U,Se]),Ke=a.useMemo(()=>Be.flatMap(J=>J.gitlab?[{item:Tr("pull",J.gitlab),url:J.url,title:J.title}]:[]),[Be]),Fe=pc(Ke),tt=a.useMemo(()=>Sx(rt,[..._e,...Fe.filter(J=>J!==null)]),[rt,Fe,_e]),bt=a.useMemo(()=>{let J=0;return Be.filter(Dt=>{if(!Dt.gitlab)return!0;const Vt=Fe[J]!==null;return J+=1,!Vt})},[Fe,Be]),mt=a.useMemo(()=>vx(Xe,tt),[Xe,tt]),it=rt?`var(--pr-${rt.visualState})`:void 0,Tt=a.useMemo(()=>U?Q3:nl(Se),[U,Se]),at=a.useMemo(()=>Tt.flatMap(J=>J.source==="github"?[Ir("issue",J)]:[]),[Tt]),$t=Do(at),zt=a.useMemo(()=>Tt.flatMap(J=>J.source==="gitlab"?[Tr("issue",J.ref)]:[]),[Tt]),Mt=Do(zt),Re=a.useMemo(()=>Tt.flatMap(J=>J.source==="linear"?[rl(J.identifier)]:[]),[Tt]),ct=Ef(Re),lt=a.useMemo(()=>{if(tt.length>0||mt.length>0||bt.length>0){const J=tt.map(_t=>{const cs=If(_t,e),Ut=qa(_t.provider,_t.number);return{key:`${_t.provider??""}:${_t.repo?.owner??""}/${_t.repo?.repo??""}#${_t.number}`,icon:"git-pull-request",label:Ut,color:`var(--pr-${_t.visualState})`,url:_t.url,title:_t.title,text:cs?`${Ut} · ${cs}`:Ut}}),Dt=mt.map(_t=>({key:`${_t.owner}/${_t.repo}#${_t.number}`,icon:"git-pull-request",label:`#${_t.number}`,url:_t.url,title:_t.title,text:`#${_t.number}`})),Vt=bt.map(_t=>({key:_t.key,icon:"git-pull-request",label:_t.identifier,url:_t.url,title:_t.title,text:_t.identifier}));return[...J,...Dt,...Vt]}return Tf(Tt,$t,ct,Mt).map(J=>({key:J.key,icon:J.icon,label:J.label,color:J.color??void 0,url:J.url,title:J.title,text:J.statusKey?`${J.label} · ${e(J.statusKey)}`:J.statusText?`${J.label} · ${J.statusText}`:J.label}))},[Mt,$t,Tt,ct,mt,tt,e,bt]),dt=lt[0]??null,st=Math.max(0,lt.length-1),wt=sl(),pt=lt.map(J=>J.text).join(", "),E=xt(J=>J.currentSessionId===Se.id),Q=vt(Se.directory??null)??vt(o??null),Ne=l!==void 0?l:i??Q??null,Ce=$u(),We=Df(),$e=U,kt=c3(),jt=us(J=>J.enabled),Et=us(a.useCallback(J=>J.selectedIds.has(Se.id),[Se.id])),Lt=us(J=>J.toggleSelected),Yt=us(J=>J.setRange),is=lh(),Wt=V??Se.id,rs=b===Se.id&&v===Wt,as=a.useCallback(J=>{const Dt=[],Vt=_t=>{_t.children.forEach(cs=>{Dt.push(cs.session.id),Vt(cs)})};return Vt(J),Dt},[]),Ss=a.useCallback(J=>{const Dt=[],Vt=_t=>{_t.children.forEach(cs=>{Dt.push(cs.session),Vt(cs)})};return Vt(J),Dt},[]),[Me,pe]=a.useState(!1),[Le,yt]=a.useState(!0),Rt=`${P}:${d?"archived":"active"}:${Se.id}`,Nt=V?`session-menu:${V}`:Rt,re=V?`session-context:${V}`:null,Ze=wx(a.useCallback(J=>!!J.sessionMemoryState.get(kx(Se.id))?.isZombie,[Se.id])),Qe=Du(Se.id),ae=Qe!==null,He=jx(Se.id,ae),ut=Zf(Se.id),gt=_a(Se.id,Q),Pt=ut||gt,Kt=s.worktree??xt.getState().getWorktreeMetadata(Se.id)??null,[es,os]=a.useState([]),[ps,Ht]=a.useState(!1),hs=a.useRef(!1),ms=a.useRef(0),$s=Cx(ye),ts=ve&&ol(ye),Fn=ts&&!ae&&Px(ye),zs=e(ts?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),pn=async()=>{try{await Lx(Se.id,Q,ts?"done":"open")}catch{ze.error(e("sessions.sidebar.session.work.updateFailed"))}},Ln=$s?e(Ex[$s.status]):"",wl=$s?n.jsx(On,{label:Ln,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":Ln,children:n.jsx(Z,{name:"target",className:"h-3 w-3",style:{color:Ix[$s.status]}})})}):null,hn=ye.title||e("sessions.sidebar.session.untitled"),kl=!ft&&s.children.length>0,Gr=ni(u,Q,Se.id),di=Rt,_n=p?!0:f.has(di),Oh=a.useMemo(()=>D??Pa(s,_n,Q),[_n,s,Q,D]),{hasPermission:jl,hasForm:Cl}=Tx(Oh),Pl=!!ye.parentID,El=Ru(Se.id)>0&&(!Pl||g),Il=Dx(ye)||Date.now(),Bh=Rx(Il),ui=Rf(Il),{isMenuOpen:Tl,isContextMenuOpen:Dl,handleMenuOpenChange:Fh,handleContextMenuOpenChange:Lh,handleMenuOpenChangeComplete:Rl,toggleMenu:_h}=D3({menuInstanceKey:Nt,contextMenuInstanceKey:re,openSidebarMenuKey:R,setOpenSidebarMenuKey:I,hasDeferredCloseWork:()=>ke.current!==null,onCloseComplete:()=>{if(!ke.current)return;const{id:J,title:Dt}=ke.current;ke.current=null,x(J),y(Wt),S(Dt)}}),ur=Tl||Dl,Nl=a.useMemo(()=>Nx(ye)?.key??null,[ye]),fi=a.useMemo(()=>as(s).length,[as,s]),pi=a.useCallback(async J=>{const Dt=[];let Vt=0;for(const _t of J)try{if(!Q)throw new Error("Session directory is required for export");const cs=await Ce({directory:Q,sessionID:_t.session.id});if(!cs)throw new Error("Session runtime changed during export");const Ut=_t.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Ks=_t.session.agent,ws=await pi(_t.children);Vt+=ws.skipped,Dt.push({title:Ut,agent:Ks,records:cs,children:ws.children})}catch{Vt+=as(_t).length+1}return{children:Dt,skipped:Vt}},[as,Ce,Q,e]),hi=a.useCallback(J=>{J<=0||ze.warning(J===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:J}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:J}))},[e]),mi=a.useCallback(async J=>{if(!Q){ze.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Dt=await Ce({directory:Q,sessionID:Se.id}).catch(()=>null);if(!Dt){ze.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Dt.length===0){ze.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Vt,_t=0;if(J&&s.children.length>0){const ws=await pi(s.children);Vt=ws.children,_t=ws.skipped}const cs=zu(Dt,ye.title??null,Vt),Ut=Ku(ye.title??null),Ks=await Wu(cs,Ut);if(Ks){ze.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Ax()),onClick:()=>{Mx(Ks).then(ws=>{ws||ze.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),hi(_t);return}Hu(cs,Ut),ze.success(e("sessions.sidebar.session.export.success")),hi(_t)},[pi,Ce,s.children,ye.title,Se.id,Q,hi,e]),Ml=Vu(),$h=a.useMemo(()=>Uu(Ml),[Ml]),zh=a.useCallback(J=>{Yf({entry:J,t:e,session:{id:Se.id,title:ye.title,directory:Q},loadRecords:()=>Q?Ce({directory:Q,sessionID:Se.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>ze.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[Ce,ye.title,Se.id,Q,e]),Kh=a.useCallback(async()=>{if(s.children.length>0){yt(!0),pe(!0);return}await mi(!1)},[mi,s.children.length]),Wh=a.useCallback(()=>{Q&&xn("desktop_open_session_mini_chat_window",{sessionId:Se.id,directory:Q,...Sr()}).catch(J=>{console.warn("[session-sidebar] failed to open mini chat window",J)})},[Se.id,Q]),Al=()=>{if(!Q)return;const J=_x()??Q;te(J,{mode:"chat",dedupeKey:`session:${Se.id}`,label:hn,sessionTitleFallback:hn,targetDirectory:Q})};if(a.useEffect(()=>{if(!rs)return;const J=Dt=>{const _t=(Dt.target instanceof HTMLElement?Dt.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Wt)}"]`);Ue.current&&!_t&&$.current(be.current)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[rs,Wt]),a.useLayoutEffect(()=>{if(!rs){Ie.current===Wt&&(Ie.current=null);return}Ie.current!==Wt&&(Ie.current=Wt,Ye.current=!0)},[h,rs,Wt]),a.useLayoutEffect(()=>{if(!rs||!Ye.current)return;const J=nt.current;!J||J.value!==h||(Ye.current=!1,J.focus(),J.select())},[h,rs,fe]),rs){const J=n.jsxs("form",{ref:Ue,"data-session-rename-form":Wt,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Dt=>{Dt.preventDefault(),w(fe)},children:[n.jsx("input",{ref:nt,value:fe,onChange:Dt=>S(Dt.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:Dt=>Yi(Dt,C)}),n.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:n.jsx(Z,{name:"check",className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:C,"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:n.jsx(Z,{name:"close",className:"size-3.5"})})]});return ft?n.jsx("div",{style:{paddingInlineStart:Md},className:Te("oc-ref-tint-scope group relative my-0.5 flex items-center rounded-md pe-2.5",qe?"py-1":"py-1.5",E&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:n.jsx(Ia,{compact:qe,project:et,projectLabel:St,title:J,titleClassName:"text-foreground",branchLabel:we,spaceMark:De?e("sessions.sidebar.group.space"):null,statusDot:null,pinnedMarker:null,timeSlot:ui,directoryIndicator:null,prBadge:dt?n.jsxs("span",{className:Te("inline-flex flex-shrink-0 items-center gap-1 typography-micro",dt.color?"oc-ref-tint":"text-muted-foreground"),style:dt.color?Xn(dt.color):void 0,children:[n.jsx(Z,{name:dt.icon,className:"h-3 w-3"}),qe?null:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"leading-none tabular-nums",children:dt.label}),st>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",st]}):null]})]}):null,zombieIndicator:null,goal:wl,badges:null,hideMetaOnHoverClass:""})},Se.id):n.jsxs("div",{style:{paddingInlineStart:lr(r)},className:"group relative my-0.5 flex items-center gap-1.5 rounded-md py-[3px] pe-2.5",children:[n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:J})]},Se.id)}const Ol=e("sessions.sidebar.session.status.questionPending"),Bl=!Pt&&!ae&&El&&!E,Hh=ae||Bl,Vh=n.jsx(Au,{state:Qe??"unread",tooltip:!0}),Uh=(ae||Bl)&&He,Gh=ft&&!qe?["[--oc-actions-reserve:14px]","[--oc-actions-reserve:36px]","[--oc-actions-reserve:58px]","[--oc-actions-reserve:80px]"][L]:["[--oc-actions-reserve:10px]","[--oc-actions-reserve:28px]","[--oc-actions-reserve:46px]","[--oc-actions-reserve:64px]"][L],qh=Y?void 0:ur?"oc-actions-mask":U?"group-hover:oc-actions-mask":"group-hover:oc-actions-mask group-has-[:focus-visible]:oc-actions-mask",Yh=ur?"opacity-0":Oe,Fl=e("sessions.sidebar.session.status.pinned"),Xh=n.jsx(On,{label:Fl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":Fl,children:n.jsx(Z,{name:"pushpin",className:"h-3 w-3 text-primary"})})}),Zh=n.jsx(Z,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(gt?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),Qh=ft?null:kl?n.jsx("span",{role:"button",tabIndex:0,onClick:J=>{J.stopPropagation(),J.currentTarget.blur(),k(di)},onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),J.stopPropagation(),k(di))},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e(_n?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":_n,children:n.jsx(Ar,{expanded:_n})}):n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}),gi=Ze?n.jsx(Z,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Jh=J=>{J.preventDefault(),J.stopPropagation(),_h()},em=J=>{J.preventDefault(),J.stopPropagation()},tm=J=>{J.preventDefault(),J.stopPropagation()},bi=J=>{J.preventDefault(),J.stopPropagation()},yi=J=>{J.preventDefault(),J.stopPropagation()},sm=J=>{J.preventDefault(),J.stopPropagation(),I(null),W(Se,{archivedBucket:d})},nm=J=>{J.preventDefault(),J.stopPropagation(),I(null),W(Se,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},rm=J=>{J.preventDefault(),J.stopPropagation()},om=J=>{J.preventDefault(),J.stopPropagation()},im=J=>{J.preventDefault(),J.stopPropagation(),xe?.vscode?.executeCommand("openchamber.openSessionInEditor",Se.id,hn)},Ll=J=>{if(se.current){se.current=!1;return}if(jt){if(J?.preventDefault(),J?.stopPropagation(),J?.shiftKey){const Dt=is?.getEntries(),Vt=Dt??Array.from(document.querySelectorAll("[data-session-row]")).map(Ut=>Ut.getAttribute("data-session-row")).filter(Ut=>!!Ut).map(Ut=>({id:Ut,rowKey:Ut,scopeKey:Ne,archived:d})),_t=Dt?us.getState().anchorRowKey:us.getState().anchorId,cs=new Map;cs.set(Se.id,as(s)),Yt(_t,Wt,Vt,is?.getDescendantIds()??[],Ne,cs);return}Lt(Se.id,Ne,as(s),Wt);return}if(J?.shiftKey&&!U&&Q){Al();return}J?.currentTarget&&e4(J.currentTarget),T(Se.id,Q)},am=J=>{J.defaultPrevented||(J.target instanceof HTMLElement?J.target:null)?.closest('button, a, input, [data-session-row-main], [role="menuitem"], [role="menu"]')||Ll(J)},lm=J=>{(J.button===2||J.button===0&&J.ctrlKey&&!jt)&&(se.current=!0),J.button===0&&J.shiftKey&&!jt&&J.preventDefault()},cm=J=>{M&&J.pointerType==="touch"&&he(!0),J.button===0&&!E&&!jt&&!$e&&Q&&!na(Se.id,Q).renderable&&We({directory:Q,sessionID:Se.id}).catch(()=>{})},$n=!E&&!jt&&Q?{id:Se.id,directory:Q}:null,dm=J=>{J.pointerType!=="mouse"||!$n||kt?.schedule($n)},um=()=>{$n&&kt?.schedule($n)},_l=()=>{$n&&kt?.cancel($n)},$l=J=>{M&&J.pointerType==="touch"&&he(!1)},fm=J=>{hs.current=J,ms.current+=1;const Dt=ms.current;if(!J){Ht(!1);return}const Vt=H({projectId:i??null,sourceDirectory:Q,currentWorktree:Kt});os(Vt.cachedTargets),Ht(!1),Vt.refreshTargets.then(_t=>{!hs.current||ms.current!==Dt||(os(_t),Ht(!1))}).catch(()=>{!hs.current||ms.current!==Dt||Ht(!0)})},zl=({Item:J,Separator:Dt,Sub:Vt,SubTrigger:_t,SubContent:cs})=>n.jsxs(n.Fragment,{children:[n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(J,{onClick:()=>{ke.current={id:Se.id,title:hn}},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]})}),n.jsx(ua,{sessionID:Se.id,directory:Q,open:ur,Item:J}),n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(J,{onClick:()=>K(Se.id),className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"file-copy",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]})}),n.jsx(Qt,{hint:e(Gr?"sessions.sidebar.session.menuHint.unpin":"sessions.sidebar.session.menuHint.pin"),children:n.jsxs(J,{onClick:()=>Q&&F({directory:Q,sessionId:Se.id}),className:"[&>svg]:me-1",children:[Gr?n.jsx(Z,{name:"unpin",className:"me-1 h-4 w-4"}):n.jsx(Z,{name:"pushpin",className:"me-1 h-4 w-4"}),e(Gr?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]})}),ve?n.jsx(Qt,{hint:e(ts?"sessions.sidebar.session.menuHint.markDone":"sessions.sidebar.session.menuHint.track"),children:n.jsxs(J,{onClick:()=>{pn()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:ts?"check":"eye",className:"me-1 h-4 w-4"}),e(ts?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]})}):null,n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(J,{onClick:()=>{Kh()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"download",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]})}),$h.map(Ut=>n.jsxs(J,{onClick:()=>zh(Ut),className:"[&>svg]:me-1",children:[n.jsx(dr,{icon:Ut.icon,iconSrc:Ut.iconSrc,className:"me-1 size-4"}),Ut.action.label]},`${Ut.guest.id}:${Ut.action.id}`)),R2({isSubtaskSession:Pl,archivedBucket:!!d,isVSCode:U,sessionDirectory:Q})?(()=>{const Ut=N2({sessionDirectory:Q,isStreaming:ae,isMovingToWorktree:ut}),Ks=Y3({targets:es,loadFailed:ps}),ws=n.jsxs(_t,{disabled:Ut,className:"w-full [&>svg]:me-1","data-session-worktree-submenu-trigger":Se.id,children:[n.jsx(Z,{name:"folder-shared",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]}),Ms=ut?e("sessions.sidebar.session.moveToWorktree.tooltipMoving"):ae?e("sessions.sidebar.session.moveToWorktree.tooltipBusy"):null;return n.jsxs(Vt,{onOpenChange:fm,children:[Ms?n.jsx(Qt,{hint:Ms,children:ws}):ws,n.jsxs(cs,{className:"min-w-[220px]","data-session-worktree-submenu":Se.id,children:[es.map(ys=>{const gs=vt(ys.metadata.path??null)??ys.metadata.path,bs=ys.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ys.metadata.label||ys.metadata.branch||ys.metadata.name||ys.metadata.path,tn=ys.isCurrent||ys.metadata.worktreeStatus!=="ready";return n.jsxs(J,{disabled:tn,title:ys.metadata.path,"data-session-worktree-target":gs,onClick:()=>{tn||!Q||No({kind:"existing",root:ye,descendants:Ss(s),sourceDirectory:Q,destination:ys.metadata,messages:Ro(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[n.jsx("span",{className:"truncate",children:bs}),ys.isCurrent?n.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ys.isCurrent?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},gs)}),Ks.refreshState==="error"?n.jsx(J,{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,n.jsx(Dt,{}),n.jsxs(J,{disabled:Ut,"data-session-worktree-new-action":"true",onClick:()=>{Ut||!Q||No({kind:"quick",root:ye,descendants:Ss(s),sourceDirectory:Q,messages:Ro(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,Nl?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openRunOverview"),children:n.jsxs(J,{onClick:()=>de.getState().setRunOverviewKey(Nl),className:"[&>svg]:me-1",children:[n.jsx(ra,{className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]})}):null,Q&&!d&&!ft?(()=>{const Ut=[],Ks=gs=>{const bs=vt(gs??null);bs&&!Ut.includes(bs)&&Ut.push(bs)};if(i&&!U){const gs=Jt.getState().projects.find(tn=>tn.id===i),bs=vt(gs?.path??null);Ks(bs),bs&&(xt.getState().availableWorktreesByProject.get(bs)??[]).forEach(tn=>Ks(tn.path))}Ks(La(Q)),Ks(Q);const ws=Ut.flatMap(gs=>X(gs).map(bs=>({scope:gs,folder:bs}))),Ms=ws.find(({scope:gs,folder:bs})=>oe(gs,Se.id)===bs.id)??null,ys=Ut[0]??Q;return n.jsxs(n.Fragment,{children:[n.jsx(Dt,{}),n.jsxs(Vt,{children:[n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.moveToFolder"),children:n.jsxs(_t,{className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]})}),n.jsxs(cs,{className:"min-w-[180px]",children:[ws.length===0?n.jsx(J,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):ws.map(({scope:gs,folder:bs})=>{const tn=Ms?.folder.id===bs.id;return n.jsxs(J,{onClick:()=>{if(tn){ne(gs,Se.id);return}Ms&&Ms.scope!==gs&&ne(Ms.scope,Se.id),A(gs,bs.id,Se.id)},children:[n.jsx("span",{className:"flex-1 truncate",children:bs.name}),tn?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},bs.id)}),n.jsx(Dt,{}),n.jsxs(J,{onClick:()=>{const gs=N(ys);gs&&(Ae.current=!0,Ms&&Ms.scope!==ys&&ne(Ms.scope,Se.id),A(ys,gs.id,Se.id))},children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Ms?n.jsxs(J,{onClick:()=>{ne(Ms.scope,Se.id)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,U?null:n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openInSidePanel"),children:n.jsxs(J,{disabled:!Q,onClick:Al,className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"chat-4",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")})]})}),Pe?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openMiniChatWindow"),children:n.jsxs(J,{disabled:!Q,onClick:Wh,className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"window",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]})}):null,n.jsx(Dt,{}),d?null:n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.archive"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>W(Se,{archivedBucket:d}),children:[n.jsx(Z,{name:"inbox-archive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]})}),d?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.restore"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>z(Se),children:[n.jsx(Z,{name:"inbox-unarchive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]})}):null,n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(J,{className:"text-destructive focus:text-destructive [&>svg]:me-1",onClick:()=>W(Se,{archivedBucket:d,hardDelete:!0}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})})]}),pm=J=>{J.preventDefault(),J.stopPropagation(),pn()},xi=Y?"h-6 w-6":ft&&!qe?"h-5 w-5":"h-4 w-4",qr=Y?"h-3.5 w-3.5":ft&&!qe?"h-3 w-3":"h-2.5 w-2.5",hm=Y?"h-4 w-4":ft&&!qe?"h-3.5 w-3.5":"h-3 w-3",Kl=ue&&!ae&&Ox(ye)?.recap||null,Wl=e("sessions.sidebar.session.work.doneSuggested"),mm=J=>Fn?n.jsx(On,{label:Wl,children:n.jsx("span",{className:Te("inline-flex flex-shrink-0 items-center text-muted-foreground/75",J),"aria-label":Wl,children:n.jsx(Z,{name:"check",className:"h-3.5 w-3.5"})})}):null,Hl=e("sessions.sidebar.session.status.permissionRequired"),gm=jl||Cl?n.jsxs(n.Fragment,{children:[jl?n.jsx(On,{label:Hl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":Hl,children:n.jsx(Z,{name:"shield",className:"h-3 w-3"})})}):null,Cl?n.jsx(On,{label:Ol,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":Ol,children:n.jsx(Z,{name:"question",className:"h-3 w-3"})})}):null]}):null,bm=ft&&dt?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,closeDelay:dh,children:n.jsxs("button",{type:"button",className:Te("inline-flex flex-shrink-0 items-center gap-1 rounded typography-micro hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",dt.color?"oc-ref-tint":"text-muted-foreground"),style:dt.color?Xn(dt.color):void 0,disabled:!dt.url,"aria-label":pt,onPointerDown:bi,onMouseDown:yi,onClick:J=>{J.preventDefault(),J.stopPropagation(),!(J.target instanceof Element&&J.target.closest("[data-ref-more]"))&&dt.url&&wt(dt.url,Q,J)},onKeyDown:J=>J.stopPropagation(),children:[n.jsx(Z,{name:dt.icon,className:"h-3 w-3"}),qe?null:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"leading-none tabular-nums",children:dt.label}),st>0?n.jsxs("span",{"data-ref-more":!0,className:"leading-none tabular-nums text-muted-foreground",children:["+",st]}):null]})]})}),n.jsx(Ot,{side:"top",sideOffset:6,className:"max-w-xs",children:n.jsx($o,{items:lt,directory:Q})})]}):null,ym=n.jsx(Ia,{compact:!ar(P),project:et,projectLabel:St,title:uo(hn,m),titleClassName:E||Et?"text-interactive-selection-foreground":El?"text-foreground":"text-foreground/80",branchLabel:we,spaceMark:De?e("sessions.sidebar.group.space"):null,statusDot:Pt?Zh:Hh?Vh:null,pinnedMarker:Gr&&!Pt?Xh:null,timeSlot:Uh?n.jsx(Bx,{sessionId:Se.id,running:ae,className:"typography-micro"}):ui,directoryIndicator:!d&&Q&&P!=="project"?n.jsx(_o,{directory:Q}):null,prBadge:bm,zombieIndicator:ft?gi:null,goal:wl,badges:gm,doneHint:mm(),providerId:ft?ye.model?.providerID??null:null,metaPaddingClass:ft&&Y?ie?"pe-13":"pe-7":void 0,hideMetaOnHoverClass:Y&&!U?"":Yh,actionsReserveClass:Gh,actionsMaskClass:qh}),xm=n.jsx(Ds,{align:"end",className:"min-w-[180px]",finalFocus:()=>Ae.current?(Ae.current=!1,!1):!ge.current,children:zl({Item:qt,Separator:wn,Sub:bf,SubTrigger:yf,SubContent:xf})}),Sm=n.jsx(aa,{children:n.jsx(la,{className:"app-region-no-drag z-50",children:n.jsx(ca,{"data-slot":"dropdown-menu-content",finalFocus:()=>Ae.current?(Ae.current=!1,!1):!ge.current,style:{color:"var(--surface-elevated-foreground)"},className:Te(Zi,"min-w-[180px]"),children:zl({Item:({className:J,...Dt})=>n.jsx(Uf,{className:Te(Mu,J),...Dt}),Separator:({className:J,...Dt})=>n.jsx(Vf,{className:Te(Nu,J),...Dt}),Sub:r1,SubTrigger:({className:J,children:Dt,...Vt})=>n.jsxs(o1,{className:Te(Fx,J),...Vt,children:[Dt,n.jsx(Z,{name:"arrow-right-s",className:"ms-auto size-3.5"})]}),SubContent:({className:J,children:Dt,...Vt})=>n.jsx(aa,{children:n.jsx(la,{className:"app-region-no-drag z-50",children:n.jsx(ca,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Te(Zi,J),...Vt,children:Dt})})})})})})});return n.jsxs(a.Fragment,{children:[n.jsx(P3,{sessionId:Se.id,dragKey:B??Wt,ownerKey:c??Ne,sessionDirectory:Q??null,sessionTitle:hn,archivedBucket:d,children:n.jsxs(qf,{open:Dl,onOpenChange:Lh,onOpenChangeComplete:Rl,children:[n.jsxs(Gf,{render:n.jsx("div",{"data-session-row":Se.id,"data-session-scope":Ne??"","data-session-archived":d?"1":"0","aria-current":E?"page":void 0,onClick:am,style:{paddingInlineStart:ft?Md:lr(r)},className:Te("oc-ref-tint-scope group relative my-0.5 flex cursor-pointer items-center rounded-md pe-2.5",!ft&&"gap-1.5",ft?qe?"py-1":"py-1.5":"py-[3px]",!(E||Et)&&"hover:bg-interactive-hover/60",(E||Et)&&"bg-interactive-selection/70 text-interactive-selection-foreground",Et&&"ring-1 ring-inset ring-border")}),children:[Qh,n.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:n.jsxs(Ft,{actionsRef:Ve.actionsRef,onOpenChange:Ve.onOpenChange,children:[n.jsx(Bt,{asChild:!0,closeDelay:0,disabled:U,children:n.jsx("div",{role:"button",tabIndex:0,"data-session-row-main":"",onKeyDown:J=>{J.target!==J.currentTarget||J.key!=="Enter"&&J.key!==" "||(J.preventDefault(),J.currentTarget.click())},"aria-pressed":jt?Et:void 0,onPointerDown:cm,onPointerUp:$l,onPointerCancel:$l,onPointerEnter:dm,onPointerLeave:_l,onFocus:um,onBlur:_l,onMouseDown:lm,onClick:J=>Ll(J),onDoubleClick:J=>{J.stopPropagation(),O(Se.id,hn)},className:Te("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none",je&&"bg-interactive-hover/70",ft||!Y?void 0:U?le:G),children:ym})}),U?null:n.jsx(Ot,{side:"right",sideOffset:8,className:"max-w-xs text-start",children:n.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-start text-xs",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{dir:"auto",className:"oc-ui-start-align min-w-0 truncate font-medium text-foreground",children:hn}),n.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:Bh,children:ui})]}),St?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[n.jsx(Z,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:St})]}):null,we?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[De?n.jsx(Z,{name:"box-3",className:"h-3 w-3 flex-shrink-0","aria-hidden":!1,role:"img","aria-label":e("sessions.sidebar.group.space")}):n.jsx(Z,{name:"git-branch",className:Te("h-3 w-3 flex-shrink-0",it&&"oc-ref-tint"),style:it?Xn(it):void 0}),n.jsx("span",{className:"min-w-0 truncate",children:we})]}):null,lt.length>0?n.jsx($o,{items:lt,directory:Q}):null,Kl?n.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:Kl}):null]})})]})}),gi&&!M&&!ft?n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 z-10",children:gi}):null,n.jsx("div",{className:Te("absolute inset-e-1 z-10 flex items-center gap-0.5 transition-opacity",ft&&!qe?"top-1.5 h-5":"top-1/2 -translate-y-1/2",ur||Y&&!U?"opacity-100":Te("opacity-0",ce)),children:n.jsxs(ri,{delayDuration:400,children:[Ee?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",className:Te("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",xi,ts?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":zs,onPointerDown:bi,onMouseDown:yi,onClick:pm,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:ts?"check":"eye",className:ts?hm:qr})})}),n.jsx(Ot,{side:"top",sideOffset:6,children:zs})]}):null,ie?n.jsx(t4,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:xi,iconSizeClass:qr,onPointerDown:bi,onMouseDown:yi,onArchive:sm,onDelete:nm}):null,me?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",className:Te("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-ring transition-opacity",xi),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:rm,onMouseDown:om,onClick:im,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"external-link",className:qr})})}),n.jsx(Ot,{side:"top",sideOffset:6,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,n.jsxs(Is,{open:Tl,onOpenChange:Fh,onOpenChangeComplete:Rl,children:[n.jsx(Ts,{asChild:!0,children:n.jsx("button",{type:"button",className:Te("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-ring transition-opacity",Y?"h-6 w-6 opacity-100":ur?"h-4 w-4 opacity-100":Te("h-4 w-4 opacity-0",ce)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:em,onMouseDown:tm,onClick:Jh,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"more-2",className:qr})})}),xm]})]})})]}),Sm]})}),kl&&_n?_:null,n.jsx(qs,{open:Me,onOpenChange:pe,children:n.jsxs(Gs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Js,{children:[n.jsx(Zs,{children:e("sessions.sidebar.session.export.dialog.title")}),n.jsx(Qs,{children:fi===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:fi}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:fi})})]}),n.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:Le,onChange:J=>yt(J.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),n.jsxs(kn,{children:[n.jsx(It,{type:"button",onClick:()=>pe(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),n.jsx(It,{type:"button",onClick:()=>{pe(!1),mi(Le)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},Se.id)}const Ad=t=>vt(t.session.directory??null),n4=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null)&&(t?.inSpace??!1)===(e?.inSpace??!1),r4=t=>{if(!t.openSidebarMenuKey)return null;if(t.rowKey&&(t.openSidebarMenuKey===`session-menu:${t.rowKey}`||t.openSidebarMenuKey===`session-context:${t.rowKey}`))return t.node.session.id;const e=t.archivedBucket?"archived":"active",s=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(s)?t.openSidebarMenuKey.slice(s.length):null},Od=t=>t.menuOpenSessionId??r4(t),ao=(t,e,s)=>e?s.has(t.node.session.id)?!0:or(t.node,e):!1,Ra=(t,e,s,r,o)=>{if(t.session.id!==e.session.id)return!0;const i=o(t);if(s.has(i)!==r.has(i)||t.children.length!==e.children.length)return!0;for(let c=0;c<t.children.length;c+=1)if(Ra(t.children[c],e.children[c],s,r,o))return!0;return!1},o4=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const s=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return Ra(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${s}:${o.session.id}`)||Ra(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},i4=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived&&t.time?.idle===e.time?.idle&&t.metadata===e.metadata&&Nf(t,e),a4=(t,e)=>{if(t.node.session.id!==e.node.session.id||!i4(t.node.session,e.node.session)||!X3(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(Ad(t.node)!==Ad(e.node))return"nodeDirectory";if(!n4(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&Xp(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&o4(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(ao(t,t.editingId,t.subtreeContainsEditing)||ao(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editingRowKey!==e.editingRowKey&&(t.editingRowKey===t.rowKey||e.editingRowKey===e.rowKey))return"editingRowKey";if(t.editTitle!==e.editTitle&&(ao(t,t.editingId,t.subtreeContainsEditing)||ao(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=Od(t),o=Od(e);if(or(t.node,r)||or(e.node,o))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&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.handleCopySessionId===e.handleCopySessionId&&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"},l4=(t,e)=>{const s=a4(t,e);return s===null?!0:(js(`ui.sidebar_session_node.props_changed.${s}`),!1)},c4=a.memo(s4,l4);function d4(t){return t.stopPropagation()}const u4=t=>{const{t:e}=Ct(),s=a.useRef(t.editingId),r=a.useRef(t.editTitle),o=a.useRef(t.deleteSessionConfirm);s.current=t.editingId,r.current=t.editTitle,o.current=t.deleteSessionConfirm;const i=de(j=>j.setSessionSwitcherOpen),c=xt(j=>j.setCurrentSession),l=xt(j=>j.updateSessionTitle),d=xt(j=>j.deleteSession),u=xt(j=>j.deleteSessions),f=xt(j=>j.archiveSession),p=xt(j=>j.archiveSessions),m=xt(j=>j.unarchiveSession),{mobileVariant:g,allowReselect:b,onSessionSelected:v,resetSessionSearch:x,descendantIds:y,showDeletionDialog:h,setDeleteSessionConfirm:S,setEditingId:w,setEditingRowKey:C,editingSessionId:k,editingOccurrenceKey:T,setEditTitle:O}=t,K=a.useCallback((j,P)=>{if(qi("navigation.session_select"),de.getState().closeMainSurfaces(),g&&i(!1),j===xt.getState().currentSessionId){b&&v?.(j),x();return}qi("navigation.session_state_set"),c(j,P??null),v?.(j),x()},[b,g,v,x,c,i]),R=a.useCallback((j,P)=>{w(j),C(T),O(P)},[T,O,w,C]),I=a.useCallback(async j=>{if(!s.current)return;const D=(j??r.current).trim();if(D)try{await l(k,D)}catch(V){console.error("[session-actions] rename failed",V),ze.error(e("sessions.sidebar.session.rename.error",{detail:Eu(V instanceof Error?V:new Error(String(V)),e)}))}w(null),C(null),O("")},[k,O,w,C,e,l]),N=a.useCallback(()=>{w(null),C(null),O("")},[O,w,C]),W=a.useCallback(j=>{ei(j).then(P=>{if(P.ok){ze.success(e("sessions.sidebar.session.copyId.success"));return}ze.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(e("sessions.sidebar.session.copyId.error")))},[e]),z=a.useCallback(async(j,P,D)=>{const V=P?.archivedBucket===!0||P?.hardDelete===!0,B=D?.descendantIds??y;await Jg(V?"delete":"archive",j,B,{archiveSession:f,archiveSessions:p,deleteSession:d,deleteSessions:u},e)},[f,p,d,u,y,e]),H=a.useCallback((j,P)=>{const D=P?.archivedBucket===!0||P?.hardDelete===!0,V=xu(j.id,y,D);if(!h||P?.skipConfirm===!0){z(j,P,{descendantIds:V});return}S({session:j,descendantCount:V.length,descendantIds:V,archivedBucket:D})},[y,z,S,h]),M=a.useCallback(async()=>{const j=o.current;if(!j)return;const{session:P,archivedBucket:D,descendantIds:V}=j;S(null),await z(P,{archivedBucket:D},{descendantIds:V})},[z,S]),Y=a.useCallback(async j=>{await m(j.id)?ze.success(e("sessions.sidebar.session.restore.success")):ze.error(e("sessions.sidebar.session.restore.error"))},[e,m]);return a.useMemo(()=>({handleSessionSelect:K,handleSessionDoubleClick:R,handleSaveEdit:I,handleCancelEdit:N,handleCopySessionId:W,handleDeleteSession:H,handleRestoreSession:Y,confirmDeleteSession:M}),[N,W,H,Y,I,R,K,M])};function f4(t){const e=Je.c(71),{t:s}=Ct(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:c,onConfirm:l}=t;let d,u,f,p,m,g,b,v,x,y;if(e[0]!==o||e[1]!==s||e[2]!==r){const P=s("sessions.sidebar.session.untitled");p=qs,x=!!r,e[13]!==o?(y=V=>{V||o(null)},e[13]=o,e[14]=y):y=e[14],f=Gs,b=!1,v="max-w-sm gap-5",u=Js;let D;e[15]!==s||e[16]!==r?.archivedBucket?(D=r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.title"):s("sessions.sidebar.dialogs.archiveSession.title"),e[15]=s,e[16]=r?.archivedBucket,e[17]=D):D=e[17],e[18]!==D?(g=n.jsx(Zs,{children:D}),e[18]=D,e[19]=g):g=e[19],d=Qs,m=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?s("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||P,count:r.descendantCount}):s("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||P,count:r.descendantCount}):r.descendantCount===1?s("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||P,count:r.descendantCount}):s("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||P,count:r.descendantCount}):r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||P}):s("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||P}),e[0]=o,e[1]=s,e[2]=r,e[3]=d,e[4]=u,e[5]=f,e[6]=p,e[7]=m,e[8]=g,e[9]=b,e[10]=v,e[11]=x,e[12]=y}else d=e[3],u=e[4],f=e[5],p=e[6],m=e[7],g=e[8],b=e[9],v=e[10],x=e[11],y=e[12];let h;e[20]!==d||e[21]!==m?(h=n.jsx(d,{children:m}),e[20]=d,e[21]=m,e[22]=h):h=e[22];let S;e[23]!==u||e[24]!==g||e[25]!==h?(S=n.jsxs(u,{children:[g,h]}),e[23]=u,e[24]=g,e[25]=h,e[26]=S):S=e[26];let w;e[27]!==c||e[28]!==i?(w=()=>c(!i),e[27]=c,e[28]=i,e[29]=w):w=e[29];const C=!i;let k;e[30]!==i?(k=i?n.jsx(Z,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Z,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=i,e[31]=k):k=e[31];let T;e[32]!==s?(T=s("sessions.sidebar.dialogs.neverAsk"),e[32]=s,e[33]=T):T=e[33];let O;e[34]!==k||e[35]!==T||e[36]!==w||e[37]!==C?(O=n.jsxs("button",{type:"button",onClick:w,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-ring","aria-pressed":C,children:[k,T]}),e[34]=k,e[35]=T,e[36]=w,e[37]=C,e[38]=O):O=e[38];let K;e[39]!==o?(K=()=>o(null),e[39]=o,e[40]=K):K=e[40];let R;e[41]!==s?(R=s("sessions.sidebar.dialogs.cancel"),e[41]=s,e[42]=R):R=e[42];let I;e[43]!==K||e[44]!==R?(I=n.jsx("button",{type:"button",onClick:K,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-ring",children:R}),e[43]=K,e[44]=R,e[45]=I):I=e[45];let N;e[46]!==l?(N=()=>{l()},e[46]=l,e[47]=N):N=e[47];let W;e[48]!==s||e[49]!==r?.archivedBucket?(W=r?.archivedBucket?s("sessions.sidebar.bulkActions.delete"):s("sessions.sidebar.bulkActions.archive"),e[48]=s,e[49]=r?.archivedBucket,e[50]=W):W=e[50];let z;e[51]!==N||e[52]!==W?(z=n.jsx("button",{type:"button",onClick:N,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:W}),e[51]=N,e[52]=W,e[53]=z):z=e[53];let H;e[54]!==I||e[55]!==z?(H=n.jsxs("div",{className:"flex items-center gap-2",children:[I,z]}),e[54]=I,e[55]=z,e[56]=H):H=e[56];let M;e[57]!==O||e[58]!==H?(M=n.jsxs(kn,{className:"w-full sm:items-center sm:justify-between",children:[O,H]}),e[57]=O,e[58]=H,e[59]=M):M=e[59];let Y;e[60]!==f||e[61]!==b||e[62]!==M||e[63]!==v||e[64]!==S?(Y=n.jsxs(f,{showCloseButton:b,className:v,children:[S,M]}),e[60]=f,e[61]=b,e[62]=M,e[63]=v,e[64]=S,e[65]=Y):Y=e[65];let j;return e[66]!==p||e[67]!==Y||e[68]!==x||e[69]!==y?(j=n.jsx(p,{open:x,onOpenChange:y,children:Y}),e[66]=p,e[67]=Y,e[68]=x,e[69]=y,e[70]=j):j=e[70],j}function p4(t){const e=Je.c(57),{t:s}=Ct(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:c,onConfirm:l}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let f;e[0]!==d||e[1]!==u||e[2]!==s?(f=s(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=s,e[3]=f):f=e[3];const p=f;let m;e[4]!==d||e[5]!==u||e[6]!==s?(m=d?u===1?s("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?s("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=s,e[7]=m):m=e[7];const g=m,b=!!r;let v;e[8]!==o?(v=j=>{j||o(null)},e[8]=o,e[9]=v):v=e[9];let x;e[10]!==p?(x=n.jsx(Zs,{children:p}),e[10]=p,e[11]=x):x=e[11];let y;e[12]!==g?(y=n.jsx(Qs,{children:g}),e[12]=g,e[13]=y):y=e[13];let h;e[14]!==x||e[15]!==y?(h=n.jsxs(Js,{children:[x,y]}),e[14]=x,e[15]=y,e[16]=h):h=e[16];let S;e[17]!==c||e[18]!==i?(S=()=>c(!i),e[17]=c,e[18]=i,e[19]=S):S=e[19];const w=!i;let C;e[20]!==i?(C=i?n.jsx(Z,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Z,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=i,e[21]=C):C=e[21];let k;e[22]!==s?(k=s("sessions.sidebar.dialogs.neverAsk"),e[22]=s,e[23]=k):k=e[23];let T;e[24]!==k||e[25]!==S||e[26]!==w||e[27]!==C?(T=n.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-ring","aria-pressed":w,children:[C,k]}),e[24]=k,e[25]=S,e[26]=w,e[27]=C,e[28]=T):T=e[28];let O;e[29]!==o?(O=()=>o(null),e[29]=o,e[30]=O):O=e[30];let K;e[31]!==s?(K=s("sessions.sidebar.dialogs.cancel"),e[31]=s,e[32]=K):K=e[32];let R;e[33]!==O||e[34]!==K?(R=n.jsx("button",{type:"button",onClick:O,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-ring",children:K}),e[33]=O,e[34]=K,e[35]=R):R=e[35];let I;e[36]!==l?(I=()=>{l()},e[36]=l,e[37]=I):I=e[37];let N;e[38]!==d||e[39]!==s?(N=s(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=s,e[40]=N):N=e[40];let W;e[41]!==I||e[42]!==N?(W=n.jsx("button",{type:"button",onClick:I,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:N}),e[41]=I,e[42]=N,e[43]=W):W=e[43];let z;e[44]!==R||e[45]!==W?(z=n.jsxs("div",{className:"flex items-center gap-2",children:[R,W]}),e[44]=R,e[45]=W,e[46]=z):z=e[46];let H;e[47]!==T||e[48]!==z?(H=n.jsxs(kn,{className:"w-full sm:items-center sm:justify-between",children:[T,z]}),e[47]=T,e[48]=z,e[49]=H):H=e[49];let M;e[50]!==H||e[51]!==h?(M=n.jsxs(Gs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[h,H]}),e[50]=H,e[51]=h,e[52]=M):M=e[52];let Y;return e[53]!==b||e[54]!==M||e[55]!==v?(Y=n.jsx(qs,{open:b,onOpenChange:v,children:M}),e[53]=b,e[54]=M,e[55]=v,e[56]=Y):Y=e[56],Y}function gh(t){const e=Je.c(36),{t:s}=Ct(),{value:r,setValue:o,onConfirm:i}=t,c=!!r;let l;e[0]!==o?(l=C=>{C||o(null)},e[0]=o,e[1]=l):l=e[1];let d;e[2]!==s?(d=s("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==d?(u=n.jsx(Zs,{children:d}),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==s||e[7]!==r?(f=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?s("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):s("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=s,e[7]=r,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx(Qs,{children:f}),e[9]=f,e[10]=p):p=e[10];let m;e[11]!==u||e[12]!==p?(m=n.jsxs(Js,{children:[u,p]}),e[11]=u,e[12]=p,e[13]=m):m=e[13];let g;e[14]!==o?(g=()=>o(null),e[14]=o,e[15]=g):g=e[15];let b;e[16]!==s?(b=s("sessions.sidebar.dialogs.cancel"),e[16]=s,e[17]=b):b=e[17];let v;e[18]!==g||e[19]!==b?(v=n.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-ring",children:b}),e[18]=g,e[19]=b,e[20]=v):v=e[20];let x;e[21]!==s?(x=s("sessions.sidebar.bulkActions.delete"),e[21]=s,e[22]=x):x=e[22];let y;e[23]!==i||e[24]!==x?(y=n.jsx("button",{type:"button",onClick:i,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]=i,e[24]=x,e[25]=y):y=e[25];let h;e[26]!==y||e[27]!==v?(h=n.jsxs(kn,{children:[v,y]}),e[26]=y,e[27]=v,e[28]=h):h=e[28];let S;e[29]!==h||e[30]!==m?(S=n.jsxs(Gs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[m,h]}),e[29]=h,e[30]=m,e[31]=S):S=e[31];let w;return e[32]!==c||e[33]!==l||e[34]!==S?(w=n.jsx(qs,{open:c,onOpenChange:l,children:S}),e[32]=c,e[33]=l,e[34]=S,e[35]=w):w=e[35],w}const h4=new Set;function m4(t){const e=Je.c(113),{node:s,depth:r,groupDirectory:o,projectId:i,folderOwnerKey:c,selectionScopeKey:l,archivedBucket:d,secondaryMeta:u,renderContext:f,rowKey:p,dragKey:m,renderExtras:g,pinnedSessionIds:b,expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:y,notifyOnSubtasks:h,editingId:S,editingRowKey:w,setEditingId:C,setEditingRowKey:k,editTitle:T,setEditTitle:O,toggleParent:K,openSidebarMenuKey:R,setOpenSidebarMenuKey:I,allowReselect:N,onSessionSelected:W,resetSessionSearch:z,deleteSessionConfirm:H,setDeleteSessionConfirm:M,startFolderRename:Y,startSessionWorktreeMenuLoad:j,mobileVariant:P,alwaysShowActions:D,renderChildren:V}=t,B=r===void 0?0:r,_=d===void 0?!1:d,F=f===void 0?"project":f,X=V===void 0?!0:V;js("ui.sidebar_tree_item.render");const oe=p??`${F}:${_?"archived":"active"}:${s.session.id}`,ne=Xt(x4),A=Xt(y4),te=de(b4),U=de(g4);let Pe;if(e[0]!==s){Pe=[];const Ie=Ye=>Ye.children.forEach(nt=>{Pe.push(nt.session.id),Ie(nt)});Ie(s),e[0]=s,e[1]=Pe}else Pe=e[1];const xe=Pe.join(`
1047
- `);let ce;e[2]!==xe?(ce=xe?xe.split(`
1048
- `):[],e[2]=xe,e[3]=ce):ce=e[3];const Oe=ce;let me;e[4]!==ne||e[5]!==Y||e[6]!==A?(me=(Ie,Ye)=>{if(!Ie)return null;Ye&&Xt.getState().collapsedFolderIds.has(Ye)&&A(Ye);const nt=ne(Ie,"New folder",Ye);return Y(Ie,nt),nt},e[4]=ne,e[5]=Y,e[6]=A,e[7]=me):me=e[7];const ie=me;let q;e[8]!==N||e[9]!==H||e[10]!==Oe||e[11]!==T||e[12]!==S||e[13]!==oe||e[14]!==P||e[15]!==s.session.id||e[16]!==W||e[17]!==z||e[18]!==M||e[19]!==O||e[20]!==C||e[21]!==k||e[22]!==te?(q={mobileVariant:P,allowReselect:N,onSessionSelected:W,resetSessionSearch:z,descendantIds:Oe,showDeletionDialog:te,setDeleteSessionConfirm:M,deleteSessionConfirm:H,editingId:S,setEditingId:C,setEditingRowKey:k,editingSessionId:s.session.id,editingOccurrenceKey:oe,editTitle:T,setEditTitle:O},e[8]=N,e[9]=H,e[10]=Oe,e[11]=T,e[12]=S,e[13]=oe,e[14]=P,e[15]=s.session.id,e[16]=W,e[17]=z,e[18]=M,e[19]=O,e[20]=C,e[21]=k,e[22]=te,e[23]=q):q=e[23];const ue=u4(q),ve=g?.childRenderExtrasFor,Ee=s.session.directory??o;let L;e[24]!==_||e[25]!==i||e[26]!==F||e[27]!==Ee?(L={groupDirectory:Ee,projectId:i,archivedBucket:_,renderContext:F},e[24]=_,e[25]=i,e[26]=F,e[27]=Ee,e[28]=L):L=e[28];const le=L,G=m??p??s.session.id,se=g?.subtreeContainsEditing??h4,je=g?.menuOpenSessionId??null,he=g?.nodeStructureKey??"",ge=g?.blockingBadgeSessionScopes,ke=g?.relativeTimeTick;let Ae;e[29]!==N||e[30]!==D||e[31]!==le||e[32]!==ve||e[33]!==H||e[34]!==B||e[35]!==T||e[36]!==S||e[37]!==w||e[38]!==v||e[39]!==c||e[40]!==x||e[41]!==P||e[42]!==s.children||e[43]!==y||e[44]!==h||e[45]!==W||e[46]!==R||e[47]!==b||e[48]!==X||e[49]!==z||e[50]!==l||e[51]!==M||e[52]!==O||e[53]!==C||e[54]!==k||e[55]!==I||e[56]!==Y||e[57]!==j||e[58]!==K?(Ae=X?s.children.map(Ie=>n.jsx(Ko,{node:Ie,pinnedSessionIds:b,expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:y,notifyOnSubtasks:h,editingId:S,editingRowKey:w,setEditingId:C,setEditingRowKey:k,editTitle:T,setEditTitle:O,toggleParent:K,openSidebarMenuKey:R,setOpenSidebarMenuKey:I,allowReselect:N,onSessionSelected:W,resetSessionSearch:z,deleteSessionConfirm:H,setDeleteSessionConfirm:M,startFolderRename:Y,startSessionWorktreeMenuLoad:j,mobileVariant:P,alwaysShowActions:D,depth:B+1,folderOwnerKey:c,selectionScopeKey:l,...le,renderExtras:ve?.(Ie)},Ie.session.id)):null,e[29]=N,e[30]=D,e[31]=le,e[32]=ve,e[33]=H,e[34]=B,e[35]=T,e[36]=S,e[37]=w,e[38]=v,e[39]=c,e[40]=x,e[41]=P,e[42]=s.children,e[43]=y,e[44]=h,e[45]=W,e[46]=R,e[47]=b,e[48]=X,e[49]=z,e[50]=l,e[51]=M,e[52]=O,e[53]=C,e[54]=k,e[55]=I,e[56]=Y,e[57]=j,e[58]=K,e[59]=Ae):Ae=e[59];let $;e[60]!==D||e[61]!==_||e[62]!==ie||e[63]!==B||e[64]!==T||e[65]!==S||e[66]!==w||e[67]!==oe||e[68]!==v||e[69]!==c||e[70]!==o||e[71]!==x||e[72]!==P||e[73]!==s||e[74]!==y||e[75]!==h||e[76]!==R||e[77]!==b||e[78]!==i||e[79]!==F||e[80]!==u||e[81]!==l||e[82]!==ue.handleCancelEdit||e[83]!==ue.handleCopySessionId||e[84]!==ue.handleDeleteSession||e[85]!==ue.handleRestoreSession||e[86]!==ue.handleSaveEdit||e[87]!==ue.handleSessionDoubleClick||e[88]!==ue.handleSessionSelect||e[89]!==O||e[90]!==C||e[91]!==k||e[92]!==I||e[93]!==j||e[94]!==G||e[95]!==se||e[96]!==je||e[97]!==he||e[98]!==ge||e[99]!==ke||e[100]!==Ae||e[101]!==K?($=n.jsx(c4,{expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:y,notifyOnSubtasks:h,editingId:S,editingRowKey:w,setEditingId:C,setEditingRowKey:k,editTitle:T,setEditTitle:O,handleSaveEdit:ue.handleSaveEdit,handleCancelEdit:ue.handleCancelEdit,toggleParent:K,handleSessionSelect:ue.handleSessionSelect,handleSessionDoubleClick:ue.handleSessionDoubleClick,handleCopySessionId:ue.handleCopySessionId,openSidebarMenuKey:R,setOpenSidebarMenuKey:I,createFolderAndStartRename:ie,handleDeleteSession:ue.handleDeleteSession,handleRestoreSession:ue.handleRestoreSession,startSessionWorktreeMenuLoad:j,mobileVariant:P,alwaysShowActions:D,pinnedSessionIds:b,node:s,depth:B,groupDirectory:o,projectId:i,folderOwnerKey:c,selectionScopeKey:l,archivedBucket:_,secondaryMeta:u,renderContext:F,rowKey:oe,dragKey:G,subtreeContainsEditing:se,menuOpenSessionId:je,nodeStructureKey:he,blockingBadgeSessionScopes:ge,relativeTimeTick:ke,children:Ae}),e[60]=D,e[61]=_,e[62]=ie,e[63]=B,e[64]=T,e[65]=S,e[66]=w,e[67]=oe,e[68]=v,e[69]=c,e[70]=o,e[71]=x,e[72]=P,e[73]=s,e[74]=y,e[75]=h,e[76]=R,e[77]=b,e[78]=i,e[79]=F,e[80]=u,e[81]=l,e[82]=ue.handleCancelEdit,e[83]=ue.handleCopySessionId,e[84]=ue.handleDeleteSession,e[85]=ue.handleRestoreSession,e[86]=ue.handleSaveEdit,e[87]=ue.handleSessionDoubleClick,e[88]=ue.handleSessionSelect,e[89]=O,e[90]=C,e[91]=k,e[92]=I,e[93]=j,e[94]=G,e[95]=se,e[96]=je,e[97]=he,e[98]=ge,e[99]=ke,e[100]=Ae,e[101]=K,e[102]=$):$=e[102];let fe;e[103]!==H||e[104]!==s.session.id||e[105]!==ue.confirmDeleteSession||e[106]!==M||e[107]!==U||e[108]!==te?(fe=H?.session.id===s.session.id?n.jsx(f4,{value:H,setValue:M,showDeletionDialog:te,setShowDeletionDialog:U,onConfirm:ue.confirmDeleteSession}):null,e[103]=H,e[104]=s.session.id,e[105]=ue.confirmDeleteSession,e[106]=M,e[107]=U,e[108]=te,e[109]=fe):fe=e[109];let be;return e[110]!==$||e[111]!==fe?(be=n.jsxs(n.Fragment,{children:[$,fe]}),e[110]=$,e[111]=fe,e[112]=be):be=e[112],be}function g4(t){return t.setShowDeletionDialog}function b4(t){return t.showDeletionDialog}function y4(t){return t.toggleFolderCollapse}function x4(t){return t.createFolder}const S4=(t,e)=>t.session.id===e.session.id&&t.session.title===e.session.title&&t.session.directory===e.session.directory&&t.session.parentID===e.session.parentID&&t.session.time?.created===e.session.time?.created&&t.session.time?.updated===e.session.time?.updated&&t.session.time?.archived===e.session.time?.archived&&Nf(t.session,e.session)&&vt(t.worktree?.path??null)===vt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,v4=(t,e)=>{if(t.node!==e.node&&!S4(t.node,e.node)||(t.renderExtras?.nodeStructureKey??"")!==(e.renderExtras?.nodeStructureKey??"")||(t.renderExtras?.menuOpenSessionId??null)!==(e.renderExtras?.menuOpenSessionId??null)||t.renderExtras?.relativeTimeTick!==e.renderExtras?.relativeTimeTick)return!1;const s=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(s)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(s)??!1)||(t.secondaryMeta?.projectLabel??null)!==(e.secondaryMeta?.projectLabel??null)||(t.secondaryMeta?.branchLabel??null)!==(e.secondaryMeta?.branchLabel??null)||(t.secondaryMeta?.inSpace??!1)!==(e.secondaryMeta?.inSpace??!1))return!1;const r=["depth","groupDirectory","projectId","folderOwnerKey","selectionScopeKey","archivedBucket","renderContext","rowKey","dragKey","renderChildren","hasSessionSearchQuery","normalizedSessionSearchQuery","notifyOnSubtasks","editingId","editingRowKey","editTitle","openSidebarMenuKey","mobileVariant","alwaysShowActions","allowReselect","pinnedSessionIds","expandedParents","deleteSessionConfirm","setEditingId","setEditingRowKey","setEditTitle","toggleParent","setOpenSidebarMenuKey","startSessionWorktreeMenuLoad","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const o of r)if(t[o]!==e[o])return!1;return!0},Ko=a.memo(m4,v4),w4=10,k4=4;function Bd(t){const e=Je.c(7),{providerIDs:s,ringClass:r}=t;let o;if(e[0]!==s||e[1]!==r){let c;e[3]!==r?(c=l=>n.jsx("span",{className:Te("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:n.jsx(wf,{providerId:l,className:"h-3 w-3"})},l),e[3]=r,e[4]=c):c=e[4],o=s.slice(0,k4).map(c),e[0]=s,e[1]=r,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=n.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:o}),e[5]=o,e[6]=i):i=e[6],i}function j4(t){const e=Je.c(97),{run:s,depth:r,laneNodes:o,blockingSessionIds:i,renderContext:c,projectId:l,projectLabel:d,expansionKey:u,expanded:f,forceExpanded:p,notifyOnSubtasks:m,toggleParent:g}=t,{t:b}=Ct();let v;e[0]!==s.key?(v=me=>me.runOverviewKey===s.key,e[0]=s.key,e[1]=v):v=e[1];const x=de(v),y=c==="mixed-compact",h=ar(c)||y;let S;e[2]!==l||e[3]!==c?(S=me=>c==="timeline-mixed"&&l?me.projects.find(ie=>ie.id===l)??null:null,e[2]=l,e[3]=c,e[4]=S):S=e[4];const w=Jt(S),C=s.lanes.length;let k;e[5]!==C||e[6]!==b?(k=C===1?b("sessions.sidebar.run.laneCountSingle",{count:C}):b("sessions.sidebar.run.laneCountPlural",{count:C}),e[5]=C,e[6]=b,e[7]=k):k=e[7];const T=k;let O;e[8]!==o?(O=[...o],e[8]=o,e[9]=O):O=e[9];const K=O;let R;e[10]!==K||e[11]!==i||e[12]!==m?(R=n.jsx(Iu,{nodes:K,blockingSessionIds:i,includeUnreadSubtasks:m}),e[10]=K,e[11]=i,e[12]=m,e[13]=R):R=e[13];const I=R,N=x?"text-interactive-selection-foreground":"text-foreground/80";let W;e[14]!==s.key?(W=()=>de.getState().setRunOverviewKey(s.key),e[14]=s.key,e[15]=W):W=e[15];const z=W;if(h){const me=s.key,ie=x?"page":void 0;let q;e[16]!==s.title||e[17]!==b?(q=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[16]=s.title,e[17]=b,e[18]=q):q=e[18];let ue;e[19]===Symbol.for("react.memo_cache_sentinel")?(ue={paddingInlineStart:w4},e[19]=ue):ue=e[19];const ve=y?"py-1":"py-1.5",Ee=x?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let L;e[20]!==ve||e[21]!==Ee?(L=Te("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md pe-2.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",ve,Ee),e[20]=ve,e[21]=Ee,e[22]=L):L=e[22];const le=s.title;let G;e[23]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(ra,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[23]=G):G=e[23];let se;e[24]!==T?(se=n.jsxs(n.Fragment,{children:[G,n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:T})]}),e[24]=T,e[25]=se):se=e[25];let je;e[26]!==s.lastActivity?(je=Rf(s.lastActivity),e[26]=s.lastActivity,e[27]=je):je=e[27];let he;e[28]!==s.providerIDs?(he=n.jsx(Bd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[28]=s.providerIDs,e[29]=he):he=e[29];let ge;e[30]!==I||e[31]!==y||e[32]!==d||e[33]!==s.title||e[34]!==se||e[35]!==je||e[36]!==he||e[37]!==w||e[38]!==N?(ge=n.jsx(Ia,{compact:y,project:w,projectLabel:d,title:le,titleClassName:N,branchLabel:null,metaLineLead:se,statusDot:I,pinnedMarker:null,timeSlot:je,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:he,hideMetaOnHoverClass:""}),e[30]=I,e[31]=y,e[32]=d,e[33]=s.title,e[34]=se,e[35]=je,e[36]=he,e[37]=w,e[38]=N,e[39]=ge):ge=e[39];let ke;return e[40]!==z||e[41]!==s.key||e[42]!==L||e[43]!==ge||e[44]!==ie||e[45]!==q?(ke=n.jsx("button",{type:"button","data-run-row":me,"aria-current":ie,"aria-label":q,onClick:z,style:ue,className:L,children:ge}),e[40]=z,e[41]=s.key,e[42]=L,e[43]=ge,e[44]=ie,e[45]=q,e[46]=ke):ke=e[46],ke}let H;e[47]!==u||e[48]!==p||e[49]!==g?(H=me=>{me.stopPropagation(),p||g(u)},e[47]=u,e[48]=p,e[49]=g,e[50]=H):H=e[50];const M=H,Y=s.key,j=x?"page":void 0;let P;e[51]!==r?(P=lr(r),e[51]=r,e[52]=P):P=e[52];let D;e[53]!==P?(D={paddingInlineStart:P},e[53]=P,e[54]=D):D=e[54];const V=x?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let B;e[55]!==V?(B=Te("group relative my-0.5 flex cursor-pointer items-center gap-1.5 rounded-md py-[3px] pe-2.5",V),e[55]=V,e[56]=B):B=e[56];let _;e[57]!==M?(_=me=>{(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),M(me))},e[57]=M,e[58]=_):_=e[58];let F;e[59]!==f||e[60]!==b?(F=b(f?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[59]=f,e[60]=b,e[61]=F):F=e[61];let X;e[62]!==f?(X=n.jsx(Ar,{expanded:f}),e[62]=f,e[63]=X):X=e[63];let oe;e[64]!==f||e[65]!==_||e[66]!==F||e[67]!==X||e[68]!==M?(oe=n.jsx("button",{type:"button",onClick:M,onKeyDown:_,className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":f,"aria-label":F,children:X}),e[64]=f,e[65]=_,e[66]=F,e[67]=X,e[68]=M,e[69]=oe):oe=e[69];let ne;e[70]!==z?(ne=me=>{me.stopPropagation(),z()},e[70]=z,e[71]=ne):ne=e[71];let A;e[72]!==s.title||e[73]!==b?(A=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[72]=s.title,e[73]=b,e[74]=A):A=e[74];let te;e[75]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx(ra,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[75]=te):te=e[75];let U;e[76]!==N?(U=Te("oc-ui-start-align block min-w-0 flex-1 truncate typography-ui-label font-normal",N),e[76]=N,e[77]=U):U=e[77];let Pe;e[78]!==s.title||e[79]!==U?(Pe=n.jsx("span",{dir:"auto",className:U,children:s.title}),e[78]=s.title,e[79]=U,e[80]=Pe):Pe=e[80];let xe;e[81]!==s.providerIDs?(xe=n.jsx(Bd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar"}),e[81]=s.providerIDs,e[82]=xe):xe=e[82];let ce;e[83]!==I||e[84]!==ne||e[85]!==A||e[86]!==Pe||e[87]!==xe?(ce=n.jsxs("button",{type:"button",onClick:ne,className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":A,children:[te,Pe,xe,I]}),e[83]=I,e[84]=ne,e[85]=A,e[86]=Pe,e[87]=xe,e[88]=ce):ce=e[88];let Oe;return e[89]!==z||e[90]!==s.key||e[91]!==D||e[92]!==B||e[93]!==oe||e[94]!==ce||e[95]!==j?(Oe=n.jsxs("div",{"data-run-row":Y,"aria-current":j,onClick:z,style:D,className:B,children:[oe,ce]}),e[89]=z,e[90]=s.key,e[91]=D,e[92]=B,e[93]=oe,e[94]=ce,e[95]=j,e[96]=Oe):Oe=e[96],Oe}const C4=a.memo(j4),P4=24,E4=t=>Array.from({length:Math.min(t,P4)},(e,s)=>s),I4=(t,e,s)=>{const r=new Set(t);for(const o of e)o>=0&&o<s&&r.add(o);return[...r].sort((o,i)=>o-i)},T4=(t,e)=>t.find(s=>s.end>e)?.index??0,D4={"pb-2":8,"pb-1.5":6},Fd=t=>`${t.kind}:${"renderContext"in t?t.renderContext:""}`,R4=(t,e)=>`${t.key}|${Gn(t,e)??""}`,N4=(t,e,s={})=>{const r=Gn(t,e),o=r?s.gapBySpacing?.get(r)??D4[r]:0;return(s.height??t.estimateSize)+o},Gn=(t,e)=>e?.kind==="activity-header"||e?.kind==="project-header"?"pb-2":e?.kind==="group-header"&&t.kind!=="project-header"?"pb-1.5":void 0,M4=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function A4({model:t,scrollElement:e,pinnedRowIndexes:s,renderRow:r,onFirstVisibleIndexChange:o}){const i=t.rows,c=a.useCallback(()=>e,[e]),l=a.useRef(new Map),d=a.useRef(new Map),u=a.useCallback(R=>{const I=i[R];if(!I)return 32;const N=i[R+1];return N4(I,N,{height:l.current.get(Fd(I)),gapBySpacing:d.current})},[i]),f=a.useCallback((R,I,N)=>{const W=p1(R,I,N),z=N.indexFromElement(R),H=i[z];if(H){const M=Gn(H,i[z+1]),Y=M&&Number.parseFloat(getComputedStyle(R).paddingBottom)||0;M&&d.current.set(M,Y),l.current.set(Fd(H),W-Y)}return W},[i]),p=a.useCallback(R=>{const I=i[R];return I?R4(I,i[R+1]):R},[i]),m=a.useRef(0),[g,b]=a.useState(null),v=g?.slidingIndexes,x=a.useCallback(R=>{const I=h1(R),N=v?.length?new Set([...s,...v]):s;return I4(I,N,i.length)},[s,i.length,v]),y=f1({count:i.length,enabled:e!==null,getScrollElement:c,estimateSize:u,measureElement:f,getItemKey:p,overscan:8,rangeExtractor:x}),h=y.getVirtualItems(),S=e?y.getTotalSize():0,w=e?Math.max(S-e.clientHeight,0):0,C=e?Math.min(e.scrollTop,w):0,k=T4(h,C);a.useLayoutEffect(()=>{o(k)},[k,o]);const T=a.useRef(null),O=a.useRef(null);if(a.useLayoutEffect(()=>{const R=O.current;if(!R||R.rows===i||!e||M4())return;const I=eb(R.rows,i);if(!I)return;const N=R.measurements,W=y.measurementsCache,z=N[I.previousHeaderIndex],H=W[I.nextHeaderIndex];if(!z||!H)return;const M=H.start-z.start,Y=I.opened?N[I.previousHeaderIndex+1]:N[I.blockEnd],j=I.opened?I.blockEnd:I.nextHeaderIndex+1,P=W[j],D=(Y?.start??z.end)+M,V=P?.start??H.end,B=e.scrollTop-e.clientHeight,_=e.scrollTop+e.clientHeight*2,F=new Set,X=[],oe=[];if(I.opened){for(let ne=I.blockStart;ne<I.blockEnd;ne+=1)F.add(i[ne].key);for(let ne=j;ne<W.length&&W[ne].start+D-V<_;ne+=1)oe.push(ne)}else for(let ne=I.blockStart;ne<I.blockEnd;ne+=1){const A=N[ne];!A||A.end+M<B||A.start+M>_||X.push({row:R.rows[ne],nextRow:R.rows[ne+1],start:A.start+M,end:A.end+M})}m.current+=1,b({id:m.current,revealKeys:F,ghosts:X,followingIndex:j,from:D,to:V,slidingIndexes:oe})},[i,e,y]),a.useLayoutEffect(()=>{O.current={rows:i,measurements:y.measurementsCache}}),a.useLayoutEffect(()=>{const R=T.current;if(!g||!R)return;const I={duration:sb,easing:tb},N=g.from-g.to,W=[];for(const H of R.children){if(!(H instanceof HTMLElement))continue;const M=H.dataset.sidebarRowKey??"",Y=Number(H.dataset.sidebarVirtualStart);H.dataset.sidebarGhost==="true"?W.push(H.animate(tc(Y,H.offsetHeight,g.from,g.to),{...I,fill:"forwards"})):g.revealKeys.has(M)?W.push(H.animate(tc(Y,H.offsetHeight,g.from,g.to),I)):Number(H.dataset.index)>=g.followingIndex&&N!==0&&W.push(H.animate([{transform:`translateY(${Y+N}px)`},{transform:`translateY(${Y}px)`}],I))}let z=!1;return Promise.all(W.map(H=>H.finished)).then(()=>{z||b(H=>H?.id===g.id?null:H)},()=>{}),()=>{z=!0;for(const H of W)H.cancel()}},[g]),!e){const R=E4(i.length),I=R.reduce((W,z)=>W+(i[z]?.estimateSize??0),0),N=i.reduce((W,z)=>W+z.estimateSize,0);return n.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[R.map(W=>{const z=i[W];return z?n.jsx("div",{className:Gn(z,i[W+1]),children:r(z,W)},z.key):null}),N>I?n.jsx("div",{"aria-hidden":"true",style:{height:N-I}}):null]})}const K=g?.ghosts.reduce((R,I)=>Math.max(R,I.end),0)??0;return n.jsxs("div",{ref:T,"data-sidebar-virtual-ready":"true",style:{height:Math.max(S,K),position:"relative"},children:[g?.ghosts.map(R=>n.jsx("div",{"aria-hidden":"true",inert:!0,className:`[&_[data-session-row]]:my-px ${Gn(R.row,R.nextRow)??""}`,"data-sidebar-ghost":"true","data-sidebar-row-key":R.row.key,"data-sidebar-virtual-start":R.start,style:{position:"absolute",top:0,left:0,width:"100%",pointerEvents:"none",transform:`translateY(${R.start}px)`},children:r(R.row,-1)},R.row.key)),h.map(R=>{const I=i[R.index];return I?n.jsx("div",{className:`[&_[data-session-row]]:my-px ${Gn(I,i[R.index+1])??""}`,"data-index":R.index,"data-sidebar-row-key":I.key,"data-sidebar-virtual-start":R.start,ref:y.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${R.start}px)`},children:r(I,R.index)},I.key):null})]})}const O4={pinned:"pushpin",work:"eye",chats:"chat-4"},B4={pinned:"sessions.sidebar.activity.pinnedTitle",work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle"},F4=t=>{const e=Je.c(33),{activityKey:s,collapsed:r,forceExpanded:o,alwaysShowActions:i,onToggle:c,onNewChat:l}=t,{t:d}=Ct(),u=s==="chats",f=o?void 0:c,p=u?"pe-10":"pe-3.5";let m;e[0]!==p?(m=Te("group flex w-full items-center gap-1.5 py-1 ps-4 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",p),e[0]=p,e[1]=m):m=e[1];const g=!r,b=O4[s],v=!o&&"group-hover:hidden";let x;e[2]!==v?(x=Te("h-3.5 w-3.5 text-muted-foreground/80",v),e[2]=v,e[3]=x):x=e[3];let y;e[4]!==b||e[5]!==x?(y=n.jsx(Z,{name:b,className:x}),e[4]=b,e[5]=x,e[6]=y):y=e[6];let h;e[7]!==r||e[8]!==o?(h=o?null:n.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:n.jsx(Z,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[7]=r,e[8]=o,e[9]=h):h=e[9];let S;e[10]!==y||e[11]!==h?(S=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[y,h]}),e[10]=y,e[11]=h,e[12]=S):S=e[12];const w=B4[s];let C;e[13]!==d||e[14]!==w?(C=d(w),e[13]=d,e[14]=w,e[15]=C):C=e[15];let k;e[16]!==C?(k=n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:C}),e[16]=C,e[17]=k):k=e[17];let T;e[18]!==o||e[19]!==f||e[20]!==S||e[21]!==k||e[22]!==m||e[23]!==g?(T=n.jsxs("button",{type:"button",onClick:f,disabled:o,className:m,"aria-expanded":g,children:[S,k]}),e[18]=o,e[19]=f,e[20]=S,e[21]=k,e[22]=m,e[23]=g,e[24]=T):T=e[24];let O;e[25]!==i||e[26]!==u||e[27]!==l||e[28]!==d?(O=u?n.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),l()},className:Te("absolute inset-e-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",i?"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":d("sessions.sidebar.header.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})}):null,e[25]=i,e[26]=u,e[27]=l,e[28]=d,e[29]=O):O=e[29];let K;return e[30]!==T||e[31]!==O?(K=n.jsxs("div",{className:"relative group/chats -ms-2.5 -me-2",children:[T,O]}),e[30]=T,e[31]=O,e[32]=K):K=e[32],K},bh=a.createContext(null);function Ld(t){let e=0,s=t;for(;s;){e+=s.offsetTop;const i=s.offsetParent;s=i instanceof HTMLElement?i:null}const r=t.closest("[data-sidebar-virtual-start]"),o=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(o)?o:0)}function L4(t){const e=Je.c(11),{suspended:s,layoutKey:r,scrollRef:o,children:i}=t,c=s===void 0?!1:s,l=r===void 0?"":r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[0]=d):d=e[0];const u=a.useRef(d),f=a.useRef(null);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=x=>(u.current.add(x),f.current?.(),()=>{u.current.delete(x),f.current?.()}),e[1]=p):p=e[1];const m=p;let g;e[2]!==o||e[3]!==c?(g=()=>{const x=o.current;if(c||!x)return;const y=document.createElement("div");y.dataset.sidebarCrossfadeLayer="true",y.className="pointer-events-none sticky top-0 z-30 h-0",y.style.marginBlock="0px",x.prepend(y);let h=null,S=null,w=null,C=0;const k=new Set;let T=[];const O=window.matchMedia("(prefers-reduced-motion: reduce)"),K=(M,Y)=>{const j=document.activeElement,P=j instanceof HTMLElement&&M.host.contains(j),D=P?x.scrollTop:null;Y.moveBefore&&Y.isConnected&&M.host.isConnected?Y.moveBefore(M.host,null):Y.append(M.host),P&&j.focus({preventScroll:!0}),D!==null&&x.scrollTop!==D&&(x.scrollTop=D)},R=()=>{w?.cancel(),w=null,S?.remove(),S=null},I=()=>{let M=null,Y=-1/0;for(const{entry:j,top:P}of T)P<=x.scrollTop&&P>=Y&&(Y=P,M=j);if(h!==M){if(R(),h&&M&&!O.matches){const j=h.host.cloneNode(!0);j instanceof HTMLElement&&(j.inert=!0,j.setAttribute("aria-hidden","true"),j.querySelectorAll("[id]").forEach(_4),j.className="pointer-events-none absolute inset-x-0 top-0 z-30",S=j)}h&&(K(h,h.slot),h.slot.style.removeProperty("height")),h=M,y.hidden=!M,M&&(M.slot.style.height=`${M.host.getBoundingClientRect().height}px`,K(M,y),S&&(y.append(S),w=S.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),w.onfinish=R))}},N=()=>{h&&(h.slot.style.height=`${h.host.getBoundingClientRect().height}px`);const M=Ld(x)+x.clientTop;T=Array.from(u.current,Y=>({entry:Y,top:Ld(Y.slot)-M})),I()},W=new ResizeObserver(N),z=new MutationObserver(()=>{cancelAnimationFrame(C),C=requestAnimationFrame(N)});W.observe(x);const H=()=>{z.disconnect();for(const M of k)u.current.has(M)||(W.unobserve(M.host),M.slot.parentElement&&W.unobserve(M.slot.parentElement),k.delete(M));for(const M of u.current){const Y=M.slot.closest("[data-sidebar-virtual-start]");Y&&z.observe(Y,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),k.has(M)||(W.observe(M.host),M.slot.parentElement&&W.observe(M.slot.parentElement),k.add(M))}cancelAnimationFrame(C),C=requestAnimationFrame(N)};return f.current=H,x.addEventListener("scroll",I,{passive:!0}),H(),N(),()=>{f.current=null,cancelAnimationFrame(C),x.removeEventListener("scroll",I),W.disconnect(),z.disconnect(),R(),y.hidden=!0,h&&(K(h,h.slot),h.slot.style.removeProperty("height")),y.remove()}},e[2]=o,e[3]=c,e[4]=g):g=e[4];let b;e[5]!==l||e[6]!==o||e[7]!==c?(b=[c,l,o],e[5]=l,e[6]=o,e[7]=c,e[8]=b):b=e[8],a.useLayoutEffect(g,b);let v;return e[9]!==i?(v=n.jsx(bh.Provider,{value:m,children:i}),e[9]=i,e[10]=v):v=e[10],v}function _4(t){return t.removeAttribute("id")}function $4(t){const e=Je.c(15);let s,r;e[0]!==t?({register:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=a.useRef(null),[i]=a.useState(z4);let c,l;e[3]!==i||e[4]!==r?(c=()=>{const m=o.current;if(!m)return;m.append(i);const g=r({slot:m,host:i});return()=>{g(),i.remove()}},l=[i,r],e[3]=i,e[4]=r,e[5]=c,e[6]=l):(c=e[5],l=e[6]),a.useLayoutEffect(c,l);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{ref:o}),e[7]=d):d=e[7];let u;e[8]!==s?(u=n.jsx("div",{...s}),e[8]=s,e[9]=u):u=e[9];let f;e[10]!==i||e[11]!==u?(f=Oa.createPortal(u,i),e[10]=i,e[11]=u,e[12]=f):f=e[12];let p;return e[13]!==f?(p=n.jsxs(n.Fragment,{children:[d,f]}),e[13]=f,e[14]=p):p=e[14],p}function z4(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function yh(t){const e=Je.c(3),s=a.useContext(bh);let r;return e[0]!==t||e[1]!==s?(r=s?n.jsx($4,{...t,register:s}):n.jsx("div",{...t}),e[0]=t,e[1]=s,e[2]=r):r=e[2],r}const K4=t=>{const e=Je.c(3),[s,r]=a.useState(!1);let o,i;return e[0]!==t?(o=()=>{if(!t){r(!1);return}let c=!0;const l=()=>{jo.getDirectoryAvailability(t).then(d=>{c&&d!=="unknown"&&r(d==="missing")})};return l(),window.addEventListener("focus",l),()=>{c=!1,window.removeEventListener("focus",l)}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),a.useEffect(o,i),s},Ki=t=>{const e=Je.c(27),{id:s,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:c,projectIconBackground:l,isCollapsed:d,alwaysShowActions:u,labelClassName:f}=t,p=u===void 0?!1:u,{currentTheme:m}=cr(),g=o?Ka[o]:null;let b;e[0]!==i?(b=Wa(i),e[0]=i,e[1]=b):b=e[1];const v=b,x=d!==void 0,y=x?p?"hidden":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0":void 0;let h;e[2]!==p||e[3]!==x||e[4]!==d?(h=x?n.jsx("span",{className:Te("h-3.5 w-3.5 items-center justify-center text-muted-foreground",p?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/project:opacity-100 group-focus-within/project:opacity-100"),children:n.jsx(Z,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[2]=p,e[3]=x,e[4]=d,e[5]=h):h=e[5];let S;e[6]!==p||e[7]!==m||e[8]!==x||e[9]!==v||e[10]!==y||e[11]!==s||e[12]!==l||e[13]!==c||e[14]!==g?(S=c?n.jsx("span",{className:Te("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",x&&p?"hidden":"inline-flex",y),style:l?{backgroundColor:l}:void 0,children:n.jsx(Ha,{project:{id:s,iconImage:c},options:{themeVariant:m.metadata.variant,iconColor:m.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?n.jsx(Z,{name:g,className:"h-3.5 w-3.5",style:v?{color:v}:void 0}):n.jsx(Z,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:v?{color:v}:void 0})})}):g?n.jsx(Z,{name:g,className:Te("h-3.5 w-3.5",y),style:v?{color:v}:void 0}):n.jsx(Z,{name:"folder",className:Te("h-3.5 w-3.5 text-muted-foreground/80",y),style:v?{color:v}:void 0}),e[6]=p,e[7]=m,e[8]=x,e[9]=v,e[10]=y,e[11]=s,e[12]=l,e[13]=c,e[14]=g,e[15]=S):S=e[15];let w;e[16]!==h||e[17]!==S?(w=n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[h,S]}),e[16]=h,e[17]=S,e[18]=w):w=e[18];let C;e[19]!==f?(C=Te("truncate typography-ui-header font-semibold text-foreground",f),e[19]=f,e[20]=C):C=e[20];let k;e[21]!==r||e[22]!==C?(k=n.jsx("span",{className:C,children:r}),e[21]=r,e[22]=C,e[23]=k):k=e[23];let T;return e[24]!==w||e[25]!==k?(T=n.jsxs(n.Fragment,{children:[w,k]}),e[24]=w,e[25]=k,e[26]=T):T=e[26],T},W4=t=>{const e=Je.c(67),{id:s,disabled:r,projectLabel:o,projectDescription:i,projectDirectory:c,projectIcon:l,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:p,isRepo:m,hideDirectoryControls:g,alwaysShowActions:b,onToggle:v,onNewSession:x,onNewWorktreeSession:y,onManageWorktrees:h,onManageSpaces:S,onOpenFolder:w,onRenameStart:C,onArchiveAll:k,onClose:T,children:O,showCreateButtons:K,hideHeader:R,statusIndicator:I,openSidebarMenuKey:N,setOpenSidebarMenuKey:W,projectPickerOptions:z,onProjectSelect:H}=t,M=r===void 0?!1:r,Y=K===void 0?!0:K,j=R===void 0?!1:R,P=I===void 0?null:I,{t:D}=Ct(),V=K4(c);let B;e[0]!==M||e[1]!==s?(B={id:s,disabled:M},e[0]=M,e[1]=s,e[2]=B):B=e[2];const{attributes:_,listeners:F,setNodeRef:X,transform:oe,transition:ne,isDragging:A}=Wr(B),te=a.useRef(!1),U=`project:${s}`,Pe=N===U,[xe,ce]=a.useState(!1),Oe=!!(z&&H);let me;e[3]!==U||e[4]!==W?(me=Ve=>{Ve&&ce(!1),W(Ve?U:null)},e[3]=U,e[4]=W,e[5]=me):me=e[5];const ie=me;let q;e[6]!==g||e[7]!==m||e[8]!==k||e[9]!==T||e[10]!==S||e[11]!==h||e[12]!==x||e[13]!==w||e[14]!==C||e[15]!==Y||e[16]!==D?(q=Ve=>n.jsxs(n.Fragment,{children:[Y&&!m&&!g&&x&&n.jsxs(Ve,{onClick:x,children:[n.jsx(Z,{name:"add",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.newSession")]}),m&&!g&&h&&n.jsxs(Ve,{onClick:h,children:[n.jsx(Z,{name:"node-tree",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.manageWorktrees")]}),m&&!g&&S&&n.jsxs(Ve,{onClick:S,children:[n.jsx(Z,{name:"box-3",className:"me-1.5 h-4 w-4"}),D("spaces.page.menuItem")]}),w&&n.jsxs(Ve,{onClick:w,children:[n.jsx(Z,{name:"folder-received",className:"me-1.5 h-4 w-4"}),D(df())]}),n.jsxs(Ve,{onClick:C,children:[n.jsx(Z,{name:"pencil-ai",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.edit")]}),k&&n.jsxs(Ve,{onClick:k,children:[n.jsx(Z,{name:"archive",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.archiveAll")]}),n.jsxs(Ve,{onClick:T,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=g,e[7]=m,e[8]=k,e[9]=T,e[10]=S,e[11]=h,e[12]=x,e[13]=w,e[14]=C,e[15]=Y,e[16]=D,e[17]=q):q=e[17];const ue=q,ve=U4,Ee=G4,L=q4;let le;e[18]===Symbol.for("react.memo_cache_sentinel")?(le=Ve=>{(Ve.button===2||Ve.button===0&&Ve.ctrlKey)&&(te.current=!0)},e[18]=le):le=e[18];const G=le;let se;e[19]!==v?(se=Ve=>{if(Ve.currentTarget.blur(),te.current){te.current=!1;return}v()},e[19]=v,e[20]=se):se=e[20];const je=se,ge=(Y&&m&&!g&&!!y?1:0)+(g?0:1),ke=ge===2?"[--oc-actions-reserve:66px]":ge===1&&Y?"[--oc-actions-reserve:38px]":Y||ge===1?"[--oc-actions-reserve:12px]":void 0,Ae=b?void 0:Pe?"oc-actions-mask":"group-hover/project:oc-actions-mask group-focus-within/project:oc-actions-mask",$=b?void 0:Pe?"opacity-0":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0";let fe;e[21]!==oe?(fe=Hr.Transform.toString(oe),e[21]=oe,e[22]=fe):fe=e[22];let be;e[23]!==fe||e[24]!==ne?(be={transform:fe,transition:ne},e[23]=fe,e[24]=ne,e[25]=be):be=e[25];const Ie=A&&"opacity-30";let Ye;e[26]!==Ie?(Ye=Te("relative",Ie),e[26]=Ie,e[27]=Ye):Ye=e[27];let nt;e[28]!==b||e[29]!==_||e[30]!==V||e[31]!==ie||e[32]!==je||e[33]!==ke||e[34]!==$||e[35]!==Ae||e[36]!==g||e[37]!==j||e[38]!==s||e[39]!==p||e[40]!==xe||e[41]!==Pe||e[42]!==Oe||e[43]!==m||e[44]!==F||e[45]!==x||e[46]!==y||e[47]!==H||e[48]!==d||e[49]!==i||e[50]!==c||e[51]!==l||e[52]!==f||e[53]!==u||e[54]!==o||e[55]!==z||e[56]!==ue||e[57]!==Y||e[58]!==P||e[59]!==D?(nt=j?null:n.jsx(n.Fragment,{children:n.jsxs(el,{open:xe,onOpenChange:ce,children:[n.jsx(Ja,{render:n.jsx(yh,{className:Te("-ms-2.5 -me-2 text-start group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:Ve=>{g||(Ve.preventDefault(),ce(!0))}}),children:n.jsxs("div",{className:"relative flex items-center gap-1 py-1 ps-4 pe-3.5",..._,children:[Oe?n.jsxs(Is,{children:[n.jsx(Ts,{asChild:!0,children:n.jsxs("button",{type:"button",className:Te("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",m&&!g?b||Pe?"pe-20":"pe-0 group-hover/project:pe-20 group-focus-within/project:pe-20":b||Pe?"pe-14":"pe-0 group-hover/project:pe-14 group-focus-within/project:pe-14"),"aria-label":D("sessions.sidebar.project.selectAria",{project:o}),children:[n.jsx(Ki,{id:s,projectLabel:o,projectIcon:l,projectColor:d,projectIconImage:u,projectIconBackground:f}),n.jsx(Z,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),c?n.jsx(_o,{directory:c,className:"ms-auto"}):null]})}),n.jsx(Ds,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:z?.map(Ve=>n.jsxs(qt,{onClick:()=>H?.(Ve.id),className:"flex items-center justify-between gap-3",title:Ve.projectDescription,children:[n.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:n.jsx(Ki,{...Ve})}),Ve.id===s?n.jsx(Z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},Ve.id))})]}):n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsxs("button",{type:"button",onMouseDown:G,onClick:je,...F,className:Te("@container flex-1 min-w-0 flex items-center gap-1.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing",b?m&&!g?"pe-20":"pe-14":ke),children:[n.jsx(Ki,{id:s,projectLabel:o,projectIcon:l,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:p,alwaysShowActions:b,labelClassName:Te("[--oc-actions-inset:20px]",Ae)}),V?n.jsx("span",{className:Te("inline-flex flex-shrink-0 items-center text-status-warning",$),title:D("sessions.sidebar.project.folderMissing"),"aria-label":D("sessions.sidebar.project.folderMissing"),children:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,P?n.jsx("span",{className:Te("ms-1 inline-flex flex-shrink-0 items-center",$),children:P}):null,c?n.jsx(_o,{directory:c,className:Te("ms-auto",$)}):null]})}),n.jsx(Ot,{side:"right",sideOffset:8,children:i})]}),n.jsxs("div",{className:Te("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",Y?"inset-e-7":"inset-e-0.5"),children:[Y&&m&&!g&&y?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ve=>{Ve.stopPropagation(),y()},className:Te("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-ring hover:text-foreground transition-opacity",b?"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":D("sessions.sidebar.project.actions.newWorktree"),children:n.jsx(Z,{name:"node-tree",className:"h-3.5 w-3.5"})})}),n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:D("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,g?null:n.jsxs(Is,{open:Pe,onOpenChange:ie,children:[n.jsx(Ts,{asChild:!0,children:n.jsx("button",{type:"button",className:Te("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-ring hover:text-foreground",Pe?"opacity-100 pointer-events-auto":b?"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":D("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Ee,onMouseDown:L,onClick:ve,children:n.jsx(Z,{name:"more-2",className:"h-3 w-3"})})}),n.jsx(Ds,{align:"end",className:"min-w-[180px]",children:ue(qt)})]})]}),Y&&x?n.jsx("div",{className:"absolute inset-e-0.5 top-1/2 z-10 -translate-y-1/2",children:n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ve=>{Ve.stopPropagation(),x()},className:Te("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-ring transition-opacity",b?"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":D(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:D(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),n.jsx(Qa,{className:"min-w-[180px]",children:ue(Bn)})]})}),e[28]=b,e[29]=_,e[30]=V,e[31]=ie,e[32]=je,e[33]=ke,e[34]=$,e[35]=Ae,e[36]=g,e[37]=j,e[38]=s,e[39]=p,e[40]=xe,e[41]=Pe,e[42]=Oe,e[43]=m,e[44]=F,e[45]=x,e[46]=y,e[47]=H,e[48]=d,e[49]=i,e[50]=c,e[51]=l,e[52]=f,e[53]=u,e[54]=o,e[55]=z,e[56]=ue,e[57]=Y,e[58]=P,e[59]=D,e[60]=nt):nt=e[60];let Ue;return e[61]!==O||e[62]!==X||e[63]!==be||e[64]!==Ye||e[65]!==nt?(Ue=n.jsxs("div",{ref:X,style:be,className:Ye,children:[nt,O]}),e[61]=O,e[62]=X,e[63]=be,e[64]=Ye,e[65]=nt,e[66]=Ue):Ue=e[66],Ue},H4=t=>{const e=Je.c(21),{id:s,disabled:r,children:o}=t,i=r===void 0?!1:r;let c;e[0]!==i||e[1]!==s?(c={id:s,disabled:i},e[0]=i,e[1]=s,e[2]=c):c=e[2];const{listeners:l,setNodeRef:d,setActivatorNodeRef:u,transform:f,transition:p,isDragging:m}=Wr(c);let g;e[3]!==l||e[4]!==u?(g={listeners:l,setActivatorNodeRef:u},e[3]=l,e[4]=u,e[5]=g):g=e[5];const b=g;let v;e[6]!==f?(v=Hr.Transform.toString(f),e[6]=f,e[7]=v):v=e[7];let x;e[8]!==v||e[9]!==p?(x={transform:v,transition:p},e[8]=v,e[9]=p,e[10]=x):x=e[10];const y=m&&"opacity-50";let h;e[11]!==y?(h=Te("space-y-0.5 rounded-md",y),e[11]=y,e[12]=h):h=e[12];let S;e[13]!==o||e[14]!==b?(S=o(b),e[13]=o,e[14]=b,e[15]=S):S=e[15];let w;return e[16]!==d||e[17]!==x||e[18]!==h||e[19]!==S?(w=n.jsx("div",{ref:d,style:x,className:h,children:S}),e[16]=d,e[17]=x,e[18]=h,e[19]=S,e[20]=w):w=e[20],w},V4=a.memo(H4);function U4(t){t.stopPropagation()}function G4(t){t.stopPropagation()}function q4(t){t.stopPropagation()}const _d=[],Y4=t=>{const e=Je.c(6),{nodes:s,includeUnreadSubtasks:r,children:o}=t;let i;e[0]!==r||e[1]!==s?(i={nodes:s,includeUnreadSubtasks:r},e[0]=r,e[1]=s,e[2]=i):i=e[2];const c=Pu(i);let l;return e[3]!==o||e[4]!==c?(l=o(c),e[3]=o,e[4]=c,e[5]=l):l=e[5],l},Wi=(t,e)=>e?t.sessions.some(s=>or(s,e)):!1,X4=(t,e,s)=>t.sessions.some(r=>Xp(r,r,e,s,t.directory,t.directory)),Z4=(t,e,s)=>{const r=o=>{const i=o.session.id;return e.get(i)!==s.get(i)?!0:o.children.some(r)};return t.sessions.some(r)},Q4=(t,e,s)=>{const r=t.isArchivedBucket?"archived":"active",o=i=>{const c=`project:${r}:${i.session.id}`;return e.has(c)!==s.has(c)?!0:i.children.some(o)};return t.sessions.some(o)},J4=(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&&X4(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&Z4(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&Q4(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Wi(e.group,t.editingId)||Wi(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Wi(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const s=e.group.isArchivedBucket===!0,r=Lo(e.group.sessions,t.openSidebarMenuKey,"project",s),o=Lo(e.group.sessions,e.openSidebarMenuKey,"project",s);if(r||o)return!1}if(t.folderRename!==e.folderRename){const s=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??vt(e.group.directory??null)];if(s.includes(t.folderRename?.scopeKey??null)||s.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.renderBody===e.renderBody&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.resetSessionSearch===e.resetSessionSearch&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename},e5=a.memo(function(e){const s=Je.c(23),{label:r,sessions:o,worktree:i}=e,{t:c}=Ct(),l=fh();let d;s[0]!==o||s[1]!==l||s[2]!==i?(d=y=>{y.stopPropagation(),Cn.requestDelete({sessions:o,mode:"worktree",worktree:i,skipDialogIfSafe:l||y.shiftKey})},s[0]=o,s[1]=l,s[2]=i,s[3]=d):d=s[3];const u=l?"text-destructive":"text-muted-foreground";let f;s[4]!==u?(f=Te("inline-flex h-6 w-6 items-center justify-center rounded-md hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u),s[4]=u,s[5]=f):f=s[5];let p;s[6]!==r||s[7]!==l||s[8]!==c?(p=l?c("sessions.sidebar.group.actions.deleteGroupAndBranchAria",{label:r}):c("sessions.sidebar.group.actions.deleteGroupAria",{label:r}),s[6]=r,s[7]=l,s[8]=c,s[9]=p):p=s[9];let m;s[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"}),s[10]=m):m=s[10];let g;s[11]!==d||s[12]!==f||s[13]!==p?(g=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:f,"aria-label":p,children:m})}),s[11]=d,s[12]=f,s[13]=p,s[14]=g):g=s[14];let b;s[15]!==l||s[16]!==c?(b=c(l?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),s[15]=l,s[16]=c,s[17]=b):b=s[17];let v;s[18]!==b?(v=n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b})}),s[18]=b,s[19]=v):v=s[19];let x;return s[20]!==g||s[21]!==v?(x=n.jsxs(Ft,{children:[g,v]}),s[20]=g,s[21]=v,s[22]=x):x=s[22],x}),$d=[];function t5(t){const{t:e}=Ct(),s=sl(),r=Vm(t.group.space?.id),{group:o,groupKey:i,projectId:c,hideGroupLabel:l,renderBody:d=!0,isEmpty:u=!1,hasSessionSearchQuery:f,normalizedSessionSearchQuery:p,groupSearchDataByGroup:m,visibleSessionCount:g,sessionBatchSize:b,collapsedGroups:v,hideDirectoryControls:x,showMoreGroupSessions:y,resetGroupSessionLimit:h,mobileVariant:S,alwaysShowActions:w,activeProjectId:C,setActiveProjectIdOnly:k,setSessionSwitcherOpen:T,openNewSessionDraft:O,pinnedSessionIds:K,sessionOrderIndex:R,notifyOnSubtasks:I,onToggleCollapsedGroup:N,dragHandleProps:W,compactBodyPadding:z=!1,expandedParents:H,editingId:M,editingRowKey:Y,openSidebarMenuKey:j,editTitle:P,folderRename:D,setFolderRenameDraft:V,clearFolderRename:B}=t,_=Xt(ae=>ae.toggleFolderCollapse),F=Xt(ae=>ae.renameFolder),X=Xt(ae=>ae.deleteFolder),oe=Xt(ae=>ae.addSessionToFolder),ne=de(ae=>ae.showDeletionDialog),[A,te]=a.useState(null),U=a.useCallback((ae,He)=>{const ut=R.get(ae.session.id),gt=R.get(He.session.id);if(ut!==void 0||gt!==void 0){if(ut===void 0)return 1;if(gt===void 0)return-1;if(ut!==gt)return ut-gt}return tl(ae.session,He.session,K,pf)},[K,R]),Pe=f?m.get(o):null,xe=f?!1:v.has(i),ce=$x(!o.isMain&&o.worktree?o.worktree.path:null),Oe=o.isMain||o.isArchivedBucket||l?null:vt(o.directory??null),me=o.isMain||o.isArchivedBucket||l?null:o.branch?.trim()||null,ie=Cf(Oe,me),q=ie?`var(--pr-${ie.visualState})`:void 0,ue=If(ie,e),ve=ie?qa(ie.provider,ie.number):"",Ee=ie?ue?`${ve} · ${ue}`:ve:void 0,L=Fr(),le=a.useMemo(()=>{const ae=o.folderScopes?.map(He=>vt(He.directory))??[vt(o.directory??null)];return[...new Set(ae.filter(He=>!!He))]},[o.directory,o.folderScopes]);a.useSyncExternalStore(a.useCallback(ae=>le.length>0?L.subscribeBootstrap(ae):()=>{},[le.length,L]),a.useCallback(()=>le.map(ae=>`${ae}\0${L.getBootstrapState(ae)??""}\0${L.getBootstrapFailure(ae)??""}\0${L.getInitializationState(ae)??""}\0${L.getInitializationFailure(ae)??""}`).join(""),[le,L]),a.useCallback(()=>"",[]));const G=le.some(ae=>{const He=L.getBootstrapState(ae);return He==="queued"||He==="running"}),se=le.find(ae=>L.getBootstrapState(ae)==="failed"||L.getInitializationState(ae)==="failed")??null,je=se!==null&&L.getBootstrapState(se)==="failed",he=se?je?L.getBootstrapFailure(se):L.getInitializationFailure(se):void 0,ge=he==="os-permission"&&hu(),[ke,Ae]=a.useState(!1),$=a.useCallback(()=>{se&&L.requestBootstrap({directory:se,priority:xe?"visible":"expanded",reason:o.isMain?"project-expanded":"worktree-expanded",force:!0})},[L,se,o.isMain,xe]),fe=a.useCallback(async()=>{if(!(!se||!ge||ke)){Ae(!0);try{(await mu(se)).success&&$()}finally{Ae(!1)}}},[ge,se,ke,$]),be=b??(x?10:7),Ie=Math.max(be,g??be),Ye=f?Pe?.groupMatches===!0:!1,nt=f,Ue=a.useMemo(()=>[...nt?Pe?.filteredNodes??[]:o.sessions].sort(U),[U,o.sessions,Pe?.filteredNodes,nt]),Ve=o.folderScopeKey??vt(o.directory??null),Se=Jn(c,o.directory),ye=a.useMemo(()=>o.folderScopes&&o.folderScopes.length>0?o.folderScopes:Ve?[{scopeKey:Ve,directory:o.directory??null}]:[],[Ve,o.directory,o.folderScopes]),Ge=Xt(rr(a.useCallback(ae=>ye.map(({scopeKey:He})=>ae.foldersMap[He]??_d),[ye]))),qe=a.useMemo(()=>ye.flatMap(({scopeKey:ae,directory:He},ut)=>(Ge[ut]??_d).map(Pt=>({folder:Pt,scopeKey:ae,scopeDirectory:He}))),[Ge,ye]),ft=Xt(rr(a.useCallback(ae=>new Set(Ge.flatMap(He=>He.filter(ut=>ae.collapsedFolderIds.has(ut.id)).map(ut=>ut.id))),[Ge]))),et=a.useMemo(()=>{const ae=new Map,He=ut=>{ut.forEach(gt=>{ae.set(gt.session.id,gt),gt.children.length>0&&He(gt.children)})};return He(Ue),ae},[Ue]),St=a.useMemo(()=>qe.map(({folder:ae,scopeKey:He,scopeDirectory:ut})=>{const gt=Ea(ae.sessionIds,et).sort(U);return{folder:ae,scopeKey:He,scopeDirectory:ut,nodes:gt}}),[qe,et,U]),we=a.useMemo(()=>{const ae=Yp(St.map(({folder:He,nodes:ut})=>({id:He.id,name:He.name,parentId:He.parentId,nodeCount:ut.length})),{archivedBucket:o.isArchivedBucket===!0,searchQuery:f?p:""});return St.filter(({folder:He})=>ae.has(He.id))},[St,o.isArchivedBucket,f,p]),De=M,ot=j,rt=a.useMemo(()=>new Set(we.flatMap(ae=>ae.folder.sessionIds)),[we]),Xe=a.useMemo(()=>Ue.filter(ae=>!rt.has(ae.session.id)),[Ue,rt]),ht=a.useMemo(()=>{const ae=new Map(we.map(He=>[He.folder.id,He]));return qp(we.map(He=>He.folder)).map(He=>ae.get(He.id)).filter(He=>!!He)},[we]),ee=a.useMemo(()=>{const ae=new Map;return we.forEach(He=>{if(!He.folder.parentId)return;const ut=ae.get(He.folder.parentId)??[];ut.push(He),ae.set(He.folder.parentId,ut)}),ae},[we]),_e=a.useMemo(()=>{const ae=new Map(we.map(gt=>[gt.folder.id,gt])),He=new Map,ut=(gt,Pt)=>{const Kt=He.get(gt);if(Kt!==void 0)return Kt;if(Pt.has(gt))return[];Pt.add(gt);const es=ae.get(gt),os=es?[...es.nodes]:[];for(const ps of ee.get(gt)??[])os.push(...ut(ps.folder.id,Pt));return He.set(gt,os),os};return we.forEach(({folder:gt})=>ut(gt.id,new Set)),He},[we,ee]),Be="project",Ke=a.useMemo(()=>{const ae=new Set;return dd(Ue,De,ae),we.forEach(({nodes:He})=>{dd(He,De,ae)}),ae},[Ue,we,De]),Fe=a.useMemo(()=>{if(!ot)return null;const ae=Lo(Ue,ot,Be,!!o.isArchivedBucket);if(ae)return ae;for(const{nodes:He}of we){const ut=Lo(He,ot,Be,!!o.isArchivedBucket);if(ut)return ut}return null},[ot,Ue,we,o.isArchivedBucket]),tt=a.useCallback(ae=>{const He=new WeakMap,ut=gt=>{He.set(gt,Mr(gt));for(const Pt of gt.children)ut(Pt)};return ae.forEach(ut),He},[]),bt=a.useMemo(()=>tt(Ue),[tt,Ue]),mt=a.useMemo(()=>{const ae=new WeakMap;return we.forEach(({nodes:He})=>{He.forEach(ut=>ae.set(ut,Mr(ut)))}),ae},[we]),it=a.useCallback(ae=>bt.get(ae)??mt.get(ae)??"",[bt,mt]),Tt=a.useCallback(ae=>({subtreeContainsEditing:Ke,menuOpenSessionId:Fe,nodeStructureKey:it(ae)}),[Ke,Fe,it]),at=Xe.length,$t=o.isArchivedBucket||f?Xe:Xe.slice(0,Ie),zt=at-$t.length,Mt=!o.isArchivedBucket&&!f&&at>be&&zt===0,Re=a.useCallback(ae=>{const He=[],ut=gt=>{gt.forEach(Pt=>{He.push(Pt.session),Pt.children.length>0&&ut(Pt.children)})};return ut(ae),He},[]),ct=a.useMemo(()=>Re(Ue),[Re,Ue]),lt=a.useMemo(()=>{if(ie||o.isMain||o.isArchivedBucket||l)return $d;const ae=new Map;for(const He of ct)for(const ut of nl(He))ae.has(ut.key)||ae.set(ut.key,ut);return ae.size>0?[...ae.values()]:$d},[ct,o.isArchivedBucket,o.isMain,ie,l]),dt=a.useMemo(()=>lt.flatMap(ae=>ae.source==="github"?[Ir("issue",ae)]:[]),[lt]),st=Do(dt),wt=a.useMemo(()=>lt.flatMap(ae=>ae.source==="linear"?[rl(ae.identifier)]:[]),[lt]),pt=Ef(wt),E=a.useMemo(()=>lt.flatMap(ae=>ae.source==="gitlab"?[Tr("issue",ae.ref)]:[]),[lt]),Q=Do(E),Ne=a.useMemo(()=>Tf(lt,st,pt,Q).map(ae=>({...ae,text:ae.statusKey?`${ae.label} · ${e(ae.statusKey)}`:ae.statusText?`${ae.label} · ${ae.statusText}`:ae.label})),[Q,st,lt,pt,e]),Ce=Ne[0]??null,We=a.useMemo(()=>{if(!o.isArchivedBucket)return new Map;const ae=new Map,He=new Map;for(const{folder:gt}of we){if(!gt.parentId)continue;const Pt=He.get(gt.parentId)??[];Pt.push(gt.id),He.set(gt.parentId,Pt)}const ut=(gt,Pt)=>{if(Pt.has(gt))return[];Pt.add(gt);const Kt=we.find(({folder:ps})=>ps.id===gt),es=Kt?Re(Kt.nodes):[],os=He.get(gt)??[];for(const ps of os)es.push(...ut(ps,Pt));return es};for(const{folder:gt}of we)ae.set(gt.id,ut(gt.id,new Set));return ae},[we,Re,o.isArchivedBucket]);if(f&&!Ye&&ht.length===0&&Xe.length===0)return null;const $e=!o.isMain&&!!o.branch,kt=o.branch&&zx(o.branch,o.label)?{label:o.branch}:null,jt=xe?n.jsx(Iu,{nodes:Ue,includeUnreadSubtasks:I}):null,Et=(ae,He)=>{const{folder:ut,scopeKey:gt,scopeDirectory:Pt,nodes:Kt}=ae,es=We.get(ut.id)??[],os=D?.folderId===ut.id&&D?.scopeKey===gt,ps=f?!1:ft.has(ut.id),Ht=hs=>n.jsx(ih,{folderId:ut.id,scopeKey:gt,ownerKey:Se,children:(ms,$s)=>n.jsx(oh,{folder:ut,displayName:He,sessions:Kt,isCollapsed:ps,collapsedActivityState:hs,onToggle:()=>_(ut.id),onRename:ts=>{F(gt,ut.id,ts)},onDelete:()=>{if(o.isArchivedBucket){Cn.requestDelete({sessions:es,mode:"session"});return}if(!ne){X(gt,ut.id);return}const ts=we.filter(({folder:zs})=>zs.parentId===ut.id).length,Fn=Kt.length;te({scopeKey:gt,folderId:ut.id,folderName:ut.name,subFolderCount:ts,sessionCount:Fn})},groupDirectory:Pt??o.directory,projectId:c,mobileVariant:S,alwaysShowActions:w,isRenaming:os,renameDraft:os?D?.draft:void 0,onRenameDraftChange:V,onRenameSave:()=>{const ts=D?.draft.trim()??"";ts&&F(gt,ut.id,ts),B()},onRenameCancel:B,droppableRef:ms,isDropTarget:$s,depth:0,onNewSession:()=>{c&&c!==C&&k(c),S&&T(!1),O({selectedProjectId:c,directoryOverride:Pt??o.directory,targetFolderId:ut.id,target:o.draftTarget})},hideActions:!1,archivedBucket:o.isArchivedBucket===!0,children:Kt.map(ts=>n.jsx(Ko,{node:ts,pinnedSessionIds:K,expandedParents:H,hasSessionSearchQuery:f,normalizedSessionSearchQuery:p,notifyOnSubtasks:I,editingId:M,editingRowKey:Y,editTitle:P,openSidebarMenuKey:j,mobileVariant:S,alwaysShowActions:w,groupDirectory:Pt??o.directory,projectId:c,folderOwnerKey:Se,selectionScopeKey:Se,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Ke,menuOpenSessionId:Fe,nodeStructureKey:it(ts),childRenderExtrasFor:Tt},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},ts.session.id))})},ut.id);return ps?n.jsx(Y4,{nodes:_e.get(ut.id)??Kt,includeUnreadSubtasks:I,children:Ht},ut.id):Ht(null)},Lt=()=>{const ae=new Map;for(const Pt of we){const Kt=Pt.folder.parentId;if(!Kt)continue;const es=ae.get(Kt);es?es.push(Pt):ae.set(Kt,[Pt])}const He=[],ut=new Set,gt=(Pt,Kt)=>{if(ut.has(Pt.folder.id))return;ut.add(Pt.folder.id);const es=Kt?`${Kt} / ${Pt.folder.name}`:Pt.folder.name;He.push(Et(Pt,es)),!(!f&&ft.has(Pt.folder.id))&&(ae.get(Pt.folder.id)??[]).forEach(ps=>gt(ps,es))};return ht.forEach(Pt=>gt(Pt,"")),He},Yt=!!(!o.isMain&&o.worktree&&!ce),is=o.worktree?.worktreeStatus==="missing"?n.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:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,Wt=o.space&&o.space.state!=="complete"?n.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.spaceStale"),"aria-label":e("sessions.sidebar.group.spaceStale"),children:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,rs=Yt||!!o.space,as=!!o.space,Ss=w?as?"pe-20":rs?"pe-14":"pe-7":Te("pe-2",as?"[--oc-actions-reserve:68px]":rs?"[--oc-actions-reserve:44px]":"[--oc-actions-reserve:18px]"),Me=w?void 0:"group-hover/gh:oc-actions-mask group-focus-within/gh:oc-actions-mask",pe=w?void 0:"transition-opacity group-hover/gh:opacity-0 group-focus-within/gh:opacity-0",Le=u?n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}):n.jsx(Ar,{expanded:!xe}),yt=ie&&ue?[{key:`pr:${ie.number}`,icon:"git-pull-request",text:`${ve} · ${ue}`,title:ie.title,color:q,url:ie.url}]:[],Rt=se?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(he==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":je?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),ge?n.jsx(It,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ke,onClick:()=>{fe()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,n.jsx(It,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:$,children:e("sessions.sidebar.group.empty.retry")})]}):null,Nt=ae=>n.jsx(Ko,{node:ae,pinnedSessionIds:K,expandedParents:H,hasSessionSearchQuery:f,normalizedSessionSearchQuery:p,notifyOnSubtasks:I,editingId:M,editingRowKey:Y,editTitle:P,openSidebarMenuKey:j,mobileVariant:S,alwaysShowActions:w,groupDirectory:o.directory,projectId:c,folderOwnerKey:Se,selectionScopeKey:Se,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Ke,menuOpenSessionId:Fe,nodeStructureKey:it(ae),childRenderExtrasFor:Tt},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},ae.session.id),re=n.jsxs(E3,{scopeKey:ye[0]?.scopeKey??Ve,ownerKey:Se,hasFolders:we.length>0,onSessionDroppedOnFolder:(ae,He)=>{const ut=we.find(({folder:Pt,scopeKey:Kt})=>Pt.id===He.folderId&&Kt===He.scopeKey);if(!ut)return;const gt=Xt.getState();for(const{scopeKey:Pt}of ye)Pt!==ut.scopeKey&&gt.getSessionFolderId(Pt,ae)&&gt.removeSessionFromFolder(Pt,ae);oe(ut.scopeKey,He.folderId,ae)},children:[Lt(),$t.map(Nt),at===0&&we.length===0&&!r?!o.isArchivedBucket&&!G&&!Rt&&o.directory&&!o.emptyMessage?n.jsx(It,{variant:"link",size:"xs",className:"w-full justify-start ps-[26px] text-start font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{c&&c!==C&&k(c),S&&T(!1),O({selectedProjectId:c,directoryOverride:o.directory,target:o.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-muted-foreground",children:o.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):G?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Z,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Rt||(o.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,at>0&&Rt?n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-status-error",children:Rt}):null,zt>0?n.jsx("button",{type:"button",onClick:()=>y(i,$t.length,b??7),className:"mt-0.5 flex items-center justify-start rounded-md ps-[26px] pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,Mt?n.jsx("button",{type:"button",onClick:()=>h(i),className:"mt-0.5 flex items-center justify-start rounded-md ps-[26px] pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),Ze="pb-2",Qe=n.jsx(gh,{value:A,setValue:te,onConfirm:()=>{const ae=A;ae&&(X(ae.scopeKey,ae.folderId),te(null))}});return l?d?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"oc-group",children:n.jsx("div",{className:Te("oc-group-body",Ze),children:re})}),Qe]}):null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:Te("oc-group",ce&&"opacity-60"),"aria-busy":ce||void 0,children:[n.jsxs("div",{className:Te("oc-ref-tint-scope group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md hover:bg-interactive-hover/60","cursor-pointer"),children:[n.jsxs(Ft,{disabled:ie?!ue:!Ce,children:[n.jsx(Bt,{asChild:!0,closeDelay:dh,children:n.jsx("div",{className:"min-w-0 flex-1",...u?{}:{onClick:()=>N(i),role:"button",tabIndex:0,onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),N(i))},"aria-label":xe?e("sessions.sidebar.group.expandAria",{label:o.label}):e("sessions.sidebar.group.collapseAria",{label:o.label}),"aria-expanded":!xe},children:n.jsxs("div",{ref:W?.setActivatorNodeRef,style:{paddingInlineStart:lr(0)},className:Te("@container min-w-0 flex flex-1 items-start gap-1 overflow-hidden",Ss),...W?.listeners??{},children:[n.jsxs("div",{className:Te("min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",Me),children:[n.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:o.isArchivedBucket?n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-0.5",children:[Le,n.jsx(Z,{name:"archive",className:"mx-px h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:uo(o.label,p)}),is,jt]}):!o.isMain||o.worktree?n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-0.5",children:[Le,ce?n.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-muted-foreground",title:e("sessions.sidebar.group.worktreeRemoving"),role:"status","aria-label":e("sessions.sidebar.group.worktreeRemoving"),children:n.jsx(Z,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"})}):n.jsx(Z,{name:o.space?"box-3":"git-branch",className:Te("mx-px h-3 w-3 shrink-0",q?"oc-ref-tint":"text-muted-foreground"),style:q?Xn(q):void 0,"aria-label":o.space?e("sessions.sidebar.group.space"):void 0}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label font-medium text-foreground",children:uo(o.label,p)}),is,Wt,jt,ie?n.jsx("button",{type:"button",className:Te("ms-auto flex-shrink-0 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",q&&"oc-ref-tint",pe),style:q?Xn(q):void 0,disabled:!ie.url,"aria-label":Ee,onPointerDown:ae=>ae.stopPropagation(),onKeyDown:ae=>ae.stopPropagation(),onClick:ae=>{ae.stopPropagation(),ie.url&&s(ie.url,o.directory??null,ae)},children:ve}):Ce?n.jsxs("button",{type:"button",className:Te("ms-auto inline-flex flex-shrink-0 items-center gap-1 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Ce.color?"oc-ref-tint":"text-muted-foreground",pe),style:Ce.color?Xn(Ce.color):void 0,"aria-label":Ne.map(ae=>ae.text).join(", "),onPointerDown:ae=>ae.stopPropagation(),onKeyDown:ae=>ae.stopPropagation(),onClick:ae=>{ae.stopPropagation(),!(ae.target instanceof Element&&ae.target.closest("[data-ref-more]"))&&s(Ce.url,o.directory??null,ae)},children:[n.jsx(Z,{name:Ce.icon,className:"h-3 w-3"}),Ce.label,Ne.length>1?n.jsxs("span",{"data-ref-more":!0,className:"text-muted-foreground",children:["+",Ne.length-1]}):null]}):null]}):n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[Le,n.jsx("span",{className:"min-w-0 truncate",children:uo(o.label,p)}),jt]})}),$e&&kt?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[o.isArchivedBucket?n.jsx(Z,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx(Z,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:kt.label})]}):null]}),!o.isArchivedBucket&&o.directory?n.jsx(_o,{directory:o.directory,className:Te("self-center",pe)}):null]})})}),yt.length>0?n.jsx(Ot,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx($o,{items:yt,directory:o.directory??null})}):!ie&&Ce?n.jsx(Ot,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx($o,{items:Ne,directory:o.directory??null})}):null]}),n.jsxs(ri,{delayDuration:400,children:[o.isArchivedBucket&&ct.length>0?n.jsx("div",{className:Te("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),Cn.requestDelete({sessions:ct,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-ring","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:o.label}),children:n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,o.directory&&!o.isMain&&o.worktree&&!ce?n.jsx("div",{className:Te("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsx(e5,{label:o.label,sessions:ct,worktree:o.worktree})}):null,o.space?n.jsx("div",{className:Te("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),o.space&&Vs.getState().openAccessDialog(o.space.id)},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-ring","aria-label":e("spaces.group.access.giveAria",{label:o.label}),children:n.jsx(Z,{name:"key",className:"h-3.5 w-3.5"})})}),n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,o.space?n.jsx("div",{className:Te("absolute inset-e-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:n.jsx(nb,{spaceId:o.space.id,label:o.label})}):null,o.directory?n.jsx("div",{className:Te("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),c&&c!==C&&k(c),S&&T(!1),O({selectedProjectId:c,directoryOverride:o.directory,preserveDirectoryOverride:!!o.space})},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-ring","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:o.label}),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]})]}),o.space?n.jsx(rb,{spaceId:o.space.id,className:"pb-1 ps-5"}):null,!xe&&d?n.jsx("div",{className:Te("oc-group-body",Ze),children:re}):null]}),Qe]})}const s5=a.memo(t5,J4),Hi=({projectId:t,mobileVariant:e,closeMobileSwitcher:s,setActiveProjectIdOnly:r,setSessionSwitcherOpen:o})=>{t&&r(t),e&&s&&o(!1)},n5=(t,e)=>{const s=new Set;for(const r of t)if(!r.isArchivedBucket)for(const o of r.sessions){const{session:i}=o;i.time?.archived||e(i)||s.add(i.id)}return[...s]},zd=10,Kd=(t,e)=>jf(t.label?.trim()||Qo(t.normalizedPath,e)||t.normalizedPath);function r5(t){const e=Je.c(103),{model:s,view:r,actions:o}=t;js("ui.sidebar_projects_list.render");const{t:i}=Ct(),c=Fr(),{files:l}=_s(),d=Xt(m5),u=Xt(h5),f=Xt(p5),p=Xt(f5),m=de(u5),g=de(d5)&&!Pn(),[b,v]=a.useState(null),[x,y]=a.useState(null),[h,S]=a.useState(null),[w,C]=a.useState(null),[k,T]=a.useState(null),O=k?.kind==="project",K=a.useRef(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{distance:8}},e[0]=R):R=e[0];let I;e[1]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{delay:200,tolerance:6}},e[1]=I):I=e[1];let N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N={coordinateGetter:Hf},e[2]=N):N=e[2];const W=Lr(Fs($r,R),Fs(_r,I),Fs(Wf,N));let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=$=>{K.current=$,C($)},e[3]=z):z=e[3];const H=z;let M;if(e[4]!==s.projectSections||e[5]!==r.homeDirectory){let $;e[7]!==r.homeDirectory?($=fe=>({id:fe.project.id,projectLabel:Kd(fe.project,r.homeDirectory),projectDescription:nr(fe.project.normalizedPath,r.homeDirectory),projectIcon:fe.project.icon,projectColor:fe.project.color,projectIconImage:fe.project.iconImage,projectIconBackground:fe.project.iconBackground}),e[7]=r.homeDirectory,e[8]=$):$=e[8],M=s.projectSections.map($),e[4]=s.projectSections,e[5]=r.homeDirectory,e[6]=M}else M=e[6];const Y=M,j=Kx(),{confirm:P}=j;let D;e[9]!==P||e[10]!==i?(D=async($,fe)=>{const be=kf.getState().ids,Ie=n5(fe,Ve=>ni(be,Ve.directory,Ve.id)||Bu(Ve.id)||ol(Ve));if(Ie.length===0){ze.info(i("sessions.sidebar.project.archiveAll.nothing"));return}if(!await P({title:i("sessions.sidebar.project.archiveAll.title",{project:$}),message:Ie.length===1?i("sessions.sidebar.project.archiveAll.descriptionSingle",{count:Ie.length}):i("sessions.sidebar.project.archiveAll.descriptionPlural",{count:Ie.length}),action:i("sessions.sidebar.bulkActions.archive")}))return;const{archivedIds:nt,failedIds:Ue}=await xt.getState().archiveSessions(Ie);nt.length>0&&ze.success(nt.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:nt.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:nt.length})),Ue.length>0&&ze.error(Ue.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Ue.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:Ue.length}))},e[9]=P,e[10]=i,e[11]=D):D=e[11];const V=D;let B;e[12]!==l||e[13]!==i?(B=$=>{l.revealPath&&l.revealPath($).catch(()=>{ze.error(i("sidebarFilesTree.toast.revealFailed"))})},e[12]=l,e[13]=i,e[14]=B):B=e[14];const _=B;let F;e[15]!==x?(F=$=>`${$.kind}:${$.id}`===x,e[15]=x,e[16]=F):F=e[16];const X=s.rowModel.stickyHeaders.findIndex(F);let oe;if(e[17]!==h||e[18]!==s.groupProps.editingRowKey||e[19]!==s.rowModel.rowIndexByKey||e[20]!==s.rowModel.rows||e[21]!==s.rowModel.stickyHeaders||e[22]!==s.state.openSidebarMenuKey||e[23]!==X){if(oe=new Set,h){let $;e[25]!==h||e[26]!==s.rowModel.rowIndexByKey?($=s.rowModel.rowIndexByKey.get(h),e[25]=h,e[26]=s.rowModel.rowIndexByKey,e[27]=$):$=e[27];const fe=$;fe!==void 0&&oe.add(fe)}for(let $=0;$<s.rowModel.rows.length;$=$+1,$){const fe=s.rowModel.rows[$];fe?.kind==="session"&&(s.groupProps.editingRowKey===fe.key||s.state.openSidebarMenuKey===`session-menu:${fe.key}`||s.state.openSidebarMenuKey===`session-context:${fe.key}`)&&oe.add($)}if(X>=0){const $=Math.max(0,X-1),fe=Math.min(s.rowModel.stickyHeaders.length-1,X+1);for(let be=$;be<=fe;be=be+1,be){const Ie=s.rowModel.stickyHeaders[be];Ie&&oe.add(Ie.rowIndex)}}e[17]=h,e[18]=s.groupProps.editingRowKey,e[19]=s.rowModel.rowIndexByKey,e[20]=s.rowModel.rows,e[21]=s.rowModel.stickyHeaders,e[22]=s.state.openSidebarMenuKey,e[23]=X,e[24]=oe}else oe=e[24];const ne=oe;let A;e[28]!==s.rowModel.stickyHeaders?(A=$=>{const fe=K2(s.rowModel.stickyHeaders,$),be=fe?`${fe.kind}:${fe.id}`:null;y(Ie=>Ie===be?Ie:be)},e[28]=s.rowModel.stickyHeaders,e[29]=A):A=e[29];const te=A;let U;e[30]!==c||e[31]!==i?(U=$=>{const fe=()=>{if(!$.status.directory){Mf();return}c.requestBootstrap({directory:$.status.directory,priority:"expanded",reason:$.group.isMain?"project-expanded":"worktree-expanded",force:!0})},be=async()=>{if(!$.status.directory)return;(await mu($.status.directory)).success&&fe()};let Ie;e:switch($.status.state){case"permission-denied":{Ie=i("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Ie=i("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Ie=i("sessions.sidebar.group.empty.initializationFailed");break e}default:Ie=i("sessions.sidebar.group.empty.loadingSessions")}return n.jsx("div",{className:"relative py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:$.flat?zd:Pd($.depth??0)},children:n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[$.status.state==="loading"?n.jsx(Z,{name:"loader-4",className:"size-3 animate-spin"}):null,Ie,$.status.canGrantAccess?n.jsx(It,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{be()},children:i("sessions.sidebar.group.empty.grantAccess")}):null,$.status.state!=="loading"?n.jsx(It,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:fe,children:i("sessions.sidebar.group.empty.retry")}):null]})})},e[30]=c,e[31]=i,e[32]=U):U=e[32];const Pe=U;let xe;e[33]!==o||e[34]!==f||e[35]!==l||e[36]!==s.emptyState||e[37]!==s.groupProps||e[38]!==s.projectRepoStatus||e[39]!==s.searchEmptyState||e[40]!==s.singleProjectMode||e[41]!==s.state||e[42]!==_||e[43]!==Y||e[44]!==u||e[45]!==Pe||e[46]!==V||e[47]!==m||e[48]!==g||e[49]!==i||e[50]!==d||e[51]!==r?(xe=$=>{if($.kind==="activity-header")return n.jsx(yh,{className:"sticky top-0 z-20 bg-sidebar","data-sidebar-sticky-header":"true",children:n.jsx(F4,{activityKey:$.activityKey,collapsed:$.collapsed,forceExpanded:$.forceExpanded,alwaysShowActions:r.alwaysShowActions,onToggle:()=>{if(!$.collapsed){const be=`activity:${$.activityKey}`;o.group.resetGroupSessionLimit(be),s.state.setVisibleActivityCountByKey(Ie=>{if(!Ie.has(be))return Ie;const Ye=new Map(Ie);return Ye.delete(be),Ye})}s.state.setCollapsedActivityKeys(be=>{const Ie=new Set(be);return Ie.has($.activityKey)?Ie.delete($.activityKey):Ie.add($.activityKey),Ie})},onNewChat:()=>{de.getState().closeMainSurfaces(),r.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:Um,directoryOverride:null})}})});if($.kind==="project-header"){const be=$.section.project,Ie=Kd(be,r.homeDirectory);return n.jsx(W4,{id:be.id,disabled:s.singleProjectMode||$.forceExpanded||s.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:Ie,projectDescription:nr(be.normalizedPath,r.homeDirectory),projectDirectory:be.normalizedPath,projectIcon:be.icon,projectColor:be.color,projectIconImage:be.iconImage,projectIconBackground:be.iconBackground,isCollapsed:$.collapsed,isRepo:!!s.projectRepoStatus.get(be.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:$.collapsed?o.renderProjectStatusIndicator?.(be.id,$.section.groups):null,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,projectPickerOptions:s.singleProjectMode?Y:void 0,onProjectSelect:s.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{!$.forceExpanded&&!s.singleProjectMode&&o.toggleProject(be.id)},onNewSession:()=>{Hi({projectId:be.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:be.id,directoryOverride:be.normalizedPath})},onNewWorktreeSession:()=>{Hi({projectId:be.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(be.id),onManageSpaces:g?()=>de.getState().setSpacesPageProjectId(be.id):void 0,onOpenFolder:be.normalizedPath&&l.revealPath?()=>_(be.normalizedPath):void 0,onRenameStart:()=>o.openProjectEditDialog(be.id),onArchiveAll:()=>{V(Ie,$.section.groups)},onClose:()=>o.removeProject(be.id),showCreateButtons:!0})}if($.kind==="group-header")return n.jsx(V4,{id:$.groupKey,disabled:$.forceExpanded||s.state.editingId!==null||r.worktreeSortOrder!=="manual",children:be=>n.jsx(s5,{...s.groupProps,...o.group,group:$.group,groupKey:$.groupKey,projectId:$.projectId,isEmpty:$.empty,visibleSessionCount:s.state.visibleSessionCountByGroup.get($.groupKey),editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,dragHandleProps:be,renderBody:!1})});if($.kind==="folder-header"){const be=s.groupProps.folderRename?.folderId===$.folder.id&&s.groupProps.folderRename.scopeKey===$.scopeKey;return n.jsx(ih,{folderId:$.folder.id,scopeKey:$.scopeKey,ownerKey:$.ownerKey,disabled:!$.dropEnabled,children:(Ie,Ye)=>n.jsx(C3,{notifyOnSubtasks:s.groupProps.notifyOnSubtasks,activityNodes:$.activityNodes,folder:$.folder,displayName:$.displayName,sessions:$.nodes,depth:$.depth,canExpand:!$.empty,isCollapsed:$.collapsed,onToggle:$.forceExpanded?c5:()=>d($.folder.id),onRename:nt=>u($.scopeKey,$.folder.id,nt),onDelete:()=>{$.archived?Cn.requestDelete({sessions:[...$.deleteSessions],mode:"session"}):m?v({scopeKey:$.scopeKey,folderId:$.folder.id,folderName:$.folder.name,subFolderCount:$.subFolderCount,sessionCount:$.nodes.length}):f($.scopeKey,$.folder.id)},renderBody:!1,groupDirectory:$.scopeDirectory??$.group.directory,projectId:$.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:be,renameDraft:be?s.groupProps.folderRename?.draft:void 0,onRenameDraftChange:s.groupProps.setFolderRenameDraft,onRenameSave:()=>{const nt=s.groupProps.folderRename?.draft.trim();nt&&u($.scopeKey,$.folder.id,nt),s.groupProps.clearFolderRename()},onRenameCancel:s.groupProps.clearFolderRename,droppableRef:Ie,isDropTarget:Ye,onNewSession:()=>{Hi({projectId:$.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:$.projectId,directoryOverride:$.scopeDirectory??$.group.directory,targetFolderId:$.folder.id,target:$.group.draftTarget})},archivedBucket:$.archived})})}if($.kind==="session"){const be=new Set;return or($.node,s.state.editingId)&&be.add($.node.session.id),n.jsx("div",{onFocusCapture:()=>S($.key),onBlurCapture:()=>S(Ie=>Ie===$.key?null:Ie),children:n.jsx(Ko,{...s.groupProps,node:$.node,depth:$.depth,groupDirectory:$.groupDirectory,projectId:$.projectId,folderOwnerKey:$.ownerKey,selectionScopeKey:$.selectionScopeKey,archivedBucket:$.archived,renderContext:$.renderContext,rowKey:$.key,dragKey:$.key,secondaryMeta:$.secondaryMeta,renderChildren:!1,editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:be,menuOpenSessionId:s.state.openSidebarMenuKey===`session-menu:${$.key}`||s.state.openSidebarMenuKey===`session-context:${$.key}`?$.node.session.id:null,nodeStructureKey:$.blockingBadgeSessionScopes?`${Mr($.node)}:${JSON.stringify($.blockingBadgeSessionScopes)}`:Mr($.node),blockingBadgeSessionScopes:$.blockingBadgeSessionScopes}})})}if($.kind==="run")return n.jsx(C4,{run:$.run,depth:$.depth,laneNodes:$.laneNodes,blockingSessionIds:$.blockingSessionIds,renderContext:$.renderContext,projectId:$.projectId,projectLabel:$.projectLabel,expansionKey:$.expansionKey,expanded:$.expanded,forceExpanded:$.forceExpanded,notifyOnSubtasks:s.groupProps.notifyOnSubtasks,toggleParent:s.groupProps.toggleParent});const fe=$.kind==="show-control"&&$.flat===!0?zd:Pd($.kind==="show-control"||$.kind==="empty"?$.depth??0:0);return $.kind==="show-control"?n.jsx("div",{children:n.jsx("button",{type:"button",className:"mt-0.5 flex items-center justify-start rounded-md pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",style:{paddingInlineStart:fe},onClick:()=>{$.containerKey.startsWith("activity:")?s.state.setVisibleActivityCountByKey(be=>{const Ie=new Map(be);return $.control==="more"?Ie.set($.containerKey,$.currentCount+$.increment):Ie.delete($.containerKey),Ie}):$.control==="more"?o.group.showMoreGroupSessions($.containerKey,$.currentCount,$.increment):o.group.resetGroupSessionLimit($.containerKey)},children:i($.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")})}):$.kind==="status"?Pe($):$.emptyKind==="sidebar"?s.emptyState:$.emptyKind==="search"?s.searchEmptyState:n.jsx("div",{className:"py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:fe},children:i("sessions.sidebar.group.empty.noArchivedSessions")})},e[33]=o,e[34]=f,e[35]=l,e[36]=s.emptyState,e[37]=s.groupProps,e[38]=s.projectRepoStatus,e[39]=s.searchEmptyState,e[40]=s.singleProjectMode,e[41]=s.state,e[42]=_,e[43]=Y,e[44]=u,e[45]=Pe,e[46]=V,e[47]=m,e[48]=g,e[49]=i,e[50]=d,e[51]=r,e[52]=xe):xe=e[52];const ce=xe;let Oe;if(e[53]!==k||e[54]!==s.rowModel.rows){let $;e[56]!==k?($=fe=>fe.kind==="project-header"?k?.kind==="group"?[]:[fe.section.project.id]:fe.kind!=="group-header"?[]:k?.kind==="project"?[]:k?.kind==="group"&&fe.projectId!==k.projectId?[]:[fe.groupKey],e[56]=k,e[57]=$):$=e[57],Oe=s.rowModel.rows.flatMap($),e[53]=k,e[54]=s.rowModel.rows,e[55]=Oe}else Oe=e[55];const me=Oe;let ie;e[58]!==s.sectionsForRender?(ie=new Set(s.sectionsForRender.map(l5)),e[58]=s.sectionsForRender,e[59]=ie):ie=e[59];const q=ie;let ue;e[60]!==s.rowModel.stickyHeaders?(ue=s.rowModel.stickyHeaders.map(a5).join(""),e[60]=s.rowModel.stickyHeaders,e[61]=ue):ue=e[61];const ve=ue;let Ee;e[62]!==s.rowModel.rows||e[63]!==q?(Ee=$=>{const fe=String($.active.id);if(q.has(fe)){T({kind:"project"});return}const be=s.rowModel.rows.find(Ie=>Ie.kind==="group-header"&&Ie.groupKey===fe);T(be?{kind:"group",projectId:be.projectId}:null)},e[62]=s.rowModel.rows,e[63]=q,e[64]=Ee):Ee=e[64];let L;e[65]===Symbol.for("react.memo_cache_sentinel")?(L=()=>T(null),e[65]=L):L=e[65];let le;e[66]!==o||e[67]!==p||e[68]!==s.rowModel.folderAuthorityByOwner||e[69]!==s.rowModel.folderDropTargets||e[70]!==s.rowModel.rows||e[71]!==s.sectionsForRender||e[72]!==s.state||e[73]!==r?(le=$=>{if(T(null),!$.over)return;const fe=$.active.data.current,be=$.over.data.current;if(fe?.type==="session"&&fe.sessionId&&fe.ownerKey&&fe.archivedBucket!==!0&&be?.type==="folder"&&be.folderId&&be.scopeKey&&be.ownerKey===fe.ownerKey){const St=s.rowModel.folderDropTargets.find(ot=>ot.folderId===be.folderId&&ot.scopeKey===be.scopeKey&&ot.ownerKey===fe.ownerKey),we=s.rowModel.folderAuthorityByOwner.get(fe.ownerKey);if(!St?.enabled||we?.complete!==!0)return;const De=Xt.getState();for(const ot of we.scopeKeys)ot!==be.scopeKey&&De.removeSessionFromFolder(ot,fe.sessionId);p(be.scopeKey,be.folderId,fe.sessionId);return}if(r.hasSessionSearchQuery||s.state.editingId!==null||$.active.id===$.over.id)return;const Ie=String($.active.id),Ye=String($.over.id),nt=s.sectionsForRender.map(i5),Ue=nt.indexOf(Ie),Ve=nt.indexOf(Ye);if(Ue>=0&&Ve>=0&&r.projectSortOrder==="manual"){o.reorderProjects(Ue,Ve);return}const Se=s.rowModel.rows.find(St=>St.kind==="group-header"&&St.groupKey===Ie),ye=s.rowModel.rows.find(St=>St.kind==="group-header"&&St.groupKey===Ye);if(!Se||!ye||Se.projectId!==ye.projectId||!Se.projectId)return;const Ge=Se.projectId,qe=s.sectionsForRender.find(St=>St.project.id===Ge);if(!qe)return;const ft=qe.groups.findIndex(St=>St.id===Se.group.id),et=qe.groups.findIndex(St=>St.id===ye.group.id);ft<0||et<0||o.setGroupOrderByProject(St=>new Map(St).set(Ge,il(qe.groups,ft,et).map(o5)))},e[66]=o,e[67]=p,e[68]=s.rowModel.folderAuthorityByOwner,e[69]=s.rowModel.folderDropTargets,e[70]=s.rowModel.rows,e[71]=s.sectionsForRender,e[72]=s.state,e[73]=r,e[74]=le):le=e[74];let G;e[75]!==te||e[76]!==s.rowModel||e[77]!==ne||e[78]!==ce||e[79]!==w?(G=n.jsx(A4,{model:s.rowModel,scrollElement:w,pinnedRowIndexes:ne,renderRow:ce,onFirstVisibleIndexChange:te}),e[75]=te,e[76]=s.rowModel,e[77]=ne,e[78]=ce,e[79]=w,e[80]=G):G=e[80];let se;e[81]!==me||e[82]!==G?(se=n.jsx(oi,{items:me,strategy:al,children:G}),e[81]=me,e[82]=G,e[83]=se):se=e[83];let je;e[84]!==W||e[85]!==Ee||e[86]!==le||e[87]!==se?(je=n.jsx(Or,{ref:H,useScrollShadow:!0,hideTopScrollShadow:!0,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 ps-2.5 pe-2 [overflow-anchor:none]",children:n.jsx(zr,{sensors:W,collisionDetection:Kr,onDragStart:Ee,onDragCancel:L,onDragEnd:le,children:se})}),e[84]=W,e[85]=Ee,e[86]=le,e[87]=se,e[88]=je):je=e[88];let he;e[89]!==O||e[90]!==je||e[91]!==ve?(he=n.jsx(L4,{suspended:O,layoutKey:ve,scrollRef:K,children:je}),e[89]=O,e[90]=je,e[91]=ve,e[92]=he):he=e[92];let ge;e[93]!==f||e[94]!==b?(ge=()=>{b&&(f(b.scopeKey,b.folderId),v(null))},e[93]=f,e[94]=b,e[95]=ge):ge=e[95];let ke;e[96]!==b||e[97]!==ge?(ke=n.jsx(gh,{value:b,setValue:v,onConfirm:ge}),e[96]=b,e[97]=ge,e[98]=ke):ke=e[98];let Ae;return e[99]!==j.dialog||e[100]!==he||e[101]!==ke?(Ae=n.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[he,ke,j.dialog]}),e[99]=j.dialog,e[100]=he,e[101]=ke,e[102]=Ae):Ae=e[102],Ae}function o5(t){return t.id}function i5(t){return t.project.id}function a5(t){const{kind:e,id:s,rowIndex:r}=t;return`${e}:${s}:${r}`}function l5(t){return t.project.id}function c5(){}function d5(t){return t.isolatedSpacesEnabled}function u5(t){return t.showDeletionDialog}function f5(t){return t.addSessionToFolder}function p5(t){return t.deleteFolder}function h5(t){return t.renameFolder}function m5(t){return t.toggleFolderCollapse}const g5=a.memo(r5),Na=new Map,Wd=(t,e)=>{for(const s of t){const r=vt(s??null);r&&!Na.has(r)&&Na.set(r,e)}},Hd=t=>{const e=vt(t??null);return e?Na.get(e)??0:0},br=t=>!!t.time?.archived,b5=(t,e)=>{if(t===e)return!0;if(!t||!e||t.size!==e.size)return!1;for(const[s,r]of e)if(t.get(s)?.scopeDirectory!==r.scopeDirectory)return!1;return!0},y5=t=>{const{t:e}=Ct(),s=a.useRef(t.gitBranches);s.current=t.gitBranches;const r=a.useRef(t.sessionOrderRanks);r.current=t.sessionOrderRanks;const o=a.useRef(t.sessionOwners),i=a.useMemo(()=>(b5(o.current,t.sessionOwners)||(o.current=t.sessionOwners),o.current),[t.sessionOwners]),c=a.useCallback(f=>[f.label,f.branch??"",f.description??"",f.directory??""].join(" ").toLowerCase(),[]),l=a.useCallback(f=>{const p=vt(f.directory??null)??"";return`${(f.title||e("sessions.sidebar.session.untitled")).trim()} ${p}`.toLowerCase()},[e]),d=a.useCallback((f,p)=>{if(!p)return f;const m=p.trim().toLowerCase(),g=m.startsWith("ses_");return f.flatMap(b=>{if(g&&br(b.session))return[];if(g?b.session.id.toLowerCase()===m:To([l(b.session)],p))return[b];const x=d(b.children,p);return x.length===0?[]:[{...b,children:x}]})},[l]),u=a.useCallback((f,p,m,g,b)=>{const v=vt(p??null),x=vf(f),y=new Map(x.map(_=>[_.id,_])),h=new Map;x.forEach(_=>{const F=_.parentID;if(!F)return;const X=y.get(F);if(!X||br(X)||br(_))return;const oe=h.get(F)??[];oe.push(_),h.set(F,oe)});const S=Wx(m,v),w=(v&&!t.isVSCode?t.spacesByProject?.get(v):void 0)??[],C=new Map;for(const _ of w){const F=vt(_.directory);F&&C.set(F,_)}const k=_=>{const F=vt(_.directory??null),X=t.worktreeMetadata.get(_.id)??null;if(X)return X;if(F){const oe=S.get(F)??null;if(oe&&F!==v)return oe}return null},T=new Set,O=_=>{T.add(_.id);const F=h.get(_.id)??[],X=[];for(const oe of F)T.has(oe.id)||X.push(O(oe));return{session:_,children:X,worktree:k(_)}},K=_=>{const F=_.parentID;if(!F)return!1;if(br(_))return!0;const X=y.get(F);return!!(X&&br(X))},R=x.filter(_=>{const F=_.parentID;return F?!y.has(F)&&!K(_):!0}),I=[],N=_=>{T.has(_.id)||I.push(O(_))};R.forEach(N),x.forEach(_=>{K(_)||N(_)});const W=new Map,z="__archived__",H=_=>{if(_.time?.archived)return z;if(t.isVSCode||t.runKeyBySessionId?.has(_.id))return v??"__project_root__";const F=i?.get(_.id)?.scopeDirectory;if(F){if(F===v)return v??"__project_root__";if(S.has(F)||C.has(F))return F}const oe=vt(t.worktreeMetadata.get(_.id)?.path??null)??sr(_);return oe&&oe!==v&&S.has(oe)?oe:v??"__project_root__"};I.forEach(_=>{const F=H(_.session);W.has(F)||W.set(F,[]),W.get(F)?.push(_)});const M=v??"__project_root__",Y=[{id:"root",label:b&&g&&g!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:g}):e("sessions.sidebar.grouping.projectRoot"),branch:g??null,description:v?nr(v,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:v,folderScopeKey:v,sessions:W.get(M)??[]}],j=new Map;m.forEach(_=>{const F=vt(_.path)??_.path,X=W.get(F)??[],oe=X.length>0,ne=X.reduce((A,te)=>{const U=Hx(te.session,r.current);return Number.isFinite(U)?Math.max(A,U):A},0);j.set(F,{hasActiveSession:oe,lastUpdatedAt:ne})});const P=(_,F)=>{const X=(_.label||_.branch||_.name||_.path||"").toLowerCase(),oe=(F.label||F.branch||F.name||F.path||"").toLowerCase();return X.localeCompare(oe)},D=t.worktreeSortOrder!=="recent"?[...m].sort(P):[...m].sort((_,F)=>{const X=vt(_.path)??_.path,oe=vt(F.path)??F.path,ne=j.get(X)??{hasActiveSession:!1,lastUpdatedAt:0},A=j.get(oe)??{hasActiveSession:!1,lastUpdatedAt:0};if(ne.hasActiveSession!==A.hasActiveSession)return ne.hasActiveSession?-1:1;if(ne.hasActiveSession&&A.hasActiveSession)return A.lastUpdatedAt-ne.lastUpdatedAt;const te=Hd(_.path),U=Hd(F.path);return te!==U?U-te:P(_,F)});(t.isVSCode?[]:D).forEach(_=>{const F=vt(_.path)??_.path,X=s.current.get(F)?.trim()||null,oe=_.branch?.trim()||null,A=!!(X&&oe&&_.label&&hc(_.label)===hc(oe))?X:_.label||_.name||Qo(F,t.homeDirectory)||F;Y.push({id:`worktree:${F}`,label:A,branch:X||oe,description:nr(F,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:_,directory:F,folderScopeKey:F,sessions:W.get(F)??[]})});for(const[_,F]of C)Y.push({id:`space:${F.id}`,label:F.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:F,directory:_,folderScopeKey:_,sessions:W.get(_)??[]});const B=W.get(z)??[];return B.length>0&&Y.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&&v?Sf(v):null,sessions:B}),Y},[t.homeDirectory,t.worktreeMetadata,t.isVSCode,t.worktreeSortOrder,i,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:c,buildSessionSearchText:l,filterSessionNodesForSearch:d,buildGroupedSessions:u}},x5=t=>{const e=Je.c(60),{selectedCount:s,scopeKey:r,scopeFolders:o,archivedBucket:i,onMoveToFolder:c,onCreateFolderAndMove:l,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:f,onArchive:p,onDelete:m,onDone:g}=t,{t:b}=Ct(),v=s>0,x=v&&!!r&&!i;let y;e[0]!==s||e[1]!==b?(y=b("sessions.sidebar.bulkActions.selectedCount",{count:s}),e[0]=s,e[1]=b,e[2]=y):y=e[2];let h;e[3]!==y?(h=n.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:y}),e[3]=y,e[4]=h):h=e[4];let S;e[5]!==x||e[6]!==u||e[7]!==l||e[8]!==c||e[9]!==d||e[10]!==o||e[11]!==b?(S=x?n.jsxs(Is,{children:[n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx(Ts,{asChild:!0,children:n.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-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.moveToFolder"),children:n.jsx(Z,{name:"folder",className:"h-4 w-4"})})})}),n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),n.jsxs(Ds,{align:"end",className:"min-w-[180px]",children:[o.length===0?n.jsx(qt,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):o.map(B=>n.jsx(qt,{onClick:()=>c(B.id),children:n.jsx("span",{className:"flex-1 truncate",children:B.name})},B.id)),n.jsx(wn,{}),n.jsxs(qt,{onClick:l,children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?n.jsxs(qt,{onClick:d,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=x,e[6]=u,e[7]=l,e[8]=c,e[9]=d,e[10]=o,e[11]=b,e[12]=S):S=e[12];let w;e[13]!==i||e[14]!==v||e[15]!==f||e[16]!==b?(w=i?n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:f,disabled:!v,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-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.restore"),children:n.jsx(Z,{name:"inbox-unarchive",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=i,e[14]=v,e[15]=f,e[16]=b,e[17]=w):w=e[17];let C;e[18]!==i||e[19]!==v||e[20]!==p||e[21]!==b?(C=i?null:n.jsxs(Ft,{children:[n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:p,disabled:!v,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-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.archive"),children:n.jsx(Z,{name:"archive",className:"h-4 w-4"})})}),n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.archive")})})]}),e[18]=i,e[19]=v,e[20]=p,e[21]=b,e[22]=C):C=e[22];const k=!v;let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=Te("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 disabled:pointer-events-none disabled:opacity-40"),e[23]=T):T=e[23];let O;e[24]!==b?(O=b("sessions.sidebar.bulkActions.delete"),e[24]=b,e[25]=O):O=e[25];let K;e[26]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Z,{name:"delete-bin",className:"h-4 w-4"}),e[26]=K):K=e[26];let R;e[27]!==m||e[28]!==k||e[29]!==O?(R=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:m,disabled:k,className:T,"aria-label":O,children:K})}),e[27]=m,e[28]=k,e[29]=O,e[30]=R):R=e[30];let I;e[31]!==b?(I=b("sessions.sidebar.bulkActions.delete"),e[31]=b,e[32]=I):I=e[32];let N;e[33]!==I?(N=n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:I})}),e[33]=I,e[34]=N):N=e[34];let W;e[35]!==R||e[36]!==N?(W=n.jsxs(Ft,{children:[R,N]}),e[35]=R,e[36]=N,e[37]=W):W=e[37];let z;e[38]!==b?(z=b("sessions.sidebar.header.actions.exitSelection"),e[38]=b,e[39]=z):z=e[39];let H;e[40]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Z,{name:"close",className:"h-4 w-4"}),e[40]=H):H=e[40];let M;e[41]!==g||e[42]!==z?(M=n.jsx(Bt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,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-ring disabled:pointer-events-none disabled:opacity-40","aria-label":z,children:H})}),e[41]=g,e[42]=z,e[43]=M):M=e[43];let Y;e[44]!==b?(Y=b("sessions.sidebar.header.actions.exitSelection"),e[44]=b,e[45]=Y):Y=e[45];let j;e[46]!==Y?(j=n.jsx(Ot,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Y})}),e[46]=Y,e[47]=j):j=e[47];let P;e[48]!==M||e[49]!==j?(P=n.jsxs(Ft,{children:[M,j]}),e[48]=M,e[49]=j,e[50]=P):P=e[50];let D;e[51]!==W||e[52]!==P||e[53]!==S||e[54]!==w||e[55]!==C?(D=n.jsxs("div",{className:"ms-auto flex items-center gap-0.5",children:[S,w,C,W,P]}),e[51]=W,e[52]=P,e[53]=S,e[54]=w,e[55]=C,e[56]=D):D=e[56];let V;return e[57]!==h||e[58]!==D?(V=n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[h,D]}),e[57]=h,e[58]=D,e[59]=V):V=e[59],V},Vd=new Map,S5=(t,e)=>{if(!t)return[];const s=e(t);return s.length>0?s.map(r=>r.scopeKey):[t]},v5=(t,e)=>{const s=t.sessionIds.filter(i=>e.has(i));if(s.length===0)return{ready:!1,value:null};const r=t.archivedBucket||ch(new Set(s),e),o={sessionIds:s,sessionCount:s.length,archivedBucket:r};return{ready:s.length===t.sessionIds.length&&r===t.archivedBucket,value:o}},w5=t=>{const e=Je.c(89),{t:s}=Ct();let r;e[0]!==s?(r=he=>{const ge=Vx(he);return ge?{description:Eu(ge,s)}:void 0},e[0]=s,e[1]=r):r=e[1];const o=r,{isInlineEditing:i,showDeletionDialog:c,foldersMap:l,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:f,createFolderAndStartRename:p,archiveSessions:m,unarchiveSessions:g,deleteSessions:b,bulkDeleteConfirm:v,setBulkDeleteConfirm:x}=t,y=us(k5),h=us(j5),S=h>0,w=us(C5),C=us(P5),k=lh(),T=E5,O=I5;let K;e[2]!==S||e[3]!==k||e[4]!==w?(K=S&&ch(w,k?.getSessionsById()??Vd),e[2]=S,e[3]=k,e[4]=w,e[5]=K):K=e[5];const R=K;let I;e:{if(C){I=C;break e}I=null}const N=I;let W;e[6]!==N||e[7]!==d?(W=S5(N,d),e[6]=N,e[7]=d,e[8]=W):W=e[8];const z=W;let H;if(e[9]!==l||e[10]!==z){let he;e[12]!==l?(he=ge=>l[ge]??[],e[12]=l,e[13]=he):he=e[13],H=z.flatMap(he),e[9]=l,e[10]=z,e[11]=H}else H=e[11];const M=H;let Y;e[14]!==l||e[15]!==z?(Y=he=>{for(const ge of z)if((l[ge]??[]).some(ke=>ke.id===he))return ge;return null},e[14]=l,e[15]=z,e[16]=Y):Y=e[16];const j=Y;let P;e:{if(!S){P=!1;break e}for(const he of z)for(const ge of l[he]??[])for(const ke of ge.sessionIds)if(w.has(ke)){P=!0;break e}P=!1}const D=P;let V;e[17]!==u||e[18]!==f||e[19]!==w||e[20]!==z?(V=(he,ge)=>{const ke=Array.from(w);for(const Ae of z)Ae!==he&&f(Ae,ke);u(he,ge,ke)},e[17]=u,e[18]=f,e[19]=w,e[20]=z,e[21]=V):V=e[21];const B=V;let _;e[22]!==S||e[23]!==B||e[24]!==j?(_=he=>{if(!S)return;const ge=j(he);ge&&B(ge,he)},e[22]=S,e[23]=B,e[24]=j,e[25]=_):_=e[25];const F=_;let X;e[26]!==p||e[27]!==S||e[28]!==B||e[29]!==z?(X=()=>{const he=z[0];if(!he||!S)return;const ge=p(he);ge&&B(he,ge.id)},e[26]=p,e[27]=S,e[28]=B,e[29]=z,e[30]=X):X=e[30];const oe=X;let ne;e[31]!==S||e[32]!==f||e[33]!==w||e[34]!==z?(ne=()=>{if(!S)return;const he=Array.from(w);for(const ge of z)f(ge,he)},e[31]=S,e[32]=f,e[33]=w,e[34]=z,e[35]=ne):ne=e[35];const A=ne;let te;e[36]!==m||e[37]!==b||e[38]!==o||e[39]!==s?(te=async(he,ge)=>{if(he.length!==0)if(ge){const{deletedIds:ke,failedIds:Ae}=await b(he);ke.length>0&&ze.success(ke.length===1?s("sessions.sidebar.bulkActions.deletedSingle",{count:ke.length}):s("sessions.sidebar.bulkActions.deletedPlural",{count:ke.length})),Ae.length>0&&ze.error(Ae.length===1?s("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Ae.length}):s("sessions.sidebar.bulkActions.failedDeletePlural",{count:Ae.length}),o(Ae)),us.getState().removeMany(ke)}else{const{archivedIds:ke,failedIds:Ae}=await m(he);ke.length>0&&ze.success(ke.length===1?s("sessions.sidebar.bulkActions.archivedSingle",{count:ke.length}):s("sessions.sidebar.bulkActions.archivedPlural",{count:ke.length})),Ae.length>0&&ze.error(Ae.length===1?s("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Ae.length}):s("sessions.sidebar.bulkActions.failedArchivePlural",{count:Ae.length}),o(Ae)),us.getState().removeMany(ke)}},e[36]=m,e[37]=b,e[38]=o,e[39]=s,e[40]=te):te=e[40];const U=te;let Pe;e[41]!==U||e[42]!==S||e[43]!==w||e[44]!==x||e[45]!==c?(Pe=he=>{if(!S)return;const ge=Array.from(w);if(!c){U(ge,he);return}x({sessionIds:ge,sessionCount:ge.length,archivedBucket:he})},e[41]=U,e[42]=S,e[43]=w,e[44]=x,e[45]=c,e[46]=Pe):Pe=e[46];const xe=Pe;let ce;e[47]!==R||e[48]!==xe?(ce=()=>xe(R),e[47]=R,e[48]=xe,e[49]=ce):ce=e[49];const Oe=ce;let me;e[50]!==xe?(me=()=>xe(!1),e[50]=xe,e[51]=me):me=e[51];const ie=me;let q;e[52]!==xe?(q=()=>xe(!0),e[52]=xe,e[53]=q):q=e[53];const ue=q;let ve;e[54]!==R||e[55]!==o||e[56]!==S||e[57]!==w||e[58]!==s||e[59]!==g?(ve=async()=>{if(!S||!R)return;const he=Array.from(w),{restoredIds:ge,failedIds:ke}=await g(he);ge.length>0&&ze.success(ge.length===1?s("sessions.sidebar.bulkActions.restoredSingle",{count:ge.length}):s("sessions.sidebar.bulkActions.restoredPlural",{count:ge.length})),ke.length>0&&ze.error(ke.length===1?s("sessions.sidebar.bulkActions.failedRestoreSingle",{count:ke.length}):s("sessions.sidebar.bulkActions.failedRestorePlural",{count:ke.length}),o(ke)),us.getState().removeMany(ge)},e[54]=R,e[55]=o,e[56]=S,e[57]=w,e[58]=s,e[59]=g,e[60]=ve):ve=e[60];const Ee=ve;let L;e[61]!==v||e[62]!==U||e[63]!==k||e[64]!==x?(L=async()=>{if(!v)return;const he=k?.getSessionsById()??Vd,ge=v5(v,he);if(!ge.ready){x(ge.value);return}x(null),await U(ge.value.sessionIds,ge.value.archivedBucket)},e[61]=v,e[62]=U,e[63]=k,e[64]=x,e[65]=L):L=e[65];const le=L;let G,se;e[66]!==v||e[67]!==Oe||e[68]!==i||e[69]!==k||e[70]!==y?(G=()=>{if(!y)return;const he=/Macintosh|Mac OS X/.test(navigator.userAgent||""),ge=ke=>{if(v||i)return;const Ae=ke.target instanceof HTMLElement?ke.target:null;if(Ae&&(Ae.tagName==="INPUT"||Ae.tagName==="TEXTAREA"||Ae.isContentEditable))return;const $=he?ke.metaKey:ke.ctrlKey;if(ke.key==="Escape"){ke.preventDefault(),us.getState().disable();return}if($&&ke.key==="Backspace"){ke.preventDefault(),Oe();return}if($&&(ke.key==="a"||ke.key==="A")){const fe=T3(k?.getEntries()??[],k?.getDescendantIds()??[],us.getState().scopeKey);if(!fe)return;ke.preventDefault(),us.getState().replaceAll(fe.ids,fe.scopeKey)}};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},se=[v,Oe,i,k,y],e[66]=v,e[67]=Oe,e[68]=i,e[69]=k,e[70]=y,e[71]=G,e[72]=se):(G=e[71],se=e[72]),a.useEffect(G,se);let je;return e[73]!==D||e[74]!==M||e[75]!==R||e[76]!==le||e[77]!==N||e[78]!==ie||e[79]!==oe||e[80]!==Oe||e[81]!==ue||e[82]!==F||e[83]!==A||e[84]!==Ee||e[85]!==S||e[86]!==h||e[87]!==y?(je={selectionModeEnabled:y,hasSelection:S,selectedIdsSize:h,bulkScopeIsArchived:R,derivedSelectionScope:N,bulkScopeFolders:M,bulkCanRemoveFromFolder:D,handleToggleSelectionMode:T,handleExitSelectionMode:O,handleBulkMoveToFolder:F,handleBulkCreateFolderAndMove:oe,handleBulkRemoveFromFolder:A,handleBulkDelete:Oe,handleBulkArchive:ie,handleBulkHardDelete:ue,handleBulkRestore:Ee,confirmBulkDelete:le},e[73]=D,e[74]=M,e[75]=R,e[76]=le,e[77]=N,e[78]=ie,e[79]=oe,e[80]=Oe,e[81]=ue,e[82]=F,e[83]=A,e[84]=Ee,e[85]=S,e[86]=h,e[87]=y,e[88]=je):je=e[88],je};function k5(t){return t.enabled}function j5(t){return t.selectedIds.size}function C5(t){return t.selectedIds}function P5(t){return t.scopeKey}function E5(){us.getState().toggleMode()}function I5(){us.getState().disable()}function T5(t){const e=Je.c(37),{getFolderScopesForProject:s,isInlineEditing:r,startFolderRename:o}=t,[i,c]=a.useState(null),l=de(L5),d=de(F5),u=Xt(B5),f=Xt(O5),p=Xt(A5),m=Xt(M5),g=xt(N5),b=xt(R5),v=xt(D5);let x;e[0]!==f||e[1]!==o?(x=k=>{const T=f(k,"New folder");return o(k,T),T},e[0]=f,e[1]=o,e[2]=x):x=e[2];let y;e[3]!==p||e[4]!==g||e[5]!==i||e[6]!==v||e[7]!==u||e[8]!==s||e[9]!==r||e[10]!==m||e[11]!==l||e[12]!==x||e[13]!==b?(y={isInlineEditing:r,showDeletionDialog:l,foldersMap:u,getFolderScopesForProject:s,addSessionsToFolder:p,removeSessionsFromFolders:m,createFolderAndStartRename:x,archiveSessions:g,unarchiveSessions:b,deleteSessions:v,bulkDeleteConfirm:i,setBulkDeleteConfirm:c},e[3]=p,e[4]=g,e[5]=i,e[6]=v,e[7]=u,e[8]=s,e[9]=r,e[10]=m,e[11]=l,e[12]=x,e[13]=b,e[14]=y):y=e[14];const h=w5(y);let S;e[15]!==h.bulkCanRemoveFromFolder||e[16]!==h.bulkScopeFolders||e[17]!==h.bulkScopeIsArchived||e[18]!==h.derivedSelectionScope||e[19]!==h.handleBulkArchive||e[20]!==h.handleBulkCreateFolderAndMove||e[21]!==h.handleBulkHardDelete||e[22]!==h.handleBulkMoveToFolder||e[23]!==h.handleBulkRemoveFromFolder||e[24]!==h.handleBulkRestore||e[25]!==h.handleExitSelectionMode||e[26]!==h.selectedIdsSize||e[27]!==h.selectionModeEnabled?(S=h.selectionModeEnabled?n.jsx(x5,{selectedCount:h.selectedIdsSize,scopeKey:h.derivedSelectionScope,scopeFolders:h.bulkScopeFolders,archivedBucket:h.bulkScopeIsArchived,onMoveToFolder:h.handleBulkMoveToFolder,onCreateFolderAndMove:h.handleBulkCreateFolderAndMove,onRemoveFromFolder:h.handleBulkRemoveFromFolder,canRemoveFromFolder:h.bulkCanRemoveFromFolder,onRestore:h.handleBulkRestore,onArchive:h.handleBulkArchive,onDelete:h.handleBulkHardDelete,onDone:h.handleExitSelectionMode}):null,e[15]=h.bulkCanRemoveFromFolder,e[16]=h.bulkScopeFolders,e[17]=h.bulkScopeIsArchived,e[18]=h.derivedSelectionScope,e[19]=h.handleBulkArchive,e[20]=h.handleBulkCreateFolderAndMove,e[21]=h.handleBulkHardDelete,e[22]=h.handleBulkMoveToFolder,e[23]=h.handleBulkRemoveFromFolder,e[24]=h.handleBulkRestore,e[25]=h.handleExitSelectionMode,e[26]=h.selectedIdsSize,e[27]=h.selectionModeEnabled,e[28]=S):S=e[28];let w;e[29]!==h.confirmBulkDelete||e[30]!==i||e[31]!==d||e[32]!==l?(w=n.jsx(p4,{value:i,setValue:c,showDeletionDialog:l,setShowDeletionDialog:d,onConfirm:h.confirmBulkDelete}),e[29]=h.confirmBulkDelete,e[30]=i,e[31]=d,e[32]=l,e[33]=w):w=e[33];let C;return e[34]!==S||e[35]!==w?(C=n.jsxs(n.Fragment,{children:[S,w]}),e[34]=S,e[35]=w,e[36]=C):C=e[36],C}function D5(t){return t.deleteSessions}function R5(t){return t.unarchiveSessions}function N5(t){return t.archiveSessions}function M5(t){return t.removeSessionsFromFolders}function A5(t){return t.addSessionsToFolder}function O5(t){return t.createFolder}function B5(t){return t.foldersMap}function F5(t){return t.setShowDeletionDialog}function L5(t){return t.showDeletionDialog}const xh="oc.sessions.expandedParents.v3",_5=ii(Ls()),$5=()=>{try{const t=globalThis.localStorage.getItem(xh);if(t===null)return new Set;const e=_5.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},z5=()=>{const[t,e]=a.useState($5),s=a.useRef(t);s.current=t;const r=a.useCallback(o=>{const i=Ux(s.current,o);s.current=i,e(i);try{globalThis.localStorage.setItem(xh,JSON.stringify([...i]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},K5=t=>{const e=Je.c(22),{childStores:s,sections:r,chatGroup:o,canGrantAccess:i}=t,c=Ps(W5),l=Ps(H5);let d;e[0]!==o||e[1]!==r?(d=[...r.flatMap(V5),...o?[{key:"activity:chats",group:o}]:[]].map(q5),e[0]=o,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]!==u?(f=new Set(u.flatMap(Y5)),e[3]=u,e[4]=f):f=e[4];let p;e[5]!==f?(p=[...f],e[5]=f,e[6]=p):p=e[6];const m=p;let g;e[7]!==s||e[8]!==m.length?(g=S=>m.length>0?s.subscribeBootstrap(S):X5,e[7]=s,e[8]=m.length,e[9]=g):g=e[9];let b;e[10]!==s||e[11]!==m?(b=()=>m.map(S=>`${S}\0${s.getBootstrapState(S)??""}\0${s.getBootstrapFailure(S)??""}\0${s.getInitializationState(S)??""}\0${s.getInitializationFailure(S)??""}`).join(""),e[10]=s,e[11]=m,e[12]=b):b=e[12];const v=a.useSyncExternalStore(g,b,Z5);let x;if(e[13]!==i||e[14]!==s||e[15]!==c||e[16]!==u||e[17]!==l){x=new Map;for(const{key:S,archived:w,directories:C}of u){const k=C.find(T=>s.getBootstrapState(T)==="failed"||s.getInitializationState(T)==="failed");if(k){const T=s.getBootstrapState(k)==="failed",O=T?s.getBootstrapFailure(k):s.getInitializationFailure(k);x.set(S,{state:O==="os-permission"?"permission-denied":T?"load-failed":"initialization-failed",directory:k,canGrantAccess:O==="os-permission"&&i})}else{const T=l||!w&&C.length>0&&C.every(O=>s.getBootstrapState(O)==="complete");x.set(S,{state:T?"ready":c==="error"?"load-failed":"loading",directory:T?C[0]??null:null,canGrantAccess:!1})}}e[13]=i,e[14]=s,e[15]=c,e[16]=u,e[17]=l,e[18]=x}else x=e[18];const y=x;let h;return e[19]!==v||e[20]!==y?(h={groupStatusByKey:y,bootstrapSnapshot:v},e[19]=v,e[20]=y,e[21]=h):h=e[21],h};function W5(t){return t.status}function H5(t){return t.hasLoaded}function V5(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function U5(t){return vt(t.directory)}function G5(t){return!!t}function q5(t){const{key:e,group:s}=t;return{key:e,archived:s.isArchivedBucket===!0,directories:ir(s).map(U5).filter(G5)}}function Y5(t){return t.directories}function X5(){}function Z5(){return""}const Q5=6e4,J5=[],Ud=[],Gd={pinned:[],work:[]},eP=t=>!t.parentID,tP=({topology:t,view:e,actions:s})=>{const{alwaysShowActions:r,notifyOnSubtasks:o,projectViewActions:i,rowActions:c,...l}=s,d=Xt(Me=>Me.foldersMap),u=Xt(Me=>Me.collapsedFolderIds),f=Xt(Me=>Me.createFolder),p=Xt(Me=>Me.addSessionToFolder),m=e.projectView,{getOrderedGroups:g,setGroupOrderByProject:b,toggleGroup:v,toggleProject:x,setCollapsedActivities:y}=i,h=ob({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),S=Gx(Me=>Me.projects),w=Gm(),C=a.useMemo(()=>new Map(w.map(Me=>[Me.id,Me.name])),[w]),k=a.useMemo(()=>{const Me=new Map;for(const pe of w){const Le=vt(pe.projectDirectory);if(!Le)continue;const yt=Me.get(Le);yt?yt.push(pe):Me.set(Le,[pe])}return Me},[w]),T=a.useMemo(()=>u1(h.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,h.archivedSessions,S,w),[S,h.archivedSessions,h.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[O,K]=a.useState(new Map),[R,I]=a.useState(new Map),N=a.useCallback((Me,pe,Le=7)=>{K(yt=>new Map(yt).set(Me,pe+Le))},[]),W=a.useCallback(Me=>{K(pe=>{if(!pe.has(Me))return pe;const Le=new Map(pe);return Le.delete(Me),Le})},[]);a.useEffect(()=>{K(Me=>{if(Me.size===0)return Me;const pe=Rt=>m.collapsedGroups.has(Rt)||[...m.collapsedProjects].some(Nt=>Rt===th(Nt)||Rt.startsWith(`${Nt}:`)),Le=[...Me.keys()].filter(pe);if(Le.length===0)return Me;const yt=new Map(Me);for(const Rt of Le)yt.delete(Rt);return yt})},[m.collapsedGroups,m.collapsedProjects]);const z=Zt(Me=>Me.showChatsSection),H=Zt(Me=>Me.projectDisplayMode),M=Zt(Me=>Me.singleProjectId),Y=Zt(Me=>Me.setSingleProjectId),P=!t.isVSCode&&!qm()&&H==="single",D=e.sidebarViewMode==="timeline"&&!t.isVSCode,V=a.useMemo(()=>qx(h.rootSessions,Me=>vt(t.worktreeMetadata.get(Me.id)?.projectDirectory??Me.directory??null)),[h.rootSessions,t.worktreeMetadata]),B=a.useRef(null),_=a.useMemo(()=>{const Me=Array.from(V.runKeyBySessionId,([pe,Le])=>`${pe}\0${Le}`).sort().join("");return B.current?.signature!==Me&&(B.current={signature:Me,map:V.runKeyBySessionId}),B.current.map},[V]),[F,X]=a.useState(null),[oe,ne]=a.useState(null),[A,te]=a.useState(""),[U,Pe]=a.useState(null),[xe,ce]=a.useState(null),[Oe,me]=a.useState(null),ie=a.useCallback((Me,pe)=>{me({scopeKey:Me,folderId:pe.id,draft:pe.name})},[]),q=a.useCallback(Me=>{me(pe=>pe?{...pe,draft:Me}:null)},[]),ue=a.useCallback(()=>me(null),[]),{expandedParents:ve,toggleParent:Ee}=z5(),L=xt(Me=>Me.setCurrentSession),le=a.useCallback((Me,pe)=>{Me!==xt.getState().currentSessionId&&L(Me,pe)},[L]),G=Df(),se=Zt(Me=>Me.worktreeSortOrder),{buildGroupedSessions:je,filterSessionNodesForSearch:he,buildGroupSearchText:ge}=y5({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:h.pinnedSessionIds,sessionOrderRanks:h.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:se,sessionOwners:T.bySessionId,spacesByProject:k,runKeyBySessionId:_}),{getSessionsForProject:ke,getArchivedSessionsForProject:Ae}=e3({ownership:T}),$=Yx(),fe=a.useMemo(()=>{if(t.isVSCode)return null;const Me=$??h.chatSessions.map(Le=>La(Le.directory)).find(Boolean)??null;if(!Me)return null;const pe=Array.from(new Set([Me,...h.chatSessions.map(Le=>vt(Le.directory??null)).filter(Boolean)])).filter(Le=>!!Le).map(Le=>({scopeKey:Le,directory:Le}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Me,folderScopeKey:Me,folderScopes:pe,draftTarget:"chat",sessions:h.chatSessions.filter(Le=>!Le.time?.archived&&eP(Le)).map(Le=>fr(h.childrenMap,Le))}},[h.chatSessions,h.childrenMap,$,t.isVSCode]),be=a.useMemo(()=>fe?[fe]:J5,[fe]),{projectSections:Ie,groupSearchDataByGroup:Ye,sectionsForRender:nt,flatSectionsForRender:Ue}=o3({normalizedProjects:t.projects,getSessionsForProject:ke,getArchivedSessionsForProject:Ae,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,sessionOrderRanks:h.sessionOrderRanks,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:je,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:he,buildGroupSearchText:ge,foldersMap:d,standaloneGroups:be}),Ve=e.onSearchMatchCountChange;a.useEffect(()=>()=>Ve(0),[Ve]);const Se=Fr(),ye=e.useGroupedSections?nt:Ue,Ge=a.useMemo(()=>e.showInlineArchived?ye:ye.map(Me=>Me.groups.some(pe=>pe.isArchivedBucket)?{...Me,groups:Me.groups.filter(pe=>!pe.isArchivedBucket)}:Me),[ye,e.showInlineArchived]),qe=a.useCallback(Me=>Ue.find(Le=>Le.project.id===Me)?.groups.find(Le=>!Le.isArchivedBucket)?.folderScopes??[],[Ue]);GC({enabled:!0,normalizedProjects:t.projects,ownership:T,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:h.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:f,addSessionToFolder:p});const{sourceControl:ft}=_s(),et=ds(Me=>Me.ensureEntry),St=ds(Me=>Me.setParams),we=ds(Me=>Me.refreshTargets),De=ds(Me=>Me.clearDirectoryStatus),ot=ds(Me=>Me.beginActiveContextsLoad),rt=ds(Me=>Me.commitActiveContexts),Xe=ds(Me=>Me.releaseActiveContexts),ht=ds(Me=>Me.activeContextRegistrations),ee=a.useId(),_e=a.useRef(new Set),Be=a.useMemo(()=>new Map(h.orderedSessions.map((Me,pe)=>[Me.id,pe])),[h.orderedSessions]),[Ke,Fe]=a.useState(null),tt=a.useRef([]),bt=e.projectSortOrder==="recent";a.useEffect(()=>{bt||Fe(null)},[bt]);const mt=a.useMemo(()=>{const Me=se!=="manual"?Ge:Ge.map(Le=>{const yt=g(Le.project.id,Le.groups);return yt===Le.groups?Le:{...Le,groups:yt}}),pe=ib(Me,e.projectSortOrder,Le=>Le.project.id,T.sessionsByProject);return[...Ke&&bt?ab(pe,Ke,Le=>Le.project.id):pe]},[g,Ke,bt,T.sessionsByProject,Ge,e.projectSortOrder,se]);a.useEffect(()=>{tt.current=mt.map(Me=>Me.project.id)},[mt]);const it=a.useMemo(()=>{if(!D)return Ud;const Me=new Set(h.rootSessions.map(Nt=>Nt.id)),pe=h.orderedSessions.filter(Nt=>Me.has(Nt.id)&&!Nt.time?.archived),Le=new Map,yt=sc({sessions:pe,projects:t.projects,ownerBySessionId:T.bySessionId,spaceLabelById:C,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return pd({sessions:pe,getSessionLocation:Nt=>yt.get(Nt)??null,getSessionNode:Nt=>{const re=fr(h.childrenMap,Nt),Ze=yt.get(Nt.id);return Le.set(Nt.id,Pa(re,!1,Ze?.groupDirectory??Nt.directory??null)),{...re,children:[],worktree:Ze?.worktree??null}},query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""}).map(Nt=>({...Nt,blockingBadgeSessionScopes:Le.get(Nt.node.session.id)}))},[h.childrenMap,h.orderedSessions,h.rootSessions,T.bySessionId,C,D,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Tt=de(Me=>Me.sessionWorkEnabled),at=Zt(Me=>Me.showWorkSection),$t=Zt(Me=>Me.showPinnedSection),zt=Zt(Me=>Me.detailedZoneRows),Mt=a.useMemo(()=>{const Me=Tt&&at;if(!Me&&!$t)return Gd;const pe=[],Le=[];for(const yt of h.orderedSessions)yt.parentID||yt.time?.archived||Fa(yt.directory)||($t&&ni(h.pinnedSessionIds,yt.directory,yt.id)?pe.push(yt):Me&&ol(yt)&&Le.push(yt));return pe.length===0&&Le.length===0?Gd:{pinned:pe,work:Le}},[h.orderedSessions,h.pinnedSessionIds,Tt,$t,at]),Re=Mt.work,ct=a.useMemo(()=>new Set([...Mt.pinned,...Mt.work].map(Me=>Me.id)),[Mt]),lt=a.useCallback(Me=>{if(Me.length===0)return Ud;const pe=sc({sessions:[...Me],projects:t.projects,ownerBySessionId:T.bySessionId,spaceLabelById:C,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1}),Le=new Map,yt=new Map(Me.map(Qe=>[Qe.id,fr(h.childrenMap,Qe)])),Rt=new Map(Me.map(Qe=>{const ae=yt.get(Qe.id)??fr(h.childrenMap,Qe);Le.set(Qe.id,Pa(ae,!1,pe.get(Qe.id)?.groupDirectory??Qe.directory??null));const He={...ae,children:[],worktree:pe.get(Qe.id)?.worktree??null};return[Qe.id,He]})),Nt=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",re=Nt?Me.filter(Qe=>{const ae=yt.get(Qe.id);return ae?Zp(ae,Nt):!1}):[...Me];return pd({sessions:re,getSessionLocation:Qe=>pe.get(Qe)??null,getSessionNode:Qe=>Rt.get(Qe.id)??fr(h.childrenMap,Qe),query:""}).map(Qe=>({...Qe,blockingBadgeSessionScopes:Le.get(Qe.node.session.id)}))},[h.childrenMap,T.bySessionId,C,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),dt=a.useMemo(()=>lt(Mt.pinned),[lt,Mt.pinned]),st=a.useMemo(()=>lt(Mt.work),[lt,Mt.work]),wt=a.useMemo(()=>{const Me=new Map,pe=new Map,Le=new Map,yt=new Map,Rt=new Set,Nt=(Ze,Qe)=>{const ae=Qe?.trim();Ze&&ae&&Me.set(Qx(Ze,ae),{directory:Ze,branch:ae})},re=Ze=>{if(Nt(vt(Ze.worktree?.path??null),Ze.worktree?.branch),!t.isVSCode){for(const Qe of Pf(Ze.session))pe.set(`${Qe.owner.toLowerCase()}/${Qe.repo.toLowerCase()}#${Qe.number}`,{owner:Qe.owner,repo:Qe.repo,number:Qe.number});for(const Qe of nl(Ze.session))Qe.source==="github"?Le.set(`${Qe.owner.toLowerCase()}/${Qe.repo.toLowerCase()}#${Qe.number}`,{owner:Qe.owner,repo:Qe.repo,number:Qe.number}):Qe.source==="linear"&&Rt.add(Qe.identifier.toUpperCase());for(const Qe of Zx(Ze.session))yt.set(Qe.key,Qe)}Ze.children.forEach(re)};return dt.forEach(Ze=>re(Ze.node)),st.forEach(Ze=>re(Ze.node)),D?(it.forEach(Ze=>{(!Ze.projectId||!m.collapsedProjects.has(Ze.projectId))&&re(Ze.node)}),{targets:Me,linkedRefs:[...pe.values()],linkedIssueRefs:[...Le.values()],linearIdentifiers:[...Rt],gitlabRefs:[...yt.values()]}):(Ie.forEach(Ze=>{m.collapsedProjects.has(Ze.project.id)||Ze.groups.forEach(Qe=>{if(Qe.isArchivedBucket||(Qe.sessions.forEach(re),Qe.isMain))return;const ae=vt(Qe.directory??null);Nt(ae,Qe.branch?.trim()||t.gitBranches.get(ae||""))})}),{targets:Me,linkedRefs:[...pe.values()],linkedIssueRefs:[...Le.values()],linearIdentifiers:[...Rt],gitlabRefs:[...yt.values()]})},[dt,Ie,m.collapsedProjects,it,D,t.gitBranches,t.isVSCode,st]),pt=wt.targets,E=a.useRef(null),Q=a.useMemo(()=>{const Me=UC(pt.values()),pe=JSON.stringify(Me);return E.current?.signature!==pe&&(E.current={signature:pe,candidates:Me}),E.current.candidates},[pt]);a.useEffect(()=>{const Me=Q;if(Me.length===0)return;let pe=!1;const Le=Gt(),yt=async(He,ut=Q5)=>{const gt=Date.now(),Pt=new Map,Kt=Ht=>{const hs=Pt.get(Ht);if(hs)return hs;const ms=ot(Le,Ht,ee),$s=In.scope(Ht),ts=kr(()=>In.read($s,ft)).then(Fn=>{if(pe||Le!==Gt())return null;const zs=Fn.contexts[0],pn=zs&&ea(Sn.getState().entries[Vn(zs)],zs).connected?[zs]:[];return rt(Le,Ht,ee,ms,pn)?(pn.length===0&&De(Ht),pn):null});return Pt.set(Ht,ts),ts},es=await Promise.all(Me.filter(Ht=>!He||Ht.directory===He).map(async Ht=>(await Kt(Ht.directory)??[]).map(ms=>({...Ht,context:ms}))));if(pe||Le!==Gt())return;const os=new Map,ps=new Map;for(const Ht of es.flat()){const hs=tf(Ht.context,Ht.branch);ps.set(hs,{context:Ht.context,branch:Ht.branch});const ms=ds.getState().entries[hs],$s=ms?.status?.changeRequest??ms?.status?.pr,ts=$s?.state,zs=!!$s&&!(ts==="closed"||ts==="merged"),pn=Math.max(ms?.lastRefreshAt??0,ms?.lastDiscoveryPollAt??0),Ln=!!(ms?.isInitialStatusResolved&&!zs&&(!_e.current.has(hs)||gt-pn>=ut));(!ms||!ms.isInitialStatusResolved||Ln)&&(Ln&&_e.current.add(hs),os.has(hs)||os.set(hs,{context:Ht.context,branch:Ht.branch}))}ps.forEach((Ht,hs)=>{et(hs),St(hs,{directory:Ht.context.directory,branch:Ht.branch,remoteName:Ht.context.primaryRemote,canShow:!0,identity:Ht.context,readContext:Ht.context,sourceControl:ft,authChecked:!0,connected:!0})}),os.size!==0&&await we([...os.values()],{silent:!0,markInitialResolved:!0})},Rt=[...new Set(Me.map(He=>He.directory))].map(He=>In.scope(He)),Nt=Rt.map(He=>{let ut=In.snapshot(He);return In.subscribe(He,()=>{const gt=In.snapshot(He),Pt=ut.read!==null&&ut!==gt;ut=gt,Pt&&!pe&&yt(He.directory)})}),re=Sn.subscribe((He,ut)=>{if(!(pe||Le!==Gt()||He.entries===ut.entries))for(const gt of Rt){const Pt=In.snapshot(gt).contexts[0];if(!Pt)continue;const Kt=Vn(Pt);He.entries[Kt]!==ut.entries[Kt]&&yt(gt.directory)}});yt();const Ze=new Set(Me.map(He=>He.directory)),Qe=jn(He=>{!pe&&He.type==="source-control-activity"&&Ze.has(He.directory)&&yt(He.directory,0)}),ae=()=>{!pe&&document.visibilityState==="visible"&&yt()};return document.addEventListener("visibilitychange",ae),()=>{pe=!0,re(),Nt.forEach(He=>He()),Qe(),document.removeEventListener("visibilitychange",ae);for(const He of Me)Xe(Le,He.directory,ee)}},[ot,De,rt,Q,et,we,Xe,St,ft,ee]);const Ne=a.useMemo(()=>Xx(ht,pt.values()),[ht,pt]),Ce=nf(Ne),We=a.useMemo(()=>[...Ce,...wt.linkedRefs.map(Me=>Ir("pull",Me)),...wt.linkedIssueRefs.map(Me=>Ir("issue",Me)),...wt.gitlabRefs.map(Me=>Me.thread==="pull"?Tr("pull",Me):Tr("issue",Me)),...wt.linearIdentifiers.map(rl)],[Ce,wt]);sf(We);const{groupStatusByKey:$e,bootstrapSnapshot:kt}=K5({childStores:Se,sections:mt,chatGroup:fe,canGrantAccess:hu()});let jt=null;P&&(Ie.some(Me=>Me.project.id===M)?jt=M:Ie.some(Me=>Me.project.id===e.activeProjectId)?jt=e.activeProjectId:jt=Ie[0]?.project.id??null);const Et=a.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:Ye,collapsedGroups:m.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:o,pinnedSessionIds:h.pinnedSessionIds,sessionOrderIndex:Be,expandedParents:ve,editingId:F,editingRowKey:oe,editTitle:A,sessionBatchSize:P&&!e.useGroupedSections?20:void 0,setEditingId:X,setEditingRowKey:ne,setEditTitle:te,toggleParent:Ee,allowReselect:c.allowReselect,onSessionSelected:c.onSessionSelected,resetSessionSearch:c.resetSessionSearch,deleteSessionConfirm:xe,setDeleteSessionConfirm:ce,startFolderRename:ie,startSessionWorktreeMenuLoad:s.startSessionWorktreeMenuLoad,folderRename:Oe,setFolderRenameDraft:q,clearFolderRename:ue}),[h.pinnedSessionIds,r,o,m.collapsedGroups,Ye,Be,A,F,oe,ve,Oe,q,ue,ie,xe,s.startSessionWorktreeMenuLoad,c,Ee,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,P]),Lt=a.useMemo(()=>({showMoreGroupSessions:N,resetGroupSessionLimit:W,setActiveProjectIdOnly:l.setActiveProjectIdOnly,setSessionSwitcherOpen:l.setSessionSwitcherOpen,openNewSessionDraft:l.openNewSessionDraft,onToggleCollapsedGroup:v}),[W,N,v,l.openNewSessionDraft,l.setActiveProjectIdOnly,l.setSessionSwitcherOpen]),Yt=a.useMemo(()=>{const Me=new Map;for(const pe of mt)for(const Le of pe.groups){const yt=Jn(pe.project.id,Le.directory);if(!yt)continue;const Rt=ir(Le),Nt=Me.get(yt),re=[...new Set([...Nt?.scopeKeys??[],...Rt.map(Qe=>Qe.scopeKey)])],Ze=h.hasAuthoritativeGlobalSessions&&Rt.every(Qe=>{const ae=vt(Qe.directory);return!ae||Se.getBootstrapState(ae)==="complete"});Me.set(yt,{scopeKeys:re,complete:(Nt?.complete??!0)&&Ze})}if(fe){const pe=Jn(null,fe.directory);pe&&Me.set(pe,{scopeKeys:ir(fe).map(Le=>Le.scopeKey),complete:h.hasAuthoritativeGlobalSessions})}return Me},[kt,fe,Se,h.hasAuthoritativeGlobalSessions,mt]),is=a.useMemo(()=>new Map([...O,...R]),[R,O]),Wt=a.useMemo(()=>W2({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:D?"timeline":"projects",sections:mt,authoritativeSections:Ie,chatGroup:z?fe:null,timelineItems:it,pinnedItems:dt,workItems:st,zoneSessionIds:ct,detailedZoneRows:zt,foldersMap:d,groupSearchDataByGroup:Ye,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:m.collapsedProjects,collapsedGroups:m.collapsedGroups,collapsedFolders:u,collapsedActivities:m.collapsedActivities,expandedParents:ve,visibleCountByContainer:is,pinnedSessionIds:h.pinnedSessionIds,sessionOrderIndex:Be,groupStatusByKey:$e,folderAuthorityByOwner:Yt,activeProjectId:e.activeProjectId,singleProjectMode:P&&!D,singleProjectId:jt,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:P&&!e.useGroupedSections?20:void 0,runIndex:V}),[V,fe,z,m.collapsedActivities,it,D,dt,st,ct,zt,u,h.pinnedSessionIds,ve,Yt,d,Ye,$e,mt,Ie,m.collapsedGroups,m.collapsedProjects,jt,Be,P,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,is]);a.useEffect(()=>{Ve(Wt.searchMatchCount)},[Ve,Wt.searchMatchCount]),a.useEffect(()=>{if(e.hasSessionSearchQuery)return;const Me=Xt.getState().toggleFolderCollapse;for(const pe of Wt.rows)pe.kind==="group-header"&&pe.empty&&m.collapsedGroups.has(pe.groupKey)?v(pe.groupKey):pe.kind==="folder-header"&&pe.empty&&u.has(pe.folder.id)&&Me(pe.folder.id)},[u,m.collapsedGroups,Wt.rows,v,e.hasSessionSearchQuery]);const rs=a.useMemo(()=>({rowModel:Wt,sectionsForRender:mt,projectSections:Ie,singleProjectMode:P,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:F,openSidebarMenuKey:U,setOpenSidebarMenuKey:Pe,visibleSessionCountByGroup:O,collapsedActivityKeys:m.collapsedActivities,setCollapsedActivityKeys:y,visibleActivityCountByKey:R,setVisibleActivityCountByKey:I},groupProps:Et}),[Et,F,U,Ie,mt,Wt,t.projectRepoStatus,e.emptyState,e.searchEmptyState,O,R,m.collapsedActivities,y,P]),as=a.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:se}),[se,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder]),Ss=a.useMemo(()=>({group:Lt,toggleProject:x,setActiveProjectIdOnly:l.setActiveProjectIdOnly,setSessionSwitcherOpen:l.setSessionSwitcherOpen,openNewSessionDraft:l.openNewSessionDraft,openNewWorktreeDialog:l.openNewWorktreeDialog,openWorktreesPage:l.openWorktreesPage,openProjectEditDialog:l.openProjectEditDialog,removeProject:l.removeProject,reorderProjects:l.reorderProjects,setGroupOrderByProject:b,renderProjectStatusIndicator:l.renderProjectStatusIndicator,setSingleProjectId:Y}),[Lt,l.openNewSessionDraft,l.openNewWorktreeDialog,l.openProjectEditDialog,l.openWorktreesPage,l.removeProject,l.reorderProjects,l.setActiveProjectIdOnly,l.setSessionSwitcherOpen,b,x,l.renderProjectStatusIndicator,Y]);return n.jsxs(n.Fragment,{children:[n.jsx(zC,{}),n.jsx(ZC,{projectSections:Ie,activeProjectId:e.activeProjectId,initialActiveSessionByProject:s.initialActiveSessionByProject,persistActiveSessionByProject:s.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:s.openNewSessionDraft,setSessionSwitcherOpen:s.setSessionSwitcherOpen,sessionOwnerBySessionId:T.bySessionId,handleSessionSelect:le}),n.jsx(u3,{sortedSessions:h.orderedSessions,workSessions:Re,prefetchSession:G,children:n.jsxs(I3,{entries:Wt.selectionEntries,descendantIds:Wt.selectionDescendantIds,sessionsById:Wt.sessionById,children:[n.jsx(T5,{getFolderScopesForProject:qe,isInlineEditing:F!==null,startFolderRename:ie}),n.jsx("div",{className:"contents",onPointerEnter:Me=>{bt&&Me.pointerType==="mouse"&&Fe(tt.current)},onPointerLeave:()=>Fe(null),children:n.jsx(g5,{model:rs,view:as,actions:Ss})})]})})]})},sP=t=>{const e=Je.c(3),[s,r]=a.useState(t.view.isVisible);t.view.isVisible&&!s&&r(!0);let o;return e[0]!==t||e[1]!==s?(o=s?n.jsx(tP,{...t}):null,e[0]=t,e[1]=s,e[2]=o):o=e[2],o},Sh=(t,e,s)=>{const r=new Set;for(const o of t){const i=vt(o.path);i&&r.add(i)}if(s?.includeWorktrees===!1)return r;for(const o of e.values())for(const i of o){const c=vt(i.path);c&&r.add(c)}return r},qd="oc.sessions.activeSessionByProject",nP=Dr(Ls(),Ls().min(1).catch("")),rP=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:s,allowReselect:r=!1,hideDirectoryControls:o=!1,showOnlyMainWorkspace:i=!1})=>{qi("react.session_sidebar_render"),js("ui.session_sidebar.render"),js(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),js(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:c}=Ct(),[l,d]=a.useState(!1),[u,f]=a.useState(""),p=a.useCallback(()=>d(!0),[]),m=a.useCallback(()=>{f(""),d(!1)},[]),[g,b]=a.useState(0),v=a.useRef(null),x=a.useRef(null),[y,h]=a.useState(null),S=a.useMemo(()=>Po(),[]),[w,C]=a.useState(new Map),k=de(Re=>Re.isNewWorktreeDialogOpen),T=de(Re=>Re.setNewWorktreeDialogOpen),[O,K]=a.useState(!1),R=a.useMemo(()=>{try{const Re=S.getItem(qd);if(!Re)return new Map;const ct=nP.safeParse(JSON.parse(Re));if(!ct.success)return new Map;const lt=new Map;return Object.entries(ct.data).forEach(([dt,st])=>{st&&lt.set(dt,st)}),lt}catch{return new Map}},[S]),I=a.useCallback(Re=>{try{S.setItem(qd,JSON.stringify(Object.fromEntries(Re.entries())))}catch{}},[S]),[N,W]=a.useState(new Map),z=xs(Re=>Re.homeDirectory),H=Jt(Re=>Re.projects),M=Jt(Re=>Re.activeProjectId),Y=Jt(Re=>Re.removeProject),j=Jt(Re=>Re.setActiveProjectIdOnly),P=Jt(Re=>Re.updateProjectMeta),D=Jt(Re=>Re.reorderProjects),V=de(Re=>Re.setSettingsDialogOpen),B=de(Re=>Re.toggleHelpDialog),_=de(Re=>Re.setAboutDialogOpen),F=de(Re=>Re.setSessionSwitcherOpen),X=de(Re=>Re.setWorktreesPageProjectId),oe=de(Re=>Re.notifyOnSubtasks),ne=a.useMemo(()=>u.trim().toLowerCase(),[u]),A=ne.length>0;E2({enabled:t,isSessionSearchOpen:l,openSessionSearch:p,closeSessionSearch:m,sessionSearchInputRef:x,sessionSearchContainerRef:v});const te=Jx(t),U=a.useMemo(()=>Pn(),[]),Pe=xt(Re=>Re.worktreeMetadata),xe=xt(Re=>Re.availableWorktreesByProject),ce=xt(Re=>Re.openNewSessionDraft),Oe=a.useMemo(()=>Sh(H,xe,{includeWorktrees:!U}),[xe,U,H]),me=a.useCallback(Re=>{de.getState().closeMainSurfaces(),ce(Re),U&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[U,ce]),ie=wr(rr(Re=>({checkForUpdates:Re.checkForUpdates,available:Re.available,runtimeType:Re.runtimeType,info:Re.info,downloading:Re.downloading,downloaded:Re.downloaded,installing:Re.installing,progress:Re.progress,error:Re.error,downloadUpdate:Re.downloadUpdate,restartToUpdate:Re.restartToUpdate}))),q=Gt(),ue=a.useMemo(()=>`${q}|${H.map(Re=>`${Re.id}:${vt(Re.path)??""}`).join("|")}`,[H,q]),[ve,Ee]=a.useState(U?ue:null),[L,le]=a.useReducer(Re=>Re+1,0),G=!U&&ve!==ue,[se,je]=a.useState(new Set),he=a.useRef(se);he.current=se;const ge=ns(Re=>Re.isConnected),ke=a.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});a.useEffect(()=>{let Re=!1;return(async()=>{const lt=q,dt=ns.getState().isConnected,st=Jt.getState().projects;if(xt.setState({worktreeDiscoveryByProject:new Map(st.map($e=>[vt($e.path)??$e.path,"loading"]))}),st.length===0||U){Re||(ke.current={runtimeKey:null,revision:0,worktreesByProject:new Map},je(new Set),Ee(ue));return}const wt=xt.getState().availableWorktreesByProject,pt=vl({rawWorktreesByProjectRef:ke,publishedWorktreesByProject:wt,runtimeKey:lt}),E=pt.revision,Q=new Map(pt.worktreesByProject),Ne=new Set;if(await kr(()=>Promise.all(st.map(async $e=>{const kt=vt($e.path);if(kt)try{if(!(vn.getState().directories.get(kt)?.isGitRepo??await Fu(kt))){Q.delete(kt);return}const Lt=await bc({id:$e.id,path:kt});if(Re)return;Lt.length===0?Q.delete(kt):Q.set(kt,Lt)}catch{Ne.add(kt)}}))),Re||Gt()!==lt)return;const Ce=new Set(st.map($e=>vt($e.path)).filter(Boolean));for(const $e of Q.keys())Ce.has($e)||Q.delete($e);q3({rawWorktreesByProjectRef:ke,runtimeKey:lt,capturedRevision:E,nextRawWorktreesByProject:Q,publishedWorktreesByProject:wt,partitionWorktreesByRegisteredProject:gc,projects:st,worktreeMapsEqual:mc,recordWorktreesSeen:Wd,publishTopology:$e=>{xt.setState($e)},requestRediscovery:()=>{le()},now:()=>Date.now()})&&(je(Ne),xt.setState({worktreeDiscoveryByProject:new Map(st.map($e=>{const kt=vt($e.path)??$e.path;return[kt,Ne.has(kt)?"error":"ready"]}))}),Ee(ue),Ne.size>0&&!dt&&ns.getState().isConnected&&le())})(),()=>{Re=!0}},[U,ue,q,L]),a.useEffect(()=>{ge&&he.current.size>0&&le()},[ge]);const Ae=a.useMemo(()=>cn(),[]),{isTablet:$}=En(),fe=e||$,be=a.useMemo(()=>n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[n.jsx("p",{className:"typography-ui-label font-semibold",children:c("sessions.sidebar.empty.noSessions.title")}),n.jsx("p",{className:"typography-meta mt-1",children:c("sessions.sidebar.empty.noSessions.description")})]}),[c]),Ie=a.useMemo(()=>H.find(Re=>Re.id===y)??null,[H,y]),Ye=a.useCallback(Re=>{y&&P(y,{label:Re.label,icon:Re.icon,color:Re.color,iconBackground:Re.iconBackground,defaultAgent:Re.defaultAgent??null,defaultModel:Re.defaultModel??null,defaultVariant:Re.defaultVariant??null})},[y,P]),nt=a.useCallback(()=>{T(!0)},[T]),Ue=a.useCallback(()=>{const Re=wr.getState();if(Re.available&&Re.info){K(!0);return}ie.checkForUpdates().then(()=>{const{available:ct,error:lt}=wr.getState();if(lt){ze.error(c("sessions.sidebar.updateCheck.errorTitle"),{description:lt});return}if(!ct){ze.success(c("sessions.sidebar.updateCheck.latestVersion"));return}K(!0)})},[c,ie]),Ve=a.useCallback(()=>{e&&F(!1),V(!0)},[e,F,V]),Se=ie.available&&(ie.runtimeType==="desktop"||ie.runtimeType==="web"),ye=a.useCallback(()=>{Cn.requestDirectoryDialog()},[]),Ge=a.useMemo(()=>H.flatMap(Re=>{const ct=vt(Re.path);return ct?[{id:Re.id,path:Re.path,label:Re.label,normalizedPath:ct,icon:Re.icon??void 0,color:Re.color??void 0,iconImage:Re.iconImage??void 0,iconBackground:Re.iconBackground??void 0,addedAt:Re.addedAt,lastOpenedAt:Re.lastOpenedAt,sidebarCollapsed:Re.sidebarCollapsed}]:[]}),[H]),qe=a.useMemo(()=>Ge.map(Re=>Re.normalizedPath),[Ge]),ft=eS(qe,t);Z2({enabled:t,normalizedProjects:Ge,gitRepoStatus:ft,setProjectRepoStatus:C,setProjectRootBranches:W});const et=xt(Re=>Re.isLoading),St=a.useRef(!1);M&&w.has(M)&&(St.current=!!w.get(M));const we=Zt(Re=>Re.showArchivedSessions),De=Zt(Re=>Re.projectSortOrder),ot=Zt(Re=>Re.sidebarViewMode),rt=U?"projects":ot,Xe=rt==="timeline"?"manual":De,ht=Jt(Re=>Re.manualProjectOrder),ee={isVisible:t,mobileVariant:e,onSessionSelected:s,allowReselect:r,hideDirectoryControls:o,showOnlyMainWorkspace:i,t:c,isTablet:$,projects:H,activeProjectId:M,manualProjectOrder:ht,worktreeMetadata:Pe,availableWorktreesByProject:xe,gitBranches:te,gitRepoStatus:ft,updateStore:ie,showArchivedSessions:we,projectSortOrder:Xe,projectRepoStatus:w,projectRootBranches:N,resolvedWorktreeTopologyKey:ve,unresolvedWorktreeProjectPaths:se,isSessionSearchOpen:l,sessionSearchQuery:u,editingProjectDialogId:y,updateDialogOpen:O},_e=a.useRef(null),Be=_e.current;if(Be){let Re=!1;for(const ct of Object.keys(ee))Object.is(Be[ct],ee[ct])||(js(`ui.session_sidebar.source.${ct}`),Re=!0);Re||js("ui.session_sidebar.source.parent_or_context")}_e.current=ee;const Ke=a.useMemo(()=>lb(Ge,Xe,ht),[Ge,Xe,ht]),Fe=V2({isVSCode:U,projects:Ke}),tt=a.useMemo(()=>n.jsx(_C,{query:u,showArchive:!U,resetSessionSearch:m}),[U,m,u]),bt=U&&we,mt=!U,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-ring 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-ring disabled:cursor-not-allowed",$t="h-4 w-4",zt=a.useMemo(()=>({projects:H,getCurrentProjects:()=>Jt.getState().projects,rawWorktreesByProjectRef:ke,getPublishedWorktreesByProject:()=>xt.getState().availableWorktreesByProject,resolveProject:Re=>Qi(Re),listProjectWorktrees:bc,partitionWorktreesByRegisteredProject:gc,worktreeMapsEqual:mc,recordWorktreesSeen:Wd,publishTopology:Re=>{xt.setState(Re)},getRuntimeKey:Gt,now:()=>Date.now()}),[H]),Mt=a.useCallback(Re=>{const ct=mh(Re,{projects:H,resolveProject:Qi});return G3(Re,{...zt,projectRootBranch:ct?N.get(ct.id)??null:null})},[N,H,zt]);return a.useEffect(()=>{if(U)return;const Re=ct=>{for(const lt of ct){const dt=vt(lt.path),st=Gt(),wt=pt=>{!dt||Gt()!==st||xt.setState(E=>({worktreeDiscoveryByProject:new Map(E.worktreeDiscoveryByProject).set(dt,pt)}))};wt("loading"),ph(lt,null,zt).then(()=>{!dt||Gt()!==st||(wt("ready"),je(pt=>{if(!pt.has(dt))return pt;const E=new Set(pt);return E.delete(dt),E}))}).catch(()=>{!dt||Gt()!==st||(wt("error"),je(pt=>new Set(pt).add(dt)))})}};return jn(ct=>{if(ct.type==="session-created"){const lt=tS(ct.directory,Jt.getState().projects);if(!lt){le();return}Re([lt]);return}ct.type==="worktree-changed"&&Re(sS(ct.directories))})},[U,zt]),n.jsx(ri,{delay:400,closeDelay:0,timeout:300,children:n.jsxs("div",{ref:v,className:Te("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[n.jsx(aC,{hideDirectoryControls:o,showProjectDisplayControls:!U,showSectionControls:!U,handleOpenDirectoryDialog:ye,showSourceBoard:!e&&!U,headerActionIconClass:$t,headerActionButtonClass:at,isSessionSearchOpen:l,openSessionSearch:p,closeSessionSearch:m,sessionSearchInputRef:x,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:A,searchMatchCount:g,collapseAll:Fe.actions.collapseAll,expandAll:Fe.actions.expandAll}),n.jsx(sP,{topology:{projects:Ke,availableWorktreesByProject:xe,knownDirectories:Oe,isVSCode:U,worktreeMetadata:Pe,gitBranches:te,projectRepoStatus:w,projectRootBranches:N,lastRepoStatus:St.current},view:{isVisible:t,hasSessionSearchQuery:A,normalizedSessionSearchQuery:ne,activeProjectId:M,showInlineArchived:bt,useGroupedSections:mt,homeDirectory:z,mobileVariant:e,hideDirectoryControls:o,showOnlyMainWorkspace:i,isDesktopShellRuntime:Ae,projectSortOrder:Xe,sidebarViewMode:rt,emptyState:be,searchEmptyState:tt,isSessionsLoading:et,isWorktreeTopologyLoading:G,unresolvedWorktreeProjectPaths:se,projectView:Fe.state,onSearchMatchCountChange:b},actions:{rowActions:{allowReselect:r,onSessionSelected:s,resetSessionSearch:m},alwaysShowActions:fe,notifyOnSubtasks:oe,setActiveProjectIdOnly:j,setSessionSwitcherOpen:F,openNewSessionDraft:me,openNewWorktreeDialog:nt,openWorktreesPage:Re=>{e&&F(!1),X(Re)},openProjectEditDialog:h,removeProject:Y,reorderProjects:D,startSessionWorktreeMenuLoad:Mt,initialActiveSessionByProject:R,persistActiveSessionByProject:I,projectViewActions:Fe.actions}}),n.jsx(FC,{onOpenSettings:Ve,onOpenShortcuts:B,onOpenAbout:()=>_(!0),onOpenUpdate:Ue,showRuntimeButtons:!U,showUpdateButton:Se}),n.jsx(za,{open:O,onOpenChange:K,info:ie.info,downloading:ie.downloading,downloaded:ie.downloaded,installing:ie.installing,progress:ie.progress,error:ie.error,onDownload:ie.downloadUpdate,onRestart:ie.restartToUpdate,runtimeType:ie.runtimeType}),n.jsx(rC,{open:!!Ie,onOpenChange:Re=>{Re||h(null)},project:Ie,onSave:Ye}),n.jsx(nS,{open:k,onOpenChange:T,onWorktreeCreated:Re=>{de.getState().closeMainSurfaces(),e&&F(!1),ce({directoryOverride:Re,preserveDirectoryOverride:!0})}})]})})},oP=a.memo(rP),sn=t=>t?n.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Bs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},iP=()=>{const{t}=Ct(),{git:e,sourceControl:s}=_s(),[r,o]=a.useState(!1),[i,c]=a.useState(null),[l,d]=a.useState([]),[u,f]=a.useState(!1),[p,m]=a.useState(!1),[g,b]=a.useState(!1),[v,x]=a.useState(!1),[y,h]=a.useState(new Set),S=xt(G=>G.getWorktreeMetadata),w=xt(G=>G.newSessionDraft),C=xt(G=>G.setNewSessionDraftTarget),k=xt(G=>G.setDraftBootstrapPendingDirectory),T=rS,O=iS,K=xt(G=>G.deleteSessions),R=xt(G=>G.archiveSessions),I=de(G=>G.showDeletionDialog),N=de(G=>G.setShowDeletionDialog),W=xs(G=>G.currentDirectory),z=xs(G=>G.homeDirectory),H=Jt(G=>G.projects),M=Jt(G=>G.activeProjectId),{isMobile:Y,isTablet:j,hasTouchInput:P}=En(),D=Y||j||P,V=a.useMemo(()=>{const se=(M?H.find(je=>je.id===M)??null:null)?.path??W;return Bs(se)},[M,W,H]),B=a.useCallback(G=>{const je=Bs(G.projectDirectory)||V;return{id:(H.find(ge=>Bs(ge.path)===je)??null)?.id??`path:${je}`,path:je}},[V,H]),_=v&&y.size>0,F=a.useMemo(()=>{const G=i?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!!G.status?.upstream?.split("/")[0]?.trim():l.length>0&&l.every(({metadata:se})=>typeof se.branch=="string"&&se.branch.trim().length>0&&!!se.status?.upstream?.split("/")[0]?.trim())},[i?.worktree,l]),X=i?.mode==="worktree",oe=g||!X||!F,ne=g||!X,A=a.useCallback(G=>{c({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),te=a.useCallback(()=>{c(null),d([]),f(!1),m(!1),b(!1),x(!1),h(new Set)},[]),U=a.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const ge=G.sessions[0];await T(ge.id)?ze.success(t("sessions.sidebar.session.delete.success")):ze.error(t("sessions.sidebar.session.delete.error"));return}const se=G.sessions.map(ge=>ge.id),{deletedIds:je,failedIds:he}=await K(se);if(je.length>0){const ge=he.length>0?he.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:he.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:he.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.dateLabel}):void 0;ze.success(je.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:je.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:je.length}),{description:sn(ge)})}he.length>0&&ze.error(he.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:he.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:he.length}),{description:sn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[T,K,t]);a.useEffect(()=>Cn.onDirectoryRequest(()=>{o(!0)}),[]),a.useEffect(()=>{if(!i){d([]),f(!1),m(!1),x(!1),h(new Set);return}const G=i.sessions.map(he=>{const ge=S(he.id);return ge?{session:he,metadata:ge}:null}).filter(he=>!!he);d(G),f(!1),x(!1),h(new Set);const se=new Map;if(i.worktree?.path&&se.set(Bs(i.worktree.path),i.worktree),G.forEach(({metadata:he})=>{he.path&&se.set(Bs(he.path),he)}),se.size===0){x(!0);return}let je=!1;return(async()=>{const he=new Map,ge=new Set;await Promise.all(Array.from(se.entries()).map(async([ke,Ae])=>{try{const $=await yc(Ae.path);he.set(ke,$),$?.isDirty&&ge.add(ke)}catch{Ae.status&&(he.set(ke,Ae.status),Ae.status.isDirty&&ge.add(ke))}})).catch(ke=>{console.warn("Failed to inspect worktree status before deletion:",ke)}),!je&&(h(ge),x(!0),c(ke=>{if(!ke?.worktree?.path)return ke;const Ae=Bs(ke.worktree.path),$=he.get(Ae);if(!$)return ke;const fe=ke.worktree.status;return fe?.isDirty===$.isDirty&&fe?.ahead===$.ahead&&fe?.behind===$.behind&&fe?.upstream===$.upstream?ke:{...ke,worktree:{...ke.worktree,status:$}}}),d(ke=>ke.map(Ae=>{const $=Bs(Ae.metadata.path),fe=he.get($);return fe?{session:Ae.session,metadata:{...Ae.metadata,status:fe}}:Ae})))})(),()=>{je=!0}},[i,S]),a.useEffect(()=>{F||f(!1)},[F]);const Pe=a.useCallback(async(G,se,je)=>{const he=u&&F,ge=B(G),ke=Bs(G.path),Ae=Bs(ge.path);try{await Lu(ge,G,{deleteRemoteBranch:he,deleteLocalBranch:se,remoteName:G.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s}});const $=Bs(w?.directoryOverride);return w?.open&&ke&&$===ke&&Ae&&(k(null),C({projectId:ge.id,directoryOverride:Ae},{force:!0})),Bs(W)===ke&&Ae&&xs.getState().setDirectory(Ae,{showOverlay:!1}),!0}catch($){return ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:ji(G)}),{id:je,description:sn($ instanceof Error?$.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[F,W,u,B,e,w?.directoryOverride,w?.open,k,C,s,t]),xe=a.useCallback((G,se,je)=>{const he=u&&F,ge=ze.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:ji(G)}));return oS(G.path),(async()=>{try{const ke=await cb({sessionIds:se,removeWorktree:()=>Pe(G,je,ge),archiveSessions:async fe=>fe.length===1?await O(fe[0])?{archivedIds:fe,failedIds:[]}:{archivedIds:[],failedIds:fe}:R(fe)});if(!ke.removed)return;const Ae=t(he?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");ze.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:ji(G)}),{id:ge,description:sn(Ae)});const{failedIds:$}=ke.archive;$.length>0&&ze.error($.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:$.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:$.length}),{description:sn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(ke){ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:ge,description:sn(ke instanceof Error?ke.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{aS(G.path)}})()},[O,R,F,u,Pe,t]),ce=a.useRef(new Set),Oe=a.useCallback(async(G,se)=>{const je=Bs(G.path);if(!ce.current.has(je)){ce.current.add(je);try{const he=await yc(G.path).catch(()=>{});if(!lS(he)){A({sessions:se,mode:"worktree",worktree:G});return}await xe(G,se.map(ge=>ge.id),!0)}finally{ce.current.delete(je)}}},[A,xe]);a.useEffect(()=>Cn.onDeleteRequest(G=>{if(!I&&(G.mode??"session")==="session"){U(G);return}if(G.mode==="worktree"&&G.skipDialogIfSafe&&G.worktree){Oe(G.worktree,G.sessions);return}A(G)}),[A,I,U,Oe]);const me=a.useCallback(async()=>{if(i){b(!0);try{if(X){const G=i.worktree??l[0]?.metadata;if(!G){ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:sn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}xe(G,i.sessions.map(se=>se.id),p),te();return}if(i.sessions.length===1){const G=i.sessions[0];if(!await T(G.id)){ze.error(t("sessions.sidebar.session.delete.error")),b(!1);return}ze.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const G=i.sessions.map(he=>he.id),{deletedIds:se,failedIds:je}=await K(G);if(se.length>0){const he=je.length>0?je.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:je.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:je.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;ze.success(se.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:se.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:se.length}),{description:sn(he),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(je.length>0&&(ze.error(je.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:je.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:je.length}),{description:sn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),se.length===0)){b(!1);return}}te()}finally{b(!1)}}},[i,l,p,T,K,te,X,xe,t]),ie=i?.worktree??l[0]?.metadata??null;let q="";if(i?.mode==="worktree"){const G=i.sessions.length;G===0?q=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):G===1?q=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:G}):q=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:G})}else if(i){const G=i.sessions.length;G===1?q=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):q=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:G,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:G})}const ue=i?n.jsxs("div",{className:Te(X?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&n.jsxs("div",{className:Te(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&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:i.sessions.length})]}),n.jsxs("ul",{className:Te(X?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(G=>n.jsxs("li",{className:Te(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:[n.jsx("span",{className:Te(!X&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:G.title||t("sessions.sidebar.session.untitled")})]},G.id)),i.sessions.length>5&&n.jsx("li",{className:Te(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:i.sessions.length-5})})]})]}),X?n.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Z,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),ie?.label?n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:ie.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:ie?nr(ie.path,z):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),_&&n.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):n.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,ve=X?F?n.jsxs("button",{type:"button",onClick:()=>{oe||f(G=>!G)},disabled:oe,"aria-pressed":u,className:Te("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",oe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Z,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):n.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,Ee=X?n.jsxs("button",{type:"button",onClick:()=>{ne||m(G=>!G)},disabled:ne,"aria-pressed":p,className:Te("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ne?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Z,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,L=X?n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col items-start gap-1",children:[Ee,ve]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(It,{variant:"ghost",onClick:te,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(It,{variant:"destructive",onClick:me,disabled:g,children:t(g?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>N(!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-ring","aria-pressed":!I,children:[I?n.jsx(Z,{name:"checkbox-blank",className:"size-4"}):n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(It,{variant:"ghost",onClick:te,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(It,{variant:"destructive",onClick:me,disabled:g,children:g?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),le=X?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[D?n.jsx(cS,{open:!!i,onClose:()=>{g||te()},title:le,footer:n.jsx("div",{className:"flex justify-end gap-2",children:L}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[q&&n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:q}),ue]})}):n.jsx(qs,{open:!!i,onOpenChange:G=>{if(!G){if(g)return;te()}},children:n.jsxs(Gs,{className:Te(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:[n.jsxs(Js,{children:[n.jsxs(Zs,{className:Te(X&&"flex items-center gap-2"),children:[X&&n.jsx(Z,{name:"delete-bin",className:"h-5 w-5"}),le]}),q&&n.jsx(Qs,{children:q})]}),n.jsx("div",{className:Te(X&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:ue}),n.jsx(kn,{className:"mt-2 gap-2 pt-1 pb-1",children:L})]})}),n.jsx(db,{open:r,onOpenChange:o})]})},aP=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],lP=["dev","start","preview","serve"];async function cP(t,e,s){if(!t)return null;const r=fP(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const o=pP(s);if(o){const i=await hP(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await dP(t)){const o=await uP(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function dP(t){const e=`${t}/index.html`,s=await Wo(e,t);return typeof s=="string"&&s.trim().length>0}async function uP(){try{const t=await Us("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function fP(t){for(const e of t){const s=`${e.name} ${e.command}`.toLowerCase();if(lP.some(o=>s.includes(o)))return e}return null}function pP(t){for(const{pattern:e}of aP)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function hP(t){const e=await Wo(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of s){const i=await Wo(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Wo(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Us(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const s=gu()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await Us(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function mP(t){try{const e=await Wo(`${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 gP=/\{(worktree|branch)\}/g,Vi=63,bP=new Set(["main","master"]),vh=t=>/\{(worktree|branch)\}/.test(t??""),yP=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},wh=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Vi)return e;const s=await yP(e);return s?`${e.slice(0,Vi-7).replace(/-+$/,"")}-${s}`:e.slice(0,Vi).replace(/-+$/,"")},xP=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},SP=async(t,e,s)=>{const r=s.includes("{branch}"),o=s.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:xP(i.current),linkedWorktree:o}},vP=async t=>!t.linkedWorktree||!t.branch||bP.has(t.branch)?"":wh(t.branch.split("/").pop()??""),wP=t=>{const e=t.lastIndexOf("@"),s=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,c=o>=0?r.slice(o):"",l=i.split(".").map(d=>d.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${l.join(".")}${c}`},kP=async(t,e)=>{const s={worktree:await vP(e),branch:e.branch?await wh(e.branch):""},r=t.replace(gP,(d,u)=>s[u]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",c="",l=""]=o;return`${i}${wP(c)}${l}`},jP=async(t,e,s)=>vh(e)?kP(e,await SP(t,s,e)):e,kh="oc.projectActions.selectedAction.v1",CP=Dr(Ls(),Dr(Ls(),Ls())),jh=()=>{const t=Yo().getItem(kh);if(t===null)return{};try{const e=CP.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},Yd=(t,e=Gt())=>jh()[e]?.[t]??null,PP=(t,e,s=Gt())=>{const r=jh();r[s]?.[t]!==e&&Yo().setItem(kh,JSON.stringify({...r,[s]:{...r[s],[t]:e}}))},EP=15e3,IP=3e3,TP=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},DP=({projectRef:t,directory:e,allowMobile:s=!1})=>{const{t:r}=Ct(),{currentTheme:o}=cr(),{terminal:i,runtime:c,git:l}=_s(),d=fn(),{isMobile:u}=En(),f=a.useMemo(()=>cn(),[]),p=nc(ee=>ee.instances),m=nc(ee=>ee.load),g=de(ee=>ee.terminalShell),b=de(ee=>ee.terminalLoginShells.includes(ee.terminalShell)),v=de(ee=>ee.setSettingsPage),x=de(ee=>ee.setSettingsDialogOpen),y=de(ee=>ee.setSettingsProjectsSelectedId),h=de(ee=>ee.openContextPreview),S=At(ee=>ee.ensureDirectory),w=At(ee=>ee.reconcileServerSessions),C=At(ee=>ee.setTabLabel),k=At(ee=>ee.setTabIconKey),T=At(ee=>ee.setActiveTab),O=At(ee=>ee.setConnecting),K=At(ee=>ee.setTabSessionId),R=At(ee=>ee.setTabPurpose),I=At(ee=>ee.allocateActionExecution),N=At(ee=>ee.setTabLifecycle),W=At(ee=>ee.setTabPreviewUrl),z=At(ee=>ee.matchesActionExecution),H=At(ee=>ee.captureStartedActionMutationRevisions),[M,Y]=a.useState([]),j=a.useRef(null),[P,D]=a.useState(()=>t?.id?Yd(t.id):null),[V,B]=a.useState(!1),_=a.useRef({}),F=a.useRef({}),X=a.useRef({}),oe=a.useRef(new Set),ne=a.useRef(0),[A,te]=a.useState({}),U=t?.id??null,Pe=t?.path??"";a.useEffect(()=>{D(U?Yd(U):null)},[U]);const xe=a.useMemo(()=>U?{id:U,path:Pe}:null,[U,Pe]);a.useEffect(()=>{f&&m().catch(()=>{})},[f,m]);const ce=a.useCallback(async ee=>{await ti(ee)},[]),Oe=a.useCallback(async()=>{if(!xe)return;const ee=ne.current+1;ne.current=ee,B(!0);try{const _e=await xc(xe);if(ne.current!==ee)return;j.current=_e;const Be=_e.projectActions;Y(Be)}catch{if(ne.current!==ee)return}finally{ne.current===ee&&B(!1)}},[xe]),me=a.useMemo(()=>Ci(e||xe?.path||""),[e,xe?.path]),ie=a.useMemo(()=>Ci(xe?.path||""),[xe?.path]),q=a.useMemo(()=>Ci(d||"")||me,[d,me]),ue=a.useRef(q);a.useEffect(()=>{ue.current=q},[q]);const ve=At(ee=>me?ee.getDirectoryState(me):void 0),Ee=At(ee=>ie&&ie!==me?ee.getDirectoryState(ie):void 0),L=a.useMemo(()=>{const ee=me?[{directory:me,state:ve}]:[];return ie&&ie!==me&&ee.push({directory:ie,state:Ee}),ee},[ve,me,ie,Ee]),le=a.useMemo(()=>{const ee=me?[me]:[];return ie&&ie!==me&&ee.push(ie),ee},[me,ie]),G=a.useCallback(ee=>ee.id!==Tn&&ee.runIn==="parent"&&ie||me,[me,ie]),se=a.useCallback((ee,_e,Be)=>`${ee}::${_e}::${Be}`,[]),je=a.useCallback((ee,_e,Be=At.getState())=>ee?Be.getDirectoryState(ee)?.tabs.find(Ke=>Ke.purpose.type==="project-action"&&Ke.purpose.actionId===_e)??null:null,[]),he=a.useMemo(()=>{const ee={};for(const{directory:_e,state:Be}of L)for(const Ke of Be?.tabs??[]){if(Ke.purpose.type!=="project-action"||!Ke.purpose.executionId||!Ke.terminalSessionId||Ke.lifecycle==="idle"||Ke.lifecycle==="exited")continue;const Fe=Kn(_e,Ke.purpose.actionId),tt=se(_e,Ke.purpose.actionId,Ke.purpose.executionId);ee[Fe]={directory:_e,actionId:Ke.purpose.actionId,tabId:Ke.id,sessionId:Ke.terminalSessionId,executionId:Ke.purpose.executionId,status:Ke.lifecycle==="stopping"?"stopping":A[tt]?"waiting-for-preview":"running"}}return ee},[se,A,L]),ge=a.useCallback((ee,_e,Be)=>{const Ke=Kn(ee,_e),Fe=se(ee,_e,Be),bt=_.current[Ke]?.executionId===Be,mt=globalThis.window,it=Tt=>{mt?.clearTimeout(X.current[Tt]),delete X.current[Tt]};bt&&(delete _.current[Ke],it(Ke)),F.current[Fe]?.(),delete F.current[Fe],it(Fe),te(Tt=>{if(!Tt[Fe])return Tt;const at={...Tt};return delete at[Fe],at})},[se]),ke=a.useCallback(ee=>{F.current[ee]?.(),delete F.current[ee]},[]),Ae=a.useCallback(ee=>{window.clearTimeout(X.current[ee]),delete X.current[ee]},[]);a.useEffect(()=>{const ee=F.current,_e=X.current;return()=>{for(const Be of Object.keys(ee))ke(Be);for(const Be of Object.keys(_e))Ae(Be)}},[Ae,ke]),a.useEffect(()=>{const ee=new Set(le);for(const _e of Object.values(_.current))ee.has(_e.directory)||ge(_e.directory,_e.actionId,_e.executionId);for(const _e of Object.keys(F.current)){const Be=_e.split("::",1)[0]??"";ee.has(Be)||ke(_e)}},[ge,ke,le]);const $=a.useCallback((ee,_e)=>{de.getState().openContextPanelTab(ee,{mode:"terminal",targetDirectory:_e===ee?null:_e})},[]),fe=a.useMemo(()=>({id:Tn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),be=!u,Ie=a.useMemo(()=>be?[...M,fe]:M,[M,fe,be]),Ye=a.useMemo(()=>P?Ie.find(ee=>ee.id===P)??null:null,[Ie,P]);a.useEffect(()=>{Oe()},[Oe]);const[nt,Ue]=a.useState(0),Ve=a.useCallback(()=>(Ue(ee=>ee+1),()=>Ue(ee=>ee-1)),[]),Se=nt>0;a.useEffect(()=>{if(!Se)return;const ee=le.map(_e=>Xi(i,_e,H,Be=>w(_e,Be.sessions,{startedActionMutationRevisions:Be.startedActionMutationRevisions})));return()=>{for(const _e of ee)_e()}},[H,Se,w,i,le]),a.useEffect(()=>{for(const{directory:ee,state:_e}of L)if(ee)for(const Be of _e?.tabs??[]){if(Be.purpose.type!=="project-action")continue;const Ke=Be.purpose.actionId,Fe=Ie.find(mt=>mt.id===Ke),tt=Fe?.name??Ke,bt=Fe?.icon||"play";Be.label!==tt&&C(ee,Be.id,tt),Be.iconKey!==bt&&k(ee,Be.id,bt)}},[Ie,k,C,L]),a.useEffect(()=>{const ee=globalThis.window;if(!ee)return;const _e=Be=>{const Ke=Be.detail;U&&(Ke?.projectId&&Ke.projectId!==U||Oe())};return ee.addEventListener(Sc,_e),()=>{ee.removeEventListener(Sc,_e)}},[Oe,U]),a.useEffect(()=>{const ee=Be=>{delete X.current[Be];const Ke=_.current[Be];if(!Ke||Ke.openedUrl)return;const Fe=se(Ke.directory,Ke.actionId,Ke.executionId),tt=Ke.announced;if(tt.length!==0){if(window.clearTimeout(X.current[Fe]),delete X.current[Fe],Ke.openedUrl=!0,te(bt=>{if(!bt[Fe])return bt;const mt={...bt};return delete mt[Fe],mt}),tt.length===1){Oi(Ke.directory,[]),W(Ke.directory,Ke.tabId,tt[0],{locked:!1,autoOpened:!0}),h(Ke.directory,tt[0]);return}Ke.offering=!0,Oi(Ke.directory,tt),de.getState().openContextSurface(Ke.directory,"browser"),ze.info(r("projectActions.toast.multipleServers"))}},_e=()=>{const Be=At.getState(),Ke=Be.sessions,Fe=he;for(const[tt,bt]of Object.entries(Fe)){const it=Ke.get(bt.directory)?.tabs.find(st=>st.id===bt.tabId);if(!it||it.terminalSessionId!==bt.sessionId){ge(bt.directory,bt.actionId,bt.executionId);continue}const Tt=_.current[tt],at=Tt?.executionId===bt.executionId?Tt:{hostDirectory:ue.current||bt.directory,directory:bt.directory,tabId:bt.tabId,actionId:bt.actionId,executionId:bt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};_.current[tt]=at;const $t=Ie.find(st=>st.id===bt.actionId),zt=Be.getBuffer(bt.directory,bt.tabId).chunks;if(!$t||zt.length===0)continue;const Mt=zt.filter(st=>at.lastSeenChunkId===null||st.id>at.lastSeenChunkId);if(Mt.length===0)continue;const Re=Mt.map(st=>st.data).join(""),ct=`${at.tail}${Re}`;for(const st of mb(ct))at.proxiedPorts.includes(st)||at.proxiedPorts.push(st);if(at.openInPreview&&(!at.openedUrl||at.offering)){const st=gb(ct,{proxiedPorts:at.proxiedPorts,namedAddressesReachable:!rc()}),wt=at.announced.length;for(const E of st)at.announced.includes(E)||at.announced.push(E);const pt=at.announced.length-wt;at.offering&&pt>0?Oi(bt.directory,at.announced):!at.openedUrl&&wt===0&&at.announced.length>0&&(window.clearTimeout(X.current[tt]),X.current[tt]=window.setTimeout(()=>ee(tt),IP))}const lt=!at.openedUrl&&$t.autoOpenUrl===!0&&!at.openInPreview?bb(ct,{proxiedPorts:at.proxiedPorts,namedAddressesReachable:!rc()}):null,dt=Mt[Mt.length-1]?.id??at.lastSeenChunkId;if(at.lastSeenChunkId=dt,at.tail=ct.slice(-512),lt)if(at.openedUrl=!0,at.openInPreview){const st=Fe[tt];st&&(W(st.directory,st.tabId,lt,{locked:!1,autoOpened:!1,expectedExecutionId:st.executionId}),st.status==="waiting-for-preview"&&te(wt=>{const pt=se(st.directory,st.actionId,st.executionId);if(!wt[pt])return wt;const E={...wt};return delete E[pt],E}),window.clearTimeout(X.current[tt]),delete X.current[tt],h(st.directory,lt))}else ce(lt),ze.success(r("projectActions.toast.openedUrlFromOutput"));_.current[tt]=at}for(const tt of Object.keys(_.current))if(!Fe[tt]){const bt=_.current[tt],mt=bt?Ke.get(bt.directory)?.tabs.find(Tt=>Tt.id===bt.tabId):void 0;if(mt?.purpose.type==="project-action"&&mt.purpose.executionId===bt?.executionId&&!!mt.terminalSessionId&&mt.lifecycle!=="idle"&&mt.lifecycle!=="exited")continue;delete _.current[tt],window.clearTimeout(X.current[tt]),delete X.current[tt]}};return _e(),At.subscribe((Be,Ke)=>{(Be.sessions!==Ke.sessions||Be.buffers!==Ke.buffers)&&_e()})},[ge,ue,Ie,se,h,ce,he,W,r]),a.useEffect(()=>{for(const{directory:ee,state:_e}of L)for(const Be of _e?.tabs??[]){if(Be.purpose.type!=="project-action"||!Be.purpose.executionId||!Be.terminalSessionId||Be.lifecycle!=="running")continue;const Ke=Be.purpose.actionId,Fe=Be.purpose.executionId,tt=se(ee,Ke,Fe);if(F.current[tt])continue;const bt=i.connect(Be.terminalSessionId,{onEvent:mt=>{if(!z(ee,Be.id,Fe))return;mt.type==="snapshot"&&(At.getState().replaceBuffer(ee,Be.id,mt.data??"",mt.sequence??0,Vl(mt)),mt.status==="running"&&At.getState().setTabLifecycle(ee,Be.id,"running",{expectedExecutionId:Fe}),mt.status==="exited"&&(At.getState().setTabLifecycle(ee,Be.id,"exited",{expectedExecutionId:Fe}),At.getState().setTabPurpose(ee,Be.id,{type:"project-action",actionId:Ke,executionId:null}),ge(ee,Ke,Fe)));const it=mt.type==="data"?mt.data??"":"";it&&At.getState().appendToBuffer(ee,Be.id,it,mt.sequence,mt.replayData),mt.type==="exit"&&(At.getState().setTabLifecycle(ee,Be.id,"exited",{expectedExecutionId:Fe}),At.getState().setTabPurpose(ee,Be.id,{type:"project-action",actionId:Ke,executionId:null}),ge(ee,Ke,Fe))},onError:(mt,it)=>{!it||!z(ee,Be.id,Fe)||(At.getState().setTabLifecycle(ee,Be.id,"exited",{expectedExecutionId:Fe}),At.getState().setTabSessionId(ee,Be.id,null,{expectedExecutionId:Fe}),At.getState().setTabPurpose(ee,Be.id,{type:"project-action",actionId:Ke,executionId:null}),ge(ee,Ke,Fe))}},ee);F.current[tt]=bt.close}},[ge,se,z,i,L]);const ye=a.useCallback(async ee=>{const _e=G(ee);if(!_e)throw new Error(r("projectActions.error.noActiveDirectory"));const Be=Kn(_e,ee.id);S(_e);const Ke=At.getState(),Fe=je(_e,ee.id,Ke),tt=Fe?.id??Ke.createTab(_e);C(_e,tt,ee.name),k(_e,tt,ee.icon||"play"),Fe||R(_e,tt,{type:"project-action",actionId:ee.id,executionId:null}),T(_e,tt);const mt=At.getState().getDirectoryState(_e)?.tabs.find(it=>it.id===tt);return{executionDirectory:_e,key:Be,tabId:tt,sessionId:mt?.terminalSessionId??null,executionId:mt?.purpose.type==="project-action"?mt.purpose.executionId:null}},[S,G,je,T,k,C,R,r]),Ge=a.useCallback(async ee=>{if(c.isVSCode||!s&&u)return;if(!me){ze.error(r("projectActions.error.noActiveDirectoryForAction"));return}const _e=Kn(G(ee),ee.id),Be=he[_e];if(Be&&Be.status==="running"||oe.current.has(_e))return;oe.current.add(_e);let Ke=null;try{const Fe=ee.id===Tn?await(async()=>{const[Ne,Ce]=await Promise.all([dS({id:xe?.id??"",path:me}),mP(me)]),We=await cP(me,Ne.actions,Ce);if(!We)throw new Error(r("contextPanel.preview.noDevServer"));return{id:Tn,name:r("projectActions.actions.autoDiscover"),command:We.command,icon:"scan-2",autoOpenUrl:!0,openUrl:We.previewUrlHint||""}})():ee,tt=Fe.autoOpenUrl===!0&&(Fe.openUrl||"").trim().length>0,bt=!tt&&ee.id!==Tn,mt=ue.current||me,{executionDirectory:it,key:Tt,tabId:at}=await ye(Fe),$t=ub(Fe.command);if(!$t)throw new Error(r("projectActions.error.failedToRunAction"));const zt=Fe.autoOpenUrl===!0&&f&&(Fe.desktopOpenSshForward||"").trim().length>0,Mt=Fe.autoOpenUrl&&Fe.openUrl||"";let Re=!1;const ct=vh(Mt)?await jP(l,Mt,it).catch(()=>(Re=!0,"")):Mt,lt=Fe.autoOpenUrl?TP(ct):null,dt=Fe.autoOpenUrl&&f?uS(Fe.desktopOpenSshForward,p):null;if(i.listSessions){const Ne=je(it,Fe.id);if(Ne?.purpose.type==="project-action"&&Ne.purpose.executionId===null){const Ce=await fb(i,it,{captureStartedActionMutationRevisions:H});Ce&&w(it,Ce.sessions,{startedActionMutationRevisions:Ce.startedActionMutationRevisions})}}const st=je(it,Fe.id);let wt,pt;if(st?.lifecycle==="running"&&st.terminalSessionId&&st.purpose.type==="project-action"&&st.purpose.executionId)wt=st.terminalSessionId,pt=st.purpose.executionId;else{const Ne=st?.purpose.type==="project-action"?st.purpose.executionId:null;Ne&&ge(it,Fe.id,Ne);const Ce=I(it,at,Fe.id);if(!Ce)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));Ke={directory:it,tabId:at,id:Ce},O(it,at,!0,{expectedExecutionId:Ce});const We=await pb({terminal:i,createOptions:{cwd:it,shell:g,loginShell:b,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:$t,isRunStillExpected:()=>z(it,at,Ce),purpose:{type:"project-action",actionId:Fe.id,executionId:Ce}});if(!z(it,at,Ce)){We.sessionId===Ce&&await i.close(We.sessionId).catch(()=>{});return}pt=We.purpose?.type==="project-action"?We.purpose.executionId:Ce,wt=We.sessionId,R(it,at,{type:"project-action",actionId:Fe.id,executionId:pt}),K(it,at,wt,{expectedExecutionId:pt}),O(it,at,!1,{expectedExecutionId:pt})}bt&&mt&&$(mt,it),_.current[Tt]={hostDirectory:mt,directory:it,tabId:at,actionId:Fe.id,executionId:pt,lastSeenChunkId:null,openedUrl:!!dt||!!lt||tt,tail:"",openInPreview:Fe.id===Tn,announced:[],offering:!1,proxiedPorts:[]};const E=se(it,Fe.id,pt);O(it,at,!0,{expectedExecutionId:pt});const Q=i.connect(wt,{onEvent:Ne=>{if(!z(it,at,pt)||Ne.purpose?.type==="project-action"&&Ne.purpose.executionId!==pt)return;Ne.type==="snapshot"&&(At.getState().replaceBuffer(it,at,Ne.data??"",Ne.sequence??0,Vl(Ne)),At.getState().setConnecting(it,at,!1,{expectedExecutionId:pt}),Ne.purpose?.type==="project-action"&&At.getState().setTabPurpose(it,at,{type:"project-action",actionId:Ne.purpose.actionId,executionId:Ne.purpose.executionId}),Ne.status==="running"&&At.getState().setTabLifecycle(it,at,"running",{expectedExecutionId:pt}),Ne.status==="exited"&&(At.getState().setTabLifecycle(it,at,"exited",{expectedExecutionId:pt}),At.getState().setTabPurpose(it,at,{type:"project-action",actionId:Fe.id,executionId:null}),ge(it,Fe.id,pt)));const Ce=Ne.type==="data"?Ne.data??"":"";Ce&&At.getState().appendToBuffer(it,at,Ce,Ne.sequence,Ne.replayData),Ne.type==="exit"&&(At.getState().setTabLifecycle(it,at,"exited",{expectedExecutionId:pt}),At.getState().setConnecting(it,at,!1,{expectedExecutionId:pt}),At.getState().setTabPurpose(it,at,{type:"project-action",actionId:Fe.id,executionId:null}),ge(it,Fe.id,pt))},onError:(Ne,Ce)=>{z(it,at,pt)&&(At.getState().setConnecting(it,at,!1,{expectedExecutionId:pt}),Ce&&(At.getState().setTabLifecycle(it,at,"exited",{expectedExecutionId:pt}),At.getState().setTabSessionId(it,at,null,{expectedExecutionId:pt}),At.getState().setTabPurpose(it,at,{type:"project-action",actionId:Fe.id,executionId:null}),ge(it,Fe.id,pt)))}},it);if(!z(it,at,pt)){Q.close();return}F.current[E]?.(),F.current[E]=Q.close,window.clearTimeout(X.current[E]),delete X.current[E],Fe.id===Tn&&!lt&&(te(Ne=>({...Ne,[E]:!0})),X.current[E]=window.setTimeout(()=>{delete X.current[E];const Ne=_.current[Tt];!Ne||Ne.executionId!==pt||Ne.openedUrl||Ne.offering||z(it,at,pt)&&(te(Ce=>{if(!Ce[E])return Ce;const We={...Ce};return delete We[E],We}),At.getState().setActiveTab(it,at),$(Ne.hostDirectory,it))},EP)),dt?(W(it,at,null,{locked:!0,expectedExecutionId:pt}),ce(dt),ze.success(r("projectActions.toast.openedForwardedUrl"))):lt?(W(it,at,lt,{locked:!0,autoOpened:!0,expectedExecutionId:pt}),h(mt,lt),ze.success(r("projectActions.toast.openedActionUrl"))):Re?(W(it,at,null,{locked:!0,expectedExecutionId:pt}),ze.error(r("projectActions.error.openUrlTemplateUnresolved"))):tt?(W(it,at,null,{locked:!0,expectedExecutionId:pt}),ze.error(r("projectActions.error.invalidCustomUrlFormat"))):zt?(W(it,at,null,{locked:!0,expectedExecutionId:pt}),ze.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):W(it,at,null,{locked:!1,autoOpened:!1,expectedExecutionId:pt})}catch(Fe){if(Ke&&z(Ke.directory,Ke.tabId,Ke.id)){const{directory:tt,tabId:bt,id:mt}=Ke;ge(tt,ee.id,mt),N(tt,bt,"exited",{expectedExecutionId:mt}),R(tt,bt,{type:"project-action",actionId:ee.id,executionId:null})}if(Fe instanceof Error&&Fe.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Fe instanceof Error&&(Fe.message==="COMMAND_MODE_UNSUPPORTED"||Fe.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){ze.error(r("projectActions.error.failedToCreateTerminalSession"));return}ze.error(Fe instanceof Error?Fe.message:r("projectActions.error.failedToRunAction"))}finally{oe.current.delete(_e)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,ue,p,ye,l,s,u,f,me,b,g,ce,h,he,$,c.isVSCode,G,z,ge,se,je,w,I,H,O,N,R,W,K,xe?.id,r,i]),qe=a.useCallback(async ee=>{const _e=Kn(G(ee),ee.id),Be=he[_e];Be&&await hb({terminal:i,sessionId:Be.sessionId,isExecutionStillCurrent:()=>z(Be.directory,Be.tabId,Be.executionId),markStopping:()=>{N(Be.directory,Be.tabId,"stopping",{expectedExecutionId:Be.executionId})},restoreRunning:()=>{N(Be.directory,Be.tabId,"running",{expectedExecutionId:Be.executionId})},clearSession:()=>{K(Be.directory,Be.tabId,null,{expectedExecutionId:Be.executionId})},finalizeExit:()=>{N(Be.directory,Be.tabId,"exited",{expectedExecutionId:Be.executionId}),R(Be.directory,Be.tabId,{type:"project-action",actionId:Be.actionId,executionId:null}),ge(Be.directory,Be.actionId,Be.executionId)}})},[ge,G,z,he,N,R,K,i]),ft=a.useCallback(async ee=>{if(ee.source==="shared"&&xe){const _e=j.current?.trust.trusted?j.current:await xc(xe);if(j.current=_e,!await fS(xe,_e))return;j.current={..._e,trust:{..._e.trust,trusted:!0}}}await Ge(ee)},[Ge,xe]),et=a.useCallback(ee=>he[Kn(G(ee),ee.id)]??null,[G,he]),St=(Ye&&et(Ye)?Ye:null)??Ie.find(ee=>et(ee)!==null)??Ye??Ie[0]??null,we=a.useCallback(ee=>{const _e=et(ee);if(_e?.status!=="stopping"){if(_e){qe(ee);return}ft(ee)}},[ft,et,qe]),De=a.useCallback(ee=>{ft(ee)},[ft]),ot=a.useCallback(ee=>{qe(ee)},[qe]),rt=a.useCallback(ee=>{D(ee.id),U&&PP(U,ee.id)},[U]),Xe=a.useCallback(()=>{xe?.id&&(y(xe.id),v("projects"),x(!0))},[x,v,y,xe?.id]),ht=!c.isVSCode&&(s||!u)&&!!xe&&!!me;return a.useMemo(()=>({available:ht,actions:ht?Ie:[],shown:ht?St:null,isLoading:V,observe:Ve,runOf:et,select:rt,run:De,stop:ot,toggle:we,openSettings:Xe}),[ht,Ie,V,Ve,Xe,De,et,rt,St,ot,we])},RP=t=>{const e=Je.c(6);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=DP(r);let i;return e[3]!==s||e[4]!==o?(i=n.jsx(pS.Provider,{value:o,children:s}),e[3]=s,e[4]=o,e[5]=i):i=e[5],i},NP=t=>{const e=Je.c(4),{children:s}=t,r=hS(),o=r?.projectRef??null,i=r?.directory??"";let c;return e[0]!==s||e[1]!==o||e[2]!==i?(c=n.jsx(RP,{projectRef:o,directory:i,children:s}),e[0]=s,e[1]=o,e[2]=i,e[3]=c):c=e[3],c};function ci(t,e,s){const[r,o]=a.useState(null),i=a.useRef(s);return i.current=s,a.useEffect(()=>{if(!t||r)return;let c=!1;return mS(e).then(l=>{c||o(()=>l)},l=>{console.error("[on-demand] failed to load component",l),c||i.current()}),()=>{c=!0}},[r,e,t]),r}function MP(t){const e=[],s=(r,o)=>{const i=vt(r);!i||e.some(c=>c.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const AP=new Map,OP=t=>{const e=Je.c(23),{isVSCode:s}=t,r=Fr(),o=Jt(BP),i=xs(FP),c=xt(LP);let l;e[0]!==s?(l=K=>s?AP:K.availableWorktreesByProject,e[0]=s,e[1]=l):l=e[1];const d=xt(l),u=!s;let f;e[2]!==d||e[3]!==o||e[4]!==u?(f=Sh(o,d,{includeWorktrees:u}),e[2]=d,e[3]=o,e[4]=u,e[5]=f):f=e[5];const p=f,m=Ps(_P),g=Ps($P),b=Ps(zP),v=`session-list-sync:${a.useId()}`;let x,y;e[6]!==v||e[7]!==r||e[8]!==i||e[9]!==c?(x=()=>(r.setBootstrapDemand(v,MP({currentDirectory:i,currentSessionDirectory:c})),()=>r.clearBootstrapDemand(v)),y=[v,r,i,c],e[6]=v,e[7]=r,e[8]=i,e[9]=c,e[10]=x,e[11]=y):(x=e[10],y=e[11]),a.useEffect(x,y);const h=a.useRef(null);let S,w;e[12]!==s||e[13]!==p?(S=()=>{const K=new Set(p),R=h.current;h.current=K;const I=R?[...K].filter(N=>!R.has(N)):s?[...K]:[];I.length&&Va(I,oa())},w=[s,p],e[12]=s,e[13]=p,e[14]=S,e[15]=w):(S=e[14],w=e[15]),a.useEffect(S,w);let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[16]=C):C=e[16],a.useEffect(KP,C);let k;e[17]!==g||e[18]!==m?(k=[...m,...g],e[17]=g,e[18]=m,e[19]=k):k=e[19];const T=k;let O;e[20]!==T||e[21]!==b?(O={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:T},e[20]=T,e[21]=b,e[22]=O):O=e[22],yb(O)};function BP(t){return t.projects}function FP(t){return t.currentDirectory}function LP(t){return t.currentSessionDirectory}function _P(t){return t.activeSessions}function $P(t){return t.archivedSessions}function zP(t){return t.status==="ready"}function KP(){let t=null,e=!1;const s=new Set,r=jn(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")s.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,s.clear(),Mf(oa());return}const i=[...s];s.clear(),i.length&&Va(i,oa())},500)});return()=>{t&&clearTimeout(t),r()}}const WP=()=>ss(()=>import("./SettingsWindow-Cx6TrtY0.js"),__vite__mapDeps([144,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,145,84,146,131,132,133,134,140,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,147,148,139,127,149])).then(t=>t.SettingsWindow),HP=()=>ss(()=>import("./CommandPalette-CtKzNzwW.js"),__vite__mapDeps([150,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,149,84,122,123,124])).then(t=>t.CommandPalette),VP=()=>ss(()=>import("./HelpDialog-9YZGhBgT.js"),__vite__mapDeps([151,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])).then(t=>t.HelpDialog),UP=()=>ss(()=>import("./ProjectActionsDialog-DATu0aBc.js"),__vite__mapDeps([152,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])).then(t=>t.ProjectActionsDialog),GP=()=>ss(()=>import("./OpenCodeStatusDialog-CXBWWRh8.js"),__vite__mapDeps([153,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])).then(t=>t.OpenCodeStatusDialog),qP=()=>ss(()=>import("./RunOverview-D6xy_vME.js"),__vite__mapDeps([154,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])).then(t=>t.RunOverview),YP=()=>ss(()=>import("./ScheduledTasksDialog-BWXVnfrf.js"),__vite__mapDeps([155,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,142,156,157])).then(t=>t.ScheduledTasksDialog),XP=()=>ss(()=>import("./ArchiveView-CkeSWPcI.js"),__vite__mapDeps([158,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])).then(t=>t.ArchiveView),ZP=()=>ss(()=>import("./UsageStatsView-D7WrDBTC.js"),__vite__mapDeps([159,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])).then(t=>t.UsageStatsView),QP=()=>ss(()=>import("./SourceBoardView-yca1qvgB.js"),__vite__mapDeps([160,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])).then(t=>t.SourceBoardView),JP=()=>ss(()=>import("./WorktreesView-C-t7uxq1.js"),__vite__mapDeps([161,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])).then(t=>t.WorktreesView),eE=()=>ss(()=>import("./SpacesView-DvoOh4sM.js"),__vite__mapDeps([162,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,163,84])).then(t=>t.SpacesView),tE=()=>ss(()=>import("./SpaceAccessDialog-CZ-u75py.js"),__vite__mapDeps([164,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,165])).then(t=>t.SpaceAccessDialog),sE=()=>ss(()=>import("./SpaceApplyDialog-BtuwtlaG.js"),__vite__mapDeps([166,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,167])).then(t=>t.SpaceApplyDialog),nE=()=>ss(()=>import("./SpaceSetupOutput-Uo5LS7Jy.js"),__vite__mapDeps([168,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,165])).then(t=>t.SpaceSetupOutputDialog),Nn=()=>de.getState().closeMainSurfaces(),ks=t=>{const e=Je.c(2),{needed:s,load:r,onFailure:o}=t,i=ci(s,r,o);let c;return e[0]!==i?(c=i?n.jsx(i,{}):null,e[0]=i,e[1]=c):c=e[1],c},Ch=a.memo(t=>{const e=Je.c(11),{isMobile:s}=t,r=de(oE),o=!r&&!s,i=Jo();let c;e[0]!==o||e[1]!==i?(c={enabled:o,layoutAnimationMs:i},e[0]=o,e[1]=i,e[2]=c):c=e[2];const l=lv(c);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(sv,{}),e[3]=d):d=e[3];const u=r||l.state!==!1;let f;e[4]!==u?(f=n.jsx(oP,{isVisible:u}),e[4]=u,e[5]=f):f=e[5];let p;return e[6]!==s||e[7]!==r||e[8]!==l||e[9]!==f?(p=n.jsx(tv,{isOpen:r,isMobile:s,className:"border-border",topBar:d,peek:l,children:f}),e[6]=s,e[7]=r,e[8]=l,e[9]=f,e[10]=p):p=e[10],p});Ch.displayName="LeftSidebar";const rE=()=>{const t=Je.c(104);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],OP(e),xb();const s=de(iE),r=de(aE),o=de(lE),i=de(cE);let c;t[1]!==i?(c=()=>i(!1),t[1]=i,t[2]=c):c=t[2];const l=ci(o,WP,c),d=de(dE),u=de(uE),f=de(fE),p=de(pE),m=de(hE),g=de(mE),b=de(gE),v=de(bE),x=de(yE),y=de(xE),h=de(SE),S=Vs(vE),w=Vs(wE),C=Vs(kE),k=de(jE),T=hf();let O;if(t[3]!==T||t[4]!==k){let qe;t[6]!==k?(qe=ft=>ft.id===k,t[6]=k,t[7]=qe):qe=t[7],O=T.find(qe),t[3]=T,t[4]=k,t[5]=O}else O=t[5];const K=O;let R,I;t[8]!==K||t[9]!==k?(R=()=>{k&&!K&&de.getState().setOpenGuestPage(null)},I=[k,K],t[8]=K,t[9]=k,t[10]=R,t[11]=I):(R=t[10],I=t[11]),a.useEffect(R,I);let N;t[12]===Symbol.for("react.memo_cache_sentinel")?(N=[],t[12]=N):N=t[12],a.useEffect(PE,N);let W;t[13]===Symbol.for("react.memo_cache_sentinel")?(W=[],t[13]=W):W=t[13],a.useEffect(EE,W);const z=u||f||p||m||!!g||b||d||!!K;let H,M;t[14]!==z?(H=()=>{Af(z)},M=[z],t[14]=z,t[15]=H,t[16]=M):(H=t[15],M=t[16]),a.useLayoutEffect(H,M);let Y;t[17]===Symbol.for("react.memo_cache_sentinel")?(Y=[],t[17]=Y):Y=t[17],a.useEffect(TE,Y);let j;t[18]===Symbol.for("react.memo_cache_sentinel")?(j=[],t[18]=j):j=t[18],a.useEffect(RE,j);const{isMobile:P}=En();Sb();let D,V;t[19]!==P||t[20]!==r?(D=()=>{de.getState().isMobile!==P&&r(P)},V=[P,r],t[19]=P,t[20]=r,t[21]=D,t[22]=V):(D=t[21],V=t[22]),a.useEffect(D,V);let B;t[23]!==v?(B=n.jsx(ks,{needed:v,load:HP,onFailure:NE}),t[23]=v,t[24]=B):B=t[24];let _;t[25]!==x?(_=n.jsx(ks,{needed:x,load:VP,onFailure:ME}),t[25]=x,t[26]=_):_=t[26];let F;t[27]!==y?(F=n.jsx(ks,{needed:y,load:UP,onFailure:AE}),t[27]=y,t[28]=F):F=t[28];let X;t[29]!==h?(X=n.jsx(ks,{needed:h,load:GP,onFailure:OE}),t[29]=h,t[30]=X):X=t[30];let oe,ne;t[31]===Symbol.for("react.memo_cache_sentinel")?(oe=n.jsx(vb,{}),ne=n.jsx(iP,{}),t[31]=oe,t[32]=ne):(oe=t[31],ne=t[32]);let A;t[33]!==S||t[34]!==w||t[35]!==C||t[36]!==s?(A=s?n.jsxs(n.Fragment,{children:[n.jsx(ks,{needed:S,load:tE,onFailure:BE}),n.jsx(wb,{}),n.jsx(ks,{needed:w,load:sE,onFailure:FE}),n.jsx(kb,{}),n.jsx(ks,{needed:C,load:nE,onFailure:LE})]}):null,t[33]=S,t[34]=w,t[35]=C,t[36]=s,t[37]=A):A=t[37];let te;t[38]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx(cv,{}),t[38]=te):te=t[38];let U;t[39]!==P?(U=n.jsx(Ch,{isMobile:P}),t[39]=P,t[40]=U):U=t[40];let Pe;t[41]===Symbol.for("react.memo_cache_sentinel")?(Pe=n.jsx(ev,{}),t[41]=Pe):Pe=t[41];let xe;t[42]===Symbol.for("react.memo_cache_sentinel")?(xe=n.jsx(Mi,{zone:"left"}),t[42]=xe):xe=t[42];const ce=z&&"invisible";let Oe;t[43]!==ce?(Oe=Te("absolute inset-0",ce),t[43]=ce,t[44]=Oe):Oe=t[44];const me=!o&&!z;let ie;t[45]!==me?(ie=n.jsx(vs,{children:n.jsx(Cu,{active:me})}),t[45]=me,t[46]=ie):ie=t[46];let q;t[47]!==Oe||t[48]!==ie?(q=n.jsx("div",{className:Oe,children:ie}),t[47]=Oe,t[48]=ie,t[49]=q):q=t[49];let ue;t[50]!==d?(ue=n.jsx(vs,{children:n.jsx(ks,{needed:d,load:qP,onFailure:Nn})}),t[50]=d,t[51]=ue):ue=t[51];let ve;t[52]!==u?(ve=n.jsx(vs,{children:n.jsx(ks,{needed:u,load:YP,onFailure:Nn})}),t[52]=u,t[53]=ve):ve=t[53];let Ee;t[54]!==f?(Ee=n.jsx(vs,{children:n.jsx(ks,{needed:f,load:XP,onFailure:Nn})}),t[54]=f,t[55]=Ee):Ee=t[55];let L;t[56]!==p?(L=p&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(vs,{children:n.jsx(ks,{needed:!0,load:ZP,onFailure:Nn})})}),t[56]=p,t[57]=L):L=t[57];let le;t[58]!==m?(le=n.jsx(ks,{needed:m,load:QP,onFailure:Nn}),t[58]=m,t[59]=le):le=t[59];const G=!!g;let se;t[60]!==G?(se=n.jsx(vs,{children:n.jsx(ks,{needed:G,load:JP,onFailure:Nn})}),t[60]=G,t[61]=se):se=t[61];let je;t[62]!==b?(je=b?n.jsx(vs,{children:n.jsx(ks,{needed:!0,load:eE,onFailure:Nn})}):null,t[62]=b,t[63]=je):je=t[63];let he;t[64]!==K?(he=K&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(vs,{children:n.jsx(gS,{mode:`plugin:${K.id}`,surface:"page",item:null,onDismiss:_E})})}),t[64]=K,t[65]=he):he=t[65];let ge;t[66]!==q||t[67]!==ue||t[68]!==ve||t[69]!==Ee||t[70]!==L||t[71]!==le||t[72]!==se||t[73]!==je||t[74]!==he?(ge=n.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[q,ue,ve,Ee,L,le,se,je,he]}),t[66]=q,t[67]=ue,t[68]=ve,t[69]=Ee,t[70]=L,t[71]=le,t[72]=se,t[73]=je,t[74]=he,t[75]=ge):ge=t[75];let ke;t[76]===Symbol.for("react.memo_cache_sentinel")?(ke=n.jsx(Mi,{zone:"bottom"}),t[76]=ke):ke=t[76];let Ae;t[77]!==ge?(Ae=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[ge,ke]}),t[77]=ge,t[78]=Ae):Ae=t[78];let $,fe,be,Ie;t[79]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(Mi,{zone:"right"}),fe=n.jsx(Lj,{}),be=n.jsx(zj,{}),Ie=n.jsx(Vj,{}),t[79]=$,t[80]=fe,t[81]=be,t[82]=Ie):($=t[79],fe=t[80],be=t[81],Ie=t[82]);let Ye;t[83]!==Ae?(Ye=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[xe,n.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:[Ae,$,fe,be,Ie]})]})}),t[83]=Ae,t[84]=Ye):Ye=t[84];let nt;t[85]===Symbol.for("react.memo_cache_sentinel")?(nt=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(vs,{children:n.jsx(u2,{})})}),t[85]=nt):nt=t[85];let Ue;t[86]===Symbol.for("react.memo_cache_sentinel")?(Ue=n.jsx(vs,{children:n.jsx(XS,{})}),t[86]=Ue):Ue=t[86];let Ve;t[87]!==Ye?(Ve=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Pe,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ye,nt,Ue]})]}),t[87]=Ye,t[88]=Ve):Ve=t[88];let Se;t[89]!==U||t[90]!==Ve?(Se=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[U,Ve]}),t[89]=U,t[90]=Ve,t[91]=Se):Se=t[91];let ye;t[92]!==l||t[93]!==o||t[94]!==i?(ye=l?n.jsx(l,{open:o,onOpenChange:i}):null,t[92]=l,t[93]=o,t[94]=i,t[95]=ye):ye=t[95];let Ge;return t[96]!==B||t[97]!==_||t[98]!==F||t[99]!==X||t[100]!==A||t[101]!==Se||t[102]!==ye?(Ge=n.jsx(jb,{children:n.jsx(NP,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[B,_,F,X,oe,ne,A,te,Se,ye]})})}),t[96]=B,t[97]=_,t[98]=F,t[99]=X,t[100]=A,t[101]=Se,t[102]=ye,t[103]=Ge):Ge=t[103],Ge};function oE(t){return t.isSidebarOpen}function iE(t){return t.isolatedSpacesEnabled}function aE(t){return t.setIsMobile}function lE(t){return t.isSettingsDialogOpen}function cE(t){return t.setSettingsDialogOpen}function dE(t){return t.runOverviewKey!==null}function uE(t){return t.isScheduledTasksDialogOpen}function fE(t){return t.isArchivePageOpen}function pE(t){return t.isUsageStatsPageOpen}function hE(t){return t.isSourceBoardOpen}function mE(t){return t.worktreesPageProjectId}function gE(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function bE(t){return t.isCommandPaletteOpen}function yE(t){return t.isHelpDialogOpen}function xE(t){return t.isProjectActionsDialogOpen}function SE(t){return t.isOpenCodeStatusDialogOpen}function vE(t){return t.accessDialog!==null}function wE(t){return t.applyDialog!==null}function kE(t){return t.setupOutputDialog!==null}function jE(t){return t.openGuestPageId}function CE(){return de.getState().setOpenGuestPage(null)}function PE(){return Uo(CE)}function EE(){return YS()}function IE(){return Af(!1)}function TE(){return IE}function DE(){return de.getState().closeMainSurfaces()}function RE(){const t=DE,e=xt.subscribe((s,r)=>{const o=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,i=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function NE(){return de.getState().setCommandPaletteOpen(!1)}function ME(){return de.getState().setHelpDialogOpen(!1)}function AE(){return de.getState().setProjectActionsDialogOpen(!1)}function OE(){return de.getState().setOpenCodeStatusDialogOpen(!1)}function BE(){return Vs.getState().closeAccessDialog()}function FE(){return Vs.getState().closeApplyDialog()}function LE(){return Vs.getState().closeSetupOutputDialog()}function _E(){return de.getState().setOpenGuestPage(null)}const Ph=12,$E=[{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"}],zE=t=>{const e=Je.c(18),{isActive:s,burstKey:r,className:o,durationMs:i,bursts:c,onComplete:l}=t,d=r===void 0?0:r,u=i===void 0?900:i,f=c===void 0?$E:c,p=fs.useRef(!1);let m,g;e[0]!==s||e[1]!==l?(m=()=>{!s&&p.current&&l?.(),s&&(p.current=!0)},g=[s,l],e[0]=s,e[1]=l,e[2]=m,e[3]=g):(m=e[2],g=e[3]),fs.useEffect(m,g);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:Ph},KE),e[4]=b):b=e[4];const v=b;if(!s)return null;let x;e[5]!==o?(x=Te("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=x):x=e[6];let y;if(e[7]!==d||e[8]!==f||e[9]!==u){let S;e[11]!==d||e[12]!==u?(S=w=>{const C={"--burst-delay":`${w.delay}ms`,"--burst-x":`${w.x}%`,"--burst-y":`${w.y}%`,"--firework-color":`var(${w.colorVar})`,"--firework-duration":`${u}ms`};return n.jsx("div",{className:"firework-burst",style:C,children:v.map((k,T)=>{const O=k.x*w.radius,K=k.y*w.radius,R={"--translate-x":`${O}px`,"--translate-y":`${K}px`,"--particle-delay":`${k.delay}ms`,color:`var(${w.colorVar})`};return n.jsx("span",{className:"firework-particle",style:R},`${w.id}-${T}-${d}`)})},`${w.id}-${d}`)},e[11]=d,e[12]=u,e[13]=S):S=e[13],y=f.map(S),e[7]=d,e[8]=f,e[9]=u,e[10]=y}else y=e[10];let h;return e[14]!==d||e[15]!==x||e[16]!==y?(h=n.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":d,children:y}),e[14]=d,e[15]=x,e[16]=y,e[17]=h):h=e[17],h};function KE(t,e){const s=Math.PI*2*e/Ph;return{x:Math.cos(s),y:Math.sin(s),delay:e*18}}const WE=t=>{const e=Je.c(13);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{durationMs:r}=s,o=r===void 0?3400:r;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={isActive:!1,cycle:0},e[2]=i):i=e[2];const[c,l]=fs.useState(i),d=fs.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const f=u;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{f(),l(HE)},e[4]=p):p=e[4];const m=p;let g;e[5]!==o?(g=()=>{f(),l(VE),d.current=window.setTimeout(()=>{l(UE),d.current=null},o)},e[5]=o,e[6]=g):g=e[6];const b=g;let v,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>f(),x=[f],e[7]=v,e[8]=x):(v=e[7],x=e[8]),fs.useEffect(v,x);let y;return e[9]!==c.cycle||e[10]!==c.isActive||e[11]!==b?(y={isActive:c.isActive,burstKey:c.cycle,triggerFireworks:b,dismissFireworks:m},e[9]=c.cycle,e[10]=c.isActive,e[11]=b,e[12]=y):y=e[12],y};function HE(t){return t.isActive?{...t,isActive:!1}:t}function VE(t){return{isActive:!0,cycle:t.cycle+1}}function UE(t){return t.isActive?{...t,isActive:!1}:t}const Eh=a.createContext(void 0),GE=t=>{const e=Je.c(10),{children:s}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:c}=WE();let l;e[0]!==c||e[1]!==i?(l={triggerFireworks:i,dismissFireworks:c},e[0]=c,e[1]=i,e[2]=l):l=e[2];const d=l;let u;e[3]!==o||e[4]!==r?(u=n.jsx(zE,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==d?(f=n.jsxs(Eh.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f},ST=()=>{const t=a.useContext(Eh);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Ma="openchamber_requests_in_flight",Ih=1e3,qE=300*1e3,Ho=Math.ceil(qE/Ih),YE=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ma)==="1"}catch{return!1}},Th=()=>({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 XE=1;const ZE=(t,e)=>{const s=window.__openchamberRequestsInFlight__;!s||!s.enabled||(s.inFlight+=1,s.totalStarted+=1,s.inFlight>s.peak&&(s.peak=s.inFlight),s.inFlightStarts.set(t,e))},QE=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Dh=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,o)=>r-o),s},er=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},JE=()=>{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 s=async(r,o)=>{const i=XE++;ZE(i,Date.now());try{return await e(r,o)}finally{QE(i)}};window.fetch=s},Xd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},yr=t=>{t.length>Ho&&t.splice(0,t.length-Ho)},eI=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Dh(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(er(e,50)),t.p90Samples.push(er(e,90)),t.p99Samples.push(er(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,yr(t.samples),yr(t.p50Samples),yr(t.p90Samples),yr(t.p99Samples),yr(t.maxSamples),t.lastSampleAt=Date.now()},tI=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(eI,Ih))},Zd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Qd=t=>{if(!(typeof window>"u"))try{if(t){Zd(),Xd(),window.localStorage.setItem(Ma,"1"),window.__openchamberRequestsInFlight__=Th(),JE(),tI();return}window.localStorage.removeItem(Ma),Zd(),Xd(),delete window.__openchamberRequestsInFlight__}catch{}},vT=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Th();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},wT=()=>{if(typeof window>"u")return Jd();const t=window.__openchamberRequestsInFlight__;if(!YE()||!t)return Jd();const e=Dh(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:er(e,50),ageP90:er(e,90),ageP99:er(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:Ho}},Jd=()=>({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:Ho}),sI=()=>{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()??"":""},nI=async()=>{const t=sI()||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")},eu="openchamber:menu-action",Ui="openchamber:check-for-updates",rI=t=>{const e=xt(y=>y.openNewSessionDraft),s=de(y=>y.toggleCommandPalette),r=de(y=>y.setCommandPaletteOpen),o=de(y=>y.toggleHelpDialog),i=de(y=>y.toggleSidebar),c=de(y=>y.setSessionSwitcherOpen),l=de(y=>y.setSettingsDialogOpen),d=de(y=>y.setAboutDialogOpen),u=wr(y=>y.checkForUpdates),{setThemeMode:f}=cr(),p=a.useRef(!1),m=a.useCallback(()=>{p.current||(p.current=!0,u().then(()=>{const{available:y,error:h}=wr.getState();if(h){ze.error("Failed to check for updates",{description:h});return}y||ze.success("You are on the latest version")}).finally(()=>{p.current=!1}))},[u]),g=a.useCallback(()=>{Cn.requestDirectoryDialog()},[]),b=a.useCallback(y=>{const h=bS();if(h.length===0)return;const S=xt.getState().currentSessionId,w=h.findIndex(T=>T.id===S);let C=y>0?0:h.length-1;w>=0&&(C=(w+y+h.length)%h.length);const k=h[C];k&&(c(!1),xt.getState().setCurrentSession(k.id))},[c]),v=a.useCallback(y=>{const{activeProjectId:h,projects:S,setActiveProject:w}=Jt.getState();if(S.length===0)return;const C=S.findIndex(O=>O.id===h);let k=y>0?0:S.length-1;C>=0&&(k=(C+y+S.length)%S.length);const T=S[k];T&&w(T.id)},[]),x=a.useCallback(y=>{switch(y){case"about":d(!0);break;case"settings":l(!0);break;case"command-palette":s();break;case"quick-open":r(!0);break;case"new-session":c(!1);{const h=xt.getState(),S=xs.getState().currentDirectory;e(h.currentSessionId&&S?{directoryOverride:S}:void 0)}break;case"new-worktree-session":c(!1),SS();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const h=xs.getState().currentDirectory;if(!h)break;const S=de.getState(),w=Cs(h),C=S.contextPanelByDirectory[w],k=C?Ym(C.tabs,S.contextSurfaceZones,"right",Go(C,"right").activeTabId):null;C?.isOpen?S.closeContextPanel(w):k?S.setActiveContextPanelTab(w,k):S.openContextSurface(w,"git");break}case"open-right-sidebar-git":{const h=xs.getState().currentDirectory;if(!h)break;de.getState().openContextSurface(Cs(h),"git");break}case"open-right-sidebar-files":{const h=xs.getState().currentDirectory;if(!h)break;de.getState().openContextSurface(Cs(h),"file");break}case"toggle-terminal":{const h=xs.getState().currentDirectory;if(!h)break;de.getState().openContextSurface(Cs(h),"terminal");break}case"toggle-terminal-expanded":{const h=xs.getState().currentDirectory;if(!h)break;const S=Cs(h),w=de.getState(),C=w.contextPanelByDirectory[S];Ba(C,w.contextSurfaceZones).has("terminal")||w.openContextSurface(S,"terminal"),w.toggleContextPanelExpanded(S,Co(w.contextSurfaceZones,"terminal"));break}case"copy":{const h=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(h)||nI();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":xS();break;case"toggle-sidebar":i();break;case"toggle-memory-debug":t?.();break;case"go-back":vc(-1);break;case"go-forward":vc(1);break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":o();break;case"download-logs":{yS().catch(()=>{ze.error("Failed to collect OpenCode status")});break}}},[g,v,b,t,e,d,c,r,l,f,s,o,i]);a.useEffect(()=>{const y=S=>{const w=S.detail;w&&x(w)},h=()=>{m()};return window.addEventListener(eu,y),window.addEventListener(Ui,h),()=>{window.removeEventListener(eu,y),window.removeEventListener(Ui,h)}},[x,m]),a.useEffect(()=>{if(typeof window>"u")return;const h=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof h!="function")return;let S=null,w=null;return h("openchamber:menu-action",C=>{const k=C?.payload;typeof k=="string"&&x(k)}).then(C=>{S=C}).catch(()=>{}),h("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Ui))}).then(C=>{w=C}).catch(()=>{}),()=>{(async()=>{try{const k=S?.();k instanceof Promise&&await k}catch{}try{const k=w?.();k instanceof Promise&&await k}catch{}})()}},[x])},oI="openchamber:tray-action",iI=5e3,aI=500,lI=20,tu=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},su=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Rh=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},Nh=t=>t.title.trim()||"Question",cI=new Set,dI=(t,e)=>tl(t,e,cI,Lf.getState().rankById),uI=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},fI=(t,e,s,r,o)=>{if(!t)return"";const i=Tu(s,r,t),c=e.project?.name,l=i?.label?.trim()||c?.trim()||uI(t),d=fo(t);let u=d&&o.get(d)||"";if(!u){for(const[f,p]of vn.getState().directories)if(fo(f)===d){u=p.status?.current??"";break}}if(!u)for(const f of r.values()){const p=f.find(m=>fo(m.path)===d);if(p?.branch){u=p.branch;break}}return u?`${l} · ${u}`:l},pI=()=>{const{results:t,dropdownProviderIds:e,displayMode:s}=Hn.getState(),r=s==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(c=>[c.providerId,c])),i=[];for(const c of wS){if(!e.includes(c.id))continue;const l=o.get(c.id);if(!l||l.configured!==!0)continue;const d=[];for(const[f,p]of Object.entries(l.usage?.windows??{})){const m=r==="remaining"?p.remainingPercent:p.usedPercent;d.push({label:jS(f),value:kS(p.valueLabel,m)})}const u=!l.ok&&l.error?l.error:d.length===0?"No rate limits reported":null;i.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:i}},hI=async()=>{try{if(Xo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Xm();if(e&&Ul(e,t))return"Local OpenChamber";const r=(await Zo()).hosts.find(o=>e?Ul(e,bu(o)):!1);return r?.label?.trim()?fu(r.label.trim()):"Instance"}catch{return""}},mI=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=ia()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[i,c]of o.children.entries()){const l=c.getState();l.vcs?.branch&&e.set(fo(i)??i,l.vcs.branch);for(const d of l.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(l.session_status??{})){const f=u?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(d);(!m||m==="idle")&&t.set(d,p)}for(const[d,u]of Object.entries(l.permission??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||d;s.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:Rh(f),directory:i,canSave:_f(f.save)})}for(const[d,u]of Object.entries(l.form??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||d;s.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:Nh(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},gI=(t,e)=>{const s=Of.getState().index.session,r=Ps.getState().activeSessions,o=new Map;for(const h of r)if(h?.id&&h.parentID){const S=o.get(h.parentID)??[];S.push(h.id),o.set(h.parentID,S)}const i=h=>{const S=[],w=[...o.get(h)??[]],C=new Set;for(;w.length;){const k=w.pop();C.has(k)||(C.add(k),S.push(k),w.push(...o.get(k)??[]))}return S},c=de.getState();let l=0;if(c.dockBadgeEnabled)for(const h of r){if(!h?.id||h.parentID)continue;let S=s.unseenCount[h.id]??0;S===0&&c.notifyOnSubtasks&&(S=i(h.id).reduce((w,C)=>w+(s.unseenCount[C]??0),0)),S>0&&(l+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:l};const d=mI(),u=new Map(d.titleById);for(const h of r)h?.id&&h.title&&u.set(h.id,h.title);const f=Bf.getState().statusById,p=h=>{const S=d.statusById.get(h);return S&&S!=="idle"?S:f.get(h)?.status.type??S??"idle"},m=h=>{const S=h.map(w=>p(w));return S.includes("busy")?"busy":S.includes("retry")?"retry":"idle"},g=Jt.getState().projects,b=xt.getState().availableWorktreesByProject,v=r.filter(h=>h?.id&&!h.parentID).slice().sort(dI).slice(0,lI).map(h=>{const S=[h.id,...i(h.id)],w=sr(h)??"";return{id:h.id,title:h.title||"Untitled session",status:m(S),branch:w?d.branchByDirectory.get(w)??"":"",unseen:S.reduce((C,k)=>C+(s.unseenCount[k]??0),0),hasError:S.some(C=>s.unseenHasError[C]??!1),directory:w,subtitle:fI(w,h,g,b,d.branchByDirectory)}}),x=d.approvals.map(h=>({...h,sessionTitle:u.get(h.sessionId)||""})),y=new Set(x.map(h=>h.id));for(const[h,S]of Ff.getState().bySession){const w=u.get(h)||"";for(const C of S.permissions)y.has(C.id)||(y.add(C.id),x.push({kind:"permission",id:C.id,sessionId:h,sessionTitle:w,label:Rh(C),directory:S.directory,canSave:_f(C.save)}));for(const C of S.forms)y.has(C.id)||(y.add(C.id),x.push({kind:"form",id:C.id,sessionId:h,sessionTitle:w,label:Nh(C),directory:S.directory,canSave:!1}))}return{sessions:v,approvals:x,instanceName:t,usage:pI(),dockBadgeCount:l}},bI=()=>{a.useEffect(()=>{if(!tu()||!vo())return;const t=su();let e=!1,s="",r=null,o="";const i=()=>{if(e)return;const k=gI(o,t),T=JSON.stringify(k);T!==s&&(s=T,xn("desktop_tray_update",k))},c=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},aI))},l=Of.subscribe(()=>c()),d=Ps.subscribe(()=>c()),u=de.subscribe((k,T)=>{(k.dockBadgeEnabled!==T.dockBadgeEnabled||k.notifyOnSubtasks!==T.notifyOnSubtasks)&&c()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),l(),d(),u()};if(!t)return i(),f;hI().then(k=>{e||(o=k,i())});const p=new Map,m=()=>{if(e)return;let k;try{k=ia()}catch{return}const T=new Set;for(const[O,K]of k.children.entries())T.add(O),p.has(O)||p.set(O,K.subscribe(()=>c()));for(const[O,K]of p)T.has(O)||(K(),p.delete(O))};let g=null;try{g=ia().subscribeRegistry(()=>{m(),c()})}catch{}m();const b=Jt.subscribe(()=>c()),v=xt.subscribe(()=>c()),x=vn.subscribe(()=>c()),y=Bf.subscribe(()=>c()),h=Ff.subscribe(()=>c()),S=Lf.subscribe(()=>c()),w=Hn.subscribe(()=>c());Hn.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:k,results:T}=Hn.getState();k.length>0&&k.some(K=>!T.some(R=>R.providerId===K))&&Hn.getState().fetchQuotas(k)});const C=window.setInterval(()=>{m(),i()},iI);return i(),()=>{f(),window.clearInterval(C),b(),v(),x(),y(),h(),S(),w(),g?.();for(const k of p.values())k();p.clear()}},[]),a.useEffect(()=>{if(!tu()||!su()||!vo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=o=>{o.type==="respond-permission"&&vS(o.sessionId,o.id,o.response).catch(()=>{ze.error("Failed to respond to permission request")})};let r=null;return e(oI,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||s(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},yI=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,xI=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,SI=t=>{t.kind!=="plugin"||!t.title||ze.info(t.title,{id:xI(t.kind,t.title,t.body,t.tag),description:t.body})},vI=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,wI=t=>{const e=Je.c(3),s=!0;let r,o;e[0]!==s?(r=()=>{if(!(cn()||!yu()||!globalThis.window))return jn(kI)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),a.useEffect(r,o)};function kI(t){if(t.type!=="notification")return;const e=de.getState();if(!e.nativeNotificationsEnabled)return;const s=yI();if(vI(t.payload,s)){SI(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;gu()?.notifications?.notifyAgentCompletion(t.payload)}const jI=()=>{const t=Je.c(4),{t:e}=Ct(),s=de(CI);let r,o;t[0]!==s||t[1]!==e?(r=()=>jn(i=>{i.type==="browser-provider-reset"&&(s("builtin"),ze.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[s,e],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),a.useEffect(r,o)};function CI(t){return t.setBrowserProvider}const nu=()=>{Zm()||(Cb(),CS(Pb.map(t=>t.id)))},PI=(t,e)=>{const s=Je.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const c=window.requestIdleCallback(nu,{timeout:1e4});return()=>window.cancelIdleCallback(c)}const i=setTimeout(nu,3e3);return()=>clearTimeout(i)},s[0]=t,s[1]=r):r=s[1];let o;s[2]!==e||s[3]!==t?(o=[t,e],s[2]=e,s[3]=t,s[4]=o):o=s[4],a.useEffect(r,o)},ru="pwa-install-toast-shown",ou="pwa-install-toast-dismissed",EI=()=>{const t=Je.c(6),{browserTab:e}=Eb(),{t:s}=Ct(),r=a.useRef(s);let o,i;t[0]!==s?(o=()=>{r.current=s},i=[s],t[0]=s,t[1]=o,t[2]=i):(o=t[1],i=t[2]),a.useEffect(o,i);let c,l;t[3]!==e?(c=()=>{if(typeof window>"u"||!yu()||!e)return;let d=null,u=null;const f=()=>{u!==null&&(ze.dismiss(u),u=null)},p=async()=>{if(!d)return;const b=d;d=null,f(),await b.prompt();const{outcome:v}=await b.userChoice;v==="accepted"&&ze.success(r.current("pwa.installPrompt.started"))},m=b=>{const v=b;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const x=Po(),y=Qm();Ib({dismissed:x.getItem(ou),sessionShown:y.getItem(ru),hasActiveToast:u!==null})&&(y.setItem(ru,"true"),u=ze.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Po().setItem(ou,"true"),f()}}}))},g=()=>{d=null,f(),ze.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",g),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",g)}},l=[e],t[3]=e,t[4]=c,t[5]=l):(c=t[4],l=t[5]),a.useEffect(c,l)},II=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",Mh=async(t,e)=>{const s=(await Zo()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await sg(s.id,e);return}const r=ng(bu(s));if(!r)throw new Error("host-not-found");rg({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:og(s),sshForwarded:s.sshForwarded===!0})},TI=async t=>{const e=await Zo(),s=await eg(t,e.hosts);await tg({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await Mh(s.hostId,{reconnectActive:!0})},DI=async t=>{const e=await Jm();for(const s of e)try{s.type==="pairing"?await TI(s.link):await Mh(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(II(o))}},Aa="project-config-invalid",RI=()=>{const t=Je.c(9),{t:e}=Ct(),s=ns(NI);let r;t[0]!==s?(r=m=>m.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=ns(r),[i,c]=fs.useState(!1);let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const m=ns.getState(),g=m.activeDirectoryKey;c(!0),Promise.all([m.loadProviders({directory:g,source:"projectConfigError:retry"}),m.loadAgents({directory:g,source:"projectConfigError:retry"})]).finally(()=>c(!1))},t[2]=l):l=t[2];const d=l;let u,f;t[3]!==o||t[4]!==i||t[5]!==e?(u=()=>{if(!o){ze.dismiss(Aa);return}ze.error(e("projectConfigError.toast.title"),{id:Aa,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),i||d()}}})},f=[o,i,d,e],t[3]=o,t[4]=i,t[5]=e,t[6]=u,t[7]=f):(u=t[6],f=t[7]),fs.useEffect(u,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],fs.useEffect(AI,p),null};function NI(t){return t.activeDirectoryKey}function MI(){ze.dismiss(Aa)}function AI(){return MI}const OI="\x1B",BI=new RegExp(`${OI}\\[[0-9;?]*[ -/]*[@-~]`,"g"),lo=Ls().transform(t=>t.replace(BI,"").trim()).nullish(),FI=da({isOpenCodeReady:jc().optional(),openCodeRunning:jc().optional(),lastOpenCodeError:lo,opencodeBinaryResolved:lo,lastOpenCodeLaunchDiagnostics:da({sourceBinary:lo,binary:lo}).nullish()}),LI=async(t,e=Us)=>{const s=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)throw new Error(`Startup diagnostics request failed (${s.status})`);const r=FI.parse(await s.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},_I=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},$I=da({openchamberVersion:Ls()}),zI=async(t,e=Us)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=$I.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},KI=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function WI({version:t}){const{t:e}=Ct(),[s,r]=a.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const l=await Tb();r(l.available&&!l.installBlocked?{kind:"available",info:l}:{kind:"manual",info:l,error:null})}catch(l){r({kind:"manual",info:null,error:l instanceof Error?l.message:null})}},i=s.kind==="manual"?s:null,c=i?.info?.updateCommand||"openchamber update";return n.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"typography-title text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-body text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(It,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx(Z,{name:s.kind==="checking"?"loader":"download",className:s.kind==="checking"?"size-4 animate-spin":"size-4"}),s.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),n.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:c})]})]}),n.jsx(za,{open:s.kind==="available",onOpenChange:l=>{l||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const iu=Br(()=>ss(()=>import("./OnboardingScreen-B5Zzb1Mp.js"),__vite__mapDeps([169,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])).then(t=>({default:t.OnboardingScreen}))),HI=()=>ss(()=>import("./AboutDialog-MZbHWRua.js"),__vite__mapDeps([170,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])).then(t=>t.AboutDialog),VI=()=>ss(()=>import("./MemoryDebugPanel-Ct0h3RWh.js"),__vite__mapDeps([171,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,122,123,124])).then(t=>t.MemoryDebugPanel),UI=()=>{const t=Je.c(6),e=de(ZI),s=de(QI);let r;t[0]!==s?(r=()=>s(!1),t[0]=s,t[1]=r):r=t[1];const o=ci(e,HI,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==s?(i=n.jsx(o,{open:e,onOpenChange:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=i):i=t[5],i},GI=t=>{const e=Je.c(3),{onClose:s}=t,r=ci(!0,VI,s);let o;return e[0]!==r||e[1]!==s?(o=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=o):o=e[2],o},qI=t=>{const e=Je.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=Ct(),[i,c]=a.useState(null);let l,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const K=new AbortController,R=Gt(),I=setTimeout(()=>K.abort(),5e3);return LI(K.signal).then(N=>{!K.signal.aborted&&Gt()===R&&c(N)}).catch(JI).finally(()=>clearTimeout(I)),()=>{K.abort(),clearTimeout(I)}},d=[],e[0]=l,e[1]=d):(l=e[0],d=e[1]),a.useEffect(l,d);const[u,f]=a.useState(null);let p,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const K=new AbortController,R=Gt(),I=setTimeout(()=>K.abort(),5e3);return zI(K.signal).then(N=>{K.signal.aborted||Gt()!==R||f(N&&KI(N)?N:null)}).catch(eT).finally(()=>clearTimeout(I)),()=>{K.abort(),clearTimeout(I)}},m=[],e[2]=p,e[3]=m):(p=e[2],m=e[3]),a.useEffect(p,m);const g=ns(tT),b=i?null:g?.message??null;if(u){let K;e[4]!==u?(K=n.jsx(WI,{version:u}),e[4]=u,e[5]=K):K=e[5];let R;e[6]!==r||e[7]!==o?(R=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=R):R=e[8];let I;e[9]!==r||e[10]!==s||e[11]!==R?(I=n.jsx(It,{type:"button",variant:"outline",onClick:s,disabled:r,children:R}),e[9]=r,e[10]=s,e[11]=R,e[12]=I):I=e[12];let N;return e[13]!==K||e[14]!==I?(N=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[K,I]})}),e[13]=K,e[14]=I,e[15]=N):N=e[15],N}let v;e[16]!==o?(v=o("startup.initRecovery.title"),e[16]=o,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsx("h1",{className:"typography-title text-foreground",children:v}),e[18]=v,e[19]=x):x=e[19];let y;e[20]!==i||e[21]!==g||e[22]!==o?(y=o(_I(i,g)),e[20]=i,e[21]=g,e[22]=o,e[23]=y):y=e[23];let h;e[24]!==y?(h=n.jsx("p",{className:"typography-body text-muted-foreground",children:y}),e[24]=y,e[25]=h):h=e[25];let S;e[26]!==x||e[27]!==h?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[x,h]}),e[26]=x,e[27]=h,e[28]=S):S=e[28];let w;e[29]!==b||e[30]!==o?(w=b&&n.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:b})]}),e[29]=b,e[30]=o,e[31]=w):w=e[31];let C;e[32]!==i||e[33]!==o?(C=i&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:i.error})]})]}),e[32]=i,e[33]=o,e[34]=C):C=e[34];let k;e[35]!==r||e[36]!==o?(k=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=k):k=e[37];let T;e[38]!==r||e[39]!==s||e[40]!==k?(T=n.jsx(It,{type:"button",onClick:s,disabled:r,children:k}),e[38]=r,e[39]=s,e[40]=k,e[41]=T):T=e[41];let O;return e[42]!==w||e[43]!==C||e[44]!==T||e[45]!==S?(O=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[S,w,C,T]})}),e[42]=w,e[43]=C,e[44]=T,e[45]=S,e[46]=O):O=e[46],O};function YI({apis:t}){a.useEffect(()=>{ig("App:mounted"),ag()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=ns(A=>A.initializeApp),s=ns(A=>A.isInitialized),r=ns(A=>A.isConnected),o=ns(A=>A.providersLoaded),i=ns(A=>A.agentsLoaded),c=ns(A=>A.loadProviders),l=ns(A=>A.loadAgents),d=xt(A=>A.error),u=xt(A=>A.clearError),f=xs(A=>A.currentDirectory),p=xs(A=>A.isSwitchingDirectory),[m,g]=a.useState(!1),b=Sn(A=>A.refreshAll),v=PS(A=>A.refreshStatus),[x,y]=a.useState(()=>t.runtime.isVSCode),[h,S]=a.useState(!1),[w,C]=a.useState(0),[k,T]=a.useState(0),[O,K]=a.useState(!1),R=de(A=>A.wideChatLayoutEnabled),I=de(A=>A.mobileKeyboardMode),N=a.useMemo(()=>cn(),[]),[W,z]=a.useState(()=>Gl()),[H,M]=a.useState(()=>{const A=Si();return A!==null?ql({isDesktopShell:!0,bootOutcome:A}):null}),Y=a.useRef(!1),{t:j}=Ct(),P=a.useRef(!1);a.useEffect(()=>{if(!s||W!=="valid"||P.current)return;const A=Si();A?.target!=="local"||A.status!=="ok"||!A.sshStartupFallbackHostId||(P.current=!0,ze.error(j("desktopHostSwitcher.startup.title"),{description:j("desktopHostSwitcher.startup.fellBackToLocal")}))},[W,s,j]),a.useEffect(()=>(Yl(m),Qd(m),()=>{Yl(!1),Qd(!1)}),[m]),a.useEffect(()=>{lg(I)},[I]),a.useEffect(()=>{y(t.runtime.isVSCode)},[t.runtime.isVSCode]),a.useEffect(()=>Uo(A=>{Rb(A)&&Nb(A),T(te=>te+1),S(!1),C(te=>te+1)}),[]);const D=wc(A=>{const te=Gt();return Object.values(A.runsByOriginalSessionID).filter(U=>U.status==="running"&&U.runtimeKey===te).map(U=>`${U.originalSessionID}:${U.phase}:${U.lastForwardedMessageID??""}:${U.expectedAssistantParentID??""}`).sort().join("|")});a.useEffect(()=>{const A=Gt(),te=Object.values(wc.getState().runsByOriginalSessionID).filter(U=>U.status==="running"&&U.runtimeKey===A);for(const U of te)ES(U.originalSessionID)},[D,k]),a.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",R),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[R]),a.useEffect(()=>(Xl(t),()=>Xl(null)),[t]),a.useEffect(()=>{r&&(b(t.sourceControl,{force:!0}),v(t.linear,{force:!0}))},[t.sourceControl,t.linear,r,b,v,k]),IS();const V=W==="valid",B=H?.screen==="main";a.useEffect(()=>{if(!cg({isDesktopShell:N,bootOutcomeKnown:V}))return;TS();const A=setTimeout(()=>{const te=document.getElementById("initial-loading");te&&(te.classList.add("fade-out"),setTimeout(()=>{te.remove()},300))},150);return()=>clearTimeout(A)},[N,V]),a.useEffect(()=>{if(!N||W!=="malformed")return;const A=document.getElementById("initial-loading");A&&(A.textContent="Desktop startup failed — please restart the app.")},[N,W]),a.useEffect(()=>{x||e()},[e,x]),a.useEffect(()=>{if(x||s)return;let A=!0,te,U=0;const Pe=10,xe=1e3,ce=async()=>{if(!A)return;if(U>=Pe){S(!0);return}const Oe=ns.getState();if(Oe.isInitialized){S(!1);return}U+=1,await Oe.initializeApp();const me=ns.getState();if(!A)return;if(me.isInitialized){S(!1);return}if(U>=Pe){S(!0);return}const ie=Math.min(xe*Math.pow(2,U-1),4e3);te=setTimeout(ce,ie)};return te=setTimeout(ce,xe),()=>{A=!1,te&&clearTimeout(te)}},[w,s,x]),a.useEffect(()=>{s&&S(!1)},[s]),a.useEffect(()=>{if(!h)return;const A=document.getElementById("initial-loading");A&&(A.classList.add("fade-out"),setTimeout(()=>{A.remove()},300))},[h]),a.useEffect(()=>{if(x||!r||o&&i)return;let A=!0,te=0;const U=15,Pe=async()=>{const ce=ns.getState();if(!(ce.providersLoaded&&ce.agentsLoaded))try{ce.providersLoaded||await c({source:"startupRecovery"}),ns.getState().agentsLoaded||await l({source:"startupRecovery"})}catch{}};Pe();const xe=setInterval(()=>{if(A){if(++te>=U){clearInterval(xe);return}Pe()}},2e3);return()=>{A=!1,clearInterval(xe)}},[r,x,l,c,o,i]),a.useEffect(()=>{p||x||r&&jo.setDirectory(f)},[f,p,r,x]),a.useEffect(()=>{if(typeof window>"u")return;const A=te=>{const U=te.detail,Pe=typeof U?.sessionId=="string"?U.sessionId.trim():"";if(!Pe)return;const xe=typeof U?.directory=="string"&&U.directory.trim().length>0?U.directory.trim():null,ce=String(U?.runtimeKey??"").trim();if(!(ce&&ce!==Gt()&&pg(ce,Pe))){if(!xe){kc(Pe,typeof U?.messageId=="string"?U.messageId.trim():null);return}xt.getState().setCurrentSession(Pe,xe)}};return window.addEventListener("openchamber:open-session",A),dg().then(te=>{for(const U of te)kc(U.sessionId,U.messageId)}),()=>window.removeEventListener("openchamber:open-session",A)},[]),a.useEffect(()=>{if(!cn())return;const A=()=>{DI(te=>{ze.error(j(te==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":te==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",A),A(),()=>window.removeEventListener("openchamber:host-actions-ready",A)},[j]);const _=a.useRef({attempt:null,running:!1,done:!1});a.useLayoutEffect(()=>{const A=_.current;A.attempt||(A.attempt=Mb({selectNow:!Ab().sessionId}))},[]),a.useEffect(()=>{const A=_.current,te=()=>{const U=A.attempt;if(!U||A.running||A.done)return;const Pe=ns.getState().isInitialized;A.running=!0,U().then(xe=>{if(A.running=!1,xe!=="failed"||Pe){A.done=!0;return}ns.getState().isInitialized&&te()})};te()},[s]),a.useEffect(()=>{if(typeof window>"u")return;const A=()=>{xn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Sr()})};return window.addEventListener("openchamber:open-mini-chat",A),()=>window.removeEventListener("openchamber:open-mini-chat",A)},[]),a.useEffect(()=>{if(typeof window>"u")return;const A=()=>{const te=xt.getState().currentSessionId;te&&uf(te)};return window.addEventListener("focus",A),()=>window.removeEventListener("focus",A)},[]),a.useEffect(()=>{if(typeof window>"u")return;const A=te=>{const U=te.detail,Pe=typeof U?.directory=="string"&&U.directory.trim().length>0?U.directory.trim():null,xe=typeof U?.projectId=="string"&&U.projectId.trim().length>0?U.projectId.trim():null,ce=!!(Pe||xe);de.getState().setSessionSwitcherOpen(!1),xt.getState().openNewSessionDraft({target:ce?"project":"chat",selectedProjectId:ce?xe:null,directoryOverride:ce?Pe:null,preserveDirectoryOverride:!!Pe})};return window.addEventListener("openchamber:open-draft-session",A),()=>window.removeEventListener("openchamber:open-draft-session",A)},[]),a.useEffect(()=>{typeof window>"u"||!s||p||Y.current||(Y.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,p]),DS(),wI(),Ob(f||null),jI(),RS(),Bb(),PI(s&&r,k),EI(),NS(),ZS(),Fb();const F=a.useCallback(()=>{g(A=>!A)},[]);rI(F),bI(),QS(!0),a.useEffect(()=>{const A=()=>g(te=>!te);return window.addEventListener("openchamber:memory-debug-toggle",A),()=>window.removeEventListener("openchamber:memory-debug-toggle",A)},[]),a.useEffect(()=>{d&&setTimeout(()=>u(),5e3)},[u,d]),a.useEffect(()=>{if(!N||W!=="not-injected")return;let A=!1,te=0;const U=200,Pe=2e3,xe=50,ce=()=>{if(A)return;te++;const Oe=Gl();if(Oe!=="not-injected"){if(A=!0,z(Oe),Oe==="valid"){const ie=Si();ie&&M(ql({isDesktopShell:!0,bootOutcome:ie}))}return}const me=Math.min(U*Math.pow(1.1,te),Pe);if(te>=xe){const ie=document.getElementById("initial-loading");ie&&!ie.textContent?.includes("taking longer")&&(ie.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(ce,me)};return window.setTimeout(ce,U),()=>{A=!0}},[N,W]);const X=a.useCallback(async()=>{if(ug({isDesktopShell:cn(),isDesktopLocalOriginActive:Xo()})){await fg();return}window.location.reload()},[]),oe=a.useCallback(async()=>{if(!O){S(!1),K(!0);try{await ns.getState().initializeApp()}finally{K(!1)}ns.getState().isInitialized||C(A=>A+1)}},[O]),ne=A=>{if(A.screen==="recovery")return A.variant};if(N&&H&&H.screen!=="main"){if(H.screen==="chooser")return n.jsx(vs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(a.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(iu,{mode:"first-launch",localAvailable:H.localAvailable!==!1,onCliAvailable:X,onChooseRemote:()=>{}})})})});const A=ne(H),te=H.screen==="recovery"&&"url"in H?H.url:void 0,U=H.screen==="recovery"&&"hostId"in H?H.hostId:void 0;return n.jsx(vs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(a.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(iu,{mode:"recovery",recoveryVariant:A,recoveryHostUrl:te,recoveryHostLabel:void 0,recoveryHostId:U,localAvailable:H.localAvailable!==!1,onCliAvailable:X})})})})}return h&&!s&&!x?n.jsx(vs,{children:n.jsx(qI,{onRetry:()=>{oe()},isRetrying:O},k)}):n.jsx(vs,{children:n.jsx(MS,{sdk:jo.getSdkClient(),directory:f||"",children:n.jsx(AS,{apis:t,children:n.jsx(GE,{children:n.jsx(ri,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:N?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(OS,{backgroundWorkEnabled:!0}),n.jsx(Lb,{}),n.jsx(RI,{}),n.jsx(rE,{}),N?n.jsx(_b,{ready:V&&B}):null,n.jsx(BS,{}),n.jsx(FS,{}),n.jsx(LS,{}),n.jsx($b,{}),n.jsx(UI,{}),m&&n.jsx(GI,{onClose:()=>g(!1)})]})})})})},k)})}function XI(t){const e=Je.c(2);let s;return e[0]!==t?(s=n.jsx(Db,{children:n.jsx(YI,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function ZI(t){return t.isAboutDialogOpen}function QI(t){return t.setAboutDialogOpen}function JI(){}function eT(){}function tT(t){return t.lastInitFailure}const sT=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();hg();zb();Kb();mg().then(()=>{_S().catch(t=>{console.error("[main] settings init failed:",t)}),$S(),zS(),KS()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Ah=document.getElementById("root");if(!Ah)throw new Error("Root element not found");WS();vm.createRoot(Ah).render(n.jsx(fs.StrictMode,{children:n.jsx(HS,{children:n.jsx(VS,{children:n.jsx(US,{children:n.jsx(GS,{children:n.jsx(XI,{apis:sT})})})})})}));const kT=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Sv as W,bj as a,ST as b,wT as g,kT as m,vT as r,mv as u,gj as v};