@vantran-se/openchamber-web 1.24.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +2 -8
  2. package/bin/lib/commands-connect-url.js +3 -8
  3. package/bin/lib/commands-tunnel.js +3 -0
  4. package/dist/assets/{CodeMirrorCommentWidgets-BjJHrzmU.js → CodeMirrorCommentWidgets-ntXIbhV2.js} +1 -1
  5. package/dist/assets/DiffView-CjxUovbM.js +4 -0
  6. package/dist/assets/FilesView-DFWD0RQR.js +17 -0
  7. package/dist/assets/{GitView-CDOJy5Ay.js → GitView-BWa7e5vw.js} +4 -4
  8. package/dist/assets/{GuestAttachDialog-D3S0Rjic.js → GuestAttachDialog-DdOuyZzp.js} +1 -1
  9. package/dist/assets/GuestSurfacePane-DDfzid3U.js +1 -0
  10. package/dist/assets/{JsonTreeView-D0C9nU7K.js → JsonTreeView-3sGwqexh.js} +1 -1
  11. package/dist/assets/LinearIssuesView-C6dpIdjw.js +1 -0
  12. package/dist/assets/MarkdownImageGallery-Q7YR_tl4.js +1 -0
  13. package/dist/assets/MarkdownRendererImpl-DxDV56bL.js +12 -0
  14. package/dist/assets/OnboardingScreen-rK4Stg__.js +1 -0
  15. package/dist/assets/{PatchDiff-DnEhjXcC.js → PatchDiff-DS-IMU1j.js} +1 -1
  16. package/dist/assets/{PierreDiffViewer-DyxZVVVR.js → PierreDiffViewer-DW23KWKZ.js} +1 -1
  17. package/dist/assets/PlanView-BCk_VobP.js +5 -0
  18. package/dist/assets/PluginPane-BPP1dbck.js +3 -0
  19. package/dist/assets/SettingsView-kMmrpn43.js +29 -0
  20. package/dist/assets/SettingsWindow-BpvD6IYQ.js +1 -0
  21. package/dist/assets/SubmoduleDiffSummary-BLttSS1X.js +1 -0
  22. package/dist/assets/ToolOutputDialog-CtqDqbyr.js +15 -0
  23. package/dist/assets/ToolPartDiffPreview-5FcKdyRy.js +8 -0
  24. package/dist/assets/{VirtualizedFileDiff-0pyr_mHY.js → VirtualizedFileDiff-C763hNCR.js} +4 -4
  25. package/dist/assets/{WalkthroughView-yNj4nOP5.js → WalkthroughView-lap5btCF.js} +2 -2
  26. package/dist/assets/appThemeRegistry-u4zw1l0B.js +1 -0
  27. package/dist/assets/{commitAndPush-DvJKa3Ks.js → commitAndPush-CwGJfJG-.js} +1 -1
  28. package/dist/assets/{computeVirtualFileMetrics-DxTBMuu-.js → computeVirtualFileMetrics-DW5jjX4n.js} +1 -1
  29. package/dist/assets/de-CndEg67T.js +10 -0
  30. package/dist/assets/es-DglvPlaC.js +16 -0
  31. package/dist/assets/fr-DejPCpbS.js +14 -0
  32. package/dist/assets/index-C2r64QfD.js +1 -0
  33. package/dist/assets/index-CLcM8HKx.css +1 -0
  34. package/dist/assets/index-CvLgnuNI.js +41 -0
  35. package/dist/assets/{isDiffPlainText-D7FkBMP6.js → isDiffPlainText-D47a6hMP.js} +1 -1
  36. package/dist/assets/{isFilePlainText-CL2vsrIZ.js → isFilePlainText-B-mGgeKl.js} +1 -1
  37. package/dist/assets/ja-CVpQawCd.js +16 -0
  38. package/dist/assets/ko-Bw446h9j.js +16 -0
  39. package/dist/assets/main-Bz4WWXbr.js +2 -0
  40. package/dist/assets/main-oreqDsOV.js +896 -0
  41. package/dist/assets/{markdownCore-Dh7WEsdM.js → markdownCore-D2e5sp9y.js} +4 -4
  42. package/dist/assets/miniChat-D1v2gsBI.js +2 -0
  43. package/dist/assets/mobile-DBj3lCf2.js +2 -0
  44. package/dist/assets/{patchFileDiff-Bsba8KFp.js → patchFileDiff-BpeUOV91.js} +3 -3
  45. package/dist/assets/pl-BYNlPdhm.js +16 -0
  46. package/dist/assets/pt-BR-CL-Yfv9H.js +16 -0
  47. package/dist/assets/renderElectronMiniChatApp-DVtfEB2z.js +2 -0
  48. package/dist/assets/renderMobileApp-DFp9-xbG.js +25 -0
  49. package/dist/assets/runtimeEndpointReset-CsIpUep1.js +27 -0
  50. package/dist/assets/scheduledTasksApi-B5OHVpPM.js +1 -0
  51. package/dist/assets/{shikiHighlight-8_3csmr6.js → shikiHighlight-DNm2Z_Jc.js} +1 -1
  52. package/dist/assets/{textMateThemeFromAppTheme-CHo2fCgW.js → textMateThemeFromAppTheme-DGF2kG7g.js} +1 -1
  53. package/dist/assets/tr-DzmbxLy-.js +7 -0
  54. package/dist/assets/uk-C7vQnwro.js +16 -0
  55. package/dist/assets/useAppFontEffects-Ci3FEaPf.js +7337 -0
  56. package/dist/assets/{useInlineCommentController-DkQ_gqpn.js → useInlineCommentController-CuUuakrt.js} +2 -2
  57. package/dist/assets/useRootScrollLock-CQIsyERq.js +2 -0
  58. package/dist/assets/{vendor-codemirror-language-data-CdzUmUyZ.js → vendor-codemirror-language-data-CQa7_1cr.js} +2 -2
  59. package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
  60. package/dist/assets/vendor-opencode-client-_BAHQo4R.js +12 -0
  61. package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
  62. package/dist/assets/{vendor-zod-CgAdXWZO.js → vendor-zod-Gea9uBlY.js} +1 -1
  63. package/dist/assets/{web-components-B8IcVQAA.js → web-components-B6tKQyJN.js} +2 -2
  64. package/dist/assets/zh-CN-Cl0srS-z.js +16 -0
  65. package/dist/assets/zh-TW-DtII5bDb.js +16 -0
  66. package/dist/index.html +13 -7
  67. package/dist/mini-chat.html +5 -5
  68. package/dist/mobile.html +5 -5
  69. package/package.json +6 -5
  70. package/server/index.d.ts +1 -0
  71. package/server/index.js +246 -91
  72. package/server/lib/agent-tool/DOCUMENTATION.md +32 -15
  73. package/server/lib/agent-tool/runtime.js +135 -54
  74. package/server/lib/agent-tool/runtime.test.js +155 -87
  75. package/server/lib/browser-control/DOCUMENTATION.md +37 -2
  76. package/server/lib/browser-control/provider.js +217 -0
  77. package/server/lib/browser-control/provider.test.js +251 -0
  78. package/server/lib/context-obligatory/runtime.js +61 -50
  79. package/server/lib/context-obligatory/runtime.test.js +62 -162
  80. package/server/lib/event-stream/DOCUMENTATION.md +12 -1
  81. package/server/lib/event-stream/delta-coalescer.js +0 -0
  82. package/server/lib/event-stream/delta-coalescer.test.js +68 -57
  83. package/server/lib/event-stream/directory-ws-bridge.js +1 -1
  84. package/server/lib/event-stream/global-hub.js +10 -1
  85. package/server/lib/event-stream/global-hub.test.js +27 -26
  86. package/server/lib/event-stream/index.js +6 -0
  87. package/server/lib/event-stream/protocol.js +26 -19
  88. package/server/lib/event-stream/protocol.test.js +18 -7
  89. package/server/lib/event-stream/rebind.test.js +5 -5
  90. package/server/lib/event-stream/runtime.test.js +17 -15
  91. package/server/lib/event-stream/translate-v2.js +313 -0
  92. package/server/lib/event-stream/translate-v2.test.js +209 -0
  93. package/server/lib/event-stream/upstream-reader.test.js +16 -16
  94. package/server/lib/fs/DOCUMENTATION.md +4 -2
  95. package/server/lib/fs/byte-range.js +35 -0
  96. package/server/lib/fs/byte-range.test.js +31 -0
  97. package/server/lib/fs/routes.js +47 -42
  98. package/server/lib/fs/routes.test.js +123 -18
  99. package/server/lib/git/service.js +12 -0
  100. package/server/lib/github/DOCUMENTATION.md +1 -1
  101. package/server/lib/github/pr-status.js +22 -2
  102. package/server/lib/github/pr-status.test.js +27 -14
  103. package/server/lib/guests/DOCUMENTATION.md +13 -0
  104. package/server/lib/guests/catalog.js +12 -0
  105. package/server/lib/guests/catalog.test.js +33 -0
  106. package/server/lib/guests/routes.js +10 -1
  107. package/server/lib/guests/service.js +192 -14
  108. package/server/lib/guests/service.test.js +201 -1
  109. package/server/lib/guests/surface.js +630 -0
  110. package/server/lib/guests/surface.test.js +486 -0
  111. package/server/lib/markdown-image-grants/routes.js +18 -5
  112. package/server/lib/markdown-image-grants/routes.test.js +9 -6
  113. package/server/lib/message-queue/DOCUMENTATION.md +33 -22
  114. package/server/lib/message-queue/runtime.js +155 -100
  115. package/server/lib/message-queue/runtime.test.js +168 -82
  116. package/server/lib/notifications/DOCUMENTATION.md +28 -0
  117. package/server/lib/notifications/control-stream.http.test.js +68 -0
  118. package/server/lib/notifications/emitter-runtime.js +15 -0
  119. package/server/lib/notifications/emitter-runtime.test.js +32 -0
  120. package/server/lib/notifications/push-runtime.js +5 -1
  121. package/server/lib/notifications/push-runtime.test.js +2 -2
  122. package/server/lib/notifications/routes.js +1 -1
  123. package/server/lib/notifications/runtime.js +115 -26
  124. package/server/lib/notifications/template-runtime.js +13 -15
  125. package/server/lib/notifications/template-runtime.test.js +16 -9
  126. package/server/lib/notifications/trigger-runtime.test.js +187 -0
  127. package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
  128. package/server/lib/openchamber-control/actions.js +3 -2
  129. package/server/lib/openchamber-control/error.js +1 -1
  130. package/server/lib/openchamber-control/file-open.js +59 -0
  131. package/server/lib/openchamber-control/file-open.test.js +57 -0
  132. package/server/lib/openchamber-control/routes.test.js +12 -0
  133. package/server/lib/openchamber-control/service.js +102 -49
  134. package/server/lib/openchamber-control/service.test.js +84 -44
  135. package/server/lib/openchamber-sessions/archive-store.js +224 -0
  136. package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
  137. package/server/lib/openchamber-sessions/opencode-client.js +22 -0
  138. package/server/lib/openchamber-sessions/routes.js +398 -328
  139. package/server/lib/openchamber-sessions/routes.test.js +777 -740
  140. package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
  141. package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
  142. package/server/lib/opencode/DOCUMENTATION.md +449 -29
  143. package/server/lib/opencode/agents.js +233 -327
  144. package/server/lib/opencode/auth.js +41 -44
  145. package/server/lib/opencode/auth.test.js +92 -0
  146. package/server/lib/opencode/cli-upgrade.d.ts +4 -0
  147. package/server/lib/opencode/cli-upgrade.js +18 -0
  148. package/server/lib/opencode/cli-upgrade.test.js +36 -0
  149. package/server/lib/opencode/commands.js +164 -145
  150. package/server/lib/opencode/compatibility.d.ts +16 -0
  151. package/server/lib/opencode/compatibility.js +88 -0
  152. package/server/lib/opencode/compatibility.test.js +62 -0
  153. package/server/lib/opencode/config-entity-routes.js +58 -29
  154. package/server/lib/opencode/config-entity-v2.test.js +290 -0
  155. package/server/lib/opencode/config-mutation-response.js +17 -7
  156. package/server/lib/opencode/config-mutation-response.test.js +4 -7
  157. package/server/lib/opencode/config-paths.test.js +2 -2
  158. package/server/lib/opencode/config-v2.d.ts +183 -0
  159. package/server/lib/opencode/config-v2.js +801 -0
  160. package/server/lib/opencode/config-v2.test.js +466 -0
  161. package/server/lib/opencode/credential-db.js +144 -0
  162. package/server/lib/opencode/credential-db.test.js +104 -0
  163. package/server/lib/opencode/env-runtime.js +48 -9
  164. package/server/lib/opencode/env-runtime.test.js +45 -0
  165. package/server/lib/opencode/feature-routes-runtime.js +15 -5
  166. package/server/lib/opencode/lifecycle-process.test.js +7 -4
  167. package/server/lib/opencode/lifecycle.js +85 -30
  168. package/server/lib/opencode/lifecycle.test.js +80 -8
  169. package/server/lib/opencode/login-shell-env.js +27 -0
  170. package/server/lib/opencode/managed-config-file.js +119 -0
  171. package/server/lib/opencode/managed-config-file.test.js +152 -0
  172. package/server/lib/opencode/managed-plugin-config.js +33 -13
  173. package/server/lib/opencode/mcp.js +43 -149
  174. package/server/lib/opencode/network-runtime.js +6 -7
  175. package/server/lib/opencode/openchamber-routes.test.js +2 -5
  176. package/server/lib/opencode/plugin-routes.js +3 -3
  177. package/server/lib/opencode/plugin-routes.test.js +6 -24
  178. package/server/lib/opencode/plugins.js +91 -40
  179. package/server/lib/opencode/plugins.test.js +28 -15
  180. package/server/lib/opencode/providers.js +63 -83
  181. package/server/lib/opencode/providers.test.js +128 -59
  182. package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
  183. package/server/lib/opencode/proxy.js +179 -129
  184. package/server/lib/opencode/pwa-manifest-routes.js +4 -2
  185. package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
  186. package/server/lib/opencode/response-envelope.js +14 -0
  187. package/server/lib/opencode/response-envelope.test.js +23 -0
  188. package/server/lib/opencode/routes-upgrade.test.js +73 -116
  189. package/server/lib/opencode/routes.js +121 -428
  190. package/server/lib/opencode/server-utils-runtime.js +10 -4
  191. package/server/lib/opencode/session-activity.js +78 -0
  192. package/server/lib/opencode/session-runtime.js +21 -10
  193. package/server/lib/opencode/session-runtime.test.js +9 -9
  194. package/server/lib/opencode/settings-helpers.js +9 -9
  195. package/server/lib/opencode/settings-helpers.test.js +7 -12
  196. package/server/lib/opencode/settings-registry.json +6 -8
  197. package/server/lib/opencode/settings-runtime.js +18 -1
  198. package/server/lib/opencode/settings-runtime.test.js +31 -2
  199. package/server/lib/opencode/shared.js +54 -22
  200. package/server/lib/opencode/shared.test.js +8 -4
  201. package/server/lib/opencode/shutdown-runtime.js +54 -7
  202. package/server/lib/opencode/shutdown-runtime.test.js +224 -30
  203. package/server/lib/opencode/skill-routes.js +23 -24
  204. package/server/lib/opencode/skills.js +7 -5
  205. package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
  206. package/server/lib/opencode/upgrade-capability.test.js +1 -1
  207. package/server/lib/opencode/v1-migration-topup.js +288 -0
  208. package/server/lib/opencode/v1-migration-topup.test.js +266 -0
  209. package/server/lib/opencode/v2-install.d.ts +8 -0
  210. package/server/lib/opencode/v2-install.js +158 -0
  211. package/server/lib/opencode/v2-install.test.js +124 -0
  212. package/server/lib/opencode/watcher.js +10 -3
  213. package/server/lib/opencode/watcher.test.js +17 -21
  214. package/server/lib/opencode/websearch-config.js +66 -0
  215. package/server/lib/package-manager.js +55 -68
  216. package/server/lib/package-manager.test.js +241 -75
  217. package/server/lib/permission-auto-accept/runtime.js +38 -22
  218. package/server/lib/permission-auto-accept/runtime.test.js +39 -17
  219. package/server/lib/quota/DOCUMENTATION.md +4 -0
  220. package/server/lib/quota/providers/xai.js +4 -4
  221. package/server/lib/relay/tunnel-host.js +4 -1
  222. package/server/lib/relay/tunnel-host.test.js +7 -0
  223. package/server/lib/routing/DOCUMENTATION.md +52 -21
  224. package/server/lib/routing/defaults.js +23 -6
  225. package/server/lib/routing/jev.js +17 -7
  226. package/server/lib/routing/routes.http.test.js +68 -33
  227. package/server/lib/routing/routes.js +65 -22
  228. package/server/lib/routing/runtime.js +145 -48
  229. package/server/lib/routing/runtime.test.js +79 -55
  230. package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
  231. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
  232. package/server/lib/scheduled-tasks/runtime.js +81 -74
  233. package/server/lib/scheduled-tasks/runtime.test.js +53 -1
  234. package/server/lib/session-assist/DOCUMENTATION.md +8 -3
  235. package/server/lib/session-assist/context.js +122 -46
  236. package/server/lib/session-assist/context.test.js +117 -49
  237. package/server/lib/session-assist/runtime.js +52 -22
  238. package/server/lib/session-assist/runtime.test.js +145 -173
  239. package/server/lib/session-goal/DOCUMENTATION.md +23 -15
  240. package/server/lib/session-goal/create.js +9 -12
  241. package/server/lib/session-goal/create.test.js +27 -28
  242. package/server/lib/session-goal/runtime.js +164 -77
  243. package/server/lib/session-goal/runtime.test.js +271 -519
  244. package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
  245. package/server/lib/session-knowledge/runtime.js +59 -41
  246. package/server/lib/session-knowledge/runtime.test.js +90 -20
  247. package/server/lib/small-model/DOCUMENTATION.md +154 -208
  248. package/server/lib/small-model/client.js +113 -0
  249. package/server/lib/small-model/index.js +296 -158
  250. package/server/lib/small-model/index.test.js +423 -256
  251. package/server/lib/small-model/routes.js +1 -1
  252. package/server/lib/spaces/DOCUMENTATION.md +807 -0
  253. package/server/lib/spaces/code-in-bait.js +185 -0
  254. package/server/lib/spaces/code-in.js +641 -0
  255. package/server/lib/spaces/code-in.test.js +1048 -0
  256. package/server/lib/spaces/errors.js +8 -0
  257. package/server/lib/spaces/exec-http.js +94 -0
  258. package/server/lib/spaces/gatekeeper-channel.js +202 -0
  259. package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
  260. package/server/lib/spaces/gatekeeper-program.cjs +914 -0
  261. package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
  262. package/server/lib/spaces/hardening.js +457 -0
  263. package/server/lib/spaces/hardening.test.js +368 -0
  264. package/server/lib/spaces/host-git.js +127 -0
  265. package/server/lib/spaces/host-git.test.js +137 -0
  266. package/server/lib/spaces/labels.js +234 -0
  267. package/server/lib/spaces/labels.test.js +219 -0
  268. package/server/lib/spaces/layout.js +184 -0
  269. package/server/lib/spaces/layout.test.js +30 -0
  270. package/server/lib/spaces/manager.js +82 -0
  271. package/server/lib/spaces/manager.test.js +114 -0
  272. package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
  273. package/server/lib/spaces/places/contract-suite.js +156 -0
  274. package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
  275. package/server/lib/spaces/places/contract.test.js +6 -0
  276. package/server/lib/spaces/places/docker-engine.js +126 -0
  277. package/server/lib/spaces/places/docker-live-support.js +202 -0
  278. package/server/lib/spaces/places/docker-tools.js +186 -0
  279. package/server/lib/spaces/places/docker.js +587 -0
  280. package/server/lib/spaces/places/docker.test.js +1610 -0
  281. package/server/lib/spaces/places/escape-suite.js +1018 -0
  282. package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
  283. package/server/lib/spaces/places/fake-docker.js +375 -0
  284. package/server/lib/spaces/places/memory-place.js +103 -0
  285. package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
  286. package/server/lib/spaces/places/registry.js +43 -0
  287. package/server/lib/spaces/places/registry.test.js +50 -0
  288. package/server/lib/spaces/places/server.docker.live.test.js +225 -0
  289. package/server/lib/spaces/run-command.js +261 -0
  290. package/server/lib/spaces/run-command.test.js +396 -0
  291. package/server/lib/spaces/space-server.js +190 -0
  292. package/server/lib/spaces/space-server.test.js +335 -0
  293. package/server/lib/spaces/tools-filler.js +82 -0
  294. package/server/lib/spaces/tools-filler.test.js +148 -0
  295. package/server/lib/spaces/tools-pack.js +49 -0
  296. package/server/lib/spaces/tools-pack.test.js +57 -0
  297. package/server/lib/spaces/tools.js +138 -0
  298. package/server/lib/spaces/tools.test.js +153 -0
  299. package/server/lib/tts/openai-sdk.js +11 -0
  300. package/server/lib/tts/service.js +7 -5
  301. package/server/lib/tts/stt.js +3 -2
  302. package/server/lib/tunnels/DOCUMENTATION.md +2 -0
  303. package/server/lib/tunnels/routes.js +7 -0
  304. package/server/lib/tunnels/routes.test.js +55 -0
  305. package/server/lib/ui-auth/ui-auth.js +38 -2
  306. package/server/lib/ui-auth/ui-auth.test.js +42 -0
  307. package/server/lib/ui-auth/ui-passkeys.js +12 -10
  308. package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
  309. package/server/lib/walkthrough/pull-request.js +61 -8
  310. package/server/lib/walkthrough/pull-request.test.js +54 -1
  311. package/server/lib/walkthrough/routes.js +20 -0
  312. package/server/lib/walkthrough/routes.test.js +19 -0
  313. package/server/opencode-proxy.test.js +190 -166
  314. package/server/opencode-worktree-readiness.test.js +5 -4
  315. package/dist/assets/DiffView-COVQhWGd.js +0 -4
  316. package/dist/assets/FilesView-B1V5JxFX.js +0 -13
  317. package/dist/assets/LinearIssuesView-D7FKg1XJ.js +0 -1
  318. package/dist/assets/MarkdownImageGallery-BrFjAVEf.js +0 -1
  319. package/dist/assets/MarkdownRendererImpl-DWepTafh.js +0 -12
  320. package/dist/assets/OnboardingScreen-Dyxxiqdt.js +0 -1
  321. package/dist/assets/PlanView-LW2z_EAP.js +0 -5
  322. package/dist/assets/PluginPane-B4tKno2h.js +0 -3
  323. package/dist/assets/SettingsView-DEaMulN9.js +0 -29
  324. package/dist/assets/SettingsWindow-FLDJXOgQ.js +0 -1
  325. package/dist/assets/SubmoduleDiffSummary-CvVwD-Vi.js +0 -1
  326. package/dist/assets/ToolOutputDialog-BiP0x2Rw.js +0 -15
  327. package/dist/assets/ToolPartDiffPreview-CkR4msKP.js +0 -8
  328. package/dist/assets/appThemeRegistry-BuUKhbYQ.js +0 -1
  329. package/dist/assets/de-DgxgFyGG.js +0 -10
  330. package/dist/assets/es-BFsZj5F_.js +0 -16
  331. package/dist/assets/fr-jdZ5KKQi.js +0 -14
  332. package/dist/assets/index-CKHjPKbq.js +0 -1
  333. package/dist/assets/index-Cbci4i1W.js +0 -40
  334. package/dist/assets/index-DqaMWNrC.css +0 -1
  335. package/dist/assets/ja-C5kKrhO4.js +0 -16
  336. package/dist/assets/ko-DXDTT_0O.js +0 -16
  337. package/dist/assets/main-CZALtVek.js +0 -896
  338. package/dist/assets/main-CgXMBNvG.js +0 -2
  339. package/dist/assets/miniChat-CwTmDixi.js +0 -2
  340. package/dist/assets/mobile-CLf2vCtO.js +0 -2
  341. package/dist/assets/pl-D-7x4Y8Q.js +0 -16
  342. package/dist/assets/pt-BR-CSBZrHa8.js +0 -16
  343. package/dist/assets/renderElectronMiniChatApp-C5gAFBk0.js +0 -2
  344. package/dist/assets/renderMobileApp-V4hYd32H.js +0 -25
  345. package/dist/assets/runtimeEndpointReset-DhlHCn-2.js +0 -25
  346. package/dist/assets/scheduledTasksApi-DzjbLd8P.js +0 -1
  347. package/dist/assets/tr-Dr-oJ22L.js +0 -7
  348. package/dist/assets/uk-9Nx83UcI.js +0 -16
  349. package/dist/assets/useAppFontEffects-khZXpFL_.js +0 -7333
  350. package/dist/assets/useRootScrollLock-DdvHf9Pt.js +0 -2
  351. package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
  352. package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
  353. package/dist/assets/zh-CN-Bxy_Hj3r.js +0 -16
  354. package/dist/assets/zh-TW-0BB4gpHM.js +0 -16
  355. package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
  356. package/server/lib/routing/feature-flag.js +0 -11
  357. package/server/lib/small-model/call.js +0 -851
  358. package/server/lib/small-model/call.test.js +0 -1292
  359. package/server/lib/small-model/catalog.js +0 -13
  360. package/server/lib/small-model/resolve.js +0 -131
  361. package/server/lib/small-model/resolve.test.js +0 -197
  362. package/server/lib/small-model/runtime-providers.js +0 -164
  363. package/server/lib/small-model/runtime-providers.test.js +0 -118
  364. package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
  365. package/server/lib/system-prompt/runtime.js +0 -49
  366. package/server/lib/system-prompt/runtime.test.js +0 -76
  367. package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
@@ -0,0 +1,896 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-lap5btCF.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Ci3FEaPf.js","assets/index-CvLgnuNI.js","assets/vendor-zod-Gea9uBlY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-_BAHQo4R.js","assets/index-CLcM8HKx.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CQa7_1cr.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-BpeUOV91.js","assets/runtimeEndpointReset-CsIpUep1.js","assets/GuestAttachDialog-DdOuyZzp.js","assets/PluginPane-BPP1dbck.js","assets/VirtualizedFileDiff-C763hNCR.js","assets/web-components-B6tKQyJN.js","assets/computeVirtualFileMetrics-DW5jjX4n.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isDiffPlainText-D47a6hMP.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-DW23KWKZ.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CuUuakrt.js","assets/appThemeRegistry-u4zw1l0B.js","assets/textMateThemeFromAppTheme-DGF2kG7g.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-CQIsyERq.js","assets/scheduledTasksApi-B5OHVpPM.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-CjxUovbM.js","assets/SubmoduleDiffSummary-BLttSS1X.js","assets/FilesView-DFWD0RQR.js","assets/shikiHighlight-DNm2Z_Jc.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-3sGwqexh.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-B-mGgeKl.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-ntXIbhV2.js","assets/GitView-BWa7e5vw.js","assets/commitAndPush-CwGJfJG-.js","assets/LinearIssuesView-C6dpIdjw.js","assets/PlanView-BCk_VobP.js","assets/GuestSurfacePane-DDfzid3U.js","assets/SettingsWindow-BpvD6IYQ.js","assets/SettingsView-kMmrpn43.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-rK4Stg__.js"])))=>i.map(i=>d[i]);
2
+ import{f as tt,R as c,j as s,r as ut,c as Om,h as Bm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{E as xn,F as Zo,H as Fm,I as _m,h as bs,x as Od,u as Ne,J as Mt,K as pl,a as Qt,y as Cr,o as xt,L as Ts,N as qr,O as _n,P as Bd,Q as Lm,R as $m,S as zm,T as Wm,U as Fd,n as os,V as Fn,W as Yr,e as Dn,X as Km,Y as Vm,Z as Um,_ as Hm,$ as _d,v as pn,B as dn,a0 as Gm,a1 as gl,a2 as qm,a3 as Ld,a4 as Ym,a5 as $d,f as Qm,a6 as Qn,a7 as tr,a8 as Fo,a9 as Ui,aa as Xm,ab as Ma,d as _o,t as Fr,q as Ns,ac as zd,ad as Jm,ae as Hi,af as Wd,ag as Kd,i as Zm,ah as Po,ai as Do,aj as eh,ak as xl,al as th,am as sh,an as nh,ao as rh,ap as bl,aq as yl,ar as wl,as as vl,at as oh,A as Sl,au as ih,av as ah,aw as lh,C as ch,D as dh}from"./index-CvLgnuNI.js";import{_ as yn}from"./vendor-vite-runtime-DD1OZmLC.js";import{y as jl,z as ki,E as an,F as Gi,G as kl,H as uh,I as fh,J as mh,K as hh,L as ph,M as gh,Q as xh,R as bh,V as Oa,a as yh,e as Vd,W as Ud,h as qi,l as Hd,X as wh,k as vh,j as Sh,Y as Gd,Z as Yi,_ as Xn,$ as qd,a0 as Yd,P as jh,T as kh,a1 as Ch,a2 as Nh,a3 as Ah,b as Qd,a4 as Ph,a5 as Xd,a6 as Lo,a7 as Dh,a8 as Ih,a9 as Th,S as Ci,aa as Jd,ab as Zd,d as Eh,ac as Rh,c as Mh,ad as Oh,r as Cl,ae as Bh,af as Fh,ag as lo,u as Kr,s as _h,N as Lh,D as $h,ah as zh,ai as Nl,aj as Wh,ak as Ni,v as Kh,o as Vh,w as eu,U as Uh,x as Hh,al as Gh,am as qh,an as Yh,O as Qh,n as Xh,q as Jh,t as tu,A as Zh,C as ep}from"./runtimeEndpointReset-CsIpUep1.js";import{f as Nt,h as Ee,bh as Ht,I as _,g as cr,t as Ke,at as Fs,bi as Es,av as _s,as as Ls,T as Ln,_ as wn,ai as dr,bj as $n,o as eo,bk as Al,bl as tp,bm as sp,ae as vt,af as St,ag as jt,b as Ut,z as rt,H as np,bn as su,bo as co,u as vs,r as As,D as nu,C as ru,bp as Qi,bq as rp,br as ou,bs as iu,S as Ba,bt as op,bu as ip,bv as Pl,bw as Dl,bx as au,by as ap,bz as Il,bA as lp,bB as cp,bC as Fa,bD as Xi,bE as lu,bF as dp,bG as up,bH as fp,Q as cu,bI as mp,bJ as hp,bK as pp,n as hr,bL as du,bM as gp,bN as xp,p as bp,bO as uu,bP as yp,bQ as wp,bR as vp,bS as fu,bT as mu,bU as hu,bV as pu,bW as gu,bX as xu,bY as bu,bZ as to,b_ as _a,aJ as La,b$ as sr,c0 as so,c1 as Sp,c2 as Ps,c3 as Ds,c4 as sn,c5 as Us,c6 as Hs,c7 as zn,B as ct,c8 as En,aB as Cs,c9 as jp,ca as kp,aH as In,cb as _r,cc as Vs,cd as ei,ce as yu,cf as Ji,cg as Zi,ch as ea,ci as Cp,cj as Rs,ck as Ms,cl as js,cm as Os,cn as rs,X as An,co as pr,cp as Tl,cq as xr,cr as wu,R as ti,aj as Np,ak as $a,al as vu,J as Su,K as Tn,cs as za,a9 as Wa,ct as Ap,cu as Pp,az as Dp,cv as Ip,cw as ju,cx as Tp,cy as Ep,aA as Ka,cz as Rp,cA as ku,cB as br,cC as Cu,cD as Mp,l as Yt,s as Op,cE as Bp,cF as Fp,aO as Wn,cG as _p,cH as mr,O as Nu,cI as Lp,cJ as $p,cK as Kn,cL as zp,cM as Wp,aD as Kp,cN as Ai,cO as Vp,cP as Up,cQ as Hp,cR as Au,cS as Va,cT as Gp,cU as Pu,cV as qp,aI as ta,cW as sa,cX as El,cY as Yp,cZ as Rl,c_ as Lr,c as Qr,d as Ua,a4 as Qp,a1 as Du,c$ as Dr,d0 as $r,d1 as Xp,d2 as Jp,d3 as Zp,$ as Ha,aC as eg,d4 as tg,d5 as sg,d6 as ng,d7 as rg,d8 as Iu,d9 as un,da as og,db as Tu,dc as ig,a8 as na,dd as ag,de as Eu,df as ms,dg as lg,dh as cg,di as dg,dj as Ru,dk as ug,dl as Ga,dm as Mu,a6 as $o,dn as ra,dp as si,a as qa,dq as Ya,a5 as fg,dr as Ml,U as ni,V as ri,W as oi,ds as mg,dt as oa,du as Ou,dv as hg,au as Bu,dw as pg,dx as Qa,P as ia,L as gg,dy as Ol,dz as xg,dA as bg,dB as ss,dC as yg,dD as ir,dE as Fu,dF as _u,dG as Lu,dH as $u,dI as wg,E as vg,dJ as Sg,dK as jg,dL as kg,dM as Bl,dN as zu,dO as Cg,dP as Wu,F as Ng,dQ as Ag,dR as Pg,dS as Vr,dT as Dg,dU as Ig,dV as Tg,dW as Eg,e as Xa,dX as ii,dY as Rg,dZ as Xr,a3 as Mg,G as ai,d_ as Og,d$ as Bg,e0 as Fl,e1 as Fg,e2 as _g,a0 as Lg,e3 as $g,e4 as zg,a$ as _l,ab as Ll,aa as $l,e5 as Wg,aW as aa,e6 as Kg,M as Vg,N as Pi,e7 as Ug,e8 as Hg,e9 as Ku,ea as Vu,eb as Uu,ec as Gg,ed as qg,a7 as Yg,am as Qg,ee as Xg,ef as zl,eg as Jg,eh as Zg,ei as ex,ej as tx,ek as zo,el as sx,em as Wl,en as nx,eo as rx,ep as ox,eq as ix,er as la,es as ax,et as Io,eu as lx,i as cx,ev as dx,ew as ux,ex as fx,ey as mx,ez as hx,eA as px,eB as Kl,eC as gx,aP as xx,aQ as bx,aS as yx,aR as wx,aU as Vl,aV as Ul,aY as Hl,aZ as Gl,aX as Hu,a_ as Gu,eD as vx,bc as Sx,bd as jx,be as kx,bf as Cx,bg as Nx,b6 as Ax,b8 as Px,b9 as Dx,ba as Ix,bb as Tx}from"./useAppFontEffects-Ci3FEaPf.js";import{u as qu,S as ql,C as Ex,t as Rx,W as Yu,f as Mx,G as Ox,a as Bx}from"./useRootScrollLock-CQIsyERq.js";import{u as Un,O as Yl,D as Fx,a as _x,b as Lx,c as $x,f as zx,d as Ql,s as Wx,e as Kx,g as Vx,r as Ux}from"./scheduledTasksApi-B5OHVpPM.js";import{f as li,h as Pn,T as ci,M as di,D as ui,j as fi,d as Hx,b as Gx,k as qx,i as Yx}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as mi,S as Ja,h as Qx,a as Qu,v as Xu,s as Xx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as hi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Ju,M as Zu,C as ef,a as ca,b as da,c as ua,d as tf,e as Jx,f as Zx}from"./vendor-base-ui-CsXYnR5c.js";import{c as no,u as ar,d as eb,p as tb}from"./vendor-zustand-BAGL70zf.js";import{g as sb,a as nb,E as sf,b as rb,c as ob,d as ib,e as ab,i as lb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as cb}from"./PluginPane-BPP1dbck.js";import{a as Za,s as lr,r as nf,o as Xl,b as Jl}from"./vendor-zod-Gea9uBlY.js";import{u as db}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as ub}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as rf}from"./vendor-cron-parser-CjvYVigk.js";const fb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",mb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",Di=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?fb:t.id==="terminal"?mb:void 0}),Zl=t=>{const e=tt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=y):y=e[4],y}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Ee("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},hb=t=>{const e=tt.c(75),{directory:n,className:r}=t,{t:i}=Nt(),o=Un(pb),l=Un(gb),a=Un(xb),d=Un(bb),u=Un(yb),m=Un(wb),f=Un(vb);let p,y;e[0]!==u?(p=()=>{u()},y=[u],e[0]=u,e[1]=p,e[2]=y):(p=e[1],y=e[2]),c.useEffect(p,y);const x=xn()&&Zo();let k;e:{let be;e[3]!==l||e[4]!==o?(be=l.find(H=>H.id===o)??l.find(Sb)??l[0]??Yl[0],e[3]=l,e[4]=o,e[5]=be):be=e[5];const fe=be;if(fe){let H;e[6]!==fe?(H=Di(fe),e[6]=fe,e[7]=H):H=e[7],k=H;break e}let ke;e[8]===Symbol.for("react.memo_cache_sentinel")?(ke=Di(Yl[0]),e[8]=ke):ke=e[8],k=ke}const w=k;if(!x||!n||l.length===0)return null;let h;e[9]!==n?(h=async be=>{await Fm(n,be.id,be.appName)||await _m(n,be.appName)},e[9]=n,e[10]=h):h=e[10];const g=h;let j;e[11]!==g||e[12]!==f?(j=async be=>{await f(be.id),await g(be)},e[11]=g,e[12]=f,e[13]=j):j=e[13];const b=j;let S;e[14]!==n||e[15]!==i?(S=async()=>{(await cr(n)).ok&&Ke.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=S):S=e[16];const C=S;let v;e[17]!==r?(v=Ee("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=v):v=e[18];let E;e[19]!==g||e[20]!==w?(E=()=>{g(w)},e[19]=g,e[20]=w,e[21]=E):E=e[21];const R=d&&"animate-pulse";let A;e[22]!==R?(A=Ee("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",R),e[22]=R,e[23]=A):A=e[23];let O;e[24]!==w.label||e[25]!==i?(O=i("openInApp.actions.openInAria",{app:w.label}),e[24]=w.label,e[25]=i,e[26]=O):O=e[26];let B;e[27]!==w.fallbackIconDataUrl||e[28]!==w.iconDataUrl||e[29]!==w.label?(B=s.jsx(Zl,{label:w.label,iconDataUrl:w.iconDataUrl,fallbackIconDataUrl:w.fallbackIconDataUrl}),e[27]=w.fallbackIconDataUrl,e[28]=w.iconDataUrl,e[29]=w.label,e[30]=B):B=e[30];let T;e[31]!==A||e[32]!==O||e[33]!==B||e[34]!==E?(T=s.jsx("button",{type:"button",onClick:E,className:A,"aria-label":O,children:B}),e[31]=A,e[32]=O,e[33]=B,e[34]=E,e[35]=T):T=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=Ee("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=M):M=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let W;e[39]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=W):W=e[39];let $;e[40]!==L?($=s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:M,"aria-label":L,children:W})}),e[40]=L,e[41]=$):$=e[41];let P;e[42]!==C?(P=()=>{C()},e[42]=C,e[43]=P):P=e[43];let D;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(_,{name:"file-copy",className:"h-4 w-4"}),e[44]=D):D=e[44];let I;e[45]!==i?(I=i("openInApp.actions.copyPath"),e[45]=i,e[46]=I):I=e[46];let X;e[47]!==I?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:I}),e[47]=I,e[48]=X):X=e[48];let Z;e[49]!==P||e[50]!==X?(Z=s.jsxs(Ht,{className:"flex items-center gap-2",onClick:P,children:[D,X]}),e[49]=P,e[50]=X,e[51]=Z):Z=e[51];let ne;e[52]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(Es,{}),e[52]=ne):ne=e[52];let ue;if(e[53]!==l||e[54]!==b||e[55]!==w.id){let be;e[57]!==b||e[58]!==w.id?(be=fe=>{const ke=Di(fe);return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{b(fe)},children:[s.jsx(Zl,{label:fe.label,iconDataUrl:fe.iconDataUrl,fallbackIconDataUrl:ke.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:fe.label}),w.id===fe.id?s.jsx(_,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},fe.id)},e[57]=b,e[58]=w.id,e[59]=be):be=e[59],ue=l.map(be),e[53]=l,e[54]=b,e[55]=w.id,e[56]=ue}else ue=e[56];let se;e[60]!==a||e[61]!==m||e[62]!==i?(se=a?s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(_,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=m,e[62]=i,e[63]=se):se=e[63];let xe;e[64]!==Z||e[65]!==ue||e[66]!==se?(xe=s.jsxs(_s,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Z,ne,ue,se]}),e[64]=Z,e[65]=ue,e[66]=se,e[67]=xe):xe=e[67];let ie;e[68]!==$||e[69]!==xe?(ie=s.jsxs(Ls,{children:[$,xe]}),e[68]=$,e[69]=xe,e[70]=ie):ie=e[70];let Re;return e[71]!==T||e[72]!==ie||e[73]!==v?(Re=s.jsxs("div",{className:v,children:[T,ie]}),e[71]=T,e[72]=ie,e[73]=v,e[74]=Re):Re=e[74],Re};function pb(t){return t.selectedAppId}function gb(t){return t.availableApps}function xb(t){return t.isCacheStale}function bb(t){return t.isScanning}function yb(t){return t.initialize}function wb(t){return t.loadInstalledApps}function vb(t){return t.selectApp}function Sb(t){return t.id===Fx}const Wo=new Map,fa=new Set,of=()=>{for(const t of fa)t()},Ii=(t,e)=>{const n=t.trim();n&&(e.length===0?Wo.delete(n):Wo.set(n,[...e]),of())},jb=t=>{Wo.delete(t.trim())&&of()},af=[],kb=t=>Wo.get(t.trim())??af,Cb=t=>(fa.add(t),()=>{fa.delete(t)}),Nb=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=()=>kb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(Cb,n,Ab)};function Ab(){return af}const Pb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Db=["dev","start","preview","serve"];async function Ib(t,e,n){if(!t)return null;const r=Rb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Mb(n);if(i){const o=await Ob(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await Tb(t)){const i=await Eb(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function Tb(t){const e=`${t}/index.html`,n=await Ko(e,t);return typeof n=="string"&&n.trim().length>0}async function Eb(){try{const t=await bs("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Rb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Db.some(i=>n.includes(i)))return e}return null}function Mb(t){for(const{pattern:e}of Pb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ob(t){const e=await Ko(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Ko(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ko(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await bs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Od()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await bs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Bb(t){try{const e=await Ko(`${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 cn="__openchamber_auto_discover_preview__",Fb=15e3,_b=3e3,Ti=t=>t.id===cn?"scan-2":bh.find(n=>n.key===t.icon)?.Icon??"play",Lb=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},$b=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=Nt(),{currentTheme:l}=Ln(),{terminal:a,runtime:d}=wn(),u=dr(),{isMobile:m}=$n(),f=c.useMemo(()=>xn(),[]),p=jl(te=>te.instances),y=jl(te=>te.load),x=Ne(te=>te.terminalShell),k=Ne(te=>te.terminalLoginShells.includes(te.terminalShell)),w=Ne(te=>te.setSettingsPage),h=Ne(te=>te.setSettingsDialogOpen),g=Ne(te=>te.setSettingsProjectsSelectedId),j=Ne(te=>te.openContextPreview),b=Mt(te=>te.ensureDirectory),S=Mt(te=>te.reconcileServerSessions),C=Mt(te=>te.setTabLabel),v=Mt(te=>te.setTabIconKey),E=Mt(te=>te.setActiveTab),R=Mt(te=>te.setConnecting),A=Mt(te=>te.setTabSessionId),O=Mt(te=>te.setTabPurpose),B=Mt(te=>te.allocateActionExecution),T=Mt(te=>te.setTabLifecycle),M=Mt(te=>te.setTabPreviewUrl),L=Mt(te=>te.matchesActionExecution),W=Mt(te=>te.captureStartedActionMutationRevisions),[$,P]=c.useState([]),D=c.useRef(null),[I,X]=c.useState(null),[Z,ne]=c.useState(!1),ue=c.useRef({}),se=c.useRef({}),xe=c.useRef({}),ie=c.useRef(new Set),Re=c.useRef(0),[be,fe]=c.useState({}),ke=t?.id??null,H=t?.path??"",J=c.useMemo(()=>ke?{id:ke,path:H}:null,[ke,H]);c.useEffect(()=>{f&&y().catch(()=>{})},[f,y]);const ce=c.useCallback(async te=>{await eo(te)},[]),je=c.useCallback(async()=>{if(!J)return;const te=Re.current+1;Re.current=te,ne(!0);try{const me=await Al(J);if(Re.current!==te)return;D.current=me;const De=me.projectActions;P(De),X(K=>K===cn||K&&De.some(Se=>Se.id===K)?K:null)}catch{if(Re.current!==te)return}finally{Re.current===te&&ne(!1)}},[J]),G=c.useMemo(()=>ki(e||J?.path||""),[e,J?.path]),we=c.useMemo(()=>ki(J?.path||""),[J?.path]),Te=c.useMemo(()=>ki(u||"")||G,[u,G]),he=c.useRef(Te);c.useEffect(()=>{he.current=Te},[Te]);const re=Mt(te=>G?te.getDirectoryState(G):void 0),ge=Mt(te=>we&&we!==G?te.getDirectoryState(we):void 0),q=c.useMemo(()=>{const te=G?[{directory:G,state:re}]:[];return we&&we!==G&&te.push({directory:we,state:ge}),te},[re,G,we,ge]),z=c.useMemo(()=>{const te=G?[G]:[];return we&&we!==G&&te.push(we),te},[G,we]),ee=c.useCallback(te=>te.id!==cn&&te.runIn==="parent"&&we||G,[G,we]),de=c.useCallback((te,me,De)=>`${te}::${me}::${De}`,[]),Y=c.useCallback((te,me,De=Mt.getState())=>te?De.getDirectoryState(te)?.tabs.find(K=>K.purpose.type==="project-action"&&K.purpose.actionId===me)??null:null,[]),U=c.useMemo(()=>{const te={};for(const{directory:me,state:De}of q)for(const K of De?.tabs??[]){if(K.purpose.type!=="project-action"||!K.purpose.executionId||!K.terminalSessionId||K.lifecycle==="idle"||K.lifecycle==="exited")continue;const Se=an(me,K.purpose.actionId),Ve=de(me,K.purpose.actionId,K.purpose.executionId);te[Se]={directory:me,actionId:K.purpose.actionId,tabId:K.id,sessionId:K.terminalSessionId,executionId:K.purpose.executionId,status:K.lifecycle==="stopping"?"stopping":be[Ve]?"waiting-for-preview":"running"}}return te},[de,be,q]),F=c.useCallback((te,me,De)=>{const K=an(te,me),Se=de(te,me,De),Xe=ue.current[K]?.executionId===De,nt=globalThis.window,Ze=gt=>{nt?.clearTimeout(xe.current[gt]),delete xe.current[gt]};Xe&&(delete ue.current[K],Ze(K)),se.current[Se]?.(),delete se.current[Se],Ze(Se),fe(gt=>{if(!gt[Se])return gt;const We={...gt};return delete We[Se],We})},[de]),V=c.useCallback(te=>{se.current[te]?.(),delete se.current[te]},[]),oe=c.useCallback(te=>{window.clearTimeout(xe.current[te]),delete xe.current[te]},[]);c.useEffect(()=>{const te=se.current,me=xe.current;return()=>{for(const De of Object.keys(te))V(De);for(const De of Object.keys(me))oe(De)}},[oe,V]),c.useEffect(()=>{const te=new Set(z);for(const me of Object.values(ue.current))te.has(me.directory)||F(me.directory,me.actionId,me.executionId);for(const me of Object.keys(se.current)){const De=me.split("::",1)[0]??"";te.has(De)||V(me)}},[F,V,z]);const ae=c.useCallback((te,me)=>{Ne.getState().openContextPanelTab(te,{mode:"terminal",targetDirectory:me===te?null:me})},[]),pe=c.useMemo(()=>I?$.find(te=>te.id===I)??null:null,[$,I]),le=c.useMemo(()=>({id:cn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),_e=!m,Fe=c.useMemo(()=>_e?[le,...$]:$,[$,le,_e]);c.useEffect(()=>{je()},[je]),c.useEffect(()=>{const te=z.map(me=>Gi(a,me,W,De=>S(me,De.sessions,{startedActionMutationRevisions:De.startedActionMutationRevisions})));return()=>{for(const me of te)me()}},[W,S,a,z]),c.useEffect(()=>{for(const{directory:te,state:me}of q)if(te)for(const De of me?.tabs??[]){if(De.purpose.type!=="project-action")continue;const K=De.purpose.actionId,Se=Fe.find(nt=>nt.id===K),Ve=Se?.name??K,Xe=Se?.icon||"play";De.label!==Ve&&C(te,De.id,Ve),De.iconKey!==Xe&&v(te,De.id,Xe)}},[Fe,v,C,q]),c.useEffect(()=>{const te=globalThis.window;if(!te)return;const me=De=>{const K=De.detail;ke&&(K?.projectId&&K.projectId!==ke||je())};return te.addEventListener(kl,me),()=>{te.removeEventListener(kl,me)}},[je,ke]),c.useEffect(()=>{I&&(I===cn&&_e||$.some(te=>te.id===I)||X(null))},[$,_e,I]),c.useEffect(()=>{const te=De=>{delete xe.current[De];const K=ue.current[De];if(!K||K.openedUrl)return;const Se=de(K.directory,K.actionId,K.executionId),Ve=K.announced;if(Ve.length!==0){if(window.clearTimeout(xe.current[Se]),delete xe.current[Se],K.openedUrl=!0,fe(Xe=>{if(!Xe[Se])return Xe;const nt={...Xe};return delete nt[Se],nt}),Ve.length===1){Ii(K.directory,[]),M(K.directory,K.tabId,Ve[0],{locked:!1,autoOpened:!0}),j(K.directory,Ve[0]);return}K.offering=!0,Ii(K.directory,Ve),Ne.getState().openContextSurface(K.directory,"browser"),Ke.info(o("projectActions.toast.multipleServers"))}},me=()=>{const De=Mt.getState(),K=De.sessions,Se=U;for(const[Ve,Xe]of Object.entries(Se)){const Ze=K.get(Xe.directory)?.tabs.find(ve=>ve.id===Xe.tabId);if(!Ze||Ze.terminalSessionId!==Xe.sessionId){F(Xe.directory,Xe.actionId,Xe.executionId);continue}const gt=ue.current[Ve],We=gt?.executionId===Xe.executionId?gt:{hostDirectory:he.current||Xe.directory,directory:Xe.directory,tabId:Xe.tabId,actionId:Xe.actionId,executionId:Xe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ue.current[Ve]=We;const Et=Fe.find(ve=>ve.id===Xe.actionId),Ft=De.getBuffer(Xe.directory,Xe.tabId).chunks;if(!Et||Ft.length===0)continue;const Ie=Ft.filter(ve=>We.lastSeenChunkId===null||ve.id>We.lastSeenChunkId);if(Ie.length===0)continue;const yt=Ie.map(ve=>ve.data).join(""),At=`${We.tail}${yt}`;if(We.openInPreview&&(!We.openedUrl||We.offering)){const ve=gh(At),Qe=We.announced.length;for(const Ye of ve)We.announced.includes(Ye)||We.announced.push(Ye);const qe=We.announced.length-Qe;We.offering&&qe>0?Ii(Xe.directory,We.announced):!We.openedUrl&&Qe===0&&We.announced.length>0&&(window.clearTimeout(xe.current[Ve]),xe.current[Ve]=window.setTimeout(()=>te(Ve),_b))}const He=!We.openedUrl&&Et.autoOpenUrl===!0&&!We.openInPreview?xh(At):null,Ue=Ie[Ie.length-1]?.id??We.lastSeenChunkId;if(We.lastSeenChunkId=Ue,We.tail=At.slice(-512),He)if(We.openedUrl=!0,We.openInPreview){const ve=Se[Ve];ve&&(M(ve.directory,ve.tabId,He,{locked:!1,autoOpened:!1,expectedExecutionId:ve.executionId}),ve.status==="waiting-for-preview"&&fe(Qe=>{const qe=de(ve.directory,ve.actionId,ve.executionId);if(!Qe[qe])return Qe;const Ye={...Qe};return delete Ye[qe],Ye}),window.clearTimeout(xe.current[Ve]),delete xe.current[Ve],j(ve.directory,He))}else ce(He),Ke.success(o("projectActions.toast.openedUrlFromOutput"));ue.current[Ve]=We}for(const Ve of Object.keys(ue.current))if(!Se[Ve]){const Xe=ue.current[Ve],nt=Xe?K.get(Xe.directory)?.tabs.find(gt=>gt.id===Xe.tabId):void 0;if(nt?.purpose.type==="project-action"&&nt.purpose.executionId===Xe?.executionId&&!!nt.terminalSessionId&&nt.lifecycle!=="idle"&&nt.lifecycle!=="exited")continue;delete ue.current[Ve],window.clearTimeout(xe.current[Ve]),delete xe.current[Ve]}};return me(),Mt.subscribe((De,K)=>{(De.sessions!==K.sessions||De.buffers!==K.buffers)&&me()})},[F,he,Fe,de,j,ce,U,M,o]),c.useEffect(()=>{for(const{directory:te,state:me}of q)for(const De of me?.tabs??[]){if(De.purpose.type!=="project-action"||!De.purpose.executionId||!De.terminalSessionId||De.lifecycle!=="running")continue;const K=De.purpose.actionId,Se=De.purpose.executionId,Ve=de(te,K,Se);if(se.current[Ve])continue;const Xe=a.connect(De.terminalSessionId,{onEvent:nt=>{if(!L(te,De.id,Se))return;nt.type==="snapshot"&&(Mt.getState().replaceBuffer(te,De.id,nt.data??"",nt.sequence??0,pl(nt)),nt.status==="running"&&Mt.getState().setTabLifecycle(te,De.id,"running",{expectedExecutionId:Se}),nt.status==="exited"&&(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se)));const Ze=nt.type==="data"?nt.data??"":"";Ze&&Mt.getState().appendToBuffer(te,De.id,Ze,nt.sequence,nt.replayData),nt.type==="exit"&&(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se))},onError:(nt,Ze)=>{!Ze||!L(te,De.id,Se)||(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabSessionId(te,De.id,null,{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se))}});se.current[Ve]=Xe.close}},[F,de,L,a,q]);const Me=c.useCallback(async te=>{const me=ee(te);if(!me)throw new Error(o("projectActions.error.noActiveDirectory"));const De=an(me,te.id);b(me);const K=Mt.getState(),Se=Y(me,te.id,K),Ve=Se?.id??K.createTab(me);C(me,Ve,te.name),v(me,Ve,te.icon||"play"),Se||O(me,Ve,{type:"project-action",actionId:te.id,executionId:null}),E(me,Ve);const nt=Mt.getState().getDirectoryState(me)?.tabs.find(Ze=>Ze.id===Ve);return{executionDirectory:me,key:De,tabId:Ve,sessionId:nt?.terminalSessionId??null,executionId:nt?.purpose.type==="project-action"?nt.purpose.executionId:null}},[b,ee,Y,E,v,C,O,o]),Ae=c.useCallback(async te=>{if(d.isVSCode||!i&&m)return;if(!G){Ke.error(o("projectActions.error.noActiveDirectoryForAction"));return}const me=an(ee(te),te.id),De=U[me];if(De&&De.status==="running"||ie.current.has(me))return;ie.current.add(me);let K=null;try{const Se=te.id===cn?await(async()=>{const[qe,Ye]=await Promise.all([tp({id:J?.id??"",path:G}),Bb(G)]),dt=await Ib(G,qe.actions,Ye);if(!dt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:cn,name:o("projectActions.actions.autoDiscover"),command:dt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:dt.previewUrlHint||""}})():te,Ve=Se.autoOpenUrl===!0&&(Se.openUrl||"").trim().length>0,Xe=!Ve&&te.id!==cn,nt=he.current||G,{executionDirectory:Ze,key:gt,tabId:We}=await Me(Se),Et=uh(Se.command);if(!Et)throw new Error(o("projectActions.error.failedToRunAction"));const Ft=Se.autoOpenUrl===!0&&f&&(Se.desktopOpenSshForward||"").trim().length>0,Ie=Se.autoOpenUrl?Lb(Se.openUrl):null,yt=Se.autoOpenUrl&&f?fh(Se.desktopOpenSshForward,p):null;if(a.listSessions){const qe=Y(Ze,Se.id);if(qe?.purpose.type==="project-action"&&qe.purpose.executionId===null){const Ye=await mh(a,Ze,{captureStartedActionMutationRevisions:W});Ye&&S(Ze,Ye.sessions,{startedActionMutationRevisions:Ye.startedActionMutationRevisions})}}const At=Y(Ze,Se.id);let He,Ue;if(At?.lifecycle==="running"&&At.terminalSessionId&&At.purpose.type==="project-action"&&At.purpose.executionId)He=At.terminalSessionId,Ue=At.purpose.executionId;else{const qe=At?.purpose.type==="project-action"?At.purpose.executionId:null;qe&&F(Ze,Se.id,qe);const Ye=B(Ze,We,Se.id);if(!Ye)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));K={directory:Ze,tabId:We,id:Ye},R(Ze,We,!0,{expectedExecutionId:Ye});const dt=await hh({terminal:a,createOptions:{cwd:Ze,shell:x,loginShell:k,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Et,isRunStillExpected:()=>L(Ze,We,Ye),purpose:{type:"project-action",actionId:Se.id,executionId:Ye}});if(!L(Ze,We,Ye)){dt.sessionId===Ye&&await a.close(dt.sessionId).catch(()=>{});return}Ue=dt.purpose?.type==="project-action"?dt.purpose.executionId:Ye,He=dt.sessionId,O(Ze,We,{type:"project-action",actionId:Se.id,executionId:Ue}),A(Ze,We,He,{expectedExecutionId:Ue}),R(Ze,We,!1,{expectedExecutionId:Ue})}Xe&&nt&&ae(nt,Ze),ue.current[gt]={hostDirectory:nt,directory:Ze,tabId:We,actionId:Se.id,executionId:Ue,lastSeenChunkId:null,openedUrl:!!yt||!!Ie||Ve,tail:"",openInPreview:Se.id===cn,announced:[],offering:!1};const ve=de(Ze,Se.id,Ue);R(Ze,We,!0,{expectedExecutionId:Ue});const Qe=a.connect(He,{onEvent:qe=>{if(!L(Ze,We,Ue)||qe.purpose?.type==="project-action"&&qe.purpose.executionId!==Ue)return;qe.type==="snapshot"&&(Mt.getState().replaceBuffer(Ze,We,qe.data??"",qe.sequence??0,pl(qe)),Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),qe.purpose?.type==="project-action"&&Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:qe.purpose.actionId,executionId:qe.purpose.executionId}),qe.status==="running"&&Mt.getState().setTabLifecycle(Ze,We,"running",{expectedExecutionId:Ue}),qe.status==="exited"&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue)));const Ye=qe.type==="data"?qe.data??"":"";Ye&&Mt.getState().appendToBuffer(Ze,We,Ye,qe.sequence,qe.replayData),qe.type==="exit"&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue))},onError:(qe,Ye)=>{L(Ze,We,Ue)&&(Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),Ye&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setTabSessionId(Ze,We,null,{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue)))}});if(!L(Ze,We,Ue)){Qe.close();return}se.current[ve]?.(),se.current[ve]=Qe.close,window.clearTimeout(xe.current[ve]),delete xe.current[ve],Se.id===cn&&!Ie&&(fe(qe=>({...qe,[ve]:!0})),xe.current[ve]=window.setTimeout(()=>{delete xe.current[ve];const qe=ue.current[gt];!qe||qe.executionId!==Ue||qe.openedUrl||qe.offering||L(Ze,We,Ue)&&(fe(Ye=>{if(!Ye[ve])return Ye;const dt={...Ye};return delete dt[ve],dt}),Mt.getState().setActiveTab(Ze,We),ae(qe.hostDirectory,Ze))},Fb)),yt?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),ce(yt),Ke.success(o("projectActions.toast.openedForwardedUrl"))):Ie?(M(Ze,We,Ie,{locked:!0,autoOpened:!0,expectedExecutionId:Ue}),j(nt,Ie),Ke.success(o("projectActions.toast.openedActionUrl"))):Ve?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),Ke.error(o("projectActions.error.invalidCustomUrlFormat"))):Ft?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),Ke.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):M(Ze,We,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ue})}catch(Se){if(K&&L(K.directory,K.tabId,K.id)){const{directory:Ve,tabId:Xe,id:nt}=K;F(Ve,te.id,nt),T(Ve,Xe,"exited",{expectedExecutionId:nt}),O(Ve,Xe,{type:"project-action",actionId:te.id,executionId:null})}if(Se instanceof Error&&Se.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Se instanceof Error&&(Se.message==="COMMAND_MODE_UNSUPPORTED"||Se.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Ke.error(o("projectActions.error.failedToCreateTerminalSession"));return}Ke.error(Se instanceof Error?Se.message:o("projectActions.error.failedToRunAction"))}finally{ie.current.delete(me)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,he,p,Me,i,m,f,G,k,x,ce,j,U,ae,d.isVSCode,ee,L,F,de,Y,S,B,W,R,T,O,M,A,J?.id,o,a]),Q=c.useCallback(async te=>{const me=an(ee(te),te.id),De=U[me];De&&await ph({terminal:a,sessionId:De.sessionId,isExecutionStillCurrent:()=>L(De.directory,De.tabId,De.executionId),markStopping:()=>{T(De.directory,De.tabId,"stopping",{expectedExecutionId:De.executionId})},restoreRunning:()=>{T(De.directory,De.tabId,"running",{expectedExecutionId:De.executionId})},clearSession:()=>{A(De.directory,De.tabId,null,{expectedExecutionId:De.executionId})},finalizeExit:()=>{T(De.directory,De.tabId,"exited",{expectedExecutionId:De.executionId}),O(De.directory,De.tabId,{type:"project-action",actionId:De.actionId,executionId:null}),F(De.directory,De.actionId,De.executionId)}})},[F,ee,L,U,T,O,A,a]),Ce=c.useCallback(()=>{const te=pe??Fe[0];if(!te)return;const me=an(ee(te),te.id),De=U[me];if(De?.status!=="stopping"){if(De){Q(te);return}Ae(te)}},[Fe,ee,Ae,U,pe,Q]),Be=c.useCallback(async te=>{if(te.source==="shared"&&J){const me=D.current?.trust.trusted?D.current:await Al(J);if(D.current=me,!await sp(J,me))return;D.current={...me,trust:{...me.trust,trusted:!0}}}await Ae(te)},[Ae,J]),Le=c.useCallback((te,me=!1)=>{if(X(te.id),!me){Be(te);return}const De=an(ee(te),te.id),K=U[De];if(K?.status!=="stopping"){if(K){Q(te);return}Be(te)}},[ee,Be,U,Q]),Je=c.useCallback(()=>{J?.id&&(g(J.id),w("projects"),h(!0))},[h,w,g,J?.id]),ot=pe??Fe[0]??null,et=ot?U[an(ee(ot),ot.id)]:null,it=Mt(te=>et?te.getDirectoryState(et.directory)?.tabs.find(me=>me.id===et.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&m||!J||!G)return null;const ht=pe??Fe[0]??null;if(!ht)return null;const st=Ti(ht),mt=an(ee(ht),ht.id),kt=U[mt],Pe=kt?.status==="stopping",Ge=kt?.status==="waiting-for-preview",at=!!(kt&&it),ze=()=>{!kt||!it||j(kt.directory,it)},ft=ht.id===cn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",disabled:Z||Pe,className:Ee("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:Ce,"aria-label":kt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:Pe||Ge?s.jsx(_,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):kt?s.jsx(_,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(_,{name:st,className:"h-5 w-5"})})}),ft?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),at?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:ze,children:s.jsx(_,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(_,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(_s,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ht,{className:"flex items-center gap-2",onClick:Je,children:[s.jsx(_,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Es,{}),Fe.map(te=>{const me=Ti(te),De=an(ee(te),te.id),K=U[De],Se=!!K,Ve=K?.status==="stopping";return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{Le(te,!0)},children:[s.jsx(_,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:te.name}),te.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Ve||K?.status==="waiting-for-preview"?s.jsx(_,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Se?s.jsx(_,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},te.id)})]})]})]}):s.jsxs("div",{className:Ee("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ce,disabled:Z||Pe,className:Ee("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":kt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Pe||Ge?s.jsx(_,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):kt?s.jsx(_,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(_,{name:st,className:"h-4 w-4"})})})}),ft?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),at?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ze,className:Ee(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(_,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(_s,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ht,{className:"flex items-center gap-2",onClick:Je,children:[s.jsx(_,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Es,{}),Fe.map(te=>{const me=Ti(te),De=an(ee(te),te.id),K=U[De],Se=!!K,Ve=K?.status==="stopping";return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{Le(te,!0)},children:[s.jsx(_,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:te.name}),te.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Ve||K?.status==="waiting-for-preview"?s.jsx(_,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Se?s.jsx(_,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},te.id)})]})]})]})},zr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},zb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=zr(n??"");if(i){const o=su(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Wb(){const t=Ut(x=>x.projects),e=Ut(x=>x.activeProjectId),n=rt(x=>x.availableWorktreesByProject),r=rt(x=>x.currentSessionId),i=np(r??null),o=rt(x=>r?x.worktreeMetadata.get(r)?.path??"":""),l=rt(x=>x.newSessionDraft?.open?zr(x.newSessionDraft.bootstrapPendingDirectory??x.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>zr(o||""),[o]),d=c.useMemo(()=>{const x=typeof i?.directory=="string"?i.directory:"";return zr(x||"")},[i?.directory]),u=a||d||l,m=c.useMemo(()=>zb({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>zr(u||m?.path||""),[u,m?.path]),p=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),y=c.useRef(null);return c.useEffect(()=>{p&&f&&(y.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:y.current,[p,f])}const Kb=({transform:t})=>({...t,y:0}),Vb={Item:Ht,Separator:Es},Ub={Item:({className:t,...e})=>s.jsx(Zu,{className:Ee(iu,t),...e}),Separator:({className:t,...e})=>s.jsx(Ju,{className:Ee(ou,t),...e})},Hb=t=>{const e=tt.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:m}=t,{t:f}=Nt(),[p,y]=c.useState(!1),[x,k]=c.useState(!1),[w,h]=c.useState(!1);let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:j,listeners:b,setNodeRef:S,transform:C,transition:v,isDragging:E}=mi(g);let R;e[2]!==f||e[3]!==n.session.title?(R=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=R):R=e[4];const A=R,O=!i&&(p||x),B=n.id;let T;e[5]!==n.session?(T=As(n.session),e[5]=n.session,e[6]=T):T=e[6];const M=Oa(B,T),L=nu(n.id),$=ru(n.id)>0&&!r&&!L,P=L||$;let D;e[7]!==L||e[8]!==f?(D=f(L?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=L,e[8]=f,e[9]=D):D=e[9];const I=D;let X;e[10]!==d||e[11]!==w||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(X=we=>({session:n.session,open:p||w,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:we}),e[10]=d,e[11]=w,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=X):X=e[16];const Z=X;let ne;e[17]!==C?(ne=hi.Translate.toString(C),e[17]=C,e[18]=ne):ne=e[18];let ue;e[19]!==ne||e[20]!==v?(ue={transform:ne,transition:v},e[19]=ne,e[20]=v,e[21]=ue):ue=e[21];const se=E&&"z-10 opacity-60";let xe;e[22]!==se?(xe=Ee("session-tab-slot flex h-7 w-44 shrink-0 touch-none",se),e[22]=se,e[23]=xe):xe=e[23];const ie=r?"true":"false";let Re;e[24]!==r?(Re=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Re):Re=e[25];let be;e[26]!==u?(be=we=>u?.(we),e[26]=u,e[27]=be):be=e[27];let fe;e[28]!==m||e[29]!==I||e[30]!==r||e[31]!==M||e[32]!==L||e[33]!==Z||e[34]!==p||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==O||e[39]!==a||e[40]!==P||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==A?(fe=s.jsx(ef,{render:we=>s.jsxs("div",{...we,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),o(n))},onAuxClick:Te=>{Te.button===1&&(Te.preventDefault(),l(n.id))},"data-controls-open":O?"true":"false",className:Ee("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":Ee("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",O&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Ee("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",O&&"pr-10"),children:[s.jsx("div",{className:Ee("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?m:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:A})})}),M?s.jsx(_,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):P?s.jsx(Ba,{state:L?"running":"unread",label:I,className:Ee("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",O&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:qb,onPointerDown:Yb,className:Ee("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",O&&"flex opacity-100"),children:[s.jsxs(Ls,{open:p,onOpenChange:Te=>{y(Te),Te&&k(!0)},onOpenChangeComplete:Te=>{Te||k(!1),u?.(Te)},children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"more",className:"size-4"})})}),s.jsx(_s,{align:"start",className:"min-w-[190px]",children:a(Z(Vb))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"size-4"})})]})]})}),e[28]=m,e[29]=I,e[30]=r,e[31]=M,e[32]=L,e[33]=Z,e[34]=p,e[35]=l,e[36]=u,e[37]=o,e[38]=O,e[39]=a,e[40]=P,e[41]=i,e[42]=f,e[43]=n,e[44]=A,e[45]=fe):fe=e[45];let ke,H;e[46]===Symbol.for("react.memo_cache_sentinel")?(ke={color:"var(--surface-elevated-foreground)"},H=Ee(Qi,"min-w-[190px]"),e[46]=ke,e[47]=H):(ke=e[46],H=e[47]);let J;e[48]!==Z||e[49]!==a?(J=a(Z(Ub)),e[48]=Z,e[49]=a,e[50]=J):J=e[50];let ce;e[51]!==J?(ce=s.jsx(ca,{children:s.jsx(da,{className:"app-region-no-drag z-50",children:s.jsx(ua,{"data-slot":"dropdown-menu-content",style:ke,className:H,children:J})})}),e[51]=J,e[52]=ce):ce=e[52];let je;e[53]!==w||e[54]!==be||e[55]!==fe||e[56]!==ce?(je=s.jsxs(tf,{open:w,onOpenChange:h,onOpenChangeComplete:be,children:[fe,ce]}),e[53]=w,e[54]=be,e[55]=fe,e[56]=ce,e[57]=je):je=e[57];let G;return e[58]!==j||e[59]!==b||e[60]!==S||e[61]!==xe||e[62]!==ie||e[63]!==Re||e[64]!==je||e[65]!==ue?(G=s.jsx("div",{ref:S,style:ue,className:xe,"data-active":ie,...Re,...j,...b,children:je}),e[58]=j,e[59]=b,e[60]=S,e[61]=xe,e[62]=ie,e[63]=Re,e[64]=je,e[65]=ue,e[66]=G):G=e[66],G},Gb=t=>{const e=tt.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=Nt(),d=co(Qb),u=co(Xb),m=co(Jb),f=co(Zb),p=rt(ey),y=rt(ty),x=vs(sy);let k,w;e[0]!==p||e[1]!==u?(k=()=>{p&&u(p)},w=[p,u],e[0]=p,e[1]=u,e[2]=k,e[3]=w):(k=e[2],w=e[3]),c.useEffect(k,w);let h;if(e[4]!==x){h=new Map;for(const he of x)h.set(he.id,he);e[4]=x,e[5]=h}else h=e[5];const g=h;let j;if(e[6]!==g||e[7]!==d){j=[];for(const he of d){const re=g.get(he);re&&j.push({id:he,session:re})}e[6]=g,e[7]=d,e[8]=j}else j=e[8];const b=j;let S;e[9]!==y?(S=he=>{y(he.id,As(he.session))},e[9]=y,e[10]=S):S=e[10];const C=S,v=ny;let E;e[11]!==m||e[12]!==p||e[13]!==C||e[14]!==b?(E=he=>{if(m(he),p&&p!==he){const re=b.find(ge=>ge.id===he);re&&C(re)}},e[11]=m,e[12]=p,e[13]=C,e[14]=b,e[15]=E):E=e[15];const R=E;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[16]=A):A=e[16];let O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{delay:200,tolerance:6}},e[17]=O):O=e[17];const B=li(Pn(di,A),Pn(ci,O));let T;e[18]!==f?(T=he=>{const{active:re,over:ge}=he;ge&&re.id!==ge.id&&f(String(re.id),String(ge.id))},e[18]=f,e[19]=T):T=e[19];const M=T,L=c.useRef(null);let W;e[20]===Symbol.for("react.memo_cache_sentinel")?(W={left:!1,right:!1},e[20]=W):W=e[20];const[$,P]=c.useState(W);let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{const he=L.current;if(!he)return;const re=he.scrollLeft>2,ge=he.scrollLeft+he.clientWidth<he.scrollWidth-2;P(q=>q.left===re&&q.right===ge?q:{left:re,right:ge})},e[21]=D):D=e[21];const I=D;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{I();const he=L.current;if(!he||!globalThis.ResizeObserver)return;const re=new ResizeObserver(I);return re.observe(he),()=>re.disconnect()},e[22]=X):X=e[22];let Z;e[23]!==b.length?(Z=[I,b.length],e[23]=b.length,e[24]=Z):Z=e[24],c.useEffect(X,Z);let ne;e[25]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=ne):ne=e[25];let ue;e[26]!==p?(ue=[p],e[26]=p,e[27]=ue):ue=e[27],c.useEffect(ne,ue);const se=$.left&&$.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":$.left?"linear-gradient(to right, transparent, black 24px)":$.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let xe;e[28]!==b?(xe=b.map(ry),e[28]=b,e[29]=xe):xe=e[29];const ie=xe;let Re;e[30]!==p||e[31]!==b?(Re=!p||!b.some(he=>he.id===p),e[30]=p,e[31]=b,e[32]=Re):Re=e[32];const be=Re;let fe;e[33]!==a?(fe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=fe):fe=e[34];let ke;e[35]!==se?(ke=se?{maskImage:se,WebkitMaskImage:se}:void 0,e[35]=se,e[36]=ke):ke=e[36];let H;e[37]===Symbol.for("react.memo_cache_sentinel")?(H=[Kb],e[37]=H):H=e[37];let J;e[38]!==o||e[39]!==p||e[40]!==R||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==b?(J=b.map(he=>s.jsx(Hb,{tab:he,isActive:he.id===p,suppressControls:he.id===p&&l,onSelect:C,onClose:v,renderMenu:n,closeOtherTabs:R,onMenuOpenChangeComplete:r,children:he.id===p?o:null},he.id)),e[38]=o,e[39]=p,e[40]=R,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=b,e[46]=J):J=e[46];let ce;e[47]!==J||e[48]!==ie?(ce=s.jsx(Ja,{items:ie,strategy:Qx,children:J}),e[47]=J,e[48]=ie,e[49]=ce):ce=e[49];let je;e[50]!==M||e[51]!==B||e[52]!==ce?(je=s.jsx(ui,{sensors:B,collisionDetection:fi,modifiers:H,onDragEnd:M,children:ce}),e[50]=M,e[51]=B,e[52]=ce,e[53]=je):je=e[53];let G;e[54]!==o||e[55]!==be?(G=be?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=be,e[56]=G):G=e[56];let we;e[57]!==ke||e[58]!==je||e[59]!==G?(we=s.jsxs("div",{ref:L,onScroll:I,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:ke,children:[je,G]}),e[57]=ke,e[58]=je,e[59]=G,e[60]=we):we=e[60];let Te;return e[61]!==fe||e[62]!==we?(Te=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":fe,children:we}),e[61]=fe,e[62]=we,e[63]=Te):Te=e[63],Te};function qb(t){return t.stopPropagation()}function Yb(t){return t.stopPropagation()}function Qb(t){return t.tabIds}function Xb(t){return t.ensureTab}function Jb(t){return t.closeOtherTabs}function Zb(t){return t.reorderTabs}function ey(t){return t.currentSessionId}function ty(t){return t.setCurrentSession}function sy(t){return t.activeSessions}function ny(t){rp(t)}function ry(t){return t.id}const lf=async t=>{const{entry:e,session:n}=t,r=Qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(op(e.action)&&ip(e.guest,"conversation"))){await Pl(e,Dl(e.action.id,i),t.t,r);return}let l=!1;const a=Cr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Pl(e,Dl(e.action.id,i,d),t.t,r)}};function ma(t){const e=tt.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=Nt(),{pending:a,disabled:d,hint:u,run:m}=yh(n,r,i),f=a?"loader-4":"ai-generate-2",p=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let y;e[0]!==f||e[1]!==p?(y=s.jsx(_,{name:f,className:p}),e[0]=f,e[1]=p,e[2]=y):y=e[2];let x;e[3]!==l?(x=l("sessions.aiRename.action"),e[3]=l,e[4]=x):x=e[4];let k;e[5]!==o||e[6]!==d||e[7]!==m||e[8]!==y||e[9]!==x?(k=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:m,className:"w-full",children:[y,x]})})}),e[5]=o,e[6]=d,e[7]=m,e[8]=y,e[9]=x,e[10]=k):k=e[10];let w;e[11]!==u?(w=s.jsx(jt,{side:"right",children:u}),e[11]=u,e[12]=w):w=e[12];let h;return e[13]!==k||e[14]!==w?(h=s.jsxs(vt,{children:[k,w]}),e[13]=k,e[14]=w,e[15]=h):h=e[15],h}const ha=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class cf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const pi=no(()=>({pendingSessionIds:new Set})),df=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],pi(n)},ec=(t,e)=>{pi.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},oy=async(t,e)=>{try{const d=(await fp(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=xt(t),r=xt(e)??e,i=rt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>xt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},tc=t=>{for(const e of t){const n=lp(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class iy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const ay=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new iy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},ly=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(cp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await au(o,n,e),rt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i},sc=async(t,e,n)=>{try{await cu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},nc=async(t,e)=>{const n=e?[t,e]:[t];try{await Fa(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},uf=async(t,e)=>{if(pi.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");ec(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,rt.getState().getWorktreeMetadata(a.id)]));tc(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){tc(n.slice(a));try{await au(d,t.sourceDirectory,i.directory)}catch(u){throw ap(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&rt.getState().setWorktreeMetadata(d.id,Il(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await ly(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await nc(t.sourceDirectory,i?.directory),u.length>0)throw ay(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new cf(d):d}return rt.getState().setWorktreeMetadata(t.root.id,Il(i.metadata)),await nc(t.sourceDirectory,i.directory),i.directory}finally{ec(t.root.id,!1)}},cy=async t=>{const e=xt(t.sourceDirectory)??t.sourceDirectory,n=xt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return uf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},dy=async t=>uf(t,async()=>{const e=Xi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await lu(t.sourceDirectory)?await oy(t.sourceDirectory,e.path):null,r=await dp(e,n?{startRef:n}:{});try{await up(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return sc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>sc(e,r,i)}}),uy=t=>{(t.kind==="existing"?cy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):dy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>Ke.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));Ke.error(t.messages.failure,{description:r instanceof cf?t.messages.outcomeUnknown:r.message})})},pa=t=>{pi.getState().pendingSessionIds.has(t.root.id)||uy(t)},Vo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",fy=c.memo(function(e){const n=tt.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,p=m===void 0?!1:m;if(!f)return null;const y=a??Vo,x=p&&"bg-interactive-selection text-interactive-selection-foreground";let k;n[0]!==y||n[1]!==x?(k=Ee(y,x),n[0]=y,n[1]=x,n[2]=k):k=n[2];const w=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==w?(h=s.jsx(_,{name:d,className:w}),n[3]=d,n[4]=w,n[5]=h):h=n[5];let g;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==k||n[10]!==h?(g=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:k,children:h})}),n[6]=o,n[7]=l,n[8]=p,n[9]=k,n[10]=h,n[11]=g):g=n[11];let j;n[12]!==i?(j=s.jsx(jt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=j):j=n[13];let b;return n[14]!==g||n[15]!==j?(b=s.jsxs(vt,{children:[g,j]}),n[14]=g,n[15]=j,n[16]=b):b=n[16],b}),my=c.memo(function(e){const n=tt.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:m,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:y}=e,{t:x}=Nt();let k;n[0]!==d||n[1]!==a?(k=B=>{a(B),B&&d()},n[0]=d,n[1]=a,n[2]=k):k=n[2];let w;n[3]!==i||n[4]!==r||n[5]!==x?(w=r?x("header.services.openWithCurrent",{current:i}):x("header.services.open"),n[3]=i,n[4]=r,n[5]=x,n[6]=w):w=n[6];const h=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let g;n[7]!==h?(g=Ee(Vo,h),n[7]=h,n[8]=g):g=n[8];let j;n[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(_,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=j):j=n[9];let b;n[10]!==i||n[11]!==r?(b=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=b):b=n[12];let S;n[13]!==w||n[14]!==g||n[15]!==b?(S=s.jsx(St,{asChild:!0,children:s.jsx(Fs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":w,className:g,children:[j,b]})})}),n[13]=w,n[14]=g,n[15]=b,n[16]=S):S=n[16];let C;n[17]!==i||n[18]!==u||n[19]!==x?(C=x("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=x,n[20]=C):C=n[20];let v;n[21]!==C?(v=s.jsx(jt,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=v):v=n[22];let E;n[23]!==S||n[24]!==v?(E=s.jsxs(vt,{children:[S,v]}),n[23]=S,n[24]=v,n[25]=E):E=n[25];let R;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==y||n[30]!==f||n[31]!==p||n[32]!==m||n[33]!==a||n[34]!==x?(R=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:x("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:m?.available?x("header.services.remoteUpdate.available",{version:m.version||""}):f?x("header.services.remoteUpdate.checking"):p||x("header.services.remoteUpdate.upToDate")})]}),m?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:y,children:x("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(mp,{embedded:!0,open:l,onOpenChange:py,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=y,n[30]=f,n[31]=p,n[32]=m,n[33]=a,n[34]=x,n[35]=R):R=n[35];let A;n[36]!==R?(A=s.jsx(_s,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:R}),n[36]=R,n[37]=A):A=n[37];let O;return n[38]!==l||n[39]!==k||n[40]!==E||n[41]!==A?(O=s.jsxs(Ls,{open:l,onOpenChange:k,children:[E,A]}),n[38]=l,n[39]=k,n[40]=E,n[41]=A,n[42]=O):O=n[42],O}),kn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},rc=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,hy=()=>{Ts("ui.header.render");const{t}=Nt(),e=Ne(N=>N.isSidebarOpen),n=Ne(N=>N.openContextOverview),r=Ne(N=>N.closeContextPanel),i=Ne(N=>N.shortcutOverrides),o=Ne(N=>N.sessionTabsEnabled),l=rt(N=>N.getContextUsage),a=rt(N=>!!N.newSessionDraft?.open),d=rt(N=>N.currentSessionId),u=hp(d??""),m=pp(d??""),f=df(d??""),p=vs(ar(c.useCallback(N=>{if(!d)return null;const ye=[...N.activeSessions,...N.archivedSessions].find(lt=>lt.id===d);if(!ye)return null;const $e=ye;return{title:ye.title??null,directory:$e.directory??null,created:ye.time?.created??null,slug:$e.slug??null,parentId:ye.parentID??null}},[d]))),y=Ut(ar(N=>{if(!N.activeProjectId)return null;const ye=N.projects.find($e=>$e.id===N.activeProjectId);return ye?{id:ye.id,path:ye.path,label:ye.label}:null})),x=c.useMemo(()=>{if(!y)return null;const N=y.label?.trim();if(N)return N;const ye=y.path.split(/[\\/]/).filter(Boolean);return ye[ye.length-1]??null},[y]),k=hr(N=>N.loadSettings),{isMobile:w}=$n(),h=c.useRef(null),[g,j]=c.useState(()=>typeof window>"u"?!1:xn()),b=c.useMemo(()=>qr(),[]),S=du(),[C,v]=c.useState(!1),E=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:R,side:A}=qu(),O=c.useMemo(()=>{if(typeof window>"u")return null;const N=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof N=="number"&&Number.isFinite(N)&&N>0)return N;if(typeof navigator>"u")return null;const ye=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ye)return null;const $e=Number.parseInt(ye[1],10),lt=Number.parseInt(ye[2],10);return Number.isNaN($e)?null:$e===10?lt:$e},[]);ut.useEffect(()=>{typeof window>"u"||j(xn())},[]);const{context:B,output:T}=gp(d),M=l(B,T),[L,W]=c.useState(null),$=!d||u;ut.useEffect(()=>{if(!d){W(N=>N===null?N:null);return}if(M){W(N=>xp(N,M)?N:M);return}$&&W(N=>N===null?N:null)},[M,d,$]);const[P,D]=c.useState(!1),[I,X]=c.useState("Local"),[Z,ne]=c.useState(!0),[ue,se]=c.useState(!1),[xe,ie]=c.useState(null),[Re,be]=c.useState(!1),[fe,ke]=c.useState(null),H=c.useMemo(()=>_n(),[]),J=Ne(N=>N.workStatusPanelVisible),ce=Ne(N=>N.workStatusPanelEnabled),je=Ne(N=>N.setWorkStatusPanelEnabled),G=Ne(N=>N.workStatusPanelFits),we=Ne(N=>N.workStatusOverlayOpen),Te=Ne(N=>N.setWorkStatusOverlayOpen),re=ce&&G||we,ge=c.useCallback(()=>{if(ce&&!G){Te(!we);return}je(!ce)},[Te,je,we,ce,G]),q=!H&&!J&&!!L,z=c.useCallback(async()=>{if(!(typeof window>"u"||!g))try{if(Zo()){X("Local"),ne(!0);return}ne(!1);const N=await Bd(),ye=Lm(),$e=$m([zm(ye),...N.hosts]);if($e.id===Wm){X("Local"),ne(!0);return}X(Fd($e.label.trim()||"Instance"))}catch{X("Local"),ne(!0)}},[g]);ut.useEffect(()=>(z(),Cr(()=>{z()})),[z]);const ee=c.useCallback(async()=>{if(Z){ie(null),ke(null);return}be(!0),ke(null);try{const N=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),ye=await bs(`/api/openchamber/update-check?${N.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!ye.ok)throw new Error(`Server responded with ${ye.status}`);const $e=await ye.json();ie({available:$e.available??!1,version:$e.version,currentVersion:$e.currentVersion??"unknown",body:$e.body,nextSuggestedCheckInSec:typeof $e.nextSuggestedCheckInSec=="number"?$e.nextSuggestedCheckInSec:void 0,packageManager:$e.packageManager,updateCommand:$e.updateCommand})}catch(N){ie(null),ke(N instanceof Error?N.message:t("header.services.remoteUpdate.error"))}finally{be(!1)}},[Z,t]);c.useEffect(()=>{ie(null),ke(null),se(!1)},[Z,I]),c.useEffect(()=>{if(!g||Z)return;const N=3e3,ye=3600*1e3;let $e=!1,lt=null;const Pt=Dt=>{lt=window.setTimeout(()=>{if($e||typeof document<"u"&&document.visibilityState!=="visible"){Pt(ye);return}ee().finally(()=>{$e||Pt(ye)})},Dt)};return Pt(N),()=>{$e=!0,lt!==null&&window.clearTimeout(lt)}},[ee,Z,I,g]);const de=c.useCallback(()=>{if(xe?.available){se(!0);return}ee()},[ee,xe?.available]);bp(),c.useEffect(()=>{k()},[k]);const Y=d?p??null:null,U=c.useRef(null),[F,V]=c.useState(0);c.useEffect(()=>{if(!d){U.current&&(U.current=null,V(lt=>lt+1));return}if(Y){U.current={sessionId:d,session:Y,expiresAt:Date.now()+2e3};return}const N=U.current;if(!N||N.sessionId!==d)return;const ye=N.expiresAt-Date.now();if(ye<=0){U.current=null,V(lt=>lt+1);return}const $e=window.setTimeout(()=>{U.current?.sessionId===d&&(U.current=null),V(lt=>lt+1)},ye);return()=>{window.clearTimeout($e)}},[d,Y]);const oe=(()=>{if(Y)return Y;if(!d)return null;const N=U.current;return N&&N.sessionId===d&&N.expiresAt>Date.now()?N.session:null})(),ae=rt(N=>d?N.worktreeMetadata.get(d)?.path??"":""),pe=rt(N=>d?N.worktreeMetadata.get(d)?.branch?.trim()??null:null),le=uu(N=>d?N.getAttachment(d):void 0),_e=c.useMemo(()=>le?yp(le,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,le]),Fe=c.useMemo(()=>le?le.legacy?"legacy":le.degraded?"degraded":le.worktreeStatus==="pending"?"pending":le.worktreeStatus==="missing"?"missing":le.worktreeStatus==="invalid"?"invalid":le.attentionReason?"attention":null:null,[le]),Me=c.useMemo(()=>kn(ae||""),[ae]),Ae=c.useMemo(()=>{const N=typeof oe?.directory=="string"?oe.directory:"";return kn(N||"")},[oe?.directory]),Q=Oa(d??"",Ae),Ce=rt(N=>N.newSessionDraft?.open?kn(N.newSessionDraft.bootstrapPendingDirectory??N.newSessionDraft.directoryOverride??""):""),Be=rt(N=>N.newSessionDraft.target),Le=rt(N=>N.newSessionDraft.selectedProjectId),Je=rt(N=>N.currentSessionDirectory),ot=os(N=>N.homeDirectory),et=c.useMemo(()=>Me||Ae||Ce,[Ce,Ae,Me]),it=Ne(c.useCallback(N=>{const ye=kn(et||"");return ye?rc(N.contextPanelByDirectory[ye]):null},[et])),ht=rt(N=>{const ye=kn(Me||Ae||"");if(!ye)return null;for(const $e of N.availableWorktreesByProject.values()){const Pt=$e.find(Dt=>kn(Dt.path)===ye)?.branch?.trim();if(Pt)return Pt}return null}),mt=wp(et||null)||pe||ht,kt=a?Be==="chat":vp(Ae||Je,ot),Pe=!kt&&!J&&!!(x||mt||!a&&Fe),Ge=c.useMemo(()=>{if(!d)return x??"OpenChamber";const N=oe?.title?.trim();return N&&N.length>0?N:"Untitled Session"},[x,oe?.title,d]),at=fu(),ze=rt(N=>N.updateSessionTitle),ft=rt(N=>N.archiveSessions),te=rt(N=>N.deleteSessions),[me,De]=c.useState(!1),[K,Se]=c.useState(!1),Ve=c.useRef(null),[Xe,nt]=c.useState(""),[Ze,gt]=c.useState(null),We=c.useRef(null),Et=c.useCallback(()=>{d&&(nt(oe?.title?.trim()||Ge),De(!0))},[oe?.title,d,Ge]),Ft=c.useRef(Et);Ft.current=Et;const Ie=c.useCallback(N=>{N&&(N.focus(),N.select())},[]);c.useEffect(()=>{if(Se(!1),gt(null),d&&Ve.current===d){Ve.current=null,Ft.current();return}De(!1),nt("")},[d]);const yt=c.useCallback(async()=>{if(!d)return;const N=Xe.trim();N&&N!==oe?.title?.trim()&&await ze(d,N),De(!1)},[oe?.title,d,Xe,ze]);c.useEffect(()=>{if(!me)return;const N=ye=>{const $e=ye.target;(!$e||!We.current?.contains($e))&&yt()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[me,yt]);const At=c.useCallback(N=>{N&&cr(N).then(ye=>{Ke[ye.ok?"success":"error"](t(ye.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(t("sessions.sidebar.session.copyId.error")))},[t]),He=c.useCallback(async()=>{if(!d||!et){Ke.error(t("sessions.sidebar.session.export.nothingToExport"));return}const N=await at({sessionID:d,directory:et}).catch(()=>null);if(!N){Ke.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(N.length===0){Ke.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ye=mu(N,oe?.title??null),$e=hu(oe?.title??null);await pu(ye,$e)||gu(ye,$e),Ke.success(t("sessions.sidebar.session.export.success"))},[oe?.title,d,at,et,t]),Ue=xu(),ve=c.useMemo(()=>bu(Ue),[Ue]),Qe=c.useCallback(N=>{d&&lf({entry:N,t,session:{id:d,title:oe?.title,directory:Ae??et},loadRecords:async()=>{if(!et)return null;try{return await at({sessionID:d,directory:et})}catch{return null}},onLoadFailed:()=>Ke.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[oe?.title,d,at,et,Ae,t]),qe=c.useCallback(N=>ve.map(ye=>s.jsxs(N,{onClick:()=>Qe(ye),children:[s.jsx(to,{icon:ye.icon,iconSrc:ye.iconSrc,className:"mr-1 size-4"}),ye.action.label]},`${ye.guest.id}:${ye.action.id}`)),[ve,Qe]),Ye=m?.type==="busy"||m?.type==="retry",dt=c.useCallback(()=>{if(!d||!Ae||Ye||f)return;const N=vs.getState().activeSessions,ye=N.find(Pt=>Pt.id===d);if(!ye)return;const $e=[],lt=[d];for(let Pt=0;Pt<lt.length;Pt+=1){const Dt=lt[Pt];for(const pt of N)pt.parentID===Dt&&($e.push(pt),lt.push(pt.id))}pa({kind:"quick",root:ye,descendants:$e,sourceDirectory:Ae,messages:ha(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Ye,f,Ae,t]),Ot=c.useCallback(async()=>{if(!Ze)return;const N=Ze.action,ye=[Ze.sessionId,...Vd(Ze.sessionId,[],N==="delete")];if(gt(null),(N==="archive"?await ft(ye):await te(ye)).failedIds.length>0){Ke.error(t(N==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Ke.success(t(N==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ft,te,Ze,t]),zt=Ne(N=>N.openGuestPageId),Kt=_a(N=>N.guests.find(ye=>ye.id===zt)),Gt=Ne(N=>N.isScheduledTasksDialogOpen),Bt=Ne(N=>N.isArchivePageOpen),Jt=Ne(N=>N.isUsageStatsPageOpen),Vt=Ne(N=>N.worktreesPageProjectId),Wt=Ne(N=>N.isMultiRunLauncherOpen),_t=Ut(N=>{if(!Vt)return null;const ye=N.projects.find($e=>$e.id===Vt);return ye?.label?.trim()||ye?.path?.split("/").pop()||null}),Xt=c.useMemo(()=>Kt?{title:Kt.pageTitle??Kt.name,subtitle:null}:Gt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Bt?{title:t("sessions.archivePage.title"),subtitle:null}:Jt?{title:t("usageStats.title"),subtitle:null}:Vt?{title:t("sessions.worktreesPage.title",{project:_t??""}),subtitle:null}:Wt?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[Kt,Bt,Wt,Gt,Jt,t,Vt,_t]),Ct=c.useMemo(()=>kn(et||y?.path||""),[y?.path,et]),Tt=Wb(),is=La(N=>N.planModeEnabled),$s=rt(N=>N.isSessionPlanAvailable),cs=is&&d?$s(d):!1,ps=c.useRef("");c.useEffect(()=>{if(!is||!d)return;const N=`${d||"none"}:${Ae||"none"}:${oe?.created||0}:${oe?.slug||"none"}`;ps.current!==N&&(ps.current=N)},[is,cs,oe?.slug,oe?.created,d,Ae]);const fn=c.useCallback(()=>{Fn("desktop_open_draft_mini_chat_window",{directory:kt?"":Ce,projectId:kt?null:Le,apiBaseUrl:Dn(),clientToken:Yr()}).catch(N=>{console.warn("[header] failed to open draft mini chat window",N)})},[Ce,Le,kt]),nn=c.useCallback(()=>{if(a){fn();return}d&&Fn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ae||kn(Je||"")||Me,apiBaseUrl:Dn(),clientToken:Yr()}).catch(N=>{console.warn("[header] failed to open session mini chat window",N)})},[d,fn,a,Je,Ae,Me]),mn=c.useCallback(()=>{const N=kn(et||"");if(!N)return;const ye=Ne.getState().contextPanelByDirectory[N];if(rc(ye)==="context"){r(N);return}n(N)},[r,n,et]),vn=it==="context",ks=Vo,rn=c.useMemo(()=>g&&E&&!C?"88px":S?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||R)&&!H?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,C,E,S,H,R]);ut.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",rn)},[rn]);const zs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Ws=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ut.useEffect(()=>{if(!g||!E){v(!1);return}let N=!1;const ye=async()=>{try{const lt=await Fn("desktop_is_window_fullscreen");N||v(lt===!0)}catch{N||v(!1)}},$e=()=>{ye()};return ye(),window.addEventListener("openchamber:window-resized",$e),()=>{N=!0,window.removeEventListener("openchamber:window-resized",$e)}},[g,E]);const as=c.useMemo(()=>!g||!E||O===null?"":O>=26?"h-12":O<=15?"h-14":"",[g,E,O]),Gs=c.useMemo(()=>{if(!(g&&!R||H)&&!(R&&A==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[g,H,R,A]),gs=c.useCallback(()=>{if(typeof document>"u")return;const N=h.current?.getBoundingClientRect().height;N&&document.documentElement.style.setProperty("--oc-header-height",`${N}px`)},[]);ut.useEffect(()=>{if(typeof window>"u")return;gs();const N=h.current;if(!N||typeof ResizeObserver>"u")return()=>{};let ye=0;const $e=()=>{ye||(ye=requestAnimationFrame(()=>{ye=0,gs()}))},lt=new ResizeObserver($e);return lt.observe(N),window.addEventListener("resize",$e),window.addEventListener("orientationchange",$e),()=>{ye&&cancelAnimationFrame(ye),lt.disconnect(),window.removeEventListener("resize",$e),window.removeEventListener("orientationchange",$e)}},[gs]),ut.useEffect(()=>{gs()},[gs,w,as]);const us=c.useCallback(async N=>{const ye=N.target;ye.closest(".app-region-no-drag")||ye.closest("button, a, input, select, textarea")||N.button===0&&g&&await Km()},[g]),qs=c.useCallback(N=>sr(so(N,i)),[i]);Sp({rename_current_session:()=>{if(!d||w)return!1;Et()},toggle_services_menu:()=>{if(P){D(!1);return}D(!0),z()}});const Sn=s.jsxs(s.Fragment,{children:[Tt?s.jsx($b,{projectRef:Tt.projectRef,directory:Tt.directory,className:"mr-2"}):null,s.jsx(hb,{directory:Ct,className:"mr-1"}),g?s.jsx(my,{isDesktopApp:g,currentInstanceLabel:I,currentInstanceIsLocal:Z,isDesktopServicesOpen:P,setIsDesktopServicesOpen:D,refreshCurrentInstanceLabel:z,shortcutLabel:qs,remoteUpdateInfo:xe,remoteUpdateChecking:Re,remoteUpdateError:fe,onOpenRemoteUpdate:de}):null]}),Ys=b&&(a||!!d),hn=c.useCallback(({session:N,open:ye,isActive:$e,select:lt,closeOtherTabs:Pt,components:Dt})=>{const{Item:pt,Separator:qt}=Dt,wt=$e&&!H&&!kt&&oe&&!oe.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(pt,{onClick:()=>{$e||lt(),Ve.current=N.id},children:[s.jsx(_,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ma,{sessionID:N.id,directory:N.directory,open:ye,Item:pt}),s.jsxs(pt,{onClick:()=>At(N.id),children:[s.jsx(_,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(qt,{}),$e?s.jsxs(pt,{onClick:()=>{He()},children:[s.jsx(_,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,$e?qe(pt):null,wt?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(pt,{disabled:!Ae||Ye||f,onClick:dt,className:"w-full",children:[s.jsx(_,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ye?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(qt,{}),s.jsxs(pt,{onClick:Pt,children:[s.jsx(_,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(qt,{}),s.jsxs(pt,{onClick:()=>gt({action:"archive",sessionId:N.id}),children:[s.jsx(_,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(pt,{className:"text-destructive focus:text-destructive",onClick:()=>gt({action:"delete",sessionId:N.id}),children:[s.jsx(_,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[At,oe,He,kt,Ye,f,H,dt,qe,Ae,t]),on=()=>s.jsxs("div",{onMouseDown:us,className:Ee("app-region-drag relative flex h-12 select-none items-center",R&&A==="right"?"pr-0":"pr-3",as),style:Gs,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:zs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Ws}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Xt?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Ne.getState().closeMainSurfaces(),children:s.jsx(_,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Xt.title}),Xt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Xt.subtitle}):null]})]}):H||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[Q?s.jsx(_,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(ql,{align:"start",children:s.jsx("button",{type:"button",className:ks,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(_,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[me?s.jsxs("form",{ref:We,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),yt()},children:[s.jsx("input",{ref:Ie,value:Xe,onChange:N=>nt(N.target.value),onKeyDown:N=>qi(N,()=>De(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>De(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ge}),Pe?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[x?s.jsx("span",{className:"truncate",children:x}):null,mt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:mt})]}):null,!a&&Fe?s.jsxs("span",{className:Ee("inline-flex min-w-0 items-center gap-0.5",Fe==="attention"||Fe==="invalid"||Fe==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(_,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:_e})]}):null]}):null]}),s.jsx("div",{className:Ee("flex h-[18px] shrink-0 items-center justify-center",Pe?"self-start":"self-center"),children:d&&!a&&!me?s.jsxs(Ls,{open:K,onOpenChange:Se,onOpenChangeComplete:N=>{!N&&Ve.current&&Ve.current===d&&(Ve.current=null,Et())},children:[s.jsx(Fs,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(_,{name:"more",className:"size-4"})})}),s.jsxs(_s,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Ht,{onClick:()=>{Ve.current=d},children:[s.jsx(_,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ma,{sessionID:d,directory:Ae,open:K,Item:Ht}),s.jsxs(Ht,{onClick:()=>d&&At(d),children:[s.jsx(_,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Es,{}),s.jsxs(Ht,{onClick:()=>{He()},children:[s.jsx(_,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),qe(Ht),!H&&!kt&&oe&&!oe.parentId?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ht,{disabled:!Ae||Ye||f,onClick:dt,className:"w-full",children:[s.jsx(_,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ye?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Es,{}),s.jsxs(Ht,{onClick:()=>{d&&gt({action:"archive",sessionId:d})},children:[s.jsx(_,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Ht,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&gt({action:"delete",sessionId:d})},children:[s.jsx(_,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(ql,{align:"start",children:s.jsx("button",{type:"button",className:ks,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(_,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Gb,{renderMenu:hn,suppressActiveTabControls:me,onMenuOpenChangeComplete:N=>{!N&&Ve.current&&Ve.current===d&&(Ve.current=null,Et())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:me?s.jsxs("form",{ref:We,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),yt()},children:[s.jsx("input",{ref:Ie,value:Xe,onChange:N=>nt(N.target.value),onKeyDown:N=>qi(N,()=>De(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>De(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Ge})})})]}),Xt||H||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&L?s.jsx(Ex,{reading:Rx(L),contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:mn,pressed:vn,className:Ys?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(fy,{visible:Ys,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:nn,className:Ee(ks,"mr-1"),Icon:"picture-in-picture-2"}),H?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":re,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:ge,className:Ee(Vo,"mr-1",re?"text-foreground":"text-muted-foreground/50"),children:s.jsx(_,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t(ce&&!G?we?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ce?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),Sn,s.jsx(Yu,{visible:R&&A==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:on()}),s.jsx(Ps,{open:Ze!==null,onOpenChange:N=>{N||gt(null)},children:s.jsxs(Ds,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(sn,{children:[s.jsx(Us,{children:Ze?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Hs,{children:Ze?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Ge}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Ge})})]}),s.jsxs(zn,{children:[s.jsx(ct,{variant:"outline",size:"sm",onClick:()=>gt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ct,{variant:"destructive",size:"sm",onClick:()=>{Ot()},children:Ze?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Ud,{open:ue,onOpenChange:se,info:xe,downloading:!1,downloaded:!1,progress:null,error:fe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function py(){}const oc=280,ic=264,ac=500,gy=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=Nt(),l=Ne(v=>v.sidebarWidth),a=Ne(v=>v.setSidebarWidth),[d,u]=c.useState(!1),m=c.useRef(0),f=c.useRef(l||oc),p=c.useRef(null),y=c.useRef(null),x=c.useRef(null),k=c.useCallback(v=>Math.min(ac,Math.max(ic,v)),[]),w=c.useCallback(v=>{const E=x.current;E&&(E.style.width=`${v}px`,E.style.minWidth=`${v}px`,E.style.maxWidth=`${v}px`,E.style.setProperty("--oc-left-sidebar-width",`${v}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(p.current=null,y.current=null)},[d]),e)return null;const h=Math.min(ac,Math.max(ic,l||oc)),g=t?h:0,j=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}y.current=v.pointerId,u(!0),m.current=v.clientX,f.current=g,p.current=g,w(g),v.preventDefault()}},b=v=>{if(e||!d||y.current!==v.pointerId)return;const E=v.clientX-m.current,R=k(f.current+E);p.current!==R&&(p.current=R,w(R))},S=v=>{if(y.current!==v.pointerId||e)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const E=k(p.current??g);y.current=null,p.current=null,u(!1),a(E)},C=d?p.current??g:g;return s.jsxs("aside",{ref:x,className:Ee("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${d?C:h}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||g===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Ee("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:j,onPointerMove:b,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Ee("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(En,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Cs,{children:n})})]})]})},xy=()=>{const t=tt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},uo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",by=()=>{const t=tt.c(37),{t:e}=Nt(),n=Ne(yy),r=Ne(wy),i=Ne(vy),o=c.useRef(null),l=sr(so("toggle_sidebar",i)),a=Sy,{usesFramelessChrome:d,side:u}=qu(),m=ky;let f,p;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const L=o.current;if(!L)return;const W=()=>{const P=Math.max(L.getBoundingClientRect().width,L.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(P)}px`)};if(W(),typeof ResizeObserver>"u")return;const $=new ResizeObserver(W);return $.observe(L),()=>{$.disconnect()}},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),c.useEffect(f,p);const y="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let x;t[2]===Symbol.for("react.memo_cache_sentinel")?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=x):x=t[2];const k="flex items-center gap-2";let w;t[3]!==d||t[4]!==u?(w=d&&u==="left"?s.jsx(Yu,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=w):w=t[5];let h;t[6]!==e||t[7]!==d?(h=d?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:Ee(uo,"shrink-0"),children:s.jsx(_,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=h):h=t[8];const g=vt;let j;t[9]!==e?(j=e("header.actions.openSessionsAria"),t[9]=e,t[10]=j):j=t[10];let b,S;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=Ee(uo,"shrink-0"),S=s.jsx(_,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=b,t[12]=S):(b=t[11],S=t[12]);let C;t[13]!==j||t[14]!==n?(C=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":j,className:b,children:S})}),t[13]=j,t[14]=n,t[15]=C):C=t[15];const v=jt,E=e("header.actions.openSessionsWithShortcut",{shortcut:l});let R;t[16]!==E?(R=s.jsx("p",{children:E}),t[16]=E,t[17]=R):R=t[17];let A;t[18]!==v||t[19]!==R?(A=s.jsx(v,{children:R}),t[18]=v,t[19]=R,t[20]=A):A=t[20];let O;t[21]!==g||t[22]!==C||t[23]!==A?(O=s.jsxs(g,{children:[C,A]}),t[21]=g,t[22]=C,t[23]=A,t[24]=O):O=t[24];let B;t[25]!==a||t[26]!==r||t[27]!==e?(B=r?s.jsxs("button",{type:"button",onClick:a,className:Ee(uo,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(_,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Ee(uo,"-ml-1 shrink-0"),children:s.jsx(_,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=B):B=t[28];let T;t[29]!==O||t[30]!==B||t[31]!==w||t[32]!==h?(T=s.jsxs("div",{ref:o,className:k,children:[w,h,O,B]}),t[29]=O,t[30]=B,t[31]=w,t[32]=h,t[33]=T):T=t[33];let M;return t[34]!==T||t[35]!==x?(M=s.jsx("div",{className:y,style:x,children:T}),t[34]=T,t[35]=x,t[36]=M):M=t[36],M};function yy(t){return t.toggleSidebar}function wy(t){return t.isSidebarOpen}function vy(t){return t.shortcutOverrides}function Sy(){Ne.getState().closeMainSurfaces(),rt.getState().openNewSessionDraft()}function jy(t){console.warn("[titlebar] failed to open app menu",t)}function ky(t){const e=t.currentTarget.getBoundingClientRect();Fn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(jy)}function ff(t){const e=tt.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(_,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const lc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Cy(t,e,n){const r=tt.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([jp(t),kp(t)]).catch(Ny);if(d)return;const f=lc(u),p=lc(m);if(!f||!p||p===f)return;const y=n||"",x=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:y,label:y||x,name:x,worktreeRoot:p,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Ny(){return["",""]}const cc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Ay=async(t,e)=>{if(t)return t.authActivate(e);const n=await bs("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},dc=({className:t})=>{const{t:e}=Nt(),{github:n}=wn(),r=In(y=>y.status),i=In(y=>y.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async y=>{if(!(!y||o)){l(!0);try{i(await Ay(n,y))}catch(x){console.error("Failed to switch GitHub account:",x)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,m=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),p=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(_,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return m.length<=1?s.jsx("div",{className:Ee(cc,t),title:f,children:p}):s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(cc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(_s,{align:"end",className:"w-64",children:[s.jsx(_r,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Es,{}),m.map(y=>{const x=y.user,k=!!y.current,w=y.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Ht,{className:"gap-2",disabled:o,onSelect:()=>{k||a(y.id)},children:[x?.avatarUrl?s.jsx("img",{src:x.avatarUrl,alt:x.login?e("header.github.avatarWithLogin",{login:x.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(_,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:x?.name?.trim()||x?.login||"GitHub"}),x?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:x.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:w})]}):null]}),k?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})};class gi extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const xi="/api/walkthrough",mf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),hf=()=>new gi("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Py=t=>!mf(t)&&(t.ok||t.status===404),el=async(t,e)=>{if(Py(t))throw hf();const n=await t.json().catch(()=>null);throw new gi(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},pf=async t=>{if(!mf(t))throw hf();try{return await t.json()}catch{throw new gi("The server returned a malformed walkthrough response")}};async function Dy(t,e,n={}){const r=await bs(xi,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?pf(r):el(r,"Failed to load walkthrough")}async function Iy(t,e,n={}){const r=await bs(`${xi}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?pf(r):el(r,"Failed to generate walkthrough")}async function Ty(t,e){const n=await bs(`${xi}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await el(n,"Failed to cancel walkthrough generation")}async function Ey(t,e,n){const r=await bs(`${xi}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Ir={status:"idle",stage:null,result:null,readiness:null,error:null},Ry=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,Rn=(t,e)=>`${Qt()}\0${t}\0${Ry(e)}`,uc=t=>t instanceof gi?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Js=new Map,Tr=new Map,My=1e3,Oy=no()(eb((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Rn(n,r)],selectModel:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Rn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Rn(n,r)]??Ir,load:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);if(e().entries[o]?.status==="generating")return;Js.get(o)?.abort();const a=new AbortController;Js.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Ir,status:"loading",error:null}}}));try{const d=await Dy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Ir,status:"error",stage:null,error:uc(d)}}}))}finally{Js.get(o)===a&&Js.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);Js.get(o)?.abort();const l=new AbortController;Js.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Ir,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Tr.get(o);d!==void 0&&(clearInterval(d),Tr.delete(o))};a(),Tr.set(o,setInterval(()=>{Ey(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const m=u.entries[o];return!m||m.status!=="generating"||m.stage===d?u:{entries:{...u.entries,[o]:{...m,stage:d}}}})}).catch(()=>{})},My));try{const d=await Iy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Ir,status:"error",stage:null,error:uc(d)}}}))}finally{a(),Js.get(o)===l&&Js.delete(o)}},cancel:(n,r)=>{const i=Rn(n,r);Ty(n,r).catch(()=>{}),Js.get(i)?.abort(),Js.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of Js.values())n.abort();Js.clear();for(const n of Tr.values())clearInterval(n);Tr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),By="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)]",Fy=3e4,fc=20,gf=(t,e)=>JSON.stringify([Qt(),t,e]),_y=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},mc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),fo=new Map,Ly=t=>{const e=Object.entries(t);return e.length<=fc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,fc))},hc=no()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=gf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<Fy&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const m=`${l}::${a?"details":"plain"}`,p=fo.get(`${l}::details`)??(a?null:fo.get(m));if(p&&!o?.force)return p;const y=(async()=>{t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??mc(),isLoading:!0,error:null}}}));try{const x=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(k=>({entries:Ly({...k.entries,[l]:{result:x,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),x}catch(x){const k=x instanceof Error?x.message:"Failed to load pull request context";return t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??mc(),isLoading:!1,error:k}}})),null}finally{fo.delete(m)}})();return fo.set(m,y),y},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=_y(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),$y=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},zy=35e3,Ei=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Ri=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},pc=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"}},Wy=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},Ky=[2e3,5e3],Vy=600,gc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),On=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):""},Uy=(t,e)=>{const n=On(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Hy=(t,e)=>`${t}::${e}`,tl=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Mi=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=tl(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},Gy=t=>t.startsWith("pr-"),qy=(t,e)=>{const n=tl(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!Gy(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Er=new Map,mo=eo;function Yy(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const Qy=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=Nt(),d=Ne(N=>N.timeFormatPreference),{github:u}=wn(),m=In(N=>N.status),f=In(N=>N.hasChecked),p=Ne(N=>N.setSettingsDialogOpen),y=Ne(N=>N.setSettingsPage),x=rt(N=>N.currentSessionId),k=rt(N=>!!N.newSessionDraft?.open),{isMobile:w,hasTouchInput:h,screenWidth:g}=$n(),j=Ne(N=>N.openContextSurface),b=Oy(N=>N.requestSource),S=!w&&g>=768&&!_n(),C=c.useCallback(()=>{y("integrations"),p(!0)},[p,y]),v=c.useMemo(()=>Hy(t,e),[t,e]),E=c.useMemo(()=>Er.get(v)??null,[v]),R=Vs(N=>N.ensureEntry),A=Vs(N=>N.setParams),O=Vs(N=>N.startWatching),B=Vs(N=>N.stopWatching),T=Vs(N=>N.refresh),M=Vs(N=>N.updateStatus),[L,W]=c.useState(()=>E?.title??gc(e)),[$,P]=c.useState(()=>E?.body??""),[D,I]=c.useState(()=>E?.draft??!1),[X,Z]=c.useState(()=>E?.additionalContext??""),[ne,ue]=c.useState(()=>{const N=typeof E?.targetBaseBranch=="string"?On(E.targetBaseBranch):"";return N||On(n)}),[se,xe]=c.useState("squash"),[ie,Re]=c.useState(!1),[be,fe]=c.useState(!1),[ke,H]=c.useState(!1),[J,ce]=c.useState(!1),[je,G]=c.useState(!1),[we,Te]=c.useState(!1),[he,re]=c.useState(null),[ge,q]=c.useState(""),[z,ee]=c.useState(""),[de,Y]=c.useState(!1),[U,F]=c.useState(!1),[V,oe]=c.useState(()=>Mi(i,{selectedRemoteName:E?.selectedRemoteName,trackingBranch:r})),[ae,pe]=c.useState(!1),{detectedUpstream:le,upstreamBranches:_e}=Yy(t,u);c.useEffect(()=>{pe(!1)},[t]);const Fe=i.some(N=>N.name==="upstream"),Ae=!!(t&&e&&n&&(e!==n||(Fe||le!==null))),Q=c.useMemo(()=>ei(t,e,V?.name??null),[t,e,V?.name]),Ce=Vs(N=>N.entries[Q]),Be=Ce?.isLoading??!1,Le=Ce?.status??null,Je=Ce?.error??null,ot=Ce?.isInitialStatusResolved??!1,et=c.useMemo(()=>{const N=ae?null:V?.name?.trim()||null,ye=new Set;for(const Pt of o){const Dt=Uy(Pt,N);!Dt||Dt==="HEAD"||ye.add(Dt)}if(ae)for(const Pt of _e)Pt&&Pt!=="HEAD"&&ye.add(Pt);const $e=On(n);$e&&$e!=="HEAD"&&ye.add($e);const lt=On(ne);return lt&&lt!=="HEAD"&&ye.add(lt),Array.from(ye).sort((Pt,Dt)=>Pt.localeCompare(Dt))},[n,o,V?.name,ne,_e,ae]);c.useEffect(()=>{if(i.length===0){V&&oe(null);return}(!V||!i.some(N=>N.name===V.name))&&oe(Mi(i,{selectedRemoteName:E?.selectedRemoteName,trackingBranch:r}))},[E?.selectedRemoteName,i,V,r]),c.useEffect(()=>{const N=On(n);if(!ne&&N){ue(N);return}if(et.length!==0&&!et.includes(ne)){const ye=et.includes(N)?N:et[0];ye&&ue(ye)}},[et,n,ne]);const[it,ht]=c.useState(()=>E?.activeSegment??"overview"),[st,mt]=c.useState(new Set),[kt,Pe]=c.useState(new Set),Ge=c.useRef(new Set),at=c.useRef(null),ze=c.useRef(!1),ft=c.useRef(new Set),te=c.useRef([]);c.useEffect(()=>{le&&!Fe&&pe(!0)},[le,Fe]),c.useEffect(()=>{ae&&le?.defaultBranch&&ue(le.defaultBranch)},[ae,le?.defaultBranch]);const me=Le?.pr??null,De=me?.state==="merged"||me?.state==="closed",K=De?null:me,Se=K?gf(t,K.number):null,Ve=hc(N=>Se?N.entries[Se]:void 0),Xe=hc(N=>N.ensure),nt=Ve?.result??null,Ze=Ve?.isLoading??!1,gt=c.useCallback(N=>{ht(N);const ye=Er.get(v);ye&&Er.set(v,{...ye,activeSegment:N})},[v]);c.useEffect(()=>{!K||!u?.prContext||it==="overview"||Xe(u,t,K.number,{includeCheckDetails:it==="checks",sourceRepo:Le?.repo??null})},[it,t,Xe,u,K,Le?.repo]);const We=Le?.checks??null,Et=(We?.pending??0)>0,Ft=nt?.checkRuns??null,Ie=nt?.fetchedAt;c.useEffect(()=>{if(!Ft||Ft.length===0)return;const N=$y(Ft);M(Q,ye=>{if(!ye?.pr||typeof Ie=="number"&&typeof ye.fetchedAt=="number"&&Ie<ye.fetchedAt)return ye;const $e=ye.checks;return $e&&$e.state===N.state&&$e.total===N.total&&$e.success===N.success&&$e.failure===N.failure&&$e.pending===N.pending&&$e.inProgress===N.inProgress&&$e.queued===N.queued&&$e.startedAt===N.startedAt?ye:{...ye,checks:N,...typeof Ie=="number"?{fetchedAt:Ie}:{}}})},[Ft,Ie,Q,M]),c.useEffect(()=>{if(it!=="checks"||!Et||!me||!u?.prContext)return;const N=window.setInterval(()=>{Xe(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Le?.repo??null,force:!0})},zy);return()=>window.clearInterval(N)},[it,Et,t,Xe,u,me,Le?.repo]);const[yt,At]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Et)return;At(Date.now());const N=window.setInterval(()=>At(Date.now()),3e4);return()=>window.clearInterval(N)},[Et]);const He=me?`${t}#${me.number}`:null,Ue=!!(He&&he===He);c.useEffect(()=>{if(!u?.prContext||!me||typeof me.body=="string"&&me.body.length>0)return;const N=`${t}#${me.number}`;if(Ge.current.has(N))return;Ge.current.add(N),re(N);let ye=!1;return Xe(u,t,me.number,{sourceRepo:Le?.repo??null}).then($e=>{if(ye)return;const lt=$e?.pr;lt&&M(Q,Pt=>!Pt?.pr||Pt.pr.number!==me.number?Pt:{...Pt,pr:{...Pt.pr,body:lt.body||""}})}).catch(()=>{}).finally(()=>{ye||re($e=>$e===N?null:$e)}),()=>{ye=!0}},[t,Xe,u,me,Q,Le?.repo,M]),c.useEffect(()=>{if(!me){Te(!1),q(""),ee(""),at.current=null;return}const N=at.current!==null&&at.current!==me.number;N&&Te(!1),(!we||N)&&(q(me.title||""),ee(me.body||"")),at.current=me.number},[we,me]);const ve=c.useCallback(N=>{if(!N)return"";const ye=Date.parse(N);return Number.isFinite(ye)?yu(ye,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):N},[d]),Qe=c.useMemo(()=>{const N=m?.user?.login;return typeof N=="string"?N.trim():""},[m]),qe=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),Ye=c.useCallback(N=>{const ye=Qe.toLowerCase(),$e=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return N.replace($e,(lt,Pt,Dt)=>{const pt=`@${Dt}`,qt=Dt.toLowerCase();return`${Pt}[${pt}](https://github.com/${qt}${ye&&qt===ye?"?oc-self-mention=1":""})`})},[Qe]),dt=c.useMemo(()=>{const N=(nt?.issueComments??[]).map(lt=>({id:`issue-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.login||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),ye=(nt?.reviewComments??[]).map(lt=>({id:`review-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.login||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:lt.path||null,line:lt.line??null})),$e=[...N,...ye];return $e.sort((lt,Pt)=>{const Dt=lt.createdAt?Date.parse(lt.createdAt):0,pt=Pt.createdAt?Date.parse(Pt.createdAt):0,qt=Number.isFinite(Dt)?Dt:0,wt=Number.isFinite(pt)?pt:0;return qt-wt}),$e},[nt,a]),Ot=c.useCallback(()=>{const N=x??(k?"draft":null);return N?{directory:t,sessionKey:N}:(Ke.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[x,t,k,a]),zt=c.useCallback((N,ye)=>{const $e=ye.authorLogin?`@${ye.authorLogin}`:ye.authorName,lt=ye.path?` · ${ye.path}${ye.line?`:${ye.line}`:""}`:"";Ji.getState().addDraft(N,{source:"pr-comment",fileLabel:`PR #${me?.number??""} ${$e}${lt}`,startLine:ye.line??0,endLine:ye.line??0,code:ye.body,language:"markdown",text:""})},[me?.number]),Kt=c.useCallback((N,ye)=>{const $e=N.status||"unknown",lt=N.conclusion??void 0,Pt=lt?`${$e} / ${lt}`:$e,Dt=N.app?.name||N.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:ye?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[ye?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:N.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Dt?`${Dt} · ${Pt}`:Pt})]}),N.detailsUrl?s.jsx(ct,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:N.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(_,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),N.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:N.output.title}):null,N.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:N.output.summary}):null,N.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:N.output.text}):null,Array.isArray(N.annotations)&&N.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",N.annotations.length>20?` (showing 20/${N.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:N.annotations.slice(0,20).map((pt,qt)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[pt.title||pt.level||"Issue",pt.path?` · ${pt.path}`:"",typeof pt.startLine=="number"?`:${pt.startLine}`:"",typeof pt.endLine=="number"&&pt.endLine!==pt.startLine?`-${pt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:pt.message}),pt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:pt.rawDetails}):null]},`${pt.path||"file"}:${pt.startLine||qt}:${qt}`))})]}):null,N.job?.steps&&N.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:N.job.steps.map((pt,qt)=>{const wt=(pt.conclusion||"").toLowerCase(),bt=wt&&!["success","neutral","skipped"].includes(wt),It=`${N.id??"run"}:${N.job?.jobId??"job"}:${pt.number??qt}:${pt.name}`,Lt=st.has(It);return bt?s.jsxs(Zi,{open:Lt,children:[s.jsxs("button",{type:"button",onClick:()=>{mt(Zt=>{const $t=new Set(Zt);return $t.has(It)?$t.delete(It):$t.add(It),$t})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(bt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Lt?s.jsx(_,{name:"arrow-down-s",className:"size-4"}):s.jsx(_,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:pt.name}),pt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:pt.conclusion}):null]}),s.jsx(ea,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof pt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",pt.number]}):null,pt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",pt.status]}):null,pt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",pt.conclusion]}):null,pt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",ve(pt.startedAt)]}):null,pt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",ve(pt.completedAt)]}):null]})})]},It):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:pt.name}),pt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:pt.conclusion}):null]},It)})})]}):null]})},[st,ve,a]),[Gt,Bt]=c.useState(!1),[Jt,Vt]=c.useState(!1),Wt=c.useCallback(async()=>{if(!u?.prContext){Ke.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!me)return;const N=Ot();if(N){Bt(!0);try{const ye=await Xe(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Le?.repo??null});if(!ye){Ke.error(a("gitView.pr.toast.loadChecksFailed"));return}const lt=(ye.checkRuns??[]).filter(Dt=>Ri(Dt.conclusion));if(lt.length===0){Ke.message(a("gitView.pr.toast.noFailedChecks"));return}const Pt=Ji.getState();for(const Dt of lt){const pt=(Dt.annotations??[]).map(bt=>[[bt.level,bt.title].filter(Boolean).join(" "),bt.path?`${bt.path}${typeof bt.startLine=="number"?`:${bt.startLine}`:""}`:null,bt.message,bt.rawDetails].filter(Boolean).join(`
3
+ `)),qt=(Dt.job?.steps??[]).filter(bt=>Ri(bt.conclusion)).map(bt=>`step ${bt.number??"?"}: ${bt.name} → ${bt.conclusion}`),wt=[`check: ${Dt.job?.workflowName?`${Dt.job.workflowName} / ${Dt.name}`:Dt.name}`,`status: ${Dt.status??"unknown"} / ${Dt.conclusion??"unknown"}`,Dt.detailsUrl?`url: ${Dt.detailsUrl}`:null,Dt.output?.title?`title: ${Dt.output.title}`:null,Dt.output?.summary?`summary:
4
+ ${Dt.output.summary}`:null,qt.length>0?`failed steps:
5
+ ${qt.join(`
6
+ `)}`:null,pt.length>0?`annotations:
7
+ ${pt.join(`
8
+ ---
9
+ `)}`:null].filter(Boolean).join(`
10
+
11
+ `);Pt.addDraft(N,{source:"pr-check",fileLabel:`PR #${me.number} · ${Dt.name}`,startLine:0,endLine:0,code:wt,language:"text",text:""})}}catch(ye){const $e=ye instanceof Error?ye.message:String(ye);Ke.error(a("gitView.pr.toast.loadChecksFailed"),{description:$e})}finally{Bt(!1)}}},[t,Xe,u,me,Ot,Le?.repo,a]),_t=c.useCallback(async()=>{if(!u?.prContext){Ke.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!me)return;const N=Ot();if(N){Vt(!0);try{if(!await Xe(u,t,me.number,{sourceRepo:Le?.repo??null})){Ke.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(dt.length===0){Ke.message(a("gitView.pr.toast.noPrComments"));return}for(const $e of dt)zt(N,$e)}catch(ye){const $e=ye instanceof Error?ye.message:String(ye);Ke.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:$e})}finally{Vt(!1)}}},[zt,t,Xe,u,me,Ot,Le?.repo,a,dt]),Xt=c.useCallback(async N=>{const ye=Ot();ye&&zt(ye,N)},[zt,Ot]),Ct=c.useCallback(async N=>{await T(Q,N)},[Q,T]),[Tt,is]=c.useState(!1),$s=c.useRef(!0);c.useEffect(()=>($s.current=!0,()=>{$s.current=!1}),[]);const cs=c.useCallback(async()=>{if(Tt)return;is(!0);const N=Date.now();try{await Ct({force:!0})}finally{const ye=Vy-(Date.now()-N);ye>0&&await new Promise($e=>window.setTimeout($e,ye)),$s.current&&is(!1)}},[Tt,Ct]),ps=c.useCallback(()=>{te.current.forEach(N=>{window.clearTimeout(N)}),te.current=Ky.map(N=>window.setTimeout(()=>{Ct({force:!0,silent:!0,markInitialResolved:!0})},N))},[Ct]);c.useEffect(()=>{if(!u?.prStatus||!Ae||i.length<=1||ze.current||Le?.pr)return;const N=`${v}::${V?.name??""}`;if(ft.current.has(N))return;ft.current.add(N);const ye=qy(i,r).filter(Pt=>Pt.name!==V?.name);if(ye.length===0)return;let $e=!1;return(async()=>{for(const Pt of ye){if($e)return;try{if(!(await u.prStatus(t,e,Pt.name))?.pr)continue;if($e)return;oe(pt=>pt?.name===Pt.name?pt:Pt);return}catch{}}})(),()=>{$e=!0}},[e,Ae,t,u,i,V?.name,v,Le?.pr,r]),c.useEffect(()=>{R(Q),A(Q,{directory:t,branch:e,remoteName:V?.name??null,canShow:Ae,github:u,githubAuthChecked:f,githubConnected:m?.connected??null})},[e,Ae,t,R,u,f,m?.connected,Q,V?.name,A]),c.useEffect(()=>(O(Q),()=>{B(Q)}),[Q,O,B]),c.useEffect(()=>{const N=Er.get(v)??null;W(N?.title??gc(e)),P(N?.body??""),I(N?.draft??!1),ue(N?.targetBaseBranch?On(N.targetBaseBranch):On(n));const ye=Mi(i,{selectedRemoteName:N?.selectedRemoteName,trackingBranch:r});oe($e=>$e?.name===ye?.name?$e:ye)},[n,e,i,v,r]),c.useEffect(()=>{Ct({markInitialResolved:!0})},[Q,Ct]),c.useEffect(()=>{!Ae||!V?.name||Ct({force:!0,silent:!0,markInitialResolved:!0})},[Ae,Ct,V?.name]),c.useEffect(()=>{const N=Le?.resolvedRemoteName?.trim();if(!N||ze.current)return;const ye=i.find($e=>$e.name===N);ye&&oe($e=>$e?.name===ye.name?$e:ye)},[i,Le?.resolvedRemoteName]),c.useEffect(()=>{const N=()=>{const $e=Vs.getState().entries[Q]?.lastRefreshAt??0;Date.now()-$e>6e4&&Ct({force:!0,silent:!0})},ye=()=>{document.visibilityState==="visible"&&N()};return window.addEventListener("focus",N),document.addEventListener("visibilitychange",ye),()=>{window.removeEventListener("focus",N),document.removeEventListener("visibilitychange",ye)}},[Q,Ct]),c.useEffect(()=>{f&&m?.connected===!1&&Ct({force:!0,silent:!0,markInitialResolved:!0})},[f,m,Ct]),c.useEffect(()=>{!t||!e||Er.set(v,{title:L,body:$,draft:D,additionalContext:X,targetBaseBranch:ne,selectedRemoteName:V?.name,activeSegment:it})},[v,L,$,D,X,ne,V?.name,t,e,it]),c.useEffect(()=>{const N=te.current;return()=>{N.forEach(ye=>{window.clearTimeout(ye)}),te.current=[]}},[]);const fn=c.useCallback(async()=>{if(!ie&&t){Re(!0);try{const ye={base:ae&&le?.defaultBranchSha?le.defaultBranchSha:ne,head:e};X&&(ye.context=X);const $e=await Cp(t,ye);$e.title?.trim()&&W($e.title.trim()),$e.body?.trim()&&P($e.body.trim()),l?.()}catch(N){const ye=N instanceof Error?N.message:String(N);Ke.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:ye})}finally{Re(!1)}}},[X,e,le?.defaultBranchSha,t,ie,l,ne,a,ae]),nn=c.useCallback(async()=>{if(!u?.prCreate){Ke.error(a("gitView.pr.toast.githubApiUnavailable"));return}const N=L.trim();if(!N){Ke.error(a("gitView.pr.toast.titleRequired"));return}const ye=ne.trim();if(!ye){Ke.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!ae&&ye===e){Ke.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}fe(!0);try{const $e=tl(r),lt=ae&&le,Pt=await u.prCreate({directory:t,title:N,head:e,base:ye,...$.trim()?{body:$}:{},draft:D,...lt?{targetRepo:{owner:le.owner,repo:le.repo},headRemote:"origin"}:{...V?{remote:V.name}:{},...$e&&$e!==V?.name?{headRemote:$e}:{}}});Ke.success(a("gitView.pr.toast.prCreated")),M(Q,Dt=>Dt&&{...Dt,pr:Pt}),await Ct({force:!0}),ps()}catch($e){const lt=$e instanceof Error?$e.message:String($e);Ke.error(a("gitView.pr.toast.createPrFailed"),{description:lt})}finally{fe(!1)}},[$,e,le,t,D,u,Q,Ct,ps,V,ne,L,r,M,ae,a]),mn=c.useCallback(async N=>{if(!u?.prMerge){Ke.error(a("gitView.pr.toast.githubApiUnavailable"));return}ce(!0);try{const ye=await u.prMerge({directory:t,number:N.number,method:se});ye.merged?Ke.success(a("gitView.pr.toast.prMerged")):Ke.message(a("gitView.pr.toast.prNotMerged"),{description:ye.message||a("gitView.pr.notMergeable")}),await Ct({force:!0}),ps()}catch(ye){const $e=ye instanceof Error?ye.message:String(ye);Ke.error(a("gitView.pr.toast.mergeFailed"),{description:$e}),N.url&&mo(N.url)}finally{ce(!1)}},[t,u,se,Ct,ps,a]),vn=c.useCallback(async N=>{if(!u?.prReady){Ke.error(a("gitView.pr.toast.githubApiUnavailable"));return}G(!0);try{await u.prReady({directory:t,number:N.number}),Ke.success(a("gitView.pr.toast.markedReady")),await Ct({force:!0}),ps()}catch(ye){const $e=ye instanceof Error?ye.message:String(ye);Ke.error(a("gitView.pr.toast.markReadyFailed"),{description:$e}),N.url&&mo(N.url)}finally{G(!1)}},[t,u,Ct,ps,a]),ks=c.useCallback(async N=>{if(!u?.prUpdate){Ke.error(a("gitView.pr.toast.githubApiUnavailable"));return}const ye=ge.trim();if(!ye){Ke.error(a("gitView.pr.toast.titleRequired"));return}H(!0);try{const $e=await u.prUpdate({directory:t,number:N.number,title:ye,body:z});M(Q,lt=>lt&&{...lt,pr:{...lt.pr??N,...$e}}),Te(!1),Ke.success(a("gitView.pr.toast.prUpdated")),await Ct({force:!0}),ps()}catch($e){const lt=$e instanceof Error?$e.message:String($e);Ke.error(a("gitView.pr.toast.updatePrFailed"),{description:lt})}finally{H(!1)}},[t,z,ge,u,Q,Ct,ps,M,a]);if(!Ae)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx(dc,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const rn=Le?.repo?.url||null,zs=ae&&le?.url?le.url:rn,Ws=!!Le?.canMerge,as=!!Le?.connected,Gs=f&&Le?.connected===!1,gs=Wy(Le),us=gs?`var(--pr-${gs})`:"var(--status-info)",qs=gs==="draft"?"git-pr-draft":gs==="merged"?"git-merge":gs==="closed"?"git-close-pull-request":"git-pull-request",Sn=me?[`${me.state}${me.draft?" (draft)":""}`,me.mergeable===!1?a("gitView.pr.notMergeable"):null,me.state==="open"&&typeof me.mergeableState=="string"&&me.mergeableState&&me.mergeableState!=="unknown"?me.mergeableState:null].filter(Boolean).join(" · "):"",Ys=We?We.total>0?`${We.success}/${We.total} ${a("gitView.pr.checks.label")}`:`${We.state} ${a("gitView.pr.checks.label")}`:"";return s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[s.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[s.jsxs("div",{className:"@container/pr-actions flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[me?s.jsxs(ct,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{mo(me.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(_,{name:qs,className:"size-4 shrink-0",style:{color:us}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(_,{name:qs,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),me?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",me.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[me&&S?s.jsxs(ct,{variant:"outline",size:"sm",className:Ee("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",By),onClick:()=>{b(t,{kind:"pr",number:me.number,sourceRepo:Le?.repo?{owner:Le.repo.owner,repo:Le.repo.repo}:void 0}),j(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(_,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Be||Tt,onClick:()=>{cs()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Be||Tt?s.jsx(_,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(_,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(dc,{className:"h-7 w-7"})]})]}),me?s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:us},children:Sn}),We?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${pc(We.state)}`}),Ys]}):null,r&&V&&r.split("/")[0]!==V.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",V.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Ws&&me.draft&&me.state==="open"?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>vn(me),disabled:je||J||ke||we,"aria-label":a("gitView.pr.actions.markReadyAria"),children:je?s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(_,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,Ws?s.jsxs(s.Fragment,{children:[s.jsxs(Rs,{value:se,onValueChange:N=>xe(N),disabled:J||me.state!=="open",children:[s.jsx(Ms,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(js,{})}),s.jsxs(Os,{children:[s.jsx(rs,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(rs,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(rs,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>mn(me),disabled:J||je||me.state!=="open"||me.draft||ke||we,"aria-label":a("gitView.pr.actions.mergePrAria"),children:J?s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(_,{name:"git-merge",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[Gs?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(ct,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,Je?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:Je}),zs?s.jsx(ct,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:zs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(_,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!me&&!ot&&!Je&&!Gs?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):me&&!De?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(Hd,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:We&&We.total>0?`${a("gitView.pr.segment.checks")} ${We.success}/${We.total}`:a("gitView.pr.segment.checks"),icon:We?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${pc(We.state)}`}):void 0},{id:"comments",label:nt?`${a("gitView.pr.segment.comments")} ${(nt.issueComments?.length??0)+(nt.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:it,onSelect:N=>gt(N),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),it==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Ws&&me.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,Ws?null:s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:we?s.jsx(An,{value:ge,onChange:N=>q(N.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:me.title})}),me.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:we?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Te(!1),q(me.title||""),ee(me.body||"")},disabled:ke,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(_,{name:"close",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>ks(me),disabled:ke||!ge.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:ke?s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(_,{name:"check",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Te(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(_,{name:"edit",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),we?s.jsx(pr,{value:z,onChange:N=>ee(N.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h}):null,we?null:me.body?.trim()?s.jsx(Tl,{content:me.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(Ue?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,it==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[We&&We.total>0?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[We.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${We.success/We.total*100}%`}}):null,We.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${We.failure/We.total*100}%`}}):null,We.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${We.pending/We.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[We.success,"/",We.total," ",a("gitView.pr.checks.label")]}),(We.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}),Ei(We.startedAt,void 0,yt)]}):null]}):null,We?.failure?s.jsxs(ct,{variant:"outline",size:"sm",className:"w-fit gap-1.5 border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",onClick:Wt,disabled:Gt,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Gt?s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(_,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(nt?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(nt?.checkRuns??[]).map((N,ye)=>{const $e=`${N.id??"run"}:${N.name}:${ye}`,lt=N.status==="in_progress",Pt=N.status==="queued",Dt=Ri(N.conclusion),pt=kt.has($e),qt=!!(N.output?.title||N.output?.summary||N.output?.text||(N.annotations?.length??0)>0||(N.job?.steps?.length??0)>0||N.detailsUrl),wt=N.job?.workflowName,bt=lt?Ei(N.startedAt,void 0,yt):Ei(N.startedAt,N.completedAt);return s.jsxs("div",{className:Ee("rounded-md border border-border/40",Dt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!qt,onClick:()=>{Pe(It=>{const Lt=new Set(It);return Lt.has($e)?Lt.delete($e):Lt.add($e),Lt})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[lt?s.jsx(_,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):Pt?s.jsx(_,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):Dt?s.jsx(_,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(_,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:wt&&wt!==N.name?`${wt} / ${N.name}`:N.name}),bt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:bt}):null,qt?s.jsx(_,{name:"arrow-down-s",className:Ee("size-4 shrink-0 text-muted-foreground transition-transform",pt&&"rotate-180")}):null]}),pt&&qt?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Kt(N,{hideHeader:!0})}):null]},$e)})}):Ze?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,it==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[dt.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(ct,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)]",onClick:_t,disabled:Jt,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Jt?s.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(_,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,dt.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:dt.map((N,ye)=>{const $e=(N.authorName||"?").charAt(0).toUpperCase(),lt=ye===dt.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[lt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:N.avatarUrl?s.jsx("img",{src:N.avatarUrl,alt:N.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:$e})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1 typography-micro text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-1 sm:gap-y-1",children:[s.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[N.authorName,N.authorLogin&&N.authorLogin!==N.authorName?` · @${N.authorLogin}`:""]}),N.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:ve(N.createdAt)}):null,s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ct,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{Xt(N)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(_,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[N.context,N.path?` · ${N.path}`:"",N.line?`:${N.line}`:""]}),s.jsx(Tl,{content:Ye(N.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",qe].filter(Boolean).join(" "),enableFileReferences:!1})]})]},N.id)})})}):Ze&&!nt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[me&&De?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[s.jsx(_,{name:me.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:us}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:me.state==="merged"?a("gitView.pr.history.merged",{number:me.number,base:me.base||ne}):a("gitView.pr.history.closed",{number:me.number})}),s.jsx(ct,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{mo(me.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(_,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",ne," ",s.jsxs("span",{className:"opacity-60",children:["(",ae&&le?"upstream":"remote",")"]})]})]}),zs?s.jsx(ct,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:zs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(_,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),s.jsx(An,{value:L,onChange:N=>W(N.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),et.length>0?s.jsxs(Rs,{value:ne,onValueChange:ue,children:[s.jsx(Ms,{size:"lg",children:s.jsx(js,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(Os,{children:et.map(N=>s.jsx(rs,{value:N,children:N},N))})]}):s.jsx(An,{value:ne,onChange:N=>ue(N.target.value),placeholder:a("gitView.pr.placeholder.main")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),s.jsx(pr,{value:$,onChange:N=>P(N.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":D,onClick:()=>I(N=>!N),onKeyDown:N=>{(N.key===" "||N.key==="Enter")&&(N.preventDefault(),I(ye=>!ye))},children:[s.jsx(xr,{size:"sm",checked:D,onChange:N=>I(N),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),w?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx(ct,{variant:"outline",size:"sm",onClick:()=>F(!0),children:X.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),X.trim()&&s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):s.jsxs(Zi,{open:de,onOpenChange:Y,children:[s.jsxs(wu,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:de?a("gitView.pr.actions.hide"):X.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(ea,{children:s.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[s.jsx(pr,{value:X,onChange:N=>Z(N.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(ti,{open:U,onClose:()=>F(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(ct,{size:"sm",onClick:()=>F(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(pr,{value:X,onChange:N=>Z(N.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ct,{variant:"outline",size:"sm",onClick:fn,disabled:ie||be,children:[ie?s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(_,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(ct,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:nn,disabled:be||!as||!ne.trim()||!ae&&ne.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:be?s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(_,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},Oi=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),ho=new Map,po=new Map,Mn=t=>`${Qt()}::${t}`,Xy=()=>{const t=tt.c(115),{t:e}=Nt(),{git:n}=wn(),r=dr(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=Np(r??null),a=$a(o??null),d=vu(o??null),u=Su(o??null),{ensureAll:m,ensureNestedRepos:f,selectNestedRepo:p}=Tn(ar(Jy)),y=rt(Zy),x=rt(e1),k=rt(t1),w=rt(s1);let h;t[0]!==r?(h=Oi(r),t[0]=r,t[1]=h):h=t[1];const g=h;let j;if(t[2]!==w||t[3]!==g||t[4]!==k){e:{if(!g){j=void 0;break e}let V;if(t[6]!==w||t[7]!==g){let ae;t[9]!==g?(ae=pe=>Oi(pe.path)===g,t[9]=g,t[10]=ae):ae=t[10],V=w.find(ae),t[6]=w,t[7]=g,t[8]=V}else V=t[8];const oe=V;if(oe){j=oe;break e}for(const ae of k.values())if(Oi(ae.path)===g){j=ae;break e}j=void 0}t[2]=w,t[3]=g,t[4]=k,t[5]=j}else j=t[5];const b=j;let S;t[11]!==y||t[12]!==b||t[13]!==x?.open||t[14]!==k?(S=()=>{if(y)return k.get(y)??b;if(x?.open)return b},t[11]=y,t[12]=b,t[13]=x?.open,t[14]=k,t[15]=S):S=t[15],x?.open;let C;t[16]!==S?(C=S(),t[16]=S,t[17]=C):C=t[17];const v=C;let E;t[18]!==y?(E=V=>y?V.getAttachment(y):void 0,t[18]=y,t[19]=E):E=t[19];const R=uu(E),A=R&&!R.degraded&&!R.legacy?R.worktreeRoot??void 0:void 0,O=Cy(r,v,a?.current??void 0);let B,T;t[20]!==m||t[21]!==n||t[22]!==o?(B=()=>{!o||!n||m(o,n)},T=[o,m,n],t[20]=m,t[21]=n,t[22]=o,t[23]=B,t[24]=T):(B=t[23],T=t[24]),c.useEffect(B,T);const[M,L]=c.useState(null);let W;t[25]!==A||t[26]!==O?.projectDirectory?(W=()=>{const V=A||O?.projectDirectory;if(!V){L(null);return}let oe=!1;return za(V).then(ae=>{if(oe)return;const pe=ae.trim();L(pe&&pe!=="HEAD"?pe:null)}).catch(()=>{oe||L(null)}),()=>{oe=!0}},t[25]=A,t[26]=O?.projectDirectory,t[27]=W):W=t[27];const $=O?.projectDirectory;let P;t[28]!==A||t[29]!==$?(P=[A,$],t[28]=A,t[29]=$,t[30]=P):P=t[30],c.useEffect(W,P);let D;t[31]!==o?(D=()=>(o?ho.get(Mn(o)):void 0)??[],t[31]=o,t[32]=D):D=t[32];const[I,X]=c.useState(D);let Z;t[33]!==o?(Z=()=>(o?po.get(Mn(o)):void 0)??null,t[33]=o,t[34]=Z):Z=t[34];const[ne,ue]=c.useState(Z);let se,xe;t[35]!==n||t[36]!==o?(se=()=>{if(!o||!n?.getRemotes){X([]);return}X(ho.get(Mn(o))??[]);let V=!1;return n.getRemotes(o).then(oe=>{V||(ho.set(Mn(o),oe??[]),X(oe??[]))}).catch(()=>{V||X(ho.get(Mn(o))??[])}),()=>{V=!0}},xe=[o,n],t[35]=n,t[36]=o,t[37]=se,t[38]=xe):(se=t[37],xe=t[38]),c.useEffect(se,xe);let ie,Re;t[39]!==n||t[40]!==o?(ie=()=>{if(!o||!n?.getRemoteUrl){ue(null);return}ue(po.get(Mn(o))??null);let V=!1;return n.getRemoteUrl(o).then(oe=>{V||(po.set(Mn(o),oe),ue(oe))}).catch(()=>{V||ue(po.get(Mn(o))??null)}),()=>{V=!0}},Re=[o,n],t[39]=n,t[40]=o,t[41]=ie,t[42]=Re):(ie=t[41],Re=t[42]),c.useEffect(ie,Re);let be;e:{if(!d?.all){let oe;t[43]===Symbol.for("react.memo_cache_sentinel")?(oe=[],t[43]=oe):oe=t[43],be=oe;break e}let V;t[44]!==d.all?(V=d.all.filter(n1).sort(),t[44]=d.all,t[45]=V):V=t[45],be=V}const fe=be;let ke;e:{if(!d?.all){let oe;t[46]===Symbol.for("react.memo_cache_sentinel")?(oe=[],t[46]=oe):oe=t[46],ke=oe;break e}let V;t[47]!==d.all?(V=d.all.filter(r1).map(o1).sort(),t[47]=d.all,t[48]=V):V=t[48],ke=V}const H=ke;let J;t[49]!==H||t[50]!==ne||t[51]!==I||t[52]!==a?.tracking?(J=()=>{if(I.length>0)return I;const V=new Set,oe=a?.tracking?.trim();oe&&oe.includes("/")&&V.add(oe.split("/")[0]);for(const ae of H){const pe=ae.indexOf("/");pe>0&&V.add(ae.slice(0,pe))}return V.size===0&&ne&&V.add("origin"),Array.from(V).map(ae=>({name:ae,fetchUrl:ne??"",pushUrl:ne??""}))},t[49]=H,t[50]=ne,t[51]=I,t[52]=a?.tracking,t[53]=J):J=t[53],a?.tracking;let ce;t[54]!==J?(ce=J(),t[54]=J,t[55]=ce):ce=t[55];const je=ce,G=a?.current??null;a?.tracking;let we;t[56]!==a?.tracking?(we=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=we):we=t[57];const Te=we,he=(Te&&d?.defaultBranches?.[Te])??d?.defaultBranches?.origin;let re;t[58]!==G||t[59]!==he||t[60]!==je||t[61]!==fe||t[62]!==M||t[63]!==O?.createdFromBranch?(re=()=>wh({remoteNames:new Set(je.map(i1)),localBranches:fe,worktreeCreatedFromBranch:O?.createdFromBranch,rootBranchHint:M,defaultBranch:he,headBranch:G}),t[58]=G,t[59]=he,t[60]=je,t[61]=fe,t[62]=M,t[63]=O?.createdFromBranch,t[64]=re):re=t[64],O?.createdFromBranch;let ge;t[65]!==re?(ge=re(),t[65]=re,t[66]=ge):ge=t[66];const q=ge;if(!r){let V;t[67]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(_,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=V):V=t[67];let oe;t[68]!==e?(oe=e("gitView.pullRequest.title"),t[68]=e,t[69]=oe):oe=t[69];let ae;t[70]!==oe?(ae=s.jsx("div",{className:"typography-ui-header text-foreground",children:oe}),t[70]=oe,t[71]=ae):ae=t[71];let pe;t[72]!==e?(pe=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=pe):pe=t[73];let le;t[74]!==pe?(le=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:pe}),t[74]=pe,t[75]=le):le=t[75];let _e;return t[76]!==ae||t[77]!==le?(_e=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[V,ae,le]}),t[76]=ae,t[77]=le,t[78]=_e):_e=t[78],_e}if(i===!1&&u!==!0){let V;t[79]!==r||t[80]!==f?(V=()=>{f(r,{force:!0})},t[79]=r,t[80]=f,t[81]=V):V=t[81];let oe;return t[82]!==u||t[83]!==l||t[84]!==i||t[85]!==V?(oe=s.jsx(vh,{rootIsGitRepo:i,resolvedIsGitRepo:u,nestedRepos:l,onRetryDiscovery:V}),t[82]=u,t[83]=l,t[84]=i,t[85]=V,t[86]=oe):oe=t[86],oe}if(!G){let V;t[87]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(_,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=V):V=t[87];let oe;t[88]!==e?(oe=e("gitView.pullRequest.title"),t[88]=e,t[89]=oe):oe=t[89];let ae;t[90]!==oe?(ae=s.jsx("div",{className:"typography-ui-header text-foreground",children:oe}),t[90]=oe,t[91]=ae):ae=t[91];let pe;t[92]!==e?(pe=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=pe):pe=t[93];let le;t[94]!==pe?(le=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:pe}),t[94]=pe,t[95]=le):le=t[95];let _e;return t[96]!==ae||t[97]!==le?(_e=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[V,ae,le]}),t[96]=ae,t[97]=le,t[98]=_e):_e=t[98],_e}const z=i===!1&&Array.isArray(l)&&l.length>0;let ee;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==p||t[103]!==z?(ee=z?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(Sh,{repositories:l,selectedRepository:o??null,onSelectRepository:V=>{r&&p(r,V)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=p,t[103]=z,t[104]=ee):ee=t[104];const de=o??r,Y=a?.tracking??void 0;let U;t[105]!==q||t[106]!==G||t[107]!==H||t[108]!==I||t[109]!==de||t[110]!==Y?(U=s.jsx(En,{as:Wa,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(Qy,{directory:de,branch:G,baseBranch:q,trackingBranch:Y,remotes:I,remoteBranches:H})}),t[105]=q,t[106]=G,t[107]=H,t[108]=I,t[109]=de,t[110]=Y,t[111]=U):U=t[111];let F;return t[112]!==ee||t[113]!==U?(F=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ee,U]}),t[112]=ee,t[113]=U,t[114]=F):F=t[114],F};function Jy(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function Zy(t){return t.currentSessionId}function e1(t){return t.newSessionDraft}function t1(t){return t.worktreeMetadata}function s1(t){return t.availableWorktrees}function n1(t){return!t.startsWith("remotes/")}function r1(t){return t.startsWith("remotes/")}function o1(t){return t.replace(/^remotes\//,"")}function i1(t){return t.name}const ga=2e4,a1=(t,e)=>{if(!t)return 1;let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(n+=1,n>e))return n;return n},go=(t,e)=>Tp(Ep.getState().dictionary,t,e),l1=t=>{const n=(t instanceof Error?t.message:String(t??"")).toLowerCase();return n.includes("file not found")||n.includes("not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")?"missing":"unreadable"},c1=async(t,e,n)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});n?.directory&&r.set("directory",n.directory);const i=await bs(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},xf=async(t,e,n)=>{if(Ap(e)||Pp(e)||Dp(e))return{ok:!0};try{const r=await c1(t,e,n);return Ip(r)?{ok:!1,reason:"binary"}:a1(r,ga)>ga?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:l1(r)}}},bf=t=>{if(t==="too-large"){const e=ga.toLocaleString(ju());return go("contextFileOpen.failure.tooLarge",{count:e})}return go(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},xc=8;let xa=null;const yf=t=>{xa={x:t.clientX,y:t.clientY}},wf=t=>{const e=xa;return xa=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=xc&&Math.abs(t.clientY-e.y)<=xc},yr=t=>Array.from(t.types).includes("Files"),d1=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},u1=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),hs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},sl=(t,e)=>{const n=hs(e),r=hs(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},f1=(t,e)=>{const n=sl(t,e);if(n!==".")return n;const r=hs(t);return r.split("/").filter(Boolean).pop()??r},m1=t=>{const e=hs(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},h1=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),p1=new Set(["node_modules"]),g1=t=>p1.has(t),x1=t=>{const e=hs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},b1=8,gn=new Map,nl=t=>JSON.stringify([Qt(),t]),y1=t=>{const e=nl(t),n=gn.get(e);return n?(n.touchedAt=Date.now(),gn.delete(e),gn.set(e,n),n):null},Bi=t=>{const e=nl(t),n=gn.get(e);if(n)return n.touchedAt=Date.now(),n;if(gn.size>=b1){const i=gn.keys().next().value;i!==void 0&&gn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return gn.set(e,r),r},vf=(t,e)=>s.jsx(Ka,{filePath:t,extension:e}),w1=t=>{const e=tt.c(3),{status:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const i=r[n];let o;return e[1]!==i?(o=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},v1=t=>{const e=tt.c(90),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:d,isDropTarget:u,canUpload:m,permissions:f,downloadFile:p,onSelect:y,onToggle:x,onRevealPath:k,onOpenDialog:w,onSetDropTarget:h,onDropFiles:g,onPickFiles:j}=t,{t:b}=Nt(),S=n.type==="directory";let C;e[0]!==S||e[1]!==n.path?(C=S?n.path:m1(n.path),e[0]=S,e[1]=n.path,e[2]=C):C=e[2];const v=C,{canRename:E,canCreateFile:R,canCreateFolder:A,canDelete:O,canReveal:B}=f,T=!S&&!!p,M=B&&!l,L=S&&m,W=E||R||A||L||O||T||M,[$,P]=c.useState(!1),[D,I]=c.useState(!1);let X;e[3]!==W?(X=pe=>{W&&(pe?.preventDefault(),I(!0))},e[3]=W,e[4]=X):X=e[4];const Z=X;let ne;e[5]!==S||e[6]!==n||e[7]!==y||e[8]!==x?(ne=()=>{S?x(n.path):y(n)},e[5]=S,e[6]=n,e[7]=y,e[8]=x,e[9]=ne):ne=e[9];const ue=ne;let se;e[10]===Symbol.for("react.memo_cache_sentinel")?(se=pe=>{pe.stopPropagation(),I(!1),P(!0)},e[10]=se):se=e[10];const xe=se;let ie;e[11]!==R||e[12]!==A||e[13]!==O||e[14]!==E||e[15]!==M||e[16]!==L||e[17]!==p||e[18]!==l||e[19]!==S||e[20]!==n||e[21]!==w||e[22]!==j||e[23]!==k||e[24]!==b?(ie=pe=>{const{Item:le,Separator:_e}=pe;return s.jsxs(s.Fragment,{children:[E&&s.jsxs(le,{onClick:Fe=>{Fe.stopPropagation(),w("rename",n)},children:[s.jsx(_,{name:"edit",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.rename")]}),s.jsxs(le,{onClick:Fe=>{Fe.stopPropagation(),cr(n.path).then(Me=>{if(Me.ok){Ke.success(b("sidebarFilesTree.toast.pathCopied"));return}Ke.error(b("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(_,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.copyPath")]}),!S&&p&&s.jsxs(le,{onClick:Fe=>{Fe.stopPropagation(),p(n.path).catch(Me=>{console.error("Download failed:",Me),Ke.error(b("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(_,{name:"download",className:"mr-2 h-4 w-4"})," ",b(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),M&&s.jsxs(le,{onClick:Fe=>{Fe.stopPropagation(),k(n.path)},children:[s.jsx(_,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",b(Rp())]}),S&&(R||A||L)&&s.jsxs(s.Fragment,{children:[s.jsx(_e,{}),R&&s.jsxs(le,{onClick:Fe=>{Fe.stopPropagation(),w("createFile",n)},children:[s.jsx(_,{name:"file-add",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.newFile")]}),A&&s.jsxs(le,{onClick:Fe=>{Fe.stopPropagation(),w("createFolder",n)},children:[s.jsx(_,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.newFolder")]}),L&&s.jsxs(le,{onClick:Fe=>{Fe.stopPropagation(),j(n.path)},children:[s.jsx(_,{name:"upload-2",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.uploadFiles")]})]}),O&&s.jsxs(s.Fragment,{children:[s.jsx(_e,{}),s.jsxs(le,{onClick:Fe=>{Fe.stopPropagation(),w("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",b("sidebarFilesTree.menu.delete")]})]})]})},e[11]=R,e[12]=A,e[13]=O,e[14]=E,e[15]=M,e[16]=L,e[17]=p,e[18]=l,e[19]=S,e[20]=n,e[21]=w,e[22]=j,e[23]=k,e[24]=b,e[25]=ie):ie=e[25];const Re=ie;let be;e[26]!==n.path||e[27]!==r?(be=pe=>{yf(pe);const le=sl(r,n.path);!le||le==="."||(pe.dataTransfer.setData("application/x-openchamber-file-path",le),pe.dataTransfer.effectAllowed="copy")},e[26]=n.path,e[27]=r,e[28]=be):be=e[28];const fe=be;let ke;e[29]!==ue?(ke=pe=>{wf(pe)&&ue()},e[29]=ue,e[30]=ke):ke=e[30];const H=ke;let J;e[31]!==m||e[32]!==h||e[33]!==v?(J=pe=>{!m||!v||!yr(pe.dataTransfer)||(pe.preventDefault(),pe.stopPropagation(),pe.dataTransfer.dropEffect="copy",h(v))},e[31]=m,e[32]=h,e[33]=v,e[34]=J):J=e[34];const ce=J;let je;e[35]!==m||e[36]!==h||e[37]!==v?(je=pe=>{!m||!v||!yr(pe.dataTransfer)||pe.relatedTarget instanceof Node&&pe.currentTarget.contains(pe.relatedTarget)||(pe.stopPropagation(),h(null))},e[35]=m,e[36]=h,e[37]=v,e[38]=je):je=e[38];const G=je;let we;e[39]!==m||e[40]!==g||e[41]!==v?(we=pe=>{!m||!v||!yr(pe.dataTransfer)||(pe.preventDefault(),pe.stopPropagation(),g(v,pe.dataTransfer))},e[39]=m,e[40]=g,e[41]=v,e[42]=we):we=e[42];const Te=we;let he;e[43]===Symbol.for("react.memo_cache_sentinel")?(he={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[43]=he):he=e[43];let re;e[44]!==Z||e[45]!==G||e[46]!==ce||e[47]!==Te?(re=s.jsx("div",{className:"group relative flex items-center typography-meta",style:he,onContextMenu:Z,onDragEnter:ce,onDragOver:ce,onDragLeave:G,onDrop:Te}),e[44]=Z,e[45]=G,e[46]=ce,e[47]=Te,e[48]=re):re=e[48];const ge=u?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let q;e[49]!==ge?(q=Ee("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",ge),e[49]=ge,e[50]=q):q=e[50];let z;e[51]!==S||e[52]!==i||e[53]!==n.extension||e[54]!==n.path?(z=S?i?s.jsx(_,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(_,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):vf(n.path,n.extension),e[51]=S,e[52]=i,e[53]=n.extension,e[54]=n.path,e[55]=z):z=e[55];let ee;e[56]!==n.name||e[57]!==n.path?(ee=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[56]=n.name,e[57]=n.path,e[58]=ee):ee=e[58];let de;e[59]!==S||e[60]!==a?(de=!S&&a&&s.jsx(w1,{status:a}),e[59]=S,e[60]=a,e[61]=de):de=e[61];let Y;e[62]!==d||e[63]!==S?(Y=S&&d&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[d.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",d.modified]}),d.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",d.added]})]}),e[62]=d,e[63]=S,e[64]=Y):Y=e[64];let U;e[65]!==Z||e[66]!==H||e[67]!==fe||e[68]!==ue||e[69]!==q||e[70]!==z||e[71]!==ee||e[72]!==de||e[73]!==Y?(U=s.jsxs("button",{type:"button",onClick:ue,onContextMenu:Z,draggable:!0,onDragStart:fe,onDragEnd:H,className:q,children:[z,ee,de,Y]}),e[65]=Z,e[66]=H,e[67]=fe,e[68]=ue,e[69]=q,e[70]=z,e[71]=ee,e[72]=de,e[73]=Y,e[74]=U):U=e[74];let F;e[75]!==$||e[76]!==W||e[77]!==Re||e[78]!==b?(F=W&&s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:s.jsxs(Ls,{open:$,onOpenChange:P,children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Fs,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:xe,title:b("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":b("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(_,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:b("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(_s,{align:"end",side:"bottom",onCloseAutoFocus:()=>P(!1),children:Re({Item:Ht,Separator:Es})})]})}),e[75]=$,e[76]=W,e[77]=Re,e[78]=b,e[79]=F):F=e[79];let V;e[80]!==re||e[81]!==U||e[82]!==F?(V=s.jsxs(qd,{render:re,children:[U,F]}),e[80]=re,e[81]=U,e[82]=F,e[83]=V):V=e[83];let oe;e[84]!==Re?(oe=s.jsx(Gd,{className:"min-w-[180px]",children:Re({Item:Xn,Separator:Yi})}),e[84]=Re,e[85]=oe):oe=e[85];let ae;return e[86]!==D||e[87]!==V||e[88]!==oe?(ae=s.jsxs(Yd,{open:D,onOpenChange:I,children:[V,oe]}),e[86]=D,e[87]=V,e[88]=oe,e[89]=ae):ae=e[89],ae},S1=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles&&t.onPickFiles===e.onPickFiles,j1=c.memo(v1,S1),k1=t=>{const e=tt.c(6),{visible:n}=t,r=n===void 0?!0:n,i=Tn(N1),o=dr();let l;e[0]!==o||e[1]!==i?(l=JSON.stringify([i,o]),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==l||e[4]!==r?(a=s.jsx(C1,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},C1=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:n}=Nt(),{files:r,runtime:i}=wn(),o=Vm(i.platform),l=dr()??"",a=hs(l.trim()),d=nl(a),u=Um(),m=Hm(),f=_d(Pe=>Pe.searchFiles),p=Ne(Pe=>Pe.openContextFile),y=$a(t?l:null),[x,k]=c.useState(""),w=ku(x,200),h=c.useRef(null),[g,j]=c.useState([]),[b,S]=c.useState(!1),[C,v]=c.useState(null),[E,R]=c.useState({}),[A,O]=c.useState({}),B=c.useRef(new Set),T=c.useMemo(()=>new _x,[]);c.useEffect(()=>()=>T.clear(),[T]);const M=c.useRef(null);c.useEffect(()=>{if(v(null),!a){R({}),O({}),B.current=new Set;return}const Pe=y1(a);Pe?(R({...Pe.childrenByDir}),O({...Pe.loadErrorsByDir}),B.current=new Set(Pe.loadedDirs)):(R({}),O({}),B.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const Pe=Bi(a);Pe.childrenByDir=E},[a,E]),c.useEffect(()=>{if(!a)return;const Pe=Bi(a);Pe.loadErrorsByDir=A},[a,A]),c.useEffect(()=>{if(!a)return;const Pe=Bi(a);Pe.loadedDirs=new Set(B.current)},[a,E,A]),c.useEffect(()=>()=>{if(!a)return;const Pe=gn.get(d);Pe&&Pe.loadedDirs.size===0&&Object.keys(Pe.childrenByDir).length===0&&gn.delete(d)},[d,a]);const L=c.useMemo(()=>[],[]),W=c.useMemo(()=>[],[]),$=pn(Pe=>a?Pe.byRoot[a]?.expandedPaths??L:L),P=c.useMemo(()=>new Set($),[$]),D=pn(Pe=>a?Pe.byRoot[a]?.selectedPath??null:null),I=pn(Pe=>Pe.setSelectedPath),X=pn(Pe=>Pe.addOpenPath),Z=pn(Pe=>Pe.removeOpenPathsByPrefix),ne=pn(Pe=>Pe.toggleExpandedPath),ue=pn(Pe=>Pe.collapseAllExpandedPaths),se=Ne(Pe=>a?Pe.contextPanelByDirectory[a]?.tabs??W:W),xe=c.useMemo(()=>new Set(se.map(Pe=>Pe.mode==="file"?Pe.targetPath:null).filter(Pe=>typeof Pe=="string"&&Pe.length>0).map(Pe=>hs(Pe))),[se]),[ie,Re]=c.useState(null),[be,fe]=c.useState(null),[ke,H]=c.useState(""),[J,ce]=c.useState(!1),je=!!r.writeFile,G=!!r.createDirectory,we=!!r.rename,Te=!!r.delete,he=!!r.revealPath,re=c.useMemo(()=>({canRename:we,canCreateFile:je,canCreateFolder:G,canDelete:Te,canReveal:he}),[we,je,G,Te,he]),ge=c.useCallback(Pe=>{r.revealPath&&r.revealPath(Pe).catch(()=>{Ke.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),q=c.useCallback((Pe,Ge)=>{Re(Pe),fe(Ge),H(Pe==="rename"&&Ge.name||""),ce(!1)},[]),z=c.useCallback((Pe,Ge)=>{const at=Ge.filter(ze=>ze&&typeof ze.name=="string"&&ze.name.length>0).filter(ze=>u||!ze.name.startsWith(".")).filter(ze=>m||!g1(ze.name)).map(ze=>{const ft=ze.name,te=hs(ze.path||""),me=te?h1(te)?te:hs(`${Pe}/${te}`):hs(`${Pe}/${ft}`),De=ze.isDirectory?"directory":"file",K=De==="file"&&ft.includes(".")?ft.split(".").pop()?.toLowerCase():void 0;return{name:ft,path:me,type:De,extension:K}});return u1(at)},[m,u]),ee=c.useCallback(async(Pe,Ge,at=!1)=>{if(!e.current||Ge?.())return;const ze=hs(Pe.trim());if(!ze||!at&&B.current.has(ze))return;const ft=Qt();return T.run(ze,async te=>{const me=()=>!te()||Qt()!==ft;try{const De=r.listDirectory?(await r.listDirectory(ze)).entries:await dn.listLocalDirectory(ze);if(me())return;const K=z(ze,De);B.current=new Set(B.current),B.current.add(ze),O(Se=>{if(!Se[ze])return Se;const Ve={...Se};return delete Ve[ze],Ve}),R(Se=>Se[ze]&&Lx(Se[ze],K)?Se:{...Se,[ze]:K})}catch(De){if(me())return;const K=De instanceof Error?De.message:String(De??"");console.error("Failed to load sidebar directory:",De),O(Se=>({...Se,[ze]:K}))}},at)},[T,r,z]),de=c.useCallback(async()=>{if(!a)return;M.current?.abort();const Pe=new AbortController;M.current=Pe,T.clear();try{const at=(pn.getState().byRoot[a]?.expandedPaths??[]).map(te=>hs(te)).filter(te=>!!te&&te!==a&&te.startsWith(`${a}/`)),ze=[a,...at];B.current=new Set(B.current);for(const te of ze)B.current.delete(te);O(te=>{if(Object.keys(te).length===0)return te;const me={...te};let De=!1;for(const K of ze)K in me&&(delete me[K],De=!0);return De?me:te});const ft=()=>Pe.signal.aborted;await ee(a,ft);for(let te=0;te<at.length&&!Pe.signal.aborted;te+=3){const me=at.slice(te,te+3);await Promise.all(me.map(De=>ee(De,ft)))}}catch(Ge){if(Pe.signal.aborted)return;console.error("Failed to refresh sidebar tree:",Ge)}finally{M.current===Pe&&(M.current=null)}},[T,ee,a]),Y=c.useCallback(async Pe=>{if(!Pe){await de();return}const Ge=hs(Pe);B.current=new Set(B.current),B.current.delete(Ge),await ee(Ge,void 0,!0)},[ee,de]);c.useEffect(()=>{a&&(M.current?.abort(),B.current=new Set,T.clear(),O({}),R(Pe=>Object.keys(Pe).length===0?Pe:{}),ee(a))},[T,ee,a,u,m]),c.useEffect(()=>{if(!t||!a||$.length===0)return;const Pe=$.map(ze=>hs(ze)).filter(ze=>!!ze&&ze!==a&&ze.startsWith(`${a}/`)&&!B.current.has(ze)&&!T.has(ze)).sort((ze,ft)=>ze.split("/").length-ft.split("/").length);if(Pe.length===0)return;let Ge=!1;const at=()=>Ge;return(async()=>{for(let ze=0;ze<Pe.length&&!Ge;ze+=3){const ft=Pe.slice(ze,ze+3);await Promise.all(ft.map(te=>ee(te,at)))}})(),()=>{Ge=!0}},[T,$,ee,a,t]);const U=c.useRef(t);c.useEffect(()=>{const Pe=t&&!U.current;U.current=t,Pe&&de()},[de,t]),c.useEffect(()=>{if(!t)return;if(!l){j([]),S(!1);return}const Pe=w.trim();if(!Pe){j([]),S(!1);return}let Ge=!1;return S(!0),f(l,Pe,150,{includeHidden:u,respectGitignore:!m,type:"file"}).then(at=>{if(Ge)return;const ft=at.filter(te=>m||!x1(te.path)).map(te=>({name:te.name,path:hs(te.path),type:"file",extension:te.extension,relativePath:te.relativePath}));j(ft)}).catch(()=>{Ge||j([])}).finally(()=>{Ge||S(!1)}),()=>{Ge=!0}},[l,w,f,u,m,t]);const F=c.useMemo(()=>{const Pe=new Map;if(!y?.files)return Pe;for(const Ge of y.files)Ge.index==="A"||Ge.working_dir==="?"?Pe.set(Ge.path,"git-added"):Ge.index==="D"?Pe.set(Ge.path,"git-deleted"):(Ge.index==="M"||Ge.working_dir==="M")&&Pe.set(Ge.path,"git-modified");return Pe},[y]),V=c.useMemo(()=>{const Pe=new Map;if(!y?.files||!a)return Pe;for(const Ge of y.files){const at=Ge.index==="M"||Ge.working_dir==="M",ze=Ge.index==="A"||Ge.working_dir==="?";if(!at&&!ze)continue;const ft=Ge.path.split("/");if(ft.length<=1)continue;let te=a;for(let me=0;me<ft.length-1;me++){te=`${te}/${ft[me]}`;let De=Pe.get(te);De||(De={modified:0,added:0},Pe.set(te,De)),at&&De.modified++,ze&&De.added++}}return Pe},[y,a]),oe=c.useCallback(Pe=>{if(xe.has(Pe))return"open";if(F.size===0)return null;const Ge=Pe.startsWith(a+"/")?Pe.slice(a.length+1):Pe;return F.get(Ge)??null},[xe,F,a]),ae=c.useCallback(Pe=>{if(V.size===0)return null;const Ge=V.get(Pe);return Ge&&Ge.modified+Ge.added>0?Ge:null},[V]),pe=c.useCallback(async Pe=>{if(!a)return;const Ge=await xf(r,Pe.path,{directory:a});if(!Ge.ok){Ke.error(bf(Ge.reason));return}I(a,Pe.path),X(a,Pe.path),p(a,Pe.path)},[X,r,p,a,I]),le=c.useCallback(async Pe=>{const Ge=hs(Pe);a&&(ne(a,Ge),B.current.has(Ge)||await ee(Ge))},[ee,a,ne]),{canUpload:_e,uploadingDirectory:Fe,uploadFiles:Me,pickFiles:Ae,uploadElements:Q}=$x({root:a,refreshDirectory:Y}),Ce=Fe!==null,Be=Fe??C,Le=c.useCallback((Pe,Ge)=>{const at=d1(Ge);at.length!==0&&(v(null),Me(Pe,at))},[Me]),Je=c.useCallback(Pe=>{!_e||Ce||!a||!yr(Pe.dataTransfer)||(Pe.preventDefault(),Pe.dataTransfer.dropEffect="copy",v(a))},[_e,Ce,a]),ot=c.useCallback(Pe=>{yr(Pe.dataTransfer)&&(Pe.relatedTarget instanceof Node&&Pe.currentTarget.contains(Pe.relatedTarget)||v(null))},[]),et=c.useCallback(Pe=>{!_e||Ce||!a||!yr(Pe.dataTransfer)||(Pe.preventDefault(),Le(a,Pe.dataTransfer))},[_e,Le,Ce,a]),it=c.useCallback(async Pe=>{if(Pe?.preventDefault(),!be||!ie)return;ce(!0);const Ge=()=>ce(!1),at=()=>Re(null);if(ie==="createFile"){if(!ke.trim()){Ke.error(n("sidebarFilesTree.toast.filenameRequired")),Ge();return}if(!r.writeFile){Ke.error(n("sidebarFilesTree.toast.writeNotSupported")),Ge();return}const ze=be.path,ft=ze?`${ze}/`:"",te=hs(`${ft}${ke.trim()}`);await r.writeFile(te,"").then(async me=>{me.success&&(Ke.success(n("sidebarFilesTree.toast.fileCreated")),await Y(ze)),at()}).catch(()=>Ke.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ge);return}if(ie==="createFolder"){if(!ke.trim()){Ke.error(n("sidebarFilesTree.toast.folderNameRequired")),Ge();return}const ze=be.path,ft=ze?`${ze}/`:"",te=hs(`${ft}${ke.trim()}`);await r.createDirectory(te).then(async me=>{me.success&&(Ke.success(n("sidebarFilesTree.toast.folderCreated")),await Y(ze)),at()}).catch(()=>Ke.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ge);return}if(ie==="rename"){if(!ke.trim()){Ke.error(n("sidebarFilesTree.toast.nameRequired")),Ge();return}if(!r.rename){Ke.error(n("sidebarFilesTree.toast.renameNotSupported")),Ge();return}const ze=be.path,ft=ze.split("/").slice(0,-1).join("/"),te=ft?`${ft}/`:"",me=hs(`${te}${ke.trim()}`);await r.rename(ze,me).then(async De=>{De.success&&(Ke.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await Y(ft),a&&Z(a,ze),(D===ze||D&&D.startsWith(`${ze}/`))&&I(a,null)),at()}).catch(()=>Ke.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ge);return}if(ie==="delete"){if(!r.delete){Ke.error(n("sidebarFilesTree.toast.deleteNotSupported")),Ge();return}const ze=be.path,ft=ze.split("/").slice(0,-1).join("/");await r.delete(ze).then(async te=>{te.success&&(Ke.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await Y(ft),a&&Z(a,ze),(D===ze||D&&D.startsWith(ze+"/"))&&I(a,null)),at()}).catch(()=>Ke.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ge);return}Ge()},[ie,be,ke,r,Y,Z,a,D,I,n]);function ht(Pe,Ge){const at=E[Pe]??[];return at.map((ze,ft)=>{const te=ze.type==="directory",me=te&&P.has(ze.path),De=D===ze.path,K=ft===at.length-1;return s.jsxs("li",{className:"relative",children:[Ge>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),K&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(j1,{node:ze,root:a,isExpanded:me,isActive:De,isBrowserClient:o,status:te?void 0:oe(ze.path),badge:te?ae(ze.path):void 0,isDropTarget:te&&Be===ze.path,canUpload:_e&&!Ce,permissions:re,downloadFile:r.downloadFile,onSelect:pe,onToggle:le,onRevealPath:ge,onOpenDialog:q,onSetDropTarget:v,onDropFiles:Le,onPickFiles:Ae}),te&&me&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[A[ze.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:A[ze.path],children:A[ze.path]}),s.jsxs(ct,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Y(ze.path)},children:[s.jsx(_,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,ht(ze.path,Ge+1)]})]},ze.path)})}const st=!!(a&&E[a]),mt=a?A[a]:null,kt=Be?f1(a,Be):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[je&&s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>q("createFile",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFileTitle"),"aria-label":n("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(_,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFileTitle")})]}),G&&s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>q("createFolder",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFolderTitle"),"aria-label":n("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(_,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFolderTitle")})]}),_e&&s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>Ae(a),disabled:!a||Ce,className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":n("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(_,{name:"upload-2",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>{de()},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.refreshTitle"),"aria-label":n("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(_,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>{a&&ue(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":n("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(_,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(_,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(An,{ref:h,value:x,onChange:Pe=>k(Pe.target.value),placeholder:n("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),x.trim().length>0?s.jsx("button",{type:"button","aria-label":n("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{k(""),h.current?.focus()},children:s.jsx(_,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(En,{outerClassName:"h-full min-h-0",className:Ee("p-2",Be===a&&"bg-interactive-selection/10"),onDragEnter:Je,onDragOver:Je,onDragLeave:ot,onDrop:et,children:s.jsx("ul",{className:"flex flex-col",children:b?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(_,{name:"loader-4",className:"h-4 w-4 animate-spin"}),n("sidebarFilesTree.state.searching")]}):g.length>0?g.map(Pe=>{const Ge=D===Pe.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>pe(Pe),draggable:!0,onDragStart:at=>{yf(at);const ze=Pe.relativePath||sl(a??"",Pe.path);!ze||ze==="."||(at.dataTransfer.setData("application/x-openchamber-file-path",ze),at.dataTransfer.effectAllowed="copy")},onDragEnd:at=>{wf(at)&&pe(Pe)},className:Ee("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",Ge?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:Pe.path,children:[vf(Pe.path,Pe.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:Pe.relativePath??Pe.path})]})},Pe.path)}):mt?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:mt}),s.jsxs(ct,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{de()},children:[s.jsx(_,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):st&&a?ht(a,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("sidebarFilesTree.state.loading")})})}),Be?s.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(_,{name:Ce?"loader-4":"folder-received",className:Ee("size-4 flex-shrink-0",Ce&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:kt,children:n(Ce?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:kt})})]}):null]}),Q,s.jsx(Ps,{open:!!ie,onOpenChange:Pe=>!Pe&&Re(null),children:s.jsxs(Ds,{children:[s.jsxs(sn,{children:[s.jsxs(Us,{children:[ie==="createFile"&&n("sidebarFilesTree.dialog.createFile.title"),ie==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.title"),ie==="rename"&&n("sidebarFilesTree.dialog.rename.title"),ie==="delete"&&n("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Hs,{children:[ie==="createFile"&&n("sidebarFilesTree.dialog.createFile.description",{path:be?.path??n("sidebarFilesTree.dialog.rootFallback")}),ie==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.description",{path:be?.path??n("sidebarFilesTree.dialog.rootFallback")}),ie==="rename"&&n("sidebarFilesTree.dialog.rename.description",{name:be?.name??""}),ie==="delete"&&n("sidebarFilesTree.dialog.delete.description",{name:be?.name??""})]})]}),ie!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(An,{value:ke,onChange:Pe=>H(Pe.target.value),placeholder:n(ie==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:Pe=>{Pe.key==="Enter"&&it()},autoFocus:!0})}),s.jsxs(zn,{children:[s.jsx(ct,{variant:"outline",onClick:()=>Re(null),disabled:J,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(ct,{variant:ie==="delete"?"destructive":"default",onClick:()=>{it()},disabled:J||ie!=="delete"&&!ke.trim(),children:J?s.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):n(ie==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function N1(t){return t.runtimeKey}const bc=60,A1=t=>{try{return new URL(t).origin}catch{return""}},Fi=new Set,Sf=no()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=A1(n);!i||!r||e().byOrigin[i]||Fi.has(i)||(Fi.add(i),br("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const d={...a.byOrigin,[i]:l},u=Object.keys(d);if(u.length<=bc)return{byOrigin:d};for(const m of u.slice(0,u.length-bc))delete d[m];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{Fi.delete(i)}))}})),rl=t=>t,ba=t=>{const e=rl(t).type;return typeof e=="string"?e:""},P1=t=>{const e=rl(t).tool;return typeof e=="string"?e:""},D1=t=>{const e=rl(t).text;return typeof e=="string"?e:""},I1=t=>{const e=ba(t);return e==="tool"?P1(t).trim().toLowerCase()||"tool":e||"unknown"},T1=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=I1(n);e.includes(r)||e.push(r)}return e.join(" + ")},E1=t=>t.replace(/\s+/g," ").trim(),R1=t=>{for(const n of t)if(ba(n)==="text"){const r=E1(D1(n));if(r.length===0)continue;return r}const e=t.filter(n=>ba(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},M1=(t,e,n)=>`${n(t)} / ${n(e)}`,O1=t=>{if(t==="12h")return!0;if(t==="24h")return!1},B1=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=O1(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},ya={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},To={user:0,assistant:0,tool:0,other:0},Bn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,yc=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(m=>m.tokens!==void 0)?.tokens;if(typeof n=="number")return{...ya,total:Bn(n)};if(!n||typeof n!="object")return ya;const r=n,i=Bn(r.input),o=Bn(r.output),l=Bn(r.reasoning),a=Bn(r.cache?.read),d=Bn(r.cache?.write),u=Bn(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:i+o+l+a+d}},F1=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Ks=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Ks(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Ks(n),0):0,_1=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...To,assistant:Ks(n.text)+Ks(n.content)};const i=F1(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Ks(n.input)+Ks(n.output)+Ks(n.error)+Ks(n.call?.input)+Ks(n.call?.output)+Ks(n.call?.error)+Ks(n.raw)+Math.round(Ks(n.metadata)*.25)+Math.round(Ks(n.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},wc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),L1=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",$1=(t,e)=>{if(t.length===0)return{...To};const n=t.reduce((r,i)=>{const o=L1(i);let l={...To};for(const a of i.parts)l=wc(l,_1(a,o));return wc(r,l)},{...To});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},qn=t=>t.toLocaleString(ju()),z1=(t,e)=>!t||!Number.isFinite(t)?"-":yu(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),W1=(t,e,n)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===n);return{providerName:r?.name||e||"-",modelName:i?.name||n||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},K1=()=>{const t=tt.c(209),{t:e}=Nt(),n=Ne(V1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),d=c.useRef(null),u=rt(U1),m=rt(H1),f=Cu(m??void 0),p=Mp(u??"",m??void 0),y=Yt(G1);let x;t[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),o(q1),a(null)},t[1]=x):x=t[1];let k;t[2]!==m||t[3]!==u?(k=[m,u],t[2]=m,t[3]=u,t[4]=k):k=t[4],c.useEffect(x,k);let w,h;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},h=[],t[5]=w,t[6]=h):(w=t[5],h=t[6]),c.useEffect(w,h);let g;t[7]===Symbol.for("react.memo_cache_sentinel")?(g=async(He,Ue)=>{(await cr(Ue)).ok?(a(He),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a(Qe=>Qe===He?null:Qe),d.current=null},2e3)):a(null)},t[7]=g):g=t[7];const j=g;let b;t[8]!==u||t[9]!==f?(b=u?f.find(He=>He.id===u)??null:null,t[8]=u,t[9]=f,t[10]=b):b=t[10];const S=b;let C,v,E,R,A,O,B;if(t[11]!==p){C=p.filter(Y1),B=p.filter(Q1);const He=Op(p.map(X1));E=He?p[He.index]??null:null,R=He?.state==="compacted";let Ue;t[19]!==E?(O=E?yc(E):ya,Ue=Bp({input:O.input,cache:{read:O.cacheRead,write:O.cacheWrite}}),t[19]=E,t[20]=Ue,t[21]=O):(Ue=t[20],O=t[21]),v=Ue,A=C.reduce(J1,0),t[11]=p,t[12]=C,t[13]=v,t[14]=E,t[15]=R,t[16]=A,t[17]=O,t[18]=B}else C=t[12],v=t[13],E=t[14],R=t[15],A=t[16],O=t[17],B=t[18];const T=A,M=E?.info??null,L=y,W=M?.providerID||"",$=M?.modelID||"";let P;t[22]!==$||t[23]!==L||t[24]!==W?(P=W1(L,W,$),t[22]=$,t[23]=L,t[24]=W,t[25]=P):P=t[25];const D=P,I=D.contextLimit,X=R?null:I&&I>0?Math.min(999,O.total/I*100):0;let Z;if(t[26]!==p){const He=[...p].reverse().find(Z1),Ue=He?.info.role==="system"?He.info.text:"";Z=$1(p,Ue),t[26]=p,t[27]=Z}else Z=t[27];const ne=Z,ue=ne.user,se=ne.assistant,xe=ne.tool,ie=Math.max(0,O.input-ue-se-xe),Re=ue+se+xe+ie,be=p[0]?.info?.time?.created,fe=p.length>0?p[p.length-1]?.info?.time?.created:null;let ke;t[28]!==S?.title||t[29]!==e?(ke=S?.title||e("contextSidebar.session.untitled"),t[28]=S?.title,t[29]=e,t[30]=ke):ke=t[30];const H=S?.time?.created??be??null,J=fe??S?.time?.created??null;let ce;t[31]!==se||t[32]!==ie||t[33]!==xe||t[34]!==ue?(ce={user:ue,assistant:se,tool:xe,other:ie},t[31]=se,t[32]=ie,t[33]=xe,t[34]=ue,t[35]=ce):ce=t[35];let je;t[36]!==C.length||t[37]!==Re||t[38]!==v||t[39]!==I||t[40]!==D||t[41]!==p.length||t[42]!==ke||t[43]!==H||t[44]!==J||t[45]!==ce||t[46]!==O||t[47]!==T||t[48]!==X||t[49]!==B.length?(je={sessionTitle:ke,messagesCount:p.length,userMessagesCount:B.length,assistantMessagesCount:C.length,createdAt:H,lastActivityAt:J,providerModel:D,tokenBreakdown:O,usagePercent:X,cacheHitRate:v,totalAssistantCost:T,contextLimit:I,breakdown:ce,breakdownTotal:Re},t[36]=C.length,t[37]=Re,t[38]=v,t[39]=I,t[40]=D,t[41]=p.length,t[42]=ke,t[43]=H,t[44]=J,t[45]=ce,t[46]=O,t[47]=T,t[48]=X,t[49]=B.length,t[50]=je):je=t[50];const G=je;if(!u){let He;t[51]!==e?(He=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=He):He=t[52];let Ue;return t[53]!==He?(Ue=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:He}),t[53]=He,t[54]=Ue):Ue=t[54],Ue}let we;t[55]!==e?(we=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=we):we=t[56];let Te;t[57]!==we||t[58]!==G.breakdown.user?(Te={key:"user",label:we,value:G.breakdown.user,color:"var(--status-success)"},t[57]=we,t[58]=G.breakdown.user,t[59]=Te):Te=t[59];let he;t[60]!==e?(he=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=he):he=t[61];let re;t[62]!==he||t[63]!==G.breakdown.assistant?(re={key:"assistant",label:he,value:G.breakdown.assistant,color:"var(--primary-base)"},t[62]=he,t[63]=G.breakdown.assistant,t[64]=re):re=t[64];let ge;t[65]!==e?(ge=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=ge):ge=t[66];let q;t[67]!==ge||t[68]!==G.breakdown.tool?(q={key:"tool",label:ge,value:G.breakdown.tool,color:"var(--status-warning)"},t[67]=ge,t[68]=G.breakdown.tool,t[69]=q):q=t[69];let z;t[70]!==e?(z=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=z):z=t[71];let ee;t[72]!==z||t[73]!==G.breakdown.other?(ee={key:"other",label:z,value:G.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=z,t[73]=G.breakdown.other,t[74]=ee):ee=t[74];let de;t[75]!==Te||t[76]!==re||t[77]!==q||t[78]!==ee?(de=[Te,re,q,ee],t[75]=Te,t[76]=re,t[77]=q,t[78]=ee,t[79]=de):de=t[79];const Y=de;let U;t[80]!==G.sessionTitle?(U=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:G.sessionTitle}),t[80]=G.sessionTitle,t[81]=U):U=t[81];let F;t[82]!==G.providerModel.modelName||t[83]!==G.providerModel.providerName?(F=s.jsxs("span",{children:[G.providerModel.providerName," / ",G.providerModel.modelName]}),t[82]=G.providerModel.modelName,t[83]=G.providerModel.providerName,t[84]=F):F=t[84];let V;t[85]!==n||t[86]!==G.createdAt?(V=G.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:z1(G.createdAt,n)})]}),t[85]=n,t[86]=G.createdAt,t[87]=V):V=t[87];let oe;t[88]!==F||t[89]!==V?(oe=s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[F,V]}),t[88]=F,t[89]=V,t[90]=oe):oe=t[90];let ae;t[91]!==U||t[92]!==oe?(ae=s.jsxs("div",{className:"mb-6",children:[U,oe]}),t[91]=U,t[92]=oe,t[93]=ae):ae=t[93];let pe;t[94]!==e?(pe=e("contextSidebar.section.context"),t[94]=e,t[95]=pe):pe=t[95];let le;t[96]!==pe?(le=s.jsx("span",{className:"typography-micro text-muted-foreground",children:pe}),t[96]=pe,t[97]=le):le=t[97];let _e;t[98]!==G.tokenBreakdown.total||t[99]!==G.usagePercent?(_e=G.usagePercent===null?"—":qn(G.tokenBreakdown.total),t[98]=G.tokenBreakdown.total,t[99]=G.usagePercent,t[100]=_e):_e=t[100];let Fe;t[101]!==G.contextLimit?(Fe=G.contextLimit?` / ${qn(G.contextLimit)}`:"",t[101]=G.contextLimit,t[102]=Fe):Fe=t[102];let Me;t[103]!==_e||t[104]!==Fe?(Me=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[_e,Fe]}),t[103]=_e,t[104]=Fe,t[105]=Me):Me=t[105];let Ae;t[106]!==le||t[107]!==Me?(Ae=s.jsxs("div",{className:"flex items-baseline justify-between",children:[le,Me]}),t[106]=le,t[107]=Me,t[108]=Ae):Ae=t[108];let Q;t[109]!==G.usagePercent?(Q=G.usagePercent!==null&&G.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,G.usagePercent)}%`,backgroundColor:G.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=G.usagePercent,t[110]=Q):Q=t[110];let Ce;t[111]!==Q?(Ce=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Q}),t[111]=Q,t[112]=Ce):Ce=t[112];let Be;t[113]!==e||t[114]!==G.usagePercent?(Be=G.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:G.usagePercent.toFixed(1)}),t[113]=e,t[114]=G.usagePercent,t[115]=Be):Be=t[115];let Le;t[116]!==Be?(Le=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Be}),t[116]=Be,t[117]=Le):Le=t[117];let Je;t[118]!==Ae||t[119]!==Ce||t[120]!==Le?(Je=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ae,Ce,Le]}),t[118]=Ae,t[119]=Ce,t[120]=Le,t[121]=Je):Je=t[121];let ot;t[122]!==e?(ot=e("contextSidebar.stats.messages"),t[122]=e,t[123]=ot):ot=t[123];let et;t[124]!==G.messagesCount?(et=qn(G.messagesCount),t[124]=G.messagesCount,t[125]=et):et=t[125];let it;t[126]!==ot||t[127]!==et?(it={label:ot,value:et},t[126]=ot,t[127]=et,t[128]=it):it=t[128];let ht;t[129]!==e?(ht=e("contextSidebar.stats.user"),t[129]=e,t[130]=ht):ht=t[130];let st;t[131]!==G.userMessagesCount?(st=qn(G.userMessagesCount),t[131]=G.userMessagesCount,t[132]=st):st=t[132];let mt;t[133]!==ht||t[134]!==st?(mt={label:ht,value:st},t[133]=ht,t[134]=st,t[135]=mt):mt=t[135];let kt;t[136]!==e?(kt=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=kt):kt=t[137];let Pe;t[138]!==G.assistantMessagesCount?(Pe=qn(G.assistantMessagesCount),t[138]=G.assistantMessagesCount,t[139]=Pe):Pe=t[139];let Ge;t[140]!==kt||t[141]!==Pe?(Ge={label:kt,value:Pe},t[140]=kt,t[141]=Pe,t[142]=Ge):Ge=t[142];let at;t[143]!==e?(at=e("contextSidebar.stats.cost"),t[143]=e,t[144]=at):at=t[144];let ze;t[145]!==G.totalAssistantCost?(ze=Mx(G.totalAssistantCost),t[145]=G.totalAssistantCost,t[146]=ze):ze=t[146];let ft;t[147]!==at||t[148]!==ze?(ft={label:at,value:ze},t[147]=at,t[148]=ze,t[149]=ft):ft=t[149];let te;t[150]!==it||t[151]!==mt||t[152]!==Ge||t[153]!==ft?(te=[it,mt,Ge,ft],t[150]=it,t[151]=mt,t[152]=Ge,t[153]=ft,t[154]=te):te=t[154];const me=te;let De;t[155]!==me?(De=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:me.map(ew)}),t[155]=me,t[156]=De):De=t[156];let K;t[157]!==e?(K=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=K):K=t[158];let Se;t[159]!==K?(Se=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:K}),t[159]=K,t[160]=Se):Se=t[160];let Ve;t[161]!==e||t[162]!==G.cacheHitRate.hasInput||t[163]!==G.cacheHitRate.percent||t[164]!==G.tokenBreakdown.cacheRead||t[165]!==G.tokenBreakdown.cacheWrite||t[166]!==G.tokenBreakdown.input||t[167]!==G.tokenBreakdown.output||t[168]!==G.tokenBreakdown.reasoning?(Ve=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:G.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:G.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:G.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:G.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:G.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:G.cacheHitRate.hasInput?G.cacheHitRate.percent:null,format:"percent"}].map(tw)}),t[161]=e,t[162]=G.cacheHitRate.hasInput,t[163]=G.cacheHitRate.percent,t[164]=G.tokenBreakdown.cacheRead,t[165]=G.tokenBreakdown.cacheWrite,t[166]=G.tokenBreakdown.input,t[167]=G.tokenBreakdown.output,t[168]=G.tokenBreakdown.reasoning,t[169]=Ve):Ve=t[169];let Xe;t[170]!==Se||t[171]!==Ve?(Xe=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Se,Ve]}),t[170]=Se,t[171]=Ve,t[172]=Xe):Xe=t[172];let nt;t[173]!==Y||t[174]!==G.breakdownTotal?(nt=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Y.map(He=>He.value<=0||G.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${He.value/G.breakdownTotal*100}%`,backgroundColor:He.color}},He.key))}),t[173]=Y,t[174]=G.breakdownTotal,t[175]=nt):nt=t[175];let Ze;t[176]!==Y||t[177]!==G.breakdownTotal?(Ze=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:Y.map(He=>{const Ue=G.breakdownTotal>0?He.value/G.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:He.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[He.label," ",s.jsxs("span",{className:"tabular-nums",children:[Ue.toFixed(0),"%"]})]})]},He.key)})}),t[176]=Y,t[177]=G.breakdownTotal,t[178]=Ze):Ze=t[178];let gt;t[179]!==nt||t[180]!==Ze?(gt=s.jsxs("div",{className:"mb-6",children:[nt,Ze]}),t[179]=nt,t[180]=Ze,t[181]=gt):gt=t[181];let We;t[182]!==e?(We=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=We):We=t[183];let Et;t[184]!==We?(Et=s.jsx("div",{className:"typography-micro text-muted-foreground",children:We}),t[184]=We,t[185]=Et):Et=t[185];let Ft;if(t[186]!==l||t[187]!==i||t[188]!==p||t[189]!==e||t[190]!==n){let He;t[192]!==l||t[193]!==i||t[194]!==e||t[195]!==n?(He=Ue=>{const ve=Ue.info.role,Qe=ve==="assistant",qe=ve==="user",Ye=i[Ue.info.id]===!0,dt=l===Ue.info.id,Ot=Ue.info.time?.created??null,zt=T1(Ue.parts),Kt=Qe?yc({info:Ue.info,parts:Ue.parts}):null,Gt=qe?R1(Ue.parts):"",Bt=B1(Ot,n),Jt=zt||"—",Vt=Kt?M1(Kt.input,Kt.output,qn):"",Wt=ve||"unknown",_t=zt?`${Wt}: ${zt}`:Wt,Xt=Ye?JSON.stringify({info:Ue.info,parts:Ue.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":Ye,onClick:()=>{o(Ct=>({...Ct,[Ue.info.id]:Ct[Ue.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:Qe?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[qe?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Gt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:Qe?Jt:_t}),Qe&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Vt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Bt})]})}),Ye&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[s.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:Ct=>{Ct.stopPropagation(),j(Ue.info.id,Xt)},"aria-label":e(dt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(dt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:dt?s.jsx(_,{name:"check",className:"size-3.5"}):s.jsx(_,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Fp,{language:"json",code:Xt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Ue.info.id)},t[192]=l,t[193]=i,t[194]=e,t[195]=n,t[196]=He):He=t[196],Ft=[...p].reverse().map(He),t[186]=l,t[187]=i,t[188]=p,t[189]=e,t[190]=n,t[191]=Ft}else Ft=t[191];let Ie;t[197]!==Ft?(Ie=s.jsx("div",{className:"mt-2.5 space-y-1",children:Ft}),t[197]=Ft,t[198]=Ie):Ie=t[198];let yt;t[199]!==Et||t[200]!==Ie?(yt=s.jsxs("div",{children:[Et,Ie]}),t[199]=Et,t[200]=Ie,t[201]=yt):yt=t[201];let At;return t[202]!==ae||t[203]!==Je||t[204]!==De||t[205]!==Xe||t[206]!==gt||t[207]!==yt?(At=s.jsx(En,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ae,Je,De,Xe,gt,yt]})}),t[202]=ae,t[203]=Je,t[204]=De,t[205]=Xe,t[206]=gt,t[207]=yt,t[208]=At):At=t[208],At};function V1(t){return t.timeFormatPreference}function U1(t){return t.currentSessionId}function H1(t){return t.currentSessionDirectory}function G1(t){return t.providers}function q1(t){return Object.keys(t).length>0?{}:t}function Y1(t){return t.info.role==="assistant"}function Q1(t){return t.info.role==="user"}function X1(t){return t.info}function J1(t,e){const n=Bn(e.info.cost);return t+n}function Z1(t){return t.info.role==="system"}function ew(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function tw(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:qn(t.value):"—"})]},t.label)}const jf=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),sw=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return jf.has(n.toLowerCase())},tn="about:blank",wr=t=>{const e=t.trim();if(!e)return tn;const n=e.includes("://")?e:`${sw(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?tn:r.toString()}catch{return tn}},Nr=t=>{try{return jf.has(new URL(t).hostname.toLowerCase())}catch{return!1}},ol=t=>{if(!t||t===tn)return"";try{return new URL(t).host||t}catch{return t}},nw=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),rw=(t,e)=>nw.has(t)&&Nr(e),ow=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"},iw=async t=>{try{const e=await bs("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const n=await e.json();if(!n||typeof n!="object")return{kind:"unavailable"};const r=n.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(ow)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},aw=async t=>{try{const e=await bs("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},lw=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},cw=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=lw(r);i!==null&&!n.has(i)&&n.set(i,r)}return e?e.map(r=>{const i=n.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...n.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},wa="__openchamberBrowserAnnotationActive",dw=`(() => {
12
+ try {
13
+ var host = document.querySelector('[data-openchamber-annotation]');
14
+ if (host && host.parentNode) host.parentNode.removeChild(host);
15
+ } catch (error) { /* page navigated away */ }
16
+ try {
17
+ var cursor = document.getElementById('openchamber-annotation-cursor');
18
+ if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
19
+ } catch (error) { /* page navigated away */ }
20
+ try { delete window['${wa}']; } catch (error) { /* non-configurable */ }
21
+ })();`,uw=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
22
+ var CONFIG = ${n};
23
+ var THEME = CONFIG.theme;
24
+ var LABELS = CONFIG.labels;
25
+ var OVERLAY_ATTR = 'data-openchamber-annotation';
26
+ var Z_OVERLAY = 2147483646;
27
+ var MAX_TEXT = 400;
28
+ var MIN_RECT = 3;
29
+ var EDITOR_GAP = 10;
30
+
31
+ try {
32
+ var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
33
+ if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
34
+ } catch (error) { /* nothing to clean */ }
35
+
36
+ window['${wa}'] = true;
37
+
38
+ var counter = 0;
39
+ var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
40
+
41
+ var selected = null;
42
+ var regions = [];
43
+ var strokes = [];
44
+ var tool = 'select';
45
+ var settled = false;
46
+
47
+ // ---------------------------------------------------------------- geometry
48
+
49
+ var rectFrom = function (domRect) {
50
+ return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
51
+ };
52
+ var normalizeRect = function (ax, ay, bx, by) {
53
+ return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
54
+ };
55
+ var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
56
+
57
+ // ------------------------------------------------------------- description
58
+
59
+ var isOverlayNode = function (element) {
60
+ var node = element;
61
+ while (node) {
62
+ if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
63
+ node = node.parentNode || (node.host || null);
64
+ }
65
+ return false;
66
+ };
67
+
68
+ var elementFromPoint = function (x, y) {
69
+ var found = document.elementFromPoint(x, y);
70
+ if (!found || isOverlayNode(found)) return null;
71
+ return found;
72
+ };
73
+
74
+ var selectorPart = function (element) {
75
+ var part = element.tagName.toLowerCase();
76
+ if (element.id) return part + '#' + element.id;
77
+ var className = typeof element.className === 'string' ? element.className.trim() : '';
78
+ if (className) {
79
+ var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
80
+ if (first) part += '.' + first;
81
+ }
82
+ return part;
83
+ };
84
+
85
+ var buildSelector = function (element) {
86
+ if (element.id) return '#' + element.id;
87
+ var parts = [];
88
+ var node = element;
89
+ var depth = 0;
90
+ while (node && node.nodeType === 1 && depth < 5) {
91
+ var part = selectorPart(node);
92
+ var parent = node.parentElement;
93
+ if (parent) {
94
+ var siblings = Array.prototype.filter.call(parent.children, function (child) {
95
+ return child.tagName === node.tagName;
96
+ });
97
+ if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
98
+ }
99
+ parts.unshift(part);
100
+ if (node.id) break;
101
+ node = parent;
102
+ depth += 1;
103
+ }
104
+ return parts.join(' > ');
105
+ };
106
+
107
+ var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
108
+ var STYLE_PROPS = [
109
+ 'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
110
+ 'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
111
+ 'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
112
+ ];
113
+
114
+ var describe = function (element) {
115
+ var computed = window.getComputedStyle(element);
116
+ var attributes = {};
117
+ for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
118
+ var name = INTERESTING_ATTRS[i];
119
+ var value = element.getAttribute(name);
120
+ if (value) attributes[name] = String(value).slice(0, 200);
121
+ }
122
+ var computedStyle = {};
123
+ for (var j = 0; j < STYLE_PROPS.length; j += 1) {
124
+ var prop = STYLE_PROPS[j];
125
+ computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
126
+ }
127
+ var ancestry = [];
128
+ var node = element.parentElement;
129
+ var depth = 0;
130
+ while (node && node.nodeType === 1 && depth < 4) {
131
+ var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
132
+ if (node.id) entry.id = node.id;
133
+ var cls = typeof node.className === 'string' ? node.className.trim() : '';
134
+ if (cls) entry.className = cls.slice(0, 200);
135
+ ancestry.unshift(entry);
136
+ node = node.parentElement;
137
+ depth += 1;
138
+ }
139
+ var box = element.getBoundingClientRect();
140
+ var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
141
+ return {
142
+ tag: element.tagName.toLowerCase(),
143
+ text: text.slice(0, MAX_TEXT),
144
+ selector: buildSelector(element),
145
+ path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
146
+ bounds: rectFrom(box),
147
+ center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
148
+ attributes: attributes,
149
+ computedStyle: computedStyle,
150
+ ancestry: ancestry
151
+ };
152
+ };
153
+
154
+ // ------------------------------------------------------------------ chrome
155
+
156
+ var host = document.createElement('div');
157
+ host.setAttribute(OVERLAY_ATTR, '');
158
+ host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
159
+ var shadow = host.attachShadow({ mode: 'closed' });
160
+
161
+ var style = document.createElement('style');
162
+ style.textContent = [
163
+ ':host{all:initial}',
164
+ '*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
165
+ '.layer{position:fixed;inset:0;pointer-events:none}',
166
+ '.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
167
+ '.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}',
168
+ '.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}',
169
+ '.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}',
170
+ '.tools button:hover{background:' + THEME.primaryFaint + '}',
171
+ '.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
172
+ '.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}',
173
+ '.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}',
174
+ '.editor textarea::placeholder{color:' + THEME.mutedText + '}',
175
+ '.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}',
176
+ '.editor button svg{width:16px;height:16px;display:block}',
177
+ '.editor button[disabled]{opacity:.5;cursor:default}'
178
+ ].join('');
179
+ shadow.appendChild(style);
180
+
181
+ var cursorStyle = document.createElement('style');
182
+ cursorStyle.id = 'openchamber-annotation-cursor';
183
+ document.head.appendChild(cursorStyle);
184
+ var setCursor = function (value) {
185
+ cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
186
+ };
187
+
188
+ var svgNS = 'http://www.w3.org/2000/svg';
189
+ var svg = document.createElementNS(svgNS, 'svg');
190
+ svg.setAttribute('class', 'layer');
191
+ svg.style.overflow = 'visible';
192
+ shadow.appendChild(svg);
193
+
194
+ var hoverBox = document.createElement('div');
195
+ hoverBox.className = 'box';
196
+ var hoverLabel = document.createElement('div');
197
+ hoverLabel.className = 'label';
198
+ var marqueeBox = document.createElement('div');
199
+ marqueeBox.className = 'box';
200
+ shadow.append(hoverBox, hoverLabel, marqueeBox);
201
+
202
+ var positionBox = function (node, rect) {
203
+ node.style.display = 'block';
204
+ node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
205
+ node.style.width = rect.width + 'px';
206
+ node.style.height = rect.height + 'px';
207
+ };
208
+
209
+ var tools = document.createElement('div');
210
+ tools.className = 'tools';
211
+ shadow.appendChild(tools);
212
+
213
+ var toolButtons = {};
214
+ [['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
215
+ var button = document.createElement('button');
216
+ button.type = 'button';
217
+ button.textContent = entry[1];
218
+ button.addEventListener('click', function () { setTool(entry[0]); });
219
+ toolButtons[entry[0]] = button;
220
+ tools.appendChild(button);
221
+ });
222
+
223
+ var editor = document.createElement('div');
224
+ editor.className = 'editor';
225
+ shadow.appendChild(editor);
226
+
227
+ var comment = document.createElement('textarea');
228
+ comment.rows = 1;
229
+ comment.placeholder = LABELS.commentPlaceholder;
230
+ var submit = document.createElement('button');
231
+ submit.type = 'button';
232
+ // Icon-only attach button (Remix attachment-2), matching the chat comment
233
+ // input; the localized label stays available to assistive tech.
234
+ submit.setAttribute('aria-label', LABELS.submit);
235
+ submit.title = LABELS.submit;
236
+ 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>';
237
+ editor.append(comment, submit);
238
+
239
+ /**
240
+ * Grows the box with its content.
241
+ *
242
+ * A hidden element reports scrollHeight 0, so measuring one collapses the
243
+ * field to nothing — which is what left a sliver of a click target and an
244
+ * invisible caret. Measuring only while visible, and never below the CSS
245
+ * min-height, keeps it usable.
246
+ */
247
+ var resizeComment = function () {
248
+ if (editor.style.display === 'none') return;
249
+ comment.style.height = 'auto';
250
+ comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
251
+ };
252
+ comment.addEventListener('input', resizeComment);
253
+
254
+ // -------------------------------------------------------------- selection
255
+
256
+ var lastTargetRect = null;
257
+
258
+ /** Places the comment box under whatever was just marked, kept on screen. */
259
+ var positionEditor = function () {
260
+ if (!lastTargetRect) {
261
+ editor.style.display = 'none';
262
+ return;
263
+ }
264
+ var wasHidden = editor.style.display === 'none';
265
+ editor.style.display = 'flex';
266
+ // Measured now that it is laid out, not while it was still hidden.
267
+ if (wasHidden) resizeComment();
268
+ var box = editor.getBoundingClientRect();
269
+ var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
270
+ var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
271
+ // Above the target when there is no room below, so the box is never left
272
+ // half off the bottom of the page.
273
+ if (top + box.height > window.innerHeight - 8) {
274
+ top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
275
+ }
276
+ left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
277
+ editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
278
+ };
279
+
280
+ /** Focus after layout: focusing a zero-height field puts the caret nowhere. */
281
+ var focusComment = function () {
282
+ requestAnimationFrame(function () {
283
+ try {
284
+ comment.focus({ preventScroll: true });
285
+ comment.setSelectionRange(comment.value.length, comment.value.length);
286
+ } catch (error) { /* field went away */ }
287
+ });
288
+ };
289
+
290
+ var hasTargets = function () {
291
+ return Boolean(selected) || regions.length > 0 || strokes.length > 0;
292
+ };
293
+
294
+ var syncChrome = function () {
295
+ submit.disabled = !hasTargets();
296
+ if (!hasTargets()) {
297
+ lastTargetRect = null;
298
+ editor.style.display = 'none';
299
+ return;
300
+ }
301
+ positionEditor();
302
+ };
303
+
304
+ var syncSelectionVisuals = function () {
305
+ if (!selected) return;
306
+ var rect = rectFrom(selected.element.getBoundingClientRect());
307
+ if (!usableRect(rect)) {
308
+ selected.outline.style.display = 'none';
309
+ selected.badge.style.display = 'none';
310
+ return;
311
+ }
312
+ positionBox(selected.outline, rect);
313
+ selected.badge.style.display = 'block';
314
+ selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
315
+ lastTargetRect = rect;
316
+ };
317
+
318
+ var dropSelection = function () {
319
+ if (!selected) return;
320
+ selected.outline.remove();
321
+ selected.badge.remove();
322
+ selected = null;
323
+ };
324
+
325
+ var selectElement = function (element) {
326
+ var wasSelected = selected && selected.element === element;
327
+ dropSelection();
328
+ if (wasSelected) {
329
+ // Clicking the chosen element again clears it, so a misclick costs one
330
+ // click rather than starting over.
331
+ lastTargetRect = null;
332
+ syncChrome();
333
+ return;
334
+ }
335
+ var outline = document.createElement('div');
336
+ outline.className = 'box';
337
+ var badge = document.createElement('div');
338
+ badge.className = 'label';
339
+ badge.textContent = selectorPart(element);
340
+ shadow.append(outline, badge);
341
+ selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
342
+ syncSelectionVisuals();
343
+ syncChrome();
344
+ focusComment();
345
+ };
346
+
347
+ var setTool = function (next) {
348
+ tool = next;
349
+ hoverBox.style.display = 'none';
350
+ hoverLabel.style.display = 'none';
351
+ marqueeBox.style.display = 'none';
352
+ setCursor(next === 'select' ? '' : 'crosshair');
353
+ for (var key in toolButtons) {
354
+ if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
355
+ toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
356
+ }
357
+ }
358
+ };
359
+
360
+ // ------------------------------------------------------------- interaction
361
+
362
+ var drag = null;
363
+
364
+ var onPointerMove = function (event) {
365
+ if (drag) {
366
+ if (drag.kind === 'marquee') {
367
+ drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
368
+ positionBox(marqueeBox, drag.rect);
369
+ } else if (drag.kind === 'draw') {
370
+ drag.points.push({ x: event.clientX, y: event.clientY });
371
+ drag.path.setAttribute('d', drag.points.map(function (point, index) {
372
+ return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
373
+ }).join(' '));
374
+ }
375
+ return;
376
+ }
377
+
378
+ if (tool !== 'select') return;
379
+ var element = elementFromPoint(event.clientX, event.clientY);
380
+ if (!element) {
381
+ hoverBox.style.display = 'none';
382
+ hoverLabel.style.display = 'none';
383
+ return;
384
+ }
385
+ var rect = rectFrom(element.getBoundingClientRect());
386
+ positionBox(hoverBox, rect);
387
+ hoverLabel.textContent = selectorPart(element);
388
+ hoverLabel.style.display = 'block';
389
+ hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
390
+ };
391
+
392
+ var onPointerDown = function (event) {
393
+ if (event.button !== 0) return;
394
+ if (isOverlayNode(event.target)) return;
395
+ event.preventDefault();
396
+ event.stopPropagation();
397
+
398
+ if (tool === 'select') {
399
+ var element = elementFromPoint(event.clientX, event.clientY);
400
+ if (element) selectElement(element);
401
+ return;
402
+ }
403
+
404
+ if (tool === 'marquee') {
405
+ drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
406
+ return;
407
+ }
408
+
409
+ var path = document.createElementNS(svgNS, 'path');
410
+ path.setAttribute('fill', 'none');
411
+ path.setAttribute('stroke', THEME.primary);
412
+ path.setAttribute('stroke-width', '2.5');
413
+ path.setAttribute('stroke-linecap', 'round');
414
+ path.setAttribute('stroke-linejoin', 'round');
415
+ svg.appendChild(path);
416
+ drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
417
+ };
418
+
419
+ var onPointerUp = function () {
420
+ if (!drag) return;
421
+ var finished = drag;
422
+ drag = null;
423
+
424
+ if (finished.kind === 'marquee') {
425
+ marqueeBox.style.display = 'none';
426
+ var rect = finished.rect;
427
+ if (!rect || !usableRect(rect)) return;
428
+ // A region marks an area, not the elements inside it: expanding it into a
429
+ // selection made the result depend on the page's markup rather than on
430
+ // what was drawn.
431
+ regions.push({ id: nextId('region'), rect: rect });
432
+ var outline = document.createElementNS(svgNS, 'rect');
433
+ outline.setAttribute('x', String(rect.x));
434
+ outline.setAttribute('y', String(rect.y));
435
+ outline.setAttribute('width', String(rect.width));
436
+ outline.setAttribute('height', String(rect.height));
437
+ outline.style.fill = THEME.primarySoft;
438
+ outline.setAttribute('stroke', THEME.primary);
439
+ outline.setAttribute('stroke-width', '1.5');
440
+ outline.setAttribute('rx', '2');
441
+ svg.appendChild(outline);
442
+ lastTargetRect = rect;
443
+ syncChrome();
444
+ focusComment();
445
+ return;
446
+ }
447
+
448
+ var points = finished.points;
449
+ if (points.length < 2) {
450
+ if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
451
+ return;
452
+ }
453
+ var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
454
+ for (var p = 1; p < points.length; p += 1) {
455
+ minX = Math.min(minX, points[p].x);
456
+ minY = Math.min(minY, points[p].y);
457
+ maxX = Math.max(maxX, points[p].x);
458
+ maxY = Math.max(maxY, points[p].y);
459
+ }
460
+ var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
461
+ strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
462
+ lastTargetRect = bounds;
463
+ syncChrome();
464
+ focusComment();
465
+ };
466
+
467
+ /**
468
+ * Swallows the page's own mouse handling while annotating.
469
+ *
470
+ * Blocking pointerdown is not enough: a click still follows it, so marking a
471
+ * button pressed that button and marking a link navigated away from the page
472
+ * being annotated. These are the events that reach page code, so these are
473
+ * the ones that have to stop.
474
+ */
475
+ var blockPageInteraction = function (event) {
476
+ if (isOverlayNode(event.target)) return;
477
+ event.preventDefault();
478
+ event.stopPropagation();
479
+ };
480
+ var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
481
+
482
+ var onScrollOrResize = function () {
483
+ syncSelectionVisuals();
484
+ positionEditor();
485
+ };
486
+
487
+ var onKeyDown = function (event) {
488
+ if (event.isComposing || event.keyCode === 229) return;
489
+ if (event.key === 'Escape') {
490
+ event.preventDefault();
491
+ event.stopImmediatePropagation();
492
+ finish(null);
493
+ }
494
+ };
495
+
496
+ var onCommentKeyDown = function (event) {
497
+ // Do not let the annotated page treat typed letters as its own shortcuts.
498
+ event.stopPropagation();
499
+ // WebKit can report the composition-confirming Enter as keyCode 229.
500
+ if (event.isComposing || event.keyCode === 229) return;
501
+ if (event.key === 'Enter' && !event.shiftKey) {
502
+ event.preventDefault();
503
+ attach();
504
+ }
505
+ };
506
+
507
+ document.addEventListener('pointermove', onPointerMove, true);
508
+ document.addEventListener('pointerdown', onPointerDown, true);
509
+ document.addEventListener('pointerup', onPointerUp, true);
510
+ BLOCKED_EVENTS.forEach(function (name) {
511
+ window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
512
+ });
513
+ window.addEventListener('scroll', onScrollOrResize, true);
514
+ window.addEventListener('resize', onScrollOrResize, true);
515
+ window.addEventListener('keydown', onKeyDown, true);
516
+ comment.addEventListener('keydown', onCommentKeyDown);
517
+
518
+ // ------------------------------------------------------------------ finish
519
+
520
+ var teardown = function () {
521
+ document.removeEventListener('pointermove', onPointerMove, true);
522
+ document.removeEventListener('pointerdown', onPointerDown, true);
523
+ document.removeEventListener('pointerup', onPointerUp, true);
524
+ BLOCKED_EVENTS.forEach(function (name) {
525
+ window.removeEventListener(name, blockPageInteraction, true);
526
+ });
527
+ window.removeEventListener('scroll', onScrollOrResize, true);
528
+ window.removeEventListener('resize', onScrollOrResize, true);
529
+ window.removeEventListener('keydown', onKeyDown, true);
530
+ comment.removeEventListener('keydown', onCommentKeyDown);
531
+ setCursor('');
532
+ if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
533
+ if (host.parentNode) host.parentNode.removeChild(host);
534
+ try { delete window['${wa}']; } catch (error) { /* non-configurable */ }
535
+ };
536
+
537
+ var finish = function (payload) {
538
+ if (settled) return;
539
+ settled = true;
540
+ teardown();
541
+ // Removing the chrome is not enough: the host screenshots this page right
542
+ // after we resolve, and the compositor can still hold a frame containing
543
+ // our outlines. Yield two frames so the page has actually repainted.
544
+ requestAnimationFrame(function () {
545
+ requestAnimationFrame(function () { resolve(payload); });
546
+ });
547
+ };
548
+
549
+ var attach = function () {
550
+ if (!hasTargets()) return;
551
+ finish({
552
+ id: 'annotation-' + Date.now(),
553
+ pageUrl: String(location.href),
554
+ pageTitle: String(document.title || ''),
555
+ viewport: { width: window.innerWidth, height: window.innerHeight },
556
+ devicePixelRatio: window.devicePixelRatio || 1,
557
+ comment: comment.value,
558
+ // Zero or one element, never more. Kept as a list so elements, regions
559
+ // and strokes stay one uniform shape for everything downstream.
560
+ elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
561
+ regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
562
+ strokes: strokes.map(function (entry) {
563
+ return { id: entry.id, points: entry.points, bounds: entry.bounds };
564
+ })
565
+ });
566
+ };
567
+
568
+ submit.addEventListener('click', attach);
569
+
570
+ (document.body || document.documentElement).appendChild(host);
571
+ setTool('select');
572
+ syncChrome();
573
+ });`},fw={kind:"idle"},bn=t=>typeof t=="object"&&t!==null,Nn=t=>typeof t=="number"&&Number.isFinite(t),vc=t=>bn(t)&&Object.values(t).every(e=>typeof e=="string"),il=t=>bn(t)&&Nn(t.x)&&Nn(t.y)&&Nn(t.width)&&Nn(t.height),kf=t=>bn(t)&&Nn(t.x)&&Nn(t.y),mw=t=>bn(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"),hw=t=>bn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&il(t.bounds)&&kf(t.center)&&vc(t.attributes)&&vc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(mw),pw=t=>bn(t)&&typeof t.id=="string"&&hw(t.element),gw=t=>bn(t)&&typeof t.id=="string"&&il(t.rect),xw=t=>bn(t)&&typeof t.id=="string"&&il(t.bounds)&&Array.isArray(t.points)&&t.points.every(kf),bw=t=>bn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&bn(t.viewport)&&Nn(t.viewport.width)&&Nn(t.viewport.height)&&Nn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(pw)&&Array.isArray(t.regions)&&t.regions.every(gw)&&Array.isArray(t.strokes)&&t.strokes.every(xw),yw=1600,ww=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Failed to decode browser page capture")),r.src=t}),vw=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await ww(`data:${e};base64,${t}`),m=Math.max(1,u.naturalWidth||n),f=Math.max(1,u.naturalHeight||r),p=m/Math.max(1,i||m),y=f/Math.max(1,o||f),x=Math.min(1,yw/m),k=document.createElement("canvas");k.width=Math.max(1,Math.floor(m*x)),k.height=Math.max(1,Math.floor(f*x));const w=k.getContext("2d");if(!w)return null;w.scale(x,x),w.drawImage(u,0,0,m,f);const h=S=>({x:S.x*p,y:S.y*y,width:S.width*p,height:S.height*y}),g=Math.max(2,2.5*p/Math.max(x,.2));w.strokeStyle=a,w.fillStyle=d;const j=S=>{const C=h(S);w.lineWidth=g,w.fillRect(C.x,C.y,C.width,C.height),w.strokeRect(C.x,C.y,C.width,C.height)};for(const S of l.elements)j(S.element.bounds);for(const S of l.regions)j(S.rect);for(const S of l.strokes)S.points.length<2||(w.beginPath(),S.points.forEach((C,v)=>{const E=C.x*p,R=C.y*y;v===0?w.moveTo(E,R):w.lineTo(E,R)}),w.lineCap="round",w.lineJoin="round",w.lineWidth=g*1.4,w.stroke());const b=await new Promise(S=>k.toBlob(S,"image/jpeg",.85));return b?new File([b],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},Sw="({ width: window.innerWidth, height: window.innerHeight })",jw=async t=>{try{const e=await t.executeJavaScript(Sw,!0);if(!e||typeof e!="object")return null;const n=e;return typeof n.width!="number"||typeof n.height!="number"||!Number.isFinite(n.width)||!Number.isFinite(n.height)?null:{width:n.width,height:n.height}}catch{return null}},Eo=async t=>{try{await t.executeJavaScript(dw,!1)}catch{}},kw=async({host:t,theme:e,labels:n})=>{const r=uw(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!bw(i))return await Eo(t),null;const o=i;try{const l=await jw(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const d=await vw({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:d}}catch{return{payload:o,screenshot:null}}},Zs={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)"},Cw=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const n=window.getComputedStyle(t).backgroundColor;return n&&n!=="rgba(0, 0, 0, 0)"?n:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},Nw=t=>{const e=Cw();if(!e)return{...Zs,colorScheme:t};try{const n=(a,d)=>e.read(`var(${a})`)||d,r=(a,d,u)=>e.read(`color-mix(in srgb, var(${a}) ${d}%, transparent)`)||u,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||Zs.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",Zs.primary),primarySoft:r("--primary",16,Zs.primarySoft),primaryFaint:r("--primary",10,Zs.primaryFaint),primaryContrast:n("--primary-foreground",Zs.primaryContrast),surface:n("--surface-background",Zs.surface),surfaceElevated:n("--surface-elevated",Zs.surfaceElevated),border:n("--border",Zs.border),text:n("--foreground",Zs.text),mutedText:n("--muted-foreground",Zs.mutedText)}}catch{return{...Zs,colorScheme:t}}finally{e.dispose()}},Aw=2e3,Pw=50;let nr=null,vr=null,Ur=null;const Dw=async t=>{try{const e=await bs("/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}},fr=async(t,e)=>{try{const n=await bs("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},Iw=async(t=Aw)=>{const e=Date.now()+t;for(;!nr&&Date.now()<e;)await new Promise(n=>setTimeout(n,Pw));return nr},Tw=async t=>{const e=t.action==="browser.open",n=nr;if(!(!n&&!(e&&vr))&&await Dw(t.requestId))try{if(e&&!n){const i=typeof t.parameters.url=="string"?t.parameters.url:"";if(!i){await fr(t.requestId,{ok:!1,error:"url is required"});return}vr?.(i);const o=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!o||o==="fill"){await fr(t.requestId,{ok:!0,data:{url:i,opened:!0}});return}const l=await Iw();if(!l){await fr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const a=await l.run("browser.resize",{viewport:o}),d=a&&typeof a=="object"?a.viewport??null:null;await fr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!0,viewport:d}});return}const r=await n.run(t.action,t.parameters);await fr(t.requestId,{ok:!0,data:r})}catch(r){await fr(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},Cf=()=>{Ur||(Ur=Wn(t=>{t.type==="browser-control-request"&&Tw({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Nf=()=>{nr||vr||!Ur||(Ur(),Ur=null)},Ew=t=>(nr=t,Cf(),()=>{nr===t&&(nr=null),Nf()}),Rw=t=>(vr=t,Cf(),()=>{vr===t&&(vr=null),Nf()}),Mw=50,Ow=6,Bw=2048,Fw=200,Af=t=>{const e=wr(String(t??"").trim());if(!e||e.length>Bw)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},_w=(t,e)=>{const n=Af(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,Fw)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,Mw)},Lw=(t,e)=>{const n=Af(e);return t.filter(r=>r.url!==n)},$w=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Pf=(t,e,n=Ow)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,n);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=$w(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},Sc=20,Ro=t=>{const e=xt((t||"").trim());return e?JSON.stringify([Qt(),e]):""},zw=t=>{const e=Object.keys(t);if(e.length<=Sc)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Sc);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},Sr=no()(tb(t=>({byProject:{},recordVisit:(e,n)=>{const r=Ro(e);r&&t(i=>{const o=i.byProject[r]??[],l=_w(o,{...n,at:Date.now()});return l===o?i:{byProject:zw({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=Ro(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:Lw(o,n)}}:i})},clear:e=>{const n=Ro(e);n&&t(r=>{if(!(n in r.byProject))return r;const i={...r.byProject};return delete i[n],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:Gm(),partialize:t=>({byProject:t.byProject})})),Ww=[],Df=t=>e=>{const n=Ro(t);return(n?e.byProject[n]:void 0)??Ww},va=new Map,bi=new Map,rr=new Map,or=new Set,Kw=async(t,e)=>{if(!gl()){or.delete(t),mr(t,{type:"close"});return}if(await qm(Dn()),!or.has(t)||!gl())return;const n=Ld().websocket(`/api/dev-tunnel?port=${e}`),r=Ym(n);rr.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>mr(t,{type:"ready"}),r.onmessage=i=>mr(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>mr(t,{type:"close"}),r.onclose=()=>{or.delete(t),rr.delete(t),mr(t,{type:"close"})}};_p(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=rr.get(t);r&&n.data&&r.send(n.data);return}case"close":or.delete(t),rr.get(t)?.close(),rr.delete(t);return;case"connect":or.add(t),Kw(t,e).catch(()=>{or.delete(t),mr(t,{type:"close"})})}});const If=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Tf=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!Nr(e.toString())}catch{return!1}},Ef=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:0}catch{return 0}},jc=(t,e)=>{try{const n=new URL(t);return n.protocol="http:",n.hostname="127.0.0.1",n.port=String(e),n.toString()}catch{return t}},kc=(t,e)=>{try{bi.set(e,new URL(t).origin)}catch{}};class Hr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const Cc=async t=>{if(!t||!If()||!Nr(t))return t;const e=Dn();if(!Tf(e))return t;const n=Ef(t);if(!n)return t;const r=`${e}|${n}`,i=va.get(r);if(i)return kc(t,i),jc(t,i);try{const o=await br("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:Qm(),targetKey:Qt(),clientToken:Yr(),requestHeaders:$d()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new Hr(t);return va.set(r,o.localPort),kc(t,o.localPort),jc(t,o.localPort)}catch(o){throw o instanceof Hr?o:new Hr(t)}},Nc=t=>{if(!t||!If()||!Nr(t)||!Tf(Dn()))return!1;const e=Ef(t);return e>0&&!bi.has(e)},Rr=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=bi.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},Vw=()=>{va.clear(),bi.clear(),or.clear();for(const t of rr.values())t.close();rr.clear(),br("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&Cr(Vw);const Ac=6e3,Uw=120,Hw=80,Gw=`
574
+ var MAX_ELEMENTS = ${Uw};
575
+ var MAX_LABEL_CHARS = ${Hw};
576
+ var visible = function (element) {
577
+ var rect = element.getBoundingClientRect();
578
+ if (rect.width < 1 || rect.height < 1) return false;
579
+ var style = window.getComputedStyle(element);
580
+ return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
581
+ };
582
+ var label = function (element) {
583
+ var aria = element.getAttribute('aria-label');
584
+ if (aria) return aria.trim();
585
+ var value = element.getAttribute('value');
586
+ var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
587
+ if (text) return text.slice(0, MAX_LABEL_CHARS);
588
+ if (value) return String(value).slice(0, MAX_LABEL_CHARS);
589
+ var placeholder = element.getAttribute('placeholder');
590
+ return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
591
+ };
592
+ var isUnique = function (selector) {
593
+ try {
594
+ return document.querySelectorAll(selector).length === 1;
595
+ } catch (error) {
596
+ return false;
597
+ }
598
+ };
599
+
600
+ /**
601
+ * Names an element by what it is, falling back to where it sits.
602
+ *
603
+ * A positional chain like 'main > section:nth-of-type(3) > div > a' survives
604
+ * only until the markup shifts, and says nothing about what it points at.
605
+ * Anything the page states about identity — an id, a test id, an accessible
606
+ * name — outlives edits and reads as the thing it selects. The chain remains
607
+ * as the last resort, because something always has to work.
608
+ */
609
+ var cssPath = function (element) {
610
+ var tag = element.tagName.toLowerCase();
611
+
612
+ if (element.id) {
613
+ var byId = '#' + CSS.escape(element.id);
614
+ if (isUnique(byId)) return byId;
615
+ }
616
+ var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
617
+ for (var a = 0; a < stableAttrs.length; a += 1) {
618
+ var value = element.getAttribute(stableAttrs[a]);
619
+ if (!value) continue;
620
+ var raw = String(value);
621
+ // A value containing a quote would need escaping for no real gain: such
622
+ // attributes are rare, and the positional chain still covers them.
623
+ if (raw.indexOf('"') !== -1) continue;
624
+ var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
625
+ if (isUnique(byAttr)) return byAttr;
626
+ }
627
+ var className = typeof element.className === 'string' ? element.className.trim() : '';
628
+ if (className) {
629
+ var classes = className.split(/\\s+/).filter(Boolean);
630
+ for (var c = 0; c < classes.length; c += 1) {
631
+ var byClass = tag + '.' + CSS.escape(classes[c]);
632
+ if (isUnique(byClass)) return byClass;
633
+ }
634
+ }
635
+
636
+ var parts = [];
637
+ var node = element;
638
+ var depth = 0;
639
+ while (node && node.nodeType === 1 && depth < 6) {
640
+ var part = node.tagName.toLowerCase();
641
+ var parent = node.parentElement;
642
+ if (!parent) { parts.unshift(part); break; }
643
+ var siblings = Array.prototype.filter.call(parent.children, function (child) {
644
+ return child.tagName === node.tagName;
645
+ });
646
+ if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
647
+ parts.unshift(part);
648
+ if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
649
+ node = parent;
650
+ depth += 1;
651
+ }
652
+ return parts.join(' > ');
653
+ };
654
+
655
+ /** What a screen reader would announce, or '' when there is nothing to say. */
656
+ var accessibleName = function (element) {
657
+ var aria = element.getAttribute('aria-label');
658
+ if (aria && aria.trim()) return aria.trim();
659
+ var labelled = element.getAttribute('aria-labelledby');
660
+ if (labelled) {
661
+ var source = document.getElementById(labelled.split(/\\s+/)[0]);
662
+ if (source && (source.innerText || '').trim()) return source.innerText.trim();
663
+ }
664
+ var title = element.getAttribute('title');
665
+ if (title && title.trim()) return title.trim();
666
+ var alt = element.getAttribute('alt');
667
+ if (alt && alt.trim()) return alt.trim();
668
+ var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
669
+ if (text) return text;
670
+ var value = element.getAttribute('value');
671
+ return value && String(value).trim() ? String(value).trim() : '';
672
+ };
673
+ var findByText = function (needle) {
674
+ var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
675
+ var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
676
+ var exact = null;
677
+ var partial = null;
678
+ for (var i = 0; i < candidates.length; i += 1) {
679
+ var element = candidates[i];
680
+ if (!visible(element)) continue;
681
+ var text = label(element).toLowerCase();
682
+ if (!text) continue;
683
+ if (text === wanted) { exact = element; break; }
684
+ if (!partial && text.indexOf(wanted) !== -1) partial = element;
685
+ }
686
+ return exact || partial;
687
+ };
688
+ `,ro=t=>`(() => {
689
+ ${Gw}
690
+ ${t}
691
+ })()`,qw=({selector:t}={})=>ro(`
692
+ var scopeSelector = ${JSON.stringify(t??"")};
693
+ var root = document;
694
+ if (scopeSelector) {
695
+ try { root = document.querySelector(scopeSelector); }
696
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
697
+ if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
698
+ }
699
+ var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
700
+ var elements = [];
701
+ var visibleTotal = 0;
702
+ for (var i = 0; i < interactive.length; i += 1) {
703
+ var element = interactive[i];
704
+ if (!visible(element)) continue;
705
+ visibleTotal += 1;
706
+ if (elements.length >= MAX_ELEMENTS) continue;
707
+
708
+ var rect = element.getBoundingClientRect();
709
+ // Empty and default-valued fields are left out rather than serialized as
710
+ // "" and false. Repeated across a hundred entries that overhead dwarfed
711
+ // the information it carried.
712
+ var entry = {
713
+ selector: cssPath(element),
714
+ tag: element.tagName.toLowerCase(),
715
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
716
+ };
717
+ // The list covers the whole document so anything can be clicked without
718
+ // scrolling to it first, which means bounds alone do not say what is on
719
+ // screen — a negative y reads as a bug otherwise.
720
+ if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
721
+ var type = element.getAttribute('type');
722
+ if (type) entry.type = type;
723
+ var role = element.getAttribute('role');
724
+ if (role) entry.role = role;
725
+ var labelText = label(element);
726
+ if (labelText) entry.label = labelText;
727
+ if (element.disabled === true) entry.disabled = true;
728
+ // Flagged rather than described: reporting the accessible name of every
729
+ // element would cost more than it tells, while its absence on something
730
+ // clickable is a defect worth naming.
731
+ if (!accessibleName(element)) entry.missingAccessibleName = true;
732
+ elements.push(entry);
733
+ }
734
+ var body = document.body ? (document.body.innerText || '') : '';
735
+ var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
736
+ var docEl = document.documentElement;
737
+ var result = {
738
+ ok: true,
739
+ url: String(location.href),
740
+ title: String(document.title || ''),
741
+ scope: scopeSelector || 'document',
742
+ scrollY: Math.round(window.scrollY),
743
+ maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
744
+ text: text.slice(0, ${Ac}),
745
+ elements: elements
746
+ };
747
+ // State what was dropped. A capped list that reports only its own length
748
+ // reads as the whole page, and the agent acts as if it had seen everything.
749
+ if (text.length > ${Ac}) {
750
+ result.textTruncated = true;
751
+ result.textTotalChars = text.length;
752
+ }
753
+ if (visibleTotal > elements.length) {
754
+ result.elementsTruncated = true;
755
+ result.interactiveElementsOnPage = visibleTotal;
756
+ }
757
+ return result;
758
+ `),Yw=({selector:t,text:e})=>ro(`
759
+ var selector = ${JSON.stringify(t??"")};
760
+ var text = ${JSON.stringify(e??"")};
761
+ var target = null;
762
+ if (selector) {
763
+ try { target = document.querySelector(selector); }
764
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
765
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
766
+ } else {
767
+ target = findByText(text);
768
+ if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
769
+ }
770
+ if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
771
+ target.scrollIntoView({ block: 'center', inline: 'center' });
772
+ target.click();
773
+ return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
774
+ `),Qw=({selector:t,value:e,submit:n})=>ro(`
775
+ var selector = ${JSON.stringify(t)};
776
+ var value = ${JSON.stringify(e)};
777
+ var target = null;
778
+ try { target = document.querySelector(selector); }
779
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
780
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
781
+
782
+ var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
783
+ if (!editable) return { ok: false, error: selector + ' is not a text field' };
784
+ if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
785
+
786
+ target.scrollIntoView({ block: 'center' });
787
+ target.focus();
788
+ if (target.isContentEditable) {
789
+ target.textContent = value;
790
+ } else {
791
+ // Frameworks track the value through the native setter; assigning the
792
+ // property directly leaves React and friends unaware of the change.
793
+ var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
794
+ var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
795
+ if (setter && setter.set) setter.set.call(target, value);
796
+ else target.value = value;
797
+ }
798
+ target.dispatchEvent(new Event('input', { bubbles: true }));
799
+ target.dispatchEvent(new Event('change', { bubbles: true }));
800
+
801
+ if (${n?"true":"false"}) {
802
+ var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
803
+ target.dispatchEvent(new KeyboardEvent('keydown', enter));
804
+ target.dispatchEvent(new KeyboardEvent('keyup', enter));
805
+ var form = target.form;
806
+ if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
807
+ }
808
+ return { ok: true, selector: cssPath(target), url: String(location.href) };
809
+ `),Xw=({selector:t,direction:e})=>ro(`
810
+ var selector = ${JSON.stringify(t??"")};
811
+ var direction = ${JSON.stringify(e??"")};
812
+
813
+ var settle = function (extra) {
814
+ return new Promise(function (resolve) {
815
+ requestAnimationFrame(function () {
816
+ requestAnimationFrame(function () {
817
+ var doc = document.documentElement;
818
+ var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
819
+ var scrollY = Math.round(window.scrollY);
820
+ var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
821
+ result.atTop = scrollY <= 1;
822
+ result.atBottom = scrollY >= maxScrollY - 1;
823
+ for (var key in extra) {
824
+ if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
825
+ }
826
+ resolve(result);
827
+ });
828
+ });
829
+ });
830
+ };
831
+
832
+ if (selector) {
833
+ var target = null;
834
+ try { target = document.querySelector(selector); }
835
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
836
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
837
+ // Instant on purpose: the page's own smooth scrolling would still be
838
+ // animating when the next action runs against it.
839
+ target.scrollIntoView({ block: 'center', behavior: 'instant' });
840
+ return settle({ scrolledTo: cssPath(target) });
841
+ }
842
+
843
+ var doc = document.documentElement;
844
+ var page = Math.round(window.innerHeight * 0.85);
845
+ var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
846
+ if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
847
+ else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
848
+ else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
849
+ else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
850
+ else return { ok: false, error: 'Unknown scroll direction: ' + direction };
851
+ return settle({ direction: direction });
852
+ `),Jw=["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"],Zw=({selector:t})=>ro(`
853
+ var selector = ${JSON.stringify(t)};
854
+ var target = null;
855
+ try { target = document.querySelector(selector); }
856
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
857
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
858
+
859
+ var computed = window.getComputedStyle(target);
860
+ var styles = {};
861
+ var props = ${JSON.stringify(Jw)};
862
+ for (var i = 0; i < props.length; i += 1) {
863
+ var value = computed.getPropertyValue(props[i]);
864
+ if (value) styles[props[i]] = String(value).trim();
865
+ }
866
+
867
+ var rect = target.getBoundingClientRect();
868
+ return {
869
+ ok: true,
870
+ selector: cssPath(target),
871
+ tag: target.tagName.toLowerCase(),
872
+ label: label(target),
873
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
874
+ inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
875
+ styles: styles
876
+ };
877
+ `),ev=t=>{const e=tt.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=Nt();if(n.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(p,y)=>s.jsxs("div",{role:"option","aria-selected":y===r,className:Ee("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",y===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),i(p.url)},onPointerEnter:()=>l(y),children:[s.jsx(_,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||ol(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:Ee("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:x=>{x.preventDefault(),x.stopPropagation(),o(p.url)},children:s.jsx(_,{name:"close",className:"size-3","aria-hidden":"true"})})]},p.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let m;return e[15]!==d||e[16]!==u?(m=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=m):m=e[17],m},en=t=>{const e=tt.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=Ee("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 m;e[2]!==n?(m=s.jsx(_,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=m):m=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==m?(f=s.jsx(St,{asChild:!0,children:s.jsx(ct,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:m})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=m,e[11]=f):f=e[11];let p;e[12]!==r?(p=s.jsx(jt,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let y;return e[14]!==f||e[15]!==p?(y=s.jsxs(vt,{children:[f,p]}),e[14]=f,e[15]=p,e[16]=y):y=e[16],y},Rf=t=>{const e=tt.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:m,canGoBack:f,canGoForward:p,isLoading:y,onAnnotate:x,onOpenDevTools:k,isAnnotating:w,onHardReload:h,onZoomIn:g,onZoomOut:j,onZoomReset:b,zoomPercent:S,onClearCookies:C,onClearCache:v,onToggleDeviceBar:E,isDeviceBarOpen:R}=t;let A;e[0]!==r?(A=r===void 0?[]:r,e[0]=r,e[1]=A):A=e[1];const O=A,B=S===void 0?100:S,{t:T}=Nt(),[M,L]=c.useState(!1),[W,$]=c.useState(-1);let P;e[2]!==M||e[3]!==O?(P=M?O:[],e[2]=M,e[3]=O,e[4]=P):P=e[4];const D=P;let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{$(-1)},e[5]=I):I=e[5];let X;e[6]!==n||e[7]!==M?(X=[n,M],e[6]=n,e[7]=M,e[8]=X):X=e[8],c.useEffect(I,X);let Z;e[9]!==l?(Z=Fe=>{L(!1),$(-1),l(Fe)},e[9]=l,e[10]=Z):Z=e[10];const ne=Z;let ue;e[11]!==W||e[12]!==ne||e[13]!==D?(ue=Fe=>{if(D.length!==0){if(Fe.key==="ArrowDown"||Fe.key==="ArrowUp"){Fe.preventDefault();const Me=Fe.key==="ArrowDown"?1:-1,Ae=D.length;$(Q=>{const Ce=Q+Me;return Ce<-1?Ae-1:Ce>=Ae?-1:Ce});return}if(Fe.key==="Escape"&&W>=0){Fe.preventDefault(),$(-1);return}if(Fe.key==="Enter"&&W>=0){Fe.preventDefault();const Me=D[W];Me&&ne(Me.url)}}},e[11]=W,e[12]=ne,e[13]=D,e[14]=ue):ue=e[14];const se=ue;let xe;e[15]!==T?(xe=T("contextPanel.browser.back"),e[15]=T,e[16]=xe):xe=e[16];const ie=!f;let Re;e[17]!==a||e[18]!==ie||e[19]!==xe?(Re=s.jsx(en,{icon:"arrow-left",label:xe,onClick:a,disabled:ie}),e[17]=a,e[18]=ie,e[19]=xe,e[20]=Re):Re=e[20];let be;e[21]!==T?(be=T("contextPanel.browser.forward"),e[21]=T,e[22]=be):be=e[22];const fe=!p;let ke;e[23]!==d||e[24]!==be||e[25]!==fe?(ke=s.jsx(en,{icon:"arrow-right",label:be,onClick:d,disabled:fe}),e[23]=d,e[24]=be,e[25]=fe,e[26]=ke):ke=e[26];let H;e[27]!==y||e[28]!==T?(H=T(y?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=y,e[28]=T,e[29]=H):H=e[29];let J;e[30]!==u||e[31]!==H?(J=s.jsx(en,{icon:"refresh",label:H,onClick:u}),e[30]=u,e[31]=H,e[32]=J):J=e[32];let ce;e[33]!==h||e[34]!==T?(ce=h?s.jsx(en,{icon:"restart",label:T("contextPanel.browser.hardReload"),onClick:h}):null,e[33]=h,e[34]=T,e[35]=ce):ce=e[35];let je;e[36]!==n||e[37]!==ne?(je=Fe=>{Fe.preventDefault(),ne(n)},e[36]=n,e[37]=ne,e[38]=je):je=e[38];let G;e[39]!==o?(G=Fe=>o(Fe.target.value),e[39]=o,e[40]=G):G=e[40];let we,Te;e[41]===Symbol.for("react.memo_cache_sentinel")?(we=()=>L(!0),Te=()=>L(!1),e[41]=we,e[42]=Te):(we=e[41],Te=e[42]);const he=D.length>0;let re;e[43]===Symbol.for("react.memo_cache_sentinel")?(re=Ee("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=re):re=e[43];let ge;e[44]!==T?(ge=T("contextPanel.browser.addressAria"),e[44]=T,e[45]=ge):ge=e[45];let q;e[46]!==n||e[47]!==se||e[48]!==G||e[49]!==he||e[50]!==ge?(q=s.jsx("input",{value:n,onChange:G,onFocus:we,onBlur:Te,onKeyDown:se,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":he,"aria-controls":"openchamber-browser-address-suggestions",className:re,"aria-label":ge}),e[46]=n,e[47]=se,e[48]=G,e[49]=he,e[50]=ge,e[51]=q):q=e[51];let z;e[52]!==i?(z=Fe=>i?.(Fe),e[52]=i,e[53]=z):z=e[53];let ee;e[54]!==W||e[55]!==ne||e[56]!==z||e[57]!==D?(ee=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(ev,{entries:D,activeIndex:W,onSelect:ne,onForget:z,onHighlight:$})}),e[54]=W,e[55]=ne,e[56]=z,e[57]=D,e[58]=ee):ee=e[58];let de;e[59]!==je||e[60]!==q||e[61]!==ee?(de=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:je,children:[q,ee]}),e[59]=je,e[60]=q,e[61]=ee,e[62]=de):de=e[62];let Y;e[63]!==g||e[64]!==j||e[65]!==b||e[66]!==T||e[67]!==B?(Y=j&&g?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(en,{icon:"subtract",label:T("contextPanel.browser.zoomOut"),onClick:j}),B!==100&&b?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ct,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:b,"aria-label":T("contextPanel.browser.zoomReset"),children:[B,"%"]})}),s.jsx(jt,{sideOffset:6,children:T("contextPanel.browser.zoomReset")})]}):null,s.jsx(en,{icon:"add",label:T("contextPanel.browser.zoomIn"),onClick:g})]}):null,e[63]=g,e[64]=j,e[65]=b,e[66]=T,e[67]=B,e[68]=Y):Y=e[68];let U;e[69]!==C||e[70]!==T?(U=C?s.jsx(en,{icon:"delete-bin",label:T("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=T,e[71]=U):U=e[71];let F;e[72]!==v||e[73]!==T?(F=v?s.jsx(en,{icon:"database-2",label:T("contextPanel.browser.clearCache"),onClick:v}):null,e[72]=v,e[73]=T,e[74]=F):F=e[74];let V;e[75]!==R||e[76]!==E||e[77]!==T?(V=E?s.jsx(en,{icon:"smartphone",label:T("contextPanel.browser.deviceToolbar"),onClick:E,pressed:R}):null,e[75]=R,e[76]=E,e[77]=T,e[78]=V):V=e[78];let oe;e[79]!==w||e[80]!==x||e[81]!==T?(oe=x?s.jsx(en,{icon:"markup",label:T("contextPanel.browser.annotate.toggle"),onClick:x,pressed:w}):null,e[79]=w,e[80]=x,e[81]=T,e[82]=oe):oe=e[82];let ae;e[83]!==k||e[84]!==T?(ae=k?s.jsx(en,{icon:"terminal-box",label:T("contextPanel.browser.devTools"),onClick:k}):null,e[83]=k,e[84]=T,e[85]=ae):ae=e[85];let pe;e[86]!==T?(pe=T("contextPanel.browser.openExternal"),e[86]=T,e[87]=pe):pe=e[87];let le;e[88]!==m||e[89]!==pe?(le=s.jsx(en,{icon:"external-link",label:pe,onClick:m}),e[88]=m,e[89]=pe,e[90]=le):le=e[90];let _e;return e[91]!==Re||e[92]!==ke||e[93]!==J||e[94]!==ce||e[95]!==de||e[96]!==Y||e[97]!==U||e[98]!==F||e[99]!==V||e[100]!==oe||e[101]!==ae||e[102]!==le?(_e=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Re,ke,J,ce,de,Y,U,F,V,oe,ae,le]}),e[91]=Re,e[92]=ke,e[93]=J,e[94]=ce,e[95]=de,e[96]=Y,e[97]=U,e[98]=F,e[99]=V,e[100]=oe,e[101]=ae,e[102]=le,e[103]=_e):_e=e[103],_e},Uo={kind:"fill"},Pc=240,tv=3840,Mf=[{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}],Dc=t=>Number.isFinite(t)?Math.round(Math.min(tv,Math.max(Pc,t))):Pc,Ho=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Of=t=>{const e=Mf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},sv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},nv=(t,e)=>{const n=Ho(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},rv=["mobile","tablet","desktop","fill"],ov={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Ic=t=>typeof t=="string"&&rv.includes(t),Sa=t=>t==="fill"?Uo:Of(ov[t])??Uo,xo=t=>{const e=Ho(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Sa(n),i=Ho(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},iv=t=>{const e=tt.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=Nt();let d;e[0]!==n?(d=Ho(n),e[0]=n,e[1]=d):d=e[1];const u=d,m=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(ie,Re)=>{const be=Number.parseInt(Re,10);if(!Number.isFinite(be))return;const fe=u??{width:1280,height:800};r({kind:"custom",width:Dc(ie==="width"?be:fe.width),height:Dc(ie==="height"?be:fe.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const p=f;let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=Ee("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]=y):y=e[5];const x=y;let k;e[6]!==r?(k=ie=>{const Re=Of(ie.target.value);r(Re??Uo)},e[6]=r,e[7]=k):k=e[7];let w;e[8]!==a?(w=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=w):w=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=Ee("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]=h):h=e[10];let g;e[11]!==a?(g=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=g):g=e[12];let j;e[13]!==g?(j=s.jsx("option",{value:"",children:g}),e[13]=g,e[14]=j):j=e[14];let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=Mf.map(av),e[15]=b):b=e[15];let S;e[16]!==m||e[17]!==k||e[18]!==w||e[19]!==j?(S=s.jsxs("select",{value:m,onChange:k,"aria-label":w,className:h,children:[j,b]}),e[16]=m,e[17]=k,e[18]=w,e[19]=j,e[20]=S):S=e[20];const C=u?String(u.width):"";let v;e[21]!==p?(v=ie=>p("width",ie.target.value),e[21]=p,e[22]=v):v=e[22];let E;e[23]!==a?(E=a("contextPanel.browser.device.width"),e[23]=a,e[24]=E):E=e[24];let R;e[25]!==C||e[26]!==v||e[27]!==E?(R=s.jsx("input",{value:C,onChange:v,placeholder:"—",inputMode:"numeric","aria-label":E,className:x}),e[25]=C,e[26]=v,e[27]=E,e[28]=R):R=e[28];let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=A):A=e[29];const O=u?String(u.height):"";let B;e[30]!==p?(B=ie=>p("height",ie.target.value),e[30]=p,e[31]=B):B=e[31];let T;e[32]!==a?(T=a("contextPanel.browser.device.height"),e[32]=a,e[33]=T):T=e[33];let M;e[34]!==O||e[35]!==B||e[36]!==T?(M=s.jsx("input",{value:O,onChange:B,placeholder:"—",inputMode:"numeric","aria-label":T,className:x}),e[34]=O,e[35]=B,e[36]=T,e[37]=M):M=e[37];let L;e[38]!==r||e[39]!==n?(L=()=>r(sv(n)),e[38]=r,e[39]=n,e[40]=L):L=e[40];const W=!u;let $;e[41]!==a?($=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=$):$=e[42];let P;e[43]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(_,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=P):P=e[43];let D;e[44]!==L||e[45]!==W||e[46]!==$?(D=s.jsx(St,{asChild:!0,children:s.jsx(ct,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:L,disabled:W,"aria-label":$,children:P})}),e[44]=L,e[45]=W,e[46]=$,e[47]=D):D=e[47];let I;e[48]!==a?(I=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=I):I=e[49];let X;e[50]!==I?(X=s.jsx(jt,{sideOffset:6,children:I}),e[50]=I,e[51]=X):X=e[51];let Z;e[52]!==D||e[53]!==X?(Z=s.jsxs(vt,{children:[D,X]}),e[52]=D,e[53]=X,e[54]=Z):Z=e[54];let ne;e[55]!==l||e[56]!==u?(ne=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=ne):ne=e[57];let ue;e[58]===Symbol.for("react.memo_cache_sentinel")?(ue=["system","light","dark"],e[58]=ue):ue=e[58];let se;e[59]!==i||e[60]!==o||e[61]!==a?(se=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ue.map(ie=>s.jsx(ct,{type:"button",variant:i===ie?"secondary":"ghost",size:"xs",className:Ee("shrink-0 rounded-full px-2.5 typography-micro",i===ie?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(ie),"aria-pressed":i===ie,children:a(ie==="system"?"contextPanel.browser.device.schemeSystem":ie==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ie))}),e[59]=i,e[60]=o,e[61]=a,e[62]=se):se=e[62];let xe;return e[63]!==S||e[64]!==R||e[65]!==M||e[66]!==Z||e[67]!==ne||e[68]!==se?(xe=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[S,R,A,M,Z,ne,se]}),e[63]=S,e[64]=R,e[65]=M,e[66]=Z,e[67]=ne,e[68]=se,e[69]=xe):xe=e[69],xe};function av(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const lv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},cv=2e3,dv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=Dn();if(!t)return!1;try{return!Nr(new URL(t,window.location.href).toString())}catch{return!1}},Bf=t=>{const e=tt.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=Nt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=Nb(i),[m]=c.useState(dv);let f,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let R=!0,A=null;const O=new AbortController,B=()=>{iw(O.signal).then(T=>{R&&(d(T),A=setTimeout(B,cv))})};return B(),()=>{R=!1,A&&clearTimeout(A),O.abort()}},p=[],e[1]=f,e[2]=p):(f=e[1],p=e[2]),c.useEffect(f,p);const y=a.kind==="ready"?a.servers:null;let x;e[3]!==u||e[4]!==y?(x=cw({announced:u,discovered:y}),e[3]=u,e[4]=y,e[5]=x):x=e[5];const k=x;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Nu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=w):w=e[6];let h;e[7]!==o?(h=o("contextPanel.browser.empty"),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==h?(g=s.jsx("span",{className:"typography-ui-header text-foreground",children:h}),e[9]=h,e[10]=g):g=e[10];let j;e[11]!==o?(j=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=j):j=e[12];let b;e[13]!==j?(b=s.jsx("span",{className:"typography-micro text-muted-foreground",children:j}),e[13]=j,e[14]=b):b=e[14];let S;e[15]!==b||e[16]!==g?(S=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[g,b]}),e[15]=b,e[16]=g,e[17]=S):S=e[17];let C;e[18]!==u||e[19]!==k||e[20]!==i||e[21]!==n||e[22]!==m||e[23]!==o?(C=k.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),m?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:k.map(R=>s.jsxs(ct,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{jb(i),n(R.url)},children:[s.jsx(_,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:ol(R.url)||R.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:lv(R.url)})]},R.port))})]}):null,e[18]=u,e[19]=k,e[20]=i,e[21]=n,e[22]=m,e[23]=o,e[24]=C):C=e[24];let v;e[25]!==k.length||e[26]!==a.kind||e[27]!==o?(v=k.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=k.length,e[26]=a.kind,e[27]=o,e[28]=v):v=e[28];let E;return e[29]!==S||e[30]!==C||e[31]!==v?(E=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[w,S,C,v]}),e[29]=S,e[30]=C,e[31]=v,e[32]=E):E=e[32],E},Bs=t=>Math.round(t),uv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Bs(l.x)}, y=${Bs(l.y)}, width=${Bs(l.width)}, height=${Bs(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},fv=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Bs(n.x)}, y=${Bs(n.y)}, width=${Bs(n.width)}, height=${Bs(n.height)}`},mv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Bs(n.x)}, y=${Bs(n.y)}, width=${Bs(n.width)}, height=${Bs(n.height)}`},hv=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Bs(t.viewport.width)}x${Bs(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...uv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(fv(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(mv(l,a)))),o.filter(l=>typeof l=="string").join(`
878
+ `)},pv=t=>{const e=tt.c(7),{t:n}=Nt(),r=rt(xv),i=rt(bv),o=Ji(yv),l=Lp(wv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){Ke.error(n("contextPanel.browser.annotate.noSession"));return}let m=!1;if(d.screenshot)try{await l(d.screenshot),m=!0}catch{m=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:hv({payload:d.payload,screenshotAttached:m,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Ke.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},gv=()=>{const t=tt.c(16),{t:e}=Nt();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function xv(t){return t.currentSessionId}function bv(t){return t.newSessionDraft?.open}function yv(t){return t.addDraft}function wv(t){return t.addAttachedFile}const vv=3e4,Sv=3,jv=250,kv={attempts:0,windowStartedAt:null},Cv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=vv,r=n?0:t.attempts;return r>=Sv?null:{delayMs:jv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Nv=-3,bo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",gr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Av=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:fw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,m]=c.useState(!1),[f,p]=c.useState(!1),y=c.useRef(n);y.current=n;const x=c.useRef(kv);return c.useEffect(()=>{if(!t)return;const k=()=>{try{const A=t.getURL();return bo(A)?A:""}catch{return""}},w=()=>{try{m(t.canGoBack()),p(t.canGoForward())}catch{}},h=A=>{bo(A)&&(l(A),y.current(A))},g=()=>{const A=k();i({kind:"loading",url:A})},j=()=>{const A=k();let O="";try{O=t.getTitle()||""}catch{O=""}d(O),h(A),w(),i(B=>B.kind==="failed"&&B.url===A?B:{kind:"ready",url:A,title:O})},b=A=>{const O=gr(A);bo(O.url)&&(h(O.url),w())},S=A=>{const O=gr(A),B=Array.isArray(O.favicons)?O.favicons.find(Boolean):"",T=k();B&&T&&Sf.getState().resolve(T,B)},C=A=>{const O=gr(A);typeof O.title=="string"&&d(O.title)},v=A=>{const O=gr(A);if(O.isMainFrame===!1)return;const B=typeof O.errorCode=="number"?O.errorCode:0;B!==Nv&&i({kind:"failed",url:bo(O.validatedURL)?O.validatedURL:k(),code:B,description:typeof O.errorDescription=="string"?O.errorDescription:""})};let E=null;const R=()=>{const A=k(),O=Cv(x.current,Date.now());if(!O){i({kind:"failed",url:A,code:0,description:"",crashed:!0});return}x.current=O.state,i({kind:"loading",url:A}),E=setTimeout(()=>{E=null;try{t.reload()}catch{i({kind:"failed",url:A,code:0,description:"",crashed:!0})}},O.delayMs)};t.addEventListener("did-start-loading",g),t.addEventListener("did-stop-loading",j),t.addEventListener("did-navigate",b),t.addEventListener("did-navigate-in-page",b),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",S),t.addEventListener("did-fail-load",v),t.addEventListener("render-process-gone",R),t.addEventListener("crashed",R);try{!t.isLoading()&&k()&&j()}catch{}return()=>{E!==null&&clearTimeout(E),t.removeEventListener("render-process-gone",R),t.removeEventListener("crashed",R),t.removeEventListener("did-start-loading",g),t.removeEventListener("did-stop-loading",j),t.removeEventListener("did-navigate",b),t.removeEventListener("did-navigate-in-page",b),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",S),t.removeEventListener("did-fail-load",v)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},Pv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Dv=4e4,yo=.5,Iv=-3,Tv=4,Ev="persist:openchamber-browser",Tc=20,Rv=600,Mv=2e4,Ov=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=Nt(),{currentTheme:i}=Ln(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(Y=>{o.current=Y,a(Y)},[]),u=Ne(Y=>Y.setContextPanelTabTargetPath),m=c.useRef(wr(t)),f=m.current!==tn?m.current:"",[p,y]=c.useState(f?null:tn),[x,k]=c.useState(f),[w,h]=c.useState(!1),[g,j]=c.useState(!1),[b,S]=c.useState(0),C=c.useRef(0),[v,E]=c.useState(!1),[R,A]=c.useState(Uo),O=c.useRef(R);O.current=R;const B=c.useRef([]),[T,M]=c.useState("system"),[L,W]=c.useState({width:0,height:0}),$=c.useRef(null),P=c.useRef(null),D=c.useRef(!1),I=c.useRef(Date.now()),X=c.useCallback(Y=>{!Y||Y===tn||!e||!n||u(e,n,Y)},[e,n,u]),Z=Av(l,{initialUrl:f,onUrlChange:c.useCallback(Y=>{const U=Rr(Y);k(U),X(U)},[X])}),[ne,ue]=c.useState(null),se=pv(e),xe=gv(),ie=Z.status.kind==="loading",Re=Sr(Df(e)),be=Sr(Y=>Y.recordVisit),fe=Sr(Y=>Y.forget);c.useEffect(()=>{Z.status.kind==="ready"&&be(e,{url:Rr(Z.status.url),title:Z.status.title})},[e,Z.status,be]);const ke=c.useMemo(()=>Pf(Re,x),[Re,x]),H=c.useCallback(Y=>{const U=wr(Y);U!==tn&&(k(U),ue(null),Cc(U).then(F=>{const V=o.current;if(!V){y(F);return}try{V.loadURL(F)}catch{y(F)}}).catch(F=>{F instanceof Hr&&ue(U)}))},[]);c.useEffect(()=>{if(!f)return;let Y=!0;return Cc(f).then(U=>{Y&&y(U)}).catch(U=>{if(Y){if(U instanceof Hr){ue(f),y(tn);return}y(f)}}),()=>{Y=!1}},[]);const J=c.useMemo(()=>({executeJavaScript:async(Y,U)=>{const F=o.current;if(!F)throw new Error("Browser view is not available");return F.executeJavaScript(Y,U)},capturePage:async()=>{const Y=o.current;if(!Y)return null;const U=Y.getWebContentsId();return Number.isFinite(U)?await br("desktop_browser_capture_page",{webContentsId:U}):null}}),[]),ce=c.useCallback(()=>{if(w){h(!1),Eo(J);return}if(!Z.url){Ke.error(r("contextPanel.browser.annotate.noPage"));return}const Y=Nw(i.metadata.variant==="light"?"light":"dark");h(!0),kw({host:J,theme:Y,labels:xe}).then(async U=>{h(!1),U&&await se(U)}).catch(()=>{h(!1),Ke.error(r("contextPanel.browser.annotate.failed"))})},[J,se,i,w,Z.url,xe,r]);c.useEffect(()=>{if(!w)return;const Y=U=>{$p(U)||U.key!=="Escape"||(U.preventDefault(),U.stopImmediatePropagation(),h(!1),Eo(J))};return window.addEventListener("keydown",Y,!0),()=>window.removeEventListener("keydown",Y,!0)},[J,w]);const je=c.useCallback(async(Y=8e3)=>{const U=Date.now();for(;;){const F=o.current;if(!F)return!1;let V=!1;try{V=F.isLoading()}catch{return!1}if(!V)return!0;if(Date.now()-U>Y)return!1;await new Promise(oe=>setTimeout(oe,120))}},[]),G=c.useCallback(async(Y,U)=>{const F=o.current;if(!F)throw new Error("The browser panel is not ready");const V=()=>{Ic(U.viewport)&&(A(Sa(U.viewport)),E(!0))};if(Y==="browser.back"||Y==="browser.forward"){const Fe=Y==="browser.back";if(!(Fe?F.canGoBack():F.canGoForward()))throw new Error(Fe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Fe?F.goBack():F.goForward(),await new Promise(Q=>setTimeout(Q,150)),await je();let Ae="";try{Ae=F.getTitle()||""}catch{Ae=""}return{url:Rr(F.getURL()),title:Ae}}if(Y==="browser.capture"){const Fe=Ne.getState(),Me=Qn(e),Ae=Fe.contextPanelByDirectory[Me],Q=!!(Ae?.isOpen&&Ae.activeTabId===n);Q||Fe.setActiveContextPanelTab(e,n);const Ce=()=>{if(Q||!Ae)return;const Be=Ne.getState(),Le=Be.contextPanelByDirectory[Me];!Le?.isOpen||Le.activeTabId!==n||(Ae.activeTabId&&Ae.activeTabId!==n&&Be.setActiveContextPanelTab(e,Ae.activeTabId),Ae.isOpen||Be.closeContextPanel(e))};try{const Be=Date.now()+1200;let Le=0,Je=0;for(;Je<2&&Date.now()<Be;){const it=F.getBoundingClientRect().width;Je=it>=2&&Math.abs(it-Le)<.5?Je+1:0,Le=it,await new Promise(ht=>setTimeout(ht,50))}await new Promise(it=>{requestAnimationFrame(()=>requestAnimationFrame(()=>it()))}),await je();const ot=await J.capturePage();if(!ot)throw new Error("The page could not be captured");let et="";try{et=F.getTitle()||""}catch{et=""}return{...ot,url:Rr(F.getURL()),title:et,viewport:xo(O.current)}}finally{Ce()}}if(Y==="browser.resize"){if(!Ic(U.viewport))throw new Error("viewport is required");return V(),await new Promise(Fe=>setTimeout(Fe,200)),await je(),{viewport:xo(Sa(U.viewport))}}if(Y==="browser.open"){const Fe=typeof U.url=="string"?U.url:"";if(!Fe)throw new Error("url is required");V(),H(Fe),await new Promise(Q=>setTimeout(Q,150));const Me=await je(25e3);let Ae="";try{Ae=F.getTitle()||""}catch{Ae=""}return{url:wr(Fe),title:Ae,opened:!0,settled:Me,viewport:xo(O.current)}}await je();const oe=Fe=>typeof Fe=="string"&&Fe?Fe:void 0,pe=(()=>{switch(Y){case"browser.snapshot":return qw({selector:oe(U.selector)});case"browser.click":return Yw({selector:oe(U.selector),text:oe(U.text)});case"browser.type":return Qw({selector:String(U.selector??""),value:String(U.value??""),submit:U.submit===!0});case"browser.inspect":return Zw({selector:String(U.selector??"")});case"browser.scroll":return Xw({selector:oe(U.selector),direction:oe(U.direction)});default:return null}})();if(!pe)throw new Error(`Unsupported browser action: ${Y}`);const le=await F.executeJavaScript(pe,!0);if(!le||typeof le!="object")throw new Error("The page returned no result");const _e=le;if(_e.ok!==!0)throw new Error(typeof _e.error=="string"&&_e.error?_e.error:"Browser action failed");if(Y==="browser.snapshot"){const Fe=B.current;return{..._e,viewport:xo(O.current),...Fe.length>0?{consoleProblems:[...Fe]}:{}}}return(Y==="browser.click"||Y==="browser.type"&&U.submit===!0)&&(await new Promise(Fe=>setTimeout(Fe,150)),await je()),le},[J,e,H,n,je]);c.useEffect(()=>Ew({run:G}),[G]),c.useEffect(()=>{const Y=J;return()=>{Eo(Y)}},[J]),c.useEffect(()=>{if(!l)return;const Y=F=>{const V=F;if(typeof V.level!="number"||V.level<2)return;const oe=V.sourceId?`${V.sourceId}${V.line?`:${V.line}`:""}`:"";B.current.push({level:V.level>=3?"error":"warning",message:String(V.message??"").slice(0,400),source:oe}),B.current.length>Tc&&B.current.splice(0,B.current.length-Tc)},U=()=>{B.current=[]};return l.addEventListener("console-message",Y),l.addEventListener("did-start-loading",U),()=>{l.removeEventListener("console-message",Y),l.removeEventListener("did-start-loading",U)}},[l]);const we=c.useRef(new Set),Te=c.useCallback(Y=>{we.current.clear(),H(Y)},[H]);c.useEffect(()=>{if(!l)return;const Y=F=>{const V=gr(F),oe=typeof V.url=="string"?V.url:"";!oe||!Nc(oe)||(F.preventDefault(),H(oe))},U=F=>{const V=gr(F);if(V.isMainFrame===!1||V.errorCode===-3)return;const oe=typeof V.validatedURL=="string"?V.validatedURL:"";!oe||!Nc(oe)||we.current.has(oe)||(we.current.add(oe),H(oe))};return l.addEventListener("will-navigate",Y),l.addEventListener("did-fail-load",U),()=>{l.removeEventListener("will-navigate",Y),l.removeEventListener("did-fail-load",U)}},[H,l]),c.useEffect(()=>{if(!l)return;const Y=U=>{const F=U.detail;U.preventDefault(),F?.url&&H(F.url)};return l.addEventListener("new-window",Y),()=>l.removeEventListener("new-window",Y)},[H,l]);const he=c.useCallback(Y=>{const U=Math.min(Tv,Math.max(Iv,Y));C.current=U,S(U);try{o.current?.setZoomLevel(U)}catch{}},[]);c.useEffect(()=>{const Y=U=>{if(!(U instanceof CustomEvent))return;const F=U.detail,V=o.current;!V||document.activeElement!==V||(F==="zoom-in"?he(C.current+yo):F==="zoom-out"?he(C.current-yo):F==="zoom-reset"&&he(0))};return window.addEventListener("openchamber:zoom",Y),()=>window.removeEventListener("openchamber:zoom",Y)},[he]);const re=c.useCallback(Y=>{br("desktop_browser_clear_data",{partition:Ev,cookies:Y==="cookies",cache:Y==="cache"}).then(()=>{Ke.success(r(Y==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Ke.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const Y=$.current;if(!Y||typeof ResizeObserver>"u")return;const U=new ResizeObserver(F=>{const V=F[0]?.contentRect;V&&W({width:V.width,height:V.height})});return U.observe(Y),()=>U.disconnect()},[]);const ge=c.useCallback(Y=>{M(Y);const U=o.current;if(!U)return;let F=-1;try{F=U.getWebContentsId()}catch{return}br("desktop_browser_set_color_scheme",{webContentsId:F,scheme:Y}).catch(V=>{M("system"),Ke.error(V instanceof Error?V.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),q=c.useCallback(()=>{try{ie?o.current?.stop():o.current?.reload()}catch{}},[ie]),z=Z.status;c.useEffect(()=>{const Y=()=>{j(!0);const V=setTimeout(()=>{try{o.current?.reload()}catch{}},Rv);return()=>clearTimeout(V)};if(z.kind==="failed"){if(!rw(z.code,z.url)){j(!1);return}const V=Date.now(),oe=P.current?.url===z.url?P.current:{url:z.url,startedAt:V};if(P.current=oe,V-oe.startedAt>Dv){j(!1);return}return Y()}if(z.kind==="loading")return;if(P.current=null,z.kind!=="ready"||!z.url||!Nr(z.url)){D.current=!0,j(!1);return}if(D.current||Date.now()-I.current>Mv){D.current=!0,j(!1);return}let U=!1,F=null;return aw(Rr(z.url)).then(V=>{if(!U){if(V===null||V<500){D.current=!0,j(!1);return}F=Y()}}),()=>{U=!0,F?.()}},[z]);const ee=Z.status.kind==="failed"&&!g?Z.status:null,de=nv(R,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Rf,{address:x,onAddressChange:k,onSubmit:Te,suggestions:ke,onForgetSuggestion:Y=>fe(e,Y),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:q,onOpenExternal:()=>{eo(Z.url||x)},canGoBack:Z.canGoBack,canGoForward:Z.canGoForward,isLoading:ie,onAnnotate:ce,isAnnotating:w,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>he(b+yo),onZoomOut:()=>he(b-yo),onZoomReset:()=>he(0),zoomPercent:Math.round(Math.pow(1.2,b)*100),onClearCookies:()=>re("cookies"),onClearCache:()=>re("cache"),onToggleDeviceBar:()=>E(Y=>!Y),isDeviceBarOpen:v}),v?s.jsx(iv,{viewport:R,onViewportChange:A,colorScheme:T,onColorSchemeChange:ge,scale:de?.scale??1}):null,s.jsxs("div",{ref:$,className:Ee("relative min-h-0 flex-1 bg-background",de&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:d,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:de?{width:`${de.width}px`,height:`${de.height}px`,transform:`scale(${de.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!Z.url&&!ie?s.jsx(Bf,{onOpen:Te,directory:e}):null,g?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,ne?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:ne})})]}):null,ee&&!ne?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ee.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ee.crashed?r("contextPanel.browser.crashedHint"):ee.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ie?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},Bv=t=>{const e=tt.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=Nt(),l=Ne(_v);let a;e[0]!==n?(a=wr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==tn?d:"",[m,f]=c.useState(u),[p,y]=c.useState(u);let x;e[2]!==u?(x=u?[u]:[],e[2]=u,e[3]=x):x=e[3];const[k,w]=c.useState(x),[h,g]=c.useState(u?0:-1),[j,b]=c.useReducer(Lv,0);let S;e[4]!==r||e[5]!==l||e[6]!==i?(S=xe=>{!xe||xe===tn||!r||!i||l(r,i,xe)},e[4]=r,e[5]=l,e[6]=i,e[7]=S):S=e[7];const C=S;let v;e[8]!==r?(v=Df(r),e[8]=r,e[9]=v):v=e[9];const E=Sr(v),R=Sr($v),A=Sr(zv);let O;e[10]!==m||e[11]!==E?(O=Pf(E,m),e[10]=m,e[11]=E,e[12]=O):O=e[12];const B=O;let T;e[13]!==r||e[14]!==h||e[15]!==C||e[16]!==R?(T=xe=>{const ie=wr(xe);ie!==tn&&(f(ie),y(ie),C(ie),R(r,{url:ie}),w(Re=>{const be=h>=0?Re.slice(0,h+1):[];return be[be.length-1]===ie?(g(be.length-1),be):(g(be.length),[...be,ie])}))},e[13]=r,e[14]=h,e[15]=C,e[16]=R,e[17]=T):T=e[17];const M=T;let L;e[18]!==k||e[19]!==C?(L=xe=>{const ie=k[xe];ie&&(g(xe),f(ie),y(ie),C(ie))},e[18]=k,e[19]=C,e[20]=L):L=e[20];const W=L;let $;e[21]!==r||e[22]!==A?($=xe=>A(r,xe),e[21]=r,e[22]=A,e[23]=$):$=e[23];let P,D;e[24]!==W||e[25]!==h?(D=()=>W(h-1),P=()=>W(h+1),e[24]=W,e[25]=h,e[26]=P,e[27]=D):(P=e[26],D=e[27]);let I;e[28]!==m||e[29]!==p?(I=()=>{eo(p||m)},e[28]=m,e[29]=p,e[30]=I):I=e[30];const X=h>0,Z=h>=0&&h<k.length-1;let ne;e[31]!==m||e[32]!==M||e[33]!==B||e[34]!==P||e[35]!==I||e[36]!==X||e[37]!==Z||e[38]!==$||e[39]!==D?(ne=s.jsx(Rf,{address:m,onAddressChange:f,onSubmit:M,suggestions:B,onForgetSuggestion:$,onBack:D,onForward:P,onReload:b,onOpenExternal:I,canGoBack:X,canGoForward:Z,isLoading:!1}),e[31]=m,e[32]=M,e[33]=B,e[34]=P,e[35]=I,e[36]=X,e[37]=Z,e[38]=$,e[39]=D,e[40]=ne):ne=e[40];let ue;e[41]!==p||e[42]!==M||e[43]!==j||e[44]!==o?(ue=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:p?s.jsx("iframe",{src:p,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${p}|${j}`):s.jsx(Bf,{onOpen:M})}),e[41]=p,e[42]=M,e[43]=j,e[44]=o,e[45]=ue):ue=e[45];let se;return e[46]!==ne||e[47]!==ue?(se=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[ne,ue]}),e[46]=ne,e[47]=ue,e[48]=se):se=e[48],se},Fv=t=>{const e=tt.c(3),[n]=c.useState(Pv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Ov,{...t}):s.jsx(Bv,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function _v(t){return t.setContextPanelTabTargetPath}function Lv(t){return t+1}function $v(t){return t.recordVisit}function zv(t){return t.forget}const Wv=Kn(()=>yn(()=>import("./WalkthroughView-lap5btCF.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,125,126,127])).then(t=>({default:t.WalkthroughView}))),Kv=Kn(()=>yn(()=>import("./DiffView-CjxUovbM.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,83,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,129,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),Vv=Kn(()=>yn(()=>import("./FilesView-DFWD0RQR.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,84,85,86,131,132,133,134,135,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,136,137,120,121,118,125,138,119,139])).then(t=>({default:t.FilesView}))),Uv=Kn(()=>yn(()=>import("./GitView-BWa7e5vw.js"),__vite__mapDeps([140,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,141,117,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,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),Hv=Kn(()=>yn(()=>import("./LinearIssuesView-C6dpIdjw.js"),__vite__mapDeps([142,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.LinearIssuesView}))),Gv=Kn(()=>yn(()=>import("./PlanView-BCk_VobP.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,131,57,58,59,60,61,62,79,55,56,63,132,133,134,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,119,139,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Ec=c.lazy(()=>yn(()=>import("./PluginPane-BPP1dbck.js").then(t=>t.l),__vite__mapDeps([86,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.PluginPane}))),_i={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-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},Rc=c.lazy(()=>yn(()=>import("./GuestSurfacePane-DDfzid3U.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,86])).then(t=>({default:t.GuestSurfacePane}))),Ff=320,al=600,qv=400,Yv=100,Qv=24,Go=new Map,Xv=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Mc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Ff,Math.round(t))):al,Oc=t=>{const e=t??(typeof window<"u"?window.innerWidth:al*2);return Math.max(Ff,e-qv)},Jv=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Zv=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},_f=(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==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):tr(t)?_a.getState().guests.find(r=>r.id===Fo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),eS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},tS=(t,e,n)=>{if(t.mode==="chat"){const r=ja(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?ol(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?eS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):_f(t.mode,n)},sS=t=>{const e=tt.c(8),{mode:n}=t,r=Va();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=m=>m.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Gp,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(to,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Bc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Ka,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(ff,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(_,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(_,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(_,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(_,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(_,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(_,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(_,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(_,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(_,{name:"chat-4",className:"h-3.5 w-3.5"});if(tr(t.mode))return s.jsx(sS,{mode:t.mode});if(t.mode==="browser"){const n=nS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(_,{name:"global",className:"h-3.5 w-3.5"})}},nS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},rS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=Nt(),i=Ne(g=>g.contextEditorTreeWidth),o=Ne(g=>g.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),y=c.useCallback(g=>{const j=p.current;j&&(j.style.width=`${g}px`,j.style.setProperty("--oc-editor-tree-width",`${g}px`))},[]),x=g=>{if(t){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{}f.current=g.pointerId,a(!0),d.current=g.clientX,u.current=i,m.current=i,g.preventDefault()}},k=g=>{if(!l||f.current!==g.pointerId)return;const j=d.current-g.clientX,b=Ui(u.current+j);m.current!==b&&(m.current=b,y(b))},w=g=>{if(f.current!==g.pointerId)return;try{g.currentTarget.releasePointerCapture(g.pointerId)}catch{}const j=Ui(m.current??i);f.current=null,m.current=null,a(!1),o(j)},h=t?i:0;return s.jsxs("div",{ref:p,className:Ee("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?m.current??h:h}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?m.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&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Ee("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:x,onPointerMove:k,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Ee("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:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(k1,{visible:t&&e})})]})},ja=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,oS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},iS=(t,e)=>{if(e.length===0)return Go;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Go:r},aS=(t,e)=>{const n=Hp(t),r=c.useRef(Go),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=iS(n.getState().session,i.current);return oS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Go)},lS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,cS=()=>{const{t}=Nt(),e=dr()??"",n=c.useMemo(()=>Xv(e),[e]),r=Ne(K=>n?K.contextPanelByDirectory[n]:void 0),i=Ne(K=>K.closeContextPanel),o=Ne(K=>K.closeContextPanelTab),l=Ne(K=>K.openContextPanelTab),a=Ne(K=>K.toggleContextPanelExpanded),d=Ne(K=>K.setContextPanelWidth),u=Ne(K=>K.setActiveContextPanelTab),m=Ne(K=>K.openContextBrowser);c.useEffect(()=>{if(e)return Rw(K=>m(e,K,{reveal:!1}))},[e,m]);const f=Ne(K=>K.openContextFile);c.useEffect(()=>Wn(K=>{if(K.type!=="file-open-request")return;const Se=K.directory??e;Se&&f(Se,K.path)}),[e,f]);const p=Ne(K=>K.reorderContextPanelTabs),y=pn(K=>K.setSelectedPath),x=Ne(K=>K.contextEditorTreeVisible),k=Ne(K=>K.contextEditorTreeWidth),w=Ne(K=>K.setContextEditorTreeWidth),h=Ne(K=>K.toggleContextEditorTree),g=Ne(K=>K.contextEditorVisible),j=Ne(K=>K.toggleContextEditor),b=Ne(K=>K.openNewContextBrowserTab),S=Sf(K=>K.byOrigin),C=Ne(K=>K.allowPromptingSubagentSessions),{themeMode:v,setThemeMode:E,lightThemeId:R,darkThemeId:A,currentTheme:O}=Ln(),B=c.useMemo(()=>r?.tabs??[],[r?.tabs]),T=B.find(K=>K.id===r?.activeTabId)??B[B.length-1]??null,M=!!(r?.isOpen&&T),[L,W]=c.useState(null),$=c.useMemo(()=>B.some(K=>K.mode==="file"&&K.targetPath),[B]),P=$&&(g||!x),D=T?.mode??null,I=D==="file"&&!P,X=!!(M&&r?.expanded&&!I),Z=D?r?.widthByMode?.[D]:void 0,ne=D?r?.widthFractionByMode?.[D]:void 0,ue=D?zp(D):.5,se=L??(typeof window<"u"?window.innerWidth:al*2),xe=ne!=null&&L!=null?Math.round(ne*L):Z,ie=I?k:Mc(xe??Math.round(ue*se),Oc(L??se));c.useEffect(()=>{!n||!D||I||ne!=null||Z==null||L==null||d(n,D,Z,L)},[D,L,n,I,Z,ne,d]);const Re=c.useMemo(()=>{const K=[];for(const Se of B){if(Se.mode!=="chat")continue;const Ve=ja(Se.dedupeKey);Ve&&!K.includes(Ve)&&K.push(Ve)}return K},[B]),be=aS(n||void 0,Re),[fe,ke]=c.useState(!1),H=c.useRef(0),J=c.useRef(ie),ce=c.useRef(null),je=c.useRef(null),G=c.useRef(null),we=c.useRef(new Map),Te=c.useRef(new Map),he=c.useRef(!1);c.useLayoutEffect(()=>{const K=G.current?.parentElement;if(!K||typeof ResizeObserver>"u")return;const Se=new ResizeObserver(()=>{W(K.clientWidth||null)});return Se.observe(K),W(K.clientWidth||null),()=>Se.disconnect()},[]),c.useEffect(()=>{if(!M||he.current){he.current=M;return}const K=window.requestAnimationFrame(()=>{G.current?.focus({preventScroll:!0})});return he.current=!0,()=>window.cancelAnimationFrame(K)},[M]);const re=c.useRef(null),ge=c.useRef(null),q=c.useCallback(()=>{ge.current=null;const K=G.current,Se=ce.current;!K||Se===null||K.style.setProperty("--oc-context-panel-width",`${Se}px`)},[]);c.useEffect(()=>()=>{ge.current!==null&&clearTimeout(ge.current)},[]);const z=c.useCallback(K=>{const Se=re.current,Ve=I?Ui(K):Mc(K,Oc(Se));return Se===null?Ve:Math.min(Ve,Math.max(1,Se))},[I]),ee=c.useCallback(K=>{!M||X||!n||(je.current=K.pointerId,ke(!0),H.current=K.clientX,J.current=ie,ce.current=ie,re.current=Jv(G.current),document.documentElement.style.cursor="col-resize",K.preventDefault())},[n,X,M,ie]),de=c.useCallback(()=>{const K=z(ce.current??ie),Se=re.current;ce.current=null,re.current=null,ge.current!==null&&(clearTimeout(ge.current),ge.current=null),document.documentElement.style.cursor="",I?w(K):n&&D&&d(n,D,K,Se??void 0),ke(!1),je.current=null},[D,z,n,I,w,d,ie]);c.useEffect(()=>{if(!fe)return;const K=Xe=>{if(je.current!==Xe.pointerId)return;const nt=H.current-Xe.clientX,Ze=z(J.current+nt);ce.current!==Ze&&(ce.current=Ze,ge.current===null&&(ge.current=setTimeout(q,Yv)))},Se=Xe=>{je.current===Xe.pointerId&&de()},Ve=()=>{de()};return window.addEventListener("pointermove",K),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se),window.addEventListener("blur",Ve),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),window.removeEventListener("blur",Ve)}},[q,z,de,fe]),c.useEffect(()=>{fe||(ce.current=null,document.documentElement.style.cursor="")},[fe]);const Y=c.useCallback(()=>{n&&i(n)},[i,n]),U=c.useCallback(()=>{n&&a(n)},[n,a]),F=c.useCallback(K=>{K.key==="Escape"&&(K.target instanceof Node&&!K.currentTarget.contains(K.target)||Wp(K.target)||Kp(K.target)||(K.preventDefault(),K.stopPropagation(),Y()))},[Y]);c.useEffect(()=>{if(!(!n||!T)&&T.mode==="file"&&T.targetPath){y(n,T.targetPath,{allowOutsideRoot:!0});return}},[T,n,y]);const V=c.useMemo(()=>B.filter(K=>K.mode==="chat"),[B]),oe=M&&T?.mode==="chat"?T.id:null,ae=M&&T?.mode==="chat"?ja(T.dedupeKey):null,pe=sb(V,oe);c.useEffect(()=>{if(!M||!n||!ae||typeof window>"u")return;const K=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Ai(n,ae,!1);return}Au(ae),Ai(n,ae,!0)};K();const Se=window.setInterval(K,1e4);return window.addEventListener("focus",K),window.addEventListener("blur",K),document.addEventListener("visibilitychange",K),()=>{window.clearInterval(Se),window.removeEventListener("focus",K),window.removeEventListener("blur",K),document.removeEventListener("visibilitychange",K),Ai(n,ae,!1)}},[ae,n,M]);const le=c.useCallback((K,Se,Ve)=>nb(Te.current,K,Se,n||null,Ve,{mode:v,lightThemeId:R,darkThemeId:A,currentTheme:O},{allowPromptingSubagentSessions:C}),[C,O,A,n,R,v]),_e=pe&&ae?le(pe.id,ae,pe.readOnly):null;c.useEffect(()=>{const K=new Set(B.map(Se=>Se.id));for(const Se of Te.current.keys())K.has(Se)||Te.current.delete(Se)},[B]);const Fe=c.useCallback(K=>{!n||T?.mode!=="diff"||l(n,{mode:"diff",targetPath:T.targetPath,stagedDiff:K==="staged",diffScope:K})},[T,n,l]),Me=c.useCallback(()=>{if(typeof window>"u")return;const K={themeMode:v,lightThemeId:R,darkThemeId:A,currentTheme:O};for(const Se of we.current.values()){const Ve=Se.contentWindow;Ve&&Ve.postMessage({type:"openchamber:theme-sync",payload:K},window.location.origin)}},[O,A,R,v]),Ae=c.useCallback(()=>{if(typeof window>"u")return;const K={allowPromptingSubagentSessions:C};for(const Se of we.current.values()){const Ve=Se.contentWindow;Ve&&Ve.postMessage({type:"openchamber:chat-settings-sync",payload:K},window.location.origin)}},[C]),Q=c.useCallback((K,Se,Ve)=>{const Xe=Se.contentWindow;Xe&&Xe.postMessage({type:sf,payload:{visible:oe===K}},Ve)},[oe]),Ce=c.useCallback(()=>{if(!(typeof window>"u"))for(const[K,Se]of we.current.entries())Q(K,Se,window.location.origin)},[Q]);c.useEffect(()=>{if(typeof window>"u")return;const K=Se=>{if(Se.origin!==window.location.origin)return;const Ve=Array.from(we.current.entries()).find(([,We])=>We.contentWindow===Se.source);if(!Ve)return;const Xe=Se.data;if(Xe?.type===rb){const[We,Et]=Ve;Q(We,Et,Se.origin);return}if(Xe?.type===ob){if(typeof Xe.requestId!="string"||!Xe.requestId)return;const We=Qt(),Et={apiBaseUrl:Dn(),clientToken:Yr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:$d(),relayHostId:We.startsWith("host:")?We.slice(5):"",relay:Xm()??void 0};Se.source?.postMessage({type:ib,requestId:Xe.requestId,payload:Et},Se.origin);return}if(Xe?.type==="openchamber:theme-sync-request"){Me();return}if(Xe?.type==="openchamber:chat-settings-request"){Ae();return}if(Xe?.type!=="openchamber:cycle-theme-request")return;const nt=["light","dark","system"],gt=(nt.indexOf(v)+1)%nt.length;E(nt[gt])};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[Ae,Q,Me,E,v]),c.useLayoutEffect(()=>{B.some(Se=>Se.mode==="chat")&&(Me(),Ae(),Ce())},[A,R,Ae,Ce,Me,B,v]);const Be=T?.mode==="file"||T?.mode==="chat"||T?.mode==="browser",Le=c.useMemo(()=>T?B.filter(K=>K.mode===T.mode):[],[T,B]),Je=c.useMemo(()=>Le.map(K=>{const Se=tS(K,be,t),Ve=lS(Se,Qv),Xe=Zv(K.targetPath,e);return{id:K.id,label:Ve,icon:Bc(K,S),title:Xe?`${Se}: ${Xe}`:Se,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ve})}}),[Le,e,S,be,t]),ot=T?.mode==="context"?s.jsx(K1,{}):T?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uv,{isActive:M})}):T?.mode==="pr"?s.jsx(Xy,{}):T?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hv,{})}):T?.mode==="notes"?s.jsx(jh,{}):T?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Gv,{targetPath:T.targetPath,savedProjectPlan:T.projectPlanId&&T.projectPlanRef?{projectRef:T.projectPlanRef,planId:T.projectPlanId}:null})}):null,et=c.useMemo(()=>B.filter(K=>K.mode==="browser"),[B]),it=c.useMemo(()=>B.filter(K=>K.mode==="diff"),[B]),ht=c.useMemo(()=>B.find(K=>K.mode==="terminal")??null,[B]),st=c.useMemo(()=>B.some(K=>K.mode==="walkthrough"),[B]),mt=c.useMemo(()=>B.filter(K=>tr(K.mode)),[B]),kt=_a(K=>K.guests),Pe=c.useMemo(()=>new Set(kt.filter(Vp).map(K=>K.id)),[kt]),Ge=c.useMemo(()=>{const K=new Map;for(const Se of kt){const Ve=Up(Se);Ve&&K.set(Se.id,Ve)}return K},[kt]),at=c.useMemo(()=>B.some(K=>K.mode==="file"),[B]),ze=T?.mode==="file",ft=Ne(K=>K.closeContextPanelTabs),te=c.useCallback(K=>{if(!n)return null;const{id:Se,index:Ve,allIds:Xe,close:nt}=K,Ze=()=>ft(n,Xe.filter(At=>At!==Se)),gt=()=>ft(n,Xe.slice(0,Ve)),We=()=>ft(n,Xe.slice(Ve+1)),Et=()=>ft(n,Xe),Ft=Xe.length>1,Ie=Ve===0,yt=Ve===Xe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Xn,{onClick:nt,children:[s.jsx(_,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Yi,{}),s.jsxs(Xn,{onClick:Ze,disabled:!Ft,children:[s.jsx(_,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Xn,{onClick:gt,disabled:Ie,children:[s.jsx(_,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Xn,{onClick:We,disabled:yt,children:[s.jsx(_,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Yi,{}),s.jsxs(Xn,{onClick:Et,disabled:!Ft,children:[s.jsx(_,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[ft,n,t]),me=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Be?s.jsx(Hd,{items:Je,activeId:T?.id??null,onSelect:K=>{n&&u(n,K)},onClose:K=>{n&&o(n,K)},onReorder:(K,Se)=>{n&&p(n,K,Se)},layoutMode:"scrollable",variant:"default",tabContextMenu:te}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[T?Bc(T,S):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:T?_f(T.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[T?.mode==="browser"?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&b(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})}):null,ze&&$?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":P,children:s.jsx(_,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,ze?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":x,children:s.jsx(_,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,I?null:s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:U,className:"h-7 w-7 p-0",title:t(X?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(X?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:X?s.jsx(_,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:Y,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})]}),De=M?X?{"--oc-context-panel-width":L!==null?`${L}px`:"100%",width:L!==null?`${L}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${ie}px`}:{"--oc-context-panel-width":`${ie}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:G,"data-context-panel":"true",tabIndex:-1,inert:!M||void 0,className:Ee("flex min-h-0 flex-col overflow-hidden bg-background",X?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!M&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:F,style:De,children:[M&&!X&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),M&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!X&&s.jsx("div",{className:Ee("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",fe&&"bg-[var(--interactive-border)]"),onPointerDown:ee,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Ee("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!M&&"pointer-events-none select-none opacity-0"),style:{width:X?L!==null?`${L}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!M,children:[me,s.jsxs("div",{className:Ee("relative min-h-0 flex-1 overflow-hidden",fe&&"pointer-events-none"),children:[at?s.jsxs("div",{className:Ee("absolute inset-0 flex",ze?"flex":"hidden"),children:[$||!x?s.jsx("div",{className:Ee("h-full min-w-0 flex-1",$&&!P&&"hidden"),children:$?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vv,{mode:"editor-only",visible:M&&ze&&P})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(_,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(rS,{visible:x,active:M&&ze,fill:!P})]}):null,pe&&ae&&_e?s.jsx("iframe",{ref:K=>{if(!K){we.current.delete(pe.id);return}we.current.set(pe.id,K)},src:_e,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ae}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Me(),Ae(),Ce()}},pe.id):null,et.map(K=>s.jsx("div",{className:Ee("absolute inset-0",T?.id!==K.id&&"invisible pointer-events-none"),"aria-hidden":T?.id!==K.id||void 0,children:s.jsx(Fv,{initialUrl:K.targetPath??"",directory:n,tabID:K.id})},K.id)),it.map(K=>s.jsx("div",{className:Ee("absolute inset-0",T?.id!==K.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kv,{visible:M&&T?.id===K.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:K.diffScope??(K.stagedDiff?"staged":"working"),onDiffScopeChange:Fe,targetFilePath:K.targetPath,flushContent:!0})})},K.id)),ht?s.jsx("div",{className:Ee("absolute inset-0",T?.mode==="terminal"?"block":"hidden"),children:s.jsx(kh,{visible:M&&T?.mode==="terminal",directory:ht.targetDirectory})}):null,st?s.jsx("div",{className:Ee("absolute inset-0",T?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Wv,{directory:e,visible:M&&T?.mode==="walkthrough"})})}):null,mt.map(K=>{if(!tr(K.mode))return null;const Se=Fo(K.mode),Ve=Pe.has(Se),Xe=Ge.get(Se),nt=T?.id===K.id,Ze=nt&&M;return Ve&&!Xe&&!Ze?null:s.jsx("div",{className:Ee("absolute inset-0",nt?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ve?Xe?s.jsxs("div",{className:Ee("flex h-full",_i[Xe.dock].container),children:[s.jsx("div",{className:Ee("shrink-0",_i[Xe.dock].page),style:_i[Xe.dock].vertical?{height:Xe.size}:{width:Xe.size},children:s.jsx(Ec,{mode:K.mode})}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ze?s.jsx(Rc,{mode:K.mode}):null})]}):s.jsx(Rc,{mode:K.mode}):s.jsx(Ec,{mode:K.mode})})},K.id)}),T?.mode!=="chat"&&!ze&&T?.mode!=="browser"&&T?.mode!=="diff"&&T?.mode!=="terminal"&&T?.mode!=="walkthrough"&&!(T&&tr(T.mode))?ot:null]})]})]})},dS=t=>{const e=tt.c(43),{open:n,onOpenChange:r}=t,{t:i}=Nt(),o=Ne(uS),l=Ne(fS),a=Ne(mS),d=Ne(hS),u=Va();let m;e[0]!==o||e[1]!==u?(m=Pu(o,u),e[0]=o,e[1]=u,e[2]=m):m=e[2];const f=m,p=l.length===0;let y;if(e[3]!==l||e[4]!==f){let R;e[6]!==l?(R=A=>l.includes(A.id),e[6]=l,e[7]=R):R=e[7],y=f.every(R),e[3]=l,e[4]=f,e[5]=y}else y=e[5];const x=y;let k;e[8]!==i?(k=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=k):k=e[9];let w;e[10]!==k?(w=s.jsx(Us,{children:k}),e[10]=k,e[11]=w):w=e[11];let h;e[12]!==i?(h=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=h):h=e[13];let g;e[14]!==h?(g=s.jsx(Hs,{children:h}),e[14]=h,e[15]=g):g=e[15];let j;e[16]!==w||e[17]!==g?(j=s.jsxs(sn,{children:[w,g]}),e[16]=w,e[17]=g,e[18]=j):j=e[18];let b;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let R;e[24]!==l||e[25]!==a||e[26]!==i?(R=A=>s.jsx(qp,{settingsItem:`layout.context-rail.surface.${A.id}`,checked:!l.includes(A.id),onChange:O=>a(A.id,O),label:A.label??i(A.labelKey),ariaLabel:A.label??i(A.labelKey)},A.id),e[24]=l,e[25]=a,e[26]=i,e[27]=R):R=e[27],b=f.map(R),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=b}else b=e[23];let S;e[28]!==b?(S=s.jsx("div",{className:"flex flex-col",children:b}),e[28]=b,e[29]=S):S=e[29];let C;e[30]!==p||e[31]!==x||e[32]!==d||e[33]!==i?(C=p?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ct,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=p,e[31]=x,e[32]=d,e[33]=i,e[34]=C):C=e[34];let v;e[35]!==C||e[36]!==j||e[37]!==S?(v=s.jsxs(Ds,{className:"max-w-md",children:[j,S,C]}),e[35]=C,e[36]=j,e[37]=S,e[38]=v):v=e[38];let E;return e[39]!==r||e[40]!==n||e[41]!==v?(E=s.jsx(Ps,{open:n,onOpenChange:r,children:v}),e[39]=r,e[40]=n,e[41]=v,e[42]=E):E=e[42],E};function uS(t){return t.contextRailOrder}function fS(t){return t.contextRailHiddenSurfaces}function mS(t){return t.setContextRailSurfaceVisible}function hS(t){return t.setContextRailHiddenSurfaces}const Lf=150,pS=500,gS=[],xS=t=>t>99?"99+":String(t),bS=t=>{const e=tt.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:m,showOrderNumber:f,onSelect:p}=t;let y;e[0]!==n.id?(y={id:n.id},e[0]=n.id,e[1]=y):y=e[1];const{attributes:x,listeners:k,setNodeRef:w,transform:h,transition:g,isDragging:j}=mi(y);let b;e[2]!==a?(b=a!=null&&a>0?xS(a):null,e[2]=a,e[3]=b):b=e[3];const S=b;let C;e[4]!==h?(C=hi.Translate.toString(h),e[4]=h,e[5]=C):C=e[5];let v;e[6]!==C||e[7]!==g?(v={transform:C,transition:g},e[6]=C,e[7]=g,e[8]=v):v=e[8];const E=j&&"z-10 opacity-70";let R;e[9]!==E?(R=Ee("relative",E),e[9]=E,e[10]=R):R=e[10];let A;e[11]!==p||e[12]!==n?(A=()=>p(n),e[11]=p,e[12]=n,e[13]=A):A=e[13];const O=d??o,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let T;e[14]!==B?(T=Ee("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=T):T=e[15];let M;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?(M=n.id==="diff"?s.jsx(ff,{className:"h-[18px] w-[18px]"}):s.jsx(to,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=M):M=e[19];let L;e[20]!==S||e[21]!==m||e[22]!==i||e[23]!==f?(L=f&&m!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:m===10?"0":m}):S?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:S}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=S,e[21]=m,e[22]=i,e[23]=f,e[24]=L):L=e[24];let W;e[25]!==x||e[26]!==r||e[27]!==k||e[28]!==T||e[29]!==M||e[30]!==L||e[31]!==A||e[32]!==O?(W=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",...x,...k,onClick:A,"aria-label":O,"aria-pressed":r,className:T,children:[M,L]})}),e[25]=x,e[26]=r,e[27]=k,e[28]=T,e[29]=M,e[30]=L,e[31]=A,e[32]=O,e[33]=W):W=e[33];let $;e[34]!==o?($=s.jsx("span",{children:o}),e[34]=o,e[35]=$):$=e[35];let P;e[36]!==l?(P=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=P):P=e[37];let D;e[38]!==u?(D=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=D):D=e[39];let I;e[40]!==$||e[41]!==P||e[42]!==D?(I=s.jsx(jt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[$,P,D]})}),e[40]=$,e[41]=P,e[42]=D,e[43]=I):I=e[43];let X;e[44]!==W||e[45]!==I?(X=s.jsxs(vt,{delayDuration:Lf,children:[W,I]}),e[44]=W,e[45]=I,e[46]=X):X=e[46];let Z;return e[47]!==w||e[48]!==X||e[49]!==v||e[50]!==R?(Z=s.jsx("div",{ref:w,style:v,className:R,children:X}),e[47]=w,e[48]=X,e[49]=v,e[50]=R,e[51]=Z):Z=e[51],Z},yS=()=>{const t=tt.c(92),{t:e}=Nt(),n=dr();let r;t[0]!==n?(r=n?Qn(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=Y=>i?Y.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Ne(o),a=Ne(wS),d=Ne(vS),u=Ne(SS),m=Ne(jS),f=Ne(kS),p=Ne(CS),y=Ne(NS),x=La(AS),k=ta(PS),w=ta(DS),h=In(IS),g=In(TS),{screenWidth:j}=$n(),b=$a(i||null);let S;t[4]!==y?(S=sa("switch_context_surface",y),t[4]=y,t[5]=S):S=t[5];const C=S,[v,E]=c.useState(!1);let R,A;t[6]!==C?(R=()=>{const Y=new Set;let U=null,F=!1;const V=ES,oe=()=>{Rl(C,Y)?!F&&U===null&&(U=setTimeout(()=>E(!0),pS)):(F=!1,U!==null&&(clearTimeout(U),U=null),E(!1))},ae=_e=>{if(Y.add(_e.key.toLowerCase()),V(_e.key)&&Rl(C,Y)){F=!0,U!==null&&(clearTimeout(U),U=null),E(!1);return}oe()},pe=_e=>{Y.delete(_e.key.toLowerCase()),oe()},le=()=>{Y.clear(),F=!1,U!==null&&(clearTimeout(U),U=null),E(!1)};return window.addEventListener("keydown",ae,!0),window.addEventListener("keyup",pe,!0),window.addEventListener("blur",le),()=>{window.removeEventListener("keydown",ae,!0),window.removeEventListener("keyup",pe,!0),window.removeEventListener("blur",le),U!==null&&clearTimeout(U)}},A=[C],t[6]=C,t[7]=R,t[8]=A):(R=t[7],A=t[8]),c.useEffect(R,A);let O;t[9]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{distance:8}},t[9]=O):O=t[9];let B;t[10]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{delay:200,tolerance:6}},t[10]=B):B=t[10];const T=li(Pn(di,O),Pn(ci,B)),M=Va(),L=El(RS),W=El(MS),$=l?.tabs??gS;let P;t[11]!==l?.activeTabId||t[12]!==$?(P=$.find(Y=>Y.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=$,t[13]=P):P=t[13];const D=P,I=l?.isOpen?D?.mode??null:null,X=b?.files.length??0;let Z;t[14]!==u||t[15]!==d||t[16]!==g||t[17]!==M||t[18]!==w||t[19]!==x||t[20]!==j||t[21]!==$?(Z=Yp({railOrder:d,hiddenSurfaces:u,planModeEnabled:x,isVSCode:_n(),screenWidth:j,tabs:$,linearConnected:w,githubConnected:g,extras:M}),t[14]=u,t[15]=d,t[16]=g,t[17]=M,t[18]=w,t[19]=x,t[20]=j,t[21]=$,t[22]=Z):Z=t[22];const ne=Z;let ue,se;t[23]!==I||t[24]!==p||t[25]!==i||t[26]!==k||t[27]!==w?(se=()=>{!i||!k||w||I!=="linear"||p(i)},ue=[I,p,i,k,w],t[23]=I,t[24]=p,t[25]=i,t[26]=k,t[27]=w,t[28]=ue,t[29]=se):(ue=t[28],se=t[29]),c.useEffect(se,ue);let xe,ie;t[30]!==I||t[31]!==p||t[32]!==i||t[33]!==h||t[34]!==g?(xe=()=>{!i||!h||g||I!=="pr"||p(i)},ie=[I,p,i,h,g],t[30]=I,t[31]=p,t[32]=i,t[33]=h,t[34]=g,t[35]=xe,t[36]=ie):(xe=t[35],ie=t[36]),c.useEffect(xe,ie);const[Re,be]=c.useState(!1);let fe;t[37]!==M||t[38]!==m?(fe=Y=>{const{active:U,over:F}=Y;if(!F||U.id===F.id)return;const V=Pu(Ne.getState().contextRailOrder,M).map(OS),oe=V.indexOf(U.id),ae=V.indexOf(F.id);oe===-1||ae===-1||m(Qu(V,oe,ae))},t[37]=M,t[38]=m,t[39]=fe):fe=t[39];const ke=fe;if(!i)return null;let H;t[40]!==e?(H=e("contextRail.aria.rail"),t[40]=e,t[41]=H):H=t[41];let J;t[42]!==ne?(J=ne.map(BS),t[42]=ne,t[43]=J):J=t[43];let ce;if(t[44]!==I||t[45]!==X||t[46]!==W||t[47]!==i||t[48]!==L||t[49]!==f||t[50]!==v||t[51]!==ne||t[52]!==e||t[53]!==a){let Y;t[55]!==I||t[56]!==X||t[57]!==W||t[58]!==i||t[59]!==L||t[60]!==f||t[61]!==v||t[62]!==e||t[63]!==a?(Y=(U,F)=>{const V=U.label??e(U.labelKey),oe=U.id==="git"&&!a?X:0,ae=tr(U.mode)&&I!==U.mode?L[Fo(U.mode)]??0:0,pe=oe>0?oe:ae>0?ae:null,le=pe!==null&&oe===0;return s.jsx(bS,{surface:U,isActive:I===U.mode,showActivityDot:!1,label:V,description:e(U.descriptionKey),badgeCount:pe,badgeAriaLabel:pe!==null?e(le?pe===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":pe===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:V,count:pe}):null,badgeDescription:pe!==null?e(le?pe===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":pe===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:pe}):null,orderNumber:F+1,showOrderNumber:v,onSelect:_e=>{tr(_e.mode)&&W(Fo(_e.mode)),f(i,_e.mode)}},U.id)},t[55]=I,t[56]=X,t[57]=W,t[58]=i,t[59]=L,t[60]=f,t[61]=v,t[62]=e,t[63]=a,t[64]=Y):Y=t[64],ce=ne.map(Y),t[44]=I,t[45]=X,t[46]=W,t[47]=i,t[48]=L,t[49]=f,t[50]=v,t[51]=ne,t[52]=e,t[53]=a,t[54]=ce}else ce=t[54];let je;t[65]!==J||t[66]!==ce?(je=s.jsx(Ja,{items:J,strategy:Xu,children:ce}),t[65]=J,t[66]=ce,t[67]=je):je=t[67];let G;t[68]!==ke||t[69]!==T||t[70]!==je?(G=s.jsx(ui,{sensors:T,collisionDetection:fi,onDragEnd:ke,children:je}),t[68]=ke,t[69]=T,t[70]=je,t[71]=G):G=t[71];let we;t[72]!==e?(we=e("contextRail.configure.open"),t[72]=e,t[73]=we):we=t[73];let Te;t[74]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>be(!0),t[74]=Te):Te=t[74];let he;t[75]===Symbol.for("react.memo_cache_sentinel")?(he=s.jsx(_,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=he):he=t[75];let re;t[76]!==we?(re=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":we,onClick:Te,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:he})}),t[76]=we,t[77]=re):re=t[77];let ge;t[78]!==e?(ge=e("contextRail.configure.open"),t[78]=e,t[79]=ge):ge=t[79];let q;t[80]!==ge?(q=s.jsx(jt,{side:"left",sideOffset:8,children:ge}),t[80]=ge,t[81]=q):q=t[81];let z;t[82]!==re||t[83]!==q?(z=s.jsxs(vt,{delayDuration:Lf,children:[re,q]}),t[82]=re,t[83]=q,t[84]=z):z=t[84];let ee;t[85]!==Re?(ee=s.jsx(dS,{open:Re,onOpenChange:be}),t[85]=Re,t[86]=ee):ee=t[86];let de;return t[87]!==H||t[88]!==G||t[89]!==z||t[90]!==ee?(de=s.jsxs("nav",{"aria-label":H,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[G,z,ee]}),t[87]=H,t[88]=G,t[89]=z,t[90]=ee,t[91]=de):de=t[91],de};function wS(t){return t.workStatusPanelVisible}function vS(t){return t.contextRailOrder}function SS(t){return t.contextRailHiddenSurfaces}function jS(t){return t.setContextRailOrder}function kS(t){return t.openContextSurface}function CS(t){return t.closeContextPanel}function NS(t){return t.shortcutOverrides}function AS(t){return t.planModeEnabled}function PS(t){return t.hasChecked}function DS(t){return t.status?.connected===!0}function IS(t){return t.hasChecked}function TS(t){return t.status?.connected===!0}function ES(t){return t.length===1&&t>="0"&&t<="9"}function RS(t){return t.countByGuest}function MS(t){return t.clearBadge}function OS(t){return t.id}function BS(t){return t.id}const FS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),_S=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Lr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),LS=new Set,$S=[],ka=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},zS=()=>{const t=tt.c(183),{t:e}=Nt(),n=Ne(WS),r=Ne(KS),i=Ne(VS),o=Ne(US),l=Ne(HS),a=Ne(GS),d=Ne(qS),u=Ne(YS),m=Ne(QS),f=Ne(XS),p=Ne(JS),y=Ne(ZS),x=Ne(e0),k=rt(t0),w=rt(s0),h=rt(n0),g=Qr(r0);let j;t[0]!==n?(j=He=>n?He.activeSessions:$S,t[0]=n,t[1]=j):j=t[1];const b=vs(j);let S;t[2]!==n?(S=He=>n?He.ids:LS,t[2]=n,t[3]=S):S=t[3];const C=Qr(S);let v;t[4]!==n?(v=He=>n?He.rankById:Ha,t[4]=n,t[5]=v):v=t[5];const E=Ua(v),R=os(o0),A=Ut(i0),O=Ut(a0),B=dr(),T=_d(l0),{files:M,git:L}=wn(),W=Tn(c0),{isMobile:$}=$n();let P;t[6]!==B?(P=B?ka(B):null,t[6]=B,t[7]=P):P=t[7];const D=P,[I,X]=c.useState(""),ne=ku(I,200).trim();let ue;t[8]!==I?(ue=I.trim(),t[8]=I,t[9]=ue):ue=t[9];const se=ue;let xe,ie;t[10]!==n?(xe=()=>{n&&X("")},ie=[n],t[10]=n,t[11]=xe,t[12]=ie):(xe=t[11],ie=t[12]),c.useEffect(xe,ie);let Re,be;t[13]!==b||t[14]!==W||t[15]!==L||t[16]!==n?(Re=()=>{if(!n||!L)return;const He=setTimeout(()=>{const Ue=new Set;for(const ve of b){const Qe=As(ve);!Qe||Ue.has(Qe)||(Ue.add(Qe),W(Qe,L))}},0);return()=>clearTimeout(He)},be=[n,b,L,W],t[13]=b,t[14]=W,t[15]=L,t[16]=n,t[17]=Re,t[18]=be):(Re=t[17],be=t[18]),c.useEffect(Re,be);let fe;t[19]!==r?(fe=()=>r(!1),t[19]=r,t[20]=fe):fe=t[20];const ke=fe;let H;t[21]!==ke?(H=He=>()=>{ke(),He()},t[21]=ke,t[22]=H):H=t[22];const J=H;let ce;t[23]!==A?.id||t[24]!==A?.path||t[25]!==R||t[26]!==h||t[27]!==$||t[28]!==d||t[29]!==u||t[30]!==p||t[31]!==k||t[32]!==J||t[33]!==y||t[34]!==x||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==g||t[39]!==a?(ce=()=>{const He=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(_,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:J(()=>{l(!1),k()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(_,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:J(d0)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(_,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:J(u0)},{id:"toggle-sidebar",title:e($?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(_,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e($?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:J(()=>{if($){const{isSessionSwitcherOpen:Ue}=Ne.getState();l(!Ue)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(_,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:J(()=>{R&&u(R,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(_,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:J(()=>{R&&d(R)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(_,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:J(f0)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(_,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:J(m0)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(_,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:J(()=>i(!0))}];return He.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(_,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:J(()=>{h&&R&&g({directory:R,sessionId:h})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(_,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:J(()=>{h&&cr(h).then(Ue=>{if(Ue.ok){Ke.success(e("sessions.sidebar.session.copyId.success"));return}Ke.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(_,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:J(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(_,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:J(()=>{l(!1),y(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(_,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:J(()=>{R&&(x("notes"),u(R,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(_,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:J(()=>{R&&(x("todos"),u(R,"notes"))})}),He.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(_,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:J(h0)}),qr()&&He.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(_,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:J(()=>{Fn("desktop_open_draft_mini_chat_window",{directory:ka(R||A?.path||""),projectId:A?.id??null}).catch(p0)})}),He},t[23]=A?.id,t[24]=A?.path,t[25]=R,t[26]=h,t[27]=$,t[28]=d,t[29]=u,t[30]=p,t[31]=k,t[32]=J,t[33]=y,t[34]=x,t[35]=l,t[36]=i,t[37]=e,t[38]=g,t[39]=a,t[40]=ce):ce=t[40],A?.id,A?.path;let je;t[41]!==ce?(je=ce(),t[41]=ce,t[42]=je):je=t[42];const G=je,we=Ne(g0);let Te;t[43]===Symbol.for("react.memo_cache_sentinel")?(Te=xn(),t[43]=Te):Te=t[43];const he=Te;let re,ge;t[44]===Symbol.for("react.memo_cache_sentinel")?(re=_n(),ge=!he&&Ma(),t[44]=re,t[45]=ge):(re=t[44],ge=t[45]);let q;t[46]!==$||t[47]!==we?(q={isVSCode:re,isWeb:ge,isDesktop:he,isMobile:$,routingAvailable:we},t[46]=$,t[47]=we,t[48]=q):q=t[48];const z=q;let ee;if(t[49]!==J||t[50]!==i||t[51]!==o||t[52]!==z){let He;t[54]!==z?(He=ve=>ve.isAvailable?ve.isAvailable(z):!0,t[54]=z,t[55]=He):He=t[55];let Ue;t[56]!==J||t[57]!==i||t[58]!==o?(Ue=ve=>{const Qe=Nh(ve.slug)??"settings-3",qe=(ve.keywords??[]).join(" ");return{id:`settings:${ve.slug}`,title:ve.title,icon:ve.slug==="mcp"?s.jsx(eg,{className:"mr-2 h-4 w-4"}):s.jsx(_,{name:Qe,className:"mr-2 h-4 w-4"}),searchText:`${ve.title} ${ve.group} ${qe}`,onSelect:J(()=>{o(ve.slug),i(!0)})}},t[56]=J,t[57]=i,t[58]=o,t[59]=Ue):Ue=t[59],ee=Ch.filter(x0).filter(He).map(Ue),t[49]=J,t[50]=i,t[51]=o,t[52]=z,t[53]=ee}else ee=t[53];const de=ee;let Y;if(t[60]!==b||t[61]!==C||t[62]!==E){const He=b.filter(b0);Y=Qp(He,C,E),t[60]=b,t[61]=C,t[62]=E,t[63]=Y}else Y=t[63];const U=Y,F=Du(),V=rt(y0);let oe;t[64]!==F||t[65]!==V?(oe=(He,Ue)=>{const ve=V.get(He);return ve?.branch?ve.branch.trim()||null:Ue&&F.get(Ue)?.trim()||null},t[64]=F,t[65]=V,t[66]=oe):oe=t[66];const ae=oe;let pe;t[67]===Symbol.for("react.memo_cache_sentinel")?(pe=[],t[67]=pe):pe=t[67];const[le,_e]=c.useState(pe),[Fe,Me]=c.useState(""),Ae=FS(D,ne);let Q;t[68]!==D||t[69]!==Ae||t[70]!==n||t[71]!==T||t[72]!==_e||t[73]!==Me||t[74]!==ne?(Q=()=>{if(!n){_e([]),Me("");return}if(!Ae){_e([]),Me("");return}if(!D){_e([]),Me("");return}let He=!1;return T(D,ne,40,{type:"file"}).then(Ue=>{He||(_e(Ue.map(w0)),Me(Ae))}).catch(()=>{He||(_e([]),Me(Ae))}),()=>{He=!0}},t[68]=D,t[69]=Ae,t[70]=n,t[71]=T,t[72]=_e,t[73]=Me,t[74]=ne,t[75]=Q):Q=t[75];let Ce;t[76]!==D||t[77]!==Ae||t[78]!==n||t[79]!==T||t[80]!==ne?(Ce=[n,D,ne,Ae,T],t[76]=D,t[77]=Ae,t[78]=n,t[79]=T,t[80]=ne,t[81]=Ce):Ce=t[81],c.useEffect(Q,Ce);const Be=se.length>0;let Le;e:{if(!Be){let Ue;t[82]!==G?(Ue=G.filter(v0).map(S0),t[82]=G,t[83]=Ue):Ue=t[83],Le=Ue;break e}let He;t[84]!==G||t[85]!==se?(He=Lr(G,se,j0,{limit:7,noFuzzy:!0}),t[84]=G,t[85]=se,t[86]=He):He=t[86],Le=He}const Je=Le;let ot;e:{if(!Be){let Ue;t[87]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[87]=Ue):Ue=t[87],ot=Ue;break e}let He;t[88]!==se||t[89]!==de?(He=Lr(de,se,k0,{limit:7,noFuzzy:!0}),t[88]=se,t[89]=de,t[90]=He):He=t[90],ot=He}const et=ot;let it;e:{if(!Be){let Ue;t[91]!==U?(Ue=U.slice(0,5).map(C0),t[91]=U,t[92]=Ue):Ue=t[92],it=Ue;break e}let He;t[93]!==se||t[94]!==U?(He=Lr(U,se,N0,{limit:7,threshold:.2}),t[93]=se,t[94]=U,t[95]=He):He=t[95],it=He}const ht=it;let st;e:{if(!n){let Ue;t[96]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[96]=Ue):Ue=t[96],st=Ue;break e}let He;t[97]!==le||t[98]!==Fe||t[99]!==Ae||t[100]!==ne?(He=_S(le,ne,Ae,Fe),t[97]=le,t[98]=Fe,t[99]=Ae,t[100]=ne,t[101]=He):He=t[101],st=He}const mt=st,kt=n&&Ae.length>0&&Fe!==Ae;let Pe;e:{if(!Be){let Ue;t[102]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[102]=Ue):Ue=t[102],Pe=Ue;break e}let He;if(t[103]!==se||t[104]!==O){const Ue=O.map(A0);He=Lr(Ue,se,P0,{limit:7,threshold:.4}),t[103]=se,t[104]=O,t[105]=He}else He=t[105];Pe=He}const Ge=Pe;let at,ze,ft,te,me,De,K,Se,Ve,Xe,nt,Ze,gt,We;if(t[106]!==ae||t[107]!==ke||t[108]!==D||t[109]!==M||t[110]!==Be||t[111]!==n||t[112]!==m||t[113]!==k||t[114]!==I||t[115]!==Je||t[116]!==mt||t[117]!==Ge||t[118]!==ht||t[119]!==et||t[120]!==r||t[121]!==w||t[122]!==f||t[123]!==e){const He=Je.map(D0),Ue=et.map(I0),ve=ht.map(T0),Qe=Be?mt.map(E0):[],qe=Be?Ge.map(R0):[];let Ye;e:{if(!Be){Ye=["commands","sessions"];break e}const Ct=M0,Tt=[{key:"commands",score:Ct(Je)},{key:"settings",score:Ct(et)},{key:"sessions",score:Ct(ht)},{key:"files",score:Ct(mt)},{key:"projects",score:Ct(Ge)}];Tt.sort(O0),Ye=Tt.map(B0)}const dt=Ye,Ot=Ct=>{ke(),w(Ct.id,As(Ct))},zt=async Ct=>{if(!D)return;const Tt=await xf(M,Ct,{directory:D});if(!Tt.ok){Ke.error(bf(Tt.reason));return}m(D,Ct),ke()},Kt=(Ct,Tt)=>{ke(),k({selectedProjectId:Ct,directoryOverride:Tt})},Gt=Ct=>sr(so(Ct,f));te=Ps,Ze=n,gt=r;let Bt;t[138]!==e?(Bt=e("commandPalette.title"),t[138]=e,t[139]=Bt):Bt=t[139];let Jt;t[140]!==Bt?(Jt=s.jsx(Us,{children:Bt}),t[140]=Bt,t[141]=Jt):Jt=t[141];let Vt;t[142]!==e?(Vt=e("commandPalette.description"),t[142]=e,t[143]=Vt):Vt=t[143];let Wt;t[144]!==Vt?(Wt=s.jsx(Hs,{children:Vt}),t[144]=Vt,t[145]=Wt):Wt=t[145],t[146]!==Jt||t[147]!==Wt?(We=s.jsxs(sn,{className:"sr-only",children:[Jt,Wt]}),t[146]=Jt,t[147]=Wt,t[148]=We):We=t[148],ft=Ds,Xe="overflow-hidden p-0",nt=!0,ze=tg,K=!1,Se="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let _t;t[149]!==e?(_t=e("commandPalette.input.placeholder"),t[149]=e,t[150]=_t):_t=t[150],t[151]!==I||t[152]!==_t?(Ve=s.jsx(sg,{value:I,onValueChange:X,placeholder:_t}),t[151]=I,t[152]=_t,t[153]=Ve):Ve=t[153],at=ng;let Xt;t[154]!==e?(Xt=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Xt):Xt=t[155],t[156]!==Xt?(me=s.jsx(rg,{children:Xt}),t[156]=Xt,t[157]=me):me=t[157],De=dt.map(Ct=>Ct==="commands"&&He.length>0?s.jsx(Dr,{children:He.map(Tt=>s.jsxs($r,{value:Tt.id,onSelect:Tt.onSelect,children:[Tt.icon,s.jsx("span",{children:Tt.title}),Tt.shortcutId?s.jsx(Xp,{children:Gt(Tt.shortcutId)}):null]},Tt.id))},"commands"):Ct==="settings"&&Ue.length>0?s.jsx(Dr,{children:Ue.map(F0)},"settings"):Ct==="sessions"&&ve.length>0?s.jsx(Dr,{children:ve.map(Tt=>{const is=Tt.title||e("commandPalette.session.untitled"),$s=As(Tt),cs=ae(Tt.id,$s);return s.jsxs($r,{value:`session:${Tt.id}`,onSelect:()=>Ot(Tt),children:[s.jsx(_,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:is}),cs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:cs})]}):null]},Tt.id)})},"sessions"):Ct==="files"&&Qe.length>0?s.jsx(Dr,{children:Qe.map(Tt=>{const is=Jp(Tt.relativePath||Tt.name,{maxLength:80});return s.jsxs($r,{value:`file:${Tt.path}`,onSelect:()=>{zt(Tt.path)},children:[s.jsx(Ka,{filePath:Tt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Tt.relativePath,children:is})]},`file:${Tt.path}`)})},"files"):Ct==="projects"&&qe.length>0?s.jsx(Dr,{children:qe.map(Tt=>{const is=Tt.displayName;return s.jsxs($r,{value:`project:${Tt.id}`,onSelect:()=>Kt(Tt.id,Tt.path),children:[s.jsx(_,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:is}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Tt.path})]},`project:${Tt.id}`)})},"projects"):null),t[106]=ae,t[107]=ke,t[108]=D,t[109]=M,t[110]=Be,t[111]=n,t[112]=m,t[113]=k,t[114]=I,t[115]=Je,t[116]=mt,t[117]=Ge,t[118]=ht,t[119]=et,t[120]=r,t[121]=w,t[122]=f,t[123]=e,t[124]=at,t[125]=ze,t[126]=ft,t[127]=te,t[128]=me,t[129]=De,t[130]=K,t[131]=Se,t[132]=Ve,t[133]=Xe,t[134]=nt,t[135]=Ze,t[136]=gt,t[137]=We}else at=t[124],ze=t[125],ft=t[126],te=t[127],me=t[128],De=t[129],K=t[130],Se=t[131],Ve=t[132],Xe=t[133],nt=t[134],Ze=t[135],gt=t[136],We=t[137];let Et;t[158]!==kt||t[159]!==e?(Et=kt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=kt,t[159]=e,t[160]=Et):Et=t[160];let Ft;t[161]!==at||t[162]!==me||t[163]!==De||t[164]!==Et?(Ft=s.jsxs(at,{children:[me,De,Et]}),t[161]=at,t[162]=me,t[163]=De,t[164]=Et,t[165]=Ft):Ft=t[165];let Ie;t[166]!==ze||t[167]!==K||t[168]!==Se||t[169]!==Ve||t[170]!==Ft?(Ie=s.jsxs(ze,{shouldFilter:K,className:Se,children:[Ve,Ft]}),t[166]=ze,t[167]=K,t[168]=Se,t[169]=Ve,t[170]=Ft,t[171]=Ie):Ie=t[171];let yt;t[172]!==ft||t[173]!==Xe||t[174]!==nt||t[175]!==Ie?(yt=s.jsx(ft,{className:Xe,showCloseButton:nt,children:Ie}),t[172]=ft,t[173]=Xe,t[174]=nt,t[175]=Ie,t[176]=yt):yt=t[176];let At;return t[177]!==te||t[178]!==Ze||t[179]!==gt||t[180]!==We||t[181]!==yt?(At=s.jsxs(te,{open:Ze,onOpenChange:gt,children:[We,yt]}),t[177]=te,t[178]=Ze,t[179]=gt,t[180]=We,t[181]=yt,t[182]=At):At=t[182],At};function WS(t){return t.isCommandPaletteOpen}function KS(t){return t.setCommandPaletteOpen}function VS(t){return t.setSettingsDialogOpen}function US(t){return t.setSettingsPage}function HS(t){return t.setSessionSwitcherOpen}function GS(t){return t.toggleSidebar}function qS(t){return t.openContextOverview}function YS(t){return t.openContextSurface}function QS(t){return t.openContextFile}function XS(t){return t.shortcutOverrides}function JS(t){return t.openMultiRunLauncher}function ZS(t){return t.setArchivePageOpen}function e0(t){return t.setProjectContextTab}function t0(t){return t.openNewSessionDraft}function s0(t){return t.setCurrentSession}function n0(t){return t.currentSessionId}function r0(t){return t.toggle}function o0(t){return t.currentDirectory}function i0(t){return t.getActiveProject()}function a0(t){return t.projects}function l0(t){return t.searchFiles}function c0(t){return t.ensureStatus}function d0(){Iu()}function u0(){un.requestDirectoryDialog()}function f0(){og.invoke("cycle_theme")}function m0(){Tu()}function h0(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function p0(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function g0(t){return t.routingFeatureAvailable}function x0(t){return t.slug!=="home"}function b0(t){return!Zp(t)}function y0(t){return t.worktreeMetadata}function w0(t){return{path:ka(t.path),name:t.name,relativePath:t.relativePath}}function v0(t){return!t.secondary}function S0(t){return{item:t,score:0}}function j0(t){return t.searchText}function k0(t){return t.searchText}function C0(t){return{item:t,score:0}}function N0(t){return t.title||""}function A0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function P0(t){return t.searchText}function D0(t){return t.item}function I0(t){return t.item}function T0(t){return t.item}function E0(t){return t.item}function R0(t){return t.item}function M0(t){return t.length?t[0].score:1/0}function O0(t,e){return t.score-e.score}function B0(t){return t.key}function F0(t){return s.jsxs($r,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Fc=(t,e,n)=>sr(so(t,e),n),_0=()=>{const t=tt.c(74),{t:e}=Nt(),n=Ne(L0),r=Ne($0),i=Ne(z0);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=_n(),t[0]=o):o=t[0];const l=o;let a,d,u,m,f,p,y,x,k,w,h,g;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const P=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[sr("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${sr(sa("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${sr(sa("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];u=Ps,h=n,g=r,d=Ds,k="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let D;t[17]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(_,{name:"command",className:"h-5 w-5"}),t[17]=D):D=t[17];let I;t[18]!==e?(I=e("helpDialog.title"),t[18]=e,t[19]=I):I=t[19];let X;t[20]!==I?(X=s.jsxs(Us,{className:"flex items-center gap-2",children:[D,I]}),t[20]=I,t[21]=X):X=t[21];let Z;t[22]!==e?(Z=e("helpDialog.description"),t[22]=e,t[23]=Z):Z=t[23];let ne;t[24]!==Z?(ne=s.jsx(Hs,{children:Z}),t[24]=Z,t[25]=ne):ne=t[25],t[26]!==X||t[27]!==ne?(w=s.jsxs(sn,{children:[X,ne]}),t[26]=X,t[27]=ne,t[28]=w):w=t[28],a=En,p="flex-1 min-h-0 mt-3",y="pr-1",x=!0,m="space-y-4",f=P.map(ue=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ue.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ue.items.filter(se=>!(l&&se.id==="toggle_prompt_navigator")).map(se=>{const xe=se.id?ig(se.id):void 0,ie=se.descriptionKey??(xe?.customizable?xe.settingsLabelKey:void 0);if(!ie||se.id&&!so(se.id,i))return null;const Re=se.id?Fc(se.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(se.keys)?se.keys:se.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[se.icon&&s.jsx(_,{name:se.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(ie)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Re)?Re:[Re]).map((be,fe)=>s.jsxs(c.Fragment,{children:[fe>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:be})]},`${be}-${fe}`))})]},se.id||ie)})})]},ue.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=d,t[7]=u,t[8]=m,t[9]=f,t[10]=p,t[11]=y,t[12]=x,t[13]=k,t[14]=w,t[15]=h,t[16]=g}else a=t[5],d=t[6],u=t[7],m=t[8],f=t[9],p=t[10],y=t[11],x=t[12],k=t[13],w=t[14],h=t[15],g=t[16];let j;t[29]!==m||t[30]!==f?(j=s.jsx("div",{className:m,children:f}),t[29]=m,t[30]=f,t[31]=j):j=t[31];let b;t[32]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(_,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=b):b=t[32];let S;t[33]!==e?(S=e("helpDialog.proTips.title"),t[33]=e,t[34]=S):S=t[34];let C;t[35]!==S?(C=s.jsx("p",{className:"font-medium mb-1",children:S}),t[35]=S,t[36]=C):C=t[36];let v;t[37]!==i||t[38]!==e?(v=e("helpDialog.proTips.commandPalette",{shortcut:Fc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=v):v=t[39];let E;t[40]!==v?(E=s.jsxs("li",{children:["• ",v]}),t[40]=v,t[41]=E):E=t[41];let R;t[42]!==e?(R=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=R):R=t[43];let A;t[44]!==R?(A=s.jsxs("li",{children:["• ",R]}),t[44]=R,t[45]=A):A=t[45];let O;t[46]!==e?(O=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=O):O=t[47];let B;t[48]!==O?(B=s.jsxs("li",{children:["• ",O]}),t[48]=O,t[49]=B):B=t[49];let T;t[50]!==E||t[51]!==A||t[52]!==B?(T=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[E,A,B]}),t[50]=E,t[51]=A,t[52]=B,t[53]=T):T=t[53];let M;t[54]!==C||t[55]!==T?(M=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[b,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,T]})]})}),t[54]=C,t[55]=T,t[56]=M):M=t[56];let L;t[57]!==a||t[58]!==j||t[59]!==M||t[60]!==p||t[61]!==y||t[62]!==x?(L=s.jsxs(a,{outerClassName:p,className:y,disableHorizontal:x,children:[j,M]}),t[57]=a,t[58]=j,t[59]=M,t[60]=p,t[61]=y,t[62]=x,t[63]=L):L=t[63];let W;t[64]!==d||t[65]!==L||t[66]!==k||t[67]!==w?(W=s.jsxs(d,{className:k,children:[w,L]}),t[64]=d,t[65]=L,t[66]=k,t[67]=w,t[68]=W):W=t[68];let $;return t[69]!==u||t[70]!==W||t[71]!==h||t[72]!==g?($=s.jsx(u,{open:h,onOpenChange:g,children:W}),t[69]=u,t[70]=W,t[71]=h,t[72]=g,t[73]=$):$=t[73],$};function L0(t){return t.isHelpDialogOpen}function $0(t){return t.setHelpDialogOpen}function z0(t){return t.shortcutOverrides}const W0=()=>{const t=tt.c(32),{t:e}=Nt(),n=Ne(K0),r=Ne(V0),i=Ne(U0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await cr(i)).ok){Ke.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Ke.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Us,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==u?(m=s.jsx(Hs,{children:u}),t[9]=u,t[10]=m):m=t[10];let f;t[11]!==d||t[12]!==m?(f=s.jsxs(sn,{children:[d,m]}),t[11]=d,t[12]=m,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let y;t[16]!==l||t[17]!==p?(y=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:p})}),t[16]=l,t[17]=p,t[18]=y):y=t[18];let x;t[19]!==i||t[20]!==e?(x=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=x):x=t[21];let k;t[22]!==x?(k=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:x}),t[22]=x,t[23]=k):k=t[23];let w;t[24]!==f||t[25]!==y||t[26]!==k?(w=s.jsxs(Ds,{className:"max-w-2xl",children:[f,y,k]}),t[24]=f,t[25]=y,t[26]=k,t[27]=w):w=t[27];let h;return t[28]!==n||t[29]!==r||t[30]!==w?(h=s.jsx(Ps,{open:n,onOpenChange:r,children:w}),t[28]=n,t[29]=r,t[30]=w,t[31]=h):h=t[31],h};function K0(t){return t.isOpenCodeStatusDialogOpen}function V0(t){return t.setOpenCodeStatusDialogOpen}function U0(t){return t.openCodeStatusText}const H0=t=>{const e=tt.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const x=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(x)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let m,f;e[5]!==a||e[6]!==o||e[7]!==i?(m=()=>{if(!a||typeof window>"u")return;const x=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",x),()=>window.removeEventListener("openchamber:sidebar-session-search",x)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=m,e[9]=f):(m=e[8],f=e[9]),c.useEffect(m,f);let p,y;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const x=k=>{l.current&&(l.current.contains(k.target)||i(!1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},y=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=y):(p=e[14],y=e[15]),c.useEffect(p,y)},G0=t=>{const e=tt.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(q0)),u=[];a.forEach(p=>{const y=d.get(p);y&&(u.push(y),d.delete(p))});const m=[],f=[];return l.forEach(p=>{d.has(p.id)&&(p.isArchivedBucket?f.push(p):m.push(p))}),[...m,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function q0(t){return[t.id,t]}const wo="oc.sessions.projectCollapse",_c="oc.sessions.groupOrder",Lc="oc.sessions.groupCollapse",$c=t=>{if(!t)return new Set;try{const e=Za(lr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},Y0=t=>{if(!t)return new Map;try{const e=nf(lr(),Za(lr())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},Q0=t=>{const e=tt.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=_o(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>$c(o.getItem(wo)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>$c(o.getItem(Lc)),e[2]=u):u=e[2];const[m,f]=c.useState(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>Y0(o.getItem(_c)),e[3]=p):p=e[3];const[y,x]=c.useState(p),k=c.useRef(0),w=c.useRef(!1),h=c.useRef(!1),g=c.useRef(null),j=c.useRef(null);let b;e[4]!==n?(b=()=>{if(n)return;const fe=j.current;if(j.current=null,g.current=null,!fe)return;const{projects:ke}=Ut.getState(),H=ke.map(J=>({...J,sidebarCollapsed:fe.has(J.id)}));Fr({projects:H}).catch(X0)},e[4]=n,e[5]=b):b=e[5];const S=b;let C;e[6]!==S||e[7]!==n?(C=fe=>{!globalThis.window||n||(j.current=fe,g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{S()},700))},e[6]=S,e[7]=n,e[8]=C):C=e[8];const v=C;let E,R;e[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>()=>{globalThis.window&&g.current!==null&&window.clearTimeout(g.current),g.current=null,j.current=null},R=[],e[9]=E,e[10]=R):(E=e[9],R=e[10]),c.useEffect(E,R);let A,O;e[11]!==y?(O=()=>{if(h.current)try{o.setItem(_c,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},A=[y,o],e[11]=y,e[12]=A,e[13]=O):(A=e[12],O=e[13]),c.useEffect(O,A);let B,T;e[14]!==m?(B=()=>{if(w.current)try{o.setItem(Lc,JSON.stringify(Array.from(m)))}catch{}},T=[m,o],e[14]=m,e[15]=B,e[16]=T):(B=e[15],T=e[16]),c.useEffect(B,T);let M;e[17]!==r||e[18]!==v?(M=()=>{k.current=Date.now()+150,w.current=!0,f(new Set),d(()=>{const fe=new Set(r.map(J0));try{o.setItem(wo,JSON.stringify(Array.from(fe)))}catch{}return v(fe),fe})},e[17]=r,e[18]=v,e[19]=M):M=e[19];const L=M;let W;e[20]!==v?(W=()=>{k.current=Date.now()+150,w.current=!0,f(new Set),d(()=>{const fe=new Set;try{o.setItem(wo,JSON.stringify([]))}catch{}return v(fe),fe})},e[20]=v,e[21]=W):W=e[21];const $=W;let P;e[22]!==v?(P=fe=>{k.current=Date.now()+150,d(ke=>{const H=new Set(ke);H.has(fe)?H.delete(fe):H.add(fe);try{o.setItem(wo,JSON.stringify(Array.from(H)))}catch{}return v(H),H})},e[22]=v,e[23]=P):P=e[23];const D=P;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=fe=>{w.current=!0,f(ke=>{const H=new Set(ke);return H.has(fe)?H.delete(fe):H.add(fe),H})},e[24]=I):I=e[24];const X=I;let Z;e[25]===Symbol.for("react.memo_cache_sentinel")?(Z=fe=>{h.current=!0,x(fe)},e[25]=Z):Z=e[25];const ne=Z,{getOrderedGroups:ue}=G0(y);let se;e[26]!==m||e[27]!==a||e[28]!==y?(se={collapsedProjects:a,collapsedGroups:m,groupOrderByProject:y},e[26]=m,e[27]=a,e[28]=y,e[29]=se):se=e[29];const xe=se;let ie;e[30]!==L||e[31]!==$||e[32]!==ue||e[33]!==v||e[34]!==D?(ie={setCollapsedProjects:d,toggleProject:D,collapseAllProjects:L,expandAllProjects:$,scheduleCollapsedProjectsPersist:v,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:ne,getOrderedGroups:ue},e[30]=L,e[31]=$,e[32]=ue,e[33]=v,e[34]=D,e[35]=ie):ie=e[35];const Re=ie;let be;return e[36]!==Re||e[37]!==xe?(be={state:xe,actions:Re},e[36]=Re,e[37]=xe,e[38]=be):be=e[38],be};function X0(){}function J0(t){return t.id}const Z0=5*6e4,ej=t=>{const e=tt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=wn(),u=Tn(tj);let m,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(m=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(C=>{na(()=>u(C.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=m,e[6]=f):(m=e[5],f=e[6]),c.useEffect(m,f);let p,y;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(v=>{C.set(v.id,i.get(v.normalizedPath)?.isGitRepo??null)}),o(C)},y=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=y):(p=e[11],y=e[12]),c.useEffect(p,y);let x;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=v=>{const E=i.get(v.normalizedPath)?.branch??"";return`${v.id}:${E}`},e[16]=i,e[17]=C):C=e[17],x=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=x}else x=e[15];const k=x;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=new Map,e[18]=w):w=e[18];const h=c.useRef(w);let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=new Map,e[19]=g):g=e[19];const j=c.useRef(g);let b;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(b=()=>{if(!a)return;let C=!1;const v=setTimeout(()=>{(async()=>{const R=new Set(n.map(sj));for(const L of h.current.keys())R.has(L)||(h.current.delete(L),j.current.delete(L));const A=Date.now(),O=n.filter(L=>{const W=i.get(L.normalizedPath);if(W?.isGitRepo===!1)return h.current.delete(L.id),j.current.delete(L.id),!1;if(W?.isGitRepo!==!0||W.branch===null)return!1;const $=W.branch.trim(),P=`${L.normalizedPath}\0${$}`,D=h.current.get(L.id);if(D===P){const I=j.current.get(L.id);return I&&(I.at=A),!1}return!(D!==void 0&&A-(j.current.get(L.id)?.at??0)<Z0)});if(O.length===0)return;const B=await ag(O,2,async L=>{const W=i.get(L.normalizedPath)?.branch?.trim()??"",$=`${L.normalizedPath}\0${W}`,P=await na(()=>za(L.normalizedPath,W?{knownBranch:W}:void 0)).catch(nj);return{id:L.id,inputKey:$,branch:P}});if(C)return;const T=B.filter(rj);if(T.length===0)return;const M=Date.now();l(L=>{const W=new Map(L);return T.forEach($=>{const{id:P,branch:D}=$;D&&W.set(P,D)}),W}),T.forEach(L=>{const{id:W,inputKey:$,branch:P}=L;h.current.set(W,$),P&&j.current.set(W,{branch:P,at:M})})})()},150);return()=>{C=!0,clearTimeout(v)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=b):b=e[24];let S;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==k||e[29]!==l?(S=[a,n,k,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=k,e[29]=l,e[30]=S):S=e[30],c.useEffect(b,S)};function tj(t){return t.ensureStatus}function sj(t){return t.id}function nj(){return null}function rj(t){return t.branch}const oj=t=>{const e=tt.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Ah,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(Ds,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(En,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(Ps,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function ij(t){const e=tt.c(197),{t:n}=Nt(),r=Eu(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:m,onOpenArchive:f,headerActionIconClass:p,headerActionButtonClass:y,isSessionSearchOpen:x,setIsSessionSearchOpen:k,sessionSearchInputRef:w,sessionSearchQuery:h,setSessionSearchQuery:g,hasSessionSearchQuery:j,searchMatchCount:b,collapseAllProjects:S,expandAllProjects:C}=t,v=ms(bj),E=ms(xj),R=Ns(gj),A=Ns(pj),O=Ns(hj),B=Ns(mj),T=Ns(fj),M=Ns(uj),L=Ns(dj),W=Ns(cj),$=o&&L==="single",P=o&&T==="timeline";if(i)return null;let D;e[0]!==y?(D=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=y,e[1]=D):D=e[1];let I;e[2]!==n?(I=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=I):I=e[3];let X;e[4]!==p?(X=s.jsx(_,{name:"folder-add",className:p}),e[4]=p,e[5]=X):X=e[5];let Z;e[6]!==a||e[7]!==D||e[8]!==I||e[9]!==X?(Z=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:D,"aria-label":I,children:X})}),e[6]=a,e[7]=D,e[8]=I,e[9]=X,e[10]=Z):Z=e[10];let ne;e[11]!==n?(ne=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=ne):ne=e[12];let ue;e[13]!==ne?(ue=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[13]=ne,e[14]=ue):ue=e[14];let se;e[15]!==Z||e[16]!==ue?(se=s.jsxs(vt,{children:[Z,ue]}),e[15]=Z,e[16]=ue,e[17]=se):se=e[17];let xe;e[18]!==y?(xe=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=y,e[19]=xe):xe=e[19];let ie;e[20]!==n?(ie=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=ie):ie=e[21];let Re;e[22]!==p?(Re=s.jsx(_,{name:"calendar-schedule",className:p}),e[22]=p,e[23]=Re):Re=e[23];let be;e[24]!==d||e[25]!==xe||e[26]!==ie||e[27]!==Re?(be=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:xe,"aria-label":ie,children:Re})}),e[24]=d,e[25]=xe,e[26]=ie,e[27]=Re,e[28]=be):be=e[28];let fe;e[29]!==n?(fe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=fe):fe=e[30];let ke;e[31]!==fe?(ke=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[31]=fe,e[32]=ke):ke=e[32];let H;e[33]!==be||e[34]!==ke?(H=s.jsxs(vt,{children:[be,ke]}),e[33]=be,e[34]=ke,e[35]=H):H=e[35];let J;e[36]!==y?(J=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=y,e[37]=J):J=e[37];let ce;e[38]!==n?(ce=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=ce):ce=e[39];const je=!m;let G;e[40]!==p?(G=s.jsx(dg,{className:p}),e[40]=p,e[41]=G):G=e[41];let we;e[42]!==u||e[43]!==J||e[44]!==ce||e[45]!==je||e[46]!==G?(we=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:J,"aria-label":ce,disabled:je,children:G})}),e[42]=u,e[43]=J,e[44]=ce,e[45]=je,e[46]=G,e[47]=we):we=e[47];let Te;e[48]!==n?(Te=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Te):Te=e[49];let he;e[50]!==Te?(he=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Te})}),e[50]=Te,e[51]=he):he=e[51];let re;e[52]!==we||e[53]!==he?(re=s.jsxs(vt,{children:[we,he]}),e[52]=we,e[53]=he,e[54]=re):re=e[54];let ge;e[55]!==y?(ge=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=y,e[56]=ge):ge=e[56];let q;e[57]!==n?(q=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=q):q=e[58];let z;e[59]!==p?(z=s.jsx(_,{name:"archive",className:p}),e[59]=p,e[60]=z):z=e[60];let ee;e[61]!==f||e[62]!==ge||e[63]!==q||e[64]!==z?(ee=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:ge,"aria-label":q,children:z})}),e[61]=f,e[62]=ge,e[63]=q,e[64]=z,e[65]=ee):ee=e[65];let de;e[66]!==n?(de=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=de):de=e[67];let Y;e[68]!==de?(Y=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:de})}),e[68]=de,e[69]=Y):Y=e[69];let U;e[70]!==ee||e[71]!==Y?(U=s.jsxs(vt,{children:[ee,Y]}),e[70]=ee,e[71]=Y,e[72]=U):U=e[72];let F;e[73]!==r||e[74]!==p||e[75]!==n?(F=r.length>0&&s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(_,{name:"apps",className:p})})}),s.jsxs(_s,{align:"start",children:[s.jsx(_r,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(lj)]})]}),e[73]=r,e[74]=p,e[75]=n,e[76]=F):F=e[76];let V;e[77]!==H||e[78]!==re||e[79]!==U||e[80]!==F||e[81]!==se?(V=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[se,H,re,U,F]}),e[77]=H,e[78]=re,e[79]=U,e[80]=F,e[81]=se,e[82]=V):V=e[82];let oe;e[83]!==k?(oe=()=>k(aj),e[83]=k,e[84]=oe):oe=e[84];let ae;e[85]!==y?(ae=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=y,e[86]=ae):ae=e[86];let pe;e[87]!==n?(pe=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=pe):pe=e[88];let le;e[89]!==p?(le=s.jsx(_,{name:"search",className:p}),e[89]=p,e[90]=le):le=e[90];let _e;e[91]!==x||e[92]!==oe||e[93]!==ae||e[94]!==pe||e[95]!==le?(_e=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:oe,className:ae,"aria-label":pe,"aria-expanded":x,children:le})}),e[91]=x,e[92]=oe,e[93]=ae,e[94]=pe,e[95]=le,e[96]=_e):_e=e[96];let Fe;e[97]!==n?(Fe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=Fe):Fe=e[98];let Me;e[99]!==Fe?(Me=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Fe})}),e[99]=Fe,e[100]=Me):Me=e[100];let Ae;e[101]!==_e||e[102]!==Me?(Ae=s.jsxs(vt,{children:[_e,Me]}),e[101]=_e,e[102]=Me,e[103]=Ae):Ae=e[103];const Q=v&&"bg-interactive-hover text-primary";let Ce;e[104]!==y||e[105]!==Q?(Ce=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent",Q),e[104]=y,e[105]=Q,e[106]=Ce):Ce=e[106];let Be;e[107]!==v||e[108]!==n?(Be=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=v,e[108]=n,e[109]=Be):Be=e[109];let Le;e[110]!==p?(Le=s.jsx(_,{name:"checkbox-multiple",className:p}),e[110]=p,e[111]=Le):Le=e[111];let Je;e[112]!==v||e[113]!==Ce||e[114]!==Be||e[115]!==Le||e[116]!==E?(Je=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:E,className:Ce,"aria-label":Be,"aria-pressed":v,children:Le})}),e[112]=v,e[113]=Ce,e[114]=Be,e[115]=Le,e[116]=E,e[117]=Je):Je=e[117];let ot;e[118]!==v||e[119]!==n?(ot=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=v,e[119]=n,e[120]=ot):ot=e[120];let et;e[121]!==ot?(et=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ot})}),e[121]=ot,e[122]=et):et=e[122];let it;e[123]!==Je||e[124]!==et?(it=s.jsxs(vt,{children:[Je,et]}),e[123]=Je,e[124]=et,e[125]=it):it=e[125];let ht;e[126]!==y?(ht=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=y,e[127]=ht):ht=e[127];let st;e[128]!==n?(st=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=st):st=e[129];let mt;e[130]!==p?(mt=s.jsx(_,{name:"equalizer-2",className:p}),e[130]=p,e[131]=mt):mt=e[131];let kt;e[132]!==ht||e[133]!==st||e[134]!==mt?(kt=s.jsx(St,{asChild:!0,children:s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:ht,"aria-label":st,children:mt})})}),e[132]=ht,e[133]=st,e[134]=mt,e[135]=kt):kt=e[135];let Pe;e[136]!==n?(Pe=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=Pe):Pe=e[137];let Ge;e[138]!==Pe?(Ge=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Pe})}),e[138]=Pe,e[139]=Ge):Ge=e[139];let at;e[140]!==kt||e[141]!==Ge?(at=s.jsxs(vt,{children:[kt,Ge]}),e[140]=kt,e[141]=Ge,e[142]=at):at=e[142];let ze;e[143]!==M||e[144]!==o||e[145]!==T||e[146]!==n||e[147]!==P?(ze=o?s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{M(gt),Fr({sidebarViewMode:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),T===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),P?null:s.jsx(Es,{})]}):null,e[143]=M,e[144]=o,e[145]=T,e[146]=n,e[147]=P,e[148]=ze):ze=e[148];let ft;e[149]!==L||e[150]!==O||e[151]!==W||e[152]!==B||e[153]!==o||e[154]!==n||e[155]!==P?(ft=P?null:s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("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"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{B(gt),Fr({sidebarProjectSortOrder:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),O===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),s.jsx(Es,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{W(gt),Fr({sidebarProjectDisplayMode:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),L===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),s.jsx(Es,{})]}):null]}),e[149]=L,e[150]=O,e[151]=W,e[152]=B,e[153]=o,e[154]=n,e[155]=P,e[156]=ft):ft=e[156];let te;e[157]!==$||e[158]!==l||e[159]!==R||e[160]!==n||e[161]!==P||e[162]!==A?(te=!P&&l&&!$?s.jsxs(Ht,{onClick:()=>{A(),Fr({sidebarShowRecentSection:!R})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),R?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[157]=$,e[158]=l,e[159]=R,e[160]=n,e[161]=P,e[162]=A,e[163]=te):te=e[163];let me;e[164]!==S||e[165]!==C||e[166]!==$||e[167]!==n||e[168]!==P?(me=!P&&!$?s.jsxs(s.Fragment,{children:[s.jsx(Es,{}),s.jsxs(Ht,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(_,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Ht,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(_,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[164]=S,e[165]=C,e[166]=$,e[167]=n,e[168]=P,e[169]=me):me=e[169];let De;e[170]!==ze||e[171]!==ft||e[172]!==te||e[173]!==me?(De=s.jsxs(_s,{align:"end",className:"min-w-[180px]",children:[ze,ft,te,me]}),e[170]=ze,e[171]=ft,e[172]=te,e[173]=me,e[174]=De):De=e[174];let K;e[175]!==at||e[176]!==De?(K=s.jsxs(Ls,{children:[at,De]}),e[175]=at,e[176]=De,e[177]=K):K=e[177];let Se;e[178]!==Ae||e[179]!==it||e[180]!==K?(Se=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Ae,it,K]}),e[178]=Ae,e[179]=it,e[180]=K,e[181]=Se):Se=e[181];let Ve;e[182]!==V||e[183]!==Se?(Ve=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[V,Se]}),e[182]=V,e[183]=Se,e[184]=Ve):Ve=e[184];let Xe;e[185]!==j||e[186]!==x||e[187]!==b||e[188]!==w||e[189]!==h||e[190]!==k||e[191]!==g||e[192]!==n?(Xe=x?s.jsx("div",{className:"pb-1",children:s.jsx(Qd,{inputRef:w,value:h,onSearch:g,onClose:()=>k(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:j?b===1?n("sessions.sidebar.header.search.matchCountSingle",{count:b}):n("sessions.sidebar.header.search.matchCountPlural",{count:b}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[185]=j,e[186]=x,e[187]=b,e[188]=w,e[189]=h,e[190]=k,e[191]=g,e[192]=n,e[193]=Xe):Xe=e[193];let nt;return e[194]!==Ve||e[195]!==Xe?(nt=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Ve,Xe]})}),e[194]=Ve,e[195]=Xe,e[196]=nt):nt=e[196],nt}function aj(t){return!t}function lj(t){return s.jsxs(Ht,{onSelect:()=>Ne.getState().setOpenGuestPage(t.id),children:[s.jsx(to,{icon:cg(t.icon),iconSrc:lg(t.id,t.icon,Ld().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function cj(t){return t.setProjectDisplayMode}function dj(t){return t.projectDisplayMode}function uj(t){return t.setSidebarViewMode}function fj(t){return t.sidebarViewMode}function mj(t){return t.setProjectSortOrder}function hj(t){return t.projectSortOrder}function pj(t){return t.toggleRecentSection}function gj(t){return t.showRecentSection}function xj(t){return t.toggleMode}function bj(t){return t.enabled}const vo="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";function yj(t){const e=tt.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,m=d===void 0?!0:d,{t:f}=Nt();if(!u&&!m)return null;let p;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(p=u?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:vo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(_,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:vo,"aria-label":f("usageStats.openAction"),children:s.jsx(_,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:vo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(_,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:vo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(_,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=p):p=e[6];let y;e[7]!==l||e[8]!==m||e[9]!==f?(y=m?s.jsx(ct,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=m,e[9]=f,e[10]=y):y=e[10];let x;return e[11]!==p||e[12]!==y?(x=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[p,y]}),e[11]=p,e[12]=y,e[13]=x):x=e[13],x}const wj=t=>{for(const e of t.sessions.values())if(e.tabs.some(zd))return!0;return!1},vj=()=>{const t=tt.c(4),{terminal:e}=wn(),n=Mt(wj);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=Sj,l=jj;if(n)return Gi(e,"",l,o);let a=kj;return a=Gi(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function Sj(t){const e=Mt.getState(),n=Ph(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function jj(){return new Map(Mt.getState().actionMutationRevisions)}function kj(){}const Cj=t=>{const e=tt.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:m,addSessionToFolder:f}=t,p=r===void 0?!0:r;let y,x;e[0]!==f||e[1]!==m||e[2]!==p||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(y=()=>{!p||o||!l||a||n.forEach(k=>{if(d.has(k.normalizedPath))return;const w=Ru(k.normalizedPath),h=i.archivedSessionsByProject.get(k.id)??[],g=u[w]??[],j=new Map(g.map(Nj));h.forEach(b=>{const S=ug(b,k.normalizedPath),C=S.toLowerCase();let v=j.get(C);v||(v=m(w,S),j.set(C,v)),v.sessionIds.includes(b.id)||f(w,v.id,b.id)})})},x=[n,p,i,o,l,a,d,u,m,f],e[0]=f,e[1]=m,e[2]=p,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=y,e[11]=x):(y=e[10],x=e[11]),c.useEffect(y,x)};function Nj(t){return[t.name.toLowerCase(),t]}function Aj({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([m,f])=>m!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const Pj=t=>{const e=tt.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:m,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let y,x;if(e[0]!==n){x=new Map,y=new Map;const C=(v,E,R,A)=>{x.has(v)||x.set(v,new Map);const O=x.get(v);A.forEach(B=>{const T=xt(B.worktree?.path??B.session.directory??R??E);O.set(B.session.id,{directory:T}),y.has(v)||y.set(v,{id:B.session.id,directory:T}),B.children.length>0&&C(v,E,T,B.children)})};n.forEach(v=>{v.groups.forEach(E=>{C(v.project.id,v.project.normalizedPath,E.directory,E.sessions)})}),e[0]=n,e[1]=y,e[2]=x}else y=e[1],x=e[2];let k;e[3]!==y||e[4]!==x?(k={metaByProject:x,firstSessionByProject:y},e[3]=y,e[4]=x,e[5]=k):k=e[5];const w=k,h=c.useRef(null);let g,j;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==m||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==w||e[16]!==o||e[17]!==p?(g=()=>{if(!r||u||Ne.getState().isNewWorktreeDialogOpen||h.current===r)return;const C=n.find(A=>A.project.id===r);if(!C)return;const v=w.metaByProject.get(r);if(l&&v&&v.has(l)){h.current=r,o(A=>{if(A.get(r)===l)return A;const O=new Map(A);return O.set(r,l),O});return}const E=Aj({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:v,metaByProject:w.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:w.firstSessionByProject.get(r)?.id??null});if(E.kind==="preserve-current"){a===r&&(h.current=r);return}if(h.current=r,E.kind==="open-draft"){m&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(E.kind!=="select-session")return;const R=v?.get(E.sessionId)?.directory??null;d(E.sessionId,R)},j=[r,i,l,a,d,u,m,f,n,w,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=m,e[12]=u,e[13]=f,e[14]=n,e[15]=w,e[16]=o,e[17]=p,e[18]=g,e[19]=j):(g=e[18],j=e[19]),c.useLayoutEffect(g,j);let b,S;e[20]!==r||e[21]!==l||e[22]!==w||e[23]!==o?(b=()=>{if(!r||!l)return;const C=w.metaByProject.get(r);!C||!C.has(l)||o(v=>{if(v.get(r)===l)return v;const E=new Map(v);return E.set(r,l),E})},S=[r,l,w,o],e[20]=r,e[21]=l,e[22]=w,e[23]=o,e[24]=b,e[25]=S):(b=e[24],S=e[25]),c.useEffect(b,S)},Dj=t=>{const e=tt.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=rt(Ij),a=rt(Tj);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let m;e[8]!==r?(m=()=>new Map(r),e[8]=r,e[9]=m):m=e[9];const[f,p]=c.useState(m);let y;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(y={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=y):y=e[15],Pj(y);let x,k;return e[16]!==f||e[17]!==i?(x=()=>{i(f)},k=[f,i],e[16]=f,e[17]=i,e[18]=x,e[19]=k):(x=e[18],k=e[19]),c.useEffect(x,k),null};function Ij(t){return t.currentSessionId}function Tj(t){return!!t.newSessionDraft?.open}const Ej=t=>{const e=tt.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Yn=(t,e)=>`${t}\0${e}`,Zn=(t,e)=>t??Ga(e)??xt(e??null),Jr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??xt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},ll=t=>t.startsWith("__archived__:"),Rj=(t,e)=>t.map(n=>{const r=xt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
879
+ `),Mj=[],Oj=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:m,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:p,buildGroupSearchText:y,foldersMap:x,standaloneGroups:k}=t,w=c.useRef(new Map),h=c.useMemo(()=>{const R=w.current,A=new Map;let O=0,B=0;const T=(L,W)=>L.length===W.length&&L.every(($,P)=>$===W[P]),M=e.map(L=>{const W=n(L.id),$=r(L.id),P=i.get(L.normalizedPath)??Mj,D=o.has(L.id)?!!o.get(L.id):d,I=l.get(L.id)??null,X=Rj(P,a),Z=R.get(L.id);if(Z&&Z.project===L&&T(Z.activeSessions,W)&&T(Z.archivedSessions,$)&&Z.availableWorktrees===P&&Z.rootBranch===I&&Z.worktreeBranchesKey===X&&Z.isRepo===D&&Z.buildGroupedSessions===u)return O+=1,A.set(L.id,Z),Z.section;if(B+=1,Z){const xe=Z.project!==L?"project":T(Z.activeSessions,W)?T(Z.archivedSessions,$)?Z.availableWorktrees!==P?"worktrees":Z.rootBranch!==I?"branch":Z.worktreeBranchesKey!==X?"worktreeBranches":Z.isRepo!==D?"repo":"builder":"archived":"sessions";Ts(`ui.sidebar.project_section.rebuilt_reason.${xe}`)}const ne=Mu([...W,...$]),ue=u(ne,L.normalizedPath,P,I,D),se={project:L,groups:ue};return A.set(L.id,{project:L,activeSessions:W,archivedSessions:$,availableWorktrees:P,rootBranch:I,worktreeBranchesKey:X,isRepo:D,buildGroupedSessions:u,section:se}),se});return w.current=A,O>0&&Ts("ui.sidebar.project_section.reused",O),B>0&&Ts("ui.sidebar.project_section.rebuilt",B),M},[e,n,r,i,o,d,u,l,a]),g=c.useMemo(()=>h,[h]),j=c.useMemo(()=>{const R=new WeakMap;if(!m)return R;const A=f.trim().toLowerCase(),O=A.startsWith("ses_"),B=M=>M.reduce((L,W)=>L+(!O||W.session.id.toLowerCase()===A?1:0)+B(W.children),0),T=M=>{const L=p(M.sessions,f),W=B(L),$=!O&&$o([y(M)],f),P=Jr(M).flatMap(({scopeKey:I})=>x[I]??[]),D=O?0:P.filter(I=>$o([I.name],f)).length;R.set(M,{filteredNodes:L,matchedSessionCount:W,folderNameMatchCount:D,groupMatches:$,hasMatch:$||W>0||D>0})};return g.forEach(M=>{M.groups.forEach(T)}),k.forEach(T),R},[m,g,k,p,f,y,x]),b=c.useMemo(()=>m?g.map(R=>({...R,groups:R.groups.filter(A=>j.get(A)?.hasMatch===!0)})).filter(R=>R.groups.length>0):g,[m,g,j]),S=m?b:g,C=c.useRef(new WeakMap),v=c.useMemo(()=>{const R=C.current;return S.map(A=>{const O=R.get(A);if(O&&O.query===f)return O.section;const B=A.groups.filter(D=>!D.isArchivedBucket),T=A.groups.filter(D=>D.isArchivedBucket),M=B.flatMap(D=>m?j.get(D)?.filteredNodes??[]:D.sessions),L=B.map(D=>({scopeKey:D.folderScopeKey??xt(D.directory??null),directory:D.directory??null})).filter(D=>!!D.scopeKey),W=B.find(D=>D.isMain)??null,$={id:"flat",label:W?.label??"",branch:W?.branch??null,description:W?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:W?.directory??A.project.normalizedPath,folderScopeKey:W?.folderScopeKey??A.project.normalizedPath,folderScopes:L,sessions:M};if(m){const D=B.map(I=>j.get(I)).filter(I=>!!I);j.set($,{filteredNodes:M,matchedSessionCount:D.reduce((I,X)=>I+X.matchedSessionCount,0),folderNameMatchCount:D.reduce((I,X)=>I+X.folderNameMatchCount,0),groupMatches:D.some(I=>I.groupMatches),hasMatch:D.some(I=>I.hasMatch)})}const P={project:A.project,groups:[$,...T]};return R.set(A,{query:f,section:P}),P})},[j,m,f,S]),E=c.useMemo(()=>{if(!m)return 0;const R=(O,B)=>{const T=j.get(B);if(!T)return O;const M=T.folderNameMatchCount+(T.groupMatches?1:0);return O+T.matchedSessionCount+M},A=S.reduce((O,B)=>B.groups.reduce(R,O),0);return k.reduce(R,A)},[m,S,k,j]);return{projectSections:h,visibleProjectSections:g,groupSearchDataByGroup:j,searchableProjectSections:b,sectionsForRender:S,flatSectionsForRender:v,searchMatchCount:E}},Bj=180,zc=150,Fj=2,_j=8,Wc=[-1,1],Li=t=>`${t.directory}
880
+ ${t.sessionId}`,Lj=t=>t?.directory?.trim()||null,$j=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>_n(),[]),m=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(y=>window.clearTimeout(y)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<Fj&&l.current.length>0;){const y=l.current.shift();if(!y)break;if(y.generation!==d.current||rt.getState().currentSessionId===y.sessionId||ra(y.sessionId,y.directory).renderable)continue;const k=Li(y);a.current.add(k),i({directory:y.directory,sessionID:y.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(k),f()})}},[t,u,i]),p=c.useCallback(y=>{const x=y?.id,k=Lj(y);if(!t||u||!x||!k||x===e)return;const w={sessionId:x,directory:k,generation:d.current},h=Li(w);if(ra(x,k).renderable||a.current.has(h)||l.current.some(b=>Li(b)===h))return;const g=o.current.get(h);g!==void 0&&window.clearTimeout(g);const j=window.setTimeout(()=>{if(o.current.delete(h),w.generation!==d.current)return;const b=l.current;b.length>=_j&&b.shift(),b.push(w),f()},Bj);o.current.set(h,j)},[e,t,u,f]);c.useEffect(()=>{m()},[m,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const y=window.setTimeout(()=>{const x=n.findIndex(k=>k.id===e);if(!(x<0))for(const k of Wc)p(n[x+k])},zc);return()=>window.clearTimeout(y)},[e,t,u,p,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const y=window.setTimeout(()=>{const x=r.findIndex(k=>k.id===e);if(!(x<0))for(const k of Wc)p(r[x+k])},zc);return()=>window.clearTimeout(y)},[e,t,u,r,p]),c.useEffect(()=>m,[m])},zj=t=>{const e=tt.c(3),n=rt(Wj);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],$j(r),null};function Wj(t){return t.currentSessionId}const Kj=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},cl=t=>{const e=tt.c(15),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==o||e[1]!==n?(l=o?n:[],e[0]=o,e[1]=n,e[2]=l):l=e[2];let a;e[3]!==r||e[4]!==l?(a=Kj(l,r),e[3]=r,e[4]=l,e[5]=a):a=e[5];const d=a;let u;e[6]!==o||e[7]!==d.active?(u=k=>{if(!o)return null;for(const w of d.active){const h=k.statusById.get(w)?.status.type;if(h==="busy"||h==="retry")return"active"}return null},e[6]=o,e[7]=d.active,e[8]=u):u=e[8];const m=si(u);let f;e[9]!==o||e[10]!==d.unread?(f=k=>{if(!o)return null;for(const w of d.unread)if((k.index.session.unseenCount[w]??0)>0)return"unread";return null},e[9]=o,e[10]=d.unread,e[11]=f):f=e[11];const p=qa(f);let y;return e[12]!==o||e[13]!==d.active?(y=k=>{if(!o)return null;let w=null;for(const h of d.active){const g=k.bySession.get(h);if(g){if(g.permissions.length>0)return"permission";g.forms.length>0&&(w="form")}}return w},e[12]=o,e[13]=d.active,e[14]=y):y=e[14],Ya(y)??m??p};function $f(t){const e=tt.c(19),{state:n,className:r}=t,{t:i}=Nt();if(n==="permission"||n==="form"){let u;e[0]!==n||e[1]!==i?(u=i(n==="permission"?"sessions.sidebar.session.status.permissionRequired":"sessions.sidebar.session.status.questionPending"),e[0]=n,e[1]=i,e[2]=u):u=e[2];const m=u,f=n==="permission"?"text-destructive":"text-status-info";let p;e[3]!==r||e[4]!==f?(p=Ee("inline-flex shrink-0 items-center",f,r),e[3]=r,e[4]=f,e[5]=p):p=e[5];const y=n==="permission"?"shield":"question";let x;e[6]!==y?(x=s.jsx(_,{name:y,className:"h-3 w-3"}),e[6]=y,e[7]=x):x=e[7];let k;return e[8]!==m||e[9]!==p||e[10]!==x?(k=s.jsx("span",{className:p,"aria-label":m,title:m,children:x}),e[8]=m,e[9]=p,e[10]=x,e[11]=k):k=e[11],k}let o;e[12]!==n||e[13]!==i?(o=i(n==="active"?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[12]=n,e[13]=i,e[14]=o):o=e[14];const l=o,a=n==="active"?"running":"unread";let d;return e[15]!==r||e[16]!==l||e[17]!==a?(d=s.jsx(Ba,{state:a,label:l,className:r}),e[15]=r,e[16]=l,e[17]=a,e[18]=d):d=e[18],d}const Vj=t=>{const e=tt.c(5),{nodes:n,includeUnreadSubtasks:r}=t;let i;e[0]!==r||e[1]!==n?(i={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=i):i=e[2];const o=cl(i);if(!o)return null;let l;return e[3]!==o?(l=s.jsx($f,{state:o}),e[3]=o,e[4]=l):l=e[4],l},Uj=t=>{const e=tt.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:m,children:f,renderBody:p,mobileVariant:y,alwaysShowActions:x,isRenaming:k,renameDraft:w,onRenameDraftChange:h,onRenameSave:g,onRenameCancel:j,droppableRef:b,isDropTarget:S,onNewSession:C,depth:v,hideActions:E,archivedBucket:R}=t,A=a===void 0?null:a,O=p===void 0?!0:p,T=x===void 0?y===void 0?!1:y:x,M=k===void 0?!1:k,L=w===void 0?"":w,W=S===void 0?!1:S,$=E===void 0?!1:E,P=R===void 0?!1:R,{t:D}=Nt(),[I,X]=c.useState(!1),[Z,ne]=c.useState(""),ue=c.useRef(null),se=M||I,xe=M?L:Z;let ie;e[0]!==n.name?(ie=()=>{ne(n.name),X(!0)},e[0]=n.name,e[1]=ie):ie=e[1];const Re=ie;let be;e[2]!==xe||e[3]!==n.name||e[4]!==M||e[5]!==u||e[6]!==g?(be=()=>{const Me=xe.trim();Me&&Me!==n.name&&u(Me),M&&g&&g(),X(!1),ne("")},e[2]=xe,e[3]=n.name,e[4]=M,e[5]=u,e[6]=g,e[7]=be):be=e[7];const fe=be;let ke;e[8]!==M||e[9]!==j?(ke=()=>{M&&j&&j(),X(!1),ne("")},e[8]=M,e[9]=j,e[10]=ke):ke=e[10];const H=ke;let J;e[11]!==M||e[12]!==h?(J=Me=>{M&&h?h(Me):ne(Me)},e[11]=M,e[12]=h,e[13]=J):J=e[13];const ce=J;let je,G;e[14]!==M?(je=()=>{if(!M)return;const Me=()=>{const Ce=ue.current;Ce&&(Ce.focus(),Ce.select())},Ae=requestAnimationFrame(Me),Q=window.setTimeout(Me,0);return()=>{cancelAnimationFrame(Ae),window.clearTimeout(Q)}},G=[M],e[14]=M,e[15]=je,e[16]=G):(je=e[15],G=e[16]),c.useEffect(je,G);const we=l?"folder":"folder-open",Te=W&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let he;e[17]!==Te?(he=Ee("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Te),e[17]=Te,e[18]=he):he=e[18];let re;e[19]!==d||e[20]!==se?(re=se?void 0:Me=>{Me.currentTarget.blur(),d()},e[19]=d,e[20]=se,e[21]=re):re=e[21];const ge=se?void 0:"button",q=se?void 0:0;let z;e[22]!==d||e[23]!==se?(z=se?void 0:Me=>{(Me.key==="Enter"||Me.key===" ")&&(Me.preventDefault(),d())},e[22]=d,e[23]=se,e[24]=z):z=e[24];let ee;e[25]!==n.name||e[26]!==l||e[27]!==D?(ee=l?D("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):D("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=D,e[28]=ee):ee=e[28];const de=P?T?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":T?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let Y;e[29]!==de?(Y=Ee("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",de),e[29]=de,e[30]=Y):Y=e[30];const U=W?"text-primary":"text-muted-foreground";let F;e[31]!==U?(F=Ee("h-3.5 w-3.5 flex-shrink-0",U),e[31]=U,e[32]=F):F=e[32];let V;e[33]!==we||e[34]!==F?(V=s.jsx(_,{name:we,className:F}),e[33]=we,e[34]=F,e[35]=V):V=e[35];let oe;e[36]!==A||e[37]!==r||e[38]!==xe||e[39]!==n.name||e[40]!==H||e[41]!==ce||e[42]!==fe||e[43]!==l||e[44]!==W||e[45]!==se||e[46]!==i||e[47]!==D?(oe=se?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:Hj,onMouseDown:Gj,onSubmit:Me=>{Me.preventDefault(),fe()},children:[s.jsx("input",{ref:ue,value:xe,onChange:Me=>ce(Me.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:D("sessions.sidebar.folderItem.namePlaceholder"),onClick:qj,onPointerDown:Yj,onMouseDown:Qj,onKeyDown:Me=>{if(Me.key==="Escape"){Me.stopPropagation(),H();return}(Me.key===" "||Me.key==="Enter")&&Me.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:Xj,onPointerDown:Jj,onMouseDown:Zj,children:s.jsx(_,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),H()},onPointerDown:e2,onMouseDown:t2,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:Ee("typography-ui-label font-semibold truncate",W?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(jt,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),A?s.jsx($f,{state:A}):null,l?s.jsx(_,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(_,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=A,e[37]=r,e[38]=xe,e[39]=n.name,e[40]=H,e[41]=ce,e[42]=fe,e[43]=l,e[44]=W,e[45]=se,e[46]=i,e[47]=D,e[48]=oe):oe=e[48];let ae;e[49]!==Y||e[50]!==V||e[51]!==oe?(ae=s.jsxs("div",{className:Y,children:[V,oe]}),e[49]=Y,e[50]=V,e[51]=oe,e[52]=ae):ae=e[52];let pe;e[53]!==T||e[54]!==P||e[55]!==n.name||e[56]!==Re||e[57]!==$||e[58]!==m||e[59]!==C||e[60]!==se||e[61]!==D?(pe=!se&&(!$||P)?s.jsx("div",{className:Ee("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",T?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!P&&C?s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),C()},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":D("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:D("sessions.sidebar.project.actions.newSession"),children:s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})}):null,P?null:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),Re()},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":D("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(_,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),m()},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":P?D("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):D("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=T,e[54]=P,e[55]=n.name,e[56]=Re,e[57]=$,e[58]=m,e[59]=C,e[60]=se,e[61]=D,e[62]=pe):pe=e[62];let le;e[63]!==b||e[64]!==he||e[65]!==re||e[66]!==ge||e[67]!==q||e[68]!==z||e[69]!==ee||e[70]!==ae||e[71]!==pe?(le=s.jsxs("div",{ref:b,className:he,onClick:re,role:ge,tabIndex:q,onKeyDown:z,"aria-label":ee,children:[ae,pe]}),e[63]=b,e[64]=he,e[65]=re,e[66]=ge,e[67]=q,e[68]=z,e[69]=ee,e[70]=ae,e[71]=pe,e[72]=le):le=e[72];let _e;e[73]!==f||e[74]!==l||e[75]!==O||e[76]!==i||e[77]!==o||e[78]!==D?(_e=!l&&O?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:D("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=O,e[76]=i,e[77]=o,e[78]=D,e[79]=_e):_e=e[79];let Fe;return e[80]!==le||e[81]!==_e?(Fe=s.jsxs("div",{className:"oc-folder",children:[le,_e]}),e[80]=le,e[81]=_e,e[82]=Fe):Fe=e[82],Fe},zf=c.memo(Uj);function Hj(t){return t.stopPropagation()}function Gj(t){return t.stopPropagation()}function qj(t){return t.stopPropagation()}function Yj(t){return t.stopPropagation()}function Qj(t){return t.stopPropagation()}function Xj(t){return t.stopPropagation()}function Jj(t){return t.stopPropagation()}function Zj(t){return t.stopPropagation()}function e2(t){return t.stopPropagation()}function t2(t){return t.stopPropagation()}function s2(t){const e=tt.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=cl(l);let d;return e[8]!==a||e[9]!==i?(d=s.jsx(zf,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const Zr=t=>{const e=tt.c(13),{directory:n,className:r}=t,{t:i}=Nt();let o;e[0]!==n?(o=Jm(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=k=>k.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Mt(a)?.tabs.some(zd))return null;let m;e[4]!==i?(m=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=m):m=e[5];const f=m;let p;e[6]!==r?(p=Ee("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(_,{name:"pulse",className:"size-3.5"}),e[8]=y):y=e[8];let x;return e[9]!==l||e[10]!==f||e[11]!==p?(x=s.jsx("span",{className:p,role:"img","aria-label":f,title:f,"data-action-directory":l,children:y}),e[9]=l,e[10]=f,e[11]=p,e[12]=x):x=e[12],x},n2=t=>{const e=tt.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,m=a===void 0?!1:a,f=`session-drag:${r??n}`;let p;e[0]!==m||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(p={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:m},e[0]=m,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=p):p=e[5];let y;e[6]!==m||e[7]!==f||e[8]!==p?(y={id:f,disabled:m,data:p},e[6]=m,e[7]=f,e[8]=p,e[9]=y):y=e[9];const{attributes:x,listeners:k,setNodeRef:w,isDragging:h}=Hx(y);let g;e[10]!==k?(g=C=>{C.stopPropagation(),k?.onPointerDown&&k.onPointerDown(C)},e[10]=k,e[11]=g):g=e[11];const j=g,b=`touch-pan-y select-none${h?" opacity-30":""}`;let S;return e[12]!==x||e[13]!==d||e[14]!==j||e[15]!==k||e[16]!==w||e[17]!==b?(S=s.jsx("div",{ref:w,...x,...k,onPointerDown:j,className:b,children:d}),e[12]=x,e[13]=d,e[14]=j,e[15]=k,e[16]=w,e[17]=b,e[18]=S):S=e[18],S},Wf=t=>{const e=tt.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==n||e[1]!==r?(d=Yn(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let m;e[3]!==a||e[4]!==r?(m=a||ll(r),e[3]=a,e[4]=r,e[5]=m):m=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let p;e[10]!==u||e[11]!==m||e[12]!==f?(p={id:u,disabled:m,data:f},e[10]=u,e[11]=m,e[12]=f,e[13]=p):p=e[13];const{setNodeRef:y,isOver:x}=Gx(p);let k;e[14]!==l||e[15]!==x||e[16]!==y?(k=l(y,x),e[14]=l,e[15]=x,e[16]=y,e[17]=k):k=e[17];let w;return e[18]!==k?(w=s.jsx(s.Fragment,{children:k}),e[18]=k,e[19]=w):w=e[19],w},r2=t=>{const e=tt.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=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 m=li(Pn(di,d),Pn(ci,u)),[f,p]=c.useState(null),[y,x]=c.useState("Session"),[k,w]=c.useState(null),[h,g]=c.useState(null);if(!n){let A;return e[2]!==l?(A=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=A):A=e[3],A}let j;e[4]!==o||e[5]!==a?(j=A=>{p(null),w(null),g(null);const{active:O,over:B}=A;if(!B)return;const T=O.data.current,M=B.data.current;T?.type!=="session"||!T.sessionId||!T.ownerKey||T.archivedBucket===!0||a&&T.ownerKey!==a||M?.type!=="folder"||!M.folderId||!M.scopeKey||!M.ownerKey||ll(M.scopeKey)||M.ownerKey!==T.ownerKey||o(T.sessionId,{folderId:M.folderId,scopeKey:M.scopeKey,ownerKey:M.ownerKey},T.ownerKey)},e[4]=o,e[5]=a,e[6]=j):j=e[6];const b=j;let S,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{const O=A.active.data.current;if(O?.type==="session"&&O.sessionId){p(O.sessionId),x(O.sessionTitle??"Session");const B=A.active.rect.current.initial?.width,T=A.active.rect.current.initial?.height;w(B??null),g(T??null)}},C=()=>{p(null),w(null),g(null)},e[7]=S,e[8]=C):(S=e[7],C=e[8]);let v;e[9]!==h||e[10]!==f||e[11]!==y||e[12]!==k||e[13]!==i?(v=f&&i?s.jsxs("div",{style:{width:k?`${k}px`:"auto",height:h?`${h}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(_,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:y})]}):null,e[9]=h,e[10]=f,e[11]=y,e[12]=k,e[13]=i,e[14]=v):v=e[14];let E;e[15]!==v?(E=s.jsx(qx,{children:v}),e[15]=v,e[16]=E):E=e[16];let R;return e[17]!==l||e[18]!==b||e[19]!==m||e[20]!==E?(R=s.jsxs(ui,{sensors:m,collisionDetection:fi,onDragStart:S,onDragCancel:C,onDragEnd:b,children:[l,E]}),e[17]=l,e[18]=b,e[19]=m,e[20]=E,e[21]=R):R=e[21],R},Kf=c.createContext(null),o2=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Kf.Provider,{value:a.current,children:r})},Vf=()=>c.useContext(Kf),i2=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const m of u)l.has(m)||(l.add(m),o.push(m))}return o.length>0?{ids:o,scopeKey:i}:null},Uf=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},Kc=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},kr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(kr(n,e))return!0;return!1},a2=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!fg(r),l2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,c2=(t,e,n)=>{const r=new Map,i=o=>{const l=As(o.session)??xt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},Ca=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},Hf=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},Gf=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const p=i.get(u.parentId)??[];p.push(u.id),i.set(u.parentId,p)}const m=new Set;let f=u.id;for(;f;){if(m.has(f)){o.add(u.id);break}m.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const m=r.get(u);if(!m)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&m.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(m.nodeCount>0||!n&&$o([m.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},Vc=new WeakMap;let Uc=1;const d2=t=>{const e=Vc.get(t);if(e!==void 0)return e;const n=Uc;return Uc+=1,Vc.set(t,n),n},qo=t=>t.children.length===0?"":t.children.map(n=>{const r=d2(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${qo(n)}`}).join("|"),qf=(t,e,n,r,i,o)=>{const l=Qt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const m=d.session.directory??i,f=u.session.directory??o,p=Ml(l,m??"",d.session.id),y=Ml(l,f??"",u.session.id);return(p?n.has(p):!1)!==(y?r.has(y):!1)?!0:d.children.some((x,k)=>a(x,u.children[k]))};return a(t,e)},u2=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,f2=(t,e)=>t?t.branchLabel??null:e??null,m2=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=xt(t?.path??null);return n&&r?ei(r,n):null},Yo=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},h2=t=>{const e=tt.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[m,f]=c.useState(!1),p=i===n&&!m,y=r?i===r&&!m:d;let x;e[0]!==l||e[1]!==i||e[2]!==o?(x=R=>{if(i===R){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=x):x=e[3];const k=x;let w;e[4]!==n||e[5]!==k||e[6]!==o?(w=R=>{if(R){u(!1),f(!1),o(n);return}k(n)},e[4]=n,e[5]=k,e[6]=o,e[7]=w):w=e[7];const h=w;let g;e[8]!==r||e[9]!==k||e[10]!==o?(g=R=>{if(!r){u(R);return}if(R){f(!1),o(r);return}k(r)},e[8]=r,e[9]=k,e[10]=o,e[11]=g):g=e[11];const j=g;let b;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(b=R=>{R||(a(),f(!1),(i===n||i===r)&&o(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=i,e[16]=o,e[17]=b):b=e[17];const S=b;let C;e[18]!==p||e[19]!==n||e[20]!==o?(C=()=>{f(!1),o(p?null:n)},e[18]=p,e[19]=n,e[20]=o,e[21]=C):C=e[21];const v=C;let E;return e[22]!==j||e[23]!==h||e[24]!==S||e[25]!==y||e[26]!==p||e[27]!==v?(E={isMenuOpen:p,isContextMenuOpen:y,handleMenuOpenChange:h,handleContextMenuOpenChange:j,handleMenuOpenChangeComplete:S,toggleMenu:v},e[22]=j,e[23]=h,e[24]=S,e[25]=y,e[26]=p,e[27]=v,e[28]=E):E=e[28],E},p2=t=>{const e=tt.c(10),{project:n,fallback:r}=t,{currentTheme:i}=Ln(),o=n.iconImage??null;let l;e[0]!==n.id||e[1]!==o?(l={id:n.id,iconImage:o},e[0]=n.id,e[1]=o,e[2]=l):l=e[2];let a;e[3]!==i.colors.surface.foreground||e[4]!==i.metadata.variant?(a={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[3]=i.colors.surface.foreground,e[4]=i.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==l||e[8]!==a?(d=s.jsx(oi,{project:l,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=l,e[8]=a,e[9]=d):d=e[9],d},g2=t=>{const e=tt.c(13),{project:n}=t,r=n?.icon?ni[n.icon]:null,i=n?.color?ri[n.color]??null:null;let o;e[0]!==i||e[1]!==r?(o=r?s.jsx(_,{name:r,className:Ee("h-3.5 w-3.5",!i&&"text-muted-foreground/75"),style:i?{color:i}:void 0}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:i?{color:i}:void 0}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;if(!n?.iconImage){let m;return e[3]!==l?(m=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=m):m=e[4],m}let a;e[5]!==n.iconBackground?(a=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[5]=n.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==n?(d=s.jsx(p2,{project:n,fallback:l}),e[7]=l,e[8]=n,e[9]=d):d=e[9];let u;return e[10]!==a||e[11]!==d?(u=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:a,children:d}),e[10]=a,e[11]=d,e[12]=u):u=e[12],u},Hc=t=>{const e=tt.c(45),{compact:n,project:r,projectLabel:i,title:o,titleClassName:l,branchLabel:a,statusDot:d,pinnedMarker:u,timeSlot:m,directoryIndicator:f,prBadge:p,zombieIndicator:y,badges:x,metaPaddingClass:k,hideMetaOnHoverClass:w}=t,h=n===void 0?!1:n,g=!h&&(!!a||!!p||!!y||!!x);let j;e[0]!==w||e[1]!==k?(j=Ee("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",k,w),e[0]=w,e[1]=k,e[2]=j):j=e[2];let b;e[3]!==m?(b=s.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:m}),e[3]=m,e[4]=b):b=e[4];let S;e[5]!==f||e[6]!==u||e[7]!==d||e[8]!==j||e[9]!==b?(S=s.jsxs("span",{className:j,children:[f,u,d,b]}),e[5]=f,e[6]=u,e[7]=d,e[8]=j,e[9]=b,e[10]=S):S=e[10];const C=S;if(h){let M;e[11]!==l?(M=Ee("min-w-0 flex-1 truncate typography-ui-label font-normal",l),e[11]=l,e[12]=M):M=e[12];let L;e[13]!==M||e[14]!==o?(L=s.jsx("div",{className:M,children:o}),e[13]=M,e[14]=o,e[15]=L):L=e[15];let W;e[16]!==x?(W=x?s.jsx("span",{className:"flex flex-shrink-0 items-center gap-1",children:x}):null,e[16]=x,e[17]=W):W=e[17];let $;return e[18]!==C||e[19]!==L||e[20]!==W?($=s.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[L,C,W]}),e[18]=C,e[19]=L,e[20]=W,e[21]=$):$=e[21],$}let v;e[22]!==r?(v=s.jsx(g2,{project:r}),e[22]=r,e[23]=v):v=e[23];let E;e[24]!==i?(E=i?s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/85",children:i}):null,e[24]=i,e[25]=E):E=e[25];let R;e[26]!==C||e[27]!==v||e[28]!==E?(R=s.jsxs("div",{className:"relative flex h-5 w-full min-w-0 items-center gap-1",children:[v,E,C]}),e[26]=C,e[27]=v,e[28]=E,e[29]=R):R=e[29];let A;e[30]!==l?(A=Ee("w-full min-w-0 truncate typography-ui-label font-normal",l),e[30]=l,e[31]=A):A=e[31];let O;e[32]!==A||e[33]!==o?(O=s.jsx("div",{className:A,children:o}),e[32]=A,e[33]=o,e[34]=O):O=e[34];let B;e[35]!==x||e[36]!==a||e[37]!==g||e[38]!==p||e[39]!==y?(B=g?s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[a?s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null,s.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[y??p,x]})]}):null,e[35]=x,e[36]=a,e[37]=g,e[38]=p,e[39]=y,e[40]=B):B=e[40];let T;return e[41]!==B||e[42]!==R||e[43]!==O?(T=s.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[R,O,B]}),e[41]=B,e[42]=R,e[43]=O,e[44]=T):T=e[44],T};let Na=!1;const Aa=new Set;let Gc=!1;function x2(){for(const t of Aa)t()}function dl(t){Na!==t&&(Na=t,x2())}function b2(t){t.key==="Shift"&&dl(!0)}function y2(t){t.key==="Shift"&&dl(!1)}function w2(){dl(!1)}function v2(){Gc||typeof window>"u"||(Gc=!0,window.addEventListener("keydown",b2),window.addEventListener("keyup",y2),window.addEventListener("blur",w2))}function S2(t){return v2(),Aa.add(t),()=>{Aa.delete(t)}}function j2(){return Na}function k2(){return!1}function C2(){return ut.useSyncExternalStore(S2,j2,k2)}async function N2(t,e,n){const r=await Promise.all(t.map(async i=>{n();const o=i.directory??i.session.directory,l=await dn.getSession(i.session.id,o);if(n(),!Xd(e,Lo(l,i.projectDirectory??l.directory)))throw new Error("Fusion source membership changed");const a=await dn.getSessionMessages(i.session.id,{limit:50},o);n();let d="";for(const u of a.items)if(u.info.role==="assistant"){d=mg(u.parts).trim();break}return{source:{...i,session:l},text:d}}));return n(),r.filter(i=>i.text.length>0)}const Yf=t=>{const e=tt.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:d}=Nt(),u=Yt(A2),m=Yt(P2),f=Yt(D2);let p;e[0]!==u?(p=u(),e[0]=u,e[1]=p):p=e[1];const y=p;let x;e[2]!==y?(x=y.filter(I2),e[2]=y,e[3]=x):x=e[3];const k=x;let w,h;e[4]!==y.length||e[5]!==m?(w=()=>{y.length===0&&m()},h=[y.length,m],e[4]=y.length,e[5]=m,e[6]=w,e[7]=h):(w=e[6],h=e[7]),c.useEffect(w,h);let g,j;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==k||e[12]!==n?(g=()=>{if(o)return;const B=n.trim();if(B.length>0&&k.some(L=>L.name===B))return;const T=typeof f=="string"&&f.trim().length>0?f.trim():null;if(T&&k.some(L=>L.name===T)){r(T);return}const M=k[0]?.name;M&&r(M)},j=[f,o,r,k,n],e[8]=f,e[9]=o,e[10]=r,e[11]=k,e[12]=n,e[13]=g,e[14]=j):(g=e[13],j=e[14]),c.useEffect(g,j);const b=n.trim().length>0?n:void 0;let S;e[15]!==i?(S=Ee("max-w-full",i),e[15]=i,e[16]=S):S=e[16];let C;e[17]!==d?(C=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=C):C=e[18];let v;e[19]!==C?(v=s.jsx(js,{placeholder:C}),e[19]=C,e[20]=v):v=e[20];let E;e[21]!==l||e[22]!==S||e[23]!==v?(E=s.jsx(Ms,{id:l,size:"lg",className:S,children:v}),e[21]=l,e[22]=S,e[23]=v,e[24]=E):E=e[24];let R;e[25]!==k?(R=k.length>0&&s.jsx(oa,{children:k.map(T2)}),e[25]=k,e[26]=R):R=e[26];let A;e[27]!==a||e[28]!==R?(A=s.jsx(Os,{fitContent:!0,portalToBody:a,children:R}),e[27]=a,e[28]=R,e[29]=A):A=e[29];let O;return e[30]!==o||e[31]!==r||e[32]!==b||e[33]!==E||e[34]!==A?(O=s.jsxs(Rs,{value:b,onValueChange:r,disabled:o,children:[E,A]}),e[30]=o,e[31]=r,e[32]=b,e[33]=E,e[34]=A,e[35]=O):O=e[35],O};function A2(t){return t.getVisibleAgents}function P2(t){return t.loadAgents}function D2(t){return t.currentAgentName}function I2(t){return Ou(t.mode)}function T2(t){return s.jsx(rs,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const E2="h-7",Gr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,R2=t=>{const e=tt.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=Ee("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",E2),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(ia,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let m;e[3]!==a?(m=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=m):m=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let p;e[6]!==o?(p=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=p):p=e[7];let y;return e[8]!==u||e[9]!==m||e[10]!==p?(y=s.jsxs("div",{className:d,children:[u,m,p]}),e[8]=u,e[9]=m,e[10]=p,e[11]=y):y=e[11],y},Qf=t=>{const e=tt.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:m,dropdownSide:f,dropdownClassName:p,containerClassName:y,triggerIcon:x}=t,k=d===void 0?!0:d,w=f===void 0?"top":f,{t:h}=Nt(),g=Yt(M2),j=Yt(O2),b=Ne(B2),S=Ne(F2),{favoriteModelsList:C,recentModelsList:v}=hg(),E=Ne(_2),R=Ne(L2),[A,O]=c.useState(!1),[B,T]=c.useState(""),[M,L]=c.useState(null),W=c.useRef(null),$=c.useRef(null),P=u===1,D=u===void 0||n.length<u||P;let I;if(e[0]!==n){I=new Map;for(const Le of n){const Je=`${Le.providerID}:${Le.modelID}`;I.set(Je,(I.get(Je)||0)+1)}e[0]=n,e[1]=I}else I=e[1];const X=I;let Z;e[2]!==n?(Z=Le=>n.filter(ot=>ot.providerID===Le.providerID&&ot.modelID===Le.modelID).findIndex(ot=>ot.instanceId===Le.instanceId)+1,e[2]=n,e[3]=Z):Z=e[3];const ne=Z;let ue,se;e[4]!==w||e[5]!==A?(ue=()=>{if(!A||!$.current)return;const Le=$.current.getBoundingClientRect();if(w==="bottom"){const st=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Le.bottom-16-112;L(Math.max(160,Math.min(320,st)));return}let Je=$.current.parentElement;for(;Je&&!Je.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const it=getComputedStyle(Je);if(it.overflow==="auto"||it.overflow==="hidden"||it.overflowY==="auto"||it.overflowY==="hidden")break;Je=Je.parentElement}const ot=Je?Je.getBoundingClientRect().top:0,et=Le.top-ot-16;L(Math.max(150,Math.min(300,et)))},se=[w,A],e[4]=w,e[5]=A,e[6]=ue,e[7]=se):(ue=e[6],se=e[7]),c.useEffect(ue,se);let xe,ie;e[8]!==D||e[9]!==A?(xe=()=>{!D&&A&&(O(!1),T(""))},ie=[D,A],e[8]=D,e[9]=A,e[10]=xe,e[11]=ie):(xe=e[10],ie=e[11]),c.useEffect(xe,ie);let Re,be;e[12]!==A?(Re=()=>{if(!A)return;const Le=Je=>{W.current&&!W.current.contains(Je.target)&&(O(!1),T(""))};return document.addEventListener("mousedown",Le),()=>document.removeEventListener("mousedown",Le)},be=[A],e[12]=A,e[13]=Re,e[14]=be):(Re=e[13],be=e[14]),c.useEffect(Re,be);let fe;e[15]!==P||e[16]!==r||e[17]!==o||e[18]!==n.length?(fe=Le=>{const Je={providerID:Le.providerID,modelID:Le.modelID,displayName:Le.model.name||Le.modelID,instanceId:Gr()};P&&n.length>0&&o?o(0,Je):r(Je),P&&(O(!1),T(""))},e[15]=P,e[16]=r,e[17]=o,e[18]=n.length,e[19]=fe):fe=e[19];const ke=fe;let H;e[20]!==h?(H=h("multirun.modelMultiSelect.search.placeholder"),e[20]=h,e[21]=H):H=e[21];let J;e[22]!==h?(J=h("multirun.modelMultiSelect.search.noResults"),e[22]=h,e[23]=J):J=e[23];let ce;e[24]!==h?(ce=h("multirun.modelMultiSelect.sections.favorites"),e[24]=h,e[25]=ce):ce=e[25];let je;e[26]!==h?(je=h("multirun.modelMultiSelect.sections.recent"),e[26]=h,e[27]=je):je=e[27];let G;e[28]!==h?(G=h("multirun.modelMultiSelect.keyboard.hint"),e[28]=h,e[29]=G):G=e[29];let we;e[30]!==h?(we=h("settings.agents.modelSelector.actions.favorite"),e[30]=h,e[31]=we):we=e[31];let Te;e[32]!==h?(Te=h("settings.agents.modelSelector.actions.unfavorite"),e[32]=h,e[33]=Te):Te=e[33];let he;e[34]!==h?(he=h("chat.modelControls.capabilities"),e[34]=h,e[35]=he):he=e[35];let re;e[36]!==h?(re=h("chat.modelControls.capability.toolCalling"),e[36]=h,e[37]=re):re=e[37];let ge;e[38]!==h?(ge=h("chat.modelControls.capability.reasoning"),e[38]=h,e[39]=ge):ge=e[39];let q;e[40]!==h?(q=h("chat.modelControls.input"),e[40]=h,e[41]=q):q=e[41];let z;e[42]!==h?(z=h("chat.modelControls.output"),e[42]=h,e[43]=z):z=e[43];let ee;e[44]!==h?(ee=h("chat.modelControls.costPerMillion"),e[44]=h,e[45]=ee):ee=e[45];let de;e[46]!==H||e[47]!==J||e[48]!==ce||e[49]!==je||e[50]!==G||e[51]!==we||e[52]!==Te||e[53]!==he||e[54]!==re||e[55]!==ge||e[56]!==q||e[57]!==z||e[58]!==ee?(de={searchPlaceholder:H,noResults:J,favorites:ce,recent:je,keyboardHint:G,favorite:we,unfavorite:Te,capabilities:he,capabilityToolCalling:re,capabilityReasoning:ge,input:q,output:z,costPerMillion:ee},e[46]=H,e[47]=J,e[48]=ce,e[49]=je,e[50]=G,e[51]=we,e[52]=Te,e[53]=he,e[54]=re,e[55]=ge,e[56]=q,e[57]=z,e[58]=ee,e[59]=de):de=e[59];const Y=de;let U;e[60]!==y?(U=Ee("relative",y),e[60]=y,e[61]=U):U=e[61];const F=A?"":void 0;let V;e[62]!==m?(V=Ee(Bu({size:"default"}),"w-fit",m),e[62]=m,e[63]=V):V=e[63];const oe=!D;let ae;e[64]!==A?(ae=()=>{O(!A)},e[64]=A,e[65]=ae):ae=e[65];let pe;e[66]!==x?(pe=x??s.jsx(_,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=x,e[67]=pe):pe=e[67];let le;e[68]!==a||e[69]!==h?(le=a??h("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=h,e[70]=le):le=e[70];let _e;e[71]!==F||e[72]!==V||e[73]!==oe||e[74]!==ae||e[75]!==pe||e[76]!==le?(_e=s.jsxs("button",{ref:$,type:"button","data-popup-open":F,className:V,disabled:oe,onClick:ae,children:[pe,le]}),e[71]=F,e[72]=V,e[73]=oe,e[74]=ae,e[75]=pe,e[76]=le,e[77]=_e):_e=e[77];let Fe;e[78]!==M||e[79]!==D||e[80]!==p||e[81]!==w||e[82]!==C||e[83]!==ke||e[84]!==E||e[85]!==S||e[86]!==A||e[87]!==Y||e[88]!==X||e[89]!==j||e[90]!==R||e[91]!==g||e[92]!==v||e[93]!==B||e[94]!==b?(Fe=A?s.jsx("div",{className:Ee("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",w==="top"?"bottom-full mb-1":"top-full mt-1",p),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(pg,{providers:g,providerOrder:R,favoriteModels:C,recentModels:v,modelsMetadata:j,hiddenModels:E,searchQuery:B,onSearchQueryChange:T,onSelect:ke,labels:Y,selectionCount:Le=>X.get(`${Le.providerID}:${Le.modelID}`)||0,disabled:!D,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:M?`${M}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:A,isFavorite:Le=>S(Le.providerID,Le.modelID),onToggleFavorite:Le=>b(Le.providerID,Le.modelID),onEscape:()=>{O(!1),T("")}})}):null,e[78]=M,e[79]=D,e[80]=p,e[81]=w,e[82]=C,e[83]=ke,e[84]=E,e[85]=S,e[86]=A,e[87]=Y,e[88]=X,e[89]=j,e[90]=R,e[91]=g,e[92]=v,e[93]=B,e[94]=b,e[95]=Fe):Fe=e[95];let Me;e[96]!==U||e[97]!==_e||e[98]!==Fe?(Me=s.jsxs("div",{className:U,ref:W,children:[_e,Fe]}),e[96]=U,e[97]=_e,e[98]=Fe,e[99]=Me):Me=e[99];let Ae;e[100]!==ne||e[101]!==X||e[102]!==i||e[103]!==o||e[104]!==g||e[105]!==n||e[106]!==k||e[107]!==h?(Ae=k&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Le,Je)=>{const ot=`${Le.providerID}:${Le.modelID}`,et=X.get(ot)||1,it=ne(Le),st=g.find(Ge=>Ge.id===Le.providerID)?.models?.find(Ge=>Ge.id===Le.modelID),mt=Qa(st?.variants),kt=mt.length>0,Pe=Le.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(R2,{model:Le,instanceIndex:it,totalSameModel:et,onRemove:()=>i(Je)}),kt&&s.jsxs(Rs,{value:Pe,onValueChange:Ge=>{if(!o)return;o(Je,{...Le,variant:Ge==="__default__"?void 0:Ge})},children:[s.jsxs(Ms,{size:"sm",className:"gap-1.5",children:[s.jsx(_,{name:"brain-ai-3",className:Ee("h-3.5 w-3.5 flex-shrink-0",Pe==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(js,{placeholder:h("multirun.modelMultiSelect.variant.placeholder"),children:Ge=>Ge==="__default__"?h("multirun.modelMultiSelect.variant.default"):Ge})]}),s.jsxs(Os,{fitContent:!0,children:[s.jsx(rs,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:h("multirun.modelMultiSelect.variant.default")}),mt.map($2)]})]})]},Le.instanceId)})}),e[100]=ne,e[101]=X,e[102]=i,e[103]=o,e[104]=g,e[105]=n,e[106]=k,e[107]=h,e[108]=Ae):Ae=e[108];let Q;e[109]!==Me||e[110]!==Ae?(Q=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[Me,Ae]}),e[109]=Me,e[110]=Ae,e[111]=Q):Q=e[111];let Ce;e[112]!==u||e[113]!==l||e[114]!==n.length||e[115]!==h?(Ce=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?h("multirun.modelMultiSelect.validation.minToMax",{min:l,max:u}):h("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=u,e[113]=l,e[114]=n.length,e[115]=h,e[116]=Ce):Ce=e[116];let Be;return e[117]!==Q||e[118]!==Ce?(Be=s.jsxs("div",{className:"space-y-2",children:[Q,Ce]}),e[117]=Q,e[118]=Ce,e[119]=Be):Be=e[119],Be};function M2(t){return t.providers}function O2(t){return t.modelsMetadata}function B2(t){return t.toggleFavoriteModel}function F2(t){return t.isFavoriteModel}function _2(t){return t.hiddenModels}function L2(t){return t.providerOrder}function $2(t){return s.jsx(rs,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const z2=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
881
+
882
+ --- RESULT ${n+1}: ${r} ---
883
+ ${e.trim()}
884
+ --- END RESULT ${n+1} ---`},qc=(t,e)=>rt.getState().getWorktreeMetadata(t)?.projectDirectory??e;function W2({session:t,open:e,onOpenChange:n}){const{t:r}=Nt(),i=gg(),o=vs(I=>I.activeSessions),l=vs(I=>I.archivedSessions),a=vs(I=>I.status==="ready"),d=Yt(I=>I.providers),u=Yt(I=>I.currentProviderId),m=Yt(I=>I.currentModelId),f=Yt(I=>I.currentAgentName),[p,y]=c.useState(u??""),[x,k]=c.useState(m??""),[w,h]=c.useState(()=>u&&m?[{providerID:u,modelID:m,instanceId:Gr()}]:[]),[g,j]=c.useState(""),[b,S]=c.useState(f??""),[C,v]=c.useState([]),[E,R]=c.useState(!1),A=c.useMemo(()=>Lo(t,qc(t.id,t.directory)??t.directory),[t]),O=c.useMemo(()=>{const I=new Map;for(const X of i)I.set(X.id,X);for(const X of o)I.set(X.id,X);for(const X of l)I.set(X.id,X);return t.id&&I.set(t.id,t),Array.from(I.values())},[o,l,i,t]);c.useEffect(()=>{v([])},[e,t.id]);const B=c.useMemo(()=>!e||!A?[]:O.map(I=>{if(C.includes(I.id))return null;const X=rt.getState().getDirectoryForSession(I.id)??As(I),Z=qc(I.id,X),ne=Lo(I,Z??I.directory);return!ne||!Xd(A,ne)?null:{session:I,directory:X,projectDirectory:Z,identity:ne}}).filter(I=>I!==null).sort((I,X)=>(I.session.time?.created??0)-(X.session.time?.created??0)),[O,e,A,C]),M=d.find(I=>I.id===p)?.models.find(I=>I.id===x),L=Qa(M?.variants),W=!!(A&&a&&p&&x&&B.length>0&&!E),$=c.useCallback(I=>{h([I]),y(I.providerID),k(I.modelID),j("")},[]),P=w[0]?.displayName||w[0]?.modelID||r("multirun.fusion.model.placeholder"),D=async()=>{if(!A||!W)return;const I=Qt(),X=dn.getSdkClient(),Z=()=>{if(Qt()!==I||dn.getSdkClient()!==X)throw new Error("Runtime changed")};R(!0);try{const ne=await N2(B,A,Z);if(ne.length===0){Ke.error(r("multirun.fusion.toast.noOutputs"));return}const ue=B[0]?.projectDirectory??B[0]?.directory??null;if(!ue)throw new Error("Fusion requires a session directory");const se=Dh(A.groupSlug,p,x,A.runGroup),[xe,ie]=await Promise.all([Ol("session.fusion.visible"),Ol("session.fusion.instructions")]),Re=await Ih({title:se,directory:ue,identity:{group:A.group,groupSlug:A.groupSlug,runGroup:A.runGroup,role:"fusion",providerID:p,modelID:x},selection:{model:{providerID:p,id:x,variant:g||void 0},agent:b||void 0}},Z);Th(Re,ue),rt.getState().setCurrentSession(Re.id,ue),n(!1),Z(),await dn.sendMessage({runtimeKey:I,id:Re.id,providerID:p,model:{providerID:p,id:x,variant:g||void 0},agent:b||void 0,text:xe,context:[{text:ie},...ne.map((be,fe)=>({text:z2(be.source,be.text,fe)})),{text:`
885
+
886
+ --- FUSION INPUTS END ---
887
+ Now write the final fused answer.`}],directory:ue})}catch(ne){if(Qt()!==I||dn.getSdkClient()!==X)return;console.error("[MultiRunFusion] Failed to start fusion",ne),Ke.error(r("multirun.fusion.toast.failed"))}finally{R(!1)}};return s.jsx(Ps,{open:e,onOpenChange:n,children:s.jsxs(Ds,{className:"max-w-xl overflow-visible",children:[s.jsxs(sn,{children:[s.jsx(Us,{children:r("multirun.fusion.title")}),s.jsx(Hs,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(Qf,{selectedModels:w,onAdd:$,onUpdate:(I,X)=>$(X),onRemove:()=>{h([]),y(""),k(""),j("")},maxModels:1,addButtonLabel:P,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:p?s.jsx(ia,{providerId:p,className:"h-3.5 w-3.5 mr-1"}):void 0})}),L.length>0?s.jsxs(Rs,{value:g||"__default__",onValueChange:I=>j(I==="__default__"?"":I),children:[s.jsxs(Ms,{size:"lg",className:"w-fit",children:[s.jsx(_,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(js,{children:I=>I==="__default__"?r("multirun.modelMultiSelect.variant.default"):I})]}),s.jsxs(Os,{fitContent:!0,portalToBody:!0,children:[s.jsx(rs,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),L.map(I=>s.jsx(rs,{value:I,children:I},I))]})]}):null,s.jsx(Yf,{value:b,onChange:S,portalToBody:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:B.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:B.map(I=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(ia,{providerId:I.identity.providerID,className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:I.session.title||I.session.id}),s.jsx("button",{type:"button",onClick:()=>v(X=>[...X,I.session.id]),className:"text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"h-4 w-4"})})]},I.session.id))})]}),s.jsxs(zn,{children:[s.jsx(ct,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(ct,{onClick:D,disabled:!W,children:r(E?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function K2(t){const e=tt.c(7);let n,r,i,o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),i=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),o=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),l=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=i,e[3]=o,e[4]=l):(n=e[0],r=e[1],i=e[2],o=e[3],l=e[4]);let a;return e[5]!==t?(a=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,i,o,l]}),e[5]=t,e[6]=a):a=e[6],a}const Xf=async(t,e,n)=>{const r=n.getRuntimeKey(),i=xt(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await n.listProjectWorktrees(t,{force:!0});if(n.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const l=n.getCurrentProjects(),a=l.find(x=>x.id===t.id)??null;if(!a||xt(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const d=ul({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),u=o.map(x=>Qo(x));u.sort((x,k)=>Jf({metadata:x},{metadata:k}));const m=xg(d.worktreesByProject,i,u,e?.projectDirectory);V2(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:m};const f=n.getPublishedWorktreesByProject(),p=bg(n.partitionWorktreesByRegisteredProject(l,m),f),y=[...p.values()].flat();return n.recordWorktreesSeen(y.map(x=>x.path),n.now()),n.worktreeMapsEqual(p,f)||n.publishTopology({availableWorktrees:y,availableWorktreesByProject:p}),u},V2=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),U2=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>Qo(r))])),ul=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:U2(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),Jf=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},Yc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Qo=t=>({...t,path:xt(t.path)??t.path,projectDirectory:xt(t.projectDirectory)??t.projectDirectory,worktreeRoot:xt(t.worktreeRoot??t.path)??t.worktreeRoot}),Qc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=xt(e?.path??null)===n,a=l?e?.branch??"":i??"",d={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||Yc(n):i||Yc(n),name:l?e?.name:void 0,worktreeRoot:l?xt(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...d}:d},Xc=t=>{const e=xt(t.projectPath??null),n=xt(t.sourceDirectory??null)??xt(t.currentWorktree?.path??null),r=xt(t.discoveredWorktrees.find(m=>xt(m.projectDirectory??null))?.projectDirectory??null),i=xt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=m=>{const f=xt(m.metadata.path??null);!f||l.has(f)||l.set(f,{...m,metadata:Qo({...m.metadata,path:f})})};for(const m of t.discoveredWorktrees){const f=xt(m.path??null);f&&a({metadata:Qo({...m,path:f,projectDirectory:xt(m.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:Qc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:Qc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const d=[],u=[];for(const m of l.values()){if(m.isPrimary){d.push(m);continue}u.push(m)}return d.sort((m,f)=>m.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),u.sort(Jf),[...d,...u]},Zf=(t,e)=>{const n=t.projectId?e.projects.find(o=>o.id===t.projectId)??null:null;if(n)return n;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const i=t.currentWorktree?.projectDirectory??null;return i?e.resolveProject(i):null},H2=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=ul({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),o=Zf(t,e),l=xt(o?.path??null);return{cachedTargets:Xc({projectPath:l,discoveredWorktrees:l?i.worktreesByProject.get(l)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!o||!l)throw new Error("Unable to resolve worktree project");const d=await Xf(o,t.currentWorktree,e);return Xc({projectPath:l,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},G2=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},q2=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),Y2=(t,e)=>xt(t.worktree?.path??null)===xt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,Wr=6,So=14,Jc=Wr+14+6,$i=new WeakMap,Q2=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;$i.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,$i.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},d=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(n.scrollTop+=u,Ts("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(d)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),$i.set(n,a),l=window.requestAnimationFrame(d)},X2=c.memo(function(e){const n=tt.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:m}=e,f=C2(),p=f?i:r;let y;n[0]!==u||n[1]!==m||n[2]!==f?(y=C=>{if(f||C.shiftKey){m(C);return}u(C)},n[0]=u,n[1]=m,n[2]=f,n[3]=y):y=n[3];const x=y,k=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let w;n[4]!==o||n[5]!==k?(w=Ee("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",k,o),n[4]=o,n[5]=k,n[6]=w):w=n[6];const h=f?"delete-bin":"archive";let g;n[7]!==l||n[8]!==h?(g=s.jsx(_,{name:h,className:l}),n[7]=l,n[8]=h,n[9]=g):g=n[9];let j;n[10]!==x||n[11]!==p||n[12]!==d||n[13]!==a||n[14]!==w||n[15]!==g?(j=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:w,"aria-label":p,onPointerDown:a,onMouseDown:d,onClick:x,onKeyDown:ik,children:g})}),n[10]=x,n[11]=p,n[12]=d,n[13]=a,n[14]=w,n[15]=g,n[16]=j):j=n[16];let b;n[17]!==p?(b=s.jsx(jt,{side:"left",sideOffset:8,children:p}),n[17]=p,n[18]=b):b=n[18];let S;return n[19]!==j||n[20]!==b?(S=s.jsxs(vt,{children:[j,b]}),n[19]=j,n[20]=b,n[21]=S):S=n[21],S});function J2(t){Ts("ui.sidebar_session_node.render");const{t:e}=Nt(),{node:n,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:m,hasSessionSearchQuery:f,normalizedSessionSearchQuery:p,notifyOnSubtasks:y,editingId:x,editingRowKey:k,setEditingId:w,setEditingRowKey:h,editTitle:g,setEditTitle:j,handleSaveEdit:b,handleCancelEdit:S,toggleParent:C,handleSessionSelect:v,handleSessionDoubleClick:E,handleCopySessionId:R,openSidebarMenuKey:A,setOpenSidebarMenuKey:O,createFolderAndStartRename:B,handleDeleteSession:T,handleRestoreSession:M,startSessionWorktreeMenuLoad:L,onEditProject:W,mobileVariant:$,alwaysShowActions:P,secondaryMeta:D,renderContext:I="project",rowKey:X,dragKey:Z,children:ne}=t,ue=Qr(Oe=>Oe.toggle),se=ss(Oe=>Oe.getFoldersForScope),xe=ss(Oe=>Oe.getSessionFolderId),ie=ss(Oe=>Oe.removeSessionFromFolder),Re=ss(Oe=>Oe.addSessionToFolder),be=Ne(Oe=>Oe.openContextPanelTab),fe=c.useMemo(()=>_n(),[]),ke=c.useMemo(()=>qr(),[]),H=c.useContext(yg),J=fe?"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",ce=fe?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",je=fe,G=!d&&!$,we=fe?G&&je?"group-hover:pr-18":G||je?"group-hover:pr-14":"group-hover:pr-8":G?"group-hover:pr-7 group-has-[:focus-visible]:pr-7":"group-hover:pr-3 group-has-[:focus-visible]:pr-3",Te=G?"pr-13":"pr-7",he=fe?G?"pr-18":"pr-14":G?"pr-7":"pr-3",re=c.useRef(!1),[ge,q]=c.useState(!1),z=c.useRef(x);z.current=x;const ee=c.useRef(null),de=c.useRef(!1),Y=c.useRef(b);Y.current=b;const U=g,F=c.useRef(U);F.current=U;const V=c.useRef(null),oe=c.useRef(!1),ae=c.useRef(null),pe=c.useRef(null),le=n.session,_e=le,Fe=Ut(c.useCallback(Oe=>{if(D?.projectLabel||!o)return null;const Rt=Oe.projects.find(es=>es.id===o);return Rt?Rt.label?.trim()||ir(xt(Rt.path)??Rt.path,null)||Rt.path:null},[o,D?.projectLabel])),Me=I==="timeline"||I==="timeline-chat",Ae=I==="timeline-chat",Q=Ut(c.useCallback(Oe=>!Me||!o?null:Oe.projects.find(Rt=>Rt.id===o)??null,[Me,o])),Ce=D?.projectLabel??(Fe?Fu(Fe):null),Be=f2(D,n.worktree?.branch??null),Le=c.useMemo(()=>m2(n.worktree,fe),[fe,n.worktree]),Je=_u(Le),ot=Je?`var(--pr-${Je.visualState})`:void 0,et=!!Be&&I==="recent",it=c.useMemo(()=>{if(!Je)return null;switch(Je.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return Je.canMerge===!0||Je.mergeableState==="clean"||Je.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return Je.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[Je,e]),ht=rt(Oe=>Oe.currentSessionId===le.id),st=xt(le.directory??null)??xt(i??null),mt=a!==void 0?a:o??st??null,kt=fu(),Pe=Lu(),Ge=fe,at=ms(Oe=>Oe.enabled),ze=ms(c.useCallback(Oe=>Oe.selectedIds.has(le.id),[le.id])),ft=ms(Oe=>Oe.toggleSelected),te=ms(Oe=>Oe.setRange),me=Vf(),De=X??le.id,K=x===le.id&&k===De,Se=c.useCallback(Oe=>{const Rt=[],es=ds=>{ds.children.forEach(ys=>{Rt.push(ys.session.id),es(ys)})};return es(Oe),Rt},[]),Ve=c.useCallback(Oe=>{const Rt=[],es=ds=>{ds.children.forEach(ys=>{Rt.push(ys.session),es(ys)})};return es(Oe),Rt},[]),[Xe,nt]=c.useState(!1),[Ze,gt]=c.useState(!0),We=`${I}:${d?"archived":"active"}:${le.id}`,Et=X?`session-menu:${X}`:We,Ft=X?`session-context:${X}`:null,Ie=$u(c.useCallback(Oe=>!!Oe.sessionMemoryState.get(wg(le.id))?.isZombie,[le.id])),yt=nu(le.id),At=vg(le.id,yt),He=df(le.id),Ue=Oa(le.id,st),ve=He||Ue,Qe=n.worktree??rt.getState().getWorktreeMetadata(le.id)??null,[qe,Ye]=c.useState([]),[dt,Ot]=c.useState(!1),[zt,Kt]=c.useState(!1),Gt=c.useRef(!1),Bt=c.useRef(0),Jt=Sg(le.id,st??void 0,{bootstrap:!1}),Vt=jg(_e),Wt=Vt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Bl[Vt.status]),"aria-label":e(Bl[Vt.status]),children:s.jsx(_,{name:"target",className:"h-3 w-3",style:{color:kg[Vt.status]}})}):null,_t=_e.title||e("sessions.sidebar.session.untitled"),Xt=!Me&&n.children.length>0,Ct=zu(u,st,le.id),Tt=We,is=f?!0:m.has(Tt),$s=c.useMemo(()=>c2(n,is,st),[is,n,st]),cs=Cg($s),ps=!!_e.parentID,nn=ru(le.id)>0&&(!ps||y),mn=_e.time?.updated||_e.time?.created||Date.now(),vn=Wu(mn),ks=Ng(mn),{isMenuOpen:rn,isContextMenuOpen:zs,handleMenuOpenChange:Ws,handleContextMenuOpenChange:as,handleMenuOpenChangeComplete:Gs,toggleMenu:gs}=h2({menuInstanceKey:Et,contextMenuInstanceKey:Ft,openSidebarMenuKey:A,setOpenSidebarMenuKey:O,hasDeferredCloseWork:()=>ee.current!==null,onCloseComplete:()=>{if(!ee.current)return;const{id:Oe,title:Rt}=ee.current;ee.current=null,w(Oe),h(De),j(Rt)}}),us=rn||zs,qs=c.useMemo(()=>Lo(_e)!==null,[_e]),[Sn,Ys]=c.useState(!1),hn=c.useMemo(()=>Se(n).length,[Se,n]),on=c.useCallback(async Oe=>{const Rt=[];let es=0;for(const ds of Oe)try{if(!st)throw new Error("Session directory is required for export");const ys=await kt({directory:st,sessionID:ds.session.id});if(!ys)throw new Error("Session runtime changed during export");const ts=ds.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Qs=ds.session.agent,ns=await on(ds.children);es+=ns.skipped,Rt.push({title:ts,agent:Qs,records:ys,children:ns.children})}catch{es+=Se(ds).length+1}return{children:Rt,skipped:es}},[Se,kt,st,e]),jn=c.useCallback(Oe=>{Oe<=0||Ke.warning(Oe===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Oe}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Oe}))},[e]),N=c.useCallback(async Oe=>{if(!st){Ke.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Rt=await kt({directory:st,sessionID:le.id}).catch(()=>null);if(!Rt){Ke.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Rt.length===0){Ke.error(e("sessions.sidebar.session.export.nothingToExport"));return}let es,ds=0;if(Oe&&n.children.length>0){const ns=await on(n.children);es=ns.children,ds=ns.skipped}const ys=mu(Rt,_e.title??null,es),ts=hu(_e.title??null),Qs=await pu(ys,ts);if(Qs){Ke.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Pg()),onClick:()=>{Ag(Qs).then(ns=>{ns||Ke.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),jn(ds);return}gu(ys,ts),Ke.success(e("sessions.sidebar.session.export.success")),jn(ds)},[on,kt,n.children,_e.title,le.id,st,jn,e]),ye=xu(),$e=c.useMemo(()=>bu(ye),[ye]),lt=c.useCallback(Oe=>{lf({entry:Oe,t:e,session:{id:le.id,title:_e.title,directory:st},loadRecords:()=>st?kt({directory:st,sessionID:le.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>Ke.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[kt,_e.title,le.id,st,e]),Pt=c.useCallback(async()=>{if(n.children.length>0){gt(!0),nt(!0);return}await N(!1)},[N,n.children.length]),Dt=c.useCallback(()=>{st&&Fn("desktop_open_session_mini_chat_window",{sessionId:le.id,directory:st,apiBaseUrl:Dn(),clientToken:Yr()}).catch(Oe=>{console.warn("[session-sidebar] failed to open mini chat window",Oe)})},[le.id,st]);if(c.useEffect(()=>{if(!K)return;const Oe=Rt=>{const ds=(Rt.target instanceof HTMLElement?Rt.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(De)}"]`);pe.current&&!ds&&Y.current(F.current)};return document.addEventListener("mousedown",Oe),()=>document.removeEventListener("mousedown",Oe)},[K,De]),c.useLayoutEffect(()=>{if(!K){V.current===De&&(V.current=null);return}V.current!==De&&(V.current=De,oe.current=!0)},[g,K,De]),c.useLayoutEffect(()=>{if(!K||!oe.current)return;const Oe=ae.current;!Oe||Oe.value!==g||(oe.current=!1,Oe.focus(),Oe.select())},[g,K,U]),K){const Oe=s.jsxs("form",{ref:pe,"data-session-rename-form":De,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Rt=>{Rt.preventDefault(),b(U)},children:[s.jsx("input",{ref:ae,value:U,onChange:Rt=>j(Rt.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:Rt=>qi(Rt,S)}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"check",className:"size-3.5"})}),s.jsx("button",{type:"button",onClick:S,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"size-3.5"})})]});return Me?s.jsx("div",{style:{paddingLeft:Wr+4},className:Ee("group relative my-0.5 flex items-center rounded-md pr-2.5",Ae?"py-1":"py-1.5",ht&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:s.jsx(Hc,{compact:Ae,project:Q,projectLabel:Ce,title:Oe,titleClassName:"text-foreground",branchLabel:Be,statusDot:null,pinnedMarker:null,timeSlot:ks,directoryIndicator:null,prBadge:Je?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 typography-micro",style:ot?{color:ot}:void 0,children:[s.jsx(_,{name:"git-pull-request",className:"h-3 w-3",style:ot?{color:ot}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",Je.number]})]}):null,zombieIndicator:null,badges:null,hideMetaOnHoverClass:""})},le.id):s.jsx("div",{style:{paddingLeft:Jc+r*So},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:Oe})},le.id)}const pt=Jt.length,qt=cs===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:cs}),wt=u2({actionsAlwaysVisible:P&&!fe,menuOpen:us,hideOnHoverClass:ce}),bt=!ve&&!yt&&nn&&!ht,It=yt||bt,Lt=e(yt?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),Zt=s.jsx(Ba,{state:yt?"running":"unread",label:Lt}),$t=(yt||bt)&&At,ls=!P&&Xt&&(ve||It||Ct),fs=Ct&&!ve&&!It,Vn=s.jsx(_,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),oo=ve||It||fs?s.jsx("span",{style:{left:Wr+r*So},className:Ee("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",ls?"opacity-100 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0":""),children:ve?s.jsx(_,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(Ue?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):It?Zt:fs?Vn:null}):null,yi=Xt&&!P&&(ve||It||Ct),io=Xt?s.jsx("span",{role:"button",tabIndex:0,onClick:Oe=>{Oe.stopPropagation(),Oe.currentTarget.blur(),C(Tt)},onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),Oe.stopPropagation(),C(Tt))},style:{minWidth:14,minHeight:14,left:Wr+r*So},className:Ee("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",yi?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto":""),"aria-label":e(is?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:is?s.jsx(_,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(_,{name:"arrow-right-s",className:"h-3 w-3"})}):null,wi=Ie?s.jsx(_,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,xm=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),gs()},bm=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},ym=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},vi=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},Si=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},wm=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),O(null),T(le,{archivedBucket:d})},vm=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),O(null),T(le,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},Sm=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},jm=Oe=>{Oe.preventDefault(),Oe.stopPropagation()},km=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),H?.vscode?.executeCommand("openchamber.openSessionInEditor",le.id,_t)},fl=Oe=>{if(re.current){re.current=!1;return}if(at){if(Oe?.preventDefault(),Oe?.stopPropagation(),Oe?.shiftKey){const Rt=me?.getEntries(),es=Rt??Array.from(document.querySelectorAll("[data-session-row]")).map(ts=>ts.getAttribute("data-session-row")).filter(ts=>!!ts).map(ts=>({id:ts,rowKey:ts,scopeKey:mt,archived:d})),ds=Rt?ms.getState().anchorRowKey:ms.getState().anchorId,ys=new Map;ys.set(le.id,Se(n)),te(ds,De,es,me?.getDescendantIds()??[],mt,ys);return}ft(le.id,mt,Se(n),De);return}Oe?.currentTarget&&Q2(Oe.currentTarget),v(le.id,st)},Cm=Oe=>{Oe.defaultPrevented||(Oe.target instanceof HTMLElement?Oe.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||fl(Oe)},Nm=Oe=>{(Oe.button===2||Oe.button===0&&Oe.ctrlKey&&!at)&&(re.current=!0)},Am=Oe=>{$&&Oe.pointerType==="touch"&&q(!0),Oe.button===0&&!ht&&!at&&!Ge&&st&&!ra(le.id,st).renderable&&Pe({directory:st,sessionID:le.id}).catch(()=>{})},ml=Oe=>{$&&Oe.pointerType==="touch"&&q(!1)},Pm=Oe=>{Gt.current=Oe,Bt.current+=1;const Rt=Bt.current;if(!Oe){Ot(!1),Kt(!1);return}const es=L({projectId:o??null,sourceDirectory:st,currentWorktree:Qe});Ye(es.cachedTargets),Ot(!0),Kt(!1),es.refreshTargets.then(ds=>{!Gt.current||Bt.current!==Rt||(Ye(ds),Ot(!1),Kt(!1))}).catch(()=>{!Gt.current||Bt.current!==Rt||(Ot(!1),Kt(!0))})},hl=({Item:Oe,Separator:Rt,Sub:es,SubTrigger:ds,SubContent:ys})=>s.jsxs(s.Fragment,{children:[s.jsxs(Oe,{onClick:()=>{ee.current={id:le.id,title:_t}},className:"[&>svg]:mr-1",children:[s.jsx(_,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsx(ma,{sessionID:le.id,directory:st,open:us,Item:Oe}),s.jsxs(Oe,{onClick:()=>R(le.id),className:"[&>svg]:mr-1",children:[s.jsx(_,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Oe,{onClick:()=>st&&ue({directory:st,sessionId:le.id}),className:"[&>svg]:mr-1",children:[Ct?s.jsx(_,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(_,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(Ct?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),s.jsxs(Oe,{onClick:()=>{Pt()},className:"[&>svg]:mr-1",children:[s.jsx(_,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),$e.map(ts=>s.jsxs(Oe,{onClick:()=>lt(ts),className:"[&>svg]:mr-1",children:[s.jsx(to,{icon:ts.icon,iconSrc:ts.iconSrc,className:"mr-1 size-4"}),ts.action.label]},`${ts.guest.id}:${ts.action.id}`)),Me&&o&&W?s.jsxs(Oe,{onClick:()=>W(o),className:"[&>svg]:mr-1",children:[s.jsx(_,{name:"pencil-ai",className:"h-4 w-4"}),e("sessions.sidebar.project.actions.edit")]}):null,a2({isSubtaskSession:ps,archivedBucket:!!d,isVSCode:fe,sessionDirectory:st})?(()=>{const ts=l2({sessionDirectory:st,isStreaming:yt,isMovingToWorktree:He}),Qs=q2({targets:qe,isRefreshing:dt,loadFailed:zt});return s.jsxs(es,{onOpenChange:Pm,children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ds,{disabled:ts,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":le.id,children:[s.jsx(_,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(jt,{side:"right",className:"max-w-72",children:e(He?"sessions.sidebar.session.moveToWorktree.tooltipMoving":yt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(ys,{className:"min-w-[220px]","data-session-worktree-submenu":le.id,children:[qe.map(ns=>{const Xs=xt(ns.metadata.path??null)??ns.metadata.path,Pr=ns.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ns.metadata.label||ns.metadata.branch||ns.metadata.name||ns.metadata.path,xs=ns.isCurrent||ns.metadata.worktreeStatus!=="ready";return s.jsxs(Oe,{disabled:xs,title:ns.metadata.path,"data-session-worktree-target":Xs,onClick:()=>{xs||!st||pa({kind:"existing",root:_e,descendants:Ve(n),sourceDirectory:st,destination:ns.metadata,messages:ha(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:Pr}),ns.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ns.isCurrent?s.jsx(_,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Xs)}),Qs.refreshState==="loading"?s.jsx(Oe,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,Qs.refreshState==="error"?s.jsx(Oe,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(Rt,{}),s.jsxs(Oe,{disabled:ts,"data-session-worktree-new-action":"true",onClick:()=>{ts||!st||pa({kind:"quick",root:_e,descendants:Ve(n),sourceDirectory:st,messages:ha(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(_,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,qs?s.jsxs(Oe,{onClick:()=>Ys(!0),className:"[&>svg]:mr-1",children:[s.jsx(K2,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,st&&!d&&!Me?(()=>{const ts=[],Qs=xs=>{const Ss=xt(xs??null);Ss&&!ts.includes(Ss)&&ts.push(Ss)};if(o&&!fe){const xs=Ut.getState().projects.find(ur=>ur.id===o),Ss=xt(xs?.path??null);Qs(Ss),Ss&&(rt.getState().availableWorktreesByProject.get(Ss)??[]).forEach(ur=>Qs(ur.path))}Qs(Ga(st)),Qs(st);const ns=ts.flatMap(xs=>se(xs).map(Ss=>({scope:xs,folder:Ss}))),Xs=ns.find(({scope:xs,folder:Ss})=>xe(xs,le.id)===Ss.id)??null,Pr=ts[0]??st;return s.jsxs(s.Fragment,{children:[s.jsx(Rt,{}),s.jsxs(es,{children:[s.jsxs(ds,{className:"[&>svg]:mr-1",children:[s.jsx(_,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(ys,{className:"min-w-[180px]",children:[ns.length===0?s.jsx(Oe,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):ns.map(({scope:xs,folder:Ss})=>{const ur=Xs?.folder.id===Ss.id;return s.jsxs(Oe,{onClick:()=>{if(ur){ie(xs,le.id);return}Xs&&Xs.scope!==xs&&ie(Xs.scope,le.id),Re(xs,Ss.id,le.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:Ss.name}),ur?s.jsx(_,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},Ss.id)}),s.jsx(Rt,{}),s.jsxs(Oe,{onClick:()=>{const xs=B(Pr);xs&&(de.current=!0,Xs&&Xs.scope!==Pr&&ie(Xs.scope,le.id),Re(Pr,xs.id,le.id))},children:[s.jsx(_,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Xs?s.jsxs(Oe,{onClick:()=>{ie(Xs.scope,le.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,fe?null:s.jsxs(Oe,{disabled:!st,onClick:()=>{st&&be(st,{mode:"chat",dedupeKey:`session:${le.id}`,label:_t,sessionTitleFallback:_t})},className:"[&>svg]:mr-1",children:[s.jsx(_,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),ke?s.jsxs(Oe,{disabled:!st,onClick:Dt,className:"[&>svg]:mr-1",children:[s.jsx(_,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Rt,{}),d?null:s.jsxs(Oe,{className:"[&>svg]:mr-1",onClick:()=>T(le,{archivedBucket:d}),children:[s.jsx(_,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),d?s.jsxs(Oe,{className:"[&>svg]:mr-1",onClick:()=>M(le),children:[s.jsx(_,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Oe,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>T(le,{archivedBucket:d,hardDelete:!0}),children:[s.jsx(_,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Dm=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),st&&ue({directory:st,sessionId:le.id})},ji=P?"h-6 w-6":Me&&!Ae?"h-5 w-5":"h-4 w-4",ao=P?"h-3.5 w-3.5":Me&&!Ae?"h-3 w-3":"h-2.5 w-2.5",Im=pt>0||cs>0?s.jsxs(s.Fragment,{children:[pt>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(_,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:pt})]}):null,cs>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info",title:qt,"aria-label":qt,children:[s.jsx(_,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:cs})]}):null]}):null,Tm=Me&&Je?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",className:"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",style:ot?{color:ot}:void 0,disabled:!Je.url,"aria-label":it?`#${Je.number} · ${it}`:`#${Je.number}`,onPointerDown:vi,onMouseDown:Si,onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),Je.url&&eo(Je.url)},onKeyDown:Oe=>Oe.stopPropagation(),children:[s.jsx(_,{name:"git-pull-request",className:"h-3 w-3",style:ot?{color:ot}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",Je.number]})]})}),s.jsx(jt,{side:"top",sideOffset:6,children:s.jsx("p",{children:it?`#${Je.number} · ${it}`:`#${Je.number}`})})]}):null,Em=Me?s.jsx(Hc,{compact:Ae,project:Q,projectLabel:Ce,title:Vr(_t,p),titleClassName:ht||ze?"text-interactive-selection-foreground":nn?"text-foreground":"text-foreground/80",branchLabel:Be,statusDot:It?Zt:null,pinnedMarker:Ct&&!ve?Vn:null,timeSlot:$t?s.jsx(Ci,{sessionId:le.id,running:yt,className:"typography-micro"}):ks,directoryIndicator:!d&&st?s.jsx(Zr,{directory:st}):null,prBadge:Tm,zombieIndicator:wi,badges:Im,metaPaddingClass:P?G?"pr-19":"pr-13":void 0,hideMetaOnHoverClass:P&&!fe?"":Ee(ce,us&&"opacity-0")}):null,Rm=s.jsx(_s,{align:"end",className:"min-w-[180px]",finalFocus:()=>de.current?(de.current=!1,!1):!z.current,children:hl({Item:Ht,Separator:Es,Sub:Ig,SubTrigger:Tg,SubContent:Eg})}),Mm=s.jsx(ca,{children:s.jsx(da,{className:"app-region-no-drag z-50",children:s.jsx(ua,{"data-slot":"dropdown-menu-content",finalFocus:()=>de.current?(de.current=!1,!1):!z.current,style:{color:"var(--surface-elevated-foreground)"},className:Ee(Qi,"min-w-[180px]"),children:hl({Item:({className:Oe,...Rt})=>s.jsx(Zu,{className:Ee(iu,Oe),...Rt}),Separator:({className:Oe,...Rt})=>s.jsx(Ju,{className:Ee(ou,Oe),...Rt}),Sub:Jx,SubTrigger:({className:Oe,children:Rt,...es})=>s.jsxs(Zx,{className:Ee(Dg,Oe),...es,children:[Rt,s.jsx(_,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Oe,children:Rt,...es})=>s.jsx(ca,{children:s.jsx(da,{className:"app-region-no-drag z-50",children:s.jsx(ua,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Ee(Qi,Oe),...es,children:Rt})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(n2,{sessionId:le.id,dragKey:Z??De,ownerKey:l??mt,sessionDirectory:st??null,sessionTitle:_t,archivedBucket:d,children:s.jsxs(tf,{open:zs,onOpenChange:as,onOpenChangeComplete:Gs,children:[s.jsxs(ef,{render:s.jsx("div",{"data-session-row":le.id,"data-session-scope":mt??"","data-session-archived":d?"1":"0","aria-current":ht?"page":void 0,onClick:Cm,style:{paddingLeft:Me?Wr+4:Jc+r*So},className:Ee("group relative my-0.5 flex cursor-pointer items-center rounded-md pr-2.5",Me&&!Ae?"py-1.5":"py-1",Me&&!(ht||ze)&&"hover:bg-interactive-hover/60",(ht||ze)&&"bg-interactive-selection/70 text-interactive-selection-foreground",ze&&"ring-1 ring-inset ring-border")}),children:[Me?null:oo,Me?null:io,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-pressed":at?ze:void 0,onPointerDown:Am,onPointerUp:ml,onPointerCancel:ml,onMouseDown:Nm,onClick:Oe=>fl(Oe),onDoubleClick:Oe=>{Oe.stopPropagation(),E(le.id,_t)},className:Ee("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none transition-[padding]",ge&&"bg-interactive-hover/70",Me?void 0:P?fe?we:Te:us?he:we),children:Me?Em:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Ee("block min-w-0 flex-1 truncate typography-ui-label font-normal",ht||ze?"text-interactive-selection-foreground":nn?"text-foreground":"text-foreground/80"),children:Vr(_t,p)}),!d&&st&&I==="recent"?s.jsx(Zr,{directory:st,className:P?void 0:us?"mr-1":fe?"group-hover:mr-1":"group-hover:mr-1 group-has-[:focus-visible]:mr-1"}):null,P?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:$t?s.jsx(Ci,{sessionId:le.id,running:yt}):s.jsxs(s.Fragment,{children:[Wt,et?s.jsx(_,{name:"git-branch",className:Ee("h-3 w-3",!ot&&"text-muted-foreground/60"),style:ot?{color:ot}:void 0}):null,ks]})}):$t||Wt||et||I==="recent"?s.jsx("div",{className:Ee("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",us?"hidden":fe?"group-hover:hidden":"group-hover:hidden group-has-[:focus-visible]:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:$t?s.jsx(Ci,{sessionId:le.id,running:yt,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[Wt,et?s.jsx(_,{name:"git-branch",className:Ee("h-3 w-3",!ot&&"text-muted-foreground/60"),style:ot?{color:ot}:void 0}):null,I==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:ks}):null]})})}):null,pt>0?s.jsxs("span",{className:Ee("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",wt),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(_,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:pt})]}):null,cs>0?s.jsxs("span",{className:Ee("inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",wt),title:qt,"aria-label":qt,children:[s.jsx(_,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:cs})]}):null]})})}),!fe&&!Me?s.jsx(jt,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:_t}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:vn,children:ks})]}),Ce&&!Me?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(_,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:Ce})]}):null,Be?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:ot?{color:ot}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:Be})]}):null,Je&&it?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(_,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:ot?{color:ot}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:ot?{color:ot}:void 0,children:["#",Je.number," · ",it]})]}):null]})}):null]})}),wi&&!$&&!Me?s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 z-10",children:wi}):null,s.jsxs("div",{className:Ee("absolute right-1 z-10 flex items-center gap-0.5 transition-opacity",Me&&!Ae?"top-1.5 h-5":"top-1/2 -translate-y-1/2",us||P&&!fe?"opacity-100":Ee("opacity-0",J)),children:[Me?s.jsx("button",{type:"button",className:Ee("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",ji,Ct?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-label":e(Ct?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin"),onPointerDown:vi,onMouseDown:Si,onClick:Dm,onKeyDown:Oe=>Oe.stopPropagation(),children:s.jsx(_,{name:"pushpin",className:ao})}):null,G?s.jsx(X2,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:ji,iconSizeClass:ao,onPointerDown:vi,onMouseDown:Si,onArchive:wm,onDelete:vm}):null,je?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee("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",ji),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Sm,onMouseDown:jm,onClick:km,onKeyDown:Oe=>Oe.stopPropagation(),children:s.jsx(_,{name:"external-link",className:ao})})}),s.jsx(jt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(Ls,{open:rn,onOpenChange:Ws,onOpenChangeComplete:Gs,children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee("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",P?"h-6 w-6 opacity-100":us?"h-4 w-4 opacity-100":Ee("h-4 w-4 opacity-0",J)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:bm,onMouseDown:ym,onClick:xm,onKeyDown:Oe=>Oe.stopPropagation(),children:s.jsx(_,{name:"more-2",className:ao})})}),Rm]})]})]}),Mm]})}),Xt&&is?ne:null,s.jsx(Ps,{open:Xe,onOpenChange:nt,children:s.jsxs(Ds,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(sn,{children:[s.jsx(Us,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Hs,{children:hn===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:hn}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:hn})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Ze,onChange:Oe=>gt(Oe.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(zn,{children:[s.jsx(ct,{type:"button",onClick:()=>nt(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(ct,{type:"button",onClick:()=>{nt(!1),N(Ze)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),qs?s.jsx(W2,{session:_e,open:Sn,onOpenChange:Ys}):null]},le.id)}const Zc=t=>xt(t.session.directory??null),Z2=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),ek=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",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},ed=t=>t.menuOpenSessionId??ek(t),jo=(t,e,n)=>e?n.has(t.node.session.id)?!0:kr(t.node,e):!1,Pa=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(Pa(t.children[l],e.children[l],n,r,i))return!0;return!1},tk=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return Pa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||Pa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},sk=(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&&Jd(t,e),nk=(t,e)=>{if(t.node.session.id!==e.node.session.id||!sk(t.node.session,e.node.session)||!Y2(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(Zc(t.node)!==Zc(e.node))return"nodeDirectory";if(!Z2(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&qf(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&tk(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(jo(t,t.editingId,t.subtreeContainsEditing)||jo(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&&(jo(t,t.editingId,t.subtreeContainsEditing)||jo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=ed(t),i=ed(e);if(kr(t.node,r)||kr(e.node,i))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.onEditProject===e.onEditProject&&t.children===e.children?null:"callbacks"},rk=(t,e)=>{const n=nk(t,e);return n===null?!0:(Ts(`ui.sidebar_session_node.props_changed.${n}`),!1)},ok=c.memo(J2,rk);function ik(t){return t.stopPropagation()}const ak=t=>{const{t:e}=Nt(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=Ne(D=>D.setSessionSwitcherOpen),a=rt(D=>D.setCurrentSession),d=rt(D=>D.updateSessionTitle),u=rt(D=>D.deleteSession),m=rt(D=>D.deleteSessions),f=rt(D=>D.archiveSession),p=rt(D=>D.archiveSessions),y=rt(D=>D.unarchiveSession),{mobileVariant:x,allowReselect:k,onSessionSelected:w,resetSessionSearch:h,descendantIds:g,showDeletionDialog:j,setDeleteSessionConfirm:b,setEditingId:S,setEditingRowKey:C,editingSessionId:v,editingOccurrenceKey:E,setEditTitle:R}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const A=c.useCallback((D,I)=>{if(Hi("navigation.session_select"),Ne.getState().closeMainSurfaces(),x&&l(!1),D===rt.getState().currentSessionId){k&&w?.(D),h();return}Hi("navigation.session_state_set"),a(D,I??null),w?.(D),h()},[k,x,w,h,a,l]),O=c.useCallback((D,I)=>{S(D),C(E),R(I)},[E,R,S,C]),B=c.useCallback(async D=>{if(!r.current)return;const X=(D??i.current).trim();if(X)try{await d(v,X)}catch(Z){console.error("[session-actions] rename failed",Z),Ke.error(e("sessions.sidebar.session.rename.error",{detail:Zd(Z instanceof Error?Z:new Error(String(Z)),e)}))}S(null),C(null),R("")},[v,R,S,C,e,d]),T=c.useCallback(()=>{S(null),C(null),R("")},[R,S,C]),M=c.useCallback(D=>{cr(D).then(I=>{if(I.ok){Ke.success(e("sessions.sidebar.session.copyId.success"));return}Ke.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(e("sessions.sidebar.session.copyId.error")))},[e]),L=c.useCallback(async(D,I,X)=>{const Z=I?.archivedBucket===!0||I?.hardDelete===!0,ne=X?.descendantIds??g;await Eh(Z?"delete":"archive",D,ne,{archiveSession:f,archiveSessions:p,deleteSession:u,deleteSessions:m},e)},[f,p,u,m,g,e]),W=c.useCallback((D,I)=>{const X=I?.archivedBucket===!0||I?.hardDelete===!0,Z=Vd(D.id,g,X);if(!j||I?.skipConfirm===!0){L(D,I,{descendantIds:Z});return}b({session:D,descendantCount:Z.length,descendantIds:Z,archivedBucket:X})},[g,L,b,j]),$=c.useCallback(async()=>{const D=o.current;if(!D)return;const{session:I,archivedBucket:X,descendantIds:Z}=D;b(null),await L(I,{archivedBucket:X},{descendantIds:Z})},[L,b]),P=c.useCallback(async D=>{await y(D.id)?Ke.success(e("sessions.sidebar.session.restore.success")):Ke.error(e("sessions.sidebar.session.restore.error"))},[e,y]);return c.useMemo(()=>({handleSessionSelect:A,handleSessionDoubleClick:O,handleSaveEdit:B,handleCancelEdit:T,handleCopySessionId:M,handleDeleteSession:W,handleRestoreSession:P,confirmDeleteSession:$}),[T,M,W,P,B,O,A,$])};function lk(t){const e=tt.c(71),{t:n}=Nt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,m,f,p,y,x,k,w,h;if(e[0]!==i||e[1]!==n||e[2]!==r){const D=n("sessions.sidebar.session.untitled");f=Ps,w=!!r,e[13]!==i?(h=X=>{X||i(null)},e[13]=i,e[14]=h):h=e[14],m=Ds,x=!1,k="max-w-sm gap-5",u=sn;let I;e[15]!==n||e[16]!==r?.archivedBucket?(I=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=I):I=e[17],e[18]!==I?(y=s.jsx(Us,{children:I}),e[18]=I,e[19]=y):y=e[19],d=Hs,p=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||D,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||D,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||D,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||D,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||D}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||D}),e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=m,e[6]=f,e[7]=p,e[8]=y,e[9]=x,e[10]=k,e[11]=w,e[12]=h}else d=e[3],u=e[4],m=e[5],f=e[6],p=e[7],y=e[8],x=e[9],k=e[10],w=e[11],h=e[12];let g;e[20]!==d||e[21]!==p?(g=s.jsx(d,{children:p}),e[20]=d,e[21]=p,e[22]=g):g=e[22];let j;e[23]!==u||e[24]!==y||e[25]!==g?(j=s.jsxs(u,{children:[y,g]}),e[23]=u,e[24]=y,e[25]=g,e[26]=j):j=e[26];let b;e[27]!==l||e[28]!==o?(b=()=>l(!o),e[27]=l,e[28]=o,e[29]=b):b=e[29];const S=!o;let C;e[30]!==o?(C=o?s.jsx(_,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(_,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=C):C=e[31];let v;e[32]!==n?(v=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=v):v=e[33];let E;e[34]!==C||e[35]!==v||e[36]!==b||e[37]!==S?(E=s.jsxs("button",{type:"button",onClick:b,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":S,children:[C,v]}),e[34]=C,e[35]=v,e[36]=b,e[37]=S,e[38]=E):E=e[38];let R;e[39]!==i?(R=()=>i(null),e[39]=i,e[40]=R):R=e[40];let A;e[41]!==n?(A=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=A):A=e[42];let O;e[43]!==R||e[44]!==A?(O=s.jsx("button",{type:"button",onClick:R,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:A}),e[43]=R,e[44]=A,e[45]=O):O=e[45];let B;e[46]!==a?(B=()=>{a()},e[46]=a,e[47]=B):B=e[47];let T;e[48]!==n||e[49]!==r?.archivedBucket?(T=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=T):T=e[50];let M;e[51]!==B||e[52]!==T?(M=s.jsx("button",{type:"button",onClick:B,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:T}),e[51]=B,e[52]=T,e[53]=M):M=e[53];let L;e[54]!==O||e[55]!==M?(L=s.jsxs("div",{className:"flex items-center gap-2",children:[O,M]}),e[54]=O,e[55]=M,e[56]=L):L=e[56];let W;e[57]!==E||e[58]!==L?(W=s.jsxs(zn,{className:"w-full sm:items-center sm:justify-between",children:[E,L]}),e[57]=E,e[58]=L,e[59]=W):W=e[59];let $;e[60]!==m||e[61]!==x||e[62]!==W||e[63]!==k||e[64]!==j?($=s.jsxs(m,{showCloseButton:x,className:k,children:[j,W]}),e[60]=m,e[61]=x,e[62]=W,e[63]=k,e[64]=j,e[65]=$):$=e[65];let P;return e[66]!==f||e[67]!==$||e[68]!==w||e[69]!==h?(P=s.jsx(f,{open:w,onOpenChange:h,children:$}),e[66]=f,e[67]=$,e[68]=w,e[69]=h,e[70]=P):P=e[70],P}function ck(t){const e=tt.c(57),{t:n}=Nt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let m;e[0]!==d||e[1]!==u||e[2]!==n?(m=n(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]=n,e[3]=m):m=e[3];const f=m;let p;e[4]!==d||e[5]!==u||e[6]!==n?(p=d?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=n,e[7]=p):p=e[7];const y=p,x=!!r;let k;e[8]!==i?(k=P=>{P||i(null)},e[8]=i,e[9]=k):k=e[9];let w;e[10]!==f?(w=s.jsx(Us,{children:f}),e[10]=f,e[11]=w):w=e[11];let h;e[12]!==y?(h=s.jsx(Hs,{children:y}),e[12]=y,e[13]=h):h=e[13];let g;e[14]!==w||e[15]!==h?(g=s.jsxs(sn,{children:[w,h]}),e[14]=w,e[15]=h,e[16]=g):g=e[16];let j;e[17]!==l||e[18]!==o?(j=()=>l(!o),e[17]=l,e[18]=o,e[19]=j):j=e[19];const b=!o;let S;e[20]!==o?(S=o?s.jsx(_,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(_,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=S):S=e[21];let C;e[22]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=C):C=e[23];let v;e[24]!==C||e[25]!==j||e[26]!==b||e[27]!==S?(v=s.jsxs("button",{type:"button",onClick:j,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":b,children:[S,C]}),e[24]=C,e[25]=j,e[26]=b,e[27]=S,e[28]=v):v=e[28];let E;e[29]!==i?(E=()=>i(null),e[29]=i,e[30]=E):E=e[30];let R;e[31]!==n?(R=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=R):R=e[32];let A;e[33]!==E||e[34]!==R?(A=s.jsx("button",{type:"button",onClick:E,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[33]=E,e[34]=R,e[35]=A):A=e[35];let O;e[36]!==a?(O=()=>{a()},e[36]=a,e[37]=O):O=e[37];let B;e[38]!==d||e[39]!==n?(B=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=B):B=e[40];let T;e[41]!==O||e[42]!==B?(T=s.jsx("button",{type:"button",onClick:O,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:B}),e[41]=O,e[42]=B,e[43]=T):T=e[43];let M;e[44]!==A||e[45]!==T?(M=s.jsxs("div",{className:"flex items-center gap-2",children:[A,T]}),e[44]=A,e[45]=T,e[46]=M):M=e[46];let L;e[47]!==v||e[48]!==M?(L=s.jsxs(zn,{className:"w-full sm:items-center sm:justify-between",children:[v,M]}),e[47]=v,e[48]=M,e[49]=L):L=e[49];let W;e[50]!==L||e[51]!==g?(W=s.jsxs(Ds,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,L]}),e[50]=L,e[51]=g,e[52]=W):W=e[52];let $;return e[53]!==x||e[54]!==W||e[55]!==k?($=s.jsx(Ps,{open:x,onOpenChange:k,children:W}),e[53]=x,e[54]=W,e[55]=k,e[56]=$):$=e[56],$}function em(t){const e=tt.c(36),{t:n}=Nt(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=S=>{S||i(null)},e[0]=i,e[1]=a):a=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==d?(u=s.jsx(Us,{children:d}),e[4]=d,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==r?(m=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=m):m=e[8];let f;e[9]!==m?(f=s.jsx(Hs,{children:m}),e[9]=m,e[10]=f):f=e[10];let p;e[11]!==u||e[12]!==f?(p=s.jsxs(sn,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13];let y;e[14]!==i?(y=()=>i(null),e[14]=i,e[15]=y):y=e[15];let x;e[16]!==n?(x=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=x):x=e[17];let k;e[18]!==y||e[19]!==x?(k=s.jsx("button",{type:"button",onClick:y,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:x}),e[18]=y,e[19]=x,e[20]=k):k=e[20];let w;e[21]!==n?(w=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=w):w=e[22];let h;e[23]!==o||e[24]!==w?(h=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:w}),e[23]=o,e[24]=w,e[25]=h):h=e[25];let g;e[26]!==h||e[27]!==k?(g=s.jsxs(zn,{children:[k,h]}),e[26]=h,e[27]=k,e[28]=g):g=e[28];let j;e[29]!==g||e[30]!==p?(j=s.jsxs(Ds,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,g]}),e[29]=g,e[30]=p,e[31]=j):j=e[31];let b;return e[32]!==l||e[33]!==a||e[34]!==j?(b=s.jsx(Ps,{open:l,onOpenChange:a,children:j}),e[32]=l,e[33]=a,e[34]=j,e[35]=b):b=e[35],b}const dk=new Set;function uk(t){const e=tt.c(113),{node:n,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:m,rowKey:f,dragKey:p,renderExtras:y,pinnedSessionIds:x,expandedParents:k,hasSessionSearchQuery:w,normalizedSessionSearchQuery:h,notifyOnSubtasks:g,editingId:j,editingRowKey:b,setEditingId:S,setEditingRowKey:C,editTitle:v,setEditTitle:E,toggleParent:R,openSidebarMenuKey:A,setOpenSidebarMenuKey:O,allowReselect:B,onSessionSelected:T,resetSessionSearch:M,deleteSessionConfirm:L,setDeleteSessionConfirm:W,startFolderRename:$,startSessionWorktreeMenuLoad:P,onEditProject:D,mobileVariant:I,alwaysShowActions:X,renderChildren:Z}=t,ne=r===void 0?0:r,ue=d===void 0?!1:d,se=m===void 0?"project":m,xe=Z===void 0?!0:Z;Ts("ui.sidebar_tree_item.render");const ie=f??`${se}:${ue?"archived":"active"}:${n.session.id}`,Re=ss(pk),be=ss(hk),fe=Ne(mk),ke=Ne(fk);let H;if(e[0]!==n){H=[];const le=_e=>_e.children.forEach(Fe=>{H.push(Fe.session.id),le(Fe)});le(n),e[0]=n,e[1]=H}else H=e[1];const J=H.join(`
888
+ `);let ce;e[2]!==J?(ce=J?J.split(`
889
+ `):[],e[2]=J,e[3]=ce):ce=e[3];const je=ce;let G;e[4]!==Re||e[5]!==$||e[6]!==be?(G=(le,_e)=>{if(!le)return null;_e&&ss.getState().collapsedFolderIds.has(_e)&&be(_e);const Fe=Re(le,"New folder",_e);return $(le,Fe),Fe},e[4]=Re,e[5]=$,e[6]=be,e[7]=G):G=e[7];const we=G;let Te;e[8]!==B||e[9]!==L||e[10]!==je||e[11]!==v||e[12]!==j||e[13]!==ie||e[14]!==I||e[15]!==n.session.id||e[16]!==T||e[17]!==M||e[18]!==W||e[19]!==E||e[20]!==S||e[21]!==C||e[22]!==fe?(Te={mobileVariant:I,allowReselect:B,onSessionSelected:T,resetSessionSearch:M,descendantIds:je,showDeletionDialog:fe,setDeleteSessionConfirm:W,deleteSessionConfirm:L,editingId:j,setEditingId:S,setEditingRowKey:C,editingSessionId:n.session.id,editingOccurrenceKey:ie,editTitle:v,setEditTitle:E},e[8]=B,e[9]=L,e[10]=je,e[11]=v,e[12]=j,e[13]=ie,e[14]=I,e[15]=n.session.id,e[16]=T,e[17]=M,e[18]=W,e[19]=E,e[20]=S,e[21]=C,e[22]=fe,e[23]=Te):Te=e[23];const he=ak(Te),re=y?.childRenderExtrasFor,ge=n.session.directory??i;let q;e[24]!==ue||e[25]!==o||e[26]!==se||e[27]!==ge?(q={groupDirectory:ge,projectId:o,archivedBucket:ue,renderContext:se},e[24]=ue,e[25]=o,e[26]=se,e[27]=ge,e[28]=q):q=e[28];const z=q,ee=p??f??n.session.id,de=y?.subtreeContainsEditing??dk,Y=y?.menuOpenSessionId??null,U=y?.nodeStructureKey??"",F=y?.relativeTimeTick;let V;e[29]!==B||e[30]!==X||e[31]!==z||e[32]!==re||e[33]!==L||e[34]!==ne||e[35]!==v||e[36]!==j||e[37]!==b||e[38]!==k||e[39]!==l||e[40]!==w||e[41]!==I||e[42]!==n.children||e[43]!==h||e[44]!==g||e[45]!==T||e[46]!==A||e[47]!==x||e[48]!==xe||e[49]!==M||e[50]!==a||e[51]!==W||e[52]!==E||e[53]!==S||e[54]!==C||e[55]!==O||e[56]!==$||e[57]!==P||e[58]!==R?(V=xe?n.children.map(le=>s.jsx(Xo,{node:le,pinnedSessionIds:x,expandedParents:k,hasSessionSearchQuery:w,normalizedSessionSearchQuery:h,notifyOnSubtasks:g,editingId:j,editingRowKey:b,setEditingId:S,setEditingRowKey:C,editTitle:v,setEditTitle:E,toggleParent:R,openSidebarMenuKey:A,setOpenSidebarMenuKey:O,allowReselect:B,onSessionSelected:T,resetSessionSearch:M,deleteSessionConfirm:L,setDeleteSessionConfirm:W,startFolderRename:$,startSessionWorktreeMenuLoad:P,mobileVariant:I,alwaysShowActions:X,depth:ne+1,folderOwnerKey:l,selectionScopeKey:a,...z,renderExtras:re?.(le)},le.session.id)):null,e[29]=B,e[30]=X,e[31]=z,e[32]=re,e[33]=L,e[34]=ne,e[35]=v,e[36]=j,e[37]=b,e[38]=k,e[39]=l,e[40]=w,e[41]=I,e[42]=n.children,e[43]=h,e[44]=g,e[45]=T,e[46]=A,e[47]=x,e[48]=xe,e[49]=M,e[50]=a,e[51]=W,e[52]=E,e[53]=S,e[54]=C,e[55]=O,e[56]=$,e[57]=P,e[58]=R,e[59]=V):V=e[59];let oe;e[60]!==X||e[61]!==ue||e[62]!==we||e[63]!==ne||e[64]!==v||e[65]!==j||e[66]!==b||e[67]!==ie||e[68]!==k||e[69]!==l||e[70]!==i||e[71]!==w||e[72]!==I||e[73]!==n||e[74]!==h||e[75]!==g||e[76]!==D||e[77]!==A||e[78]!==x||e[79]!==o||e[80]!==se||e[81]!==u||e[82]!==a||e[83]!==he.handleCancelEdit||e[84]!==he.handleCopySessionId||e[85]!==he.handleDeleteSession||e[86]!==he.handleRestoreSession||e[87]!==he.handleSaveEdit||e[88]!==he.handleSessionDoubleClick||e[89]!==he.handleSessionSelect||e[90]!==E||e[91]!==S||e[92]!==C||e[93]!==O||e[94]!==P||e[95]!==ee||e[96]!==de||e[97]!==Y||e[98]!==U||e[99]!==F||e[100]!==V||e[101]!==R?(oe=s.jsx(ok,{expandedParents:k,hasSessionSearchQuery:w,normalizedSessionSearchQuery:h,notifyOnSubtasks:g,editingId:j,editingRowKey:b,setEditingId:S,setEditingRowKey:C,editTitle:v,setEditTitle:E,handleSaveEdit:he.handleSaveEdit,handleCancelEdit:he.handleCancelEdit,toggleParent:R,handleSessionSelect:he.handleSessionSelect,handleSessionDoubleClick:he.handleSessionDoubleClick,handleCopySessionId:he.handleCopySessionId,openSidebarMenuKey:A,setOpenSidebarMenuKey:O,createFolderAndStartRename:we,handleDeleteSession:he.handleDeleteSession,handleRestoreSession:he.handleRestoreSession,startSessionWorktreeMenuLoad:P,onEditProject:D,mobileVariant:I,alwaysShowActions:X,pinnedSessionIds:x,node:n,depth:ne,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:ue,secondaryMeta:u,renderContext:se,rowKey:ie,dragKey:ee,subtreeContainsEditing:de,menuOpenSessionId:Y,nodeStructureKey:U,relativeTimeTick:F,children:V}),e[60]=X,e[61]=ue,e[62]=we,e[63]=ne,e[64]=v,e[65]=j,e[66]=b,e[67]=ie,e[68]=k,e[69]=l,e[70]=i,e[71]=w,e[72]=I,e[73]=n,e[74]=h,e[75]=g,e[76]=D,e[77]=A,e[78]=x,e[79]=o,e[80]=se,e[81]=u,e[82]=a,e[83]=he.handleCancelEdit,e[84]=he.handleCopySessionId,e[85]=he.handleDeleteSession,e[86]=he.handleRestoreSession,e[87]=he.handleSaveEdit,e[88]=he.handleSessionDoubleClick,e[89]=he.handleSessionSelect,e[90]=E,e[91]=S,e[92]=C,e[93]=O,e[94]=P,e[95]=ee,e[96]=de,e[97]=Y,e[98]=U,e[99]=F,e[100]=V,e[101]=R,e[102]=oe):oe=e[102];let ae;e[103]!==L||e[104]!==n.session.id||e[105]!==he.confirmDeleteSession||e[106]!==W||e[107]!==ke||e[108]!==fe?(ae=L?.session.id===n.session.id?s.jsx(lk,{value:L,setValue:W,showDeletionDialog:fe,setShowDeletionDialog:ke,onConfirm:he.confirmDeleteSession}):null,e[103]=L,e[104]=n.session.id,e[105]=he.confirmDeleteSession,e[106]=W,e[107]=ke,e[108]=fe,e[109]=ae):ae=e[109];let pe;return e[110]!==oe||e[111]!==ae?(pe=s.jsxs(s.Fragment,{children:[oe,ae]}),e[110]=oe,e[111]=ae,e[112]=pe):pe=e[112],pe}function fk(t){return t.setShowDeletionDialog}function mk(t){return t.showDeletionDialog}function hk(t){return t.toggleFolderCollapse}function pk(t){return t.createFolder}const gk=(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&&Jd(t.session,e.session)&&xt(t.worktree?.path??null)===xt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,xk=(t,e)=>{if(t.node!==e.node&&!gk(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 n=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(n)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(n)??!1)||(t.secondaryMeta?.projectLabel??null)!==(e.secondaryMeta?.projectLabel??null)||(t.secondaryMeta?.branchLabel??null)!==(e.secondaryMeta?.branchLabel??null))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","onEditProject","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const i of r)if(t[i]!==e[i])return!1;return!0},Xo=c.memo(uk,xk),bk=24,yk=t=>Array.from({length:Math.min(t,bk)},(e,n)=>n),wk=(t,e,n)=>{const r=new Set(t);for(const i of e)i>=0&&i<n&&r.add(i);return[...r].sort((i,o)=>i-o)},vk=(t,e)=>t.find(n=>n.end>e)?.index??0;function td(t,e){return e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0}function Sk({model:t,scrollElement:e,pinnedRowIndexes:n,renderRow:r,onFirstVisibleIndexChange:i}){const o=t.rows,l=c.useCallback(()=>e,[e]),a=c.useCallback(w=>o[w]?.estimateSize??32,[o]),d=c.useCallback(w=>o[w]?.key??w,[o]),u=c.useCallback(w=>wk(ub(w),n,o.length),[n,o.length]),m=db({count:o.length,enabled:e!==null,getScrollElement:l,estimateSize:a,getItemKey:d,overscan:8,rangeExtractor:u}),f=m.getVirtualItems(),p=e?m.getTotalSize():0,y=e?Math.max(p-e.clientHeight,0):0,x=e?Math.min(e.scrollTop,y):0,k=vk(f,x);if(c.useLayoutEffect(()=>{i(k)},[k,i]),!e){const w=yk(o.length),h=w.reduce((j,b)=>j+(o[b]?.estimateSize??0),0),g=o.reduce((j,b)=>j+b.estimateSize,0);return s.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[w.map(j=>{const b=o[j];return b?s.jsx("div",{className:td(b,o[j+1]),children:r(b,j)},b.key):null}),g>h?s.jsx("div",{"aria-hidden":"true",style:{height:g-h}}):null]})}return s.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:p,position:"relative"},children:f.map(w=>{const h=o[w.index];return h?s.jsx("div",{className:`[&_[data-session-row]]:my-px ${td(h,o[w.index+1])??""}`,"data-index":w.index,"data-sidebar-virtual-start":w.start,ref:m.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${w.start}px)`},children:r(h,w.index)},h.key):null})})}const jk={chats:"chat-4","active-now":"history",timeline:"folder"},sd={chats:"sessions.sidebar.activity.chatsTitle","active-now":"sessions.sidebar.activity.recentTitle",timeline:"sessions.sidebar.activity.timelineTitle"},kk=t=>{const e=tt.c(48),{activityKey:n,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:l,onNewChat:a,timelineView:d}=t,u=d===void 0?!1:d,{t:m}=Nt(),f=n==="chats";if(u){const B=i?void 0:l;let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=Ee("group flex w-full items-center gap-1 py-2 pl-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","pr-3.5"),e[0]=T):T=e[0];const M=!r,L=sd[n];let W;e[1]!==m||e[2]!==L?(W=m(L),e[1]=m,e[2]=L,e[3]=W):W=e[3];let $;e[4]!==W?($=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:W}),e[4]=W,e[5]=$):$=e[5];let P;e[6]!==r||e[7]!==i?(P=i?null:s.jsx(_,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5 text-muted-foreground"}),e[6]=r,e[7]=i,e[8]=P):P=e[8];let D;return e[9]!==i||e[10]!==B||e[11]!==M||e[12]!==$||e[13]!==P?(D=s.jsx("div",{className:"relative group/chats -mr-2",children:s.jsxs("button",{type:"button",onClick:B,disabled:i,className:T,"aria-expanded":M,children:[$,P]})}),e[9]=i,e[10]=B,e[11]=M,e[12]=$,e[13]=P,e[14]=D):D=e[14],D}const p=i?void 0:l,y=f?"pr-10":"pr-3.5";let x;e[15]!==y?(x=Ee("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",y),e[15]=y,e[16]=x):x=e[16];const k=!r,w=jk[n],h=!i&&"group-hover:hidden";let g;e[17]!==h?(g=Ee("h-3.5 w-3.5 text-muted-foreground/80",h),e[17]=h,e[18]=g):g=e[18];let j;e[19]!==w||e[20]!==g?(j=s.jsx(_,{name:w,className:g}),e[19]=w,e[20]=g,e[21]=j):j=e[21];let b;e[22]!==r||e[23]!==i?(b=i?null:s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:s.jsx(_,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[22]=r,e[23]=i,e[24]=b):b=e[24];let S;e[25]!==b||e[26]!==j?(S=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[j,b]}),e[25]=b,e[26]=j,e[27]=S):S=e[27];const C=sd[n];let v;e[28]!==m||e[29]!==C?(v=m(C),e[28]=m,e[29]=C,e[30]=v):v=e[30];let E;e[31]!==v?(E=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:v}),e[31]=v,e[32]=E):E=e[32];let R;e[33]!==i||e[34]!==S||e[35]!==E||e[36]!==p||e[37]!==x||e[38]!==k?(R=s.jsxs("button",{type:"button",onClick:p,disabled:i,className:x,"aria-expanded":k,children:[S,E]}),e[33]=i,e[34]=S,e[35]=E,e[36]=p,e[37]=x,e[38]=k,e[39]=R):R=e[39];let A;e[40]!==o||e[41]!==f||e[42]!==a||e[43]!==m?(A=f?s.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),a()},className:Ee("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o?"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":m("sessions.sidebar.header.actions.newSession"),children:s.jsx(_,{name:"add",className:"h-4 w-4"})}):null,e[40]=o,e[41]=f,e[42]=a,e[43]=m,e[44]=A):A=e[44];let O;return e[45]!==R||e[46]!==A?(O=s.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[R,A]}),e[45]=R,e[46]=A,e[47]=O):O=e[47],O},Ck=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return(e.mainWorkspaceOnly?[n,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===n.id:o.isMain}))},Nk=[],Ak=32,Pk=64,Dk=3,Ik=7,ko=32,Hn=28,nd=(t,e,n,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return Xa(t.session,e.session,n,Ha)},zi=t=>{const e=new Map,n=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),n.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),i.set(l.node,[d,d+1]),o.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const m=l.node.children[u];m&&o.push({node:m,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},Tk=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,Ek=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},Rk=t=>{const e=[],n=[],r=[],i=[],o=[],l=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds);let m=0;const p=[...[...t.authoritativeSections.flatMap(S=>S.groups.flatMap(C=>C.sessions)),...t.chatGroup?.sessions??[]]];for(;p.length>0;){const S=p.pop();S&&(l.set(S.session.id,S.session),p.push(...S.children))}const y=S=>{const C=a.get(S)??0;return a.set(S,C+1),C===0?S:`${S}:${C}`},x=S=>{e.push(Object.freeze(S))},k=S=>{const C=[...S.nodes].reverse().map(v=>({node:v,depth:0,directory:S.groupDirectory}));for(;C.length>0;){const v=C.pop();if(!v)continue;const E=y(`${S.containerKey}:session:${v.node.session.id}`),R=v.node.session.directory??v.directory;l.set(v.node.session.id,v.node.session),x({kind:"session",key:E,estimateSize:S.renderContext==="timeline"?Pk:Ak,node:v.node,depth:v.depth,projectId:S.projectId,groupDirectory:v.directory,ownerKey:S.ownerKey,selectionScopeKey:S.selectionScopeKey,archived:S.archived,renderContext:S.renderContext,secondaryMeta:S.getSecondaryMeta?S.getSecondaryMeta(v.node.session.id):S.secondaryMeta??null});const A=S.indexedNodes?.subtreeRangeByNode.get(v.node),O=A&&A[1]>A[0]+1?Object.freeze([(S.selectionPoolOffset??0)+A[0]+1,(S.selectionPoolOffset??0)+A[1]]):void 0;if(n.push(Object.freeze({id:v.node.session.id,rowKey:E,scopeKey:S.selectionScopeKey,archived:S.archived,descendantRange:O})),!(!d&&!t.expandedParents.has(Tk(S.renderContext,S.archived,v.node.session.id))))for(let B=v.node.children.length-1;B>=0;B-=1){const T=v.node.children[B];T&&C.push({node:T,depth:v.depth+1,directory:R})}}},w=(S,C,v,E,R)=>{const A=t.groupSearchDataByGroup.get(S);if(d&&A?.hasMatch!==!0)return;d&&A&&(m+=A.matchedSessionCount+A.folderNameMatchCount+(A.groupMatches?1:0));const O=[...d?A?.filteredNodes??[]:S.sessions].sort((re,ge)=>nd(re,ge,u,t.sessionOrderIndex)),B=zi(O),T=r.length;r.push(...B.preorderIds);for(const[re,ge]of B.sessionsById)l.set(re,ge);const M=Zn(v,S.directory),L=!d&&t.collapsedGroups.has(C);if(!E){const re=B.preorderIds.flatMap(ge=>B.sessionsById.get(ge)??[]);x({kind:"group-header",key:`${C}:header`,estimateSize:ko,group:S,groupKey:C,projectId:v,collapsed:L,forceExpanded:d,allSessions:Object.freeze(re)})}if(L)return;const W=Jr(S).flatMap(({scopeKey:re,directory:ge})=>(t.foldersMap[re]??Nk).map(q=>({folder:q,scopeKey:re,scopeDirectory:ge,ownerKey:M,nodes:Ca(q.sessionIds,B.byId).sort((z,ee)=>nd(z,ee,u,t.sessionOrderIndex))}))),$=Gf(W.map(re=>({id:re.folder.id,name:re.folder.name,parentId:re.folder.parentId,nodeCount:re.nodes.length})),{archivedBucket:S.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),P=W.filter(re=>$.has(re.folder.id)),D=new Map(P.map(re=>[Yn(re.scopeKey,re.folder.id),re])),I=new Map;for(const re of P){if(!re.folder.parentId)continue;const ge=Yn(re.scopeKey,re.folder.parentId),q=I.get(ge)??[];q.push(re),I.set(ge,q)}const X=Hf(P.map(re=>({...re.folder,scopeKey:re.scopeKey}))).map(re=>D.get(Yn(re.scopeKey??"",re.id))).filter(re=>!!re),Z=new Set(P.flatMap(re=>re.folder.sessionIds)),ne=O.filter(re=>!Z.has(re.session.id)),ue=new Map,se=X.map(re=>({folder:re,visited:!1})),xe=new Set;for(;se.length>0;){const re=se.pop();if(!re)continue;const ge=Yn(re.folder.scopeKey,re.folder.folder.id);if(!re.visited){if(xe.has(ge))continue;xe.add(ge),se.push({folder:re.folder,visited:!0});for(const z of I.get(ge)??[])se.push({folder:z,visited:!1});continue}const q=re.folder.nodes.flatMap(z=>{const ee=B.subtreeRangeByNode.get(z);return ee?B.preorderIds.slice(ee[0],ee[1]).flatMap(de=>B.sessionsById.get(de)??[]):[z.session]});for(const z of I.get(ge)??[])q.push(...ue.get(Yn(z.scopeKey,z.folder.id))??[]);ue.set(ge,Object.freeze(q))}const ie=new Set,Re=(re,ge)=>{const q=Yn(re.scopeKey,re.folder.id);if(ie.has(q))return;ie.add(q);const z=ge?`${ge} / ${re.folder.name}`:re.folder.name,ee=`${C}:folder:${q}`,de=!d&&t.collapsedFolders.has(re.folder.id),Y=ue.get(q)??[],U=de&&!S.isArchivedBucket?Ca([...new Set(Y.map(oe=>oe.id))],B.byId):[],F=M?t.folderAuthorityByOwner.get(M):void 0,V=!!M&&!S.isArchivedBucket&&!ll(re.scopeKey)&&F?.complete===!0&&F.scopeKeys.includes(re.scopeKey);if(x({kind:"folder-header",key:ee,estimateSize:ko,group:S,folder:re.folder,displayName:z,scopeKey:re.scopeKey,scopeDirectory:re.scopeDirectory,ownerKey:M,nodes:re.nodes,activityNodes:U,projectId:v,archived:S.isArchivedBucket===!0,collapsed:de,forceExpanded:d,deleteSessions:Y,subFolderCount:I.get(q)?.length??0,dropEnabled:V}),M&&o.push(Object.freeze({rowKey:ee,scopeKey:re.scopeKey,folderId:re.folder.id,ownerKey:M,enabled:V})),!de){k({nodes:re.nodes,containerKey:ee,projectId:v,groupDirectory:re.scopeDirectory??S.directory,ownerKey:M,selectionScopeKey:M,archived:S.isArchivedBucket===!0,renderContext:"project",indexedNodes:B,selectionPoolOffset:T});for(const oe of I.get(q)??[])Re(oe,z)}};for(const re of X)Re(re,"");const be=v?t.sessionBatchSize:void 0,fe=R?.initial??be??(t.hideDirectoryControls?10:5),ke=R?.increment??be??7,H=Math.max(fe,t.visibleCountByContainer.get(C)??fe),J=re=>R?.pinnedAlwaysVisible===!0&&zu(u,re.session.directory??S.directory,re.session.id),ce=ne.filter(re=>!J(re));let je=H;const G=S.isArchivedBucket||d?ne:ne.filter(re=>J(re)?!0:je<=0?!1:(je-=1,!0));k({nodes:G,containerKey:C,projectId:v,groupDirectory:S.directory,ownerKey:M,selectionScopeKey:M,archived:S.isArchivedBucket===!0,renderContext:R?.renderContext??"project",indexedNodes:B,selectionPoolOffset:T});const we=ne.length-G.length,Te=H-je;!d&&!S.isArchivedBucket&&we>0?x({kind:"show-control",key:`${C}:more`,estimateSize:Hn,control:"more",containerKey:C,currentCount:Te,increment:ke}):!d&&!S.isArchivedBucket&&ce.length>fe&&we===0&&x({kind:"show-control",key:`${C}:fewer`,estimateSize:Hn,control:"fewer",containerKey:C,currentCount:Te,increment:ke});const he=t.groupStatusByKey.get(C);O.length===0&&P.length===0?he&&he.state!=="ready"?x({kind:"status",key:`${C}:status`,estimateSize:Hn,status:he,group:S,groupKey:C}):x({kind:"empty",key:`${C}:empty`,estimateSize:Hn,emptyKind:S.isArchivedBucket?"archived":"group",group:S,projectId:v}):he&&he.state!=="ready"&&he.state!=="loading"&&x({kind:"status",key:`${C}:status`,estimateSize:Hn,status:he,group:S,groupKey:C})},h=S=>{const C=!d&&t.collapsedActivities.has(S),v=e.length;return x({kind:"activity-header",key:`activity:${S}:header`,estimateSize:ko,activityKey:S,collapsed:C,forceExpanded:d}),i.push(Object.freeze({rowIndex:v,kind:"activity",id:S})),C},g=t.viewMode==="timeline";if(t.chatGroup){const S=t.groupSearchDataByGroup.get(t.chatGroup);(!d||S?.hasMatch===!0)&&(h("chats")||w(t.chatGroup,"activity:chats",null,!0,g?{initial:Dk,increment:Ik,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0))}if(g){const S=t.timelineItems??[];if(S.length>0&&!h("timeline")){const v="activity:timeline";for(const E of S){const R=zi([E.node]),A=r.length;r.push(...R.preorderIds);const O=Zn(E.projectId,E.groupDirectory);k({nodes:[E.node],containerKey:v,projectId:E.projectId,groupDirectory:E.groupDirectory,ownerKey:O,selectionScopeKey:null,archived:!1,renderContext:"timeline",secondaryMeta:E.secondaryMeta,indexedNodes:R,selectionPoolOffset:A}),d&&(m+=1)}}}if(!g&&t.showRecentSection)for(const S of t.recentSections){if(S.items.length===0||h("active-now"))continue;const v=`activity:${S.key}`,E=7,R=Math.max(E,t.visibleCountByContainer.get(v)??E),A=d?S.items:S.items.slice(0,R);for(const B of A){const T=zi([B.node]),M=r.length;r.push(...T.preorderIds),k({nodes:[B.node],containerKey:v,projectId:B.projectId,groupDirectory:B.groupDirectory,ownerKey:Zn(B.projectId,B.groupDirectory),selectionScopeKey:Zn(B.projectId,B.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:B.secondaryMeta,getSecondaryMeta:B.getSecondaryMeta,indexedNodes:T,selectionPoolOffset:M}),d&&(m+=1)}const O=S.items.length-A.length;!d&&O>0?x({kind:"show-control",key:`${v}:more`,estimateSize:Hn,control:"more",containerKey:v,currentCount:A.length,increment:7}):!d&&S.items.length>E&&x({kind:"show-control",key:`${v}:fewer`,estimateSize:Hn,control:"fewer",containerKey:v,currentCount:A.length,increment:7})}let j=g?[]:t.singleProjectMode?t.sections.filter(S=>S.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const S=j.find(C=>C.project.id===t.activeProjectId)??j[0];j=S?[S]:[]}for(const S of j){const C=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(S.project.id);if(!t.showOnlyMainWorkspace){const E=e.length;x({kind:"project-header",key:`project:${S.project.id}:header`,estimateSize:ko,section:S,collapsed:C,forceExpanded:d}),i.push(Object.freeze({rowIndex:E,kind:"project",id:S.project.id}))}if(C)continue;const v=Ck(S,{mainWorkspaceOnly:t.showOnlyMainWorkspace});for(const E of v)w(E.group,E.groupKey,E.projectId,E.hideGroupLabel)}e.length===0&&x({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const b=new Map;return e.forEach((S,C)=>b.set(S.key,C)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:b,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?m:0})},tm=c.createContext(null);function rd(t){let e=0,n=t;for(;n;){e+=n.offsetTop;const o=n.offsetParent;n=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function Mk(t){const e=tt.c(14),{enabled:n,suspended:r,layoutKey:i,scrollRef:o,children:l}=t,a=r===void 0?!1:r,d=i===void 0?"":i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const m=c.useRef(u),f=c.useRef(null);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=g=>(m.current.add(g),f.current?.(),()=>{m.current.delete(g),f.current?.()}),e[1]=p):p=e[1];const y=p;let x;e[2]!==n||e[3]!==o||e[4]!==a?(x=()=>{const g=o.current;if(!n||a||!g)return;const j=document.createElement("div");j.dataset.sidebarCrossfadeLayer="true",j.className="pointer-events-none sticky top-0 z-30 h-0",j.style.marginBlock="0px",g.prepend(j);let b=null,S=null,C=null,v=0;const E=new Set;let R=[];const A=window.matchMedia("(prefers-reduced-motion: reduce)"),O=Bk,B=()=>{C?.cancel(),C=null,S?.remove(),S=null},T=()=>{let P=null,D=-1/0;for(const{entry:I,top:X}of R)X<=g.scrollTop&&X>=D&&(D=X,P=I);if(b!==P){if(B(),b&&P&&!A.matches){const I=b.host.cloneNode(!0);I instanceof HTMLElement&&(I.inert=!0,I.setAttribute("aria-hidden","true"),I.querySelectorAll("[id]").forEach(Ok),I.className="pointer-events-none absolute inset-x-0 top-0 z-30",S=I)}b&&(O(b,b.slot),b.slot.style.removeProperty("height")),b=P,j.hidden=!P,P&&(P.slot.style.height=`${P.host.getBoundingClientRect().height}px`,O(P,j),S&&(j.append(S),C=S.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),C.onfinish=B))}},M=()=>{b&&(b.slot.style.height=`${b.host.getBoundingClientRect().height}px`);const P=rd(g)+g.clientTop;R=Array.from(m.current,D=>({entry:D,top:rd(D.slot)-P})),T()},L=new ResizeObserver(M),W=new MutationObserver(()=>{cancelAnimationFrame(v),v=requestAnimationFrame(M)});L.observe(g);const $=()=>{W.disconnect();for(const P of E)m.current.has(P)||(L.unobserve(P.host),P.slot.parentElement&&L.unobserve(P.slot.parentElement),E.delete(P));for(const P of m.current){const D=P.slot.closest("[data-sidebar-virtual-start]");D&&W.observe(D,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),E.has(P)||(L.observe(P.host),P.slot.parentElement&&L.observe(P.slot.parentElement),E.add(P))}cancelAnimationFrame(v),v=requestAnimationFrame(M)};return f.current=$,g.addEventListener("scroll",T,{passive:!0}),$(),M(),()=>{f.current=null,cancelAnimationFrame(v),g.removeEventListener("scroll",T),L.disconnect(),W.disconnect(),B(),j.hidden=!0,b&&(O(b,b.slot),b.slot.style.removeProperty("height")),j.remove()}},e[2]=n,e[3]=o,e[4]=a,e[5]=x):x=e[5];let k;e[6]!==n||e[7]!==d||e[8]!==o||e[9]!==a?(k=[n,a,d,o],e[6]=n,e[7]=d,e[8]=o,e[9]=a,e[10]=k):k=e[10],c.useLayoutEffect(x,k);const w=n?y:null;let h;return e[11]!==l||e[12]!==w?(h=s.jsx(tm.Provider,{value:w,children:l}),e[11]=l,e[12]=w,e[13]=h):h=e[13],h}function Ok(t){return t.removeAttribute("id")}function Bk(t,e){const n=document.activeElement,r=n instanceof HTMLElement&&t.host.contains(n);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&n.focus({preventScroll:!0})}function Fk(t){const e=tt.c(15);let n,r;e[0]!==t?({register:r,...n}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const i=c.useRef(null),[o]=c.useState(_k);let l,a;e[3]!==o||e[4]!==r?(l=()=>{const p=i.current;if(!p)return;p.append(o);const y=r({slot:p,host:o});return()=>{y(),o.remove()}},a=[o,r],e[3]=o,e[4]=r,e[5]=l,e[6]=a):(l=e[5],a=e[6]),c.useLayoutEffect(l,a);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("div",{ref:i}),e[7]=d):d=e[7];let u;e[8]!==n?(u=s.jsx("div",{...n}),e[8]=n,e[9]=u):u=e[9];let m;e[10]!==o||e[11]!==u?(m=Om.createPortal(u,o),e[10]=o,e[11]=u,e[12]=m):m=e[12];let f;return e[13]!==m?(f=s.jsxs(s.Fragment,{children:[d,m]}),e[13]=m,e[14]=f):f=e[14],f}function _k(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function sm(t){const e=tt.c(3),n=c.useContext(tm);let r;return e[0]!==t||e[1]!==n?(r=n?s.jsx(Fk,{...t,register:n}):s.jsx("div",{...t}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const Wi=t=>{const e=tt.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,m=u===void 0?!1:u,{currentTheme:f}=Ln(),p=i?ni[i]:null,y=o?ri[o]??null:null,x=d!==void 0,k=x?m?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let w;e[0]!==m||e[1]!==x||e[2]!==d?(w=x?s.jsx("span",{className:Ee("h-3.5 w-3.5 items-center justify-center text-muted-foreground",m?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(_,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=m,e[1]=x,e[2]=d,e[3]=w):w=e[3];let h;e[4]!==m||e[5]!==f||e[6]!==x||e[7]!==y||e[8]!==k||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==p?(h=l?s.jsx("span",{className:Ee("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",x&&m?"hidden":"inline-flex",k),style:a?{backgroundColor:a}:void 0,children:s.jsx(oi,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:p?s.jsx(_,{name:p,className:"h-3.5 w-3.5",style:y?{color:y}:void 0}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:y?{color:y}:void 0})})}):p?s.jsx(_,{name:p,className:Ee("h-3.5 w-3.5",k),style:y?{color:y}:void 0}):s.jsx(_,{name:"folder",className:Ee("h-3.5 w-3.5 text-muted-foreground/80",k),style:y?{color:y}:void 0}),e[4]=m,e[5]=f,e[6]=x,e[7]=y,e[8]=k,e[9]=n,e[10]=a,e[11]=l,e[12]=p,e[13]=h):h=e[13];let g;e[14]!==w||e[15]!==h?(g=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[w,h]}),e[14]=w,e[15]=h,e[16]=g):g=e[16];let j;e[17]!==r?(j=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=j):j=e[18];let b;return e[19]!==g||e[20]!==j?(b=s.jsxs(s.Fragment,{children:[g,j]}),e[19]=g,e[20]=j,e[21]=b):b=e[21],b},Lk=t=>{const e=tt.c(60),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m,isCollapsed:f,isRepo:p,hideDirectoryControls:y,alwaysShowActions:x,onToggle:k,onNewSession:w,onNewWorktreeSession:h,onManageWorktrees:g,onRenameStart:j,onClose:b,children:S,showCreateButtons:C,hideHeader:v,statusIndicator:E,openSidebarMenuKey:R,setOpenSidebarMenuKey:A,projectPickerOptions:O,onProjectSelect:B}=t,T=r===void 0?!1:r,M=C===void 0?!0:C,L=v===void 0?!1:v,W=E===void 0?null:E,{t:$}=Nt();let P;e[0]!==T||e[1]!==n?(P={id:n,disabled:T},e[0]=T,e[1]=n,e[2]=P):P=e[2];const{attributes:D,listeners:I,setNodeRef:X,transform:Z,transition:ne,isDragging:ue}=mi(P),se=c.useRef(!1),xe=`project:${n}`,ie=R===xe,[Re,be]=c.useState(!1),fe=!!(O&&B);let ke;e[3]!==xe||e[4]!==A?(ke=F=>{F&&be(!1),A(F?xe:null)},e[3]=xe,e[4]=A,e[5]=ke):ke=e[5];const H=ke;let J;e[6]!==y||e[7]!==p||e[8]!==b||e[9]!==g||e[10]!==w||e[11]!==j||e[12]!==M||e[13]!==$?(J=F=>s.jsxs(s.Fragment,{children:[M&&!p&&!y&&w&&s.jsxs(F,{onClick:w,children:[s.jsx(_,{name:"add",className:"mr-1.5 h-4 w-4"}),$("sessions.sidebar.project.actions.newSession")]}),p&&!y&&g&&s.jsxs(F,{onClick:g,children:[s.jsx(_,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),$("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(F,{onClick:j,children:[s.jsx(_,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),$("sessions.sidebar.project.actions.edit")]}),s.jsxs(F,{onClick:b,className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"close",className:"mr-1.5 h-4 w-4"}),$("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=y,e[7]=p,e[8]=b,e[9]=g,e[10]=w,e[11]=j,e[12]=M,e[13]=$,e[14]=J):J=e[14];const ce=J,je=Wk,G=Kk,we=Vk;let Te;e[15]===Symbol.for("react.memo_cache_sentinel")?(Te=F=>{(F.button===2||F.button===0&&F.ctrlKey)&&(se.current=!0)},e[15]=Te):Te=e[15];const he=Te;let re;e[16]!==k?(re=F=>{if(F.currentTarget.blur(),se.current){se.current=!1;return}k()},e[16]=k,e[17]=re):re=e[17];const ge=re;let q;e[18]!==Z?(q=hi.Transform.toString(Z),e[18]=Z,e[19]=q):q=e[19];let z;e[20]!==q||e[21]!==ne?(z={transform:q,transition:ne},e[20]=q,e[21]=ne,e[22]=z):z=e[22];const ee=ue&&"opacity-30";let de;e[23]!==ee?(de=Ee("relative",ee),e[23]=ee,e[24]=de):de=e[24];let Y;e[25]!==x||e[26]!==D||e[27]!==H||e[28]!==ge||e[29]!==y||e[30]!==L||e[31]!==n||e[32]!==f||e[33]!==Re||e[34]!==ie||e[35]!==fe||e[36]!==p||e[37]!==I||e[38]!==w||e[39]!==h||e[40]!==B||e[41]!==d||e[42]!==o||e[43]!==l||e[44]!==a||e[45]!==m||e[46]!==u||e[47]!==i||e[48]!==O||e[49]!==ce||e[50]!==M||e[51]!==W||e[52]!==$?(Y=L?null:s.jsx(s.Fragment,{children:s.jsxs(Yd,{open:Re,onOpenChange:be,children:[s.jsx(qd,{render:s.jsx(sm,{className:Ee("-ml-2.5 -mr-2 text-left group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:F=>{y||(F.preventDefault(),be(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...D,children:[fe?s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsxs("button",{type:"button",className:Ee("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-[padding]",p&&!y?x||ie?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":x||ie?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":$("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(Wi,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m}),s.jsx(_,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(Zr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(_s,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:O?.map(F=>s.jsxs(Ht,{onClick:()=>B?.(F.id),className:"flex items-center justify-between gap-3",title:F.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(Wi,{...F})}),F.id===n?s.jsx(_,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},F.id))})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:he,onClick:ge,...I,className:Ee("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing transition-[padding]",p&&!y?x||ie?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":x||ie?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(Wi,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m,isCollapsed:f,alwaysShowActions:x}),W?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:W}):null,l?s.jsx(Zr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(jt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Ee("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",M?"right-7":"right-0.5"),children:[M&&p&&!y&&h?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),h()},className:Ee("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",x?"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":$("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(_,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:$("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,y?null:s.jsxs(Ls,{open:ie,onOpenChange:H,children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee("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",ie?"opacity-100 pointer-events-auto":x?"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":$("sessions.sidebar.project.actions.projectMenu"),onPointerDown:G,onMouseDown:we,onClick:je,children:s.jsx(_,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(_s,{align:"end",className:"min-w-[180px]",children:ce(Ht)})]})]}),M&&w?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),w()},className:Ee("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",x?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":$(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(_,{name:"add",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:$(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(Gd,{className:"min-w-[180px]",children:ce(Xn)})]})}),e[25]=x,e[26]=D,e[27]=H,e[28]=ge,e[29]=y,e[30]=L,e[31]=n,e[32]=f,e[33]=Re,e[34]=ie,e[35]=fe,e[36]=p,e[37]=I,e[38]=w,e[39]=h,e[40]=B,e[41]=d,e[42]=o,e[43]=l,e[44]=a,e[45]=m,e[46]=u,e[47]=i,e[48]=O,e[49]=ce,e[50]=M,e[51]=W,e[52]=$,e[53]=Y):Y=e[53];let U;return e[54]!==S||e[55]!==X||e[56]!==z||e[57]!==de||e[58]!==Y?(U=s.jsxs("div",{ref:X,style:z,className:de,children:[Y,S]}),e[54]=S,e[55]=X,e[56]=z,e[57]=de,e[58]=Y,e[59]=U):U=e[59],U},$k=t=>{const e=tt.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:m,transition:f,isDragging:p}=mi(l);let y;e[3]!==a||e[4]!==u?(y={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=y):y=e[5];const x=y;let k;e[6]!==m?(k=hi.Transform.toString(m),e[6]=m,e[7]=k):k=e[7];let w;e[8]!==k||e[9]!==f?(w={transform:k,transition:f},e[8]=k,e[9]=f,e[10]=w):w=e[10];const h=p&&"opacity-50";let g;e[11]!==h?(g=Ee("space-y-0.5 rounded-md",h),e[11]=h,e[12]=g):g=e[12];let j;e[13]!==i||e[14]!==x?(j=i(x),e[13]=i,e[14]=x,e[15]=j):j=e[15];let b;return e[16]!==d||e[17]!==w||e[18]!==g||e[19]!==j?(b=s.jsx("div",{ref:d,style:w,className:g,children:j}),e[16]=d,e[17]=w,e[18]=g,e[19]=j,e[20]=b):b=e[20],b},zk=c.memo($k);function Wk(t){t.stopPropagation()}function Kk(t){t.stopPropagation()}function Vk(t){t.stopPropagation()}const od=[],Uk=t=>{const e=tt.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=cl(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Ki=(t,e)=>e?t.sessions.some(n=>kr(n,e)):!1,Hk=(t,e,n)=>t.sessions.some(r=>qf(r,r,e,n,t.directory,t.directory)),Gk=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},qk=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},Yk=(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&&Hk(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&Gk(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&qk(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Ki(e.group,t.editingId)||Ki(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Ki(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Yo(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Yo(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??xt(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.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};function Qk(t){const{t:e}=Nt(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,renderBody:l=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,groupSearchDataByGroup:u,visibleSessionCount:m,sessionBatchSize:f,collapsedGroups:p,hideDirectoryControls:y,showMoreGroupSessions:x,resetGroupSessionLimit:k,mobileVariant:w,alwaysShowActions:h,activeProjectId:g,setActiveProjectIdOnly:j,setSessionSwitcherOpen:b,openNewSessionDraft:S,pinnedSessionIds:C,sessionOrderIndex:v,notifyOnSubtasks:E,onToggleCollapsedGroup:R,dragHandleProps:A,compactBodyPadding:O=!1,expandedParents:B,editingId:T,editingRowKey:M,openSidebarMenuKey:L,editTitle:W,folderRename:$,setFolderRenameDraft:P,clearFolderRename:D}=t,I=ss(ve=>ve.toggleFolderCollapse),X=ss(ve=>ve.renameFolder),Z=ss(ve=>ve.deleteFolder),ne=ss(ve=>ve.addSessionToFolder),ue=Ne(ve=>ve.showDeletionDialog),[se,xe]=c.useState(null),ie=c.useCallback((ve,Qe)=>{const qe=v.get(ve.session.id),Ye=v.get(Qe.session.id);if(qe!==void 0||Ye!==void 0){if(qe===void 0)return 1;if(Ye===void 0)return-1;if(qe!==Ye)return qe-Ye}return Xa(ve.session,Qe.session,C,Ha)},[C,v]),Re=a?u.get(n):null,be=a?!1:p.has(r),fe=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const ve=xt(n.directory??null),Qe=n.branch?.trim();return ve&&Qe?ei(ve,Qe):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),ke=_u(fe),H=ke?`var(--pr-${ke.visualState})`:void 0,J=ii(),ce=c.useMemo(()=>{const ve=n.folderScopes?.map(Qe=>xt(Qe.directory))??[xt(n.directory??null)];return[...new Set(ve.filter(Qe=>!!Qe))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(ve=>ce.length>0?J.subscribeBootstrap(ve):()=>{},[ce.length,J]),c.useCallback(()=>ce.map(ve=>`${ve}\0${J.getBootstrapState(ve)??""}\0${J.getBootstrapFailure(ve)??""}\0${J.getInitializationState(ve)??""}\0${J.getInitializationFailure(ve)??""}`).join(""),[ce,J]),c.useCallback(()=>"",[]));const je=ce.some(ve=>{const Qe=J.getBootstrapState(ve);return Qe==="queued"||Qe==="running"}),G=ce.find(ve=>J.getBootstrapState(ve)==="failed"||J.getInitializationState(ve)==="failed")??null,we=G!==null&&J.getBootstrapState(G)==="failed",Te=G?we?J.getBootstrapFailure(G):J.getInitializationFailure(G):void 0,he=Te==="os-permission"&&Wd(),[re,ge]=c.useState(!1),q=c.useCallback(()=>{G&&J.requestBootstrap({directory:G,priority:be?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[J,G,n.isMain,be]),z=c.useCallback(async()=>{if(!(!G||!he||re)){ge(!0);try{(await Kd(G)).success&&q()}finally{ge(!1)}}},[he,G,re,q]),ee=f??(y?10:5),de=Math.max(ee,m??ee),Y=a?Re?.groupMatches===!0:!1,U=a,F=c.useMemo(()=>[...U?Re?.filteredNodes??[]:n.sessions].sort(ie),[ie,n.sessions,Re?.filteredNodes,U]),V=n.folderScopeKey??xt(n.directory??null),oe=Zn(i,n.directory),ae=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:V?[{scopeKey:V,directory:n.directory??null}]:[],[V,n.directory,n.folderScopes]),pe=ss(ar(c.useCallback(ve=>ae.map(({scopeKey:Qe})=>ve.foldersMap[Qe]??od),[ae]))),le=c.useMemo(()=>ae.flatMap(({scopeKey:ve,directory:Qe},qe)=>(pe[qe]??od).map(dt=>({folder:dt,scopeKey:ve,scopeDirectory:Qe}))),[pe,ae]),_e=ss(ar(c.useCallback(ve=>new Set(pe.flatMap(Qe=>Qe.filter(qe=>ve.collapsedFolderIds.has(qe.id)).map(qe=>qe.id))),[pe]))),Fe=c.useMemo(()=>{const ve=new Map,Qe=qe=>{qe.forEach(Ye=>{ve.set(Ye.session.id,Ye),Ye.children.length>0&&Qe(Ye.children)})};return Qe(F),ve},[F]),Me=c.useMemo(()=>le.map(({folder:ve,scopeKey:Qe,scopeDirectory:qe})=>{const Ye=Ca(ve.sessionIds,Fe).sort(ie);return{folder:ve,scopeKey:Qe,scopeDirectory:qe,nodes:Ye}}),[le,Fe,ie]),Ae=c.useMemo(()=>{const ve=Gf(Me.map(({folder:Qe,nodes:qe})=>({id:Qe.id,name:Qe.name,parentId:Qe.parentId,nodeCount:qe.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:a?d:""});return Me.filter(({folder:Qe})=>ve.has(Qe.id))},[Me,n.isArchivedBucket,a,d]),Q=T,Ce=L,Be=c.useMemo(()=>new Set(Ae.flatMap(ve=>ve.folder.sessionIds)),[Ae]),Le=c.useMemo(()=>F.filter(ve=>!Be.has(ve.session.id)),[F,Be]),Je=c.useMemo(()=>{const ve=new Map(Ae.map(Qe=>[Qe.folder.id,Qe]));return Hf(Ae.map(Qe=>Qe.folder)).map(Qe=>ve.get(Qe.id)).filter(Qe=>!!Qe)},[Ae]),ot=c.useMemo(()=>{const ve=new Map;return Ae.forEach(Qe=>{if(!Qe.folder.parentId)return;const qe=ve.get(Qe.folder.parentId)??[];qe.push(Qe),ve.set(Qe.folder.parentId,qe)}),ve},[Ae]),et=c.useMemo(()=>{const ve=new Map(Ae.map(Ye=>[Ye.folder.id,Ye])),Qe=new Map,qe=(Ye,dt)=>{const Ot=Qe.get(Ye);if(Ot!==void 0)return Ot;if(dt.has(Ye))return[];dt.add(Ye);const zt=ve.get(Ye),Kt=zt?[...zt.nodes]:[];for(const Gt of ot.get(Ye)??[])Kt.push(...qe(Gt.folder.id,dt));return Qe.set(Ye,Kt),Kt};return Ae.forEach(({folder:Ye})=>qe(Ye.id,new Set)),Qe},[Ae,ot]),it="project",ht=c.useMemo(()=>{const ve=new Set;return Kc(F,Q,ve),Ae.forEach(({nodes:Qe})=>{Kc(Qe,Q,ve)}),ve},[F,Ae,Q]),st=c.useMemo(()=>{if(!Ce)return null;const ve=Yo(F,Ce,it,!!n.isArchivedBucket);if(ve)return ve;for(const{nodes:Qe}of Ae){const qe=Yo(Qe,Ce,it,!!n.isArchivedBucket);if(qe)return qe}return null},[Ce,F,Ae,n.isArchivedBucket]),mt=c.useCallback(ve=>{const Qe=new WeakMap,qe=Ye=>{Qe.set(Ye,qo(Ye));for(const dt of Ye.children)qe(dt)};return ve.forEach(qe),Qe},[]),kt=c.useMemo(()=>mt(F),[mt,F]),Pe=c.useMemo(()=>{const ve=new WeakMap;return Ae.forEach(({nodes:Qe})=>{Qe.forEach(qe=>ve.set(qe,qo(qe)))}),ve},[Ae]),Ge=c.useCallback(ve=>kt.get(ve)??Pe.get(ve)??"",[kt,Pe]),at=c.useCallback(ve=>({subtreeContainsEditing:ht,menuOpenSessionId:st,nodeStructureKey:Ge(ve)}),[ht,st,Ge]),ze=Le.length,ft=n.isArchivedBucket||a?Le:Le.slice(0,de),te=ze-ft.length,me=!n.isArchivedBucket&&!a&&ze>ee&&te===0,De=c.useCallback(ve=>{const Qe=[],qe=Ye=>{Ye.forEach(dt=>{Qe.push(dt.session),dt.children.length>0&&qe(dt.children)})};return qe(ve),Qe},[]),K=c.useMemo(()=>De(F),[De,F]),Se=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const ve=new Map,Qe=new Map;for(const{folder:Ye}of Ae){if(!Ye.parentId)continue;const dt=Qe.get(Ye.parentId)??[];dt.push(Ye.id),Qe.set(Ye.parentId,dt)}const qe=(Ye,dt)=>{if(dt.has(Ye))return[];dt.add(Ye);const Ot=Ae.find(({folder:Gt})=>Gt.id===Ye),zt=Ot?De(Ot.nodes):[],Kt=Qe.get(Ye)??[];for(const Gt of Kt)zt.push(...qe(Gt,dt));return zt};for(const{folder:Ye}of Ae)ve.set(Ye.id,qe(Ye.id,new Set));return ve},[Ae,De,n.isArchivedBucket]);if(a&&!Y&&Je.length===0&&Le.length===0)return null;const Ve=!n.isMain&&!!n.branch,Xe=n.branch&&Rg(n.branch,n.label)?{label:n.branch}:null,nt=be?s.jsx(Vj,{nodes:F,includeUnreadSubtasks:E}):null,Ze=(ve,Qe)=>{const{folder:qe,scopeKey:Ye,scopeDirectory:dt,nodes:Ot}=ve,zt=Se.get(qe.id)??[],Kt=$?.folderId===qe.id&&$?.scopeKey===Ye,Gt=a?!1:_e.has(qe.id),Bt=Jt=>s.jsx(Wf,{folderId:qe.id,scopeKey:Ye,ownerKey:oe,children:(Vt,Wt)=>s.jsx(zf,{folder:qe,displayName:Qe,sessions:Ot,isCollapsed:Gt,collapsedActivityState:Jt,onToggle:()=>I(qe.id),onRename:_t=>{X(Ye,qe.id,_t)},onDelete:()=>{if(n.isArchivedBucket){un.requestDelete({sessions:zt,mode:"session"});return}if(!ue){Z(Ye,qe.id);return}const _t=Ae.filter(({folder:Ct})=>Ct.parentId===qe.id).length,Xt=Ot.length;xe({scopeKey:Ye,folderId:qe.id,folderName:qe.name,subFolderCount:_t,sessionCount:Xt})},groupDirectory:dt??n.directory,projectId:i,mobileVariant:w,alwaysShowActions:h,isRenaming:Kt,renameDraft:Kt?$?.draft:void 0,onRenameDraftChange:P,onRenameSave:()=>{const _t=$?.draft.trim()??"";_t&&X(Ye,qe.id,_t),D()},onRenameCancel:D,droppableRef:Vt,isDropTarget:Wt,depth:0,onNewSession:()=>{i&&i!==g&&j(i),w&&b(!1),S({selectedProjectId:i,directoryOverride:dt??n.directory,targetFolderId:qe.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:Ot.map(_t=>s.jsx(Xo,{node:_t,pinnedSessionIds:C,expandedParents:B,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:E,editingId:T,editingRowKey:M,editTitle:W,openSidebarMenuKey:L,mobileVariant:w,alwaysShowActions:h,groupDirectory:dt??n.directory,projectId:i,folderOwnerKey:oe,selectionScopeKey:oe,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ht,menuOpenSessionId:st,nodeStructureKey:Ge(_t),childRenderExtrasFor:at},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},_t.session.id))})},qe.id);return Gt?s.jsx(Uk,{nodes:et.get(qe.id)??Ot,includeUnreadSubtasks:E,children:Bt},qe.id):Bt(null)},gt=()=>{const ve=new Map;for(const dt of Ae){const Ot=dt.folder.parentId;if(!Ot)continue;const zt=ve.get(Ot);zt?zt.push(dt):ve.set(Ot,[dt])}const Qe=[],qe=new Set,Ye=(dt,Ot)=>{if(qe.has(dt.folder.id))return;qe.add(dt.folder.id);const zt=Ot?`${Ot} / ${dt.folder.name}`:dt.folder.name;Qe.push(Ze(dt,zt)),!(!a&&_e.has(dt.folder.id))&&(ve.get(dt.folder.id)??[]).forEach(Gt=>Ye(Gt,zt))};return Je.forEach(dt=>Ye(dt,"")),Qe},We=!!(!n.isMain&&n.worktree),Et=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(_,{name:"alert",className:"h-3 w-3"})}):null,Ft=h?We?"pr-14":"pr-7":We?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",Ie=G?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Te==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":we?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),he?s.jsx(ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:re,onClick:()=>{z()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:q,children:e("sessions.sidebar.group.empty.retry")})]}):null,yt=ve=>s.jsx(Xo,{node:ve,pinnedSessionIds:C,expandedParents:B,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:E,editingId:T,editingRowKey:M,editTitle:W,openSidebarMenuKey:L,mobileVariant:w,alwaysShowActions:h,groupDirectory:n.directory,projectId:i,folderOwnerKey:oe,selectionScopeKey:oe,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ht,menuOpenSessionId:st,nodeStructureKey:Ge(ve),childRenderExtrasFor:at},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},ve.session.id),At=s.jsxs(r2,{scopeKey:ae[0]?.scopeKey??V,ownerKey:oe,hasFolders:Ae.length>0,onSessionDroppedOnFolder:(ve,Qe)=>{const qe=Ae.find(({folder:dt,scopeKey:Ot})=>dt.id===Qe.folderId&&Ot===Qe.scopeKey);if(!qe)return;const Ye=ss.getState();for(const{scopeKey:dt}of ae)dt!==qe.scopeKey&&Ye.getSessionFolderId(dt,ve)&&Ye.removeSessionFromFolder(dt,ve);ne(qe.scopeKey,Qe.folderId,ve)},children:[gt(),ft.map(yt),ze===0&&Ae.length===0?!n.isArchivedBucket&&!je&&!Ie&&n.directory&&!n.emptyMessage?s.jsx(ct,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{i&&i!==g&&j(i),w&&b(!1),S({selectedProjectId:i,directoryOverride:n.directory,target:n.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):je?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(_,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Ie||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,ze>0&&Ie?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Ie}):null,te>0?s.jsx("button",{type:"button",onClick:()=>x(r,ft.length,f??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,me?s.jsx("button",{type:"button",onClick:()=>k(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),He="pb-2",Ue=s.jsx(em,{value:se,setValue:xe,onConfirm:()=>{const ve=se;ve&&(Z(ve.scopeKey,ve.folderId),xe(null))}});return o?l?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Ee("oc-group-body",He),children:At})}),Ue]}):null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Ee("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>R(r),role:"button",tabIndex:0,onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),R(r))},"aria-label":be?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!be,children:[s.jsxs("div",{ref:A?.setActivatorNodeRef,className:Ee("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Ft),...A?.listeners??{},children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(_,{name:"archive",className:Ee("h-3.5 w-3.5 shrink-0 text-muted-foreground",h?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Ee("text-muted-foreground h-3.5 w-3.5 items-center justify-center",h?"inline-flex":"hidden group-hover/gh:inline-flex"),children:be?s.jsx(_,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Vr(n.label,d)}),Et,nt]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(_,{name:"git-branch",className:Ee("h-3.5 w-3.5 shrink-0",!H&&"text-muted-foreground",h?"hidden":"group-hover/gh:hidden"),style:H?{color:H}:void 0}),s.jsx("span",{className:Ee("text-muted-foreground h-3.5 w-3.5 items-center justify-center",h?"inline-flex":"hidden group-hover/gh:inline-flex"),children:be?s.jsx(_,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:Vr(n.label,d)}),Et,nt,ke?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:H?{color:H}:void 0,children:["#",ke.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:Vr(n.label,d)}),nt]})}),Ve&&Xe?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(_,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(_,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:Xe.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(Zr,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&K.length>0?s.jsx("div",{className:Ee("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),un.requestDelete({sessions:K,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:n.label}),children:s.jsx(_,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:Ee("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),un.requestDelete({sessions:K,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(_,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:Ee("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),i&&i!==g&&j(i),w&&b(!1),S({selectedProjectId:i,directoryOverride:n.directory})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(_,{name:"add",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),!be&&l?s.jsx("div",{className:Ee("oc-group-body",He),children:At}):null]}),Ue]})}const Xk=c.memo(Qk,Yk),Co=({projectId:t,mobileVariant:e,closeMobileSwitcher:n,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&n&&i(!1)},id=(t,e)=>Fu(t.label?.trim()||ir(t.normalizedPath,e)||t.normalizedPath);function Jk(t){const e=tt.c(103),{model:n,view:r,actions:i}=t;Ts("ui.sidebar_projects_list.render");const{t:o}=Nt(),l=ii(),a=ss(c3),d=ss(l3),u=ss(a3),m=ss(i3),f=Ne(o3),[p,y]=c.useState(null),[x,k]=c.useState(null),[w,h]=c.useState(null),[g,j]=c.useState(null),[b,S]=c.useState(!1),C=c.useRef(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={activationConstraint:{distance:8}},e[0]=v):v=e[0];let E;e[1]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{delay:200,tolerance:6}},e[1]=E):E=e[1];let R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R={coordinateGetter:Xx},e[2]=R):R=e[2];const A=li(Pn(di,v),Pn(ci,E),Pn(Yx,R));let O;e[3]===Symbol.for("react.memo_cache_sentinel")?(O=z=>{C.current=z,j(z)},e[3]=O):O=e[3];const B=O;let T;if(e[4]!==n.projectSections||e[5]!==r.homeDirectory){let z;e[7]!==r.homeDirectory?(z=ee=>({id:ee.project.id,projectLabel:id(ee.project,r.homeDirectory),projectDescription:Xr(ee.project.normalizedPath,r.homeDirectory),projectIcon:ee.project.icon,projectColor:ee.project.color,projectIconImage:ee.project.iconImage,projectIconBackground:ee.project.iconBackground}),e[7]=r.homeDirectory,e[8]=z):z=e[8],T=n.projectSections.map(z),e[4]=n.projectSections,e[5]=r.homeDirectory,e[6]=T}else T=e[6];const M=T;let L;e:{if(!r.stickyZoneHeaders){L=-1;break e}let z;if(e[9]!==n.rowModel.stickyHeaders||e[10]!==x){let ee;e[12]!==x?(ee=de=>`${de.kind}:${de.id}`===x,e[12]=x,e[13]=ee):ee=e[13],z=n.rowModel.stickyHeaders.findIndex(ee),e[9]=n.rowModel.stickyHeaders,e[10]=x,e[11]=z}else z=e[11];L=z}const W=L;let $;if(e[14]!==w||e[15]!==n.groupProps.editingRowKey||e[16]!==n.rowModel.rowIndexByKey||e[17]!==n.rowModel.rows||e[18]!==n.rowModel.stickyHeaders||e[19]!==n.state.openSidebarMenuKey||e[20]!==W){if($=new Set,w){let z;e[22]!==w||e[23]!==n.rowModel.rowIndexByKey?(z=n.rowModel.rowIndexByKey.get(w),e[22]=w,e[23]=n.rowModel.rowIndexByKey,e[24]=z):z=e[24];const ee=z;ee!==void 0&&$.add(ee)}for(let z=0;z<n.rowModel.rows.length;z=z+1,z){const ee=n.rowModel.rows[z];ee?.kind==="session"&&(n.groupProps.editingRowKey===ee.key||n.state.openSidebarMenuKey===`session-menu:${ee.key}`||n.state.openSidebarMenuKey===`session-context:${ee.key}`)&&$.add(z)}if(W>=0){const z=Math.max(0,W-1),ee=Math.min(n.rowModel.stickyHeaders.length-1,W+1);for(let de=z;de<=ee;de=de+1,de){const Y=n.rowModel.stickyHeaders[de];Y&&$.add(Y.rowIndex)}}e[14]=w,e[15]=n.groupProps.editingRowKey,e[16]=n.rowModel.rowIndexByKey,e[17]=n.rowModel.rows,e[18]=n.rowModel.stickyHeaders,e[19]=n.state.openSidebarMenuKey,e[20]=W,e[21]=$}else $=e[21];const P=$;let D;e[25]!==n.rowModel.stickyHeaders||e[26]!==r.stickyZoneHeaders?(D=z=>{const ee=r.stickyZoneHeaders?Ek(n.rowModel.stickyHeaders,z):null,de=ee?`${ee.kind}:${ee.id}`:null;k(Y=>Y===de?Y:de)},e[25]=n.rowModel.stickyHeaders,e[26]=r.stickyZoneHeaders,e[27]=D):D=e[27];const I=D;let X;e[28]!==l||e[29]!==o?(X=z=>{const ee=()=>{if(!z.status.directory){ai();return}l.requestBootstrap({directory:z.status.directory,priority:"expanded",reason:z.group.isMain?"project-expanded":"worktree-expanded",force:!0})},de=async()=>{if(!z.status.directory)return;(await Kd(z.status.directory)).success&&ee()};let Y;e:switch(z.status.state){case"permission-denied":{Y=o("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Y=o("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Y=o("sessions.sidebar.group.empty.initializationFailed");break e}default:Y=o("sessions.sidebar.group.empty.loadingSessions")}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[z.status.state==="loading"?s.jsx(_,{name:"loader-4",className:"size-3 animate-spin"}):null,Y,z.status.canGrantAccess?s.jsx(ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{de()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,z.status.state!=="loading"?s.jsx(ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ee,children:o("sessions.sidebar.group.empty.retry")}):null]})})},e[28]=l,e[29]=o,e[30]=X):X=e[30];const Z=X;let ne;e[31]!==i||e[32]!==u||e[33]!==n.emptyState||e[34]!==n.groupProps||e[35]!==n.projectRepoStatus||e[36]!==n.searchEmptyState||e[37]!==n.singleProjectMode||e[38]!==n.state||e[39]!==M||e[40]!==d||e[41]!==Z||e[42]!==f||e[43]!==o||e[44]!==a||e[45]!==r.alwaysShowActions||e[46]!==r.hideDirectoryControls||e[47]!==r.homeDirectory||e[48]!==r.mobileVariant||e[49]!==r.projectSortOrder||e[50]!==r.stickyZoneHeaders||e[51]!==r.timelineView?(ne=z=>{if(z.kind==="activity-header")return s.jsx(sm,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:s.jsx(kk,{activityKey:z.activityKey,collapsed:z.collapsed,forceExpanded:z.forceExpanded,alwaysShowActions:r.alwaysShowActions,timelineView:r.timelineView,onToggle:()=>{if(!z.collapsed){const ee=`activity:${z.activityKey}`;i.group.resetGroupSessionLimit(ee),n.state.setVisibleActivityCountByKey(de=>{if(!de.has(ee))return de;const Y=new Map(de);return Y.delete(ee),Y})}n.state.setCollapsedActivityKeys(ee=>{const de=new Set(ee);return de.has(z.activityKey)?de.delete(z.activityKey):de.add(z.activityKey),de})},onNewChat:()=>{Ne.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:Mg,directoryOverride:null})}})});if(z.kind==="project-header"){const ee=z.section.project,de=id(ee,r.homeDirectory);return s.jsx(Lk,{id:ee.id,disabled:n.singleProjectMode||z.forceExpanded||n.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:de,projectDescription:Xr(ee.normalizedPath,r.homeDirectory),projectDirectory:ee.normalizedPath,projectIcon:ee.icon,projectColor:ee.color,projectIconImage:ee.iconImage,projectIconBackground:ee.iconBackground,isCollapsed:z.collapsed,isRepo:!!n.projectRepoStatus.get(ee.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:z.collapsed?i.renderProjectStatusIndicator?.(ee.id,z.section.groups):null,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,projectPickerOptions:n.singleProjectMode?M:void 0,onProjectSelect:n.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!z.forceExpanded&&!n.singleProjectMode&&i.toggleProject(ee.id)},onNewSession:()=>{Co({projectId:ee.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:ee.id,directoryOverride:ee.normalizedPath})},onNewWorktreeSession:()=>{Co({projectId:ee.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewWorktreeDialog()},onManageWorktrees:()=>i.openWorktreesPage(ee.id),onRenameStart:()=>i.openProjectEditDialog(ee.id),onClose:()=>i.removeProject(ee.id),showCreateButtons:!0})}if(z.kind==="group-header")return s.jsx(zk,{id:z.groupKey,disabled:z.forceExpanded||n.state.editingId!==null,children:ee=>s.jsx(Xk,{...n.groupProps,...i.group,group:z.group,groupKey:z.groupKey,projectId:z.projectId,visibleSessionCount:n.state.visibleSessionCountByGroup.get(z.groupKey),editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,dragHandleProps:ee,renderBody:!1})});if(z.kind==="folder-header"){const ee=n.groupProps.folderRename?.folderId===z.folder.id&&n.groupProps.folderRename.scopeKey===z.scopeKey;return s.jsx(Wf,{folderId:z.folder.id,scopeKey:z.scopeKey,ownerKey:z.ownerKey,disabled:!z.dropEnabled,children:(de,Y)=>s.jsx(s2,{notifyOnSubtasks:n.groupProps.notifyOnSubtasks,activityNodes:z.activityNodes,folder:z.folder,displayName:z.displayName,sessions:z.nodes,isCollapsed:z.collapsed,onToggle:z.forceExpanded?r3:()=>a(z.folder.id),onRename:U=>d(z.scopeKey,z.folder.id,U),onDelete:()=>{z.archived?un.requestDelete({sessions:[...z.deleteSessions],mode:"session"}):f?y({scopeKey:z.scopeKey,folderId:z.folder.id,folderName:z.folder.name,subFolderCount:z.subFolderCount,sessionCount:z.nodes.length}):u(z.scopeKey,z.folder.id)},renderBody:!1,groupDirectory:z.scopeDirectory??z.group.directory,projectId:z.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:ee,renameDraft:ee?n.groupProps.folderRename?.draft:void 0,onRenameDraftChange:n.groupProps.setFolderRenameDraft,onRenameSave:()=>{const U=n.groupProps.folderRename?.draft.trim();U&&d(z.scopeKey,z.folder.id,U),n.groupProps.clearFolderRename()},onRenameCancel:n.groupProps.clearFolderRename,droppableRef:de,isDropTarget:Y,onNewSession:()=>{Co({projectId:z.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:z.projectId,directoryOverride:z.scopeDirectory??z.group.directory,targetFolderId:z.folder.id,target:z.group.draftTarget})},archivedBucket:z.archived})})}if(z.kind==="session"){const ee=new Set;return kr(z.node,n.state.editingId)&&ee.add(z.node.session.id),s.jsx("div",{onFocusCapture:()=>h(z.key),onBlurCapture:()=>h(de=>de===z.key?null:de),children:s.jsx(Xo,{...n.groupProps,node:z.node,depth:z.depth,groupDirectory:z.groupDirectory,projectId:z.projectId,folderOwnerKey:z.ownerKey,selectionScopeKey:z.selectionScopeKey,archivedBucket:z.archived,renderContext:z.renderContext,rowKey:z.key,dragKey:z.key,secondaryMeta:z.secondaryMeta,renderChildren:!1,editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:ee,menuOpenSessionId:n.state.openSidebarMenuKey===`session-menu:${z.key}`||n.state.openSidebarMenuKey===`session-context:${z.key}`?z.node.session.id:null,nodeStructureKey:qo(z.node)}})})}if(z.kind==="show-control")return s.jsx("button",{type:"button",className:Ee("mt-0.5 flex items-center justify-start rounded-md pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",r.timelineView?"pl-[10px]":"pl-[26px]"),onClick:()=>{z.containerKey.startsWith("activity:")?n.state.setVisibleActivityCountByKey(ee=>{const de=new Map(ee);return z.control==="more"?de.set(z.containerKey,z.currentCount+z.increment):de.delete(z.containerKey),de}):z.control==="more"?i.group.showMoreGroupSessions(z.containerKey,z.currentCount,z.increment):i.group.resetGroupSessionLimit(z.containerKey)},children:o(z.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")});if(z.kind==="status")return Z(z);if(z.emptyKind==="sidebar")return n.emptyState;if(z.emptyKind==="search")return n.searchEmptyState;if(z.emptyKind==="group"&&z.group?.directory&&!z.group.emptyMessage){const ee=z.group;return s.jsx(ct,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{Co({projectId:z.projectId??null,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:z.projectId,directoryOverride:ee.directory,target:ee.draftTarget})},children:o("sessions.sidebar.group.empty.startSession")})}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:z.emptyKind==="archived"?o("sessions.sidebar.group.empty.noArchivedSessions"):z.group?.emptyMessage??o("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[31]=i,e[32]=u,e[33]=n.emptyState,e[34]=n.groupProps,e[35]=n.projectRepoStatus,e[36]=n.searchEmptyState,e[37]=n.singleProjectMode,e[38]=n.state,e[39]=M,e[40]=d,e[41]=Z,e[42]=f,e[43]=o,e[44]=a,e[45]=r.alwaysShowActions,e[46]=r.hideDirectoryControls,e[47]=r.homeDirectory,e[48]=r.mobileVariant,e[49]=r.projectSortOrder,e[50]=r.stickyZoneHeaders,e[51]=r.timelineView,e[52]=ne):ne=e[52];const ue=ne;let se;e[53]!==n.rowModel.rows?(se=n.rowModel.rows.flatMap(n3),e[53]=n.rowModel.rows,e[54]=se):se=e[54];const xe=se;let ie;e[55]!==n.sectionsForRender?(ie=new Set(n.sectionsForRender.map(s3)),e[55]=n.sectionsForRender,e[56]=ie):ie=e[56];const Re=ie;let be;e[57]!==n.rowModel.stickyHeaders?(be=n.rowModel.stickyHeaders.map(t3).join(""),e[57]=n.rowModel.stickyHeaders,e[58]=be):be=e[58];const fe=be,ke=!r.timelineView;let H;e[59]!==Re?(H=z=>{S(Re.has(String(z.active.id)))},e[59]=Re,e[60]=H):H=e[60];let J;e[61]===Symbol.for("react.memo_cache_sentinel")?(J=()=>S(!1),e[61]=J):J=e[61];let ce;e[62]!==i||e[63]!==m||e[64]!==n.rowModel.folderAuthorityByOwner||e[65]!==n.rowModel.folderDropTargets||e[66]!==n.rowModel.rows||e[67]!==n.sectionsForRender||e[68]!==n.state||e[69]!==r.hasSessionSearchQuery||e[70]!==r.projectSortOrder?(ce=z=>{if(S(!1),!z.over)return;const ee=z.active.data.current,de=z.over.data.current;if(ee?.type==="session"&&ee.sessionId&&ee.ownerKey&&ee.archivedBucket!==!0&&de?.type==="folder"&&de.folderId&&de.scopeKey&&de.ownerKey===ee.ownerKey){const Ae=n.rowModel.folderDropTargets.find(Be=>Be.folderId===de.folderId&&Be.scopeKey===de.scopeKey&&Be.ownerKey===ee.ownerKey),Q=n.rowModel.folderAuthorityByOwner.get(ee.ownerKey);if(!Ae?.enabled||Q?.complete!==!0)return;const Ce=ss.getState();for(const Be of Q.scopeKeys)Be!==de.scopeKey&&Ce.removeSessionFromFolder(Be,ee.sessionId);m(de.scopeKey,de.folderId,ee.sessionId);return}if(r.hasSessionSearchQuery||n.state.editingId!==null||z.active.id===z.over.id)return;const Y=String(z.active.id),U=String(z.over.id),F=n.sectionsForRender.map(e3),V=F.indexOf(Y),oe=F.indexOf(U);if(V>=0&&oe>=0&&r.projectSortOrder==="manual"){i.reorderProjects(V,oe);return}const ae=n.rowModel.rows.find(Ae=>Ae.kind==="group-header"&&Ae.groupKey===Y),pe=n.rowModel.rows.find(Ae=>Ae.kind==="group-header"&&Ae.groupKey===U);if(!ae||!pe||ae.projectId!==pe.projectId||!ae.projectId)return;const le=ae.projectId,_e=n.sectionsForRender.find(Ae=>Ae.project.id===le);if(!_e)return;const Fe=_e.groups.findIndex(Ae=>Ae.id===ae.group.id),Me=_e.groups.findIndex(Ae=>Ae.id===pe.group.id);Fe<0||Me<0||i.setGroupOrderByProject(Ae=>new Map(Ae).set(le,Qu(_e.groups,Fe,Me).map(Zk)))},e[62]=i,e[63]=m,e[64]=n.rowModel.folderAuthorityByOwner,e[65]=n.rowModel.folderDropTargets,e[66]=n.rowModel.rows,e[67]=n.sectionsForRender,e[68]=n.state,e[69]=r.hasSessionSearchQuery,e[70]=r.projectSortOrder,e[71]=ce):ce=e[71];let je;e[72]!==I||e[73]!==n.rowModel||e[74]!==P||e[75]!==ue||e[76]!==g?(je=s.jsx(Sk,{model:n.rowModel,scrollElement:g,pinnedRowIndexes:P,renderRow:ue,onFirstVisibleIndexChange:I}),e[72]=I,e[73]=n.rowModel,e[74]=P,e[75]=ue,e[76]=g,e[77]=je):je=e[77];let G;e[78]!==xe||e[79]!==je?(G=s.jsx(Ja,{items:xe,strategy:Xu,children:je}),e[78]=xe,e[79]=je,e[80]=G):G=e[80];let we;e[81]!==A||e[82]!==H||e[83]!==ce||e[84]!==G?(we=s.jsx(ui,{sensors:A,collisionDetection:fi,onDragStart:H,onDragCancel:J,onDragEnd:ce,children:G}),e[81]=A,e[82]=H,e[83]=ce,e[84]=G,e[85]=we):we=e[85];let Te;e[86]!==ke||e[87]!==we?(Te=s.jsx(En,{ref:B,useScrollShadow:!0,hideTopScrollShadow:ke,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:we}),e[86]=ke,e[87]=we,e[88]=Te):Te=e[88];let he;e[89]!==b||e[90]!==Te||e[91]!==r.stickyZoneHeaders||e[92]!==fe?(he=s.jsx(Mk,{enabled:r.stickyZoneHeaders,suspended:b,layoutKey:fe,scrollRef:C,children:Te}),e[89]=b,e[90]=Te,e[91]=r.stickyZoneHeaders,e[92]=fe,e[93]=he):he=e[93];let re;e[94]!==u||e[95]!==p?(re=()=>{p&&(u(p.scopeKey,p.folderId),y(null))},e[94]=u,e[95]=p,e[96]=re):re=e[96];let ge;e[97]!==p||e[98]!==re?(ge=s.jsx(em,{value:p,setValue:y,onConfirm:re}),e[97]=p,e[98]=re,e[99]=ge):ge=e[99];let q;return e[100]!==he||e[101]!==ge?(q=s.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[he,ge]}),e[100]=he,e[101]=ge,e[102]=q):q=e[102],q}function Zk(t){return t.id}function e3(t){return t.project.id}function t3(t){const{kind:e,id:n,rowIndex:r}=t;return`${e}:${n}:${r}`}function s3(t){return t.project.id}function n3(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function r3(){}function o3(t){return t.showDeletionDialog}function i3(t){return t.addSessionToFolder}function a3(t){return t.deleteFolder}function l3(t){return t.renameFolder}function c3(t){return t.toggleFolderCollapse}const d3=c.memo(Jk),Da=new Map,ad=(t,e)=>{for(const n of t){const r=xt(n??null);r&&!Da.has(r)&&Da.set(r,e)}},ld=t=>{const e=xt(t??null);return e?Da.get(e)??0:0},Mr=t=>!!t.time?.archived,u3=t=>{const{t:e}=Nt(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const d=xt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${d}`.toLowerCase()},[e]),o=c.useCallback((a,d)=>{if(!d)return a;const u=d.trim().toLowerCase(),m=u.startsWith("ses_");return a.flatMap(f=>{if(m&&Mr(f.session))return[];if(m?f.session.id.toLowerCase()===u:$o([i(f.session)],d))return[f];const y=o(f.children,d);return y.length===0?[]:[{...f,children:y}]})},[i]),l=c.useCallback((a,d,u,m,f)=>{const p=xt(d??null),y=Mu(a),x=new Map(y.map(W=>[W.id,W])),k=new Map;y.forEach(W=>{const $=W.parentID;if(!$)return;const P=x.get($);if(!P||Mr(P)!==Mr(W))return;const D=k.get($)??[];D.push(W),k.set($,D)});const w=Og(u,p),h=W=>{const $=xt(W.directory??null),P=t.worktreeMetadata.get(W.id)??null;if(P)return P;if($){const D=w.get($)??null;if(D&&$!==p)return D}return null},g=new Set,j=W=>{g.add(W.id);const $=k.get(W.id)??[],P=[];for(const D of $)g.has(D.id)||P.push(j(D));return{session:W,children:P,worktree:h(W)}},b=y.filter(W=>{const $=W.parentID;if(!$)return!0;const P=x.get($);return P?Mr(P)!==Mr(W):!0}),S=[],C=W=>{g.has(W.id)||S.push(j(W))};b.forEach(C),y.forEach(C);const v=new Map,E="__archived__",R=W=>{if(W.time?.archived)return E;if(t.isVSCode)return p??"__project_root__";const $=t.sessionOwners?.get(W.id)?.scopeDirectory;if($){if($===p)return p??"__project_root__";if(w.has($))return $}const D=xt(t.worktreeMetadata.get(W.id)?.path??null)??As(W);return D&&D!==p&&w.has(D)?D:p??"__project_root__"};S.forEach(W=>{const $=R(W.session);v.has($)||v.set($,[]),v.get($)?.push(W)});const A=p??"__project_root__",O=[{id:"root",label:f&&m&&m!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:m}):e("sessions.sidebar.grouping.projectRoot"),branch:m??null,description:p?Xr(p,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:p,folderScopeKey:p,sessions:v.get(A)??[]}],B=new Map;u.forEach(W=>{const $=xt(W.path)??W.path,P=v.get($)??[],D=P.length>0,I=P.reduce((X,Z)=>{const ne=Bg(Z.session,t.sessionOrderRanks);return Number.isFinite(ne)?Math.max(X,ne):X},0);B.set($,{hasActiveSession:D,lastUpdatedAt:I})});const T=[...u].sort((W,$)=>{const P=xt(W.path)??W.path,D=xt($.path)??$.path,I=B.get(P)??{hasActiveSession:!1,lastUpdatedAt:0},X=B.get(D)??{hasActiveSession:!1,lastUpdatedAt:0};if(I.hasActiveSession!==X.hasActiveSession)return I.hasActiveSession?-1:1;if(I.hasActiveSession&&X.hasActiveSession)return X.lastUpdatedAt-I.lastUpdatedAt;const Z=ld(W.path),ne=ld($.path);if(Z!==ne)return ne-Z;const ue=(W.label||W.branch||W.name||W.path||"").toLowerCase(),se=($.label||$.branch||$.name||$.path||"").toLowerCase();return ue.localeCompare(se)});(t.isVSCode?[]:T).forEach(W=>{const $=xt(W.path)??W.path,P=n.current.get($)?.trim()||null,D=W.branch?.trim()||null,X=!!(P&&D&&W.label&&Fl(W.label)===Fl(D))?P:W.label||W.name||ir($,t.homeDirectory)||$;O.push({id:`worktree:${$}`,label:X,branch:P||D,description:Xr($,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:W,directory:$,folderScopeKey:$,sessions:v.get($)??[]})});const L=v.get(E)??[];return L.length>0&&O.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&p?Ru(p):null,sessions:L}),O},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,t.sessionOwners,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},f3=t=>{const e=tt.c(60),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:m,onArchive:f,onDelete:p,onDone:y}=t,{t:x}=Nt(),k=n>0,w=k&&!!r&&!o;let h;e[0]!==n||e[1]!==x?(h=x("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[0]=n,e[1]=x,e[2]=h):h=e[2];let g;e[3]!==h?(g=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:h}),e[3]=h,e[4]=g):g=e[4];let j;e[5]!==w||e[6]!==u||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==i||e[11]!==x?(j=w?s.jsxs(Ls,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":x("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(_,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(_s,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Ht,{disabled:!0,className:"text-muted-foreground",children:x("sessions.sidebar.folders.none")}):i.map(Z=>s.jsx(Ht,{onClick:()=>l(Z.id),children:s.jsx("span",{className:"flex-1 truncate",children:Z.name})},Z.id)),s.jsx(Es,{}),s.jsxs(Ht,{onClick:a,children:[s.jsx(_,{name:"add",className:"mr-1 h-4 w-4"}),x("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(Ht,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(_,{name:"close",className:"mr-1 h-4 w-4"}),x("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=w,e[6]=u,e[7]=a,e[8]=l,e[9]=d,e[10]=i,e[11]=x,e[12]=j):j=e[12];let b;e[13]!==o||e[14]!==k||e[15]!==m||e[16]!==x?(b=o?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,disabled:!k,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":x("sessions.sidebar.bulkActions.restore"),children:s.jsx(_,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=o,e[14]=k,e[15]=m,e[16]=x,e[17]=b):b=e[17];let S;e[18]!==o||e[19]!==k||e[20]!==f||e[21]!==x?(S=o?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,disabled:!k,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":x("sessions.sidebar.bulkActions.archive"),children:s.jsx(_,{name:"archive",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.archive")})})]}),e[18]=o,e[19]=k,e[20]=f,e[21]=x,e[22]=S):S=e[22];const C=!k;let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=Ee("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]=v):v=e[23];let E;e[24]!==x?(E=x("sessions.sidebar.bulkActions.delete"),e[24]=x,e[25]=E):E=e[25];let R;e[26]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(_,{name:"delete-bin",className:"h-4 w-4"}),e[26]=R):R=e[26];let A;e[27]!==p||e[28]!==C||e[29]!==E?(A=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:p,disabled:C,className:v,"aria-label":E,children:R})}),e[27]=p,e[28]=C,e[29]=E,e[30]=A):A=e[30];let O;e[31]!==x?(O=x("sessions.sidebar.bulkActions.delete"),e[31]=x,e[32]=O):O=e[32];let B;e[33]!==O?(B=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:O})}),e[33]=O,e[34]=B):B=e[34];let T;e[35]!==A||e[36]!==B?(T=s.jsxs(vt,{children:[A,B]}),e[35]=A,e[36]=B,e[37]=T):T=e[37];let M;e[38]!==x?(M=x("sessions.sidebar.header.actions.exitSelection"),e[38]=x,e[39]=M):M=e[39];let L;e[40]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(_,{name:"close",className:"h-4 w-4"}),e[40]=L):L=e[40];let W;e[41]!==y||e[42]!==M?(W=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:y,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":M,children:L})}),e[41]=y,e[42]=M,e[43]=W):W=e[43];let $;e[44]!==x?($=x("sessions.sidebar.header.actions.exitSelection"),e[44]=x,e[45]=$):$=e[45];let P;e[46]!==$?(P=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:$})}),e[46]=$,e[47]=P):P=e[47];let D;e[48]!==W||e[49]!==P?(D=s.jsxs(vt,{children:[W,P]}),e[48]=W,e[49]=P,e[50]=D):D=e[50];let I;e[51]!==T||e[52]!==D||e[53]!==j||e[54]!==b||e[55]!==S?(I=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[j,b,S,T,D]}),e[51]=T,e[52]=D,e[53]=j,e[54]=b,e[55]=S,e[56]=I):I=e[56];let X;return e[57]!==g||e[58]!==I?(X=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[g,I]}),e[57]=g,e[58]=I,e[59]=X):X=e[59],X},cd=new Map,m3=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},h3=(t,e)=>{const n=t.sessionIds.filter(o=>e.has(o));if(n.length===0)return{ready:!1,value:null};const r=t.archivedBucket||Uf(new Set(n),e),i={sessionIds:n,sessionCount:n.length,archivedBucket:r};return{ready:n.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},p3=t=>{const e=tt.c(89),{t:n}=Nt();let r;e[0]!==n?(r=Y=>{const U=Fg(Y);return U?{description:Zd(U,n)}:void 0},e[0]=n,e[1]=r):r=e[1];const i=r,{isInlineEditing:o,showDeletionDialog:l,foldersMap:a,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:m,createFolderAndStartRename:f,archiveSessions:p,unarchiveSessions:y,deleteSessions:x,bulkDeleteConfirm:k,setBulkDeleteConfirm:w}=t,h=ms(g3),g=ms(x3),j=g>0,b=ms(b3),S=ms(y3),C=Vf(),v=w3,E=v3;let R;e[2]!==j||e[3]!==C||e[4]!==b?(R=j&&Uf(b,C?.getSessionsById()??cd),e[2]=j,e[3]=C,e[4]=b,e[5]=R):R=e[5];const A=R;let O;e:{if(S){O=S;break e}O=null}const B=O;let T;e[6]!==B||e[7]!==d?(T=m3(B,d),e[6]=B,e[7]=d,e[8]=T):T=e[8];const M=T;let L;if(e[9]!==a||e[10]!==M){let Y;e[12]!==a?(Y=U=>a[U]??[],e[12]=a,e[13]=Y):Y=e[13],L=M.flatMap(Y),e[9]=a,e[10]=M,e[11]=L}else L=e[11];const W=L;let $;e[14]!==a||e[15]!==M?($=Y=>{for(const U of M)if((a[U]??[]).some(F=>F.id===Y))return U;return null},e[14]=a,e[15]=M,e[16]=$):$=e[16];const P=$;let D;e:{if(!j){D=!1;break e}for(const Y of M)for(const U of a[Y]??[])for(const F of U.sessionIds)if(b.has(F)){D=!0;break e}D=!1}const I=D;let X;e[17]!==u||e[18]!==m||e[19]!==b||e[20]!==M?(X=(Y,U)=>{const F=Array.from(b);for(const V of M)V!==Y&&m(V,F);u(Y,U,F)},e[17]=u,e[18]=m,e[19]=b,e[20]=M,e[21]=X):X=e[21];const Z=X;let ne;e[22]!==j||e[23]!==Z||e[24]!==P?(ne=Y=>{if(!j)return;const U=P(Y);U&&Z(U,Y)},e[22]=j,e[23]=Z,e[24]=P,e[25]=ne):ne=e[25];const ue=ne;let se;e[26]!==f||e[27]!==j||e[28]!==Z||e[29]!==M?(se=()=>{const Y=M[0];if(!Y||!j)return;const U=f(Y);U&&Z(Y,U.id)},e[26]=f,e[27]=j,e[28]=Z,e[29]=M,e[30]=se):se=e[30];const xe=se;let ie;e[31]!==j||e[32]!==m||e[33]!==b||e[34]!==M?(ie=()=>{if(!j)return;const Y=Array.from(b);for(const U of M)m(U,Y)},e[31]=j,e[32]=m,e[33]=b,e[34]=M,e[35]=ie):ie=e[35];const Re=ie;let be;e[36]!==p||e[37]!==x||e[38]!==i||e[39]!==n?(be=async(Y,U)=>{if(Y.length!==0)if(U){const{deletedIds:F,failedIds:V}=await x(Y);F.length>0&&Ke.success(F.length===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:F.length}):n("sessions.sidebar.bulkActions.deletedPlural",{count:F.length})),V.length>0&&Ke.error(V.length===1?n("sessions.sidebar.bulkActions.failedDeleteSingle",{count:V.length}):n("sessions.sidebar.bulkActions.failedDeletePlural",{count:V.length}),i(V)),ms.getState().removeMany(F)}else{const{archivedIds:F,failedIds:V}=await p(Y);F.length>0&&Ke.success(F.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:F.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:F.length})),V.length>0&&Ke.error(V.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:V.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:V.length}),i(V)),ms.getState().removeMany(F)}},e[36]=p,e[37]=x,e[38]=i,e[39]=n,e[40]=be):be=e[40];const fe=be;let ke;e[41]!==fe||e[42]!==j||e[43]!==b||e[44]!==w||e[45]!==l?(ke=Y=>{if(!j)return;const U=Array.from(b);if(!l){fe(U,Y);return}w({sessionIds:U,sessionCount:U.length,archivedBucket:Y})},e[41]=fe,e[42]=j,e[43]=b,e[44]=w,e[45]=l,e[46]=ke):ke=e[46];const H=ke;let J;e[47]!==A||e[48]!==H?(J=()=>H(A),e[47]=A,e[48]=H,e[49]=J):J=e[49];const ce=J;let je;e[50]!==H?(je=()=>H(!1),e[50]=H,e[51]=je):je=e[51];const G=je;let we;e[52]!==H?(we=()=>H(!0),e[52]=H,e[53]=we):we=e[53];const Te=we;let he;e[54]!==A||e[55]!==i||e[56]!==j||e[57]!==b||e[58]!==n||e[59]!==y?(he=async()=>{if(!j||!A)return;const Y=Array.from(b),{restoredIds:U,failedIds:F}=await y(Y);U.length>0&&Ke.success(U.length===1?n("sessions.sidebar.bulkActions.restoredSingle",{count:U.length}):n("sessions.sidebar.bulkActions.restoredPlural",{count:U.length})),F.length>0&&Ke.error(F.length===1?n("sessions.sidebar.bulkActions.failedRestoreSingle",{count:F.length}):n("sessions.sidebar.bulkActions.failedRestorePlural",{count:F.length}),i(F)),ms.getState().removeMany(U)},e[54]=A,e[55]=i,e[56]=j,e[57]=b,e[58]=n,e[59]=y,e[60]=he):he=e[60];const re=he;let ge;e[61]!==k||e[62]!==fe||e[63]!==C||e[64]!==w?(ge=async()=>{if(!k)return;const Y=C?.getSessionsById()??cd,U=h3(k,Y);if(!U.ready){w(U.value);return}w(null),await fe(U.value.sessionIds,U.value.archivedBucket)},e[61]=k,e[62]=fe,e[63]=C,e[64]=w,e[65]=ge):ge=e[65];const q=ge;let z,ee;e[66]!==k||e[67]!==ce||e[68]!==o||e[69]!==C||e[70]!==h?(z=()=>{if(!h)return;const Y=/Macintosh|Mac OS X/.test(navigator.userAgent||""),U=F=>{if(k||o)return;const V=F.target instanceof HTMLElement?F.target:null;if(V&&(V.tagName==="INPUT"||V.tagName==="TEXTAREA"||V.isContentEditable))return;const oe=Y?F.metaKey:F.ctrlKey;if(F.key==="Escape"){F.preventDefault(),ms.getState().disable();return}if(oe&&F.key==="Backspace"){F.preventDefault(),ce();return}if(oe&&(F.key==="a"||F.key==="A")){const ae=i2(C?.getEntries()??[],C?.getDescendantIds()??[],ms.getState().scopeKey);if(!ae)return;F.preventDefault(),ms.getState().replaceAll(ae.ids,ae.scopeKey)}};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},ee=[k,ce,o,C,h],e[66]=k,e[67]=ce,e[68]=o,e[69]=C,e[70]=h,e[71]=z,e[72]=ee):(z=e[71],ee=e[72]),c.useEffect(z,ee);let de;return e[73]!==I||e[74]!==W||e[75]!==A||e[76]!==q||e[77]!==B||e[78]!==G||e[79]!==xe||e[80]!==ce||e[81]!==Te||e[82]!==ue||e[83]!==Re||e[84]!==re||e[85]!==j||e[86]!==g||e[87]!==h?(de={selectionModeEnabled:h,hasSelection:j,selectedIdsSize:g,bulkScopeIsArchived:A,derivedSelectionScope:B,bulkScopeFolders:W,bulkCanRemoveFromFolder:I,handleToggleSelectionMode:v,handleExitSelectionMode:E,handleBulkMoveToFolder:ue,handleBulkCreateFolderAndMove:xe,handleBulkRemoveFromFolder:Re,handleBulkDelete:ce,handleBulkArchive:G,handleBulkHardDelete:Te,handleBulkRestore:re,confirmBulkDelete:q},e[73]=I,e[74]=W,e[75]=A,e[76]=q,e[77]=B,e[78]=G,e[79]=xe,e[80]=ce,e[81]=Te,e[82]=ue,e[83]=Re,e[84]=re,e[85]=j,e[86]=g,e[87]=h,e[88]=de):de=e[88],de};function g3(t){return t.enabled}function x3(t){return t.selectedIds.size}function b3(t){return t.selectedIds}function y3(t){return t.scopeKey}function w3(){ms.getState().toggleMode()}function v3(){ms.getState().disable()}function S3(t){const e=tt.c(37),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Ne(T3),d=Ne(I3),u=ss(D3),m=ss(P3),f=ss(A3),p=ss(N3),y=rt(C3),x=rt(k3),k=rt(j3);let w;e[0]!==m||e[1]!==i?(w=C=>{const v=m(C,"New folder");return i(C,v),v},e[0]=m,e[1]=i,e[2]=w):w=e[2];let h;e[3]!==f||e[4]!==y||e[5]!==o||e[6]!==k||e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==p||e[11]!==a||e[12]!==w||e[13]!==x?(h={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:p,createFolderAndStartRename:w,archiveSessions:y,unarchiveSessions:x,deleteSessions:k,bulkDeleteConfirm:o,setBulkDeleteConfirm:l},e[3]=f,e[4]=y,e[5]=o,e[6]=k,e[7]=u,e[8]=n,e[9]=r,e[10]=p,e[11]=a,e[12]=w,e[13]=x,e[14]=h):h=e[14];const g=p3(h);let j;e[15]!==g.bulkCanRemoveFromFolder||e[16]!==g.bulkScopeFolders||e[17]!==g.bulkScopeIsArchived||e[18]!==g.derivedSelectionScope||e[19]!==g.handleBulkArchive||e[20]!==g.handleBulkCreateFolderAndMove||e[21]!==g.handleBulkHardDelete||e[22]!==g.handleBulkMoveToFolder||e[23]!==g.handleBulkRemoveFromFolder||e[24]!==g.handleBulkRestore||e[25]!==g.handleExitSelectionMode||e[26]!==g.selectedIdsSize||e[27]!==g.selectionModeEnabled?(j=g.selectionModeEnabled?s.jsx(f3,{selectedCount:g.selectedIdsSize,scopeKey:g.derivedSelectionScope,scopeFolders:g.bulkScopeFolders,archivedBucket:g.bulkScopeIsArchived,onMoveToFolder:g.handleBulkMoveToFolder,onCreateFolderAndMove:g.handleBulkCreateFolderAndMove,onRemoveFromFolder:g.handleBulkRemoveFromFolder,canRemoveFromFolder:g.bulkCanRemoveFromFolder,onRestore:g.handleBulkRestore,onArchive:g.handleBulkArchive,onDelete:g.handleBulkHardDelete,onDone:g.handleExitSelectionMode}):null,e[15]=g.bulkCanRemoveFromFolder,e[16]=g.bulkScopeFolders,e[17]=g.bulkScopeIsArchived,e[18]=g.derivedSelectionScope,e[19]=g.handleBulkArchive,e[20]=g.handleBulkCreateFolderAndMove,e[21]=g.handleBulkHardDelete,e[22]=g.handleBulkMoveToFolder,e[23]=g.handleBulkRemoveFromFolder,e[24]=g.handleBulkRestore,e[25]=g.handleExitSelectionMode,e[26]=g.selectedIdsSize,e[27]=g.selectionModeEnabled,e[28]=j):j=e[28];let b;e[29]!==g.confirmBulkDelete||e[30]!==o||e[31]!==d||e[32]!==a?(b=s.jsx(ck,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:g.confirmBulkDelete}),e[29]=g.confirmBulkDelete,e[30]=o,e[31]=d,e[32]=a,e[33]=b):b=e[33];let S;return e[34]!==j||e[35]!==b?(S=s.jsxs(s.Fragment,{children:[j,b]}),e[34]=j,e[35]=b,e[36]=S):S=e[36],S}function j3(t){return t.deleteSessions}function k3(t){return t.unarchiveSessions}function C3(t){return t.archiveSessions}function N3(t){return t.removeSessionsFromFolders}function A3(t){return t.addSessionsToFolder}function P3(t){return t.createFolder}function D3(t){return t.foldersMap}function I3(t){return t.setShowDeletionDialog}function T3(t){return t.showDeletionDialog}const nm="oc.sessions.expandedParents.v3",E3=Za(lr()),R3=()=>{try{const t=globalThis.localStorage.getItem(nm);if(t===null)return new Set;const e=E3.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},M3=()=>{const[t,e]=c.useState(R3),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=_g(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(nm,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},O3=t=>{const e=tt.c(22),{childStores:n,sections:r,chatGroup:i,canGrantAccess:o}=t,l=vs(B3),a=vs(F3);let d;e[0]!==i||e[1]!==r?(d=[...r.flatMap(_3),...i?[{key:"activity:chats",group:i}]:[]].map(z3),e[0]=i,e[1]=r,e[2]=d):d=e[2];const u=d;let m;e[3]!==u?(m=new Set(u.flatMap(W3)),e[3]=u,e[4]=m):m=e[4];let f;e[5]!==m?(f=[...m],e[5]=m,e[6]=f):f=e[6];const p=f;let y;e[7]!==n||e[8]!==p.length?(y=j=>p.length>0?n.subscribeBootstrap(j):K3,e[7]=n,e[8]=p.length,e[9]=y):y=e[9];let x;e[10]!==n||e[11]!==p?(x=()=>p.map(j=>`${j}\0${n.getBootstrapState(j)??""}\0${n.getBootstrapFailure(j)??""}\0${n.getInitializationState(j)??""}\0${n.getInitializationFailure(j)??""}`).join(""),e[10]=n,e[11]=p,e[12]=x):x=e[12];const k=c.useSyncExternalStore(y,x,V3);let w;if(e[13]!==o||e[14]!==n||e[15]!==l||e[16]!==u||e[17]!==a){w=new Map;for(const{key:j,archived:b,directories:S}of u){const C=S.find(v=>n.getBootstrapState(v)==="failed"||n.getInitializationState(v)==="failed");if(C){const v=n.getBootstrapState(C)==="failed",E=v?n.getBootstrapFailure(C):n.getInitializationFailure(C);w.set(j,{state:E==="os-permission"?"permission-denied":v?"load-failed":"initialization-failed",directory:C,canGrantAccess:E==="os-permission"&&o})}else{const v=a||!b&&S.length>0&&S.every(E=>n.getBootstrapState(E)==="complete");w.set(j,{state:v?"ready":l==="error"?"load-failed":"loading",directory:v?S[0]??null:null,canGrantAccess:!1})}}e[13]=o,e[14]=n,e[15]=l,e[16]=u,e[17]=a,e[18]=w}else w=e[18];const h=w;let g;return e[19]!==k||e[20]!==h?(g={groupStatusByKey:h,bootstrapSnapshot:k},e[19]=k,e[20]=h,e[21]=g):g=e[21],g};function B3(t){return t.status}function F3(t){return t.hasLoaded}function _3(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function L3(t){return xt(t.directory)}function $3(t){return!!t}function z3(t){const{key:e,group:n}=t;return{key:e,archived:n.isArchivedBucket===!0,directories:Jr(n).map(L3).filter($3)}}function W3(t){return t.directories}function K3(){}function V3(){return""}const U3=5*6e4,H3=[],G3=[],q3=t=>!t.parentID,Y3=t=>{const e=tt.c(311),{topology:n,view:r,actions:i}=t;let o,l,a,d,u;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:d,...u}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=d,e[5]=u):(o=e[1],l=e[2],a=e[3],d=e[4],u=e[5]);const m=ss(X3),f=ss(J3),p=ss(Z3),y=ss(e4),x=r.projectView,{getOrderedGroups:k,setGroupOrderByProject:w,toggleGroup:h,toggleProject:g}=a;let j;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(j={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=j):j=e[8];const b=Rh(j),S=Lg(t4);let C;e[9]!==S||e[10]!==b.archivedSessions||e[11]!==b.sessions||e[12]!==n.availableWorktreesByProject||e[13]!==n.isVSCode||e[14]!==n.projects?(C=Mh(b.sessions,n.projects,n.availableWorktreesByProject,n.isVSCode,b.archivedSessions,S),e[9]=S,e[10]=b.archivedSessions,e[11]=b.sessions,e[12]=n.availableWorktreesByProject,e[13]=n.isVSCode,e[14]=n.projects,e[15]=C):C=e[15];const v=C;let E;e[16]===Symbol.for("react.memo_cache_sentinel")?(E=new Map,e[16]=E):E=e[16];const[R,A]=c.useState(E);let O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O=new Set,e[17]=O):O=e[17];const[B,T]=c.useState(O);let M;e[18]===Symbol.for("react.memo_cache_sentinel")?(M=new Map,e[18]=M):M=e[18];const[L,W]=c.useState(M);let $;e[19]===Symbol.for("react.memo_cache_sentinel")?($=(wt,bt,It)=>{const Lt=It===void 0?7:It;A(Zt=>new Map(Zt).set(wt,bt+Lt))},e[19]=$):$=e[19];const P=$;let D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=wt=>{A(bt=>{if(!bt.has(wt))return bt;const It=new Map(bt);return It.delete(wt),It})},e[20]=D):D=e[20];const I=D,X=Ns(s4),Z=Ns(n4),ne=Ns(r4),ue=Ns(o4);let se;e[21]!==n.isVSCode?(se=!n.isVSCode&&!Zm(),e[21]=n.isVSCode,e[22]=se):se=e[22];const ie=se&&Z==="single",Re=r.sidebarViewMode==="timeline"&&!n.isVSCode,be=X&&!ie&&!Re;let fe;e[23]!==b.pinnedSessionIds||e[24]!==b.rootSessions||e[25]!==b.sessionOrderRanks||e[26]!==be||e[27]!==n.isVSCode?(fe={enabled:be,isVSCode:n.isVSCode,pinnedSessionIds:b.pinnedSessionIds,sessionOrderRanks:b.sessionOrderRanks,sessions:b.rootSessions},e[23]=b.pinnedSessionIds,e[24]=b.rootSessions,e[25]=b.sessionOrderRanks,e[26]=be,e[27]=n.isVSCode,e[28]=fe):fe=e[28];const ke=Oh(fe),[H,J]=c.useState(null),[ce,je]=c.useState(null),[G,we]=c.useState(""),[Te,he]=c.useState(null),[re,ge]=c.useState(null),[q,z]=c.useState(null);let ee;e[29]===Symbol.for("react.memo_cache_sentinel")?(ee=(wt,bt)=>{z({scopeKey:wt,folderId:bt.id,draft:bt.name})},e[29]=ee):ee=e[29];const de=ee;let Y;e[30]===Symbol.for("react.memo_cache_sentinel")?(Y=wt=>{z(bt=>bt?{...bt,draft:wt}:null)},e[30]=Y):Y=e[30];const U=Y;let F;e[31]===Symbol.for("react.memo_cache_sentinel")?(F=()=>z(null),e[31]=F):F=e[31];const V=F,{expandedParents:oe,toggleParent:ae}=M3(),pe=rt(i4);let le;e[32]!==pe?(le=(wt,bt)=>{wt!==rt.getState().currentSessionId&&pe(wt,bt)},e[32]=pe,e[33]=le):le=e[33];const _e=le,Fe=Lu();let Me;e[34]!==b.pinnedSessionIds||e[35]!==b.sessionOrderRanks||e[36]!==v.bySessionId||e[37]!==n.gitBranches||e[38]!==n.isVSCode||e[39]!==n.worktreeMetadata||e[40]!==r.homeDirectory?(Me={homeDirectory:r.homeDirectory,worktreeMetadata:n.worktreeMetadata,pinnedSessionIds:b.pinnedSessionIds,sessionOrderRanks:b.sessionOrderRanks,gitBranches:n.gitBranches,isVSCode:n.isVSCode,sessionOwners:v.bySessionId},e[34]=b.pinnedSessionIds,e[35]=b.sessionOrderRanks,e[36]=v.bySessionId,e[37]=n.gitBranches,e[38]=n.isVSCode,e[39]=n.worktreeMetadata,e[40]=r.homeDirectory,e[41]=Me):Me=e[41];const{buildGroupedSessions:Ae,filterSessionNodesForSearch:Q,buildGroupSearchText:Ce}=u3(Me);let Be;e[42]!==v?(Be={ownership:v},e[42]=v,e[43]=Be):Be=e[43];const{getSessionsForProject:Le,getArchivedSessionsForProject:Je}=Ej(Be);let ot;e:{if(n.isVSCode){ot=null;break e}let wt;e[44]!==b.chatSessions||e[45]!==r.homeDirectory?(wt=$g(r.homeDirectory)??b.chatSessions.map(a4).find(Boolean)??null,e[44]=b.chatSessions,e[45]=r.homeDirectory,e[46]=wt):wt=e[46];const bt=wt;if(!bt){ot=null;break e}let It;if(e[47]!==bt||e[48]!==b.chatSessions){const ls=[bt,...b.chatSessions.map(l4).filter(Boolean)];let fs;e[50]!==ls?(fs=new Set(ls),e[50]=ls,e[51]=fs):fs=e[51],It=Array.from(fs).filter(c4).map(d4),e[47]=bt,e[48]=b.chatSessions,e[49]=It}else It=e[49];const Lt=It;let Zt;if(e[52]!==b.chatSessions||e[53]!==b.childrenMap){let ls;e[55]!==b.childrenMap?(ls=fs=>lo(b.childrenMap,fs),e[55]=b.childrenMap,e[56]=ls):ls=e[56],Zt=b.chatSessions.filter(u4).map(ls),e[52]=b.chatSessions,e[53]=b.childrenMap,e[54]=Zt}else Zt=e[54];let $t;e[57]!==bt||e[58]!==Lt||e[59]!==Zt?($t={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:bt,folderScopeKey:bt,folderScopes:Lt,draftTarget:"chat",sessions:Zt},e[57]=bt,e[58]=Lt,e[59]=Zt,e[60]=$t):$t=e[60],ot=$t}const et=ot;let it;e[61]!==et?(it=et?[et]:H3,e[61]=et,e[62]=it):it=e[62];const ht=it;let st;e[63]!==Ce||e[64]!==Ae||e[65]!==Q||e[66]!==m||e[67]!==Je||e[68]!==Le||e[69]!==ht||e[70]!==n.availableWorktreesByProject||e[71]!==n.gitBranches||e[72]!==n.lastRepoStatus||e[73]!==n.projectRepoStatus||e[74]!==n.projectRootBranches||e[75]!==n.projects||e[76]!==r.hasSessionSearchQuery||e[77]!==r.normalizedSessionSearchQuery?(st={normalizedProjects:n.projects,getSessionsForProject:Le,getArchivedSessionsForProject:Je,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:Ae,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:Q,buildGroupSearchText:Ce,foldersMap:m,standaloneGroups:ht},e[63]=Ce,e[64]=Ae,e[65]=Q,e[66]=m,e[67]=Je,e[68]=Le,e[69]=ht,e[70]=n.availableWorktreesByProject,e[71]=n.gitBranches,e[72]=n.lastRepoStatus,e[73]=n.projectRepoStatus,e[74]=n.projectRootBranches,e[75]=n.projects,e[76]=r.hasSessionSearchQuery,e[77]=r.normalizedSessionSearchQuery,e[78]=st):st=e[78];const{projectSections:mt,groupSearchDataByGroup:kt,sectionsForRender:Pe,flatSectionsForRender:Ge}=Oj(st),at=r.onSearchMatchCountChange;let ze,ft;e[79]!==at?(ze=()=>()=>at(0),ft=[at],e[79]=at,e[80]=ze,e[81]=ft):(ze=e[80],ft=e[81]),c.useEffect(ze,ft);const te=ii(),me=r.useGroupedSections?Pe:Ge;let De;e[82]!==me||e[83]!==r.showInlineArchived?(De=r.showInlineArchived?me:me.map(h4),e[82]=me,e[83]=r.showInlineArchived,e[84]=De):De=e[84];const K=De;let Se;e[85]!==Ge?(Se=wt=>Ge.find(It=>It.project.id===wt)?.groups.find(p4)?.folderScopes??[],e[85]=Ge,e[86]=Se):Se=e[86];const Ve=Se;let Xe;e[87]!==y||e[88]!==b.hasAuthoritativeGlobalSessions||e[89]!==p||e[90]!==m||e[91]!==v||e[92]!==n.projects||e[93]!==r.isSessionsLoading||e[94]!==r.isWorktreeTopologyLoading||e[95]!==r.unresolvedWorktreeProjectPaths?(Xe={enabled:!0,normalizedProjects:n.projects,ownership:v,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:b.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:m,createFolder:p,addSessionToFolder:y},e[87]=y,e[88]=b.hasAuthoritativeGlobalSessions,e[89]=p,e[90]=m,e[91]=v,e[92]=n.projects,e[93]=r.isSessionsLoading,e[94]=r.isWorktreeTopologyLoading,e[95]=r.unresolvedWorktreeProjectPaths,e[96]=Xe):Xe=e[96],Cj(Xe);const{github:nt}=wn(),Ze=In(g4),gt=In(x4),We=Vs(b4),Et=Vs(y4),Ft=Vs(w4);let Ie;e[97]===Symbol.for("react.memo_cache_sentinel")?(Ie=new Set,e[97]=Ie):Ie=e[97];const yt=c.useRef(Ie);let At;e[98]!==We||e[99]!==nt||e[100]!==gt||e[101]!==Ze||e[102]!==mt||e[103]!==x.collapsedProjects||e[104]!==Ft||e[105]!==Et||e[106]!==n.gitBranches?(At=()=>{if(!nt||!gt||!Ze?.connected)return;const wt=new Map,bt=Date.now();mt.forEach(It=>{x.collapsedProjects.has(It.project.id)||It.groups.forEach(Lt=>{if(Lt.isArchivedBucket||Lt.isMain)return;const Zt=xt(Lt.directory??null),$t=Lt.branch?.trim()||n.gitBranches.get(Zt||"")?.trim();if(!Zt||!$t)return;const ls=ei(Zt,$t),fs=Vs.getState().entries[ls],Vn=fs?.status?.pr?.state==="closed"||fs?.status?.pr?.state==="merged",oo=`${Zt}::${$t}`,yi=Math.max(fs?.lastRefreshAt??0,fs?.lastDiscoveryPollAt??0),io=!!(fs?.isInitialStatusResolved&&(!fs.status?.pr||Vn)&&(!yt.current.has(oo)||bt-yi>=U3));(!fs||!fs.isInitialStatusResolved||io)&&(io&&yt.current.add(oo),wt.set(ls,{directory:Zt,branch:$t}))})}),wt.forEach((It,Lt)=>{We(Lt),Et(Lt,{...It,remoteName:null,canShow:!0,github:nt,githubAuthChecked:gt,githubConnected:Ze.connected})}),wt.size&&Ft([...wt.values()],{silent:!0,markInitialResolved:!0})},e[98]=We,e[99]=nt,e[100]=gt,e[101]=Ze,e[102]=mt,e[103]=x.collapsedProjects,e[104]=Ft,e[105]=Et,e[106]=n.gitBranches,e[107]=At):At=e[107];const He=Ze?.connected;let Ue;e[108]!==We||e[109]!==nt||e[110]!==gt||e[111]!==mt||e[112]!==x.collapsedProjects||e[113]!==Ft||e[114]!==Et||e[115]!==He||e[116]!==n.gitBranches?(Ue=[We,nt,gt,He,mt,x.collapsedProjects,Ft,Et,n.gitBranches],e[108]=We,e[109]=nt,e[110]=gt,e[111]=mt,e[112]=x.collapsedProjects,e[113]=Ft,e[114]=Et,e[115]=He,e[116]=n.gitBranches,e[117]=Ue):Ue=e[117],c.useEffect(At,Ue);let ve;e[118]!==b.orderedSessions?(ve=new Map(b.orderedSessions.map(v4)),e[118]=b.orderedSessions,e[119]=ve):ve=e[119];const Qe=ve;let qe;if(e[120]!==k||e[121]!==K){let wt;e[123]!==k?(wt=bt=>{const It=k(bt.project.id,bt.groups);return It===bt.groups?bt:{...bt,groups:It}},e[123]=k,e[124]=wt):wt=e[124],qe=K.map(wt),e[120]=k,e[121]=K,e[122]=qe}else qe=e[122];const Ye=qe;let dt;if(e[125]!==b.childrenMap||e[126]!==v.bySessionId||e[127]!==ke||e[128]!==n.availableWorktreesByProject||e[129]!==n.gitBranches||e[130]!==n.projects||e[131]!==r.hasSessionSearchQuery||e[132]!==r.homeDirectory||e[133]!==r.normalizedSessionSearchQuery){let wt;e[135]!==b.childrenMap?(wt=$t=>[$t.id,lo(b.childrenMap,$t)],e[135]=b.childrenMap,e[136]=wt):wt=e[136];const bt=new Map(ke.map(wt)),It=[...bt.values()],Lt=[];for(;It.length>0;){const $t=It.pop();if(!$t)break;Lt.push($t.session),It.push(...$t.children)}const Zt=Cl({sessions:Lt,projects:n.projects,ownerBySessionId:v.bySessionId,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,hideBranchMatchingProjectLabel:!0});dt=Bh({sessions:ke,getSessionLocation:$t=>Zt.get($t)??null,getSessionNode:$t=>bt.get($t.id)??lo(b.childrenMap,$t),query:r.hasSessionSearchQuery?r.normalizedSessionSearchQuery:""}),e[125]=b.childrenMap,e[126]=v.bySessionId,e[127]=ke,e[128]=n.availableWorktreesByProject,e[129]=n.gitBranches,e[130]=n.projects,e[131]=r.hasSessionSearchQuery,e[132]=r.homeDirectory,e[133]=r.normalizedSessionSearchQuery,e[134]=dt}else dt=e[134];const Ot=dt;let zt;e:{if(!Re){zt=G3;break e}let wt;e[137]!==b.rootSessions?(wt=new Set(b.rootSessions.map(S4)),e[137]=b.rootSessions,e[138]=wt):wt=e[138];const bt=wt;let It;if(e[139]!==b.childrenMap||e[140]!==b.orderedSessions||e[141]!==v.bySessionId||e[142]!==bt||e[143]!==n.availableWorktreesByProject||e[144]!==n.gitBranches||e[145]!==n.projectRootBranches||e[146]!==n.projects||e[147]!==r.hasSessionSearchQuery||e[148]!==r.homeDirectory||e[149]!==r.normalizedSessionSearchQuery){let Lt;e[151]!==bt?(Lt=ls=>bt.has(ls.id)&&!ls.time?.archived,e[151]=bt,e[152]=Lt):Lt=e[152];const Zt=b.orderedSessions.filter(Lt),$t=Cl({sessions:Zt,projects:n.projects,ownerBySessionId:v.bySessionId,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,rootBranchByProjectId:n.projectRootBranches,hideBranchMatchingProjectLabel:!1});It=Fh({sessions:Zt,getSessionLocation:ls=>$t.get(ls)??null,getSessionNode:ls=>({...lo(b.childrenMap,ls),children:[],worktree:$t.get(ls.id)?.worktree??null}),query:r.hasSessionSearchQuery?r.normalizedSessionSearchQuery:""}),e[139]=b.childrenMap,e[140]=b.orderedSessions,e[141]=v.bySessionId,e[142]=bt,e[143]=n.availableWorktreesByProject,e[144]=n.gitBranches,e[145]=n.projectRootBranches,e[146]=n.projects,e[147]=r.hasSessionSearchQuery,e[148]=r.homeDirectory,e[149]=r.normalizedSessionSearchQuery,e[150]=It}else It=e[150];zt=It}const Kt=zt;let Gt;e[153]===Symbol.for("react.memo_cache_sentinel")?(Gt=Wd(),e[153]=Gt):Gt=e[153];let Bt;e[154]!==et||e[155]!==te||e[156]!==Ye?(Bt={childStores:te,sections:Ye,chatGroup:et,canGrantAccess:Gt},e[154]=et,e[155]=te,e[156]=Ye,e[157]=Bt):Bt=e[157];const{groupStatusByKey:Jt,bootstrapSnapshot:Vt}=O3(Bt);let Wt;e[158]!==mt||e[159]!==ne||e[160]!==ie||e[161]!==r.activeProjectId?(Wt=null,ie&&(mt.some(wt=>wt.project.id===ne)?Wt=ne:mt.some(wt=>wt.project.id===r.activeProjectId)?Wt=r.activeProjectId:Wt=mt[0]?.project.id??null),e[158]=mt,e[159]=ne,e[160]=ie,e[161]=r.activeProjectId,e[162]=Wt):Wt=e[162];const _t=ie&&!r.useGroupedSections?20:void 0,Xt=Re?u.openProjectEditDialog:void 0;let Ct;e[163]!==i.startSessionWorktreeMenuLoad||e[164]!==o||e[165]!==b.pinnedSessionIds||e[166]!==re||e[167]!==G||e[168]!==H||e[169]!==ce||e[170]!==oe||e[171]!==q||e[172]!==kt||e[173]!==l||e[174]!==x.collapsedGroups||e[175]!==d.allowReselect||e[176]!==d.onSessionSelected||e[177]!==d.resetSessionSearch||e[178]!==Qe||e[179]!==_t||e[180]!==Xt||e[181]!==ae||e[182]!==r.activeProjectId||e[183]!==r.hasSessionSearchQuery||e[184]!==r.hideDirectoryControls||e[185]!==r.mobileVariant||e[186]!==r.normalizedSessionSearchQuery?(Ct={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:kt,collapsedGroups:x.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:b.pinnedSessionIds,sessionOrderIndex:Qe,expandedParents:oe,editingId:H,editingRowKey:ce,editTitle:G,sessionBatchSize:_t,setEditingId:J,setEditingRowKey:je,setEditTitle:we,toggleParent:ae,allowReselect:d.allowReselect,onSessionSelected:d.onSessionSelected,resetSessionSearch:d.resetSessionSearch,deleteSessionConfirm:re,setDeleteSessionConfirm:ge,startFolderRename:de,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,onEditProject:Xt,folderRename:q,setFolderRenameDraft:U,clearFolderRename:V},e[163]=i.startSessionWorktreeMenuLoad,e[164]=o,e[165]=b.pinnedSessionIds,e[166]=re,e[167]=G,e[168]=H,e[169]=ce,e[170]=oe,e[171]=q,e[172]=kt,e[173]=l,e[174]=x.collapsedGroups,e[175]=d.allowReselect,e[176]=d.onSessionSelected,e[177]=d.resetSessionSearch,e[178]=Qe,e[179]=_t,e[180]=Xt,e[181]=ae,e[182]=r.activeProjectId,e[183]=r.hasSessionSearchQuery,e[184]=r.hideDirectoryControls,e[185]=r.mobileVariant,e[186]=r.normalizedSessionSearchQuery,e[187]=Ct):Ct=e[187];const Tt=Ct;let is;e[188]!==u.openNewSessionDraft||e[189]!==u.setActiveProjectIdOnly||e[190]!==u.setSessionSwitcherOpen||e[191]!==h?(is={showMoreGroupSessions:P,resetGroupSessionLimit:I,setActiveProjectIdOnly:u.setActiveProjectIdOnly,setSessionSwitcherOpen:u.setSessionSwitcherOpen,openNewSessionDraft:u.openNewSessionDraft,onToggleCollapsedGroup:h},e[188]=u.openNewSessionDraft,e[189]=u.setActiveProjectIdOnly,e[190]=u.setSessionSwitcherOpen,e[191]=h,e[192]=is):is=e[192];const $s=is;let cs;if(e[193]!==et||e[194]!==te||e[195]!==b.hasAuthoritativeGlobalSessions||e[196]!==Ye){cs=new Map;for(const wt of Ye)for(const bt of wt.groups){const It=Zn(wt.project.id,bt.directory);if(!It)continue;const Lt=Jr(bt),Zt=cs.get(It),$t=[...new Set([...Zt?.scopeKeys??[],...Lt.map(j4)])],ls=b.hasAuthoritativeGlobalSessions&&Lt.every(fs=>{const Vn=xt(fs.directory);return!Vn||te.getBootstrapState(Vn)==="complete"});cs.set(It,{scopeKeys:$t,complete:(Zt?.complete??!0)&&ls})}if(et){let wt;e[198]!==et.directory?(wt=Zn(null,et.directory),e[198]=et.directory,e[199]=wt):wt=e[199];const bt=wt;if(bt){let It;e[200]!==et?(It=Jr(et).map(k4),e[200]=et,e[201]=It):It=e[201];let Lt;e[202]!==b.hasAuthoritativeGlobalSessions||e[203]!==It?(Lt={scopeKeys:It,complete:b.hasAuthoritativeGlobalSessions},e[202]=b.hasAuthoritativeGlobalSessions,e[203]=It,e[204]=Lt):Lt=e[204],cs.set(bt,Lt)}}e[193]=et,e[194]=te,e[195]=b.hasAuthoritativeGlobalSessions,e[196]=Ye,e[197]=cs}else cs=e[197];const ps=cs;let fn;e[205]!==L||e[206]!==R?(fn=new Map([...R,...L]),e[205]=L,e[206]=R,e[207]=fn):fn=e[207];const nn=fn,mn=r.hasSessionSearchQuery?"search":"normal",vn=Re?"timeline":"projects",ks=X&&!ie&&!Re,rn=ie&&!Re,zs=ie&&!r.useGroupedSections?20:void 0;let Ws;e[208]!==et||e[209]!==B||e[210]!==f||e[211]!==b.pinnedSessionIds||e[212]!==oe||e[213]!==ps||e[214]!==m||e[215]!==kt||e[216]!==Jt||e[217]!==Ye||e[218]!==mt||e[219]!==x.collapsedGroups||e[220]!==x.collapsedProjects||e[221]!==Ot||e[222]!==Wt||e[223]!==Qe||e[224]!==mn||e[225]!==vn||e[226]!==ks||e[227]!==rn||e[228]!==zs||e[229]!==Kt||e[230]!==r.activeProjectId||e[231]!==r.hideDirectoryControls||e[232]!==r.normalizedSessionSearchQuery||e[233]!==r.showOnlyMainWorkspace||e[234]!==nn?(Ws=Rk({mode:mn,viewMode:vn,sections:Ye,authoritativeSections:mt,chatGroup:et,recentSections:Ot,timelineItems:Kt,showRecentSection:ks,foldersMap:m,groupSearchDataByGroup:kt,normalizedQuery:r.normalizedSessionSearchQuery,collapsedProjects:x.collapsedProjects,collapsedGroups:x.collapsedGroups,collapsedFolders:f,collapsedActivities:B,expandedParents:oe,visibleCountByContainer:nn,pinnedSessionIds:b.pinnedSessionIds,sessionOrderIndex:Qe,groupStatusByKey:Jt,folderAuthorityByOwner:ps,activeProjectId:r.activeProjectId,singleProjectMode:rn,singleProjectId:Wt,showOnlyMainWorkspace:r.showOnlyMainWorkspace,hideDirectoryControls:r.hideDirectoryControls,sessionBatchSize:zs}),e[208]=et,e[209]=B,e[210]=f,e[211]=b.pinnedSessionIds,e[212]=oe,e[213]=ps,e[214]=m,e[215]=kt,e[216]=Jt,e[217]=Ye,e[218]=mt,e[219]=x.collapsedGroups,e[220]=x.collapsedProjects,e[221]=Ot,e[222]=Wt,e[223]=Qe,e[224]=mn,e[225]=vn,e[226]=ks,e[227]=rn,e[228]=zs,e[229]=Kt,e[230]=r.activeProjectId,e[231]=r.hideDirectoryControls,e[232]=r.normalizedSessionSearchQuery,e[233]=r.showOnlyMainWorkspace,e[234]=nn,e[235]=Ws):Ws=e[235];const as=Ws;let Gs,gs;e[236]!==at||e[237]!==as.searchMatchCount?(Gs=()=>{at(as.searchMatchCount)},gs=[at,as.searchMatchCount],e[236]=at,e[237]=as.searchMatchCount,e[238]=Gs,e[239]=gs):(Gs=e[238],gs=e[239]),c.useEffect(Gs,gs);let us;e[240]!==B||e[241]!==H||e[242]!==Te||e[243]!==L||e[244]!==R?(us={editingId:H,openSidebarMenuKey:Te,setOpenSidebarMenuKey:he,visibleSessionCountByGroup:R,collapsedActivityKeys:B,setCollapsedActivityKeys:T,visibleActivityCountByKey:L,setVisibleActivityCountByKey:W},e[240]=B,e[241]=H,e[242]=Te,e[243]=L,e[244]=R,e[245]=us):us=e[245];let qs;e[246]!==Tt||e[247]!==Ye||e[248]!==mt||e[249]!==as||e[250]!==ie||e[251]!==us||e[252]!==n.projectRepoStatus||e[253]!==r.emptyState||e[254]!==r.searchEmptyState?(qs={rowModel:as,sectionsForRender:Ye,projectSections:mt,singleProjectMode:ie,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,state:us,groupProps:Tt},e[246]=Tt,e[247]=Ye,e[248]=mt,e[249]=as,e[250]=ie,e[251]=us,e[252]=n.projectRepoStatus,e[253]=r.emptyState,e[254]=r.searchEmptyState,e[255]=qs):qs=e[255];const Sn=qs;let Ys;e[256]!==o||e[257]!==Re||e[258]!==r.hasSessionSearchQuery||e[259]!==r.hideDirectoryControls||e[260]!==r.homeDirectory||e[261]!==r.mobileVariant||e[262]!==r.projectSortOrder||e[263]!==r.stickyZoneHeaders?(Ys={homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,hideDirectoryControls:r.hideDirectoryControls,stickyZoneHeaders:r.stickyZoneHeaders,mobileVariant:r.mobileVariant,alwaysShowActions:o,projectSortOrder:r.projectSortOrder,timelineView:Re},e[256]=o,e[257]=Re,e[258]=r.hasSessionSearchQuery,e[259]=r.hideDirectoryControls,e[260]=r.homeDirectory,e[261]=r.mobileVariant,e[262]=r.projectSortOrder,e[263]=r.stickyZoneHeaders,e[264]=Ys):Ys=e[264];const hn=Ys;let on;e[265]!==$s||e[266]!==u.openNewSessionDraft||e[267]!==u.openNewWorktreeDialog||e[268]!==u.openProjectEditDialog||e[269]!==u.openWorktreesPage||e[270]!==u.removeProject||e[271]!==u.renderProjectStatusIndicator||e[272]!==u.reorderProjects||e[273]!==u.setActiveProjectIdOnly||e[274]!==u.setSessionSwitcherOpen||e[275]!==w||e[276]!==ue||e[277]!==g?(on={group:$s,toggleProject:g,setActiveProjectIdOnly:u.setActiveProjectIdOnly,setSessionSwitcherOpen:u.setSessionSwitcherOpen,openNewSessionDraft:u.openNewSessionDraft,openNewWorktreeDialog:u.openNewWorktreeDialog,openWorktreesPage:u.openWorktreesPage,openProjectEditDialog:u.openProjectEditDialog,removeProject:u.removeProject,reorderProjects:u.reorderProjects,setGroupOrderByProject:w,renderProjectStatusIndicator:u.renderProjectStatusIndicator,setSingleProjectId:ue},e[265]=$s,e[266]=u.openNewSessionDraft,e[267]=u.openNewWorktreeDialog,e[268]=u.openProjectEditDialog,e[269]=u.openWorktreesPage,e[270]=u.removeProject,e[271]=u.renderProjectStatusIndicator,e[272]=u.reorderProjects,e[273]=u.setActiveProjectIdOnly,e[274]=u.setSessionSwitcherOpen,e[275]=w,e[276]=ue,e[277]=g,e[278]=on):on=e[278];const jn=on;let N;e[279]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(vj,{}),e[279]=N):N=e[279];let ye;e[280]!==i.initialActiveSessionByProject||e[281]!==i.openNewSessionDraft||e[282]!==i.persistActiveSessionByProject||e[283]!==i.setSessionSwitcherOpen||e[284]!==v.bySessionId||e[285]!==mt||e[286]!==_e||e[287]!==r.activeProjectId||e[288]!==r.mobileVariant?(ye=s.jsx(Dj,{projectSections:mt,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:v.bySessionId,handleSessionSelect:_e}),e[280]=i.initialActiveSessionByProject,e[281]=i.openNewSessionDraft,e[282]=i.persistActiveSessionByProject,e[283]=i.setSessionSwitcherOpen,e[284]=v.bySessionId,e[285]=mt,e[286]=_e,e[287]=r.activeProjectId,e[288]=r.mobileVariant,e[289]=ye):ye=e[289];let $e;e[290]!==b.orderedSessions||e[291]!==Fe||e[292]!==ke?($e=s.jsx(zj,{sortedSessions:b.orderedSessions,recentSessions:ke,prefetchSession:Fe}),e[290]=b.orderedSessions,e[291]=Fe,e[292]=ke,e[293]=$e):$e=e[293];const lt=H!==null;let Pt;e[294]!==Ve||e[295]!==lt?(Pt=s.jsx(S3,{getFolderScopesForProject:Ve,isInlineEditing:lt,startFolderRename:de}),e[294]=Ve,e[295]=lt,e[296]=Pt):Pt=e[296];let Dt;e[297]!==jn||e[298]!==Sn||e[299]!==hn?(Dt=s.jsx(d3,{model:Sn,view:hn,actions:jn}),e[297]=jn,e[298]=Sn,e[299]=hn,e[300]=Dt):Dt=e[300];let pt;e[301]!==as.selectionDescendantIds||e[302]!==as.selectionEntries||e[303]!==as.sessionById||e[304]!==Pt||e[305]!==Dt?(pt=s.jsxs(o2,{entries:as.selectionEntries,descendantIds:as.selectionDescendantIds,sessionsById:as.sessionById,children:[Pt,Dt]}),e[301]=as.selectionDescendantIds,e[302]=as.selectionEntries,e[303]=as.sessionById,e[304]=Pt,e[305]=Dt,e[306]=pt):pt=e[306];let qt;return e[307]!==ye||e[308]!==$e||e[309]!==pt?(qt=s.jsxs(s.Fragment,{children:[N,ye,$e,pt]}),e[307]=ye,e[308]=$e,e[309]=pt,e[310]=qt):qt=e[310],qt},Q3=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(Y3,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function X3(t){return t.foldersMap}function J3(t){return t.collapsedFolderIds}function Z3(t){return t.createFolder}function e4(t){return t.addSessionToFolder}function t4(t){return t.projects}function s4(t){return t.showRecentSection}function n4(t){return t.projectDisplayMode}function r4(t){return t.singleProjectId}function o4(t){return t.setSingleProjectId}function i4(t){return t.setCurrentSession}function a4(t){return Ga(t.directory)}function l4(t){return xt(t.directory??null)}function c4(t){return!!t}function d4(t){return{scopeKey:t,directory:t}}function u4(t){return!t.time?.archived&&q3(t)}function f4(t){return t.isArchivedBucket}function m4(t){return!t.isArchivedBucket}function h4(t){return t.groups.some(f4)?{...t,groups:t.groups.filter(m4)}:t}function p4(t){return!t.isArchivedBucket}function g4(t){return t.status}function x4(t){return t.hasChecked}function b4(t){return t.ensureEntry}function y4(t){return t.setParams}function w4(t){return t.refreshTargets}function v4(t,e){return[t.id,e]}function S4(t){return t.id}function j4(t){return t.scopeKey}function k4(t){return t.scopeKey}const rm=(t,e,n)=>{const r=new Set;for(const i of t){const o=xt(i.path);o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=xt(o.path);l&&r.add(l)}return r},dd="oc.sessions.activeSessionByProject",C4=[],N4=nf(lr(),lr().min(1).catch("")),A4=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{Hi("react.session_sidebar_render"),Ts("ui.session_sidebar.render"),Ts(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Ts(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=Nt(),[a,d]=c.useState(!1),[u,m]=c.useState(""),f=c.useCallback(()=>{m(""),d(!1)},[]),[p,y]=c.useState(0),x=c.useRef(null),k=c.useRef(null),[w,h]=c.useState(null),g=c.useMemo(()=>_o(),[]),[j,b]=c.useState(new Map),S=Ne(Ie=>Ie.isNewWorktreeDialogOpen),C=Ne(Ie=>Ie.setNewWorktreeDialogOpen),[v,E]=c.useState(!1),R=c.useMemo(()=>{try{const Ie=g.getItem(dd);if(!Ie)return new Map;const yt=N4.safeParse(JSON.parse(Ie));if(!yt.success)return new Map;const At=new Map;return Object.entries(yt.data).forEach(([He,Ue])=>{Ue&&At.set(He,Ue)}),At}catch{return new Map}},[g]),A=c.useCallback(Ie=>{try{g.setItem(dd,JSON.stringify(Object.fromEntries(Ie.entries())))}catch{}},[g]),[O,B]=c.useState(new Map),T=os(Ie=>Ie.homeDirectory),M=Ut(Ie=>Ie.projects),L=Ut(Ie=>Ie.activeProjectId),W=Ut(Ie=>Ie.removeProject),$=Ut(Ie=>Ie.setActiveProjectIdOnly),P=Ut(Ie=>Ie.updateProjectMeta),D=Ut(Ie=>Ie.reorderProjects),I=Ne(Ie=>Ie.setSettingsDialogOpen),X=Ne(Ie=>Ie.toggleHelpDialog),Z=Ne(Ie=>Ie.setAboutDialogOpen),ne=Ne(Ie=>Ie.setSessionSwitcherOpen),ue=Ne(Ie=>Ie.setScheduledTasksDialogOpen),se=Ne(Ie=>Ie.setArchivePageOpen),xe=Ne(Ie=>Ie.setUsageStatsPageOpen),ie=Ne(Ie=>Ie.setWorktreesPageProjectId),Re=Ne(Ie=>Ie.openMultiRunLauncher),be=Ne(Ie=>Ie.notifyOnSubtasks),fe=c.useMemo(()=>u.trim().toLowerCase(),[u]),ke=fe.length>0;H0({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:k,sessionSearchContainerRef:x});const H=Du(t),J=c.useMemo(()=>_n(),[]),ce=rt(Ie=>Ie.setCurrentSession),je=rt(Ie=>Ie.worktreeMetadata),G=rt(Ie=>Ie.availableWorktreesByProject),we=rt(Ie=>Ie.openNewSessionDraft),Te=c.useMemo(()=>rm(M,G,{includeWorktrees:!J}),[G,J,M]),he=c.useCallback(Ie=>{Ne.getState().closeMainSurfaces(),we(Ie),J&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[J,we]),re=Kr(ar(Ie=>({checkForUpdates:Ie.checkForUpdates,available:Ie.available,runtimeType:Ie.runtimeType,info:Ie.info,downloading:Ie.downloading,downloaded:Ie.downloaded,progress:Ie.progress,error:Ie.error,downloadUpdate:Ie.downloadUpdate,restartToUpdate:Ie.restartToUpdate}))),ge=Qt(),q=c.useMemo(()=>`${ge}|${M.map(Ie=>`${Ie.id}:${xt(Ie.path)??""}`).join("|")}`,[M,ge]),[z,ee]=c.useState(J?q:null),[de,Y]=c.useReducer(Ie=>Ie+1,0),U=!J&&z!==q,[F,V]=c.useState(new Set),oe=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let Ie=!1;return(async()=>{const At=ge,He=Ut.getState().projects;if(rt.setState({worktreeDiscoveryByProject:new Map(He.map(Bt=>[xt(Bt.path)??Bt.path,"loading"]))}),He.length===0||J){Ie||(oe.current={runtimeKey:null,revision:0,worktreesByProject:new Map},V(new Set),ee(q));return}const Ue=rt.getState().availableWorktreesByProject,ve=ul({rawWorktreesByProjectRef:oe,publishedWorktreesByProject:Ue,runtimeKey:At}),Qe=ve.revision,qe=new Map(ve.worktreesByProject),Ye=new Set,dt=3;let Ot=0;const zt=Array.from({length:dt},async()=>{for(;;){const Bt=Ot;if(Ot+=1,Bt>=He.length)return;const Jt=He[Bt],Vt=xt(Jt.path);if(Vt)try{const Wt=await na(async()=>Tn.getState().directories.get(Vt)?.isGitRepo??await lu(Vt)?$l({id:Jt.id,path:Vt}):null);if(Wt===null){qe.delete(Vt);continue}if(Ie)return;Wt.length===0?qe.delete(Vt):qe.set(Vt,Wt)}catch{Ye.add(Vt)}}});if(await Promise.all(zt),Ie||Qt()!==At)return;const Kt=new Set(He.map(Bt=>xt(Bt.path)).filter(Boolean));for(const Bt of qe.keys())Kt.has(Bt)||qe.delete(Bt);G2({rawWorktreesByProjectRef:oe,runtimeKey:At,capturedRevision:Qe,nextRawWorktreesByProject:qe,publishedWorktreesByProject:Ue,partitionWorktreesByRegisteredProject:Ll,projects:He,worktreeMapsEqual:_l,recordWorktreesSeen:ad,publishTopology:Bt=>{rt.setState(Bt)},requestRediscovery:()=>{Y()},now:()=>Date.now()})&&(V(Ye),rt.setState({worktreeDiscoveryByProject:new Map(He.map(Bt=>{const Jt=xt(Bt.path)??Bt.path;return[Jt,Ye.has(Jt)?"error":"ready"]}))}),ee(q))})(),()=>{Ie=!0}},[J,q,ge,de]);const ae=c.useMemo(()=>xn(),[]),{isTablet:pe}=$n(),le=e||pe,_e=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),Fe=c.useMemo(()=>M.find(Ie=>Ie.id===w)??null,[M,w]),Me=c.useCallback(Ie=>{w&&P(w,{label:Ie.label,icon:Ie.icon,color:Ie.color,iconBackground:Ie.iconBackground,defaultAgent:Ie.defaultAgent??null,defaultModel:Ie.defaultModel??null,defaultVariant:Ie.defaultVariant??null})},[w,P]),Ae=c.useCallback(()=>{C(!0)},[C]),Q=c.useCallback(()=>{const Ie=Kr.getState();if(Ie.available&&Ie.info){E(!0);return}re.checkForUpdates().then(()=>{const{available:yt,error:At}=Kr.getState();if(At){Ke.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:At});return}if(!yt){Ke.success(l("sessions.sidebar.updateCheck.latestVersion"));return}E(!0)})},[l,re]),Ce=c.useCallback(()=>{e&&ne(!1),I(!0)},[e,ne,I]),Be=re.available&&(re.runtimeType==="desktop"||re.runtimeType==="web"),Le=c.useCallback(()=>{un.requestDirectoryDialog()},[]),Je=c.useMemo(()=>M.flatMap(Ie=>{const yt=xt(Ie.path);return yt?[{id:Ie.id,path:Ie.path,label:Ie.label,normalizedPath:yt,icon:Ie.icon??void 0,color:Ie.color??void 0,iconImage:Ie.iconImage??void 0,iconBackground:Ie.iconBackground??void 0,addedAt:Ie.addedAt,lastOpenedAt:Ie.lastOpenedAt,sidebarCollapsed:Ie.sidebarCollapsed}]:[]}),[M]),ot=c.useMemo(()=>Je.map(Ie=>Ie.normalizedPath),[Je]),et=zg(t?ot:C4);ej({enabled:t,normalizedProjects:Je,gitRepoStatus:et,setProjectRepoStatus:b,setProjectRootBranches:B});const it=rt(Ie=>Ie.isLoading),ht=c.useRef(!1);L&&j.has(L)&&(ht.current=!!j.get(L));const st=Ns(Ie=>Ie.showArchivedSessions),mt=Ns(Ie=>Ie.projectSortOrder),kt=Ns(Ie=>Ie.sidebarViewMode),Pe=Ut(Ie=>Ie.manualProjectOrder),Ge={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:pe,projects:M,activeProjectId:L,manualProjectOrder:Pe,worktreeMetadata:je,availableWorktreesByProject:G,gitBranches:H,gitRepoStatus:et,updateStore:re,showArchivedSessions:st,projectSortOrder:mt,projectRepoStatus:j,projectRootBranches:O,resolvedWorktreeTopologyKey:z,unresolvedWorktreeProjectPaths:F,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:w,updateDialogOpen:v},at=c.useRef(null),ze=at.current;if(ze){let Ie=!1;for(const yt of Object.keys(Ge))Object.is(ze[yt],Ge[yt])||(Ts(`ui.session_sidebar.source.${yt}`),Ie=!0);Ie||Ts("ui.session_sidebar.source.parent_or_context")}at.current=Ge;const ft=c.useMemo(()=>_h(Je,mt,Pe),[Je,mt,Pe]),te=Q0({isVSCode:J,projects:ft}),me=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),De=J&&st,K=!J,Se=J?"projects":kt,Ve=Se==="projects",Ze=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",gt="h-4.5 w-4.5",We=c.useCallback(()=>{e&&ne(!1),Re()},[e,Re,ne]),Et=c.useMemo(()=>({projects:M,getCurrentProjects:()=>Ut.getState().projects,rawWorktreesByProjectRef:oe,getPublishedWorktreesByProject:()=>rt.getState().availableWorktreesByProject,resolveProject:Ie=>Xi(Ie),listProjectWorktrees:$l,partitionWorktreesByRegisteredProject:Ll,worktreeMapsEqual:_l,recordWorktreesSeen:ad,publishTopology:Ie=>{rt.setState(Ie)},getRuntimeKey:Qt,now:()=>Date.now()}),[M]),Ft=c.useCallback(Ie=>{const yt=Zf(Ie,{projects:M,resolveProject:Xi});return H2(Ie,{...Et,projectRootBranch:yt?O.get(yt.id)??null:null})},[O,M,Et]);return c.useEffect(()=>{if(!J)return Wn(Ie=>{if(Ie.type==="session-created"){Y();return}if(Ie.type==="worktree-changed")for(const yt of Wg(Ie.directories)){const At=xt(yt.path),He=Qt(),Ue=ve=>{!At||Qt()!==He||rt.setState(Qe=>({worktreeDiscoveryByProject:new Map(Qe.worktreeDiscoveryByProject).set(At,ve)}))};Ue("loading"),Xf(yt,null,Et).then(()=>{!At||Qt()!==He||(Ue("ready"),V(ve=>{if(!ve.has(At))return ve;const Qe=new Set(ve);return Qe.delete(At),Qe}))}).catch(()=>{!At||Qt()!==He||(Ue("error"),V(ve=>new Set(ve).add(At)))})}})},[J,Et]),s.jsx(aa,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:x,className:Ee("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[s.jsx(ij,{hideDirectoryControls:i,showProjectDisplayControls:!J,showRecentControls:!J,handleOpenDirectoryDialog:Le,onOpenScheduled:()=>{e&&ne(!1),ue(!0)},onOpenMultiRun:We,canOpenMultiRun:M.length>0,onOpenArchive:()=>{e&&ne(!1),se(!0)},headerActionIconClass:gt,headerActionButtonClass:Ze,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:k,sessionSearchQuery:u,setSessionSearchQuery:m,hasSessionSearchQuery:ke,searchMatchCount:p,collapseAllProjects:te.actions.collapseAllProjects,expandAllProjects:te.actions.expandAllProjects}),s.jsx(Q3,{topology:{projects:ft,availableWorktreesByProject:G,knownDirectories:Te,isVSCode:J,worktreeMetadata:je,gitBranches:H,projectRepoStatus:j,projectRootBranches:O,lastRepoStatus:ht.current},view:{isVisible:t,hasSessionSearchQuery:ke,normalizedSessionSearchQuery:fe,activeProjectId:L,showInlineArchived:De,useGroupedSections:K,homeDirectory:T,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:ae,stickyZoneHeaders:Ve,projectSortOrder:mt,sidebarViewMode:Se,emptyState:_e,searchEmptyState:me,isSessionsLoading:it,isWorktreeTopologyLoading:U,unresolvedWorktreeProjectPaths:F,projectView:te.state,onSearchMatchCountChange:y},actions:{rowActions:{allowReselect:r,onSessionSelected:n,resetSessionSearch:f},alwaysShowActions:le,notifyOnSubtasks:be,setActiveProjectIdOnly:$,setSessionSwitcherOpen:ne,openNewSessionDraft:he,openNewWorktreeDialog:Ae,openWorktreesPage:Ie=>{e&&ne(!1),ie(Ie)},openProjectEditDialog:h,removeProject:W,reorderProjects:D,startSessionWorktreeMenuLoad:Ft,initialActiveSessionByProject:R,persistActiveSessionByProject:A,projectViewActions:te.actions}}),s.jsx(yj,{onOpenSettings:Ce,onOpenUsage:()=>xe(!0),onOpenShortcuts:X,onOpenAbout:()=>Z(!0),onOpenUpdate:Q,showRuntimeButtons:!J,showUpdateButton:Be}),s.jsx(Ud,{open:v,onOpenChange:E,info:re.info,downloading:re.downloading,downloaded:re.downloaded,progress:re.progress,error:re.error,onDownload:re.downloadUpdate,onRestart:re.restartToUpdate,runtimeType:re.runtimeType}),s.jsx(oj,{open:!!Fe,onOpenChange:Ie=>{Ie||h(null)},project:Fe,onSave:Me}),s.jsx(Lh,{open:S,onOpenChange:C,onWorktreeCreated:(Ie,yt)=>{if(Ne.getState().closeMainSurfaces(),e&&ne(!1),yt?.sessionId){ce(yt.sessionId,Ie);return}we({directoryOverride:Ie,preserveDirectoryOverride:!0})}})]})})},P4=c.memo(A4),Cn=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,ln=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},D4=()=>{const{t}=Nt(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,d]=c.useState([]),[u,m]=c.useState(!1),[f,p]=c.useState(!1),[y,x]=c.useState(!1),[k,w]=c.useState(!1),[h,g]=c.useState(new Set),j=rt(q=>q.getWorktreeMetadata),b=rt(q=>q.newSessionDraft),S=rt(q=>q.setNewSessionDraftTarget),C=rt(q=>q.setDraftBootstrapPendingDirectory),v=Kg,E=rt(q=>q.deleteSessions),R=rt(q=>q.archiveSessions),A=Ne(q=>q.showDeletionDialog),O=Ne(q=>q.setShowDeletionDialog),B=os(q=>q.currentDirectory),T=os(q=>q.homeDirectory),M=os(q=>q.isHomeReady),L=Ut(q=>q.projects),W=Ut(q=>q.activeProjectId),{isMobile:$,isTablet:P,hasTouchInput:D}=$n(),I=$||P||D,X=c.useMemo(()=>{const z=(W?L.find(ee=>ee.id===W)??null:null)?.path??B;return ln(z)},[W,B,L]),Z=c.useCallback(q=>{const ee=ln(q.projectDirectory)||X;return{id:(L.find(Y=>ln(Y.path)===ee)??null)?.id??`path:${ee}`,path:ee}},[X,L]),ne=k&&h.size>0,ue=c.useMemo(()=>{const q=o?.worktree;return q&&typeof q.branch=="string"&&q.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:z})=>typeof z.branch=="string"&&z.branch.trim().length>0)},[o?.worktree,a]),se=o?.mode==="worktree",xe=se,ie=y||!se||!ue,Re=y||!se;c.useEffect(()=>{r||!M||L.length>0||(i(!0),n(!0))},[r,M,L.length]);const be=c.useCallback(q=>{l({sessions:q.sessions,dateLabel:q.dateLabel,mode:q.mode??"session",worktree:q.worktree??null})},[]),fe=c.useCallback(()=>{l(null),d([]),m(!1),p(!1),x(!1),w(!1),g(new Set)},[]),ke=c.useCallback(async q=>{if(q.sessions.length===0)return;if(q.sessions.length===1){const Y=q.sessions[0];await v(Y.id)?Ke.success(t("sessions.sidebar.session.delete.success")):Ke.error(t("sessions.sidebar.session.delete.error"));return}const z=q.sessions.map(Y=>Y.id),{deletedIds:ee,failedIds:de}=await E(z);if(ee.length>0){const Y=de.length>0?de.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:de.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:de.length}):q.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:q.dateLabel}):void 0;Ke.success(ee.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ee.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ee.length}),{description:Cn(Y)})}de.length>0&&Ke.error(de.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:de.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:de.length}),{description:Cn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[v,E,t]);c.useEffect(()=>un.onDeleteRequest(q=>{if(!A&&(q.mode??"session")==="session"){ke(q);return}be(q)}),[be,A,ke]),c.useEffect(()=>un.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){d([]),m(!1),p(!1),w(!1),g(new Set);return}const q=o.sessions.map(de=>{const Y=j(de.id);return Y?{session:de,metadata:Y}:null}).filter(de=>!!de);d(q),m(!1),w(!1),g(new Set);const z=new Map;if(o.worktree?.path&&z.set(ln(o.worktree.path),o.worktree),q.forEach(({metadata:de})=>{de.path&&z.set(ln(de.path),de)}),z.size===0){w(!0);return}let ee=!1;return(async()=>{const de=new Map,Y=new Set;await Promise.all(Array.from(z.entries()).map(async([U,F])=>{try{const V=await Vg(F.path);de.set(U,V),V?.isDirty&&Y.add(U)}catch{F.status&&(de.set(U,F.status),F.status.isDirty&&Y.add(U))}})).catch(U=>{console.warn("Failed to inspect worktree status before deletion:",U)}),!ee&&(g(Y),w(!0),l(U=>{if(!U?.worktree?.path)return U;const F=ln(U.worktree.path),V=de.get(F);if(!V)return U;const oe=U.worktree.status;return oe?.isDirty===V.isDirty&&oe?.ahead===V.ahead&&oe?.behind===V.behind&&oe?.upstream===V.upstream?U:{...U,worktree:{...U.worktree,status:V}}}),d(U=>U.map(F=>{const V=ln(F.metadata.path),oe=de.get(V);return oe?{session:F.session,metadata:{...F.metadata,status:oe}}:F})))})(),()=>{ee=!0}},[o,j]),c.useEffect(()=>{ue||m(!1)},[ue]);const H=c.useCallback(async(q,z,ee)=>{const de=u&&ue,Y=Z(q),U=ln(q.path),F=ln(Y.path);try{await cu(Y,q,{deleteRemoteBranch:de,deleteLocalBranch:z});const V=ln(b?.directoryOverride);return b?.open&&U&&V===U&&F&&(C(null),S({projectId:Y.id,directoryOverride:F},{force:!0})),ln(B)===U&&F&&os.getState().setDirectory(F,{showOverlay:!1}),!0}catch(V){return Ke.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:Pi(q)}),{id:ee,description:Cn(V instanceof Error?V.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ue,B,u,Z,b?.directoryOverride,b?.open,C,S,t]),J=c.useCallback((q,z,ee)=>{const de=u&&ue,Y=Ke.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Pi(q)}));(async()=>{try{if(z.length>0){const{failedIds:V}=await R(z);if(V.length>0){Ke.error(V.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:V.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:V.length}),{id:Y,description:Cn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await H(q,ee,Y))return;const F=t(de?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Ke.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:Pi(q)}),{id:Y,description:Cn(F)})}catch(U){Ke.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Y,description:Cn(U instanceof Error?U.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[R,ue,u,H,t]),ce=c.useCallback(async()=>{if(o){x(!0);try{const q=xe,z=q&&u,ee=q&&f;if(se&&o.worktree){J(o.worktree,o.sessions.map(de=>de.id),ee),fe();return}if(o.sessions.length===1){const de=o.sessions[0];if(!await v(de.id)){Ke.error(t("sessions.sidebar.session.delete.error")),x(!1);return}const U=!se&&q?t(z?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Ke.success(t("sessions.sidebar.session.delete.success"),{description:Cn(U),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const de=o.sessions.map(V=>V.id);let Y=[],U=[];const F=await E(de);if(Y=F.deletedIds,U=F.failedIds,Y.length>0){const V=!se&&q?t(z?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,ae=[U.length>0?U.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:U.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:U.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,V].filter(Boolean).join(" ");Ke.success(Y.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Y.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Y.length}),{description:Cn(ae||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(U.length>0&&(Ke.error(U.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:U.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:U.length}),{description:Cn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Y.length===0)){x(!1);return}}fe()}finally{x(!1)}}},[o,u,f,v,E,fe,xe,se,J,t]),je=o?.worktree??a[0]?.metadata??null,G=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",we=o?s.jsxs("div",{className:Ee(se?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Ee(se?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[se&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:Ee(se?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(q=>s.jsxs("li",{className:Ee(se?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Ee(!se&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:q.title||t("sessions.sidebar.session.untitled")})]},q.id)),o.sessions.length>5&&s.jsx("li",{className:Ee(se?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),se?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),je?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:je.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:je?Xr(je.path,T):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),ne&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Te=se?ue?s.jsxs("button",{type:"button",onClick:()=>{ie||m(q=>!q)},disabled:ie,className:Ee("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ie?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?s.jsx(_,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(_,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,he=se?s.jsxs("button",{type:"button",onClick:()=>{Re||p(q=>!q)},disabled:Re,className:Ee("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Re?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?s.jsx(_,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(_,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,re=se?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[he,Te]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ct,{variant:"ghost",onClick:fe,disabled:y,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ct,{variant:"destructive",onClick:ce,disabled:y,children:t(y?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>O(!A),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":!A,children:[A?s.jsx(_,{name:"checkbox-blank",className:"size-4"}):s.jsx(_,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ct,{variant:"ghost",onClick:fe,disabled:y,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ct,{variant:"destructive",onClick:ce,disabled:y,children:y?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),ge=se?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[I?s.jsx(ti,{open:!!o,onClose:()=>{y||fe()},title:ge,footer:s.jsx("div",{className:"flex justify-end gap-2",children:re}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[G&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:G}),we]})}):s.jsx(Ps,{open:!!o,onOpenChange:q=>{if(!q){if(y)return;fe()}},children:s.jsxs(Ds,{className:Ee(se?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(sn,{children:[s.jsxs(Us,{className:Ee(se&&"flex items-center gap-2"),children:[se&&s.jsx(_,{name:"delete-bin",className:"h-5 w-5"}),ge]}),G&&s.jsx(Hs,{children:G})]}),s.jsx("div",{className:Ee(se&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:we}),s.jsx(zn,{className:"mt-2 gap-2 pt-1 pb-1",children:re})]})}),s.jsx($h,{open:e,onOpenChange:n})]})};function om(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return rf.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function I4(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=rf.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const T4=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],E4={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},er=t=>E4[t]??t,im=[0,1,2,3,4,5,6],ud="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",Ia=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(er))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],fd=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},Mo=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},md=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},R4=(t,e,n)=>{const r=Mo(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},hd=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),M4=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),d=new Date(n,r,0).getDate(),u=[];for(let m=0;m<42;m+=1){const f=m-l+1;if(f<=0){const p=d+f;u.push({date:new Date(n,r-1,p),inCurrentMonth:!1});continue}if(f>a){u.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}u.push({date:new Date(n,r,f),inCurrentMonth:!0})}return u},O4=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},Gn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},Ar=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},pd=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:Ar(t,{min:1,max:12}),No=t=>/^[0-5][0-9]$/.test(t)?t:Ar(t,{max:59}),B4=(t,e)=>Ar(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),gd=(t,e)=>Ar(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),F4=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},_4=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},L4=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return im.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},$4=(t,e)=>[...t.slice(e),...t.slice(0,e)],Is=t=>{const e=tt.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},xd=t=>{const e=tt.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:d,pmLabel:u}=t;let m;e[0]!==n?(m=O4(n),e[0]=n,e[1]=m):m=e[1];const f=m,p=ut.useRef(null),y=ut.useRef(null),[x,k]=ut.useState(null),[w,h]=ut.useState(null),g=ut.useRef(null),j=ut.useRef(null);let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=q=>{g.current=q,k(q)},e[2]=b):b=e[2];const S=b;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=q=>{j.current=q,h(q)},e[3]=C):C=e[3];const v=C,E=G4,R=q4,A=Y4;let O;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(O=q=>{const z=q.replace(/\D/g,"").slice(0,2);S(z),z.length===2&&(r(i?A(E(z),f.minute):Gn(pd(z),f.minute,f.meridiem)),S(null),y.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=i,e[8]=O):O=e[8];const B=O;let T;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(T=()=>{const q=g.current;if(q!==null&&(S(null),q.length!==0)){if(i){r(A(E(q.padStart(2,"0")),f.minute));return}r(Gn(pd(q.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=T):T=e[13];const M=T;let L;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(L=q=>{const z=q.replace(/\D/g,"").slice(0,2);v(z),z.length===2&&(r(i?A(f.hour24,No(z)):Gn(f.hour12,No(z),f.meridiem)),v(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=L):L=e[19];const W=L;let $;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?($=()=>{const q=j.current;q!==null&&(v(null),q.length!==0&&r(i?A(f.hour24,No(q.padStart(2,"0"))):Gn(f.hour12,No(q.padStart(2,"0")),f.meridiem)))},e[20]=r,e[21]=f.hour12,e[22]=f.hour24,e[23]=f.meridiem,e[24]=i,e[25]=$):$=e[25];const P=$;let D;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(D=q=>r(i?A(R(f.hour24,q),f.minute):Gn(B4(f.hour12,q),f.minute,f.meridiem)),e[26]=r,e[27]=f.hour12,e[28]=f.hour24,e[29]=f.meridiem,e[30]=f.minute,e[31]=i,e[32]=D):D=e[32];const I=D;let X;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(X=q=>r(i?A(f.hour24,gd(f.minute,q)):Gn(f.hour12,gd(f.minute,q),f.meridiem)),e[33]=r,e[34]=f.hour12,e[35]=f.hour24,e[36]=f.meridiem,e[37]=f.minute,e[38]=i,e[39]=X):X=e[39];const Z=X;let ne;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(ne=q=>{q!==f.meridiem&&r(Gn(f.hour12,f.minute,q))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=ne):ne=e[44];const ue=ne;let se;e[45]!==M||e[46]!==I?(se=q=>{if(q.key==="ArrowRight"){q.preventDefault(),M(),y.current?.focus();return}(q.key==="ArrowUp"||q.key==="ArrowDown")&&(q.preventDefault(),S(null),I(q.key==="ArrowUp"?1:-1))},e[45]=M,e[46]=I,e[47]=se):se=e[47];const xe=se;let ie;e[48]!==P||e[49]!==Z?(ie=q=>{if(q.key==="ArrowLeft"&&(q.currentTarget.selectionStart??0)===0){q.preventDefault(),P(),p.current?.focus();return}(q.key==="ArrowUp"||q.key==="ArrowDown")&&(q.preventDefault(),v(null),Z(q.key==="ArrowUp"?1:-1))},e[48]=P,e[49]=Z,e[50]=ie):ie=e[50];const Re=ie,be=i?"px-2":"pl-2 pr-1";let fe;e[51]!==be?(fe=Ee("oc-surface-elevated inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-surface-elevated focus-within:ring-1 focus-within:ring-ring focus-within:border-ring",be),e[51]=be,e[52]=fe):fe=e[52];const ke=x??(i?f.hour24:f.hour12);let H;e[53]!==B?(H=q=>B(q.target.value),e[53]=B,e[54]=H):H=e[54];let J;e[55]===Symbol.for("react.memo_cache_sentinel")?(J=()=>S(""),e[55]=J):J=e[55];let ce;e[56]!==M||e[57]!==o||e[58]!==xe||e[59]!==ke||e[60]!==H?(ce=s.jsx("input",{ref:p,inputMode:"numeric",value:ke,onChange:H,onKeyDown:xe,onFocus:J,onBlur:M,maxLength:2,"aria-label":o,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=M,e[57]=o,e[58]=xe,e[59]=ke,e[60]=H,e[61]=ce):ce=e[61];let je;e[62]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=je):je=e[62];const G=w??f.minute;let we;e[63]!==W?(we=q=>W(q.target.value),e[63]=W,e[64]=we):we=e[64];let Te;e[65]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>v(""),e[65]=Te):Te=e[65];let he;e[66]!==P||e[67]!==l||e[68]!==Re||e[69]!==G||e[70]!==we?(he=s.jsx("input",{ref:y,inputMode:"numeric",value:G,onChange:we,onKeyDown:Re,onFocus:Te,onBlur:P,maxLength:2,"aria-label":l,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=P,e[67]=l,e[68]=Re,e[69]=G,e[70]=we,e[71]=he):he=e[71];let re;e[72]!==d||e[73]!==f.meridiem||e[74]!==a||e[75]!==u||e[76]!==ue||e[77]!==i?(re=i?null:s.jsxs(Rs,{value:f.meridiem,onValueChange:q=>ue(q),children:[s.jsx(Ms,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(js,{})}),s.jsxs(Os,{children:[s.jsx(rs,{value:"AM",children:d}),s.jsx(rs,{value:"PM",children:u})]})]}),e[72]=d,e[73]=f.meridiem,e[74]=a,e[75]=u,e[76]=ue,e[77]=i,e[78]=re):re=e[78];let ge;return e[79]!==fe||e[80]!==ce||e[81]!==he||e[82]!==re?(ge=s.jsxs("div",{className:fe,children:[ce,je,he,re]}),e[79]=fe,e[80]=ce,e[81]=he,e[82]=re,e[83]=ge):ge=e[83],ge},bd=t=>new Date(t.getFullYear(),t.getMonth(),1),z4=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},yd=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),W4=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},wd=(t,e)=>{const n=er(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:W4(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:fd(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:er(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:fd(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},K4=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!om(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},V4=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},U4=t=>{const e=tt.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?om(l):null,e[0]=l,e[1]=a):a=e[1];const d=a;let u;e:{if(!d?.valid||!l.trim()){let D;e[2]===Symbol.for("react.memo_cache_sentinel")?(D=[],e[2]=D):D=e[2],u=D;break e}let P;e[3]!==l||e[4]!==n.schedule.timezone?(P=I4(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=P):P=e[5],u=P}const m=u;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=P=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(P),e[6]=n.schedule.timezone,e[7]=i,e[8]=f):f=e[8];const p=f;let y;e[9]!==o?(y=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=y):y=e[10];let x;e[11]!==y?(x=s.jsx(Is,{htmlFor:"sched-cron",required:!0,children:y}),e[11]=y,e[12]=x):x=e[12];let k;e[13]!==r?(k=P=>r(D=>({...D,schedule:{...D.schedule,cronExpression:P.target.value}})),e[13]=r,e[14]=k):k=e[14];let w;e[15]!==o?(w=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=w):w=e[16];let h;e[17]!==l||e[18]!==k||e[19]!==w?(h=s.jsx(An,{id:"sched-cron",value:l,onChange:k,placeholder:w,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=k,e[19]=w,e[20]=h):h=e[20];let g;e[21]!==l||e[22]!==d||e[23]!==o?(g=d&&!d.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=d,e[23]=o,e[24]=g):g=e[24];let j;e[25]!==x||e[26]!==h||e[27]!==g?(j=s.jsxs("div",{className:"flex flex-col gap-1",children:[x,h,g]}),e[25]=x,e[26]=h,e[27]=g,e[28]=j):j=e[28];let b;e[29]!==p||e[30]!==m||e[31]!==o?(b=m.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:m.map(p).join(", ")})]}):null,e[29]=p,e[30]=m,e[31]=o,e[32]=b):b=e[32];let S;e[33]!==o?(S=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=S):S=e[34];let C;e[35]!==S?(C=s.jsx("span",{className:"typography-meta text-muted-foreground",children:S}),e[35]=S,e[36]=C):C=e[36];let v;e[37]!==r||e[38]!==o?(v=T4.map(P=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(D=>({...D,schedule:{...D.schedule,cronExpression:P.expression}})),children:[s.jsx("span",{className:"font-mono",children:P.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(P.labelKey)})]},P.expression)),e[37]=r,e[38]=o,e[39]=v):v=e[39];let E;e[40]!==v?(E=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:v}),e[40]=v,e[41]=E):E=e[41];let R;e[42]!==C||e[43]!==E?(R=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,E]}),e[42]=C,e[43]=E,e[44]=R):R=e[44];let A;e[45]!==o?(A=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=A):A=e[46];let O;e[47]!==A?(O=s.jsx(Is,{children:A}),e[47]=A,e[48]=O):O=e[48];let B;e[49]!==r?(B=P=>{r(D=>({...D,schedule:{...D.schedule,timezone:P}}))},e[49]=r,e[50]=B):B=e[50];let T;e[51]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{})}),e[51]=T):T=e[51];let M;e[52]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Os,{children:Ia.map(Q4)}),e[52]=M):M=e[52];let L;e[53]!==n.schedule.timezone||e[54]!==B?(L=s.jsxs(Rs,{value:n.schedule.timezone,onValueChange:B,children:[T,M]}),e[53]=n.schedule.timezone,e[54]=B,e[55]=L):L=e[55];let W;e[56]!==O||e[57]!==L?(W=s.jsxs("div",{className:"flex flex-col gap-1",children:[O,L]}),e[56]=O,e[57]=L,e[58]=W):W=e[58];let $;return e[59]!==j||e[60]!==b||e[61]!==R||e[62]!==W?($=s.jsxs("div",{className:"flex flex-col gap-3",children:[j,b,R,W]}),e[59]=j,e[60]=b,e[61]=R,e[62]=W,e[63]=$):$=e[63],$};function H4(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=Nt(),a=Yt(Q=>Q.loadProviders),d=Yt(Q=>Q.loadAgents),u=Yt(Q=>Q.providers),m=Yt(Q=>Q.currentProviderId),f=Yt(Q=>Q.currentModelId),p=Yt(Q=>Q.currentVariant||""),y=Yt(Q=>Q.currentAgentName||""),x=Ne(Q=>Q.timeFormatPreference),k=Ne(Q=>Q.weekStartPreference),w=Ne(Q=>Q.isMobile),[h,g]=ut.useState(()=>wd(n,{providerID:m,modelID:f,variant:p,agent:y})),[j,b]=ut.useState(!1),[S,C]=ut.useState(!1),[v,E]=ut.useState(!1),[R,A]=ut.useState(""),[O,B]=ut.useState(!1),[T,M]=ut.useState(""),[L,W]=ut.useState(!1),[$,P]=ut.useState(""),[D,I]=ut.useState(()=>{const Q=Mo(n?.schedule?.date||"")||new Date;return new Date(Q.getFullYear(),Q.getMonth(),1)}),X=ut.useRef(null),Z=ut.useRef(null),ne=ut.useRef(null),ue=ut.useRef(null),se=ut.useRef(null),xe=ut.useMemo(()=>_4(l),[l]),ie=ut.useMemo(()=>F4(l),[l]),Re=ut.useMemo(()=>x==="24h"?!0:x==="12h"?!1:xe,[x,xe]),be=ut.useMemo(()=>k==="sunday"?0:k==="monday"?1:ie,[k,ie]),fe=ut.useMemo(()=>{const Q=L4(l);return $4(im.map(Ce=>({value:Ce,label:Q[Ce]||""})),be)},[l,be]);ut.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),d({source:"scheduledTaskEditor"}))},[e,a,d]),ut.useEffect(()=>{if(!e)return;g(wd(n,{providerID:m,modelID:f,variant:p,agent:y}));const Q=Mo(n?.schedule?.date||"")||new Date;I(new Date(Q.getFullYear(),Q.getMonth(),1)),C(!1),B(!1),E(!1),M(""),A("")},[e,n,m,f,p,y]),ut.useEffect(()=>{if(!S)return;const Q=Ce=>{X.current&&!X.current.contains(Ce.target)&&C(!1)};return document.addEventListener("mousedown",Q),()=>{document.removeEventListener("mousedown",Q)}},[S]);const ke=ut.useMemo(()=>{const Ce=u.find(Be=>Be.id===h.execution.providerID)?.models?.find(Be=>Be.id===h.execution.modelID);return Qa(Ce?.variants)},[u,h.execution.providerID,h.execution.modelID]),H=ke.length>0,J=ut.useMemo(()=>!H||!h.execution.variant?"__default":ke.includes(h.execution.variant)?h.execution.variant:"__default",[h.execution.variant,H,ke]);ut.useEffect(()=>{H||!h.execution.variant||g(Q=>({...Q,execution:{...Q.execution,variant:""}}))},[H,h.execution.variant]);const ce=ut.useCallback((Q,Ce)=>{g(Be=>{const Le=new Set(Be.schedule.weekdays);return Ce?Le.add(Q):Le.delete(Q),{...Be,schedule:{...Be.schedule,weekdays:Array.from(Le).sort((Je,ot)=>Je-ot)}}})},[]),je=ut.useCallback((Q,Ce)=>{g(Be=>{const Le=Be.schedule.times.slice();return Le[Q]=Ce,{...Be,schedule:{...Be.schedule,times:Le}}})},[]),G=ut.useCallback(Q=>{g(Ce=>{const Be=Ce.schedule.times.filter((Le,Je)=>Je!==Q);return{...Ce,schedule:{...Ce.schedule,times:Be.length>0?Be:["09:00"]}}})},[]),we=ut.useCallback(()=>{g(Q=>({...Q,schedule:{...Q.schedule,times:[...Q.schedule.times,"12:00"]}}))},[]),Te=ut.useMemo(()=>z4(),[]),he=ut.useMemo(()=>bd(Te),[Te]),re=ut.useMemo(()=>{const Q=Mo(h.schedule.onceDate);return Q?yd(Q,Te)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(Q):null},[h.schedule.onceDate,l,o,Te]),ge=ut.useMemo(()=>bd(D).getTime()<=he.getTime(),[D,he]),q=ut.useMemo(()=>fe.map(Q=>Q.label),[fe]),z=ut.useCallback(Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,onceDate:Q}}))},[]),ee=ut.useCallback((Q,Ce)=>{if(Q.startsWith("/")){const ot=Q.indexOf(" "),et=Q.indexOf(`
890
+ `),it=Math.min(ot===-1?Q.length:ot,et===-1?Q.length:et);if(Ce<=it&&ot===-1){M(Q.substring(1,it)),B(!0),E(!1),W(!1);return}}B(!1);const Be=Q.substring(0,Ce),Le=Be.lastIndexOf("#");if(Le!==-1){const ot=Le>0?Be[Le-1]:null,et=Be.substring(Le+1);if((!ot||/\s/.test(ot))&&!et.includes(" ")&&!et.includes(`
891
+ `)){P(et),W(!0),E(!1);return}}W(!1);const Je=Be.lastIndexOf("@");if(Je!==-1){const ot=Je>0?Be[Je-1]:null,et=Be.substring(Je+1);(!ot||/\s/.test(ot))&&!et.includes(" ")&&!et.includes(`
892
+ `)?(A(et),E(!0)):E(!1);return}E(!1)},[]),de=ut.useCallback(Q=>{g(Ce=>({...Ce,execution:{...Ce.execution,prompt:Q}}))},[]),Y=ut.useCallback(Q=>{const Ce=h.execution.prompt,Le=Z.current?.selectionStart??Ce.length,ot=Ce.substring(0,Le).lastIndexOf("@"),et=Q.relativePath&&Q.relativePath.trim().length>0?Q.relativePath.trim():Q.path||Q.name,it=ot!==-1?ot:Le,ht=`${Ce.substring(0,it)}@${et} ${Ce.substring(Le)}`,st=it+et.length+2;de(ht),E(!1),A(""),requestAnimationFrame(()=>{const mt=Z.current;mt&&(mt.selectionStart=st,mt.selectionEnd=st,mt.focus()),ee(ht,st)})},[h.execution.prompt,de,ee]),U=ut.useCallback(Q=>{const Ce=h.execution.prompt,Le=Z.current?.selectionStart??Ce.length,ot=Ce.substring(0,Le).lastIndexOf("@"),et=ot!==-1?ot:Le,it=`${Ce.substring(0,et)}@${Q} ${Ce.substring(Le)}`,ht=et+Q.length+2;de(it),E(!1),A(""),requestAnimationFrame(()=>{const st=Z.current;st&&(st.selectionStart=ht,st.selectionEnd=ht,st.focus()),ee(it,ht)})},[h.execution.prompt,de,ee]),F=ut.useCallback(Q=>{const Ce=`/${Q.name} `;de(Ce),B(!1),M(""),W(!1),requestAnimationFrame(()=>{const Be=Z.current;Be&&(Be.focus(),Be.selectionStart=Be.value.length,Be.selectionEnd=Be.value.length),ee(Ce,Ce.length)})},[de,ee]),V=ut.useCallback((Q,Ce)=>{const Be=h.execution.prompt,Je=Z.current?.selectionStart??Be.length,et=Be.substring(0,Je).lastIndexOf("#"),it=et!==-1?et:Je,ht=`${Be.substring(0,it)}#${Ce} ${Be.substring(Je)}`,st=it+Ce.length+2;de(ht),W(!1),P(""),requestAnimationFrame(()=>{const mt=Z.current;mt&&(mt.selectionStart=st,mt.selectionEnd=st,mt.focus()),ee(ht,st)})},[h.execution.prompt,de,ee]),oe=ut.useCallback(Q=>{if(O&&ue.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")){Q.preventDefault(),ue.current.handleKeyDown(Q.key);return}v&&ne.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")&&(Q.preventDefault(),ne.current.handleKeyDown(Q.key)),L&&se.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")&&(Q.preventDefault(),se.current.handleKeyDown(Q.key))},[O,v,L]),ae=ut.useCallback(async()=>{const Q=K4(h,o);if(Q){Ke.error(Q);return}const Ce={...h.id?{id:h.id}:{},name:h.name.trim(),enabled:h.enabled,schedule:{kind:h.schedule.kind,timezone:h.schedule.timezone.trim(),...h.schedule.kind==="cron"?{cron:h.schedule.cronExpression.trim()}:h.schedule.kind==="once"?{date:h.schedule.onceDate,time:h.schedule.onceTime}:{times:V4(h.schedule.times),...h.schedule.kind==="weekly"?{weekdays:h.schedule.weekdays}:{}}},execution:{prompt:h.execution.prompt,providerID:h.execution.providerID,modelID:h.execution.modelID,...h.execution.variant.trim()?{variant:h.execution.variant.trim()}:{},...h.execution.agent.trim()?{agent:h.execution.agent.trim()}:{},...h.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...h.execution.goalEnabled?{goalEnabled:!0}:{},...h.execution.goalEnabled&&h.execution.goalTokenBudget?{goalTokenBudget:h.execution.goalTokenBudget}:{}},...h.state?{state:h.state}:{}};b(!0);try{await i(Ce),r(!1)}catch(Be){Ke.error(Be instanceof Error?Be.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{b(!1)}},[h,r,i,o]),pe=ut.useId(),le=ut.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),_e=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),Fe=o("sessions.scheduledTasks.editor.description"),Me=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Is,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(An,{id:"sched-name",value:h.name,onChange:Q=>g(Ce=>({...Ce,name:Q.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Rs,{value:h.schedule.kind,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,kind:Q,...Q==="cron"&&!Ce.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{children:Q=>o(Q==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":Q==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":Q==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Os,{children:[s.jsx(rs,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(rs,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(rs,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(rs,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),h.schedule.kind==="cron"?s.jsx(U4,{draft:h,setDraft:g,locale:l,t:o}):h.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:X,children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Ee(Bu({size:"default"}),"w-fit max-w-full"),onClick:()=>C(Q=>!Q),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(_,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:R4(h.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),S?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>I(Q=>hd(Q,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:ge,children:s.jsx(_,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(D)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>I(Q=>hd(Q,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(_,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:q.map((Q,Ce)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:Q},`${Q}-${Ce}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:M4(D,be).map(({date:Q,inCurrentMonth:Ce})=>{const Be=md(Q),Le=Be===h.schedule.onceDate,Je=yd(Q,Te),ot=Q.getTime()<Te.getTime(),et=Le?"bg-interactive-selection text-interactive-selection-foreground":ot?"text-muted-foreground/40":Ce?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{ot||(z(Be),C(!1))},disabled:ot,className:["h-8 rounded-md typography-ui-label",et,Je&&!Le?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",ot?"cursor-not-allowed opacity-45":""].join(" "),children:Q.getDate()},Be)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:re||""}),s.jsx(ct,{type:"button",size:"xs",variant:"ghost",onClick:()=>{z(md(Te)),I(new Date(Te.getFullYear(),Te.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(xd,{value:h.schedule.onceTime,use24Hour:Re,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Q=>g(Ce=>({...Ce,schedule:{...Ce.schedule,onceTime:Q}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Rs,{value:h.schedule.timezone,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,timezone:Q}}))},children:[s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{})}),s.jsx(Os,{children:Ia.map(Q=>s.jsx(rs,{value:Q,children:Q},Q))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[h.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:fe.map(Q=>{const Ce=h.schedule.weekdays.includes(Q.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",Ce?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(xr,{checked:Ce,onChange:Be=>ce(Q.value,Be),ariaLabel:Q.label}),s.jsx("button",{type:"button",onClick:()=>ce(Q.value,!Ce),className:"group-hover:text-foreground",children:Q.label})]},Q.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:h.schedule.times.map((Q,Ce)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xd,{value:Q,use24Hour:Re,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Be=>je(Ce,Be)}),h.schedule.times.length>1?s.jsx(ct,{type:"button",size:"icon",variant:"ghost",onClick:()=>G(Ce),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(_,{name:"close",className:"h-4 w-4"})}):null]},Ce))}),s.jsx("div",{children:s.jsxs(ct,{type:"button",size:"sm",variant:"outline",onClick:we,children:[s.jsx(_,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Rs,{value:h.schedule.timezone,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,timezone:Q}}))},children:[s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{})}),s.jsx(Os,{children:Ia.map(Q=>s.jsx(rs,{value:Q,children:Q},Q))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Is,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Ug,{providerId:h.execution.providerID,modelId:h.execution.modelID,onChange:(Q,Ce)=>{g(Be=>({...Be,execution:{...Be.execution,providerID:Q,modelID:Ce,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Rs,{value:J,disabled:!H,onValueChange:Q=>{g(Ce=>({...Ce,execution:{...Ce.execution,variant:Q==="__default"?"":Q}}))},children:[s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{children:Q=>Q==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):Q})}),s.jsxs(Os,{children:[s.jsx(rs,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),ke.map(Q=>s.jsx(rs,{value:Q,children:Q},Q))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Hg,{agentName:h.execution.agent,filter:Q=>Ou(Q.mode),onChange:Q=>g(Ce=>({...Ce,execution:{...Ce.execution,agent:Q}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Is,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(pr,{id:"sched-prompt",ref:Z,value:h.execution.prompt,onChange:Q=>{const Ce=Q.target.value;de(Ce);const Be=Q.target.selectionStart??Ce.length;ee(Ce,Be)},onKeyDown:oe,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),O?s.jsx(Ku,{ref:ue,searchQuery:T,onCommandSelect:F,onClose:()=>B(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,v?s.jsx(Vu,{ref:ne,searchQuery:R,onFileSelect:Y,onAgentSelect:U,onClose:()=>E(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,L?s.jsx(Uu,{ref:se,searchQuery:$,onSnippetSelect:V,onClose:()=>W(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),h.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(xr,{checked:h.execution.goalTokenBudget!==null,onChange:Q=>g(Ce=>({...Ce,execution:{...Ce.execution,goalTokenBudget:Q?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),h.execution.goalTokenBudget!==null?s.jsx(Gg,{value:h.execution.goalTokenBudget,onValueChange:Q=>{typeof Q=="number"&&Number.isFinite(Q)&&Q>0&&g(Ce=>({...Ce,execution:{...Ce.execution,goalTokenBudget:Math.floor(Q)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Ae=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(xr,{checked:h.enabled,onChange:Q=>g(Ce=>({...Ce,enabled:Q})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(ud),onClick:()=>g(Q=>({...Q,execution:{...Q.execution,permissionAutoAccept:!Q.execution.permissionAutoAccept}})),"aria-pressed":h.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:h.execution.permissionAutoAccept?s.jsx(_,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(_,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(ud,h.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>g(Q=>({...Q,execution:{...Q.execution,goalEnabled:!Q.execution.goalEnabled}})),"aria-pressed":h.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:h.execution.goalEnabled?s.jsx(_,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(_,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:j,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(ct,{type:"button",size:"sm",onClick:ae,disabled:j,children:o(j?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return w?s.jsx(ti,{open:e,title:_e,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:Q=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:_e}),Q]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:Fe})]}),footer:Ae,children:Me}):s.jsx(Ps,{open:e,onOpenChange:Q=>{!Q&&le()||r(Q)},children:s.jsxs(Ds,{"aria-describedby":pe,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Hs,{id:pe,className:"sr-only",children:Fe}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Us,{className:"typography-ui-label font-medium text-foreground",children:_e}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:Fe})]})}),s.jsx(Wa,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:Me})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:Ae})})]})})}function G4(t){return Ar(t,{min:0,max:23})}function q4(t,e){return Ar(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function Y4(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function Q4(t){return s.jsx(rs,{value:t,children:t},t)}const X4=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},J4=(t,e)=>{const n=X4(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},Z4=(t,e)=>!t||!Number.isFinite(t)?"":qg(t,e),vd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),p=Math.round(r%o/i),y=p>0?`${f}h ${p}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:y}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:y})}const d=Math.floor(r/l),u=Math.round(r%l/o),m=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:m}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:m})},e5={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},t5=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function s5(){const{t}=Nt(),e=Ne(P=>P.isScheduledTasksDialogOpen),n=Ne(P=>P.setScheduledTasksDialogOpen),r=Ne(P=>P.isMobile),i=Ne(P=>P.timeFormatPreference),o=Ut(P=>P.projects),l=Ut(P=>P.getActiveProject()),a=os(P=>P.homeDirectory),{currentTheme:d}=Ln(),[u,m]=ut.useState(""),[f,p]=ut.useState([]),[y,x]=ut.useState(!0),[k,w]=ut.useState(!1),[h,g]=ut.useState(null),[j,b]=ut.useState(null),S=ut.useMemo(()=>o.find(P=>P.id===u)||null,[o,u]),C=ut.useCallback(P=>{const D=P.label?.trim()||ir(P.path,a||void 0),I=P.icon?ni[P.icon]:null,X=P.color?ri[P.color]:void 0,Z=I?s.jsx(_,{name:I,className:"h-3.5 w-3.5 shrink-0",style:X?{color:X}:void 0}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:X?{color:X}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[P.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:P.iconBackground?{backgroundColor:P.iconBackground}:void 0,children:s.jsx(oi,{project:{id:P.id,iconImage:P.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:Z})}):Z,s.jsx("span",{className:"truncate",children:D})]})},[a,d.metadata.variant,d.colors.surface.foreground]),v=ut.useCallback(async(P,D)=>{if(!P){p([]);return}D?.silent||x(!0);try{const I=await zx(P);I.sort((X,Z)=>{if(X.enabled!==Z.enabled)return X.enabled?-1:1;const ne=X.name.localeCompare(Z.name);return ne!==0?ne:(X.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(Z.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(I)}catch(I){Ke.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),D?.silent||p([])}finally{D?.silent||x(!1)}},[t]);ut.useEffect(()=>{if(!e)return;const P=l?.id||o[0]?.id||"";m(P),P?v(P):(p([]),x(!1))},[e,l,o,v]),ut.useEffect(()=>{if(!e)return;let P=null;const D=Wn(I=>{I.type==="scheduled-task-ran"&&I.projectId===u&&(P&&clearTimeout(P),P=setTimeout(()=>{v(u,{silent:!0})},400))});return()=>{P&&clearTimeout(P),D()}},[e,u,v]);const E=ut.useCallback(async P=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Ql(u,P),await v(u),Ke.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,v,t]),R=ut.useCallback(async(P,D)=>{if(u){b(P.id),p(I=>I.map(X=>X.id===P.id?{...X,enabled:D}:X));try{P.loopFile?await Wx(u,P.id,D):await Ql(u,{...P,enabled:D}),await v(u,{silent:!0})}catch(I){Ke.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await v(u,{silent:!0})}finally{b(null)}}},[u,v,t]),A=ut.useCallback(async P=>{if(!(!u||!window.confirm(P.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:P.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:P.name})))){b(P.id);try{P.loopFile?await Kx(u,P.id):await Vx(u,P.id),await v(u,{silent:!0}),Ke.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(I){Ke.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{b(null)}}},[u,v,t]),O=ut.useCallback(P=>{if(!P.loopFile){g(P),w(!0);return}S?.path&&(n(!1),pn.getState().setSelectedPath(S.path,P.loopFile,{allowOutsideRoot:!0}),Ne.getState().openContextFile(S.path,P.loopFile))},[S?.path,n]),B=ut.useCallback(async P=>{if(u){b(P.id);try{const{sessionId:D,persistError:I}=await Ux(u,P.id);if(await Promise.all([v(u,{silent:!0}),ai()]),I?Ke.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Ke.success(t("sessions.scheduledTasks.dialog.toast.started")),D){const X=o.find(Z=>Z.id===u);rt.getState().setCurrentSession(D,X?.path??null)}}catch(D){Ke.error(D instanceof Error?D.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{b(null)}}},[u,o,v,t]),T=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(Rs,{value:u||"__none",onValueChange:P=>{const D=P==="__none"?"":P;m(D),D?v(D):p([])},children:[s.jsx(Ms,{size:"lg",className:r?"w-full":void 0,children:S?s.jsx(js,{children:C(S)}):s.jsx(js,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Os,{children:[o.length===0?s.jsx(rs,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(P=>s.jsx(rs,{value:P.id,children:C(P)},P.id))]})]})]}),M=()=>{g(null),w(!0)},L=P=>{m(P),P?v(P):p([])},W=s.jsx("div",{className:"min-h-[280px]",children:y?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(_,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(P=>{const D=j===P.id,I=P.state?.lastStatus||"idle",X=e5[I],Z=t(I==="success"?"sessions.scheduledTasks.dialog.status.success":I==="error"?"sessions.scheduledTasks.dialog.status.error":I==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),ne=P.state?.nextRunAt,ue=P.state?.lastRunAt;return s.jsxs("div",{className:Ee("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Ee("min-w-0",!P.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:P.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:J4(P,t)}),P.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:P.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:P.loopFile})}):null]}),s.jsxs("div",{className:Ee("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!P.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(_,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),ne?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:vd(ne,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Z4(ne,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(_,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),I==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(_,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ue?s.jsxs(s.Fragment,{children:[X.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${X.tone})`},children:[s.jsx(_,{name:X.Icon,className:"h-3.5 w-3.5"}),Z]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:vd(ue,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),P.state?.lastError?s.jsxs("div",{className:Ee("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!P.enabled&&"opacity-60"),style:t5("error"),children:[s.jsx(_,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:P.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Ee("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",P.enabled?"text-foreground":"text-muted-foreground",D&&"cursor-not-allowed opacity-50"),children:[s.jsx(xr,{checked:P.enabled,onChange:se=>{R(P,se)},ariaLabel:P.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:P.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:P.name}),disabled:D}),P.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(ct,{variant:"outline",size:"sm",onClick:()=>{B(P)},disabled:D,children:[s.jsx(_,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(ct,{variant:"outline",size:"sm",onClick:()=>O(P),disabled:D,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:P.name}),children:[s.jsx(_,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(ct,{variant:"destructive",size:"sm",onClick:()=>{A(P)},disabled:D,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:P.name}),children:s.jsx(_,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},P.id)})})}),$=s.jsxs("div",{className:"space-y-4",children:[T,W]});return s.jsxs(s.Fragment,{children:[r?s.jsx(ti,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:P=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),P]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(ct,{className:"w-full",onClick:M,disabled:!u,children:[s.jsx(_,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:$}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface-elevated",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(P=>s.jsx("button",{type:"button",onClick:()=>L(P.id),className:Ee("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u===P.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(P)},P.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(ct,{size:"sm",onClick:M,disabled:!u,children:[s.jsx(_,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:W})})]})]})}):null,s.jsx(H4,{open:k,task:h,onOpenChange:w,onSave:E})]})}const Oo=100;function n5(){const t=tt.c(108),{t:e}=Nt(),n=Ne(f5),r=Ne(u5),i=rt(d5),o=rt(c5),l=os(l5);let a;t[0]!==n?(a=ne=>n?ne.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=vs(ar(a)),[u,m]=c.useState(""),[f,p]=c.useState(null),[y,x]=c.useState(Oo);let k;t[2]!==u?(k=u.trim().toLowerCase(),t[2]=u,t[3]=k):k=t[3];const w=k;let h;e:{if(!n){let ue;t[4]===Symbol.for("react.memo_cache_sentinel")?(ue=[],t[4]=ue):ue=t[4],h=ue;break e}let ne;t[5]!==d?(ne=[...d].sort(a5),t[5]=d,t[6]=ne):ne=t[6],h=ne}const g=h;let j;if(t[7]!==l||t[8]!==g||t[9]!==e){const ne=new Map;for(const ue of g){const se=xt(As(ue))??"",xe=ne.get(se);if(xe){xe.sessions.push(ue);continue}ne.set(se,{directory:se,label:se?ir(se,l)||se:e("sessions.archivePage.otherProjects"),sessions:[ue]})}j=[...ne.values()].sort(i5),t[7]=l,t[8]=g,t[9]=e,t[10]=j}else j=t[10];const b=j;let S;e:{if(w){if(w.startsWith("ses_")){let se;if(t[11]!==w||t[12]!==g){let xe;t[14]!==w?(xe=ie=>ie.id.toLowerCase()===w,t[14]=w,t[15]=xe):xe=t[15],se=g.filter(xe),t[11]=w,t[12]=g,t[13]=se}else se=t[13];S=se;break e}let ue;t[16]!==w||t[17]!==g?(ue=Yg(g,w,o5),t[16]=w,t[17]=g,t[18]=ue):ue=t[18],S=ue;break e}if(f===null){S=g;break e}let ne;t[19]!==b||t[20]!==f?(ne=b.find(ue=>ue.directory===f)?.sessions??[],t[19]=b,t[20]=f,t[21]=ne):ne=t[21],S=ne}const C=S;let v,E,R,A,O,B,T,M,L,W;if(t[22]!==d.length||t[23]!==b||t[24]!==C||t[25]!==l||t[26]!==w||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==y){O=Symbol.for("react.early_return_sentinel");e:{const ne=C.slice(0,y);v=C.length-ne.length;const ue=d.length;let se;t[45]===Symbol.for("react.memo_cache_sentinel")?(se=ge=>{p(ge),x(Oo)},t[45]=se):se=t[45];const xe=se;let ie;t[46]!==i||t[47]!==r?(ie=ge=>{const q=xt(As(ge));i(ge.id,q??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=ie):ie=t[48];const Re=ie;let be;t[49]!==e||t[50]!==o?(be=ge=>{o(ge.id).then(q=>{q?Ke.success(e("sessions.sidebar.session.restore.success")):Ke.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=be):be=t[51];const fe=be;if(!n){O=null;break e}let ke;t[52]!==e?(ke=(ge,q,z,ee,de,Y,U)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:de,title:Y,className:Ee("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",U?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",ee?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:q}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:z})]}),U?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>un.requestDelete({sessions:U,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:q}),children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ge),t[52]=e,t[53]=ke):ke=t[53];const H=ke;A="absolute inset-0 z-10 flex flex-col bg-background",E="flex min-h-0 flex-1";let J;if(t[54]!==H||t[55]!==f||t[56]!==e||t[57]!==ue){let ge;t[59]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>xe(null),t[59]=ge):ge=t[59],J=H("__all__",e("sessions.archivePage.allDirectories"),ue,f===null,ge),t[54]=H,t[55]=f,t[56]=e,t[57]=ue,t[58]=J}else J=t[58];let ce;if(t[60]!==b||t[61]!==H||t[62]!==f){let ge;t[64]!==H||t[65]!==f?(ge=q=>H(q.directory||"__none__",q.label,q.sessions.length,f===q.directory,()=>xe(q.directory),q.directory||void 0,q.sessions),t[64]=H,t[65]=f,t[66]=ge):ge=t[66],ce=b.map(ge),t[60]=b,t[61]=H,t[62]=f,t[63]=ce}else ce=t[63];t[67]!==J||t[68]!==ce?(R=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[J,ce]})}),t[67]=J,t[68]=ce,t[69]=R):R=t[69],L="flex min-w-0 flex-1 flex-col";let je;t[70]===Symbol.for("react.memo_cache_sentinel")?(je=ge=>{m(ge),x(Oo)},t[70]=je):je=t[70];let G;t[71]!==e?(G=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=G):G=t[72];let we;t[73]!==e?(we=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=we):we=t[74];let Te;t[75]!==u||t[76]!==G||t[77]!==we?(Te=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Qd,{value:u,onSearch:je,placeholder:G,clearLabel:we})}),t[75]=u,t[76]=G,t[77]=we,t[78]=Te):Te=t[78];let he;t[79]!==C.length||t[80]!==e?(he=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[79]=C.length,t[80]=e,t[81]=he):he=t[81];let re;t[82]!==he?(re=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:he}),t[82]=he,t[83]=re):re=t[83],t[84]!==Te||t[85]!==re?(W=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Te,re]}),t[84]=Te,t[85]=re,t[86]=W):W=t[86],M="min-h-0 flex-1 overflow-y-auto px-6 py-3",B="mx-auto w-full max-w-3xl space-y-0.5",T=ne.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(w?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):ne.map(ge=>{const q=xt(As(ge))??"",z=q?ir(q,l)||q:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Re(ge),role:"button",tabIndex:0,onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&(ee.preventDefault(),Re(ge))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ge.title||e("sessions.sidebar.session.untitled")}),w&&z?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:q,children:z}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Wu(ge.time?.archived??ge.time?.updated??ge.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),fe(ge)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:ge.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(_,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),un.requestDelete({sessions:[ge],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:ge.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ge.id)})}t[22]=d.length,t[23]=b,t[24]=C,t[25]=l,t[26]=w,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=y,t[35]=v,t[36]=E,t[37]=R,t[38]=A,t[39]=O,t[40]=B,t[41]=T,t[42]=M,t[43]=L,t[44]=W}else v=t[35],E=t[36],R=t[37],A=t[38],O=t[39],B=t[40],T=t[41],M=t[42],L=t[43],W=t[44];if(O!==Symbol.for("react.early_return_sentinel"))return O;let $;t[87]!==v||t[88]!==e?($=v>0?s.jsx("button",{type:"button",onClick:()=>x(r5),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=v,t[88]=e,t[89]=$):$=t[89];let P;t[90]!==$||t[91]!==B||t[92]!==T?(P=s.jsxs("div",{className:B,children:[T,$]}),t[90]=$,t[91]=B,t[92]=T,t[93]=P):P=t[93];let D;t[94]!==P||t[95]!==M?(D=s.jsx("div",{className:M,children:P}),t[94]=P,t[95]=M,t[96]=D):D=t[96];let I;t[97]!==D||t[98]!==L||t[99]!==W?(I=s.jsxs("div",{className:L,children:[W,D]}),t[97]=D,t[98]=L,t[99]=W,t[100]=I):I=t[100];let X;t[101]!==E||t[102]!==R||t[103]!==I?(X=s.jsxs("div",{className:E,children:[R,I]}),t[101]=E,t[102]=R,t[103]=I,t[104]=X):X=t[104];let Z;return t[105]!==A||t[106]!==X?(Z=s.jsx("div",{className:A,children:X}),t[105]=A,t[106]=X,t[107]=Z):Z=t[107],Z}function r5(t){return t+Oo}function o5(t){return[t.title]}function i5(t,e){return e.sessions.length-t.sessions.length}function a5(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function l5(t){return t.homeDirectory}function c5(t){return t.unarchiveSession}function d5(t){return t.setCurrentSession}function u5(t){return t.setArchivePageOpen}function f5(t){return t.isArchivePageOpen}function m5(){const t=tt.c(18),{t:e}=Nt(),n=Ne(g5),r=Ne(p5),i=Ut(h5);let o;t[0]!==n?(o=y=>y.projects.find(x=>x.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Ut(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==a||t[10]!==u?(m=s.jsx("div",{className:"flex items-center",children:s.jsxs(ct,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=m):m=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(zh,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let p;return t[15]!==m||t[16]!==f?(p=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[m,f]})})}),t[15]=m,t[16]=f,t[17]=p):p=t[17],p}function h5(t){return t.setActiveProjectIdOnly}function p5(t){return t.setNewWorktreeDialogOpen}function g5(t){return t.worktreesPageProjectId}function am(t){const e=tt.c(30),{git:n}=wn(),r=vu(t),i=Su(t),o=Qg(t),l=Xg(t),a=Tn(v5),d=Tn(w5);let u,m;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==i||e[4]!==o?(u=()=>{!t||!n||i!==null||o||d(t,n,{silent:!0})},m=[t,n,d,i,o],e[0]=t,e[1]=d,e[2]=n,e[3]=i,e[4]=o,e[5]=u,e[6]=m):(u=e[5],m=e[6]),c.useEffect(u,m);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=f):f=e[12];const p=r?.all;let y;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(y=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=y):y=e[18],c.useEffect(f,y);const x=o||i===!0&&l;let k;e:{if(!r?.all){let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[19]=v):v=e[19],k=v;break e}let C;e[20]!==r.all?(C=r.all.filter(y5).sort(),e[20]=r.all,e[21]=C):C=e[21],k=C}const w=k;let h;e:{if(!r?.all){let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[22]=v):v=e[22],h=v;break e}let C;e[23]!==r.all?(C=r.all.filter(b5).map(x5).sort(),e[23]=r.all,e[24]=C):C=e[24],h=C}const g=h;let j;e:{if(!t){j=null;break e}if(i!==null){j=i;break e}if(x){j=null;break e}j=r?.all?!0:null}const b=j;let S;return e[25]!==b||e[26]!==x||e[27]!==w||e[28]!==g?(S={localBranches:w,remoteBranches:g,isLoading:x,isGitRepository:b},e[25]=b,e[26]=x,e[27]=w,e[28]=g,e[29]=S):S=e[29],S}function x5(t){return t.replace(/^remotes\//,"")}function b5(t){return t.startsWith("remotes/")}function y5(t){return!t.startsWith("remotes/")}function w5(t){return t.fetchStatus}function v5(t){return t.fetchBranches}const S5=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=Nt(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:m}=am(t),f=c.useMemo(()=>[...a,...d.map(y=>`remotes/${y}`)],[a,d]);c.useEffect(()=>{if(i||u||f.length===0||e&&f.includes(e))return;const y=e;let x=!1;return(async()=>{try{const w=t?await za(t).catch(()=>null):null;if(x)return;const h=localStorage.getItem(Nl),{sourceBranch:g,shouldClearSavedSourceBranch:j}=Wh({branches:f,savedSourceBranch:h,rootBranch:w});if(j&&localStorage.removeItem(Nl),x||y&&f.includes(y))return;g&&n(g)}catch{}})(),()=>{x=!0}},[f,t,i,u,n,e]);const p=i||!m||u;return s.jsxs("div",{children:[s.jsxs(Rs,{value:e,onValueChange:n,disabled:p,children:[s.jsx(Ms,{id:o,size:"lg",className:Ee("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(js,{placeholder:l(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Os,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(oa,{children:[s.jsx(zl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(y=>s.jsx(rs,{value:y,className:"whitespace-normal break-all",children:y},y))]}),a.length>0&&d.length>0&&s.jsx(Jg,{}),d.length>0&&s.jsxs(oa,{children:[s.jsx(zl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),d.map(y=>s.jsx(rs,{value:`remotes/${y}`,className:"whitespace-normal break-all",children:y},`remotes/${y}`))]})]})})]}),m===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},j5=10*1024*1024,Bo=t=>{const e=tt.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(_,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(vt,{children:[r,s.jsx(jt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Jn=t=>{const e=tt.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const d=o&&o;let u;return e[6]!==a||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,d]}),e[6]=a,e[7]=d,e[8]=u):u=e[8],u},k5=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=Nt(),[o,l]=c.useState(""),[a,d]=c.useState(()=>[{id:Gr(),prompt:"",models:[]}]),[u,m]=c.useState(""),[f,p]=c.useState([]),[y,x]=c.useState(!1),[k,w]=c.useState([]),[h,g]=c.useState(!1),[j,b]=c.useState(!1),[S,C]=c.useState(!0),v=c.useRef(null),E=os(F=>F.currentDirectory??null),R=os(F=>F.homeDirectory??null),A=c.useMemo(()=>{if(typeof window>"u")return null;const F=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof F=="string"&&F.trim().length>0?F.trim():null},[]),O=Ut(F=>F.activeProjectId),B=Ut(F=>F.setActiveProjectIdOnly),T=Ut(F=>F.projects),[M,L]=c.useState(()=>O??null);c.useEffect(()=>{if(O){L(O);return}!M&&T.length>0&&L(T[0].id)},[O,T,M]);const W=c.useMemo(()=>M?T.find(F=>F.id===M)??null:null,[T,M]),$=W?.path??E,P=c.useCallback(F=>{L(F),F!==O&&B(F)},[O,B]),{currentTheme:D}=Ln(),I=c.useCallback(F=>{const V=F.label?.trim()||ir(F.path,R),oe=F.icon?ni[F.icon]:null,ae=F.color?ri[F.color]:void 0,pe=oe?s.jsx(_,{name:oe,className:"h-3.5 w-3.5 shrink-0",style:ae?{color:ae}:void 0}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:ae?{color:ae}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[F.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:F.iconBackground?{backgroundColor:F.iconBackground}:void 0,children:s.jsx(oi,{project:{id:F.id,iconImage:F.iconImage??null},options:{themeVariant:D.metadata.variant,iconColor:D.colors.surface.foreground},className:"h-full w-full object-contain",fallback:pe})}):pe,s.jsx("span",{className:"truncate",children:V})]})},[R,D.metadata.variant,D.colors.surface.foreground]),X=c.useMemo(()=>{if(W?.path)return{id:W.id,path:W.path};const F=E??A;return F?{id:`path:${F}`,path:F}:null},[W,E,A]),[Z]=c.useState(()=>typeof window<"u"?xn():!1),ne=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ue=du(),se=c.useMemo(()=>{if(typeof window>"u")return null;const F=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof F=="number"&&Number.isFinite(F)&&F>0)return F;if(typeof navigator>"u")return null;const V=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!V)return null;const oe=Number.parseInt(V[1],10),ae=Number.parseInt(V[2],10);return Number.isNaN(oe)?null:oe===10?ae:oe},[]),xe=c.useMemo(()=>Z&&ne||ue?"pl-[88px]":"pl-3",[Z,ne,ue]),ie=c.useMemo(()=>!Z||!ne||se===null?"":se>=26?"h-12":se<=15?"h-14":"",[Z,ne,se]),Re=c.useCallback(async F=>{F.target.closest("button, a, input, select, textarea")||F.button===0&&Z&&await Zg()},[Z]);c.useEffect(()=>{if(!n)return;const F=V=>{V.key==="Escape"&&(V.preventDefault(),V.stopPropagation(),n())};return window.addEventListener("keydown",F,!0),()=>window.removeEventListener("keydown",F,!0)},[n]);const[be,fe]=c.useState(""),{isLoading:ke,isGitRepository:H}=am($),J=c.useRef(!1),ce=H===!0,je=ce&&S;c.useEffect(()=>{if(H===!1){J.current=!0,C(!1);return}H===!0&&J.current&&(J.current=!1,C(!0))},[H]);const G=Ni(F=>F.createMultiRun),we=Ni(F=>F.error),Te=Ni(F=>F.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(F=>{const V=[...F];return V.length>0&&!V[0].prompt.trim()&&(V[0]={...V[0],prompt:t}),V})},[t]),c.useEffect(()=>{if(!X)return;let F=!1;return b(!0),(async()=>{try{const V=await ex(X);F||w(V)}catch{}finally{F||b(!1)}})(),()=>{F=!0}},[X]);const he=c.useCallback((F,V)=>{d(oe=>oe.map(ae=>ae.id===F?{...ae,...V}:ae))},[]),re=c.useCallback(F=>{d(V=>V.filter(oe=>oe.id!==F))},[]),ge=c.useCallback(()=>{d(F=>[...F,{id:Gr(),prompt:"",models:[]}])},[]),q=async F=>{const V=F.target.files;if(!V)return;let oe=0;for(let ae=0;ae<V.length;ae++){const pe=V[ae];if(pe.size>j5){Ke.error(i("multirun.launcher.toast.fileTooLarge",{fileName:pe.name}));continue}try{const le=await new Promise((_e,Fe)=>{const Me=new FileReader;Me.onload=()=>_e(Me.result),Me.onerror=Fe,Me.readAsDataURL(pe)});p(_e=>[..._e,{id:Gr(),filename:pe.name,mimeType:pe.type||"application/octet-stream",size:pe.size,dataUrl:le}]),oe++}catch(le){console.error("File attach failed",le),Ke.error(i("multirun.launcher.toast.attachFailed",{fileName:pe.name}))}}oe>0&&Ke.success(oe===1?i("multirun.launcher.toast.attachedSingle",{count:oe}):i("multirun.launcher.toast.attachedPlural",{count:oe})),v.current&&(v.current.value="")},z=F=>{p(V=>V.filter(oe=>oe.id!==F))},ee=c.useMemo(()=>a.reduce((F,V)=>F+V.models.length,0),[a]),de=async F=>{F.preventDefault();const V=a.filter(oe=>oe.prompt.trim()&&oe.models.length>=1);if(V.length!==0&&!(ee<1)){x(!0),Te();try{M&&M!==O&&B(M);const oe=f.map(Fe=>({mime:Fe.mimeType,filename:Fe.filename,url:Fe.dataUrl})),ae=k.filter(Fe=>Fe.trim().length>0),pe=V.map(Fe=>({prompt:Fe.prompt.trim(),models:Fe.models.map(Me=>({providerID:Me.providerID,modelID:Me.modelID,displayName:Me.displayName,variant:Me.variant}))})),le={name:o.trim(),groups:pe,agent:u||void 0,worktreeBaseBranch:je?be:void 0,isolateRuns:je,files:oe.length>0?oe:void 0,setupCommands:ae.length>0?ae:void 0},_e=await G(le);_e&&(_e.failedCount>0&&Ke.error(i("multirun.launcher.toast.partialFailure",{failed:_e.failedCount})),_e.firstSessionId&&rt.getState().setCurrentSession(_e.firstSessionId),e?.())}finally{x(!1)}}},Y=!!(o.trim()&&a.some(F=>F.prompt.trim()&&F.models.length>=1)&&ee>=1&&$&&!ke&&(H===!1||!je||be)),U=k.filter(F=>F.trim()).length;return s.jsxs("form",{onSubmit:de,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Re,className:Ee("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",xe,ie),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring app-region-no-drag",children:s.jsx(_,{name:"close",className:"h-5 w-5"})})}),s.jsx(jt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(Wa,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Jn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),T.length>0?s.jsxs(Rs,{value:M??void 0,onValueChange:P,children:[s.jsx(Ms,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:W?s.jsx(js,{children:I(W)}):s.jsx(js,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Os,{fitContent:!0,children:T.map(F=>s.jsx(rs,{value:F.id,className:"max-w-[24rem]",children:I(F)},F.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Jn,{htmlFor:"group-name",required:!0,info:s.jsx(Bo,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(An,{id:"group-name",value:o,onChange:F=>l(F.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Jn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Bo,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(S5,{directory:$,value:be,onChange:fe,disabled:!je,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(xr,{checked:S,onChange:C,disabled:!ce,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Jn,{htmlFor:"multirun-agent",info:s.jsx(Bo,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(Yf,{value:u,onChange:m,id:"multirun-agent"})]})]}),s.jsxs(Zi,{open:h,onOpenChange:g,children:[s.jsxs(wu,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(_,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),U>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:U}),s.jsx(_,{name:"arrow-down-s",className:Ee("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",h&&"rotate-180")})]}),s.jsx(ea,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:j?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[k.map((F,V)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(An,{value:F,onChange:oe=>{const ae=[...k];ae[V]=oe.target.value,w(ae)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>w(k.filter((oe,ae)=>ae!==V)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]},`${F}-${V}`)),s.jsxs("button",{type:"button",onClick:()=>w([...k,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(_,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Jn,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:q,accept:"*/*"}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>v.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(_,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(jt,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(F=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[F.mimeType.startsWith("image/")?s.jsx(_,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(_,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:F.filename,children:F.filename}),s.jsx("button",{type:"button",onClick:()=>z(F.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(_,{name:"close",className:"h-3 w-3"})})]},F.id))]})]}),a.map((F,V)=>s.jsx(C5,{group:F,groupIndex:V,canRemove:a.length>1,onUpdate:he,onRemove:re},F.id)),s.jsxs("button",{type:"button",onClick:ge,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),we&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:we})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!je&&H!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(_,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(ct,{type:"submit",size:"sm",disabled:!Y||y,children:y?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:ee})})})]})})]})},C5=t=>{const e=tt.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=Nt(),[d,u]=c.useState(!1),[m,f]=c.useState(""),[p,y]=c.useState(!1),[x,k]=c.useState(""),[w,h]=c.useState(!1),[g,j]=c.useState(""),b=c.useRef(null),S=c.useRef(null),C=c.useRef(null),v=c.useRef(null);let E;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(E=ae=>{o(n.id,{models:[...n.models,ae]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=E):E=e[3];const R=E;let A;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(A=ae=>{o(n.id,{models:n.models.filter((pe,le)=>le!==ae)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=A):A=e[7];const O=A;let B;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(B=(ae,pe)=>{o(n.id,{models:n.models.map((le,_e)=>_e===ae?pe:le)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=B):B=e[11];const T=B;let M;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=(ae,pe)=>{if(ae.startsWith("/")){const Me=ae.indexOf(" "),Ae=ae.indexOf(`
893
+ `),Q=Math.min(Me===-1?ae.length:Me,Ae===-1?ae.length:Ae);if(pe<=Q&&Me===-1){k(ae.substring(1,Q)),y(!0),u(!1),h(!1);return}}y(!1);const le=ae.substring(0,pe),_e=le.lastIndexOf("#");if(_e!==-1){const Me=_e>0?le[_e-1]:null,Ae=le.substring(_e+1);if((!Me||/\s/.test(Me))&&!Ae.includes(" ")&&!Ae.includes(`
894
+ `)){j(Ae),h(!0),u(!1);return}}h(!1);const Fe=le.lastIndexOf("@");if(Fe!==-1){const Me=Fe>0?le[Fe-1]:null,Ae=le.substring(Fe+1);(!Me||/\s/.test(Me))&&!Ae.includes(" ")&&!Ae.includes(`
895
+ `)?(f(Ae),u(!0)):u(!1);return}u(!1)},e[12]=M):M=e[12];const L=M;let W;e[13]!==n.id||e[14]!==o?(W=ae=>{o(n.id,{prompt:ae})},e[13]=n.id,e[14]=o,e[15]=W):W=e[15];const $=W;let P;e[16]!==n.prompt||e[17]!==$?(P=ae=>{const pe=n.prompt,_e=b.current?.selectionStart??pe.length,Me=pe.substring(0,_e).lastIndexOf("@"),Ae=ae.relativePath&&ae.relativePath.trim().length>0?ae.relativePath.trim():ae.path||ae.name,Q=Me!==-1?Me:_e,Ce=`${pe.substring(0,Q)}@${Ae} ${pe.substring(_e)}`,Be=Q+Ae.length+2;$(Ce),u(!1),f(""),requestAnimationFrame(()=>{const Le=b.current;Le&&(Le.selectionStart=Be,Le.selectionEnd=Be,Le.focus()),L(Ce,Be)})},e[16]=n.prompt,e[17]=$,e[18]=P):P=e[18];const D=P;let I;e[19]!==n.prompt||e[20]!==$?(I=ae=>{const pe=n.prompt,_e=b.current?.selectionStart??pe.length,Me=pe.substring(0,_e).lastIndexOf("@"),Ae=Me!==-1?Me:_e,Q=`${pe.substring(0,Ae)}@${ae} ${pe.substring(_e)}`,Ce=Ae+ae.length+2;$(Q),u(!1),f(""),requestAnimationFrame(()=>{const Be=b.current;Be&&(Be.selectionStart=Ce,Be.selectionEnd=Ce,Be.focus()),L(Q,Ce)})},e[19]=n.prompt,e[20]=$,e[21]=I):I=e[21];const X=I;let Z;e[22]!==$?(Z=ae=>{const pe=`/${ae.name} `;$(pe),y(!1),k(""),h(!1),requestAnimationFrame(()=>{const le=b.current;le&&(le.focus(),le.selectionStart=le.value.length,le.selectionEnd=le.value.length),L(pe,pe.length)})},e[22]=$,e[23]=Z):Z=e[23];const ne=Z;let ue;e[24]!==n.prompt||e[25]!==$?(ue=(ae,pe)=>{const le=n.prompt,Fe=b.current?.selectionStart??le.length,Ae=le.substring(0,Fe).lastIndexOf("#"),Q=Ae!==-1?Ae:Fe,Ce=`${le.substring(0,Q)}#${pe} ${le.substring(Fe)}`,Be=Q+pe.length+2;$(Ce),h(!1),j(""),requestAnimationFrame(()=>{const Le=b.current;Le&&(Le.selectionStart=Be,Le.selectionEnd=Be,Le.focus()),L(Ce,Be)})},e[24]=n.prompt,e[25]=$,e[26]=ue):ue=e[26];const se=ue;let xe;e[27]!==p||e[28]!==d||e[29]!==w?(xe=ae=>{if(p&&C.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")){ae.preventDefault(),C.current.handleKeyDown(ae.key);return}d&&S.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),S.current.handleKeyDown(ae.key)),w&&v.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),v.current.handleKeyDown(ae.key))},e[27]=p,e[28]=d,e[29]=w,e[30]=xe):xe=e[30];const ie=xe,Re=r+1;let be;e[31]!==a||e[32]!==Re?(be=a("multirun.launcher.groups.groupLabel",{index:Re}),e[31]=a,e[32]=Re,e[33]=be):be=e[33];let fe;e[34]!==be?(fe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:be}),e[34]=be,e[35]=fe):fe=e[35];let ke;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(ke=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=ke):ke=e[40];let H;e[41]!==fe||e[42]!==ke?(H=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[fe,ke]}),e[41]=fe,e[42]=ke,e[43]=H):H=e[43];let J;e[44]!==a?(J=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=J):J=e[45];let ce;e[46]!==J?(ce=s.jsx(Jn,{required:!0,children:J}),e[46]=J,e[47]=ce):ce=e[47];const je=n.prompt;let G;e[48]!==$?(G=ae=>{const pe=ae.target.value;$(pe);const le=ae.target.selectionStart??pe.length;L(pe,le)},e[48]=$,e[49]=G):G=e[49];let we;e[50]!==a?(we=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=we):we=e[51];let Te;e[52]!==n.prompt||e[53]!==ie||e[54]!==G||e[55]!==we?(Te=s.jsx(pr,{ref:b,value:je,onChange:G,onKeyDown:ie,placeholder:we,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=ie,e[54]=G,e[55]=we,e[56]=Te):Te=e[56];let he;e[57]!==x||e[58]!==ne||e[59]!==p?(he=p?s.jsx(Ku,{ref:C,searchQuery:x,onCommandSelect:ne,onClose:()=>y(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=x,e[58]=ne,e[59]=p,e[60]=he):he=e[60];let re;e[61]!==X||e[62]!==D||e[63]!==m||e[64]!==d?(re=d?s.jsx(Vu,{ref:S,searchQuery:m,onFileSelect:D,onAgentSelect:X,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=D,e[63]=m,e[64]=d,e[65]=re):re=e[65];let ge;e[66]!==se||e[67]!==w||e[68]!==g?(ge=w?s.jsx(Uu,{ref:v,searchQuery:g,onSnippetSelect:se,onClose:()=>h(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=se,e[67]=w,e[68]=g,e[69]=ge):ge=e[69];let q;e[70]!==Te||e[71]!==he||e[72]!==re||e[73]!==ge?(q=s.jsxs("div",{className:"relative",children:[Te,he,re,ge]}),e[70]=Te,e[71]=he,e[72]=re,e[73]=ge,e[74]=q):q=e[74];let z;e[75]!==ce||e[76]!==q?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ce,q]}),e[75]=ce,e[76]=q,e[77]=z):z=e[77];let ee;e[78]!==a?(ee=a("multirun.launcher.models.info"),e[78]=a,e[79]=ee):ee=e[79];let de;e[80]!==ee?(de=s.jsx(Bo,{children:ee}),e[80]=ee,e[81]=de):de=e[81];let Y;e[82]!==a?(Y=a("multirun.launcher.models.label"),e[82]=a,e[83]=Y):Y=e[83];let U;e[84]!==de||e[85]!==Y?(U=s.jsx(Jn,{required:!0,info:de,children:Y}),e[84]=de,e[85]=Y,e[86]=U):U=e[86];let F;e[87]!==n.models||e[88]!==R||e[89]!==O||e[90]!==T?(F=s.jsx(Qf,{selectedModels:n.models,onAdd:R,onRemove:O,onUpdate:T,minModels:1}),e[87]=n.models,e[88]=R,e[89]=O,e[90]=T,e[91]=F):F=e[91];let V;e[92]!==U||e[93]!==F?(V=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[U,F]}),e[92]=U,e[93]=F,e[94]=V):V=e[94];let oe;return e[95]!==H||e[96]!==z||e[97]!==V?(oe=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[H,z,V]}),e[95]=H,e[96]=z,e[97]=V,e[98]=oe):oe=e[98],oe};function N5(t){const e=[],n=(r,i)=>{const o=xt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const A5=t=>{const e=new Map;for(const n of t){const r=As(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},P5=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},D5=t=>{const e=tt.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=Qt(),m=A5(i),f=l.current?.runtimeKey===u?l.current.identities:null;for(const p of P5(f,m))tx({runtimeKey:u,...p});l.current={runtimeKey:u,identities:m}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},I5=new Map,T5=t=>{const e=tt.c(23),{isVSCode:n}=t,r=ii(),i=Ut(E5),o=os(R5),l=rt(M5);let a;e[0]!==n?(a=R=>n?I5:R.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=rt(a),u=!n;let m;e[2]!==d||e[3]!==i||e[4]!==u?(m=rm(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=m):m=e[5];const f=m,p=vs(O5),y=vs(B5),x=vs(F5),k=`session-list-sync:${c.useId()}`;let w,h;e[6]!==k||e[7]!==r||e[8]!==o||e[9]!==l?(w=()=>(r.setBootstrapDemand(k,N5({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(k)),h=[k,r,o,l],e[6]=k,e[7]=r,e[8]=o,e[9]=l,e[10]=w,e[11]=h):(w=e[10],h=e[11]),c.useEffect(w,h);const g=c.useRef(null);let j,b;e[12]!==n||e[13]!==f?(j=()=>{const R=new Set(f),A=g.current;g.current=R;const O=A?[...R].filter(B=>!A.has(B)):n?[...R]:[];O.length&&Fa(O,zo())},b=[n,f],e[12]=n,e[13]=f,e[14]=j,e[15]=b):(j=e[14],b=e[15]),c.useEffect(j,b);let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[16]=S):S=e[16],c.useEffect(_5,S);let C;e[17]!==y||e[18]!==p?(C=[...p,...y],e[17]=y,e[18]=p,e[19]=C):C=e[19];const v=C;let E;e[20]!==v||e[21]!==x?(E={enabled:!0,hasAuthoritativeGlobalSessions:x,sessions:v},e[20]=v,e[21]=x,e[22]=E):E=e[22],D5(E)};function E5(t){return t.projects}function R5(t){return t.currentDirectory}function M5(t){return t.currentSessionDirectory}function O5(t){return t.activeSessions}function B5(t){return t.archivedSessions}function F5(t){return t.status==="ready"}function _5(){let t=null,e=!1;const n=new Set,r=Wn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),ai(zo());return}const o=[...n];n.clear(),o.length&&Fa(o,zo())},500)});return()=>{t&&clearTimeout(t),r()}}const L5=Kn(()=>yn(()=>import("./SettingsWindow-BpvD6IYQ.js"),__vite__mapDeps([145,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,146,84,85,86,147,131,132,133,134,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,148,149,150])).then(t=>({default:t.SettingsWindow}))),$5=()=>{const t=tt.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],T5(e),Kh();const n=Ne(z5),r=Ne(W5),i=Ne(K5),o=Ne(V5),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const m=Ne(U5),f=Ne(H5),p=Ne(G5),y=Ne(q5),x=Ne(Y5),k=Ne(Q5),w=Ne(X5),h=Ne(J5),g=Eu();let j;if(t[4]!==g||t[5]!==h){let q;t[7]!==h?(q=z=>z.id===h,t[7]=h,t[8]=q):q=t[8],j=g.find(q),t[4]=g,t[5]=h,t[6]=j}else j=t[6];const b=j;let S,C;t[9]!==b||t[10]!==h?(S=()=>{h&&!b&&Ne.getState().setOpenGuestPage(null)},C=[h,b],t[9]=b,t[10]=h,t[11]=S,t[12]=C):(S=t[11],C=t[12]),c.useEffect(S,C);let v;t[13]===Symbol.for("react.memo_cache_sentinel")?(v=[],t[13]=v):v=t[13],c.useEffect(eC,v);const E=y||x||k||!!w||m||!!b;let R;t[14]===Symbol.for("react.memo_cache_sentinel")?(R=[],t[14]=R):R=t[14],c.useEffect(sC,R);const{isMobile:A}=$n();Vh();let O,B;t[15]!==A||t[16]!==r?(O=()=>{Ne.getState().isMobile!==A&&r(A)},B=[A,r],t[15]=A,t[16]=r,t[17]=O,t[18]=B):(O=t[17],B=t[18]),c.useEffect(O,B);let T,M,L,W,$;t[19]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(zS,{}),M=s.jsx(_0,{}),L=s.jsx(W0,{}),W=s.jsx(D4,{}),$=s.jsx(by,{}),t[19]=T,t[20]=M,t[21]=L,t[22]=W,t[23]=$):(T=t[19],M=t[20],L=t[21],W=t[22],$=t[23]);let P;t[24]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(xy,{}),t[24]=P):P=t[24];let D;t[25]!==n?(D=s.jsx(P4,{isVisible:n}),t[25]=n,t[26]=D):D=t[26];let I;t[27]!==A||t[28]!==n||t[29]!==D?(I=s.jsx(gy,{isOpen:n,isMobile:A,className:"border-border",topBar:P,children:D}),t[27]=A,t[28]=n,t[29]=D,t[30]=I):I=t[30];let X;t[31]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(hy,{}),t[31]=X):X=t[31];const Z=E&&"invisible";let ne;t[32]!==Z?(ne=Ee("absolute inset-0",Z),t[32]=Z,t[33]=ne):ne=t[33];const ue=!i&&!E;let se;t[34]!==ue?(se=s.jsx(Cs,{children:s.jsx(eu,{active:ue})}),t[34]=ue,t[35]=se):se=t[35];let xe;t[36]!==ne||t[37]!==se?(xe=s.jsx("div",{className:ne,children:se}),t[36]=ne,t[37]=se,t[38]=xe):xe=t[38];let ie;t[39]!==m||t[40]!==p||t[41]!==f?(ie=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(k5,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[39]=m,t[40]=p,t[41]=f,t[42]=ie):ie=t[42];let Re;t[43]===Symbol.for("react.memo_cache_sentinel")?(Re=s.jsx(Cs,{children:s.jsx(s5,{})}),t[43]=Re):Re=t[43];let be;t[44]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(Cs,{children:s.jsx(n5,{})}),t[44]=be):be=t[44];let fe;t[45]!==k?(fe=k&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(Uh,{})})}),t[45]=k,t[46]=fe):fe=t[46];let ke;t[47]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(Cs,{children:s.jsx(m5,{})}),t[47]=ke):ke=t[47];let H;t[48]!==b?(H=b&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(cb,{mode:`plugin:${b.id}`,surface:"page",item:null,onDismiss:nC})})}),t[48]=b,t[49]=H):H=t[49];let J;t[50]!==xe||t[51]!==ie||t[52]!==fe||t[53]!==H?(J=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[xe,ie,Re,be,fe,ke,H]}),t[50]=xe,t[51]=ie,t[52]=fe,t[53]=H,t[54]=J):J=t[54];let ce;t[55]===Symbol.for("react.memo_cache_sentinel")?(ce=s.jsx(cS,{}),t[55]=ce):ce=t[55];let je;t[56]!==J?(je=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[J,ce]})})}),t[56]=J,t[57]=je):je=t[57];let G;t[58]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Cs,{children:s.jsx(yS,{})})}),t[58]=G):G=t[58];let we;t[59]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(Cs,{children:s.jsx(Ox,{})}),t[59]=we):we=t[59];let Te;t[60]!==je?(Te=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[X,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[je,G,we]})]}),t[60]=je,t[61]=Te):Te=t[61];let he;t[62]!==I||t[63]!==Te?(he=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[I,Te]}),t[62]=I,t[63]=Te,t[64]=he):he=t[64];let re;t[65]!==i||t[66]!==o||t[67]!==l?(re=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(L5,{open:i,onOpenChange:o})}):null,t[65]=i,t[66]=o,t[67]=l,t[68]=re):re=t[68];let ge;return t[69]!==he||t[70]!==re?(ge=s.jsx(Hh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[T,M,L,W,$,he,re]})}),t[69]=he,t[70]=re,t[71]=ge):ge=t[71],ge};function z5(t){return t.isSidebarOpen}function W5(t){return t.setIsMobile}function K5(t){return t.isSettingsDialogOpen}function V5(t){return t.setSettingsDialogOpen}function U5(t){return t.isMultiRunLauncherOpen}function H5(t){return t.setMultiRunLauncherOpen}function G5(t){return t.multiRunLauncherPrefillPrompt}function q5(t){return t.isScheduledTasksDialogOpen}function Y5(t){return t.isArchivePageOpen}function Q5(t){return t.isUsageStatsPageOpen}function X5(t){return t.worktreesPageProjectId}function J5(t){return t.openGuestPageId}function Z5(){return Ne.getState().setOpenGuestPage(null)}function eC(){return Cr(Z5)}function tC(){return Ne.getState().closeMainSurfaces()}function sC(){const t=tC,e=rt.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function nC(){return Ne.getState().setOpenGuestPage(null)}const lm=12,rC=[{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"}],oC=t=>{const e=tt.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,m=l===void 0?rC:l,f=ut.useRef(!1);let p,y;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},y=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=y):(p=e[2],y=e[3]),ut.useEffect(p,y);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=Array.from({length:lm},iC),e[4]=x):x=e[4];const k=x;if(!n)return null;let w;e[5]!==i?(w=Ee("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=w):w=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let j;e[11]!==d||e[12]!==u?(j=b=>{const S={"--burst-delay":`${b.delay}ms`,"--burst-x":`${b.x}%`,"--burst-y":`${b.y}%`,"--firework-color":`var(${b.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:S,children:k.map((C,v)=>{const E=C.x*b.radius,R=C.y*b.radius,A={"--translate-x":`${E}px`,"--translate-y":`${R}px`,"--particle-delay":`${C.delay}ms`,color:`var(${b.colorVar})`};return s.jsx("span",{className:"firework-particle",style:A},`${b.id}-${v}-${d}`)})},`${b.id}-${d}`)},e[11]=d,e[12]=u,e[13]=j):j=e[13],h=m.map(j),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let g;return e[14]!==d||e[15]!==w||e[16]!==h?(g=s.jsx("div",{className:w,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=w,e[16]=h,e[17]=g):g=e[17],g};function iC(t,e){const n=Math.PI*2*e/lm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const aC=t=>{const e=tt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ut.useState(o),d=ut.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 m=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{m(),a(lC)},e[4]=f):f=e[4];const p=f;let y;e[5]!==i?(y=()=>{m(),a(cC),d.current=window.setTimeout(()=>{a(dC),d.current=null},i)},e[5]=i,e[6]=y):y=e[6];const x=y;let k,w;e[7]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>m(),w=[m],e[7]=k,e[8]=w):(k=e[7],w=e[8]),ut.useEffect(k,w);let h;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==x?(h={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:x,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=x,e[12]=h):h=e[12],h};function lC(t){return t.isActive?{...t,isActive:!1}:t}function cC(t){return{isActive:!0,cycle:t.cycle+1}}function dC(t){return t.isActive?{...t,isActive:!1}:t}const cm=c.createContext(void 0),uC=t=>{const e=tt.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=aC();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(oC,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(cm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},nA=()=>{const t=c.useContext(cm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Ta="openchamber_requests_in_flight",dm=1e3,fC=300*1e3,Jo=Math.ceil(fC/dm),mC=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ta)==="1"}catch{return!1}},um=()=>({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 hC=1;const pC=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},gC=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},fm=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},jr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},xC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=hC++;pC(o,Date.now());try{return await e(r,i)}finally{gC(o)}};window.fetch=n},Sd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Or=t=>{t.length>Jo&&t.splice(0,t.length-Jo)},bC=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=fm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(jr(e,50)),t.p90Samples.push(jr(e,90)),t.p99Samples.push(jr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Or(t.samples),Or(t.p50Samples),Or(t.p90Samples),Or(t.p99Samples),Or(t.maxSamples),t.lastSampleAt=Date.now()},yC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(bC,dm))},jd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},kd=t=>{if(!(typeof window>"u"))try{if(t){jd(),Sd(),window.localStorage.setItem(Ta,"1"),window.__openchamberRequestsInFlight__=um(),xC(),yC();return}window.localStorage.removeItem(Ta),jd(),Sd(),delete window.__openchamberRequestsInFlight__}catch{}},wC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=um();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},Ea=()=>{if(typeof window>"u")return Cd();const t=window.__openchamberRequestsInFlight__;if(!mC()||!t)return Cd();const e=fm(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:jr(e,50),ageP90:jr(e,90),ageP99:jr(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:Jo}},Cd=()=>({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:Jo});function vC(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const mm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Ra=t=>`${(t/1e3).toFixed(2)} s`,ws=t=>{const e=tt.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Nd=t=>{const e=tt.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=Nt();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(kC,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?mm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let y;e[18]!==m||e[19]!==p?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,p]}),e[18]=m,e[19]=p,e[20]=y):y=e[20];let x;e[21]!==o?(x=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=x):x=e[22];let k;e[23]!==r.entries.length||e[24]!==x?(k=s.jsx(ws,{label:x,value:r.entries.length}),e[23]=r.entries.length,e[24]=x,e[25]=k):k=e[25];let w;e[26]!==o?(w=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=w):w=e[27];let h;e[28]!==w||e[29]!==u?(h=s.jsx(ws,{label:w,value:u}),e[28]=w,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==o?(g=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=g):g=e[32];let j;e[33]!==r.lastUpdatedAt||e[34]!==o?(j=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=j):j=e[35];let b;e[36]!==g||e[37]!==j?(b=s.jsx(ws,{label:g,value:j}),e[36]=g,e[37]=j,e[38]=b):b=e[38];let S;e[39]!==h||e[40]!==b||e[41]!==k?(S=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[k,h,b]}),e[39]=h,e[40]=b,e[41]=k,e[42]=S):S=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[y,S,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(En,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},Ad=t=>{const e=tt.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(CC,0),u=r>0?52/r:0;let m;e[0]!==d||e[1]!==a?(m=b=>a-d+b,e[0]=d,e[1]=a,e[2]=m):m=e[2];const f=m;let p;e[3]!==u?(p=b=>56-b*u,e[3]=u,e[4]=p):p=e[4];const y=p;let x;e[5]!==l?(x=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=x):x=e[6];const k=`0 0 ${a} 56`;let w;e[7]!==a?(w=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=w):w=e[8];let h;if(e[9]!==n||e[10]!==f||e[11]!==y){let b;e[13]!==f||e[14]!==y?(b=(S,C)=>{const v=S.samples.length;if(v===0)return null;const E=S.samples.map((A,O)=>`${f(O)},${y(A).toFixed(2)}`),R=`M ${E.join(" L ")}`;return s.jsxs(c.Fragment,{children:[S.filled?s.jsx("path",{d:`M ${f(0)},56 L ${E.join(" L ")} L ${f(v-1)},56 Z`,fill:`color-mix(in srgb, ${S.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:R,fill:"none",stroke:S.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=y,e[15]=b):b=e[15],h=n.map(b),e[9]=n,e[10]=f,e[11]=y,e[12]=h}else h=e[12];let g;e[16]!==o||e[17]!==k||e[18]!==w||e[19]!==h?(g=s.jsxs("svg",{viewBox:k,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[w,h]}),e[16]=o,e[17]=k,e[18]=w,e[19]=h,e[20]=g):g=e[20];let j;return e[21]!==x||e[22]!==g?(j=s.jsxs("div",{className:"relative w-full",children:[x,g]}),e[21]=x,e[22]=g,e[23]=j):j=e[23],j},SC=t=>{const e=tt.c(100),{onClose:n}=t,{t:r}=Nt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=rt(NC),u=$u(AC),m=Cu(),f=sx(PC),p=Vs(DC),[y,x]=c.useState(IC),[k,w]=c.useState(TC),[h,g]=c.useState(EC),j=[{label:"p50",current:h.ageP50,samples:h.p50Samples,color:"var(--status-success)"},{label:"p90",current:h.ageP90,samples:h.p90Samples,color:"var(--status-info)"},{label:"p99",current:h.ageP99,samples:h.p99Samples,color:"var(--status-warning)"},{label:"max",current:h.ageMax,samples:h.maxSamples,color:"var(--status-error)"}];let b;e[0]!==h.samples?(b=h.samples.reduce(RC,0),e[0]=h.samples,e[1]=b):b=e[1];const S=b,C=j.reduce(OC,0);let v;e[2]!==y.entries?(v=new Map,y.entries.forEach(Be=>{v.set(Be.metric,Be.count)}),e[2]=y.entries,e[3]=v):v=e[3];let E;e[4]!==v?(E=v.get("ui.message_list.render")??0,e[4]=v,e[5]=E):E=e[5];let R;e[6]!==v?(R=v.get("ui.message_list.render.streaming")??0,e[6]=v,e[7]=R):R=e[7];let A;e[8]!==v?(A=v.get("ui.chat_message.render")??0,e[8]=v,e[9]=A):A=e[9];let O;e[10]!==v?(O=v.get("ui.chat_message.render.streaming")??0,e[10]=v,e[11]=O):O=e[11];let B;e[12]!==v?(B=v.get("ui.chat_message.render.static_during_stream")??0,e[12]=v,e[13]=B):B=e[13];let T;e[14]!==v?(T=v.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=v,e[15]=T):T=e[15];let M;e[16]!==E||e[17]!==R||e[18]!==A||e[19]!==O||e[20]!==B||e[21]!==T?(M={messageListRender:E,messageListRenderStreaming:R,chatMessageRender:A,chatMessageRenderStreaming:O,chatMessageRenderStaticDuringStream:B,chatMessageRenderStaticOutsideActiveTurnDuringStream:T},e[16]=E,e[17]=R,e[18]=A,e[19]=O,e[20]=B,e[21]=T,e[22]=M):M=e[22];const L=M;let W,$;e[23]===Symbol.for("react.memo_cache_sentinel")?($=()=>{const Be=()=>{x(Po()),w(Do()),g(Ea())};Be();const Le=window.setInterval(Be,500);return()=>window.clearInterval(Le)},W=[],e[23]=W,e[24]=$):(W=e[23],$=e[24]),c.useEffect($,W);let P,D;e[25]!==l?(P=()=>{if(l==="idle")return;const Be=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Be)},D=[l],e[25]=l,e[26]=P,e[27]=D):(P=e[26],D=e[27]),c.useEffect(P,D);let I=0,X=0,Z=0;for(const Be of Object.keys(f)){const Le=f[Be]??[];X=X+Le.length;for(const Je of Le)Je.role==="user"?Z=Z+1:Je.role==="assistant"&&(I=I+1)}let ne;e[28]!==I||e[29]!==X||e[30]!==Z?(ne={assistant:I,total:X,user:Z},e[28]=I,e[29]=X,e[30]=Z,e[31]=ne):ne=e[31];const ue=ne;let se;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==m||e[36]!==r){let Be;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Be=Le=>{const Je=f[Le.id]??[];let ot=0,et=0;for(const ht of Je)ht.role==="user"?et=et+1:ht.role==="assistant"&&(ot=ot+1);const it=u.get(Le.id);return{id:Le.id,title:Le.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ot,messageCount:Je.length,userMessageCount:et,isStreaming:it?.isStreaming||!1,isZombie:it?.isZombie||!1,backgroundCount:it?.backgroundMessageCount||0,lastAccessed:it?.lastAccessedAt||0,isCurrent:Le.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Be):Be=e[42],se=m.map(Be).sort(BC),e[32]=d,e[33]=f,e[34]=u,e[35]=m,e[36]=r,e[37]=se}else se=e[37];const xe=se;let ie;e[43]!==f?(ie=Object.keys(f),e[43]=f,e[44]=ie):ie=e[44];const Re=ie.length;let be;e[45]===Symbol.for("react.memo_cache_sentinel")?(be=async()=>{try{const Be={generatedAt:new Date().toISOString(),ui:Po(),vscode:Do()};await navigator.clipboard.writeText(JSON.stringify(Be,null,2)),a("copied")}catch{a("error")}},e[45]=be):be=e[45];const fe=be,ke=rx,H="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let J;e[46]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=J):J=e[46];let ce;e[47]!==i?(ce=vC(i),e[47]=i,e[48]=ce):ce=e[48];let je;e[49]!==ce?(je=s.jsx(_,{name:ce,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=ce,e[50]=je):je=e[50];let G;e[51]!==r?(G=r("memoryDebugPanel.title"),e[51]=r,e[52]=G):G=e[52];let we;e[53]!==G?(we=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:G}),e[53]=G,e[54]=we):we=e[54];let Te;e[55]!==je||e[56]!==we?(Te=s.jsxs("div",{className:"flex items-center gap-2",children:[je,we]}),e[55]=je,e[56]=we,e[57]=Te):Te=e[57];let he;e[58]!==i?(he=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ct,{size:"xs",variant:"ghost",onClick:fe,children:s.jsx(_,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ct,{size:"xs",variant:"ghost",onClick:()=>{eh(),x(Po()),w(Do())},children:s.jsx(_,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=he):he=e[59];let re;e[60]!==i?(re=i==="requests"?s.jsx(ct,{size:"xs",variant:"ghost",onClick:()=>{wC(),g(Ea())},children:s.jsx(_,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=re):re=e[61];let ge;e[62]!==n?(ge=n?s.jsx(ct,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(_,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=ge):ge=e[63];let q;e[64]!==he||e[65]!==re||e[66]!==ge?(q=s.jsxs("div",{className:"flex items-center gap-1",children:[he,re,ge]}),e[64]=he,e[65]=re,e[66]=ge,e[67]=q):q=e[67];let z;e[68]!==Te||e[69]!==q?(z=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Te,q]}),e[68]=Te,e[69]=q,e[70]=z):z=e[70];let ee;e[71]===Symbol.for("react.memo_cache_sentinel")?(ee={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ee):ee=e[71];const de=i==="memory"?"secondary":"ghost";let Y;e[72]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>o("memory"),e[72]=Y):Y=e[72];let U;e[73]!==r?(U=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=U):U=e[74];let F;e[75]!==de||e[76]!==U?(F=s.jsx(ct,{size:"sm",variant:de,className:"flex-1",onClick:Y,children:U}),e[75]=de,e[76]=U,e[77]=F):F=e[77];const V=i==="streaming"?"secondary":"ghost";let oe;e[78]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>o("streaming"),e[78]=oe):oe=e[78];let ae;e[79]!==r?(ae=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ae):ae=e[80];let pe;e[81]!==V||e[82]!==ae?(pe=s.jsx(ct,{size:"sm",variant:V,className:"flex-1",onClick:oe,children:ae}),e[81]=V,e[82]=ae,e[83]=pe):pe=e[83];const le=i==="requests"?"secondary":"ghost";let _e;e[84]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>o("requests"),e[84]=_e):_e=e[84];let Fe;e[85]!==r?(Fe=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Fe):Fe=e[86];let Me;e[87]!==le||e[88]!==Fe?(Me=s.jsx(ct,{size:"sm",variant:le,className:"flex-1",onClick:_e,children:Fe}),e[87]=le,e[88]=Fe,e[89]=Me):Me=e[89];let Ae;e[90]!==F||e[91]!==pe||e[92]!==Me?(Ae=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ee,children:[F,pe,Me]}),e[90]=F,e[91]=pe,e[92]=Me,e[93]=Ae):Ae=e[93];const Q=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ws,{label:r("memoryDebugPanel.metric.totalMessages"),value:ue.total}),s.jsx(ws,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Re} / ${Wl.MAX_SESSIONS}`}),s.jsx(ws,{label:r("memoryDebugPanel.metric.userMessages"),value:ue.user}),s.jsx(ws,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ue.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:nx()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Wl.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(En,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:xe.map(Be=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Be.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Be.title}),Be.isStreaming?s.jsx(_,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Be.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Be.assistantMessageCount,user:Be.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Be.messageCount})}),Be.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Be.backgroundCount]}):null]})]},Be.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(FC),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:ue,sessionMessageRoleCounts:xe.map(_C),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(jt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(ct,{size:"xs",variant:"outline",onClick:fe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ws,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:k.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Nd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),k.entries.length>0?s.jsx(Nd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:k,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ws,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${h.totalSettled} / ${h.totalStarted}`}),s.jsx(ws,{label:r("memoryDebugPanel.requests.tracking"),value:h.startedAt?mm(h.durationMs):r("memoryDebugPanel.common.idle")})]}),h.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.peak})]})]}),s.jsx(Ad,{series:[{samples:h.samples,color:"var(--status-info)",filled:!0}],peak:S,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:h.peak}),maxLabel:`${S}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ra(h.peakAgeMs)})]}),s.jsx(Ad,{series:j.map(LC),peak:C,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Ra(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map($C)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:h.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let Ce;return e[94]!==ke||e[95]!==J||e[96]!==z||e[97]!==Ae||e[98]!==Q?(Ce=s.jsxs(ke,{className:H,style:J,children:[z,Ae,Q]}),e[94]=ke,e[95]=J,e[96]=z,e[97]=Ae,e[98]=Q,e[99]=Ce):Ce=e[99],Ce},jC=SC;function kC(t,e){return t+e.count}function CC(t,e){return Math.max(t,e.samples.length)}function NC(t){return t.currentSessionId}function AC(t){return t.sessionMemoryState}function PC(t){return t.message}function DC(t){return t.totalRequestCount}function IC(){return Po()}function TC(){return Do()}function EC(){return Ea()}function RC(t,e){return Math.max(t,e)}function MC(t,e){return Math.max(t,e)}function OC(t,e){return e.samples.reduce(MC,t)}function BC(t,e){return e.lastAccessed-t.lastAccessed}function FC(t){return{id:t.id,title:t.title}}function _C(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function LC(t){return{samples:t.samples,color:t.color}}function $C(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ra(t.current)})]},t.label)}const zC=()=>{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()??"":""},WC=async()=>{const t=zC()||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")},Pd="openchamber:menu-action",Vi="openchamber:check-for-updates",KC=t=>{const e=rt(h=>h.openNewSessionDraft),n=Ne(h=>h.toggleCommandPalette),r=Ne(h=>h.setCommandPaletteOpen),i=Ne(h=>h.toggleHelpDialog),o=Ne(h=>h.toggleSidebar),l=Ne(h=>h.setSessionSwitcherOpen),a=Ne(h=>h.setSettingsDialogOpen),d=Ne(h=>h.setAboutDialogOpen),u=Kr(h=>h.checkForUpdates),{setThemeMode:m}=Ln(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:h,error:g}=Kr.getState();if(g){Ke.error("Failed to check for updates",{description:g});return}h||Ke.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),y=c.useCallback(()=>{un.requestDirectoryDialog()},[]),x=c.useCallback(h=>{const g=ox();if(g.length===0)return;const j=rt.getState().currentSessionId,b=g.findIndex(v=>v.id===j);let S=h>0?0:g.length-1;b>=0&&(S=(b+h+g.length)%g.length);const C=g[S];C&&(l(!1),rt.getState().setCurrentSession(C.id))},[l]),k=c.useCallback(h=>{const{activeProjectId:g,projects:j,setActiveProject:b}=Ut.getState();if(j.length===0)return;const S=j.findIndex(E=>E.id===g);let C=h>0?0:j.length-1;S>=0&&(C=(S+h+j.length)%j.length);const v=j[C];v&&b(v.id)},[]),w=c.useCallback(h=>{switch(h){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const g=rt.getState(),j=os.getState().currentDirectory;e(g.currentSessionId&&j?{directoryOverride:j}:void 0)}break;case"new-worktree-session":l(!1),Iu();break;case"change-workspace":y();break;case"toggle-right-sidebar":{const g=os.getState().currentDirectory;if(!g)break;const j=Ne.getState(),b=Qn(g),S=j.contextPanelByDirectory[b];S?.isOpen?j.closeContextPanel(b):S?.activeTabId?j.setActiveContextPanelTab(b,S.activeTabId):j.openContextSurface(b,"git");break}case"open-right-sidebar-git":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"git");break}case"open-right-sidebar-files":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"file");break}case"toggle-terminal":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"terminal");break}case"toggle-terminal-expanded":{const g=os.getState().currentDirectory;if(!g)break;const j=Qn(g),b=Ne.getState(),S=b.contextPanelByDirectory[j];(S?.isOpen?S.tabs.find(v=>v.id===S.activeTabId)?.mode:null)!=="terminal"&&b.openContextSurface(j,"terminal"),b.toggleContextPanelExpanded(j);break}case"copy":{const g=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(g)||WC();break}case"theme-light":m("light");break;case"theme-dark":m("dark");break;case"theme-system":m("system");break;case"add-selection-to-chat":ix();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":os.getState().goBack();break;case"go-forward":os.getState().goForward();break;case"previous-session":x(-1);break;case"next-session":x(1);break;case"previous-project":k(-1);break;case"next-project":k(1);break;case"help-dialog":i();break;case"download-logs":{Tu().catch(()=>{Ke.error("Failed to collect OpenCode status")});break}}},[y,k,x,t,e,d,l,r,a,m,n,i,o]);c.useEffect(()=>{const h=j=>{const b=j.detail;b&&w(b)},g=()=>{p()};return window.addEventListener(Pd,h),window.addEventListener(Vi,g),()=>{window.removeEventListener(Pd,h),window.removeEventListener(Vi,g)}},[w,p]),c.useEffect(()=>{if(typeof window>"u")return;const g=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof g!="function")return;let j=null,b=null;return g("openchamber:menu-action",S=>{const C=S?.payload;typeof C=="string"&&w(C)}).then(S=>{j=S}).catch(()=>{}),g("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Vi))}).then(S=>{b=S}).catch(()=>{}),()=>{(async()=>{try{const C=j?.();C instanceof Promise&&await C}catch{}try{const C=b?.();C instanceof Promise&&await C}catch{}})()}},[w])},VC="openchamber:tray-action",UC=5e3,HC=500,GC=20,Dd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Id=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,hm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},pm=t=>t.title.trim()||"Question",qC=(t,e)=>Xa(t,e,Qr.getState().ids,Ua.getState().rankById),YC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},QC=(t,e,n,r,i)=>{if(!t)return"";const o=su(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||YC(t),d=Io(t);let u=d&&i.get(d)||"";if(!u){for(const[m,f]of Tn.getState().directories)if(Io(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(p=>Io(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},XC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=hr.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of lx){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:dx(m),value:cx(f.valueLabel,p)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},JC=async()=>{try{if(Zo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Dn();if(e&&xl(e,t))return"Local OpenChamber";const r=(await Bd()).hosts.find(i=>e?xl(e,th(i)):!1);return r?.label?.trim()?Fd(r.label.trim()):"Instance"}catch{return""}},ZC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=la()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(Io(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:hm(m),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"form",id:m.id,sessionId:f,sessionTitle:"",label:pm(m),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},eN=(t,e)=>{const n=qa.getState().index.session,r=vs.getState().activeSessions,i=new Map;for(const g of r)if(g?.id&&g.parentID){const j=i.get(g.parentID)??[];j.push(g.id),i.set(g.parentID,j)}const o=g=>{const j=[],b=[...i.get(g)??[]],S=new Set;for(;b.length;){const C=b.pop();S.has(C)||(S.add(C),j.push(C),b.push(...i.get(C)??[]))}return j},l=Ne.getState();let a=0;if(l.dockBadgeEnabled)for(const g of r){if(!g?.id||g.parentID)continue;let j=n.unseenCount[g.id]??0;j===0&&l.notifyOnSubtasks&&(j=o(g.id).reduce((b,S)=>b+(n.unseenCount[S]??0),0)),j>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=ZC(),u=new Map(d.titleById);for(const g of r)g?.id&&g.title&&u.set(g.id,g.title);const m=si.getState().statusById,f=g=>{const j=d.statusById.get(g);return j&&j!=="idle"?j:m.get(g)?.status.type??j??"idle"},p=g=>{const j=g.map(b=>f(b));return j.includes("busy")?"busy":j.includes("retry")?"retry":"idle"},y=Ut.getState().projects,x=rt.getState().availableWorktreesByProject,k=r.filter(g=>g?.id&&!g.parentID).slice().sort(qC).slice(0,GC).map(g=>{const j=[g.id,...o(g.id)],b=As(g)??"";return{id:g.id,title:g.title||"Untitled session",status:p(j),branch:b?d.branchByDirectory.get(b)??"":"",unseen:j.reduce((S,C)=>S+(n.unseenCount[C]??0),0),hasError:j.some(S=>n.unseenHasError[S]??!1),directory:b,subtitle:QC(b,g,y,x,d.branchByDirectory)}}),w=d.approvals.map(g=>({...g,sessionTitle:u.get(g.sessionId)||""})),h=new Set(w.map(g=>g.id));for(const[g,j]of Ya.getState().bySession){const b=u.get(g)||"";for(const S of j.permissions)h.has(S.id)||(h.add(S.id),w.push({kind:"permission",id:S.id,sessionId:g,sessionTitle:b,label:hm(S),directory:j.directory}));for(const S of j.forms)h.has(S.id)||(h.add(S.id),w.push({kind:"form",id:S.id,sessionId:g,sessionTitle:b,label:pm(S),directory:j.directory}))}return{sessions:k,approvals:w,instanceName:t,usage:XC(),dockBadgeCount:a}},tN=()=>{c.useEffect(()=>{if(!Dd()||!qr())return;const t=Id();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const v=eN(i,t),E=JSON.stringify(v);E!==n&&(n=E,Fn("desktop_tray_update",v))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},HC))},a=qa.subscribe(()=>l()),d=vs.subscribe(()=>l()),u=Ne.subscribe((v,E)=>{(v.dockBadgeEnabled!==E.dockBadgeEnabled||v.notifyOnSubtasks!==E.notifyOnSubtasks)&&l()}),m=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),m;JC().then(v=>{e||(i=v,o())});const f=new Map,p=()=>{if(e)return;let v;try{v=la()}catch{return}const E=new Set;for(const[R,A]of v.children.entries())E.add(R),f.has(R)||f.set(R,A.subscribe(()=>l()));for(const[R,A]of f)E.has(R)||(A(),f.delete(R))};let y=null;try{y=la().subscribeRegistry(()=>{p(),l()})}catch{}p();const x=Ut.subscribe(()=>l()),k=rt.subscribe(()=>l()),w=Tn.subscribe(()=>l()),h=si.subscribe(()=>l()),g=Ya.subscribe(()=>l()),j=Ua.subscribe(()=>l()),b=Qr.subscribe(()=>l()),S=hr.subscribe(()=>l());hr.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:v,results:E}=hr.getState();v.length>0&&v.some(A=>!E.some(O=>O.providerId===A))&&hr.getState().fetchQuotas(v)});const C=window.setInterval(()=>{p(),o()},UC);return o(),()=>{m(),window.clearInterval(C),x(),k(),w(),h(),g(),j(),b(),S(),y?.();for(const v of f.values())v();f.clear()}},[]),c.useEffect(()=>{if(!Dd()||!Id()||!qr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&ax(i.sessionId,i.id,i.response).catch(()=>{Ke.error("Failed to respond to permission request")})};let r=null;return e(VC,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},sN=30*6e4,nN=(t,e,n=sN)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Br=null;const rN=()=>{if(Br)return Br;const t=Qt();return Br=(async()=>{const e=await dn.getHostSessionStatusSnapshot();if(!e||Qt()!==t)return;const n=si.getState(),r=vs.getState().entityById,i=nN(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?As(a):null}});for(const[l,a]of i)ux(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?As(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}fx(o)})().finally(()=>{Br=null}),Br},oN=45e3,iN=[1e3,2e3,4e3],aN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const m=await u().catch(()=>!1);if(i)return;a||=m;const f=a?void 0:iN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??oN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},lN=t=>{const e=tt.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=cN;let o=i();const l=Cr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function cN(){const t=Qt();let e=!0;const n=async i=>(i?await mx(zo()):await ai(),!e||Qt()!==t?!1:(rN(),vs.getState().status==="ready")),r=aN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const dN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,uN=t=>{const e=tt.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||xn()||!Ma()||!globalThis.window))return Wn(fN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function fN(t){if(t.type!=="notification")return;const e=Ne.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&dN())return;Od()?.notifications?.notifyAgentCompletion(t.payload)}const mN=6e4,hN=t=>{const e=tt.c(10),n=Ne(pN),r=hx(gN),o=Gh(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:mN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Wn(m=>{m.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function pN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function gN(t){return t.load}const xN=()=>{const t=tt.c(4),{t:e}=Nt(),n=Ne(bN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Wn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),Ke.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function bN(t){return t.setBrowserProvider}const Td="pwa-install-toast-shown",Ed="pwa-install-toast-dismissed",yN=()=>{const t=tt.c(6),{browserTab:e}=qh(),{t:n}=Nt(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!Ma()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(Ke.dismiss(u),u=null)},f=async()=>{if(!d)return;const x=d;d=null,m(),await x.prompt();const{outcome:k}=await x.userChoice;k==="accepted"&&Ke.success(r.current("pwa.installPrompt.started"))},p=x=>{const k=x;if(typeof k.prompt!="function")return;k.preventDefault(),d=k;const w=_o(),h=sh();Yh({dismissed:w.getItem(Ed),sessionShown:h.getItem(Td),hasActiveToast:u!==null})&&(h.setItem(Td,"true"),u=Ke.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{_o().setItem(Ed,"true"),m()}}}))},y=()=>{d=null,m(),Ke.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",y),()=>{m(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",y)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},wN=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[m,f]=c.useState(!1),[p,y]=c.useState(null),[x,k]=c.useState(!1);c.useCallback(async()=>{},[p,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const g=await bs("/api/system/info");if(g.ok){const j=await g.json();if(typeof j.openchamberVersion=="string"&&j.openchamberVersion.trim()){o(j.openchamberVersion);return}}}catch{}o(await px())})()},[t]),c.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const j=await bs("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!j.ok)return;const b=await j.json().catch(()=>null),S=typeof b?.currentVersion=="string"?b.currentVersion.trim():"";!h&&S&&a(S)}catch{}})(),()=>{h=!0}},[t]),c.useEffect(()=>{{y(null),k(!1);return}},[t,r]);const w=i;return s.jsx(Ps,{open:t,onOpenChange:e,children:s.jsx(Ds,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Nu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[w&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:w})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(_,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(_,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(_,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},vN="\x1B",SN=new RegExp(`${vN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Ao=lr().transform(t=>t.replace(SN,"").trim()).nullish(),jN=Xl({isOpenCodeReady:Jl().optional(),openCodeRunning:Jl().optional(),lastOpenCodeError:Ao,opencodeBinaryResolved:Ao,lastOpenCodeLaunchDiagnostics:Xl({sourceBinary:Ao,binary:Ao}).nullish()}),kN=async(t,e=bs)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=jN.parse(await n.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}},Rd=Kn(()=>yn(()=>import("./OnboardingScreen-rK4Stg__.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])).then(t=>({default:t.OnboardingScreen}))),CN=()=>{const t=tt.c(3),e=Ne(TN),n=Ne(EN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(wN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},NN=t=>{const e=tt.c(28),{onRetry:n,isRetrying:r}=t,{t:i}=Nt(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const j=new AbortController,b=Qt(),S=setTimeout(()=>j.abort(),5e3);return kN(j.signal).then(C=>{!j.signal.aborted&&Qt()===b&&l(C)}).catch(RN).finally(()=>clearTimeout(S)),()=>{j.abort(),clearTimeout(S)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);let u;e[2]!==i?(u=i("startup.initRecovery.title"),e[2]=i,e[3]=u):u=e[3];let m;e[4]!==u?(m=s.jsx("h1",{className:"typography-title text-foreground",children:u}),e[4]=u,e[5]=m):m=e[5];const f=o?"startup.initRecovery.openCodeUnavailable":"startup.initRecovery.description";let p;e[6]!==i||e[7]!==f?(p=i(f),e[6]=i,e[7]=f,e[8]=p):p=e[8];let y;e[9]!==p?(y=s.jsx("p",{className:"typography-body text-muted-foreground",children:p}),e[9]=p,e[10]=y):y=e[10];let x;e[11]!==m||e[12]!==y?(x=s.jsxs("div",{className:"flex flex-col gap-2",children:[m,y]}),e[11]=m,e[12]=y,e[13]=x):x=e[13];let k;e[14]!==o||e[15]!==i?(k=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[14]=o,e[15]=i,e[16]=k):k=e[16];let w;e[17]!==r||e[18]!==i?(w=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[17]=r,e[18]=i,e[19]=w):w=e[19];let h;e[20]!==r||e[21]!==n||e[22]!==w?(h=s.jsx(ct,{type:"button",onClick:n,disabled:r,children:w}),e[20]=r,e[21]=n,e[22]=w,e[23]=h):h=e[23];let g;return e[24]!==h||e[25]!==x||e[26]!==k?(g=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[x,k,h]})}),e[24]=h,e[25]=x,e[26]=k,e[27]=g):g=e[27],g},Md=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",AN=()=>{if(typeof window>"u"||!lb())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},PN=t=>{const e=tt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=os(MN),l=rt(ON),a=rt(BN),d=vx(),u=c.useRef(null);let m;e[0]!==n.directory?(m=Md(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let p;e[2]!==o?(p=Md(o),e[2]=o,e[3]=p):p=e[3];const y=p;let x,k;if(e[4]!==y||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(x=()=>{if(r||f&&y!==f)return;const S=`${f}
896
+ ${n.sessionId}`;u.current===S&&l||(u.current=S,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},k=[y,l,n.directory,n.sessionId,f,r,a,d],e[4]=y,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=x,e[13]=k):(x=e[12],k=e[13]),c.useEffect(x,k),f&&y!==f)return null;let w;e[14]!==i?(w=s.jsx(Hu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=w):w=e[15];let h;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(tu,{}),e[16]=h):h=e[16];let g;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(g=s.jsx(eu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=g):g=e[20];let j;e[21]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Gu,{}),e[21]=j):j=e[21];let b;return e[22]!==w||e[23]!==g?(b=s.jsxs(s.Fragment,{children:[w,h,g,j]}),e[22]=w,e[23]=g,e[24]=b):b=e[24],b};function DN({apis:t}){c.useEffect(()=>{nh("App:mounted"),rh()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Yt(H=>H.initializeApp),n=Yt(H=>H.isInitialized),r=Yt(H=>H.isConnected),i=Yt(H=>H.providers.length),o=Yt(H=>H.agents.length),l=Yt(H=>H.loadProviders),a=Yt(H=>H.loadAgents),d=rt(H=>H.error),u=rt(H=>H.clearError),m=os(H=>H.currentDirectory),f=os(H=>H.setDirectory),p=os(H=>H.isSwitchingDirectory),[y,x]=c.useState(!1),k=In(H=>H.refreshStatus),w=ta(H=>H.refreshStatus),[h,g]=c.useState(()=>t.runtime.isVSCode),[j,b]=c.useState(!1),[S,C]=c.useState(!1),[v,E]=c.useState(0),[R,A]=c.useState(0),[O,B]=c.useState(!1),T=Ne(H=>H.wideChatLayoutEnabled),M=Ne(H=>H.mobileKeyboardMode),L=c.useMemo(()=>xn(),[]),W=La(H=>H.setPlanModeEnabled),[$,P]=c.useState(()=>bl()),[D,I]=c.useState(()=>{const H=yl();return H!==null?wl({isDesktopShell:!0,bootOutcome:H}):null}),X=c.useRef(!1),Z=c.useMemo(()=>AN(),[]),ne=!Z||j;c.useEffect(()=>(vl(y),kd(y),()=>{vl(!1),kd(!1)}),[y]),c.useEffect(()=>{oh(M)},[M]),c.useEffect(()=>{g(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Cr(H=>{Xh(H),A(J=>J+1),C(!1),E(J=>J+1)}),[]);const ue=Kl(H=>{const J=Qt();return Object.values(H.runsByOriginalSessionID).filter(ce=>ce.status==="running"&&ce.runtimeKey===J).map(ce=>`${ce.originalSessionID}:${ce.phase}:${ce.lastForwardedMessageID??""}:${ce.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(Z)return;const H=Qt(),J=Object.values(Kl.getState().runsByOriginalSessionID).filter(ce=>ce.status==="running"&&ce.runtimeKey===H);for(const ce of J)gx(ce.originalSessionID)},[ue,Z,R]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",T),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[T]),c.useEffect(()=>(Sl(t),()=>Sl(null)),[t]),c.useEffect(()=>{Z||(k(t.github,{force:!0}),w(t.linear,{force:!0}))},[t.github,t.linear,Z,r,k,w,R]),xx();const se=$==="valid",xe=D?.screen==="main";c.useEffect(()=>{if(!ih({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:se,bootViewIsMain:xe}))return;const H=setTimeout(()=>{const J=document.getElementById("initial-loading");J&&(J.classList.add("fade-out"),setTimeout(()=>{J.remove()},300))},150);return()=>clearTimeout(H)},[L,n,se,xe]),c.useEffect(()=>{if(!L||$!=="malformed")return;const H=document.getElementById("initial-loading");H&&(H.textContent="Desktop startup failed — please restart the app.")},[L,$]),c.useEffect(()=>{if(L)return;const H=setTimeout(()=>{const J=document.getElementById("initial-loading");J&&!n&&(J.classList.add("fade-out"),setTimeout(()=>{J.remove()},300))},5e3);return()=>clearTimeout(H)},[L,n]),c.useEffect(()=>{let H=!1;return(async()=>{const ce=await bs("/health",{method:"GET"}).catch(()=>null);if(!ce||!ce.ok||H)return;const je=await ce.json().catch(()=>null);if(!je||H)return;const G=je.planModeExperimentalEnabled;W(G===!0||G===1||G==="1"||G==="true")})(),()=>{H=!0}},[W]),c.useEffect(()=>{h||e()},[e,h]),c.useEffect(()=>{if(h||n)return;let H=!0,J,ce=0;const je=10,G=1e3,we=async()=>{if(!H)return;if(ce>=je){C(!0);return}const Te=Yt.getState();if(Te.isInitialized){C(!1);return}ce+=1,await Te.initializeApp();const he=Yt.getState();if(!H)return;if(he.isInitialized){C(!1);return}if(ce>=je){C(!0);return}const re=Math.min(G*Math.pow(2,ce-1),16e3);J=setTimeout(we,re)};return J=setTimeout(we,G),()=>{H=!1,J&&clearTimeout(J)}},[v,n,h]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!S)return;const H=document.getElementById("initial-loading");H&&(H.classList.add("fade-out"),setTimeout(()=>{H.remove()},300))},[S]),c.useEffect(()=>{if(h||!r||i>0&&o>0)return;let H=!0,J=0;const ce=15,je=async()=>{const we=Yt.getState();if(!(we.providers.length>0&&we.agents.length>0))try{we.providers.length===0&&await l({source:"startupRecovery"}),Yt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};je();const G=setInterval(()=>{if(H){if(++J>=ce){clearInterval(G);return}je()}},2e3);return()=>{H=!1,clearInterval(G)}},[r,h,a,l,i,o]),c.useEffect(()=>{p||h||r&&dn.setDirectory(m)},[m,p,r,h]),c.useEffect(()=>{if(!Z||typeof window>"u")return;const H=je=>{b(je?.visible===!0)},J=je=>{if(je.origin!==window.location.origin||je.source!==window.parent)return;const G=je.data;G?.type===sf&&H(G.payload)},ce=window;return ce.__openchamberSetEmbeddedVisibility=H,window.addEventListener("message",J),ab(),()=>{window.removeEventListener("message",J),ce.__openchamberSetEmbeddedVisibility===H&&delete ce.__openchamberSetEmbeddedVisibility}},[Z]),c.useEffect(()=>{!Z?.directory||h||m!==Z.directory&&f(Z.directory,{showOverlay:!1})},[m,Z,h,f]),c.useEffect(()=>{if(!Z||typeof window>"u")return;const H=J=>{J.storageArea===window.localStorage&&J.key==="ui-store"&&Ne.persist.rehydrate()};return window.addEventListener("storage",H),()=>{window.removeEventListener("storage",H)}},[Z]),c.useEffect(()=>{if(typeof window>"u")return;const H=J=>{const ce=J.detail,je=typeof ce?.sessionId=="string"?ce.sessionId.trim():"";if(!je)return;const G=typeof ce?.directory=="string"&&ce.directory.trim().length>0?ce.directory.trim():null;rt.getState().setCurrentSession(je,G)};return window.addEventListener("openchamber:open-session",H),()=>window.removeEventListener("openchamber:open-session",H)},[]),c.useEffect(()=>{if(typeof window>"u")return;const H=()=>{Fn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",H),()=>window.removeEventListener("openchamber:open-mini-chat",H)},[]),c.useEffect(()=>{if(typeof window>"u")return;const H=()=>{const J=rt.getState().currentSessionId;J&&Au(J)};return window.addEventListener("focus",H),()=>window.removeEventListener("focus",H)},[]),c.useEffect(()=>{if(typeof window>"u")return;const H=J=>{const ce=J.detail,je=typeof ce?.directory=="string"&&ce.directory.trim().length>0?ce.directory.trim():null,G=typeof ce?.projectId=="string"&&ce.projectId.trim().length>0?ce.projectId.trim():null,we=!!(je||G);Ne.getState().setSessionSwitcherOpen(!1),rt.getState().openNewSessionDraft({target:we?"project":"chat",selectedProjectId:we?G:null,directoryOverride:we?je:null,preserveDirectoryOverride:!!je})};return window.addEventListener("openchamber:open-draft-session",H),()=>window.removeEventListener("openchamber:open-draft-session",H)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||X.current||(X.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),bx({enabled:ne}),uN({enabled:ne}),hN(m||null),xN(),yx(),yN(),wx(),Bx(),Jh();const ie=c.useCallback(()=>{x(H=>!H)},[]);KC(ie),tN(),lN(!Z),c.useEffect(()=>{if(Z)return;const H=()=>x(J=>!J);return window.addEventListener("openchamber:memory-debug-toggle",H),()=>window.removeEventListener("openchamber:memory-debug-toggle",H)},[Z]),c.useEffect(()=>{Z||d&&setTimeout(()=>u(),5e3)},[u,Z,d]),c.useEffect(()=>{if(!L||$!=="not-injected")return;let H=!1,J=0;const ce=200,je=2e3,G=50,we=()=>{if(H)return;J++;const Te=bl();if(Te!=="not-injected"){if(H=!0,P(Te),Te==="valid"){const re=yl();re&&I(wl({isDesktopShell:!0,bootOutcome:re}))}return}const he=Math.min(ce*Math.pow(1.1,J),je);if(J>=G){const re=document.getElementById("initial-loading");re&&!re.textContent?.includes("taking longer")&&(re.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(we,he)};return window.setTimeout(we,ce),()=>{H=!0}},[L,$]);const Re=c.useCallback(async()=>{if(ah({isDesktopShell:xn(),isDesktopLocalOriginActive:Zo()})){await lh();return}window.location.reload()},[]),be=c.useCallback(async()=>{if(!O){C(!1),B(!0);try{await Yt.getState().initializeApp()}finally{B(!1)}Yt.getState().isInitialized||E(H=>H+1)}},[O]),fe=H=>{if(H.screen==="recovery")return H.variant};if(L&&D&&D.screen!=="main"){if(D.screen==="chooser")return s.jsx(Cs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Rd,{mode:"first-launch",localAvailable:D.localAvailable!==!1,onCliAvailable:Re,onChooseRemote:()=>{}})})})});const H=fe(D),J=D.screen==="recovery"&&"url"in D?D.url:void 0;return s.jsx(Cs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Rd,{mode:"recovery",recoveryVariant:H,recoveryHostUrl:J,recoveryHostLabel:void 0,localAvailable:D.localAvailable!==!1,onCliAvailable:Re})})})})}if(Z)return s.jsx(Cs,{children:s.jsx(Vl,{sdk:dn.getSdkClient(),directory:m||"",children:s.jsx(Ul,{apis:t,children:s.jsx(aa,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(PN,{embeddedSessionChat:Z,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:ne}),s.jsx(Hl,{}),s.jsx(Gl,{})]})})})},R)});if(S&&!n&&!h&&!Z)return s.jsx(Cs,{children:s.jsx(NN,{onRetry:()=>{be()},isRetrying:O},R)});const ke=!n&&!L;return s.jsx(Cs,{children:s.jsx(Vl,{sdk:dn.getSdkClient(),directory:m||"",children:s.jsx(Ul,{apis:t,children:s.jsx(uC,{children:s.jsx(aa,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:L?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Hu,{embeddedBackgroundWorkEnabled:ne}),s.jsx(tu,{}),s.jsx($5,{}),s.jsx(Zh,{ready:n&&(!L||se&&xe)}),s.jsx(Gu,{}),s.jsx(Hl,{}),s.jsx(Gl,{}),!ke&&s.jsxs(s.Fragment,{children:[s.jsx(ep,{}),s.jsx(CN,{}),y&&s.jsx(jC,{onClose:()=>x(!1)})]})]})})})})},R)})}function IN(t){const e=tt.c(2);let n;return e[0]!==t?(n=s.jsx(Qh,{children:s.jsx(DN,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function TN(t){return t.isAboutDialogOpen}function EN(t){return t.setAboutDialogOpen}function RN(){}function MN(t){return t.currentDirectory}function ON(t){return t.currentSessionId}function BN(t){return t.setCurrentSession}const FN=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Sx();ch().then(()=>{Promise.all([dh(),jx()]).catch(t=>{console.error("[main] settings init failed:",t)}),kx(),Cx(),Nx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const gm=document.getElementById("root");if(!gm)throw new Error("Root element not found");Ax();Bm.createRoot(gm).render(s.jsx(ut.StrictMode,{children:s.jsx(Px,{children:s.jsx(Dx,{children:s.jsx(Ix,{children:s.jsx(Tx,{children:s.jsx(IN,{apis:FN})})})})})}));const rA=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{By as W,Cy as a,nA as b,bf as g,rA as m,Oy as u,xf as v};